@jini-ai/agent-runtime 0.7.2 → 0.7.3-next.2

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 (405) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/README.md +1 -0
  3. package/dist/acp-model-probe.d.ts +2 -3
  4. package/dist/acp-model-probe.js +1 -1
  5. package/dist/agent-protocol/acp/account-failure.d.ts +3 -1
  6. package/dist/agent-protocol/acp/account-failure.js +1 -1
  7. package/dist/agent-protocol/acp/constants.d.ts +6 -1
  8. package/dist/agent-protocol/acp/constants.js +7 -0
  9. package/dist/agent-protocol/acp/index.d.ts +2 -1
  10. package/dist/agent-protocol/acp/index.js +2 -1
  11. package/dist/agent-protocol/acp/json.d.ts +26 -7
  12. package/dist/agent-protocol/acp/json.js +11 -11
  13. package/dist/agent-protocol/acp/models.d.ts +26 -6
  14. package/dist/agent-protocol/acp/models.js +161 -128
  15. package/dist/agent-protocol/acp/rpc.d.ts +37 -9
  16. package/dist/agent-protocol/acp/rpc.js +19 -16
  17. package/dist/agent-protocol/acp/session-params.d.ts +4 -1
  18. package/dist/agent-protocol/acp/session-params.js +1 -1
  19. package/dist/agent-protocol/acp/session-permission.d.ts +13 -0
  20. package/dist/agent-protocol/acp/session-permission.js +110 -0
  21. package/dist/agent-protocol/acp/session-results.d.ts +61 -0
  22. package/dist/agent-protocol/acp/session-results.js +231 -0
  23. package/dist/agent-protocol/acp/session-run.d.ts +92 -0
  24. package/dist/agent-protocol/acp/session-run.js +555 -0
  25. package/dist/agent-protocol/acp/session-state.d.ts +9 -0
  26. package/dist/agent-protocol/acp/session-state.js +29 -0
  27. package/dist/agent-protocol/acp/session-text-updates.d.ts +56 -0
  28. package/dist/agent-protocol/acp/session-text-updates.js +119 -0
  29. package/dist/agent-protocol/acp/session-tool-updates.d.ts +21 -0
  30. package/dist/agent-protocol/acp/session-tool-updates.js +90 -0
  31. package/dist/agent-protocol/acp/session-types.d.ts +166 -0
  32. package/dist/agent-protocol/acp/session-types.js +4 -0
  33. package/dist/agent-protocol/acp/session.d.ts +4 -280
  34. package/dist/agent-protocol/acp/session.js +65 -998
  35. package/dist/agent-protocol/acp/text-suppression.d.ts +5 -1
  36. package/dist/agent-protocol/acp/text-suppression.js +1 -1
  37. package/dist/agent-protocol/acp/updates.d.ts +43 -12
  38. package/dist/agent-protocol/acp/updates.js +34 -34
  39. package/dist/agent-protocol/core/json-line-stream.d.ts +133 -36
  40. package/dist/agent-protocol/core/json-line-stream.js +62 -62
  41. package/dist/agent-protocol/pi-rpc/events.d.ts +14 -4
  42. package/dist/agent-protocol/pi-rpc/events.js +14 -14
  43. package/dist/agent-protocol/pi-rpc/internal.d.ts +9 -3
  44. package/dist/agent-protocol/pi-rpc/internal.js +3 -3
  45. package/dist/agent-protocol/pi-rpc/models.d.ts +3 -17
  46. package/dist/agent-protocol/pi-rpc/models.js +1 -45
  47. package/dist/agent-protocol/pi-rpc/session.d.ts +36 -12
  48. package/dist/agent-protocol/pi-rpc/session.js +134 -122
  49. package/dist/amr-model-cache.d.ts +1 -1
  50. package/dist/anthropic-live-models.d.ts +8 -3
  51. package/dist/anthropic-live-models.js +0 -0
  52. package/dist/auth-common.d.ts +2 -0
  53. package/dist/auth-common.js +2 -0
  54. package/dist/auth.d.ts +7 -34
  55. package/dist/auth.js +25 -139
  56. package/dist/capabilities.d.ts +1 -1
  57. package/dist/claude-code-models.d.ts +13 -5
  58. package/dist/claude-code-models.js +12 -10
  59. package/dist/claude-filesystem-policy.d.ts +1 -1
  60. package/dist/claude-stream-frames.d.ts +125 -0
  61. package/dist/claude-stream-frames.js +327 -0
  62. package/dist/claude-stream-handler.d.ts +19 -0
  63. package/dist/claude-stream-handler.js +480 -0
  64. package/dist/claude-stream.d.ts +3 -72
  65. package/dist/claude-stream.js +2 -801
  66. package/dist/core/model-discovery-shared.d.ts +14 -8
  67. package/dist/core/model-discovery-shared.js +6 -9
  68. package/dist/core/omit-keys.d.ts +4 -1
  69. package/dist/core/omit-keys.js +1 -1
  70. package/dist/defs/aider/executable.d.ts +2 -0
  71. package/dist/defs/aider/executable.js +2 -0
  72. package/dist/defs/aider/model-discovery.d.ts +3 -0
  73. package/dist/defs/aider/model-discovery.js +6 -0
  74. package/dist/defs/aider.d.ts +10 -10
  75. package/dist/defs/amp/index.d.ts +35 -0
  76. package/dist/defs/amp/index.js +75 -0
  77. package/dist/defs/amp.d.ts +1 -34
  78. package/dist/defs/amp.js +1 -74
  79. package/dist/defs/amr/executable-resolution.d.ts +7 -0
  80. package/dist/defs/amr/executable-resolution.js +50 -0
  81. package/dist/defs/amr/executable.d.ts +2 -0
  82. package/dist/defs/amr/executable.js +2 -0
  83. package/dist/defs/amr/index.d.ts +69 -0
  84. package/dist/defs/amr/index.js +279 -0
  85. package/dist/defs/amr/model-discovery.d.ts +3 -0
  86. package/dist/defs/amr/model-discovery.js +4 -0
  87. package/dist/defs/amr.d.ts +1 -68
  88. package/dist/defs/amr.js +1 -291
  89. package/dist/defs/antigravity/auth.d.ts +14 -0
  90. package/dist/defs/antigravity/auth.js +47 -0
  91. package/dist/defs/antigravity/index.d.ts +9 -9
  92. package/dist/defs/antigravity/index.js +3 -3
  93. package/dist/defs/antigravity/model-discovery.d.ts +3 -0
  94. package/dist/defs/antigravity/model-discovery.js +5 -0
  95. package/dist/defs/auggie/executable.d.ts +2 -0
  96. package/dist/defs/auggie/executable.js +2 -0
  97. package/dist/defs/auggie.d.ts +13 -13
  98. package/dist/defs/auggie.js +2 -9
  99. package/dist/defs/claude/auth.d.ts +15 -0
  100. package/dist/defs/claude/auth.js +47 -0
  101. package/dist/defs/claude/executable.d.ts +2 -0
  102. package/dist/defs/claude/executable.js +2 -0
  103. package/dist/defs/claude/model-discovery.d.ts +3 -0
  104. package/dist/defs/claude/model-discovery.js +20 -0
  105. package/dist/defs/claude-compatible-args.d.ts +10 -6
  106. package/dist/defs/claude-compatible-args.js +5 -5
  107. package/dist/defs/claude.d.ts +11 -11
  108. package/dist/defs/claude.js +5 -4
  109. package/dist/defs/cline/executable.d.ts +2 -0
  110. package/dist/defs/cline/executable.js +2 -0
  111. package/dist/defs/cline.d.ts +13 -13
  112. package/dist/defs/cline.js +2 -9
  113. package/dist/defs/codebuddy/executable.d.ts +2 -0
  114. package/dist/defs/codebuddy/executable.js +2 -0
  115. package/dist/defs/codebuddy/index.d.ts +48 -0
  116. package/dist/defs/codebuddy/index.js +121 -0
  117. package/dist/defs/codebuddy/model-discovery.d.ts +3 -0
  118. package/dist/defs/codebuddy/model-discovery.js +5 -0
  119. package/dist/defs/codebuddy.d.ts +1 -47
  120. package/dist/defs/codebuddy.js +1 -120
  121. package/dist/defs/codex/auth.d.ts +4 -0
  122. package/dist/defs/codex/auth.js +2 -0
  123. package/dist/defs/codex/event-stream.d.ts +10 -0
  124. package/dist/defs/codex/event-stream.js +353 -0
  125. package/dist/defs/codex/executable-resolution.d.ts +7 -0
  126. package/dist/defs/codex/executable-resolution.js +37 -0
  127. package/dist/defs/codex/executable.d.ts +2 -0
  128. package/dist/defs/codex/executable.js +2 -0
  129. package/dist/defs/codex/launch.d.ts +3 -0
  130. package/dist/defs/codex/launch.js +155 -0
  131. package/dist/defs/codex/model-discovery.d.ts +3 -0
  132. package/dist/defs/codex/model-discovery.js +11 -0
  133. package/dist/defs/codex/options.d.ts +11 -0
  134. package/dist/defs/codex/options.js +5 -0
  135. package/dist/defs/codex.d.ts +18 -11
  136. package/dist/defs/codex.js +32 -29
  137. package/dist/defs/crush/executable.d.ts +2 -0
  138. package/dist/defs/crush/executable.js +2 -0
  139. package/dist/defs/crush/model-discovery.d.ts +3 -0
  140. package/dist/defs/crush/model-discovery.js +6 -0
  141. package/dist/defs/crush.d.ts +10 -10
  142. package/dist/defs/cursor-agent/auth.d.ts +13 -0
  143. package/dist/defs/cursor-agent/auth.js +22 -0
  144. package/dist/defs/cursor-agent/event-stream.d.ts +8 -0
  145. package/dist/defs/cursor-agent/event-stream.js +104 -0
  146. package/dist/defs/cursor-agent/executable.d.ts +2 -0
  147. package/dist/defs/cursor-agent/executable.js +2 -0
  148. package/dist/defs/cursor-agent/model-discovery.d.ts +3 -0
  149. package/dist/defs/cursor-agent/model-discovery.js +5 -0
  150. package/dist/defs/cursor-agent.d.ts +11 -13
  151. package/dist/defs/cursor-agent.js +1 -1
  152. package/dist/defs/deepseek/auth.d.ts +13 -0
  153. package/dist/defs/deepseek/auth.js +18 -0
  154. package/dist/defs/deepseek/executable.d.ts +2 -0
  155. package/dist/defs/deepseek/executable.js +2 -0
  156. package/dist/defs/deepseek/model-discovery.d.ts +3 -0
  157. package/dist/defs/deepseek/model-discovery.js +5 -0
  158. package/dist/defs/deepseek.d.ts +10 -10
  159. package/dist/defs/devin/executable.d.ts +2 -0
  160. package/dist/defs/devin/executable.js +2 -0
  161. package/dist/defs/devin.d.ts +15 -15
  162. package/dist/defs/devin.js +3 -10
  163. package/dist/defs/droid/executable.d.ts +2 -0
  164. package/dist/defs/droid/executable.js +2 -0
  165. package/dist/defs/droid/model-discovery.d.ts +3 -0
  166. package/dist/defs/droid/model-discovery.js +5 -0
  167. package/dist/defs/droid.d.ts +10 -10
  168. package/dist/defs/gemini/event-stream.d.ts +14 -0
  169. package/dist/defs/gemini/event-stream.js +193 -0
  170. package/dist/defs/goose/executable.d.ts +2 -0
  171. package/dist/defs/goose/executable.js +2 -0
  172. package/dist/defs/goose.d.ts +13 -13
  173. package/dist/defs/goose.js +2 -9
  174. package/dist/defs/grok-build/model-discovery.d.ts +3 -0
  175. package/dist/defs/grok-build/model-discovery.js +5 -0
  176. package/dist/defs/grok-build.d.ts +10 -10
  177. package/dist/defs/hermes/executable.d.ts +2 -0
  178. package/dist/defs/hermes/executable.js +2 -0
  179. package/dist/defs/hermes/index.d.ts +34 -0
  180. package/dist/defs/hermes/index.js +57 -0
  181. package/dist/defs/hermes.d.ts +1 -33
  182. package/dist/defs/hermes.js +1 -56
  183. package/dist/defs/index.d.ts +1 -0
  184. package/dist/defs/index.js +1 -0
  185. package/dist/defs/kilo/executable.d.ts +2 -0
  186. package/dist/defs/kilo/executable.js +2 -0
  187. package/dist/defs/kilo.d.ts +13 -13
  188. package/dist/defs/kilo.js +2 -9
  189. package/dist/defs/kimi/event-stream.d.ts +3 -0
  190. package/dist/defs/kimi/event-stream.js +46 -0
  191. package/dist/defs/kimi/executable.d.ts +2 -0
  192. package/dist/defs/kimi/executable.js +2 -0
  193. package/dist/defs/kimi.d.ts +13 -13
  194. package/dist/defs/kimi.js +2 -9
  195. package/dist/defs/kiro/executable.d.ts +2 -0
  196. package/dist/defs/kiro/executable.js +2 -0
  197. package/dist/defs/kiro.d.ts +13 -13
  198. package/dist/defs/kiro.js +2 -9
  199. package/dist/defs/mimo/executable.d.ts +2 -0
  200. package/dist/defs/mimo/executable.js +2 -0
  201. package/dist/defs/mimo/model-discovery.d.ts +3 -0
  202. package/dist/defs/mimo/model-discovery.js +7 -0
  203. package/dist/defs/mimo.d.ts +10 -10
  204. package/dist/defs/opencode/event-stream.d.ts +8 -0
  205. package/dist/defs/opencode/event-stream.js +108 -0
  206. package/dist/defs/opencode/executable.d.ts +2 -0
  207. package/dist/defs/opencode/executable.js +2 -0
  208. package/dist/defs/opencode/model-discovery.d.ts +4 -0
  209. package/dist/defs/opencode/model-discovery.js +14 -0
  210. package/dist/defs/opencode-acp.d.ts +42 -0
  211. package/dist/defs/opencode-acp.js +23 -0
  212. package/dist/defs/opencode.d.ts +9 -9
  213. package/dist/defs/pi/executable.d.ts +2 -0
  214. package/dist/defs/pi/executable.js +2 -0
  215. package/dist/defs/pi/model-discovery.d.ts +4 -0
  216. package/dist/defs/pi/model-discovery.js +16 -0
  217. package/dist/defs/pi/options.d.ts +11 -0
  218. package/dist/defs/pi/options.js +5 -0
  219. package/dist/defs/pi.d.ts +10 -10
  220. package/dist/defs/qoder/executable.d.ts +2 -0
  221. package/dist/defs/qoder/executable.js +2 -0
  222. package/dist/defs/qoder/model-discovery.d.ts +3 -0
  223. package/dist/defs/qoder/model-discovery.js +7 -0
  224. package/dist/defs/qoder.d.ts +9 -9
  225. package/dist/defs/qwen/executable.d.ts +2 -0
  226. package/dist/defs/qwen/executable.js +2 -0
  227. package/dist/defs/qwen/model-discovery.d.ts +3 -0
  228. package/dist/defs/qwen/model-discovery.js +7 -0
  229. package/dist/defs/qwen.d.ts +10 -10
  230. package/dist/defs/reasonix/auth.d.ts +13 -0
  231. package/dist/defs/reasonix/auth.js +18 -0
  232. package/dist/defs/reasonix/executable.d.ts +2 -0
  233. package/dist/defs/reasonix/executable.js +2 -0
  234. package/dist/defs/reasonix.d.ts +13 -13
  235. package/dist/defs/reasonix.js +2 -9
  236. package/dist/defs/shared.d.ts +10 -2
  237. package/dist/defs/shared.js +5 -1
  238. package/dist/defs/trae-cli/executable.d.ts +2 -0
  239. package/dist/defs/trae-cli/executable.js +2 -0
  240. package/dist/defs/trae-cli.d.ts +15 -15
  241. package/dist/defs/trae-cli.js +2 -9
  242. package/dist/defs/vibe/executable.d.ts +2 -0
  243. package/dist/defs/vibe/executable.js +2 -0
  244. package/dist/defs/vibe.d.ts +13 -13
  245. package/dist/defs/vibe.js +2 -9
  246. package/dist/detection.d.ts +4 -3
  247. package/dist/detection.js +22 -22
  248. package/dist/diagnostics.d.ts +4 -4
  249. package/dist/diagnostics.js +2 -2
  250. package/dist/env.js +2 -1
  251. package/dist/executable-helpers.d.ts +21 -0
  252. package/dist/executable-helpers.js +2 -0
  253. package/dist/executables.d.ts +2 -2
  254. package/dist/executables.js +68 -114
  255. package/dist/index.d.ts +6 -2
  256. package/dist/index.js +5 -1
  257. package/dist/invocation.d.ts +22 -6
  258. package/dist/invocation.js +19 -17
  259. package/dist/json-event-stream-shared.d.ts +81 -0
  260. package/dist/json-event-stream-shared.js +147 -0
  261. package/dist/json-event-stream.d.ts +2 -4
  262. package/dist/json-event-stream.js +15 -940
  263. package/dist/launch.d.ts +1 -9
  264. package/dist/launch.js +6 -155
  265. package/dist/log-file.d.ts +2 -8
  266. package/dist/log-file.js +1 -1
  267. package/dist/mcp.d.ts +2 -2
  268. package/dist/mcp.js +1 -1
  269. package/dist/mmd-routes.d.ts +7 -7
  270. package/dist/mmd-routes.js +19 -27
  271. package/dist/model-discovery-adapters.d.ts +47 -11
  272. package/dist/model-discovery-adapters.js +47 -41
  273. package/dist/model-discovery-config-types.d.ts +44 -0
  274. package/dist/model-discovery-config-types.js +20 -0
  275. package/dist/model-discovery-config.d.ts +19 -11
  276. package/dist/model-discovery-config.js +64 -87
  277. package/dist/model-discovery-native.d.ts +2 -1
  278. package/dist/model-discovery-native.js +3 -3
  279. package/dist/model-discovery-sdk.d.ts +6 -2
  280. package/dist/model-discovery-sdk.js +2 -2
  281. package/dist/model-discovery-types.d.ts +1 -138
  282. package/dist/model-discovery-yaml.d.ts +3 -1
  283. package/dist/model-discovery-yaml.js +1 -1
  284. package/dist/model-discovery.d.ts +15 -5
  285. package/dist/model-discovery.js +119 -105
  286. package/dist/model-loading-state.d.ts +1 -1
  287. package/dist/model-loading-state.js +1 -1
  288. package/dist/model-registry.d.ts +5 -5
  289. package/dist/model-registry.js +7 -6
  290. package/dist/models.d.ts +4 -3
  291. package/dist/models.js +2 -2
  292. package/dist/native-permissions.d.ts +47 -0
  293. package/dist/native-permissions.js +80 -0
  294. package/dist/native-runtime.d.ts +11 -8
  295. package/dist/native-runtime.js +8 -4
  296. package/dist/native-tool-policy.d.ts +1 -40
  297. package/dist/opencode-log.d.ts +3 -3
  298. package/dist/opencode-log.js +5 -3
  299. package/dist/paths.d.ts +1 -1
  300. package/dist/paths.js +1 -1
  301. package/dist/pi-models.d.ts +12 -2
  302. package/dist/pi-models.js +11 -1
  303. package/dist/prompt-augmenter.d.ts +1 -37
  304. package/dist/prompt-augmenter.js +0 -6
  305. package/dist/prompt-budget.d.ts +3 -3
  306. package/dist/prompt-budget.js +2 -2
  307. package/dist/prompt-file.d.ts +2 -6
  308. package/dist/prompt-file.js +1 -1
  309. package/dist/providers/aihubmix.d.ts +8 -8
  310. package/dist/providers/aihubmix.js +8 -8
  311. package/dist/providers/anthropic-messages.d.ts +22 -23
  312. package/dist/providers/anthropic-messages.js +26 -53
  313. package/dist/providers/azure-chat.d.ts +7 -6
  314. package/dist/providers/azure-chat.js +9 -6
  315. package/dist/providers/connection-guard.d.ts +3 -9
  316. package/dist/providers/connection-guard.js +6 -14
  317. package/dist/providers/connection-test.d.ts +1 -2
  318. package/dist/providers/connection-test.js +51 -51
  319. package/dist/providers/credentials.d.ts +59 -0
  320. package/dist/providers/credentials.js +80 -0
  321. package/dist/providers/elevenlabs.d.ts +2 -6
  322. package/dist/providers/elevenlabs.js +2 -31
  323. package/dist/providers/google-messages.d.ts +11 -10
  324. package/dist/providers/google-messages.js +16 -35
  325. package/dist/providers/google-schema.d.ts +1 -1
  326. package/dist/providers/google-schema.js +1 -1
  327. package/dist/providers/google.d.ts +6 -6
  328. package/dist/providers/google.js +6 -6
  329. package/dist/providers/index.d.ts +5 -2
  330. package/dist/providers/index.js +5 -2
  331. package/dist/providers/model-catalog.d.ts +4 -9
  332. package/dist/providers/model-catalog.js +3 -11
  333. package/dist/providers/oauth-callback-server.js +93 -87
  334. package/dist/providers/oauth-provider.d.ts +1 -1
  335. package/dist/providers/oauth-provider.js +1 -1
  336. package/dist/providers/oauth-tokens.d.ts +5 -5
  337. package/dist/providers/oauth-tokens.js +8 -9
  338. package/dist/providers/ollama-chat.d.ts +13 -12
  339. package/dist/providers/ollama-chat.js +15 -24
  340. package/dist/providers/openai-chat-request.d.ts +34 -0
  341. package/dist/providers/openai-chat-request.js +152 -0
  342. package/dist/providers/openai-chat-stream.d.ts +48 -0
  343. package/dist/providers/openai-chat-stream.js +89 -0
  344. package/dist/providers/openai-chat-tool-results.d.ts +81 -0
  345. package/dist/providers/openai-chat-tool-results.js +124 -0
  346. package/dist/providers/openai-chat-types.d.ts +180 -0
  347. package/dist/providers/openai-chat-types.js +3 -0
  348. package/dist/providers/openai-chat.d.ts +5 -405
  349. package/dist/providers/openai-chat.js +9 -388
  350. package/dist/providers/pkce.d.ts +1 -1
  351. package/dist/providers/pkce.js +1 -1
  352. package/dist/providers/provider-url.d.ts +6 -0
  353. package/dist/providers/provider-url.js +9 -0
  354. package/dist/providers/response-text.d.ts +4 -0
  355. package/dist/providers/response-text.js +16 -0
  356. package/dist/providers/sse-decode.d.ts +4 -0
  357. package/dist/providers/sse-decode.js +11 -0
  358. package/dist/providers/token-params.d.ts +5 -5
  359. package/dist/providers/token-params.js +5 -5
  360. package/dist/providers/tool-loop-verdict.d.ts +1 -1
  361. package/dist/providers/tool-loop-verdict.js +1 -1
  362. package/dist/providers/tool-turn-types.d.ts +2 -1
  363. package/dist/providers/tool-turn.js +30 -50
  364. package/dist/providers/turn-end-guard.d.ts +4 -1
  365. package/dist/providers/turn-end-guard.js +1 -1
  366. package/dist/qoder-stream.d.ts +1 -1
  367. package/dist/qoder-stream.js +1 -1
  368. package/dist/registry.d.ts +5 -5
  369. package/dist/registry.js +4 -4
  370. package/dist/role-marker-guard.d.ts +13 -1
  371. package/dist/role-marker-guard.js +15 -1
  372. package/dist/runtime-def-binding.d.ts +15 -0
  373. package/dist/runtime-def-binding.js +19 -0
  374. package/dist/runtime-port-bindings.d.ts +181 -0
  375. package/dist/runtime-port-bindings.js +95 -0
  376. package/dist/runtime-state.d.ts +2 -11
  377. package/dist/runtime-state.js +0 -13
  378. package/dist/types.d.ts +1 -454
  379. package/package.json +28 -16
  380. package/dist/ai-trace/capture.d.ts +0 -17
  381. package/dist/ai-trace/capture.js +0 -43
  382. package/dist/ai-trace/classify.d.ts +0 -12
  383. package/dist/ai-trace/classify.js +0 -16
  384. package/dist/ai-trace/index.d.ts +0 -13
  385. package/dist/ai-trace/index.js +0 -6
  386. package/dist/ai-trace/recorder.d.ts +0 -64
  387. package/dist/ai-trace/recorder.js +0 -258
  388. package/dist/ai-trace/sinks.d.ts +0 -51
  389. package/dist/ai-trace/sinks.js +0 -153
  390. package/dist/ai-trace/types.d.ts +0 -123
  391. package/dist/ai-trace/types.js +0 -17
  392. package/dist/ai-trace/usage.d.ts +0 -13
  393. package/dist/ai-trace/usage.js +0 -45
  394. package/dist/copilot-stream.d.ts +0 -65
  395. package/dist/copilot-stream.js +0 -131
  396. package/dist/defs/antigravity.d.ts +0 -94
  397. package/dist/defs/antigravity.js +0 -320
  398. package/dist/defs/copilot.d.ts +0 -34
  399. package/dist/defs/copilot.js +0 -96
  400. package/dist/defs/gemini.d.ts +0 -24
  401. package/dist/defs/gemini.js +0 -81
  402. package/dist/model-contracts.d.ts +0 -29
  403. package/dist/model-contracts.js +0 -2
  404. package/dist/providers/types.d.ts +0 -36
  405. package/dist/providers/types.js +0 -13
