@vauban-org/agent-sdk 0.17.4 → 1.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/CONTRACT.md +6401 -813
- package/dist/adapters/llm/anthropic-direct.d.ts +1 -0
- package/dist/adapters/llm/anthropic-direct.d.ts.map +1 -1
- package/dist/adapters/llm/anthropic-direct.js +43 -0
- package/dist/adapters/llm/anthropic-direct.js.map +1 -1
- package/dist/adapters/llm/cascade.d.ts.map +1 -1
- package/dist/adapters/llm/cascade.js +57 -14
- package/dist/adapters/llm/cascade.js.map +1 -1
- package/dist/adapters/llm/litellm.d.ts +2 -0
- package/dist/adapters/llm/litellm.d.ts.map +1 -1
- package/dist/adapters/llm/litellm.js +44 -0
- package/dist/adapters/llm/litellm.js.map +1 -1
- package/dist/compute/difficulty-estimator.d.ts +53 -0
- package/dist/compute/difficulty-estimator.d.ts.map +1 -0
- package/dist/compute/difficulty-estimator.js +82 -0
- package/dist/compute/difficulty-estimator.js.map +1 -0
- package/dist/compute/strategies/mixture-of-agents.d.ts +40 -0
- package/dist/compute/strategies/mixture-of-agents.d.ts.map +1 -0
- package/dist/compute/strategies/mixture-of-agents.js +110 -0
- package/dist/compute/strategies/mixture-of-agents.js.map +1 -0
- package/dist/compute/strategies/tree-of-thoughts.d.ts +48 -0
- package/dist/compute/strategies/tree-of-thoughts.d.ts.map +1 -0
- package/dist/compute/strategies/tree-of-thoughts.js +242 -0
- package/dist/compute/strategies/tree-of-thoughts.js.map +1 -0
- package/dist/compute/strategies/two-phase-orient.d.ts +72 -0
- package/dist/compute/strategies/two-phase-orient.d.ts.map +1 -0
- package/dist/compute/strategies/two-phase-orient.js +85 -0
- package/dist/compute/strategies/two-phase-orient.js.map +1 -0
- package/dist/constitution/types.d.ts +10 -10
- package/dist/container/protocol.d.ts +134 -0
- package/dist/container/protocol.d.ts.map +1 -0
- package/dist/container/protocol.js +157 -0
- package/dist/container/protocol.js.map +1 -0
- package/dist/container/runtime.d.ts +140 -0
- package/dist/container/runtime.d.ts.map +1 -0
- package/dist/container/runtime.js +256 -0
- package/dist/container/runtime.js.map +1 -0
- package/dist/events/catalogue.d.ts +327 -30
- package/dist/events/catalogue.d.ts.map +1 -1
- package/dist/events/catalogue.js +18 -0
- package/dist/events/catalogue.js.map +1 -1
- package/dist/events/index.d.ts +9 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +9 -0
- package/dist/events/index.js.map +1 -1
- package/dist/events/schemas/agent.completed.v1.d.ts +4 -4
- package/dist/events/schemas/agent.failed.v1.d.ts +2 -2
- package/dist/events/schemas/agent.hitl_resolved.v1.d.ts +2 -2
- package/dist/events/schemas/agent.started.v1.d.ts +2 -2
- package/dist/events/schemas/brain.skill.extracted.v1.d.ts +4 -4
- package/dist/events/schemas/cc.cost.anomaly_detected.v1.d.ts +2 -2
- package/dist/events/schemas/cc.cost.recorded.v1.d.ts +4 -4
- package/dist/events/schemas/citadel.sprint.analyzed.v1.d.ts +55 -0
- package/dist/events/schemas/citadel.sprint.analyzed.v1.d.ts.map +1 -0
- package/dist/events/schemas/citadel.sprint.analyzed.v1.js +22 -0
- package/dist/events/schemas/citadel.sprint.analyzed.v1.js.map +1 -0
- package/dist/events/schemas/citadel.sprint.closed.v1.d.ts +2 -2
- package/dist/events/schemas/forge.inbox.reply_classified.v1.d.ts +33 -0
- package/dist/events/schemas/forge.inbox.reply_classified.v1.d.ts.map +1 -0
- package/dist/events/schemas/forge.inbox.reply_classified.v1.js +15 -0
- package/dist/events/schemas/forge.inbox.reply_classified.v1.js.map +1 -0
- package/dist/events/schemas/forge.lead.qualified.v1.d.ts +2 -2
- package/dist/events/schemas/forge.outreach.sent.v1.d.ts +4 -4
- package/dist/events/schemas/incident.detected.v1.d.ts +2 -2
- package/dist/events/schemas/vauban-finance.forecast.generated.v1.d.ts +21 -0
- package/dist/events/schemas/vauban-finance.forecast.generated.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban-finance.forecast.generated.v1.js +11 -0
- package/dist/events/schemas/vauban-finance.forecast.generated.v1.js.map +1 -0
- package/dist/events/schemas/vauban-finance.trade.executed.v1.d.ts +24 -0
- package/dist/events/schemas/vauban-finance.trade.executed.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban-finance.trade.executed.v1.js +12 -0
- package/dist/events/schemas/vauban-finance.trade.executed.v1.js.map +1 -0
- package/dist/events/schemas/vauban.goal.checked.v1.d.ts +21 -0
- package/dist/events/schemas/vauban.goal.checked.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban.goal.checked.v1.js +11 -0
- package/dist/events/schemas/vauban.goal.checked.v1.js.map +1 -0
- package/dist/events/schemas/vauban.rebalancing.checked.v1.d.ts +21 -0
- package/dist/events/schemas/vauban.rebalancing.checked.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban.rebalancing.checked.v1.js +11 -0
- package/dist/events/schemas/vauban.rebalancing.checked.v1.js.map +1 -0
- package/dist/events/schemas/vauban.tax.checked.v1.d.ts +21 -0
- package/dist/events/schemas/vauban.tax.checked.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban.tax.checked.v1.js +11 -0
- package/dist/events/schemas/vauban.tax.checked.v1.js.map +1 -0
- package/dist/events/schemas/vauban.vault.analyzed.v1.d.ts +59 -0
- package/dist/events/schemas/vauban.vault.analyzed.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban.vault.analyzed.v1.js +19 -0
- package/dist/events/schemas/vauban.vault.analyzed.v1.js.map +1 -0
- package/dist/events/schemas/vauban.vault.compounded.v1.d.ts +24 -0
- package/dist/events/schemas/vauban.vault.compounded.v1.d.ts.map +1 -0
- package/dist/events/schemas/vauban.vault.compounded.v1.js +12 -0
- package/dist/events/schemas/vauban.vault.compounded.v1.js.map +1 -0
- package/dist/identity/agent-persona.d.ts +73 -0
- package/dist/identity/agent-persona.d.ts.map +1 -0
- package/dist/identity/agent-persona.js +165 -0
- package/dist/identity/agent-persona.js.map +1 -0
- package/dist/identity/persona-prompt.d.ts +25 -0
- package/dist/identity/persona-prompt.d.ts.map +1 -0
- package/dist/identity/persona-prompt.js +71 -0
- package/dist/identity/persona-prompt.js.map +1 -0
- package/dist/identity/persona-schema.d.ts +120 -0
- package/dist/identity/persona-schema.d.ts.map +1 -0
- package/dist/identity/persona-schema.js +103 -0
- package/dist/identity/persona-schema.js.map +1 -0
- package/dist/index.d.ts +37 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/dist/loop/index.d.ts +1 -1
- package/dist/loop/index.d.ts.map +1 -1
- package/dist/loop/index.js.map +1 -1
- package/dist/loop/minimal-loop.js +293 -287
- package/dist/loop/sdk-loop.d.ts +1 -3
- package/dist/loop/sdk-loop.d.ts.map +1 -1
- package/dist/loop/sdk-loop.js +1 -1
- package/dist/loop/sdk-loop.js.map +1 -1
- package/dist/memory/episodic-rrf.d.ts +114 -0
- package/dist/memory/episodic-rrf.d.ts.map +1 -0
- package/dist/memory/episodic-rrf.js +148 -0
- package/dist/memory/episodic-rrf.js.map +1 -0
- package/dist/mesh/attenuation.d.ts +78 -0
- package/dist/mesh/attenuation.d.ts.map +1 -0
- package/dist/mesh/attenuation.js +141 -0
- package/dist/mesh/attenuation.js.map +1 -0
- package/dist/mesh/delegate.d.ts +96 -0
- package/dist/mesh/delegate.d.ts.map +1 -0
- package/dist/mesh/delegate.js +172 -0
- package/dist/mesh/delegate.js.map +1 -0
- package/dist/mesh/dispatcher.d.ts +119 -0
- package/dist/mesh/dispatcher.d.ts.map +1 -0
- package/dist/mesh/dispatcher.js +207 -0
- package/dist/mesh/dispatcher.js.map +1 -0
- package/dist/mesh/index.d.ts +12 -0
- package/dist/mesh/index.d.ts.map +1 -0
- package/dist/mesh/index.js +11 -0
- package/dist/mesh/index.js.map +1 -0
- package/dist/mesh/types.d.ts +30 -0
- package/dist/mesh/types.d.ts.map +1 -0
- package/dist/mesh/types.js +11 -0
- package/dist/mesh/types.js.map +1 -0
- package/dist/orchestration/ooda/skills.d.ts +104 -0
- package/dist/orchestration/ooda/skills.d.ts.map +1 -1
- package/dist/orchestration/ooda/skills.js +106 -0
- package/dist/orchestration/ooda/skills.js.map +1 -1
- package/dist/orchestration/ooda/types.d.ts +3 -8
- package/dist/orchestration/ooda/types.d.ts.map +1 -1
- package/dist/ports/bastion-action.contract.test.d.ts +11 -0
- package/dist/ports/bastion-action.contract.test.d.ts.map +1 -0
- package/dist/ports/bastion-action.contract.test.js +238 -0
- package/dist/ports/bastion-action.contract.test.js.map +1 -0
- package/dist/ports/bastion-action.d.ts +133 -0
- package/dist/ports/bastion-action.d.ts.map +1 -0
- package/dist/ports/bastion-action.js +73 -0
- package/dist/ports/bastion-action.js.map +1 -0
- package/dist/ports/brain.d.ts +31 -0
- package/dist/ports/brain.d.ts.map +1 -1
- package/dist/ports/brain.js +115 -1
- package/dist/ports/brain.js.map +1 -1
- package/dist/ports/citadel-action.contract.test.d.ts +11 -0
- package/dist/ports/citadel-action.contract.test.d.ts.map +1 -0
- package/dist/ports/citadel-action.contract.test.js +317 -0
- package/dist/ports/citadel-action.contract.test.js.map +1 -0
- package/dist/ports/citadel-action.d.ts +111 -0
- package/dist/ports/citadel-action.d.ts.map +1 -0
- package/dist/ports/citadel-action.js +62 -0
- package/dist/ports/citadel-action.js.map +1 -0
- package/dist/ports/compliance-contract.d.ts +123 -0
- package/dist/ports/compliance-contract.d.ts.map +1 -0
- package/dist/ports/compliance-contract.js +35 -0
- package/dist/ports/compliance-contract.js.map +1 -0
- package/dist/ports/db.d.ts +38 -0
- package/dist/ports/db.d.ts.map +1 -1
- package/dist/ports/db.js +88 -1
- package/dist/ports/db.js.map +1 -1
- package/dist/ports/delegation.contract.test.d.ts +9 -0
- package/dist/ports/delegation.contract.test.d.ts.map +1 -0
- package/dist/ports/delegation.contract.test.js +337 -0
- package/dist/ports/delegation.contract.test.js.map +1 -0
- package/dist/ports/delegation.d.ts +134 -0
- package/dist/ports/delegation.d.ts.map +1 -0
- package/dist/ports/delegation.js +105 -0
- package/dist/ports/delegation.js.map +1 -0
- package/dist/ports/event-bus.d.ts +29 -13
- package/dist/ports/event-bus.d.ts.map +1 -1
- package/dist/ports/event-bus.js +106 -1
- package/dist/ports/event-bus.js.map +1 -1
- package/dist/ports/federation.contract.test.d.ts +9 -0
- package/dist/ports/federation.contract.test.d.ts.map +1 -0
- package/dist/ports/federation.contract.test.js +279 -0
- package/dist/ports/federation.contract.test.js.map +1 -0
- package/dist/ports/federation.d.ts +140 -0
- package/dist/ports/federation.d.ts.map +1 -0
- package/dist/ports/federation.js +57 -0
- package/dist/ports/federation.js.map +1 -0
- package/dist/ports/index.d.ts +28 -2
- package/dist/ports/index.d.ts.map +1 -1
- package/dist/ports/index.js +17 -2
- package/dist/ports/index.js.map +1 -1
- package/dist/ports/llm-provider.d.ts +37 -0
- package/dist/ports/llm-provider.d.ts.map +1 -1
- package/dist/ports/llm-provider.js +99 -1
- package/dist/ports/llm-provider.js.map +1 -1
- package/dist/ports/logger.d.ts +27 -0
- package/dist/ports/logger.d.ts.map +1 -1
- package/dist/ports/logger.js +87 -0
- package/dist/ports/logger.js.map +1 -1
- package/dist/ports/manifest-registry.contract.test.d.ts +9 -0
- package/dist/ports/manifest-registry.contract.test.d.ts.map +1 -0
- package/dist/ports/manifest-registry.contract.test.js +246 -0
- package/dist/ports/manifest-registry.contract.test.js.map +1 -0
- package/dist/ports/manifest-registry.d.ts +116 -0
- package/dist/ports/manifest-registry.d.ts.map +1 -0
- package/dist/ports/manifest-registry.js +79 -0
- package/dist/ports/manifest-registry.js.map +1 -0
- package/dist/ports/observability.contract.test.d.ts +12 -0
- package/dist/ports/observability.contract.test.d.ts.map +1 -0
- package/dist/ports/observability.contract.test.js +260 -0
- package/dist/ports/observability.contract.test.js.map +1 -0
- package/dist/ports/observability.d.ts +98 -0
- package/dist/ports/observability.d.ts.map +1 -0
- package/dist/ports/observability.js +59 -0
- package/dist/ports/observability.js.map +1 -0
- package/dist/ports/outcome.d.ts +26 -0
- package/dist/ports/outcome.d.ts.map +1 -1
- package/dist/ports/outcome.js +62 -1
- package/dist/ports/outcome.js.map +1 -1
- package/dist/ports/privacy.contract.test.d.ts +12 -0
- package/dist/ports/privacy.contract.test.d.ts.map +1 -0
- package/dist/ports/privacy.contract.test.js +325 -0
- package/dist/ports/privacy.contract.test.js.map +1 -0
- package/dist/ports/privacy.d.ts +132 -0
- package/dist/ports/privacy.d.ts.map +1 -0
- package/dist/ports/privacy.js +83 -0
- package/dist/ports/privacy.js.map +1 -0
- package/dist/ports/tenant-context.contract.test.d.ts +14 -0
- package/dist/ports/tenant-context.contract.test.d.ts.map +1 -0
- package/dist/ports/tenant-context.contract.test.js +352 -0
- package/dist/ports/tenant-context.contract.test.js.map +1 -0
- package/dist/ports/tenant-context.d.ts +103 -0
- package/dist/ports/tenant-context.d.ts.map +1 -0
- package/dist/ports/tenant-context.js +48 -0
- package/dist/ports/tenant-context.js.map +1 -0
- package/dist/ports/vauban-finance-action.contract.test.d.ts +11 -0
- package/dist/ports/vauban-finance-action.contract.test.d.ts.map +1 -0
- package/dist/ports/vauban-finance-action.contract.test.js +260 -0
- package/dist/ports/vauban-finance-action.contract.test.js.map +1 -0
- package/dist/ports/vauban-finance-action.d.ts +106 -0
- package/dist/ports/vauban-finance-action.d.ts.map +1 -0
- package/dist/ports/vauban-finance-action.js +60 -0
- package/dist/ports/vauban-finance-action.js.map +1 -0
- package/dist/ports/workflow-runtime.d.ts +204 -0
- package/dist/ports/workflow-runtime.d.ts.map +1 -0
- package/dist/ports/workflow-runtime.js +72 -0
- package/dist/ports/workflow-runtime.js.map +1 -0
- package/dist/proof/cert-verify.d.ts +80 -0
- package/dist/proof/cert-verify.d.ts.map +1 -0
- package/dist/proof/cert-verify.js +178 -0
- package/dist/proof/cert-verify.js.map +1 -0
- package/dist/replay/replay.d.ts.map +1 -1
- package/dist/replay/replay.js +5 -1
- package/dist/replay/replay.js.map +1 -1
- package/dist/retry/index.d.ts +129 -0
- package/dist/retry/index.d.ts.map +1 -0
- package/dist/retry/index.js +156 -0
- package/dist/retry/index.js.map +1 -0
- package/dist/retry/presets.d.ts +39 -0
- package/dist/retry/presets.d.ts.map +1 -0
- package/dist/retry/presets.js +69 -0
- package/dist/retry/presets.js.map +1 -0
- package/dist/skill-loop/ab-runner.d.ts +67 -0
- package/dist/skill-loop/ab-runner.d.ts.map +1 -0
- package/dist/skill-loop/ab-runner.js +160 -0
- package/dist/skill-loop/ab-runner.js.map +1 -0
- package/dist/skill-loop/adoption.d.ts +67 -0
- package/dist/skill-loop/adoption.d.ts.map +1 -0
- package/dist/skill-loop/adoption.js +126 -0
- package/dist/skill-loop/adoption.js.map +1 -0
- package/dist/skill-loop/candidate.d.ts +45 -0
- package/dist/skill-loop/candidate.d.ts.map +1 -0
- package/dist/skill-loop/candidate.js +43 -0
- package/dist/skill-loop/candidate.js.map +1 -0
- package/dist/skill-loop/evaluator.d.ts +42 -0
- package/dist/skill-loop/evaluator.d.ts.map +1 -0
- package/dist/skill-loop/evaluator.js +184 -0
- package/dist/skill-loop/evaluator.js.map +1 -0
- package/dist/skill-loop/index.d.ts +27 -0
- package/dist/skill-loop/index.d.ts.map +1 -0
- package/dist/skill-loop/index.js +27 -0
- package/dist/skill-loop/index.js.map +1 -0
- package/dist/skill-loop/reflexion-replay.d.ts +87 -0
- package/dist/skill-loop/reflexion-replay.d.ts.map +1 -0
- package/dist/skill-loop/reflexion-replay.js +110 -0
- package/dist/skill-loop/reflexion-replay.js.map +1 -0
- package/dist/skill-loop/sign-off.d.ts +88 -0
- package/dist/skill-loop/sign-off.d.ts.map +1 -0
- package/dist/skill-loop/sign-off.js +146 -0
- package/dist/skill-loop/sign-off.js.map +1 -0
- package/dist/skill-loop/value-metric.d.ts +55 -0
- package/dist/skill-loop/value-metric.d.ts.map +1 -0
- package/dist/skill-loop/value-metric.js +69 -0
- package/dist/skill-loop/value-metric.js.map +1 -0
- package/dist/skill-loop/versioning.d.ts +36 -0
- package/dist/skill-loop/versioning.d.ts.map +1 -0
- package/dist/skill-loop/versioning.js +47 -0
- package/dist/skill-loop/versioning.js.map +1 -0
- package/dist/skill-manifest/anchor.d.ts +91 -0
- package/dist/skill-manifest/anchor.d.ts.map +1 -0
- package/dist/skill-manifest/anchor.js +331 -0
- package/dist/skill-manifest/anchor.js.map +1 -0
- package/dist/skill-manifest/builder.d.ts +47 -0
- package/dist/skill-manifest/builder.d.ts.map +1 -0
- package/dist/skill-manifest/builder.js +93 -0
- package/dist/skill-manifest/builder.js.map +1 -0
- package/dist/skill-manifest/index.d.ts +13 -0
- package/dist/skill-manifest/index.d.ts.map +1 -0
- package/dist/skill-manifest/index.js +9 -0
- package/dist/skill-manifest/index.js.map +1 -0
- package/dist/skill-manifest/types.d.ts +67 -0
- package/dist/skill-manifest/types.d.ts.map +1 -0
- package/dist/skill-manifest/types.js +16 -0
- package/dist/skill-manifest/types.js.map +1 -0
- package/dist/skill-manifest/verifier.d.ts +42 -0
- package/dist/skill-manifest/verifier.d.ts.map +1 -0
- package/dist/skill-manifest/verifier.js +136 -0
- package/dist/skill-manifest/verifier.js.map +1 -0
- package/dist/skills/brain-query.d.ts +4 -4
- package/dist/skills/brain-store.d.ts +6 -6
- package/dist/skills/errors.d.ts +15 -0
- package/dist/skills/errors.d.ts.map +1 -1
- package/dist/skills/errors.js +21 -0
- package/dist/skills/errors.js.map +1 -1
- package/dist/skills/hitl-request.d.ts +2 -2
- package/dist/skills/index.d.ts +3 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +4 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/markdown/loader.d.ts +52 -0
- package/dist/skills/markdown/loader.d.ts.map +1 -0
- package/dist/skills/markdown/loader.js +93 -0
- package/dist/skills/markdown/loader.js.map +1 -0
- package/dist/skills/markdown/schema.d.ts +432 -0
- package/dist/skills/markdown/schema.d.ts.map +1 -0
- package/dist/skills/markdown/schema.js +121 -0
- package/dist/skills/markdown/schema.js.map +1 -0
- package/dist/skills/poc-md-loader/markdown-loader.d.ts +77 -0
- package/dist/skills/poc-md-loader/markdown-loader.d.ts.map +1 -0
- package/dist/skills/poc-md-loader/markdown-loader.js +125 -0
- package/dist/skills/poc-md-loader/markdown-loader.js.map +1 -0
- package/dist/skills/poc-md-loader/runner.d.ts +24 -0
- package/dist/skills/poc-md-loader/runner.d.ts.map +1 -0
- package/dist/skills/poc-md-loader/runner.js +57 -0
- package/dist/skills/poc-md-loader/runner.js.map +1 -0
- package/dist/skills/poc-md-loader/vitest.poc.config.d.ts +3 -0
- package/dist/skills/poc-md-loader/vitest.poc.config.d.ts.map +1 -0
- package/dist/skills/poc-md-loader/vitest.poc.config.js +13 -0
- package/dist/skills/poc-md-loader/vitest.poc.config.js.map +1 -0
- package/dist/skills/poc-md-loader/web-search/script.d.ts +33 -0
- package/dist/skills/poc-md-loader/web-search/script.d.ts.map +1 -0
- package/dist/skills/poc-md-loader/web-search/script.js +75 -0
- package/dist/skills/poc-md-loader/web-search/script.js.map +1 -0
- package/dist/skills/record-outcome.d.ts +4 -4
- package/dist/skills/send-email.d.ts.map +1 -1
- package/dist/skills/send-email.js +15 -3
- package/dist/skills/send-email.js.map +1 -1
- package/dist/skills/slack-notify.d.ts +4 -4
- package/dist/skills/starknet-balance.d.ts +1 -1
- package/dist/skills/telegram-notify.d.ts +4 -4
- package/dist/skills/web-search.d.ts +1 -1
- package/dist/testing/contracts/event-bus.contract.d.ts.map +1 -1
- package/dist/testing/contracts/event-bus.contract.js +14 -12
- package/dist/testing/contracts/event-bus.contract.js.map +1 -1
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/test-brain-port.d.ts +4 -0
- package/dist/testing/test-brain-port.d.ts.map +1 -1
- package/dist/testing/test-brain-port.js +75 -20
- package/dist/testing/test-brain-port.js.map +1 -1
- package/dist/testing/test-event-bus.d.ts.map +1 -1
- package/dist/testing/test-event-bus.js +89 -36
- package/dist/testing/test-event-bus.js.map +1 -1
- package/dist/trace/schema.d.ts +1 -1
- package/dist/trace/schema.d.ts.map +1 -1
- package/dist/trace/schema.js +1 -1
- package/dist/trace/schema.js.map +1 -1
- package/dist/verify/formal/index.d.ts +44 -0
- package/dist/verify/formal/index.d.ts.map +1 -0
- package/dist/verify/formal/index.js +98 -0
- package/dist/verify/formal/index.js.map +1 -0
- package/dist/verify/formal/policy.d.ts +105 -0
- package/dist/verify/formal/policy.d.ts.map +1 -0
- package/dist/verify/formal/policy.js +159 -0
- package/dist/verify/formal/policy.js.map +1 -0
- package/dist/verify/formal/result.d.ts +50 -0
- package/dist/verify/formal/result.d.ts.map +1 -0
- package/dist/verify/formal/result.js +21 -0
- package/dist/verify/formal/result.js.map +1 -0
- package/dist/verify/formal/solver.d.ts +67 -0
- package/dist/verify/formal/solver.d.ts.map +1 -0
- package/dist/verify/formal/solver.js +184 -0
- package/dist/verify/formal/solver.js.map +1 -0
- package/dist/verify/formal/spec-language.d.ts +80 -0
- package/dist/verify/formal/spec-language.d.ts.map +1 -0
- package/dist/verify/formal/spec-language.js +219 -0
- package/dist/verify/formal/spec-language.js.map +1 -0
- package/docs/attestation.md +199 -0
- package/docs/identity.md +193 -0
- package/package.json +22 -1
- package/src/adapters/llm/anthropic-direct.ts +51 -0
- package/src/adapters/llm/cascade.ts +64 -19
- package/src/adapters/llm/litellm.ts +49 -0
- package/src/compute/difficulty-estimator.ts +111 -0
- package/src/compute/strategies/mixture-of-agents.ts +150 -0
- package/src/compute/strategies/tree-of-thoughts.ts +293 -0
- package/src/compute/strategies/two-phase-orient.ts +147 -0
- package/src/container/protocol.ts +243 -0
- package/src/container/runtime.ts +424 -0
- package/src/db/migrations/026_formal_verify_results.sql +30 -0
- package/src/events/catalogue.ts +54 -0
- package/src/events/index.ts +9 -0
- package/src/events/schemas/citadel.sprint.analyzed.v1.ts +23 -0
- package/src/events/schemas/forge.inbox.reply_classified.v1.ts +15 -0
- package/src/events/schemas/vauban-finance.forecast.generated.v1.ts +11 -0
- package/src/events/schemas/vauban-finance.trade.executed.v1.ts +12 -0
- package/src/events/schemas/vauban.goal.checked.v1.ts +11 -0
- package/src/events/schemas/vauban.rebalancing.checked.v1.ts +11 -0
- package/src/events/schemas/vauban.tax.checked.v1.ts +11 -0
- package/src/events/schemas/vauban.vault.analyzed.v1.ts +21 -0
- package/src/events/schemas/vauban.vault.compounded.v1.ts +12 -0
- package/src/identity/agent-persona.ts +203 -0
- package/src/identity/persona-prompt.ts +84 -0
- package/src/identity/persona-schema.ts +127 -0
- package/src/index.ts +338 -1
- package/src/loop/index.ts +0 -1
- package/src/loop/sdk-loop.ts +5 -8
- package/src/memory/episodic-rrf.ts +224 -0
- package/src/mesh/attenuation.ts +190 -0
- package/src/mesh/delegate.ts +254 -0
- package/src/mesh/dispatcher.ts +301 -0
- package/src/mesh/index.ts +39 -0
- package/src/mesh/types.ts +31 -0
- package/src/orchestration/ooda/skills.ts +177 -0
- package/src/orchestration/ooda/types.ts +3 -9
- package/src/ports/bastion-action.contract.test.ts +355 -0
- package/src/ports/bastion-action.ts +198 -0
- package/src/ports/brain.ts +177 -15
- package/src/ports/citadel-action.contract.test.ts +430 -0
- package/src/ports/citadel-action.ts +174 -0
- package/src/ports/compliance-contract.ts +191 -0
- package/src/ports/db.ts +98 -0
- package/src/ports/delegation.contract.test.ts +428 -0
- package/src/ports/delegation.ts +211 -0
- package/src/ports/event-bus.ts +133 -18
- package/src/ports/federation.contract.test.ts +355 -0
- package/src/ports/federation.ts +190 -0
- package/src/ports/index.ts +186 -1
- package/src/ports/llm-provider.ts +123 -0
- package/src/ports/logger.ts +104 -0
- package/src/ports/manifest-registry.contract.test.ts +324 -0
- package/src/ports/manifest-registry.ts +188 -0
- package/src/ports/observability.contract.test.ts +315 -0
- package/src/ports/observability.ts +150 -0
- package/src/ports/outcome.ts +69 -0
- package/src/ports/privacy.contract.test.ts +413 -0
- package/src/ports/privacy.ts +207 -0
- package/src/ports/tenant-context.contract.test.ts +454 -0
- package/src/ports/tenant-context.ts +150 -0
- package/src/ports/vauban-finance-action.contract.test.ts +335 -0
- package/src/ports/vauban-finance-action.ts +166 -0
- package/src/ports/workflow-runtime.ts +327 -0
- package/src/proof/cert-verify.ts +249 -0
- package/src/replay/replay.ts +11 -8
- package/src/retry/index.ts +227 -0
- package/src/retry/presets.ts +75 -0
- package/src/skill-loop/ab-runner.ts +196 -0
- package/src/skill-loop/adoption.ts +188 -0
- package/src/skill-loop/candidate.ts +75 -0
- package/src/skill-loop/evaluator.ts +238 -0
- package/src/skill-loop/index.ts +51 -0
- package/src/skill-loop/reflexion-replay.ts +173 -0
- package/src/skill-loop/sign-off.ts +247 -0
- package/src/skill-loop/value-metric.ts +120 -0
- package/src/skill-loop/versioning.ts +75 -0
- package/src/skill-manifest/anchor.ts +401 -0
- package/src/skill-manifest/builder.ts +129 -0
- package/src/skill-manifest/index.ts +18 -0
- package/src/skill-manifest/types.ts +72 -0
- package/src/skill-manifest/verifier.ts +198 -0
- package/src/skills/errors.ts +30 -2
- package/src/skills/index.ts +19 -0
- package/src/skills/markdown/loader.ts +129 -0
- package/src/skills/markdown/schema.ts +144 -0
- package/src/skills/poc-md-loader/e2e-parity.test.ts +237 -0
- package/src/skills/poc-md-loader/markdown-loader.ts +161 -0
- package/src/skills/poc-md-loader/runner.ts +82 -0
- package/src/skills/poc-md-loader/vitest.poc.config.ts +13 -0
- package/src/skills/poc-md-loader/web-search/SKILL.md +42 -0
- package/src/skills/poc-md-loader/web-search/script.ts +109 -0
- package/src/skills/send-email.ts +15 -3
- package/src/testing/contracts/event-bus.contract.ts +16 -14
- package/src/testing/test-brain-port.ts +98 -24
- package/src/testing/test-event-bus.ts +104 -43
- package/src/trace/schema.ts +1 -1
- package/src/verify/formal/index.ts +154 -0
- package/src/verify/formal/policy.ts +253 -0
- package/src/verify/formal/result.ts +52 -0
- package/src/verify/formal/solver.ts +235 -0
- package/src/verify/formal/spec-language.ts +274 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/mesh/dispatcher.ts
|
|
3
|
+
*
|
|
4
|
+
* Mesh dispatcher — routes a {@link DispatchIntent} to a concrete executor
|
|
5
|
+
* (LLM, OODA, MCP tool, plugin, fallback) and returns a uniform result shape.
|
|
6
|
+
*
|
|
7
|
+
* @experimental — sprint-585. Public API may change before v1.x freeze.
|
|
8
|
+
*
|
|
9
|
+
* The dispatcher knows NOTHING about budget tokens or capability attenuation —
|
|
10
|
+
* those concerns live in `delegate.ts`. Keep this module narrowly scoped to
|
|
11
|
+
* "given an intent kind, run the right executor".
|
|
12
|
+
*
|
|
13
|
+
* Default classifier is a heuristic (no LLM call). Callers may inject their own.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { MeshAgentKind } from "./types.js";
|
|
17
|
+
|
|
18
|
+
// ─── Public types ────────────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
export interface DispatchIntent {
|
|
21
|
+
/** Resolved kind — caller (or default classifier) decided which executor to use. */
|
|
22
|
+
readonly kind: MeshAgentKind;
|
|
23
|
+
/** Natural-language need. */
|
|
24
|
+
readonly need: string;
|
|
25
|
+
/** Optional context (structured data stringified, or free text). */
|
|
26
|
+
readonly context?: string;
|
|
27
|
+
/** Wall-clock deadline in ms. */
|
|
28
|
+
readonly deadline_ms?: number;
|
|
29
|
+
/** Max cost in EUR. */
|
|
30
|
+
readonly max_cost_eur?: number;
|
|
31
|
+
/** Optional MCP tool name (only used when kind === "mcp-tool"). */
|
|
32
|
+
readonly toolName?: string;
|
|
33
|
+
/** Opaque MCP tool args (only used when kind === "mcp-tool"). */
|
|
34
|
+
readonly toolArgs?: unknown;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface DispatchResult {
|
|
38
|
+
readonly output: string;
|
|
39
|
+
readonly costEur: number;
|
|
40
|
+
readonly durationMs: number;
|
|
41
|
+
/** True if the executor stopped on deadline before producing a final answer. */
|
|
42
|
+
readonly truncated: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface MeshDispatcher {
|
|
46
|
+
dispatch(intent: DispatchIntent): Promise<DispatchResult>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ─── Classifier (heuristic, no LLM) ──────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Tokens that suggest a long-running observation/audit loop → OODA.
|
|
53
|
+
* Order-stable, lowercase, word-boundary matched in {@link defaultClassifier}.
|
|
54
|
+
*/
|
|
55
|
+
const OODA_HINTS = [
|
|
56
|
+
"scan",
|
|
57
|
+
"audit",
|
|
58
|
+
"monitor",
|
|
59
|
+
"watch",
|
|
60
|
+
"step by step",
|
|
61
|
+
"analyze then",
|
|
62
|
+
"investigate",
|
|
63
|
+
"diagnose",
|
|
64
|
+
"post-mortem",
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Tokens that suggest a single tool call → MCP tool dispatch.
|
|
69
|
+
*/
|
|
70
|
+
const MCP_HINTS = [
|
|
71
|
+
"get price",
|
|
72
|
+
"fetch",
|
|
73
|
+
"call api",
|
|
74
|
+
"lookup",
|
|
75
|
+
"read contract",
|
|
76
|
+
"check balance",
|
|
77
|
+
"get_",
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Default heuristic classifier — zero LLM cost.
|
|
82
|
+
*
|
|
83
|
+
* - OODA when need contains an OODA hint OR has ≥ 3 sentence-terminating marks.
|
|
84
|
+
* - MCP-tool when need contains an MCP hint and is short (< 80 chars).
|
|
85
|
+
* - LLM-router otherwise.
|
|
86
|
+
*
|
|
87
|
+
* Note: callers wanting LLM-based classification should inject a custom
|
|
88
|
+
* `classifier` via {@link DispatcherConfig}.
|
|
89
|
+
*/
|
|
90
|
+
export function defaultClassifier(need: string): MeshAgentKind {
|
|
91
|
+
const n = need.toLowerCase().trim();
|
|
92
|
+
if (n.length === 0) return "llm-router";
|
|
93
|
+
|
|
94
|
+
for (const hint of OODA_HINTS) {
|
|
95
|
+
if (n.includes(hint)) return "ooda";
|
|
96
|
+
}
|
|
97
|
+
// 3+ sentence terminators = multi-step instruction → OODA.
|
|
98
|
+
const terminators = (n.match(/[.!?]/g) ?? []).length;
|
|
99
|
+
if (terminators >= 3) return "ooda";
|
|
100
|
+
|
|
101
|
+
if (n.length < 80) {
|
|
102
|
+
for (const hint of MCP_HINTS) {
|
|
103
|
+
if (n.includes(hint)) return "mcp-tool";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return "llm-router";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ─── DispatcherConfig & DefaultMeshDispatcher ────────────────────────────────
|
|
111
|
+
|
|
112
|
+
export interface DispatcherConfig {
|
|
113
|
+
/** Override the default heuristic classifier. */
|
|
114
|
+
readonly classifier?: (need: string) => MeshAgentKind;
|
|
115
|
+
/**
|
|
116
|
+
* Executor for `kind === "llm-router"`.
|
|
117
|
+
* Must respect `deadline_ms` (caller-provided).
|
|
118
|
+
*/
|
|
119
|
+
readonly llmExecutor?: (prompt: string, deadlineMs: number) => Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* Executor for `kind === "ooda"`. Receives need + optional context.
|
|
122
|
+
* Must respect `deadline_ms` (passed via 3rd arg).
|
|
123
|
+
*/
|
|
124
|
+
readonly oodaExecutor?: (
|
|
125
|
+
need: string,
|
|
126
|
+
context: string | undefined,
|
|
127
|
+
deadlineMs: number,
|
|
128
|
+
) => Promise<string>;
|
|
129
|
+
/**
|
|
130
|
+
* Registry of MCP tools. Keyed by tool name; values are pre-bound async fns.
|
|
131
|
+
*/
|
|
132
|
+
readonly mcpTools?: Readonly<Record<string, (args: unknown) => Promise<string>>>;
|
|
133
|
+
/**
|
|
134
|
+
* Optional plugin executor (last-resort, kind === "plugin").
|
|
135
|
+
*/
|
|
136
|
+
readonly pluginExecutor?: (need: string, context: string | undefined) => Promise<string>;
|
|
137
|
+
/**
|
|
138
|
+
* Fallback executor when no other kind matches. Default: echoes need.
|
|
139
|
+
*/
|
|
140
|
+
readonly fallbackExecutor?: (intent: DispatchIntent) => Promise<string>;
|
|
141
|
+
/**
|
|
142
|
+
* Cost model in EUR per millisecond. Default 0 (free-tier accounting).
|
|
143
|
+
* Production: inject a model that consults `tracking/provider-usage`.
|
|
144
|
+
*/
|
|
145
|
+
readonly costPerMs?: number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const DEFAULT_DEADLINE_MS = 30_000;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Default dispatcher — composes injected executors into a uniform
|
|
152
|
+
* "intent → result" pipeline, including deadline enforcement and cost
|
|
153
|
+
* accounting.
|
|
154
|
+
*
|
|
155
|
+
* Concurrency notes:
|
|
156
|
+
* - Uses `AbortController` + `setTimeout` to enforce `deadline_ms`.
|
|
157
|
+
* - On deadline trip, returns `truncated: true` and the executor must respect
|
|
158
|
+
* the abort signal it received via Promise.race.
|
|
159
|
+
*/
|
|
160
|
+
export class DefaultMeshDispatcher implements MeshDispatcher {
|
|
161
|
+
private readonly classifier: (need: string) => MeshAgentKind;
|
|
162
|
+
private readonly llm: NonNullable<DispatcherConfig["llmExecutor"]>;
|
|
163
|
+
private readonly ooda: NonNullable<DispatcherConfig["oodaExecutor"]>;
|
|
164
|
+
private readonly mcpTools: Readonly<Record<string, (args: unknown) => Promise<string>>>;
|
|
165
|
+
private readonly plugin: NonNullable<DispatcherConfig["pluginExecutor"]>;
|
|
166
|
+
private readonly fallback: NonNullable<DispatcherConfig["fallbackExecutor"]>;
|
|
167
|
+
private readonly costPerMs: number;
|
|
168
|
+
|
|
169
|
+
constructor(config: DispatcherConfig = {}) {
|
|
170
|
+
this.classifier = config.classifier ?? defaultClassifier;
|
|
171
|
+
this.llm =
|
|
172
|
+
config.llmExecutor ?? (async (prompt) => `[llm-router stub] ${prompt.slice(0, 200)}`);
|
|
173
|
+
this.ooda = config.oodaExecutor ?? (async (need) => `[ooda stub] ${need.slice(0, 200)}`);
|
|
174
|
+
this.mcpTools = config.mcpTools ?? {};
|
|
175
|
+
this.plugin = config.pluginExecutor ?? (async (need) => `[plugin stub] ${need.slice(0, 200)}`);
|
|
176
|
+
this.fallback = config.fallbackExecutor ?? (async (i) => `[fallback] ${i.need.slice(0, 200)}`);
|
|
177
|
+
this.costPerMs = config.costPerMs ?? 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Classify a need without dispatching — exposed for callers that pre-route. */
|
|
181
|
+
classify(need: string): MeshAgentKind {
|
|
182
|
+
return this.classifier(need);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async dispatch(intent: DispatchIntent): Promise<DispatchResult> {
|
|
186
|
+
const deadlineMs = intent.deadline_ms ?? DEFAULT_DEADLINE_MS;
|
|
187
|
+
if (!Number.isFinite(deadlineMs) || deadlineMs <= 0) {
|
|
188
|
+
throw new RangeError(
|
|
189
|
+
`DefaultMeshDispatcher.dispatch: deadline_ms must be > 0, got ${deadlineMs}`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
const maxCost = intent.max_cost_eur ?? Number.POSITIVE_INFINITY;
|
|
193
|
+
if (maxCost < 0) {
|
|
194
|
+
throw new RangeError(
|
|
195
|
+
`DefaultMeshDispatcher.dispatch: max_cost_eur must be ≥ 0, got ${maxCost}`,
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const start = performance.now();
|
|
200
|
+
const exec = this.executorFor(intent);
|
|
201
|
+
|
|
202
|
+
let truncated = false;
|
|
203
|
+
let output: string;
|
|
204
|
+
try {
|
|
205
|
+
output = await this.runWithDeadline(exec, deadlineMs);
|
|
206
|
+
} catch (err) {
|
|
207
|
+
if (err instanceof DeadlineExceededError) {
|
|
208
|
+
truncated = true;
|
|
209
|
+
output = err.partial ?? "";
|
|
210
|
+
} else {
|
|
211
|
+
throw err;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const durationMs = performance.now() - start;
|
|
216
|
+
const costEur = Math.min(maxCost, durationMs * this.costPerMs);
|
|
217
|
+
|
|
218
|
+
return { output, costEur, durationMs, truncated };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ─── internals ─────────────────────────────────────────────────────────────
|
|
222
|
+
|
|
223
|
+
private executorFor(intent: DispatchIntent): () => Promise<string> {
|
|
224
|
+
const deadlineMs = intent.deadline_ms ?? DEFAULT_DEADLINE_MS;
|
|
225
|
+
switch (intent.kind) {
|
|
226
|
+
case "llm-router": {
|
|
227
|
+
const prompt = intent.context
|
|
228
|
+
? `${intent.need}\n\n[context]\n${intent.context}`
|
|
229
|
+
: intent.need;
|
|
230
|
+
return () => this.llm(prompt, deadlineMs);
|
|
231
|
+
}
|
|
232
|
+
case "ooda":
|
|
233
|
+
return () => this.ooda(intent.need, intent.context, deadlineMs);
|
|
234
|
+
case "mcp-tool": {
|
|
235
|
+
const name = intent.toolName;
|
|
236
|
+
if (!name) {
|
|
237
|
+
return async () => {
|
|
238
|
+
throw new MeshDispatchError(
|
|
239
|
+
"mcp-tool intent missing toolName",
|
|
240
|
+
"MCP_TOOL_NAME_MISSING",
|
|
241
|
+
);
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
const tool = this.mcpTools[name];
|
|
245
|
+
if (!tool) {
|
|
246
|
+
return async () => {
|
|
247
|
+
throw new MeshDispatchError(`mcp-tool "${name}" not registered`, "MCP_TOOL_NOT_FOUND");
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
return () => tool(intent.toolArgs);
|
|
251
|
+
}
|
|
252
|
+
case "plugin":
|
|
253
|
+
return () => this.plugin(intent.need, intent.context);
|
|
254
|
+
case "fallback":
|
|
255
|
+
return () => this.fallback(intent);
|
|
256
|
+
default: {
|
|
257
|
+
const _exhaustive: never = intent.kind;
|
|
258
|
+
return async () => {
|
|
259
|
+
throw new MeshDispatchError(
|
|
260
|
+
`Unknown intent kind: ${String(_exhaustive)}`,
|
|
261
|
+
"UNKNOWN_KIND",
|
|
262
|
+
);
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private async runWithDeadline(exec: () => Promise<string>, deadlineMs: number): Promise<string> {
|
|
269
|
+
let timeoutHandle: ReturnType<typeof setTimeout> | undefined;
|
|
270
|
+
const timeout = new Promise<never>((_, reject) => {
|
|
271
|
+
timeoutHandle = setTimeout(() => {
|
|
272
|
+
reject(new DeadlineExceededError(deadlineMs));
|
|
273
|
+
}, deadlineMs);
|
|
274
|
+
});
|
|
275
|
+
try {
|
|
276
|
+
return await Promise.race([exec(), timeout]);
|
|
277
|
+
} finally {
|
|
278
|
+
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// ─── Errors ──────────────────────────────────────────────────────────────────
|
|
284
|
+
|
|
285
|
+
export class DeadlineExceededError extends Error {
|
|
286
|
+
override readonly name = "MeshDeadlineExceededError";
|
|
287
|
+
readonly partial?: string;
|
|
288
|
+
constructor(deadlineMs: number, partial?: string) {
|
|
289
|
+
super(`mesh.dispatch: deadline ${deadlineMs}ms exceeded`);
|
|
290
|
+
this.partial = partial;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export class MeshDispatchError extends Error {
|
|
295
|
+
override readonly name = "MeshDispatchError";
|
|
296
|
+
readonly code: string;
|
|
297
|
+
constructor(message: string, code: string) {
|
|
298
|
+
super(message);
|
|
299
|
+
this.code = code;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/mesh/index.ts
|
|
3
|
+
*
|
|
4
|
+
* Public barrel for the mesh.delegate() surface (sprint-585).
|
|
5
|
+
*
|
|
6
|
+
* @experimental — API may change before v1.x freeze.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
attenuateScope,
|
|
11
|
+
buildToken,
|
|
12
|
+
parseToken,
|
|
13
|
+
scopeAllows,
|
|
14
|
+
type AttenuatedToken,
|
|
15
|
+
type CapabilityScope,
|
|
16
|
+
type MeshCapabilityScope,
|
|
17
|
+
} from "./attenuation.js";
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
DefaultMeshDispatcher,
|
|
21
|
+
DeadlineExceededError as MeshDeadlineExceededError,
|
|
22
|
+
MeshDispatchError,
|
|
23
|
+
defaultClassifier,
|
|
24
|
+
type DispatchIntent,
|
|
25
|
+
type DispatchResult,
|
|
26
|
+
type DispatcherConfig,
|
|
27
|
+
type MeshDispatcher,
|
|
28
|
+
} from "./dispatcher.js";
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
DelegateAttenuationError,
|
|
32
|
+
createMeshDelegate,
|
|
33
|
+
meshDelegate,
|
|
34
|
+
type DelegateChunk,
|
|
35
|
+
type DelegateOptions,
|
|
36
|
+
type DelegateResult,
|
|
37
|
+
} from "./delegate.js";
|
|
38
|
+
|
|
39
|
+
export type { DelegationLink, MeshAgentKind } from "./types.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/mesh/types.ts
|
|
3
|
+
*
|
|
4
|
+
* Shared types for mesh.delegate() and dispatcher.
|
|
5
|
+
*
|
|
6
|
+
* @experimental — sprint-585. Renamed from "AgentKind" to "MeshAgentKind" to
|
|
7
|
+
* avoid clash with `registry/agent-capability.ts::AgentKind` (which uses
|
|
8
|
+
* uppercase enum values ARCHITECT/BUILDER/...).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Kind of executor selected by the dispatcher.
|
|
13
|
+
* - `"ooda"` : long-running Observe→Orient→Decide→Act loop
|
|
14
|
+
* - `"llm-router"` : single LLM call (single-shot or BoN-MAV)
|
|
15
|
+
* - `"mcp-tool"` : direct MCP tool invocation
|
|
16
|
+
* - `"plugin"` : in-process plugin executor
|
|
17
|
+
* - `"fallback"` : last-resort echo / static handler
|
|
18
|
+
*/
|
|
19
|
+
export type MeshAgentKind = "ooda" | "llm-router" | "mcp-tool" | "plugin" | "fallback";
|
|
20
|
+
|
|
21
|
+
/** One step of the delegation chain (audit trail for capability narrowing). */
|
|
22
|
+
export interface DelegationLink {
|
|
23
|
+
/** Parent / delegator agent identifier. */
|
|
24
|
+
readonly from: string;
|
|
25
|
+
/** Child / delegatee agent identifier. */
|
|
26
|
+
readonly to: string;
|
|
27
|
+
/** Scope handed down (subset of parent's scope). */
|
|
28
|
+
readonly scope: ReadonlyArray<string>;
|
|
29
|
+
/** Budget handed down in EUR. */
|
|
30
|
+
readonly budget: number;
|
|
31
|
+
}
|
|
@@ -16,6 +16,92 @@
|
|
|
16
16
|
import type { DbClient } from "../../tracking/agent-run-tracker.js";
|
|
17
17
|
import type { LoggerPort } from "../../ports/logger.js";
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Secrets access surface handed to skills. Implementations MUST track every
|
|
21
|
+
* lookup in `accessedSecrets` so callers can audit which secrets a skill
|
|
22
|
+
* actually consumed (required for ADR-ECO-027 proof-grade tripartite and
|
|
23
|
+
* future VPSF skill attestations).
|
|
24
|
+
*
|
|
25
|
+
* @public @since 1.2.0
|
|
26
|
+
*/
|
|
27
|
+
export interface SecretsAccessor {
|
|
28
|
+
/**
|
|
29
|
+
* Get a secret by name. Returns `defaultValue` if missing and provided;
|
|
30
|
+
* otherwise throws when `defaultValue` is undefined and the secret is
|
|
31
|
+
* not configured. Implementations MUST record the lookup in
|
|
32
|
+
* {@link accessedSecrets} regardless of outcome.
|
|
33
|
+
*/
|
|
34
|
+
get(name: string, defaultValue?: string): string;
|
|
35
|
+
/** Whether a secret with this name is available. Counts as access. */
|
|
36
|
+
has(name: string): boolean;
|
|
37
|
+
/** Set of secret names the skill actually consulted during this invocation. */
|
|
38
|
+
readonly accessedSecrets: ReadonlySet<string>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Error thrown by {@link InMemorySecretsAccessor} when a secret is requested
|
|
43
|
+
* without a default value and is not configured.
|
|
44
|
+
*
|
|
45
|
+
* @public @since 1.2.0
|
|
46
|
+
*/
|
|
47
|
+
export class SecretNotFoundError extends Error {
|
|
48
|
+
readonly secretName: string;
|
|
49
|
+
constructor(secretName: string) {
|
|
50
|
+
super(`secret '${secretName}' is not configured`);
|
|
51
|
+
this.name = "SecretNotFoundError";
|
|
52
|
+
this.secretName = secretName;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* In-memory {@link SecretsAccessor} suitable for tests and ephemeral
|
|
58
|
+
* runtimes. Production hosts can implement their own accessor backed by
|
|
59
|
+
* Vault, SOPS, or k8s SealedSecrets while preserving the audit semantics.
|
|
60
|
+
*
|
|
61
|
+
* @public @since 1.2.0
|
|
62
|
+
*/
|
|
63
|
+
export class InMemorySecretsAccessor implements SecretsAccessor {
|
|
64
|
+
private readonly store: ReadonlyMap<string, string>;
|
|
65
|
+
private readonly accessed: Set<string> = new Set();
|
|
66
|
+
|
|
67
|
+
constructor(secrets: Readonly<Record<string, string>> = {}) {
|
|
68
|
+
this.store = new Map(Object.entries(secrets));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get(name: string, defaultValue?: string): string {
|
|
72
|
+
this.accessed.add(name);
|
|
73
|
+
const value = this.store.get(name);
|
|
74
|
+
if (value !== undefined) return value;
|
|
75
|
+
if (defaultValue !== undefined) return defaultValue;
|
|
76
|
+
throw new SecretNotFoundError(name);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
has(name: string): boolean {
|
|
80
|
+
this.accessed.add(name);
|
|
81
|
+
return this.store.has(name);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get accessedSecrets(): ReadonlySet<string> {
|
|
85
|
+
return this.accessed;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Noop accessor — used as default for skills that declare no secrets.
|
|
91
|
+
* Always returns `defaultValue` when provided, otherwise throws.
|
|
92
|
+
*
|
|
93
|
+
* @public @since 1.2.0
|
|
94
|
+
*/
|
|
95
|
+
export const NOOP_SECRETS: SecretsAccessor = new InMemorySecretsAccessor();
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Progress callback invoked by skills via `ctx.progress(value, message?)`.
|
|
99
|
+
* `value` is clamped into `[0, 1]` by implementations.
|
|
100
|
+
*
|
|
101
|
+
* @public @since 1.2.0
|
|
102
|
+
*/
|
|
103
|
+
export type ProgressCallback = (value: number, message?: string) => void;
|
|
104
|
+
|
|
19
105
|
/**
|
|
20
106
|
* Context handed to each skill invocation.
|
|
21
107
|
*
|
|
@@ -23,14 +109,105 @@ import type { LoggerPort } from "../../ports/logger.js";
|
|
|
23
109
|
* the skill must short-circuit and emit no observable mutation (no LLM
|
|
24
110
|
* call, no HTTP, no DB INSERT). This guarantees replay safety for the
|
|
25
111
|
* OODA cycle log.
|
|
112
|
+
*
|
|
113
|
+
* Fields added in SDK v1.2.0 (executionId, secrets, progress,
|
|
114
|
+
* elapsedSeconds, remainingSeconds) are OPTIONAL by design — existing
|
|
115
|
+
* skills compile unchanged. New skills can opt in via the
|
|
116
|
+
* {@link createSkillContext} factory.
|
|
26
117
|
*/
|
|
27
118
|
export interface SkillContext {
|
|
28
119
|
readonly isReplay: boolean;
|
|
29
120
|
readonly dryRunMocks: Record<string, (input: unknown) => unknown>;
|
|
30
121
|
readonly db: DbClient;
|
|
31
122
|
readonly logger: LoggerPort;
|
|
123
|
+
/** Unique invocation identifier. Optional for backwards compatibility. */
|
|
124
|
+
readonly executionId?: string;
|
|
125
|
+
/** Audit-trail-bearing secret access. Defaults to {@link NOOP_SECRETS}. */
|
|
126
|
+
readonly secrets?: SecretsAccessor;
|
|
127
|
+
/** Report execution progress in [0, 1]. Noop when absent. */
|
|
128
|
+
readonly progress?: ProgressCallback;
|
|
129
|
+
/** Seconds since invocation began. Returns 0 when not tracked. */
|
|
130
|
+
readonly elapsedSeconds?: number;
|
|
131
|
+
/** Seconds remaining until timeout. Returns +Infinity when not tracked. */
|
|
132
|
+
readonly remainingSeconds?: number;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Options for {@link createSkillContext}.
|
|
137
|
+
*
|
|
138
|
+
* @public @since 1.2.0
|
|
139
|
+
*/
|
|
140
|
+
export interface CreateSkillContextOptions {
|
|
141
|
+
isReplay?: boolean;
|
|
142
|
+
dryRunMocks?: Record<string, (input: unknown) => unknown>;
|
|
143
|
+
db: DbClient;
|
|
144
|
+
logger: LoggerPort;
|
|
145
|
+
executionId?: string;
|
|
146
|
+
secrets?: SecretsAccessor;
|
|
147
|
+
progress?: ProgressCallback;
|
|
148
|
+
/** Absolute timeout in seconds; used to compute remainingSeconds. Default: +Infinity. */
|
|
149
|
+
timeoutSeconds?: number;
|
|
150
|
+
/** Reference Date for elapsed/remaining computation. Default: new Date(). */
|
|
151
|
+
startedAt?: Date;
|
|
32
152
|
}
|
|
33
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Build a {@link SkillContext} with sane defaults for the optional fields.
|
|
156
|
+
* Useful for hosts that want a uniform context without writing the boilerplate.
|
|
157
|
+
*
|
|
158
|
+
* Time accessors are LIVE — `elapsedSeconds` and `remainingSeconds` are
|
|
159
|
+
* recomputed on each property read, so a skill that loops can observe them
|
|
160
|
+
* decreasing without rebuilding the context.
|
|
161
|
+
*
|
|
162
|
+
* @public @since 1.2.0
|
|
163
|
+
*/
|
|
164
|
+
export function createSkillContext(
|
|
165
|
+
opts: CreateSkillContextOptions
|
|
166
|
+
): SkillContext {
|
|
167
|
+
const startedAt = opts.startedAt ?? new Date();
|
|
168
|
+
const timeoutSeconds = opts.timeoutSeconds ?? Number.POSITIVE_INFINITY;
|
|
169
|
+
const secrets = opts.secrets ?? NOOP_SECRETS;
|
|
170
|
+
const progressFn = opts.progress ?? noopProgress;
|
|
171
|
+
|
|
172
|
+
const ctx: SkillContext = {
|
|
173
|
+
isReplay: opts.isReplay ?? false,
|
|
174
|
+
dryRunMocks: opts.dryRunMocks ?? {},
|
|
175
|
+
db: opts.db,
|
|
176
|
+
logger: opts.logger,
|
|
177
|
+
secrets,
|
|
178
|
+
progress: (value, message) => {
|
|
179
|
+
const clamped = clampProgress(value);
|
|
180
|
+
progressFn(clamped, message);
|
|
181
|
+
},
|
|
182
|
+
get elapsedSeconds() {
|
|
183
|
+
return Math.max(0, (Date.now() - startedAt.getTime()) / 1000);
|
|
184
|
+
},
|
|
185
|
+
get remainingSeconds() {
|
|
186
|
+
if (!Number.isFinite(timeoutSeconds)) return Number.POSITIVE_INFINITY;
|
|
187
|
+
const elapsed = (Date.now() - startedAt.getTime()) / 1000;
|
|
188
|
+
return Math.max(0, timeoutSeconds - elapsed);
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
if (opts.executionId !== undefined) {
|
|
192
|
+
Object.defineProperty(ctx, "executionId", {
|
|
193
|
+
value: opts.executionId,
|
|
194
|
+
writable: false,
|
|
195
|
+
enumerable: true,
|
|
196
|
+
configurable: false,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return ctx;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function clampProgress(value: number): number {
|
|
203
|
+
if (!Number.isFinite(value)) return 0;
|
|
204
|
+
if (value < 0) return 0;
|
|
205
|
+
if (value > 1) return 1;
|
|
206
|
+
return value;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const noopProgress: ProgressCallback = () => {};
|
|
210
|
+
|
|
34
211
|
/**
|
|
35
212
|
* Skill — single named callable unit invoked from an OODA phase.
|
|
36
213
|
*
|
|
@@ -250,16 +250,10 @@ export interface OODAAgentConfig<
|
|
|
250
250
|
/**
|
|
251
251
|
* Port dependencies injected at boot (BYOM — plan v6 §3.7).
|
|
252
252
|
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* When `SDK_STRICT_DEPS !== "false"` (default), boot validation throws
|
|
257
|
-
* `MissingDependencyError` if this field is absent or `deps.llm` is missing.
|
|
258
|
-
*
|
|
259
|
-
* @deprecated Omitting `deps` is supported only in legacy mode. Will be required in 1.0.
|
|
253
|
+
* Required since SDK 1.0. Boot validation throws `MissingDependencyError`
|
|
254
|
+
* if this field is absent or `deps.llm` is missing.
|
|
260
255
|
*/
|
|
261
|
-
|
|
262
|
-
readonly deps?: OODAAgentDeps;
|
|
256
|
+
readonly deps: OODAAgentDeps;
|
|
263
257
|
|
|
264
258
|
readonly phases: {
|
|
265
259
|
readonly observe: PhaseDef<void, TObs>;
|