@agent-native/core 0.7.10 → 0.7.12

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 (375) hide show
  1. package/dist/action.js +30 -11
  2. package/dist/action.js.map +1 -1
  3. package/dist/agent/engine/ai-sdk-engine.d.ts +14 -2
  4. package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
  5. package/dist/agent/engine/ai-sdk-engine.js +70 -54
  6. package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
  7. package/dist/agent/engine/anthropic-engine.d.ts +1 -6
  8. package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
  9. package/dist/agent/engine/anthropic-engine.js +3 -14
  10. package/dist/agent/engine/anthropic-engine.js.map +1 -1
  11. package/dist/agent/engine/builtin.d.ts.map +1 -1
  12. package/dist/agent/engine/builtin.js +3 -0
  13. package/dist/agent/engine/builtin.js.map +1 -1
  14. package/dist/agent/engine/index.d.ts +1 -1
  15. package/dist/agent/engine/index.d.ts.map +1 -1
  16. package/dist/agent/engine/index.js +1 -1
  17. package/dist/agent/engine/index.js.map +1 -1
  18. package/dist/agent/engine/provider-env-vars.d.ts +21 -0
  19. package/dist/agent/engine/provider-env-vars.d.ts.map +1 -0
  20. package/dist/agent/engine/provider-env-vars.js +50 -0
  21. package/dist/agent/engine/provider-env-vars.js.map +1 -0
  22. package/dist/agent/engine/registry.d.ts +18 -0
  23. package/dist/agent/engine/registry.d.ts.map +1 -1
  24. package/dist/agent/engine/registry.js +54 -4
  25. package/dist/agent/engine/registry.js.map +1 -1
  26. package/dist/agent/engine/translate-ai-sdk.d.ts +35 -10
  27. package/dist/agent/engine/translate-ai-sdk.d.ts.map +1 -1
  28. package/dist/agent/engine/translate-ai-sdk.js +190 -91
  29. package/dist/agent/engine/translate-ai-sdk.js.map +1 -1
  30. package/dist/agent/engine/types.d.ts +10 -1
  31. package/dist/agent/engine/types.d.ts.map +1 -1
  32. package/dist/agent/production-agent.d.ts +21 -1
  33. package/dist/agent/production-agent.d.ts.map +1 -1
  34. package/dist/agent/production-agent.js +72 -21
  35. package/dist/agent/production-agent.js.map +1 -1
  36. package/dist/agent/thread-data-builder.js +1 -1
  37. package/dist/agent/thread-data-builder.js.map +1 -1
  38. package/dist/agent/types.d.ts +4 -0
  39. package/dist/agent/types.d.ts.map +1 -1
  40. package/dist/application-state/script-helpers.d.ts +12 -5
  41. package/dist/application-state/script-helpers.d.ts.map +1 -1
  42. package/dist/application-state/script-helpers.js +41 -20
  43. package/dist/application-state/script-helpers.js.map +1 -1
  44. package/dist/catalog.json +15 -0
  45. package/dist/checkpoints/index.d.ts +3 -0
  46. package/dist/checkpoints/index.d.ts.map +1 -0
  47. package/dist/checkpoints/index.js +3 -0
  48. package/dist/checkpoints/index.js.map +1 -0
  49. package/dist/checkpoints/service.d.ts +6 -0
  50. package/dist/checkpoints/service.d.ts.map +1 -0
  51. package/dist/checkpoints/service.js +107 -0
  52. package/dist/checkpoints/service.js.map +1 -0
  53. package/dist/checkpoints/store.d.ts +27 -0
  54. package/dist/checkpoints/store.d.ts.map +1 -0
  55. package/dist/checkpoints/store.js +92 -0
  56. package/dist/checkpoints/store.js.map +1 -0
  57. package/dist/cli/create.d.ts.map +1 -1
  58. package/dist/cli/create.js +191 -2
  59. package/dist/cli/create.js.map +1 -1
  60. package/dist/cli/index.js +63 -3
  61. package/dist/cli/index.js.map +1 -1
  62. package/dist/cli/templates-meta.d.ts +2 -0
  63. package/dist/cli/templates-meta.d.ts.map +1 -1
  64. package/dist/cli/templates-meta.js +35 -0
  65. package/dist/cli/templates-meta.js.map +1 -1
  66. package/dist/cli/workspacify.d.ts.map +1 -1
  67. package/dist/cli/workspacify.js +7 -3
  68. package/dist/cli/workspacify.js.map +1 -1
  69. package/dist/client/AgentPanel.d.ts.map +1 -1
  70. package/dist/client/AgentPanel.js +3 -1
  71. package/dist/client/AgentPanel.js.map +1 -1
  72. package/dist/client/AssistantChat.d.ts +15 -0
  73. package/dist/client/AssistantChat.d.ts.map +1 -1
  74. package/dist/client/AssistantChat.js +162 -67
  75. package/dist/client/AssistantChat.js.map +1 -1
  76. package/dist/client/CommandMenu.d.ts.map +1 -1
  77. package/dist/client/CommandMenu.js +9 -5
  78. package/dist/client/CommandMenu.js.map +1 -1
  79. package/dist/client/ConnectBuilderCard.js +1 -1
  80. package/dist/client/ConnectBuilderCard.js.map +1 -1
  81. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  82. package/dist/client/MultiTabAssistantChat.js +89 -4
  83. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  84. package/dist/client/agent-chat-adapter.d.ts +6 -0
  85. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  86. package/dist/client/agent-chat-adapter.js +4 -0
  87. package/dist/client/agent-chat-adapter.js.map +1 -1
  88. package/dist/client/composer/TiptapComposer.d.ts +12 -1
  89. package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
  90. package/dist/client/composer/TiptapComposer.js +87 -5
  91. package/dist/client/composer/TiptapComposer.js.map +1 -1
  92. package/dist/client/notifications/NotificationsBell.d.ts +23 -0
  93. package/dist/client/notifications/NotificationsBell.d.ts.map +1 -0
  94. package/dist/client/notifications/NotificationsBell.js +165 -0
  95. package/dist/client/notifications/NotificationsBell.js.map +1 -0
  96. package/dist/client/notifications/index.d.ts +2 -0
  97. package/dist/client/notifications/index.d.ts.map +1 -0
  98. package/dist/client/notifications/index.js +2 -0
  99. package/dist/client/notifications/index.js.map +1 -0
  100. package/dist/client/onboarding/OnboardingPanel.js +6 -3
  101. package/dist/client/onboarding/OnboardingPanel.js.map +1 -1
  102. package/dist/client/progress/RunsTray.d.ts +18 -0
  103. package/dist/client/progress/RunsTray.d.ts.map +1 -0
  104. package/dist/client/progress/RunsTray.js +70 -0
  105. package/dist/client/progress/RunsTray.js.map +1 -0
  106. package/dist/client/progress/index.d.ts +2 -0
  107. package/dist/client/progress/index.d.ts.map +1 -0
  108. package/dist/client/progress/index.js +2 -0
  109. package/dist/client/progress/index.js.map +1 -0
  110. package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
  111. package/dist/client/resources/ResourcesPanel.js +19 -4
  112. package/dist/client/resources/ResourcesPanel.js.map +1 -1
  113. package/dist/client/settings/AutomationsSection.d.ts +2 -0
  114. package/dist/client/settings/AutomationsSection.d.ts.map +1 -0
  115. package/dist/client/settings/AutomationsSection.js +214 -0
  116. package/dist/client/settings/AutomationsSection.js.map +1 -0
  117. package/dist/client/settings/ComingSoonSection.d.ts.map +1 -1
  118. package/dist/client/settings/ComingSoonSection.js +2 -1
  119. package/dist/client/settings/ComingSoonSection.js.map +1 -1
  120. package/dist/client/settings/SecretsSection.d.ts.map +1 -1
  121. package/dist/client/settings/SecretsSection.js +122 -3
  122. package/dist/client/settings/SecretsSection.js.map +1 -1
  123. package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
  124. package/dist/client/settings/SettingsPanel.js +252 -14
  125. package/dist/client/settings/SettingsPanel.js.map +1 -1
  126. package/dist/client/settings/VoiceTranscriptionSection.d.ts.map +1 -1
  127. package/dist/client/settings/VoiceTranscriptionSection.js +2 -2
  128. package/dist/client/settings/VoiceTranscriptionSection.js.map +1 -1
  129. package/dist/client/use-pausing-interval.d.ts +11 -0
  130. package/dist/client/use-pausing-interval.d.ts.map +1 -0
  131. package/dist/client/use-pausing-interval.js +49 -0
  132. package/dist/client/use-pausing-interval.js.map +1 -0
  133. package/dist/db/client.d.ts +26 -0
  134. package/dist/db/client.d.ts.map +1 -1
  135. package/dist/db/client.js +84 -2
  136. package/dist/db/client.js.map +1 -1
  137. package/dist/db/drizzle-config.d.ts +33 -0
  138. package/dist/db/drizzle-config.d.ts.map +1 -0
  139. package/dist/db/drizzle-config.js +132 -0
  140. package/dist/db/drizzle-config.js.map +1 -0
  141. package/dist/db/migrations.d.ts.map +1 -1
  142. package/dist/db/migrations.js +11 -6
  143. package/dist/db/migrations.js.map +1 -1
  144. package/dist/deploy/build.js +2 -1
  145. package/dist/deploy/build.js.map +1 -1
  146. package/dist/event-bus/bus.d.ts +20 -0
  147. package/dist/event-bus/bus.d.ts.map +1 -0
  148. package/dist/event-bus/bus.js +108 -0
  149. package/dist/event-bus/bus.js.map +1 -0
  150. package/dist/event-bus/index.d.ts +4 -0
  151. package/dist/event-bus/index.d.ts.map +1 -0
  152. package/dist/event-bus/index.js +3 -0
  153. package/dist/event-bus/index.js.map +1 -0
  154. package/dist/event-bus/registry.d.ts +22 -0
  155. package/dist/event-bus/registry.d.ts.map +1 -0
  156. package/dist/event-bus/registry.js +63 -0
  157. package/dist/event-bus/registry.js.map +1 -0
  158. package/dist/event-bus/types.d.ts +27 -0
  159. package/dist/event-bus/types.d.ts.map +1 -0
  160. package/dist/event-bus/types.js +2 -0
  161. package/dist/event-bus/types.js.map +1 -0
  162. package/dist/integrations/config-store.d.ts.map +1 -1
  163. package/dist/integrations/config-store.js +16 -12
  164. package/dist/integrations/config-store.js.map +1 -1
  165. package/dist/integrations/google-docs-poller.d.ts.map +1 -1
  166. package/dist/integrations/google-docs-poller.js +5 -1
  167. package/dist/integrations/google-docs-poller.js.map +1 -1
  168. package/dist/jobs/scheduler.d.ts.map +1 -1
  169. package/dist/jobs/scheduler.js +7 -3
  170. package/dist/jobs/scheduler.js.map +1 -1
  171. package/dist/notifications/actions.d.ts +10 -0
  172. package/dist/notifications/actions.d.ts.map +1 -0
  173. package/dist/notifications/actions.js +114 -0
  174. package/dist/notifications/actions.js.map +1 -0
  175. package/dist/notifications/channels.d.ts +15 -0
  176. package/dist/notifications/channels.d.ts.map +1 -0
  177. package/dist/notifications/channels.js +97 -0
  178. package/dist/notifications/channels.js.map +1 -0
  179. package/dist/notifications/index.d.ts +4 -0
  180. package/dist/notifications/index.d.ts.map +1 -0
  181. package/dist/notifications/index.js +3 -0
  182. package/dist/notifications/index.js.map +1 -0
  183. package/dist/notifications/registry.d.ts +9 -0
  184. package/dist/notifications/registry.d.ts.map +1 -0
  185. package/dist/notifications/registry.js +146 -0
  186. package/dist/notifications/registry.js.map +1 -0
  187. package/dist/notifications/routes.d.ts +34 -0
  188. package/dist/notifications/routes.d.ts.map +1 -0
  189. package/dist/notifications/routes.js +69 -0
  190. package/dist/notifications/routes.js.map +1 -0
  191. package/dist/notifications/store.d.ts +25 -0
  192. package/dist/notifications/store.d.ts.map +1 -0
  193. package/dist/notifications/store.js +158 -0
  194. package/dist/notifications/store.js.map +1 -0
  195. package/dist/notifications/types.d.ts +43 -0
  196. package/dist/notifications/types.d.ts.map +1 -0
  197. package/dist/notifications/types.js +2 -0
  198. package/dist/notifications/types.js.map +1 -0
  199. package/dist/onboarding/default-steps.d.ts.map +1 -1
  200. package/dist/onboarding/default-steps.js +63 -20
  201. package/dist/onboarding/default-steps.js.map +1 -1
  202. package/dist/org/handlers.d.ts.map +1 -1
  203. package/dist/org/handlers.js +7 -26
  204. package/dist/org/handlers.js.map +1 -1
  205. package/dist/progress/actions.d.ts +8 -0
  206. package/dist/progress/actions.d.ts.map +1 -0
  207. package/dist/progress/actions.js +158 -0
  208. package/dist/progress/actions.js.map +1 -0
  209. package/dist/progress/index.d.ts +3 -0
  210. package/dist/progress/index.d.ts.map +1 -0
  211. package/dist/progress/index.js +2 -0
  212. package/dist/progress/index.js.map +1 -0
  213. package/dist/progress/registry.d.ts +22 -0
  214. package/dist/progress/registry.d.ts.map +1 -0
  215. package/dist/progress/registry.js +98 -0
  216. package/dist/progress/registry.js.map +1 -0
  217. package/dist/progress/routes.d.ts +21 -0
  218. package/dist/progress/routes.d.ts.map +1 -0
  219. package/dist/progress/routes.js +59 -0
  220. package/dist/progress/routes.js.map +1 -0
  221. package/dist/progress/store.d.ts +7 -0
  222. package/dist/progress/store.d.ts.map +1 -0
  223. package/dist/progress/store.js +195 -0
  224. package/dist/progress/store.js.map +1 -0
  225. package/dist/progress/types.d.ts +49 -0
  226. package/dist/progress/types.d.ts.map +1 -0
  227. package/dist/progress/types.js +7 -0
  228. package/dist/progress/types.js.map +1 -0
  229. package/dist/resources/store.d.ts.map +1 -1
  230. package/dist/resources/store.js +19 -15
  231. package/dist/resources/store.js.map +1 -1
  232. package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
  233. package/dist/scripts/agent-engines/list-agent-engines.js +19 -5
  234. package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
  235. package/dist/scripts/agent-engines/set-agent-engine.d.ts.map +1 -1
  236. package/dist/scripts/agent-engines/set-agent-engine.js +8 -7
  237. package/dist/scripts/agent-engines/set-agent-engine.js.map +1 -1
  238. package/dist/secrets/index.d.ts +3 -2
  239. package/dist/secrets/index.d.ts.map +1 -1
  240. package/dist/secrets/index.js +3 -2
  241. package/dist/secrets/index.js.map +1 -1
  242. package/dist/secrets/routes.d.ts +41 -2
  243. package/dist/secrets/routes.d.ts.map +1 -1
  244. package/dist/secrets/routes.js +167 -1
  245. package/dist/secrets/routes.js.map +1 -1
  246. package/dist/secrets/schema.d.ts +39 -1
  247. package/dist/secrets/schema.d.ts.map +1 -1
  248. package/dist/secrets/schema.js +6 -0
  249. package/dist/secrets/schema.js.map +1 -1
  250. package/dist/secrets/storage.d.ts +26 -0
  251. package/dist/secrets/storage.d.ts.map +1 -1
  252. package/dist/secrets/storage.js +111 -5
  253. package/dist/secrets/storage.js.map +1 -1
  254. package/dist/secrets/substitution.d.ts +39 -0
  255. package/dist/secrets/substitution.d.ts.map +1 -0
  256. package/dist/secrets/substitution.js +93 -0
  257. package/dist/secrets/substitution.js.map +1 -0
  258. package/dist/server/agent-chat-plugin.d.ts.map +1 -1
  259. package/dist/server/agent-chat-plugin.js +1684 -1410
  260. package/dist/server/agent-chat-plugin.js.map +1 -1
  261. package/dist/server/agent-teams.d.ts.map +1 -1
  262. package/dist/server/agent-teams.js +17 -6
  263. package/dist/server/agent-teams.js.map +1 -1
  264. package/dist/server/analytics.d.ts +8 -5
  265. package/dist/server/analytics.d.ts.map +1 -1
  266. package/dist/server/analytics.js +17 -8
  267. package/dist/server/analytics.js.map +1 -1
  268. package/dist/server/app-url.d.ts.map +1 -1
  269. package/dist/server/app-url.js +7 -4
  270. package/dist/server/app-url.js.map +1 -1
  271. package/dist/server/auth.d.ts +11 -0
  272. package/dist/server/auth.d.ts.map +1 -1
  273. package/dist/server/auth.js +74 -21
  274. package/dist/server/auth.js.map +1 -1
  275. package/dist/server/better-auth-instance.d.ts.map +1 -1
  276. package/dist/server/better-auth-instance.js +34 -16
  277. package/dist/server/better-auth-instance.js.map +1 -1
  278. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  279. package/dist/server/core-routes-plugin.js +179 -2
  280. package/dist/server/core-routes-plugin.js.map +1 -1
  281. package/dist/server/email-templates.d.ts +43 -0
  282. package/dist/server/email-templates.d.ts.map +1 -0
  283. package/dist/server/email-templates.js +86 -0
  284. package/dist/server/email-templates.js.map +1 -0
  285. package/dist/server/framework-request-handler.d.ts +15 -0
  286. package/dist/server/framework-request-handler.d.ts.map +1 -1
  287. package/dist/server/framework-request-handler.js +64 -1
  288. package/dist/server/framework-request-handler.js.map +1 -1
  289. package/dist/server/onboarding-html.d.ts +11 -0
  290. package/dist/server/onboarding-html.d.ts.map +1 -1
  291. package/dist/server/onboarding-html.js +275 -16
  292. package/dist/server/onboarding-html.js.map +1 -1
  293. package/dist/server/schema-prompt.d.ts.map +1 -1
  294. package/dist/server/schema-prompt.js +5 -0
  295. package/dist/server/schema-prompt.js.map +1 -1
  296. package/dist/shared/index.d.ts +1 -0
  297. package/dist/shared/index.d.ts.map +1 -1
  298. package/dist/shared/index.js +1 -0
  299. package/dist/shared/index.js.map +1 -1
  300. package/dist/shared/truncate.d.ts +8 -0
  301. package/dist/shared/truncate.d.ts.map +1 -0
  302. package/dist/shared/truncate.js +12 -0
  303. package/dist/shared/truncate.js.map +1 -0
  304. package/dist/templates/default/.agents/skills/agent-engines/SKILL.md +60 -4
  305. package/dist/templates/default/.agents/skills/notifications/SKILL.md +95 -0
  306. package/dist/templates/default/.agents/skills/progress/SKILL.md +97 -0
  307. package/dist/templates/default/AGENTS.md +12 -10
  308. package/dist/templates/default/package.json +10 -10
  309. package/dist/templates/workspace-core/package.json +5 -5
  310. package/dist/templates/workspace-root/package.json +1 -1
  311. package/dist/templates/workspace-root/pnpm-workspace.yaml +6 -0
  312. package/dist/templates/workspace-root/tsconfig.base.json +1 -2
  313. package/dist/tools/fetch-tool.d.ts +22 -0
  314. package/dist/tools/fetch-tool.d.ts.map +1 -0
  315. package/dist/tools/fetch-tool.js +156 -0
  316. package/dist/tools/fetch-tool.js.map +1 -0
  317. package/dist/tracking/index.d.ts +4 -0
  318. package/dist/tracking/index.d.ts.map +1 -0
  319. package/dist/tracking/index.js +3 -0
  320. package/dist/tracking/index.js.map +1 -0
  321. package/dist/tracking/providers.d.ts +15 -0
  322. package/dist/tracking/providers.d.ts.map +1 -0
  323. package/dist/tracking/providers.js +195 -0
  324. package/dist/tracking/providers.js.map +1 -0
  325. package/dist/tracking/registry.d.ts +10 -0
  326. package/dist/tracking/registry.d.ts.map +1 -0
  327. package/dist/tracking/registry.js +75 -0
  328. package/dist/tracking/registry.js.map +1 -0
  329. package/dist/tracking/types.d.ts +13 -0
  330. package/dist/tracking/types.d.ts.map +1 -0
  331. package/dist/tracking/types.js +2 -0
  332. package/dist/tracking/types.js.map +1 -0
  333. package/dist/triggers/actions.d.ts +10 -0
  334. package/dist/triggers/actions.d.ts.map +1 -0
  335. package/dist/triggers/actions.js +277 -0
  336. package/dist/triggers/actions.js.map +1 -0
  337. package/dist/triggers/condition-evaluator.d.ts +15 -0
  338. package/dist/triggers/condition-evaluator.d.ts.map +1 -0
  339. package/dist/triggers/condition-evaluator.js +107 -0
  340. package/dist/triggers/condition-evaluator.js.map +1 -0
  341. package/dist/triggers/dispatcher.d.ts +32 -0
  342. package/dist/triggers/dispatcher.d.ts.map +1 -0
  343. package/dist/triggers/dispatcher.js +291 -0
  344. package/dist/triggers/dispatcher.js.map +1 -0
  345. package/dist/triggers/index.d.ts +5 -0
  346. package/dist/triggers/index.d.ts.map +1 -0
  347. package/dist/triggers/index.js +4 -0
  348. package/dist/triggers/index.js.map +1 -0
  349. package/dist/triggers/types.d.ts +35 -0
  350. package/dist/triggers/types.d.ts.map +1 -0
  351. package/dist/triggers/types.js +9 -0
  352. package/dist/triggers/types.js.map +1 -0
  353. package/dist/vite/client.d.ts.map +1 -1
  354. package/dist/vite/client.js +66 -16
  355. package/dist/vite/client.js.map +1 -1
  356. package/docs/content/automations.md +239 -0
  357. package/docs/content/multi-tenancy.md +88 -0
  358. package/docs/content/notifications.md +199 -0
  359. package/docs/content/progress.md +176 -0
  360. package/docs/content/tracking.md +168 -0
  361. package/package.json +59 -35
  362. package/src/templates/default/.agents/skills/agent-engines/SKILL.md +60 -4
  363. package/src/templates/default/.agents/skills/notifications/SKILL.md +95 -0
  364. package/src/templates/default/.agents/skills/progress/SKILL.md +97 -0
  365. package/src/templates/default/AGENTS.md +12 -10
  366. package/src/templates/default/package.json +10 -10
  367. package/src/templates/workspace-core/package.json +5 -5
  368. package/src/templates/workspace-root/package.json +1 -1
  369. package/src/templates/workspace-root/pnpm-workspace.yaml +6 -0
  370. package/src/templates/workspace-root/tsconfig.base.json +1 -2
  371. package/tsconfig.base.json +1 -1
  372. package/dist/client/settings/LLMSection.d.ts +0 -2
  373. package/dist/client/settings/LLMSection.d.ts.map +0 -1
  374. package/dist/client/settings/LLMSection.js +0 -64
  375. package/dist/client/settings/LLMSection.js.map +0 -1
