@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
@@ -33,9 +33,9 @@ export declare const MAX_IMAGE_COUNT = 10;
33
33
  /** Total byte ceiling for all images forwarded in one prompt turn. */
34
34
  export declare const MAX_TOTAL_IMAGE_BYTES: number;
35
35
  /** File extensions accepted in pi's `images` RPC field. */
36
- export declare const ALLOWED_IMAGE_EXTENSIONS: Set<string>;
36
+ export declare const ALLOWED_IMAGE_EXTENSIONS: ReadonlySet<string>;
37
37
  /** Extension UI methods that expect no response — silently consumed without reply. */
38
- export declare const FIRE_AND_FORGET_METHODS: Set<string>;
38
+ export declare const FIRE_AND_FORGET_METHODS: ReadonlySet<string>;
39
39
  /**
40
40
  * Writes a JSON-RPC response to pi's stdin for an `extension_ui_request` event,
41
41
  * keeping pi unblocked without surfacing an interactive dialog to the daemon caller.
@@ -45,8 +45,13 @@ export declare const FIRE_AND_FORGET_METHODS: Set<string>;
45
45
  * @param writable - The child process stdin stream.
46
46
  * @param raw - The parsed `extension_ui_request` RPC object from pi's stdout.
47
47
  */
48
- export declare function firstDialogOptionResult(opts: unknown): Record<string, unknown>;
49
- export declare function replyExtensionUi(writable: Writable, raw: JsonRecord): void;
48
+ export declare function firstDialogOptionResult({ opts }: {
49
+ opts: unknown;
50
+ }, _optional?: Record<string, never>): Record<string, unknown>;
51
+ export declare function replyExtensionUi({ writable, raw }: {
52
+ writable: Writable;
53
+ raw: JsonRecord;
54
+ }, _optional?: Record<string, never>): void;
50
55
  /** Snapshot of `.pi/sessions/` file metadata taken before a prompt is sent. */
