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.
Files changed (305) hide show
  1. package/README.md +241 -98
  2. package/esm/mod.d.ts +57 -28
  3. package/esm/mod.js +43 -23
  4. package/esm/src/cli/commands/bench.js +18 -18
  5. package/esm/src/cli/commands/fuzz-canary.d.ts +13 -0
  6. package/esm/src/cli/commands/fuzz-canary.js +191 -0
  7. package/esm/src/cli/commands/fuzz-guardrails.d.ts +3 -5
  8. package/esm/src/cli/commands/fuzz-guardrails.js +4 -581
  9. package/esm/src/cli/commands/guardrails-eval.d.ts +14 -0
  10. package/esm/src/cli/commands/guardrails-eval.js +15 -0
  11. package/esm/src/cli/commands/profile.js +35 -15
  12. package/esm/src/cli/commands/run.d.ts +3 -0
  13. package/esm/src/cli/commands/run.js +23 -32
  14. package/esm/src/cli/commands/test.d.ts +10 -1
  15. package/esm/src/cli/commands/test.js +34 -34
  16. package/esm/src/cli/event-log.d.ts +19 -0
  17. package/esm/src/cli/event-log.js +147 -0
  18. package/esm/src/cli/index.js +57 -11
  19. package/esm/src/cli/matrix/synthesizer.d.ts +10 -12
  20. package/esm/src/cli/matrix/synthesizer.js +45 -118
  21. package/esm/src/guardrails/canary-gate.d.ts +21 -0
  22. package/esm/src/guardrails/canary-gate.js +32 -0
  23. package/esm/src/guardrails/canary.d.ts +34 -0
  24. package/esm/src/guardrails/canary.js +150 -0
  25. package/esm/src/guardrails/corpus/canary-egress-attacks.d.ts +17 -0
  26. package/esm/src/guardrails/corpus/canary-egress-attacks.js +151 -0
  27. package/esm/src/guardrails/corpus/fuzz-inbound.d.ts +11 -0
  28. package/esm/src/guardrails/corpus/fuzz-inbound.js +213 -0
  29. package/esm/src/guardrails/corpus/inbound-payloads.d.ts +10 -0
  30. package/esm/src/guardrails/corpus/inbound-payloads.js +125 -0
  31. package/esm/src/guardrails/corpus/live-attacks.d.ts +20 -0
  32. package/esm/src/guardrails/corpus/live-attacks.js +231 -0
  33. package/esm/src/guardrails/corpus/mod.d.ts +14 -0
  34. package/esm/src/guardrails/corpus/mod.js +11 -0
  35. package/esm/src/guardrails/corpus/secrets.d.ts +17 -0
  36. package/esm/src/guardrails/corpus/secrets.js +17 -0
  37. package/esm/src/guardrails/corpus/strings.d.ts +28 -0
  38. package/esm/src/guardrails/corpus/strings.js +34 -0
  39. package/esm/src/guardrails/corpus/types.d.ts +38 -0
  40. package/esm/src/guardrails/corpus/types.js +6 -0
  41. package/esm/src/guardrails/egress.d.ts +32 -0
  42. package/esm/src/guardrails/egress.js +87 -0
  43. package/esm/src/guardrails/error.d.ts +14 -23
  44. package/esm/src/guardrails/error.js +87 -76
  45. package/esm/src/guardrails/eval/corpus.d.ts +108 -0
  46. package/esm/src/guardrails/eval/corpus.js +978 -0
  47. package/esm/src/guardrails/eval/mod.d.ts +51 -0
  48. package/esm/src/guardrails/eval/mod.js +133 -0
  49. package/esm/src/guardrails/eval/score.d.ts +66 -0
  50. package/esm/src/guardrails/eval/score.js +114 -0
  51. package/esm/src/guardrails/events.d.ts +25 -0
  52. package/esm/src/guardrails/events.js +56 -0
  53. package/esm/src/guardrails/hits.d.ts +24 -0
  54. package/esm/src/guardrails/hits.js +45 -0
  55. package/esm/src/guardrails/injection.js +28 -5
  56. package/esm/src/guardrails/lexicon.d.ts +39 -0
  57. package/esm/src/guardrails/lexicon.js +200 -0
  58. package/esm/src/guardrails/live-outbound-gate.d.ts +41 -0
  59. package/esm/src/guardrails/live-outbound-gate.js +222 -0
  60. package/esm/src/guardrails/mod.d.ts +30 -6
  61. package/esm/src/guardrails/mod.js +20 -5
  62. package/esm/src/guardrails/network.d.ts +19 -0
  63. package/esm/src/guardrails/network.js +234 -0
  64. package/esm/src/guardrails/policy.d.ts +35 -0
  65. package/esm/src/guardrails/policy.js +50 -0
  66. package/esm/src/guardrails/progressive-yield.d.ts +51 -0
  67. package/esm/src/guardrails/progressive-yield.js +98 -0
  68. package/esm/src/guardrails/quota.d.ts +17 -3
  69. package/esm/src/guardrails/quota.js +18 -4
  70. package/esm/src/guardrails/sanitize.d.ts +45 -19
  71. package/esm/src/guardrails/sanitize.js +177 -94
  72. package/esm/src/guardrails/sensitive.js +2 -1
  73. package/esm/src/guardrails/serialize.d.ts +35 -0
  74. package/esm/src/guardrails/serialize.js +58 -0
  75. package/esm/src/guardrails/testing.d.ts +17 -0
  76. package/esm/src/guardrails/testing.js +13 -0
  77. package/esm/src/guardrails/theorum-error.d.ts +12 -0
  78. package/esm/src/guardrails/theorum-error.js +15 -0
  79. package/esm/src/guardrails/tool-directives.d.ts +48 -0
  80. package/esm/src/guardrails/tool-directives.js +124 -0
  81. package/esm/src/guardrails/tool-result.d.ts +93 -0
  82. package/esm/src/guardrails/tool-result.js +276 -0
  83. package/esm/src/guardrails/types.d.ts +291 -0
  84. package/esm/src/guardrails/types.js +72 -0
  85. package/esm/src/host/client-turn.d.ts +19 -0
  86. package/esm/src/host/client-turn.js +36 -0
  87. package/esm/src/host/mint-trace.d.ts +1 -1
  88. package/esm/src/host/mod.d.ts +5 -3
  89. package/esm/src/host/mod.js +4 -3
  90. package/esm/src/kernel/auth/crypto.d.ts +42 -0
  91. package/esm/src/kernel/auth/crypto.js +106 -0
  92. package/esm/src/kernel/auth/mod.d.ts +11 -0
  93. package/esm/src/kernel/auth/mod.js +11 -0
  94. package/esm/src/kernel/auth/oauth.d.ts +47 -0
  95. package/esm/src/kernel/auth/oauth.js +278 -0
  96. package/esm/src/kernel/auth/types.d.ts +133 -0
  97. package/esm/src/kernel/auth/types.js +13 -0
  98. package/esm/src/kernel/engine/delta.d.ts +24 -2
  99. package/esm/src/kernel/engine/delta.js +478 -39
  100. package/esm/src/kernel/engine/live-inbound.d.ts +21 -0
  101. package/esm/src/kernel/engine/live-inbound.js +31 -0
  102. package/esm/src/kernel/engine/live-ingress.d.ts +19 -0
  103. package/esm/src/kernel/engine/live-ingress.js +47 -0
  104. package/esm/src/kernel/engine/repair.js +13 -12
  105. package/esm/src/kernel/engine/runner/gates.d.ts +1 -1
  106. package/esm/src/kernel/engine/runner/gates.js +130 -43
  107. package/esm/src/kernel/engine/runner/mod.d.ts +6 -4
  108. package/esm/src/kernel/engine/runner/mod.js +192 -53
  109. package/esm/src/kernel/engine/runner/schema-validation.js +3 -3
  110. package/esm/src/kernel/engine/runner/stages.d.ts +39 -0
  111. package/esm/src/kernel/engine/runner/stages.js +89 -0
  112. package/esm/src/kernel/engine/runner/state.d.ts +31 -0
  113. package/esm/src/kernel/engine/runner/steps.d.ts +1 -1
  114. package/esm/src/kernel/engine/runner/steps.js +244 -43
  115. package/esm/src/kernel/engine/runner/stream.d.ts +9 -3
  116. package/esm/src/kernel/engine/runner/stream.js +140 -44
  117. package/esm/src/kernel/engine/session/mod.d.ts +25 -0
  118. package/esm/src/kernel/engine/session/mod.js +557 -0
  119. package/esm/src/kernel/interaction-parts.d.ts +14 -0
  120. package/esm/src/kernel/interaction-parts.js +23 -0
  121. package/esm/src/kernel/mod.d.ts +21 -10
  122. package/esm/src/kernel/mod.js +11 -8
  123. package/esm/src/kernel/profile-graph.d.ts +159 -0
  124. package/esm/src/kernel/profile-graph.js +156 -0
  125. package/esm/src/kernel/registry/attachments.d.ts +12 -10
  126. package/esm/src/kernel/registry/attachments.js +33 -27
  127. package/esm/src/kernel/registry/catalog.d.ts +25 -24
  128. package/esm/src/kernel/registry/catalog.js +60 -101
  129. package/esm/src/kernel/registry/ingress.d.ts +9 -4
  130. package/esm/src/kernel/registry/ingress.js +97 -75
  131. package/esm/src/kernel/registry/profile-outputs.d.ts +4 -0
  132. package/esm/src/kernel/registry/profile-outputs.js +8 -0
  133. package/esm/src/kernel/registry/profiles.d.ts +55 -12
  134. package/esm/src/kernel/registry/profiles.js +413 -73
  135. package/esm/src/kernel/registry/provider-request.js +13 -7
  136. package/esm/src/kernel/registry/resolve.d.ts +8 -8
  137. package/esm/src/kernel/registry/resolve.js +169 -154
  138. package/esm/src/kernel/registry/schemas.js +1 -1
  139. package/esm/src/kernel/registry/sole-model.d.ts +8 -0
  140. package/esm/src/kernel/registry/sole-model.js +10 -0
  141. package/esm/src/kernel/registry/system-prompt.d.ts +10 -0
  142. package/esm/src/kernel/registry/system-prompt.js +40 -0
  143. package/esm/src/kernel/registry/system-role.d.ts +8 -0
  144. package/esm/src/kernel/registry/system-role.js +14 -0
  145. package/esm/src/kernel/registry/vault.d.ts +12 -7
  146. package/esm/src/kernel/registry/vault.js +32 -10
  147. package/esm/src/kernel/schema.d.ts +231 -0
  148. package/esm/src/kernel/schema.js +607 -0
  149. package/esm/src/kernel/stages.d.ts +175 -0
  150. package/esm/src/kernel/stages.js +476 -0
  151. package/esm/src/kernel/stop.d.ts +78 -19
  152. package/esm/src/kernel/stop.js +51 -16
  153. package/esm/src/kernel/tools/events.d.ts +41 -0
  154. package/esm/src/kernel/tools/events.js +71 -0
  155. package/esm/src/kernel/tools/execute.d.ts +84 -0
  156. package/esm/src/kernel/tools/execute.js +614 -0
  157. package/esm/src/kernel/tools/harness.d.ts +8 -0
  158. package/esm/src/kernel/tools/harness.js +46 -0
  159. package/esm/src/kernel/tools/invoke.d.ts +10 -0
  160. package/esm/src/kernel/tools/invoke.js +101 -0
  161. package/esm/src/kernel/tools/mod.d.ts +13 -0
  162. package/esm/src/kernel/tools/mod.js +11 -0
  163. package/esm/src/kernel/tools/permission.d.ts +15 -0
  164. package/esm/src/kernel/tools/permission.js +47 -0
  165. package/esm/src/kernel/tools/project.d.ts +12 -0
  166. package/esm/src/kernel/tools/project.js +36 -0
  167. package/esm/src/kernel/tools/registry.d.ts +23 -0
  168. package/esm/src/kernel/tools/registry.js +81 -0
  169. package/esm/src/kernel/tools/remote.d.ts +94 -0
  170. package/esm/src/kernel/tools/remote.js +577 -0
  171. package/esm/src/kernel/tools/resolve.d.ts +39 -0
  172. package/esm/src/kernel/tools/resolve.js +283 -0
  173. package/esm/src/kernel/tools/schema.d.ts +15 -0
  174. package/esm/src/kernel/tools/schema.js +176 -0
  175. package/esm/src/kernel/tools/stage-run.d.ts +105 -0
  176. package/esm/src/kernel/tools/stage-run.js +155 -0
  177. package/esm/src/kernel/tools/types.d.ts +394 -0
  178. package/esm/src/kernel/tools/types.js +9 -0
  179. package/esm/src/kernel/types.d.ts +540 -256
  180. package/esm/src/kernel/util/find-last.d.ts +2 -0
  181. package/esm/src/kernel/util/find-last.js +10 -0
  182. package/esm/src/observability/destinations.d.ts +31 -0
  183. package/esm/src/observability/destinations.js +67 -0
  184. package/esm/src/observability/mod.d.ts +10 -3
  185. package/esm/src/observability/mod.js +6 -2
  186. package/esm/src/observability/policy.d.ts +27 -0
  187. package/esm/src/observability/policy.js +80 -0
  188. package/esm/src/observability/resolve-policy.d.ts +16 -0
  189. package/esm/src/observability/resolve-policy.js +64 -0
  190. package/esm/src/observability/trace-attach.d.ts +8 -4
  191. package/esm/src/observability/trace-attach.js +50 -29
  192. package/esm/src/observability/trace-record.d.ts +23 -13
  193. package/esm/src/observability/trace-record.js +96 -39
  194. package/esm/src/observability/trace-sink.d.ts +19 -0
  195. package/esm/src/observability/trace-sink.js +10 -0
  196. package/esm/src/observability/trace-usage.d.ts +10 -3
  197. package/esm/src/observability/trace-usage.js +70 -17
  198. package/esm/src/observability/trace.d.ts +18 -7
  199. package/esm/src/observability/trace.js +34 -17
  200. package/esm/src/observability/types.d.ts +113 -0
  201. package/esm/src/observability/types.js +11 -0
  202. package/esm/src/presets/google/speech-voices.d.ts +11 -0
  203. package/esm/src/presets/google/speech-voices.js +41 -0
  204. package/esm/src/presets/google.d.ts +36 -24
  205. package/esm/src/presets/google.js +50 -63
  206. package/esm/src/presets/mod.d.ts +2 -2
  207. package/esm/src/presets/mod.js +1 -1
  208. package/esm/src/providers/create-provider.d.ts +20 -17
  209. package/esm/src/providers/create-provider.js +72 -26
  210. package/esm/src/providers/google/interactions/framing.d.ts +23 -0
  211. package/esm/src/providers/google/interactions/framing.js +269 -0
  212. package/esm/src/providers/google/interactions/mod.d.ts +7 -0
  213. package/esm/src/providers/google/interactions/mod.js +7 -0
  214. package/esm/src/providers/google/interactions/stream.d.ts +83 -0
  215. package/esm/src/providers/google/interactions/stream.js +588 -0
  216. package/esm/src/providers/google/keys.d.ts +26 -0
  217. package/esm/src/providers/{keys.js → google/keys.js} +19 -31
  218. package/esm/src/providers/google/live/framing.d.ts +49 -0
  219. package/esm/src/providers/google/live/framing.js +552 -0
  220. package/esm/src/providers/google/live/openapi-schema.d.ts +6 -0
  221. package/esm/src/providers/google/live/openapi-schema.js +46 -0
  222. package/esm/src/providers/google/live/session.d.ts +25 -0
  223. package/esm/src/providers/google/live/session.js +134 -0
  224. package/esm/src/providers/google/live/stream.d.ts +45 -0
  225. package/esm/src/providers/google/live/stream.js +214 -0
  226. package/esm/src/providers/google/urls.d.ts +6 -0
  227. package/esm/src/providers/google/urls.js +6 -0
  228. package/esm/src/providers/local/local.d.ts +30 -0
  229. package/esm/src/providers/{local.js → local/local.js} +66 -126
  230. package/esm/src/providers/local/mod.d.ts +9 -0
  231. package/esm/src/providers/local/mod.js +9 -0
  232. package/esm/src/providers/mod.d.ts +6 -3
  233. package/esm/src/providers/mod.js +3 -1
  234. package/esm/src/providers/openrouter/cache-control.d.ts +24 -0
  235. package/esm/src/providers/openrouter/cache-control.js +23 -0
  236. package/esm/src/providers/openrouter/chat.d.ts +107 -0
  237. package/esm/src/providers/{openrouter.js → openrouter/chat.js} +117 -231
  238. package/esm/src/providers/openrouter/image.d.ts +34 -0
  239. package/esm/src/providers/openrouter/image.js +275 -0
  240. package/esm/src/providers/openrouter/openai/chat-payload.d.ts +24 -0
  241. package/esm/src/providers/openrouter/openai/chat-payload.js +82 -0
  242. package/esm/src/providers/openrouter/openai/compat.d.ts +53 -0
  243. package/esm/src/providers/openrouter/openai/compat.js +213 -0
  244. package/esm/src/providers/openrouter/openai/image-payload.d.ts +18 -0
  245. package/esm/src/providers/openrouter/openai/image-payload.js +90 -0
  246. package/esm/src/providers/openrouter/openai/sdk-messages.d.ts +22 -0
  247. package/esm/src/providers/openrouter/openai/sdk-messages.js +122 -0
  248. package/esm/src/providers/openrouter/resolve-api-key.d.ts +9 -0
  249. package/esm/src/providers/openrouter/resolve-api-key.js +24 -0
  250. package/esm/src/providers/openrouter/speech.d.ts +23 -0
  251. package/esm/src/providers/{speech.js → openrouter/speech.js} +32 -55
  252. package/esm/src/providers/probe.d.ts +1 -0
  253. package/esm/src/providers/probe.js +22 -0
  254. package/esm/src/providers/shared/pcm.d.ts +12 -0
  255. package/esm/src/providers/{pcm.js → shared/pcm.js} +16 -3
  256. package/esm/src/providers/shared/sse.d.ts +18 -0
  257. package/esm/src/providers/shared/sse.js +87 -0
  258. package/esm/src/providers/shared/tool-args.d.ts +17 -0
  259. package/esm/src/providers/shared/tool-args.js +45 -0
  260. package/esm/src/providers/shared/upstream-tap.d.ts +5 -0
  261. package/esm/src/providers/{google-tap.js → shared/upstream-tap.js} +4 -7
  262. package/esm/src/providers/shared/upstream-tape.d.ts +6 -0
  263. package/esm/src/providers/{gemini-tape.js → shared/upstream-tape.js} +12 -22
  264. package/esm/src/providers/types.d.ts +27 -0
  265. package/esm/src/providers/types.js +1 -0
  266. package/package.json +11 -7
  267. package/docs/cli.md +0 -97
  268. package/docs/guardrails.md +0 -178
  269. package/docs/host.md +0 -97
  270. package/docs/kernel.md +0 -404
  271. package/docs/observability.md +0 -105
  272. package/docs/openrouter.md +0 -125
  273. package/docs/presets-google.md +0 -91
  274. package/docs/presets.md +0 -88
  275. package/docs/providers.md +0 -202
  276. package/docs/streaming.md +0 -96
  277. package/esm/src/kernel/engine/boundary.d.ts +0 -10
  278. package/esm/src/kernel/engine/boundary.js +0 -55
  279. package/esm/src/kernel/engine/runner/tools.d.ts +0 -13
  280. package/esm/src/kernel/engine/runner/tools.js +0 -198
  281. package/esm/src/kernel/registry/tools.d.ts +0 -12
  282. package/esm/src/kernel/registry/tools.js +0 -36
  283. package/esm/src/providers/expose-for-tests.d.ts +0 -1
  284. package/esm/src/providers/expose-for-tests.js +0 -25
  285. package/esm/src/providers/gemini-tape.d.ts +0 -2
  286. package/esm/src/providers/google-tap.d.ts +0 -3
  287. package/esm/src/providers/interactions.d.ts +0 -5
  288. package/esm/src/providers/interactions.js +0 -169
  289. package/esm/src/providers/keys.d.ts +0 -19
  290. package/esm/src/providers/local.d.ts +0 -29
  291. package/esm/src/providers/openrouter-mod.d.ts +0 -13
  292. package/esm/src/providers/openrouter-mod.js +0 -12
  293. package/esm/src/providers/openrouter-payload.d.ts +0 -39
  294. package/esm/src/providers/openrouter-payload.js +0 -195
  295. package/esm/src/providers/openrouter.d.ts +0 -15
  296. package/esm/src/providers/pcm.d.ts +0 -7
  297. package/esm/src/providers/provider.d.ts +0 -15
  298. package/esm/src/providers/provider.js +0 -202
  299. package/esm/src/providers/speech.d.ts +0 -23
  300. package/esm/src/providers/sse.d.ts +0 -7
  301. package/esm/src/providers/sse.js +0 -55
  302. package/esm/src/streaming/mod.d.ts +0 -9
  303. package/esm/src/streaming/mod.js +0 -8
  304. /package/esm/src/{streaming → host}/readStreamingJsonStringField.d.ts +0 -0
  305. /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
