@engenty/wizards-runtime 0.11.7 → 0.11.9

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 (54) hide show
  1. package/apps/runtime/dist/app.js +25 -0
  2. package/apps/runtime/dist/db/client.js +32 -0
  3. package/apps/runtime/dist/db/control-schema.js +2 -0
  4. package/apps/runtime/dist/db/migrations/control/0012_runner_line.sql +1 -0
  5. package/apps/runtime/dist/db/migrations/control/meta/0012_snapshot.json +607 -0
  6. package/apps/runtime/dist/db/migrations/control/meta/_journal.json +7 -0
  7. package/apps/runtime/dist/engine/runner.js +37 -3
  8. package/apps/runtime/dist/env.js +10 -0
  9. package/apps/runtime/dist/files/objects.js +15 -2
  10. package/apps/runtime/dist/health.js +287 -0
  11. package/apps/runtime/dist/index.js +19 -0
  12. package/apps/runtime/dist/open-command.js +31 -0
  13. package/apps/runtime/dist/routes/internal.js +2 -0
  14. package/apps/runtime/dist/tenants/control.js +20 -0
  15. package/apps/web/dist/assets/{AboutDialog-J9rRhJTJ.js → AboutDialog-CVr7-F9d.js} +1 -1
  16. package/apps/web/dist/assets/{ChangelogDialog-D9bBSuLQ.js → ChangelogDialog-BBrbTJvy.js} +1 -1
  17. package/apps/web/dist/assets/{CodeEditor-CiRJjYpm.js → CodeEditor-ydfkafOX.js} +1 -1
  18. package/apps/web/dist/assets/{EditorPage-ChLV09jO.js → EditorPage-Dp9t6JBC.js} +1 -1
  19. package/apps/web/dist/assets/{FlowPreview-QRnLE4JM.js → FlowPreview-CPEK110v.js} +1 -1
  20. package/apps/web/dist/assets/{Harness-dM1CDgnx.js → Harness-BnU7FnhV.js} +1 -1
  21. package/apps/web/dist/assets/{Marketplace-8rU-MhWj.js → Marketplace-_IfcAgYO.js} +2 -2
  22. package/apps/web/dist/assets/{NewWizardChannels--JqgVT-t.js → NewWizardChannels-GqURod9Z.js} +1 -1
  23. package/apps/web/dist/assets/{NewWizardPage-CNv5UuBn.js → NewWizardPage-f7aCNCQz.js} +1 -1
  24. package/apps/web/dist/assets/{OnboardingPage-CDuhfBEI.js → OnboardingPage-B0z2X_4h.js} +1 -1
  25. package/apps/web/dist/assets/{PreviewPane-BsMrHW8b.js → PreviewPane-BC4zFl4u.js} +2 -2
  26. package/apps/web/dist/assets/{ProjectPage-CoVMEoB1.js → ProjectPage-B33OxA3U.js} +1 -1
  27. package/apps/web/dist/assets/PublicRunner-BvIMLJXn.js +1 -0
  28. package/apps/web/dist/assets/{ReadOnly-Ch-ss9Mh.js → ReadOnly-D8H4QIVD.js} +1 -1
  29. package/apps/web/dist/assets/{SettingsPage-CGp6G_fp.js → SettingsPage-cS2n5ThJ.js} +2 -2
  30. package/apps/web/dist/assets/{SetupPage-DgFT_646.js → SetupPage-RemLlEon.js} +1 -1
  31. package/apps/web/dist/assets/{SharePage-CEcFKE3b.js → SharePage-D4upbrdD.js} +1 -1
  32. package/apps/web/dist/assets/changelog-DicAdDi2.js +1 -0
  33. package/apps/web/dist/assets/i18n-BX8GnEZT.js +55 -0
  34. package/apps/web/dist/assets/{index-Dx7qMiM3.js → index-EkjeX2z-.js} +5 -5
  35. package/apps/web/dist/assets/{phone-De-HF0g7.js → phone-Dd7IVbpJ.js} +1 -1
  36. package/apps/web/dist/assets/{runners-UIPj9xyX.js → runners-XifDCQG3.js} +1 -1
  37. package/apps/web/dist/assets/{session-DUxZmhqy.js → session-BwtsznZF.js} +1 -1
  38. package/apps/web/dist/assets/{settings-menu-Bo1yXMGF.js → settings-menu-CS-fXrFW.js} +1 -1
  39. package/apps/web/dist/assets/{theme-CSuPPxre.js → theme-s9XywvSy.js} +2 -2
  40. package/apps/web/dist/assets/{ui-CBDsXUoA.js → ui-D719V_Yj.js} +1 -1
  41. package/apps/web/dist/assets/{upload-CZgdEF60.js → upload-CYTDCrYd.js} +1 -1
  42. package/apps/web/dist/assets/{useMutation-ZHWqRSPd.js → useMutation-CVVmJvyz.js} +1 -1
  43. package/apps/web/dist/assets/{volume-2-c641MxaU.js → volume-2-Do0dsjv2.js} +1 -1
  44. package/apps/web/dist/assets/{wrench-DCEAyYuR.js → wrench-C5syJD9J.js} +1 -1
  45. package/apps/web/dist/index.html +7 -7
  46. package/apps/web/dist/mcp/flow.html +2 -2
  47. package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +3 -1
  48. package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +2 -0
  49. package/package.json +1 -1
  50. package/plugin/.claude-plugin/plugin.json +1 -1
  51. package/plugin/plugin.json +1 -1
  52. package/apps/web/dist/assets/PublicRunner-Ckte5NnM.js +0 -1
  53. package/apps/web/dist/assets/changelog-DMhLfQmS.js +0 -1
  54. package/apps/web/dist/assets/i18n-AXoEWXfv.js +0 -55
