wizards 0.5.12 → 0.6.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 (89) hide show
  1. package/apps/runtime/dist/authoring/guide.js +63 -7
  2. package/apps/runtime/dist/credits/estimate.js +1 -1
  3. package/apps/runtime/dist/db/control-schema.js +10 -0
  4. package/apps/runtime/dist/db/migrations/control/0010_tan_snowbird.sql +6 -0
  5. package/apps/runtime/dist/db/migrations/control/meta/0010_snapshot.json +600 -0
  6. package/apps/runtime/dist/db/migrations/control/meta/_journal.json +7 -0
  7. package/apps/runtime/dist/db/migrations/tenant/0016_even_trish_tilby.sql +12 -0
  8. package/apps/runtime/dist/db/migrations/tenant/meta/0016_snapshot.json +3326 -0
  9. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  10. package/apps/runtime/dist/db/schema.js +20 -0
  11. package/apps/runtime/dist/engine/requirements.js +1 -1
  12. package/apps/runtime/dist/engine/runner.js +72 -7
  13. package/apps/runtime/dist/engine/steps.js +169 -126
  14. package/apps/runtime/dist/model-errors.js +20 -7
  15. package/apps/runtime/dist/render/downloads.js +16 -3
  16. package/apps/runtime/dist/render/shaped.js +137 -0
  17. package/apps/runtime/dist/routes/runs.js +228 -25
  18. package/apps/runtime/dist/routes/studio.js +41 -3
  19. package/apps/runtime/dist/services/brand.js +2 -1
  20. package/apps/runtime/dist/services/cloud.js +1 -0
  21. package/apps/runtime/dist/services/spaces.js +1 -0
  22. package/apps/runtime/dist/services/translations.js +303 -0
  23. package/apps/runtime/dist/services/wizards.js +3 -1
  24. package/apps/runtime/dist/texts.js +2 -0
  25. package/apps/runtime/dist/widgets/runtime.js +25 -2
  26. package/apps/runtime/dist/widgets/step.js +2 -0
  27. package/apps/web/dist/assets/AboutDialog-xOyf_juP.js +1 -0
  28. package/apps/web/dist/assets/{ChangelogDialog-BZ8i3wt_.js → ChangelogDialog-vNG0Smoo.js} +1 -1
  29. package/apps/web/dist/assets/ChatView-BrDkurRe.js +10 -0
  30. package/apps/web/dist/assets/EditorPage-97U-JYKn.js +3 -0
  31. package/apps/web/dist/assets/{FlowPreview-DG23aI89.js → FlowPreview-DA0sHtr7.js} +1 -1
  32. package/apps/web/dist/assets/{Harness-CFh04TZ3.js → Harness-Y9E7o83r.js} +2 -2
  33. package/apps/web/dist/assets/{NewWizardChannels-Bmo5yRCv.js → NewWizardChannels-D6v1iDOo.js} +1 -1
  34. package/apps/web/dist/assets/NewWizardPage-BzaAPMUK.js +7 -0
  35. package/apps/web/dist/assets/OnboardingPage-9xZAkhuO.js +1 -0
  36. package/apps/web/dist/assets/ProjectPage-dQ7wwxD2.js +1 -0
  37. package/apps/web/dist/assets/PublicRunner-CKa8M0Qd.js +1 -0
  38. package/apps/web/dist/assets/{ReadOnly-C_jD7KjW.js → ReadOnly-Bqk14yPD.js} +1 -1
  39. package/apps/web/dist/assets/RunDrawer-DsfZUojZ.js +4 -0
  40. package/apps/web/dist/assets/RunnerView-D0JQ1fgM.js +1 -0
  41. package/apps/web/dist/assets/SettingsPage-Dzu6Fl6b.js +1 -0
  42. package/apps/web/dist/assets/SetupPage-D2Kl-8NR.js +1 -0
  43. package/apps/web/dist/assets/SharePage-QSZxUlPt.js +1 -0
  44. package/apps/web/dist/assets/changelog-XlAAw5Gv.js +1 -0
  45. package/apps/web/dist/assets/{esm-Dzqe3TT4.js → esm-DqRvG-PU.js} +1 -1
  46. package/apps/web/dist/assets/index-BhVJwBz7.css +1 -0
  47. package/apps/web/dist/assets/index-mwmrgVFT.js +14 -0
  48. package/apps/web/dist/assets/{lock-a8rDnyg5.js → lock-D_KjsGfU.js} +1 -1
  49. package/apps/web/dist/assets/{phone-CitA6oZn.js → phone-YRxkPQk6.js} +1 -1
  50. package/apps/web/dist/assets/{settings-menu-COgM8CgB.js → settings-menu-CQgehwEX.js} +1 -1
  51. package/apps/web/dist/assets/ui-DDUCc_4v.js +137 -0
  52. package/apps/web/dist/assets/{upload-CcKFwoPd.js → upload-DDo14e2p.js} +1 -1
  53. package/apps/web/dist/index.html +3 -3
  54. package/apps/web/dist/mcp/flow.html +58 -55
  55. package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +5 -2
  56. package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +206 -3
  57. package/node_modules/@engenty-wizards/shared/dist/definition.js +140 -18
  58. package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +11 -0
  59. package/node_modules/@engenty-wizards/shared/dist/projects.js +54 -0
  60. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +68 -4
  61. package/node_modules/@engenty-wizards/shared/dist/run.js +26 -8
  62. package/node_modules/@engenty-wizards/shared/dist/runner-texts.d.ts +546 -0
  63. package/node_modules/@engenty-wizards/shared/dist/runner-texts.js +523 -0
  64. package/node_modules/@engenty-wizards/shared/dist/runners.js +1 -1
  65. package/node_modules/@engenty-wizards/shared/dist/shape.d.ts +102 -0
  66. package/node_modules/@engenty-wizards/shared/dist/shape.js +318 -0
  67. package/node_modules/@engenty-wizards/shared/dist/surface.d.ts +33 -7
  68. package/node_modules/@engenty-wizards/shared/dist/surface.js +263 -20
  69. package/node_modules/@engenty-wizards/shared/dist/texts.d.ts +11 -2
  70. package/node_modules/@engenty-wizards/shared/dist/texts.js +16 -8
  71. package/node_modules/@engenty-wizards/shared/dist/translation.d.ts +23 -0
  72. package/node_modules/@engenty-wizards/shared/dist/translation.js +154 -0
  73. package/package.json +1 -1
  74. package/apps/web/dist/assets/AboutDialog-DvkE9J4h.js +0 -1
  75. package/apps/web/dist/assets/ChatView-DIDIR0mb.js +0 -10
  76. package/apps/web/dist/assets/EditorPage-BYysznX3.js +0 -3
  77. package/apps/web/dist/assets/NewWizardPage-4n9-ZmHt.js +0 -7
  78. package/apps/web/dist/assets/OnboardingPage-DpZv9qEO.js +0 -1
  79. package/apps/web/dist/assets/ProjectPage-IQb9RFlm.js +0 -1
  80. package/apps/web/dist/assets/PublicRunner-Da0klKj-.js +0 -1
  81. package/apps/web/dist/assets/RunDrawer-FwLK67Yn.js +0 -4
  82. package/apps/web/dist/assets/RunnerView-BBuphCkK.js +0 -1
  83. package/apps/web/dist/assets/SettingsPage-CZx52Ubk.js +0 -1
  84. package/apps/web/dist/assets/SetupPage-B-o7VhbI.js +0 -1
  85. package/apps/web/dist/assets/SharePage-k2OMGOWU.js +0 -1
  86. package/apps/web/dist/assets/changelog-9oSWVuP-.js +0 -1
  87. package/apps/web/dist/assets/index-93fPRTxr.js +0 -14
  88. package/apps/web/dist/assets/index-DaKjB676.css +0 -1
  89. package/apps/web/dist/assets/ui-CeZNNuaK.js +0 -134
