@engenty/wizards-runtime 0.9.7 → 0.10.0

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 (124) hide show
  1. package/apps/runtime/dist/agents/architect.js +4 -2
  2. package/apps/runtime/dist/agents/company.js +1 -1
  3. package/apps/runtime/dist/agents/studio-assistant.js +1 -1
  4. package/apps/runtime/dist/app.js +18 -1
  5. package/apps/runtime/dist/assistant/primer.js +1 -1
  6. package/apps/runtime/dist/auth/index.js +10 -1
  7. package/apps/runtime/dist/authoring/example.js +2 -2
  8. package/apps/runtime/dist/authoring/guide.js +11 -11
  9. package/apps/runtime/dist/credits/estimate.js +5 -5
  10. package/apps/runtime/dist/db/adopt.js +4 -3
  11. package/apps/runtime/dist/db/client.js +9 -1
  12. package/apps/runtime/dist/db/migrations/control/0011_model_classes.sql +11 -0
  13. package/apps/runtime/dist/db/migrations/control/meta/0011_snapshot.json +600 -0
  14. package/apps/runtime/dist/db/migrations/control/meta/_journal.json +7 -0
  15. package/apps/runtime/dist/db/migrations/tenant/0021_model_classes.sql +41 -0
  16. package/apps/runtime/dist/db/migrations/tenant/0022_sync.sql +247 -0
  17. package/apps/runtime/dist/db/migrations/tenant/meta/0021_snapshot.json +3475 -0
  18. package/apps/runtime/dist/db/migrations/tenant/meta/0022_snapshot.json +3792 -0
  19. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +14 -0
  20. package/apps/runtime/dist/db/schema.js +60 -0
  21. package/apps/runtime/dist/docs/dev/plugins/quick-start.md +2 -2
  22. package/apps/runtime/dist/docs/dev/plugins/server.md +2 -2
  23. package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +9 -5
  24. package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +2 -2
  25. package/apps/runtime/dist/docs/dev/wizard-format/index.md +14 -8
  26. package/apps/runtime/dist/docs/user-guide/cloud-sync.md +85 -0
  27. package/apps/runtime/dist/docs/user-guide/data.md +4 -4
  28. package/apps/runtime/dist/docs/user-guide/meta.json +1 -0
  29. package/apps/runtime/dist/docs/user-guide/models.md +22 -13
  30. package/apps/runtime/dist/docs/user-guide/steps.md +6 -6
  31. package/apps/runtime/dist/docs/user-guide/test-and-share.md +4 -14
  32. package/apps/runtime/dist/documents/parse.js +1 -1
  33. package/apps/runtime/dist/engine/requirements.js +11 -11
  34. package/apps/runtime/dist/engine/steps.js +4 -4
  35. package/apps/runtime/dist/env.js +4 -4
  36. package/apps/runtime/dist/files/blobs.js +13 -0
  37. package/apps/runtime/dist/film/step.js +1 -1
  38. package/apps/runtime/dist/harness/antigravity.js +3 -3
  39. package/apps/runtime/dist/harness/apple.js +1 -1
  40. package/apps/runtime/dist/harness/claude.js +2 -2
  41. package/apps/runtime/dist/harness/codex.js +3 -3
  42. package/apps/runtime/dist/harness/cursor.js +1 -1
  43. package/apps/runtime/dist/index.js +7 -1
  44. package/apps/runtime/dist/mcp/tools.js +6 -3
  45. package/apps/runtime/dist/models.js +64 -10
  46. package/apps/runtime/dist/plugins/jobs.js +7 -0
  47. package/apps/runtime/dist/plugins/loader.js +1 -1
  48. package/apps/runtime/dist/routes/api.js +107 -0
  49. package/apps/runtime/dist/routes/studio.js +78 -5
  50. package/apps/runtime/dist/services/assistant-chats.js +1 -1
  51. package/apps/runtime/dist/services/brand.js +1 -1
  52. package/apps/runtime/dist/services/cloud.js +39 -5
  53. package/apps/runtime/dist/services/knowledge-model.js +1 -1
  54. package/apps/runtime/dist/services/marketplace.js +3 -1
  55. package/apps/runtime/dist/services/project-files.js +1 -1
  56. package/apps/runtime/dist/services/projects.js +11 -0
  57. package/apps/runtime/dist/services/translations.js +2 -2
  58. package/apps/runtime/dist/services/wizards.js +2 -2
  59. package/apps/runtime/dist/sharing/agent.js +1 -1
  60. package/apps/runtime/dist/sync/apply.js +39 -0
  61. package/apps/runtime/dist/sync/client.js +828 -0
  62. package/apps/runtime/dist/sync/hub.js +324 -0
  63. package/apps/runtime/dist/sync/log.js +74 -0
  64. package/apps/runtime/dist/sync/records.js +943 -0
  65. package/apps/runtime/dist/sync/state.js +17 -0
  66. package/apps/runtime/dist/texts.js +12 -0
  67. package/apps/web/dist/assets/{AboutDialog-B3tljxg5.js → AboutDialog-D1YHT0jc.js} +1 -1
  68. package/apps/web/dist/assets/{ChangelogDialog-DfWTNzyl.js → ChangelogDialog-Bv02g8av.js} +1 -1
  69. package/apps/web/dist/assets/{EditorPage-XDdz2UM4.js → EditorPage-BThoZwqO.js} +4 -4
  70. package/apps/web/dist/assets/{FlowPreview-CKNVCFbp.js → FlowPreview-dc5C92kK.js} +1 -1
  71. package/apps/web/dist/assets/{Harness-BCec49Cq.js → Harness-D0nFOIVx.js} +1 -1
  72. package/apps/web/dist/assets/{Marketplace-BuYeaxK2.js → Marketplace-Cnd8BF3q.js} +2 -2
  73. package/apps/web/dist/assets/{NewWizardChannels-DRNji-bk.js → NewWizardChannels-i62Y_2DZ.js} +1 -1
  74. package/apps/web/dist/assets/{NewWizardPage-4TpgYOaI.js → NewWizardPage-BcpRA1fx.js} +1 -1
  75. package/apps/web/dist/assets/{OnboardingPage-Cf52NOIt.js → OnboardingPage-BcMDEXNq.js} +1 -1
  76. package/apps/web/dist/assets/PreviewPane-GHcVV2Hu.js +4 -0
  77. package/apps/web/dist/assets/{ProjectPage-D6Tah3QK.js → ProjectPage-TDywzUOd.js} +1 -1
  78. package/apps/web/dist/assets/{PublicRunner-Bftc1c4m.js → PublicRunner-B6JINLpR.js} +1 -1
  79. package/apps/web/dist/assets/{ReadOnly-DVQm9IYx.js → ReadOnly-Mv5M2OV9.js} +1 -1
  80. package/apps/web/dist/assets/SettingsPage-B-F1dLgt.js +2 -0
  81. package/apps/web/dist/assets/SetupPage-CVdsdVBW.js +1 -0
  82. package/apps/web/dist/assets/{SharePage-Cn-bqSyr.js → SharePage-CBSRK0wF.js} +1 -1
  83. package/apps/web/dist/assets/changelog-BR1lxaWv.js +1 -0
  84. package/apps/web/dist/assets/{coins-DgDTBbeg.js → coins-BGZKYmu6.js} +1 -1
  85. package/apps/web/dist/assets/index-D3-kv1WF.js +14 -0
  86. package/apps/web/dist/assets/index-DcUL6teA.css +1 -0
  87. package/apps/web/dist/assets/{phone-D1Drdiio.js → phone-BzHhwehj.js} +1 -1
  88. package/apps/web/dist/assets/{runners-CTd0YAiA.js → runners-C1-zIlry.js} +1 -1
  89. package/apps/web/dist/assets/{session-DX2BcTfz.js → session-B_JeZnJ0.js} +1 -1
  90. package/apps/web/dist/assets/{settings-menu-ay9jNbQu.js → settings-menu-BZRGhsIO.js} +1 -1
  91. package/apps/web/dist/assets/theme-HcCfZDzS.js +11 -0
  92. package/apps/web/dist/assets/{ui-CJCF3Mhe.js → ui-BI1RPFWT.js} +26 -26
  93. package/apps/web/dist/assets/{upload-Dj7KPL--.js → upload-CwT8oMz0.js} +1 -1
  94. package/apps/web/dist/assets/{useMutation-CUSQpD-i.js → useMutation-byk81dDj.js} +1 -1
  95. package/apps/web/dist/assets/{volume-2-CcHZOU2m.js → volume-2-B1Pz6Iwt.js} +1 -1
  96. package/apps/web/dist/assets/{wrench-CfJTFnMJ.js → wrench-CvzXRbWN.js} +1 -1
  97. package/apps/web/dist/index.html +8 -8
  98. package/apps/web/dist/mcp/flow.html +56 -56
  99. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +2 -2
  100. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +872 -18
  101. package/node_modules/@engenty/wizards-shared/dist/definition.js +52 -11
  102. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +6 -0
  103. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +6 -0
  104. package/node_modules/@engenty/wizards-shared/dist/json-schema.js +3 -3
  105. package/node_modules/@engenty/wizards-shared/dist/providers.d.ts +37 -0
  106. package/node_modules/@engenty/wizards-shared/dist/providers.js +64 -12
  107. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +6 -0
  108. package/node_modules/@engenty/wizards-shared/dist/run.js +12 -0
  109. package/node_modules/@engenty/wizards-shared/dist/sync-merge.d.ts +55 -0
  110. package/node_modules/@engenty/wizards-shared/dist/sync-merge.js +214 -0
  111. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +166 -0
  112. package/node_modules/@engenty/wizards-shared/dist/sync.js +40 -0
  113. package/node_modules/@engenty/wizards-shared/dist/text-merge.d.ts +14 -0
  114. package/node_modules/@engenty/wizards-shared/dist/text-merge.js +137 -0
  115. package/package.json +1 -1
  116. package/plugin/.claude-plugin/plugin.json +1 -1
  117. package/plugin/plugin.json +1 -1
  118. package/apps/web/dist/assets/PreviewPane-C4yMcZPM.js +0 -4
  119. package/apps/web/dist/assets/SettingsPage-Cd-osLDu.js +0 -2
  120. package/apps/web/dist/assets/SetupPage-Dc8U5k5P.js +0 -1
  121. package/apps/web/dist/assets/changelog-CjSBB-a4.js +0 -1
  122. package/apps/web/dist/assets/index-DS3zUVw_.css +0 -1
  123. package/apps/web/dist/assets/index-Da7hPToW.js +0 -14
  124. package/apps/web/dist/assets/theme-DanjuO1H.js +0 -11
