@soleri/core 9.0.3 → 9.2.0
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/dist/brain/intelligence.d.ts +27 -0
- package/dist/brain/intelligence.d.ts.map +1 -1
- package/dist/brain/intelligence.js +160 -14
- package/dist/brain/intelligence.js.map +1 -1
- package/dist/brain/learning-radar.d.ts +4 -0
- package/dist/brain/learning-radar.d.ts.map +1 -1
- package/dist/brain/learning-radar.js +20 -1
- package/dist/brain/learning-radar.js.map +1 -1
- package/dist/brain/strength-scorer.d.ts +31 -0
- package/dist/brain/strength-scorer.d.ts.map +1 -0
- package/dist/brain/strength-scorer.js +264 -0
- package/dist/brain/strength-scorer.js.map +1 -0
- package/dist/chat/agent-loop.d.ts.map +1 -1
- package/dist/chat/agent-loop.js +2 -0
- package/dist/chat/agent-loop.js.map +1 -1
- package/dist/chat/notifications.d.ts.map +1 -1
- package/dist/chat/notifications.js +2 -0
- package/dist/chat/notifications.js.map +1 -1
- package/dist/claudemd/compose.js +1 -1
- package/dist/claudemd/compose.js.map +1 -1
- package/dist/control/intent-router.d.ts.map +1 -1
- package/dist/control/intent-router.js +12 -4
- package/dist/control/intent-router.js.map +1 -1
- package/dist/curator/contradiction-detector.d.ts +27 -0
- package/dist/curator/contradiction-detector.d.ts.map +1 -0
- package/dist/curator/contradiction-detector.js +62 -0
- package/dist/curator/contradiction-detector.js.map +1 -0
- package/dist/curator/curator.d.ts +3 -4
- package/dist/curator/curator.d.ts.map +1 -1
- package/dist/curator/curator.js +90 -525
- package/dist/curator/curator.js.map +1 -1
- package/dist/curator/duplicate-detector.d.ts +14 -0
- package/dist/curator/duplicate-detector.d.ts.map +1 -0
- package/dist/curator/duplicate-detector.js +77 -0
- package/dist/curator/duplicate-detector.js.map +1 -0
- package/dist/curator/health-audit.d.ts +15 -0
- package/dist/curator/health-audit.d.ts.map +1 -0
- package/dist/curator/health-audit.js +97 -0
- package/dist/curator/health-audit.js.map +1 -0
- package/dist/curator/metadata-enricher.d.ts +17 -0
- package/dist/curator/metadata-enricher.d.ts.map +1 -0
- package/dist/curator/metadata-enricher.js +60 -0
- package/dist/curator/metadata-enricher.js.map +1 -0
- package/dist/curator/schema.d.ts +7 -0
- package/dist/curator/schema.d.ts.map +1 -0
- package/dist/curator/schema.js +62 -0
- package/dist/curator/schema.js.map +1 -0
- package/dist/curator/tag-manager.d.ts +36 -0
- package/dist/curator/tag-manager.d.ts.map +1 -0
- package/dist/curator/tag-manager.js +78 -0
- package/dist/curator/tag-manager.js.map +1 -0
- package/dist/engine/bin/soleri-engine.js +55 -3
- package/dist/engine/bin/soleri-engine.js.map +1 -1
- package/dist/engine/core-ops.d.ts.map +1 -1
- package/dist/engine/core-ops.js +33 -10
- package/dist/engine/core-ops.js.map +1 -1
- package/dist/engine/module-manifest.d.ts.map +1 -1
- package/dist/engine/module-manifest.js +22 -2
- package/dist/engine/module-manifest.js.map +1 -1
- package/dist/engine/register-engine.d.ts.map +1 -1
- package/dist/engine/register-engine.js +26 -2
- package/dist/engine/register-engine.js.map +1 -1
- package/dist/errors/retry.d.ts.map +1 -1
- package/dist/errors/retry.js +2 -0
- package/dist/errors/retry.js.map +1 -1
- package/dist/facades/types.d.ts +1 -1
- package/dist/flows/chain-types.d.ts +18 -18
- package/dist/flows/gate-evaluator.d.ts.map +1 -1
- package/dist/flows/gate-evaluator.js +22 -0
- package/dist/flows/gate-evaluator.js.map +1 -1
- package/dist/flows/types.d.ts +157 -28
- package/dist/flows/types.d.ts.map +1 -1
- package/dist/flows/types.js +4 -0
- package/dist/flows/types.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/intake/intake-pipeline.d.ts.map +1 -1
- package/dist/intake/intake-pipeline.js +1 -0
- package/dist/intake/intake-pipeline.js.map +1 -1
- package/dist/intake/text-ingester.d.ts.map +1 -1
- package/dist/intake/text-ingester.js +2 -0
- package/dist/intake/text-ingester.js.map +1 -1
- package/dist/llm/key-pool.d.ts +1 -1
- package/dist/llm/key-pool.d.ts.map +1 -1
- package/dist/llm/key-pool.js +3 -4
- package/dist/llm/key-pool.js.map +1 -1
- package/dist/llm/utils.d.ts.map +1 -1
- package/dist/llm/utils.js +2 -0
- package/dist/llm/utils.js.map +1 -1
- package/dist/migrations/migration-runner.test-helpers.d.ts +13 -0
- package/dist/migrations/migration-runner.test-helpers.d.ts.map +1 -0
- package/dist/migrations/migration-runner.test-helpers.js +47 -0
- package/dist/migrations/migration-runner.test-helpers.js.map +1 -0
- package/dist/operator/operator-profile.d.ts +44 -0
- package/dist/operator/operator-profile.d.ts.map +1 -0
- package/dist/operator/operator-profile.js +377 -0
- package/dist/operator/operator-profile.js.map +1 -0
- package/dist/operator/operator-signals.d.ts +45 -0
- package/dist/operator/operator-signals.d.ts.map +1 -0
- package/dist/operator/operator-signals.js +228 -0
- package/dist/operator/operator-signals.js.map +1 -0
- package/dist/operator/operator-types.d.ts +360 -0
- package/dist/operator/operator-types.d.ts.map +1 -0
- package/dist/operator/operator-types.js +24 -0
- package/dist/operator/operator-types.js.map +1 -0
- package/dist/packs/types.d.ts +27 -27
- package/dist/paths.d.ts +40 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +98 -0
- package/dist/paths.js.map +1 -0
- package/dist/persistence/index.d.ts +1 -1
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +1 -1
- package/dist/persistence/index.js.map +1 -1
- package/dist/persistence/sqlite-provider.d.ts +2 -0
- package/dist/persistence/sqlite-provider.d.ts.map +1 -1
- package/dist/persistence/sqlite-provider.js +8 -5
- package/dist/persistence/sqlite-provider.js.map +1 -1
- package/dist/planning/evidence-collector.d.ts +13 -1
- package/dist/planning/evidence-collector.d.ts.map +1 -1
- package/dist/planning/evidence-collector.js +33 -0
- package/dist/planning/evidence-collector.js.map +1 -1
- package/dist/planning/gap-analysis.d.ts +5 -4
- package/dist/planning/gap-analysis.d.ts.map +1 -1
- package/dist/planning/gap-analysis.js +7 -341
- package/dist/planning/gap-analysis.js.map +1 -1
- package/dist/planning/gap-passes.d.ts +19 -0
- package/dist/planning/gap-passes.d.ts.map +1 -0
- package/dist/planning/gap-passes.js +157 -0
- package/dist/planning/gap-passes.js.map +1 -0
- package/dist/planning/gap-patterns.d.ts +29 -0
- package/dist/planning/gap-patterns.d.ts.map +1 -0
- package/dist/planning/gap-patterns.js +129 -0
- package/dist/planning/gap-patterns.js.map +1 -0
- package/dist/planning/gap-types.d.ts +1 -1
- package/dist/planning/gap-types.d.ts.map +1 -1
- package/dist/planning/gap-types.js +1 -0
- package/dist/planning/gap-types.js.map +1 -1
- package/dist/planning/github-projection.d.ts +122 -0
- package/dist/planning/github-projection.d.ts.map +1 -0
- package/dist/planning/github-projection.js +294 -0
- package/dist/planning/github-projection.js.map +1 -0
- package/dist/planning/impact-analyzer.d.ts +26 -0
- package/dist/planning/impact-analyzer.d.ts.map +1 -0
- package/dist/planning/impact-analyzer.js +199 -0
- package/dist/planning/impact-analyzer.js.map +1 -0
- package/dist/planning/plan-lifecycle.d.ts +136 -0
- package/dist/planning/plan-lifecycle.d.ts.map +1 -0
- package/dist/planning/plan-lifecycle.js +296 -0
- package/dist/planning/plan-lifecycle.js.map +1 -0
- package/dist/planning/planner-types.d.ts +202 -0
- package/dist/planning/planner-types.d.ts.map +1 -0
- package/dist/planning/planner-types.js +6 -0
- package/dist/planning/planner-types.js.map +1 -0
- package/dist/planning/planner.d.ts +31 -383
- package/dist/planning/planner.d.ts.map +1 -1
- package/dist/planning/planner.js +154 -878
- package/dist/planning/planner.js.map +1 -1
- package/dist/planning/rationalization-detector.d.ts +32 -0
- package/dist/planning/rationalization-detector.d.ts.map +1 -0
- package/dist/planning/rationalization-detector.js +89 -0
- package/dist/planning/rationalization-detector.js.map +1 -0
- package/dist/planning/reconciliation-engine.d.ts +47 -0
- package/dist/planning/reconciliation-engine.d.ts.map +1 -0
- package/dist/planning/reconciliation-engine.js +128 -0
- package/dist/planning/reconciliation-engine.js.map +1 -0
- package/dist/planning/task-verifier.d.ts +85 -0
- package/dist/planning/task-verifier.d.ts.map +1 -0
- package/dist/planning/task-verifier.js +227 -0
- package/dist/planning/task-verifier.js.map +1 -0
- package/dist/plugins/types.d.ts +4 -4
- package/dist/runtime/admin-ops.d.ts +2 -2
- package/dist/runtime/admin-ops.d.ts.map +1 -1
- package/dist/runtime/admin-ops.js +44 -17
- package/dist/runtime/admin-ops.js.map +1 -1
- package/dist/runtime/admin-setup-ops.d.ts.map +1 -1
- package/dist/runtime/admin-setup-ops.js +21 -46
- package/dist/runtime/admin-setup-ops.js.map +1 -1
- package/dist/runtime/archive-ops.d.ts +10 -0
- package/dist/runtime/archive-ops.d.ts.map +1 -0
- package/dist/runtime/archive-ops.js +310 -0
- package/dist/runtime/archive-ops.js.map +1 -0
- package/dist/runtime/capture-ops.d.ts.map +1 -1
- package/dist/runtime/capture-ops.js +42 -7
- package/dist/runtime/capture-ops.js.map +1 -1
- package/dist/runtime/claude-md-helpers.js +1 -1
- package/dist/runtime/claude-md-helpers.js.map +1 -1
- package/dist/runtime/context-health.d.ts +31 -0
- package/dist/runtime/context-health.d.ts.map +1 -0
- package/dist/runtime/context-health.js +57 -0
- package/dist/runtime/context-health.js.map +1 -0
- package/dist/runtime/facades/archive-facade.d.ts +10 -0
- package/dist/runtime/facades/archive-facade.d.ts.map +1 -0
- package/dist/runtime/facades/archive-facade.js +11 -0
- package/dist/runtime/facades/archive-facade.js.map +1 -0
- package/dist/runtime/facades/brain-facade.d.ts.map +1 -1
- package/dist/runtime/facades/brain-facade.js +2 -0
- package/dist/runtime/facades/brain-facade.js.map +1 -1
- package/dist/runtime/facades/chat-facade.d.ts +7 -0
- package/dist/runtime/facades/chat-facade.d.ts.map +1 -1
- package/dist/runtime/facades/chat-facade.js +15 -800
- package/dist/runtime/facades/chat-facade.js.map +1 -1
- package/dist/runtime/facades/chat-service-ops.d.ts +9 -0
- package/dist/runtime/facades/chat-service-ops.d.ts.map +1 -0
- package/dist/runtime/facades/chat-service-ops.js +330 -0
- package/dist/runtime/facades/chat-service-ops.js.map +1 -0
- package/dist/runtime/facades/chat-session-ops.d.ts +8 -0
- package/dist/runtime/facades/chat-session-ops.d.ts.map +1 -0
- package/dist/runtime/facades/chat-session-ops.js +136 -0
- package/dist/runtime/facades/chat-session-ops.js.map +1 -0
- package/dist/runtime/facades/chat-state.d.ts +31 -0
- package/dist/runtime/facades/chat-state.d.ts.map +1 -0
- package/dist/runtime/facades/chat-state.js +32 -0
- package/dist/runtime/facades/chat-state.js.map +1 -0
- package/dist/runtime/facades/chat-transport-ops.d.ts +9 -0
- package/dist/runtime/facades/chat-transport-ops.d.ts.map +1 -0
- package/dist/runtime/facades/chat-transport-ops.js +337 -0
- package/dist/runtime/facades/chat-transport-ops.js.map +1 -0
- package/dist/runtime/facades/control-facade.d.ts.map +1 -1
- package/dist/runtime/facades/control-facade.js +4 -1
- package/dist/runtime/facades/control-facade.js.map +1 -1
- package/dist/runtime/facades/index.d.ts.map +1 -1
- package/dist/runtime/facades/index.js +6 -0
- package/dist/runtime/facades/index.js.map +1 -1
- package/dist/runtime/facades/memory-facade.d.ts.map +1 -1
- package/dist/runtime/facades/memory-facade.js +75 -6
- package/dist/runtime/facades/memory-facade.js.map +1 -1
- package/dist/runtime/facades/operator-facade.d.ts +8 -0
- package/dist/runtime/facades/operator-facade.d.ts.map +1 -0
- package/dist/runtime/facades/operator-facade.js +220 -0
- package/dist/runtime/facades/operator-facade.js.map +1 -0
- package/dist/runtime/facades/orchestrate-facade.js +3 -3
- package/dist/runtime/facades/orchestrate-facade.js.map +1 -1
- package/dist/runtime/facades/plan-facade.d.ts.map +1 -1
- package/dist/runtime/facades/plan-facade.js +39 -6
- package/dist/runtime/facades/plan-facade.js.map +1 -1
- package/dist/runtime/facades/review-facade.d.ts +7 -0
- package/dist/runtime/facades/review-facade.d.ts.map +1 -0
- package/dist/runtime/facades/review-facade.js +8 -0
- package/dist/runtime/facades/review-facade.js.map +1 -0
- package/dist/runtime/facades/sync-facade.d.ts +7 -0
- package/dist/runtime/facades/sync-facade.d.ts.map +1 -0
- package/dist/runtime/facades/sync-facade.js +8 -0
- package/dist/runtime/facades/sync-facade.js.map +1 -0
- package/dist/runtime/facades/vault-facade.d.ts +4 -1
- package/dist/runtime/facades/vault-facade.d.ts.map +1 -1
- package/dist/runtime/facades/vault-facade.js +13 -66
- package/dist/runtime/facades/vault-facade.js.map +1 -1
- package/dist/runtime/github-integration.d.ts +49 -0
- package/dist/runtime/github-integration.d.ts.map +1 -0
- package/dist/runtime/github-integration.js +113 -0
- package/dist/runtime/github-integration.js.map +1 -0
- package/dist/runtime/grading-ops.js +1 -1
- package/dist/runtime/grading-ops.js.map +1 -1
- package/dist/runtime/memory-extra-ops.d.ts.map +1 -1
- package/dist/runtime/memory-extra-ops.js +6 -2
- package/dist/runtime/memory-extra-ops.js.map +1 -1
- package/dist/runtime/orchestrate-ops.d.ts.map +1 -1
- package/dist/runtime/orchestrate-ops.js +367 -40
- package/dist/runtime/orchestrate-ops.js.map +1 -1
- package/dist/runtime/planning-extra-ops.d.ts.map +1 -1
- package/dist/runtime/planning-extra-ops.js +69 -4
- package/dist/runtime/planning-extra-ops.js.map +1 -1
- package/dist/runtime/review-ops.d.ts +10 -0
- package/dist/runtime/review-ops.d.ts.map +1 -0
- package/dist/runtime/review-ops.js +97 -0
- package/dist/runtime/review-ops.js.map +1 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +27 -12
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/session-briefing.d.ts +3 -0
- package/dist/runtime/session-briefing.d.ts.map +1 -1
- package/dist/runtime/session-briefing.js +68 -1
- package/dist/runtime/session-briefing.js.map +1 -1
- package/dist/runtime/sync-ops.d.ts +12 -0
- package/dist/runtime/sync-ops.d.ts.map +1 -0
- package/dist/runtime/sync-ops.js +288 -0
- package/dist/runtime/sync-ops.js.map +1 -0
- package/dist/runtime/types.d.ts +10 -4
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/vault-extra-ops.d.ts +5 -4
- package/dist/runtime/vault-extra-ops.d.ts.map +1 -1
- package/dist/runtime/vault-extra-ops.js +5 -300
- package/dist/runtime/vault-extra-ops.js.map +1 -1
- package/dist/runtime/vault-sharing-ops.d.ts +4 -4
- package/dist/runtime/vault-sharing-ops.d.ts.map +1 -1
- package/dist/runtime/vault-sharing-ops.js +5 -300
- package/dist/runtime/vault-sharing-ops.js.map +1 -1
- package/dist/skills/sync-skills.d.ts +27 -0
- package/dist/skills/sync-skills.d.ts.map +1 -0
- package/dist/skills/sync-skills.js +81 -0
- package/dist/skills/sync-skills.js.map +1 -0
- package/dist/update-check.d.ts +14 -0
- package/dist/update-check.d.ts.map +1 -0
- package/dist/update-check.js +96 -0
- package/dist/update-check.js.map +1 -0
- package/dist/vault/linking.d.ts +10 -12
- package/dist/vault/linking.d.ts.map +1 -1
- package/dist/vault/linking.js +104 -161
- package/dist/vault/linking.js.map +1 -1
- package/dist/vault/vault-entries.d.ts +69 -0
- package/dist/vault/vault-entries.d.ts.map +1 -0
- package/dist/vault/vault-entries.js +257 -0
- package/dist/vault/vault-entries.js.map +1 -0
- package/dist/vault/vault-interfaces.d.ts +153 -0
- package/dist/vault/vault-interfaces.d.ts.map +1 -0
- package/dist/vault/vault-interfaces.js +2 -0
- package/dist/vault/vault-interfaces.js.map +1 -0
- package/dist/vault/vault-maintenance.d.ts +40 -0
- package/dist/vault/vault-maintenance.d.ts.map +1 -0
- package/dist/vault/vault-maintenance.js +142 -0
- package/dist/vault/vault-maintenance.js.map +1 -0
- package/dist/vault/vault-markdown-sync.d.ts +22 -0
- package/dist/vault/vault-markdown-sync.d.ts.map +1 -0
- package/dist/vault/vault-markdown-sync.js +143 -0
- package/dist/vault/vault-markdown-sync.js.map +1 -0
- package/dist/vault/vault-memories.d.ts +61 -0
- package/dist/vault/vault-memories.d.ts.map +1 -0
- package/dist/vault/vault-memories.js +240 -0
- package/dist/vault/vault-memories.js.map +1 -0
- package/dist/vault/vault-schema.d.ts +9 -0
- package/dist/vault/vault-schema.d.ts.map +1 -0
- package/dist/vault/vault-schema.js +179 -0
- package/dist/vault/vault-schema.js.map +1 -0
- package/dist/vault/vault.d.ts +29 -81
- package/dist/vault/vault.d.ts.map +1 -1
- package/dist/vault/vault.js +78 -931
- package/dist/vault/vault.js.map +1 -1
- package/package.json +1 -1
- package/src/agency/agency-manager.test.ts +600 -0
- package/src/agency/default-rules.test.ts +228 -0
- package/src/{__tests__ → brain}/brain-intelligence.test.ts +37 -14
- package/src/{__tests__ → brain}/brain.test.ts +1 -1
- package/src/brain/intelligence.ts +196 -15
- package/src/brain/learning-radar.ts +22 -1
- package/src/{__tests__ → brain}/second-brain-features.test.ts +4 -4
- package/src/{__tests__ → brain}/session-lifecycle.test.ts +2 -2
- package/src/brain/strength-scorer.ts +404 -0
- package/src/capabilities/chain-mapping.test.ts +66 -0
- package/src/capabilities/registry.test.ts +369 -0
- package/src/chat/agent-loop.test.ts +394 -0
- package/src/chat/agent-loop.ts +2 -0
- package/src/{__tests__ → chat}/chat-differentiators.test.ts +3 -3
- package/src/{__tests__ → chat}/chat-enhanced.test.ts +4 -4
- package/src/{__tests__ → chat}/chat-transport.test.ts +6 -6
- package/src/chat/mcp-bridge.test.ts +173 -0
- package/src/chat/notifications.ts +2 -0
- package/src/chat/output-compressor.test.ts +164 -0
- package/src/claudemd/compose.test.ts +178 -0
- package/src/claudemd/compose.ts +1 -1
- package/src/claudemd/inject.test.ts +211 -0
- package/src/context/context-engine.test.ts +461 -0
- package/src/control/identity-manager.test.ts +305 -0
- package/src/control/intent-router.test.ts +360 -0
- package/src/control/intent-router.ts +13 -4
- package/src/curator/classifier.test.ts +104 -0
- package/src/curator/contradiction-detector.test.ts +180 -0
- package/src/curator/contradiction-detector.ts +87 -0
- package/src/{__tests__ → curator}/curator-pipeline-e2e.test.ts +10 -10
- package/src/{__tests__ → curator}/curator.test.ts +77 -1
- package/src/curator/curator.ts +115 -777
- package/src/curator/duplicate-detector.test.ts +183 -0
- package/src/curator/duplicate-detector.ts +103 -0
- package/src/curator/health-audit.ts +126 -0
- package/src/curator/metadata-enricher.ts +84 -0
- package/src/curator/quality-gate.test.ts +135 -0
- package/src/curator/schema.ts +65 -0
- package/src/curator/tag-manager.test.ts +165 -0
- package/src/curator/tag-manager.ts +109 -0
- package/src/domain-packs/inject-rules.test.ts +117 -0
- package/src/domain-packs/knowledge-installer.test.ts +171 -0
- package/src/domain-packs/loader.test.ts +86 -0
- package/src/domain-packs/pack-runtime.test.ts +140 -0
- package/src/domain-packs/skills-installer.test.ts +135 -0
- package/src/domain-packs/token-resolver.test.ts +150 -0
- package/src/domain-packs/types.test.ts +130 -0
- package/src/enforcement/adapters/claude-code.test.ts +216 -0
- package/src/enforcement/registry.test.ts +264 -0
- package/src/engine/bin/soleri-engine.ts +59 -3
- package/src/engine/core-ops.test.ts +254 -0
- package/src/engine/core-ops.ts +35 -10
- package/src/engine/module-manifest.test.ts +124 -0
- package/src/engine/module-manifest.ts +22 -2
- package/src/engine/register-engine.test.ts +230 -0
- package/src/engine/register-engine.ts +26 -2
- package/src/errors/classify.test.ts +199 -0
- package/src/errors/retry.test.ts +156 -0
- package/src/errors/retry.ts +2 -0
- package/src/errors/types.test.ts +108 -0
- package/src/events/event-bus.test.ts +149 -0
- package/src/extensions/middleware.test.ts +234 -0
- package/src/facades/facade-factory.test.ts +424 -0
- package/src/flows/chain-runner.test.ts +273 -0
- package/src/flows/context-router.test.ts +52 -0
- package/src/flows/dispatch-registry.test.ts +128 -0
- package/src/flows/epilogue.test.ts +107 -0
- package/src/flows/executor.test.ts +263 -0
- package/src/flows/gate-evaluator.test.ts +194 -0
- package/src/flows/gate-evaluator.ts +25 -0
- package/src/flows/types.ts +4 -0
- package/src/governance/governance.test.ts +726 -0
- package/src/health/health-registry.test.ts +186 -0
- package/src/health/vault-integrity.test.ts +110 -0
- package/src/index.ts +92 -0
- package/src/intake/content-classifier.test.ts +209 -0
- package/src/intake/dedup-gate.test.ts +131 -0
- package/src/intake/intake-pipeline.test.ts +506 -0
- package/src/intake/intake-pipeline.ts +1 -0
- package/src/intake/text-ingester.test.ts +194 -0
- package/src/intake/text-ingester.ts +2 -0
- package/src/llm/key-pool.test.ts +236 -0
- package/src/llm/key-pool.ts +3 -4
- package/src/llm/llm-client.test.ts +345 -0
- package/src/llm/oauth-discovery.test.ts +180 -0
- package/src/llm/utils.test.ts +327 -0
- package/src/llm/utils.ts +2 -0
- package/src/{__tests__ → logging}/logger.test.ts +41 -62
- package/src/loop/loop-manager.test.ts +519 -0
- package/src/migrations/migration-runner.edge-cases.test.ts +319 -0
- package/src/migrations/migration-runner.test-helpers.ts +64 -0
- package/src/migrations/migration-runner.test.ts +385 -0
- package/src/operator/auto-signal-pipeline.test.ts +207 -0
- package/src/operator/operator-profile-extended.test.ts +320 -0
- package/src/operator/operator-profile.test.ts +314 -0
- package/src/operator/operator-profile.ts +469 -0
- package/src/operator/operator-signals-extended.test.ts +245 -0
- package/src/operator/operator-signals.test.ts +281 -0
- package/src/operator/operator-signals.ts +261 -0
- package/src/operator/operator-types.ts +444 -0
- package/src/operator/prompts/hook-precompact-operator-dispatch.md +94 -0
- package/src/operator/prompts/subagent-soft-signal-extractor.md +125 -0
- package/src/operator/prompts/subagent-synthesis-cognition.md +181 -0
- package/src/operator/prompts/subagent-synthesis-communication.md +140 -0
- package/src/operator/prompts/subagent-synthesis-technical.md +160 -0
- package/src/operator/prompts/subagent-synthesis-trust.md +143 -0
- package/src/{__tests__ → packs}/pack-lockfile.test.ts +3 -3
- package/src/{__tests__ → packs}/pack-system.test.ts +2 -2
- package/src/paths.ts +115 -0
- package/src/persistence/index.ts +1 -1
- package/src/persistence/sqlite-provider.test.ts +540 -0
- package/src/persistence/sqlite-provider.ts +8 -5
- package/src/persona/defaults.test.ts +59 -0
- package/src/persona/loader.test.ts +67 -0
- package/src/persona/prompt-generator.test.ts +127 -0
- package/src/planning/evidence-collector.test.ts +406 -0
- package/src/planning/evidence-collector.ts +50 -0
- package/src/planning/gap-analysis-alternatives.test.ts +169 -0
- package/src/planning/gap-analysis.ts +21 -636
- package/src/planning/gap-passes.test.ts +372 -0
- package/src/planning/gap-passes.ts +298 -0
- package/src/planning/gap-patterns.test.ts +320 -0
- package/src/planning/gap-patterns.ts +234 -0
- package/src/planning/gap-types.ts +4 -1
- package/src/planning/github-projection.test.ts +177 -0
- package/src/planning/github-projection.ts +425 -0
- package/src/planning/impact-analyzer.test.ts +180 -0
- package/src/planning/impact-analyzer.ts +264 -0
- package/src/planning/plan-lifecycle.test.ts +312 -0
- package/src/planning/plan-lifecycle.ts +346 -0
- package/src/planning/planner-types.ts +215 -0
- package/src/{__tests__ → planning}/planner.test.ts +169 -15
- package/src/planning/planner.ts +197 -1228
- package/src/planning/rationalization-detector.test.ts +171 -0
- package/src/planning/rationalization-detector.ts +138 -0
- package/src/planning/reconciliation-engine.test.ts +141 -0
- package/src/planning/reconciliation-engine.ts +162 -0
- package/src/planning/task-verifier.test.ts +235 -0
- package/src/planning/task-verifier.ts +303 -0
- package/src/planning/verification-protocol.test.ts +201 -0
- package/src/playbooks/generic/generic-playbooks.test.ts +438 -0
- package/src/playbooks/index.test.ts +77 -0
- package/src/playbooks/playbook-executor.test.ts +255 -0
- package/src/playbooks/playbook-registry.test.ts +232 -0
- package/src/playbooks/playbook-seeder.test.ts +153 -0
- package/src/plugins/plugin-loader.test.ts +212 -0
- package/src/plugins/plugin-registry.test.ts +272 -0
- package/src/project/project-registry.test.ts +428 -0
- package/src/prompts/parser.test.ts +100 -0
- package/src/prompts/template-manager.test.ts +109 -0
- package/src/{__tests__ → queue}/async-infrastructure.test.ts +3 -3
- package/src/queue/job-queue.test.ts +331 -0
- package/src/queue/pipeline-runner.test.ts +209 -0
- package/src/runtime/admin-extra-ops.test.ts +527 -0
- package/src/runtime/admin-ops.test.ts +257 -0
- package/src/runtime/admin-ops.ts +45 -17
- package/src/runtime/admin-setup-ops.test.ts +328 -0
- package/src/runtime/admin-setup-ops.ts +20 -43
- package/src/runtime/archive-ops.test.ts +269 -0
- package/src/runtime/archive-ops.ts +347 -0
- package/src/runtime/capture-ops.test.ts +433 -0
- package/src/runtime/capture-ops.ts +50 -8
- package/src/runtime/chain-ops.test.ts +149 -0
- package/src/runtime/claude-md-helpers.test.ts +191 -0
- package/src/runtime/claude-md-helpers.ts +1 -1
- package/src/runtime/context-health.test.ts +78 -0
- package/src/runtime/context-health.ts +85 -0
- package/src/runtime/curator-extra-ops.test.ts +202 -0
- package/src/runtime/deprecation.test.ts +98 -0
- package/src/runtime/domain-ops.test.ts +268 -0
- package/src/runtime/facades/admin-facade.test.ts +333 -0
- package/src/runtime/facades/agency-facade.test.ts +278 -0
- package/src/runtime/facades/archive-facade.test.ts +294 -0
- package/src/runtime/facades/archive-facade.ts +14 -0
- package/src/runtime/facades/brain-facade.test.ts +714 -0
- package/src/runtime/facades/brain-facade.ts +2 -0
- package/src/runtime/facades/chat-facade.test.ts +166 -0
- package/src/runtime/facades/chat-facade.ts +15 -906
- package/src/runtime/facades/chat-service-ops.test.ts +276 -0
- package/src/runtime/facades/chat-service-ops.ts +374 -0
- package/src/runtime/facades/chat-session-ops.test.ts +197 -0
- package/src/runtime/facades/chat-session-ops.ts +146 -0
- package/src/runtime/facades/chat-state.ts +60 -0
- package/src/runtime/facades/chat-transport-ops.test.ts +269 -0
- package/src/runtime/facades/chat-transport-ops.ts +380 -0
- package/src/runtime/facades/context-facade.test.ts +108 -0
- package/src/runtime/facades/control-facade.test.ts +436 -0
- package/src/runtime/facades/control-facade.ts +6 -1
- package/src/runtime/facades/curator-facade.test.ts +303 -0
- package/src/runtime/facades/index.ts +6 -0
- package/src/runtime/facades/loop-facade.test.ts +245 -0
- package/src/runtime/facades/memory-facade.test.ts +269 -0
- package/src/runtime/facades/memory-facade.ts +78 -6
- package/src/runtime/facades/operator-facade.test.ts +208 -0
- package/src/runtime/facades/operator-facade.ts +236 -0
- package/src/runtime/facades/orchestrate-facade.test.ts +185 -0
- package/src/runtime/facades/orchestrate-facade.ts +3 -3
- package/src/runtime/facades/plan-facade.test.ts +266 -0
- package/src/runtime/facades/plan-facade.ts +42 -6
- package/src/runtime/facades/review-facade.test.ts +82 -0
- package/src/runtime/facades/review-facade.ts +11 -0
- package/src/runtime/facades/sync-facade.test.ts +113 -0
- package/src/runtime/facades/sync-facade.ts +11 -0
- package/src/runtime/facades/vault-facade.test.ts +631 -0
- package/src/runtime/facades/vault-facade.ts +15 -70
- package/src/runtime/feature-flags.test.ts +140 -0
- package/src/runtime/github-integration.test.ts +89 -0
- package/src/runtime/github-integration.ts +159 -0
- package/src/runtime/grading-ops.test.ts +141 -0
- package/src/runtime/grading-ops.ts +1 -1
- package/src/runtime/intake-ops.test.ts +208 -0
- package/src/runtime/loop-ops.test.ts +238 -0
- package/src/runtime/memory-cross-project-ops.test.ts +177 -0
- package/src/runtime/memory-extra-ops.test.ts +453 -0
- package/src/runtime/memory-extra-ops.ts +6 -2
- package/src/runtime/orchestrate-ops.test.ts +302 -0
- package/src/runtime/orchestrate-ops.ts +435 -46
- package/src/runtime/pack-ops.test.ts +158 -0
- package/src/runtime/planning-extra-ops.test.ts +583 -0
- package/src/runtime/planning-extra-ops.ts +72 -4
- package/src/{__tests__ → runtime}/playbook-ops-execution.test.ts +3 -3
- package/src/runtime/playbook-ops.test.ts +262 -0
- package/src/runtime/plugin-ops.test.ts +201 -0
- package/src/runtime/project-ops.test.ts +235 -0
- package/src/runtime/review-ops.test.ts +142 -0
- package/src/runtime/review-ops.ts +99 -0
- package/src/runtime/runtime.test.ts +363 -0
- package/src/runtime/runtime.ts +39 -12
- package/src/runtime/session-briefing.test.ts +302 -0
- package/src/runtime/session-briefing.ts +80 -1
- package/src/runtime/sync-ops.test.ts +221 -0
- package/src/runtime/sync-ops.ts +325 -0
- package/src/runtime/telemetry-ops.test.ts +132 -0
- package/src/runtime/types.ts +10 -4
- package/src/runtime/vault-extra-ops.test.ts +246 -0
- package/src/runtime/vault-extra-ops.ts +5 -332
- package/src/runtime/vault-linking-ops.test.ts +237 -0
- package/src/runtime/vault-sharing-ops.test.ts +130 -0
- package/src/runtime/vault-sharing-ops.ts +5 -329
- package/src/skills/sync-skills.ts +108 -0
- package/src/streams/normalize.test.ts +95 -0
- package/src/streams/replayable-stream.test.ts +166 -0
- package/src/telemetry/telemetry.test.ts +143 -0
- package/src/transport/http-server.test.ts +394 -0
- package/src/transport/lsp-server.test.ts +458 -0
- package/src/transport/rate-limiter.test.ts +126 -0
- package/src/transport/session-manager.test.ts +133 -0
- package/src/transport/token-auth.test.ts +136 -0
- package/src/transport/ws-server.test.ts +294 -0
- package/src/update-check.ts +111 -0
- package/src/vault/__tests__/vault-characterization.test.ts +168 -0
- package/src/vault/content-hash.test.ts +78 -0
- package/src/vault/git-vault-sync.test.ts +234 -0
- package/src/vault/knowledge-review.test.ts +269 -0
- package/src/vault/linking.test.ts +358 -0
- package/src/vault/linking.ts +149 -183
- package/src/vault/obsidian-sync.test.ts +342 -0
- package/src/vault/playbook.test.ts +152 -0
- package/src/vault/scope-detector.test.ts +187 -0
- package/src/vault/vault-branching.test.ts +250 -0
- package/src/{__tests__ → vault}/vault-connect.test.ts +1 -1
- package/src/vault/vault-entries.ts +282 -0
- package/src/vault/vault-interfaces.ts +56 -0
- package/src/vault/vault-maintenance.ts +205 -0
- package/src/vault/vault-manager.test.ts +206 -0
- package/src/vault/vault-markdown-sync.test.ts +203 -0
- package/src/vault/vault-markdown-sync.ts +160 -0
- package/src/vault/vault-memories.ts +339 -0
- package/src/{__tests__ → vault}/vault-scaling.test.ts +1 -1
- package/src/vault/vault-schema.ts +181 -0
- package/src/{__tests__ → vault}/vault-sharing.test.ts +4 -4
- package/src/{__tests__ → vault}/vault.test.ts +2 -2
- package/src/vault/vault.ts +89 -1171
- package/dist/cognee/client.d.ts +0 -43
- package/dist/cognee/client.d.ts.map +0 -1
- package/dist/cognee/client.js +0 -375
- package/dist/cognee/client.js.map +0 -1
- package/dist/cognee/sync-manager.d.ts +0 -153
- package/dist/cognee/sync-manager.d.ts.map +0 -1
- package/dist/cognee/sync-manager.js +0 -390
- package/dist/cognee/sync-manager.js.map +0 -1
- package/dist/cognee/types.d.ts +0 -62
- package/dist/cognee/types.d.ts.map +0 -1
- package/dist/cognee/types.js +0 -3
- package/dist/cognee/types.js.map +0 -1
- package/dist/governance/index.d.ts +0 -3
- package/dist/governance/index.d.ts.map +0 -1
- package/dist/governance/index.js +0 -2
- package/dist/governance/index.js.map +0 -1
- package/dist/health/doctor-checks.d.ts +0 -15
- package/dist/health/doctor-checks.d.ts.map +0 -1
- package/dist/health/doctor-checks.js +0 -98
- package/dist/health/doctor-checks.js.map +0 -1
- package/dist/persistence/postgres-provider.d.ts +0 -81
- package/dist/persistence/postgres-provider.d.ts.map +0 -1
- package/dist/persistence/postgres-provider.js +0 -256
- package/dist/persistence/postgres-provider.js.map +0 -1
- package/dist/runtime/cognee-sync-ops.d.ts +0 -12
- package/dist/runtime/cognee-sync-ops.d.ts.map +0 -1
- package/dist/runtime/cognee-sync-ops.js +0 -93
- package/dist/runtime/cognee-sync-ops.js.map +0 -1
- package/dist/runtime/core-ops.d.ts +0 -23
- package/dist/runtime/core-ops.d.ts.map +0 -1
- package/dist/runtime/core-ops.js +0 -1296
- package/dist/runtime/core-ops.js.map +0 -1
- package/dist/runtime/facades/cognee-facade.d.ts +0 -8
- package/dist/runtime/facades/cognee-facade.d.ts.map +0 -1
- package/dist/runtime/facades/cognee-facade.js +0 -156
- package/dist/runtime/facades/cognee-facade.js.map +0 -1
- package/src/__tests__/admin-extra-ops.test.ts +0 -484
- package/src/__tests__/admin-ops.test.ts +0 -268
- package/src/__tests__/admin-setup-ops.test.ts +0 -355
- package/src/__tests__/agency-manager.test.ts +0 -374
- package/src/__tests__/agent-loop.test.ts +0 -256
- package/src/__tests__/capture-ops.test.ts +0 -784
- package/src/__tests__/claudemd.test.ts +0 -282
- package/src/__tests__/content-hash.test.ts +0 -60
- package/src/__tests__/context-engine.test.ts +0 -251
- package/src/__tests__/core-ops.test.ts +0 -550
- package/src/__tests__/curator-extra-ops.test.ts +0 -383
- package/src/__tests__/deprecation.test.ts +0 -78
- package/src/__tests__/domain-ops.test.ts +0 -226
- package/src/__tests__/domain-packs.test.ts +0 -421
- package/src/__tests__/enforcement.test.ts +0 -153
- package/src/__tests__/errors.test.ts +0 -388
- package/src/__tests__/extensions.test.ts +0 -233
- package/src/__tests__/facade-factory.test.ts +0 -271
- package/src/__tests__/feature-flags.test.ts +0 -137
- package/src/__tests__/flows.test.ts +0 -604
- package/src/__tests__/git-vault-sync.test.ts +0 -230
- package/src/__tests__/governance.test.ts +0 -522
- package/src/__tests__/grading-ops.test.ts +0 -361
- package/src/__tests__/health-registry.test.ts +0 -173
- package/src/__tests__/identity-manager.test.ts +0 -243
- package/src/__tests__/intake-pipeline.test.ts +0 -162
- package/src/__tests__/intent-router.test.ts +0 -222
- package/src/__tests__/knowledge-review.test.ts +0 -104
- package/src/__tests__/llm-client.test.ts +0 -69
- package/src/__tests__/llm.test.ts +0 -556
- package/src/__tests__/loader.test.ts +0 -176
- package/src/__tests__/loop-ops.test.ts +0 -469
- package/src/__tests__/lsp-transport.test.ts +0 -442
- package/src/__tests__/memory-cross-project-ops.test.ts +0 -248
- package/src/__tests__/memory-extra-ops.test.ts +0 -352
- package/src/__tests__/migration-runner.test.ts +0 -170
- package/src/__tests__/module-manifest-drift.test.ts +0 -59
- package/src/__tests__/normalize.test.ts +0 -85
- package/src/__tests__/obsidian-sync.test.ts +0 -354
- package/src/__tests__/orchestrate-ops.test.ts +0 -289
- package/src/__tests__/pack-ops.test.ts +0 -146
- package/src/__tests__/persistence.test.ts +0 -291
- package/src/__tests__/planning-extra-ops.test.ts +0 -706
- package/src/__tests__/playbook-executor.test.ts +0 -249
- package/src/__tests__/playbook-registry.test.ts +0 -326
- package/src/__tests__/playbook-seeder.test.ts +0 -163
- package/src/__tests__/playbook.test.ts +0 -389
- package/src/__tests__/plugin-ops.test.ts +0 -411
- package/src/__tests__/plugin-system.test.ts +0 -509
- package/src/__tests__/project-ops.test.ts +0 -381
- package/src/__tests__/replayable-stream.test.ts +0 -177
- package/src/__tests__/runtime.test.ts +0 -95
- package/src/__tests__/scope-detector.test.ts +0 -121
- package/src/__tests__/template-manager.test.ts +0 -222
- package/src/__tests__/token-resolver.test.ts +0 -79
- package/src/__tests__/transport.test.ts +0 -758
- package/src/__tests__/vault-branching.test.ts +0 -274
- package/src/__tests__/vault-extra-ops.test.ts +0 -482
- package/src/__tests__/vault-integrity.test.ts +0 -71
- package/src/__tests__/vault-manager.test.ts +0 -238
- package/src/__tests__/ws-transport.test.ts +0 -479
|
@@ -1,808 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Chat facade — session management, response chunking, auth for chat transports.
|
|
3
|
+
*
|
|
4
|
+
* Delegates to:
|
|
5
|
+
* - chat-session-ops.ts — session lifecycle (init, get, append, clear, delete, list)
|
|
6
|
+
* - chat-transport-ops.ts — chunking, auth, bridge, compression
|
|
7
|
+
* - chat-service-ops.ts — cancellation, self-update, files, notifications,
|
|
8
|
+
* voice, queue, browser
|
|
9
|
+
* - chat-state.ts — shared state and lazy initializers
|
|
3
10
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { SelfUpdateManager } from '../../chat/self-update.js';
|
|
9
|
-
import { NotificationEngine } from '../../chat/notifications.js';
|
|
10
|
-
import { detectFileIntent, buildMultimodalContent, cleanupTempFiles, } from '../../chat/file-handler.js';
|
|
11
|
-
import { transcribeAudio, synthesizeSpeech } from '../../chat/voice.js';
|
|
12
|
-
import { MessageQueue } from '../../chat/queue.js';
|
|
13
|
-
import { BrowserSessionManager } from '../../chat/browser-session.js';
|
|
14
|
-
import { chunkResponse } from '../../chat/response-chunker.js';
|
|
15
|
-
import { McpToolBridge } from '../../chat/mcp-bridge.js';
|
|
16
|
-
import { createOutputCompressor } from '../../chat/output-compressor.js';
|
|
17
|
-
function getOrCreateSessions(state, config) {
|
|
18
|
-
if (!state.sessions) {
|
|
19
|
-
state.sessions = new ChatSessionManager(config);
|
|
20
|
-
state.sessions.startReaper();
|
|
21
|
-
}
|
|
22
|
-
return state.sessions;
|
|
23
|
-
}
|
|
24
|
-
function getOrCreateAuth(state, config) {
|
|
25
|
-
if (!state.auth) {
|
|
26
|
-
state.auth = new ChatAuthManager(config);
|
|
27
|
-
}
|
|
28
|
-
return state.auth;
|
|
29
|
-
}
|
|
11
|
+
import { createChatState } from './chat-state.js';
|
|
12
|
+
import { createChatSessionOps } from './chat-session-ops.js';
|
|
13
|
+
import { createChatTransportOps } from './chat-transport-ops.js';
|
|
14
|
+
import { createChatServiceOps } from './chat-service-ops.js';
|
|
30
15
|
export function createChatFacadeOps(_runtime) {
|
|
31
|
-
const state =
|
|
32
|
-
sessions: null,
|
|
33
|
-
auth: null,
|
|
34
|
-
bridge: null,
|
|
35
|
-
cancellation: null,
|
|
36
|
-
updater: null,
|
|
37
|
-
notifications: null,
|
|
38
|
-
queue: null,
|
|
39
|
-
browser: null,
|
|
40
|
-
};
|
|
16
|
+
const state = createChatState();
|
|
41
17
|
return [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
description: 'Initialize chat session management. Must be called before other session ops. Provide the storage directory path.',
|
|
46
|
-
auth: 'write',
|
|
47
|
-
schema: z.object({
|
|
48
|
-
storageDir: z.string().describe('Directory for session persistence.'),
|
|
49
|
-
ttlMs: z.number().optional().describe('Session TTL in ms. Default: 7200000 (2 hours).'),
|
|
50
|
-
compactionThreshold: z
|
|
51
|
-
.number()
|
|
52
|
-
.optional()
|
|
53
|
-
.describe('Messages before compaction. Default: 100.'),
|
|
54
|
-
compactionKeep: z
|
|
55
|
-
.number()
|
|
56
|
-
.optional()
|
|
57
|
-
.describe('Messages to keep after compaction. Default: 40.'),
|
|
58
|
-
}),
|
|
59
|
-
handler: async (params) => {
|
|
60
|
-
const config = {
|
|
61
|
-
storageDir: params.storageDir,
|
|
62
|
-
ttlMs: params.ttlMs,
|
|
63
|
-
compactionThreshold: params.compactionThreshold,
|
|
64
|
-
compactionKeep: params.compactionKeep,
|
|
65
|
-
};
|
|
66
|
-
const sessions = getOrCreateSessions(state, config);
|
|
67
|
-
return {
|
|
68
|
-
initialized: true,
|
|
69
|
-
activeSessions: sessions.size,
|
|
70
|
-
storageDir: config.storageDir,
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
name: 'chat_session_get',
|
|
76
|
-
description: 'Get or create a chat session by ID. Returns session with message history.',
|
|
77
|
-
auth: 'read',
|
|
78
|
-
schema: z.object({
|
|
79
|
-
sessionId: z.string().describe('Session/chat ID.'),
|
|
80
|
-
storageDir: z.string().describe('Storage directory (auto-initializes if needed).'),
|
|
81
|
-
}),
|
|
82
|
-
handler: async (params) => {
|
|
83
|
-
const sessions = getOrCreateSessions(state, {
|
|
84
|
-
storageDir: params.storageDir,
|
|
85
|
-
});
|
|
86
|
-
const session = sessions.getOrCreate(params.sessionId);
|
|
87
|
-
return {
|
|
88
|
-
id: session.id,
|
|
89
|
-
messageCount: session.messages.length,
|
|
90
|
-
createdAt: session.createdAt,
|
|
91
|
-
lastActiveAt: session.lastActiveAt,
|
|
92
|
-
meta: session.meta,
|
|
93
|
-
};
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
name: 'chat_session_append',
|
|
98
|
-
description: 'Append a message to a chat session.',
|
|
99
|
-
auth: 'write',
|
|
100
|
-
schema: z.object({
|
|
101
|
-
sessionId: z.string().describe('Session/chat ID.'),
|
|
102
|
-
storageDir: z.string().describe('Storage directory.'),
|
|
103
|
-
role: z.enum(['user', 'assistant', 'system', 'tool']).describe('Message role.'),
|
|
104
|
-
content: z.string().describe('Message content.'),
|
|
105
|
-
}),
|
|
106
|
-
handler: async (params) => {
|
|
107
|
-
const sessions = getOrCreateSessions(state, {
|
|
108
|
-
storageDir: params.storageDir,
|
|
109
|
-
});
|
|
110
|
-
sessions.appendMessage(params.sessionId, {
|
|
111
|
-
role: params.role,
|
|
112
|
-
content: params.content,
|
|
113
|
-
timestamp: Date.now(),
|
|
114
|
-
});
|
|
115
|
-
return {
|
|
116
|
-
sessionId: params.sessionId,
|
|
117
|
-
messageCount: sessions.messageCount(params.sessionId),
|
|
118
|
-
};
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: 'chat_session_clear',
|
|
123
|
-
description: 'Clear message history for a session (keeps session alive).',
|
|
124
|
-
auth: 'write',
|
|
125
|
-
schema: z.object({
|
|
126
|
-
sessionId: z.string().describe('Session/chat ID.'),
|
|
127
|
-
storageDir: z.string().describe('Storage directory.'),
|
|
128
|
-
}),
|
|
129
|
-
handler: async (params) => {
|
|
130
|
-
const sessions = getOrCreateSessions(state, {
|
|
131
|
-
storageDir: params.storageDir,
|
|
132
|
-
});
|
|
133
|
-
sessions.clear(params.sessionId);
|
|
134
|
-
return { cleared: true, sessionId: params.sessionId };
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
name: 'chat_session_delete',
|
|
139
|
-
description: 'Delete a session entirely (memory + disk).',
|
|
140
|
-
auth: 'write',
|
|
141
|
-
schema: z.object({
|
|
142
|
-
sessionId: z.string().describe('Session/chat ID.'),
|
|
143
|
-
storageDir: z.string().describe('Storage directory.'),
|
|
144
|
-
}),
|
|
145
|
-
handler: async (params) => {
|
|
146
|
-
const sessions = getOrCreateSessions(state, {
|
|
147
|
-
storageDir: params.storageDir,
|
|
148
|
-
});
|
|
149
|
-
sessions.delete(params.sessionId);
|
|
150
|
-
return { deleted: true, sessionId: params.sessionId };
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: 'chat_session_list',
|
|
155
|
-
description: 'List all session IDs (active + persisted).',
|
|
156
|
-
auth: 'read',
|
|
157
|
-
schema: z.object({
|
|
158
|
-
storageDir: z.string().describe('Storage directory.'),
|
|
159
|
-
}),
|
|
160
|
-
handler: async (params) => {
|
|
161
|
-
const sessions = getOrCreateSessions(state, {
|
|
162
|
-
storageDir: params.storageDir,
|
|
163
|
-
});
|
|
164
|
-
const ids = sessions.listAll();
|
|
165
|
-
return { sessions: ids, count: ids.length, active: sessions.size };
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
// ─── Response Chunking ────────────────────────────────────────
|
|
169
|
-
{
|
|
170
|
-
name: 'chat_chunk_response',
|
|
171
|
-
description: 'Split a long response into chunks for chat platforms. Converts Markdown to HTML by default.',
|
|
172
|
-
auth: 'read',
|
|
173
|
-
schema: z.object({
|
|
174
|
-
text: z.string().describe('The response text to chunk.'),
|
|
175
|
-
maxChunkSize: z.number().optional().describe('Max characters per chunk. Default: 4000.'),
|
|
176
|
-
format: z
|
|
177
|
-
.enum(['html', 'markdown', 'plain'])
|
|
178
|
-
.optional()
|
|
179
|
-
.describe('Output format. Default: html.'),
|
|
180
|
-
}),
|
|
181
|
-
handler: async (params) => {
|
|
182
|
-
const config = {
|
|
183
|
-
maxChunkSize: params.maxChunkSize,
|
|
184
|
-
format: params.format,
|
|
185
|
-
};
|
|
186
|
-
const chunks = chunkResponse(params.text, config);
|
|
187
|
-
return { chunks, count: chunks.length };
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
// ─── Authentication ───────────────────────────────────────────
|
|
191
|
-
{
|
|
192
|
-
name: 'chat_auth_init',
|
|
193
|
-
description: 'Initialize chat authentication. Provide passphrase and optional allowlist.',
|
|
194
|
-
auth: 'write',
|
|
195
|
-
schema: z.object({
|
|
196
|
-
storagePath: z.string().describe('Path to auth persistence file.'),
|
|
197
|
-
passphrase: z.string().optional().describe('Auth passphrase. If unset, auth is disabled.'),
|
|
198
|
-
allowedUsers: z
|
|
199
|
-
.array(z.union([z.string(), z.number()]))
|
|
200
|
-
.optional()
|
|
201
|
-
.describe('Allowed user IDs. Empty = any user.'),
|
|
202
|
-
}),
|
|
203
|
-
handler: async (params) => {
|
|
204
|
-
const config = {
|
|
205
|
-
storagePath: params.storagePath,
|
|
206
|
-
passphrase: params.passphrase,
|
|
207
|
-
allowedUsers: params.allowedUsers,
|
|
208
|
-
};
|
|
209
|
-
const auth = getOrCreateAuth(state, config);
|
|
210
|
-
return {
|
|
211
|
-
initialized: true,
|
|
212
|
-
enabled: auth.enabled,
|
|
213
|
-
authenticatedCount: auth.authenticatedCount,
|
|
214
|
-
};
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
name: 'chat_auth_check',
|
|
219
|
-
description: 'Check if a user is authenticated.',
|
|
220
|
-
auth: 'read',
|
|
221
|
-
schema: z.object({
|
|
222
|
-
userId: z.union([z.string(), z.number()]).describe('User ID to check.'),
|
|
223
|
-
storagePath: z.string().describe('Auth storage path (auto-initializes if needed).'),
|
|
224
|
-
}),
|
|
225
|
-
handler: async (params) => {
|
|
226
|
-
const auth = getOrCreateAuth(state, {
|
|
227
|
-
storagePath: params.storagePath,
|
|
228
|
-
});
|
|
229
|
-
const userId = params.userId;
|
|
230
|
-
return {
|
|
231
|
-
userId,
|
|
232
|
-
authenticated: auth.isAuthenticated(userId),
|
|
233
|
-
lockedOut: auth.isLockedOut(userId),
|
|
234
|
-
};
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
name: 'chat_auth_authenticate',
|
|
239
|
-
description: 'Attempt to authenticate a user with a passphrase.',
|
|
240
|
-
auth: 'write',
|
|
241
|
-
schema: z.object({
|
|
242
|
-
userId: z.union([z.string(), z.number()]).describe('User ID.'),
|
|
243
|
-
passphrase: z.string().describe('Passphrase to verify.'),
|
|
244
|
-
storagePath: z.string().describe('Auth storage path.'),
|
|
245
|
-
}),
|
|
246
|
-
handler: async (params) => {
|
|
247
|
-
const auth = getOrCreateAuth(state, {
|
|
248
|
-
storagePath: params.storagePath,
|
|
249
|
-
});
|
|
250
|
-
const success = auth.authenticate(params.userId, params.passphrase);
|
|
251
|
-
return {
|
|
252
|
-
userId: params.userId,
|
|
253
|
-
success,
|
|
254
|
-
lockedOut: auth.isLockedOut(params.userId),
|
|
255
|
-
};
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
name: 'chat_auth_revoke',
|
|
260
|
-
description: 'Revoke authentication for a user.',
|
|
261
|
-
auth: 'write',
|
|
262
|
-
schema: z.object({
|
|
263
|
-
userId: z.union([z.string(), z.number()]).describe('User ID to revoke.'),
|
|
264
|
-
storagePath: z.string().describe('Auth storage path.'),
|
|
265
|
-
}),
|
|
266
|
-
handler: async (params) => {
|
|
267
|
-
const auth = getOrCreateAuth(state, {
|
|
268
|
-
storagePath: params.storagePath,
|
|
269
|
-
});
|
|
270
|
-
auth.revoke(params.userId);
|
|
271
|
-
return { revoked: true, userId: params.userId };
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
name: 'chat_auth_status',
|
|
276
|
-
description: 'Get authentication status — enabled, user count, list.',
|
|
277
|
-
auth: 'read',
|
|
278
|
-
schema: z.object({
|
|
279
|
-
storagePath: z.string().describe('Auth storage path.'),
|
|
280
|
-
}),
|
|
281
|
-
handler: async (params) => {
|
|
282
|
-
const auth = getOrCreateAuth(state, {
|
|
283
|
-
storagePath: params.storagePath,
|
|
284
|
-
});
|
|
285
|
-
return {
|
|
286
|
-
enabled: auth.enabled,
|
|
287
|
-
authenticatedCount: auth.authenticatedCount,
|
|
288
|
-
authenticatedUsers: auth.listAuthenticated(),
|
|
289
|
-
};
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
// ─── MCP Bridge Ops ─────────────────────────────────────────────
|
|
293
|
-
{
|
|
294
|
-
name: 'chat_bridge_init',
|
|
295
|
-
description: 'Initialize the MCP tool bridge for local tool execution. Optional allowlist filters which tools are registered.',
|
|
296
|
-
auth: 'write',
|
|
297
|
-
schema: z.object({
|
|
298
|
-
allowlist: z
|
|
299
|
-
.array(z.string())
|
|
300
|
-
.optional()
|
|
301
|
-
.describe('Tool name allowlist. If unset, all tools are allowed.'),
|
|
302
|
-
maxOutput: z
|
|
303
|
-
.number()
|
|
304
|
-
.optional()
|
|
305
|
-
.describe('Max output length per tool call. Default: 10000.'),
|
|
306
|
-
}),
|
|
307
|
-
handler: async (params) => {
|
|
308
|
-
state.bridge = new McpToolBridge({
|
|
309
|
-
allowlist: params.allowlist,
|
|
310
|
-
compressor: createOutputCompressor(),
|
|
311
|
-
maxOutput: params.maxOutput,
|
|
312
|
-
});
|
|
313
|
-
return { initialized: true, toolCount: 0 };
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
name: 'chat_bridge_register',
|
|
318
|
-
description: 'Register a tool with the MCP bridge.',
|
|
319
|
-
auth: 'write',
|
|
320
|
-
schema: z.object({
|
|
321
|
-
name: z.string().describe('Tool name.'),
|
|
322
|
-
description: z.string().describe('Tool description.'),
|
|
323
|
-
inputSchema: z.record(z.unknown()).describe('JSON Schema for tool input.'),
|
|
324
|
-
}),
|
|
325
|
-
handler: async (params) => {
|
|
326
|
-
if (!state.bridge) {
|
|
327
|
-
state.bridge = new McpToolBridge({ compressor: createOutputCompressor() });
|
|
328
|
-
}
|
|
329
|
-
// Handler is a no-op since we can't pass functions through JSON
|
|
330
|
-
// Real handler registration happens in code, not via ops
|
|
331
|
-
state.bridge.register({
|
|
332
|
-
name: params.name,
|
|
333
|
-
description: params.description,
|
|
334
|
-
inputSchema: params.inputSchema,
|
|
335
|
-
handler: async () => ({ message: 'Registered via op — handler is a placeholder' }),
|
|
336
|
-
});
|
|
337
|
-
return { registered: true, name: params.name, totalTools: state.bridge.size };
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
name: 'chat_bridge_list',
|
|
342
|
-
description: 'List all tools registered with the MCP bridge.',
|
|
343
|
-
auth: 'read',
|
|
344
|
-
handler: async () => {
|
|
345
|
-
if (!state.bridge)
|
|
346
|
-
return { tools: [], count: 0 };
|
|
347
|
-
const tools = state.bridge.listTools();
|
|
348
|
-
return { tools, count: tools.length };
|
|
349
|
-
},
|
|
350
|
-
},
|
|
351
|
-
{
|
|
352
|
-
name: 'chat_bridge_execute',
|
|
353
|
-
description: 'Execute a registered tool via the MCP bridge.',
|
|
354
|
-
auth: 'write',
|
|
355
|
-
schema: z.object({
|
|
356
|
-
name: z.string().describe('Tool name to execute.'),
|
|
357
|
-
input: z.record(z.unknown()).optional().describe('Tool input parameters.'),
|
|
358
|
-
}),
|
|
359
|
-
handler: async (params) => {
|
|
360
|
-
if (!state.bridge)
|
|
361
|
-
return { output: 'Bridge not initialized', isError: true };
|
|
362
|
-
const result = await state.bridge.execute(params.name, params.input ?? {});
|
|
363
|
-
return result;
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
name: 'chat_compress_output',
|
|
368
|
-
description: 'Compress verbose tool output for chat display. Uses JSON-aware truncation.',
|
|
369
|
-
auth: 'read',
|
|
370
|
-
schema: z.object({
|
|
371
|
-
toolName: z.string().describe('Tool name (for compressor lookup).'),
|
|
372
|
-
output: z.string().describe('Raw tool output to compress.'),
|
|
373
|
-
maxLength: z.number().optional().describe('Max output length. Default: 4000.'),
|
|
374
|
-
}),
|
|
375
|
-
handler: async (params) => {
|
|
376
|
-
const compressor = createOutputCompressor();
|
|
377
|
-
const compressed = compressor(params.toolName, params.output, params.maxLength);
|
|
378
|
-
return {
|
|
379
|
-
compressed,
|
|
380
|
-
originalLength: params.output.length,
|
|
381
|
-
compressedLength: compressed.length,
|
|
382
|
-
};
|
|
383
|
-
},
|
|
384
|
-
},
|
|
385
|
-
// ─── Task Cancellation Ops ─────────────────────────────────────
|
|
386
|
-
{
|
|
387
|
-
name: 'chat_cancel_create',
|
|
388
|
-
description: 'Create an AbortSignal for a chat task. If a task is already running for this chat, it is cancelled first. Returns signal status.',
|
|
389
|
-
auth: 'write',
|
|
390
|
-
schema: z.object({
|
|
391
|
-
chatId: z.string().describe('Chat/session ID.'),
|
|
392
|
-
description: z.string().optional().describe('Description of what is running.'),
|
|
393
|
-
}),
|
|
394
|
-
handler: async (params) => {
|
|
395
|
-
if (!state.cancellation) {
|
|
396
|
-
state.cancellation = new TaskCancellationManager();
|
|
397
|
-
}
|
|
398
|
-
const signal = state.cancellation.create(params.chatId, params.description);
|
|
399
|
-
return {
|
|
400
|
-
chatId: params.chatId,
|
|
401
|
-
created: true,
|
|
402
|
-
aborted: signal.aborted,
|
|
403
|
-
activeTasks: state.cancellation.size,
|
|
404
|
-
};
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
name: 'chat_cancel_stop',
|
|
409
|
-
description: 'Cancel the running task for a chat. Aborts the associated AbortController.',
|
|
410
|
-
auth: 'write',
|
|
411
|
-
schema: z.object({
|
|
412
|
-
chatId: z.string().describe('Chat/session ID to cancel.'),
|
|
413
|
-
}),
|
|
414
|
-
handler: async (params) => {
|
|
415
|
-
if (!state.cancellation) {
|
|
416
|
-
return { cancelled: false, reason: 'No cancellation manager initialized.' };
|
|
417
|
-
}
|
|
418
|
-
const info = state.cancellation.cancel(params.chatId);
|
|
419
|
-
if (!info) {
|
|
420
|
-
return { cancelled: false, reason: 'No running task for this chat.' };
|
|
421
|
-
}
|
|
422
|
-
return {
|
|
423
|
-
cancelled: true,
|
|
424
|
-
chatId: params.chatId,
|
|
425
|
-
description: info.description ?? null,
|
|
426
|
-
ranForMs: Date.now() - info.startedAt,
|
|
427
|
-
activeTasks: state.cancellation.size,
|
|
428
|
-
};
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
name: 'chat_cancel_status',
|
|
433
|
-
description: 'Get cancellation status — running tasks, per-chat info.',
|
|
434
|
-
auth: 'read',
|
|
435
|
-
schema: z.object({
|
|
436
|
-
chatId: z.string().optional().describe('Specific chat to check. Omit for all.'),
|
|
437
|
-
}),
|
|
438
|
-
handler: async (params) => {
|
|
439
|
-
if (!state.cancellation) {
|
|
440
|
-
return { activeTasks: 0, running: [] };
|
|
441
|
-
}
|
|
442
|
-
if (params.chatId) {
|
|
443
|
-
const info = state.cancellation.getInfo(params.chatId);
|
|
444
|
-
return {
|
|
445
|
-
chatId: params.chatId,
|
|
446
|
-
running: !!info,
|
|
447
|
-
description: info?.description ?? null,
|
|
448
|
-
startedAt: info?.startedAt ?? null,
|
|
449
|
-
ranForMs: info ? Date.now() - info.startedAt : null,
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
const running = state.cancellation.listRunning();
|
|
453
|
-
return {
|
|
454
|
-
activeTasks: state.cancellation.size,
|
|
455
|
-
running: running.map((id) => {
|
|
456
|
-
const info = state.cancellation.getInfo(id);
|
|
457
|
-
return {
|
|
458
|
-
chatId: id,
|
|
459
|
-
description: info?.description ?? null,
|
|
460
|
-
startedAt: info?.startedAt ?? null,
|
|
461
|
-
};
|
|
462
|
-
}),
|
|
463
|
-
};
|
|
464
|
-
},
|
|
465
|
-
},
|
|
466
|
-
// ─── Self-Update Ops ───────────────────────────────────────────
|
|
467
|
-
{
|
|
468
|
-
name: 'chat_update_init',
|
|
469
|
-
description: 'Initialize self-update manager. Provide path for restart context persistence.',
|
|
470
|
-
auth: 'write',
|
|
471
|
-
schema: z.object({
|
|
472
|
-
contextPath: z.string().describe('Path for restart context JSON file.'),
|
|
473
|
-
}),
|
|
474
|
-
handler: async (params) => {
|
|
475
|
-
state.updater = new SelfUpdateManager(params.contextPath);
|
|
476
|
-
const pending = state.updater.loadContext();
|
|
477
|
-
return {
|
|
478
|
-
initialized: true,
|
|
479
|
-
hasPendingRestart: !!pending,
|
|
480
|
-
pendingContext: pending,
|
|
481
|
-
};
|
|
482
|
-
},
|
|
483
|
-
},
|
|
484
|
-
{
|
|
485
|
-
name: 'chat_update_request',
|
|
486
|
-
description: 'Request a restart. Saves context for post-restart confirmation.',
|
|
487
|
-
auth: 'write',
|
|
488
|
-
schema: z.object({
|
|
489
|
-
chatId: z.string().describe('Chat ID for post-restart confirmation.'),
|
|
490
|
-
reason: z
|
|
491
|
-
.enum(['self-update', 'rebuild', 'manual'])
|
|
492
|
-
.optional()
|
|
493
|
-
.describe('Restart reason. Default: manual.'),
|
|
494
|
-
commitSha: z.string().optional().describe('Git commit SHA if self-update.'),
|
|
495
|
-
contextPath: z.string().describe('Path for restart context.'),
|
|
496
|
-
}),
|
|
497
|
-
handler: async (params) => {
|
|
498
|
-
if (!state.updater) {
|
|
499
|
-
state.updater = new SelfUpdateManager(params.contextPath);
|
|
500
|
-
}
|
|
501
|
-
return state.updater.requestRestart(params.chatId, params.reason ?? 'manual', params.commitSha);
|
|
502
|
-
},
|
|
503
|
-
},
|
|
504
|
-
{
|
|
505
|
-
name: 'chat_update_confirm',
|
|
506
|
-
description: 'Clear restart context after successful startup.',
|
|
507
|
-
auth: 'write',
|
|
508
|
-
schema: z.object({
|
|
509
|
-
contextPath: z.string().describe('Path for restart context.'),
|
|
510
|
-
}),
|
|
511
|
-
handler: async (params) => {
|
|
512
|
-
if (!state.updater) {
|
|
513
|
-
state.updater = new SelfUpdateManager(params.contextPath);
|
|
514
|
-
}
|
|
515
|
-
const context = state.updater.loadContext();
|
|
516
|
-
state.updater.clearContext();
|
|
517
|
-
return { confirmed: true, previousContext: context };
|
|
518
|
-
},
|
|
519
|
-
},
|
|
520
|
-
// ─── File Handling Ops ─────────────────────────────────────────
|
|
521
|
-
{
|
|
522
|
-
name: 'chat_file_detect_intent',
|
|
523
|
-
description: 'Detect user intent for a file — vision, text, or intake.',
|
|
524
|
-
auth: 'read',
|
|
525
|
-
schema: z.object({
|
|
526
|
-
filename: z.string().describe('Original filename.'),
|
|
527
|
-
mimeType: z.string().describe('MIME type.'),
|
|
528
|
-
userText: z.string().optional().describe('Accompanying user message text.'),
|
|
529
|
-
}),
|
|
530
|
-
handler: async (params) => {
|
|
531
|
-
const intent = detectFileIntent(params.filename, params.mimeType, params.userText);
|
|
532
|
-
return { filename: params.filename, mimeType: params.mimeType, intent };
|
|
533
|
-
},
|
|
534
|
-
},
|
|
535
|
-
{
|
|
536
|
-
name: 'chat_file_build_content',
|
|
537
|
-
description: 'Build multimodal content from a file for the Anthropic API.',
|
|
538
|
-
auth: 'read',
|
|
539
|
-
schema: z.object({
|
|
540
|
-
filename: z.string().describe('Original filename.'),
|
|
541
|
-
mimeType: z.string().describe('MIME type.'),
|
|
542
|
-
dataBase64: z.string().describe('File content as base64.'),
|
|
543
|
-
intent: z.enum(['vision', 'text', 'intake']).describe('Detected intent.'),
|
|
544
|
-
}),
|
|
545
|
-
handler: async (params) => {
|
|
546
|
-
const file = {
|
|
547
|
-
name: params.filename,
|
|
548
|
-
mimeType: params.mimeType,
|
|
549
|
-
size: Buffer.byteLength(params.dataBase64, 'base64'),
|
|
550
|
-
data: Buffer.from(params.dataBase64, 'base64'),
|
|
551
|
-
};
|
|
552
|
-
return buildMultimodalContent(file, params.intent);
|
|
553
|
-
},
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
name: 'chat_file_cleanup',
|
|
557
|
-
description: 'Clean up temp files older than maxAgeMs.',
|
|
558
|
-
auth: 'write',
|
|
559
|
-
schema: z.object({
|
|
560
|
-
uploadDir: z.string().describe('Temp upload directory.'),
|
|
561
|
-
maxAgeMs: z.number().optional().describe('Max age in ms. Default: 1 hour.'),
|
|
562
|
-
}),
|
|
563
|
-
handler: async (params) => {
|
|
564
|
-
const removed = cleanupTempFiles(params.uploadDir, params.maxAgeMs);
|
|
565
|
-
return { removed, uploadDir: params.uploadDir };
|
|
566
|
-
},
|
|
567
|
-
},
|
|
568
|
-
// ─── Notification Ops ──────────────────────────────────────────
|
|
569
|
-
{
|
|
570
|
-
name: 'chat_notify_init',
|
|
571
|
-
description: 'Initialize the notification engine. Notifications are delivered via the provided callback pattern.',
|
|
572
|
-
auth: 'write',
|
|
573
|
-
schema: z.object({
|
|
574
|
-
intervalMs: z.number().optional().describe('Polling interval in ms. Default: 30 minutes.'),
|
|
575
|
-
defaultCooldownMs: z
|
|
576
|
-
.number()
|
|
577
|
-
.optional()
|
|
578
|
-
.describe('Default cooldown between notifications. Default: 4 hours.'),
|
|
579
|
-
}),
|
|
580
|
-
handler: async (params) => {
|
|
581
|
-
// The onNotify callback can't be passed via JSON — it's set up in code.
|
|
582
|
-
// This op initializes with a no-op that logs to console.
|
|
583
|
-
state.notifications = new NotificationEngine({
|
|
584
|
-
intervalMs: params.intervalMs,
|
|
585
|
-
defaultCooldownMs: params.defaultCooldownMs,
|
|
586
|
-
onNotify: async (checkId, message) => {
|
|
587
|
-
console.log(`[notification] ${checkId}: ${message}`);
|
|
588
|
-
},
|
|
589
|
-
});
|
|
590
|
-
return { initialized: true };
|
|
591
|
-
},
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
name: 'chat_notify_start',
|
|
595
|
-
description: 'Start the notification polling loop.',
|
|
596
|
-
auth: 'write',
|
|
597
|
-
handler: async () => {
|
|
598
|
-
if (!state.notifications) {
|
|
599
|
-
return { started: false, reason: 'Notification engine not initialized.' };
|
|
600
|
-
}
|
|
601
|
-
state.notifications.start();
|
|
602
|
-
return { started: true, ...state.notifications.stats() };
|
|
603
|
-
},
|
|
604
|
-
},
|
|
605
|
-
{
|
|
606
|
-
name: 'chat_notify_stop',
|
|
607
|
-
description: 'Stop the notification polling loop.',
|
|
608
|
-
auth: 'write',
|
|
609
|
-
handler: async () => {
|
|
610
|
-
if (!state.notifications) {
|
|
611
|
-
return { stopped: false, reason: 'Notification engine not initialized.' };
|
|
612
|
-
}
|
|
613
|
-
state.notifications.stop();
|
|
614
|
-
return { stopped: true, ...state.notifications.stats() };
|
|
615
|
-
},
|
|
616
|
-
},
|
|
617
|
-
{
|
|
618
|
-
name: 'chat_notify_poll',
|
|
619
|
-
description: 'Run all notification checks once (manual trigger).',
|
|
620
|
-
auth: 'write',
|
|
621
|
-
handler: async () => {
|
|
622
|
-
if (!state.notifications) {
|
|
623
|
-
return { polled: false, reason: 'Notification engine not initialized.' };
|
|
624
|
-
}
|
|
625
|
-
const notified = await state.notifications.poll();
|
|
626
|
-
return { polled: true, notified, ...state.notifications.stats() };
|
|
627
|
-
},
|
|
628
|
-
},
|
|
629
|
-
{
|
|
630
|
-
name: 'chat_notify_status',
|
|
631
|
-
description: 'Get notification engine status.',
|
|
632
|
-
auth: 'read',
|
|
633
|
-
handler: async () => {
|
|
634
|
-
if (!state.notifications) {
|
|
635
|
-
return { initialized: false, checks: 0, running: false, sent: 0, lastPollAt: null };
|
|
636
|
-
}
|
|
637
|
-
return { initialized: true, ...state.notifications.stats() };
|
|
638
|
-
},
|
|
639
|
-
},
|
|
640
|
-
// ─── Voice Ops ─────────────────────────────────────────────────
|
|
641
|
-
{
|
|
642
|
-
name: 'chat_voice_transcribe',
|
|
643
|
-
description: 'Transcribe audio using OpenAI Whisper. Provide base64-encoded audio.',
|
|
644
|
-
auth: 'write',
|
|
645
|
-
schema: z.object({
|
|
646
|
-
audioBase64: z.string().describe('Base64-encoded audio data.'),
|
|
647
|
-
openaiApiKey: z.string().describe('OpenAI API key.'),
|
|
648
|
-
filename: z.string().optional().describe('Audio filename. Default: audio.ogg.'),
|
|
649
|
-
}),
|
|
650
|
-
handler: async (params) => {
|
|
651
|
-
const buffer = Buffer.from(params.audioBase64, 'base64');
|
|
652
|
-
return transcribeAudio(buffer, {
|
|
653
|
-
openaiApiKey: params.openaiApiKey,
|
|
654
|
-
}, params.filename);
|
|
655
|
-
},
|
|
656
|
-
},
|
|
657
|
-
{
|
|
658
|
-
name: 'chat_voice_synthesize',
|
|
659
|
-
description: 'Synthesize speech from text using OpenAI TTS. Returns base64 MP3.',
|
|
660
|
-
auth: 'write',
|
|
661
|
-
schema: z.object({
|
|
662
|
-
text: z.string().describe('Text to synthesize.'),
|
|
663
|
-
openaiApiKey: z.string().describe('OpenAI API key.'),
|
|
664
|
-
voice: z.string().optional().describe('Voice ID. Default: onyx.'),
|
|
665
|
-
}),
|
|
666
|
-
handler: async (params) => {
|
|
667
|
-
const result = await synthesizeSpeech(params.text, {
|
|
668
|
-
openaiApiKey: params.openaiApiKey,
|
|
669
|
-
ttsVoice: params.voice,
|
|
670
|
-
});
|
|
671
|
-
if (!result)
|
|
672
|
-
return { success: false, reason: 'No API key.' };
|
|
673
|
-
return {
|
|
674
|
-
success: result.success,
|
|
675
|
-
audioBase64: result.audio.toString('base64'),
|
|
676
|
-
audioSize: result.audio.length,
|
|
677
|
-
};
|
|
678
|
-
},
|
|
679
|
-
},
|
|
680
|
-
// ─── Queue Ops ─────────────────────────────────────────────────
|
|
681
|
-
{
|
|
682
|
-
name: 'chat_queue_init',
|
|
683
|
-
description: 'Initialize the message queue for disk-based chat relay.',
|
|
684
|
-
auth: 'write',
|
|
685
|
-
schema: z.object({
|
|
686
|
-
queueDir: z.string().describe('Base directory for inbox/outbox.'),
|
|
687
|
-
}),
|
|
688
|
-
handler: async (params) => {
|
|
689
|
-
state.queue = new MessageQueue({ queueDir: params.queueDir });
|
|
690
|
-
return {
|
|
691
|
-
initialized: true,
|
|
692
|
-
inbox: state.queue.inboxCount(),
|
|
693
|
-
outbox: state.queue.outboxCount(),
|
|
694
|
-
};
|
|
695
|
-
},
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
name: 'chat_queue_inbox',
|
|
699
|
-
description: 'Read pending messages from the queue inbox.',
|
|
700
|
-
auth: 'read',
|
|
701
|
-
schema: z.object({
|
|
702
|
-
queueDir: z.string().describe('Queue directory (auto-initializes).'),
|
|
703
|
-
}),
|
|
704
|
-
handler: async (params) => {
|
|
705
|
-
if (!state.queue) {
|
|
706
|
-
state.queue = new MessageQueue({ queueDir: params.queueDir });
|
|
707
|
-
}
|
|
708
|
-
const messages = state.queue.readInbox();
|
|
709
|
-
return { messages, count: messages.length, formatted: state.queue.formatInbox() };
|
|
710
|
-
},
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
name: 'chat_queue_reply',
|
|
714
|
-
description: 'Send a reply to a queued message. Removes from inbox, writes to outbox.',
|
|
715
|
-
auth: 'write',
|
|
716
|
-
schema: z.object({
|
|
717
|
-
messageId: z.string().describe('Original message ID.'),
|
|
718
|
-
chatId: z.string().describe('Target chat ID.'),
|
|
719
|
-
text: z.string().describe('Response text.'),
|
|
720
|
-
queueDir: z.string().describe('Queue directory.'),
|
|
721
|
-
}),
|
|
722
|
-
handler: async (params) => {
|
|
723
|
-
if (!state.queue) {
|
|
724
|
-
state.queue = new MessageQueue({ queueDir: params.queueDir });
|
|
725
|
-
}
|
|
726
|
-
const response = state.queue.sendResponse(params.messageId, params.chatId, params.text);
|
|
727
|
-
return { sent: true, response };
|
|
728
|
-
},
|
|
729
|
-
},
|
|
730
|
-
{
|
|
731
|
-
name: 'chat_queue_drain',
|
|
732
|
-
description: 'Drain outbox — read and remove all pending responses.',
|
|
733
|
-
auth: 'write',
|
|
734
|
-
schema: z.object({
|
|
735
|
-
queueDir: z.string().describe('Queue directory.'),
|
|
736
|
-
}),
|
|
737
|
-
handler: async (params) => {
|
|
738
|
-
if (!state.queue) {
|
|
739
|
-
state.queue = new MessageQueue({ queueDir: params.queueDir });
|
|
740
|
-
}
|
|
741
|
-
const responses = state.queue.drainOutbox();
|
|
742
|
-
return { responses, count: responses.length };
|
|
743
|
-
},
|
|
744
|
-
},
|
|
745
|
-
// ─── Browser Session Ops ───────────────────────────────────────
|
|
746
|
-
{
|
|
747
|
-
name: 'chat_browser_init',
|
|
748
|
-
description: 'Initialize the browser session manager for per-chat Playwright isolation.',
|
|
749
|
-
auth: 'write',
|
|
750
|
-
schema: z.object({
|
|
751
|
-
maxSessions: z.number().optional().describe('Max concurrent sessions. Default: 3.'),
|
|
752
|
-
idleTimeoutMs: z.number().optional().describe('Idle timeout in ms. Default: 5 minutes.'),
|
|
753
|
-
}),
|
|
754
|
-
handler: async (params) => {
|
|
755
|
-
state.browser = new BrowserSessionManager({
|
|
756
|
-
maxSessions: params.maxSessions,
|
|
757
|
-
idleTimeoutMs: params.idleTimeoutMs,
|
|
758
|
-
});
|
|
759
|
-
return { initialized: true, maxSessions: params.maxSessions ?? 3 };
|
|
760
|
-
},
|
|
761
|
-
},
|
|
762
|
-
{
|
|
763
|
-
name: 'chat_browser_acquire',
|
|
764
|
-
description: 'Get or create a browser session for a chat. Spawns Playwright if needed.',
|
|
765
|
-
auth: 'write',
|
|
766
|
-
schema: z.object({
|
|
767
|
-
chatId: z.string().describe('Chat ID for isolation.'),
|
|
768
|
-
}),
|
|
769
|
-
handler: async (params) => {
|
|
770
|
-
if (!state.browser) {
|
|
771
|
-
state.browser = new BrowserSessionManager();
|
|
772
|
-
}
|
|
773
|
-
const session = state.browser.acquire(params.chatId);
|
|
774
|
-
return {
|
|
775
|
-
chatId: params.chatId,
|
|
776
|
-
pid: session.process.pid ?? null,
|
|
777
|
-
activeSessions: state.browser.size,
|
|
778
|
-
};
|
|
779
|
-
},
|
|
780
|
-
},
|
|
781
|
-
{
|
|
782
|
-
name: 'chat_browser_release',
|
|
783
|
-
description: 'Release a browser session for a chat.',
|
|
784
|
-
auth: 'write',
|
|
785
|
-
schema: z.object({
|
|
786
|
-
chatId: z.string().describe('Chat ID to release.'),
|
|
787
|
-
}),
|
|
788
|
-
handler: async (params) => {
|
|
789
|
-
if (!state.browser)
|
|
790
|
-
return { released: false, reason: 'No browser manager.' };
|
|
791
|
-
const released = state.browser.release(params.chatId);
|
|
792
|
-
return { released, activeSessions: state.browser.size };
|
|
793
|
-
},
|
|
794
|
-
},
|
|
795
|
-
{
|
|
796
|
-
name: 'chat_browser_status',
|
|
797
|
-
description: 'Get browser session status — active sessions, per-chat info.',
|
|
798
|
-
auth: 'read',
|
|
799
|
-
handler: async () => {
|
|
800
|
-
if (!state.browser)
|
|
801
|
-
return { initialized: false, activeSessions: 0, sessions: [] };
|
|
802
|
-
const sessions = state.browser.listSessions().map((id) => (Object.assign({ chatId: id }, state.browser.getInfo(id))));
|
|
803
|
-
return { initialized: true, activeSessions: state.browser.size, sessions };
|
|
804
|
-
},
|
|
805
|
-
},
|
|
18
|
+
...createChatSessionOps(state),
|
|
19
|
+
...createChatTransportOps(state),
|
|
20
|
+
...createChatServiceOps(state),
|
|
806
21
|
];
|
|
807
22
|
}
|
|
808
23
|
//# sourceMappingURL=chat-facade.js.map
|