@theoremjs/agents 0.3.0 → 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/README.md +276 -995
- package/esm/mod.d.ts +33 -19
- package/esm/mod.js +18 -11
- package/esm/src/cli/commands/bench.js +36 -14
- 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 +3 -3
- package/esm/src/cli/commands/fuzz-canary.js +55 -16
- package/esm/src/cli/commands/profile.js +4 -4
- package/esm/src/cli/commands/run.d.ts +2 -2
- package/esm/src/cli/commands/run.js +1 -1
- package/esm/src/cli/commands/test.d.ts +4 -3
- package/esm/src/cli/commands/test.js +2 -2
- package/esm/src/cli/index.js +9 -9
- package/esm/src/cli/matrix/fixtures.js +25 -30
- package/esm/src/evals/attachments.d.ts +1 -0
- package/esm/src/evals/attachments.js +4 -2
- package/esm/src/evals/breakdown.d.ts +2 -0
- package/esm/src/evals/breakdown.js +1 -0
- package/esm/src/evals/graders/answer.d.ts +3 -0
- package/esm/src/evals/graders/answer.js +1 -0
- package/esm/src/evals/graders/code.d.ts +7 -31
- package/esm/src/evals/graders/code.js +4 -25
- package/esm/src/evals/graders/judge.d.ts +4 -0
- package/esm/src/evals/graders/judge.js +7 -5
- package/esm/src/evals/graders/latency.d.ts +1 -0
- package/esm/src/evals/graders/latency.js +3 -2
- package/esm/src/evals/graders/live.d.ts +3 -0
- package/esm/src/evals/graders/live.js +2 -0
- package/esm/src/evals/graders/media.js +1 -2
- package/esm/src/evals/graders/shared.js +1 -1
- package/esm/src/evals/graders/transcript.d.ts +2 -0
- package/esm/src/evals/graders/transcript.js +5 -3
- package/esm/src/evals/mod.d.ts +1 -9
- package/esm/src/evals/mod.js +1 -9
- package/esm/src/evals/record.d.ts +6 -0
- package/esm/src/evals/record.js +4 -2
- package/esm/src/evals/rubrics/mod.d.ts +1 -1
- package/esm/src/evals/rubrics/mod.js +1 -1
- package/esm/src/evals/rubrics/mustache.js +1 -1
- package/esm/src/evals/rubrics/types.js +1 -1
- package/esm/src/evals/run.d.ts +9 -52
- package/esm/src/evals/run.js +12 -46
- package/esm/src/evals/suite.d.ts +12 -3
- package/esm/src/evals/suite.js +9 -4
- package/esm/src/evals/summary.d.ts +3 -0
- package/esm/src/evals/summary.js +1 -0
- package/esm/src/evals/trial.d.ts +3 -16
- package/esm/src/evals/trial.js +7 -30
- package/esm/src/evals/types.d.ts +30 -121
- package/esm/src/evals/types.js +3 -16
- package/esm/src/evals/verdict.d.ts +5 -0
- package/esm/src/evals/verdict.js +4 -1
- 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 +1 -0
- package/esm/src/guardrails/canary.d.ts +49 -15
- package/esm/src/guardrails/canary.js +103 -30
- package/esm/src/guardrails/compile-egress.d.ts +6 -5
- package/esm/src/guardrails/compile-egress.js +6 -5
- package/esm/src/guardrails/corpus/canary-egress-attacks.d.ts +3 -1
- package/esm/src/guardrails/corpus/canary-egress-attacks.js +4 -2
- package/esm/src/guardrails/corpus/fuzz-inbound.js +14 -17
- package/esm/src/guardrails/corpus/inbound-payloads.d.ts +2 -0
- package/esm/src/guardrails/corpus/inbound-payloads.js +4 -2
- package/esm/src/guardrails/corpus/live-attacks.d.ts +2 -0
- package/esm/src/guardrails/corpus/live-attacks.js +6 -1
- package/esm/src/guardrails/corpus/mod.d.ts +1 -1
- package/esm/src/guardrails/corpus/secrets.d.ts +3 -3
- package/esm/src/guardrails/corpus/secrets.js +2 -2
- package/esm/src/guardrails/corpus/strings.d.ts +1 -1
- package/esm/src/guardrails/corpus/strings.js +1 -1
- package/esm/src/guardrails/corpus/types.d.ts +5 -1
- 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 +4 -6
- package/esm/src/guardrails/egress-automata.js +24095 -4572
- package/esm/src/guardrails/egress-compiler.d.ts +38 -16
- package/esm/src/guardrails/egress-compiler.js +254 -60
- package/esm/src/guardrails/egress-patterns.d.ts +4 -2
- package/esm/src/guardrails/egress-patterns.js +6 -2
- package/esm/src/guardrails/egress-stream.d.ts +54 -36
- package/esm/src/guardrails/egress-stream.js +253 -124
- package/esm/src/guardrails/egress-urls.d.ts +6 -3
- package/esm/src/guardrails/egress-urls.js +14 -22
- package/esm/src/guardrails/egress.d.ts +26 -86
- package/esm/src/guardrails/egress.js +59 -309
- package/esm/src/guardrails/error.d.ts +13 -8
- package/esm/src/guardrails/error.js +23 -18
- package/esm/src/guardrails/event-schemas.d.ts +46 -3
- package/esm/src/guardrails/event-schemas.js +12 -5
- package/esm/src/guardrails/events.d.ts +5 -1
- package/esm/src/guardrails/events.js +4 -1
- package/esm/src/guardrails/hints.d.ts +14 -0
- package/esm/src/guardrails/hints.js +57 -0
- package/esm/src/guardrails/hits.d.ts +7 -1
- package/esm/src/guardrails/hits.js +12 -1
- 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 +6 -1
- package/esm/src/guardrails/injection-patterns.js +33 -1
- 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 +17 -1
- package/esm/src/guardrails/injection.js +259 -36
- 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 +9 -8
- package/esm/src/guardrails/live-outbound-gate.js +100 -107
- package/esm/src/guardrails/mod.d.ts +29 -21
- package/esm/src/guardrails/mod.js +18 -13
- package/esm/src/guardrails/network.d.ts +4 -0
- package/esm/src/guardrails/network.js +21 -19
- package/esm/src/guardrails/normalize.d.ts +15 -1
- package/esm/src/guardrails/normalize.js +34 -1
- package/esm/src/guardrails/policy.d.ts +2 -17
- package/esm/src/guardrails/policy.js +12 -41
- package/esm/src/guardrails/progressive-yield.d.ts +65 -24
- package/esm/src/guardrails/progressive-yield.js +191 -147
- package/esm/src/guardrails/prompt-echo.d.ts +4 -2
- package/esm/src/guardrails/prompt-echo.js +87 -6
- package/esm/src/guardrails/quota.d.ts +1 -0
- package/esm/src/guardrails/quota.js +1 -1
- package/esm/src/guardrails/rules.d.ts +20 -29
- package/esm/src/guardrails/rules.js +23 -30
- package/esm/src/guardrails/sanitize.d.ts +32 -15
- package/esm/src/guardrails/sanitize.js +100 -124
- 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 +16 -23
- package/esm/src/guardrails/sensitive.js +168 -47
- package/esm/src/guardrails/serialize.d.ts +1 -0
- package/esm/src/guardrails/testing.d.ts +4 -2
- package/esm/src/guardrails/testing.js +4 -2
- package/esm/src/guardrails/theorem-error.d.ts +4 -1
- package/esm/src/guardrails/theorem-error.js +3 -2
- package/esm/src/guardrails/thought-guard.d.ts +34 -13
- package/esm/src/guardrails/thought-guard.js +264 -64
- package/esm/src/guardrails/tool-directives.d.ts +29 -10
- package/esm/src/guardrails/tool-directives.js +133 -47
- 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 +45 -14
- package/esm/src/guardrails/tool-result.js +94 -70
- package/esm/src/guardrails/types.d.ts +79 -71
- package/esm/src/guardrails/types.js +11 -7
- package/esm/src/host/client-turn.d.ts +29 -2
- package/esm/src/host/client-turn.js +46 -4
- package/esm/src/host/mint-trace.d.ts +1 -0
- package/esm/src/host/mint-trace.js +3 -2
- package/esm/src/host/mod.d.ts +2 -2
- package/esm/src/host/mod.js +1 -1
- package/esm/src/host/readStreamingJsonStringField.js +2 -43
- package/esm/src/host/reply.d.ts +6 -0
- package/esm/src/host/reply.js +7 -1
- package/esm/src/interface/blocks.d.ts +3 -0
- package/esm/src/interface/blocks.js +84 -14
- package/esm/src/interface/composer-actions.d.ts +4 -0
- package/esm/src/interface/composer-actions.js +5 -3
- package/esm/src/interface/draft.d.ts +6 -0
- package/esm/src/interface/draft.js +22 -11
- package/esm/src/interface/from-profile.d.ts +13 -1
- package/esm/src/interface/from-profile.js +66 -31
- package/esm/src/interface/history.d.ts +9 -3
- package/esm/src/interface/history.js +33 -24
- package/esm/src/interface/inputs.d.ts +1 -0
- package/esm/src/interface/inputs.js +3 -0
- package/esm/src/interface/mod.d.ts +4 -2
- package/esm/src/interface/mod.js +3 -2
- package/esm/src/interface/models.d.ts +7 -0
- package/esm/src/interface/models.js +5 -0
- package/esm/src/interface/pending.d.ts +9 -0
- package/esm/src/interface/pending.js +9 -3
- package/esm/src/interface/profile-interface.js +54 -40
- package/esm/src/interface/session.d.ts +12 -5
- package/esm/src/interface/session.js +17 -10
- 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 +14 -2
- package/esm/src/interface/tool-calls.js +64 -10
- package/esm/src/interface/tool-invoke.d.ts +2 -0
- package/esm/src/interface/tool-invoke.js +3 -1
- package/esm/src/interface/tool-media.d.ts +2 -0
- package/esm/src/interface/tool-media.js +2 -1
- package/esm/src/interface/types.d.ts +105 -40
- package/esm/src/interface/types.js +1 -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/crypto.d.ts +7 -2
- package/esm/src/kernel/auth/crypto.js +12 -10
- package/esm/src/kernel/auth/oauth.d.ts +2 -1
- package/esm/src/kernel/auth/oauth.js +23 -22
- package/esm/src/kernel/auth/typed-secret.js +2 -2
- package/esm/src/kernel/auth/types.d.ts +13 -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 +43 -5
- package/esm/src/kernel/default-scope.js +54 -5
- 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 +6 -5
- package/esm/src/kernel/engine/compaction.js +12 -11
- package/esm/src/kernel/engine/decision.d.ts +10 -8
- package/esm/src/kernel/engine/decision.js +173 -146
- package/esm/src/kernel/engine/embedding.d.ts +8 -0
- package/esm/src/kernel/engine/embedding.js +118 -0
- package/esm/src/kernel/engine/live-inbound.d.ts +14 -4
- package/esm/src/kernel/engine/live-inbound.js +36 -11
- package/esm/src/kernel/engine/live-ingress.d.ts +6 -0
- package/esm/src/kernel/engine/live-ingress.js +6 -1
- package/esm/src/kernel/engine/repair.js +12 -12
- package/esm/src/kernel/engine/runner/gates.d.ts +2 -2
- package/esm/src/kernel/engine/runner/gates.js +287 -101
- package/esm/src/kernel/engine/runner/mod.d.ts +19 -5
- package/esm/src/kernel/engine/runner/mod.js +107 -56
- 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 +24 -3
- package/esm/src/kernel/engine/runner/schema-validation.js +78 -4
- package/esm/src/kernel/engine/runner/stages.d.ts +1 -1
- package/esm/src/kernel/engine/runner/stages.js +1 -8
- package/esm/src/kernel/engine/runner/state.d.ts +33 -12
- package/esm/src/kernel/engine/runner/state.js +11 -1
- 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 +2 -2
- package/esm/src/kernel/engine/runner/steps.js +328 -169
- package/esm/src/kernel/engine/runner/stream.d.ts +42 -11
- package/esm/src/kernel/engine/runner/stream.js +197 -46
- package/esm/src/kernel/engine/runner/usage.d.ts +5 -5
- package/esm/src/kernel/engine/runner/usage.js +12 -14
- package/esm/src/kernel/engine/session/mod.d.ts +8 -6
- package/esm/src/kernel/engine/session/mod.js +360 -129
- package/esm/src/kernel/engine/session/session-trace.d.ts +10 -10
- package/esm/src/kernel/engine/session/session-trace.js +41 -30
- package/esm/src/kernel/engine/token-estimate.d.ts +10 -64
- package/esm/src/kernel/engine/token-estimate.js +14 -194
- package/esm/src/kernel/engine/tool-trace.d.ts +3 -3
- package/esm/src/kernel/engine/tool-trace.js +2 -1
- package/esm/src/kernel/engine/turn-trace.d.ts +8 -7
- package/esm/src/kernel/engine/turn-trace.js +28 -36
- package/esm/src/kernel/engine/usage.d.ts +6 -0
- package/esm/src/kernel/engine/usage.js +17 -0
- package/esm/src/kernel/interaction-parts.d.ts +3 -0
- package/esm/src/kernel/interaction-parts.js +18 -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 +38 -11
- package/esm/src/kernel/mod.js +22 -7
- package/esm/src/kernel/profile-graph.d.ts +11 -6
- package/esm/src/kernel/profile-graph.js +14 -7
- package/esm/src/kernel/profile-presence.d.ts +10 -1
- package/esm/src/kernel/profile-presence.js +90 -75
- package/esm/src/kernel/profile-scope.d.ts +7 -3
- package/esm/src/kernel/profile-scope.js +67 -55
- 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 +15 -4
- package/esm/src/kernel/registry/attachments.js +31 -22
- package/esm/src/kernel/registry/catalog.d.ts +6 -0
- package/esm/src/kernel/registry/catalog.js +9 -2
- 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 +6 -2
- package/esm/src/kernel/registry/ingress.js +55 -10
- package/esm/src/kernel/registry/kernel-registry.d.ts +3 -0
- package/esm/src/kernel/registry/kernel-registry.js +9 -2
- package/esm/src/kernel/registry/profile-outputs.js +4 -1
- package/esm/src/kernel/registry/profiles.d.ts +38 -14
- package/esm/src/kernel/registry/profiles.js +280 -205
- package/esm/src/kernel/registry/provider-request.d.ts +3 -3
- package/esm/src/kernel/registry/provider-request.js +5 -13
- package/esm/src/kernel/registry/resolve.d.ts +4 -1
- package/esm/src/kernel/registry/resolve.js +59 -58
- package/esm/src/kernel/registry/schemas.d.ts +3 -0
- package/esm/src/kernel/registry/schemas.js +3 -1
- 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/system-prompt.js +7 -8
- package/esm/src/kernel/registry/vault.d.ts +14 -13
- package/esm/src/kernel/registry/vault.js +1 -14
- package/esm/src/kernel/schema.d.ts +100 -46
- package/esm/src/kernel/schema.js +499 -257
- package/esm/src/kernel/scope.d.ts +12 -5
- package/esm/src/kernel/scope.js +23 -3
- package/esm/src/kernel/stages.d.ts +38 -3
- package/esm/src/kernel/stages.js +82 -39
- package/esm/src/kernel/stop.d.ts +29 -6
- package/esm/src/kernel/stop.js +16 -4
- package/esm/src/kernel/system-parts.js +6 -6
- package/esm/src/kernel/tools/activity-label.d.ts +12 -6
- package/esm/src/kernel/tools/activity-label.js +258 -32
- 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 +21 -6
- package/esm/src/kernel/tools/events.js +53 -18
- package/esm/src/kernel/tools/execute.d.ts +47 -11
- package/esm/src/kernel/tools/execute.js +508 -136
- package/esm/src/kernel/tools/gate-answer.d.ts +12 -2
- package/esm/src/kernel/tools/gate-answer.js +17 -6
- 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 +1 -0
- package/esm/src/kernel/tools/harness.js +2 -1
- 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 +27 -5
- package/esm/src/kernel/tools/invoke.js +223 -70
- package/esm/src/kernel/tools/mcp-sessions.d.ts +4 -1
- package/esm/src/kernel/tools/mcp-sessions.js +13 -8
- package/esm/src/kernel/tools/mod.d.ts +4 -3
- package/esm/src/kernel/tools/mod.js +3 -2
- package/esm/src/kernel/tools/model-text.d.ts +10 -5
- package/esm/src/kernel/tools/model-text.js +18 -12
- 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 +11 -2
- package/esm/src/kernel/tools/permission.js +12 -12
- package/esm/src/kernel/tools/project.d.ts +4 -1
- package/esm/src/kernel/tools/project.js +32 -2
- package/esm/src/kernel/tools/registry.d.ts +9 -2
- package/esm/src/kernel/tools/registry.js +69 -10
- package/esm/src/kernel/tools/remote.d.ts +40 -6
- package/esm/src/kernel/tools/remote.js +219 -92
- package/esm/src/kernel/tools/resolve.d.ts +3 -0
- package/esm/src/kernel/tools/resolve.js +12 -4
- 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 +3 -3
- package/esm/src/kernel/tools/schema.js +21 -100
- package/esm/src/kernel/tools/signed-in-fetch.d.ts +2 -1
- package/esm/src/kernel/tools/signed-in-fetch.js +3 -3
- package/esm/src/kernel/tools/stage-run.d.ts +27 -4
- package/esm/src/kernel/tools/stage-run.js +75 -17
- package/esm/src/kernel/tools/types.d.ts +235 -25
- 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 +208 -31
- package/esm/src/kernel/turn-events.js +127 -9
- package/esm/src/kernel/types.d.ts +302 -161
- package/esm/src/kernel/util/base64.d.ts +2 -0
- package/esm/src/kernel/util/base64.js +2 -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 +1 -0
- package/esm/src/kernel/util/record.js +1 -0
- package/esm/src/observability/destinations.d.ts +5 -0
- package/esm/src/observability/destinations.js +7 -2
- package/esm/src/observability/jsonl.d.ts +2 -2
- package/esm/src/observability/jsonl.js +15 -22
- package/esm/src/observability/mod.d.ts +3 -3
- package/esm/src/observability/mod.js +2 -2
- package/esm/src/observability/openinference.d.ts +1 -1
- package/esm/src/observability/openinference.js +3 -3
- package/esm/src/observability/otlp.d.ts +3 -0
- package/esm/src/observability/otlp.js +3 -3
- package/esm/src/observability/phoenix.d.ts +1 -0
- package/esm/src/observability/policy.d.ts +3 -0
- package/esm/src/observability/policy.js +5 -1
- package/esm/src/observability/resolve-policy.js +11 -5
- package/esm/src/observability/spans.d.ts +8 -2
- package/esm/src/observability/spans.js +21 -5
- package/esm/src/observability/trace-catalog.d.ts +19 -2
- package/esm/src/observability/trace-catalog.js +128 -87
- package/esm/src/observability/trace-record.js +22 -17
- package/esm/src/observability/trace-schema.d.ts +3 -0
- package/esm/src/observability/trace-schema.js +1 -1
- package/esm/src/observability/trace-sink.d.ts +1 -0
- package/esm/src/observability/trace-sink.js +1 -1
- package/esm/src/observability/trace-span.d.ts +7 -1
- package/esm/src/observability/trace-span.js +3 -1
- package/esm/src/observability/trace.d.ts +2 -0
- package/esm/src/observability/trace.js +4 -2
- package/esm/src/observability/types.d.ts +35 -11
- package/esm/src/observability/types.js +1 -1
- package/esm/src/presets/google/speech-voices.d.ts +1 -0
- package/esm/src/presets/google-limits.d.ts +1 -0
- package/esm/src/presets/google.d.ts +27 -12
- package/esm/src/presets/google.js +34 -25
- package/esm/src/presets/local.d.ts +26 -0
- package/esm/src/presets/local.js +30 -0
- package/esm/src/presets/mod.d.ts +5 -4
- package/esm/src/presets/mod.js +4 -4
- package/esm/src/presets/openrouter.d.ts +14 -1
- package/esm/src/presets/openrouter.js +19 -1
- 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/builtins.d.ts +14 -0
- package/esm/src/providers/google/builtins.js +57 -0
- package/esm/src/providers/google/grounding.d.ts +4 -4
- package/esm/src/providers/google/interactions/framing.d.ts +20 -8
- package/esm/src/providers/google/interactions/framing.js +85 -44
- package/esm/src/providers/google/interactions/steps.d.ts +5 -5
- package/esm/src/providers/google/interactions/steps.js +4 -4
- package/esm/src/providers/google/interactions/stream.d.ts +10 -11
- package/esm/src/providers/google/interactions/stream.js +33 -100
- package/esm/src/providers/google/live/framing.d.ts +15 -5
- package/esm/src/providers/google/live/framing.js +25 -25
- package/esm/src/providers/google/live/stream.d.ts +6 -44
- package/esm/src/providers/google/live/stream.js +3 -209
- package/esm/src/providers/google/urls.d.ts +1 -3
- package/esm/src/providers/google/urls.js +1 -3
- package/esm/src/providers/google/usage.js +2 -2
- 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 +28 -7
- package/esm/src/providers/mod.js +19 -3
- 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 +0 -9
- package/esm/src/providers/openrouter/image.js +0 -153
- 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 +2 -2
- package/esm/src/providers/openrouter/openai/compat.js +6 -6
- package/esm/src/providers/openrouter/openai/image-payload.d.ts +2 -2
- 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/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.js +2 -2
- 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 +2 -2
- 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 +0 -4
- package/esm/src/providers/shared/sse.js +50 -36
- package/esm/src/providers/shared/tool-args.d.ts +6 -7
- package/esm/src/providers/shared/tool-args.js +10 -6
- 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 +2 -2
- package/esm/src/providers/shared/upstream-tape.js +1 -1
- 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 +48 -16
- package/esm/src/providers/types.js +2 -1
- 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 +19 -1
- package/esm/src/surface/formats.js +68 -29
- package/esm/src/surface/mod.d.ts +4 -2
- package/esm/src/surface/mod.js +4 -2
- package/esm/src/surface/runtime.d.ts +4 -0
- package/esm/src/surface/runtime.js +2 -0
- package/esm/src/surface/tools.d.ts +2 -8
- package/esm/src/surface/tools.js +4 -22
- package/esm/src/surface/types.d.ts +6 -0
- package/package.json +5 -13
- package/esm/src/cli/commands/egress-compile.d.ts +0 -17
- package/esm/src/cli/commands/egress-compile.js +0 -25
- package/esm/src/guardrails/egress-policy.d.ts +0 -27
- package/esm/src/guardrails/egress-policy.js +0 -76
- package/esm/src/guardrails/egress-rules.d.ts +0 -54
- package/esm/src/guardrails/egress-rules.js +0 -49
- package/esm/src/guardrails/lexicon.d.ts +0 -30
- package/esm/src/guardrails/lexicon.js +0 -478
- package/esm/src/kernel/engine/media-probe/audio.d.ts +0 -7
- package/esm/src/kernel/engine/media-probe/audio.js +0 -342
- package/esm/src/kernel/engine/media-probe/bytes.d.ts +0 -6
- package/esm/src/kernel/engine/media-probe/bytes.js +0 -26
- package/esm/src/kernel/engine/media-probe/image.d.ts +0 -5
- package/esm/src/kernel/engine/media-probe/image.js +0 -171
- package/esm/src/kernel/engine/media-probe/iso-bmff.d.ts +0 -19
- package/esm/src/kernel/engine/media-probe/iso-bmff.js +0 -48
- package/esm/src/kernel/engine/media-probe/matroska.d.ts +0 -35
- package/esm/src/kernel/engine/media-probe/matroska.js +0 -226
- package/esm/src/kernel/engine/media-probe/mp4.d.ts +0 -22
- package/esm/src/kernel/engine/media-probe/mp4.js +0 -279
- package/esm/src/kernel/engine/media-probe/opus.d.ts +0 -4
- package/esm/src/kernel/engine/media-probe/opus.js +0 -23
- package/esm/src/kernel/engine/media-probe/pdf.d.ts +0 -5
- package/esm/src/kernel/engine/media-probe/pdf.js +0 -117
- package/esm/src/kernel/engine/media-probe/video.d.ts +0 -15
- package/esm/src/kernel/engine/media-probe/video.js +0 -49
- package/esm/src/presets/typesafe.d.ts +0 -2
- package/esm/src/presets/typesafe.js +0 -2
- package/esm/src/providers/create-provider.d.ts +0 -21
- package/esm/src/providers/create-provider.js +0 -90
- package/esm/src/providers/decision/usage.d.ts +0 -3
- package/esm/src/providers/decision/usage.js +0 -25
- package/esm/src/providers/google/interactions/mod.d.ts +0 -2
- package/esm/src/providers/google/interactions/mod.js +0 -2
- package/esm/src/providers/google/keys.d.ts +0 -20
- package/esm/src/providers/google/keys.js +0 -87
- package/esm/src/providers/google/live/mod.d.ts +0 -7
- package/esm/src/providers/google/live/mod.js +0 -7
- package/esm/src/providers/google/live/openapi-schema.d.ts +0 -1
- package/esm/src/providers/google/live/openapi-schema.js +0 -42
- package/esm/src/providers/google/live/session.d.ts +0 -14
- package/esm/src/providers/google/live/session.js +0 -150
- package/esm/src/providers/local/local.d.ts +0 -12
- package/esm/src/providers/local/local.js +0 -186
- package/esm/src/providers/local/mod.d.ts +0 -8
- package/esm/src/providers/local/mod.js +0 -8
- package/esm/src/providers/openrouter/cache-control.d.ts +0 -5
- package/esm/src/providers/openrouter/cache-control.js +0 -4
- package/esm/src/providers/openrouter/chat.d.ts +0 -64
- package/esm/src/providers/openrouter/chat.js +0 -490
- package/esm/src/providers/openrouter/openai/sdk-messages.d.ts +0 -10
- package/esm/src/providers/openrouter/openai/sdk-messages.js +0 -99
- package/esm/src/providers/openrouter/resolve-api-key.d.ts +0 -3
- package/esm/src/providers/openrouter/resolve-api-key.js +0 -8
- package/esm/src/providers/openrouter/speech.d.ts +0 -18
- package/esm/src/providers/openrouter/speech.js +0 -109
- package/esm/src/providers/probe.d.ts +0 -5
- package/esm/src/providers/probe.js +0 -15
- package/esm/src/providers/shared/builtin-wire.d.ts +0 -4
- package/esm/src/providers/shared/builtin-wire.js +0 -9
- package/esm/src/providers/shared/vault.d.ts +0 -13
- package/esm/src/providers/shared/vault.js +0 -41
|
@@ -1,22 +1,35 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProviderCheckpoint, ProviderContinuationPolicy } from './checkpoint.js';
|
|
2
|
+
import type { JsonObject } from './json.js';
|
|
3
|
+
import type { CacheMode, CacheTtl, CompactionMeter, CompactionOutcome, CompactionTiming, ContextSender, ContinueStopKind, FieldMeta, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveStartSensitivity, MediaInputKind, ProfileType, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolLoadTier, TurnStage, TurnStopKind } from './schema.js';
|
|
2
4
|
import type { StageHandler } from './stages.js';
|
|
3
5
|
import type { GateDecision } from './tools/gate-answer.js';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
|
|
6
|
+
import type { PageToolExecution, ToolExecutionCoordinator } from './tools/operation.js';
|
|
7
|
+
import type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, HostProfileToolsSpec, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, LiveProfileToolsSpec, ModelToolResult, PageAnswer, ProfileToolsSpec, RegisteredTool, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolPolicy, TurnToolSnapshot, WireFunctionTool } from './tools/types.js';
|
|
8
|
+
import type { AttemptReason, CallDone, CompactionFailure, CompactionResult, CompactionSignal, DoneFields, GroundingEvent, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, ModelEvent, ProviderEvidence, RemovedItem, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnTokenSide, TurnTokens } from './turn-events.js';
|
|
9
|
+
export type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, AttemptReason, CacheMode, CacheTtl, CallDone, CompactionFailure, CompactionMeter, CompactionOutcome, CompactionResult, CompactionSignal, CompactionTiming, ContinueStopKind, DoneFields, FieldMeta, GroundingEvent, HostProfileToolsSpec, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveProfileToolsSpec, LiveStartSensitivity, MediaInputKind, ModelEvent, ProfileToolsSpec, ProfileType, ProviderEvidence, RegisteredTool, RemovedItem, 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, };
|
|
10
|
+
/** A host-chosen key naming one model binding in a profile's `models`. */
|
|
7
11
|
export type ModelId = string;
|
|
12
|
+
/** The id of a provider-side tool such as web search. */
|
|
8
13
|
export type BuiltinToolId = string;
|
|
14
|
+
/** The id a profile lists in `tools.allow` and the model calls a tool by. */
|
|
9
15
|
export type ToolId = string;
|
|
16
|
+
/** The id of a registered structured-output schema. */
|
|
10
17
|
export type StructuredSchemaId = string;
|
|
18
|
+
/** A structured-output schema resolved to its JSON Schema. */
|
|
11
19
|
export interface ResolvedStructured {
|
|
12
20
|
id: StructuredSchemaId;
|
|
13
21
|
jsonSchema: Record<string, unknown>;
|
|
14
22
|
}
|
|
23
|
+
/** A provider-side tool the turn uses, with the args the request addressed to it. */
|
|
15
24
|
export interface ProviderBuiltin {
|
|
16
25
|
id: BuiltinToolId;
|
|
17
|
-
|
|
26
|
+
args?: JsonObject;
|
|
18
27
|
}
|
|
28
|
+
/** Args a request hands to built-in tools, each checked by the schema its adapter declares. */
|
|
29
|
+
export type BuiltInArgs = Record<BuiltinToolId, JsonObject>;
|
|
30
|
+
/** The id a profile is registered and run under. */
|
|
19
31
|
export type ProfileId = string;
|
|
32
|
+
/** The roles a history message can carry. */
|
|
20
33
|
export type ChatRole = 'system' | 'user' | 'assistant';
|
|
21
34
|
/** Host strings (presets own the vocabularies); an unpinned value is the provider default. */
|
|
22
35
|
export interface ProfileImageSpec {
|
|
@@ -32,52 +45,10 @@ export interface ProfileImageSpec {
|
|
|
32
45
|
/** Also request interleaved text with the images (Google: text + image `response_format`). */
|
|
33
46
|
includeText?: boolean;
|
|
34
47
|
}
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
}
|
|
48
|
+
import type { DecisionModelBinding, ModelBinding } from './protocols/binding.js';
|
|
49
|
+
export type { DecisionModelBinding, ModelBinding };
|
|
79
50
|
/**
|
|
80
|
-
* OpenRouter prompt-cache policy (`models.*.cache`).
|
|
51
|
+
* OpenRouter prompt-cache policy (`models.*.options.cache`).
|
|
81
52
|
*
|
|
82
53
|
* - `automatic` — top-level `cache_control`; breakpoint advances with the conversation.
|
|
83
54
|
* - `system` — explicit breakpoint on the system instruction only.
|
|
@@ -87,6 +58,7 @@ export interface CacheSpec {
|
|
|
87
58
|
/** Ephemeral TTL. Omit → provider default (typically 5m on Anthropic). */
|
|
88
59
|
ttl?: CacheTtl;
|
|
89
60
|
}
|
|
61
|
+
/** What a compaction trigger sees when it decides whether to compact. */
|
|
90
62
|
export interface CompactionTriggerContext {
|
|
91
63
|
tokens: number;
|
|
92
64
|
maxTokens: number;
|
|
@@ -95,6 +67,7 @@ export interface CompactionTriggerContext {
|
|
|
95
67
|
/** Media parts not counted in `tokens` — no verified rule for this model. */
|
|
96
68
|
unknownMedia: number;
|
|
97
69
|
}
|
|
70
|
+
/** When history compacts and how: the meter, the token budget, and the compactor. */
|
|
98
71
|
export interface CompactionSpec {
|
|
99
72
|
/**
|
|
100
73
|
* Token budget compared by the trigger (`compactAt * maxTokens`).
|
|
@@ -142,15 +115,18 @@ export interface CompactHistoryRequest {
|
|
|
142
115
|
conversationId?: string;
|
|
143
116
|
metadata?: Record<string, unknown>;
|
|
144
117
|
}
|
|
118
|
+
/** A structured-output schema given inline. */
|
|
145
119
|
export interface StructuredSpec {
|
|
146
120
|
jsonSchema: Record<string, unknown>;
|
|
147
121
|
}
|
|
122
|
+
/** Caps on the files a turn may attach. */
|
|
148
123
|
export interface MediaLimits {
|
|
149
124
|
maxFiles: number;
|
|
150
125
|
maxBytes: number;
|
|
151
126
|
maxTurnBytes: number;
|
|
152
127
|
limitsByMime?: Record<string, number>;
|
|
153
128
|
}
|
|
129
|
+
/** The input kinds a profile accepts, with their limits. */
|
|
154
130
|
export interface MimeInputs extends Partial<MediaLimits> {
|
|
155
131
|
text?: boolean;
|
|
156
132
|
attachments?: {
|
|
@@ -160,16 +136,19 @@ export interface MimeInputs extends Partial<MediaLimits> {
|
|
|
160
136
|
accept: string[];
|
|
161
137
|
};
|
|
162
138
|
}
|
|
163
|
-
|
|
139
|
+
/** Why an attachment was refused. */
|
|
140
|
+
export type AttachmentValidationCode = 'mime_not_allowed' | 'too_many_files' | 'too_many_of_kind' | 'file_too_large' | 'turn_too_large' | 'attachments_not_accepted' | 'voice_not_accepted' | 'limits_unconfigured';
|
|
164
141
|
/**
|
|
165
142
|
* Structured parameters for rendering one validation issue. Validation emits
|
|
166
|
-
* codes + params only; the wording is the
|
|
143
|
+
* codes + params only; the wording is the labels' `attachments.*` lines.
|
|
167
144
|
*/
|
|
168
145
|
export interface AttachmentValidationParams {
|
|
169
146
|
maxFiles?: number;
|
|
170
147
|
maxBytes?: number;
|
|
171
148
|
maxTurnBytes?: number;
|
|
172
149
|
mimeType?: string;
|
|
150
|
+
/** The kind of media a count is of, such as `PDF` or `image`. */
|
|
151
|
+
kind?: string;
|
|
173
152
|
channel?: 'attachment' | 'voice';
|
|
174
153
|
}
|
|
175
154
|
/** One reason a turn's files were refused; `fileName` names the file when the problem is one file's. */
|
|
@@ -178,18 +157,45 @@ export interface AttachmentValidationIssue {
|
|
|
178
157
|
params?: AttachmentValidationParams;
|
|
179
158
|
fileName?: string;
|
|
180
159
|
}
|
|
160
|
+
/** Picks the structured-output schema by the value of a turn slot, with a fallback. */
|
|
181
161
|
export interface StructuredBySlot {
|
|
182
162
|
by: string;
|
|
183
163
|
map: Record<string, string>;
|
|
184
164
|
fallback: string;
|
|
185
165
|
}
|
|
166
|
+
/** What a host validator returns for a candidate output. */
|
|
186
167
|
export interface ValidationResult {
|
|
187
168
|
isValid: boolean;
|
|
188
169
|
error?: string;
|
|
189
170
|
finding?: string;
|
|
190
171
|
data?: Record<string, unknown>;
|
|
191
172
|
}
|
|
173
|
+
/** A host function that checks one structured-output field. */
|
|
192
174
|
export type ProfileValidator = (candidate: unknown, slots?: Record<string, string>) => ValidationResult | Promise<ValidationResult>;
|
|
175
|
+
/** A tool call the turn completed, as an item check reads it. */
|
|
176
|
+
export interface TurnToolResult {
|
|
177
|
+
tool: string;
|
|
178
|
+
/** The output the call settled with, after any `post_tool` `mutate`. */
|
|
179
|
+
output: unknown;
|
|
180
|
+
}
|
|
181
|
+
/** What an item check reads of the turn whose reply it is checking. */
|
|
182
|
+
export interface ItemCheckTurn {
|
|
183
|
+
slots?: Record<string, string>;
|
|
184
|
+
/** Every tool call the turn completed, in order, across its attempts. */
|
|
185
|
+
toolResults: readonly TurnToolResult[];
|
|
186
|
+
}
|
|
187
|
+
/** A host function that checks one item of a list against what the turn's tools returned. */
|
|
188
|
+
export type ProfileItemCheck = (item: unknown, turn: ItemCheckTurn) => ValidationResult | Promise<ValidationResult>;
|
|
189
|
+
/**
|
|
190
|
+
* A host check on each item of one list in a structured reply. A refused item
|
|
191
|
+
* never fails the reply: `drop` removes it, and `fix` first asks the model to
|
|
192
|
+
* rewrite the refused items alone, then removes any that are refused again.
|
|
193
|
+
*/
|
|
194
|
+
export interface ProfileItemRule {
|
|
195
|
+
check: ProfileItemCheck;
|
|
196
|
+
onFail: 'drop' | 'fix';
|
|
197
|
+
}
|
|
198
|
+
/** Host validators a profile runs on its structured output. */
|
|
193
199
|
export interface ProfileValidationSpec {
|
|
194
200
|
/**
|
|
195
201
|
* Host domain validators keyed by dotted paths into structured output
|
|
@@ -197,14 +203,23 @@ export interface ProfileValidationSpec {
|
|
|
197
203
|
* these run only for required paths and for optional paths that are present.
|
|
198
204
|
*/
|
|
199
205
|
fields?: Record<string, ProfileValidator>;
|
|
206
|
+
/** Host checks on list items, keyed by the dotted path of a list in the structured output. */
|
|
207
|
+
items?: Record<string, ProfileItemRule>;
|
|
200
208
|
maxRetries?: number;
|
|
201
209
|
}
|
|
202
210
|
/** `voice` is the TTS voice id, not ingress audio (`inputs.voice`). */
|
|
203
211
|
export interface ProfileSpeechSpec {
|
|
204
212
|
voice?: string;
|
|
205
|
-
/**
|
|
213
|
+
/** How the script is delivered, in plain words: pace, mood, accent. Never read aloud. */
|
|
214
|
+
style?: string;
|
|
215
|
+
/** The speaking rate; 1 is the voice's own pace. */
|
|
216
|
+
speed?: number;
|
|
217
|
+
/** A provider that cannot make the format refuses the turn. */
|
|
206
218
|
format?: SpeechAudioFormat;
|
|
207
219
|
}
|
|
220
|
+
/** What one speech turn sets for itself; each field given replaces the profile's `speech` field of that name. */
|
|
221
|
+
export type TurnSpeech = Pick<ProfileSpeechSpec, 'voice' | 'style' | 'speed'>;
|
|
222
|
+
/** Voice activity detection settings for a live session. */
|
|
208
223
|
export interface LiveVadSpec {
|
|
209
224
|
activityHandling?: LiveActivityHandling;
|
|
210
225
|
startSensitivity?: LiveStartSensitivity;
|
|
@@ -227,6 +242,7 @@ export interface LiveContextCompressionSpec {
|
|
|
227
242
|
/** Drops the oldest turns; the system instruction stays. Gemini's only mechanism. */
|
|
228
243
|
slidingWindow: LiveSlidingWindowSpec;
|
|
229
244
|
}
|
|
245
|
+
/** Sliding-window context compression for a live session. */
|
|
230
246
|
export interface LiveSlidingWindowSpec {
|
|
231
247
|
/**
|
|
232
248
|
* Tokens to keep after compressing. A whole number above 0, below
|
|
@@ -234,6 +250,7 @@ export interface LiveSlidingWindowSpec {
|
|
|
234
250
|
*/
|
|
235
251
|
targetTokens?: number;
|
|
236
252
|
}
|
|
253
|
+
/** Which sides of a live session are transcribed. */
|
|
237
254
|
export interface LiveTranscriptionSpec {
|
|
238
255
|
input?: boolean;
|
|
239
256
|
output?: boolean;
|
|
@@ -251,40 +268,52 @@ export interface LiveIngressSpec {
|
|
|
251
268
|
/** Typed text via `sendText`. Omit → disabled (opt-in). */
|
|
252
269
|
text?: boolean;
|
|
253
270
|
}
|
|
271
|
+
/** The prompt a resumed call opens with, and how long away earns it. */
|
|
272
|
+
export interface LiveResumedSpec {
|
|
273
|
+
prompt: string;
|
|
274
|
+
/** The shortest time away, in milliseconds, the agent remarks on. Omit → `DEFAULT_RESUMED_AFTER_MS`. */
|
|
275
|
+
afterMs?: number;
|
|
276
|
+
}
|
|
277
|
+
/** The settings only a live profile has: ingress, voice, detection, windowing, transcription, and resumption. */
|
|
254
278
|
export interface ProfileLiveSpec {
|
|
255
279
|
ingress?: LiveIngressSpec;
|
|
256
280
|
voice?: string;
|
|
257
281
|
vad?: LiveVadSpec;
|
|
258
282
|
sessionResumption?: boolean;
|
|
283
|
+
/** A prompt the session sends itself when a call opens new, so the agent speaks first. Omit → the agent waits. */
|
|
284
|
+
greeting?: string;
|
|
285
|
+
/** What the agent is prompted with when a call resumes after the caller was away. Omit → a resumed call is silent. */
|
|
286
|
+
resumed?: LiveResumedSpec;
|
|
259
287
|
/** Context window compression. Omit → none: the provider ends the session at its limit. */
|
|
260
288
|
contextCompression?: LiveContextCompressionSpec;
|
|
261
289
|
transcription?: LiveTranscriptionSpec;
|
|
262
290
|
}
|
|
291
|
+
/** How a profile's reply streams. */
|
|
263
292
|
export interface ProfileStreamingSpec {
|
|
264
293
|
mode?: StreamMode;
|
|
265
294
|
/** When false, filter `thought` events from the turn stream. */
|
|
266
295
|
streamThoughts?: boolean;
|
|
267
296
|
}
|
|
268
297
|
export type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './stop.js';
|
|
269
|
-
import type {
|
|
298
|
+
import type { LabelOverrides } from '../guardrails/labels.js';
|
|
270
299
|
import type { ResolveHost } from '../guardrails/network.js';
|
|
271
300
|
import type { DecisionGuardrailsSpec, HostGuardrailsSpec, ProfileGuardrailsSpec } from '../guardrails/types.js';
|
|
272
301
|
import type { ProfileObservabilitySpec } from '../observability/types.js';
|
|
273
302
|
import type { ToolCredentialSource } from './auth/credential-source.js';
|
|
274
303
|
import type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, TurnContinueFrom } from './stop.js';
|
|
304
|
+
/** The model fields every model-running profile shares. */
|
|
275
305
|
export interface ProfileModelFields {
|
|
306
|
+
providerContinuation?: ProviderContinuationPolicy;
|
|
276
307
|
/** Host-named models. Each key is a selectable model id when `allowModelSelect` is set. */
|
|
277
308
|
models: Record<ModelId, ModelBinding>;
|
|
278
309
|
/** The model a turn runs when it names none; registration fills it with the only key when there is one. */
|
|
279
310
|
defaultModel: ModelId;
|
|
280
|
-
/** Turn may pass `{ model: "<id>" }
|
|
311
|
+
/** Turn may pass `{ model: "<id>" }`; a name that is not a key of `models` is refused. */
|
|
281
312
|
allowModelSelect?: boolean;
|
|
282
|
-
/** Tool-loop ceiling. Omit
|
|
313
|
+
/** Tool-loop ceiling. Omit = `DEFAULT_MAX_STEPS`; `1` = one-shot; `> 1` = hard cap. */
|
|
283
314
|
maxSteps?: number;
|
|
284
|
-
key?: KeySlot;
|
|
285
|
-
/** Retried once when `key` is refused for quota. Off unless set. */
|
|
286
|
-
fallbackKey?: KeySlot;
|
|
287
315
|
}
|
|
316
|
+
/** What a profile accepts as input. */
|
|
288
317
|
export interface ProfileInputsSpec {
|
|
289
318
|
text?: boolean;
|
|
290
319
|
attachments?: {
|
|
@@ -298,7 +327,18 @@ export interface ProfileInputsSpec {
|
|
|
298
327
|
maxTurnBytes?: number;
|
|
299
328
|
limitsByMime?: Record<string, number>;
|
|
300
329
|
slots?: Record<string, string[]>;
|
|
330
|
+
context?: ProfileContextSpec;
|
|
331
|
+
}
|
|
332
|
+
/** What a live profile declares beside its ingress channels. */
|
|
333
|
+
export type LiveInputsSpec = Pick<ProfileInputsSpec, 'slots' | 'context'>;
|
|
334
|
+
/** Who may send a turn its context, and how much. */
|
|
335
|
+
export interface ProfileContextSpec {
|
|
336
|
+
from: ContextSender[];
|
|
337
|
+
maxChars: number;
|
|
301
338
|
}
|
|
339
|
+
/** The context each sender gives a turn: any JSON, or text. */
|
|
340
|
+
export type TurnContext = Partial<Record<ContextSender, unknown>>;
|
|
341
|
+
/** What a profile returns: its structured schema, validation, and streaming. */
|
|
302
342
|
export interface ProfileOutputsSpec {
|
|
303
343
|
structured?: StructuredSchemaId | StructuredBySlot | null;
|
|
304
344
|
validation?: ProfileValidationSpec;
|
|
@@ -308,6 +348,7 @@ export interface ProfileOutputsSpec {
|
|
|
308
348
|
export interface PrivateSystemPart {
|
|
309
349
|
private: string;
|
|
310
350
|
}
|
|
351
|
+
/** One part of a system prompt: plain text or a part kept out of traces. */
|
|
311
352
|
export type SystemPart = string | PrivateSystemPart;
|
|
312
353
|
/**
|
|
313
354
|
* A system prompt: a string, or parts sent concatenated as written. A string,
|
|
@@ -320,36 +361,32 @@ export interface SystemPiece {
|
|
|
320
361
|
text: string;
|
|
321
362
|
private: boolean;
|
|
322
363
|
}
|
|
364
|
+
/** A profile's handle and system prompt. */
|
|
323
365
|
export interface ProfileIdentity {
|
|
324
366
|
handle: string;
|
|
325
367
|
system?: SystemPrompt;
|
|
326
368
|
systemByRole?: Record<string, SystemPrompt>;
|
|
327
369
|
}
|
|
370
|
+
/** The fields every profile type shares. */
|
|
328
371
|
export interface ProfileCommon {
|
|
372
|
+
providerContinuation?: ProviderContinuationPolicy;
|
|
329
373
|
id: ProfileId;
|
|
330
374
|
identity: ProfileIdentity;
|
|
331
375
|
models: Record<ModelId, ModelBinding>;
|
|
332
376
|
defaultModel: ModelId;
|
|
333
377
|
allowModelSelect?: boolean;
|
|
334
378
|
maxSteps?: number;
|
|
335
|
-
key?: KeySlot;
|
|
336
|
-
/** Retried once when `key` is refused for quota. Off unless set. */
|
|
337
|
-
fallbackKey?: KeySlot;
|
|
338
379
|
outputs?: ProfileOutputsSpec;
|
|
339
380
|
guardrails?: ProfileGuardrailsSpec;
|
|
340
381
|
observability?: ProfileObservabilitySpec;
|
|
341
|
-
/** This profile's wording: replaces any
|
|
342
|
-
|
|
382
|
+
/** This profile's wording: replaces any label default, and any `overrideLabels` entry, for this profile. */
|
|
383
|
+
labels?: LabelOverrides;
|
|
343
384
|
}
|
|
385
|
+
/** Any JSON value; the state a decision reads. */
|
|
344
386
|
export type DecisionJson = null | string | number | boolean | DecisionJson[] | {
|
|
345
387
|
[key: string]: DecisionJson;
|
|
346
388
|
};
|
|
347
|
-
/**
|
|
348
|
-
export interface DecisionModelBinding extends Pick<ModelBinding, 'apiId' | 'key'> {
|
|
349
|
-
protocol: 'decision';
|
|
350
|
-
provider: 'typesafe' | 'openrouter';
|
|
351
|
-
timeoutMs?: number;
|
|
352
|
-
}
|
|
389
|
+
/** What a decision profile accepts: JSON state up to a byte cap. */
|
|
353
390
|
export interface DecisionInputsSpec {
|
|
354
391
|
state: 'json';
|
|
355
392
|
maxStateBytes?: number;
|
|
@@ -367,40 +404,64 @@ export interface DecisionProfile {
|
|
|
367
404
|
identity: Pick<ProfileIdentity, 'handle'>;
|
|
368
405
|
/** Exactly one model: a decision profile runs one model and never selects. */
|
|
369
406
|
models: Record<ModelId, DecisionModelBinding>;
|
|
370
|
-
key?: KeySlot;
|
|
371
407
|
inputs: DecisionInputsSpec;
|
|
372
408
|
decision: {
|
|
373
409
|
contract: DecisionContractId;
|
|
374
410
|
};
|
|
375
411
|
guardrails?: DecisionGuardrailsSpec;
|
|
376
412
|
observability?: ProfileObservabilitySpec;
|
|
377
|
-
/** This profile's wording: replaces any
|
|
378
|
-
|
|
413
|
+
/** This profile's wording: replaces any label default, and any `overrideLabels` entry, for this profile. */
|
|
414
|
+
labels?: LabelOverrides;
|
|
379
415
|
}
|
|
380
416
|
/** Text or nested text instruction entries. Non-text leaves are rejected locally. */
|
|
381
417
|
export type DecisionEntry = string | DecisionEntry[] | {
|
|
382
418
|
[key: string]: DecisionEntry;
|
|
383
419
|
};
|
|
420
|
+
/** A question answered by picking one of the named criteria. */
|
|
384
421
|
export interface DecisionChoiceQuestion {
|
|
385
422
|
type: 'choice';
|
|
386
423
|
instructions: DecisionEntry;
|
|
387
424
|
criteria: Record<string, DecisionEntry>;
|
|
388
425
|
}
|
|
426
|
+
/** A question answered with a single number, optionally with named criteria. */
|
|
389
427
|
export interface DecisionNoulQuestion {
|
|
390
428
|
type: 'noul';
|
|
391
429
|
instructions: DecisionEntry;
|
|
392
430
|
criteria?: Record<string, DecisionEntry>;
|
|
393
431
|
}
|
|
432
|
+
/** A question answered by scoring against an ordered list of criteria. */
|
|
394
433
|
export interface DecisionScoreQuestion {
|
|
395
434
|
type: 'score';
|
|
396
435
|
instructions: DecisionEntry;
|
|
397
436
|
criteria: readonly DecisionEntry[];
|
|
398
437
|
}
|
|
399
|
-
|
|
438
|
+
/** A question answered with the one box that holds what the instructions name, in an image. */
|
|
439
|
+
export interface DecisionBoxQuestion {
|
|
440
|
+
type: 'box';
|
|
441
|
+
instructions: DecisionEntry;
|
|
442
|
+
/**
|
|
443
|
+
* The image the box is in: a reference in `assets`, such as `<ghs02>`, or the state field that
|
|
444
|
+
* holds one, such as `photo.front`. Unset, the model reads the image from the instructions.
|
|
445
|
+
*/
|
|
446
|
+
image?: string;
|
|
447
|
+
}
|
|
448
|
+
/** One question a decision answers. */
|
|
449
|
+
export type DecisionQuestion = DecisionChoiceQuestion | DecisionNoulQuestion | DecisionScoreQuestion | DecisionBoxQuestion;
|
|
450
|
+
/** An image a decision reads: PNG or JPEG bytes as base64, with no `data:` prefix. */
|
|
451
|
+
export interface DecisionAsset {
|
|
452
|
+
mimeType: 'image/png' | 'image/jpeg';
|
|
453
|
+
data: string;
|
|
454
|
+
}
|
|
455
|
+
/** A request to `runDecision`: the profile, the state to judge, and the questions to answer. */
|
|
400
456
|
export interface DecisionRequest {
|
|
401
457
|
profile: ProfileId;
|
|
402
458
|
state: Exclude<DecisionJson, null>;
|
|
403
459
|
questions: Record<string, DecisionQuestion>;
|
|
460
|
+
/**
|
|
461
|
+
* Images by reference. Write a reference as a string where its image belongs, in `state`, in a
|
|
462
|
+
* question's instructions, or in its criteria; the provider puts the image there.
|
|
463
|
+
*/
|
|
464
|
+
assets?: Record<string, DecisionAsset>;
|
|
404
465
|
signal?: AbortSignal;
|
|
405
466
|
/** Host-owned metadata preserved on the decision's trace record; the kernel does not interpret it. */
|
|
406
467
|
metadata?: Record<string, unknown>;
|
|
@@ -411,6 +472,7 @@ export interface DecisionRequest {
|
|
|
411
472
|
*/
|
|
412
473
|
traceparent?: string;
|
|
413
474
|
}
|
|
475
|
+
/** The model's answer to one decision question. */
|
|
414
476
|
export type DecisionAnswer = {
|
|
415
477
|
type: 'choice';
|
|
416
478
|
choice: string;
|
|
@@ -425,17 +487,99 @@ export type DecisionAnswer = {
|
|
|
425
487
|
confidence: number;
|
|
426
488
|
legend: Record<string, string>;
|
|
427
489
|
probabilities: Record<string, number>;
|
|
490
|
+
}
|
|
491
|
+
/** Edges are fractions of the image, from its top-left corner. */
|
|
492
|
+
| {
|
|
493
|
+
type: 'box';
|
|
494
|
+
box: {
|
|
495
|
+
top: number;
|
|
496
|
+
bottom: number;
|
|
497
|
+
left: number;
|
|
498
|
+
right: number;
|
|
499
|
+
};
|
|
500
|
+
confidence: number;
|
|
428
501
|
};
|
|
502
|
+
/** What `runDecision` returns: the model and an answer for each question. */
|
|
429
503
|
export interface DecisionResult {
|
|
430
504
|
model: string;
|
|
431
505
|
answers: Record<string, DecisionAnswer>;
|
|
432
|
-
/** Provider-reported tokens and cost
|
|
506
|
+
/** Provider-reported tokens and cost; a cost worked out from the provider's prices is `estimated`. */
|
|
433
507
|
usage?: {
|
|
434
508
|
inputTokens: number;
|
|
435
509
|
outputTokens: number;
|
|
436
510
|
costUsd?: number;
|
|
511
|
+
estimated?: true;
|
|
437
512
|
};
|
|
438
513
|
}
|
|
514
|
+
/** One provider-neutral input part for an embedding request. */
|
|
515
|
+
export type EmbeddingPart = {
|
|
516
|
+
type: 'text';
|
|
517
|
+
text: string;
|
|
518
|
+
} | {
|
|
519
|
+
type: 'media';
|
|
520
|
+
mimeType: string;
|
|
521
|
+
data: string;
|
|
522
|
+
} | {
|
|
523
|
+
type: 'media-ref';
|
|
524
|
+
mimeType: string;
|
|
525
|
+
uri: string;
|
|
526
|
+
};
|
|
527
|
+
/** One embedding input. Media-only inputs remain valid for native local models. */
|
|
528
|
+
export type EmbeddingInput = string | {
|
|
529
|
+
parts: readonly EmbeddingPart[];
|
|
530
|
+
};
|
|
531
|
+
/** A profile's accepted embedding input kinds and limits. */
|
|
532
|
+
export interface EmbeddingInputsSpec {
|
|
533
|
+
text?: boolean;
|
|
534
|
+
attachments?: {
|
|
535
|
+
accept: string[];
|
|
536
|
+
};
|
|
537
|
+
maxFiles?: number;
|
|
538
|
+
maxBytes?: number;
|
|
539
|
+
maxTurnBytes?: number;
|
|
540
|
+
limitsByMime?: Record<string, number>;
|
|
541
|
+
}
|
|
542
|
+
/** A profile that returns vectors instead of a model turn. */
|
|
543
|
+
export interface EmbeddingProfile extends Omit<ProfileCommon, 'identity' | 'outputs' | 'maxSteps'> {
|
|
544
|
+
type: 'embedding';
|
|
545
|
+
identity: Pick<ProfileIdentity, 'handle'>;
|
|
546
|
+
inputs: EmbeddingInputsSpec;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* What the inputs are for in a search: `query` for what someone asks,
|
|
550
|
+
* `document` for what is searched. A model that embeds the two the same way
|
|
551
|
+
* ignores it.
|
|
552
|
+
*/
|
|
553
|
+
export type EmbeddingTask = 'query' | 'document';
|
|
554
|
+
/** A request to `runEmbedding`. */
|
|
555
|
+
export interface EmbeddingRequest {
|
|
556
|
+
profile: ProfileId;
|
|
557
|
+
model?: ModelId;
|
|
558
|
+
input: EmbeddingInput | readonly EmbeddingInput[];
|
|
559
|
+
task?: EmbeddingTask;
|
|
560
|
+
signal?: AbortSignal;
|
|
561
|
+
metadata?: Record<string, unknown>;
|
|
562
|
+
traceparent?: string;
|
|
563
|
+
}
|
|
564
|
+
/** One vector returned for one ordered embedding input. */
|
|
565
|
+
export interface EmbeddingVector {
|
|
566
|
+
index: number;
|
|
567
|
+
values: readonly number[];
|
|
568
|
+
dimensions: number;
|
|
569
|
+
}
|
|
570
|
+
/** Provider usage for an embedding call. */
|
|
571
|
+
export interface EmbeddingUsage {
|
|
572
|
+
inputTokens?: number;
|
|
573
|
+
costUsd?: number;
|
|
574
|
+
estimated?: true;
|
|
575
|
+
}
|
|
576
|
+
/** The normalized result of `runEmbedding`. */
|
|
577
|
+
export interface EmbeddingResult {
|
|
578
|
+
model: string;
|
|
579
|
+
embeddings: readonly EmbeddingVector[];
|
|
580
|
+
usage?: EmbeddingUsage;
|
|
581
|
+
}
|
|
582
|
+
/** A profile that runs text turns. */
|
|
439
583
|
export interface TextProfile extends ProfileCommon {
|
|
440
584
|
type: 'text';
|
|
441
585
|
tools: ProfileToolsSpec;
|
|
@@ -448,6 +592,7 @@ export interface TextProfile extends ProfileCommon {
|
|
|
448
592
|
* `maxFiles` caps them.
|
|
449
593
|
*/
|
|
450
594
|
export type ImageInputsSpec = Omit<ProfileInputsSpec, 'voice'>;
|
|
595
|
+
/** A profile that generates images. */
|
|
451
596
|
export interface ImageProfile extends ProfileCommon {
|
|
452
597
|
type: 'image';
|
|
453
598
|
image: ProfileImageSpec;
|
|
@@ -456,35 +601,28 @@ export interface ImageProfile extends ProfileCommon {
|
|
|
456
601
|
turnBehaviour?: MediaTurnBehaviourSpec;
|
|
457
602
|
}
|
|
458
603
|
/**
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
* text a canary scan could read.
|
|
604
|
+
* Unary TTS — text-in locked by type; no tools / inputs block. The input text is the transcript;
|
|
605
|
+
* there is no system prompt, so no canary is planted and nothing of the profile's own can leak.
|
|
462
606
|
*/
|
|
463
|
-
export
|
|
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'> {
|
|
607
|
+
export interface SpeechProfile extends Omit<ProfileCommon, 'identity'> {
|
|
468
608
|
type: 'speech';
|
|
469
609
|
identity: Pick<ProfileIdentity, 'handle'>;
|
|
470
|
-
/** Registration always stores `canary: false`. */
|
|
471
|
-
guardrails: SpeechGuardrailsSpec & {
|
|
472
|
-
canary: false;
|
|
473
|
-
};
|
|
474
610
|
speech: ProfileSpeechSpec;
|
|
475
611
|
turnBehaviour?: MediaTurnBehaviourSpec;
|
|
476
612
|
}
|
|
613
|
+
/** A profile that holds a live audio session. */
|
|
477
614
|
export interface LiveProfile extends Omit<ProfileCommon, 'outputs'> {
|
|
478
615
|
type: 'live';
|
|
479
616
|
live: ProfileLiveSpec;
|
|
617
|
+
inputs?: LiveInputsSpec;
|
|
480
618
|
tools: LiveProfileToolsSpec;
|
|
481
619
|
/** Stage inject gate only; live resumption is `live.sessionResumption`. */
|
|
482
620
|
turnBehaviour?: Pick<ProfileTurnBehaviourSpec, 'allowSteering'>;
|
|
483
621
|
}
|
|
484
622
|
/**
|
|
485
623
|
* 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
|
|
624
|
+
* `tools.allow` with no visibility, loading tiers, or path gating. `guardrails` holds only
|
|
625
|
+
* the guards that fire on `invokeTool`: quota, canary, and egress guard a model turn, so
|
|
488
626
|
* `defineProfile` refuses them rather than accept inert config.
|
|
489
627
|
*/
|
|
490
628
|
export interface HostProfile {
|
|
@@ -493,12 +631,14 @@ export interface HostProfile {
|
|
|
493
631
|
tools: HostProfileToolsSpec;
|
|
494
632
|
guardrails?: HostGuardrailsSpec;
|
|
495
633
|
observability?: ProfileObservabilitySpec;
|
|
496
|
-
/** This profile's wording: replaces any
|
|
497
|
-
|
|
634
|
+
/** This profile's wording: replaces any label default, and any `overrideLabels` entry, for this profile. */
|
|
635
|
+
labels?: LabelOverrides;
|
|
498
636
|
}
|
|
499
|
-
|
|
637
|
+
/** The contract that defines an agent’s capabilities and the rules for its interactions. Its type determines which settings it accepts. */
|
|
638
|
+
export type Profile = TextProfile | ImageProfile | SpeechProfile | LiveProfile | DecisionProfile | EmbeddingProfile | HostProfile;
|
|
500
639
|
/** Profiles that run a model turn — every type except `host` and `decision` (which runs through `runDecision`). */
|
|
501
|
-
export type ModelProfile = Exclude<Profile, HostProfile | DecisionProfile>;
|
|
640
|
+
export type ModelProfile = Exclude<Profile, HostProfile | DecisionProfile | EmbeddingProfile>;
|
|
641
|
+
/** The image a profile asks the model to return. */
|
|
502
642
|
export interface ImageResponseFormat {
|
|
503
643
|
type: 'image';
|
|
504
644
|
mimeType?: string;
|
|
@@ -512,6 +652,7 @@ export interface ImageResponseFormat {
|
|
|
512
652
|
outputCompression?: number;
|
|
513
653
|
includeText: boolean;
|
|
514
654
|
}
|
|
655
|
+
/** A file sent inline with a turn. */
|
|
515
656
|
export interface TurnBlob {
|
|
516
657
|
mimeType: string;
|
|
517
658
|
data: string;
|
|
@@ -528,15 +669,19 @@ export interface TurnMediaRef {
|
|
|
528
669
|
/** The file's name, used only to tell the user which file was refused; never sent to the model. */
|
|
529
670
|
name?: string;
|
|
530
671
|
}
|
|
672
|
+
/** A rejected output and the guidance to retry it with. */
|
|
531
673
|
export interface TurnRepairRequest {
|
|
532
674
|
previousOutput: string;
|
|
533
675
|
rejection: string;
|
|
534
676
|
guidance?: string;
|
|
535
677
|
}
|
|
678
|
+
/** What the user sent for a turn: text, slots, attachments, voice, and history. */
|
|
536
679
|
export interface TurnInput {
|
|
537
680
|
text?: string;
|
|
538
681
|
role?: string;
|
|
539
682
|
slots?: Record<string, string>;
|
|
683
|
+
/** What the page or the host wants the model to know, by sender; the profile's `inputs.context` allows it. */
|
|
684
|
+
context?: TurnContext;
|
|
540
685
|
attachments?: Array<TurnBlob | TurnMediaRef>;
|
|
541
686
|
voice?: TurnBlob[];
|
|
542
687
|
history?: TurnHistoryMessage[];
|
|
@@ -552,8 +697,8 @@ export interface TurnInput {
|
|
|
552
697
|
* Ignored when `meter` is `'history'`.
|
|
553
698
|
*/
|
|
554
699
|
inputTokens?: number;
|
|
555
|
-
sessionResumptionHandle?: string;
|
|
556
700
|
}
|
|
701
|
+
/** A turn request whose `input` is always present. */
|
|
557
702
|
export type NormalizedTurnRequest = TurnRequest & {
|
|
558
703
|
input: TurnInput;
|
|
559
704
|
};
|
|
@@ -569,7 +714,11 @@ export interface TurnTraceLink {
|
|
|
569
714
|
/** How the earlier turn stopped, when the host knows. */
|
|
570
715
|
stop?: TurnStopKind;
|
|
571
716
|
}
|
|
717
|
+
/** A request to `runTurn`: the profile, the input, and the host's hooks and keys. */
|
|
572
718
|
export interface TurnRequest {
|
|
719
|
+
execution?: ToolExecutionCoordinator;
|
|
720
|
+
pageExecution?: PageToolExecution;
|
|
721
|
+
providerState?: ProviderCheckpoint;
|
|
573
722
|
profile: ProfileId;
|
|
574
723
|
projectId?: string;
|
|
575
724
|
/**
|
|
@@ -577,25 +726,19 @@ export interface TurnRequest {
|
|
|
577
726
|
* Not the same as `projectId` or Gemini `previousInteractionId`.
|
|
578
727
|
*/
|
|
579
728
|
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
729
|
/** Selected model id when `profile.allowModelSelect` is true. */
|
|
594
730
|
model?: ModelId;
|
|
595
731
|
/** Selected effort alias when the binding has `allowEffortSelect`. */
|
|
596
732
|
effort?: string;
|
|
733
|
+
/**
|
|
734
|
+
* Args for built-in tools on the chosen model's `builtInTools`, by tool id.
|
|
735
|
+
* Each is parsed by the schema the provider's adapter declares for that tool.
|
|
736
|
+
*/
|
|
737
|
+
builtInArgs?: BuiltInArgs;
|
|
597
738
|
/** Host-provided dynamic system prompt combined with profile persona */
|
|
598
739
|
system?: SystemPrompt;
|
|
740
|
+
/** This turn's voice, style, and speed, over `profile.speech`. Speech profiles only. */
|
|
741
|
+
speech?: TurnSpeech;
|
|
599
742
|
sessionPermissions?: string[];
|
|
600
743
|
/** Host channel/path for catalog `paths` filtering. */
|
|
601
744
|
path?: string;
|
|
@@ -634,9 +777,6 @@ export interface TurnRequest {
|
|
|
634
777
|
*/
|
|
635
778
|
continuation?: number;
|
|
636
779
|
input?: TurnInput;
|
|
637
|
-
/** Runs a `timing: 'before'` compactor the turn's provider cannot. */
|
|
638
|
-
compactionProvider?: ModelProvider;
|
|
639
|
-
sessionResumptionHandle?: string;
|
|
640
780
|
/** Credentials for authenticated HTTP / MCP tools, read by auth slot when a tool needs one. */
|
|
641
781
|
credentials?: ToolCredentialSource;
|
|
642
782
|
/**
|
|
@@ -646,7 +786,14 @@ export interface TurnRequest {
|
|
|
646
786
|
resolveHost?: ResolveHost;
|
|
647
787
|
/** Text `runTurn` emits stages and applies the returned affordances. */
|
|
648
788
|
onStage?: StageHandler;
|
|
789
|
+
/**
|
|
790
|
+
* Runs before each agent tool call in this turn, and in the turns those
|
|
791
|
+
* calls run. Shape the called agent's request (history, model, provider) or
|
|
792
|
+
* refuse the call. Omit it: the agent runs on what the model sent.
|
|
793
|
+
*/
|
|
794
|
+
onAgentCall?: AgentCallHook;
|
|
649
795
|
}
|
|
796
|
+
/** A profile projected for a client, with its secrets and server-only fields removed. */
|
|
650
797
|
export interface ProjectedProfile extends ProfileModelFields {
|
|
651
798
|
id: string;
|
|
652
799
|
type: ModelProfile['type'];
|
|
@@ -661,11 +808,10 @@ export interface ProjectedProfile extends ProfileModelFields {
|
|
|
661
808
|
speech?: ProfileSpeechSpec | null;
|
|
662
809
|
live?: ProfileLiveSpec | null;
|
|
663
810
|
}
|
|
811
|
+
/** The generation settings a provider call is made with. */
|
|
664
812
|
export interface ProviderGenerationConfig {
|
|
665
813
|
model: ModelId;
|
|
666
814
|
apiId: string;
|
|
667
|
-
previousInteractionId?: string;
|
|
668
|
-
store?: boolean;
|
|
669
815
|
/**
|
|
670
816
|
* Upstream stream vs batch, derived from `outputs.streaming.mode`.
|
|
671
817
|
* `true` = SSE (THEOREM default when mode is omitted); `false` = buffered.
|
|
@@ -676,35 +822,22 @@ export interface ProviderGenerationConfig {
|
|
|
676
822
|
maxOutputTokens?: number;
|
|
677
823
|
temperature?: number;
|
|
678
824
|
builtins: BuiltinToolId[];
|
|
679
|
-
googleMapsLocation?: {
|
|
680
|
-
latitude: number;
|
|
681
|
-
longitude: number;
|
|
682
|
-
};
|
|
683
|
-
/** OpenRouter only. */
|
|
684
|
-
cache?: CacheSpec;
|
|
685
825
|
/** Forwarded as OpenRouter `session_id`. */
|
|
686
826
|
sessionId?: string;
|
|
687
827
|
}
|
|
688
|
-
|
|
828
|
+
/** The transport a provider adapter speaks. */
|
|
829
|
+
export type ProviderTransport = 'turn' | 'live';
|
|
830
|
+
/** A generation config after the profile and request are resolved, with its transport. */
|
|
689
831
|
export interface ResolvedGeneration extends ProviderGenerationConfig {
|
|
832
|
+
/** The request's `builtInArgs`, parsed. */
|
|
833
|
+
builtInArgs?: BuiltInArgs;
|
|
834
|
+
execution?: ToolExecutionCoordinator;
|
|
835
|
+
pageExecution?: PageToolExecution;
|
|
690
836
|
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
837
|
tools: TurnToolSnapshot;
|
|
699
838
|
sessionPermissions?: string[];
|
|
700
839
|
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. */
|
|
840
|
+
/** Tool-loop ceiling: the profile's `maxSteps`, or `DEFAULT_MAX_STEPS`. */
|
|
708
841
|
maxSteps?: number;
|
|
709
842
|
structured: ResolvedStructured | null;
|
|
710
843
|
image: ImageResponseFormat | null;
|
|
@@ -712,64 +845,62 @@ export interface ResolvedGeneration extends ProviderGenerationConfig {
|
|
|
712
845
|
live?: ProfileLiveSpec;
|
|
713
846
|
input: InteractionPart[];
|
|
714
847
|
/**
|
|
715
|
-
*
|
|
848
|
+
* The canary bound into the system prompt; empty with the canary off. A turn
|
|
849
|
+
* binds the profile's (`profileCanary`), the same for the same prompt; a
|
|
850
|
+
* Live session binds this one, minted for it.
|
|
716
851
|
*/
|
|
717
|
-
keySlot?: KeySlot;
|
|
718
|
-
/** The slot a quota refusal on `keySlot` retries on once, when the profile names one. */
|
|
719
|
-
fallbackKeySlot?: KeySlot;
|
|
720
852
|
canary: string;
|
|
721
|
-
sessionResumptionHandle?: string;
|
|
722
853
|
/** Snapshotted synchronously before any async work; the runner binds the canary on top. */
|
|
723
854
|
resolvedSystem: readonly SystemPiece[];
|
|
724
855
|
/** `TurnRequest.host`, carried to tool contexts only. Never sent to providers or traces. */
|
|
725
856
|
host?: unknown;
|
|
726
857
|
}
|
|
727
|
-
/**
|
|
728
|
-
|
|
729
|
-
|
|
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. */
|
|
858
|
+
/** One model call as the engine asks it: the resolved generation, the conversation, and the tools. */
|
|
859
|
+
export interface ModelRequest extends Omit<ProviderGenerationConfig, 'summaries' | 'builtins'> {
|
|
860
|
+
/** The turn's builtins with the args addressed to each. */
|
|
734
861
|
builtins: ProviderBuiltin[];
|
|
735
862
|
summaries?: SummaryMode;
|
|
863
|
+
providerState?: ProviderCheckpoint;
|
|
736
864
|
system: string;
|
|
737
865
|
input: InteractionPart[];
|
|
738
866
|
history?: TurnHistoryMessage[];
|
|
739
|
-
/** Sent after `previousInteractionId` instead of history + user parts; mapped like history. */
|
|
740
|
-
continuation?: TurnHistoryMessage[];
|
|
741
867
|
wireTools?: WireFunctionTool[];
|
|
742
868
|
structured: ResolvedStructured | null;
|
|
743
869
|
image: ImageResponseFormat | null;
|
|
744
870
|
speech?: ProfileSpeechSpec;
|
|
745
871
|
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
872
|
/** Scrubbed SSE / HTTP rows for traces. */
|
|
751
873
|
tapUpstream?: (row: Record<string, unknown>) => void;
|
|
752
|
-
/** Host abort signal
|
|
874
|
+
/** Host abort signal. */
|
|
753
875
|
signal?: AbortSignal;
|
|
754
876
|
}
|
|
755
|
-
|
|
756
|
-
|
|
877
|
+
/** One model call, streamed as the model's events. */
|
|
878
|
+
export interface TurnModel {
|
|
879
|
+
complete: (req: ModelRequest) => AsyncIterable<ModelEvent>;
|
|
757
880
|
}
|
|
758
881
|
/**
|
|
759
882
|
* Host request to open a long-lived live session (`runSession`).
|
|
760
883
|
* Profile must be `type: 'live'`.
|
|
761
884
|
*/
|
|
762
885
|
export interface SessionRequest {
|
|
886
|
+
providerState?: ProviderCheckpoint;
|
|
763
887
|
profile: ProfileId;
|
|
764
888
|
/** Host-built system prompt merged with profile identity.system. */
|
|
765
889
|
system?: SystemPrompt;
|
|
766
890
|
/** Override `profile.live.voice` for this session. */
|
|
767
891
|
voice?: string;
|
|
892
|
+
/** As `TurnRequest.builtInArgs`. */
|
|
893
|
+
builtInArgs?: BuiltInArgs;
|
|
768
894
|
path?: string;
|
|
769
895
|
sessionPermissions?: string[];
|
|
770
896
|
history?: TurnHistoryMessage[];
|
|
771
|
-
|
|
772
|
-
|
|
897
|
+
/** The value chosen for each of the profile's `inputs.slots`. */
|
|
898
|
+
slots?: Record<string, string>;
|
|
899
|
+
/** What the page and the host tell the agent as the call opens; `sendContext` replaces it later. */
|
|
900
|
+
context?: TurnContext;
|
|
901
|
+
/** How long the caller was away before this resume, in milliseconds. The session keeps no clock across calls. */
|
|
902
|
+
awayMs?: number;
|
|
903
|
+
/** Optional realtime parts sent immediately after setup. A call that sends them gets no `live.greeting`. */
|
|
773
904
|
input?: InteractionPart[];
|
|
774
905
|
/**
|
|
775
906
|
* Registry-resolved tool snapshot from the process that owns the tool registry
|
|
@@ -793,6 +924,12 @@ export interface SessionRequest {
|
|
|
793
924
|
links?: TurnTraceLink[];
|
|
794
925
|
/** Immutable for the session; there is no `setOnStage`. */
|
|
795
926
|
onStage?: StageHandler;
|
|
927
|
+
/**
|
|
928
|
+
* As `TurnRequest.onAgentCall`, for the agent tools this session's calls run.
|
|
929
|
+
* Omit it: each agent runs on what the model sent, with the session's own
|
|
930
|
+
* provider options.
|
|
931
|
+
*/
|
|
932
|
+
onAgentCall?: AgentCallHook;
|
|
796
933
|
/**
|
|
797
934
|
* Default credentials for `executeTool` (per-call args override). Without one, the
|
|
798
935
|
* session keeps keys typed at its sign-in gates in memory.
|
|
@@ -813,6 +950,7 @@ export interface SessionRequest {
|
|
|
813
950
|
*/
|
|
814
951
|
export type LiveExecuteToolArgs = {
|
|
815
952
|
callId: string;
|
|
953
|
+
operationId?: string;
|
|
816
954
|
decision?: GateDecision;
|
|
817
955
|
input?: unknown;
|
|
818
956
|
/**
|
|
@@ -823,6 +961,8 @@ export type LiveExecuteToolArgs = {
|
|
|
823
961
|
secret?: string;
|
|
824
962
|
credentials?: ToolCredentialSource;
|
|
825
963
|
host?: unknown;
|
|
964
|
+
/** The page's answer, for a call to a tool with `answeredBy: 'page'`. */
|
|
965
|
+
page?: PageAnswer;
|
|
826
966
|
};
|
|
827
967
|
/**
|
|
828
968
|
* Settle a call the model made in this session whose body ran in the process
|
|
@@ -833,6 +973,7 @@ export type LiveAnswerToolCallArgs = {
|
|
|
833
973
|
callId: string;
|
|
834
974
|
events: readonly TurnEvent[];
|
|
835
975
|
};
|
|
976
|
+
/** What running a tool call during a live session returns. */
|
|
836
977
|
export type LiveExecuteToolResult = {
|
|
837
978
|
outputRaw?: unknown;
|
|
838
979
|
outputModel?: ModelToolResult;
|
|
@@ -841,7 +982,7 @@ export type LiveExecuteToolResult = {
|
|
|
841
982
|
gated?: ToolGate;
|
|
842
983
|
};
|
|
843
984
|
/**
|
|
844
|
-
* Open
|
|
985
|
+
* Open live session returned by `runSession`. It streams events until
|
|
845
986
|
* `close()` and exposes realtime media ingress and staged tool execution.
|
|
846
987
|
*/
|
|
847
988
|
export interface LiveSession {
|
|
@@ -860,11 +1001,11 @@ export interface LiveSession {
|
|
|
860
1001
|
}): Promise<void>;
|
|
861
1002
|
sendText(text: string): Promise<void>;
|
|
862
1003
|
/**
|
|
863
|
-
*
|
|
864
|
-
*
|
|
865
|
-
*
|
|
1004
|
+
* What the page or the host tells the model to know, by sender: it opens no turn and
|
|
1005
|
+
* draws no reply. Checked against `inputs.context` and read at the `context` boundary;
|
|
1006
|
+
* the model sees it from its next turn on.
|
|
866
1007
|
*/
|
|
867
|
-
sendContext(
|
|
1008
|
+
sendContext(context: TurnContext): Promise<void>;
|
|
868
1009
|
/**
|
|
869
1010
|
* Run a call the model made through the registry, with stages; its events
|
|
870
1011
|
* join `events()`. A gate returns `gated` and answers the model nothing yet;
|