@theoremjs/agents 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (568) hide show
  1. package/README.md +276 -995
  2. package/esm/mod.d.ts +33 -19
  3. package/esm/mod.js +18 -11
  4. package/esm/src/cli/commands/bench.js +36 -14
  5. package/esm/src/cli/commands/detect-compile.d.ts +17 -0
  6. package/esm/src/cli/commands/detect-compile.js +22 -0
  7. package/esm/src/cli/commands/eval.d.ts +3 -3
  8. package/esm/src/cli/commands/fuzz-canary.js +55 -16
  9. package/esm/src/cli/commands/profile.js +4 -4
  10. package/esm/src/cli/commands/run.d.ts +2 -2
  11. package/esm/src/cli/commands/run.js +1 -1
  12. package/esm/src/cli/commands/test.d.ts +4 -3
  13. package/esm/src/cli/commands/test.js +2 -2
  14. package/esm/src/cli/index.js +9 -9
  15. package/esm/src/cli/matrix/fixtures.js +25 -30
  16. package/esm/src/evals/attachments.d.ts +1 -0
  17. package/esm/src/evals/attachments.js +4 -2
  18. package/esm/src/evals/breakdown.d.ts +2 -0
  19. package/esm/src/evals/breakdown.js +1 -0
  20. package/esm/src/evals/graders/answer.d.ts +3 -0
  21. package/esm/src/evals/graders/answer.js +1 -0
  22. package/esm/src/evals/graders/code.d.ts +7 -31
  23. package/esm/src/evals/graders/code.js +4 -25
  24. package/esm/src/evals/graders/judge.d.ts +4 -0
  25. package/esm/src/evals/graders/judge.js +7 -5
  26. package/esm/src/evals/graders/latency.d.ts +1 -0
  27. package/esm/src/evals/graders/latency.js +3 -2
  28. package/esm/src/evals/graders/live.d.ts +3 -0
  29. package/esm/src/evals/graders/live.js +2 -0
  30. package/esm/src/evals/graders/media.js +1 -2
  31. package/esm/src/evals/graders/shared.js +1 -1
  32. package/esm/src/evals/graders/transcript.d.ts +2 -0
  33. package/esm/src/evals/graders/transcript.js +5 -3
  34. package/esm/src/evals/mod.d.ts +1 -9
  35. package/esm/src/evals/mod.js +1 -9
  36. package/esm/src/evals/record.d.ts +6 -0
  37. package/esm/src/evals/record.js +4 -2
  38. package/esm/src/evals/rubrics/mod.d.ts +1 -1
  39. package/esm/src/evals/rubrics/mod.js +1 -1
  40. package/esm/src/evals/rubrics/mustache.js +1 -1
  41. package/esm/src/evals/rubrics/types.js +1 -1
  42. package/esm/src/evals/run.d.ts +9 -52
  43. package/esm/src/evals/run.js +12 -46
  44. package/esm/src/evals/suite.d.ts +12 -3
  45. package/esm/src/evals/suite.js +9 -4
  46. package/esm/src/evals/summary.d.ts +3 -0
  47. package/esm/src/evals/summary.js +1 -0
  48. package/esm/src/evals/trial.d.ts +3 -16
  49. package/esm/src/evals/trial.js +7 -30
  50. package/esm/src/evals/types.d.ts +30 -121
  51. package/esm/src/evals/types.js +3 -16
  52. package/esm/src/evals/verdict.d.ts +5 -0
  53. package/esm/src/evals/verdict.js +4 -1
  54. package/esm/src/guardrails/boundaries.d.ts +41 -0
  55. package/esm/src/guardrails/boundaries.js +103 -0
  56. package/esm/src/guardrails/canary-gate.d.ts +1 -0
  57. package/esm/src/guardrails/canary.d.ts +49 -15
  58. package/esm/src/guardrails/canary.js +103 -30
  59. package/esm/src/guardrails/compile-egress.d.ts +6 -5
  60. package/esm/src/guardrails/compile-egress.js +6 -5
  61. package/esm/src/guardrails/corpus/canary-egress-attacks.d.ts +3 -1
  62. package/esm/src/guardrails/corpus/canary-egress-attacks.js +4 -2
  63. package/esm/src/guardrails/corpus/fuzz-inbound.js +14 -17
  64. package/esm/src/guardrails/corpus/inbound-payloads.d.ts +2 -0
  65. package/esm/src/guardrails/corpus/inbound-payloads.js +4 -2
  66. package/esm/src/guardrails/corpus/live-attacks.d.ts +2 -0
  67. package/esm/src/guardrails/corpus/live-attacks.js +6 -1
  68. package/esm/src/guardrails/corpus/mod.d.ts +1 -1
  69. package/esm/src/guardrails/corpus/secrets.d.ts +3 -3
  70. package/esm/src/guardrails/corpus/secrets.js +2 -2
  71. package/esm/src/guardrails/corpus/strings.d.ts +1 -1
  72. package/esm/src/guardrails/corpus/strings.js +1 -1
  73. package/esm/src/guardrails/corpus/types.d.ts +5 -1
  74. package/esm/src/guardrails/credential-rules.d.ts +36 -0
  75. package/esm/src/guardrails/credential-rules.js +3001 -0
  76. package/esm/src/guardrails/credential-scan.d.ts +45 -0
  77. package/esm/src/guardrails/credential-scan.js +172 -0
  78. package/esm/src/guardrails/destinations.d.ts +45 -0
  79. package/esm/src/guardrails/destinations.js +234 -0
  80. package/esm/src/guardrails/detect-at.d.ts +107 -0
  81. package/esm/src/guardrails/detect-at.js +434 -0
  82. package/esm/src/guardrails/detect-reply.d.ts +61 -0
  83. package/esm/src/guardrails/detect-reply.js +95 -0
  84. package/esm/src/guardrails/detect-stream.d.ts +33 -0
  85. package/esm/src/guardrails/detect-stream.js +77 -0
  86. package/esm/src/guardrails/detectors.d.ts +216 -0
  87. package/esm/src/guardrails/detectors.js +503 -0
  88. package/esm/src/guardrails/egress-automata.d.ts +4 -6
  89. package/esm/src/guardrails/egress-automata.js +24095 -4572
  90. package/esm/src/guardrails/egress-compiler.d.ts +38 -16
  91. package/esm/src/guardrails/egress-compiler.js +254 -60
  92. package/esm/src/guardrails/egress-patterns.d.ts +4 -2
  93. package/esm/src/guardrails/egress-patterns.js +6 -2
  94. package/esm/src/guardrails/egress-stream.d.ts +54 -36
  95. package/esm/src/guardrails/egress-stream.js +253 -124
  96. package/esm/src/guardrails/egress-urls.d.ts +6 -3
  97. package/esm/src/guardrails/egress-urls.js +14 -22
  98. package/esm/src/guardrails/egress.d.ts +26 -86
  99. package/esm/src/guardrails/egress.js +59 -309
  100. package/esm/src/guardrails/error.d.ts +13 -8
  101. package/esm/src/guardrails/error.js +23 -18
  102. package/esm/src/guardrails/event-schemas.d.ts +46 -3
  103. package/esm/src/guardrails/event-schemas.js +12 -5
  104. package/esm/src/guardrails/events.d.ts +5 -1
  105. package/esm/src/guardrails/events.js +4 -1
  106. package/esm/src/guardrails/hints.d.ts +14 -0
  107. package/esm/src/guardrails/hints.js +57 -0
  108. package/esm/src/guardrails/hits.d.ts +7 -1
  109. package/esm/src/guardrails/hits.js +12 -1
  110. package/esm/src/guardrails/host-patterns.d.ts +85 -0
  111. package/esm/src/guardrails/host-patterns.js +173 -0
  112. package/esm/src/guardrails/injection-patterns.d.ts +6 -1
  113. package/esm/src/guardrails/injection-patterns.js +33 -1
  114. package/esm/src/guardrails/injection-reversed.d.ts +9 -0
  115. package/esm/src/guardrails/injection-reversed.js +49 -0
  116. package/esm/src/guardrails/injection.d.ts +17 -1
  117. package/esm/src/guardrails/injection.js +259 -36
  118. package/esm/src/guardrails/labels.d.ts +40 -0
  119. package/esm/src/guardrails/labels.js +874 -0
  120. package/esm/src/guardrails/live-outbound-gate.d.ts +9 -8
  121. package/esm/src/guardrails/live-outbound-gate.js +100 -107
  122. package/esm/src/guardrails/mod.d.ts +29 -21
  123. package/esm/src/guardrails/mod.js +18 -13
  124. package/esm/src/guardrails/network.d.ts +4 -0
  125. package/esm/src/guardrails/network.js +21 -19
  126. package/esm/src/guardrails/normalize.d.ts +15 -1
  127. package/esm/src/guardrails/normalize.js +34 -1
  128. package/esm/src/guardrails/policy.d.ts +2 -17
  129. package/esm/src/guardrails/policy.js +12 -41
  130. package/esm/src/guardrails/progressive-yield.d.ts +65 -24
  131. package/esm/src/guardrails/progressive-yield.js +191 -147
  132. package/esm/src/guardrails/prompt-echo.d.ts +4 -2
  133. package/esm/src/guardrails/prompt-echo.js +87 -6
  134. package/esm/src/guardrails/quota.d.ts +1 -0
  135. package/esm/src/guardrails/quota.js +1 -1
  136. package/esm/src/guardrails/rules.d.ts +20 -29
  137. package/esm/src/guardrails/rules.js +23 -30
  138. package/esm/src/guardrails/sanitize.d.ts +32 -15
  139. package/esm/src/guardrails/sanitize.js +100 -124
  140. package/esm/src/guardrails/sensitive-groups.d.ts +21 -0
  141. package/esm/src/guardrails/sensitive-groups.js +12 -0
  142. package/esm/src/guardrails/sensitive.d.ts +16 -23
  143. package/esm/src/guardrails/sensitive.js +168 -47
  144. package/esm/src/guardrails/serialize.d.ts +1 -0
  145. package/esm/src/guardrails/testing.d.ts +4 -2
  146. package/esm/src/guardrails/testing.js +4 -2
  147. package/esm/src/guardrails/theorem-error.d.ts +4 -1
  148. package/esm/src/guardrails/theorem-error.js +3 -2
  149. package/esm/src/guardrails/thought-guard.d.ts +34 -13
  150. package/esm/src/guardrails/thought-guard.js +264 -64
  151. package/esm/src/guardrails/tool-directives.d.ts +29 -10
  152. package/esm/src/guardrails/tool-directives.js +133 -47
  153. package/esm/src/guardrails/tool-leak.d.ts +26 -0
  154. package/esm/src/guardrails/tool-leak.js +45 -0
  155. package/esm/src/guardrails/tool-result.d.ts +45 -14
  156. package/esm/src/guardrails/tool-result.js +94 -70
  157. package/esm/src/guardrails/types.d.ts +79 -71
  158. package/esm/src/guardrails/types.js +11 -7
  159. package/esm/src/host/client-turn.d.ts +29 -2
  160. package/esm/src/host/client-turn.js +46 -4
  161. package/esm/src/host/mint-trace.d.ts +1 -0
  162. package/esm/src/host/mint-trace.js +3 -2
  163. package/esm/src/host/mod.d.ts +2 -2
  164. package/esm/src/host/mod.js +1 -1
  165. package/esm/src/host/readStreamingJsonStringField.js +2 -43
  166. package/esm/src/host/reply.d.ts +6 -0
  167. package/esm/src/host/reply.js +7 -1
  168. package/esm/src/interface/blocks.d.ts +3 -0
  169. package/esm/src/interface/blocks.js +84 -14
  170. package/esm/src/interface/composer-actions.d.ts +4 -0
  171. package/esm/src/interface/composer-actions.js +5 -3
  172. package/esm/src/interface/draft.d.ts +6 -0
  173. package/esm/src/interface/draft.js +22 -11
  174. package/esm/src/interface/from-profile.d.ts +13 -1
  175. package/esm/src/interface/from-profile.js +66 -31
  176. package/esm/src/interface/history.d.ts +9 -3
  177. package/esm/src/interface/history.js +33 -24
  178. package/esm/src/interface/inputs.d.ts +1 -0
  179. package/esm/src/interface/inputs.js +3 -0
  180. package/esm/src/interface/mod.d.ts +4 -2
  181. package/esm/src/interface/mod.js +3 -2
  182. package/esm/src/interface/models.d.ts +7 -0
  183. package/esm/src/interface/models.js +5 -0
  184. package/esm/src/interface/pending.d.ts +9 -0
  185. package/esm/src/interface/pending.js +9 -3
  186. package/esm/src/interface/profile-interface.js +54 -40
  187. package/esm/src/interface/session.d.ts +12 -5
  188. package/esm/src/interface/session.js +17 -10
  189. package/esm/src/interface/stop.d.ts +13 -0
  190. package/esm/src/interface/stop.js +28 -0
  191. package/esm/src/interface/tool-calls.d.ts +14 -2
  192. package/esm/src/interface/tool-calls.js +64 -10
  193. package/esm/src/interface/tool-invoke.d.ts +2 -0
  194. package/esm/src/interface/tool-invoke.js +3 -1
  195. package/esm/src/interface/tool-media.d.ts +2 -0
  196. package/esm/src/interface/tool-media.js +2 -1
  197. package/esm/src/interface/types.d.ts +105 -40
  198. package/esm/src/interface/types.js +1 -0
  199. package/esm/src/kernel/api-catalog.d.ts +85 -0
  200. package/esm/src/kernel/api-catalog.js +229 -0
  201. package/esm/src/kernel/auth/crypto.d.ts +7 -2
  202. package/esm/src/kernel/auth/crypto.js +12 -10
  203. package/esm/src/kernel/auth/oauth.d.ts +2 -1
  204. package/esm/src/kernel/auth/oauth.js +23 -22
  205. package/esm/src/kernel/auth/typed-secret.js +2 -2
  206. package/esm/src/kernel/auth/types.d.ts +13 -0
  207. package/esm/src/kernel/checkpoint.d.ts +43 -0
  208. package/esm/src/kernel/checkpoint.js +58 -0
  209. package/esm/src/kernel/default-scope.d.ts +43 -5
  210. package/esm/src/kernel/default-scope.js +54 -5
  211. package/esm/src/kernel/engine/call-trace.d.ts +19 -0
  212. package/esm/src/kernel/engine/call-trace.js +29 -0
  213. package/esm/src/kernel/engine/compaction.d.ts +6 -5
  214. package/esm/src/kernel/engine/compaction.js +12 -11
  215. package/esm/src/kernel/engine/decision.d.ts +10 -8
  216. package/esm/src/kernel/engine/decision.js +173 -146
  217. package/esm/src/kernel/engine/embedding.d.ts +8 -0
  218. package/esm/src/kernel/engine/embedding.js +118 -0
  219. package/esm/src/kernel/engine/live-inbound.d.ts +14 -4
  220. package/esm/src/kernel/engine/live-inbound.js +36 -11
  221. package/esm/src/kernel/engine/live-ingress.d.ts +6 -0
  222. package/esm/src/kernel/engine/live-ingress.js +6 -1
  223. package/esm/src/kernel/engine/repair.js +12 -12
  224. package/esm/src/kernel/engine/runner/gates.d.ts +2 -2
  225. package/esm/src/kernel/engine/runner/gates.js +287 -101
  226. package/esm/src/kernel/engine/runner/mod.d.ts +19 -5
  227. package/esm/src/kernel/engine/runner/mod.js +107 -56
  228. package/esm/src/kernel/engine/runner/nested.d.ts +32 -0
  229. package/esm/src/kernel/engine/runner/nested.js +134 -0
  230. package/esm/src/kernel/engine/runner/schema-validation.d.ts +24 -3
  231. package/esm/src/kernel/engine/runner/schema-validation.js +78 -4
  232. package/esm/src/kernel/engine/runner/stages.d.ts +1 -1
  233. package/esm/src/kernel/engine/runner/stages.js +1 -8
  234. package/esm/src/kernel/engine/runner/state.d.ts +33 -12
  235. package/esm/src/kernel/engine/runner/state.js +11 -1
  236. package/esm/src/kernel/engine/runner/step-order.d.ts +27 -0
  237. package/esm/src/kernel/engine/runner/step-order.js +165 -0
  238. package/esm/src/kernel/engine/runner/steps.d.ts +2 -2
  239. package/esm/src/kernel/engine/runner/steps.js +328 -169
  240. package/esm/src/kernel/engine/runner/stream.d.ts +42 -11
  241. package/esm/src/kernel/engine/runner/stream.js +197 -46
  242. package/esm/src/kernel/engine/runner/usage.d.ts +5 -5
  243. package/esm/src/kernel/engine/runner/usage.js +12 -14
  244. package/esm/src/kernel/engine/session/mod.d.ts +8 -6
  245. package/esm/src/kernel/engine/session/mod.js +360 -129
  246. package/esm/src/kernel/engine/session/session-trace.d.ts +10 -10
  247. package/esm/src/kernel/engine/session/session-trace.js +41 -30
  248. package/esm/src/kernel/engine/token-estimate.d.ts +10 -64
  249. package/esm/src/kernel/engine/token-estimate.js +14 -194
  250. package/esm/src/kernel/engine/tool-trace.d.ts +3 -3
  251. package/esm/src/kernel/engine/tool-trace.js +2 -1
  252. package/esm/src/kernel/engine/turn-trace.d.ts +8 -7
  253. package/esm/src/kernel/engine/turn-trace.js +28 -36
  254. package/esm/src/kernel/engine/usage.d.ts +6 -0
  255. package/esm/src/kernel/engine/usage.js +17 -0
  256. package/esm/src/kernel/interaction-parts.d.ts +3 -0
  257. package/esm/src/kernel/interaction-parts.js +18 -0
  258. package/esm/src/kernel/json.d.ts +10 -0
  259. package/esm/src/kernel/json.js +3 -0
  260. package/esm/src/kernel/mod.d.ts +38 -11
  261. package/esm/src/kernel/mod.js +22 -7
  262. package/esm/src/kernel/profile-graph.d.ts +11 -6
  263. package/esm/src/kernel/profile-graph.js +14 -7
  264. package/esm/src/kernel/profile-presence.d.ts +10 -1
  265. package/esm/src/kernel/profile-presence.js +90 -75
  266. package/esm/src/kernel/profile-scope.d.ts +7 -3
  267. package/esm/src/kernel/profile-scope.js +67 -55
  268. package/esm/src/kernel/protocols/binding.d.ts +65 -0
  269. package/esm/src/kernel/protocols/binding.js +125 -0
  270. package/esm/src/kernel/protocols/limits.d.ts +15 -0
  271. package/esm/src/kernel/protocols/limits.js +28 -0
  272. package/esm/src/kernel/protocols/mod.d.ts +5 -0
  273. package/esm/src/kernel/protocols/mod.js +5 -0
  274. package/esm/src/kernel/protocols/prices.d.ts +36 -0
  275. package/esm/src/kernel/protocols/prices.js +37 -0
  276. package/esm/src/kernel/protocols/protocol.d.ts +253 -0
  277. package/esm/src/kernel/protocols/protocol.js +253 -0
  278. package/esm/src/kernel/protocols/provider.d.ts +108 -0
  279. package/esm/src/kernel/protocols/provider.js +143 -0
  280. package/esm/src/kernel/protocols/runtime.d.ts +55 -0
  281. package/esm/src/kernel/protocols/runtime.js +534 -0
  282. package/esm/src/kernel/provider-budget.d.ts +32 -0
  283. package/esm/src/kernel/provider-budget.js +262 -0
  284. package/esm/src/kernel/provider-dispatch.d.ts +13 -0
  285. package/esm/src/kernel/provider-dispatch.js +36 -0
  286. package/esm/src/kernel/provider-live.d.ts +7 -0
  287. package/esm/src/kernel/provider-live.js +189 -0
  288. package/esm/src/kernel/provider-runtime.d.ts +57 -0
  289. package/esm/src/kernel/provider-runtime.js +524 -0
  290. package/esm/src/kernel/registry/attachments.d.ts +15 -4
  291. package/esm/src/kernel/registry/attachments.js +31 -22
  292. package/esm/src/kernel/registry/catalog.d.ts +6 -0
  293. package/esm/src/kernel/registry/catalog.js +9 -2
  294. package/esm/src/kernel/registry/embedding-rules.d.ts +28 -0
  295. package/esm/src/kernel/registry/embedding-rules.js +66 -0
  296. package/esm/src/kernel/registry/ingress.d.ts +6 -2
  297. package/esm/src/kernel/registry/ingress.js +55 -10
  298. package/esm/src/kernel/registry/kernel-registry.d.ts +3 -0
  299. package/esm/src/kernel/registry/kernel-registry.js +9 -2
  300. package/esm/src/kernel/registry/profile-outputs.js +4 -1
  301. package/esm/src/kernel/registry/profiles.d.ts +38 -14
  302. package/esm/src/kernel/registry/profiles.js +280 -205
  303. package/esm/src/kernel/registry/provider-request.d.ts +3 -3
  304. package/esm/src/kernel/registry/provider-request.js +5 -13
  305. package/esm/src/kernel/registry/resolve.d.ts +4 -1
  306. package/esm/src/kernel/registry/resolve.js +59 -58
  307. package/esm/src/kernel/registry/schemas.d.ts +3 -0
  308. package/esm/src/kernel/registry/schemas.js +3 -1
  309. package/esm/src/kernel/registry/slot-fill.d.ts +7 -0
  310. package/esm/src/kernel/registry/slot-fill.js +22 -0
  311. package/esm/src/kernel/registry/system-prompt.js +7 -8
  312. package/esm/src/kernel/registry/vault.d.ts +14 -13
  313. package/esm/src/kernel/registry/vault.js +1 -14
  314. package/esm/src/kernel/schema.d.ts +100 -46
  315. package/esm/src/kernel/schema.js +499 -257
  316. package/esm/src/kernel/scope.d.ts +12 -5
  317. package/esm/src/kernel/scope.js +23 -3
  318. package/esm/src/kernel/stages.d.ts +38 -3
  319. package/esm/src/kernel/stages.js +82 -39
  320. package/esm/src/kernel/stop.d.ts +29 -6
  321. package/esm/src/kernel/stop.js +16 -4
  322. package/esm/src/kernel/system-parts.js +6 -6
  323. package/esm/src/kernel/tools/activity-label.d.ts +12 -6
  324. package/esm/src/kernel/tools/activity-label.js +258 -32
  325. package/esm/src/kernel/tools/agent.d.ts +66 -0
  326. package/esm/src/kernel/tools/agent.js +212 -0
  327. package/esm/src/kernel/tools/coordinate.d.ts +4 -0
  328. package/esm/src/kernel/tools/coordinate.js +165 -0
  329. package/esm/src/kernel/tools/events.d.ts +21 -6
  330. package/esm/src/kernel/tools/events.js +53 -18
  331. package/esm/src/kernel/tools/execute.d.ts +47 -11
  332. package/esm/src/kernel/tools/execute.js +508 -136
  333. package/esm/src/kernel/tools/gate-answer.d.ts +12 -2
  334. package/esm/src/kernel/tools/gate-answer.js +17 -6
  335. package/esm/src/kernel/tools/handler-events.d.ts +45 -0
  336. package/esm/src/kernel/tools/handler-events.js +106 -0
  337. package/esm/src/kernel/tools/harness.d.ts +1 -0
  338. package/esm/src/kernel/tools/harness.js +2 -1
  339. package/esm/src/kernel/tools/http-limit.d.ts +27 -0
  340. package/esm/src/kernel/tools/http-limit.js +85 -0
  341. package/esm/src/kernel/tools/invoke.d.ts +27 -5
  342. package/esm/src/kernel/tools/invoke.js +223 -70
  343. package/esm/src/kernel/tools/mcp-sessions.d.ts +4 -1
  344. package/esm/src/kernel/tools/mcp-sessions.js +13 -8
  345. package/esm/src/kernel/tools/mod.d.ts +4 -3
  346. package/esm/src/kernel/tools/mod.js +3 -2
  347. package/esm/src/kernel/tools/model-text.d.ts +10 -5
  348. package/esm/src/kernel/tools/model-text.js +18 -12
  349. package/esm/src/kernel/tools/operation.d.ts +76 -0
  350. package/esm/src/kernel/tools/operation.js +100 -0
  351. package/esm/src/kernel/tools/page-answer.d.ts +8 -0
  352. package/esm/src/kernel/tools/page-answer.js +19 -0
  353. package/esm/src/kernel/tools/permission.d.ts +11 -2
  354. package/esm/src/kernel/tools/permission.js +12 -12
  355. package/esm/src/kernel/tools/project.d.ts +4 -1
  356. package/esm/src/kernel/tools/project.js +32 -2
  357. package/esm/src/kernel/tools/registry.d.ts +9 -2
  358. package/esm/src/kernel/tools/registry.js +69 -10
  359. package/esm/src/kernel/tools/remote.d.ts +40 -6
  360. package/esm/src/kernel/tools/remote.js +219 -92
  361. package/esm/src/kernel/tools/resolve.d.ts +3 -0
  362. package/esm/src/kernel/tools/resolve.js +12 -4
  363. package/esm/src/kernel/tools/run.d.ts +28 -0
  364. package/esm/src/kernel/tools/run.js +86 -0
  365. package/esm/src/kernel/tools/schema.d.ts +3 -3
  366. package/esm/src/kernel/tools/schema.js +21 -100
  367. package/esm/src/kernel/tools/signed-in-fetch.d.ts +2 -1
  368. package/esm/src/kernel/tools/signed-in-fetch.js +3 -3
  369. package/esm/src/kernel/tools/stage-run.d.ts +27 -4
  370. package/esm/src/kernel/tools/stage-run.js +75 -17
  371. package/esm/src/kernel/tools/types.d.ts +235 -25
  372. package/esm/src/kernel/tools/unchecked-output.d.ts +14 -0
  373. package/esm/src/kernel/tools/unchecked-output.js +18 -0
  374. package/esm/src/kernel/turn-events.d.ts +208 -31
  375. package/esm/src/kernel/turn-events.js +127 -9
  376. package/esm/src/kernel/types.d.ts +302 -161
  377. package/esm/src/kernel/util/base64.d.ts +2 -0
  378. package/esm/src/kernel/util/base64.js +2 -0
  379. package/esm/src/kernel/util/partial-json.d.ts +23 -0
  380. package/esm/src/kernel/util/partial-json.js +128 -0
  381. package/esm/src/kernel/util/record.d.ts +1 -0
  382. package/esm/src/kernel/util/record.js +1 -0
  383. package/esm/src/observability/destinations.d.ts +5 -0
  384. package/esm/src/observability/destinations.js +7 -2
  385. package/esm/src/observability/jsonl.d.ts +2 -2
  386. package/esm/src/observability/jsonl.js +15 -22
  387. package/esm/src/observability/mod.d.ts +3 -3
  388. package/esm/src/observability/mod.js +2 -2
  389. package/esm/src/observability/openinference.d.ts +1 -1
  390. package/esm/src/observability/openinference.js +3 -3
  391. package/esm/src/observability/otlp.d.ts +3 -0
  392. package/esm/src/observability/otlp.js +3 -3
  393. package/esm/src/observability/phoenix.d.ts +1 -0
  394. package/esm/src/observability/policy.d.ts +3 -0
  395. package/esm/src/observability/policy.js +5 -1
  396. package/esm/src/observability/resolve-policy.js +11 -5
  397. package/esm/src/observability/spans.d.ts +8 -2
  398. package/esm/src/observability/spans.js +21 -5
  399. package/esm/src/observability/trace-catalog.d.ts +19 -2
  400. package/esm/src/observability/trace-catalog.js +128 -87
  401. package/esm/src/observability/trace-record.js +22 -17
  402. package/esm/src/observability/trace-schema.d.ts +3 -0
  403. package/esm/src/observability/trace-schema.js +1 -1
  404. package/esm/src/observability/trace-sink.d.ts +1 -0
  405. package/esm/src/observability/trace-sink.js +1 -1
  406. package/esm/src/observability/trace-span.d.ts +7 -1
  407. package/esm/src/observability/trace-span.js +3 -1
  408. package/esm/src/observability/trace.d.ts +2 -0
  409. package/esm/src/observability/trace.js +4 -2
  410. package/esm/src/observability/types.d.ts +35 -11
  411. package/esm/src/observability/types.js +1 -1
  412. package/esm/src/presets/google/speech-voices.d.ts +1 -0
  413. package/esm/src/presets/google-limits.d.ts +1 -0
  414. package/esm/src/presets/google.d.ts +27 -12
  415. package/esm/src/presets/google.js +34 -25
  416. package/esm/src/presets/local.d.ts +26 -0
  417. package/esm/src/presets/local.js +30 -0
  418. package/esm/src/presets/mod.d.ts +5 -4
  419. package/esm/src/presets/mod.js +4 -4
  420. package/esm/src/presets/openrouter.d.ts +14 -1
  421. package/esm/src/presets/openrouter.js +19 -1
  422. package/esm/src/providers/embedding-limits.d.ts +7 -0
  423. package/esm/src/providers/embedding-limits.js +12 -0
  424. package/esm/src/providers/gemini/embedding-protocol.d.ts +8 -0
  425. package/esm/src/providers/gemini/embedding-protocol.js +125 -0
  426. package/esm/src/providers/gemini/interactions-protocol.d.ts +8 -0
  427. package/esm/src/providers/gemini/interactions-protocol.js +105 -0
  428. package/esm/src/providers/gemini/live-protocol.d.ts +3 -0
  429. package/esm/src/providers/gemini/live-protocol.js +191 -0
  430. package/esm/src/providers/gemini/prices.d.ts +3 -0
  431. package/esm/src/providers/gemini/prices.js +63 -0
  432. package/esm/src/providers/gemini/provider.d.ts +7 -0
  433. package/esm/src/providers/gemini/provider.js +39 -0
  434. package/esm/src/providers/google/builtins.d.ts +14 -0
  435. package/esm/src/providers/google/builtins.js +57 -0
  436. package/esm/src/providers/google/grounding.d.ts +4 -4
  437. package/esm/src/providers/google/interactions/framing.d.ts +20 -8
  438. package/esm/src/providers/google/interactions/framing.js +85 -44
  439. package/esm/src/providers/google/interactions/steps.d.ts +5 -5
  440. package/esm/src/providers/google/interactions/steps.js +4 -4
  441. package/esm/src/providers/google/interactions/stream.d.ts +10 -11
  442. package/esm/src/providers/google/interactions/stream.js +33 -100
  443. package/esm/src/providers/google/live/framing.d.ts +15 -5
  444. package/esm/src/providers/google/live/framing.js +25 -25
  445. package/esm/src/providers/google/live/stream.d.ts +6 -44
  446. package/esm/src/providers/google/live/stream.js +3 -209
  447. package/esm/src/providers/google/urls.d.ts +1 -3
  448. package/esm/src/providers/google/urls.js +1 -3
  449. package/esm/src/providers/google/usage.js +2 -2
  450. package/esm/src/providers/live.d.ts +6 -0
  451. package/esm/src/providers/live.js +6 -0
  452. package/esm/src/providers/local/embedding-protocol.d.ts +7 -0
  453. package/esm/src/providers/local/embedding-protocol.js +60 -0
  454. package/esm/src/providers/local/provider.d.ts +7 -0
  455. package/esm/src/providers/local/provider.js +28 -0
  456. package/esm/src/providers/mod.d.ts +28 -7
  457. package/esm/src/providers/mod.js +19 -3
  458. package/esm/src/providers/open-ai/protocol.d.ts +3 -0
  459. package/esm/src/providers/open-ai/protocol.js +189 -0
  460. package/esm/src/providers/openrouter/embedding-protocol.d.ts +6 -0
  461. package/esm/src/providers/openrouter/embedding-protocol.js +86 -0
  462. package/esm/src/providers/openrouter/image.d.ts +0 -9
  463. package/esm/src/providers/openrouter/image.js +0 -153
  464. package/esm/src/providers/openrouter/images-protocol.d.ts +3 -0
  465. package/esm/src/providers/openrouter/images-protocol.js +82 -0
  466. package/esm/src/providers/openrouter/openai/compat.d.ts +2 -2
  467. package/esm/src/providers/openrouter/openai/compat.js +6 -6
  468. package/esm/src/providers/openrouter/openai/image-payload.d.ts +2 -2
  469. package/esm/src/providers/openrouter/openai/reasoning-state.d.ts +2 -0
  470. package/esm/src/providers/openrouter/openai/reasoning-state.js +31 -0
  471. package/esm/src/providers/openrouter/protocol.d.ts +8 -0
  472. package/esm/src/providers/openrouter/protocol.js +171 -0
  473. package/esm/src/providers/openrouter/provider.d.ts +10 -0
  474. package/esm/src/providers/openrouter/provider.js +50 -0
  475. package/esm/src/providers/shared/carried-tool-files.d.ts +7 -0
  476. package/esm/src/providers/shared/carried-tool-files.js +43 -0
  477. package/esm/src/providers/shared/pcm.js +2 -2
  478. package/esm/src/providers/shared/protocol-events.d.ts +8 -0
  479. package/esm/src/providers/shared/protocol-events.js +20 -0
  480. package/esm/src/providers/shared/response-identity.d.ts +2 -2
  481. package/esm/src/providers/shared/retry.d.ts +17 -0
  482. package/esm/src/providers/shared/retry.js +90 -0
  483. package/esm/src/providers/shared/sse.d.ts +0 -4
  484. package/esm/src/providers/shared/sse.js +50 -36
  485. package/esm/src/providers/shared/tool-args.d.ts +6 -7
  486. package/esm/src/providers/shared/tool-args.js +10 -6
  487. package/esm/src/providers/shared/tool-draft.d.ts +16 -0
  488. package/esm/src/providers/shared/tool-draft.js +14 -0
  489. package/esm/src/providers/shared/upstream-tap.d.ts +2 -2
  490. package/esm/src/providers/shared/upstream-tape.js +1 -1
  491. package/esm/src/providers/system-one/protocol.d.ts +8 -0
  492. package/esm/src/providers/system-one/protocol.js +93 -0
  493. package/esm/src/providers/types.d.ts +48 -16
  494. package/esm/src/providers/types.js +2 -1
  495. package/esm/src/providers/typesafe/provider.d.ts +7 -0
  496. package/esm/src/providers/typesafe/provider.js +24 -0
  497. package/esm/src/surface/formats.d.ts +19 -1
  498. package/esm/src/surface/formats.js +68 -29
  499. package/esm/src/surface/mod.d.ts +4 -2
  500. package/esm/src/surface/mod.js +4 -2
  501. package/esm/src/surface/runtime.d.ts +4 -0
  502. package/esm/src/surface/runtime.js +2 -0
  503. package/esm/src/surface/tools.d.ts +2 -8
  504. package/esm/src/surface/tools.js +4 -22
  505. package/esm/src/surface/types.d.ts +6 -0
  506. package/package.json +5 -13
  507. package/esm/src/cli/commands/egress-compile.d.ts +0 -17
  508. package/esm/src/cli/commands/egress-compile.js +0 -25
  509. package/esm/src/guardrails/egress-policy.d.ts +0 -27
  510. package/esm/src/guardrails/egress-policy.js +0 -76
  511. package/esm/src/guardrails/egress-rules.d.ts +0 -54
  512. package/esm/src/guardrails/egress-rules.js +0 -49
  513. package/esm/src/guardrails/lexicon.d.ts +0 -30
  514. package/esm/src/guardrails/lexicon.js +0 -478
  515. package/esm/src/kernel/engine/media-probe/audio.d.ts +0 -7
  516. package/esm/src/kernel/engine/media-probe/audio.js +0 -342
  517. package/esm/src/kernel/engine/media-probe/bytes.d.ts +0 -6
  518. package/esm/src/kernel/engine/media-probe/bytes.js +0 -26
  519. package/esm/src/kernel/engine/media-probe/image.d.ts +0 -5
  520. package/esm/src/kernel/engine/media-probe/image.js +0 -171
  521. package/esm/src/kernel/engine/media-probe/iso-bmff.d.ts +0 -19
  522. package/esm/src/kernel/engine/media-probe/iso-bmff.js +0 -48
  523. package/esm/src/kernel/engine/media-probe/matroska.d.ts +0 -35
  524. package/esm/src/kernel/engine/media-probe/matroska.js +0 -226
  525. package/esm/src/kernel/engine/media-probe/mp4.d.ts +0 -22
  526. package/esm/src/kernel/engine/media-probe/mp4.js +0 -279
  527. package/esm/src/kernel/engine/media-probe/opus.d.ts +0 -4
  528. package/esm/src/kernel/engine/media-probe/opus.js +0 -23
  529. package/esm/src/kernel/engine/media-probe/pdf.d.ts +0 -5
  530. package/esm/src/kernel/engine/media-probe/pdf.js +0 -117
  531. package/esm/src/kernel/engine/media-probe/video.d.ts +0 -15
  532. package/esm/src/kernel/engine/media-probe/video.js +0 -49
  533. package/esm/src/presets/typesafe.d.ts +0 -2
  534. package/esm/src/presets/typesafe.js +0 -2
  535. package/esm/src/providers/create-provider.d.ts +0 -21
  536. package/esm/src/providers/create-provider.js +0 -90
  537. package/esm/src/providers/decision/usage.d.ts +0 -3
  538. package/esm/src/providers/decision/usage.js +0 -25
  539. package/esm/src/providers/google/interactions/mod.d.ts +0 -2
  540. package/esm/src/providers/google/interactions/mod.js +0 -2
  541. package/esm/src/providers/google/keys.d.ts +0 -20
  542. package/esm/src/providers/google/keys.js +0 -87
  543. package/esm/src/providers/google/live/mod.d.ts +0 -7
  544. package/esm/src/providers/google/live/mod.js +0 -7
  545. package/esm/src/providers/google/live/openapi-schema.d.ts +0 -1
  546. package/esm/src/providers/google/live/openapi-schema.js +0 -42
  547. package/esm/src/providers/google/live/session.d.ts +0 -14
  548. package/esm/src/providers/google/live/session.js +0 -150
  549. package/esm/src/providers/local/local.d.ts +0 -12
  550. package/esm/src/providers/local/local.js +0 -186
  551. package/esm/src/providers/local/mod.d.ts +0 -8
  552. package/esm/src/providers/local/mod.js +0 -8
  553. package/esm/src/providers/openrouter/cache-control.d.ts +0 -5
  554. package/esm/src/providers/openrouter/cache-control.js +0 -4
  555. package/esm/src/providers/openrouter/chat.d.ts +0 -64
  556. package/esm/src/providers/openrouter/chat.js +0 -490
  557. package/esm/src/providers/openrouter/openai/sdk-messages.d.ts +0 -10
  558. package/esm/src/providers/openrouter/openai/sdk-messages.js +0 -99
  559. package/esm/src/providers/openrouter/resolve-api-key.d.ts +0 -3
  560. package/esm/src/providers/openrouter/resolve-api-key.js +0 -8
  561. package/esm/src/providers/openrouter/speech.d.ts +0 -18
  562. package/esm/src/providers/openrouter/speech.js +0 -109
  563. package/esm/src/providers/probe.d.ts +0 -5
  564. package/esm/src/providers/probe.js +0 -15
  565. package/esm/src/providers/shared/builtin-wire.d.ts +0 -4
  566. package/esm/src/providers/shared/builtin-wire.js +0 -9
  567. package/esm/src/providers/shared/vault.d.ts +0 -13
  568. package/esm/src/providers/shared/vault.js +0 -41
