@theoremjs/agents 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +1264 -2
- package/esm/_dnt.polyfills.d.ts +66 -0
- package/esm/_dnt.polyfills.js +51 -0
- package/esm/mod.d.ts +65 -0
- package/esm/mod.js +42 -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 +458 -0
- package/esm/src/cli/commands/egress-compile.d.ts +17 -0
- package/esm/src/cli/commands/egress-compile.js +25 -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 +202 -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 +25 -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 +72 -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 +4 -0
- package/esm/src/evals/attachments.js +53 -0
- package/esm/src/evals/breakdown.d.ts +28 -0
- package/esm/src/evals/breakdown.js +68 -0
- package/esm/src/evals/graders/answer.d.ts +13 -0
- package/esm/src/evals/graders/answer.js +133 -0
- package/esm/src/evals/graders/code.d.ts +64 -0
- package/esm/src/evals/graders/code.js +205 -0
- package/esm/src/evals/graders/judge.d.ts +20 -0
- package/esm/src/evals/graders/judge.js +365 -0
- package/esm/src/evals/graders/latency.d.ts +5 -0
- package/esm/src/evals/graders/latency.js +81 -0
- package/esm/src/evals/graders/live.d.ts +11 -0
- package/esm/src/evals/graders/live.js +40 -0
- package/esm/src/evals/graders/media.d.ts +18 -0
- package/esm/src/evals/graders/media.js +92 -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 +17 -0
- package/esm/src/evals/graders/transcript.js +200 -0
- package/esm/src/evals/mod.d.ts +42 -0
- package/esm/src/evals/mod.js +30 -0
- package/esm/src/evals/record.d.ts +35 -0
- package/esm/src/evals/record.js +105 -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 +118 -0
- package/esm/src/evals/run.js +452 -0
- package/esm/src/evals/suite.d.ts +19 -0
- package/esm/src/evals/suite.js +92 -0
- package/esm/src/evals/summary.d.ts +32 -0
- package/esm/src/evals/summary.js +30 -0
- package/esm/src/evals/trial.d.ts +27 -0
- package/esm/src/evals/trial.js +158 -0
- package/esm/src/evals/types.d.ts +260 -0
- package/esm/src/evals/types.js +126 -0
- package/esm/src/evals/verdict.d.ts +18 -0
- package/esm/src/evals/verdict.js +45 -0
- package/esm/src/guardrails/canary-gate.d.ts +21 -0
- package/esm/src/guardrails/canary-gate.js +40 -0
- package/esm/src/guardrails/canary.d.ts +112 -0
- package/esm/src/guardrails/canary.js +901 -0
- package/esm/src/guardrails/compile-egress.d.ts +11 -0
- package/esm/src/guardrails/compile-egress.js +11 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.d.ts +22 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.js +303 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.d.ts +5 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.js +202 -0
- package/esm/src/guardrails/corpus/inbound-payloads.d.ts +3 -0
- package/esm/src/guardrails/corpus/inbound-payloads.js +118 -0
- package/esm/src/guardrails/corpus/live-attacks.d.ts +13 -0
- package/esm/src/guardrails/corpus/live-attacks.js +224 -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 +32 -0
- package/esm/src/guardrails/corpus/types.js +1 -0
- package/esm/src/guardrails/egress-automata.d.ts +14 -0
- package/esm/src/guardrails/egress-automata.js +6059 -0
- package/esm/src/guardrails/egress-compiler.d.ts +33 -0
- package/esm/src/guardrails/egress-compiler.js +237 -0
- package/esm/src/guardrails/egress-patterns.d.ts +24 -0
- package/esm/src/guardrails/egress-patterns.js +32 -0
- package/esm/src/guardrails/egress-policy.d.ts +27 -0
- package/esm/src/guardrails/egress-policy.js +76 -0
- package/esm/src/guardrails/egress-rules.d.ts +54 -0
- package/esm/src/guardrails/egress-rules.js +49 -0
- package/esm/src/guardrails/egress-stream.d.ts +105 -0
- package/esm/src/guardrails/egress-stream.js +645 -0
- package/esm/src/guardrails/egress-urls.d.ts +83 -0
- package/esm/src/guardrails/egress-urls.js +917 -0
- package/esm/src/guardrails/egress.d.ts +106 -0
- package/esm/src/guardrails/egress.js +374 -0
- package/esm/src/guardrails/error.d.ts +26 -0
- package/esm/src/guardrails/error.js +91 -0
- package/esm/src/guardrails/event-schemas.d.ts +57 -0
- package/esm/src/guardrails/event-schemas.js +41 -0
- package/esm/src/guardrails/events.d.ts +9 -0
- package/esm/src/guardrails/events.js +42 -0
- package/esm/src/guardrails/hits.d.ts +8 -0
- package/esm/src/guardrails/hits.js +19 -0
- package/esm/src/guardrails/injection-patterns.d.ts +15 -0
- package/esm/src/guardrails/injection-patterns.js +94 -0
- package/esm/src/guardrails/injection.d.ts +14 -0
- package/esm/src/guardrails/injection.js +237 -0
- package/esm/src/guardrails/lexicon.d.ts +30 -0
- package/esm/src/guardrails/lexicon.js +478 -0
- package/esm/src/guardrails/live-outbound-gate.d.ts +54 -0
- package/esm/src/guardrails/live-outbound-gate.js +305 -0
- package/esm/src/guardrails/mod.d.ts +46 -0
- package/esm/src/guardrails/mod.js +29 -0
- package/esm/src/guardrails/network.d.ts +42 -0
- package/esm/src/guardrails/network.js +328 -0
- package/esm/src/guardrails/normalize.d.ts +6 -0
- package/esm/src/guardrails/normalize.js +132 -0
- package/esm/src/guardrails/policy.d.ts +19 -0
- package/esm/src/guardrails/policy.js +50 -0
- package/esm/src/guardrails/progressive-yield.d.ts +69 -0
- package/esm/src/guardrails/progressive-yield.js +237 -0
- package/esm/src/guardrails/prompt-echo.d.ts +38 -0
- package/esm/src/guardrails/prompt-echo.js +225 -0
- package/esm/src/guardrails/quota.d.ts +20 -0
- package/esm/src/guardrails/quota.js +80 -0
- package/esm/src/guardrails/rules.d.ts +56 -0
- package/esm/src/guardrails/rules.js +54 -0
- package/esm/src/guardrails/sanitize.d.ts +23 -0
- package/esm/src/guardrails/sanitize.js +184 -0
- package/esm/src/guardrails/sensitive.d.ts +29 -0
- package/esm/src/guardrails/sensitive.js +113 -0
- package/esm/src/guardrails/serialize.d.ts +14 -0
- package/esm/src/guardrails/serialize.js +37 -0
- package/esm/src/guardrails/testing.d.ts +9 -0
- package/esm/src/guardrails/testing.js +8 -0
- package/esm/src/guardrails/theorem-error.d.ts +18 -0
- package/esm/src/guardrails/theorem-error.js +53 -0
- package/esm/src/guardrails/thought-guard.d.ts +55 -0
- package/esm/src/guardrails/thought-guard.js +464 -0
- package/esm/src/guardrails/tool-directives.d.ts +19 -0
- package/esm/src/guardrails/tool-directives.js +109 -0
- package/esm/src/guardrails/tool-result.d.ts +61 -0
- package/esm/src/guardrails/tool-result.js +248 -0
- package/esm/src/guardrails/types.d.ts +242 -0
- package/esm/src/guardrails/types.js +54 -0
- package/esm/src/host/client-turn.d.ts +9 -0
- package/esm/src/host/client-turn.js +38 -0
- package/esm/src/host/mint-trace.d.ts +28 -0
- package/esm/src/host/mint-trace.js +59 -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 +68 -0
- package/esm/src/host/reply.d.ts +7 -0
- package/esm/src/host/reply.js +35 -0
- package/esm/src/interface/blocks.d.ts +8 -0
- package/esm/src/interface/blocks.js +213 -0
- package/esm/src/interface/composer-actions.d.ts +20 -0
- package/esm/src/interface/composer-actions.js +31 -0
- package/esm/src/interface/draft.d.ts +14 -0
- package/esm/src/interface/draft.js +28 -0
- package/esm/src/interface/from-profile.d.ts +12 -0
- package/esm/src/interface/from-profile.js +144 -0
- package/esm/src/interface/history.d.ts +40 -0
- package/esm/src/interface/history.js +269 -0
- package/esm/src/interface/inputs.d.ts +10 -0
- package/esm/src/interface/inputs.js +64 -0
- package/esm/src/interface/mod.d.ts +31 -0
- package/esm/src/interface/mod.js +21 -0
- package/esm/src/interface/models.d.ts +19 -0
- package/esm/src/interface/models.js +45 -0
- package/esm/src/interface/pending.d.ts +48 -0
- package/esm/src/interface/pending.js +146 -0
- package/esm/src/interface/profile-interface.d.ts +4 -0
- package/esm/src/interface/profile-interface.js +223 -0
- package/esm/src/interface/session.d.ts +64 -0
- package/esm/src/interface/session.js +121 -0
- package/esm/src/interface/tool-calls.d.ts +20 -0
- package/esm/src/interface/tool-calls.js +73 -0
- package/esm/src/interface/tool-invoke.d.ts +4 -0
- package/esm/src/interface/tool-invoke.js +20 -0
- package/esm/src/interface/tool-media.d.ts +9 -0
- package/esm/src/interface/tool-media.js +112 -0
- package/esm/src/interface/types.d.ts +213 -0
- package/esm/src/interface/types.js +4 -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 +51 -0
- package/esm/src/kernel/auth/crypto.js +161 -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 +17 -0
- package/esm/src/kernel/auth/oauth.js +438 -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 +139 -0
- package/esm/src/kernel/auth/types.js +1 -0
- package/esm/src/kernel/default-scope.d.ts +34 -0
- package/esm/src/kernel/default-scope.js +72 -0
- package/esm/src/kernel/engine/compaction.d.ts +70 -0
- package/esm/src/kernel/engine/compaction.js +202 -0
- package/esm/src/kernel/engine/decision.d.ts +41 -0
- package/esm/src/kernel/engine/decision.js +412 -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 +9 -0
- package/esm/src/kernel/engine/live-inbound.js +19 -0
- package/esm/src/kernel/engine/live-ingress.d.ts +9 -0
- package/esm/src/kernel/engine/live-ingress.js +37 -0
- package/esm/src/kernel/engine/media-probe/audio.d.ts +7 -0
- package/esm/src/kernel/engine/media-probe/audio.js +342 -0
- package/esm/src/kernel/engine/media-probe/bytes.d.ts +6 -0
- package/esm/src/kernel/engine/media-probe/bytes.js +26 -0
- package/esm/src/kernel/engine/media-probe/image.d.ts +5 -0
- package/esm/src/kernel/engine/media-probe/image.js +171 -0
- package/esm/src/kernel/engine/media-probe/iso-bmff.d.ts +19 -0
- package/esm/src/kernel/engine/media-probe/iso-bmff.js +48 -0
- package/esm/src/kernel/engine/media-probe/matroska.d.ts +35 -0
- package/esm/src/kernel/engine/media-probe/matroska.js +226 -0
- package/esm/src/kernel/engine/media-probe/mp4.d.ts +22 -0
- package/esm/src/kernel/engine/media-probe/mp4.js +279 -0
- package/esm/src/kernel/engine/media-probe/opus.d.ts +4 -0
- package/esm/src/kernel/engine/media-probe/opus.js +23 -0
- package/esm/src/kernel/engine/media-probe/pdf.d.ts +5 -0
- package/esm/src/kernel/engine/media-probe/pdf.js +117 -0
- package/esm/src/kernel/engine/media-probe/video.d.ts +15 -0
- package/esm/src/kernel/engine/media-probe/video.js +49 -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 +322 -0
- package/esm/src/kernel/engine/runner/mod.d.ts +15 -0
- package/esm/src/kernel/engine/runner/mod.js +574 -0
- package/esm/src/kernel/engine/runner/schema-validation.d.ts +14 -0
- package/esm/src/kernel/engine/runner/schema-validation.js +105 -0
- package/esm/src/kernel/engine/runner/stages.d.ts +28 -0
- package/esm/src/kernel/engine/runner/stages.js +48 -0
- package/esm/src/kernel/engine/runner/state.d.ts +76 -0
- package/esm/src/kernel/engine/runner/state.js +40 -0
- package/esm/src/kernel/engine/runner/steps.d.ts +14 -0
- package/esm/src/kernel/engine/runner/steps.js +360 -0
- package/esm/src/kernel/engine/runner/stream.d.ts +40 -0
- package/esm/src/kernel/engine/runner/stream.js +225 -0
- package/esm/src/kernel/engine/runner/usage.d.ts +45 -0
- package/esm/src/kernel/engine/runner/usage.js +150 -0
- package/esm/src/kernel/engine/session/mod.d.ts +31 -0
- package/esm/src/kernel/engine/session/mod.js +951 -0
- package/esm/src/kernel/engine/session/session-trace.d.ts +115 -0
- package/esm/src/kernel/engine/session/session-trace.js +489 -0
- package/esm/src/kernel/engine/token-estimate.d.ts +77 -0
- package/esm/src/kernel/engine/token-estimate.js +218 -0
- package/esm/src/kernel/engine/tool-trace.d.ts +58 -0
- package/esm/src/kernel/engine/tool-trace.js +131 -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 +118 -0
- package/esm/src/kernel/engine/turn-trace.js +863 -0
- package/esm/src/kernel/engine/usage.d.ts +30 -0
- package/esm/src/kernel/engine/usage.js +134 -0
- package/esm/src/kernel/interaction-parts.d.ts +10 -0
- package/esm/src/kernel/interaction-parts.js +22 -0
- package/esm/src/kernel/mod.d.ts +47 -0
- package/esm/src/kernel/mod.js +30 -0
- package/esm/src/kernel/profile-graph.d.ts +140 -0
- package/esm/src/kernel/profile-graph.js +151 -0
- package/esm/src/kernel/profile-presence.d.ts +9 -0
- package/esm/src/kernel/profile-presence.js +143 -0
- package/esm/src/kernel/profile-scope.d.ts +36 -0
- package/esm/src/kernel/profile-scope.js +262 -0
- package/esm/src/kernel/registry/attachments.d.ts +35 -0
- package/esm/src/kernel/registry/attachments.js +211 -0
- package/esm/src/kernel/registry/catalog.d.ts +19 -0
- package/esm/src/kernel/registry/catalog.js +78 -0
- package/esm/src/kernel/registry/ingress.d.ts +8 -0
- package/esm/src/kernel/registry/ingress.js +134 -0
- package/esm/src/kernel/registry/kernel-registry.d.ts +12 -0
- package/esm/src/kernel/registry/kernel-registry.js +8 -0
- package/esm/src/kernel/registry/profile-outputs.d.ts +3 -0
- package/esm/src/kernel/registry/profile-outputs.js +7 -0
- package/esm/src/kernel/registry/profiles.d.ts +92 -0
- package/esm/src/kernel/registry/profiles.js +698 -0
- package/esm/src/kernel/registry/provider-request.d.ts +6 -0
- package/esm/src/kernel/registry/provider-request.js +42 -0
- package/esm/src/kernel/registry/resolve.d.ts +14 -0
- package/esm/src/kernel/registry/resolve.js +237 -0
- package/esm/src/kernel/registry/schemas.d.ts +9 -0
- package/esm/src/kernel/registry/schemas.js +25 -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 +33 -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 +13 -0
- package/esm/src/kernel/registry/vault.js +14 -0
- package/esm/src/kernel/schema.d.ts +172 -0
- package/esm/src/kernel/schema.js +653 -0
- package/esm/src/kernel/scope.d.ts +22 -0
- package/esm/src/kernel/scope.js +25 -0
- package/esm/src/kernel/stages.d.ts +141 -0
- package/esm/src/kernel/stages.js +388 -0
- package/esm/src/kernel/stop.d.ts +93 -0
- package/esm/src/kernel/stop.js +125 -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 +16 -0
- package/esm/src/kernel/tools/activity-label.js +209 -0
- package/esm/src/kernel/tools/events.d.ts +51 -0
- package/esm/src/kernel/tools/events.js +149 -0
- package/esm/src/kernel/tools/execute.d.ts +64 -0
- package/esm/src/kernel/tools/execute.js +801 -0
- package/esm/src/kernel/tools/gate-answer.d.ts +50 -0
- package/esm/src/kernel/tools/gate-answer.js +54 -0
- package/esm/src/kernel/tools/harness.d.ts +16 -0
- package/esm/src/kernel/tools/harness.js +42 -0
- package/esm/src/kernel/tools/invoke.d.ts +10 -0
- package/esm/src/kernel/tools/invoke.js +129 -0
- package/esm/src/kernel/tools/mcp-sessions.d.ts +20 -0
- package/esm/src/kernel/tools/mcp-sessions.js +64 -0
- package/esm/src/kernel/tools/mod.d.ts +9 -0
- package/esm/src/kernel/tools/mod.js +6 -0
- package/esm/src/kernel/tools/model-text.d.ts +11 -0
- package/esm/src/kernel/tools/model-text.js +25 -0
- package/esm/src/kernel/tools/permission.d.ts +6 -0
- package/esm/src/kernel/tools/permission.js +38 -0
- package/esm/src/kernel/tools/project.d.ts +8 -0
- package/esm/src/kernel/tools/project.js +25 -0
- package/esm/src/kernel/tools/registry.d.ts +20 -0
- package/esm/src/kernel/tools/registry.js +84 -0
- package/esm/src/kernel/tools/remote.d.ts +110 -0
- package/esm/src/kernel/tools/remote.js +998 -0
- package/esm/src/kernel/tools/resolve.d.ts +28 -0
- package/esm/src/kernel/tools/resolve.js +259 -0
- package/esm/src/kernel/tools/schema.d.ts +10 -0
- package/esm/src/kernel/tools/schema.js +174 -0
- package/esm/src/kernel/tools/signed-in-fetch.d.ts +18 -0
- package/esm/src/kernel/tools/signed-in-fetch.js +45 -0
- package/esm/src/kernel/tools/stage-run.d.ts +93 -0
- package/esm/src/kernel/tools/stage-run.js +140 -0
- package/esm/src/kernel/tools/types.d.ts +287 -0
- package/esm/src/kernel/tools/types.js +1 -0
- package/esm/src/kernel/turn-events.d.ts +599 -0
- package/esm/src/kernel/turn-events.js +425 -0
- package/esm/src/kernel/types.d.ts +884 -0
- package/esm/src/kernel/types.js +1 -0
- package/esm/src/kernel/util/base64.d.ts +2 -0
- package/esm/src/kernel/util/base64.js +13 -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/record.d.ts +1 -0
- package/esm/src/kernel/util/record.js +3 -0
- package/esm/src/observability/destinations.d.ts +9 -0
- package/esm/src/observability/destinations.js +38 -0
- package/esm/src/observability/jsonl.d.ts +18 -0
- package/esm/src/observability/jsonl.js +117 -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 +68 -0
- package/esm/src/observability/otlp.js +98 -0
- package/esm/src/observability/phoenix.d.ts +29 -0
- package/esm/src/observability/phoenix.js +71 -0
- package/esm/src/observability/policy.d.ts +14 -0
- package/esm/src/observability/policy.js +69 -0
- package/esm/src/observability/resolve-policy.d.ts +8 -0
- package/esm/src/observability/resolve-policy.js +58 -0
- package/esm/src/observability/spans.d.ts +16 -0
- package/esm/src/observability/spans.js +56 -0
- package/esm/src/observability/trace-catalog.d.ts +111 -0
- package/esm/src/observability/trace-catalog.js +865 -0
- package/esm/src/observability/trace-record.d.ts +23 -0
- package/esm/src/observability/trace-record.js +223 -0
- package/esm/src/observability/trace-schema.d.ts +54 -0
- package/esm/src/observability/trace-schema.js +59 -0
- package/esm/src/observability/trace-sink.d.ts +13 -0
- package/esm/src/observability/trace-sink.js +3 -0
- package/esm/src/observability/trace-span.d.ts +92 -0
- package/esm/src/observability/trace-span.js +199 -0
- package/esm/src/observability/trace.d.ts +11 -0
- package/esm/src/observability/trace.js +35 -0
- package/esm/src/observability/types.d.ts +85 -0
- package/esm/src/observability/types.js +3 -0
- package/esm/src/presets/google/speech-voices.d.ts +8 -0
- package/esm/src/presets/google/speech-voices.js +38 -0
- package/esm/src/presets/google-limits.d.ts +12 -0
- package/esm/src/presets/google-limits.js +18 -0
- package/esm/src/presets/google.d.ts +104 -0
- package/esm/src/presets/google.js +188 -0
- package/esm/src/presets/mod.d.ts +10 -0
- package/esm/src/presets/mod.js +9 -0
- package/esm/src/presets/openrouter.d.ts +13 -0
- package/esm/src/presets/openrouter.js +13 -0
- package/esm/src/presets/typesafe.d.ts +2 -0
- package/esm/src/presets/typesafe.js +2 -0
- package/esm/src/providers/create-provider.d.ts +21 -0
- package/esm/src/providers/create-provider.js +90 -0
- package/esm/src/providers/decision/usage.d.ts +3 -0
- package/esm/src/providers/decision/usage.js +25 -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/grounding.d.ts +5 -0
- package/esm/src/providers/google/grounding.js +226 -0
- package/esm/src/providers/google/interactions/framing.d.ts +15 -0
- package/esm/src/providers/google/interactions/framing.js +263 -0
- package/esm/src/providers/google/interactions/mod.d.ts +2 -0
- package/esm/src/providers/google/interactions/mod.js +2 -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 +24 -0
- package/esm/src/providers/google/interactions/stream.js +297 -0
- package/esm/src/providers/google/keys.d.ts +20 -0
- package/esm/src/providers/google/keys.js +87 -0
- package/esm/src/providers/google/live/framing.d.ts +51 -0
- package/esm/src/providers/google/live/framing.js +597 -0
- package/esm/src/providers/google/live/mod.d.ts +7 -0
- package/esm/src/providers/google/live/mod.js +7 -0
- package/esm/src/providers/google/live/openapi-schema.d.ts +1 -0
- package/esm/src/providers/google/live/openapi-schema.js +42 -0
- package/esm/src/providers/google/live/session.d.ts +14 -0
- package/esm/src/providers/google/live/session.js +150 -0
- package/esm/src/providers/google/live/stream.d.ts +51 -0
- package/esm/src/providers/google/live/stream.js +263 -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 +6 -0
- package/esm/src/providers/google/urls.js +6 -0
- package/esm/src/providers/google/usage.d.ts +7 -0
- package/esm/src/providers/google/usage.js +49 -0
- package/esm/src/providers/local/local.d.ts +12 -0
- package/esm/src/providers/local/local.js +186 -0
- package/esm/src/providers/local/mod.d.ts +8 -0
- package/esm/src/providers/local/mod.js +8 -0
- package/esm/src/providers/mod.d.ts +11 -0
- package/esm/src/providers/mod.js +7 -0
- package/esm/src/providers/openrouter/cache-control.d.ts +5 -0
- package/esm/src/providers/openrouter/cache-control.js +4 -0
- package/esm/src/providers/openrouter/chat.d.ts +64 -0
- package/esm/src/providers/openrouter/chat.js +490 -0
- package/esm/src/providers/openrouter/image.d.ts +24 -0
- package/esm/src/providers/openrouter/image.js +187 -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/sdk-messages.d.ts +10 -0
- package/esm/src/providers/openrouter/openai/sdk-messages.js +99 -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/resolve-api-key.d.ts +3 -0
- package/esm/src/providers/openrouter/resolve-api-key.js +8 -0
- package/esm/src/providers/openrouter/speech.d.ts +18 -0
- package/esm/src/providers/openrouter/speech.js +109 -0
- package/esm/src/providers/probe.d.ts +5 -0
- package/esm/src/providers/probe.js +15 -0
- package/esm/src/providers/shared/builtin-wire.d.ts +4 -0
- package/esm/src/providers/shared/builtin-wire.js +9 -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/response-identity.d.ts +11 -0
- package/esm/src/providers/shared/response-identity.js +12 -0
- package/esm/src/providers/shared/sse.d.ts +10 -0
- package/esm/src/providers/shared/sse.js +79 -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 +25 -0
- package/esm/src/providers/shared/tool-args.js +84 -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/shared/vault.d.ts +13 -0
- package/esm/src/providers/shared/vault.js +41 -0
- package/esm/src/providers/types.d.ts +19 -0
- package/esm/src/providers/types.js +1 -0
- package/esm/src/surface/formats.d.ts +28 -0
- package/esm/src/surface/formats.js +139 -0
- package/esm/src/surface/mod.d.ts +14 -0
- package/esm/src/surface/mod.js +10 -0
- package/esm/src/surface/runtime.d.ts +40 -0
- package/esm/src/surface/runtime.js +439 -0
- package/esm/src/surface/tools.d.ts +15 -0
- package/esm/src/surface/tools.js +80 -0
- package/esm/src/surface/types.d.ts +104 -0
- package/esm/src/surface/types.js +4 -0
- package/package.json +108 -4
|
@@ -0,0 +1,884 @@
|
|
|
1
|
+
import type { CacheMode, CacheTtl, CompactionMeter, CompactionOutcome, CompactionTiming, ContinueStopKind, FieldMeta, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveStartSensitivity, MediaInputKind, ProfileType, ProfileTypeProtocol, Protocol, Provider, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolLoadTier, TurnStage, TurnStopKind } from './schema.js';
|
|
2
|
+
import type { StageHandler } from './stages.js';
|
|
3
|
+
import type { GateDecision } from './tools/gate-answer.js';
|
|
4
|
+
import type { BuiltinWire, HostProfileToolsSpec, InvokeToolRequest, InvokeToolResume, LiveProfileToolsSpec, ModelToolResult, ProfileToolsSpec, RegisteredTool, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolPolicy, TurnToolSnapshot, WireFunctionTool } from './tools/types.js';
|
|
5
|
+
import type { CallDone, CompactionFailure, CompactionResult, CompactionSignal, DoneFields, GroundingEvent, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, ProviderEvent, ProviderEvidence, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnTokenSide, TurnTokens } from './turn-events.js';
|
|
6
|
+
export type { CacheMode, CacheTtl, CallDone, CompactionFailure, CompactionMeter, CompactionOutcome, CompactionResult, CompactionSignal, CompactionTiming, ContinueStopKind, DoneFields, FieldMeta, GroundingEvent, HostProfileToolsSpec, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvokeToolRequest, InvokeToolResume, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveProfileToolsSpec, LiveStartSensitivity, MediaInputKind, ProfileToolsSpec, ProfileType, ProfileTypeProtocol, Protocol, Provider, ProviderEvent, ProviderEvidence, RegisteredTool, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolLoadTier, ToolPolicy, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnStage, TurnStopKind, TurnTokenSide, TurnTokens, TurnToolSnapshot, WireFunctionTool, };
|
|
7
|
+
export type ModelId = string;
|
|
8
|
+
export type BuiltinToolId = string;
|
|
9
|
+
export type ToolId = string;
|
|
10
|
+
export type StructuredSchemaId = string;
|
|
11
|
+
export interface ResolvedStructured {
|
|
12
|
+
id: StructuredSchemaId;
|
|
13
|
+
jsonSchema: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface ProviderBuiltin {
|
|
16
|
+
id: BuiltinToolId;
|
|
17
|
+
wire: BuiltinWire;
|
|
18
|
+
}
|
|
19
|
+
export type ProfileId = string;
|
|
20
|
+
export type ChatRole = 'system' | 'user' | 'assistant';
|
|
21
|
+
/** Host strings (presets own the vocabularies); an unpinned value is the provider default. */
|
|
22
|
+
export interface ProfileImageSpec {
|
|
23
|
+
aspectRatio?: string;
|
|
24
|
+
resolution?: string;
|
|
25
|
+
mimeType?: string;
|
|
26
|
+
quality?: string;
|
|
27
|
+
background?: string;
|
|
28
|
+
n?: number;
|
|
29
|
+
seed?: number;
|
|
30
|
+
outputCompression?: number;
|
|
31
|
+
references?: Array<TurnBlob | TurnMediaRef>;
|
|
32
|
+
/** Also request interleaved text with the images (Google: text + image `response_format`). */
|
|
33
|
+
includeText?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ModelBinding {
|
|
36
|
+
protocol: Protocol;
|
|
37
|
+
provider: Provider;
|
|
38
|
+
apiId: string;
|
|
39
|
+
/** Alias → thinking level. One entry = fixed; two+ may be selectable at turn time. */
|
|
40
|
+
efforts?: Record<string, ThinkingLevel>;
|
|
41
|
+
/** Effort alias when the turn omits `effort`. Defaults to the only key when there is one. */
|
|
42
|
+
defaultEffort?: string;
|
|
43
|
+
/** Turn may pass `{ effort: "<alias>" }`. Requires two or more `efforts` keys. */
|
|
44
|
+
allowEffortSelect?: boolean;
|
|
45
|
+
/** Emit thinking summaries on the stream. Omit → provider default. */
|
|
46
|
+
summaries?: boolean;
|
|
47
|
+
/** Cap on output tokens. Omit → provider default. */
|
|
48
|
+
maxOutputTokens?: number;
|
|
49
|
+
/** Sampling temperature. Omit → provider default. */
|
|
50
|
+
temperature?: number;
|
|
51
|
+
builtInTools?: BuiltinToolId[];
|
|
52
|
+
/** Overrides `profile.key` for this model. */
|
|
53
|
+
key?: KeySlot;
|
|
54
|
+
/** Overrides `profile.fallbackKey` for this model. */
|
|
55
|
+
fallbackKey?: KeySlot;
|
|
56
|
+
compaction?: CompactionSpec;
|
|
57
|
+
/**
|
|
58
|
+
* OpenRouter prompt-cache policy. Omit → no opt-in `cache_control`.
|
|
59
|
+
* `defineProfile` accepts only when `provider` is `openrouter` (protocol `openAi`).
|
|
60
|
+
*/
|
|
61
|
+
cache?: CacheSpec;
|
|
62
|
+
/** Gemini Interactions: whether the provider stores the interaction. Omit → provider default. */
|
|
63
|
+
store?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Gemini Interactions: `true` chains each step and turn on Google's stored
|
|
66
|
+
* interaction (`previous_interaction_id`), so Google builds the context;
|
|
67
|
+
* `false` sends the history the host passes, plus this turn's steps, on every
|
|
68
|
+
* call — across turns the host builds that history. Required on every
|
|
69
|
+
* `geminiInteractions` binding; `true` needs `store` left on.
|
|
70
|
+
*/
|
|
71
|
+
persistViaInteractionId?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Local server that hosts the model (e.g. `ollama`, `vllm`, `llama.cpp`).
|
|
74
|
+
* Traces report it as `gen_ai.provider.name`; omit → the attribute is absent.
|
|
75
|
+
* `defineProfile` accepts only when `provider` is `local`.
|
|
76
|
+
*/
|
|
77
|
+
server?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* OpenRouter prompt-cache policy (`models.*.cache`).
|
|
81
|
+
*
|
|
82
|
+
* - `automatic` — top-level `cache_control`; breakpoint advances with the conversation.
|
|
83
|
+
* - `system` — explicit breakpoint on the system instruction only.
|
|
84
|
+
*/
|
|
85
|
+
export interface CacheSpec {
|
|
86
|
+
mode: CacheMode;
|
|
87
|
+
/** Ephemeral TTL. Omit → provider default (typically 5m on Anthropic). */
|
|
88
|
+
ttl?: CacheTtl;
|
|
89
|
+
}
|
|
90
|
+
export interface CompactionTriggerContext {
|
|
91
|
+
tokens: number;
|
|
92
|
+
maxTokens: number;
|
|
93
|
+
compactAt: number;
|
|
94
|
+
meter: CompactionMeter;
|
|
95
|
+
/** Media parts not counted in `tokens` — no verified rule for this model. */
|
|
96
|
+
unknownMedia: number;
|
|
97
|
+
}
|
|
98
|
+
export interface CompactionSpec {
|
|
99
|
+
/**
|
|
100
|
+
* Token budget compared by the trigger (`compactAt * maxTokens`).
|
|
101
|
+
* Meaning depends on `meter`: history budget vs full-prompt input budget.
|
|
102
|
+
*/
|
|
103
|
+
maxTokens: number;
|
|
104
|
+
/** Fraction of `maxTokens` at which compaction fires. Must be in (0, 1). */
|
|
105
|
+
compactAt: number;
|
|
106
|
+
/**
|
|
107
|
+
* Recent exchanges kept verbatim (an exchange is a user message and everything up to the
|
|
108
|
+
* next one). `≥ 1` = exchange count, `(0, 1)` = fraction of `maxTokens`, `0` = compact all.
|
|
109
|
+
*/
|
|
110
|
+
previousExchanges: number;
|
|
111
|
+
/**
|
|
112
|
+
* Profile id of the compaction agent. Must be registered before the owning profile.
|
|
113
|
+
* Omit it and the agent compacts its own history: the same instructions and model, no tools.
|
|
114
|
+
*/
|
|
115
|
+
profile?: ProfileId;
|
|
116
|
+
/**
|
|
117
|
+
* When compaction runs relative to the primary turn.
|
|
118
|
+
* - `'before'`: kernel compacts synchronously before the turn; user pays latency on this turn.
|
|
119
|
+
* - `'after'`: kernel signals in the `done` event; host runs compaction asynchronously.
|
|
120
|
+
*/
|
|
121
|
+
timing: CompactionTiming;
|
|
122
|
+
/**
|
|
123
|
+
* Threshold meter. Defaults to `'history'`.
|
|
124
|
+
* Use `'input'` when the host prefers provider full-prompt usage (after
|
|
125
|
+
* subtracting a known baseline in `maxTokens` / `compactAt`).
|
|
126
|
+
*/
|
|
127
|
+
meter?: CompactionMeter;
|
|
128
|
+
/** Replaces the default `tokens > compactAt * maxTokens` check. */
|
|
129
|
+
trigger?: (ctx: CompactionTriggerContext) => boolean | Promise<boolean>;
|
|
130
|
+
}
|
|
131
|
+
/** `compactHistory` input, for `timing: 'after'`: the host passes back what `done.compaction` carried. */
|
|
132
|
+
export interface CompactHistoryRequest {
|
|
133
|
+
/** The profile whose model binding carries the `compaction` spec. */
|
|
134
|
+
profile: ProfileId;
|
|
135
|
+
/** That binding; defaults to the profile's `defaultModel`. */
|
|
136
|
+
model?: ModelId;
|
|
137
|
+
history: TurnHistoryMessage[];
|
|
138
|
+
/** `done.compaction.tokens`: a failed compactor drops `toCompact` only when this is over `maxTokens`. */
|
|
139
|
+
tokens: number;
|
|
140
|
+
signal?: AbortSignal;
|
|
141
|
+
traceparent?: string;
|
|
142
|
+
conversationId?: string;
|
|
143
|
+
metadata?: Record<string, unknown>;
|
|
144
|
+
}
|
|
145
|
+
export interface StructuredSpec {
|
|
146
|
+
jsonSchema: Record<string, unknown>;
|
|
147
|
+
}
|
|
148
|
+
export interface MediaLimits {
|
|
149
|
+
maxFiles: number;
|
|
150
|
+
maxBytes: number;
|
|
151
|
+
maxTurnBytes: number;
|
|
152
|
+
limitsByMime?: Record<string, number>;
|
|
153
|
+
}
|
|
154
|
+
export interface MimeInputs extends Partial<MediaLimits> {
|
|
155
|
+
text?: boolean;
|
|
156
|
+
attachments?: {
|
|
157
|
+
accept: string[];
|
|
158
|
+
};
|
|
159
|
+
voice?: {
|
|
160
|
+
accept: string[];
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export type AttachmentValidationCode = 'mime_not_allowed' | 'too_many_files' | 'file_too_large' | 'turn_too_large' | 'attachments_not_accepted' | 'voice_not_accepted' | 'limits_unconfigured';
|
|
164
|
+
/**
|
|
165
|
+
* Structured parameters for rendering one validation issue. Validation emits
|
|
166
|
+
* codes + params only; the wording is the lexicon's `attachments.*` lines.
|
|
167
|
+
*/
|
|
168
|
+
export interface AttachmentValidationParams {
|
|
169
|
+
maxFiles?: number;
|
|
170
|
+
maxBytes?: number;
|
|
171
|
+
maxTurnBytes?: number;
|
|
172
|
+
mimeType?: string;
|
|
173
|
+
channel?: 'attachment' | 'voice';
|
|
174
|
+
}
|
|
175
|
+
/** One reason a turn's files were refused; `fileName` names the file when the problem is one file's. */
|
|
176
|
+
export interface AttachmentValidationIssue {
|
|
177
|
+
code: AttachmentValidationCode;
|
|
178
|
+
params?: AttachmentValidationParams;
|
|
179
|
+
fileName?: string;
|
|
180
|
+
}
|
|
181
|
+
export interface StructuredBySlot {
|
|
182
|
+
by: string;
|
|
183
|
+
map: Record<string, string>;
|
|
184
|
+
fallback: string;
|
|
185
|
+
}
|
|
186
|
+
export interface ValidationResult {
|
|
187
|
+
isValid: boolean;
|
|
188
|
+
error?: string;
|
|
189
|
+
finding?: string;
|
|
190
|
+
data?: Record<string, unknown>;
|
|
191
|
+
}
|
|
192
|
+
export type ProfileValidator = (candidate: unknown, slots?: Record<string, string>) => ValidationResult | Promise<ValidationResult>;
|
|
193
|
+
export interface ProfileValidationSpec {
|
|
194
|
+
/**
|
|
195
|
+
* Host domain validators keyed by dotted paths into structured output
|
|
196
|
+
* (e.g. `diagram.mermaid`). Presence/required is owned by the JSON Schema;
|
|
197
|
+
* these run only for required paths and for optional paths that are present.
|
|
198
|
+
*/
|
|
199
|
+
fields?: Record<string, ProfileValidator>;
|
|
200
|
+
maxRetries?: number;
|
|
201
|
+
}
|
|
202
|
+
/** `voice` is the TTS voice id, not ingress audio (`inputs.voice`). */
|
|
203
|
+
export interface ProfileSpeechSpec {
|
|
204
|
+
voice?: string;
|
|
205
|
+
/** `mp3` requires `protocol: 'openAi'` speech; rejected on Interactions. */
|
|
206
|
+
format?: SpeechAudioFormat;
|
|
207
|
+
}
|
|
208
|
+
export interface LiveVadSpec {
|
|
209
|
+
activityHandling?: LiveActivityHandling;
|
|
210
|
+
startSensitivity?: LiveStartSensitivity;
|
|
211
|
+
endSensitivity?: LiveEndSensitivity;
|
|
212
|
+
prefixPaddingMs?: number;
|
|
213
|
+
silenceDurationMs?: number;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Context window compression for a live session: once the context reaches the
|
|
217
|
+
* trigger, the mechanism shrinks it. Without it, Gemini ends audio sessions at
|
|
218
|
+
* 15 minutes and audio-video sessions at 2.
|
|
219
|
+
*/
|
|
220
|
+
export interface LiveContextCompressionSpec {
|
|
221
|
+
/**
|
|
222
|
+
* Context tokens, counted before a turn, that start compression. A whole
|
|
223
|
+
* number above 0. Omit → provider default (Gemini: 80% of the model's context
|
|
224
|
+
* window).
|
|
225
|
+
*/
|
|
226
|
+
triggerTokens?: number;
|
|
227
|
+
/** Drops the oldest turns; the system instruction stays. Gemini's only mechanism. */
|
|
228
|
+
slidingWindow: LiveSlidingWindowSpec;
|
|
229
|
+
}
|
|
230
|
+
export interface LiveSlidingWindowSpec {
|
|
231
|
+
/**
|
|
232
|
+
* Tokens to keep after compressing. A whole number above 0, below
|
|
233
|
+
* `triggerTokens`. Omit → provider default (Gemini: half of `triggerTokens`).
|
|
234
|
+
*/
|
|
235
|
+
targetTokens?: number;
|
|
236
|
+
}
|
|
237
|
+
export interface LiveTranscriptionSpec {
|
|
238
|
+
input?: boolean;
|
|
239
|
+
output?: boolean;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Realtime ingress modalities for a live session.
|
|
243
|
+
* Distinct from turn `inputs` (file attachments, MIME limits) — these gate
|
|
244
|
+
* `LiveSession.sendAudio` / `sendVideo` / `sendText` channels.
|
|
245
|
+
*/
|
|
246
|
+
export interface LiveIngressSpec {
|
|
247
|
+
/** Microphone PCM via `sendAudio`. Omit → enabled. */
|
|
248
|
+
audio?: boolean;
|
|
249
|
+
/** Webcam JPEG frames via `sendVideo`. Omit → enabled. */
|
|
250
|
+
video?: boolean;
|
|
251
|
+
/** Typed text via `sendText`. Omit → disabled (opt-in). */
|
|
252
|
+
text?: boolean;
|
|
253
|
+
}
|
|
254
|
+
export interface ProfileLiveSpec {
|
|
255
|
+
ingress?: LiveIngressSpec;
|
|
256
|
+
voice?: string;
|
|
257
|
+
vad?: LiveVadSpec;
|
|
258
|
+
sessionResumption?: boolean;
|
|
259
|
+
/** Context window compression. Omit → none: the provider ends the session at its limit. */
|
|
260
|
+
contextCompression?: LiveContextCompressionSpec;
|
|
261
|
+
transcription?: LiveTranscriptionSpec;
|
|
262
|
+
}
|
|
263
|
+
export interface ProfileStreamingSpec {
|
|
264
|
+
mode?: StreamMode;
|
|
265
|
+
/** When false, filter `thought` events from the turn stream. */
|
|
266
|
+
streamThoughts?: boolean;
|
|
267
|
+
}
|
|
268
|
+
export type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './stop.js';
|
|
269
|
+
import type { LexiconOverrides } from '../guardrails/lexicon.js';
|
|
270
|
+
import type { ResolveHost } from '../guardrails/network.js';
|
|
271
|
+
import type { DecisionGuardrailsSpec, HostGuardrailsSpec, ProfileGuardrailsSpec } from '../guardrails/types.js';
|
|
272
|
+
import type { ProfileObservabilitySpec } from '../observability/types.js';
|
|
273
|
+
import type { ToolCredentialSource } from './auth/credential-source.js';
|
|
274
|
+
import type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, TurnContinueFrom } from './stop.js';
|
|
275
|
+
export interface ProfileModelFields {
|
|
276
|
+
/** Host-named models. Each key is a selectable model id when `allowModelSelect` is set. */
|
|
277
|
+
models: Record<ModelId, ModelBinding>;
|
|
278
|
+
/** The model a turn runs when it names none; registration fills it with the only key when there is one. */
|
|
279
|
+
defaultModel: ModelId;
|
|
280
|
+
/** Turn may pass `{ model: "<id>" }`. Requires two or more `models` keys. */
|
|
281
|
+
allowModelSelect?: boolean;
|
|
282
|
+
/** Tool-loop ceiling. Omit or `<= 0` = unbounded; `1` = one-shot; `> 1` = hard cap. */
|
|
283
|
+
maxSteps?: number;
|
|
284
|
+
key?: KeySlot;
|
|
285
|
+
/** Retried once when `key` is refused for quota. Off unless set. */
|
|
286
|
+
fallbackKey?: KeySlot;
|
|
287
|
+
}
|
|
288
|
+
export interface ProfileInputsSpec {
|
|
289
|
+
text?: boolean;
|
|
290
|
+
attachments?: {
|
|
291
|
+
accept: string[];
|
|
292
|
+
};
|
|
293
|
+
voice?: {
|
|
294
|
+
accept: string[];
|
|
295
|
+
};
|
|
296
|
+
maxFiles?: number;
|
|
297
|
+
maxBytes?: number;
|
|
298
|
+
maxTurnBytes?: number;
|
|
299
|
+
limitsByMime?: Record<string, number>;
|
|
300
|
+
slots?: Record<string, string[]>;
|
|
301
|
+
}
|
|
302
|
+
export interface ProfileOutputsSpec {
|
|
303
|
+
structured?: StructuredSchemaId | StructuredBySlot | null;
|
|
304
|
+
validation?: ProfileValidationSpec;
|
|
305
|
+
streaming?: ProfileStreamingSpec;
|
|
306
|
+
}
|
|
307
|
+
/** Text a reply may not repeat when the rest of its prompt is marked shareable. */
|
|
308
|
+
export interface PrivateSystemPart {
|
|
309
|
+
private: string;
|
|
310
|
+
}
|
|
311
|
+
export type SystemPart = string | PrivateSystemPart;
|
|
312
|
+
/**
|
|
313
|
+
* A system prompt: a string, or parts sent concatenated as written. A string,
|
|
314
|
+
* or parts none of which is `{ private }`, is private throughout; once one
|
|
315
|
+
* part is `{ private }`, the plain strings beside it are shareable.
|
|
316
|
+
*/
|
|
317
|
+
export type SystemPrompt = string | readonly SystemPart[];
|
|
318
|
+
/** A stretch of the system prompt as sent, and whether a reply may repeat it. */
|
|
319
|
+
export interface SystemPiece {
|
|
320
|
+
text: string;
|
|
321
|
+
private: boolean;
|
|
322
|
+
}
|
|
323
|
+
export interface ProfileIdentity {
|
|
324
|
+
handle: string;
|
|
325
|
+
system?: SystemPrompt;
|
|
326
|
+
systemByRole?: Record<string, SystemPrompt>;
|
|
327
|
+
}
|
|
328
|
+
export interface ProfileCommon {
|
|
329
|
+
id: ProfileId;
|
|
330
|
+
identity: ProfileIdentity;
|
|
331
|
+
models: Record<ModelId, ModelBinding>;
|
|
332
|
+
defaultModel: ModelId;
|
|
333
|
+
allowModelSelect?: boolean;
|
|
334
|
+
maxSteps?: number;
|
|
335
|
+
key?: KeySlot;
|
|
336
|
+
/** Retried once when `key` is refused for quota. Off unless set. */
|
|
337
|
+
fallbackKey?: KeySlot;
|
|
338
|
+
outputs?: ProfileOutputsSpec;
|
|
339
|
+
guardrails?: ProfileGuardrailsSpec;
|
|
340
|
+
observability?: ProfileObservabilitySpec;
|
|
341
|
+
/** This profile's wording: replaces any lexicon default, and any `overrideLexicon` entry, for this profile. */
|
|
342
|
+
lexicon?: LexiconOverrides;
|
|
343
|
+
}
|
|
344
|
+
export type DecisionJson = null | string | number | boolean | DecisionJson[] | {
|
|
345
|
+
[key: string]: DecisionJson;
|
|
346
|
+
};
|
|
347
|
+
/** A decision model binding follows the same protocol/provider/apiId spine as turn models. */
|
|
348
|
+
export interface DecisionModelBinding extends Pick<ModelBinding, 'apiId' | 'key'> {
|
|
349
|
+
protocol: 'decision';
|
|
350
|
+
provider: 'typesafe' | 'openrouter';
|
|
351
|
+
timeoutMs?: number;
|
|
352
|
+
}
|
|
353
|
+
export interface DecisionInputsSpec {
|
|
354
|
+
state: 'json';
|
|
355
|
+
maxStateBytes?: number;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* A host-owned id for the decision a profile makes. The trace records it as
|
|
359
|
+
* `theorem.decision.contract`; it is not sent to the provider and does not constrain
|
|
360
|
+
* the questions a call asks.
|
|
361
|
+
*/
|
|
362
|
+
export type DecisionContractId = string;
|
|
363
|
+
/** Decision profile. It cannot be passed to chat or live execution doors. */
|
|
364
|
+
export interface DecisionProfile {
|
|
365
|
+
type: 'decision';
|
|
366
|
+
id: ProfileId;
|
|
367
|
+
identity: Pick<ProfileIdentity, 'handle'>;
|
|
368
|
+
/** Exactly one model: a decision profile runs one model and never selects. */
|
|
369
|
+
models: Record<ModelId, DecisionModelBinding>;
|
|
370
|
+
key?: KeySlot;
|
|
371
|
+
inputs: DecisionInputsSpec;
|
|
372
|
+
decision: {
|
|
373
|
+
contract: DecisionContractId;
|
|
374
|
+
};
|
|
375
|
+
guardrails?: DecisionGuardrailsSpec;
|
|
376
|
+
observability?: ProfileObservabilitySpec;
|
|
377
|
+
/** This profile's wording: replaces any lexicon default, and any `overrideLexicon` entry, for this profile. */
|
|
378
|
+
lexicon?: LexiconOverrides;
|
|
379
|
+
}
|
|
380
|
+
/** Text or nested text instruction entries. Non-text leaves are rejected locally. */
|
|
381
|
+
export type DecisionEntry = string | DecisionEntry[] | {
|
|
382
|
+
[key: string]: DecisionEntry;
|
|
383
|
+
};
|
|
384
|
+
export interface DecisionChoiceQuestion {
|
|
385
|
+
type: 'choice';
|
|
386
|
+
instructions: DecisionEntry;
|
|
387
|
+
criteria: Record<string, DecisionEntry>;
|
|
388
|
+
}
|
|
389
|
+
export interface DecisionNoulQuestion {
|
|
390
|
+
type: 'noul';
|
|
391
|
+
instructions: DecisionEntry;
|
|
392
|
+
criteria?: Record<string, DecisionEntry>;
|
|
393
|
+
}
|
|
394
|
+
export interface DecisionScoreQuestion {
|
|
395
|
+
type: 'score';
|
|
396
|
+
instructions: DecisionEntry;
|
|
397
|
+
criteria: readonly DecisionEntry[];
|
|
398
|
+
}
|
|
399
|
+
export type DecisionQuestion = DecisionChoiceQuestion | DecisionNoulQuestion | DecisionScoreQuestion;
|
|
400
|
+
export interface DecisionRequest {
|
|
401
|
+
profile: ProfileId;
|
|
402
|
+
state: Exclude<DecisionJson, null>;
|
|
403
|
+
questions: Record<string, DecisionQuestion>;
|
|
404
|
+
signal?: AbortSignal;
|
|
405
|
+
/** Host-owned metadata preserved on the decision's trace record; the kernel does not interpret it. */
|
|
406
|
+
metadata?: Record<string, unknown>;
|
|
407
|
+
/**
|
|
408
|
+
* W3C `traceparent` of the host span this decision runs under. The `decide`
|
|
409
|
+
* root joins that trace as its child; without it the decision starts a new
|
|
410
|
+
* trace. A malformed value throws.
|
|
411
|
+
*/
|
|
412
|
+
traceparent?: string;
|
|
413
|
+
}
|
|
414
|
+
export type DecisionAnswer = {
|
|
415
|
+
type: 'choice';
|
|
416
|
+
choice: string;
|
|
417
|
+
confidence: number;
|
|
418
|
+
probabilities: Record<string, number>;
|
|
419
|
+
} | {
|
|
420
|
+
type: 'noul';
|
|
421
|
+
noul: number;
|
|
422
|
+
} | {
|
|
423
|
+
type: 'score';
|
|
424
|
+
score: number;
|
|
425
|
+
confidence: number;
|
|
426
|
+
legend: Record<string, string>;
|
|
427
|
+
probabilities: Record<string, number>;
|
|
428
|
+
};
|
|
429
|
+
export interface DecisionResult {
|
|
430
|
+
model: string;
|
|
431
|
+
answers: Record<string, DecisionAnswer>;
|
|
432
|
+
/** Provider-reported tokens and cost, or a provider adapter's known model tariff. */
|
|
433
|
+
usage?: {
|
|
434
|
+
inputTokens: number;
|
|
435
|
+
outputTokens: number;
|
|
436
|
+
costUsd?: number;
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
export interface TextProfile extends ProfileCommon {
|
|
440
|
+
type: 'text';
|
|
441
|
+
tools: ProfileToolsSpec;
|
|
442
|
+
inputs: ProfileInputsSpec;
|
|
443
|
+
turnBehaviour?: ProfileTurnBehaviourSpec;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* An image profile's inputs: no voice channel, and attachments within
|
|
447
|
+
* `IMAGE_ATTACHMENT_ACCEPT`. Every attachment is a reference the model reads;
|
|
448
|
+
* `maxFiles` caps them.
|
|
449
|
+
*/
|
|
450
|
+
export type ImageInputsSpec = Omit<ProfileInputsSpec, 'voice'>;
|
|
451
|
+
export interface ImageProfile extends ProfileCommon {
|
|
452
|
+
type: 'image';
|
|
453
|
+
image: ProfileImageSpec;
|
|
454
|
+
tools: ProfileToolsSpec;
|
|
455
|
+
inputs: ImageInputsSpec;
|
|
456
|
+
turnBehaviour?: MediaTurnBehaviourSpec;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Speech guardrails: no canary. A speech turn has no system channel to bind a
|
|
460
|
+
* token into (Gemini TTS rejects developer instructions) and yields audio, not
|
|
461
|
+
* text a canary scan could read.
|
|
462
|
+
*/
|
|
463
|
+
export type SpeechGuardrailsSpec = Omit<ProfileGuardrailsSpec, 'canary'> & {
|
|
464
|
+
canary?: false;
|
|
465
|
+
};
|
|
466
|
+
/** Unary TTS — text-in locked by type; no tools / inputs block. The input text is the transcript; there is no system prompt. */
|
|
467
|
+
export interface SpeechProfile extends Omit<ProfileCommon, 'identity' | 'guardrails'> {
|
|
468
|
+
type: 'speech';
|
|
469
|
+
identity: Pick<ProfileIdentity, 'handle'>;
|
|
470
|
+
/** Registration always stores `canary: false`. */
|
|
471
|
+
guardrails: SpeechGuardrailsSpec & {
|
|
472
|
+
canary: false;
|
|
473
|
+
};
|
|
474
|
+
speech: ProfileSpeechSpec;
|
|
475
|
+
turnBehaviour?: MediaTurnBehaviourSpec;
|
|
476
|
+
}
|
|
477
|
+
export interface LiveProfile extends Omit<ProfileCommon, 'outputs'> {
|
|
478
|
+
type: 'live';
|
|
479
|
+
live: ProfileLiveSpec;
|
|
480
|
+
tools: LiveProfileToolsSpec;
|
|
481
|
+
/** Stage inject gate only; live resumption is `live.sessionResumption`. */
|
|
482
|
+
turnBehaviour?: Pick<ProfileTurnBehaviourSpec, 'allowSteering'>;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Host-driven tool execution; never runs a model. `invokeTool` runs any tool in
|
|
486
|
+
* `tools.allow` with no visibility, loading tiers or path gating. `guardrails` holds only
|
|
487
|
+
* the guards that fire on `invokeTool`: quota, canary and egress guard a model turn, so
|
|
488
|
+
* `defineProfile` refuses them rather than accept inert config.
|
|
489
|
+
*/
|
|
490
|
+
export interface HostProfile {
|
|
491
|
+
type: 'host';
|
|
492
|
+
id: ProfileId;
|
|
493
|
+
tools: HostProfileToolsSpec;
|
|
494
|
+
guardrails?: HostGuardrailsSpec;
|
|
495
|
+
observability?: ProfileObservabilitySpec;
|
|
496
|
+
/** This profile's wording: replaces any lexicon default, and any `overrideLexicon` entry, for this profile. */
|
|
497
|
+
lexicon?: LexiconOverrides;
|
|
498
|
+
}
|
|
499
|
+
export type Profile = TextProfile | ImageProfile | SpeechProfile | LiveProfile | DecisionProfile | HostProfile;
|
|
500
|
+
/** Profiles that run a model turn — every type except `host` and `decision` (which runs through `runDecision`). */
|
|
501
|
+
export type ModelProfile = Exclude<Profile, HostProfile | DecisionProfile>;
|
|
502
|
+
export interface ImageResponseFormat {
|
|
503
|
+
type: 'image';
|
|
504
|
+
mimeType?: string;
|
|
505
|
+
aspectRatio?: string;
|
|
506
|
+
/** Adapters map it to the provider wire key (Google `imageSize`, OpenRouter `resolution`). */
|
|
507
|
+
resolution?: string;
|
|
508
|
+
quality?: string;
|
|
509
|
+
background?: string;
|
|
510
|
+
n?: number;
|
|
511
|
+
seed?: number;
|
|
512
|
+
outputCompression?: number;
|
|
513
|
+
includeText: boolean;
|
|
514
|
+
}
|
|
515
|
+
export interface TurnBlob {
|
|
516
|
+
mimeType: string;
|
|
517
|
+
data: string;
|
|
518
|
+
/** The file's name, used only to tell the user which file was refused; never sent to the model. */
|
|
519
|
+
name?: string;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Media attachment supplied by reference (provider file uri) instead of bytes.
|
|
523
|
+
* MIME acceptance still applies; base64 and byte limits do not.
|
|
524
|
+
*/
|
|
525
|
+
export interface TurnMediaRef {
|
|
526
|
+
mimeType: string;
|
|
527
|
+
uri: string;
|
|
528
|
+
/** The file's name, used only to tell the user which file was refused; never sent to the model. */
|
|
529
|
+
name?: string;
|
|
530
|
+
}
|
|
531
|
+
export interface TurnRepairRequest {
|
|
532
|
+
previousOutput: string;
|
|
533
|
+
rejection: string;
|
|
534
|
+
guidance?: string;
|
|
535
|
+
}
|
|
536
|
+
export interface TurnInput {
|
|
537
|
+
text?: string;
|
|
538
|
+
role?: string;
|
|
539
|
+
slots?: Record<string, string>;
|
|
540
|
+
attachments?: Array<TurnBlob | TurnMediaRef>;
|
|
541
|
+
voice?: TurnBlob[];
|
|
542
|
+
history?: TurnHistoryMessage[];
|
|
543
|
+
repair?: TurnRepairRequest;
|
|
544
|
+
/**
|
|
545
|
+
* Optional host-supplied history token count for `meter: 'history'`.
|
|
546
|
+
* When set, overrides the local history estimate. Not full-prompt API tokens.
|
|
547
|
+
*/
|
|
548
|
+
historyTokens?: number;
|
|
549
|
+
/**
|
|
550
|
+
* Optional host-supplied full-prompt input token count for `meter: 'input'`
|
|
551
|
+
* with `timing: 'before'` (typically the previous turn's `tokens.input`).
|
|
552
|
+
* Ignored when `meter` is `'history'`.
|
|
553
|
+
*/
|
|
554
|
+
inputTokens?: number;
|
|
555
|
+
sessionResumptionHandle?: string;
|
|
556
|
+
}
|
|
557
|
+
export type NormalizedTurnRequest = TurnRequest & {
|
|
558
|
+
input: TurnInput;
|
|
559
|
+
};
|
|
560
|
+
/**
|
|
561
|
+
* An earlier trace this one follows from. Recorded as a span link on the
|
|
562
|
+
* root, so a developer can walk a conversation across records.
|
|
563
|
+
*/
|
|
564
|
+
export interface TurnTraceLink {
|
|
565
|
+
/** The earlier root's `traceparent` (its terminal `done.traceparent`). */
|
|
566
|
+
traceparent: string;
|
|
567
|
+
/** `resume` after a pause, `continue` after a resumeable stop, `retry` of a failed turn. */
|
|
568
|
+
kind: 'resume' | 'continue' | 'retry';
|
|
569
|
+
/** How the earlier turn stopped, when the host knows. */
|
|
570
|
+
stop?: TurnStopKind;
|
|
571
|
+
}
|
|
572
|
+
export interface TurnRequest {
|
|
573
|
+
profile: ProfileId;
|
|
574
|
+
projectId?: string;
|
|
575
|
+
/**
|
|
576
|
+
* Sticky routing / cache session key for OpenRouter (`session_id`).
|
|
577
|
+
* Not the same as `projectId` or Gemini `previousInteractionId`.
|
|
578
|
+
*/
|
|
579
|
+
sessionId?: string;
|
|
580
|
+
/** Google Interactions server-side conversation state. Omit for stateless/manual history. */
|
|
581
|
+
previousInteractionId?: string;
|
|
582
|
+
/**
|
|
583
|
+
* Location bias for Interactions `google_maps` builtin.
|
|
584
|
+
* Wired as `tools: [{ type: "google_maps", latitude, longitude }]`.
|
|
585
|
+
* Ignored when `googleMaps` is not enabled for the selected model.
|
|
586
|
+
*/
|
|
587
|
+
googleMapsLocation?: {
|
|
588
|
+
latitude: number;
|
|
589
|
+
longitude: number;
|
|
590
|
+
};
|
|
591
|
+
/** Optional Interactions storage override. Omit to let the selected model binding decide. */
|
|
592
|
+
store?: boolean;
|
|
593
|
+
/** Selected model id when `profile.allowModelSelect` is true. */
|
|
594
|
+
model?: ModelId;
|
|
595
|
+
/** Selected effort alias when the binding has `allowEffortSelect`. */
|
|
596
|
+
effort?: string;
|
|
597
|
+
/** Host-provided dynamic system prompt combined with profile persona */
|
|
598
|
+
system?: SystemPrompt;
|
|
599
|
+
sessionPermissions?: string[];
|
|
600
|
+
/** Host channel/path for catalog `paths` filtering. */
|
|
601
|
+
path?: string;
|
|
602
|
+
/** Host-owned metadata preserved for traces; the kernel does not interpret it. */
|
|
603
|
+
metadata?: Record<string, unknown>;
|
|
604
|
+
/**
|
|
605
|
+
* W3C `traceparent` of the host span this turn runs under. The turn's root
|
|
606
|
+
* span joins that trace as its child; without it the turn starts a new trace.
|
|
607
|
+
* A malformed value throws.
|
|
608
|
+
*/
|
|
609
|
+
traceparent?: string;
|
|
610
|
+
/** Host conversation id, recorded as `gen_ai.conversation.id`. */
|
|
611
|
+
conversationId?: string;
|
|
612
|
+
links?: TurnTraceLink[];
|
|
613
|
+
/**
|
|
614
|
+
* Opaque application context handed to tool `handler` / `preTool` and
|
|
615
|
+
* `tools.t1Policy` as `ctx.host`. The kernel never reads, logs, traces, or
|
|
616
|
+
* serializes it.
|
|
617
|
+
*/
|
|
618
|
+
host?: unknown;
|
|
619
|
+
/**
|
|
620
|
+
* Optional abort signal. When aborted, THEOREM stops the turn and cancels
|
|
621
|
+
* in-flight provider HTTP where the adapter supports it.
|
|
622
|
+
*/
|
|
623
|
+
signal?: AbortSignal;
|
|
624
|
+
/**
|
|
625
|
+
* Continue a prior resumeable stop. On text profiles the turn's user message
|
|
626
|
+
* is the continue instruction (no `input.text`); the host passes the partial
|
|
627
|
+
* reply as the last assistant message in `input.history`. Image and speech
|
|
628
|
+
* re-send the original request unchanged.
|
|
629
|
+
*/
|
|
630
|
+
continueFrom?: TurnContinueFrom;
|
|
631
|
+
/**
|
|
632
|
+
* 1-based continue attempt when `continueFrom` is set.
|
|
633
|
+
* Compared to `profile.turnBehaviour.resumption.maxContinues` when that cap is set.
|
|
634
|
+
*/
|
|
635
|
+
continuation?: number;
|
|
636
|
+
input?: TurnInput;
|
|
637
|
+
/** Runs a `timing: 'before'` compactor the turn's provider cannot. */
|
|
638
|
+
compactionProvider?: ModelProvider;
|
|
639
|
+
sessionResumptionHandle?: string;
|
|
640
|
+
/** Credentials for authenticated HTTP / MCP tools, read by auth slot when a tool needs one. */
|
|
641
|
+
credentials?: ToolCredentialSource;
|
|
642
|
+
/**
|
|
643
|
+
* Resolves remote tool and OAuth host names before each request; a name that
|
|
644
|
+
* resolves to a private address is refused (see `fetchGuarded`).
|
|
645
|
+
*/
|
|
646
|
+
resolveHost?: ResolveHost;
|
|
647
|
+
/** Text `runTurn` emits stages and applies the returned affordances. */
|
|
648
|
+
onStage?: StageHandler;
|
|
649
|
+
}
|
|
650
|
+
export interface ProjectedProfile extends ProfileModelFields {
|
|
651
|
+
id: string;
|
|
652
|
+
type: ModelProfile['type'];
|
|
653
|
+
handle: string;
|
|
654
|
+
tools: Array<RegisteredTool | {
|
|
655
|
+
name: ToolId;
|
|
656
|
+
missing: true;
|
|
657
|
+
}>;
|
|
658
|
+
inputs: ProfileInputsSpec | null;
|
|
659
|
+
outputs: ProfileOutputsSpec | null;
|
|
660
|
+
image?: ProfileImageSpec | null;
|
|
661
|
+
speech?: ProfileSpeechSpec | null;
|
|
662
|
+
live?: ProfileLiveSpec | null;
|
|
663
|
+
}
|
|
664
|
+
export interface ProviderGenerationConfig {
|
|
665
|
+
model: ModelId;
|
|
666
|
+
apiId: string;
|
|
667
|
+
previousInteractionId?: string;
|
|
668
|
+
store?: boolean;
|
|
669
|
+
/**
|
|
670
|
+
* Upstream stream vs batch, derived from `outputs.streaming.mode`.
|
|
671
|
+
* `true` = SSE (THEOREM default when mode is omitted); `false` = buffered.
|
|
672
|
+
*/
|
|
673
|
+
stream?: boolean;
|
|
674
|
+
thinking?: ThinkingLevel;
|
|
675
|
+
summaries?: SummaryMode;
|
|
676
|
+
maxOutputTokens?: number;
|
|
677
|
+
temperature?: number;
|
|
678
|
+
builtins: BuiltinToolId[];
|
|
679
|
+
googleMapsLocation?: {
|
|
680
|
+
latitude: number;
|
|
681
|
+
longitude: number;
|
|
682
|
+
};
|
|
683
|
+
/** OpenRouter only. */
|
|
684
|
+
cache?: CacheSpec;
|
|
685
|
+
/** Forwarded as OpenRouter `session_id`. */
|
|
686
|
+
sessionId?: string;
|
|
687
|
+
}
|
|
688
|
+
export type ProviderTransport = 'interactions' | 'geminiLive' | 'openAiCompat';
|
|
689
|
+
export interface ResolvedGeneration extends ProviderGenerationConfig {
|
|
690
|
+
transport: ProviderTransport;
|
|
691
|
+
/**
|
|
692
|
+
* Whether the turn's steps chain on the stored interaction: a tool result or
|
|
693
|
+
* stage inject rides `continuation` after `previousInteractionId`. Only an
|
|
694
|
+
* Interactions binding chains, and never one with `persistViaInteractionId:
|
|
695
|
+
* false` — its steps each send the host's history plus the turn's steps so far.
|
|
696
|
+
*/
|
|
697
|
+
chains: boolean;
|
|
698
|
+
tools: TurnToolSnapshot;
|
|
699
|
+
sessionPermissions?: string[];
|
|
700
|
+
history?: TurnHistoryMessage[];
|
|
701
|
+
/**
|
|
702
|
+
* Interactions-only: messages sent after `previousInteractionId` (tool
|
|
703
|
+
* results, stage injects) instead of history + user parts. The model reads
|
|
704
|
+
* the stored interaction plus these.
|
|
705
|
+
*/
|
|
706
|
+
continuation?: TurnHistoryMessage[];
|
|
707
|
+
/** Tool-loop ceiling. `undefined` or `<= 0` = unbounded. */
|
|
708
|
+
maxSteps?: number;
|
|
709
|
+
structured: ResolvedStructured | null;
|
|
710
|
+
image: ImageResponseFormat | null;
|
|
711
|
+
speech?: ProfileSpeechSpec;
|
|
712
|
+
live?: ProfileLiveSpec;
|
|
713
|
+
input: InteractionPart[];
|
|
714
|
+
/**
|
|
715
|
+
* Vault key slot; every model but a local one without a key names one. Never sent on the wire.
|
|
716
|
+
*/
|
|
717
|
+
keySlot?: KeySlot;
|
|
718
|
+
/** The slot a quota refusal on `keySlot` retries on once, when the profile names one. */
|
|
719
|
+
fallbackKeySlot?: KeySlot;
|
|
720
|
+
canary: string;
|
|
721
|
+
sessionResumptionHandle?: string;
|
|
722
|
+
/** Snapshotted synchronously before any async work; the runner binds the canary on top. */
|
|
723
|
+
resolvedSystem: readonly SystemPiece[];
|
|
724
|
+
/** `TurnRequest.host`, carried to tool contexts only. Never sent to providers or traces. */
|
|
725
|
+
host?: unknown;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* `previousInteractionId`, `store`, `stream`, `summaries` and `continuation` are
|
|
729
|
+
* Google Interactions-only and absent otherwise. `keySlot` is required for every
|
|
730
|
+
* provider but local; it is never sent on the wire.
|
|
731
|
+
*/
|
|
732
|
+
export interface ProviderCompleteRequest extends Omit<ProviderGenerationConfig, 'summaries' | 'builtins'> {
|
|
733
|
+
/** The turn's builtins with their wire names; adapters read no registry. */
|
|
734
|
+
builtins: ProviderBuiltin[];
|
|
735
|
+
summaries?: SummaryMode;
|
|
736
|
+
system: string;
|
|
737
|
+
input: InteractionPart[];
|
|
738
|
+
history?: TurnHistoryMessage[];
|
|
739
|
+
/** Sent after `previousInteractionId` instead of history + user parts; mapped like history. */
|
|
740
|
+
continuation?: TurnHistoryMessage[];
|
|
741
|
+
wireTools?: WireFunctionTool[];
|
|
742
|
+
structured: ResolvedStructured | null;
|
|
743
|
+
image: ImageResponseFormat | null;
|
|
744
|
+
speech?: ProfileSpeechSpec;
|
|
745
|
+
live?: ProfileLiveSpec;
|
|
746
|
+
sessionResumptionHandle?: string;
|
|
747
|
+
keySlot?: KeySlot;
|
|
748
|
+
/** The slot a quota refusal on `keySlot` retries on once. Never sent on the wire. */
|
|
749
|
+
fallbackKeySlot?: KeySlot;
|
|
750
|
+
/** Scrubbed SSE / HTTP rows for traces. */
|
|
751
|
+
tapUpstream?: (row: Record<string, unknown>) => void;
|
|
752
|
+
/** Host abort signal — adapters should pass this into fetch / SDK calls. */
|
|
753
|
+
signal?: AbortSignal;
|
|
754
|
+
}
|
|
755
|
+
export interface ModelProvider {
|
|
756
|
+
complete: (req: ProviderCompleteRequest) => AsyncIterable<ProviderEvent>;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Host request to open a long-lived live session (`runSession`).
|
|
760
|
+
* Profile must be `type: 'live'`.
|
|
761
|
+
*/
|
|
762
|
+
export interface SessionRequest {
|
|
763
|
+
profile: ProfileId;
|
|
764
|
+
/** Host-built system prompt merged with profile identity.system. */
|
|
765
|
+
system?: SystemPrompt;
|
|
766
|
+
/** Override `profile.live.voice` for this session. */
|
|
767
|
+
voice?: string;
|
|
768
|
+
path?: string;
|
|
769
|
+
sessionPermissions?: string[];
|
|
770
|
+
history?: TurnHistoryMessage[];
|
|
771
|
+
sessionResumptionHandle?: string;
|
|
772
|
+
/** Optional realtime parts sent immediately after setup. */
|
|
773
|
+
input?: InteractionPart[];
|
|
774
|
+
/**
|
|
775
|
+
* Registry-resolved tool snapshot from the process that owns the tool registry
|
|
776
|
+
* (`prepareTurnToolSnapshot`). When set, session setup declares `snapshot.wire`
|
|
777
|
+
* instead of resolving tools locally, so a relay process without the registry
|
|
778
|
+
* can open the session. Every custom id must be within the profile's
|
|
779
|
+
* `tools.allow`; ids outside it are refused.
|
|
780
|
+
*/
|
|
781
|
+
snapshot?: TurnToolSnapshot;
|
|
782
|
+
signal?: AbortSignal;
|
|
783
|
+
/** Host-owned metadata preserved on every record the session writes. */
|
|
784
|
+
metadata?: Record<string, unknown>;
|
|
785
|
+
/**
|
|
786
|
+
* W3C `traceparent` of the host span this session runs under. The session's
|
|
787
|
+
* root span joins that trace as its child; without it the session starts a
|
|
788
|
+
* new trace. A malformed value throws.
|
|
789
|
+
*/
|
|
790
|
+
traceparent?: string;
|
|
791
|
+
/** Host conversation id, recorded as `gen_ai.conversation.id`. */
|
|
792
|
+
conversationId?: string;
|
|
793
|
+
links?: TurnTraceLink[];
|
|
794
|
+
/** Immutable for the session; there is no `setOnStage`. */
|
|
795
|
+
onStage?: StageHandler;
|
|
796
|
+
/**
|
|
797
|
+
* Default credentials for `executeTool` (per-call args override). Without one, the
|
|
798
|
+
* session keeps keys typed at its sign-in gates in memory.
|
|
799
|
+
*/
|
|
800
|
+
credentials?: ToolCredentialSource;
|
|
801
|
+
/**
|
|
802
|
+
* Resolves remote tool and OAuth host names before each request; a name that
|
|
803
|
+
* resolves to a private address is refused (see `fetchGuarded`).
|
|
804
|
+
*/
|
|
805
|
+
resolveHost?: ResolveHost;
|
|
806
|
+
/** Opaque host slot for stages / tool execute (per-call args override). */
|
|
807
|
+
host?: unknown;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Run a call the model made in this session, by its id: once, with the
|
|
811
|
+
* model's input. `decision` answers a call waiting on a gate, and only such a
|
|
812
|
+
* call; `input` is the user's edit, and only with `approve` on a gated call.
|
|
813
|
+
*/
|
|
814
|
+
export type LiveExecuteToolArgs = {
|
|
815
|
+
callId: string;
|
|
816
|
+
decision?: GateDecision;
|
|
817
|
+
input?: unknown;
|
|
818
|
+
/**
|
|
819
|
+
* The key the user typed at a sign-in gate, only with `approve` on that
|
|
820
|
+
* gate: the session sets it as the credential for the gate's slot
|
|
821
|
+
* (`credentialFromTypedSecret`) in the source the call runs with.
|
|
822
|
+
*/
|
|
823
|
+
secret?: string;
|
|
824
|
+
credentials?: ToolCredentialSource;
|
|
825
|
+
host?: unknown;
|
|
826
|
+
};
|
|
827
|
+
/**
|
|
828
|
+
* Settle a call the model made in this session whose body ran in the process
|
|
829
|
+
* that owns the tool registry: `events` are that process's `invokeTool`
|
|
830
|
+
* events for `callId`, which ran with the model's input.
|
|
831
|
+
*/
|
|
832
|
+
export type LiveAnswerToolCallArgs = {
|
|
833
|
+
callId: string;
|
|
834
|
+
events: readonly TurnEvent[];
|
|
835
|
+
};
|
|
836
|
+
export type LiveExecuteToolResult = {
|
|
837
|
+
outputRaw?: unknown;
|
|
838
|
+
outputModel?: ModelToolResult;
|
|
839
|
+
failure?: ToolFailure;
|
|
840
|
+
awaiting?: boolean;
|
|
841
|
+
gated?: ToolGate;
|
|
842
|
+
};
|
|
843
|
+
/**
|
|
844
|
+
* Open Gemini Live session returned by `runSession`. It streams events until
|
|
845
|
+
* `close()` and exposes realtime media ingress and staged tool execution.
|
|
846
|
+
*/
|
|
847
|
+
export interface LiveSession {
|
|
848
|
+
readonly profileId: ProfileId;
|
|
849
|
+
readonly canary: string;
|
|
850
|
+
events(): AsyncGenerator<TurnEvent, void, undefined>;
|
|
851
|
+
/** `mimeType` states the audio as sent (`audio/pcm;rate=16000`); the API rejects what it cannot take. */
|
|
852
|
+
sendAudio(args: {
|
|
853
|
+
data: string;
|
|
854
|
+
mimeType: string;
|
|
855
|
+
}): Promise<void>;
|
|
856
|
+
/** `mimeType` states the frame as sent (`image/jpeg`). */
|
|
857
|
+
sendVideo(args: {
|
|
858
|
+
data: string;
|
|
859
|
+
mimeType: string;
|
|
860
|
+
}): Promise<void>;
|
|
861
|
+
sendText(text: string): Promise<void>;
|
|
862
|
+
/**
|
|
863
|
+
* Text the model reads as background, not as the caller speaking: it opens no
|
|
864
|
+
* turn and draws no reply. Same `ingress.text` gate and inbound guardrails as
|
|
865
|
+
* `sendText`; the model sees it from its next turn on.
|
|
866
|
+
*/
|
|
867
|
+
sendContext(text: string): Promise<void>;
|
|
868
|
+
/**
|
|
869
|
+
* Run a call the model made through the registry, with stages; its events
|
|
870
|
+
* join `events()`. A gate returns `gated` and answers the model nothing yet;
|
|
871
|
+
* the call waits `gateTtlMs` for its `decision`. An unknown, settled,
|
|
872
|
+
* running or expired call is a `request` error and runs nothing.
|
|
873
|
+
*/
|
|
874
|
+
executeTool(args: LiveExecuteToolArgs): Promise<LiveExecuteToolResult>;
|
|
875
|
+
/**
|
|
876
|
+
* Settle a call whose body ran in the registry-owning process: its events
|
|
877
|
+
* join `events()` and the model reads its `readBack`. A run that ends on a
|
|
878
|
+
* gate leaves the call open; a released sign-in (`signInGate: 'answer'`)
|
|
879
|
+
* takes its outcome until `gateTtlMs`. An unknown, settled, running or
|
|
880
|
+
* expired call, or events that settle nothing for it, is a `request` error.
|
|
881
|
+
*/
|
|
882
|
+
answerToolCall(args: LiveAnswerToolCallArgs): LiveExecuteToolResult;
|
|
883
|
+
close(reason?: string): Promise<void>;
|
|
884
|
+
}
|