wizards 0.2.47 → 0.2.49

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 (181) hide show
  1. package/README.md +2 -1
  2. package/apps/runtime/dist/agents/{project-assistant.js → studio-assistant.js} +199 -69
  3. package/apps/runtime/dist/agents/website.js +25 -2
  4. package/apps/runtime/dist/app.js +2 -1
  5. package/apps/runtime/dist/apple/wizards-apple +0 -0
  6. package/apps/runtime/dist/assistant/browser.js +26 -0
  7. package/apps/runtime/dist/assistant/docs.js +158 -0
  8. package/apps/runtime/dist/assistant/knows.js +325 -0
  9. package/apps/runtime/dist/assistant/primer.js +26 -0
  10. package/apps/runtime/dist/authoring/guide.js +5 -0
  11. package/apps/runtime/dist/cli/status.js +1 -1
  12. package/apps/runtime/dist/connectors/plugin-connections.js +123 -29
  13. package/apps/runtime/dist/db/migrations/tenant/0012_assistant_chat.sql +40 -0
  14. package/apps/runtime/dist/db/migrations/tenant/0013_run_origin.sql +1 -0
  15. package/apps/runtime/dist/db/migrations/tenant/meta/0012_snapshot.json +3132 -0
  16. package/apps/runtime/dist/db/migrations/tenant/meta/0013_snapshot.json +3139 -0
  17. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +14 -0
  18. package/apps/runtime/dist/db/schema.js +35 -0
  19. package/apps/runtime/dist/docs/dev/index.md +34 -0
  20. package/apps/runtime/dist/docs/dev/meta.json +7 -0
  21. package/apps/runtime/dist/docs/dev/plugins/connections.md +70 -0
  22. package/apps/runtime/dist/docs/dev/plugins/events.md +86 -0
  23. package/apps/runtime/dist/docs/dev/plugins/examples.md +99 -0
  24. package/apps/runtime/dist/docs/dev/plugins/index.md +72 -0
  25. package/apps/runtime/dist/docs/dev/plugins/layout.md +88 -0
  26. package/apps/runtime/dist/docs/dev/plugins/meta.json +29 -0
  27. package/apps/runtime/dist/docs/dev/plugins/pro-modules.md +59 -0
  28. package/apps/runtime/dist/docs/dev/plugins/quick-start.md +92 -0
  29. package/apps/runtime/dist/docs/dev/plugins/reference.md +298 -0
  30. package/apps/runtime/dist/docs/dev/plugins/reloading.md +75 -0
  31. package/apps/runtime/dist/docs/dev/plugins/routes.md +123 -0
  32. package/apps/runtime/dist/docs/dev/plugins/runners.md +184 -0
  33. package/apps/runtime/dist/docs/dev/plugins/server.md +191 -0
  34. package/apps/runtime/dist/docs/dev/plugins/shipping.md +98 -0
  35. package/apps/runtime/dist/docs/dev/plugins/space.md +260 -0
  36. package/apps/runtime/dist/docs/dev/plugins/starters.md +62 -0
  37. package/apps/runtime/dist/docs/dev/plugins/studio.md +261 -0
  38. package/apps/runtime/dist/docs/dev/plugins/styling.md +109 -0
  39. package/apps/runtime/dist/docs/dev/plugins/tables.md +102 -0
  40. package/apps/runtime/dist/docs/dev/plugins/tools.md +128 -0
  41. package/apps/runtime/dist/docs/meta.json +3 -0
  42. package/apps/runtime/dist/docs/user/ai-apps.md +99 -0
  43. package/apps/runtime/dist/docs/user/assistant.md +52 -0
  44. package/apps/runtime/dist/docs/user/build-a-wizard.md +79 -0
  45. package/apps/runtime/dist/docs/user/command-line.md +76 -0
  46. package/apps/runtime/dist/docs/user/connectors.md +80 -0
  47. package/apps/runtime/dist/docs/user/data.md +61 -0
  48. package/apps/runtime/dist/docs/user/first-start.md +42 -0
  49. package/apps/runtime/dist/docs/user/index.md +45 -0
  50. package/apps/runtime/dist/docs/user/install.md +76 -0
  51. package/apps/runtime/dist/docs/user/meta.json +30 -0
  52. package/apps/runtime/dist/docs/user/models.md +125 -0
  53. package/apps/runtime/dist/docs/user/plugins.md +61 -0
  54. package/apps/runtime/dist/docs/user/run.md +92 -0
  55. package/apps/runtime/dist/docs/user/server.md +50 -0
  56. package/apps/runtime/dist/docs/user/space.md +97 -0
  57. package/apps/runtime/dist/docs/user/steps.md +196 -0
  58. package/apps/runtime/dist/docs/user/test-and-share.md +216 -0
  59. package/apps/runtime/dist/docs/user/troubleshooting.md +57 -0
  60. package/apps/runtime/dist/docs/user/wordpress.md +103 -0
  61. package/apps/runtime/dist/engine/device.js +182 -0
  62. package/apps/runtime/dist/engine/events.js +3 -0
  63. package/apps/runtime/dist/engine/input.js +3 -0
  64. package/apps/runtime/dist/engine/prepare.js +1 -0
  65. package/apps/runtime/dist/engine/requirements.js +6 -109
  66. package/apps/runtime/dist/engine/runner.js +13 -5
  67. package/apps/runtime/dist/engine/steps.js +2 -1
  68. package/apps/runtime/dist/env.js +1 -1
  69. package/apps/runtime/dist/harness/apple.js +258 -0
  70. package/apps/runtime/dist/harness/model.js +3 -1
  71. package/apps/runtime/dist/manage.js +11 -0
  72. package/apps/runtime/dist/mcp/auth.js +3 -0
  73. package/apps/runtime/dist/mcp/scopes.js +11 -2
  74. package/apps/runtime/dist/media/transcribe.js +6 -1
  75. package/apps/runtime/dist/models.js +63 -9
  76. package/apps/runtime/dist/plugins/loader.js +2 -0
  77. package/apps/runtime/dist/routes/api.js +232 -1
  78. package/apps/runtime/dist/routes/plugins.js +6 -2
  79. package/apps/runtime/dist/routes/runs.js +65 -3
  80. package/apps/runtime/dist/routes/studio.js +130 -69
  81. package/apps/runtime/dist/services/api.js +244 -0
  82. package/apps/runtime/dist/services/assistant-chats.js +267 -0
  83. package/apps/runtime/dist/services/engenty-shapes.js +1 -1
  84. package/apps/runtime/dist/services/package.js +77 -9
  85. package/apps/runtime/dist/services/project-index.js +1 -1
  86. package/apps/runtime/dist/services/runs.js +4 -3
  87. package/apps/runtime/dist/services/site.js +262 -0
  88. package/apps/runtime/dist/services/space-origin.js +45 -2
  89. package/apps/web/dist/assets/AboutDialog-6CCpWqAl.js +1 -0
  90. package/apps/web/dist/assets/ChangelogDialog-ApswqjRk.js +1 -0
  91. package/apps/web/dist/assets/ChatView-D7N2QyGS.js +10 -0
  92. package/apps/web/dist/assets/EditorPage-CbtYQTWj.js +3 -0
  93. package/apps/web/dist/assets/FlowPreview-KTaelucs.js +1 -0
  94. package/apps/web/dist/assets/{Harness-zKMptCzB.js → Harness-_mD1Stm4.js} +2 -2
  95. package/apps/web/dist/assets/Marketplace-DKQ9j4OC.js +2 -0
  96. package/apps/web/dist/assets/NewWizardPage-CoCCRcoi.js +1 -0
  97. package/apps/web/dist/assets/ProjectPage-DDLh_qxi.js +2 -0
  98. package/apps/web/dist/assets/PublicRunner-Lpu-BY5w.js +1 -0
  99. package/apps/web/dist/assets/ReadOnly-ClY8xMQS.js +1 -0
  100. package/apps/web/dist/assets/RunDrawer-JXG5wZp7.js +4 -0
  101. package/apps/web/dist/assets/RunnerView-BlUSqfqB.js +1 -0
  102. package/apps/web/dist/assets/SettingsPage-V_E267hI.js +1 -0
  103. package/apps/web/dist/assets/SetupPage-Dvoze8cZ.js +1 -0
  104. package/apps/web/dist/assets/SharePage-DBcp_npb.js +1 -0
  105. package/apps/web/dist/assets/brand-CNF5NxD9.js +2 -0
  106. package/apps/web/dist/assets/changelog-CmZrNHwc.js +1 -0
  107. package/apps/web/dist/assets/circle-alert-r2qc1Vej.js +1 -0
  108. package/apps/web/dist/assets/engenty-eXZ-EAwd.js +1 -0
  109. package/apps/web/dist/assets/esm-DZeij_95.js +7 -0
  110. package/apps/web/dist/assets/{fluffy-engenty-D7rFrNcJ.js → fluffy-engenty-ClRou7yu.js} +1 -1
  111. package/apps/web/dist/assets/index-BbogBDv_.js +11 -0
  112. package/apps/web/dist/assets/index-Dr0bv52Q.css +1 -0
  113. package/apps/web/dist/assets/jsx-runtime-BNakU3Ej.js +1 -0
  114. package/apps/web/dist/assets/lock-N-C6-ZeG.js +1 -0
  115. package/apps/web/dist/assets/logo-C4V2_3Ar.js +1 -0
  116. package/apps/web/dist/assets/oss-credits-BQQX0kvk.js +1 -0
  117. package/apps/web/dist/assets/pdfmake-Cx9scTbD.js +228 -0
  118. package/apps/web/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
  119. package/apps/web/dist/assets/session-Cpg5S8B3.js +1 -0
  120. package/apps/web/dist/assets/settings-menu-C7m2i7Sf.js +1 -0
  121. package/apps/web/dist/assets/ui-DKcggL84.js +133 -0
  122. package/apps/web/dist/assets/upload-D24SDj7W.js +1 -0
  123. package/apps/web/dist/assets/useMutation-DKyQXgyj.js +1 -0
  124. package/apps/web/dist/assets/vfs_fonts-DllDSYt1.js +1 -0
  125. package/apps/web/dist/assets/volume-2-C-Y7-S4b.js +1 -0
  126. package/apps/web/dist/embed.js +57 -8
  127. package/apps/web/dist/index.html +12 -16
  128. package/apps/web/dist/mcp/flow.html +435 -207
  129. package/modules/calls/dist/client.css +1 -1
  130. package/modules/sms/dist/client.css +1 -1
  131. package/modules/whatsapp/dist/client.css +1 -1
  132. package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +82 -7
  133. package/node_modules/@engenty-wizards/plugin-sdk/dist/studio.d.ts +58 -4
  134. package/node_modules/@engenty-wizards/shared/dist/assistant.d.ts +113 -0
  135. package/node_modules/@engenty-wizards/shared/dist/assistant.js +55 -0
  136. package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +58 -1
  137. package/node_modules/@engenty-wizards/shared/dist/definition.js +94 -4
  138. package/node_modules/@engenty-wizards/shared/dist/fit.d.ts +71 -0
  139. package/node_modules/@engenty-wizards/shared/dist/fit.js +381 -0
  140. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +3 -1
  141. package/package.json +1 -1
  142. package/apps/web/dist/assets/AboutDialog-t7bpiasT.js +0 -1
  143. package/apps/web/dist/assets/ChangelogDialog-B87yS6aN.js +0 -1
  144. package/apps/web/dist/assets/ChatView-Dm764bYy.js +0 -10
  145. package/apps/web/dist/assets/EditorPage-BG_Ue2iC.js +0 -3
  146. package/apps/web/dist/assets/FlowPreview-ChXfiMn_.js +0 -1
  147. package/apps/web/dist/assets/HomePage-BXSg5P5k.js +0 -1
  148. package/apps/web/dist/assets/Marketplace-BWhUJ4UX.js +0 -2
  149. package/apps/web/dist/assets/NewWizardPage-C3NqEGmg.js +0 -1
  150. package/apps/web/dist/assets/ProjectPage-D6Fy7uTV.js +0 -2
  151. package/apps/web/dist/assets/PublicRunner-ChgJs0C9.js +0 -1
  152. package/apps/web/dist/assets/ReadOnly-C9P9aiU6.js +0 -1
  153. package/apps/web/dist/assets/RunDrawer-CvIKLphz.js +0 -4
  154. package/apps/web/dist/assets/RunnerView-Bmayop7s.js +0 -2
  155. package/apps/web/dist/assets/SettingsPage-QkwtRFoD.js +0 -1
  156. package/apps/web/dist/assets/SetupPage-B3IOQLO3.js +0 -1
  157. package/apps/web/dist/assets/SharePage-C3QEzicl.js +0 -1
  158. package/apps/web/dist/assets/ThemeSwitch-3IzIOlNz.js +0 -1
  159. package/apps/web/dist/assets/arrow-right-Dpp_mpHe.js +0 -1
  160. package/apps/web/dist/assets/changelog-Du2gWzlN.js +0 -1
  161. package/apps/web/dist/assets/circle-alert-CPo3Naay.js +0 -1
  162. package/apps/web/dist/assets/definition-CQGiBQ4X.js +0 -56
  163. package/apps/web/dist/assets/engenty-Cm8yZLON.js +0 -1
  164. package/apps/web/dist/assets/esm-rJY59Ixx.js +0 -7
  165. package/apps/web/dist/assets/external-link-CpU8aJY2.js +0 -1
  166. package/apps/web/dist/assets/index-Cz6c1S5g.js +0 -78
  167. package/apps/web/dist/assets/index-DKHClEy3.css +0 -1
  168. package/apps/web/dist/assets/jsx-runtime-D3jfb0Ew.js +0 -1
  169. package/apps/web/dist/assets/lock-C_WlXIQ0.js +0 -1
  170. package/apps/web/dist/assets/logo-C80CWCDM.js +0 -1
  171. package/apps/web/dist/assets/oss-credits-CIxnNZor.js +0 -1
  172. package/apps/web/dist/assets/react-dom-DenslgJm.js +0 -1
  173. package/apps/web/dist/assets/refresh-cw-Cli5WGnW.js +0 -1
  174. package/apps/web/dist/assets/session-miDEdw2c.js +0 -1
  175. package/apps/web/dist/assets/settings-menu-ROT8Lbbj.js +0 -1
  176. package/apps/web/dist/assets/sparkles-CP5H-O1E.js +0 -1
  177. package/apps/web/dist/assets/trash-DU-hZpV0.js +0 -1
  178. package/apps/web/dist/assets/ui-D92EkdEB.js +0 -9
  179. package/apps/web/dist/assets/upload-DMq5N6Fw.js +0 -1
  180. package/apps/web/dist/assets/useMutation-DKcIz55V.js +0 -1
  181. package/apps/web/dist/assets/volume-2-0SfkvOho.js +0 -1
