@case-framework/survey-assistant 0.8.0 → 0.9.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 (114) hide show
  1. package/dist/{authoring-references-DbuOKerg.mjs → authoring-references-CmwLc_C8.mjs} +40 -32
  2. package/dist/authoring-references-CmwLc_C8.mjs.map +1 -0
  3. package/dist/capabilities-D55dq-fO.mjs +582 -0
  4. package/dist/capabilities-D55dq-fO.mjs.map +1 -0
  5. package/dist/capabilities-default.d.mts +4 -12
  6. package/dist/capabilities-default.d.mts.map +1 -1
  7. package/dist/capabilities-default.mjs +2 -2
  8. package/dist/capabilities-z95e1mti.d.mts +117 -0
  9. package/dist/capabilities-z95e1mti.d.mts.map +1 -0
  10. package/dist/{constants-B6HzpEsx.d.mts → constants-HL_klgJl.d.mts} +4 -4
  11. package/dist/{constants-B6HzpEsx.d.mts.map → constants-HL_klgJl.d.mts.map} +1 -1
  12. package/dist/{controller-proxy-DEeFl9IA.mjs → controller-proxy-BQ1YsVxJ.mjs} +4 -3
  13. package/dist/controller-proxy-BQ1YsVxJ.mjs.map +1 -0
  14. package/dist/{controller-proxy-D7uQfm5f.d.mts → controller-proxy-Cmzdr9tV.d.mts} +4 -4
  15. package/dist/{controller-proxy-D7uQfm5f.d.mts.map → controller-proxy-Cmzdr9tV.d.mts.map} +1 -1
  16. package/dist/default-D22AKTqE.mjs +233 -0
  17. package/dist/default-D22AKTqE.mjs.map +1 -0
  18. package/dist/{digest-C39WyAWG.d.mts → digest-FnTTDBq2.d.mts} +2 -2
  19. package/dist/digest-FnTTDBq2.d.mts.map +1 -0
  20. package/dist/digest.d.mts +1 -1
  21. package/dist/engine-D950TfvC.mjs +3098 -0
  22. package/dist/engine-D950TfvC.mjs.map +1 -0
  23. package/dist/engine.d.mts +4 -3
  24. package/dist/engine.mjs +3 -3
  25. package/dist/{index-WB5kfnz0.d.mts → index-B8TLBd1G.d.mts} +8 -6
  26. package/dist/index-B8TLBd1G.d.mts.map +1 -0
  27. package/dist/index-CaX3hZmr.d.mts +23813 -0
  28. package/dist/index-CaX3hZmr.d.mts.map +1 -0
  29. package/dist/{index-r5riv4md.d.mts → index-CeUlGkoU.d.mts} +27 -6
  30. package/dist/index-CeUlGkoU.d.mts.map +1 -0
  31. package/dist/{index-D7wT6P3t.d.mts → index-DYHdvSE8.d.mts} +83 -41
  32. package/dist/index-DYHdvSE8.d.mts.map +1 -0
  33. package/dist/lifecycle-DFzxVxpq.d.mts +54346 -0
  34. package/dist/lifecycle-DFzxVxpq.d.mts.map +1 -0
  35. package/dist/{memory-thread-repository-DAnOGIB3.mjs → memory-thread-repository-DmLadygY.mjs} +15 -9
  36. package/dist/{memory-thread-repository-DAnOGIB3.mjs.map → memory-thread-repository-DmLadygY.mjs.map} +1 -1
  37. package/dist/protocol-BQ7uIDYT.mjs +569 -0
  38. package/dist/protocol-BQ7uIDYT.mjs.map +1 -0
  39. package/dist/protocol.d.mts +4 -4
  40. package/dist/protocol.mjs +3 -2
  41. package/dist/{react-C_GY-Fsc.mjs → react-DybJ5pWw.mjs} +17 -11
  42. package/dist/react-DybJ5pWw.mjs.map +1 -0
  43. package/dist/react-integration.d.mts +1 -1
  44. package/dist/react-integration.mjs +1 -1
  45. package/dist/react.d.mts +2 -2
  46. package/dist/react.mjs +2 -2
  47. package/dist/references/assistant-operations.md +190 -215
  48. package/dist/references/core-rules.md +2 -2
  49. package/dist/references/element-types.md +189 -0
  50. package/dist/references/expressions.md +215 -238
  51. package/dist/references/follow-ups.md +151 -0
  52. package/dist/references/localization.md +26 -12
  53. package/dist/references/response-variables.md +3 -3
  54. package/dist/references/rich-text-content.md +22 -43
  55. package/dist/references/source-material-surveys.md +20 -25
  56. package/dist/references/survey-data-model.md +36 -117
  57. package/dist/{request-context-Dg4jSwN1.mjs → request-context-KVh8VjgH.mjs} +4 -4
  58. package/dist/request-context-KVh8VjgH.mjs.map +1 -0
  59. package/dist/server-agent.d.mts +28 -7
  60. package/dist/server-agent.d.mts.map +1 -1
  61. package/dist/server-agent.mjs +33 -25
  62. package/dist/server-agent.mjs.map +1 -1
  63. package/dist/server-runtime.d.mts +6 -5
  64. package/dist/server-runtime.d.mts.map +1 -1
  65. package/dist/server-runtime.mjs +3 -3
  66. package/dist/server-tasks.d.mts +1 -1
  67. package/dist/server-tasks.mjs +1 -1
  68. package/dist/server-tools.d.mts +1 -1
  69. package/dist/server-tools.mjs +1 -1
  70. package/dist/server.d.mts +7 -6
  71. package/dist/server.d.mts.map +1 -1
  72. package/dist/server.mjs +3 -3
  73. package/dist/{tasks-BZEiwgxA.mjs → tasks-Coh5N027.mjs} +16 -15
  74. package/dist/tasks-Coh5N027.mjs.map +1 -0
  75. package/dist/{tasks-B9h3LPam.d.mts → tasks-wb9M-bak.d.mts} +11 -11
  76. package/dist/{tasks-B9h3LPam.d.mts.map → tasks-wb9M-bak.d.mts.map} +1 -1
  77. package/dist/{thread-handlers-Bef0td9N.d.mts → thread-handlers-C3Iya92v.d.mts} +6 -5
  78. package/dist/thread-handlers-C3Iya92v.d.mts.map +1 -0
  79. package/dist/{tools-CEsv-WoO.mjs → tools-D0KBDolR.mjs} +435 -408
  80. package/dist/tools-D0KBDolR.mjs.map +1 -0
  81. package/dist/turn-survey-draft-B34lggSG.d.mts +185 -0
  82. package/dist/turn-survey-draft-B34lggSG.d.mts.map +1 -0
  83. package/dist/ui.d.mts +3 -3
  84. package/dist/ui.d.mts.map +1 -1
  85. package/dist/ui.mjs +35 -23
  86. package/dist/ui.mjs.map +1 -1
  87. package/package.json +7 -7
  88. package/dist/authoring-references-DbuOKerg.mjs.map +0 -1
  89. package/dist/capabilities-CmeeAjEc.d.mts +0 -192
  90. package/dist/capabilities-CmeeAjEc.d.mts.map +0 -1
  91. package/dist/capabilities-DCMA71PP.mjs +0 -58
  92. package/dist/capabilities-DCMA71PP.mjs.map +0 -1
  93. package/dist/controller-proxy-DEeFl9IA.mjs.map +0 -1
  94. package/dist/default-fhSon2RM.mjs +0 -760
  95. package/dist/default-fhSon2RM.mjs.map +0 -1
  96. package/dist/digest-C39WyAWG.d.mts.map +0 -1
  97. package/dist/engine-nXoCWYpQ.mjs +0 -6888
  98. package/dist/engine-nXoCWYpQ.mjs.map +0 -1
  99. package/dist/index-Ciq7vHIs.d.mts +0 -716
  100. package/dist/index-Ciq7vHIs.d.mts.map +0 -1
  101. package/dist/index-D7wT6P3t.d.mts.map +0 -1
  102. package/dist/index-WB5kfnz0.d.mts.map +0 -1
  103. package/dist/index-r5riv4md.d.mts.map +0 -1
  104. package/dist/lifecycle-Dm8u7QFh.d.mts +0 -545
  105. package/dist/lifecycle-Dm8u7QFh.d.mts.map +0 -1
  106. package/dist/protocol-CF4Bh_Ch.mjs +0 -1255
  107. package/dist/protocol-CF4Bh_Ch.mjs.map +0 -1
  108. package/dist/react-C_GY-Fsc.mjs.map +0 -1
  109. package/dist/references/embedded-forms.md +0 -146
  110. package/dist/references/item-types.md +0 -641
  111. package/dist/request-context-Dg4jSwN1.mjs.map +0 -1
  112. package/dist/tasks-BZEiwgxA.mjs.map +0 -1
  113. package/dist/thread-handlers-Bef0td9N.d.mts.map +0 -1
  114. package/dist/tools-CEsv-WoO.mjs.map +0 -1
