wizards 0.2.48 → 0.2.50

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 (119) hide show
  1. package/README.md +2 -1
  2. package/apps/runtime/dist/apple/wizards-apple +0 -0
  3. package/apps/runtime/dist/cli/status.js +1 -1
  4. package/apps/runtime/dist/db/migrations/tenant/0013_run_origin.sql +1 -0
  5. package/apps/runtime/dist/db/migrations/tenant/meta/0013_snapshot.json +3139 -0
  6. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  7. package/apps/runtime/dist/db/schema.js +5 -0
  8. package/apps/runtime/dist/docs/user/meta.json +1 -0
  9. package/apps/runtime/dist/docs/user/models.md +25 -0
  10. package/apps/runtime/dist/docs/user/test-and-share.md +7 -1
  11. package/apps/runtime/dist/docs/user/wordpress.md +103 -0
  12. package/apps/runtime/dist/engine/device.js +182 -0
  13. package/apps/runtime/dist/engine/events.js +3 -0
  14. package/apps/runtime/dist/engine/input.js +3 -0
  15. package/apps/runtime/dist/engine/prepare.js +1 -0
  16. package/apps/runtime/dist/engine/requirements.js +6 -109
  17. package/apps/runtime/dist/engine/runner.js +1 -0
  18. package/apps/runtime/dist/engine/steps.js +2 -1
  19. package/apps/runtime/dist/env.js +1 -1
  20. package/apps/runtime/dist/harness/apple.js +258 -0
  21. package/apps/runtime/dist/harness/model.js +3 -1
  22. package/apps/runtime/dist/mcp/auth.js +3 -0
  23. package/apps/runtime/dist/mcp/scopes.js +11 -2
  24. package/apps/runtime/dist/media/transcribe.js +6 -1
  25. package/apps/runtime/dist/models.js +63 -9
  26. package/apps/runtime/dist/routes/api.js +232 -1
  27. package/apps/runtime/dist/routes/plugins.js +6 -2
  28. package/apps/runtime/dist/routes/runs.js +65 -3
  29. package/apps/runtime/dist/routes/studio.js +11 -1
  30. package/apps/runtime/dist/services/api.js +244 -0
  31. package/apps/runtime/dist/services/engenty-shapes.js +1 -1
  32. package/apps/runtime/dist/services/package.js +77 -9
  33. package/apps/runtime/dist/services/runs.js +4 -3
  34. package/apps/runtime/dist/services/site.js +262 -0
  35. package/apps/web/dist/assets/AboutDialog-BRjyFW7N.js +1 -0
  36. package/apps/web/dist/assets/ChangelogDialog-DU-fYMNG.js +1 -0
  37. package/apps/web/dist/assets/ChatView-Chv8rH9v.js +10 -0
  38. package/apps/web/dist/assets/EditorPage-BEEiRjpL.js +3 -0
  39. package/apps/web/dist/assets/FlowPreview-911P5v6v.js +1 -0
  40. package/apps/web/dist/assets/{Harness-DAR1u4Dk.js → Harness-DE9pS-ZP.js} +2 -2
  41. package/apps/web/dist/assets/Marketplace-DfoRgS49.js +2 -0
  42. package/apps/web/dist/assets/NewWizardPage-BwZ39he_.js +1 -0
  43. package/apps/web/dist/assets/ProjectPage-BB8feiW1.js +2 -0
  44. package/apps/web/dist/assets/PublicRunner-JsgGibnC.js +1 -0
  45. package/apps/web/dist/assets/ReadOnly-ClY8xMQS.js +1 -0
  46. package/apps/web/dist/assets/RunDrawer-CxJtIQlP.js +4 -0
  47. package/apps/web/dist/assets/RunnerView-DvIBDzr1.js +1 -0
  48. package/apps/web/dist/assets/SettingsPage-DJBQvyom.js +1 -0
  49. package/apps/web/dist/assets/SetupPage-BVqbshmT.js +1 -0
  50. package/apps/web/dist/assets/SharePage-ChQxeHFC.js +1 -0
  51. package/apps/web/dist/assets/brand-CNF5NxD9.js +2 -0
  52. package/apps/web/dist/assets/changelog-OdE5-SsX.js +1 -0
  53. package/apps/web/dist/assets/circle-alert-r2qc1Vej.js +1 -0
  54. package/apps/web/dist/assets/engenty-eXZ-EAwd.js +1 -0
  55. package/apps/web/dist/assets/esm-cYET-omK.js +7 -0
  56. package/apps/web/dist/assets/{fluffy-engenty-D7rFrNcJ.js → fluffy-engenty-ClRou7yu.js} +1 -1
  57. package/apps/web/dist/assets/index-CDgxPZY_.js +11 -0
  58. package/apps/web/dist/assets/jsx-runtime-BNakU3Ej.js +1 -0
  59. package/apps/web/dist/assets/lock-N-C6-ZeG.js +1 -0
  60. package/apps/web/dist/assets/logo-C4V2_3Ar.js +1 -0
  61. package/apps/web/dist/assets/oss-credits-BQQX0kvk.js +1 -0
  62. package/apps/web/dist/assets/pdfmake-Cx9scTbD.js +228 -0
  63. package/apps/web/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
  64. package/apps/web/dist/assets/session-Cpg5S8B3.js +1 -0
  65. package/apps/web/dist/assets/settings-menu-B763_KXf.js +1 -0
  66. package/apps/web/dist/assets/ui-DKcggL84.js +133 -0
  67. package/apps/web/dist/assets/upload-D24SDj7W.js +1 -0
  68. package/apps/web/dist/assets/useMutation-DKyQXgyj.js +1 -0
  69. package/apps/web/dist/assets/vfs_fonts-DllDSYt1.js +1 -0
  70. package/apps/web/dist/assets/volume-2-C-Y7-S4b.js +1 -0
  71. package/apps/web/dist/embed.js +57 -8
  72. package/apps/web/dist/index.html +11 -15
  73. package/apps/web/dist/mcp/flow.html +434 -206
  74. package/modules/calls/dist/client.css +1 -1
  75. package/modules/sms/dist/client.css +1 -1
  76. package/modules/whatsapp/dist/client.css +1 -1
  77. package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +2 -0
  78. package/node_modules/@engenty-wizards/shared/dist/fit.d.ts +71 -0
  79. package/node_modules/@engenty-wizards/shared/dist/fit.js +381 -0
  80. package/package.json +1 -1
  81. package/apps/web/dist/assets/AboutDialog-CuiVGknS.js +0 -1
  82. package/apps/web/dist/assets/ChangelogDialog-DCEQD3Jd.js +0 -1
  83. package/apps/web/dist/assets/ChatView-DFxrG2PD.js +0 -10
  84. package/apps/web/dist/assets/EditorPage-B5rzKNMy.js +0 -3
  85. package/apps/web/dist/assets/FlowPreview-CYoR5DRY.js +0 -1
  86. package/apps/web/dist/assets/HomePage-BnYdh_Nx.js +0 -1
  87. package/apps/web/dist/assets/Marketplace-BDQNwMDB.js +0 -2
  88. package/apps/web/dist/assets/NewWizardPage-DztTEUlG.js +0 -1
  89. package/apps/web/dist/assets/ProjectPage-B7-Lqx9a.js +0 -2
  90. package/apps/web/dist/assets/PublicRunner-CaH3bHHd.js +0 -1
  91. package/apps/web/dist/assets/ReadOnly-DnB47DQC.js +0 -1
  92. package/apps/web/dist/assets/RunDrawer-Dv0KRqGA.js +0 -4
  93. package/apps/web/dist/assets/RunnerView-Bzwv1u4j.js +0 -2
  94. package/apps/web/dist/assets/SettingsPage-oVO7CKvc.js +0 -1
  95. package/apps/web/dist/assets/SetupPage-D--8cWA0.js +0 -1
  96. package/apps/web/dist/assets/SharePage-DjU08q7T.js +0 -1
  97. package/apps/web/dist/assets/ThemeSwitch-C3EJRN06.js +0 -1
  98. package/apps/web/dist/assets/arrow-right-F7X_SjK9.js +0 -1
  99. package/apps/web/dist/assets/changelog-BRoVI_JJ.js +0 -1
  100. package/apps/web/dist/assets/circle-alert-DdpaAYgd.js +0 -1
  101. package/apps/web/dist/assets/definition-CHacJYmI.js +0 -56
  102. package/apps/web/dist/assets/engenty-Cm8yZLON.js +0 -1
  103. package/apps/web/dist/assets/esm-rJY59Ixx.js +0 -7
  104. package/apps/web/dist/assets/external-link-Dfc1VFvS.js +0 -1
  105. package/apps/web/dist/assets/index-CX_yxZVQ.js +0 -79
  106. package/apps/web/dist/assets/jsx-runtime-D3jfb0Ew.js +0 -1
  107. package/apps/web/dist/assets/lock-Bu1wDFs8.js +0 -1
  108. package/apps/web/dist/assets/logo-C80CWCDM.js +0 -1
  109. package/apps/web/dist/assets/oss-credits-CIxnNZor.js +0 -1
  110. package/apps/web/dist/assets/react-dom-DenslgJm.js +0 -1
  111. package/apps/web/dist/assets/refresh-cw-BUDPOT39.js +0 -1
  112. package/apps/web/dist/assets/session-Blj2os_v.js +0 -1
  113. package/apps/web/dist/assets/settings-menu-BvxRnNtf.js +0 -1
  114. package/apps/web/dist/assets/sparkles-DWGJluyV.js +0 -1
  115. package/apps/web/dist/assets/trash-D9UB6TtS.js +0 -1
  116. package/apps/web/dist/assets/ui-GsuU9WTj.js +0 -9
  117. package/apps/web/dist/assets/upload-BngimDBR.js +0 -1
  118. package/apps/web/dist/assets/useMutation-DKcIz55V.js +0 -1
  119. package/apps/web/dist/assets/volume-2-BZju_bOP.js +0 -1
