wizards 0.3.6 → 0.3.7

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 (62) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +285 -31
  2. package/apps/runtime/dist/agents/website.js +256 -34
  3. package/apps/runtime/dist/db/schema.js +1 -1
  4. package/apps/runtime/dist/documents/parse.js +14 -0
  5. package/apps/runtime/dist/engine/steps.js +42 -6
  6. package/apps/runtime/dist/engine/template.js +50 -3
  7. package/apps/runtime/dist/film/project.js +54 -4
  8. package/apps/runtime/dist/routes/studio.js +37 -1
  9. package/apps/runtime/dist/services/brand.js +6 -3
  10. package/apps/runtime/dist/services/project-files.js +59 -3
  11. package/apps/runtime/dist/services/projects.js +150 -2
  12. package/apps/web/dist/assets/AboutDialog-C0dN86zd.js +1 -0
  13. package/apps/web/dist/assets/{ChangelogDialog-m2M7gZiB.js → ChangelogDialog-Cv81t7tj.js} +1 -1
  14. package/apps/web/dist/assets/ChatView-uogJ3nht.js +10 -0
  15. package/apps/web/dist/assets/EditorPage-n8YuTh6j.js +3 -0
  16. package/apps/web/dist/assets/{FlowPreview-BdRy7FO7.js → FlowPreview-D4dp1MWS.js} +1 -1
  17. package/apps/web/dist/assets/{Harness-DmJkTwOO.js → Harness-v7r0e6vK.js} +2 -2
  18. package/apps/web/dist/assets/NewWizardChannels-Be-7VhBi.js +1 -0
  19. package/apps/web/dist/assets/NewWizardPage-C8hPvrK8.js +7 -0
  20. package/apps/web/dist/assets/ProjectPage-B686ArYy.js +1 -0
  21. package/apps/web/dist/assets/PublicRunner-DeCpVfZP.js +1 -0
  22. package/apps/web/dist/assets/{ReadOnly-CaGzgOPe.js → ReadOnly-B-UCgnqW.js} +1 -1
  23. package/apps/web/dist/assets/RunDrawer-C6pzi8AJ.js +4 -0
  24. package/apps/web/dist/assets/{RunnerView-CJ4cLA_0.js → RunnerView-Deenymq0.js} +1 -1
  25. package/apps/web/dist/assets/SettingsPage-CK6L0yEe.js +1 -0
  26. package/apps/web/dist/assets/SetupPage-9CH3qXdH.js +1 -0
  27. package/apps/web/dist/assets/SharePage-B778xUFo.js +1 -0
  28. package/apps/web/dist/assets/changelog-DCJo2mbx.js +1 -0
  29. package/apps/web/dist/assets/{circle-alert-CpuMIhbH.js → circle-alert-DLvC9ePT.js} +1 -1
  30. package/apps/web/dist/assets/{esm-DRaZAcXQ.js → esm-BJskogLD.js} +1 -1
  31. package/apps/web/dist/assets/index-D6hUM8NU.css +1 -0
  32. package/apps/web/dist/assets/index-Df6UxElH.js +12 -0
  33. package/apps/web/dist/assets/{lock-BGotwAyN.js → lock-DR7NakPn.js} +1 -1
  34. package/apps/web/dist/assets/{phone-CA2A8W7I.js → phone-BORh3jfv.js} +1 -1
  35. package/apps/web/dist/assets/{settings-menu-DxswVOqQ.js → settings-menu-DV5D91TD.js} +1 -1
  36. package/apps/web/dist/assets/{ui-DAHMnAVc.js → ui-BOCXzzHi.js} +1 -1
  37. package/apps/web/dist/assets/{upload-DLbJVvfd.js → upload-B3yv8gsk.js} +1 -1
  38. package/apps/web/dist/index.html +3 -8
  39. package/apps/web/dist/mcp/flow.html +2 -2
  40. package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +3 -3
  41. package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +138 -3
  42. package/node_modules/@engenty-wizards/shared/dist/projects.js +153 -4
  43. package/package.json +1 -1
  44. package/apps/web/dist/assets/AboutDialog-Dz_tYBSU.js +0 -1
  45. package/apps/web/dist/assets/ChatView-D21o-lq8.js +0 -10
  46. package/apps/web/dist/assets/EditorPage-D6j3dQpu.js +0 -3
  47. package/apps/web/dist/assets/Marketplace-B-gy2onK.js +0 -2
  48. package/apps/web/dist/assets/NewWizardChannels-B3FEpsJ-.js +0 -1
  49. package/apps/web/dist/assets/NewWizardPage-CT1lThNM.js +0 -7
  50. package/apps/web/dist/assets/ProjectPage-BIanCF0m.js +0 -2
  51. package/apps/web/dist/assets/PublicRunner-H1fXa9BK.js +0 -1
  52. package/apps/web/dist/assets/RunDrawer-8sjkAbm5.js +0 -4
  53. package/apps/web/dist/assets/SettingsPage-BsdwE1OA.js +0 -1
  54. package/apps/web/dist/assets/SetupPage-sqrv7Auf.js +0 -1
  55. package/apps/web/dist/assets/SharePage-B6ets1ot.js +0 -1
  56. package/apps/web/dist/assets/brand-BRw18WJF.js +0 -2
  57. package/apps/web/dist/assets/changelog-BOFdRjx2.js +0 -1
  58. package/apps/web/dist/assets/index-DY9CslcT.css +0 -1
  59. package/apps/web/dist/assets/index-DkDBEMwz.js +0 -11
  60. package/apps/web/dist/assets/session-DBOQL_bg.js +0 -1
  61. package/apps/web/dist/assets/useMutation-DKyQXgyj.js +0 -1
  62. package/apps/web/dist/assets/volume-2-KaKQ4zMJ.js +0 -1
@@ -139,7 +139,7 @@ export interface PluginSpaceFileEvent {
139
139
  file: {
140
140
  id: string;
141
141
  name: string;
142
- kind: "logo" | "asset" | "document";
142
+ kind: "logo" | "asset" | "document" | "pattern";
143
143
  mime: string;
144
144
  };
145
145
  }
