@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,143 @@
|
|
|
1
|
+
import { getProfile, listProfiles, runTurn } from '../../kernel/default-scope.js';
|
|
2
|
+
import { sumTokens } from '../../kernel/engine/usage.js';
|
|
3
|
+
import { isModelProfile, requireModelProfile } from '../../kernel/registry/resolve.js';
|
|
4
|
+
import { profileToolAllow } from '../../kernel/tools/resolve.js';
|
|
5
|
+
import { createCliTraceCapture, printTestEvent, printTraceRecord } from '../event-log.js';
|
|
6
|
+
import { buildCustomTurnRequest, synthesizeMatrixCombos, } from '../matrix/synthesizer.js';
|
|
7
|
+
function printTestHeader(req, testName) {
|
|
8
|
+
const profile = requireModelProfile(getProfile(req.profile), 'agents test');
|
|
9
|
+
const modelId = req.model && profile.models[req.model] ? req.model : (Object.keys(profile.models)[0] ?? '');
|
|
10
|
+
const customs = profileToolAllow(profile).join(', ') || 'none';
|
|
11
|
+
const builtins = (profile.models[modelId]?.builtInTools ?? []).join(', ') || 'none';
|
|
12
|
+
console.log(`\n▶ [THEOREM TEST] ${testName}`);
|
|
13
|
+
console.log(` Profile: ${req.profile} (Model: ${req.model ?? 'default'})`);
|
|
14
|
+
console.log(` Custom: ${customs}`);
|
|
15
|
+
console.log(` Builtins: ${builtins}`);
|
|
16
|
+
console.log(` Attachments: ${req.input?.attachments?.length ?? 0} file(s) | Voice: ${req.input?.voice?.length ? 'yes' : 'no'}`);
|
|
17
|
+
console.log(` ${'-'.repeat(60)}`);
|
|
18
|
+
}
|
|
19
|
+
function processTestEvent(event, acc, options) {
|
|
20
|
+
if (event.type === 'tokens' && event.tokens) {
|
|
21
|
+
acc.calls.push(event.tokens);
|
|
22
|
+
}
|
|
23
|
+
if (event.type === 'error' && event.error) {
|
|
24
|
+
acc.hasError = true;
|
|
25
|
+
acc.errorMessage = event.error;
|
|
26
|
+
}
|
|
27
|
+
printTestEvent(event, { verbose: options.verbose });
|
|
28
|
+
}
|
|
29
|
+
function printTestResult(passed, durationSec, tokens, errorMessage) {
|
|
30
|
+
if (passed) {
|
|
31
|
+
const estimates = tokens?.estimated ? ', includes estimates' : '';
|
|
32
|
+
console.log(`\n ✓ STATUS: PASSED (took ${durationSec.toFixed(2)}s, ${tokens?.total ? `${tokens.total} tokens${estimates}` : 'ok'})`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.log(`\n ✗ STATUS: FAILED: ${errorMessage} (${durationSec.toFixed(2)}s)`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export async function executeSingleTest(req, testName, provider, cliOptions = {}) {
|
|
39
|
+
const start = Date.now();
|
|
40
|
+
getProfile(req.profile);
|
|
41
|
+
printTestHeader(req, testName);
|
|
42
|
+
const acc = {
|
|
43
|
+
calls: [],
|
|
44
|
+
hasError: false,
|
|
45
|
+
errorMessage: '',
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
if (!provider) {
|
|
49
|
+
throw new Error('Theorem CLI does not create providers or read keys. Pass an explicit ProviderHostOptions from the host app.');
|
|
50
|
+
}
|
|
51
|
+
const traceCapture = cliOptions.trace ? createCliTraceCapture(cliOptions.traceDir) : undefined;
|
|
52
|
+
for await (const event of runTurn(req, provider, traceCapture?.sink)) {
|
|
53
|
+
processTestEvent(event, acc, cliOptions);
|
|
54
|
+
}
|
|
55
|
+
if (cliOptions.trace) {
|
|
56
|
+
printTraceRecord(traceCapture?.records.at(-1), cliOptions.verbose === true);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
acc.hasError = true;
|
|
61
|
+
acc.errorMessage = err instanceof Error ? err.message : String(err);
|
|
62
|
+
}
|
|
63
|
+
const durationSec = (Date.now() - start) / 1000;
|
|
64
|
+
const passed = !acc.hasError;
|
|
65
|
+
const tokens = sumTokens(acc.calls);
|
|
66
|
+
printTestResult(passed, durationSec, tokens, acc.errorMessage);
|
|
67
|
+
return {
|
|
68
|
+
passed,
|
|
69
|
+
name: testName,
|
|
70
|
+
durationSec,
|
|
71
|
+
...(tokens ? { tokens } : {}),
|
|
72
|
+
error: acc.errorMessage,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function resolveTargetProfiles(profileId, all) {
|
|
76
|
+
if (all) {
|
|
77
|
+
// why: Host and decision profiles run no model turn, so they have no turn matrix.
|
|
78
|
+
return listProfiles().filter(isModelProfile);
|
|
79
|
+
}
|
|
80
|
+
if (profileId) {
|
|
81
|
+
try {
|
|
82
|
+
return [requireModelProfile(getProfile(profileId), 'agents test')];
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
console.error(`\n Error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
console.error('Error: Please specify a profile ID (e.g. `agents test --profile your-profile`) or `--all`.');
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
async function runProfileMatrix(profile, provider, cliOptions = {}) {
|
|
93
|
+
const results = [];
|
|
94
|
+
const combos = synthesizeMatrixCombos(profile);
|
|
95
|
+
for (const combo of combos) {
|
|
96
|
+
const res = await executeSingleTest(combo.req, `${profile.id} [${combo.name}]`, provider, cliOptions);
|
|
97
|
+
results.push(res);
|
|
98
|
+
}
|
|
99
|
+
return results;
|
|
100
|
+
}
|
|
101
|
+
async function runProfileSingle(profile, options, provider, cliOptions = {}) {
|
|
102
|
+
const req = buildCustomTurnRequest(profile, options);
|
|
103
|
+
const testName = options.lite ? `${profile.id} [Lite]` : `${profile.id} [Stress Combo]`;
|
|
104
|
+
return await executeSingleTest(req, testName, provider, cliOptions);
|
|
105
|
+
}
|
|
106
|
+
function printSummaryReport(results) {
|
|
107
|
+
console.log(`\n${'='.repeat(70)}`);
|
|
108
|
+
console.log(' TEST SUMMARY:');
|
|
109
|
+
console.log('='.repeat(70));
|
|
110
|
+
let allPassed = true;
|
|
111
|
+
for (const r of results) {
|
|
112
|
+
const status = r.passed ? '✓ PASSED' : '✗ FAILED';
|
|
113
|
+
console.log(` ${status.padEnd(10)} ${r.name.padEnd(45)} (${r.durationSec.toFixed(2)}s)`);
|
|
114
|
+
if (!r.passed) {
|
|
115
|
+
allPassed = false;
|
|
116
|
+
if (r.error)
|
|
117
|
+
console.log(` Reason: ${r.error}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
console.log(`${'='.repeat(70)}\n`);
|
|
121
|
+
return allPassed;
|
|
122
|
+
}
|
|
123
|
+
export async function testProfileCommand(profileId, options = {}) {
|
|
124
|
+
const targetProfiles = resolveTargetProfiles(profileId, options.all);
|
|
125
|
+
if (!targetProfiles || targetProfiles.length === 0) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
const cliOptions = {
|
|
129
|
+
verbose: options.verbose,
|
|
130
|
+
trace: options.trace,
|
|
131
|
+
traceDir: options.traceDir,
|
|
132
|
+
};
|
|
133
|
+
const results = [];
|
|
134
|
+
for (const profile of targetProfiles) {
|
|
135
|
+
if (options.matrix) {
|
|
136
|
+
results.push(...(await runProfileMatrix(profile, options.provider, cliOptions)));
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
results.push(await runProfileSingle(profile, options, options.provider, cliOptions));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return printSummaryReport(results);
|
|
143
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TurnEvent } from '../kernel/turn-events.js';
|
|
2
|
+
import { type TraceRecord } from '../observability/trace-record.js';
|
|
3
|
+
import type { TraceSink } from '../observability/trace-sink.js';
|
|
4
|
+
export interface CliEventLogOptions {
|
|
5
|
+
verbose?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface CliTraceCapture {
|
|
8
|
+
sink: TraceSink;
|
|
9
|
+
records: TraceRecord[];
|
|
10
|
+
}
|
|
11
|
+
declare function createCliTraceCapture(traceDir?: string): CliTraceCapture;
|
|
12
|
+
declare function printRunEvent(event: TurnEvent, options?: CliEventLogOptions): void;
|
|
13
|
+
declare function printTestEvent(event: TurnEvent, options?: CliEventLogOptions): void;
|
|
14
|
+
declare function printTraceRecord(record: TraceRecord | undefined, verbose: boolean): void;
|
|
15
|
+
export { createCliTraceCapture, printRunEvent, printTestEvent, printTraceRecord };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { stdout } from 'node:process';
|
|
2
|
+
import { jsonlSink } from '../observability/jsonl.js';
|
|
3
|
+
import { memorySink } from '../observability/trace.js';
|
|
4
|
+
import { inlineContent } from '../observability/trace-record.js';
|
|
5
|
+
function createCliTraceCapture(traceDir) {
|
|
6
|
+
const records = [];
|
|
7
|
+
const sinks = [memorySink(records)];
|
|
8
|
+
if (traceDir?.trim()) {
|
|
9
|
+
sinks.push(jsonlSink(traceDir.trim()));
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
records,
|
|
13
|
+
sink: {
|
|
14
|
+
write: async (record, context) => {
|
|
15
|
+
for (const sink of sinks) {
|
|
16
|
+
await sink.write(record, context);
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function printVerboseEvidence(event) {
|
|
23
|
+
const e = event.evidence;
|
|
24
|
+
if (e.raw) {
|
|
25
|
+
console.log('\n\x1b[2m[verbose evidence.raw]\x1b[0m');
|
|
26
|
+
console.log(JSON.stringify(e.raw, null, 2));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function printVerboseError(event) {
|
|
30
|
+
if (event.type !== 'error' || !event.errorInternal) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
console.error(`\n\x1b[2m[verbose errorInternal]\x1b[0m ${event.errorInternal}`);
|
|
34
|
+
}
|
|
35
|
+
function printRunEvidence(event, verbose) {
|
|
36
|
+
const e = event.evidence;
|
|
37
|
+
if (e.kind === 'code_execution_call') {
|
|
38
|
+
console.log(`\n\x1b[36m🐍 [code_execution_call]\x1b[0m\n${e.code}`);
|
|
39
|
+
}
|
|
40
|
+
else if (e.kind === 'code_execution_result') {
|
|
41
|
+
console.log(`\n\x1b[36m🐍 [code_execution_result]\x1b[0m isError=${String(e.isError)}\n${e.result ?? ''}`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.log(`\n\x1b[36m📎 [evidence]\x1b[0m ${e.kind}`);
|
|
45
|
+
}
|
|
46
|
+
if (verbose) {
|
|
47
|
+
printVerboseEvidence(event);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function printRunEvent(event, options = {}) {
|
|
51
|
+
const verbose = options.verbose === true;
|
|
52
|
+
if (event.type === 'thought' && event.text) {
|
|
53
|
+
stdout.write(`\x1b[2m${event.text}\x1b[0m`);
|
|
54
|
+
}
|
|
55
|
+
else if (event.type === 'text' && event.text) {
|
|
56
|
+
stdout.write(event.text);
|
|
57
|
+
}
|
|
58
|
+
else if (event.type === 'tool' && event.tool.phase === undefined) {
|
|
59
|
+
stdout.write(`\n\x1b[33m⚡ [Tool Call] ${event.tool.name}\x1b[0m: `);
|
|
60
|
+
console.log(event.tool.arguments);
|
|
61
|
+
}
|
|
62
|
+
else if (event.type === 'evidence') {
|
|
63
|
+
printRunEvidence(event, verbose);
|
|
64
|
+
}
|
|
65
|
+
else if (event.type === 'structured' && event.structured) {
|
|
66
|
+
console.log('\n\x1b[32m✓ [Structured Output]\x1b[0m:');
|
|
67
|
+
console.log(JSON.stringify(event.structured, null, 2));
|
|
68
|
+
}
|
|
69
|
+
else if (event.type === 'media' && event.media) {
|
|
70
|
+
console.log(`\n\x1b[34m🖼 [Media Output]\x1b[0m (${event.media.mimeType})`);
|
|
71
|
+
}
|
|
72
|
+
else if (event.type === 'error' && event.error) {
|
|
73
|
+
console.error(`\n\x1b[31m✗ Error\x1b[0m: ${event.error}`);
|
|
74
|
+
if (verbose) {
|
|
75
|
+
printVerboseError(event);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function printTestEvidence(event, verbose) {
|
|
80
|
+
const e = event.evidence;
|
|
81
|
+
if (e.kind === 'code_execution_call') {
|
|
82
|
+
const preview = e.code.replaceAll('\n', ' ').slice(0, 80);
|
|
83
|
+
console.log(`\n 🐍 [code_execution_call] ${preview || e.id}`);
|
|
84
|
+
}
|
|
85
|
+
else if (e.kind === 'code_execution_result') {
|
|
86
|
+
const preview = (e.result ?? '').replaceAll('\n', ' ').slice(0, 80);
|
|
87
|
+
console.log(`\n 🐍 [code_execution_result] isError=${String(e.isError)} ${preview}`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
console.log(`\n 📎 [evidence] ${e.kind}`);
|
|
91
|
+
}
|
|
92
|
+
if (verbose) {
|
|
93
|
+
printVerboseEvidence(event);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function printTestEvent(event, options = {}) {
|
|
97
|
+
const verbose = options.verbose === true;
|
|
98
|
+
if (event.type === 'thought' && event.text) {
|
|
99
|
+
stdout.write('.');
|
|
100
|
+
}
|
|
101
|
+
else if (event.type === 'tool' && event.tool.phase === undefined) {
|
|
102
|
+
console.log(`\n ⚡ [Tool Dispatched] ${event.tool.name}(${JSON.stringify(event.tool.arguments)})`);
|
|
103
|
+
}
|
|
104
|
+
else if (event.type === 'evidence') {
|
|
105
|
+
printTestEvidence(event, verbose);
|
|
106
|
+
}
|
|
107
|
+
else if (event.type === 'structured') {
|
|
108
|
+
console.log('\n ✓ [Structured Schema Validated]');
|
|
109
|
+
}
|
|
110
|
+
else if (event.type === 'media') {
|
|
111
|
+
console.log(`\n ✓ [Media Generated] (${event.media?.mimeType})`);
|
|
112
|
+
}
|
|
113
|
+
else if (event.type === 'error' && event.error) {
|
|
114
|
+
console.error(`\n [Test Error Detail]: ${event.error}`);
|
|
115
|
+
if (verbose) {
|
|
116
|
+
printVerboseError(event);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function upstreamRows(record) {
|
|
121
|
+
return record.spans.flatMap((span) => span.events.flatMap((event) => event.name === 'theorem.upstream.row' ? [inlineContent(record, event.attributes.row)] : []));
|
|
122
|
+
}
|
|
123
|
+
function printTraceRecord(record, verbose) {
|
|
124
|
+
if (!record) {
|
|
125
|
+
console.error('\n\x1b[33m[trace]\x1b[0m No trace record captured for this turn.');
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
console.log('\n\x1b[35m════ TRACE RECORD ════\x1b[0m');
|
|
129
|
+
console.log(JSON.stringify(record, null, 2));
|
|
130
|
+
const rows = verbose ? upstreamRows(record) : [];
|
|
131
|
+
if (rows.length > 0) {
|
|
132
|
+
console.log('\n\x1b[35m════ UPSTREAM LOG ════\x1b[0m');
|
|
133
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export { createCliTraceCapture, printRunEvent, printTestEvent, printTraceRecord };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command-line entrypoint for inspecting registered profiles, running turns, and
|
|
3
|
+
* exercising the kernel's guardrail and performance tools. It reads profiles
|
|
4
|
+
* registered by the embedding host; it does not supply application profiles.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import "../../_dnt.polyfills.js";
|
|
9
|
+
/** Unknown or omitted commands print help; a command that cannot continue exits 1. */
|
|
10
|
+
export declare function main(cliArgs?: string[]): Promise<void>;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command-line entrypoint for inspecting registered profiles, running turns, and
|
|
3
|
+
* exercising the kernel's guardrail and performance tools. It reads profiles
|
|
4
|
+
* registered by the embedding host; it does not supply application profiles.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import "../../_dnt.polyfills.js";
|
|
9
|
+
import { argv, exit } from 'node:process';
|
|
10
|
+
import { benchCommand } from './commands/bench.js';
|
|
11
|
+
import { detectCompileCommand } from './commands/detect-compile.js';
|
|
12
|
+
import { evalCommand } from './commands/eval.js';
|
|
13
|
+
import { fuzzCanaryCommand } from './commands/fuzz-canary.js';
|
|
14
|
+
import { fuzzGuardrailsCommand } from './commands/fuzz-guardrails.js';
|
|
15
|
+
import { listProfilesCommand, showProfileCommand } from './commands/profile.js';
|
|
16
|
+
import { runCommand } from './commands/run.js';
|
|
17
|
+
import { testProfileCommand } from './commands/test.js';
|
|
18
|
+
function printHelp() {
|
|
19
|
+
console.log(`
|
|
20
|
+
Theorem CLI - Profile Testing and Profile Inspection
|
|
21
|
+
|
|
22
|
+
USAGE:
|
|
23
|
+
agents <command> [options]
|
|
24
|
+
|
|
25
|
+
COMMANDS:
|
|
26
|
+
bench Synthetic kernel performance benchmark
|
|
27
|
+
--chunks <n> Text chunks per mock turn (default: 200)
|
|
28
|
+
--iterations <n> Measurement iterations (default: 50)
|
|
29
|
+
--warmup <n> Warmup iterations (default: 5)
|
|
30
|
+
|
|
31
|
+
detect-compile <module> Compile the patterns in a module's detect setting
|
|
32
|
+
--export <name> The export holding the setting (default: detect)
|
|
33
|
+
--out <path> Where to write the compiled module
|
|
34
|
+
|
|
35
|
+
eval <suite> Run an eval suite live or over recorded traces
|
|
36
|
+
--recorded <path> Grade a JSONL file or directory of trace records instead of running
|
|
37
|
+
--trials <k> Trials per case, overriding the suite
|
|
38
|
+
--concurrency <n> Trials in flight at once (default: 1)
|
|
39
|
+
--max-cost-usd <n> Stop starting trials once the run's cost passes this
|
|
40
|
+
--threshold <f> Fraction of cases that must pass for exit 0 (default 1)
|
|
41
|
+
--trace-dir <path> Append trial and run records as JSONL under this directory
|
|
42
|
+
--json Print the run as one JSON document
|
|
43
|
+
|
|
44
|
+
fuzz Adversarial inbound sanitization fuzzer
|
|
45
|
+
fuzz-canary Adversarial canary egress fuzzer (stream + Live gates)
|
|
46
|
+
|
|
47
|
+
run Execute a turn with real-time streaming output
|
|
48
|
+
--profile, -p <id> Target profile ID
|
|
49
|
+
--prompt <text> User prompt string
|
|
50
|
+
--mode <fast|smart> Reasoning mode
|
|
51
|
+
--search Requires googleSearch on the selected model's builtInTools
|
|
52
|
+
--map Requires googleMaps on the selected model's builtInTools
|
|
53
|
+
--verbose, -v Print errorInternal and evidence.raw while running
|
|
54
|
+
--trace Capture a TraceRecord and print it after the turn
|
|
55
|
+
--trace-dir <path> Also append trace JSONL under this directory
|
|
56
|
+
|
|
57
|
+
test Run stress matrix or custom profile tests
|
|
58
|
+
--profile, -p <id> Target profile ID registered by your host app
|
|
59
|
+
--all, -a Test all registered profiles
|
|
60
|
+
--lite Minimal fast-path connectivity ping
|
|
61
|
+
--matrix Run all valid permutations for the profile
|
|
62
|
+
--mode <fast|smart> Reasoning mode override
|
|
63
|
+
--search Requires googleSearch on the selected model's builtInTools
|
|
64
|
+
--map Requires googleMaps on the selected model's builtInTools
|
|
65
|
+
--verbose, -v Print errorInternal and evidence.raw while running
|
|
66
|
+
--trace Capture a TraceRecord and print it after each turn
|
|
67
|
+
--trace-dir <path> Also append trace JSONL under this directory
|
|
68
|
+
|
|
69
|
+
profile Inspect registered profile blueprints
|
|
70
|
+
list List all registered profiles
|
|
71
|
+
show <id> Show detailed JSON profile specification
|
|
72
|
+
|
|
73
|
+
help, --help, -h Show this help message
|
|
74
|
+
`);
|
|
75
|
+
}
|
|
76
|
+
function cliDiagnostics(flags) {
|
|
77
|
+
return {
|
|
78
|
+
verbose: Boolean(flags.verbose || flags.v),
|
|
79
|
+
trace: Boolean(flags.trace),
|
|
80
|
+
traceDir: typeof flags['trace-dir'] === 'string' ? flags['trace-dir'] : undefined,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function parseLongFlag(arg, nextArg, flags) {
|
|
84
|
+
const key = arg.slice(2);
|
|
85
|
+
if (nextArg && !nextArg.startsWith('-')) {
|
|
86
|
+
flags[key] = nextArg;
|
|
87
|
+
return 1;
|
|
88
|
+
}
|
|
89
|
+
flags[key] = true;
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
function parseShortFlag(arg, nextArg, flags) {
|
|
93
|
+
const key = arg.slice(1);
|
|
94
|
+
if (key === 'p' && nextArg) {
|
|
95
|
+
flags.profile = nextArg;
|
|
96
|
+
return 1;
|
|
97
|
+
}
|
|
98
|
+
if (key === 'a')
|
|
99
|
+
flags.all = true;
|
|
100
|
+
else if (key === 'h')
|
|
101
|
+
flags.help = true;
|
|
102
|
+
else if (key === 'v')
|
|
103
|
+
flags.verbose = true;
|
|
104
|
+
else
|
|
105
|
+
flags[key] = true;
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
function parseFlags(args) {
|
|
109
|
+
const flags = { _: [] };
|
|
110
|
+
let i = 0;
|
|
111
|
+
while (i < args.length) {
|
|
112
|
+
const arg = args[i];
|
|
113
|
+
const next = args[i + 1];
|
|
114
|
+
if (arg.startsWith('--')) {
|
|
115
|
+
i += 1 + parseLongFlag(arg, next, flags);
|
|
116
|
+
}
|
|
117
|
+
else if (arg.startsWith('-')) {
|
|
118
|
+
i += 1 + parseShortFlag(arg, next, flags);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
flags._.push(arg);
|
|
122
|
+
i += 1;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return flags;
|
|
126
|
+
}
|
|
127
|
+
function extractProfileId(flags) {
|
|
128
|
+
if (typeof flags.profile === 'string')
|
|
129
|
+
return flags.profile;
|
|
130
|
+
if (typeof flags.p === 'string')
|
|
131
|
+
return flags.p;
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
async function handleTest(flags) {
|
|
135
|
+
const profile = extractProfileId(flags);
|
|
136
|
+
const diagnostics = cliDiagnostics(flags);
|
|
137
|
+
const success = await testProfileCommand(profile, {
|
|
138
|
+
all: Boolean(flags.all || flags.a),
|
|
139
|
+
lite: Boolean(flags.lite),
|
|
140
|
+
matrix: Boolean(flags.matrix),
|
|
141
|
+
mode: typeof flags.mode === 'string' ? flags.mode : undefined,
|
|
142
|
+
search: flags.search ? true : undefined,
|
|
143
|
+
map: flags.map ? true : undefined,
|
|
144
|
+
verbose: diagnostics.verbose,
|
|
145
|
+
trace: diagnostics.trace,
|
|
146
|
+
traceDir: diagnostics.traceDir,
|
|
147
|
+
});
|
|
148
|
+
if (!success) {
|
|
149
|
+
exit(1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function handleRun(flags) {
|
|
153
|
+
const profile = extractProfileId(flags);
|
|
154
|
+
if (!profile) {
|
|
155
|
+
console.error('Error: Profile ID required (e.g. `agents run --profile your-profile`)');
|
|
156
|
+
exit(1);
|
|
157
|
+
}
|
|
158
|
+
const prompt = typeof flags.prompt === 'string' ? flags.prompt : flags._.slice(1).join(' ');
|
|
159
|
+
const diagnostics = cliDiagnostics(flags);
|
|
160
|
+
await runCommand({
|
|
161
|
+
profile,
|
|
162
|
+
prompt,
|
|
163
|
+
mode: typeof flags.mode === 'string' ? flags.mode : undefined,
|
|
164
|
+
search: Boolean(flags.search),
|
|
165
|
+
map: Boolean(flags.map),
|
|
166
|
+
verbose: diagnostics.verbose,
|
|
167
|
+
trace: diagnostics.trace,
|
|
168
|
+
traceDir: diagnostics.traceDir,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function numberFlag(flags, key) {
|
|
172
|
+
return typeof flags[key] === 'string' ? Number(flags[key]) : undefined;
|
|
173
|
+
}
|
|
174
|
+
async function handleEval(flags) {
|
|
175
|
+
const suite = flags._[1];
|
|
176
|
+
if (!suite) {
|
|
177
|
+
console.error('Error: Suite module required (e.g. `agents eval ./evals/suite.ts`)');
|
|
178
|
+
exit(1);
|
|
179
|
+
}
|
|
180
|
+
const ok = await evalCommand({
|
|
181
|
+
suite,
|
|
182
|
+
recorded: typeof flags.recorded === 'string' ? flags.recorded : undefined,
|
|
183
|
+
trials: numberFlag(flags, 'trials'),
|
|
184
|
+
concurrency: numberFlag(flags, 'concurrency'),
|
|
185
|
+
maxCostUsd: numberFlag(flags, 'max-cost-usd'),
|
|
186
|
+
threshold: numberFlag(flags, 'threshold'),
|
|
187
|
+
traceDir: cliDiagnostics(flags).traceDir,
|
|
188
|
+
json: Boolean(flags.json),
|
|
189
|
+
});
|
|
190
|
+
if (!ok) {
|
|
191
|
+
exit(1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function handleProfile(flags) {
|
|
195
|
+
const sub = flags._[1] || 'list';
|
|
196
|
+
if (sub === 'list') {
|
|
197
|
+
listProfilesCommand();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const id = sub === 'show' ? flags._[2] || flags.profile : sub;
|
|
201
|
+
if (typeof id !== 'string' || !id) {
|
|
202
|
+
console.error('Error: Profile ID required (e.g. `agents profile show your-profile`)');
|
|
203
|
+
exit(1);
|
|
204
|
+
}
|
|
205
|
+
showProfileCommand(id);
|
|
206
|
+
}
|
|
207
|
+
async function handleDetectCompile(flags) {
|
|
208
|
+
const module = flags._[1];
|
|
209
|
+
if (!module || typeof flags.out !== 'string') {
|
|
210
|
+
console.error('Error: usage `agents detect-compile <module> --out <path> [--export <name>]`');
|
|
211
|
+
exit(1);
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
const detectors = await detectCompileCommand({
|
|
215
|
+
module,
|
|
216
|
+
exportName: typeof flags.export === 'string' ? flags.export : undefined,
|
|
217
|
+
out: flags.out,
|
|
218
|
+
});
|
|
219
|
+
console.log(`Compiled the patterns of ${detectors.join(', ') || 'no detector'} to ${flags.out}`);
|
|
220
|
+
}
|
|
221
|
+
catch (err) {
|
|
222
|
+
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
223
|
+
exit(1);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/** Unknown or omitted commands print help; a command that cannot continue exits 1. */
|
|
227
|
+
export async function main(cliArgs = argv.slice(2)) {
|
|
228
|
+
const flags = parseFlags(cliArgs);
|
|
229
|
+
const command = flags._[0] || (flags.help ? 'help' : 'help');
|
|
230
|
+
if (command === 'fuzz') {
|
|
231
|
+
const ok = fuzzGuardrailsCommand();
|
|
232
|
+
if (!ok) {
|
|
233
|
+
exit(1);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else if (command === 'fuzz-canary') {
|
|
237
|
+
const ok = await fuzzCanaryCommand();
|
|
238
|
+
if (!ok) {
|
|
239
|
+
exit(1);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
else if (command === 'detect-compile') {
|
|
243
|
+
await handleDetectCompile(flags);
|
|
244
|
+
}
|
|
245
|
+
else if (command === 'bench') {
|
|
246
|
+
await benchCommand({
|
|
247
|
+
chunks: typeof flags.chunks === 'string' ? Number(flags.chunks) : undefined,
|
|
248
|
+
iterations: typeof flags.iterations === 'string' ? Number(flags.iterations) : undefined,
|
|
249
|
+
warmup: typeof flags.warmup === 'string' ? Number(flags.warmup) : undefined,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
else if (command === 'test') {
|
|
253
|
+
await handleTest(flags);
|
|
254
|
+
}
|
|
255
|
+
else if (command === 'run') {
|
|
256
|
+
await handleRun(flags);
|
|
257
|
+
}
|
|
258
|
+
else if (command === 'eval') {
|
|
259
|
+
await handleEval(flags);
|
|
260
|
+
}
|
|
261
|
+
else if (command === 'profile') {
|
|
262
|
+
handleProfile(flags);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
printHelp();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const FIXTURE_PNG_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
|
|
2
|
+
export declare const FIXTURE_PDF_BASE64: string;
|
|
3
|
+
export declare function createSyntheticWavBase64(durationSec?: number, sampleRate?: number): string;
|
|
4
|
+
export declare const FIXTURE_WAV_BASE64: string;
|
|
5
|
+
export declare const FIXTURE_CSV_BASE64: string;
|
|
6
|
+
export declare const FIXTURE_TEXT_BASE64: string;
|
|
7
|
+
export declare function getFixtureForMime(mime: string): {
|
|
8
|
+
data: string;
|
|
9
|
+
mimeType: string;
|
|
10
|
+
} | undefined;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const FIXTURE_PNG_BASE64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';
|
|
2
|
+
export const FIXTURE_PDF_BASE64 = btoa('%PDF-1.4\n1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj\n2 0 obj<</Type/Pages/Count 1/Kids[3 0 R]>>endobj\n3 0 obj<</Type/Page/MediaBox[0 0 612 792]/Parent 2 0 R/Resources<<>>>>endobj\nxref\n0 4\n0000000000 65535 f \n0000000009 00000 n \n0000000056 00000 n \n0000000111 00000 n \ntrailer<</Size 4/Root 1 0 R>>\nstartxref\n188\n%%EOF\n');
|
|
3
|
+
export function createSyntheticWavBase64(durationSec = 0.1, sampleRate = 16000) {
|
|
4
|
+
const numSamples = Math.floor(sampleRate * durationSec);
|
|
5
|
+
const dataSize = numSamples * 2;
|
|
6
|
+
const buffer = new ArrayBuffer(44 + dataSize);
|
|
7
|
+
const view = new DataView(buffer);
|
|
8
|
+
view.setUint8(0, 0x52);
|
|
9
|
+
view.setUint8(1, 0x49);
|
|
10
|
+
view.setUint8(2, 0x46);
|
|
11
|
+
view.setUint8(3, 0x46);
|
|
12
|
+
view.setUint32(4, 36 + dataSize, true);
|
|
13
|
+
view.setUint8(8, 0x57);
|
|
14
|
+
view.setUint8(9, 0x41);
|
|
15
|
+
view.setUint8(10, 0x56);
|
|
16
|
+
view.setUint8(11, 0x45);
|
|
17
|
+
view.setUint8(12, 0x66);
|
|
18
|
+
view.setUint8(13, 0x6d);
|
|
19
|
+
view.setUint8(14, 0x74);
|
|
20
|
+
view.setUint8(15, 0x20);
|
|
21
|
+
view.setUint32(16, 16, true);
|
|
22
|
+
view.setUint16(20, 1, true);
|
|
23
|
+
view.setUint16(22, 1, true);
|
|
24
|
+
view.setUint32(24, sampleRate, true);
|
|
25
|
+
view.setUint32(28, sampleRate * 2, true);
|
|
26
|
+
view.setUint16(32, 2, true);
|
|
27
|
+
view.setUint16(34, 16, true);
|
|
28
|
+
view.setUint8(36, 0x64);
|
|
29
|
+
view.setUint8(37, 0x61);
|
|
30
|
+
view.setUint8(38, 0x74);
|
|
31
|
+
view.setUint8(39, 0x61);
|
|
32
|
+
view.setUint32(40, dataSize, true);
|
|
33
|
+
const freq = 440;
|
|
34
|
+
for (let i = 0; i < numSamples; i++) {
|
|
35
|
+
const t = i / sampleRate;
|
|
36
|
+
const sample = Math.sin(2 * Math.PI * freq * t) * 0.2 * 32767;
|
|
37
|
+
view.setInt16(44 + i * 2, sample, true);
|
|
38
|
+
}
|
|
39
|
+
const bytes = new Uint8Array(buffer);
|
|
40
|
+
let binary = '';
|
|
41
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
42
|
+
binary += String.fromCharCode(bytes[i]);
|
|
43
|
+
}
|
|
44
|
+
return btoa(binary);
|
|
45
|
+
}
|
|
46
|
+
export const FIXTURE_WAV_BASE64 = createSyntheticWavBase64(0.1, 16000);
|
|
47
|
+
export const FIXTURE_CSV_BASE64 = btoa('item_id,label,category,score\nitem_1,Alpha,test,0.95\nitem_2,Beta,test,0.88\n');
|
|
48
|
+
export const FIXTURE_TEXT_BASE64 = btoa('This is a synthetic fixture text document for Theorem validation testing.\n');
|
|
49
|
+
export function getFixtureForMime(mime) {
|
|
50
|
+
const m = mime.toLowerCase().trim();
|
|
51
|
+
if (m.startsWith('image/')) {
|
|
52
|
+
return { data: FIXTURE_PNG_BASE64, mimeType: 'image/png' };
|
|
53
|
+
}
|
|
54
|
+
if (m === 'application/pdf') {
|
|
55
|
+
return { data: FIXTURE_PDF_BASE64, mimeType: 'application/pdf' };
|
|
56
|
+
}
|
|
57
|
+
if (m === 'audio/wav' || m === 'audio/x-wav' || m.startsWith('audio/')) {
|
|
58
|
+
return { data: FIXTURE_WAV_BASE64, mimeType: 'audio/wav' };
|
|
59
|
+
}
|
|
60
|
+
if (m === 'text/csv') {
|
|
61
|
+
return { data: FIXTURE_CSV_BASE64, mimeType: 'text/csv' };
|
|
62
|
+
}
|
|
63
|
+
if (m === 'text/plain') {
|
|
64
|
+
return { data: FIXTURE_TEXT_BASE64, mimeType: 'text/plain' };
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ModelProfile, TurnRequest } from '../../kernel/types.js';
|
|
2
|
+
export interface MatrixOptions {
|
|
3
|
+
lite?: boolean;
|
|
4
|
+
/** Requires googleSearch on the selected model's builtInTools. */
|
|
5
|
+
search?: boolean;
|
|
6
|
+
/** Requires googleMaps on the selected model's builtInTools. */
|
|
7
|
+
map?: boolean;
|
|
8
|
+
mode?: string;
|
|
9
|
+
attachmentPaths?: string[];
|
|
10
|
+
voicePath?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function synthesizeLiteCombo(profile: ModelProfile): TurnRequest;
|
|
13
|
+
export declare function synthesizeStressCombo(profile: ModelProfile): TurnRequest;
|
|
14
|
+
export declare function synthesizeMatrixCombos(profile: ModelProfile): Array<{
|
|
15
|
+
name: string;
|
|
16
|
+
req: TurnRequest;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function buildCustomTurnRequest(profile: ModelProfile, options: MatrixOptions): TurnRequest;
|