wizards 0.5.6 → 0.5.8

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 (113) hide show
  1. package/apps/runtime/dist/agents/architect.js +13 -26
  2. package/apps/runtime/dist/agents/studio-assistant.js +19 -22
  3. package/apps/runtime/dist/agents/subscription.js +10 -9
  4. package/apps/runtime/dist/app.js +9 -7
  5. package/apps/runtime/dist/assistant/knows.js +10 -9
  6. package/apps/runtime/dist/auth/index.js +7 -0
  7. package/apps/runtime/dist/connectors/external.js +3 -3
  8. package/apps/runtime/dist/connectors/index.js +23 -23
  9. package/apps/runtime/dist/connectors/via-account.js +6 -6
  10. package/apps/runtime/dist/documents/parse.js +3 -3
  11. package/apps/runtime/dist/engine/input.js +11 -11
  12. package/apps/runtime/dist/engine/requirements.js +7 -8
  13. package/apps/runtime/dist/engine/runner.js +10 -14
  14. package/apps/runtime/dist/engine/steps.js +6 -6
  15. package/apps/runtime/dist/engine/surface.js +2 -2
  16. package/apps/runtime/dist/film/step.js +5 -5
  17. package/apps/runtime/dist/harness/apple.js +2 -1
  18. package/apps/runtime/dist/harness/claude.js +2 -2
  19. package/apps/runtime/dist/harness/codex.js +2 -2
  20. package/apps/runtime/dist/harness/model.js +4 -5
  21. package/apps/runtime/dist/harness/terminal.js +4 -4
  22. package/apps/runtime/dist/media/conversation.js +18 -35
  23. package/apps/runtime/dist/media/transcribe.js +2 -1
  24. package/apps/runtime/dist/model-errors.js +1 -1
  25. package/apps/runtime/dist/models.js +32 -40
  26. package/apps/runtime/dist/plugins/runs.js +3 -5
  27. package/apps/runtime/dist/routes/api.js +9 -9
  28. package/apps/runtime/dist/routes/lang.js +14 -9
  29. package/apps/runtime/dist/routes/marketplace.js +6 -1
  30. package/apps/runtime/dist/routes/runs.js +5 -5
  31. package/apps/runtime/dist/routes/studio.js +38 -37
  32. package/apps/runtime/dist/services/access.js +4 -4
  33. package/apps/runtime/dist/services/architect.js +3 -12
  34. package/apps/runtime/dist/services/assistant-chats.js +2 -2
  35. package/apps/runtime/dist/services/brand.js +3 -3
  36. package/apps/runtime/dist/services/cloud.js +5 -5
  37. package/apps/runtime/dist/services/errors.js +2 -2
  38. package/apps/runtime/dist/services/knowledge-model.js +3 -3
  39. package/apps/runtime/dist/services/marketplace.js +18 -8
  40. package/apps/runtime/dist/services/package-file.js +9 -11
  41. package/apps/runtime/dist/services/package.js +8 -9
  42. package/apps/runtime/dist/services/profile.js +2 -1
  43. package/apps/runtime/dist/services/project-files.js +13 -13
  44. package/apps/runtime/dist/services/projects.js +7 -11
  45. package/apps/runtime/dist/services/runners.js +4 -4
  46. package/apps/runtime/dist/services/runs.js +7 -10
  47. package/apps/runtime/dist/services/shares.js +2 -2
  48. package/apps/runtime/dist/services/site.js +8 -11
  49. package/apps/runtime/dist/services/space-categories.js +7 -7
  50. package/apps/runtime/dist/services/space-data.js +20 -20
  51. package/apps/runtime/dist/services/spaces.js +7 -9
  52. package/apps/runtime/dist/services/wizards.js +11 -13
  53. package/apps/runtime/dist/store/index.js +2 -2
  54. package/apps/runtime/dist/texts.js +195 -0
  55. package/apps/runtime/dist/tools/plugin.js +7 -3
  56. package/apps/runtime/dist/widgets/step.js +2 -2
  57. package/apps/web/dist/assets/AboutDialog-BcTtA42P.js +1 -0
  58. package/apps/web/dist/assets/{ChangelogDialog-sdSC9eZj.js → ChangelogDialog-DMOWV_Iu.js} +1 -1
  59. package/apps/web/dist/assets/ChatView-CrnrYHjp.js +10 -0
  60. package/apps/web/dist/assets/EditorPage-DpEw3eOu.js +3 -0
  61. package/apps/web/dist/assets/{FlowPreview-B4-ipMdE.js → FlowPreview-CzmH4JUQ.js} +1 -1
  62. package/apps/web/dist/assets/{Harness-DwI4wFqj.js → Harness-DipH0Vec.js} +2 -2
  63. package/apps/web/dist/assets/{NewWizardChannels-DkI648G-.js → NewWizardChannels-DShu0PP6.js} +1 -1
  64. package/apps/web/dist/assets/NewWizardPage-HSa6PNJs.js +7 -0
  65. package/apps/web/dist/assets/OnboardingPage-CPADMs4c.js +1 -0
  66. package/apps/web/dist/assets/ProjectPage-DMPcrhgt.js +1 -0
  67. package/apps/web/dist/assets/PublicRunner-DZ5sWmtg.js +1 -0
  68. package/apps/web/dist/assets/{ReadOnly-Jvzgyelg.js → ReadOnly-B9xaq_M3.js} +1 -1
  69. package/apps/web/dist/assets/RunDrawer-9nMGhbSm.js +4 -0
  70. package/apps/web/dist/assets/{RunnerView-DN4sMYS6.js → RunnerView-NSSP3tc6.js} +1 -1
  71. package/apps/web/dist/assets/SettingsPage-Dy9MbwQh.js +1 -0
  72. package/apps/web/dist/assets/SetupPage-kemgI7v5.js +1 -0
  73. package/apps/web/dist/assets/{SharePage-CmowpiJG.js → SharePage-CQfIdcwy.js} +1 -1
  74. package/apps/web/dist/assets/{changelog-Cz8fZ-jG.js → changelog-BW40vzI6.js} +1 -1
  75. package/apps/web/dist/assets/{esm-J06O1nN_.js → esm-BF1nonbH.js} +1 -1
  76. package/apps/web/dist/assets/index-CnJ4Yzkf.css +1 -0
  77. package/apps/web/dist/assets/index-DQ9qAB4v.js +14 -0
  78. package/apps/web/dist/assets/{lock-ChDlFFHO.js → lock-DVvM6IsA.js} +1 -1
  79. package/apps/web/dist/assets/{phone-Cr7jz_kf.js → phone-3fG1okFs.js} +1 -1
  80. package/apps/web/dist/assets/{settings-menu-BAwHMXCR.js → settings-menu-D9fbi1Z0.js} +1 -1
  81. package/apps/web/dist/assets/ui-EuR3jezP.js +134 -0
  82. package/apps/web/dist/assets/{upload-DcAIMe8d.js → upload-BsMUhEfX.js} +1 -1
  83. package/apps/web/dist/index.html +3 -3
  84. package/apps/web/dist/mcp/flow.html +78 -78
  85. package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +26 -9
  86. package/node_modules/@engenty-wizards/shared/dist/definition.js +125 -3
  87. package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.d.ts +1 -1
  88. package/node_modules/@engenty-wizards/shared/dist/marketplace-entry.js +9 -8
  89. package/node_modules/@engenty-wizards/shared/dist/marketplace-search.js +6 -6
  90. package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +78 -205
  91. package/node_modules/@engenty-wizards/shared/dist/marketplace.js +167 -68
  92. package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +3 -6
  93. package/node_modules/@engenty-wizards/shared/dist/projects.js +9 -9
  94. package/node_modules/@engenty-wizards/shared/dist/providers.d.ts +33 -7
  95. package/node_modules/@engenty-wizards/shared/dist/providers.js +88 -37
  96. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +298 -365
  97. package/node_modules/@engenty-wizards/shared/dist/run.js +582 -240
  98. package/node_modules/@engenty-wizards/shared/dist/texts.d.ts +36 -0
  99. package/node_modules/@engenty-wizards/shared/dist/texts.js +46 -0
  100. package/package.json +1 -1
  101. package/apps/web/dist/assets/AboutDialog-Ck6_TSVJ.js +0 -1
  102. package/apps/web/dist/assets/ChatView-S1H9Pcih.js +0 -10
  103. package/apps/web/dist/assets/EditorPage-BSfJXx4W.js +0 -3
  104. package/apps/web/dist/assets/NewWizardPage-dumNiSqM.js +0 -7
  105. package/apps/web/dist/assets/OnboardingPage-BAfHLLNT.js +0 -1
  106. package/apps/web/dist/assets/ProjectPage-fneLQr6R.js +0 -1
  107. package/apps/web/dist/assets/PublicRunner-CuxDAXK7.js +0 -1
  108. package/apps/web/dist/assets/RunDrawer-C_T1I77g.js +0 -4
  109. package/apps/web/dist/assets/SettingsPage-DjFvKMRz.js +0 -1
  110. package/apps/web/dist/assets/SetupPage-CzYwVUvh.js +0 -1
  111. package/apps/web/dist/assets/index-CZFfDGHy.css +0 -1
  112. package/apps/web/dist/assets/index-DZTDv2pA.js +0 -14
  113. package/apps/web/dist/assets/ui-C5_NcAmG.js +0 -134
@@ -1,6 +1,6 @@
1
1
  import { versionChanges } from "@engenty-wizards/shared/changes";
2
2
  import { pluginToolOf, shapeIssues, validateWizard, wizardSchema, } from "@engenty-wizards/shared/definition";
3
- import { bilingual } from "@engenty-wizards/shared/run";
3
+ import { note } from "@engenty-wizards/shared/run";
4
4
  import { and, desc, eq, sql } from "drizzle-orm";
5
5
  import { nanoid } from "nanoid";
6
6
  import { applyOps, OpError } from "../authoring/ops.js";
