@agent-native/core 0.149.2 → 0.149.3

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 (345) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +54 -488
  3. package/corpus/templates/analytics/.agents/skills/actions/references/action-fields.md +136 -0
  4. package/corpus/templates/analytics/.agents/skills/actions/references/examples.md +94 -0
  5. package/corpus/templates/analytics/.agents/skills/actions/references/provider-apis.md +95 -0
  6. package/corpus/templates/analytics/.agents/skills/create-skill/SKILL.md +9 -35
  7. package/corpus/templates/analytics/.agents/skills/creative-context/SKILL.md +4 -2
  8. package/corpus/templates/analytics/.agents/skills/frontend-design/SKILL.md +4 -5
  9. package/corpus/templates/analytics/.agents/skills/turn-into-app/SKILL.md +18 -31
  10. package/corpus/templates/analytics/AGENTS.md +25 -32
  11. package/corpus/templates/analytics/app/global.css +1 -1
  12. package/corpus/templates/analytics/changelog/2026-08-11-full-page-chat-composers-stay-at-a-focused-750px-width.md +6 -0
  13. package/corpus/templates/assets/.agents/skills/actions/SKILL.md +54 -488
  14. package/corpus/templates/assets/.agents/skills/actions/references/action-fields.md +136 -0
  15. package/corpus/templates/assets/.agents/skills/actions/references/examples.md +94 -0
  16. package/corpus/templates/assets/.agents/skills/actions/references/provider-apis.md +95 -0
  17. package/corpus/templates/assets/.agents/skills/create-skill/SKILL.md +9 -35
  18. package/corpus/templates/assets/.agents/skills/creative-context/SKILL.md +4 -2
  19. package/corpus/templates/assets/.agents/skills/frontend-design/SKILL.md +4 -5
  20. package/corpus/templates/assets/.agents/skills/turn-into-app/SKILL.md +18 -31
  21. package/corpus/templates/assets/AGENTS.md +6 -9
  22. package/corpus/templates/assets/app/global.css +1 -1
  23. package/corpus/templates/assets/changelog/2026-08-11-full-page-chat-composers-stay-at-a-focused-750px-width.md +6 -0
  24. package/corpus/templates/brain/.agents/skills/actions/SKILL.md +54 -488
  25. package/corpus/templates/brain/.agents/skills/actions/references/action-fields.md +136 -0
  26. package/corpus/templates/brain/.agents/skills/actions/references/examples.md +94 -0
  27. package/corpus/templates/brain/.agents/skills/actions/references/provider-apis.md +95 -0
  28. package/corpus/templates/brain/.agents/skills/create-skill/SKILL.md +9 -35
  29. package/corpus/templates/brain/.agents/skills/frontend-design/SKILL.md +4 -5
  30. package/corpus/templates/brain/.agents/skills/turn-into-app/SKILL.md +18 -31
  31. package/corpus/templates/brain/AGENTS.md +5 -12
  32. package/corpus/templates/brain/app/global.css +1 -1
  33. package/corpus/templates/brain/changelog/2026-08-11-full-page-chat-composers-stay-at-a-focused-750px-width.md +6 -0
  34. package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +54 -488
  35. package/corpus/templates/calendar/.agents/skills/actions/references/action-fields.md +136 -0
  36. package/corpus/templates/calendar/.agents/skills/actions/references/examples.md +94 -0
  37. package/corpus/templates/calendar/.agents/skills/actions/references/provider-apis.md +95 -0
  38. package/corpus/templates/calendar/.agents/skills/create-skill/SKILL.md +9 -35
  39. package/corpus/templates/calendar/.agents/skills/frontend-design/SKILL.md +4 -5
  40. package/corpus/templates/calendar/.agents/skills/turn-into-app/SKILL.md +18 -31
  41. package/corpus/templates/calendar/AGENTS.md +8 -9
  42. package/corpus/templates/chat/.agents/skills/actions/SKILL.md +54 -488
  43. package/corpus/templates/chat/.agents/skills/actions/references/action-fields.md +136 -0
  44. package/corpus/templates/chat/.agents/skills/actions/references/examples.md +94 -0
  45. package/corpus/templates/chat/.agents/skills/actions/references/provider-apis.md +95 -0
  46. package/corpus/templates/chat/.agents/skills/create-skill/SKILL.md +9 -35
  47. package/corpus/templates/chat/.agents/skills/frontend-design/SKILL.md +4 -5
  48. package/corpus/templates/chat/.agents/skills/turn-into-app/SKILL.md +18 -31
  49. package/corpus/templates/chat/AGENTS.md +32 -80
  50. package/corpus/templates/clips/.agents/skills/actions/SKILL.md +54 -488
  51. package/corpus/templates/clips/.agents/skills/actions/references/action-fields.md +136 -0
  52. package/corpus/templates/clips/.agents/skills/actions/references/examples.md +94 -0
  53. package/corpus/templates/clips/.agents/skills/actions/references/provider-apis.md +95 -0
  54. package/corpus/templates/clips/.agents/skills/create-skill/SKILL.md +9 -35
  55. package/corpus/templates/clips/.agents/skills/frontend-design/SKILL.md +4 -5
  56. package/corpus/templates/clips/.agents/skills/turn-into-app/SKILL.md +18 -31
  57. package/corpus/templates/clips/AGENTS.md +25 -31
  58. package/corpus/templates/content/.agents/skills/actions/SKILL.md +54 -488
  59. package/corpus/templates/content/.agents/skills/actions/references/action-fields.md +136 -0
  60. package/corpus/templates/content/.agents/skills/actions/references/examples.md +94 -0
  61. package/corpus/templates/content/.agents/skills/actions/references/provider-apis.md +95 -0
  62. package/corpus/templates/content/.agents/skills/create-skill/SKILL.md +9 -35
  63. package/corpus/templates/content/.agents/skills/creative-context/SKILL.md +4 -2
  64. package/corpus/templates/content/.agents/skills/frontend-design/SKILL.md +4 -5
  65. package/corpus/templates/content/.agents/skills/turn-into-app/SKILL.md +18 -31
  66. package/corpus/templates/content/AGENTS.md +5 -9
  67. package/corpus/templates/crm/.agents/skills/turn-into-app/SKILL.md +18 -31
  68. package/corpus/templates/crm/AGENTS.md +7 -11
  69. package/corpus/templates/crm/app/global.css +1 -1
  70. package/corpus/templates/crm/changelog/2026-08-11-full-page-chat-composers-stay-at-a-focused-750px-width.md +6 -0
  71. package/corpus/templates/design/.agents/skills/actions/SKILL.md +54 -488
  72. package/corpus/templates/design/.agents/skills/actions/references/action-fields.md +136 -0
  73. package/corpus/templates/design/.agents/skills/actions/references/examples.md +94 -0
  74. package/corpus/templates/design/.agents/skills/actions/references/provider-apis.md +95 -0
  75. package/corpus/templates/design/.agents/skills/create-skill/SKILL.md +9 -35
  76. package/corpus/templates/design/.agents/skills/creative-context/SKILL.md +4 -2
  77. package/corpus/templates/design/.agents/skills/frontend-design/SKILL.md +4 -5
  78. package/corpus/templates/design/.agents/skills/turn-into-app/SKILL.md +18 -31
  79. package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +70 -3
  80. package/corpus/templates/design/AGENTS.md +13 -21
  81. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +12 -0
  82. package/corpus/templates/design/app/components/design/LayersPanel.tsx +19 -2
  83. package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +115 -7
  84. package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +82 -7
  85. package/corpus/templates/design/app/components/design/design-trace.ts +120 -0
  86. package/corpus/templates/design/app/components/design/dnd-debug.ts +2 -1
  87. package/corpus/templates/design/app/components/design/edit-panel/position-layout-properties.tsx +40 -26
  88. package/corpus/templates/design/app/components/design/multi-screen/board-surface-html.ts +4 -1
  89. package/corpus/templates/design/app/components/design/multi-screen/frame-geometry.ts +12 -3
  90. package/corpus/templates/design/app/components/design/multi-screen/screen-content-cache.ts +4 -0
  91. package/corpus/templates/design/app/components/design/multi-screen/types.ts +7 -0
  92. package/corpus/templates/design/app/components/editor/PromptDialog.tsx +3 -2
  93. package/corpus/templates/design/app/components/layout/Sidebar.tsx +2 -2
  94. package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +3 -0
  95. package/corpus/templates/design/app/i18n-data.ts +1 -0
  96. package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +5 -5
  97. package/corpus/templates/design/app/pages/DesignSystems.tsx +3 -2
  98. package/corpus/templates/design/app/pages/design-editor/canvas-primitive-insert.ts +100 -13
  99. package/corpus/templates/design/app/pages/design-editor/cross-screen-text-color.ts +1 -1
  100. package/corpus/templates/design/app/pages/design-editor/data-operations.ts +14 -0
  101. package/corpus/templates/design/changelog/2026-08-10-marquee-selecting-layers-far-down-a-tall-screen-now-selects-.md +6 -0
  102. package/corpus/templates/design/changelog/2026-08-10-the-frame-tool-draws-a-plain-frame-by-default-with-screen-av.md +6 -0
  103. package/corpus/templates/design/e2e/global-setup.ts +27 -32
  104. package/corpus/templates/design/playwright.config.ts +3 -5
  105. package/corpus/templates/design/shared/breakpoint-media.ts +9 -2
  106. package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +54 -488
  107. package/corpus/templates/dispatch/.agents/skills/actions/references/action-fields.md +136 -0
  108. package/corpus/templates/dispatch/.agents/skills/actions/references/examples.md +94 -0
  109. package/corpus/templates/dispatch/.agents/skills/actions/references/provider-apis.md +95 -0
  110. package/corpus/templates/dispatch/.agents/skills/create-skill/SKILL.md +9 -35
  111. package/corpus/templates/dispatch/.agents/skills/frontend-design/SKILL.md +4 -5
  112. package/corpus/templates/dispatch/.agents/skills/turn-into-app/SKILL.md +18 -31
  113. package/corpus/templates/dispatch/AGENTS.md +9 -16
  114. package/corpus/templates/factory/.agents/skills/actions/SKILL.md +54 -488
  115. package/corpus/templates/factory/.agents/skills/actions/references/action-fields.md +136 -0
  116. package/corpus/templates/factory/.agents/skills/actions/references/examples.md +94 -0
  117. package/corpus/templates/factory/.agents/skills/actions/references/provider-apis.md +95 -0
  118. package/corpus/templates/factory/.agents/skills/create-skill/SKILL.md +9 -35
  119. package/corpus/templates/factory/.agents/skills/frontend-design/SKILL.md +4 -5
  120. package/corpus/templates/factory/.agents/skills/turn-into-app/SKILL.md +18 -31
  121. package/corpus/templates/factory/AGENTS.md +10 -24
  122. package/corpus/templates/forms/.agents/skills/actions/SKILL.md +54 -488
  123. package/corpus/templates/forms/.agents/skills/actions/references/action-fields.md +136 -0
  124. package/corpus/templates/forms/.agents/skills/actions/references/examples.md +94 -0
  125. package/corpus/templates/forms/.agents/skills/actions/references/provider-apis.md +95 -0
  126. package/corpus/templates/forms/.agents/skills/create-skill/SKILL.md +9 -35
  127. package/corpus/templates/forms/.agents/skills/frontend-design/SKILL.md +4 -5
  128. package/corpus/templates/forms/.agents/skills/turn-into-app/SKILL.md +18 -31
  129. package/corpus/templates/forms/AGENTS.md +11 -17
  130. package/corpus/templates/forms/app/global.css +1 -0
  131. package/corpus/templates/forms/changelog/2026-08-11-full-page-chat-composers-stay-at-a-focused-750px-width.md +6 -0
  132. package/corpus/templates/macros/.agents/skills/frontend-design/SKILL.md +4 -5
  133. package/corpus/templates/macros/.agents/skills/turn-into-app/SKILL.md +18 -31
  134. package/corpus/templates/macros/AGENTS.md +8 -8
  135. package/corpus/templates/mail/.agents/skills/actions/SKILL.md +54 -488
  136. package/corpus/templates/mail/.agents/skills/actions/references/action-fields.md +136 -0
  137. package/corpus/templates/mail/.agents/skills/actions/references/examples.md +94 -0
  138. package/corpus/templates/mail/.agents/skills/actions/references/provider-apis.md +95 -0
  139. package/corpus/templates/mail/.agents/skills/create-skill/SKILL.md +9 -35
  140. package/corpus/templates/mail/.agents/skills/frontend-design/SKILL.md +4 -5
  141. package/corpus/templates/mail/.agents/skills/turn-into-app/SKILL.md +18 -31
  142. package/corpus/templates/mail/AGENTS.md +5 -6
  143. package/corpus/templates/plan/.agents/skills/actions/SKILL.md +54 -488
  144. package/corpus/templates/plan/.agents/skills/actions/references/action-fields.md +136 -0
  145. package/corpus/templates/plan/.agents/skills/actions/references/examples.md +94 -0
  146. package/corpus/templates/plan/.agents/skills/actions/references/provider-apis.md +95 -0
  147. package/corpus/templates/plan/.agents/skills/create-skill/SKILL.md +9 -35
  148. package/corpus/templates/plan/.agents/skills/frontend-design/SKILL.md +4 -5
  149. package/corpus/templates/plan/.agents/skills/turn-into-app/SKILL.md +18 -31
  150. package/corpus/templates/plan/AGENTS.md +5 -14
  151. package/corpus/templates/plan/changelog/2026-08-11-plan-no-longer-reloads-when-runtime-state-changes.md +6 -0
  152. package/corpus/templates/plan/vite.config.ts +5 -0
  153. package/corpus/templates/slides/.agents/skills/actions/SKILL.md +54 -488
  154. package/corpus/templates/slides/.agents/skills/actions/references/action-fields.md +136 -0
  155. package/corpus/templates/slides/.agents/skills/actions/references/examples.md +94 -0
  156. package/corpus/templates/slides/.agents/skills/actions/references/provider-apis.md +95 -0
  157. package/corpus/templates/slides/.agents/skills/create-deck/SKILL.md +2 -2
  158. package/corpus/templates/slides/.agents/skills/create-skill/SKILL.md +9 -35
  159. package/corpus/templates/slides/.agents/skills/creative-context/SKILL.md +6 -3
  160. package/corpus/templates/slides/.agents/skills/deck-management/SKILL.md +6 -1
  161. package/corpus/templates/slides/.agents/skills/frontend-design/SKILL.md +4 -5
  162. package/corpus/templates/slides/.agents/skills/image-generation-via-a2a/SKILL.md +3 -2
  163. package/corpus/templates/slides/.agents/skills/slide-editing/SKILL.md +3 -0
  164. package/corpus/templates/slides/.agents/skills/slide-images/SKILL.md +3 -3
  165. package/corpus/templates/slides/.agents/skills/turn-into-app/SKILL.md +18 -31
  166. package/corpus/templates/slides/AGENTS.md +22 -25
  167. package/corpus/templates/slides/actions/get-deck-reference-context.ts +2 -2
  168. package/corpus/templates/slides/actions/get-deck.ts +57 -9
  169. package/corpus/templates/slides/actions/import-file.ts +2 -1
  170. package/corpus/templates/slides/actions/patch-deck.ts +45 -2
  171. package/corpus/templates/slides/actions/update-slide.ts +1 -1
  172. package/corpus/templates/slides/app/components/comments/SlideCommentsPanel.tsx +2 -2
  173. package/corpus/templates/slides/app/components/deck/DeckCard.tsx +1 -23
  174. package/corpus/templates/slides/app/components/design-system/DesignSystemCard.tsx +2 -2
  175. package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +6 -6
  176. package/corpus/templates/slides/app/components/editor/AnimationsPanel.tsx +3 -3
  177. package/corpus/templates/slides/app/components/editor/DeckEditorSkeleton.tsx +4 -4
  178. package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +1 -1
  179. package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +428 -180
  180. package/corpus/templates/slides/app/components/editor/ExportMenu.tsx +294 -266
  181. package/corpus/templates/slides/app/components/editor/PromptDialog.tsx +7 -5
  182. package/corpus/templates/slides/app/components/editor/SlideContextToolbar.tsx +1 -1
  183. package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +40 -12
  184. package/corpus/templates/slides/app/components/editor/SpeakerNotesPanel.tsx +6 -12
  185. package/corpus/templates/slides/app/components/editor/editor-command-model.ts +35 -0
  186. package/corpus/templates/slides/app/components/layout/Sidebar.tsx +8 -10
  187. package/corpus/templates/slides/app/context/DeckContext.tsx +2 -1
  188. package/corpus/templates/slides/app/global.css +76 -1
  189. package/corpus/templates/slides/app/i18n/en-US.ts +1 -0
  190. package/corpus/templates/slides/app/lib/create-deck-generation.ts +51 -23
  191. package/corpus/templates/slides/app/lib/slide-animation-elements.ts +68 -5
  192. package/corpus/templates/slides/app/pages/DeckEditor.tsx +13 -6
  193. package/corpus/templates/slides/app/pages/DesignSystems.tsx +2 -2
  194. package/corpus/templates/slides/app/pages/Index.tsx +87 -74
  195. package/corpus/templates/slides/app/root.tsx +43 -0
  196. package/corpus/templates/slides/changelog/2026-08-11-faster-slides-chat-deck-reads.md +6 -0
  197. package/corpus/templates/slides/changelog/2026-08-11-slides-chat-can-read-one-slide-without-loading-the-full-deck.md +6 -0
  198. package/corpus/templates/slides/changelog/2026-08-11-slides-clearly-indicate-when-an-ai-agent-is-editing-alongsid.md +6 -0
  199. package/corpus/templates/slides/package.json +1 -0
  200. package/corpus/templates/slides/server/lib/validate-slide-animations.ts +163 -0
  201. package/corpus/templates/slides/server/plugins/agent-chat.ts +4 -3
  202. package/corpus/templates/slides/shared/api.ts +46 -15
  203. package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +54 -488
  204. package/corpus/templates/tasks/.agents/skills/actions/references/action-fields.md +136 -0
  205. package/corpus/templates/tasks/.agents/skills/actions/references/examples.md +94 -0
  206. package/corpus/templates/tasks/.agents/skills/actions/references/provider-apis.md +95 -0
  207. package/corpus/templates/tasks/.agents/skills/agent-watchdog/SKILL.md +1 -0
  208. package/corpus/templates/tasks/.agents/skills/create-skill/SKILL.md +9 -35
  209. package/corpus/templates/tasks/.agents/skills/efficient-fable/SKILL.md +1 -0
  210. package/corpus/templates/tasks/.agents/skills/efficient-frontier/SKILL.md +1 -0
  211. package/corpus/templates/tasks/.agents/skills/frontend-design/SKILL.md +4 -5
  212. package/corpus/templates/tasks/.agents/skills/plan-arbiter/SKILL.md +1 -0
  213. package/corpus/templates/tasks/.agents/skills/plow-ahead/SKILL.md +1 -0
  214. package/corpus/templates/tasks/.agents/skills/quick-recap/SKILL.md +1 -0
  215. package/corpus/templates/tasks/.agents/skills/read-the-damn-docs/SKILL.md +1 -0
  216. package/corpus/templates/tasks/.agents/skills/stay-within-limits/SKILL.md +1 -0
  217. package/corpus/templates/tasks/.agents/skills/turn-into-app/SKILL.md +18 -31
  218. package/corpus/templates/tasks/AGENTS.md +5 -20
  219. package/dist/agent/production-agent.js +376 -345
  220. package/dist/agent/run-manager.js +156 -14
  221. package/dist/agent/run-store.d.ts +11 -10
  222. package/dist/agent/run-store.js +17 -13
  223. package/dist/client/AssistantChat.d.ts +6 -2
  224. package/dist/client/AssistantChat.js +216 -131
  225. package/dist/client/active-run-state.d.ts +9 -1
  226. package/dist/client/active-run-state.js +34 -3
  227. package/dist/client/agent-chat-adapter.d.ts +8 -0
  228. package/dist/client/agent-chat-adapter.js +114 -28
  229. package/dist/client/chat/message-components.d.ts +7 -1
  230. package/dist/client/chat/message-components.js +32 -5
  231. package/dist/client/chat/run-recovery.d.ts +1 -0
  232. package/dist/client/chat/run-recovery.js +8 -0
  233. package/dist/client/chat/tool-call-display.d.ts +2 -0
  234. package/dist/client/chat/tool-call-display.js +2 -0
  235. package/dist/client/chat-first/apps-rail.js +1 -1
  236. package/dist/client/chat-first/chat-history.d.ts +1 -1
  237. package/dist/client/chat-first/chat-history.js +5 -2
  238. package/dist/client/sse-event-processor.d.ts +4 -2
  239. package/dist/client/sse-event-processor.js +36 -6
  240. package/dist/client/use-run-stuck-detection.d.ts +2 -0
  241. package/dist/client/use-run-stuck-detection.js +85 -9
  242. package/dist/collab/awareness.d.ts +2 -2
  243. package/dist/collab/routes.d.ts +1 -1
  244. package/dist/integrations/adapters/slack.d.ts +0 -4
  245. package/dist/integrations/adapters/slack.js +6 -30
  246. package/dist/integrations/catalog.js +1 -1
  247. package/dist/integrations/pending-tasks-store.d.ts +0 -8
  248. package/dist/integrations/pending-tasks-store.js +0 -21
  249. package/dist/integrations/slack-manifest.d.ts +2 -2
  250. package/dist/integrations/slack-manifest.js +0 -3
  251. package/dist/mcp/screen-memory-stdio.d.ts +7 -7
  252. package/dist/observability/routes.d.ts +3 -3
  253. package/dist/provider-api/actions/custom-provider-registration.d.ts +4 -4
  254. package/dist/provider-api/actions/provider-api.d.ts +8 -8
  255. package/dist/resources/handlers.d.ts +1 -1
  256. package/dist/scripts/docs/source-search.js +2 -2
  257. package/dist/secrets/routes.d.ts +9 -9
  258. package/dist/server/agent-chat/framework-prompts.js +7 -2
  259. package/dist/server/agent-chat/prompt-resources.js +2 -2
  260. package/dist/server/agent-chat/skill-frontmatter.d.ts +31 -2
  261. package/dist/server/agent-chat/skill-frontmatter.js +41 -15
  262. package/dist/server/agent-chat-plugin.js +3 -3
  263. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  264. package/dist/server/agents-bundle.d.ts +16 -19
  265. package/dist/server/agents-bundle.js +19 -35
  266. package/dist/server/better-auth-instance.d.ts +1 -0
  267. package/dist/server/better-auth-instance.js +17 -2
  268. package/dist/server/prompts/framework-core-compact.d.ts +6 -1
  269. package/dist/server/prompts/framework-core-compact.js +12 -9
  270. package/dist/server/prompts/framework-core.d.ts +6 -1
  271. package/dist/server/prompts/framework-core.js +11 -9
  272. package/dist/server/prompts/index.d.ts +1 -1
  273. package/dist/server/prompts/index.js +1 -1
  274. package/dist/server/prompts/shared-rules.d.ts +15 -11
  275. package/dist/server/prompts/shared-rules.js +17 -13
  276. package/dist/server/realtime-token.d.ts +1 -1
  277. package/dist/server/transcribe-voice.d.ts +1 -1
  278. package/dist/templates/chat/.agents/skills/actions/SKILL.md +54 -488
  279. package/dist/templates/chat/.agents/skills/actions/references/action-fields.md +136 -0
  280. package/dist/templates/chat/.agents/skills/actions/references/examples.md +94 -0
  281. package/dist/templates/chat/.agents/skills/actions/references/provider-apis.md +95 -0
  282. package/dist/templates/chat/.agents/skills/create-skill/SKILL.md +9 -35
  283. package/dist/templates/chat/.agents/skills/frontend-design/SKILL.md +4 -5
  284. package/dist/templates/chat/.agents/skills/turn-into-app/SKILL.md +18 -31
  285. package/dist/templates/chat/AGENTS.md +32 -80
  286. package/dist/templates/default/.agents/skills/actions/SKILL.md +54 -488
  287. package/dist/templates/default/.agents/skills/actions/references/action-fields.md +136 -0
  288. package/dist/templates/default/.agents/skills/actions/references/examples.md +94 -0
  289. package/dist/templates/default/.agents/skills/actions/references/provider-apis.md +95 -0
  290. package/dist/templates/default/.agents/skills/create-skill/SKILL.md +9 -35
  291. package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +4 -5
  292. package/dist/templates/default/.agents/skills/turn-into-app/SKILL.md +18 -31
  293. package/dist/templates/headless/.agents/skills/actions/SKILL.md +54 -488
  294. package/dist/templates/headless/.agents/skills/actions/references/action-fields.md +136 -0
  295. package/dist/templates/headless/.agents/skills/actions/references/examples.md +94 -0
  296. package/dist/templates/headless/.agents/skills/actions/references/provider-apis.md +95 -0
  297. package/dist/templates/headless/.agents/skills/turn-into-app/SKILL.md +18 -31
  298. package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +54 -488
  299. package/dist/templates/workspace-core/.agents/skills/actions/references/action-fields.md +136 -0
  300. package/dist/templates/workspace-core/.agents/skills/actions/references/examples.md +94 -0
  301. package/dist/templates/workspace-core/.agents/skills/actions/references/provider-apis.md +95 -0
  302. package/dist/templates/workspace-core/.agents/skills/adding-workspace-apps/SKILL.md +1 -0
  303. package/dist/templates/workspace-core/.agents/skills/agent-page/SKILL.md +1 -0
  304. package/dist/templates/workspace-core/.agents/skills/create-skill/SKILL.md +9 -35
  305. package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +4 -5
  306. package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +21 -29
  307. package/dist/templates/workspace-core/.agents/skills/turn-into-app/SKILL.md +18 -31
  308. package/dist/templates/workspace-core/.agents/skills/workspace-conventions/SKILL.md +7 -17
  309. package/dist/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +3 -3
  310. package/dist/templates/workspace-core/AGENTS.md +7 -16
  311. package/docs/content/messaging.mdx +6 -7
  312. package/package.json +1 -1
  313. package/src/templates/chat/.agents/skills/actions/SKILL.md +54 -488
  314. package/src/templates/chat/.agents/skills/actions/references/action-fields.md +136 -0
  315. package/src/templates/chat/.agents/skills/actions/references/examples.md +94 -0
  316. package/src/templates/chat/.agents/skills/actions/references/provider-apis.md +95 -0
  317. package/src/templates/chat/.agents/skills/create-skill/SKILL.md +9 -35
  318. package/src/templates/chat/.agents/skills/frontend-design/SKILL.md +4 -5
  319. package/src/templates/chat/.agents/skills/turn-into-app/SKILL.md +18 -31
  320. package/src/templates/chat/AGENTS.md +32 -80
  321. package/src/templates/default/.agents/skills/actions/SKILL.md +54 -488
  322. package/src/templates/default/.agents/skills/actions/references/action-fields.md +136 -0
  323. package/src/templates/default/.agents/skills/actions/references/examples.md +94 -0
  324. package/src/templates/default/.agents/skills/actions/references/provider-apis.md +95 -0
  325. package/src/templates/default/.agents/skills/create-skill/SKILL.md +9 -35
  326. package/src/templates/default/.agents/skills/frontend-design/SKILL.md +4 -5
  327. package/src/templates/default/.agents/skills/turn-into-app/SKILL.md +18 -31
  328. package/src/templates/headless/.agents/skills/actions/SKILL.md +54 -488
  329. package/src/templates/headless/.agents/skills/actions/references/action-fields.md +136 -0
  330. package/src/templates/headless/.agents/skills/actions/references/examples.md +94 -0
  331. package/src/templates/headless/.agents/skills/actions/references/provider-apis.md +95 -0
  332. package/src/templates/headless/.agents/skills/turn-into-app/SKILL.md +18 -31
  333. package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +54 -488
  334. package/src/templates/workspace-core/.agents/skills/actions/references/action-fields.md +136 -0
  335. package/src/templates/workspace-core/.agents/skills/actions/references/examples.md +94 -0
  336. package/src/templates/workspace-core/.agents/skills/actions/references/provider-apis.md +95 -0
  337. package/src/templates/workspace-core/.agents/skills/adding-workspace-apps/SKILL.md +1 -0
  338. package/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +1 -0
  339. package/src/templates/workspace-core/.agents/skills/create-skill/SKILL.md +9 -35
  340. package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +4 -5
  341. package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +21 -29
  342. package/src/templates/workspace-core/.agents/skills/turn-into-app/SKILL.md +18 -31
  343. package/src/templates/workspace-core/.agents/skills/workspace-conventions/SKILL.md +7 -17
  344. package/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +3 -3
  345. package/src/templates/workspace-core/AGENTS.md +7 -16
