@case-framework/survey-assistant 0.1.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.
- package/README.md +212 -0
- package/dist/authoring-references-Cy8J-DWt.d.mts +48 -0
- package/dist/authoring-references-Cy8J-DWt.d.mts.map +1 -0
- package/dist/authoring-references-X6uRaWuf.mjs +68 -0
- package/dist/authoring-references-X6uRaWuf.mjs.map +1 -0
- package/dist/capabilities-B6tvE7fK.mjs +66 -0
- package/dist/capabilities-B6tvE7fK.mjs.map +1 -0
- package/dist/capabilities-DvSKtjAw.d.mts +182 -0
- package/dist/capabilities-DvSKtjAw.d.mts.map +1 -0
- package/dist/capabilities-default.d.mts +15 -0
- package/dist/capabilities-default.d.mts.map +1 -0
- package/dist/capabilities-default.mjs +347 -0
- package/dist/capabilities-default.mjs.map +1 -0
- package/dist/constants-CFUWrRtl.mjs +7 -0
- package/dist/constants-CFUWrRtl.mjs.map +1 -0
- package/dist/constants-Jw0k8ojS.d.mts +67 -0
- package/dist/constants-Jw0k8ojS.d.mts.map +1 -0
- package/dist/controller-proxy-BRDusFiO.d.mts +57 -0
- package/dist/controller-proxy-BRDusFiO.d.mts.map +1 -0
- package/dist/controller-proxy-Duxo2IFE.mjs +92 -0
- package/dist/controller-proxy-Duxo2IFE.mjs.map +1 -0
- package/dist/digest-BsoVq49o.d.mts +9 -0
- package/dist/digest-BsoVq49o.d.mts.map +1 -0
- package/dist/digest.d.mts +2 -0
- package/dist/digest.mjs +20 -0
- package/dist/digest.mjs.map +1 -0
- package/dist/engine-sPvuixWg.mjs +4857 -0
- package/dist/engine-sPvuixWg.mjs.map +1 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +4 -0
- package/dist/index-BWNHkpkh.d.mts +187 -0
- package/dist/index-BWNHkpkh.d.mts.map +1 -0
- package/dist/index-CUqbBjkc.d.mts +641 -0
- package/dist/index-CUqbBjkc.d.mts.map +1 -0
- package/dist/index-MpEMQzTm.d.mts +123 -0
- package/dist/index-MpEMQzTm.d.mts.map +1 -0
- package/dist/index-TFtvBiSQ.d.mts +1149 -0
- package/dist/index-TFtvBiSQ.d.mts.map +1 -0
- package/dist/memory-thread-repository-CJkkVE2-.mjs +718 -0
- package/dist/memory-thread-repository-CJkkVE2-.mjs.map +1 -0
- package/dist/protocol-DV0ka9WT.mjs +1032 -0
- package/dist/protocol-DV0ka9WT.mjs.map +1 -0
- package/dist/protocol.d.mts +3 -0
- package/dist/protocol.mjs +2 -0
- package/dist/react-VuYe-cPh.mjs +521 -0
- package/dist/react-VuYe-cPh.mjs.map +1 -0
- package/dist/react-integration.d.mts +2 -0
- package/dist/react-integration.mjs +3 -0
- package/dist/react.d.mts +3 -0
- package/dist/react.mjs +4 -0
- package/dist/references/assistant-operations.md +287 -0
- package/dist/references/core-rules.md +11 -0
- package/dist/references/embedded-forms.md +80 -0
- package/dist/references/expressions.md +301 -0
- package/dist/references/item-types.md +364 -0
- package/dist/references/localization.md +25 -0
- package/dist/references/rich-text-content.md +193 -0
- package/dist/references/source-material-surveys.md +60 -0
- package/dist/references/survey-data-model.md +109 -0
- package/dist/references/survey-quality.md +23 -0
- package/dist/request-context-jcmXT_Q2.mjs +44 -0
- package/dist/request-context-jcmXT_Q2.mjs.map +1 -0
- package/dist/request-guardrails-C59IWnH8.mjs +73 -0
- package/dist/request-guardrails-C59IWnH8.mjs.map +1 -0
- package/dist/server-agent.d.mts +131 -0
- package/dist/server-agent.d.mts.map +1 -0
- package/dist/server-agent.mjs +229 -0
- package/dist/server-agent.mjs.map +1 -0
- package/dist/server-runtime.d.mts +123 -0
- package/dist/server-runtime.d.mts.map +1 -0
- package/dist/server-runtime.mjs +296 -0
- package/dist/server-runtime.mjs.map +1 -0
- package/dist/server-tasks.d.mts +78 -0
- package/dist/server-tasks.d.mts.map +1 -0
- package/dist/server-tasks.mjs +253 -0
- package/dist/server-tasks.mjs.map +1 -0
- package/dist/server-tools.d.mts +2 -0
- package/dist/server-tools.mjs +2 -0
- package/dist/server.d.mts +52 -0
- package/dist/server.d.mts.map +1 -0
- package/dist/server.mjs +6 -0
- package/dist/storage-postgres.d.mts +37 -0
- package/dist/storage-postgres.d.mts.map +1 -0
- package/dist/storage-postgres.mjs +167 -0
- package/dist/storage-postgres.mjs.map +1 -0
- package/dist/thread-documents-DamIq9Od.d.mts +91 -0
- package/dist/thread-documents-DamIq9Od.d.mts.map +1 -0
- package/dist/thread-handlers-DpynUc64.d.mts +112 -0
- package/dist/thread-handlers-DpynUc64.d.mts.map +1 -0
- package/dist/tools-Hz2p7vyv.mjs +1879 -0
- package/dist/tools-Hz2p7vyv.mjs.map +1 -0
- package/dist/ui.css +2 -0
- package/dist/ui.d.mts +63 -0
- package/dist/ui.d.mts.map +1 -0
- package/dist/ui.mjs +2238 -0
- package/dist/ui.mjs.map +1 -0
- package/package.json +166 -0
- package/ui.css.d.ts +3 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { r as createSurveyAssistantCapabilities } from "./capabilities-B6tvE7fK.mjs";
|
|
2
|
+
import { ValueType } from "@case-framework/survey-core";
|
|
3
|
+
//#region src/capabilities/default.ts
|
|
4
|
+
const COMMON_OPERATIONS = [
|
|
5
|
+
"create-item",
|
|
6
|
+
"update-item-key",
|
|
7
|
+
"update-item-label",
|
|
8
|
+
"update-item-color",
|
|
9
|
+
"update-item-translation",
|
|
10
|
+
"update-placed-image",
|
|
11
|
+
"patch-item-config",
|
|
12
|
+
"remove-item",
|
|
13
|
+
"move-item",
|
|
14
|
+
"survey-json-patch"
|
|
15
|
+
];
|
|
16
|
+
const QUESTION_CONTENT_SURFACES = [
|
|
17
|
+
{
|
|
18
|
+
key: "title",
|
|
19
|
+
role: "primary",
|
|
20
|
+
format: "rich",
|
|
21
|
+
requiredOnCreate: true,
|
|
22
|
+
aliases: [
|
|
23
|
+
"content",
|
|
24
|
+
"label",
|
|
25
|
+
"prompt",
|
|
26
|
+
"question",
|
|
27
|
+
"text"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
key: "subtitle",
|
|
32
|
+
role: "secondary",
|
|
33
|
+
format: "rich",
|
|
34
|
+
aliases: ["subheading", "subtext"]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
key: "topContent",
|
|
38
|
+
role: "secondary",
|
|
39
|
+
format: "rich",
|
|
40
|
+
aliases: ["preContent", "preResponse"]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: "bottomContent",
|
|
44
|
+
role: "secondary",
|
|
45
|
+
format: "rich",
|
|
46
|
+
aliases: ["postContent", "postResponse"]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: "cardFooter",
|
|
50
|
+
role: "secondary",
|
|
51
|
+
format: "rich",
|
|
52
|
+
aliases: ["footer"]
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
const FIELD_CONTENT_SURFACES = [
|
|
56
|
+
"label",
|
|
57
|
+
"description",
|
|
58
|
+
"error",
|
|
59
|
+
"placeholder",
|
|
60
|
+
"unit",
|
|
61
|
+
"checkedLabel",
|
|
62
|
+
"uncheckedLabel"
|
|
63
|
+
].map((key) => ({
|
|
64
|
+
key: `fields.<fieldId>.${key}`,
|
|
65
|
+
role: key === "error" ? "validation" : "field",
|
|
66
|
+
format: "rich",
|
|
67
|
+
pattern: true
|
|
68
|
+
}));
|
|
69
|
+
const createManifest = (manifest) => ({
|
|
70
|
+
capabilityVersion: "1",
|
|
71
|
+
...manifest
|
|
72
|
+
});
|
|
73
|
+
const STRUCTURE_REFERENCE = {
|
|
74
|
+
topic: "item-types",
|
|
75
|
+
markdown: "Groups are containers. Create a group without child ids, then create or move children through separate operations. Page breaks are standalone structural boundaries."
|
|
76
|
+
};
|
|
77
|
+
const QUESTION_REFERENCE = {
|
|
78
|
+
topic: "item-types",
|
|
79
|
+
markdown: "Question titles and supporting text are translations. Configuration stores response behavior; respondent-visible option and field labels use the declared dynamic content surfaces."
|
|
80
|
+
};
|
|
81
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
82
|
+
const getFieldValueType = (field) => {
|
|
83
|
+
switch (field.type) {
|
|
84
|
+
case "number":
|
|
85
|
+
case "slider": return ValueType.number;
|
|
86
|
+
case "datepicker": return ValueType.date;
|
|
87
|
+
case "switch": return ValueType.boolean;
|
|
88
|
+
default: return ValueType.string;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const deriveFormResponseSlots = (config, prefix) => {
|
|
92
|
+
if (!isRecord(config) || !Array.isArray(config.fieldGroups)) return {};
|
|
93
|
+
const slots = {};
|
|
94
|
+
for (const group of config.fieldGroups.filter(isRecord)) {
|
|
95
|
+
if (!Array.isArray(group.fields)) continue;
|
|
96
|
+
for (const field of group.fields.filter(isRecord)) {
|
|
97
|
+
if (typeof field.key !== "string" || field.key.length === 0) continue;
|
|
98
|
+
slots[prefix ? `${prefix}.${field.key}` : field.key] = getFieldValueType(field);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return slots;
|
|
102
|
+
};
|
|
103
|
+
const deriveChoiceResponseSlots = (item) => {
|
|
104
|
+
const config = isRecord(item.config) ? item.config : {};
|
|
105
|
+
const slots = { [typeof config.id === "string" && config.id.length > 0 ? config.id : item.id]: config.maxSelection === 1 ? ValueType.reference : ValueType.referenceArray };
|
|
106
|
+
if (Array.isArray(config.options)) for (const option of config.options.filter(isRecord)) {
|
|
107
|
+
if (typeof option.id !== "string" || !option.embeddedForm) continue;
|
|
108
|
+
Object.assign(slots, deriveFormResponseSlots(option.embeddedForm, `embedded.${option.id}`));
|
|
109
|
+
}
|
|
110
|
+
return slots;
|
|
111
|
+
};
|
|
112
|
+
const rootItemAssistantCapability = { manifest: createManifest({
|
|
113
|
+
itemType: "root",
|
|
114
|
+
displayName: "Survey root",
|
|
115
|
+
description: "The existing root container. A second root cannot be created.",
|
|
116
|
+
create: "unsupported",
|
|
117
|
+
supportedOperations: [
|
|
118
|
+
"update-item-key",
|
|
119
|
+
"update-item-label",
|
|
120
|
+
"update-item-color"
|
|
121
|
+
],
|
|
122
|
+
contentSurfaces: [],
|
|
123
|
+
referenceTopics: ["survey-data-model", "item-types"]
|
|
124
|
+
}) };
|
|
125
|
+
const groupItemAssistantCapability = {
|
|
126
|
+
manifest: createManifest({
|
|
127
|
+
itemType: "group",
|
|
128
|
+
displayName: "Group",
|
|
129
|
+
description: "A structural container whose children are created as separate items.",
|
|
130
|
+
defaultItemKeyPrefix: "group",
|
|
131
|
+
create: "deterministic",
|
|
132
|
+
supportedOperations: [...COMMON_OPERATIONS, "reorder-items"],
|
|
133
|
+
contentSurfaces: [{
|
|
134
|
+
key: "title",
|
|
135
|
+
role: "primary",
|
|
136
|
+
format: "rich",
|
|
137
|
+
aliases: [
|
|
138
|
+
"content",
|
|
139
|
+
"label",
|
|
140
|
+
"name",
|
|
141
|
+
"text"
|
|
142
|
+
]
|
|
143
|
+
}],
|
|
144
|
+
referenceTopics: ["survey-data-model", "item-types"]
|
|
145
|
+
}),
|
|
146
|
+
references: [STRUCTURE_REFERENCE]
|
|
147
|
+
};
|
|
148
|
+
const pageBreakItemAssistantCapability = {
|
|
149
|
+
manifest: createManifest({
|
|
150
|
+
itemType: "page-break",
|
|
151
|
+
displayName: "Page break",
|
|
152
|
+
description: "A structural page boundary.",
|
|
153
|
+
defaultItemKeyPrefix: "page",
|
|
154
|
+
create: "deterministic",
|
|
155
|
+
supportedOperations: COMMON_OPERATIONS,
|
|
156
|
+
contentSurfaces: [{
|
|
157
|
+
key: "title",
|
|
158
|
+
role: "primary",
|
|
159
|
+
format: "rich",
|
|
160
|
+
aliases: [
|
|
161
|
+
"content",
|
|
162
|
+
"label",
|
|
163
|
+
"name",
|
|
164
|
+
"text"
|
|
165
|
+
]
|
|
166
|
+
}],
|
|
167
|
+
referenceTopics: ["survey-data-model", "item-types"]
|
|
168
|
+
}),
|
|
169
|
+
references: [STRUCTURE_REFERENCE]
|
|
170
|
+
};
|
|
171
|
+
const infoItemAssistantCapability = {
|
|
172
|
+
manifest: createManifest({
|
|
173
|
+
itemType: "infoItem",
|
|
174
|
+
displayName: "Info",
|
|
175
|
+
description: "Display-only formatted content without a response slot.",
|
|
176
|
+
defaultItemKeyPrefix: "info",
|
|
177
|
+
create: "deterministic",
|
|
178
|
+
supportedOperations: COMMON_OPERATIONS,
|
|
179
|
+
contentSurfaces: [{
|
|
180
|
+
key: "content",
|
|
181
|
+
role: "primary",
|
|
182
|
+
format: "rich",
|
|
183
|
+
requiredOnCreate: true,
|
|
184
|
+
aliases: [
|
|
185
|
+
"body",
|
|
186
|
+
"label",
|
|
187
|
+
"prompt",
|
|
188
|
+
"question",
|
|
189
|
+
"text",
|
|
190
|
+
"title"
|
|
191
|
+
]
|
|
192
|
+
}],
|
|
193
|
+
referenceTopics: ["item-types", "rich-text-content"]
|
|
194
|
+
}),
|
|
195
|
+
references: [{
|
|
196
|
+
topic: "rich-text-content",
|
|
197
|
+
markdown: "Info content uses the rich `content` surface. Markdown strings are not parsed; send structured rich text when formatting matters."
|
|
198
|
+
}]
|
|
199
|
+
};
|
|
200
|
+
const choiceItemAssistantCapability = {
|
|
201
|
+
manifest: createManifest({
|
|
202
|
+
itemType: "choiceItem",
|
|
203
|
+
displayName: "Choice question",
|
|
204
|
+
description: "A single- or multiple-choice question with optional embedded forms.",
|
|
205
|
+
defaultItemKeyPrefix: "choice",
|
|
206
|
+
create: "deterministic",
|
|
207
|
+
supportedOperations: [
|
|
208
|
+
...COMMON_OPERATIONS,
|
|
209
|
+
"add-choice-option",
|
|
210
|
+
"update-choice-option-label",
|
|
211
|
+
"remove-choice-option",
|
|
212
|
+
"reorder-choice-options",
|
|
213
|
+
"upsert-form-field-group",
|
|
214
|
+
"remove-form-field-group",
|
|
215
|
+
"reorder-form-field-groups",
|
|
216
|
+
"upsert-form-field",
|
|
217
|
+
"remove-form-field",
|
|
218
|
+
"move-form-field",
|
|
219
|
+
"set-embedded-form",
|
|
220
|
+
"remove-embedded-form"
|
|
221
|
+
],
|
|
222
|
+
contentSurfaces: [
|
|
223
|
+
...QUESTION_CONTENT_SURFACES,
|
|
224
|
+
{
|
|
225
|
+
key: "options.<optionId>.label",
|
|
226
|
+
role: "option",
|
|
227
|
+
format: "rich",
|
|
228
|
+
pattern: true
|
|
229
|
+
},
|
|
230
|
+
...FIELD_CONTENT_SURFACES.map((surface) => ({
|
|
231
|
+
...surface,
|
|
232
|
+
key: `embeddedForms.<optionId>.${surface.key}`
|
|
233
|
+
})),
|
|
234
|
+
{
|
|
235
|
+
key: "embeddedForms.<optionId>.fields.<fieldId>.options.<optionId>.label",
|
|
236
|
+
role: "option",
|
|
237
|
+
format: "rich",
|
|
238
|
+
pattern: true
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
key: "embeddedForms.<optionId>.fields.<fieldId>.validations.<validationId>.message",
|
|
242
|
+
role: "validation",
|
|
243
|
+
format: "rich",
|
|
244
|
+
pattern: true
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
key: "embeddedForms.<optionId>.fieldGroups.<groupId>.title",
|
|
248
|
+
role: "field",
|
|
249
|
+
format: "rich",
|
|
250
|
+
pattern: true
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
key: "embeddedForms.<optionId>.fieldGroups.<groupId>.description",
|
|
254
|
+
role: "field",
|
|
255
|
+
format: "rich",
|
|
256
|
+
pattern: true
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
responseSlots: [{
|
|
260
|
+
key: "<responseId>",
|
|
261
|
+
valueType: "reference|referenceArray"
|
|
262
|
+
}],
|
|
263
|
+
referenceTopics: [
|
|
264
|
+
"item-types",
|
|
265
|
+
"embedded-forms",
|
|
266
|
+
"localization",
|
|
267
|
+
"expressions",
|
|
268
|
+
"rich-text-content"
|
|
269
|
+
],
|
|
270
|
+
authoring: { configSummary: "Config stores id, maxSelection, shuffleOptions, and options. Use choice option operations for ordinary option edits." }
|
|
271
|
+
}),
|
|
272
|
+
references: [QUESTION_REFERENCE],
|
|
273
|
+
deriveResponseSlots: deriveChoiceResponseSlots
|
|
274
|
+
};
|
|
275
|
+
const formItemAssistantCapability = {
|
|
276
|
+
manifest: createManifest({
|
|
277
|
+
itemType: "formItem",
|
|
278
|
+
displayName: "Form",
|
|
279
|
+
description: "A form with groups, typed fields, validations, and select options.",
|
|
280
|
+
defaultItemKeyPrefix: "form",
|
|
281
|
+
create: "deterministic",
|
|
282
|
+
supportedOperations: [
|
|
283
|
+
...COMMON_OPERATIONS,
|
|
284
|
+
"upsert-form-field-group",
|
|
285
|
+
"remove-form-field-group",
|
|
286
|
+
"reorder-form-field-groups",
|
|
287
|
+
"upsert-form-field",
|
|
288
|
+
"remove-form-field",
|
|
289
|
+
"move-form-field"
|
|
290
|
+
],
|
|
291
|
+
contentSurfaces: [
|
|
292
|
+
...QUESTION_CONTENT_SURFACES,
|
|
293
|
+
{
|
|
294
|
+
key: "fieldGroups.<groupId>.title",
|
|
295
|
+
role: "field",
|
|
296
|
+
format: "rich",
|
|
297
|
+
pattern: true
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
key: "fieldGroups.<groupId>.description",
|
|
301
|
+
role: "field",
|
|
302
|
+
format: "rich",
|
|
303
|
+
pattern: true
|
|
304
|
+
},
|
|
305
|
+
...FIELD_CONTENT_SURFACES,
|
|
306
|
+
{
|
|
307
|
+
key: "fields.<fieldId>.options.<optionId>.label",
|
|
308
|
+
role: "option",
|
|
309
|
+
format: "rich",
|
|
310
|
+
pattern: true
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
key: "fields.<fieldId>.validations.<validationId>.message",
|
|
314
|
+
role: "validation",
|
|
315
|
+
format: "rich",
|
|
316
|
+
pattern: true
|
|
317
|
+
}
|
|
318
|
+
],
|
|
319
|
+
responseSlots: [{
|
|
320
|
+
key: "<fieldKey>",
|
|
321
|
+
valueType: "field-dependent"
|
|
322
|
+
}],
|
|
323
|
+
referenceTopics: [
|
|
324
|
+
"item-types",
|
|
325
|
+
"localization",
|
|
326
|
+
"expressions",
|
|
327
|
+
"rich-text-content"
|
|
328
|
+
],
|
|
329
|
+
authoring: { configSummary: "Config stores fieldGroups with layouts and typed fields. Inspect current config and load item-types before editing fields." }
|
|
330
|
+
}),
|
|
331
|
+
references: [QUESTION_REFERENCE],
|
|
332
|
+
deriveResponseSlots: (item) => deriveFormResponseSlots(item.config)
|
|
333
|
+
};
|
|
334
|
+
const defaultSurveyAssistantCapabilities = [
|
|
335
|
+
rootItemAssistantCapability,
|
|
336
|
+
groupItemAssistantCapability,
|
|
337
|
+
pageBreakItemAssistantCapability,
|
|
338
|
+
infoItemAssistantCapability,
|
|
339
|
+
choiceItemAssistantCapability,
|
|
340
|
+
formItemAssistantCapability
|
|
341
|
+
];
|
|
342
|
+
const defaultSurveyAssistantCapabilitySet = createSurveyAssistantCapabilities(defaultSurveyAssistantCapabilities);
|
|
343
|
+
const getDefaultSurveyAssistantCapability = (itemType) => defaultSurveyAssistantCapabilitySet.byItemType.get(itemType);
|
|
344
|
+
//#endregion
|
|
345
|
+
export { choiceItemAssistantCapability, defaultSurveyAssistantCapabilities, defaultSurveyAssistantCapabilitySet, formItemAssistantCapability, getDefaultSurveyAssistantCapability, groupItemAssistantCapability, infoItemAssistantCapability, pageBreakItemAssistantCapability, rootItemAssistantCapability };
|
|
346
|
+
|
|
347
|
+
//# sourceMappingURL=capabilities-default.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities-default.mjs","names":[],"sources":["../src/capabilities/default.ts"],"sourcesContent":["import type { AssistantContentSurface, AssistantItemTypeManifest } from \"../protocol\";\nimport { ValueType, type RawSurveyItem } from \"@case-framework/survey-core\";\nimport {\n createSurveyAssistantCapabilities,\n type AssistantItemCapabilityAdapter,\n} from \"../engine/capabilities\";\n\nconst COMMON_OPERATIONS = [\n \"create-item\",\n \"update-item-key\",\n \"update-item-label\",\n \"update-item-color\",\n \"update-item-translation\",\n \"update-placed-image\",\n \"patch-item-config\",\n \"remove-item\",\n \"move-item\",\n \"survey-json-patch\",\n] satisfies AssistantItemTypeManifest[\"supportedOperations\"];\n\nconst QUESTION_CONTENT_SURFACES: AssistantContentSurface[] = [\n {\n key: \"title\",\n role: \"primary\",\n format: \"rich\",\n requiredOnCreate: true,\n aliases: [\"content\", \"label\", \"prompt\", \"question\", \"text\"],\n },\n {\n key: \"subtitle\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"subheading\", \"subtext\"],\n },\n {\n key: \"topContent\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"preContent\", \"preResponse\"],\n },\n {\n key: \"bottomContent\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"postContent\", \"postResponse\"],\n },\n {\n key: \"cardFooter\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"footer\"],\n },\n];\n\nconst FIELD_CONTENT_SURFACES: AssistantContentSurface[] = [\n \"label\",\n \"description\",\n \"error\",\n \"placeholder\",\n \"unit\",\n \"checkedLabel\",\n \"uncheckedLabel\",\n].map((key) => ({\n key: `fields.<fieldId>.${key}`,\n role: key === \"error\" ? \"validation\" : \"field\",\n format: \"rich\",\n pattern: true,\n}));\n\nconst createManifest = (\n manifest: Omit<AssistantItemTypeManifest, \"capabilityVersion\">,\n): AssistantItemTypeManifest => ({ capabilityVersion: \"1\", ...manifest });\n\nconst STRUCTURE_REFERENCE = {\n topic: \"item-types\",\n markdown:\n \"Groups are containers. Create a group without child ids, then create or move children through separate operations. Page breaks are standalone structural boundaries.\",\n};\nconst QUESTION_REFERENCE = {\n topic: \"item-types\",\n markdown:\n \"Question titles and supporting text are translations. Configuration stores response behavior; respondent-visible option and field labels use the declared dynamic content surfaces.\",\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst getFieldValueType = (field: Record<string, unknown>): ValueType => {\n switch (field.type) {\n case \"number\":\n case \"slider\":\n return ValueType.number;\n case \"datepicker\":\n return ValueType.date;\n case \"switch\":\n return ValueType.boolean;\n default:\n return ValueType.string;\n }\n};\n\nconst deriveFormResponseSlots = (config: unknown, prefix?: string): Record<string, ValueType> => {\n if (!isRecord(config) || !Array.isArray(config.fieldGroups)) {\n return {};\n }\n\n const slots: Record<string, ValueType> = {};\n for (const group of config.fieldGroups.filter(isRecord)) {\n if (!Array.isArray(group.fields)) continue;\n for (const field of group.fields.filter(isRecord)) {\n if (typeof field.key !== \"string\" || field.key.length === 0) continue;\n slots[prefix ? `${prefix}.${field.key}` : field.key] = getFieldValueType(field);\n }\n }\n return slots;\n};\n\nconst deriveChoiceResponseSlots = (item: RawSurveyItem): Record<string, ValueType> => {\n const config = isRecord(item.config) ? item.config : {};\n const responseId = typeof config.id === \"string\" && config.id.length > 0 ? config.id : item.id;\n const slots: Record<string, ValueType> = {\n [responseId]: config.maxSelection === 1 ? ValueType.reference : ValueType.referenceArray,\n };\n\n if (Array.isArray(config.options)) {\n for (const option of config.options.filter(isRecord)) {\n if (typeof option.id !== \"string\" || !option.embeddedForm) continue;\n Object.assign(slots, deriveFormResponseSlots(option.embeddedForm, `embedded.${option.id}`));\n }\n }\n return slots;\n};\n\nexport const rootItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"root\",\n displayName: \"Survey root\",\n description: \"The existing root container. A second root cannot be created.\",\n create: \"unsupported\",\n supportedOperations: [\"update-item-key\", \"update-item-label\", \"update-item-color\"],\n contentSurfaces: [],\n referenceTopics: [\"survey-data-model\", \"item-types\"],\n }),\n};\n\nexport const groupItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"group\",\n displayName: \"Group\",\n description: \"A structural container whose children are created as separate items.\",\n defaultItemKeyPrefix: \"group\",\n create: \"deterministic\",\n supportedOperations: [...COMMON_OPERATIONS, \"reorder-items\"],\n contentSurfaces: [\n {\n key: \"title\",\n role: \"primary\",\n format: \"rich\",\n aliases: [\"content\", \"label\", \"name\", \"text\"],\n },\n ],\n referenceTopics: [\"survey-data-model\", \"item-types\"],\n }),\n references: [STRUCTURE_REFERENCE],\n};\n\nexport const pageBreakItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"page-break\",\n displayName: \"Page break\",\n description: \"A structural page boundary.\",\n defaultItemKeyPrefix: \"page\",\n create: \"deterministic\",\n supportedOperations: COMMON_OPERATIONS,\n contentSurfaces: [\n {\n key: \"title\",\n role: \"primary\",\n format: \"rich\",\n aliases: [\"content\", \"label\", \"name\", \"text\"],\n },\n ],\n referenceTopics: [\"survey-data-model\", \"item-types\"],\n }),\n references: [STRUCTURE_REFERENCE],\n};\n\nexport const infoItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"infoItem\",\n displayName: \"Info\",\n description: \"Display-only formatted content without a response slot.\",\n defaultItemKeyPrefix: \"info\",\n create: \"deterministic\",\n supportedOperations: COMMON_OPERATIONS,\n contentSurfaces: [\n {\n key: \"content\",\n role: \"primary\",\n format: \"rich\",\n requiredOnCreate: true,\n aliases: [\"body\", \"label\", \"prompt\", \"question\", \"text\", \"title\"],\n },\n ],\n referenceTopics: [\"item-types\", \"rich-text-content\"],\n }),\n references: [\n {\n topic: \"rich-text-content\",\n markdown:\n \"Info content uses the rich `content` surface. Markdown strings are not parsed; send structured rich text when formatting matters.\",\n },\n ],\n};\n\nexport const choiceItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"choiceItem\",\n displayName: \"Choice question\",\n description: \"A single- or multiple-choice question with optional embedded forms.\",\n defaultItemKeyPrefix: \"choice\",\n create: \"deterministic\",\n supportedOperations: [\n ...COMMON_OPERATIONS,\n \"add-choice-option\",\n \"update-choice-option-label\",\n \"remove-choice-option\",\n \"reorder-choice-options\",\n \"upsert-form-field-group\",\n \"remove-form-field-group\",\n \"reorder-form-field-groups\",\n \"upsert-form-field\",\n \"remove-form-field\",\n \"move-form-field\",\n \"set-embedded-form\",\n \"remove-embedded-form\",\n ],\n contentSurfaces: [\n ...QUESTION_CONTENT_SURFACES,\n {\n key: \"options.<optionId>.label\",\n role: \"option\",\n format: \"rich\",\n pattern: true,\n },\n ...FIELD_CONTENT_SURFACES.map((surface) => ({\n ...surface,\n key: `embeddedForms.<optionId>.${surface.key}`,\n })),\n {\n key: \"embeddedForms.<optionId>.fields.<fieldId>.options.<optionId>.label\",\n role: \"option\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"embeddedForms.<optionId>.fields.<fieldId>.validations.<validationId>.message\",\n role: \"validation\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"embeddedForms.<optionId>.fieldGroups.<groupId>.title\",\n role: \"field\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"embeddedForms.<optionId>.fieldGroups.<groupId>.description\",\n role: \"field\",\n format: \"rich\",\n pattern: true,\n },\n ],\n responseSlots: [{ key: \"<responseId>\", valueType: \"reference|referenceArray\" }],\n referenceTopics: [\n \"item-types\",\n \"embedded-forms\",\n \"localization\",\n \"expressions\",\n \"rich-text-content\",\n ],\n authoring: {\n configSummary:\n \"Config stores id, maxSelection, shuffleOptions, and options. Use choice option operations for ordinary option edits.\",\n },\n }),\n references: [QUESTION_REFERENCE],\n deriveResponseSlots: deriveChoiceResponseSlots,\n};\n\nexport const formItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"formItem\",\n displayName: \"Form\",\n description: \"A form with groups, typed fields, validations, and select options.\",\n defaultItemKeyPrefix: \"form\",\n create: \"deterministic\",\n supportedOperations: [\n ...COMMON_OPERATIONS,\n \"upsert-form-field-group\",\n \"remove-form-field-group\",\n \"reorder-form-field-groups\",\n \"upsert-form-field\",\n \"remove-form-field\",\n \"move-form-field\",\n ],\n contentSurfaces: [\n ...QUESTION_CONTENT_SURFACES,\n {\n key: \"fieldGroups.<groupId>.title\",\n role: \"field\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"fieldGroups.<groupId>.description\",\n role: \"field\",\n format: \"rich\",\n pattern: true,\n },\n ...FIELD_CONTENT_SURFACES,\n {\n key: \"fields.<fieldId>.options.<optionId>.label\",\n role: \"option\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"fields.<fieldId>.validations.<validationId>.message\",\n role: \"validation\",\n format: \"rich\",\n pattern: true,\n },\n ],\n responseSlots: [{ key: \"<fieldKey>\", valueType: \"field-dependent\" }],\n referenceTopics: [\"item-types\", \"localization\", \"expressions\", \"rich-text-content\"],\n authoring: {\n configSummary:\n \"Config stores fieldGroups with layouts and typed fields. Inspect current config and load item-types before editing fields.\",\n },\n }),\n references: [QUESTION_REFERENCE],\n deriveResponseSlots: (item) => deriveFormResponseSlots(item.config),\n};\n\nexport const defaultSurveyAssistantCapabilities = [\n rootItemAssistantCapability,\n groupItemAssistantCapability,\n pageBreakItemAssistantCapability,\n infoItemAssistantCapability,\n choiceItemAssistantCapability,\n formItemAssistantCapability,\n] as const;\n\nexport const defaultSurveyAssistantCapabilitySet = createSurveyAssistantCapabilities(\n defaultSurveyAssistantCapabilities,\n);\n\nexport const getDefaultSurveyAssistantCapability = (\n itemType: string,\n): AssistantItemCapabilityAdapter | undefined =>\n defaultSurveyAssistantCapabilitySet.byItemType.get(itemType);\n"],"mappings":";;;AAOA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,4BAAuD;CAC3D;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,kBAAkB;EAClB,SAAS;GAAC;GAAW;GAAS;GAAU;GAAY;GAAO;EAC5D;CACD;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,cAAc,UAAU;EACnC;CACD;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,cAAc,cAAc;EACvC;CACD;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,eAAe,eAAe;EACzC;CACD;EACE,KAAK;EACL,MAAM;E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D;IACE,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACV;GACD,GAAG;GACH;IACE,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACV;GACD;IACE,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACV;GACF;EACD,eAAe,CAAC;GAAE,KAAK;GAAc,WAAW;GAAmB,CAAC;EACpE,iBAAiB;GAAC;GAAc;GAAgB;GAAe;GAAoB;EACnF,WAAW,EACT,eACE,8HACH;EACF,CAAC;CACF,YAAY,CAAC,mBAAmB;CAChC,sBAAsB,SAAS,wBAAwB,KAAK,OAAO;CACpE;AAED,MAAa,qCAAqC;CAChD;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,sCAAsC,kCACjD,mCACD;AAED,MAAa,uCACX,aAEA,oCAAoC,WAAW,IAAI,SAAS"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/server/constants.ts
|
|
2
|
+
const SURVEY_ASSISTANT_AGENT_ID = "survey-assistant-agent";
|
|
3
|
+
const SURVEY_ASSISTANT_TASK_AGENT_ID = "survey-assistant-task-agent";
|
|
4
|
+
//#endregion
|
|
5
|
+
export { SURVEY_ASSISTANT_TASK_AGENT_ID as n, SURVEY_ASSISTANT_AGENT_ID as t };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=constants-CFUWrRtl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-CFUWrRtl.mjs","names":[],"sources":["../src/server/constants.ts"],"sourcesContent":["export const SURVEY_ASSISTANT_AGENT_ID = \"survey-assistant-agent\";\nexport const SURVEY_ASSISTANT_TASK_AGENT_ID = \"survey-assistant-task-agent\";\n"],"mappings":";AAAA,MAAa,4BAA4B;AACzC,MAAa,iCAAiC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { cn as SurveyDocumentSnapshot } from "./index-TFtvBiSQ.mjs";
|
|
2
|
+
import { Ft as SurveyAssistantCapabilitySet, g as TurnChangeCollector, xt as SurveyAssistantEngineContext } from "./index-CUqbBjkc.mjs";
|
|
3
|
+
import { n as SurveyAssistantModelAttachment, t as SurveyAssistantAttachmentAccess } from "./thread-documents-DamIq9Od.mjs";
|
|
4
|
+
import { RequestContext } from "@mastra/core/request-context";
|
|
5
|
+
|
|
6
|
+
//#region src/server/request-context.d.ts
|
|
7
|
+
interface SurveyAssistantInvocationContext {
|
|
8
|
+
kind: "chat";
|
|
9
|
+
}
|
|
10
|
+
interface SurveyAssistantIdentityContext {
|
|
11
|
+
authority: "experimental-client-request" | "authenticated-host";
|
|
12
|
+
resourceId: string;
|
|
13
|
+
threadId: string;
|
|
14
|
+
}
|
|
15
|
+
interface SurveyAssistantModelSelection {
|
|
16
|
+
id: string;
|
|
17
|
+
model: string;
|
|
18
|
+
}
|
|
19
|
+
type SurveyAssistantSnapshotSource = "full" | "missing";
|
|
20
|
+
interface SurveyAssistantRequestContext {
|
|
21
|
+
invocation: SurveyAssistantInvocationContext;
|
|
22
|
+
turnId: string;
|
|
23
|
+
changeCollector: TurnChangeCollector;
|
|
24
|
+
identity: SurveyAssistantIdentityContext;
|
|
25
|
+
authenticatedResourceId?: string;
|
|
26
|
+
authorizedThreadId?: string;
|
|
27
|
+
applyPolicy?: "auto" | "review" | "deny";
|
|
28
|
+
mastra__resourceId?: string;
|
|
29
|
+
mastra__threadId?: string;
|
|
30
|
+
snapshotSource?: SurveyAssistantSnapshotSource;
|
|
31
|
+
engineContext?: SurveyAssistantEngineContext;
|
|
32
|
+
documentSnapshot?: SurveyDocumentSnapshot;
|
|
33
|
+
modelAttachments?: SurveyAssistantModelAttachment[];
|
|
34
|
+
attachmentAccess?: SurveyAssistantAttachmentAccess;
|
|
35
|
+
modelSelection?: SurveyAssistantModelSelection;
|
|
36
|
+
}
|
|
37
|
+
declare const parseSurveyAssistantSnapshot: (value: unknown) => SurveyDocumentSnapshot | null;
|
|
38
|
+
declare const buildSurveyAssistantRequestContext: ({
|
|
39
|
+
changeCollector,
|
|
40
|
+
identity,
|
|
41
|
+
snapshot,
|
|
42
|
+
snapshotSource,
|
|
43
|
+
trustedCapabilities,
|
|
44
|
+
attachmentAccess,
|
|
45
|
+
modelAttachments,
|
|
46
|
+
modelSelection
|
|
47
|
+
}: {
|
|
48
|
+
changeCollector: TurnChangeCollector;
|
|
49
|
+
identity: SurveyAssistantIdentityContext;
|
|
50
|
+
snapshot: SurveyDocumentSnapshot | null;
|
|
51
|
+
snapshotSource?: SurveyAssistantSnapshotSource;
|
|
52
|
+
trustedCapabilities?: SurveyAssistantCapabilitySet;
|
|
53
|
+
attachmentAccess?: SurveyAssistantAttachmentAccess;
|
|
54
|
+
modelAttachments?: SurveyAssistantModelAttachment[];
|
|
55
|
+
modelSelection?: SurveyAssistantModelSelection;
|
|
56
|
+
}) => RequestContext<SurveyAssistantRequestContext>;
|
|
57
|
+
declare const requireSurveyAssistantTurnState: (requestContext: RequestContext<SurveyAssistantRequestContext> | undefined) => {
|
|
58
|
+
turnId: string;
|
|
59
|
+
changeCollector: TurnChangeCollector;
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/server/constants.d.ts
|
|
63
|
+
declare const SURVEY_ASSISTANT_AGENT_ID = "survey-assistant-agent";
|
|
64
|
+
declare const SURVEY_ASSISTANT_TASK_AGENT_ID = "survey-assistant-task-agent";
|
|
65
|
+
//#endregion
|
|
66
|
+
export { SurveyAssistantRequestContext as a, parseSurveyAssistantSnapshot as c, SurveyAssistantModelSelection as i, requireSurveyAssistantTurnState as l, SURVEY_ASSISTANT_TASK_AGENT_ID as n, SurveyAssistantSnapshotSource as o, SurveyAssistantIdentityContext as r, buildSurveyAssistantRequestContext as s, SURVEY_ASSISTANT_AGENT_ID as t };
|
|
67
|
+
//# sourceMappingURL=constants-Jw0k8ojS.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-Jw0k8ojS.d.mts","names":[],"sources":["../src/server/request-context.ts","../src/server/constants.ts"],"mappings":";;;;;;UAkBiB,gCAAA;EACf,IAAA;AAAA;AAAA,UAGe,8BAAA;EACf,SAAA;EACA,UAAA;EACA,QAAA;AAAA;AAAA,UAGe,6BAAA;EACf,EAAA;EACA,KAAA;AAAA;AAAA,KAGU,6BAAA;AAAA,UAEK,6BAAA;EACf,UAAA,EAAY,gCAAA;EACZ,MAAA;EACA,eAAA,EAAiB,mBAAA;EACjB,QAAA,EAAU,8BAAA;EACV,uBAAA;EACA,kBAAA;EACA,WAAA;EACA,kBAAA;EACA,gBAAA;EACA,cAAA,GAAiB,6BAAA;EACjB,aAAA,GAAgB,4BAAA;EAChB,gBAAA,GAAmB,sBAAA;EACnB,gBAAA,GAAmB,8BAAA;EACnB,gBAAA,GAAmB,+BAAA;EACnB,cAAA,GAAiB,6BAAA;AAAA;AAAA,cAGN,4BAAA,GAAgC,KAAA,cAAiB,sBAAA;AAAA,cAQjD,kCAAA;EAAsC,eAAA;EAAA,QAAA;EAAA,QAAA;EAAA,cAAA;EAAA,mBAAA;EAAA,gBAAA;EAAA,gBAAA;EAAA;AAAA;EAUjD,eAAA,EAAiB,mBAAA;EACjB,QAAA,EAAU,8BAAA;EACV,QAAA,EAAU,sBAAA;EACV,cAAA,GAAiB,6BAAA;EACjB,mBAAA,GAAsB,4BAAA;EACtB,gBAAA,GAAmB,+BAAA;EACnB,gBAAA,GAAmB,8BAAA;EACnB,cAAA,GAAiB,6BAAA;AAAA,MACf,cAAA,CAAe,6BAAA;AAAA,cAmCN,+BAAA,GACX,cAAA,EAAgB,cAAA,CAAe,6BAAA;;;;;;cCnHpB,yBAAA;AAAA,cACA,8BAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { A as SurveyAssistantSuggestItemKeyResult, B as SurveyAssistantTranslateContentResult, F as SurveyAssistantTaskInvocationMode, M as SurveyAssistantSuggestItemLabelResult, P as SurveyAssistantTaskContext, f as SurveyBatchApplyResult, i as SurveyApplyResult, j as SurveyAssistantSuggestItemLabelInput, k as SurveyAssistantSuggestItemKeyInput, on as SurveyAssistantSnapshot, p as SurveyChangeSet, z as SurveyAssistantTranslateContentInput } from "./index-TFtvBiSQ.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/react/task-client.d.ts
|
|
4
|
+
interface SurveyAssistantTaskClientOptions {
|
|
5
|
+
api?: string;
|
|
6
|
+
getModelId?: () => string | undefined;
|
|
7
|
+
}
|
|
8
|
+
interface SurveyAssistantTaskExecutionOptions {
|
|
9
|
+
mode?: SurveyAssistantTaskInvocationMode;
|
|
10
|
+
modelId?: string;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
interface SurveyAssistantTaskClient {
|
|
14
|
+
suggestItemKey(input: SurveyAssistantSuggestItemKeyInput, context: SurveyAssistantTaskContext, options?: SurveyAssistantTaskExecutionOptions): Promise<SurveyAssistantSuggestItemKeyResult>;
|
|
15
|
+
suggestItemLabel(input: SurveyAssistantSuggestItemLabelInput, context: SurveyAssistantTaskContext, options?: SurveyAssistantTaskExecutionOptions): Promise<SurveyAssistantSuggestItemLabelResult>;
|
|
16
|
+
translateContent(input: SurveyAssistantTranslateContentInput, context: SurveyAssistantTaskContext, options?: SurveyAssistantTaskExecutionOptions): Promise<SurveyAssistantTranslateContentResult>;
|
|
17
|
+
}
|
|
18
|
+
interface SurveyAssistantTaskExecutorRequestOptions {
|
|
19
|
+
mode?: SurveyAssistantTaskInvocationMode;
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
}
|
|
22
|
+
interface SurveyAssistantTaskExecutorCacheContext {
|
|
23
|
+
cacheScope?: string;
|
|
24
|
+
}
|
|
25
|
+
interface SurveyAssistantTaskExecutor {
|
|
26
|
+
suggestItemKey(input: SurveyAssistantSuggestItemKeyInput, context: SurveyAssistantTaskContext, options?: SurveyAssistantTaskExecutorRequestOptions, cache?: SurveyAssistantTaskExecutorCacheContext): Promise<SurveyAssistantSuggestItemKeyResult>;
|
|
27
|
+
suggestItemLabel(input: SurveyAssistantSuggestItemLabelInput, context: SurveyAssistantTaskContext, options?: SurveyAssistantTaskExecutorRequestOptions, cache?: SurveyAssistantTaskExecutorCacheContext): Promise<SurveyAssistantSuggestItemLabelResult>;
|
|
28
|
+
translateContent(input: SurveyAssistantTranslateContentInput, context: SurveyAssistantTaskContext, options?: SurveyAssistantTaskExecutorRequestOptions, cache?: SurveyAssistantTaskExecutorCacheContext): Promise<SurveyAssistantTranslateContentResult>;
|
|
29
|
+
}
|
|
30
|
+
declare const createSurveyAssistantTaskClient: ({
|
|
31
|
+
api,
|
|
32
|
+
getModelId
|
|
33
|
+
}?: SurveyAssistantTaskClientOptions) => SurveyAssistantTaskClient;
|
|
34
|
+
declare const createSurveyAssistantTaskExecutor: (options?: SurveyAssistantTaskClientOptions) => SurveyAssistantTaskExecutor;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/react/controller.d.ts
|
|
37
|
+
interface SurveyAssistantController {
|
|
38
|
+
getSnapshot(): SurveyAssistantSnapshot | null;
|
|
39
|
+
applyAssistantChange?(change: SurveyChangeSet): SurveyApplyResult;
|
|
40
|
+
applyAssistantChanges?(changes: SurveyChangeSet[]): SurveyBatchApplyResult;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/react/controller-proxy.d.ts
|
|
44
|
+
interface CreateSurveyAssistantControllerProxyOptions {
|
|
45
|
+
notReadyMessage?: string;
|
|
46
|
+
}
|
|
47
|
+
interface SurveyAssistantControllerBridge {
|
|
48
|
+
controller: SurveyAssistantController;
|
|
49
|
+
setController(controller: SurveyAssistantController | null | undefined): void;
|
|
50
|
+
}
|
|
51
|
+
declare const createSurveyAssistantControllerProxy: (getController: () => SurveyAssistantController | null | undefined, {
|
|
52
|
+
notReadyMessage
|
|
53
|
+
}?: CreateSurveyAssistantControllerProxyOptions) => SurveyAssistantController;
|
|
54
|
+
declare const createSurveyAssistantControllerBridge: (options?: CreateSurveyAssistantControllerProxyOptions) => SurveyAssistantControllerBridge;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { SurveyAssistantController as a, SurveyAssistantTaskExecutionOptions as c, SurveyAssistantTaskExecutorRequestOptions as d, createSurveyAssistantTaskClient as f, createSurveyAssistantControllerProxy as i, SurveyAssistantTaskExecutor as l, SurveyAssistantControllerBridge as n, SurveyAssistantTaskClient as o, createSurveyAssistantTaskExecutor as p, createSurveyAssistantControllerBridge as r, SurveyAssistantTaskClientOptions as s, CreateSurveyAssistantControllerProxyOptions as t, SurveyAssistantTaskExecutorCacheContext as u };
|
|
57
|
+
//# sourceMappingURL=controller-proxy-BRDusFiO.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-proxy-BRDusFiO.d.mts","names":[],"sources":["../src/react/task-client.ts","../src/react/controller.ts","../src/react/controller-proxy.ts"],"mappings":";;;UAeiB,gCAAA;EACf,GAAA;EACA,UAAA;AAAA;AAAA,UAGe,mCAAA;EACf,IAAA,GAAO,iCAAA;EACP,OAAA;EACA,MAAA,GAAS,WAAA;AAAA;AAAA,UAGM,yBAAA;EACf,cAAA,CACE,KAAA,EAAO,kCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,mCAAA,GACT,OAAA,CAAQ,mCAAA;EACX,gBAAA,CACE,KAAA,EAAO,oCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,mCAAA,GACT,OAAA,CAAQ,qCAAA;EACX,gBAAA,CACE,KAAA,EAAO,oCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,mCAAA,GACT,OAAA,CAAQ,qCAAA;AAAA;AAAA,UAGI,yCAAA;EACf,IAAA,GAAO,iCAAA;EACP,MAAA,GAAS,WAAA;AAAA;AAAA,UAGM,uCAAA;EACf,UAAA;AAAA;AAAA,UAGe,2BAAA;EACf,cAAA,CACE,KAAA,EAAO,kCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,yCAAA,EACV,KAAA,GAAQ,uCAAA,GACP,OAAA,CAAQ,mCAAA;EACX,gBAAA,CACE,KAAA,EAAO,oCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,yCAAA,EACV,KAAA,GAAQ,uCAAA,GACP,OAAA,CAAQ,qCAAA;EACX,gBAAA,CACE,KAAA,EAAO,oCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,yCAAA,EACV,KAAA,GAAQ,uCAAA,GACP,OAAA,CAAQ,qCAAA;AAAA;AAAA,cAGA,+BAAA;EAAmC,GAAA;EAAA;AAAA,IAG7C,gCAAA,KAAwC,yBAAA;AAAA,cA4C9B,iCAAA,GACX,OAAA,GAAS,gCAAA,KACR,2BAAA;;;UCpHc,yBAAA;EACf,WAAA,IAAe,uBAAA;EACf,oBAAA,EAAsB,MAAA,EAAQ,eAAA,GAAkB,iBAAA;EAChD,qBAAA,EAAuB,OAAA,EAAS,eAAA,KAAoB,sBAAA;AAAA;;;UCPrC,2CAAA;EACf,eAAA;AAAA;AAAA,UAGe,+BAAA;EACf,UAAA,EAAY,yBAAA;EACZ,aAAA,CAAc,UAAA,EAAY,yBAAA;AAAA;AAAA,cAWf,oCAAA,GACX,aAAA,QAAqB,yBAAA;EACrB;AAAA,IAEG,2CAAA,KACF,yBAAA;AAAA,cAUU,qCAAA,GACX,OAAA,GAAU,2CAAA,KACT,+BAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Dt as parseSurveyAssistantError, E as surveyAssistantTranslateContentResultSchema, g as surveyAssistantSuggestItemKeyResultSchema, v as surveyAssistantSuggestItemLabelResultSchema } from "./protocol-DV0ka9WT.mjs";
|
|
2
|
+
//#region src/react/client-error.ts
|
|
3
|
+
var SurveyAssistantClientError = class extends Error {
|
|
4
|
+
code;
|
|
5
|
+
constructor(code, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "SurveyAssistantClientError";
|
|
8
|
+
this.code = code;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const readSurveyAssistantJson = async (response, fallback = "The assistant request could not be completed.") => {
|
|
12
|
+
const body = await response.json().catch(() => ({}));
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
const detail = typeof body?.error === "string" ? body.error : fallback;
|
|
15
|
+
const parsed = parseSurveyAssistantError(typeof body?.code === "string" ? {
|
|
16
|
+
code: body.code,
|
|
17
|
+
detail
|
|
18
|
+
} : detail);
|
|
19
|
+
throw new SurveyAssistantClientError(parsed.code, parsed.detail ?? detail);
|
|
20
|
+
}
|
|
21
|
+
return body;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/react/task-client.ts
|
|
25
|
+
const createSurveyAssistantTaskClient = ({ api = "/api/survey-assistant/tasks", getModelId } = {}) => {
|
|
26
|
+
const run = async (taskId, input, context, options) => {
|
|
27
|
+
const modelId = options?.modelId ?? getModelId?.();
|
|
28
|
+
return readSurveyAssistantJson(await fetch(api, {
|
|
29
|
+
body: JSON.stringify({
|
|
30
|
+
taskId,
|
|
31
|
+
input,
|
|
32
|
+
context,
|
|
33
|
+
...options?.mode ? { mode: options.mode } : {},
|
|
34
|
+
...modelId ? { modelId } : {}
|
|
35
|
+
}),
|
|
36
|
+
headers: { "content-type": "application/json" },
|
|
37
|
+
method: "POST",
|
|
38
|
+
signal: options?.signal
|
|
39
|
+
}), "The survey assistant task could not be completed.");
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
async suggestItemKey(input, context, options) {
|
|
43
|
+
return surveyAssistantSuggestItemKeyResultSchema.parse(await run("suggest-item-key", input, context, options));
|
|
44
|
+
},
|
|
45
|
+
async suggestItemLabel(input, context, options) {
|
|
46
|
+
return surveyAssistantSuggestItemLabelResultSchema.parse(await run("suggest-item-label", input, context, options));
|
|
47
|
+
},
|
|
48
|
+
async translateContent(input, context, options) {
|
|
49
|
+
return surveyAssistantTranslateContentResultSchema.parse(await run("translate-content", input, context, options));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const createSurveyAssistantTaskExecutor = (options = {}) => {
|
|
54
|
+
const client = createSurveyAssistantTaskClient(options);
|
|
55
|
+
const executionOptions = (request, cache) => ({
|
|
56
|
+
mode: request?.mode,
|
|
57
|
+
modelId: cache?.cacheScope,
|
|
58
|
+
signal: request?.signal
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
suggestItemKey: (input, context, request, cache) => client.suggestItemKey(input, context, executionOptions(request, cache)),
|
|
62
|
+
suggestItemLabel: (input, context, request, cache) => client.suggestItemLabel(input, context, executionOptions(request, cache)),
|
|
63
|
+
translateContent: (input, context, request, cache) => client.translateContent(input, context, executionOptions(request, cache))
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/react/controller-proxy.ts
|
|
68
|
+
const failedResult = (change, message) => ({
|
|
69
|
+
status: "failed",
|
|
70
|
+
changeId: change.id,
|
|
71
|
+
summary: change.summary,
|
|
72
|
+
message,
|
|
73
|
+
appliedOperations: 0
|
|
74
|
+
});
|
|
75
|
+
const createSurveyAssistantControllerProxy = (getController, { notReadyMessage = "The survey editor is not ready." } = {}) => ({
|
|
76
|
+
getSnapshot: () => getController()?.getSnapshot() ?? null,
|
|
77
|
+
applyAssistantChange: (change) => getController()?.applyAssistantChange?.(change) ?? failedResult(change, notReadyMessage),
|
|
78
|
+
applyAssistantChanges: (changes) => getController()?.applyAssistantChanges?.(changes) ?? { results: changes.map((change) => failedResult(change, notReadyMessage)) }
|
|
79
|
+
});
|
|
80
|
+
const createSurveyAssistantControllerBridge = (options) => {
|
|
81
|
+
let currentController;
|
|
82
|
+
return {
|
|
83
|
+
controller: createSurveyAssistantControllerProxy(() => currentController, options),
|
|
84
|
+
setController(controller) {
|
|
85
|
+
currentController = controller;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
export { SurveyAssistantClientError as a, createSurveyAssistantTaskExecutor as i, createSurveyAssistantControllerProxy as n, readSurveyAssistantJson as o, createSurveyAssistantTaskClient as r, createSurveyAssistantControllerBridge as t };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=controller-proxy-Duxo2IFE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-proxy-Duxo2IFE.mjs","names":[],"sources":["../src/react/client-error.ts","../src/react/task-client.ts","../src/react/controller-proxy.ts"],"sourcesContent":["import { parseSurveyAssistantError, type SurveyAssistantErrorCode } from \"../protocol\";\n\nexport class SurveyAssistantClientError extends Error {\n readonly code: SurveyAssistantErrorCode;\n\n constructor(code: SurveyAssistantErrorCode, message: string) {\n super(message);\n this.name = \"SurveyAssistantClientError\";\n this.code = code;\n }\n}\n\nexport const readSurveyAssistantJson = async (\n response: Response,\n fallback = \"The assistant request could not be completed.\",\n) => {\n const body = await response.json().catch(() => ({}));\n if (!response.ok) {\n const detail = typeof body?.error === \"string\" ? body.error : fallback;\n const parsed = parseSurveyAssistantError(\n typeof body?.code === \"string\" ? { code: body.code, detail } : detail,\n );\n throw new SurveyAssistantClientError(parsed.code, parsed.detail ?? detail);\n }\n return body;\n};\n","import {\n surveyAssistantSuggestItemKeyResultSchema,\n surveyAssistantSuggestItemLabelResultSchema,\n surveyAssistantTranslateContentResultSchema,\n type SurveyAssistantSuggestItemKeyInput,\n type SurveyAssistantSuggestItemKeyResult,\n type SurveyAssistantSuggestItemLabelInput,\n type SurveyAssistantSuggestItemLabelResult,\n type SurveyAssistantTaskContext,\n type SurveyAssistantTaskInvocationMode,\n type SurveyAssistantTranslateContentInput,\n type SurveyAssistantTranslateContentResult,\n} from \"../protocol\";\nimport { readSurveyAssistantJson } from \"./client-error\";\n\nexport interface SurveyAssistantTaskClientOptions {\n api?: string;\n getModelId?: () => string | undefined;\n}\n\nexport interface SurveyAssistantTaskExecutionOptions {\n mode?: SurveyAssistantTaskInvocationMode;\n modelId?: string;\n signal?: AbortSignal;\n}\n\nexport interface SurveyAssistantTaskClient {\n suggestItemKey(\n input: SurveyAssistantSuggestItemKeyInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutionOptions,\n ): Promise<SurveyAssistantSuggestItemKeyResult>;\n suggestItemLabel(\n input: SurveyAssistantSuggestItemLabelInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutionOptions,\n ): Promise<SurveyAssistantSuggestItemLabelResult>;\n translateContent(\n input: SurveyAssistantTranslateContentInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutionOptions,\n ): Promise<SurveyAssistantTranslateContentResult>;\n}\n\nexport interface SurveyAssistantTaskExecutorRequestOptions {\n mode?: SurveyAssistantTaskInvocationMode;\n signal?: AbortSignal;\n}\n\nexport interface SurveyAssistantTaskExecutorCacheContext {\n cacheScope?: string;\n}\n\nexport interface SurveyAssistantTaskExecutor {\n suggestItemKey(\n input: SurveyAssistantSuggestItemKeyInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutorRequestOptions,\n cache?: SurveyAssistantTaskExecutorCacheContext,\n ): Promise<SurveyAssistantSuggestItemKeyResult>;\n suggestItemLabel(\n input: SurveyAssistantSuggestItemLabelInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutorRequestOptions,\n cache?: SurveyAssistantTaskExecutorCacheContext,\n ): Promise<SurveyAssistantSuggestItemLabelResult>;\n translateContent(\n input: SurveyAssistantTranslateContentInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutorRequestOptions,\n cache?: SurveyAssistantTaskExecutorCacheContext,\n ): Promise<SurveyAssistantTranslateContentResult>;\n}\n\nexport const createSurveyAssistantTaskClient = ({\n api = \"/api/survey-assistant/tasks\",\n getModelId,\n}: SurveyAssistantTaskClientOptions = {}): SurveyAssistantTaskClient => {\n const run = async (\n taskId: \"suggest-item-key\" | \"suggest-item-label\" | \"translate-content\",\n input: unknown,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutionOptions,\n ) => {\n const modelId = options?.modelId ?? getModelId?.();\n return readSurveyAssistantJson(\n await fetch(api, {\n body: JSON.stringify({\n taskId,\n input,\n context,\n ...(options?.mode ? { mode: options.mode } : {}),\n ...(modelId ? { modelId } : {}),\n }),\n headers: { \"content-type\": \"application/json\" },\n method: \"POST\",\n signal: options?.signal,\n }),\n \"The survey assistant task could not be completed.\",\n );\n };\n\n return {\n async suggestItemKey(input, context, options) {\n return surveyAssistantSuggestItemKeyResultSchema.parse(\n await run(\"suggest-item-key\", input, context, options),\n );\n },\n async suggestItemLabel(input, context, options) {\n return surveyAssistantSuggestItemLabelResultSchema.parse(\n await run(\"suggest-item-label\", input, context, options),\n );\n },\n async translateContent(input, context, options) {\n return surveyAssistantTranslateContentResultSchema.parse(\n await run(\"translate-content\", input, context, options),\n );\n },\n };\n};\n\nexport const createSurveyAssistantTaskExecutor = (\n options: SurveyAssistantTaskClientOptions = {},\n): SurveyAssistantTaskExecutor => {\n const client = createSurveyAssistantTaskClient(options);\n const executionOptions = (\n request?: SurveyAssistantTaskExecutorRequestOptions,\n cache?: SurveyAssistantTaskExecutorCacheContext,\n ): SurveyAssistantTaskExecutionOptions => ({\n mode: request?.mode,\n modelId: cache?.cacheScope,\n signal: request?.signal,\n });\n\n return {\n suggestItemKey: (input, context, request, cache) =>\n client.suggestItemKey(input, context, executionOptions(request, cache)),\n suggestItemLabel: (input, context, request, cache) =>\n client.suggestItemLabel(input, context, executionOptions(request, cache)),\n translateContent: (input, context, request, cache) =>\n client.translateContent(input, context, executionOptions(request, cache)),\n };\n};\n","import type { SurveyApplyResult, SurveyBatchApplyResult, SurveyChangeSet } from \"../protocol\";\nimport type { SurveyAssistantController } from \"./controller\";\n\nexport interface CreateSurveyAssistantControllerProxyOptions {\n notReadyMessage?: string;\n}\n\nexport interface SurveyAssistantControllerBridge {\n controller: SurveyAssistantController;\n setController(controller: SurveyAssistantController | null | undefined): void;\n}\n\nconst failedResult = (change: SurveyChangeSet, message: string): SurveyApplyResult => ({\n status: \"failed\",\n changeId: change.id,\n summary: change.summary,\n message,\n appliedOperations: 0,\n});\n\nexport const createSurveyAssistantControllerProxy = (\n getController: () => SurveyAssistantController | null | undefined,\n {\n notReadyMessage = \"The survey editor is not ready.\",\n }: CreateSurveyAssistantControllerProxyOptions = {},\n): SurveyAssistantController => ({\n getSnapshot: () => getController()?.getSnapshot() ?? null,\n applyAssistantChange: (change) =>\n getController()?.applyAssistantChange?.(change) ?? failedResult(change, notReadyMessage),\n applyAssistantChanges: (changes): SurveyBatchApplyResult =>\n getController()?.applyAssistantChanges?.(changes) ?? {\n results: changes.map((change) => failedResult(change, notReadyMessage)),\n },\n});\n\nexport const createSurveyAssistantControllerBridge = (\n options?: CreateSurveyAssistantControllerProxyOptions,\n): SurveyAssistantControllerBridge => {\n let currentController: SurveyAssistantController | null | undefined;\n return {\n controller: createSurveyAssistantControllerProxy(() => currentController, options),\n setController(controller) {\n currentController = controller;\n },\n };\n};\n"],"mappings":";;AAEA,IAAa,6BAAb,cAAgD,MAAM;CACpD;CAEA,YAAY,MAAgC,SAAiB;AAC3D,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;;;AAIhB,MAAa,0BAA0B,OACrC,UACA,WAAW,oDACR;CACH,MAAM,OAAO,MAAM,SAAS,MAAM,CAAC,aAAa,EAAE,EAAE;AACpD,KAAI,CAAC,SAAS,IAAI;EAChB,MAAM,SAAS,OAAO,MAAM,UAAU,WAAW,KAAK,QAAQ;EAC9D,MAAM,SAAS,0BACb,OAAO,MAAM,SAAS,WAAW;GAAE,MAAM,KAAK;GAAM;GAAQ,GAAG,OAChE;AACD,QAAM,IAAI,2BAA2B,OAAO,MAAM,OAAO,UAAU,OAAO;;AAE5E,QAAO;;;;ACkDT,MAAa,mCAAmC,EAC9C,MAAM,+BACN,eACoC,EAAE,KAAgC;CACtE,MAAM,MAAM,OACV,QACA,OACA,SACA,YACG;EACH,MAAM,UAAU,SAAS,WAAW,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EACE,kBAAkB,sCAC6B,EAAE,MACpB;CAC/B,mBAAmB,eAAe,EAAE,aAAa,IAAI;CACrD,uBAAuB,WACrB,eAAe,EAAE,uBAAuB,OAAO,IAAI,aAAa,QAAQ,gBAAgB;CAC1F,wBAAwB,YACtB,eAAe,EAAE,wBAAwB,QAAQ,IAAI,EACnD,SAAS,QAAQ,KAAK,WAAW,aAAa,QAAQ,gBAAgB,CAAC,EACxE;CACJ;AAED,MAAa,yCACX,YACoC;CACpC,IAAI;AACJ,QAAO;EACL,YAAY,2CAA2C,mBAAmB,QAAQ;EAClF,cAAc,YAAY;AACxB,uBAAoB;;EAEvB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { o as SurveyAssistantCapabilityManifest } from "./capabilities-DvSKtjAw.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/protocol/digest.d.ts
|
|
4
|
+
declare const stableStringify: (value: unknown) => string;
|
|
5
|
+
declare const hashString: (input: string) => string;
|
|
6
|
+
declare const buildCapabilityDigest: (manifest: Omit<SurveyAssistantCapabilityManifest, "digest">) => string;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { hashString as n, stableStringify as r, buildCapabilityDigest as t };
|
|
9
|
+
//# sourceMappingURL=digest-BsoVq49o.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest-BsoVq49o.d.mts","names":[],"sources":["../src/protocol/digest.ts"],"mappings":";;;cAEa,eAAA,GAAmB,KAAA;AAAA,cAcnB,UAAA,GAAc,KAAA;AAAA,cASd,qBAAA,GACX,QAAA,EAAU,IAAA,CAAK,iCAAA"}
|