wizards 0.4.4 → 0.4.5

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 (120) hide show
  1. package/apps/runtime/dist/agents/architect.js +32 -13
  2. package/apps/runtime/dist/agents/subscription.js +12 -12
  3. package/apps/runtime/dist/app.js +9 -5
  4. package/apps/runtime/dist/assistant/knows.js +2 -2
  5. package/apps/runtime/dist/authoring/example.js +21 -20
  6. package/apps/runtime/dist/authoring/guide.js +4 -2
  7. package/apps/runtime/dist/connectors/imap.js +4 -4
  8. package/apps/runtime/dist/connectors/index.js +40 -15
  9. package/apps/runtime/dist/connectors/plugin-connections.js +3 -2
  10. package/apps/runtime/dist/connectors/via-account.js +8 -6
  11. package/apps/runtime/dist/docs/dev/plugins/connections.md +1 -1
  12. package/apps/runtime/dist/docs/dev/plugins/starters.md +1 -1
  13. package/apps/runtime/dist/documents/parse.js +5 -3
  14. package/apps/runtime/dist/engine/events.js +1 -1
  15. package/apps/runtime/dist/engine/input.js +28 -8
  16. package/apps/runtime/dist/engine/prepare.js +2 -2
  17. package/apps/runtime/dist/engine/requirements.js +12 -3
  18. package/apps/runtime/dist/engine/runner.js +34 -23
  19. package/apps/runtime/dist/engine/steps.js +6 -5
  20. package/apps/runtime/dist/engine/surface.js +2 -1
  21. package/apps/runtime/dist/engine/template.js +1 -1
  22. package/apps/runtime/dist/engine/types.js +2 -1
  23. package/apps/runtime/dist/film/project.js +1 -1
  24. package/apps/runtime/dist/film/skills.js +2 -2
  25. package/apps/runtime/dist/film/sounds.js +1 -1
  26. package/apps/runtime/dist/film/step.js +7 -4
  27. package/apps/runtime/dist/film/tools.js +1 -1
  28. package/apps/runtime/dist/geocode.js +1 -1
  29. package/apps/runtime/dist/harness/apple.js +0 -5
  30. package/apps/runtime/dist/harness/claude.js +2 -1
  31. package/apps/runtime/dist/harness/codex.js +2 -1
  32. package/apps/runtime/dist/harness/model.js +4 -3
  33. package/apps/runtime/dist/harness/terminal.js +4 -3
  34. package/apps/runtime/dist/model-errors.js +8 -3
  35. package/apps/runtime/dist/models.js +58 -38
  36. package/apps/runtime/dist/plugins/runs.js +2 -1
  37. package/apps/runtime/dist/routes/api.js +16 -5
  38. package/apps/runtime/dist/routes/lang.js +13 -0
  39. package/apps/runtime/dist/routes/runs.js +12 -19
  40. package/apps/runtime/dist/routes/studio.js +40 -28
  41. package/apps/runtime/dist/services/access.js +4 -3
  42. package/apps/runtime/dist/services/architect.js +15 -4
  43. package/apps/runtime/dist/services/assistant-chats.js +2 -1
  44. package/apps/runtime/dist/services/brand.js +3 -2
  45. package/apps/runtime/dist/services/errors.js +7 -5
  46. package/apps/runtime/dist/services/knowledge-model.js +3 -2
  47. package/apps/runtime/dist/services/marketplace.js +6 -5
  48. package/apps/runtime/dist/services/package.js +10 -3
  49. package/apps/runtime/dist/services/profile.js +12 -0
  50. package/apps/runtime/dist/services/project-files.js +13 -12
  51. package/apps/runtime/dist/services/projects.js +11 -6
  52. package/apps/runtime/dist/services/runs.js +18 -11
  53. package/apps/runtime/dist/services/shares.js +2 -1
  54. package/apps/runtime/dist/services/site.js +21 -10
  55. package/apps/runtime/dist/services/space-categories.js +7 -6
  56. package/apps/runtime/dist/services/space-data.js +19 -16
  57. package/apps/runtime/dist/services/spaces.js +8 -7
  58. package/apps/runtime/dist/services/wizards.js +41 -20
  59. package/apps/runtime/dist/store/errors.js +2 -1
  60. package/apps/runtime/dist/store/index.js +21 -4
  61. package/apps/runtime/dist/store/shared-lists.js +2 -3
  62. package/apps/runtime/dist/tools/index.js +17 -2
  63. package/apps/runtime/dist/tools/plugin.js +3 -2
  64. package/apps/runtime/dist/widgets/render.js +1 -1
  65. package/apps/runtime/dist/widgets/step.js +2 -1
  66. package/apps/web/dist/assets/{AboutDialog-nLn3vZAN.js → AboutDialog-BCtnYRj2.js} +1 -1
  67. package/apps/web/dist/assets/{ChangelogDialog-Cbx3mN2p.js → ChangelogDialog-DBjoIIHL.js} +1 -1
  68. package/apps/web/dist/assets/ChatView-BcyUYN0Q.js +10 -0
  69. package/apps/web/dist/assets/EditorPage-Ce1QD-DK.js +3 -0
  70. package/apps/web/dist/assets/{FlowPreview-Bvj3R8g4.js → FlowPreview-BtpAdyt-.js} +1 -1
  71. package/apps/web/dist/assets/{Harness-D-Z3MbYq.js → Harness-DJJ_yMLY.js} +2 -2
  72. package/apps/web/dist/assets/NewWizardChannels-BrYLMV6F.js +1 -0
  73. package/apps/web/dist/assets/NewWizardPage-827zwhhW.js +7 -0
  74. package/apps/web/dist/assets/{OnboardingPage-CdoAfnI2.js → OnboardingPage-jC6FidpF.js} +1 -1
  75. package/apps/web/dist/assets/ProjectPage-BYcM1-1H.js +1 -0
  76. package/apps/web/dist/assets/{PublicRunner-CHwK3X75.js → PublicRunner-BofZl0MO.js} +1 -1
  77. package/apps/web/dist/assets/{ReadOnly-DQPHmvS0.js → ReadOnly-B4nIGkoj.js} +1 -1
  78. package/apps/web/dist/assets/RunDrawer-Dx-BRCkY.js +4 -0
  79. package/apps/web/dist/assets/RunnerView-CDCp61aq.js +1 -0
  80. package/apps/web/dist/assets/SettingsPage-B49nLHwv.js +1 -0
  81. package/apps/web/dist/assets/SetupPage-4tzzHUq0.js +1 -0
  82. package/apps/web/dist/assets/SharePage-Bs4s73h4.js +1 -0
  83. package/apps/web/dist/assets/changelog-D-12LwZB.js +1 -0
  84. package/apps/web/dist/assets/{circle-alert-DCBV7n5k.js → circle-alert-BueS7qO8.js} +1 -1
  85. package/apps/web/dist/assets/esm-CjGdsKU4.js +7 -0
  86. package/apps/web/dist/assets/index-BRDn-5v_.js +14 -0
  87. package/apps/web/dist/assets/index-mlnAPOdf.css +1 -0
  88. package/apps/web/dist/assets/{lock-DlzTfwxP.js → lock-CkXYnQux.js} +1 -1
  89. package/apps/web/dist/assets/{phone-BFD815nc.js → phone-CHkEf-Dz.js} +1 -1
  90. package/apps/web/dist/assets/settings-menu-CrVpArM_.js +1 -0
  91. package/apps/web/dist/assets/ui-DrdqFaQt.js +134 -0
  92. package/apps/web/dist/assets/{upload-BEf5-d6X.js → upload-CzkkZqAo.js} +1 -1
  93. package/apps/web/dist/index.html +4 -4
  94. package/apps/web/dist/mcp/flow.html +76 -76
  95. package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +4 -2
  96. package/node_modules/@engenty-wizards/plugin-sdk/dist/thread.js +6 -1
  97. package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +6 -2
  98. package/node_modules/@engenty-wizards/shared/dist/definition.js +13 -5
  99. package/node_modules/@engenty-wizards/shared/dist/knowledge.js +1 -1
  100. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +11 -1
  101. package/node_modules/@engenty-wizards/shared/dist/run.js +11 -1
  102. package/node_modules/@engenty-wizards/shared/dist/store.d.ts +8 -0
  103. package/node_modules/@engenty-wizards/shared/dist/store.js +8 -0
  104. package/package.json +1 -1
  105. package/apps/web/dist/assets/ChatView-1VuHE2Q7.js +0 -10
  106. package/apps/web/dist/assets/EditorPage-Cp3jqQsk.js +0 -3
  107. package/apps/web/dist/assets/NewWizardChannels-DCF7JoL0.js +0 -1
  108. package/apps/web/dist/assets/NewWizardPage-BTlgq7yN.js +0 -7
  109. package/apps/web/dist/assets/ProjectPage-CoPSdDO9.js +0 -1
  110. package/apps/web/dist/assets/RunDrawer-CmGuqp0p.js +0 -4
  111. package/apps/web/dist/assets/RunnerView-DiaQiDbw.js +0 -1
  112. package/apps/web/dist/assets/SettingsPage-NzmFrJXb.js +0 -1
  113. package/apps/web/dist/assets/SetupPage-8mBuezdY.js +0 -1
  114. package/apps/web/dist/assets/SharePage-C-T5fkp1.js +0 -1
  115. package/apps/web/dist/assets/changelog-CsxPWKJ-.js +0 -1
  116. package/apps/web/dist/assets/esm-CnR8rDPi.js +0 -7
  117. package/apps/web/dist/assets/index-CmxVazOf.css +0 -1
  118. package/apps/web/dist/assets/index-D57rKyGN.js +0 -14
  119. package/apps/web/dist/assets/settings-menu-D-UqnL1p.js +0 -1
  120. package/apps/web/dist/assets/ui-DTuixH4y.js +0 -134
