@hailer/mcp 1.1.14 → 1.1.16
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/CLAUDE.md +370 -0
- package/.claude/agents/agent-ada-skill-builder.md +94 -0
- package/.claude/agents/agent-alejandro-function-fields.md +342 -0
- package/.claude/agents/agent-bjorn-config-audit.md +103 -0
- package/.claude/agents/agent-builder-agent-creator.md +130 -0
- package/.claude/agents/agent-code-simplifier.md +53 -0
- package/.claude/agents/agent-dmitri-activity-crud.md +159 -0
- package/.claude/agents/agent-giuseppe-app-builder.md +208 -0
- package/.claude/agents/agent-gunther-mcp-tools.md +39 -0
- package/.claude/agents/agent-helga-workflow-config.md +204 -0
- package/.claude/agents/agent-igor-activity-mover-automation.md +125 -0
- package/.claude/agents/agent-ingrid-doc-templates.md +261 -0
- package/.claude/agents/agent-ivan-monolith.md +154 -0
- package/.claude/agents/agent-kenji-data-reader.md +86 -0
- package/.claude/agents/agent-lars-code-inspector.md +102 -0
- package/.claude/agents/agent-marco-mockup-builder.md +110 -0
- package/.claude/agents/agent-marcus-api-documenter.md +323 -0
- package/.claude/agents/agent-marketplace-publisher.md +280 -0
- package/.claude/agents/agent-marketplace-reviewer.md +309 -0
- package/.claude/agents/agent-permissions-handler.md +208 -0
- package/.claude/agents/agent-simple-writer.md +48 -0
- package/.claude/agents/agent-svetlana-code-review.md +171 -0
- package/.claude/agents/agent-tanya-test-runner.md +333 -0
- package/.claude/agents/agent-ui-designer.md +100 -0
- package/.claude/agents/agent-viktor-sql-insights.md +212 -0
- package/.claude/agents/agent-web-search.md +55 -0
- package/.claude/agents/agent-yevgeni-discussions.md +45 -0
- package/.claude/agents/agent-zara-zapier.md +159 -0
- package/.claude/agents/ragnar.md +68 -0
- package/.claude/commands/app-squad.md +135 -0
- package/.claude/commands/audit-squad.md +158 -0
- package/.claude/commands/autoplan.md +563 -0
- package/.claude/commands/cleanup-squad.md +98 -0
- package/.claude/commands/config-squad.md +106 -0
- package/.claude/commands/crud-squad.md +87 -0
- package/.claude/commands/data-squad.md +97 -0
- package/.claude/commands/debug-squad.md +303 -0
- package/.claude/commands/doc-squad.md +65 -0
- package/.claude/commands/handoff.md +137 -0
- package/.claude/commands/health.md +49 -0
- package/.claude/commands/help.md +29 -0
- package/.claude/commands/help:agents.md +151 -0
- package/.claude/commands/help:commands.md +78 -0
- package/.claude/commands/help:faq.md +79 -0
- package/.claude/commands/help:plugins.md +50 -0
- package/.claude/commands/help:skills.md +93 -0
- package/.claude/commands/help:tools.md +75 -0
- package/.claude/commands/hotfix-squad.md +112 -0
- package/.claude/commands/integration-squad.md +82 -0
- package/.claude/commands/janitor-squad.md +167 -0
- package/.claude/commands/learn-auto.md +120 -0
- package/.claude/commands/learn.md +120 -0
- package/.claude/commands/mcp-list.md +27 -0
- package/.claude/commands/onboard-squad.md +140 -0
- package/.claude/commands/plan-workspace.md +732 -0
- package/.claude/commands/prd.md +130 -0
- package/.claude/commands/project-status.md +82 -0
- package/.claude/commands/publish.md +138 -0
- package/.claude/commands/recap.md +69 -0
- package/.claude/commands/restore.md +64 -0
- package/.claude/commands/review-squad.md +152 -0
- package/.claude/commands/save.md +24 -0
- package/.claude/commands/stats.md +19 -0
- package/.claude/commands/swarm.md +210 -0
- package/.claude/commands/tool-builder.md +39 -0
- package/.claude/commands/ws-pull.md +44 -0
- package/.claude/skills/SDK-activity-patterns/SKILL.md +428 -0
- package/.claude/skills/SDK-document-templates/SKILL.md +1033 -0
- package/.claude/skills/SDK-function-fields/SKILL.md +542 -0
- package/.claude/skills/SDK-generate-skill/SKILL.md +92 -0
- package/.claude/skills/SDK-init-skill/SKILL.md +127 -0
- package/.claude/skills/SDK-insight-queries/SKILL.md +787 -0
- package/.claude/skills/SDK-ws-config-skill/SKILL.md +1139 -0
- package/.claude/skills/agent-structure/SKILL.md +98 -0
- package/.claude/skills/api-documentation-patterns/SKILL.md +474 -0
- package/.claude/skills/chrome-mcp-reference/SKILL.md +370 -0
- package/.claude/skills/delegation-routing/SKILL.md +202 -0
- package/.claude/skills/frontend-design/SKILL.md +254 -0
- package/.claude/skills/hailer-activity-mover/SKILL.md +213 -0
- package/.claude/skills/hailer-api-client/SKILL.md +518 -0
- package/.claude/skills/hailer-app-builder/SKILL.md +1440 -0
- package/.claude/skills/hailer-apps-pictures/SKILL.md +269 -0
- package/.claude/skills/hailer-design-system/SKILL.md +231 -0
- package/.claude/skills/hailer-monolith-automations/SKILL.md +686 -0
- package/.claude/skills/hailer-permissions-system/SKILL.md +121 -0
- package/.claude/skills/hailer-project-protocol/SKILL.md +488 -0
- package/.claude/skills/hailer-rest-api/SKILL.md +61 -0
- package/.claude/skills/hailer-rest-api/hailer-activities.md +184 -0
- package/.claude/skills/hailer-rest-api/hailer-admin.md +473 -0
- package/.claude/skills/hailer-rest-api/hailer-calendar.md +256 -0
- package/.claude/skills/hailer-rest-api/hailer-feed.md +249 -0
- package/.claude/skills/hailer-rest-api/hailer-insights.md +195 -0
- package/.claude/skills/hailer-rest-api/hailer-messaging.md +276 -0
- package/.claude/skills/hailer-rest-api/hailer-workflows.md +283 -0
- package/.claude/skills/insight-join-patterns/SKILL.md +174 -0
- package/.claude/skills/integration-patterns/SKILL.md +421 -0
- package/.claude/skills/json-only-output/SKILL.md +72 -0
- package/.claude/skills/lsp-setup/SKILL.md +160 -0
- package/.claude/skills/mcp-direct-tools/SKILL.md +153 -0
- package/.claude/skills/optional-parameters/SKILL.md +72 -0
- package/.claude/skills/publish-hailer-app/SKILL.md +221 -0
- package/.claude/skills/testing-patterns/SKILL.md +630 -0
- package/.claude/skills/tool-builder/SKILL.md +250 -0
- package/.claude/skills/tool-parameter-usage/SKILL.md +126 -0
- package/.claude/skills/tool-response-verification/SKILL.md +92 -0
- package/.claude/skills/zapier-hailer-patterns/SKILL.md +581 -0
- package/.opencode/agent/agent-ada-skill-builder.md +35 -0
- package/.opencode/agent/agent-alejandro-function-fields.md +39 -0
- package/.opencode/agent/agent-bjorn-config-audit.md +36 -0
- package/.opencode/agent/agent-builder-agent-creator.md +39 -0
- package/.opencode/agent/agent-code-simplifier.md +31 -0
- package/.opencode/agent/agent-dmitri-activity-crud.md +40 -0
- package/.opencode/agent/agent-giuseppe-app-builder.md +37 -0
- package/.opencode/agent/agent-gunther-mcp-tools.md +39 -0
- package/.opencode/agent/agent-helga-workflow-config.md +204 -0
- package/.opencode/agent/agent-igor-activity-mover-automation.md +46 -0
- package/.opencode/agent/agent-ingrid-doc-templates.md +39 -0
- package/.opencode/agent/agent-ivan-monolith.md +46 -0
- package/.opencode/agent/agent-kenji-data-reader.md +53 -0
- package/.opencode/agent/agent-lars-code-inspector.md +28 -0
- package/.opencode/agent/agent-marco-mockup-builder.md +42 -0
- package/.opencode/agent/agent-marcus-api-documenter.md +53 -0
- package/.opencode/agent/agent-marketplace-publisher.md +44 -0
- package/.opencode/agent/agent-marketplace-reviewer.md +42 -0
- package/.opencode/agent/agent-permissions-handler.md +50 -0
- package/.opencode/agent/agent-simple-writer.md +45 -0
- package/.opencode/agent/agent-svetlana-code-review.md +39 -0
- package/.opencode/agent/agent-tanya-test-runner.md +57 -0
- package/.opencode/agent/agent-ui-designer.md +56 -0
- package/.opencode/agent/agent-viktor-sql-insights.md +34 -0
- package/.opencode/agent/agent-web-search.md +42 -0
- package/.opencode/agent/agent-yevgeni-discussions.md +37 -0
- package/.opencode/agent/agent-zara-zapier.md +53 -0
- package/.opencode/commands/app-squad.md +135 -0
- package/.opencode/commands/audit-squad.md +158 -0
- package/.opencode/commands/autoplan.md +563 -0
- package/.opencode/commands/cleanup-squad.md +98 -0
- package/.opencode/commands/config-squad.md +106 -0
- package/.opencode/commands/crud-squad.md +87 -0
- package/.opencode/commands/data-squad.md +97 -0
- package/.opencode/commands/debug-squad.md +303 -0
- package/.opencode/commands/doc-squad.md +65 -0
- package/.opencode/commands/handoff.md +137 -0
- package/.opencode/commands/health.md +49 -0
- package/.opencode/commands/help-agents.md +151 -0
- package/.opencode/commands/help-commands.md +32 -0
- package/.opencode/commands/help-faq.md +29 -0
- package/.opencode/commands/help-plugins.md +28 -0
- package/.opencode/commands/help-skills.md +7 -0
- package/.opencode/commands/help-tools.md +40 -0
- package/.opencode/commands/help.md +28 -0
- package/.opencode/commands/hotfix-squad.md +112 -0
- package/.opencode/commands/integration-squad.md +82 -0
- package/.opencode/commands/janitor-squad.md +167 -0
- package/.opencode/commands/learn-auto.md +120 -0
- package/.opencode/commands/learn.md +120 -0
- package/.opencode/commands/mcp-list.md +27 -0
- package/.opencode/commands/onboard-squad.md +140 -0
- package/.opencode/commands/plan-workspace.md +732 -0
- package/.opencode/commands/prd.md +131 -0
- package/.opencode/commands/project-status.md +82 -0
- package/.opencode/commands/publish.md +138 -0
- package/.opencode/commands/recap.md +69 -0
- package/.opencode/commands/restore.md +64 -0
- package/.opencode/commands/review-squad.md +152 -0
- package/.opencode/commands/save.md +24 -0
- package/.opencode/commands/stats.md +19 -0
- package/.opencode/commands/swarm.md +210 -0
- package/.opencode/commands/tool-builder.md +39 -0
- package/.opencode/commands/ws-pull.md +44 -0
- package/.opencode/opencode.json +21 -0
- package/dist/agents/bot-manager.d.ts +48 -0
- package/dist/agents/bot-manager.d.ts.map +1 -0
- package/dist/agents/bot-manager.js +254 -0
- package/dist/agents/bot-manager.js.map +1 -0
- package/dist/agents/bug-fixer/ai.d.ts +80 -0
- package/dist/agents/bug-fixer/ai.d.ts.map +1 -0
- package/dist/agents/bug-fixer/ai.js +466 -0
- package/dist/agents/bug-fixer/ai.js.map +1 -0
- package/dist/agents/bug-fixer/bot.d.ts +92 -0
- package/dist/agents/bug-fixer/bot.d.ts.map +1 -0
- package/dist/agents/bug-fixer/bot.js +687 -0
- package/dist/agents/bug-fixer/bot.js.map +1 -0
- package/dist/agents/bug-fixer/config.d.ts +21 -0
- package/dist/agents/bug-fixer/config.d.ts.map +1 -0
- package/dist/agents/bug-fixer/config.js +218 -0
- package/dist/agents/bug-fixer/config.js.map +1 -0
- package/dist/agents/bug-fixer/files.d.ts +67 -0
- package/dist/agents/bug-fixer/files.d.ts.map +1 -0
- package/dist/agents/bug-fixer/files.js +386 -0
- package/dist/agents/bug-fixer/files.js.map +1 -0
- package/dist/agents/bug-fixer/git.d.ts +48 -0
- package/dist/agents/bug-fixer/git.d.ts.map +1 -0
- package/dist/agents/bug-fixer/git.js +298 -0
- package/dist/agents/bug-fixer/git.js.map +1 -0
- package/dist/agents/bug-fixer/index.d.ts +103 -0
- package/dist/agents/bug-fixer/index.d.ts.map +1 -0
- package/dist/agents/bug-fixer/index.js +262 -0
- package/dist/agents/bug-fixer/index.js.map +1 -0
- package/dist/agents/bug-fixer/lsp.d.ts +113 -0
- package/dist/agents/bug-fixer/lsp.d.ts.map +1 -0
- package/dist/agents/bug-fixer/lsp.js +485 -0
- package/dist/agents/bug-fixer/lsp.js.map +1 -0
- package/dist/agents/bug-fixer/monitor.d.ts +123 -0
- package/dist/agents/bug-fixer/monitor.d.ts.map +1 -0
- package/dist/agents/bug-fixer/monitor.js +629 -0
- package/dist/agents/bug-fixer/monitor.js.map +1 -0
- package/dist/agents/bug-fixer/prompt.d.ts +5 -0
- package/dist/agents/bug-fixer/prompt.d.ts.map +1 -0
- package/dist/agents/bug-fixer/prompt.js +94 -0
- package/dist/agents/bug-fixer/prompt.js.map +1 -0
- package/dist/agents/bug-fixer/registries/pending-classification.d.ts +28 -0
- package/dist/agents/bug-fixer/registries/pending-classification.d.ts.map +1 -0
- package/dist/agents/bug-fixer/registries/pending-classification.js +50 -0
- package/dist/agents/bug-fixer/registries/pending-classification.js.map +1 -0
- package/dist/agents/bug-fixer/registries/pending-fix.d.ts +33 -0
- package/dist/agents/bug-fixer/registries/pending-fix.d.ts.map +1 -0
- package/dist/agents/bug-fixer/registries/pending-fix.js +64 -0
- package/dist/agents/bug-fixer/registries/pending-fix.js.map +1 -0
- package/dist/agents/bug-fixer/registries/pending.d.ts +27 -0
- package/dist/agents/bug-fixer/registries/pending.d.ts.map +1 -0
- package/dist/agents/bug-fixer/registries/pending.js +49 -0
- package/dist/agents/bug-fixer/registries/pending.js.map +1 -0
- package/dist/agents/bug-fixer/specialist-daemon.d.ts +88 -0
- package/dist/agents/bug-fixer/specialist-daemon.d.ts.map +1 -0
- package/dist/agents/bug-fixer/specialist-daemon.js +431 -0
- package/dist/agents/bug-fixer/specialist-daemon.js.map +1 -0
- package/dist/agents/bug-fixer/specialist.d.ts +47 -0
- package/dist/agents/bug-fixer/specialist.d.ts.map +1 -0
- package/dist/agents/bug-fixer/specialist.js +327 -0
- package/dist/agents/bug-fixer/specialist.js.map +1 -0
- package/dist/agents/bug-fixer/types.d.ts +123 -0
- package/dist/agents/bug-fixer/types.d.ts.map +1 -0
- package/dist/agents/bug-fixer/types.js +9 -0
- package/dist/agents/bug-fixer/types.js.map +1 -0
- package/dist/agents/factory.d.ts +172 -0
- package/dist/agents/factory.d.ts.map +1 -0
- package/dist/agents/factory.js +706 -0
- package/dist/agents/factory.js.map +1 -0
- package/dist/agents/hailer-expert/index.d.ts +8 -0
- package/dist/agents/hailer-expert/index.d.ts.map +1 -0
- package/dist/agents/hailer-expert/index.js +14 -0
- package/dist/agents/hailer-expert/index.js.map +1 -0
- package/dist/agents/hal/daemon.d.ts +174 -0
- package/dist/agents/hal/daemon.d.ts.map +1 -0
- package/dist/agents/hal/daemon.js +1385 -0
- package/dist/agents/hal/daemon.js.map +1 -0
- package/dist/agents/hal/definitions.d.ts +42 -0
- package/dist/agents/hal/definitions.d.ts.map +1 -0
- package/dist/agents/hal/definitions.js +300 -0
- package/dist/agents/hal/definitions.js.map +1 -0
- package/dist/agents/hal/index.d.ts +3 -0
- package/dist/agents/hal/index.d.ts.map +1 -0
- package/dist/agents/hal/index.js +8 -0
- package/dist/agents/hal/index.js.map +1 -0
- package/dist/agents/index.d.ts +18 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +48 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/shared/base.d.ts +253 -0
- package/dist/agents/shared/base.d.ts.map +1 -0
- package/dist/agents/shared/base.js +1122 -0
- package/dist/agents/shared/base.js.map +1 -0
- package/dist/agents/shared/schemas/action-schema.d.ts +62 -0
- package/dist/agents/shared/schemas/action-schema.d.ts.map +1 -0
- package/dist/agents/shared/schemas/action-schema.js +483 -0
- package/dist/agents/shared/schemas/action-schema.js.map +1 -0
- package/dist/agents/shared/services/agent-registry.d.ts +108 -0
- package/dist/agents/shared/services/agent-registry.d.ts.map +1 -0
- package/dist/agents/shared/services/agent-registry.js +469 -0
- package/dist/agents/shared/services/agent-registry.js.map +1 -0
- package/dist/agents/shared/services/conversation-manager.d.ts +57 -0
- package/dist/agents/shared/services/conversation-manager.d.ts.map +1 -0
- package/dist/agents/shared/services/conversation-manager.js +168 -0
- package/dist/agents/shared/services/conversation-manager.js.map +1 -0
- package/dist/agents/shared/services/mcp-client.d.ts +56 -0
- package/dist/agents/shared/services/mcp-client.d.ts.map +1 -0
- package/dist/agents/shared/services/mcp-client.js +124 -0
- package/dist/agents/shared/services/mcp-client.js.map +1 -0
- package/dist/agents/shared/services/message-classifier.d.ts +37 -0
- package/dist/agents/shared/services/message-classifier.d.ts.map +1 -0
- package/dist/agents/shared/services/message-classifier.js +203 -0
- package/dist/agents/shared/services/message-classifier.js.map +1 -0
- package/dist/agents/shared/services/message-formatter.d.ts +89 -0
- package/dist/agents/shared/services/message-formatter.d.ts.map +1 -0
- package/dist/agents/shared/services/message-formatter.js +390 -0
- package/dist/agents/shared/services/message-formatter.js.map +1 -0
- package/dist/agents/shared/services/session-logger.d.ts +162 -0
- package/dist/agents/shared/services/session-logger.d.ts.map +1 -0
- package/dist/agents/shared/services/session-logger.js +724 -0
- package/dist/agents/shared/services/session-logger.js.map +1 -0
- package/dist/agents/shared/services/structured-output-executor.d.ts +88 -0
- package/dist/agents/shared/services/structured-output-executor.d.ts.map +1 -0
- package/dist/agents/shared/services/structured-output-executor.js +296 -0
- package/dist/agents/shared/services/structured-output-executor.js.map +1 -0
- package/dist/agents/shared/services/token-billing.d.ts +72 -0
- package/dist/agents/shared/services/token-billing.d.ts.map +1 -0
- package/dist/agents/shared/services/token-billing.js +198 -0
- package/dist/agents/shared/services/token-billing.js.map +1 -0
- package/dist/agents/shared/services/tool-executor.d.ts +43 -0
- package/dist/agents/shared/services/tool-executor.d.ts.map +1 -0
- package/dist/agents/shared/services/tool-executor.js +175 -0
- package/dist/agents/shared/services/tool-executor.js.map +1 -0
- package/dist/agents/shared/services/typing-indicator.d.ts +24 -0
- package/dist/agents/shared/services/typing-indicator.d.ts.map +1 -0
- package/dist/agents/shared/services/typing-indicator.js +54 -0
- package/dist/agents/shared/services/typing-indicator.js.map +1 -0
- package/dist/agents/shared/services/workspace-schema-cache.d.ts +122 -0
- package/dist/agents/shared/services/workspace-schema-cache.d.ts.map +1 -0
- package/dist/agents/shared/services/workspace-schema-cache.js +507 -0
- package/dist/agents/shared/services/workspace-schema-cache.js.map +1 -0
- package/dist/agents/shared/specialist.d.ts +91 -0
- package/dist/agents/shared/specialist.d.ts.map +1 -0
- package/dist/agents/shared/specialist.js +399 -0
- package/dist/agents/shared/specialist.js.map +1 -0
- package/dist/agents/shared/tool-schema-loader.d.ts +65 -0
- package/dist/agents/shared/tool-schema-loader.d.ts.map +1 -0
- package/dist/agents/shared/tool-schema-loader.js +238 -0
- package/dist/agents/shared/tool-schema-loader.js.map +1 -0
- package/dist/agents/shared/types.d.ts +190 -0
- package/dist/agents/shared/types.d.ts.map +1 -0
- package/dist/agents/shared/types.js +13 -0
- package/dist/agents/shared/types.js.map +1 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js.map +1 -0
- package/dist/bot/bot-config.d.ts.map +1 -0
- package/dist/bot/bot-config.js.map +1 -0
- package/dist/bot/bot-manager.d.ts.map +1 -0
- package/dist/bot/bot-manager.js.map +1 -0
- package/dist/bot/bot.d.ts.map +1 -0
- package/dist/bot/bot.js.map +1 -0
- package/dist/bot/operation-logger.d.ts.map +1 -0
- package/dist/bot/operation-logger.js.map +1 -0
- package/dist/bot/services/__tests__/permission-guard.test.d.ts +2 -0
- package/dist/bot/services/__tests__/permission-guard.test.d.ts.map +1 -0
- package/dist/bot/services/__tests__/permission-guard.test.js +357 -0
- package/dist/bot/services/__tests__/permission-guard.test.js.map +1 -0
- package/dist/bot/services/conversation-manager.d.ts.map +1 -0
- package/dist/bot/services/conversation-manager.js.map +1 -0
- package/dist/bot/services/index.d.ts.map +1 -0
- package/dist/bot/services/index.js.map +1 -0
- package/dist/bot/services/message-classifier.d.ts.map +1 -0
- package/dist/bot/services/message-classifier.js.map +1 -0
- package/dist/bot/services/message-formatter.d.ts.map +1 -0
- package/dist/bot/services/message-formatter.js.map +1 -0
- package/dist/bot/services/permission-guard.d.ts.map +1 -0
- package/dist/bot/services/permission-guard.js.map +1 -0
- package/dist/bot/services/session-logger.d.ts.map +1 -0
- package/dist/bot/services/session-logger.js.map +1 -0
- package/dist/bot/services/token-billing.d.ts.map +1 -0
- package/dist/bot/services/token-billing.js.map +1 -0
- package/dist/bot/services/types.d.ts.map +1 -0
- package/dist/bot/services/types.js.map +1 -0
- package/dist/bot/services/typing-indicator.d.ts.map +1 -0
- package/dist/bot/services/typing-indicator.js.map +1 -0
- package/dist/bot/services/workspace-schema-cache.d.ts.map +1 -0
- package/dist/bot/services/workspace-schema-cache.js.map +1 -0
- package/dist/bot/tool-executor.d.ts.map +1 -0
- package/dist/bot/tool-executor.js.map +1 -0
- package/dist/bot/workspace-overview.d.ts.map +1 -0
- package/dist/bot/workspace-overview.js.map +1 -0
- package/dist/bot-config/constants.d.ts +42 -0
- package/dist/bot-config/constants.d.ts.map +1 -0
- package/dist/bot-config/constants.js +118 -0
- package/dist/bot-config/constants.js.map +1 -0
- package/dist/bot-config/context.d.ts +157 -0
- package/dist/bot-config/context.d.ts.map +1 -0
- package/dist/bot-config/context.js +475 -0
- package/dist/bot-config/context.js.map +1 -0
- package/dist/bot-config/index.d.ts +21 -0
- package/dist/bot-config/index.d.ts.map +1 -0
- package/dist/bot-config/index.js +104 -0
- package/dist/bot-config/index.js.map +1 -0
- package/dist/bot-config/loader.d.ts +28 -0
- package/dist/bot-config/loader.d.ts.map +1 -0
- package/dist/bot-config/loader.js +194 -0
- package/dist/bot-config/loader.js.map +1 -0
- package/dist/bot-config/persistence.d.ts +68 -0
- package/dist/bot-config/persistence.d.ts.map +1 -0
- package/dist/bot-config/persistence.js +261 -0
- package/dist/bot-config/persistence.js.map +1 -0
- package/dist/bot-config/state.d.ts +56 -0
- package/dist/bot-config/state.d.ts.map +1 -0
- package/dist/bot-config/state.js +197 -0
- package/dist/bot-config/state.js.map +1 -0
- package/dist/bot-config/tools.d.ts +28 -0
- package/dist/bot-config/tools.d.ts.map +1 -0
- package/dist/bot-config/tools.js +279 -0
- package/dist/bot-config/tools.js.map +1 -0
- package/dist/bot-config/types.d.ts +45 -0
- package/dist/bot-config/types.d.ts.map +1 -0
- package/dist/bot-config/types.js +9 -0
- package/dist/bot-config/types.js.map +1 -0
- package/dist/bot-config/webhooks.d.ts +27 -0
- package/dist/bot-config/webhooks.d.ts.map +1 -0
- package/dist/bot-config/webhooks.js +212 -0
- package/dist/bot-config/webhooks.js.map +1 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/agents/base.d.ts +207 -0
- package/dist/client/agents/base.d.ts.map +1 -0
- package/dist/client/agents/base.js +744 -0
- package/dist/client/agents/base.js.map +1 -0
- package/dist/client/agents/definitions.d.ts +53 -0
- package/dist/client/agents/definitions.d.ts.map +1 -0
- package/dist/client/agents/definitions.js +263 -0
- package/dist/client/agents/definitions.js.map +1 -0
- package/dist/client/agents/orchestrator.d.ts +141 -0
- package/dist/client/agents/orchestrator.d.ts.map +1 -0
- package/dist/client/agents/orchestrator.js +1062 -0
- package/dist/client/agents/orchestrator.js.map +1 -0
- package/dist/client/agents/specialist.d.ts +86 -0
- package/dist/client/agents/specialist.d.ts.map +1 -0
- package/dist/client/agents/specialist.js +340 -0
- package/dist/client/agents/specialist.js.map +1 -0
- package/dist/client/bot-entrypoint.d.ts +7 -0
- package/dist/client/bot-entrypoint.d.ts.map +1 -0
- package/dist/client/bot-entrypoint.js +103 -0
- package/dist/client/bot-entrypoint.js.map +1 -0
- package/dist/client/bot-manager.d.ts +44 -0
- package/dist/client/bot-manager.d.ts.map +1 -0
- package/dist/client/bot-manager.js +173 -0
- package/dist/client/bot-manager.js.map +1 -0
- package/dist/client/bot-runner.d.ts +35 -0
- package/dist/client/bot-runner.d.ts.map +1 -0
- package/dist/client/bot-runner.js +188 -0
- package/dist/client/bot-runner.js.map +1 -0
- package/dist/client/chat-agent-daemon.d.ts +464 -0
- package/dist/client/chat-agent-daemon.d.ts.map +1 -0
- package/dist/client/chat-agent-daemon.js +1774 -0
- package/dist/client/chat-agent-daemon.js.map +1 -0
- package/dist/client/daemon-factory.d.ts +106 -0
- package/dist/client/daemon-factory.d.ts.map +1 -0
- package/dist/client/daemon-factory.js +301 -0
- package/dist/client/daemon-factory.js.map +1 -0
- package/dist/client/factory.d.ts +111 -0
- package/dist/client/factory.d.ts.map +1 -0
- package/dist/client/factory.js +314 -0
- package/dist/client/factory.js.map +1 -0
- package/dist/client/index.d.ts +17 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +38 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/multi-bot-manager.d.ts +42 -0
- package/dist/client/multi-bot-manager.d.ts.map +1 -0
- package/dist/client/multi-bot-manager.js +161 -0
- package/dist/client/multi-bot-manager.js.map +1 -0
- package/dist/client/orchestrator-daemon.d.ts +87 -0
- package/dist/client/orchestrator-daemon.d.ts.map +1 -0
- package/dist/client/orchestrator-daemon.js +444 -0
- package/dist/client/orchestrator-daemon.js.map +1 -0
- package/dist/client/server.d.ts +8 -0
- package/dist/client/server.d.ts.map +1 -0
- package/dist/client/server.js +251 -0
- package/dist/client/server.js.map +1 -0
- package/dist/client/services/agent-registry.d.ts +108 -0
- package/dist/client/services/agent-registry.d.ts.map +1 -0
- package/dist/client/services/agent-registry.js +630 -0
- package/dist/client/services/agent-registry.js.map +1 -0
- package/dist/client/services/conversation-manager.d.ts +50 -0
- package/dist/client/services/conversation-manager.d.ts.map +1 -0
- package/dist/client/services/conversation-manager.js +136 -0
- package/dist/client/services/conversation-manager.js.map +1 -0
- package/dist/client/services/mcp-client.d.ts +48 -0
- package/dist/client/services/mcp-client.d.ts.map +1 -0
- package/dist/client/services/mcp-client.js +105 -0
- package/dist/client/services/mcp-client.js.map +1 -0
- package/dist/client/services/message-classifier.d.ts +37 -0
- package/dist/client/services/message-classifier.d.ts.map +1 -0
- package/dist/client/services/message-classifier.js +187 -0
- package/dist/client/services/message-classifier.js.map +1 -0
- package/dist/client/services/message-formatter.d.ts +84 -0
- package/dist/client/services/message-formatter.d.ts.map +1 -0
- package/dist/client/services/message-formatter.js +353 -0
- package/dist/client/services/message-formatter.js.map +1 -0
- package/dist/client/services/session-logger.d.ts +106 -0
- package/dist/client/services/session-logger.d.ts.map +1 -0
- package/dist/client/services/session-logger.js +446 -0
- package/dist/client/services/session-logger.js.map +1 -0
- package/dist/client/services/tool-executor.d.ts +41 -0
- package/dist/client/services/tool-executor.d.ts.map +1 -0
- package/dist/client/services/tool-executor.js +169 -0
- package/dist/client/services/tool-executor.js.map +1 -0
- package/dist/client/services/workspace-schema-cache.d.ts +149 -0
- package/dist/client/services/workspace-schema-cache.d.ts.map +1 -0
- package/dist/client/services/workspace-schema-cache.js +732 -0
- package/dist/client/services/workspace-schema-cache.js.map +1 -0
- package/dist/client/specialist-daemon.d.ts +77 -0
- package/dist/client/specialist-daemon.d.ts.map +1 -0
- package/dist/client/specialist-daemon.js +197 -0
- package/dist/client/specialist-daemon.js.map +1 -0
- package/dist/client/specialists.d.ts +53 -0
- package/dist/client/specialists.d.ts.map +1 -0
- package/dist/client/specialists.js +178 -0
- package/dist/client/specialists.js.map +1 -0
- package/dist/client/tool-schema-loader.d.ts +62 -0
- package/dist/client/tool-schema-loader.d.ts.map +1 -0
- package/dist/client/tool-schema-loader.js +232 -0
- package/dist/client/tool-schema-loader.js.map +1 -0
- package/dist/client/types.d.ts +327 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +121 -0
- package/dist/client/types.js.map +1 -0
- package/dist/commands/seed-config.d.ts +9 -0
- package/dist/commands/seed-config.d.ts.map +1 -0
- package/dist/commands/seed-config.js +392 -0
- package/dist/commands/seed-config.js.map +1 -0
- package/dist/commands/setup.d.ts +11 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +320 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js.map +1 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js.map +1 -0
- package/dist/lib/discussion-lock.d.ts.map +1 -0
- package/dist/lib/discussion-lock.js.map +1 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/request-logger.d.ts.map +1 -0
- package/dist/lib/request-logger.js.map +1 -0
- package/dist/mcp/UserContextCache.d.ts.map +1 -0
- package/dist/mcp/UserContextCache.js.map +1 -0
- package/dist/mcp/auth.d.ts.map +1 -0
- package/dist/mcp/auth.js.map +1 -0
- package/dist/mcp/hailer-clients.d.ts.map +1 -0
- package/dist/mcp/hailer-clients.js.map +1 -0
- package/dist/mcp/session-store.d.ts.map +1 -0
- package/dist/mcp/session-store.js.map +1 -0
- package/dist/mcp/signal-handler.d.ts.map +1 -0
- package/dist/mcp/signal-handler.js.map +1 -0
- package/dist/mcp/tool-registry.d.ts.map +1 -0
- package/dist/mcp/tool-registry.js.map +1 -0
- package/dist/mcp/tools/__tests__/discussion-forward.test.d.ts +2 -0
- package/dist/mcp/tools/__tests__/discussion-forward.test.d.ts.map +1 -0
- package/dist/mcp/tools/__tests__/discussion-forward.test.js +218 -0
- package/dist/mcp/tools/__tests__/discussion-forward.test.js.map +1 -0
- package/dist/mcp/tools/activity.d.ts.map +1 -0
- package/dist/mcp/tools/activity.js.map +1 -0
- package/dist/mcp/tools/app-core.d.ts.map +1 -0
- package/dist/mcp/tools/app-core.js.map +1 -0
- package/dist/mcp/tools/app-marketplace.d.ts.map +1 -0
- package/dist/mcp/tools/app-marketplace.js.map +1 -0
- package/dist/mcp/tools/app-member.d.ts.map +1 -0
- package/dist/mcp/tools/app-member.js.map +1 -0
- package/dist/mcp/tools/app-scaffold.d.ts.map +1 -0
- package/dist/mcp/tools/app-scaffold.js.map +1 -0
- package/dist/mcp/tools/app.d.ts.map +1 -0
- package/dist/mcp/tools/app.js.map +1 -0
- package/dist/mcp/tools/bot-config/constants.d.ts.map +1 -0
- package/dist/mcp/tools/bot-config/constants.js.map +1 -0
- package/dist/mcp/tools/bot-config/core.d.ts.map +1 -0
- package/dist/mcp/tools/bot-config/core.js.map +1 -0
- package/dist/mcp/tools/bot-config/index.d.ts.map +1 -0
- package/dist/mcp/tools/bot-config/index.js.map +1 -0
- package/dist/mcp/tools/bot-config/tools.d.ts.map +1 -0
- package/dist/mcp/tools/bot-config/tools.js.map +1 -0
- package/dist/mcp/tools/bot-config/types.d.ts.map +1 -0
- package/dist/mcp/tools/bot-config/types.js.map +1 -0
- package/dist/mcp/tools/bug-fixer-tools.d.ts.map +1 -0
- package/dist/mcp/tools/bug-fixer-tools.js.map +1 -0
- package/dist/mcp/tools/company.d.ts.map +1 -0
- package/dist/mcp/tools/company.js.map +1 -0
- package/dist/mcp/tools/discussion.d.ts.map +1 -0
- package/dist/mcp/tools/discussion.js.map +1 -0
- package/dist/mcp/tools/document.d.ts.map +1 -0
- package/dist/mcp/tools/document.js.map +1 -0
- package/dist/mcp/tools/file.d.ts.map +1 -0
- package/dist/mcp/tools/file.js.map +1 -0
- package/dist/mcp/tools/insight.d.ts.map +1 -0
- package/dist/mcp/tools/insight.js.map +1 -0
- package/dist/mcp/tools/investigate.d.ts.map +1 -0
- package/dist/mcp/tools/investigate.js.map +1 -0
- package/dist/mcp/tools/user.d.ts.map +1 -0
- package/dist/mcp/tools/user.js.map +1 -0
- package/dist/mcp/tools/workflow-permissions.d.ts.map +1 -0
- package/dist/mcp/tools/workflow-permissions.js.map +1 -0
- package/dist/mcp/tools/workflow.d.ts.map +1 -0
- package/dist/mcp/tools/workflow.js.map +1 -0
- package/dist/mcp/utils/api-errors.d.ts.map +1 -0
- package/dist/mcp/utils/api-errors.js.map +1 -0
- package/dist/mcp/utils/data-transformers.d.ts.map +1 -0
- package/dist/mcp/utils/data-transformers.js.map +1 -0
- package/dist/mcp/utils/file-upload.d.ts.map +1 -0
- package/dist/mcp/utils/file-upload.js.map +1 -0
- package/dist/mcp/utils/hailer-api-client.d.ts.map +1 -0
- package/dist/mcp/utils/hailer-api-client.js.map +1 -0
- package/dist/mcp/utils/index.d.ts.map +1 -0
- package/dist/mcp/utils/index.js.map +1 -0
- package/dist/mcp/utils/logger.d.ts.map +1 -0
- package/dist/mcp/utils/logger.js.map +1 -0
- package/dist/mcp/utils/pagination.d.ts.map +1 -0
- package/dist/mcp/utils/pagination.js.map +1 -0
- package/dist/mcp/utils/response-builder.d.ts.map +1 -0
- package/dist/mcp/utils/response-builder.js.map +1 -0
- package/dist/mcp/utils/role-utils.d.ts.map +1 -0
- package/dist/mcp/utils/role-utils.js.map +1 -0
- package/dist/mcp/utils/tool-helpers.d.ts.map +1 -0
- package/dist/mcp/utils/tool-helpers.js.map +1 -0
- package/dist/mcp/utils/types.d.ts.map +1 -0
- package/dist/mcp/utils/types.js.map +1 -0
- package/dist/mcp/webhook-handler.d.ts.map +1 -0
- package/dist/mcp/webhook-handler.js.map +1 -0
- package/dist/mcp/workspace-cache.d.ts.map +1 -0
- package/dist/mcp/workspace-cache.js.map +1 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/modules/bug-reports/bug-config.d.ts +25 -0
- package/dist/modules/bug-reports/bug-config.d.ts.map +1 -0
- package/dist/modules/bug-reports/bug-config.js +187 -0
- package/dist/modules/bug-reports/bug-config.js.map +1 -0
- package/dist/modules/bug-reports/bug-monitor.d.ts +108 -0
- package/dist/modules/bug-reports/bug-monitor.d.ts.map +1 -0
- package/dist/modules/bug-reports/bug-monitor.js +510 -0
- package/dist/modules/bug-reports/bug-monitor.js.map +1 -0
- package/dist/modules/bug-reports/giuseppe-agent.d.ts +58 -0
- package/dist/modules/bug-reports/giuseppe-agent.d.ts.map +1 -0
- package/dist/modules/bug-reports/giuseppe-agent.js +467 -0
- package/dist/modules/bug-reports/giuseppe-agent.js.map +1 -0
- package/dist/modules/bug-reports/giuseppe-ai.d.ts +83 -0
- package/dist/modules/bug-reports/giuseppe-ai.d.ts.map +1 -0
- package/dist/modules/bug-reports/giuseppe-ai.js +466 -0
- package/dist/modules/bug-reports/giuseppe-ai.js.map +1 -0
- package/dist/modules/bug-reports/giuseppe-bot.d.ts +110 -0
- package/dist/modules/bug-reports/giuseppe-bot.d.ts.map +1 -0
- package/dist/modules/bug-reports/giuseppe-bot.js +804 -0
- package/dist/modules/bug-reports/giuseppe-bot.js.map +1 -0
- package/dist/modules/bug-reports/giuseppe-daemon.d.ts +80 -0
- package/dist/modules/bug-reports/giuseppe-daemon.d.ts.map +1 -0
- package/dist/modules/bug-reports/giuseppe-daemon.js +617 -0
- package/dist/modules/bug-reports/giuseppe-daemon.js.map +1 -0
- package/dist/modules/bug-reports/giuseppe-files.d.ts +64 -0
- package/dist/modules/bug-reports/giuseppe-files.d.ts.map +1 -0
- package/dist/modules/bug-reports/giuseppe-files.js +375 -0
- package/dist/modules/bug-reports/giuseppe-files.js.map +1 -0
- package/dist/modules/bug-reports/giuseppe-git.d.ts +48 -0
- package/dist/modules/bug-reports/giuseppe-git.d.ts.map +1 -0
- package/dist/modules/bug-reports/giuseppe-git.js +298 -0
- package/dist/modules/bug-reports/giuseppe-git.js.map +1 -0
- package/dist/modules/bug-reports/giuseppe-lsp.d.ts +113 -0
- package/dist/modules/bug-reports/giuseppe-lsp.d.ts.map +1 -0
- package/dist/modules/bug-reports/giuseppe-lsp.js +485 -0
- package/dist/modules/bug-reports/giuseppe-lsp.js.map +1 -0
- package/dist/modules/bug-reports/giuseppe-prompt.d.ts +5 -0
- package/dist/modules/bug-reports/giuseppe-prompt.d.ts.map +1 -0
- package/dist/modules/bug-reports/giuseppe-prompt.js +94 -0
- package/dist/modules/bug-reports/giuseppe-prompt.js.map +1 -0
- package/dist/modules/bug-reports/index.d.ts +77 -0
- package/dist/modules/bug-reports/index.d.ts.map +1 -0
- package/dist/modules/bug-reports/index.js +215 -0
- package/dist/modules/bug-reports/index.js.map +1 -0
- package/dist/modules/bug-reports/pending-classification-registry.d.ts +28 -0
- package/dist/modules/bug-reports/pending-classification-registry.d.ts.map +1 -0
- package/dist/modules/bug-reports/pending-classification-registry.js +50 -0
- package/dist/modules/bug-reports/pending-classification-registry.js.map +1 -0
- package/dist/modules/bug-reports/pending-fix-registry.d.ts +30 -0
- package/dist/modules/bug-reports/pending-fix-registry.d.ts.map +1 -0
- package/dist/modules/bug-reports/pending-fix-registry.js +42 -0
- package/dist/modules/bug-reports/pending-fix-registry.js.map +1 -0
- package/dist/modules/bug-reports/pending-registry.d.ts +27 -0
- package/dist/modules/bug-reports/pending-registry.d.ts.map +1 -0
- package/dist/modules/bug-reports/pending-registry.js +49 -0
- package/dist/modules/bug-reports/pending-registry.js.map +1 -0
- package/dist/modules/bug-reports/types.d.ts +123 -0
- package/dist/modules/bug-reports/types.d.ts.map +1 -0
- package/dist/modules/bug-reports/types.js +9 -0
- package/dist/modules/bug-reports/types.js.map +1 -0
- package/dist/plugins/bug-fixer/index.d.ts.map +1 -0
- package/dist/plugins/bug-fixer/index.js.map +1 -0
- package/dist/plugins/bug-fixer/tools.d.ts.map +1 -0
- package/dist/plugins/bug-fixer/tools.js.map +1 -0
- package/dist/plugins/vipunen/__tests__/tools.test.d.ts +10 -0
- package/dist/plugins/vipunen/__tests__/tools.test.d.ts.map +1 -0
- package/dist/plugins/vipunen/__tests__/tools.test.js +646 -0
- package/dist/plugins/vipunen/__tests__/tools.test.js.map +1 -0
- package/dist/plugins/vipunen/client.d.ts.map +1 -0
- package/dist/plugins/vipunen/client.js.map +1 -0
- package/dist/plugins/vipunen/index.d.ts.map +1 -0
- package/dist/plugins/vipunen/index.js.map +1 -0
- package/dist/plugins/vipunen/tools.d.ts.map +1 -0
- package/dist/plugins/vipunen/tools.js.map +1 -0
- package/dist/routes/agents.d.ts +44 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +311 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/services/agent-credential-store.d.ts +73 -0
- package/dist/services/agent-credential-store.d.ts.map +1 -0
- package/dist/services/agent-credential-store.js +212 -0
- package/dist/services/agent-credential-store.js.map +1 -0
- package/dist/stdio-server.d.ts.map +1 -0
- package/dist/stdio-server.js.map +1 -0
- package/dist/workspace/context.d.ts +148 -0
- package/dist/workspace/context.d.ts.map +1 -0
- package/dist/workspace/context.js +339 -0
- package/dist/workspace/context.js.map +1 -0
- package/dist/workspace/credentials.d.ts +55 -0
- package/dist/workspace/credentials.d.ts.map +1 -0
- package/dist/workspace/credentials.js +239 -0
- package/dist/workspace/credentials.js.map +1 -0
- package/dist/workspace/index.d.ts +21 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +45 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/loader.d.ts +27 -0
- package/dist/workspace/loader.d.ts.map +1 -0
- package/dist/workspace/loader.js +222 -0
- package/dist/workspace/loader.js.map +1 -0
- package/dist/workspace/schema.d.ts +37 -0
- package/dist/workspace/schema.d.ts.map +1 -0
- package/dist/workspace/schema.js +192 -0
- package/dist/workspace/schema.js.map +1 -0
- package/package.json +13 -1
- package/test-billing-server.js +0 -136
|
@@ -0,0 +1,724 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Session Logger Service
|
|
4
|
+
*
|
|
5
|
+
* Manages per-activity session tracking and logging to Hailer workflows:
|
|
6
|
+
* - Tracks metrics (tokens, tool calls, messages)
|
|
7
|
+
* - Logs completed sessions to SESSION_LOG workflow
|
|
8
|
+
* - Manages idle session detection and flushing
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.SessionLoggerService = void 0;
|
|
12
|
+
const types_1 = require("../../shared/types");
|
|
13
|
+
class SessionLoggerService {
|
|
14
|
+
agentDirectoryId;
|
|
15
|
+
logger;
|
|
16
|
+
callMcpTool;
|
|
17
|
+
getDefaultTeamId;
|
|
18
|
+
activitySessions = new Map();
|
|
19
|
+
lastGlobalLogId = null;
|
|
20
|
+
idleCheckTimer = null;
|
|
21
|
+
anthropicClient = null;
|
|
22
|
+
schemaCache = null;
|
|
23
|
+
_currentWorkspaceId = null;
|
|
24
|
+
constructor(agentDirectoryId, logger, callMcpTool, getDefaultTeamId) {
|
|
25
|
+
this.agentDirectoryId = agentDirectoryId;
|
|
26
|
+
this.logger = logger;
|
|
27
|
+
this.callMcpTool = callMcpTool;
|
|
28
|
+
this.getDefaultTeamId = getDefaultTeamId;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Set the workspace schema cache for dynamic ID lookup
|
|
32
|
+
*/
|
|
33
|
+
setSchemaCache(cache, workspaceId) {
|
|
34
|
+
this.schemaCache = cache;
|
|
35
|
+
this._currentWorkspaceId = workspaceId;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get Session Log schema from cache for a specific workspace
|
|
39
|
+
*/
|
|
40
|
+
getSessionLogSchema(workspaceId) {
|
|
41
|
+
if (!this.schemaCache || !workspaceId) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return this.schemaCache.getSessionLogSchema(workspaceId) || null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Set Anthropic client for generating summaries
|
|
48
|
+
*/
|
|
49
|
+
setAnthropicClient(client) {
|
|
50
|
+
this.anthropicClient = client;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get or create an activity session for tracking
|
|
54
|
+
* Multi-tenant: workspaceId is required for proper schema lookup
|
|
55
|
+
*/
|
|
56
|
+
getOrCreateActivitySession(message) {
|
|
57
|
+
// Use linked activity ID as key, fallback to discussion ID
|
|
58
|
+
const sessionKey = message.linkedActivityId || message.discussionId;
|
|
59
|
+
let session = this.activitySessions.get(sessionKey);
|
|
60
|
+
if (!session) {
|
|
61
|
+
session = {
|
|
62
|
+
activityId: message.linkedActivityId || "",
|
|
63
|
+
activityName: message.linkedActivityName || `Discussion ${message.discussionId.substring(0, 8)}`,
|
|
64
|
+
discussionId: message.discussionId,
|
|
65
|
+
workspaceId: message.workspaceId, // Multi-tenant: store workspace for this session
|
|
66
|
+
startTime: Date.now(),
|
|
67
|
+
lastActivityTime: Date.now(),
|
|
68
|
+
metrics: {
|
|
69
|
+
inputTokens: 0,
|
|
70
|
+
outputTokens: 0,
|
|
71
|
+
cacheCreationTokens: 0,
|
|
72
|
+
cacheReadTokens: 0,
|
|
73
|
+
toolCalls: 0,
|
|
74
|
+
writeOperations: 0,
|
|
75
|
+
messagesProcessed: 0,
|
|
76
|
+
responsesPosted: 0,
|
|
77
|
+
apiCalls: 0,
|
|
78
|
+
},
|
|
79
|
+
actions: [],
|
|
80
|
+
previousLogId: this.lastGlobalLogId,
|
|
81
|
+
conversation: [],
|
|
82
|
+
writeDetails: [],
|
|
83
|
+
triggerRequest: null,
|
|
84
|
+
requestedBy: null,
|
|
85
|
+
requestedById: null,
|
|
86
|
+
};
|
|
87
|
+
this.activitySessions.set(sessionKey, session);
|
|
88
|
+
this.logger.debug("Created new activity session", {
|
|
89
|
+
sessionKey,
|
|
90
|
+
workspaceId: message.workspaceId,
|
|
91
|
+
activityName: session.activityName,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return session;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get session by key
|
|
98
|
+
*/
|
|
99
|
+
getSession(key) {
|
|
100
|
+
return this.activitySessions.get(key);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get all active sessions
|
|
104
|
+
*/
|
|
105
|
+
getActiveSessions() {
|
|
106
|
+
return new Map(this.activitySessions);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Check for idle sessions and flush them
|
|
110
|
+
* Called periodically by timer
|
|
111
|
+
*/
|
|
112
|
+
async checkAndFlushIdleSessions() {
|
|
113
|
+
const now = Date.now();
|
|
114
|
+
const sessionsToFlush = [];
|
|
115
|
+
for (const [key, session] of this.activitySessions) {
|
|
116
|
+
const idleTime = now - session.lastActivityTime;
|
|
117
|
+
if (idleTime >= types_1.SESSION_IDLE_TIMEOUT) {
|
|
118
|
+
sessionsToFlush.push(key);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
for (const key of sessionsToFlush) {
|
|
122
|
+
const session = this.activitySessions.get(key);
|
|
123
|
+
if (session) {
|
|
124
|
+
await this.flushActivitySession(key, session);
|
|
125
|
+
this.activitySessions.delete(key);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (sessionsToFlush.length > 0) {
|
|
129
|
+
this.logger.debug("Flushed idle sessions", { count: sessionsToFlush.length });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Flush a single activity session to the session log
|
|
134
|
+
* Set DISABLE_SESSION_LOG=true to skip persistence (saves 20+ tokens per session)
|
|
135
|
+
*/
|
|
136
|
+
async flushActivitySession(_key, session) {
|
|
137
|
+
// Check if session logging is disabled via env var
|
|
138
|
+
if (process.env.DISABLE_SESSION_LOG === 'true') {
|
|
139
|
+
this.logger.debug("Skipping session log - disabled via DISABLE_SESSION_LOG", {
|
|
140
|
+
activity: session.activityName,
|
|
141
|
+
metrics: session.metrics,
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Only log if API calls were made (skip sessions with no activity)
|
|
146
|
+
if (session.metrics.apiCalls === 0) {
|
|
147
|
+
this.logger.debug("Skipping session log - no API calls", {
|
|
148
|
+
activity: session.activityName,
|
|
149
|
+
});
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// Get dynamic schema for this session's workspace
|
|
153
|
+
const schema = this.getSessionLogSchema(session.workspaceId);
|
|
154
|
+
if (!schema) {
|
|
155
|
+
this.logger.debug("Skipping session log - no Session Log workflow in workspace", {
|
|
156
|
+
workspaceId: session.workspaceId,
|
|
157
|
+
});
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (!this.agentDirectoryId) {
|
|
161
|
+
this.logger.debug("Skipping session log - no agent directory ID");
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
// Build descriptive session name from first write operation
|
|
166
|
+
let sessionName;
|
|
167
|
+
if (session.writeDetails.length > 0) {
|
|
168
|
+
sessionName = session.writeDetails[0].what;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
sessionName = session.activityName || `Session ${new Date().toISOString()}`;
|
|
172
|
+
}
|
|
173
|
+
// Generate session metadata (headline, topics, entities, outcome, summary)
|
|
174
|
+
const metadata = await this.generateSessionMetadata(session);
|
|
175
|
+
const summary = await this.buildActivitySessionSummary(session, metadata);
|
|
176
|
+
// Calculate total tokens and cost
|
|
177
|
+
const { inputTokens, outputTokens, cacheCreationTokens, cacheReadTokens } = session.metrics;
|
|
178
|
+
const totalTokens = inputTokens + outputTokens + cacheCreationTokens + cacheReadTokens;
|
|
179
|
+
const cost = this.calculateCost(inputTokens, outputTokens, cacheCreationTokens, cacheReadTokens);
|
|
180
|
+
// Get field IDs from schema (use our standard keys that were mapped)
|
|
181
|
+
const contextSummaryFieldId = schema.fields["contextSummary"] || schema.fields["Context summary"];
|
|
182
|
+
const madeByFieldId = schema.fields["madeBy"] || schema.fields["Log entry made by"];
|
|
183
|
+
const costFieldId = schema.fields["cost"] || schema.fields["Tokens Used"];
|
|
184
|
+
const previousLogFieldId = schema.fields["previousLog"] || schema.fields["Previus log entry"];
|
|
185
|
+
const linkedWorkFieldId = schema.fields["linkedWork"] || schema.fields["Most relevant link to work"];
|
|
186
|
+
// New billing field IDs (looked up by key from schema)
|
|
187
|
+
const uncachedTokensFieldId = schema.fields["uncachedTokens"];
|
|
188
|
+
const cachedTokensFieldId = schema.fields["cachedTokens"];
|
|
189
|
+
const outputTokensFieldId = schema.fields["outputTokens"];
|
|
190
|
+
const cacheHitRateFieldId = schema.fields["cacheHitRate"];
|
|
191
|
+
const costUsdFieldId = schema.fields["costUsd"];
|
|
192
|
+
const apiCallsFieldId = schema.fields["apiCalls"];
|
|
193
|
+
const durationSecFieldId = schema.fields["durationSec"];
|
|
194
|
+
const writeOperationsFieldId = schema.fields["writeOperations"];
|
|
195
|
+
// Memory metadata field IDs (for smart retrieval)
|
|
196
|
+
const headlineFieldId = schema.fields["headline"];
|
|
197
|
+
const topicsFieldId = schema.fields["topics"];
|
|
198
|
+
const entitiesFieldId = schema.fields["entities"];
|
|
199
|
+
const outcomeFieldId = schema.fields["outcome"];
|
|
200
|
+
const discussionIdFieldId = schema.fields["discussionId"];
|
|
201
|
+
// Calculate metrics
|
|
202
|
+
const sessionDuration = Math.round((Date.now() - session.startTime) / 1000);
|
|
203
|
+
const cacheHitPct = totalTokens > 0
|
|
204
|
+
? Math.round((cacheReadTokens / (inputTokens + cacheCreationTokens + cacheReadTokens)) * 100)
|
|
205
|
+
: 0;
|
|
206
|
+
// Build fields
|
|
207
|
+
const fields = {};
|
|
208
|
+
// Context summary (just the conversation summary, not stats)
|
|
209
|
+
if (contextSummaryFieldId) {
|
|
210
|
+
fields[contextSummaryFieldId] = summary;
|
|
211
|
+
}
|
|
212
|
+
if (madeByFieldId && this.agentDirectoryId) {
|
|
213
|
+
fields[madeByFieldId] = this.agentDirectoryId;
|
|
214
|
+
}
|
|
215
|
+
if (costFieldId) {
|
|
216
|
+
fields[costFieldId] = totalTokens;
|
|
217
|
+
}
|
|
218
|
+
// Billing fields (separate columns for reporting) - only if fields exist in schema
|
|
219
|
+
if (uncachedTokensFieldId) {
|
|
220
|
+
fields[uncachedTokensFieldId] = inputTokens + cacheCreationTokens; // tokens charged at full/125% rate
|
|
221
|
+
}
|
|
222
|
+
if (cachedTokensFieldId) {
|
|
223
|
+
fields[cachedTokensFieldId] = cacheReadTokens;
|
|
224
|
+
}
|
|
225
|
+
if (outputTokensFieldId) {
|
|
226
|
+
fields[outputTokensFieldId] = outputTokens;
|
|
227
|
+
}
|
|
228
|
+
if (cacheHitRateFieldId) {
|
|
229
|
+
fields[cacheHitRateFieldId] = cacheHitPct;
|
|
230
|
+
}
|
|
231
|
+
if (costUsdFieldId) {
|
|
232
|
+
fields[costUsdFieldId] = parseFloat(cost.toFixed(6)); // Store as number for aggregation
|
|
233
|
+
}
|
|
234
|
+
if (apiCallsFieldId) {
|
|
235
|
+
fields[apiCallsFieldId] = session.metrics.apiCalls;
|
|
236
|
+
}
|
|
237
|
+
if (durationSecFieldId) {
|
|
238
|
+
fields[durationSecFieldId] = sessionDuration;
|
|
239
|
+
}
|
|
240
|
+
if (writeOperationsFieldId) {
|
|
241
|
+
fields[writeOperationsFieldId] = session.metrics.writeOperations;
|
|
242
|
+
}
|
|
243
|
+
// Chain to previous log
|
|
244
|
+
if (session.previousLogId && previousLogFieldId) {
|
|
245
|
+
fields[previousLogFieldId] = session.previousLogId;
|
|
246
|
+
}
|
|
247
|
+
// Link to activity being worked on
|
|
248
|
+
if (session.activityId && linkedWorkFieldId) {
|
|
249
|
+
fields[linkedWorkFieldId] = session.activityId;
|
|
250
|
+
}
|
|
251
|
+
// Memory metadata fields (for smart retrieval)
|
|
252
|
+
if (metadata) {
|
|
253
|
+
if (headlineFieldId && metadata.headline) {
|
|
254
|
+
fields[headlineFieldId] = metadata.headline;
|
|
255
|
+
}
|
|
256
|
+
if (topicsFieldId && metadata.topics) {
|
|
257
|
+
fields[topicsFieldId] = metadata.topics;
|
|
258
|
+
}
|
|
259
|
+
if (entitiesFieldId && metadata.entities) {
|
|
260
|
+
fields[entitiesFieldId] = metadata.entities;
|
|
261
|
+
}
|
|
262
|
+
if (outcomeFieldId && metadata.outcome) {
|
|
263
|
+
fields[outcomeFieldId] = metadata.outcome;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Store discussionId for filtering/retrieval
|
|
267
|
+
if (discussionIdFieldId && session.discussionId) {
|
|
268
|
+
fields[discussionIdFieldId] = session.discussionId;
|
|
269
|
+
}
|
|
270
|
+
// Get phase ID (try "active" first, then first available)
|
|
271
|
+
const phaseId = schema.phases["active"] || Object.values(schema.phases)[0];
|
|
272
|
+
const createParams = {
|
|
273
|
+
workflowId: schema.workflowId,
|
|
274
|
+
name: sessionName,
|
|
275
|
+
phaseId,
|
|
276
|
+
fields,
|
|
277
|
+
};
|
|
278
|
+
const wsTeamId = this.getDefaultTeamId();
|
|
279
|
+
if (wsTeamId) {
|
|
280
|
+
createParams.teamId = wsTeamId;
|
|
281
|
+
}
|
|
282
|
+
const result = await this.callMcpTool("create_activity", createParams);
|
|
283
|
+
// Extract created ID for chaining
|
|
284
|
+
const resultText = result?.content?.[0]?.text;
|
|
285
|
+
if (resultText) {
|
|
286
|
+
const idMatch = resultText.match(/"_id":\s*"([a-f0-9]{24})"/i) ||
|
|
287
|
+
resultText.match(/`([a-f0-9]{24})`/);
|
|
288
|
+
if (idMatch) {
|
|
289
|
+
this.lastGlobalLogId = idMatch[1];
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const durationSec = Math.round((Date.now() - session.startTime) / 1000);
|
|
293
|
+
const cacheHitRate = totalTokens > 0
|
|
294
|
+
? Math.round((cacheReadTokens / (inputTokens + cacheCreationTokens + cacheReadTokens)) * 100)
|
|
295
|
+
: 0;
|
|
296
|
+
this.logger.info("Activity session logged", {
|
|
297
|
+
activity: session.activityName,
|
|
298
|
+
durationSec,
|
|
299
|
+
messages: session.metrics.messagesProcessed,
|
|
300
|
+
toolCalls: session.metrics.toolCalls,
|
|
301
|
+
tokens: totalTokens,
|
|
302
|
+
cacheHitRate: `${cacheHitRate}%`,
|
|
303
|
+
costUsd: `$${cost.toFixed(4)}`,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
this.logger.warn("Failed to flush activity session", {
|
|
308
|
+
activity: session.activityName,
|
|
309
|
+
error: error instanceof Error ? error.message : String(error),
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Flush all active sessions (called on shutdown)
|
|
315
|
+
*/
|
|
316
|
+
async flushAllSessions() {
|
|
317
|
+
for (const [key, session] of this.activitySessions) {
|
|
318
|
+
await this.flushActivitySession(key, session);
|
|
319
|
+
}
|
|
320
|
+
this.activitySessions.clear();
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Build summary for an activity session
|
|
324
|
+
* Uses pre-generated metadata if available
|
|
325
|
+
*/
|
|
326
|
+
async buildActivitySessionSummary(session, metadata) {
|
|
327
|
+
const lines = [];
|
|
328
|
+
// Who requested this
|
|
329
|
+
if (session.requestedBy) {
|
|
330
|
+
lines.push(`**Requested by:** ${session.requestedBy}`);
|
|
331
|
+
}
|
|
332
|
+
// What they asked for
|
|
333
|
+
if (session.triggerRequest) {
|
|
334
|
+
lines.push(`**Request:** "${session.triggerRequest}"`);
|
|
335
|
+
}
|
|
336
|
+
// What was changed (write operations only)
|
|
337
|
+
if (session.writeDetails.length > 0) {
|
|
338
|
+
lines.push("");
|
|
339
|
+
lines.push(`**Changes made:**`);
|
|
340
|
+
for (const detail of session.writeDetails) {
|
|
341
|
+
lines.push(`- ${detail.what}`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// Use metadata summary if available, otherwise generate one
|
|
345
|
+
const conversationSummary = metadata?.summary || await this.generateConversationSummary(session);
|
|
346
|
+
if (conversationSummary) {
|
|
347
|
+
lines.push("");
|
|
348
|
+
lines.push(`**Conversation:** ${conversationSummary}`);
|
|
349
|
+
}
|
|
350
|
+
// Stats are now in separate fields, so just return the context summary
|
|
351
|
+
return lines.join("\n");
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Calculate cost in USD based on Haiku 4.5 pricing
|
|
355
|
+
* - Input (uncached): $0.80 / 1M tokens
|
|
356
|
+
* - Output: $4.00 / 1M tokens
|
|
357
|
+
* - Cache creation: $1.00 / 1M tokens (125% of input)
|
|
358
|
+
* - Cache read: $0.08 / 1M tokens (10% of input)
|
|
359
|
+
*/
|
|
360
|
+
calculateCost(inputTokens, outputTokens, cacheCreationTokens, cacheReadTokens) {
|
|
361
|
+
const inputCost = (inputTokens / 1_000_000) * 0.80;
|
|
362
|
+
const outputCost = (outputTokens / 1_000_000) * 4.00;
|
|
363
|
+
const cacheCreationCost = (cacheCreationTokens / 1_000_000) * 1.00;
|
|
364
|
+
const cacheReadCost = (cacheReadTokens / 1_000_000) * 0.08;
|
|
365
|
+
return inputCost + outputCost + cacheCreationCost + cacheReadCost;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Start periodic idle session checking
|
|
369
|
+
*/
|
|
370
|
+
startIdleCheckTimer(intervalMs = 30_000) {
|
|
371
|
+
if (this.idleCheckTimer) {
|
|
372
|
+
clearInterval(this.idleCheckTimer);
|
|
373
|
+
}
|
|
374
|
+
this.idleCheckTimer = setInterval(() => {
|
|
375
|
+
this.checkAndFlushIdleSessions().catch(err => {
|
|
376
|
+
this.logger.warn("Error checking idle sessions", { error: err });
|
|
377
|
+
});
|
|
378
|
+
}, intervalMs);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Stop idle check timer
|
|
382
|
+
*/
|
|
383
|
+
stopIdleCheckTimer() {
|
|
384
|
+
if (this.idleCheckTimer) {
|
|
385
|
+
clearInterval(this.idleCheckTimer);
|
|
386
|
+
this.idleCheckTimer = null;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
// ===== MEMORY SYSTEM =====
|
|
390
|
+
/**
|
|
391
|
+
* Sanitize string to remove invalid Unicode surrogate pairs
|
|
392
|
+
* These can cause JSON parsing errors in the Anthropic API
|
|
393
|
+
*/
|
|
394
|
+
sanitizeString(str) {
|
|
395
|
+
// Remove unpaired surrogates (invalid Unicode)
|
|
396
|
+
// eslint-disable-next-line no-control-regex
|
|
397
|
+
return str.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, '');
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Generate conversation summary AND metadata for memory retrieval
|
|
401
|
+
* Returns structured data for smart session recall
|
|
402
|
+
*/
|
|
403
|
+
async generateSessionMetadata(session) {
|
|
404
|
+
if (!this.anthropicClient || session.conversation.length === 0) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
try {
|
|
408
|
+
// Sanitize conversation to remove invalid Unicode that causes JSON parsing errors
|
|
409
|
+
const sanitizedConversation = session.conversation
|
|
410
|
+
.map(msg => this.sanitizeString(msg))
|
|
411
|
+
.join("\n");
|
|
412
|
+
const response = await this.anthropicClient.messages.create({
|
|
413
|
+
model: "claude-haiku-4-5-20251001",
|
|
414
|
+
max_tokens: 600,
|
|
415
|
+
messages: [
|
|
416
|
+
{
|
|
417
|
+
role: "user",
|
|
418
|
+
content: `Analyze this conversation and extract memory metadata. Return JSON only, no other text.
|
|
419
|
+
|
|
420
|
+
Conversation:
|
|
421
|
+
${sanitizedConversation}
|
|
422
|
+
|
|
423
|
+
Return this exact JSON structure:
|
|
424
|
+
{
|
|
425
|
+
"headline": "1-sentence summary, max 50 chars",
|
|
426
|
+
"topics": "comma-separated tags like: workflow, bug, insight, app, setup, question, config, data, report",
|
|
427
|
+
"entities": "specific names mentioned: workflow names, app names, user names",
|
|
428
|
+
"outcome": "one of: resolved, pending, escalated, info",
|
|
429
|
+
"summary": "2-3 sentence summary of what was discussed and accomplished"
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
JSON:`,
|
|
433
|
+
},
|
|
434
|
+
],
|
|
435
|
+
});
|
|
436
|
+
const textBlock = response.content.find((b) => b.type === "text");
|
|
437
|
+
if (!textBlock?.text) {
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
// Parse JSON response
|
|
441
|
+
const jsonMatch = textBlock.text.match(/\{[\s\S]*\}/);
|
|
442
|
+
if (!jsonMatch) {
|
|
443
|
+
this.logger.warn("Failed to parse session metadata JSON", { response: textBlock.text.substring(0, 200) });
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
446
|
+
const metadata = JSON.parse(jsonMatch[0]);
|
|
447
|
+
// Validate and truncate
|
|
448
|
+
return {
|
|
449
|
+
headline: (metadata.headline || "").substring(0, 60),
|
|
450
|
+
topics: (metadata.topics || "").substring(0, 200),
|
|
451
|
+
entities: (metadata.entities || "").substring(0, 200),
|
|
452
|
+
outcome: ["resolved", "pending", "escalated", "info"].includes(metadata.outcome)
|
|
453
|
+
? metadata.outcome
|
|
454
|
+
: "info",
|
|
455
|
+
summary: (metadata.summary || "").substring(0, 1000),
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
catch (error) {
|
|
459
|
+
this.logger.warn("Failed to generate session metadata", {
|
|
460
|
+
error: error instanceof Error ? error.message : String(error),
|
|
461
|
+
});
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Generate a conversation summary using LLM (legacy, uses new method internally)
|
|
467
|
+
*/
|
|
468
|
+
async generateConversationSummary(session) {
|
|
469
|
+
const metadata = await this.generateSessionMetadata(session);
|
|
470
|
+
return metadata?.summary || null;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Load memory entries for an activity from SESSION_LOG
|
|
474
|
+
* Returns past conversation summaries for context injection
|
|
475
|
+
*
|
|
476
|
+
* NOTE: ActivityLink fields store objects {_id, name}, so we fetch recent
|
|
477
|
+
* session logs and filter client-side by checking the nested _id.
|
|
478
|
+
*/
|
|
479
|
+
async loadMemoryForActivity(activityId, workspaceId, limit = 5) {
|
|
480
|
+
if (!activityId || !workspaceId) {
|
|
481
|
+
return [];
|
|
482
|
+
}
|
|
483
|
+
// Get dynamic schema for this workspace
|
|
484
|
+
const schema = this.getSessionLogSchema(workspaceId);
|
|
485
|
+
if (!schema) {
|
|
486
|
+
this.logger.debug("Cannot load memory - no Session Log workflow in workspace", { workspaceId });
|
|
487
|
+
return [];
|
|
488
|
+
}
|
|
489
|
+
// Get field IDs from schema
|
|
490
|
+
const contextSummaryFieldId = schema.fields["contextSummary"] || schema.fields["Context summary"];
|
|
491
|
+
const linkedWorkFieldId = schema.fields["linkedWork"] || schema.fields["Most relevant link to work"];
|
|
492
|
+
const phaseId = schema.phases["active"] || Object.values(schema.phases)[0];
|
|
493
|
+
if (!contextSummaryFieldId || !linkedWorkFieldId || !phaseId) {
|
|
494
|
+
this.logger.debug("Cannot load memory - missing required fields in schema");
|
|
495
|
+
return [];
|
|
496
|
+
}
|
|
497
|
+
try {
|
|
498
|
+
// Query SESSION_LOG for recent sessions (fetch more to filter client-side)
|
|
499
|
+
// ActivityLink filters don't work with simple equals, so we filter after
|
|
500
|
+
const result = await this.callMcpTool("list_activities", {
|
|
501
|
+
workflowId: schema.workflowId,
|
|
502
|
+
phaseId,
|
|
503
|
+
fields: [contextSummaryFieldId, linkedWorkFieldId],
|
|
504
|
+
limit: 50, // Fetch more, filter client-side
|
|
505
|
+
sortBy: "created",
|
|
506
|
+
sortOrder: "desc",
|
|
507
|
+
});
|
|
508
|
+
const resultText = result?.content?.[0]?.text;
|
|
509
|
+
if (!resultText) {
|
|
510
|
+
return [];
|
|
511
|
+
}
|
|
512
|
+
// Parse the response to extract memory entries
|
|
513
|
+
const entries = [];
|
|
514
|
+
// Try to parse as JSON array
|
|
515
|
+
try {
|
|
516
|
+
const parsed = JSON.parse(resultText);
|
|
517
|
+
const activities = parsed.activities || parsed.data || parsed;
|
|
518
|
+
if (Array.isArray(activities)) {
|
|
519
|
+
for (const activity of activities) {
|
|
520
|
+
// Get linkedWork field - it's an ActivityLink with nested {_id, name}
|
|
521
|
+
const linkedWorkField = activity.fields?.[linkedWorkFieldId];
|
|
522
|
+
const linkedWorkId = linkedWorkField?.value?._id || linkedWorkField?._id;
|
|
523
|
+
// Filter: only include entries linked to our target activity
|
|
524
|
+
if (linkedWorkId !== activityId) {
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
527
|
+
// Get context summary
|
|
528
|
+
const summaryField = activity.fields?.[contextSummaryFieldId];
|
|
529
|
+
const summary = summaryField?.value || summaryField;
|
|
530
|
+
if (summary) {
|
|
531
|
+
// Extract conversation summary section if present
|
|
532
|
+
const conversationMatch = summary.match(/\*\*Conversation:\*\*\s*([\s\S]*?)(?=\n\n\*\*|---\n|$)/);
|
|
533
|
+
const memorySummary = conversationMatch?.[1]?.trim() || summary;
|
|
534
|
+
entries.push({
|
|
535
|
+
sessionId: activity._id,
|
|
536
|
+
timestamp: activity.created || Date.now(),
|
|
537
|
+
summary: memorySummary,
|
|
538
|
+
linkedActivityId: activityId,
|
|
539
|
+
});
|
|
540
|
+
// Stop once we have enough
|
|
541
|
+
if (entries.length >= limit) {
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
catch {
|
|
549
|
+
// Not JSON, try regex extraction (fallback)
|
|
550
|
+
this.logger.debug("Failed to parse as JSON, using regex fallback");
|
|
551
|
+
}
|
|
552
|
+
this.logger.debug("Loaded memory entries", {
|
|
553
|
+
activityId,
|
|
554
|
+
count: entries.length,
|
|
555
|
+
});
|
|
556
|
+
return entries;
|
|
557
|
+
}
|
|
558
|
+
catch (error) {
|
|
559
|
+
this.logger.warn("Failed to load memory for activity", {
|
|
560
|
+
activityId,
|
|
561
|
+
error: error instanceof Error ? error.message : String(error),
|
|
562
|
+
});
|
|
563
|
+
return [];
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Format memory entries for injection into conversation context
|
|
568
|
+
*/
|
|
569
|
+
formatMemoryForContext(entries) {
|
|
570
|
+
if (entries.length === 0) {
|
|
571
|
+
return "";
|
|
572
|
+
}
|
|
573
|
+
const lines = ["<previous_memory>", "Past interactions with this activity:"];
|
|
574
|
+
for (const entry of entries) {
|
|
575
|
+
const date = new Date(entry.timestamp).toLocaleDateString();
|
|
576
|
+
lines.push(`- [${date}] ${entry.summary}`);
|
|
577
|
+
}
|
|
578
|
+
lines.push("</previous_memory>");
|
|
579
|
+
return lines.join("\n");
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Load memory headlines for a discussion (for smart context injection)
|
|
583
|
+
* Returns lightweight headlines instead of full summaries
|
|
584
|
+
*
|
|
585
|
+
* @param discussionId - Discussion to load memory for
|
|
586
|
+
* @param workspaceId - Workspace context
|
|
587
|
+
* @param options - Search options
|
|
588
|
+
*/
|
|
589
|
+
async loadMemoryForDiscussion(discussionId, workspaceId, options = {}) {
|
|
590
|
+
const { limit = 3, keywords, maxAgeDays = 7 } = options;
|
|
591
|
+
if (!discussionId || !workspaceId) {
|
|
592
|
+
return [];
|
|
593
|
+
}
|
|
594
|
+
const schema = this.getSessionLogSchema(workspaceId);
|
|
595
|
+
if (!schema) {
|
|
596
|
+
this.logger.debug("Cannot load memory - no Session Log workflow", { workspaceId });
|
|
597
|
+
return [];
|
|
598
|
+
}
|
|
599
|
+
// Get field IDs
|
|
600
|
+
const headlineFieldId = schema.fields["headline"];
|
|
601
|
+
const topicsFieldId = schema.fields["topics"];
|
|
602
|
+
const outcomeFieldId = schema.fields["outcome"];
|
|
603
|
+
const discussionIdFieldId = schema.fields["discussionId"];
|
|
604
|
+
const phaseId = schema.phases["active"] || Object.values(schema.phases)[0];
|
|
605
|
+
if (!headlineFieldId || !discussionIdFieldId || !phaseId) {
|
|
606
|
+
this.logger.debug("Cannot load memory - missing required fields (headline, discussionId)");
|
|
607
|
+
return [];
|
|
608
|
+
}
|
|
609
|
+
try {
|
|
610
|
+
// Build query params
|
|
611
|
+
const queryParams = {
|
|
612
|
+
workflowId: schema.workflowId,
|
|
613
|
+
phaseId,
|
|
614
|
+
fields: [headlineFieldId, topicsFieldId, outcomeFieldId, discussionIdFieldId].filter(Boolean),
|
|
615
|
+
limit: 20, // Fetch more to filter client-side
|
|
616
|
+
sortBy: "created",
|
|
617
|
+
sortOrder: "desc",
|
|
618
|
+
};
|
|
619
|
+
// Add keyword search if provided
|
|
620
|
+
if (keywords && topicsFieldId) {
|
|
621
|
+
queryParams.search = keywords;
|
|
622
|
+
}
|
|
623
|
+
const result = await this.callMcpTool("list_activities", queryParams);
|
|
624
|
+
const resultText = result?.content?.[0]?.text;
|
|
625
|
+
if (!resultText) {
|
|
626
|
+
return [];
|
|
627
|
+
}
|
|
628
|
+
const entries = [];
|
|
629
|
+
const maxAgeMs = maxAgeDays * 24 * 60 * 60 * 1000;
|
|
630
|
+
const cutoffTime = Date.now() - maxAgeMs;
|
|
631
|
+
try {
|
|
632
|
+
// Extract JSON from response
|
|
633
|
+
const jsonMatch = resultText.match(/\[[\s\S]*\]/);
|
|
634
|
+
if (!jsonMatch) {
|
|
635
|
+
return [];
|
|
636
|
+
}
|
|
637
|
+
const activities = JSON.parse(jsonMatch[0]);
|
|
638
|
+
for (const activity of activities) {
|
|
639
|
+
// Filter by discussionId
|
|
640
|
+
const actDiscussionId = activity.fieldsAndValues?.find((f) => f.fieldId === discussionIdFieldId)?.value || activity.fields?.[discussionIdFieldId]?.value;
|
|
641
|
+
if (actDiscussionId !== discussionId) {
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
// Filter by age
|
|
645
|
+
const created = activity.created || Date.now();
|
|
646
|
+
if (created < cutoffTime) {
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
// Extract fields
|
|
650
|
+
const headline = activity.fieldsAndValues?.find((f) => f.fieldId === headlineFieldId)?.value || activity.fields?.[headlineFieldId]?.value || "";
|
|
651
|
+
const topics = activity.fieldsAndValues?.find((f) => f.fieldId === topicsFieldId)?.value || activity.fields?.[topicsFieldId]?.value || "";
|
|
652
|
+
const outcome = activity.fieldsAndValues?.find((f) => f.fieldId === outcomeFieldId)?.value || activity.fields?.[outcomeFieldId]?.value || "info";
|
|
653
|
+
if (headline) {
|
|
654
|
+
entries.push({
|
|
655
|
+
sessionId: activity._id,
|
|
656
|
+
timestamp: created,
|
|
657
|
+
headline,
|
|
658
|
+
topics,
|
|
659
|
+
outcome,
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
if (entries.length >= limit) {
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
catch (parseError) {
|
|
668
|
+
this.logger.debug("Failed to parse memory response", { error: parseError });
|
|
669
|
+
}
|
|
670
|
+
this.logger.debug("Loaded memory headlines", {
|
|
671
|
+
discussionId: discussionId.substring(0, 8),
|
|
672
|
+
count: entries.length,
|
|
673
|
+
});
|
|
674
|
+
return entries;
|
|
675
|
+
}
|
|
676
|
+
catch (error) {
|
|
677
|
+
this.logger.warn("Failed to load memory for discussion", {
|
|
678
|
+
discussionId: discussionId.substring(0, 8),
|
|
679
|
+
error: error instanceof Error ? error.message : String(error),
|
|
680
|
+
});
|
|
681
|
+
return [];
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Format memory headlines for context injection (lightweight)
|
|
686
|
+
* Returns ~50 tokens for 3 entries
|
|
687
|
+
*/
|
|
688
|
+
formatHeadlinesForContext(entries) {
|
|
689
|
+
if (entries.length === 0) {
|
|
690
|
+
return "";
|
|
691
|
+
}
|
|
692
|
+
const lines = ["[Recent context from this conversation]"];
|
|
693
|
+
for (const entry of entries) {
|
|
694
|
+
const ago = this.formatTimeAgo(entry.timestamp);
|
|
695
|
+
const status = entry.outcome !== "info" ? ` (${entry.outcome})` : "";
|
|
696
|
+
lines.push(`• ${ago}: ${entry.headline}${status}`);
|
|
697
|
+
}
|
|
698
|
+
return lines.join("\n");
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Format timestamp as relative time (e.g., "2h ago", "yesterday")
|
|
702
|
+
*/
|
|
703
|
+
formatTimeAgo(timestamp) {
|
|
704
|
+
const now = Date.now();
|
|
705
|
+
const diffMs = now - timestamp;
|
|
706
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
707
|
+
const diffHours = Math.floor(diffMs / 3600000);
|
|
708
|
+
const diffDays = Math.floor(diffMs / 86400000);
|
|
709
|
+
if (diffMins < 60) {
|
|
710
|
+
return `${diffMins}m ago`;
|
|
711
|
+
}
|
|
712
|
+
else if (diffHours < 24) {
|
|
713
|
+
return `${diffHours}h ago`;
|
|
714
|
+
}
|
|
715
|
+
else if (diffDays === 1) {
|
|
716
|
+
return "yesterday";
|
|
717
|
+
}
|
|
718
|
+
else {
|
|
719
|
+
return `${diffDays}d ago`;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
exports.SessionLoggerService = SessionLoggerService;
|
|
724
|
+
//# sourceMappingURL=session-logger.js.map
|