@@ -793,10 +793,13 @@ export interface PluginRunner {
793
793
  token: string;
794
794
  }): PluginRunnerAddress | null | Promise<PluginRunnerAddress | null>;
795
795
  }
796
- /** How a run answers a review: accept it, with edited texts where the review allows, or ask for one of the shown steps again. */
796
+ /**
797
+ * How a run answers a review: accept it, with edits where the review allows (a text, or the
798
+ * data of a json step), or ask for one of the shown steps again.
799
+ */
797
800
  export type PluginReviewAction = {
798
801
  type: "accept";
799
- edits?: Record<string, string>;
802
+ edits?: Record<string, string | Record<string, unknown>>;
800
803
  } | {
801
804
  type: "regenerate";
802
805
  target: string;
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { type ObjectShape } from "./shape.js";
2
3
  import { type SurfaceComponent } from "./surface.js";
3
4
  /** The engenty avatars a wizard can wear. Same cast as engenty's ui-core. */
4
5
  export declare const ENGENTY_KINDS: readonly ["round", "drop", "dome", "flame", "oval", "bean", "pebble", "sprout", "tower", "wedge"];
@@ -25,6 +26,25 @@ export declare function langOf(tag: string | null | undefined): Lang | null;
25
26
  * in; null where neither names one.
26
27
  */
27
28
  export declare function localLang(languages: readonly string[], timeZone?: string | null): Lang | null;
29
+ /**
30
+ * A language a wizard can be translated into: any language, by its two- or three-letter code
31
+ * ("fr", "it", "pl"), not only those of `LANGS`.
32
+ */
33
+ export declare const LANG_CODE: RegExp;
34
+ /** The code of a tag such as "fr-CA" or "pt_BR"; null where it names no language. */
35
+ export declare function langCodeOf(tag: string | null | undefined): string | null;
36
+ /**
37
+ * The language the person reads, for a wizard translated on request: the first of their
38
+ * languages (the browser's, in its order), else the main language of the country their time
39
+ * zone lies in. Any language, not only one engenty's own strings are written in.
40
+ */
41
+ export declare function viewerLang(languages: readonly string[], timeZone?: string | null): string | null;
42
+ /** A language's name in that language, as a switch shows it: "Italiano", "Polski". */
43
+ export declare function langName(code: string): string;
44
+ /** A language's name in English, for a model told what to write in: "Italian". */
45
+ export declare function langNameEn(code: string): string;
46
+ /** The locale amounts, dates and plural forms are written in for any language. */
47
+ export declare function localeOf(code: string): string;
28
48
  export declare const FIELD_KINDS: readonly ["text", "textarea", "number", "select", "multiselect", "date", "email", "url", "toggle", "color", "image", "file", "items", "connection", "list", "location", "audio", "signature", "slot"];
29
49
  export type FieldKind = (typeof FIELD_KINDS)[number];
30
50
  /**
@@ -528,7 +548,40 @@ export declare const agentStepSchema: z.ZodObject<{
528
548
  columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
529
549
  options: z.ZodOptional<z.ZodArray<z.ZodString>>;
530
550
  }, z.core.$strip>>>;
531
- surface: z.ZodOptional<z.ZodBoolean>;
551
+ schema: z.ZodOptional<z.ZodType<ObjectShape, unknown, z.core.$ZodTypeInternals<ObjectShape, unknown>>>;
552
+ surface: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodObject<{
553
+ id: z.ZodString;
554
+ component: z.ZodEnum<{
555
+ Actions: "Actions";
556
+ Badge: "Badge";
557
+ BarChart: "BarChart";
558
+ Button: "Button";
559
+ Callout: "Callout";
560
+ Card: "Card";
561
+ Checklist: "Checklist";
562
+ Chips: "Chips";
563
+ Column: "Column";
564
+ DetailGrid: "DetailGrid";
565
+ DonutChart: "DonutChart";
566
+ Fold: "Fold";
567
+ Grid: "Grid";
568
+ Group: "Group";
569
+ Image: "Image";
570
+ LineChart: "LineChart";
571
+ Link: "Link";
572
+ List: "List";
573
+ Metric: "Metric";
574
+ Row: "Row";
575
+ Steps: "Steps";
576
+ Table: "Table";
577
+ Tabs: "Tabs";
578
+ Text: "Text";
579
+ }>;
580
+ children: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
581
+ path: z.ZodString;
582
+ componentId: z.ZodString;
583
+ }, z.core.$strip>]>>;
584
+ }, z.core.$loose>>]>>;
532
585
  }, z.core.$strip>>;
533
586
  model: z.ZodOptional<z.ZodEnum<{
534
587
  classifier: "classifier";
@@ -668,6 +721,10 @@ export declare const widgetStepSchema: z.ZodObject<{
668
721
  entry: z.ZodString;
669
722
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
670
723
  sample: z.ZodOptional<z.ZodString>;
724
+ layout: z.ZodOptional<z.ZodEnum<{
725
+ fixed: "fixed";
726
+ page: "page";
727
+ }>>;
671
728
  size: z.ZodOptional<z.ZodObject<{
672
729
  width: z.ZodNumber;
673
730
  height: z.ZodNumber;
@@ -758,16 +815,25 @@ export declare const surfaceCandidateSchema: z.ZodObject<{
758
815
  Badge: "Badge";
759
816
  BarChart: "BarChart";
760
817
  Button: "Button";
818
+ Callout: "Callout";
819
+ Card: "Card";
820
+ Checklist: "Checklist";
821
+ Chips: "Chips";
761
822
  Column: "Column";
762
823
  DetailGrid: "DetailGrid";
763
824
  DonutChart: "DonutChart";
825
+ Fold: "Fold";
764
826
  Grid: "Grid";
827
+ Group: "Group";
765
828
  Image: "Image";
766
829
  LineChart: "LineChart";
830
+ Link: "Link";
767
831
  List: "List";
768
832
  Metric: "Metric";
769
833
  Row: "Row";
834
+ Steps: "Steps";
770
835
  Table: "Table";
836
+ Tabs: "Tabs";
771
837
  Text: "Text";
772
838
  }>;
773
839
  children: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
@@ -822,16 +888,25 @@ export declare const surfaceStepSchema: z.ZodObject<{
822
888
  Badge: "Badge";
823
889
  BarChart: "BarChart";
824
890
  Button: "Button";
891
+ Callout: "Callout";
892
+ Card: "Card";
893
+ Checklist: "Checklist";
894
+ Chips: "Chips";
825
895
  Column: "Column";
826
896
  DetailGrid: "DetailGrid";
827
897
  DonutChart: "DonutChart";
898
+ Fold: "Fold";
828
899
  Grid: "Grid";
900
+ Group: "Group";
829
901
  Image: "Image";
830
902
  LineChart: "LineChart";
903
+ Link: "Link";
831
904
  List: "List";
832
905
  Metric: "Metric";
833
906
  Row: "Row";
907
+ Steps: "Steps";
834
908
  Table: "Table";
909
+ Tabs: "Tabs";
835
910
  Text: "Text";
836
911
  }>;
837
912
  children: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
@@ -849,16 +924,25 @@ export declare const surfaceStepSchema: z.ZodObject<{
849
924
  Badge: "Badge";
850
925
  BarChart: "BarChart";
851
926
  Button: "Button";
927
+ Callout: "Callout";
928
+ Card: "Card";
929
+ Checklist: "Checklist";
930
+ Chips: "Chips";
852
931
  Column: "Column";
853
932
  DetailGrid: "DetailGrid";
854
933
  DonutChart: "DonutChart";
934
+ Fold: "Fold";
855
935
  Grid: "Grid";
936
+ Group: "Group";
856
937
  Image: "Image";
857
938
  LineChart: "LineChart";
939
+ Link: "Link";
858
940
  List: "List";
859
941
  Metric: "Metric";
860
942
  Row: "Row";
943
+ Steps: "Steps";
861
944
  Table: "Table";
945
+ Tabs: "Tabs";
862
946
  Text: "Text";
863
947
  }>;
864
948
  children: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
@@ -1210,7 +1294,40 @@ export declare const stepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1210
1294
  columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
1211
1295
  options: z.ZodOptional<z.ZodArray<z.ZodString>>;
1212
1296
  }, z.core.$strip>>>;
1213
- surface: z.ZodOptional<z.ZodBoolean>;
1297
+ schema: z.ZodOptional<z.ZodType<ObjectShape, unknown, z.core.$ZodTypeInternals<ObjectShape, unknown>>>;
1298
+ surface: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodObject<{
1299
+ id: z.ZodString;
1300
+ component: z.ZodEnum<{
1301
+ Actions: "Actions";
1302
+ Badge: "Badge";
1303
+ BarChart: "BarChart";
1304
+ Button: "Button";
1305
+ Callout: "Callout";
1306
+ Card: "Card";
1307
+ Checklist: "Checklist";
1308
+ Chips: "Chips";
1309
+ Column: "Column";
1310
+ DetailGrid: "DetailGrid";
1311
+ DonutChart: "DonutChart";
1312
+ Fold: "Fold";
1313
+ Grid: "Grid";
1314
+ Group: "Group";
1315
+ Image: "Image";
1316
+ LineChart: "LineChart";
1317
+ Link: "Link";
1318
+ List: "List";
1319
+ Metric: "Metric";
1320
+ Row: "Row";
1321
+ Steps: "Steps";
1322
+ Table: "Table";
1323
+ Tabs: "Tabs";
1324
+ Text: "Text";
1325
+ }>;
1326
+ children: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
1327
+ path: z.ZodString;
1328
+ componentId: z.ZodString;
1329
+ }, z.core.$strip>]>>;
1330
+ }, z.core.$loose>>]>>;
1214
1331
  }, z.core.$strip>>;
1215
1332
  model: z.ZodOptional<z.ZodEnum<{
1216
1333
  classifier: "classifier";
@@ -1348,6 +1465,10 @@ export declare const stepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1348
1465
  entry: z.ZodString;
1349
1466
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
1350
1467
  sample: z.ZodOptional<z.ZodString>;
1468
+ layout: z.ZodOptional<z.ZodEnum<{
1469
+ fixed: "fixed";
1470
+ page: "page";
1471
+ }>>;
1351
1472
  size: z.ZodOptional<z.ZodObject<{
1352
1473
  width: z.ZodNumber;
1353
1474
  height: z.ZodNumber;
@@ -1398,16 +1519,25 @@ export declare const stepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1398
1519
  Badge: "Badge";
1399
1520
  BarChart: "BarChart";
1400
1521
  Button: "Button";
1522
+ Callout: "Callout";
1523
+ Card: "Card";
1524
+ Checklist: "Checklist";
1525
+ Chips: "Chips";
1401
1526
  Column: "Column";
1402
1527
  DetailGrid: "DetailGrid";
1403
1528
  DonutChart: "DonutChart";
1529
+ Fold: "Fold";
1404
1530
  Grid: "Grid";
1531
+ Group: "Group";
1405
1532
  Image: "Image";
1406
1533
  LineChart: "LineChart";
1534
+ Link: "Link";
1407
1535
  List: "List";
1408
1536
  Metric: "Metric";
1409
1537
  Row: "Row";
1538
+ Steps: "Steps";
1410
1539
  Table: "Table";
1540
+ Tabs: "Tabs";
1411
1541
  Text: "Text";
1412
1542
  }>;
1413
1543
  children: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
@@ -1425,16 +1555,25 @@ export declare const stepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1425
1555
  Badge: "Badge";
1426
1556
  BarChart: "BarChart";
1427
1557
  Button: "Button";
1558
+ Callout: "Callout";
1559
+ Card: "Card";
1560
+ Checklist: "Checklist";
1561
+ Chips: "Chips";
1428
1562
  Column: "Column";
1429
1563
  DetailGrid: "DetailGrid";
1430
1564
  DonutChart: "DonutChart";
1565
+ Fold: "Fold";
1431
1566
  Grid: "Grid";
1567
+ Group: "Group";
1432
1568
  Image: "Image";
1433
1569
  LineChart: "LineChart";
1570
+ Link: "Link";
1434
1571
  List: "List";
1435
1572
  Metric: "Metric";
1436
1573
  Row: "Row";
1574
+ Steps: "Steps";
1437
1575
  Table: "Table";
1576
+ Tabs: "Tabs";
1438
1577
  Text: "Text";
1439
1578
  }>;
1440
1579
  children: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
@@ -1618,6 +1757,15 @@ export type AgentStep = z.infer<typeof agentStepSchema>;
1618
1757
  * (no text) can take.
1619
1758
  */
1620
1759
  export declare function isDecisionStep(step: AgentStep): boolean;
1760
+ /**
1761
+ * What an agent step's json output holds: its schema, or its fields as one. Undefined when it
1762
+ * names neither (the model then returns one table).
1763
+ */
1764
+ export declare function declaredShape(step: AgentStep): ObjectShape | undefined;
1765
+ /** What an agent step's json output holds: its declared shape, or else one table. */
1766
+ export declare function stepShape(step: AgentStep): ObjectShape;
1767
+ /** The top-level keys of an agent step's output: what `steps.<id>.<key>` may name. */
1768
+ export declare function outputKeys(step: AgentStep): string[];
1621
1769
  export type GenerateStep = z.infer<typeof generateStepSchema>;
1622
1770
  export type WidgetStep = z.infer<typeof widgetStepSchema>;
1623
1771
  export type FilmStep = z.infer<typeof filmStepSchema>;
@@ -2148,7 +2296,40 @@ export declare const wizardSchema: z.ZodObject<{
2148
2296
  columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
2149
2297
  options: z.ZodOptional<z.ZodArray<z.ZodString>>;
2150
2298
  }, z.core.$strip>>>;
2151
- surface: z.ZodOptional<z.ZodBoolean>;
2299
+ schema: z.ZodOptional<z.ZodType<ObjectShape, unknown, z.core.$ZodTypeInternals<ObjectShape, unknown>>>;
2300
+ surface: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodObject<{
2301
+ id: z.ZodString;
2302
+ component: z.ZodEnum<{
2303
+ Actions: "Actions";
2304
+ Badge: "Badge";
2305
+ BarChart: "BarChart";
2306
+ Button: "Button";
2307
+ Callout: "Callout";
2308
+ Card: "Card";
2309
+ Checklist: "Checklist";
2310
+ Chips: "Chips";
2311
+ Column: "Column";
2312
+ DetailGrid: "DetailGrid";
2313
+ DonutChart: "DonutChart";
2314
+ Fold: "Fold";
2315
+ Grid: "Grid";
2316
+ Group: "Group";
2317
+ Image: "Image";
2318
+ LineChart: "LineChart";
2319
+ Link: "Link";
2320
+ List: "List";
2321
+ Metric: "Metric";
2322
+ Row: "Row";
2323
+ Steps: "Steps";
2324
+ Table: "Table";
2325
+ Tabs: "Tabs";
2326
+ Text: "Text";
2327
+ }>;
2328
+ children: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
2329
+ path: z.ZodString;
2330
+ componentId: z.ZodString;
2331
+ }, z.core.$strip>]>>;
2332
+ }, z.core.$loose>>]>>;
2152
2333
  }, z.core.$strip>>;