@@ -36,7 +36,7 @@ export const AIHUBMIX_DEFAULT_BASE_URL = 'https://aihubmix.com/v1';
36
36
  * fixed `APP-Code` attribution header. Callers spread the result into their
37
37
  * `fetch` headers and may add `content-type` etc. on top.
38
38
  */
39
- export function aihubmixHeaders({ apiKey }) {
39
+ export function aihubmixHeaders({ apiKey }, _optional = {}) {
40
40
  return {
41
41
  authorization: `Bearer ${apiKey}`,
42
42
  ...aihubmixAppCodeHeader(),
@@ -55,7 +55,7 @@ export function aihubmixHeaders({ apiKey }) {
55
55
  export function aihubmixAppCodeHeader() {
56
56
  return { 'APP-Code': AIHUBMIX_APP_CODE };
57
57
  }
58
- export function classifyAIHubMixModel({ model }) {
58
+ export function classifyAIHubMixModel({ model }, _optional = {}) {
59
59
  const m = (model || '').trim().toLowerCase();
60
60
  // Gemini: gemini*/imagen*, excluding the `-nothink`/`-search` suffixes and
61
61
  // any embedding model (those stay on the OpenAI-compatible path per §4.1).
@@ -75,7 +75,7 @@ export function classifyAIHubMixModel({ model }) {
75
75
  * anthropic -> `${origin}` (+ /v1/messages)
76
76
  * gemini -> `${origin}/gemini` (+ /v1beta/models/{model}:...)
77
77
  */
78
- export function aihubmixOriginFromBase({ baseUrl }) {
78
+ export function aihubmixOriginFromBase({ baseUrl }, _optional = {}) {
79
79
  try {
80
80
  return new URL(baseUrl || AIHUBMIX_DEFAULT_BASE_URL).origin;
81
81
  }
@@ -84,7 +84,7 @@ export function aihubmixOriginFromBase({ baseUrl }) {
84
84
  }
85
85
  }
86
86
  /** Gemini-native generateContent endpoint for an AIHubMix image model. */
87
- export function aihubmixGeminiImageUrl({ baseUrl, wireModel }) {
87
+ export function aihubmixGeminiImageUrl({ baseUrl, wireModel }, _optional = {}) {
88
88
  return (`${aihubmixOriginFromBase({ baseUrl: baseUrl })}/gemini/v1beta/models/`
89
89
  + `${encodeURIComponent(wireModel)}:generateContent`);
90
90
  }
@@ -100,7 +100,7 @@ export function aihubmixGeminiImageUrl({ baseUrl, wireModel }) {
100
100
  * dispatcher, abort signal, redirect policy). Throws on a non-OK status or a
101
101
  * response without inline image data.
102
102
  */
103
- export async function aihubmixGeminiImageBytes({ req, doFetch }) {
103
+ export async function aihubmixGeminiImageBytes({ req, doFetch }, _optional = {}) {
104
104
  const url = aihubmixGeminiImageUrl({ baseUrl: req.baseUrl, wireModel: req.wireModel });
105
105
  const resp = await doFetch({ url: url, init: {
106
106
  method: 'POST',
@@ -143,7 +143,7 @@ const AIHUBMIX_WIRE_MODELS = {
143
143
  'aihubmix-dall-e-3': 'dall-e-3',
144
144
  'aihubmix-tts-1': 'tts-1',
145
145
  };
146
- export function aihubmixWireModel({ catalogId }) {
146
+ export function aihubmixWireModel({ catalogId }, _optional = {}) {
147
147
  return AIHUBMIX_WIRE_MODELS[catalogId] ?? catalogId.replace(/^aihubmix-/, '');
148
148
  }
149
149
  // AIHubMix's unified /videos API uses a single `seconds` (string) field for
@@ -161,7 +161,7 @@ const AIHUBMIX_VIDEO_SECONDS = [
161
161
  ['sora', [4, 8, 12]],
162
162
  ['wan', [5, 10]],
163
163
  ];
164
- export function aihubmixVideoSeconds({ wireModel, requested }) {
164
+ export function aihubmixVideoSeconds({ wireModel, requested }, _optional = {}) {
165
165
  const m = (wireModel || '').toLowerCase();
166
166
  const req = Number.isFinite(requested) ? requested : 5;
167
167
  const allowed = AIHUBMIX_VIDEO_SECONDS.find(([prefix]) => m.startsWith(prefix))?.[1] ?? null;
@@ -173,7 +173,7 @@ export function aihubmixVideoSeconds({ wireModel, requested }) {
173
173
  const snapped = allowed.reduce((best, v) => (Math.abs(v - req) < Math.abs(best - req) ? v : best), allowed[0]);
174
174
  return String(snapped);
175
175
  }
176
- export function aihubmixCatalogUrl({ baseUrl, type }) {
176
+ export function aihubmixCatalogUrl({ baseUrl, type }, _optional = {}) {
177
177
  const origin = aihubmixOriginFromBase({ baseUrl });
178
178
  return `${origin}/api/v1/models?type=${type}`;
179
179
  }
@@ -74,7 +74,10 @@
74
74
  * for the integration-level regression proof.
75
75
  */
76
76
  import { createRoleMarkerGuard } from '../role-marker-guard.js';
77
- import { type DnsLookupFn, type PinnedFetch } from './connection-guard.js';
77
+ import { extractProviderErrorDetail } from './response-text.js';
78
+ import { type PinnedFetch } from './connection-guard.js';
79
+ import { type DnsLookupFn } from '@jini-ai/core/contracts/agents';
80
+ import { parseSseJsonRecord } from './sse-decode.js';
78
81
  import { type TurnEndReason } from './turn-end-guard.js';
79
82
  import type { ProviderToolSnapshotOptions, ProviderSchemaFallback } from './provider-tool-policy.js';
80
83
  export interface AnthropicTextBlockParam {
@@ -216,17 +219,15 @@ export interface AnthropicTurnResult {
216
219
  }
217
220
  export declare function anthropicRequestUrl({ baseUrl }: {
218
221
  baseUrl: string | undefined;
219
- }): string;
222
+ }, _optional?: Record<string, never>): string;
220
223
  /** The `AnthropicTurnOptions` keys every caller must pass. */
221
224
  type AnthropicRequiredOption = "apiKey" | "model" | "messages" | "maxTokens" | "onEvent";
222
225
  export declare function anthropicHeaders(requiredArgs: Pick<AnthropicTurnOptions, AnthropicRequiredOption>, optionalArgs?: Omit<AnthropicTurnOptions, AnthropicRequiredOption>): Record<string, string>;
223
226
  export declare function anthropicRequestBody({ options, messages }: {
224
227
  options: AnthropicTurnOptions;
225
228
  messages: readonly AnthropicMessageParam[];
226
- }): Record<string, unknown>;
227
- export declare function extractAnthropicErrorDetail({ rawText }: {
228
- rawText: string;
229
- }): string;
229
+ }, _optional?: Record<string, never>): Record<string, unknown>;
230
+ export declare const extractAnthropicErrorDetail: typeof extractProviderErrorDetail;
230
231
  /**
231
232
  * Validates one tool-result content block against the real API's format/size constraints.
232
233
  * Returns the violation reason, or `null` when the block is legal to send.
@@ -241,7 +242,7 @@ export declare function extractAnthropicErrorDetail({ rawText }: {
241
242
  */
242
243
  export declare function invalidToolResultContentBlockReason({ block }: {
243
244
  block: AnthropicToolResultContentBlock;
244
- }): string | null;
245
+ }, _optional?: Record<string, never>): string | null;
245
246
  /**
246
247
  * Runtime guard applied to every `AnthropicToolExecutor` result before it is wired onto the
247
248
  * outbound request or reported via `onEvent`. `AnthropicToolResult` is host-owned (see
@@ -262,7 +263,7 @@ export declare function invalidToolResultContentBlockReason({ block }: {
262
263
  */
263
264
  export declare function guardToolResult({ result }: {
264
265
  result: AnthropicToolResult;
265
- }): AnthropicToolResult;
266
+ }, _optional?: Record<string, never>): AnthropicToolResult;
266
267
  export interface AnthropicBlockState {
267
268
  readonly type: 'text' | 'tool_use' | 'other';
268
269
  text: string;
@@ -285,13 +286,11 @@ export interface AnthropicStreamState {
285
286
  usage: Record<string, unknown> | null;
286
287
  }
287
288
  /** Parses one SSE frame's data as a JSON object, or `null` for a malformed/empty keep-alive frame or a non-object payload — both are tolerated by the caller as "nothing to do this frame". */
288
- export declare function parseAnthropicSseData({ raw }: {
289
- raw: string;
290
- }): Record<string, unknown> | null;
289
+ export declare const parseAnthropicSseData: typeof parseSseJsonRecord;
291
290
  export declare function handleContentBlockStart({ state, data }: {
292
291
  state: AnthropicStreamState;
293
292
  data: Record<string, unknown>;
294
- }): void;
293
+ }, _optional?: Record<string, never>): void;
295
294
  /**
296
295
  * Feeds one text delta through the role-marker guard and emits the safe portion. Returns
297
296
  * `'break'` once the guard flags contamination (the caller ends the turn immediately), otherwise
@@ -302,41 +301,41 @@ export declare function handleAnthropicTextDelta({ state, index, text, onEvent }
302
301
  index: number;
303
302
  text: string;
304
303
  onEvent: (event: AnthropicTurnEvent) => void;
305
- }): 'continue' | 'break';
304
+ }, _optional?: Record<string, never>): 'continue' | 'break';
306
305
  export declare function handleAnthropicInputJsonDelta({ state, index, partialJson }: {
307
306
  state: AnthropicStreamState;
308
307
  index: number;
309
308
  partialJson: string;
310
- }): void;
309
+ }, _optional?: Record<string, never>): void;
311
310
  export declare function handleContentBlockDelta({ state, data, onEvent }: {
312
311
  state: AnthropicStreamState;
313
312
  data: Record<string, unknown>;
314
313
  onEvent: (event: AnthropicTurnEvent) => void;
315
- }): 'continue' | 'break';
314
+ }, _optional?: Record<string, never>): 'continue' | 'break';
316
315
  /** Parses one tool_use block's accumulated `input_json_delta` text, falling back to `{}` for empty or malformed JSON — mirrors OpenAI's identical fallback for `tool_calls[].function.arguments` in `openai-chat.ts`. */
317
316
  export declare function parseAccumulatedToolInputJson({ inputJson }: {
318
317
  inputJson: string;
319
- }): unknown;
318
+ }, _optional?: Record<string, never>): unknown;
320
319
  export declare function handleContentBlockStop({ state, data, onEvent }: {
321
320
  state: AnthropicStreamState;
322
321
  data: Record<string, unknown>;
323
322
  onEvent: (event: AnthropicTurnEvent) => void;
324
- }): void;
323
+ }, _optional?: Record<string, never>): void;
325
324
  export declare function handleMessageDelta({ state, data, onEvent }: {
326
325
  state: AnthropicStreamState;
327
326
  data: Record<string, unknown>;
328
327
  onEvent: (event: AnthropicTurnEvent) => void;
329
- }): void;
328
+ }, _optional?: Record<string, never>): void;
330
329
  export declare function handleAnthropicErrorFrame({ data, onEvent, apiKey }: {
331
330
  data: Record<string, unknown>;
332
331
  onEvent: (event: AnthropicTurnEvent) => void;
333
332
  apiKey: string;
334
- }): void;
333
+ }, _optional?: Record<string, never>): void;
335
334
  /** The SSE event's dispatch key: `data.type` when present (every real Anthropic frame carries one), else the record's `event:` line, else `''` — a key that intentionally matches no entry in {@link ANTHROPIC_FRAME_HANDLERS} (`message_stop`/`ping`/future event types fall through as no-ops, same as before this frame was a lookup table). */
336
335
  export declare function anthropicFrameKind({ data, frameEvent }: {
337
336
  data: Record<string, unknown>;
338
337
  frameEvent: string | null;
339
- }): string;
338
+ }, _optional?: Record<string, never>): string;
340
339
  /**
341
340
  * Runs a full Anthropic Messages API turn, including the tool-execution
342
341
  * loop when `options.executeTool` is supplied and the model requests tool
@@ -359,17 +358,17 @@ export declare function anthropicLoopExitReason({ outcome, toolTurns, maxToolTur
359
358
  outcome: SingleRequestOutcome;
360
359
  toolTurns: number;
361
360
  maxToolTurns: number;
362
- }): AnthropicTurnEndReason | null;
361
+ }, _optional?: Record<string, never>): AnthropicTurnEndReason | null;
363
362
  export declare function buildAnthropicAssistantContent({ text, toolCalls }: {
364
363
  text: string;
365
364
  toolCalls: readonly AnthropicToolCall[];
366
- }): AnthropicContentBlockParam[];
365
+ }, _optional?: Record<string, never>): AnthropicContentBlockParam[];
367
366
  /** Runs every pending tool call in order and reduces the results into the `tool_result` blocks the next request's `user` message carries. Emits one `tool_result` event per call as it goes. */
