wizards 0.5.11 → 0.5.13

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 (91) hide show
  1. package/apps/runtime/dist/browser/fast/action-space.js +0 -2
  2. package/apps/runtime/dist/cli/mcp.js +2 -15
  3. package/apps/runtime/dist/cli/report.js +2 -15
  4. package/apps/runtime/dist/cli/start.js +28 -14
  5. package/apps/runtime/dist/cli/status.js +1 -1
  6. package/apps/runtime/dist/credits/credits.js +0 -3
  7. package/apps/runtime/dist/db/client.js +0 -7
  8. package/apps/runtime/dist/db/control-schema.js +10 -0
  9. package/apps/runtime/dist/db/migrations/control/0010_tan_snowbird.sql +6 -0
  10. package/apps/runtime/dist/db/migrations/control/meta/0010_snapshot.json +600 -0
  11. package/apps/runtime/dist/db/migrations/control/meta/_journal.json +7 -0
  12. package/apps/runtime/dist/db/migrations/tenant/0016_even_trish_tilby.sql +12 -0
  13. package/apps/runtime/dist/db/migrations/tenant/meta/0016_snapshot.json +3326 -0
  14. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  15. package/apps/runtime/dist/db/schema.js +20 -0
  16. package/apps/runtime/dist/docs/user/build-a-wizard.md +1 -1
  17. package/apps/runtime/dist/engine/runner.js +31 -10
  18. package/apps/runtime/dist/engine/steps.js +15 -4
  19. package/apps/runtime/dist/harness/index.js +0 -4
  20. package/apps/runtime/dist/manage.js +7 -7
  21. package/apps/runtime/dist/model-errors.js +20 -7
  22. package/apps/runtime/dist/plugins/pro.js +0 -6
  23. package/apps/runtime/dist/render/convert.js +0 -3
  24. package/apps/runtime/dist/routes/runs.js +170 -23
  25. package/apps/runtime/dist/routes/studio.js +83 -9
  26. package/apps/runtime/dist/services/api.js +8 -6
  27. package/apps/runtime/dist/services/cloud.js +1 -0
  28. package/apps/runtime/dist/services/spaces.js +1 -0
  29. package/apps/runtime/dist/services/translations.js +303 -0
  30. package/apps/runtime/dist/services/wizards.js +3 -1
  31. package/apps/runtime/dist/store/index.js +0 -11
  32. package/apps/runtime/dist/texts.js +47 -39
  33. package/apps/web/dist/assets/{AboutDialog-L1hcshAX.js → AboutDialog-CkE7uZNL.js} +1 -1
  34. package/apps/web/dist/assets/{ChangelogDialog-DZLYVOkl.js → ChangelogDialog-BCS3WIRA.js} +1 -1
  35. package/apps/web/dist/assets/ChatView-DClGzMte.js +10 -0
  36. package/apps/web/dist/assets/EditorPage-Dg27sIZ7.js +3 -0
  37. package/apps/web/dist/assets/{FlowPreview-CTEJi5TQ.js → FlowPreview-D2haAZwo.js} +1 -1
  38. package/apps/web/dist/assets/{Harness-CApAHvJE.js → Harness-CGI6ZMTA.js} +2 -2
  39. package/apps/web/dist/assets/{NewWizardChannels-tst10rkV.js → NewWizardChannels-C4b_phHw.js} +1 -1
  40. package/apps/web/dist/assets/{NewWizardPage-BAKaUY1g.js → NewWizardPage-DhDXrjKX.js} +2 -2
  41. package/apps/web/dist/assets/OnboardingPage-DgySdBgo.js +1 -0
  42. package/apps/web/dist/assets/ProjectPage-dvtJn_3c.js +1 -0
  43. package/apps/web/dist/assets/PublicRunner-lP4sVF1q.js +1 -0
  44. package/apps/web/dist/assets/{ReadOnly-Bb8khbuH.js → ReadOnly-B-4l3bVt.js} +1 -1
  45. package/apps/web/dist/assets/RunDrawer-B2bsB9Z6.js +4 -0
  46. package/apps/web/dist/assets/RunnerView-BZ83HUnO.js +1 -0
  47. package/apps/web/dist/assets/SettingsPage-C0_wAa_j.js +1 -0
  48. package/apps/web/dist/assets/SetupPage-kuvBk0G0.js +1 -0
  49. package/apps/web/dist/assets/{SharePage-Bb-BIvAX.js → SharePage-COLVxXMI.js} +1 -1
  50. package/apps/web/dist/assets/changelog-CIYdRaa5.js +1 -0
  51. package/apps/web/dist/assets/{esm-pbWES-Cu.js → esm-BqbWrbsa.js} +1 -1
  52. package/apps/web/dist/assets/index-Da9Pvzpj.js +14 -0
  53. package/apps/web/dist/assets/index-DaKjB676.css +1 -0
  54. package/apps/web/dist/assets/{lock-C6LaSCq_.js → lock-BkN0Fai6.js} +1 -1
  55. package/apps/web/dist/assets/{phone-BUWpzNWn.js → phone-Dip_wSUZ.js} +1 -1
  56. package/apps/web/dist/assets/{settings-menu-yO8b8LjQ.js → settings-menu-B7eXkvba.js} +1 -1
  57. package/apps/web/dist/assets/ui-B9AOCT0v.js +134 -0
  58. package/apps/web/dist/assets/{upload-D89fyY2-.js → upload-DPQ4pwnl.js} +1 -1
  59. package/apps/web/dist/index.html +3 -3
  60. package/apps/web/dist/mcp/flow.html +54 -54
  61. package/node_modules/@engenty-wizards/plugin-sdk/dist/thread.js +34 -34
  62. package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +19 -6
  63. package/node_modules/@engenty-wizards/shared/dist/definition.js +51 -10
  64. package/node_modules/@engenty-wizards/shared/dist/features.d.ts +0 -1
  65. package/node_modules/@engenty-wizards/shared/dist/features.js +0 -1
  66. package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +0 -5
  67. package/node_modules/@engenty-wizards/shared/dist/marketplace.js +0 -5
  68. package/node_modules/@engenty-wizards/shared/dist/providers.d.ts +1 -1
  69. package/node_modules/@engenty-wizards/shared/dist/providers.js +1 -1
  70. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +46 -4
  71. package/node_modules/@engenty-wizards/shared/dist/run.js +24 -9
  72. package/node_modules/@engenty-wizards/shared/dist/runner-texts.d.ts +506 -0
  73. package/node_modules/@engenty-wizards/shared/dist/runner-texts.js +483 -0
  74. package/node_modules/@engenty-wizards/shared/dist/texts.d.ts +11 -2
  75. package/node_modules/@engenty-wizards/shared/dist/texts.js +16 -8
  76. package/node_modules/@engenty-wizards/shared/dist/translation.d.ts +23 -0
  77. package/node_modules/@engenty-wizards/shared/dist/translation.js +154 -0
  78. package/package.json +1 -1
  79. package/apps/web/dist/assets/ChatView-GNHi9ZnZ.js +0 -10
  80. package/apps/web/dist/assets/EditorPage-COJunH8K.js +0 -3
  81. package/apps/web/dist/assets/OnboardingPage-Di8AuZj_.js +0 -1
  82. package/apps/web/dist/assets/ProjectPage-DaerYm8A.js +0 -1
  83. package/apps/web/dist/assets/PublicRunner-Hms0Vi88.js +0 -1
  84. package/apps/web/dist/assets/RunDrawer-DWaC_ryo.js +0 -4
  85. package/apps/web/dist/assets/RunnerView-D5BQ99ah.js +0 -1
  86. package/apps/web/dist/assets/SettingsPage-CQX6fKsa.js +0 -1
  87. package/apps/web/dist/assets/SetupPage-BZkbpN_V.js +0 -1
  88. package/apps/web/dist/assets/changelog-BUHje4CT.js +0 -1
  89. package/apps/web/dist/assets/index-BVWLhiGX.js +0 -14
  90. package/apps/web/dist/assets/index-DmQEcSlY.css +0 -1
  91. package/apps/web/dist/assets/ui-i5saQjmD.js +0 -134