@@ -11,8 +11,9 @@ import { cn } from "./utils.js";
11
11
  import { AgentTaskCard } from "./AgentTaskCard.js";
12
12
  import { ConnectBuilderCard } from "./ConnectBuilderCard.js";
13
13
  import { IframeEmbed, parseEmbedBody } from "./IframeEmbed.js";
14
+ import { useDevMode } from "./use-dev-mode.js";
14
15
  import { TiptapComposer, } from "./composer/TiptapComposer.js";
15
- import { IconMessage, IconX, IconPlayerStop, IconCheck, IconChevronDown, IconCopy, IconTerminal, IconLoader2, IconCircleX, IconSquareFilled, IconClock, IconFile, IconFolder, IconFileText, IconCheckbox, IconMail, IconUser, IconPresentation, IconStack2, IconMessageChatbot, IconLock, } from "@tabler/icons-react";
16
+ import { IconMessage, IconX, IconPlayerStop, IconCheck, IconChevronDown, IconCopy, IconTerminal, IconLoader2, IconCircleX, IconSquareFilled, IconClock, IconFile, IconFolder, IconFileText, IconCheckbox, IconMail, IconUser, IconPresentation, IconStack2, IconMessageChatbot, IconLock, IconArrowBackUp, IconExternalLink, } from "@tabler/icons-react";
16
17
  // ─── Markdown Text ──────────────────────────────────────────────────────────