@@ -327,7 +327,7 @@ export interface PluginSpaceFile {
327
327
  name: string;
328
328
  mime: string;
329
329
  size: number;
330
- kind: "logo" | "asset" | "document";
330
+ kind: "logo" | "asset" | "document" | "pattern";
331
331
  updatedAt: string;
332
332
  }
333
333
  /** What a plugin wrote into a space. */
@@ -386,7 +386,7 @@ export interface PluginSpaceData {
386
386
  parent?: string;
387
387
  }): Promise<PluginSpacePage[]>;
388
388
  /** The space's files of a kind (`document` when left out), newest first. */
389
- files(space: string, kind?: "logo" | "asset" | "document"): Promise<PluginSpaceFile[]>;
389
+ files(space: string, kind?: "logo" | "asset" | "document" | "pattern"): Promise<PluginSpaceFile[]>;
390
390
  /** One file of the space with its bytes: a price list someone dropped into Wissen. */
391
391
  readFile(space: string, fileId: string): Promise<PluginSpaceFile & {
392
392
  data: Uint8Array;
@@ -24,8 +24,134 @@ export interface BrandColor {
24
24
  name: string;
25
25
  /** #rrggbb */
26
26
  value: string;
27
+ /** The `ColorSection` it belongs to; none for the standard colours. */
28
+ section?: string;
27
29
  }
28
- export declare const PROJECT_FILE_KINDS: readonly ["logo", "asset", "document"];
30
+ export declare const COLOR_SECTION_KINDS: readonly ["colors", "gradients", "patterns"];
31
+ export type ColorSectionKind = (typeof COLOR_SECTION_KINDS)[number];
32
+ /**
33
+ * Further colours of one use, as a brand guide groups them: "Illustration – for drawings and
34
+ * charts". Optional. A section holds colours, gradients or patterns (`kind`, colours when none).
35
+ * Colours in no section are the standard ones: they come first, and the first of them is the
36
+ * accent.
37
+ */
38
+ export interface ColorSection {
39
+ id: string;
40
+ title: string;
41
+ /** When to use what is in it. */
42
+ description: string;
43
+ kind?: ColorSectionKind;
44
+ }
45
+ export declare const GRADIENT_TYPES: readonly ["linear", "radial", "conic"];
46
+ export type GradientType = (typeof GRADIENT_TYPES)[number];
47
+ /** A gradient of the brand, as CSS draws it: its type, its angle and its colour stops. */
48
+ export interface BrandGradient {
49
+ id: string;
50
+ name: string;
51
+ /** The gradients section it is in. */
52
+ section: string;
53
+ type: GradientType;
54
+ /** Degrees: the direction of a linear one, where a conic one starts. */
55
+ angle: number;
56
+ stops: {
57
+ color: string;
58
+ at: number;
59
+ }[];
60
+ }
61
+ /** A pattern or a fill of the brand: a picture of the space (`file`), tiled or filling. */
62
+ export interface BrandPattern {
63
+ id: string;
64
+ name: string;
65
+ /** The patterns section it is in. */
66
+ section: string;
67
+ /** The project file (kind `pattern`) with the picture. */
68
+ file: string;
69
+ /** Repeated as a tile; else it fills the area. */
70
+ tile?: boolean;
71
+ }
72
+ /** The gradient as CSS. */
73
+ export declare function gradientCss(g: Pick<BrandGradient, "type" | "angle" | "stops">): string;
74
+ /**
75
+ * A CSS gradient read back: linear, radial or conic, with hex stops. Stops without a position
76
+ * are spread evenly. Null where it is not one of these.
77
+ */
78
+ export declare function parseGradient(css: string): Pick<BrandGradient, "type" | "angle" | "stops"> | null;
79
+ /**
80
+ * The colours as stored: the standard ones first, then each section's in the sections' order; a
81
+ * section that is not there any more is dropped from its colours.
82
+ */
83
+ export declare function orderColors(colors: BrandColor[], sections: ColorSection[]): BrandColor[];
84
+ /**
85
+ * Further logos of one use, as a brand guide groups them: "Logomark – small spaces, app icons".
86
+ * Optional. Logos in no section are the standard ones: they come first, without a title, and
87
+ * the first of them is the main logo.
88
+ */
89
+ export interface LogoSection {
90
+ id: string;
91
+ title: string;
92
+ /** When to use the logos in it. */
93
+ description: string;
94
+ /** The logo files in it, in order. A file sits in one section at most. */
95
+ logos: string[];
96
+ }
97
+ /** The main logo: the first standard one (in no section), else the first of all. */
98
+ export declare function mainLogo<T extends {
99
+ id: string;
100
+ }>(logos: T[], sections: LogoSection[] | undefined): T | undefined;
101
+ /** The sign before a rule: a bullet unless chosen. */
102
+ export declare const RULE_MARKS: readonly ["bullet", "do", "dont", "question", "important", "number"];
103
+ export type RuleMark = (typeof RULE_MARKS)[number];
104
+ /** A rule of the brand — for its logos, colours or type — in the admin's words. */
105
+ export interface BrandRule {
106
+ text: string;
107
+ /** None: a bullet. */
108
+ mark?: RuleMark;
109
+ }
110
+ /** Rules as a model reads them: the sign said in words, numbered ones counted. */
111
+ export declare function ruleLines(rules: BrandRule[]): string;
112
+ /** A typeface of the brand and what it is for: "Space Grotesk – headings". */
113
+ export interface BrandFont {
114
+ id: string;
115
+ /** The family as CSS names it: "Space Grotesk". */
116
+ family: string;
117
+ /** What it is for, in the admin's words. */
118
+ role: string;
119
+ /** The weights the brand uses: 400, 600, … */
120
+ weights: number[];
121
+ }
122
+ /** A text style of the type scale: "Headline XL – Space Grotesk 600, 48 px, line 90 %, −4 %". */
123
+ export interface TextStyle {
124
+ id: string;
125
+ name: string;
126
+ /** The `BrandFont` it is set in; none for the first font. */
127
+ font?: string;
128
+ /** px */
129
+ size: number;
130
+ weight: number;
131
+ /** Line height in % of the size. */
132
+ lineHeight: number;
133
+ /** Letter spacing in % of the size. */
134
+ tracking: number;
135
+ uppercase?: boolean;
136
+ }
137
+ export declare const FONT_WEIGHTS: readonly [300, 400, 500, 600, 700, 800];
138
+ /** A text style as a model and a person read it: "Space Grotesk 600, 48 px, line 90 %, tracking −4 %". */
139
+ export declare function textStyleLine(style: TextStyle, fonts: BrandFont[]): string;
140
+ /**
141
+ * Assets of one kind, shown as a tab of their own, named by its title: "Icons", "Background
142
+ * images". Optional.
143
+ * Assets in no section are the general ones, in the first tab.
144
+ */
145
+ export interface AssetSection {
146
+ id: string;
147
+ title: string;
148
+ /** The asset files in it, in order. A file sits in one section at most. */
149
+ assets: string[];
150
+ }
151
+ /** The sections as stored: each file in its first section only, ids not known to `files` left out. */
152
+ export declare function cleanLogoSections(sections: LogoSection[], files?: string[]): LogoSection[];
153
+ export declare function cleanAssetSections(sections: AssetSection[], files?: string[]): AssetSection[];
154
+ export declare const PROJECT_FILE_KINDS: readonly ["logo", "asset", "document", "pattern"];
29
155
  export type ProjectFileKind = (typeof PROJECT_FILE_KINDS)[number];
30
156
  /** `pending`: being read, described and indexed. */
31
157
  export type ProjectFileStatus = "pending" | "ready" | "failed";
@@ -48,17 +174,26 @@ export interface ProjectFileView {
48
174
  }
49
175
  export declare const PROJECT_LIMITS: {
50
176
  readonly facts: 100;
51
- readonly colors: 12;
177
+ readonly colors: 32;
178
+ readonly fonts: 6;
179
+ readonly textStyles: 16;
180
+ /** Sections of logos, and of colours, each. */
181
+ readonly logoSections: 8;
182
+ /** Rows of logo rules. */
183
+ readonly logoRules: 16;
52
184
  readonly files: {
53
- readonly logo: 8;
185
+ readonly logo: 24;
54
186
  readonly asset: 100;
55
187
  readonly document: 2000;
188
+ readonly pattern: 24;
56
189
  };
190
+ readonly gradients: 24;
57
191
  readonly bytes: {
58
192
  readonly logo: 5000000;
59
193
  readonly asset: 15000000;
60
194
  readonly video: 80000000;
61
195
  readonly document: 30000000;
196
+ readonly pattern: 10000000;
62
197
  };
63
198
  };
64
199
  /** The largest file of a kind and type a project takes. */
@@ -79,13 +79,162 @@ export const BASIC_FACTS = [
79
79
  { key: "website", de: "Website", en: "Website" },
80
80
  { key: "iban", de: "IBAN", en: "IBAN" },
81
81
  ];
82
+ export const COLOR_SECTION_KINDS = ["colors", "gradients", "patterns"];
83
+ export const GRADIENT_TYPES = ["linear", "radial", "conic"];
84
+ /** The gradient as CSS. */
85
+ export function gradientCss(g) {
86
+ const stops = [...g.stops]
87
+ .sort((a, b) => a.at - b.at)
88
+ .map((s) => `${s.color} ${Math.round(s.at)}%`)
89
+ .join(", ");
90
+ if (g.type === "radial") {
91
+ return `radial-gradient(circle at center, ${stops})`;
92
+ }
93
+ if (g.type === "conic") {
94
+ return `conic-gradient(from ${Math.round(g.angle)}deg at center, ${stops})`;
95
+ }
96
+ return `linear-gradient(${Math.round(g.angle)}deg, ${stops})`;
97
+ }
98
+ const SIDES = {
99
+ top: 0,
100
+ "top right": 45,
101
+ right: 90,
102
+ "bottom right": 135,
103
+ bottom: 180,
104
+ "bottom left": 225,
105
+ left: 270,
106
+ "top left": 315,
107
+ };
108
+ /**
109
+ * A CSS gradient read back: linear, radial or conic, with hex stops. Stops without a position
110
+ * are spread evenly. Null where it is not one of these.
111
+ */
112
+ export function parseGradient(css) {
113
+ const m = css.trim().match(/^(repeating-)?(linear|radial|conic)-gradient\(\s*([\s\S]*)\)\s*;?$/i);
114
+ if (!m) {
115
+ return null;
116
+ }
117
+ const type = m[2].toLowerCase();
118
+ const parts = m[3].split(/,(?![^(]*\))/).map((p) => p.trim());
119
+ let angle = type === "linear" ? 180 : 0;
120
+ const head = parts[0] ?? "";
121
+ if (!/^#|^rgb|^hsl|^oklch/i.test(head)) {
122
+ parts.shift();
123
+ const deg = head.match(/(-?[\d.]+)deg/);
124
+ const side = head.match(/^to\s+(.+)$/i)?.[1].toLowerCase();
125
+ if (deg) {
126
+ angle = Number(deg[1]);
127
+ }
128
+ else if (side && side in SIDES) {
129
+ angle = SIDES[side];
130
+ }
131
+ }
132
+ const stops = parts
133
+ .map((p) => p.match(/^(#[0-9a-f]{3,8})\b\s*(-?[\d.]+%)?/i))
134
+ .filter((x) => Boolean(x))
135
+ .map((x, i, all) => ({
136
+ color: x[1].toLowerCase(),
137
+ at: x[2] ? Number.parseFloat(x[2]) : all.length > 1 ? (i / (all.length - 1)) * 100 : 0,
138
+ }));
139
+ return stops.length >= 2 ? { type, angle: ((angle % 360) + 360) % 360, stops } : null;
140
+ }
141
+ /**
142
+ * The colours as stored: the standard ones first, then each section's in the sections' order; a
143
+ * section that is not there any more is dropped from its colours.
144
+ */
145
+ export function orderColors(colors, sections) {
146
+ const at = (c) => (c.section ? sections.findIndex((s) => s.id === c.section) : -1);
147
+ return colors
148
+ .map((c) => (c.section && at(c) < 0 ? { name: c.name, value: c.value } : c))
149
+ .map((c, i) => ({ c, i }))
150
+ .sort((a, b) => at(a.c) - at(b.c) || a.i - b.i)
151
+ .map(({ c }) => c);
152
+ }
153
+ /** The main logo: the first standard one (in no section), else the first of all. */
154
+ export function mainLogo(logos, sections) {
155
+ const grouped = new Set(sections?.flatMap((s) => s.logos));
156
+ return logos.find((f) => !grouped.has(f.id)) ?? logos[0];
157
+ }
158
+ /** The sign before a rule: a bullet unless chosen. */
159
+ export const RULE_MARKS = ["bullet", "do", "dont", "question", "important", "number"];
160
+ /** Rules as a model reads them: the sign said in words, numbered ones counted. */
161
+ export function ruleLines(rules) {
162
+ let n = 0;
163
+ return rules
164
+ .map((r) => {
165
+ switch (r.mark) {
166
+ case "do":
167
+ return `- Do: ${r.text}`;
168
+ case "dont":
169
+ return `- Don't: ${r.text}`;
170
+ case "question":
171
+ return `- To check with the person: ${r.text}`;
172
+ case "important":
173
+ return `- Important: ${r.text}`;
174
+ case "number":
175
+ n += 1;
176
+ return `${n}. ${r.text}`;
177
+ default:
178
+ return `- ${r.text}`;
179
+ }
180
+ })
181
+ .join("\n");
182
+ }
183
+ export const FONT_WEIGHTS = [300, 400, 500, 600, 700, 800];
184
+ /** A text style as a model and a person read it: "Space Grotesk 600, 48 px, line 90 %, tracking −4 %". */
185
+ export function textStyleLine(style, fonts) {
186
+ const family = (fonts.find((f) => f.id === style.font) ?? fonts[0])?.family;
187
+ return [
188
+ family ? `${family} ${style.weight}` : `weight ${style.weight}`,
189
+ `${style.size} px`,
190
+ `line ${style.lineHeight} %`,
191
+ `tracking ${style.tracking} %`,
192
+ style.uppercase ? "uppercase" : "",
193
+ ]
194
+ .filter(Boolean)
195
+ .join(", ");
196
+ }
197
+ /** Each file in its first list only; ids not known to `files` left out. */
198
+ function uniqueFiles(lists, files) {
199
+ const seen = new Set();
200
+ const known = files ? new Set(files) : null;
201
+ return lists.map((ids) => ids.filter((id) => {
202
+ if (seen.has(id) || (known && !known.has(id))) {
203
+ return false;
204
+ }
205
+ seen.add(id);
206
+ return true;
207
+ }));
208
+ }
209
+ /** The sections as stored: each file in its first section only, ids not known to `files` left out. */
210
+ export function cleanLogoSections(sections, files) {
211
+ const lists = uniqueFiles(sections.map((s) => s.logos), files);
212
+ return sections.map((s, i) => ({ ...s, logos: lists[i] }));
213
+ }
214
+ export function cleanAssetSections(sections, files) {
215
+ const lists = uniqueFiles(sections.map((s) => s.assets), files);
216
+ return sections.map((s, i) => ({ ...s, assets: lists[i] }));
217
+ }
82
218
  // --- files -----------------------------------------------------------------------
83
- export const PROJECT_FILE_KINDS = ["logo", "asset", "document"];
219
+ export const PROJECT_FILE_KINDS = ["logo", "asset", "document", "pattern"];
84
220
  export const PROJECT_LIMITS = {
85
221
  facts: 100,
86
- colors: 12,
87
- files: { logo: 8, asset: 100, document: 2000 },
88
- bytes: { logo: 5_000_000, asset: 15_000_000, video: 80_000_000, document: 30_000_000 },
222
+ colors: 32,
223
+ fonts: 6,
224
+ textStyles: 16,
225
+ /** Sections of logos, and of colours, each. */
226
+ logoSections: 8,
227
+ /** Rows of logo rules. */
228
+ logoRules: 16,
229
+ files: { logo: 24, asset: 100, document: 2000, pattern: 24 },
230
+ gradients: 24,
231
+ bytes: {
232
+ logo: 5_000_000,
233
+ asset: 15_000_000,
234
+ video: 80_000_000,
235
+ document: 30_000_000,
236
+ pattern: 10_000_000,
237
+ },
89
238
  };
90
239
  /** The largest file of a kind and type a project takes. */
91
240
  export function projectFileLimit(kind, mime) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wizards",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
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{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{t as r}from"./logo-C4V2_3Ar.js";import{t as i}from"./preload-helper-CNEI7N0N.js";import{Ct as a,Dt as o,Tt as s,Zt as c,bt as l,ft as u,ht as d,jt as f,kt as p,mt as m,nn as h,pt as g}from"./ui-DAHMnAVc.js";import{B as _,Q as v,V as y}from"./index-DkDBEMwz.js";import{c as b,f as x}from"./settings-menu-DxswVOqQ.js";import{ReleaseNotes as S,loadReleases as C,releaseDate as w,releaseLabel as T}from"./ChangelogDialog-m2M7gZiB.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:i}){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)(c,{"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})]}),i?(0,k.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):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[o]},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 i(()=>import(`./oss-credits-BQQX0kvk.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,E.useEffect)(()=>{e||a(``)},[e]);let o=r.trim().toLowerCase(),s=e=>o?e.filter(e=>A(o,e.name,e.license,e.description.de,e.description.en)):e,c=e=>o?e.filter(e=>A(o,e.name,e.license,e.version)):e,u=s(D),f=s(O),m=t?[{id:`shared`,label:p(`about.creditsShared`),packages:c(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:c(e.packages)}))].filter(e=>e.packages.length>0):[],h=u.length===0&&f.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:p(`about.creditsHint`)}),(0,k.jsx)(d,{type:`search`,value:r,placeholder:p(`about.search`),onChange:e=>a(e.target.value)}),u.length>0?(0,k.jsx)(M,{title:p(`about.creditsProduct`),children:(0,k.jsx)(N,{credits:u})}):null,f.length>0?(0,k.jsx)(M,{title:p(`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)(l,{})}):m.length>0?(0,k.jsx)(M,{title:p(`about.creditsDeps`),hint:o?void 0:p(`about.creditsDepsHint`),children:m.map(e=>(0,k.jsx)(P,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&h?(0,k.jsx)(g,{children:p(`about.noMatches`)}):null]})}var I=[`new`,`earlier`,`credits`],L=e=>p(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),R=e=>e===1?p(`about.change`):p(`about.changes`,{n:e});function z({open:e,onClose:t,me:n}){let i=n?.mode===`local`,{data:o,latest:c}=y(i&&e),[d,g]=(0,E.useState)(null),[D,O]=(0,E.useState)(`new`),A=x(I.indexOf(D)),j=o?.newer&&c?c:v;(0,E.useEffect)(()=>{if(!e)return;let t=!1;return g(null),C(j===`0.3.6`?void 0:j).then(e=>{t||g(e)}),()=>{t=!0}},[e,j]);let M=d?.find(e=>e.version===`v${j}`)??d?.[0]??null,N=d?.filter(e=>e!==M)??[],P=i?o?.kind??null:`cloud`;return(0,k.jsxs)(u,{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)(m,{label:p(`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)(r,{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:[p(`about.version`,{v}),P?` · ${p(`about.kind.${P}`)}`:``]})]}),i?(0,k.jsx)(`div`,{className:`mt-5`,children:(0,k.jsx)(_,{enabled:e})}):null,(0,k.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,k.jsx)(a,{value:D,onChange:O,options:I.map(e=>({id:e,label:L(e)})),label:p(`about.title`)})}),(0,k.jsxs)(`div`,{className:s(`mt-5`,b(A)),children:[D===`new`?d===null?(0,k.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,k.jsx)(l,{})}):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:p(`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)(h,{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,10 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{A as r,Dt as i,E as a,Et as o,Ft as s,It as c,J as l,Kt as u,Lt as d,M as f,Mt as p,N as m,O as h,Pt as g,S as _,Tt as v,Vt as y,Wt as b,_t as x,an as S,at as C,b as w,bt as T,dn as E,et as D,it as O,j as k,k as A,kt as j,l as M,mt as N,nt as P,rt as F,s as I,sn as L,v as R,wt as ee,x as z,z as B}from"./ui-DAHMnAVc.js";import{r as te}from"./brand-BRw18WJF.js";import{t as ne}from"./phone-CA2A8W7I.js";import{t as re}from"./volume-2-KaKQ4zMJ.js";import{J as ie,Y as ae,mt as oe,ot as se,q as ce,rt as le,t as ue}from"./index-DkDBEMwz.js";import{n as de}from"./RunnerView-CJ4cLA_0.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=E(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=E(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=E(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=E(_e),ye=oe(),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:v(`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)(T,{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:v(`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 d=async()=>{l(!1),await e.start(),n&&await e.startCamera()},f=()=>{e.stop(),l(!0)},m=n||e.camera,h=[...e.captions].reverse().find(e=>e.who===`bot`),_=[...e.captions].reverse().find(e=>e.who===`me`),y=e.speaking?j(`talk.speaking`):e.listening?j(`talk.listening`):i?j(`talk.live`):a?j(`talk.connecting`):c?j(`video.ended`):``;return(0,U.jsxs)(`section`,{className:v(`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:v(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,y]}):null,(0,U.jsx)(xe,{since:o})]}),(0,U.jsxs)(`div`,{className:v(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,m?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!m&&i&&e.captions.length?`h-[38%]`:m?``:`flex-1`),children:[(0,U.jsxs)(`div`,{className:v(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!m&&`hidden`),children:[(0,U.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:v(`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:j(`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:[j(`video.you`),e.muted?(0,U.jsx)(se,{className:`ml-1.5 inline size-3`}):null]})]}),(0,U.jsxs)(`div`,{className:v(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,m?`bg-neutral-900`:`bg-transparent`,m&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,U.jsx)(`div`,{className:v(`rounded-full transition-shadow duration-500`,!m&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!m&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,U.jsx)(te,{kind:t?.wizard.avatar??`round`,size:m?140:200,fluffy:!0,interactive:!1})}),m?(0,U.jsx)(`span`,{className:`absolute bottom-2 left-3 max-w-[85%] truncate rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:t?.wizard.title??``}):null]})]}),i&&!m?(0,U.jsx)(Se,{voice:e}):i&&(h||_)?(0,U.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[_?(0,U.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:_.text}):null,h?(0,U.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:h.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:j(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,U.jsx)(se,{className:`size-5`}):(0,U.jsx)(u,{className:`size-5`})}),(0,U.jsx)(W,{label:j(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,U.jsx)(p,{className:`size-5`}):(0,U.jsx)(V,{className:`size-5`})}),e.camera&&be?(0,U.jsx)(W,{label:j(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,U.jsx)(g,{className:`size-5`})}):null,(0,U.jsx)(W,{label:j(`video.leave`),danger:!0,onClick:f,children:(0,U.jsx)(le,{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 d(),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)(T,{className:`size-4`}):n?(0,U.jsx)(p,{className:`size-5`}):(0,U.jsx)(u,{className:`size-5`}),j(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:j(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var we=e=>B[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: ${o(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,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(`environment`),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)([]),b=(0,H.useRef)(null),x=(0,H.useRef)(null),S=(0,H.useRef)(0),C=(0,H.useRef)(!1);C.current=f;let w=(0,H.useRef)(null),T=(0,H.useRef)(null),E=(0,H.useRef)(null),D=(0,H.useRef)(null),O=(0,H.useRef)(t);O.current=t;let k=(0,H.useRef)(r);k.current=r;let A=(0,H.useRef)(n);A.current=n;let N=(0,H.useRef)(``),P=(0,H.useCallback)(e=>{let t=T.current;t&&t.readyState===`open`&&t.send(JSON.stringify(e))},[]),F=(0,H.useCallback)(()=>{let e=b.current;if(!C.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 x.current?.getTracks()??[])e.stop();x.current=null,b.current&&(b.current.srcObject=null),p(!1)},[]),L=(0,H.useCallback)(async e=>{if(x.current)return;let t=e??`environment`;try{let e=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:t},width:{ideal:1280}},audio:!1});x.current=e;let n=e.getVideoTracks()[0]?.getSettings().facingMode;h(n===`user`||n===`environment`?n:t),b.current&&(b.current.srcObject=e,await b.current.play().catch(()=>void 0)),p(!0)}catch(e){s(e.name===`NotAllowedError`?j(`talk.cameraDenied`):e.message)}},[]),R=(0,H.useCallback)(async()=>{let e=m===`user`?`environment`:`user`;I(),await L(e)},[m,I,L]),ee=(0,H.useCallback)(()=>{_(e=>{for(let t of D.current?.getAudioTracks()??[])t.enabled=e;return!e})},[]),z=(0,H.useCallback)(()=>{I(),T.current?.close(),T.current=null,w.current?.close(),w.current=null;for(let e of D.current?.getTracks()??[])e.stop();D.current=null,E.current&&=(E.current.srcObject=null,E.current.remove(),null),N.current=``,l(!1),d(!1),_(!1),a(`off`)},[I]);(0,H.useEffect)(()=>()=>z(),[z]);let B=(0,H.useCallback)(async(t,n)=>{let r=O.current,i=k.current,a=A.current;switch(t){case`get_state`:return r?Oe(r,i,C.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 M.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 M.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(!w.current){s(null),y([]),a(`connecting`);try{let t=await M.post(`/api/runs/${e}/talk`),n=await navigator.mediaDevices.getUserMedia({audio:!0});D.current=n;let r=new RTCPeerConnection;w.current=r;let i=document.createElement(`audio`);i.autoplay=!0,i.setAttribute(`playsinline`,``),document.body.append(i),E.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`);T.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`:{d(!0);let e=Date.now()-S.current>Ee?F():null;e&&(S.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`:d(!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`;y(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=O.current;e&&(N.current=Oe(e,k.current,C.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=()=>{w.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(`${j(`talk.failed`)} (${u.status})`);await r.setRemoteDescription({type:`answer`,sdp:await u.text()})}catch(e){z(),s(e.name===`NotAllowedError`?j(`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,f);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,f,P]),{state:i,error:o,speaking:c,listening:u,start:te,stop:z,camera:f,facing:m,startCamera:L,stopCamera:I,flipCamera:R,muted:g,toggleMute:ee,captions:v,video:b}}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]),a=(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},[]);ae(!!n?.readAloud,n?.lang??i,r,a);let o=[];for(let e of t){let t=o.at(-1);t&&t.who===`bot`&&e.who===`bot`?t.lines.push(e):o.push({who:e.who,lines:[e]})}return o.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)(te,{kind:e,size:30,interactive:n>=o.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:v(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?v(`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)(y,{className:`size-3`}),` `,j(`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":j(`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:v(`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)(T,{className:`size-4`}):null,t]})}function Fe({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:a,inputRef:o,onSend:c}){let[l,d]=(0,H.useState)(e),f=(0,H.useRef)(null),m=o??f,h=(0,H.useContext)(q),g=I(l,d,{endpoint:h?`/api/runs/${h.runId}/transcribe`:void 0}),_=!!h&&g.supported&&!a;(0,H.useEffect)(()=>{if(!_)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),g.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,g.toggle]),(0,H.useEffect)(()=>{!P&&!a&&m.current?.focus()},[a,m]);let y=()=>{i||a||(g.listening&&g.toggle(),c(l)!==!1&&d(``))},b=g.listening?j(`chat.listening`):g.processing?j(`chat.transcribing`):t,x=h?.voice??null,S=!!h?.call,C=h&&!S&&(ce||_||x)?(0,U.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[x?(0,U.jsx)(N,{label:j(x.state===`live`?`talk.stop`:x.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":x.state===`live`,disabled:x.state===`connecting`,onClick:()=>x.state===`live`?x.stop():void x.start(),className:v(`size-9`,x.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,x.state===`off`&&h.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:x.state===`connecting`?(0,U.jsx)(T,{className:`size-4`}):x.state===`live`?(0,U.jsx)(le,{className:`size-4`}):(0,U.jsx)(ne,{className:`size-4`})}):null,x?.state===`live`?(0,U.jsx)(N,{label:j(x.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":x.camera,onClick:()=>x.camera?x.stopCamera():void x.startCamera(),className:v(`size-9`,x.camera&&`text-ink`),children:x.camera?(0,U.jsx)(p,{className:`size-4`}):(0,U.jsx)(V,{className:`size-4`})}):null,ce?(0,U.jsx)(N,{label:j(h.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":h.readAloud,onClick:()=>h.setReadAloud(!h.readAloud),className:v(`size-9`,h.readAloud&&`text-ink`),children:h.readAloud?(0,U.jsx)(re,{className:`size-4`}):(0,U.jsx)(ve,{className:`size-4`})}):null,_?(0,U.jsx)(N,{label:j(g.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":g.listening,disabled:g.processing,onClick:g.toggle,className:v(`size-9`,g.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:g.processing?(0,U.jsx)(T,{className:`size-4`}):g.listening?(0,U.jsx)(s,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,U.jsx)(u,{className:`size-4`})}):null]}):null;return(0,U.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),y()},children:[x&&!S?(0,U.jsx)(`video`,{ref:x.video,muted:!0,playsInline:!0,autoPlay:!0,className:v(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,x.camera?`block`:`hidden`)}):null,(0,U.jsxs)(`div`,{className:v(`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:[C,n?(0,U.jsx)(ee,{ref:m,minRows:1,maxRows:6,value:l,disabled:a,placeholder:b,autoCapitalize:`sentences`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!P&&!e.nativeEvent.isComposing&&(e.preventDefault(),y())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,U.jsx)(`input`,{ref:m,...r,value:l,disabled:a,placeholder:b,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":j(`chat.send`),title:j(`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)(T,{className:`size-4`}):(0,U.jsx)(L,{className:`size-4`})})]}),g.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:g.error===`denied`?j(`chat.micDenied`):g.error}):S?null:x?.error?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:x.error}):x?.state===`live`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:x.speaking?j(`talk.speaking`):x.listening?j(`talk.listening`):j(`talk.live`)}):h?.talk&&x?.state===`off`?(0,U.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:j(`talk.hint`)}):null]})}function Q({placeholder:e=j(`chat.above`)}){return(0,U.jsx)(Me,{children:(0,U.jsx)(Fe,{disabled:!0,placeholder:e,onSend:()=>!1})})}function Ie(e){let t=B[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?j(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return j(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return j(`chat.badUrl`)}return e.kind===`number`&&!Number.isFinite(Number(r.replace(`,`,`.`)))?j(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?j(`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:j(`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`}),` `,j(`chat.checked`)]});if(e.kind===`toggle`)return(0,U.jsx)(U.Fragment,{children:j(t===!0?`run.yes`:`run.no`)});if(Le(t))return(0,U.jsx)(`span`,{className:`italic opacity-80`,children:j(`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(i,{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:v(`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`}),` `,j(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)(u,{className:`size-4`}),` `,j(`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:j(`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&&!l(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`,j(`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=>!l(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)(()=>w(n,e)),[c,l]=(0,H.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?D(Ke(n,e),e.known??{},w(n,e)).slice(0,-1).map(e=>e.id):[]),[u,d]=(0,H.useState)({}),[f,p]=(0,H.useState)(!1),[m,g]=(0,H.useState)(!1),_=D(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),S=x?()=>l(e=>e.filter(e=>e!==x.id)):void 0;(0,H.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=D(i,a,o),r=n.findIndex(t=>e.includes(t.id));r>=0&&(l(n.slice(0,r).map(e=>e.id)),d(t.fieldErrors))},[t.fieldErrors]);let C=e=>{t.submitPage(n.id,e).then(g)},T=(0,H.useContext)(q),E=(0,H.useRef)(o);E.current=o;let O=T?.bindPage,k=(0,H.useRef)(C);k.current=C,(0,H.useEffect)(()=>{if(!O)return;let e=D(i,a,o);return O({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]),d({}),null):`no such field on this page`},submit:()=>k.current(E.current)}),()=>O(null)},[O,n,i,a,o]);let A=e=>{if(!y)return!1;let t=Re(y,e);if(t)return d({[y.id]:t}),!1;let n={...o,[y.id]:e},r=[...c,y.id];return s(n),l(r),d({}),D(i,a,n).some(e=>!r.includes(e.id))||C(n),!0},M=[...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:S}:e)];y?(Ie(y)===`control`?M.push(G(`now:${n.id}:${y.id}:control`,(0,U.jsx)(h,{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:p}),{wide:!0})):b||M.push(G(`now:${n.id}:${y.id}`,(0,U.jsx)(Be,{field:y}))),u[y.id]&&M.push(G(`now:${n.id}:${y.id}:error`,u[y.id],{tone:`error`}))):t.busy||m?M.push(G(`sending`,(0,U.jsx)(Pe,{}))):t.error&&M.push(G(`send-error`,t.error,{tone:`error`}));let N=(0,U.jsx)(Q,{});if(m||!y&&c.length>0&&t.busy)N=(0,U.jsx)(Q,{placeholder:j(`run.working`)});else if(!y)M.push(X(`now:${n.id}:go`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Z,{primary:!0,busy:t.busy,onClick:()=>C(o),children:n.cta||j(`run.next`)}),S?(0,U.jsx)(Z,{onClick:S,disabled:t.busy,children:j(`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:j(`chat.skip`)}):null;if(r===`typed`){i&&M.push(X(`now:${n.id}:${y.id}:replies`,i));let e=o[y.id];N=(0,U.jsx)(Me,{children:(0,U.jsx)(Fe,{initial:Le(e)?``:String(e),multiline:y.kind===`textarea`,placeholder:y.placeholder||(b?y.label:j(`chat.placeholder`)),inputProps:Je(y),busy:t.busy,onSend:e=>A(ze(y,e))},y.id)})}else if(r===`tapped`)M.push(G(`now:${n.id}:${y.id}:replies`,(0,U.jsx)(Ye,{field:y,view:e,value:o[y.id],onAnswer:A}),{bare:!0}));else{let e=_.filter(e=>!c.includes(e.id)).length===1;M.push(X(`now:${n.id}:${y.id}:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Z,{primary:!0,disabled:f,onClick:()=>A(o[y.id]),children:e&&n.cta?n.cta:j(`chat.send`)}),i]})))}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:e.wizard.avatar,lines:M}),N]})}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 A(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:j(`run.no`)}),(0,U.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:j(`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?j(`chat.send`):j(`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:j(`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,i]=(0,H.useState)(Date.now());(0,H.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[]);let a=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),s=a.at(-1),l=[...a].reverse().find(Qe),u=[...new Set(a.map(e=>e.asset).filter(e=>!!e))];return(0,U.jsxs)(`div`,{className:v(`flex max-w-full flex-col gap-1`,l?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??j(`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??j(`run.working`)}),(0,U.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:j(`run.elapsed`,{s:Math.max(0,Math.round((r-n)/1e3))})})]}),s&&s!==l?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,U.jsx)(c,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,U.jsx)(`span`,{className:`truncate`,children:o(s)})]}):null,l&&e.status===`running`?(0,U.jsx)(et,{runId:e.id,event:l}):null,u.length?(0,U.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:u.slice(-6).map(t=>(0,U.jsx)(`img`,{src: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),[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=()=>M.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 u=i===`person`,d=async()=>{c(!0);try{let t=await M.post(`/api/runs/${e}/browser/seat`,{to:u?`agent`:`person`});a(t.seat)}catch{}finally{c(!1)}};return(0,U.jsx)(C,{runId:e,driving:u,caption:o(t),hint:j(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,U.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>void d(),className:v(`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`}),j(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:i,asked:o,onNote:s}){let c=e.shown.filter(e=>e.output),[l,u]=(0,H.useState)(c.length===1?c[0].step.id:null),d=(0,H.useRef)(null),p=[...i,...o.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}),...c.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)(a,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{u(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)(r,{runId:e.id,list:t}):(0,U.jsx)(f,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&p.push(G(`review-error`,t.error,{tone:`error`}));let m=n.regenerate&&c.length>0;return p.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`}),` `,j(`run.accept`)]}),m&&c.length>1?c.map(({step:e})=>(0,U.jsx)(Z,{on:l===e.id,onClick:()=>u(e.id),children:e.title},e.id)):null]}))),(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:e.wizard.avatar,lines:p}),m?(0,U.jsx)(Me,{children:(0,U.jsx)(Fe,{multiline:!0,inputRef:d,busy:t.busy,placeholder:c.length>1&&!l?j(`run.feedbackPick`):j(`run.feedbackPlaceholder`),disabled:!l,onSend:e=>{let r=e.trim();return!r||!l?!1:(s(r),t.regenerate(n.id,l,r),!0)}})}):(0,U.jsx)(Q,{})]})}function nt({view:e,run:t,step:n,before:r,onRestart:i}){let o=e.shown.filter(e=>e.output),s=`/api/runs/${e.id}`,c=[...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}),...o.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)(_,{base:s,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,U.jsx)(a,{base:s,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:j(`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)(k,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,U.jsx)(f,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return c.push(X(`result:replies`,(0,U.jsxs)(U.Fragment,{children:[o.length?(0,U.jsx)(ue,{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)(d,{className:`size-4`}),` `,j(`run.again`)]}):null,e.canBack?(0,U.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:j(`run.back`)}):null,e.keeps?(0,U.jsx)(`span`,{className:`ml-1`,children:(0,U.jsx)(m,{runId:e.id})}):null]}))),(0,U.jsx)(J,{avatar:e.wizard.avatar,lines:c})}function rt({runId:e,onRestart:t,onView:n,header:r,footer:a,talk:o=!1,call:s=!1}){let c=de(e),{view:l}=c,[u,f]=(0,H.useState)(null),p=ke(e,l,c,u);(0,H.useEffect)(()=>{n?.(l)},[l,n]);let[m,h]=ie(),g=(0,H.useMemo)(()=>({runId:e,lang:l?.lang??i,readAloud:m,setReadAloud:h,voice:l?.talk?p:null,talk:o,call:!!s,bindPage:f}),[e,l?.lang,l?.talk,m,h,p,o,s]);F(l?.status===`running`&&!l.ask),z(l);let[_,v]=(0,H.useState)({}),[y,b]=(0,H.useState)(null);(0,H.useEffect)(()=>{l&&l.status!==`running`&&b(null)},[l]);let S;if(c.notFound)S=(0,U.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:j(`run.notFound`)});else if(!l)S=(0,U.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,U.jsx)(T,{})});else{let e=l.step,n=l.status===`waiting_input`,r=Ge(l,l.canBack&&n&&!c.busy?()=>void c.back():void 0);if(l.status===`running`&&l.ask)S=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,G(`ask:${l.ask.id}`,(0,U.jsx)(O,{runId:l.id,ask:l.ask}),{wide:!0})]}),(0,U.jsx)(Q,{})]});else if(l.status===`running`)S=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,...y?[K(`note`,y)]:[],G(`working:${e?.id}`,(0,U.jsx)(Xe,{view:l}),{wide:l.events.some(t=>t.stepId===e?.id&&Qe(t))?`most`:void 0})]}),(0,U.jsx)(Q,{placeholder:j(`run.working`)})]});else if(l.status===`failed`)S=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,G(`failed`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`font-medium`,children:j(`run.failed`)}),l.error?(0,U.jsx)(`span`,{className:`mt-0.5 block`,children:(0,U.jsx)(x,{text:l.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{primary:!0,busy:c.busy,onClick:()=>void c.retry(),children:[(0,U.jsx)(d,{className:`size-4`}),` `,j(`run.retry`)]}),l.canBack?(0,U.jsx)(Z,{onClick:()=>void c.back(),disabled:c.busy,children:j(`run.back`)}):null]}))]}),(0,U.jsx)(Q,{})]});else if(l.status===`cancelled`)S=(0,U.jsx)(J,{avatar:l.wizard.avatar,lines:[...r,G(`cancelled`,j(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,U.jsxs)(Z,{primary:!0,onClick:t,children:[(0,U.jsx)(d,{className:`size-4`}),` `,j(`run.again`)]}))]:[]]});else if(e?.type===`page`)S=(0,U.jsx)(qe,{view:l,run:c,step:e,before:r},e.id);else if(e?.type===`review`){let t=l.shown.map(e=>e.output?.at??``).join(`|`);S=(0,U.jsx)(tt,{view:l,run:c,step:e,before:r,asked:_[e.id]??[],onNote:t=>{b(t),v(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else S=e?.type===`result`?(0,U.jsx)(nt,{view:l,run:c,step:e,before:r,onRestart:t}):(0,U.jsx)(J,{avatar:l.wizard.avatar,lines:r})}return s?(0,U.jsx)(q.Provider,{value: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:l,video:s===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,U.jsx)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-border-soft border-t lg:w-[420px] lg:flex-none lg:border-t-0 lg:border-l`,children:(0,U.jsx)(Ne,{footer:a,children:S})})]})}):(0,U.jsx)(q.Provider,{value:g,children:(0,U.jsx)(Ne,{header:r,footer:a,children:S})})}export{J as a,Z as i,Ne as n,X as o,Q as r,je as s,rt as t};