@engenty/wizards-runtime 0.7.11 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/README.md +5 -1
  2. package/apps/runtime/dist/agents/architect.js +2 -2
  3. package/apps/runtime/dist/agents/studio-assistant.js +1 -1
  4. package/apps/runtime/dist/agents/website.js +1 -1
  5. package/apps/runtime/dist/app.js +1 -1
  6. package/apps/runtime/dist/assistant/browser.js +1 -1
  7. package/apps/runtime/dist/authoring/guide.js +16 -4
  8. package/apps/runtime/dist/authoring/ops.js +1 -1
  9. package/apps/runtime/dist/cli/exec.js +4 -1
  10. package/apps/runtime/dist/cli/features.js +1 -1
  11. package/apps/runtime/dist/cli/validate.js +2 -2
  12. package/apps/runtime/dist/connectors/builtin.js +4 -2
  13. package/apps/runtime/dist/connectors/external.js +1 -1
  14. package/apps/runtime/dist/connectors/index.js +37 -6
  15. package/apps/runtime/dist/connectors/smtp.js +221 -0
  16. package/apps/runtime/dist/connectors/via-account.js +1 -1
  17. package/apps/runtime/dist/credits/estimate.js +1 -1
  18. package/apps/runtime/dist/db/migrations/tenant/0018_share_job.sql +18 -0
  19. package/apps/runtime/dist/db/migrations/tenant/meta/0018_snapshot.json +3460 -0
  20. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  21. package/apps/runtime/dist/db/schema.js +19 -0
  22. package/apps/runtime/dist/docs/dev/index.md +25 -13
  23. package/apps/runtime/dist/docs/dev/integration/index.md +1 -1
  24. package/apps/runtime/dist/docs/dev/integration/openui.md +1 -1
  25. package/apps/runtime/dist/docs/dev/integration/own-ui.md +2 -2
  26. package/apps/runtime/dist/docs/dev/meta.json +8 -2
  27. package/apps/runtime/dist/docs/dev/plugins/examples.md +2 -3
  28. package/apps/runtime/dist/docs/dev/plugins/studio.md +5 -6
  29. package/apps/runtime/dist/docs/dev/plugins/styling.md +10 -7
  30. package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +112 -0
  31. package/apps/runtime/dist/docs/dev/wizard-format/branches.md +63 -0
  32. package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +47 -0
  33. package/apps/runtime/dist/docs/dev/wizard-format/generate-steps.md +57 -0
  34. package/apps/runtime/dist/docs/dev/wizard-format/index.md +188 -0
  35. package/apps/runtime/dist/docs/dev/wizard-format/lists-and-connections.md +65 -0
  36. package/apps/runtime/dist/docs/dev/wizard-format/meta.json +19 -0
  37. package/apps/runtime/dist/docs/dev/wizard-format/pages-and-fields.md +102 -0
  38. package/apps/runtime/dist/docs/dev/wizard-format/review-and-result.md +64 -0
  39. package/apps/runtime/dist/docs/dev/wizard-format/templates.md +57 -0
  40. package/apps/runtime/dist/docs/dev/wizard-format/validate.md +63 -0
  41. package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +103 -0
  42. package/apps/runtime/dist/docs/dev/wizard-format/wizard-file.md +147 -0
  43. package/apps/runtime/dist/docs/user/build-a-wizard.md +2 -2
  44. package/apps/runtime/dist/docs/user/run.md +21 -4
  45. package/apps/runtime/dist/docs/user/space.md +14 -10
  46. package/apps/runtime/dist/docs/user/steps.md +26 -1
  47. package/apps/runtime/dist/docs/user/test-and-share.md +3 -2
  48. package/apps/runtime/dist/documents/parse.js +1 -1
  49. package/apps/runtime/dist/engine/decide.js +1 -1
  50. package/apps/runtime/dist/engine/events.js +1 -1
  51. package/apps/runtime/dist/engine/input.js +3 -3
  52. package/apps/runtime/dist/engine/prepare.js +1 -1
  53. package/apps/runtime/dist/engine/requirements.js +25 -10
  54. package/apps/runtime/dist/engine/runner.js +23 -14
  55. package/apps/runtime/dist/engine/steps.js +6 -6
  56. package/apps/runtime/dist/engine/surface.js +3 -3
  57. package/apps/runtime/dist/engine/template.js +4 -4
  58. package/apps/runtime/dist/env.js +5 -0
  59. package/apps/runtime/dist/features.js +1 -1
  60. package/apps/runtime/dist/film/project.js +2 -2
  61. package/apps/runtime/dist/film/step.js +2 -2
  62. package/apps/runtime/dist/harness/antigravity.js +2 -10
  63. package/apps/runtime/dist/harness/apple.js +1 -1
  64. package/apps/runtime/dist/harness/claude.js +3 -11
  65. package/apps/runtime/dist/harness/codex.js +6 -12
  66. package/apps/runtime/dist/harness/cursor.js +2 -10
  67. package/apps/runtime/dist/harness/env.js +23 -0
  68. package/apps/runtime/dist/harness/index.js +6 -3
  69. package/apps/runtime/dist/harness/model.js +1 -1
  70. package/apps/runtime/dist/harness/terminal.js +1 -1
  71. package/apps/runtime/dist/mcp/flow-app.js +1 -1
  72. package/apps/runtime/dist/media/conversation.js +1 -1
  73. package/apps/runtime/dist/media/transcribe.js +1 -1
  74. package/apps/runtime/dist/model-errors.js +1 -1
  75. package/apps/runtime/dist/models.js +3 -3
  76. package/apps/runtime/dist/plugin.js +1 -1
  77. package/apps/runtime/dist/plugins/discovery.js +1 -1
  78. package/apps/runtime/dist/plugins/loader.js +2 -2
  79. package/apps/runtime/dist/plugins/runs.js +2 -2
  80. package/apps/runtime/dist/render/downloads.js +2 -2
  81. package/apps/runtime/dist/render/shaped.js +1 -1
  82. package/apps/runtime/dist/routes/api.js +2 -2
  83. package/apps/runtime/dist/routes/lang.js +1 -1
  84. package/apps/runtime/dist/routes/marketplace.js +1 -1
  85. package/apps/runtime/dist/routes/runs.js +110 -10
  86. package/apps/runtime/dist/routes/studio.js +20 -8
  87. package/apps/runtime/dist/services/access.js +1 -1
  88. package/apps/runtime/dist/services/api.js +4 -4
  89. package/apps/runtime/dist/services/assistant-chats.js +2 -2
  90. package/apps/runtime/dist/services/brand.js +2 -2
  91. package/apps/runtime/dist/services/cloud.js +1 -1
  92. package/apps/runtime/dist/services/errors.js +1 -1
  93. package/apps/runtime/dist/services/files.js +1 -1
  94. package/apps/runtime/dist/services/knowledge-model.js +3 -3
  95. package/apps/runtime/dist/services/knowledge.js +2 -2
  96. package/apps/runtime/dist/services/marketplace.js +5 -5
  97. package/apps/runtime/dist/services/package-file.js +3 -3
  98. package/apps/runtime/dist/services/package.js +2 -2
  99. package/apps/runtime/dist/services/profile.js +1 -1
  100. package/apps/runtime/dist/services/project-files.js +2 -2
  101. package/apps/runtime/dist/services/project-index.js +1 -1
  102. package/apps/runtime/dist/services/projects.js +2 -2
  103. package/apps/runtime/dist/services/runners.js +3 -3
  104. package/apps/runtime/dist/services/runs.js +2 -2
  105. package/apps/runtime/dist/services/shares.js +1 -1
  106. package/apps/runtime/dist/services/site.js +2 -2
  107. package/apps/runtime/dist/services/space-categories.js +3 -3
  108. package/apps/runtime/dist/services/space-data.js +4 -4
  109. package/apps/runtime/dist/services/spaces.js +6 -6
  110. package/apps/runtime/dist/services/translations.js +5 -5
  111. package/apps/runtime/dist/services/widgets.js +1 -1
  112. package/apps/runtime/dist/services/wizards.js +3 -3
  113. package/apps/runtime/dist/sharing/agent.js +65 -0
  114. package/apps/runtime/dist/sharing/files.js +121 -0
  115. package/apps/runtime/dist/sharing/index.js +298 -0
  116. package/apps/runtime/dist/sharing/jobs.js +186 -0
  117. package/apps/runtime/dist/sharing/state.js +116 -0
  118. package/apps/runtime/dist/sharing/targets/browser.js +131 -0
  119. package/apps/runtime/dist/sharing/targets/connector.js +63 -0
  120. package/apps/runtime/dist/sharing/targets/email.js +98 -0
  121. package/apps/runtime/dist/sharing/targets/slack.js +54 -0
  122. package/apps/runtime/dist/sharing/targets/storage.js +164 -0
  123. package/apps/runtime/dist/sharing/types.js +13 -0
  124. package/apps/runtime/dist/store/index.js +3 -3
  125. package/apps/runtime/dist/store/shared-lists.js +1 -1
  126. package/apps/runtime/dist/texts.js +109 -1
  127. package/apps/runtime/dist/tools/browser.js +48 -0
  128. package/apps/runtime/dist/tools/connector.js +3 -2
  129. package/apps/runtime/dist/tools/index.js +1 -1
  130. package/apps/runtime/dist/tools/plugin.js +2 -2
  131. package/apps/runtime/dist/tools/project.js +1 -1
  132. package/apps/runtime/dist/tools/store.js +20 -3
  133. package/apps/runtime/dist/widgets/bundle.js +1 -1
  134. package/apps/runtime/dist/widgets/step.js +3 -3
  135. package/apps/web/dist/assets/AboutDialog-CB0EwGxP.js +1 -0
  136. package/apps/web/dist/assets/{ChangelogDialog-CZrd-MgC.js → ChangelogDialog-BQRBkiVD.js} +1 -1
  137. package/apps/web/dist/assets/ChatView-BLZkLlHi.js +10 -0
  138. package/apps/web/dist/assets/EditorPage-YawfYRAL.js +4 -0
  139. package/apps/web/dist/assets/{FlowPreview-oX_Emm7u.js → FlowPreview-B0xF8e3r.js} +1 -1
  140. package/apps/web/dist/assets/{Harness-DiB8CBdY.js → Harness-snRbALGd.js} +2 -2
  141. package/apps/web/dist/assets/NewWizardChannels-BGzp9z0m.js +1 -0
  142. package/apps/web/dist/assets/{NewWizardPage-C2Oh2sMM.js → NewWizardPage-cOHfwcnA.js} +2 -2
  143. package/apps/web/dist/assets/OnboardingPage-jB3ChKi3.js +1 -0
  144. package/apps/web/dist/assets/ProjectPage-hRCBquNb.js +1 -0
  145. package/apps/web/dist/assets/PublicRunner-D_ZkOyRV.js +1 -0
  146. package/apps/web/dist/assets/{ReadOnly-CD5YWvrW.js → ReadOnly-Db_odT6Y.js} +1 -1
  147. package/apps/web/dist/assets/RunDrawer-B6AQw90D.js +4 -0
  148. package/apps/web/dist/assets/RunnerView-DHUkvi_G.js +1 -0
  149. package/apps/web/dist/assets/SettingsPage-DleMaLz8.js +2 -0
  150. package/apps/web/dist/assets/SetupPage-DTvVJR1U.js +1 -0
  151. package/apps/web/dist/assets/{SharePage-B6u9kS12.js → SharePage-Bl-rfCji.js} +1 -1
  152. package/apps/web/dist/assets/changelog-BcW79fHm.js +1 -0
  153. package/apps/web/dist/assets/esm-Bji0ThaK.js +7 -0
  154. package/apps/web/dist/assets/index-CQKA-z2z.js +14 -0
  155. package/apps/web/dist/assets/index-Cnziz-H-.css +1 -0
  156. package/apps/web/dist/assets/oss-credits-BjwxLtU4.js +1 -0
  157. package/apps/web/dist/assets/{phone-BjmhIKuT.js → phone-DwAf8S3l.js} +1 -1
  158. package/apps/web/dist/assets/settings-menu-B1ND1GF3.js +1 -0
  159. package/apps/web/dist/assets/ui-Cdv3QUOd.js +137 -0
  160. package/apps/web/dist/assets/{upload-JX9BcMTq.js → upload-DCMZI6pp.js} +1 -1
  161. package/apps/web/dist/assets/{wrench-BSxnPs2_.js → wrench-BRYtnxti.js} +1 -1
  162. package/apps/web/dist/index.html +3 -3
  163. package/apps/web/dist/mcp/flow.html +53 -53
  164. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/definition.d.ts +22 -0
  165. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/definition.js +26 -0
  166. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/run.d.ts +6 -0
  167. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/run.js +2 -0
  168. package/node_modules/@engenty/wizards-shared/dist/sharing.d.ts +135 -0
  169. package/node_modules/@engenty/wizards-shared/dist/sharing.js +11 -0
  170. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/store.d.ts +8 -0
  171. package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/package.json +1 -1
  172. package/package.json +4 -3
  173. package/plugin/.claude-plugin/plugin.json +1 -1
  174. package/apps/runtime/dist/docs/dev/wizard-format.md +0 -125
  175. package/apps/web/dist/assets/AboutDialog-CPRAlD2H.js +0 -1
  176. package/apps/web/dist/assets/ChatView-DVeERQdi.js +0 -10
  177. package/apps/web/dist/assets/EditorPage-DhUoKcss.js +0 -4
  178. package/apps/web/dist/assets/NewWizardChannels-Ba3XGpro.js +0 -1
  179. package/apps/web/dist/assets/OnboardingPage-D_4ShWrL.js +0 -1
  180. package/apps/web/dist/assets/ProjectPage-C58rq50b.js +0 -1
  181. package/apps/web/dist/assets/PublicRunner-CE0ohzyd.js +0 -1
  182. package/apps/web/dist/assets/RunDrawer-Cd8-qHV7.js +0 -4
  183. package/apps/web/dist/assets/RunnerView-BW1h4x63.js +0 -1
  184. package/apps/web/dist/assets/SettingsPage-ChYLv-MG.js +0 -1
  185. package/apps/web/dist/assets/SetupPage-hX7deF0g.js +0 -1
  186. package/apps/web/dist/assets/changelog-Dn9LT4MS.js +0 -1
  187. package/apps/web/dist/assets/esm-C-ZWeuhU.js +0 -7
  188. package/apps/web/dist/assets/index-4jH2mkp7.js +0 -14
  189. package/apps/web/dist/assets/index-BwW652E-.css +0 -1
  190. package/apps/web/dist/assets/oss-credits-Bc05Qv5H.js +0 -1
  191. package/apps/web/dist/assets/settings-menu-Dpkp3f56.js +0 -1
  192. package/apps/web/dist/assets/ui-DMmT-cSO.js +0 -137
  193. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/assistant.d.ts +0 -0
  194. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/assistant.js +0 -0
  195. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/changes.d.ts +0 -0
  196. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/changes.js +0 -0
  197. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/claude-plugin.d.ts +0 -0
  198. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/claude-plugin.js +0 -0
  199. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/connectors.d.ts +0 -0
  200. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/connectors.js +0 -0
  201. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/decision.d.ts +0 -0
  202. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/decision.js +0 -0
  203. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns-format.d.ts +0 -0
  204. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns-format.js +0 -0
  205. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns-value.d.ts +0 -0
  206. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns-value.js +0 -0
  207. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns.d.ts +0 -0
  208. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/columns.js +0 -0
  209. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/index.d.ts +0 -0
  210. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/data-tables/index.js +0 -0
  211. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/search-index/catalog-lexical.d.ts +0 -0
  212. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/search-index/catalog-lexical.js +0 -0
  213. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/search-index/catalog-rank.d.ts +0 -0
  214. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/engenty/search-index/catalog-rank.js +0 -0
  215. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/feature-flags.d.ts +0 -0
  216. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/feature-flags.js +0 -0
  217. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/features.d.ts +0 -0
  218. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/features.js +0 -0
  219. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/fit.d.ts +0 -0
  220. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/fit.js +0 -0
  221. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/json-schema.d.ts +0 -0
  222. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/json-schema.js +0 -0
  223. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/knowledge.d.ts +0 -0
  224. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/knowledge.js +0 -0
  225. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace-entry.d.ts +0 -0
  226. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace-entry.js +0 -0
  227. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace-search.d.ts +0 -0
  228. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace-search.js +0 -0
  229. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace.d.ts +0 -0
  230. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/marketplace.js +0 -0
  231. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/merge.d.ts +0 -0
  232. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/merge.js +0 -0
  233. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/numbers.d.ts +0 -0
  234. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/numbers.js +0 -0
  235. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/projects.d.ts +0 -0
  236. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/projects.js +0 -0
  237. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/providers.d.ts +0 -0
  238. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/providers.js +0 -0
  239. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/runner-texts.d.ts +0 -0
  240. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/runner-texts.js +0 -0
  241. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/runners.d.ts +0 -0
  242. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/runners.js +0 -0
  243. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/shape.d.ts +0 -0
  244. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/shape.js +0 -0
  245. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/space-data.d.ts +0 -0
  246. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/space-data.js +0 -0
  247. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/store.js +0 -0
  248. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/surface.d.ts +0 -0
  249. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/surface.js +0 -0
  250. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/texts.d.ts +0 -0
  251. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/texts.js +0 -0
  252. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/translation.d.ts +0 -0
  253. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/translation.js +0 -0
  254. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/wizard-package.d.ts +0 -0
  255. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/wizard-package.js +0 -0
  256. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/workspace.d.ts +0 -0
  257. /package/node_modules/{@engenty-wizards/shared → @engenty/wizards-shared}/dist/workspace.js +0 -0
