theorum 0.1.15 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +241 -98
- package/esm/mod.d.ts +57 -28
- package/esm/mod.js +43 -23
- package/esm/src/cli/commands/bench.js +18 -18
- package/esm/src/cli/commands/fuzz-canary.d.ts +13 -0
- package/esm/src/cli/commands/fuzz-canary.js +191 -0
- package/esm/src/cli/commands/fuzz-guardrails.d.ts +3 -5
- package/esm/src/cli/commands/fuzz-guardrails.js +4 -581
- package/esm/src/cli/commands/guardrails-eval.d.ts +14 -0
- package/esm/src/cli/commands/guardrails-eval.js +15 -0
- package/esm/src/cli/commands/profile.js +35 -15
- package/esm/src/cli/commands/run.d.ts +3 -0
- package/esm/src/cli/commands/run.js +23 -32
- package/esm/src/cli/commands/test.d.ts +10 -1
- package/esm/src/cli/commands/test.js +34 -34
- package/esm/src/cli/event-log.d.ts +19 -0
- package/esm/src/cli/event-log.js +147 -0
- package/esm/src/cli/index.js +57 -11
- package/esm/src/cli/matrix/synthesizer.d.ts +10 -12
- package/esm/src/cli/matrix/synthesizer.js +45 -118
- package/esm/src/guardrails/canary-gate.d.ts +21 -0
- package/esm/src/guardrails/canary-gate.js +32 -0
- package/esm/src/guardrails/canary.d.ts +34 -0
- package/esm/src/guardrails/canary.js +150 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.d.ts +17 -0
- package/esm/src/guardrails/corpus/canary-egress-attacks.js +151 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.d.ts +11 -0
- package/esm/src/guardrails/corpus/fuzz-inbound.js +213 -0
- package/esm/src/guardrails/corpus/inbound-payloads.d.ts +10 -0
- package/esm/src/guardrails/corpus/inbound-payloads.js +125 -0
- package/esm/src/guardrails/corpus/live-attacks.d.ts +20 -0
- package/esm/src/guardrails/corpus/live-attacks.js +231 -0
- package/esm/src/guardrails/corpus/mod.d.ts +14 -0
- package/esm/src/guardrails/corpus/mod.js +11 -0
- package/esm/src/guardrails/corpus/secrets.d.ts +17 -0
- package/esm/src/guardrails/corpus/secrets.js +17 -0
- package/esm/src/guardrails/corpus/strings.d.ts +28 -0
- package/esm/src/guardrails/corpus/strings.js +34 -0
- package/esm/src/guardrails/corpus/types.d.ts +38 -0
- package/esm/src/guardrails/corpus/types.js +6 -0
- package/esm/src/guardrails/egress.d.ts +32 -0
- package/esm/src/guardrails/egress.js +87 -0
- package/esm/src/guardrails/error.d.ts +14 -23
- package/esm/src/guardrails/error.js +87 -76
- package/esm/src/guardrails/eval/corpus.d.ts +108 -0
- package/esm/src/guardrails/eval/corpus.js +978 -0
- package/esm/src/guardrails/eval/mod.d.ts +51 -0
- package/esm/src/guardrails/eval/mod.js +133 -0
- package/esm/src/guardrails/eval/score.d.ts +66 -0
- package/esm/src/guardrails/eval/score.js +114 -0
- package/esm/src/guardrails/events.d.ts +25 -0
- package/esm/src/guardrails/events.js +56 -0
- package/esm/src/guardrails/hits.d.ts +24 -0
- package/esm/src/guardrails/hits.js +45 -0
- package/esm/src/guardrails/injection.js +28 -5
- package/esm/src/guardrails/lexicon.d.ts +39 -0
- package/esm/src/guardrails/lexicon.js +200 -0
- package/esm/src/guardrails/live-outbound-gate.d.ts +41 -0
- package/esm/src/guardrails/live-outbound-gate.js +222 -0
- package/esm/src/guardrails/mod.d.ts +30 -6
- package/esm/src/guardrails/mod.js +20 -5
- package/esm/src/guardrails/network.d.ts +19 -0
- package/esm/src/guardrails/network.js +234 -0
- package/esm/src/guardrails/policy.d.ts +35 -0
- package/esm/src/guardrails/policy.js +50 -0
- package/esm/src/guardrails/progressive-yield.d.ts +51 -0
- package/esm/src/guardrails/progressive-yield.js +98 -0
- package/esm/src/guardrails/quota.d.ts +17 -3
- package/esm/src/guardrails/quota.js +18 -4
- package/esm/src/guardrails/sanitize.d.ts +45 -19
- package/esm/src/guardrails/sanitize.js +177 -94
- package/esm/src/guardrails/sensitive.js +2 -1
- package/esm/src/guardrails/serialize.d.ts +35 -0
- package/esm/src/guardrails/serialize.js +58 -0
- package/esm/src/guardrails/testing.d.ts +17 -0
- package/esm/src/guardrails/testing.js +13 -0
- package/esm/src/guardrails/theorum-error.d.ts +12 -0
- package/esm/src/guardrails/theorum-error.js +15 -0
- package/esm/src/guardrails/tool-directives.d.ts +48 -0
- package/esm/src/guardrails/tool-directives.js +124 -0
- package/esm/src/guardrails/tool-result.d.ts +93 -0
- package/esm/src/guardrails/tool-result.js +276 -0
- package/esm/src/guardrails/types.d.ts +291 -0
- package/esm/src/guardrails/types.js +72 -0
- package/esm/src/host/client-turn.d.ts +19 -0
- package/esm/src/host/client-turn.js +36 -0
- package/esm/src/host/mint-trace.d.ts +1 -1
- package/esm/src/host/mod.d.ts +5 -3
- package/esm/src/host/mod.js +4 -3
- package/esm/src/kernel/auth/crypto.d.ts +42 -0
- package/esm/src/kernel/auth/crypto.js +106 -0
- package/esm/src/kernel/auth/mod.d.ts +11 -0
- package/esm/src/kernel/auth/mod.js +11 -0
- package/esm/src/kernel/auth/oauth.d.ts +47 -0
- package/esm/src/kernel/auth/oauth.js +278 -0
- package/esm/src/kernel/auth/types.d.ts +133 -0
- package/esm/src/kernel/auth/types.js +13 -0
- package/esm/src/kernel/engine/delta.d.ts +24 -2
- package/esm/src/kernel/engine/delta.js +478 -39
- package/esm/src/kernel/engine/live-inbound.d.ts +21 -0
- package/esm/src/kernel/engine/live-inbound.js +31 -0
- package/esm/src/kernel/engine/live-ingress.d.ts +19 -0
- package/esm/src/kernel/engine/live-ingress.js +47 -0
- package/esm/src/kernel/engine/repair.js +13 -12
- package/esm/src/kernel/engine/runner/gates.d.ts +1 -1
- package/esm/src/kernel/engine/runner/gates.js +130 -43
- package/esm/src/kernel/engine/runner/mod.d.ts +6 -4
- package/esm/src/kernel/engine/runner/mod.js +192 -53
- package/esm/src/kernel/engine/runner/schema-validation.js +3 -3
- package/esm/src/kernel/engine/runner/stages.d.ts +39 -0
- package/esm/src/kernel/engine/runner/stages.js +89 -0
- package/esm/src/kernel/engine/runner/state.d.ts +31 -0
- package/esm/src/kernel/engine/runner/steps.d.ts +1 -1
- package/esm/src/kernel/engine/runner/steps.js +244 -43
- package/esm/src/kernel/engine/runner/stream.d.ts +9 -3
- package/esm/src/kernel/engine/runner/stream.js +140 -44
- package/esm/src/kernel/engine/session/mod.d.ts +25 -0
- package/esm/src/kernel/engine/session/mod.js +557 -0
- package/esm/src/kernel/interaction-parts.d.ts +14 -0
- package/esm/src/kernel/interaction-parts.js +23 -0
- package/esm/src/kernel/mod.d.ts +21 -10
- package/esm/src/kernel/mod.js +11 -8
- package/esm/src/kernel/profile-graph.d.ts +159 -0
- package/esm/src/kernel/profile-graph.js +156 -0
- package/esm/src/kernel/registry/attachments.d.ts +12 -10
- package/esm/src/kernel/registry/attachments.js +33 -27
- package/esm/src/kernel/registry/catalog.d.ts +25 -24
- package/esm/src/kernel/registry/catalog.js +60 -101
- package/esm/src/kernel/registry/ingress.d.ts +9 -4
- package/esm/src/kernel/registry/ingress.js +97 -75
- package/esm/src/kernel/registry/profile-outputs.d.ts +4 -0
- package/esm/src/kernel/registry/profile-outputs.js +8 -0
- package/esm/src/kernel/registry/profiles.d.ts +55 -12
- package/esm/src/kernel/registry/profiles.js +413 -73
- package/esm/src/kernel/registry/provider-request.js +13 -7
- package/esm/src/kernel/registry/resolve.d.ts +8 -8
- package/esm/src/kernel/registry/resolve.js +169 -154
- package/esm/src/kernel/registry/schemas.js +1 -1
- package/esm/src/kernel/registry/sole-model.d.ts +8 -0
- package/esm/src/kernel/registry/sole-model.js +10 -0
- package/esm/src/kernel/registry/system-prompt.d.ts +10 -0
- package/esm/src/kernel/registry/system-prompt.js +40 -0
- package/esm/src/kernel/registry/system-role.d.ts +8 -0
- package/esm/src/kernel/registry/system-role.js +14 -0
- package/esm/src/kernel/registry/vault.d.ts +12 -7
- package/esm/src/kernel/registry/vault.js +32 -10
- package/esm/src/kernel/schema.d.ts +231 -0
- package/esm/src/kernel/schema.js +607 -0
- package/esm/src/kernel/stages.d.ts +175 -0
- package/esm/src/kernel/stages.js +476 -0
- package/esm/src/kernel/stop.d.ts +78 -19
- package/esm/src/kernel/stop.js +51 -16
- package/esm/src/kernel/tools/events.d.ts +41 -0
- package/esm/src/kernel/tools/events.js +71 -0
- package/esm/src/kernel/tools/execute.d.ts +84 -0
- package/esm/src/kernel/tools/execute.js +614 -0
- package/esm/src/kernel/tools/harness.d.ts +8 -0
- package/esm/src/kernel/tools/harness.js +46 -0
- package/esm/src/kernel/tools/invoke.d.ts +10 -0
- package/esm/src/kernel/tools/invoke.js +101 -0
- package/esm/src/kernel/tools/mod.d.ts +13 -0
- package/esm/src/kernel/tools/mod.js +11 -0
- package/esm/src/kernel/tools/permission.d.ts +15 -0
- package/esm/src/kernel/tools/permission.js +47 -0
- package/esm/src/kernel/tools/project.d.ts +12 -0
- package/esm/src/kernel/tools/project.js +36 -0
- package/esm/src/kernel/tools/registry.d.ts +23 -0
- package/esm/src/kernel/tools/registry.js +81 -0
- package/esm/src/kernel/tools/remote.d.ts +94 -0
- package/esm/src/kernel/tools/remote.js +577 -0
- package/esm/src/kernel/tools/resolve.d.ts +39 -0
- package/esm/src/kernel/tools/resolve.js +283 -0
- package/esm/src/kernel/tools/schema.d.ts +15 -0
- package/esm/src/kernel/tools/schema.js +176 -0
- package/esm/src/kernel/tools/stage-run.d.ts +105 -0
- package/esm/src/kernel/tools/stage-run.js +155 -0
- package/esm/src/kernel/tools/types.d.ts +394 -0
- package/esm/src/kernel/tools/types.js +9 -0
- package/esm/src/kernel/types.d.ts +540 -256
- package/esm/src/kernel/util/find-last.d.ts +2 -0
- package/esm/src/kernel/util/find-last.js +10 -0
- package/esm/src/observability/destinations.d.ts +31 -0
- package/esm/src/observability/destinations.js +67 -0
- package/esm/src/observability/mod.d.ts +10 -3
- package/esm/src/observability/mod.js +6 -2
- package/esm/src/observability/policy.d.ts +27 -0
- package/esm/src/observability/policy.js +80 -0
- package/esm/src/observability/resolve-policy.d.ts +16 -0
- package/esm/src/observability/resolve-policy.js +64 -0
- package/esm/src/observability/trace-attach.d.ts +8 -4
- package/esm/src/observability/trace-attach.js +50 -29
- package/esm/src/observability/trace-record.d.ts +23 -13
- package/esm/src/observability/trace-record.js +96 -39
- package/esm/src/observability/trace-sink.d.ts +19 -0
- package/esm/src/observability/trace-sink.js +10 -0
- package/esm/src/observability/trace-usage.d.ts +10 -3
- package/esm/src/observability/trace-usage.js +70 -17
- package/esm/src/observability/trace.d.ts +18 -7
- package/esm/src/observability/trace.js +34 -17
- package/esm/src/observability/types.d.ts +113 -0
- package/esm/src/observability/types.js +11 -0
- package/esm/src/presets/google/speech-voices.d.ts +11 -0
- package/esm/src/presets/google/speech-voices.js +41 -0
- package/esm/src/presets/google.d.ts +36 -24
- package/esm/src/presets/google.js +50 -63
- package/esm/src/presets/mod.d.ts +2 -2
- package/esm/src/presets/mod.js +1 -1
- package/esm/src/providers/create-provider.d.ts +20 -17
- package/esm/src/providers/create-provider.js +72 -26
- package/esm/src/providers/google/interactions/framing.d.ts +23 -0
- package/esm/src/providers/google/interactions/framing.js +269 -0
- package/esm/src/providers/google/interactions/mod.d.ts +7 -0
- package/esm/src/providers/google/interactions/mod.js +7 -0
- package/esm/src/providers/google/interactions/stream.d.ts +83 -0
- package/esm/src/providers/google/interactions/stream.js +588 -0
- package/esm/src/providers/google/keys.d.ts +26 -0
- package/esm/src/providers/{keys.js → google/keys.js} +19 -31
- package/esm/src/providers/google/live/framing.d.ts +49 -0
- package/esm/src/providers/google/live/framing.js +552 -0
- package/esm/src/providers/google/live/openapi-schema.d.ts +6 -0
- package/esm/src/providers/google/live/openapi-schema.js +46 -0
- package/esm/src/providers/google/live/session.d.ts +25 -0
- package/esm/src/providers/google/live/session.js +134 -0
- package/esm/src/providers/google/live/stream.d.ts +45 -0
- package/esm/src/providers/google/live/stream.js +214 -0
- package/esm/src/providers/google/urls.d.ts +6 -0
- package/esm/src/providers/google/urls.js +6 -0
- package/esm/src/providers/local/local.d.ts +30 -0
- package/esm/src/providers/{local.js → local/local.js} +66 -126
- package/esm/src/providers/local/mod.d.ts +9 -0
- package/esm/src/providers/local/mod.js +9 -0
- package/esm/src/providers/mod.d.ts +6 -3
- package/esm/src/providers/mod.js +3 -1
- package/esm/src/providers/openrouter/cache-control.d.ts +24 -0
- package/esm/src/providers/openrouter/cache-control.js +23 -0
- package/esm/src/providers/openrouter/chat.d.ts +107 -0
- package/esm/src/providers/{openrouter.js → openrouter/chat.js} +117 -231
- package/esm/src/providers/openrouter/image.d.ts +34 -0
- package/esm/src/providers/openrouter/image.js +275 -0
- package/esm/src/providers/openrouter/openai/chat-payload.d.ts +24 -0
- package/esm/src/providers/openrouter/openai/chat-payload.js +82 -0
- package/esm/src/providers/openrouter/openai/compat.d.ts +53 -0
- package/esm/src/providers/openrouter/openai/compat.js +213 -0
- package/esm/src/providers/openrouter/openai/image-payload.d.ts +18 -0
- package/esm/src/providers/openrouter/openai/image-payload.js +90 -0
- package/esm/src/providers/openrouter/openai/sdk-messages.d.ts +22 -0
- package/esm/src/providers/openrouter/openai/sdk-messages.js +122 -0
- package/esm/src/providers/openrouter/resolve-api-key.d.ts +9 -0
- package/esm/src/providers/openrouter/resolve-api-key.js +24 -0
- package/esm/src/providers/openrouter/speech.d.ts +23 -0
- package/esm/src/providers/{speech.js → openrouter/speech.js} +32 -55
- package/esm/src/providers/probe.d.ts +1 -0
- package/esm/src/providers/probe.js +22 -0
- package/esm/src/providers/shared/pcm.d.ts +12 -0
- package/esm/src/providers/{pcm.js → shared/pcm.js} +16 -3
- package/esm/src/providers/shared/sse.d.ts +18 -0
- package/esm/src/providers/shared/sse.js +87 -0
- package/esm/src/providers/shared/tool-args.d.ts +17 -0
- package/esm/src/providers/shared/tool-args.js +45 -0
- package/esm/src/providers/shared/upstream-tap.d.ts +5 -0
- package/esm/src/providers/{google-tap.js → shared/upstream-tap.js} +4 -7
- package/esm/src/providers/shared/upstream-tape.d.ts +6 -0
- package/esm/src/providers/{gemini-tape.js → shared/upstream-tape.js} +12 -22
- package/esm/src/providers/types.d.ts +27 -0
- package/esm/src/providers/types.js +1 -0
- package/package.json +11 -7
- package/docs/cli.md +0 -97
- package/docs/guardrails.md +0 -178
- package/docs/host.md +0 -97
- package/docs/kernel.md +0 -404
- package/docs/observability.md +0 -105
- package/docs/openrouter.md +0 -125
- package/docs/presets-google.md +0 -91
- package/docs/presets.md +0 -88
- package/docs/providers.md +0 -202
- package/docs/streaming.md +0 -96
- package/esm/src/kernel/engine/boundary.d.ts +0 -10
- package/esm/src/kernel/engine/boundary.js +0 -55
- package/esm/src/kernel/engine/runner/tools.d.ts +0 -13
- package/esm/src/kernel/engine/runner/tools.js +0 -198
- package/esm/src/kernel/registry/tools.d.ts +0 -12
- package/esm/src/kernel/registry/tools.js +0 -36
- package/esm/src/providers/expose-for-tests.d.ts +0 -1
- package/esm/src/providers/expose-for-tests.js +0 -25
- package/esm/src/providers/gemini-tape.d.ts +0 -2
- package/esm/src/providers/google-tap.d.ts +0 -3
- package/esm/src/providers/interactions.d.ts +0 -5
- package/esm/src/providers/interactions.js +0 -169
- package/esm/src/providers/keys.d.ts +0 -19
- package/esm/src/providers/local.d.ts +0 -29
- package/esm/src/providers/openrouter-mod.d.ts +0 -13
- package/esm/src/providers/openrouter-mod.js +0 -12
- package/esm/src/providers/openrouter-payload.d.ts +0 -39
- package/esm/src/providers/openrouter-payload.js +0 -195
- package/esm/src/providers/openrouter.d.ts +0 -15
- package/esm/src/providers/pcm.d.ts +0 -7
- package/esm/src/providers/provider.d.ts +0 -15
- package/esm/src/providers/provider.js +0 -202
- package/esm/src/providers/speech.d.ts +0 -23
- package/esm/src/providers/sse.d.ts +0 -7
- package/esm/src/providers/sse.js +0 -55
- package/esm/src/streaming/mod.d.ts +0 -9
- package/esm/src/streaming/mod.js +0 -8
- /package/esm/src/{streaming → host}/readStreamingJsonStringField.d.ts +0 -0
- /package/esm/src/{streaming → host}/readStreamingJsonStringField.js +0 -0
|
@@ -1,28 +1,48 @@
|
|
|
1
1
|
import { getProfile, listProfiles } from '../../kernel/registry/profiles.js';
|
|
2
2
|
function formatProfileInputs(p) {
|
|
3
|
+
if (p.type === 'speech') {
|
|
4
|
+
return 'text (speech)';
|
|
5
|
+
}
|
|
6
|
+
if (p.type === 'live') {
|
|
7
|
+
return 'audio/video (live)';
|
|
8
|
+
}
|
|
3
9
|
const inputs = [];
|
|
4
|
-
|
|
10
|
+
const { inputs: spec } = p;
|
|
11
|
+
if (!spec) {
|
|
12
|
+
return 'none';
|
|
13
|
+
}
|
|
14
|
+
if (spec.text !== false)
|
|
5
15
|
inputs.push('text');
|
|
6
|
-
if (
|
|
16
|
+
if (spec.voice)
|
|
7
17
|
inputs.push('voice');
|
|
8
|
-
if (
|
|
9
|
-
inputs.push(`attachments [${
|
|
10
|
-
|
|
18
|
+
if (spec.attachments) {
|
|
19
|
+
inputs.push(`attachments [${spec.attachments.accept?.join(', ')}]`);
|
|
20
|
+
}
|
|
21
|
+
return inputs.join(' | ') || 'none';
|
|
22
|
+
}
|
|
23
|
+
function formatProfileTools(p) {
|
|
24
|
+
if (p.type === 'speech') {
|
|
25
|
+
return 'none';
|
|
26
|
+
}
|
|
27
|
+
return p.tools.allow?.length ? p.tools.allow.join(', ') : 'none';
|
|
11
28
|
}
|
|
12
29
|
function printProfileCard(p) {
|
|
13
|
-
const tools = p
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
const tools = formatProfileTools(p);
|
|
31
|
+
if (p.type === 'host') {
|
|
32
|
+
console.log(` • Profile: ${p.id.padEnd(16)} [host]`);
|
|
33
|
+
console.log(` - Tools: ${tools}`);
|
|
34
|
+
console.log('-'.repeat(70));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const models = Object.keys(p.models).join(', ') || 'default';
|
|
38
|
+
const structured = p.type === 'live' || p.type === 'speech' ? undefined : p.outputs?.structured;
|
|
39
|
+
const structuredLabel = typeof structured === 'string' ? structured : structured ? 'custom' : 'none';
|
|
40
|
+
console.log(` • Profile: ${p.id.padEnd(16)} (handle: ${p.identity.handle}) [${p.type}]`);
|
|
21
41
|
console.log(` - Models: ${models}`);
|
|
22
42
|
console.log(` - Inputs: ${formatProfileInputs(p)}`);
|
|
23
43
|
console.log(` - Tools: ${tools}`);
|
|
24
|
-
console.log(` - Structured: ${
|
|
25
|
-
console.log(` - Key
|
|
44
|
+
console.log(` - Structured: ${structuredLabel}`);
|
|
45
|
+
console.log(` - Key Slot: ${p.key ?? '(unset)'}`);
|
|
26
46
|
console.log('-'.repeat(70));
|
|
27
47
|
}
|
|
28
48
|
export function listProfilesCommand() {
|
|
@@ -1,53 +1,44 @@
|
|
|
1
|
-
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
1
|
import { runTurn } from '../../kernel/engine/runner.js';
|
|
3
2
|
import { getProfile } from '../../kernel/registry/profiles.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
dntShim.Deno.stdout.write(new TextEncoder().encode(`\x1b[2m${event.text}\x1b[0m`));
|
|
7
|
-
}
|
|
8
|
-
else if (event.type === 'text' && event.text) {
|
|
9
|
-
dntShim.Deno.stdout.write(new TextEncoder().encode(event.text));
|
|
10
|
-
}
|
|
11
|
-
else if (event.type === 'tool' && event.tool) {
|
|
12
|
-
console.log(`\n\x1b[33m⚡ [Tool Call] ${event.tool.name}\x1b[0m:`, event.tool.arguments);
|
|
13
|
-
}
|
|
14
|
-
else if (event.type === 'structured' && event.structured) {
|
|
15
|
-
console.log('\n\x1b[32m✓ [Structured Output]\x1b[0m:');
|
|
16
|
-
console.log(JSON.stringify(event.structured, null, 2));
|
|
17
|
-
}
|
|
18
|
-
else if (event.type === 'media' && event.media) {
|
|
19
|
-
console.log(`\n\x1b[34m🖼 [Media Output]\x1b[0m (${event.media.mimeType})`);
|
|
20
|
-
}
|
|
21
|
-
else if (event.type === 'error' && event.error) {
|
|
22
|
-
console.error(`\n\x1b[31m✗ Error\x1b[0m: ${event.error}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
3
|
+
import { requireModelProfile } from '../../kernel/registry/resolve.js';
|
|
4
|
+
import { createCliTraceCapture, printRunEvent, printTraceRecord } from '../event-log.js';
|
|
25
5
|
export async function runCommand(options) {
|
|
26
|
-
getProfile(options.profile);
|
|
6
|
+
requireModelProfile(getProfile(options.profile), 'theorum run');
|
|
27
7
|
const provider = options.provider;
|
|
28
8
|
if (!provider) {
|
|
29
9
|
console.error('\n\x1b[31mExecution Failed\x1b[0m: Theorum CLI does not create providers or read keys. Run turns from a host app with an explicit ModelProvider.\n');
|
|
30
10
|
return;
|
|
31
11
|
}
|
|
32
12
|
const prompt = options.prompt || 'Hello! Please introduce your capabilities.';
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
if (options.search || options.map) {
|
|
14
|
+
const profile = requireModelProfile(getProfile(options.profile), 'theorum run');
|
|
15
|
+
const selected = options.mode ?? profile.defaultModel ?? Object.keys(profile.models)[0] ?? '';
|
|
16
|
+
const builtins = new Set(profile.models[selected]?.builtInTools ?? []);
|
|
17
|
+
if (options.search && !builtins.has('googleSearch')) {
|
|
18
|
+
console.error('\n\x1b[31mExecution Failed\x1b[0m: --search requires googleSearch on models.*.builtInTools for the selected model.\n');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (options.map && !builtins.has('googleMaps')) {
|
|
22
|
+
console.error('\n\x1b[31mExecution Failed\x1b[0m: --map requires googleMaps on models.*.builtInTools for the selected model.\n');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
38
26
|
const req = {
|
|
39
27
|
profile: options.profile,
|
|
40
|
-
|
|
41
|
-
tools: Object.keys(tools).length > 0 ? tools : undefined,
|
|
28
|
+
model: options.mode,
|
|
42
29
|
input: { text: prompt },
|
|
43
30
|
};
|
|
44
31
|
console.log(`\n▶ [RUNNING TURN] Profile: ${options.profile} (${options.mode ?? 'default'})`);
|
|
45
32
|
console.log(`Prompt: "${prompt}"\n`);
|
|
33
|
+
const traceCapture = options.trace ? createCliTraceCapture(options.traceDir) : undefined;
|
|
46
34
|
try {
|
|
47
|
-
for await (const event of runTurn(req, provider)) {
|
|
48
|
-
|
|
35
|
+
for await (const event of runTurn(req, provider, traceCapture?.sink)) {
|
|
36
|
+
printRunEvent(event, { verbose: options.verbose });
|
|
49
37
|
}
|
|
50
38
|
console.log('\n');
|
|
39
|
+
if (options.trace) {
|
|
40
|
+
printTraceRecord(traceCapture?.records.at(-1), options.verbose === true);
|
|
41
|
+
}
|
|
51
42
|
}
|
|
52
43
|
catch (err) {
|
|
53
44
|
console.error(`\n\x1b[31mExecution Failed\x1b[0m: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
@@ -7,9 +7,18 @@ export interface TestRunResult {
|
|
|
7
7
|
tokensTotal?: number;
|
|
8
8
|
error?: string;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
interface CliTestOptions {
|
|
11
|
+
verbose?: boolean;
|
|
12
|
+
trace?: boolean;
|
|
13
|
+
traceDir?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function executeSingleTest(req: TurnRequest, testName: string, provider?: ModelProvider, cliOptions?: CliTestOptions): Promise<TestRunResult>;
|
|
11
16
|
export declare function testProfileCommand(profileId?: string, options?: MatrixOptions & {
|
|
12
17
|
all?: boolean;
|
|
13
18
|
matrix?: boolean;
|
|
14
19
|
provider?: ModelProvider;
|
|
20
|
+
verbose?: boolean;
|
|
21
|
+
trace?: boolean;
|
|
22
|
+
traceDir?: string;
|
|
15
23
|
}): Promise<boolean>;
|
|
24
|
+
export {};
|
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
1
|
import { runTurn } from '../../kernel/engine/runner.js';
|
|
3
2
|
import { getProfile, listProfiles } from '../../kernel/registry/profiles.js';
|
|
3
|
+
import { requireModelProfile } from '../../kernel/registry/resolve.js';
|
|
4
|
+
import { createCliTraceCapture, printTestEvent, printTraceRecord } from '../event-log.js';
|
|
4
5
|
import { buildCustomTurnRequest, synthesizeMatrixCombos, } from '../matrix/synthesizer.js';
|
|
5
6
|
function printTestHeader(req, testName) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const profile = requireModelProfile(getProfile(req.profile), 'theorum test');
|
|
8
|
+
const modelId = req.model && profile.models[req.model] ? req.model : (Object.keys(profile.models)[0] ?? '');
|
|
9
|
+
const customs = profile.type === 'speech' ? 'none' : profile.tools.allow.join(', ') || 'none';
|
|
10
|
+
const builtins = (profile.models[modelId]?.builtInTools ?? []).join(', ') || 'none';
|
|
10
11
|
console.log(`\n▶ [THEORUM TEST] ${testName}`);
|
|
11
|
-
console.log(` Profile: ${req.profile} (
|
|
12
|
-
console.log(`
|
|
12
|
+
console.log(` Profile: ${req.profile} (Model: ${req.model ?? 'default'})`);
|
|
13
|
+
console.log(` Custom: ${customs}`);
|
|
14
|
+
console.log(` Builtins: ${builtins}`);
|
|
13
15
|
console.log(` Attachments: ${req.input?.attachments?.length ?? 0} file(s) | Voice: ${req.input?.voice?.length ? 'yes' : 'no'}`);
|
|
14
16
|
console.log(` ${'-'.repeat(60)}`);
|
|
15
17
|
}
|
|
16
|
-
function processTestEvent(event, acc) {
|
|
17
|
-
if (event.type === '
|
|
18
|
-
dntShim.Deno.stdout.write(new TextEncoder().encode('.'));
|
|
19
|
-
}
|
|
20
|
-
else if (event.type === 'tool' && event.tool) {
|
|
21
|
-
console.log(`\n ⚡ [Tool Dispatched] ${event.tool.name}(${JSON.stringify(event.tool.arguments ?? {})})`);
|
|
22
|
-
}
|
|
23
|
-
else if (event.type === 'structured') {
|
|
24
|
-
console.log(`\n ✓ [Structured Schema Validated]`);
|
|
25
|
-
}
|
|
26
|
-
else if (event.type === 'media') {
|
|
27
|
-
console.log(`\n ✓ [Media Generated] (${event.media?.mimeType})`);
|
|
28
|
-
}
|
|
29
|
-
else if (event.type === 'tokens' && event.tokens) {
|
|
18
|
+
function processTestEvent(event, acc, options) {
|
|
19
|
+
if (event.type === 'tokens' && event.tokens) {
|
|
30
20
|
acc.totalTokens = event.tokens.total;
|
|
31
21
|
}
|
|
32
|
-
|
|
22
|
+
if (event.type === 'error' && event.error) {
|
|
33
23
|
acc.hasError = true;
|
|
34
24
|
acc.errorMessage = event.error;
|
|
35
|
-
console.error(`\n [Test Error Detail]: ${event.error}`);
|
|
36
25
|
}
|
|
26
|
+
printTestEvent(event, { verbose: options.verbose });
|
|
37
27
|
}
|
|
38
28
|
function printTestResult(passed, durationSec, acc) {
|
|
39
29
|
if (passed) {
|
|
@@ -43,7 +33,7 @@ function printTestResult(passed, durationSec, acc) {
|
|
|
43
33
|
console.log(`\n ✗ STATUS: FAILED: ${acc.errorMessage} (${durationSec.toFixed(2)}s)`);
|
|
44
34
|
}
|
|
45
35
|
}
|
|
46
|
-
export async function executeSingleTest(req, testName, provider) {
|
|
36
|
+
export async function executeSingleTest(req, testName, provider, cliOptions = {}) {
|
|
47
37
|
const start = Date.now();
|
|
48
38
|
getProfile(req.profile);
|
|
49
39
|
printTestHeader(req, testName);
|
|
@@ -56,8 +46,12 @@ export async function executeSingleTest(req, testName, provider) {
|
|
|
56
46
|
if (!provider) {
|
|
57
47
|
throw new Error('Theorum CLI does not create providers or read keys. Pass an explicit ModelProvider from the host app.');
|
|
58
48
|
}
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
const traceCapture = cliOptions.trace ? createCliTraceCapture(cliOptions.traceDir) : undefined;
|
|
50
|
+
for await (const event of runTurn(req, provider, traceCapture?.sink)) {
|
|
51
|
+
processTestEvent(event, acc, cliOptions);
|
|
52
|
+
}
|
|
53
|
+
if (cliOptions.trace) {
|
|
54
|
+
printTraceRecord(traceCapture?.records.at(-1), cliOptions.verbose === true);
|
|
61
55
|
}
|
|
62
56
|
}
|
|
63
57
|
catch (err) {
|
|
@@ -77,11 +71,12 @@ export async function executeSingleTest(req, testName, provider) {
|
|
|
77
71
|
}
|
|
78
72
|
function resolveTargetProfiles(profileId, all) {
|
|
79
73
|
if (all) {
|
|
80
|
-
|
|
74
|
+
// Host profiles never run a model, so there is no turn matrix to execute.
|
|
75
|
+
return listProfiles().filter((profile) => profile.type !== 'host');
|
|
81
76
|
}
|
|
82
77
|
if (profileId) {
|
|
83
78
|
try {
|
|
84
|
-
return [getProfile(profileId)];
|
|
79
|
+
return [requireModelProfile(getProfile(profileId), 'theorum test')];
|
|
85
80
|
}
|
|
86
81
|
catch (err) {
|
|
87
82
|
console.error(`\n Error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
@@ -91,19 +86,19 @@ function resolveTargetProfiles(profileId, all) {
|
|
|
91
86
|
console.error('Error: Please specify a profile ID (e.g. `theorum test --profile your-profile`) or `--all`.');
|
|
92
87
|
return null;
|
|
93
88
|
}
|
|
94
|
-
async function runProfileMatrix(profile, provider) {
|
|
89
|
+
async function runProfileMatrix(profile, provider, cliOptions = {}) {
|
|
95
90
|
const results = [];
|
|
96
91
|
const combos = synthesizeMatrixCombos(profile);
|
|
97
92
|
for (const combo of combos) {
|
|
98
|
-
const res = await executeSingleTest(combo.req, `${profile.id} [${combo.name}]`, provider);
|
|
93
|
+
const res = await executeSingleTest(combo.req, `${profile.id} [${combo.name}]`, provider, cliOptions);
|
|
99
94
|
results.push(res);
|
|
100
95
|
}
|
|
101
96
|
return results;
|
|
102
97
|
}
|
|
103
|
-
async function runProfileSingle(profile, options, provider) {
|
|
98
|
+
async function runProfileSingle(profile, options, provider, cliOptions = {}) {
|
|
104
99
|
const req = buildCustomTurnRequest(profile, options);
|
|
105
100
|
const testName = options.lite ? `${profile.id} [Lite]` : `${profile.id} [Stress Combo]`;
|
|
106
|
-
return await executeSingleTest(req, testName, provider);
|
|
101
|
+
return await executeSingleTest(req, testName, provider, cliOptions);
|
|
107
102
|
}
|
|
108
103
|
function printSummaryReport(results) {
|
|
109
104
|
console.log(`\n${'='.repeat(70)}`);
|
|
@@ -127,13 +122,18 @@ export async function testProfileCommand(profileId, options = {}) {
|
|
|
127
122
|
if (!targetProfiles || targetProfiles.length === 0) {
|
|
128
123
|
return false;
|
|
129
124
|
}
|
|
125
|
+
const cliOptions = {
|
|
126
|
+
verbose: options.verbose,
|
|
127
|
+
trace: options.trace,
|
|
128
|
+
traceDir: options.traceDir,
|
|
129
|
+
};
|
|
130
130
|
const results = [];
|
|
131
131
|
for (const profile of targetProfiles) {
|
|
132
132
|
if (options.matrix) {
|
|
133
|
-
results.push(...(await runProfileMatrix(profile, options.provider)));
|
|
133
|
+
results.push(...(await runProfileMatrix(profile, options.provider, cliOptions)));
|
|
134
134
|
}
|
|
135
135
|
else {
|
|
136
|
-
results.push(await runProfileSingle(profile, options, options.provider));
|
|
136
|
+
results.push(await runProfileSingle(profile, options, options.provider, cliOptions));
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
return printSummaryReport(results);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TurnEvent } from '../kernel/types.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
|
+
/** Attach an in-memory trace sink; optionally mirror to a JSONL directory. */
|
|
12
|
+
declare function createCliTraceCapture(traceDir?: string): CliTraceCapture;
|
|
13
|
+
/** Print one turn event for `theorum run`. */
|
|
14
|
+
declare function printRunEvent(event: TurnEvent, options?: CliEventLogOptions): void;
|
|
15
|
+
/** Print one turn event for `theorum test`. */
|
|
16
|
+
declare function printTestEvent(event: TurnEvent, options?: CliEventLogOptions): void;
|
|
17
|
+
/** Dump the last captured trace record after a CLI turn. */
|
|
18
|
+
declare function printTraceRecord(record: TraceRecord | undefined, verbose: boolean): void;
|
|
19
|
+
export { createCliTraceCapture, printRunEvent, printTestEvent, printTraceRecord };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared CLI turn-event printing and trace capture for `run` and `test`.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
7
|
+
import { jsonlSink, memorySink } from '../observability/trace.js';
|
|
8
|
+
/** Attach an in-memory trace sink; optionally mirror to a JSONL directory. */
|
|
9
|
+
function createCliTraceCapture(traceDir) {
|
|
10
|
+
const records = [];
|
|
11
|
+
const sinks = [memorySink(records)];
|
|
12
|
+
if (traceDir?.trim()) {
|
|
13
|
+
sinks.push(jsonlSink(traceDir.trim()));
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
records,
|
|
17
|
+
sink: {
|
|
18
|
+
write: async (record) => {
|
|
19
|
+
for (const sink of sinks) {
|
|
20
|
+
await sink.write(record);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function printVerboseEvidence(event) {
|
|
27
|
+
if (event.type !== 'evidence' || !event.evidence) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const e = event.evidence;
|
|
31
|
+
if (e.raw) {
|
|
32
|
+
console.log('\n\x1b[2m[verbose evidence.raw]\x1b[0m');
|
|
33
|
+
console.log(JSON.stringify(e.raw, null, 2));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function printVerboseError(event) {
|
|
37
|
+
if (event.type !== 'error' || !event.errorInternal) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
console.error(`\n\x1b[2m[verbose errorInternal]\x1b[0m ${event.errorInternal}`);
|
|
41
|
+
}
|
|
42
|
+
function printRunEvidence(event, verbose) {
|
|
43
|
+
const e = event.evidence;
|
|
44
|
+
if (!e) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (e.kind === 'code_execution_call') {
|
|
48
|
+
console.log(`\n\x1b[36m🐍 [code_execution_call]\x1b[0m\n${e.code ?? ''}`);
|
|
49
|
+
}
|
|
50
|
+
else if (e.kind === 'code_execution_result') {
|
|
51
|
+
console.log(`\n\x1b[36m🐍 [code_execution_result]\x1b[0m isError=${String(e.isError)}\n${e.result ?? ''}`);
|
|
52
|
+
}
|
|
53
|
+
else if (e.kind) {
|
|
54
|
+
console.log(`\n\x1b[36m📎 [evidence]\x1b[0m ${e.kind}`);
|
|
55
|
+
}
|
|
56
|
+
if (verbose) {
|
|
57
|
+
printVerboseEvidence(event);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Print one turn event for `theorum run`. */
|
|
61
|
+
function printRunEvent(event, options = {}) {
|
|
62
|
+
const verbose = options.verbose === true;
|
|
63
|
+
if (event.type === 'thought' && event.text) {
|
|
64
|
+
dntShim.Deno.stdout.write(new TextEncoder().encode(`\x1b[2m${event.text}\x1b[0m`));
|
|
65
|
+
}
|
|
66
|
+
else if (event.type === 'text' && event.text) {
|
|
67
|
+
dntShim.Deno.stdout.write(new TextEncoder().encode(event.text));
|
|
68
|
+
}
|
|
69
|
+
else if (event.type === 'tool' && event.tool) {
|
|
70
|
+
console.log(`\n\x1b[33m⚡ [Tool Call] ${event.tool.name}\x1b[0m:`, event.tool.arguments);
|
|
71
|
+
}
|
|
72
|
+
else if (event.type === 'evidence') {
|
|
73
|
+
printRunEvidence(event, verbose);
|
|
74
|
+
}
|
|
75
|
+
else if (event.type === 'structured' && event.structured) {
|
|
76
|
+
console.log('\n\x1b[32m✓ [Structured Output]\x1b[0m:');
|
|
77
|
+
console.log(JSON.stringify(event.structured, null, 2));
|
|
78
|
+
}
|
|
79
|
+
else if (event.type === 'media' && event.media) {
|
|
80
|
+
console.log(`\n\x1b[34m🖼 [Media Output]\x1b[0m (${event.media.mimeType})`);
|
|
81
|
+
}
|
|
82
|
+
else if (event.type === 'error' && event.error) {
|
|
83
|
+
console.error(`\n\x1b[31m✗ Error\x1b[0m: ${event.error}`);
|
|
84
|
+
if (verbose) {
|
|
85
|
+
printVerboseError(event);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function printTestEvidence(event, verbose) {
|
|
90
|
+
const e = event.evidence;
|
|
91
|
+
if (!e) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (e.kind === 'code_execution_call') {
|
|
95
|
+
const preview = (e.code ?? '').replaceAll('\n', ' ').slice(0, 80);
|
|
96
|
+
console.log(`\n 🐍 [code_execution_call] ${preview || e.id || ''}`);
|
|
97
|
+
}
|
|
98
|
+
else if (e.kind === 'code_execution_result') {
|
|
99
|
+
const preview = (e.result ?? '').replaceAll('\n', ' ').slice(0, 80);
|
|
100
|
+
console.log(`\n 🐍 [code_execution_result] isError=${String(e.isError)} ${preview}`);
|
|
101
|
+
}
|
|
102
|
+
else if (e.kind) {
|
|
103
|
+
console.log(`\n 📎 [evidence] ${e.kind}`);
|
|
104
|
+
}
|
|
105
|
+
if (verbose) {
|
|
106
|
+
printVerboseEvidence(event);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** Print one turn event for `theorum test`. */
|
|
110
|
+
function printTestEvent(event, options = {}) {
|
|
111
|
+
const verbose = options.verbose === true;
|
|
112
|
+
if (event.type === 'thought' && event.text) {
|
|
113
|
+
dntShim.Deno.stdout.write(new TextEncoder().encode('.'));
|
|
114
|
+
}
|
|
115
|
+
else if (event.type === 'tool' && event.tool) {
|
|
116
|
+
console.log(`\n ⚡ [Tool Dispatched] ${event.tool.name}(${JSON.stringify(event.tool.arguments ?? {})})`);
|
|
117
|
+
}
|
|
118
|
+
else if (event.type === 'evidence') {
|
|
119
|
+
printTestEvidence(event, verbose);
|
|
120
|
+
}
|
|
121
|
+
else if (event.type === 'structured') {
|
|
122
|
+
console.log('\n ✓ [Structured Schema Validated]');
|
|
123
|
+
}
|
|
124
|
+
else if (event.type === 'media') {
|
|
125
|
+
console.log(`\n ✓ [Media Generated] (${event.media?.mimeType})`);
|
|
126
|
+
}
|
|
127
|
+
else if (event.type === 'error' && event.error) {
|
|
128
|
+
console.error(`\n [Test Error Detail]: ${event.error}`);
|
|
129
|
+
if (verbose) {
|
|
130
|
+
printVerboseError(event);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** Dump the last captured trace record after a CLI turn. */
|
|
135
|
+
function printTraceRecord(record, verbose) {
|
|
136
|
+
if (!record) {
|
|
137
|
+
console.error('\n\x1b[33m[trace]\x1b[0m No trace record captured for this turn.');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
console.log('\n\x1b[35m════ TRACE RECORD ════\x1b[0m');
|
|
141
|
+
console.log(JSON.stringify(record, null, 2));
|
|
142
|
+
if (verbose && record.upstreamLog) {
|
|
143
|
+
console.log('\n\x1b[35m════ UPSTREAM LOG ════\x1b[0m');
|
|
144
|
+
console.log(JSON.stringify(record.upstreamLog, null, 2));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export { createCliTraceCapture, printRunEvent, printTestEvent, printTraceRecord };
|
package/esm/src/cli/index.js
CHANGED
|
@@ -3,7 +3,9 @@ import "../../_dnt.polyfills.js";
|
|
|
3
3
|
import "../../_dnt.polyfills.js";
|
|
4
4
|
import * as dntShim from "../../_dnt.shims.js";
|
|
5
5
|
import { benchCommand } from './commands/bench.js';
|
|
6
|
+
import { fuzzCanaryCommand } from './commands/fuzz-canary.js';
|
|
6
7
|
import { fuzzGuardrailsCommand } from './commands/fuzz-guardrails.js';
|
|
8
|
+
import { guardrailsEvalCommand } from './commands/guardrails-eval.js';
|
|
7
9
|
import { listProfilesCommand, showProfileCommand } from './commands/profile.js';
|
|
8
10
|
import { runCommand } from './commands/run.js';
|
|
9
11
|
import { testProfileCommand } from './commands/test.js';
|
|
@@ -20,7 +22,21 @@ COMMANDS:
|
|
|
20
22
|
--iterations <n> Measurement iterations (default: 50)
|
|
21
23
|
--warmup <n> Warmup iterations (default: 5)
|
|
22
24
|
|
|
23
|
-
fuzz Adversarial
|
|
25
|
+
fuzz Adversarial inbound sanitization fuzzer
|
|
26
|
+
fuzz-canary Adversarial canary egress fuzzer (stream + Live gates)
|
|
27
|
+
guardrails-eval Score detectors against external corpora (fetches on run)
|
|
28
|
+
--cache-dir <path> Corpus cache location (default: .guardrail-corpus)
|
|
29
|
+
--limit <n> Cap samples per source for a quick run
|
|
30
|
+
|
|
31
|
+
run Execute a turn with real-time streaming output
|
|
32
|
+
--profile, -p <id> Target profile ID
|
|
33
|
+
--prompt <text> User prompt string
|
|
34
|
+
--mode <fast|smart> Reasoning mode
|
|
35
|
+
--search Requires googleSearch on the selected model's builtInTools
|
|
36
|
+
--map Requires googleMaps on the selected model's builtInTools
|
|
37
|
+
--verbose, -v Print errorInternal and evidence.raw while running
|
|
38
|
+
--trace Capture a TraceRecord and print it after the turn
|
|
39
|
+
--trace-dir <path> Also append trace JSONL under this directory
|
|
24
40
|
|
|
25
41
|
test Run stress matrix or custom profile tests
|
|
26
42
|
--profile, -p <id> Target profile ID registered by your host app
|
|
@@ -28,15 +44,11 @@ COMMANDS:
|
|
|
28
44
|
--lite Minimal fast-path connectivity ping
|
|
29
45
|
--matrix Run all valid permutations for the profile
|
|
30
46
|
--mode <fast|smart> Reasoning mode override
|
|
31
|
-
--search
|
|
32
|
-
--map
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
--
|
|
36
|
-
--prompt <text> User prompt string
|
|
37
|
-
--mode <fast|smart> Reasoning mode
|
|
38
|
-
--search Optional: set tool id googleSearch when allowlisted
|
|
39
|
-
--map Optional: set tool id googleMaps when allowlisted
|
|
47
|
+
--search Requires googleSearch on the selected model's builtInTools
|
|
48
|
+
--map Requires googleMaps on the selected model's builtInTools
|
|
49
|
+
--verbose, -v Print errorInternal and evidence.raw while running
|
|
50
|
+
--trace Capture a TraceRecord and print it after each turn
|
|
51
|
+
--trace-dir <path> Also append trace JSONL under this directory
|
|
40
52
|
|
|
41
53
|
profile Inspect registered profile blueprints
|
|
42
54
|
list List all registered profiles
|
|
@@ -45,6 +57,13 @@ COMMANDS:
|
|
|
45
57
|
help, --help, -h Show this help message
|
|
46
58
|
`);
|
|
47
59
|
}
|
|
60
|
+
function cliDiagnostics(flags) {
|
|
61
|
+
return {
|
|
62
|
+
verbose: Boolean(flags.verbose || flags.v),
|
|
63
|
+
trace: Boolean(flags.trace),
|
|
64
|
+
traceDir: typeof flags['trace-dir'] === 'string' ? flags['trace-dir'] : undefined,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
48
67
|
function parseLongFlag(arg, nextArg, flags) {
|
|
49
68
|
const key = arg.slice(2);
|
|
50
69
|
if (nextArg && !nextArg.startsWith('-')) {
|
|
@@ -64,6 +83,8 @@ function parseShortFlag(arg, nextArg, flags) {
|
|
|
64
83
|
flags.all = true;
|
|
65
84
|
else if (key === 'h')
|
|
66
85
|
flags.help = true;
|
|
86
|
+
else if (key === 'v')
|
|
87
|
+
flags.verbose = true;
|
|
67
88
|
else
|
|
68
89
|
flags[key] = true;
|
|
69
90
|
return 0;
|
|
@@ -96,6 +117,7 @@ function extractProfileId(flags) {
|
|
|
96
117
|
}
|
|
97
118
|
async function handleTest(flags) {
|
|
98
119
|
const profile = extractProfileId(flags);
|
|
120
|
+
const diagnostics = cliDiagnostics(flags);
|
|
99
121
|
const success = await testProfileCommand(profile, {
|
|
100
122
|
all: Boolean(flags.all || flags.a),
|
|
101
123
|
lite: Boolean(flags.lite),
|
|
@@ -103,6 +125,9 @@ async function handleTest(flags) {
|
|
|
103
125
|
mode: typeof flags.mode === 'string' ? flags.mode : undefined,
|
|
104
126
|
search: flags.search ? true : undefined,
|
|
105
127
|
map: flags.map ? true : undefined,
|
|
128
|
+
verbose: diagnostics.verbose,
|
|
129
|
+
trace: diagnostics.trace,
|
|
130
|
+
traceDir: diagnostics.traceDir,
|
|
106
131
|
});
|
|
107
132
|
if (!success) {
|
|
108
133
|
dntShim.Deno.exit(1);
|
|
@@ -115,12 +140,16 @@ async function handleRun(flags) {
|
|
|
115
140
|
dntShim.Deno.exit(1);
|
|
116
141
|
}
|
|
117
142
|
const prompt = typeof flags.prompt === 'string' ? flags.prompt : flags._.slice(1).join(' ');
|
|
143
|
+
const diagnostics = cliDiagnostics(flags);
|
|
118
144
|
await runCommand({
|
|
119
145
|
profile,
|
|
120
146
|
prompt,
|
|
121
147
|
mode: typeof flags.mode === 'string' ? flags.mode : undefined,
|
|
122
148
|
search: Boolean(flags.search),
|
|
123
149
|
map: Boolean(flags.map),
|
|
150
|
+
verbose: diagnostics.verbose,
|
|
151
|
+
trace: diagnostics.trace,
|
|
152
|
+
traceDir: diagnostics.traceDir,
|
|
124
153
|
});
|
|
125
154
|
}
|
|
126
155
|
function handleProfile(flags) {
|
|
@@ -140,7 +169,24 @@ export async function main(cliArgs = dntShim.Deno.args) {
|
|
|
140
169
|
const flags = parseFlags(cliArgs);
|
|
141
170
|
const command = flags._[0] || (flags.help ? 'help' : 'help');
|
|
142
171
|
if (command === 'fuzz') {
|
|
143
|
-
fuzzGuardrailsCommand();
|
|
172
|
+
const ok = fuzzGuardrailsCommand();
|
|
173
|
+
if (!ok) {
|
|
174
|
+
dntShim.Deno.exit(1);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else if (command === 'guardrails-eval') {
|
|
178
|
+
const cacheDir = typeof flags['cache-dir'] === 'string' ? flags['cache-dir'] : undefined;
|
|
179
|
+
const limit = typeof flags.limit === 'string' ? Number(flags.limit) : undefined;
|
|
180
|
+
await guardrailsEvalCommand({
|
|
181
|
+
...(cacheDir ? { cacheDir } : {}),
|
|
182
|
+
...(limit !== undefined && Number.isFinite(limit) ? { limit } : {}),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
else if (command === 'fuzz-canary') {
|
|
186
|
+
const ok = await fuzzCanaryCommand();
|
|
187
|
+
if (!ok) {
|
|
188
|
+
dntShim.Deno.exit(1);
|
|
189
|
+
}
|
|
144
190
|
}
|
|
145
191
|
else if (command === 'bench') {
|
|
146
192
|
await benchCommand({
|
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Stress / matrix turn synthesis for the THEORUM CLI.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Custom tools come from `profile.tools.allow` (visibility via loadTier).
|
|
5
|
+
* Provider builtins come from `models.*.builtInTools`. `--search` /
|
|
6
|
+
* `--map` only verify those ids are listed on the selected model.
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
10
|
+
import type { ModelProfile, TurnRequest } from '../../kernel/types.js';
|
|
11
11
|
export interface MatrixOptions {
|
|
12
12
|
lite?: boolean;
|
|
13
|
-
/**
|
|
13
|
+
/** Requires googleSearch on the selected model's builtInTools. */
|
|
14
14
|
search?: boolean;
|
|
15
|
-
/**
|
|
15
|
+
/** Requires googleMaps on the selected model's builtInTools. */
|
|
16
16
|
map?: boolean;
|
|
17
17
|
mode?: string;
|
|
18
18
|
attachmentPaths?: string[];
|
|
19
19
|
voicePath?: string;
|
|
20
20
|
}
|
|
21
|
-
export declare function synthesizeLiteCombo(profile:
|
|
22
|
-
export declare function synthesizeStressCombo(profile:
|
|
23
|
-
|
|
24
|
-
}): TurnRequest;
|
|
25
|
-
export declare function synthesizeMatrixCombos(profile: Profile): Array<{
|
|
21
|
+
export declare function synthesizeLiteCombo(profile: ModelProfile): TurnRequest;
|
|
22
|
+
export declare function synthesizeStressCombo(profile: ModelProfile): TurnRequest;
|
|
23
|
+
export declare function synthesizeMatrixCombos(profile: ModelProfile): Array<{
|
|
26
24
|
name: string;
|
|
27
25
|
req: TurnRequest;
|
|
28
26
|
}>;
|
|
29
|
-
export declare function buildCustomTurnRequest(profile:
|
|
27
|
+
export declare function buildCustomTurnRequest(profile: ModelProfile, options: MatrixOptions): TurnRequest;
|