@@ -0,0 +1,113 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The studio's assistant between the browser and the runtime: what a page tells it, the tools
4
+ * the browser runs, and the events of a turn. The events are our own, shaped like AG-UI's
5
+ * (docs.ag-ui.com): message and tool-call ids and AG-UI's field names, so a later switch is a
6
+ * rename on both ends.
7
+ */
8
+ /** A page's snapshot is cut to this many bytes of JSON. */
9
+ export declare const ASSISTANT_PAGE_BYTES: number;
10
+ /** What the page the person writes from shows; it goes up with every message. */
11
+ export declare const assistantPageSchema: z.ZodObject<{
12
+ route: z.ZodString;
13
+ title: z.ZodOptional<z.ZodString>;
14
+ view: z.ZodOptional<z.ZodString>;
15
+ open: z.ZodOptional<z.ZodObject<{
16
+ kind: z.ZodString;
17
+ id: z.ZodOptional<z.ZodString>;
18
+ label: z.ZodString;
19
+ }, z.core.$strip>>;
20
+ selection: z.ZodOptional<z.ZodArray<z.ZodString>>;
21
+ summary: z.ZodOptional<z.ZodString>;
22
+ fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
23
+ id: z.ZodString;
24
+ label: z.ZodString;
25
+ value: z.ZodUnknown;
26
+ }, z.core.$strip>>>;
27
+ plugin: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strip>;
29
+ export type AssistantPage = z.infer<typeof assistantPageSchema>;
30
+ /** A tool the browser runs (AG-UI's `Tool`): its arguments as JSON Schema. */
31
+ export declare const browserToolSchema: z.ZodObject<{
32
+ name: z.ZodString;
33
+ description: z.ZodString;
34
+ parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
35
+ }, z.core.$strip>;
36
+ export type BrowserTool = z.infer<typeof browserToolSchema>;
37
+ /** The browser waits no longer for a tool than this; the runtime neither. */
38
+ export declare const BROWSER_TOOL_TIMEOUT_MS = 60000;
39
+ /** What the browser sends to start a turn (AG-UI's `RunAgentInput`, cut to what we use). */
40
+ export declare const assistantTurnSchema: z.ZodObject<{
41
+ message: z.ZodString;
42
+ projectId: z.ZodOptional<z.ZodString>;
43
+ page: z.ZodOptional<z.ZodObject<{
44
+ route: z.ZodString;
45
+ title: z.ZodOptional<z.ZodString>;
46
+ view: z.ZodOptional<z.ZodString>;
47
+ open: z.ZodOptional<z.ZodObject<{
48
+ kind: z.ZodString;
49
+ id: z.ZodOptional<z.ZodString>;
50
+ label: z.ZodString;
51
+ }, z.core.$strip>>;
52
+ selection: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ summary: z.ZodOptional<z.ZodString>;
54
+ fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
55
+ id: z.ZodString;
56
+ label: z.ZodString;
57
+ value: z.ZodUnknown;
58
+ }, z.core.$strip>>>;
59
+ plugin: z.ZodOptional<z.ZodString>;
60
+ }, z.core.$strip>>;
61
+ tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
62
+ name: z.ZodString;
63
+ description: z.ZodString;
64
+ parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
65
+ }, z.core.$strip>>>;
66
+ }, z.core.$strip>;
67
+ export type AssistantTurn = z.input<typeof assistantTurnSchema>;
68
+ /** The events of a turn, by SSE event name. */
69
+ export interface AssistantEvents {
70
+ /** The turn started; `messageId` is the stored message of the person. */
71
+ run_started: {
72
+ threadId: string;
73
+ runId: string;
74
+ messageId: string;
75
+ };
76
+ text: {
77
+ messageId: string;
78
+ delta: string;
79
+ };
80
+ /** What the assistant does right now, in a few words. */
81
+ activity: {
82
+ label: string;
83
+ };
84
+ tool_call: {
85
+ toolCallId: string;
86
+ toolCallName: string;
87
+ args: unknown;
88
+ };
89
+ tool_result: {
90
+ toolCallId: string;
91
+ content: string;
92
+ };
93
+ /** A plugin's tool returned what its card in the chat draws. */
94
+ card: {
95
+ toolCallId?: string;
96
+ plugin: string;
97
+ tool: string;
98
+ data: unknown;
99
+ };
100
+ /** The space or a plugin's data changed: the page reads its data again. */
101
+ changed: Record<string, never>;
102
+ done: {
103
+ messageId: string;
104
+ reply: string;
105
+ changed: boolean;
106
+ };
107
+ error: {
108
+ message: string;
109
+ };
110
+ }
111
+ /** Where the assistant stands on the screen, per person. */
112
+ export declare const ASSISTANT_LAYOUTS: readonly ["bottom", "sidebar", "avatar"];
113
+ export type AssistantLayout = (typeof ASSISTANT_LAYOUTS)[number];
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The studio's assistant between the browser and the runtime: what a page tells it, the tools
4
+ * the browser runs, and the events of a turn. The events are our own, shaped like AG-UI's
5
+ * (docs.ag-ui.com): message and tool-call ids and AG-UI's field names, so a later switch is a
6
+ * rename on both ends.
7
+ */
8
+ /** A page's snapshot is cut to this many bytes of JSON. */
9
+ export const ASSISTANT_PAGE_BYTES = 16 * 1024;
10
+ /** What the page the person writes from shows; it goes up with every message. */
11
+ export const assistantPageSchema = z.object({
12
+ /** The studio's address: `/shop`, `/space/knowledge`. */
13
+ route: z.string().max(400),
14
+ /** What the top bar's trail says the page is. */
15
+ title: z.string().max(200).optional(),
16
+ /** The section in view: "Display and checkout". */
17
+ view: z.string().max(200).optional(),
18
+ /** An item the page has open. */
19
+ open: z
20
+ .object({
21
+ kind: z.string().max(60),
22
+ id: z.string().max(120).optional(),
23
+ label: z.string().max(200),
24
+ })
25
+ .optional(),
26
+ /** Ids of what the person picked. */
27
+ selection: z.array(z.string().max(120)).max(100).optional(),
28
+ /** A line on what the page holds: "0 products · no source · prices incl. VAT". */
29
+ summary: z.string().max(2000).optional(),
30
+ /** Fields of the page with their values. */
31
+ fields: z
32
+ .array(z.object({ id: z.string().max(120), label: z.string().max(200), value: z.unknown() }))
33
+ .max(60)
34
+ .optional(),
35
+ /** The plugin whose page it is. */
36
+ plugin: z.string().max(60).optional(),
37
+ });
38
+ /** A tool the browser runs (AG-UI's `Tool`): its arguments as JSON Schema. */
39
+ export const browserToolSchema = z.object({
40
+ name: z.string().regex(/^[a-z][a-z0-9_]{1,62}$/),
41
+ description: z.string().max(2000),
42
+ parameters: z.record(z.string(), z.unknown()),
43
+ });
44
+ /** The browser waits no longer for a tool than this; the runtime neither. */
45
+ export const BROWSER_TOOL_TIMEOUT_MS = 60_000;
46
+ /** What the browser sends to start a turn (AG-UI's `RunAgentInput`, cut to what we use). */
47
+ export const assistantTurnSchema = z.object({
48
+ message: z.string().min(1).max(8000),
49
+ /** The space the page shows; its tools need it. */
50
+ projectId: z.string().max(80).optional(),
51
+ page: assistantPageSchema.optional(),
52
+ tools: z.array(browserToolSchema).max(40).default([]),
53
+ });
54
+ /** Where the assistant stands on the screen, per person. */
55
+ export const ASSISTANT_LAYOUTS = ["bottom", "sidebar", "avatar"];
@@ -30,6 +30,8 @@ export interface AudioValue {
30
30
  asset: string;
31
31
  seconds?: number;
32
32
  transcript?: string;
33
+ /** The language the runner was in when the note was taken: what it is most likely spoken in. */
34
+ lang?: "de" | "en";
33
35
  }
