@dcyfr/ai 1.0.3 → 2.1.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/CHANGELOG.md +106 -0
- package/LICENSE +27 -1
- package/README.md +720 -9
- package/dist/ai/agents/agent-loader.d.ts +12 -0
- package/dist/ai/agents/agent-loader.d.ts.map +1 -1
- package/dist/ai/agents/agent-loader.js +74 -65
- package/dist/ai/agents/agent-loader.js.map +1 -1
- package/dist/ai/agents/agent-registry.d.ts +2 -0
- package/dist/ai/agents/agent-registry.d.ts.map +1 -1
- package/dist/ai/agents/agent-registry.js +15 -14
- package/dist/ai/agents/agent-registry.js.map +1 -1
- package/dist/ai/agents/agent-router.d.ts +20 -5
- package/dist/ai/agents/agent-router.d.ts.map +1 -1
- package/dist/ai/agents/agent-router.js +89 -43
- package/dist/ai/agents/agent-router.js.map +1 -1
- package/dist/ai/agents/index.d.ts +6 -1
- package/dist/ai/agents/index.d.ts.map +1 -1
- package/dist/ai/agents/index.js +9 -3
- package/dist/ai/agents/index.js.map +1 -1
- package/dist/ai/agents/instruction-template.d.ts +45 -0
- package/dist/ai/agents/instruction-template.d.ts.map +1 -0
- package/dist/ai/agents/instruction-template.js +197 -0
- package/dist/ai/agents/instruction-template.js.map +1 -0
- package/dist/ai/agents/persona-resolver.d.ts +90 -0
- package/dist/ai/agents/persona-resolver.d.ts.map +1 -0
- package/dist/ai/agents/persona-resolver.js +121 -0
- package/dist/ai/agents/persona-resolver.js.map +1 -0
- package/dist/ai/agents/schema.d.ts +166 -0
- package/dist/ai/agents/schema.d.ts.map +1 -0
- package/dist/ai/agents/schema.js +94 -0
- package/dist/ai/agents/schema.js.map +1 -0
- package/dist/ai/agents/types.d.ts +102 -0
- package/dist/ai/agents/types.d.ts.map +1 -1
- package/dist/ai/agents-builtin/architecture/index.js +3 -3
- package/dist/ai/agents-builtin/content/index.js +1 -1
- package/dist/ai/agents-builtin/data/index.js +1 -1
- package/dist/ai/agents-builtin/development/index.js +4 -4
- package/dist/ai/agents-builtin/devops/index.js +1 -1
- package/dist/ai/agents-builtin/index.js +33 -33
- package/dist/ai/agents-builtin/performance/index.js +1 -1
- package/dist/ai/agents-builtin/research/index.js +1 -1
- package/dist/ai/agents-builtin/security/index.js +1 -1
- package/dist/ai/agents-builtin/testing/index.js +2 -2
- package/dist/ai/config/loader.d.ts.map +1 -1
- package/dist/ai/config/loader.js +6 -3
- package/dist/ai/config/loader.js.map +1 -1
- package/dist/ai/config/schema.d.ts +242 -1156
- package/dist/ai/config/schema.d.ts.map +1 -1
- package/dist/ai/config/schema.js +69 -20
- package/dist/ai/config/schema.js.map +1 -1
- package/dist/ai/core/provider-registry.d.ts +32 -0
- package/dist/ai/core/provider-registry.d.ts.map +1 -1
- package/dist/ai/core/provider-registry.js +189 -14
- package/dist/ai/core/provider-registry.js.map +1 -1
- package/dist/ai/core/telemetry-engine.d.ts +26 -0
- package/dist/ai/core/telemetry-engine.d.ts.map +1 -1
- package/dist/ai/core/telemetry-engine.js +81 -1
- package/dist/ai/core/telemetry-engine.js.map +1 -1
- package/dist/ai/delegation/agent-registry.d.ts +143 -0
- package/dist/ai/delegation/agent-registry.d.ts.map +1 -0
- package/dist/ai/delegation/agent-registry.js +231 -0
- package/dist/ai/delegation/agent-registry.js.map +1 -0
- package/dist/ai/delegation/blast-radius-tracker.d.ts +65 -0
- package/dist/ai/delegation/blast-radius-tracker.d.ts.map +1 -0
- package/dist/ai/delegation/blast-radius-tracker.js +81 -0
- package/dist/ai/delegation/blast-radius-tracker.js.map +1 -0
- package/dist/ai/delegation/capability-bootstrap.d.ts +40 -0
- package/dist/ai/delegation/capability-bootstrap.d.ts.map +1 -0
- package/dist/ai/delegation/capability-bootstrap.js +431 -0
- package/dist/ai/delegation/capability-bootstrap.js.map +1 -0
- package/dist/ai/delegation/capability-registry.d.ts +81 -0
- package/dist/ai/delegation/capability-registry.d.ts.map +1 -0
- package/dist/ai/delegation/capability-registry.js +339 -0
- package/dist/ai/delegation/capability-registry.js.map +1 -0
- package/dist/ai/delegation/chain-tracker.d.ts +152 -0
- package/dist/ai/delegation/chain-tracker.d.ts.map +1 -0
- package/dist/ai/delegation/chain-tracker.js +336 -0
- package/dist/ai/delegation/chain-tracker.js.map +1 -0
- package/dist/ai/delegation/circuit-breaker.d.ts +59 -0
- package/dist/ai/delegation/circuit-breaker.d.ts.map +1 -0
- package/dist/ai/delegation/circuit-breaker.js +153 -0
- package/dist/ai/delegation/circuit-breaker.js.map +1 -0
- package/dist/ai/delegation/contract-manager.d.ts +415 -0
- package/dist/ai/delegation/contract-manager.d.ts.map +1 -0
- package/dist/ai/delegation/contract-manager.js +1258 -0
- package/dist/ai/delegation/contract-manager.js.map +1 -0
- package/dist/ai/delegation/delegation-manager.d.ts +505 -0
- package/dist/ai/delegation/delegation-manager.d.ts.map +1 -0
- package/dist/ai/delegation/delegation-manager.js +773 -0
- package/dist/ai/delegation/delegation-manager.js.map +1 -0
- package/dist/ai/delegation/event-schemas.d.ts +101 -0
- package/dist/ai/delegation/event-schemas.d.ts.map +1 -0
- package/dist/ai/delegation/event-schemas.js +59 -0
- package/dist/ai/delegation/event-schemas.js.map +1 -0
- package/dist/ai/delegation/execution-mode-dashboard.d.ts +109 -0
- package/dist/ai/delegation/execution-mode-dashboard.d.ts.map +1 -0
- package/dist/ai/delegation/execution-mode-dashboard.js +167 -0
- package/dist/ai/delegation/execution-mode-dashboard.js.map +1 -0
- package/dist/ai/delegation/feature-flags.d.ts +191 -0
- package/dist/ai/delegation/feature-flags.d.ts.map +1 -0
- package/dist/ai/delegation/feature-flags.js +332 -0
- package/dist/ai/delegation/feature-flags.js.map +1 -0
- package/dist/ai/delegation/index.d.ts +51 -0
- package/dist/ai/delegation/index.d.ts.map +1 -0
- package/dist/ai/delegation/index.js +39 -0
- package/dist/ai/delegation/index.js.map +1 -0
- package/dist/ai/delegation/middleware/chain-depth-middleware.d.ts +39 -0
- package/dist/ai/delegation/middleware/chain-depth-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/chain-depth-middleware.js +77 -0
- package/dist/ai/delegation/middleware/chain-depth-middleware.js.map +1 -0
- package/dist/ai/delegation/middleware/chain-tracker-middleware.d.ts +46 -0
- package/dist/ai/delegation/middleware/chain-tracker-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/chain-tracker-middleware.js +89 -0
- package/dist/ai/delegation/middleware/chain-tracker-middleware.js.map +1 -0
- package/dist/ai/delegation/middleware/content-policy-middleware.d.ts +31 -0
- package/dist/ai/delegation/middleware/content-policy-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/content-policy-middleware.js +82 -0
- package/dist/ai/delegation/middleware/content-policy-middleware.js.map +1 -0
- package/dist/ai/delegation/middleware/feature-flag-middleware.d.ts +46 -0
- package/dist/ai/delegation/middleware/feature-flag-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/feature-flag-middleware.js +59 -0
- package/dist/ai/delegation/middleware/feature-flag-middleware.js.map +1 -0
- package/dist/ai/delegation/middleware/identity-middleware.d.ts +23 -0
- package/dist/ai/delegation/middleware/identity-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/identity-middleware.js +64 -0
- package/dist/ai/delegation/middleware/identity-middleware.js.map +1 -0
- package/dist/ai/delegation/middleware/permissions-middleware.d.ts +48 -0
- package/dist/ai/delegation/middleware/permissions-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/permissions-middleware.js +107 -0
- package/dist/ai/delegation/middleware/permissions-middleware.js.map +1 -0
- package/dist/ai/delegation/middleware/rate-limiter-middleware.d.ts +38 -0
- package/dist/ai/delegation/middleware/rate-limiter-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/rate-limiter-middleware.js +65 -0
- package/dist/ai/delegation/middleware/rate-limiter-middleware.js.map +1 -0
- package/dist/ai/delegation/middleware/reputation-middleware.d.ts +39 -0
- package/dist/ai/delegation/middleware/reputation-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/reputation-middleware.js +75 -0
- package/dist/ai/delegation/middleware/reputation-middleware.js.map +1 -0
- package/dist/ai/delegation/middleware/resource-limiter-middleware.d.ts +52 -0
- package/dist/ai/delegation/middleware/resource-limiter-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/resource-limiter-middleware.js +112 -0
- package/dist/ai/delegation/middleware/resource-limiter-middleware.js.map +1 -0
- package/dist/ai/delegation/middleware/threat-validator-middleware.d.ts +23 -0
- package/dist/ai/delegation/middleware/threat-validator-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/threat-validator-middleware.js +83 -0
- package/dist/ai/delegation/middleware/threat-validator-middleware.js.map +1 -0
- package/dist/ai/delegation/middleware/tlp-middleware.d.ts +23 -0
- package/dist/ai/delegation/middleware/tlp-middleware.d.ts.map +1 -0
- package/dist/ai/delegation/middleware/tlp-middleware.js +59 -0
- package/dist/ai/delegation/middleware/tlp-middleware.js.map +1 -0
- package/dist/ai/delegation/monitoring.d.ts +298 -0
- package/dist/ai/delegation/monitoring.d.ts.map +1 -0
- package/dist/ai/delegation/monitoring.js +584 -0
- package/dist/ai/delegation/monitoring.js.map +1 -0
- package/dist/ai/delegation/security-middleware-chain.d.ts +71 -0
- package/dist/ai/delegation/security-middleware-chain.d.ts.map +1 -0
- package/dist/ai/delegation/security-middleware-chain.js +163 -0
- package/dist/ai/delegation/security-middleware-chain.js.map +1 -0
- package/dist/ai/delegation/session-checkpoint.d.ts +77 -0
- package/dist/ai/delegation/session-checkpoint.d.ts.map +1 -0
- package/dist/ai/delegation/session-checkpoint.js +131 -0
- package/dist/ai/delegation/session-checkpoint.js.map +1 -0
- package/dist/ai/delegation/session-manager.d.ts +131 -0
- package/dist/ai/delegation/session-manager.d.ts.map +1 -0
- package/dist/ai/delegation/session-manager.js +243 -0
- package/dist/ai/delegation/session-manager.js.map +1 -0
- package/dist/ai/delegation/session-queue.d.ts +95 -0
- package/dist/ai/delegation/session-queue.d.ts.map +1 -0
- package/dist/ai/delegation/session-queue.js +136 -0
- package/dist/ai/delegation/session-queue.js.map +1 -0
- package/dist/ai/delegation/timeout-watchdog.d.ts +60 -0
- package/dist/ai/delegation/timeout-watchdog.d.ts.map +1 -0
- package/dist/ai/delegation/timeout-watchdog.js +100 -0
- package/dist/ai/delegation/timeout-watchdog.js.map +1 -0
- package/dist/ai/examples/integration-demo.d.ts +27 -0
- package/dist/ai/examples/integration-demo.d.ts.map +1 -0
- package/dist/ai/examples/integration-demo.js +536 -0
- package/dist/ai/examples/integration-demo.js.map +1 -0
- package/dist/ai/index.d.ts +27 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +32 -10
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/mcp/index.d.ts +14 -2
- package/dist/ai/mcp/index.d.ts.map +1 -1
- package/dist/ai/mcp/index.js +11 -1
- package/dist/ai/mcp/index.js.map +1 -1
- package/dist/ai/mcp/servers/analytics/index.d.ts +19 -0
- package/dist/ai/mcp/servers/analytics/index.d.ts.map +1 -0
- package/dist/ai/mcp/servers/analytics/index.js +612 -0
- package/dist/ai/mcp/servers/analytics/index.js.map +1 -0
- package/dist/ai/mcp/servers/content-manager/content-provider.d.ts +61 -0
- package/dist/ai/mcp/servers/content-manager/content-provider.d.ts.map +1 -0
- package/dist/ai/mcp/servers/content-manager/content-provider.js +8 -0
- package/dist/ai/mcp/servers/content-manager/content-provider.js.map +1 -0
- package/dist/ai/mcp/servers/content-manager/index.d.ts +19 -0
- package/dist/ai/mcp/servers/content-manager/index.d.ts.map +1 -0
- package/dist/ai/mcp/servers/content-manager/index.js +282 -0
- package/dist/ai/mcp/servers/content-manager/index.js.map +1 -0
- package/dist/ai/mcp/servers/delegation-monitor/index.d.ts +36 -0
- package/dist/ai/mcp/servers/delegation-monitor/index.d.ts.map +1 -0
- package/dist/ai/mcp/servers/delegation-monitor/index.js +757 -0
- package/dist/ai/mcp/servers/delegation-monitor/index.js.map +1 -0
- package/dist/ai/mcp/servers/design-tokens/index.d.ts +19 -0
- package/dist/ai/mcp/servers/design-tokens/index.d.ts.map +1 -0
- package/dist/ai/mcp/servers/design-tokens/index.js +445 -0
- package/dist/ai/mcp/servers/design-tokens/index.js.map +1 -0
- package/dist/ai/mcp/servers/design-tokens/token-provider.d.ts +59 -0
- package/dist/ai/mcp/servers/design-tokens/token-provider.d.ts.map +1 -0
- package/dist/ai/mcp/servers/design-tokens/token-provider.js +8 -0
- package/dist/ai/mcp/servers/design-tokens/token-provider.js.map +1 -0
- package/dist/ai/mcp/servers/promptintel/index.d.ts +19 -0
- package/dist/ai/mcp/servers/promptintel/index.d.ts.map +1 -0
- package/dist/ai/mcp/servers/promptintel/index.js +335 -0
- package/dist/ai/mcp/servers/promptintel/index.js.map +1 -0
- package/dist/ai/mcp/servers/shared/cache.d.ts +62 -0
- package/dist/ai/mcp/servers/shared/cache.d.ts.map +1 -0
- package/dist/ai/mcp/servers/shared/cache.js +117 -0
- package/dist/ai/mcp/servers/shared/cache.js.map +1 -0
- package/dist/ai/mcp/servers/shared/promptintel-client.d.ts +53 -0
- package/dist/ai/mcp/servers/shared/promptintel-client.d.ts.map +1 -0
- package/dist/ai/mcp/servers/shared/promptintel-client.js +185 -0
- package/dist/ai/mcp/servers/shared/promptintel-client.js.map +1 -0
- package/dist/ai/mcp/servers/shared/promptintel-types.d.ts +85 -0
- package/dist/ai/mcp/servers/shared/promptintel-types.d.ts.map +1 -0
- package/dist/ai/mcp/servers/shared/promptintel-types.js +7 -0
- package/dist/ai/mcp/servers/shared/promptintel-types.js.map +1 -0
- package/dist/ai/mcp/servers/shared/rate-limiter.d.ts +54 -0
- package/dist/ai/mcp/servers/shared/rate-limiter.d.ts.map +1 -0
- package/dist/ai/mcp/servers/shared/rate-limiter.js +124 -0
- package/dist/ai/mcp/servers/shared/rate-limiter.js.map +1 -0
- package/dist/ai/mcp/servers/shared/redis-client.d.ts +54 -0
- package/dist/ai/mcp/servers/shared/redis-client.d.ts.map +1 -0
- package/dist/ai/mcp/servers/shared/redis-client.js +232 -0
- package/dist/ai/mcp/servers/shared/redis-client.js.map +1 -0
- package/dist/ai/mcp/servers/shared/types.d.ts +301 -0
- package/dist/ai/mcp/servers/shared/types.d.ts.map +1 -0
- package/dist/ai/mcp/servers/shared/types.js +6 -0
- package/dist/ai/mcp/servers/shared/types.js.map +1 -0
- package/dist/ai/mcp/servers/shared/utils.d.ts +49 -0
- package/dist/ai/mcp/servers/shared/utils.d.ts.map +1 -0
- package/dist/ai/mcp/servers/shared/utils.js +233 -0
- package/dist/ai/mcp/servers/shared/utils.js.map +1 -0
- package/dist/ai/memory/config.d.ts +102 -0
- package/dist/ai/memory/config.d.ts.map +1 -0
- package/dist/ai/memory/config.js +200 -0
- package/dist/ai/memory/config.js.map +1 -0
- package/dist/ai/memory/dcyfr-memory.d.ts +67 -0
- package/dist/ai/memory/dcyfr-memory.d.ts.map +1 -0
- package/dist/ai/memory/dcyfr-memory.js +308 -0
- package/dist/ai/memory/dcyfr-memory.js.map +1 -0
- package/dist/ai/memory/index.d.ts +15 -0
- package/dist/ai/memory/index.d.ts.map +1 -0
- package/dist/ai/memory/index.js +15 -0
- package/dist/ai/memory/index.js.map +1 -0
- package/dist/ai/memory/mem0-client.d.ts +108 -0
- package/dist/ai/memory/mem0-client.d.ts.map +1 -0
- package/dist/ai/memory/mem0-client.js +205 -0
- package/dist/ai/memory/mem0-client.js.map +1 -0
- package/dist/ai/memory/types.d.ts +175 -0
- package/dist/ai/memory/types.d.ts.map +1 -0
- package/dist/ai/memory/types.js +10 -0
- package/dist/ai/memory/types.js.map +1 -0
- package/dist/ai/permissions/attenuation-engine.d.ts +159 -0
- package/dist/ai/permissions/attenuation-engine.d.ts.map +1 -0
- package/dist/ai/permissions/attenuation-engine.js +511 -0
- package/dist/ai/permissions/attenuation-engine.js.map +1 -0
- package/dist/ai/plugins/plugin-loader.d.ts +4 -0
- package/dist/ai/plugins/plugin-loader.d.ts.map +1 -1
- package/dist/ai/plugins/plugin-loader.js +28 -28
- package/dist/ai/plugins/plugin-loader.js.map +1 -1
- package/dist/ai/reputation/execution-mode-reputation.d.ts +104 -0
- package/dist/ai/reputation/execution-mode-reputation.d.ts.map +1 -0
- package/dist/ai/reputation/execution-mode-reputation.js +142 -0
- package/dist/ai/reputation/execution-mode-reputation.js.map +1 -0
- package/dist/ai/reputation/reputation-engine.d.ts +204 -0
- package/dist/ai/reputation/reputation-engine.d.ts.map +1 -0
- package/dist/ai/reputation/reputation-engine.js +426 -0
- package/dist/ai/reputation/reputation-engine.js.map +1 -0
- package/dist/ai/runtime/agent-runtime.d.ts +193 -0
- package/dist/ai/runtime/agent-runtime.d.ts.map +1 -0
- package/dist/ai/runtime/agent-runtime.js +1009 -0
- package/dist/ai/runtime/agent-runtime.js.map +1 -0
- package/dist/ai/runtime/index.d.ts +11 -0
- package/dist/ai/runtime/index.d.ts.map +1 -0
- package/dist/ai/runtime/index.js +9 -0
- package/dist/ai/runtime/index.js.map +1 -0
- package/dist/ai/runtime/telemetry-schema.d.ts +192 -0
- package/dist/ai/runtime/telemetry-schema.d.ts.map +1 -0
- package/dist/ai/runtime/telemetry-schema.js +200 -0
- package/dist/ai/runtime/telemetry-schema.js.map +1 -0
- package/dist/ai/runtime/types.d.ts +236 -0
- package/dist/ai/runtime/types.d.ts.map +1 -0
- package/dist/ai/runtime/types.js +10 -0
- package/dist/ai/runtime/types.js.map +1 -0
- package/dist/ai/src/batch-processor.d.ts +298 -0
- package/dist/ai/src/batch-processor.d.ts.map +1 -0
- package/dist/ai/src/batch-processor.js +520 -0
- package/dist/ai/src/batch-processor.js.map +1 -0
- package/dist/ai/src/capability-bootstrap.d.ts +222 -0
- package/dist/ai/src/capability-bootstrap.d.ts.map +1 -0
- package/dist/ai/src/capability-bootstrap.js +421 -0
- package/dist/ai/src/capability-bootstrap.js.map +1 -0
- package/dist/ai/src/capability-manifest-generator.d.ts +52 -0
- package/dist/ai/src/capability-manifest-generator.d.ts.map +1 -0
- package/dist/ai/src/capability-manifest-generator.js +691 -0
- package/dist/ai/src/capability-manifest-generator.js.map +1 -0
- package/dist/ai/src/capability-registry.d.ts +157 -0
- package/dist/ai/src/capability-registry.d.ts.map +1 -0
- package/dist/ai/src/capability-registry.js +577 -0
- package/dist/ai/src/capability-registry.js.map +1 -0
- package/dist/ai/src/cli/telemetry-dashboard.d.ts +132 -0
- package/dist/ai/src/cli/telemetry-dashboard.d.ts.map +1 -0
- package/dist/ai/src/cli/telemetry-dashboard.js +565 -0
- package/dist/ai/src/cli/telemetry-dashboard.js.map +1 -0
- package/dist/ai/src/delegation/feature-flags.d.ts +213 -0
- package/dist/ai/src/delegation/feature-flags.d.ts.map +1 -0
- package/dist/ai/src/delegation/feature-flags.js +395 -0
- package/dist/ai/src/delegation/feature-flags.js.map +1 -0
- package/dist/ai/src/delegation/liability-firebreak.d.ts +303 -0
- package/dist/ai/src/delegation/liability-firebreak.d.ts.map +1 -0
- package/dist/ai/src/delegation/liability-firebreak.js +643 -0
- package/dist/ai/src/delegation/liability-firebreak.js.map +1 -0
- package/dist/ai/src/delegation/security-threat-model.d.ts +171 -0
- package/dist/ai/src/delegation/security-threat-model.d.ts.map +1 -0
- package/dist/ai/src/delegation/security-threat-model.js +723 -0
- package/dist/ai/src/delegation/security-threat-model.js.map +1 -0
- package/dist/ai/src/delegation/tlp-enforcement.d.ts +146 -0
- package/dist/ai/src/delegation/tlp-enforcement.d.ts.map +1 -0
- package/dist/ai/src/delegation/tlp-enforcement.js +382 -0
- package/dist/ai/src/delegation/tlp-enforcement.js.map +1 -0
- package/dist/ai/src/delegation-capability-integration.d.ts +154 -0
- package/dist/ai/src/delegation-capability-integration.d.ts.map +1 -0
- package/dist/ai/src/delegation-capability-integration.js +351 -0
- package/dist/ai/src/delegation-capability-integration.js.map +1 -0
- package/dist/ai/src/end-to-end-workflow-orchestrator.d.ts +325 -0
- package/dist/ai/src/end-to-end-workflow-orchestrator.d.ts.map +1 -0
- package/dist/ai/src/end-to-end-workflow-orchestrator.js +801 -0
- package/dist/ai/src/end-to-end-workflow-orchestrator.js.map +1 -0
- package/dist/ai/src/enhanced-capability-detection.d.ts +237 -0
- package/dist/ai/src/enhanced-capability-detection.d.ts.map +1 -0
- package/dist/ai/src/enhanced-capability-detection.js +448 -0
- package/dist/ai/src/enhanced-capability-detection.js.map +1 -0
- package/dist/ai/src/intelligent-cache-manager.d.ts +327 -0
- package/dist/ai/src/intelligent-cache-manager.d.ts.map +1 -0
- package/dist/ai/src/intelligent-cache-manager.js +634 -0
- package/dist/ai/src/intelligent-cache-manager.js.map +1 -0
- package/dist/ai/src/mcp-auto-configuration.d.ts +232 -0
- package/dist/ai/src/mcp-auto-configuration.d.ts.map +1 -0
- package/dist/ai/src/mcp-auto-configuration.js +445 -0
- package/dist/ai/src/mcp-auto-configuration.js.map +1 -0
- package/dist/ai/src/performance-profiler.d.ts +351 -0
- package/dist/ai/src/performance-profiler.d.ts.map +1 -0
- package/dist/ai/src/performance-profiler.js +475 -0
- package/dist/ai/src/performance-profiler.js.map +1 -0
- package/dist/ai/src/personas/hooks/before-llm-call.d.ts +96 -0
- package/dist/ai/src/personas/hooks/before-llm-call.d.ts.map +1 -0
- package/dist/ai/src/personas/hooks/before-llm-call.js +83 -0
- package/dist/ai/src/personas/hooks/before-llm-call.js.map +1 -0
- package/dist/ai/src/personas/index.d.ts +10 -0
- package/dist/ai/src/personas/index.d.ts.map +1 -0
- package/dist/ai/src/personas/index.js +10 -0
- package/dist/ai/src/personas/index.js.map +1 -0
- package/dist/ai/src/personas/persona-loader.d.ts +42 -0
- package/dist/ai/src/personas/persona-loader.d.ts.map +1 -0
- package/dist/ai/src/personas/persona-loader.js +162 -0
- package/dist/ai/src/personas/persona-loader.js.map +1 -0
- package/dist/ai/src/personas/types.d.ts +199 -0
- package/dist/ai/src/personas/types.d.ts.map +1 -0
- package/dist/ai/src/personas/types.js +7 -0
- package/dist/ai/src/personas/types.js.map +1 -0
- package/dist/ai/src/personas/voice-resolver.d.ts +40 -0
- package/dist/ai/src/personas/voice-resolver.d.ts.map +1 -0
- package/dist/ai/src/personas/voice-resolver.js +201 -0
- package/dist/ai/src/personas/voice-resolver.js.map +1 -0
- package/dist/ai/src/resource-monitor.d.ts +311 -0
- package/dist/ai/src/resource-monitor.d.ts.map +1 -0
- package/dist/ai/src/resource-monitor.js +475 -0
- package/dist/ai/src/resource-monitor.js.map +1 -0
- package/dist/ai/src/runtime/agent-runtime.d.ts +340 -0
- package/dist/ai/src/runtime/agent-runtime.d.ts.map +1 -0
- package/dist/ai/src/runtime/agent-runtime.js +1084 -0
- package/dist/ai/src/runtime/agent-runtime.js.map +1 -0
- package/dist/ai/src/telemetry/delegation-telemetry.d.ts +287 -0
- package/dist/ai/src/telemetry/delegation-telemetry.d.ts.map +1 -0
- package/dist/ai/src/telemetry/delegation-telemetry.js +389 -0
- package/dist/ai/src/telemetry/delegation-telemetry.js.map +1 -0
- package/dist/ai/src/telemetry/index.d.ts +48 -0
- package/dist/ai/src/telemetry/index.d.ts.map +1 -0
- package/dist/ai/src/telemetry/index.js +48 -0
- package/dist/ai/src/telemetry/index.js.map +1 -0
- package/dist/ai/src/telemetry/runtime-telemetry-integration.d.ts +67 -0
- package/dist/ai/src/telemetry/runtime-telemetry-integration.d.ts.map +1 -0
- package/dist/ai/src/telemetry/runtime-telemetry-integration.js +415 -0
- package/dist/ai/src/telemetry/runtime-telemetry-integration.js.map +1 -0
- package/dist/ai/src/telemetry/telemetry-utils.d.ts +119 -0
- package/dist/ai/src/telemetry/telemetry-utils.d.ts.map +1 -0
- package/dist/ai/src/telemetry/telemetry-utils.js +250 -0
- package/dist/ai/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/ai/src/types/agent-capabilities.d.ts +227 -0
- package/dist/ai/src/types/agent-capabilities.d.ts.map +1 -0
- package/dist/ai/src/types/agent-capabilities.js +11 -0
- package/dist/ai/src/types/agent-capabilities.js.map +1 -0
- package/dist/ai/src/types/context-verification.d.ts +158 -0
- package/dist/ai/src/types/context-verification.d.ts.map +1 -0
- package/dist/ai/src/types/context-verification.js +73 -0
- package/dist/ai/src/types/context-verification.js.map +1 -0
- package/dist/ai/src/types/delegation-contracts.d.ts +296 -0
- package/dist/ai/src/types/delegation-contracts.d.ts.map +1 -0
- package/dist/ai/src/types/delegation-contracts.js +17 -0
- package/dist/ai/src/types/delegation-contracts.js.map +1 -0
- package/dist/ai/src/validation-pipeline-integration.d.ts +266 -0
- package/dist/ai/src/validation-pipeline-integration.d.ts.map +1 -0
- package/dist/ai/src/validation-pipeline-integration.js +695 -0
- package/dist/ai/src/validation-pipeline-integration.js.map +1 -0
- package/dist/ai/src/verification/multi-modal-formatters.d.ts +57 -0
- package/dist/ai/src/verification/multi-modal-formatters.d.ts.map +1 -0
- package/dist/ai/src/verification/multi-modal-formatters.js +655 -0
- package/dist/ai/src/verification/multi-modal-formatters.js.map +1 -0
- package/dist/ai/src/verification/output-formatter.d.ts +186 -0
- package/dist/ai/src/verification/output-formatter.d.ts.map +1 -0
- package/dist/ai/src/verification/output-formatter.js +296 -0
- package/dist/ai/src/verification/output-formatter.js.map +1 -0
- package/dist/ai/src/verification/parser-integration.d.ts +137 -0
- package/dist/ai/src/verification/parser-integration.d.ts.map +1 -0
- package/dist/ai/src/verification/parser-integration.js +273 -0
- package/dist/ai/src/verification/parser-integration.js.map +1 -0
- package/dist/ai/types/agent-capabilities.d.ts +387 -0
- package/dist/ai/types/agent-capabilities.d.ts.map +1 -0
- package/dist/ai/types/agent-capabilities.js +32 -0
- package/dist/ai/types/agent-capabilities.js.map +1 -0
- package/dist/ai/types/delegation-contracts.d.ts +291 -0
- package/dist/ai/types/delegation-contracts.d.ts.map +1 -0
- package/dist/ai/types/delegation-contracts.js +14 -0
- package/dist/ai/types/delegation-contracts.js.map +1 -0
- package/dist/ai/types/index.d.ts +4 -1
- package/dist/ai/types/index.d.ts.map +1 -1
- package/dist/ai/types/index.js +4 -1
- package/dist/ai/types/index.js.map +1 -1
- package/dist/ai/types/permission-tokens.d.ts +365 -0
- package/dist/ai/types/permission-tokens.d.ts.map +1 -0
- package/dist/ai/types/permission-tokens.js +13 -0
- package/dist/ai/types/permission-tokens.js.map +1 -0
- package/dist/ai/types/security-middleware.d.ts +130 -0
- package/dist/ai/types/security-middleware.d.ts.map +1 -0
- package/dist/ai/types/security-middleware.js +13 -0
- package/dist/ai/types/security-middleware.js.map +1 -0
- package/dist/ai/utils/storage.d.ts.map +1 -1
- package/dist/ai/utils/storage.js +6 -3
- package/dist/ai/utils/storage.js.map +1 -1
- package/dist/ai/validation/validation-framework.js +1 -1
- package/dist/ai/verification/policy-framework.d.ts +161 -0
- package/dist/ai/verification/policy-framework.d.ts.map +1 -0
- package/dist/ai/verification/policy-framework.js +436 -0
- package/dist/ai/verification/policy-framework.js.map +1 -0
- package/package.json +56 -6
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Monitor MCP Server
|
|
3
|
+
* TLP:CLEAR
|
|
4
|
+
*
|
|
5
|
+
* Provides AI assistants with delegation monitoring and management capabilities
|
|
6
|
+
* including event logging, reputation queries, task status, and manual escalation.
|
|
7
|
+
*
|
|
8
|
+
* Tools:
|
|
9
|
+
* - delegation:logEvent - Log delegation events to telemetry system
|
|
10
|
+
* - delegation:queryReputation - Query agent reputation scores and history
|
|
11
|
+
* - delegation:getTaskStatus - Check delegation contract execution status
|
|
12
|
+
* - delegation:triggerEscalation - Manual escalation for human review
|
|
13
|
+
* - delegation:querySessionsByMode - Query sessions filtered by execution mode (Phase 3)
|
|
14
|
+
* - delegation:getSessionHandoffHistory - Get handoff events for a session (Phase 3)
|
|
15
|
+
* - delegation:triggerSessionHandoff - Trigger an execution mode transition (Phase 3)
|
|
16
|
+
*
|
|
17
|
+
* Resources:
|
|
18
|
+
* - delegation://contracts/active - Active delegation contracts
|
|
19
|
+
* - delegation://reputation/top - Top-performing agents by reputation
|
|
20
|
+
* - delegation://events/recent - Recent delegation events
|
|
21
|
+
* - delegation://escalations/pending - Pending manual reviews
|
|
22
|
+
* - delegation://sessions/by-mode - Sessions grouped by execution mode (Phase 3)
|
|
23
|
+
*
|
|
24
|
+
* @module mcp/servers/delegation-monitor
|
|
25
|
+
* @version 1.1.0
|
|
26
|
+
* @date 2026-02-13
|
|
27
|
+
*/
|
|
28
|
+
import { FastMCP } from 'fastmcp';
|
|
29
|
+
import { z } from 'zod';
|
|
30
|
+
import { handleToolError, logToolExecution, MCPToolError, measurePerformance, } from '../shared/utils.js';
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// Authentication
|
|
33
|
+
// ============================================================================
|
|
34
|
+
/**
|
|
35
|
+
* Validates a bearer token for write operations.
|
|
36
|
+
* If DELEGATION_MCP_WRITE_TOKEN is set, the provided token must match.
|
|
37
|
+
* If the env var is unset (dev mode), all writes are permitted.
|
|
38
|
+
*
|
|
39
|
+
* @throws MCPToolError with code UNAUTHORIZED if validation fails
|
|
40
|
+
*/
|
|
41
|
+
export function validateWriteToken(token) {
|
|
42
|
+
const expectedToken = process.env['DELEGATION_MCP_WRITE_TOKEN'];
|
|
43
|
+
if (!expectedToken) {
|
|
44
|
+
// Dev/unprotected mode — allow all writes
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!token) {
|
|
48
|
+
throw new MCPToolError('UNAUTHORIZED', 'Write operations require a bearer token. Provide authToken in the request.');
|
|
49
|
+
}
|
|
50
|
+
if (token !== expectedToken) {
|
|
51
|
+
throw new MCPToolError('UNAUTHORIZED', 'Invalid bearer token for write operation.');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Temporary: Use stub implementations until we wire up actual instances
|
|
55
|
+
// TODO: Inject real ContractManager and ReputationEngine from main module exports
|
|
56
|
+
class StubContractManager {
|
|
57
|
+
contracts = new Map();
|
|
58
|
+
queryContracts(query) {
|
|
59
|
+
return Array.from(this.contracts.values());
|
|
60
|
+
}
|
|
61
|
+
getContract(id) {
|
|
62
|
+
return this.contracts.get(id);
|
|
63
|
+
}
|
|
64
|
+
updateContract(id, update) {
|
|
65
|
+
const contract = this.contracts.get(id);
|
|
66
|
+
if (contract) {
|
|
67
|
+
Object.assign(contract, update);
|
|
68
|
+
this.contracts.set(id, contract);
|
|
69
|
+
}
|
|
70
|
+
return Promise.resolve(contract);
|
|
71
|
+
}
|
|
72
|
+
getStats() {
|
|
73
|
+
return { total_contracts: this.contracts.size };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Query contracts filtered by execution mode (stored in metadata).
|
|
77
|
+
* Phase 3.1: Returns contracts whose metadata.execution_mode matches.
|
|
78
|
+
*/
|
|
79
|
+
querySessionsByMode(mode) {
|
|
80
|
+
return Array.from(this.contracts.values()).filter((c) => {
|
|
81
|
+
try {
|
|
82
|
+
const meta = typeof c.metadata === 'string' ? JSON.parse(c.metadata) : (c.metadata ?? {});
|
|
83
|
+
return (meta.execution_mode ?? 'interactive') === mode;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return mode === 'interactive'; // default
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get handoff history entries for a given session ID.
|
|
92
|
+
* Phase 3.6: Searches contracts for parent_contract_id chain.
|
|
93
|
+
*/
|
|
94
|
+
getSessionHandoffHistory(sessionId) {
|
|
95
|
+
// In the stub implementation, return an empty history.
|
|
96
|
+
// Real implementation would trace the parent_contract_id chain.
|
|
97
|
+
return Array.from(this.contracts.values())
|
|
98
|
+
.filter((c) => {
|
|
99
|
+
try {
|
|
100
|
+
const meta = typeof c.metadata === 'string' ? JSON.parse(c.metadata) : (c.metadata ?? {});
|
|
101
|
+
return meta.session_id === sessionId;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
.map((c) => ({
|
|
108
|
+
contractId: c.contract_id ?? c.id,
|
|
109
|
+
executionMode: (() => {
|
|
110
|
+
try {
|
|
111
|
+
const meta = typeof c.metadata === 'string' ? JSON.parse(c.metadata) : (c.metadata ?? {});
|
|
112
|
+
return meta.execution_mode ?? 'interactive';
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return 'interactive';
|
|
116
|
+
}
|
|
117
|
+
})(),
|
|
118
|
+
status: c.status,
|
|
119
|
+
createdAt: c.created_at,
|
|
120
|
+
parentContractId: c.parent_contract_id,
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Trigger a session handoff (stub — returns a synthetic new contract).
|
|
125
|
+
* Phase 3.6: Real implementation calls DelegationContractManager.handoffSession().
|
|
126
|
+
*/
|
|
127
|
+
async triggerSessionHandoff(request) {
|
|
128
|
+
const source = this.contracts.get(request.fromContractId);
|
|
129
|
+
if (!source) {
|
|
130
|
+
throw new Error(`Contract not found: ${request.fromContractId}`);
|
|
131
|
+
}
|
|
132
|
+
const newContract = {
|
|
133
|
+
...source,
|
|
134
|
+
contract_id: `${request.fromContractId}-handoff-${Date.now()}`,
|
|
135
|
+
parent_contract_id: request.fromContractId,
|
|
136
|
+
metadata: JSON.stringify({
|
|
137
|
+
...((() => { try {
|
|
138
|
+
return JSON.parse(source.metadata ?? '{}');
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return {};
|
|
142
|
+
} })()),
|
|
143
|
+
execution_mode: request.toExecutionMode,
|
|
144
|
+
handoff_reason: request.handoffReason,
|
|
145
|
+
handed_off_at: new Date().toISOString(),
|
|
146
|
+
}),
|
|
147
|
+
created_at: new Date().toISOString(),
|
|
148
|
+
status: 'active',
|
|
149
|
+
};
|
|
150
|
+
this.contracts.set(newContract.contract_id, newContract);
|
|
151
|
+
return newContract;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
class StubReputationEngine {
|
|
155
|
+
profiles = new Map();
|
|
156
|
+
queryProfiles(query) {
|
|
157
|
+
return Array.from(this.profiles.values());
|
|
158
|
+
}
|
|
159
|
+
getProfile(agentId) {
|
|
160
|
+
return this.profiles.get(agentId);
|
|
161
|
+
}
|
|
162
|
+
getStats() {
|
|
163
|
+
return { total_profiles: this.profiles.size };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
class StubTelemetryEngine {
|
|
167
|
+
async trackEvent(event) {
|
|
168
|
+
console.log('[Telemetry]', event);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// ============================================================================
|
|
172
|
+
// Server Configuration
|
|
173
|
+
// ============================================================================
|
|
174
|
+
const server = new FastMCP({
|
|
175
|
+
name: 'dcyfr-delegation-monitor',
|
|
176
|
+
version: '1.0.0',
|
|
177
|
+
instructions: 'Provides delegation monitoring and management tools for tracking contracts, reputation, events, and escalations. Use these tools to monitor delegation chains, query agent performance, and trigger manual reviews when needed.',
|
|
178
|
+
});
|
|
179
|
+
// Initialize delegation infrastructure
|
|
180
|
+
// Initialize delegation infrastructure (using stubs until proper wiring)
|
|
181
|
+
const contractManager = new StubContractManager();
|
|
182
|
+
const reputationEngine = new StubReputationEngine();
|
|
183
|
+
const telemetryEngine = new StubTelemetryEngine();
|
|
184
|
+
// ============================================================================
|
|
185
|
+
// Tool 1: Log Delegation Event
|
|
186
|
+
// ============================================================================
|
|
187
|
+
server.addTool({
|
|
188
|
+
name: 'delegation:logEvent',
|
|
189
|
+
description: 'Log a delegation event to the telemetry system. Use this to track contract lifecycle events, performance metrics, and delegation chain activities. Requires bearer token authentication (authToken).',
|
|
190
|
+
parameters: z.object({
|
|
191
|
+
authToken: z.string().optional().describe('Bearer token for write authorization'),
|
|
192
|
+
eventType: z
|
|
193
|
+
.enum([
|
|
194
|
+
'delegation_contract_created',
|
|
195
|
+
'delegation_progress',
|
|
196
|
+
'delegation_completed',
|
|
197
|
+
'delegation_failed',
|
|
198
|
+
'delegation_firebreak_triggered',
|
|
199
|
+
])
|
|
200
|
+
.describe('Type of delegation event'),
|
|
201
|
+
contractId: z.string().describe('Delegation contract identifier'),
|
|
202
|
+
agentId: z.string().optional().describe('Agent involved in the event'),
|
|
203
|
+
metadata: z
|
|
204
|
+
.record(z.string(), z.unknown())
|
|
205
|
+
.optional()
|
|
206
|
+
.describe('Additional event metadata (JSON object)'),
|
|
207
|
+
}),
|
|
208
|
+
annotations: {
|
|
209
|
+
readOnlyHint: false,
|
|
210
|
+
openWorldHint: false,
|
|
211
|
+
},
|
|
212
|
+
execute: async (args, { log }) => {
|
|
213
|
+
try {
|
|
214
|
+
validateWriteToken(args.authToken);
|
|
215
|
+
const { result, durationMs } = await measurePerformance(async () => {
|
|
216
|
+
// Create simple delegation event (telemetry API not yet fully implemented)
|
|
217
|
+
const event_id = `evt_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
218
|
+
// Get contract if exists
|
|
219
|
+
const contract = contractManager.getContract(args.contractId);
|
|
220
|
+
// Note: Actual telemetry.trackEvent() or similar method would be called here
|
|
221
|
+
// For now, we just return success confirmation
|
|
222
|
+
return {
|
|
223
|
+
success: true,
|
|
224
|
+
event_id,
|
|
225
|
+
event_type: args.eventType,
|
|
226
|
+
contract_id: args.contractId,
|
|
227
|
+
contract_status: contract?.status || 'unknown',
|
|
228
|
+
timestamp: new Date().toISOString(),
|
|
229
|
+
message: `Event logged successfully (telemetry integration pending)`,
|
|
230
|
+
};
|
|
231
|
+
}, 'logDelegationEvent');
|
|
232
|
+
logToolExecution('delegation:logEvent', args, true, durationMs);
|
|
233
|
+
return JSON.stringify(result, null, 2);
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
logToolExecution('delegation:logEvent', args, false);
|
|
237
|
+
return handleToolError(error);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
// ============================================================================
|
|
242
|
+
// Tool 2: Query Reputation
|
|
243
|
+
// ============================================================================
|
|
244
|
+
server.addTool({
|
|
245
|
+
name: 'delegation:queryReputation',
|
|
246
|
+
description: 'Query agent reputation scores and history. Returns multi-dimensional scores (reliability, speed, quality, security), overall score, task completion history, and confidence level.',
|
|
247
|
+
parameters: z.object({
|
|
248
|
+
agentId: z.string().optional().describe('Specific agent ID to query'),
|
|
249
|
+
minScore: z.number().min(0).max(1).optional().describe('Minimum overall score filter'),
|
|
250
|
+
minTasksCompleted: z
|
|
251
|
+
.number()
|
|
252
|
+
.int()
|
|
253
|
+
.min(0)
|
|
254
|
+
.optional()
|
|
255
|
+
.describe('Minimum number of completed tasks'),
|
|
256
|
+
dimension: z
|
|
257
|
+
.enum(['reliability', 'speed', 'quality', 'security'])
|
|
258
|
+
.optional()
|
|
259
|
+
.describe('Filter by specific dimension'),
|
|
260
|
+
limit: z.number().int().min(1).max(100).optional().default(10).describe('Maximum results'),
|
|
261
|
+
}),
|
|
262
|
+
annotations: {
|
|
263
|
+
readOnlyHint: true,
|
|
264
|
+
openWorldHint: false,
|
|
265
|
+
},
|
|
266
|
+
execute: async (args, { log }) => {
|
|
267
|
+
try {
|
|
268
|
+
const { result, durationMs } = await measurePerformance(async () => {
|
|
269
|
+
if (args.agentId) {
|
|
270
|
+
// Query specific agent
|
|
271
|
+
const profile = reputationEngine.getProfile(args.agentId);
|
|
272
|
+
return {
|
|
273
|
+
agent_id: profile.agent_id,
|
|
274
|
+
overall_score: profile.overall_score,
|
|
275
|
+
dimensions: profile.dimensions,
|
|
276
|
+
tasks_completed: profile.tasks_completed,
|
|
277
|
+
consecutive_successes: profile.consecutive_successes,
|
|
278
|
+
consecutive_failures: profile.consecutive_failures,
|
|
279
|
+
confidence: profile.confidence,
|
|
280
|
+
specializations: profile.specializations || [],
|
|
281
|
+
last_updated: profile.last_updated,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
// Query with filters
|
|
286
|
+
const query = {
|
|
287
|
+
limit: args.limit,
|
|
288
|
+
sort_by: 'overall_score',
|
|
289
|
+
sort_order: 'desc',
|
|
290
|
+
};
|
|
291
|
+
if (args.minScore !== undefined) {
|
|
292
|
+
query.min_score = args.minScore;
|
|
293
|
+
}
|
|
294
|
+
if (args.minTasksCompleted !== undefined) {
|
|
295
|
+
query.min_tasks_completed = args.minTasksCompleted;
|
|
296
|
+
}
|
|
297
|
+
if (args.dimension) {
|
|
298
|
+
// Filter by specific dimension score
|
|
299
|
+
// Use minScore as threshold for that dimension
|
|
300
|
+
query.min_dimension_score = {
|
|
301
|
+
dimension: args.dimension,
|
|
302
|
+
score: args.minScore || 0.5,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
const profiles = reputationEngine.queryProfiles(query);
|
|
306
|
+
return {
|
|
307
|
+
total_results: profiles.length,
|
|
308
|
+
profiles: profiles.map((p) => ({
|
|
309
|
+
agent_id: p.agent_id,
|
|
310
|
+
overall_score: p.overall_score,
|
|
311
|
+
dimensions: p.dimensions,
|
|
312
|
+
tasks_completed: p.tasks_completed,
|
|
313
|
+
confidence: p.confidence,
|
|
314
|
+
last_updated: p.last_updated,
|
|
315
|
+
})),
|
|
316
|
+
query_params: args,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}, 'queryReputation');
|
|
320
|
+
logToolExecution('delegation:queryReputation', args, true, durationMs);
|
|
321
|
+
return JSON.stringify(result, null, 2);
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
logToolExecution('delegation:queryReputation', args, false);
|
|
325
|
+
return handleToolError(error);
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
// ============================================================================
|
|
330
|
+
// Tool 3: Get Task Status
|
|
331
|
+
// ============================================================================
|
|
332
|
+
server.addTool({
|
|
333
|
+
name: 'delegation:getTaskStatus',
|
|
334
|
+
description: 'Check the status of a delegation contract including execution progress, verification results, and performance metrics. Use this to monitor ongoing delegations and check completion status.',
|
|
335
|
+
parameters: z.object({
|
|
336
|
+
contractId: z.string().describe('Delegation contract identifier'),
|
|
337
|
+
includeHistory: z
|
|
338
|
+
.boolean()
|
|
339
|
+
.optional()
|
|
340
|
+
.default(false)
|
|
341
|
+
.describe('Include full event history'),
|
|
342
|
+
}),
|
|
343
|
+
annotations: {
|
|
344
|
+
readOnlyHint: true,
|
|
345
|
+
openWorldHint: false,
|
|
346
|
+
},
|
|
347
|
+
execute: async (args, { log }) => {
|
|
348
|
+
try {
|
|
349
|
+
const { result, durationMs } = await measurePerformance(async () => {
|
|
350
|
+
// Get contract from manager
|
|
351
|
+
const contract = contractManager.getContract(args.contractId);
|
|
352
|
+
if (!contract) {
|
|
353
|
+
return {
|
|
354
|
+
found: false,
|
|
355
|
+
contract_id: args.contractId,
|
|
356
|
+
message: 'Contract not found',
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
// Build status response
|
|
360
|
+
const statusData = {
|
|
361
|
+
found: true,
|
|
362
|
+
contract_id: contract.contract_id,
|
|
363
|
+
task_id: contract.task_id,
|
|
364
|
+
status: contract.status,
|
|
365
|
+
delegator: contract.delegator_agent_id,
|
|
366
|
+
delegatee: contract.delegatee_agent_id,
|
|
367
|
+
verification_policy: contract.verification_policy,
|
|
368
|
+
tlp_classification: contract.tlp_classification,
|
|
369
|
+
created_at: contract.created_at,
|
|
370
|
+
timeout_ms: contract.timeout_ms,
|
|
371
|
+
};
|
|
372
|
+
// Add completion data if available
|
|
373
|
+
if (contract.completion) {
|
|
374
|
+
statusData.completion = {
|
|
375
|
+
completed_at: contract.completion.completed_at,
|
|
376
|
+
success: contract.completion.success,
|
|
377
|
+
execution_time_ms: contract.completion.metrics?.execution_time_ms,
|
|
378
|
+
verification_passed: contract.completion.verification?.verified,
|
|
379
|
+
verification_method: contract.completion.verification?.verification_method,
|
|
380
|
+
quality_score: contract.completion.verification?.quality_score,
|
|
381
|
+
};
|
|
382
|
+
if (contract.completion.error) {
|
|
383
|
+
statusData.completion.error = contract.completion.error;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
// Add event history if requested
|
|
387
|
+
if (args.includeHistory) {
|
|
388
|
+
// Note: telemetryEngine.getContractEvents() not yet implemented
|
|
389
|
+
// Would retrieve event history here
|
|
390
|
+
statusData.event_history = [];
|
|
391
|
+
statusData.event_history_note = 'Event history integration pending';
|
|
392
|
+
}
|
|
393
|
+
// Calculate time remaining if active
|
|
394
|
+
if (contract.status === 'active' && contract.timeout_ms) {
|
|
395
|
+
const elapsed = Date.now() - new Date(contract.created_at).getTime();
|
|
396
|
+
statusData.time_remaining_ms = Math.max(0, contract.timeout_ms - elapsed);
|
|
397
|
+
statusData.progress_percent = Math.min(100, (elapsed / contract.timeout_ms) * 100);
|
|
398
|
+
}
|
|
399
|
+
return statusData;
|
|
400
|
+
}, 'getTaskStatus');
|
|
401
|
+
logToolExecution('delegation:getTaskStatus', args, true, durationMs);
|
|
402
|
+
return JSON.stringify(result, null, 2);
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
logToolExecution('delegation:getTaskStatus', args, false);
|
|
406
|
+
return handleToolError(error);
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
// ============================================================================
|
|
411
|
+
// Tool 4: Trigger Escalation
|
|
412
|
+
// ============================================================================
|
|
413
|
+
server.addTool({
|
|
414
|
+
name: 'delegation:triggerEscalation',
|
|
415
|
+
description: 'Manually escalate a delegation contract for human review. Use this when automated verification is insufficient or when manual_required verification policy is in effect. Creates an escalation ticket and marks contract for human attention. Requires bearer token authentication (authToken).',
|
|
416
|
+
parameters: z.object({
|
|
417
|
+
authToken: z.string().optional().describe('Bearer token for write authorization'),
|
|
418
|
+
contractId: z.string().describe('Delegation contract to escalate'),
|
|
419
|
+
reason: z.string().describe('Reason for escalation (human-readable)'),
|
|
420
|
+
priority: z
|
|
421
|
+
.enum(['low', 'medium', 'high', 'critical'])
|
|
422
|
+
.optional()
|
|
423
|
+
.default('medium')
|
|
424
|
+
.describe('Escalation priority level'),
|
|
425
|
+
requestedReviewer: z.string().optional().describe('Specific human reviewer to assign'),
|
|
426
|
+
additionalContext: z
|
|
427
|
+
.record(z.string(), z.unknown())
|
|
428
|
+
.optional()
|
|
429
|
+
.describe('Additional context for reviewer'),
|
|
430
|
+
}),
|
|
431
|
+
annotations: {
|
|
432
|
+
readOnlyHint: false,
|
|
433
|
+
openWorldHint: false,
|
|
434
|
+
},
|
|
435
|
+
execute: async (args, { log }) => {
|
|
436
|
+
try {
|
|
437
|
+
validateWriteToken(args.authToken);
|
|
438
|
+
const { result, durationMs } = await measurePerformance(async () => {
|
|
439
|
+
// Get contract
|
|
440
|
+
const contract = contractManager.getContract(args.contractId);
|
|
441
|
+
if (!contract) {
|
|
442
|
+
throw new Error(`Contract not found: ${args.contractId}`);
|
|
443
|
+
}
|
|
444
|
+
// Create escalation ticket
|
|
445
|
+
const escalation_id = `esc_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
446
|
+
const escalationData = {
|
|
447
|
+
escalation_id,
|
|
448
|
+
contract_id: args.contractId,
|
|
449
|
+
task_id: contract.task_id,
|
|
450
|
+
reason: args.reason,
|
|
451
|
+
priority: args.priority || 'medium',
|
|
452
|
+
requested_reviewer: args.requestedReviewer,
|
|
453
|
+
status: 'pending',
|
|
454
|
+
created_at: new Date().toISOString(),
|
|
455
|
+
contract_status: contract.status,
|
|
456
|
+
delegatee: contract.delegatee_agent_id,
|
|
457
|
+
verification_policy: contract.verification_policy,
|
|
458
|
+
tlp_classification: contract.tlp_classification,
|
|
459
|
+
additional_context: args.additionalContext || {},
|
|
460
|
+
};
|
|
461
|
+
// Log escalation event (telemetry integration pending)
|
|
462
|
+
// Note: Actual telemetry method would be called here once API is finalized
|
|
463
|
+
// Update contract metadata with escalation
|
|
464
|
+
await contractManager.updateContract(args.contractId, {
|
|
465
|
+
metadata: {
|
|
466
|
+
...contract.metadata,
|
|
467
|
+
escalation_id,
|
|
468
|
+
escalated_at: new Date().toISOString(),
|
|
469
|
+
escalation_reason: args.reason,
|
|
470
|
+
},
|
|
471
|
+
});
|
|
472
|
+
return {
|
|
473
|
+
success: true,
|
|
474
|
+
escalation_id,
|
|
475
|
+
contract_id: args.contractId,
|
|
476
|
+
status: 'pending_review',
|
|
477
|
+
priority: args.priority,
|
|
478
|
+
message: 'Escalation created successfully',
|
|
479
|
+
next_steps: [
|
|
480
|
+
'Human reviewer will be notified',
|
|
481
|
+
'Contract execution may be paused pending review',
|
|
482
|
+
'Use delegation:getTaskStatus to check escalation status',
|
|
483
|
+
],
|
|
484
|
+
escalation_details: escalationData,
|
|
485
|
+
};
|
|
486
|
+
}, 'triggerEscalation');
|
|
487
|
+
logToolExecution('delegation:triggerEscalation', args, true, durationMs);
|
|
488
|
+
return JSON.stringify(result, null, 2);
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
logToolExecution('delegation:triggerEscalation', args, false);
|
|
492
|
+
return handleToolError(error);
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
});
|
|
496
|
+
// ============================================================================
|
|
497
|
+
// Tool 5: Query Sessions By Mode (Phase 3)
|
|
498
|
+
// ============================================================================
|
|
499
|
+
server.addTool({
|
|
500
|
+
name: 'delegation:querySessionsByMode',
|
|
501
|
+
description: 'Query delegation sessions (contracts) filtered by execution mode (interactive, background, async). Returns session IDs, status, and metadata.',
|
|
502
|
+
parameters: z.object({
|
|
503
|
+
mode: z
|
|
504
|
+
.enum(['interactive', 'background', 'async'])
|
|
505
|
+
.describe('Execution mode to filter by'),
|
|
506
|
+
limit: z
|
|
507
|
+
.number()
|
|
508
|
+
.int()
|
|
509
|
+
.min(1)
|
|
510
|
+
.max(100)
|
|
511
|
+
.default(20)
|
|
512
|
+
.describe('Maximum number of sessions to return'),
|
|
513
|
+
}),
|
|
514
|
+
async execute(args) {
|
|
515
|
+
const startTime = performance.now();
|
|
516
|
+
try {
|
|
517
|
+
const { mode, limit } = args;
|
|
518
|
+
const sessions = contractManager.querySessionsByMode(mode);
|
|
519
|
+
const limited = sessions.slice(0, limit);
|
|
520
|
+
const result = {
|
|
521
|
+
mode,
|
|
522
|
+
total_found: sessions.length,
|
|
523
|
+
returned: limited.length,
|
|
524
|
+
sessions: limited.map((c) => ({
|
|
525
|
+
contract_id: c.contract_id ?? c.id,
|
|
526
|
+
session_id: (() => {
|
|
527
|
+
try {
|
|
528
|
+
return JSON.parse(c.metadata ?? '{}').session_id ?? null;
|
|
529
|
+
}
|
|
530
|
+
catch {
|
|
531
|
+
return null;
|
|
532
|
+
}
|
|
533
|
+
})(),
|
|
534
|
+
status: c.status,
|
|
535
|
+
task_id: c.task_id,
|
|
536
|
+
delegatee: c.delegatee_agent_id ?? c.delegatee?.agent_id,
|
|
537
|
+
created_at: c.created_at,
|
|
538
|
+
})),
|
|
539
|
+
generated_at: new Date().toISOString(),
|
|
540
|
+
};
|
|
541
|
+
const durationMs = Math.round(performance.now() - startTime);
|
|
542
|
+
logToolExecution('delegation:querySessionsByMode', args, true, durationMs);
|
|
543
|
+
return JSON.stringify(result, null, 2);
|
|
544
|
+
}
|
|
545
|
+
catch (error) {
|
|
546
|
+
logToolExecution('delegation:querySessionsByMode', args, false);
|
|
547
|
+
return handleToolError(error);
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
});
|
|
551
|
+
// ============================================================================
|
|
552
|
+
// Tool 6: Get Session Handoff History (Phase 3)
|
|
553
|
+
// ============================================================================
|
|
554
|
+
server.addTool({
|
|
555
|
+
name: 'delegation:getSessionHandoffHistory',
|
|
556
|
+
description: 'Retrieve the execution mode handoff history for a delegation session. Returns the chain of contracts created by session handoffs.',
|
|
557
|
+
parameters: z.object({
|
|
558
|
+
sessionId: z
|
|
559
|
+
.string()
|
|
560
|
+
.min(1)
|
|
561
|
+
.describe('Session ID to retrieve handoff history for (stored in contract metadata)'),
|
|
562
|
+
}),
|
|
563
|
+
async execute(args) {
|
|
564
|
+
const startTime = performance.now();
|
|
565
|
+
try {
|
|
566
|
+
const { sessionId } = args;
|
|
567
|
+
const history = contractManager.getSessionHandoffHistory(sessionId);
|
|
568
|
+
const result = {
|
|
569
|
+
sessionId,
|
|
570
|
+
handoffCount: history.length,
|
|
571
|
+
history,
|
|
572
|
+
generated_at: new Date().toISOString(),
|
|
573
|
+
};
|
|
574
|
+
const durationMs = Math.round(performance.now() - startTime);
|
|
575
|
+
logToolExecution('delegation:getSessionHandoffHistory', args, true, durationMs);
|
|
576
|
+
return JSON.stringify(result, null, 2);
|
|
577
|
+
}
|
|
578
|
+
catch (error) {
|
|
579
|
+
logToolExecution('delegation:getSessionHandoffHistory', args, false);
|
|
580
|
+
return handleToolError(error);
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
// ============================================================================
|
|
585
|
+
// Tool 7: Trigger Session Handoff (Phase 3)
|
|
586
|
+
// ============================================================================
|
|
587
|
+
server.addTool({
|
|
588
|
+
name: 'delegation:triggerSessionHandoff',
|
|
589
|
+
description: 'Trigger an execution mode transition for a delegation session. Creates a new contract in the target mode and archives the current one.',
|
|
590
|
+
parameters: z.object({
|
|
591
|
+
fromContractId: z
|
|
592
|
+
.string()
|
|
593
|
+
.min(1)
|
|
594
|
+
.describe('Contract ID of the session to hand off from'),
|
|
595
|
+
toExecutionMode: z
|
|
596
|
+
.enum(['interactive', 'background', 'async'])
|
|
597
|
+
.describe('Target execution mode for the new session'),
|
|
598
|
+
handoffReason: z
|
|
599
|
+
.string()
|
|
600
|
+
.min(5)
|
|
601
|
+
.describe('Human-readable reason for the handoff (min 5 chars)'),
|
|
602
|
+
authToken: z
|
|
603
|
+
.string()
|
|
604
|
+
.optional()
|
|
605
|
+
.describe('Bearer token for authentication (required unless DELEGATION_MCP_WRITE_TOKEN is unset)'),
|
|
606
|
+
}),
|
|
607
|
+
async execute(args) {
|
|
608
|
+
const startTime = performance.now();
|
|
609
|
+
try {
|
|
610
|
+
validateWriteToken(args.authToken);
|
|
611
|
+
const newContract = await contractManager.triggerSessionHandoff({
|
|
612
|
+
fromContractId: args.fromContractId,
|
|
613
|
+
toExecutionMode: args.toExecutionMode,
|
|
614
|
+
handoffReason: args.handoffReason,
|
|
615
|
+
});
|
|
616
|
+
const result = {
|
|
617
|
+
success: true,
|
|
618
|
+
handoff: {
|
|
619
|
+
fromContractId: args.fromContractId,
|
|
620
|
+
toContractId: newContract.contract_id,
|
|
621
|
+
toExecutionMode: args.toExecutionMode,
|
|
622
|
+
handoffReason: args.handoffReason,
|
|
623
|
+
handedOffAt: new Date().toISOString(),
|
|
624
|
+
},
|
|
625
|
+
newContract: {
|
|
626
|
+
contract_id: newContract.contract_id,
|
|
627
|
+
status: newContract.status,
|
|
628
|
+
task_id: newContract.task_id,
|
|
629
|
+
},
|
|
630
|
+
};
|
|
631
|
+
const durationMs = Math.round(performance.now() - startTime);
|
|
632
|
+
logToolExecution('delegation:triggerSessionHandoff', args, true, durationMs);
|
|
633
|
+
return JSON.stringify(result, null, 2);
|
|
634
|
+
}
|
|
635
|
+
catch (error) {
|
|
636
|
+
logToolExecution('delegation:triggerSessionHandoff', args, false);
|
|
637
|
+
return handleToolError(error);
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
});
|
|
641
|
+
// ============================================================================
|
|
642
|
+
// Resource 1: Active Contracts
|
|
643
|
+
// ============================================================================
|
|
644
|
+
server.addResource({
|
|
645
|
+
uri: 'delegation://contracts/active',
|
|
646
|
+
name: 'Active Delegation Contracts',
|
|
647
|
+
description: 'List of currently active delegation contracts',
|
|
648
|
+
mimeType: 'application/json',
|
|
649
|
+
async load() {
|
|
650
|
+
try {
|
|
651
|
+
const activeContracts = contractManager.queryContracts({
|
|
652
|
+
status: ['active', 'pending'],
|
|
653
|
+
limit: 50,
|
|
654
|
+
sort_by: 'created_at',
|
|
655
|
+
sort_order: 'desc',
|
|
656
|
+
});
|
|
657
|
+
const summary = {
|
|
658
|
+
total_active: activeContracts.length,
|
|
659
|
+
contracts: activeContracts.map((c) => ({
|
|
660
|
+
contract_id: c.contract_id,
|
|
661
|
+
task_id: c.task_id,
|
|
662
|
+
status: c.status,
|
|
663
|
+
delegatee: c.delegatee?.agent_id || c.delegatee_agent_id,
|
|
664
|
+
verification_policy: c.verification_policy,
|
|
665
|
+
created_at: c.created_at,
|
|
666
|
+
tlp: c.tlp_classification,
|
|
667
|
+
})),
|
|
668
|
+
generated_at: new Date().toISOString(),
|
|
669
|
+
};
|
|
670
|
+
return { text: JSON.stringify(summary, null, 2) };
|
|
671
|
+
}
|
|
672
|
+
catch (error) {
|
|
673
|
+
return { text: handleToolError(error) };
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
});
|
|
677
|
+
// ============================================================================
|
|
678
|
+
// Resource 2: Top Performers
|
|
679
|
+
// ============================================================================
|
|
680
|
+
server.addResource({
|
|
681
|
+
uri: 'delegation://reputation/top',
|
|
682
|
+
name: 'Top Performing Agents',
|
|
683
|
+
description: 'Agents with highest reputation scores',
|
|
684
|
+
mimeType: 'application/json',
|
|
685
|
+
async load() {
|
|
686
|
+
try {
|
|
687
|
+
const topPerformers = reputationEngine.queryProfiles({
|
|
688
|
+
min_score: 0.7,
|
|
689
|
+
limit: 20,
|
|
690
|
+
sort_by: 'overall_score',
|
|
691
|
+
sort_order: 'desc',
|
|
692
|
+
});
|
|
693
|
+
const summary = {
|
|
694
|
+
total_count: topPerformers.length,
|
|
695
|
+
profiles: topPerformers.map((p) => ({
|
|
696
|
+
agent_id: p.agent_id,
|
|
697
|
+
overall_score: p.overall_score,
|
|
698
|
+
dimensions: p.dimensions,
|
|
699
|
+
tasks_completed: p.tasks_completed,
|
|
700
|
+
confidence: p.confidence,
|
|
701
|
+
})),
|
|
702
|
+
generated_at: new Date().toISOString(),
|
|
703
|
+
};
|
|
704
|
+
return { text: JSON.stringify(summary, null, 2) };
|
|
705
|
+
}
|
|
706
|
+
catch (error) {
|
|
707
|
+
return { text: handleToolError(error) };
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
});
|
|
711
|
+
// ============================================================================
|
|
712
|
+
// Resource 3: Sessions By Mode (Phase 3)
|
|
713
|
+
// ============================================================================
|
|
714
|
+
server.addResource({
|
|
715
|
+
uri: 'delegation://sessions/by-mode',
|
|
716
|
+
name: 'Sessions By Execution Mode',
|
|
717
|
+
description: 'Delegation sessions grouped by execution mode (interactive, background, async)',
|
|
718
|
+
mimeType: 'application/json',
|
|
719
|
+
async load() {
|
|
720
|
+
try {
|
|
721
|
+
const modes = ['interactive', 'background', 'async'];
|
|
722
|
+
const grouped = {};
|
|
723
|
+
for (const mode of modes) {
|
|
724
|
+
grouped[mode] = contractManager.querySessionsByMode(mode).map((c) => ({
|
|
725
|
+
contract_id: c.contract_id ?? c.id,
|
|
726
|
+
status: c.status,
|
|
727
|
+
task_id: c.task_id,
|
|
728
|
+
delegatee: c.delegatee_agent_id ?? c.delegatee?.agent_id,
|
|
729
|
+
created_at: c.created_at,
|
|
730
|
+
}));
|
|
731
|
+
}
|
|
732
|
+
const summary = {
|
|
733
|
+
interactive: grouped['interactive'],
|
|
734
|
+
background: grouped['background'],
|
|
735
|
+
async: grouped['async'],
|
|
736
|
+
totals: {
|
|
737
|
+
interactive: grouped['interactive']?.length ?? 0,
|
|
738
|
+
background: grouped['background']?.length ?? 0,
|
|
739
|
+
async: grouped['async']?.length ?? 0,
|
|
740
|
+
},
|
|
741
|
+
generated_at: new Date().toISOString(),
|
|
742
|
+
};
|
|
743
|
+
return { text: JSON.stringify(summary, null, 2) };
|
|
744
|
+
}
|
|
745
|
+
catch (error) {
|
|
746
|
+
return { text: handleToolError(error) };
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
});
|
|
750
|
+
// ============================================================================
|
|
751
|
+
// Start Server
|
|
752
|
+
// ============================================================================
|
|
753
|
+
server.start({
|
|
754
|
+
transportType: 'stdio',
|
|
755
|
+
});
|
|
756
|
+
console.warn('✅ Delegation Monitor MCP Server started (stdio mode)');
|
|
757
|
+
//# sourceMappingURL=index.js.map
|