@@ -7,8 +7,6 @@
7
7
  // the answer is validated against exactly the ids that were offered. Ported
8
8
  // from engenty-pro's fast loop.
9
9
  import { NEXT_ACTION, TARGET } from "./instructions.js";
10
- /** What the classifier may pick besides an element operation. */
11
- export const CONTROL_OPERATIONS = ["DONE", "BLOCKED"];
12
10
  /** The operation head's id for "interact with one element". */
13
11
  export const ACT = "ACT";
14
12
  /** The single target head's key in the questions and the answers. */
@@ -1,8 +1,7 @@
1
- import { readFileSync } from "node:fs";
2
1
  import { join } from "node:path";
3
2
  import { createInterface } from "node:readline";
4
3
  import { LOCAL_CLIENT_HEADER, LOCAL_MCP_HEADER, mintLocalTicket } from "../auth/local-ticket.js";
5
- import { runningRuntime, settings, startInBackground } from "./start.js";
4
+ import { readSecret, runningRuntime, settings, startInBackground } from "./start.js";
6
5
  import { tilde } from "./ui.js";
7
6
  /** The JSON-RPC messages of a response: a JSON body (one or a batch) or a server-sent stream. */
8
7
  export function messagesOf(contentType, body) {
@@ -26,18 +25,6 @@ export function messagesOf(contentType, body) {
26
25
  const parsed = JSON.parse(body);
27
26
  return Array.isArray(parsed) ? parsed : [parsed];
28
27
  }
29
- function readSecret(paths, dataDir) {
30
- const given = process.env.APP_SECRET?.trim() || settings(paths).fileEnv.APP_SECRET?.trim();
31
- if (given) {
32
- return given;
33
- }
34
- try {
35
- return readFileSync(join(dataDir, "secret"), "utf8").trim();
36
- }
37
- catch {
38
- return null;
39
- }
40
- }
41
28
  export async function mcp(paths) {
42
29
  const { dataDir } = settings(paths);
43
30
  let running = null;
@@ -63,7 +50,7 @@ export async function mcp(paths) {
63
50
  };
64
51
  const post = async (message) => {
65
52
  const at = await runtime();
66
- const secret = readSecret(paths, dataDir);
53
+ const secret = readSecret(paths);
67
54
  if (!secret) {
68
55
  throw new Error("No secret in the data folder yet. Start engenty wizards once first.");
69
56
  }
@@ -1,7 +1,6 @@
1
- import { readFileSync } from "node:fs";
2
1
  import { join } from "node:path";
3
2
  import { LOCAL_MCP_HEADER, mintLocalTicket } from "../auth/local-ticket.js";
4
- import { runningRuntime, settings } from "./start.js";
3
+ import { readSecret, runningRuntime, settings } from "./start.js";
5
4
  import { bad, cmd, dim, ok, tilde } from "./ui.js";
6
5
  /**
7
6
  * `wizards logs` shows the last lines the running runtime printed; `wizards report` sends its
@@ -9,25 +8,13 @@ import { bad, cmd, dim, ok, tilde } from "./ui.js";
9
8
  * (docs/plans/remote-debug.md). Both talk to the running process, signed with the data folder's
10
9
  * secret as `wizards mcp` does; neither sends anything by itself.
11
10
  */
12
- function readSecret(paths, dataDir) {
13
- const given = process.env.APP_SECRET?.trim() || settings(paths).fileEnv.APP_SECRET?.trim();
14
- if (given) {
15
- return given;
16
- }
17
- try {
18
- return readFileSync(join(dataDir, "secret"), "utf8").trim();
19
- }
20
- catch {
21
- return null;
22
- }
23
- }
24
11
  async function ask(paths, method, path) {
25
12
  const { dataDir } = settings(paths);
26
13
  const running = await runningRuntime(dataDir);
27
14
  if (!running) {
28
15
  return `engenty wizards isn’t running. To start it: ${cmd("start")}`;
29
16
  }
30
- const secret = readSecret(paths, dataDir);
17
+ const secret = readSecret(paths);
31
18
  if (!secret) {
32
19
  return `Couldn’t read the data folder’s secret (${tilde(join(dataDir, "secret"))}).`;
33
20
  }
@@ -23,6 +23,25 @@ export function settings(paths, env = process.env) {
23
23
  appUrl: value("APP_URL").replace(/\/$/, ""),
24
24
  };
25
25
  }
26
+ /**
27
+ * The secret the runtime this command starts signs with, read the way it reads it (env.ts): its
28
+ * APP_SECRET, else the one it keeps in the data folder; null before it made one. The runtime
29
+ * never sees the terminal's APP_SECRET (cli/environment.ts), only its folder's `.env.local` and
30
+ * `.env`, so the terminal's is left out here too: a ticket signed with it would be refused.
31
+ */
32
+ export function readSecret(paths, env = process.env) {
33
+ const { fileEnv, dataDir } = settings(paths, env);
34
+ const given = readEnvFile(join(paths.home, ".env.local")).APP_SECRET?.trim() || fileEnv.APP_SECRET?.trim();
35
+ if (given) {
36
+ return given;
37
+ }
38
+ try {
39
+ return readFileSync(join(dataDir, "secret"), "utf8").trim() || null;
40
+ }
41
+ catch {
42
+ return null;
43
+ }
44
+ }
26
45
  export async function healthy(port) {
27
46
  try {
28
47
  const response = await fetch(`http://127.0.0.1:${port}/api/health`, {
@@ -55,16 +74,11 @@ export async function runningRuntime(dataDir) {
55
74
  const running = readRunning(dataDir);
56
75
  return running && (await healthy(running.port)) ? running : null;
57
76
  }
58
- /** A link that lets this browser into a running runtime: a ticket signed with the data folder's secret. */
59
- export function entryUrl(running, dataDir) {
60
- try {
61
- const secret = readFileSync(join(dataDir, "secret"), "utf8").trim();
62
- return `${running.url}/api/local/enter?t=${mintLocalTicket(secret)}`;
63
- }
64
- catch {
65
- // APP_SECRET is set elsewhere: the browser gets in if it was let in before.
66
- return `${running.url}/`;
67
- }
77
+ /** A link that lets this browser into a running runtime: a ticket signed with the runtime's secret. */
78
+ export function entryUrl(running, paths, env = process.env) {
79
+ const secret = readSecret(paths, env);
80
+ // No secret to be read here: the browser gets in if it was let in before.
81
+ return secret ? `${running.url}/api/local/enter?t=${mintLocalTicket(secret)}` : `${running.url}/`;
68
82
  }
69
83
  /** Opens an address in the person's browser; false when this machine has none to open it with. */
70
84
  export function openBrowser(url) {
@@ -145,7 +159,7 @@ export async function start(paths, options) {
145
159
  mkdirSync(paths.logs, { recursive: true });
146
160
  const running = await runningRuntime(dataDir);
147
161
  if (running) {
148
- show(running.url, entryUrl(running, dataDir), options.open);
162
+ show(running.url, entryUrl(running, paths), options.open);
149
163
  console.log(dim(` It was already running. To stop it: ${cmd("stop")}`));
150
164
  return 0;
151
165
  }
@@ -155,7 +169,7 @@ export async function start(paths, options) {
155
169
  console.error(`engenty wizards didn’t start. Its log is in ${tilde(join(paths.logs, "runtime.log"))}.`);
156
170
  return 1;
157
171
  }
158
- show(started.url, entryUrl(started, dataDir), options.open);
172
+ show(started.url, entryUrl(started, paths), options.open);
159
173
  console.log(dim(` It’s running in the background. To stop it: ${cmd("stop")}`));
160
174
  console.log(dim(` Its log is in ${tilde(join(paths.logs, "runtime.log"))}.`));
161
175
  return 0;
@@ -224,7 +238,7 @@ export async function studio(paths) {
224
238
  const { dataDir } = settings(paths);
225
239
  const running = await runningRuntime(dataDir);
226
240
  if (running) {
227
- show(running.url, entryUrl(running, dataDir), true);
241
+ show(running.url, entryUrl(running, paths), true);
228
242
  return 0;
229
243
  }
230
244
  return start(paths, { open: true, background: true });
@@ -237,7 +251,7 @@ export async function open(paths, print) {
237
251
  console.error(`engenty wizards isn’t running. To start it: ${cmd("start")}`);
238
252
  return 1;
239
253
  }
240
- const entry = entryUrl(running, dataDir);
254
+ const entry = entryUrl(running, paths);
241
255
  if (print || !openBrowser(entry)) {
242
256
  console.log(entry);
243
257
  }
@@ -135,7 +135,7 @@ export async function restart(paths) {
135
135
  }
136
136
  console.log(`${ok} ${running ? "Restarted" : "Started"}: ${cyan(started.url)} ${dim(`pid ${started.pid}, in the background`)}`);
137
137
  if (!running) {
138
- console.log(` Open the studio: ${cyan(entryUrl(started, dataDir))}`);
138
+ console.log(` Open the studio: ${cyan(entryUrl(started, paths))}`);
139
139
  }
140
140
  return 0;
141
141
  }
@@ -11,9 +11,6 @@ export const MICROS_PER_CREDIT = 1_000_000;
11
11
  export function usdToMicros(usd) {
12
12
  return Math.ceil(usd * 100 * MICROS_PER_CREDIT);
13
13
  }
14
- export function microsToCredits(micros) {
15
- return Math.round(micros / MICROS_PER_CREDIT);
16
- }
17
14
  /** At least one credit left — enough to start something. */
18
15
  export async function canSpend() {
19
16
  if (!managed) {
@@ -92,13 +92,6 @@ export function tenantDb(id) {
92
92
  }
93
93
  return db;
94
94
  }
95
- /** Records where the Manage-App created the tenant's database, before it is first opened. */
96
- export async function registerTenant(id, dbUrl) {
97
- await controlDb
98
- .insert(control.tenant)
99
- .values({ id, dbUrl })
100
- .onConflictDoUpdate({ target: control.tenant.id, set: { dbUrl } });
101
- }
102
95
  const ready = new Map();
103
96
  /** Closes and forgets an open tenant database (the tenant was deleted or moved). */
104
97
  export function closeTenantDb(id) {
@@ -80,6 +80,16 @@ export const setting = sqliteTable("setting", {
80
80
  key: text("key").primaryKey(),
81
81
  value: text("value", { mode: "json" }).$type().notNull(),
82
82
  });
83
+ /**
84
+ * The runner's own words in a language outside `LANGS`, translated once for the runtime:
85
+ * `source` is the hash of the English tables they were made from.
86
+ */
87
+ export const uiTranslation = sqliteTable("ui_translation", {
88
+ lang: text("lang").primaryKey(),
89
+ source: text("source").notNull(),
90
+ texts: text("texts", { mode: "json" }).$type().notNull(),
91
+ createdAt: createdAt(),
92
+ });
83
93
  // --- marketplace -----------------------------------------------------------------
84
94
  // The marketplace is an app of its own (docs/marketplace-contract.md). What this runtime keeps
85
95
  // of it for offline use: its starters and what people starred, as the marketplace exports them.
@@ -0,0 +1,6 @@
1
+ CREATE TABLE `ui_translation` (
2
+ `lang` text PRIMARY KEY NOT NULL,
3
+ `source` text NOT NULL,
4
+ `texts` text NOT NULL,
5
+ `created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL
6
+ );