368
367
  export declare function executeAnthropicToolCalls({ executeTool, calls, onEvent }: {
369
368
  executeTool: AnthropicToolExecutor;
370
369
  calls: readonly AnthropicToolCall[];
371
370
  onEvent: (event: AnthropicTurnEvent) => void;
372
- }): Promise<AnthropicToolResultBlockParam[]>;
371
+ }, _optional?: Record<string, never>): Promise<AnthropicToolResultBlockParam[]>;
373
372
  export declare function runAnthropicToolTurn(requiredArgs: Pick<AnthropicTurnOptions, AnthropicRequiredOption>, optionalArgs?: Omit<AnthropicTurnOptions, AnthropicRequiredOption>): Promise<AnthropicTurnResult>;
374
373
  export {};
375
374
  //# sourceMappingURL=anthropic-messages.d.ts.map
@@ -74,11 +74,14 @@ import { redactSecrets } from '@jini-ai/core';
74
74
  * `__tests__/anthropic-messages.test.ts`'s "never emits end twice" case
75
75
  * for the integration-level regression proof.
76
76
  */
77
- import { createRoleMarkerGuard } from '../role-marker-guard.js';
77
+ import { createRoleMarkerGuard, emitGuardedTextDelta } from '../role-marker-guard.js';
78
+ import { extractProviderErrorDetail } from './response-text.js';
78
79
  import { defaultDnsLookup, pinnedFetch, validateBaseUrlResolved } from './connection-guard.js';
