wizards 0.2.55 → 0.2.56

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 (104) hide show
  1. package/README.md +2 -2
  2. package/apps/runtime/dist/cli/autostart.js +1 -1
  3. package/apps/runtime/dist/cli/machine.js +5 -48
  4. package/apps/runtime/dist/cli/report.js +1 -1
  5. package/apps/runtime/dist/docs/dev/index.md +4 -4
  6. package/apps/runtime/dist/docs/dev/plugins/connections.md +4 -3
  7. package/apps/runtime/dist/docs/dev/plugins/events.md +1 -0
  8. package/apps/runtime/dist/docs/dev/plugins/examples.md +10 -9
  9. package/apps/runtime/dist/docs/dev/plugins/index.md +4 -3
  10. package/apps/runtime/dist/docs/dev/plugins/layout.md +2 -1
  11. package/apps/runtime/dist/docs/dev/plugins/meta.json +0 -1
  12. package/apps/runtime/dist/docs/dev/plugins/quick-start.md +4 -3
  13. package/apps/runtime/dist/docs/dev/plugins/reference.md +36 -14
  14. package/apps/runtime/dist/docs/dev/plugins/reloading.md +5 -5
  15. package/apps/runtime/dist/docs/dev/plugins/routes.md +30 -6
  16. package/apps/runtime/dist/docs/dev/plugins/runners.md +15 -10
  17. package/apps/runtime/dist/docs/dev/plugins/server.md +16 -7
  18. package/apps/runtime/dist/docs/dev/plugins/shipping.md +4 -26
  19. package/apps/runtime/dist/docs/dev/plugins/space.md +66 -53
  20. package/apps/runtime/dist/docs/dev/plugins/starters.md +10 -7
  21. package/apps/runtime/dist/docs/dev/plugins/studio.md +33 -12
  22. package/apps/runtime/dist/docs/dev/plugins/styling.md +19 -9
  23. package/apps/runtime/dist/docs/dev/plugins/tables.md +6 -4
  24. package/apps/runtime/dist/docs/dev/plugins/tools.md +22 -12
  25. package/apps/runtime/dist/docs/dev/wizard-format.md +3 -2
  26. package/apps/runtime/dist/docs/user/ai-apps.md +3 -1
  27. package/apps/runtime/dist/docs/user/assistant.md +5 -3
  28. package/apps/runtime/dist/docs/user/build-a-wizard.md +14 -2
  29. package/apps/runtime/dist/docs/user/command-line.md +16 -14
  30. package/apps/runtime/dist/docs/user/connectors.md +17 -12
  31. package/apps/runtime/dist/docs/user/data.md +14 -9
  32. package/apps/runtime/dist/docs/user/first-start.md +13 -6
  33. package/apps/runtime/dist/docs/user/index.md +2 -1
  34. package/apps/runtime/dist/docs/user/install.md +19 -11
  35. package/apps/runtime/dist/docs/user/models.md +44 -22
  36. package/apps/runtime/dist/docs/user/plugins.md +9 -4
  37. package/apps/runtime/dist/docs/user/run.md +14 -9
  38. package/apps/runtime/dist/docs/user/server.md +7 -5
  39. package/apps/runtime/dist/docs/user/space.md +15 -8
  40. package/apps/runtime/dist/docs/user/steps.md +33 -13
  41. package/apps/runtime/dist/docs/user/test-and-share.md +41 -25
  42. package/apps/runtime/dist/docs/user/troubleshooting.md +15 -7
  43. package/apps/runtime/dist/docs/user/wordpress.md +59 -49
  44. package/apps/runtime/dist/engine/runner.js +40 -18
  45. package/apps/runtime/dist/env.js +6 -3
  46. package/apps/runtime/dist/harness/apple.js +36 -21
  47. package/apps/runtime/dist/harness/claude.js +1 -1
  48. package/apps/runtime/dist/harness/model.js +2 -2
  49. package/apps/runtime/dist/limits.js +7 -4
  50. package/apps/runtime/dist/media/conversation.js +6 -5
  51. package/apps/runtime/dist/model-errors.js +22 -1
  52. package/apps/runtime/dist/models.js +30 -7
  53. package/apps/runtime/dist/plugins/pro-keys.js +1 -1
  54. package/apps/runtime/dist/plugins/pro-state.js +1 -1
  55. package/apps/runtime/dist/plugins/pro.js +1 -1
  56. package/apps/runtime/dist/plugins/runs.js +14 -10
  57. package/apps/runtime/dist/render/browser-path.js +54 -0
  58. package/apps/runtime/dist/routes/runs.js +51 -31
  59. package/apps/runtime/dist/routes/studio.js +7 -3
  60. package/apps/runtime/dist/services/api.js +3 -1
  61. package/apps/runtime/dist/services/package-file.js +8 -8
  62. package/apps/runtime/dist/update.js +1 -1
  63. package/apps/web/dist/assets/AboutDialog-Bv7p9iGr.js +1 -0
  64. package/apps/web/dist/assets/{ChangelogDialog-BLmJABe4.js → ChangelogDialog-D4sBrhi-.js} +1 -1
  65. package/apps/web/dist/assets/{ChatView-YAiOT6mt.js → ChatView-Bntm0u8V.js} +1 -1
  66. package/apps/web/dist/assets/{EditorPage-C0zMXwlF.js → EditorPage-DaVeNzHU.js} +2 -2
  67. package/apps/web/dist/assets/{FlowPreview-B4lbmeha.js → FlowPreview-C0tTz51A.js} +1 -1
  68. package/apps/web/dist/assets/{Harness-_riwRD-c.js → Harness-De-PsLFA.js} +1 -1
  69. package/apps/web/dist/assets/{Marketplace-B0Nki6J6.js → Marketplace-7Bdv7Gd5.js} +2 -2
  70. package/apps/web/dist/assets/{NewWizardPage-DkvGgROv.js → NewWizardPage-CV7jrSkz.js} +1 -1
  71. package/apps/web/dist/assets/{ProjectPage-CFRIPset.js → ProjectPage-CBCd24oM.js} +1 -1
  72. package/apps/web/dist/assets/{PublicRunner-QJuQB7ff.js → PublicRunner-CVmkHSnC.js} +1 -1
  73. package/apps/web/dist/assets/{ReadOnly-DiOfNtVr.js → ReadOnly-zQecD9OB.js} +1 -1
  74. package/apps/web/dist/assets/{RunDrawer-LjUX3yIv.js → RunDrawer-CvzuYc0d.js} +1 -1
  75. package/apps/web/dist/assets/{RunnerView-DkJVfUeG.js → RunnerView-BtZp1FD6.js} +1 -1
  76. package/apps/web/dist/assets/SettingsPage--Zj2pTgf.js +1 -0
  77. package/apps/web/dist/assets/SetupPage-F_e8f1to.js +1 -0
  78. package/apps/web/dist/assets/{SharePage-CCimr8XT.js → SharePage-DLivbYu6.js} +1 -1
  79. package/apps/web/dist/assets/{brand-CwLcF9JR.js → brand-DIKyySmf.js} +1 -1
  80. package/apps/web/dist/assets/changelog-CWualFcc.js +1 -0
  81. package/apps/web/dist/assets/{circle-alert-BEDKtkJy.js → circle-alert-B9b9Vb9k.js} +1 -1
  82. package/apps/web/dist/assets/{esm-BCwno33N.js → esm-BMtXxAe0.js} +1 -1
  83. package/apps/web/dist/assets/{index-Dq-Wj6Yo.js → index-MlQy_Qoy.js} +4 -4
  84. package/apps/web/dist/assets/{lock-Ce2ofIWG.js → lock-BNvsUKTg.js} +1 -1
  85. package/apps/web/dist/assets/session-CSbo-pmx.js +1 -0
  86. package/apps/web/dist/assets/{settings-menu-DX0JnPBR.js → settings-menu-JtMfy9en.js} +1 -1
  87. package/apps/web/dist/assets/{ui-mkL5nF_f.js → ui-FW7ypPI6.js} +1 -1
  88. package/apps/web/dist/assets/{upload-BfrqabpO.js → upload-MQ_24gSb.js} +1 -1
  89. package/apps/web/dist/assets/{volume-2-C3GeMqc-.js → volume-2-B1mj20eS.js} +1 -1
  90. package/apps/web/dist/index.html +6 -6
  91. package/apps/web/dist/install.sh +2 -2
  92. package/apps/web/dist/mcp/flow.html +1 -1
  93. package/modules/calls/dist/client.css +1 -1
  94. package/modules/sms/dist/client.css +1 -1
  95. package/modules/whatsapp/dist/client.css +1 -1
  96. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +152 -2
  97. package/node_modules/@engenty-wizards/shared/dist/run.js +135 -1
  98. package/package.json +2 -2
  99. package/apps/runtime/dist/docs/dev/plugins/pro-modules.md +0 -59
  100. package/apps/web/dist/assets/AboutDialog-BelD7JCn.js +0 -1
  101. package/apps/web/dist/assets/SettingsPage-BKZ1KLfP.js +0 -1
  102. package/apps/web/dist/assets/SetupPage-Rqlo16Lk.js +0 -1
  103. package/apps/web/dist/assets/changelog-Bg5ZBu5p.js +0 -1
  104. package/apps/web/dist/assets/session-BuVghS-e.js +0 -1
