()
| 519 | * Returns both the App and the Express router to mount |
| 520 | */ |
| 521 | export async function initializeAddieBolt(): Promise<{ app: InstanceType<typeof App>; router: Router } | null> { |
| 522 | const botToken = process.env.ADDIE_BOT_TOKEN || process.env.SLACK_BOT_TOKEN; |
| 523 | const signingSecret = process.env.ADDIE_SIGNING_SECRET || process.env.SLACK_SIGNING_SECRET; |
| 524 | const anthropicKey = process.env.ADDIE_ANTHROPIC_API_KEY || process.env.ANTHROPIC_API_KEY; |
| 525 | |
| 526 | if (!botToken || !signingSecret) { |
| 527 | logger.warn('Addie Bolt: Missing ADDIE_BOT_TOKEN or ADDIE_SIGNING_SECRET, Addie will be disabled'); |
| 528 | return null; |
| 529 | } |
| 530 | |
| 531 | if (!anthropicKey) { |
| 532 | logger.warn('Addie Bolt: Missing ANTHROPIC_API_KEY, Addie will be disabled'); |
| 533 | return null; |
| 534 | } |
| 535 | |
| 536 | logger.info('Addie Bolt: Initializing...'); |
| 537 | |
| 538 | // Initialize Claude client |
| 539 | claudeClient = new AddieClaudeClient(anthropicKey, AddieModelConfig.chat); |
| 540 | |
| 541 | // Initialize router (uses Haiku for fast classification) |
| 542 | addieRouter = new AddieRouter(anthropicKey); |
| 543 | |
| 544 | // Initialize database access |
| 545 | addieDb = new AddieDatabase(); |
| 546 | |
| 547 | // Initialize thread context store |
| 548 | threadContextStore = new DatabaseThreadContextStore(addieDb); |
| 549 | |
| 550 | // Register shared baseline tools (knowledge, billing, schema, directory, brand, property) |
| 551 | // Shared with web chat handler via register-baseline-tools.ts |
| 552 | await registerBaselineTools(claudeClient); |
| 553 | |
| 554 | // Register Slack-specific tools below (these need Slack context) |
| 555 | |
| 556 | // Register URL fetching tools (for reading links and files shared in Slack) |
| 557 | const urlHandlers = createUrlToolHandlers(botToken); |
| 558 | for (const tool of URL_TOOLS) { |
| 559 | const handler = urlHandlers[tool.name]; |
| 560 | if (handler) { |
| 561 | claudeClient.registerTool(tool, handler); |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | // Register Google Docs tools (for reading Google Docs/Drive files) |
| 566 | const googleDocsHandlers = createGoogleDocsToolHandlers(); |
| 567 | if (googleDocsHandlers) { |
| 568 | for (const tool of GOOGLE_DOCS_TOOLS) { |
| 569 | const handler = googleDocsHandlers[tool.name]; |
| 570 | if (handler) { |
| 571 | claudeClient.registerTool(tool, handler); |
| 572 | } |
| 573 | } |
| 574 | logger.info('Addie: Google Docs tools registered'); |
| 575 | } |
| 576 | |
| 577 | // Register SI host tools (Sponsored Intelligence protocol) |
| 578 | // These enable Addy to connect users with AAO member brand agents |
no test coverage detected