@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
package/esm/src/evals/trial.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Records → `Trial`. A live run hands the runner what its memory sink caught;
|
|
3
|
-
* a recorded run hands it what a file held. Both build the same trial, so the
|
|
4
|
-
* same graders give the same results.
|
|
5
|
-
*
|
|
6
|
-
* The root is the `invoke_agent` span with no agent above it in the set; a host
|
|
7
|
-
* span above it (the host's request, when the host nests the turn under its own
|
|
8
|
-
* span) does not hide it, and the topmost span above it is the trial's `top`. It
|
|
9
|
-
* is never assumed to be the first record: a compaction turn's record can be
|
|
10
|
-
* written before its parent's (P9).
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
1
|
import { TheoremError } from '../guardrails/error.js';
|
|
15
2
|
import { contentOf, inlineContent } from '../observability/trace-record.js';
|
|
16
3
|
function byStart(a, b) {
|
|
@@ -22,11 +9,9 @@ function operationOf(span) {
|
|
|
22
9
|
const value = span.attributes['gen_ai.operation.name'];
|
|
23
10
|
return typeof value === 'string' ? value : undefined;
|
|
24
11
|
}
|
|
25
|
-
/** Every span of every record, in start order. */
|
|
26
12
|
function allSpans(records) {
|
|
27
13
|
return records.flatMap((record) => record.spans).sort(byStart);
|
|
28
14
|
}
|
|
29
|
-
/** The spans above `span` in the set, nearest first; a parent outside the set ends the walk. */
|
|
30
15
|
function ancestorsOf(span, byId) {
|
|
31
16
|
const above = [];
|
|
32
17
|
const seen = new Set([span.spanId]);
|
|
@@ -38,16 +23,13 @@ function ancestorsOf(span, byId) {
|
|
|
38
23
|
}
|
|
39
24
|
return above;
|
|
40
25
|
}
|
|
41
|
-
/**
|
|
42
|
-
* The `invoke_agent` span with no `invoke_agent` above it in the set; the
|
|
43
|
-
* earliest when several qualify (a session root before its responses).
|
|
44
|
-
*/
|
|
26
|
+
/** The earliest `invoke_agent` span with no `invoke_agent` above it; never assumed to be the first record, since a compaction turn's record can be written before its parent's (P9). */
|
|
45
27
|
function rootOf(spans, byId) {
|
|
46
28
|
const roots = spans.filter((span) => operationOf(span) === 'invoke_agent' &&
|
|
47
29
|
!ancestorsOf(span, byId).some((above) => operationOf(above) === 'invoke_agent'));
|
|
48
30
|
const [root] = roots;
|
|
49
31
|
if (!root) {
|
|
50
|
-
throw new TheoremError('config', 'trial records hold no invoke_agent root span'); //
|
|
32
|
+
throw new TheoremError('config', 'trial records hold no invoke_agent root span'); // labels-exempt: developer contract error
|
|
51
33
|
}
|
|
52
34
|
return root;
|
|
53
35
|
}
|
|
@@ -55,7 +37,7 @@ function rootOf(spans, byId) {
|
|
|
55
37
|
function mergedRecord(records) {
|
|
56
38
|
const [first] = records;
|
|
57
39
|
if (!first) {
|
|
58
|
-
throw new TheoremError('config', 'a trial needs at least one trace record'); //
|
|
40
|
+
throw new TheoremError('config', 'a trial needs at least one trace record'); // labels-exempt: developer contract error
|
|
59
41
|
}
|
|
60
42
|
return { ...first, content: Object.assign({}, ...records.map((record) => record.content)) };
|
|
61
43
|
}
|
|
@@ -69,7 +51,6 @@ function isObject(value) {
|
|
|
69
51
|
function isMessageList(value) {
|
|
70
52
|
return Array.isArray(value) && value.every(isObject);
|
|
71
53
|
}
|
|
72
|
-
/** The root's usage attributes as `TurnTokens`; zero when the root recorded none. */
|
|
73
54
|
function usageOf(root) {
|
|
74
55
|
const input = numberAttribute(root, 'gen_ai.usage.input_tokens') ?? 0;
|
|
75
56
|
const output = numberAttribute(root, 'gen_ai.usage.output_tokens') ?? 0;
|
|
@@ -99,11 +80,7 @@ function usageOf(root) {
|
|
|
99
80
|
};
|
|
100
81
|
return costUsd === undefined ? { tokens } : { tokens, costUsd };
|
|
101
82
|
}
|
|
102
|
-
/**
|
|
103
|
-
* What the host received. A turn's root carries `gen_ai.output.messages`; a
|
|
104
|
-
* Live session's root carries none, and each response span carries its own
|
|
105
|
-
* `theorem.output.delivered`, taken in start order.
|
|
106
|
-
*/
|
|
83
|
+
/** A turn's root carries `gen_ai.output.messages`; a Live session's root carries none, and each response span carries its own `theorem.output.delivered`. */
|
|
107
84
|
function deliveredOf(root, spans) {
|
|
108
85
|
const own = root.attributes['gen_ai.output.messages'];
|
|
109
86
|
if (isMessageList(own))
|
|
@@ -115,7 +92,7 @@ function deliveredOf(root, spans) {
|
|
|
115
92
|
return isMessageList(delivered) ? delivered : [];
|
|
116
93
|
});
|
|
117
94
|
}
|
|
118
|
-
/**
|
|
95
|
+
/** Builds the `Trial` a grader reads from one trial's trace records: its root and top spans and accessors for spans, children, content, delivered output, and usage. */
|
|
119
96
|
function buildTrial(args) {
|
|
120
97
|
const merged = mergedRecord(args.records);
|
|
121
98
|
const spans = allSpans(args.records);
|
|
@@ -136,7 +113,7 @@ function buildTrial(args) {
|
|
|
136
113
|
usage: () => usageOf(root),
|
|
137
114
|
};
|
|
138
115
|
}
|
|
139
|
-
/**
|
|
116
|
+
/** Groups trace records by the trace id of their first span; records with no spans are dropped. */
|
|
140
117
|
function groupByTrace(records) {
|
|
141
118
|
const groups = new Map();
|
|
142
119
|
for (const record of records) {
|
|
@@ -151,7 +128,7 @@ function groupByTrace(records) {
|
|
|
151
128
|
}
|
|
152
129
|
return groups;
|
|
153
130
|
}
|
|
154
|
-
/**
|
|
131
|
+
/** True when any record holds an `invoke_agent` span, meaning an agent turn ran. */
|
|
155
132
|
function hasTurn(records) {
|
|
156
133
|
return records.some((record) => record.spans.some((span) => operationOf(span) === 'invoke_agent'));
|
|
157
134
|
}
|
package/esm/src/evals/types.d.ts
CHANGED
|
@@ -1,96 +1,66 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Eval shapes: the suite a host writes, the cases it keeps in JSONL,
|
|
3
|
-
* and the result every grader returns. Each is a documented type and a zod
|
|
4
|
-
* schema checked against it (`Equals`): the type is what graders read; the
|
|
5
|
-
* schema is what the runner runs on a file.
|
|
6
|
-
*
|
|
7
|
-
* Vocabulary follows Anthropic's evals guide so a host can read both: a
|
|
8
|
-
* **suite** of **cases**, each run as k **trials**; a **grader** reads a
|
|
9
|
-
* trial's transcript (its trace) and returns a **result**; the suite's pass
|
|
10
|
-
* rule turns k results into one **verdict**.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
1
|
import { z } from 'zod';
|
|
15
2
|
import type { RunDecisionOptions } from '../kernel/engine/decision.js';
|
|
3
|
+
import type { ProviderHostOptions } from '../kernel/protocols/runtime.js';
|
|
16
4
|
import type { TurnTokens } from '../kernel/turn-events.js';
|
|
17
|
-
import type { ModelProvider } from '../kernel/types.js';
|
|
18
5
|
import type { TraceRecord } from '../observability/trace-record.js';
|
|
19
6
|
import type { TraceAttributeValue, TraceSpan } from '../observability/trace-span.js';
|
|
20
|
-
/**
|
|
7
|
+
/** Whether a case probes what the profile can do (`capability`) or guards what it already did (`regression`). */
|
|
21
8
|
export type EvalCaseKind = 'capability' | 'regression';
|
|
22
|
-
/**
|
|
9
|
+
/** An attachment carried in the case file as base64. */
|
|
23
10
|
export interface EvalInlineAttachment {
|
|
24
11
|
mimeType: string;
|
|
25
12
|
/** Base64 bytes. */
|
|
26
13
|
data: string;
|
|
27
14
|
name?: string;
|
|
28
15
|
}
|
|
29
|
-
/**
|
|
30
|
-
* A file the case attaches to its turn, kept beside the cases file and pinned
|
|
31
|
-
* by the hex SHA-256 of its bytes; a file whose bytes hash otherwise is refused.
|
|
32
|
-
*/
|
|
16
|
+
/** A file attachment is pinned by the hex SHA-256 of its bytes; a file whose bytes hash otherwise is refused. */
|
|
33
17
|
export interface EvalFileAttachment {
|
|
34
18
|
mimeType: string;
|
|
35
|
-
/** Relative to the cases file, or absolute; the loaded case holds it absolute. */
|
|
36
19
|
path: string;
|
|
37
20
|
sha256: string;
|
|
38
21
|
name?: string;
|
|
39
22
|
}
|
|
40
|
-
/**
|
|
23
|
+
/** An attachment a case sends: inline bytes or a file on disk. */
|
|
41
24
|
export type EvalAttachment = EvalInlineAttachment | EvalFileAttachment;
|
|
42
|
-
/**
|
|
25
|
+
/** A single-turn case input. */
|
|
43
26
|
export interface EvalTurnInput {
|
|
44
27
|
text?: string;
|
|
45
28
|
attachments?: EvalAttachment[];
|
|
46
29
|
}
|
|
47
|
-
/** One
|
|
30
|
+
/** One message of a session case, sent once the previous step's turn completes. */
|
|
48
31
|
export interface EvalSessionStep {
|
|
49
32
|
text: string;
|
|
50
33
|
until: 'turn_complete';
|
|
51
34
|
}
|
|
52
|
-
/** A
|
|
35
|
+
/** A multi-step session case input. */
|
|
53
36
|
export interface EvalSessionInput {
|
|
54
37
|
session: {
|
|
55
38
|
steps: EvalSessionStep[];
|
|
56
39
|
};
|
|
57
40
|
}
|
|
58
|
-
/**
|
|
41
|
+
/** A case input: one turn or a session. */
|
|
59
42
|
export type EvalCaseInput = EvalTurnInput | EvalSessionInput;
|
|
60
|
-
/**
|
|
61
|
-
* A dataset case's right answer. Only an `accepted` name passes; a `partial`
|
|
62
|
-
* one is close but not enough (the genus, the broader condition); a `rejected`
|
|
63
|
-
* one is a wrong answer the dataset records for the case (a confuser, an
|
|
64
|
-
* identification it superseded).
|
|
65
|
-
*/
|
|
43
|
+
/** Only an `accepted` name passes; a `partial` one is close but not enough; a `rejected` one named beside an accepted name makes the reply `partial`, not a pass. */
|
|
66
44
|
export interface EvalAnswer {
|
|
67
|
-
/** Every name that counts: scientific name, synonyms, common names. */
|
|
68
45
|
accepted: string[];
|
|
69
46
|
partial?: string[];
|
|
70
|
-
/** A reply that names one beside an accepted name hedged: `partial`, not a pass. */
|
|
71
47
|
rejected?: string[];
|
|
72
|
-
/** Grounding notes for the person reading a miss; no grader reads them. */
|
|
73
48
|
reference?: string;
|
|
74
49
|
}
|
|
75
|
-
/** What
|
|
50
|
+
/** What a case expects: tools, JSON fields, a transcription, or an answer. */
|
|
76
51
|
export interface EvalExpect {
|
|
77
|
-
/** Tools the agent should call, in order (`toolTrajectory` reads it). Empty = no tool. */
|
|
78
52
|
tools?: string[];
|
|
79
|
-
/** Fields the delivered JSON should carry, each compared whole (`delivered.json` reads it). */
|
|
80
53
|
json?: Record<string, unknown>;
|
|
81
|
-
/** What the Live reply's transcript should say (`transcription.*` read it). */
|
|
82
54
|
transcription?: {
|
|
83
55
|
includes?: string;
|
|
84
56
|
regex?: string;
|
|
85
57
|
};
|
|
86
|
-
/** The right answer to a dataset question (`answer` reads it). */
|
|
87
58
|
answer?: EvalAnswer;
|
|
88
|
-
/** For the human reading the case; no grader reads it. */
|
|
89
59
|
notes?: string;
|
|
90
60
|
}
|
|
91
|
-
/**
|
|
61
|
+
/** How hard a case is, from 1 to 5. */
|
|
92
62
|
export type EvalDifficulty = 1 | 2 | 3 | 4 | 5;
|
|
93
|
-
/** One
|
|
63
|
+
/** One eval case: its input and what the reply is expected to be. */
|
|
94
64
|
export interface EvalCase {
|
|
95
65
|
id: string;
|
|
96
66
|
kind: EvalCaseKind;
|
|
@@ -99,113 +69,70 @@ export interface EvalCase {
|
|
|
99
69
|
expect?: EvalExpect;
|
|
100
70
|
tags?: string[];
|
|
101
71
|
}
|
|
102
|
-
/**
|
|
72
|
+
/** The schema an eval case parses against. */
|
|
103
73
|
export declare const evalCaseSchema: z.ZodType<EvalCase>;
|
|
104
|
-
/** The
|
|
74
|
+
/** The operation a trace span records. */
|
|
105
75
|
export type TraceOperation = 'invoke_agent' | 'chat' | 'generate_content' | 'execute_tool';
|
|
106
76
|
/** A message as the trace stores it: `{ role, parts: [...] }`, parts by hash; resolve them with `text` / `content`. */
|
|
107
77
|
export type TrialMessage = Record<string, TraceAttributeValue>;
|
|
108
|
-
/**
|
|
78
|
+
/** Tokens and cost a trial used. */
|
|
109
79
|
export interface TrialUsage {
|
|
110
80
|
tokens: TurnTokens;
|
|
111
81
|
costUsd?: number;
|
|
112
82
|
}
|
|
113
|
-
/**
|
|
114
|
-
* One run of one case, as every grader receives it: the trace records that
|
|
115
|
-
* share the trial's trace id and nothing else. If a grader needs a fact the
|
|
116
|
-
* trace does not hold, the trace is wrong, not the grader.
|
|
117
|
-
*/
|
|
83
|
+
/** A grader receives the trace records that share the trial's trace id and nothing else; if it needs a fact the trace does not hold, the trace is wrong, not the grader. */
|
|
118
84
|
export interface Trial {
|
|
119
85
|
suite: string;
|
|
120
|
-
/** Absent in caseless recorded mode (a production trace with no `metadata.eval`). */
|
|
121
86
|
case?: EvalCase;
|
|
122
|
-
/** 0..k-1. */
|
|
123
87
|
index: number;
|
|
124
88
|
records: TraceRecord[];
|
|
125
|
-
/** The `invoke_agent` span with no agent above it in the set; never assumed to be first. */
|
|
126
89
|
root: TraceSpan;
|
|
127
|
-
/**
|
|
128
|
-
* The topmost span above `root` in the set: the host's own span when the host
|
|
129
|
-
* nested the turn under it, else `root`. Its length is the trial's time.
|
|
130
|
-
*/
|
|
90
|
+
/** The topmost span above `root`: the host's own span when the host nested the turn under it, else `root`. Its length is the trial's time. */
|
|
131
91
|
top: TraceSpan;
|
|
132
|
-
/** Spans by operation, in start order, across every record. */
|
|
133
92
|
spans: (operation: TraceOperation) => TraceSpan[];
|
|
134
|
-
/** The spans one span parents, in start order (a model call's HTTP tries, a response's tool calls). */
|
|
135
93
|
children: (span: TraceSpan) => TraceSpan[];
|
|
136
|
-
/** A value with every `{ content_sha256 }` / `{ json_sha256 }` reference replaced by its stored content. */
|
|
137
94
|
content: (value: unknown) => unknown;
|
|
138
|
-
/** The stored text one reference names; `undefined` for any other value. */
|
|
139
95
|
text: (value: unknown) => string | undefined;
|
|
140
|
-
/** What the host received: the root's output messages, or each Live response's, as stored. */
|
|
141
96
|
delivered: () => TrialMessage[];
|
|
142
|
-
/** Tokens and cost from the root's usage attributes. */
|
|
143
97
|
usage: () => TrialUsage;
|
|
144
98
|
}
|
|
145
|
-
/**
|
|
99
|
+
/** Whether a result came from code or from a model. */
|
|
146
100
|
export type EvalResultSource = 'code' | 'model';
|
|
147
|
-
/**
|
|
148
|
-
* One grader's reading of one trial: the semconv `gen_ai.evaluation.result`
|
|
149
|
-
* event, before it is written. `passed` is the grader's yes/no when it has one;
|
|
150
|
-
* absent means the result informs but does not decide the verdict.
|
|
151
|
-
*/
|
|
101
|
+
/** One grader's verdict on a trial: a score, a label, and why. */
|
|
152
102
|
export interface EvalResult {
|
|
153
|
-
/** The grader's name, e.g. `tool_trajectory`, `faithfulness`. */
|
|
154
103
|
name: string;
|
|
155
104
|
source: EvalResultSource;
|
|
156
|
-
/** `value` is 0–1 unless the grader says otherwise; `label` is one of the grader's labels. */
|
|
157
105
|
score?: {
|
|
158
106
|
value?: number;
|
|
159
107
|
label?: string;
|
|
160
108
|
};
|
|
161
|
-
/** Why, in the grader's words. */
|
|
162
109
|
explanation?: string;
|
|
163
110
|
/** Whether this result counts as a pass. Absent: informational only. */
|
|
164
111
|
passed?: boolean;
|
|
165
112
|
/** Why no score could be produced; the result is then a failed one. */
|
|
166
113
|
errorType?: string;
|
|
167
|
-
/** Judge turns this result was drawn from (`traceparent` each); model graders only. */
|
|
168
114
|
judgeTraceparents?: string[];
|
|
169
115
|
}
|
|
170
|
-
/**
|
|
116
|
+
/** The schema an eval result parses against. */
|
|
171
117
|
export declare const evalResultSchema: z.ZodType<EvalResult>;
|
|
172
|
-
/** How
|
|
118
|
+
/** How many trials of a case must pass for the case to pass. */
|
|
173
119
|
export type EvalPassRule = 'all' | 'any' | {
|
|
174
120
|
atLeast: number;
|
|
175
121
|
};
|
|
176
|
-
/** How
|
|
122
|
+
/** How often a case runs, and the rule across those runs. */
|
|
177
123
|
export interface EvalTrials {
|
|
178
124
|
/** Trials per case. No default: it is a cost decision, so the suite states it. `1` cannot tell noise from change. */
|
|
179
125
|
repeat: number;
|
|
180
|
-
/** Default `all`. */
|
|
181
126
|
pass?: EvalPassRule;
|
|
182
127
|
}
|
|
183
|
-
/**
|
|
184
|
-
* What the runner hands every grader beside the trial. Code graders ignore it;
|
|
185
|
-
* a model grader runs its judge through it and reports each judge call's
|
|
186
|
-
* records through `traced`, so the runner can count their cost and write them
|
|
187
|
-
* to the sink.
|
|
188
|
-
*/
|
|
128
|
+
/** What a grader gets besides the trial: the judge model and its trace parent. */
|
|
189
129
|
export interface EvalGradeContext {
|
|
190
|
-
/** The suite's judge profile, when it names one; a grader may name its own. */
|
|
191
130
|
judge?: string;
|
|
192
|
-
|
|
193
|
-
judgeProvider?: ModelProvider;
|
|
194
|
-
/** The host's vault for decision judge profiles. */
|
|
131
|
+
judgeProvider?: ProviderHostOptions;
|
|
195
132
|
judgeDecision?: Omit<RunDecisionOptions, 'sink'>;
|
|
196
|
-
/**
|
|
197
|
-
* The trial span as a W3C `traceparent`: a judge call runs under it, so it
|
|
198
|
-
* lands in the judged trace beneath the trial. Absent, each judge call
|
|
199
|
-
* starts a trace of its own.
|
|
200
|
-
*/
|
|
133
|
+
/** The trial span as a W3C `traceparent`: a judge call runs under it, so it lands in the judged trace beneath the trial. Absent, each judge call starts a trace of its own. */
|
|
201
134
|
traceparent?: string;
|
|
202
|
-
/**
|
|
203
|
-
* The host's store for media a trace names only by hash. A judge that must
|
|
204
|
-
* see media the case did not attach asks here; absent, only the case's own
|
|
205
|
-
* attachments can be shown.
|
|
206
|
-
*/
|
|
207
135
|
media?: EvalMediaResolver;
|
|
208
|
-
/** Every record a grader's own judge call produced. */
|
|
209
136
|
traced: (records: TraceRecord[]) => void | Promise<void>;
|
|
210
137
|
signal?: AbortSignal;
|
|
211
138
|
}
|
|
@@ -216,45 +143,27 @@ export interface EvalMediaRef {
|
|
|
216
143
|
}
|
|
217
144
|
/** The media's bytes as base64, or `undefined` when the host does not have them. */
|
|
218
145
|
export type EvalMediaResolver = (ref: EvalMediaRef) => string | undefined | Promise<string | undefined>;
|
|
219
|
-
/**
|
|
146
|
+
/** Grades one trial of a case, from its trace. */
|
|
220
147
|
export interface EvalGrader {
|
|
221
|
-
/** The result's `gen_ai.evaluation.name`. */
|
|
222
148
|
name: string;
|
|
223
|
-
/**
|
|
224
|
-
* Stable text naming exactly what this grader checks (its options, its
|
|
225
|
-
* rubric). Its sha256 is written as `theorem.evaluation.grader.version`, so
|
|
226
|
-
* a later reader can tell which rubric produced which score.
|
|
227
|
-
*/
|
|
149
|
+
/** Stable text naming exactly what this grader checks; its sha256 is written as `theorem.evaluation.grader.version`, so a later reader can tell which rubric produced which score. */
|
|
228
150
|
identity: string;
|
|
229
151
|
source: EvalResultSource;
|
|
230
|
-
/** Reads the case's `expect`; skipped when a trial has no case (caseless recorded mode). */
|
|
231
152
|
needsExpect: boolean;
|
|
232
|
-
/**
|
|
233
|
-
* Model graders: every judge profile this grader may run, given the suite's
|
|
234
|
-
* `judge.profile`: its judge first, then any it escalates to. Throws when
|
|
235
|
-
* there is none, or a profile cannot run this grader, so a suite fails
|
|
236
|
-
* before its first trial.
|
|
237
|
-
*/
|
|
238
153
|
judgeProfiles?: (suiteJudge: string | undefined) => string[];
|
|
239
154
|
grade: (trial: Trial, context: EvalGradeContext) => EvalResult | Promise<EvalResult>;
|
|
240
155
|
}
|
|
241
|
-
/** A
|
|
156
|
+
/** A suite: a profile, a mode, a cases file, and the graders to run. */
|
|
242
157
|
export interface EvalSuite {
|
|
243
158
|
id: string;
|
|
244
|
-
/** The profile under test; any type but `host`. */
|
|
245
159
|
profile: string;
|
|
246
160
|
mode: 'turn' | 'session';
|
|
247
|
-
/** Path to `cases.jsonl`, relative to the suite module. */
|
|
248
161
|
cases: string;
|
|
249
162
|
trials: EvalTrials;
|
|
250
163
|
graders: EvalGrader[];
|
|
251
|
-
/**
|
|
252
|
-
* The judge profile model graders run unless they name their own: a text
|
|
253
|
-
* profile that answers through `evalJudgment`, or a decision profile (Jev).
|
|
254
|
-
*/
|
|
255
164
|
judge?: {
|
|
256
165
|
profile: string;
|
|
257
166
|
};
|
|
258
167
|
}
|
|
259
|
-
/**
|
|
168
|
+
/** The schema an eval suite parses against. */
|
|
260
169
|
export declare const evalSuiteSchema: z.ZodType<EvalSuite>;
|
package/esm/src/evals/types.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Eval shapes: the suite a host writes, the cases it keeps in JSONL,
|
|
3
|
-
* and the result every grader returns. Each is a documented type and a zod
|
|
4
|
-
* schema checked against it (`Equals`): the type is what graders read; the
|
|
5
|
-
* schema is what the runner runs on a file.
|
|
6
|
-
*
|
|
7
|
-
* Vocabulary follows Anthropic's evals guide so a host can read both: a
|
|
8
|
-
* **suite** of **cases**, each run as k **trials**; a **grader** reads a
|
|
9
|
-
* trial's transcript (its trace) and returns a **result**; the suite's pass
|
|
10
|
-
* rule turns k results into one **verdict**.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
1
|
import { z } from 'zod';
|
|
15
2
|
import { isRecord } from '../kernel/util/record.js';
|
|
16
3
|
const evalCaseKind = z.enum(['capability', 'regression']);
|
|
@@ -75,7 +62,7 @@ const evalCase = z.object({
|
|
|
75
62
|
tags: z.array(z.string()).optional(),
|
|
76
63
|
});
|
|
77
64
|
true;
|
|
78
|
-
/**
|
|
65
|
+
/** The schema an eval case parses against. */
|
|
79
66
|
export const evalCaseSchema = evalCase;
|
|
80
67
|
const evalResultSource = z.enum(['code', 'model']);
|
|
81
68
|
true;
|
|
@@ -89,7 +76,7 @@ const evalResult = z.object({
|
|
|
89
76
|
judgeTraceparents: z.array(z.string()).optional(),
|
|
90
77
|
});
|
|
91
78
|
true;
|
|
92
|
-
/**
|
|
79
|
+
/** The schema an eval result parses against. */
|
|
93
80
|
export const evalResultSchema = evalResult;
|
|
94
81
|
const evalPassRule = z.union([
|
|
95
82
|
z.literal('all'),
|
|
@@ -122,5 +109,5 @@ const evalSuite = z.object({
|
|
|
122
109
|
judge: z.object({ profile: z.string().min(1) }).optional(),
|
|
123
110
|
});
|
|
124
111
|
true;
|
|
125
|
-
/**
|
|
112
|
+
/** The schema an eval suite parses against. */
|
|
126
113
|
export const evalSuiteSchema = evalSuite;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { EvalCase, EvalPassRule, EvalResult } from './types.js';
|
|
2
|
+
/** How a trial ended: passed, failed, errored, or ungraded. */
|
|
2
3
|
type TrialOutcome = 'passed' | 'failed' | 'errored' | 'ungraded';
|
|
4
|
+
/** The outcome of a trial from its results. */
|
|
3
5
|
declare function trialOutcome(results: readonly EvalResult[]): TrialOutcome;
|
|
6
|
+
/** A case's verdict across its trials, under the pass rule. */
|
|
4
7
|
interface CaseVerdict {
|
|
5
8
|
case: string;
|
|
6
9
|
kind: EvalCase['kind'];
|
|
@@ -12,7 +15,9 @@ interface CaseVerdict {
|
|
|
12
15
|
trialsErrored: number;
|
|
13
16
|
trialsUngraded: number;
|
|
14
17
|
}
|
|
18
|
+
/** The name of a pass rule, as the trace records it. */
|
|
15
19
|
declare function passRuleName(rule: EvalPassRule): 'all' | 'any' | 'at_least';
|
|
20
|
+
/** The verdict of a case from its trials' results. */
|
|
16
21
|
declare function caseVerdict(evalCase: EvalCase, trials: readonly (readonly EvalResult[])[], rule?: EvalPassRule): CaseVerdict;
|
|
17
22
|
export type { CaseVerdict, TrialOutcome };
|
|
18
23
|
export { caseVerdict, passRuleName, trialOutcome };
|
package/esm/src/evals/verdict.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** The outcome of a trial from its results. */
|
|
1
2
|
function trialOutcome(results) {
|
|
2
3
|
if (results.some((result) => result.errorType !== undefined))
|
|
3
4
|
return 'errored';
|
|
@@ -18,10 +19,12 @@ function ruleMet(rule, passed, trials) {
|
|
|
18
19
|
function trialsNeeded(rule) {
|
|
19
20
|
return typeof rule === 'object' ? rule.atLeast : 1;
|
|
20
21
|
}
|
|
22
|
+
/** The name of a pass rule, as the trace records it. */
|
|
21
23
|
function passRuleName(rule) {
|
|
22
24
|
return typeof rule === 'string' ? rule : 'at_least';
|
|
23
25
|
}
|
|
24
|
-
// An errored trial is one that could not be graded (a provider error, a judge that failed), so the rule reads it as a trial that never ran: a rate limit never counts against the agent.
|
|
26
|
+
// why: An errored trial is one that could not be graded (a provider error, a judge that failed), so the rule reads it as a trial that never ran: a rate limit never counts against the agent.
|
|
27
|
+
/** The verdict of a case from its trials' results. */
|
|
25
28
|
function caseVerdict(evalCase, trials, rule = 'all') {
|
|
26
29
|
const outcomes = trials.map(trialOutcome);
|
|
27
30
|
const count = (outcome) => outcomes.filter((o) => o === outcome).length;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** labels-exempt-file: authoring labels and descriptions for boundaries — not runtime user or model copy (P2) */
|
|
2
|
+
/** A record with one entry per key, typed by the keys it was built from. */
|
|
3
|
+
declare function recordOf<K extends string, V>(keys: readonly K[], value: (key: K) => V): Record<K, V>;
|
|
4
|
+
/**
|
|
5
|
+
* The kinds of tool whose text the kernel reads, in the words a builder writes as a tool's
|
|
6
|
+
* `type`. A provider builtin has none: the provider runs it and the kernel never reads its text.
|
|
7
|
+
*/
|
|
8
|
+
declare const TOOL_KINDS: readonly ["function", "http", "mcp", "agent"];
|
|
9
|
+
/** One of {@linkcode TOOL_KINDS}. */
|
|
10
|
+
type ToolKind = (typeof TOOL_KINDS)[number];
|
|
11
|
+
/**
|
|
12
|
+
* The places a tool's text crosses: what the model sends, what comes back to it, its error text,
|
|
13
|
+
* and what the call shows the person (its output, error, artifacts, and trace on the turn's events).
|
|
14
|
+
*/
|
|
15
|
+
declare const TOOL_CROSSINGS: readonly ["tool_arguments", "tool_output", "tool_failure", "tool_shown"];
|
|
16
|
+
/** One of {@linkcode TOOL_CROSSINGS}. */
|
|
17
|
+
type ToolCrossing = (typeof TOOL_CROSSINGS)[number];
|
|
18
|
+
/** A tool crossing for one kind of tool, such as `tool_output_mcp`. */
|
|
19
|
+
type ToolBoundary = `${ToolCrossing}_${ToolKind}`;
|
|
20
|
+
/** The boundary where `crossing` happens for a `kind` tool. */
|
|
21
|
+
declare function toolBoundary<C extends ToolCrossing, K extends ToolKind>(crossing: C, kind: K): `${C}_${K}`;
|
|
22
|
+
/** Every tool boundary, each crossing in turn for every kind of tool. */
|
|
23
|
+
declare const TOOL_BOUNDARIES: readonly ToolBoundary[];
|
|
24
|
+
/** Where text reaches the model from the person or the host. */
|
|
25
|
+
declare const INBOUND_BOUNDARIES: readonly ["user", "attachment", "voice", "slots", "context", "history", "injected", "system", "repair", "live_user"];
|
|
26
|
+
/** Where the model's own text reaches the person. */
|
|
27
|
+
declare const OUTBOUND_BOUNDARIES: readonly ["reply", "reply_structured", "live_reply", "thought"];
|
|
28
|
+
/** Every place the kernel reads text as it crosses, in the order a turn meets them. */
|
|
29
|
+
declare const BOUNDARIES: readonly ["user", "attachment", "voice", "slots", "context", "history", "injected", "system", "repair", "live_user", ...("tool_arguments_function" | "tool_arguments_http" | "tool_arguments_mcp" | "tool_arguments_agent" | "tool_output_function" | "tool_output_http" | "tool_output_mcp" | "tool_output_agent" | "tool_failure_function" | "tool_failure_http" | "tool_failure_mcp" | "tool_failure_agent" | "tool_shown_function" | "tool_shown_http" | "tool_shown_mcp" | "tool_shown_agent")[], "reply", "reply_structured", "live_reply", "thought"];
|
|
30
|
+
/** One of {@linkcode BOUNDARIES}. */
|
|
31
|
+
type Boundary = (typeof BOUNDARIES)[number];
|
|
32
|
+
/** How a boundary is named and described to a builder. */
|
|
33
|
+
interface BoundaryMeta {
|
|
34
|
+
label: string;
|
|
35
|
+
/** What is read there. */
|
|
36
|
+
doc: string;
|
|
37
|
+
}
|
|
38
|
+
/** The label and description of every boundary. */
|
|
39
|
+
declare const BOUNDARY_META: Readonly<Record<Boundary, BoundaryMeta>>;
|
|
40
|
+
export type { Boundary, BoundaryMeta, ToolBoundary, ToolCrossing, ToolKind };
|
|
41
|
+
export { BOUNDARIES, BOUNDARY_META, INBOUND_BOUNDARIES, OUTBOUND_BOUNDARIES, recordOf, TOOL_BOUNDARIES, TOOL_KINDS, toolBoundary, };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// invariant: Leaf module. Imports nothing from `src/guardrails/types.ts` or `src/kernel/`, so the
|
|
2
|
+
// vocabulary can be read by every layer without a cycle.
|
|
3
|
+
/** labels-exempt-file: authoring labels and descriptions for boundaries — not runtime user or model copy (P2) */
|
|
4
|
+
/** A record with one entry per key, typed by the keys it was built from. */
|
|
5
|
+
function recordOf(keys, value) {
|
|
6
|
+
return Object.fromEntries(keys.map((key) => [key, value(key)]));
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The kinds of tool whose text the kernel reads, in the words a builder writes as a tool's
|
|
10
|
+
* `type`. A provider builtin has none: the provider runs it and the kernel never reads its text.
|
|
11
|
+
*/
|
|
12
|
+
const TOOL_KINDS = ['function', 'http', 'mcp', 'agent'];
|
|
13
|
+
/**
|
|
14
|
+
* The places a tool's text crosses: what the model sends, what comes back to it, its error text,
|
|
15
|
+
* and what the call shows the person (its output, error, artifacts, and trace on the turn's events).
|
|
16
|
+
*/
|
|
17
|
+
const TOOL_CROSSINGS = ['tool_arguments', 'tool_output', 'tool_failure', 'tool_shown'];
|
|
18
|
+
/** The boundary where `crossing` happens for a `kind` tool. */
|
|
19
|
+
function toolBoundary(crossing, kind) {
|
|
20
|
+
return `${crossing}_${kind}`;
|
|
21
|
+
}
|
|
22
|
+
/** Every tool boundary, each crossing in turn for every kind of tool. */
|
|
23
|
+
const TOOL_BOUNDARIES = TOOL_CROSSINGS.flatMap((crossing) => TOOL_KINDS.map((kind) => toolBoundary(crossing, kind)));
|
|
24
|
+
/** Where text reaches the model from the person or the host. */
|
|
25
|
+
const INBOUND_BOUNDARIES = [
|
|
26
|
+
'user',
|
|
27
|
+
'attachment',
|
|
28
|
+
'voice',
|
|
29
|
+
'slots',
|
|
30
|
+
'context',
|
|
31
|
+
'history',
|
|
32
|
+
'injected',
|
|
33
|
+
'system',
|
|
34
|
+
'repair',
|
|
35
|
+
'live_user',
|
|
36
|
+
];
|
|
37
|
+
/** Where the model's own text reaches the person. */
|
|
38
|
+
const OUTBOUND_BOUNDARIES = ['reply', 'reply_structured', 'live_reply', 'thought'];
|
|
39
|
+
/** Every place the kernel reads text as it crosses, in the order a turn meets them. */
|
|
40
|
+
const BOUNDARIES = [
|
|
41
|
+
...INBOUND_BOUNDARIES,
|
|
42
|
+
...TOOL_BOUNDARIES,
|
|
43
|
+
...OUTBOUND_BOUNDARIES,
|
|
44
|
+
];
|
|
45
|
+
const TOOL_KIND_LABELS = {
|
|
46
|
+
function: 'function',
|
|
47
|
+
http: 'HTTP',
|
|
48
|
+
mcp: 'MCP',
|
|
49
|
+
agent: 'agent',
|
|
50
|
+
};
|
|
51
|
+
const TOOL_CROSSING_META = {
|
|
52
|
+
tool_arguments: (kind) => ({
|
|
53
|
+
label: `Arguments to ${kind} tools`,
|
|
54
|
+
doc: `What the model sends to a tool of type ${kind}.`,
|
|
55
|
+
}),
|
|
56
|
+
tool_output: (kind) => ({
|
|
57
|
+
label: `Output of ${kind} tools`,
|
|
58
|
+
doc: `What a tool of type ${kind} returns.`,
|
|
59
|
+
}),
|
|
60
|
+
tool_failure: (kind) => ({
|
|
61
|
+
label: `Errors from ${kind} tools`,
|
|
62
|
+
doc: `The error text of a tool of type ${kind} that failed.`,
|
|
63
|
+
}),
|
|
64
|
+
tool_shown: (kind) => ({
|
|
65
|
+
label: `Shown from ${kind} tools`,
|
|
66
|
+
doc: `What a call to a tool of type ${kind} shows the person: its output, error, artifacts, and trace.`,
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
function toolBoundaryMeta() {
|
|
70
|
+
const entries = TOOL_CROSSINGS.flatMap((crossing) => TOOL_KINDS.map((kind) => [
|
|
71
|
+
toolBoundary(crossing, kind),
|
|
72
|
+
TOOL_CROSSING_META[crossing](TOOL_KIND_LABELS[kind]),
|
|
73
|
+
]));
|
|
74
|
+
return Object.fromEntries(entries);
|
|
75
|
+
}
|
|
76
|
+
/** The label and description of every boundary. */
|
|
77
|
+
const BOUNDARY_META = {
|
|
78
|
+
user: { label: 'User message', doc: 'The message the person typed.' },
|
|
79
|
+
attachment: { label: 'Attachments', doc: 'The text of a file the person attached.' },
|
|
80
|
+
voice: { label: 'Voice', doc: 'The transcript of what the person said.' },
|
|
81
|
+
slots: { label: 'Slots', doc: 'The values the host fills into the prompt.' },
|
|
82
|
+
context: { label: 'Context', doc: 'What the page or the host tells the model to know.' },
|
|
83
|
+
history: { label: 'History', doc: 'Earlier messages the host replays.' },
|
|
84
|
+
injected: { label: 'Stage messages', doc: 'Messages a host stage adds during the turn.' },
|
|
85
|
+
system: {
|
|
86
|
+
label: 'Turn system text',
|
|
87
|
+
doc: 'Text the host adds to the system instruction for one turn.',
|
|
88
|
+
},
|
|
89
|
+
repair: {
|
|
90
|
+
label: 'Repair',
|
|
91
|
+
doc: 'A stopped reply and the reason, handed back to the model to try again.',
|
|
92
|
+
},
|
|
93
|
+
live_user: { label: 'Live message', doc: 'Text the person sends in a Live session.' },
|
|
94
|
+
...toolBoundaryMeta(),
|
|
95
|
+
reply: { label: 'Reply', doc: 'The text the model says to the person.' },
|
|
96
|
+
reply_structured: {
|
|
97
|
+
label: 'Structured reply',
|
|
98
|
+
doc: 'The structured output the model returns.',
|
|
99
|
+
},
|
|
100
|
+
live_reply: { label: 'Live reply', doc: 'What the model says in a Live session.' },
|
|
101
|
+
thought: { label: 'Thoughts', doc: "The model's reasoning, where the host shows it." },
|
|
102
|
+
};
|
|
103
|
+
export { BOUNDARIES, BOUNDARY_META, INBOUND_BOUNDARIES, OUTBOUND_BOUNDARIES, recordOf, TOOL_BOUNDARIES, TOOL_KINDS, toolBoundary, };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TurnEvent } from '../kernel/types.js';
|
|
2
2
|
import { type CanaryStreamGate } from './canary.js';
|
|
3
|
+
/** A canary leak gate for one reply: the turn canary, the system prompt to catch echoes of, and the stream gate that holds text back. */
|
|
3
4
|
export interface CanaryGateSession {
|
|
4
5
|
canary: string;
|
|
5
6
|
/** The system prompt as sent, when replies echoing it are leaks too. */
|