@@ -1,4 +1,5 @@
1
- import { newCells, patchCells, rowKey, STORE_LIMITS, } from "@engenty-wizards/shared/store";
1
+ import { bilingual } from "@engenty-wizards/shared/run";
2
+ import { firstRowAt, newCells, patchCells, rowKey, STORE_LIMITS, } from "@engenty-wizards/shared/store";
2
3
  import { cleanPath, mimeForPath } from "@engenty-wizards/shared/workspace";
3
4
  import { and, asc, eq, inArray, like, lt, sql } from "drizzle-orm";
4
5
  import { nanoid } from "nanoid";
@@ -59,6 +60,7 @@ export async function saveRows(scope, def, input) {
59
60
  const existing = await db.query.storeRow.findMany({ where: inList(scope, def.id) });
60
61
  const byKey = new Map(existing.filter((r) => r.key).map((r) => [r.key, r]));
61
62
  let count = existing.length;
63
+ const at = firstRowAt(existing);
62
64
  for (const raw of input) {
63
65
  const key = rowKey(def, raw);
64
66
  const hit = key ? byKey.get(key) : undefined;
@@ -79,10 +81,17 @@ export async function saveRows(scope, def, input) {
79
81
  if (count >= STORE_LIMITS.rowsPerList) {
80
82
  throw new StoreError(`List "${def.id}" is full (${STORE_LIMITS.rowsPerList} rows).`);
81
83
  }
82
- const row = { id: nanoid(14), ...scope, list: def.id, key, cells };
84
+ const row = {
85
+ id: nanoid(14),
86
+ ...scope,
87
+ list: def.id,
88
+ key,
89
+ cells,
90
+ createdAt: new Date(at + added),
91
+ };
83
92
  await db.insert(schema.storeRow).values(row);
84
93
  if (key) {
85
- byKey.set(key, { ...row, createdAt: new Date(), updatedAt: new Date() });
94
+ byKey.set(key, { ...row, updatedAt: new Date() });
86
95
  }
87
96
  count++;
88
97
  added++;
@@ -109,7 +118,7 @@ export async function updateRow(scope, def, rowId, patch) {
109
118
  })
110
119
  : null;
111
120
  if (clash) {
112
- throw new StoreError("Diesen Eintrag gibt es schon.");
121
+ throw new StoreError(bilingual("Diesen Eintrag gibt es schon.", "This entry already exists."));
113
122
  }
114
123
  await db
115
124
  .update(schema.storeRow)
@@ -176,6 +185,14 @@ export async function storeFiles(scope, folder) {
176
185
  });
177
186
  return rows.map(toFile);
178
187
  }
188
+ /** Whether the wizard keeps any file for the holder: one row, not the whole list. */
189
+ export async function hasStoreFiles(scope) {
190
+ const row = await db.query.storeFile.findFirst({
191
+ where: ownFiles(scope),
192
+ columns: { path: true },
193
+ });
194
+ return row !== undefined;
195
+ }
179
196
  export async function readStoreFile(scope, rawPath) {
180
197
  const path = cleanPath(rawPath);
181
198
  const row = path
@@ -1,4 +1,4 @@
1
- import { newCells, patchCells, rowKey, STORE_LIMITS, } from "@engenty-wizards/shared/store";
1
+ import { firstRowAt, newCells, patchCells, rowKey, STORE_LIMITS, } from "@engenty-wizards/shared/store";
2
2
  import { and, asc, eq, inArray } from "drizzle-orm";
3
3
  import { nanoid } from "nanoid";
4
4
  import { db, schema } from "../db/client.js";
@@ -64,8 +64,7 @@ export async function saveSharedRows(wizardId, def, input) {
64
64
  });
65
65
  const byKey = new Map(existing.filter((r) => r.key).map((r) => [r.key, r]));
66
66
  let count = existing.length;
67
- // Rows stand in the order they came, also those saved in the same second.
68
- const at = Date.now();
67
+ const at = firstRowAt(existing);
69
68
  let added = 0;
70
69
  let updated = 0;
71
70
  for (const raw of input) {
@@ -10,6 +10,7 @@ import { gatewayTools, isHarnessVendor } from "../models.js";
10
10
  import { htmlToMarkdown } from "../render/convert.js";
11
11
  import { pythonToolDescription, sandboxCapabilities, shellToolDescription, } from "../sandbox/index.js";
12
12
  import { snapshotFile } from "../services/files.js";
13
+ import { hasStoreFiles } from "../store/index.js";
13
14
  import { browserTools } from "./browser.js";
14
15
  import { connectorTools } from "./connector.js";
15
16
  import { mailTools } from "./mail.js";
@@ -44,6 +45,13 @@ function isReadable(type, body) {
44
45
  }
45
46
  return odd <= sample.length * 0.01;
46
47
  }
48
+ /**
49
+ * Whether a step has no use for the wizard's store: it declares no tools and no connections,
50
+ * got no uploads, and the wizard keeps no lists. Its files may still be there (`buildStepTools`).
51
+ */
52
+ export function storeIdle(step, lists, uploads) {
53
+ return step.tools.length === 0 && !step.connections?.length && lists === 0 && uploads === 0;
54
+ }
47
55
  /** The tools an agent step may use: exactly what its definition allowlists. */