@@ -1,22 +1,35 @@
1
- import type { CacheMode, CacheTtl, CompactionMeter, CompactionOutcome, CompactionTiming, ContinueStopKind, FieldMeta, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveStartSensitivity, MediaInputKind, ProfileType, ProfileTypeProtocol, Protocol, Provider, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolLoadTier, TurnStage, TurnStopKind } from './schema.js';
1
+ import type { ProviderCheckpoint, ProviderContinuationPolicy } from './checkpoint.js';
2
+ import type { JsonObject } from './json.js';
3
+ import type { CacheMode, CacheTtl, CompactionMeter, CompactionOutcome, CompactionTiming, ContextSender, ContinueStopKind, FieldMeta, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveStartSensitivity, MediaInputKind, ProfileType, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolLoadTier, TurnStage, TurnStopKind } from './schema.js';
2
4
  import type { StageHandler } from './stages.js';
3
5
  import type { GateDecision } from './tools/gate-answer.js';
4
- import type { BuiltinWire, HostProfileToolsSpec, InvokeToolRequest, InvokeToolResume, LiveProfileToolsSpec, ModelToolResult, ProfileToolsSpec, RegisteredTool, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolPolicy, TurnToolSnapshot, WireFunctionTool } from './tools/types.js';
5
- import type { CallDone, CompactionFailure, CompactionResult, CompactionSignal, DoneFields, GroundingEvent, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, ProviderEvent, ProviderEvidence, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnTokenSide, TurnTokens } from './turn-events.js';
6
- export type { CacheMode, CacheTtl, CallDone, CompactionFailure, CompactionMeter, CompactionOutcome, CompactionResult, CompactionSignal, CompactionTiming, ContinueStopKind, DoneFields, FieldMeta, GroundingEvent, HostProfileToolsSpec, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvokeToolRequest, InvokeToolResume, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveProfileToolsSpec, LiveStartSensitivity, MediaInputKind, ProfileToolsSpec, ProfileType, ProfileTypeProtocol, Protocol, Provider, ProviderEvent, ProviderEvidence, RegisteredTool, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolLoadTier, ToolPolicy, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnStage, TurnStopKind, TurnTokenSide, TurnTokens, TurnToolSnapshot, WireFunctionTool, };
6
+ import type { PageToolExecution, ToolExecutionCoordinator } from './tools/operation.js';
7
+ import type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, HostProfileToolsSpec, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, LiveProfileToolsSpec, ModelToolResult, PageAnswer, ProfileToolsSpec, RegisteredTool, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolPolicy, TurnToolSnapshot, WireFunctionTool } from './tools/types.js';
8
+ import type { AttemptReason, CallDone, CompactionFailure, CompactionResult, CompactionSignal, DoneFields, GroundingEvent, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, ModelEvent, ProviderEvidence, RemovedItem, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnTokenSide, TurnTokens } from './turn-events.js';
9
+ export type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, AttemptReason, CacheMode, CacheTtl, CallDone, CompactionFailure, CompactionMeter, CompactionOutcome, CompactionResult, CompactionSignal, CompactionTiming, ContinueStopKind, DoneFields, FieldMeta, GroundingEvent, HostProfileToolsSpec, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveProfileToolsSpec, LiveStartSensitivity, MediaInputKind, ModelEvent, ProfileToolsSpec, ProfileType, ProviderEvidence, RegisteredTool, RemovedItem, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolLoadTier, ToolPolicy, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnStage, TurnStopKind, TurnTokenSide, TurnTokens, TurnToolSnapshot, WireFunctionTool, };
10
+ /** A host-chosen key naming one model binding in a profile's `models`. */
7
11
  export type ModelId = string;