34
36
  export declare function isLocationValue(v: unknown): v is LocationValue;
35
37
  export declare function isAudioValue(v: unknown): v is AudioValue;
@@ -129,6 +131,25 @@ export declare const whenSchema: z.ZodUnion<readonly [z.ZodObject<{
129
131
  value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
130
132
  }, z.core.$strip>>]>;
131
133
  export type When = z.infer<typeof whenSchema>;
134
+ /** What a card of a choice shows: the columns of the table the choices come from. */
135
+ export declare const cardsSchema: z.ZodObject<{
136
+ label: z.ZodString;
137
+ value: z.ZodOptional<z.ZodString>;
138
+ image: z.ZodOptional<z.ZodString>;
139
+ subtitle: z.ZodOptional<z.ZodString>;
140
+ meta: z.ZodOptional<z.ZodString>;
141
+ link: z.ZodOptional<z.ZodString>;
142
+ }, z.core.$strip>;
143
+ export type CardsDef = z.infer<typeof cardsSchema>;
144
+ /** A choice drawn as a card, as the runner gets it. */
145
+ export interface CardOption {
146
+ value: string;
147
+ label: string;
148
+ image?: string;
149
+ subtitle?: string;
150
+ meta?: string;
151
+ link?: string;
152
+ }
132
153
  export declare const fieldSchema: z.ZodObject<{
133
154
  id: z.ZodString;
134
155
  label: z.ZodString;
@@ -210,6 +231,14 @@ export declare const fieldSchema: z.ZodObject<{
210
231
  value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
211
232
  }, z.core.$strip>>]>>;
