@agent-native/core 0.15.13 → 0.16.0

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 (411) hide show
  1. package/README.md +37 -0
  2. package/dist/agent/app-model-defaults.d.ts +37 -0
  3. package/dist/agent/app-model-defaults.d.ts.map +1 -0
  4. package/dist/agent/app-model-defaults.js +136 -0
  5. package/dist/agent/app-model-defaults.js.map +1 -0
  6. package/dist/agent/engine/registry.d.ts +12 -7
  7. package/dist/agent/engine/registry.d.ts.map +1 -1
  8. package/dist/agent/engine/registry.js +28 -8
  9. package/dist/agent/engine/registry.js.map +1 -1
  10. package/dist/agent/production-agent.d.ts +2 -0
  11. package/dist/agent/production-agent.d.ts.map +1 -1
  12. package/dist/agent/production-agent.js +3 -1
  13. package/dist/agent/production-agent.js.map +1 -1
  14. package/dist/browser-sessions/actions.d.ts +7 -0
  15. package/dist/browser-sessions/actions.d.ts.map +1 -0
  16. package/dist/browser-sessions/actions.js +223 -0
  17. package/dist/browser-sessions/actions.js.map +1 -0
  18. package/dist/browser-sessions/routes.d.ts +7 -0
  19. package/dist/browser-sessions/routes.d.ts.map +1 -0
  20. package/dist/browser-sessions/routes.js +159 -0
  21. package/dist/browser-sessions/routes.js.map +1 -0
  22. package/dist/browser-sessions/store.d.ts +33 -0
  23. package/dist/browser-sessions/store.d.ts.map +1 -0
  24. package/dist/browser-sessions/store.js +506 -0
  25. package/dist/browser-sessions/store.js.map +1 -0
  26. package/dist/browser-sessions/types.d.ts +68 -0
  27. package/dist/browser-sessions/types.d.ts.map +1 -0
  28. package/dist/browser-sessions/types.js +2 -0
  29. package/dist/browser-sessions/types.js.map +1 -0
  30. package/dist/cli/code-agent-commands.d.ts +36 -0
  31. package/dist/cli/code-agent-commands.d.ts.map +1 -0
  32. package/dist/cli/code-agent-commands.js +192 -0
  33. package/dist/cli/code-agent-commands.js.map +1 -0
  34. package/dist/cli/code-agent-connector.d.ts +17 -0
  35. package/dist/cli/code-agent-connector.d.ts.map +1 -0
  36. package/dist/cli/code-agent-connector.js +724 -0
  37. package/dist/cli/code-agent-connector.js.map +1 -0
  38. package/dist/cli/code-agent-executor.d.ts +31 -0
  39. package/dist/cli/code-agent-executor.d.ts.map +1 -0
  40. package/dist/cli/code-agent-executor.js +921 -0
  41. package/dist/cli/code-agent-executor.js.map +1 -0
  42. package/dist/cli/code-agent-runs.d.ts +102 -0
  43. package/dist/cli/code-agent-runs.d.ts.map +1 -0
  44. package/dist/cli/code-agent-runs.js +277 -0
  45. package/dist/cli/code-agent-runs.js.map +1 -0
  46. package/dist/cli/code.d.ts +66 -0
  47. package/dist/cli/code.d.ts.map +1 -0
  48. package/dist/cli/code.js +1306 -0
  49. package/dist/cli/code.js.map +1 -0
  50. package/dist/cli/create.d.ts +2 -1
  51. package/dist/cli/create.d.ts.map +1 -1
  52. package/dist/cli/create.js +11 -1
  53. package/dist/cli/create.js.map +1 -1
  54. package/dist/cli/index.js +26 -1
  55. package/dist/cli/index.js.map +1 -1
  56. package/dist/cli/migrate.d.ts +27 -0
  57. package/dist/cli/migrate.d.ts.map +1 -1
  58. package/dist/cli/migrate.js +1328 -20
  59. package/dist/cli/migrate.js.map +1 -1
  60. package/dist/cli/templates-meta.d.ts.map +1 -1
  61. package/dist/cli/templates-meta.js +26 -2
  62. package/dist/cli/templates-meta.js.map +1 -1
  63. package/dist/cli/workspacify.d.ts +2 -0
  64. package/dist/cli/workspacify.d.ts.map +1 -1
  65. package/dist/cli/workspacify.js +2 -1
  66. package/dist/cli/workspacify.js.map +1 -1
  67. package/dist/client/AgentNative.d.ts +32 -0
  68. package/dist/client/AgentNative.d.ts.map +1 -0
  69. package/dist/client/AgentNative.js +79 -0
  70. package/dist/client/AgentNative.js.map +1 -0
  71. package/dist/client/AgentNativeEmbedded.d.ts +47 -0
  72. package/dist/client/AgentNativeEmbedded.d.ts.map +1 -0
  73. package/dist/client/AgentNativeEmbedded.js +148 -0
  74. package/dist/client/AgentNativeEmbedded.js.map +1 -0
  75. package/dist/client/AgentNativeFrame.d.ts +25 -0
  76. package/dist/client/AgentNativeFrame.d.ts.map +1 -0
  77. package/dist/client/AgentNativeFrame.js +68 -0
  78. package/dist/client/AgentNativeFrame.js.map +1 -0
  79. package/dist/client/AgentPanel.d.ts +19 -2
  80. package/dist/client/AgentPanel.d.ts.map +1 -1
  81. package/dist/client/AgentPanel.js +15 -4
  82. package/dist/client/AgentPanel.js.map +1 -1
  83. package/dist/client/AssistantChat.d.ts +1 -1
  84. package/dist/client/AssistantChat.d.ts.map +1 -1
  85. package/dist/client/AssistantChat.js +79 -48
  86. package/dist/client/AssistantChat.js.map +1 -1
  87. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  88. package/dist/client/MultiTabAssistantChat.js +2 -1
  89. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  90. package/dist/client/NewWorkspaceAppFlow.d.ts.map +1 -1
  91. package/dist/client/NewWorkspaceAppFlow.js +3 -2
  92. package/dist/client/NewWorkspaceAppFlow.js.map +1 -1
  93. package/dist/client/browser-session-bridge.d.ts +44 -0
  94. package/dist/client/browser-session-bridge.d.ts.map +1 -0
  95. package/dist/client/browser-session-bridge.js +339 -0
  96. package/dist/client/browser-session-bridge.js.map +1 -0
  97. package/dist/client/client-action.d.ts +7 -0
  98. package/dist/client/client-action.d.ts.map +1 -0
  99. package/dist/client/client-action.js +4 -0
  100. package/dist/client/client-action.js.map +1 -0
  101. package/dist/client/components/ui/tooltip.d.ts.map +1 -1
  102. package/dist/client/components/ui/tooltip.js +1 -1
  103. package/dist/client/components/ui/tooltip.js.map +1 -1
  104. package/dist/client/composer/AgentComposerFrame.d.ts +17 -0
  105. package/dist/client/composer/AgentComposerFrame.d.ts.map +1 -0
  106. package/dist/client/composer/AgentComposerFrame.js +14 -0
  107. package/dist/client/composer/AgentComposerFrame.js.map +1 -0
  108. package/dist/client/composer/MentionPopover.d.ts.map +1 -1
  109. package/dist/client/composer/MentionPopover.js +2 -2
  110. package/dist/client/composer/MentionPopover.js.map +1 -1
  111. package/dist/client/composer/PromptComposer.d.ts +35 -2
  112. package/dist/client/composer/PromptComposer.d.ts.map +1 -1
  113. package/dist/client/composer/PromptComposer.js +31 -17
  114. package/dist/client/composer/PromptComposer.js.map +1 -1
  115. package/dist/client/composer/TiptapComposer.d.ts +20 -2
  116. package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
  117. package/dist/client/composer/TiptapComposer.js +112 -22
  118. package/dist/client/composer/TiptapComposer.js.map +1 -1
  119. package/dist/client/composer/index.d.ts +3 -2
  120. package/dist/client/composer/index.d.ts.map +1 -1
  121. package/dist/client/composer/index.js +1 -0
  122. package/dist/client/composer/index.js.map +1 -1
  123. package/dist/client/composer/types.d.ts +1 -0
  124. package/dist/client/composer/types.d.ts.map +1 -1
  125. package/dist/client/composer/types.js.map +1 -1
  126. package/dist/client/extensions/AgentNativeExtensionFrame.d.ts +58 -0
  127. package/dist/client/extensions/AgentNativeExtensionFrame.d.ts.map +1 -0
  128. package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.d.ts +2 -0
  129. package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.d.ts.map +1 -0
  130. package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.js +110 -0
  131. package/dist/client/extensions/AgentNativeExtensionFrame.e2e-host.js.map +1 -0
  132. package/dist/client/extensions/AgentNativeExtensionFrame.js +354 -0
  133. package/dist/client/extensions/AgentNativeExtensionFrame.js.map +1 -0
  134. package/dist/client/extensions/AgentNativeExtensionFrame.spec.d.ts +2 -0
  135. package/dist/client/extensions/AgentNativeExtensionFrame.spec.d.ts.map +1 -0
  136. package/dist/client/extensions/AgentNativeExtensionFrame.spec.js +68 -0
  137. package/dist/client/extensions/AgentNativeExtensionFrame.spec.js.map +1 -0
  138. package/dist/client/extensions/agent-native-extension-runtime.d.ts +69 -0
  139. package/dist/client/extensions/agent-native-extension-runtime.d.ts.map +1 -0
  140. package/dist/client/extensions/agent-native-extension-runtime.js +348 -0
  141. package/dist/client/extensions/agent-native-extension-runtime.js.map +1 -0
  142. package/dist/client/extensions/index.d.ts +2 -0
  143. package/dist/client/extensions/index.d.ts.map +1 -1
  144. package/dist/client/extensions/index.js +2 -0
  145. package/dist/client/extensions/index.js.map +1 -1
  146. package/dist/client/extensions/portable-extension.d.ts +86 -0
  147. package/dist/client/extensions/portable-extension.d.ts.map +1 -0
  148. package/dist/client/extensions/portable-extension.js +480 -0
  149. package/dist/client/extensions/portable-extension.js.map +1 -0
  150. package/dist/client/host-bridge.d.ts +266 -0
  151. package/dist/client/host-bridge.d.ts.map +1 -0
  152. package/dist/client/host-bridge.js +745 -0
  153. package/dist/client/host-bridge.js.map +1 -0
  154. package/dist/client/host-tools.d.ts +40 -0
  155. package/dist/client/host-tools.d.ts.map +1 -0
  156. package/dist/client/host-tools.js +94 -0
  157. package/dist/client/host-tools.js.map +1 -0
  158. package/dist/client/index.d.ts +13 -2
  159. package/dist/client/index.d.ts.map +1 -1
  160. package/dist/client/index.js +11 -2
  161. package/dist/client/index.js.map +1 -1
  162. package/dist/client/resources/BuiltinCapabilityDetail.d.ts +10 -0
  163. package/dist/client/resources/BuiltinCapabilityDetail.d.ts.map +1 -0
  164. package/dist/client/resources/BuiltinCapabilityDetail.js +51 -0
  165. package/dist/client/resources/BuiltinCapabilityDetail.js.map +1 -0
  166. package/dist/client/resources/ResourceEditor.d.ts +3 -1
  167. package/dist/client/resources/ResourceEditor.d.ts.map +1 -1
  168. package/dist/client/resources/ResourceEditor.js +40 -17
  169. package/dist/client/resources/ResourceEditor.js.map +1 -1
  170. package/dist/client/resources/ResourceTree.d.ts.map +1 -1
  171. package/dist/client/resources/ResourceTree.js +23 -2
  172. package/dist/client/resources/ResourceTree.js.map +1 -1
  173. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  174. package/dist/client/resources/ResourcesPanel.js +77 -17
  175. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  176. package/dist/client/resources/index.d.ts +1 -0
  177. package/dist/client/resources/index.d.ts.map +1 -1
  178. package/dist/client/resources/index.js +1 -0
  179. package/dist/client/resources/index.js.map +1 -1
  180. package/dist/client/resources/use-builtin-capabilities.d.ts +62 -0
  181. package/dist/client/resources/use-builtin-capabilities.d.ts.map +1 -0
  182. package/dist/client/resources/use-builtin-capabilities.js +54 -0
  183. package/dist/client/resources/use-builtin-capabilities.js.map +1 -0
  184. package/dist/client/resources/use-resources.d.ts +30 -2
  185. package/dist/client/resources/use-resources.d.ts.map +1 -1
  186. package/dist/client/resources/use-resources.js +42 -1
  187. package/dist/client/resources/use-resources.js.map +1 -1
  188. package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
  189. package/dist/client/settings/SettingsPanel.js +151 -2
  190. package/dist/client/settings/SettingsPanel.js.map +1 -1
  191. package/dist/client/use-chat-models.d.ts.map +1 -1
  192. package/dist/client/use-chat-models.js +20 -0
  193. package/dist/client/use-chat-models.js.map +1 -1
  194. package/dist/client/use-chat-threads.d.ts.map +1 -1
  195. package/dist/client/use-chat-threads.js +46 -2
  196. package/dist/client/use-chat-threads.js.map +1 -1
  197. package/dist/client/use-chat-threads.spec.js +77 -0
  198. package/dist/client/use-chat-threads.spec.js.map +1 -1
  199. package/dist/code-agents/index.d.ts +4 -0
  200. package/dist/code-agents/index.d.ts.map +1 -0
  201. package/dist/code-agents/index.js +4 -0
  202. package/dist/code-agents/index.js.map +1 -0
  203. package/dist/connections/catalog.d.ts +134 -0
  204. package/dist/connections/catalog.d.ts.map +1 -0
  205. package/dist/connections/catalog.js +180 -0
  206. package/dist/connections/catalog.js.map +1 -0
  207. package/dist/connections/index.d.ts +2 -0
  208. package/dist/connections/index.d.ts.map +1 -0
  209. package/dist/connections/index.js +2 -0
  210. package/dist/connections/index.js.map +1 -0
  211. package/dist/extensions/change-marker.d.ts +10 -0
  212. package/dist/extensions/change-marker.d.ts.map +1 -0
  213. package/dist/extensions/change-marker.js +42 -0
  214. package/dist/extensions/change-marker.js.map +1 -0
  215. package/dist/extensions/routes.d.ts.map +1 -1
  216. package/dist/extensions/routes.js +1 -7
  217. package/dist/extensions/routes.js.map +1 -1
  218. package/dist/extensions/schema.d.ts +1 -0
  219. package/dist/extensions/schema.d.ts.map +1 -1
  220. package/dist/extensions/schema.js +1 -0
  221. package/dist/extensions/schema.js.map +1 -1
  222. package/dist/extensions/slots/routes.js +1 -1
  223. package/dist/extensions/slots/routes.js.map +1 -1
  224. package/dist/extensions/store.d.ts +3 -0
  225. package/dist/extensions/store.d.ts.map +1 -1
  226. package/dist/extensions/store.js +112 -4
  227. package/dist/extensions/store.js.map +1 -1
  228. package/dist/index.d.ts +4 -1
  229. package/dist/index.d.ts.map +1 -1
  230. package/dist/index.js +6 -1
  231. package/dist/index.js.map +1 -1
  232. package/dist/integrations/adapters/telegram.d.ts.map +1 -1
  233. package/dist/integrations/adapters/telegram.js +1 -0
  234. package/dist/integrations/adapters/telegram.js.map +1 -1
  235. package/dist/integrations/index.d.ts +5 -1
  236. package/dist/integrations/index.d.ts.map +1 -1
  237. package/dist/integrations/index.js +4 -1
  238. package/dist/integrations/index.js.map +1 -1
  239. package/dist/integrations/plugin.d.ts +8 -0
  240. package/dist/integrations/plugin.d.ts.map +1 -1
  241. package/dist/integrations/plugin.js +760 -32
  242. package/dist/integrations/plugin.js.map +1 -1
  243. package/dist/integrations/remote-commands-store.d.ts +36 -0
  244. package/dist/integrations/remote-commands-store.d.ts.map +1 -0
  245. package/dist/integrations/remote-commands-store.js +273 -0
  246. package/dist/integrations/remote-commands-store.js.map +1 -0
  247. package/dist/integrations/remote-devices-store.d.ts +43 -0
  248. package/dist/integrations/remote-devices-store.d.ts.map +1 -0
  249. package/dist/integrations/remote-devices-store.js +315 -0
  250. package/dist/integrations/remote-devices-store.js.map +1 -0
  251. package/dist/integrations/remote-push-store.d.ts +37 -0
  252. package/dist/integrations/remote-push-store.d.ts.map +1 -0
  253. package/dist/integrations/remote-push-store.js +299 -0
  254. package/dist/integrations/remote-push-store.js.map +1 -0
  255. package/dist/integrations/remote-retry-job.d.ts +7 -0
  256. package/dist/integrations/remote-retry-job.d.ts.map +1 -0
  257. package/dist/integrations/remote-retry-job.js +45 -0
  258. package/dist/integrations/remote-retry-job.js.map +1 -0
  259. package/dist/integrations/remote-run-events-store.d.ts +18 -0
  260. package/dist/integrations/remote-run-events-store.d.ts.map +1 -0
  261. package/dist/integrations/remote-run-events-store.js +82 -0
  262. package/dist/integrations/remote-run-events-store.js.map +1 -0
  263. package/dist/integrations/remote-types.d.ts +101 -0
  264. package/dist/integrations/remote-types.d.ts.map +1 -0
  265. package/dist/integrations/remote-types.js +2 -0
  266. package/dist/integrations/remote-types.js.map +1 -0
  267. package/dist/integrations/webhook-handler.d.ts +2 -0
  268. package/dist/integrations/webhook-handler.d.ts.map +1 -1
  269. package/dist/integrations/webhook-handler.js +4 -1
  270. package/dist/integrations/webhook-handler.js.map +1 -1
  271. package/dist/jobs/scheduler.d.ts +4 -2
  272. package/dist/jobs/scheduler.d.ts.map +1 -1
  273. package/dist/jobs/scheduler.js +9 -3
  274. package/dist/jobs/scheduler.js.map +1 -1
  275. package/dist/mcp-client/builtin-capabilities.d.ts +20 -0
  276. package/dist/mcp-client/builtin-capabilities.d.ts.map +1 -0
  277. package/dist/mcp-client/builtin-capabilities.js +75 -0
  278. package/dist/mcp-client/builtin-capabilities.js.map +1 -0
  279. package/dist/mcp-client/builtin-store.d.ts +10 -0
  280. package/dist/mcp-client/builtin-store.d.ts.map +1 -0
  281. package/dist/mcp-client/builtin-store.js +55 -0
  282. package/dist/mcp-client/builtin-store.js.map +1 -0
  283. package/dist/mcp-client/index.d.ts +3 -1
  284. package/dist/mcp-client/index.d.ts.map +1 -1
  285. package/dist/mcp-client/index.js +3 -1
  286. package/dist/mcp-client/index.js.map +1 -1
  287. package/dist/mcp-client/routes.d.ts +28 -0
  288. package/dist/mcp-client/routes.d.ts.map +1 -1
  289. package/dist/mcp-client/routes.js +195 -1
  290. package/dist/mcp-client/routes.js.map +1 -1
  291. package/dist/org/context.d.ts.map +1 -1
  292. package/dist/org/context.js +34 -0
  293. package/dist/org/context.js.map +1 -1
  294. package/dist/resources/handlers.d.ts +4 -0
  295. package/dist/resources/handlers.d.ts.map +1 -1
  296. package/dist/resources/handlers.js +46 -7
  297. package/dist/resources/handlers.js.map +1 -1
  298. package/dist/resources/script-helpers.d.ts +8 -1
  299. package/dist/resources/script-helpers.d.ts.map +1 -1
  300. package/dist/resources/script-helpers.js +18 -8
  301. package/dist/resources/script-helpers.js.map +1 -1
  302. package/dist/resources/store.d.ts +19 -0
  303. package/dist/resources/store.d.ts.map +1 -1
  304. package/dist/resources/store.js +86 -3
  305. package/dist/resources/store.js.map +1 -1
  306. package/dist/scripts/agent-engines/list-agent-engines.d.ts +1 -1
  307. package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
  308. package/dist/scripts/agent-engines/list-agent-engines.js +18 -7
  309. package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
  310. package/dist/scripts/agent-engines/manage-agent-engine.d.ts.map +1 -1
  311. package/dist/scripts/agent-engines/manage-agent-engine.js +100 -7
  312. package/dist/scripts/agent-engines/manage-agent-engine.js.map +1 -1
  313. package/dist/scripts/resources/delete.d.ts.map +1 -1
  314. package/dist/scripts/resources/delete.js +4 -1
  315. package/dist/scripts/resources/delete.js.map +1 -1
  316. package/dist/scripts/resources/effective.d.ts +11 -0
  317. package/dist/scripts/resources/effective.d.ts.map +1 -0
  318. package/dist/scripts/resources/effective.js +54 -0
  319. package/dist/scripts/resources/effective.js.map +1 -0
  320. package/dist/scripts/resources/index.d.ts.map +1 -1
  321. package/dist/scripts/resources/index.js +1 -0
  322. package/dist/scripts/resources/index.js.map +1 -1
  323. package/dist/scripts/resources/list.d.ts +1 -1
  324. package/dist/scripts/resources/list.d.ts.map +1 -1
  325. package/dist/scripts/resources/list.js +17 -5
  326. package/dist/scripts/resources/list.js.map +1 -1
  327. package/dist/scripts/resources/read.d.ts +1 -1
  328. package/dist/scripts/resources/read.d.ts.map +1 -1
  329. package/dist/scripts/resources/read.js +20 -5
  330. package/dist/scripts/resources/read.js.map +1 -1
  331. package/dist/scripts/resources/write.d.ts.map +1 -1
  332. package/dist/scripts/resources/write.js +4 -1
  333. package/dist/scripts/resources/write.js.map +1 -1
  334. package/dist/scripts/runner.d.ts +11 -1
  335. package/dist/scripts/runner.d.ts.map +1 -1
  336. package/dist/scripts/runner.js +75 -27
  337. package/dist/scripts/runner.js.map +1 -1
  338. package/dist/server/action-discovery.d.ts.map +1 -1
  339. package/dist/server/action-discovery.js +5 -0
  340. package/dist/server/action-discovery.js.map +1 -1
  341. package/dist/server/agent-chat-plugin.d.ts +24 -0
  342. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  343. package/dist/server/agent-chat-plugin.js +608 -54
  344. package/dist/server/agent-chat-plugin.js.map +1 -1
  345. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  346. package/dist/server/core-routes-plugin.js +2 -0
  347. package/dist/server/core-routes-plugin.js.map +1 -1
  348. package/dist/server/embedded.d.ts +72 -0
  349. package/dist/server/embedded.d.ts.map +1 -0
  350. package/dist/server/embedded.js +119 -0
  351. package/dist/server/embedded.js.map +1 -0
  352. package/dist/server/index.d.ts +8 -1
  353. package/dist/server/index.d.ts.map +1 -1
  354. package/dist/server/index.js +7 -1
  355. package/dist/server/index.js.map +1 -1
  356. package/dist/server/poll.d.ts.map +1 -1
  357. package/dist/server/poll.js +184 -13
  358. package/dist/server/poll.js.map +1 -1
  359. package/dist/server/resources-plugin.d.ts.map +1 -1
  360. package/dist/server/resources-plugin.js +11 -2
  361. package/dist/server/resources-plugin.js.map +1 -1
  362. package/dist/sharing/actions/extension-change.d.ts +4 -0
  363. package/dist/sharing/actions/extension-change.d.ts.map +1 -0
  364. package/dist/sharing/actions/extension-change.js +13 -0
  365. package/dist/sharing/actions/extension-change.js.map +1 -0
  366. package/dist/sharing/actions/set-resource-visibility.d.ts.map +1 -1
  367. package/dist/sharing/actions/set-resource-visibility.js +3 -0
  368. package/dist/sharing/actions/set-resource-visibility.js.map +1 -1
  369. package/dist/sharing/actions/share-resource.d.ts.map +1 -1
  370. package/dist/sharing/actions/share-resource.js +4 -0
  371. package/dist/sharing/actions/share-resource.js.map +1 -1
  372. package/dist/sharing/actions/unshare-resource.d.ts.map +1 -1
  373. package/dist/sharing/actions/unshare-resource.js +3 -0
  374. package/dist/sharing/actions/unshare-resource.js.map +1 -1
  375. package/dist/templates/default/AGENTS.md +3 -3
  376. package/dist/templates/workspace-core/AGENTS.md +7 -0
  377. package/dist/templates/workspace-root/AGENTS.md +7 -0
  378. package/dist/templates/workspace-root/README.md +25 -0
  379. package/dist/triggers/dispatcher.d.ts +3 -1
  380. package/dist/triggers/dispatcher.d.ts.map +1 -1
  381. package/dist/triggers/dispatcher.js +9 -3
  382. package/dist/triggers/dispatcher.js.map +1 -1
  383. package/dist/workspace-connections/index.d.ts +2 -0
  384. package/dist/workspace-connections/index.d.ts.map +1 -0
  385. package/dist/workspace-connections/index.js +2 -0
  386. package/dist/workspace-connections/index.js.map +1 -0
  387. package/dist/workspace-connections/store.d.ts +229 -0
  388. package/dist/workspace-connections/store.d.ts.map +1 -0
  389. package/dist/workspace-connections/store.js +938 -0
  390. package/dist/workspace-connections/store.js.map +1 -0
  391. package/docs/content/agent-teams.md +6 -0
  392. package/docs/content/cloneable-saas.md +1 -0
  393. package/docs/content/code-agents-ui.md +261 -0
  394. package/docs/content/dispatch.md +40 -3
  395. package/docs/content/embedding-sdk.md +459 -0
  396. package/docs/content/faq.md +1 -0
  397. package/docs/content/getting-started.md +1 -0
  398. package/docs/content/mcp-clients.md +41 -3
  399. package/docs/content/migration-workbench.md +237 -54
  400. package/docs/content/multi-app-workspace.md +41 -0
  401. package/docs/content/multi-tenancy.md +1 -1
  402. package/docs/content/template-brain.md +418 -0
  403. package/docs/content/template-dispatch.md +30 -0
  404. package/docs/content/workspace-connections.md +509 -0
  405. package/docs/content/workspace-management.md +12 -12
  406. package/docs/content/workspace.md +180 -40
  407. package/package.json +7 -2
  408. package/src/templates/default/AGENTS.md +3 -3
  409. package/src/templates/workspace-core/AGENTS.md +7 -0
  410. package/src/templates/workspace-root/AGENTS.md +7 -0
  411. package/src/templates/workspace-root/README.md +25 -0