12
+ /** The id of a provider-side tool such as web search. */
8
13
  export type BuiltinToolId = string;
14
+ /** The id a profile lists in `tools.allow` and the model calls a tool by. */
9
15
  export type ToolId = string;
16
+ /** The id of a registered structured-output schema. */
10
17
  export type StructuredSchemaId = string;
18
+ /** A structured-output schema resolved to its JSON Schema. */
11
19
  export interface ResolvedStructured {
12
20
  id: StructuredSchemaId;
13
21
  jsonSchema: Record<string, unknown>;
14
22
  }
23
+ /** A provider-side tool the turn uses, with the args the request addressed to it. */
15
24
  export interface ProviderBuiltin {
16
25
  id: BuiltinToolId;
17
- wire: BuiltinWire;
26
+ args?: JsonObject;
18
27
  }
28
+ /** Args a request hands to built-in tools, each checked by the schema its adapter declares. */
29
+ export type BuiltInArgs = Record<BuiltinToolId, JsonObject>;
30
+ /** The id a profile is registered and run under. */
19
31
  export type ProfileId = string;
32
+ /** The roles a history message can carry. */
20
33
  export type ChatRole = 'system' | 'user' | 'assistant';
21
34
  /** Host strings (presets own the vocabularies); an unpinned value is the provider default. */
