@jini-ai/agent-runtime 0.7.2 → 0.7.3-next.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 (405) hide show
  1. package/CHANGELOG.md +3 -13
  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 +3 -1
  8. package/dist/agent-protocol/acp/constants.js +2 -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 +157 -129
  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 +226 -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 +27 -15
  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
@@ -19,7 +19,7 @@ import { buildAcpSessionNewParams } from './session-params.js';
19
19
  * @param value - A raw field value from an ACP config option object.
20
20
  * @returns A normalised token string, or `''` when `value` is not a string.
21
21
  */
22
- export function normalizeConfigOptionToken(value) {
22
+ export function normalizeConfigOptionToken({ value }, _optional = {}) {
23
23
  return typeof value === 'string'
24
24
  ? value.trim().toLowerCase().replace(/[\s_-]+/g, '')
25
25
  : '';
@@ -32,16 +32,16 @@ export function normalizeConfigOptionToken(value) {
32
32
  * @param option - A single item from the `configOptions` array.
33
33
  * @param configId - The trimmed `id` field of that item.
34
34
  */
35
- export function isModelConfigOption(option, configId) {
36
- const category = normalizeConfigOptionToken(option.category);
35
+ export function isModelConfigOption({ option, configId }, _optional = {}) {
36
+ const category = normalizeConfigOptionToken({ value: option.category });
37
37
  if (category === 'model')
38
38
  return true;
39
- const id = normalizeConfigOptionToken(configId);
39
+ const id = normalizeConfigOptionToken({ value: configId });
40
40
  if (id === 'model')
41
41
  return true;
42
42
  if (category)
43
43
  return false;
44
- const name = normalizeConfigOptionToken(option.name);
44
+ const name = normalizeConfigOptionToken({ value: option.name });
45
45
  return MODEL_CONFIG_OPTION_IDS.has(id) || name === 'model';
46
46
  }
47
47
  /**
@@ -52,7 +52,7 @@ export function isModelConfigOption(option, configId) {
52
52
  * @param configOptions - The raw `result.configOptions` value from a session response.
53
53
  * @returns A parsed `AcpModelConfigOption` or `null` when absent.
54
54
  */
55
- export function findModelConfigOption(configOptions) {
55
+ export function findModelConfigOption({ configOptions }, _optional = {}) {
56
56
  const options = Array.isArray(configOptions) ? configOptions : [];
57
57
  for (const rawOption of options) {
58
58
  const parsed = parseModelConfigOption(rawOption);
@@ -61,6 +61,20 @@ export function findModelConfigOption(configOptions) {
61
61
  }
62
62
  return null;
63
63
  }
64
+ export function findEffortConfigOption({ configOptions }, _optional = {}) {
65
+ const options = Array.isArray(configOptions) ? configOptions : [];
66
+ for (const rawOption of options) {
67
+ const option = asObject({ value: rawOption });
68
+ if (option?.category !== 'thought_level' || typeof option.id !== 'string')
69
+ continue;
70
+ const values = Array.isArray(option.options) ? option.options.flatMap((rawValue) => {
71
+ const value = asObject({ value: rawValue })?.value;
72
+ return typeof value === 'string' ? [value] : [];
73
+ }) : [];
74
+ return { configId: option.id, values };
75
+ }
76
+ return null;
77
+ }
64
78
  /** Returns the trimmed string when `value` is a string, else `''`. */
65
79
  function trimmedOrEmpty(value) {
66
80
  return typeof value === 'string' ? value.trim() : '';
@@ -68,7 +82,7 @@ function trimmedOrEmpty(value) {
68
82
  /** Parses one `configOptions` entry, returning it only when it is a
69
83
  * select-type (or untyped) model-selection option with a non-blank id. */
70
84
  function parseModelConfigOption(rawOption) {
71
- const option = asObject(rawOption);
85
+ const option = asObject({ value: rawOption });
72
86
  if (!option)
73
87
  return null;
74
88
  const configId = trimmedOrEmpty(option.id);
@@ -77,7 +91,7 @@ function parseModelConfigOption(rawOption) {
77
91
  const type = trimmedOrEmpty(option.type);
78
92
  if (type && type !== 'select')
79
93
  return null;
80
- if (!isModelConfigOption(option, configId))
94
+ if (!isModelConfigOption({ option, configId }))
81
95
  return null;
82
96
  return {
83
97
  configId,
@@ -109,7 +123,7 @@ function configOptionEntry(value) {
109
123
  }
110
124
  /** Reads a legacy `models.availableModels` entry. */
111
125
  function legacyModelEntry(model) {
112
- const obj = asObject(model);
126
+ const obj = asObject({ value: model });
113
127
  return { id: trimmedOrEmpty(obj?.modelId), name: trimmedOrEmpty(obj?.name) };
114
128
  }
115
129
  /**
@@ -122,13 +136,13 @@ function legacyModelEntry(model) {
122
136
  * @param defaultModelOption - The fallback option to prepend to the list.
123
137
  * @returns `{ currentModelId, models }` or `null` when no config option is found.
124
138
  */
125
- export function normalizeModelConfigOptions(configOptions, defaultModelOption) {
126
- const modelConfig = findModelConfigOption(configOptions);
139
+ export function normalizeModelConfigOptions({ configOptions, defaultModelOption }, _optional = {}) {
140
+ const modelConfig = findModelConfigOption({ configOptions });
127
141
  if (!modelConfig)
128
142
  return null;
129
143
  const entries = [];
130
144
  for (const rawValue of modelConfig.values) {
131
- const value = asObject(rawValue);
145
+ const value = asObject({ value: rawValue });
132
146
  if (value)
133
147
  entries.push(configOptionEntry(value));
134
148
  }
@@ -151,7 +165,7 @@ export function normalizeModelConfigOptions(configOptions, defaultModelOption) {
151
165
  * @returns A deduplicated array of `ModelOption` items.
152
166
  */
153
167
  export function normalizeModels({ models, defaultModelOption }, { configOptions } = {}) {
154
- const configModels = normalizeModelConfigOptions(configOptions, defaultModelOption);
168
+ const configModels = normalizeModelConfigOptions({ configOptions, defaultModelOption });
155
169
  if (configModels && configModels.models.length > 1) {
156
170
  return configModels.models;
157
171
  }
@@ -160,7 +174,7 @@ export function normalizeModels({ models, defaultModelOption }, { configOptions
160
174
  }
161
175
  /** The legacy `result.models.availableModels` path of `normalizeModels`. */
162
176
  function legacyModelOptions({ models, defaultModelOption, }) {
163
- const modelsObj = asObject(models);
177
+ const modelsObj = asObject({ value: models });
164
178
  const available = Array.isArray(modelsObj?.availableModels) ? modelsObj.availableModels : [];
165
179
  const currentId = typeof modelsObj?.currentModelId === 'string' ? modelsObj.currentModelId : null;
166
180
  return buildModelOptions({ defaultModelOption, currentId, entries: available.map(legacyModelEntry) });
@@ -172,7 +186,7 @@ function legacyModelOptions({ models, defaultModelOption, }) {
172
186
  *
173
187
  * @param code - The `error.code` value from a JSON-RPC error response.
174
188
  */
175
- export function modelSelectionErrorIsRecoverable(code) {
189
+ export function modelSelectionErrorIsRecoverable({ code }, _optional = {}) {
176
190
  return code === -32603 || code === -32602 || code === -32601 || code === -32002;
177
191
  }
178
192
  /**
@@ -182,11 +196,11 @@ export function modelSelectionErrorIsRecoverable(code) {
182
196
  *
183
197
  * @param result - The parsed `result` object from a session handshake response.
184
198
  */
185
- export function currentModelFromSessionResult(result) {
186
- const configCurrent = findModelConfigOption(result.configOptions)?.currentValue;
199
+ export function currentModelFromSessionResult({ result }, _optional = {}) {
200
+ const configCurrent = findModelConfigOption({ configOptions: result.configOptions })?.currentValue;
187
201
  if (configCurrent)
188
202
  return configCurrent;
189
- const models = asObject(result.models);
203
+ const models = asObject({ value: result.models });
190
204
  return typeof models?.currentModelId === 'string' && models.currentModelId.trim()
191
205
  ? models.currentModelId.trim()
192
206
  : null;
@@ -211,118 +225,132 @@ export function currentModelFromSessionResult(result) {
211
225
  * @returns A promise resolving to the available `ModelOption[]`.
212
226
  */
213
227
  export async function detectAcpModels(requiredArgs, optionalArgs = {}) {
214
- const { bin, args, cwd = process.cwd(), env = process.env, timeoutMs = DEFAULT_TIMEOUT_MS, clientName = 'agent-runtime-detect', clientVersion = 'runtime-adapter', defaultModelOption = { id: 'default', label: 'Default (CLI config)' }, signal, onSessionResult, spawnProcess = spawn, } = { ...optionalArgs, ...requiredArgs };
215
- const effectiveTimeoutMs = resolveAcpTimeoutMs(env, timeoutMs);
216
- return await new Promise((resolve, reject) => {
217
- if (signal?.aborted)
218
- throw new Error('ACP model detection aborted');
219
- const child = spawnProcess(bin, args, {
220
- cwd,
221
- stdio: ['pipe', 'pipe', 'pipe'],
222
- env: { ...env },
223
- });
224
- child.stdout.setEncoding('utf8');
225
- child.stderr.setEncoding('utf8');
226
- let settled = false;
227
- let closed = false;
228
- let stderrBuf = '';
229
- let stdoutBytes = 0;
230
- let expectedId = 1;
231
- let timer = null;
232
- const finish = (fn, value) => {
233
- if (settled)
234
- return;
235
- settled = true;
236
- if (timer)
237
- clearTimeout(timer);
238
- signal?.removeEventListener('abort', abort);
239
- if (closed)
240
- fn(value);
241
- else
242
- finishAcpProbeProcess({ child, complete: () => fn(value) });
243
- };
244
- const fail = (message) => {
245
- finish(reject, new Error(message));
246
- };
247
- const abort = () => fail('ACP model detection aborted');
248
- signal?.addEventListener('abort', abort, { once: true });
249
- if (signal?.aborted) {
250
- abort();
251
- return;
252
- }
253
- const writeRpc = (id, method, params) => {
254
- try {
255
- sendRpc(child.stdin, id, method, params);
256
- }
257
- catch (err) {
258
- fail(`stdin write failed: ${errorMessage(err)}`);
259
- }
260
- };
261
- const handleRpcError = (obj, rpcErr) => {
262
- // JSON-RPC -32603 "Internal error" during model detection:
263
- // If this is for the current expected-id (initialize/session/new),
264
- // it's a real probe failure — reject immediately.
265
- // Otherwise it's cleanup noise — suppress it.
266
- if (asObject(obj?.error)?.code === -32603 && obj?.id !== expectedId)
267
- return;
268
- fail(rpcErr);
269
- };
270
- const handleResult = (result) => {
271
- if (expectedId === 1) {
272
- expectedId = 2;
273
- writeRpc(2, 'session/new', buildAcpSessionNewParams({ cwd: cwd }));
274
- return;
275
- }
276
- onSessionResult?.(result);
277
- const models = normalizeModels({ models: result.models, defaultModelOption: defaultModelOption }, { configOptions: result.configOptions });
278
- finish(resolve, models);
279
- };
280
- const parser = createJsonLineStream({ onError: error => fail(error.message), onMessage: ({ message: raw }) => {
281
- const obj = asObject(raw);
282
- const rpcErr = rpcErrorMessage(raw);
283
- if (rpcErr) {
284
- handleRpcError(obj, rpcErr);
285
- return;
286
- }
287
- const result = asObject(obj?.result);
288
- if (obj?.id !== expectedId || !result)
289
- return;
290
- handleResult(result);
291
- } });
292
- child.stdout.on('data', (chunk) => {
293
- stdoutBytes += Buffer.byteLength(String(chunk), 'utf8');
294
- if (stdoutBytes > 8 * 1024 * 1024) {
295
- fail('ACP metadata output exceeded its limit');
296
- return;
297
- }
298
- parser.feed({ chunk: chunk });
299
- });
300
- child.stdout.on('close', () => parser.flush());
301
- child.stdin.on('error', (err) => fail(`stdin error: ${err.message}`));
302
- child.stderr.on('data', (chunk) => {
303
- stderrBuf = `${stderrBuf}${chunk}`.slice(-16_000);
304
- });
305
- child.on('error', (err) => fail(`spawn failed: ${err.message}`));
306
- child.on('close', (code, signal) => {
307
- closed = true;
308
- parser.flush();
309
- if (!settled) {
310
- const errTail = stderrBuf.trim();
311
- const suffix = errTail ? ` stderr=${errTail}` : '';
312
- fail(`ACP model detection exited code=${code} signal=${signal ?? 'none'}${suffix}`);
313
- }
314
- });
315
- if (effectiveTimeoutMs > 0) {
316
- timer = setTimeout(() => {
317
- fail(`ACP model detection timed out after ${effectiveTimeoutMs}ms`);
318
- }, effectiveTimeoutMs);
319
- }
320
- writeRpc(1, 'initialize', {
228
+ const config = resolveProbeConfig({ ...optionalArgs, ...requiredArgs });
229
+ return await new Promise((resolve, reject) => startProbe({ config, resolve, reject }));
230
+ }
231
+ function resolveProbeConfig(options) {
232
+ const { cwd = process.cwd(), env = process.env, timeoutMs = DEFAULT_TIMEOUT_MS, clientName = 'agent-runtime-detect', clientVersion = 'runtime-adapter', defaultModelOption = { id: 'default', label: 'Default (CLI config)' }, spawnProcess = spawn, } = options;
233
+ return {
234
+ bin: options.bin, args: options.args, cwd, env, timeoutMs, clientName, clientVersion,
235
+ defaultModelOption, spawnProcess, signal: options.signal, onSessionResult: options.onSessionResult,
236
+ effectiveTimeoutMs: resolveAcpTimeoutMs({ env, fallbackMs: timeoutMs }),
237
+ };
238
+ }
239
+ function finishProbe({ run, fn, value }) {
240
+ if (run.settled)
241
+ return;
242
+ run.settled = true;
243
+ if (run.timer)
244
+ clearTimeout(run.timer);
245
+ run.config.signal?.removeEventListener('abort', run.abort);
246
+ if (run.closed)
247
+ fn(value);
248
+ else
249
+ finishAcpProbeProcess({ child: run.child, complete: () => fn(value) });
250
+ }
251
+ function failProbe({ run, message }) {
252
+ finishProbe({ run, fn: run.reject, value: new Error(message) });
253
+ }
254
+ function writeProbeRpc(run, rpc) {
255
+ try {
256
+ sendRpc({ writable: run.child.stdin, id: rpc.id, method: rpc.method, params: rpc.params });
257
+ }
258
+ catch (err) {
259
+ failProbe({ run, message: `stdin write failed: ${errorMessage({ err })}` });
260
+ }
261
+ }
262
+ function handleProbeRpcError({ run, obj, rpcErr }) {
263
+ // JSON-RPC -32603 "Internal error" during model detection:
264
+ // If this is for the current expected-id (initialize/session/new),
265
+ // it's a real probe failure — reject immediately.
266
+ // Otherwise it's cleanup noise — suppress it.
267
+ if (asObject({ value: obj?.error })?.code === -32603 && obj?.id !== run.expectedId)
268
+ return;
269
+ failProbe({ run, message: rpcErr });
270
+ }
271
+ function handleProbeResult(run, result) {
272
+ const { config } = run;
273
+ if (run.expectedId === 1) {
274
+ run.expectedId = 2;
275
+ writeProbeRpc(run, { id: 2, method: 'session/new', params: buildAcpSessionNewParams({ cwd: config.cwd }) });
276
+ return;
277
+ }
278
+ config.onSessionResult?.(result);
279
+ const models = normalizeModels({ models: result.models, defaultModelOption: config.defaultModelOption }, { configOptions: result.configOptions });
280
+ finishProbe({ run, fn: run.resolve, value: models });
281
+ }
282
+ function handleProbeMessage({ run, raw }) {
283
+ const obj = asObject({ value: raw });
284
+ const rpcErr = rpcErrorMessage({ raw });
285
+ if (rpcErr) {
286
+ handleProbeRpcError({ run, obj, rpcErr });
287
+ return;
288
+ }
289
+ const result = asObject({ value: obj?.result });
290
+ if (obj?.id !== run.expectedId || !result)
291
+ return;
292
+ handleProbeResult(run, result);
293
+ }
294
+ function handleProbeStdout({ run, parser, chunk }) {
295
+ run.stdoutBytes += Buffer.byteLength(String(chunk), 'utf8');
296
+ if (run.stdoutBytes > 8 * 1024 * 1024) {
297
+ failProbe({ run, message: 'ACP metadata output exceeded its limit' });
298
+ return;
299
+ }
300
+ parser.feed({ chunk: chunk });
301
+ }
302
+ function handleProbeClose({ run, parser, exit }) {
303
+ run.closed = true;
304
+ parser.flush();
305
+ if (run.settled)
306
+ return;
307
+ const errTail = run.stderrBuf.trim();
308
+ const suffix = errTail ? ` stderr=${errTail}` : '';
309
+ failProbe({
310
+ run,
311
+ message: `ACP model detection exited code=${exit.code} signal=${exit.signal ?? 'none'}${suffix}`,
312
+ });
313
+ }
314
+ function wireProbeListeners(run) {
315
+ const { child } = run;
316
+ const parser = createJsonLineStream({
317
+ onMessage: ({ message: raw }) => handleProbeMessage({ run, raw }),
318
+ }, { onError: error => failProbe({ run, message: error.message }) });
319
+ child.stdout.on('data', (chunk) => handleProbeStdout({ run, parser, chunk }));
320
+ child.stdout.on('close', () => parser.flush());
321
+ child.stdin.on('error', (err) => failProbe({ run, message: `stdin error: ${err.message}` }));
322
+ child.stderr.on('data', (chunk) => {
323
+ run.stderrBuf = `${run.stderrBuf}${chunk}`.slice(-16_000);
324
+ });
325
+ child.on('error', (err) => failProbe({ run, message: `spawn failed: ${err.message}` }));
326
+ child.on('close', (code, signal) => handleProbeClose({ run, parser, exit: { code, signal } }));
327
+ }
328
+ function startProbe({ config, resolve, reject }) {
329
+ if (config.signal?.aborted)
330
+ throw new Error('ACP model detection aborted');
331
+ const child = config.spawnProcess(config.bin, config.args, {
332
+ cwd: config.cwd,
333
+ stdio: ['pipe', 'pipe', 'pipe'],
334
+ env: { ...config.env },
335
+ });
336
+ child.stdout.setEncoding('utf8');
337
+ child.stderr.setEncoding('utf8');
338
+ const run = {
339
+ config, child, resolve, reject, settled: false, closed: false, stderrBuf: '', stdoutBytes: 0,
340
+ expectedId: 1, timer: null, abort: () => failProbe({ run, message: 'ACP model detection aborted' }),
341
+ };
342
+ config.signal?.addEventListener('abort', run.abort, { once: true });
343
+ wireProbeListeners(run);
344
+ if (config.effectiveTimeoutMs > 0) {
345
+ run.timer = setTimeout(() => {
346
+ failProbe({ run, message: `ACP model detection timed out after ${config.effectiveTimeoutMs}ms` });
347
+ }, config.effectiveTimeoutMs);
348
+ }
349
+ writeProbeRpc(run, { id: 1, method: 'initialize', params: {
321
350
  protocolVersion: ACP_PROTOCOL_VERSION,
322
351
  clientCapabilities: { terminal: false },
323
- clientInfo: { name: clientName, version: clientVersion },
324
- });
325
- });
352
+ clientInfo: { name: config.clientName, version: config.clientVersion },
353
+ } });
326
354
  }
327
355
  /**
328
356
  * Ends a finished probe and completes after close, or after exit plus a pipe-drain grace.
@@ -378,7 +406,7 @@ function finishAcpProbeProcess({ child, complete }, _optionalArgs = {}) {
378
406
  export async function detectAcpModelMetadata(requiredArgs, optionalArgs = {}) {
379
407
  let currentModelId = null;
380
408
  const models = await detectAcpModels(requiredArgs, { ...optionalArgs, onSessionResult: (result) => {
381
- currentModelId = currentModelFromSessionResult(result);
409
+ currentModelId = currentModelFromSessionResult({ result });
382
410
  optionalArgs.onSessionResult?.(result);
383
411
  } });
384
412
  return { models: models.filter((model) => model.id !== 'default').map((model) => {
@@ -4,7 +4,7 @@
4
4
  * acp/types and acp/json; consumed by acp/session.ts and acp/models.ts.
5
5
  */
6
6
  import type { JsonRpcId, RpcWritable } from './types.js';
7
- import type { RuntimeBuildOptions } from '../../types.js';
7
+ import type { RuntimeBuildOptions } from '@jini-ai/core/contracts/agents';
8
8
  /**
9
9
  * Writes a JSON-RPC 2.0 request frame to `writable` as a single newline-terminated
10
10
  * line. Used to send ACP method calls (e.g. `initialize`, `session/new`,
@@ -15,7 +15,12 @@ import type { RuntimeBuildOptions } from '../../types.js';
15
15
  * @param method - The RPC method name.
16
16
  * @param params - The method parameter payload (any JSON-serialisable value).
17
17
  */
18
- export declare function sendRpc(writable: RpcWritable, id: JsonRpcId, method: string, params: unknown): void;
18
+ export declare function sendRpc({ writable, id, method, params }: {
19
+ writable: RpcWritable;
20
+ id: JsonRpcId;
21
+ method: string;
22
+ params: unknown;
23
+ }, _optional?: Record<string, never>): void;
19
24
  /**
20
25
  * Writes a JSON-RPC 2.0 result response frame to `writable`. Used to reply to
21
26
  * incoming `session/request_permission` calls from an ACP agent.
@@ -24,7 +29,17 @@ export declare function sendRpc(writable: RpcWritable, id: JsonRpcId, method: st
24
29
  * @param id - The id from the incoming request being answered.
25
30
  * @param result - The result payload to include in the response.
26
31
  */
27
- export declare function sendRpcResult(writable: RpcWritable, id: JsonRpcId, result: unknown): void;
32
+ export declare function sendRpcResult({ writable, id, result }: {
33
+ writable: RpcWritable;
34
+ id: JsonRpcId;
35
+ result: unknown;
36
+ }, _optional?: Record<string, never>): void;
37
+ export declare function sendRpcError({ writable, id, code, message }: {
38
+ writable: RpcWritable;
39
+ id: JsonRpcId;
40
+ code: number;
41
+ message: string;
42
+ }, _optional?: Record<string, never>): void;
28
43
  /**
29
44
  * Type guard that returns `true` when `value` is a valid JSON-RPC id
30
45
  * (a `number` or `string`). Used before replying to incoming requests.
@@ -38,7 +53,9 @@ export declare function isJsonRpcId(value: unknown): value is JsonRpcId;
38
53
  * @param raw - A parsed JSON-RPC response object (unknown shape).
39
54
  * @returns A non-empty error message string, or `''` when not an error response.
40
55
  */
41
- export declare function rpcErrorMessage(raw: unknown): string;
56
+ export declare function rpcErrorMessage({ raw }: {
57
+ raw: unknown;
58
+ }, _optional?: Record<string, never>): string;
42
59
  /**
43
60
  * Extracts the structured `data` field from a JSON-RPC error response's `error`
44
61
  * object, if present. Used to retrieve typed failure details (e.g. `retryable`,
@@ -47,7 +64,9 @@ export declare function rpcErrorMessage(raw: unknown): string;
47
64
  * @param raw - A parsed JSON-RPC response object (unknown shape).
48
65
  * @returns The `error.data` value, or `undefined` when absent.
49
66
  */
50
- export declare function rpcErrorData(raw: unknown): unknown;
67
+ export declare function rpcErrorData({ raw }: {
68
+ raw: unknown;
69
+ }, _optional?: Record<string, never>): unknown;
51
70
  /**
52
71
  * Reads the `retryable` boolean from a structured RPC error `data` payload.
53
72
  * Returns `undefined` when the field is absent so callers can distinguish
@@ -55,7 +74,9 @@ export declare function rpcErrorData(raw: unknown): unknown;
55
74
  *
56
75
  * @param data - The value of `error.data` extracted via `rpcErrorData`.
57
76
  */
58
- export declare function rpcErrorRetryable(data: unknown): boolean | undefined;
77
+ export declare function rpcErrorRetryable({ data }: {
78
+ data: unknown;
79
+ }, _optional?: Record<string, never>): boolean | undefined;
59
80
  /**
60
81
  * Promotes an opencode `ROLE_MARKER_HALLUCINATION` error embedded in an ACP
61
82
  * JSON-RPC `error.data` payload into a canonical, structured error object.
@@ -67,7 +88,10 @@ export declare function rpcErrorRetryable(data: unknown): boolean | undefined;
67
88
  * @param fallbackMessage - Used when the payload's `message` field is blank.
68
89
  * @returns A structured error payload, or `null` when not applicable.
69
90
  */
70
- export declare function promotedOpenCodeSessionErrorPayload(data: unknown, fallbackMessage: string): {
91
+ export declare function promotedOpenCodeSessionErrorPayload({ data, fallbackMessage }: {
92
+ data: unknown;
93
+ fallbackMessage: string;
94
+ }, _optional?: Record<string, never>): {
71
95
  message: string;
72
96
  error: {
73
97
  code: string;
@@ -95,7 +119,9 @@ export interface FormattedUsage {
95
119
  * @param usage - The raw `result.usage` value from a `session/prompt` response.
96
120
  * @returns A `FormattedUsage` object with at least one field, or `null`.
97
121
  */
98
- export declare function formatUsage(usage: unknown): FormattedUsage | null;
122
+ export declare function formatUsage({ usage }: {
123
+ usage: unknown;
124
+ }, _optional?: Record<string, never>): FormattedUsage | null;
99
125
  /**
100
126
  * Selects the best permission-outcome `optionId` to reply with when an ACP
101
127
  * agent sends a `session/request_permission` request. Bypass permits only
@@ -107,5 +133,7 @@ export declare function formatUsage(usage: unknown): FormattedUsage | null;
107
133
  * @returns An offered `optionId`, or `null` when no safe choice exists.
108
134
  * @complexity O(n) time and O(1) space for n offered options.
109
135
  */
110
- export declare function choosePermissionOutcome(options: unknown, policy?: Pick<RuntimeBuildOptions, 'permissionMode' | 'cliParity'>): string | null;
136
+ export declare function choosePermissionOutcome({ options }: {
137
+ options: unknown;
138
+ }, policy?: Pick<RuntimeBuildOptions, 'permissionMode' | 'cliParity'>): string | null;
111
139
  //# sourceMappingURL=rpc.d.ts.map
@@ -9,7 +9,7 @@ import { asObject } from './json.js';
9
9
  * @param method - The RPC method name.
10
10
  * @param params - The method parameter payload (any JSON-serialisable value).
11
11
  */
12
- export function sendRpc(writable, id, method, params) {
12
+ export function sendRpc({ writable, id, method, params }, _optional = {}) {
13
13
  writable.write(`${JSON.stringify({ jsonrpc: '2.0', id, method, params })}\n`);
14
14
  }
15
15
  /**
@@ -20,9 +20,12 @@ export function sendRpc(writable, id, method, params) {
20
20
  * @param id - The id from the incoming request being answered.
21
21
  * @param result - The result payload to include in the response.
22
22
  */
23
- export function sendRpcResult(writable, id, result) {
23
+ export function sendRpcResult({ writable, id, result }, _optional = {}) {
24
24
  writable.write(`${JSON.stringify({ jsonrpc: '2.0', id, result })}\n`);
25
25
  }
26
+ export function sendRpcError({ writable, id, code, message }, _optional = {}) {
27
+ writable.write(`${JSON.stringify({ jsonrpc: '2.0', id, error: { code, message } })}\n`);
28
+ }
26
29
  /**
27
30
  * Type guard that returns `true` when `value` is a valid JSON-RPC id
28
31
  * (a `number` or `string`). Used before replying to incoming requests.
@@ -38,9 +41,9 @@ export function isJsonRpcId(value) {
38
41
  * @param raw - A parsed JSON-RPC response object (unknown shape).
39
42
  * @returns A non-empty error message string, or `''` when not an error response.
40
43
  */
41
- export function rpcErrorMessage(raw) {
42
- const obj = asObject(raw);
43
- const error = asObject(obj?.error);
44
+ export function rpcErrorMessage({ raw }, _optional = {}) {
45
+ const obj = asObject({ value: raw });
46
+ const error = asObject({ value: obj?.error });
44
47
  if (!obj || !error) {
45
48
  return '';
46
49
  }
@@ -58,9 +61,9 @@ export function rpcErrorMessage(raw) {
58
61
  * @param raw - A parsed JSON-RPC response object (unknown shape).
59
62
  * @returns The `error.data` value, or `undefined` when absent.
60
63
  */
61
- export function rpcErrorData(raw) {
62
- const obj = asObject(raw);
63
- const error = asObject(obj?.error);
64
+ export function rpcErrorData({ raw }, _optional = {}) {
65
+ const obj = asObject({ value: raw });
66
+ const error = asObject({ value: obj?.error });
64
67
  return error && 'data' in error ? error.data : undefined;
65
68
  }
66
69
  /**
@@ -70,8 +73,8 @@ export function rpcErrorData(raw) {
70
73
  *
71
74
  * @param data - The value of `error.data` extracted via `rpcErrorData`.
72
75
  */
73
- export function rpcErrorRetryable(data) {
74
- const details = asObject(data);
76
+ export function rpcErrorRetryable({ data }, _optional = {}) {
77
+ const details = asObject({ value: data });
75
78
  return typeof details?.retryable === 'boolean' ? details.retryable : undefined;
76
79
  }
77
80
  /**
@@ -85,8 +88,8 @@ export function rpcErrorRetryable(data) {
85
88
  * @param fallbackMessage - Used when the payload's `message` field is blank.
86
89
  * @returns A structured error payload, or `null` when not applicable.
87
90
  */
88
- export function promotedOpenCodeSessionErrorPayload(data, fallbackMessage) {
89
- const details = asObject(data);
91
+ export function promotedOpenCodeSessionErrorPayload({ data, fallbackMessage }, _optional = {}) {
92
+ const details = asObject({ value: data });
90
93
  if (details?.kind !== 'opencode_session_error' ||
91
94
  details.source !== 'opencode' ||
92
95
  details.code !== 'ROLE_MARKER_HALLUCINATION') {
@@ -117,8 +120,8 @@ export function promotedOpenCodeSessionErrorPayload(data, fallbackMessage) {
117
120
  * @param usage - The raw `result.usage` value from a `session/prompt` response.
118
121
  * @returns A `FormattedUsage` object with at least one field, or `null`.
119
122
  */
120
- export function formatUsage(usage) {
121
- const src = asObject(usage);
123
+ export function formatUsage({ usage }, _optional = {}) {
124
+ const src = asObject({ value: usage });
122
125
  if (!src)
123
126
  return null;
124
127
  const out = {};
@@ -146,13 +149,13 @@ export function formatUsage(usage) {
146
149
  * @returns An offered `optionId`, or `null` when no safe choice exists.
147
150
  * @complexity O(n) time and O(1) space for n offered options.
148
151
  */
149
- export function choosePermissionOutcome(options, policy = {}) {
152
+ export function choosePermissionOutcome({ options }, policy = {}) {
150
153
  const list = Array.isArray(options) ? options : [];
151
154
  const bypassKinds = policy.cliParity ? ['allow_once', 'allow_always', 'reject_once', 'reject_always'] : ['allow_once', 'reject_once', 'reject_always'];
152
155
  const kinds = policy.permissionMode === 'bypass' ? bypassKinds : ['reject_once', 'reject_always'];
153
156
  for (const kind of kinds) {
154
157
  const option = list.find((value) => {
155
- const record = asObject(value);
158
+ const record = asObject({ value });
156
159
  return record?.kind === kind && typeof record.optionId === 'string' && record.optionId.length > 0;
157
160
  });
158
161
  if (option)
@@ -53,5 +53,8 @@ export declare function buildAcpSessionNewParams({ cwd }: {
53
53
  * @param imagePaths - Optional image attachment paths to append.
54
54
  * @returns An array of prompt blocks ready for inclusion in `session/prompt` params.
55
55
  */
56
- export declare function buildPromptBlocks(prompt: string, imagePaths: string[]): Array<Record<string, string>>;
56
+ export declare function buildPromptBlocks({ prompt, imagePaths }: {
57
+ prompt: string;
58
+ imagePaths: string[];
59
+ }, _optional?: Record<string, never>): Array<Record<string, string>>;
57
60
  //# sourceMappingURL=session-params.d.ts.map
@@ -73,7 +73,7 @@ function normalizeMcpEnv({ rawEnv, wantsMap }) {
73
73
  * @param imagePaths - Optional image attachment paths to append.
74
74
  * @returns An array of prompt blocks ready for inclusion in `session/prompt` params.
75
75
  */
76
- export function buildPromptBlocks(prompt, imagePaths) {
76
+ export function buildPromptBlocks({ prompt, imagePaths }, _optional = {}) {
77
77
  const blocks = [{ type: 'text', text: prompt }];
78
78
  for (const imagePath of imagePaths) {
79
79
  if (typeof imagePath !== 'string' || imagePath.trim().length === 0)
@@ -0,0 +1,13 @@
1
+ /** @module agent-protocol/acp/session-permission
2
+ * Answers an ACP agent's `session/request_permission` calls for one attached
3
+ * session: well-formed option filtering, the default policy, the injected
4
+ * `onPermissionRequest` handler, and fail-closed cancellation. Split out of
5
+ * `session-run.ts` to keep each module under the file-size limit.
6
+ */
7
+ import type { UnknownRecord } from './types.js';
8
+ import { type AcpRun } from './session-run.js';
9
+ export declare function replyPermission({ run, raw }: {
10
+ run: AcpRun;
11
+ raw: UnknownRecord;
12
+ }, _optional?: Record<string, never>): void;
13
+ //# sourceMappingURL=session-permission.d.ts.map