- if (p.inputs.text !== false)
10
+ const { inputs: spec } = p;
11
+ if (!spec) {
12
+ return 'none';
13
+ }
14
+ if (spec.text !== false)
5
15
  inputs.push('text');
6
- if (p.inputs.voice)
16
+ if (spec.voice)
7
17
  inputs.push('voice');
8
- if (p.inputs.attachments)
9
- inputs.push(`attachments [${p.inputs.attachments.accept?.join(', ')}]`);
10
- return inputs.join(' | ');
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.tools.allow?.length ? p.tools.allow.join(', ') : 'none';
14
- const models = p.model.allow?.join(', ') || 'default';
15
- const structured = typeof p.outputs.structured === 'string'
16
- ? p.outputs.structured
17
- : p.outputs.structured
18
- ? 'custom'
19
- : 'none';
20
- console.log(` Profile: ${p.id.padEnd(16)} (handle: ${p.identity.handle})`);
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: ${structured}`);
25
- console.log(` - Key Bucket: ${p.model.key ?? 'freeA'}`);
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() {
@@ -6,5 +6,8 @@ export interface RunOptions {
6
6
  search?: boolean;
7
7
  map?: boolean;
8
8
  provider?: ModelProvider;
9
+ verbose?: boolean;
10
+ trace?: boolean;
11
+ traceDir?: string;
9
12
  }
10
13
  export declare function runCommand(options: RunOptions): Promise<void>;
@@ -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
- function handleRunEvent(event) {
5
- if (event.type === 'thought' && event.text) {
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
- const tools = {};
34
- if (options.search)
35
- tools.googleSearch = true;
36
- if (options.map)
37
- tools.googleMaps = true;
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
- select: options.mode,
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
- handleRunEvent(event);
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
- export declare function executeSingleTest(req: TurnRequest, testName: string, provider?: ModelProvider): Promise<TestRunResult>;
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 activeTools = Object.entries(req.tools ?? {})
7
- .filter(([, v]) => Boolean(v))
8
- .map(([k]) => k)
9
- .join(', ');
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} (Mode: ${req.select ?? 'default'})`);
12
- console.log(` Tools: ${activeTools || 'none'}`);
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 === 'thought' && event.text) {
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
- else if (event.type === 'error' && event.error) {
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
- for await (const event of runTurn(req, provider)) {
60
- processTestEvent(event, acc);
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
- return listProfiles();
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 };
@@ -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 guardrail fuzzer
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 Optional: set tool id googleSearch when allowlisted
32
- --map Optional: set tool id googleMaps when allowlisted
33
-
34
- run Execute a turn with real-time streaming output
35
- --profile, -p <id> Target profile ID
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
- * Tool enabling walks the profile allowlist and registered catalog metadata
5
- * (`conflictsWith`). Google `--search` / `--map` flags remain as convenience
6
- * aliases for `googleSearch` / `googleMaps` when those ids are allowed.
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 { Profile, ToolId, TurnRequest } from '../../kernel/types.js';
10
+ import type { ModelProfile, TurnRequest } from '../../kernel/types.js';
11
11
  export interface MatrixOptions {
12
12
  lite?: boolean;
13
- /** Convenience alias for enabling/disabling `googleSearch` when allowed. */
13
+ /** Requires googleSearch on the selected model's builtInTools. */
14
14
  search?: boolean;
15
- /** Convenience alias for enabling/disabling `googleMaps` when allowed. */
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: Profile): TurnRequest;
22
- export declare function synthesizeStressCombo(profile: Profile, options?: {
23
- preferTool?: ToolId;
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: Profile, options: MatrixOptions): TurnRequest;
27
+ export declare function buildCustomTurnRequest(profile: ModelProfile, options: MatrixOptions): TurnRequest;