22
35
  export interface ProfileImageSpec {
@@ -32,52 +45,10 @@ export interface ProfileImageSpec {
32
45
  /** Also request interleaved text with the images (Google: text + image `response_format`). */
33
46
  includeText?: boolean;
34
47
  }
35
- export interface ModelBinding {
36
- protocol: Protocol;
37
- provider: Provider;
38
- apiId: string;
39
- /** Alias → thinking level. One entry = fixed; two+ may be selectable at turn time. */
40
- efforts?: Record<string, ThinkingLevel>;
41
- /** Effort alias when the turn omits `effort`. Defaults to the only key when there is one. */
42
- defaultEffort?: string;
43
- /** Turn may pass `{ effort: "<alias>" }`. Requires two or more `efforts` keys. */
44
- allowEffortSelect?: boolean;
45
- /** Emit thinking summaries on the stream. Omit → provider default. */
46
- summaries?: boolean;
47
- /** Cap on output tokens. Omit → provider default. */
48
- maxOutputTokens?: number;
49
- /** Sampling temperature. Omit → provider default. */
50
- temperature?: number;
51
- builtInTools?: BuiltinToolId[];
52
- /** Overrides `profile.key` for this model. */
53
- key?: KeySlot;
54
- /** Overrides `profile.fallbackKey` for this model. */
55
- fallbackKey?: KeySlot;
56
- compaction?: CompactionSpec;
57
- /**
58
- * OpenRouter prompt-cache policy. Omit → no opt-in `cache_control`.
59
- * `defineProfile` accepts only when `provider` is `openrouter` (protocol `openAi`).
60
- */
61
- cache?: CacheSpec;
62
- /** Gemini Interactions: whether the provider stores the interaction. Omit → provider default. */
63
- store?: boolean;
64
- /**
65
- * Gemini Interactions: `true` chains each step and turn on Google's stored
66
- * interaction (`previous_interaction_id`), so Google builds the context;
67
- * `false` sends the history the host passes, plus this turn's steps, on every
68
- * call — across turns the host builds that history. Required on every
69
- * `geminiInteractions` binding; `true` needs `store` left on.
70
- */
71
- persistViaInteractionId?: boolean;
72
- /**
73
- * Local server that hosts the model (e.g. `ollama`, `vllm`, `llama.cpp`).
74
- * Traces report it as `gen_ai.provider.name`; omit → the attribute is absent.
75
- * `defineProfile` accepts only when `provider` is `local`.
76
- */
77
- server?: string;
78
- }
48
+ import type { DecisionModelBinding, ModelBinding } from './protocols/binding.js';
49
+ export type { DecisionModelBinding, ModelBinding };
79
50
  /**
80
- * OpenRouter prompt-cache policy (`models.*.cache`).
51
+ * OpenRouter prompt-cache policy (`models.*.options.cache`).
81
52
  *
82
53
  * - `automatic` — top-level `cache_control`; breakpoint advances with the conversation.
83
54
  * - `system` — explicit breakpoint on the system instruction only.
@@ -87,6 +58,7 @@ export interface CacheSpec {
87
58
  /** Ephemeral TTL. Omit → provider default (typically 5m on Anthropic). */
88
59
  ttl?: CacheTtl;
89
60
  }
