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
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Google Gemini TTS voice names for `speech.voice`.
3
+ *
4
+ * Standalone preset vocabulary — no kernel registry imports so docs UIs can
5
+ * import this file without pulling provider wiring.
6
+ *
7
+ * @module
8
+ */
9
+ /** Common Gemini TTS voice names. */
10
+ export const GOOGLE_SPEECH_VOICES = [
11
+ 'Zephyr',
12
+ 'Puck',
13
+ 'Charon',
14
+ 'Kore',
15
+ 'Fenrir',
16
+ 'Leda',
17
+ 'Orus',
18
+ 'Aoede',
19
+ 'Callirrhoe',
20
+ 'Autonoe',
21
+ 'Enceladus',
22
+ 'Iapetus',
23
+ 'Umbriel',
24
+ 'Algieba',
25
+ 'Despina',
26
+ 'Erinome',
27
+ 'Algenib',
28
+ 'Rasalgethi',
29
+ 'Laomedeia',
30
+ 'Achernar',
31
+ 'Alnilam',
32
+ 'Schedar',
33
+ 'Gacrux',
34
+ 'Pulcherrima',
35
+ 'Achird',
36
+ 'Zubenelgenubi',
37
+ 'Vindemiatrix',
38
+ 'Sadachbia',
39
+ 'Sadaltager',
40
+ 'Sulafat',
41
+ ];
@@ -1,50 +1,62 @@
1
1
  /**
2
2
  * Google / Gemini convenience preset.
3
3
  *
4
- * Kernel stays open (`string` pins). This pack owns Google vocabularies as
5
- * real unions so host profiles stay typed when they opt into the preset.
6
- *
7
- * Call `registerGooglePreset()` at host startup for tools; use the exported
8
- * types/constants when authoring image/speech-adjacent profile fields.
9
- *
10
4
  * @module
11
5
  */
12
6
  import "../../_dnt.polyfills.js";
13
- import type { ProfileImageSpec, ProfileSpeechSpec, ToolCatalogEntry } from '../kernel/types.js';
14
- /** Google Interactions / Gemini grounding builtins. */
15
- declare const GOOGLE_BUILTIN_TOOLS: Record<string, ToolCatalogEntry>;
7
+ import type { ProfileImageSpec, ProfileLiveSpec, ProfileSpeechSpec } from '../kernel/types.js';
8
+ import { GOOGLE_SPEECH_VOICES, type GoogleSpeechVoice } from './google/speech-voices.js';
16
9
  /** Common Gemini image input MIME allowlist. */
17
10
  declare const GOOGLE_IMAGE_INPUT_MIMES: readonly ["image/png", "image/jpeg", "image/webp", "image/heic", "image/heif"];
18
11
  /** Common voice/audio input MIME allowlist for Gemini multimodal. */
19
12
  declare const GOOGLE_VOICE_INPUT_MIMES: readonly ["audio/webm", "audio/wav", "audio/mpeg", "audio/mp4"];
20
- /** Common Gemini TTS voice names for `outputs.speech.voice`. */
21
- declare const GOOGLE_SPEECH_VOICES: readonly ["Zephyr", "Puck", "Charon", "Kore", "Fenrir", "Leda", "Orus", "Aoede", "Callirrhoe", "Autonoe", "Enceladus", "Iapetus", "Umbriel", "Algieba", "Despina", "Erinome", "Algenib", "Rasalgethi", "Laomedeia", "Achernar", "Alnilam", "Schedar", "Gacrux", "Pulcherrima", "Achird", "Zubenelgenubi", "Vindemiatrix", "Sadachbia", "Sadaltager", "Sulafat"];
22
- type GoogleSpeechVoice = (typeof GOOGLE_SPEECH_VOICES)[number];
23
- /**
24
- * `outputs.speech` pins narrowed to Google TTS vocabulary.
25
- * Assignable to kernel `ProfileSpeechSpec`.
26
- */
27
13
  type GoogleSpeechPins = Omit<ProfileSpeechSpec, 'voice'> & {
28
14
  voice?: GoogleSpeechVoice;
29
15
  };