@@ -13,6 +13,7 @@ import { authRoutes, principalOf } from "./auth/index.js";
13
13
  import { db, schema, withTenant } from "./db/client.js";
14
14
  import { basePath, env } from "./env.js";
15
15
  import { features } from "./features.js";
16
+ import { health, httpStatus, publicHealth, requestStarted } from "./health.js";
16
17
  import { allowed, hashIp } from "./limits.js";
17
18
  import { linkPreview } from "./link-preview.js";
18
19
  import { nudge, signal } from "./live/hub.js";
@@ -20,6 +21,7 @@ import { discovery, managed } from "./manage.js";
20
21
  import { bridgeRequest } from "./mcp/bridge.js";
21
22
  import { mcpHandler } from "./mcp/handler.js";
22
23
  import { MCP_RESOURCE, SCOPES } from "./mcp/scopes.js";
24
+ import { openCommand } from "./open-command.js";
23
25
  import { PLUGIN_NAME, pluginArchive, pluginMarketplace } from "./plugin.js";
24
26
  import { apiRoutes } from "./routes/api.js";
25
27
  import { browserReport, localDebugRoutes } from "./routes/debug.js";
@@ -45,6 +47,17 @@ const app = new Hono();
45
47
  // Which halves this process serves (RUNTIME_ROLE): the studio's routes, the doors' routes, or
46
48
  // both. What both need — health, config, the runs' API, the connect callback — is always there.
47
49
  const { serves } = env;