@@ -1,3 +1,24 @@
1
+ import { noteText } from "@engenty-wizards/shared/run";
2
+ /**
3
+ * A failure the person reads, given as a note of `RUN_NOTES` where it has one: a run shows it in
4
+ * the wizard's language, the message keeps the German line for the log. Free text has no note.
5
+ */
6
+ export class NotedError extends Error {
7
+ note;
8
+ constructor(said) {
9
+ super(typeof said === "string" ? said : noteText(said, "de"));
10
+ this.note = typeof said === "string" ? null : said;
11
+ }
12
+ }
1
13
  /** A class has nothing to run on: no key, no account, no installed client — the person can fix it in the settings. */
2
- export class ModelUnavailableError extends Error {
14
+ export class ModelUnavailableError extends NotedError {
15
+ }
16
+ /** The note a failure carries, or null. */
17
+ export function noteOf(err) {
18
+ return err instanceof NotedError ? err.note : null;
19
+ }
20
+ /** A failure in a language: its note where it has one, else its message as it is. */
21
+ export function errorText(err, lang) {
22
+ const note = noteOf(err);
23
+ return note ? noteText(note, lang) : (err?.message ?? String(err));
3
24
  }
@@ -12,9 +12,10 @@ import { generateSpeech, generateText, } from "ai";
12
12
  import { accountToken, linkedAccount } from "./auth/account.js";
13
13
  import { DeviceModel, deviceThinks } from "./engine/device.js";
14
14
  import { env } from "./env.js";
15
- import { appleModel, appleStatus, appleTranscriptionModel, appleUnavailable, } from "./harness/apple.js";
15
+ import { appleModel, appleStatus, appleTranscriptionModel, appleUnavailable, appleUnavailableNote, } from "./harness/apple.js";
16
16
  import { detectHarness, HarnessModel, harness, isHarnessVendor, notInstalled, signedOut, } from "./harness/index.js";
17
17
  import { managed } from "./manage.js";
18
+ import { hasFfmpeg } from "./media/ffmpeg.js";
18
19
  import { ModelUnavailableError } from "./model-errors.js";
19
20
  import { seal, unseal } from "./secrets/crypto.js";
20
21
  import { vaultDelete, vaultGet, vaultSet } from "./secrets/vault.js";
@@ -201,6 +202,11 @@ function reachable(cfg, ref) {
201
202
  /** What a class runs on without credits: a client, an own key or a local model. "" = no way of its own. */
202
203
  function ownRef(cfg, cls) {
203
204
  const bound = cfg.settings.bindings[cls];
205
+ // A text class bound to Apple Intelligence (Classifier, Standard) thinks on this Mac whatever
206
+ // the source is: the others keep the installed client, the account's credits or the keys.
207
+ if (isText(cls) && bound && parse(bound).provider === "apple") {
208
+ return reachable(cfg, bound) ? bound : "";
209
+ }
204
210
  const client = managed ? null : harness(cfg.settings.source);
205
211
  if (isText(cls) && client) {
206
212
  // Text thinks on the installed client; a binding counts only where it names that client.
@@ -378,7 +384,7 @@ async function ownLanguageModel(cfg, ref, meta) {
378
384
  case "apple": {
379
385
  const status = await appleStatus();
380
386
  if (!status.available) {
381
- throw new ModelUnavailableError(appleUnavailable(status));
387
+ throw new ModelUnavailableError(appleUnavailableNote(status));
382
388
  }
383
389
  return { model: appleModel(id), gateway: false };
384
390
  }
@@ -834,8 +840,12 @@ export async function filmClient(cls) {
834
840
  if (status.auth === "none") {
835
841
  return { problem: signedOut(client) };
836
842
  }
843
+ // A class that thinks on Apple Intelligence makes its films on the client's model of the class.
837
844
  const ref = ownRef(cfg, cls);
838
- return { client, alias: ref.slice(client.id.length + 1) || client.classes[cls] };
845
+ return {
846
+ client,
847
+ alias: ref.startsWith(`${client.id}/`) ? ref.slice(client.id.length + 1) : client.classes[cls],
848
+ };
839
849
  }
840
850
  /** Whether any text model can answer at all: the studio says so before the first chat turn. */
841
851
  export async function hasTextModel() {
@@ -868,7 +878,7 @@ export async function classWays() {
868
878
  problem: client
869
879
  ? null
870
880
  : provider === "apple"
871
- ? await appleProblem()
881
+ ? await appleProblem(cls)
872
882
  : await gatewayProblem(cls, ref),
873
883
  };
874
884
  continue;
@@ -891,10 +901,23 @@ export async function classWays() {
891
901
  }
892
902
  return ways;
893
903
  }
894
- /** Why Apple Intelligence does not answer right now; null while it does. */
895
- async function appleProblem() {
904
+ /**
905
+ * Why this Mac's models do not take a class right now; null while they do. Text needs Apple
906
+ * Intelligence switched on. A voice note needs only the Mac (macOS 26 on Apple silicon, the
907
+ * helper; the system fetches a language on its first note), and ffmpeg for a recording it
908
+ * cannot read itself: a browser's WebM or Ogg.
909
+ */
910
+ async function appleProblem(cls) {
896
911
  const status = await appleStatus();
897
- return status.available ? null : appleUnavailable(status);
912
+ if (cls !== "audio") {
913
+ return status.available ? null : appleUnavailable(status);
914
+ }
915
+ if (!status.supported || status.reason === "missing") {
916
+ return appleUnavailable(status);
917
+ }
918
+ return (await hasFfmpeg())
919
+ ? null
920
+ : "Aufnahmen aus Chrome oder Firefox (WebM, Ogg) schreibt dieser Mac erst mit ffmpeg auf; Safari und die App brauchen es nicht. ffmpeg installieren, z. B. mit „brew install ffmpeg“.";
898
921
  }
899
922
  /** At start the ways are asked once, so a model the key cannot reach shows before a run meets it. */
900
923
  export async function checkModelsAtStart() {
@@ -1,7 +1,7 @@
1
1
  import { createPublicKey, verify } from "node:crypto";
2
2
  import { env } from "../env.js";
3
3
  /**
4
- * The keys a Pro module's package must be signed with (docs/content/dev/plugins/pro-modules).
4
+ * The keys a Pro module's package must be signed with (docs/pro-modules.md).
5
5
  * Only the public halves are here; the private one signs in the build of the closed plugins and
6
6
  * is kept nowhere else. A new key is added beside the old one, which goes a release later.
7
7
  */
@@ -4,7 +4,7 @@ import { packageVersion } from "../cli/home.js";
4
4
  import { env } from "../env.js";
5
5
  import { managed } from "../manage.js";
6
6
  /**
7
- * Which Pro modules may load (docs/content/dev/plugins/pro-modules). A Pro module is a closed
7
+ * Which Pro modules may load (docs/pro-modules.md). A Pro module is a closed
8
8
  * plugin the linked account's plan includes, installed by pro.ts into a folder of its own. It
9
9
  * loads while the entitlement the account's Manage-App signed lists it and has not ended, and
10
10
  * only in the release it was built for. Kept apart from pro.ts, so the loader needs no network.
@@ -13,7 +13,7 @@ import { signedByUs } from "./pro-keys.js";
13
13
  import { currentEntitlement, ENTITLEMENT_SETTING, heldBackModules, INSTALLED_FILE, installedModule, proModulesDir, runtimeTag, setEntitlement, } from "./pro-state.js";
14
14
  import { loadedPlugin } from "./registry.js";
15
15
  /*
16
- * Pro modules on a runtime that runs alone (docs/content/dev/plugins/pro-modules): the closed
16
+ * Pro modules on a runtime that runs alone (docs/pro-modules.md): the closed
17
17
  * plugins the linked account's plan includes, fetched from its Manage-App.
18
18
  *
19
19
  * GET /v1/modules?runtime=<release> what is built for this release, the plan's
@@ -9,7 +9,7 @@ import { cancel, createRun, goBack, NoCreditsError, RunInputError, retry, review
9
9
  import { saveAsset } from "../files/storage.js";
10
10
  import { wizardUnavailable } from "../limits.js";
11
11
  import { transcribeAudio } from "../media/transcribe.js";
12
- import { ModelUnavailableError } from "../model-errors.js";
12
+ import { errorText, ModelUnavailableError } from "../model-errors.js";
13
13
  import { runTicket } from "../secrets/signing.js";
14
14
  import { notFound, ServiceError } from "../services/errors.js";
15
15
  import { runnerSettingsOf, runnersOf } from "../services/runners.js";
@@ -38,20 +38,20 @@ export function runsApiFor(pluginId) {
38
38
  if (!w || w.publishedVersion === null) {
39
39
  throw notFound();
40
40
  }
41
+ const version = await db.query.wizardVersion.findFirst({
42
+ where: and(eq(schema.wizardVersion.wizardId, w.id), eq(schema.wizardVersion.version, w.publishedVersion)),
43
+ });
44
+ if (!version) {
45
+ throw notFound();
46
+ }
41
47
  const reason = await wizardUnavailable(w);
42
48
  if (reason) {
43
- throw new ServiceError("refused", reason);
49
+ throw new ServiceError("refused", noteText(reason, wizardLang(version.definition)));
44
50
  }
45
51
  const visitorId = visitorOf(input.person);
46
52
  if (await visitorOverLimit(visitorId, null)) {
47
53
  throw new ServiceError("refused", "This person started many runs lately. Try again in an hour.");
48
54
  }
49
- const version = await db.query.wizardVersion.findFirst({
50
- where: and(eq(schema.wizardVersion.wizardId, w.id), eq(schema.wizardVersion.version, w.publishedVersion)),
51
- });
52
- if (!version) {
53
- throw notFound();
54
- }
55
55
  const runId = await createRun({
56
56
  wizardId: w.id,
57
57
  definition: version.definition,
@@ -62,7 +62,7 @@ export function runsApiFor(pluginId) {
62
62
  runner: input.runner ?? pluginId,
63
63
  }).catch((err) => {
64
64
  if (err instanceof ModelUnavailableError) {
65
- throw new ServiceError("refused", err.message);
65
+ throw new ServiceError("refused", errorText(err, wizardLang(version.definition)));
66
66
  }
67
67
  if (err instanceof NoCreditsError) {
68
68
  throw new ServiceError("no_credits", "The wizard's credits are used up.");
@@ -139,6 +139,10 @@ export function runsApiFor(pluginId) {
139
139
  // The listener runs inside the tenant the subscription was made in, as the events do.
140
140
  const tenantId = currentTenant();
141
141
  return subscribe(runId, (signal) => {
142
+ // The runtime asking the phone around the runner to think is not a change of the run.
143
+ if (signal.device) {
144
+ return;
145
+ }
142
146
  const event = signal.event;
143
147
  const shaped = {
144
148
  runId: signal.runId,
@@ -195,7 +199,7 @@ export function runsApiFor(pluginId) {
195
199
  call: { runId: run.id },
196
200
  }).catch((err) => {
197
201
  if (err instanceof ModelUnavailableError) {
198
- throw new ServiceError("refused", err.message);
202
+ throw new ServiceError("refused", errorText(err, wizardLang(run.definition)));
199
203
  }
200
204
  throw err;
201
205
  });
@@ -0,0 +1,54 @@
1
+ import { accessSync, constants, existsSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { delimiter, join } from "node:path";
4
+ /** The first executable called `name` in the folders of `path` (a PATH value). */
5
+ export function findOnPath(name, path) {
6
+ for (const dir of path.split(delimiter)) {
7
+ if (!dir) {
8
+ continue;
9
+ }
10
+ const file = join(dir, name);
11
+ try {
12
+ accessSync(file, constants.X_OK);
13
+ return file;
14
+ }
15
+ catch {
16
+ // not here
17
+ }
18
+ }
19
+ return null;
20
+ }
21
+ /**
22
+ * The browser the runtime renders PDF and PNG with and drives for websites: `CHROME_PATH`, else
23
+ * the first Chromium-based browser installed (Chrome, Edge, Chromium, Brave). The setup and
24
+ * `wizards doctor` report this one, and env.ts starts it, so a browser they show is the one used.
25
+ */
26
+ export function findChrome(env = process.env) {
27
+ if (env.CHROME_PATH) {
28
+ return existsSync(env.CHROME_PATH) ? env.CHROME_PATH : null;
29
+ }
30
+ if (process.platform === "darwin") {
31
+ const apps = [
32
+ "Google Chrome.app/Contents/MacOS/Google Chrome",
33
+ "Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
34
+ "Chromium.app/Contents/MacOS/Chromium",
35
+ "Brave Browser.app/Contents/MacOS/Brave Browser",
36
+ ];
37
+ const roots = ["/Applications", join(homedir(), "Applications")];
38
+ for (const app of apps) {
39
+ for (const root of roots) {
40
+ if (existsSync(join(root, app))) {
41
+ return join(root, app);
42
+ }
43
+ }
44
+ }
45
+ return null;
46
+ }
47
+ for (const name of ["google-chrome", "chromium", "chromium-browser", "microsoft-edge"]) {
48
+ const file = findOnPath(name, env.PATH ?? "");
49
+ if (file) {
50
+ return file;
51
+ }
52
+ }
53
+ return null;
54
+ }
@@ -1,5 +1,6 @@
1
1
  import { FORMATS, LIST_FORMATS, TEXT_CLASSES } from "@engenty-wizards/shared/definition";
2
2
  import { TableColumnValueError } from "@engenty-wizards/shared/engenty/data-tables";
3
+ import { noteText } from "@engenty-wizards/shared/run";
3
4
  import { getConnInfo } from "@hono/node-server/conninfo";
4
5
  import { and, eq } from "drizzle-orm";
5
6
  import { Hono } from "hono";
@@ -17,14 +18,14 @@ import { answerDevice, offerDevice } from "../engine/device.js";
17
18
  import { emitEvent, signalChanged, subscribe } from "../engine/events.js";
18
19
  import { pushAvailable, setPushDevice } from "../engine/push.js";
19
20
  import { liveResources } from "../engine/resources.js";
20
- import { cancel, createRun, goBack, NoCreditsError, projectIdOf, RunConflict, RunInputError, retry, reviewStep, runView, submitPage, } from "../engine/runner.js";
21
+ import { cancel, createRun, goBack, NoCreditsError, projectIdOf, RunConflict, RunInputError, retry, reviewStep, runView, submitPage, talkAllowed, } from "../engine/runner.js";
21
22
  import { basePath, env } from "../env.js";
22
23
  import { loadAsset, saveAsset } from "../files/storage.js";
23
24
  import { reverseGeocode } from "../geocode.js";
24
25
  import { allowed, hashIp, verifyTurnstile, wizardUnavailable } from "../limits.js";
25
26
  import { mintConversation } from "../media/conversation.js";
26
27
  import { transcribeAudio } from "../media/transcribe.js";
27
- import { ModelUnavailableError } from "../model-errors.js";
28
+ import { errorText, ModelUnavailableError, noteOf } from "../model-errors.js";
28
29
  import { listDownload, renderDownload, stepHtml } from "../render/downloads.js";
29
30
  import { HTML_RESPONSE_CSP } from "../render/guard.js";
30
31
  import { runTicketValid, verifySignedUrl } from "../secrets/signing.js";
@@ -51,6 +52,19 @@ export function clientIp(c) {
51
52
  return null;
52
53
  }
53
54
  }
55
+ /**
56
+ * The language a visitor's request asks for: what the runner around it speaks, the browser's
57
+ * first language (apps/web: `navigator.language`) — German for "de…", else English; German
58
+ * without one, as the runner starts.
59
+ */
60
+ function requestLang(c) {
61
+ const asked = c.req.header("accept-language")?.trim().toLowerCase();
62
+ return !asked || asked.startsWith("de") ? "de" : "en";
63
+ }
64
+ /** A refusal the visitor reads, in the language their request asks for. */
65
+ function refuse(c, note, status) {
66
+ return c.json({ error: noteText(note, requestLang(c)) }, status);
67
+ }
54
68
  /**
55
69
  * The mobile app's own requests (a run's view, downloads) name the visitor in a header: iOS
56
70
  * merges a Cookie header the app sets with its own cookie store (`wz_vid=a,wz_vid=a`). The header
@@ -125,10 +139,10 @@ async function viewOf(run) {
125
139
  }
126
140
  function commandError(c, err) {
127
141
  if (err instanceof RunInputError) {
128
- return c.json({ error: err.message, fields: err.errors }, 422);
142
+ return c.json({ error: errorText(err, requestLang(c)), fields: err.errors }, 422);
129
143
  }
130
144
  if (err instanceof RunConflict) {
131
- return c.json({ error: err.message }, 409);
145
+ return c.json({ error: errorText(err, requestLang(c)) }, 409);
132
146
  }
133
147
  throw err;
134
148
  }
@@ -143,7 +157,7 @@ function tenantFrom(find) {
143
157
  return c.json({ error: "not found" }, 404);
144
158
  }
145
159
  if ((await tenantStatus(tenant)) === "suspended") {
146
- return c.json({ error: "Dieser Wizard ist gerade nicht verfügbar." }, 403);
160
+ return refuse(c, { code: "wizardUnavailable" }, 403);
147
161
  }
148
162
  return withTenant(tenant, next);
149
163
  };
@@ -227,7 +241,7 @@ export const publicRoutes = new Hono()
227
241
  brand: await brandView(w.projectId),
228
242
  turnstileSiteKey: env.turnstile.siteKey || null,
229
243
  available: !reason,
230
- unavailableReason: reason,
244
+ unavailableReason: reason && noteText(reason, requestLang(c)),
231
245
  runners: await publicRunners(w, def),
232
246
  };
233
247
  return c.json(body);
@@ -241,7 +255,7 @@ export const publicRoutes = new Hono()
241
255
  }
242
256
  const reason = await wizardUnavailable(w);
243
257
  if (reason) {
244
- return c.json({ error: reason }, 403);
258
+ return refuse(c, reason, 403);
245
259
  }
246
260
  const body = z
247
261
  .object({
@@ -253,14 +267,12 @@ export const publicRoutes = new Hono()
253
267
  .parse(await c.req.json().catch(() => ({})));
254
268
  const ip = clientIp(c);
255
269
  if (!(await verifyTurnstile(body.turnstileToken, ip))) {
256
- return c.json({ error: "Bitte bestätige kurz, dass du ein Mensch bist." }, 403);
270
+ return refuse(c, { code: "confirmHuman" }, 403);
257
271
  }
258
272
  const vid = visitorId(c, true, body.embedded);
259
273
  const ipHash = hashIp(ip);
260
274
  if (await visitorOverLimit(vid, ipHash)) {
261
- return c.json({
262
- error: "Du hast gerade viele Durchläufe gestartet. Bitte versuche es in einer Stunde wieder.",
263
- }, 429);
275
+ return refuse(c, { code: "tooManyRuns" }, 429);
264
276
  }
265
277
  const version = await db.query.wizardVersion.findFirst({
266
278
  where: and(eq(schema.wizardVersion.wizardId, w.id), eq(schema.wizardVersion.version, w.publishedVersion)),
@@ -280,7 +292,7 @@ export const publicRoutes = new Hono()
280
292
  }
281
293
  catch (err) {
282
294
  if (err instanceof NoCreditsError || err instanceof ModelUnavailableError) {
283
- return c.json({ error: "Dieser Wizard ist gerade nicht verfügbar." }, 403);
295
+ return refuse(c, { code: "wizardUnavailable" }, 403);
284
296
  }
285
297
  throw err;
286
298
  }
@@ -526,10 +538,13 @@ export const runRoutes = new Hono()
526
538
  return c.json({ error: "not found" }, 404);
527
539
  }
528
540
  if (run.status === "done" || run.status === "cancelled" || run.status === "failed") {
529
- return c.json({ error: "Der Durchlauf ist beendet." }, 409);
541
+ return refuse(c, { code: "runOver" }, 409);
542
+ }
543
+ if (!(await talkAllowed(run))) {
544
+ return refuse(c, { code: "talkOff" }, 403);
530
545
  }
531
546
  if (!allowed(`talk:${run.id}`, 20, 3600_000)) {
532
- return c.json({ error: "Bitte später noch einmal." }, 429);
547
+ return refuse(c, { code: "tryLater" }, 429);
533
548
  }
534
549
  try {
535
550
  const view = await viewOf(run);
@@ -537,10 +552,10 @@ export const runRoutes = new Hono()
537
552
  }
538
553
  catch (err) {
539
554
  if (err instanceof ModelUnavailableError) {
540
- return c.json({ error: err.message }, 403);
555
+ return c.json({ error: errorText(err, requestLang(c)) }, 403);
541
556
  }
542
557
  console.error("[talk]", err);
543
- return c.json({ error: err.message }, 502);
558
+ return c.json({ error: errorText(err, requestLang(c)) }, 502);
544
559
  }
545
560
  })
546
561
  // What the person says into the chat's composer, written down — where the browser cannot do it itself.
@@ -550,14 +565,14 @@ export const runRoutes = new Hono()
550
565
  return c.json({ error: "not found" }, 404);
551
566
  }
552
567
  if (run.status === "done" || run.status === "cancelled" || run.status === "failed") {
553
- return c.json({ error: "Der Durchlauf ist beendet." }, 409);
568
+ return refuse(c, { code: "runOver" }, 409);
554
569
  }
555
570
  if (!allowed(`transcribe:${run.id}`, 60, 3600_000)) {
556
- return c.json({ error: "Bitte später noch einmal." }, 429);
571
+ return refuse(c, { code: "tryLater" }, 429);
557
572
  }
558
573
  const file = (await c.req.formData()).get("file");
559
574
  if (!(file instanceof File) || !file.size || file.size > 10_000_000) {
560
- return c.json({ error: "Bitte eine Aufnahme bis 10 MB." }, 400);
575
+ return refuse(c, { code: "recordingTooLarge" }, 400);
561
576
  }
562
577
  try {
563
578
  const { text } = await transcribeAudio({
@@ -569,7 +584,11 @@ export const runRoutes = new Hono()
569
584
  }
570
585
  catch (err) {
571
586
  if (err instanceof ModelUnavailableError) {
572
- return c.json({ error: err.message }, 403);
587
+ return c.json({ error: errorText(err, requestLang(c)) }, 403);
588
+ }
589
+ // Apple Intelligence on this Mac says why in a note (harness/apple.ts).
590
+ if (noteOf(err)) {
591
+ return c.json({ error: errorText(err, requestLang(c)) }, 502);
573
592
  }
574
593
  throw err;
575
594
  }
@@ -585,7 +604,7 @@ export const runRoutes = new Hono()
585
604
  const mime = file instanceof File ? file.type.split(";")[0].trim().toLowerCase() : "";
586
605
  const limit = uploadLimit(mime);
587
606
  if (!(file instanceof File) || file.size > limit) {
588
- return c.json({ error: `Bitte eine Datei bis ${Math.round(limit / 1_000_000)} MB wählen.` }, 400);
607
+ return refuse(c, { code: "fileTooLarge", params: { mb: Math.round(limit / 1_000_000) } }, 400);
589
608
  }
590
609
  const ref = await saveAsset({
591
610
  runId: run.id,
@@ -643,7 +662,7 @@ export const runRoutes = new Hono()
643
662
  ])
644
663
  .parse(await c.req.json());
645
664
  if (!answerAsk(run.id, c.req.param("askId"), answer)) {
646
- return c.json({ error: "Diese Frage ist nicht mehr offen." }, 409);
665
+ return refuse(c, { code: "askClosed" }, 409);
647
666
  }
648
667
  return c.json({ ok: true });
649
668
  })
@@ -662,7 +681,7 @@ export const runRoutes = new Hono()
662
681
  const run = await accessibleRun(c, c.req.param("id"));
663
682
  const resources = run?.status === "running" ? liveResources(run.id) : null;
664
683
  if (!(run && resources?.openPage())) {
665
- return c.json({ error: "Der Wizard hat gerade keinen Browser offen." }, 409);
684
+ return refuse(c, { code: "noBrowser" }, 409);
666
685
  }
667
686
  const { to } = z.object({ to: z.enum(["person", "agent"]) }).parse(await c.req.json());
668
687
  if (resources.seatHolder() !== to) {
@@ -752,7 +771,7 @@ export const runRoutes = new Hono()
752
771
  const theirs = run && (pendingAsk(run.id) || resources?.seatHolder() === "person");
753
772
  const page = theirs ? resources?.openPage() : null;
754
773
  if (!(run && resources && page)) {
755
- return c.json({ error: "Der Wizard wartet gerade nicht auf dich." }, 409);
774
+ return refuse(c, { code: "notWaiting" }, 409);
756
775
  }
757
776
  resources.touchSeat();
758
777
  const act = z
@@ -794,7 +813,7 @@ export const runRoutes = new Hono()
794
813
  await page.waitForLoadState("domcontentloaded", { timeout: 3000 }).catch(() => undefined);
795
814
  }
796
815
  catch {
797
- return c.json({ error: "Das hat auf der Seite nicht geklappt." }, 422);
816
+ return refuse(c, { code: "pageActFailed" }, 422);
798
817
  }
799
818
  return c.json({ ok: true });
800
819
  })
@@ -1039,9 +1058,9 @@ export const connectCallback = new Hono().get("/callback", async (c) => {
1039
1058
  const ticket = c.req.query("ticket");
1040
1059
  const state = c.req.query("state");
1041
1060
  let ok = false;
1042
- let message = c.req.query("error") === "exchange_failed"
1043
- ? "Verbinden hat nicht geklappt. Bitte noch einmal versuchen."
1044
- : "Verbinden wurde abgebrochen.";
1061
+ let said = c.req.query("error") === "exchange_failed"
1062
+ ? { code: "connectFailed" }
1063
+ : { code: "connectCancelled" };
1045
1064
  // A plugin's sign-in (server.connections) names its tenant; a wizard's names its run.
1046
1065
  const pluginTenant = state ? pluginStateTenant(state) : null;
1047
1066
  const tenant = state ? (pluginTenant ?? (await tenantOfRun(oauthStateRun(state) ?? ""))) : null;
@@ -1056,13 +1075,14 @@ export const connectCallback = new Hono().get("/callback", async (c) => {
1056
1075
  signalChanged(done.runId);
1057
1076
  }
1058
1077
  ok = true;
1059
- message = "Verbunden. Du kannst dieses Fenster schließen.";
1078
+ said = { code: "connected" };
1060
1079
  }
1061
1080
  catch (err) {
1062
1081
  console.error("[connect]", err);
1063
- message = "Verbinden hat nicht geklappt. Bitte noch einmal versuchen.";
1082
+ said = { code: "connectFailed" };
1064
1083
  }
1065
1084
  }
1085
+ const message = noteText(said, requestLang(c));
1066
1086
  return c.html(`<!doctype html><meta charset="utf-8"><title>engenty wizards</title>
1067
1087
  <body style="font:16px system-ui;display:grid;place-items:center;height:100vh;margin:0;color:#333">
1068
1088
  <p>${message}</p>
@@ -1141,7 +1161,7 @@ export const shareRoutes = new Hono()
1141
1161
  .get("/:token", async (c) => {
1142
1162
  const run = await sharedRun(c.req.param("token"));
1143
1163
  if (!run) {
1144
- return c.json({ error: "Dieser Link ist abgelaufen oder wurde zurückgezogen." }, 404);
1164
+ return refuse(c, { code: "linkGone" }, 404);
1145
1165
  }
1146
1166
  return c.json(await shareView(run));
1147
1167
  })
@@ -64,13 +64,17 @@ async function testedSources() {
64
64
  const tested = await readSetting("setup-done");
65
65
  return Array.isArray(tested) ? tested : [];
66
66
  }
67
- /** The chosen source has passed a test call and can still answer: its client is there and signed in. */
67
+ /**
68
+ * The chosen source has passed a test call and can still answer: its client is there and signed
69
+ * in. Where Apple Intelligence thinks the short classes, the test ran there; a client behind High
70
+ * and Highest is no condition then.
71
+ */
68
72
  async function setupDone() {
69
- const source = localModelSettings().source;
73
+ const { source, bindings } = localModelSettings();
70
74
  if (!(await testedSources()).includes(source)) {
71
75
  return false;
72
76
  }
73
- const client = harness(source);
77
+ const client = bindings.standard.startsWith("apple:") ? null : harness(source);
74
78
  if (client) {
75
79
  const status = await detectHarness(client.id);
76
80
  return Boolean(status?.version) && status?.auth !== "none";
@@ -1,5 +1,7 @@
1
+ import { wizardLang } from "@engenty-wizards/shared/definition";
1
2
  import { standaloneEntry } from "@engenty-wizards/shared/fit";
2
3
  import { pluginsOf } from "@engenty-wizards/shared/marketplace";
4
+ import { noteText } from "@engenty-wizards/shared/run";
3
5
  import { and, count, desc, eq, gte, inArray, isNotNull, or, sql } from "drizzle-orm";
4
6
  import { MICROS_PER_CREDIT } from "../credits/credits.js";
5
7
  import { db, schema } from "../db/client.js";
@@ -98,7 +100,7 @@ export async function apiWizards(userId, spaceId) {
98
100
  ? `${env.appUrl}/api/public/wizards/${w.shareToken}/icons/icon-192.png`
99
101
  : null,
100
102
  available: Boolean(live) && !reason,
101
- unavailableReason: reason,
103
+ unavailableReason: reason && noteText(reason, wizardLang(def)),
102
104
  dailyRunLimit: w.dailyRunLimit,
103
105
  /** The plugins its steps call: a wizard that books needs `appointments`. */
104
106
  plugins: pluginsOf(def),
@@ -12,7 +12,7 @@ export function json(data) {
12
12
  return JSON.parse(strFromU8(data));
13
13
  }
14
14
  catch {
15
- throw invalid("Das ist kein Wizard-Paket: wizard.json ist kein gültiges JSON.");
15
+ throw invalid("This is not a wizard package: wizard.json is not valid JSON.");
16
16
  }
17
17
  }
18
18
  /** A manifest, or a bare definition: a wizard without workspace is fully told by its JSON. */
@@ -22,7 +22,7 @@ export function readManifest(raw) {
22
22
  }
23
23
  const parsed = manifestSchema.safeParse(raw);
24
24
  if (!parsed.success) {
25
- throw invalid("Dieses Wizard-Paket stammt aus einer neueren Version oder ist beschädigt.");
25
+ throw invalid("This wizard package comes from a newer version, or it is damaged.");
26
26
  }
27
27
  return parsed.data;
28
28
  }
@@ -45,24 +45,24 @@ export function readPackage(data) {
45
45
  total += file.originalSize;
46
46
  count += 1;
47
47
  if (file.originalSize > WORKSPACE_LIMITS.fileBytes) {
48
- throw invalid(`${file.name} ist größer als 5 MB.`);
48
+ throw invalid(`${file.name} is larger than 5 MB.`);
49
49
  }
50
50
  if (count > WORKSPACE_LIMITS.files + 1 || total > PACKAGE_MAX_BYTES) {
51
- throw invalid("Das Paket ist größer als ein Workspace sein darf (200 Dateien, 25 MB).");
51
+ throw invalid("The package is larger than a workspace may be (200 files, 25 MB).");
52
52
  }
53
53
  return true;
54
54
  },
55
55
  });
56
56
  }
57
57
  catch (err) {
58
- throw err instanceof ServiceError ? err : invalid("Das Paket lässt sich nicht entpacken.");
58
+ throw err instanceof ServiceError ? err : invalid("The package cannot be unpacked.");
59
59
  }
60
60
  // A package unpacked and zipped again often sits in a folder of its own.
61
61
  const manifestPath = Object.keys(entries)
62
62
  .filter((name) => name === PACKAGE_MANIFEST || name.endsWith(`/${PACKAGE_MANIFEST}`))
63
63
  .sort((a, b) => a.length - b.length)[0];
64
64
  if (manifestPath === undefined) {
65
- throw invalid("Das ist kein Wizard-Paket: wizard.json fehlt.");
65
+ throw invalid("This is not a wizard package: wizard.json is missing.");
66
66
  }
67
67
  const root = manifestPath.slice(0, -PACKAGE_MANIFEST.length);
68
68
  const files = Object.entries(entries)
@@ -70,12 +70,12 @@ export function readPackage(data) {
70
70
  .map(([name, content]) => {
71
71
  const path = cleanPath(name.slice(root.length + PACKAGE_FILES.length));
72
72
  if (!path) {
73
- throw invalid(`"${name}" ist kein gültiger Dateipfad.`);
73
+ throw invalid(`"${name}" is not a valid file path.`);
74
74
  }
75
75
  return { path, data: content };
76
76
  });
77
77
  if (files.reduce((n, f) => n + f.data.byteLength, 0) > WORKSPACE_LIMITS.totalBytes) {
78
- throw invalid("Der Workspace im Paket ist größer als 25 MB.");
78
+ throw invalid("The workspace in the package is larger than 25 MB.");
79
79
  }
80
80
  return { manifest: readManifest(json(entries[manifestPath])), files };
81
81
  }
@@ -3,7 +3,7 @@ import { mkdirSync, openSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { installedByScript, isCheckout, layout, packageRoot, packageVersion } from "./cli/home.js";
5
5
  const RELEASES_URL = process.env.ENGENTY_WIZARDS_RELEASES_URL?.trim() ||
6
- "https://api.github.com/repos/engenty/engenty-wizards/releases/latest";
6
+ "https://api.github.com/repos/engenty/wizards/releases/latest";
7
7
  /** How long an answer from GitHub holds, found or not, before the runtime asks again. */
8
8
  const CHECK_EVERY_MS = 60 * 60_000;
9
9
  /**