212
233
  optionsFrom: z.ZodOptional<z.ZodString>;
234
+ cards: z.ZodOptional<z.ZodObject<{
235
+ label: z.ZodString;
236
+ value: z.ZodOptional<z.ZodString>;
237
+ image: z.ZodOptional<z.ZodString>;
238
+ subtitle: z.ZodOptional<z.ZodString>;
239
+ meta: z.ZodOptional<z.ZodString>;
240
+ link: z.ZodOptional<z.ZodString>;
241
+ }, z.core.$strip>>;
213
242
  ask: z.ZodOptional<z.ZodString>;
214
243
  group: z.ZodOptional<z.ZodString>;
215
244
  }, z.core.$strip>;
@@ -350,6 +379,14 @@ export declare const pageStepSchema: z.ZodObject<{
350
379
  value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
351
380
  }, z.core.$strip>>]>>;
352
381
  optionsFrom: z.ZodOptional<z.ZodString>;
382
+ cards: z.ZodOptional<z.ZodObject<{
383
+ label: z.ZodString;
384
+ value: z.ZodOptional<z.ZodString>;
385
+ image: z.ZodOptional<z.ZodString>;
386
+ subtitle: z.ZodOptional<z.ZodString>;
387
+ meta: z.ZodOptional<z.ZodString>;
388
+ link: z.ZodOptional<z.ZodString>;
389
+ }, z.core.$strip>>;
353
390
  ask: z.ZodOptional<z.ZodString>;