79
- import { decodeSseStream } from './sse-decode.js';
80
+ import {} from '@jini-ai/core/contracts/agents';
81
+ import { decodeSseStream, parseSseJsonRecord } from './sse-decode.js';
80
82
  import { createTurnEndGuard } from './turn-end-guard.js';
81
83
  import { createStrictToolRetry } from './openai-chat.js';
84
+ import {} from './openai-chat-types.js';
82
85
  import { trimCharsEnd } from '@jini-ai/core/text';
83
86
  import { toolLoopVerdict } from './tool-loop-verdict.js';
84
87
  import { omitKeys } from '../core/omit-keys.js';
@@ -88,7 +91,7 @@ const DEFAULT_MAX_TOOL_TURNS = 8;
88
91
  function isRecord(value) {
89
92
  return typeof value === 'object' && value !== null && !Array.isArray(value);
90
93
  }
91
- export function anthropicRequestUrl({ baseUrl }) {
94
+ export function anthropicRequestUrl({ baseUrl }, _optional = {}) {
92
95
  const base = trimCharsEnd({ text: baseUrl ?? DEFAULT_ANTHROPIC_BASE_URL, chars: '/' });
93
96
  return `${base}/v1/messages`;
94
97
  }
@@ -101,7 +104,7 @@ export function anthropicHeaders(requiredArgs, optionalArgs = {}) {
101
104
  ...(options.extraHeaders ?? {}),
102
105
  };
103
106
  }