51
56
  export type PiSessionFileSnapshot = Map<string, {
52
57
  mtimeMs: number;
@@ -59,7 +64,9 @@ export type PiSessionFileSnapshot = Map<string, {
59
64
  *
60
65
  * @param cwd - Absolute path to the pi working directory; may be undefined.
61
66
  */
62
- export declare function readPiSessionFiles(cwd: string | undefined): Array<{
67
+ export declare function readPiSessionFiles({ cwd }: {
68
+ cwd: string | undefined;
69
+ }, _optional?: Record<string, never>): Array<{
63
70
  path: string;
64
71
  mtimeMs: number;
65
72
  size: number;
@@ -70,7 +77,9 @@ export declare function readPiSessionFiles(cwd: string | undefined): Array<{
70
77
  *
71
78
  * @param cwd - Absolute path to the pi working directory; may be undefined.
72
79
  */
73
- export declare function snapshotPiSessionFiles(cwd: string | undefined): PiSessionFileSnapshot;
80
+ export declare function snapshotPiSessionFiles({ cwd }: {
81
+ cwd: string | undefined;
82
+ }, _optional?: Record<string, never>): PiSessionFileSnapshot;
74
83
  /**
75
84
  * Compares the current `.pi/sessions/` directory against a before-snapshot
76
85
  * and returns the path of the single changed file. Returns `null` when zero
@@ -81,9 +90,17 @@ export declare function snapshotPiSessionFiles(cwd: string | undefined): PiSessi
81
90
  * @param before - Snapshot taken before the prompt was sent.
82
91
  * @returns Absolute path of the changed session file, or `null`.
83
92
  */
84
- export declare function resolveSessionPathChangedSince(cwd: string | undefined, before: PiSessionFileSnapshot): string | null;
85
- export declare function piImageMimeType(ext: string): string;
86
- export declare function isPathUnderRoot(realPath: string, resolvedRoot: string): boolean;
93
+ export declare function resolveSessionPathChangedSince({ cwd, before }: {
94
+ cwd: string | undefined;
95
+ before: PiSessionFileSnapshot;
96
+ }, _optional?: Record<string, never>): string | null;
97
+ export declare function piImageMimeType({ ext }: {
98
+ ext: string;
99
+ }, _optional?: Record<string, never>): string;
100
+ export declare function isPathUnderRoot({ realPath, resolvedRoot }: {
101
+ realPath: string;
102
+ resolvedRoot: string;
103
+ }, _optional?: Record<string, never>): boolean;
87
104
  /**
88
105
  * Validates and reads one candidate image path for pi's `images` prompt
89
106
  * field: resolves symlinks, re-verifies the resolved path is a regular file
@@ -91,7 +108,11 @@ export declare function isPathUnderRoot(realPath: string, resolvedRoot: string):
91
108
  * remaining total-byte budget. Returns `null` for any rejection or read
92
109
  * failure rather than throwing, so one bad image never fails the whole run.
93
110
  */
94
- export declare function tryReadImagePayload(imgPath: unknown, uploadRoot: string | undefined, totalBytesSoFar: number): {
111
+ export declare function tryReadImagePayload({ imgPath, uploadRoot, totalBytesSoFar }: {
112
+ imgPath: unknown;
113
+ uploadRoot: string | undefined;
114
+ totalBytesSoFar: number;
115
+ }, _optional?: Record<string, never>): {
95
116
  payload: PiImagePayload;
96
117
  size: number;
97
118
  } | null;
@@ -102,7 +123,10 @@ export declare function tryReadImagePayload(imgPath: unknown, uploadRoot: string
102
123
  * daemon's safeImages guard already validated that each path exists under
103
124
  * UPLOAD_DIR; see {@link tryReadImagePayload} for the per-path re-checks.
104
125
  */
105
- export declare function buildPiImagePayloads(imagePaths: string[] | undefined, uploadRoot: string | undefined): PiImagePayload[];
126
+ export declare function buildPiImagePayloads({ imagePaths, uploadRoot }: {
127
+ imagePaths: string[] | undefined;
128
+ uploadRoot: string | undefined;
129
+ }, _optional?: Record<string, never>): PiImagePayload[];
106
130
  /**
107
131
  * Routes one `response`-type frame from pi's RPC stdout: a rejected parent
108
132
  * session fails the run immediately (a resumed turn must not continue
@@ -119,7 +143,7 @@ export declare function handlePiResponseMessage({ raw, parentSessionRpcId, promp
119
143
  promptRpcId: number | null;
120
144
  fail: (message: string, code?: string) => void;
121
145
  sendPromptCommand: () => void;
122
- }): void;
146
+ }, _optional?: Record<string, never>): void;
123
147
  /**
124
148
  * Attaches the daemon's run lifecycle to an already-spawned `pi --mode rpc` child process.
125
149
  *
@@ -34,15 +34,15 @@ export const FIRE_AND_FORGET_METHODS = new Set([
34
34
  * @param raw - The parsed `extension_ui_request` RPC object from pi's stdout.
35
35
  */
36
36
  // select: pick the first option if available, else cancel.
37
- export function firstDialogOptionResult(opts) {
37
+ export function firstDialogOptionResult({ opts }, _optional = {}) {
38
38
  if (!Array.isArray(opts) || opts.length === 0)
39
39
  return { cancelled: true };
40
40
  const first = opts[0];
41
41
  return typeof first === 'string'
42
42
  ? { value: first }
43
- : { value: getRecord(first)?.label ?? getRecord(first)?.value ?? '' };
43
+ : { value: getRecord({ value: first })?.label ?? getRecord({ value: first })?.value ?? '' };
44
44
  }
45
- export function replyExtensionUi(writable, raw) {
45
+ export function replyExtensionUi({ writable, raw }, _optional = {}) {
46
46
  if (raw?.id == null)
47
47
  return;
48
48
  // Fire-and-forget: no response expected. Silently consume.
@@ -52,7 +52,7 @@ export function replyExtensionUi(writable, raw) {
52
52
  // confirm → true, select/input/editor → empty-ish default
53
53
  const result = raw.method === 'confirm'
54
54
  ? { confirmed: true }
55
- : firstDialogOptionResult(getRecord(raw.params)?.options ?? raw.options);
55
+ : firstDialogOptionResult({ opts: getRecord({ value: raw.params })?.options ?? raw.options });
56
56
  writable.write(`${JSON.stringify({ type: 'extension_ui_response', id: raw.id, ...result })}\n`);
57
57
  }
58
58
  /**
@@ -62,7 +62,7 @@ export function replyExtensionUi(writable, raw) {
62
62
  *
63
63
  * @param cwd - Absolute path to the pi working directory; may be undefined.
64
64
  */
65
- export function readPiSessionFiles(cwd) {
65
+ export function readPiSessionFiles({ cwd }, _optional = {}) {
66
66
  if (typeof cwd !== 'string' || cwd.length === 0)
67
67
  return [];
68
68
  const sessionsDir = path.join(cwd, '.pi', 'sessions');
@@ -94,9 +94,9 @@ export function readPiSessionFiles(cwd) {
94
94
  *
95
95
  * @param cwd - Absolute path to the pi working directory; may be undefined.
96
96
  */
97
- export function snapshotPiSessionFiles(cwd) {
97
+ export function snapshotPiSessionFiles({ cwd }, _optional = {}) {
98
98
  const snapshot = new Map();
99
- for (const file of readPiSessionFiles(cwd)) {
99
+ for (const file of readPiSessionFiles({ cwd })) {
100
100
  snapshot.set(file.path, { mtimeMs: file.mtimeMs, size: file.size });
101
101
  }
102
102
  return snapshot;
@@ -111,8 +111,8 @@ export function snapshotPiSessionFiles(cwd) {
111
111
  * @param before - Snapshot taken before the prompt was sent.
112
112
  * @returns Absolute path of the changed session file, or `null`.
113
113
  */
114
- export function resolveSessionPathChangedSince(cwd, before) {
115
- const changed = readPiSessionFiles(cwd).filter((file) => {
114
+ export function resolveSessionPathChangedSince({ cwd, before }, _optional = {}) {
115
+ const changed = readPiSessionFiles({ cwd }).filter((file) => {
116
116
  const previous = before.get(file.path);
117
117
  return !previous || file.mtimeMs > previous.mtimeMs || file.size !== previous.size;
118
118
  });
@@ -121,7 +121,7 @@ export function resolveSessionPathChangedSince(cwd, before) {
121
121
  // never actually be exercised.
122
122
  return changed.length === 1 ? changed[0].path : null;
123
123
  }
124
- export function piImageMimeType(ext) {
124
+ export function piImageMimeType({ ext }, _optional = {}) {
125
125
  if (ext === '.png')
126
126
  return 'image/png';
127
127
  if (ext === '.gif')
@@ -137,7 +137,7 @@ export function piImageMimeType(ext) {
137
137
  // Exported for direct testing: the `+ path.sep` is load-bearing and easy to
138
138
  // drop in a later edit, so it is pinned by its own unit test rather than only
139
139
  // exercised through `tryReadImagePayload`.
140
- export function isPathUnderRoot(realPath, resolvedRoot) {
140
+ export function isPathUnderRoot({ realPath, resolvedRoot }, _optional = {}) {
141
141
  return realPath === resolvedRoot || realPath.startsWith(resolvedRoot + path.sep);
142
142
  }
143
143
  /**
@@ -147,7 +147,7 @@ export function isPathUnderRoot(realPath, resolvedRoot) {
147
147
  * remaining total-byte budget. Returns `null` for any rejection or read
148
148
  * failure rather than throwing, so one bad image never fails the whole run.
149
149
  */
150
- export function tryReadImagePayload(imgPath, uploadRoot, totalBytesSoFar) {
150
+ export function tryReadImagePayload({ imgPath, uploadRoot, totalBytesSoFar }, _optional = {}) {
151
151
  if (typeof imgPath !== 'string' || !imgPath.length)
152
152
  return null;
153
153
  try {
@@ -158,7 +158,7 @@ export function tryReadImagePayload(imgPath, uploadRoot, totalBytesSoFar) {
158
158
  return null;
159
159
  if (uploadRoot) {
160
160
  const resolvedRoot = fs.realpathSync(uploadRoot);
161
- if (!isPathUnderRoot(realPath, resolvedRoot))
161
+ if (!isPathUnderRoot({ realPath, resolvedRoot }))
162
162
  return null;
163
163
  }
164
164
  const ext = path.extname(realPath).toLowerCase();
@@ -169,7 +169,7 @@ export function tryReadImagePayload(imgPath, uploadRoot, totalBytesSoFar) {
169
169
  return null;
170
170
  const buf = fs.readFileSync(realPath);
171
171
  return {
172
- payload: { type: 'image', data: buf.toString('base64'), mimeType: piImageMimeType(ext) },
172
+ payload: { type: 'image', data: buf.toString('base64'), mimeType: piImageMimeType({ ext }) },
173
173
  size: stat.size,
174
174
  };
175
175
  }
@@ -187,7 +187,7 @@ export function tryReadImagePayload(imgPath, uploadRoot, totalBytesSoFar) {
187
187
  * daemon's safeImages guard already validated that each path exists under
188
188
  * UPLOAD_DIR; see {@link tryReadImagePayload} for the per-path re-checks.
189
189
  */
190
- export function buildPiImagePayloads(imagePaths, uploadRoot) {
190
+ export function buildPiImagePayloads({ imagePaths, uploadRoot }, _optional = {}) {
191
191
  const images = [];
192
192
  if (!Array.isArray(imagePaths) || imagePaths.length === 0)
193
193
  return images;
@@ -195,7 +195,7 @@ export function buildPiImagePayloads(imagePaths, uploadRoot) {
195
195
  for (const imgPath of imagePaths) {
196
196
  if (images.length >= MAX_IMAGE_COUNT)
197
197
  break;
198
- const read = tryReadImagePayload(imgPath, uploadRoot, totalBytes);
198
+ const read = tryReadImagePayload({ imgPath, uploadRoot, totalBytesSoFar: totalBytes });
199
199
  if (read) {
200
200
  images.push(read.payload);
201
201
  totalBytes += read.size;
@@ -213,7 +213,7 @@ export function buildPiImagePayloads(imagePaths, uploadRoot) {
213
213
  * touches `attachPiRpcSession`'s other session state — so it is directly
214
214
  * testable without spinning up a session.
215
215
  */
216
- export function handlePiResponseMessage({ raw, parentSessionRpcId, promptRpcId, fail, sendPromptCommand, }) {
216
+ export function handlePiResponseMessage({ raw, parentSessionRpcId, promptRpcId, fail, sendPromptCommand, }, _optional = {}) {
217
217
  if (raw.id === parentSessionRpcId) {
218
218
  if (raw.success === false) {
219
219
  fail(`parent session rejected: ${String(raw.error ?? 'unknown')}`, 'PI_PARENT_SESSION_FAILED');
@@ -250,7 +250,8 @@ export function handlePiResponseMessage({ raw, parentSessionRpcId, promptRpcId,
250
250
  * @returns A `PiRpcSession` handle with `hasFatalError`, `getLastSessionPath`, and `abort`.
251
251
  */
252
252
  export function attachPiRpcSession(requiredArgs, optionalArgs = {}) {
253
- const { child, prompt, cwd, model, send, imagePaths, uploadRoot, parentSession, gracefulShutdownMs = 5000, } = { ...optionalArgs, ...requiredArgs };
253
+ const options = { ...optionalArgs, ...requiredArgs };
254
+ const { child, cwd, model, send, imagePaths, uploadRoot, parentSession } = options;
254
255
  const { stdin, stdout } = child;
255
256
  if (stdin === null) {
256
257
  throw new Error('pi RPC child process is missing stdin');
@@ -258,35 +259,11 @@ export function attachPiRpcSession(requiredArgs, optionalArgs = {}) {
258
259
  if (stdout === null) {
259
260
  throw new Error('pi RPC child process is missing stdout');
260
261
  }
261
- const runStartedAt = Date.now();
262
- const sessionFilesBeforePrompt = snapshotPiSessionFiles(cwd);
263
- let finished = false;
264
- let fatal = false;
265
- const sentFirstToken = { value: false };
266
- let capturedSessionPath = null;
267
- let nextRpcId = 1;
268
- let stdinOpen = true;
269
- function sendCommand(writable, type, params = {}) {
270
- if (!stdinOpen)
271
- return null;
272
- const id = nextRpcId;
273
- nextRpcId += 1;
274
- writable.write(`${JSON.stringify({ id, type, ...params })}\n`);
275
- return id;
276
- }
277
- // Track RPC ids so resume and prompt failures are attributed to the right
278
- // request. A resumed turn must not send the trimmed prompt until pi confirms
279
- // it loaded the parent session.
280
- let parentSessionRpcId = null;
281
- let promptRpcId = null;
282
- const fail = (message, code) => {
283
- if (finished)
284
- return;
285
- finished = true;
286
- fatal = true;
287
- send({ event: 'error', payload: { message, ...(code ? { code } : {}) } });
288
- if (!child.killed)
289
- child.kill('SIGTERM');
262
+ const run = {
263
+ options, stdin, runStartedAt: Date.now(), sessionFilesBeforePrompt: snapshotPiSessionFiles({ cwd }),
264
+ finished: false, fatal: false, sentFirstToken: { value: false }, capturedSessionPath: null,
265
+ nextRpcId: 1, stdinOpen: true, parentSessionRpcId: null, promptRpcId: null,
266
+ images: [],
290
267
  };
291
268
  // Emit initial status with model name immediately — before pi even
292
269
  // responds — so the UI header shows the model name at session start.
@@ -295,28 +272,12 @@ export function attachPiRpcSession(requiredArgs, optionalArgs = {}) {
295
272
  label: 'initializing',
296
273
  model: typeof model === 'string' && model ? model : null,
297
274
  } });
298
- // ---- Outbound: send new_session (if parentSession provided) then prompt via RPC ----
299
- stdin.on('error', (err) => {
300
- if (errorCode(err) !== 'EPIPE') {
301
- fail(`stdin: ${errorMessage(err)}`);
302
- }
303
- });
304
- stdin.on('close', () => {
305
- stdinOpen = false;
306
- });
307
- // If a prior session file path is provided, send new_session with
308
- // parentSession so pi loads the prior conversation history into the
309
- // new session, enabling conversational continuity across edit rounds.
275
+ wirePiStdin(run);
310
276
  // Build the images array for pi's prompt command. pi's RPC protocol
311
277
  // accepts `images` as an array of {type, data, mimeType} objects where
312
278
  // `data` is base64-encoded file contents.
313
- const images = buildPiImagePayloads(imagePaths, uploadRoot);
314
- const sendPromptCommand = () => {
315
- promptRpcId = sendCommand(stdin, 'prompt', {
316
- message: prompt,
317
- ...(images.length > 0 ? { images } : {}),
318
- });
319
- };
279
+ run.images = buildPiImagePayloads({ imagePaths, uploadRoot });
280
+ // ---- Outbound: send new_session (if parentSession provided) then prompt via RPC ----
320
281
  // If a prior session file path is provided, send new_session with
321
282
  // parentSession so pi loads the prior conversation history into the
322
283
  // new session, enabling conversational continuity across edit rounds.
@@ -324,85 +285,136 @@ export function attachPiRpcSession(requiredArgs, optionalArgs = {}) {
324
285
  // intentionally contain only the latest user turn, so continuing after a
325
286
  // failed parent load would silently drop prior conversation context.
326
287
  if (parentSession) {
327
- parentSessionRpcId = sendCommand(stdin, 'new_session', { parentSession });
288
+ run.parentSessionRpcId = sendPiCommand({ run, type: 'new_session' }, { params: { parentSession } });
328
289
  }
329
290
  else {
330
- sendPromptCommand();
291
+ sendPiPrompt(run);
331
292
  }
332
- const handlePiAgentEnd = () => {
333
- finished = true;
334
- // Capture only the session file changed by this run. If another pi
335
- // process wrote to the shared session directory concurrently, the
336
- // resolver returns null instead of risking cross-conversation resume.
337
- capturedSessionPath = resolveSessionPathChangedSince(cwd, sessionFilesBeforePrompt);
338
- // pi's RPC process stays alive after agent_end (designed for
339
- // multi-prompt sessions). The daemon's /api/chat is single-shot,
340
- // so close stdin and let the process exit naturally, or kill it
341
- // after a grace period.
342
- try {
343
- stdin.end();
344
- }
345
- catch (err) {
346
- fail(`stdin close: ${errorMessage(err)}`);
293
+ wirePiOutput({ run, child, stdout });
294
+ return buildPiRpcSession(run);
295
+ }
296
+ function sendPiCommand({ run, type }, { params = {} } = {}) {
297
+ if (!run.stdinOpen)
298
+ return null;
299
+ const id = run.nextRpcId;
300
+ run.nextRpcId += 1;
301
+ run.stdin.write(`${JSON.stringify({ id, type, ...params })}\n`);
302
+ return id;
303
+ }
304
+ function sendPiPrompt(run) {
305
+ run.promptRpcId = sendPiCommand({ run, type: 'prompt' }, {
306
+ params: {
307
+ message: run.options.prompt,
308
+ ...(run.images.length > 0 ? { images: run.images } : {}),
309
+ },
310
+ });
311
+ }
312
+ function failPi({ run, message }, { code } = {}) {
313
+ if (run.finished)
314
+ return;
315
+ run.finished = true;
316
+ run.fatal = true;
317
+ run.options.send({ event: 'error', payload: { message, ...(code ? { code } : {}) } });
318
+ if (!run.options.child.killed)
319
+ run.options.child.kill('SIGTERM');
320
+ }
321
+ function wirePiStdin(run) {
322
+ run.stdin.on('error', (err) => {
323
+ if (errorCode({ err }) !== 'EPIPE') {
324
+ failPi({ run, message: `stdin: ${errorMessage({ err })}` });
347
325
  }
348
- // Grace period before SIGTERM lets resource-constrained machines drain a slow event loop.
349
- // The host supplies timing explicitly, resolving PI_GRACEFUL_SHUTDOWN_MS at composition.
350
- setTimeout(() => {
351
- if (!child.killed)
352
- child.kill('SIGTERM');
353
- }, gracefulShutdownMs);
354
- };
355
- // ---- Inbound: parse stdout events ----
356
- const parser = createJsonLineStream({ onError: error => fail(`parser: ${error.message}`), onMessage: ({ message: raw }) => {
357
- if (!isRecord(raw))
358
- return;
359
- // Once finished (agent_end or abort), stop processing — the run is
360
- // over, so no more agent events should be emitted. We still drain
361
- // stdout via parser.feed() so the pipe doesn't break; we just skip
362
- // acting on the parsed objects.
363
- if (finished)
364
- return;
365
- // Extension UI requests: auto-resolve to keep pi unblocked.
366
- if (raw.type === 'extension_ui_request') {
367
- replyExtensionUi(stdin, raw);
368
- return;
369
- }
370
- if (raw.type === 'response') {
371
- handlePiResponseMessage({ raw, parentSessionRpcId, promptRpcId, fail, sendPromptCommand });
372
- return;
373
- }
374
- // Agent events: delegate to the pure mapper.
375
- const result = mapPiRpcEvent({ raw: raw, send: send, ctx: { runStartedAt, sentFirstToken } });
376
- if (result === 'agent_end') {
377
- handlePiAgentEnd();
378
- }
379
- } });
326
+ });
327
+ run.stdin.on('close', () => {
328
+ run.stdinOpen = false;
329
+ });
330
+ }
331
+ function handlePiAgentEnd(run) {
332
+ const { child, cwd, gracefulShutdownMs = 5000 } = run.options;
333
+ run.finished = true;
334
+ // Capture only the session file changed by this run. If another pi
335
+ // process wrote to the shared session directory concurrently, the
336
+ // resolver returns null instead of risking cross-conversation resume.
337
+ run.capturedSessionPath = resolveSessionPathChangedSince({ cwd, before: run.sessionFilesBeforePrompt });
338
+ // pi's RPC process stays alive after agent_end (designed for
339
+ // multi-prompt sessions). The daemon's /api/chat is single-shot,
340
+ // so close stdin and let the process exit naturally, or kill it
341
+ // after a grace period.
342
+ try {
343
+ run.stdin.end();
344
+ }
345
+ catch (err) {
346
+ failPi({ run, message: `stdin close: ${errorMessage({ err })}` });
347
+ }
348
+ // Grace period before SIGTERM lets resource-constrained machines drain a slow event loop.
349
+ // The host supplies timing explicitly, resolving PI_GRACEFUL_SHUTDOWN_MS at composition.
350
+ setTimeout(() => {
351
+ if (!child.killed)
352
+ child.kill('SIGTERM');
353
+ }, gracefulShutdownMs);
354
+ }
355
+ function handlePiMessage({ run, raw }) {
356
+ if (!isRecord(raw))
357
+ return;
358
+ // Once finished (agent_end or abort), stop processing — the run is
359
+ // over, so no more agent events should be emitted. We still drain
360
+ // stdout via parser.feed() so the pipe doesn't break; we just skip
361
+ // acting on the parsed objects.
362
+ if (run.finished)
363
+ return;
364
+ // Extension UI requests: auto-resolve to keep pi unblocked.
365
+ if (raw.type === 'extension_ui_request') {
366
+ replyExtensionUi({ writable: run.stdin, raw });
367
+ return;
368
+ }
369
+ if (raw.type === 'response') {
370
+ handlePiResponseMessage({
371
+ raw,
372
+ parentSessionRpcId: run.parentSessionRpcId,
373
+ promptRpcId: run.promptRpcId,
374
+ fail: (message, code) => failPi({ run, message }, code === undefined ? {} : { code }),
375
+ sendPromptCommand: () => sendPiPrompt(run),
376
+ });
377
+ return;
378
+ }
379
+ // Agent events: delegate to the pure mapper.
380
+ const result = mapPiRpcEvent({ raw: raw, send: run.options.send, ctx: { runStartedAt: run.runStartedAt, sentFirstToken: run.sentFirstToken } });
381
+ if (result === 'agent_end') {
382
+ handlePiAgentEnd(run);
383
+ }
384
+ }
385
+ // ---- Inbound: parse stdout events ----
386
+ function wirePiOutput({ run, child, stdout }) {
387
+ const parser = createJsonLineStream({
388
+ onMessage: ({ message: raw }) => handlePiMessage({ run, raw }),
389
+ }, { onError: error => failPi({ run, message: `parser: ${error.message}` }) });
380
390
  stdout.on('data', (chunk) => {
381
391
  try {
382
392
  parser.feed({ chunk: typeof chunk === 'string' ? chunk : chunk.toString('utf8') });
383
393
  }
384
394
  catch (err) {
385
- fail(`parser: ${errorMessage(err)}`);
395
+ failPi({ run, message: `parser: ${errorMessage({ err })}` });
386
396
  }
387
397
  });
388
398
  stdout.on('close', () => parser.flush());
389
- child.on('error', (err) => fail(errorMessage(err)));
399
+ child.on('error', (err) => failPi({ run, message: errorMessage({ err }) }));
400
+ }
401
+ function buildPiRpcSession(run) {
390
402
  return {
391
403
  hasFatalError() {
392
- return fatal;
404
+ return run.fatal;
393
405
  },
394
406
  getLastSessionPath() {
395
- return capturedSessionPath;
407
+ return run.capturedSessionPath;
396
408
  },
397
409
  abort() {
398
410
  // Send RPC abort so pi can clean up gracefully (flush logs,
399
411
  // finalize session files, etc.). The termination guarantee
400
412
  // (SIGTERM fallback) is owned by the caller (runs.cancel()),
401
413
  // not by this method.
402
- if (finished || child.killed)
414
+ if (run.finished || run.options.child.killed)
403
415
  return;
404
- finished = true;
405
- sendCommand(stdin, 'abort');
416
+ run.finished = true;
417
+ sendPiCommand({ run, type: 'abort' });
406
418
  },
407
419
  };
408
420
  }
@@ -3,7 +3,7 @@
3
3
  * Return cached remote models while refreshing, with static presets on cold start. This caching
4
4
  * pattern also serves other agents with cheap presets and slower authoritative remote catalogs.
5
5
  */
6
- import type { RuntimeModelOption } from './types.js';
6
+ import type { RuntimeModelOption } from '@jini-ai/core/contracts/agents';
7
7
  export type AmrModelsResponse = {
8
8
  source: 'remote' | 'preset';
9
9
  models: RuntimeModelOption[];
@@ -1,5 +1,5 @@
1
1
  import { listProviderModels } from './providers/model-catalog.js';
2
- import type { RuntimeEnv, RuntimeModelOption } from './types.js';
2
+ import type { RuntimeEnv, RuntimeModelOption } from '@jini-ai/core/contracts/agents';
3
3
  /** Test-only reset — this module-scope cache would otherwise leak a stubbed `fetch`'s result across
4
4
  * test cases. */
5
5
  export declare function resetAnthropicLiveModelCacheForTesting(): void;
@@ -19,7 +19,9 @@ export type AnthropicCredential = {
19
19
  * network call whatsoever.
20
20
  * @complexity O(1).
21
21
  */
22
- export declare function resolveAnthropicCredential(env: RuntimeEnv): AnthropicCredential | null;
22
+ export declare function resolveAnthropicCredential({ env }: {
23
+ env: RuntimeEnv;
24
+ }, _optional?: Record<string, never>): AnthropicCredential | null;
23
25
  /**
24
26
  * Appends live-discovered models to the static fallback list.
25
27
  *
@@ -29,7 +31,10 @@ export declare function resolveAnthropicCredential(env: RuntimeEnv): AnthropicCr
29
31
  *
30
32
  * @complexity O(f + l) — one `Set` over the fallback, one pass over the live list.
31
33
  */
32
- export declare function mergeLiveModels(fallback: readonly RuntimeModelOption[], live: readonly RuntimeModelOption[]): RuntimeModelOption[];
34
+ export declare function mergeLiveModels({ fallback, live }: {
35
+ fallback: readonly RuntimeModelOption[];
36
+ live: readonly RuntimeModelOption[];
37
+ }, _optional?: Record<string, never>): RuntimeModelOption[];
33
38
  /**
34
39
  * Returns the Claude model list with the account's live catalog merged in, or `null` when there is
35
40
  * nothing to merge.
Binary file
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_HOST_NAME = "the host application";
2
+ //# sourceMappingURL=auth-common.d.ts.map
@@ -0,0 +1,2 @@
1
+ export const DEFAULT_HOST_NAME = 'the host application';
2
+ //# sourceMappingURL=auth-common.js.map
package/dist/auth.d.ts CHANGED
@@ -1,4 +1,9 @@
1
- import type { RuntimeAgentDef, RuntimeEnv } from './types.js';
1
+ import type { AgentServiceFailureCode, RuntimeAgentDef, RuntimeEnv } from '@jini-ai/core/contracts/agents';
2
+ export { claudeAuthGuidance, isClaudeAuthFailureText } from './defs/claude/auth.js';
3
+ export { cursorAuthGuidance, isCursorAuthFailureText } from './defs/cursor-agent/auth.js';
4
+ export { deepseekAuthGuidance, isDeepSeekAuthFailureText } from './defs/deepseek/auth.js';
5
+ export { antigravityAuthGuidance, antigravityQuotaGuidance, isAntigravityAuthFailureText } from './defs/antigravity/auth.js';
6
+ export { reasonixAuthGuidance, isReasonixAuthFailureText } from './defs/reasonix/auth.js';
2
7
  export type AgentAuthProbeResult = {
3
8
  status: 'ok' | 'missing' | 'unknown';
4
9
  message?: string;
@@ -7,47 +12,15 @@ export type AgentAuthProbeResult = {
7
12
  exitCode?: number | null;
8
13
  signal?: string | null;
9
14
  };
10
- export declare function cursorAuthGuidance({}: {}, { hostName }?: {
11
- hostName?: string;
12
- }): string;
13
- export declare function deepseekAuthGuidance({}: {}, { hostName }?: {
14
- hostName?: string;
15
- }): string;
16
- export declare function antigravityAuthGuidance({}: {}, { hostName }?: {
17
- hostName?: string;
18
- }): string;
19
- export declare function antigravityQuotaGuidance(): string;
20
- export declare function reasonixAuthGuidance({}: {}, { hostName }?: {
21
- hostName?: string;
22
- }): string;
23
- export declare function claudeAuthGuidance({}: {}, { hostName }?: {
24
- hostName?: string;
25
- }): string;
26
- export declare function isCursorAuthFailureText({ text }: {
27
- text: string;
28
- }): boolean;
29
- export declare function isAntigravityAuthFailureText({ text }: {
30
- text: string;
31
- }): boolean;
32
- export declare function isDeepSeekAuthFailureText({ text }: {
33
- text: string;
34
- }): boolean;
35
- export declare function isReasonixAuthFailureText({ text }: {
36
- text: string;
37
- }): boolean;
38
- export declare function isClaudeAuthFailureText({ text }: {
39
- text: string;
40
- }): boolean;
41
15
  export declare function classifyAgentAuthFailure({ agentId, text }: {
42
16
  agentId: string;
43
17
  text: string;
44
18
  }, { hostName }?: {
45
19
  hostName?: string;
46
20
  }): AgentAuthProbeResult | null;
47
- export type AgentServiceFailureCode = 'AGENT_AUTH_REQUIRED' | 'RATE_LIMITED' | 'UPSTREAM_UNAVAILABLE';
48
21
  export declare function classifyAgentServiceFailure({ text }: {
49
22
  text: string;
50
- }): AgentServiceFailureCode | null;
23
+ }, _optional?: Record<string, never>): AgentServiceFailureCode | null;
51
24
  export declare function probeAgentAuthStatus({ def, resolvedBin, env }: {
52
25
  def: Pick<RuntimeAgentDef, 'id' | 'name' | 'authProbe'>;
53
26
  resolvedBin: string;