@theoremjs/agents 0.3.0 → 0.3.2
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 +277 -995
- package/esm/mod.d.ts +34 -20
- package/esm/mod.js +19 -12
- 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 +25 -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 +881 -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 +30 -22
- package/esm/src/guardrails/mod.js +19 -14
- 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 +4 -1
- package/esm/src/guardrails/quota.js +7 -2
- 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 +5 -2
- package/esm/src/guardrails/theorem-error.js +6 -3
- 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 +8 -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 +174 -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 +329 -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 +130 -88
- 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 +102 -0
- package/esm/src/providers/gemini/live-protocol.d.ts +3 -0
- package/esm/src/providers/gemini/live-protocol.js +191 -0
- package/esm/src/providers/gemini/prices.d.ts +3 -0
- package/esm/src/providers/gemini/prices.js +63 -0
- package/esm/src/providers/gemini/provider.d.ts +7 -0
- package/esm/src/providers/gemini/provider.js +39 -0
- package/esm/src/providers/google/api-error.d.ts +2 -0
- package/esm/src/providers/google/api-error.js +26 -18
- 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 +4 -210
- 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 +18 -0
- package/esm/src/providers/shared/retry.js +89 -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,7 +1,7 @@
|
|
|
1
1
|
import type { GuardrailEvent, GuardrailStage, TrustLevel } from '../../guardrails/types.js';
|
|
2
2
|
import { type SpanHandle, type SpanLinkInput, type SpanOptions, type TraceAttributes, type TraceAttributeValue } from '../../observability/trace-span.js';
|
|
3
3
|
import type { ToolFailure } from '../tools/types.js';
|
|
4
|
-
import type { InteractionPart, ModelBinding,
|
|
4
|
+
import type { InteractionPart, ModelBinding, ModelEvent, ModelRequest, ProviderTransport, TurnEvent, TurnRequest, TurnStop, TurnTokens, TurnTraceLink } from '../types.js';
|
|
5
5
|
import type { CallUsage } from './runner/usage.js';
|
|
6
6
|
type TracePart = {
|
|
7
7
|
[key: string]: TraceAttributeValue;
|
|
@@ -13,7 +13,7 @@ declare class OutputFold {
|
|
|
13
13
|
private open?;
|
|
14
14
|
/** Each call's `tool_call` part by `callId`, for the failure that follows a malformed one. */
|
|
15
15
|
private readonly calls;
|
|
16
|
-
add(event:
|
|
16
|
+
add(event: ModelEvent, nowUnixNano: string): void;
|
|
17
17
|
private appendText;
|
|
18
18
|
/**
|
|
19
19
|
* The model's call as a `tool_call` part. A malformed call's failure follows
|
|
@@ -43,13 +43,14 @@ declare function guardrailAttributes(guardrail: GuardrailEvent): TraceAttributes
|
|
|
43
43
|
* each tool boundary, the checks that run on streamed output, and a live
|
|
44
44
|
* session's own gates.
|
|
45
45
|
*/
|
|
46
|
-
type GuardrailCheck = 'input' | 'egress' | 'tool_arguments' | 'taint' | 'tool_result' | 'tool_failure' | 'network' | 'network_request' | StreamCheck | 'live_input';
|
|
46
|
+
type GuardrailCheck = 'input' | 'egress' | 'tool_arguments' | 'taint' | 'destination' | 'tool_result' | 'tool_failure' | 'network' | 'network_request' | StreamCheck | 'live_input';
|
|
47
47
|
/**
|
|
48
48
|
* A check that runs many times on one model call's streamed output: the
|
|
49
49
|
* progressive gate on each piece of reply text, the canary scan of every other
|
|
50
|
-
* streamed event,
|
|
50
|
+
* streamed event, the gate on each piece of a tool call the model is drafting,
|
|
51
|
+
* and a live session's gate on each batch it sends.
|
|
51
52
|
*/
|
|
52
|
-
type StreamCheck = 'output_stream' | 'stream_canary' | 'live_output';
|
|
53
|
+
type StreamCheck = 'output_stream' | 'stream_canary' | 'tool_draft' | 'live_output';
|
|
53
54
|
/**
|
|
54
55
|
* One timed guardrail check as `theorem.guardrail` attributes: its decision,
|
|
55
56
|
* or a pass (`allow`, no hits) when it let the text through. Trace only; the
|
|
@@ -77,7 +78,7 @@ interface CallTrace {
|
|
|
77
78
|
/** Pass as the adapter's `tapUpstream`. */
|
|
78
79
|
tap: (row: Record<string, unknown>) => void;
|
|
79
80
|
/** Every provider event, before guardrails. */
|
|
80
|
-
observe: (event:
|
|
81
|
+
observe: (event: ModelEvent) => void;
|
|
81
82
|
/** A stream check's decision; it carries the time that check has spent on the call so far. */
|
|
82
83
|
guardrail: (event: GuardrailEvent) => void;
|
|
83
84
|
/** Add one run of a stream check to this call. */
|
|
@@ -89,7 +90,7 @@ interface CallTrace {
|
|
|
89
90
|
* `usage.conversation` is read again at the end, since a Live response sets it only when it closes.
|
|
90
91
|
*/
|
|
91
92
|
declare function startCallTrace(open: (name: string, options: SpanOptions) => SpanHandle, args: {
|
|
92
|
-
req:
|
|
93
|
+
req: ModelRequest;
|
|
93
94
|
usage: CallUsage;
|
|
94
95
|
binding: ModelBinding | undefined;
|
|
95
96
|
transport: ProviderTransport;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { errorKind } from '../../guardrails/error.js';
|
|
2
2
|
import { traceBytes, traceContent, traceJson, } from '../../observability/trace-span.js';
|
|
3
3
|
import { historyMessageParts } from '../interaction-parts.js';
|
|
4
|
+
import { isFailedStopKind } from '../stop.js';
|
|
4
5
|
import { findLast } from '../util/find-last.js';
|
|
5
6
|
import { asRecord } from './record.js';
|
|
6
7
|
import { sumEventTokens } from './usage.js';
|
|
@@ -33,7 +34,6 @@ function tracePart(part) {
|
|
|
33
34
|
function traceMessage(msg) {
|
|
34
35
|
const media = historyMessageParts(msg).map(tracePart);
|
|
35
36
|
if (msg.role === 'tool') {
|
|
36
|
-
// The tool's text is its response; media it returned follows as parts.
|
|
37
37
|
const response = {
|
|
38
38
|
type: 'tool_call_response',
|
|
39
39
|
...(msg.tool_call_id ? { id: msg.tool_call_id } : {}),
|
|
@@ -93,7 +93,7 @@ class OutputFold {
|
|
|
93
93
|
return;
|
|
94
94
|
case 'evidence': {
|
|
95
95
|
const { evidence } = event;
|
|
96
|
-
// Live transcription: labelled, never taken for the model's own text.
|
|
96
|
+
// why: Live transcription: labelled, never taken for the model's own text.
|
|
97
97
|
if (evidence.kind === 'input_transcription' || evidence.kind === 'output_transcription') {
|
|
98
98
|
this.appendText('text', event.text ?? '', evidence.kind, evidence.interim);
|
|
99
99
|
return;
|
|
@@ -103,6 +103,10 @@ class OutputFold {
|
|
|
103
103
|
this.push(part);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
+
case 'tool_draft':
|
|
107
|
+
case 'structured_draft':
|
|
108
|
+
// why: A preview of the call or reply that follows; that one is recorded whole.
|
|
109
|
+
return;
|
|
106
110
|
default:
|
|
107
111
|
return;
|
|
108
112
|
}
|
|
@@ -287,6 +291,7 @@ function guardrailAttributes(guardrail) {
|
|
|
287
291
|
const STREAM_CHECK_STAGE = {
|
|
288
292
|
output_stream: 'output_delta',
|
|
289
293
|
stream_canary: 'output_delta',
|
|
294
|
+
tool_draft: 'tool_call',
|
|
290
295
|
live_output: 'live_outbound',
|
|
291
296
|
};
|
|
292
297
|
/**
|
|
@@ -342,22 +347,17 @@ function usageAttributes(tokens) {
|
|
|
342
347
|
};
|
|
343
348
|
}
|
|
344
349
|
function operationName(transport) {
|
|
345
|
-
return transport === '
|
|
350
|
+
return transport === 'turn' ? 'chat' : 'generate_content';
|
|
346
351
|
}
|
|
347
|
-
/** `gen_ai.provider.name`:
|
|
352
|
+
/** `gen_ai.provider.name`: the name the provider's preset states; else the binding's server, when declared. */
|
|
348
353
|
function providerName(binding) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
case 'openrouter':
|
|
353
|
-
return 'openrouter';
|
|
354
|
-
default:
|
|
355
|
-
return binding?.server;
|
|
356
|
-
}
|
|
354
|
+
if (!binding)
|
|
355
|
+
return undefined;
|
|
356
|
+
return binding.provider;
|
|
357
357
|
}
|
|
358
358
|
function outputType(req, transport) {
|
|
359
|
-
// Live answers in audio: its setup asks for `responseModalities: ['AUDIO']` (live/framing.ts).
|
|
360
|
-
if (transport === '
|
|
359
|
+
// why: Live answers in audio: its setup asks for `responseModalities: ['AUDIO']` (live/framing.ts).
|
|
360
|
+
if (transport === 'live')
|
|
361
361
|
return 'speech';
|
|
362
362
|
if (req.structured)
|
|
363
363
|
return 'json';
|
|
@@ -374,35 +374,30 @@ function requestAttributes(req, binding, transport) {
|
|
|
374
374
|
...optional('gen_ai.provider.name', provider),
|
|
375
375
|
'gen_ai.request.model': req.apiId,
|
|
376
376
|
'theorem.model.id': req.model,
|
|
377
|
+
...optional('theorem.key_slot', binding?.keySlot),
|
|
377
378
|
...optional('gen_ai.request.temperature', req.temperature),
|
|
378
379
|
...optional('gen_ai.request.max_tokens', req.maxOutputTokens),
|
|
379
380
|
...optional('gen_ai.request.reasoning.level', req.thinking),
|
|
380
|
-
...optional('gen_ai.request.previous_response.id', req.previousInteractionId),
|
|
381
381
|
'gen_ai.system_instructions': [{ type: 'text', ...traceContent(req.system) }],
|
|
382
382
|
...(req.wireTools?.length
|
|
383
383
|
? { 'gen_ai.tool.definitions': traceContent(JSON.stringify(req.wireTools)) }
|
|
384
384
|
: {}),
|
|
385
385
|
'gen_ai.output.type': outputType(req, transport),
|
|
386
|
-
...optional('theorem.key_slot', req.keySlot),
|
|
387
386
|
...controlAttributes(req),
|
|
388
387
|
};
|
|
389
388
|
}
|
|
390
389
|
/**
|
|
391
|
-
* Request controls semconv has no names for, as requested.
|
|
392
|
-
*
|
|
393
|
-
* the user.
|
|
390
|
+
* Request controls semconv has no names for, as requested. Builtins are named
|
|
391
|
+
* by id only; their args are left to the wire body (`outboundWire`): the Maps
|
|
392
|
+
* location locates the user.
|
|
394
393
|
*/
|
|
395
394
|
function controlAttributes(req) {
|
|
396
|
-
const {
|
|
395
|
+
const { image, speech, live } = req;
|
|
397
396
|
return {
|
|
398
397
|
'theorem.request.builtins': req.builtins.map((b) => b.id),
|
|
399
|
-
...optional('theorem.request.store', req.store),
|
|
400
398
|
...optional('theorem.request.summaries', req.summaries),
|
|
401
399
|
...optional('theorem.request.structured', req.structured?.id),
|
|
402
400
|
...optional('theorem.request.session_id', req.sessionId),
|
|
403
|
-
...(cache
|
|
404
|
-
? { 'theorem.request.cache': { mode: cache.mode, ...optional('ttl', cache.ttl) } }
|
|
405
|
-
: {}),
|
|
406
401
|
...(image
|
|
407
402
|
? {
|
|
408
403
|
'theorem.request.image': {
|
|
@@ -422,6 +417,7 @@ function controlAttributes(req) {
|
|
|
422
417
|
? {
|
|
423
418
|
'theorem.request.speech': {
|
|
424
419
|
...optional('voice', speech.voice),
|
|
420
|
+
...optional('speed', speech.speed),
|
|
425
421
|
...optional('format', speech.format),
|
|
426
422
|
},
|
|
427
423
|
}
|
|
@@ -463,7 +459,7 @@ function liveAttributes(live, req) {
|
|
|
463
459
|
},
|
|
464
460
|
}
|
|
465
461
|
: {}),
|
|
466
|
-
resumed: Boolean(req.
|
|
462
|
+
resumed: Boolean(req.providerState),
|
|
467
463
|
};
|
|
468
464
|
}
|
|
469
465
|
function headerAttributes(prefix, headers) {
|
|
@@ -475,7 +471,7 @@ function urlAttributes(url) {
|
|
|
475
471
|
if (typeof url !== 'string')
|
|
476
472
|
return {};
|
|
477
473
|
const parsed = URL.canParse(url) ? new URL(url) : undefined;
|
|
478
|
-
// The path only: a query can carry credentials.
|
|
474
|
+
// why: The path only: a query can carry credentials.
|
|
479
475
|
return parsed ? { 'server.address': parsed.hostname, 'url.path': parsed.pathname } : {};
|
|
480
476
|
}
|
|
481
477
|
/** POST spans of one call, opened and closed from the adapter's tap rows. */
|
|
@@ -523,7 +519,7 @@ class HttpTries {
|
|
|
523
519
|
},
|
|
524
520
|
});
|
|
525
521
|
this.tries += 1;
|
|
526
|
-
// The body sent decides, not the profile: an adapter may stream or buffer regardless.
|
|
522
|
+
// why: The body sent decides, not the profile: an adapter may stream or buffer regardless.
|
|
527
523
|
this.streamed = asRecord(row.body)?.stream === true;
|
|
528
524
|
if (this.streamed)
|
|
529
525
|
this.call.set({ 'gen_ai.request.stream': true });
|
|
@@ -547,7 +543,7 @@ class HttpTries {
|
|
|
547
543
|
this.current?.set({ 'error.type': String(status) });
|
|
548
544
|
}
|
|
549
545
|
else {
|
|
550
|
-
// Streamed or buffered, the first data row is the reply's first chunk: a buffered body is its one chunk.
|
|
546
|
+
// why: Streamed or buffered, the first data row is the reply's first chunk: a buffered body is its one chunk.
|
|
551
547
|
this.awaitingFirstChunk = true;
|
|
552
548
|
}
|
|
553
549
|
}
|
|
@@ -653,7 +649,7 @@ function callOutcome(stop, failure) {
|
|
|
653
649
|
function responseAttributes(response, native, transport) {
|
|
654
650
|
const reported = !native
|
|
655
651
|
? {}
|
|
656
|
-
: transport === '
|
|
652
|
+
: transport === 'turn'
|
|
657
653
|
? { 'gen_ai.response.finish_reasons': [native] }
|
|
658
654
|
: { 'gen_ai.response.status': native };
|
|
659
655
|
return {
|
|
@@ -697,7 +693,6 @@ function startCallTrace(open, args) {
|
|
|
697
693
|
},
|
|
698
694
|
observe: (event) => {
|
|
699
695
|
if (event.type === 'evidence' && event.evidence.kind === 'input_transcription') {
|
|
700
|
-
// What the provider heard in the input: labelled, beside what the model read.
|
|
701
696
|
heard.add(event, span.nowUnixNano());
|
|
702
697
|
return;
|
|
703
698
|
}
|
|
@@ -757,7 +752,7 @@ function startCallTrace(open, args) {
|
|
|
757
752
|
...optional('finish_reason', outcome.finish),
|
|
758
753
|
};
|
|
759
754
|
const { input } = inputMessages(usage);
|
|
760
|
-
// A continuation replays what the model read, not the provider's transcript of it.
|
|
755
|
+
// why: A continuation replays what the model read, not the provider's transcript of it.
|
|
761
756
|
callMessages.set(usage, { input, output: outputMessage });
|
|
762
757
|
const transcript = heard.parts.length > 0 ? [{ role: 'user', parts: heard.parts }] : [];
|
|
763
758
|
http.close(httpStatus(http.lastStatus, outcome.stopped, end.thrown));
|
|
@@ -816,8 +811,6 @@ function turnSpanOptions(req) {
|
|
|
816
811
|
links: traceLinks(req.links),
|
|
817
812
|
};
|
|
818
813
|
}
|
|
819
|
-
/** Stops where the turn failed; the rest either finished or were stopped on purpose. */
|
|
820
|
-
const FAILED_STOPS = new Set(['provider_error', 'stream_incomplete']);
|
|
821
814
|
const FINISHED_STOPS = new Set(['completed', 'length', 'generation_complete']);
|
|
822
815
|
/**
|
|
823
816
|
* Close a turn's `invoke_agent` span. Usage is the sum of this turn's own
|
|
@@ -832,10 +825,9 @@ function endTurnSpan(root, end) {
|
|
|
832
825
|
const threw = end.thrown !== undefined;
|
|
833
826
|
if (threw)
|
|
834
827
|
recordException(root, end.thrown);
|
|
835
|
-
const failed = threw || (stop !== undefined &&
|
|
836
|
-
// The builder's name for the failure: the thrown value's kind, else the error event's, else the stop.
|
|
828
|
+
const failed = threw || (stop !== undefined && isFailedStopKind(stop));
|
|
837
829
|
const failure = threw ? errorKind(end.thrown) : (errorEvent?.errorKind ?? stop);
|
|
838
|
-
// What the host received, beside each call's `output.messages` (what the model produced).
|
|
830
|
+
// why: What the host received, beside each call's `output.messages` (what the model produced).
|
|
839
831
|
const delivered = {
|
|
840
832
|
role: 'assistant',
|
|
841
833
|
parts: end.delivered.parts,
|
|
@@ -23,6 +23,12 @@ export declare function usageCount(value: unknown): number | undefined;
|
|
|
23
23
|
export declare function reportedTokens(usage: ReportedUsage): TurnTokens | undefined;
|
|
24
24
|
/** A turn's usage: the sum of its `tokens` events. `done.tokens` and the turn's span both read it. */
|
|
25
25
|
export declare function sumEventTokens(events: readonly TurnEvent[]): TurnTokens | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* A turn's usage with its agent tool calls': its own `tokens` events plus each
|
|
28
|
+
* call's `tokens` on the tool's `complete` or `error`. `done.tokens` reads it;
|
|
29
|
+
* the turn's span keeps `sumEventTokens`, since each call has its own span.
|
|
30
|
+
*/
|
|
31
|
+
export declare function sumTurnTokens(events: readonly TurnEvent[]): TurnTokens | undefined;
|
|
26
32
|
/**
|
|
27
33
|
* A side is `estimated` when any call estimated it. Cost is `partial` when some call reported none;
|
|
28
34
|
* a missing `upstreamUsd` is not missing data (OpenRouter reports it only for BYOK).
|
|
@@ -92,6 +92,23 @@ function sumGrounding(calls) {
|
|
|
92
92
|
export function sumEventTokens(events) {
|
|
93
93
|
return sumTokens(events.flatMap((event) => (event.type === 'tokens' ? [event.tokens] : [])));
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* A turn's usage with its agent tool calls': its own `tokens` events plus each
|
|
97
|
+
* call's `tokens` on the tool's `complete` or `error`. `done.tokens` reads it;
|
|
98
|
+
* the turn's span keeps `sumEventTokens`, since each call has its own span.
|
|
99
|
+
*/
|
|
100
|
+
export function sumTurnTokens(events) {
|
|
101
|
+
return sumTokens(events.flatMap((event) => {
|
|
102
|
+
if (event.type === 'tokens')
|
|
103
|
+
return [event.tokens];
|
|
104
|
+
if (event.type !== 'tool')
|
|
105
|
+
return [];
|
|
106
|
+
const { tool } = event;
|
|
107
|
+
return (tool.phase === 'complete' || tool.phase === 'error') && tool.tokens
|
|
108
|
+
? [tool.tokens]
|
|
109
|
+
: [];
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
95
112
|
/**
|
|
96
113
|
* A side is `estimated` when any call estimated it. Cost is `partial` when some call reported none;
|
|
97
114
|
* a missing `upstreamUsd` is not missing data (OpenRouter reports it only for BYOK).
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { InteractionMediaRefPart, InteractionPart, TurnHistoryMessage } from './types.js';
|
|
2
2
|
/** `toGoogleValue` snake-cases `mimeType` to the documented Interactions `mime_type`. */
|
|
3
3
|
export declare function wireInteractionPart(part: InteractionPart): Record<string, string>;
|
|
4
|
+
/** True for a part that is media referenced by `uri` rather than carried as data. */
|
|
4
5
|
export declare function isMediaRefPart(part: InteractionPart): part is InteractionMediaRefPart;
|
|
5
6
|
/**
|
|
6
7
|
* Everything a history message says, in the one order every provider adapter
|
|
@@ -8,3 +9,5 @@ export declare function isMediaRefPart(part: InteractionPart): part is Interacti
|
|
|
8
9
|
* Neither field replaces the other.
|
|
9
10
|
*/
|
|
10
11
|
export declare function historyMessageParts(msg: TurnHistoryMessage): InteractionPart[];
|
|
12
|
+
/** One step's calls as the assistant message that made them, with the reasoning written before them. */
|
|
13
|
+
export declare function historyToolCalls(calls: readonly Pick<import('./turn-events.js').ToolCallRequest, 'callId' | 'name' | 'arguments' | 'reasoning'>[]): TurnHistoryMessage;
|
|
@@ -8,6 +8,7 @@ export function wireInteractionPart(part) {
|
|
|
8
8
|
}
|
|
9
9
|
return { type: part.type, mimeType: part.mimeType, data: part.data };
|
|
10
10
|
}
|
|
11
|
+
/** True for a part that is media referenced by `uri` rather than carried as data. */
|
|
11
12
|
export function isMediaRefPart(part) {
|
|
12
13
|
return part.type !== 'text' && 'uri' in part;
|
|
13
14
|
}
|
|
@@ -20,3 +21,20 @@ export function historyMessageParts(msg) {
|
|
|
20
21
|
const parts = msg.parts ?? [];
|
|
21
22
|
return msg.content ? [{ type: 'text', text: msg.content }, ...parts] : [...parts];
|
|
22
23
|
}
|
|
24
|
+
/** One step's calls as the assistant message that made them, with the reasoning written before them. */
|
|
25
|
+
export function historyToolCalls(calls) {
|
|
26
|
+
const reasoning = calls.flatMap((call) => call.reasoning ?? []);
|
|
27
|
+
const tool_calls = [];
|
|
28
|
+
for (const call of calls) {
|
|
29
|
+
tool_calls.push({
|
|
30
|
+
id: call.callId,
|
|
31
|
+
type: 'function',
|
|
32
|
+
function: { name: call.name, arguments: JSON.stringify(call.arguments) },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
role: 'assistant',
|
|
37
|
+
tool_calls,
|
|
38
|
+
...(reasoning.length ? { reasoning: [...reasoning] } : {}),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Any value JSON can hold. */
|
|
3
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
4
|
+
[key: string]: JsonValue;
|
|
5
|
+
};
|
|
6
|
+
export type JsonObject = {
|
|
7
|
+
[key: string]: JsonValue;
|
|
8
|
+
};
|
|
9
|
+
export declare const jsonValueSchema: z.ZodType<JsonValue>;
|
|
10
|
+
export declare const jsonObjectSchema: z.ZodRecord<z.ZodString, z.ZodType<JsonValue>>;
|
package/esm/src/kernel/mod.d.ts
CHANGED
|
@@ -5,42 +5,69 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import "../../_dnt.polyfills.js";
|
|
7
7
|
export * from './auth/mod.js';
|
|
8
|
-
export {
|
|
8
|
+
export type { ProviderCheckpoint, ProviderContinuationPolicy, ProviderStateRebuilt, ProviderWarning, } from './checkpoint.js';
|
|
9
|
+
export { historyHash, providerCheckpointSchema, providerContinuationSchema, providerWarningSchema, } from './checkpoint.js';
|
|
10
|
+
export { clearProfiles, compactHistory, getProfile, getProvider, getStructured, getTool, hasProfile, hasTool, invokeTool, invokeToolStep, listProfiles, listProtocols, listProviders, listTools, projectProfile, registerProfile, registerProfiles, registerProvider, registerStructured, registerTool, registerTools, requireTool, resetTools, resolveTurn, runDecision, runEmbedding, runSession, runTurn, } from './default-scope.js';
|
|
9
11
|
export type { CompactionSplit, CompactionTokens } from './engine/compaction.js';
|
|
10
12
|
export { compactionMeter, compactionNeeded, resolveCompactionTokens, resolveHistoryTokens, shouldCompact, splitForCompaction, } from './engine/compaction.js';
|
|
11
13
|
export type { RunDecisionOptions } from './engine/decision.js';
|
|
12
14
|
export { DecisionError, validateDecisionRequest } from './engine/decision.js';
|
|
15
|
+
export type { RunEmbeddingOptions } from './engine/embedding.js';
|
|
13
16
|
export type { LiveIngressChannel } from './engine/live-ingress.js';
|
|
14
17
|
export { assertLiveIngress, assertLiveIngressConfigured, hasAnyLiveIngress, liveIngressChannelDefault, liveIngressEnabled, liveIngressEnabledFromSpec, } from './engine/live-ingress.js';
|
|
15
18
|
export type { RunSessionOptions, SignInGatePolicy } from './engine/session/mod.js';
|
|
16
|
-
export type {
|
|
17
|
-
export { loadTokenEstimator,
|
|
19
|
+
export type { TokenCount, TokenEstimator } from './engine/token-estimate.js';
|
|
20
|
+
export { loadTokenEstimator, TOKEN_TEXT_ENCODING, } from './engine/token-estimate.js';
|
|
18
21
|
export { sumTokens } from './engine/usage.js';
|
|
19
22
|
export { isMediaRefPart, wireInteractionPart } from './interaction-parts.js';
|
|
23
|
+
export type { JsonObject, JsonValue } from './json.js';
|
|
24
|
+
export { jsonObjectSchema, jsonValueSchema } from './json.js';
|
|
20
25
|
export type { ProfileGraphEditor, ProfileGraphFacet, ProfileGraphFacetId, ProfileGraphRole, } from './profile-graph.js';
|
|
21
26
|
export { PROFILE_GRAPH, profileGraphFacet, spineFacetsForProfileType, } from './profile-graph.js';
|
|
27
|
+
export { unsetValue } from './profile-presence.js';
|
|
28
|
+
export { outOfScopeFields, profileTypesForField } from './profile-scope.js';
|
|
29
|
+
export type { DecisionModelBinding, ModelBinding, RuntimeAbilities } from './protocols/binding.js';
|
|
30
|
+
export { checkBinding, commonModelSettingsSchema, decisionModelBindingSchema, keySlotSchema, keySlotsOf, modelBindingSchema, } from './protocols/binding.js';
|
|
31
|
+
export type { ProviderLimits } from './protocols/limits.js';
|
|
32
|
+
export { providerLimitsSchema, resolveProviderLimits } from './protocols/limits.js';
|
|
33
|
+
export type { EstimatedCost, ModelPrice, PriceTable, Rates } from './protocols/prices.js';
|
|
34
|
+
export { costFromPrices } from './protocols/prices.js';
|
|
35
|
+
export type { Continuation, DecisionCall, EmbeddingCall, EmbeddingMediaKind, EmbeddingModelLimits, ExtensionBodyAt, ExtensionReader, LiveToolResult, ModelProfileType, Protocol, ProtocolContentEvent, ProtocolContext, ProtocolDefinition, ProtocolEvent, ProtocolExtension, ProtocolOperations, ProtocolRequest, ProtocolSession, ProtocolSocket, SendInit, UpstreamFailure, } from './protocols/protocol.js';
|
|
36
|
+
export { carriesTo, defineProtocol, extendProtocol, modelOptions } from './protocols/protocol.js';
|
|
37
|
+
export type { Authorize, DecisionModelSettings, ModelSettings, Outgoing, Provider, ProviderDefinition, ProviderRegistry, RegisteredProvider, Registration, Serve, Signer, } from './protocols/provider.js';
|
|
38
|
+
export { bearer, createProviderRegistry, defineProvider, endpointUrlSchema, header, query, } from './protocols/provider.js';
|
|
39
|
+
export type { CallSetup, OpenWebSocket, ProtocolCall, ProviderHostOptions, } from './protocols/runtime.js';
|
|
40
|
+
export { callProtocol, plainWebSocket } from './protocols/runtime.js';
|
|
22
41
|
export type { MediaInputChannel } from './registry/catalog.js';
|
|
23
42
|
export { clampThinkingLevel, clampThinkingLevelForApiId, mediaChannelForMime, mediaKindForMime, mimeAllowed, mimeEssence, modelEntryByApiId, requireModelBinding, } from './registry/catalog.js';
|
|
24
43
|
export type { KernelRegistry } from './registry/kernel-registry.js';
|
|
25
44
|
export { createKernelRegistry } from './registry/kernel-registry.js';
|
|
26
|
-
export type { DecisionProfileDefinition, HostProfileDefinition, ImageProfileDefinition, LiveProfileDefinition, ProfileDefinition, ProfileDefinitionBase, ProfileRegistry, SpeechProfileDefinition, TextProfileDefinition, } from './registry/profiles.js';
|
|
45
|
+
export type { DecisionProfileDefinition, EmbeddingProfileDefinition, HostProfileDefinition, ImageProfileDefinition, LiveProfileDefinition, ProfileDefinition, ProfileDefinitionBase, ProfileRegistry, SpeechProfileDefinition, TextProfileDefinition, } from './registry/profiles.js';
|
|
27
46
|
export { createProfileRegistry, defineProfile } from './registry/profiles.js';
|
|
28
47
|
export { projectProfileObject, requireModelProfile } from './registry/resolve.js';
|
|
29
48
|
export type { SchemaRegistry } from './registry/schemas.js';
|
|
30
49
|
export { createSchemaRegistry } from './registry/schemas.js';
|
|
31
|
-
export type {
|
|
32
|
-
export {
|
|
50
|
+
export type { CredentialContext, CredentialResolver, KeyCredential } from './registry/vault.js';
|
|
51
|
+
export type { AuthUnauthenticatedPolicy, CustomToolType, HttpMethod, StudioAuthType, ToolAccess, ToolAuthType, ToolPermission, ToolType, } from './schema.js';
|
|
52
|
+
export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, CACHE_MODES, CACHE_TTLS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './schema.js';
|
|
33
53
|
export type { KernelScope } from './scope.js';
|
|
34
54
|
export { createKernelScope, defaultKernelScope } from './scope.js';
|
|
35
55
|
export type { AwaitingUserInput, StageAffordance, StageApplyInput, StageApplyOutput, StageApplyWarning, StageApplyWarningCode, StageContext, StageEventExtra, StageHandler, StageMutate, StageResult, } from './stages.js';
|
|
36
|
-
export { applyStageResult,
|
|
56
|
+
export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './stages.js';
|
|
37
57
|
export type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './stop.js';
|
|
38
|
-
export { AUTO_CONTINUE_DELAY_MS, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './stop.js';
|
|
58
|
+
export { AUTO_CONTINUE_DELAY_MS, CONTINUE_INSTRUCTION_TYPES, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './stop.js';
|
|
59
|
+
export { systemPromptProblem } from './system-parts.js';
|
|
60
|
+
export { activityLabelProblem } from './tools/activity-label.js';
|
|
61
|
+
export { agentToolInputFor, agentToolOutput } from './tools/agent.js';
|
|
39
62
|
export { type AnsweredGate, answerGatedCall, GATE_DECISIONS, type GateAnswerRequest, type GateDecision, gateExpired, type HeldGatedCall, resolveGateTtlMs, sessionPermissionsAfterApproval, type ToolGateAuth, } from './tools/gate-answer.js';
|
|
40
|
-
export type { McpProtocolVersion, McpRpcResponse, ToolRegistry } from './tools/mod.js';
|
|
41
|
-
export { askUserTool, coerceToolResultParts, createToolRegistry, executeHttpTool, executeMcpTool, executeRegisteredTool, formatToolResult, isUnsupportedMcpProtocolError, leanToolResultData, MCP_PROTOCOL_VERSIONS, parseMcpRpcResponse, prepareTurnToolSnapshot, projectForModel, registerHarnessTools, resolveToolAuth, } from './tools/mod.js';
|
|
63
|
+
export type { CredentialQuery, McpProtocolVersion, McpRpcResponse, ToolRegistry, } from './tools/mod.js';
|
|
64
|
+
export { askUserTool, authorizeToolReplay, coerceToolResultParts, createToolRegistry, credentialPlacement, executeHttpTool, executeMcpTool, executeRegisteredTool, formatToolResult, isUnsupportedMcpProtocolError, leanToolResultData, MCP_PROTOCOL_VERSIONS, parseMcpRpcResponse, prepareTurnToolSnapshot, projectForModel, registerHarnessTools, resolveToolAuth, withCredentialQuery, } from './tools/mod.js';
|
|
65
|
+
export type { BeginToolOperationResult, PageToolDispatch, PageToolExecution, SavedToolInvocation, TerminalToolEvent, ToolExecutionCoordinator, ToolOperationClaim, ToolOperationIdentity, ToolOperationOutcome, ToolOperationUncertainty, } from './tools/operation.js';
|
|
66
|
+
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, } from './tools/operation.js';
|
|
67
|
+
export { jsonSchemaFromZod } from './tools/schema.js';
|
|
42
68
|
export { CredentialRefusedError } from './tools/signed-in-fetch.js';
|
|
43
|
-
export {
|
|
69
|
+
export type { ModelToolResult, PageAnswer, ToolAuthConfig, ToolContext, ToolLabels, } from './tools/types.js';
|
|
70
|
+
export { awaitingUserInputSchema, type GateReference, gateReferenceSchema, isAwaitingUserInput, keptReply, reasoningPartSchema, TURN_EVENT_SCHEMAS, toolGateSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './turn-events.js';
|
|
44
71
|
export type * from './types.js';
|
|
45
72
|
export { base64ToBytes, bytesToBase64 } from './util/base64.js';
|
|
46
73
|
export type { Equals } from './util/exact-type.js';
|
package/esm/src/kernel/mod.js
CHANGED
|
@@ -5,26 +5,41 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import "../../_dnt.polyfills.js";
|
|
7
7
|
export * from './auth/mod.js';
|
|
8
|
-
export {
|
|
8
|
+
export { historyHash, providerCheckpointSchema, providerContinuationSchema, providerWarningSchema, } from './checkpoint.js';
|
|
9
|
+
export { clearProfiles, compactHistory, getProfile, getProvider, getStructured, getTool, hasProfile, hasTool, invokeTool, invokeToolStep, listProfiles, listProtocols, listProviders, listTools, projectProfile, registerProfile, registerProfiles, registerProvider, registerStructured, registerTool, registerTools, requireTool, resetTools, resolveTurn, runDecision, runEmbedding, runSession, runTurn, } from './default-scope.js';
|
|
9
10
|
export { compactionMeter, compactionNeeded, resolveCompactionTokens, resolveHistoryTokens, shouldCompact, splitForCompaction, } from './engine/compaction.js';
|
|
10
11
|
export { DecisionError, validateDecisionRequest } from './engine/decision.js';
|
|
11
12
|
export { assertLiveIngress, assertLiveIngressConfigured, hasAnyLiveIngress, liveIngressChannelDefault, liveIngressEnabled, liveIngressEnabledFromSpec, } from './engine/live-ingress.js';
|
|
12
|
-
export { loadTokenEstimator,
|
|
13
|
+
export { loadTokenEstimator, TOKEN_TEXT_ENCODING, } from './engine/token-estimate.js';
|
|
13
14
|
export { sumTokens } from './engine/usage.js';
|
|
14
15
|
export { isMediaRefPart, wireInteractionPart } from './interaction-parts.js';
|
|
16
|
+
export { jsonObjectSchema, jsonValueSchema } from './json.js';
|
|
15
17
|
export { PROFILE_GRAPH, profileGraphFacet, spineFacetsForProfileType, } from './profile-graph.js';
|
|
18
|
+
export { unsetValue } from './profile-presence.js';
|
|
19
|
+
export { outOfScopeFields, profileTypesForField } from './profile-scope.js';
|
|
20
|
+
export { checkBinding, commonModelSettingsSchema, decisionModelBindingSchema, keySlotSchema, keySlotsOf, modelBindingSchema, } from './protocols/binding.js';
|
|
21
|
+
export { providerLimitsSchema, resolveProviderLimits } from './protocols/limits.js';
|
|
22
|
+
export { costFromPrices } from './protocols/prices.js';
|
|
23
|
+
export { carriesTo, defineProtocol, extendProtocol, modelOptions } from './protocols/protocol.js';
|
|
24
|
+
export { bearer, createProviderRegistry, defineProvider, endpointUrlSchema, header, query, } from './protocols/provider.js';
|
|
25
|
+
export { callProtocol, plainWebSocket } from './protocols/runtime.js';
|
|
16
26
|
export { clampThinkingLevel, clampThinkingLevelForApiId, mediaChannelForMime, mediaKindForMime, mimeAllowed, mimeEssence, modelEntryByApiId, requireModelBinding, } from './registry/catalog.js';
|
|
17
27
|
export { createKernelRegistry } from './registry/kernel-registry.js';
|
|
18
28
|
export { createProfileRegistry, defineProfile } from './registry/profiles.js';
|
|
19
29
|
export { projectProfileObject, requireModelProfile } from './registry/resolve.js';
|
|
20
30
|
export { createSchemaRegistry } from './registry/schemas.js';
|
|
21
|
-
export { ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, CACHE_MODES, CACHE_TTLS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor,
|
|
31
|
+
export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, CACHE_MODES, CACHE_TTLS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './schema.js';
|
|
22
32
|
export { createKernelScope, defaultKernelScope } from './scope.js';
|
|
23
|
-
export { applyStageResult,
|
|
24
|
-
export { AUTO_CONTINUE_DELAY_MS, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './stop.js';
|
|
33
|
+
export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './stages.js';
|
|
34
|
+
export { AUTO_CONTINUE_DELAY_MS, CONTINUE_INSTRUCTION_TYPES, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './stop.js';
|
|
35
|
+
export { systemPromptProblem } from './system-parts.js';
|
|
36
|
+
export { activityLabelProblem } from './tools/activity-label.js';
|
|
37
|
+
export { agentToolInputFor, agentToolOutput } from './tools/agent.js';
|
|
25
38
|
export { answerGatedCall, GATE_DECISIONS, gateExpired, resolveGateTtlMs, sessionPermissionsAfterApproval, } from './tools/gate-answer.js';
|
|
26
|
-
export { askUserTool, coerceToolResultParts, createToolRegistry, executeHttpTool, executeMcpTool, executeRegisteredTool, formatToolResult, isUnsupportedMcpProtocolError, leanToolResultData, MCP_PROTOCOL_VERSIONS, parseMcpRpcResponse, prepareTurnToolSnapshot, projectForModel, registerHarnessTools, resolveToolAuth, } from './tools/mod.js';
|
|
39
|
+
export { askUserTool, authorizeToolReplay, coerceToolResultParts, createToolRegistry, credentialPlacement, executeHttpTool, executeMcpTool, executeRegisteredTool, formatToolResult, isUnsupportedMcpProtocolError, leanToolResultData, MCP_PROTOCOL_VERSIONS, parseMcpRpcResponse, prepareTurnToolSnapshot, projectForModel, registerHarnessTools, resolveToolAuth, withCredentialQuery, } from './tools/mod.js';
|
|
40
|
+
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, } from './tools/operation.js';
|
|
41
|
+
export { jsonSchemaFromZod } from './tools/schema.js';
|
|
27
42
|
export { CredentialRefusedError } from './tools/signed-in-fetch.js';
|
|
28
|
-
export { awaitingUserInputSchema, TURN_EVENT_SCHEMAS, toolGateSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './turn-events.js';
|
|
43
|
+
export { awaitingUserInputSchema, gateReferenceSchema, isAwaitingUserInput, keptReply, reasoningPartSchema, TURN_EVENT_SCHEMAS, toolGateSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './turn-events.js';
|
|
29
44
|
export { base64ToBytes, bytesToBase64 } from './util/base64.js';
|
|
30
45
|
export { isRecord } from './util/record.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ProfileType } from './schema.js';
|
|
2
|
+
/** The editor a graph facet is edited with: schema-driven or structural. */
|
|
2
3
|
export type ProfileGraphEditor = 'schema' | 'structural';
|
|
4
|
+
/** Where a facet sits in the graph: root, spine, or branch. */
|
|
3
5
|
export type ProfileGraphRole = 'root' | 'spine' | 'branch';
|
|
4
6
|
/**
|
|
5
7
|
* Adding a profile section? Add it to PROFILE_FIELDS and a row here, never a FacetKind in the
|
|
@@ -12,7 +14,7 @@ declare const PROFILE_GRAPH_DEF: readonly [{
|
|
|
12
14
|
readonly optional: false;
|
|
13
15
|
readonly editor: "structural";
|
|
14
16
|
readonly label: "Identity";
|
|
15
|
-
readonly ownsFields: readonly ["id", "type"];
|
|
17
|
+
readonly ownsFields: readonly ["profile.id", "profile.type"];
|
|
16
18
|
}, {
|
|
17
19
|
readonly id: "models";
|
|
18
20
|
readonly profilePath: "models";
|
|
@@ -20,7 +22,7 @@ declare const PROFILE_GRAPH_DEF: readonly [{
|
|
|
20
22
|
readonly optional: false;
|
|
21
23
|
readonly editor: "structural";
|
|
22
24
|
readonly label: "Models";
|
|
23
|
-
readonly ownsFields: readonly ["defaultModel", "allowModelSelect", "maxSteps", "
|
|
25
|
+
readonly ownsFields: readonly ["profile.defaultModel", "profile.allowModelSelect", "profile.maxSteps", "providerContinuation"];
|
|
24
26
|
}, {
|
|
25
27
|
readonly id: "modelBinding";
|
|
26
28
|
readonly profilePath: "models.*";
|
|
@@ -109,13 +111,14 @@ declare const PROFILE_GRAPH_DEF: readonly [{
|
|
|
109
111
|
readonly editor: "structural";
|
|
110
112
|
readonly label: "Observability";
|
|
111
113
|
}, {
|
|
112
|
-
readonly id: "
|
|
113
|
-
readonly profilePath: "
|
|
114
|
+
readonly id: "labels";
|
|
115
|
+
readonly profilePath: "labels";
|
|
114
116
|
readonly role: "spine";
|
|
115
117
|
readonly optional: true;
|
|
116
118
|
readonly editor: "structural";
|
|
117
|
-
readonly label: "
|
|
119
|
+
readonly label: "Labels";
|
|
118
120
|
}];
|
|
121
|
+
/** The id of a profile graph facet. */
|
|
119
122
|
export type ProfileGraphFacetId = (typeof PROFILE_GRAPH_DEF)[number]['id'];
|
|
120
123
|
/** `profilePath` is a PROFILE_FIELDS key (section root) or a dynamic path (`models.*`). */
|
|
121
124
|
export interface ProfileGraphFacet {
|
|
@@ -129,12 +132,14 @@ export interface ProfileGraphFacet {
|
|
|
129
132
|
label: string;
|
|
130
133
|
/**
|
|
131
134
|
* Extra PROFILE_FIELDS top-level keys owned by this facet (not 1:1 with id).
|
|
132
|
-
* Used by the drift gate so `defaultModel` / `id` / `type` are not orphaned.
|
|
135
|
+
* Used by the drift gate so `profile.defaultModel` / `profile.id` / `profile.type` are not orphaned.
|
|
133
136
|
*/
|
|
134
137
|
ownsFields?: readonly string[];
|
|
135
138
|
}
|
|
139
|
+
/** The profile graph: each facet, with the profile types it applies to. */
|
|
136
140
|
export declare const PROFILE_GRAPH: readonly ProfileGraphFacet[];
|
|
137
141
|
/** Spine (and root) facets visible for a profile type, in catalog order. */
|
|
138
142
|
declare function spineFacetsForProfileType(type: ProfileType): ProfileGraphFacet[];
|
|
143
|
+
/** The facet with this id, or `undefined`. */
|
|
139
144
|
declare function profileGraphFacet(id: ProfileGraphFacetId): ProfileGraphFacet | undefined;
|
|
140
145
|
export { profileGraphFacet, spineFacetsForProfileType };
|
|
@@ -11,7 +11,7 @@ const PROFILE_GRAPH_DEF = [
|
|
|
11
11
|
optional: false,
|
|
12
12
|
editor: 'structural',
|
|
13
13
|
label: 'Identity',
|
|
14
|
-
ownsFields: ['id', 'type'],
|
|
14
|
+
ownsFields: ['profile.id', 'profile.type'],
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
id: 'models',
|
|
@@ -20,7 +20,12 @@ const PROFILE_GRAPH_DEF = [
|
|
|
20
20
|
optional: false,
|
|
21
21
|
editor: 'structural',
|
|
22
22
|
label: 'Models',
|
|
23
|
-
ownsFields: [
|
|
23
|
+
ownsFields: [
|
|
24
|
+
'profile.defaultModel',
|
|
25
|
+
'profile.allowModelSelect',
|
|
26
|
+
'profile.maxSteps',
|
|
27
|
+
'providerContinuation',
|
|
28
|
+
],
|
|
24
29
|
},
|
|
25
30
|
{
|
|
26
31
|
id: 'modelBinding',
|
|
@@ -122,21 +127,22 @@ const PROFILE_GRAPH_DEF = [
|
|
|
122
127
|
label: 'Observability',
|
|
123
128
|
},
|
|
124
129
|
{
|
|
125
|
-
id: '
|
|
126
|
-
profilePath: '
|
|
130
|
+
id: 'labels',
|
|
131
|
+
profilePath: 'labels',
|
|
127
132
|
role: 'spine',
|
|
128
133
|
optional: true,
|
|
129
134
|
editor: 'structural',
|
|
130
|
-
label: '
|
|
135
|
+
label: 'Labels',
|
|
131
136
|
},
|
|
132
137
|
];
|
|
133
138
|
/** The facets whose types differ from their `profilePath`'s scope. */
|
|
134
139
|
const FACET_PROFILE_TYPES = {
|
|
135
|
-
// The root holds `id` and `type`, which every profile has.
|
|
140
|
+
// why: The root holds `id` and `type`, which every profile has.
|
|
136
141
|
identity: ALL_PROFILE_TYPES,
|
|
137
|
-
// A decision's inputs belong to its Decision facet.
|
|
142
|
+
// why: A decision's inputs belong to its Decision facet.
|
|
138
143
|
inputs: profileTypesForField('inputs').filter((type) => type !== 'decision'),
|
|
139
144
|
};
|
|
145
|
+
/** The profile graph: each facet, with the profile types it applies to. */
|
|
140
146
|
export const PROFILE_GRAPH = PROFILE_GRAPH_DEF.map((facet) => ({
|
|
141
147
|
...facet,
|
|
142
148
|
profileTypes: FACET_PROFILE_TYPES[facet.id] ?? profileTypesForField(facet.profilePath),
|
|
@@ -145,6 +151,7 @@ export const PROFILE_GRAPH = PROFILE_GRAPH_DEF.map((facet) => ({
|
|
|
145
151
|
function spineFacetsForProfileType(type) {
|
|
146
152
|
return PROFILE_GRAPH.filter((facet) => (facet.role === 'root' || facet.role === 'spine') && facet.profileTypes.includes(type));
|
|
147
153
|
}
|
|
154
|
+
/** The facet with this id, or `undefined`. */
|
|
148
155
|
function profileGraphFacet(id) {
|
|
149
156
|
return PROFILE_GRAPH.find((facet) => facet.id === id);
|
|
150
157
|
}
|