@@ -1,4 +1,5 @@
1
1
  import { anthropic } from "@ai-sdk/anthropic";
2
+ import { DEFINITION_VERSION, upgradeDefinition, } from "@engenty/wizards-shared/definition";
2
3
  import { SURFACE_GUIDE } from "@engenty/wizards-shared/surface";
3
4
  import { isTextMime } from "@engenty/wizards-shared/workspace";
4
5
  import { Agent } from "@mastra/core/agent";
@@ -135,7 +136,8 @@ function buildTools(input, resolved, wrote) {
135
136
  execute: async ({ wizard }) => attempt(async () => {
136
137
  const w = await ownedWizard(userId, wizardId);
137
138
  const { issues } = await writeDraft(userId, wizardId, {
138
- definition: wizard,
139
+ // Written from today's authoring guide: today's version, said or not.
140
+ definition: upgradeDefinition(wizard, DEFINITION_VERSION),
139
141
  baseRevision: w.revision,
140
142
  });
141
143
  wrote();
@@ -321,7 +323,7 @@ export async function runArchitect(input) {
321
323
  const files = await listFiles(input.userId, input.wizardId);
322
324
  let changed = false;
323
325
  // Building a wizard is the hardest job here: widgets are code.
324
- const resolved = await chatModel(input.way, "highest");
326
+ const resolved = await chatModel(input.way, "high");
325
327
  const tools = buildTools(input, resolved, () => {
326
328
  changed = true;
327
329
  });
@@ -44,7 +44,7 @@ export async function readCompany(input) {
44
44
  if (!(await canSpend())) {
45
45
  return null;
46
46
  }
47
- const reader = await textModel("standard");
47
+ const reader = await textModel("low");
48
48
  const { output } = await generateText({
49
49
  model: reader.model,
50
50
  abortSignal: input.signal,
@@ -681,7 +681,7 @@ export async function runStudioAssistant(input) {
681
681
  let changes = 0;
682
682
  // The way the settings chose for the studio's chats: on a client, its tools reach it over MCP.
683
683
  const way = managed ? "models" : await chatEngine(await hasTextModel());
684
- const resolved = await chatModel(way, "high");
684
+ const resolved = await chatModel(way, "standard");
685
685
  const wrote = () => {
686
686
  changes++;
687
687
  input.onChanged?.();
@@ -34,6 +34,7 @@ import { runTicketValid } from "./secrets/signing.js";
34
34
  import { asRole } from "./services/access.js";
35
35
  import { ServiceError } from "./services/errors.js";
36
36
  import { servePageRunner } from "./services/runners.js";
37
+ import { afterStudioWrite, beforeStudioLoad } from "./sync/client.js";
37
38
  import { tenantOfLink, tenantStatus } from "./tenants/control.js";
38
39
  const app = new Hono();
39
40
  // Which halves this process serves (RUNTIME_ROLE): the studio's routes, the doors' routes, or
@@ -199,6 +200,8 @@ if (serves.doors) {
199
200
  ]);
200
201
  });
201
202
  }
203
+ /** The studio's requests that open an item: a wizard, a page, a table, a space. */
204
+ const STUDIO_LOADS = /\/api\/studio\/(wizards\/[^/]+|pages\/[^/]+|tables\/[^/]+|projects(\/[^/]+(\/(data|knowledge|files|wizards|page))?)?)$/;
202
205
  if (serves.studio) {
203
206
  /** Studio requests act as the signed-in person, inside that person's tenant. */
204
207
  app.use("/api/studio/*", async (c, next) => {
@@ -216,7 +219,21 @@ if (serves.studio) {
216
219
  }, 403);
217
220
  }
218
221
  c.set("user", user);
219
- return withTenant(user.tenantId, () => asRole(user.role, next));
222
+ if (managed) {
223
+ return withTenant(user.tenantId, () => asRole(user.role, next));
224
+ }
225
+ // An install that syncs both ways (sync/client.ts): what the studio opens comes down from
226
+ // the cloud first, what it saved goes up after.
227
+ return withTenant(user.tenantId, async () => {
228
+ const loads = c.req.method === "GET" && STUDIO_LOADS.test(c.req.path);
229
+ if (loads) {
230
+ await beforeStudioLoad().catch(() => undefined);
231
+ }
232
+ await asRole(user.role, next);
233
+ if (c.req.method !== "GET" && !c.req.path.includes("/api/studio/sync")) {
234
+ afterStudioWrite((run) => withTenant(user.tenantId, run));
235
+ }
236
+ });
220
237
  });
221
238
  const mcp = mcpHandler();
222
239
  app.on(["GET", "POST", "DELETE"], "/api/mcp", (c) => mcp(c.req.raw));
@@ -11,7 +11,7 @@ Words
11
11
  - Wizard: a flow of steps a person walks through on a link. Step kinds: a page (fields to fill in), an AI step (an agent with tools: web search, reading files, writing documents, images, video, pages, other services), a review, and the result.
12
12
  - Run: one person going through a wizard once. Results lists every run that reached its result.
13
13
  - Space: what all wizards of an organization know. Its page has four parts: Info & brand (title, about, logos, colours, assets, facts), Knowledge (pages, tables and files the AI steps look things up in, kept apart by typed categories), Data (tables and pages the wizards keep) and Results (finished runs).
14
- - Model class: the kind of model a step needs (Classifier, Standard, High, Highest for text; Image, Video, Speech, Audio). Which model serves a class is a setting (Settings › Models), not part of the wizard.
14
+ - Model class: the kind of model a step needs (Classifier, Low, Standard, High for text; Image, Video, Speech, Audio). Which model serves a class is a setting (Settings › Models), not part of the wizard.
15
15
 
16
16
  Thinking: an installed AI client on the person's subscription (Claude Code, Codex, Antigravity, Cursor Agent), own API keys (OpenAI, Anthropic, Google, fal.ai, ElevenLabs, Replicate, Vercel AI Gateway), a local model (Ollama), or engenty credits from an account. Settings › Models shows which way serves each class and what is missing.
17
17
 
@@ -30,7 +30,16 @@ async function firstSync() {
30
30
  try {
31
31
  // Loaded here: the services read the session this module makes.
32
32
  const { syncAllToCloud } = await import("../services/cloud.js");
33
- await withTenant(LOCAL_TENANT, () => syncAllToCloud(localUser().id));
33
+ const twoWay = await import("../sync/client.js");
34
+ await withTenant(LOCAL_TENANT, async () => {
35
+ // With the two-way sync the spaces themselves go up and come down; else what is published.
36
+ if (await twoWay.twoWayAvailable()) {
37
+ await twoWay.syncAll();
38
+ }
39
+ else {
40
+ await syncAllToCloud(localUser().id);
41
+ }
42
+ });
34
43
  }
35
44
  catch (err) {
36
45
  console.error("[cloud] first sync failed:", err);
@@ -3,7 +3,7 @@
3
3
  * the guide's own, not a marketplace entry, so the guide never depends on the marketplace.
4
4
  */
5
5
  export const EXAMPLE_WIZARD = {
6
- version: 1,
6
+ version: 2,
7
7
  title: "X post with an image",
8
8
  description: "Turns a topic into a finished post with an image.",
9
9
  avatar: "flame",
@@ -40,7 +40,7 @@ export const EXAMPLE_WIZARD = {
40
40
  instructions: "Write a post for X (Twitter) on the topic: {{topic}}. Tone: {{tone}}. At most 270 characters including the link, and at most two hashtags. If a link is given ({{link}}), put it at the end. A strong first sentence. Output only the post.",
41
41
  tools: [],
42
42
  output: { format: "text" },
43
- model: "standard",
43
+ model: "low",
44
44
  },
45
45
  {
46
46
  id: "visual",
@@ -8,7 +8,7 @@ import { EXAMPLE_WIZARD } from "./example.js";
8
8
  */
9
9
  export const SCHEMA_DOC = `
10
10
  type Wizard = {
11
- version: 1
11
+ version: 2 // always write it: the class names below are those of version 2
12
12
  title: string // short, what the end user gets ("Rechnung erstellen")
13
13
  description: string // one sentence
14
14
  avatar: "round"|"drop"|"dome"|"flame"|"oval"|"bean"|"pebble"|"sprout"|"tower"|"wedge" // the engenty mascot shown to end users
@@ -164,8 +164,8 @@ type AgentStep = {
164
164
  // one table, steps.<id>.rows: the entry's columns plus the step's output fields, a row per entry.
165
165
  // a table with columns gives rows as objects with exactly those keys — what widgets read
166
166
  // "yesno" answers the question in its description with true/false; "choice" picks one of its options
167
- model?: "classifier"|"standard"|"high"|"highest" // the kind of model, see "Models"; default "high"
168
- effort?: "low"|"medium"|"high" // how hard it should think; leave out unless it matters
167
+ model?: "classifier"|"low"|"standard"|"high" // the kind of model, see "Models"; default "standard"
168
+ effort?: "low"|"medium"|"high" // how hard it should think; leave out unless it matters
169
169
  working?: string // shown while it runs ("Recherchiert im Web …")
170
170
  }
171
171
  // Every agent step also has, without listing them: list_read / list_write (the wizard's lists), files_list,
@@ -287,7 +287,7 @@ type FilmStep = {
287
287
  from?: string // "steps.<filmStepId>": start from that earlier film's code and lay it out for this format —
288
288
  // the second format of a film in minutes; made from scratch when that step did not run
289
289
  seconds?: number // about how long
290
- model?: "standard" | "high" // default standard
290
+ model?: "low" | "standard" // the model class; default "low"
291
291
  effort?: Effort
292
292
  working?: string
293
293
  }
@@ -349,7 +349,7 @@ How good wizards look:
349
349
  correct or regenerate. A result people can simply make again needs no review before it.
350
350
  - Money/totals: use an "items" field with vat — the runner computes totals; documents must use {{items}} verbatim. Never let a model compute totals.
351
351
  - Facts from the web need an agent step with web_search + web_fetch BEFORE writing; documents then cite those notes.
352
- - Live data with a free public JSON API (weather and wind: api.open-meteo.com; sunrise/sunset is in it too) → an agent step with the http tool and model "standard" that calls the API and returns json. Far cheaper and more exact than web research; use web research only when no API exists.
352
+ - Live data with a free public JSON API (weather and wind: api.open-meteo.com; sunrise/sunset is in it too) → an agent step with the http tool and model "low" that calls the API and returns json. Far cheaper and more exact than web research; use web research only when no API exists.
353
353
  - Writing into other systems (CRM, database, spreadsheet, website): an agent step with the matching mcp server, http, or browser tool, preceded by a review step. Such a step hands over an earlier step's output as a file by naming it "result:<stepId>.<format>" — to browser_upload, or as "file:result:<stepId>.<format>" where a connector action takes "*_base64".
354
354
  - Sending the finished result on (mail it, file it in a cloud folder, post it on social media or a website, put it into an ads account): do not build a step for it. Put the targets into the result step's "share": the person sees the result first and sends it with one button. Build an agent step only when the wizard must write somewhere without being asked.
355
355
  ${sandboxGuideLine()}
@@ -368,8 +368,8 @@ ${sandboxGuideLine()}
368
368
  - Going through documents one by one (receipts against payments): never one model step per document. One step reads them in batches (scan_documents takes 30 at once) and writes rows into a list with "check"; the review shows that list split-screen — the person answers each row beside its file, without any model call.
369
369
  - Video that convinces is built in stages, each with its own review: idea and script (agent, json with a table of shots) → one still per shot (generate image with "each", starting from the person's product photo) → one clip per still (generate video with "each" and referenceImage = the stills step) → a voice-over (generate voice) → a film widget (video: true) that cuts clips, captions, voice and a closing card with the call to action. The starters "facebook-video-ad" and "property-film" carry such a widget (film/film.js) to copy. Offer a cheaper path without clips: the film animates the stills.
370
370
  - Motion-graphics films (explainers, product spots, shorts) are a "film" step after the preparation, each with a review:
371
- research and script (agent, high) → the voice-over (one generate voice step for the whole script; the film step finds the
372
- word timings itself) → film (inputs: the voice, pictures, the script). The look comes from a style kit in the workspace (kit), so the film step stays on "standard".
371
+ research and script (agent, standard) → the voice-over (one generate voice step for the whole script; the film step finds the
372
+ word timings itself) → film (inputs: the voice, pictures, the script). The look comes from a style kit in the workspace (kit), so the film step stays on "low".
373
373
  - Prices come from a file the admin keeps in the workspace (a CSV price list): the agent step looks them up with read_workspace_file and proposes positions as a table; the next page shows them in an "items" field with "prefill" for the person to correct; the runner computes the totals.
374
374
  - AI media is marked for you (EU AI Act, Art. 50): images, clips, voice-overs and films carry the marking in their file metadata, and the pages lay the EU's "AI" label over them. Never ask an image step to draw such a label into the picture. A film is different — it leaves the page as a video file, so its widget shows the EU label in the picture: wizard.ai tells a widget whether the run's media in its data is "generated" or "edited" (film/film.js draws the matching icon).
375
375
  - Every step a person sees later (review/result) must come from an earlier step id.
@@ -455,11 +455,11 @@ ${connectorsLine(connectors)}${pluginToolsLine(pluginTools)}
455
455
  Models: a step names the KIND of model it needs, never a model. Pick the cheapest class that does the job:
456
456
  - "classifier": routing, yes/no, picking from options, pulling a few values out of text.
457
457
  A DECISION is a "classifier" step with no tools whose json output has only "yesno", "choice" and "score" fields: it is answered in one fast, very cheap call. A branch can also read how sure it is: "steps.<id>.<field>.p" is the probability of its answer (a number 0–1; 1 or 0 where no decision model is set up), e.g. { field: "steps.check.urgent.p", op: "gt", value: 0.8 }. Write the question into each field's description, give the step everything it must judge in its instructions via {{templates}}, and branch on the answer with "next" (e.g. { when: { field: "steps.check.refund", op: "equals", value: true }, goto: "refund" }).
458
- - "standard": short copy, calling an API, reformatting, simple summaries.
459
- - "high": research with tools, long documents, reasoning over many sources (the default).
460
- - "highest": hard reasoning or writing code; rare in a run, several times the cost of "high".
458
+ - "low": short copy, calling an API, reformatting, simple summaries.
459
+ - "standard": research with tools, long documents, reasoning over many sources (the default).
460
+ - "high": hard reasoning or writing code; rare in a run, several times the cost of "standard".
461
461
  "effort" ("low" | "medium" | "high") tells the model how hard to think where it can be told; leave it out unless a step is clearly trivial ("low") or clearly hard ("high").
462
- A generate step for a document or dashboard takes the same "model" (default "high"). Image and video steps use the image and video class; which model serves a class is set by the platform, not in the wizard.
462
+ A generate step for a document or dashboard takes the same "model" (default "standard"). Image and video steps use the image and video class; which model serves a class is set by the platform, not in the wizard.
463
463
 
464
464
  Editing:
465
465
  - Every write returns the new "revision" and the validator's "issues". Pass the revision you last saw as "baseRevision"; on revision_conflict re-read with get_wizard and apply your change again.
@@ -51,7 +51,7 @@ function stepFormula(step, catalog) {
51
51
  ? TOKENS.tools
52
52
  : TOKENS.plain;
53
53
  // A step with `each` runs once per entry; until it has run, three stand in.
54
- let credits = textCredits(cls(step.model ?? "high"), shape) * (step.each ? 3 : 1);
54
+ let credits = textCredits(cls(step.model ?? "standard"), shape) * (step.each ? 3 : 1);
55
55
  if (step.tools.includes("web_search")) {
56
56
  credits += 4 * catalog.webSearchCredits;
57
57
  }
@@ -62,20 +62,20 @@ function stepFormula(step, catalog) {
62
62
  credits += textCredits(cls("classifier"), TOKENS.structure);
63
63
  }
64
64
  if (step.output.surface === true) {
65
- credits += textCredits(cls("standard"), TOKENS.structure);
65
+ credits += textCredits(cls("low"), TOKENS.structure);
66
66
  }
67
67
  return credits;
68
68
  }
69
69
  if (step.type === "generate") {
70
70
  if (step.asset === "image") {
71
- return ((catalog.classes.image?.creditsPerImage ?? 0) + textCredits(cls("standard"), TOKENS.prompt));
71
+ return (catalog.classes.image?.creditsPerImage ?? 0) + textCredits(cls("low"), TOKENS.prompt);
72
72
  }
73
73
  if (step.asset === "video") {
74
74
  const seconds = Math.min(Math.max(Math.round(step.options?.duration ?? 8), 4), 10);
75
75
  return (seconds * (catalog.classes.video?.creditsPerSecond ?? 0) +
76
- textCredits(cls("standard"), TOKENS.prompt));
76
+ textCredits(cls("low"), TOKENS.prompt));
77
77
  }
78
- return textCredits(cls(step.model ?? "high"), TOKENS.document);
78
+ return textCredits(cls(step.model ?? "standard"), TOKENS.document);
79
79
  }
80
80
  return 0;
81
81
  }
@@ -1,6 +1,7 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { cp } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
+ import { upgradeDefinition } from "@engenty/wizards-shared/definition";
4
5
  import { createClient } from "@libsql/client";
5
6
  import { env } from "../env.js";
6
7
  import { readSetting, writeSetting } from "../settings.js";
@@ -26,14 +27,14 @@ const TABLES = [
26
27
  "store_file",
27
28
  "store_secret",
28
29
  ];
29
- const CLASS_OF = { fast: "standard", smart: "high" };
30
- /** Steps named a model speed before they named a model class. */
30
+ const CLASS_OF = { fast: "low", smart: "standard" };
31
+ /** Steps named a model speed before they named a model class; then classes of version 1. */
31
32
  function withClasses(json) {
32
33
  if (typeof json !== "string") {
33
34
  return json;
34
35
  }
35
36
  try {
36
- const def = JSON.parse(json);
37
+ const def = upgradeDefinition(JSON.parse(json));
37
38
  for (const step of def.steps ?? []) {
38
39
  if (step.model && CLASS_OF[step.model]) {
39
40
  step.model = CLASS_OF[step.model];
@@ -1,5 +1,5 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
- import { mkdirSync } from "node:fs";
2
+ import { mkdirSync, readFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { createClient } from "@libsql/client";
@@ -16,6 +16,14 @@ const here = dirname(fileURLToPath(import.meta.url));
16
16
  function migrationsFolder(name) {
17
17
  return join(here, "migrations", name);
18
18
  }
19
+ /**
20
+ * The tenant schema this release writes: the last migration's tag (`0022_sync`). The two-way
21
+ * sync runs only between sides that have the same.
22
+ */
23
+ export const tenantSchemaVersion = (() => {
24
+ const journal = JSON.parse(readFileSync(join(migrationsFolder("tenant"), "meta", "_journal.json"), "utf8"));
25
+ return journal.entries.at(-1)?.tag ?? "";
26
+ })();
19
27
  function open(url, authToken) {
20
28
  return createClient({ url, ...(authToken ? { authToken } : {}) });
21
29
  }
@@ -0,0 +1,11 @@
1
+ -- Definition version 2: the bindings of the text classes standard, high and highest of version 1
2
+ -- belong to low, standard and high now. json_patch leaves out a class that had no binding.
3
+ UPDATE `setting` SET `value` = json_set(`value`, '$.bindings', json_patch(
4
+ json_remove(json_extract(`value`, '$.bindings'), '$.standard', '$.high', '$.highest'),
5
+ json_object(
6
+ 'low', json_extract(`value`, '$.bindings.standard'),
7
+ 'standard', json_extract(`value`, '$.bindings.high'),
8
+ 'high', json_extract(`value`, '$.bindings.highest')
9
+ )))
10
+ WHERE (`key` = 'models' OR `key` LIKE 'models:%')
11
+ AND json_valid(`value`) AND json_type(`value`, '$.bindings') = 'object';