@@ -2,7 +2,13 @@ export declare const ACTIVE_RUN_STATE_EVENT = "agent-chat:active-run-state-chang
2
2
  export interface ActiveRunState {
3
3
  threadId: string;
4
4
  runId: string;
5
+ /** Stable logical-turn identity shared by continuation run IDs. */
6
+ turnId?: string;
5
7
  lastSeq: number;
8
+ /** Last SSE sequence classified as real work progress, not keepalive. */
9
+ lastProgressSeq?: number;
10
+ /** Browser time when the last real work-progress event was received. */
11
+ lastProgressObservedAt?: number;
6
12
  activityTool?: string | null;
7
13
  }
8
14
  export interface PendingTurnState {
@@ -11,7 +17,9 @@ export interface PendingTurnState {
11
17
  }
12
18
  export declare function setActiveRun(state: ActiveRunState): void;
13
19
  export declare function getActiveRun(): ActiveRunState | null;
14
- export declare function updateActiveRunSeq(seq: number): void;
20
+ export declare function updateActiveRunSeq(seq: number, isProgress?: boolean): void;
21
+ /** Whether this browser has received real progress for the matching run recently. */
22
+ export declare function hasRecentActiveRunProgress(threadId: string | null | undefined, runId: string | null | undefined, thresholdMs: number, now?: number): boolean;
15
23
  export declare function updateActiveRunActivity(toolName: string | null | undefined): void;
16
24
  export declare function getActiveRunActivityTool(threadId: string, runId: string): string | null;
17
25
  export declare function clearActiveRun(): void;
@@ -16,11 +16,24 @@ function normalizeActivityTool(toolName) {
16
16
  return tool || null;
17
17
  }
18
18
  export function setActiveRun(state) {
19
+ const previous = getActiveRun();
20
+ const sameRun = previous?.threadId === state.threadId && previous.runId === state.runId;
21
+ const nextState = sameRun
22
+ ? {
23
+ ...state,
24
+ turnId: state.turnId ?? previous.turnId,
25
+ // Reconnect/continuation writers replace the cursor object. Preserve
26
+ // the browser's real-progress proof across those writes so a healthy
27
+ // stream cannot be reclassified as stale by its own reconnect path.
28
+ lastProgressSeq: state.lastProgressSeq ?? previous.lastProgressSeq,
29
+ lastProgressObservedAt: state.lastProgressObservedAt ?? previous.lastProgressObservedAt,
30
+ }
31
+ : state;
19
32
  try {
20
- sessionStorage.setItem(STORAGE_KEY, JSON.stringify(state));
33
+ sessionStorage.setItem(STORAGE_KEY, JSON.stringify(nextState));
21
34
  }
22
35
  catch { }
23
- notifyActiveRunStateChanged(state);
36
+ notifyActiveRunStateChanged(nextState);
24
37
  }
25
38
  export function getActiveRun() {
26
39
  try {
@@ -33,13 +46,31 @@ export function getActiveRun() {
33
46
  return null;
34
47
  }
35
48
  }
36
- export function updateActiveRunSeq(seq) {
49
+ export function updateActiveRunSeq(seq, isProgress = false) {
37
50
  const state = getActiveRun();
38
51
  if (state) {
39
52
  state.lastSeq = seq;
53
+ if (isProgress &&
54
+ seq >=
55
+ (Number.isFinite(state.lastProgressSeq) ? state.lastProgressSeq : -1)) {
56
+ state.lastProgressSeq = seq;
57
+ state.lastProgressObservedAt = Date.now();
58
+ }
40
59
  setActiveRun(state);
41
60
  }
42
61
  }
62
+ /** Whether this browser has received real progress for the matching run recently. */
63
+ export function hasRecentActiveRunProgress(threadId, runId, thresholdMs, now = Date.now()) {
64
+ const state = getActiveRun();
65
+ if (!state ||
66
+ !runId ||
67
+ state.runId !== runId ||
68
+ (threadId != null && state.threadId !== threadId) ||
69
+ typeof state.lastProgressObservedAt !== "number") {
70
+ return false;
71
+ }
72
+ return now - state.lastProgressObservedAt <= thresholdMs;
73
+ }
43
74
  export function updateActiveRunActivity(toolName) {
44
75
  const state = getActiveRun();
45
76
  if (!state)
@@ -17,6 +17,14 @@ export declare const BACKGROUND_FOLLOW_ATTACH_WATCHDOG_MS = 90000;
17
17
  export declare const BACKGROUND_FOLLOW_IDLE_TIMEOUT_MS = 210000;
18
18
  export declare const MAX_FOLLOWED_BACKGROUND_RUNS = 24;
19
19
  export declare const MAX_BACKGROUND_FOLLOW_WALL_TIME_MS: number;
20
+ /**
21
+ * True when an action was streamed but never returned a result yet — i.e. a
22
+ * `tool_start` with no matching `tool_done`. The server is still executing it,
23
+ * so a run_timeout that fires in this window is NOT a stall: the agent was
24
+ * actively working and `foldAssistantTurn` persisted the in-flight call. We
25
+ * must not count this against the stalled/empty continuation budgets.
26
+ */
27
+ export declare function hasInFlightToolCall(content: ContentPart[]): boolean;
20
28
  /**
21
29
  * Server truth for "does this run still look alive?", used to keep the client
22
30
  * from aborting a run the server believes is healthy — the destructive half of
@@ -1,7 +1,7 @@
1
1
  import { unwrapAttachmentEnvelope } from "@agent-native/toolkit/composer/pasted-text";
2
2
  import { actionPreparationContinuationNote } from "../agent/action-continuation-guidance.js";
3
3
  import { LLM_MISSING_CREDENTIALS_ERROR_CODE, LLM_MISSING_CREDENTIALS_MESSAGE, } from "../agent/engine/credential-errors.js";
4
- import { clearPendingTurnIfMatches, setActiveRun, updateActiveRunSeq, clearActiveRun, setPendingTurn, } from "./active-run-state.js";
4
+ import { clearPendingTurnIfMatches, getActiveRun, setActiveRun, updateActiveRunSeq, clearActiveRun, clearActiveRunIfMatches, setPendingTurn, } from "./active-run-state.js";
5
5
  import { getOrCreateAnalyticsSessionId } from "./analytics-session.js";
6
6
  import { captureError } from "./analytics.js";
7
7
  import { agentNativePath } from "./api-path.js";
@@ -95,6 +95,9 @@ function dispatchTerminalChatUiCleanup(tabId) {
95
95
  window.dispatchEvent(new CustomEvent("agent-chat:activity-clear", { detail: { tabId } }));
96
96
  window.dispatchEvent(new CustomEvent("agent-chat:stream-progress", { detail: { tabId } }));
97
97
  }
98
+ function isTerminalChatModelRunResult(result) {
99
+ return (result.status?.type === "complete" || result.status?.type === "incomplete");
100
+ }
98
101
  // ── Background follow mode ──────────────────────────────────────────────────
99
102
  // For server-continued runs (dispatchMode starts with "background" or equals
100
103
  // "foreground-self-chain") the SERVER normally chains continuation chunks
@@ -782,7 +785,7 @@ function continuationRepeatSignature(content) {
782
785
  * actively working and `foldAssistantTurn` persisted the in-flight call. We
783
786
  * must not count this against the stalled/empty continuation budgets.
784
787
  */
785
- function hasInFlightToolCall(content) {
788
+ export function hasInFlightToolCall(content) {
786
789
  return content.some((part) => part.type === "tool-call" &&
787
790
  part.result === undefined &&
788
791
  part.activity !== true);
@@ -808,7 +811,10 @@ export async function activeRunLooksAlive(args) {
808
811
  if (data?.active !== true || String(data.runId ?? "") !== args.runId) {
809
812
  return false;
810
813
  }
811
- return data.hasInFlightWork === true || data.status === "running";
814
+ // `running` only says the server row has not terminalized. It is not proof
815
+ // that a tool is executing, and treating it as proof skips the client
816
+ // rescue precisely when a stalled run has no in-flight work.
817
+ return data.hasInFlightWork === true;
812
818
  }
813
819
  catch {
814
820
  return true;
@@ -1412,9 +1418,14 @@ export function createAgentChatAdapter(options) {
1412
1418
  const engine = runConfigSelection("engine") ?? engineRef?.current;
1413
1419
  const effort = runConfigSelection("effort") ??
1414
1420
  effortRef?.current;
1421
+ const requestedTurnId = (() => {
1422
+ const raw = runConfig?.custom && typeof runConfig.custom === "object"
1423
+ ? runConfig.custom.turnId
1424
+ : undefined;
1425
+ return typeof raw === "string" && raw.trim() ? raw.trim() : undefined;
1426
+ })();
1427
+ const turnId = requestedTurnId ?? generateTurnId();
1415
1428
  const withRequestModeMetadata = (result) => {
1416
- if (!requestMode)
1417
- return result;
1418
1429
  const metadata = (result.metadata ?? {});
1419
1430
  const custom = metadata.custom && typeof metadata.custom === "object"
1420
1431
  ? metadata.custom
@@ -1423,7 +1434,11 @@ export function createAgentChatAdapter(options) {
1423
1434
  ...result,
1424
1435
  metadata: {
1425
1436
  ...metadata,
1426
- custom: { ...custom, requestMode },
1437
+ custom: {
1438
+ ...custom,
1439
+ turnId,
1440
+ ...(requestMode ? { requestMode } : {}),
1441
+ },
1427
1442
  },
1428
1443
  };
1429
1444
  };
@@ -1455,11 +1470,34 @@ export function createAgentChatAdapter(options) {
1455
1470
  }
1456
1471
  const content = [];
1457
1472
  const toolCallCounter = { value: 0 };
1458
- const turnId = generateTurnId();
1459
1473
  if (threadId)
1460
1474
  setPendingTurn({ threadId, turnId });
1461
1475
  let runId = null;
1462
1476
  let lastSeq = -1;
1477
+ const ownsActiveRunState = () => {
1478
+ const activeRun = getActiveRun();
1479
+ return (!activeRun ||
1480
+ (!!threadId &&
1481
+ !!runId &&
1482
+ activeRun.threadId === threadId &&
1483
+ activeRun.runId === runId));
1484
+ };
1485
+ const settleTerminalChatRun = () => {
1486
+ if (!ownsActiveRunState())
1487
+ return;
1488
+ if (threadId && runId) {
1489
+ clearActiveRunIfMatches(threadId, runId);
1490
+ }
1491
+ else {
1492
+ clearActiveRun();
1493
+ }
1494
+ if (typeof window === "undefined")
1495
+ return;
1496
+ dispatchTerminalChatUiCleanup(tabId);
1497
+ window.dispatchEvent(new CustomEvent("agentNative.chatRunning", {
1498
+ detail: { isRunning: false, tabId },
1499
+ }));
1500
+ };
1463
1501
  const seenRunSeqs = new Map();
1464
1502
  const preparingActionStatesByRun = new Map();
1465
1503
  let currentRunDispatchMode = null;
@@ -1706,6 +1744,7 @@ export function createAgentChatAdapter(options) {
1706
1744
  return state;
1707
1745
  };
1708
1746
  const currentSSEOptions = (overrides = {}) => ({
1747
+ markTerminalResults: true,
1709
1748
  durableBackgroundRun: currentRunDispatchMode?.startsWith("background") === true,
1710
1749
  ...(runId
1711
1750
  ? { preparingActionState: preparingActionStateForRun(runId) }
@@ -1816,14 +1855,20 @@ export function createAgentChatAdapter(options) {
1816
1855
  break;
1817
1856
  }
1818
1857
  updateCurrentRunDispatchMode(reconnectRes.headers.get("X-Dispatch-Mode"));
1819
- for await (const result of readSSEStream(reconnectRes.body, content, toolCallCounter, tabId, (seq) => {
1858
+ for await (const result of readSSEStream(reconnectRes.body, content, toolCallCounter, tabId, (seq, isProgress) => {
1820
1859
  rememberRunSeq(seq);
1821
1860
  if (threadId)
1822
- updateActiveRunSeq(seq);
1861
+ updateActiveRunSeq(seq, isProgress);
1823
1862
  }, runId, currentSSEOptions())) {
1824
- yield withRequestModeMetadata(result);
1863
+ const nextResult = withRequestModeMetadata(result);
1864
+ if (isTerminalChatModelRunResult(nextResult)) {
1865
+ settleTerminalChatRun();
1866
+ }
1867
+ yield nextResult;
1868
+ }
1869
+ if (ownsActiveRunState()) {
1870
+ clearActiveRun();
1825
1871
  }
1826
- clearActiveRun();
1827
1872
  return true;
1828
1873
  }
1829
1874
  catch (reconnectErr) {
@@ -1844,7 +1889,7 @@ export function createAgentChatAdapter(options) {
1844
1889
  }
1845
1890
  return false;
1846
1891
  };
1847
- const reconnectActiveRunForThread = async function* () {
1892
+ const reconnectActiveRunForThread = async function* (options) {
1848
1893
  if (!threadId)
1849
1894
  return false;
1850
1895
  let lastActiveRunError = null;
@@ -1865,6 +1910,9 @@ export function createAgentChatAdapter(options) {
1865
1910
  if (active?.active && active.runId) {
1866
1911
  const activeRunId = String(active.runId);
1867
1912
  const activeTurnId = typeof active.turnId === "string" ? active.turnId : "";
1913
+ if (options?.requireCurrentTurn && activeTurnId !== turnId) {
1914
+ return false;
1915
+ }
1868
1916
  if (!canAttachRun(activeRunId, activeTurnId)) {
1869
1917
  return false;
1870
1918
  }
@@ -1875,7 +1923,12 @@ export function createAgentChatAdapter(options) {
1875
1923
  attemptedRunIds.push(activeRunId);
1876
1924
  }
1877
1925
  reconnectCursorForRun(activeRunId, previousRunId);
1878
- setActiveRun({ threadId, runId: activeRunId, lastSeq });
1926
+ setActiveRun({
1927
+ threadId,
1928
+ runId: activeRunId,
1929
+ turnId,
1930
+ lastSeq,
1931
+ });
1879
1932
  const reconnected = yield* reconnectCurrentRun();
1880
1933
  if (reconnected)
1881
1934
  return true;
@@ -1945,7 +1998,12 @@ export function createAgentChatAdapter(options) {
1945
1998
  attemptedRunIds.push(activeRunId);
1946
1999
  }
1947
2000
  reconnectCursorForRun(activeRunId, previousRunId);
1948
- setActiveRun({ threadId, runId: activeRunId, lastSeq });
2001
+ setActiveRun({
2002
+ threadId,
2003
+ runId: activeRunId,
2004
+ turnId,
2005
+ lastSeq,
2006
+ });
1949
2007
  const reconnected = yield* reconnectCurrentRun();
1950
2008
  if (reconnected)
1951
2009
  return true;
@@ -1995,6 +2053,7 @@ export function createAgentChatAdapter(options) {
1995
2053
  type: "text",
1996
2054
  text: formatChatErrorText(args.message, undefined, args.errorCode),
1997
2055
  });
2056
+ settleTerminalChatRun();
1998
2057
  yield {
1999
2058
  content: [...content],
2000
2059
  status: { type: "incomplete", reason: "error" },
@@ -2058,6 +2117,7 @@ export function createAgentChatAdapter(options) {
2058
2117
  includeActivity: true,
2059
2118
  });
2060
2119
  const runWarning = appendMissingFinalResponseWarning(content);
2120
+ settleTerminalChatRun();
2061
2121
  yield {
2062
2122
  content: [...content],
2063
2123
  status: { type: "complete", reason: "stop" },
@@ -2113,15 +2173,19 @@ export function createAgentChatAdapter(options) {
2113
2173
  }
2114
2174
  attached = true;
2115
2175
  updateCurrentRunDispatchMode(eventsRes.headers.get("X-Dispatch-Mode"));
2116
- for await (const result of readSSEStream(eventsRes.body, content, toolCallCounter, tabId, (seq) => {
2176
+ for await (const result of readSSEStream(eventsRes.body, content, toolCallCounter, tabId, (seq, isProgress) => {
2117
2177
  rememberRunSeq(seq);
2118
2178
  if (threadId)
2119
- updateActiveRunSeq(seq);
2179
+ updateActiveRunSeq(seq, isProgress);
2120
2180
  }, runId, currentSSEOptions({
2121
2181
  noProgressTimeoutMs: BACKGROUND_FOLLOW_ATTACH_WATCHDOG_MS,
2122
2182
  actionPreparationStallTimeoutMs: BACKGROUND_FOLLOW_ATTACH_WATCHDOG_MS,
2123
2183
  }))) {
2124
- yield withRequestModeMetadata(result);
2184
+ const nextResult = withRequestModeMetadata(result);
2185
+ if (isTerminalChatModelRunResult(nextResult)) {
2186
+ settleTerminalChatRun();
2187
+ }
2188
+ yield nextResult;
2125
2189
  }
2126
2190
  // readSSEStream returned normally: a terminal done/error was
2127
2191
  // consumed and rendered — the turn is over.
@@ -2424,7 +2488,12 @@ export function createAgentChatAdapter(options) {
2424
2488
  }
2425
2489
  reconnectCursorForRun(activeRunId, previousRunId);
2426
2490
  if (threadId) {
2427
- setActiveRun({ threadId, runId: activeRunId, lastSeq });
2491
+ setActiveRun({
2492
+ threadId,
2493
+ runId: activeRunId,
2494
+ turnId,
2495
+ lastSeq,
2496
+ });
2428
2497
  }
2429
2498
  const seqBeforeAttach = lastSeq;
2430
2499
  const attach = yield* followAttachOnce();
@@ -2938,10 +3007,10 @@ export function createAgentChatAdapter(options) {
2938
3007
  // internal continuation is only adoptable after /runs/active
2939
3008
  // proves it carries this turnId; a bare 409 run id is not
2940
3009
  // enough ownership evidence.
2941
- if (activeRunId !== null &&
2942
- internalContinuationRequest &&
2943
- !attemptedRunIds.includes(activeRunId)) {
2944
- const reconnected = yield* reconnectActiveRunForThread();
3010
+ if (activeRunId !== null && internalContinuationRequest) {
3011
+ const reconnected = yield* reconnectActiveRunForThread({
3012
+ requireCurrentTurn: true,
3013
+ });
2945
3014
  if (reconnected)
2946
3015
  return;
2947
3016
  }
@@ -2982,6 +3051,7 @@ export function createAgentChatAdapter(options) {
2982
3051
  type: "text",
2983
3052
  text: `Something went wrong: ${message}`,
2984
3053
  });
3054
+ settleTerminalChatRun();
2985
3055
  yield {
2986
3056
  content: [...content],
2987
3057
  status: {
@@ -2990,7 +3060,6 @@ export function createAgentChatAdapter(options) {
2990
3060
  },
2991
3061
  metadata: { custom: { runError } },
2992
3062
  };
2993
- clearActiveRun();
2994
3063
  return;
2995
3064
  }
2996
3065
  }
@@ -3003,6 +3072,7 @@ export function createAgentChatAdapter(options) {
3003
3072
  type: "text",
3004
3073
  text: authErrorText("auth-required"),
3005
3074
  });
3075
+ settleTerminalChatRun();
3006
3076
  yield {
3007
3077
  content: [...content],
3008
3078
  status: {
@@ -3023,6 +3093,7 @@ export function createAgentChatAdapter(options) {
3023
3093
  type: "text",
3024
3094
  text: authErrorText("session-expired"),
3025
3095
  });
3096
+ settleTerminalChatRun();
3026
3097
  yield {
3027
3098
  content: [...content],
3028
3099
  status: {
@@ -3046,6 +3117,7 @@ export function createAgentChatAdapter(options) {
3046
3117
  type: "text",
3047
3118
  text: authErrorText(reason, body),
3048
3119
  });
3120
+ settleTerminalChatRun();
3049
3121
  yield {
3050
3122
  content: [...content],
3051
3123
  status: {
@@ -3064,6 +3136,7 @@ export function createAgentChatAdapter(options) {
3064
3136
  }));
3065
3137
  }
3066
3138
  content.push({ type: "text", text: failure.text });
3139
+ settleTerminalChatRun();
3067
3140
  yield {
3068
3141
  content: [...content],
3069
3142
  status: {
@@ -3111,15 +3184,19 @@ export function createAgentChatAdapter(options) {
3111
3184
  }
3112
3185
  if (runId && threadId) {
3113
3186
  clearPendingTurnIfMatches(threadId, turnId);
3114
- setActiveRun({ threadId, runId, lastSeq: -1 });
3187
+ setActiveRun({ threadId, runId, turnId, lastSeq: -1 });
3115
3188
  }
3116
- for await (const result of readSSEStream(res.body, content, toolCallCounter, tabId, (seq) => {
3189
+ for await (const result of readSSEStream(res.body, content, toolCallCounter, tabId, (seq, isProgress) => {
3117
3190
  rememberRunSeq(seq);
3118
3191
  if (runId && threadId) {
3119
- updateActiveRunSeq(seq);
3192
+ updateActiveRunSeq(seq, isProgress);
3120
3193
  }
3121
3194
  }, runId, currentSSEOptions())) {
3122
- yield withRequestModeMetadata(result);
3195
+ const nextResult = withRequestModeMetadata(result);
3196
+ if (isTerminalChatModelRunResult(nextResult)) {
3197
+ settleTerminalChatRun();
3198
+ }
3199
+ yield nextResult;
3123
3200
  }
3124
3201
  // Run completed normally — clear active run state
3125
3202
  clearActiveRun();
@@ -3170,6 +3247,7 @@ export function createAgentChatAdapter(options) {
3170
3247
  if (continuation.completedToolName) {
3171
3248
  const message = completedToolTimeoutMessage(continuation.completedToolName);
3172
3249
  content.push({ type: "text", text: message });
3250
+ settleTerminalChatRun();
3173
3251
  yield {
3174
3252
  content: [...content],
3175
3253
  status: {
@@ -3230,6 +3308,7 @@ export function createAgentChatAdapter(options) {
3230
3308
  // with the generic interruption copy.
3231
3309
  preservedError ? errorCode : undefined),
3232
3310
  });
3311
+ settleTerminalChatRun();
3233
3312
  yield {
3234
3313
  content: [...content],
3235
3314
  status: {
@@ -3300,6 +3379,7 @@ export function createAgentChatAdapter(options) {
3300
3379
  type: "text",
3301
3380
  text: `Something went wrong: ${normalized.message}`,
3302
3381
  });
3382
+ settleTerminalChatRun();
3303
3383
  yield {
3304
3384
  content: [...content],
3305
3385
  status: {
@@ -3326,6 +3406,7 @@ export function createAgentChatAdapter(options) {
3326
3406
  type: "text",
3327
3407
  text: authErrorText(reason, errMsg),
3328
3408
  });
3409
+ settleTerminalChatRun();
3329
3410
  yield {
3330
3411
  content: [...content],
3331
3412
  status: {
@@ -3345,6 +3426,7 @@ export function createAgentChatAdapter(options) {
3345
3426
  }));
3346
3427
  }
3347
3428
  content.push({ type: "text", text: failure.text });
3429
+ settleTerminalChatRun();
3348
3430
  yield {
3349
3431
  content: [...content],
3350
3432
  status: {
@@ -3403,6 +3485,7 @@ export function createAgentChatAdapter(options) {
3403
3485
  type: "text",
3404
3486
  text: `Something went wrong: ${message}`,
3405
3487
  });
3488
+ settleTerminalChatRun();
3406
3489
  yield {
3407
3490
  content: [...content],
3408
3491
  status: {
@@ -3422,6 +3505,7 @@ export function createAgentChatAdapter(options) {
3422
3505
  if (continuation.completedToolName) {
3423
3506
  const message = completedToolTimeoutMessage(continuation.completedToolName);
3424
3507
  content.push({ type: "text", text: message });
3508
+ settleTerminalChatRun();
3425
3509
  yield {
3426
3510
  content: [...content],
3427
3511
  status: {
@@ -3463,6 +3547,7 @@ export function createAgentChatAdapter(options) {
3463
3547
  type: "text",
3464
3548
  text: `Something went wrong: ${message}`,
3465
3549
  });
3550
+ settleTerminalChatRun();
3466
3551
  yield {
3467
3552
  content: [...content],
3468
3553
  status: {
@@ -3522,6 +3607,7 @@ export function createAgentChatAdapter(options) {
3522
3607
  ? errMsg
3523
3608
  : `Something went wrong: ${normalized.message}`,
3524
3609
  });
3610
+ settleTerminalChatRun();
3525
3611
  yield {
3526
3612
  content: [...content],
3527
3613
  status: {
@@ -3535,7 +3621,7 @@ export function createAgentChatAdapter(options) {
3535
3621
  }
3536
3622
  }
3537
3623
  finally {
3538
- if (typeof window !== "undefined") {
3624
+ if (typeof window !== "undefined" && ownsActiveRunState()) {
3539
3625
  dispatchTerminalChatUiCleanup(tabId);
3540
3626
  window.dispatchEvent(new CustomEvent("agentNative.chatRunning", {
3541
3627
  detail: { isRunning: false, tabId },
@@ -49,6 +49,8 @@ export declare function shouldOfferRestore(args: {
49
49
  * messages put it at `metadata.runId`.
50
50
  */
51
51
  export declare function assistantMessageRunId(message: unknown): string | undefined;
52
+ /** Stable logical-turn identity shared by chained continuation run IDs. */
53
+ export declare function assistantMessageTurnId(message: unknown): string | undefined;
52
54
  export declare function resolveAssistantRequestId(message: unknown, activeRun: {
53
55
  threadId: string;
54
56
  runId: string;
@@ -71,9 +73,13 @@ export declare function computeActiveTailToolCallId(content: ContentPart[] | und
71
73
  chatRunning: boolean;
72
74
  isLast: boolean;
73
75
  }): string | null;
74
- export declare function shouldShowAssistantMessageFooter({ isLast, chatRunning, hasRenderableContent, statusIsTerminal, hasUnresolvedTool, }: {
76
+ export declare function shouldShowAssistantMessageFooter({ isLast, chatRunning, activeRunId, messageRunId, activeTurnId, messageTurnId, hasRenderableContent, statusIsTerminal, hasUnresolvedTool, }: {
75
77
  isLast: boolean;
76
78
  chatRunning: boolean;
79
+ activeRunId?: string | null;
80
+ messageRunId?: string;
81
+ activeTurnId?: string | null;
82
+ messageTurnId?: string;
77
83
  hasRenderableContent: boolean;
78
84
  statusIsTerminal: boolean;
79
85
  hasUnresolvedTool?: boolean;
@@ -19,7 +19,7 @@ import { cn } from "../utils.js";
19
19
  import { MarkdownText, renderMarkdownToClipboardHtml, SmoothMarkdownText, } from "./markdown-renderer.js";
20
20
  import { getAssistantRunDurationMs } from "./repo-helpers.js";
21
21
  import { getRunErrorMetadata, runErrorHeadline, runErrorKey, } from "./run-recovery.js";
22
- import { ToolCallFallback, ToolActivityPresentation, ToolCallStackMotion, FilesChangedSummary, ASSISTANT_VISIBLE_TOOL_CALL_LIMIT, ChatRunningContext, ChatRunDurationContext, formatWorkedDuration, RanToolsSummary, ReasoningCell, WorkedForSummary, toolCallHasPendingApproval, } from "./tool-call-display.js";
22
+ import { ToolCallFallback, ToolActivityPresentation, ToolCallStackMotion, FilesChangedSummary, ASSISTANT_VISIBLE_TOOL_CALL_LIMIT, ChatRunningContext, ChatRunningRunIdContext, ChatRunningTurnIdContext, ChatRunDurationContext, formatWorkedDuration, RanToolsSummary, ReasoningCell, WorkedForSummary, toolCallHasPendingApproval, } from "./tool-call-display.js";
23
23
  export { toolCallHasPendingApproval };
24
24
  // ─── Pending selection context key ───────────────────────────────────────────
25
25
  // Mirrored from AssistantChat to avoid a cross-import on a private constant.
@@ -172,6 +172,15 @@ export function assistantMessageRunId(message) {
172
172
  ? metadata.runId
173
173
  : undefined;
174
174
  }
175
+ /** Stable logical-turn identity shared by chained continuation run IDs. */
176
+ export function assistantMessageTurnId(message) {
177
+ const metadata = message?.metadata;
178
+ return typeof metadata?.custom?.turnId === "string"
179
+ ? metadata.custom.turnId
180
+ : typeof metadata?.turnId === "string"
181
+ ? metadata.turnId
182
+ : undefined;
183
+ }
175
184
  export function resolveAssistantRequestId(message, activeRun, threadId) {
176
185
  return (assistantMessageRunId(message) ||
177
186
  (activeRun?.threadId === threadId ? activeRun.runId : undefined));
@@ -592,13 +601,24 @@ export function computeActiveTailToolCallId(content, { chatRunning, isLast }) {
592
601
  ? part.toolCallId
593
602
  : latestToolCallId, null) ?? null);
594
603
  }
595
- export function shouldShowAssistantMessageFooter({ isLast, chatRunning, hasRenderableContent, statusIsTerminal, hasUnresolvedTool, }) {
604
+ export function shouldShowAssistantMessageFooter({ isLast, chatRunning, activeRunId, messageRunId, activeTurnId, messageTurnId, hasRenderableContent, statusIsTerminal, hasUnresolvedTool, }) {
596
605
  if (!hasRenderableContent)
597
606
  return false;
607
+ const ownsActiveTurn = activeTurnId != null &&
608
+ (messageTurnId == null || activeTurnId === messageTurnId);
609
+ // Keep the run-id comparison only for legacy messages that predate the
610
+ // turn-id metadata. Once either side has a logical-turn identity, absent
611
+ // turn evidence must not be treated as proof of a different run.
612
+ const ownsLegacyRun = activeTurnId == null &&
613
+ messageTurnId == null &&
614
+ activeRunId != null &&
615
+ messageRunId != null &&
616
+ activeRunId === messageRunId;
617
+ const ownsActiveRun = isLast || ownsActiveTurn || ownsLegacyRun;
618
+ if (chatRunning && ownsActiveRun)
619
+ return false;
598
620
  if (!isLast)
599
621
  return true;
600
- if (chatRunning)
601
- return false;
602
622
  if (hasUnresolvedTool)
603
623
  return false;
604
624
  return statusIsTerminal;
@@ -776,6 +796,8 @@ export function AssistantMessage() {
776
796
  const messageRuntime = useMessageRuntime();
777
797
  const thread = useThread();
778
798
  const chatRunning = React.useContext(ChatRunningContext);
799
+ const activeRunId = React.useContext(ChatRunningRunIdContext);
800
+ const activeTurnId = React.useContext(ChatRunningTurnIdContext);
779
801
  const lastRunDurationMs = React.useContext(ChatRunDurationContext);
780
802
  const msg = messageRuntime.getState();
781
803
  const persistedDurationMs = getAssistantRunDurationMs(msg);
@@ -790,6 +812,8 @@ export function AssistantMessage() {
790
812
  const statusIsTerminal = assistantMessageStatusIsTerminal(msg);
791
813
  const hasCompletedCustomUi = assistantMessageHasCompletedCustomUi(msg.content);
792
814
  const hasCustomUi = assistantMessageHasCustomUi(msg.content);
815
+ const messageRunId = assistantMessageRunId(msg);
816
+ const messageTurnId = assistantMessageTurnId(msg);
793
817
  const serverRunActive = React.useContext(ServerRunActiveContext);
794
818
  const messageRunError = getRunErrorMetadata(msg);
795
819
  const messageActions = React.useContext(MessageActionsContext);
@@ -838,6 +862,10 @@ export function AssistantMessage() {
838
862
  shouldShowAssistantMessageFooter({
839
863
  isLast,
840
864
  chatRunning,
865
+ activeRunId,
866
+ messageRunId,
867
+ activeTurnId,
868
+ messageTurnId,
841
869
  hasRenderableContent,
842
870
  statusIsTerminal,
843
871
  hasUnresolvedTool,
@@ -881,7 +909,6 @@ export function AssistantMessage() {
881
909
  }
882
910
  wasRunningRef.current = chatRunning && isLast;
883
911
  }, [chatRunning, isComplete, isLast]);
884
- const messageRunId = assistantMessageRunId(msg);
885
912
  const handleRestore = useCallback(async () => {
886
913
  if (restoreState === "idle" || restoreState === "error") {
887
914
  setRestoreError(null);
@@ -6,6 +6,7 @@ export type RunErrorInfo = {
6
6
  details?: string;
7
7
  errorCode?: string;
8
8
  runId?: string;
9
+ turnId?: string;
9
10
  recoverable?: boolean;
10
11
  };
11
12
  export declare function getLoopLimitMetadata(message: unknown): LoopLimitInfo | null;
@@ -39,6 +39,13 @@ export function getRunErrorMetadata(message) {
39
39
  : typeof meta?.runId === "string"
40
40
  ? meta.runId
41
41
  : undefined;
42
+ const turnId = typeof runError.turnId === "string"
43
+ ? runError.turnId
44
+ : typeof meta?.custom?.turnId === "string"
45
+ ? meta.custom.turnId
46
+ : typeof meta?.turnId === "string"
47
+ ? meta.turnId
48
+ : undefined;
42
49
  return {
43
50
  message: messageText,
44
51
  ...(typeof runError.details === "string"
@@ -48,6 +55,7 @@ export function getRunErrorMetadata(message) {
48
55
  ? { errorCode: runError.errorCode }
49
56
  : {}),
50
57
  ...(runId ? { runId } : {}),
58
+ ...(turnId ? { turnId } : {}),
51
59
  ...(runError.recoverable ? { recoverable: true } : {}),
52
60
  };
53
61
  }
@@ -5,6 +5,8 @@ import type { AgentMcpAppPayload } from "../../mcp-client/app-result.js";
5
5
  import type { ContentPart } from "../sse-event-processor.js";
6
6
  import { FilesChangedSummary } from "../tool-cells/index.js";
7
7
  export declare const ChatRunningContext: React.Context<boolean>;
8
+ export declare const ChatRunningRunIdContext: React.Context<string | null>;
9
+ export declare const ChatRunningTurnIdContext: React.Context<string | null>;
8
10
  export declare const ChatRunDurationContext: React.Context<number | null>;
9
11
  export declare const ASSISTANT_VISIBLE_TOOL_CALL_LIMIT = 3;
10
12
  /**
@@ -18,6 +18,8 @@ import { resolveToolRenderer } from "./tool-render-registry.js";
18
18
  import { isBuiltinDataWidgetActionRenderer, resolveBuiltinActionChatRenderer, resolveBuiltinFallbackToolRenderer, } from "./widgets/builtin-tool-renderers.js";
19
19
  // Exported so AssistantChatInner can provide a context value.
20
20
  export const ChatRunningContext = React.createContext(false);
21
+ export const ChatRunningRunIdContext = React.createContext(null);
22
+ export const ChatRunningTurnIdContext = React.createContext(null);
21
23
  export const ChatRunDurationContext = React.createContext(null);
22
24
  export const ASSISTANT_VISIBLE_TOOL_CALL_LIMIT = 3;
23
25
  /**