48
56
  export async function buildStepTools(step, ctx, resolved, uploads) {
49
57
  const tools = {};
@@ -139,8 +147,15 @@ export async function buildStepTools(step, ctx, resolved, uploads) {
139
147
  Object.assign(tools, await browserTools(ctx, assets, files));
140
148
  }
141
149
  // The wizard's lists and files, the documents the person gave and the project's documents are
142
- // always at hand.
143
- Object.assign(tools, storeTools(ctx, uploads, files));
150
+ // always at hand. An installed client gets tools over an MCP bridge its CLI starts for every
151
+ // call, seconds of its own: a step with no use for the store goes without its tools, and
152
+ // without others (Wissen, a workspace file) the client answers without the bridge.
153
+ const idle = isHarnessVendor(resolved.vendor) &&
154
+ storeIdle(step, ctx.def.lists?.length ?? 0, uploads.length) &&
155
+ !(await hasStoreFiles(ctx.store));
156
+ if (!idle) {
157
+ Object.assign(tools, storeTools(ctx, uploads, files));
158
+ }
144
159
  Object.assign(tools, await projectTools(ctx));
145
160
  Object.assign(tools, mailTools(step, ctx, files));
146
161
  Object.assign(tools, await connectorTools(step, ctx, files));
@@ -1,4 +1,5 @@
1
1
  import { pluginToolOf } from "@engenty-wizards/shared/definition";
2
+ import { bilingual } from "@engenty-wizards/shared/run";
2
3
  import { createTool } from "@mastra/core/tools";
3
4
  import { StepError } from "../engine/types.js";
4
5
  import { loadedPlugin, pluginIdsOf, pluginsOf } from "../plugins/registry.js";
@@ -38,7 +39,7 @@ async function toolOf(id, ctx) {
38
39
  const found = named && has.has(named.plugin) ? loadedPlugin(named.plugin)?.tools.get(named.tool) : undefined;
39
40
  if (!(named && found)) {
40
41
  const plugin = named?.plugin ?? id;
41
- throw new StepError(`Dieser Schritt braucht das Werkzeug „${id}“. Das Plugin „${plugin}“ ist hier nicht installiert.`);
42
+ throw new StepError(bilingual(`Dieser Schritt braucht das Werkzeug „${id}“. Das Plugin „${plugin}“ ist hier nicht installiert.`, `This step needs the tool “${id}”. The plugin “${plugin}” is not installed here.`));
42
43
  }
43
44
  return { plugin: named.plugin, tool: found };
44
45
  }
@@ -51,7 +52,7 @@ export async function callPluginTool(id, input, ctx) {
51
52
  const parsed = tool.inputSchema.safeParse(input);
52
53
  if (!parsed.success) {
53
54
  const issue = parsed.error.issues[0];
54
- throw new StepError(`„${id}“ bekam ungültige Angaben: ${issue?.path.join(".") || "input"} – ${issue?.message}`);
55
+ throw new StepError(bilingual(`„${id}“ bekam ungültige Angaben: ${issue?.path.join(".") || "input"} – ${issue?.message}`, `“${id}” got invalid input: ${issue?.path.join(".") || "input"} – ${issue?.message}`));
55
56
  }
56
57
  try {
57
58
  return await tool.execute(parsed.data, toolContext(ctx));
@@ -312,7 +312,7 @@ export async function renderFilm(html, size, media, onProgress) {
312
312
  out = mixed;
313
313
  }
314
314
  else {
315
- errors.push(`Der Ton konnte nicht gemischt werden: ${stderr.slice(-200)}`);
315
+ errors.push(`The sound could not be mixed: ${stderr.slice(-200)}`);
316
316
  }
317
317
  }
318
318
  return {
@@ -1,4 +1,5 @@
1
1
  import { allFields, dataRef, widgetSize, } from "@engenty-wizards/shared/definition";
2
+ import { bilingual } from "@engenty-wizards/shared/run";
2
3
  import { resolveRef } from "../engine/template.js";
3
4
  import { StepError } from "../engine/types.js";
4
5
  import { extFor, inlineAssetRefs, loadAsset } from "../files/storage.js";
@@ -106,7 +107,7 @@ async function runFilmStep(step, ctx, html, data, media, origin) {
106
107
  }
107
108
  });
108
109
  if (!film) {
109
- throw new StepError("Der Film konnte nicht gerendert werden: dazu braucht es ffmpeg und eine Zeitleiste im Widget.");
110
+ throw new StepError(bilingual("Der Film konnte nicht gerendert werden: dazu braucht es ffmpeg und eine Zeitleiste im Widget.", "The film could not be rendered: that needs ffmpeg and a timeline in the widget."));
110
111
  }
111
112
  if (film.errors.length) {
112
113
  await ctx.emit("info", {
@@ -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{$t as r,An as i,Fn as a,Gt as o,Ht as s,Ut as c,Wt as l,Xt as u,an as d,rn as f,sn as p,tn as m}from"./ui-DTuixH4y.js";import{t as h}from"./preload-helper-CNEI7N0N.js";import{$ as g,H as _,V as v,gt as y}from"./index-D57rKyGN.js";import{c as b,f as x}from"./settings-menu-D-UqnL1p.js";import{ReleaseNotes as S,loadReleases as C,releaseDate as w,releaseLabel as T}from"./ChangelogDialog-Cbx3mN2p.js";var E=e(t(),1),D=[{name:`engenty wizards`,description:{de:`KI-Wizards aus einer Beschreibung, mit einem Link geteilt.`,en:`AI wizards built from a description, shared with a link.`},homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:{de:`Konnektoren, Datentabellen, Suche und die Engenties stammen aus dem engenty-Framework.`,en:`Connectors, data tables, search and the engenties come from the engenty framework.`},homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],O=[{name:`Mastra`,description:{de:`Agent-Framework hinter den KI-Schritten.`,en:`Agent framework behind the AI steps.`},homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:{de:`Modell-Aufrufe für Text, Bild, Video und Sprache.`,en:`Model calls for text, image, video and speech.`},homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:{de:`MCP-Server zum Bauen von Wizards, MCP-Client für Werkzeuge der Schritte.`,en:`MCP server for building wizards, MCP client for the steps' tools.`},homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:{de:`HTTP-API der Runtime.`,en:`The runtime's HTTP API.`},homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:{de:`Schema und Migrationen der Datenbanken.`,en:`Schema and migrations of the databases.`},homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:{de:`Eine Datenbank je Mandant, lokal als Datei oder bei Turso.`,en:`One database per tenant, a local file or at Turso.`},homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:{de:`Browser-Schritte sowie PDF- und PNG-Export.`,en:`Browser steps and the PDF and PNG export.`},homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`agentOS`,description:{de:`Sandbox für Code-Schritte ohne Docker.`,en:`Sandbox for code steps without Docker.`},homepage:`https://github.com/rivet-dev/agentos`,license:`Apache-2.0`},{name:`React`,description:{de:`UI-Bibliothek der Web-App.`,en:`UI library of the web app.`},homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:{de:`Build-Werkzeug der Web-App.`,en:`Build tool of the web app.`},homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:{de:`Styling der Oberfläche.`,en:`Styling of the interface.`},homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:{de:`Das Diagramm der Schritte im Editor.`,en:`The diagram of steps in the editor.`},homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:{de:`Server-Daten in der Web-App.`,en:`Server data in the web app.`},homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:{de:`Das Terminal auf der Seite, in dem sich KI-Clients anmelden.`,en:`The terminal on the page where AI clients sign in.`},homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:{de:`Icons.`,en:`Icons.`},homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:{de:`Schrift der Oberfläche.`,en:`Typeface of the interface.`},homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:{de:`Schrift der Überschriften.`,en:`Typeface of the headings.`},homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:{de:`Erzeugt den Changelog aus den Commits.`,en:`Generates the changelog from the commits.`},homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],k=e(n(),1),A=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function j({name:e,homepage:t,version:n,license:r,description:a}){return(0,k.jsxs)(`li`,{className:`py-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,k.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,k.jsx)(i,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,k.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,k.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,k.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),a?(0,k.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:a}):null]})}function M({title:e,hint:t,children:n}){return(0,k.jsxs)(`section`,{className:`mt-6`,children:[(0,k.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,k.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function N({credits:e}){return(0,k.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,k.jsx)(j,{name:e.name,homepage:e.homepage,license:e.license,description:e.description[f]},e.name))})}function P({label:e,packages:t}){return(0,k.jsxs)(`div`,{className:`mt-4`,children:[(0,k.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,k.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,k.jsx)(j,{...e},e.name))})]})}function F({active:e}){let[t,n]=(0,E.useState)(null),[r,i]=(0,E.useState)(``);(0,E.useEffect)(()=>{if(!e||t)return;let r=!1;return h(()=>import(`./oss-credits-BQQX0kvk.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,E.useEffect)(()=>{e||i(``)},[e]);let a=r.trim().toLowerCase(),s=e=>a?e.filter(e=>A(a,e.name,e.license,e.description.de,e.description.en)):e,l=e=>a?e.filter(e=>A(a,e.name,e.license,e.version)):e,f=s(D),p=s(O),m=t?[{id:`shared`,label:d(`about.creditsShared`),packages:l(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:l(e.packages)}))].filter(e=>e.packages.length>0):[],g=f.length===0&&p.length===0&&m.length===0;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:d(`about.creditsHint`)}),(0,k.jsx)(o,{type:`search`,value:r,placeholder:d(`about.search`),onChange:e=>i(e.target.value)}),f.length>0?(0,k.jsx)(M,{title:d(`about.creditsProduct`),children:(0,k.jsx)(N,{credits:f})}):null,p.length>0?(0,k.jsx)(M,{title:d(`about.creditsBuiltWith`),children:(0,k.jsx)(N,{credits:p})}):null,t===null?(0,k.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,k.jsx)(u,{})}):m.length>0?(0,k.jsx)(M,{title:d(`about.creditsDeps`),hint:a?void 0:d(`about.creditsDepsHint`),children:m.map(e=>(0,k.jsx)(P,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,k.jsx)(c,{children:d(`about.noMatches`)}):null]})}var I=[`new`,`earlier`,`credits`],L=e=>d(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),R=e=>e===1?d(`about.change`):d(`about.changes`,{n:e});function z({open:e,onClose:t,me:n}){let i=n?.mode===`local`,{data:o,latest:c}=_(i&&e),[f,h]=(0,E.useState)(null),[D,O]=(0,E.useState)(`new`),A=x(I.indexOf(D)),j=o?.newer&&c?c:g;(0,E.useEffect)(()=>{if(!e)return;let t=!1;return h(null),C(j===`0.4.4`?void 0:j).then(e=>{t||h(e)}),()=>{t=!0}},[e,j]);let M=f?.find(e=>e.version===`v${j}`)??f?.[0]??null,N=f?.filter(e=>e!==M)??[],P=i?o?.kind??null:`cloud`;return(0,k.jsxs)(s,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,k.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,k.jsx)(l,{label:d(`common.close`),onClick:t,children:(0,k.jsx)(p,{className:`size-4`})})}),(0,k.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,k.jsx)(y,{size:96}),(0,k.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,k.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,k.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,k.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[d(`about.version`,{v:g}),P?` · ${d(`about.kind.${P}`)}`:``]})]}),i?(0,k.jsx)(`div`,{className:`mt-5`,children:(0,k.jsx)(v,{enabled:e})}):null,(0,k.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,k.jsx)(r,{value:D,onChange:O,options:I.map(e=>({id:e,label:L(e)})),label:d(`about.title`)})}),(0,k.jsxs)(`div`,{className:m(`mt-5`,b(A)),children:[D===`new`?f===null?(0,k.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,k.jsx)(u,{})}):M?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[T(M),(0,k.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:w(M)})]}),(0,k.jsx)(`div`,{className:`mt-3`,children:(0,k.jsx)(S,{release:M})})]}):(0,k.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:d(`about.changelogEmpty`)}):null,D===`earlier`?(0,k.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:N.map(e=>(0,k.jsxs)(`details`,{className:`group/r py-2`,children:[(0,k.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,k.jsx)(a,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,k.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:T(e)}),(0,k.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:w(e)}),(0,k.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:R(e.commits.length)})]}),(0,k.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,k.jsx)(S,{release:e})})]},e.version??`unreleased`))}):null,D===`credits`?(0,k.jsx)(F,{active:!0}):null]},D)]})}export{z as AboutDialog};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{In as r,Jt as i,Vn as a,Xt as o,Yt as s,cn as c,dn as l,in as u,on as d,pn as f,qt as p,tn as m}from"./ui-DrdqFaQt.js";import{t as h}from"./preload-helper-CNEI7N0N.js";import{H as g,U as _,W as v,_t as y}from"./index-BRDn-5v_.js";import{c as b,f as x}from"./settings-menu-CrVpArM_.js";import{ReleaseNotes as S,loadReleases as C,releaseDate as w,releaseLabel as T}from"./ChangelogDialog-DBjoIIHL.js";var E=e(t(),1),D=[{name:`engenty wizards`,description:{de:`KI-Wizards aus einer Beschreibung, mit einem Link geteilt.`,en:`AI wizards built from a description, shared with a link.`},homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:{de:`Konnektoren, Datentabellen, Suche und die Engenties stammen aus dem engenty-Framework.`,en:`Connectors, data tables, search and the engenties come from the engenty framework.`},homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],O=[{name:`Mastra`,description:{de:`Agent-Framework hinter den KI-Schritten.`,en:`Agent framework behind the AI steps.`},homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:{de:`Modell-Aufrufe für Text, Bild, Video und Sprache.`,en:`Model calls for text, image, video and speech.`},homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:{de:`MCP-Server zum Bauen von Wizards, MCP-Client für Werkzeuge der Schritte.`,en:`MCP server for building wizards, MCP client for the steps' tools.`},homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:{de:`HTTP-API der Runtime.`,en:`The runtime's HTTP API.`},homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:{de:`Schema und Migrationen der Datenbanken.`,en:`Schema and migrations of the databases.`},homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:{de:`Eine Datenbank je Mandant, lokal als Datei oder bei Turso.`,en:`One database per tenant, a local file or at Turso.`},homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:{de:`Browser-Schritte sowie PDF- und PNG-Export.`,en:`Browser steps and the PDF and PNG export.`},homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`agentOS`,description:{de:`Sandbox für Code-Schritte ohne Docker.`,en:`Sandbox for code steps without Docker.`},homepage:`https://github.com/rivet-dev/agentos`,license:`Apache-2.0`},{name:`React`,description:{de:`UI-Bibliothek der Web-App.`,en:`UI library of the web app.`},homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:{de:`Build-Werkzeug der Web-App.`,en:`Build tool of the web app.`},homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:{de:`Styling der Oberfläche.`,en:`Styling of the interface.`},homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:{de:`Das Diagramm der Schritte im Editor.`,en:`The diagram of steps in the editor.`},homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:{de:`Server-Daten in der Web-App.`,en:`Server data in the web app.`},homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:{de:`Das Terminal auf der Seite, in dem sich KI-Clients anmelden.`,en:`The terminal on the page where AI clients sign in.`},homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:{de:`Icons.`,en:`Icons.`},homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:{de:`Schrift der Oberfläche.`,en:`Typeface of the interface.`},homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:{de:`Schrift der Überschriften.`,en:`Typeface of the headings.`},homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:{de:`Erzeugt den Changelog aus den Commits.`,en:`Generates the changelog from the commits.`},homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],k=e(n(),1),A=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function j({name:e,homepage:t,version:n,license:i,description:a}){return(0,k.jsxs)(`li`,{className:`py-2.5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,k.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,k.jsx)(r,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,k.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,k.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,k.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:i})]}),a?(0,k.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:a}):null]})}function M({title:e,hint:t,children:n}){return(0,k.jsxs)(`section`,{className:`mt-6`,children:[(0,k.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,k.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function N({credits:e}){return(0,k.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,k.jsx)(j,{name:e.name,homepage:e.homepage,license:e.license,description:e.description[c]},e.name))})}function P({label:e,packages:t}){return(0,k.jsxs)(`div`,{className:`mt-4`,children:[(0,k.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,k.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,k.jsx)(j,{...e},e.name))})]})}function F({active:e}){let[t,n]=(0,E.useState)(null),[r,a]=(0,E.useState)(``);(0,E.useEffect)(()=>{if(!e||t)return;let r=!1;return h(()=>import(`./oss-credits-BQQX0kvk.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,E.useEffect)(()=>{e||a(``)},[e]);let s=r.trim().toLowerCase(),c=e=>s?e.filter(e=>A(s,e.name,e.license,e.description.de,e.description.en)):e,u=e=>s?e.filter(e=>A(s,e.name,e.license,e.version)):e,d=c(D),f=c(O),p=t?[{id:`shared`,label:l(`about.creditsShared`),packages:u(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:u(e.packages)}))].filter(e=>e.packages.length>0):[],g=d.length===0&&f.length===0&&p.length===0;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:l(`about.creditsHint`)}),(0,k.jsx)(o,{type:`search`,value:r,placeholder:l(`about.search`),onChange:e=>a(e.target.value)}),d.length>0?(0,k.jsx)(M,{title:l(`about.creditsProduct`),children:(0,k.jsx)(N,{credits:d})}):null,f.length>0?(0,k.jsx)(M,{title:l(`about.creditsBuiltWith`),children:(0,k.jsx)(N,{credits:f})}):null,t===null?(0,k.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,k.jsx)(m,{})}):p.length>0?(0,k.jsx)(M,{title:l(`about.creditsDeps`),hint:s?void 0:l(`about.creditsDepsHint`),children:p.map(e=>(0,k.jsx)(P,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,k.jsx)(i,{children:l(`about.noMatches`)}):null]})}var I=[`new`,`earlier`,`credits`],L=e=>l(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),R=e=>e===1?l(`about.change`):l(`about.changes`,{n:e});function z({open:e,onClose:t,me:n}){let r=n?.mode===`local`,{data:i,latest:o}=v(r&&e),[c,h]=(0,E.useState)(null),[D,O]=(0,E.useState)(`new`),A=x(I.indexOf(D)),j=i?.newer&&o?o:_;(0,E.useEffect)(()=>{if(!e)return;let t=!1;return h(null),C(j===`0.4.5`?void 0:j).then(e=>{t||h(e)}),()=>{t=!0}},[e,j]);let M=c?.find(e=>e.version===`v${j}`)??c?.[0]??null,N=c?.filter(e=>e!==M)??[],P=r?i?.kind??null:`cloud`;return(0,k.jsxs)(p,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,k.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,k.jsx)(s,{label:l(`common.close`),onClick:t,children:(0,k.jsx)(f,{className:`size-4`})})}),(0,k.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,k.jsx)(y,{size:96}),(0,k.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,k.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,k.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,k.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[l(`about.version`,{v:_}),P?` · ${l(`about.kind.${P}`)}`:``]})]}),r?(0,k.jsx)(`div`,{className:`mt-5`,children:(0,k.jsx)(g,{enabled:e})}):null,(0,k.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,k.jsx)(u,{value:D,onChange:O,options:I.map(e=>({id:e,label:L(e)})),label:l(`about.title`)})}),(0,k.jsxs)(`div`,{className:d(`mt-5`,b(A)),children:[D===`new`?c===null?(0,k.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,k.jsx)(m,{})}):M?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[T(M),(0,k.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:w(M)})]}),(0,k.jsx)(`div`,{className:`mt-3`,children:(0,k.jsx)(S,{release:M})})]}):(0,k.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:l(`about.changelogEmpty`)}):null,D===`earlier`?(0,k.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:N.map(e=>(0,k.jsxs)(`details`,{className:`group/r py-2`,children:[(0,k.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,k.jsx)(a,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,k.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:T(e)}),(0,k.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:w(e)}),(0,k.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:R(e.commits.length)})]}),(0,k.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,k.jsx)(S,{release:e})})]},e.version??`unreleased`))}):null,D===`credits`?(0,k.jsx)(F,{active:!0}):null]},D)]})}export{z as AboutDialog};
@@ -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{Gt as r,Ht as i,Ut as a,Xt as o,an as s,tn as c}from"./ui-DTuixH4y.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/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-CsxPWKJ-.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)(i,{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)(o,{})}):c.length===0?(0,d.jsx)(a,{children:s(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(r,{type:`search`,value:f,placeholder:s(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(a,{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};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Jt as r,Xt as i,dn as a,on as o,qt as s,tn as c}from"./ui-DrdqFaQt.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/,``):a(`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/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-D-12LwZB.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:o(`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:a(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[o,l]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||o)return;let t=!1;return _(n).then(e=>{t||l(e)}),()=>{t=!0}},[e,o,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=o?g(o,f):[];return(0,d.jsxs)(s,{open:e,onClose:t,title:a(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:a(`about.changelogHint`)}),o===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(c,{})}):o.length===0?(0,d.jsx)(r,{children:a(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i,{type:`search`,value:f,placeholder:a(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(r,{children:a(`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{$ as r,Bt as i,Dn as a,Ft as o,Kn as s,Lt as c,Qt as l,Rt as u,W as d,Wn as f,Xn as p,Yt as m,_n as h,an as g,bn as _,bt as v,cn as y,dn as b,dt as x,ft as S,gn as C,kn as w,kt as T,lt as E,mn as D,mt as O,nt as k,on as A,p as j,pt as M,rt as N,sn as P,sr as F,st as I,tn as L,tt as R,ut as ee,vn as z,wn as B,zt as te}from"./ui-DrdqFaQt.js";import{t as ne}from"./phone-CHkEf-Dz.js";import{Mt as re,Q as ie,X as ae,Z as oe,ft as se,kt as ce,t as le,yt as ue}from"./index-BRDn-5v_.js";import{n as de}from"./RunnerView-CDCp61aq.js";var fe={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`}]]};fe.node;var pe=p(fe),me={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`}]]};me.node;var he=p(me),ge={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`}]]};ge.node;var V=p(ge),_e={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`}]]};_e.node;var ve=p(_e),ye=F(),H=e(t(),1),U=e(n(),1),be=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function xe({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:i,children:a}){return(0,U.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:A(`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)(L,{className:`size-5`}):a})}function Se({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:A(`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 Ce({voice:e,view:t,video:n,className:r}){let i=e.state===`live`,a=e.state===`connecting`,[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!1);(0,H.useEffect)(()=>{s(i?Date.now():null)},[i]);let u=async()=>{l(!1),await e.start(),n&&await e.startCamera()},d=()=>{e.stop(),l(!0)},f=n||e.camera,p=[...e.captions].reverse().find(e=>e.who===`bot`),m=[...e.captions].reverse().find(e=>e.who===`me`),h=e.speaking?b(`talk.speaking`):e.listening?b(`talk.listening`):i?b(`talk.live`):a?b(`talk.connecting`):c?b(`video.ended`):``;return(0,U.jsxs)(`section`,{className:A(`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??``}),h?(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[i?(0,U.jsx)(`span`,{className:A(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,h]}):null,(0,U.jsx)(xe,{since:o})]}),(0,U.jsxs)(`div`,{className:A(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,f?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!f&&i&&e.captions.length?`h-[38%]`:f?``:`flex-1`),children:[(0,U.jsxs)(`div`,{className:A(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!f&&`hidden`),children:[(0,U.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:A(`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:b(`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:[b(`video.you`),e.muted?(0,U.jsx)(re,{className:`ml-1.5 inline size-3`}):null]})]}),(0,U.jsxs)(`div`,{className:A(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,f?`bg-neutral-900`:`bg-transparent`,f&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,U.jsx)(`div`,{className:A(`rounded-full transition-shadow duration-500`,!f&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!f&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,U.jsx)(se,{kind:t?.wizard.avatar??`round`,size:f?140:200,fluffy:!0,interactive:!1})}),f?(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]})]}),i&&!f?(0,U.jsx)(Se,{voice:e}):i&&(p||m)?(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:[m?(0,U.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:m.text}):null,p?(0,U.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:p.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:i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(W,{label:b(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,U.jsx)(re,{className:`size-5`}):(0,U.jsx)(w,{className:`size-5`})}),(0,U.jsx)(W,{label:b(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,U.jsx)(D,{className:`size-5`}):(0,U.jsx)(V,{className:`size-5`})}),e.camera&&be?(0,U.jsx)(W,{label:b(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,U.jsx)(C,{className:`size-5`})}):null,(0,U.jsx)(W,{label:b(`video.leave`),danger:!0,onClick:d,children:(0,U.jsx)(ce,{className:`size-5`})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:a||!t?.talk,onClick:()=>void u(),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:[a?(0,U.jsx)(L,{className:`size-4`}):n?(0,U.jsx)(D,{className:`size-5`}):(0,U.jsx)(w,{className:`size-5`}),b(c?`video.rejoin`:n?`video.join`:`talk.start`)]}),!c&&!e.error?(0,U.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:b(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var we=e=>v[e.kind]!==`device`,Te=1024,Ee=4e3;function De(e,t){return e?e.length>t?`${e.slice(0,t)} …`:e:``}function Oe(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: ${P(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}: ${De(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=we(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?` = ${De(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}": ${De(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 ke(e,t,n,r){let[i,a]=(0,H.useState)(`off`),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!1),[u,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(`environment`),[_,v]=(0,H.useState)(!1),[y,x]=(0,H.useState)([]),S=(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=S.current;if(!T.current||!e||e.videoWidth===0)return null;let t=Math.min(1,Te/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,S.current&&(S.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),S.current&&(S.current.srcObject=e,await S.current.play().catch(()=>void 0)),m(!0)}catch(e){s(e.name===`NotAllowedError`?b(`talk.cameraDenied`):e.message)}},[]),R=(0,H.useCallback)(async()=>{let e=h===`user`?`environment`:`user`;I(),await L(e)},[h,I,L]),ee=(0,H.useCallback)(()=>{v(e=>{for(let t of k.current?.getAudioTracks()??[])t.enabled=e;return!e})},[]),z=(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)(()=>()=>z(),[z]);let B=(0,H.useCallback)(async(t,n)=>{let r=A.current,i=j.current,a=M.current;switch(t){case`get_state`:return r?Oe(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 d.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&&we(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 d.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]),te=(0,H.useCallback)(async()=>{if(!E.current){s(null),x([]),a(`connecting`);try{let t=await d.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>Ee?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`;x(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{}B(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=Oe(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&&z()};let c=await r.createOffer();await r.setLocalDescription(c);let u=await fetch(t.endpoint,{method:`POST`,headers:{authorization:`Bearer ${t.clientSecret}`,"content-type":`application/sdp`},body:c.sdp});if(!u.ok)throw Error(`${b(`talk.failed`)} (${u.status})`);await r.setRemoteDescription({type:`answer`,sdp:await u.text()})}catch(e){z(),s(e.name===`NotAllowedError`?b(`chat.micDenied`):e.message),a(`error`)}}},[e,B,F,P,z]);return(0,H.useEffect)(()=>{if(i!==`live`||!t)return;let e=Oe(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:u,start:te,stop:z,camera:p,facing:h,startCamera:L,stopCamera:I,flipCamera:R,muted:_,toggleMute:ee,captions:y,video:S}}var G=(e,t,n)=>({key:e,who:`bot`,node:t,...n}),K=(e,t,n)=>({key:e,who:`me`,node:t,...n}),Ae=(0,H.createContext)(null),q=(0,H.createContext)(null);function je(){return(0,H.useContext)(q)?.voice??null}function Me({children:e}){let t=(0,H.useContext)(Ae);return t?(0,ye.createPortal)(e,t):null}function Ne({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)(Ae.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},[]);ie(!!n?.readAloud,n?.lang??y,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)(se,{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:A(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?A(`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)(B,{className:`size-3`}),` `,b(`chat.change`)]}):null]},e.key)))}function Pe(){return(0,U.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":b(`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:i,busy:a}){return(0,U.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||a,onClick:e,className:A(`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:[a?(0,U.jsx)(L,{className:`size-4`}):null,t]})}function Fe({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:a,inputRef:o,onSend:l}){let[u,d]=(0,H.useState)(e),f=(0,H.useRef)(null),p=o??f,_=(0,H.useContext)(q),v=j(u,d,{endpoint:_?`/api/runs/${_.runId}/transcribe`:void 0}),y=!!_&&v.supported&&!a;(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)(()=>{!c&&!a&&p.current?.focus()},[a,p]);let x=()=>{i||a||(v.listening&&v.toggle(),l(u)!==!1&&d(``))},S=v.listening?b(`chat.listening`):v.processing?b(`chat.transcribing`):t,C=_?.voice??null,T=!!_?.call,E=_&&!T&&(ae||y||C)?(0,U.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[C?(0,U.jsx)(m,{label:b(C.state===`live`?`talk.stop`:C.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":C.state===`live`,disabled:C.state===`connecting`,onClick:()=>C.state===`live`?C.stop():void C.start(),className:A(`size-9`,C.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,C.state===`off`&&_.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:C.state===`connecting`?(0,U.jsx)(L,{className:`size-4`}):C.state===`live`?(0,U.jsx)(ce,{className:`size-4`}):(0,U.jsx)(ne,{className:`size-4`})}):null,C?.state===`live`?(0,U.jsx)(m,{label:b(C.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":C.camera,onClick:()=>C.camera?C.stopCamera():void C.startCamera(),className:A(`size-9`,C.camera&&`text-ink`),children:C.camera?(0,U.jsx)(D,{className:`size-4`}):(0,U.jsx)(V,{className:`size-4`})}):null,ae?(0,U.jsx)(m,{label:b(_.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":_.readAloud,onClick:()=>_.setReadAloud(!_.readAloud),className:A(`size-9`,_.readAloud&&`text-ink`),children:_.readAloud?(0,U.jsx)(ue,{className:`size-4`}):(0,U.jsx)(ve,{className:`size-4`})}):null,y?(0,U.jsx)(m,{label:b(v.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":v.listening,disabled:v.processing,onClick:v.toggle,className:A(`size-9`,v.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:v.processing?(0,U.jsx)(L,{className:`size-4`}):v.listening?(0,U.jsx)(h,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,U.jsx)(w,{className:`size-4`})}):null]}):null;return(0,U.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),x()},children:[C&&!T?(0,U.jsx)(`video`,{ref:C.video,muted:!0,playsInline:!0,autoPlay:!0,className:A(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,C.camera?`block`:`hidden`)}):null,(0,U.jsxs)(`div`,{className:A(`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`,a&&`opacity-60`),children:[E,n?(0,U.jsx)(g,{ref:p,minRows:1,maxRows:6,value:u,disabled:a,placeholder:S,autoCapitalize:`sentences`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!c&&!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:p,...r,value:u,disabled:a,placeholder:S,enterKeyHint:`send`,onChange:e=>d(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":b(`chat.send`),title:b(`chat.send`),disabled:i||a,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:i?(0,U.jsx)(L,{className:`size-4`}):(0,U.jsx)(s,{className:`size-4`})})]}),v.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:v.error===`denied`?b(`chat.micDenied`):v.error}):T?null:C?.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:C.error}):C?.state===`live`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:C.speaking?b(`talk.speaking`):C.listening?b(`talk.listening`):b(`talk.live`)}):_?.talk&&C?.state===`off`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:b(`talk.hint`)}):null]})}function Q({placeholder:e=b(`chat.above`)}){return(0,U.jsx)(Me,{children:(0,U.jsx)(Fe,{disabled:!0,placeholder:e,onSend:()=>!1})})}function Ie(e){let t=v[e.kind];return t===`typed`&&!e.scan?`typed`:t===`tapped`?`tapped`:`control`}var Le=e=>e==null||e===``||Array.isArray(e)&&e.length===0;function Re(e,t){let n=e.kind===`toggle`||e.kind===`connection`||e.kind===`list`;if(Le(t))return e.required&&!n?b(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return b(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return b(`chat.badUrl`)}return e.kind===`number`&&!Number.isFinite(Number(r.replace(`,`,`.`)))?b(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?b(`run.filesMin`,{n:t.length,min:e.min}):null}function ze(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 Be({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 Ve({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 He({field:e,value:t,runId:n}){if(e.kind===`connection`)return(0,U.jsx)(U.Fragment,{children:typeof t==`string`&&t?t:b(`chat.connected`)});if(e.kind===`list`)return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(f,{className:`size-4`}),` `,b(`chat.checked`)]});if(e.kind===`toggle`)return(0,U.jsx)(U.Fragment,{children:b(t===!0?`run.yes`:`run.no`)});if(Le(t))return(0,U.jsx)(`span`,{className:`italic opacity-80`,children:b(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,U.jsx)(U.Fragment,{children:t.join(`, `)});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(y,{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:r(`/api/runs/${n}/assets/${t}`),alt:``,className:A(`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)(a,{className:`size-4`}),` `,b(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)(w,{className:`size-4`}),` `,b(`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:b(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,U.jsx)(U.Fragment,{children:String(t)})}}function Ue(e,t,n,r,i,a){let o=[G(t,(0,U.jsx)(Ve,{step:e,only:a}))];for(let e of i)a||o.push(G(`${t}:${e.id}`,(0,U.jsx)(Be,{field:e}))),o.push(K(`${t}:${e.id}:a`,(0,U.jsx)(He,{field:e,value:n[e.id],runId:r})));return o}var We=(e,t)=>e.fields.filter(e=>!e.when&&!T(e)||t[e.id]!==void 0&&t[e.id]!==null);function Ge(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(...Ue(r,i,e.values,e.id,We(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`,b(`run.accept`))))}let r=n.at(-1);return t&&r?.who===`me`&&(n[n.length-1]={...r,onEdit:t}),n}function Ke(e,t){return e.fields.filter(e=>!T(e)||t.decidedFields?.includes(e.id)).map(e=>t.options?.[e.id]?.length?{...e,options:t.options[e.id]}:e)}function qe({view:e,run:t,step:n,before:r}){let i=(0,H.useMemo)(()=>Ke(n,e),[n,e]),a=e.known??{},[s,c]=(0,H.useState)(()=>R(n,e)),[l,u]=(0,H.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?o(Ke(n,e),e.known??{},R(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),_=o(i,a,s),v=_.filter(e=>l.includes(e.id)),y=_.find(e=>!l.includes(e.id)),x=i.length===1?i[0]:void 0,S=v.at(-1),C=S?()=>u(e=>e.filter(e=>e!==S.id)):void 0;(0,H.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=o(i,a,s),r=n.findIndex(t=>e.includes(t.id));r>=0&&(u(n.slice(0,r).map(e=>e.id)),f(t.fieldErrors))},[t.fieldErrors]);let w=e=>{t.submitPage(n.id,e).then(g)},T=(0,H.useContext)(q),D=(0,H.useRef)(s);D.current=s;let O=T?.bindPage,k=(0,H.useRef)(w);k.current=w,(0,H.useEffect)(()=>{if(!O)return;let e=o(i,a,s);return O({step:n,fields:e,values:s,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?Re(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(D.current)}),()=>O(null)},[O,n,i,a,s]);let A=e=>{if(!y)return!1;let t=Re(y,e);if(t)return f({[y.id]:t}),!1;let n={...s,[y.id]:e},r=[...l,y.id];return c(n),u(r),f({}),o(i,a,n).some(e=>!r.includes(e.id))||w(n),!0},j=[...r.map(e=>l.length?{...e,onEdit:void 0}:e),...Ue(n,`now:${n.id}`,s,e.id,v,x).map((e,t,n)=>t===n.length-1&&e.who===`me`&&y?{...e,onEdit:C}:e)];y?(Ie(y)===`control`?j.push(G(`now:${n.id}:${y.id}:control`,(0,U.jsx)(E,{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})):x||j.push(G(`now:${n.id}:${y.id}`,(0,U.jsx)(Be,{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)(Pe,{}))):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:b(`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||b(`run.next`)}),C?(0,U.jsx)(Z,{onClick:C,disabled:t.busy,children:b(`run.back`)}):null]})));else{let r=Ie(y),i=!y.required&&y.kind!==`connection`&&y.kind!==`list`?(0,U.jsx)(Z,{onClick:()=>A(void 0),children:b(`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)(Me,{children:(0,U.jsx)(Fe,{initial:Le(e)?``:String(e),multiline:y.kind===`textarea`,placeholder:y.placeholder||(x?y.label:b(`chat.placeholder`)),inputProps:Je(y),busy:t.busy,onSend:e=>A(ze(y,e))},y.id)})}else if(r===`tapped`)j.push(G(`now:${n.id}:${y.id}:replies`,(0,U.jsx)(Ye,{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:b(`chat.send`)}),i]})))}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:e.wizard.avatar,lines:j}),M]})}function Je(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 ee(e)}}function Ye({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:b(`run.no`)}),(0,U.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:b(`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:e},e)),(0,U.jsx)(Z,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?b(`chat.send`):b(`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:e},e)),e.required?null:(0,U.jsx)(Z,{onClick:()=>r(void 0),children:b(`chat.skip`)})]})}function Xe({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(),[i,a]=(0,H.useState)(Date.now());(0,H.useEffect)(()=>{let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[]);let o=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),s=o.at(-1),c=[...o].reverse().find(Qe),l=[...new Set(o.map(e=>e.asset).filter(e=>!!e))];return(0,U.jsxs)(`div`,{className:A(`flex max-w-full flex-col gap-1`,c?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??b(`run.working`),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(Pe,{}),(0,U.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??b(`run.working`)}),(0,U.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:b(`run.elapsed`,{s:Math.max(0,Math.round((i-n)/1e3))})})]}),s&&s!==c?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,U.jsx)(z,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,U.jsx)(`span`,{className:`truncate`,children:P(s)})]}):null,c&&e.status===`running`?(0,U.jsx)(et,{runId:e.id,event:c}):null,l.length?(0,U.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:l.slice(-6).map(t=>(0,U.jsx)(`img`,{src:r(`/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 Ze=new Set([`opens`,`clicks`,`clicksOn`,`types`,`typesText`,`selects`,`scrolls`,`presses`,`goesBack`,`waitsForPage`,`fastLoop`,`looksAtPage`,`personDrives`,`agentDrives`]);function Qe(e){return!!e.note&&Ze.has(e.note.code)}var $e=1e4;function et({runId:e,event:t}){let[n,r]=(0,H.useState)(null),[a,o]=(0,H.useState)(`agent`),[s,c]=(0,H.useState)(!1),l=t.note?.code;if((0,H.useEffect)(()=>{l===`personDrives`?o(`person`):l===`agentDrives`&&o(`agent`)},[l]),(0,H.useEffect)(()=>{let t=()=>d.get(`/api/runs/${e}/browser/seat`).then(e=>o(e.seat)).catch(()=>void 0);if(t(),a!==`person`)return;let n=setInterval(t,$e);return()=>clearInterval(n)},[e,a]),n!==null&&n>=t.id)return null;let u=a===`person`,f=async()=>{c(!0);try{let t=await d.post(`/api/runs/${e}/browser/seat`,{to:u?`agent`:`person`});o(t.seat)}catch{}finally{c(!1)}};return(0,U.jsx)(i,{runId:e,driving:u,caption:P(t),hint:b(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,U.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>void f(),className:A(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,u?`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:[u?(0,U.jsx)(he,{className:`size-3.5`}):(0,U.jsx)(pe,{className:`size-3.5`}),b(u?`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 tt({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)(I,{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)(x,{runId:e.id,list:t}):(0,U.jsx)(M,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&u.push(G(`review-error`,t.error,{tone:`error`}));let d=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)(f,{className:`size-4`}),` `,b(`run.accept`)]}),d&&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}),d?(0,U.jsx)(Me,{children:(0,U.jsx)(Fe,{multiline:!0,inputRef:l,busy:t.busy,placeholder:o.length>1&&!s?b(`run.feedbackPick`):b(`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 nt({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)(N,{base:o,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,U.jsx)(I,{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:b(`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)(S,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,U.jsx)(M,{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)(le,{runId:e.id,title:`${n.title} · ${e.wizard.title}`,initial:e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null}):null,i?(0,U.jsxs)(Z,{onClick:i,children:[(0,U.jsx)(_,{className:`size-4`}),` `,b(`run.again`)]}):null,e.canBack?(0,U.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:b(`run.back`)}):null,e.keeps?(0,U.jsx)(`span`,{className:`ml-1`,children:(0,U.jsx)(O,{runId:e.id})}):null]}))),(0,U.jsx)(J,{avatar:e.wizard.avatar,lines:s})}function rt({runId:e,onRestart:t,onView:n,header:r,footer:i,talk:a=!1,call:o=!1}){let s=de(e),{view:c}=s,[d,f]=(0,H.useState)(null),p=ke(e,c,s,d);(0,H.useEffect)(()=>{n?.(c)},[c,n]);let[m,h]=oe(),g=(0,H.useMemo)(()=>({runId:e,lang:c?.lang??y,readAloud:m,setReadAloud:h,voice:c?.talk?p:null,talk:a,call:!!o,bindPage:f}),[e,c?.lang,c?.talk,m,h,p,a,o]);u(c?.status===`running`&&!c.ask),k(c);let[v,x]=(0,H.useState)({}),[S,C]=(0,H.useState)(null);(0,H.useEffect)(()=>{c&&c.status!==`running`&&C(null)},[c]);let w;if(s.notFound)w=(0,U.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:b(`run.notFound`)});else if(!c)w=(0,U.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,U.jsx)(L,{})});else{let e=c.step,n=c.status===`waiting_input`,r=Ge(c,c.canBack&&n&&!s.busy?()=>void s.back():void 0);if(c.status===`running`&&c.ask)w=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:c.wizard.avatar,lines:[...r,G(`ask:${c.ask.id}`,(0,U.jsx)(te,{runId:c.id,ask:c.ask}),{wide:!0})]}),(0,U.jsx)(Q,{})]});else if(c.status===`running`)w=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:c.wizard.avatar,lines:[...r,...S?[K(`note`,S)]:[],G(`working:${e?.id}`,(0,U.jsx)(Xe,{view:c}),{wide:c.events.some(t=>t.stepId===e?.id&&Qe(t))?`most`:void 0})]}),(0,U.jsx)(Q,{placeholder:b(`run.working`)})]});else if(c.status===`failed`)w=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:c.wizard.avatar,lines:[...r,G(`failed`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:b(`run.failed`)}),c.error?(0,U.jsx)(`span`,{className:`mt-0.5 block`,children:(0,U.jsx)(l,{text:c.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{primary:!0,busy:s.busy,onClick:()=>void s.retry(),children:[(0,U.jsx)(_,{className:`size-4`}),` `,b(`run.retry`)]}),c.canBack?(0,U.jsx)(Z,{onClick:()=>void s.back(),disabled:s.busy,children:b(`run.back`)}):null]}))]}),(0,U.jsx)(Q,{})]});else if(c.status===`cancelled`)w=(0,U.jsx)(J,{avatar:c.wizard.avatar,lines:[...r,G(`cancelled`,b(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,U.jsxs)(Z,{primary:!0,onClick:t,children:[(0,U.jsx)(_,{className:`size-4`}),` `,b(`run.again`)]}))]:[]]});else if(e?.type===`page`)w=(0,U.jsx)(qe,{view:c,run:s,step:e,before:r},e.id);else if(e?.type===`review`){let t=c.shown.map(e=>e.output?.at??``).join(`|`);w=(0,U.jsx)(tt,{view:c,run:s,step:e,before:r,asked:v[e.id]??[],onNote:t=>{C(t),x(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else w=e?.type===`result`?(0,U.jsx)(nt,{view:c,run:s,step:e,before:r,onRestart:t}):(0,U.jsx)(J,{avatar:c.wizard.avatar,lines:r})}return o?(0,U.jsx)(q.Provider,{value:g,children:(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,U.jsx)(Ce,{voice:p,view:c,video:o===`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)(Ne,{footer:i,children:w})})]})}):(0,U.jsx)(q.Provider,{value:g,children:(0,U.jsx)(Ne,{header:r,footer:i,children:w})})}export{J as a,Z as i,Ne as n,X as o,Q as r,je as s,rt as t};