@hailer/mcp 1.2.1 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/agent-hailer-helper.md +118 -0
- package/.claude/commands/debug-squad.md +13 -290
- package/.claude/commands/publish.md +2 -2
- package/.claude/commands/review-squad.md +17 -139
- package/.claude/skills/create-and-publish-app/SKILL.md +133 -143
- package/.claude/skills/hailer-app-builder/SKILL.md +29 -2
- package/.claude/skills/hailer-ui-guide/SKILL.md +265 -0
- package/.env.example +50 -1
- package/CLAUDE.md +141 -10
- package/dist/app-prep.d.ts +27 -0
- package/dist/app-prep.d.ts.map +1 -0
- package/dist/app-prep.js +94 -0
- package/dist/app-prep.js.map +1 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +3 -0
- package/dist/app.js.map +1 -1
- package/dist/bot/bot-manager.d.ts +9 -6
- package/dist/bot/bot-manager.d.ts.map +1 -1
- package/dist/bot/bot-manager.js +142 -31
- package/dist/bot/bot-manager.js.map +1 -1
- package/dist/bot/bot.d.ts +61 -16
- package/dist/bot/bot.d.ts.map +1 -1
- package/dist/bot/bot.js +927 -151
- package/dist/bot/bot.js.map +1 -1
- package/dist/bot/operation-logger.d.ts.map +1 -1
- package/dist/bot/operation-logger.js +24 -12
- package/dist/bot/operation-logger.js.map +1 -1
- package/dist/bot/services/bot-permissions.d.ts +37 -5
- package/dist/bot/services/bot-permissions.d.ts.map +1 -1
- package/dist/bot/services/bot-permissions.js +159 -35
- package/dist/bot/services/bot-permissions.js.map +1 -1
- package/dist/bot/services/conversation-manager.d.ts +23 -23
- package/dist/bot/services/conversation-manager.d.ts.map +1 -1
- package/dist/bot/services/conversation-manager.js +52 -49
- package/dist/bot/services/conversation-manager.js.map +1 -1
- package/dist/bot/services/helper-prompt.d.ts +8 -0
- package/dist/bot/services/helper-prompt.d.ts.map +1 -0
- package/dist/bot/services/helper-prompt.js +177 -0
- package/dist/bot/services/helper-prompt.js.map +1 -0
- package/dist/bot/services/message-classifier.d.ts +16 -16
- package/dist/bot/services/message-classifier.d.ts.map +1 -1
- package/dist/bot/services/message-classifier.js +55 -49
- package/dist/bot/services/message-classifier.js.map +1 -1
- package/dist/bot/services/message-formatter.d.ts +47 -38
- package/dist/bot/services/message-formatter.d.ts.map +1 -1
- package/dist/bot/services/message-formatter.js +99 -80
- package/dist/bot/services/message-formatter.js.map +1 -1
- package/dist/bot/services/permission-guard.d.ts.map +1 -1
- package/dist/bot/services/permission-guard.js +20 -10
- package/dist/bot/services/permission-guard.js.map +1 -1
- package/dist/bot/services/signal-router.d.ts.map +1 -1
- package/dist/bot/services/signal-router.js +11 -6
- package/dist/bot/services/signal-router.js.map +1 -1
- package/dist/bot/services/system-prompt.d.ts +14 -0
- package/dist/bot/services/system-prompt.d.ts.map +1 -1
- package/dist/bot/services/system-prompt.js +181 -4
- package/dist/bot/services/system-prompt.js.map +1 -1
- package/dist/bot/services/token-billing.d.ts +23 -23
- package/dist/bot/services/token-billing.d.ts.map +1 -1
- package/dist/bot/services/token-billing.js +51 -36
- package/dist/bot/services/token-billing.js.map +1 -1
- package/dist/bot/services/types.d.ts +3 -1
- package/dist/bot/services/types.d.ts.map +1 -1
- package/dist/bot/services/typing-indicator.d.ts +8 -8
- package/dist/bot/services/typing-indicator.d.ts.map +1 -1
- package/dist/bot/services/typing-indicator.js +12 -10
- package/dist/bot/services/typing-indicator.js.map +1 -1
- package/dist/bot/services/workspace-refresh.d.ts +3 -3
- package/dist/bot/services/workspace-refresh.d.ts.map +1 -1
- package/dist/bot/services/workspace-refresh.js +23 -13
- package/dist/bot/services/workspace-refresh.js.map +1 -1
- package/dist/bot/tool-executor.d.ts +10 -6
- package/dist/bot/tool-executor.d.ts.map +1 -1
- package/dist/bot/tool-executor.js +12 -6
- package/dist/bot/tool-executor.js.map +1 -1
- package/dist/bot/workspace-overview.d.ts.map +1 -1
- package/dist/bot/workspace-overview.js +6 -3
- package/dist/bot/workspace-overview.js.map +1 -1
- package/dist/bot-config/activity-error.d.ts +47 -0
- package/dist/bot-config/activity-error.d.ts.map +1 -0
- package/dist/bot-config/activity-error.js +67 -0
- package/dist/bot-config/activity-error.js.map +1 -0
- package/dist/bot-config/context.d.ts +4 -4
- package/dist/bot-config/context.d.ts.map +1 -1
- package/dist/bot-config/context.js +18 -14
- package/dist/bot-config/context.js.map +1 -1
- package/dist/bot-config/events.d.ts +45 -0
- package/dist/bot-config/events.d.ts.map +1 -0
- package/dist/bot-config/events.js +51 -0
- package/dist/bot-config/events.js.map +1 -0
- package/dist/bot-config/index.d.ts +3 -0
- package/dist/bot-config/index.d.ts.map +1 -1
- package/dist/bot-config/index.js +8 -1
- package/dist/bot-config/index.js.map +1 -1
- package/dist/bot-config/loader.d.ts +3 -0
- package/dist/bot-config/loader.d.ts.map +1 -1
- package/dist/bot-config/loader.js +45 -20
- package/dist/bot-config/loader.js.map +1 -1
- package/dist/bot-config/persistence.js.map +1 -1
- package/dist/bot-config/reconciler.d.ts +11 -0
- package/dist/bot-config/reconciler.d.ts.map +1 -0
- package/dist/bot-config/reconciler.js +121 -0
- package/dist/bot-config/reconciler.js.map +1 -0
- package/dist/bot-config/state.d.ts.map +1 -1
- package/dist/bot-config/state.js.map +1 -1
- package/dist/bot-config/types.d.ts +32 -0
- package/dist/bot-config/types.d.ts.map +1 -1
- package/dist/bot-config/webhooks.d.ts.map +1 -1
- package/dist/bot-config/webhooks.js.map +1 -1
- package/dist/bot-config/workflow-installer.d.ts +37 -0
- package/dist/bot-config/workflow-installer.d.ts.map +1 -0
- package/dist/bot-config/workflow-installer.js +346 -0
- package/dist/bot-config/workflow-installer.js.map +1 -0
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +92 -11
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +23 -19
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +65 -27
- package/dist/config.js.map +1 -1
- package/dist/core.d.ts +6 -4
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +11 -16
- package/dist/core.js.map +1 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +7 -4
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/request-logger.d.ts +19 -19
- package/dist/lib/request-logger.d.ts.map +1 -1
- package/dist/lib/request-logger.js +19 -19
- package/dist/lib/request-logger.js.map +1 -1
- package/dist/mcp/UserContextCache.d.ts +28 -22
- package/dist/mcp/UserContextCache.d.ts.map +1 -1
- package/dist/mcp/UserContextCache.js +23 -23
- package/dist/mcp/UserContextCache.js.map +1 -1
- package/dist/mcp/auth.js.map +1 -1
- package/dist/mcp/hailer-clients.d.ts +5 -4
- package/dist/mcp/hailer-clients.d.ts.map +1 -1
- package/dist/mcp/hailer-clients.js +83 -34
- package/dist/mcp/hailer-clients.js.map +1 -1
- package/dist/mcp/hailer-rpc.d.ts +40 -0
- package/dist/mcp/hailer-rpc.d.ts.map +1 -0
- package/dist/mcp/hailer-rpc.js +43 -0
- package/dist/mcp/hailer-rpc.js.map +1 -0
- package/dist/mcp/publish-auth-injector.d.ts +22 -0
- package/dist/mcp/publish-auth-injector.d.ts.map +1 -0
- package/dist/mcp/publish-auth-injector.js +100 -0
- package/dist/mcp/publish-auth-injector.js.map +1 -0
- package/dist/mcp/session-store.d.ts +16 -16
- package/dist/mcp/session-store.d.ts.map +1 -1
- package/dist/mcp/session-store.js +16 -16
- package/dist/mcp/session-store.js.map +1 -1
- package/dist/mcp/tool-profiles.d.ts +69 -0
- package/dist/mcp/tool-profiles.d.ts.map +1 -0
- package/dist/mcp/tool-profiles.js +184 -0
- package/dist/mcp/tool-profiles.js.map +1 -0
- package/dist/mcp/tool-registry.d.ts +16 -0
- package/dist/mcp/tool-registry.d.ts.map +1 -1
- package/dist/mcp/tool-registry.js +91 -39
- package/dist/mcp/tool-registry.js.map +1 -1
- package/dist/mcp/tools/activity.d.ts +2 -0
- package/dist/mcp/tools/activity.d.ts.map +1 -1
- package/dist/mcp/tools/activity.js +575 -218
- package/dist/mcp/tools/activity.js.map +1 -1
- package/dist/mcp/tools/aliases.d.ts +11 -0
- package/dist/mcp/tools/aliases.d.ts.map +1 -0
- package/dist/mcp/tools/aliases.js +182 -0
- package/dist/mcp/tools/aliases.js.map +1 -0
- package/dist/mcp/tools/app-core.d.ts +6 -8
- package/dist/mcp/tools/app-core.d.ts.map +1 -1
- package/dist/mcp/tools/app-core.js +355 -254
- package/dist/mcp/tools/app-core.js.map +1 -1
- package/dist/mcp/tools/app-marketplace.d.ts +12 -16
- package/dist/mcp/tools/app-marketplace.d.ts.map +1 -1
- package/dist/mcp/tools/app-marketplace.js +748 -856
- package/dist/mcp/tools/app-marketplace.js.map +1 -1
- package/dist/mcp/tools/app.d.ts +4 -7
- package/dist/mcp/tools/app.d.ts.map +1 -1
- package/dist/mcp/tools/app.js +4 -7
- package/dist/mcp/tools/app.js.map +1 -1
- package/dist/mcp/tools/bot-self.d.ts +21 -0
- package/dist/mcp/tools/bot-self.d.ts.map +1 -0
- package/dist/mcp/tools/bot-self.js +174 -0
- package/dist/mcp/tools/bot-self.js.map +1 -0
- package/dist/mcp/tools/calendar.d.ts +21 -0
- package/dist/mcp/tools/calendar.d.ts.map +1 -0
- package/dist/mcp/tools/calendar.js +741 -0
- package/dist/mcp/tools/calendar.js.map +1 -0
- package/dist/mcp/tools/company.d.ts.map +1 -1
- package/dist/mcp/tools/company.js +2 -1
- package/dist/mcp/tools/company.js.map +1 -1
- package/dist/mcp/tools/date.js.map +1 -1
- package/dist/mcp/tools/discussion.d.ts +29 -3
- package/dist/mcp/tools/discussion.d.ts.map +1 -1
- package/dist/mcp/tools/discussion.js +419 -534
- package/dist/mcp/tools/discussion.js.map +1 -1
- package/dist/mcp/tools/file.d.ts.map +1 -1
- package/dist/mcp/tools/file.js +18 -16
- package/dist/mcp/tools/file.js.map +1 -1
- package/dist/mcp/tools/index.js +4 -4
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/insight.d.ts +24 -5
- package/dist/mcp/tools/insight.d.ts.map +1 -1
- package/dist/mcp/tools/insight.js +513 -480
- package/dist/mcp/tools/insight.js.map +1 -1
- package/dist/mcp/tools/user.d.ts.map +1 -1
- package/dist/mcp/tools/user.js +15 -13
- package/dist/mcp/tools/user.js.map +1 -1
- package/dist/mcp/tools/workflow-permissions.d.ts +2 -4
- package/dist/mcp/tools/workflow-permissions.d.ts.map +1 -1
- package/dist/mcp/tools/workflow-permissions.js +88 -97
- package/dist/mcp/tools/workflow-permissions.js.map +1 -1
- package/dist/mcp/tools/workflow.d.ts +9 -7
- package/dist/mcp/tools/workflow.d.ts.map +1 -1
- package/dist/mcp/tools/workflow.js +852 -860
- package/dist/mcp/tools/workflow.js.map +1 -1
- package/dist/mcp/utils/api-errors.d.ts.map +1 -1
- package/dist/mcp/utils/api-errors.js +2 -2
- package/dist/mcp/utils/api-errors.js.map +1 -1
- package/dist/mcp/utils/data-transformers.d.ts +0 -3
- package/dist/mcp/utils/data-transformers.d.ts.map +1 -1
- package/dist/mcp/utils/data-transformers.js +32 -5
- package/dist/mcp/utils/data-transformers.js.map +1 -1
- package/dist/mcp/utils/file-upload.d.ts.map +1 -1
- package/dist/mcp/utils/file-upload.js +1 -1
- package/dist/mcp/utils/file-upload.js.map +1 -1
- package/dist/mcp/utils/hailer-api-client.d.ts +81 -81
- package/dist/mcp/utils/hailer-api-client.d.ts.map +1 -1
- package/dist/mcp/utils/hailer-api-client.js +113 -103
- package/dist/mcp/utils/hailer-api-client.js.map +1 -1
- package/dist/mcp/utils/index.d.ts.map +1 -1
- package/dist/mcp/utils/index.js.map +1 -1
- package/dist/mcp/utils/logger.d.ts.map +1 -1
- package/dist/mcp/utils/logger.js.map +1 -1
- package/dist/mcp/utils/response-builder.d.ts.map +1 -1
- package/dist/mcp/utils/response-builder.js +8 -4
- package/dist/mcp/utils/response-builder.js.map +1 -1
- package/dist/mcp/utils/role-utils.d.ts.map +1 -1
- package/dist/mcp/utils/role-utils.js +6 -3
- package/dist/mcp/utils/role-utils.js.map +1 -1
- package/dist/mcp/utils/tool-helpers.d.ts.map +1 -1
- package/dist/mcp/utils/tool-helpers.js +2 -2
- package/dist/mcp/utils/tool-helpers.js.map +1 -1
- package/dist/mcp/utils/types.d.ts +2 -1
- package/dist/mcp/utils/types.d.ts.map +1 -1
- package/dist/mcp/utils/types.js.map +1 -1
- package/dist/mcp/webhook-handler.d.ts +43 -8
- package/dist/mcp/webhook-handler.d.ts.map +1 -1
- package/dist/mcp/webhook-handler.js +861 -116
- package/dist/mcp/webhook-handler.js.map +1 -1
- package/dist/mcp/workspace-admin-store.d.ts +49 -0
- package/dist/mcp/workspace-admin-store.d.ts.map +1 -0
- package/dist/mcp/workspace-admin-store.js +168 -0
- package/dist/mcp/workspace-admin-store.js.map +1 -0
- package/dist/mcp/workspace-cache.d.ts +2 -2
- package/dist/mcp/workspace-cache.d.ts.map +1 -1
- package/dist/mcp/workspace-cache.js +9 -5
- package/dist/mcp/workspace-cache.js.map +1 -1
- package/dist/mcp-server.d.ts +26 -11
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +367 -48
- package/dist/mcp-server.js.map +1 -1
- package/dist/plugins/vipunen/client.d.ts +41 -41
- package/dist/plugins/vipunen/client.d.ts.map +1 -1
- package/dist/plugins/vipunen/client.js +53 -48
- package/dist/plugins/vipunen/client.js.map +1 -1
- package/dist/plugins/vipunen/index.js.map +1 -1
- package/dist/plugins/vipunen/tools.d.ts.map +1 -1
- package/dist/plugins/vipunen/tools.js +6 -3
- package/dist/plugins/vipunen/tools.js.map +1 -1
- package/dist/public-chat/graduate.d.ts +29 -0
- package/dist/public-chat/graduate.d.ts.map +1 -0
- package/dist/public-chat/graduate.js +593 -0
- package/dist/public-chat/graduate.js.map +1 -0
- package/dist/public-chat/handler.d.ts +12 -0
- package/dist/public-chat/handler.d.ts.map +1 -0
- package/dist/public-chat/handler.js +183 -0
- package/dist/public-chat/handler.js.map +1 -0
- package/dist/public-chat/index.d.ts +16 -0
- package/dist/public-chat/index.d.ts.map +1 -0
- package/dist/public-chat/index.js +74 -0
- package/dist/public-chat/index.js.map +1 -0
- package/dist/public-chat/knowledge.d.ts +3 -0
- package/dist/public-chat/knowledge.d.ts.map +1 -0
- package/dist/public-chat/knowledge.js +1340 -0
- package/dist/public-chat/knowledge.js.map +1 -0
- package/dist/public-chat/rate-limit.d.ts +16 -0
- package/dist/public-chat/rate-limit.d.ts.map +1 -0
- package/dist/public-chat/rate-limit.js +51 -0
- package/dist/public-chat/rate-limit.js.map +1 -0
- package/dist/public-chat/session-store.d.ts +41 -0
- package/dist/public-chat/session-store.d.ts.map +1 -0
- package/dist/public-chat/session-store.js +95 -0
- package/dist/public-chat/session-store.js.map +1 -0
- package/dist/public-chat/studio-prewarm.d.ts +61 -0
- package/dist/public-chat/studio-prewarm.d.ts.map +1 -0
- package/dist/public-chat/studio-prewarm.js +162 -0
- package/dist/public-chat/studio-prewarm.js.map +1 -0
- package/dist/public-chat/system-prompt.d.ts +22 -0
- package/dist/public-chat/system-prompt.d.ts.map +1 -0
- package/dist/public-chat/system-prompt.js +435 -0
- package/dist/public-chat/system-prompt.js.map +1 -0
- package/package.json +13 -7
- package/scripts/build-public-chat-knowledge.py +101 -0
- package/scripts/smoke-public-chat-live.ts +148 -0
- package/scripts/smoke-public-chat.ts +110 -0
- package/.claude/CLAUDE.md +0 -126
- package/.claude/commands/app-squad.md +0 -131
- package/.claude/commands/audit-squad.md +0 -158
- package/.claude/commands/cleanup-squad.md +0 -98
- package/.claude/commands/config-squad.md +0 -106
- package/.claude/commands/crud-squad.md +0 -87
- package/.claude/commands/data-squad.md +0 -97
- package/.claude/commands/doc-squad.md +0 -65
- package/.claude/commands/help.md +0 -29
- package/.claude/commands/help:agents.md +0 -182
- package/.claude/commands/help:commands.md +0 -78
- package/.claude/commands/help:faq.md +0 -79
- package/.claude/commands/help:plugins.md +0 -50
- package/.claude/commands/help:skills.md +0 -87
- package/.claude/commands/help:tools.md +0 -75
- package/.claude/commands/hotfix-squad.md +0 -112
- package/.claude/commands/integration-squad.md +0 -82
- package/.claude/commands/janitor-squad.md +0 -167
- package/.claude/commands/onboard-squad.md +0 -130
- package/.claude/commands/swarm.md +0 -210
- package/.claude/commands/tool-builder.md +0 -39
- package/.claude/skills/publish-hailer-app/SKILL.md +0 -280
- package/dist/CLAUDE.md +0 -370
- package/dist/agents/bot-manager.d.ts +0 -48
- package/dist/agents/bot-manager.d.ts.map +0 -1
- package/dist/agents/bot-manager.js +0 -254
- package/dist/agents/bot-manager.js.map +0 -1
- package/dist/agents/bug-fixer/ai.d.ts +0 -80
- package/dist/agents/bug-fixer/ai.d.ts.map +0 -1
- package/dist/agents/bug-fixer/ai.js +0 -466
- package/dist/agents/bug-fixer/ai.js.map +0 -1
- package/dist/agents/bug-fixer/bot.d.ts +0 -92
- package/dist/agents/bug-fixer/bot.d.ts.map +0 -1
- package/dist/agents/bug-fixer/bot.js +0 -687
- package/dist/agents/bug-fixer/bot.js.map +0 -1
- package/dist/agents/bug-fixer/config.d.ts +0 -21
- package/dist/agents/bug-fixer/config.d.ts.map +0 -1
- package/dist/agents/bug-fixer/config.js +0 -218
- package/dist/agents/bug-fixer/config.js.map +0 -1
- package/dist/agents/bug-fixer/files.d.ts +0 -67
- package/dist/agents/bug-fixer/files.d.ts.map +0 -1
- package/dist/agents/bug-fixer/files.js +0 -386
- package/dist/agents/bug-fixer/files.js.map +0 -1
- package/dist/agents/bug-fixer/git.d.ts +0 -48
- package/dist/agents/bug-fixer/git.d.ts.map +0 -1
- package/dist/agents/bug-fixer/git.js +0 -298
- package/dist/agents/bug-fixer/git.js.map +0 -1
- package/dist/agents/bug-fixer/index.d.ts +0 -103
- package/dist/agents/bug-fixer/index.d.ts.map +0 -1
- package/dist/agents/bug-fixer/index.js +0 -262
- package/dist/agents/bug-fixer/index.js.map +0 -1
- package/dist/agents/bug-fixer/lsp.d.ts +0 -113
- package/dist/agents/bug-fixer/lsp.d.ts.map +0 -1
- package/dist/agents/bug-fixer/lsp.js +0 -485
- package/dist/agents/bug-fixer/lsp.js.map +0 -1
- package/dist/agents/bug-fixer/monitor.d.ts +0 -123
- package/dist/agents/bug-fixer/monitor.d.ts.map +0 -1
- package/dist/agents/bug-fixer/monitor.js +0 -629
- package/dist/agents/bug-fixer/monitor.js.map +0 -1
- package/dist/agents/bug-fixer/prompt.d.ts +0 -5
- package/dist/agents/bug-fixer/prompt.d.ts.map +0 -1
- package/dist/agents/bug-fixer/prompt.js +0 -94
- package/dist/agents/bug-fixer/prompt.js.map +0 -1
- package/dist/agents/bug-fixer/registries/pending-classification.d.ts +0 -28
- package/dist/agents/bug-fixer/registries/pending-classification.d.ts.map +0 -1
- package/dist/agents/bug-fixer/registries/pending-classification.js +0 -50
- package/dist/agents/bug-fixer/registries/pending-classification.js.map +0 -1
- package/dist/agents/bug-fixer/registries/pending-fix.d.ts +0 -33
- package/dist/agents/bug-fixer/registries/pending-fix.d.ts.map +0 -1
- package/dist/agents/bug-fixer/registries/pending-fix.js +0 -64
- package/dist/agents/bug-fixer/registries/pending-fix.js.map +0 -1
- package/dist/agents/bug-fixer/registries/pending.d.ts +0 -27
- package/dist/agents/bug-fixer/registries/pending.d.ts.map +0 -1
- package/dist/agents/bug-fixer/registries/pending.js +0 -49
- package/dist/agents/bug-fixer/registries/pending.js.map +0 -1
- package/dist/agents/bug-fixer/specialist-daemon.d.ts +0 -88
- package/dist/agents/bug-fixer/specialist-daemon.d.ts.map +0 -1
- package/dist/agents/bug-fixer/specialist-daemon.js +0 -431
- package/dist/agents/bug-fixer/specialist-daemon.js.map +0 -1
- package/dist/agents/bug-fixer/specialist.d.ts +0 -47
- package/dist/agents/bug-fixer/specialist.d.ts.map +0 -1
- package/dist/agents/bug-fixer/specialist.js +0 -327
- package/dist/agents/bug-fixer/specialist.js.map +0 -1
- package/dist/agents/bug-fixer/types.d.ts +0 -123
- package/dist/agents/bug-fixer/types.d.ts.map +0 -1
- package/dist/agents/bug-fixer/types.js +0 -9
- package/dist/agents/bug-fixer/types.js.map +0 -1
- package/dist/agents/factory.d.ts +0 -172
- package/dist/agents/factory.d.ts.map +0 -1
- package/dist/agents/factory.js +0 -706
- package/dist/agents/factory.js.map +0 -1
- package/dist/agents/hailer-expert/index.d.ts +0 -8
- package/dist/agents/hailer-expert/index.d.ts.map +0 -1
- package/dist/agents/hailer-expert/index.js +0 -14
- package/dist/agents/hailer-expert/index.js.map +0 -1
- package/dist/agents/hal/daemon.d.ts +0 -174
- package/dist/agents/hal/daemon.d.ts.map +0 -1
- package/dist/agents/hal/daemon.js +0 -1385
- package/dist/agents/hal/daemon.js.map +0 -1
- package/dist/agents/hal/definitions.d.ts +0 -42
- package/dist/agents/hal/definitions.d.ts.map +0 -1
- package/dist/agents/hal/definitions.js +0 -300
- package/dist/agents/hal/definitions.js.map +0 -1
- package/dist/agents/hal/index.d.ts +0 -3
- package/dist/agents/hal/index.d.ts.map +0 -1
- package/dist/agents/hal/index.js +0 -8
- package/dist/agents/hal/index.js.map +0 -1
- package/dist/agents/index.d.ts +0 -18
- package/dist/agents/index.d.ts.map +0 -1
- package/dist/agents/index.js +0 -48
- package/dist/agents/index.js.map +0 -1
- package/dist/agents/shared/base.d.ts +0 -253
- package/dist/agents/shared/base.d.ts.map +0 -1
- package/dist/agents/shared/base.js +0 -1122
- package/dist/agents/shared/base.js.map +0 -1
- package/dist/agents/shared/schemas/action-schema.d.ts +0 -62
- package/dist/agents/shared/schemas/action-schema.d.ts.map +0 -1
- package/dist/agents/shared/schemas/action-schema.js +0 -483
- package/dist/agents/shared/schemas/action-schema.js.map +0 -1
- package/dist/agents/shared/services/agent-registry.d.ts +0 -108
- package/dist/agents/shared/services/agent-registry.d.ts.map +0 -1
- package/dist/agents/shared/services/agent-registry.js +0 -469
- package/dist/agents/shared/services/agent-registry.js.map +0 -1
- package/dist/agents/shared/services/conversation-manager.d.ts +0 -57
- package/dist/agents/shared/services/conversation-manager.d.ts.map +0 -1
- package/dist/agents/shared/services/conversation-manager.js +0 -168
- package/dist/agents/shared/services/conversation-manager.js.map +0 -1
- package/dist/agents/shared/services/mcp-client.d.ts +0 -56
- package/dist/agents/shared/services/mcp-client.d.ts.map +0 -1
- package/dist/agents/shared/services/mcp-client.js +0 -124
- package/dist/agents/shared/services/mcp-client.js.map +0 -1
- package/dist/agents/shared/services/message-classifier.d.ts +0 -37
- package/dist/agents/shared/services/message-classifier.d.ts.map +0 -1
- package/dist/agents/shared/services/message-classifier.js +0 -203
- package/dist/agents/shared/services/message-classifier.js.map +0 -1
- package/dist/agents/shared/services/message-formatter.d.ts +0 -89
- package/dist/agents/shared/services/message-formatter.d.ts.map +0 -1
- package/dist/agents/shared/services/message-formatter.js +0 -390
- package/dist/agents/shared/services/message-formatter.js.map +0 -1
- package/dist/agents/shared/services/session-logger.d.ts +0 -162
- package/dist/agents/shared/services/session-logger.d.ts.map +0 -1
- package/dist/agents/shared/services/session-logger.js +0 -724
- package/dist/agents/shared/services/session-logger.js.map +0 -1
- package/dist/agents/shared/services/structured-output-executor.d.ts +0 -88
- package/dist/agents/shared/services/structured-output-executor.d.ts.map +0 -1
- package/dist/agents/shared/services/structured-output-executor.js +0 -296
- package/dist/agents/shared/services/structured-output-executor.js.map +0 -1
- package/dist/agents/shared/services/token-billing.d.ts +0 -72
- package/dist/agents/shared/services/token-billing.d.ts.map +0 -1
- package/dist/agents/shared/services/token-billing.js +0 -198
- package/dist/agents/shared/services/token-billing.js.map +0 -1
- package/dist/agents/shared/services/tool-executor.d.ts +0 -43
- package/dist/agents/shared/services/tool-executor.d.ts.map +0 -1
- package/dist/agents/shared/services/tool-executor.js +0 -175
- package/dist/agents/shared/services/tool-executor.js.map +0 -1
- package/dist/agents/shared/services/typing-indicator.d.ts +0 -24
- package/dist/agents/shared/services/typing-indicator.d.ts.map +0 -1
- package/dist/agents/shared/services/typing-indicator.js +0 -54
- package/dist/agents/shared/services/typing-indicator.js.map +0 -1
- package/dist/agents/shared/services/workspace-schema-cache.d.ts +0 -122
- package/dist/agents/shared/services/workspace-schema-cache.d.ts.map +0 -1
- package/dist/agents/shared/services/workspace-schema-cache.js +0 -507
- package/dist/agents/shared/services/workspace-schema-cache.js.map +0 -1
- package/dist/agents/shared/specialist.d.ts +0 -91
- package/dist/agents/shared/specialist.d.ts.map +0 -1
- package/dist/agents/shared/specialist.js +0 -399
- package/dist/agents/shared/specialist.js.map +0 -1
- package/dist/agents/shared/tool-schema-loader.d.ts +0 -65
- package/dist/agents/shared/tool-schema-loader.d.ts.map +0 -1
- package/dist/agents/shared/tool-schema-loader.js +0 -238
- package/dist/agents/shared/tool-schema-loader.js.map +0 -1
- package/dist/agents/shared/types.d.ts +0 -190
- package/dist/agents/shared/types.d.ts.map +0 -1
- package/dist/agents/shared/types.js +0 -13
- package/dist/agents/shared/types.js.map +0 -1
- package/dist/bot/bot-config.d.ts +0 -37
- package/dist/bot/bot-config.d.ts.map +0 -1
- package/dist/bot/bot-config.js +0 -219
- package/dist/bot/bot-config.js.map +0 -1
- package/dist/bot/services/__tests__/permission-guard.test.d.ts +0 -2
- package/dist/bot/services/__tests__/permission-guard.test.d.ts.map +0 -1
- package/dist/bot/services/__tests__/permission-guard.test.js +0 -357
- package/dist/bot/services/__tests__/permission-guard.test.js.map +0 -1
- package/dist/bot/services/session-logger.d.ts +0 -162
- package/dist/bot/services/session-logger.d.ts.map +0 -1
- package/dist/bot/services/session-logger.js +0 -724
- package/dist/bot/services/session-logger.js.map +0 -1
- package/dist/bot/services/workspace-schema-cache.d.ts +0 -122
- package/dist/bot/services/workspace-schema-cache.d.ts.map +0 -1
- package/dist/bot/services/workspace-schema-cache.js +0 -506
- package/dist/bot/services/workspace-schema-cache.js.map +0 -1
- package/dist/bot-config/tools.d.ts +0 -28
- package/dist/bot-config/tools.d.ts.map +0 -1
- package/dist/bot-config/tools.js +0 -279
- package/dist/bot-config/tools.js.map +0 -1
- package/dist/client/agents/base.d.ts +0 -207
- package/dist/client/agents/base.d.ts.map +0 -1
- package/dist/client/agents/base.js +0 -744
- package/dist/client/agents/base.js.map +0 -1
- package/dist/client/agents/definitions.d.ts +0 -53
- package/dist/client/agents/definitions.d.ts.map +0 -1
- package/dist/client/agents/definitions.js +0 -263
- package/dist/client/agents/definitions.js.map +0 -1
- package/dist/client/agents/orchestrator.d.ts +0 -141
- package/dist/client/agents/orchestrator.d.ts.map +0 -1
- package/dist/client/agents/orchestrator.js +0 -1062
- package/dist/client/agents/orchestrator.js.map +0 -1
- package/dist/client/agents/specialist.d.ts +0 -86
- package/dist/client/agents/specialist.d.ts.map +0 -1
- package/dist/client/agents/specialist.js +0 -340
- package/dist/client/agents/specialist.js.map +0 -1
- package/dist/client/bot-entrypoint.d.ts +0 -7
- package/dist/client/bot-entrypoint.d.ts.map +0 -1
- package/dist/client/bot-entrypoint.js +0 -103
- package/dist/client/bot-entrypoint.js.map +0 -1
- package/dist/client/bot-manager.d.ts +0 -44
- package/dist/client/bot-manager.d.ts.map +0 -1
- package/dist/client/bot-manager.js +0 -173
- package/dist/client/bot-manager.js.map +0 -1
- package/dist/client/bot-runner.d.ts +0 -35
- package/dist/client/bot-runner.d.ts.map +0 -1
- package/dist/client/bot-runner.js +0 -188
- package/dist/client/bot-runner.js.map +0 -1
- package/dist/client/chat-agent-daemon.d.ts +0 -464
- package/dist/client/chat-agent-daemon.d.ts.map +0 -1
- package/dist/client/chat-agent-daemon.js +0 -1774
- package/dist/client/chat-agent-daemon.js.map +0 -1
- package/dist/client/daemon-factory.d.ts +0 -106
- package/dist/client/daemon-factory.d.ts.map +0 -1
- package/dist/client/daemon-factory.js +0 -301
- package/dist/client/daemon-factory.js.map +0 -1
- package/dist/client/factory.d.ts +0 -111
- package/dist/client/factory.d.ts.map +0 -1
- package/dist/client/factory.js +0 -314
- package/dist/client/factory.js.map +0 -1
- package/dist/client/index.d.ts +0 -17
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -38
- package/dist/client/index.js.map +0 -1
- package/dist/client/multi-bot-manager.d.ts +0 -42
- package/dist/client/multi-bot-manager.d.ts.map +0 -1
- package/dist/client/multi-bot-manager.js +0 -161
- package/dist/client/multi-bot-manager.js.map +0 -1
- package/dist/client/orchestrator-daemon.d.ts +0 -87
- package/dist/client/orchestrator-daemon.d.ts.map +0 -1
- package/dist/client/orchestrator-daemon.js +0 -444
- package/dist/client/orchestrator-daemon.js.map +0 -1
- package/dist/client/server.d.ts +0 -8
- package/dist/client/server.d.ts.map +0 -1
- package/dist/client/server.js +0 -251
- package/dist/client/server.js.map +0 -1
- package/dist/client/services/agent-registry.d.ts +0 -108
- package/dist/client/services/agent-registry.d.ts.map +0 -1
- package/dist/client/services/agent-registry.js +0 -630
- package/dist/client/services/agent-registry.js.map +0 -1
- package/dist/client/services/conversation-manager.d.ts +0 -50
- package/dist/client/services/conversation-manager.d.ts.map +0 -1
- package/dist/client/services/conversation-manager.js +0 -136
- package/dist/client/services/conversation-manager.js.map +0 -1
- package/dist/client/services/mcp-client.d.ts +0 -48
- package/dist/client/services/mcp-client.d.ts.map +0 -1
- package/dist/client/services/mcp-client.js +0 -105
- package/dist/client/services/mcp-client.js.map +0 -1
- package/dist/client/services/message-classifier.d.ts +0 -37
- package/dist/client/services/message-classifier.d.ts.map +0 -1
- package/dist/client/services/message-classifier.js +0 -187
- package/dist/client/services/message-classifier.js.map +0 -1
- package/dist/client/services/message-formatter.d.ts +0 -84
- package/dist/client/services/message-formatter.d.ts.map +0 -1
- package/dist/client/services/message-formatter.js +0 -353
- package/dist/client/services/message-formatter.js.map +0 -1
- package/dist/client/services/session-logger.d.ts +0 -106
- package/dist/client/services/session-logger.d.ts.map +0 -1
- package/dist/client/services/session-logger.js +0 -446
- package/dist/client/services/session-logger.js.map +0 -1
- package/dist/client/services/tool-executor.d.ts +0 -41
- package/dist/client/services/tool-executor.d.ts.map +0 -1
- package/dist/client/services/tool-executor.js +0 -169
- package/dist/client/services/tool-executor.js.map +0 -1
- package/dist/client/services/workspace-schema-cache.d.ts +0 -149
- package/dist/client/services/workspace-schema-cache.d.ts.map +0 -1
- package/dist/client/services/workspace-schema-cache.js +0 -732
- package/dist/client/services/workspace-schema-cache.js.map +0 -1
- package/dist/client/specialist-daemon.d.ts +0 -77
- package/dist/client/specialist-daemon.d.ts.map +0 -1
- package/dist/client/specialist-daemon.js +0 -197
- package/dist/client/specialist-daemon.js.map +0 -1
- package/dist/client/specialists.d.ts +0 -53
- package/dist/client/specialists.d.ts.map +0 -1
- package/dist/client/specialists.js +0 -178
- package/dist/client/specialists.js.map +0 -1
- package/dist/client/tool-schema-loader.d.ts +0 -62
- package/dist/client/tool-schema-loader.d.ts.map +0 -1
- package/dist/client/tool-schema-loader.js +0 -232
- package/dist/client/tool-schema-loader.js.map +0 -1
- package/dist/client/types.d.ts +0 -327
- package/dist/client/types.d.ts.map +0 -1
- package/dist/client/types.js +0 -121
- package/dist/client/types.js.map +0 -1
- package/dist/commands/seed-config.d.ts +0 -9
- package/dist/commands/seed-config.d.ts.map +0 -1
- package/dist/commands/seed-config.js +0 -377
- package/dist/commands/seed-config.js.map +0 -1
- package/dist/commands/setup.d.ts +0 -11
- package/dist/commands/setup.d.ts.map +0 -1
- package/dist/commands/setup.js +0 -320
- package/dist/commands/setup.js.map +0 -1
- package/dist/lib/discussion-lock.d.ts +0 -42
- package/dist/lib/discussion-lock.d.ts.map +0 -1
- package/dist/lib/discussion-lock.js +0 -110
- package/dist/lib/discussion-lock.js.map +0 -1
- package/dist/mcp/signal-handler.d.ts +0 -82
- package/dist/mcp/signal-handler.d.ts.map +0 -1
- package/dist/mcp/signal-handler.js +0 -406
- package/dist/mcp/signal-handler.js.map +0 -1
- package/dist/mcp/tools/__tests__/discussion-forward.test.d.ts +0 -2
- package/dist/mcp/tools/__tests__/discussion-forward.test.d.ts.map +0 -1
- package/dist/mcp/tools/__tests__/discussion-forward.test.js +0 -218
- package/dist/mcp/tools/__tests__/discussion-forward.test.js.map +0 -1
- package/dist/mcp/tools/app-member.d.ts +0 -14
- package/dist/mcp/tools/app-member.d.ts.map +0 -1
- package/dist/mcp/tools/app-member.js +0 -195
- package/dist/mcp/tools/app-member.js.map +0 -1
- package/dist/mcp/tools/app-scaffold.d.ts +0 -14
- package/dist/mcp/tools/app-scaffold.d.ts.map +0 -1
- package/dist/mcp/tools/app-scaffold.js +0 -581
- package/dist/mcp/tools/app-scaffold.js.map +0 -1
- package/dist/mcp/tools/bot-config/constants.d.ts +0 -23
- package/dist/mcp/tools/bot-config/constants.d.ts.map +0 -1
- package/dist/mcp/tools/bot-config/constants.js +0 -94
- package/dist/mcp/tools/bot-config/constants.js.map +0 -1
- package/dist/mcp/tools/bot-config/core.d.ts +0 -253
- package/dist/mcp/tools/bot-config/core.d.ts.map +0 -1
- package/dist/mcp/tools/bot-config/core.js +0 -2456
- package/dist/mcp/tools/bot-config/core.js.map +0 -1
- package/dist/mcp/tools/bot-config/index.d.ts +0 -10
- package/dist/mcp/tools/bot-config/index.d.ts.map +0 -1
- package/dist/mcp/tools/bot-config/index.js +0 -59
- package/dist/mcp/tools/bot-config/index.js.map +0 -1
- package/dist/mcp/tools/bot-config/tools.d.ts +0 -7
- package/dist/mcp/tools/bot-config/tools.d.ts.map +0 -1
- package/dist/mcp/tools/bot-config/tools.js +0 -15
- package/dist/mcp/tools/bot-config/tools.js.map +0 -1
- package/dist/mcp/tools/bot-config/types.d.ts +0 -50
- package/dist/mcp/tools/bot-config/types.d.ts.map +0 -1
- package/dist/mcp/tools/bot-config/types.js +0 -6
- package/dist/mcp/tools/bot-config/types.js.map +0 -1
- package/dist/mcp/tools/bug-fixer-tools.d.ts +0 -45
- package/dist/mcp/tools/bug-fixer-tools.d.ts.map +0 -1
- package/dist/mcp/tools/bug-fixer-tools.js +0 -1096
- package/dist/mcp/tools/bug-fixer-tools.js.map +0 -1
- package/dist/mcp/tools/document.d.ts +0 -11
- package/dist/mcp/tools/document.d.ts.map +0 -1
- package/dist/mcp/tools/document.js +0 -741
- package/dist/mcp/tools/document.js.map +0 -1
- package/dist/mcp/tools/investigate.d.ts +0 -9
- package/dist/mcp/tools/investigate.d.ts.map +0 -1
- package/dist/mcp/tools/investigate.js +0 -254
- package/dist/mcp/tools/investigate.js.map +0 -1
- package/dist/mcp/utils/pagination.d.ts +0 -40
- package/dist/mcp/utils/pagination.d.ts.map +0 -1
- package/dist/mcp/utils/pagination.js +0 -55
- package/dist/mcp/utils/pagination.js.map +0 -1
- package/dist/modules/bug-reports/bug-config.d.ts +0 -25
- package/dist/modules/bug-reports/bug-config.d.ts.map +0 -1
- package/dist/modules/bug-reports/bug-config.js +0 -187
- package/dist/modules/bug-reports/bug-config.js.map +0 -1
- package/dist/modules/bug-reports/bug-monitor.d.ts +0 -108
- package/dist/modules/bug-reports/bug-monitor.d.ts.map +0 -1
- package/dist/modules/bug-reports/bug-monitor.js +0 -510
- package/dist/modules/bug-reports/bug-monitor.js.map +0 -1
- package/dist/modules/bug-reports/giuseppe-agent.d.ts +0 -58
- package/dist/modules/bug-reports/giuseppe-agent.d.ts.map +0 -1
- package/dist/modules/bug-reports/giuseppe-agent.js +0 -467
- package/dist/modules/bug-reports/giuseppe-agent.js.map +0 -1
- package/dist/modules/bug-reports/giuseppe-ai.d.ts +0 -83
- package/dist/modules/bug-reports/giuseppe-ai.d.ts.map +0 -1
- package/dist/modules/bug-reports/giuseppe-ai.js +0 -466
- package/dist/modules/bug-reports/giuseppe-ai.js.map +0 -1
- package/dist/modules/bug-reports/giuseppe-bot.d.ts +0 -110
- package/dist/modules/bug-reports/giuseppe-bot.d.ts.map +0 -1
- package/dist/modules/bug-reports/giuseppe-bot.js +0 -804
- package/dist/modules/bug-reports/giuseppe-bot.js.map +0 -1
- package/dist/modules/bug-reports/giuseppe-daemon.d.ts +0 -80
- package/dist/modules/bug-reports/giuseppe-daemon.d.ts.map +0 -1
- package/dist/modules/bug-reports/giuseppe-daemon.js +0 -617
- package/dist/modules/bug-reports/giuseppe-daemon.js.map +0 -1
- package/dist/modules/bug-reports/giuseppe-files.d.ts +0 -64
- package/dist/modules/bug-reports/giuseppe-files.d.ts.map +0 -1
- package/dist/modules/bug-reports/giuseppe-files.js +0 -375
- package/dist/modules/bug-reports/giuseppe-files.js.map +0 -1
- package/dist/modules/bug-reports/giuseppe-git.d.ts +0 -48
- package/dist/modules/bug-reports/giuseppe-git.d.ts.map +0 -1
- package/dist/modules/bug-reports/giuseppe-git.js +0 -298
- package/dist/modules/bug-reports/giuseppe-git.js.map +0 -1
- package/dist/modules/bug-reports/giuseppe-lsp.d.ts +0 -113
- package/dist/modules/bug-reports/giuseppe-lsp.d.ts.map +0 -1
- package/dist/modules/bug-reports/giuseppe-lsp.js +0 -485
- package/dist/modules/bug-reports/giuseppe-lsp.js.map +0 -1
- package/dist/modules/bug-reports/giuseppe-prompt.d.ts +0 -5
- package/dist/modules/bug-reports/giuseppe-prompt.d.ts.map +0 -1
- package/dist/modules/bug-reports/giuseppe-prompt.js +0 -94
- package/dist/modules/bug-reports/giuseppe-prompt.js.map +0 -1
- package/dist/modules/bug-reports/index.d.ts +0 -77
- package/dist/modules/bug-reports/index.d.ts.map +0 -1
- package/dist/modules/bug-reports/index.js +0 -215
- package/dist/modules/bug-reports/index.js.map +0 -1
- package/dist/modules/bug-reports/pending-classification-registry.d.ts +0 -28
- package/dist/modules/bug-reports/pending-classification-registry.d.ts.map +0 -1
- package/dist/modules/bug-reports/pending-classification-registry.js +0 -50
- package/dist/modules/bug-reports/pending-classification-registry.js.map +0 -1
- package/dist/modules/bug-reports/pending-fix-registry.d.ts +0 -30
- package/dist/modules/bug-reports/pending-fix-registry.d.ts.map +0 -1
- package/dist/modules/bug-reports/pending-fix-registry.js +0 -42
- package/dist/modules/bug-reports/pending-fix-registry.js.map +0 -1
- package/dist/modules/bug-reports/pending-registry.d.ts +0 -27
- package/dist/modules/bug-reports/pending-registry.d.ts.map +0 -1
- package/dist/modules/bug-reports/pending-registry.js +0 -49
- package/dist/modules/bug-reports/pending-registry.js.map +0 -1
- package/dist/modules/bug-reports/types.d.ts +0 -123
- package/dist/modules/bug-reports/types.d.ts.map +0 -1
- package/dist/modules/bug-reports/types.js +0 -9
- package/dist/modules/bug-reports/types.js.map +0 -1
- package/dist/plugins/bug-fixer/index.d.ts +0 -2
- package/dist/plugins/bug-fixer/index.d.ts.map +0 -1
- package/dist/plugins/bug-fixer/index.js +0 -18
- package/dist/plugins/bug-fixer/index.js.map +0 -1
- package/dist/plugins/bug-fixer/tools.d.ts +0 -45
- package/dist/plugins/bug-fixer/tools.d.ts.map +0 -1
- package/dist/plugins/bug-fixer/tools.js +0 -1096
- package/dist/plugins/bug-fixer/tools.js.map +0 -1
- package/dist/plugins/vipunen/__tests__/tools.test.d.ts +0 -10
- package/dist/plugins/vipunen/__tests__/tools.test.d.ts.map +0 -1
- package/dist/plugins/vipunen/__tests__/tools.test.js +0 -646
- package/dist/plugins/vipunen/__tests__/tools.test.js.map +0 -1
- package/dist/routes/agents.d.ts +0 -44
- package/dist/routes/agents.d.ts.map +0 -1
- package/dist/routes/agents.js +0 -311
- package/dist/routes/agents.js.map +0 -1
- package/dist/services/agent-credential-store.d.ts +0 -73
- package/dist/services/agent-credential-store.d.ts.map +0 -1
- package/dist/services/agent-credential-store.js +0 -212
- package/dist/services/agent-credential-store.js.map +0 -1
- package/dist/stdio-server.d.ts +0 -14
- package/dist/stdio-server.d.ts.map +0 -1
- package/dist/stdio-server.js +0 -101
- package/dist/stdio-server.js.map +0 -1
- package/dist/workspace/context.d.ts +0 -148
- package/dist/workspace/context.d.ts.map +0 -1
- package/dist/workspace/context.js +0 -339
- package/dist/workspace/context.js.map +0 -1
- package/dist/workspace/credentials.d.ts +0 -55
- package/dist/workspace/credentials.d.ts.map +0 -1
- package/dist/workspace/credentials.js +0 -239
- package/dist/workspace/credentials.js.map +0 -1
- package/dist/workspace/index.d.ts +0 -21
- package/dist/workspace/index.d.ts.map +0 -1
- package/dist/workspace/index.js +0 -45
- package/dist/workspace/index.js.map +0 -1
- package/dist/workspace/loader.d.ts +0 -27
- package/dist/workspace/loader.d.ts.map +0 -1
- package/dist/workspace/loader.js +0 -222
- package/dist/workspace/loader.js.map +0 -1
- package/dist/workspace/schema.d.ts +0 -37
- package/dist/workspace/schema.d.ts.map +0 -1
- package/dist/workspace/schema.js +0 -192
- package/dist/workspace/schema.js.map +0 -1
|
@@ -7,10 +7,16 @@
|
|
|
7
7
|
* - Activities = Rows
|
|
8
8
|
* - Fields = Columns
|
|
9
9
|
*
|
|
10
|
-
* All 4 insight
|
|
10
|
+
* All 4 insight tools in one file for cohesion (v2 surface):
|
|
11
|
+
* - run_insight (saved execution + ad-hoc preview)
|
|
12
|
+
* - save_insight (create + update upsert)
|
|
13
|
+
* - list_insights
|
|
14
|
+
* - remove_insight
|
|
11
15
|
*/
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.insightTools = exports.listInsightsTool = exports.removeInsightTool = exports.
|
|
17
|
+
exports.insightTools = exports.listInsightsTool = exports.removeInsightTool = exports.saveInsightTool = exports.runInsightTool = void 0;
|
|
18
|
+
exports.formatResultData = formatResultData;
|
|
19
|
+
exports.findExistingInsight = findExistingInsight;
|
|
14
20
|
const zod_1 = require("zod");
|
|
15
21
|
const tool_registry_1 = require("../tool-registry");
|
|
16
22
|
const logger_1 = require("../../lib/logger");
|
|
@@ -25,10 +31,10 @@ const logger = (0, logger_1.createLogger)({ component: 'insight-tools' });
|
|
|
25
31
|
* Accepts both 'id' and 'fieldId' for flexibility (LLMs often use 'id')
|
|
26
32
|
*/
|
|
27
33
|
const fieldSchema = zod_1.z.object({
|
|
28
|
-
name: zod_1.z.string().describe(
|
|
34
|
+
name: zod_1.z.string().describe('Column name in SQL query'),
|
|
29
35
|
// Accept both 'id' and 'fieldId' - will be normalized to 'fieldId'
|
|
30
|
-
id: zod_1.z.string().optional().describe(
|
|
31
|
-
fieldId: zod_1.z.string().optional().describe(
|
|
36
|
+
id: zod_1.z.string().optional().describe('Field ID (alias for fieldId)'),
|
|
37
|
+
fieldId: zod_1.z.string().optional().describe('Custom field ID from workflow'),
|
|
32
38
|
meta: zod_1.z.enum([
|
|
33
39
|
'_id',
|
|
34
40
|
'uid',
|
|
@@ -43,7 +49,7 @@ const fieldSchema = zod_1.z.object({
|
|
|
43
49
|
'workflowId',
|
|
44
50
|
'workflowName',
|
|
45
51
|
'priority'
|
|
46
|
-
]).optional().describe(
|
|
52
|
+
]).optional().describe('Built-in activity property (alternative to fieldId)'),
|
|
47
53
|
}).refine((data) => data.meta || data.fieldId || data.id, { message: "Field must have either 'meta', 'fieldId', or 'id'" });
|
|
48
54
|
/**
|
|
49
55
|
* Sanitize field name to be SQL-identifier safe (no spaces, special chars)
|
|
@@ -53,8 +59,9 @@ function sanitizeFieldName(name) {
|
|
|
53
59
|
return name
|
|
54
60
|
.split(/\s+/)
|
|
55
61
|
.map((word, index) => {
|
|
56
|
-
if (index === 0)
|
|
62
|
+
if (index === 0) {
|
|
57
63
|
return word.charAt(0).toLowerCase() + word.slice(1);
|
|
64
|
+
}
|
|
58
65
|
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
59
66
|
})
|
|
60
67
|
.join('')
|
|
@@ -67,7 +74,7 @@ function normalizeFields(sources) {
|
|
|
67
74
|
return sources.map(source => ({
|
|
68
75
|
...source,
|
|
69
76
|
fields: source.fields.map(field => {
|
|
70
|
-
|
|
77
|
+
const normalized = { ...field };
|
|
71
78
|
// Sanitize field name (remove spaces, make SQL-safe)
|
|
72
79
|
if (normalized.name) {
|
|
73
80
|
normalized.name = sanitizeFieldName(normalized.name);
|
|
@@ -85,546 +92,572 @@ function normalizeFields(sources) {
|
|
|
85
92
|
* Source definition schema - workflow as SQL table
|
|
86
93
|
*/
|
|
87
94
|
const sourceSchema = zod_1.z.object({
|
|
88
|
-
name: zod_1.z.string().describe(
|
|
89
|
-
workflowId: zod_1.z.string().describe(
|
|
90
|
-
fields: zod_1.z.array(fieldSchema).min(1).describe(
|
|
95
|
+
name: zod_1.z.string().describe('Table alias for SQL query'),
|
|
96
|
+
workflowId: zod_1.z.string().describe('Workflow ID to query'),
|
|
97
|
+
fields: zod_1.z.array(fieldSchema).min(1).describe('Field mappings for SQL columns'),
|
|
91
98
|
});
|
|
92
|
-
// ============================================================================
|
|
93
|
-
// CREATE INSIGHT TOOL
|
|
94
|
-
// ============================================================================
|
|
95
99
|
const INSIGHT_SQL_GUIDE = `**How sources map to SQL:**
|
|
96
100
|
- sources[].name → TABLE NAME in SQL
|
|
97
101
|
- sources[].fields[].name → COLUMN NAME in SQL
|
|
98
|
-
- sources[].fields[].fieldId → custom field ID (hex string from
|
|
99
|
-
- sources[].fields[].meta → built-in property (use INSTEAD of fieldId): phaseName, name, created, updated, uid, team, priority
|
|
102
|
+
- sources[].fields[].fieldId → custom field ID (hex string from describe_workflows include:["schema"])
|
|
103
|
+
- sources[].fields[].meta → built-in property (use INSTEAD of fieldId): _id, phaseName, name, created, updated, uid, team, priority (use meta: "_id" to get activity IDs for update_activity bulk calls)
|
|
100
104
|
|
|
101
105
|
**Example — count by phase:**
|
|
102
106
|
sources: [{ name: "T", workflowId: "...", fields: [{ name: "phase", meta: "phaseName" }] }]
|
|
103
107
|
query: "SELECT phase, COUNT(*) as count FROM T GROUP BY phase"
|
|
104
108
|
|
|
105
109
|
**NEVER use fieldId or workflowId in the SQL — only field name values.**`;
|
|
106
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Result byte budget — keeps insight responses under MCP client caps while
|
|
112
|
+
* returning the actual data. (The old formatter showed a 10-row sample and
|
|
113
|
+
* discarded the rest, which made run_insight useless for data retrieval.)
|
|
114
|
+
*/
|
|
115
|
+
const MAX_INSIGHT_RESPONSE_CHARS = 200000;
|
|
116
|
+
/**
|
|
117
|
+
* Format a headers/rows result set as compact JSON, windowed by offset/maxRows
|
|
118
|
+
* and trimmed to the byte budget on whole-row boundaries. The full result set
|
|
119
|
+
* is already in memory here — slicing costs nothing and lets the model page.
|
|
120
|
+
*/
|
|
121
|
+
function formatResultData(headers, rows, offset, maxRows) {
|
|
122
|
+
if (!headers || !rows) {
|
|
123
|
+
return '⚠️ No data returned\n';
|
|
124
|
+
}
|
|
125
|
+
if (rows.length === 0) {
|
|
126
|
+
return `**Columns:** ${headers.join(', ')}\n\n⚠️ **No rows matched** - Check your query filters\n`;
|
|
127
|
+
}
|
|
128
|
+
const totalRows = rows.length;
|
|
129
|
+
const windowed = rows.slice(offset, offset + maxRows);
|
|
130
|
+
const included = [];
|
|
131
|
+
let used = JSON.stringify(headers).length + 32;
|
|
132
|
+
for (const row of windowed) {
|
|
133
|
+
const rowLength = JSON.stringify(row).length + 1;
|
|
134
|
+
if (used + rowLength > MAX_INSIGHT_RESPONSE_CHARS) {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
included.push(row);
|
|
138
|
+
used += rowLength;
|
|
139
|
+
}
|
|
140
|
+
if (included.length === 0 && windowed.length > 0) {
|
|
141
|
+
// A pagination hint here would point at the SAME offset forever.
|
|
142
|
+
return `⚠️ **Row too large**: the single row at offset ${offset} exceeds the response size cap. ` +
|
|
143
|
+
`Select fewer or shorter columns in the SQL, or skip it with offset=${offset + 1}.\n`;
|
|
144
|
+
}
|
|
145
|
+
let text = `**Rows ${Math.min(offset + 1, totalRows)}-${offset + included.length} of ${totalRows}**\n`;
|
|
146
|
+
text += '```json\n';
|
|
147
|
+
text += JSON.stringify({ headers, rows: included });
|
|
148
|
+
text += '\n```\n';
|
|
149
|
+
const nextOffset = offset + included.length;
|
|
150
|
+
if (nextOffset < totalRows) {
|
|
151
|
+
text += `\n➡️ **More rows available**: call run_insight again with the same query/insightId and offset=${nextOffset}\n`;
|
|
152
|
+
}
|
|
153
|
+
return text;
|
|
154
|
+
}
|
|
155
|
+
// ============================================================================
|
|
156
|
+
// RUN INSIGHT TOOL (saved execution + ad-hoc preview)
|
|
157
|
+
// ============================================================================
|
|
158
|
+
const runInsightDescription = `Execute an insight query and return rows. PREFER THIS over paginating list_activities for: aggregations (COUNT/SUM/GROUP BY), selecting a few columns across many activities, cross-workflow JOINs, and collecting activity _ids for bulk updates (\`SELECT _id ...\` with meta: "_id").
|
|
159
|
+
|
|
160
|
+
Two modes (mutually exclusive):
|
|
161
|
+
- Saved: pass insightId to run a stored insight over the FULL dataset (no sampling). Results may be served from a server cache up to ~15 min old; a newly saved insight computes fresh on first run. Check list_insights first — an existing insight may already answer the question; reuse before creating new ones.
|
|
162
|
+
- Ad-hoc: pass sources + query to test SQL without saving. ⚠️ Ad-hoc runs on a SAMPLE (the newest ~200 activities per source) — good for validating SQL and small workflows, NOT for full-dataset counts/sums. Save the insight and run it by insightId for exact numbers.
|
|
163
|
+
|
|
164
|
+
Results return as compact JSON (headers + rows) up to a size cap — page with offset/maxRows.
|
|
107
165
|
|
|
108
166
|
${INSIGHT_SQL_GUIDE}`;
|
|
109
|
-
|
|
110
|
-
|
|
167
|
+
/** Saved-insight path: v3.insight.data */
|
|
168
|
+
async function runSavedInsight(insightId, context, offset, maxRows) {
|
|
169
|
+
try {
|
|
170
|
+
logger.debug('Calling v3.insight.data', { insightId });
|
|
171
|
+
// Always update: false — forcing recalculation rebuilds the whole
|
|
172
|
+
// in-memory SQLite dataset server-side (queued, max 2 concurrent) and
|
|
173
|
+
// is never needed: an uncached insight computes on first run anyway.
|
|
174
|
+
const result = await context.hailer.request('v3.insight.data', [insightId, { update: false }]);
|
|
175
|
+
logger.debug('Insight data retrieved', {
|
|
176
|
+
headers: result.headers?.length,
|
|
177
|
+
rows: result.rows?.length,
|
|
178
|
+
fullResult: JSON.stringify(result).substring(0, 500)
|
|
179
|
+
});
|
|
180
|
+
let responseText = `✅ **Insight Data Retrieved** (${result.rows?.length || 0} rows)\n\n`;
|
|
181
|
+
responseText += formatResultData(result.headers, result.rows, offset, maxRows);
|
|
182
|
+
if (!result.headers || !result.rows) {
|
|
183
|
+
responseText += `**Debug:** Response keys: ${Object.keys(result).join(', ')}\n`;
|
|
184
|
+
responseText += `**Full response (truncated):** \`${JSON.stringify(result).substring(0, 300)}\`\n`;
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
content: [{
|
|
188
|
+
type: 'text',
|
|
189
|
+
text: responseText,
|
|
190
|
+
}],
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
if (!request_logger_1.RequestLogger.getCurrent()) {
|
|
195
|
+
logger.error('Error getting insight data', error);
|
|
196
|
+
}
|
|
197
|
+
const errorMessage = (0, tool_helpers_1.extractErrorMessage)(error);
|
|
198
|
+
return {
|
|
199
|
+
content: [{
|
|
200
|
+
type: 'text',
|
|
201
|
+
text: `❌ **Error getting insight data**\n\n**Error:** ${errorMessage}\n\n**Common Issues:**\n- Insight ID not found\n- Permission denied\n- Insight query has errors\n- Use \`list_insights\` to verify insight ID`,
|
|
202
|
+
}],
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/** Ad-hoc path: v3.insight.preview */
|
|
207
|
+
async function runAdHocInsight(sources, query, context, offset, maxRows) {
|
|
208
|
+
try {
|
|
209
|
+
// Resolve workspace ID (returns undefined if cache unavailable)
|
|
210
|
+
const workspaceId = (0, tool_helpers_1.getResolvedWorkspaceId)({}, context);
|
|
211
|
+
if (!workspaceId) {
|
|
212
|
+
return (0, tool_helpers_1.missingWorkspaceCacheResponse)();
|
|
213
|
+
}
|
|
214
|
+
logger.debug('Calling v3.insight.preview', {
|
|
215
|
+
workspaceId,
|
|
216
|
+
sourcesCount: sources.length,
|
|
217
|
+
});
|
|
218
|
+
// Normalize sources (convert 'id' to 'fieldId' if needed)
|
|
219
|
+
const normalizedSources = normalizeFields(sources);
|
|
220
|
+
const previewData = {
|
|
221
|
+
sources: normalizedSources,
|
|
222
|
+
query,
|
|
223
|
+
};
|
|
224
|
+
// Call v3.insight.preview endpoint
|
|
225
|
+
const result = await context.hailer.request('v3.insight.preview', [workspaceId, previewData]);
|
|
226
|
+
logger.debug('Preview successful', {
|
|
227
|
+
headers: result.headers?.length,
|
|
228
|
+
rows: result.rows?.length
|
|
229
|
+
});
|
|
230
|
+
let responseText = `✅ **Preview Results** (~${result.rows?.length || 0} rows)\n\n`;
|
|
231
|
+
responseText += `⚠️ Ad-hoc preview computes over a SAMPLE (newest ~200 activities per source). For full-dataset numbers, save with \`save_insight\` and run by insightId.\n\n`;
|
|
232
|
+
responseText += formatResultData(result.headers, result.rows, offset, maxRows);
|
|
233
|
+
responseText += '\n✅ **Query is valid!** Ready to save with `save_insight`.';
|
|
234
|
+
return {
|
|
235
|
+
content: [{
|
|
236
|
+
type: 'text',
|
|
237
|
+
text: responseText,
|
|
238
|
+
}],
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
if (!request_logger_1.RequestLogger.getCurrent()) {
|
|
243
|
+
logger.error('Error previewing insight', error);
|
|
244
|
+
}
|
|
245
|
+
const errorMessage = (0, tool_helpers_1.extractErrorMessage)(error);
|
|
246
|
+
return {
|
|
247
|
+
content: [{
|
|
248
|
+
type: 'text',
|
|
249
|
+
text: `❌ **Preview Failed**\n\n**Error:** ${errorMessage}\n\n**Tips:**\n- Check SQL syntax\n- Verify field names match source definitions\n- Ensure workflow IDs are correct\n- Check table aliases match source names`,
|
|
250
|
+
}],
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
exports.runInsightTool = {
|
|
255
|
+
name: 'run_insight',
|
|
111
256
|
group: tool_registry_1.ToolGroup.PLAYGROUND,
|
|
112
|
-
description:
|
|
257
|
+
description: runInsightDescription,
|
|
113
258
|
schema: zod_1.z.object({
|
|
114
|
-
|
|
115
|
-
.string()
|
|
116
|
-
.optional()
|
|
117
|
-
.describe("Optional workspace ID or name - defaults to current workspace"),
|
|
118
|
-
name: zod_1.z
|
|
259
|
+
insightId: zod_1.z
|
|
119
260
|
.string()
|
|
120
|
-
.min(1)
|
|
121
|
-
.describe("Insight name"),
|
|
122
|
-
public: zod_1.z
|
|
123
|
-
.boolean()
|
|
124
261
|
.optional()
|
|
125
|
-
.
|
|
126
|
-
.describe("Whether insight is publicly accessible (default: false)"),
|
|
262
|
+
.describe('Saved insight ID to execute. Mutually exclusive with sources/query.'),
|
|
127
263
|
sources: zod_1.z
|
|
128
264
|
.array(sourceSchema)
|
|
129
265
|
.min(1)
|
|
130
|
-
.
|
|
266
|
+
.optional()
|
|
267
|
+
.describe('Ad-hoc mode: workflow sources. source.name = SQL table name, field.name = SQL column name.'),
|
|
131
268
|
query: zod_1.z
|
|
132
269
|
.string()
|
|
133
270
|
.min(1)
|
|
134
|
-
.
|
|
271
|
+
.optional()
|
|
272
|
+
.describe('Ad-hoc mode: SQL query to test'),
|
|
273
|
+
offset: zod_1.z.coerce
|
|
274
|
+
.number()
|
|
275
|
+
.int()
|
|
276
|
+
.min(0)
|
|
277
|
+
.optional()
|
|
278
|
+
.default(0)
|
|
279
|
+
.describe('Skip this many result rows (0-based) — for paging through large results'),
|
|
280
|
+
maxRows: zod_1.z.coerce
|
|
281
|
+
.number()
|
|
282
|
+
.int()
|
|
283
|
+
.min(1)
|
|
284
|
+
.max(2000)
|
|
285
|
+
.optional()
|
|
286
|
+
.default(500)
|
|
287
|
+
.describe('Maximum rows to return (default 500). A response size cap may return fewer; the response says how to continue'),
|
|
135
288
|
}),
|
|
136
289
|
async execute(args, context) {
|
|
137
|
-
logger.debug('
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
290
|
+
logger.debug('Running insight', {
|
|
291
|
+
insightId: args.insightId,
|
|
292
|
+
sourcesCount: args.sources?.length,
|
|
293
|
+
hasQuery: !!args.query,
|
|
141
294
|
apiKey: context.apiKey.substring(0, 8) + '...'
|
|
142
295
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
workspaceId,
|
|
151
|
-
name: args.name,
|
|
152
|
-
sourcesCount: args.sources.length
|
|
153
|
-
});
|
|
154
|
-
// Normalize sources (convert 'id' to 'fieldId' if needed)
|
|
155
|
-
const normalizedSources = normalizeFields(args.sources);
|
|
156
|
-
// Build insight payload
|
|
157
|
-
const insightData = {
|
|
158
|
-
name: args.name,
|
|
159
|
-
public: args.public || false,
|
|
160
|
-
sources: normalizedSources,
|
|
161
|
-
query: args.query,
|
|
296
|
+
const hasAdHocArgs = !!args.sources || !!args.query;
|
|
297
|
+
if (args.insightId && hasAdHocArgs) {
|
|
298
|
+
return {
|
|
299
|
+
content: [{
|
|
300
|
+
type: 'text',
|
|
301
|
+
text: '❌ **Conflicting modes**\n\nPass EITHER `insightId` (run a saved insight) OR `sources` + `query` (ad-hoc test) — not both.',
|
|
302
|
+
}],
|
|
162
303
|
};
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
});
|
|
169
|
-
const insightId = result.insightId || result._id;
|
|
170
|
-
const discussionId = result.discussionId || result.discussion;
|
|
171
|
-
// Automatically join the insight's discussion
|
|
172
|
-
if (discussionId) {
|
|
173
|
-
try {
|
|
174
|
-
logger.debug('Automatically joining insight discussion', { discussionId });
|
|
175
|
-
await context.hailer.joinDiscussion(discussionId);
|
|
176
|
-
logger.debug('Successfully joined insight discussion', { discussionId });
|
|
177
|
-
}
|
|
178
|
-
catch (joinError) {
|
|
179
|
-
logger.warn('Failed to join insight discussion (non-fatal)', {
|
|
180
|
-
discussionId,
|
|
181
|
-
error: joinError instanceof Error ? joinError.message : String(joinError)
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
logger.debug('No discussion ID in response, skipping auto-join');
|
|
187
|
-
}
|
|
188
|
-
// Build success response
|
|
189
|
-
let responseText = `✅ **Insight Created Successfully**\n\n`;
|
|
190
|
-
responseText += `**Insight Name:** ${args.name}\n`;
|
|
191
|
-
responseText += `**Insight ID:** \`${insightId}\`\n`;
|
|
192
|
-
responseText += `**Workspace:** ${workspaceId}\n`;
|
|
193
|
-
responseText += `**Public:** ${args.public ? 'Yes' : 'No'}\n`;
|
|
194
|
-
responseText += `**Sources:** ${args.sources.length} workflow(s)\n`;
|
|
195
|
-
if (discussionId) {
|
|
196
|
-
responseText += `**Discussion:** Automatically joined ✓\n`;
|
|
197
|
-
}
|
|
198
|
-
responseText += `\n`;
|
|
199
|
-
// Show sources
|
|
200
|
-
responseText += `**Query Sources:**\n`;
|
|
201
|
-
args.sources.forEach((source) => {
|
|
202
|
-
responseText += `- \`${source.name}\` → Workflow: \`${source.workflowId}\` (${source.fields.length} fields)\n`;
|
|
203
|
-
});
|
|
204
|
-
responseText += `\n**SQL Query:**\n\`\`\`sql\n${args.query}\n\`\`\`\n\n`;
|
|
205
|
-
responseText += `💡 **Next Steps:**\n`;
|
|
206
|
-
responseText += `- Use \`get_insight_data\` to execute the query and see results\n`;
|
|
207
|
-
responseText += `- Use \`list_insights\` to see all insights in workspace\n`;
|
|
208
|
-
responseText += `- Use \`update_insight\` to modify the insight\n`;
|
|
209
|
-
responseText += `- Use \`preview_insight\` to test query changes before saving\n\n`;
|
|
210
|
-
if (args.public) {
|
|
211
|
-
responseText += `🌐 **Public Insight:** This insight can be accessed without authentication.\n`;
|
|
212
|
-
}
|
|
304
|
+
}
|
|
305
|
+
if (args.insightId) {
|
|
306
|
+
return runSavedInsight(args.insightId, context, args.offset ?? 0, args.maxRows ?? 500);
|
|
307
|
+
}
|
|
308
|
+
if (!hasAdHocArgs) {
|
|
213
309
|
return {
|
|
214
310
|
content: [{
|
|
215
|
-
type:
|
|
216
|
-
text:
|
|
311
|
+
type: 'text',
|
|
312
|
+
text: '❌ **Missing parameters**\n\nPass `insightId` to run a saved insight, or `sources` + `query` to test an ad-hoc SQL query.\n\nUse `list_insights` to find saved insight IDs.',
|
|
217
313
|
}],
|
|
218
314
|
};
|
|
219
315
|
}
|
|
220
|
-
|
|
221
|
-
if (!request_logger_1.RequestLogger.getCurrent())
|
|
222
|
-
logger.error("Error creating insight", error);
|
|
223
|
-
let errorMessage = 'Unknown error occurred';
|
|
224
|
-
let errorDetails = '';
|
|
225
|
-
if (error instanceof Error) {
|
|
226
|
-
errorMessage = error.message;
|
|
227
|
-
if (error.stack) {
|
|
228
|
-
errorDetails = `\n\n**Stack trace:**\n\`\`\`\n${error.stack}\n\`\`\``;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
else if (typeof error === 'object' && error !== null) {
|
|
232
|
-
try {
|
|
233
|
-
errorMessage = JSON.stringify(error, null, 2);
|
|
234
|
-
}
|
|
235
|
-
catch {
|
|
236
|
-
errorMessage = String(error);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
errorMessage = String(error);
|
|
241
|
-
}
|
|
242
|
-
// Handle SQL syntax errors
|
|
243
|
-
if (errorMessage.toLowerCase().includes('sql') || errorMessage.toLowerCase().includes('syntax')) {
|
|
244
|
-
return {
|
|
245
|
-
content: [{
|
|
246
|
-
type: "text",
|
|
247
|
-
text: `❌ **SQL Query Error**\n\nThere's a problem with your SQL query.\n\n**Error:** ${errorMessage}\n\n**Tips:**\n- Check column names match field names in sources\n- Check table names match source names\n- Use \`preview_insight\` to test queries before creating\n- Make sure field IDs are correct (use \`get_workflow_schema\`)`,
|
|
248
|
-
}],
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
// Handle permission errors
|
|
252
|
-
if (errorMessage.includes('permission') || errorMessage.includes('PermissionDenied')) {
|
|
253
|
-
return {
|
|
254
|
-
content: [{
|
|
255
|
-
type: "text",
|
|
256
|
-
text: `❌ **Permission Denied**\n\nYou may not have permission to create insights or access the specified workflows.\n\n**Error:** ${errorMessage}`,
|
|
257
|
-
}],
|
|
258
|
-
};
|
|
259
|
-
}
|
|
316
|
+
if (!args.sources || !args.query) {
|
|
260
317
|
return {
|
|
261
318
|
content: [{
|
|
262
|
-
type:
|
|
263
|
-
text:
|
|
319
|
+
type: 'text',
|
|
320
|
+
text: '❌ **Incomplete ad-hoc query**\n\nAd-hoc mode requires BOTH `sources` and `query`.',
|
|
264
321
|
}],
|
|
265
322
|
};
|
|
266
323
|
}
|
|
324
|
+
return runAdHocInsight(args.sources, args.query, context, args.offset ?? 0, args.maxRows ?? 500);
|
|
267
325
|
}
|
|
268
326
|
};
|
|
269
327
|
// ============================================================================
|
|
270
|
-
//
|
|
328
|
+
// SAVE INSIGHT TOOL (create + update upsert)
|
|
271
329
|
// ============================================================================
|
|
272
|
-
const
|
|
330
|
+
const saveInsightDescription = `Create or update a SQL insight over workflow data (upsert).
|
|
331
|
+
- BEFORE creating: call list_insights — an existing insight may already cover the question (run it by insightId) or be close enough to update. Creating with a name or query that already exists returns the existing insight instead of making a duplicate.
|
|
332
|
+
- Create: omit insightId — name, sources, and query are required.
|
|
333
|
+
- Update: pass insightId — only the provided fields (name, public, sources, query) are changed.
|
|
273
334
|
|
|
274
335
|
${INSIGHT_SQL_GUIDE}`;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
.
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
logger.debug('Previewing insight', {
|
|
299
|
-
workspaceId: args.workspaceId,
|
|
300
|
-
sourcesCount: args.sources.length,
|
|
301
|
-
insightId: args.insightId,
|
|
302
|
-
apiKey: context.apiKey.substring(0, 8) + '...'
|
|
303
|
-
});
|
|
304
|
-
try {
|
|
305
|
-
// Resolve workspace ID (returns undefined if cache unavailable)
|
|
306
|
-
const workspaceId = (0, tool_helpers_1.getResolvedWorkspaceId)(args, context);
|
|
307
|
-
if (!workspaceId) {
|
|
308
|
-
return (0, tool_helpers_1.missingWorkspaceCacheResponse)();
|
|
336
|
+
/** Normalized-query comparison: whitespace collapsed, case-insensitive. */
|
|
337
|
+
function normalizeQuery(query) {
|
|
338
|
+
return query.replace(/\s+/g, ' ').trim().toLowerCase();
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Looks up an existing insight with the same name (case-insensitive) or an
|
|
342
|
+
* identical query, so create calls reuse instead of piling up duplicates.
|
|
343
|
+
* Returns undefined when the list call fails — creation proceeds normally.
|
|
344
|
+
*/
|
|
345
|
+
async function findExistingInsight(workspaceId, name, query, context) {
|
|
346
|
+
try {
|
|
347
|
+
const result = await context.hailer.request('v3.insight.list', [workspaceId]);
|
|
348
|
+
const insights = Array.isArray(result)
|
|
349
|
+
? result
|
|
350
|
+
: (result.details || result.insights || []);
|
|
351
|
+
const wantedName = name.trim().toLowerCase();
|
|
352
|
+
const wantedQuery = normalizeQuery(query);
|
|
353
|
+
for (const insight of insights) {
|
|
354
|
+
if (insight.name?.trim().toLowerCase() === wantedName) {
|
|
355
|
+
return { _id: insight._id, name: insight.name, matchedBy: 'name' };
|
|
356
|
+
}
|
|
357
|
+
if (insight.query && normalizeQuery(insight.query) === wantedQuery) {
|
|
358
|
+
return { _id: insight._id, name: insight.name || '(unnamed)', matchedBy: 'query' };
|
|
309
359
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
360
|
+
}
|
|
361
|
+
return undefined;
|
|
362
|
+
}
|
|
363
|
+
catch (error) {
|
|
364
|
+
logger.warn('Insight reuse check failed (non-fatal) - proceeding with create', {
|
|
365
|
+
error: (0, tool_helpers_1.extractErrorMessage)(error),
|
|
366
|
+
});
|
|
367
|
+
return undefined;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/** Create path: v3.insight.create (auto-joins the insight's discussion) */
|
|
371
|
+
async function createNewInsight(args, context) {
|
|
372
|
+
const { name, sources, query } = args;
|
|
373
|
+
if (!name || !sources || !query) {
|
|
374
|
+
return {
|
|
375
|
+
content: [{
|
|
376
|
+
type: 'text',
|
|
377
|
+
text: '❌ **Missing required fields**\n\nCreating a new insight (no `insightId`) requires `name`, `sources`, and `query`.\n\nTo update an existing insight instead, pass its `insightId`.',
|
|
378
|
+
}],
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
try {
|
|
382
|
+
// Resolve workspace ID (returns undefined if cache unavailable)
|
|
383
|
+
const workspaceId = (0, tool_helpers_1.getResolvedWorkspaceId)(args, context);
|
|
384
|
+
if (!workspaceId) {
|
|
385
|
+
return (0, tool_helpers_1.missingWorkspaceCacheResponse)();
|
|
386
|
+
}
|
|
387
|
+
// Reuse guard: models tend to create a fresh insight per question,
|
|
388
|
+
// piling up near-duplicates in the workspace.
|
|
389
|
+
const existing = await findExistingInsight(workspaceId, name, query, context);
|
|
390
|
+
if (existing) {
|
|
391
|
+
const matchReason = existing.matchedBy === 'query' ? 'already has this exact query' : 'already uses this name';
|
|
392
|
+
return {
|
|
393
|
+
content: [{
|
|
394
|
+
type: 'text',
|
|
395
|
+
text: `♻️ **Existing insight reused — no duplicate created**\n\n` +
|
|
396
|
+
`**${existing.name}** (ID: \`${existing._id}\`) ${matchReason}.\n\n` +
|
|
397
|
+
`- Run it: \`run_insight({ insightId: "${existing._id}" })\`\n` +
|
|
398
|
+
`- Modify it: \`save_insight({ insightId: "${existing._id}", ... })\`\n` +
|
|
399
|
+
`- Genuinely need a separate insight? Call save_insight again with a different name and query.`,
|
|
400
|
+
}],
|
|
321
401
|
};
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
402
|
+
}
|
|
403
|
+
logger.debug('Calling v3.insight.create', {
|
|
404
|
+
workspaceId,
|
|
405
|
+
name,
|
|
406
|
+
sourcesCount: sources.length
|
|
407
|
+
});
|
|
408
|
+
// Normalize sources (convert 'id' to 'fieldId' if needed)
|
|
409
|
+
const normalizedSources = normalizeFields(sources);
|
|
410
|
+
// Build insight payload
|
|
411
|
+
const insightData = {
|
|
412
|
+
name,
|
|
413
|
+
public: args.public || false,
|
|
414
|
+
sources: normalizedSources,
|
|
415
|
+
query,
|
|
416
|
+
};
|
|
417
|
+
// Call v3.insight.create endpoint
|
|
418
|
+
const result = await context.hailer.request('v3.insight.create', [workspaceId, insightData]);
|
|
419
|
+
logger.debug('Insight creation successful', {
|
|
420
|
+
insightId: result.insightId || result._id,
|
|
421
|
+
result: JSON.stringify(result)
|
|
422
|
+
});
|
|
423
|
+
const insightId = result.insightId || result._id;
|
|
424
|
+
const discussionId = result.discussionId || result.discussion;
|
|
425
|
+
// Automatically join the insight's discussion
|
|
426
|
+
if (discussionId) {
|
|
427
|
+
try {
|
|
428
|
+
logger.debug('Automatically joining insight discussion', { discussionId });
|
|
429
|
+
await context.hailer.joinDiscussion(discussionId);
|
|
430
|
+
logger.debug('Successfully joined insight discussion', { discussionId });
|
|
431
|
+
}
|
|
432
|
+
catch (joinError) {
|
|
433
|
+
logger.warn('Failed to join insight discussion (non-fatal)', {
|
|
434
|
+
discussionId,
|
|
435
|
+
error: joinError instanceof Error ? joinError.message : String(joinError)
|
|
436
|
+
});
|
|
352
437
|
}
|
|
353
|
-
|
|
438
|
+
}
|
|
439
|
+
if (!discussionId) {
|
|
440
|
+
logger.debug('No discussion ID in response, skipping auto-join');
|
|
441
|
+
}
|
|
442
|
+
// Build success response
|
|
443
|
+
let responseText = '✅ **Insight Created Successfully**\n\n';
|
|
444
|
+
responseText += `**Insight Name:** ${name}\n`;
|
|
445
|
+
responseText += `**Insight ID:** \`${insightId}\`\n`;
|
|
446
|
+
responseText += `**Workspace:** ${workspaceId}\n`;
|
|
447
|
+
responseText += `**Public:** ${args.public ? 'Yes' : 'No'}\n`;
|
|
448
|
+
responseText += `**Sources:** ${sources.length} workflow(s)\n`;
|
|
449
|
+
if (discussionId) {
|
|
450
|
+
responseText += '**Discussion:** Automatically joined ✓\n';
|
|
451
|
+
}
|
|
452
|
+
responseText += '\n';
|
|
453
|
+
// Show sources
|
|
454
|
+
responseText += '**Query Sources:**\n';
|
|
455
|
+
sources.forEach((source) => {
|
|
456
|
+
responseText += `- \`${source.name}\` → Workflow: \`${source.workflowId}\` (${source.fields.length} fields)\n`;
|
|
457
|
+
});
|
|
458
|
+
responseText += `\n**SQL Query:**\n\`\`\`sql\n${query}\n\`\`\`\n\n`;
|
|
459
|
+
responseText += '💡 **Next Steps:**\n';
|
|
460
|
+
responseText += '- Use `run_insight` with this insightId to execute the query and see results\n';
|
|
461
|
+
responseText += '- Use `list_insights` to see all insights in workspace\n';
|
|
462
|
+
responseText += '- Use `save_insight` with this insightId to modify the insight\n\n';
|
|
463
|
+
if (args.public) {
|
|
464
|
+
responseText += '🌐 **Public Insight:** This insight can be accessed without authentication.\n';
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
content: [{
|
|
468
|
+
type: 'text',
|
|
469
|
+
text: responseText,
|
|
470
|
+
}],
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
catch (error) {
|
|
474
|
+
if (!request_logger_1.RequestLogger.getCurrent()) {
|
|
475
|
+
logger.error('Error creating insight', error);
|
|
476
|
+
}
|
|
477
|
+
const errorMessage = (0, tool_helpers_1.extractErrorMessage)(error);
|
|
478
|
+
const errorDetails = error instanceof Error && error.stack
|
|
479
|
+
? `\n\n**Stack trace:**\n\`\`\`\n${error.stack}\n\`\`\``
|
|
480
|
+
: '';
|
|
481
|
+
// Handle SQL syntax errors
|
|
482
|
+
if (errorMessage.toLowerCase().includes('sql') || errorMessage.toLowerCase().includes('syntax')) {
|
|
354
483
|
return {
|
|
355
484
|
content: [{
|
|
356
|
-
type:
|
|
357
|
-
text:
|
|
485
|
+
type: 'text',
|
|
486
|
+
text: `❌ **SQL Query Error**\n\nThere's a problem with your SQL query.\n\n**Error:** ${errorMessage}\n\n**Tips:**\n- Check column names match field names in sources\n- Check table names match source names\n- Use \`run_insight\` (sources + query) to test queries before saving\n- Make sure field IDs are correct (use \`describe_workflows\` with include:["schema"])`,
|
|
358
487
|
}],
|
|
359
488
|
};
|
|
360
489
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
logger.error("Error previewing insight", error);
|
|
364
|
-
let errorMessage = 'Unknown error occurred';
|
|
365
|
-
if (error instanceof Error) {
|
|
366
|
-
errorMessage = error.message;
|
|
367
|
-
}
|
|
368
|
-
else if (typeof error === 'object' && error !== null) {
|
|
369
|
-
try {
|
|
370
|
-
errorMessage = JSON.stringify(error, null, 2);
|
|
371
|
-
}
|
|
372
|
-
catch {
|
|
373
|
-
errorMessage = String(error);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
errorMessage = String(error);
|
|
378
|
-
}
|
|
490
|
+
// Handle permission errors
|
|
491
|
+
if (errorMessage.includes('permission') || errorMessage.includes('PermissionDenied')) {
|
|
379
492
|
return {
|
|
380
493
|
content: [{
|
|
381
|
-
type:
|
|
382
|
-
text: `❌ **
|
|
494
|
+
type: 'text',
|
|
495
|
+
text: `❌ **Permission Denied**\n\nYou may not have permission to create insights or access the specified workflows.\n\n**Error:** ${errorMessage}`,
|
|
383
496
|
}],
|
|
384
497
|
};
|
|
385
498
|
}
|
|
499
|
+
return {
|
|
500
|
+
content: [{
|
|
501
|
+
type: 'text',
|
|
502
|
+
text: `❌ **Error creating insight**\n\n**Error:** ${errorMessage}${errorDetails}\n\n**Common Issues:**\n- SQL query syntax errors\n- Invalid field IDs or workflow IDs\n- Workflow fields don't exist\n- Permission issues\n- Check field IDs with \`describe_workflows\` include:["schema"]\n- Test query with \`run_insight\` (sources + query) first`,
|
|
503
|
+
}],
|
|
504
|
+
};
|
|
386
505
|
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
506
|
+
}
|
|
507
|
+
/** Update path: v3.insight.update (partial-field semantics) */
|
|
508
|
+
async function updateExistingInsight(insightId, args, context) {
|
|
509
|
+
try {
|
|
510
|
+
// Build update payload - only include provided fields
|
|
511
|
+
const updateData = {};
|
|
512
|
+
if (args.name) {
|
|
513
|
+
updateData.name = args.name;
|
|
514
|
+
}
|
|
515
|
+
if (typeof args.public === 'boolean') {
|
|
516
|
+
updateData.public = args.public;
|
|
517
|
+
}
|
|
518
|
+
if (args.sources) {
|
|
519
|
+
updateData.sources = normalizeFields(args.sources);
|
|
520
|
+
}
|
|
521
|
+
if (args.query) {
|
|
522
|
+
updateData.query = args.query;
|
|
523
|
+
}
|
|
524
|
+
// Validate at least one field is being updated
|
|
525
|
+
if (Object.keys(updateData).length === 0) {
|
|
526
|
+
return {
|
|
527
|
+
content: [{
|
|
528
|
+
type: 'text',
|
|
529
|
+
text: `❌ **No updates provided**\n\nYou must provide at least one field to update:\n- name\n- public\n- sources\n- query\n\nExample:\n\`\`\`javascript\nsave_insight({\n insightId: "${insightId}",\n name: "New Name"\n})\n\`\`\``,
|
|
530
|
+
}],
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
logger.debug('Calling v3.insight.update', {
|
|
534
|
+
insightId,
|
|
535
|
+
updateFields: Object.keys(updateData)
|
|
411
536
|
});
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
537
|
+
// Call v3.insight.update endpoint
|
|
538
|
+
// API expects: [insightId, updateData]
|
|
539
|
+
const result = await context.hailer.request('v3.insight.update', [
|
|
540
|
+
insightId,
|
|
541
|
+
updateData
|
|
542
|
+
]);
|
|
543
|
+
logger.debug('Insight update successful', {
|
|
544
|
+
insightId,
|
|
545
|
+
result: JSON.stringify(result)
|
|
546
|
+
});
|
|
547
|
+
// Build success response
|
|
548
|
+
let responseText = '✅ **Insight Updated Successfully**\n\n';
|
|
549
|
+
responseText += `**Insight ID:** \`${insightId}\`\n`;
|
|
550
|
+
responseText += '**Updated Fields:**\n';
|
|
551
|
+
if (args.name) {
|
|
552
|
+
responseText += `- Name: ${args.name}\n`;
|
|
553
|
+
}
|
|
554
|
+
if (typeof args.public === 'boolean') {
|
|
555
|
+
responseText += `- Public: ${args.public ? 'Yes' : 'No'}\n`;
|
|
556
|
+
}
|
|
557
|
+
if (args.sources) {
|
|
558
|
+
responseText += `- Sources: ${args.sources.length} workflow(s)\n`;
|
|
559
|
+
}
|
|
560
|
+
if (args.query) {
|
|
561
|
+
responseText += '- Query: Updated\n';
|
|
562
|
+
}
|
|
563
|
+
if (args.query) {
|
|
564
|
+
responseText += `\n**New SQL Query:**\n\`\`\`sql\n${args.query}\n\`\`\`\n`;
|
|
565
|
+
}
|
|
566
|
+
responseText += '\n💡 **Next Steps:**\n';
|
|
567
|
+
responseText += '- Use `run_insight` with the insightId to see results\n';
|
|
568
|
+
responseText += '- Use `run_insight` (sources + query) to test if you made query changes\n';
|
|
569
|
+
responseText += '- Use `list_insights` to see all insights\n';
|
|
570
|
+
return {
|
|
571
|
+
content: [{
|
|
572
|
+
type: 'text',
|
|
573
|
+
text: responseText,
|
|
574
|
+
}],
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
catch (error) {
|
|
578
|
+
if (!request_logger_1.RequestLogger.getCurrent()) {
|
|
579
|
+
logger.error('Error updating insight', error);
|
|
580
|
+
}
|
|
581
|
+
const errorMessage = (0, tool_helpers_1.extractErrorMessage)(error);
|
|
582
|
+
// Handle SQL syntax errors
|
|
583
|
+
if (errorMessage.toLowerCase().includes('sql') || errorMessage.toLowerCase().includes('syntax')) {
|
|
451
584
|
return {
|
|
452
585
|
content: [{
|
|
453
|
-
type:
|
|
454
|
-
text:
|
|
586
|
+
type: 'text',
|
|
587
|
+
text: `❌ **SQL Query Error**\n\nThere's a problem with your SQL query.\n\n**Error:** ${errorMessage}\n\n**Tips:**\n- Check column names match field names in sources\n- Check table names match source names\n- Use \`run_insight\` (sources + query) to test queries before updating\n- Make sure field IDs are correct (use \`describe_workflows\` with include:["schema"])`,
|
|
455
588
|
}],
|
|
456
589
|
};
|
|
457
590
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
logger.error("Error getting insight data", error);
|
|
461
|
-
let errorMessage = 'Unknown error occurred';
|
|
462
|
-
if (error instanceof Error) {
|
|
463
|
-
errorMessage = error.message;
|
|
464
|
-
}
|
|
465
|
-
else if (typeof error === 'object' && error !== null) {
|
|
466
|
-
try {
|
|
467
|
-
errorMessage = JSON.stringify(error, null, 2);
|
|
468
|
-
}
|
|
469
|
-
catch {
|
|
470
|
-
errorMessage = String(error);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
errorMessage = String(error);
|
|
475
|
-
}
|
|
591
|
+
// Handle permission errors
|
|
592
|
+
if (errorMessage.includes('permission') || errorMessage.includes('PermissionDenied')) {
|
|
476
593
|
return {
|
|
477
594
|
content: [{
|
|
478
|
-
type:
|
|
479
|
-
text: `❌ **
|
|
595
|
+
type: 'text',
|
|
596
|
+
text: `❌ **Permission Denied**\n\nYou may not have permission to update this insight.\n\n**Error:** ${errorMessage}`,
|
|
480
597
|
}],
|
|
481
598
|
};
|
|
482
599
|
}
|
|
600
|
+
// Handle not found errors
|
|
601
|
+
if (errorMessage.includes('not found') || errorMessage.includes('NotFound')) {
|
|
602
|
+
return {
|
|
603
|
+
content: [{
|
|
604
|
+
type: 'text',
|
|
605
|
+
text: `❌ **Insight Not Found**\n\nInsight ID \`${insightId}\` does not exist.\n\n**Error:** ${errorMessage}\n\n**Tips:**\n- Use \`list_insights\` to find valid insight IDs\n- Check for typos in the insight ID`,
|
|
606
|
+
}],
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
return {
|
|
610
|
+
content: [{
|
|
611
|
+
type: 'text',
|
|
612
|
+
text: `❌ **Error updating insight**\n\n**Error:** ${errorMessage}\n\n**Common Issues:**\n- Insight ID not found\n- SQL query syntax errors\n- Invalid field IDs or workflow IDs\n- Permission issues\n- Use \`list_insights\` to verify insight ID\n- Use \`run_insight\` (sources + query) to test query changes first`,
|
|
613
|
+
}],
|
|
614
|
+
};
|
|
483
615
|
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
// ============================================================================
|
|
488
|
-
const updateInsightDescription = `Update existing insight (name, query, sources, or visibility)`;
|
|
489
|
-
exports.updateInsightTool = {
|
|
490
|
-
name: 'update_insight',
|
|
616
|
+
}
|
|
617
|
+
exports.saveInsightTool = {
|
|
618
|
+
name: 'save_insight',
|
|
491
619
|
group: tool_registry_1.ToolGroup.PLAYGROUND,
|
|
492
|
-
description:
|
|
620
|
+
description: saveInsightDescription,
|
|
493
621
|
schema: zod_1.z.object({
|
|
622
|
+
workspaceId: zod_1.z
|
|
623
|
+
.string()
|
|
624
|
+
.optional()
|
|
625
|
+
.describe('Optional workspace ID or name - defaults to current workspace (create mode only)'),
|
|
494
626
|
insightId: zod_1.z
|
|
495
627
|
.string()
|
|
496
|
-
.
|
|
628
|
+
.optional()
|
|
629
|
+
.describe('Existing insight ID to update (24 characters). Omit to create a new insight.'),
|
|
497
630
|
name: zod_1.z
|
|
498
631
|
.string()
|
|
632
|
+
.min(1)
|
|
499
633
|
.optional()
|
|
500
|
-
.describe(
|
|
634
|
+
.describe('Insight name (required when creating)'),
|
|
501
635
|
public: zod_1.z
|
|
502
636
|
.coerce.boolean()
|
|
503
637
|
.optional()
|
|
504
|
-
.describe(
|
|
638
|
+
.describe('Whether insight is publicly accessible (default: false on create)'),
|
|
505
639
|
sources: zod_1.z
|
|
506
|
-
.preprocess((val) => typeof val === 'string' ? JSON.parse(val) : val, zod_1.z.array(sourceSchema).optional())
|
|
507
|
-
.describe(
|
|
640
|
+
.preprocess((val) => typeof val === 'string' ? JSON.parse(val) : val, zod_1.z.array(sourceSchema).min(1).optional())
|
|
641
|
+
.describe('Workflow sources (required when creating). source.name = SQL table name, field.name = SQL column name. Never use IDs in the query.'),
|
|
508
642
|
query: zod_1.z
|
|
509
643
|
.string()
|
|
644
|
+
.min(1)
|
|
510
645
|
.optional()
|
|
511
|
-
.describe(
|
|
646
|
+
.describe('SQL query (SELECT, JOIN, WHERE, GROUP BY, ORDER BY, etc.) - required when creating'),
|
|
512
647
|
}),
|
|
513
648
|
async execute(args, context) {
|
|
514
|
-
logger.debug('
|
|
649
|
+
logger.debug('Saving insight', {
|
|
515
650
|
insightId: args.insightId,
|
|
516
651
|
hasName: !!args.name,
|
|
517
652
|
hasQuery: !!args.query,
|
|
518
653
|
hasSources: !!args.sources,
|
|
519
|
-
hasPublic: args.public
|
|
654
|
+
hasPublic: typeof args.public === 'boolean',
|
|
520
655
|
apiKey: context.apiKey.substring(0, 8) + '...'
|
|
521
656
|
});
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
const updateData = {};
|
|
525
|
-
if (args.name !== undefined) {
|
|
526
|
-
updateData.name = args.name;
|
|
527
|
-
}
|
|
528
|
-
if (args.public !== undefined) {
|
|
529
|
-
updateData.public = args.public;
|
|
530
|
-
}
|
|
531
|
-
if (args.sources !== undefined) {
|
|
532
|
-
updateData.sources = normalizeFields(args.sources);
|
|
533
|
-
}
|
|
534
|
-
if (args.query !== undefined) {
|
|
535
|
-
updateData.query = args.query;
|
|
536
|
-
}
|
|
537
|
-
// Validate at least one field is being updated
|
|
538
|
-
if (Object.keys(updateData).length === 0) {
|
|
539
|
-
return {
|
|
540
|
-
content: [{
|
|
541
|
-
type: "text",
|
|
542
|
-
text: `❌ **No updates provided**\n\nYou must provide at least one field to update:\n- name\n- public\n- sources\n- query\n\nExample:\n\`\`\`javascript\nupdate_insight({\n insightId: "${args.insightId}",\n name: "New Name"\n})\n\`\`\``,
|
|
543
|
-
}],
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
logger.debug('Calling v3.insight.update', {
|
|
547
|
-
insightId: args.insightId,
|
|
548
|
-
updateFields: Object.keys(updateData)
|
|
549
|
-
});
|
|
550
|
-
// Call v3.insight.update endpoint
|
|
551
|
-
// API expects: [insightId, updateData]
|
|
552
|
-
const result = await context.hailer.request('v3.insight.update', [
|
|
553
|
-
args.insightId,
|
|
554
|
-
updateData
|
|
555
|
-
]);
|
|
556
|
-
logger.debug('Insight update successful', {
|
|
557
|
-
insightId: args.insightId,
|
|
558
|
-
result: JSON.stringify(result)
|
|
559
|
-
});
|
|
560
|
-
// Build success response
|
|
561
|
-
let responseText = `✅ **Insight Updated Successfully**\n\n`;
|
|
562
|
-
responseText += `**Insight ID:** \`${args.insightId}\`\n`;
|
|
563
|
-
responseText += `**Updated Fields:**\n`;
|
|
564
|
-
if (args.name !== undefined) {
|
|
565
|
-
responseText += `- Name: ${args.name}\n`;
|
|
566
|
-
}
|
|
567
|
-
if (args.public !== undefined) {
|
|
568
|
-
responseText += `- Public: ${args.public ? 'Yes' : 'No'}\n`;
|
|
569
|
-
}
|
|
570
|
-
if (args.sources !== undefined) {
|
|
571
|
-
responseText += `- Sources: ${args.sources.length} workflow(s)\n`;
|
|
572
|
-
}
|
|
573
|
-
if (args.query !== undefined) {
|
|
574
|
-
responseText += `- Query: Updated\n`;
|
|
575
|
-
}
|
|
576
|
-
if (args.query) {
|
|
577
|
-
responseText += `\n**New SQL Query:**\n\`\`\`sql\n${args.query}\n\`\`\`\n`;
|
|
578
|
-
}
|
|
579
|
-
responseText += `\n💡 **Next Steps:**\n`;
|
|
580
|
-
responseText += `- Use \`get_insight_data\` with \`update: true\` to see fresh results\n`;
|
|
581
|
-
responseText += `- Use \`preview_insight\` to test if you made query changes\n`;
|
|
582
|
-
responseText += `- Use \`list_insights\` to see all insights\n`;
|
|
583
|
-
return {
|
|
584
|
-
content: [{
|
|
585
|
-
type: "text",
|
|
586
|
-
text: responseText,
|
|
587
|
-
}],
|
|
588
|
-
};
|
|
589
|
-
}
|
|
590
|
-
catch (error) {
|
|
591
|
-
if (!request_logger_1.RequestLogger.getCurrent())
|
|
592
|
-
logger.error("Error updating insight", error);
|
|
593
|
-
const errorMessage = (0, tool_helpers_1.extractErrorMessage)(error);
|
|
594
|
-
// Handle SQL syntax errors
|
|
595
|
-
if (errorMessage.toLowerCase().includes('sql') || errorMessage.toLowerCase().includes('syntax')) {
|
|
596
|
-
return {
|
|
597
|
-
content: [{
|
|
598
|
-
type: "text",
|
|
599
|
-
text: `❌ **SQL Query Error**\n\nThere's a problem with your SQL query.\n\n**Error:** ${errorMessage}\n\n**Tips:**\n- Check column names match field names in sources\n- Check table names match source names\n- Use \`preview_insight\` to test queries before updating\n- Make sure field IDs are correct (use \`get_workflow_schema\`)`,
|
|
600
|
-
}],
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
// Handle permission errors
|
|
604
|
-
if (errorMessage.includes('permission') || errorMessage.includes('PermissionDenied')) {
|
|
605
|
-
return {
|
|
606
|
-
content: [{
|
|
607
|
-
type: "text",
|
|
608
|
-
text: `❌ **Permission Denied**\n\nYou may not have permission to update this insight.\n\n**Error:** ${errorMessage}`,
|
|
609
|
-
}],
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
// Handle not found errors
|
|
613
|
-
if (errorMessage.includes('not found') || errorMessage.includes('NotFound')) {
|
|
614
|
-
return {
|
|
615
|
-
content: [{
|
|
616
|
-
type: "text",
|
|
617
|
-
text: `❌ **Insight Not Found**\n\nInsight ID \`${args.insightId}\` does not exist.\n\n**Error:** ${errorMessage}\n\n**Tips:**\n- Use \`list_insights\` to find valid insight IDs\n- Check for typos in the insight ID`,
|
|
618
|
-
}],
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
return {
|
|
622
|
-
content: [{
|
|
623
|
-
type: "text",
|
|
624
|
-
text: `❌ **Error updating insight**\n\n**Error:** ${errorMessage}\n\n**Common Issues:**\n- Insight ID not found\n- SQL query syntax errors\n- Invalid field IDs or workflow IDs\n- Permission issues\n- Use \`list_insights\` to verify insight ID\n- Use \`preview_insight\` to test query changes first`,
|
|
625
|
-
}],
|
|
626
|
-
};
|
|
657
|
+
if (args.insightId) {
|
|
658
|
+
return updateExistingInsight(args.insightId, args, context);
|
|
627
659
|
}
|
|
660
|
+
return createNewInsight(args, context);
|
|
628
661
|
}
|
|
629
662
|
};
|
|
630
663
|
// ============================================================================
|
|
@@ -638,15 +671,15 @@ exports.removeInsightTool = {
|
|
|
638
671
|
schema: zod_1.z.object({
|
|
639
672
|
insightId: zod_1.z
|
|
640
673
|
.string()
|
|
641
|
-
.describe(
|
|
674
|
+
.describe('Insight ID to remove (get from list_insights or save_insight)'),
|
|
642
675
|
confirmed: zod_1.z
|
|
643
676
|
.boolean()
|
|
644
677
|
.optional()
|
|
645
|
-
.describe(
|
|
678
|
+
.describe('First confirmation - must be true to proceed'),
|
|
646
679
|
secondConfirmed: zod_1.z
|
|
647
680
|
.boolean()
|
|
648
681
|
.optional()
|
|
649
|
-
.describe(
|
|
682
|
+
.describe('Second confirmation - must be true to proceed (required for double-check safety)'),
|
|
650
683
|
}),
|
|
651
684
|
async execute(args, context) {
|
|
652
685
|
logger.debug('Removing insight', {
|
|
@@ -664,7 +697,7 @@ exports.removeInsightTool = {
|
|
|
664
697
|
// Fetch insight info and workspace info
|
|
665
698
|
const [insightListResult, initData] = await Promise.all([
|
|
666
699
|
context.hailer.request('v3.insight.list', [workspaceId]),
|
|
667
|
-
context.hailer.request('v2.core.init', [[
|
|
700
|
+
context.hailer.request('v2.core.init', [['network']])
|
|
668
701
|
]);
|
|
669
702
|
const insights = Array.isArray(insightListResult) ? insightListResult : (insightListResult.details || insightListResult.insights || []);
|
|
670
703
|
const insight = insights.find((i) => i._id === args.insightId);
|
|
@@ -695,11 +728,11 @@ exports.removeInsightTool = {
|
|
|
695
728
|
warningText += `\`\`\`\n\n`;
|
|
696
729
|
warningText += `💡 **Before proceeding:**\n`;
|
|
697
730
|
warningText += `- Load \`remove-insight-skill\` to review safety checklist\n`;
|
|
698
|
-
warningText += `- Use \`
|
|
731
|
+
warningText += `- Use \`run_insight\` to verify before deleting\n`;
|
|
699
732
|
warningText += `- Verify with user that this is intentional`;
|
|
700
733
|
return {
|
|
701
734
|
content: [{
|
|
702
|
-
type:
|
|
735
|
+
type: 'text',
|
|
703
736
|
text: warningText,
|
|
704
737
|
}],
|
|
705
738
|
};
|
|
@@ -724,14 +757,15 @@ exports.removeInsightTool = {
|
|
|
724
757
|
responseText += `💡 Use \`list_insights\` to see remaining insights.`;
|
|
725
758
|
return {
|
|
726
759
|
content: [{
|
|
727
|
-
type:
|
|
760
|
+
type: 'text',
|
|
728
761
|
text: responseText,
|
|
729
762
|
}],
|
|
730
763
|
};
|
|
731
764
|
}
|
|
732
765
|
catch (error) {
|
|
733
|
-
if (!request_logger_1.RequestLogger.getCurrent())
|
|
734
|
-
logger.error(
|
|
766
|
+
if (!request_logger_1.RequestLogger.getCurrent()) {
|
|
767
|
+
logger.error('Error removing insight', error);
|
|
768
|
+
}
|
|
735
769
|
let errorMessage = 'Unknown error occurred';
|
|
736
770
|
if (error instanceof Error) {
|
|
737
771
|
errorMessage = error.message;
|
|
@@ -749,14 +783,14 @@ exports.removeInsightTool = {
|
|
|
749
783
|
}
|
|
750
784
|
return {
|
|
751
785
|
content: [{
|
|
752
|
-
type:
|
|
786
|
+
type: 'text',
|
|
753
787
|
text: `❌ **Error removing insight**\n\n**Error:** ${errorMessage}\n\n**Common Issues:**\n- Insight ID not found\n- Permission denied\n- Insight already deleted\n- Use \`list_insights\` to verify insight ID`,
|
|
754
788
|
}],
|
|
755
789
|
};
|
|
756
790
|
}
|
|
757
791
|
}
|
|
758
792
|
};
|
|
759
|
-
const listInsightsDescription = `List all insights in workspace
|
|
793
|
+
const listInsightsDescription = `List all insights in the workspace (name, ID, table names, query). Check here BEFORE save_insight — reuse or update an existing insight instead of creating near-duplicates.`;
|
|
760
794
|
exports.listInsightsTool = {
|
|
761
795
|
name: 'list_insights',
|
|
762
796
|
group: tool_registry_1.ToolGroup.PLAYGROUND,
|
|
@@ -765,7 +799,7 @@ exports.listInsightsTool = {
|
|
|
765
799
|
workspaceId: zod_1.z
|
|
766
800
|
.string()
|
|
767
801
|
.optional()
|
|
768
|
-
.describe(
|
|
802
|
+
.describe('Optional workspace ID or name - defaults to current workspace'),
|
|
769
803
|
}),
|
|
770
804
|
async execute(args, context) {
|
|
771
805
|
logger.debug('Listing insights', {
|
|
@@ -792,7 +826,7 @@ exports.listInsightsTool = {
|
|
|
792
826
|
let responseText = `📊 **Insights Found** (${insights.length || 0} total)\n\n`;
|
|
793
827
|
if (!insights || insights.length === 0) {
|
|
794
828
|
responseText += `No insights found in this workspace.\n\n`;
|
|
795
|
-
responseText += `💡 Use \`
|
|
829
|
+
responseText += `💡 Use \`save_insight\` to create a new SQL-like report.`;
|
|
796
830
|
}
|
|
797
831
|
else {
|
|
798
832
|
insights.forEach((insight, index) => {
|
|
@@ -807,20 +841,21 @@ exports.listInsightsTool = {
|
|
|
807
841
|
responseText += ` - Query: \`${insight.query?.substring(0, 80)}${(insight.query?.length || 0) > 80 ? '...' : ''}\`\n\n`;
|
|
808
842
|
});
|
|
809
843
|
responseText += `💡 **Next Steps:**\n`;
|
|
810
|
-
responseText += `- Use \`
|
|
811
|
-
responseText += `- Use \`
|
|
844
|
+
responseText += `- Use \`run_insight\` with an insightId to execute an insight\n`;
|
|
845
|
+
responseText += `- Use \`run_insight\` with sources + query to test changes\n`;
|
|
812
846
|
responseText += `- Use \`remove_insight\` to delete an insight\n`;
|
|
813
847
|
}
|
|
814
848
|
return {
|
|
815
849
|
content: [{
|
|
816
|
-
type:
|
|
850
|
+
type: 'text',
|
|
817
851
|
text: responseText,
|
|
818
852
|
}],
|
|
819
853
|
};
|
|
820
854
|
}
|
|
821
855
|
catch (error) {
|
|
822
|
-
if (!request_logger_1.RequestLogger.getCurrent())
|
|
823
|
-
logger.error(
|
|
856
|
+
if (!request_logger_1.RequestLogger.getCurrent()) {
|
|
857
|
+
logger.error('Error listing insights', error);
|
|
858
|
+
}
|
|
824
859
|
let errorMessage = 'Unknown error occurred';
|
|
825
860
|
if (error instanceof Error) {
|
|
826
861
|
errorMessage = error.message;
|
|
@@ -838,7 +873,7 @@ exports.listInsightsTool = {
|
|
|
838
873
|
}
|
|
839
874
|
return {
|
|
840
875
|
content: [{
|
|
841
|
-
type:
|
|
876
|
+
type: 'text',
|
|
842
877
|
text: `❌ **Error listing insights**\n\n**Error:** ${errorMessage}\n\n**Tips:**\n- Check workspace ID is valid\n- Verify you have permission to list insights`,
|
|
843
878
|
}],
|
|
844
879
|
};
|
|
@@ -847,11 +882,9 @@ exports.listInsightsTool = {
|
|
|
847
882
|
};
|
|
848
883
|
/** All insight tools */
|
|
849
884
|
exports.insightTools = [
|
|
850
|
-
exports.createInsightTool,
|
|
851
|
-
exports.previewInsightTool,
|
|
852
|
-
exports.getInsightDataTool,
|
|
853
|
-
exports.updateInsightTool,
|
|
854
|
-
exports.removeInsightTool,
|
|
855
885
|
exports.listInsightsTool,
|
|
886
|
+
exports.runInsightTool,
|
|
887
|
+
exports.saveInsightTool,
|
|
888
|
+
exports.removeInsightTool,
|
|
856
889
|
];
|
|
857
890
|
//# sourceMappingURL=insight.js.map
|