|
| 1 | +import { ConversationType, Direction } from '../types/index.types.js' |
| 2 | + |
| 3 | +const numberCruncher: ConversationType = { |
| 4 | + name: 'numberCruncher', |
| 5 | + label: 'Number Cruncher', |
| 6 | + description: |
| 7 | + 'An admin bot that checks LLM API budget endpoints on a schedule and posts alerts to a Slack channel when spending exceeds configured thresholds', |
| 8 | + platforms: [{ name: 'slack', label: 'Slack' }], |
| 9 | + properties: [ |
| 10 | + { |
| 11 | + name: 'slackChannel', |
| 12 | + label: 'Slack Channel ID', |
| 13 | + description: 'The ID of the Slack channel the bot posts to (starts with C- or G-)', |
| 14 | + required: true, |
| 15 | + type: 'string' |
| 16 | + }, |
| 17 | + { |
| 18 | + name: 'slackWorkspace', |
| 19 | + label: 'Slack Workspace ID', |
| 20 | + description: 'The Slack workspace (team) ID (starts with T-)', |
| 21 | + required: true, |
| 22 | + type: 'string' |
| 23 | + }, |
| 24 | + { |
| 25 | + name: 'slackBotToken', |
| 26 | + label: 'Slack Bot Token', |
| 27 | + description: 'The Bot User OAuth token for the Slack app (starts with xoxb-)', |
| 28 | + required: true, |
| 29 | + type: 'string' |
| 30 | + }, |
| 31 | + { |
| 32 | + name: 'slackBotUserId', |
| 33 | + label: 'Slack Bot User ID', |
| 34 | + description: 'The user ID for the bot in Slack (starts with U-), used for routing incoming messages', |
| 35 | + required: false, |
| 36 | + type: 'string' |
| 37 | + }, |
| 38 | + { |
| 39 | + name: 'slackSigningSecret', |
| 40 | + label: 'Slack App Signing Secret', |
| 41 | + description: 'The signing secret for the Slack app. Defaults to the system-wide signing secret if not provided.', |
| 42 | + required: false, |
| 43 | + type: 'string' |
| 44 | + }, |
| 45 | + { |
| 46 | + name: 'slackAppKey', |
| 47 | + label: 'Slack App Key in Webhook', |
| 48 | + description: 'The app key for the Slack app, used as the last part of the webhook URL to route incoming messages.', |
| 49 | + required: false, |
| 50 | + type: 'string' |
| 51 | + }, |
| 52 | + { |
| 53 | + name: 'botName', |
| 54 | + label: 'Bot Name', |
| 55 | + description: 'The name the bot uses when posting messages.', |
| 56 | + required: false, |
| 57 | + type: 'string', |
| 58 | + default: 'Number Cruncher' |
| 59 | + }, |
| 60 | + { |
| 61 | + name: 'budgets', |
| 62 | + label: 'Budget Configurations (JSON)', |
| 63 | + description: |
| 64 | + 'Array of budget configs. Each entry: { "label": "AWS Bedrock", "endpoint": "https://...", "apiKey": "...", "thresholdPercent": 80 }. Endpoints must return { "quota": { "limit": "250.0" }, "remaining_limit": "199.40" }.', |
| 65 | + required: true, |
| 66 | + type: 'array' |
| 67 | + }, |
| 68 | + { |
| 69 | + name: 'checkInterval', |
| 70 | + label: 'Check Interval (seconds)', |
| 71 | + description: 'How often to check budgets, in seconds. Defaults to 86400 (24 hours).', |
| 72 | + required: false, |
| 73 | + type: 'string', |
| 74 | + default: '86400' |
| 75 | + } |
| 76 | + ], |
| 77 | + // internal |
| 78 | + agents: [ |
| 79 | + { |
| 80 | + name: 'numberCruncher', |
| 81 | + properties: [ |
| 82 | + { $ref: 'botName', as: 'agentConfig.botName' }, |
| 83 | + { $ref: 'budgets', as: 'agentConfig.budgets' }, |
| 84 | + { $ref: 'checkInterval', as: 'triggers.periodic.timerPeriod' }, |
| 85 | + { name: 'proactive', as: 'triggers.periodic.proactive', type: 'boolean', required: false, default: true } |
| 86 | + ] |
| 87 | + } |
| 88 | + ], |
| 89 | + channels: [{ name: 'numberCruncher' }], |
| 90 | + adapters: { |
| 91 | + slack: { |
| 92 | + type: 'slack', |
| 93 | + config: { |
| 94 | + channel: '{{{properties.slackChannel}}}', |
| 95 | + workspace: '{{{properties.slackWorkspace}}}', |
| 96 | + botToken: '{{{properties.slackBotToken}}}', |
| 97 | + botUserId: '{{{properties.slackBotUserId}}}', |
| 98 | + signingSecret: '{{{properties.slackSigningSecret}}}', |
| 99 | + appKey: '{{{properties.slackAppKey}}}' |
| 100 | + }, |
| 101 | + chatChannels: [ |
| 102 | + { |
| 103 | + name: 'numberCruncher', |
| 104 | + direction: Direction.BOTH |
| 105 | + } |
| 106 | + ] |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +export default numberCruncher |
0 commit comments