354
391
  group: z.ZodOptional<z.ZodString>;
355
392
  }, z.core.$strip>>;
@@ -1025,6 +1062,14 @@ export declare const stepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1025
1062
  value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
1026
1063
  }, z.core.$strip>>]>>;
1027
1064
  optionsFrom: z.ZodOptional<z.ZodString>;
1065
+ cards: z.ZodOptional<z.ZodObject<{
1066
+ label: z.ZodString;
1067
+ value: z.ZodOptional<z.ZodString>;
1068
+ image: z.ZodOptional<z.ZodString>;
1069
+ subtitle: z.ZodOptional<z.ZodString>;
1070
+ meta: z.ZodOptional<z.ZodString>;
1071
+ link: z.ZodOptional<z.ZodString>;
1072
+ }, z.core.$strip>>;
1028
1073
  ask: z.ZodOptional<z.ZodString>;
1029
1074
  group: z.ZodOptional<z.ZodString>;
1030
1075
  }, z.core.$strip>>;
@@ -1951,6 +1996,14 @@ export declare const wizardSchema: z.ZodObject<{
1951
1996
  value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
1952
1997
  }, z.core.$strip>>]>>;
1953
1998
  optionsFrom: z.ZodOptional<z.ZodString>;
1999
+ cards: z.ZodOptional<z.ZodObject<{
2000
+ label: z.ZodString;
2001
+ value: z.ZodOptional<z.ZodString>;
2002
+ image: z.ZodOptional<z.ZodString>;
2003
+ subtitle: z.ZodOptional<z.ZodString>;
2004
+ meta: z.ZodOptional<z.ZodString>;
2005
+ link: z.ZodOptional<z.ZodString>;
2006
+ }, z.core.$strip>>;
1954
2007
  ask: z.ZodOptional<z.ZodString>;
