@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
@@ -330,10 +330,11 @@ export function pluginToolOf(id) {
330
330
  : null;
331
331
  }
332
332
  /**
333
- * The kinds of model a step can ask for. A step names a class; which model serves it is bound
334
- * outside the wizard (the model-gateway, or the settings of a runtime that runs alone).
333
+ * The model classes a step can ask for (its `model`), cheapest first. A step names a class;
334
+ * which model serves it is bound outside the wizard (the model-gateway, or the settings of a
335
+ * runtime that runs alone).
335
336
  */
336
- export const TEXT_CLASSES = ["classifier", "standard", "high", "highest"];
337
+ export const TEXT_CLASSES = ["classifier", "low", "standard", "high"];
337
338
  export const MODEL_CLASSES = [...TEXT_CLASSES, "image", "video", "audio", "speech"];
338
339
  /** How hard the model should think, where the bound model can be told. */
339
340
  export const EFFORTS = ["low", "medium", "high"];
@@ -567,7 +568,7 @@ export const agentStepSchema = z.object({
567
568
  surface: z.union([z.boolean(), surfaceComponentsSchema]).optional(),
568
569
  })
569
570
  .default({ format: "markdown" }),
570
- /** The kind of model the step needs; default `high`. The model itself is bound elsewhere. */
571
+ /** The model class the step needs; default `standard`. The model itself is bound elsewhere. */
571
572
  model: z.enum(TEXT_CLASSES).optional(),
572
573
  effort: z.enum(EFFORTS).optional(),
573
574
  /** Shown to the person while it works. */