@@ -10,6 +10,7 @@ import { env } from "../env.js";
10
10
  import { costOf, textModel } from "../models.js";
11
11
  import { assertPublicUrl } from "./net-guard.js";
12
12
  import { attempt, imageOutput } from "./shared.js";
13
+ import { resolveFile } from "./store.js";
13
14
  /** The page as an agent step reads it; retried while the page is between two documents. */
14
15
  export async function readPage(page) {
15
16
  for (let attempt = 0; attempt < 5; attempt++) {
@@ -564,6 +565,53 @@ export async function browserTools(ctx, assets, files) {
564
565
  }),
565
566
  execute: ({ reason }) => acting(() => handOver({ reason, fields: [] })),
566
567
  });
568
+ tools.browser_upload = createTool({
569
+ id: "browser_upload",
570
+ description: 'Attach a file to the page: give the [number] of the file input, or of the button that opens the file picker ("Add photo", "Upload"). The file is one the person gave (`upload:<id>`), a result of this run (`result:<step>.<format>`) or a kept file\'s path.',
571
+ inputSchema: z.object({
572
+ ref: z.number().describe("[number] of the file input or the upload button."),
573
+ file: z.string().describe("upload:<id>, result:<step>.<format>, or a kept file's path."),
574
+ }),
575
+ execute: ({ ref: n, file }) => acting(async () => {
576
+ const p = await page();
577
+ const target = await atRef(p, n);
578
+ if ("error" in target) {
579
+ return target;
580
+ }
581
+ const el = await handleOf(p, n);
582
+ if (!el) {
583
+ return { error: targetError(n, { error: "gone" }), page: await read(p) };
584
+ }
585
+ const found = await resolveFile(ctx, file);
586
+ const payload = { name: found.name, mimeType: found.mime, buffer: Buffer.from(found.data) };
587
+ await ctx.emit("tool", { code: "attaches", params: { name: found.name } });
588
+ const isFileInput = await el
589
+ .evaluate((node) => node.type === "file")
590
+ .catch(() => false);
591
+ if (isFileInput) {
592
+ await el.setInputFiles(payload, { timeout: 15_000 });
593
+ }
594
+ else {
595
+ // The button opens the browser's file picker; a page that keeps its input hidden
596
+ // and opens no picker takes the file through that input.
597
+ const chooser = p.waitForEvent("filechooser", { timeout: 6000 }).catch(() => null);
598
+ await el.click({ timeout: 10_000 });
599
+ const opened = await chooser;
600
+ if (opened) {
601
+ await opened.setFiles(payload);
602
+ }
603
+ else {
604
+ const hidden = p.locator("input[type=file]").first();
605
+ if (!(await hidden.count())) {
606
+ return { error: "No file picker opened.", page: await read(p) };
607
+ }
608
+ await hidden.setInputFiles(payload, { timeout: 15_000 });
609
+ }
610
+ }
611
+ await settle(p);
612
+ return { attached: found.name, page: await read(ctx.resources.openPage() ?? p) };
613
+ }),
614
+ });
567
615
  tools.browser_download = createTool({
568
616
  id: "browser_download",
569
617
  description: "Download a file (an invoice PDF, an export) with the browser's sign-in and keep it: click the element with this [number], or fetch this URL. The file is stored under `path` in the wizard's files and added to this step's result.",
@@ -5,7 +5,7 @@ import { connectionContext } from "../connectors/index.js";
5
5
  import { inProgram } from "./code.js";
6
6
  import { attempt, clip } from "./shared.js";
7
7
  import { resolveFile } from "./store.js";
8
- const FILE_NOTE = " File content never passes through you: returned content is kept as a file and you get its path; to send a kept file, give `file:<path>` where an input asks for `*_base64`.";
8
+ const FILE_NOTE = " File content never passes through you: returned content is kept as a file and you get its path; to send a file, give `file:<path>` of a kept file or `file:result:<step>.<format>` of a result where an input asks for `*_base64`.";
9
9
  /** Above this many actions a connector is offered as "find an action, then call it". */
10
10
  const DIRECT_TOOLS = 24;
11
11
  const TOOL_NAME = /^[a-zA-Z0-9_-]{1,64}$/;
@@ -87,7 +87,8 @@ function asks(connection, action) {
87
87
  }
88
88
  return (connection.policy?.[action.id] ?? (action.group === "read" ? "allow" : "ask")) === "ask";
89
89
  }
90
- async function toolsOf(connection, ctx, files) {
90
+ /** One connection's actions as tools — for a step that lists it, or a share job that sends through it. */
91
+ export async function toolsOf(connection, ctx, files) {
91
92
  const projectId = ctx.project.id;
92
93
  const id = connection.connector ?? "";
93
94
  let resolved = await resolveConnector(projectId, id);
@@ -1,5 +1,5 @@
1
1
  import { anthropic } from "@ai-sdk/anthropic";
2
- import { isTextMime } from "@engenty-wizards/shared/workspace";
2
+ import { isTextMime } from "@engenty/wizards-shared/workspace";
3
3
  import { createTool } from "@mastra/core/tools";
4
4
  import { MCPClient } from "@mastra/mcp";
5
5
  import { z } from "zod";
@@ -1,5 +1,5 @@
1
- import { pluginToolOf } from "@engenty-wizards/shared/definition";
2
- import { note } from "@engenty-wizards/shared/run";
1
+ import { pluginToolOf } from "@engenty/wizards-shared/definition";
2
+ import { note } from "@engenty/wizards-shared/run";
3
3
  import { createTool } from "@mastra/core/tools";
4
4
  import { StepError } from "../engine/types.js";
5
5
  import { loadedPlugin, pluginIdsOf, pluginsOf } from "../plugins/registry.js";
@@ -1,4 +1,4 @@
1
- import { whereSchema } from "@engenty-wizards/shared/knowledge";
1
+ import { whereSchema } from "@engenty/wizards-shared/knowledge";
2
2
  import { createTool } from "@mastra/core/tools";
3
3
  import { and, eq } from "drizzle-orm";
4
4
  import { z } from "zod";
@@ -1,11 +1,12 @@
1
- import { allFields } from "@engenty-wizards/shared/definition";
2
- import { TableColumnValueError } from "@engenty-wizards/shared/engenty/data-tables";
1
+ import { allFields } from "@engenty/wizards-shared/definition";
2
+ import { TableColumnValueError } from "@engenty/wizards-shared/engenty/data-tables";
3
3
  import { createTool } from "@mastra/core/tools";
4
4
  import { eq } from "drizzle-orm";
5
5
  import { z } from "zod";
6
6
  import { db, schema } from "../db/client.js";
7
7
  import { parseDocument, scanDocument } from "../documents/parse.js";
8
8
  import { loadAsset } from "../files/storage.js";
9
+ import { parseResultRef, resultFile } from "../sharing/files.js";
9
10
  import { deleteRows, listRows, readStoreFile, saveRows, storeFiles } from "../store/index.js";
10
11
  import { attempt, clip } from "./shared.js";
11
12
  /** Files the person gave on earlier pages: `upload:<id>` is how tools address them. */
@@ -26,8 +27,24 @@ export async function personUploads(ctx) {
26
27
  }
27
28
  return out;
28
29
  }
29
- /** A file by the name agents use: `upload:<id>` (given by the person) or a path in the store. */
30
+ /**
31
+ * A file by the name agents use: `upload:<id>` (given by the person), `result:<step>.<format>`
32
+ * (an output of this run, rendered) or a path in the store.
33
+ */
30
34
  export async function resolveFile(ctx, file) {
35
+ const result = parseResultRef(file);
36
+ if (result) {
37
+ const found = await resultFile({ def: ctx.def, state: ctx.state, store: ctx.store }, result.from, result.format);
38
+ if (!found) {
39
+ throw new Error(`No result ${file}.`);
40
+ }
41
+ const { data, filename, mime } = found.download;
42
+ return {
43
+ data: typeof data === "string" ? new TextEncoder().encode(data) : data,
44
+ name: filename,
45
+ mime,
46
+ };
47
+ }
31
48
  if (file.startsWith("upload:")) {
32
49
  const found = await loadAsset(file.slice("upload:".length));
33
50
  if (!found || found.row.runId !== ctx.runId) {
@@ -1,5 +1,5 @@
1
1
  import { posix } from "node:path";
2
- import { isTextMime } from "@engenty-wizards/shared/workspace";
2
+ import { isTextMime } from "@engenty/wizards-shared/workspace";
3
3
  import { getBlob } from "../files/blobs.js";
4
4
  import { guardHtml } from "../render/guard.js";
5
5
  import { WIDGET_RUNTIME } from "./runtime.js";
@@ -1,6 +1,6 @@
1
- import { allFields, dataRef, widgetSize, } from "@engenty-wizards/shared/definition";
2
- import { runTheme } from "@engenty-wizards/shared/projects";
3
- import { note } from "@engenty-wizards/shared/run";
1
+ import { allFields, dataRef, widgetSize, } from "@engenty/wizards-shared/definition";
2
+ import { runTheme } from "@engenty/wizards-shared/projects";
3
+ import { note } from "@engenty/wizards-shared/run";
4
4
  import { resolveRef } from "../engine/template.js";
5
5
  import { StepError } from "../engine/types.js";
6
6
  import { extFor, inlineAssetRefs, loadAsset } from "../files/storage.js";
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Ft as r,Gt as i,Hn as a,Ht as o,It as s,Lt as c,Pt as l,en as u,pr as d,qt as f,yr as p}from"./ui-Cdv3QUOd.js";import{t as m}from"./preload-helper-CNEI7N0N.js";import{Ft as h,dt as g,ft as _,tt as v}from"./index-CQKA-z2z.js";import{c as y,f as b}from"./settings-menu-B1ND1GF3.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-BQRBkiVD.js";var T=e(t(),1),E=[{name:`engenty wizards`,description:`credit.engenty-wizards`,homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:`credit.engenty`,homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],D=[{name:`Mastra`,description:`credit.mastra`,homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:`credit.ai-sdk`,homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:`credit.model-context-protocol`,homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:`credit.hono`,homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:`credit.drizzle-orm`,homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:`credit.libsql`,homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:`credit.playwright`,homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`React`,description:`credit.react`,homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:`credit.vite`,homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:`credit.tailwind-css`,homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:`credit.react-flow`,homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:`credit.tanstack-query`,homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:`credit.xterm-js`,homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:`credit.lucide`,homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:`credit.geist-geist-mono`,homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:`credit.space-grotesk`,homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:`credit.git-cliff`,homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],O=e(n(),1),k=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function A({name:e,homepage:t,version:n,license:r,description:i}){return(0,O.jsxs)(`li`,{className:`py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,O.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.875rem] text-ink underline-offset-4 hover:underline`,children:[e,(0,O.jsx)(d,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,O.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),i?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):null]})}function j({title:e,hint:t,children:n}){return(0,O.jsxs)(`section`,{className:`mt-6`,children:[(0,O.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,O.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function M({credits:e}){return(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,O.jsx)(A,{name:e.name,homepage:e.homepage,license:e.license,description:u(e.description)},e.name))})}function N({label:e,packages:t}){return(0,O.jsxs)(`div`,{className:`mt-4`,children:[(0,O.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,O.jsx)(A,{...e},e.name))})]})}function P({active:e}){let[t,n]=(0,T.useState)(null),[i,a]=(0,T.useState)(``);(0,T.useEffect)(()=>{if(!e||t)return;let r=!1;return m(()=>import(`./oss-credits-BjwxLtU4.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,T.useEffect)(()=>{e||a(``)},[e]);let s=i.trim().toLowerCase(),l=e=>s?e.filter(e=>k(s,e.name,e.license,u(e.description))):e,d=e=>s?e.filter(e=>k(s,e.name,e.license,e.version)):e,f=l(E),p=l(D),h=t?[{id:`shared`,label:u(`about.creditsShared`),packages:d(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:d(e.packages)}))].filter(e=>e.packages.length>0):[],g=f.length===0&&p.length===0&&h.length===0;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:u(`about.creditsHint`)}),(0,O.jsx)(c,{type:`search`,value:i,placeholder:u(`about.search`),onChange:e=>a(e.target.value)}),f.length>0?(0,O.jsx)(j,{title:u(`about.creditsProduct`),children:(0,O.jsx)(M,{credits:f})}):null,p.length>0?(0,O.jsx)(j,{title:u(`about.creditsBuiltWith`),children:(0,O.jsx)(M,{credits:p})}):null,t===null?(0,O.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,O.jsx)(o,{})}):h.length>0?(0,O.jsx)(j,{title:u(`about.creditsDeps`),hint:s?void 0:u(`about.creditsDepsHint`),children:h.map(e=>(0,O.jsx)(N,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,O.jsx)(r,{children:u(`about.noMatches`)}):null]})}var F=[`new`,`earlier`,`credits`],I=e=>u(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),L=e=>e===1?u(`about.change`):u(`about.changes`,{n:e});function R({me:e,active:t,initialTab:n=`new`}){let r=e?.mode===`local`,{data:a,latest:s}=g(r&&t),[c,l]=(0,T.useState)(null),[d,m]=(0,T.useState)(n);(0,T.useEffect)(()=>m(n),[n]);let E=b(F.indexOf(d)),D=a?.newer&&s?s:_;(0,T.useEffect)(()=>{if(!t)return;let e=!1;return l(null),S(D===`0.9.0`?void 0:D).then(t=>{e||l(t)}),()=>{e=!0}},[t,D]);let k=c?.find(e=>e.version===`v${D}`)??c?.[0]??null,A=c?.filter(e=>e!==k)??[],j=r?a?.kind??null:`cloud`;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,O.jsx)(h,{size:96}),(0,O.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,O.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,O.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,O.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[u(`about.version`,{v:_}),j?` · ${u(`about.kind.${j}`)}`:``]})]}),r?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(v,{enabled:t})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(i,{value:d,onChange:m,options:F.map(e=>({id:e,label:I(e)})),label:u(`about.title`)})}),(0,O.jsxs)(`div`,{className:f(`mt-5`,y(E)),children:[d===`new`?c===null?(0,O.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,O.jsx)(o,{})}):k?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[w(k),(0,O.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:C(k)})]}),(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(x,{release:k})})]}):(0,O.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:u(`about.changelogEmpty`)}):null,d===`earlier`?(0,O.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:A.map(e=>(0,O.jsxs)(`details`,{className:`group/r py-2`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,O.jsx)(p,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,O.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:w(e)}),(0,O.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(e)}),(0,O.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:L(e.commits.length)})]}),(0,O.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,O.jsx)(x,{release:e})})]},e.version??`unreleased`))}):null,d===`credits`?(0,O.jsx)(P,{active:!0}):null]},d)]})}function z({open:e,onClose:t,me:n}){return(0,O.jsxs)(l,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,O.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,O.jsx)(s,{label:u(`common.close`),onClick:t,children:(0,O.jsx)(a,{className:`size-4`})})}),(0,O.jsx)(R,{me:n,active:e})]})}export{z as AboutDialog,R as AboutPanel};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Bt as r,Ht as i,Qt as a,an as o,qt as s,zt as c}from"./ui-DMmT-cSO.js";import{t as l}from"./preload-helper-CNEI7N0N.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):o(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await l(async()=>{let{default:e}=await import(`./changelog-Dn9LT4MS.js`);return{default:e}},[])).default}function v({release:e}){return(0,d.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:a(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:o(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[a,l]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||a)return;let t=!1;return _(n).then(e=>{t||l(e)}),()=>{t=!0}},[e,a,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=a?g(a,f):[];return(0,d.jsxs)(c,{open:e,onClose:t,title:o(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:o(`about.changelogHint`)}),a===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(s,{})}):a.length===0?(0,d.jsx)(r,{children:o(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i,{type:`search`,value:f,placeholder:o(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(r,{children:o(`about.noMatches`)}):null,y.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`div`,{className:`mt-3`,children:(0,d.jsx)(v,{release:e})})]},e.version??`unreleased`))]})]})}export{y as ChangelogDialog,v as ReleaseNotes,_ as loadReleases,m as releaseDate,p as releaseLabel};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Ft as r,Ht as i,Lt as a,Pt as o,en as s,qt as c}from"./ui-Cdv3QUOd.js";import{t as l}from"./preload-helper-CNEI7N0N.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):s(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await l(async()=>{let{default:e}=await import(`./changelog-BcW79fHm.js`);return{default:e}},[])).default}function v({release:e}){return(0,d.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:c(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:s(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[c,l]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||c)return;let t=!1;return _(n).then(e=>{t||l(e)}),()=>{t=!0}},[e,c,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=c?g(c,f):[];return(0,d.jsxs)(o,{open:e,onClose:t,title:s(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:s(`about.changelogHint`)}),c===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(i,{})}):c.length===0?(0,d.jsx)(r,{children:s(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(a,{type:`search`,value:f,placeholder:s(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(r,{children:s(`about.noMatches`)}):null,y.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`div`,{className:`mt-3`,children:(0,d.jsx)(v,{release:e})})]},e.version??`unreleased`))]})]})}export{y as ChangelogDialog,v as ReleaseNotes,_ as loadReleases,m as releaseDate,p as releaseLabel};
@@ -0,0 +1,10 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Fn as r,Ht as i,It as a,Jn as o,Jt as s,Kn as c,Kt as l,R as u,Sr as d,St as f,Tn as p,Tr as m,Un as h,Vn as g,Yt as _,Zn as v,bt as y,c as b,dn as x,en as S,ft as C,ht as w,ir as T,kr as E,lt as D,mt as O,nt as k,or as A,pt as j,q as M,qn as N,qt as P,rn as F,rt as I,st as L,tr as ee,tt as te,ut as R,xt as z,yt as B,zt as ne}from"./ui-Cdv3QUOd.js";import{t as re}from"./phone-DwAf8S3l.js";import{At as ie,Jt as ae,Lt as oe,Zt as se,ct as ce,lt as le,st as ue,t as de,vn as fe}from"./index-CQKA-z2z.js";import{n as pe}from"./RunnerView-DHUkvi_G.js";var me={name:`hand`,size:24,node:[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]};me.node;var he=E(me),ge={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};ge.node;var _e=E(ge),ve={name:`video-off`,size:24,node:[[`path`,{d:`M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196`,key:`w8jjjt`}],[`path`,{d:`M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2`,key:`1xawa7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};ve.node;var V=E(ve),ye={name:`volume-x`,size:24,node:[[`path`,{d:`M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z`,key:`1p7khw`}],[`path`,{d:`m16.5 14.5 5-5`,key:`cul3yw`}],[`path`,{d:`m16.5 9.5 5 5`,key:`1akey5`}]]};ye.node;var be=E(ye),xe=fe(),H=e(t(),1),U=e(n(),1),Se=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function Ce({since:e}){let[t,n]=(0,H.useState)(Date.now());if((0,H.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Math.max(0,Math.floor((t-e)/1e3)),i=String(Math.floor(r/60)).padStart(2,`0`),a=String(r%60).padStart(2,`0`);return(0,U.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function W({label:e,on:t,danger:n,busy:r,onClick:a,children:o}){return(0,U.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:a,className:P(`flex size-12 items-center justify-center rounded-full transition disabled:opacity-50`,n?`bg-rose text-white hover:brightness-110`:t===!1?`bg-white text-neutral-900 hover:bg-white/90`:`bg-white/15 text-white hover:bg-white/25`),children:r?(0,U.jsx)(i,{className:`size-5`}):o})}function we({voice:e}){let t=(0,H.useRef)(null),{captions:n}=e;return(0,H.useEffect)(()=>{n.length&&t.current?.scrollIntoView({block:`end`})},[n]),n.length?(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,U.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,U.jsx)(`li`,{className:P(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,U.jsx)(`div`,{ref:t})]})}):null}function Te({voice:e,view:t,video:n,className:r}){let a=e.state===`live`,o=e.state===`connecting`,[s,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(!1);(0,H.useEffect)(()=>{l(a?Date.now():null)},[a]);let f=async()=>{d(!1),await e.start(),n&&await e.startCamera()},p=()=>{e.stop(),d(!0)},m=n||e.camera,g=[...e.captions].reverse().find(e=>e.who===`bot`),_=[...e.captions].reverse().find(e=>e.who===`me`),v=e.speaking?S(`talk.speaking`):e.listening?S(`talk.listening`):a?S(`talk.live`):o?S(`talk.connecting`):u?S(`video.ended`):``;return(0,U.jsxs)(`section`,{className:P(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,r),children:[(0,U.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,U.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),v?(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[a?(0,U.jsx)(`span`,{className:P(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,v]}):null,(0,U.jsx)(Ce,{since:s})]}),(0,U.jsxs)(`div`,{className:P(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,m?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!m&&a&&e.captions.length?`h-[38%]`:m?``:`flex-1`),children:[(0,U.jsxs)(`div`,{className:P(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!m&&`hidden`),children:[(0,U.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:P(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,U.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,U.jsx)(V,{className:`size-8`}),(0,U.jsx)(`span`,{className:`text-[0.8125rem]`,children:S(`video.cameraOff`)})]}),(0,U.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[S(`video.you`),e.muted?(0,U.jsx)(se,{className:`ml-1.5 inline size-3`}):null]})]}),(0,U.jsxs)(`div`,{className:P(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,m?`bg-neutral-900`:`bg-transparent`,m&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,U.jsx)(`div`,{className:P(`rounded-full transition-shadow duration-500`,!m&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!m&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,U.jsx)(ie,{kind:t?.wizard.avatar??`round`,size:m?140:200,fluffy:!0,interactive:!1})}),m?(0,U.jsx)(`span`,{className:`absolute bottom-2 left-3 max-w-[85%] truncate rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:t?.wizard.title??``}):null]})]}),a&&!m?(0,U.jsx)(we,{voice:e}):a&&(g||_)?(0,U.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[_?(0,U.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:_.text}):null,g?(0,U.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:g.text}):null]})}):null,e.error?(0,U.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,U.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:a?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(W,{label:S(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,U.jsx)(se,{className:`size-5`}):(0,U.jsx)(A,{className:`size-5`})}),(0,U.jsx)(W,{label:S(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,U.jsx)(h,{className:`size-5`}):(0,U.jsx)(V,{className:`size-5`})}),e.camera&&Se?(0,U.jsx)(W,{label:S(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,U.jsx)(c,{className:`size-5`})}):null,(0,U.jsx)(W,{label:S(`video.leave`),danger:!0,onClick:p,children:(0,U.jsx)(ae,{className:`size-5`})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:o||!t?.talk,onClick:()=>void f(),className:`flex h-12 items-center gap-2 rounded-full bg-emerald-500 px-6 font-medium text-[0.9375rem] text-white transition hover:brightness-110 disabled:opacity-50`,children:[o?(0,U.jsx)(i,{className:`size-4`}):n?(0,U.jsx)(h,{className:`size-5`}):(0,U.jsx)(A,{className:`size-5`}),S(u?`video.rejoin`:n?`video.join`:`talk.start`)]}),!u&&!e.error?(0,U.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:S(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Ee=e=>x[e.kind]!==`device`,De=1024,Oe=4e3;function ke(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function Ae(e,t,n=!1){let r=[`status: ${e.status}`,`camera: ${n?`on`:`off`}`];if(e.ask)return r.push(e.ask.kind===`confirm`?`question: the step wants to "${e.ask.action.summary}" in ${e.ask.service}; answer_ask allows or skips it`:`question: a sign-in at ${e.ask.site.host}; the person types it on the screen, wait`),r.join(`
2
+ `);if(e.status===`running`){let t=[...e.events].reverse().find(e=>e.type===`tool`||e.type===`info`||e.type===`step_started`);return r.push(`working on: ${e.step?.title??``}`),t&&r.push(`doing: ${s(t)}`),r.join(`
3
+ `)}if(e.status===`done`){r.push(`done. made:`);for(let{step:t,output:n}of e.shown)r.push(`- ${t.title}: ${ke(n?.text,400)||`(a file, on the screen)`}`);return r.join(`
4
+ `)}if(e.status===`failed`)return r.push(`failed: ${e.error??``}; go_back or the person retries on the screen`),r.join(`
5
+ `);if(t){r.push(`page: ${t.step.title}`);for(let e of t.fields){let n=t.values[e.id],i=n!=null&&n!==``,a=Ee(e)?`by voice`:e.kind===`image`?`with the camera (take_photo) or on the screen`:`on the screen only`,o=e.options?.length?`; options: ${e.options.join(` | `)}`:``;r.push(`- field ${e.id} (${e.kind}${e.required?`, required`:``}, ${a}): ${e.label}${e.help?` – ${e.help}`:``}${o}${i?` = ${ke(String(Array.isArray(n)?n.join(`, `):n),120)}`:` = (open)`}`)}return r.join(`
6
+ `)}if(e.step?.type===`review`){r.push(`review: ${e.step.title}`);for(let{step:t,output:n}of e.shown)r.push(`- ${t.id} "${t.title}": ${ke(n?.text,600)||`(a picture or file, on the screen)`}`);return r.push(`regenerate allowed: ${e.step.regenerate?`yes`:`no`}`),r.join(`
7
+ `)}return r.push(`step: ${e.step?.title??``}`),r.join(`
8
+ `)}function je(e,t,n,r){let[i,a]=(0,H.useState)(`off`),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(`environment`),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)([]),x=(0,H.useRef)(null),C=(0,H.useRef)(null),w=(0,H.useRef)(0),T=(0,H.useRef)(!1);T.current=p;let E=(0,H.useRef)(null),D=(0,H.useRef)(null),O=(0,H.useRef)(null),k=(0,H.useRef)(null),A=(0,H.useRef)(t);A.current=t;let j=(0,H.useRef)(r);j.current=r;let M=(0,H.useRef)(n);M.current=n;let N=(0,H.useRef)(``),P=(0,H.useCallback)(e=>{let t=D.current;t&&t.readyState===`open`&&t.send(JSON.stringify(e))},[]),F=(0,H.useCallback)(()=>{let e=x.current;if(!T.current||!e||e.videoWidth===0)return null;let t=Math.min(1,De/e.videoWidth),n=document.createElement(`canvas`);return n.width=Math.round(e.videoWidth*t),n.height=Math.round(e.videoHeight*t),n.getContext(`2d`)?.drawImage(e,0,0,n.width,n.height),n.toDataURL(`image/jpeg`,.75)},[]),I=(0,H.useCallback)(()=>{for(let e of C.current?.getTracks()??[])e.stop();C.current=null,x.current&&(x.current.srcObject=null),m(!1)},[]),L=(0,H.useCallback)(async e=>{if(C.current)return;let t=e??`environment`;try{let e=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:t},width:{ideal:1280}},audio:!1});C.current=e;let n=e.getVideoTracks()[0]?.getSettings().facingMode;g(n===`user`||n===`environment`?n:t),x.current&&(x.current.srcObject=e,await x.current.play().catch(()=>void 0)),m(!0)}catch(e){s(e.name===`NotAllowedError`?S(`talk.cameraDenied`):e.message)}},[]),ee=(0,H.useCallback)(async()=>{let e=h===`user`?`environment`:`user`;I(),await L(e)},[h,I,L]),te=(0,H.useCallback)(()=>{v(e=>{for(let t of k.current?.getAudioTracks()??[])t.enabled=e;return!e})},[]),R=(0,H.useCallback)(()=>{I(),D.current?.close(),D.current=null,E.current?.close(),E.current=null;for(let e of k.current?.getTracks()??[])e.stop();k.current=null,O.current&&=(O.current.srcObject=null,O.current.remove(),null),N.current=``,l(!1),f(!1),v(!1),a(`off`)},[I]);(0,H.useEffect)(()=>()=>R(),[R]);let z=(0,H.useCallback)(async(t,n)=>{let r=A.current,i=j.current,a=M.current;switch(t){case`get_state`:return r?Ae(r,i,T.current):`no run`;case`look`:{let e=F();return e?(P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows right now`},{type:`input_image`,image_url:e}]}}),`a picture arrived as the next message`):`the camera is off; ask the person to switch it on`}case`take_photo`:{if(!i)return`no page is open`;let t=i.fields.find(e=>e.id===String(n.field??``));if(t?.kind!==`image`)return`no such photo field on this page`;let r=F();if(!r)return`the camera is off; ask the person to switch it on`;try{let n=await(await fetch(r)).blob(),a=new File([n],`photo-${Date.now()}.jpg`,{type:`image/jpeg`}),o=await u.upload(`/api/runs/${e}/uploads`,a),s=i.values[t.id],c=t.multiple?[...Array.isArray(s)?s:s?[s]:[],o.id]:o.id,l=i.setField(t.id,c);return l?`refused: ${l}`:`the photo is in the field`}catch(e){return`failed: ${e.message}`}}case`set_field`:{if(!i)return`no page is open`;let e=i.setField(String(n.field??``),n.value);return e?`refused: ${e}`:`kept`}case`submit_page`:{if(!i)return`no page is open`;let e=i.fields.filter(e=>e.required&&Ee(e)&&e.kind!==`toggle`&&(i.values[e.id]===void 0||i.values[e.id]===null||i.values[e.id]===``));return e.length?`still open: ${e.map(e=>e.id).join(`, `)}`:(i.submit(),`sent; wait for the next state`)}case`accept_review`:return r?.step?.type===`review`?await a.accept(r.step.id)?`accepted`:a.error??`refused`:`no review is open`;case`regenerate`:return r?.step?.type===`review`?await a.regenerate(r.step.id,String(n.target??``),String(n.note??``))?`the wizard makes it again; wait`:a.error??`refused`:`no review is open`;case`answer_ask`:if(!r?.ask)return`no question is open`;try{return await u.post(`/api/runs/${e}/ask/${r.ask.id}`,{type:n.allow?`done`:`skip`}),n.allow?`allowed`:`skipped`}catch(e){return`refused: ${e.message}`}case`go_back`:return await a.back()?`went back; wait for the state`:a.error??`refused`;default:return`unknown tool ${t}`}},[e,F,P]),B=(0,H.useCallback)(async()=>{if(!E.current){s(null),b([]),a(`connecting`);try{let t=await u.post(`/api/runs/${e}/talk`),n=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});k.current=n;let r=new RTCPeerConnection;E.current=r;let i=document.createElement(`audio`);i.autoplay=!0,i.setAttribute(`playsinline`,``),document.body.append(i),O.current=i,r.ontrack=e=>{i.srcObject=e.streams[0]};for(let e of n.getTracks())r.addTrack(e,n);let o=r.createDataChannel(`oai-events`);D.current=o,o.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case`output_audio_buffer.started`:l(!0);break;case`output_audio_buffer.stopped`:case`output_audio_buffer.cleared`:l(!1);break;case`input_audio_buffer.speech_started`:{f(!0);let e=Date.now()-w.current>Oe?F():null;e&&(w.current=Date.now(),P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows while speaking`},{type:`input_image`,image_url:e}]}}));break}case`input_audio_buffer.speech_stopped`:f(!1);break;case`response.output_audio_transcript.done`:case`conversation.item.input_audio_transcription.completed`:{let e=String(t.transcript??``).trim();if(e){let n=t.type===`response.output_audio_transcript.done`?`bot`:`me`;b(t=>[...t.slice(-199),{id:`${Date.now()}:${n}`,who:n,text:e}])}break}case`response.function_call_arguments.done`:{let e=String(t.name??``),n=String(t.call_id??``),r={};try{r=JSON.parse(String(t.arguments??`{}`))}catch{}z(e,r).then(e=>{P({type:`conversation.item.create`,item:{type:`function_call_output`,call_id:n,output:e}}),P({type:`response.create`})});break}case`error`:s(String(t.error?.message??`error`))}},o.onopen=()=>{a(`live`);let e=A.current;e&&(N.current=Ae(e,j.current,T.current),P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${N.current}\n\nGreet the person in one sentence and ask the first open field.`}]}}),P({type:`response.create`}))},o.onclose=()=>{E.current===r&&R()};let c=await r.createOffer();await r.setLocalDescription(c);let d=await fetch(t.endpoint,{method:`POST`,headers:{authorization:`Bearer ${t.clientSecret}`,"content-type":`application/sdp`},body:c.sdp});if(!d.ok)throw Error(`${S(`talk.failed`)} (${d.status})`);await r.setRemoteDescription({type:`answer`,sdp:await d.text()})}catch(e){R(),s(e.name===`NotAllowedError`?S(`chat.micDenied`):e.message),a(`error`)}}},[e,z,F,P,R]);return(0,H.useEffect)(()=>{if(i!==`live`||!t)return;let e=Ae(t,r,p);if(e===N.current)return;let n=N.current;N.current=e,P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${e}`}]}}),(t.status===`running`&&n.startsWith(`status: running`)&&!n.includes(`working on: `)||t.status!==`running`||n.split(`
9
+ `)[1]!==e.split(`
10
+ `)[1])&&P({type:`response.create`})},[i,t,r,p,P]),{state:i,error:o,speaking:c,listening:d,start:B,stop:R,camera:p,facing:h,startCamera:L,stopCamera:I,flipCamera:ee,muted:_,toggleMute:te,captions:y,video:x}}var G=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),K=(e,t,n)=>({key:e,who:`me`,node:t,...n}),Me=(0,H.createContext)(null),q=(0,H.createContext)(null);function Ne(){return(0,H.useContext)(q)?.voice??null}function Pe({children:e}){let t=(0,H.useContext)(Me);return t?(0,xe.createPortal)(e,t):null}function Fe({header:e,footer:t,children:n}){let[r,i]=(0,H.useState)(null),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(!0);return(0,H.useLayoutEffect)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=e.scrollTop,r=()=>{e.scrollHeight-e.scrollTop-e.clientHeight<120?s.current=!0:e.scrollTop<n&&(s.current=!1),n=e.scrollTop},i=null,c=new ResizeObserver(()=>{let r=t.querySelector(`[data-anchor]`);r&&r!==i?(i=r,e.scrollTop+=r.getBoundingClientRect().top-e.getBoundingClientRect().top-12,s.current=!1,n=e.scrollTop):s.current&&(e.scrollTop=e.scrollHeight)});return e.scrollTop=e.scrollHeight,e.addEventListener(`scroll`,r,{passive:!0}),c.observe(t),c.observe(e),()=>{c.disconnect(),e.removeEventListener(`scroll`,r)}},[]),(0,U.jsx)(Me.Provider,{value:r,children:(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,U.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,U.jsx)(`div`,{ref:o,className:`mx-auto flex w-full max-w-[760px] flex-col gap-3 px-3 pt-5 pb-4 sm:px-6`,children:n})}),(0,U.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,U.jsx)(`div`,{ref:i,className:`mx-auto w-full max-w-[760px] px-3 pt-3 sm:px-6`}),t]})]})})}function J({avatar:e,lines:t}){let n=(0,H.useContext)(q),r=(0,H.useMemo)(()=>t.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[t]),i=(0,H.useCallback)(e=>{let t=document.querySelector(`[data-say="${CSS.escape(e)}"]`);return t?.querySelector(`[data-say-text]`)?.getAttribute(`data-say-text`)??t?.innerText??null},[]);le(!!n?.readAloud,n?.lang??_,r,i);let a=[];for(let e of t){let t=a.at(-1);t&&t.who===`bot`&&e.who===`bot`?t.lines.push(e):a.push({who:e.who,lines:[e]})}return a.map((t,n)=>t.who===`bot`?(0,U.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,U.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,U.jsx)(ie,{kind:e,size:30,interactive:n>=a.length-2})}),(0,U.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:t.lines.map(e=>(0,U.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:P(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?P(`w-full bg-card p-4 shadow-soft ring-1 ring-border-soft`,e.wide===`most`&&`md:w-4/5`):`max-w-[min(36rem,100%)] bg-card px-4 py-2.5 shadow-soft ring-1 ring-border-soft`),e.tone===`error`&&`bg-rose-tint text-rose shadow-none ring-0`),children:e.node},e.key))})]},t.lines[0].key):t.lines.map(e=>(0,U.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,U.jsx)(`div`,{className:`max-w-[min(32rem,100%)] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-primary px-4 py-2.5 text-[0.9375rem] text-primary-foreground leading-relaxed`,children:e.node}),e.onEdit?(0,U.jsxs)(`button`,{type:`button`,onClick:e.onEdit,className:`inline-flex items-center gap-1 px-1 text-[0.75rem] text-ink-4 transition hover:text-ink-2 coarse:min-h-9`,children:[(0,U.jsx)(ee,{className:`size-3`}),` `,S(`chat.change`)]}):null]},e.key)))}function Ie(){return(0,U.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":S(`run.working`),children:[0,1,2].map(e=>(0,U.jsx)(`span`,{className:`size-1.5 animate-typing rounded-full bg-ink-3`,style:{animationDelay:`${e*160}ms`}},e))})}function Y({children:e}){return(0,U.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var X=(e,t)=>G(e,(0,U.jsx)(Y,{children:t}),{bare:!0});function Z({onClick:e,children:t,primary:n,on:r,disabled:a,busy:o}){return(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:a||o,onClick:e,className:P(`inline-flex h-10 items-center gap-1.5 rounded-full px-4 font-medium text-[0.875rem] transition active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 coarse:h-11`,n?`bg-primary text-primary-foreground hover:brightness-[1.06]`:r?`bg-ember-tint text-ink ring-1 ring-ember`:`bg-card text-ink-2 ring-1 ring-input hover:text-ink hover:ring-ink-4`),children:[o?(0,U.jsx)(i,{className:`size-4`}):null,t]})}function Le({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:o,disabled:s,inputRef:c,onSend:u}){let[d,f]=(0,H.useState)(e),p=(0,H.useRef)(null),g=c??p,_=(0,H.useContext)(q),v=b(d,f,{endpoint:_?`/api/runs/${_.runId}/transcribe`:void 0}),y=!!_&&v.supported&&!s;(0,H.useEffect)(()=>{if(!y)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),v.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y,v.toggle]),(0,H.useEffect)(()=>{!B&&!s&&g.current?.focus()},[s,g]);let x=()=>{o||s||(v.listening&&v.toggle(),u(d)!==!1&&f(``))},C=v.listening?S(`chat.listening`):v.processing?S(`chat.transcribing`):t,w=_?.voice??null,T=!!_?.call,E=_&&!T&&(ue||y||w)?(0,U.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[w?(0,U.jsx)(a,{label:S(w.state===`live`?`talk.stop`:w.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":w.state===`live`,disabled:w.state===`connecting`,onClick:()=>w.state===`live`?w.stop():void w.start(),className:P(`size-9`,w.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,w.state===`off`&&_.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:w.state===`connecting`?(0,U.jsx)(i,{className:`size-4`}):w.state===`live`?(0,U.jsx)(ae,{className:`size-4`}):(0,U.jsx)(re,{className:`size-4`})}):null,w?.state===`live`?(0,U.jsx)(a,{label:S(w.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":w.camera,onClick:()=>w.camera?w.stopCamera():void w.startCamera(),className:P(`size-9`,w.camera&&`text-ink`),children:w.camera?(0,U.jsx)(h,{className:`size-4`}):(0,U.jsx)(V,{className:`size-4`})}):null,ue?(0,U.jsx)(a,{label:S(_.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":_.readAloud,onClick:()=>_.setReadAloud(!_.readAloud),className:P(`size-9`,_.readAloud&&`text-ink`),children:_.readAloud?(0,U.jsx)(oe,{className:`size-4`}):(0,U.jsx)(be,{className:`size-4`})}):null,y?(0,U.jsx)(a,{label:S(v.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":v.listening,disabled:v.processing,onClick:v.toggle,className:P(`size-9`,v.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:v.processing?(0,U.jsx)(i,{className:`size-4`}):v.listening?(0,U.jsx)(N,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,U.jsx)(A,{className:`size-4`})}):null]}):null;return(0,U.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),x()},children:[w&&!T?(0,U.jsx)(`video`,{ref:w.video,muted:!0,playsInline:!0,autoPlay:!0,className:P(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,w.camera?`block`:`hidden`)}):null,(0,U.jsxs)(`div`,{className:P(`flex items-end gap-1 rounded-[1.375rem] border border-input bg-card pr-1.5 pl-1 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,s&&`opacity-60`),children:[E,n?(0,U.jsx)(l,{ref:g,minRows:1,maxRows:6,value:d,disabled:s,placeholder:C,autoCapitalize:`sentences`,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!B&&!e.nativeEvent.isComposing&&(e.preventDefault(),x())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,U.jsx)(`input`,{ref:g,...r,value:d,disabled:s,placeholder:C,enterKeyHint:`send`,onChange:e=>f(e.target.value),className:`h-11 min-w-0 flex-1 bg-transparent px-3 text-[0.9375rem] text-ink outline-none placeholder:text-ink-4`}),(0,U.jsx)(`button`,{type:`submit`,"aria-label":S(`chat.send`),title:S(`chat.send`),disabled:o||s,className:`mb-1 flex size-9 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground transition hover:brightness-[1.06] disabled:opacity-40`,children:o?(0,U.jsx)(i,{className:`size-4`}):(0,U.jsx)(m,{className:`size-4`})})]}),v.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:v.error===`denied`?S(`chat.micDenied`):v.error}):T?null:w?.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:w.error}):w?.state===`live`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:w.speaking?S(`talk.speaking`):w.listening?S(`talk.listening`):S(`talk.live`)}):_?.talk&&w?.state===`off`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:S(`talk.hint`)}):null]})}function Q({placeholder:e=S(`chat.above`)}){return(0,U.jsx)(Pe,{children:(0,U.jsx)(Le,{disabled:!0,placeholder:e,onSend:()=>!1})})}function Re(e){let t=x[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var ze=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function Be(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(ze(t))return e.required&&!n?S(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return S(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return S(`chat.badUrl`)}return e.kind===`number`&&g(r)===null?S(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?S(`run.filesMin`,{n:t.length,min:e.min}):null}function Ve(e,t){let n=e.kind===`textarea`?t.replace(/\s+$/,``):t.trim();if(n)return e.kind===`url`&&!/^[a-z][a-z0-9+.-]*:/i.test(n)?`https://${n}`:n}function He({field:e}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,U.jsx)(`span`,{className:`mt-0.5 block text-[0.8125rem] text-ink-3`,children:e.help}):null]})}function Ue({step:e,only:t}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,U.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,U.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-ink-3`,children:t.help}):null]})}function We({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,U.jsx)(U.Fragment,{children:typeof t==`string`&&t?t:S(`chat.connected`)});if(e.kind===`list`)return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(d,{className:`size-4`}),` `,S(`chat.checked`)]});if(e.kind===`toggle`)return(0,U.jsx)(U.Fragment,{children:S(t===!0?`run.yes`:`run.no`)});if(ze(t))return(0,U.jsx)(`span`,{className:`italic opacity-80`,children:S(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,U.jsx)(U.Fragment,{children:t.map(F).join(`, `)});case`select`:return(0,U.jsx)(U.Fragment,{children:F(String(t))});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,U.jsx)(U.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(_,{dateStyle:`long`}).format(e)})}case`color`:return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,U.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,U.jsx)(`img`,{src:M(`/api/runs/${n}/assets/${t}`),alt:``,className:P(`h-16 rounded-lg bg-white`,e.kind===`image`?`w-16 object-cover`:`object-contain px-1`)},t))});case`file`:{let e=Array.isArray(t)?t.length:1;return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(T,{className:`size-4`}),` `,S(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(A,{className:`size-4`}),` `,S(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,U.jsx)(U.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,U.jsx)(U.Fragment,{children:S(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,U.jsx)(U.Fragment,{children:String(t)})}}function Ge(e,t,n,r,i,a){let o=[G(t,(0,U.jsx)(Ue,{step:e,only:a}))];for(let e of i)a||o.push(G(`${t}:${e.id}`,(0,U.jsx)(He,{field:e}))),o.push(K(`${t}:${e.id}:a`,(0,U.jsx)(We,{field:e,value:n[e.id],runId:r})));return o}var Ke=(e,t)=>e.fields.filter(e=>!e.when&&!p(e)||t[e.id]!==void 0&&t[e.id]!==null);function qe(e,t){let n=[];e.wizard.description&&n.push(G(`hello`,e.wizard.description)),e.wizard.intro&&n.push(G(`intro`,e.wizard.intro));for(let[t,r]of e.answered.entries()){let i=`${t}:${r.id}`;if(r.type===`page`){let t=r.fields.length===1?r.fields[0]:void 0;n.push(...Ge(r,i,e.values,e.id,Ke(r,e.values),t))}else r.type===`review`&&(n.push(G(i,(0,U.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(K(`${i}:a`,S(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function Je(e,t){return e.fields.filter(e=>!p(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function Ye({view:e,run:t,step:n,before:i}){let a=(0,H.useMemo)(()=>Je(n,e),[n,e]),o=e.known??{},[s,c]=(0,H.useState)(()=>te(n,e)),[l,u]=(0,H.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?r(Je(n,e),e.known??{},te(n,e)).slice(0,-1).map(e=>e.id):[]),[d,f]=(0,H.useState)({}),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(!1),_=r(a,o,s),v=_.filter(e=>l.includes(e.id)),y=_.find(e=>!l.includes(e.id)),b=a.length===1?a[0]:void 0,x=v.at(-1),C=x?()=>u(e=>e.filter(e=>e!==x.id)):void 0;(0,H.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=r(a,o,s),i=n.findIndex(t=>e.includes(t.id));i>=0&&(u(n.slice(0,i).map(e=>e.id)),f(t.fieldErrors))},[t.fieldErrors]);let w=e=>{t.submitPage(n.id,e).then(g)},T=(0,H.useContext)(q),E=(0,H.useRef)(s);E.current=s;let O=T?.bindPage,k=(0,H.useRef)(w);k.current=w,(0,H.useEffect)(()=>{if(!O)return;let e=r(a,o,s);return O({step:n,fields:e,values:s,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?Be(r,n)||(c(e=>({...e,[t]:n})),u(e=>e.includes(t)?e:[...e,t]),f({}),null):`no such field on this page`},submit:()=>k.current(E.current)}),()=>O(null)},[O,n,a,o,s]);let A=e=>{if(!y)return!1;let t=Be(y,e);if(t)return f({[y.id]:t}),!1;let n={...s,[y.id]:e},i=[...l,y.id];return c(n),u(i),f({}),r(a,o,n).some(e=>!i.includes(e.id))||w(n),!0},j=[...i.map(e=>l.length?{...e,onEdit:void 0}:e),...Ge(n,`now:${n.id}`,s,e.id,v,b).map((e,t,n)=>t===n.length-1&&e.who===`me`&&y?{...e,onEdit:C}:e)];y?(Re(y)===`control`?j.push(G(`now:${n.id}:${y.id}:control`,(0,U.jsx)(D,{field:y,value:s[y.id],values:s,runId:e.id,view:e,closed:e.closed?.[y.id],onChange:e=>c(t=>({...t,[y.id]:e})),onBusy:m}),{wide:!0})):b||j.push(G(`now:${n.id}:${y.id}`,(0,U.jsx)(He,{field:y}))),d[y.id]&&j.push(G(`now:${n.id}:${y.id}:error`,d[y.id],{tone:`error`}))):t.busy||h?j.push(G(`sending`,(0,U.jsx)(Ie,{}))):t.error&&j.push(G(`send-error`,t.error,{tone:`error`}));let M=(0,U.jsx)(Q,{});if(h||!y&&l.length>0&&t.busy)M=(0,U.jsx)(Q,{placeholder:S(`run.working`)});else if(!y)j.push(X(`now:${n.id}:go`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Z,{primary:!0,busy:t.busy,onClick:()=>w(s),children:n.cta||S(`run.next`)}),C?(0,U.jsx)(Z,{onClick:C,disabled:t.busy,children:S(`run.back`)}):null]})));else{let r=Re(y),i=!y.required&&y.kind!==`connection`&&y.kind!==`list`?(0,U.jsx)(Z,{onClick:()=>A(void 0),children:S(`chat.skip`)}):null;if(r===`typed`){i&&j.push(X(`now:${n.id}:${y.id}:replies`,i));let e=s[y.id];M=(0,U.jsx)(Pe,{children:(0,U.jsx)(Le,{initial:ze(e)?``:String(e),multiline:y.kind===`textarea`,placeholder:y.placeholder||(b?y.label:S(`chat.placeholder`)),inputProps:Xe(y),busy:t.busy,onSend:e=>A(Ve(y,e))},y.id)})}else if(r===`tapped`)j.push(G(`now:${n.id}:${y.id}:replies`,(0,U.jsx)(Ze,{field:y,view:e,value:s[y.id],onAnswer:A}),{bare:!0}));else{let e=_.filter(e=>!l.includes(e.id)).length===1;j.push(X(`now:${n.id}:${y.id}:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Z,{primary:!0,disabled:p,onClick:()=>A(s[y.id]),children:e&&n.cta?n.cta:S(`chat.send`)}),i]})))}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:e.wizard.avatar,lines:j}),M]})}function Xe(e){switch(e.kind){case`number`:return{inputMode:`decimal`,autoComplete:`off`};case`email`:return{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`url`:return{inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`date`:return{type:`date`};default:return R(e)}}function Ze({field:e,view:t,value:n,onAnswer:r}){let i=new Set(t.closed?.[e.id]?.values.map(String)),[a,o]=(0,H.useState)(Array.isArray(n)?n:[]);if(e.kind===`toggle`)return(0,U.jsxs)(Y,{children:[(0,U.jsx)(Z,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:S(`run.no`)}),(0,U.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:S(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,U.jsxs)(Y,{children:[s.map(e=>(0,U.jsx)(Z,{on:a.includes(e),onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):s.filter(n=>n===e||t.includes(n))),children:F(e)},e)),(0,U.jsx)(Z,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?S(`chat.send`):S(`chat.skip`)})]}):(0,U.jsxs)(Y,{children:[s.map(e=>(0,U.jsx)(Z,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:F(e)},e)),e.required?null:(0,U.jsx)(Z,{onClick:()=>r(void 0),children:S(`chat.skip`)})]})}function Qe({view:e}){let t=(0,H.useMemo)(()=>[...e.events].reverse().find(t=>t.type===`step_started`&&t.stepId===e.step?.id),[e.events,e.step?.id]),n=t?new Date(t.at).getTime():Date.now(),[r,i]=(0,H.useState)(Date.now());(0,H.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]);let a=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),c=a.at(-1),l=[...a].reverse().find(et),u=[...new Set(a.map(e=>e.asset).filter(e=>!!e))];return(0,U.jsxs)(`div`,{className:P(`flex max-w-full flex-col gap-1`,l?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??S(`run.working`),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(Ie,{}),(0,U.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??S(`run.working`)}),(0,U.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:S(`run.elapsed`,{s:Math.max(0,Math.round((r-n)/1e3))})})]}),c&&c!==l?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,U.jsx)(o,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,U.jsx)(`span`,{className:`truncate`,children:s(c)})]}):null,l&&e.status===`running`?(0,U.jsx)(nt,{runId:e.id,event:l}):null,u.length?(0,U.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:u.slice(-6).map(t=>(0,U.jsx)(`img`,{src:M(`/api/runs/${e.id}/assets/${t}`),alt:``,className:`size-14 rounded-lg bg-paper-2 object-cover ring-1 ring-border-soft`},t))}):null]})}var $e=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function et(e){return!!e.note&&$e.has(e.note.code)}var tt=1e4;function nt({runId:e,event:t}){let[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(`agent`),[o,c]=(0,H.useState)(!1),l=t.note?.code;if((0,H.useEffect)(()=>{l===`personDrives`?a(`person`):l===`agentDrives`&&a(`agent`)},[l]),(0,H.useEffect)(()=>{let t=()=>u.get(`/api/runs/${e}/browser/seat`).then(e=>a(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,tt);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let d=i===`person`,p=async()=>{c(!0);try{let t=await u.post(`/api/runs/${e}/browser/seat`,{to:d?`agent`:`person`});a(t.seat)}catch{}finally{c(!1)}};return(0,U.jsx)(f,{runId:e,driving:d,caption:s(t),hint:S(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,U.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>void p(),className:P(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,d?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-card/90 text-ink ring-1 ring-border-soft backdrop-blur hover:bg-card`),children:[d?(0,U.jsx)(_e,{className:`size-3.5`}):(0,U.jsx)(he,{className:`size-3.5`}),S(d?`browser.handBack`:`browser.takeOver`)]})},n??0)}function $({children:e,end:t}){return(0,U.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function rt({view:e,run:t,step:n,before:r,asked:i,onNote:a}){let o=e.shown.filter(e=>e.output),[s,c]=(0,H.useState)(o.length===1?o[0].step.id:null),l=(0,H.useRef)(null),u=[...r,...i.map((e,t)=>K(`review:${n.id}:asked:${t}`,e)),G(`review:${n.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,U.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.description}):null]}),{anchor:!0}),...o.map(({step:t,output:r})=>G(`review:${n.id}:${t.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($,{children:t.title}),(0,U.jsx)(L,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{c(t.id),l.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>G(`review:${n.id}:list:${t.def.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($,{children:t.def.title}),t.def.check?(0,U.jsx)(C,{runId:e.id,list:t}):(0,U.jsx)(O,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&u.push(G(`review-error`,t.error,{tone:`error`}));let f=n.regenerate&&o.length>0;return u.push(X(`review:${n.id}:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,U.jsx)(d,{className:`size-4`}),` `,S(`run.accept`)]}),f&&o.length>1?o.map(({step:e})=>(0,U.jsx)(Z,{on:s===e.id,onClick:()=>c(e.id),children:e.title},e.id)):null]}))),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:e.wizard.avatar,lines:u}),f?(0,U.jsx)(Pe,{children:(0,U.jsx)(Le,{multiline:!0,inputRef:l,busy:t.busy,placeholder:o.length>1&&!s?S(`run.feedbackPick`):S(`run.feedbackPlaceholder`),disabled:!s,onSend:e=>{let r=e.trim();return!r||!s?!1:(a(r),t.regenerate(n.id,s,r),!0)}})}):(0,U.jsx)(Q,{})]})}function it({view:e,run:t,step:n,before:r,onRestart:i}){let a=e.shown.filter(e=>e.output),o=`/api/runs/${e.id}`,s=[...r,G(`result:${n.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,U.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:n.message}):null]}),{anchor:!0}),...a.map(({step:e,output:t,formats:n,label:r})=>G(`result:${e.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($,{end:(0,U.jsx)(I,{base:o,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,U.jsx)(L,{base:o,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,U.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:S(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>G(`result:list:${t.def.id}`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)($,{end:(0,U.jsx)(j,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,U.jsx)(O,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return s.push(X(`result:replies`,(0,U.jsxs)(U.Fragment,{children:[a.length?(0,U.jsx)(de,{view:e,title:`${n.title} · ${e.wizard.title}`}):null,i?(0,U.jsxs)(Z,{onClick:i,children:[(0,U.jsx)(v,{className:`size-4`}),` `,S(`run.again`)]}):null,e.canBack?(0,U.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:S(`run.back`)}):null,e.keeps?(0,U.jsx)(`span`,{className:`ml-1`,children:(0,U.jsx)(w,{runId:e.id})}):null]}))),(0,U.jsx)(J,{avatar:e.wizard.avatar,lines:s})}function at({runId:e,onRestart:t,onView:n,header:r,footer:a,talk:o=!1,call:s=!1}){let c=pe(e),{view:l}=c,[u,d]=(0,H.useState)(null),f=je(e,l,c,u);(0,H.useEffect)(()=>{n?.(l)},[l,n]);let[p,m]=ce(),h=(0,H.useMemo)(()=>({runId:e,lang:l?.lang??_,readAloud:p,setReadAloud:m,voice:l?.talk?f:null,talk:o,call:!!s,bindPage:d}),[e,l?.lang,l?.talk,p,m,f,o,s]);y(l?.status===`running`&&!l.ask),k(l);let[g,b]=(0,H.useState)({}),[x,C]=(0,H.useState)(null);(0,H.useEffect)(()=>{l&&l.status!==`running`&&C(null)},[l]);let w;if(c.notFound)w=(0,U.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:S(`run.notFound`)});else if(!l)w=(0,U.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,U.jsx)(i,{})});else{let e=l.step,n=l.status===`waiting_input`,r=qe(l,l.canBack&&n&&!c.busy?()=>void c.back():void 0);if(l.status===`running`&&l.ask)w=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,G(`ask:${l.ask.id}`,(0,U.jsx)(z,{runId:l.id,ask:l.ask}),{wide:!0})]}),(0,U.jsx)(Q,{})]});else if(l.status===`running`)w=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,...x?[K(`note`,x)]:[],G(`working:${e?.id}`,(0,U.jsx)(Qe,{view:l}),{wide:l.events.some(t=>t.stepId===e?.id&&et(t))?`most`:void 0})]}),(0,U.jsx)(Q,{placeholder:S(`run.working`)})]});else if(l.status===`failed`)w=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,G(`failed`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:S(`run.failed`)}),l.error?(0,U.jsx)(`span`,{className:`mt-0.5 block`,children:(0,U.jsx)(ne,{text:l.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{primary:!0,busy:c.busy,onClick:()=>void c.retry(),children:[(0,U.jsx)(v,{className:`size-4`}),` `,S(`run.retry`)]}),l.canBack?(0,U.jsx)(Z,{onClick:()=>void c.back(),disabled:c.busy,children:S(`run.back`)}):null]}))]}),(0,U.jsx)(Q,{})]});else if(l.status===`cancelled`)w=(0,U.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,G(`cancelled`,S(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,U.jsxs)(Z,{primary:!0,onClick:t,children:[(0,U.jsx)(v,{className:`size-4`}),` `,S(`run.again`)]}))]:[]]});else if(e?.type===`page`)w=(0,U.jsx)(Ye,{view:l,run:c,step:e,before:r},e.id);else if(e?.type===`review`){let t=l.shown.map(e=>e.output?.at??``).join(`|`);w=(0,U.jsx)(rt,{view:l,run:c,step:e,before:r,asked:g[e.id]??[],onNote:t=>{C(t),b(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else w=e?.type===`result`?(0,U.jsx)(it,{view:l,run:c,step:e,before:r,onRestart:t}):(0,U.jsx)(J,{avatar:l.wizard.avatar,lines:r})}return s?(0,U.jsx)(q.Provider,{value:h,children:(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,U.jsx)(Te,{voice:f,view:l,video:s===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,U.jsx)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-border-soft border-t lg:w-[420px] lg:flex-none lg:border-t-0 lg:border-l`,children:(0,U.jsx)(Fe,{footer:a,children:w})})]})}):(0,U.jsx)(q.Provider,{value:h,children:(0,U.jsx)(Fe,{header:r,footer:a,children:w})})}export{J as a,Z as i,Fe as n,X as o,Q as r,Ne as s,at as t};