104
- export function anthropicRequestBody({ options, messages }) {
107
+ export function anthropicRequestBody({ options, messages }, _optional = {}) {
105
108
  return {
106
109
  model: options.model,
107
110
  max_tokens: options.maxTokens,
@@ -112,18 +115,7 @@ export function anthropicRequestBody({ options, messages }) {
112
115
  ...(options.tools && options.tools.length > 0 ? { tools: options.tools } : {}),
113
116
  };
114
117
  }
115
- export function extractAnthropicErrorDetail({ rawText }) {
116
- try {
117
- const parsed = JSON.parse(rawText);
118
- if (isRecord(parsed) && isRecord(parsed.error) && typeof parsed.error.message === 'string') {
119
- return parsed.error.message;
120
- }
121
- }
122
- catch {
123
- // Non-JSON error body — fall through to the raw text below.
124
- }
125
- return rawText.trim().slice(0, 500);
126
- }
118
+ export const extractAnthropicErrorDetail = extractProviderErrorDetail;
127
119
  const ANTHROPIC_ALLOWED_IMAGE_MEDIA_TYPES = new Set([
128
120
  'image/jpeg',
129
121
  'image/png',
@@ -150,7 +142,7 @@ const MAX_IMAGE_BASE64_CHARS = Math.ceil((10 * 1024 * 1024 * 4) / 3);
150
142
  * @complexity O(1) — reads `data.length`, never decodes or parses the base64 payload.
151
143
  * @overallScore 100
152
144
  */
153
- export function invalidToolResultContentBlockReason({ block }) {
145
+ export function invalidToolResultContentBlockReason({ block }, _optional = {}) {
154
146
  if (block.type === 'text')
155
147
  return null;
156
148
  if (block.source.type === 'url')
@@ -181,7 +173,7 @@ export function invalidToolResultContentBlockReason({ block }) {
181
173
  * `invalidToolResultContentBlockReason`).
182
174
  * @overallScore 100
183
175
  */
184
- export function guardToolResult({ result }) {
176
+ export function guardToolResult({ result }, _optional = {}) {
185
177
  if (typeof result.content === 'string')
186
178
  return result;
187
179
  for (const block of result.content) {
@@ -193,17 +185,8 @@ export function guardToolResult({ result }) {
193
185
  return result;
194
186
  }
195
187
  /** Parses one SSE frame's data as a JSON object, or `null` for a malformed/empty keep-alive frame or a non-object payload — both are tolerated by the caller as "nothing to do this frame". */
196
- export function parseAnthropicSseData({ raw }) {
197
- let data;
198
- try {
199
- data = JSON.parse(raw);
200
- }
201
- catch {
202
- return null;
203
- }
204
- return isRecord(data) ? data : null;
205
- }
206
- export function handleContentBlockStart({ state, data }) {
188
+ export const parseAnthropicSseData = parseSseJsonRecord;
189
+ export function handleContentBlockStart({ state, data }, _optional = {}) {
207
190
  if (!isRecord(data.content_block) || typeof data.index !== 'number')
208
191
  return;
209
192
  const block = data.content_block;
@@ -222,7 +205,7 @@ export function handleContentBlockStart({ state, data }) {
222
205
  * `'break'` once the guard flags contamination (the caller ends the turn immediately), otherwise
223
206
  * `'continue'`.
224
207
  */
225
- export function handleAnthropicTextDelta({ state, index, text, onEvent }) {
208
+ export function handleAnthropicTextDelta({ state, index, text, onEvent }, _optional = {}) {
226
209
  const blockState = state.blocks.get(index);
227
210
  if (blockState)
228
211
  blockState.text += text;
@@ -231,25 +214,15 @@ export function handleAnthropicTextDelta({ state, index, text, onEvent }) {
231
214
  // delta in the same request can never reach this point already contaminated. (`feedText` itself
232
215
  // is still safe to call unconditionally regardless — it early-returns `''` once contaminated,
233
216
  // per its own doc.)
234
- const safe = state.guard.feedText({ text: text });
235
- if (safe.length > 0) {
236
- state.fullText += safe;
237
- onEvent({ type: 'text_delta', delta: safe });
238
- }
239
- if (!state.guard.contaminated)
240
- return 'continue';
241
- const warn = state.guard.warningEvent();
242
- if (warn)
243
- onEvent(warn);
244
- return 'break';
217
+ return emitGuardedTextDelta({ state, text: text, onEvent });
245
218
  }
246
- export function handleAnthropicInputJsonDelta({ state, index, partialJson }) {
219
+ export function handleAnthropicInputJsonDelta({ state, index, partialJson }, _optional = {}) {
247
220
  const blockState = state.blocks.get(index);
248
221
  if (!blockState)
249
222
  return;
250
223
  blockState.inputJson += partialJson;
251
224
  }
252
- export function handleContentBlockDelta({ state, data, onEvent }) {
225
+ export function handleContentBlockDelta({ state, data, onEvent }, _optional = {}) {
253
226
  if (!isRecord(data.delta) || typeof data.index !== 'number')
254
227
  return 'continue';
255
228
  const { delta, index } = data;
@@ -262,7 +235,7 @@ export function handleContentBlockDelta({ state, data, onEvent }) {
262
235
  return 'continue';
263
236
  }
264
237
  /** Parses one tool_use block's accumulated `input_json_delta` text, falling back to `{}` for empty or malformed JSON — mirrors OpenAI's identical fallback for `tool_calls[].function.arguments` in `openai-chat.ts`. */
265
- export function parseAccumulatedToolInputJson({ inputJson }) {
238
+ export function parseAccumulatedToolInputJson({ inputJson }, _optional = {}) {
266
239
  if (!inputJson.trim())
267
240
  return {};
268
241
  try {
@@ -272,7 +245,7 @@ export function parseAccumulatedToolInputJson({ inputJson }) {
272
245
  return {};
273
246
  }
274
247
  }
275
- export function handleContentBlockStop({ state, data, onEvent }) {
248
+ export function handleContentBlockStop({ state, data, onEvent }, _optional = {}) {
276
249
  if (typeof data.index !== 'number')
277
250
  return;
278
251
  const blockState = state.blocks.get(data.index);
@@ -283,7 +256,7 @@ export function handleContentBlockStop({ state, data, onEvent }) {
283
256
  }
284
257
  state.blocks.delete(data.index);
285
258
  }
286
- export function handleMessageDelta({ state, data, onEvent }) {
259
+ export function handleMessageDelta({ state, data, onEvent }, _optional = {}) {
287
260
  if (isRecord(data.delta) && typeof data.delta.stop_reason === 'string') {
288
261
  state.stopReason = data.delta.stop_reason;
289
262
  }
@@ -292,13 +265,13 @@ export function handleMessageDelta({ state, data, onEvent }) {
292
265
  onEvent({ type: 'usage', usage: state.usage });
293
266
  }
294
267
  }
295
- export function handleAnthropicErrorFrame({ data, onEvent, apiKey }) {
268
+ export function handleAnthropicErrorFrame({ data, onEvent, apiKey }, _optional = {}) {
296
269
  const errorDetail = isRecord(data.error) && typeof data.error.message === 'string' ? data.error.message : 'upstream error';
297
270
  const errorType = isRecord(data.error) && typeof data.error.type === 'string' ? data.error.type : undefined;
298
271
  onEvent({ type: 'error', message: redactSecrets({ input: errorDetail }, { exactSecrets: [apiKey] }), ...(errorType ? { code: errorType } : {}) });
299
272
  }
300
273
  /** The SSE event's dispatch key: `data.type` when present (every real Anthropic frame carries one), else the record's `event:` line, else `''` — a key that intentionally matches no entry in {@link ANTHROPIC_FRAME_HANDLERS} (`message_stop`/`ping`/future event types fall through as no-ops, same as before this frame was a lookup table). */
301
- export function anthropicFrameKind({ data, frameEvent }) {
274
+ export function anthropicFrameKind({ data, frameEvent }, _optional = {}) {
302
275
  if (typeof data.type === 'string')
303
276
  return data.type;
304
277
  return frameEvent ?? '';
@@ -336,7 +309,7 @@ function refreshAnthropicTools(options, retry) {
336
309
  let tools = options.getTools?.({ strict: retry.enabled }) ?? options.tools;
337
310
  if (!retry.enabled)
338
311
  tools = tools?.map(tool => {
339
- return omitKeys(tool, ['strict']);
312
+ return omitKeys({ source: tool, keys: ['strict'] });
340
313
  });
341
314
  return { ...options, ...(tools !== undefined ? { tools } : {}) };
342
315
  }
@@ -459,21 +432,21 @@ async function runSingleAnthropicRequest(options, messages, emitEnd, retry) {
459
432
  * "stop" conditions (no/empty tool_use, no executor, turn ceiling reached) are exercised as plain
460
433
  * value-in/value-out assertions rather than through the full request/event-emission machinery.
461
434
  */
462
- export function anthropicLoopExitReason({ outcome, toolTurns, maxToolTurns }) {
435
+ export function anthropicLoopExitReason({ outcome, toolTurns, maxToolTurns }, _optional = {}) {
463
436
  if (outcome.stopReason !== 'tool_use' || outcome.toolCalls.length === 0)
464
437
  return 'stop';
465
438
  if (toolTurns >= maxToolTurns)
466
439
  return 'max_tool_turns';
467
440
  return null;
468
441
  }
469
- export function buildAnthropicAssistantContent({ text, toolCalls }) {
442
+ export function buildAnthropicAssistantContent({ text, toolCalls }, _optional = {}) {
470
443
  return [
471
444
  ...(text ? [{ type: 'text', text }] : []),
472
445
  ...toolCalls.map((call) => ({ type: 'tool_use', id: call.id, name: call.name, input: call.input })),
473
446
  ];
474
447
  }
475
448
  /** Runs every pending tool call in order and reduces the results into the `tool_result` blocks the next request's `user` message carries. Emits one `tool_result` event per call as it goes. */
476
- export async function executeAnthropicToolCalls({ executeTool, calls, onEvent }) {
449
+ export async function executeAnthropicToolCalls({ executeTool, calls, onEvent }, _optional = {}) {
477
450
  const toolResultBlocks = [];
478
451
  for (const call of calls) {
479
452
  const rawResult = await executeTool(call);
@@ -493,7 +466,7 @@ export async function runAnthropicToolTurn(requiredArgs, optionalArgs = {}) {
493
466
  const retry = createStrictToolRetry({ protocol: 'anthropic', onSchemaFallback: options.onSchemaFallback });
494
467
  const maxToolTurns = options.maxToolTurns ?? DEFAULT_MAX_TOOL_TURNS;
495
468
  const executeTool = options.executeTool;
496
- const endGuard = createTurnEndGuard(options.onEvent, (reason) => ({ type: 'end', reason }));
469
+ const endGuard = createTurnEndGuard({ onEvent: options.onEvent, makeEndEvent: (reason) => ({ type: 'end', reason }) });
497
470
  const emitEnd = endGuard.emitEnd;
498
471
  let messages = options.messages.slice();
499
472
  let toolTurns = 0;
@@ -72,8 +72,9 @@
72
72
  * beyond this pointer to avoid the two copies drifting.
73
73
  * See docs/decisions/DR-001-provider-native-tool-lifecycle.md.
74
74
  */
75
- import { type DnsLookupFn, type PinnedFetch } from './connection-guard.js';
76
- import { type OpenAiCompatibleRequestOutcome } from './openai-chat.js';
75
+ import { type PinnedFetch } from './connection-guard.js';
76
+ import { type DnsLookupFn } from '@jini-ai/core/contracts/agents';
77
+ import { type OpenAiCompatibleRequestOutcome } from './openai-chat-types.js';
77
78
  import type { ProviderToolSnapshotOptions, ProviderSchemaFallback } from './provider-tool-policy.js';
78
79
  import { type TurnEndReason } from './turn-end-guard.js';
79
80
  export interface AzureFunctionToolDef {
@@ -198,11 +199,11 @@ export declare function azureLoopExitReason({ outcome, toolTurns, maxToolTurns }
198
199
  outcome: OpenAiCompatibleRequestOutcome;
199
200
  toolTurns: number;
200
201
  maxToolTurns: number;
201
- }): AzureTurnEndReason | null;
202
+ }, _optional?: Record<string, never>): AzureTurnEndReason | null;
202
203
  /** Builds the assistant continuation's `tool_calls` field — same shape as `openai-chat.ts#buildOpenAiAssistantToolCallMessage`'s `tool_calls`, since Azure's wire body is byte-identical to plain OpenAI's (see module doc). */
203
204
  export declare function buildAzureAssistantToolCalls({ toolCalls }: {
204
205
  toolCalls: readonly AzureToolCall[];
205
- }): AzureToolCallParam[];
206
+ }, _optional?: Record<string, never>): AzureToolCallParam[];
206
207
  export interface AzureToolExecutionOutcome {
207
208
  readonly toolResultMessages: AzureMessageParam[];
208
209
  readonly followUpParts: AzureContentPart[];
@@ -212,12 +213,12 @@ export declare function executeAzureToolCalls({ executeTool, calls, onEvent }: {
212
213
  executeTool: AzureToolExecutor;
213
214
  calls: readonly AzureToolCall[];
214
215
  onEvent: (event: AzureTurnEvent) => void;
215
- }): Promise<AzureToolExecutionOutcome>;
216
+ }, _optional?: Record<string, never>): Promise<AzureToolExecutionOutcome>;
216
217
  /** Azure counterpart of `openai-chat.ts#buildOpenAiToolExchangeMessages` — appends the batch's `tool` messages plus, when present, the single labeled-image follow-up message. */
217
218
  export declare function buildAzureToolExchangeMessages({ toolResultMessages, followUpParts }: {
218
219
  toolResultMessages: readonly AzureMessageParam[];
219
220
  followUpParts: readonly AzureContentPart[];
220
- }): AzureMessageParam[];
221
+ }, _optional?: Record<string, never>): AzureMessageParam[];
221
222
  /**
222
223
  * Runs a full Azure OpenAI Chat Completions turn, including the
223
224
  * tool-execution loop when `options.executeTool` is supplied and the model
@@ -73,7 +73,10 @@
73
73
  * See docs/decisions/DR-001-provider-native-tool-lifecycle.md.
74
74
  */
75
75
  import { defaultDnsLookup, validateBaseUrlResolved } from './connection-guard.js';
76
- import { runOpenAiCompatibleRequest, refreshOpenAiTools, createStrictToolRetry } from './openai-chat.js';
76
+ import {} from '@jini-ai/core/contracts/agents';
77
+ import { runOpenAiCompatibleRequest } from './openai-chat-request.js';
78
+ import { refreshOpenAiTools, createStrictToolRetry } from './openai-chat.js';
79
+ import {} from './openai-chat-types.js';
77
80
  import { buildLegacyMaxTokensParam, buildMaxCompletionTokensParam, isUnsupportedMaxTokensError } from './token-params.js';
78
81
  import { createTurnEndGuard } from './turn-end-guard.js';
79
82
  import { trimCharsEnd } from '@jini-ai/core/text';
@@ -192,7 +195,7 @@ function splitAzureToolResultContent(content) {
192
195
  * instead proceed to execute the pending tool calls — mirrors
193
196
  * `anthropic-messages.ts#anthropicLoopExitReason`'s pure decision/effect split.
194
197
  */
195
- export function azureLoopExitReason({ outcome, toolTurns, maxToolTurns }) {
198
+ export function azureLoopExitReason({ outcome, toolTurns, maxToolTurns }, _optional = {}) {
196
199
  if (outcome.finishReason !== 'tool_calls' || outcome.toolCalls.length === 0)
197
200
  return 'stop';
198
201
  if (toolTurns >= maxToolTurns)
@@ -200,11 +203,11 @@ export function azureLoopExitReason({ outcome, toolTurns, maxToolTurns }) {
200
203
  return null;
201
204
  }
202
205
  /** Builds the assistant continuation's `tool_calls` field — same shape as `openai-chat.ts#buildOpenAiAssistantToolCallMessage`'s `tool_calls`, since Azure's wire body is byte-identical to plain OpenAI's (see module doc). */
203
- export function buildAzureAssistantToolCalls({ toolCalls }) {
206
+ export function buildAzureAssistantToolCalls({ toolCalls }, _optional = {}) {
204
207
  return toolCalls.map((call) => ({ id: call.id, type: 'function', function: { name: call.name, arguments: JSON.stringify(call.input) } }));
205
208
  }
206
209
  /** Azure counterpart of `openai-chat.ts#executeOpenAiToolCalls` — same split (text-only `tool` message plus one labeled-image follow-up per batch) and same per-batch assembly discipline; see that function's doc and module doc's "synthetic follow-up message" note for why. */
207
- export async function executeAzureToolCalls({ executeTool, calls, onEvent }) {
210
+ export async function executeAzureToolCalls({ executeTool, calls, onEvent }, _optional = {}) {
208
211
  const toolResultMessages = [];
209
212
  const followUpParts = [];
210
213
  for (const call of calls) {
@@ -222,7 +225,7 @@ export async function executeAzureToolCalls({ executeTool, calls, onEvent }) {
222
225
  return { toolResultMessages, followUpParts };
223
226
  }
224
227
  /** Azure counterpart of `openai-chat.ts#buildOpenAiToolExchangeMessages` — appends the batch's `tool` messages plus, when present, the single labeled-image follow-up message. */
225
- export function buildAzureToolExchangeMessages({ toolResultMessages, followUpParts }) {
228
+ export function buildAzureToolExchangeMessages({ toolResultMessages, followUpParts }, _optional = {}) {
226
229
  return [...toolResultMessages, ...(followUpParts.length > 0 ? [{ role: 'user', content: followUpParts }] : [])];
227
230
  }
228
231
  /**
@@ -236,7 +239,7 @@ export async function runAzureToolTurn(requiredArgs, optionalArgs = {}) {
236
239
  const retry = createStrictToolRetry({ protocol: 'azure', onSchemaFallback: options.onSchemaFallback });
237
240
  const maxToolTurns = options.maxToolTurns ?? DEFAULT_MAX_TOOL_TURNS;
238
241
  const executeTool = options.executeTool;
239
- const endGuard = createTurnEndGuard(options.onEvent, (reason) => ({ type: 'end', reason }));
242
+ const endGuard = createTurnEndGuard({ onEvent: options.onEvent, makeEndEvent: (reason) => ({ type: 'end', reason }) });
240
243
  const emitEnd = endGuard.emitEnd;
241
244
  let messages = options.messages.slice();
242
245
  let toolTurns = 0;
@@ -1,3 +1,4 @@
1
+ import type { DnsLookupAddress, DnsLookupFn } from '@jini-ai/core/contracts/agents';
1
2
  export interface BaseUrlValidationResult {
2
3
  parsed?: URL;
3
4
  error?: string;
@@ -34,14 +35,7 @@ export interface BaseUrlValidationResult {
34
35
  */
35
36
  export declare function validateBaseUrl({ baseUrl }: {
36
37
  baseUrl: string;
37
- }): BaseUrlValidationResult;
38
- export type DnsLookupAddress = {
39
- address: string;
40
- family: number;
41
- };
42
- export type DnsLookupFn = (requiredArgs: {
43
- hostname: string;
44
- }) => Promise<DnsLookupAddress[]>;
38
+ }, _optional?: Record<string, never>): BaseUrlValidationResult;
45
39
  /**
46
40
  * DNS-aware companion to {@link validateBaseUrl}. The synchronous check only
47
41
  * inspects the literal hostname string, so a public DNS name pointing at
@@ -85,7 +79,7 @@ export type DnsLookupFn = (requiredArgs: {
85
79
  export declare function validateBaseUrlResolved({ baseUrl, lookup }: {
86
80
  baseUrl: string;
87
81
  lookup: DnsLookupFn;
88
- }): Promise<BaseUrlValidationResult>;
82
+ }, _optional?: Record<string, never>): Promise<BaseUrlValidationResult>;
89
83
  /** Request options accepted by {@link pinnedFetch} — the subset of `fetch`'s `init` this package's provider adapters actually pass. `redirect` is accepted only as documentation of intent: `pinnedFetch` never follows a redirect regardless of this field, so a caller cannot opt back into `fetch`'s default follow-redirects behavior. */
90
84
  export interface PinnedFetchInit {
91
85
  readonly method: string;
@@ -44,7 +44,8 @@ import { readProviderResponseText, MAX_PROVIDER_ERROR_BYTES } from './response-t
44
44
  * the UI accepts an endpoint this guard then refuses — or, in the direction
45
45
  * that actually matters, the UI accepts one this guard would have refused.
46
46
  */
47
- import { isLoopbackApiHost, isBlockedExternalApiHostname } from '@jini-ai/platform/net';
47
+ import { isLoopbackApiHost, isBlockedExternalApiHostname } from '@jini-ai/core/net';
48
+ import { isIpLiteralHostname } from '@jini-ai/core';
48
49
  import { trimCharsEnd } from '@jini-ai/core/text';
49
50
  /**
50
51
  * Synchronous base-URL check: scheme allow-list + literal-hostname block-list.
@@ -66,7 +67,7 @@ import { trimCharsEnd } from '@jini-ai/core/text';
66
67
  * is the only shape that would let the block-list inspect one string while the
67
68
  * network used another.
68
69
  */
69
- export function validateBaseUrl({ baseUrl }) {
70
+ export function validateBaseUrl({ baseUrl }, _optional = {}) {
70
71
  let parsed;
71
72
  try {
72
73
  // Trim BEFORE stripping trailing slashes: in `"https://x/ "` the trailing
@@ -85,14 +86,6 @@ export function validateBaseUrl({ baseUrl }) {
85
86
  }
86
87
  return { parsed };
87
88
  }
88
- function looksLikeIpLiteral(hostname) {
89
- const host = hostname.startsWith('[') && hostname.endsWith(']')
90
- ? hostname.slice(1, -1)
91
- : hostname;
92
- if (/^\d{1,3}(?:\.\d{1,3}){3}$/.test(host))
93
- return true;
94
- return host.includes(':');
95
- }
96
89
  /**
97
90
  * DNS-aware companion to {@link validateBaseUrl}. The synchronous check only
98
91
  * inspects the literal hostname string, so a public DNS name pointing at
@@ -133,14 +126,12 @@ function looksLikeIpLiteral(hostname) {
133
126
  * a Node host can wrap `node:dns`'s promise
134
127
  * `lookup(hostname, { all: true, family: 0 })` in this port's object signature.
135
128
  */
136
- export async function validateBaseUrlResolved({ baseUrl, lookup }) {
129
+ export async function validateBaseUrlResolved({ baseUrl, lookup }, _optional = {}) {
137
130
  const sync = validateBaseUrl({ baseUrl: baseUrl });
138
131
  if (sync.error || !sync.parsed)
139
132
  return sync;
140
133
  const hostname = sync.parsed.hostname.toLowerCase();
141
- if (isLoopbackApiHost({ hostname: hostname }))
142
- return sync;
143
- if (looksLikeIpLiteral(hostname))
134
+ if (skipsApiDnsLookup(hostname))
144
135
  return sync;
145
136
  let addresses;
146
137
  try {
@@ -166,6 +157,7 @@ export async function validateBaseUrlResolved({ baseUrl, lookup }) {
166
157
  // pre-pinning pass-through behavior. The nonempty check guarantees the first address exists.
167
158
  return { ...sync, pinnedAddress: addresses[0] };
168
159
  }
160
+ function skipsApiDnsLookup(hostname) { return isLoopbackApiHost({ hostname }) || isIpLiteralHostname({ hostname }); }
169
161
  /**
170
162
  * Idle-socket safety net, applied to every `pinnedFetch` request regardless of `init.signal`.
171
163
  * Plain `http(s).request` has NO default timeout at all — unlike `fetch`, which is backed by
@@ -17,8 +17,7 @@
17
17
  * no OD workspace-package imports, matching every other file in this
18
18
  * directory.
19
19
  */
20
- import type { DnsLookupFn } from './connection-guard.js';
21
- import type { ConnectionTestKind, ConnectionTestProtocol } from './types.js';
20
+ import type { DnsLookupFn, ConnectionTestKind, ConnectionTestProtocol } from '@jini-ai/core/contracts/agents';
22
21
  /** The four wire protocols this smoke test knows how to speak. A narrower
23
22
  * type than {@link ConnectionTestProtocol} on purpose — see this module's
24
23
  * header for what's out of scope and why. */