50
+ // Every request is open until its handler returned: one that never returns shows in the health
51
+ // checks and in the log (health.ts).
52
+ app.use("*", async (c, next) => {
53
+ const done = requestStarted(c.req.method, c.req.path);
54
+ try {
55
+ await next();
56
+ }
57
+ finally {
58
+ done();
59
+ }
60
+ });
48
61
  app.onError((err, c) => {
49
62
  if (err instanceof ServiceError) {
50
63
  const body = err.toJSON(requestLang(c));
@@ -114,6 +127,11 @@ app.use("*", async (c, next) => {
114
127
  return next();
115
128
  });
116
129
  app.get("/api/health", (c) => c.json({ ok: true }));
130
+ /** Whether this process and what it depends on work: 503 when it can't serve (health.ts). */
131
+ app.get("/api/health/ready", async (c) => {
132
+ const h = await health();
133
+ return c.json(publicHealth(h), httpStatus(h));
134
+ });
117
135
  /**
118
136
  * A page in a browser (the studio, a wizard's own page) tells of an error it met: the line
119
137
  * goes into this process's log like the server's own, so a look from afar sees both sides
@@ -151,6 +169,8 @@ app.get("/api/config", (c) => c.json({
151
169
  devLogin: !managed && env.devLogin,
152
170
  /** The product's own site, for a runtime that runs alone. */
153
171
  site: managed ? null : env.local.cloudUrl,
172
+ /** What to type to open the studio of a runtime that runs alone; null: its start printed the link. */
173
+ openCommand: managed ? null : openCommand(),
154
174
  /** Where the wizards' pages are: the studio makes their links with it. */
155
175
  publicUrl: env.publicUrl,
156
176
  /** The feature switches before anyone is signed in: the code's, the environment's, the file's. */
@@ -293,6 +313,11 @@ app.route("/api/internal", internalRoutes);
293
313
  if (serves.doors) {
294
314
  app.use("/api/public/*", answers);
295
315
  app.use("/api/shares/*", answers);
316
+ // The proxy sends `/api/public` to the doors: their readiness under their own prefix.
317
+ app.get("/api/public/health", async (c) => {
318
+ const h = await health();
319
+ return c.json(publicHealth(h), httpStatus(h));
320
+ });
296
321
  app.route("/api/public/plugins", publicPluginRoutes);
297
322
  app.route("/api/public", publicRoutes);
298
323
  app.route("/api/shares", shareRoutes);
@@ -42,6 +42,24 @@ const controlClient = open(controlUrl, env.databaseAuthToken);
42
42
  /** Links, the run index, sessions and settings: what is known before a tenant's database opens. */
43
43
  export const controlDb = drizzle(controlClient, { schema: control });
44
44
  export { control };
45
+ /**
46
+ * `SELECT 1` on the control database: through the client every request uses, or through a new
47
+ * one opened for this call alone. When the first fails and the second works, this process's
48
+ * client is stuck, not the database (health.ts).
49
+ */
50
+ export async function probeControl(fresh = false) {
51
+ if (!fresh) {
52
+ await controlClient.execute("SELECT 1");
53
+ return;
54
+ }
55
+ const client = open(controlUrl, env.databaseAuthToken);
56
+ try {
57
+ await client.execute("SELECT 1");
58
+ }
59
+ finally {
60
+ client.close();
61
+ }
62
+ }
45
63
  export async function migrateControlDb() {
46
64
  await prepare(controlClient, controlUrl);
47
65
  await migrate(controlDb, { migrationsFolder: migrationsFolder("control") });
@@ -84,7 +102,21 @@ async function whileBusy(fn) {
84
102
  }
85
103
  }
86
104
  }
105
+ /** Tenant databases still opening, and since when: one that takes minutes is stuck (health.ts). */
106
+ const opening = new Map();
107
+ export function openingTenants() {
108
+ return [...opening].map(([id, since]) => ({ id, since }));
109
+ }
87
110
  async function openTenant(id) {
111
+ opening.set(id, Date.now());
112
+ try {
113
+ return await openTenantNow(id);
114
+ }
115
+ finally {
116
+ opening.delete(id);
117
+ }
118
+ }
119
+ async function openTenantNow(id) {
88
120
  let row = await controlDb.query.tenant.findFirst({ where: eq(control.tenant.id, id) });
89
121
  if (!row) {
90
122
  await controlDb.insert(control.tenant).values({ id }).onConflictDoNothing();
@@ -60,6 +60,8 @@ export const runner = sqliteTable("runner", {
60
60
  id: text("id").primaryKey(),
61
61
  url: text("url"),
62
62
  seen: integer("seen", { mode: "timestamp_ms" }).notNull(),
63
+ /** When the runner last finished a look at the line: `seen` says it lives, this that the line moves. */
64
+ lineAt: integer("line_at", { mode: "timestamp_ms" }),
63
65
  });
64
66
  /** A studio session of someone signed in at the Manage-App. The refresh token is encrypted. */
65
67
  export const session = sqliteTable("session", {
@@ -0,0 +1 @@
1
+ ALTER TABLE `runner` ADD `line_at` integer;