@theoremjs/agents 0.0.0-stage → 0.3.1
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/LICENSE +21 -0
- package/README.md +545 -2
- package/esm/_dnt.polyfills.d.ts +66 -0
- package/esm/_dnt.polyfills.js +51 -0
- package/esm/mod.d.ts +79 -0
- package/esm/mod.js +49 -0
- package/esm/package.json +3 -0
- package/esm/src/cli/bin.d.ts +7 -0
- package/esm/src/cli/bin.js +9 -0
- package/esm/src/cli/commands/bench.d.ts +6 -0
- package/esm/src/cli/commands/bench.js +480 -0
- package/esm/src/cli/commands/detect-compile.d.ts +17 -0
- package/esm/src/cli/commands/detect-compile.js +22 -0
- package/esm/src/cli/commands/eval.d.ts +37 -0
- package/esm/src/cli/commands/eval.js +190 -0
- package/esm/src/cli/commands/fuzz-canary.d.ts +15 -0
- package/esm/src/cli/commands/fuzz-canary.js +241 -0
- package/esm/src/cli/commands/fuzz-guardrails.d.ts +2 -0
- package/esm/src/cli/commands/fuzz-guardrails.js +5 -0
- package/esm/src/cli/commands/profile.d.ts +2 -0
- package/esm/src/cli/commands/profile.js +80 -0
- package/esm/src/cli/commands/run.d.ts +13 -0
- package/esm/src/cli/commands/run.js +45 -0
- package/esm/src/cli/commands/test.d.ts +26 -0
- package/esm/src/cli/commands/test.js +143 -0
- package/esm/src/cli/event-log.d.ts +15 -0
- package/esm/src/cli/event-log.js +136 -0
- package/esm/src/cli/index.d.ts +10 -0
- package/esm/src/cli/index.js +267 -0
- package/esm/src/cli/matrix/fixtures.d.ts +10 -0
- package/esm/src/cli/matrix/fixtures.js +67 -0
- package/esm/src/cli/matrix/synthesizer.d.ts +18 -0
- package/esm/src/cli/matrix/synthesizer.js +103 -0
- package/esm/src/evals/attachments.d.ts +5 -0
- package/esm/src/evals/attachments.js +55 -0
- package/esm/src/evals/breakdown.d.ts +30 -0
- package/esm/src/evals/breakdown.js +69 -0
- package/esm/src/evals/graders/answer.d.ts +16 -0
- package/esm/src/evals/graders/answer.js +134 -0
- package/esm/src/evals/graders/code.d.ts +40 -0
- package/esm/src/evals/graders/code.js +184 -0
- package/esm/src/evals/graders/judge.d.ts +24 -0
- package/esm/src/evals/graders/judge.js +367 -0
- package/esm/src/evals/graders/latency.d.ts +6 -0
- package/esm/src/evals/graders/latency.js +82 -0
- package/esm/src/evals/graders/live.d.ts +14 -0
- package/esm/src/evals/graders/live.js +42 -0
- package/esm/src/evals/graders/media.d.ts +18 -0
- package/esm/src/evals/graders/media.js +91 -0
- package/esm/src/evals/graders/shared.d.ts +11 -0
- package/esm/src/evals/graders/shared.js +62 -0
- package/esm/src/evals/graders/transcript.d.ts +19 -0
- package/esm/src/evals/graders/transcript.js +202 -0
- package/esm/src/evals/mod.d.ts +34 -0
- package/esm/src/evals/mod.js +22 -0
- package/esm/src/evals/record.d.ts +41 -0
- package/esm/src/evals/record.js +107 -0
- package/esm/src/evals/rubrics/catalog.d.ts +148 -0
- package/esm/src/evals/rubrics/catalog.js +846 -0
- package/esm/src/evals/rubrics/mod.d.ts +24 -0
- package/esm/src/evals/rubrics/mod.js +55 -0
- package/esm/src/evals/rubrics/mustache.d.ts +23 -0
- package/esm/src/evals/rubrics/mustache.js +154 -0
- package/esm/src/evals/rubrics/types.d.ts +54 -0
- package/esm/src/evals/rubrics/types.js +74 -0
- package/esm/src/evals/run.d.ts +75 -0
- package/esm/src/evals/run.js +418 -0
- package/esm/src/evals/suite.d.ts +28 -0
- package/esm/src/evals/suite.js +97 -0
- package/esm/src/evals/summary.d.ts +35 -0
- package/esm/src/evals/summary.js +31 -0
- package/esm/src/evals/trial.d.ts +14 -0
- package/esm/src/evals/trial.js +135 -0
- package/esm/src/evals/types.d.ts +169 -0
- package/esm/src/evals/types.js +113 -0
- package/esm/src/evals/verdict.d.ts +23 -0
- package/esm/src/evals/verdict.js +48 -0
- package/esm/src/guardrails/boundaries.d.ts +41 -0
- package/esm/src/guardrails/boundaries.js +103 -0
- package/esm/src/guardrails/canary-gate.d.ts +22 -0
- package/esm/src/guardrails/canary-gate.js +40 -0
- package/esm/src/guardrails/canary.d.ts +146 -0
- package/esm/src/guardrails/canary.js +974 -0
- package/esm/src/guardrails/compile-egress.d.ts +12 -0
- package/esm/src/guardrails/compile-egress.js +12 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.d.ts +24 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.js +305 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.d.ts +5 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.js +199 -0
- package/esm/src/guardrails/corpus/inbound-payloads.d.ts +5 -0
- package/esm/src/guardrails/corpus/inbound-payloads.js +120 -0
- package/esm/src/guardrails/corpus/live-attacks.d.ts +15 -0
- package/esm/src/guardrails/corpus/live-attacks.js +229 -0
- package/esm/src/guardrails/corpus/mod.d.ts +7 -0
- package/esm/src/guardrails/corpus/mod.js +4 -0
- package/esm/src/guardrails/corpus/secrets.d.ts +12 -0
- package/esm/src/guardrails/corpus/secrets.js +16 -0
- package/esm/src/guardrails/corpus/strings.d.ts +23 -0
- package/esm/src/guardrails/corpus/strings.js +29 -0
- package/esm/src/guardrails/corpus/types.d.ts +36 -0
- package/esm/src/guardrails/corpus/types.js +1 -0
- package/esm/src/guardrails/credential-rules.d.ts +36 -0
- package/esm/src/guardrails/credential-rules.js +3001 -0
- package/esm/src/guardrails/credential-scan.d.ts +45 -0
- package/esm/src/guardrails/credential-scan.js +172 -0
- package/esm/src/guardrails/destinations.d.ts +45 -0
- package/esm/src/guardrails/destinations.js +234 -0
- package/esm/src/guardrails/detect-at.d.ts +107 -0
- package/esm/src/guardrails/detect-at.js +434 -0
- package/esm/src/guardrails/detect-reply.d.ts +61 -0
- package/esm/src/guardrails/detect-reply.js +95 -0
- package/esm/src/guardrails/detect-stream.d.ts +33 -0
- package/esm/src/guardrails/detect-stream.js +77 -0
- package/esm/src/guardrails/detectors.d.ts +216 -0
- package/esm/src/guardrails/detectors.js +503 -0
- package/esm/src/guardrails/egress-automata.d.ts +12 -0
- package/esm/src/guardrails/egress-automata.js +25582 -0
- package/esm/src/guardrails/egress-compiler.d.ts +55 -0
- package/esm/src/guardrails/egress-compiler.js +431 -0
- package/esm/src/guardrails/egress-patterns.d.ts +26 -0
- package/esm/src/guardrails/egress-patterns.js +36 -0
- package/esm/src/guardrails/egress-stream.d.ts +123 -0
- package/esm/src/guardrails/egress-stream.js +774 -0
- package/esm/src/guardrails/egress-urls.d.ts +86 -0
- package/esm/src/guardrails/egress-urls.js +909 -0
- package/esm/src/guardrails/egress.d.ts +46 -0
- package/esm/src/guardrails/egress.js +124 -0
- package/esm/src/guardrails/error.d.ts +31 -0
- package/esm/src/guardrails/error.js +96 -0
- package/esm/src/guardrails/event-schemas.d.ts +100 -0
- package/esm/src/guardrails/event-schemas.js +48 -0
- package/esm/src/guardrails/events.d.ts +13 -0
- package/esm/src/guardrails/events.js +45 -0
- package/esm/src/guardrails/hints.d.ts +14 -0
- package/esm/src/guardrails/hints.js +57 -0
- package/esm/src/guardrails/hits.d.ts +14 -0
- package/esm/src/guardrails/hits.js +30 -0
- package/esm/src/guardrails/host-patterns.d.ts +85 -0
- package/esm/src/guardrails/host-patterns.js +173 -0
- package/esm/src/guardrails/injection-patterns.d.ts +20 -0
- package/esm/src/guardrails/injection-patterns.js +126 -0
- package/esm/src/guardrails/injection-reversed.d.ts +9 -0
- package/esm/src/guardrails/injection-reversed.js +49 -0
- package/esm/src/guardrails/injection.d.ts +30 -0
- package/esm/src/guardrails/injection.js +460 -0
- package/esm/src/guardrails/labels.d.ts +40 -0
- package/esm/src/guardrails/labels.js +874 -0
- package/esm/src/guardrails/live-outbound-gate.d.ts +55 -0
- package/esm/src/guardrails/live-outbound-gate.js +298 -0
- package/esm/src/guardrails/mod.d.ts +54 -0
- package/esm/src/guardrails/mod.js +34 -0
- package/esm/src/guardrails/network.d.ts +46 -0
- package/esm/src/guardrails/network.js +330 -0
- package/esm/src/guardrails/normalize.d.ts +20 -0
- package/esm/src/guardrails/normalize.js +165 -0
- package/esm/src/guardrails/policy.d.ts +4 -0
- package/esm/src/guardrails/policy.js +21 -0
- package/esm/src/guardrails/progressive-yield.d.ts +110 -0
- package/esm/src/guardrails/progressive-yield.js +281 -0
- package/esm/src/guardrails/prompt-echo.d.ts +40 -0
- package/esm/src/guardrails/prompt-echo.js +306 -0
- package/esm/src/guardrails/quota.d.ts +21 -0
- package/esm/src/guardrails/quota.js +80 -0
- package/esm/src/guardrails/rules.d.ts +47 -0
- package/esm/src/guardrails/rules.js +47 -0
- package/esm/src/guardrails/sanitize.d.ts +40 -0
- package/esm/src/guardrails/sanitize.js +160 -0
- package/esm/src/guardrails/sensitive-groups.d.ts +21 -0
- package/esm/src/guardrails/sensitive-groups.js +12 -0
- package/esm/src/guardrails/sensitive.d.ts +22 -0
- package/esm/src/guardrails/sensitive.js +234 -0
- package/esm/src/guardrails/serialize.d.ts +15 -0
- package/esm/src/guardrails/serialize.js +37 -0
- package/esm/src/guardrails/testing.d.ts +11 -0
- package/esm/src/guardrails/testing.js +10 -0
- package/esm/src/guardrails/theorem-error.d.ts +21 -0
- package/esm/src/guardrails/theorem-error.js +54 -0
- package/esm/src/guardrails/thought-guard.d.ts +76 -0
- package/esm/src/guardrails/thought-guard.js +664 -0
- package/esm/src/guardrails/tool-directives.d.ts +38 -0
- package/esm/src/guardrails/tool-directives.js +195 -0
- package/esm/src/guardrails/tool-leak.d.ts +26 -0
- package/esm/src/guardrails/tool-leak.js +45 -0
- package/esm/src/guardrails/tool-result.d.ts +92 -0
- package/esm/src/guardrails/tool-result.js +272 -0
- package/esm/src/guardrails/types.d.ts +250 -0
- package/esm/src/guardrails/types.js +58 -0
- package/esm/src/host/client-turn.d.ts +36 -0
- package/esm/src/host/client-turn.js +80 -0
- package/esm/src/host/mint-trace.d.ts +29 -0
- package/esm/src/host/mint-trace.js +60 -0
- package/esm/src/host/mod.d.ts +13 -0
- package/esm/src/host/mod.js +11 -0
- package/esm/src/host/readStreamingJsonStringField.d.ts +2 -0
- package/esm/src/host/readStreamingJsonStringField.js +27 -0
- package/esm/src/host/reply.d.ts +13 -0
- package/esm/src/host/reply.js +41 -0
- package/esm/src/interface/blocks.d.ts +11 -0
- package/esm/src/interface/blocks.js +283 -0
- package/esm/src/interface/composer-actions.d.ts +24 -0
- package/esm/src/interface/composer-actions.js +33 -0
- package/esm/src/interface/draft.d.ts +20 -0
- package/esm/src/interface/draft.js +39 -0
- package/esm/src/interface/from-profile.d.ts +24 -0
- package/esm/src/interface/from-profile.js +179 -0
- package/esm/src/interface/history.d.ts +46 -0
- package/esm/src/interface/history.js +278 -0
- package/esm/src/interface/inputs.d.ts +11 -0
- package/esm/src/interface/inputs.js +67 -0
- package/esm/src/interface/mod.d.ts +33 -0
- package/esm/src/interface/mod.js +22 -0
- package/esm/src/interface/models.d.ts +26 -0
- package/esm/src/interface/models.js +50 -0
- package/esm/src/interface/pending.d.ts +57 -0
- package/esm/src/interface/pending.js +152 -0
- package/esm/src/interface/profile-interface.d.ts +4 -0
- package/esm/src/interface/profile-interface.js +237 -0
- package/esm/src/interface/session.d.ts +71 -0
- package/esm/src/interface/session.js +128 -0
- package/esm/src/interface/stop.d.ts +13 -0
- package/esm/src/interface/stop.js +28 -0
- package/esm/src/interface/tool-calls.d.ts +32 -0
- package/esm/src/interface/tool-calls.js +127 -0
- package/esm/src/interface/tool-invoke.d.ts +6 -0
- package/esm/src/interface/tool-invoke.js +22 -0
- package/esm/src/interface/tool-media.d.ts +11 -0
- package/esm/src/interface/tool-media.js +113 -0
- package/esm/src/interface/types.d.ts +278 -0
- package/esm/src/interface/types.js +5 -0
- package/esm/src/kernel/api-catalog.d.ts +85 -0
- package/esm/src/kernel/api-catalog.js +229 -0
- package/esm/src/kernel/auth/credential-source.d.ts +23 -0
- package/esm/src/kernel/auth/credential-source.js +11 -0
- package/esm/src/kernel/auth/crypto.d.ts +56 -0
- package/esm/src/kernel/auth/crypto.js +163 -0
- package/esm/src/kernel/auth/mod.d.ts +5 -0
- package/esm/src/kernel/auth/mod.js +5 -0
- package/esm/src/kernel/auth/oauth.d.ts +18 -0
- package/esm/src/kernel/auth/oauth.js +439 -0
- package/esm/src/kernel/auth/scope-refusal.d.ts +9 -0
- package/esm/src/kernel/auth/scope-refusal.js +8 -0
- package/esm/src/kernel/auth/typed-secret.d.ts +13 -0
- package/esm/src/kernel/auth/typed-secret.js +23 -0
- package/esm/src/kernel/auth/types.d.ts +152 -0
- package/esm/src/kernel/auth/types.js +1 -0
- package/esm/src/kernel/checkpoint.d.ts +43 -0
- package/esm/src/kernel/checkpoint.js +58 -0
- package/esm/src/kernel/default-scope.d.ts +72 -0
- package/esm/src/kernel/default-scope.js +121 -0
- package/esm/src/kernel/engine/call-trace.d.ts +19 -0
- package/esm/src/kernel/engine/call-trace.js +29 -0
- package/esm/src/kernel/engine/compaction.d.ts +71 -0
- package/esm/src/kernel/engine/compaction.js +203 -0
- package/esm/src/kernel/engine/decision.d.ts +43 -0
- package/esm/src/kernel/engine/decision.js +439 -0
- package/esm/src/kernel/engine/embedding.d.ts +8 -0
- package/esm/src/kernel/engine/embedding.js +118 -0
- package/esm/src/kernel/engine/hash.d.ts +6 -0
- package/esm/src/kernel/engine/hash.js +22 -0
- package/esm/src/kernel/engine/live-inbound.d.ts +19 -0
- package/esm/src/kernel/engine/live-inbound.js +44 -0
- package/esm/src/kernel/engine/live-ingress.d.ts +15 -0
- package/esm/src/kernel/engine/live-ingress.js +42 -0
- package/esm/src/kernel/engine/record.d.ts +3 -0
- package/esm/src/kernel/engine/record.js +11 -0
- package/esm/src/kernel/engine/repair.d.ts +7 -0
- package/esm/src/kernel/engine/repair.js +36 -0
- package/esm/src/kernel/engine/runner/gates.d.ts +5 -0
- package/esm/src/kernel/engine/runner/gates.js +508 -0
- package/esm/src/kernel/engine/runner/mod.d.ts +29 -0
- package/esm/src/kernel/engine/runner/mod.js +625 -0
- package/esm/src/kernel/engine/runner/nested.d.ts +32 -0
- package/esm/src/kernel/engine/runner/nested.js +134 -0
- package/esm/src/kernel/engine/runner/schema-validation.d.ts +35 -0
- package/esm/src/kernel/engine/runner/schema-validation.js +179 -0
- package/esm/src/kernel/engine/runner/stages.d.ts +28 -0
- package/esm/src/kernel/engine/runner/stages.js +41 -0
- package/esm/src/kernel/engine/runner/state.d.ts +97 -0
- package/esm/src/kernel/engine/runner/state.js +50 -0
- package/esm/src/kernel/engine/runner/step-order.d.ts +27 -0
- package/esm/src/kernel/engine/runner/step-order.js +165 -0
- package/esm/src/kernel/engine/runner/steps.d.ts +14 -0
- package/esm/src/kernel/engine/runner/steps.js +519 -0
- package/esm/src/kernel/engine/runner/stream.d.ts +71 -0
- package/esm/src/kernel/engine/runner/stream.js +376 -0
- package/esm/src/kernel/engine/runner/usage.d.ts +45 -0
- package/esm/src/kernel/engine/runner/usage.js +148 -0
- package/esm/src/kernel/engine/session/mod.d.ts +33 -0
- package/esm/src/kernel/engine/session/mod.js +1182 -0
- package/esm/src/kernel/engine/session/session-trace.d.ts +115 -0
- package/esm/src/kernel/engine/session/session-trace.js +500 -0
- package/esm/src/kernel/engine/token-estimate.d.ts +23 -0
- package/esm/src/kernel/engine/token-estimate.js +38 -0
- package/esm/src/kernel/engine/tool-trace.d.ts +58 -0
- package/esm/src/kernel/engine/tool-trace.js +132 -0
- package/esm/src/kernel/engine/tree.d.ts +2 -0
- package/esm/src/kernel/engine/tree.js +17 -0
- package/esm/src/kernel/engine/turn-trace.d.ts +119 -0
- package/esm/src/kernel/engine/turn-trace.js +855 -0
- package/esm/src/kernel/engine/usage.d.ts +36 -0
- package/esm/src/kernel/engine/usage.js +151 -0
- package/esm/src/kernel/interaction-parts.d.ts +13 -0
- package/esm/src/kernel/interaction-parts.js +40 -0
- package/esm/src/kernel/json.d.ts +10 -0
- package/esm/src/kernel/json.js +3 -0
- package/esm/src/kernel/mod.d.ts +74 -0
- package/esm/src/kernel/mod.js +45 -0
- package/esm/src/kernel/profile-graph.d.ts +145 -0
- package/esm/src/kernel/profile-graph.js +158 -0
- package/esm/src/kernel/profile-presence.d.ts +18 -0
- package/esm/src/kernel/profile-presence.js +158 -0
- package/esm/src/kernel/profile-scope.d.ts +40 -0
- package/esm/src/kernel/profile-scope.js +274 -0
- package/esm/src/kernel/protocols/binding.d.ts +65 -0
- package/esm/src/kernel/protocols/binding.js +125 -0
- package/esm/src/kernel/protocols/limits.d.ts +15 -0
- package/esm/src/kernel/protocols/limits.js +28 -0
- package/esm/src/kernel/protocols/mod.d.ts +5 -0
- package/esm/src/kernel/protocols/mod.js +5 -0
- package/esm/src/kernel/protocols/prices.d.ts +36 -0
- package/esm/src/kernel/protocols/prices.js +37 -0
- package/esm/src/kernel/protocols/protocol.d.ts +253 -0
- package/esm/src/kernel/protocols/protocol.js +253 -0
- package/esm/src/kernel/protocols/provider.d.ts +108 -0
- package/esm/src/kernel/protocols/provider.js +143 -0
- package/esm/src/kernel/protocols/runtime.d.ts +55 -0
- package/esm/src/kernel/protocols/runtime.js +534 -0
- package/esm/src/kernel/provider-budget.d.ts +32 -0
- package/esm/src/kernel/provider-budget.js +262 -0
- package/esm/src/kernel/provider-dispatch.d.ts +13 -0
- package/esm/src/kernel/provider-dispatch.js +36 -0
- package/esm/src/kernel/provider-live.d.ts +7 -0
- package/esm/src/kernel/provider-live.js +189 -0
- package/esm/src/kernel/provider-runtime.d.ts +57 -0
- package/esm/src/kernel/provider-runtime.js +524 -0
- package/esm/src/kernel/registry/attachments.d.ts +46 -0
- package/esm/src/kernel/registry/attachments.js +220 -0
- package/esm/src/kernel/registry/catalog.d.ts +25 -0
- package/esm/src/kernel/registry/catalog.js +85 -0
- package/esm/src/kernel/registry/embedding-rules.d.ts +28 -0
- package/esm/src/kernel/registry/embedding-rules.js +66 -0
- package/esm/src/kernel/registry/ingress.d.ts +12 -0
- package/esm/src/kernel/registry/ingress.js +179 -0
- package/esm/src/kernel/registry/kernel-registry.d.ts +15 -0
- package/esm/src/kernel/registry/kernel-registry.js +15 -0
- package/esm/src/kernel/registry/profile-outputs.d.ts +3 -0
- package/esm/src/kernel/registry/profile-outputs.js +10 -0
- package/esm/src/kernel/registry/profiles.d.ts +116 -0
- package/esm/src/kernel/registry/profiles.js +773 -0
- package/esm/src/kernel/registry/provider-request.d.ts +6 -0
- package/esm/src/kernel/registry/provider-request.js +34 -0
- package/esm/src/kernel/registry/resolve.d.ts +17 -0
- package/esm/src/kernel/registry/resolve.js +238 -0
- package/esm/src/kernel/registry/schemas.d.ts +12 -0
- package/esm/src/kernel/registry/schemas.js +27 -0
- package/esm/src/kernel/registry/slot-fill.d.ts +7 -0
- package/esm/src/kernel/registry/slot-fill.js +22 -0
- package/esm/src/kernel/registry/sole-model.d.ts +2 -0
- package/esm/src/kernel/registry/sole-model.js +4 -0
- package/esm/src/kernel/registry/system-prompt.d.ts +8 -0
- package/esm/src/kernel/registry/system-prompt.js +32 -0
- package/esm/src/kernel/registry/system-role.d.ts +3 -0
- package/esm/src/kernel/registry/system-role.js +9 -0
- package/esm/src/kernel/registry/vault.d.ts +14 -0
- package/esm/src/kernel/registry/vault.js +1 -0
- package/esm/src/kernel/schema.d.ts +226 -0
- package/esm/src/kernel/schema.js +895 -0
- package/esm/src/kernel/scope.d.ts +29 -0
- package/esm/src/kernel/scope.js +45 -0
- package/esm/src/kernel/stages.d.ts +176 -0
- package/esm/src/kernel/stages.js +431 -0
- package/esm/src/kernel/stop.d.ts +116 -0
- package/esm/src/kernel/stop.js +137 -0
- package/esm/src/kernel/system-parts.d.ts +26 -0
- package/esm/src/kernel/system-parts.js +98 -0
- package/esm/src/kernel/tools/activity-label.d.ts +22 -0
- package/esm/src/kernel/tools/activity-label.js +435 -0
- package/esm/src/kernel/tools/agent.d.ts +66 -0
- package/esm/src/kernel/tools/agent.js +212 -0
- package/esm/src/kernel/tools/coordinate.d.ts +4 -0
- package/esm/src/kernel/tools/coordinate.js +165 -0
- package/esm/src/kernel/tools/events.d.ts +66 -0
- package/esm/src/kernel/tools/events.js +184 -0
- package/esm/src/kernel/tools/execute.d.ts +100 -0
- package/esm/src/kernel/tools/execute.js +1173 -0
- package/esm/src/kernel/tools/gate-answer.d.ts +60 -0
- package/esm/src/kernel/tools/gate-answer.js +65 -0
- package/esm/src/kernel/tools/handler-events.d.ts +45 -0
- package/esm/src/kernel/tools/handler-events.js +106 -0
- package/esm/src/kernel/tools/harness.d.ts +17 -0
- package/esm/src/kernel/tools/harness.js +43 -0
- package/esm/src/kernel/tools/http-limit.d.ts +27 -0
- package/esm/src/kernel/tools/http-limit.js +85 -0
- package/esm/src/kernel/tools/invoke.d.ts +32 -0
- package/esm/src/kernel/tools/invoke.js +282 -0
- package/esm/src/kernel/tools/mcp-sessions.d.ts +23 -0
- package/esm/src/kernel/tools/mcp-sessions.js +69 -0
- package/esm/src/kernel/tools/mod.d.ts +10 -0
- package/esm/src/kernel/tools/mod.js +7 -0
- package/esm/src/kernel/tools/model-text.d.ts +16 -0
- package/esm/src/kernel/tools/model-text.js +31 -0
- package/esm/src/kernel/tools/operation.d.ts +76 -0
- package/esm/src/kernel/tools/operation.js +100 -0
- package/esm/src/kernel/tools/page-answer.d.ts +8 -0
- package/esm/src/kernel/tools/page-answer.js +19 -0
- package/esm/src/kernel/tools/permission.d.ts +15 -0
- package/esm/src/kernel/tools/permission.js +38 -0
- package/esm/src/kernel/tools/project.d.ts +11 -0
- package/esm/src/kernel/tools/project.js +55 -0
- package/esm/src/kernel/tools/registry.d.ts +27 -0
- package/esm/src/kernel/tools/registry.js +143 -0
- package/esm/src/kernel/tools/remote.d.ts +144 -0
- package/esm/src/kernel/tools/remote.js +1125 -0
- package/esm/src/kernel/tools/resolve.d.ts +31 -0
- package/esm/src/kernel/tools/resolve.js +267 -0
- package/esm/src/kernel/tools/run.d.ts +28 -0
- package/esm/src/kernel/tools/run.js +86 -0
- package/esm/src/kernel/tools/schema.d.ts +10 -0
- package/esm/src/kernel/tools/schema.js +95 -0
- package/esm/src/kernel/tools/signed-in-fetch.d.ts +19 -0
- package/esm/src/kernel/tools/signed-in-fetch.js +45 -0
- package/esm/src/kernel/tools/stage-run.d.ts +116 -0
- package/esm/src/kernel/tools/stage-run.js +198 -0
- package/esm/src/kernel/tools/types.d.ts +497 -0
- package/esm/src/kernel/tools/types.js +1 -0
- package/esm/src/kernel/tools/unchecked-output.d.ts +14 -0
- package/esm/src/kernel/tools/unchecked-output.js +18 -0
- package/esm/src/kernel/turn-events.d.ts +776 -0
- package/esm/src/kernel/turn-events.js +543 -0
- package/esm/src/kernel/types.d.ts +1025 -0
- package/esm/src/kernel/types.js +1 -0
- package/esm/src/kernel/util/base64.d.ts +4 -0
- package/esm/src/kernel/util/base64.js +15 -0
- package/esm/src/kernel/util/exact-type.d.ts +31 -0
- package/esm/src/kernel/util/exact-type.js +1 -0
- package/esm/src/kernel/util/find-last.d.ts +3 -0
- package/esm/src/kernel/util/find-last.js +9 -0
- package/esm/src/kernel/util/mime.d.ts +2 -0
- package/esm/src/kernel/util/mime.js +4 -0
- package/esm/src/kernel/util/partial-json.d.ts +23 -0
- package/esm/src/kernel/util/partial-json.js +128 -0
- package/esm/src/kernel/util/record.d.ts +2 -0
- package/esm/src/kernel/util/record.js +4 -0
- package/esm/src/observability/destinations.d.ts +14 -0
- package/esm/src/observability/destinations.js +43 -0
- package/esm/src/observability/jsonl.d.ts +18 -0
- package/esm/src/observability/jsonl.js +110 -0
- package/esm/src/observability/mod.d.ts +22 -0
- package/esm/src/observability/mod.js +16 -0
- package/esm/src/observability/openinference.d.ts +11 -0
- package/esm/src/observability/openinference.js +205 -0
- package/esm/src/observability/otlp.d.ts +71 -0
- package/esm/src/observability/otlp.js +98 -0
- package/esm/src/observability/phoenix.d.ts +30 -0
- package/esm/src/observability/phoenix.js +71 -0
- package/esm/src/observability/policy.d.ts +17 -0
- package/esm/src/observability/policy.js +73 -0
- package/esm/src/observability/resolve-policy.d.ts +8 -0
- package/esm/src/observability/resolve-policy.js +64 -0
- package/esm/src/observability/spans.d.ts +22 -0
- package/esm/src/observability/spans.js +72 -0
- package/esm/src/observability/trace-catalog.d.ts +128 -0
- package/esm/src/observability/trace-catalog.js +906 -0
- package/esm/src/observability/trace-record.d.ts +23 -0
- package/esm/src/observability/trace-record.js +228 -0
- package/esm/src/observability/trace-schema.d.ts +57 -0
- package/esm/src/observability/trace-schema.js +59 -0
- package/esm/src/observability/trace-sink.d.ts +14 -0
- package/esm/src/observability/trace-sink.js +3 -0
- package/esm/src/observability/trace-span.d.ts +98 -0
- package/esm/src/observability/trace-span.js +201 -0
- package/esm/src/observability/trace.d.ts +13 -0
- package/esm/src/observability/trace.js +37 -0
- package/esm/src/observability/types.d.ts +109 -0
- package/esm/src/observability/types.js +3 -0
- package/esm/src/presets/google/speech-voices.d.ts +9 -0
- package/esm/src/presets/google/speech-voices.js +38 -0
- package/esm/src/presets/google-limits.d.ts +13 -0
- package/esm/src/presets/google-limits.js +18 -0
- package/esm/src/presets/google.d.ts +119 -0
- package/esm/src/presets/google.js +197 -0
- package/esm/src/presets/local.d.ts +26 -0
- package/esm/src/presets/local.js +30 -0
- package/esm/src/presets/mod.d.ts +11 -0
- package/esm/src/presets/mod.js +9 -0
- package/esm/src/presets/openrouter.d.ts +26 -0
- package/esm/src/presets/openrouter.js +31 -0
- package/esm/src/providers/embedding-limits.d.ts +7 -0
- package/esm/src/providers/embedding-limits.js +12 -0
- package/esm/src/providers/gemini/embedding-protocol.d.ts +8 -0
- package/esm/src/providers/gemini/embedding-protocol.js +125 -0
- package/esm/src/providers/gemini/interactions-protocol.d.ts +8 -0
- package/esm/src/providers/gemini/interactions-protocol.js +105 -0
- package/esm/src/providers/gemini/live-protocol.d.ts +3 -0
- package/esm/src/providers/gemini/live-protocol.js +191 -0
- package/esm/src/providers/gemini/prices.d.ts +3 -0
- package/esm/src/providers/gemini/prices.js +63 -0
- package/esm/src/providers/gemini/provider.d.ts +7 -0
- package/esm/src/providers/gemini/provider.js +39 -0
- package/esm/src/providers/google/api-error.d.ts +8 -0
- package/esm/src/providers/google/api-error.js +123 -0
- package/esm/src/providers/google/builtins.d.ts +14 -0
- package/esm/src/providers/google/builtins.js +57 -0
- package/esm/src/providers/google/grounding.d.ts +5 -0
- package/esm/src/providers/google/grounding.js +226 -0
- package/esm/src/providers/google/interactions/framing.d.ts +27 -0
- package/esm/src/providers/google/interactions/framing.js +304 -0
- package/esm/src/providers/google/interactions/steps.d.ts +12 -0
- package/esm/src/providers/google/interactions/steps.js +200 -0
- package/esm/src/providers/google/interactions/stream.d.ts +23 -0
- package/esm/src/providers/google/interactions/stream.js +230 -0
- package/esm/src/providers/google/live/framing.d.ts +61 -0
- package/esm/src/providers/google/live/framing.js +597 -0
- package/esm/src/providers/google/live/stream.d.ts +13 -0
- package/esm/src/providers/google/live/stream.js +57 -0
- package/esm/src/providers/google/thinking.d.ts +3 -0
- package/esm/src/providers/google/thinking.js +8 -0
- package/esm/src/providers/google/urls.d.ts +4 -0
- package/esm/src/providers/google/urls.js +4 -0
- package/esm/src/providers/google/usage.d.ts +7 -0
- package/esm/src/providers/google/usage.js +49 -0
- package/esm/src/providers/live.d.ts +6 -0
- package/esm/src/providers/live.js +6 -0
- package/esm/src/providers/local/embedding-protocol.d.ts +7 -0
- package/esm/src/providers/local/embedding-protocol.js +60 -0
- package/esm/src/providers/local/provider.d.ts +7 -0
- package/esm/src/providers/local/provider.js +28 -0
- package/esm/src/providers/mod.d.ts +32 -0
- package/esm/src/providers/mod.js +23 -0
- package/esm/src/providers/open-ai/protocol.d.ts +3 -0
- package/esm/src/providers/open-ai/protocol.js +189 -0
- package/esm/src/providers/openrouter/embedding-protocol.d.ts +6 -0
- package/esm/src/providers/openrouter/embedding-protocol.js +86 -0
- package/esm/src/providers/openrouter/image.d.ts +15 -0
- package/esm/src/providers/openrouter/image.js +34 -0
- package/esm/src/providers/openrouter/images-protocol.d.ts +3 -0
- package/esm/src/providers/openrouter/images-protocol.js +82 -0
- package/esm/src/providers/openrouter/openai/compat.d.ts +19 -0
- package/esm/src/providers/openrouter/openai/compat.js +162 -0
- package/esm/src/providers/openrouter/openai/image-payload.d.ts +9 -0
- package/esm/src/providers/openrouter/openai/image-payload.js +115 -0
- package/esm/src/providers/openrouter/openai/reasoning-state.d.ts +2 -0
- package/esm/src/providers/openrouter/openai/reasoning-state.js +31 -0
- package/esm/src/providers/openrouter/openai/usage.d.ts +8 -0
- package/esm/src/providers/openrouter/openai/usage.js +56 -0
- package/esm/src/providers/openrouter/protocol.d.ts +8 -0
- package/esm/src/providers/openrouter/protocol.js +171 -0
- package/esm/src/providers/openrouter/provider.d.ts +10 -0
- package/esm/src/providers/openrouter/provider.js +50 -0
- package/esm/src/providers/shared/carried-tool-files.d.ts +7 -0
- package/esm/src/providers/shared/carried-tool-files.js +43 -0
- package/esm/src/providers/shared/pcm.d.ts +14 -0
- package/esm/src/providers/shared/pcm.js +78 -0
- package/esm/src/providers/shared/protocol-events.d.ts +8 -0
- package/esm/src/providers/shared/protocol-events.js +20 -0
- package/esm/src/providers/shared/response-identity.d.ts +11 -0
- package/esm/src/providers/shared/response-identity.js +12 -0
- package/esm/src/providers/shared/retry.d.ts +17 -0
- package/esm/src/providers/shared/retry.js +90 -0
- package/esm/src/providers/shared/sse.d.ts +6 -0
- package/esm/src/providers/shared/sse.js +93 -0
- package/esm/src/providers/shared/structured-output.d.ts +4 -0
- package/esm/src/providers/shared/structured-output.js +11 -0
- package/esm/src/providers/shared/tool-args.d.ts +24 -0
- package/esm/src/providers/shared/tool-args.js +88 -0
- package/esm/src/providers/shared/tool-draft.d.ts +16 -0
- package/esm/src/providers/shared/tool-draft.js +14 -0
- package/esm/src/providers/shared/upstream-tap.d.ts +8 -0
- package/esm/src/providers/shared/upstream-tap.js +85 -0
- package/esm/src/providers/shared/upstream-tape.d.ts +6 -0
- package/esm/src/providers/shared/upstream-tape.js +88 -0
- package/esm/src/providers/system-one/protocol.d.ts +8 -0
- package/esm/src/providers/system-one/protocol.js +93 -0
- package/esm/src/providers/types.d.ts +51 -0
- package/esm/src/providers/types.js +2 -0
- package/esm/src/providers/typesafe/provider.d.ts +7 -0
- package/esm/src/providers/typesafe/provider.js +24 -0
- package/esm/src/surface/formats.d.ts +46 -0
- package/esm/src/surface/formats.js +178 -0
- package/esm/src/surface/mod.d.ts +16 -0
- package/esm/src/surface/mod.js +12 -0
- package/esm/src/surface/runtime.d.ts +44 -0
- package/esm/src/surface/runtime.js +441 -0
- package/esm/src/surface/tools.d.ts +9 -0
- package/esm/src/surface/tools.js +62 -0
- package/esm/src/surface/types.d.ts +110 -0
- package/esm/src/surface/types.js +4 -0
- package/package.json +100 -4
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/** labels-exempt-file: authoring request-field and export meta — not runtime user or model copy (P2) */
|
|
2
|
+
/** The catalog of the fields a `runTurn` request takes, keyed `runTurn.<field>`. */
|
|
3
|
+
export const REQUEST_FIELDS = {
|
|
4
|
+
'runTurn.pageExecution': {
|
|
5
|
+
type: 'PageToolExecution',
|
|
6
|
+
doc: 'Host-issued browser dispatch with a claimed operation and correlated result.',
|
|
7
|
+
},
|
|
8
|
+
'runTurn.execution': {
|
|
9
|
+
type: 'ToolExecutionCoordinator',
|
|
10
|
+
doc: 'Host-owned atomic tool claims and outcomes. Never sent to providers.',
|
|
11
|
+
},
|
|
12
|
+
'runTurn.providerState': {
|
|
13
|
+
type: 'ProviderCheckpoint',
|
|
14
|
+
doc: 'Native provider state saved alongside portable history.',
|
|
15
|
+
},
|
|
16
|
+
'runTurn.profile': {
|
|
17
|
+
type: 'string',
|
|
18
|
+
doc: 'The id of the registered profile the turn runs.',
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
'runTurn.input': { type: 'TurnInput', doc: 'What the user sent for the turn.' },
|
|
22
|
+
'runTurn.input.text': { type: 'string', doc: "The user's message." },
|
|
23
|
+
'runTurn.input.role': {
|
|
24
|
+
type: 'string',
|
|
25
|
+
doc: 'Picks the instruction of that name from identity.systemByRole.',
|
|
26
|
+
unset: 'The profile instruction',
|
|
27
|
+
},
|
|
28
|
+
'runTurn.input.slots': {
|
|
29
|
+
type: 'Record<string, string>',
|
|
30
|
+
doc: 'The choice the turn makes for each slot the profile declares in inputs.slots; a slot or a value the profile does not declare is refused.',
|
|
31
|
+
},
|
|
32
|
+
'runTurn.input.context': {
|
|
33
|
+
type: "Partial<Record<'client' | 'server', unknown>>",
|
|
34
|
+
doc: "What the page (client) or the host (server) wants the model to know, as any JSON or text; a sender the profile's inputs.context does not list, or a package over its maxChars, is refused.",
|
|
35
|
+
unset: 'No context',
|
|
36
|
+
},
|
|
37
|
+
'runTurn.input.attachments': {
|
|
38
|
+
type: 'Array<TurnBlob | TurnMediaRef>',
|
|
39
|
+
doc: "Files sent with the turn, as bytes or as a provider file reference; each must pass the profile's inputs.attachments.",
|
|
40
|
+
},
|
|
41
|
+
'runTurn.input.voice': {
|
|
42
|
+
type: 'TurnBlob[]',
|
|
43
|
+
doc: "Recorded speech sent with the turn; each must pass the profile's inputs.voice.",
|
|
44
|
+
},
|
|
45
|
+
'runTurn.input.history': {
|
|
46
|
+
type: 'TurnHistoryMessage[]',
|
|
47
|
+
doc: 'The earlier messages of the conversation, when the host keeps them.',
|
|
48
|
+
unset: 'The turn starts a new conversation',
|
|
49
|
+
},
|
|
50
|
+
'runTurn.input.repair': {
|
|
51
|
+
type: 'TurnRepairRequest',
|
|
52
|
+
doc: 'A reply your host rejected and why, so that the model writes it again.',
|
|
53
|
+
},
|
|
54
|
+
'runTurn.input.historyTokens': {
|
|
55
|
+
type: 'number',
|
|
56
|
+
doc: "Your count of the history's tokens, used by compaction that meters history.",
|
|
57
|
+
unset: "Theorem's own estimate",
|
|
58
|
+
},
|
|
59
|
+
'runTurn.input.inputTokens': {
|
|
60
|
+
type: 'number',
|
|
61
|
+
doc: "Your count of the whole prompt's tokens, used by compaction that meters input before the call.",
|
|
62
|
+
},
|
|
63
|
+
'runTurn.model': {
|
|
64
|
+
type: 'string',
|
|
65
|
+
doc: "The model id the turn picks from the profile's models; refused unless the profile sets allowModelSelect.",
|
|
66
|
+
unset: "The profile's defaultModel",
|
|
67
|
+
},
|
|
68
|
+
'runTurn.effort': {
|
|
69
|
+
type: 'string',
|
|
70
|
+
doc: "The effort the turn picks from the model's efforts; refused unless the model sets allowEffortSelect.",
|
|
71
|
+
unset: "The model's default effort",
|
|
72
|
+
},
|
|
73
|
+
'runTurn.builtInArgs': {
|
|
74
|
+
type: 'Record<BuiltinToolId, JsonObject>',
|
|
75
|
+
doc: "Args for the provider's own tools on the chosen model's builtInTools, by tool id; each is checked by the schema the provider declares for that tool.",
|
|
76
|
+
unset: 'Each built-in runs with no args',
|
|
77
|
+
},
|
|
78
|
+
'runTurn.system': {
|
|
79
|
+
type: 'SystemPrompt',
|
|
80
|
+
doc: "An instruction for this request only, added to the profile's own.",
|
|
81
|
+
},
|
|
82
|
+
'runTurn.path': {
|
|
83
|
+
type: 'string',
|
|
84
|
+
doc: 'The channel the turn comes from; only tools whose paths name it, or *, are offered.',
|
|
85
|
+
unset: 'Only tools on every path',
|
|
86
|
+
},
|
|
87
|
+
'runTurn.sessionPermissions': {
|
|
88
|
+
type: 'string[]',
|
|
89
|
+
doc: 'The tools the user has already approved for this session.',
|
|
90
|
+
},
|
|
91
|
+
'runTurn.credentials': {
|
|
92
|
+
type: 'ToolCredentialSource',
|
|
93
|
+
doc: 'Where an HTTP or MCP tool gets the credential for its auth slot.',
|
|
94
|
+
},
|
|
95
|
+
'runTurn.host': {
|
|
96
|
+
type: 'unknown',
|
|
97
|
+
doc: 'Your own context, handed to tool handlers as ctx.host; Theorem never reads or records it.',
|
|
98
|
+
},
|
|
99
|
+
'runTurn.signal': {
|
|
100
|
+
type: 'AbortSignal',
|
|
101
|
+
doc: 'Stops the turn when it aborts, and cancels the provider call where the provider can.',
|
|
102
|
+
},
|
|
103
|
+
'runTurn.sessionId': {
|
|
104
|
+
type: 'string',
|
|
105
|
+
doc: 'A session key that OpenRouter uses for routing and caching.',
|
|
106
|
+
},
|
|
107
|
+
'runTurn.projectId': {
|
|
108
|
+
type: 'string',
|
|
109
|
+
doc: 'Your project id, recorded on the trace.',
|
|
110
|
+
},
|
|
111
|
+
'runTurn.conversationId': {
|
|
112
|
+
type: 'string',
|
|
113
|
+
doc: 'Your conversation id, recorded on the trace.',
|
|
114
|
+
},
|
|
115
|
+
'runTurn.metadata': {
|
|
116
|
+
type: 'Record<string, unknown>',
|
|
117
|
+
doc: 'Your own values, kept on the trace; Theorem does not read them.',
|
|
118
|
+
},
|
|
119
|
+
'runTurn.traceparent': {
|
|
120
|
+
type: 'string',
|
|
121
|
+
doc: "The W3C traceparent of your span; the turn's trace joins it as a child.",
|
|
122
|
+
unset: 'The turn starts a new trace',
|
|
123
|
+
},
|
|
124
|
+
'runTurn.links': {
|
|
125
|
+
type: 'TurnTraceLink[]',
|
|
126
|
+
doc: 'Earlier traces this turn follows: a resume, a continue, or a retry.',
|
|
127
|
+
},
|
|
128
|
+
'runTurn.continueFrom': {
|
|
129
|
+
type: 'TurnContinueFrom',
|
|
130
|
+
doc: 'Continues a turn that stopped in a way the profile lets a turn continue.',
|
|
131
|
+
},
|
|
132
|
+
'runTurn.continuation': {
|
|
133
|
+
type: 'number',
|
|
134
|
+
doc: 'Which continue attempt this is, from 1; checked against the maxContinues of the profile.',
|
|
135
|
+
},
|
|
136
|
+
'runTurn.speech': {
|
|
137
|
+
type: 'TurnSpeech',
|
|
138
|
+
doc: "This turn's voice, style, and speed; each one given replaces the profile's speech field of that name. Refused on a profile that is not speech.",
|
|
139
|
+
unset: "The profile's speech settings",
|
|
140
|
+
},
|
|
141
|
+
'runTurn.resolveHost': {
|
|
142
|
+
type: 'ResolveHost',
|
|
143
|
+
doc: 'Resolves the host name of a remote tool before each request; a name that resolves to a private address is refused.',
|
|
144
|
+
},
|
|
145
|
+
'runTurn.onStage': {
|
|
146
|
+
type: 'StageHandler',
|
|
147
|
+
doc: 'Your function that sees each stage of a text turn and can answer with what the stage allows.',
|
|
148
|
+
},
|
|
149
|
+
'runTurn.onAgentCall': {
|
|
150
|
+
type: 'AgentCallHook',
|
|
151
|
+
doc: 'Runs before each agent tool call, to shape the request to the called agent or to refuse the call.',
|
|
152
|
+
unset: 'The agent runs on what the model sent',
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
/** The catalog of the exports a builder calls by name, keyed by that name. */
|
|
156
|
+
export const API_EXPORTS = {
|
|
157
|
+
defineProfile: {
|
|
158
|
+
kind: 'function',
|
|
159
|
+
doc: 'Checks a profile and returns it; a field the profile type cannot take is a config error.',
|
|
160
|
+
},
|
|
161
|
+
registerProfile: {
|
|
162
|
+
kind: 'function',
|
|
163
|
+
doc: 'Stores a profile under its id, so that a request can name it.',
|
|
164
|
+
},
|
|
165
|
+
registerTool: {
|
|
166
|
+
kind: 'function',
|
|
167
|
+
doc: 'Stores a tool under its name, so that a profile can list it in tools.allow.',
|
|
168
|
+
},
|
|
169
|
+
registerStructured: {
|
|
170
|
+
kind: 'function',
|
|
171
|
+
doc: 'Stores a JSON Schema under an id, so that a profile can name it in outputs.structured.',
|
|
172
|
+
},
|
|
173
|
+
registerTraceDestination: {
|
|
174
|
+
kind: 'function',
|
|
175
|
+
doc: 'Stores a place to write traces under an id, so that a profile can name it in observability.',
|
|
176
|
+
},
|
|
177
|
+
defineProvider: {
|
|
178
|
+
kind: 'function',
|
|
179
|
+
doc: 'Validates a provider definition and supplies its typed model helper.',
|
|
180
|
+
},
|
|
181
|
+
registerProvider: {
|
|
182
|
+
kind: 'function',
|
|
183
|
+
doc: 'Registers a provider instance before profiles reference its ID.',
|
|
184
|
+
},
|
|
185
|
+
runTurn: {
|
|
186
|
+
kind: 'function',
|
|
187
|
+
doc: 'Runs one turn of a text, image, or speech profile and yields its events.',
|
|
188
|
+
},
|
|
189
|
+
runSession: {
|
|
190
|
+
kind: 'function',
|
|
191
|
+
doc: 'Runs a realtime voice or video session of a live profile.',
|
|
192
|
+
},
|
|
193
|
+
runDecision: {
|
|
194
|
+
kind: 'function',
|
|
195
|
+
doc: 'Asks a decision profile its questions about your JSON state and returns checked answers.',
|
|
196
|
+
},
|
|
197
|
+
invokeTool: {
|
|
198
|
+
kind: 'function',
|
|
199
|
+
doc: 'Runs one registered tool through a profile, with no model.',
|
|
200
|
+
},
|
|
201
|
+
runTool: {
|
|
202
|
+
kind: 'function',
|
|
203
|
+
doc: 'Runs one registered tool through a profile, with no model, and returns how the call settled.',
|
|
204
|
+
},
|
|
205
|
+
compactHistory: {
|
|
206
|
+
kind: 'function',
|
|
207
|
+
doc: 'Shortens a conversation history with the compaction the profile sets.',
|
|
208
|
+
},
|
|
209
|
+
takeSlot: {
|
|
210
|
+
kind: 'function',
|
|
211
|
+
doc: "Takes a client's turn slot on a profile; it answers ok, busy, quota, or not_configured.",
|
|
212
|
+
},
|
|
213
|
+
releaseSlot: {
|
|
214
|
+
kind: 'function',
|
|
215
|
+
doc: 'Frees the turn slot that takeSlot gave.',
|
|
216
|
+
},
|
|
217
|
+
overrideLabels: {
|
|
218
|
+
kind: 'function',
|
|
219
|
+
doc: "Replaces status lines for every profile in the process; a profile's own labels wins.",
|
|
220
|
+
},
|
|
221
|
+
resetLabels: {
|
|
222
|
+
kind: 'function',
|
|
223
|
+
doc: 'Removes every replacement that overrideLabels made.',
|
|
224
|
+
},
|
|
225
|
+
TheoremError: {
|
|
226
|
+
kind: 'class',
|
|
227
|
+
doc: 'The error Theorem throws; its kind tells your host which status and wording to use.',
|
|
228
|
+
},
|
|
229
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ToolCredential } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Where a call's tool credentials come from. The kernel reads a slot only when a
|
|
4
|
+
* tool that signs in runs, so a turn opens no credential it does not use.
|
|
5
|
+
*/
|
|
6
|
+
export interface ToolCredentialSource {
|
|
7
|
+
/** The slot's credential, or `undefined` when the person has not signed in. */
|
|
8
|
+
get(slot: string): Promise<ToolCredential | undefined>;
|
|
9
|
+
/**
|
|
10
|
+
* A new credential for the slot: a refreshed OAuth token, or a key typed at a
|
|
11
|
+
* sign-in gate. The call goes on only once it resolves, so persist it here; a
|
|
12
|
+
* rotated refresh token lost to a closed stream cannot be recovered.
|
|
13
|
+
*/
|
|
14
|
+
set(slot: string, credential: ToolCredential): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* The secret of a confidential OAuth client, read when the kernel refreshes a token
|
|
17
|
+
* issued to `clientId`. Omit it for public clients. The secret is the host's, not
|
|
18
|
+
* the person's, so it never lives on a stored credential.
|
|
19
|
+
*/
|
|
20
|
+
clientSecret?(clientId: string): Promise<string | undefined>;
|
|
21
|
+
}
|
|
22
|
+
/** A source held in memory, seeded from `initial` (copied, never written back). */
|
|
23
|
+
export declare function memoryCredentialSource(initial?: Readonly<Record<string, ToolCredential>>): ToolCredentialSource;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** A source held in memory, seeded from `initial` (copied, never written back). */
|
|
2
|
+
export function memoryCredentialSource(initial = {}) {
|
|
3
|
+
const slots = new Map(Object.entries(initial));
|
|
4
|
+
return {
|
|
5
|
+
get: (slot) => Promise.resolve(slots.get(slot)),
|
|
6
|
+
set: (slot, credential) => {
|
|
7
|
+
slots.set(slot, credential);
|
|
8
|
+
return Promise.resolve();
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** RFC 4648 base64url, without padding. */
|
|
2
|
+
export declare function toBase64Url(bytes: Uint8Array): string;
|
|
3
|
+
/** Decodes base64url text into bytes. */
|
|
4
|
+
export declare function fromBase64Url(base64url: string): Uint8Array<ArrayBuffer>;
|
|
5
|
+
/** RFC 7636 §4.1: 43 to 128 characters, drawn without modulo bias. */
|
|
6
|
+
export declare function generateCodeVerifier(length?: number): string;
|
|
7
|
+
/** RFC 7636 §4.2 S256. */
|
|
8
|
+
export declare function computeCodeChallenge(verifier: string): Promise<string>;
|
|
9
|
+
/** What a sealed PKCE state carries between starting and finishing a sign-in. */
|
|
10
|
+
export interface SealedStatePayload {
|
|
11
|
+
codeVerifier: string;
|
|
12
|
+
expectedIssuer: string;
|
|
13
|
+
/** RFC 9207: a response without `iss` is refused. */
|
|
14
|
+
issRequired: boolean;
|
|
15
|
+
/** Fixed when the flow began. */
|
|
16
|
+
tokenEndpoint: string;
|
|
17
|
+
resource: string;
|
|
18
|
+
redirectUri: string;
|
|
19
|
+
/** Epoch milliseconds. */
|
|
20
|
+
expiresAt: number;
|
|
21
|
+
clientId: string;
|
|
22
|
+
/** SHA-256 of the host's session binding. */
|
|
23
|
+
sessionBinding: string;
|
|
24
|
+
/** The scopes the flow asked for; a grant may hold none beyond them. Empty asks for the server's default. */
|
|
25
|
+
scopes: string[];
|
|
26
|
+
}
|
|
27
|
+
/** Encrypted, not only signed: the state crosses the browser and the server, and the PKCE verifier must stay secret. */
|
|
28
|
+
export declare function sealStatePayload(payload: SealedStatePayload, secret: string): Promise<string>;
|
|
29
|
+
/** Opens a sealed PKCE state; throws when the secret or the seal is wrong. */
|
|
30
|
+
export declare function unsealStatePayload(sealed: string, secret: string): Promise<SealedStatePayload>;
|
|
31
|
+
/** What `sealSecret` takes: the plaintext and the sealing key. */
|
|
32
|
+
export interface SealSecretInput {
|
|
33
|
+
plaintext: string;
|
|
34
|
+
/** The host's sealing key: at least 32 bytes, kept apart from where sealed values are stored. */
|
|
35
|
+
key: string;
|
|
36
|
+
/** What the sealed value belongs to, such as owner, slot, and row. Opening needs the same list. */
|
|
37
|
+
binding: readonly string[];
|
|
38
|
+
/** Names `key`, so a rotated key still opens what an older one sealed. */
|
|
39
|
+
keyVersion: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Seals a stored credential. AES-256-GCM under a key derived per seal; the key
|
|
43
|
+
* version and binding are authenticated, so a value copied to another owner,
|
|
44
|
+
* slot or row does not open.
|
|
45
|
+
*/
|
|
46
|
+
export declare function sealSecret(input: SealSecretInput): Promise<string>;
|
|
47
|
+
/** What `openSecret` takes: the sealed value and the keys still in use. */
|
|
48
|
+
export interface OpenSecretInput {
|
|
49
|
+
sealed: string;
|
|
50
|
+
/** Every key still in use, by version. */
|
|
51
|
+
keys: Readonly<Record<number, string>>;
|
|
52
|
+
/** The binding the value was sealed with. */
|
|
53
|
+
binding: readonly string[];
|
|
54
|
+
}
|
|
55
|
+
/** Opens what `sealSecret` sealed; throws when the envelope, key version, or binding does not match. */
|
|
56
|
+
export declare function openSecret(input: OpenSecretInput): Promise<string>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { base64ToBytes, bytesToBase64 } from '../util/base64.js';
|
|
2
|
+
/** RFC 4648 base64url, without padding. */
|
|
3
|
+
export function toBase64Url(bytes) {
|
|
4
|
+
return bytesToBase64(bytes).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
5
|
+
}
|
|
6
|
+
/** Decodes base64url text into bytes. */
|
|
7
|
+
export function fromBase64Url(base64url) {
|
|
8
|
+
let base64 = base64url.replace(/-/g, '+').replace(/_/g, '/');
|
|
9
|
+
while (base64.length % 4 !== 0) {
|
|
10
|
+
base64 += '=';
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return base64ToBytes(base64);
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
throw new Error(`Invalid base64url encoding: ${err instanceof Error ? err.message : String(err)}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** RFC 7636 §4.1: 43 to 128 characters, drawn without modulo bias. */
|
|
20
|
+
export function generateCodeVerifier(length = 64) {
|
|
21
|
+
if (length < 43 || length > 128) {
|
|
22
|
+
throw new RangeError(`Invalid PKCE code_verifier length: ${length}. RFC 7636 Section 4.1 requires length between 43 and 128 characters.`);
|
|
23
|
+
}
|
|
24
|
+
const validChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~';
|
|
25
|
+
const maxValid = 256 - (256 % validChars.length); // why: 198 (66 * 3): rejecting above it removes modulo bias
|
|
26
|
+
let verifier = '';
|
|
27
|
+
const buffer = new Uint8Array(length * 2);
|
|
28
|
+
while (verifier.length < length) {
|
|
29
|
+
crypto.getRandomValues(buffer);
|
|
30
|
+
for (let i = 0; i < buffer.length && verifier.length < length; i++) {
|
|
31
|
+
const val = buffer[i];
|
|
32
|
+
if (val !== undefined && val < maxValid) {
|
|
33
|
+
verifier += validChars[val % validChars.length];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return verifier;
|
|
38
|
+
}
|
|
39
|
+
/** RFC 7636 §4.2 S256. */
|
|
40
|
+
export async function computeCodeChallenge(verifier) {
|
|
41
|
+
const encoder = new TextEncoder();
|
|
42
|
+
const data = encoder.encode(verifier);
|
|
43
|
+
const digest = await crypto.subtle.digest('SHA-256', data);
|
|
44
|
+
return toBase64Url(new Uint8Array(digest));
|
|
45
|
+
}
|
|
46
|
+
/** A secret shorter than 256 bits would be the weak link. */
|
|
47
|
+
const MIN_SECRET_BYTES = 32;
|
|
48
|
+
/** Public domain-separation labels, not secrets: each use of a host secret derives a key no other use shares. */
|
|
49
|
+
const STATE_CONTEXT = 'theorem/oauth-state/v1';
|
|
50
|
+
const SEAL_CONTEXT = 'theorem/sealed-secret/v1';
|
|
51
|
+
const IV_BYTES = 12;
|
|
52
|
+
/** A fresh salt per seal gives every seal its own key, so no key sees enough random nonces for one to repeat. */
|
|
53
|
+
const SALT_BYTES = 32;
|
|
54
|
+
/** Authenticated with the ciphertext, so a later scheme can be told apart and an old one is never guessed at. */
|
|
55
|
+
const ENVELOPE_VERSION = 'v1';
|
|
56
|
+
async function sealKey(secret, salt, info, label) {
|
|
57
|
+
const encoder = new TextEncoder();
|
|
58
|
+
const secretBytes = encoder.encode(secret);
|
|
59
|
+
if (secretBytes.length < MIN_SECRET_BYTES) {
|
|
60
|
+
throw new RangeError(`${label} must be at least ${MIN_SECRET_BYTES} bytes; got ${secretBytes.length}`);
|
|
61
|
+
}
|
|
62
|
+
const base = await crypto.subtle.importKey('raw', secretBytes, 'HKDF', false, ['deriveKey']);
|
|
63
|
+
return crypto.subtle.deriveKey({ name: 'HKDF', hash: 'SHA-256', salt: salt, info: encoder.encode(info) }, base, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']);
|
|
64
|
+
}
|
|
65
|
+
/** `salt.iv.ciphertext`, base64url: AES-256-GCM under a key derived per seal. */
|
|
66
|
+
async function sealBytes(plaintext, secret, scheme) {
|
|
67
|
+
const salt = crypto.getRandomValues(new Uint8Array(SALT_BYTES));
|
|
68
|
+
const key = await sealKey(secret, salt, scheme.info, scheme.label);
|
|
69
|
+
const iv = crypto.getRandomValues(new Uint8Array(IV_BYTES));
|
|
70
|
+
const ciphertext = await crypto.subtle.encrypt({
|
|
71
|
+
name: 'AES-GCM',
|
|
72
|
+
iv: iv,
|
|
73
|
+
additionalData: new TextEncoder().encode(scheme.associatedData),
|
|
74
|
+
}, key, new TextEncoder().encode(plaintext));
|
|
75
|
+
return [toBase64Url(salt), toBase64Url(iv), toBase64Url(new Uint8Array(ciphertext))].join('.');
|
|
76
|
+
}
|
|
77
|
+
/** The plaintext `sealBytes` sealed, or null when the envelope does not open under this secret and data. */
|
|
78
|
+
async function openBytes(parts, secret, scheme) {
|
|
79
|
+
const [saltB64, ivB64, ciphertextB64] = parts;
|
|
80
|
+
if (saltB64 === undefined || ivB64 === undefined || ciphertextB64 === undefined)
|
|
81
|
+
return null;
|
|
82
|
+
const key = await sealKey(secret, fromBase64Url(saltB64), scheme.info, scheme.label);
|
|
83
|
+
try {
|
|
84
|
+
const plaintext = await crypto.subtle.decrypt({
|
|
85
|
+
name: 'AES-GCM',
|
|
86
|
+
iv: fromBase64Url(ivB64),
|
|
87
|
+
additionalData: new TextEncoder().encode(scheme.associatedData),
|
|
88
|
+
}, key, fromBase64Url(ciphertextB64));
|
|
89
|
+
return new TextDecoder().decode(plaintext);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const STATE_SCHEME = {
|
|
96
|
+
info: STATE_CONTEXT,
|
|
97
|
+
label: 'OAuth state secret', // labels-exempt: developer contract / internal diagnostic — not end-user or model copy (P2)
|
|
98
|
+
associatedData: ENVELOPE_VERSION,
|
|
99
|
+
};
|
|
100
|
+
/** Encrypted, not only signed: the state crosses the browser and the server, and the PKCE verifier must stay secret. */
|
|
101
|
+
export async function sealStatePayload(payload, secret) {
|
|
102
|
+
const envelope = await sealBytes(JSON.stringify(payload), secret, STATE_SCHEME);
|
|
103
|
+
return [ENVELOPE_VERSION, envelope].join('.');
|
|
104
|
+
}
|
|
105
|
+
/** Opens a sealed PKCE state; throws when the secret or the seal is wrong. */
|
|
106
|
+
export async function unsealStatePayload(sealed, secret) {
|
|
107
|
+
const [version, ...parts] = sealed.split('.');
|
|
108
|
+
if (version !== ENVELOPE_VERSION || parts.length !== 3) {
|
|
109
|
+
throw new Error('Invalid sealed state format'); // labels-exempt: developer contract / internal diagnostic — not end-user or model copy (P2)
|
|
110
|
+
}
|
|
111
|
+
const plaintext = await openBytes(parts, secret, STATE_SCHEME);
|
|
112
|
+
if (plaintext === null) {
|
|
113
|
+
throw new Error('OAuth state could not be opened: it was tampered with, corrupted, or sealed with another secret');
|
|
114
|
+
}
|
|
115
|
+
const payload = JSON.parse(plaintext);
|
|
116
|
+
if (!Array.isArray(payload.scopes)) {
|
|
117
|
+
throw new Error('Invalid sealed state format'); // labels-exempt: developer contract / internal diagnostic — not end-user or model copy (P2)
|
|
118
|
+
}
|
|
119
|
+
if (Date.now() > payload.expiresAt) {
|
|
120
|
+
throw new Error('OAuth state has expired'); // labels-exempt: developer contract / internal diagnostic — not end-user or model copy (P2)
|
|
121
|
+
}
|
|
122
|
+
return payload;
|
|
123
|
+
}
|
|
124
|
+
function secretScheme(keyVersion, binding) {
|
|
125
|
+
return {
|
|
126
|
+
info: SEAL_CONTEXT,
|
|
127
|
+
label: 'Secret sealing key', // labels-exempt: developer contract / internal diagnostic — not end-user or model copy (P2)
|
|
128
|
+
associatedData: JSON.stringify([ENVELOPE_VERSION, keyVersion, binding]),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function assertKeyVersion(keyVersion) {
|
|
132
|
+
if (!Number.isSafeInteger(keyVersion) || keyVersion < 0) {
|
|
133
|
+
throw new RangeError(`Key version must be a non-negative integer; got ${keyVersion}`); // labels-exempt: developer contract / internal diagnostic — not end-user or model copy (P2)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Seals a stored credential. AES-256-GCM under a key derived per seal; the key
|
|
138
|
+
* version and binding are authenticated, so a value copied to another owner,
|
|
139
|
+
* slot or row does not open.
|
|
140
|
+
*/
|
|
141
|
+
export async function sealSecret(input) {
|
|
142
|
+
assertKeyVersion(input.keyVersion);
|
|
143
|
+
const scheme = secretScheme(input.keyVersion, input.binding);
|
|
144
|
+
const envelope = await sealBytes(input.plaintext, input.key, scheme);
|
|
145
|
+
return [ENVELOPE_VERSION, String(input.keyVersion), envelope].join('.');
|
|
146
|
+
}
|
|
147
|
+
/** Opens what `sealSecret` sealed; throws when the envelope, key version, or binding does not match. */
|
|
148
|
+
export async function openSecret(input) {
|
|
149
|
+
const [version, keyVersionText, ...parts] = input.sealed.split('.');
|
|
150
|
+
const keyVersion = Number(keyVersionText);
|
|
151
|
+
if (version !== ENVELOPE_VERSION || parts.length !== 3 || !/^\d+$/.test(keyVersionText ?? '')) {
|
|
152
|
+
throw new Error('Invalid sealed secret format'); // labels-exempt: developer contract / internal diagnostic — not end-user or model copy (P2)
|
|
153
|
+
}
|
|
154
|
+
const key = input.keys[keyVersion];
|
|
155
|
+
if (key === undefined) {
|
|
156
|
+
throw new Error(`No key for sealed secret key version ${keyVersion}`); // labels-exempt: developer contract / internal diagnostic — not end-user or model copy (P2)
|
|
157
|
+
}
|
|
158
|
+
const plaintext = await openBytes(parts, key, secretScheme(keyVersion, input.binding));
|
|
159
|
+
if (plaintext === null) {
|
|
160
|
+
throw new Error('Sealed secret could not be opened: it was tampered with, bound to something else, or sealed with another key');
|
|
161
|
+
}
|
|
162
|
+
return plaintext;
|
|
163
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AuthorizationServerMetadata, CreatePkceFlowOptions, ExchangePkceCodeOptions, ExchangePkceCodeResult, OAuthTransportOptions, PkceFlowResult, ProtectedResourceMetadata, RefreshOAuthTokenOptions } from './types.js';
|
|
2
|
+
/** `undefined` on HTTP 404. RFC 9728 §3.3: a `resource` not identical to `resourceUrl` is refused. */
|
|
3
|
+
export declare function discoverResourceMetadata(resourceUrl: string, transport?: OAuthTransportOptions): Promise<ProtectedResourceMetadata | undefined>;
|
|
4
|
+
/** A non-OK URL moves on to the next; metadata that answers but fails validation is refused outright. */
|
|
5
|
+
export declare function discoverAuthServerMetadata(issuer: string, transport?: OAuthTransportOptions): Promise<AuthorizationServerMetadata>;
|
|
6
|
+
/** Stateless: the verifier, expected issuer, token endpoint, and resource are sealed into `state`. */
|
|
7
|
+
export declare function createOAuthPkceFlow(options: CreatePkceFlowOptions): Promise<PkceFlowResult>;
|
|
8
|
+
/** RFC 9207 §2.4: `iss` is required when the server advertises it, and byte-exact (no URL normalization). */
|
|
9
|
+
export declare function validateIssuer(expectedIssuer: string, receivedIss: string | undefined, issRequired: boolean): void;
|
|
10
|
+
/**
|
|
11
|
+
* Requires the session that began the flow (RFC 6749 §10.12), the same `redirect_uri` (§4.1.3)
|
|
12
|
+
* and a valid `iss` (RFC 9207); posts to the token endpoint sealed in `state`, never a caller's.
|
|
13
|
+
*/
|
|
14
|
+
export declare function exchangeOAuthPkce(options: ExchangePkceCodeOptions): Promise<ExchangePkceCodeResult>;
|
|
15
|
+
/** Exchanges a refresh token for new tokens at the token endpoint; both the endpoint and the resource must be https URLs. */
|
|
16
|
+
export declare function refreshOAuthToken(options: RefreshOAuthTokenOptions): Promise<ExchangePkceCodeResult>;
|
|
17
|
+
/** RFC 8707: the same origin, and the resource's path or below it. */
|
|
18
|
+
export declare function tokenAudienceCovers(resource: string, url: URL): boolean;
|