@@ -0,0 +1,381 @@
1
+ import { conditionsOf, dataRef, isOtherwise, listRef, pluginToolOf, ruleMatches, templateRefs, } from "./definition.js";
2
+ /** What the standalone runner can hand over of a thinking step's text itself. */
3
+ const BASE_FORMATS = new Set(["html", "md", "txt", "csv", "json"]);
4
+ /** Tools the standalone runner has no way to run; `pages` only reads the space's pages, which it lacks. */
5
+ const HARD_TOOLS = new Set(["web_search", "browser", "sandbox", "image"]);
6
+ /**
7
+ * Tools the standalone runner runs itself: a WordPress site reads a public page and calls a
8
+ * public API through its own abilities (the plugin's `Engenty_Abilities`). No need at all.
9
+ */
10
+ const RUNNER_TOOLS = new Set(["web_fetch", "http"]);
11
+ const MEMORY_RE = /\{\{\s*memory\b/;
12
+ /** The templates a step renders: what may name lists or the memory. */
13
+ function templatesOf(step) {
14
+ switch (step.type) {
15
+ case "agent":
16
+ return [step.instructions, step.call ? JSON.stringify(step.call.input) : ""];
17
+ case "generate":
18
+ return [step.prompt, step.options?.style ?? ""];
19
+ case "film":
20
+ return [step.brief];
21
+ case "widget":
22
+ case "surface":
23
+ return Object.values(step.data).map((ref) => `{{${dataRef(ref)}}}`);
24
+ default:
25
+ return [];
26
+ }
27
+ }
28
+ /** Whether a thinking step that reads files may run after `index`. */
29
+ function readsFilesLater(def, index) {
30
+ return def.steps
31
+ .slice(index + 1)
32
+ .some((s) => (s.type === "agent" && !s.call) || s.type === "generate" || s.type === "film");
33
+ }
34
+ /** What one step wants beyond a text model. */
35
+ export function needs(step, def) {
36
+ const out = [];
37
+ const add = (need, hard) => {
38
+ const found = out.find((n) => n.need === need);
39
+ if (found) {
40
+ found.hard ||= hard;
41
+ }
42
+ else {
43
+ out.push({ stepId: step.id, need, hard });
44
+ }
45
+ };
46
+ const index = def.steps.indexOf(step);
47
+ for (const template of templatesOf(step)) {
48
+ if (MEMORY_RE.test(template)) {
49
+ add("memory", true);
50
+ }
51
+ if (templateRefs(template).some((ref) => ref.startsWith("lists."))) {
52
+ add("lists", true);
53
+ }
54
+ }
55
+ switch (step.type) {
56
+ case "page":
57
+ for (const field of step.fields) {
58
+ switch (field.kind) {
59
+ case "audio":
60
+ add("field:audio", Boolean(field.required));
61
+ break;
62
+ case "connection":
63
+ add("field:connection", true);
64
+ break;
65
+ case "slot":
66
+ add("field:slot", true);
67
+ break;
68
+ case "list":
69
+ add("lists", true);
70
+ break;
71
+ case "location":
72
+ add("field:location", false);
73
+ break;
74
+ case "image":
75
+ add("field:image", false);
76
+ break;
77
+ case "file":
78
+ if (readsFilesLater(def, index)) {
79
+ add("field:file-read", true);
80
+ }
81
+ else {
82
+ add("field:file", false);
83
+ }
84
+ break;
85
+ default:
86
+ break;
87
+ }
88
+ if (field.optionsFrom &&
89
+ listRef(dataRef(field.optionsFrom).split(".").slice(0, 2).join("."))) {
90
+ add("lists", true);
91
+ }
92
+ }
93
+ break;
94
+ case "agent": {
95
+ const tools = step.call ? [...step.tools, step.call.tool] : step.tools;
96
+ for (const tool of tools) {
97
+ const plugin = pluginToolOf(tool);
98
+ if (plugin) {
99
+ add(`plugin:${plugin.plugin}`, true);
100
+ }
101
+ else if (RUNNER_TOOLS.has(tool)) {
102
+ // The site runs it.
103
+ }
104
+ else if (HARD_TOOLS.has(tool)) {
105
+ add(`tool:${tool}`, true);
106
+ }
107
+ else {
108
+ add(`tool:${tool}`, false);
109
+ }
110
+ }
111
+ if (step.mcp?.length) {
112
+ add("mcp", true);
113
+ }
114
+ if (step.connections?.length) {
115
+ add("connections", true);
116
+ }
117
+ if (step.each) {
118
+ if (listRef(dataRef(step.each))) {
119
+ add("lists", true);
120
+ }
121
+ else {
122
+ add("each", false);
123
+ }
124
+ }
125
+ break;
126
+ }
127
+ case "generate":
128
+ // A document or a dashboard is HTML a text model writes in one call: the standalone runner
129
+ // makes it too, and the browser prints it. Media need a model of their own.
130
+ if (step.asset !== "document" && step.asset !== "dashboard") {
131
+ add(`asset:${step.asset}`, true);
132
+ }
133
+ break;
134
+ case "film":
135
+ add("film", true);
136
+ break;
137
+ case "widget":
138
+ add(step.video ? "widget:video" : "widget", true);
139
+ break;
140
+ case "surface":
141
+ if (Object.values(step.data).some((ref) => listRef(dataRef(ref)))) {
142
+ add("lists", true);
143
+ }
144
+ break;
145
+ case "review":
146
+ if (step.show.some((ref) => listRef(ref))) {
147
+ add("lists", true);
148
+ }
149
+ break;
150
+ case "result":
151
+ for (const d of step.deliverables) {
152
+ if (listRef(d.from)) {
153
+ add("lists", true);
154
+ continue;
155
+ }
156
+ const from = def.steps.find((s) => s.id === d.from);
157
+ // What a media step, a widget or a film makes is the step's own need.
158
+ const written = from?.type === "agent" ||
159
+ (from?.type === "generate" && (from.asset === "document" || from.asset === "dashboard"));
160
+ if (!written) {
161
+ continue;
162
+ }
163
+ const stays = d.formats.some((f) => BASE_FORMATS.has(f));
164
+ for (const f of d.formats) {
165
+ if (BASE_FORMATS.has(f)) {
166
+ continue;
167
+ }
168
+ // A PDF of a written text the runner makes in the browser (packages/runner/src/pdf.ts);
169
+ // of a document the browser prints the HTML. The others fall away where another stays.
170
+ if (f === "pdf" && from?.type === "agent") {
171
+ continue;
172
+ }
173
+ add(`format:${f}`, f !== "pdf" && !stays);
174
+ }
175
+ }
176
+ break;
177
+ }
178
+ return out;
179
+ }
180
+ /** Whether a wizard runs on its own, with what left out. */
181
+ export function standaloneFit(def) {
182
+ const notes = def.steps.flatMap((s) => needs(s, def));
183
+ if (def.lists?.length && !notes.some((n) => n.need === "lists")) {
184
+ notes.push({ stepId: def.steps[0]?.id ?? "", need: "lists", hard: true });
185
+ }
186
+ if (def.connections?.length && !notes.some((n) => n.need === "connections")) {
187
+ notes.push({ stepId: def.steps[0]?.id ?? "", need: "connections", hard: true });
188
+ }
189
+ const unavoidable = unavoidableSteps(def);
190
+ const blocked = notes.some((n) => n.hard && unavoidable.has(n.stepId));
191
+ return { fit: blocked ? "no" : notes.length ? "less" : "full", notes };
192
+ }
193
+ /** The gallery's capability a need stands for; none for what the gallery has no word for. */
194
+ export function capabilityOf(need) {
195
+ switch (need) {
196
+ case "tool:web_search":
197
+ case "tool:web_fetch":
198
+ return "web";
199
+ case "tool:browser":
200
+ return "browser";
201
+ case "tool:sandbox":
202
+ return "code";
203
+ case "tool:image":
204
+ case "asset:image":
205
+ return "image";
206
+ case "asset:video":
207
+ case "film":
208
+ case "widget:video":
209
+ return "video";
210
+ case "asset:voice":
211
+ return "speech";
212
+ case "field:audio":
213
+ return "listening";
214
+ case "tool:http":
215
+ case "mcp":
216
+ case "connections":
217
+ case "field:connection":
218
+ return "connectors";
219
+ case "field:image":
220
+ case "field:file":
221
+ case "field:file-read":
222
+ return "documents";
223
+ default:
224
+ return null;
225
+ }
226
+ }
227
+ export function standaloneEntry(def) {
228
+ const fit = standaloneFit(def);
229
+ const unavoidable = unavoidableSteps(def);
230
+ const missing = new Set();
231
+ const optional = new Set();
232
+ const needs = new Set();
233
+ const without = new Set();
234
+ for (const note of fit.notes) {
235
+ if (note.need.startsWith("plugin:")) {
236
+ needs.add(note.need.slice("plugin:".length));
237
+ continue;
238
+ }
239
+ if (note.need.startsWith("format:")) {
240
+ without.add(note.need.slice("format:".length));
241
+ continue;
242
+ }
243
+ const capability = capabilityOf(note.need);
244
+ if (!capability) {
245
+ continue;
246
+ }
247
+ if (note.hard && unavoidable.has(note.stepId)) {
248
+ missing.add(capability);
249
+ }
250
+ else {
251
+ optional.add(capability);
252
+ }
253
+ }
254
+ for (const c of missing) {
255
+ optional.delete(c);
256
+ }
257
+ return {
258
+ ...fit,
259
+ missing: [...missing],
260
+ optional: [...optional],
261
+ needs: [...needs].sort(),
262
+ without: [...without],
263
+ };
264
+ }
265
+ // --- the steps every run passes through ------------------------------------------------------
266
+ /** The steps every run passes through: without one of them the end is not reachable. */
267
+ export function unavoidableSteps(def) {
268
+ return def.steps.length ? unavoidableFrom(def, def.steps[0].id, {}) : new Set();
269
+ }
270
+ /**
271
+ * The steps every path from `from` to the end passes through. A rule on an answer in `known`
272
+ * goes one way; a rule on anything else may go either way.
273
+ */
274
+ export function unavoidableFrom(def, from, known) {
275
+ const index = new Map(def.steps.map((s, i) => [s.id, i]));
276
+ const start = index.get(from) ?? 0;
277
+ const successors = (i) => {
278
+ const out = [];
279
+ for (const rule of def.steps[i].next ?? []) {
280
+ if (isOtherwise(rule)) {
281
+ continue;
282
+ }
283
+ const target = rule.goto === "end" ? def.steps.length : (index.get(rule.goto) ?? -1);
284
+ if (rule.ask || !conditionsOf(rule.when).every((c) => c.field in known)) {
285
+ if (target >= 0) {
286
+ out.push(target);
287
+ }
288
+ continue;
289
+ }
290
+ if (ruleMatches(rule, known)) {
291
+ // The first rule that matches decides; nothing after it is tried.
292
+ return target >= 0 ? [...out, target] : out;
293
+ }
294
+ }
295
+ // No rule matching goes on to the "otherwise" step, else the next (or ends after the last).
296
+ out.push(otherwiseIndex(def, i, index));
297
+ return out;
298
+ };
299
+ const reachesEnd = (without) => {
300
+ if (without === start) {
301
+ return false;
302
+ }
303
+ const seen = new Set([start]);
304
+ const queue = [start];
305
+ while (queue.length) {
306
+ const i = queue.shift();
307
+ if (i >= def.steps.length) {
308
+ return true;
309
+ }
310
+ for (const j of successors(i)) {
311
+ if (j !== without && !seen.has(j)) {
312
+ seen.add(j);
313
+ queue.push(j);
314
+ }
315
+ }
316
+ }
317
+ return false;
318
+ };
319
+ return new Set(def.steps.filter((_, i) => !reachesEnd(i)).map((s) => s.id));
320
+ }
321
+ /** Where step `i` goes when none of its rules holds, as an index; the length = the end. */
322
+ export function otherwiseIndex(def, i, index) {
323
+ const goto = def.steps[i].next?.find(isOtherwise)?.goto;
324
+ if (goto === undefined) {
325
+ return i + 1;
326
+ }
327
+ return goto === "end" ? def.steps.length : (index.get(goto) ?? i + 1);
328
+ }
329
+ export function choicesOf(step) {
330
+ return step.fields.flatMap((f) => {
331
+ if (f.kind === "select" && f.options?.length) {
332
+ return [{ field: f.id, values: f.options }];
333
+ }
334
+ if (f.kind === "toggle") {
335
+ return [{ field: f.id, values: [true, false] }];
336
+ }
337
+ return [];
338
+ });
339
+ }
340
+ /**
341
+ * The answers on a page that lead to a step this runtime cannot run: with them the run would
342
+ * stop there, after what came before was paid for. `lacking` says per step what it lacks (model
343
+ * classes on a runtime, needs on a standalone site). The answers given already count; the page's
344
+ * other fields may still go either way. A choice whose every value leads there is left open: the
345
+ * run cannot go around it, and the start already warned. `closedFields` are closed as a whole
346
+ * (no values): a voice note nothing here can listen to.
347
+ */
348
+ export function closedChoicesFor(def, step, values, lacking, closedFields = () => null) {
349
+ const byId = new Map(def.steps.map((s) => [s.id, s]));
350
+ const known = Object.fromEntries(Object.entries(values).filter(([id]) => !step.fields.some((f) => f.id === id)));
351
+ const out = {};
352
+ for (const field of step.fields) {
353
+ const whole = closedFields(field);
354
+ if (whole) {
355
+ out[field.id] = { values: [], classes: whole };
356
+ }
357
+ }
358
+ for (const choice of choicesOf(step)) {
359
+ const closed = { values: [], classes: [] };
360
+ for (const value of choice.values) {
361
+ const ahead = unavoidableFrom(def, step.id, { ...known, [choice.field]: value });
362
+ const missing = [...ahead].flatMap((id) => {
363
+ const s = byId.get(id);
364
+ return s ? lacking(s) : [];
365
+ });
366
+ if (missing.length) {
367
+ closed.values.push(value);
368
+ closed.classes = [...new Set([...closed.classes, ...missing])];
369
+ }
370
+ }
371
+ if (closed.values.length && closed.values.length < choice.values.length) {
372
+ out[choice.field] = closed;
373
+ }
374
+ }
375
+ return out;
376
+ }
377
+ /** The answer a closed choice gets instead: its first value that stays open. */
378
+ export function openValue(step, field, closed) {
379
+ const choice = choicesOf(step).find((c) => c.field === field);
380
+ return choice?.values.find((v) => !closed.values.some((c) => String(c) === String(v)));
381
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wizards",
3
- "version": "0.2.48",
3
+ "version": "0.2.50",
4
4
  "description": "Make a wish. Get your wizard. It guides you step by step. Let AI do the work. Runs on your machine, on the AI subscription you already have.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "homepage": "https://engenty.ai",
@@ -1 +0,0 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{t as r}from"./logo-C80CWCDM.js";import{t as i}from"./preload-helper-CNEI7N0N.js";import{H as a,I as o,M as s,P as c,_ as l,a as u,f as d,h as f,i as p,o as m,s as h,t as g}from"./ui-GsuU9WTj.js";import{t as _}from"./external-link-Dfc1VFvS.js";import{t as v}from"./refresh-cw-BUDPOT39.js";import{B as y,f as b,q as x}from"./index-CX_yxZVQ.js";import{c as S,f as C}from"./settings-menu-BvxRnNtf.js";import{ReleaseNotes as w,loadReleases as T,releaseDate as E,releaseLabel as D}from"./ChangelogDialog-DCEQD3Jd.js";var O=e(t(),1),k=[{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/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`}],A=[{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`}],j=e(n(),1),M=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function N({name:e,homepage:t,version:n,license:r,description:i}){return(0,j.jsxs)(`li`,{className:`py-2.5`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,j.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,j.jsx)(_,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,j.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,j.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,j.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),i?(0,j.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):null]})}function P({title:e,hint:t,children:n}){return(0,j.jsxs)(`section`,{className:`mt-6`,children:[(0,j.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,j.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function F({credits:e}){return(0,j.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,j.jsx)(N,{name:e.name,homepage:e.homepage,license:e.license,description:e.description[s]},e.name))})}function I({label:e,packages:t}){return(0,j.jsxs)(`div`,{className:`mt-4`,children:[(0,j.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,j.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,j.jsx)(N,{...e},e.name))})]})}function L({active:e}){let[t,n]=(0,O.useState)(null),[r,a]=(0,O.useState)(``);(0,O.useEffect)(()=>{if(!e||t)return;let r=!1;return i(()=>import(`./oss-credits-CIxnNZor.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,O.useEffect)(()=>{e||a(``)},[e]);let o=r.trim().toLowerCase(),s=e=>o?e.filter(e=>M(o,e.name,e.license,e.description.de,e.description.en)):e,l=e=>o?e.filter(e=>M(o,e.name,e.license,e.version)):e,f=s(k),p=s(A),m=t?[{id:`shared`,label:c(`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,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:c(`about.creditsHint`)}),(0,j.jsx)(h,{type:`search`,value:r,placeholder:c(`about.search`),onChange:e=>a(e.target.value)}),f.length>0?(0,j.jsx)(P,{title:c(`about.creditsProduct`),children:(0,j.jsx)(F,{credits:f})}):null,p.length>0?(0,j.jsx)(P,{title:c(`about.creditsBuiltWith`),children:(0,j.jsx)(F,{credits:p})}):null,t===null?(0,j.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,j.jsx)(d,{})}):m.length>0?(0,j.jsx)(P,{title:c(`about.creditsDeps`),hint:o?void 0:c(`about.creditsDepsHint`),children:m.map(e=>(0,j.jsx)(I,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,j.jsx)(u,{children:c(`about.noMatches`)}):null]})}var R=[`new`,`earlier`,`credits`],z=e=>c(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),B=e=>e===1?c(`about.change`):c(`about.changes`,{n:e});function V({open:e,onClose:t,me:n}){let i=n?.mode===`local`,{status:s,data:u,latest:h,check:k,apply:A,busy:M,progress:N}=b(i&&e),[P,F]=(0,O.useState)(null),[I,V]=(0,O.useState)(`new`),H=C(R.indexOf(I)),U=u?.newer&&h?h:y;(0,O.useEffect)(()=>{if(!e)return;let t=!1;return F(null),T(U===`0.2.48`?void 0:U).then(e=>{t||F(e)}),()=>{t=!0}},[e,U]);let W=P?.find(e=>e.version===`v${U}`)??P?.[0]??null,G=P?.filter(e=>e!==W)??[],K=i?u?.kind??null:`cloud`,q=u?.checkedAt?new Date(u.checkedAt).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}):null;return(0,j.jsxs)(p,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,j.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,j.jsx)(m,{label:c(`common.close`),onClick:t,children:(0,j.jsx)(o,{className:`size-4`})})}),(0,j.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,j.jsx)(r,{size:96}),(0,j.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,j.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,j.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,j.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[c(`about.version`,{v:y}),K?` · ${c(`about.kind.${K}`)}`:``]})]}),i?(0,j.jsxs)(`div`,{className:`mt-5 flex flex-col items-center gap-3 text-center text-[0.875rem] text-ink-2`,children:[s.isPending||k.isPending?(0,j.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,j.jsx)(d,{className:`size-4 text-ember-strong`}),c(`about.update.checking`)]}):N?(0,j.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[M?(0,j.jsx)(d,{className:`size-4 text-ember-strong`}):null,N]}):u?.newer&&h?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2.5 font-medium text-ink`,children:[(0,j.jsx)(x,{className:`size-4 shrink-0 text-ember-strong`}),c(`about.update.available`,{v:h})]}),u.canApply?null:(0,j.jsx)(`p`,{className:`text-ink-3`,children:c(`about.update.manual`)})]}):u?.enabled?u.latest===null?(0,j.jsx)(`p`,{children:c(`about.update.unknown`)}):(0,j.jsxs)(`p`,{children:[c(`about.update.upToDate`),q?(0,j.jsxs)(`span`,{className:`text-ink-4`,children:[` `,`· `,c(`about.update.checkedAt`,{when:q})]}):null]}):(0,j.jsx)(`p`,{children:c(`about.update.off`)}),M||s.isPending?null:(0,j.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[u?.newer&&u.canApply&&u.applying!==`running`?(0,j.jsxs)(g,{size:`sm`,disabled:A.isPending,onClick:()=>A.mutate(),children:[(0,j.jsx)(x,{className:`size-4`}),` `,c(`about.update.install`)]}):null,u?.newer&&u.url?(0,j.jsxs)(g,{size:`sm`,variant:`secondary`,onClick:()=>window.open(u.url??``,`_blank`),children:[c(`about.update.release`),` `,(0,j.jsx)(_,{className:`size-4`})]}):null,u?.enabled===!1?null:(0,j.jsxs)(g,{size:`sm`,variant:`secondary`,disabled:k.isPending,onClick:()=>k.mutate(),children:[(0,j.jsx)(v,{className:l(`size-4`,k.isPending&&`animate-spin`)}),` `,c(`about.update.check`)]})]})]}):null,(0,j.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,j.jsx)(f,{value:I,onChange:V,options:R.map(e=>({id:e,label:z(e)})),label:c(`about.title`)})}),(0,j.jsxs)(`div`,{className:l(`mt-5`,S(H)),children:[I===`new`?P===null?(0,j.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,j.jsx)(d,{})}):W?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[D(W),(0,j.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:E(W)})]}),(0,j.jsx)(`div`,{className:`mt-3`,children:(0,j.jsx)(w,{release:W})})]}):(0,j.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:c(`about.changelogEmpty`)}):null,I===`earlier`?(0,j.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:G.map(e=>(0,j.jsxs)(`details`,{className:`group/r py-2`,children:[(0,j.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,j.jsx)(a,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,j.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:D(e)}),(0,j.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:E(e)}),(0,j.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:B(e.commits.length)})]}),(0,j.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,j.jsx)(w,{release:e})})]},e.version??`unreleased`))}):null,I===`credits`?(0,j.jsx)(L,{active:!0}):null]},I)]})}export{V as AboutDialog};
@@ -1 +0,0 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{t as r}from"./preload-helper-CNEI7N0N.js";import{P as i,_ as a,a as o,f as s,i as c,s as l}from"./ui-GsuU9WTj.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/,``):i(`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 r(async()=>{let{default:e}=await import(`./changelog-BRoVI_JJ.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:i(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[r,a]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||r)return;let t=!1;return _(n).then(e=>{t||a(e)}),()=>{t=!0}},[e,r,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=r?g(r,f):[];return(0,d.jsxs)(c,{open:e,onClose:t,title:i(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:i(`about.changelogHint`)}),r===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(s,{})}):r.length===0?(0,d.jsx)(o,{children:i(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{type:`search`,value:f,placeholder:i(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(o,{children:i(`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,10 +0,0 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{t as r}from"./react-dom-DenslgJm.js";import{A as i,B as a,C as o,G as s,L as c,M as l,P as u,Y as d,_ as f,f as p,g as m,j as h,l as g,o as _,q as v,x as y,z as b}from"./ui-GsuU9WTj.js";import{_ as x,a as S,c as C,d as w,f as T,g as E,i as D,l as O,m as k,n as A,o as j,p as M,r as N,s as P,u as F,v as I}from"./RunnerView-Bzwv1u4j.js";import{t as L}from"./sparkles-DWGJluyV.js";import{n as R,t as ee}from"./volume-2-BZju_bOP.js";import{O as z,S as B,g as te,o as ne}from"./definition-CHacJYmI.js";import{E as re,G as ie,H as ae,L as oe,R as se,j as ce,v as le,x as ue,z as de}from"./index-CX_yxZVQ.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=d(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=d(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=d(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=d(_e),ye=r(),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:f(`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)(p,{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:f(`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`,o=e.state===`connecting`,[s,c]=(0,H.useState)(null),[l,d]=(0,H.useState)(!1);(0,H.useEffect)(()=>{c(i?Date.now():null)},[i]);let m=async()=>{d(!1),await e.start(),n&&await e.startCamera()},h=()=>{e.stop(),d(!0)},g=n||e.camera,_=[...e.captions].reverse().find(e=>e.who===`bot`),v=[...e.captions].reverse().find(e=>e.who===`me`),y=e.speaking?u(`talk.speaking`):e.listening?u(`talk.listening`):i?u(`talk.live`):o?u(`talk.connecting`):l?u(`video.ended`):``;return(0,U.jsxs)(`section`,{className:f(`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??``}),y?(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[i?(0,U.jsx)(`span`,{className:f(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,y]}):null,(0,U.jsx)(xe,{since:s})]}),(0,U.jsxs)(`div`,{className:f(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,g?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!g&&i&&e.captions.length?`h-[38%]`:g?``:`flex-1`),children:[(0,U.jsxs)(`div`,{className:f(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!g&&`hidden`),children:[(0,U.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:f(`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:u(`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:[u(`video.you`),e.muted?(0,U.jsx)(ie,{className:`ml-1.5 inline size-3`}):null]})]}),(0,U.jsxs)(`div`,{className:f(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,g?`bg-neutral-900`:`bg-transparent`,g&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,U.jsx)(`div`,{className:f(`rounded-full transition-shadow duration-500`,!g&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!g&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,U.jsx)(z,{kind:t?.wizard.avatar??`round`,size:g?140:200,fluffy:!0,interactive:!1})}),g?(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&&!g?(0,U.jsx)(Se,{voice:e}):i&&(_||v)?(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:[v?(0,U.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:v.text}):null,_?(0,U.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:_.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:u(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,U.jsx)(ie,{className:`size-5`}):(0,U.jsx)(a,{className:`size-5`})}),(0,U.jsx)(W,{label:u(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,U.jsx)(R,{className:`size-5`}):(0,U.jsx)(V,{className:`size-5`})}),e.camera&&be?(0,U.jsx)(W,{label:u(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,U.jsx)(k,{className:`size-5`})}):null,(0,U.jsx)(W,{label:u(`video.leave`),danger:!0,onClick:h,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 m(),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)(p,{className:`size-4`}):n?(0,U.jsx)(R,{className:`size-5`}):(0,U.jsx)(a,{className:`size-5`}),u(l?`video.rejoin`:n?`video.join`:`talk.start`)]}),!l&&!e.error?(0,U.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:u(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var we=e=>ne[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: ${h(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`),[s,c]=(0,H.useState)(null),[l,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(`environment`),[v,y]=(0,H.useState)(!1),[b,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=m;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),h(!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;_(n===`user`||n===`environment`?n:t),S.current&&(S.current.srcObject=e,await S.current.play().catch(()=>void 0)),h(!0)}catch(e){c(e.name===`NotAllowedError`?u(`talk.cameraDenied`):e.message)}},[]),R=(0,H.useCallback)(async()=>{let e=g===`user`?`environment`:`user`;I(),await L(e)},[g,I,L]),ee=(0,H.useCallback)(()=>{y(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=``,d(!1),p(!1),y(!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`}),s=await o.upload(`/api/runs/${e}/uploads`,a),c=i.values[t.id],l=t.multiple?[...Array.isArray(c)?c:c?[c]:[],s.id]:s.id,u=i.setField(t.id,l);return u?`refused: ${u}`:`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 o.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){c(null),x([]),a(`connecting`);try{let t=await o.post(`/api/runs/${e}/talk`),n=await navigator.mediaDevices.getUserMedia({audio:!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 s=r.createDataChannel(`oai-events`);D.current=s,s.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case`output_audio_buffer.started`:d(!0);break;case`output_audio_buffer.stopped`:case`output_audio_buffer.cleared`:d(!1);break;case`input_audio_buffer.speech_started`:{p(!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`:p(!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`:c(String(t.error?.message??`error`))}},s.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`}))},s.onclose=()=>{E.current===r&&z()};let l=await r.createOffer();await r.setLocalDescription(l);let f=await fetch(t.endpoint,{method:`POST`,headers:{authorization:`Bearer ${t.clientSecret}`,"content-type":`application/sdp`},body:l.sdp});if(!f.ok)throw Error(`${u(`talk.failed`)} (${f.status})`);await r.setRemoteDescription({type:`answer`,sdp:await f.text()})}catch(e){z(),c(e.name===`NotAllowedError`?u(`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,m);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,m,P]),{state:i,error:s,speaking:l,listening:f,start:te,stop:z,camera:m,facing:g,startCamera:L,stopCamera:I,flipCamera:R,muted:v,toggleMute:ee,captions:b,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},[]);de(!!n?.readAloud,n?.lang??l,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)(z,{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:f(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?f(`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)(I,{className:`size-3`}),` `,u(`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":u(`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:f(`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)(p,{className:`size-4`}):null,t]})}function Fe({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:o,inputRef:s,onSend:l}){let[d,h]=(0,H.useState)(e),g=(0,H.useRef)(null),b=s??g,S=(0,H.useContext)(q),C=y(d,h,{endpoint:S?`/api/runs/${S.runId}/transcribe`:void 0}),w=!!S&&C.supported&&!o;(0,H.useEffect)(()=>{if(!w)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),C.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[w,C.toggle]),(0,H.useEffect)(()=>{!re&&!o&&b.current?.focus()},[o,b]);let T=()=>{i||o||(C.listening&&C.toggle(),l(d)!==!1&&h(``))},E=C.listening?u(`chat.listening`):C.processing?u(`chat.transcribing`):t,D=S?.voice??null,O=!!S?.call,k=S&&!O&&(oe||w||D)?(0,U.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[D?(0,U.jsx)(_,{label:u(D.state===`live`?`talk.stop`:D.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":D.state===`live`,disabled:D.state===`connecting`,onClick:()=>D.state===`live`?D.stop():void D.start(),className:f(`size-9`,D.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,D.state===`off`&&S.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:D.state===`connecting`?(0,U.jsx)(p,{className:`size-4`}):D.state===`live`?(0,U.jsx)(ae,{className:`size-4`}):(0,U.jsx)(x,{className:`size-4`})}):null,D?.state===`live`?(0,U.jsx)(_,{label:u(D.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":D.camera,onClick:()=>D.camera?D.stopCamera():void D.startCamera(),className:f(`size-9`,D.camera&&`text-ink`),children:D.camera?(0,U.jsx)(R,{className:`size-4`}):(0,U.jsx)(V,{className:`size-4`})}):null,oe?(0,U.jsx)(_,{label:u(S.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":S.readAloud,onClick:()=>S.setReadAloud(!S.readAloud),className:f(`size-9`,S.readAloud&&`text-ink`),children:S.readAloud?(0,U.jsx)(ee,{className:`size-4`}):(0,U.jsx)(ve,{className:`size-4`})}):null,w?(0,U.jsx)(_,{label:u(C.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":C.listening,disabled:C.processing,onClick:C.toggle,className:f(`size-9`,C.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:C.processing?(0,U.jsx)(p,{className:`size-4`}):C.listening?(0,U.jsx)(c,{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(),T()},children:[D&&!O?(0,U.jsx)(`video`,{ref:D.video,muted:!0,playsInline:!0,autoPlay:!0,className:f(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,D.camera?`block`:`hidden`)}):null,(0,U.jsxs)(`div`,{className:f(`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`,o&&`opacity-60`),children:[k,n?(0,U.jsx)(m,{ref:b,minRows:1,maxRows:6,value:d,disabled:o,placeholder:E,autoCapitalize:`sentences`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!re&&!e.nativeEvent.isComposing&&(e.preventDefault(),T())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,U.jsx)(`input`,{ref:b,...r,value:d,disabled:o,placeholder:E,enterKeyHint:`send`,onChange:e=>h(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":u(`chat.send`),title:u(`chat.send`),disabled:i||o,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)(p,{className:`size-4`}):(0,U.jsx)(v,{className:`size-4`})})]}),C.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:C.error===`denied`?u(`chat.micDenied`):C.error}):O?null:D?.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:D.error}):D?.state===`live`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:D.speaking?u(`talk.speaking`):D.listening?u(`talk.listening`):u(`talk.live`)}):S?.talk&&D?.state===`off`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:u(`talk.hint`)}):null]})}function Q({placeholder:e=u(`chat.above`)}){return(0,U.jsx)(Me,{children:(0,U.jsx)(Fe,{disabled:!0,placeholder:e,onSend:()=>!1})})}function Ie(e){let t=ne[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?u(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return u(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return u(`chat.badUrl`)}return e.kind===`number`&&!Number.isFinite(Number(r.replace(`,`,`.`)))?u(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?u(`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:u(`chat.connected`)});if(e.kind===`list`)return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(s,{className:`size-4`}),` `,u(`chat.checked`)]});if(e.kind===`toggle`)return(0,U.jsx)(U.Fragment,{children:u(t===!0?`run.yes`:`run.no`)});if(Le(t))return(0,U.jsx)(`span`,{className:`italic opacity-80`,children:u(`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(l,{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:i(`/api/runs/${n}/assets/${t}`),alt:``,className:f(`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)(b,{className:`size-4`}),` `,u(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`}),` `,u(`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:u(`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&&!te(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`,u(`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=>!te(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??{},[o,s]=(0,H.useState)(()=>A(n,e)),[c,l]=(0,H.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?B(Ke(n,e),e.known??{},A(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),_=B(i,a,o),v=_.filter(e=>c.includes(e.id)),y=_.find(e=>!c.includes(e.id)),b=i.length===1?i[0]:void 0,x=v.at(-1),C=x?()=>l(e=>e.filter(e=>e!==x.id)):void 0;(0,H.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=B(i,a,o),r=n.findIndex(t=>e.includes(t.id));r>=0&&(l(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),E=(0,H.useRef)(o);E.current=o;let D=T?.bindPage,O=(0,H.useRef)(w);O.current=w,(0,H.useEffect)(()=>{if(!D)return;let e=B(i,a,o);return D({step:n,fields:e,values:o,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?Re(r,n)||(s(e=>({...e,[t]:n})),l(e=>e.includes(t)?e:[...e,t]),f({}),null):`no such field on this page`},submit:()=>O.current(E.current)}),()=>D(null)},[D,n,i,a,o]);let k=e=>{if(!y)return!1;let t=Re(y,e);if(t)return f({[y.id]:t}),!1;let n={...o,[y.id]:e},r=[...c,y.id];return s(n),l(r),f({}),B(i,a,n).some(e=>!r.includes(e.id))||w(n),!0},j=[...r.map(e=>c.length?{...e,onEdit:void 0}:e),...Ue(n,`now:${n.id}`,o,e.id,v,b).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)(S,{field:y,value:o[y.id],values:o,runId:e.id,view:e,closed:e.closed?.[y.id],onChange:e=>s(t=>({...t,[y.id]:e})),onBusy:m}),{wide:!0})):b||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&&c.length>0&&t.busy)M=(0,U.jsx)(Q,{placeholder:u(`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(o),children:n.cta||u(`run.next`)}),C?(0,U.jsx)(Z,{onClick:C,disabled:t.busy,children:u(`run.back`)}):null]})));else{let r=Ie(y),i=!y.required&&y.kind!==`connection`&&y.kind!==`list`?(0,U.jsx)(Z,{onClick:()=>k(void 0),children:u(`chat.skip`)}):null;if(r===`typed`){i&&j.push(X(`now:${n.id}:${y.id}:replies`,i));let e=o[y.id];M=(0,U.jsx)(Me,{children:(0,U.jsx)(Fe,{initial:Le(e)?``:String(e),multiline:y.kind===`textarea`,placeholder:y.placeholder||(b?y.label:u(`chat.placeholder`)),inputProps:Je(y),busy:t.busy,onSend:e=>k(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:o[y.id],onAnswer:k}),{bare:!0}));else{let e=_.filter(e=>!c.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:()=>k(o[y.id]),children:e&&n.cta?n.cta:u(`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 j(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:u(`run.no`)}),(0,U.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:u(`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?u(`chat.send`):u(`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:u(`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(),[r,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:f(`flex max-w-full flex-col gap-1`,c?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??u(`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??u(`run.working`)}),(0,U.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:u(`run.elapsed`,{s:Math.max(0,Math.round((r-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)(L,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,U.jsx)(`span`,{className:`truncate`,children:h(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:i(`/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),[i,a]=(0,H.useState)(`agent`),[s,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=()=>o.get(`/api/runs/${e}/browser/seat`).then(e=>a(e.seat)).catch(()=>void 0);if(t(),i!==`person`)return;let n=setInterval(t,$e);return()=>clearInterval(n)},[e,i]),n!==null&&n>=t.id)return null;let d=i===`person`,p=async()=>{c(!0);try{let t=await o.post(`/api/runs/${e}/browser/seat`,{to:d?`agent`:`person`});a(t.seat)}catch{}finally{c(!1)}};return(0,U.jsx)(T,{runId:e,driving:d,caption:h(t),hint:u(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,U.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>void p(),className:f(`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)(he,{className:`size-3.5`}):(0,U.jsx)(pe,{className:`size-3.5`}),u(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 tt({view:e,run:t,step:n,before:r,asked:i,onNote:a}){let o=e.shown.filter(e=>e.output),[c,l]=(0,H.useState)(o.length===1?o[0].step.id:null),d=(0,H.useRef)(null),f=[...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)(ue,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{l(t.id),d.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)(P,{runId:e.id,list:t}):(0,U.jsx)(O,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&f.push(G(`review-error`,t.error,{tone:`error`}));let p=n.regenerate&&o.length>0;return f.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)(s,{className:`size-4`}),` `,u(`run.accept`)]}),p&&o.length>1?o.map(({step:e})=>(0,U.jsx)(Z,{on:c===e.id,onClick:()=>l(e.id),children:e.title},e.id)):null]}))),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:e.wizard.avatar,lines:f}),p?(0,U.jsx)(Me,{children:(0,U.jsx)(Fe,{multiline:!0,inputRef:d,busy:t.busy,placeholder:o.length>1&&!c?u(`run.feedbackPick`):u(`run.feedbackPlaceholder`),disabled:!c,onSend:e=>{let r=e.trim();return!r||!c?!1:(a(r),t.regenerate(n.id,c,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)(le,{base:o,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,U.jsx)(ue,{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:u(`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)(C,{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)(M,{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)(E,{className:`size-4`}),` `,u(`run.again`)]}):null,e.canBack?(0,U.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:u(`run.back`)}):null,e.keeps?(0,U.jsx)(`span`,{className:`ml-1`,children:(0,U.jsx)(F,{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=D(e),{view:c}=s,[d,f]=(0,H.useState)(null),m=ke(e,c,s,d);(0,H.useEffect)(()=>{n?.(c)},[c,n]);let[h,_]=se(),v=(0,H.useMemo)(()=>({runId:e,lang:c?.lang??l,readAloud:h,setReadAloud:_,voice:c?.talk?m:null,talk:a,call:!!o,bindPage:f}),[e,c?.lang,c?.talk,h,_,m,a,o]);ce(c?.status===`running`&&!c.ask),N(c);let[y,b]=(0,H.useState)({}),[x,S]=(0,H.useState)(null);(0,H.useEffect)(()=>{c&&c.status!==`running`&&S(null)},[c]);let C;if(s.notFound)C=(0,U.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:u(`run.notFound`)});else if(!c)C=(0,U.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,U.jsx)(p,{})});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)C=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:c.wizard.avatar,lines:[...r,G(`ask:${c.ask.id}`,(0,U.jsx)(w,{runId:c.id,ask:c.ask}),{wide:!0})]}),(0,U.jsx)(Q,{})]});else if(c.status===`running`)C=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:c.wizard.avatar,lines:[...r,...x?[K(`note`,x)]:[],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:u(`run.working`)})]});else if(c.status===`failed`)C=(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:u(`run.failed`)}),c.error?(0,U.jsx)(`span`,{className:`mt-0.5 block`,children:(0,U.jsx)(g,{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)(E,{className:`size-4`}),` `,u(`run.retry`)]}),c.canBack?(0,U.jsx)(Z,{onClick:()=>void s.back(),disabled:s.busy,children:u(`run.back`)}):null]}))]}),(0,U.jsx)(Q,{})]});else if(c.status===`cancelled`)C=(0,U.jsx)(J,{avatar:c.wizard.avatar,lines:[...r,G(`cancelled`,u(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,U.jsxs)(Z,{primary:!0,onClick:t,children:[(0,U.jsx)(E,{className:`size-4`}),` `,u(`run.again`)]}))]:[]]});else if(e?.type===`page`)C=(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(`|`);C=(0,U.jsx)(tt,{view:c,run:s,step:e,before:r,asked:y[e.id]??[],onNote:t=>{S(t),b(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else C=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:v,children:(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,U.jsx)(Ce,{voice:m,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:C})})]})}):(0,U.jsx)(q.Provider,{value:v,children:(0,U.jsx)(Ne,{header:r,footer:i,children:C})})}export{J as a,Z as i,Ne as n,X as o,Q as r,je as s,rt as t};