@@ -610,7 +611,7 @@ export const generateStepSchema = z.object({
610
611
  * `referenceImage` gives each entry its own image when it holds as many.
611
612
  */
612
613
  each: z.string().optional(),
613
- /** For document/dashboard: the kind of model that writes it; default `high`. */
614
+ /** For document/dashboard: the model class that writes it; default `standard`. */
614
615
  model: z.enum(TEXT_CLASSES).optional(),
615
616
  effort: z.enum(EFFORTS).optional(),
616
617
  working: z.string().optional(),
@@ -685,7 +686,7 @@ export const filmStepSchema = z.object({
685
686
  from: z.string().optional(),
686
687
  /** About how long the film runs, in seconds. */
687
688
  seconds: z.number().int().min(3).max(600).optional(),
688
- /** The kind of model; default `standard` — the kit carries the craft. */
689
+ /** The model class; default `low` — the kit carries the craft. */
689
690
  model: z.enum(TEXT_CLASSES).optional(),
690
691
  effort: z.enum(EFFORTS).optional(),
691
692
  working: z.string().optional(),
@@ -848,9 +849,46 @@ export const connectionSchema = z.object({
848
849
  title: z.string().optional(),
849
850
  description: z.string().optional(),
850
851
  });
851
- /** The version of the definition this app writes and reads; raised only by a breaking change. */
852
- export const DEFINITION_VERSION = 1;
853
- export const wizardSchema = z.object({
852
+ /**
853
+ * The version of the definition this app writes; raised only by a breaking change. It reads the
854
+ * earlier ones too (`upgradeDefinition`). Version 1 named the text classes one step lower: its
855
+ * `standard`, `high` and `highest` are `low`, `standard` and `high` since version 2.
856
+ */
857
+ export const DEFINITION_VERSION = 2;
858
+ const CLASSES_OF_VERSION_1 = {
859
+ standard: "low",
860
+ high: "standard",
861
+ highest: "high",
862
+ };
863
+ /**
864
+ * A definition of an earlier version, brought to this one; anything else comes back as it is.
865
+ * One without a version is of version 1, unless `unversioned` says which one its writer read:
866
+ * a model that wrote it from today's authoring guide writes today's (`DEFINITION_VERSION`).
867
+ */
868
+ export function upgradeDefinition(raw, unversioned = 1) {
869
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
870
+ return raw;
871
+ }
872
+ const def = raw;
873
+ const version = def.version ?? unversioned;
874
+ if (version === DEFINITION_VERSION) {
875
+ return def.version === undefined ? { ...def, version } : def;
876
+ }
877
+ if (version !== 1) {
878
+ return raw;
879
+ }
880
+ const steps = Array.isArray(def.steps)
881
+ ? def.steps.map((step) => {
882
+ const model = step?.model;
883
+ return typeof model === "string" && CLASSES_OF_VERSION_1[model]
884
+ ? { ...step, model: CLASSES_OF_VERSION_1[model] }
885
+ : step;
886
+ })
887
+ : def.steps;
888
+ return { ...def, version: DEFINITION_VERSION, steps };
889
+ }
890
+ /** A definition of this version, as it is written: what the JSON Schema describes. */
891
+ export const currentWizardSchema = z.object({
854
892
  version: z.literal(DEFINITION_VERSION).default(DEFINITION_VERSION),
855
893
  title: z.string().min(1),
856
894
  description: z.string().default(""),
@@ -882,6 +920,8 @@ export const wizardSchema = z.object({
882
920
  themes: z.array(z.string().regex(THEME_ID)).max(8).optional(),
883
921
  steps: z.array(stepSchema).min(1),
884
922
  });
923
+ /** A definition of any version this app reads, brought to this one. */
924
+ export const wizardSchema = z.preprocess((raw) => upgradeDefinition(raw), currentWizardSchema);
885
925
  export const INTERACTIVE = new Set(["page", "review", "result"]);
886
926
  /** Which formats each producing step can be downloaded in. */
887
927
  export function formatsFor(step) {
@@ -1982,6 +2022,7 @@ function keepsAll(given, read) {
1982
2022
  }
1983
2023
  /** True when this app's schema reads the definition without losing anything of it. */
1984
2024
  export function readable(definition) {
1985
- const parsed = wizardSchema.safeParse(definition);
1986
- return parsed.success && keepsAll(definition, parsed.data);
2025
+ const upgraded = upgradeDefinition(definition);
2026
+ const parsed = currentWizardSchema.safeParse(upgraded);
2027
+ return parsed.success && keepsAll(upgraded, parsed.data);
1987
2028
  }
@@ -27,6 +27,12 @@ export declare const FEATURES: {
27
27
  readonly label: "Account in a local install";
28
28
  readonly hint: "Linking, Settings → Account, the offer to sign in.";
29
29
  };
30
+ readonly twoWaySync: {
31
+ readonly kind: "release";
32
+ readonly default: true;
33
+ readonly label: "Two-way sync with the cloud";
34
+ readonly hint: "A local install with an account keeps its spaces in step with the organization in the cloud, both ways: wizards, knowledge, data and files.";
35
+ };
30
36
  readonly unsetConnectors: {
31
37
  readonly kind: "release";
32
38
  readonly default: false;
@@ -19,6 +19,12 @@ export const FEATURES = {
19
19
  label: "Account in a local install",
20
20
  hint: "Linking, Settings → Account, the offer to sign in.",
21
21
  },
22
+ twoWaySync: {
23
+ kind: "release",
24
+ default: true,
25
+ label: "Two-way sync with the cloud",
26
+ hint: "A local install with an account keeps its spaces in step with the organization in the cloud, both ways: wizards, knowledge, data and files.",
27
+ },
22
28
  unsetConnectors: {
23
29
  kind: "release",
24
30
  default: false,
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { DEFINITION_VERSION, wizardSchema } from "./definition.js";
2
+ import { currentWizardSchema, DEFINITION_VERSION } from "./definition.js";
3
3
  import { themeSchema } from "./theme.js";
4
4
  import { manifestSchema, PACKAGE_SCHEMA_URL, THEME_SCHEMA_URL, WIZARD_SCHEMA_URL, } from "./wizard-package.js";
5
5
  const DIALECT = "https://json-schema.org/draft/2020-12/schema";
@@ -44,7 +44,7 @@ export function wizardJsonSchema() {
44
44
  $comment: LICENSE_COMMENT,
45
45
  title: "engenty.wizards wizard definition",
46
46
  description: `A wizard's definition, version ${DEFINITION_VERSION}. Checked by \`wizards validate\`, which also checks what this schema cannot say: ids, references between steps and templates.`,
47
- ...withSchemaProperty(generate(wizardSchema)),
47
+ ...withSchemaProperty(generate(currentWizardSchema)),
48
48
  };
49
49
  }
50
50
  /** `wizard.json` in a `.wizard` package: the definition with what it needs from its project. */
@@ -62,7 +62,7 @@ export function packageJsonSchema() {
62
62
  ...properties,
63
63
  definition: { $ref: "#/$defs/definition" },
64
64
  },
65
- $defs: { definition: withSchemaProperty(generate(wizardSchema)) },
65
+ $defs: { definition: withSchemaProperty(generate(currentWizardSchema)) },
66
66
  };
67
67
  }
68
68
  /** A theme: how a wizard's pages look, values only (docs/plans/themes.md). Versioned apart from the wizard's. */
@@ -8,6 +8,43 @@ export declare const MODEL_CAPABILITIES: readonly ["text", "image", "video", "sp
8
8
  export type ModelCapability = (typeof MODEL_CAPABILITIES)[number];
9
9
  export declare const CAPABILITY_CLASSES: Record<ModelCapability, readonly ModelClass[]>;
10
10
  export declare function capabilityOf(cls: ModelClass): ModelCapability;
11
+ /**
12
+ * What a model can do, as the AI Gateway's catalog says it (its tags and context window):
13
+ * calls tools, answers in a JSON shape, reads images, reasons before it answers.
14
+ */
15
+ export interface ModelTraits {
16
+ tools: boolean;
17
+ json: boolean;
18
+ vision: boolean;
19
+ reasoning: boolean;
20
+ /** Tokens it reads at most; null where the catalog does not say. */
21
+ context: number | null;
22
+ }
23
+ /** The text classes by name, the same in every language. */
24
+ export declare const CLASS_NAMES: Record<TextClass, string>;
25
+ /** A minimum a text class asks of its model. */
26
+ export declare const MODEL_NEEDS: readonly ["tools", "json", "vision", "reasoning", "context"];
27
+ export type ModelNeed = (typeof MODEL_NEEDS)[number];
28
+ export interface ClassNeeds {
29
+ needs: Exclude<ModelNeed, "context">[];
30
+ /** Tokens the model must read at least. */
31
+ context: number;
32
+ /** Without these the class cannot work at all: a binding to a model that lacks one is refused. */
33
+ blocks: ModelNeed[];
34
+ }
35
+ /**
36
+ * What a model must be able to do to serve a text class. Classifier: decisions and values pulled
37
+ * out of text, in JSON. Low: short copy, API calls, a look at a picture or a PDF. Standard: AI
38
+ * steps with tools and pictures, and Goose. High: the build chat, which writes code and looks at
39
+ * screenshots. Goose and the build chat cannot work without tools.
40
+ */
41
+ export declare const CLASS_NEEDS: Record<TextClass, ClassNeeds>;
42
+ /** A model's traits from an AI Gateway catalog entry: its tags and context window. */
43
+ export declare function traitsOf(tags: readonly string[], context: number | null | undefined): ModelTraits;
44
+ /** What of a class's minimums a model lacks; empty where it has them all. */
45
+ export declare function missingNeeds(cls: TextClass, traits: ModelTraits): ModelNeed[];
46
+ /** Of what a model lacks, what keeps its class from working at all. */
47
+ export declare function blockingNeeds(cls: TextClass, missing: readonly ModelNeed[]): ModelNeed[];
11
48
  /**
12
49
  * A binding that sends a class to the credits of the account (or of the organization in the cloud),
13
50
  * whatever keys are there; engenty picks the model. `credits:<model>` names the model, as the
@@ -5,7 +5,7 @@ import { textOf } from "./texts.js";
5
5
  */
6
6
  export const MODEL_CAPABILITIES = ["text", "image", "video", "speech", "listening"];
7
7
  export const CAPABILITY_CLASSES = {
8
- text: ["classifier", "standard", "high", "highest"],
8
+ text: ["classifier", "low", "standard", "high"],
9
9
  image: ["image"],
10
10
  video: ["video"],
11
11
  speech: ["speech"],
@@ -14,6 +14,50 @@ export const CAPABILITY_CLASSES = {
14
14
  export function capabilityOf(cls) {
15
15
  return Object.keys(CAPABILITY_CLASSES).find((c) => CAPABILITY_CLASSES[c].includes(cls));
16
16
  }
17
+ /** The text classes by name, the same in every language. */
18
+ export const CLASS_NAMES = {
19
+ classifier: "Classifier",
20
+ low: "Low",
21
+ standard: "Standard",
22
+ high: "High",
23
+ };
24
+ /** A minimum a text class asks of its model. */
25
+ export const MODEL_NEEDS = ["tools", "json", "vision", "reasoning", "context"];
26
+ /**
27
+ * What a model must be able to do to serve a text class. Classifier: decisions and values pulled
28
+ * out of text, in JSON. Low: short copy, API calls, a look at a picture or a PDF. Standard: AI
29
+ * steps with tools and pictures, and Goose. High: the build chat, which writes code and looks at
30
+ * screenshots. Goose and the build chat cannot work without tools.
31
+ */
32
+ export const CLASS_NEEDS = {
33
+ classifier: { needs: ["json"], context: 32_000, blocks: [] },
34
+ low: { needs: ["tools", "json", "vision"], context: 64_000, blocks: [] },
35
+ standard: { needs: ["tools", "json", "vision"], context: 128_000, blocks: ["tools"] },
36
+ high: { needs: ["tools", "json", "vision", "reasoning"], context: 200_000, blocks: ["tools"] },
37
+ };
38
+ /** A model's traits from an AI Gateway catalog entry: its tags and context window. */
39
+ export function traitsOf(tags, context) {
40
+ return {
41
+ tools: tags.includes("tool-use"),
42
+ json: tags.includes("structured-output"),
43
+ vision: tags.includes("vision"),
44
+ reasoning: tags.includes("reasoning"),
45
+ context: typeof context === "number" && context > 0 ? context : null,
46
+ };
47
+ }
48
+ /** What of a class's minimums a model lacks; empty where it has them all. */
49
+ export function missingNeeds(cls, traits) {
50
+ const want = CLASS_NEEDS[cls];
51
+ const missing = want.needs.filter((need) => !traits[need]);
52
+ if (traits.context !== null && traits.context < want.context) {
53
+ missing.push("context");
54
+ }
55
+ return missing;
56
+ }
57
+ /** Of what a model lacks, what keeps its class from working at all. */
58
+ export function blockingNeeds(cls, missing) {
59
+ return missing.filter((need) => CLASS_NEEDS[cls].blocks.includes(need));
60
+ }
17
61
  /**
18
62
  * A binding that sends a class to the credits of the account (or of the organization in the cloud),
19
63
  * whatever keys are there; engenty picks the model. `credits:<model>` names the model, as the
@@ -107,9 +151,9 @@ export const PROVIDERS = [
107
151
  keyPlaceholder: "sk-…",
108
152
  text: {
109
153
  classifier: "openai:gpt-5.4-mini",
110
- standard: "openai:gpt-5.4-mini",
154
+ low: "openai:gpt-5.4-mini",
155
+ standard: "openai:gpt-5.5",
111
156
  high: "openai:gpt-5.5",
112
- highest: "openai:gpt-5.5",
113
157
  },
114
158
  models: {
115
159
  text: [
@@ -149,9 +193,9 @@ export const PROVIDERS = [
149
193
  keyPlaceholder: "sk-ant-…",
150
194
  text: {
151
195
  classifier: "anthropic:claude-haiku-4-5",
152
- standard: "anthropic:claude-haiku-4-5",
153
- high: "anthropic:claude-sonnet-5-5",
154
- highest: "anthropic:claude-opus-5-5",
196
+ low: "anthropic:claude-haiku-4-5",
197
+ standard: "anthropic:claude-sonnet-5-5",
198
+ high: "anthropic:claude-opus-5-5",
155
199
  },
156
200
  models: {
157
201
  text: [
@@ -177,9 +221,9 @@ export const PROVIDERS = [
177
221
  keyPlaceholder: "AIza…",
178
222
  text: {
179
223
  classifier: "google:gemini-flash-lite-latest",
180
- standard: "google:gemini-flash-latest",
224
+ low: "google:gemini-flash-latest",
225
+ standard: "google:gemini-pro-latest",
181
226
  high: "google:gemini-pro-latest",
182
- highest: "google:gemini-pro-latest",
183
227
  },
184
228
  models: {
185
229
  text: [
@@ -329,14 +373,22 @@ export const PROVIDERS = [
329
373
  about: "about.gateway",
330
374
  keyUrl: "https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway%2Fapi-keys",
331
375
  keyPlaceholder: "vck_…",
376
+ // Economical models that meet each class's minimums (CLASS_NEEDS).
332
377
  text: {
333
- classifier: "anthropic/claude-haiku-4.5",
334
- standard: "anthropic/claude-haiku-4.5",
335
- high: "anthropic/claude-sonnet-5.5",
336
- highest: "anthropic/claude-sonnet-5.5",
378
+ classifier: "deepseek/deepseek-v4.1-flash",
379
+ low: "deepseek/deepseek-v4.1-flash",
380
+ standard: "deepseek/deepseek-v4.1-flash",
381
+ high: "moonshotai/kimi-k3",
337
382
  },
338
383
  models: {
339
384
  text: [
385
+ {
386
+ ref: "deepseek/deepseek-v4.1-flash",
387
+ label: "DeepSeek V4.1 Flash",
388
+ note: "fastLowCost",
389
+ },
390
+ { ref: "moonshotai/kimi-k3", label: "Kimi K3" },
391
+ { ref: "zai/glm-5.3", label: "GLM 5.3" },
340
392
  {
341
393
  ref: "anthropic/claude-haiku-4.5",
342
394
  label: "Claude Haiku 4.5",
@@ -428,6 +428,12 @@ declare const NOTES_EN: {
428
428
  };
429
429
  readonly accountSignedOut: "The account is signed out. Sign in again.";
430
430
  readonly cloudNotReachedRight: "The cloud can’t be reached right now.";
431
+ readonly syncUpdateHere: "The cloud runs a newer version than this computer. Update engenty wizards, then your changes arrive in the cloud again.";
432
+ readonly syncUpdateCloud: "This computer runs a newer version than the cloud. Your changes arrive there once the cloud is updated.";
433
+ readonly syncSpaceNotInCloud: "This space isn’t in the cloud.";
434
+ readonly syncOtherSpace: "In the cloud this belongs to another space.";
435
+ readonly syncChangeRefused: "The cloud doesn’t take this change: {detail}";
436
+ readonly syncFileMissing: "A file of this change hasn’t arrived in the cloud yet. It’s sent again.";
431
437
  readonly publishWizardFirst: "Publish the wizard first.";
432
438
  readonly wizardJsonUnreadable: "This isn’t a wizard file: its wizard.json can’t be read.";
433
439
  readonly wizardFileComesNewer: "This wizard file comes from a newer version, or it’s damaged. Update engenty wizards or export the wizard again.";
@@ -257,6 +257,12 @@ const NOTES_EN = {
257
257
  },
258
258
  accountSignedOut: "The account is signed out. Sign in again.",
259
259
  cloudNotReachedRight: "The cloud can’t be reached right now.",
260
+ syncUpdateHere: "The cloud runs a newer version than this computer. Update engenty wizards, then your changes arrive in the cloud again.",
261
+ syncUpdateCloud: "This computer runs a newer version than the cloud. Your changes arrive there once the cloud is updated.",
262
+ syncSpaceNotInCloud: "This space isn’t in the cloud.",
263
+ syncOtherSpace: "In the cloud this belongs to another space.",
264
+ syncChangeRefused: "The cloud doesn’t take this change: {detail}",
265
+ syncFileMissing: "A file of this change hasn’t arrived in the cloud yet. It’s sent again.",
260
266
  publishWizardFirst: "Publish the wizard first.",
261
267
  wizardJsonUnreadable: "This isn’t a wizard file: its wizard.json can’t be read.",
262
268
  wizardFileComesNewer: "This wizard file comes from a newer version, or it’s damaged. Update engenty wizards or export the wizard again.",
@@ -560,6 +566,12 @@ const NOTES_DE = {
560
566
  },
561
567
  accountSignedOut: "Das Konto ist abgemeldet. Melde dich neu an.",
562
568
  cloudNotReachedRight: "Die Cloud ist gerade nicht erreichbar.",
569
+ syncUpdateHere: "Die Cloud hat eine neuere Version als dieser Computer. Aktualisiere engenty wizards, dann kommen deine Änderungen wieder in der Cloud an.",
570
+ syncUpdateCloud: "Dieser Computer hat eine neuere Version als die Cloud. Deine Änderungen kommen dort an, sobald die Cloud aktualisiert ist.",
571
+ syncSpaceNotInCloud: "Diesen Space gibt es in der Cloud nicht.",
572
+ syncOtherSpace: "In der Cloud gehört das zu einem anderen Space.",
573
+ syncChangeRefused: "Diese Änderung nimmt die Cloud nicht an: {detail}",
574
+ syncFileMissing: "Eine Datei dieser Änderung ist noch nicht in der Cloud angekommen. Sie wird noch einmal gesendet.",
563
575
  publishWizardFirst: "Veröffentliche den Wizard zuerst.",
564
576
  wizardJsonUnreadable: "Das ist keine Wizard-Datei: Die wizard.json darin lässt sich nicht lesen.",
565
577
  wizardFileComesNewer: "Diese Wizard-Datei stammt aus einer neueren Version oder ist beschädigt. Aktualisiere engenty wizards oder exportiere den Wizard neu.",
@@ -0,0 +1,55 @@
1
+ /**
2
+ * A three-way merge of JSON, for what syncs between an install and the cloud
3
+ * (docs/plans/tenant-sync.md): a wizard's definition, a page, a row, the space's details.
4
+ * Objects merge key by key; a list of items that each carry an `id` merges item by item, its
5
+ * order taken from the side that changed it; text that both sides changed merges line by line.
6
+ * Everything else is one value: changed on one side, that side's; changed on both to different
7
+ * values, a conflict, named by where it is. Unlike `mergeDrafts` (merge.ts), which lets the
8
+ * studio's side win, this one says what it could not settle.
9
+ */
10
+ /** A step on the way to a value: a key of an object, or the item of a list with that `id`. */
11
+ export type MergePathPart = string | {
12
+ id: string;
13
+ };
14
+ export type MergePath = MergePathPart[];
15
+ export interface MergeConflict {
16
+ path: MergePath;
17
+ /**
18
+ * `value`: both changed it differently. `removed`: one side removed an item the other changed
19
+ * (the removed side's value is `undefined`). `order`: both reordered a list differently; the
20
+ * values are the lists of ids.
21
+ */
22
+ kind: "value" | "removed" | "order";
23
+ base: unknown;
24
+ local: unknown;
25
+ remote: unknown;
26
+ }
27
+ export interface JsonMerge<T> {
28
+ /** The merge; at a conflict it holds the local side. */
29
+ value: T;
30
+ conflicts: MergeConflict[];
31
+ }
32
+ export declare function mergeJson<T>(base: T, local: T, remote: T): JsonMerge<T>;
33
+ /** What the person chose for one conflict: a side, or a value of their own. */
34
+ export type MergeChoice = {
35
+ take: "local" | "remote";
36
+ } | {
37
+ value: unknown;
38
+ };
39
+ /** The value at `path`, or `undefined`. */
40
+ export declare function valueAt(root: unknown, path: MergePath): unknown;
41
+ /**
42
+ * `root` with `value` at `path` (`undefined` removes it). An item that is not in its list goes
43
+ * where it stands in `hint`, the side it came from.
44
+ */
45
+ export declare function withValueAt(root: unknown, path: MergePath, value: unknown, hint?: unknown): unknown;
46
+ /**
47
+ * The merge with each conflict settled as chosen, in order. A conflict without a choice keeps
48
+ * the local side, which the merge already holds.
49
+ */
50
+ export declare function settleConflicts<T>(merged: T, conflicts: MergeConflict[], choices: (MergeChoice | null | undefined)[], sides: {
51
+ local: T;
52
+ remote: T;
53
+ }): T;
54
+ /** A path as people read it, given the names of its items: `Steps › “File the report” › title`. */
55
+ export declare function pathLabel(path: MergePath, root: unknown, nameOf?: (item: unknown) => string | null): string;
@@ -0,0 +1,214 @@
1
+ import { mergeText } from "./text-merge.js";
2
+ const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
3
+ const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
4
+ const idOf = (v) => (isObject(v) && typeof v.id === "string" ? v.id : null);
5
+ const keyed = (v) => Array.isArray(v) && v.every((x) => idOf(x) !== null) && new Set(v.map(idOf)).size === v.length;
6
+ const multiline = (...values) => values.every((v) => typeof v === "string") && values.some((v) => v.includes("\n"));
7
+ export function mergeJson(base, local, remote) {
8
+ const conflicts = [];
9
+ const value = merge(base, local, remote, [], conflicts);
10
+ return { value, conflicts };
11
+ }
12
+ function merge(base, local, remote, path, conflicts) {
13
+ if (same(local, remote)) {
14
+ return local;
15
+ }
16
+ if (same(base, local)) {
17
+ return remote;
18
+ }
19
+ if (same(base, remote)) {
20
+ return local;
21
+ }
22
+ if (isObject(local) && isObject(remote)) {
23
+ const b = isObject(base) ? base : {};
24
+ const out = {};
25
+ // The local side's key order, then keys only the remote side has.
26
+ for (const key of new Set([...Object.keys(local), ...Object.keys(remote), ...Object.keys(b)])) {
27
+ const v = merge(b[key], local[key], remote[key], [...path, key], conflicts);
28
+ if (v !== undefined) {
29
+ out[key] = v;
30
+ }
31
+ }
32
+ return out;
33
+ }
34
+ if (keyed(local) && keyed(remote) && (base === undefined || keyed(base))) {
35
+ return mergeList(base ?? [], local, remote, path, conflicts);
36
+ }
37
+ if (multiline(base ?? "", local, remote)) {
38
+ const text = mergeText(base ?? "", local, remote);
39
+ if (text.clean) {
40
+ return text.text;
41
+ }
42
+ }
43
+ conflicts.push({ path, kind: "value", base, local, remote });
44
+ return local;
45
+ }
46
+ function mergeList(base, local, remote, path, conflicts) {
47
+ const by = (list) => new Map(list.map((x) => [idOf(x), x]));
48
+ const [B, L, R] = [by(base), by(local), by(remote)];
49
+ const items = new Map();
50
+ for (const id of new Set([...L.keys(), ...R.keys(), ...B.keys()])) {
51
+ const [b, l, r] = [B.get(id), L.get(id), R.get(id)];
52
+ const at = [...path, { id }];
53
+ if (b !== undefined && (l === undefined || r === undefined)) {
54
+ // Removed on one side: gone, unless the other side changed it meanwhile.
55
+ const kept = l ?? r;
56
+ if (kept !== undefined && !same(kept, b)) {
57
+ conflicts.push({ path: at, kind: "removed", base: b, local: l, remote: r });
58
+ if (l !== undefined) {
59
+ items.set(id, l);
60
+ }
61
+ }
62
+ continue;
63
+ }
64
+ const v = merge(b, l, r, at, conflicts);
65
+ if (v !== undefined) {
66
+ items.set(id, v);
67
+ }
68
+ }
69
+ // The order: of the items all three have, the side that moved them wins.
70
+ const common = (list) => list.map((x) => idOf(x)).filter((id) => B.has(id) && L.has(id) && R.has(id));
71
+ const [ob, ol, or] = [common(base), common(local), common(remote)];
72
+ const localMoved = !same(ob, ol);
73
+ const remoteMoved = !same(ob, or);
74
+ if (localMoved && remoteMoved && !same(ol, or)) {
75
+ conflicts.push({ path, kind: "order", base: ob, local: ol, remote: or });
76
+ }
77
+ const order = (remoteMoved && !localMoved ? remote : local).map((x) => idOf(x));
78
+ // Items the chosen order lacks: after the item they follow on their own side, and after what
79
+ // the other side added there (the local side's additions come first).
80
+ for (const side of [local, remote]) {
81
+ const own = new Set(side.map((x) => idOf(x)));
82
+ side.forEach((x, i) => {
83
+ const id = idOf(x);
84
+ if (order.includes(id)) {
85
+ return;
86
+ }
87
+ const before = side
88
+ .slice(0, i)
89
+ .reverse()
90
+ .find((p) => order.includes(idOf(p)));
91
+ let at = before ? order.indexOf(idOf(before)) + 1 : 0;
92
+ while (at < order.length && !B.has(order[at]) && !own.has(order[at])) {
93
+ at++;
94
+ }
95
+ order.splice(at, 0, id);
96
+ });
97
+ }
98
+ return order.filter((id) => items.has(id)).map((id) => items.get(id));
99
+ }
100
+ /** The value at `path`, or `undefined`. */
101
+ export function valueAt(root, path) {
102
+ let at = root;
103
+ for (const part of path) {
104
+ if (typeof part === "string") {
105
+ at = isObject(at) ? at[part] : undefined;
106
+ }
107
+ else {
108
+ at = Array.isArray(at) ? at.find((x) => idOf(x) === part.id) : undefined;
109
+ }
110
+ }
111
+ return at;
112
+ }
113
+ /**
114
+ * `root` with `value` at `path` (`undefined` removes it). An item that is not in its list goes
115
+ * where it stands in `hint`, the side it came from.
116
+ */
117
+ export function withValueAt(root, path, value, hint) {
118
+ if (!path.length) {
119
+ return value;
120
+ }
121
+ const [part, ...rest] = path;
122
+ if (typeof part === "string") {
123
+ const obj = isObject(root) ? { ...root } : {};
124
+ const next = withValueAt(obj[part], rest, value, valueAt(hint, [part]));
125
+ if (next === undefined) {
126
+ delete obj[part];
127
+ }
128
+ else {
129
+ obj[part] = next;
130
+ }
131
+ return obj;
132
+ }
133
+ const list = Array.isArray(root) ? [...root] : [];
134
+ const at = list.findIndex((x) => idOf(x) === part.id);
135
+ const hintList = Array.isArray(hint) ? hint : [];
136
+ const next = withValueAt(at === -1 ? undefined : list[at], rest, value, hintList.find((x) => idOf(x) === part.id));
137
+ if (at !== -1) {
138
+ if (next === undefined) {
139
+ list.splice(at, 1);
140
+ }
141
+ else {
142
+ list[at] = next;
143
+ }
144
+ return list;
145
+ }
146
+ if (next === undefined) {
147
+ return list;
148
+ }
149
+ // Where it stands on its own side: after the item it follows there.
150
+ const i = hintList.findIndex((x) => idOf(x) === part.id);
151
+ const before = hintList
152
+ .slice(0, Math.max(0, i))
153
+ .reverse()
154
+ .map(idOf)
155
+ .find((id) => list.some((x) => idOf(x) === id));
156
+ list.splice(before ? list.findIndex((x) => idOf(x) === before) + 1 : 0, 0, next);
157
+ return list;
158
+ }
159
+ /** A list in the order of `ids`; items not named keep their place after the one they follow. */
160
+ function reordered(list, ids) {
161
+ if (!Array.isArray(list)) {
162
+ return list;
163
+ }
164
+ const named = ids.map((id) => list.find((x) => idOf(x) === id)).filter((x) => x !== undefined);
165
+ const rest = list.filter((x) => !ids.includes(idOf(x) ?? ""));
166
+ const out = [...named];
167
+ for (const x of rest) {
168
+ const i = list.indexOf(x);
169
+ const before = list
170
+ .slice(0, i)
171
+ .reverse()
172
+ .find((p) => out.includes(p));
173
+ out.splice(before ? out.indexOf(before) + 1 : 0, 0, x);
174
+ }
175
+ return out;
176
+ }
177
+ /**
178
+ * The merge with each conflict settled as chosen, in order. A conflict without a choice keeps
179
+ * the local side, which the merge already holds.
180
+ */
181
+ export function settleConflicts(merged, conflicts, choices, sides) {
182
+ let out = merged;
183
+ conflicts.forEach((c, i) => {
184
+ const choice = choices[i];
185
+ if (!choice) {
186
+ return;
187
+ }
188
+ const pick = "take" in choice ? (choice.take === "local" ? c.local : c.remote) : choice.value;
189
+ const from = "take" in choice ? (choice.take === "local" ? sides.local : sides.remote) : merged;
190
+ if (c.kind === "order") {
191
+ out = withValueAt(out, c.path, reordered(valueAt(out, c.path), pick));
192
+ return;
193
+ }
194
+ out = withValueAt(out, c.path, pick, from);
195
+ });
196
+ return out;
197
+ }
198
+ /** A path as people read it, given the names of its items: `Steps › “File the report” › title`. */
199
+ export function pathLabel(path, root, nameOf) {
200
+ const parts = [];
201
+ let at = root;
202
+ for (const part of path) {
203
+ if (typeof part === "string") {
204
+ parts.push(part);
205
+ at = isObject(at) ? at[part] : undefined;
206
+ }
207
+ else {
208
+ at = Array.isArray(at) ? at.find((x) => idOf(x) === part.id) : undefined;
209
+ const name = (at !== undefined && nameOf?.(at)) || part.id;
210
+ parts.push(`“${name}”`);
211
+ }
212
+ }
213
+ return parts.join(" › ");
214
+ }