17
18
  const markdownStyles = `
18
19
  .agent-markdown > :first-child { margin-top: 0; }
@@ -101,6 +102,8 @@ function loadHighlighter() {
101
102
  }
102
103
  return highlighterLoader;
103
104
  }
105
+ import { PROVIDER_ENV_VARS } from "../agent/engine/provider-env-vars.js";
106
+ const PROVIDER_ENV_VAR_SET = new Set(PROVIDER_ENV_VARS);
104
107
  // Map a few common aliases to languages we bundled above.
105
108
  const LANG_ALIASES = {
106
109
  js: "javascript",
@@ -449,14 +452,17 @@ function UserMessage() {
449
452
  Text: UserMessageText,
450
453
  } }) }), !expanded && isExpandable && (_jsx("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-14 rounded-b-lg bg-gradient-to-t from-accent via-accent/90 to-transparent" }))] }), isExpandable && (_jsxs("button", { type: "button", onClick: () => setExpanded((prev) => !prev), className: "mt-1 inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-[11px] font-medium text-muted-foreground hover:text-foreground", children: [_jsx(IconChevronDown, { className: cn("h-3.5 w-3.5 transition-transform", expanded && "rotate-180") }), expanded ? "Collapse" : "Expand"] }))] }) }));
451
454
  }
455
+ const CheckpointContext = React.createContext(null);
452
456
  function AssistantMessage() {
453
457
  const [copied, setCopied] = useState(false);
458
+ const [restoreState, setRestoreState] = useState("idle");
454
459
  const messageRuntime = useMessageRuntime();
455
460
  const thread = useThread();
456
461
  const msg = messageRuntime.getState();
457
462
  const isLast = thread.messages.length > 0 &&
458
463
  thread.messages[thread.messages.length - 1].id === msg.id;
459
464
  const isComplete = !isLast || !thread.isRunning;
465
+ const cpCtx = React.useContext(CheckpointContext);
460
466
  const handleCopy = useCallback(() => {
461
467
  const m = messageRuntime.getState();
462
468
  const text = m.content
@@ -467,12 +473,56 @@ function AssistantMessage() {
467
473
  setCopied(true);
468
474
  setTimeout(() => setCopied(false), 2000);
469
475
  }, [messageRuntime]);
476
+ const handleRestore = useCallback(async () => {
477
+ if (restoreState === "idle") {
478
+ setRestoreState("confirming");
479
+ return;
480
+ }
481
+ if (restoreState !== "confirming" || !cpCtx)
482
+ return;
483
+ setRestoreState("restoring");
484
+ try {
485
+ const m = messageRuntime.getState();
486
+ const runId = m.metadata?.runId;
487
+ if (!runId) {
488
+ setRestoreState("idle");
489
+ return;
490
+ }
491
+ // Look up checkpoint by runId
492
+ const tid = cpCtx.threadId || "";
493
+ const res = await fetch(`${cpCtx.apiUrl}/checkpoints?threadId=${encodeURIComponent(tid)}`);
494
+ const checkpoints = res.ok ? await res.json() : [];
495
+ const checkpoint = checkpoints.find((cp) => cp.runId === runId);
496
+ if (!checkpoint) {
497
+ setRestoreState("idle");
498
+ return;
499
+ }
500
+ const restoreRes = await fetch(`${cpCtx.apiUrl}/checkpoints/restore`, {
501
+ method: "POST",
502
+ headers: { "Content-Type": "application/json" },
503
+ body: JSON.stringify({ checkpointId: checkpoint.id }),
504
+ });
505
+ if (restoreRes.ok) {
506
+ window.location.reload();
507
+ }
508
+ else {
509
+ setRestoreState("idle");
510
+ }
511
+ }
512
+ catch {
513
+ setRestoreState("idle");
514
+ }
515
+ }, [restoreState, cpCtx, messageRuntime]);
516
+ const cancelRestore = useCallback(() => {
517
+ setRestoreState("idle");
518
+ }, []);
519
+ const showRestore = cpCtx?.devMode && isComplete && !isLast;
470
520
  return (_jsxs("div", { className: "group relative", style: { contentVisibility: isComplete ? "auto" : "visible" }, children: [_jsx("div", { className: "max-w-[95%] text-sm leading-relaxed text-foreground", children: _jsx(MessagePrimitive.Parts, { components: {
471
521
  Text: MarkdownText,
472
522
  tools: {
473
523
  Fallback: ToolCallFallback,
474
524
  },
475
- } }) }), isComplete && (_jsx("div", { className: "mt-1 flex items-center gap-0.5 opacity-0 group-hover:opacity-100", children: _jsx("button", { onClick: handleCopy, className: "flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", children: copied ? (_jsx(IconCheck, { className: "h-3 w-3" })) : (_jsx(IconCopy, { className: "h-3 w-3" })) }) }))] }));
525
+ } }) }), isComplete && (_jsxs("div", { className: "mt-1 flex items-center gap-0.5 opacity-0 group-hover:opacity-100", children: [_jsx("button", { onClick: handleCopy, className: "flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", children: copied ? (_jsx(IconCheck, { className: "h-3 w-3" })) : (_jsx(IconCopy, { className: "h-3 w-3" })) }), showRestore && restoreState === "idle" && (_jsx("button", { onClick: handleRestore, title: "Restore project files to this point", className: "flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", children: _jsx(IconArrowBackUp, { className: "h-3 w-3" }) })), showRestore && restoreState === "confirming" && (_jsxs("div", { className: "flex items-center gap-1 text-xs", children: [_jsx("button", { onClick: handleRestore, className: "rounded-md bg-destructive px-1.5 py-0.5 text-destructive-foreground hover:bg-destructive/90", children: "Restore to here?" }), _jsx("button", { onClick: cancelRestore, className: "rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-accent", children: "Cancel" })] })), showRestore && restoreState === "restoring" && (_jsxs("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" }), "Restoring..."] }))] }))] }));
476
526
  }
477
527
  // ─── Thinking Indicator ─────────────────────────────────────────────────────
478
528
  function ThinkingIndicator({ label = "Thinking" } = {}) {
@@ -500,7 +550,7 @@ function ApiKeySetupCard({ apiUrl }) {
500
550
  const res = await fetch(`${apiUrl}/save-key`, {
501
551
  method: "POST",
502
552
  headers: { "Content-Type": "application/json" },
503
- body: JSON.stringify({ key: apiKey.trim() }),
553
+ body: JSON.stringify({ key: apiKey.trim(), provider: "anthropic" }),
504
554
  });
505
555
  if (!res.ok) {
506
556
  const data = await res.json().catch(() => ({}));
@@ -519,13 +569,13 @@ function ApiKeySetupCard({ apiUrl }) {
519
569
  if (saved) {
520
570
  return (_jsx("div", { className: "mx-4 my-6 rounded-lg border border-emerald-500/30 bg-emerald-500/5 p-4", children: _jsxs("div", { className: "flex items-center gap-2 text-sm text-emerald-400", children: [_jsx(IconCheck, { className: "h-4 w-4" }), "API key saved. Reloading..."] }) }));
521
571
  }
522
- return (_jsxs("div", { className: "mx-4 my-6 rounded-lg border border-border bg-card p-5", children: [_jsxs("div", { className: "flex items-center gap-3 mb-3", children: [_jsx("div", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted", children: _jsx(IconMessage, { className: "h-4.5 w-4.5 text-muted-foreground" }) }), _jsxs("div", { children: [_jsx("h3", { className: "text-sm font-medium text-foreground", children: "Connect your AI" }), _jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: "Connect Builder or add an Anthropic API key to enable the agent" })] })] }), _jsxs("div", { className: "space-y-3", children: [_jsx("div", { className: "rounded-md border border-border px-3 py-2.5", children: _jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-xs font-medium text-foreground", children: "Connect Builder" }), _jsx("p", { className: "text-[11px] text-muted-foreground mt-0.5", children: "Use Builder's managed Anthropic proxy \u2014 no API key needed" })] }), _jsx("span", { className: "shrink-0 rounded border border-border px-2 py-0.5 text-[10px] font-medium text-muted-foreground", children: "Coming soon" })] }) }), _jsxs("div", { className: "relative flex items-center", children: [_jsx("div", { className: "flex-grow border-t border-border" }), _jsx("span", { className: "mx-2 text-[10px] uppercase tracking-wider text-muted-foreground/60", children: "or" }), _jsx("div", { className: "flex-grow border-t border-border" })] }), _jsxs("div", { className: "rounded-md bg-muted/50 px-3 py-2.5 text-xs text-muted-foreground leading-relaxed", children: [_jsxs("p", { children: ["1. Go to", " ", _jsx("a", { href: "https://console.anthropic.com/settings/keys", target: "_blank", rel: "noopener noreferrer", className: "underline text-foreground/80 hover:text-foreground", children: "console.anthropic.com/settings/keys" })] }), _jsx("p", { className: "mt-1", children: "2. Create a new API key and paste it below" })] }), _jsx("input", { type: "password", value: apiKey, onChange: (e) => {
572
+ return (_jsxs("div", { className: "mx-4 my-6 rounded-lg border border-border bg-card p-5", children: [_jsxs("div", { className: "flex items-center gap-3 mb-3", children: [_jsx("div", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted", children: _jsx(IconMessage, { className: "h-4.5 w-4.5 text-muted-foreground" }) }), _jsx("h3", { className: "text-sm font-medium text-foreground", children: "Connect your AI" })] }), _jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: "flex items-center gap-3 rounded-md border border-border px-3 py-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-xs font-medium text-foreground", children: "Connect Builder.io" }), _jsx("p", { className: "text-[11px] text-muted-foreground mt-0.5 max-w-[200px]", children: "Managed LLM, hosting, and more \u2014 no API key needed" })] }), _jsxs("a", { href: "https://forms.agent-native.com/f/builder-waitlist/36GWqf", target: "_blank", rel: "noopener noreferrer", className: "ml-auto inline-flex items-center gap-1 shrink-0 rounded-md bg-muted/60 px-3 py-1.5 text-[11px] font-medium no-underline text-foreground hover:bg-muted", children: ["Join waitlist", _jsx(IconExternalLink, { size: 10 })] })] }), _jsxs("div", { className: "relative flex items-center", children: [_jsx("div", { className: "flex-grow border-t border-border" }), _jsx("span", { className: "mx-2 text-[10px] uppercase tracking-wider text-muted-foreground/60", children: "or" }), _jsx("div", { className: "flex-grow border-t border-border" })] }), _jsx("input", { type: "password", value: apiKey, onChange: (e) => {
523
573
  setApiKey(e.target.value);
524
574
  setError(null);
525
575
  }, onKeyDown: (e) => {
526
576
  if (e.key === "Enter")
527
577
  handleSave();
528
- }, placeholder: "sk-ant-...", className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring", autoComplete: "off" }), error && _jsx("p", { className: "text-xs text-destructive", children: error }), _jsx("button", { onClick: handleSave, disabled: saving || !apiKey.trim(), className: "w-full rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed", children: saving ? "Saving..." : "Save API key" })] })] }));
578
+ }, placeholder: "sk-ant-...", className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring", autoComplete: "off" }), error && _jsx("p", { className: "text-xs text-destructive", children: error }), apiKey.trim() && (_jsx("button", { onClick: handleSave, disabled: saving, className: "w-full rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed", children: saving ? "Saving..." : "Save API key" })), _jsx("p", { className: "text-[10px] text-muted-foreground/60 text-center", children: _jsx("a", { href: "https://console.anthropic.com/settings/keys", target: "_blank", rel: "noopener noreferrer", className: "underline hover:text-foreground/80", children: "Get an Anthropic key" }) })] })] }));
529
579
  }
530
580
  // ─── Builder.io CTA Card (usage limit / code changes / CLI) ─────────────────
531
581
  export function BuilderCtaCard({ reason, usageCents, limitCents, apiUrl = "/_agent-native/agent-chat", }) {
@@ -546,7 +596,7 @@ export function BuilderCtaCard({ reason, usageCents, limitCents, apiUrl = "/_age
546
596
  const res = await fetch(`${apiUrl}/save-key`, {
547
597
  method: "POST",
548
598
  headers: { "Content-Type": "application/json" },
549
- body: JSON.stringify({ key: apiKey.trim() }),
599
+ body: JSON.stringify({ key: apiKey.trim(), provider: "anthropic" }),
550
600
  });
551
601
  if (!res.ok) {
552
602
  const data = await res.json().catch(() => ({}));
@@ -581,7 +631,7 @@ export function BuilderCtaCard({ reason, usageCents, limitCents, apiUrl = "/_age
581
631
  }, onKeyDown: (e) => {
582
632
  if (e.key === "Enter")
583
633
  handleSave();
584
- }, placeholder: "sk-ant-...", className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring", autoComplete: "off" }), error && _jsx("p", { className: "text-xs text-destructive", children: error }), _jsx("button", { onClick: handleSave, disabled: saving || !apiKey.trim(), className: "w-full rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed", children: saving ? "Saving..." : "Save API key" }), _jsxs("div", { className: "relative", children: [_jsx("div", { className: "absolute inset-0 flex items-center", children: _jsx("span", { className: "w-full border-t border-border" }) }), _jsx("div", { className: "relative flex justify-center text-xs", children: _jsx("span", { className: "bg-card px-2 text-muted-foreground", children: "or" }) })] }), _jsxs("div", { className: "rounded-md bg-muted/50 px-3 py-2.5", children: [_jsx("p", { className: "text-xs text-muted-foreground mb-1.5", children: "Clone and run locally:" }), _jsx("code", { className: "block text-xs text-foreground/80 font-mono break-all select-all", children: cloneCommand })] }), _jsx("div", { className: "rounded-md border border-border px-3 py-2.5", children: _jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-xs font-medium text-foreground", children: "Connect Builder.io" }), _jsx("p", { className: "text-[11px] text-muted-foreground mt-0.5", children: "Builder's managed Anthropic proxy \u2014 no API key needed" })] }), _jsx("span", { className: "shrink-0 rounded border border-border px-2 py-0.5 text-[10px] font-medium text-muted-foreground", children: "Coming soon" })] }) })] })] }));
634
+ }, placeholder: "sk-ant-...", className: "w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/50 outline-none focus:ring-1 focus:ring-ring", autoComplete: "off" }), error && _jsx("p", { className: "text-xs text-destructive", children: error }), _jsx("button", { onClick: handleSave, disabled: saving || !apiKey.trim(), className: "w-full rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed", children: saving ? "Saving..." : "Save API key" }), _jsxs("div", { className: "relative", children: [_jsx("div", { className: "absolute inset-0 flex items-center", children: _jsx("span", { className: "w-full border-t border-border" }) }), _jsx("div", { className: "relative flex justify-center text-xs", children: _jsx("span", { className: "bg-card px-2 text-muted-foreground", children: "or" }) })] }), _jsxs("div", { className: "rounded-md bg-muted/50 px-3 py-2.5", children: [_jsx("p", { className: "text-xs text-muted-foreground mb-1.5", children: "Clone and run locally:" }), _jsx("code", { className: "block text-xs text-foreground/80 font-mono break-all select-all", children: cloneCommand })] }), _jsxs("div", { className: "rounded-md border border-border px-3 py-2.5", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("div", { className: "text-xs font-medium text-foreground", children: "Builder.io" }), _jsxs("a", { href: "https://forms.agent-native.com/f/builder-waitlist/36GWqf", target: "_blank", rel: "noopener noreferrer", className: "inline-flex items-center gap-1 shrink-0 rounded border border-border px-2 py-0.5 text-[10px] font-medium no-underline text-muted-foreground hover:text-foreground hover:bg-accent/40", children: ["Join waitlist", _jsx(IconExternalLink, { size: 10 })] })] }), _jsx("p", { className: "text-[11px] text-muted-foreground mt-0.5", children: "Managed hosting, LLM, and more" })] })] })] }));
585
635
  }
586
636
  export const CHAT_STORAGE_PREFIX = "agent-chat:";
587
637
  /** Remove persisted chat for a given tabId (or "default"). */
@@ -611,7 +661,7 @@ function ensureMessageMetadata(repo) {
611
661
  // Re-export for backwards compatibility
612
662
  import { extractThreadMeta } from "../agent/thread-data-builder.js";
613
663
  export { extractThreadMeta };
614
- const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, showHeader = true, onSwitchToCli, className, apiUrl, tabId, threadId, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, isNewThread, onSlashCommand, execMode, onExecModeChange, }, ref) {
664
+ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, showHeader = true, onSwitchToCli, className, apiUrl, tabId, threadId, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, isNewThread, onSlashCommand, execMode, onExecModeChange, selectedModel, defaultModel, selectedEngine, availableModels, onModelChange, }, ref) {
615
665
  const scrollRef = useRef(null);
616
666
  const thread = useThread();
617
667
  const threadRuntime = useThreadRuntime();
@@ -1009,6 +1059,43 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
1009
1059
  window.addEventListener("agent-chat:missing-api-key", handler);
1010
1060
  return () => window.removeEventListener("agent-chat:missing-api-key", handler);
1011
1061
  }, []);
1062
+ // Check on mount and whenever SettingsPanel dispatches
1063
+ // `agent-engine:configured-changed` so the gate flips live without reload.
1064
+ useEffect(() => {
1065
+ let cancelled = false;
1066
+ const check = async () => {
1067
+ const [envKeys, builderStatus, engineStatus] = await Promise.all([
1068
+ fetch("/_agent-native/env-status")
1069
+ .then((r) => (r.ok ? r.json() : null))
1070
+ .catch(() => null),
1071
+ fetch("/_agent-native/builder/status")
1072
+ .then((r) => (r.ok ? r.json() : null))
1073
+ .catch(() => null),
1074
+ fetch("/_agent-native/agent-engine/status")
1075
+ .then((r) => (r.ok ? r.json() : null))
1076
+ .catch(() => null),
1077
+ ]);
1078
+ if (cancelled)
1079
+ return;
1080
+ // All three status endpoints failed — avoid flashing the gate on a
1081
+ // transient network error.
1082
+ if (envKeys == null && builderStatus == null && engineStatus == null) {
1083
+ return;
1084
+ }
1085
+ const keys = (envKeys ?? []);
1086
+ const llmKeys = keys.filter((k) => PROVIDER_ENV_VAR_SET.has(k.key));
1087
+ const anyConfigured = llmKeys.some((k) => k.configured) ||
1088
+ builderStatus?.configured === true ||
1089
+ engineStatus?.configured === true;
1090
+ setMissingApiKey(!anyConfigured);
1091
+ };
1092
+ check();
1093
+ window.addEventListener("agent-engine:configured-changed", check);
1094
+ return () => {
1095
+ cancelled = true;
1096
+ window.removeEventListener("agent-engine:configured-changed", check);
1097
+ };
1098
+ }, []);
1012
1099
  // Listen for auth error events from the adapter
1013
1100
  useEffect(() => {
1014
1101
  const handler = (e) => {
@@ -1191,68 +1278,76 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
1191
1278
  }, 100);
1192
1279
  return () => clearInterval(interval);
1193
1280
  }, [isRunning]);
1194
- return (_jsx(ChatRunningContext.Provider, { value: isRunning, children: _jsxs("div", { className: cn("flex flex-1 flex-col h-full min-h-0 text-foreground", className), children: [showHeader && (_jsxs("div", { className: "flex h-11 shrink-0 items-center justify-between border-b border-border px-4", children: [_jsx("span", { className: "text-[13px] font-medium text-muted-foreground", children: "Agent" }), _jsx("div", { className: "flex items-center gap-1", children: onSwitchToCli && (_jsxs("button", { onClick: onSwitchToCli, className: "flex items-center gap-1 text-[12px] text-muted-foreground hover:text-foreground px-2 py-1 rounded-md hover:bg-accent", title: "Switch to CLI", children: [_jsx(IconTerminal, { className: "h-3.5 w-3.5" }), "CLI"] })) })] })), _jsx("div", { ref: scrollRef, className: "flex-1 overflow-y-auto overflow-x-hidden min-h-0", children: authError ? (_jsxs("div", { className: "flex flex-col items-center justify-center h-full px-4 gap-3", children: [_jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10", children: _jsx(IconLock, { className: "h-5 w-5 text-destructive" }) }), _jsxs("div", { className: "text-center max-w-[280px]", children: [_jsx("p", { className: "text-sm font-medium text-foreground mb-1", children: authError.sessionExpired
1195
- ? "Session expired"
1196
- : "Authentication required" }), _jsx("p", { className: "text-xs text-muted-foreground leading-relaxed", children: authError.sessionExpired ? ("Your session may have expired. Log out and log back in to reconnect.") : (_jsxs(_Fragment, { children: ["You need to log in to use the agent. If you're running locally, add", " ", _jsx("code", { className: "bg-muted px-1 py-0.5 rounded text-[10px]", children: "AUTH_MODE=local" }), " ", "to your", " ", _jsx("code", { className: "bg-muted px-1 py-0.5 rounded text-[10px]", children: ".env" }), " ", "file and restart the dev server."] })) })] }), _jsxs("div", { className: "flex gap-2", children: [authError.sessionExpired && (_jsx("button", { onClick: async () => {
1197
- try {
1198
- await fetch("/_agent-native/auth/logout", {
1199
- method: "POST",
1200
- });
1201
- }
1202
- catch { }
1203
- window.location.reload();
1204
- }, className: "text-xs text-destructive hover:text-destructive/80 px-3 py-1.5 rounded-md border border-destructive/30 hover:bg-destructive/10", children: "Log out" })), _jsx("button", { onClick: () => {
1205
- setAuthError(null);
1206
- window.location.reload();
1207
- }, className: "text-xs text-muted-foreground hover:text-foreground px-3 py-1.5 rounded-md border border-border hover:bg-accent", children: "Retry" })] })] })) : missingApiKey ? (_jsx("div", { className: "flex flex-col items-center justify-center h-full px-2", children: _jsx(ApiKeySetupCard, { apiUrl: apiUrl }) })) : usageLimitReached ? (_jsx("div", { className: "flex flex-col items-center justify-center h-full px-2", children: _jsx(BuilderCtaCard, { reason: "usage_limit", usageCents: usageLimitReached.usageCents, limitCents: usageLimitReached.limitCents, apiUrl: apiUrl }) })) : isRestoring ? (_jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("div", { className: "flex justify-end", children: _jsx("div", { className: "h-8 w-32 rounded-lg bg-muted animate-pulse" }) }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("div", { className: "h-4 w-48 rounded bg-muted animate-pulse" }), _jsx("div", { className: "h-4 w-64 rounded bg-muted animate-pulse" }), _jsx("div", { className: "h-4 w-40 rounded bg-muted animate-pulse" })] })] })) : messages.length === 0 && !isReconnecting ? (_jsxs("div", { className: "flex flex-col items-center justify-center gap-4 py-16 px-4 h-full", children: [_jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-muted", children: _jsx(IconMessage, { className: "h-5 w-5 text-muted-foreground" }) }), _jsx("p", { className: "text-sm text-muted-foreground text-center max-w-[240px]", children: emptyStateText ?? "How can I help you?" }), suggestions && suggestions.length > 0 && (_jsx("div", { className: "flex flex-col gap-1.5 w-full max-w-[280px]", children: suggestions.map((suggestion) => (_jsx("button", { onClick: () => {
1208
- threadRuntime.append({
1209
- role: "user",
1210
- content: [{ type: "text", text: suggestion }],
1211
- });
1212
- }, className: "w-full rounded-lg border border-border px-3 py-2 text-left text-[13px] text-muted-foreground hover:bg-accent hover:text-foreground", children: suggestion }, suggestion))) }))] })) : (_jsxs("div", { className: "agent-thread-content flex flex-col gap-4 px-4 py-4", children: [_jsx(ThreadPrimitive.Messages, { components: {
1213
- UserMessage,
1214
- AssistantMessage,
1215
- } }), showContinue && !showRunningInUI && (_jsx("div", { className: "flex justify-center py-2", children: _jsx("button", { type: "button", onClick: () => {
1216
- setShowContinue(false);
1217
- addToQueue("Continue from where you left off.");
1218
- }, className: "rounded-lg border border-border bg-background px-4 py-2 text-sm font-medium text-foreground hover:bg-accent", children: "Continue" }) })), (isReconnecting || reconnectFrozen) &&
1219
- reconnectContent.length > 0 && (_jsx(ReconnectStreamMessage, { content: reconnectContent })), showRunningInUI && (_jsx(ThinkingIndicator, { label: isReconnecting ? "Reconnecting" : "Thinking" })), queuedMessages.map((msg) => {
1220
- const displayText = msg.text
1221
- .replace(/<context>[\s\S]*?<\/context>\n?/g, "")
1222
- .trim();
1223
- return (_jsx("div", { className: "flex justify-end group", children: _jsxs("div", { className: "relative max-w-[85%] rounded-lg bg-accent/50 text-foreground/60 px-3 py-2 text-sm leading-relaxed whitespace-pre-wrap break-words", children: [_jsxs("div", { className: "flex items-center gap-1.5 text-[10px] text-muted-foreground mb-1 font-medium uppercase tracking-wide", children: [_jsx(IconClock, { className: "h-3 w-3" }), "Queued"] }), displayText, msg.images && msg.images.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-1.5 mt-1.5", children: msg.images.map((img, j) => (_jsx("img", { src: img, alt: "", className: "h-12 w-12 rounded object-cover border border-border/50" }, j))) })), _jsx("button", { type: "button", onClick: () => setQueuedMessages((prev) => prev.filter((m) => m.id !== msg.id)), "aria-label": "Remove from queue", className: "absolute -top-2 -right-2 flex h-5 w-5 items-center justify-center rounded-full border border-border bg-background text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:text-foreground hover:bg-accent shadow-sm", children: _jsx(IconX, { className: "h-3 w-3" }) })] }) }, msg.id));
1224
- })] })) }), showScrollToBottom && (_jsx("div", { className: "shrink-0 flex justify-center -mb-1", children: _jsx("button", { type: "button", onClick: scrollToBottom, className: "flex h-7 w-7 items-center justify-center rounded-full border border-border bg-background shadow-sm hover:bg-accent", "aria-label": "Scroll to bottom", children: _jsx(IconChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) }) })), composerSlot, _jsx("div", { className: "agent-composer-area shrink-0 px-3 py-2", children: _jsxs(ComposerPrimitive.Root, { className: "flex flex-col rounded-lg border border-input bg-background focus-within:ring-1 focus-within:ring-ring", children: [_jsx(ComposerAttachmentPreviewStrip, {}), _jsx(TiptapComposer, { focusRef: tiptapRef, placeholder: isRunning
1225
- ? queuedMessages.length > 0
1226
- ? `${queuedMessages.length} queued type another...`
1227
- : "Queue a message..."
1228
- : undefined, onSubmit: isRunning
1229
- ? (text, references) => addToQueue(text, undefined, references.length > 0 ? references : undefined)
1230
- : undefined, onSlashCommand: onSlashCommand, execMode: execMode, onExecModeChange: onExecModeChange, extraActionButton: showRunningInUI ? (_jsx("button", { type: "button", onClick: () => {
1231
- // Nuclear stop: flip forceStopped so isRunning is false
1232
- // immediately. This unblocks submission even if the
1233
- // runtime or reconnect state is stuck.
1234
- setForceStopped(true);
1235
- if (isReconnecting) {
1236
- if (reconnectRunIdRef.current) {
1237
- fetch(`${apiUrl}/runs/${encodeURIComponent(reconnectRunIdRef.current)}/abort`, { method: "POST" });
1281
+ const { isDevMode: cpDevMode } = useDevMode(apiUrl);
1282
+ const checkpointCtx = useMemo(() => ({ apiUrl, devMode: cpDevMode, threadId }), [apiUrl, cpDevMode, threadId]);
1283
+ return (_jsx(CheckpointContext.Provider, { value: checkpointCtx, children: _jsx(ChatRunningContext.Provider, { value: isRunning, children: _jsxs("div", { className: cn("flex flex-1 flex-col h-full min-h-0 text-foreground", className), children: [showHeader && (_jsxs("div", { className: "flex h-11 shrink-0 items-center justify-between border-b border-border px-4", children: [_jsx("span", { className: "text-[13px] font-medium text-muted-foreground", children: "Agent" }), _jsx("div", { className: "flex items-center gap-1", children: onSwitchToCli && (_jsxs("button", { onClick: onSwitchToCli, className: "flex items-center gap-1 text-[12px] text-muted-foreground hover:text-foreground px-2 py-1 rounded-md hover:bg-accent", title: "Switch to CLI", children: [_jsx(IconTerminal, { className: "h-3.5 w-3.5" }), "CLI"] })) })] })), _jsx("div", { ref: scrollRef, className: "flex-1 overflow-y-auto overflow-x-hidden min-h-0", children: authError ? (_jsxs("div", { className: "flex flex-col items-center justify-center h-full px-4 gap-3", children: [_jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10", children: _jsx(IconLock, { className: "h-5 w-5 text-destructive" }) }), _jsxs("div", { className: "text-center max-w-[280px]", children: [_jsx("p", { className: "text-sm font-medium text-foreground mb-1", children: authError.sessionExpired
1284
+ ? "Session expired"
1285
+ : "Authentication required" }), _jsx("p", { className: "text-xs text-muted-foreground leading-relaxed", children: authError.sessionExpired ? ("Your session may have expired. Log out and log back in to reconnect.") : (_jsxs(_Fragment, { children: ["You need to log in to use the agent. If you're running locally, add", " ", _jsx("code", { className: "bg-muted px-1 py-0.5 rounded text-[10px]", children: "AUTH_MODE=local" }), " ", "to your", " ", _jsx("code", { className: "bg-muted px-1 py-0.5 rounded text-[10px]", children: ".env" }), " ", "file and restart the dev server."] })) })] }), _jsxs("div", { className: "flex gap-2", children: [authError.sessionExpired && (_jsx("button", { onClick: async () => {
1286
+ try {
1287
+ await fetch("/_agent-native/auth/logout", {
1288
+ method: "POST",
1289
+ });
1290
+ }
1291
+ catch { }
1292
+ window.location.reload();
1293
+ }, className: "text-xs text-destructive hover:text-destructive/80 px-3 py-1.5 rounded-md border border-destructive/30 hover:bg-destructive/10", children: "Log out" })), _jsx("button", { onClick: () => {
1294
+ setAuthError(null);
1295
+ window.location.reload();
1296
+ }, className: "text-xs text-muted-foreground hover:text-foreground px-3 py-1.5 rounded-md border border-border hover:bg-accent", children: "Retry" })] })] })) : missingApiKey ? (_jsx("div", { className: "flex flex-col items-center justify-center h-full px-2", children: _jsx(ApiKeySetupCard, { apiUrl: apiUrl }) })) : usageLimitReached ? (_jsx("div", { className: "flex flex-col items-center justify-center h-full px-2", children: _jsx(BuilderCtaCard, { reason: "usage_limit", usageCents: usageLimitReached.usageCents, limitCents: usageLimitReached.limitCents, apiUrl: apiUrl }) })) : isRestoring ? (_jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("div", { className: "flex justify-end", children: _jsx("div", { className: "h-8 w-32 rounded-lg bg-muted animate-pulse" }) }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("div", { className: "h-4 w-48 rounded bg-muted animate-pulse" }), _jsx("div", { className: "h-4 w-64 rounded bg-muted animate-pulse" }), _jsx("div", { className: "h-4 w-40 rounded bg-muted animate-pulse" })] })] })) : messages.length === 0 && !isReconnecting ? (_jsxs("div", { className: "flex flex-col items-center justify-center gap-4 py-16 px-4 h-full", children: [_jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-muted", children: _jsx(IconMessage, { className: "h-5 w-5 text-muted-foreground" }) }), _jsx("p", { className: "text-sm text-muted-foreground text-center max-w-[240px]", children: emptyStateText ?? "How can I help you?" }), suggestions && suggestions.length > 0 && (_jsx("div", { className: "flex flex-col gap-1.5 w-full max-w-[280px]", children: suggestions.map((suggestion) => (_jsx("button", { onClick: () => {
1297
+ threadRuntime.append({
1298
+ role: "user",
1299
+ content: [{ type: "text", text: suggestion }],
1300
+ });
1301
+ }, className: "w-full rounded-lg border border-border px-3 py-2 text-left text-[13px] text-muted-foreground hover:bg-accent hover:text-foreground", children: suggestion }, suggestion))) }))] })) : (_jsxs("div", { className: "agent-thread-content flex flex-col gap-4 px-4 py-4", children: [_jsx(ThreadPrimitive.Messages, { components: {
1302
+ UserMessage,
1303
+ AssistantMessage,
1304
+ } }), showContinue && !showRunningInUI && (_jsx("div", { className: "flex justify-center py-2", children: _jsx("button", { type: "button", onClick: () => {
1305
+ setShowContinue(false);
1306
+ addToQueue("Continue from where you left off.");
1307
+ }, className: "rounded-lg border border-border bg-background px-4 py-2 text-sm font-medium text-foreground hover:bg-accent", children: "Continue" }) })), (isReconnecting || reconnectFrozen) &&
1308
+ reconnectContent.length > 0 && (_jsx(ReconnectStreamMessage, { content: reconnectContent })), showRunningInUI && (_jsx(ThinkingIndicator, { label: isReconnecting ? "Reconnecting" : "Thinking" })), queuedMessages.map((msg) => {
1309
+ const displayText = msg.text
1310
+ .replace(/<context>[\s\S]*?<\/context>\n?/g, "")
1311
+ .trim();
1312
+ return (_jsx("div", { className: "flex justify-end group", children: _jsxs("div", { className: "relative max-w-[85%] rounded-lg bg-accent/50 text-foreground/60 px-3 py-2 text-sm leading-relaxed whitespace-pre-wrap break-words", children: [_jsxs("div", { className: "flex items-center gap-1.5 text-[10px] text-muted-foreground mb-1 font-medium uppercase tracking-wide", children: [_jsx(IconClock, { className: "h-3 w-3" }), "Queued"] }), displayText, msg.images && msg.images.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-1.5 mt-1.5", children: msg.images.map((img, j) => (_jsx("img", { src: img, alt: "", className: "h-12 w-12 rounded object-cover border border-border/50" }, j))) })), _jsx("button", { type: "button", onClick: () => setQueuedMessages((prev) => prev.filter((m) => m.id !== msg.id)), "aria-label": "Remove from queue", className: "absolute -top-2 -right-2 flex h-5 w-5 items-center justify-center rounded-full border border-border bg-background text-muted-foreground opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:text-foreground hover:bg-accent shadow-sm", children: _jsx(IconX, { className: "h-3 w-3" }) })] }) }, msg.id));
1313
+ })] })) }), showScrollToBottom && (_jsx("div", { className: "shrink-0 flex justify-center -mb-1", children: _jsx("button", { type: "button", onClick: scrollToBottom, className: "flex h-7 w-7 items-center justify-center rounded-full border border-border bg-background shadow-sm hover:bg-accent", "aria-label": "Scroll to bottom", children: _jsx(IconChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) }) })), composerSlot, _jsx("div", { className: "agent-composer-area shrink-0 px-3 py-2", children: _jsxs(ComposerPrimitive.Root, { className: "flex flex-col rounded-lg border border-input bg-background focus-within:ring-1 focus-within:ring-ring", children: [_jsx(ComposerAttachmentPreviewStrip, {}), _jsx(TiptapComposer, { focusRef: tiptapRef, disabled: missingApiKey, placeholder: missingApiKey
1314
+ ? "Connect an AI engine above to start chatting…"
1315
+ : isRunning
1316
+ ? queuedMessages.length > 0
1317
+ ? `${queuedMessages.length} queued type another...`
1318
+ : "Queue a message..."
1319
+ : undefined, onSubmit: isRunning
1320
+ ? (text, references) => addToQueue(text, undefined, references.length > 0 ? references : undefined)
1321
+ : undefined, onSlashCommand: onSlashCommand, execMode: execMode, onExecModeChange: onExecModeChange, selectedModel: selectedModel ?? defaultModel, availableModels: availableModels, onModelChange: onModelChange, extraActionButton: showRunningInUI ? (_jsx("button", { type: "button", onClick: () => {
1322
+ // Nuclear stop: flip forceStopped so isRunning is false
1323
+ // immediately. This unblocks submission even if the
1324
+ // runtime or reconnect state is stuck.
1325
+ setForceStopped(true);
1326
+ if (isReconnecting) {
1327
+ if (reconnectRunIdRef.current) {
1328
+ fetch(`${apiUrl}/runs/${encodeURIComponent(reconnectRunIdRef.current)}/abort`, { method: "POST" });
1329
+ }
1330
+ reconnectAbortRef.current?.abort();
1331
+ reconnectAbortRef.current = null;
1332
+ reconnectRunIdRef.current = null;
1333
+ setIsReconnecting(false);
1334
+ setReconnectFrozen(reconnectContent.length > 0);
1238
1335
  }
1239
- reconnectAbortRef.current?.abort();
1240
- reconnectAbortRef.current = null;
1241
- reconnectRunIdRef.current = null;
1242
- setIsReconnecting(false);
1243
- setReconnectFrozen(reconnectContent.length > 0);
1244
- }
1245
- threadRuntime.cancelRun();
1246
- window.dispatchEvent(new CustomEvent("builder.chatRunning", {
1247
- detail: {
1248
- isRunning: false,
1249
- tabId: tabId || threadId,
1250
- },
1251
- }));
1252
- }, className: "shrink-0 flex h-7 w-7 items-center justify-center rounded-md bg-muted text-foreground hover:bg-muted/80", title: "Stop generating", children: _jsx(IconPlayerStop, { className: "h-3.5 w-3.5" }) })) : undefined })] }) })] }) }));
1336
+ threadRuntime.cancelRun();
1337
+ window.dispatchEvent(new CustomEvent("builder.chatRunning", {
1338
+ detail: {
1339
+ isRunning: false,
1340
+ tabId: tabId || threadId,
1341
+ },
1342
+ }));
1343
+ }, className: "shrink-0 flex h-7 w-7 items-center justify-center rounded-md bg-muted text-foreground hover:bg-muted/80", title: "Stop generating", children: _jsx(IconPlayerStop, { className: "h-3.5 w-3.5" }) })) : undefined })] }) })] }) }) }));
1253
1344
  });
1254
1345
  export const AssistantChat = forwardRef(function AssistantChat({ apiUrl = "/_agent-native/agent-chat", tabId, threadId, ...props }, ref) {
1255
- const adapter = useMemo(() => createAgentChatAdapter({ apiUrl, tabId, threadId }), [apiUrl, tabId, threadId]);
1346
+ const modelRef = useRef(props.selectedModel);
1347
+ modelRef.current = props.selectedModel;
1348
+ const engineRef = useRef(props.selectedEngine);
1349
+ engineRef.current = props.selectedEngine;
1350
+ const adapter = useMemo(() => createAgentChatAdapter({ apiUrl, tabId, threadId, modelRef, engineRef }), [apiUrl, tabId, threadId]);
1256
1351
  const attachmentAdapter = useMemo(() => new CompositeAttachmentAdapter([
1257
1352
  new SimpleImageAttachmentAdapter(),
1258
1353
  new SimpleTextAttachmentAdapter(),