@theoremjs/agents 0.0.0-stage → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +545 -2
- package/esm/_dnt.polyfills.d.ts +66 -0
- package/esm/_dnt.polyfills.js +51 -0
- package/esm/mod.d.ts +79 -0
- package/esm/mod.js +49 -0
- package/esm/package.json +3 -0
- package/esm/src/cli/bin.d.ts +7 -0
- package/esm/src/cli/bin.js +9 -0
- package/esm/src/cli/commands/bench.d.ts +6 -0
- package/esm/src/cli/commands/bench.js +480 -0
- package/esm/src/cli/commands/detect-compile.d.ts +17 -0
- package/esm/src/cli/commands/detect-compile.js +22 -0
- package/esm/src/cli/commands/eval.d.ts +37 -0
- package/esm/src/cli/commands/eval.js +190 -0
- package/esm/src/cli/commands/fuzz-canary.d.ts +15 -0
- package/esm/src/cli/commands/fuzz-canary.js +241 -0
- package/esm/src/cli/commands/fuzz-guardrails.d.ts +2 -0
- package/esm/src/cli/commands/fuzz-guardrails.js +5 -0
- package/esm/src/cli/commands/profile.d.ts +2 -0
- package/esm/src/cli/commands/profile.js +80 -0
- package/esm/src/cli/commands/run.d.ts +13 -0
- package/esm/src/cli/commands/run.js +45 -0
- package/esm/src/cli/commands/test.d.ts +26 -0
- package/esm/src/cli/commands/test.js +143 -0
- package/esm/src/cli/event-log.d.ts +15 -0
- package/esm/src/cli/event-log.js +136 -0
- package/esm/src/cli/index.d.ts +10 -0
- package/esm/src/cli/index.js +267 -0
- package/esm/src/cli/matrix/fixtures.d.ts +10 -0
- package/esm/src/cli/matrix/fixtures.js +67 -0
- package/esm/src/cli/matrix/synthesizer.d.ts +18 -0
- package/esm/src/cli/matrix/synthesizer.js +103 -0
- package/esm/src/evals/attachments.d.ts +5 -0
- package/esm/src/evals/attachments.js +55 -0
- package/esm/src/evals/breakdown.d.ts +30 -0
- package/esm/src/evals/breakdown.js +69 -0
- package/esm/src/evals/graders/answer.d.ts +16 -0
- package/esm/src/evals/graders/answer.js +134 -0
- package/esm/src/evals/graders/code.d.ts +40 -0
- package/esm/src/evals/graders/code.js +184 -0
- package/esm/src/evals/graders/judge.d.ts +24 -0
- package/esm/src/evals/graders/judge.js +367 -0
- package/esm/src/evals/graders/latency.d.ts +6 -0
- package/esm/src/evals/graders/latency.js +82 -0
- package/esm/src/evals/graders/live.d.ts +14 -0
- package/esm/src/evals/graders/live.js +42 -0
- package/esm/src/evals/graders/media.d.ts +18 -0
- package/esm/src/evals/graders/media.js +91 -0
- package/esm/src/evals/graders/shared.d.ts +11 -0
- package/esm/src/evals/graders/shared.js +62 -0
- package/esm/src/evals/graders/transcript.d.ts +19 -0
- package/esm/src/evals/graders/transcript.js +202 -0
- package/esm/src/evals/mod.d.ts +34 -0
- package/esm/src/evals/mod.js +22 -0
- package/esm/src/evals/record.d.ts +41 -0
- package/esm/src/evals/record.js +107 -0
- package/esm/src/evals/rubrics/catalog.d.ts +148 -0
- package/esm/src/evals/rubrics/catalog.js +846 -0
- package/esm/src/evals/rubrics/mod.d.ts +24 -0
- package/esm/src/evals/rubrics/mod.js +55 -0
- package/esm/src/evals/rubrics/mustache.d.ts +23 -0
- package/esm/src/evals/rubrics/mustache.js +154 -0
- package/esm/src/evals/rubrics/types.d.ts +54 -0
- package/esm/src/evals/rubrics/types.js +74 -0
- package/esm/src/evals/run.d.ts +75 -0
- package/esm/src/evals/run.js +418 -0
- package/esm/src/evals/suite.d.ts +28 -0
- package/esm/src/evals/suite.js +97 -0
- package/esm/src/evals/summary.d.ts +35 -0
- package/esm/src/evals/summary.js +31 -0
- package/esm/src/evals/trial.d.ts +14 -0
- package/esm/src/evals/trial.js +135 -0
- package/esm/src/evals/types.d.ts +169 -0
- package/esm/src/evals/types.js +113 -0
- package/esm/src/evals/verdict.d.ts +23 -0
- package/esm/src/evals/verdict.js +48 -0
- package/esm/src/guardrails/boundaries.d.ts +41 -0
- package/esm/src/guardrails/boundaries.js +103 -0
- package/esm/src/guardrails/canary-gate.d.ts +22 -0
- package/esm/src/guardrails/canary-gate.js +40 -0
- package/esm/src/guardrails/canary.d.ts +146 -0
- package/esm/src/guardrails/canary.js +974 -0
- package/esm/src/guardrails/compile-egress.d.ts +12 -0
- package/esm/src/guardrails/compile-egress.js +12 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.d.ts +24 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.js +305 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.d.ts +5 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.js +199 -0
- package/esm/src/guardrails/corpus/inbound-payloads.d.ts +5 -0
- package/esm/src/guardrails/corpus/inbound-payloads.js +120 -0
- package/esm/src/guardrails/corpus/live-attacks.d.ts +15 -0
- package/esm/src/guardrails/corpus/live-attacks.js +229 -0
- package/esm/src/guardrails/corpus/mod.d.ts +7 -0
- package/esm/src/guardrails/corpus/mod.js +4 -0
- package/esm/src/guardrails/corpus/secrets.d.ts +12 -0
- package/esm/src/guardrails/corpus/secrets.js +16 -0
- package/esm/src/guardrails/corpus/strings.d.ts +23 -0
- package/esm/src/guardrails/corpus/strings.js +29 -0
- package/esm/src/guardrails/corpus/types.d.ts +36 -0
- package/esm/src/guardrails/corpus/types.js +1 -0
- package/esm/src/guardrails/credential-rules.d.ts +36 -0
- package/esm/src/guardrails/credential-rules.js +3001 -0
- package/esm/src/guardrails/credential-scan.d.ts +45 -0
- package/esm/src/guardrails/credential-scan.js +172 -0
- package/esm/src/guardrails/destinations.d.ts +45 -0
- package/esm/src/guardrails/destinations.js +234 -0
- package/esm/src/guardrails/detect-at.d.ts +107 -0
- package/esm/src/guardrails/detect-at.js +434 -0
- package/esm/src/guardrails/detect-reply.d.ts +61 -0
- package/esm/src/guardrails/detect-reply.js +95 -0
- package/esm/src/guardrails/detect-stream.d.ts +33 -0
- package/esm/src/guardrails/detect-stream.js +77 -0
- package/esm/src/guardrails/detectors.d.ts +216 -0
- package/esm/src/guardrails/detectors.js +503 -0
- package/esm/src/guardrails/egress-automata.d.ts +12 -0
- package/esm/src/guardrails/egress-automata.js +25582 -0
- package/esm/src/guardrails/egress-compiler.d.ts +55 -0
- package/esm/src/guardrails/egress-compiler.js +431 -0
- package/esm/src/guardrails/egress-patterns.d.ts +26 -0
- package/esm/src/guardrails/egress-patterns.js +36 -0
- package/esm/src/guardrails/egress-stream.d.ts +123 -0
- package/esm/src/guardrails/egress-stream.js +774 -0
- package/esm/src/guardrails/egress-urls.d.ts +86 -0
- package/esm/src/guardrails/egress-urls.js +909 -0
- package/esm/src/guardrails/egress.d.ts +46 -0
- package/esm/src/guardrails/egress.js +124 -0
- package/esm/src/guardrails/error.d.ts +31 -0
- package/esm/src/guardrails/error.js +96 -0
- package/esm/src/guardrails/event-schemas.d.ts +100 -0
- package/esm/src/guardrails/event-schemas.js +48 -0
- package/esm/src/guardrails/events.d.ts +13 -0
- package/esm/src/guardrails/events.js +45 -0
- package/esm/src/guardrails/hints.d.ts +14 -0
- package/esm/src/guardrails/hints.js +57 -0
- package/esm/src/guardrails/hits.d.ts +14 -0
- package/esm/src/guardrails/hits.js +30 -0
- package/esm/src/guardrails/host-patterns.d.ts +85 -0
- package/esm/src/guardrails/host-patterns.js +173 -0
- package/esm/src/guardrails/injection-patterns.d.ts +20 -0
- package/esm/src/guardrails/injection-patterns.js +126 -0
- package/esm/src/guardrails/injection-reversed.d.ts +9 -0
- package/esm/src/guardrails/injection-reversed.js +49 -0
- package/esm/src/guardrails/injection.d.ts +30 -0
- package/esm/src/guardrails/injection.js +460 -0
- package/esm/src/guardrails/labels.d.ts +40 -0
- package/esm/src/guardrails/labels.js +874 -0
- package/esm/src/guardrails/live-outbound-gate.d.ts +55 -0
- package/esm/src/guardrails/live-outbound-gate.js +298 -0
- package/esm/src/guardrails/mod.d.ts +54 -0
- package/esm/src/guardrails/mod.js +34 -0
- package/esm/src/guardrails/network.d.ts +46 -0
- package/esm/src/guardrails/network.js +330 -0
- package/esm/src/guardrails/normalize.d.ts +20 -0
- package/esm/src/guardrails/normalize.js +165 -0
- package/esm/src/guardrails/policy.d.ts +4 -0
- package/esm/src/guardrails/policy.js +21 -0
- package/esm/src/guardrails/progressive-yield.d.ts +110 -0
- package/esm/src/guardrails/progressive-yield.js +281 -0
- package/esm/src/guardrails/prompt-echo.d.ts +40 -0
- package/esm/src/guardrails/prompt-echo.js +306 -0
- package/esm/src/guardrails/quota.d.ts +21 -0
- package/esm/src/guardrails/quota.js +80 -0
- package/esm/src/guardrails/rules.d.ts +47 -0
- package/esm/src/guardrails/rules.js +47 -0
- package/esm/src/guardrails/sanitize.d.ts +40 -0
- package/esm/src/guardrails/sanitize.js +160 -0
- package/esm/src/guardrails/sensitive-groups.d.ts +21 -0
- package/esm/src/guardrails/sensitive-groups.js +12 -0
- package/esm/src/guardrails/sensitive.d.ts +22 -0
- package/esm/src/guardrails/sensitive.js +234 -0
- package/esm/src/guardrails/serialize.d.ts +15 -0
- package/esm/src/guardrails/serialize.js +37 -0
- package/esm/src/guardrails/testing.d.ts +11 -0
- package/esm/src/guardrails/testing.js +10 -0
- package/esm/src/guardrails/theorem-error.d.ts +21 -0
- package/esm/src/guardrails/theorem-error.js +54 -0
- package/esm/src/guardrails/thought-guard.d.ts +76 -0
- package/esm/src/guardrails/thought-guard.js +664 -0
- package/esm/src/guardrails/tool-directives.d.ts +38 -0
- package/esm/src/guardrails/tool-directives.js +195 -0
- package/esm/src/guardrails/tool-leak.d.ts +26 -0
- package/esm/src/guardrails/tool-leak.js +45 -0
- package/esm/src/guardrails/tool-result.d.ts +92 -0
- package/esm/src/guardrails/tool-result.js +272 -0
- package/esm/src/guardrails/types.d.ts +250 -0
- package/esm/src/guardrails/types.js +58 -0
- package/esm/src/host/client-turn.d.ts +36 -0
- package/esm/src/host/client-turn.js +80 -0
- package/esm/src/host/mint-trace.d.ts +29 -0
- package/esm/src/host/mint-trace.js +60 -0
- package/esm/src/host/mod.d.ts +13 -0
- package/esm/src/host/mod.js +11 -0
- package/esm/src/host/readStreamingJsonStringField.d.ts +2 -0
- package/esm/src/host/readStreamingJsonStringField.js +27 -0
- package/esm/src/host/reply.d.ts +13 -0
- package/esm/src/host/reply.js +41 -0
- package/esm/src/interface/blocks.d.ts +11 -0
- package/esm/src/interface/blocks.js +283 -0
- package/esm/src/interface/composer-actions.d.ts +24 -0
- package/esm/src/interface/composer-actions.js +33 -0
- package/esm/src/interface/draft.d.ts +20 -0
- package/esm/src/interface/draft.js +39 -0
- package/esm/src/interface/from-profile.d.ts +24 -0
- package/esm/src/interface/from-profile.js +179 -0
- package/esm/src/interface/history.d.ts +46 -0
- package/esm/src/interface/history.js +278 -0
- package/esm/src/interface/inputs.d.ts +11 -0
- package/esm/src/interface/inputs.js +67 -0
- package/esm/src/interface/mod.d.ts +33 -0
- package/esm/src/interface/mod.js +22 -0
- package/esm/src/interface/models.d.ts +26 -0
- package/esm/src/interface/models.js +50 -0
- package/esm/src/interface/pending.d.ts +57 -0
- package/esm/src/interface/pending.js +152 -0
- package/esm/src/interface/profile-interface.d.ts +4 -0
- package/esm/src/interface/profile-interface.js +237 -0
- package/esm/src/interface/session.d.ts +71 -0
- package/esm/src/interface/session.js +128 -0
- package/esm/src/interface/stop.d.ts +13 -0
- package/esm/src/interface/stop.js +28 -0
- package/esm/src/interface/tool-calls.d.ts +32 -0
- package/esm/src/interface/tool-calls.js +127 -0
- package/esm/src/interface/tool-invoke.d.ts +6 -0
- package/esm/src/interface/tool-invoke.js +22 -0
- package/esm/src/interface/tool-media.d.ts +11 -0
- package/esm/src/interface/tool-media.js +113 -0
- package/esm/src/interface/types.d.ts +278 -0
- package/esm/src/interface/types.js +5 -0
- package/esm/src/kernel/api-catalog.d.ts +85 -0
- package/esm/src/kernel/api-catalog.js +229 -0
- package/esm/src/kernel/auth/credential-source.d.ts +23 -0
- package/esm/src/kernel/auth/credential-source.js +11 -0
- package/esm/src/kernel/auth/crypto.d.ts +56 -0
- package/esm/src/kernel/auth/crypto.js +163 -0
- package/esm/src/kernel/auth/mod.d.ts +5 -0
- package/esm/src/kernel/auth/mod.js +5 -0
- package/esm/src/kernel/auth/oauth.d.ts +18 -0
- package/esm/src/kernel/auth/oauth.js +439 -0
- package/esm/src/kernel/auth/scope-refusal.d.ts +9 -0
- package/esm/src/kernel/auth/scope-refusal.js +8 -0
- package/esm/src/kernel/auth/typed-secret.d.ts +13 -0
- package/esm/src/kernel/auth/typed-secret.js +23 -0
- package/esm/src/kernel/auth/types.d.ts +152 -0
- package/esm/src/kernel/auth/types.js +1 -0
- package/esm/src/kernel/checkpoint.d.ts +43 -0
- package/esm/src/kernel/checkpoint.js +58 -0
- package/esm/src/kernel/default-scope.d.ts +72 -0
- package/esm/src/kernel/default-scope.js +121 -0
- package/esm/src/kernel/engine/call-trace.d.ts +19 -0
- package/esm/src/kernel/engine/call-trace.js +29 -0
- package/esm/src/kernel/engine/compaction.d.ts +71 -0
- package/esm/src/kernel/engine/compaction.js +203 -0
- package/esm/src/kernel/engine/decision.d.ts +43 -0
- package/esm/src/kernel/engine/decision.js +439 -0
- package/esm/src/kernel/engine/embedding.d.ts +8 -0
- package/esm/src/kernel/engine/embedding.js +118 -0
- package/esm/src/kernel/engine/hash.d.ts +6 -0
- package/esm/src/kernel/engine/hash.js +22 -0
- package/esm/src/kernel/engine/live-inbound.d.ts +19 -0
- package/esm/src/kernel/engine/live-inbound.js +44 -0
- package/esm/src/kernel/engine/live-ingress.d.ts +15 -0
- package/esm/src/kernel/engine/live-ingress.js +42 -0
- package/esm/src/kernel/engine/record.d.ts +3 -0
- package/esm/src/kernel/engine/record.js +11 -0
- package/esm/src/kernel/engine/repair.d.ts +7 -0
- package/esm/src/kernel/engine/repair.js +36 -0
- package/esm/src/kernel/engine/runner/gates.d.ts +5 -0
- package/esm/src/kernel/engine/runner/gates.js +508 -0
- package/esm/src/kernel/engine/runner/mod.d.ts +29 -0
- package/esm/src/kernel/engine/runner/mod.js +625 -0
- package/esm/src/kernel/engine/runner/nested.d.ts +32 -0
- package/esm/src/kernel/engine/runner/nested.js +134 -0
- package/esm/src/kernel/engine/runner/schema-validation.d.ts +35 -0
- package/esm/src/kernel/engine/runner/schema-validation.js +179 -0
- package/esm/src/kernel/engine/runner/stages.d.ts +28 -0
- package/esm/src/kernel/engine/runner/stages.js +41 -0
- package/esm/src/kernel/engine/runner/state.d.ts +97 -0
- package/esm/src/kernel/engine/runner/state.js +50 -0
- package/esm/src/kernel/engine/runner/step-order.d.ts +27 -0
- package/esm/src/kernel/engine/runner/step-order.js +165 -0
- package/esm/src/kernel/engine/runner/steps.d.ts +14 -0
- package/esm/src/kernel/engine/runner/steps.js +519 -0
- package/esm/src/kernel/engine/runner/stream.d.ts +71 -0
- package/esm/src/kernel/engine/runner/stream.js +376 -0
- package/esm/src/kernel/engine/runner/usage.d.ts +45 -0
- package/esm/src/kernel/engine/runner/usage.js +148 -0
- package/esm/src/kernel/engine/session/mod.d.ts +33 -0
- package/esm/src/kernel/engine/session/mod.js +1182 -0
- package/esm/src/kernel/engine/session/session-trace.d.ts +115 -0
- package/esm/src/kernel/engine/session/session-trace.js +500 -0
- package/esm/src/kernel/engine/token-estimate.d.ts +23 -0
- package/esm/src/kernel/engine/token-estimate.js +38 -0
- package/esm/src/kernel/engine/tool-trace.d.ts +58 -0
- package/esm/src/kernel/engine/tool-trace.js +132 -0
- package/esm/src/kernel/engine/tree.d.ts +2 -0
- package/esm/src/kernel/engine/tree.js +17 -0
- package/esm/src/kernel/engine/turn-trace.d.ts +119 -0
- package/esm/src/kernel/engine/turn-trace.js +855 -0
- package/esm/src/kernel/engine/usage.d.ts +36 -0
- package/esm/src/kernel/engine/usage.js +151 -0
- package/esm/src/kernel/interaction-parts.d.ts +13 -0
- package/esm/src/kernel/interaction-parts.js +40 -0
- package/esm/src/kernel/json.d.ts +10 -0
- package/esm/src/kernel/json.js +3 -0
- package/esm/src/kernel/mod.d.ts +74 -0
- package/esm/src/kernel/mod.js +45 -0
- package/esm/src/kernel/profile-graph.d.ts +145 -0
- package/esm/src/kernel/profile-graph.js +158 -0
- package/esm/src/kernel/profile-presence.d.ts +18 -0
- package/esm/src/kernel/profile-presence.js +158 -0
- package/esm/src/kernel/profile-scope.d.ts +40 -0
- package/esm/src/kernel/profile-scope.js +274 -0
- package/esm/src/kernel/protocols/binding.d.ts +65 -0
- package/esm/src/kernel/protocols/binding.js +125 -0
- package/esm/src/kernel/protocols/limits.d.ts +15 -0
- package/esm/src/kernel/protocols/limits.js +28 -0
- package/esm/src/kernel/protocols/mod.d.ts +5 -0
- package/esm/src/kernel/protocols/mod.js +5 -0
- package/esm/src/kernel/protocols/prices.d.ts +36 -0
- package/esm/src/kernel/protocols/prices.js +37 -0
- package/esm/src/kernel/protocols/protocol.d.ts +253 -0
- package/esm/src/kernel/protocols/protocol.js +253 -0
- package/esm/src/kernel/protocols/provider.d.ts +108 -0
- package/esm/src/kernel/protocols/provider.js +143 -0
- package/esm/src/kernel/protocols/runtime.d.ts +55 -0
- package/esm/src/kernel/protocols/runtime.js +534 -0
- package/esm/src/kernel/provider-budget.d.ts +32 -0
- package/esm/src/kernel/provider-budget.js +262 -0
- package/esm/src/kernel/provider-dispatch.d.ts +13 -0
- package/esm/src/kernel/provider-dispatch.js +36 -0
- package/esm/src/kernel/provider-live.d.ts +7 -0
- package/esm/src/kernel/provider-live.js +189 -0
- package/esm/src/kernel/provider-runtime.d.ts +57 -0
- package/esm/src/kernel/provider-runtime.js +524 -0
- package/esm/src/kernel/registry/attachments.d.ts +46 -0
- package/esm/src/kernel/registry/attachments.js +220 -0
- package/esm/src/kernel/registry/catalog.d.ts +25 -0
- package/esm/src/kernel/registry/catalog.js +85 -0
- package/esm/src/kernel/registry/embedding-rules.d.ts +28 -0
- package/esm/src/kernel/registry/embedding-rules.js +66 -0
- package/esm/src/kernel/registry/ingress.d.ts +12 -0
- package/esm/src/kernel/registry/ingress.js +179 -0
- package/esm/src/kernel/registry/kernel-registry.d.ts +15 -0
- package/esm/src/kernel/registry/kernel-registry.js +15 -0
- package/esm/src/kernel/registry/profile-outputs.d.ts +3 -0
- package/esm/src/kernel/registry/profile-outputs.js +10 -0
- package/esm/src/kernel/registry/profiles.d.ts +116 -0
- package/esm/src/kernel/registry/profiles.js +773 -0
- package/esm/src/kernel/registry/provider-request.d.ts +6 -0
- package/esm/src/kernel/registry/provider-request.js +34 -0
- package/esm/src/kernel/registry/resolve.d.ts +17 -0
- package/esm/src/kernel/registry/resolve.js +238 -0
- package/esm/src/kernel/registry/schemas.d.ts +12 -0
- package/esm/src/kernel/registry/schemas.js +27 -0
- package/esm/src/kernel/registry/slot-fill.d.ts +7 -0
- package/esm/src/kernel/registry/slot-fill.js +22 -0
- package/esm/src/kernel/registry/sole-model.d.ts +2 -0
- package/esm/src/kernel/registry/sole-model.js +4 -0
- package/esm/src/kernel/registry/system-prompt.d.ts +8 -0
- package/esm/src/kernel/registry/system-prompt.js +32 -0
- package/esm/src/kernel/registry/system-role.d.ts +3 -0
- package/esm/src/kernel/registry/system-role.js +9 -0
- package/esm/src/kernel/registry/vault.d.ts +14 -0
- package/esm/src/kernel/registry/vault.js +1 -0
- package/esm/src/kernel/schema.d.ts +226 -0
- package/esm/src/kernel/schema.js +895 -0
- package/esm/src/kernel/scope.d.ts +29 -0
- package/esm/src/kernel/scope.js +45 -0
- package/esm/src/kernel/stages.d.ts +176 -0
- package/esm/src/kernel/stages.js +431 -0
- package/esm/src/kernel/stop.d.ts +116 -0
- package/esm/src/kernel/stop.js +137 -0
- package/esm/src/kernel/system-parts.d.ts +26 -0
- package/esm/src/kernel/system-parts.js +98 -0
- package/esm/src/kernel/tools/activity-label.d.ts +22 -0
- package/esm/src/kernel/tools/activity-label.js +435 -0
- package/esm/src/kernel/tools/agent.d.ts +66 -0
- package/esm/src/kernel/tools/agent.js +212 -0
- package/esm/src/kernel/tools/coordinate.d.ts +4 -0
- package/esm/src/kernel/tools/coordinate.js +165 -0
- package/esm/src/kernel/tools/events.d.ts +66 -0
- package/esm/src/kernel/tools/events.js +184 -0
- package/esm/src/kernel/tools/execute.d.ts +100 -0
- package/esm/src/kernel/tools/execute.js +1173 -0
- package/esm/src/kernel/tools/gate-answer.d.ts +60 -0
- package/esm/src/kernel/tools/gate-answer.js +65 -0
- package/esm/src/kernel/tools/handler-events.d.ts +45 -0
- package/esm/src/kernel/tools/handler-events.js +106 -0
- package/esm/src/kernel/tools/harness.d.ts +17 -0
- package/esm/src/kernel/tools/harness.js +43 -0
- package/esm/src/kernel/tools/http-limit.d.ts +27 -0
- package/esm/src/kernel/tools/http-limit.js +85 -0
- package/esm/src/kernel/tools/invoke.d.ts +32 -0
- package/esm/src/kernel/tools/invoke.js +282 -0
- package/esm/src/kernel/tools/mcp-sessions.d.ts +23 -0
- package/esm/src/kernel/tools/mcp-sessions.js +69 -0
- package/esm/src/kernel/tools/mod.d.ts +10 -0
- package/esm/src/kernel/tools/mod.js +7 -0
- package/esm/src/kernel/tools/model-text.d.ts +16 -0
- package/esm/src/kernel/tools/model-text.js +31 -0
- package/esm/src/kernel/tools/operation.d.ts +76 -0
- package/esm/src/kernel/tools/operation.js +100 -0
- package/esm/src/kernel/tools/page-answer.d.ts +8 -0
- package/esm/src/kernel/tools/page-answer.js +19 -0
- package/esm/src/kernel/tools/permission.d.ts +15 -0
- package/esm/src/kernel/tools/permission.js +38 -0
- package/esm/src/kernel/tools/project.d.ts +11 -0
- package/esm/src/kernel/tools/project.js +55 -0
- package/esm/src/kernel/tools/registry.d.ts +27 -0
- package/esm/src/kernel/tools/registry.js +143 -0
- package/esm/src/kernel/tools/remote.d.ts +144 -0
- package/esm/src/kernel/tools/remote.js +1125 -0
- package/esm/src/kernel/tools/resolve.d.ts +31 -0
- package/esm/src/kernel/tools/resolve.js +267 -0
- package/esm/src/kernel/tools/run.d.ts +28 -0
- package/esm/src/kernel/tools/run.js +86 -0
- package/esm/src/kernel/tools/schema.d.ts +10 -0
- package/esm/src/kernel/tools/schema.js +95 -0
- package/esm/src/kernel/tools/signed-in-fetch.d.ts +19 -0
- package/esm/src/kernel/tools/signed-in-fetch.js +45 -0
- package/esm/src/kernel/tools/stage-run.d.ts +116 -0
- package/esm/src/kernel/tools/stage-run.js +198 -0
- package/esm/src/kernel/tools/types.d.ts +497 -0
- package/esm/src/kernel/tools/types.js +1 -0
- package/esm/src/kernel/tools/unchecked-output.d.ts +14 -0
- package/esm/src/kernel/tools/unchecked-output.js +18 -0
- package/esm/src/kernel/turn-events.d.ts +776 -0
- package/esm/src/kernel/turn-events.js +543 -0
- package/esm/src/kernel/types.d.ts +1025 -0
- package/esm/src/kernel/types.js +1 -0
- package/esm/src/kernel/util/base64.d.ts +4 -0
- package/esm/src/kernel/util/base64.js +15 -0
- package/esm/src/kernel/util/exact-type.d.ts +31 -0
- package/esm/src/kernel/util/exact-type.js +1 -0
- package/esm/src/kernel/util/find-last.d.ts +3 -0
- package/esm/src/kernel/util/find-last.js +9 -0
- package/esm/src/kernel/util/mime.d.ts +2 -0
- package/esm/src/kernel/util/mime.js +4 -0
- package/esm/src/kernel/util/partial-json.d.ts +23 -0
- package/esm/src/kernel/util/partial-json.js +128 -0
- package/esm/src/kernel/util/record.d.ts +2 -0
- package/esm/src/kernel/util/record.js +4 -0
- package/esm/src/observability/destinations.d.ts +14 -0
- package/esm/src/observability/destinations.js +43 -0
- package/esm/src/observability/jsonl.d.ts +18 -0
- package/esm/src/observability/jsonl.js +110 -0
- package/esm/src/observability/mod.d.ts +22 -0
- package/esm/src/observability/mod.js +16 -0
- package/esm/src/observability/openinference.d.ts +11 -0
- package/esm/src/observability/openinference.js +205 -0
- package/esm/src/observability/otlp.d.ts +71 -0
- package/esm/src/observability/otlp.js +98 -0
- package/esm/src/observability/phoenix.d.ts +30 -0
- package/esm/src/observability/phoenix.js +71 -0
- package/esm/src/observability/policy.d.ts +17 -0
- package/esm/src/observability/policy.js +73 -0
- package/esm/src/observability/resolve-policy.d.ts +8 -0
- package/esm/src/observability/resolve-policy.js +64 -0
- package/esm/src/observability/spans.d.ts +22 -0
- package/esm/src/observability/spans.js +72 -0
- package/esm/src/observability/trace-catalog.d.ts +128 -0
- package/esm/src/observability/trace-catalog.js +906 -0
- package/esm/src/observability/trace-record.d.ts +23 -0
- package/esm/src/observability/trace-record.js +228 -0
- package/esm/src/observability/trace-schema.d.ts +57 -0
- package/esm/src/observability/trace-schema.js +59 -0
- package/esm/src/observability/trace-sink.d.ts +14 -0
- package/esm/src/observability/trace-sink.js +3 -0
- package/esm/src/observability/trace-span.d.ts +98 -0
- package/esm/src/observability/trace-span.js +201 -0
- package/esm/src/observability/trace.d.ts +13 -0
- package/esm/src/observability/trace.js +37 -0
- package/esm/src/observability/types.d.ts +109 -0
- package/esm/src/observability/types.js +3 -0
- package/esm/src/presets/google/speech-voices.d.ts +9 -0
- package/esm/src/presets/google/speech-voices.js +38 -0
- package/esm/src/presets/google-limits.d.ts +13 -0
- package/esm/src/presets/google-limits.js +18 -0
- package/esm/src/presets/google.d.ts +119 -0
- package/esm/src/presets/google.js +197 -0
- package/esm/src/presets/local.d.ts +26 -0
- package/esm/src/presets/local.js +30 -0
- package/esm/src/presets/mod.d.ts +11 -0
- package/esm/src/presets/mod.js +9 -0
- package/esm/src/presets/openrouter.d.ts +26 -0
- package/esm/src/presets/openrouter.js +31 -0
- package/esm/src/providers/embedding-limits.d.ts +7 -0
- package/esm/src/providers/embedding-limits.js +12 -0
- package/esm/src/providers/gemini/embedding-protocol.d.ts +8 -0
- package/esm/src/providers/gemini/embedding-protocol.js +125 -0
- package/esm/src/providers/gemini/interactions-protocol.d.ts +8 -0
- package/esm/src/providers/gemini/interactions-protocol.js +105 -0
- package/esm/src/providers/gemini/live-protocol.d.ts +3 -0
- package/esm/src/providers/gemini/live-protocol.js +191 -0
- package/esm/src/providers/gemini/prices.d.ts +3 -0
- package/esm/src/providers/gemini/prices.js +63 -0
- package/esm/src/providers/gemini/provider.d.ts +7 -0
- package/esm/src/providers/gemini/provider.js +39 -0
- package/esm/src/providers/google/api-error.d.ts +8 -0
- package/esm/src/providers/google/api-error.js +123 -0
- package/esm/src/providers/google/builtins.d.ts +14 -0
- package/esm/src/providers/google/builtins.js +57 -0
- package/esm/src/providers/google/grounding.d.ts +5 -0
- package/esm/src/providers/google/grounding.js +226 -0
- package/esm/src/providers/google/interactions/framing.d.ts +27 -0
- package/esm/src/providers/google/interactions/framing.js +304 -0
- package/esm/src/providers/google/interactions/steps.d.ts +12 -0
- package/esm/src/providers/google/interactions/steps.js +200 -0
- package/esm/src/providers/google/interactions/stream.d.ts +23 -0
- package/esm/src/providers/google/interactions/stream.js +230 -0
- package/esm/src/providers/google/live/framing.d.ts +61 -0
- package/esm/src/providers/google/live/framing.js +597 -0
- package/esm/src/providers/google/live/stream.d.ts +13 -0
- package/esm/src/providers/google/live/stream.js +57 -0
- package/esm/src/providers/google/thinking.d.ts +3 -0
- package/esm/src/providers/google/thinking.js +8 -0
- package/esm/src/providers/google/urls.d.ts +4 -0
- package/esm/src/providers/google/urls.js +4 -0
- package/esm/src/providers/google/usage.d.ts +7 -0
- package/esm/src/providers/google/usage.js +49 -0
- package/esm/src/providers/live.d.ts +6 -0
- package/esm/src/providers/live.js +6 -0
- package/esm/src/providers/local/embedding-protocol.d.ts +7 -0
- package/esm/src/providers/local/embedding-protocol.js +60 -0
- package/esm/src/providers/local/provider.d.ts +7 -0
- package/esm/src/providers/local/provider.js +28 -0
- package/esm/src/providers/mod.d.ts +32 -0
- package/esm/src/providers/mod.js +23 -0
- package/esm/src/providers/open-ai/protocol.d.ts +3 -0
- package/esm/src/providers/open-ai/protocol.js +189 -0
- package/esm/src/providers/openrouter/embedding-protocol.d.ts +6 -0
- package/esm/src/providers/openrouter/embedding-protocol.js +86 -0
- package/esm/src/providers/openrouter/image.d.ts +15 -0
- package/esm/src/providers/openrouter/image.js +34 -0
- package/esm/src/providers/openrouter/images-protocol.d.ts +3 -0
- package/esm/src/providers/openrouter/images-protocol.js +82 -0
- package/esm/src/providers/openrouter/openai/compat.d.ts +19 -0
- package/esm/src/providers/openrouter/openai/compat.js +162 -0
- package/esm/src/providers/openrouter/openai/image-payload.d.ts +9 -0
- package/esm/src/providers/openrouter/openai/image-payload.js +115 -0
- package/esm/src/providers/openrouter/openai/reasoning-state.d.ts +2 -0
- package/esm/src/providers/openrouter/openai/reasoning-state.js +31 -0
- package/esm/src/providers/openrouter/openai/usage.d.ts +8 -0
- package/esm/src/providers/openrouter/openai/usage.js +56 -0
- package/esm/src/providers/openrouter/protocol.d.ts +8 -0
- package/esm/src/providers/openrouter/protocol.js +171 -0
- package/esm/src/providers/openrouter/provider.d.ts +10 -0
- package/esm/src/providers/openrouter/provider.js +50 -0
- package/esm/src/providers/shared/carried-tool-files.d.ts +7 -0
- package/esm/src/providers/shared/carried-tool-files.js +43 -0
- package/esm/src/providers/shared/pcm.d.ts +14 -0
- package/esm/src/providers/shared/pcm.js +78 -0
- package/esm/src/providers/shared/protocol-events.d.ts +8 -0
- package/esm/src/providers/shared/protocol-events.js +20 -0
- package/esm/src/providers/shared/response-identity.d.ts +11 -0
- package/esm/src/providers/shared/response-identity.js +12 -0
- package/esm/src/providers/shared/retry.d.ts +17 -0
- package/esm/src/providers/shared/retry.js +90 -0
- package/esm/src/providers/shared/sse.d.ts +6 -0
- package/esm/src/providers/shared/sse.js +93 -0
- package/esm/src/providers/shared/structured-output.d.ts +4 -0
- package/esm/src/providers/shared/structured-output.js +11 -0
- package/esm/src/providers/shared/tool-args.d.ts +24 -0
- package/esm/src/providers/shared/tool-args.js +88 -0
- package/esm/src/providers/shared/tool-draft.d.ts +16 -0
- package/esm/src/providers/shared/tool-draft.js +14 -0
- package/esm/src/providers/shared/upstream-tap.d.ts +8 -0
- package/esm/src/providers/shared/upstream-tap.js +85 -0
- package/esm/src/providers/shared/upstream-tape.d.ts +6 -0
- package/esm/src/providers/shared/upstream-tape.js +88 -0
- package/esm/src/providers/system-one/protocol.d.ts +8 -0
- package/esm/src/providers/system-one/protocol.js +93 -0
- package/esm/src/providers/types.d.ts +51 -0
- package/esm/src/providers/types.js +2 -0
- package/esm/src/providers/typesafe/provider.d.ts +7 -0
- package/esm/src/providers/typesafe/provider.js +24 -0
- package/esm/src/surface/formats.d.ts +46 -0
- package/esm/src/surface/formats.js +178 -0
- package/esm/src/surface/mod.d.ts +16 -0
- package/esm/src/surface/mod.js +12 -0
- package/esm/src/surface/runtime.d.ts +44 -0
- package/esm/src/surface/runtime.js +441 -0
- package/esm/src/surface/tools.d.ts +9 -0
- package/esm/src/surface/tools.js +62 -0
- package/esm/src/surface/types.d.ts +110 -0
- package/esm/src/surface/types.js +4 -0
- package/package.json +100 -4
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { groupSummaries } from '../../evals/breakdown.js';
|
|
2
|
+
import { runSuite } from '../../evals/run.js';
|
|
3
|
+
import { loadSuite, readTraceRecords } from '../../evals/suite.js';
|
|
4
|
+
import { summarizeRun } from '../../evals/summary.js';
|
|
5
|
+
import { jsonlSink } from '../../observability/jsonl.js';
|
|
6
|
+
const GREEN = '\x1b[32m';
|
|
7
|
+
const RED = '\x1b[31m';
|
|
8
|
+
const DIM = '\x1b[2m';
|
|
9
|
+
const YELLOW = '\x1b[33m';
|
|
10
|
+
const RESET = '\x1b[0m';
|
|
11
|
+
function failed(message) {
|
|
12
|
+
console.error(`\n${RED}Eval Failed${RESET}: ${message}\n`);
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
/** Passed over decided cases: a case every trial of which errored is not a failure. */
|
|
16
|
+
function fraction(run) {
|
|
17
|
+
const decided = run.verdicts.filter((verdict) => verdict.decided);
|
|
18
|
+
if (decided.length === 0)
|
|
19
|
+
return 0;
|
|
20
|
+
return decided.filter((verdict) => verdict.passed).length / decided.length;
|
|
21
|
+
}
|
|
22
|
+
/** `part/whole pct`, with what the pass rate leaves out after it. */
|
|
23
|
+
function rate(part, whole, left, what) {
|
|
24
|
+
return `${part}/${whole} ${percent(part, whole)}${left > 0 ? ` (+${left} ${what})` : ''}`;
|
|
25
|
+
}
|
|
26
|
+
function blame(report) {
|
|
27
|
+
return report.results.flatMap((result) => {
|
|
28
|
+
if (result.passed === true)
|
|
29
|
+
return [];
|
|
30
|
+
if (result.errorType) {
|
|
31
|
+
const why = result.explanation ? ` (${result.explanation})` : '';
|
|
32
|
+
return [`${result.name}: ${result.errorType}${why}`];
|
|
33
|
+
}
|
|
34
|
+
if (result.passed === false)
|
|
35
|
+
return [`${result.name}: ${result.explanation ?? 'failed'}`];
|
|
36
|
+
return [];
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** The run's cost, never a zero standing in for calls whose provider reported none. */
|
|
40
|
+
function costLine(run) {
|
|
41
|
+
if (run.unpriced === 0)
|
|
42
|
+
return `cost $${run.costUsd.toFixed(4)}`;
|
|
43
|
+
const calls = `${run.unpriced} call${run.unpriced === 1 ? '' : 's'}`;
|
|
44
|
+
if (run.priced === 0)
|
|
45
|
+
return `cost not reported (${calls})`;
|
|
46
|
+
return `cost $${run.costUsd.toFixed(4)}, plus ${calls} whose cost went unreported`;
|
|
47
|
+
}
|
|
48
|
+
/** What a case passing means under the rule, over `k` trials. */
|
|
49
|
+
function ruleName(rule) {
|
|
50
|
+
if (rule === 'all')
|
|
51
|
+
return 'pass^k';
|
|
52
|
+
if (rule === 'any')
|
|
53
|
+
return 'pass@k';
|
|
54
|
+
return `>=${rule.atLeast}/k`;
|
|
55
|
+
}
|
|
56
|
+
function percent(part, whole) {
|
|
57
|
+
return whole === 0 ? '-' : `${Math.round((part / whole) * 100)}%`;
|
|
58
|
+
}
|
|
59
|
+
function spreadText(spread, unit = '') {
|
|
60
|
+
return spread ? `${spread.median}${unit} / ${spread.p90}${unit}` : '-';
|
|
61
|
+
}
|
|
62
|
+
/** Every cased trial, then each tag's: how often right, how consistently, how long, how many loops. */
|
|
63
|
+
function printGroups(run) {
|
|
64
|
+
const groups = groupSummaries(run);
|
|
65
|
+
const rows = groups.map((group) => [
|
|
66
|
+
group.group,
|
|
67
|
+
rate(group.casesPassed, group.cases - group.casesUndecided, group.casesUndecided, 'undecided'),
|
|
68
|
+
rate(group.trialsPassed, group.trials - group.trialsErrored, group.trialsErrored, 'errored'),
|
|
69
|
+
group.answers
|
|
70
|
+
? `${group.answers.accepted}/${group.answers.partial}/${group.answers.wrong}${group.answers.none > 0 ? ` (+${group.answers.none} none)` : ''}`
|
|
71
|
+
: '-',
|
|
72
|
+
spreadText(group.durationMs, 'ms'),
|
|
73
|
+
spreadText(group.modelCalls),
|
|
74
|
+
spreadText(group.toolCalls),
|
|
75
|
+
Object.entries(group.stops)
|
|
76
|
+
.toSorted(([a], [b]) => a.localeCompare(b))
|
|
77
|
+
.map(([stop, count]) => `${stop} ${count}`)
|
|
78
|
+
.join(', ') || '-',
|
|
79
|
+
]);
|
|
80
|
+
const header = [
|
|
81
|
+
'group',
|
|
82
|
+
`cases ${ruleName(run.passRule)}`,
|
|
83
|
+
'trials passed',
|
|
84
|
+
'accepted/partial/wrong',
|
|
85
|
+
'turn median / p90',
|
|
86
|
+
'model calls',
|
|
87
|
+
'tool calls',
|
|
88
|
+
'stops',
|
|
89
|
+
];
|
|
90
|
+
const widths = header.map((title, column) => Math.max(title.length, ...rows.map((row) => row[column]?.length ?? 0)));
|
|
91
|
+
const line = (cells) => ` ${cells.map((cell, column) => cell.padEnd(widths[column] ?? 0)).join(' ')}`;
|
|
92
|
+
console.log('');
|
|
93
|
+
console.log(line(header));
|
|
94
|
+
for (const row of rows)
|
|
95
|
+
console.log(line(row));
|
|
96
|
+
}
|
|
97
|
+
function printTable(run) {
|
|
98
|
+
const width = Math.max(4, ...run.verdicts.map((verdict) => verdict.case.length));
|
|
99
|
+
console.log(`\n▶ [EVAL] Suite: ${run.suite} (${run.mode}, ${run.repeat} trials per case)\n`);
|
|
100
|
+
console.log(` ${'case'.padEnd(width)} kind passed result`);
|
|
101
|
+
for (const verdict of run.verdicts) {
|
|
102
|
+
const mark = verdict.passed
|
|
103
|
+
? `${GREEN}pass${RESET}`
|
|
104
|
+
: verdict.decided
|
|
105
|
+
? `${RED}fail${RESET}`
|
|
106
|
+
: `${YELLOW}undecided${RESET}`;
|
|
107
|
+
const counts = `${verdict.trialsPassed}/${verdict.trials - verdict.trialsErrored}`;
|
|
108
|
+
const extra = [
|
|
109
|
+
verdict.trialsErrored > 0 ? `${verdict.trialsErrored} errored` : '',
|
|
110
|
+
verdict.trialsUngraded > 0 ? `${verdict.trialsUngraded} ungraded` : '',
|
|
111
|
+
]
|
|
112
|
+
.filter(Boolean)
|
|
113
|
+
.join(', ');
|
|
114
|
+
console.log(` ${verdict.case.padEnd(width)} ${verdict.kind.padEnd(10)} ${counts.padEnd(6)} ${mark}${extra ? ` ${DIM}(${extra})${RESET}` : ''}`);
|
|
115
|
+
}
|
|
116
|
+
for (const verdict of run.verdicts) {
|
|
117
|
+
if (verdict.passed)
|
|
118
|
+
continue;
|
|
119
|
+
const reports = run.trials.filter((report) => report.case?.id === verdict.case);
|
|
120
|
+
for (const report of reports) {
|
|
121
|
+
const reasons = blame(report);
|
|
122
|
+
if (reasons.length === 0)
|
|
123
|
+
continue;
|
|
124
|
+
console.log(`\n ${verdict.case} trial ${report.index}:`);
|
|
125
|
+
for (const reason of reasons)
|
|
126
|
+
console.log(` ${DIM}·${RESET} ${reason}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (run.caseless.length > 0) {
|
|
130
|
+
console.log(`\n ${DIM}${run.caseless.length} trace(s) carried no case stamp for this suite; graded without a case, no verdict.${RESET}`);
|
|
131
|
+
}
|
|
132
|
+
printGroups(run);
|
|
133
|
+
const passed = run.verdicts.filter((verdict) => verdict.passed).length;
|
|
134
|
+
const decided = run.verdicts.filter((verdict) => verdict.decided).length;
|
|
135
|
+
const undecided = run.verdicts.length - decided;
|
|
136
|
+
console.log(`\n ${passed}/${decided} cases passed${undecided > 0 ? ` (+${undecided} undecided)` : ''}; ${costLine(run)}`);
|
|
137
|
+
if (run.stopped)
|
|
138
|
+
console.log(` ${YELLOW}stopped on ${run.stopped}${RESET}`);
|
|
139
|
+
for (const warning of run.warnings)
|
|
140
|
+
console.log(` ${YELLOW}warning${RESET}: ${warning}`);
|
|
141
|
+
console.log('');
|
|
142
|
+
}
|
|
143
|
+
function printJson(run) {
|
|
144
|
+
console.log(JSON.stringify(summarizeRun(run), null, 2));
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Returns whether the run met the threshold; a run stopped on budget never does. The CLI never
|
|
148
|
+
* creates a provider or reads a key: the host passes them or the suite module exports them.
|
|
149
|
+
*/
|
|
150
|
+
export async function evalCommand(options, host = {}) {
|
|
151
|
+
const { provider, judgeProvider, judgeDecision, media } = host;
|
|
152
|
+
const threshold = options.threshold ?? 1;
|
|
153
|
+
if (!(threshold >= 0 && threshold <= 1))
|
|
154
|
+
return failed('--threshold is a fraction from 0 to 1.');
|
|
155
|
+
if (options.trials !== undefined && !(Number.isInteger(options.trials) && options.trials > 0)) {
|
|
156
|
+
return failed('--trials is a whole number of trials per case, 1 or more.');
|
|
157
|
+
}
|
|
158
|
+
if (options.concurrency !== undefined &&
|
|
159
|
+
!(Number.isInteger(options.concurrency) && options.concurrency > 0)) {
|
|
160
|
+
return failed('--concurrency is a whole number of trials in flight, 1 or more.');
|
|
161
|
+
}
|
|
162
|
+
let run;
|
|
163
|
+
try {
|
|
164
|
+
const loaded = await loadSuite(options.suite);
|
|
165
|
+
const recorded = options.recorded ? await readTraceRecords(options.recorded) : undefined;
|
|
166
|
+
const live = provider ?? loaded.provider;
|
|
167
|
+
if (!recorded && !live) {
|
|
168
|
+
return failed('Theorem CLI does not create providers or read keys. Export `provider` from the suite module, or pass --recorded <traces>.');
|
|
169
|
+
}
|
|
170
|
+
run = await runSuite(loaded, {
|
|
171
|
+
...(recorded ? { recorded } : {}),
|
|
172
|
+
...(live ? { provider: live } : {}),
|
|
173
|
+
...(judgeProvider ? { judgeProvider } : {}),
|
|
174
|
+
...(judgeDecision ? { judgeDecision } : {}),
|
|
175
|
+
...(media ? { media } : {}),
|
|
176
|
+
...(options.trials !== undefined ? { repeat: options.trials } : {}),
|
|
177
|
+
...(options.concurrency !== undefined ? { concurrency: options.concurrency } : {}),
|
|
178
|
+
...(options.maxCostUsd !== undefined ? { maxCostUsd: options.maxCostUsd } : {}),
|
|
179
|
+
...(options.traceDir?.trim() ? { sink: jsonlSink(options.traceDir.trim()) } : {}),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
return failed(error instanceof Error ? error.message : String(error));
|
|
184
|
+
}
|
|
185
|
+
if (options.json)
|
|
186
|
+
printJson(run);
|
|
187
|
+
else
|
|
188
|
+
printTable(run);
|
|
189
|
+
return run.stopped === undefined && fraction(run) >= threshold;
|
|
190
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CanaryEgressAttack } from '../../guardrails/corpus/canary-egress-attacks.js';
|
|
2
|
+
export interface ChannelResult {
|
|
3
|
+
attack: CanaryEgressAttack;
|
|
4
|
+
channel: string;
|
|
5
|
+
blocked: boolean;
|
|
6
|
+
bypassed: boolean;
|
|
7
|
+
falseAlarm: boolean;
|
|
8
|
+
clientWire: string;
|
|
9
|
+
}
|
|
10
|
+
/** One result per attack per channel (runTurn stream, Live batch). */
|
|
11
|
+
export declare function runCanaryFuzz(canary?: string): Promise<ChannelResult[]>;
|
|
12
|
+
/** Run adversarial canary fuzz; returns true when no bypasses or false alarms. */
|
|
13
|
+
export declare function fuzzCanaryCommand(options?: {
|
|
14
|
+
canary?: string;
|
|
15
|
+
}): Promise<boolean>;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// why: A bypass is judged from the attack's own encoded canary, not from the detector under test.
|
|
2
|
+
import { bindCanary, isStreamedCanaryEvent, mintCanary, scanTextForCanaryLeak, } from '../../guardrails/canary.js';
|
|
3
|
+
import { buildCanaryEgressAttacks, FIXED_CANARY, FUZZ_SYSTEM, } from '../../guardrails/corpus/canary-egress-attacks.js';
|
|
4
|
+
import { scopeOf } from '../../guardrails/detect-at.js';
|
|
5
|
+
import { readReply } from '../../guardrails/detect-reply.js';
|
|
6
|
+
import { givenUrlSets } from '../../guardrails/egress-urls.js';
|
|
7
|
+
import { createLiveOutboundGateSession, finalizeLiveOutboundTurn, processLiveOutboundBatch, } from '../../guardrails/live-outbound-gate.js';
|
|
8
|
+
import { resolveGuardrailPolicy } from '../../guardrails/policy.js';
|
|
9
|
+
import { scanTextOf } from '../../guardrails/serialize.js';
|
|
10
|
+
import { clearProfiles, getProfile, getProvider, registerProfile, registerProvider, resolveTurn, } from '../../kernel/default-scope.js';
|
|
11
|
+
import { isWithheldOnBlock, yieldProviderEvents, } from '../../kernel/engine/runner/stream.js';
|
|
12
|
+
import { providerCompleteRequest } from '../../kernel/registry/provider-request.js';
|
|
13
|
+
import { defaultKernelScope } from '../../kernel/scope.js';
|
|
14
|
+
import { shownToolArguments } from '../../kernel/tools/execute.js';
|
|
15
|
+
import { openRouterProvider } from '../../providers/openrouter/provider.js';
|
|
16
|
+
const FUZZ_PROFILE_ID = '__fuzz_canary__';
|
|
17
|
+
function registerFuzzCanaryProfile() {
|
|
18
|
+
if (!getProvider('openrouter'))
|
|
19
|
+
registerProvider(openRouterProvider);
|
|
20
|
+
registerProfile({
|
|
21
|
+
type: 'text',
|
|
22
|
+
id: FUZZ_PROFILE_ID,
|
|
23
|
+
identity: { handle: 'fuzz-canary', system: 'Canary fuzz profile.' },
|
|
24
|
+
models: {
|
|
25
|
+
'fuzz-model': {
|
|
26
|
+
protocol: 'openRouter',
|
|
27
|
+
provider: 'openrouter',
|
|
28
|
+
apiId: 'fuzz-model',
|
|
29
|
+
keySlot: 'fuzz',
|
|
30
|
+
efforts: { normal: 'none' },
|
|
31
|
+
summaries: false,
|
|
32
|
+
maxOutputTokens: 4096,
|
|
33
|
+
temperature: 0,
|
|
34
|
+
builtInTools: [],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
defaultModel: 'fuzz-model',
|
|
38
|
+
tools: { allow: [] },
|
|
39
|
+
inputs: { text: true },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function resolveFuzzGeneration(canary) {
|
|
43
|
+
const { generation } = resolveTurn({
|
|
44
|
+
profile: FUZZ_PROFILE_ID,
|
|
45
|
+
input: { text: 'fuzz' },
|
|
46
|
+
});
|
|
47
|
+
return { ...generation, canary };
|
|
48
|
+
}
|
|
49
|
+
/** The model's tool call as a host is shown it: its arguments as the tool gets them. */
|
|
50
|
+
function callShown(event, canary) {
|
|
51
|
+
if (event.type !== 'tool' || event.tool.phase !== undefined)
|
|
52
|
+
return event;
|
|
53
|
+
const shown = shownToolArguments({
|
|
54
|
+
tools: defaultKernelScope.tools,
|
|
55
|
+
profile: getProfile(FUZZ_PROFILE_ID),
|
|
56
|
+
name: event.tool.name,
|
|
57
|
+
input: event.tool.arguments,
|
|
58
|
+
scope: { canary, privateSystem: [bindCanary(FUZZ_SYSTEM, canary)] },
|
|
59
|
+
});
|
|
60
|
+
return { ...event, tool: { ...event.tool, arguments: shown } };
|
|
61
|
+
}
|
|
62
|
+
/** The structured output as the read of the whole reply leaves it; none when that read stops it. */
|
|
63
|
+
function structuredShown(event, canary) {
|
|
64
|
+
if (event.type !== 'structured')
|
|
65
|
+
return [event];
|
|
66
|
+
const policy = resolveGuardrailPolicy(getProfile(FUZZ_PROFILE_ID).guardrails);
|
|
67
|
+
const read = readReply({ text: '', structured: event.structured }, policy.detect, {
|
|
68
|
+
boundary: 'reply',
|
|
69
|
+
scope: scopeOf(policy, { canary, privateSystem: [bindCanary(FUZZ_SYSTEM, canary)] }),
|
|
70
|
+
});
|
|
71
|
+
return read.blocked ? [] : [{ ...event, structured: read.payload.structured }];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A call's events as the step runner passes them on. Once the stream's gate
|
|
75
|
+
* withholds the reply, its text and media are kept for the verdict on the
|
|
76
|
+
* whole reply and never reach the client. A tool call and a structured output
|
|
77
|
+
* are read at their own boundaries.
|
|
78
|
+
*/
|
|
79
|
+
async function reachingClient(control, canary, gen) {
|
|
80
|
+
const out = [];
|
|
81
|
+
for await (const event of gen) {
|
|
82
|
+
if (control.withholdVisible && isWithheldOnBlock(event))
|
|
83
|
+
continue;
|
|
84
|
+
out.push(...structuredShown(callShown(event, canary), canary));
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
function clientVisible(events) {
|
|
89
|
+
return events.filter((event) => event.type !== 'error');
|
|
90
|
+
}
|
|
91
|
+
function clientVisibleWire(events) {
|
|
92
|
+
return JSON.stringify(clientVisible(events));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Whether the attack's encoded canary reached the client: in the reply as the
|
|
96
|
+
* client assembles it across chunks and turns, or in any other event.
|
|
97
|
+
*/
|
|
98
|
+
function leakReachedClient(attack, events) {
|
|
99
|
+
if (!attack.shouldBlock) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const visible = clientVisible(events);
|
|
103
|
+
const reply = visible
|
|
104
|
+
.filter(isStreamedCanaryEvent)
|
|
105
|
+
.map((event) => event.text ?? '')
|
|
106
|
+
.join('');
|
|
107
|
+
return (reply.includes(attack.leak) ||
|
|
108
|
+
visible.some((event) => !isStreamedCanaryEvent(event) && scanTextOf(event).includes(attack.leak)));
|
|
109
|
+
}
|
|
110
|
+
function channelResult(attack, channel, blocked, events) {
|
|
111
|
+
const bypassed = leakReachedClient(attack, events);
|
|
112
|
+
return {
|
|
113
|
+
attack,
|
|
114
|
+
channel,
|
|
115
|
+
blocked,
|
|
116
|
+
bypassed,
|
|
117
|
+
falseAlarm: !attack.shouldBlock && blocked,
|
|
118
|
+
clientWire: clientVisibleWire(events),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
async function* replay(turn) {
|
|
122
|
+
await Promise.resolve();
|
|
123
|
+
yield* turn;
|
|
124
|
+
}
|
|
125
|
+
async function runStreamChannel(attack, generation, canary) {
|
|
126
|
+
const events = [];
|
|
127
|
+
// why: Every provider call of one turn shares its canary: each attack turn is a step.
|
|
128
|
+
const control = { withholdVisible: false };
|
|
129
|
+
for (const turn of attack.turns) {
|
|
130
|
+
const streamed = await reachingClient(control, canary, yieldProviderEvents({
|
|
131
|
+
profile: getProfile(FUZZ_PROFILE_ID),
|
|
132
|
+
generation,
|
|
133
|
+
request: providerCompleteRequest(defaultKernelScope.tools, generation, bindCanary(FUZZ_SYSTEM, canary)),
|
|
134
|
+
privateSystem: [bindCanary(FUZZ_SYSTEM, canary)],
|
|
135
|
+
provider: { complete: () => replay(turn) },
|
|
136
|
+
tools: defaultKernelScope.tools,
|
|
137
|
+
// why: The fuzz reads what reaches the client, not the trace.
|
|
138
|
+
call: { tap: () => { }, observe: () => { } },
|
|
139
|
+
control,
|
|
140
|
+
givenUrls: givenUrlSets(),
|
|
141
|
+
}));
|
|
142
|
+
// why: The runner reads the call's `done`; the client never receives it.
|
|
143
|
+
const turnEvents = streamed.flatMap((event) => event.type === 'done' || event.type === 'reasoning' ? [] : [event]);
|
|
144
|
+
events.push(...turnEvents);
|
|
145
|
+
if (control.withholdVisible || turnEvents.some((event) => event.type === 'error')) {
|
|
146
|
+
return channelResult(attack, 'runTurn.stream', true, events);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return channelResult(attack, 'runTurn.stream', false, events);
|
|
150
|
+
}
|
|
151
|
+
/** One Live session; each turn is a cycle the provider finishes before the next. */
|
|
152
|
+
async function runLiveBatchChannel(attack, canary) {
|
|
153
|
+
const session = await createLiveOutboundGateSession(getProfile(FUZZ_PROFILE_ID), canary, [
|
|
154
|
+
bindCanary(FUZZ_SYSTEM, canary),
|
|
155
|
+
]);
|
|
156
|
+
const events = [];
|
|
157
|
+
for (const turn of attack.turns) {
|
|
158
|
+
for (const result of [
|
|
159
|
+
await processLiveOutboundBatch(session, turn.map((event) => callShown(event, canary))),
|
|
160
|
+
await finalizeLiveOutboundTurn(session),
|
|
161
|
+
]) {
|
|
162
|
+
if (result.action === 'withhold') {
|
|
163
|
+
return channelResult(attack, 'live.batch', true, events);
|
|
164
|
+
}
|
|
165
|
+
if (result.action === 'emit') {
|
|
166
|
+
events.push(...result.events);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return channelResult(attack, 'live.batch', false, events);
|
|
171
|
+
}
|
|
172
|
+
function truncate(s, max) {
|
|
173
|
+
if (s.length <= max)
|
|
174
|
+
return s;
|
|
175
|
+
return `${s.slice(0, max - 3)}...`;
|
|
176
|
+
}
|
|
177
|
+
function printResults(results) {
|
|
178
|
+
const bypassed = results.filter((r) => r.bypassed);
|
|
179
|
+
const falseAlarms = results.filter((r) => r.falseAlarm);
|
|
180
|
+
const caught = results.filter((r) => r.attack.shouldBlock && r.blocked && !r.bypassed);
|
|
181
|
+
console.log(`\n${'═'.repeat(72)}`);
|
|
182
|
+
console.log(` TOTAL: ${results.length} | CAUGHT: ${caught.length} | BYPASSED: ${bypassed.length} | FALSE ALARM: ${falseAlarms.length}`);
|
|
183
|
+
console.log(`${'═'.repeat(72)}`);
|
|
184
|
+
if (bypassed.length > 0) {
|
|
185
|
+
console.log('\n\x1b[31mBYPASSED (canary reached client-visible output):\x1b[0m\n');
|
|
186
|
+
for (const r of bypassed) {
|
|
187
|
+
console.log(` ✗ ${r.attack.category}/${r.attack.name} [${r.channel}]`);
|
|
188
|
+
console.log(` \x1b[2m${truncate(r.clientWire, 90)}\x1b[0m`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (falseAlarms.length > 0) {
|
|
192
|
+
console.log('\n\x1b[33mFALSE ALARMS (benign payload blocked):\x1b[0m\n');
|
|
193
|
+
for (const r of falseAlarms) {
|
|
194
|
+
console.log(` ⚠ ${r.attack.category}/${r.attack.name} [${r.channel}]`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (bypassed.length === 0 && falseAlarms.length === 0) {
|
|
198
|
+
console.log('\n\x1b[32mAll leak attempts blocked; benign controls passed.\x1b[0m\n');
|
|
199
|
+
}
|
|
200
|
+
return bypassed.length === 0 && falseAlarms.length === 0;
|
|
201
|
+
}
|
|
202
|
+
/** One result per attack per channel (runTurn stream, Live batch). */
|
|
203
|
+
export async function runCanaryFuzz(canary = FIXED_CANARY) {
|
|
204
|
+
clearProfiles();
|
|
205
|
+
registerFuzzCanaryProfile();
|
|
206
|
+
try {
|
|
207
|
+
const generation = resolveFuzzGeneration(canary);
|
|
208
|
+
const results = [];
|
|
209
|
+
for (const attack of buildCanaryEgressAttacks(canary)) {
|
|
210
|
+
results.push(await runStreamChannel(attack, generation, canary));
|
|
211
|
+
results.push(await runLiveBatchChannel(attack, canary));
|
|
212
|
+
}
|
|
213
|
+
return results;
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
clearProfiles();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/** Run adversarial canary fuzz; returns true when no bypasses or false alarms. */
|
|
220
|
+
export async function fuzzCanaryCommand(options) {
|
|
221
|
+
console.log('\n🔐 Theorem Canary Egress Adversarial Fuzzer\n');
|
|
222
|
+
const canary = options?.canary ?? FIXED_CANARY;
|
|
223
|
+
if (!/^[0-9a-f]{32}$/.test(canary)) {
|
|
224
|
+
console.error(`Invalid canary shape (expected 32 hex): ${canary}`);
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
const minted = mintCanary();
|
|
228
|
+
if (!/^[0-9a-f]{32}$/.test(minted)) {
|
|
229
|
+
console.error(`mintCanary produced unexpected shape: ${minted}`);
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
if (!scanTextForCanaryLeak(canary, canary)) {
|
|
233
|
+
console.error('scanTextForCanaryLeak failed to detect literal canary');
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
const results = await runCanaryFuzz(canary);
|
|
237
|
+
console.log(`Canary: ${canary.slice(0, 12)}… (${results.length / 2} attacks × 2 channels)`);
|
|
238
|
+
const ok = printResults(results);
|
|
239
|
+
console.log('');
|
|
240
|
+
return ok;
|
|
241
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { getProfile, listProfiles } from '../../kernel/default-scope.js';
|
|
2
|
+
import { profileToolAllow } from '../../kernel/tools/resolve.js';
|
|
3
|
+
function formatProfileInputs(p) {
|
|
4
|
+
if (p.type === 'speech') {
|
|
5
|
+
return 'text (speech)';
|
|
6
|
+
}
|
|
7
|
+
if (p.type === 'live') {
|
|
8
|
+
return 'audio/video (live)';
|
|
9
|
+
}
|
|
10
|
+
const inputs = [];
|
|
11
|
+
const { inputs: spec } = p;
|
|
12
|
+
if (!spec) {
|
|
13
|
+
return 'none';
|
|
14
|
+
}
|
|
15
|
+
if (spec.text !== false)
|
|
16
|
+
inputs.push('text');
|
|
17
|
+
if (p.type !== 'image' && p.type !== 'embedding' && p.inputs?.voice)
|
|
18
|
+
inputs.push('voice');
|
|
19
|
+
if (spec.attachments) {
|
|
20
|
+
inputs.push(`attachments [${spec.attachments.accept?.join(', ')}]`);
|
|
21
|
+
}
|
|
22
|
+
return inputs.join(' | ') || 'none';
|
|
23
|
+
}
|
|
24
|
+
function formatProfileTools(p) {
|
|
25
|
+
return profileToolAllow(p).join(', ') || 'none';
|
|
26
|
+
}
|
|
27
|
+
function printProfileCard(p) {
|
|
28
|
+
const tools = formatProfileTools(p);
|
|
29
|
+
if (p.type === 'host') {
|
|
30
|
+
console.log(` • Profile: ${p.id.padEnd(16)} [host]`);
|
|
31
|
+
console.log(` - Tools: ${tools}`);
|
|
32
|
+
console.log('-'.repeat(70));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (p.type === 'decision') {
|
|
36
|
+
console.log(` • Profile: ${p.id.padEnd(16)} (handle: ${p.identity.handle}) [decision]`);
|
|
37
|
+
console.log(` - Model: ${Object.keys(p.models).join(', ')}`);
|
|
38
|
+
console.log(` - Inputs: JSON state`);
|
|
39
|
+
console.log(` - Contract: ${p.decision.contract}`);
|
|
40
|
+
console.log('-'.repeat(70));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const models = Object.keys(p.models).join(', ') || 'default';
|
|
44
|
+
const structured = p.type === 'live' || p.type === 'speech' || p.type === 'embedding'
|
|
45
|
+
? undefined
|
|
46
|
+
: p.outputs?.structured;
|
|
47
|
+
const structuredLabel = typeof structured === 'string' ? structured : structured ? 'custom' : 'none';
|
|
48
|
+
console.log(` • Profile: ${p.id.padEnd(16)} (handle: ${p.identity.handle}) [${p.type}]`);
|
|
49
|
+
console.log(` - Models: ${models}`);
|
|
50
|
+
console.log(` - Inputs: ${formatProfileInputs(p)}`);
|
|
51
|
+
console.log(` - Tools: ${tools}`);
|
|
52
|
+
console.log(` - Structured: ${structuredLabel}`);
|
|
53
|
+
console.log('-'.repeat(70));
|
|
54
|
+
}
|
|
55
|
+
export function listProfilesCommand() {
|
|
56
|
+
const profiles = listProfiles();
|
|
57
|
+
console.log('\n Registered Theorem Profiles:');
|
|
58
|
+
console.log('='.repeat(70));
|
|
59
|
+
if (profiles.length === 0) {
|
|
60
|
+
console.log(' (No profiles registered in runtime)');
|
|
61
|
+
console.log(`${'='.repeat(70)}\n`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
for (const p of profiles) {
|
|
65
|
+
printProfileCard(p);
|
|
66
|
+
}
|
|
67
|
+
console.log(`Total: ${profiles.length} profiles registered.\n`);
|
|
68
|
+
}
|
|
69
|
+
export function showProfileCommand(profileId) {
|
|
70
|
+
try {
|
|
71
|
+
const profile = getProfile(profileId);
|
|
72
|
+
console.log(`\n Profile Details: ${profileId}`);
|
|
73
|
+
console.log('='.repeat(70));
|
|
74
|
+
console.log(JSON.stringify(profile, null, 2));
|
|
75
|
+
console.log(`${'='.repeat(70)}\n`);
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
console.error(`\n Error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ProviderHostOptions } from '../../kernel/protocols/runtime.js';
|
|
2
|
+
export interface RunOptions {
|
|
3
|
+
profile: string;
|
|
4
|
+
prompt?: string;
|
|
5
|
+
mode?: string;
|
|
6
|
+
search?: boolean;
|
|
7
|
+
map?: boolean;
|
|
8
|
+
provider?: ProviderHostOptions;
|
|
9
|
+
verbose?: boolean;
|
|
10
|
+
trace?: boolean;
|
|
11
|
+
traceDir?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function runCommand(options: RunOptions): Promise<void>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getProfile, runTurn } from '../../kernel/default-scope.js';
|
|
2
|
+
import { requireModelProfile } from '../../kernel/registry/resolve.js';
|
|
3
|
+
import { createCliTraceCapture, printRunEvent, printTraceRecord } from '../event-log.js';
|
|
4
|
+
export async function runCommand(options) {
|
|
5
|
+
requireModelProfile(getProfile(options.profile), 'agents run');
|
|
6
|
+
const provider = options.provider;
|
|
7
|
+
if (!provider) {
|
|
8
|
+
console.error('\n\x1b[31mExecution Failed\x1b[0m: Theorem CLI does not create providers or read keys. Run turns from a host app with an explicit ProviderHostOptions.\n');
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const prompt = options.prompt || 'Hello! Please introduce your capabilities.';
|
|
12
|
+
if (options.search || options.map) {
|
|
13
|
+
const profile = requireModelProfile(getProfile(options.profile), 'agents run');
|
|
14
|
+
const selected = options.mode ?? profile.defaultModel;
|
|
15
|
+
const builtins = new Set(profile.models[selected]?.builtInTools ?? []);
|
|
16
|
+
if (options.search && !builtins.has('googleSearch')) {
|
|
17
|
+
console.error('\n\x1b[31mExecution Failed\x1b[0m: --search requires googleSearch on models.*.builtInTools for the selected model.\n');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (options.map && !builtins.has('googleMaps')) {
|
|
21
|
+
console.error('\n\x1b[31mExecution Failed\x1b[0m: --map requires googleMaps on models.*.builtInTools for the selected model.\n');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const req = {
|
|
26
|
+
profile: options.profile,
|
|
27
|
+
model: options.mode,
|
|
28
|
+
input: { text: prompt },
|
|
29
|
+
};
|
|
30
|
+
console.log(`\n▶ [RUNNING TURN] Profile: ${options.profile} (${options.mode ?? 'default'})`);
|
|
31
|
+
console.log(`Prompt: "${prompt}"\n`);
|
|
32
|
+
const traceCapture = options.trace ? createCliTraceCapture(options.traceDir) : undefined;
|
|
33
|
+
try {
|
|
34
|
+
for await (const event of runTurn(req, provider, traceCapture?.sink)) {
|
|
35
|
+
printRunEvent(event, { verbose: options.verbose });
|
|
36
|
+
}
|
|
37
|
+
console.log('\n');
|
|
38
|
+
if (options.trace) {
|
|
39
|
+
printTraceRecord(traceCapture?.records.at(-1), options.verbose === true);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.error(`\n\x1b[31mExecution Failed\x1b[0m: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ProviderHostOptions } from '../../kernel/protocols/runtime.js';
|
|
2
|
+
import type { TurnRequest, TurnTokens } from '../../kernel/types.js';
|
|
3
|
+
import { type MatrixOptions } from '../matrix/synthesizer.js';
|
|
4
|
+
export interface TestRunResult {
|
|
5
|
+
passed: boolean;
|
|
6
|
+
name: string;
|
|
7
|
+
durationSec: number;
|
|
8
|
+
/** The turn's usage, summed over every model call (`sumTokens`). */
|
|
9
|
+
tokens?: TurnTokens;
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
interface CliTestOptions {
|
|
13
|
+
verbose?: boolean;
|
|
14
|
+
trace?: boolean;
|
|
15
|
+
traceDir?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function executeSingleTest(req: TurnRequest, testName: string, provider?: ProviderHostOptions, cliOptions?: CliTestOptions): Promise<TestRunResult>;
|
|
18
|
+
export declare function testProfileCommand(profileId?: string, options?: MatrixOptions & {
|
|
19
|
+
all?: boolean;
|
|
20
|
+
matrix?: boolean;
|
|
21
|
+
provider?: ProviderHostOptions;
|
|
22
|
+
verbose?: boolean;
|
|
23
|
+
trace?: boolean;
|
|
24
|
+
traceDir?: string;
|
|
25
|
+
}): Promise<boolean>;
|
|
26
|
+
export {};
|