@@ -11,6 +11,7 @@ import { saidOf } from "../model-errors.js";
11
11
  import { pluginToolsOf } from "../plugins/registry.js";
12
12
  import { dropLinks, putLink } from "../tenants/control.js";
13
13
  import { currentTenant } from "../tenants/tenant.js";
14
+ import { serverText } from "../texts.js";
14
15
  import { requireAdmin, requireBuild, requireWritable, requireWritableProject } from "./access.js";
15
16
  import { changedSteps, emitDraftChanged } from "./draft-events.js";
16
17
  import { notFound, ServiceError } from "./errors.js";
@@ -21,10 +22,9 @@ import { defaultProject, ownedProject } from "./projects.js";
21
22
  import { checkRunnerSettings } from "./runners.js";
22
23
  /** The wizard a new one starts as, in the language of whoever makes it. */
23
24
  function blankWizard(lang) {
24
- const de = lang === "de";
25
25
  return {
26
26
  version: 1,
27
- title: de ? "Neuer Wizard" : "New wizard",
27
+ title: serverText(lang, "newWizard"),
28
28
  description: "",
29
29
  avatar: "round",
30
30
  lang,
@@ -32,17 +32,17 @@ function blankWizard(lang) {
32
32
  {
33
33
  id: "start",
34
34
  type: "page",
35
- title: de ? "Los geht's" : "Let's start",
35
+ title: serverText(lang, "newWizardStart"),
36
36
  fields: [
37
37
  {
38
38
  id: "input",
39
- label: de ? "Worum geht es?" : "What is it about?",
39
+ label: serverText(lang, "newWizardAsk"),
40
40
  kind: "textarea",
41
41
  required: true,
42
42
  },
43
43
  ],
44
44
  },
45
- { id: "done", type: "result", title: de ? "Fertig" : "Done", deliverables: [] },
45
+ { id: "done", type: "result", title: serverText(lang, "newWizardDone"), deliverables: [] },
46
46
  ],
47
47
  };
48
48
  }
@@ -239,7 +239,7 @@ export async function createWizard(userId, input, writer = { source: "studio" })
239
239
  ? await marketplaceWizard(input.starterId, asLang(input.lang))
240
240
  : undefined;
241
241
  if (input.starterId && !starter) {
242
- throw new ServiceError("invalid", bilingual(`Die Vorlage „${input.starterId}“ gibt es nicht.`, `There’s no template “${input.starterId}”.`));
242
+ throw new ServiceError("invalid", note("unknownTemplate", { starterId: input.starterId }));
243
243
  }
244
244
  const maker = input.lang?.toLowerCase().startsWith("de") ? "de" : "en";
245
245
  const { draft, issues } = input.definition !== undefined
@@ -279,9 +279,7 @@ export async function createWizard(userId, input, writer = { source: "studio" })
279
279
  else if (fromStarter) {
280
280
  await addMessage(id, {
281
281
  role: "assistant",
282
- content: fromStarter.language === "en"
283
- ? `I have set up the template "${fromStarter.title}" for you. Test it at the top right – or tell me what should be different.`
284
- : `Ich habe die Vorlage „${fromStarter.title}“ für dich angelegt. Teste sie rechts oben – oder sag mir, was anders sein soll.`,
282
+ content: serverText(fromStarter.language, "templateSetUp", { title: fromStarter.title }),
285
283
  });
286
284
  }
287
285
  return { id, revision: 0, issues, studioUrl: studioUrl(id) };