30
- /** Aspect ratios commonly accepted by Gemini image models. */
16
+ type GoogleLivePins = Omit<ProfileLiveSpec, 'voice'> & {
17
+ voice?: GoogleSpeechVoice;
18
+ };
31
19
  declare const GOOGLE_IMAGE_ASPECT_RATIOS: readonly ["1:1", "3:2", "2:3", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"];
32
- /** Image sizes commonly accepted by Gemini Flash Lite image. */
33
20
  declare const GOOGLE_IMAGE_SIZES: readonly ["1K"];
34
21
  type GoogleImageInputMime = (typeof GOOGLE_IMAGE_INPUT_MIMES)[number];
35
22
  type GoogleVoiceInputMime = (typeof GOOGLE_VOICE_INPUT_MIMES)[number];
36
23
  type GoogleImageAspectRatio = (typeof GOOGLE_IMAGE_ASPECT_RATIOS)[number];
37
24
  type GoogleImageSize = (typeof GOOGLE_IMAGE_SIZES)[number];
38
- /**
39
- * `outputs.image` pins narrowed to Google image vocabulary.
40
- * Assignable to kernel `ProfileImageSpec`.
41
- */
42
25
  type GoogleImagePins = Omit<ProfileImageSpec, 'aspectRatio' | 'size' | 'mimeType'> & {
43
26
  aspectRatio?: GoogleImageAspectRatio;
44
27
  size?: GoogleImageSize;
45
28
  mimeType?: GoogleImageInputMime | 'image/jpeg';
46
29
  };
47
- /** Register Google provider builtins into the process-local tool catalog. */
30
+ declare const GOOGLE_BUILTIN_TOOLS: ({
31
+ type: "builtin";
32
+ name: string;
33
+ description: string;
34
+ category: string;
35
+ access: "read-only";
36
+ paths: string[];
37
+ loadTier: "T0";
38
+ permission: "auto";
39
+ forcePaidKey: boolean;
40
+ wire: {
41
+ interactions: string;
42
+ openRouter: string;
43
+ };
44
+ } | {
45
+ type: "builtin";
46
+ name: string;
47
+ description: string;
48
+ category: string;
49
+ access: "read-only";
50
+ paths: string[];
51
+ loadTier: "T0";
52
+ permission: "auto";
53
+ wire: {
54
+ interactions: string;
55
+ openRouter?: undefined;
56
+ };
57
+ forcePaidKey?: undefined;
58
+ })[];
59
+ /** Register Google provider builtins into the process-local tool registry. */
48
60
  declare function registerGooglePreset(): void;
49
- export type { GoogleImageAspectRatio, GoogleImageInputMime, GoogleImagePins, GoogleImageSize, GoogleSpeechPins, GoogleSpeechVoice, GoogleVoiceInputMime, };
61
+ export type { GoogleImageAspectRatio, GoogleImageInputMime, GoogleImagePins, GoogleImageSize, GoogleLivePins, GoogleSpeechPins, GoogleSpeechVoice, GoogleVoiceInputMime, };
50
62
  export { GOOGLE_BUILTIN_TOOLS, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_INPUT_MIMES, GOOGLE_IMAGE_SIZES, GOOGLE_SPEECH_VOICES, GOOGLE_VOICE_INPUT_MIMES, registerGooglePreset, };
@@ -1,36 +1,11 @@
1
1
  /**
2
2
  * Google / Gemini convenience preset.
3
3
  *
4
- * Kernel stays open (`string` pins). This pack owns Google vocabularies as
5
- * real unions so host profiles stay typed when they opt into the preset.
6
- *
7
- * Call `registerGooglePreset()` at host startup for tools; use the exported
8
- * types/constants when authoring image/speech-adjacent profile fields.
9
- *
10
4
  * @module
11
5
  */
12
6
  import "../../_dnt.polyfills.js";
13
- import { registerTools } from '../kernel/registry/catalog.js';
14
- /** Google Interactions / Gemini grounding builtins. */
15
- const GOOGLE_BUILTIN_TOOLS = {
16
- googleSearch: {
17
- kind: 'builtin',
18
- ui: true,
19
- interactionsType: 'google_search',
20
- openRouterPlugin: 'web',
21
- },
22
- googleMaps: {
23
- kind: 'builtin',
24
- ui: true,
25
- interactionsType: 'google_maps',
26
- conflictsWith: ['googleSearch', 'urlContext'],
27
- },
28
- urlContext: {
29
- kind: 'builtin',
30
- ui: true,
31
- interactionsType: 'url_context',
32
- },
33
- };
7
+ import { registerTools } from '../kernel/tools/mod.js';
8
+ import { GOOGLE_SPEECH_VOICES } from './google/speech-voices.js';
34
9
  /** Common Gemini image input MIME allowlist. */
35
10
  const GOOGLE_IMAGE_INPUT_MIMES = [
36
11
  'image/png',
@@ -41,40 +16,6 @@ const GOOGLE_IMAGE_INPUT_MIMES = [
41
16
  ];
42
17
  /** Common voice/audio input MIME allowlist for Gemini multimodal. */
43
18
  const GOOGLE_VOICE_INPUT_MIMES = ['audio/webm', 'audio/wav', 'audio/mpeg', 'audio/mp4'];
44
- /** Common Gemini TTS voice names for `outputs.speech.voice`. */
45
- const GOOGLE_SPEECH_VOICES = [
46
- 'Zephyr',
47
- 'Puck',
48
- 'Charon',
49
- 'Kore',
50
- 'Fenrir',
51
- 'Leda',
52
- 'Orus',
53
- 'Aoede',
54
- 'Callirrhoe',
55
- 'Autonoe',
56
- 'Enceladus',
57
- 'Iapetus',
58
- 'Umbriel',
59
- 'Algieba',
60
- 'Despina',
61
- 'Erinome',
62
- 'Algenib',
63
- 'Rasalgethi',
64
- 'Laomedeia',
65
- 'Achernar',
66
- 'Alnilam',
67
- 'Schedar',
68
- 'Gacrux',
69
- 'Pulcherrima',
70
- 'Achird',
71
- 'Zubenelgenubi',
72
- 'Vindemiatrix',
73
- 'Sadachbia',
74
- 'Sadaltager',
75
- 'Sulafat',
76
- ];
77
- /** Aspect ratios commonly accepted by Gemini image models. */
78
19
  const GOOGLE_IMAGE_ASPECT_RATIOS = [
79
20
  '1:1',
80
21
  '3:2',
@@ -87,9 +28,55 @@ const GOOGLE_IMAGE_ASPECT_RATIOS = [
87
28
  '16:9',
88
29
  '21:9',
89
30
  ];
90
- /** Image sizes commonly accepted by Gemini Flash Lite image. */
91
31
  const GOOGLE_IMAGE_SIZES = ['1K'];
92
- /** Register Google provider builtins into the process-local tool catalog. */
32
+ const GOOGLE_BUILTIN_TOOLS = [
33
+ {
34
+ type: 'builtin',
35
+ name: 'googleSearch',
36
+ description: 'Google Search grounding',
37
+ category: 'grounding',
38
+ access: 'read-only',
39
+ paths: ['*'],
40
+ loadTier: 'T0',
41
+ permission: 'auto',
42
+ forcePaidKey: true,
43
+ wire: { interactions: 'google_search', openRouter: 'web' },
44
+ },
45
+ {
46
+ type: 'builtin',
47
+ name: 'googleMaps',
48
+ description: 'Google Maps grounding',
49
+ category: 'grounding',
50
+ access: 'read-only',
51
+ paths: ['*'],
52
+ loadTier: 'T0',
53
+ permission: 'auto',
54
+ wire: { interactions: 'google_maps' },
55
+ },
56
+ {
57
+ type: 'builtin',
58
+ name: 'urlContext',
59
+ description: 'Fetch URL context',
60
+ category: 'grounding',
61
+ access: 'read-only',
62
+ paths: ['*'],
63
+ loadTier: 'T0',
64
+ permission: 'auto',
65
+ wire: { interactions: 'url_context' },
66
+ },
67
+ {
68
+ type: 'builtin',
69
+ name: 'codeExecution',
70
+ description: 'Google code execution',
71
+ category: 'grounding',
72
+ access: 'read-only',
73
+ paths: ['*'],
74
+ loadTier: 'T0',
75
+ permission: 'auto',
76
+ wire: { interactions: 'code_execution' },
77
+ },
78
+ ];
79
+ /** Register Google provider builtins into the process-local tool registry. */
93
80
  function registerGooglePreset() {
94
81
  registerTools(GOOGLE_BUILTIN_TOOLS);
95
82
  }
@@ -7,5 +7,5 @@
7
7
  * @module
8
8
  */
9
9
  import "../../_dnt.polyfills.js";
10
- export type { GoogleImageAspectRatio, GoogleImageInputMime, GoogleImagePins, GoogleImageSize, GoogleVoiceInputMime, } from './google.js';
11
- export { GOOGLE_BUILTIN_TOOLS, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_INPUT_MIMES, GOOGLE_IMAGE_SIZES, GOOGLE_VOICE_INPUT_MIMES, registerGooglePreset, } from './google.js';
10
+ export type { GoogleImageAspectRatio, GoogleImageInputMime, GoogleImagePins, GoogleImageSize, GoogleSpeechVoice, GoogleVoiceInputMime, } from './google.js';
11
+ export { GOOGLE_BUILTIN_TOOLS, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_INPUT_MIMES, GOOGLE_IMAGE_SIZES, GOOGLE_SPEECH_VOICES, GOOGLE_VOICE_INPUT_MIMES, registerGooglePreset, } from './google.js';
@@ -7,4 +7,4 @@
7
7
  * @module
8
8
  */
9
9
  import "../../_dnt.polyfills.js";
10
- export { GOOGLE_BUILTIN_TOOLS, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_INPUT_MIMES, GOOGLE_IMAGE_SIZES, GOOGLE_VOICE_INPUT_MIMES, registerGooglePreset, } from './google.js';
10
+ export { GOOGLE_BUILTIN_TOOLS, GOOGLE_IMAGE_ASPECT_RATIOS, GOOGLE_IMAGE_INPUT_MIMES, GOOGLE_IMAGE_SIZES, GOOGLE_SPEECH_VOICES, GOOGLE_VOICE_INPUT_MIMES, registerGooglePreset, } from './google.js';
@@ -1,36 +1,39 @@
1
1
  /**
2
2
  * Host provider factory — the single public door for binding a profile to a transport.
3
3
  *
4
- * Routes from `profile.model.protocol` / `provider` (and whether the profile is
5
- * a speech role). Adapters under this folder are internal implementation.
4
+ * Routes from the selected model binding's `protocol` / `provider` (and whether the
5
+ * profile is a speech or image role). Adapters under this folder are internal implementation.
6
6
  *
7
- * The OpenRouter / Vercel AI SDK stack is loaded only when an `openAi` +
8
- * `openrouter` chat provider actually runs `complete` — not when this module
9
- * is imported, and not for Google or local paths.
7
+ * Every adapter graph is loaded only when that transport's first `complete` runs —
8
+ * not when this module is imported.
10
9
  *
11
10
  * @module
12
11
  */
13
- import type { ModelProvider, Profile } from '../kernel/types.js';
14
- import type { GeminiTransport } from './keys.js';
15
- import { type LocalProviderConfig } from './local.js';
16
- import type { OpenRouterConfig } from './openrouter-payload.js';
12
+ import type { ModelId, ModelProvider, Profile } from '../kernel/types.js';
13
+ import type { GeminiTransport } from './google/keys.js';
14
+ import type { LocalProviderConfig, OpenAiGatewayConfig } from './types.js';
17
15
  /** Credentials supplied by the host when creating a provider. */
18
16
  export interface CreateProviderOptions {
19
- /** Google Interactions (chat, image, and speech when protocol is geminiInteractions). */
17
+ /** Google Interactions (text, image, and speech when protocol is geminiInteractions). */
20
18
  gemini?: GeminiTransport;
21
19
  /**
22
- * OpenRouter-compatible credentials for `openAi` profiles.
23
- * Used for chat completions or `/audio/speech` when the profile is a speech role.
24
- * Optional `voice` is a fallback when `outputs.speech.voice` is omitted.
20
+ * OpenAI-gateway credentials for `openAi` profiles (OpenRouter or compatible).
21
+ * Used for chat completions, `/images`, or `/audio/speech` depending on output role.
22
+ * Optional `voice` is a fallback when `speech.voice` is omitted.
25
23
  */
26
- openRouter?: OpenRouterConfig & {
24
+ openAiGateway?: OpenAiGatewayConfig & {
27
25
  voice?: string;
28
26
  };
29
27
  /** Local OpenAI-compatible server (Ollama, llama.cpp, vLLM, LM Studio). */
30
28
  local?: LocalProviderConfig;
31
29
  }
30
+ export declare function isSpeechRole(profile: Profile): boolean;
31
+ export declare function isImageRole(profile: Profile): boolean;
32
32
  /**
33
- * Create a `ModelProvider` for a profile.
34
- * One call: protocol/provider (and speech role) pick the transport.
33
+ * Create a `ModelProvider` for a turn-based profile (text / image / speech).
34
+ * Live profiles use `runSession` — `createProvider` rejects geminiLive.
35
+ *
36
+ * When a profile declares multiple models, pass `modelId` to pick the binding used
37
+ * for adapter selection (defaults to `defaultModel` or the sole model key).
35
38
  */
36
- export declare function createProvider(profile: Profile, options?: CreateProviderOptions): ModelProvider;
39
+ export declare function createProvider(profile: Profile, options?: CreateProviderOptions, modelId?: ModelId): ModelProvider;
@@ -1,60 +1,106 @@
1
1
  /**
2
2
  * Host provider factory — the single public door for binding a profile to a transport.
3
3
  *
4
- * Routes from `profile.model.protocol` / `provider` (and whether the profile is
5
- * a speech role). Adapters under this folder are internal implementation.
4
+ * Routes from the selected model binding's `protocol` / `provider` (and whether the
5
+ * profile is a speech or image role). Adapters under this folder are internal implementation.
6
6
  *
7
- * The OpenRouter / Vercel AI SDK stack is loaded only when an `openAi` +
8
- * `openrouter` chat provider actually runs `complete` — not when this module
9
- * is imported, and not for Google or local paths.
7
+ * Every adapter graph is loaded only when that transport's first `complete` runs —
8
+ * not when this module is imported.
10
9
  *
11
10
  * @module
12
11
  */
13
12
  import { TheorumError } from '../guardrails/error.js';
14
- import { exposeForTests } from './expose-for-tests.js';
15
- import { createLocalProvider } from './local.js';
16
- import { createInteractionsProvider } from './provider.js';
17
- import { createSpeechProvider } from './speech.js';
18
- function isSpeechRole(profile) {
19
- return profile.outputs.speech !== undefined;
13
+ import { requireModelProfile } from '../kernel/registry/resolve.js';
14
+ import { soleModelId } from '../kernel/registry/sole-model.js';
15
+ import { isValidPair } from '../kernel/schema.js';
16
+ import { markModuleLoad } from './probe.js';
17
+ export function isSpeechRole(profile) {
18
+ return profile.type === 'speech';
19
+ }
20
+ export function isImageRole(profile) {
21
+ return profile.type === 'image';
22
+ }
23
+ function bindingForProvider(input, modelId) {
24
+ const profile = requireModelProfile(input, 'createProvider');
25
+ const id = modelId ?? profile.defaultModel ?? soleModelId(profile.models);
26
+ if (!id) {
27
+ throw new TheorumError(`createProvider: profile '${profile.id}' must set defaultModel when multiple models are declared`);
28
+ }
29
+ const binding = profile.models[id];
30
+ if (!binding) {
31
+ throw new TheorumError(`createProvider: profile '${profile.id}' has no model '${id}'`);
32
+ }
33
+ return binding;
20
34
  }
21
35
  /**
22
- * Defer loading `@openrouter/ai-sdk-provider` / `ai` until the first `complete`.
23
- * Keeps Google and local hosts free of the Vercel SDK graph.
36
+ * Lazy-load an adapter on first `complete`. When `THEORUM_IMPORT_PROBE=1`,
37
+ * emits `LOADED:<label>` exactly once at load time (import-isolation tests).
24
38
  */
25
- function lazyOpenRouterChat(config) {
39
+ function lazyAdapter(label, load) {
26
40
  let pending;
27
41
  return {
28
42
  async *complete(req) {
29
- pending ??= import('./openrouter.js').then((m) => m.createOpenRouterProvider(config));
43
+ pending ??= (async () => {
44
+ markModuleLoad(label);
45
+ return await load();
46
+ })();
30
47
  yield* (await pending).complete(req);
31
48
  },
32
49
  };
33
50
  }
51
+ function lazyOpenRouterChat(config) {
52
+ return lazyAdapter('openrouter-chat', () => import('./openrouter/chat.js').then((m) => m.createOpenRouterProvider(config)));
53
+ }
54
+ function lazyGoogleInteractions(config) {
55
+ return lazyAdapter('google-interactions-adapter', () => import('./google/interactions/mod.js').then((m) => m.createInteractionsProvider(config)));
56
+ }
57
+ function lazySpeech(config) {
58
+ return lazyAdapter('openrouter-speech', () => import('./openrouter/speech.js').then((m) => m.createSpeechProvider(config)));
59
+ }
60
+ function lazyImage(config) {
61
+ return lazyAdapter('openrouter-image', () => import('./openrouter/image.js').then((m) => m.createImageProvider(config)));
62
+ }
63
+ function lazyLocal(config) {
64
+ return lazyAdapter('local-adapter', () => import('./local/local.js').then((m) => m.createLocalProvider(config)));
65
+ }
34
66
  /**
35
- * Create a `ModelProvider` for a profile.
36
- * One call: protocol/provider (and speech role) pick the transport.
67
+ * Create a `ModelProvider` for a turn-based profile (text / image / speech).
68
+ * Live profiles use `runSession` — `createProvider` rejects geminiLive.
69
+ *
70
+ * When a profile declares multiple models, pass `modelId` to pick the binding used
71
+ * for adapter selection (defaults to `defaultModel` or the sole model key).
37
72
  */
38
- export function createProvider(profile, options = {}) {
39
- const { protocol, provider } = profile.model;
73
+ export function createProvider(profile, options = {}, modelId) {
74
+ const { protocol, provider } = bindingForProvider(profile, modelId);
75
+ if (!isValidPair(protocol, provider)) {
76
+ throw new TheorumError(`createProvider: unsupported protocol/provider pair '${protocol}'/'${provider}'`);
77
+ }
40
78
  if (protocol === 'geminiInteractions' && provider === 'google') {
41
79
  if (!options.gemini) {
42
80
  throw new TheorumError('createProvider requires gemini transport for google Interactions');
43
81
  }
44
- return createInteractionsProvider(options.gemini);
82
+ return lazyGoogleInteractions(options.gemini);
83
+ }
84
+ if (protocol === 'geminiLive' && provider === 'google') {
85
+ throw new TheorumError("createProvider does not support type 'live' / geminiLive — use runSession(req, { gemini })");
45
86
  }
46
87
  if (protocol === 'openAi' && provider === 'openrouter') {
47
- if (!options.openRouter) {
48
- throw new TheorumError('createProvider requires openRouter config for openAi/openrouter');
88
+ if (!options.openAiGateway) {
89
+ throw new TheorumError('createProvider requires openAiGateway config for openAi/openrouter');
49
90
  }
50
91
  if (isSpeechRole(profile)) {
51
- return createSpeechProvider(options.openRouter);
92
+ return lazySpeech(options.openAiGateway);
52
93
  }
53
- return lazyOpenRouterChat(options.openRouter);
94
+ if (isImageRole(profile)) {
95
+ return lazyImage(options.openAiGateway);
96
+ }
97
+ return lazyOpenRouterChat(options.openAiGateway);
54
98
  }
55
99
  if (protocol === 'openAi' && provider === 'local') {
56
- return createLocalProvider(options.local);
100
+ if (isImageRole(profile)) {
101
+ throw new TheorumError('createProvider: type image requires openrouter provider for openAi protocol');
102
+ }
103
+ return lazyLocal(options.local);
57
104
  }
58
105
  throw new TheorumError(`createProvider: unsupported protocol/provider pair '${protocol}'/'${provider}'`);
59
106
  }
60
- exposeForTests('create-provider', { isSpeechRole, createProvider, lazyOpenRouterChat });
@@ -0,0 +1,23 @@
1
+ import type { InteractionPart, ProviderCompleteRequest, TurnHistoryMessage } from '../../../kernel/types.js';
2
+ export declare function camelToSnake(key: string): string;
3
+ export declare function toGoogleValue(value: unknown): unknown;
4
+ export declare function wirePart(part: InteractionPart): Record<string, string>;
5
+ export declare function userInputStep(parts: InteractionPart[]): Record<string, unknown>;
6
+ /**
7
+ * Map one host history message to Interactions input step(s).
8
+ *
9
+ * OpenAI-shaped assistant `tool_calls` (often with no `content`) become
10
+ * `function_call` steps — never empty `model_output` text.
11
+ */
12
+ export declare function historySteps(msg: TurnHistoryMessage): Record<string, unknown>[];
13
+ /** Single-step helper for simple messages (first of {@link historySteps}). */
14
+ export declare function historyStep(msg: TurnHistoryMessage): Record<string, unknown>;
15
+ export declare function systemHoldsUserInput(system: string, parts: InteractionPart[]): boolean;
16
+ export declare function jsonResponseFormat(schema: Record<string, unknown>): unknown[];
17
+ export declare function attachResponseFormat(req: ProviderCompleteRequest, camel: Record<string, unknown>): void;
18
+ export declare function attachSpeechConfig(req: ProviderCompleteRequest, generationConfig: Record<string, unknown>): void;
19
+ export declare function inputStepsFromRequest(req: ProviderCompleteRequest): Record<string, unknown>[];
20
+ export declare function applyOptionalRequestFields(req: ProviderCompleteRequest, camel: Record<string, unknown>): void;
21
+ export declare function baseInteractionsBody(req: ProviderCompleteRequest): Record<string, unknown>;
22
+ /** Compatibility wrapper for callers that need the complete wire body. */
23
+ export declare function toInteractionsBody(req: ProviderCompleteRequest): Record<string, unknown>;