@vauban-org/agent-sdk 1.0.0 → 1.3.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 +6918 -742
- 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 +46 -46
- 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 +6 -6
- package/dist/events/schemas/citadel.sprint.closed.v1.d.ts +2 -2
- package/dist/events/schemas/forge.inbox.reply_classified.v1.d.ts +6 -6
- 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.goal.checked.v1.d.ts +2 -2
- package/dist/events/schemas/vauban.rebalancing.checked.v1.d.ts +2 -2
- package/dist/events/schemas/vauban.tax.checked.v1.d.ts +2 -2
- package/dist/events/schemas/vauban.vault.analyzed.v1.d.ts +6 -6
- 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 +41 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -1
- package/dist/index.js.map +1 -1
- package/dist/loop/minimal-loop.js +293 -287
- 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/agent.d.ts.map +1 -1
- package/dist/orchestration/ooda/agent.js +36 -0
- package/dist/orchestration/ooda/agent.js.map +1 -1
- 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 +11 -0
- 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 -0
- 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/_secrets.d.ts +16 -0
- package/dist/skills/_secrets.d.ts.map +1 -0
- package/dist/skills/_secrets.js +20 -0
- package/dist/skills/_secrets.js.map +1 -0
- package/dist/skills/alpaca-quote.d.ts +2 -2
- package/dist/skills/alpaca-quote.d.ts.map +1 -1
- package/dist/skills/alpaca-quote.js +51 -20
- package/dist/skills/alpaca-quote.js.map +1 -1
- 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 +2 -2
- package/dist/skills/send-email.d.ts.map +1 -1
- package/dist/skills/send-email.js +4 -3
- package/dist/skills/send-email.js.map +1 -1
- package/dist/skills/slack-notify.d.ts +4 -4
- package/dist/skills/slack-notify.d.ts.map +1 -1
- package/dist/skills/slack-notify.js +52 -21
- package/dist/skills/slack-notify.js.map +1 -1
- package/dist/skills/starknet-balance.d.ts +1 -1
- package/dist/skills/telegram-notify.d.ts +4 -4
- package/dist/skills/telegram-notify.d.ts.map +1 -1
- package/dist/skills/telegram-notify.js +48 -19
- package/dist/skills/telegram-notify.js.map +1 -1
- package/dist/skills/web-search.d.ts +1 -1
- package/dist/skills/web-search.d.ts.map +1 -1
- package/dist/skills/web-search.js +85 -40
- package/dist/skills/web-search.js.map +1 -1
- package/dist/telemetry/bus.d.ts +54 -0
- package/dist/telemetry/bus.d.ts.map +1 -0
- package/dist/telemetry/bus.js +159 -0
- package/dist/telemetry/bus.js.map +1 -0
- package/dist/telemetry/index.d.ts +35 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +30 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/port.d.ts +121 -0
- package/dist/telemetry/port.d.ts.map +1 -0
- package/dist/telemetry/port.js +48 -0
- package/dist/telemetry/port.js.map +1 -0
- package/dist/telemetry/sinks/otlp.d.ts +45 -0
- package/dist/telemetry/sinks/otlp.d.ts.map +1 -0
- package/dist/telemetry/sinks/otlp.js +195 -0
- package/dist/telemetry/sinks/otlp.js.map +1 -0
- package/dist/telemetry/sinks/sqlite.d.ts +32 -0
- package/dist/telemetry/sinks/sqlite.d.ts.map +1 -0
- package/dist/telemetry/sinks/sqlite.js +170 -0
- package/dist/telemetry/sinks/sqlite.js.map +1 -0
- package/dist/telemetry/sinks/stdout.d.ts +22 -0
- package/dist/telemetry/sinks/stdout.d.ts.map +1 -0
- package/dist/telemetry/sinks/stdout.js +38 -0
- package/dist/telemetry/sinks/stdout.js.map +1 -0
- 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/docs/telemetry/migration.md +155 -0
- package/docs/telemetry/overview.md +154 -0
- package/docs/telemetry/privacy.md +127 -0
- package/docs/telemetry/sinks/cc.md +155 -0
- package/docs/telemetry/sinks/otlp.md +146 -0
- package/docs/telemetry/sinks/sqlite.md +126 -0
- package/docs/telemetry/sinks/stdout.md +82 -0
- package/package.json +18 -2
- 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/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 +368 -2
- 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/agent.ts +50 -0
- package/src/orchestration/ooda/skills.ts +177 -0
- package/src/orchestration/ooda/types.ts +12 -0
- 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 -0
- 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/_secrets.ts +25 -0
- package/src/skills/alpaca-quote.ts +68 -23
- 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 +4 -3
- package/src/skills/slack-notify.ts +73 -30
- package/src/skills/telegram-notify.ts +70 -24
- package/src/skills/web-search.ts +132 -50
- package/src/telemetry/bus.test.ts +231 -0
- package/src/telemetry/bus.ts +241 -0
- package/src/telemetry/index.ts +49 -0
- package/src/telemetry/port.ts +160 -0
- package/src/telemetry/sinks/otlp.test.ts +146 -0
- package/src/telemetry/sinks/otlp.ts +250 -0
- package/src/telemetry/sinks/sqlite.test.ts +121 -0
- package/src/telemetry/sinks/sqlite.ts +260 -0
- package/src/telemetry/sinks/stdout.test.ts +109 -0
- package/src/telemetry/sinks/stdout.ts +59 -0
- 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
|
@@ -6,9 +6,31 @@
|
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
8
|
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
retry,
|
|
12
|
+
RETRY_TRANSIENT,
|
|
13
|
+
RetryExhaustedError,
|
|
14
|
+
type RetryConfig,
|
|
15
|
+
} from "../retry/index.js";
|
|
9
16
|
import type { Skill, SkillContext } from "../orchestration/ooda/skills.js";
|
|
17
|
+
|
|
10
18
|
import { SkillExecutionError, SkillNotConfiguredError } from "./errors.js";
|
|
11
19
|
import { withSkillSpan } from "./_otel.js";
|
|
20
|
+
import { readSecret } from "./_secrets.js";
|
|
21
|
+
|
|
22
|
+
class RetryableHttpError extends Error {
|
|
23
|
+
constructor(public readonly status: number, public readonly body: string) {
|
|
24
|
+
super(`HTTP ${status}: ${body.slice(0, 200)}`);
|
|
25
|
+
this.name = "RetryableHttpError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const SLACK_RETRY: RetryConfig = {
|
|
30
|
+
...RETRY_TRANSIENT,
|
|
31
|
+
retryIf: (err) =>
|
|
32
|
+
err instanceof RetryableHttpError || err instanceof TypeError,
|
|
33
|
+
};
|
|
12
34
|
|
|
13
35
|
const inputSchema = z
|
|
14
36
|
.object({
|
|
@@ -38,7 +60,7 @@ export const slackNotify: Skill<SlackNotifyInput, SlackNotifyOutput> = {
|
|
|
38
60
|
return { delivered: false, ts: null };
|
|
39
61
|
}
|
|
40
62
|
return withSkillSpan("slack_notify", async () => {
|
|
41
|
-
const token =
|
|
63
|
+
const token = readSecret(ctx, "SLACK_BOT_TOKEN");
|
|
42
64
|
if (!token) {
|
|
43
65
|
throw new SkillNotConfiguredError("slack_notify", ["SLACK_BOT_TOKEN"]);
|
|
44
66
|
}
|
|
@@ -46,45 +68,66 @@ export const slackNotify: Skill<SlackNotifyInput, SlackNotifyOutput> = {
|
|
|
46
68
|
if (!channel && input.binding_user_id) {
|
|
47
69
|
const { rows } = await ctx.db.query<{ chat_id: string }>(
|
|
48
70
|
"SELECT chat_id FROM messaging_user_binding WHERE user_id = $1 AND channel = 'slack' LIMIT 1",
|
|
49
|
-
[input.binding_user_id]
|
|
71
|
+
[input.binding_user_id]
|
|
50
72
|
);
|
|
51
73
|
channel = rows[0]?.chat_id;
|
|
52
74
|
if (!channel) {
|
|
53
75
|
throw new SkillExecutionError(
|
|
54
76
|
"slack_notify",
|
|
55
|
-
`no slack binding for user ${input.binding_user_id}
|
|
77
|
+
`no slack binding for user ${input.binding_user_id}`
|
|
56
78
|
);
|
|
57
79
|
}
|
|
58
80
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
try {
|
|
82
|
+
return await retry(
|
|
83
|
+
async () => {
|
|
84
|
+
const res = await fetch("https://slack.com/api/chat.postMessage", {
|
|
85
|
+
method: "POST",
|
|
86
|
+
headers: {
|
|
87
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
88
|
+
Authorization: `Bearer ${token}`,
|
|
89
|
+
},
|
|
90
|
+
body: JSON.stringify({
|
|
91
|
+
channel,
|
|
92
|
+
text: input.text,
|
|
93
|
+
blocks: input.blocks,
|
|
94
|
+
}),
|
|
95
|
+
});
|
|
96
|
+
if (!res.ok) {
|
|
97
|
+
const body = await res.text().catch(() => "");
|
|
98
|
+
if (res.status >= 500 || res.status === 429) {
|
|
99
|
+
throw new RetryableHttpError(res.status, body);
|
|
100
|
+
}
|
|
101
|
+
throw new SkillExecutionError("slack_notify", `${res.status}`, {
|
|
102
|
+
status: res.status,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const data = (await res.json()) as {
|
|
106
|
+
ok?: boolean;
|
|
107
|
+
ts?: string;
|
|
108
|
+
error?: string;
|
|
109
|
+
};
|
|
110
|
+
if (!data.ok) {
|
|
111
|
+
throw new SkillExecutionError(
|
|
112
|
+
"slack_notify",
|
|
113
|
+
data.error ?? "unknown slack error"
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return { delivered: true, ts: data.ts ?? null };
|
|
117
|
+
},
|
|
118
|
+
{ config: SLACK_RETRY }
|
|
85
119
|
);
|
|
120
|
+
} catch (err) {
|
|
121
|
+
const cause = err instanceof RetryExhaustedError ? err.lastError : err;
|
|
122
|
+
if (cause instanceof RetryableHttpError) {
|
|
123
|
+
throw new SkillExecutionError(
|
|
124
|
+
"slack_notify",
|
|
125
|
+
`${cause.status} after retries`,
|
|
126
|
+
{ status: cause.status }
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
throw cause;
|
|
86
130
|
}
|
|
87
|
-
return { delivered: true, ts: data.ts ?? null };
|
|
88
131
|
});
|
|
89
132
|
},
|
|
90
133
|
};
|
|
@@ -7,9 +7,31 @@
|
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
9
|
import { z } from "zod";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
retry,
|
|
13
|
+
RETRY_TRANSIENT,
|
|
14
|
+
RetryExhaustedError,
|
|
15
|
+
type RetryConfig,
|
|
16
|
+
} from "../retry/index.js";
|
|
10
17
|
import type { Skill, SkillContext } from "../orchestration/ooda/skills.js";
|
|
18
|
+
|
|
11
19
|
import { SkillExecutionError, SkillNotConfiguredError } from "./errors.js";
|
|
12
20
|
import { withSkillSpan } from "./_otel.js";
|
|
21
|
+
import { readSecret } from "./_secrets.js";
|
|
22
|
+
|
|
23
|
+
class RetryableHttpError extends Error {
|
|
24
|
+
constructor(public readonly status: number, public readonly body: string) {
|
|
25
|
+
super(`HTTP ${status}: ${body.slice(0, 200)}`);
|
|
26
|
+
this.name = "RetryableHttpError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const TELEGRAM_RETRY: RetryConfig = {
|
|
31
|
+
...RETRY_TRANSIENT,
|
|
32
|
+
retryIf: (err) =>
|
|
33
|
+
err instanceof RetryableHttpError || err instanceof TypeError,
|
|
34
|
+
};
|
|
13
35
|
|
|
14
36
|
const inputSchema = z
|
|
15
37
|
.object({
|
|
@@ -40,7 +62,7 @@ export const telegramNotify: Skill<TelegramNotifyInput, TelegramNotifyOutput> =
|
|
|
40
62
|
return { delivered: false, message_id: null };
|
|
41
63
|
}
|
|
42
64
|
return withSkillSpan("telegram_notify", async () => {
|
|
43
|
-
const token =
|
|
65
|
+
const token = readSecret(ctx, "TELEGRAM_BOT_TOKEN");
|
|
44
66
|
if (!token) {
|
|
45
67
|
throw new SkillNotConfiguredError("telegram_notify", [
|
|
46
68
|
"TELEGRAM_BOT_TOKEN",
|
|
@@ -50,39 +72,63 @@ export const telegramNotify: Skill<TelegramNotifyInput, TelegramNotifyOutput> =
|
|
|
50
72
|
if (!chatId && input.binding_user_id) {
|
|
51
73
|
const { rows } = await ctx.db.query<{ chat_id: string }>(
|
|
52
74
|
"SELECT chat_id FROM messaging_user_binding WHERE user_id = $1 AND channel = 'telegram' LIMIT 1",
|
|
53
|
-
[input.binding_user_id]
|
|
75
|
+
[input.binding_user_id]
|
|
54
76
|
);
|
|
55
77
|
chatId = rows[0]?.chat_id;
|
|
56
78
|
if (!chatId) {
|
|
57
79
|
throw new SkillExecutionError(
|
|
58
80
|
"telegram_notify",
|
|
59
|
-
`no telegram binding for user ${input.binding_user_id}
|
|
81
|
+
`no telegram binding for user ${input.binding_user_id}`
|
|
60
82
|
);
|
|
61
83
|
}
|
|
62
84
|
}
|
|
63
85
|
const url = `https://api.telegram.org/bot${token}/sendMessage`;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
try {
|
|
87
|
+
return await retry(
|
|
88
|
+
async () => {
|
|
89
|
+
const res = await fetch(url, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: { "Content-Type": "application/json" },
|
|
92
|
+
body: JSON.stringify({
|
|
93
|
+
chat_id: chatId,
|
|
94
|
+
text: input.text,
|
|
95
|
+
parse_mode: input.parse_mode,
|
|
96
|
+
}),
|
|
97
|
+
});
|
|
98
|
+
if (!res.ok) {
|
|
99
|
+
const body = await res.text().catch(() => "");
|
|
100
|
+
if (res.status >= 500 || res.status === 429) {
|
|
101
|
+
throw new RetryableHttpError(res.status, body);
|
|
102
|
+
}
|
|
103
|
+
throw new SkillExecutionError(
|
|
104
|
+
"telegram_notify",
|
|
105
|
+
`${res.status}`,
|
|
106
|
+
{ status: res.status }
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
const data = (await res.json()) as {
|
|
110
|
+
ok?: boolean;
|
|
111
|
+
result?: { message_id?: number };
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
delivered: data.ok === true,
|
|
115
|
+
message_id: data.result?.message_id ?? null,
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
{ config: TELEGRAM_RETRY }
|
|
119
|
+
);
|
|
120
|
+
} catch (err) {
|
|
121
|
+
const cause =
|
|
122
|
+
err instanceof RetryExhaustedError ? err.lastError : err;
|
|
123
|
+
if (cause instanceof RetryableHttpError) {
|
|
124
|
+
throw new SkillExecutionError(
|
|
125
|
+
"telegram_notify",
|
|
126
|
+
`${cause.status} after retries`,
|
|
127
|
+
{ status: cause.status }
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
throw cause;
|
|
77
131
|
}
|
|
78
|
-
const data = (await res.json()) as {
|
|
79
|
-
ok?: boolean;
|
|
80
|
-
result?: { message_id?: number };
|
|
81
|
-
};
|
|
82
|
-
return {
|
|
83
|
-
delivered: data.ok === true,
|
|
84
|
-
message_id: data.result?.message_id ?? null,
|
|
85
|
-
};
|
|
86
132
|
});
|
|
87
133
|
},
|
|
88
134
|
};
|
package/src/skills/web-search.ts
CHANGED
|
@@ -6,9 +6,31 @@
|
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
8
|
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
retry,
|
|
12
|
+
RETRY_TRANSIENT,
|
|
13
|
+
RetryExhaustedError,
|
|
14
|
+
type RetryConfig,
|
|
15
|
+
} from "../retry/index.js";
|
|
9
16
|
import type { Skill, SkillContext } from "../orchestration/ooda/skills.js";
|
|
17
|
+
|
|
10
18
|
import { SkillExecutionError, SkillNotConfiguredError } from "./errors.js";
|
|
11
19
|
import { withSkillSpan } from "./_otel.js";
|
|
20
|
+
import { readSecret } from "./_secrets.js";
|
|
21
|
+
|
|
22
|
+
class RetryableHttpError extends Error {
|
|
23
|
+
constructor(public readonly status: number, public readonly body: string) {
|
|
24
|
+
super(`HTTP ${status}: ${body.slice(0, 200)}`);
|
|
25
|
+
this.name = "RetryableHttpError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const SEARCH_RETRY: RetryConfig = {
|
|
30
|
+
...RETRY_TRANSIENT,
|
|
31
|
+
retryIf: (err) =>
|
|
32
|
+
err instanceof RetryableHttpError || err instanceof TypeError,
|
|
33
|
+
};
|
|
12
34
|
|
|
13
35
|
const inputSchema = z
|
|
14
36
|
.object({
|
|
@@ -38,71 +60,131 @@ export const webSearch: Skill<WebSearchInput, WebSearchOutput> = {
|
|
|
38
60
|
return { results: [], provider: "replay" };
|
|
39
61
|
}
|
|
40
62
|
return withSkillSpan("web_search", async () => {
|
|
41
|
-
const braveKey =
|
|
42
|
-
const tavilyKey =
|
|
63
|
+
const braveKey = readSecret(ctx, "BRAVE_SEARCH_KEY");
|
|
64
|
+
const tavilyKey = readSecret(ctx, "TAVILY_API_KEY");
|
|
43
65
|
if (!braveKey && !tavilyKey) {
|
|
44
66
|
throw new SkillNotConfiguredError("web_search", [
|
|
45
67
|
"BRAVE_SEARCH_KEY",
|
|
46
68
|
"TAVILY_API_KEY",
|
|
47
69
|
]);
|
|
48
70
|
}
|
|
71
|
+
|
|
72
|
+
// Try Brave first when configured. Retry on 5xx/429. Fall back to
|
|
73
|
+
// Tavily on any final non-OK (4xx other than 429 short-circuits).
|
|
49
74
|
if (braveKey) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
75
|
+
try {
|
|
76
|
+
return await retry(
|
|
77
|
+
async () => {
|
|
78
|
+
const url = `https://api.search.brave.com/res/v1/web/search?q=${encodeURIComponent(
|
|
79
|
+
input.query
|
|
80
|
+
)}&count=${input.limit}`;
|
|
81
|
+
const res = await fetch(url, {
|
|
82
|
+
headers: {
|
|
83
|
+
Accept: "application/json",
|
|
84
|
+
"X-Subscription-Token": braveKey,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
if (!res.ok) {
|
|
88
|
+
const body = await res.text().catch(() => "");
|
|
89
|
+
if (res.status >= 500 || res.status === 429) {
|
|
90
|
+
throw new RetryableHttpError(res.status, body);
|
|
91
|
+
}
|
|
92
|
+
throw new SkillExecutionError(
|
|
93
|
+
"web_search",
|
|
94
|
+
`brave ${res.status}`,
|
|
95
|
+
{ status: res.status }
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
const data = (await res.json()) as {
|
|
99
|
+
web?: {
|
|
100
|
+
results?: Array<{
|
|
101
|
+
title?: string;
|
|
102
|
+
url?: string;
|
|
103
|
+
description?: string;
|
|
104
|
+
}>;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
const results: WebSearchResult[] = (data.web?.results ?? []).map(
|
|
108
|
+
(r) => ({
|
|
109
|
+
title: r.title ?? "",
|
|
110
|
+
url: r.url ?? "",
|
|
111
|
+
snippet: r.description ?? "",
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
return { results, provider: "brave" as const };
|
|
115
|
+
},
|
|
116
|
+
{ config: SEARCH_RETRY }
|
|
117
|
+
);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
if (!tavilyKey) {
|
|
120
|
+
const cause =
|
|
121
|
+
err instanceof RetryExhaustedError ? err.lastError : err;
|
|
122
|
+
if (cause instanceof RetryableHttpError) {
|
|
123
|
+
throw new SkillExecutionError(
|
|
124
|
+
"web_search",
|
|
125
|
+
`brave ${cause.status} after retries`,
|
|
126
|
+
{ status: cause.status }
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
throw cause;
|
|
130
|
+
}
|
|
131
|
+
// Brave failed — fall through to Tavily.
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Tavily (primary if no Brave key, else fallback)
|
|
136
|
+
try {
|
|
137
|
+
return await retry(
|
|
138
|
+
async () => {
|
|
139
|
+
const res = await fetch("https://api.tavily.com/search", {
|
|
140
|
+
method: "POST",
|
|
141
|
+
headers: { "Content-Type": "application/json" },
|
|
142
|
+
body: JSON.stringify({
|
|
143
|
+
api_key: tavilyKey,
|
|
144
|
+
query: input.query,
|
|
145
|
+
max_results: input.limit,
|
|
146
|
+
}),
|
|
147
|
+
});
|
|
148
|
+
if (!res.ok) {
|
|
149
|
+
const body = await res.text().catch(() => "");
|
|
150
|
+
if (res.status >= 500 || res.status === 429) {
|
|
151
|
+
throw new RetryableHttpError(res.status, body);
|
|
152
|
+
}
|
|
153
|
+
throw new SkillExecutionError(
|
|
154
|
+
"web_search",
|
|
155
|
+
`tavily ${res.status}`,
|
|
156
|
+
{ status: res.status }
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
const data = (await res.json()) as {
|
|
60
160
|
results?: Array<{
|
|
61
161
|
title?: string;
|
|
62
162
|
url?: string;
|
|
63
|
-
|
|
163
|
+
content?: string;
|
|
64
164
|
}>;
|
|
65
165
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
166
|
+
const results: WebSearchResult[] = (data.results ?? []).map(
|
|
167
|
+
(r) => ({
|
|
168
|
+
title: r.title ?? "",
|
|
169
|
+
url: r.url ?? "",
|
|
170
|
+
snippet: r.content ?? "",
|
|
171
|
+
})
|
|
172
|
+
);
|
|
173
|
+
return { results, provider: "tavily" as const };
|
|
174
|
+
},
|
|
175
|
+
{ config: SEARCH_RETRY }
|
|
176
|
+
);
|
|
177
|
+
} catch (err) {
|
|
178
|
+
const cause = err instanceof RetryExhaustedError ? err.lastError : err;
|
|
179
|
+
if (cause instanceof RetryableHttpError) {
|
|
180
|
+
throw new SkillExecutionError(
|
|
181
|
+
"web_search",
|
|
182
|
+
`tavily ${cause.status} after retries`,
|
|
183
|
+
{ status: cause.status }
|
|
73
184
|
);
|
|
74
|
-
return { results, provider: "brave" };
|
|
75
|
-
}
|
|
76
|
-
if (!tavilyKey) {
|
|
77
|
-
throw new SkillExecutionError("web_search", `brave ${res.status}`, {
|
|
78
|
-
status: res.status,
|
|
79
|
-
});
|
|
80
185
|
}
|
|
186
|
+
throw cause;
|
|
81
187
|
}
|
|
82
|
-
// Tavily fallback
|
|
83
|
-
const res = await fetch("https://api.tavily.com/search", {
|
|
84
|
-
method: "POST",
|
|
85
|
-
headers: { "Content-Type": "application/json" },
|
|
86
|
-
body: JSON.stringify({
|
|
87
|
-
api_key: tavilyKey,
|
|
88
|
-
query: input.query,
|
|
89
|
-
max_results: input.limit,
|
|
90
|
-
}),
|
|
91
|
-
});
|
|
92
|
-
if (!res.ok) {
|
|
93
|
-
throw new SkillExecutionError("web_search", `tavily ${res.status}`, {
|
|
94
|
-
status: res.status,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
const data = (await res.json()) as {
|
|
98
|
-
results?: Array<{ title?: string; url?: string; content?: string }>;
|
|
99
|
-
};
|
|
100
|
-
const results: WebSearchResult[] = (data.results ?? []).map((r) => ({
|
|
101
|
-
title: r.title ?? "",
|
|
102
|
-
url: r.url ?? "",
|
|
103
|
-
snippet: r.content ?? "",
|
|
104
|
-
}));
|
|
105
|
-
return { results, provider: "tavily" };
|
|
106
188
|
});
|
|
107
189
|
},
|
|
108
190
|
};
|