@@ -308,7 +306,7 @@ export async function writeDraft(userId, wizardId, input, writer = { source: "st
308
306
  .returning({ revision: schema.wizard.revision });
309
307
  if (!row) {
310
308
  const current = await ownedWizard(userId, wizardId);
311
- throw new ServiceError("revision_conflict", bilingual("Der Wizard wurde inzwischen geändert.", "The wizard was changed in the meantime."), {
309
+ throw new ServiceError("revision_conflict", note("wizardChangedMeantime"), {
312
310
  revision: current.revision,
313
311
  });
314
312
  }
@@ -329,7 +327,7 @@ export async function writeDraft(userId, wizardId, input, writer = { source: "st
329
327
  export async function editWizard(userId, wizardId, input, writer) {
330
328
  const w = await writableWizard(userId, wizardId);
331
329
  if (w.revision !== input.baseRevision) {
332
- throw new ServiceError("revision_conflict", bilingual("Der Wizard wurde inzwischen geändert.", "The wizard was changed in the meantime."), {
330
+ throw new ServiceError("revision_conflict", note("wizardChangedMeantime"), {
333
331
  revision: w.revision,
334
332
  });
335
333
  }
@@ -401,7 +399,7 @@ export async function requireClean(w) {
401
399
  const files = await draftFiles(w.id);
402
400
  const issues = await checkDraft(w.projectId, w.draft, files.map((f) => f.path));
403
401
  if (issues.length) {
404
- throw new ServiceError("has_issues", bilingual("Der Wizard hat noch Fehler.", "The wizard still has errors."), { issues });
402
+ throw new ServiceError("has_issues", note("wizardStillErrors"), { issues });
405
403
  }
406
404
  return { definition: w.draft, files };
407
405
  }
@@ -1,4 +1,4 @@
1
- import { bilingual } from "@engenty-wizards/shared/run";
1
+ import { note } from "@engenty-wizards/shared/run";
2
2
  import { firstRowAt, newCells, patchCells, rowKey, STORE_LIMITS, } from "@engenty-wizards/shared/store";
3
3
  import { cleanPath, mimeForPath } from "@engenty-wizards/shared/workspace";
4
4
  import { and, asc, eq, inArray, like, lt, sql } from "drizzle-orm";
@@ -118,7 +118,7 @@ export async function updateRow(scope, def, rowId, patch) {
118
118
  })
119
119
  : null;
120
120
  if (clash) {
121
- throw new StoreError(bilingual("Diesen Eintrag gibt es schon.", "This entry already exists."));
121
+ throw new StoreError(note("entryAlreadyExists"));
122
122
  }
123
123
  await db
124
124
  .update(schema.storeRow)
@@ -0,0 +1,195 @@
1
+ import { textOf } from "@engenty-wizards/shared/texts";
2
+ /**
3
+ * What the server says itself, in each language: answers to a request, the lines about the
4
+ * assistants' work, the words of what it makes for a person (a first space, a new wizard).
5
+ * What a run reports, and errors that travel on as notes, are `RUN_NOTES` (shared/run).
6
+ */
7
+ const EN = {
8
+ keyUnknown: "The provider doesn’t recognise this key.",
9
+ providerError: "The provider answered with error {status}.",
10
+ providerUnreachable: "The provider cannot be reached right now.",
11
+ importedFrom: "Imported from “{name}”: {steps}, {files}.",
12
+ imported: "Imported: {steps}, {files}.",
13
+ stepCount: { one: "{count} step", other: "{count} steps" },
14
+ fileCount: { one: "{count} file", other: "{count} files" },
15
+ spaceStillNeeds: "This space still needs: {needs}. Add it under Settings → Connectors.",
16
+ notFinished: "I have not quite finished. Write “continue” and I will carry on right there.",
17
+ done: "Done.",
18
+ notUnderstood: "I did not understand that – could you put it differently?",
19
+ siteTakingOver: "Taking over what the website says …",
20
+ siteWritingPages: "Writing the pages into Knowledge …",
21
+ siteReading: "Reading the details …",
22
+ siteFailed: "The website could not be taken over.",
23
+ faqQuestion: "Question",
24
+ faqAnswer: "Answer",
25
+ tableTitle: "Table",
26
+ newWizard: "New wizard",
27
+ newWizardStart: "Let's start",
28
+ newWizardAsk: "What is it about?",
29
+ newWizardDone: "Done",
30
+ templateSetUp: "I have set up the template “{title}” for you. Test it at the top right – or tell me what should be different.",
31
+ imapHint: "Gmail, iCloud, GMX and web.de need an app password (in your account's security settings), not your normal password.",
32
+ doingSaveLogo: "Fetching the logo …",
33
+ doingSaveFile: "Fetching a file …",
34
+ doingSetLogoSections: "Grouping the logos …",
35
+ doingSetAssetSections: "Grouping the assets …",
36
+ doingSetTypography: "Entering the fonts …",
37
+ doingSetGradients: "Entering the gradients …",
38
+ doingSetRules: "Entering rules …",
39
+ doingSetProfile: "Writing title and description …",
40
+ doingSetFacts: "Entering facts …",
41
+ doingSetColors: "Entering the colours …",
42
+ doingLookAtFile: "Looking at a file …",
43
+ doingDescribeFile: "Describing a file …",
44
+ doingWebSearch: "Searching the web …",
45
+ doingReadSite: "Reading {host} …",
46
+ doingReadWebsite: "Reading the website …",
47
+ doingGuide: "Reading the building guide",
48
+ doingTemplate: "Looking at a template",
49
+ doingReadWizard: "Reading the wizard",
50
+ doingWriteFiles: "Writing files",
51
+ doingRebuild: "Rebuilding the wizard",
52
+ doingCheckWidget: "Checking the widget",
53
+ doingTestWizard: "Testing the wizard",
54
+ doingFindService: "Looking for a service",
55
+ doingWork: "Working",
56
+ doingFlow: "Building the flow …",
57
+ doingWriteFile: "Writing {path} …",
58
+ doingWriteAFile: "Writing a file …",
59
+ doingDownload: "Downloading data …",
60
+ doingReadWeb: "Reading the web …",
61
+ doingTestWidget: "Testing the widget …",
62
+ doingPrepare: "Preparing {output} …",
63
+ doingCalculate: "Calculating …",
64
+ doingLookFiles: "Looking at the files …",
65
+ doingTidyFiles: "Tidying up files …",
66
+ doingReadGuide: "Reading the guide …",
67
+ doingAuthoringGuide: "Reading the authoring guide …",
68
+ doingGallery: "Searching the gallery …",
69
+ doingPlans: "Looking up the plans …",
70
+ doingAccount: "Looking up the account …",
71
+ doingUsage: "Looking up the usage …",
72
+ doingModels: "Looking up the models …",
73
+ doingEarlierChats: "Searching earlier chats …",
74
+ somethingWrong: "Something went wrong. Try again.",
75
+ firstSpaceCloud: "My wizards",
76
+ firstSpaceLocal: "My computer",
77
+ invalidInput: "Invalid input",
78
+ internalError: "Internal error",
79
+ notSignedIn: "You’re not signed in.",
80
+ accountSuspended: "This account is suspended.",
81
+ tooLarge: "That is too large.",
82
+ tooManyTriesWait: "Too many tries. Wait a moment and try again.",
83
+ tooManyTransfersTry: "Too many transfers. Try again later.",
84
+ pluginNotPartPlan: "This plugin is not part of your plan. It comes with Pro.",
85
+ wizardNotPublishedYet: "The wizard is not published yet.",
86
+ tooManyTimesRow: "Too many times in a row. Try again later.",
87
+ onlyAvailableCloud: "This is only available in the cloud.",
88
+ onlyAvailableComputer: "This is only available on your computer.",
89
+ somethingWentWrongTry: "Something went wrong. Try again.",
90
+ unknownApp: "Unknown app.",
91
+ onlyTeamAdminsChange: "Only team admins can change its models.",
92
+ notAvailableCloud: "This isn’t available in the cloud.",
93
+ noApiKeySet: "No API key is set.",
94
+ onlyTeamAdminsTest: "Only team admins can test its models.",
95
+ notFound: "This doesn’t exist or was deleted.",
96
+ ownKeysNotInPlan: "Your own API keys aren’t part of the {plan} plan.",
97
+ ownKeysNotInTeamPlan: "Your own API keys aren’t part of the team’s plan.",
98
+ };
99
+ const DE = {
100
+ keyUnknown: "Der Anbieter kennt diesen API-Key nicht.",
101
+ providerError: "Der Anbieter antwortet mit Fehler {status}.",
102
+ providerUnreachable: "Der Anbieter ist gerade nicht erreichbar.",
103
+ importedFrom: "Importiert aus „{name}“: {steps}, {files}.",
104
+ imported: "Importiert: {steps}, {files}.",
105
+ stepCount: { one: "{count} Schritt", other: "{count} Schritte" },
106
+ fileCount: { one: "{count} Datei", other: "{count} Dateien" },
107
+ spaceStillNeeds: "Diesem Space fehlt noch: {needs}. Füge es unter Einstellungen → Connectors hinzu.",
108
+ notFinished: "Ich bin noch nicht ganz fertig geworden. Schreib „weiter“, dann mache ich genau dort weiter.",
109
+ done: "Erledigt.",
110
+ notUnderstood: "Das habe ich nicht verstanden – magst du es anders formulieren?",
111
+ siteTakingOver: "Übernimmt die Angaben der Website …",
112
+ siteWritingPages: "Schreibt die Seiten in Wissen …",
113
+ siteReading: "Liest die Angaben …",
114
+ siteFailed: "Die Website ließ sich nicht übernehmen.",
115
+ faqQuestion: "Frage",
116
+ faqAnswer: "Antwort",
117
+ tableTitle: "Tabelle",
118
+ newWizard: "Neuer Wizard",
119
+ newWizardStart: "Los geht's",
120
+ newWizardAsk: "Worum geht es?",
121
+ newWizardDone: "Fertig",
122
+ templateSetUp: "Ich habe die Vorlage „{title}“ für dich angelegt. Teste sie rechts oben – oder sag mir, was anders sein soll.",
123
+ imapHint: "Bei Gmail, iCloud, GMX und web.de brauchst du ein App-Passwort (in den Sicherheitseinstellungen deines Kontos), nicht dein normales Passwort.",
124
+ doingSaveLogo: "Holt das Logo …",
125
+ doingSaveFile: "Holt eine Datei …",
126
+ doingSetLogoSections: "Ordnet die Logos …",
127
+ doingSetAssetSections: "Ordnet die Assets …",
128
+ doingSetTypography: "Trägt die Schriften ein …",
129
+ doingSetGradients: "Trägt die Verläufe ein …",
130
+ doingSetRules: "Trägt Regeln ein …",
131
+ doingSetProfile: "Schreibt Titel und Beschreibung …",
132
+ doingSetFacts: "Trägt Fakten ein …",
133
+ doingSetColors: "Trägt die Farben ein …",
134
+ doingLookAtFile: "Sieht sich eine Datei an …",
135
+ doingDescribeFile: "Beschreibt eine Datei …",
136
+ doingWebSearch: "Sucht im Web …",
137
+ doingReadSite: "Liest {host} …",
138
+ doingReadWebsite: "Liest die Website …",
139
+ doingGuide: "Liest die Bauanleitung",
140
+ doingTemplate: "Sieht sich eine Vorlage an",
141
+ doingReadWizard: "Liest den Wizard",
142
+ doingWriteFiles: "Schreibt Dateien",
143
+ doingRebuild: "Baut den Wizard um",
144
+ doingCheckWidget: "Prüft das Widget",
145
+ doingTestWizard: "Testet den Wizard",
146
+ doingFindService: "Sucht einen Dienst",
147
+ doingWork: "Arbeitet",
148
+ doingFlow: "Baut den Ablauf …",
149
+ doingWriteFile: "Schreibt {path} …",
150
+ doingWriteAFile: "Schreibt eine Datei …",
151
+ doingDownload: "Lädt Daten herunter …",
152
+ doingReadWeb: "Liest im Web …",
153
+ doingTestWidget: "Testet das Widget …",
154
+ doingPrepare: "Bereitet {output} vor …",
155
+ doingCalculate: "Rechnet …",
156
+ doingLookFiles: "Sieht sich die Dateien an …",
157
+ doingTidyFiles: "Räumt Dateien auf …",
158
+ doingReadGuide: "Liest in der Anleitung …",
159
+ doingAuthoringGuide: "Liest die Bauanleitung …",
160
+ doingGallery: "Sucht in der Galerie …",
161
+ doingPlans: "Sieht die Pläne nach …",
162
+ doingAccount: "Sieht das Konto nach …",
163
+ doingUsage: "Sieht den Verbrauch nach …",
164
+ doingModels: "Sieht die Modelle nach …",
165
+ doingEarlierChats: "Sucht in früheren Chats …",
166
+ somethingWrong: "Da ist etwas schiefgelaufen. Versuch es noch einmal.",
167
+ firstSpaceCloud: "Meine Wizards",
168
+ firstSpaceLocal: "Mein Computer",
169
+ invalidInput: "Ungültige Eingabe",
170
+ internalError: "Interner Fehler",
171
+ notSignedIn: "Du bist nicht angemeldet.",
172
+ accountSuspended: "Dieses Konto ist gesperrt.",
173
+ tooLarge: "Das ist zu groß.",
174
+ tooManyTriesWait: "Zu viele Versuche. Warte kurz und versuch es noch einmal.",
175
+ tooManyTransfersTry: "Zu viele Übertragungen. Versuch es später noch einmal.",
176
+ pluginNotPartPlan: "Dieses Plugin gehört nicht zu deinem Paket. Mit Pro ist es dabei.",
177
+ wizardNotPublishedYet: "Der Wizard ist noch nicht veröffentlicht.",
178
+ tooManyTimesRow: "Zu oft hintereinander. Versuch es später noch einmal.",
179
+ onlyAvailableCloud: "Das gibt es nur in der Cloud.",
180
+ onlyAvailableComputer: "Das gibt es nur auf deinem Computer.",
181
+ somethingWentWrongTry: "Da ist etwas schiefgelaufen. Versuch es noch einmal.",
182
+ unknownApp: "Diese App gibt es nicht.",
183
+ onlyTeamAdminsChange: "Nur Admins des Teams ändern seine Modelle.",
184
+ notAvailableCloud: "Das gibt es nicht in der Cloud.",
185
+ noApiKeySet: "Kein API-Key hinterlegt.",
186
+ onlyTeamAdminsTest: "Nur Admins des Teams testen seine Modelle.",
187
+ notFound: "Das gibt es nicht oder nicht mehr.",
188
+ ownKeysNotInPlan: "Eigene API-Keys gibt es nicht im Paket {plan}.",
189
+ ownKeysNotInTeamPlan: "Eigene API-Keys gibt es nicht im Paket des Teams.",
190
+ };
191
+ export const SERVER_TEXTS = { en: EN, de: DE };
192
+ /** A line of the server's table in a language; English where the language lacks it. */
193
+ export function serverText(lang, key, params) {
194
+ return textOf(SERVER_TEXTS, key, lang, params);
195
+ }
@@ -1,5 +1,5 @@
1
1
  import { pluginToolOf } from "@engenty-wizards/shared/definition";
2
- import { bilingual } from "@engenty-wizards/shared/run";
2
+ import { note } from "@engenty-wizards/shared/run";
3
3
  import { createTool } from "@mastra/core/tools";
4
4
  import { StepError } from "../engine/types.js";
5
5
  import { loadedPlugin, pluginIdsOf, pluginsOf } from "../plugins/registry.js";
@@ -39,7 +39,7 @@ async function toolOf(id, ctx) {
39
39
  const found = named && has.has(named.plugin) ? loadedPlugin(named.plugin)?.tools.get(named.tool) : undefined;
40
40
  if (!(named && found)) {
41
41
  const plugin = named?.plugin ?? id;
42
- throw new StepError(bilingual(`Dieser Schritt braucht das Werkzeug „${id}“. Das Plugin „${plugin}“ ist hier nicht installiert.`, `This step needs the tool “${id}”. The plugin “${plugin}” isn’t installed here.`));
42
+ throw new StepError(note("stepNeedsToolPlugin", { id, plugin }));
43
43
  }
44
44
  return { plugin: named.plugin, tool: found };
45
45
  }
@@ -52,7 +52,11 @@ export async function callPluginTool(id, input, ctx) {
52
52
  const parsed = tool.inputSchema.safeParse(input);
53
53
  if (!parsed.success) {
54
54
  const issue = parsed.error.issues[0];
55
- throw new StepError(bilingual(`„${id}“ bekam ungültige Angaben: ${issue?.path.join(".") || "input"} – ${issue?.message}`, `“${id}” got invalid input: ${issue?.path.join(".") || "input"} – ${issue?.message}`));
55
+ throw new StepError(note("pluginInvalidInput", {
56
+ id,
57
+ path: issue?.path.join(".") || "input",
58
+ problem: issue?.message ?? "",
59
+ }));
56
60
  }
57
61
  try {
58
62
  return await tool.execute(parsed.data, toolContext(ctx));
@@ -1,5 +1,5 @@
1
1
  import { allFields, dataRef, widgetSize, } from "@engenty-wizards/shared/definition";
2
- import { bilingual } from "@engenty-wizards/shared/run";
2
+ import { note } from "@engenty-wizards/shared/run";
3
3
  import { resolveRef } from "../engine/template.js";
4
4
  import { StepError } from "../engine/types.js";
5
5
  import { extFor, inlineAssetRefs, loadAsset } from "../files/storage.js";
@@ -107,7 +107,7 @@ async function runFilmStep(step, ctx, html, data, media, origin) {
107
107
  }
108
108
  });
109
109
  if (!film) {
110
- throw new StepError(bilingual("Der Film ließ sich nicht rendern. Dafür braucht es ffmpeg und eine Zeitleiste im Widget.", "The film couldn’t be rendered. It needs ffmpeg and a timeline in the widget."));
110
+ throw new StepError(note("filmNotRenderedNeeds"));
111
111
  }
112
112
  if (film.errors.length) {
113
113
  await ctx.emit("info", {
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$n as r,At as i,Jn as a,Mt as o,Nt as s,Rt as c,Tn as l,Ut as u,Vt as d,Yt as f,jt as p}from"./ui-EuR3jezP.js";import{t as m}from"./preload-helper-CNEI7N0N.js";import{H as h,U as g,W as _,yt as v}from"./index-DQ9qAB4v.js";import{c as y,f as b}from"./settings-menu-D9fbi1Z0.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-DMOWV_Iu.js";var T=e(t(),1),E=[{name:`engenty wizards`,description:`credit.engenty-wizards`,homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:`credit.engenty`,homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],D=[{name:`Mastra`,description:`credit.mastra`,homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:`credit.ai-sdk`,homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:`credit.model-context-protocol`,homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:`credit.hono`,homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:`credit.drizzle-orm`,homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:`credit.libsql`,homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:`credit.playwright`,homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`agentOS`,description:`credit.agentos`,homepage:`https://github.com/rivet-dev/agentos`,license:`Apache-2.0`},{name:`React`,description:`credit.react`,homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:`credit.vite`,homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:`credit.tailwind-css`,homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:`credit.react-flow`,homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:`credit.tanstack-query`,homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:`credit.xterm-js`,homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:`credit.lucide`,homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:`credit.geist-geist-mono`,homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:`credit.space-grotesk`,homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:`credit.git-cliff`,homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],O=e(n(),1),k=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function A({name:e,homepage:t,version:n,license:r,description:i}){return(0,O.jsxs)(`li`,{className:`py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,O.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.875rem] text-ink underline-offset-4 hover:underline`,children:[e,(0,O.jsx)(a,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,O.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),i?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):null]})}function j({title:e,hint:t,children:n}){return(0,O.jsxs)(`section`,{className:`mt-6`,children:[(0,O.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,O.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function M({credits:e}){return(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,O.jsx)(A,{name:e.name,homepage:e.homepage,license:e.license,description:f(e.description)},e.name))})}function N({label:e,packages:t}){return(0,O.jsxs)(`div`,{className:`mt-4`,children:[(0,O.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,O.jsx)(A,{...e},e.name))})]})}function P({active:e}){let[t,n]=(0,T.useState)(null),[r,i]=(0,T.useState)(``);(0,T.useEffect)(()=>{if(!e||t)return;let r=!1;return m(()=>import(`./oss-credits-BJrR7BR1.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,T.useEffect)(()=>{e||i(``)},[e]);let a=r.trim().toLowerCase(),o=e=>a?e.filter(e=>k(a,e.name,e.license,f(e.description))):e,l=e=>a?e.filter(e=>k(a,e.name,e.license,e.version)):e,u=o(E),d=o(D),h=t?[{id:`shared`,label:f(`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=u.length===0&&d.length===0&&h.length===0;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:f(`about.creditsHint`)}),(0,O.jsx)(s,{type:`search`,value:r,placeholder:f(`about.search`),onChange:e=>i(e.target.value)}),u.length>0?(0,O.jsx)(j,{title:f(`about.creditsProduct`),children:(0,O.jsx)(M,{credits:u})}):null,d.length>0?(0,O.jsx)(j,{title:f(`about.creditsBuiltWith`),children:(0,O.jsx)(M,{credits:d})}):null,t===null?(0,O.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,O.jsx)(c,{})}):h.length>0?(0,O.jsx)(j,{title:f(`about.creditsDeps`),hint:a?void 0:f(`about.creditsDepsHint`),children:h.map(e=>(0,O.jsx)(N,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,O.jsx)(p,{children:f(`about.noMatches`)}):null]})}var F=[`new`,`earlier`,`credits`],I=e=>f(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),L=e=>e===1?f(`about.change`):f(`about.changes`,{n:e});function R({open:e,onClose:t,me:n}){let a=n?.mode===`local`,{data:s,latest:p}=_(a&&e),[m,E]=(0,T.useState)(null),[D,k]=(0,T.useState)(`new`),A=b(F.indexOf(D)),j=s?.newer&&p?p:g;(0,T.useEffect)(()=>{if(!e)return;let t=!1;return E(null),S(j===`0.5.8`?void 0:j).then(e=>{t||E(e)}),()=>{t=!0}},[e,j]);let M=m?.find(e=>e.version===`v${j}`)??m?.[0]??null,N=m?.filter(e=>e!==M)??[],R=a?s?.kind??null:`cloud`;return(0,O.jsxs)(i,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,O.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,O.jsx)(o,{label:f(`common.close`),onClick:t,children:(0,O.jsx)(l,{className:`size-4`})})}),(0,O.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,O.jsx)(v,{size:96}),(0,O.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,O.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,O.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,O.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[f(`about.version`,{v:g}),R?` · ${f(`about.kind.${R}`)}`:``]})]}),a?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(h,{enabled:e})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(d,{value:D,onChange:k,options:F.map(e=>({id:e,label:I(e)})),label:f(`about.title`)})}),(0,O.jsxs)(`div`,{className:u(`mt-5`,y(A)),children:[D===`new`?m===null?(0,O.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,O.jsx)(c,{})}):M?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[w(M),(0,O.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:C(M)})]}),(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(x,{release:M})})]}):(0,O.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:f(`about.changelogEmpty`)}):null,D===`earlier`?(0,O.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:N.map(e=>(0,O.jsxs)(`details`,{className:`group/r py-2`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,O.jsx)(r,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,O.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:w(e)}),(0,O.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(e)}),(0,O.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:L(e.commits.length)})]}),(0,O.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,O.jsx)(x,{release:e})})]},e.version??`unreleased`))}):null,D===`credits`?(0,O.jsx)(P,{active:!0}):null]},D)]})}export{R as AboutDialog};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Qt as i,dn as a,gn as o,on as s,tn as c}from"./ui-C5_NcAmG.js";import{t as l}from"./preload-helper-CNEI7N0N.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):o(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/engenty-wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await l(async()=>{let{default:e}=await import(`./changelog-Cz8fZ-jG.js`);return{default:e}},[])).default}function v({release:e}){return(0,d.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:a(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:o(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[a,l]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||a)return;let t=!1;return _(n).then(e=>{t||l(e)}),()=>{t=!0}},[e,a,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=a?g(a,f):[];return(0,d.jsxs)(i,{open:e,onClose:t,title:o(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:o(`about.changelogHint`)}),a===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(s,{})}):a.length===0?(0,d.jsx)(r,{children:o(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(c,{type:`search`,value:f,placeholder:o(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(r,{children:o(`about.noMatches`)}):null,y.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`div`,{className:`mt-3`,children:(0,d.jsx)(v,{release:e})})]},e.version??`unreleased`))]})]})}export{y as ChangelogDialog,v as ReleaseNotes,_ as loadReleases,m as releaseDate,p as releaseLabel};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{At as r,Nt as i,Rt as a,Ut as o,Yt as s,jt as c}from"./ui-EuR3jezP.js";import{t as l}from"./preload-helper-CNEI7N0N.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):s(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/engenty-wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await l(async()=>{let{default:e}=await import(`./changelog-BW40vzI6.js`);return{default:e}},[])).default}function v({release:e}){return(0,d.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:o(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:s(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[o,l]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||o)return;let t=!1;return _(n).then(e=>{t||l(e)}),()=>{t=!0}},[e,o,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=o?g(o,f):[];return(0,d.jsxs)(r,{open:e,onClose:t,title:s(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:s(`about.changelogHint`)}),o===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(a,{})}):o.length===0?(0,d.jsx)(c,{children:s(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i,{type:`search`,value:f,placeholder:s(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(c,{children:s(`about.noMatches`)}):null,y.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`div`,{className:`mt-3`,children:(0,d.jsx)(v,{release:e})})]},e.version??`unreleased`))]})]})}export{y as ChangelogDialog,v as ReleaseNotes,_ as loadReleases,m as releaseDate,p as releaseLabel};
@@ -0,0 +1,10 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,An as i,Cn as a,En as o,Ft as s,Gt as c,Ht as l,In as u,Mn as d,Mt as f,On as p,Rt as m,Ut as h,Vn as g,W as _,Wt as v,Yt as y,_t as b,cr as x,dt as S,ft as C,gn as w,gt as T,ht as E,ir as D,kn as O,lt as k,mt as A,nr as j,nt as M,p as N,pt as P,rn as F,rt as I,st as L,tt as R,ut as ee,vt as z,yr as B,zn as te}from"./ui-EuR3jezP.js";import{t as ne}from"./phone-3fG1okFs.js";import{Pt as re,Q as ie,X as ae,Z as oe,jt as se,mt as ce,t as le,xt as ue}from"./index-DQ9qAB4v.js";import{n as de}from"./RunnerView-NSSP3tc6.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=x(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=x(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 _e=x(ge),ve={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`}]]};ve.node;var ye=x(ve),be=B(),V=e(t(),1),H=e(n(),1),xe=typeof window<`u`&&window.matchMedia(`(pointer: coarse)`).matches;function Se({since:e}){let[t,n]=(0,V.useState)(Date.now());if((0,V.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,H.jsxs)(`span`,{className:`font-mono text-[0.8125rem] text-white/60 tabular-nums`,children:[i,`:`,a]})}function U({label:e,on:t,danger:n,busy:r,onClick:i,children:a}){return(0,H.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-pressed":t,disabled:r,onClick:i,className:h(`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,H.jsx)(m,{className:`size-5`}):a})}function Ce({voice:e}){let t=(0,V.useRef)(null),{captions:n}=e;return(0,V.useEffect)(()=>{n.length&&t.current?.scrollIntoView({block:`end`})},[n]),n.length?(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 sm:px-5`,children:(0,H.jsxs)(`ol`,{className:`mx-auto flex max-w-[720px] flex-col gap-2 py-2`,children:[n.map(e=>(0,H.jsx)(`li`,{className:h(`text-[0.9375rem] leading-snug`,e.who===`bot`?`text-white/95`:`text-right text-white/50`),children:e.text},e.id)),(0,H.jsx)(`div`,{ref:t})]})}):null}function we({voice:e,view:t,video:n,className:r}){let i=e.state===`live`,a=e.state===`connecting`,[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{c(i?Date.now():null)},[i]);let d=async()=>{u(!1),await e.start(),n&&await e.startCamera()},f=()=>{e.stop(),u(!0)},_=n||e.camera,v=[...e.captions].reverse().find(e=>e.who===`bot`),b=[...e.captions].reverse().find(e=>e.who===`me`),x=e.speaking?y(`talk.speaking`):e.listening?y(`talk.listening`):i?y(`talk.live`):a?y(`talk.connecting`):l?y(`video.ended`):``;return(0,H.jsxs)(`section`,{className:h(`relative flex min-h-0 flex-col bg-neutral-950 text-white`,`safe-top`,r),children:[(0,H.jsxs)(`div`,{className:`flex h-14 shrink-0 items-center gap-3 px-4 sm:px-5`,children:[(0,H.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-[1rem] tracking-tight`,children:t?.wizard.title??``}),x?(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-white/70`,children:[i?(0,H.jsx)(`span`,{className:h(`size-2 rounded-full`,e.speaking?`animate-pulse-dot bg-emerald-400`:`bg-rose`)}):null,x]}):null,(0,H.jsx)(Se,{since:s})]}),(0,H.jsxs)(`div`,{className:h(`grid min-h-0 gap-2 px-3 pb-2 sm:px-4`,_?`flex-1 grid-cols-1 sm:grid-cols-2`:`shrink-0 grid-cols-1`,!_&&i&&e.captions.length?`h-[38%]`:_?``:`flex-1`),children:[(0,H.jsxs)(`div`,{className:h(`relative min-h-0 overflow-hidden rounded-2xl bg-neutral-900`,!_&&`hidden`),children:[(0,H.jsx)(`video`,{ref:e.video,muted:!0,playsInline:!0,autoPlay:!0,className:h(`absolute inset-0 h-full w-full object-cover`,e.facing===`user`&&`-scale-x-100`,e.camera?`block`:`hidden`)}),e.camera?null:(0,H.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-white/50`,children:[(0,H.jsx)(_e,{className:`size-8`}),(0,H.jsx)(`span`,{className:`text-[0.8125rem]`,children:y(`video.cameraOff`)})]}),(0,H.jsxs)(`span`,{className:`absolute bottom-2 left-3 rounded-md bg-black/50 px-2 py-0.5 text-[0.75rem]`,children:[y(`video.you`),e.muted?(0,H.jsx)(re,{className:`ml-1.5 inline size-3`}):null]})]}),(0,H.jsxs)(`div`,{className:h(`relative flex min-h-0 items-center justify-center overflow-hidden rounded-2xl transition-shadow`,_?`bg-neutral-900`:`bg-transparent`,_&&e.speaking&&`ring-2 ring-emerald-400/70`),children:[(0,H.jsx)(`div`,{className:h(`rounded-full transition-shadow duration-500`,!_&&e.listening&&`shadow-[0_0_80px_20px_rgba(244,63,94,0.25)]`,!_&&e.speaking&&`shadow-[0_0_80px_20px_rgba(52,211,153,0.3)]`,e.speaking&&`animate-breathe`),children:(0,H.jsx)(ce,{kind:t?.wizard.avatar??`round`,size:_?140:200,fluffy:!0,interactive:!1})}),_?(0,H.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&&!_?(0,H.jsx)(Ce,{voice:e}):i&&(v||b)?(0,H.jsx)(`div`,{className:`shrink-0 px-4 pb-2 sm:px-5`,children:(0,H.jsxs)(`div`,{className:`mx-auto max-w-[720px] space-y-1 text-center`,children:[b?(0,H.jsx)(`p`,{className:`line-clamp-1 text-[0.8125rem] text-white/50`,children:b.text}):null,v?(0,H.jsx)(`p`,{className:`line-clamp-3 text-[0.9375rem] text-white/95 leading-snug`,children:v.text}):null]})}):null,e.error?(0,H.jsx)(`p`,{className:`shrink-0 px-5 pb-2 text-center text-[0.8125rem] text-rose`,children:e.error}):null,(0,H.jsx)(`div`,{className:`flex shrink-0 items-center justify-center gap-3 px-4 pt-1 pb-4`,children:i?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{label:y(e.muted?`video.unmute`:`video.mute`),on:!e.muted,onClick:e.toggleMute,children:e.muted?(0,H.jsx)(re,{className:`size-5`}):(0,H.jsx)(g,{className:`size-5`})}),(0,H.jsx)(U,{label:y(e.camera?`talk.cameraOff`:`talk.camera`),on:e.camera,onClick:()=>e.camera?e.stopCamera():void e.startCamera(),children:e.camera?(0,H.jsx)(o,{className:`size-5`}):(0,H.jsx)(_e,{className:`size-5`})}),e.camera&&xe?(0,H.jsx)(U,{label:y(`video.flip`),onClick:()=>void e.flipCamera(),children:(0,H.jsx)(p,{className:`size-5`})}):null,(0,H.jsx)(U,{label:y(`video.leave`),danger:!0,onClick:f,children:(0,H.jsx)(se,{className:`size-5`})})]}):(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,H.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,H.jsx)(m,{className:`size-4`}):n?(0,H.jsx)(o,{className:`size-5`}):(0,H.jsx)(g,{className:`size-5`}),y(l?`video.rejoin`:n?`video.join`:`talk.start`)]}),!l&&!e.error?(0,H.jsx)(`p`,{className:`max-w-sm text-center text-[0.75rem] text-white/50`,children:y(n?`video.hint`:`talk.joinHint`)}):null]})})]})}var Te=e=>F[e.kind]!==`device`,Ee=1024,De=4e3;function W(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: ${v(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}: ${W(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=Te(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?` = ${W(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}": ${W(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,V.useState)(`off`),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(`environment`),[g,v]=(0,V.useState)(!1),[b,x]=(0,V.useState)([]),S=(0,V.useRef)(null),C=(0,V.useRef)(null),w=(0,V.useRef)(0),T=(0,V.useRef)(!1);T.current=f;let E=(0,V.useRef)(null),D=(0,V.useRef)(null),O=(0,V.useRef)(null),k=(0,V.useRef)(null),A=(0,V.useRef)(t);A.current=t;let j=(0,V.useRef)(r);j.current=r;let M=(0,V.useRef)(n);M.current=n;let N=(0,V.useRef)(``),P=(0,V.useCallback)(e=>{let t=D.current;t&&t.readyState===`open`&&t.send(JSON.stringify(e))},[]),F=(0,V.useCallback)(()=>{let e=S.current;if(!T.current||!e||e.videoWidth===0)return null;let t=Math.min(1,Ee/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,V.useCallback)(()=>{for(let e of C.current?.getTracks()??[])e.stop();C.current=null,S.current&&(S.current.srcObject=null),p(!1)},[]),L=(0,V.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;h(n===`user`||n===`environment`?n:t),S.current&&(S.current.srcObject=e,await S.current.play().catch(()=>void 0)),p(!0)}catch(e){s(e.name===`NotAllowedError`?y(`talk.cameraDenied`):e.message)}},[]),R=(0,V.useCallback)(async()=>{let e=m===`user`?`environment`:`user`;I(),await L(e)},[m,I,L]),ee=(0,V.useCallback)(()=>{v(e=>{for(let t of k.current?.getAudioTracks()??[])t.enabled=e;return!e})},[]),z=(0,V.useCallback)(()=>{I(),D.current?.close(),D.current=null,E.current?.close(),E.current=null;for(let e of k.current?.getTracks()??[])e.stop();k.current=null,O.current&&=(O.current.srcObject=null,O.current.remove(),null),N.current=``,l(!1),d(!1),v(!1),a(`off`)},[I]);(0,V.useEffect)(()=>()=>z(),[z]);let B=(0,V.useCallback)(async(t,n)=>{let r=A.current,i=j.current,a=M.current;switch(t){case`get_state`:return r?Oe(r,i,T.current):`no run`;case`look`:{let e=F();return e?(P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[camera] what the person shows right now`},{type:`input_image`,image_url:e}]}}),`a picture arrived as the next message`):`the camera is off; ask the person to switch it on`}case`take_photo`:{if(!i)return`no page is open`;let t=i.fields.find(e=>e.id===String(n.field??``));if(t?.kind!==`image`)return`no such photo field on this page`;let r=F();if(!r)return`the camera is off; ask the person to switch it on`;try{let n=await(await fetch(r)).blob(),a=new File([n],`photo-${Date.now()}.jpg`,{type:`image/jpeg`}),o=await _.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&&Te(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 _.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,V.useCallback)(async()=>{if(!E.current){s(null),x([]),a(`connecting`);try{let t=await _.post(`/api/runs/${e}/talk`),n=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});k.current=n;let r=new RTCPeerConnection;E.current=r;let i=document.createElement(`audio`);i.autoplay=!0,i.setAttribute(`playsinline`,``),document.body.append(i),O.current=i,r.ontrack=e=>{i.srcObject=e.streams[0]};for(let e of n.getTracks())r.addTrack(e,n);let o=r.createDataChannel(`oai-events`);D.current=o,o.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}switch(t.type){case`output_audio_buffer.started`:l(!0);break;case`output_audio_buffer.stopped`:case`output_audio_buffer.cleared`:l(!1);break;case`input_audio_buffer.speech_started`:{d(!0);let e=Date.now()-w.current>De?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`: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`;x(t=>[...t.slice(-199),{id:`${Date.now()}:${n}`,who:n,text:e}])}break}case`response.function_call_arguments.done`:{let e=String(t.name??``),n=String(t.call_id??``),r={};try{r=JSON.parse(String(t.arguments??`{}`))}catch{}B(e,r).then(e=>{P({type:`conversation.item.create`,item:{type:`function_call_output`,call_id:n,output:e}}),P({type:`response.create`})});break}case`error`:s(String(t.error?.message??`error`))}},o.onopen=()=>{a(`live`);let e=A.current;e&&(N.current=Oe(e,j.current,T.current),P({type:`conversation.item.create`,item:{type:`message`,role:`user`,content:[{type:`input_text`,text:`[state]\n${N.current}\n\nGreet the person in one sentence and ask the first open field.`}]}}),P({type:`response.create`}))},o.onclose=()=>{E.current===r&&z()};let c=await r.createOffer();await r.setLocalDescription(c);let u=await fetch(t.endpoint,{method:`POST`,headers:{authorization:`Bearer ${t.clientSecret}`,"content-type":`application/sdp`},body:c.sdp});if(!u.ok)throw Error(`${y(`talk.failed`)} (${u.status})`);await r.setRemoteDescription({type:`answer`,sdp:await u.text()})}catch(e){z(),s(e.name===`NotAllowedError`?y(`chat.micDenied`):e.message),a(`error`)}}},[e,B,F,P,z]);return(0,V.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: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,V.createContext)(null),q=(0,V.createContext)(null);function je(){return(0,V.useContext)(q)?.voice??null}function Me({children:e}){let t=(0,V.useContext)(Ae);return t?(0,be.createPortal)(e,t):null}function Ne({header:e,footer:t,children:n}){let[r,i]=(0,V.useState)(null),a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=(0,V.useRef)(!0);return(0,V.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,H.jsx)(Ae.Provider,{value:r,children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[e,(0,H.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,H.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,H.jsxs)(`div`,{className:`shrink-0 border-border-soft border-t bg-background`,onPointerDownCapture:()=>{s.current=!0},onKeyDownCapture:()=>{s.current=!0},children:[(0,H.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,V.useContext)(q),r=(0,V.useMemo)(()=>t.map(e=>({key:e.key,who:e.who,spoken:!e.bare&&!e.wide})),[t]),i=(0,V.useCallback)(e=>{let t=document.querySelector(`[data-say="${CSS.escape(e)}"]`);return t?.querySelector(`[data-say-text]`)?.getAttribute(`data-say-text`)??t?.innerText??null},[]);ie(!!n?.readAloud,n?.lang??c,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,H.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,H.jsx)(`div`,{className:`sticky top-1 shrink-0 pt-0.5`,children:(0,H.jsx)(ce,{kind:e,size:30,interactive:n>=a.length-2})}),(0,H.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:t.lines.map(e=>(0,H.jsx)(`div`,{"data-anchor":e.anchor?``:void 0,"data-say":e.key,className:h(`animate-rise`,e.bare?`w-full pt-1`:`rounded-2xl rounded-tl-md text-[0.9375rem] text-ink leading-relaxed`,!e.bare&&(e.wide?h(`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,H.jsxs)(`div`,{className:`flex animate-rise flex-col items-end gap-1 pl-10`,children:[(0,H.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,H.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,H.jsx)(u,{className:`size-3`}),` `,y(`chat.change`)]}):null]},e.key)))}function Pe(){return(0,H.jsx)(`span`,{className:`inline-flex items-center gap-1 py-1.5`,role:`status`,"aria-label":y(`run.working`),children:[0,1,2].map(e=>(0,H.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,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e})}var X=(e,t)=>G(e,(0,H.jsx)(Y,{children:t}),{bare:!0});function Z({onClick:e,children:t,primary:n,on:r,disabled:i,busy:a}){return(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":r,disabled:i||a,onClick:e,className:h(`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,H.jsx)(m,{className:`size-4`}):null,t]})}function Fe({initial:e=``,placeholder:t,multiline:n,inputProps:r,busy:i,disabled:a,inputRef:s,onSend:c}){let[u,d]=(0,V.useState)(e),p=(0,V.useRef)(null),_=s??p,v=(0,V.useContext)(q),b=N(u,d,{endpoint:v?`/api/runs/${v.runId}/transcribe`:void 0}),x=!!v&&b.supported&&!a;(0,V.useEffect)(()=>{if(!x)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()===`m`&&(e.preventDefault(),b.toggle())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[x,b.toggle]),(0,V.useEffect)(()=>{!E&&!a&&_.current?.focus()},[a,_]);let S=()=>{i||a||(b.listening&&b.toggle(),c(u)!==!1&&d(``))},C=b.listening?y(`chat.listening`):b.processing?y(`chat.transcribing`):t,w=v?.voice??null,T=!!v?.call,k=v&&!T&&(ae||x||w)?(0,H.jsxs)(`div`,{className:`mb-1 flex shrink-0 items-center`,children:[w?(0,H.jsx)(f,{label:y(w.state===`live`?`talk.stop`:w.state===`connecting`?`talk.connecting`:`talk.start`),"aria-pressed":w.state===`live`,disabled:w.state===`connecting`,onClick:()=>w.state===`live`?w.stop():void w.start(),className:h(`size-9`,w.state===`live`&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`,w.state===`off`&&v.talk&&`bg-primary text-primary-foreground hover:bg-primary`),children:w.state===`connecting`?(0,H.jsx)(m,{className:`size-4`}):w.state===`live`?(0,H.jsx)(se,{className:`size-4`}):(0,H.jsx)(ne,{className:`size-4`})}):null,w?.state===`live`?(0,H.jsx)(f,{label:y(w.camera?`talk.cameraOff`:`talk.camera`),"aria-pressed":w.camera,onClick:()=>w.camera?w.stopCamera():void w.startCamera(),className:h(`size-9`,w.camera&&`text-ink`),children:w.camera?(0,H.jsx)(o,{className:`size-4`}):(0,H.jsx)(_e,{className:`size-4`})}):null,ae?(0,H.jsx)(f,{label:y(v.readAloud?`chat.readAloudOff`:`chat.readAloud`),"aria-pressed":v.readAloud,onClick:()=>v.setReadAloud(!v.readAloud),className:h(`size-9`,v.readAloud&&`text-ink`),children:v.readAloud?(0,H.jsx)(ue,{className:`size-4`}):(0,H.jsx)(ye,{className:`size-4`})}):null,x?(0,H.jsx)(f,{label:y(b.listening?`chat.dictateStop`:`chat.dictate`),"aria-pressed":b.listening,disabled:b.processing,onClick:b.toggle,className:h(`size-9`,b.listening&&`bg-rose-tint text-rose hover:bg-rose-tint hover:text-rose`),children:b.processing?(0,H.jsx)(m,{className:`size-4`}):b.listening?(0,H.jsx)(O,{className:`size-3.5 animate-pulse-dot fill-current`}):(0,H.jsx)(g,{className:`size-4`})}):null]}):null;return(0,H.jsxs)(`form`,{className:`pb-3`,onSubmit:e=>{e.preventDefault(),S()},children:[w&&!T?(0,H.jsx)(`video`,{ref:w.video,muted:!0,playsInline:!0,autoPlay:!0,className:h(`mb-2 ml-auto w-32 rounded-xl bg-black object-cover shadow-soft ring-1 ring-border-soft`,w.camera?`block`:`hidden`)}):null,(0,H.jsxs)(`div`,{className:h(`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:[k,n?(0,H.jsx)(l,{ref:_,minRows:1,maxRows:6,value:u,disabled:a,placeholder:C,autoCapitalize:`sentences`,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!E&&!e.nativeEvent.isComposing&&(e.preventDefault(),S())},className:`min-h-11 border-0 bg-transparent py-2.5 shadow-none focus:ring-0`}):(0,H.jsx)(`input`,{ref:_,...r,value:u,disabled:a,placeholder:C,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,H.jsx)(`button`,{type:`submit`,"aria-label":y(`chat.send`),title:y(`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,H.jsx)(m,{className:`size-4`}):(0,H.jsx)(D,{className:`size-4`})})]}),b.error?(0,H.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:b.error===`denied`?y(`chat.micDenied`):b.error}):T?null:w?.error?(0,H.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-rose`,children:w.error}):w?.state===`live`?(0,H.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:w.speaking?y(`talk.speaking`):w.listening?y(`talk.listening`):y(`talk.live`)}):v?.talk&&w?.state===`off`?(0,H.jsx)(`p`,{className:`mt-1.5 px-3 text-[0.75rem] text-ink-3`,children:y(`talk.hint`)}):null]})}function Q({placeholder:e=y(`chat.above`)}){return(0,H.jsx)(Me,{children:(0,H.jsx)(Fe,{disabled:!0,placeholder:e,onSend:()=>!1})})}function Ie(e){let t=F[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?y(`chat.required`):null;let r=String(t).trim();if(e.kind===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return y(`chat.badEmail`);if(e.kind===`url`)try{new URL(r)}catch{return y(`chat.badUrl`)}return e.kind===`number`&&!Number.isFinite(Number(r.replace(`,`,`.`)))?y(`chat.badNumber`):Array.isArray(t)&&e.multiple&&e.min&&t.length<e.min?y(`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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-medium`,children:e.label}),e.help?(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-medium`,children:e.title}),e.description?(0,H.jsx)(`span`,{className:`mt-0.5 block text-ink-2`,children:e.description}):null,t?.help?(0,H.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,H.jsx)(H.Fragment,{children:typeof t==`string`&&t?t:y(`chat.connected`)});if(e.kind===`list`)return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,H.jsx)(j,{className:`size-4`}),` `,y(`chat.checked`)]});if(e.kind===`toggle`)return(0,H.jsx)(H.Fragment,{children:y(t===!0?`run.yes`:`run.no`)});if(Le(t))return(0,H.jsx)(`span`,{className:`italic opacity-80`,children:y(`chat.skipped`)});switch(e.kind){case`multiselect`:return(0,H.jsx)(H.Fragment,{children:t.join(`, `)});case`date`:{let e=new Date(`${String(t)}T00:00`);return(0,H.jsx)(H.Fragment,{children:Number.isNaN(e.getTime())?String(t):new Intl.DateTimeFormat(c,{dateStyle:`long`}).format(e)})}case`color`:return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`size-4 rounded-full ring-1 ring-white/50`,style:{background:String(t)}}),String(t)]});case`image`:case`signature`:return(0,H.jsx)(`span`,{className:`-mx-1.5 flex flex-wrap gap-1.5`,children:(Array.isArray(t)?t:[String(t)]).map(t=>(0,H.jsx)(`img`,{src:r(`/api/runs/${n}/assets/${t}`),alt:``,className:h(`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,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,H.jsx)(te,{className:`size-4`}),` `,y(e===1?`chat.file`:`chat.files`,{n:e})]})}case`audio`:{let e=t.seconds;return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,H.jsx)(g,{className:`size-4`}),` `,y(`chat.voice`),e?` · ${Math.round(e)} s`:``]})}case`location`:{let e=t;return(0,H.jsx)(H.Fragment,{children:e.label||`${e.lat?.toFixed(5)}, ${e.lng?.toFixed(5)}`})}case`items`:return(0,H.jsx)(H.Fragment,{children:y(`chat.rows`,{n:Array.isArray(t)?t.length:0})});default:return(0,H.jsx)(H.Fragment,{children:String(t)})}}function Ue(e,t,n,r,i,a){let o=[G(t,(0,H.jsx)(Ve,{step:e,only:a}))];for(let e of i)a||o.push(G(`${t}:${e.id}`,(0,H.jsx)(Be,{field:e}))),o.push(K(`${t}:${e.id}:a`,(0,H.jsx)(He,{field:e,value:n[e.id],runId:r})));return o}var We=(e,t)=>e.fields.filter(e=>!e.when&&!w(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,H.jsx)(`span`,{className:`font-medium`,children:r.title}))),n.push(K(`${i}:a`,y(`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=>!w(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,V.useMemo)(()=>Ke(n,e),[n,e]),o=e.known??{},[s,c]=(0,V.useState)(()=>R(n,e)),[l,u]=(0,V.useState)(()=>n.fields.some(t=>e.values[t.id]!==void 0)?a(Ke(n,e),e.known??{},R(n,e)).slice(0,-1).map(e=>e.id):[]),[d,f]=(0,V.useState)({}),[p,m]=(0,V.useState)(!1),[h,g]=(0,V.useState)(!1),_=a(i,o,s),v=_.filter(e=>l.includes(e.id)),b=_.find(e=>!l.includes(e.id)),x=i.length===1?i[0]:void 0,S=v.at(-1),C=S?()=>u(e=>e.filter(e=>e!==S.id)):void 0;(0,V.useEffect)(()=>{let e=Object.keys(t.fieldErrors),n=a(i,o,s),r=n.findIndex(t=>e.includes(t.id));r>=0&&(u(n.slice(0,r).map(e=>e.id)),f(t.fieldErrors))},[t.fieldErrors]);let w=e=>{t.submitPage(n.id,e).then(g)},T=(0,V.useContext)(q),E=(0,V.useRef)(s);E.current=s;let D=T?.bindPage,O=(0,V.useRef)(w);O.current=w,(0,V.useEffect)(()=>{if(!D)return;let e=a(i,o,s);return D({step:n,fields:e,values:s,setField:(t,n)=>{let r=e.find(e=>e.id===t);return r?Re(r,n)||(c(e=>({...e,[t]:n})),u(e=>e.includes(t)?e:[...e,t]),f({}),null):`no such field on this page`},submit:()=>O.current(E.current)}),()=>D(null)},[D,n,i,o,s]);let A=e=>{if(!b)return!1;let t=Re(b,e);if(t)return f({[b.id]:t}),!1;let n={...s,[b.id]:e},r=[...l,b.id];return c(n),u(r),f({}),a(i,o,n).some(e=>!r.includes(e.id))||w(n),!0},j=[...r.map(e=>l.length?{...e,onEdit:void 0}:e),...Ue(n,`now:${n.id}`,s,e.id,v,x).map((e,t,n)=>t===n.length-1&&e.who===`me`&&b?{...e,onEdit:C}:e)];b?(Ie(b)===`control`?j.push(G(`now:${n.id}:${b.id}:control`,(0,H.jsx)(k,{field:b,value:s[b.id],values:s,runId:e.id,view:e,closed:e.closed?.[b.id],onChange:e=>c(t=>({...t,[b.id]:e})),onBusy:m}),{wide:!0})):x||j.push(G(`now:${n.id}:${b.id}`,(0,H.jsx)(Be,{field:b}))),d[b.id]&&j.push(G(`now:${n.id}:${b.id}:error`,d[b.id],{tone:`error`}))):t.busy||h?j.push(G(`sending`,(0,H.jsx)(Pe,{}))):t.error&&j.push(G(`send-error`,t.error,{tone:`error`}));let M=(0,H.jsx)(Q,{});if(h||!b&&l.length>0&&t.busy)M=(0,H.jsx)(Q,{placeholder:y(`run.working`)});else if(!b)j.push(X(`now:${n.id}:go`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z,{primary:!0,busy:t.busy,onClick:()=>w(s),children:n.cta||y(`run.next`)}),C?(0,H.jsx)(Z,{onClick:C,disabled:t.busy,children:y(`run.back`)}):null]})));else{let r=Ie(b),i=!b.required&&b.kind!==`connection`&&b.kind!==`list`?(0,H.jsx)(Z,{onClick:()=>A(void 0),children:y(`chat.skip`)}):null;if(r===`typed`){i&&j.push(X(`now:${n.id}:${b.id}:replies`,i));let e=s[b.id];M=(0,H.jsx)(Me,{children:(0,H.jsx)(Fe,{initial:Le(e)?``:String(e),multiline:b.kind===`textarea`,placeholder:b.placeholder||(x?b.label:y(`chat.placeholder`)),inputProps:Je(b),busy:t.busy,onSend:e=>A(ze(b,e))},b.id)})}else if(r===`tapped`)j.push(G(`now:${n.id}:${b.id}:replies`,(0,H.jsx)(Ye,{field:b,view:e,value:s[b.id],onAnswer:A}),{bare:!0}));else{let e=_.filter(e=>!l.includes(e.id)).length===1;j.push(X(`now:${n.id}:${b.id}:replies`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z,{primary:!0,disabled:p,onClick:()=>A(s[b.id]),children:e&&n.cta?n.cta:y(`chat.send`)}),i]})))}}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(J,{avatar:e.wizard.avatar,lines:j}),M]})}function Je(e){switch(e.kind){case`number`:return{inputMode:`decimal`,autoComplete:`off`};case`email`:return{type:`email`,inputMode:`email`,autoComplete:`email`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`url`:return{inputMode:`url`,autoComplete:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1};case`date`:return{type:`date`};default:return ee(e)}}function Ye({field:e,view:t,value:n,onAnswer:r}){let i=new Set(t.closed?.[e.id]?.values.map(String)),[a,o]=(0,V.useState)(Array.isArray(n)?n:[]);if(e.kind===`toggle`)return(0,H.jsxs)(Y,{children:[(0,H.jsx)(Z,{on:n===!1,disabled:i.has(`false`),onClick:()=>r(!1),children:y(`run.no`)}),(0,H.jsx)(Z,{on:n===!0,disabled:i.has(`true`),onClick:()=>r(!0),children:y(`run.yes`)})]});let s=e.options??[];return e.kind===`multiselect`?(0,H.jsxs)(Y,{children:[s.map(e=>(0,H.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,H.jsx)(Z,{primary:!0,disabled:e.required&&!a.length,onClick:()=>r(a),children:a.length||e.required?y(`chat.send`):y(`chat.skip`)})]}):(0,H.jsxs)(Y,{children:[s.map(e=>(0,H.jsx)(Z,{on:n===e,disabled:i.has(e),onClick:()=>r(e),children:e},e)),e.required?null:(0,H.jsx)(Z,{onClick:()=>r(void 0),children:y(`chat.skip`)})]})}function Xe({view:e}){let t=(0,V.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(),[a,o]=(0,V.useState)(Date.now());(0,V.useEffect)(()=>{let e=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(e)},[]);let s=e.events.filter(e=>(e.type===`tool`||e.type===`info`)&&new Date(e.at).getTime()>=n-500),c=s.at(-1),l=[...s].reverse().find(Qe),u=[...new Set(s.map(e=>e.asset).filter(e=>!!e))];return(0,H.jsxs)(`div`,{className:h(`flex max-w-full flex-col gap-1`,l?`w-full`:`w-96`),"data-say-text":t?.message??e.step?.title??y(`run.working`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(Pe,{}),(0,H.jsx)(`span`,{className:`font-medium`,children:t?.message??e.step?.title??y(`run.working`)}),(0,H.jsx)(`span`,{className:`text-[0.75rem] text-ink-4 tabular-nums`,children:y(`run.elapsed`,{s:Math.max(0,Math.round((a-n)/1e3))})})]}),c&&c!==l?(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[0.8125rem] text-ink-3`,children:[(0,H.jsx)(i,{className:`size-3.5 shrink-0 animate-breathe text-ember`}),(0,H.jsx)(`span`,{className:`truncate`,children:v(c)})]}):null,l&&e.status===`running`?(0,H.jsx)(et,{runId:e.id,event:l}):null,u.length?(0,H.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:u.slice(-6).map(t=>(0,H.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,V.useState)(null),[i,a]=(0,V.useState)(`agent`),[o,s]=(0,V.useState)(!1),c=t.note?.code;if((0,V.useEffect)(()=>{c===`personDrives`?a(`person`):c===`agentDrives`&&a(`agent`)},[c]),(0,V.useEffect)(()=>{let t=()=>_.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 l=i===`person`,u=async()=>{s(!0);try{let t=await _.post(`/api/runs/${e}/browser/seat`,{to:l?`agent`:`person`});a(t.seat)}catch{}finally{s(!1)}};return(0,H.jsx)(z,{runId:e,driving:l,caption:v(t),hint:y(`browser.driving`),onBroken:()=>r(t.id),className:`mt-1.5`,action:(0,H.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>void u(),className:h(`flex h-8 items-center gap-1.5 rounded-full px-3 font-medium text-[0.8125rem] shadow-soft transition-colors disabled:opacity-60`,l?`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:[l?(0,H.jsx)(he,{className:`size-3.5`}):(0,H.jsx)(pe,{className:`size-3.5`}),y(l?`browser.handBack`:`browser.takeOver`)]})},n??0)}function $({children:e,end:t}){return(0,H.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,H.jsx)(`h3`,{className:`font-display font-semibold text-[1rem]`,children:e}),t]})}function tt({view:e,run:t,step:n,before:r,asked:i,onNote:a}){let o=e.shown.filter(e=>e.output),[s,c]=(0,V.useState)(o.length===1?o[0].step.id:null),l=(0,V.useRef)(null),u=[...r,...i.map((e,t)=>K(`review:${n.id}:asked:${t}`,e)),G(`review:${n.id}`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-medium`,children:n.title}),n.description?(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{children:t.title}),(0,H.jsx)(L,{base:`/api/runs/${e.id}`,step:t,output:r,onSurfaceAction:n.regenerate?()=>{c(t.id),l.current?.focus()}:void 0})]}),{wide:!0})),...e.lists.map(t=>G(`review:${n.id}:list:${t.def.id}`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{children:t.def.title}),t.def.check?(0,H.jsx)(S,{runId:e.id,list:t}):(0,H.jsx)(P,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];t.error&&u.push(G(`review-error`,t.error,{tone:`error`}));let d=n.regenerate&&o.length>0;return u.push(X(`review:${n.id}:replies`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Z,{primary:!0,busy:t.busy,onClick:()=>void t.accept(n.id),children:[(0,H.jsx)(j,{className:`size-4`}),` `,y(`run.accept`)]}),d&&o.length>1?o.map(({step:e})=>(0,H.jsx)(Z,{on:s===e.id,onClick:()=>c(e.id),children:e.title},e.id)):null]}))),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(J,{avatar:e.wizard.avatar,lines:u}),d?(0,H.jsx)(Me,{children:(0,H.jsx)(Fe,{multiline:!0,inputRef:l,busy:t.busy,placeholder:o.length>1&&!s?y(`run.feedbackPick`):y(`run.feedbackPlaceholder`),disabled:!s,onSend:e=>{let r=e.trim();return!r||!s?!1:(a(r),t.regenerate(n.id,s,r),!0)}})}):(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-display font-semibold text-[1.0625rem]`,children:n.title}),n.message?(0,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{end:(0,H.jsx)(I,{base:o,stepId:e.id,formats:n,title:r??e.title}),children:r??e.title}),(0,H.jsx)(L,{base:o,step:e,output:t}),t?.assets?.some(e=>e.ai)?(0,H.jsx)(`p`,{className:`mt-3 text-[0.75rem] text-ink-3 leading-relaxed`,children:y(`ai.publish`)}):null]}),{wide:!0})),...e.lists.map(t=>G(`result:list:${t.def.id}`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{end:(0,H.jsx)(C,{runId:e.id,list:t}),children:t.label??t.def.title}),(0,H.jsx)(P,{runId:e.id,list:t,editable:!0})]}),{wide:!0}))];return s.push(X(`result:replies`,(0,H.jsxs)(H.Fragment,{children:[a.length?(0,H.jsx)(le,{runId:e.id,title:`${n.title} · ${e.wizard.title}`,initial:e.shareUrl?{url:e.shareUrl,expiresAt:e.expiresAt}:null}):null,i?(0,H.jsxs)(Z,{onClick:i,children:[(0,H.jsx)(d,{className:`size-4`}),` `,y(`run.again`)]}):null,e.canBack?(0,H.jsx)(Z,{onClick:()=>void t.back(),disabled:t.busy,children:y(`run.back`)}):null,e.keeps?(0,H.jsx)(`span`,{className:`ml-1`,children:(0,H.jsx)(A,{runId:e.id})}):null]}))),(0,H.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 l=de(e),{view:u}=l,[f,p]=(0,V.useState)(null),h=ke(e,u,l,f);(0,V.useEffect)(()=>{n?.(u)},[u,n]);let[g,_]=oe(),v=(0,V.useMemo)(()=>({runId:e,lang:u?.lang??c,readAloud:g,setReadAloud:_,voice:u?.talk?h:null,talk:a,call:!!o,bindPage:p}),[e,u?.lang,u?.talk,g,_,h,a,o]);T(u?.status===`running`&&!u.ask),M(u);let[x,S]=(0,V.useState)({}),[C,w]=(0,V.useState)(null);(0,V.useEffect)(()=>{u&&u.status!==`running`&&w(null)},[u]);let E;if(l.notFound)E=(0,H.jsx)(`div`,{className:`py-24 text-center text-ink-3`,children:y(`run.notFound`)});else if(!u)E=(0,H.jsx)(`div`,{className:`flex justify-center py-24 text-ink-4`,children:(0,H.jsx)(m,{})});else{let e=u.step,n=u.status===`waiting_input`,r=Ge(u,u.canBack&&n&&!l.busy?()=>void l.back():void 0);if(u.status===`running`&&u.ask)E=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(J,{avatar:u.wizard.avatar,lines:[...r,G(`ask:${u.ask.id}`,(0,H.jsx)(b,{runId:u.id,ask:u.ask}),{wide:!0})]}),(0,H.jsx)(Q,{})]});else if(u.status===`running`)E=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(J,{avatar:u.wizard.avatar,lines:[...r,...C?[K(`note`,C)]:[],G(`working:${e?.id}`,(0,H.jsx)(Xe,{view:u}),{wide:u.events.some(t=>t.stepId===e?.id&&Qe(t))?`most`:void 0})]}),(0,H.jsx)(Q,{placeholder:y(`run.working`)})]});else if(u.status===`failed`)E=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(J,{avatar:u.wizard.avatar,lines:[...r,G(`failed`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`font-medium`,children:y(`run.failed`)}),u.error?(0,H.jsx)(`span`,{className:`mt-0.5 block`,children:(0,H.jsx)(s,{text:u.error})}):null]}),{tone:`error`}),X(`failed:replies`,(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(Z,{primary:!0,busy:l.busy,onClick:()=>void l.retry(),children:[(0,H.jsx)(d,{className:`size-4`}),` `,y(`run.retry`)]}),u.canBack?(0,H.jsx)(Z,{onClick:()=>void l.back(),disabled:l.busy,children:y(`run.back`)}):null]}))]}),(0,H.jsx)(Q,{})]});else if(u.status===`cancelled`)E=(0,H.jsx)(J,{avatar:u.wizard.avatar,lines:[...r,G(`cancelled`,y(`run.cancelled`)),...t?[X(`cancelled:replies`,(0,H.jsxs)(Z,{primary:!0,onClick:t,children:[(0,H.jsx)(d,{className:`size-4`}),` `,y(`run.again`)]}))]:[]]});else if(e?.type===`page`)E=(0,H.jsx)(qe,{view:u,run:l,step:e,before:r},e.id);else if(e?.type===`review`){let t=u.shown.map(e=>e.output?.at??``).join(`|`);E=(0,H.jsx)(tt,{view:u,run:l,step:e,before:r,asked:x[e.id]??[],onNote:t=>{w(t),S(n=>({...n,[e.id]:[...n[e.id]??[],t]}))}},`${e.id}:${t}`)}else E=e?.type===`result`?(0,H.jsx)(nt,{view:u,run:l,step:e,before:r,onRestart:t}):(0,H.jsx)(J,{avatar:u.wizard.avatar,lines:r})}return o?(0,H.jsx)(q.Provider,{value:v,children:(0,H.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col lg:flex-row`,children:[(0,H.jsx)(we,{voice:h,view:u,video:o===`video`,className:`h-[46dvh] shrink-0 lg:h-auto lg:min-h-0 lg:flex-1`}),(0,H.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,H.jsx)(Ne,{footer:i,children:E})})]})}):(0,H.jsx)(q.Provider,{value:v,children:(0,H.jsx)(Ne,{header:r,footer:i,children:E})})}export{J as a,Z as i,Ne as n,X as o,Q as r,je as s,rt as t};