1955
2008
  group: z.ZodOptional<z.ZodString>;
1956
2009
  }, z.core.$strip>>;
@@ -2586,7 +2639,11 @@ export declare function optionsFromData(ref: string, outputs: Record<string, {
2586
2639
  rows: {
2587
2640
  cells: Record<string, unknown>;
2588
2641
  }[];
2589
- }>): string[];
2642
+ }>, cards?: CardsDef): string[];
2643
+ /** The rows of a table output as cards: what `optionsFrom` with `cards` finds in the run. */
2644
+ export declare function cardsFromData(ref: string, outputs: Record<string, {
2645
+ json?: unknown;
2646
+ }>, cards: CardsDef): CardOption[];
2590
2647
  /** An offered appointment time read on its own clock: the offset it was written with. */
2591
2648
  export interface SlotTime {
2592
2649
  /** The calendar day there: "2026-10-12". */
@@ -161,6 +161,15 @@ export const conditionSchema = z.object({
161
161
  });
162
162
  /** One condition, or several that must all hold. */
163
163
  export const whenSchema = z.union([conditionSchema, z.array(conditionSchema).min(1)]);
164
+ /** What a card of a choice shows: the columns of the table the choices come from. */
165
+ export const cardsSchema = z.object({
166
+ label: z.string().min(1),
167
+ value: z.string().optional(),
168
+ image: z.string().optional(),
169
+ subtitle: z.string().optional(),
170
+ meta: z.string().optional(),
171
+ link: z.string().optional(),
172
+ });
164
173
  export const fieldSchema = z.object({
165
174
  id,
166
175
  label: z.string().min(1),
@@ -215,6 +224,12 @@ export const fieldSchema = z.object({
215
224
  * of a stored list ("lists.<id>.<column>"). `options` stand in while that data is empty.
216
225
  */
217
226
  optionsFrom: z.string().optional(),
227
+ /**
228
+ * select / multiselect with `optionsFrom` naming a table output ("steps.<id>.<key>"): each row
229
+ * is a choice drawn as a card. The columns that hold what the card shows; `value` (default:
230
+ * `label`) is what the answer holds, `link` a page the card opens.
231
+ */
232
+ cards: cardsSchema.optional(),
218
233
  /**
219
234
  * The field is shown when a decision, made as the run reaches the page, finds this statement
220
235
  * true of the run ("The complaint is about a damaged article").
@@ -847,7 +862,7 @@ export function validateWizard(def, files) {
847
862
  return [];
848
863
  };
849
864
  /** Why an `optionsFrom` reference finds nothing, or null when it is fine. */
850
- const optionsFromProblem = (raw) => {
865
+ const optionsFromProblem = (raw, cards) => {
851
866
  const [head, from, key, column, ...more] = dataRef(raw).split(".");
852
867
  if (head === "lists" && from && key && !column) {
853
868
  const list = def.lists?.find((l) => l.id === from);
@@ -878,7 +893,16 @@ export function validateWizard(def, files) {
878
893
  ? null
879
894
  : `"optionsFrom": "${from}.${key}" is not a table with the column "${column}".`;
880
895
  }
881
- return out.kind === "list" ? null : `"optionsFrom": "${from}.${key}" is not a list.`;
896
+ if (cards) {
897
+ if (out.kind !== "table") {
898
+ return `"cards": "${from}.${key}" is not a table.`;
899
+ }
900
+ const missing = Object.values(cards).find((c) => out.columns?.length && !out.columns.includes(c));
901
+ return missing ? `"cards": table "${from}.${key}" has no column "${missing}".` : null;
902
+ }
903
+ return out.kind === "list"
904
+ ? null
905
+ : `"optionsFrom": "${from}.${key}" is not a list (a table takes a column, or "cards").`;
882
906
  }
883
907
  return `"optionsFrom" is "steps.<id>.<key>", "steps.<id>.<key>.<column>" or "lists.<id>.<column>".`;
884
908
  };
@@ -930,11 +954,19 @@ export function validateWizard(def, files) {
930
954
  if (field.optionsFrom) {
931
955
  const problem = field.kind !== "select" && field.kind !== "multiselect" && field.kind !== "slot"
932
956
  ? `"optionsFrom" fills the choices of a select, multiselect or slot; kind is "${field.kind}".`
933
- : optionsFromProblem(field.optionsFrom);
957
+ : field.cards && field.kind === "slot"
958
+ ? '"cards" draws the choices of a select or multiselect, not of a slot.'
959
+ : optionsFromProblem(field.optionsFrom, field.cards);
934
960
  if (problem) {
935
961
  issues.push({ stepId: step.id, message: `Field "${field.id}": ${problem}` });
936
962
  }
937
963
  }
964
+ else if (field.cards) {
965
+ issues.push({
966
+ stepId: step.id,
967
+ message: `Field "${field.id}": "cards" needs "optionsFrom" naming a table output.`,
968
+ });
969
+ }
938
970
  if (field.prefill) {
939
971
  const ref = dataRef(field.prefill);
940
972
  if (ref.split(".")[0] !== "steps") {
@@ -1366,7 +1398,10 @@ export const MAX_DATA_OPTIONS = 100;
1366
1398
  * column of a table output, or one column of a stored list — as text, without duplicates and
1367
1399
  * empties. Empty when the data is not there (yet).
1368
1400
  */
1369
- export function optionsFromData(ref, outputs, lists = {}) {
1401
+ export function optionsFromData(ref, outputs, lists = {}, cards) {
1402
+ if (cards) {
1403
+ return cardsFromData(ref, outputs, cards).map((c) => c.value);
1404
+ }
1370
1405
  const [head, id, key, column, ...more] = dataRef(ref).split(".");
1371
1406
  let raw = [];
1372
1407
  if (head === "lists" && id && key && !column) {
@@ -1396,6 +1431,61 @@ export function optionsFromData(ref, outputs, lists = {}) {
1396
1431
  }
1397
1432
  return [...seen];
1398
1433
  }
1434
+ /** The rows of a table output as cards: what `optionsFrom` with `cards` finds in the run. */
1435
+ export function cardsFromData(ref, outputs, cards) {
1436
+ const [head, id, key, ...more] = dataRef(ref).split(".");
1437
+ if (head !== "steps" || !id || !key || more.length) {
1438
+ return [];
1439
+ }
1440
+ const json = outputs[id]?.json;
1441
+ const rows = json && typeof json === "object" ? json[key] : undefined;
1442
+ if (!Array.isArray(rows)) {
1443
+ return [];
1444
+ }
1445
+ const cell = (row, column, max = 200) => {
1446
+ const v = column ? row[column] : undefined;
1447
+ if (v === null || v === undefined || typeof v === "object") {
1448
+ return "";
1449
+ }
1450
+ return String(v).trim().slice(0, max);
1451
+ };
1452
+ const out = [];
1453
+ const seen = new Set();
1454
+ for (const raw of rows) {
1455
+ if (!raw || typeof raw !== "object") {
1456
+ continue;
1457
+ }
1458
+ const row = raw;
1459
+ const label = cell(row, cards.label);
1460
+ const value = cell(row, cards.value) || label;
1461
+ if (!value || seen.has(value)) {
1462
+ continue;
1463
+ }
1464
+ seen.add(value);
1465
+ const card = { value, label: label || value };
1466
+ const image = cell(row, cards.image, 2000);
1467
+ const link = cell(row, cards.link, 2000);
1468
+ const subtitle = cell(row, cards.subtitle, 300);
1469
+ const meta = cell(row, cards.meta, 80);
1470
+ if (/^(https?:|data:|\/)/.test(image) || /^[a-zA-Z0-9_-]{6,64}$/.test(image)) {
1471
+ card.image = image;
1472
+ }
1473
+ if (/^https?:\/\//.test(link)) {
1474
+ card.link = link;
1475
+ }
1476
+ if (subtitle) {
1477
+ card.subtitle = subtitle;
1478
+ }
1479
+ if (meta) {
1480
+ card.meta = meta;
1481
+ }
1482
+ out.push(card);
1483
+ if (out.length >= MAX_DATA_OPTIONS) {
1484
+ break;
1485
+ }
1486
+ }
1487
+ return out;
1488
+ }
1399
1489
  // ---------------------------------------------------------------------------
1400
1490
  // Appointment times
1401
1491
  const SLOT_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/;
@@ -0,0 +1,71 @@
1
+ import { type AssetKind, type FieldKind, type Format, type ModelClass, type PageStep, type Step, type ToolId, type WizardDefinition } from "./definition.js";
2
+ import type { Capability } from "./marketplace.js";
3
+ import type { ClosedChoice } from "./run.js";
4
+ /**
5
+ * What a wizard needs beyond a text model, and whether it runs where there is nothing else: a
6
+ * WordPress site with the AI Client, no tools, no plugins, no media models (docs/plans/
7
+ * wordpress-plugin.md, "The check"). One function, computed in the studio, on upload into the
8
+ * plugin and by the gallery, so every place gives the same answer.
9
+ */
10
+ /** Something a step wants beyond a text model, as a stable id every app can word. */
11
+ export type Need = `tool:${ToolId}` | "mcp" | "connections" | `plugin:${string}` | `asset:${AssetKind}` | "film"
12
+ /** A widget runs in the runtime's widget host; the standalone runner has none yet. */
13
+ | "widget" | "widget:video" | `field:${Extract<FieldKind, "audio" | "connection" | "slot" | "location" | "image" | "file">}`
14
+ /** A file the person gives that a later thinking step reads: reading documents is the runtime's. */
15
+ | "field:file-read" | `format:${Format}` | "lists" | "memory" | "each";
16
+ export interface StepNeed {
17
+ stepId: string;
18
+ need: Need;
19
+ /** The step cannot run without it; a soft need is left out and the step runs with less. */
20
+ hard: boolean;
21
+ }
22
+ /** What one step wants beyond a text model. */
23
+ export declare function needs(step: Step, def: WizardDefinition): StepNeed[];
24
+ export interface Fit {
25
+ /** `full`: runs as is. `less`: the choices leading to a hard need are closed, soft needs are left out. `no`: a hard need on a step every run passes through. */
26
+ fit: "full" | "less" | "no";
27
+ notes: StepNeed[];
28
+ }
29
+ /** Whether a wizard runs on its own, with what left out. */
30
+ export declare function standaloneFit(def: WizardDefinition): Fit;
31
+ /** The gallery's capability a need stands for; none for what the gallery has no word for. */
32
+ export declare function capabilityOf(need: Need): Capability | null;
33
+ /**
34
+ * The fit in the fields a marketplace entry already has, so the gallery's chips and entry
35
+ * dialog draw it: `missing` is what the wizard cannot do without here (rose, "nicht
36
+ * eingerichtet"), `optional` what it runs without (amber, "geht auch ohne"), `needs` the
37
+ * plugins behind an account, `without` the result formats that fall away.
38
+ */
39
+ export interface StandaloneFit extends Fit {
40
+ missing: Capability[];
41
+ optional: Capability[];
42
+ needs: string[];
43
+ without: Format[];
44
+ }
45
+ export declare function standaloneEntry(def: WizardDefinition): StandaloneFit;
46
+ /** The steps every run passes through: without one of them the end is not reachable. */
47
+ export declare function unavoidableSteps(def: WizardDefinition): Set<string>;
48
+ /**
49
+ * The steps every path from `from` to the end passes through. A rule on an answer in `known`
50
+ * goes one way; a rule on anything else may go either way.
51
+ */
52
+ export declare function unavoidableFrom(def: WizardDefinition, from: string, known: Record<string, unknown>): Set<string>;
53
+ /** Where step `i` goes when none of its rules holds, as an index; the length = the end. */
54
+ export declare function otherwiseIndex(def: WizardDefinition, i: number, index: Map<string, number>): number;
55
+ /** The choices a page offers: each select's options, a toggle's on and off. */
56
+ export interface PageChoice {
57
+ field: string;
58
+ values: (string | boolean)[];
59
+ }
60
+ export declare function choicesOf(step: PageStep): PageChoice[];
61
+ /**
62
+ * The answers on a page that lead to a step this runtime cannot run: with them the run would
63
+ * stop there, after what came before was paid for. `lacking` says per step what it lacks (model
64
+ * classes on a runtime, needs on a standalone site). The answers given already count; the page's
65
+ * other fields may still go either way. A choice whose every value leads there is left open: the
66
+ * run cannot go around it, and the start already warned. `closedFields` are closed as a whole
67
+ * (no values): a voice note nothing here can listen to.
68
+ */
69
+ export declare function closedChoicesFor(def: WizardDefinition, step: PageStep, values: Record<string, unknown>, lacking: (step: Step) => ModelClass[], closedFields?: (field: PageStep["fields"][number]) => ModelClass[] | null): Record<string, ClosedChoice>;
70
+ /** The answer a closed choice gets instead: its first value that stays open. */
71
+ export declare function openValue(step: PageStep, field: string, closed: ClosedChoice): string | boolean | undefined;