61
+ /** What a compaction trigger sees when it decides whether to compact. */
90
62
  export interface CompactionTriggerContext {
91
63
  tokens: number;
92
64
  maxTokens: number;
@@ -95,6 +67,7 @@ export interface CompactionTriggerContext {
95
67
  /** Media parts not counted in `tokens` — no verified rule for this model. */
96
68
  unknownMedia: number;
97
69
  }
70
+ /** When history compacts and how: the meter, the token budget, and the compactor. */
98
71
  export interface CompactionSpec {
99
72
  /**
100
73
  * Token budget compared by the trigger (`compactAt * maxTokens`).
@@ -142,15 +115,18 @@ export interface CompactHistoryRequest {
142
115
  conversationId?: string;
143
116
  metadata?: Record<string, unknown>;
144
117
  }
118
+ /** A structured-output schema given inline. */
145
119
  export interface StructuredSpec {
146
120
  jsonSchema: Record<string, unknown>;
147
121
  }
122
+ /** Caps on the files a turn may attach. */
148
123
  export interface MediaLimits {
149
124
  maxFiles: number;
150
125
  maxBytes: number;
151
126
  maxTurnBytes: number;
152
127
  limitsByMime?: Record<string, number>;
153
128
  }
129
+ /** The input kinds a profile accepts, with their limits. */
154
130
  export interface MimeInputs extends Partial<MediaLimits> {
155
131
  text?: boolean;
156
132
  attachments?: {
@@ -160,16 +136,19 @@ export interface MimeInputs extends Partial<MediaLimits> {
160
136
  accept: string[];
161
137
  };
162
138
  }
163
- export type AttachmentValidationCode = 'mime_not_allowed' | 'too_many_files' | 'file_too_large' | 'turn_too_large' | 'attachments_not_accepted' | 'voice_not_accepted' | 'limits_unconfigured';
139
+ /** Why an attachment was refused. */
140
+ export type AttachmentValidationCode = 'mime_not_allowed' | 'too_many_files' | 'too_many_of_kind' | 'file_too_large' | 'turn_too_large' | 'attachments_not_accepted' | 'voice_not_accepted' | 'limits_unconfigured';
164
141
  /**
165
142
  * Structured parameters for rendering one validation issue. Validation emits
166
- * codes + params only; the wording is the lexicon's `attachments.*` lines.
143
+ * codes + params only; the wording is the labels' `attachments.*` lines.
167
144
  */
168
145
  export interface AttachmentValidationParams {
169
146
  maxFiles?: number;
170
147
  maxBytes?: number;
171
148
  maxTurnBytes?: number;
172
149
  mimeType?: string;
150
+ /** The kind of media a count is of, such as `PDF` or `image`. */
151
+ kind?: string;
173
152
  channel?: 'attachment' | 'voice';
174
153
  }
175
154
  /** One reason a turn's files were refused; `fileName` names the file when the problem is one file's. */
@@ -178,18 +157,45 @@ export interface AttachmentValidationIssue {
178
157
  params?: AttachmentValidationParams;
179
158
  fileName?: string;
180
159
  }
160
+ /** Picks the structured-output schema by the value of a turn slot, with a fallback. */
181
161
  export interface StructuredBySlot {
182
162
  by: string;
183
163
  map: Record<string, string>;
184
164
  fallback: string;
185
165
  }
166
+ /** What a host validator returns for a candidate output. */
186
167
  export interface ValidationResult {
187
168
  isValid: boolean;
188
169
  error?: string;
189
170
  finding?: string;
190
171
  data?: Record<string, unknown>;
191
172
  }
173
+ /** A host function that checks one structured-output field. */
192
174
  export type ProfileValidator = (candidate: unknown, slots?: Record<string, string>) => ValidationResult | Promise<ValidationResult>;
175
+ /** A tool call the turn completed, as an item check reads it. */
176
+ export interface TurnToolResult {
177
+ tool: string;
178
+ /** The output the call settled with, after any `post_tool` `mutate`. */
179
+ output: unknown;
180
+ }
181
+ /** What an item check reads of the turn whose reply it is checking. */
182
+ export interface ItemCheckTurn {
183
+ slots?: Record<string, string>;
184
+ /** Every tool call the turn completed, in order, across its attempts. */
185
+ toolResults: readonly TurnToolResult[];
186
+ }
187
+ /** A host function that checks one item of a list against what the turn's tools returned. */
188
+ export type ProfileItemCheck = (item: unknown, turn: ItemCheckTurn) => ValidationResult | Promise<ValidationResult>;
189
+ /**
190
+ * A host check on each item of one list in a structured reply. A refused item
191
+ * never fails the reply: `drop` removes it, and `fix` first asks the model to
192
+ * rewrite the refused items alone, then removes any that are refused again.
193
+ */
194
+ export interface ProfileItemRule {
195
+ check: ProfileItemCheck;
196
+ onFail: 'drop' | 'fix';
197
+ }
198
+ /** Host validators a profile runs on its structured output. */
193
199
  export interface ProfileValidationSpec {
194
200
  /**
195
201
  * Host domain validators keyed by dotted paths into structured output
@@ -197,14 +203,23 @@ export interface ProfileValidationSpec {
197
203
  * these run only for required paths and for optional paths that are present.
198
204
  */
199
205
  fields?: Record<string, ProfileValidator>;
206
+ /** Host checks on list items, keyed by the dotted path of a list in the structured output. */
207
+ items?: Record<string, ProfileItemRule>;
200
208
  maxRetries?: number;
201
209
  }
202
210
  /** `voice` is the TTS voice id, not ingress audio (`inputs.voice`). */
203
211
  export interface ProfileSpeechSpec {
204
212
  voice?: string;
205
- /** `mp3` requires `protocol: 'openAi'` speech; rejected on Interactions. */
213
+ /** How the script is delivered, in plain words: pace, mood, accent. Never read aloud. */
214
+ style?: string;
215
+ /** The speaking rate; 1 is the voice's own pace. */
216
+ speed?: number;
217
+ /** A provider that cannot make the format refuses the turn. */
206
218
  format?: SpeechAudioFormat;
207
219
  }
220
+ /** What one speech turn sets for itself; each field given replaces the profile's `speech` field of that name. */
221
+ export type TurnSpeech = Pick<ProfileSpeechSpec, 'voice' | 'style' | 'speed'>;
222
+ /** Voice activity detection settings for a live session. */
208
223
  export interface LiveVadSpec {
209
224
  activityHandling?: LiveActivityHandling;
210
225
  startSensitivity?: LiveStartSensitivity;
@@ -227,6 +242,7 @@ export interface LiveContextCompressionSpec {
227
242
  /** Drops the oldest turns; the system instruction stays. Gemini's only mechanism. */
228
243
  slidingWindow: LiveSlidingWindowSpec;
229
244
  }
245
+ /** Sliding-window context compression for a live session. */
230
246
  export interface LiveSlidingWindowSpec {
231
247
  /**
232
248
  * Tokens to keep after compressing. A whole number above 0, below
@@ -234,6 +250,7 @@ export interface LiveSlidingWindowSpec {
234
250
  */
235
251
  targetTokens?: number;
236
252
  }
253
+ /** Which sides of a live session are transcribed. */
237
254
  export interface LiveTranscriptionSpec {
238
255
  input?: boolean;
239
256
  output?: boolean;
@@ -251,40 +268,52 @@ export interface LiveIngressSpec {
251
268
  /** Typed text via `sendText`. Omit → disabled (opt-in). */
252
269
  text?: boolean;
253
270
  }
271
+ /** The prompt a resumed call opens with, and how long away earns it. */
272
+ export interface LiveResumedSpec {
273
+ prompt: string;
274
+ /** The shortest time away, in milliseconds, the agent remarks on. Omit → `DEFAULT_RESUMED_AFTER_MS`. */
275
+ afterMs?: number;
276
+ }
277
+ /** The settings only a live profile has: ingress, voice, detection, windowing, transcription, and resumption. */
254
278
  export interface ProfileLiveSpec {
255
279
  ingress?: LiveIngressSpec;
256
280
  voice?: string;
257
281
  vad?: LiveVadSpec;
258
282
  sessionResumption?: boolean;
283
+ /** A prompt the session sends itself when a call opens new, so the agent speaks first. Omit → the agent waits. */
284
+ greeting?: string;
285
+ /** What the agent is prompted with when a call resumes after the caller was away. Omit → a resumed call is silent. */
286
+ resumed?: LiveResumedSpec;
259
287
  /** Context window compression. Omit → none: the provider ends the session at its limit. */
260
288
  contextCompression?: LiveContextCompressionSpec;
261
289
  transcription?: LiveTranscriptionSpec;
262
290
  }
291
+ /** How a profile's reply streams. */
263
292
  export interface ProfileStreamingSpec {
264
293
  mode?: StreamMode;
265
294
  /** When false, filter `thought` events from the turn stream. */
266
295
  streamThoughts?: boolean;
267
296
  }
268
297
  export type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './stop.js';
269
- import type { LexiconOverrides } from '../guardrails/lexicon.js';
298
+ import type { LabelOverrides } from '../guardrails/labels.js';
270
299
  import type { ResolveHost } from '../guardrails/network.js';
271
300
  import type { DecisionGuardrailsSpec, HostGuardrailsSpec, ProfileGuardrailsSpec } from '../guardrails/types.js';
272
301
  import type { ProfileObservabilitySpec } from '../observability/types.js';
273
302
  import type { ToolCredentialSource } from './auth/credential-source.js';
274
303
  import type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, TurnContinueFrom } from './stop.js';
304
+ /** The model fields every model-running profile shares. */
275
305
  export interface ProfileModelFields {
306
+ providerContinuation?: ProviderContinuationPolicy;
276
307
  /** Host-named models. Each key is a selectable model id when `allowModelSelect` is set. */
277
308
  models: Record<ModelId, ModelBinding>;
278
309
  /** The model a turn runs when it names none; registration fills it with the only key when there is one. */
279
310
  defaultModel: ModelId;
280
- /** Turn may pass `{ model: "<id>" }`. Requires two or more `models` keys. */
311
+ /** Turn may pass `{ model: "<id>" }`; a name that is not a key of `models` is refused. */
281
312
  allowModelSelect?: boolean;
282
- /** Tool-loop ceiling. Omit or `<= 0` = unbounded; `1` = one-shot; `> 1` = hard cap. */
313
+ /** Tool-loop ceiling. Omit = `DEFAULT_MAX_STEPS`; `1` = one-shot; `> 1` = hard cap. */
283
314
  maxSteps?: number;
284
- key?: KeySlot;
285
- /** Retried once when `key` is refused for quota. Off unless set. */
286
- fallbackKey?: KeySlot;
287
315
  }
316
+ /** What a profile accepts as input. */
288
317
  export interface ProfileInputsSpec {
289
318
  text?: boolean;
290
319
  attachments?: {
@@ -298,7 +327,18 @@ export interface ProfileInputsSpec {
298
327
  maxTurnBytes?: number;
299
328
  limitsByMime?: Record<string, number>;
300
329
  slots?: Record<string, string[]>;
330
+ context?: ProfileContextSpec;
331
+ }
332
+ /** What a live profile declares beside its ingress channels. */
333
+ export type LiveInputsSpec = Pick<ProfileInputsSpec, 'slots' | 'context'>;
334
+ /** Who may send a turn its context, and how much. */
335
+ export interface ProfileContextSpec {
336
+ from: ContextSender[];
337
+ maxChars: number;
301
338
  }
339
+ /** The context each sender gives a turn: any JSON, or text. */
340
+ export type TurnContext = Partial<Record<ContextSender, unknown>>;
341
+ /** What a profile returns: its structured schema, validation, and streaming. */
302
342
  export interface ProfileOutputsSpec {
303
343
  structured?: StructuredSchemaId | StructuredBySlot | null;
304
344
  validation?: ProfileValidationSpec;
@@ -308,6 +348,7 @@ export interface ProfileOutputsSpec {
308
348
  export interface PrivateSystemPart {
309
349
  private: string;
310
350
  }
351
+ /** One part of a system prompt: plain text or a part kept out of traces. */
311
352
  export type SystemPart = string | PrivateSystemPart;
312
353
  /**
313
354
  * A system prompt: a string, or parts sent concatenated as written. A string,
@@ -320,36 +361,32 @@ export interface SystemPiece {
320
361
  text: string;
321
362
  private: boolean;
322
363
  }
364
+ /** A profile's handle and system prompt. */
323
365
  export interface ProfileIdentity {
324
366
  handle: string;
325
367
  system?: SystemPrompt;
326
368
  systemByRole?: Record<string, SystemPrompt>;
327
369
  }
370
+ /** The fields every profile type shares. */
328
371
  export interface ProfileCommon {
372
+ providerContinuation?: ProviderContinuationPolicy;
329
373
  id: ProfileId;
330
374
  identity: ProfileIdentity;
331
375
  models: Record<ModelId, ModelBinding>;
332
376
  defaultModel: ModelId;
333
377
  allowModelSelect?: boolean;
334
378
  maxSteps?: number;
335
- key?: KeySlot;
336
- /** Retried once when `key` is refused for quota. Off unless set. */
337
- fallbackKey?: KeySlot;
338
379
  outputs?: ProfileOutputsSpec;
339
380
  guardrails?: ProfileGuardrailsSpec;
340
381
  observability?: ProfileObservabilitySpec;
341
- /** This profile's wording: replaces any lexicon default, and any `overrideLexicon` entry, for this profile. */
342
- lexicon?: LexiconOverrides;
382
+ /** This profile's wording: replaces any label default, and any `overrideLabels` entry, for this profile. */
383
+ labels?: LabelOverrides;
343
384
  }
385
+ /** Any JSON value; the state a decision reads. */
344
386
  export type DecisionJson = null | string | number | boolean | DecisionJson[] | {
345
387
  [key: string]: DecisionJson;
346
388
  };
347
- /** A decision model binding follows the same protocol/provider/apiId spine as turn models. */
348
- export interface DecisionModelBinding extends Pick<ModelBinding, 'apiId' | 'key'> {
349
- protocol: 'decision';
350
- provider: 'typesafe' | 'openrouter';
351
- timeoutMs?: number;
352
- }
389
+ /** What a decision profile accepts: JSON state up to a byte cap. */
353
390
  export interface DecisionInputsSpec {
354
391
  state: 'json';
355
392
  maxStateBytes?: number;
@@ -367,40 +404,64 @@ export interface DecisionProfile {
367
404
  identity: Pick<ProfileIdentity, 'handle'>;
368
405
  /** Exactly one model: a decision profile runs one model and never selects. */
369
406
  models: Record<ModelId, DecisionModelBinding>;
370
- key?: KeySlot;
371
407
  inputs: DecisionInputsSpec;
372
408
  decision: {
373
409
  contract: DecisionContractId;
374
410
  };
375
411
  guardrails?: DecisionGuardrailsSpec;
376
412
  observability?: ProfileObservabilitySpec;
377
- /** This profile's wording: replaces any lexicon default, and any `overrideLexicon` entry, for this profile. */
378
- lexicon?: LexiconOverrides;
413
+ /** This profile's wording: replaces any label default, and any `overrideLabels` entry, for this profile. */
414
+ labels?: LabelOverrides;
379
415
  }
380
416
  /** Text or nested text instruction entries. Non-text leaves are rejected locally. */
381
417
  export type DecisionEntry = string | DecisionEntry[] | {
382
418
  [key: string]: DecisionEntry;
383
419
  };
420
+ /** A question answered by picking one of the named criteria. */
384
421
  export interface DecisionChoiceQuestion {
385
422
  type: 'choice';
386
423
  instructions: DecisionEntry;
387
424
  criteria: Record<string, DecisionEntry>;
388
425
  }
426
+ /** A question answered with a single number, optionally with named criteria. */
389
427
  export interface DecisionNoulQuestion {
390
428
  type: 'noul';
391
429
  instructions: DecisionEntry;
392
430
  criteria?: Record<string, DecisionEntry>;
393
431
  }
432
+ /** A question answered by scoring against an ordered list of criteria. */
394
433
  export interface DecisionScoreQuestion {
395
434
  type: 'score';
396
435
  instructions: DecisionEntry;
397
436
  criteria: readonly DecisionEntry[];
398
437
  }
399
- export type DecisionQuestion = DecisionChoiceQuestion | DecisionNoulQuestion | DecisionScoreQuestion;
438
+ /** A question answered with the one box that holds what the instructions name, in an image. */
439
+ export interface DecisionBoxQuestion {
440
+ type: 'box';
441
+ instructions: DecisionEntry;
442
+ /**
443
+ * The image the box is in: a reference in `assets`, such as `<ghs02>`, or the state field that
444
+ * holds one, such as `photo.front`. Unset, the model reads the image from the instructions.
445
+ */
446
+ image?: string;
447
+ }
448
+ /** One question a decision answers. */
449
+ export type DecisionQuestion = DecisionChoiceQuestion | DecisionNoulQuestion | DecisionScoreQuestion | DecisionBoxQuestion;
450
+ /** An image a decision reads: PNG or JPEG bytes as base64, with no `data:` prefix. */
451
+ export interface DecisionAsset {
452
+ mimeType: 'image/png' | 'image/jpeg';
453
+ data: string;
454
+ }
455
+ /** A request to `runDecision`: the profile, the state to judge, and the questions to answer. */
400
456
  export interface DecisionRequest {
401
457
  profile: ProfileId;
402
458
  state: Exclude<DecisionJson, null>;
403
459
  questions: Record<string, DecisionQuestion>;
460
+ /**
461
+ * Images by reference. Write a reference as a string where its image belongs, in `state`, in a
462
+ * question's instructions, or in its criteria; the provider puts the image there.
463
+ */
464
+ assets?: Record<string, DecisionAsset>;
404
465
  signal?: AbortSignal;
405
466
  /** Host-owned metadata preserved on the decision's trace record; the kernel does not interpret it. */
406
467
  metadata?: Record<string, unknown>;
@@ -411,6 +472,7 @@ export interface DecisionRequest {
411
472
  */
412
473
  traceparent?: string;
413
474
  }
475
+ /** The model's answer to one decision question. */
414
476
  export type DecisionAnswer = {
415
477
  type: 'choice';
416
478
  choice: string;
@@ -425,17 +487,99 @@ export type DecisionAnswer = {
425
487
  confidence: number;
426
488
  legend: Record<string, string>;
427
489
  probabilities: Record<string, number>;
490
+ }
491
+ /** Edges are fractions of the image, from its top-left corner. */
492
+ | {
493
+ type: 'box';
494
+ box: {
495
+ top: number;
496
+ bottom: number;
497
+ left: number;
498
+ right: number;
499
+ };
500
+ confidence: number;
428
501
  };
502
+ /** What `runDecision` returns: the model and an answer for each question. */
429
503
  export interface DecisionResult {
430
504
  model: string;
431
505
  answers: Record<string, DecisionAnswer>;
432
- /** Provider-reported tokens and cost, or a provider adapter's known model tariff. */
506
+ /** Provider-reported tokens and cost; a cost worked out from the provider's prices is `estimated`. */
433
507
  usage?: {
434
508
  inputTokens: number;
435
509
  outputTokens: number;
436
510
  costUsd?: number;
511
+ estimated?: true;
437
512
  };
438
513
  }
514
+ /** One provider-neutral input part for an embedding request. */
515
+ export type EmbeddingPart = {
516
+ type: 'text';
517
+ text: string;
518
+ } | {
519
+ type: 'media';
520
+ mimeType: string;
521
+ data: string;
522
+ } | {
523
+ type: 'media-ref';
524
+ mimeType: string;
525
+ uri: string;
526
+ };
527
+ /** One embedding input. Media-only inputs remain valid for native local models. */
528
+ export type EmbeddingInput = string | {
529
+ parts: readonly EmbeddingPart[];
530
+ };
531
+ /** A profile's accepted embedding input kinds and limits. */
532
+ export interface EmbeddingInputsSpec {
533
+ text?: boolean;
534
+ attachments?: {
535
+ accept: string[];
536
+ };
537
+ maxFiles?: number;
538
+ maxBytes?: number;
539
+ maxTurnBytes?: number;
540
+ limitsByMime?: Record<string, number>;
541
+ }
542
+ /** A profile that returns vectors instead of a model turn. */
543
+ export interface EmbeddingProfile extends Omit<ProfileCommon, 'identity' | 'outputs' | 'maxSteps'> {
544
+ type: 'embedding';
545
+ identity: Pick<ProfileIdentity, 'handle'>;
546
+ inputs: EmbeddingInputsSpec;
547
+ }
548
+ /**
549
+ * What the inputs are for in a search: `query` for what someone asks,
550
+ * `document` for what is searched. A model that embeds the two the same way
551
+ * ignores it.
552
+ */
553
+ export type EmbeddingTask = 'query' | 'document';
554
+ /** A request to `runEmbedding`. */
555
+ export interface EmbeddingRequest {
556
+ profile: ProfileId;
557
+ model?: ModelId;
558
+ input: EmbeddingInput | readonly EmbeddingInput[];
559
+ task?: EmbeddingTask;
560
+ signal?: AbortSignal;
561
+ metadata?: Record<string, unknown>;
562
+ traceparent?: string;
563
+ }
564
+ /** One vector returned for one ordered embedding input. */
565
+ export interface EmbeddingVector {
566
+ index: number;
567
+ values: readonly number[];
568
+ dimensions: number;
569
+ }
570
+ /** Provider usage for an embedding call. */
571
+ export interface EmbeddingUsage {
572
+ inputTokens?: number;
573
+ costUsd?: number;
574
+ estimated?: true;
575
+ }
576
+ /** The normalized result of `runEmbedding`. */
577
+ export interface EmbeddingResult {
578
+ model: string;
579
+ embeddings: readonly EmbeddingVector[];
580
+ usage?: EmbeddingUsage;
581
+ }
582
+ /** A profile that runs text turns. */
439
583
  export interface TextProfile extends ProfileCommon {
440
584
  type: 'text';
441
585
  tools: ProfileToolsSpec;
@@ -448,6 +592,7 @@ export interface TextProfile extends ProfileCommon {
448
592
  * `maxFiles` caps them.
449
593
  */
450
594
  export type ImageInputsSpec = Omit<ProfileInputsSpec, 'voice'>;
595
+ /** A profile that generates images. */
451
596
  export interface ImageProfile extends ProfileCommon {
452
597
  type: 'image';
453
598
  image: ProfileImageSpec;
@@ -456,35 +601,28 @@ export interface ImageProfile extends ProfileCommon {
456
601
  turnBehaviour?: MediaTurnBehaviourSpec;
457
602
  }
458
603
  /**
459
- * Speech guardrails: no canary. A speech turn has no system channel to bind a
460
- * token into (Gemini TTS rejects developer instructions) and yields audio, not
461
- * text a canary scan could read.
604
+ * Unary TTS — text-in locked by type; no tools / inputs block. The input text is the transcript;
605
+ * there is no system prompt, so no canary is planted and nothing of the profile's own can leak.
462
606
  */
463
- export type SpeechGuardrailsSpec = Omit<ProfileGuardrailsSpec, 'canary'> & {
464
- canary?: false;
465
- };
466
- /** Unary TTS — text-in locked by type; no tools / inputs block. The input text is the transcript; there is no system prompt. */
467
- export interface SpeechProfile extends Omit<ProfileCommon, 'identity' | 'guardrails'> {
607
+ export interface SpeechProfile extends Omit<ProfileCommon, 'identity'> {
468
608
  type: 'speech';
469
609
  identity: Pick<ProfileIdentity, 'handle'>;
470
- /** Registration always stores `canary: false`. */
471
- guardrails: SpeechGuardrailsSpec & {
472
- canary: false;
473
- };
474
610
  speech: ProfileSpeechSpec;
475
611
  turnBehaviour?: MediaTurnBehaviourSpec;
476
612
  }
613
+ /** A profile that holds a live audio session. */
477
614
  export interface LiveProfile extends Omit<ProfileCommon, 'outputs'> {
478
615
  type: 'live';
479
616
  live: ProfileLiveSpec;
617
+ inputs?: LiveInputsSpec;
480
618
  tools: LiveProfileToolsSpec;
481
619
  /** Stage inject gate only; live resumption is `live.sessionResumption`. */
482
620
  turnBehaviour?: Pick<ProfileTurnBehaviourSpec, 'allowSteering'>;
483
621
  }
484
622
  /**
485
623
  * Host-driven tool execution; never runs a model. `invokeTool` runs any tool in
486
- * `tools.allow` with no visibility, loading tiers or path gating. `guardrails` holds only
487
- * the guards that fire on `invokeTool`: quota, canary and egress guard a model turn, so
624
+ * `tools.allow` with no visibility, loading tiers, or path gating. `guardrails` holds only
625
+ * the guards that fire on `invokeTool`: quota, canary, and egress guard a model turn, so
488
626
  * `defineProfile` refuses them rather than accept inert config.
489
627
  */
490
628
  export interface HostProfile {
@@ -493,12 +631,14 @@ export interface HostProfile {
493
631
  tools: HostProfileToolsSpec;
494
632
  guardrails?: HostGuardrailsSpec;
495
633
  observability?: ProfileObservabilitySpec;
496
- /** This profile's wording: replaces any lexicon default, and any `overrideLexicon` entry, for this profile. */
497
- lexicon?: LexiconOverrides;
634
+ /** This profile's wording: replaces any label default, and any `overrideLabels` entry, for this profile. */
635
+ labels?: LabelOverrides;
498
636
  }
499
- export type Profile = TextProfile | ImageProfile | SpeechProfile | LiveProfile | DecisionProfile | HostProfile;
637
+ /** The contract that defines an agent’s capabilities and the rules for its interactions. Its type determines which settings it accepts. */
638
+ export type Profile = TextProfile | ImageProfile | SpeechProfile | LiveProfile | DecisionProfile | EmbeddingProfile | HostProfile;
500
639
  /** Profiles that run a model turn — every type except `host` and `decision` (which runs through `runDecision`). */
501
- export type ModelProfile = Exclude<Profile, HostProfile | DecisionProfile>;
640
+ export type ModelProfile = Exclude<Profile, HostProfile | DecisionProfile | EmbeddingProfile>;
641
+ /** The image a profile asks the model to return. */
502
642
  export interface ImageResponseFormat {
503
643
  type: 'image';
504
644
  mimeType?: string;
@@ -512,6 +652,7 @@ export interface ImageResponseFormat {
512
652
  outputCompression?: number;
513
653
  includeText: boolean;
514
654
  }
655
+ /** A file sent inline with a turn. */
515
656
  export interface TurnBlob {
516
657
  mimeType: string;
517
658
  data: string;
@@ -528,15 +669,19 @@ export interface TurnMediaRef {
528
669
  /** The file's name, used only to tell the user which file was refused; never sent to the model. */
529
670
  name?: string;
530
671
  }
672
+ /** A rejected output and the guidance to retry it with. */
531
673
  export interface TurnRepairRequest {
532
674
  previousOutput: string;
533
675
  rejection: string;
534
676
  guidance?: string;
535
677
  }
678
+ /** What the user sent for a turn: text, slots, attachments, voice, and history. */
536
679
  export interface TurnInput {
537
680
  text?: string;
538
681
  role?: string;
539
682
  slots?: Record<string, string>;
683
+ /** What the page or the host wants the model to know, by sender; the profile's `inputs.context` allows it. */
684
+ context?: TurnContext;
540
685
  attachments?: Array<TurnBlob | TurnMediaRef>;
541
686
  voice?: TurnBlob[];
542
687
  history?: TurnHistoryMessage[];
@@ -552,8 +697,8 @@ export interface TurnInput {
552
697
  * Ignored when `meter` is `'history'`.
553
698
  */
554
699
  inputTokens?: number;
555
- sessionResumptionHandle?: string;
556
700
  }
701
+ /** A turn request whose `input` is always present. */
557
702
  export type NormalizedTurnRequest = TurnRequest & {
558
703
  input: TurnInput;
559
704
  };
@@ -569,7 +714,11 @@ export interface TurnTraceLink {
569
714
  /** How the earlier turn stopped, when the host knows. */
570
715
  stop?: TurnStopKind;
571
716
  }
717
+ /** A request to `runTurn`: the profile, the input, and the host's hooks and keys. */
572
718
  export interface TurnRequest {
719
+ execution?: ToolExecutionCoordinator;
720
+ pageExecution?: PageToolExecution;
721
+ providerState?: ProviderCheckpoint;
573
722
  profile: ProfileId;
574
723
  projectId?: string;
575
724
  /**
@@ -577,25 +726,19 @@ export interface TurnRequest {
577
726
  * Not the same as `projectId` or Gemini `previousInteractionId`.
578
727
  */
579
728
  sessionId?: string;
580
- /** Google Interactions server-side conversation state. Omit for stateless/manual history. */
581
- previousInteractionId?: string;
582
- /**
583
- * Location bias for Interactions `google_maps` builtin.
584
- * Wired as `tools: [{ type: "google_maps", latitude, longitude }]`.
585
- * Ignored when `googleMaps` is not enabled for the selected model.
586
- */
587
- googleMapsLocation?: {
588
- latitude: number;
589
- longitude: number;
590
- };
591
- /** Optional Interactions storage override. Omit to let the selected model binding decide. */
592
- store?: boolean;
593
729
  /** Selected model id when `profile.allowModelSelect` is true. */
594
730
  model?: ModelId;
595
731
  /** Selected effort alias when the binding has `allowEffortSelect`. */
596
732
  effort?: string;
733
+ /**
734
+ * Args for built-in tools on the chosen model's `builtInTools`, by tool id.
735
+ * Each is parsed by the schema the provider's adapter declares for that tool.
736
+ */
737
+ builtInArgs?: BuiltInArgs;
597
738
  /** Host-provided dynamic system prompt combined with profile persona */
598
739
  system?: SystemPrompt;
740
+ /** This turn's voice, style, and speed, over `profile.speech`. Speech profiles only. */
741
+ speech?: TurnSpeech;
599
742
  sessionPermissions?: string[];
600
743
  /** Host channel/path for catalog `paths` filtering. */
601
744
  path?: string;
@@ -634,9 +777,6 @@ export interface TurnRequest {
634
777
  */
635
778
  continuation?: number;
636
779
  input?: TurnInput;
637
- /** Runs a `timing: 'before'` compactor the turn's provider cannot. */
638
- compactionProvider?: ModelProvider;
639
- sessionResumptionHandle?: string;
640
780
  /** Credentials for authenticated HTTP / MCP tools, read by auth slot when a tool needs one. */
641
781
  credentials?: ToolCredentialSource;
642
782
  /**
@@ -646,7 +786,14 @@ export interface TurnRequest {
646
786
  resolveHost?: ResolveHost;
647
787
  /** Text `runTurn` emits stages and applies the returned affordances. */
648
788
  onStage?: StageHandler;
789
+ /**
790
+ * Runs before each agent tool call in this turn, and in the turns those
791
+ * calls run. Shape the called agent's request (history, model, provider) or
792
+ * refuse the call. Omit it: the agent runs on what the model sent.
793
+ */
794
+ onAgentCall?: AgentCallHook;
649
795
  }
796
+ /** A profile projected for a client, with its secrets and server-only fields removed. */
650
797
  export interface ProjectedProfile extends ProfileModelFields {
651
798
  id: string;
652
799
  type: ModelProfile['type'];
@@ -661,11 +808,10 @@ export interface ProjectedProfile extends ProfileModelFields {
661
808
  speech?: ProfileSpeechSpec | null;
662
809
  live?: ProfileLiveSpec | null;
663
810
  }
811
+ /** The generation settings a provider call is made with. */
664
812
  export interface ProviderGenerationConfig {
665
813
  model: ModelId;
666
814
  apiId: string;
667
- previousInteractionId?: string;
668
- store?: boolean;
669
815
  /**
670
816
  * Upstream stream vs batch, derived from `outputs.streaming.mode`.
671
817
  * `true` = SSE (THEOREM default when mode is omitted); `false` = buffered.
@@ -676,35 +822,22 @@ export interface ProviderGenerationConfig {
676
822
  maxOutputTokens?: number;
677
823
  temperature?: number;
678
824
  builtins: BuiltinToolId[];
679
- googleMapsLocation?: {
680
- latitude: number;
681
- longitude: number;
682
- };
683
- /** OpenRouter only. */
684
- cache?: CacheSpec;
685
825
  /** Forwarded as OpenRouter `session_id`. */
686
826
  sessionId?: string;
687
827
  }
688
- export type ProviderTransport = 'interactions' | 'geminiLive' | 'openAiCompat';
828
+ /** The transport a provider adapter speaks. */
829
+ export type ProviderTransport = 'turn' | 'live';
830
+ /** A generation config after the profile and request are resolved, with its transport. */
689
831
  export interface ResolvedGeneration extends ProviderGenerationConfig {
832
+ /** The request's `builtInArgs`, parsed. */
833
+ builtInArgs?: BuiltInArgs;
834
+ execution?: ToolExecutionCoordinator;
835
+ pageExecution?: PageToolExecution;
690
836
  transport: ProviderTransport;
691
- /**
692
- * Whether the turn's steps chain on the stored interaction: a tool result or
693
- * stage inject rides `continuation` after `previousInteractionId`. Only an
694
- * Interactions binding chains, and never one with `persistViaInteractionId:
695
- * false` — its steps each send the host's history plus the turn's steps so far.
696
- */
697
- chains: boolean;
698
837
  tools: TurnToolSnapshot;
699
838
  sessionPermissions?: string[];
700
839
  history?: TurnHistoryMessage[];
701
- /**
702
- * Interactions-only: messages sent after `previousInteractionId` (tool
703
- * results, stage injects) instead of history + user parts. The model reads
704
- * the stored interaction plus these.
705
- */
706
- continuation?: TurnHistoryMessage[];
707
- /** Tool-loop ceiling. `undefined` or `<= 0` = unbounded. */
840
+ /** Tool-loop ceiling: the profile's `maxSteps`, or `DEFAULT_MAX_STEPS`. */
708
841
  maxSteps?: number;
709
842
  structured: ResolvedStructured | null;
710
843
  image: ImageResponseFormat | null;
@@ -712,64 +845,62 @@ export interface ResolvedGeneration extends ProviderGenerationConfig {
712
845
  live?: ProfileLiveSpec;
713
846
  input: InteractionPart[];
714
847
  /**
715
- * Vault key slot; every model but a local one without a key names one. Never sent on the wire.
848
+ * The canary bound into the system prompt; empty with the canary off. A turn
849
+ * binds the profile's (`profileCanary`), the same for the same prompt; a
850
+ * Live session binds this one, minted for it.
716
851
  */
717
- keySlot?: KeySlot;
718
- /** The slot a quota refusal on `keySlot` retries on once, when the profile names one. */
719
- fallbackKeySlot?: KeySlot;
720
852
  canary: string;
721
- sessionResumptionHandle?: string;
722
853
  /** Snapshotted synchronously before any async work; the runner binds the canary on top. */
723
854
  resolvedSystem: readonly SystemPiece[];
724
855
  /** `TurnRequest.host`, carried to tool contexts only. Never sent to providers or traces. */
725
856
  host?: unknown;
726
857
  }
727
- /**
728
- * `previousInteractionId`, `store`, `stream`, `summaries` and `continuation` are
729
- * Google Interactions-only and absent otherwise. `keySlot` is required for every
730
- * provider but local; it is never sent on the wire.
731
- */
732
- export interface ProviderCompleteRequest extends Omit<ProviderGenerationConfig, 'summaries' | 'builtins'> {
733
- /** The turn's builtins with their wire names; adapters read no registry. */
858
+ /** One model call as the engine asks it: the resolved generation, the conversation, and the tools. */
859
+ export interface ModelRequest extends Omit<ProviderGenerationConfig, 'summaries' | 'builtins'> {
860
+ /** The turn's builtins with the args addressed to each. */
734
861
  builtins: ProviderBuiltin[];
735
862
  summaries?: SummaryMode;
863
+ providerState?: ProviderCheckpoint;
736
864
  system: string;
737
865
  input: InteractionPart[];
738
866
  history?: TurnHistoryMessage[];
739
- /** Sent after `previousInteractionId` instead of history + user parts; mapped like history. */
740
- continuation?: TurnHistoryMessage[];
741
867
  wireTools?: WireFunctionTool[];
742
868
  structured: ResolvedStructured | null;
743
869
  image: ImageResponseFormat | null;
744
870
  speech?: ProfileSpeechSpec;
745
871
  live?: ProfileLiveSpec;
746
- sessionResumptionHandle?: string;
747
- keySlot?: KeySlot;
748
- /** The slot a quota refusal on `keySlot` retries on once. Never sent on the wire. */
749
- fallbackKeySlot?: KeySlot;
750
872
  /** Scrubbed SSE / HTTP rows for traces. */
751
873
  tapUpstream?: (row: Record<string, unknown>) => void;
752
- /** Host abort signal — adapters should pass this into fetch / SDK calls. */
874
+ /** Host abort signal. */
753
875
  signal?: AbortSignal;
754
876
  }
755
- export interface ModelProvider {
756
- complete: (req: ProviderCompleteRequest) => AsyncIterable<ProviderEvent>;
877
+ /** One model call, streamed as the model's events. */
878
+ export interface TurnModel {
879
+ complete: (req: ModelRequest) => AsyncIterable<ModelEvent>;
757
880
  }
758
881
  /**
759
882
  * Host request to open a long-lived live session (`runSession`).
760
883
  * Profile must be `type: 'live'`.
761
884
  */
762
885
  export interface SessionRequest {
886
+ providerState?: ProviderCheckpoint;
763
887
  profile: ProfileId;
764
888
  /** Host-built system prompt merged with profile identity.system. */
765
889
  system?: SystemPrompt;
766
890
  /** Override `profile.live.voice` for this session. */
767
891
  voice?: string;
892
+ /** As `TurnRequest.builtInArgs`. */
893
+ builtInArgs?: BuiltInArgs;
768
894
  path?: string;
769
895
  sessionPermissions?: string[];
770
896
  history?: TurnHistoryMessage[];
771
- sessionResumptionHandle?: string;
772
- /** Optional realtime parts sent immediately after setup. */
897
+ /** The value chosen for each of the profile's `inputs.slots`. */
898
+ slots?: Record<string, string>;
899
+ /** What the page and the host tell the agent as the call opens; `sendContext` replaces it later. */
900
+ context?: TurnContext;
901
+ /** How long the caller was away before this resume, in milliseconds. The session keeps no clock across calls. */
902
+ awayMs?: number;
903
+ /** Optional realtime parts sent immediately after setup. A call that sends them gets no `live.greeting`. */
773
904
  input?: InteractionPart[];
774
905
  /**
775
906
  * Registry-resolved tool snapshot from the process that owns the tool registry
@@ -793,6 +924,12 @@ export interface SessionRequest {
793
924
  links?: TurnTraceLink[];
794
925
  /** Immutable for the session; there is no `setOnStage`. */
795
926
  onStage?: StageHandler;
927
+ /**
928
+ * As `TurnRequest.onAgentCall`, for the agent tools this session's calls run.
929
+ * Omit it: each agent runs on what the model sent, with the session's own
930
+ * provider options.
931
+ */
932
+ onAgentCall?: AgentCallHook;
796
933
  /**
797
934
  * Default credentials for `executeTool` (per-call args override). Without one, the
798
935
  * session keeps keys typed at its sign-in gates in memory.
@@ -813,6 +950,7 @@ export interface SessionRequest {
813
950
  */
814
951
  export type LiveExecuteToolArgs = {
815
952
  callId: string;
953
+ operationId?: string;
816
954
  decision?: GateDecision;
817
955
  input?: unknown;
818
956
  /**
@@ -823,6 +961,8 @@ export type LiveExecuteToolArgs = {
823
961
  secret?: string;
824
962
  credentials?: ToolCredentialSource;
825
963
  host?: unknown;
964
+ /** The page's answer, for a call to a tool with `answeredBy: 'page'`. */
965
+ page?: PageAnswer;
826
966
  };
827
967
  /**
828
968
  * Settle a call the model made in this session whose body ran in the process
@@ -833,6 +973,7 @@ export type LiveAnswerToolCallArgs = {
833
973
  callId: string;
834
974
  events: readonly TurnEvent[];
835
975
  };
976
+ /** What running a tool call during a live session returns. */
836
977
  export type LiveExecuteToolResult = {
837
978
  outputRaw?: unknown;
838
979
  outputModel?: ModelToolResult;
@@ -841,7 +982,7 @@ export type LiveExecuteToolResult = {
841
982
  gated?: ToolGate;
842
983
  };
843
984
  /**
844
- * Open Gemini Live session returned by `runSession`. It streams events until
985
+ * Open live session returned by `runSession`. It streams events until
845
986
  * `close()` and exposes realtime media ingress and staged tool execution.
846
987
  */
847
988
  export interface LiveSession {
@@ -860,11 +1001,11 @@ export interface LiveSession {
860
1001
  }): Promise<void>;
861
1002
  sendText(text: string): Promise<void>;
862
1003
  /**
863
- * Text the model reads as background, not as the caller speaking: it opens no
864
- * turn and draws no reply. Same `ingress.text` gate and inbound guardrails as
865
- * `sendText`; the model sees it from its next turn on.
1004
+ * What the page or the host tells the model to know, by sender: it opens no turn and
1005
+ * draws no reply. Checked against `inputs.context` and read at the `context` boundary;
1006
+ * the model sees it from its next turn on.
866
1007
  */
867
- sendContext(text: string): Promise<void>;
1008
+ sendContext(context: TurnContext): Promise<void>;
868
1009
  /**
869
1010
  * Run a call the model made through the registry, with stages; its events
870
1011
  * join `events()`. A gate returns `gated` and answers the model nothing yet;