@@ -0,0 +1,582 @@
1
+ import { z } from "zod";
2
+ import { SURVEY_LOCALIZATION_SURFACES, createCompositionSchema, createFlowItemSchema, elementShape, jsonValueSchema, layoutPolicySchema, richTextImageDimensionSchema, stringRecord } from "@case-framework/survey-core/schema";
3
+ import { SURVEY_EDITOR_ITEM_COLORS } from "@case-framework/survey-core/editor/colors";
4
+ //#region src/protocol/response-settings.ts
5
+ const variableName = z.string().regex(/^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/).max(32);
6
+ const responseNamingEditSchema = z.union([z.object({
7
+ slotId: z.string().min(1),
8
+ variableName
9
+ }).strict(), z.object({
10
+ elementId: z.string().min(1),
11
+ prefix: variableName.optional(),
12
+ rows: stringRecord(z.string(), variableName).optional(),
13
+ columns: stringRecord(z.string(), variableName).optional()
14
+ }).strict()]);
15
+ const responseExportSettingsSchema = z.object({
16
+ mode: z.string().min(1),
17
+ include: z.boolean().optional(),
18
+ categorical: z.enum([
19
+ "codes",
20
+ "labels",
21
+ "ids"
22
+ ]).optional(),
23
+ multiple: z.enum([
24
+ "json",
25
+ "delimited",
26
+ "indicators"
27
+ ]).optional(),
28
+ delimiter: z.string().optional(),
29
+ locale: z.string().optional(),
30
+ optionCodes: stringRecord(z.string(), z.string()).optional(),
31
+ optionLabels: stringRecord(z.string(), z.string()).optional(),
32
+ booleanValues: z.object({
33
+ true: z.string(),
34
+ false: z.string()
35
+ }).optional(),
36
+ precision: z.number().int().nonnegative().optional(),
37
+ durationUnit: z.enum([
38
+ "seconds",
39
+ "minutes",
40
+ "hours",
41
+ "days",
42
+ "weeks",
43
+ "months",
44
+ "years"
45
+ ]).optional(),
46
+ dateFormat: z.object({ pattern: z.string().min(1) }).optional(),
47
+ maskText: z.string().optional()
48
+ }).strict();
49
+ const responseSettingsEditSchema = z.object({
50
+ slotId: z.string().min(1),
51
+ optionCodes: stringRecord(z.string(), z.string().min(1)).optional(),
52
+ exportSettings: responseExportSettingsSchema.optional()
53
+ }).strict();
54
+ const responseSettingsChangesSchema = z.object({
55
+ naming: z.array(responseNamingEditSchema).max(200),
56
+ settings: z.array(responseSettingsEditSchema).max(200)
57
+ });
58
+ //#endregion
59
+ //#region src/protocol/content.ts
60
+ const contentAttributesSchema = stringRecord(z.string(), jsonValueSchema);
61
+ const richTextStyleSchema = z.object({
62
+ weight: z.enum(["strong", "normal"]).optional(),
63
+ italic: z.enum(["italic", "normal"]).optional(),
64
+ underline: z.enum(["underline", "none"]).optional(),
65
+ color: z.enum([
66
+ "primary",
67
+ "accent",
68
+ "default"
69
+ ]).optional()
70
+ });
71
+ const richTextTextInlineSchema = z.object({
72
+ type: z.literal("text"),
73
+ text: z.string().max(2e4),
74
+ style: richTextStyleSchema.optional(),
75
+ attrs: contentAttributesSchema.optional()
76
+ });
77
+ const richTextTemplateInlineSchema = z.object({
78
+ type: z.literal("template"),
79
+ key: z.string().min(1).max(240),
80
+ style: richTextStyleSchema.optional(),
81
+ attrs: contentAttributesSchema.optional()
82
+ });
83
+ const richTextLineBreakInlineSchema = z.object({
84
+ type: z.literal("lineBreak"),
85
+ attrs: contentAttributesSchema.optional()
86
+ });
87
+ const richTextLinkChildInlineSchema = z.discriminatedUnion("type", [
88
+ richTextTextInlineSchema,
89
+ richTextTemplateInlineSchema,
90
+ richTextLineBreakInlineSchema
91
+ ]);
92
+ const richTextLinkInlineSchema = z.object({
93
+ type: z.literal("link"),
94
+ href: z.string().min(1).max(2e3),
95
+ target: z.string().max(120).nullable().optional(),
96
+ rel: z.string().max(240).nullable().optional(),
97
+ title: z.string().max(1e3).nullable().optional(),
98
+ attrs: contentAttributesSchema.optional(),
99
+ children: z.array(richTextLinkChildInlineSchema).max(200)
100
+ });
101
+ const richTextInlineExtensionSchema = z.object({
102
+ type: z.literal("inlineExtension"),
103
+ name: z.string().min(1).max(120),
104
+ attrs: contentAttributesSchema.optional()
105
+ });
106
+ const richTextInlineSchema = z.discriminatedUnion("type", [
107
+ richTextTextInlineSchema,
108
+ richTextTemplateInlineSchema,
109
+ richTextLinkInlineSchema,
110
+ richTextLineBreakInlineSchema,
111
+ richTextInlineExtensionSchema
112
+ ]);
113
+ const textAlignmentSchema = z.enum([
114
+ "left",
115
+ "center",
116
+ "right",
117
+ "justify"
118
+ ]);
119
+ const richTextParagraphBlockSchema = z.object({
120
+ type: z.literal("paragraph"),
121
+ children: z.array(richTextInlineSchema).max(500),
122
+ alignment: textAlignmentSchema.optional(),
123
+ attrs: contentAttributesSchema.optional()
124
+ });
125
+ const richTextHeadingBlockSchema = z.object({
126
+ type: z.literal("heading"),
127
+ level: z.union([z.literal(1), z.literal(2)], { error: "Heading level must be the number 1 (section heading) or 2 (subsection heading); other levels are not supported." }),
128
+ children: z.array(richTextInlineSchema).max(500),
129
+ alignment: textAlignmentSchema.optional(),
130
+ attrs: contentAttributesSchema.optional()
131
+ });
132
+ const richTextListItemBlockSchema = z.object({
133
+ type: z.literal("listItem"),
134
+ children: z.array(richTextParagraphBlockSchema).max(100),
135
+ attrs: contentAttributesSchema.optional()
136
+ });
137
+ const richTextBulletListBlockSchema = z.object({
138
+ type: z.literal("bulletList"),
139
+ items: z.array(richTextListItemBlockSchema).max(100),
140
+ attrs: contentAttributesSchema.optional()
141
+ });
142
+ const richTextImageDimensionSchema$1 = z.union([z.object({
143
+ unit: z.literal("px"),
144
+ value: z.number().finite().nonnegative()
145
+ }), z.object({
146
+ unit: z.literal("%"),
147
+ value: z.number().finite().nonnegative()
148
+ })]);
149
+ const richTextImageSourceSchema = z.discriminatedUnion("type", [z.object({
150
+ type: z.literal("asset"),
151
+ assetId: z.string().min(1).max(240)
152
+ }), z.object({
153
+ type: z.literal("external"),
154
+ url: z.string().min(1).max(2e3)
155
+ })]);
156
+ const richTextImageBlockSchema = z.object({
157
+ type: z.literal("image"),
158
+ source: richTextImageSourceSchema,
159
+ alt: z.string().max(2e3).optional(),
160
+ caption: z.array(richTextParagraphBlockSchema).max(20).optional(),
161
+ size: z.object({
162
+ width: richTextImageDimensionSchema$1.optional(),
163
+ height: richTextImageDimensionSchema$1.optional(),
164
+ maxWidth: richTextImageDimensionSchema$1.optional(),
165
+ maxHeight: richTextImageDimensionSchema$1.optional()
166
+ }).optional(),
167
+ alignment: textAlignmentSchema.optional(),
168
+ attrs: contentAttributesSchema.optional()
169
+ });
170
+ const richTextInfoBoxBlockSchema = z.object({
171
+ type: z.literal("infoBox"),
172
+ tone: z.enum(["info", "warning"]).optional(),
173
+ title: z.array(richTextInlineSchema).max(100).optional(),
174
+ collapsible: z.boolean().optional(),
175
+ defaultOpen: z.boolean().optional(),
176
+ children: z.array(richTextParagraphBlockSchema).max(100),
177
+ attrs: contentAttributesSchema.optional()
178
+ });
179
+ const richTextSeparatorBlockSchema = z.object({
180
+ type: z.literal("separator"),
181
+ attrs: contentAttributesSchema.optional()
182
+ });
183
+ const richTextBlockExtensionSchema = z.object({
184
+ type: z.literal("blockExtension"),
185
+ name: z.string().min(1).max(120),
186
+ attrs: contentAttributesSchema.optional()
187
+ });
188
+ const richTextBlockSchema = z.discriminatedUnion("type", [
189
+ richTextParagraphBlockSchema,
190
+ richTextHeadingBlockSchema,
191
+ richTextBulletListBlockSchema,
192
+ richTextImageBlockSchema,
193
+ richTextInfoBoxBlockSchema,
194
+ richTextSeparatorBlockSchema,
195
+ richTextBlockExtensionSchema
196
+ ]);
197
+ const surveyContentSchema = z.discriminatedUnion("type", [
198
+ z.object({
199
+ type: z.literal("md"),
200
+ content: z.string().max(2e4)
201
+ }),
202
+ z.object({
203
+ type: z.literal("plain"),
204
+ content: z.string().max(2e4)
205
+ }),
206
+ z.object({
207
+ type: z.literal("richText"),
208
+ version: z.literal(1),
209
+ doc: z.object({
210
+ type: z.literal("doc"),
211
+ blocks: z.array(richTextBlockSchema).max(200)
212
+ })
213
+ })
214
+ ]);
215
+ //#endregion
216
+ //#region src/protocol/structure.ts
217
+ /** Envelope only: executable registry definitions validate custom configuration at the receiver. */
218
+ const elementTransportSchema = z.strictObject({
219
+ ...elementShape,
220
+ elementType: z.string().min(1).describe("Exact type from the active element registry. Load the capability schema before authoring unfamiliar configuration."),
221
+ config: stringRecord(z.string(), jsonValueSchema).describe("Type-specific configuration validated by the registered schema, not an arbitrary extension bag. Preserve persistent IDs and use update-response-settings for coding edits.")
222
+ });
223
+ //#endregion
224
+ //#region src/protocol/operations.ts
225
+ const identity = z.string().min(1).max(240).describe("Exact persistent ID from current inspection; never a displayed label.");
226
+ const locale = z.string().trim().min(1).max(40).describe("Actual respondent locale code, such as en, de or nl. Copy an existing code exactly; a translation in a new code introduces a new survey language.");
227
+ const base = { id: z.string().min(1).max(120).optional().describe("Optional operation tracking ID, not an item, element or response ID.") };
228
+ const index = z.number().int().nonnegative().optional().describe("Zero-based insertion position in the current target list. Omit to append; 0 inserts first. Inspect the list before specifying an index.");
229
+ const flowTarget = z.strictObject({
230
+ parentItemId: identity.describe("Exact ID of the destination flow group, including the root group. Never an element or layout ID."),
231
+ index
232
+ });
233
+ const layoutTarget = z.strictObject({
234
+ layoutId: identity.describe("Exact ID of an existing layout group, including one inside a section or option follow-up."),
235
+ index
236
+ });
237
+ const ruleTransfer = z.enum(["reject", "move-with-targets"]).optional().describe("Defaults to reject if a move crosses validation-rule ownership. Explicit move-with-targets is allowed only when every target of each affected rule moves together.");
238
+ const localizationRefSchema = z.discriminatedUnion("scope", [z.strictObject({
239
+ scope: z.literal("content"),
240
+ ownerId: identity,
241
+ role: z.string().min(1).max(240)
242
+ }), z.strictObject({
243
+ scope: z.literal("survey"),
244
+ surface: z.enum(SURVEY_LOCALIZATION_SURFACES),
245
+ contentKey: z.string().min(1).max(240)
246
+ })]);
247
+ const contentWrite = {
248
+ locale,
249
+ plainText: z.string().optional().describe("Unformatted respondent wording, preserved as supplied. Use exactly one of plainText or content; Markdown syntax is not rendered formatting."),
250
+ content: surveyContentSchema.nullable().optional().describe("Canonical localized content, or null to clear this single surface. For structured formatting load rich-text-content; do not replace sibling translations.")
251
+ };
252
+ const exactlyOneContent = (value) => value.plainText !== void 0 !== (value.content !== void 0);
253
+ const contentRequired = { message: "Provide exactly one of plainText or content; use content: null to clear." };
254
+ const ownerTranslationSchema = z.strictObject({
255
+ ...contentWrite,
256
+ ownerId: identity,
257
+ role: z.string().min(1).max(240)
258
+ }).refine(exactlyOneContent, contentRequired);
259
+ const translations = z.array(ownerTranslationSchema).max(1e3).optional().describe("Atomic respondent wording for exact content owner IDs and declared roles, in each requested locale. Include labels for new inputs/options and preserve existing languages on duplication.");
260
+ const bodySchema = createCompositionSchema(elementTransportSchema);
261
+ const pointer = z.string().max(1e3).describe("Exact JSON Pointer from inspection. Escape ~ as ~0 and / as ~1 within a segment.");
262
+ const jsonPatchOperationSchema = z.discriminatedUnion("op", [
263
+ z.strictObject({
264
+ op: z.literal("add"),
265
+ path: pointer,
266
+ value: jsonValueSchema
267
+ }),
268
+ z.strictObject({
269
+ op: z.literal("replace"),
270
+ path: pointer,
271
+ value: jsonValueSchema
272
+ }),
273
+ z.strictObject({
274
+ op: z.literal("test"),
275
+ path: pointer,
276
+ value: jsonValueSchema
277
+ }),
278
+ z.strictObject({
279
+ op: z.literal("remove"),
280
+ path: pointer
281
+ }),
282
+ z.strictObject({
283
+ op: z.literal("move"),
284
+ from: pointer,
285
+ path: pointer
286
+ }),
287
+ z.strictObject({
288
+ op: z.literal("copy"),
289
+ from: pointer,
290
+ path: pointer
291
+ })
292
+ ]);
293
+ const patches = z.array(jsonPatchOperationSchema).min(1).max(100).describe("Use exact inspected JSON Pointers. Parent paths must exist; add appends with /-. replace requires an existing property.");
294
+ const createItemOperationSchema = z.strictObject({
295
+ ...base,
296
+ kind: z.literal("create-item"),
297
+ target: flowTarget,
298
+ item: createFlowItemSchema(bodySchema).describe("Complete new flow item: content, group or page-break. A content item owns config.body.blocks with layouts/elements or sections. Create groups empty, then add children. New owned IDs must be unique survey-wide."),
299
+ translations
300
+ });
301
+ const insertElementOperationSchema = z.strictObject({
302
+ ...base,
303
+ kind: z.literal("insert-element"),
304
+ target: layoutTarget,
305
+ element: elementTransportSchema.describe("Complete registered element with fresh owner and slot IDs. Load this elementType capability and its canonical schema; arbitrary configuration is validated by the active registry."),
306
+ translations
307
+ });
308
+ const insertPresetOperationSchema = z.strictObject({
309
+ ...base,
310
+ kind: z.literal("insert-preset"),
311
+ elementType: identity.describe("Exact installed element type advertised by the capability manifest, including custom elements when supported."),
312
+ presetId: identity.describe("Exact creation preset advertised for elementType. Never guess a preset ID; inspect the generated IDs before subsequent edits."),
313
+ locale,
314
+ target: z.union([flowTarget, layoutTarget])
315
+ });
316
+ const insertBlocksOperationSchema = z.strictObject({
317
+ ...base,
318
+ kind: z.literal("insert-blocks"),
319
+ bodyOwnerId: identity.describe("Exact owner of an existing composition body: content item, semantic section or follow-up trigger. This is not a layout ID."),
320
+ index,
321
+ body: bodySchema.describe("New blocks to insert, not a replacement for the existing body. One section level and one option-follow-up level are enforced independently."),
322
+ translations
323
+ });
324
+ const updateContentOperationSchema = z.strictObject({
325
+ ...base,
326
+ kind: z.literal("update-content"),
327
+ ref: localizationRefSchema,
328
+ ...contentWrite
329
+ }).refine(exactlyOneContent, contentRequired);
330
+ const patchElementConfigOperationSchema = z.strictObject({
331
+ ...base,
332
+ kind: z.literal("patch-element-config"),
333
+ elementId: identity,
334
+ patches,
335
+ translations
336
+ });
337
+ const patchItemConfigOperationSchema = z.strictObject({
338
+ ...base,
339
+ kind: z.literal("patch-item-config"),
340
+ itemId: identity,
341
+ patches,
342
+ translations
343
+ });
344
+ const updateItemLabelOperationSchema = z.strictObject({
345
+ ...base,
346
+ kind: z.literal("update-item-label"),
347
+ itemId: identity,
348
+ itemLabel: z.string().max(500).describe("Internal editor label (the Add label control), never shown to respondents. Use update-content for question titles or input/option labels.")
349
+ });
350
+ const updateItemColorOperationSchema = z.strictObject({
351
+ ...base,
352
+ kind: z.literal("update-item-color"),
353
+ itemId: identity,
354
+ color: z.enum(SURVEY_EDITOR_ITEM_COLORS).describe("Editor-only palette swatch. Does not alter participant content or imply answer meaning.")
355
+ });
356
+ const removeItemOperationSchema = z.strictObject({
357
+ ...base,
358
+ kind: z.literal("remove-item"),
359
+ itemId: identity,
360
+ includeChildren: z.boolean().optional().describe("Set true only when intentionally deleting a flow group and its complete subtree. Deletion is refused while authored references depend on removed identities.")
361
+ });
362
+ const moveItemOperationSchema = z.strictObject({
363
+ ...base,
364
+ kind: z.literal("move-item"),
365
+ itemId: identity,
366
+ target: flowTarget
367
+ });
368
+ const reorderItemsOperationSchema = z.strictObject({
369
+ ...base,
370
+ kind: z.literal("reorder-items"),
371
+ parentItemId: identity,
372
+ itemIds: z.array(identity).max(1e3).describe("Include every existing child item ID exactly once, in the desired order.")
373
+ });
374
+ const moveElementOperationSchema = z.strictObject({
375
+ ...base,
376
+ kind: z.literal("move-element"),
377
+ elementId: identity,
378
+ target: layoutTarget,
379
+ ruleTransfer
380
+ });
381
+ const moveBlockOperationSchema = z.strictObject({
382
+ ...base,
383
+ kind: z.literal("move-block"),
384
+ blockId: identity,
385
+ bodyOwnerId: identity.describe("Exact owner of an existing composition body: content item, semantic section or follow-up trigger. This is not a layout ID."),
386
+ index,
387
+ ruleTransfer
388
+ });
389
+ const removeContentOperationSchema = z.strictObject({
390
+ ...base,
391
+ kind: z.literal("remove-content"),
392
+ ownerId: identity.describe("Exact element or block owner to remove. External references must be repaired first; this is not a request to clear its wording.")
393
+ });
394
+ const updateLayoutOperationSchema = z.strictObject({
395
+ ...base,
396
+ kind: z.literal("update-layout"),
397
+ layoutId: identity,
398
+ layout: layoutPolicySchema.describe("Complete layout policy; elements and IDs are preserved. Automatic maxColumns is a maximum and supports responsive wrapping; advanced mode supplies each breakpoint explicitly.")
399
+ });
400
+ const dimension = richTextImageDimensionSchema;
401
+ const updatePlacedImageOperationSchema = z.strictObject({
402
+ ...base,
403
+ kind: z.literal("update-placed-image"),
404
+ ref: localizationRefSchema,
405
+ locale,
406
+ imageIndex: z.number().int().nonnegative().describe("Zero-based image-only index within the inspected rich-text surface, not its overall block index."),
407
+ expectedAssetId: identity.optional().describe("Inspected current local asset ID, used to reject a stale placement instead of editing the wrong image."),
408
+ changes: z.strictObject({
409
+ source: z.discriminatedUnion("type", [z.strictObject({
410
+ type: z.literal("asset"),
411
+ assetId: identity
412
+ }), z.strictObject({
413
+ type: z.literal("external"),
414
+ url: z.string().min(1)
415
+ })]).optional(),
416
+ alt: z.string().nullable().optional(),
417
+ caption: z.string().nullable().optional(),
418
+ width: dimension.nullable().optional(),
419
+ height: dimension.nullable().optional(),
420
+ maxWidth: dimension.nullable().optional(),
421
+ maxHeight: dimension.nullable().optional(),
422
+ alignment: z.enum([
423
+ "left",
424
+ "center",
425
+ "right"
426
+ ]).nullable().optional()
427
+ })
428
+ });
429
+ const updateSurveyMetadataOperationSchema = z.strictObject({
430
+ ...base,
431
+ kind: z.literal("update-survey-metadata"),
432
+ values: stringRecord(z.string().min(1), z.string().nullable()).describe("Survey metadata entries to set; null deletes an entry. Unmentioned entries stay unchanged.")
433
+ });
434
+ const updateSurveyPaginationOperationSchema = z.strictObject({
435
+ ...base,
436
+ kind: z.literal("update-survey-pagination"),
437
+ value: z.strictObject({
438
+ large: z.number().int().positive(),
439
+ small: z.number().int().positive()
440
+ }).nullable()
441
+ });
442
+ const updateSurveyTranslationOperationSchema = z.strictObject({
443
+ ...base,
444
+ kind: z.literal("update-survey-translation"),
445
+ surface: z.enum(SURVEY_LOCALIZATION_SURFACES),
446
+ contentKey: z.string().min(1),
447
+ ...contentWrite
448
+ }).refine(exactlyOneContent, contentRequired);
449
+ const addSurveyLocaleOperationSchema = z.strictObject({
450
+ ...base,
451
+ kind: z.literal("add-survey-locale"),
452
+ locale
453
+ });
454
+ const removeSurveyLocaleOperationSchema = z.strictObject({
455
+ ...base,
456
+ kind: z.literal("remove-survey-locale"),
457
+ locale
458
+ });
459
+ const assetMetadata = z.strictObject({
460
+ name: z.string().optional(),
461
+ filename: z.string().optional(),
462
+ alt: z.string().optional(),
463
+ width: z.number().int().positive().optional(),
464
+ height: z.number().int().positive().optional()
465
+ });
466
+ const setImageAssetOperationSchema = z.strictObject({
467
+ ...base,
468
+ kind: z.literal("set-image-asset"),
469
+ assetId: identity,
470
+ asset: z.strictObject({
471
+ kind: z.literal("image"),
472
+ source: z.strictObject({
473
+ type: z.literal("embedded"),
474
+ mediaType: z.string().regex(/^image\//),
475
+ encoding: z.literal("base64"),
476
+ data: z.string().min(1).max(8e6)
477
+ }),
478
+ metadata: assetMetadata.optional()
479
+ })
480
+ });
481
+ const updateImageAssetMetadataOperationSchema = z.strictObject({
482
+ ...base,
483
+ kind: z.literal("update-image-asset-metadata"),
484
+ assetId: identity,
485
+ metadata: z.strictObject({
486
+ name: z.string().nullable().optional(),
487
+ filename: z.string().nullable().optional(),
488
+ alt: z.string().nullable().optional(),
489
+ width: z.number().int().positive().nullable().optional(),
490
+ height: z.number().int().positive().nullable().optional()
491
+ })
492
+ });
493
+ const removeImageAssetOperationSchema = z.strictObject({
494
+ ...base,
495
+ kind: z.literal("remove-image-asset"),
496
+ assetId: identity
497
+ });
498
+ const surveyPatchOperationSchema = z.strictObject({
499
+ ...base,
500
+ kind: z.literal("survey-json-patch"),
501
+ patches
502
+ });
503
+ const updateResponseSettingsOperationSchema = responseSettingsChangesSchema.extend({
504
+ ...base,
505
+ kind: z.literal("update-response-settings")
506
+ }).strict();
507
+ const surveyOperationSchemasByKind = {
508
+ "create-item": createItemOperationSchema,
509
+ "insert-element": insertElementOperationSchema,
510
+ "insert-preset": insertPresetOperationSchema,
511
+ "insert-blocks": insertBlocksOperationSchema,
512
+ "update-content": updateContentOperationSchema,
513
+ "patch-element-config": patchElementConfigOperationSchema,
514
+ "patch-item-config": patchItemConfigOperationSchema,
515
+ "update-item-label": updateItemLabelOperationSchema,
516
+ "update-item-color": updateItemColorOperationSchema,
517
+ "remove-item": removeItemOperationSchema,
518
+ "move-item": moveItemOperationSchema,
519
+ "reorder-items": reorderItemsOperationSchema,
520
+ "move-element": moveElementOperationSchema,
521
+ "move-block": moveBlockOperationSchema,
522
+ "remove-content": removeContentOperationSchema,
523
+ "update-layout": updateLayoutOperationSchema,
524
+ "update-placed-image": updatePlacedImageOperationSchema,
525
+ "update-survey-metadata": updateSurveyMetadataOperationSchema,
526
+ "update-survey-pagination": updateSurveyPaginationOperationSchema,
527
+ "update-survey-translation": updateSurveyTranslationOperationSchema,
528
+ "add-survey-locale": addSurveyLocaleOperationSchema,
529
+ "remove-survey-locale": removeSurveyLocaleOperationSchema,
530
+ "set-image-asset": setImageAssetOperationSchema,
531
+ "update-image-asset-metadata": updateImageAssetMetadataOperationSchema,
532
+ "remove-image-asset": removeImageAssetOperationSchema,
533
+ "survey-json-patch": surveyPatchOperationSchema,
534
+ "update-response-settings": updateResponseSettingsOperationSchema
535
+ };
536
+ const surveyOperationSchema = z.discriminatedUnion("kind", [createItemOperationSchema, ...Object.values(surveyOperationSchemasByKind).filter((schema) => schema !== createItemOperationSchema)]);
537
+ const SURVEY_OPERATION_KINDS = Object.freeze(Object.keys(surveyOperationSchemasByKind));
538
+ const surveyValidationIssueSchema = z.object({
539
+ severity: z.enum(["error", "warning"]),
540
+ code: z.string(),
541
+ message: z.string(),
542
+ operationIndex: z.number().int().nonnegative().optional(),
543
+ operationId: z.string().optional(),
544
+ itemId: z.string().optional()
545
+ });
546
+ const surveyValidationResultSchema = z.object({
547
+ valid: z.boolean(),
548
+ issues: z.array(surveyValidationIssueSchema),
549
+ warnings: z.array(surveyValidationIssueSchema),
550
+ normalizedOperations: z.array(surveyOperationSchema)
551
+ });
552
+ //#endregion
553
+ //#region src/protocol/capabilities.ts
554
+ const assistantElementCreateModeSchema = z.enum([
555
+ "deterministic",
556
+ "interactive-only",
557
+ "unsupported"
558
+ ]);
559
+ const assistantElementAuthoringSchema = z.strictObject({
560
+ compactHint: z.string().min(1).max(240).optional(),
561
+ configSummary: z.string().min(1).max(1e3).optional()
562
+ });
563
+ const assistantCreationPresetSchema = z.strictObject({ id: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/) });
564
+ const assistantElementTypeManifestSchema = z.strictObject({
565
+ elementType: z.string().min(1),
566
+ capabilityVersion: z.string().min(1),
567
+ displayName: z.string().min(1),
568
+ description: z.string().optional(),
569
+ create: assistantElementCreateModeSchema,
570
+ supportedOperations: z.array(z.enum(SURVEY_OPERATION_KINDS)),
571
+ creationPresets: z.array(assistantCreationPresetSchema).max(100).optional(),
572
+ referenceTopics: z.array(z.string().min(1)).optional(),
573
+ authoring: assistantElementAuthoringSchema.optional()
574
+ });
575
+ const surveyAssistantCapabilityManifestSchema = z.strictObject({
576
+ digest: z.string().min(1),
577
+ elementTypes: z.array(assistantElementTypeManifestSchema)
578
+ });
579
+ //#endregion
580
+ export { updateContentOperationSchema as A, elementTransportSchema as B, reorderItemsOperationSchema as C, surveyPatchOperationSchema as D, surveyOperationSchemasByKind as E, updatePlacedImageOperationSchema as F, responseSettingsChangesSchema as G, surveyContentSchema as H, updateResponseSettingsOperationSchema as I, responseSettingsEditSchema as K, updateSurveyMetadataOperationSchema as L, updateItemColorOperationSchema as M, updateItemLabelOperationSchema as N, surveyValidationIssueSchema as O, updateLayoutOperationSchema as P, updateSurveyPaginationOperationSchema as R, removeSurveyLocaleOperationSchema as S, surveyOperationSchema as T, responseExportSettingsSchema as U, jsonValueSchema as V, responseNamingEditSchema as W, patchElementConfigOperationSchema as _, SURVEY_OPERATION_KINDS as a, removeImageAssetOperationSchema as b, insertBlocksOperationSchema as c, jsonPatchOperationSchema as d, localizationRefSchema as f, ownerTranslationSchema as g, moveItemOperationSchema as h, surveyAssistantCapabilityManifestSchema as i, updateImageAssetMetadataOperationSchema as j, surveyValidationResultSchema as k, insertElementOperationSchema as l, moveElementOperationSchema as m, assistantElementCreateModeSchema as n, addSurveyLocaleOperationSchema as o, moveBlockOperationSchema as p, assistantElementTypeManifestSchema as r, createItemOperationSchema as s, assistantElementAuthoringSchema as t, insertPresetOperationSchema as u, patchItemConfigOperationSchema as v, setImageAssetOperationSchema as w, removeItemOperationSchema as x, removeContentOperationSchema as y, updateSurveyTranslationOperationSchema as z };
581
+
582
+ //# sourceMappingURL=capabilities-D55dq-fO.mjs.map