@@ -0,0 +1,1306 @@
1
+ import { createInterface } from "node:readline";
2
+ import { CODE_AGENT_PERMISSION_MODES, appendCodeAgentTranscriptEvent, createCodeAgentRunRecord, getCodeAgentRunRecord, getLastCodeAgentRunRecord, isActiveCodeAgentRun, listCodeAgentRunRecords, listCodeAgentTranscriptEvents, normalizeCodeAgentPermissionMode, queueCodeAgentFollowUp, updateCodeAgentRunRecord, } from "./code-agent-runs.js";
3
+ import { findProjectSlashCommand, listProjectSlashCommands, renderProjectSlashCommandPrompt, } from "./code-agent-commands.js";
4
+ import { executeCodeAgentRun, executeExistingCodeAgentRun, executePendingCodeAgentApproval, } from "./code-agent-executor.js";
5
+ import { runAuditAgentWeb } from "./audit-agent-web.js";
6
+ import { runMigrate } from "./migrate.js";
7
+ export const CODE_AGENT_CLI_GOALS = [
8
+ {
9
+ id: "task",
10
+ slashCommand: "/task",
11
+ aliases: ["task", "todo"],
12
+ summary: "Run a generic coding task as a resumable Agent-Native Code session.",
13
+ backingCommand: "task",
14
+ },
15
+ {
16
+ id: "migrate",
17
+ slashCommand: "/migrate",
18
+ aliases: ["migrate", "migration"],
19
+ summary: "Move a path, URL, or described product into agent-native with verification.",
20
+ backingCommand: "migrate",
21
+ },
22
+ {
23
+ id: "audit",
24
+ slashCommand: "/audit",
25
+ aliases: ["audit", "audit-agent-web", "agent-web"],
26
+ summary: "Audit a public URL for agent-readable surfaces such as llms.txt and markdown mirrors.",
27
+ backingCommand: "audit-agent-web",
28
+ },
29
+ ];
30
+ const CODE_AGENT_CONTROL_SUBCOMMANDS = new Set([
31
+ "approve",
32
+ "attach",
33
+ "list",
34
+ "logs",
35
+ "ps",
36
+ "resume",
37
+ "status",
38
+ "stop",
39
+ "ui",
40
+ ]);
41
+ const SHELL_PROMPT = "code> ";
42
+ export function resolveCodeCommand(argv) {
43
+ const [rawFirst, ...rest] = argv;
44
+ if (!rawFirst) {
45
+ return { kind: "shell" };
46
+ }
47
+ if (rawFirst === "--help" || rawFirst === "-h") {
48
+ return { kind: "help" };
49
+ }
50
+ const first = normalizeGoalToken(rawFirst);
51
+ if (first === "goals") {
52
+ return { kind: "list-goals" };
53
+ }
54
+ if (first === "serve") {
55
+ return { kind: "serve", relayUrl: parseRelayUrlOption(rest) };
56
+ }
57
+ if (first === "exec" || first === "e") {
58
+ return {
59
+ kind: "run-goal",
60
+ goalId: "task",
61
+ forwardedArgs: rest,
62
+ };
63
+ }
64
+ if (first === "--print" || first === "-p") {
65
+ return {
66
+ kind: "run-goal",
67
+ goalId: "task",
68
+ forwardedArgs: rest,
69
+ };
70
+ }
71
+ if (first === "--continue" || first === "-c") {
72
+ const parsed = parseFollowUpArgs(rest);
73
+ return parsed.prompt
74
+ ? {
75
+ kind: "record-follow-up",
76
+ prompt: parsed.prompt,
77
+ ...(parsed.followUpMode === "queued"
78
+ ? { followUpMode: parsed.followUpMode }
79
+ : {}),
80
+ ...(parsed.permissionModeExplicit
81
+ ? { permissionMode: parsed.permissionMode }
82
+ : {}),
83
+ }
84
+ : {
85
+ kind: "control",
86
+ subcommand: "resume",
87
+ args: ["resume", "--last"],
88
+ };
89
+ }
90
+ if (first === "--resume" || first === "-r") {
91
+ return {
92
+ kind: "control",
93
+ subcommand: "resume",
94
+ args: ["resume", ...rest],
95
+ };
96
+ }
97
+ if ((first === "run" || first === "start") && rest[0]) {
98
+ return { kind: "execute-existing-run", runId: rest[0] };
99
+ }
100
+ const followUp = parseResumeFollowUpPrompt([rawFirst, ...rest]);
101
+ if (followUp) {
102
+ return {
103
+ kind: "record-follow-up",
104
+ prompt: followUp.prompt,
105
+ runId: followUp.runId,
106
+ ...(followUp.followUpMode ? { followUpMode: followUp.followUpMode } : {}),
107
+ ...(followUp.permissionMode
108
+ ? { permissionMode: followUp.permissionMode }
109
+ : {}),
110
+ };
111
+ }
112
+ const goal = findGoal(first);
113
+ if (goal) {
114
+ return {
115
+ kind: "run-goal",
116
+ goalId: goal.id,
117
+ forwardedArgs: rest,
118
+ };
119
+ }
120
+ if (rawFirst.startsWith("/")) {
121
+ const projectCommand = findProjectSlashCommand(first);
122
+ if (projectCommand) {
123
+ return {
124
+ kind: "run-project-command",
125
+ commandName: projectCommand.name,
126
+ forwardedArgs: rest,
127
+ };
128
+ }
129
+ }
130
+ if (isCodeAgentControlSubcommand(first)) {
131
+ return {
132
+ kind: "control",
133
+ subcommand: first,
134
+ args: [first, ...rest],
135
+ };
136
+ }
137
+ return {
138
+ kind: "run-goal",
139
+ goalId: "task",
140
+ forwardedArgs: argv,
141
+ };
142
+ }
143
+ export async function runCode(argv, options = {}) {
144
+ const command = resolveCodeCommand(argv);
145
+ const output = options.output ?? process.stdout;
146
+ const runGoal = options.runGoal ?? runCodeGoal;
147
+ if (command.kind === "shell") {
148
+ await runCodeShell({ ...options, output, runGoal });
149
+ return;
150
+ }
151
+ if (command.kind === "help") {
152
+ writeLine(output, codeUsage());
153
+ return;
154
+ }
155
+ if (command.kind === "list-goals") {
156
+ writeLine(output, renderGoalList());
157
+ return;
158
+ }
159
+ if (command.kind === "serve") {
160
+ const { runCodeAgentConnector } = await import("./code-agent-connector.js");
161
+ const exitCode = await runCodeAgentConnector({
162
+ relayUrl: command.relayUrl,
163
+ output,
164
+ });
165
+ if (exitCode !== 0)
166
+ process.exitCode = exitCode;
167
+ return;
168
+ }
169
+ if (command.kind === "execute-existing-run") {
170
+ await executeExistingCodeAgentRun(command.runId, { stdout: output });
171
+ return;
172
+ }
173
+ if (command.kind === "control") {
174
+ await runCodeAgentControl(command.subcommand, command.args, output);
175
+ return;
176
+ }
177
+ if (command.kind === "record-follow-up") {
178
+ await recordCodeAgentFollowUpPrompt(command.prompt, output, command.permissionMode, command.runId, command.followUpMode);
179
+ return;
180
+ }
181
+ if (command.kind === "run-project-command") {
182
+ await runProjectSlashCommand(command.commandName, command.forwardedArgs, output);
183
+ return;
184
+ }
185
+ await runGoal(command.goalId, command.forwardedArgs, output);
186
+ }
187
+ export async function runCodeShell(options = {}) {
188
+ const input = options.input ?? process.stdin;
189
+ const output = options.output ?? process.stdout;
190
+ const runGoal = options.runGoal ?? runCodeGoal;
191
+ const rl = createInterface({
192
+ input,
193
+ output,
194
+ terminal: isInteractiveTerminal(input, output),
195
+ });
196
+ writeLine(output, codeShellIntro());
197
+ writePrompt(output);
198
+ try {
199
+ for await (const line of rl) {
200
+ const result = await handleCodeShellLine(line, { output, runGoal });
201
+ if (result === "exit") {
202
+ break;
203
+ }
204
+ writePrompt(output);
205
+ }
206
+ }
207
+ finally {
208
+ rl.close();
209
+ }
210
+ }
211
+ export async function handleCodeShellLine(line, options) {
212
+ const trimmed = line.trim();
213
+ if (!trimmed) {
214
+ return "continue";
215
+ }
216
+ const parsed = parseCodeShellArgs(trimmed);
217
+ if ("error" in parsed) {
218
+ writeLine(options.output, parsed.error);
219
+ return "continue";
220
+ }
221
+ const [rawFirst, ...rest] = parsed.args;
222
+ if (!rawFirst) {
223
+ return "continue";
224
+ }
225
+ const followUp = parseResumeFollowUpPrompt(parsed.args);
226
+ if (followUp) {
227
+ await recordCodeAgentFollowUpPrompt(followUp.prompt, options.output, followUp.permissionMode, followUp.runId, followUp.followUpMode);
228
+ return "continue";
229
+ }
230
+ if (rawFirst.startsWith("/")) {
231
+ const first = normalizeGoalToken(rawFirst);
232
+ if (first === "help") {
233
+ writeLine(options.output, codeShellHelp());
234
+ return "continue";
235
+ }
236
+ if (first === "goals") {
237
+ writeLine(options.output, renderGoalList());
238
+ return "continue";
239
+ }
240
+ if (first === "exit" || first === "quit") {
241
+ writeLine(options.output, "Leaving Agent-Native Code.");
242
+ return "exit";
243
+ }
244
+ const goal = findGoal(first);
245
+ if (goal) {
246
+ await options.runGoal(goal.id, rest, options.output);
247
+ return "continue";
248
+ }
249
+ const projectCommand = findProjectSlashCommand(first);
250
+ if (projectCommand) {
251
+ await runProjectSlashCommand(projectCommand.name, rest, options.output);
252
+ return "continue";
253
+ }
254
+ writeLine(options.output, `Unknown slash command: ${rawFirst}\nTry /help to see available commands.`);
255
+ return "continue";
256
+ }
257
+ const first = normalizeGoalToken(rawFirst);
258
+ if (first === "exec" || first === "e") {
259
+ await options.runGoal("task", rest, options.output);
260
+ return "continue";
261
+ }
262
+ if (first === "--print" || first === "-p") {
263
+ await options.runGoal("task", rest, options.output);
264
+ return "continue";
265
+ }
266
+ if (first === "--continue" || first === "-c") {
267
+ const parsedTask = parseFollowUpArgs(rest);
268
+ if (parsedTask.prompt) {
269
+ await recordCodeAgentFollowUpPrompt(parsedTask.prompt, options.output, parsedTask.permissionModeExplicit
270
+ ? parsedTask.permissionMode
271
+ : undefined, undefined, parsedTask.followUpMode);
272
+ }
273
+ else {
274
+ await runCodeAgentControl("resume", ["resume", "--last"], options.output);
275
+ }
276
+ return "continue";
277
+ }
278
+ if (first === "--resume" || first === "-r") {
279
+ await runCodeAgentControl("resume", ["resume", ...rest], options.output);
280
+ return "continue";
281
+ }
282
+ if ((first === "run" || first === "start") && rest[0]) {
283
+ await executeExistingCodeAgentRun(rest[0], { stdout: options.output });
284
+ return "continue";
285
+ }
286
+ if (isCodeAgentControlSubcommand(first)) {
287
+ await runCodeAgentControl(first, parsed.args, options.output);
288
+ return "continue";
289
+ }
290
+ await options.runGoal("task", parsed.args, options.output);
291
+ return "continue";
292
+ }
293
+ export function codeUsage() {
294
+ return `agent-native code
295
+
296
+ Open the Agent-Native Code shell or run a coding-agent goal directly.
297
+
298
+ Usage:
299
+ agent-native code
300
+ agent-native code "fix the failing auth tests"
301
+ agent-native code exec "fix the failing auth tests"
302
+ agent-native code -p "fix the failing auth tests"
303
+ agent-native code --plan "explain this repo"
304
+ agent-native code --auto "fix the failing auth tests"
305
+ agent-native code /review-diff
306
+ agent-native code /audit --url https://example.com
307
+ agent-native code /migrate <source> [--out ../migrated-app]
308
+ agent-native code /migrate --describe "what to build or migrate"
309
+ agent-native code attach --last
310
+ agent-native code logs --last
311
+ agent-native code approve --last
312
+ agent-native code list
313
+ agent-native code resume --last "follow-up prompt"
314
+ agent-native code --continue "follow-up prompt"
315
+ agent-native code resume --last
316
+ agent-native code status --last
317
+ agent-native code serve --relay-url <url>
318
+ agent-native code ui --last
319
+ agent-native code run <runId>
320
+ agent-native code goals
321
+
322
+ Interactive shell:
323
+ /help Show shell commands
324
+ /goals List available coding-agent goals
325
+ /migrate ... Run the migration goal
326
+ /audit ... Run the web audit goal
327
+ /<project> Run .agents/commands/<project>.md
328
+ /exit Leave the shell
329
+
330
+ Session commands:
331
+ list List recent sessions
332
+ attach ... Attach to a run transcript, following active work
333
+ logs ... Print a run transcript once
334
+ approve ... Run one pending approved command, then resume the session
335
+ resume ... Continue the latest or selected run
336
+ status ... Show run status
337
+ stop ... Stop a tracked Desktop/CLI runner
338
+ serve ... Run the remote relay connector
339
+
340
+ Modes:
341
+ --plan, --auto
342
+ --permission-mode read-only|ask-before-edit|auto-edit|full-auto
343
+ --read-only, --ask-before-edit, --auto-edit, --full-auto
344
+
345
+ Available goals:
346
+ ${renderGoalRows()}
347
+ ${renderProjectCommandRows()}
348
+
349
+ The existing shortcut still works:
350
+ agent-native migrate <source> [options]`;
351
+ }
352
+ export function codeShellIntro() {
353
+ return `Agent-Native Code
354
+ Type a coding task to start a session, /help for commands, /goals for goals, or /exit to leave.`;
355
+ }
356
+ export function codeShellHelp() {
357
+ return `Agent-Native Code shell commands:
358
+ /help Show this help
359
+ /goals List available coding-agent goals
360
+ /migrate ... Move a source into agent-native
361
+ /audit ... Audit a public URL for agent-readable surfaces
362
+ /<project> Run a project command from .agents/commands/*.md
363
+ /exit Leave the shell
364
+ /quit Leave the shell
365
+
366
+ Compatibility shortcuts:
367
+ exec "prompt"
368
+ -p "prompt"
369
+ list
370
+ ps
371
+ attach --last
372
+ logs --last
373
+ approve --last
374
+ resume --last "follow-up prompt"
375
+ --continue "follow-up prompt"
376
+ resume --last
377
+ status --last
378
+ ui --last
379
+ stop --last`;
380
+ }
381
+ export function codeShellFreeTextMessage() {
382
+ return `Bare prompts run as generic Agent-Native Code sessions.
383
+ Use /migrate and /audit for specialized goals.`;
384
+ }
385
+ export function parseCodeShellArgs(line) {
386
+ const args = [];
387
+ let current = "";
388
+ let quote;
389
+ let escaping = false;
390
+ let hasValue = false;
391
+ const pushCurrent = () => {
392
+ if (hasValue) {
393
+ args.push(current);
394
+ current = "";
395
+ hasValue = false;
396
+ }
397
+ };
398
+ for (const char of line) {
399
+ if (escaping) {
400
+ current += char;
401
+ hasValue = true;
402
+ escaping = false;
403
+ continue;
404
+ }
405
+ if (char === "\\" && quote !== "'") {
406
+ escaping = true;
407
+ hasValue = true;
408
+ continue;
409
+ }
410
+ if (quote) {
411
+ if (char === quote) {
412
+ quote = undefined;
413
+ }
414
+ else {
415
+ current += char;
416
+ hasValue = true;
417
+ }
418
+ continue;
419
+ }
420
+ if (char === "'" || char === '"') {
421
+ quote = char;
422
+ hasValue = true;
423
+ continue;
424
+ }
425
+ if (/\s/.test(char)) {
426
+ pushCurrent();
427
+ continue;
428
+ }
429
+ current += char;
430
+ hasValue = true;
431
+ }
432
+ if (escaping) {
433
+ current += "\\";
434
+ }
435
+ if (quote) {
436
+ return { ok: false, error: `Unclosed ${quote} quote.` };
437
+ }
438
+ pushCurrent();
439
+ return { ok: true, args };
440
+ }
441
+ function renderGoalList() {
442
+ return `Available Agent-Native Code goals:
443
+ ${renderGoalRows()}
444
+ ${renderProjectCommandRows()}`;
445
+ }
446
+ function renderGoalRows() {
447
+ return CODE_AGENT_CLI_GOALS.map((goal) => ` ${goal.slashCommand.padEnd(12)} ${goal.summary}`).join("\n");
448
+ }
449
+ function renderProjectCommandRows() {
450
+ const commands = listVisibleProjectSlashCommands();
451
+ if (commands.length === 0)
452
+ return "";
453
+ return [
454
+ "",
455
+ "Project commands:",
456
+ ...commands.map((command) => {
457
+ const args = command.argumentHint ? ` ${command.argumentHint}` : "";
458
+ const description = command.description ?? "Project slash command.";
459
+ return ` /${command.name}${args}`.padEnd(24) + description;
460
+ }),
461
+ ].join("\n");
462
+ }
463
+ function listVisibleProjectSlashCommands() {
464
+ return listProjectSlashCommands().filter((command) => !isReservedSlashName(command.name));
465
+ }
466
+ function isReservedSlashName(name) {
467
+ const normalized = normalizeGoalToken(name);
468
+ return (Boolean(findGoal(normalized)) ||
469
+ isCodeAgentControlSubcommand(normalized) ||
470
+ normalized === "help" ||
471
+ normalized === "exit" ||
472
+ normalized === "quit" ||
473
+ normalized === "goals");
474
+ }
475
+ function normalizeGoalToken(value) {
476
+ return value.replace(/^\//, "").toLowerCase();
477
+ }
478
+ function findGoal(value) {
479
+ const normalized = normalizeGoalToken(value);
480
+ return CODE_AGENT_CLI_GOALS.find((goal) => goal.id === normalized ||
481
+ normalizeGoalToken(goal.slashCommand) === normalized ||
482
+ goal.aliases.includes(normalized));
483
+ }
484
+ function isCodeAgentControlSubcommand(value) {
485
+ return CODE_AGENT_CONTROL_SUBCOMMANDS.has(value);
486
+ }
487
+ function parseResumeFollowUpPrompt(args) {
488
+ const [rawFirst, ...rest] = args;
489
+ if (normalizeGoalToken(rawFirst ?? "") !== "resume")
490
+ return null;
491
+ const selector = parseResumeSelectorAndPrompt(rest);
492
+ if (!selector)
493
+ return null;
494
+ if (!selector.hasSeparator &&
495
+ !selector.promptArgs.some((arg) => !arg.startsWith("-"))) {
496
+ return null;
497
+ }
498
+ const parsed = parseFollowUpArgs(selector.promptArgs);
499
+ return parsed.prompt
500
+ ? {
501
+ prompt: parsed.prompt,
502
+ runId: selector.runId,
503
+ ...(parsed.followUpMode === "queued"
504
+ ? { followUpMode: parsed.followUpMode }
505
+ : {}),
506
+ permissionMode: parsed.permissionModeExplicit
507
+ ? parsed.permissionMode
508
+ : undefined,
509
+ }
510
+ : null;
511
+ }
512
+ function parseResumeSelectorAndPrompt(args) {
513
+ const lastIndex = args.indexOf("--last");
514
+ if (lastIndex !== -1) {
515
+ const promptArgs = args.filter((_, index) => index !== lastIndex);
516
+ const separatorIndex = promptArgs.indexOf("--");
517
+ return {
518
+ promptArgs: separatorIndex === -1
519
+ ? promptArgs
520
+ : promptArgs.slice(separatorIndex + 1),
521
+ hasSeparator: separatorIndex !== -1,
522
+ };
523
+ }
524
+ const [maybeRunId, ...rest] = args;
525
+ if (!maybeRunId ||
526
+ maybeRunId.startsWith("-") ||
527
+ !looksLikeRunId(maybeRunId)) {
528
+ return null;
529
+ }
530
+ const separatorIndex = rest.indexOf("--");
531
+ return {
532
+ runId: maybeRunId,
533
+ promptArgs: separatorIndex === -1 ? rest : rest.slice(separatorIndex + 1),
534
+ hasSeparator: separatorIndex !== -1,
535
+ };
536
+ }
537
+ function looksLikeRunId(value) {
538
+ return /^[a-z][a-z0-9-]*-(?:\d{14}|\d{8}t\d{6}z)-[a-f0-9]{8}$/i.test(value);
539
+ }
540
+ function parseRelayUrlOption(args) {
541
+ for (let i = 0; i < args.length; i++) {
542
+ const arg = args[i];
543
+ if (arg === "--relay-url" && args[i + 1])
544
+ return args[i + 1];
545
+ if (arg.startsWith("--relay-url=")) {
546
+ const value = arg.slice("--relay-url=".length).trim();
547
+ if (value)
548
+ return value;
549
+ }
550
+ }
551
+ return undefined;
552
+ }
553
+ async function runCodeAgentControl(subcommand, args, output, allowPicker = true) {
554
+ const runs = listCodeAgentRunRecords();
555
+ const effectiveArgs = await maybePickRunArgs(subcommand, runs, args, output, allowPicker);
556
+ if (!effectiveArgs) {
557
+ writeLine(output, "No Agent-Native Code session selected.");
558
+ return;
559
+ }
560
+ switch (subcommand) {
561
+ case "approve":
562
+ await approveCodeAgentRun(runs, effectiveArgs, output);
563
+ return;
564
+ case "attach":
565
+ await attachCodeAgentRun(runs, effectiveArgs, output);
566
+ return;
567
+ case "logs":
568
+ writeLine(output, renderCodeAgentLogs(runs, effectiveArgs));
569
+ return;
570
+ case "list":
571
+ case "ps":
572
+ writeLine(output, renderCodeAgentSessionList(runs));
573
+ return;
574
+ case "status":
575
+ writeLine(output, renderCodeAgentStatus(runs, effectiveArgs));
576
+ return;
577
+ case "resume":
578
+ writeLine(output, renderCodeAgentResume(runs, effectiveArgs));
579
+ return;
580
+ case "ui":
581
+ writeLine(output, renderCodeAgentUi(runs, effectiveArgs));
582
+ return;
583
+ case "stop":
584
+ writeLine(output, stopCodeAgentRun(runs, effectiveArgs));
585
+ return;
586
+ }
587
+ }
588
+ async function maybePickRunArgs(subcommand, runs, args, output, allowPicker) {
589
+ if (!allowPicker ||
590
+ !["approve", "attach", "logs", "resume"].includes(subcommand) ||
591
+ args.includes("--last") ||
592
+ hasExplicitRunId(args) ||
593
+ runs.length === 0 ||
594
+ !isInteractiveTerminal(process.stdin, output)) {
595
+ return args;
596
+ }
597
+ const selected = await promptForRunSelection(runs, output);
598
+ return selected ? [subcommand, selected.id] : null;
599
+ }
600
+ async function promptForRunSelection(runs, output) {
601
+ const choices = runs.slice(0, 10);
602
+ writeLine(output, "");
603
+ writeLine(output, "Select an Agent-Native Code session:");
604
+ choices.forEach((run, index) => {
605
+ writeLine(output, ` ${index + 1}. ${run.id}`);
606
+ writeLine(output, ` /${run.goalId} ${run.status}${run.phase ? ` (${run.phase})` : ""} updated ${run.updatedAt}`);
607
+ writeLine(output, ` ${truncateForDisplay(run.title, 90)}`);
608
+ });
609
+ writeLine(output, "");
610
+ const rl = createInterface({
611
+ input: process.stdin,
612
+ output,
613
+ terminal: true,
614
+ });
615
+ const answer = await new Promise((resolve) => {
616
+ rl.question("Run number or id (blank cancels): ", resolve);
617
+ });
618
+ rl.close();
619
+ const trimmed = answer.trim();
620
+ if (!trimmed) {
621
+ writeLine(output, "No run selected.");
622
+ return null;
623
+ }
624
+ const index = Number(trimmed);
625
+ if (Number.isInteger(index) && index >= 1 && index <= choices.length) {
626
+ return choices[index - 1] ?? null;
627
+ }
628
+ const matchingRun = choices.find((run) => run.id === trimmed) ??
629
+ choices.find((run) => run.id.startsWith(trimmed));
630
+ if (matchingRun)
631
+ return matchingRun;
632
+ writeLine(output, "No matching run selected.");
633
+ return null;
634
+ }
635
+ function renderCodeAgentSessionList(runs) {
636
+ return [
637
+ "",
638
+ "Agent-Native Code sessions",
639
+ "",
640
+ runs.length === 0
641
+ ? " No Agent-Native Code sessions found."
642
+ : ` ${runs.length} session${runs.length === 1 ? "" : "s"} found. Most recent first.`,
643
+ ...runs.slice(0, 10).map(renderCodeAgentRunListItem),
644
+ runs.length > 10 ? ` - ${runs.length - 10} more...` : "",
645
+ "",
646
+ runs.length > 0 ? "Inspect a session:" : "",
647
+ runs.length > 0 ? " agent-native code status <runId>" : "",
648
+ runs.length > 0 ? " agent-native code logs <runId>" : "",
649
+ runs.length > 0 ? " agent-native code resume <runId>" : "",
650
+ runs.length > 0
651
+ ? ' agent-native code resume <runId> "follow-up prompt"'
652
+ : 'Start one with: agent-native code "what to change"',
653
+ ]
654
+ .filter(Boolean)
655
+ .join("\n");
656
+ }
657
+ function renderCodeAgentStatus(runs, args) {
658
+ const selected = selectCodeAgentRun(runs, args, {
659
+ defaultToLast: args.includes("--last") || hasExplicitRunId(args),
660
+ });
661
+ if (selected) {
662
+ return renderCodeAgentRunDetail("Agent-Native Code status", selected);
663
+ }
664
+ return [
665
+ "",
666
+ "Agent-Native Code status",
667
+ "",
668
+ runs.length === 0
669
+ ? " No Agent-Native Code sessions found."
670
+ : ` ${runs.length} session${runs.length === 1 ? "" : "s"} found.`,
671
+ ...runs.slice(0, 10).map(renderCodeAgentRunListItem),
672
+ runs.length > 10 ? ` - ${runs.length - 10} more...` : "",
673
+ "",
674
+ 'Start one with: agent-native code "what to change"',
675
+ 'Add a follow-up with: agent-native code resume --last "what next"',
676
+ ]
677
+ .filter(Boolean)
678
+ .join("\n");
679
+ }
680
+ function renderCodeAgentResume(runs, args) {
681
+ const run = selectCodeAgentRun(runs, args, { defaultToLast: true });
682
+ if (!run) {
683
+ return [
684
+ "",
685
+ "Agent-Native Code resume",
686
+ "",
687
+ " No Agent-Native Code sessions found.",
688
+ "",
689
+ 'Start one with: agent-native code "what to change"',
690
+ ].join("\n");
691
+ }
692
+ const transcriptEvents = listCodeAgentTranscriptEvents(run.id);
693
+ const latestEvent = transcriptEvents.at(-1);
694
+ const followUpTarget = args.includes("--last") ? "--last" : run.id;
695
+ return [
696
+ "",
697
+ "Agent-Native Code resume",
698
+ "",
699
+ ` Run: ${run.id}`,
700
+ ` Goal: /${run.goalId}`,
701
+ ` Title: ${run.title}`,
702
+ ` Status: ${run.status}${run.phase ? ` (${run.phase})` : ""}`,
703
+ run.permissionMode
704
+ ? ` Mode: ${formatCodeAgentRunMode(run.permissionMode)}`
705
+ : "",
706
+ ` Updated: ${run.updatedAt}`,
707
+ latestEvent
708
+ ? ` Last: ${truncateForDisplay(latestEvent.message, 140)}`
709
+ : "",
710
+ "",
711
+ "Resume execution:",
712
+ ` agent-native code run ${run.id}`,
713
+ "",
714
+ "Attach to the live transcript:",
715
+ ` agent-native code attach ${run.id}`,
716
+ "",
717
+ "Append and run a follow-up:",
718
+ ` agent-native code resume ${followUpTarget} "next instruction"`,
719
+ ]
720
+ .filter(Boolean)
721
+ .join("\n");
722
+ }
723
+ function renderCodeAgentUi(runs, args) {
724
+ const run = selectCodeAgentRun(runs, args, { defaultToLast: true });
725
+ return [
726
+ "",
727
+ "Agent-Native Code UI",
728
+ "",
729
+ "Open Agent-Native Desktop and choose Agent-Native Code from the left sidebar.",
730
+ run ? `Run: ${run.id}` : "No run selected yet.",
731
+ run ? `Deep link: agentnative://open?app=code-agents&run=${run.id}` : "",
732
+ ]
733
+ .filter(Boolean)
734
+ .join("\n");
735
+ }
736
+ function stopCodeAgentRun(runs, args) {
737
+ const run = selectCodeAgentRun(runs, args, { defaultToLast: true });
738
+ if (run &&
739
+ (run.status === "completed" ||
740
+ run.status === "errored" ||
741
+ run.phase === "complete" ||
742
+ run.phase === "error")) {
743
+ return [
744
+ "",
745
+ "Agent-Native Code stop",
746
+ "",
747
+ ` Run: ${run.id}`,
748
+ ` Status: ${run.status}${run.phase ? ` (${run.phase})` : ""}`,
749
+ "",
750
+ " This run is already finished; no stop signal was sent.",
751
+ ].join("\n");
752
+ }
753
+ if (run) {
754
+ const pid = Number(run.metadata?.runnerPid);
755
+ let killed = false;
756
+ let killError = "";
757
+ if (Number.isFinite(pid) && pid > 0) {
758
+ try {
759
+ process.kill(pid, "SIGTERM");
760
+ killed = true;
761
+ }
762
+ catch (err) {
763
+ killError = err instanceof Error ? err.message : String(err);
764
+ }
765
+ }
766
+ appendCodeAgentTranscriptEvent({
767
+ runId: run.id,
768
+ kind: "status",
769
+ message: killed
770
+ ? "Stop requested for Agent-Native Code runner."
771
+ : "Stop requested; no active runner process was found from the CLI.",
772
+ metadata: {
773
+ source: "cli-stop",
774
+ pid: Number.isFinite(pid) ? pid : undefined,
775
+ killed,
776
+ killError: killError || undefined,
777
+ },
778
+ });
779
+ updateCodeAgentRunRecord(run.id, {
780
+ status: "paused",
781
+ phase: "stopped",
782
+ progress: {
783
+ label: "Stopped",
784
+ completed: 0,
785
+ total: 1,
786
+ percent: 0,
787
+ },
788
+ metadata: {
789
+ stoppedAt: new Date().toISOString(),
790
+ stoppedBy: "cli",
791
+ stopSignalSent: killed,
792
+ stopError: killError || undefined,
793
+ },
794
+ });
795
+ }
796
+ return [
797
+ "",
798
+ "Agent-Native Code stop",
799
+ "",
800
+ run ? ` Run: ${run.id}` : " No Agent-Native Code session selected.",
801
+ "",
802
+ run
803
+ ? " Stop requested. If a tracked runner process is active, it received SIGTERM."
804
+ : ' Start one with: agent-native code "what to change"',
805
+ ].join("\n");
806
+ }
807
+ async function approveCodeAgentRun(runs, args, output) {
808
+ const run = selectCodeAgentRun(runs, args, {
809
+ defaultToLast: args.includes("--last"),
810
+ });
811
+ if (!run) {
812
+ writeLine(output, [
813
+ "",
814
+ "Agent-Native Code approve",
815
+ "",
816
+ " No Agent-Native Code session selected.",
817
+ "",
818
+ "Try: agent-native code approve --last",
819
+ ].join("\n"));
820
+ return;
821
+ }
822
+ writeLine(output, [
823
+ "",
824
+ "Agent-Native Code approve",
825
+ "",
826
+ ` Run: ${run.id}`,
827
+ "",
828
+ "Running the pending approved command.",
829
+ ].join("\n"));
830
+ await executePendingCodeAgentApproval(run.id, { stdout: output });
831
+ writeLine(output, [
832
+ "",
833
+ "Approval step finished.",
834
+ "",
835
+ "Resume the Agent-Native Code session:",
836
+ ` agent-native code run ${run.id}`,
837
+ ].join("\n"));
838
+ }
839
+ function renderCodeAgentLogs(runs, args) {
840
+ const run = selectCodeAgentRun(runs, args, { defaultToLast: true });
841
+ if (!run) {
842
+ return [
843
+ "",
844
+ "Agent-Native Code logs",
845
+ "",
846
+ " No Agent-Native Code session selected.",
847
+ "",
848
+ "Try: agent-native code logs --last",
849
+ ].join("\n");
850
+ }
851
+ const events = listCodeAgentTranscriptEvents(run.id);
852
+ return [
853
+ "",
854
+ `Agent-Native Code logs: ${run.id}`,
855
+ `/${run.goalId} ${run.status}${run.phase ? ` (${run.phase})` : ""}`,
856
+ run.title,
857
+ `Updated: ${run.updatedAt}`,
858
+ `Events: ${events.length}`,
859
+ "",
860
+ events.length === 0
861
+ ? " No transcript events recorded yet."
862
+ : events.map(renderTranscriptEventForCli).join("\n"),
863
+ ].join("\n");
864
+ }
865
+ async function attachCodeAgentRun(runs, args, output) {
866
+ const run = selectCodeAgentRun(runs, args, { defaultToLast: true });
867
+ if (!run) {
868
+ writeLine(output, [
869
+ "",
870
+ "Agent-Native Code attach",
871
+ "",
872
+ " No Agent-Native Code session selected.",
873
+ "",
874
+ "Try: agent-native code attach --last",
875
+ ].join("\n"));
876
+ return;
877
+ }
878
+ const follow = !args.includes("--no-follow");
879
+ const printed = new Set();
880
+ writeLine(output, "");
881
+ writeLine(output, `Attaching to Agent-Native Code run ${run.id}`);
882
+ writeLine(output, "Press Ctrl+C to detach. The session keeps its transcript.");
883
+ writeLine(output, "");
884
+ const printNewEvents = () => {
885
+ const events = listCodeAgentTranscriptEvents(run.id);
886
+ for (const event of events) {
887
+ const key = `${event.id}:${event.createdAt}`;
888
+ if (printed.has(key))
889
+ continue;
890
+ printed.add(key);
891
+ writeLine(output, renderTranscriptEventForCli(event));
892
+ }
893
+ };
894
+ printNewEvents();
895
+ if (!follow)
896
+ return;
897
+ while (true) {
898
+ const latest = getCodeAgentRunRecord(run.id);
899
+ if (!latest || isTerminalRun(latest)) {
900
+ printNewEvents();
901
+ if (latest) {
902
+ writeLine(output, `\nRun ${latest.status}${latest.phase ? ` (${latest.phase})` : ""}.`);
903
+ }
904
+ return;
905
+ }
906
+ await delay(1_000);
907
+ printNewEvents();
908
+ }
909
+ }
910
+ function renderTranscriptEventForCli(event) {
911
+ const timestamp = event.createdAt.replace("T", " ").replace(/\.\d+Z$/, "Z");
912
+ const label = event.kind === "user"
913
+ ? "user"
914
+ : event.metadata?.role === "assistant"
915
+ ? "assistant"
916
+ : event.kind;
917
+ const tool = typeof event.metadata?.tool === "string" ? ` ${event.metadata.tool}` : "";
918
+ return `[${timestamp}] ${label}${tool}: ${event.message}`;
919
+ }
920
+ function isTerminalRun(run) {
921
+ return (run.status === "completed" ||
922
+ run.status === "errored" ||
923
+ run.status === "paused" ||
924
+ run.phase === "complete" ||
925
+ run.phase === "error" ||
926
+ run.phase === "paused" ||
927
+ run.phase === "missing-credentials" ||
928
+ run.phase === "stopped");
929
+ }
930
+ function delay(ms) {
931
+ return new Promise((resolve) => setTimeout(resolve, ms));
932
+ }
933
+ function selectCodeAgentRun(runs, args, options) {
934
+ const explicitRunId = getExplicitRunId(args);
935
+ if (explicitRunId) {
936
+ return runs.find((run) => run.id === explicitRunId) ?? null;
937
+ }
938
+ return options.defaultToLast ? (runs[0] ?? null) : null;
939
+ }
940
+ function hasExplicitRunId(args) {
941
+ return Boolean(getExplicitRunId(args));
942
+ }
943
+ function getExplicitRunId(args) {
944
+ const subcommand = args[0];
945
+ for (const arg of args.slice(1)) {
946
+ if (arg === "--last" || arg === "--")
947
+ continue;
948
+ if (arg.startsWith("-"))
949
+ continue;
950
+ if (arg === subcommand)
951
+ continue;
952
+ return arg;
953
+ }
954
+ return null;
955
+ }
956
+ function renderCodeAgentRunDetail(heading, run) {
957
+ const transcriptEvents = listCodeAgentTranscriptEvents(run.id);
958
+ return [
959
+ "",
960
+ heading,
961
+ "",
962
+ ` Run: ${run.id}`,
963
+ ` Goal: /${run.goalId}`,
964
+ ` Title: ${run.title}`,
965
+ run.subtitle ? ` Subtitle: ${run.subtitle}` : "",
966
+ run.permissionMode
967
+ ? ` Mode: ${formatCodeAgentRunMode(run.permissionMode)}`
968
+ : "",
969
+ ` Status: ${run.status}${run.phase ? ` (${run.phase})` : ""}`,
970
+ run.progress
971
+ ? ` Progress: ${run.progress.completed}/${run.progress.total} (${run.progress.percent}%)`
972
+ : "",
973
+ run.artifactRoot ? ` Artifacts: ${run.artifactRoot}` : "",
974
+ ` Transcript: ${transcriptEvents.length} event${transcriptEvents.length === 1 ? "" : "s"}`,
975
+ ` Updated: ${run.updatedAt}`,
976
+ ]
977
+ .filter(Boolean)
978
+ .join("\n");
979
+ }
980
+ function renderCodeAgentRunListItem(run) {
981
+ const progress = run.progress
982
+ ? `, ${run.progress.completed}/${run.progress.total}`
983
+ : "";
984
+ const permission = run.permissionMode
985
+ ? `, ${formatCodeAgentRunMode(run.permissionMode)}`
986
+ : "";
987
+ return [
988
+ ` - ${run.id}`,
989
+ ` /${run.goalId} ${run.status}${run.phase ? ` (${run.phase})` : ""}${progress}${permission}`,
990
+ ` ${truncateForDisplay(run.title, 100)}`,
991
+ ` updated ${run.updatedAt}`,
992
+ ].join("\n");
993
+ }
994
+ function isInteractiveTerminal(input, output) {
995
+ return Boolean(input.isTTY && output.isTTY);
996
+ }
997
+ function writeLine(output, text = "") {
998
+ output.write(`${text}\n`);
999
+ }
1000
+ function writePrompt(output) {
1001
+ output.write(SHELL_PROMPT);
1002
+ }
1003
+ async function runCodeGoal(goalId, forwardedArgs, output = process.stdout) {
1004
+ const goal = CODE_AGENT_CLI_GOALS.find((candidate) => candidate.id === goalId);
1005
+ if (!goal) {
1006
+ throw new Error(`Unknown Agent-Native Code goal: ${goalId}`);
1007
+ }
1008
+ switch (goal.backingCommand) {
1009
+ case "task":
1010
+ await runTask(forwardedArgs, output);
1011
+ return;
1012
+ case "audit-agent-web":
1013
+ await runAuditAgentWeb(forwardedArgs);
1014
+ return;
1015
+ case "migrate":
1016
+ await runMigrate(forwardedArgs);
1017
+ return;
1018
+ }
1019
+ }
1020
+ async function runTask(forwardedArgs, output, options = {}) {
1021
+ const parsed = parseTaskArgs(forwardedArgs, options.permissionMode);
1022
+ if (parsed.error) {
1023
+ writeLine(output, parsed.error);
1024
+ writeLine(output, taskUsage());
1025
+ return;
1026
+ }
1027
+ if (!parsed.prompt) {
1028
+ writeLine(output, taskUsage());
1029
+ return;
1030
+ }
1031
+ const prompt = parsed.prompt;
1032
+ const run = createCodeAgentRunRecord({
1033
+ goalId: "task",
1034
+ title: titleFromPrompt(prompt),
1035
+ subtitle: options.subtitle ?? "Generic coding task",
1036
+ status: "running",
1037
+ phase: "starting",
1038
+ permissionMode: parsed.permissionMode,
1039
+ progress: {
1040
+ label: "Starting",
1041
+ completed: 0,
1042
+ total: 1,
1043
+ percent: 5,
1044
+ },
1045
+ details: [
1046
+ { label: "Prompt", value: truncateForDisplay(prompt, 160) },
1047
+ { label: "Agent", value: "Running locally" },
1048
+ { label: "Mode", value: formatCodeAgentRunMode(parsed.permissionMode) },
1049
+ ],
1050
+ cwd: process.cwd(),
1051
+ metadata: {
1052
+ prompt,
1053
+ source: options.source ?? "agent-native code",
1054
+ commandName: options.commandName,
1055
+ commandPath: options.commandPath,
1056
+ permissionMode: parsed.permissionMode,
1057
+ },
1058
+ });
1059
+ appendCodeAgentTranscriptEvent({
1060
+ runId: run.id,
1061
+ kind: "user",
1062
+ message: prompt,
1063
+ metadata: { source: "initial-prompt" },
1064
+ });
1065
+ appendCodeAgentTranscriptEvent({
1066
+ runId: run.id,
1067
+ kind: "status",
1068
+ message: "Starting local Agent-Native Code execution.",
1069
+ metadata: {
1070
+ status: "running",
1071
+ phase: "starting",
1072
+ },
1073
+ });
1074
+ writeLine(output, renderTaskStarted(run, prompt));
1075
+ await executeCodeAgentRun({
1076
+ runId: run.id,
1077
+ prompt,
1078
+ appendUserEvent: false,
1079
+ stdout: output,
1080
+ });
1081
+ }
1082
+ async function runProjectSlashCommand(commandName, forwardedArgs, output) {
1083
+ const command = findProjectSlashCommand(commandName);
1084
+ if (!command) {
1085
+ writeLine(output, `Project slash command not found: /${normalizeGoalToken(commandName)}`);
1086
+ return;
1087
+ }
1088
+ const parsed = parseTaskArgs(forwardedArgs);
1089
+ if (parsed.error) {
1090
+ writeLine(output, parsed.error);
1091
+ return;
1092
+ }
1093
+ const prompt = renderProjectSlashCommandPrompt(command, parsed.promptArgs);
1094
+ await runTask([prompt], output, {
1095
+ subtitle: `Project command /${command.name}`,
1096
+ source: "agent-native code project-command",
1097
+ commandName: command.name,
1098
+ commandPath: command.path,
1099
+ permissionMode: parsed.permissionMode,
1100
+ });
1101
+ }
1102
+ async function recordCodeAgentFollowUpPrompt(prompt, output, permissionMode, runId, followUpMode = "immediate") {
1103
+ const run = runId
1104
+ ? getCodeAgentRunRecord(runId)
1105
+ : getLastCodeAgentRunRecord();
1106
+ if (!run) {
1107
+ writeLine(output, [
1108
+ "",
1109
+ runId
1110
+ ? `Agent-Native Code run not found: ${runId}`
1111
+ : "No Agent-Native Code runs found.",
1112
+ "",
1113
+ 'Start one with: agent-native code "what to change"',
1114
+ ].join("\n"));
1115
+ return;
1116
+ }
1117
+ const activeRun = permissionMode
1118
+ ? (updateCodeAgentRunRecord(run.id, { permissionMode }) ?? run)
1119
+ : run;
1120
+ const shouldQueue = isActiveCodeAgentRun(activeRun);
1121
+ const event = appendCodeAgentTranscriptEvent({
1122
+ runId: activeRun.id,
1123
+ kind: "user",
1124
+ message: prompt,
1125
+ metadata: {
1126
+ source: "resume-follow-up",
1127
+ permissionMode,
1128
+ followUpMode,
1129
+ delivery: shouldQueue ? followUpMode : "run-now",
1130
+ },
1131
+ });
1132
+ if (shouldQueue) {
1133
+ queueCodeAgentFollowUp({
1134
+ runId: activeRun.id,
1135
+ prompt,
1136
+ mode: followUpMode,
1137
+ eventId: event.id,
1138
+ permissionMode,
1139
+ source: "resume-follow-up",
1140
+ createdAt: event.createdAt,
1141
+ });
1142
+ writeLine(output, renderFollowUpRecorded(activeRun, event, followUpMode));
1143
+ return;
1144
+ }
1145
+ writeLine(output, renderFollowUpRecorded(activeRun, event, "immediate"));
1146
+ await executeCodeAgentRun({
1147
+ runId: activeRun.id,
1148
+ prompt,
1149
+ appendUserEvent: false,
1150
+ stdout: output,
1151
+ });
1152
+ }
1153
+ function parseTaskArgs(forwardedArgs, defaultPermissionMode = "full-auto") {
1154
+ const promptArgs = [];
1155
+ let permissionMode = defaultPermissionMode;
1156
+ let permissionModeExplicit = false;
1157
+ for (let index = 0; index < forwardedArgs.length; index += 1) {
1158
+ const arg = forwardedArgs[index];
1159
+ if (arg === "--") {
1160
+ promptArgs.push(...forwardedArgs.slice(index + 1));
1161
+ break;
1162
+ }
1163
+ if (arg === "--permission-mode") {
1164
+ const value = forwardedArgs[index + 1];
1165
+ const normalized = normalizeCodeAgentPermissionMode(value);
1166
+ if (!normalized) {
1167
+ return {
1168
+ prompt: "",
1169
+ promptArgs,
1170
+ permissionMode,
1171
+ error: `Invalid run mode: ${value ?? "(missing)"}`,
1172
+ };
1173
+ }
1174
+ permissionMode = normalized;
1175
+ permissionModeExplicit = true;
1176
+ index += 1;
1177
+ continue;
1178
+ }
1179
+ if (arg.startsWith("--permission-mode=")) {
1180
+ const normalized = normalizeCodeAgentPermissionMode(arg.slice("--permission-mode=".length));
1181
+ if (!normalized) {
1182
+ return {
1183
+ prompt: "",
1184
+ promptArgs,
1185
+ permissionMode,
1186
+ error: `Invalid run mode: ${arg.slice("--permission-mode=".length)}`,
1187
+ };
1188
+ }
1189
+ permissionMode = normalized;
1190
+ permissionModeExplicit = true;
1191
+ continue;
1192
+ }
1193
+ const shorthand = parsePermissionModeFlag(arg);
1194
+ if (shorthand) {
1195
+ permissionMode = shorthand;
1196
+ permissionModeExplicit = true;
1197
+ continue;
1198
+ }
1199
+ promptArgs.push(arg);
1200
+ }
1201
+ return {
1202
+ prompt: promptArgs.join(" ").trim(),
1203
+ promptArgs,
1204
+ permissionMode,
1205
+ permissionModeExplicit,
1206
+ };
1207
+ }
1208
+ function parseFollowUpArgs(forwardedArgs) {
1209
+ const promptArgs = [];
1210
+ let followUpMode = "immediate";
1211
+ for (let index = 0; index < forwardedArgs.length; index += 1) {
1212
+ const arg = forwardedArgs[index];
1213
+ if (arg === "--") {
1214
+ promptArgs.push(...forwardedArgs.slice(index));
1215
+ break;
1216
+ }
1217
+ if (arg === "--queue" || arg === "--after-completion") {
1218
+ followUpMode = "queued";
1219
+ continue;
1220
+ }
1221
+ if (arg === "--immediate" || arg === "--steer") {
1222
+ followUpMode = "immediate";
1223
+ continue;
1224
+ }
1225
+ promptArgs.push(arg);
1226
+ }
1227
+ return {
1228
+ ...parseTaskArgs(promptArgs),
1229
+ followUpMode,
1230
+ };
1231
+ }
1232
+ function parsePermissionModeFlag(arg) {
1233
+ switch (arg) {
1234
+ case "--plan":
1235
+ case "--read-only":
1236
+ return "read-only";
1237
+ case "--auto":
1238
+ return "full-auto";
1239
+ case "--ask-before-edit":
1240
+ return "ask-before-edit";
1241
+ case "--auto-edit":
1242
+ return "auto-edit";
1243
+ case "--full-auto":
1244
+ return "full-auto";
1245
+ default:
1246
+ return null;
1247
+ }
1248
+ }
1249
+ function titleFromPrompt(prompt) {
1250
+ return truncateForDisplay(prompt.replace(/\s+/g, " "), 80);
1251
+ }
1252
+ function truncateForDisplay(value, maxLength) {
1253
+ if (value.length <= maxLength)
1254
+ return value;
1255
+ return `${value.slice(0, Math.max(0, maxLength - 3))}...`;
1256
+ }
1257
+ function renderTaskStarted(run, prompt) {
1258
+ return [
1259
+ "",
1260
+ "Agent-Native Code session started.",
1261
+ "",
1262
+ ` Run: ${run.id}`,
1263
+ ` Prompt: ${truncateForDisplay(prompt, 160)}`,
1264
+ ` Mode: ${formatCodeAgentRunMode(run.permissionMode)}`,
1265
+ "",
1266
+ "Streaming output below. The transcript is saved with this run.",
1267
+ ].join("\n");
1268
+ }
1269
+ function renderFollowUpRecorded(run, event, mode) {
1270
+ const active = isActiveCodeAgentRun(run);
1271
+ const heading = active
1272
+ ? mode === "queued"
1273
+ ? "Queued follow-up prompt for Agent-Native Code run."
1274
+ : "Recorded steering prompt for active Agent-Native Code run."
1275
+ : "Running follow-up prompt for Agent-Native Code run.";
1276
+ return [
1277
+ "",
1278
+ heading,
1279
+ "",
1280
+ ` Run: ${run.id}`,
1281
+ ` Goal: /${run.goalId}`,
1282
+ ` Event: ${event.id}`,
1283
+ "",
1284
+ active
1285
+ ? mode === "queued"
1286
+ ? "It will run after the current execution finishes."
1287
+ : "It will be applied by the active runner as soon as it can steer."
1288
+ : "Streaming output below. The transcript is saved with this run.",
1289
+ ].join("\n");
1290
+ }
1291
+ function taskUsage() {
1292
+ return [
1293
+ "",
1294
+ "Usage:",
1295
+ ' agent-native code "what to change"',
1296
+ ' agent-native code --plan "explain this repo"',
1297
+ ' agent-native code --auto "fix this and verify it"',
1298
+ ` agent-native code --permission-mode ${CODE_AGENT_PERMISSION_MODES.join("|")} "what to change"`,
1299
+ "",
1300
+ "The task goal starts a local Agent-Native Code session, saves transcript events, and can be resumed with follow-up prompts.",
1301
+ ].join("\n");
1302
+ }
1303
+ function formatCodeAgentRunMode(permissionMode) {
1304
+ return permissionMode === "read-only" ? "Plan mode" : "Auto mode";
1305
+ }
1306
+ //# sourceMappingURL=code.js.map