2153
2334
  model: z.ZodOptional<z.ZodEnum<{
2154
2335
  classifier: "classifier";
@@ -2286,6 +2467,10 @@ export declare const wizardSchema: z.ZodObject<{
2286
2467
  entry: z.ZodString;
2287
2468
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
2288
2469
  sample: z.ZodOptional<z.ZodString>;
2470
+ layout: z.ZodOptional<z.ZodEnum<{
2471
+ fixed: "fixed";
2472
+ page: "page";
2473
+ }>>;
2289
2474
  size: z.ZodOptional<z.ZodObject<{
2290
2475
  width: z.ZodNumber;
2291
2476
  height: z.ZodNumber;
@@ -2336,16 +2521,25 @@ export declare const wizardSchema: z.ZodObject<{
2336
2521
  Badge: "Badge";
2337
2522
  BarChart: "BarChart";
2338
2523
  Button: "Button";
2524
+ Callout: "Callout";
2525
+ Card: "Card";
2526
+ Checklist: "Checklist";
2527
+ Chips: "Chips";
2339
2528
  Column: "Column";
2340
2529
  DetailGrid: "DetailGrid";
2341
2530
  DonutChart: "DonutChart";
2531
+ Fold: "Fold";
2342
2532
  Grid: "Grid";
2533
+ Group: "Group";
2343
2534
  Image: "Image";
2344
2535
  LineChart: "LineChart";
2536
+ Link: "Link";
2345
2537
  List: "List";
2346
2538
  Metric: "Metric";
2347
2539
  Row: "Row";
2540
+ Steps: "Steps";
2348
2541
  Table: "Table";
2542
+ Tabs: "Tabs";
2349
2543
  Text: "Text";
2350
2544
  }>;
2351
2545
  children: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
@@ -2363,16 +2557,25 @@ export declare const wizardSchema: z.ZodObject<{
2363
2557
  Badge: "Badge";
2364
2558
  BarChart: "BarChart";
2365
2559
  Button: "Button";
2560
+ Callout: "Callout";
2561
+ Card: "Card";
2562
+ Checklist: "Checklist";
2563
+ Chips: "Chips";
2366
2564
  Column: "Column";
2367
2565
  DetailGrid: "DetailGrid";
2368
2566
  DonutChart: "DonutChart";
2567
+ Fold: "Fold";
2369
2568
  Grid: "Grid";
2569
+ Group: "Group";
2370
2570
  Image: "Image";
2371
2571
  LineChart: "LineChart";
2572
+ Link: "Link";
2372
2573
  List: "List";
2373
2574
  Metric: "Metric";
2374
2575
  Row: "Row";
2576
+ Steps: "Steps";
2375
2577
  Table: "Table";
2578
+ Tabs: "Tabs";
2376
2579
  Text: "Text";
2377
2580
  }>;
2378
2581
  children: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodObject<{
@@ -1,6 +1,7 @@
1
1
  // SPDX-License-Identifier: FSL-1.1-MIT OR MIT
2
2
  import { z } from "zod";
3
3
  import { tableColumnsSchema } from "./engenty/data-tables/index.js";
4
+ import { outputShapeSchema, shapeOfFields } from "./shape.js";
4
5
  import { CONNECTION_KINDS } from "./store.js";
5
6
  import { surfaceComponentsSchema, validateSurface } from "./surface.js";
6
7
  /** The engenty avatars a wizard can wear. Same cast as engenty's ui-core. */
@@ -140,6 +141,57 @@ export function localLang(languages, timeZone) {
140
141
  const found = country ? langOf(COUNTRY_LANGUAGE[country]) : null;
141
142
  return found === "en" ? null : found;
142
143
  }
144
+ /**
145
+ * A language a wizard can be translated into: any language, by its two- or three-letter code
146
+ * ("fr", "it", "pl"), not only those of `LANGS`.
147
+ */
148
+ export const LANG_CODE = /^[a-z]{2,3}$/;
149
+ /** The code of a tag such as "fr-CA" or "pt_BR"; null where it names no language. */
150
+ export function langCodeOf(tag) {
151
+ const code = tag?.trim().toLowerCase().split(/[-_]/)[0] ?? "";
152
+ return LANG_CODE.test(code) ? code : null;
153
+ }
154
+ /**
155
+ * The language the person reads, for a wizard translated on request: the first of their
156
+ * languages (the browser's, in its order), else the main language of the country their time
157
+ * zone lies in. Any language, not only one engenty's own strings are written in.
158
+ */
159
+ export function viewerLang(languages, timeZone) {
160
+ for (const tag of languages) {
161
+ const code = langCodeOf(tag);
162
+ if (code) {
163
+ return code;
164
+ }
165
+ }
166
+ const country = timeZone ? ZONE_COUNTRY[timeZone] : undefined;
167
+ return country ? langCodeOf(COUNTRY_LANGUAGE[country]) : null;
168
+ }
169
+ /** A language's name in that language, as a switch shows it: "Italiano", "Polski". */
170
+ export function langName(code) {
171
+ if (isLang(code)) {
172
+ return LANG_NAMES[code];
173
+ }
174
+ try {
175
+ const name = new Intl.DisplayNames([code], { type: "language" }).of(code) ?? code;
176
+ return name.charAt(0).toLocaleUpperCase(code) + name.slice(1);
177
+ }
178
+ catch {
179
+ return code.toUpperCase();
180
+ }
181
+ }
182
+ /** A language's name in English, for a model told what to write in: "Italian". */
183
+ export function langNameEn(code) {
184
+ try {
185
+ return new Intl.DisplayNames(["en"], { type: "language" }).of(code) ?? code;
186
+ }
187
+ catch {
188
+ return code;
189
+ }
190
+ }
191
+ /** The locale amounts, dates and plural forms are written in for any language. */
192
+ export function localeOf(code) {
193
+ return isLang(code) ? LOCALES[code] : code;
194
+ }
143
195
  export const FIELD_KINDS = [
144
196
  "text",
145
197
  "textarea",
@@ -454,12 +506,19 @@ export const agentStepSchema = z.object({
454
506
  output: z
455
507
  .object({
456
508
  format: z.enum(["text", "markdown", "json"]),
509
+ /** The short form: one level of keys. A step has `fields` or `schema`, not both. */
457
510
  fields: z.array(outputFieldSchema).optional(),
458
511
  /**
459
- * json only: the step also composes a view of its result from the surface catalog, bound
460
- * to its own fields; reviews and the result show that view instead of a plain table.
512
+ * json only: nested data (lists of entries with lists of their own), in the kinds of
513
+ * `shape.ts`. Objects nest at most four deep, a hundred keys in all.
461
514
  */
462
- surface: z.boolean().optional(),
515
+ schema: outputShapeSchema.optional(),
516
+ /**
517
+ * json only: a view of the result from the surface catalog, bound to the step's own fields;
518
+ * reviews and the result show it instead of a plain table. Components: written once, the
519
+ * same every run, nothing to pay. `true`: a model composes one each run.
520
+ */
521
+ surface: z.union([z.boolean(), surfaceComponentsSchema]).optional(),
463
522
  })
464
523
  .default({ format: "markdown" }),
465
524
  /** The kind of model the step needs; default `high`. The model itself is bound elsewhere. */
@@ -519,6 +578,12 @@ export const widgetStepSchema = z.object({
519
578
  data: z.record(z.string(), z.string()).default({}),
520
579
  /** Workspace path of example data (JSON) for previews before any run. */
521
580
  sample: z.string().optional(),
581
+ /**
582
+ * How the run shows it: `fixed` (default) at `size`, scaled to the page; `page` as a part of
583
+ * the page, as wide as it and as tall as its content — a result people scroll and use, not a
584
+ * picture. PNG/PDF/MP4 still render at `size`.
585
+ */
586
+ layout: z.enum(["fixed", "page"]).optional(),
522
587
  /** The size the widget is designed for; previews scale it, PNG/PDF/MP4 render at it. */
523
588
  size: z
524
589
  .object({
@@ -652,6 +717,7 @@ export const stepSchema = z.discriminatedUnion("type", [
652
717
  export function isDecisionStep(step) {
653
718
  const fields = step.output.fields ?? [];
654
719
  return (!step.call &&
720
+ !step.output.schema &&
655
721
  step.model === "classifier" &&
656
722
  step.output.format === "json" &&
657
723
  fields.length > 0 &&
@@ -661,6 +727,27 @@ export function isDecisionStep(step) {
661
727
  !step.mcp?.length &&
662
728
  !step.connections?.length);
663
729
  }
730
+ /**
731
+ * What an agent step's json output holds: its schema, or its fields as one. Undefined when it
732
+ * names neither (the model then returns one table).
733
+ */
734
+ export function declaredShape(step) {
735
+ if (step.output.schema) {
736
+ return step.output.schema;
737
+ }
738
+ return step.output.fields?.length ? shapeOfFields(step.output.fields) : undefined;
739
+ }
740
+ /** What an agent step's json output holds: its declared shape, or else one table. */
741
+ export function stepShape(step) {
742
+ return (declaredShape(step) ?? {
743
+ kind: "object",
744
+ fields: { data: { kind: "table", description: "The result as a table" } },
745
+ });
746
+ }
747
+ /** The top-level keys of an agent step's output: what `steps.<id>.<key>` may name. */
748
+ export function outputKeys(step) {
749
+ return Object.keys(declaredShape(step)?.fields ?? {});
750
+ }
664
751
  export const listSchema = z.object({
665
752
  id,
666
753
  title: z.string().min(1),
@@ -743,7 +830,10 @@ export function formatsFor(step) {
743
830
  }
744
831
  if (step.type === "agent") {
745
832
  if (step.output.format === "json") {
746
- return ["json", "csv", "xlsx", "md", "zip"];
833
+ // Nested data reads as a document too.
834
+ return step.output.schema
835
+ ? ["json", "csv", "xlsx", "md", "pdf", "zip"]
836
+ : ["json", "csv", "xlsx", "md", "zip"];
747
837
  }
748
838
  return ["md", "txt", "docx", "pdf", "html", "zip"];
749
839
  }
@@ -966,8 +1056,7 @@ export function validateWizard(def, files) {
966
1056
  const source = def.steps.find((s) => s.id === from);
967
1057
  return (source?.type === "agent" &&
968
1058
  (!probability || isDecisionStep(source)) &&
969
- ((source.output.fields ?? []).some((f) => f.id === key) ||
970
- (Boolean(source.each) && key === "rows" && !probability)));
1059
+ (outputKeys(source).includes(key) || (Boolean(source.each) && key === "rows" && !probability)));
971
1060
  };
972
1061
  const conditionIssues = (stepId, c) => {
973
1062
  if ((c.op === "gt" || c.op === "lt") && typeof c.value !== "number") {
@@ -1002,27 +1091,38 @@ export function validateWizard(def, files) {
1002
1091
  if (source?.type === "agent" && source.each && key === "rows") {
1003
1092
  return column ? null : `"optionsFrom": "${from}.rows" is a table; name one of its columns.`;
1004
1093
  }
1005
- const out = source?.type === "agent"
1006
- ? (source.output.fields ?? []).find((f) => f.id === key)
1007
- : undefined;
1094
+ const out = source?.type === "agent" ? declaredShape(source)?.fields[key] : undefined;
1008
1095
  if (!out) {
1009
1096
  return `"optionsFrom" names "${from}.${key}", which is not an output of an earlier agent step.`;
1010
1097
  }
1098
+ // The keys of a table's rows, or of a list's entries; undefined: any (free columns).
1099
+ const columns = out.kind === "table"
1100
+ ? out.columns?.length
1101
+ ? out.columns
1102
+ : undefined
1103
+ : out.kind === "list" && out.of.kind === "object"
1104
+ ? Object.keys(out.of.fields)
1105
+ : null;
1106
+ if (columns === null) {
1107
+ if (column || cards) {
1108
+ return column
1109
+ ? `"optionsFrom": "${from}.${key}" is not a table with the column "${column}".`
1110
+ : `"cards": "${from}.${key}" is not a table.`;
1111
+ }
1112
+ return out.kind === "list"
1113
+ ? null
1114
+ : `"optionsFrom": "${from}.${key}" is not a list (a table takes a column, or "cards").`;
1115
+ }
1011
1116
  if (column) {
1012
- return out.kind === "table" && (!out.columns?.length || out.columns.includes(column))
1117
+ return !columns || columns.includes(column)
1013
1118
  ? null
1014
1119
  : `"optionsFrom": "${from}.${key}" is not a table with the column "${column}".`;
1015
1120
  }
1016
1121
  if (cards) {
1017
- if (out.kind !== "table") {
1018
- return `"cards": "${from}.${key}" is not a table.`;
1019
- }
1020
- const missing = Object.values(cards).find((c) => out.columns?.length && !out.columns.includes(c));
1021
- return missing ? `"cards": table "${from}.${key}" has no column "${missing}".` : null;
1122
+ const missing = Object.values(cards).find((c) => columns && !columns.includes(c));
1123
+ return missing ? `"cards": "${from}.${key}" has no column "${missing}".` : null;
1022
1124
  }
1023
- return out.kind === "list"
1024
- ? null
1025
- : `"optionsFrom": "${from}.${key}" is not a list (a table takes a column, or "cards").`;
1125
+ return `"optionsFrom": "${from}.${key}" is not a list (a table takes a column, or "cards").`;
1026
1126
  }
1027
1127
  return `"optionsFrom" is "steps.<id>.<key>", "steps.<id>.<key>.<column>" or "lists.<id>.<column>".`;
1028
1128
  };
@@ -1131,6 +1231,28 @@ export function validateWizard(def, files) {
1131
1231
  message: 'A step composes a view ("surface") of json output only.',
1132
1232
  });
1133
1233
  }
1234
+ if (step.output.schema) {
1235
+ if (step.output.fields?.length) {
1236
+ issues.push({
1237
+ stepId: step.id,
1238
+ message: 'Output has "fields" or "schema", not both.',
1239
+ });
1240
+ }
1241
+ if (step.output.format !== "json" || step.call) {
1242
+ issues.push({
1243
+ stepId: step.id,
1244
+ message: step.call
1245
+ ? 'A step with "call" keeps the tool\'s answer as it is: no "schema".'
1246
+ : 'A "schema" describes json output: output format "json".',
1247
+ });
1248
+ }
1249
+ }
1250
+ if (Array.isArray(step.output.surface)) {
1251
+ // A step with `each` hands over its entries as `rows`.
1252
+ for (const issue of validateSurface(step.output.surface, step.each ? ["rows"] : declaredShape(step))) {
1253
+ issues.push({ stepId: step.id, message: `View: ${issue.message}` });
1254
+ }
1255
+ }
1134
1256
  if (step.each) {
1135
1257
  const ref = dataRef(step.each);
1136
1258
  const list = ref.match(/^lists\.([a-zA-Z][a-zA-Z0-9_]*)$/)?.[1];
@@ -1,3 +1,4 @@
1
+ import type { RunTheme } from "./run.js";
1
2
  export declare const FACT_TYPES: readonly ["text", "longtext", "number", "date", "url", "email", "phone", "boolean"];
2
3
  export type FactType = (typeof FACT_TYPES)[number];
3
4
  export interface ProjectFact {
@@ -130,6 +131,16 @@ export interface BrandFont {
130
131
  */
131
132
  uses?: FontUse[];
132
133
  }
134
+ /**
135
+ * How a wizard's pages look, from the brand: the first standard colour is the accent, a standard
136
+ * colour named as the ground ("Hintergrund") the background, the next colourful one the second
137
+ * colour; the typeface for headings and the one for text by their roles. What the brand does not
138
+ * say stays the runner's own.
139
+ */
140
+ export declare function runTheme(brand: {
141
+ colors?: BrandColor[];
142
+ fonts?: Pick<BrandFont, "family" | "role">[];
143
+ }): RunTheme;
133
144
  /** The font's licence as a model reads it: ", licence …, may only be used for …". */
134
145
  export declare function fontLicenseWords(f: Pick<BrandFont, "license" | "uses">): string;
135
146
  /** A text style of the type scale: "Headline XL – Space Grotesk 600, 48 px, line 90 %, −4 %". */