@case-framework/survey-assistant 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/attachments-B0hg3vpT.mjs +11 -0
- package/dist/attachments-B0hg3vpT.mjs.map +1 -0
- package/dist/authoring-references-CW38pYzK.mjs +115 -0
- package/dist/authoring-references-CW38pYzK.mjs.map +1 -0
- package/dist/{capabilities-CnsVuJ1k.d.mts → capabilities-DVTfogjv.d.mts} +1 -1
- package/dist/{capabilities-CnsVuJ1k.d.mts.map → capabilities-DVTfogjv.d.mts.map} +1 -1
- package/dist/capabilities-default.d.mts +1 -1
- package/dist/capabilities-default.d.mts.map +1 -1
- package/dist/capabilities-default.mjs +39 -9
- package/dist/capabilities-default.mjs.map +1 -1
- package/dist/{constants-CFUWrRtl.mjs → constants-0UHGFcRJ.mjs} +1 -1
- package/dist/{constants-CFUWrRtl.mjs.map → constants-0UHGFcRJ.mjs.map} +1 -1
- package/dist/{constants-k1b_evIb.d.mts → constants-BMGTgfjv.d.mts} +4 -4
- package/dist/{constants-k1b_evIb.d.mts.map → constants-BMGTgfjv.d.mts.map} +1 -1
- package/dist/{controller-proxy-jWIPOZAv.mjs → controller-proxy-DMTqer6T.mjs} +1 -1
- package/dist/{controller-proxy-jWIPOZAv.mjs.map → controller-proxy-DMTqer6T.mjs.map} +1 -1
- package/dist/{controller-proxy-quQjtA7j.d.mts → controller-proxy-mRvez2qw.d.mts} +3 -3
- package/dist/{controller-proxy-quQjtA7j.d.mts.map → controller-proxy-mRvez2qw.d.mts.map} +1 -1
- package/dist/{digest-Dyjch_sC.d.mts → digest-SJmoYVaK.d.mts} +2 -2
- package/dist/{digest-Dyjch_sC.d.mts.map → digest-SJmoYVaK.d.mts.map} +1 -1
- package/dist/digest.d.mts +1 -1
- package/dist/{engine-BvfUx_Jx.mjs → engine-CQwOAcwK.mjs} +167 -24
- package/dist/engine-CQwOAcwK.mjs.map +1 -0
- package/dist/engine.d.mts +3 -3
- package/dist/engine.mjs +3 -3
- package/dist/{fair-guidance-CEdJYccK.mjs → fair-guidance-CRYCRxQm.mjs} +1 -1
- package/dist/{fair-guidance-CEdJYccK.mjs.map → fair-guidance-CRYCRxQm.mjs.map} +1 -1
- package/dist/{form-authoring-BQh40yDb.mjs → form-authoring-kQDgC5oz.mjs} +1 -1
- package/dist/{form-authoring-BQh40yDb.mjs.map → form-authoring-kQDgC5oz.mjs.map} +1 -1
- package/dist/{index-biZnRl-h.d.mts → index-B0lxsAzx.d.mts} +10 -6
- package/dist/index-B0lxsAzx.d.mts.map +1 -0
- package/dist/{index-BDp6S7r9.d.mts → index-BS-Xjk1h.d.mts} +4 -4
- package/dist/{index-BDp6S7r9.d.mts.map → index-BS-Xjk1h.d.mts.map} +1 -1
- package/dist/{index-r8HVcn5b.d.mts → index-D6nqkz0O.d.mts} +49 -8
- package/dist/{index-r8HVcn5b.d.mts.map → index-D6nqkz0O.d.mts.map} +1 -1
- package/dist/{index-8x1Eqlnz.d.mts → index-DvTqML-0.d.mts} +10 -5
- package/dist/index-DvTqML-0.d.mts.map +1 -0
- package/dist/{lifecycle-DWv5CiSu.d.mts → lifecycle-BmGAIUlv.d.mts} +2 -2
- package/dist/{lifecycle-DWv5CiSu.d.mts.map → lifecycle-BmGAIUlv.d.mts.map} +1 -1
- package/dist/{memory-thread-repository-xBZOog_q.mjs → memory-thread-repository-CjFGVNZh.mjs} +44 -13
- package/dist/{memory-thread-repository-xBZOog_q.mjs.map → memory-thread-repository-CjFGVNZh.mjs.map} +1 -1
- package/dist/protocol.d.mts +4 -4
- package/dist/protocol.mjs +2 -1
- package/dist/{react-CY6N7lVi.mjs → react-Dqlmasrs.mjs} +2 -2
- package/dist/{react-CY6N7lVi.mjs.map → react-Dqlmasrs.mjs.map} +1 -1
- package/dist/react-integration.d.mts +1 -1
- package/dist/react-integration.mjs +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.mjs +2 -2
- package/dist/{request-context-DixY5DYu.mjs → request-context-BjTHNcDd.mjs} +2 -2
- package/dist/{request-context-DixY5DYu.mjs.map → request-context-BjTHNcDd.mjs.map} +1 -1
- package/dist/{request-guardrails-h4t6u8mP.mjs → request-guardrails-TmgQtqp4.mjs} +5 -12
- package/dist/request-guardrails-TmgQtqp4.mjs.map +1 -0
- package/dist/server-agent.d.mts +9 -7
- package/dist/server-agent.d.mts.map +1 -1
- package/dist/server-agent.mjs +8 -6
- package/dist/server-agent.mjs.map +1 -1
- package/dist/server-runtime.d.mts +28 -14
- package/dist/server-runtime.d.mts.map +1 -1
- package/dist/server-runtime.mjs +47 -8
- package/dist/server-runtime.mjs.map +1 -1
- package/dist/server-tasks.d.mts +1 -1
- package/dist/server-tasks.mjs +4 -4
- package/dist/server-tools.d.mts +1 -1
- package/dist/server-tools.mjs +1 -1
- package/dist/server.d.mts +7 -7
- package/dist/server.mjs +6 -6
- package/dist/storage-postgres.d.mts +1 -1
- package/dist/storage-postgres.mjs +4 -1
- package/dist/storage-postgres.mjs.map +1 -1
- package/dist/{tasks-BWmTMXoK.d.mts → tasks-DxzD25Zc.d.mts} +16 -4
- package/dist/tasks-DxzD25Zc.d.mts.map +1 -0
- package/dist/{thread-documents-Dvo6XS7o.d.mts → thread-documents-rmd6nyX9.d.mts} +1 -1
- package/dist/{thread-documents-Dvo6XS7o.d.mts.map → thread-documents-rmd6nyX9.d.mts.map} +1 -1
- package/dist/{thread-handlers-D8gkLfU6.d.mts → thread-handlers-AbQbt4sX.d.mts} +13 -6
- package/dist/{thread-handlers-D8gkLfU6.d.mts.map → thread-handlers-AbQbt4sX.d.mts.map} +1 -1
- package/dist/{tools-TXI8bfzZ.mjs → tools-CFh35R4d.mjs} +14 -6
- package/dist/tools-CFh35R4d.mjs.map +1 -0
- package/dist/ui.css +1 -1
- package/dist/ui.d.mts +3 -3
- package/dist/ui.d.mts.map +1 -1
- package/dist/ui.mjs +198 -83
- package/dist/ui.mjs.map +1 -1
- package/docs/integration.md +37 -3
- package/package.json +2 -2
- package/dist/authoring-references-yyYC4Ydi.mjs +0 -98
- package/dist/authoring-references-yyYC4Ydi.mjs.map +0 -1
- package/dist/engine-BvfUx_Jx.mjs.map +0 -1
- package/dist/index-8x1Eqlnz.d.mts.map +0 -1
- package/dist/index-biZnRl-h.d.mts.map +0 -1
- package/dist/request-guardrails-h4t6u8mP.mjs.map +0 -1
- package/dist/tasks-BWmTMXoK.d.mts.map +0 -1
- package/dist/tools-TXI8bfzZ.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -278,3 +278,11 @@ custom authentication, provider policy, UI, or storage.
|
|
|
278
278
|
|
|
279
279
|
The high-level APIs are thin composition helpers over the same exported
|
|
280
280
|
primitives. They do not introduce a second runtime or hide Mastra.
|
|
281
|
+
|
|
282
|
+
Importing hosts can optionally require the additional
|
|
283
|
+
`SURVEY_ASSISTANT_ALLOW_EXPERIMENTAL_IDENTITY=true` production rollout gate by
|
|
284
|
+
passing `requireExperimentalIdentityOptIn: true` to a configuration parser.
|
|
285
|
+
The option does not choose or authorize an identity, and most authenticated
|
|
286
|
+
hosts should omit it unless they want that extra deployment switch. See
|
|
287
|
+
[Real-host integration](./docs/integration.md#optional-experimental-identity-rollout-gate)
|
|
288
|
+
for the exact enablement rules.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/protocol/attachments.ts
|
|
2
|
+
const SURVEY_ASSISTANT_ATTACHMENT_MEDIA_TYPES = [
|
|
3
|
+
"application/pdf",
|
|
4
|
+
"image/png",
|
|
5
|
+
"image/jpeg"
|
|
6
|
+
];
|
|
7
|
+
const isSurveyAssistantAttachmentMediaType = (mediaType) => SURVEY_ASSISTANT_ATTACHMENT_MEDIA_TYPES.includes(mediaType.toLowerCase());
|
|
8
|
+
//#endregion
|
|
9
|
+
export { isSurveyAssistantAttachmentMediaType as n, SURVEY_ASSISTANT_ATTACHMENT_MEDIA_TYPES as t };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=attachments-B0hg3vpT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments-B0hg3vpT.mjs","names":[],"sources":["../src/protocol/attachments.ts"],"sourcesContent":["export const SURVEY_ASSISTANT_ATTACHMENT_MEDIA_TYPES = [\n \"application/pdf\",\n \"image/png\",\n \"image/jpeg\",\n] as const;\n\nexport type SurveyAssistantAttachmentMediaType =\n (typeof SURVEY_ASSISTANT_ATTACHMENT_MEDIA_TYPES)[number];\n\nexport const isSurveyAssistantAttachmentMediaType = (\n mediaType: string,\n): mediaType is SurveyAssistantAttachmentMediaType =>\n (SURVEY_ASSISTANT_ATTACHMENT_MEDIA_TYPES as readonly string[]).includes(mediaType.toLowerCase());\n"],"mappings":";AAAA,MAAa,0CAA0C;CACrD;CACA;CACA;CACD;AAKD,MAAa,wCACX,cAEC,wCAA8D,SAAS,UAAU,aAAa,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import path, { resolve } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
//#region ../../node_modules/.pnpm/tsdown@0.21.10_synckit@0.11.13_typescript@6.0.3/node_modules/tsdown/esm-shims.js
|
|
5
|
+
const getFilename = () => fileURLToPath(import.meta.url);
|
|
6
|
+
const getDirname = () => path.dirname(getFilename());
|
|
7
|
+
const __dirname = /* @__PURE__ */ getDirname();
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/server/authoring-references.ts
|
|
10
|
+
const loadReference = (fileName) => readFileSync(resolve(__dirname, "references", fileName), "utf8").trim();
|
|
11
|
+
const surveyAuthoringReferenceTopics = [
|
|
12
|
+
"core-rules",
|
|
13
|
+
"survey-data-model",
|
|
14
|
+
"source-material-surveys",
|
|
15
|
+
"localization",
|
|
16
|
+
"rich-text-content",
|
|
17
|
+
"item-types",
|
|
18
|
+
"embedded-forms",
|
|
19
|
+
"expressions",
|
|
20
|
+
"assistant-operations",
|
|
21
|
+
"fair-by-design",
|
|
22
|
+
"survey-quality"
|
|
23
|
+
];
|
|
24
|
+
const ITEM_TYPE_SECTION_HEADINGS = {
|
|
25
|
+
group: "group",
|
|
26
|
+
"page-break": "page-break",
|
|
27
|
+
infoItem: "infoItem",
|
|
28
|
+
choiceItem: "choiceItem",
|
|
29
|
+
formItem: "formItem"
|
|
30
|
+
};
|
|
31
|
+
const builtInSurveyAuthoringItemTypes = Object.freeze(Object.keys(ITEM_TYPE_SECTION_HEADINGS));
|
|
32
|
+
const extractLevelTwoSection = (markdown, heading) => {
|
|
33
|
+
const lines = markdown.split("\n");
|
|
34
|
+
const sectionStart = lines.findIndex((line) => line.trim() === `## ${heading}`);
|
|
35
|
+
if (sectionStart < 0) return;
|
|
36
|
+
const nextSectionOffset = lines.slice(sectionStart + 1).findIndex((line) => line.startsWith("## "));
|
|
37
|
+
const sectionEnd = nextSectionOffset < 0 ? lines.length : sectionStart + 1 + nextSectionOffset;
|
|
38
|
+
return lines.slice(sectionStart, sectionEnd).join("\n").trim();
|
|
39
|
+
};
|
|
40
|
+
const surveyAuthoringReferences = {
|
|
41
|
+
"core-rules": {
|
|
42
|
+
title: "Core authoring rules",
|
|
43
|
+
content: loadReference("core-rules.md"),
|
|
44
|
+
loadWhen: "Load when the task depends on canonical tool choice, validation/apply semantics, identifier handling, or another cross-cutting authoring rule that the current turn has not already established."
|
|
45
|
+
},
|
|
46
|
+
"survey-data-model": {
|
|
47
|
+
title: "Survey data model",
|
|
48
|
+
content: loadReference("survey-data-model.md"),
|
|
49
|
+
loadWhen: "Load before reasoning about raw survey storage, hierarchy, ids, translation maps, assets, template values, or any direct survey-json-patch path whose exact location has not already been inspected and documented in the current turn."
|
|
50
|
+
},
|
|
51
|
+
"source-material-surveys": {
|
|
52
|
+
title: "Source-material survey implementation",
|
|
53
|
+
content: loadReference("source-material-surveys.md"),
|
|
54
|
+
loadWhen: "Load before implementing or adapting a questionnaire, document, image, or other supplied source material so completeness, respondent-input mapping, language, and digital adaptation rules are available before the first mutation."
|
|
55
|
+
},
|
|
56
|
+
localization: {
|
|
57
|
+
title: "Survey localization",
|
|
58
|
+
content: loadReference("localization.md"),
|
|
59
|
+
loadWhen: "Load before adding, removing, translating, or assessing a survey locale, including requests for localization completeness or locale lifecycle changes."
|
|
60
|
+
},
|
|
61
|
+
"rich-text-content": {
|
|
62
|
+
title: "Rich text content",
|
|
63
|
+
content: loadReference("rich-text-content.md"),
|
|
64
|
+
loadWhen: "Load before authoring or changing meaningful formatting, links, images, headings, lists, info boxes, separators, footnotes, or existing structured rich-text content; do not load it for ordinary unformatted plain text."
|
|
65
|
+
},
|
|
66
|
+
"item-types": {
|
|
67
|
+
title: "Item types",
|
|
68
|
+
content: loadReference("item-types.md"),
|
|
69
|
+
loadWhen: "Load with itemType before creating or changing an item when its configuration, response behavior, or content surfaces are not already fully specified by the current capability and focused operation contract; omit itemType only for a genuine cross-type comparison."
|
|
70
|
+
},
|
|
71
|
+
"embedded-forms": {
|
|
72
|
+
title: "Choice option embedded forms",
|
|
73
|
+
content: loadReference("embedded-forms.md"),
|
|
74
|
+
loadWhen: "Load before creating or changing a choice-option follow-up or embedded form, including \"Other, specify\", option-specific inputs, embedded field groups, or embedded-form layout and translations."
|
|
75
|
+
},
|
|
76
|
+
expressions: {
|
|
77
|
+
title: "Expressions",
|
|
78
|
+
content: loadReference("expressions.md"),
|
|
79
|
+
loadWhen: "Load before the first survey_expression prepare call for expression, condition, validation-expression, prefill, or template-value work unless the exact relevant JsonExpression and mutation shapes were already supplied by a current-turn authoring reference. survey_expression context supplies currently available runtime references and value types, but it does not replace the grammar reference. Expressions are not assumed to be survey-response-only; use the references and variable sources supported by the current runtime and reference."
|
|
80
|
+
},
|
|
81
|
+
"assistant-operations": {
|
|
82
|
+
title: "Assistant operations",
|
|
83
|
+
content: loadReference("assistant-operations.md"),
|
|
84
|
+
loadWhen: "Load with operationKind before the first survey_change call when the exact canonical fields of that operation are not already present in the current turn; add itemType when item-specific configuration or capability guidance is needed. Prefer compact detail and use full only for protocol debugging."
|
|
85
|
+
},
|
|
86
|
+
"fair-by-design": {
|
|
87
|
+
title: "FAIR-by-design survey authoring",
|
|
88
|
+
content: loadReference("fair-by-design.md"),
|
|
89
|
+
loadWhen: "Load before advising or editing when FAIR, interoperability, harmonization, cross-study reuse, stable coding, value sets, missingness semantics, metadata, provenance, versioning, standard instruments, controlled vocabularies, or machine-readable export is material; do not impose it on ordinary authoring."
|
|
90
|
+
},
|
|
91
|
+
"survey-quality": {
|
|
92
|
+
title: "Survey quality review",
|
|
93
|
+
content: loadReference("survey-quality.md"),
|
|
94
|
+
loadWhen: "Load before a substantive questionnaire-quality critique, wording or flow review, respondent-burden assessment, or recommendations about measurement quality; it is not required for a purely technical defect check."
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const formatSurveyAuthoringReferenceRoutingInstructions = () => [
|
|
98
|
+
"Authoring-reference routing rules:",
|
|
99
|
+
"Load a relevant focused reference before the first affected mutation or substantive advice, not after guessing a payload or learning through validator failures. Do not reload a reference when its exact relevant contract is already present in the current turn. References define stable authoring conventions and payload grammar; current survey state and currently available runtime references still come from inspection and context tools.",
|
|
100
|
+
"For installed capability-specific references, use the capability manifest's advertised reference topics. Load a relevant topic with itemType before changing unfamiliar capability configuration or behavior.",
|
|
101
|
+
...surveyAuthoringReferenceTopics.map((topic) => `- ${topic}: ${surveyAuthoringReferences[topic].loadWhen}`)
|
|
102
|
+
].join("\n");
|
|
103
|
+
const getBuiltInItemTypeAuthoringReference = (itemType) => {
|
|
104
|
+
const heading = ITEM_TYPE_SECTION_HEADINGS[itemType];
|
|
105
|
+
if (!heading) return;
|
|
106
|
+
const content = extractLevelTwoSection(surveyAuthoringReferences["item-types"].content, heading);
|
|
107
|
+
return content ? {
|
|
108
|
+
title: `${heading} item type`,
|
|
109
|
+
content
|
|
110
|
+
} : void 0;
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
export { surveyAuthoringReferences as a, surveyAuthoringReferenceTopics as i, formatSurveyAuthoringReferenceRoutingInstructions as n, getBuiltInItemTypeAuthoringReference as r, builtInSurveyAuthoringItemTypes as t };
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=authoring-references-CW38pYzK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring-references-CW38pYzK.mjs","names":[],"sources":["../../../node_modules/.pnpm/tsdown@0.21.10_synckit@0.11.13_typescript@6.0.3/node_modules/tsdown/esm-shims.js","../src/server/authoring-references.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nconst loadReference = (fileName: string) =>\n readFileSync(resolve(__dirname, \"references\", fileName), \"utf8\").trim();\n\nexport const surveyAuthoringReferenceTopics = [\n \"core-rules\",\n \"survey-data-model\",\n \"source-material-surveys\",\n \"localization\",\n \"rich-text-content\",\n \"item-types\",\n \"embedded-forms\",\n \"expressions\",\n \"assistant-operations\",\n \"fair-by-design\",\n \"survey-quality\",\n] as const;\n\nexport type SurveyAuthoringReferenceTopic = (typeof surveyAuthoringReferenceTopics)[number];\n\ntype SurveyAuthoringReferenceEntry = {\n title: string;\n content: string;\n loadWhen: string;\n};\n\nconst ITEM_TYPE_SECTION_HEADINGS: Readonly<Record<string, string>> = {\n group: \"group\",\n \"page-break\": \"page-break\",\n infoItem: \"infoItem\",\n choiceItem: \"choiceItem\",\n formItem: \"formItem\",\n};\n\nexport const builtInSurveyAuthoringItemTypes = Object.freeze(\n Object.keys(ITEM_TYPE_SECTION_HEADINGS),\n);\n\nconst extractLevelTwoSection = (markdown: string, heading: string): string | undefined => {\n const lines = markdown.split(\"\\n\");\n const sectionStart = lines.findIndex((line) => line.trim() === `## ${heading}`);\n if (sectionStart < 0) {\n return undefined;\n }\n\n const nextSectionOffset = lines\n .slice(sectionStart + 1)\n .findIndex((line) => line.startsWith(\"## \"));\n const sectionEnd = nextSectionOffset < 0 ? lines.length : sectionStart + 1 + nextSectionOffset;\n\n return lines.slice(sectionStart, sectionEnd).join(\"\\n\").trim();\n};\n\nexport const surveyAuthoringReferences = {\n \"core-rules\": {\n title: \"Core authoring rules\",\n content: loadReference(\"core-rules.md\"),\n loadWhen:\n \"Load when the task depends on canonical tool choice, validation/apply semantics, identifier handling, or another cross-cutting authoring rule that the current turn has not already established.\",\n },\n \"survey-data-model\": {\n title: \"Survey data model\",\n content: loadReference(\"survey-data-model.md\"),\n loadWhen:\n \"Load before reasoning about raw survey storage, hierarchy, ids, translation maps, assets, template values, or any direct survey-json-patch path whose exact location has not already been inspected and documented in the current turn.\",\n },\n \"source-material-surveys\": {\n title: \"Source-material survey implementation\",\n content: loadReference(\"source-material-surveys.md\"),\n loadWhen:\n \"Load before implementing or adapting a questionnaire, document, image, or other supplied source material so completeness, respondent-input mapping, language, and digital adaptation rules are available before the first mutation.\",\n },\n localization: {\n title: \"Survey localization\",\n content: loadReference(\"localization.md\"),\n loadWhen:\n \"Load before adding, removing, translating, or assessing a survey locale, including requests for localization completeness or locale lifecycle changes.\",\n },\n \"rich-text-content\": {\n title: \"Rich text content\",\n content: loadReference(\"rich-text-content.md\"),\n loadWhen:\n \"Load before authoring or changing meaningful formatting, links, images, headings, lists, info boxes, separators, footnotes, or existing structured rich-text content; do not load it for ordinary unformatted plain text.\",\n },\n \"item-types\": {\n title: \"Item types\",\n content: loadReference(\"item-types.md\"),\n loadWhen:\n \"Load with itemType before creating or changing an item when its configuration, response behavior, or content surfaces are not already fully specified by the current capability and focused operation contract; omit itemType only for a genuine cross-type comparison.\",\n },\n \"embedded-forms\": {\n title: \"Choice option embedded forms\",\n content: loadReference(\"embedded-forms.md\"),\n loadWhen:\n 'Load before creating or changing a choice-option follow-up or embedded form, including \"Other, specify\", option-specific inputs, embedded field groups, or embedded-form layout and translations.',\n },\n expressions: {\n title: \"Expressions\",\n content: loadReference(\"expressions.md\"),\n loadWhen:\n \"Load before the first survey_expression prepare call for expression, condition, validation-expression, prefill, or template-value work unless the exact relevant JsonExpression and mutation shapes were already supplied by a current-turn authoring reference. survey_expression context supplies currently available runtime references and value types, but it does not replace the grammar reference. Expressions are not assumed to be survey-response-only; use the references and variable sources supported by the current runtime and reference.\",\n },\n \"assistant-operations\": {\n title: \"Assistant operations\",\n content: loadReference(\"assistant-operations.md\"),\n loadWhen:\n \"Load with operationKind before the first survey_change call when the exact canonical fields of that operation are not already present in the current turn; add itemType when item-specific configuration or capability guidance is needed. Prefer compact detail and use full only for protocol debugging.\",\n },\n \"fair-by-design\": {\n title: \"FAIR-by-design survey authoring\",\n content: loadReference(\"fair-by-design.md\"),\n loadWhen:\n \"Load before advising or editing when FAIR, interoperability, harmonization, cross-study reuse, stable coding, value sets, missingness semantics, metadata, provenance, versioning, standard instruments, controlled vocabularies, or machine-readable export is material; do not impose it on ordinary authoring.\",\n },\n \"survey-quality\": {\n title: \"Survey quality review\",\n content: loadReference(\"survey-quality.md\"),\n loadWhen:\n \"Load before a substantive questionnaire-quality critique, wording or flow review, respondent-burden assessment, or recommendations about measurement quality; it is not required for a purely technical defect check.\",\n },\n} as const satisfies Record<SurveyAuthoringReferenceTopic, SurveyAuthoringReferenceEntry>;\n\nexport const formatSurveyAuthoringReferenceRoutingInstructions = (): string =>\n [\n \"Authoring-reference routing rules:\",\n \"Load a relevant focused reference before the first affected mutation or substantive advice, not after guessing a payload or learning through validator failures. Do not reload a reference when its exact relevant contract is already present in the current turn. References define stable authoring conventions and payload grammar; current survey state and currently available runtime references still come from inspection and context tools.\",\n \"For installed capability-specific references, use the capability manifest's advertised reference topics. Load a relevant topic with itemType before changing unfamiliar capability configuration or behavior.\",\n ...surveyAuthoringReferenceTopics.map(\n (topic) => `- ${topic}: ${surveyAuthoringReferences[topic].loadWhen}`,\n ),\n ].join(\"\\n\");\n\nexport const getBuiltInItemTypeAuthoringReference = (\n itemType: string,\n): { title: string; content: string } | undefined => {\n const heading = ITEM_TYPE_SECTION_HEADINGS[itemType];\n if (!heading) {\n return undefined;\n }\n\n const content = extractLevelTwoSection(surveyAuthoringReferences[\"item-types\"].content, heading);\n return content ? { title: `${heading} item type`, content } : undefined;\n};\n"],"x_google_ignoreList":[0],"mappings":";;;;AAIA,MAAM,oBAAoB,cAAc,OAAO,KAAK,IAAI;AACxD,MAAM,mBAAmB,KAAK,QAAQ,aAAa,CAAC;AAEpD,MAAa,YAA4B,4BAAY;;;ACJrD,MAAM,iBAAiB,aACrB,aAAa,QAAQ,WAAW,cAAc,SAAS,EAAE,OAAO,CAAC,MAAM;AAEzE,MAAa,iCAAiC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAUD,MAAM,6BAA+D;CACnE,OAAO;CACP,cAAc;CACd,UAAU;CACV,YAAY;CACZ,UAAU;CACX;AAED,MAAa,kCAAkC,OAAO,OACpD,OAAO,KAAK,2BAA2B,CACxC;AAED,MAAM,0BAA0B,UAAkB,YAAwC;CACxF,MAAM,QAAQ,SAAS,MAAM,KAAK;CAClC,MAAM,eAAe,MAAM,WAAW,SAAS,KAAK,MAAM,KAAK,MAAM,UAAU;AAC/E,KAAI,eAAe,EACjB;CAGF,MAAM,oBAAoB,MACvB,MAAM,eAAe,EAAE,CACvB,WAAW,SAAS,KAAK,WAAW,MAAM,CAAC;CAC9C,MAAM,aAAa,oBAAoB,IAAI,MAAM,SAAS,eAAe,IAAI;AAE7E,QAAO,MAAM,MAAM,cAAc,WAAW,CAAC,KAAK,KAAK,CAAC,MAAM;;AAGhE,MAAa,4BAA4B;CACvC,cAAc;EACZ,OAAO;EACP,SAAS,cAAc,gBAAgB;EACvC,UACE;EACH;CACD,qBAAqB;EACnB,OAAO;EACP,SAAS,cAAc,uBAAuB;EAC9C,UACE;EACH;CACD,2BAA2B;EACzB,OAAO;EACP,SAAS,cAAc,6BAA6B;EACpD,UACE;EACH;CACD,cAAc;EACZ,OAAO;EACP,SAAS,cAAc,kBAAkB;EACzC,UACE;EACH;CACD,qBAAqB;EACnB,OAAO;EACP,SAAS,cAAc,uBAAuB;EAC9C,UACE;EACH;CACD,cAAc;EACZ,OAAO;EACP,SAAS,cAAc,gBAAgB;EACvC,UACE;EACH;CACD,kBAAkB;EAChB,OAAO;EACP,SAAS,cAAc,oBAAoB;EAC3C,UACE;EACH;CACD,aAAa;EACX,OAAO;EACP,SAAS,cAAc,iBAAiB;EACxC,UACE;EACH;CACD,wBAAwB;EACtB,OAAO;EACP,SAAS,cAAc,0BAA0B;EACjD,UACE;EACH;CACD,kBAAkB;EAChB,OAAO;EACP,SAAS,cAAc,oBAAoB;EAC3C,UACE;EACH;CACD,kBAAkB;EAChB,OAAO;EACP,SAAS,cAAc,oBAAoB;EAC3C,UACE;EACH;CACF;AAED,MAAa,0DACX;CACE;CACA;CACA;CACA,GAAG,+BAA+B,KAC/B,UAAU,KAAK,MAAM,IAAI,0BAA0B,OAAO,WAC5D;CACF,CAAC,KAAK,KAAK;AAEd,MAAa,wCACX,aACmD;CACnD,MAAM,UAAU,2BAA2B;AAC3C,KAAI,CAAC,QACH;CAGF,MAAM,UAAU,uBAAuB,0BAA0B,cAAc,SAAS,QAAQ;AAChG,QAAO,UAAU;EAAE,OAAO,GAAG,QAAQ;EAAa;EAAS,GAAG,KAAA"}
|
|
@@ -190,4 +190,4 @@ type AssistantItemTypeManifest = z.infer<typeof assistantItemTypeManifestSchema>
|
|
|
190
190
|
type SurveyAssistantCapabilityManifest = z.infer<typeof surveyAssistantCapabilityManifestSchema>;
|
|
191
191
|
//#endregion
|
|
192
192
|
export { AssistantResponseSlot as a, assistantItemAuthoringSchema as c, assistantResponseSlotSchema as d, surveyAssistantCapabilityManifestSchema as f, AssistantItemTypeManifest as i, assistantItemCreateModeSchema as l, AssistantItemAuthoring as n, SurveyAssistantCapabilityManifest as o, AssistantItemCreateMode as r, assistantContentSurfaceSchema as s, AssistantContentSurface as t, assistantItemTypeManifestSchema as u };
|
|
193
|
-
//# sourceMappingURL=capabilities-
|
|
193
|
+
//# sourceMappingURL=capabilities-DVTfogjv.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities-
|
|
1
|
+
{"version":3,"file":"capabilities-DVTfogjv.d.mts","names":[],"sources":["../src/protocol/capabilities.ts"],"mappings":";;;cAGa,6BAAA,EAA6B,CAAA,CAAA,OAAA;;;;;cAM7B,6BAAA,EAA6B,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;cAS7B,2BAAA,EAA2B,CAAA,CAAA,SAAA;;;;cAK3B,4BAAA,EAA4B,CAAA,CAAA,SAAA;;;;cAS5B,+BAAA,EAA+B,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAe/B,uCAAA,EAAuC,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKxC,uBAAA,GAA0B,CAAA,CAAE,KAAA,QAAa,6BAAA;AAAA,KACzC,uBAAA,GAA0B,CAAA,CAAE,KAAA,QAAa,6BAAA;AAAA,KACzC,qBAAA,GAAwB,CAAA,CAAE,KAAA,QAAa,2BAAA;AAAA,KACvC,sBAAA,GAAyB,CAAA,CAAE,KAAA,QAAa,4BAAA;AAAA,KAExC,yBAAA,GAA4B,CAAA,CAAE,KAAA,QAAa,+BAAA;AAAA,KAC3C,iCAAA,GAAoC,CAAA,CAAE,KAAA,QACzC,uCAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Gt as SurveyAssistantCapabilitySet, Vt as AssistantItemCapabilityAdapter } from "./index-D6nqkz0O.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/capabilities/default.d.ts
|
|
4
4
|
declare const rootItemAssistantCapability: AssistantItemCapabilityAdapter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities-default.d.mts","names":[],"sources":["../src/capabilities/default.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"capabilities-default.d.mts","names":[],"sources":["../src/capabilities/default.ts"],"mappings":";;;cAkNa,2BAAA,EAA6B,8BAAA;AAAA,cAY7B,4BAAA,EAA8B,8BAAA;AAAA,cAsB9B,gCAAA,EAAkC,8BAAA;AAAA,cAsBlC,2BAAA,EAA6B,8BAAA;AAAA,cA6B7B,6BAAA,EAA+B,8BAAA;AAAA,cAyF/B,2BAAA,EAA6B,8BAAA;AAAA,cA2D7B,kCAAA,YAAkC,8BAAA,EAAA,8BAAA,EAAA,8BAAA,EAAA,8BAAA,EAAA,8BAAA,EAAA,8BAAA;AAAA,cASlC,mCAAA,EAEZ,4BAAA;AAAA,cAEY,mCAAA,GACX,QAAA,aACC,8BAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as normalizeFormAuthoringConfig, i as isValidSimpleFormConfig, l as createSurveyAssistantCapabilities } from "./form-authoring-
|
|
1
|
+
import { a as normalizeFormAuthoringConfig, i as isValidSimpleFormConfig, l as createSurveyAssistantCapabilities } from "./form-authoring-kQDgC5oz.mjs";
|
|
2
2
|
import { ValueType } from "@case-framework/survey-core";
|
|
3
3
|
//#region src/capabilities/default.ts
|
|
4
4
|
const COMMON_OPERATIONS = [
|
|
@@ -79,6 +79,36 @@ const QUESTION_REFERENCE = {
|
|
|
79
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
80
|
};
|
|
81
81
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
82
|
+
const withMaterializedConfig = (item, defaults) => ({
|
|
83
|
+
...item,
|
|
84
|
+
config: {
|
|
85
|
+
...defaults,
|
|
86
|
+
...isRecord(item.config) ? item.config : {}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const materializeGroupCreate = (item) => withMaterializedConfig(item, {
|
|
90
|
+
items: [],
|
|
91
|
+
shuffleItems: false
|
|
92
|
+
});
|
|
93
|
+
const materializeEmptyConfigCreate = (item) => withMaterializedConfig(item, {});
|
|
94
|
+
const materializeChoiceCreate = (item) => normalizeEmbeddedFormAuthoringModes({
|
|
95
|
+
...item,
|
|
96
|
+
config: {
|
|
97
|
+
...isRecord(item.config) ? item.config : {},
|
|
98
|
+
id: item.id,
|
|
99
|
+
maxSelection: isRecord(item.config) && "maxSelection" in item.config ? item.config.maxSelection : 1,
|
|
100
|
+
shuffleOptions: isRecord(item.config) && "shuffleOptions" in item.config ? item.config.shuffleOptions : false,
|
|
101
|
+
options: isRecord(item.config) && Array.isArray(item.config.options) ? item.config.options : []
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const materializeFormCreate = (item) => ({
|
|
105
|
+
...item,
|
|
106
|
+
config: normalizeFormAuthoringConfig({
|
|
107
|
+
fieldGroups: [],
|
|
108
|
+
...isRecord(item.config) ? item.config : {},
|
|
109
|
+
id: item.id
|
|
110
|
+
})
|
|
111
|
+
});
|
|
82
112
|
const getFieldValueType = (field) => {
|
|
83
113
|
switch (field.type) {
|
|
84
114
|
case "number":
|
|
@@ -164,7 +194,8 @@ const groupItemAssistantCapability = {
|
|
|
164
194
|
}],
|
|
165
195
|
referenceTopics: ["survey-data-model", "item-types"]
|
|
166
196
|
}),
|
|
167
|
-
references: [STRUCTURE_REFERENCE]
|
|
197
|
+
references: [STRUCTURE_REFERENCE],
|
|
198
|
+
normalizeCreate: materializeGroupCreate
|
|
168
199
|
};
|
|
169
200
|
const pageBreakItemAssistantCapability = {
|
|
170
201
|
manifest: createManifest({
|
|
@@ -187,7 +218,8 @@ const pageBreakItemAssistantCapability = {
|
|
|
187
218
|
}],
|
|
188
219
|
referenceTopics: ["survey-data-model", "item-types"]
|
|
189
220
|
}),
|
|
190
|
-
references: [STRUCTURE_REFERENCE]
|
|
221
|
+
references: [STRUCTURE_REFERENCE],
|
|
222
|
+
normalizeCreate: materializeEmptyConfigCreate
|
|
191
223
|
};
|
|
192
224
|
const infoItemAssistantCapability = {
|
|
193
225
|
manifest: createManifest({
|
|
@@ -216,7 +248,8 @@ const infoItemAssistantCapability = {
|
|
|
216
248
|
references: [{
|
|
217
249
|
topic: "rich-text-content",
|
|
218
250
|
markdown: "Info content uses the rich `content` surface. Markdown strings are not parsed; send structured rich text when formatting matters."
|
|
219
|
-
}]
|
|
251
|
+
}],
|
|
252
|
+
normalizeCreate: materializeEmptyConfigCreate
|
|
220
253
|
};
|
|
221
254
|
const choiceItemAssistantCapability = {
|
|
222
255
|
manifest: createManifest({
|
|
@@ -294,7 +327,7 @@ const choiceItemAssistantCapability = {
|
|
|
294
327
|
}
|
|
295
328
|
}),
|
|
296
329
|
references: [QUESTION_REFERENCE],
|
|
297
|
-
normalizeCreate:
|
|
330
|
+
normalizeCreate: materializeChoiceCreate,
|
|
298
331
|
validateItem: (item) => {
|
|
299
332
|
if (!isRecord(item.config) || !Array.isArray(item.config.options)) return [];
|
|
300
333
|
return item.config.options.flatMap((option) => isRecord(option) && isRecord(option.embeddedForm) ? getSimpleFormValidationIssues(option.embeddedForm, "An embedded form") : []);
|
|
@@ -361,10 +394,7 @@ const formItemAssistantCapability = {
|
|
|
361
394
|
}
|
|
362
395
|
}),
|
|
363
396
|
references: [QUESTION_REFERENCE],
|
|
364
|
-
normalizeCreate:
|
|
365
|
-
...item,
|
|
366
|
-
config: normalizeFormAuthoringConfig(item.config) ?? item.config
|
|
367
|
-
}),
|
|
397
|
+
normalizeCreate: materializeFormCreate,
|
|
368
398
|
validateItem: (item) => getSimpleFormValidationIssues(item.config, "A formItem"),
|
|
369
399
|
deriveResponseSlots: (item) => deriveFormResponseSlots(item.config)
|
|
370
400
|
};
|
|
@@ -1 +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\";\nimport { isValidSimpleFormConfig, normalizeFormAuthoringConfig } from \"../engine/form-authoring\";\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\nconst normalizeEmbeddedFormAuthoringModes = (item: RawSurveyItem): RawSurveyItem => {\n if (!isRecord(item.config) || !Array.isArray(item.config.options)) {\n return item;\n }\n\n return {\n ...item,\n config: {\n ...item.config,\n options: item.config.options.map((option) => {\n if (!isRecord(option) || !isRecord(option.embeddedForm)) {\n return option;\n }\n return {\n ...option,\n embeddedForm: normalizeFormAuthoringConfig(option.embeddedForm),\n };\n }),\n },\n };\n};\n\nconst getSimpleFormValidationIssues = (config: unknown, subject: string) =>\n isValidSimpleFormConfig(config)\n ? []\n : [\n {\n severity: \"error\" as const,\n code: \"invalid-simple-form-structure\",\n message: `${subject} with authoringMode \"simple\" must contain one single-column field group without group display behavior and exactly one supported field whose controller type matches the field type. Use authoringMode \"custom\" for any other structure.`,\n },\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 compactHint:\n \"presets choice.single=maxSelection 1; choice.multiple=maxSelection null; embedded one supported field=simple; embedded blank/structured=custom\",\n configSummary:\n \"Config stores id, maxSelection, shuffleOptions, and options. Put every initial option and inline embeddedForm in create-item config; choice option operations edit only choice items already present in the live snapshot. Default an eligible one-field embedded form to authoringMode simple; use custom for blank or structured follow-ups. Embedded field content uses embeddedForms.<choiceOption.id> (case-sensitive), never the option key or embeddedForm id. Form layout values are column counts 1-4; one column makes a lone field full width.\",\n },\n }),\n references: [QUESTION_REFERENCE],\n normalizeCreate: normalizeEmbeddedFormAuthoringModes,\n validateItem: (item) => {\n if (!isRecord(item.config) || !Array.isArray(item.config.options)) {\n return [];\n }\n return item.config.options.flatMap((option) =>\n isRecord(option) && isRecord(option.embeddedForm)\n ? getSimpleFormValidationIssues(option.embeddedForm, \"An embedded form\")\n : [],\n );\n },\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 compactHint:\n \"presets form.text=input|form.long-text=textarea|form.number=number|form.slider=slider|form.dropdown=select|form.date=datepicker|form.switch=switch; form.blank=custom\",\n configSummary:\n 'Config stores authoringMode and fieldGroups with typed fields. Use authoringMode \"simple\" only for exactly one internal group with exactly one field: text=input, long text=textarea, number=number, slider=slider, dropdown=select, date=datepicker, switch=switch. Use \"custom\" for blank or multi-field forms. Structural changes are a one-way transition to custom. The controller type must match the field type; full date uses datepicker/year-month-day. Layout values are column counts 1-4, not spans.',\n },\n }),\n references: [QUESTION_REFERENCE],\n normalizeCreate: (item) => ({\n ...item,\n config: normalizeFormAuthoringConfig(item.config) ?? item.config,\n }),\n validateItem: (item) => getSimpleFormValidationIssues(item.config, \"A formItem\"),\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"],"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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;GACT,aACE;GACF,eACE;GACH;EACF,CAAC;CACF,YAAY,CAAC,mBAAmB;CAChC,kBAAkB,UAAU;EAC1B,GAAG;EACH,QAAQ,6BAA6B,KAAK,OAAO,IAAI,KAAK;EAC3D;CACD,eAAe,SAAS,8BAA8B,KAAK,QAAQ,aAAa;CAChF,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"}
|
|
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\";\nimport { isValidSimpleFormConfig, normalizeFormAuthoringConfig } from \"../engine/form-authoring\";\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 withMaterializedConfig = (\n item: RawSurveyItem,\n defaults: Record<string, unknown>,\n): RawSurveyItem => ({\n ...item,\n config: {\n ...defaults,\n ...(isRecord(item.config) ? item.config : {}),\n },\n});\n\nconst materializeGroupCreate = (item: RawSurveyItem): RawSurveyItem =>\n withMaterializedConfig(item, { items: [], shuffleItems: false });\n\nconst materializeEmptyConfigCreate = (item: RawSurveyItem): RawSurveyItem =>\n withMaterializedConfig(item, {});\n\nconst materializeChoiceCreate = (item: RawSurveyItem): RawSurveyItem =>\n normalizeEmbeddedFormAuthoringModes({\n ...item,\n config: {\n ...(isRecord(item.config) ? item.config : {}),\n id: item.id,\n maxSelection:\n isRecord(item.config) && \"maxSelection\" in item.config ? item.config.maxSelection : 1,\n shuffleOptions:\n isRecord(item.config) && \"shuffleOptions\" in item.config\n ? item.config.shuffleOptions\n : false,\n options:\n isRecord(item.config) && Array.isArray(item.config.options) ? item.config.options : [],\n },\n });\n\nconst materializeFormCreate = (item: RawSurveyItem): RawSurveyItem => ({\n ...item,\n config: normalizeFormAuthoringConfig({\n fieldGroups: [],\n ...(isRecord(item.config) ? item.config : {}),\n id: item.id,\n }),\n});\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\nconst normalizeEmbeddedFormAuthoringModes = (item: RawSurveyItem): RawSurveyItem => {\n if (!isRecord(item.config) || !Array.isArray(item.config.options)) {\n return item;\n }\n\n return {\n ...item,\n config: {\n ...item.config,\n options: item.config.options.map((option) => {\n if (!isRecord(option) || !isRecord(option.embeddedForm)) {\n return option;\n }\n return {\n ...option,\n embeddedForm: normalizeFormAuthoringConfig(option.embeddedForm),\n };\n }),\n },\n };\n};\n\nconst getSimpleFormValidationIssues = (config: unknown, subject: string) =>\n isValidSimpleFormConfig(config)\n ? []\n : [\n {\n severity: \"error\" as const,\n code: \"invalid-simple-form-structure\",\n message: `${subject} with authoringMode \"simple\" must contain one single-column field group without group display behavior and exactly one supported field whose controller type matches the field type. Use authoringMode \"custom\" for any other structure.`,\n },\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 normalizeCreate: materializeGroupCreate,\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 normalizeCreate: materializeEmptyConfigCreate,\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 normalizeCreate: materializeEmptyConfigCreate,\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 compactHint:\n \"presets choice.single=maxSelection 1; choice.multiple=maxSelection null; embedded one supported field=simple; embedded blank/structured=custom\",\n configSummary:\n \"Config stores id, maxSelection, shuffleOptions, and options. Put every initial option and inline embeddedForm in create-item config; choice option operations edit only choice items already present in the live snapshot. Default an eligible one-field embedded form to authoringMode simple; use custom for blank or structured follow-ups. Embedded field content uses embeddedForms.<choiceOption.id> (case-sensitive), never the option key or embeddedForm id. Form layout values are column counts 1-4; one column makes a lone field full width.\",\n },\n }),\n references: [QUESTION_REFERENCE],\n normalizeCreate: materializeChoiceCreate,\n validateItem: (item) => {\n if (!isRecord(item.config) || !Array.isArray(item.config.options)) {\n return [];\n }\n return item.config.options.flatMap((option) =>\n isRecord(option) && isRecord(option.embeddedForm)\n ? getSimpleFormValidationIssues(option.embeddedForm, \"An embedded form\")\n : [],\n );\n },\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 compactHint:\n \"presets form.text=input|form.long-text=textarea|form.number=number|form.slider=slider|form.dropdown=select|form.date=datepicker|form.switch=switch; form.blank=custom\",\n configSummary:\n 'Config stores authoringMode and fieldGroups with typed fields. Use authoringMode \"simple\" only for exactly one internal group with exactly one field: text=input, long text=textarea, number=number, slider=slider, dropdown=select, date=datepicker, switch=switch. Use \"custom\" for blank or multi-field forms. Structural changes are a one-way transition to custom. The controller type must match the field type; full date uses datepicker/year-month-day. Layout values are column counts 1-4, not spans.',\n },\n }),\n references: [QUESTION_REFERENCE],\n normalizeCreate: materializeFormCreate,\n validateItem: (item) => getSimpleFormValidationIssues(item.config, \"A formItem\"),\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":";;;AAQA,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;EACN,QAAQ;EACR,SAAS,CAAC,SAAS;EACpB;CACF;AAED,MAAM,yBAAoD;CACxD;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC,KAAK,SAAS;CACd,KAAK,oBAAoB;CACzB,MAAM,QAAQ,UAAU,eAAe;CACvC,QAAQ;CACR,SAAS;CACV,EAAE;AAEH,MAAM,kBACJ,cAC+B;CAAE,mBAAmB;CAAK,GAAG;CAAU;AAExE,MAAM,sBAAsB;CAC1B,OAAO;CACP,UACE;CACH;AACD,MAAM,qBAAqB;CACzB,OAAO;CACP,UACE;CACH;AAED,MAAM,YAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;AAEtE,MAAM,0BACJ,MACA,cACmB;CACnB,GAAG;CACH,QAAQ;EACN,GAAG;EACH,GAAI,SAAS,KAAK,OAAO,GAAG,KAAK,SAAS,EAAE;EAC7C;CACF;AAED,MAAM,0BAA0B,SAC9B,uBAAu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AAK;GAAc,WAAW;GAAmB,CAAC;EACpE,iBAAiB;GAAC;GAAc;GAAgB;GAAe;GAAoB;EACnF,WAAW;GACT,aACE;GACF,eACE;GACH;EACF,CAAC;CACF,YAAY,CAAC,mBAAmB;CAChC,iBAAiB;CACjB,eAAe,SAAS,8BAA8B,KAAK,QAAQ,aAAa;CAChF,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants-
|
|
1
|
+
{"version":3,"file":"constants-0UHGFcRJ.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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Ct as SurveyDocumentSnapshot, o as SurveyAssistantApplyOutcome, wt as SurveyDocumentVersion } from "./lifecycle-
|
|
2
|
-
import {
|
|
3
|
-
import { n as SurveyAssistantModelAttachment, t as SurveyAssistantAttachmentAccess } from "./thread-documents-
|
|
1
|
+
import { Ct as SurveyDocumentSnapshot, o as SurveyAssistantApplyOutcome, wt as SurveyDocumentVersion } from "./lifecycle-BmGAIUlv.mjs";
|
|
2
|
+
import { Gt as SurveyAssistantCapabilitySet, jt as SurveyAssistantEngineContext, x as TurnSurveyDraft } from "./index-D6nqkz0O.mjs";
|
|
3
|
+
import { n as SurveyAssistantModelAttachment, t as SurveyAssistantAttachmentAccess } from "./thread-documents-rmd6nyX9.mjs";
|
|
4
4
|
import { RequestContext } from "@mastra/core/request-context";
|
|
5
5
|
import { AgentExecutionOptions } from "@mastra/core/agent";
|
|
6
6
|
import { OpenAICompatibleConfig } from "@mastra/core/llm";
|
|
@@ -99,4 +99,4 @@ declare const SURVEY_ASSISTANT_AGENT_ID = "survey-assistant-agent";
|
|
|
99
99
|
declare const SURVEY_ASSISTANT_TASK_AGENT_ID = "survey-assistant-task-agent";
|
|
100
100
|
//#endregion
|
|
101
101
|
export { SurveyAssistantModelSelection as a, deriveSurveyAssistantDocumentTransition as c, parseSurveyAssistantSnapshot as d, requireSurveyAssistantTurnState as f, SurveyAssistantIdentityContext as i, parseSurveyAssistantPreviousApplyOutcome as l, SURVEY_ASSISTANT_TASK_AGENT_ID as n, SurveyAssistantRequestContext as o, SurveyAssistantDocumentTransition as r, buildSurveyAssistantRequestContext as s, SURVEY_ASSISTANT_AGENT_ID as t, parseSurveyAssistantPreviousSettledVersion as u };
|
|
102
|
-
//# sourceMappingURL=constants-
|
|
102
|
+
//# sourceMappingURL=constants-BMGTgfjv.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants-
|
|
1
|
+
{"version":3,"file":"constants-BMGTgfjv.d.mts","names":[],"sources":["../src/server/request-context.ts","../src/server/constants.ts"],"mappings":";;;;;;;;UA2BiB,gCAAA;EACf,IAAA;AAAA;AAAA,UAGe,8BAAA;EACf,SAAA;EACA,UAAA;EACA,QAAA;EACA,QAAA;AAAA;AAAA,UAGe,6BAAA;EACf,EAAA;EACA,KAAA,WAAgB,sBAAA;EAChB,YAAA;EACA,eAAA,GAAkB,qBAAA;AAAA;AAAA,KAGR,iCAAA;EACN,MAAA;AAAA;EAEA,MAAA;EACA,oBAAA;EACA,mBAAA;AAAA;EAGA,MAAA;EACA,oBAAA;EACA,mBAAA;EACA,mBAAA;AAAA;EAGA,MAAA;EACA,oBAAA;EACA,mBAAA;EACA,gBAAA;EACA,eAAA,EAAiB,KAAA;EACjB,mBAAA;AAAA;AAAA,UAGW,6BAAA;EACf,UAAA,EAAY,gCAAA;EACZ,MAAA;EACA,SAAA,EAAW,eAAA;EACX,QAAA,EAAU,8BAAA;EACV,uBAAA;EACA,kBAAA;EACA,WAAA;EACA,kBAAA;EACA,gBAAA;EACA,kBAAA,GAAqB,iCAAA;EACrB,aAAA,GAAgB,4BAAA;EAChB,gBAAA,GAAmB,sBAAA;EACnB,gBAAA,GAAmB,8BAAA;EACnB,gBAAA,GAAmB,+BAAA;EACnB,cAAA,GAAiB,6BAAA;EACjB,oBAAA,GAAuB,2BAAA;AAAA;AAAA,cAGZ,4BAAA,GAAgC,KAAA,cAAiB,sBAAA;AAAA,cAQjD,0CAAA,GACX,KAAA,cACC,qBAAA;AAAA,cAQU,wCAAA,GACX,KAAA,cACC,2BAAA;AAAA,cAQU,uCAAA;EAA2C,OAAA;EAAA;AAAA;EAItD,OAAA,EAAS,sBAAA;EACT,QAAA,EAAU,qBAAA;AAAA,MACR,iCAAA;AAAA,cAqDS,kCAAA;EAAsC,SAAA;EAAA,QAAA;EAAA,QAAA;EAAA,sBAAA;EAAA,mBAAA;EAAA,gBAAA;EAAA,gBAAA;EAAA,cAAA;EAAA;AAAA;EAWjD,SAAA,EAAW,eAAA;EACX,QAAA,EAAU,8BAAA;EACV,QAAA,EAAU,sBAAA;EACV,sBAAA,GAAyB,qBAAA;EACzB,mBAAA,GAAsB,4BAAA;EACtB,gBAAA,GAAmB,+BAAA;EACnB,gBAAA,GAAmB,8BAAA;EACnB,cAAA,GAAiB,6BAAA;EACjB,oBAAA,GAAuB,2BAAA;AAAA,MACrB,cAAA,CAAe,6BAAA;AAAA,cAuDN,+BAAA,GACX,cAAA,EAAgB,cAAA,CAAe,6BAAA;;;;;;cCzPpB,yBAAA;AAAA,cACA,8BAAA"}
|
|
@@ -168,4 +168,4 @@ const createSurveyAssistantControllerBridge = (options) => {
|
|
|
168
168
|
//#endregion
|
|
169
169
|
export { applySurveyAssistantLaunchUIContext as a, SurveyAssistantClientError as c, createSurveyAssistantTaskExecutor as i, readSurveyAssistantJson as l, createSurveyAssistantControllerProxy as n, connectSurveyAssistantThreadLauncher as o, createSurveyAssistantTaskClient as r, createSurveyAssistantThreadLauncher as s, createSurveyAssistantControllerBridge as t };
|
|
170
170
|
|
|
171
|
-
//# sourceMappingURL=controller-proxy-
|
|
171
|
+
//# sourceMappingURL=controller-proxy-DMTqer6T.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-proxy-jWIPOZAv.mjs","names":[],"sources":["../src/react/client-error.ts","../src/react/thread-launcher.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 readonly retryable: boolean;\n\n constructor(code: SurveyAssistantErrorCode, message: string, retryable = false) {\n super(message);\n this.name = \"SurveyAssistantClientError\";\n this.code = code;\n this.retryable = retryable;\n }\n}\n\nexport const readSurveyAssistantJson = async (\n response: Response,\n fallback = \"The assistant request could not be completed.\",\n) => {\n if (!response.ok) {\n const responseText = await response.text().catch(() => \"\");\n let body: unknown;\n try {\n body = responseText ? JSON.parse(responseText) : undefined;\n } catch {\n body = undefined;\n }\n const detail =\n typeof body === \"object\" &&\n body !== null &&\n \"error\" in body &&\n typeof body.error === \"string\"\n ? body.error\n : responseText.trim() || fallback;\n const parsed = parseSurveyAssistantError(\n typeof body === \"object\" &&\n body !== null &&\n \"code\" in body &&\n typeof body.code === \"string\"\n ? { code: body.code, detail }\n : detail,\n );\n const explicitRetryable =\n typeof body === \"object\" &&\n body !== null &&\n \"retryable\" in body &&\n typeof body.retryable === \"boolean\"\n ? body.retryable\n : undefined;\n const retryable =\n explicitRetryable ??\n (parsed.code === \"rate_limited\" ||\n ((parsed.code === \"request_failed\" || parsed.code === \"attachment_unavailable\") &&\n response.status >= 500));\n throw new SurveyAssistantClientError(parsed.code, parsed.detail ?? detail, retryable);\n }\n return response.json().catch(() => ({}));\n};\n","import type {\n SurveyAssistantSnapshot,\n SurveyAssistantThread,\n SurveyEditorUIContext,\n} from \"../protocol\";\nimport type { FileUIPart } from \"ai\";\n\nexport type SurveyAssistantLaunchUIContext = Partial<Omit<SurveyEditorUIContext, \"history\">>;\n\nexport interface SurveyAssistantThreadLaunch {\n /** User-visible prompt submitted as the first message in the new thread. */\n prompt: string;\n files?: FileUIPart[];\n /** Optional model used for the opening assistant turn. */\n modelId?: string;\n /** Optional manual thread title. The prompt-derived automatic title is used by default. */\n title?: string;\n /** Turn-local editor context merged into the snapshot captured when the prompt is submitted. */\n uiContext?: SurveyAssistantLaunchUIContext;\n}\n\nexport interface SurveyAssistantThreadLauncher {\n /**\n * Creates a new thread and submits its first prompt when a connected panel is ready.\n * Calls made before the panel mounts are queued.\n */\n startThread(input: SurveyAssistantThreadLaunch): Promise<SurveyAssistantThread>;\n}\n\ntype LaunchHandler = (input: SurveyAssistantThreadLaunch) => Promise<SurveyAssistantThread>;\n\ninterface PendingLaunch {\n input: SurveyAssistantThreadLaunch;\n reject(error: unknown): void;\n resolve(thread: SurveyAssistantThread): void;\n}\n\ninterface LauncherState {\n handler: LaunchHandler | null;\n pending: PendingLaunch[];\n draining: boolean;\n}\n\nconst launcherStates = new WeakMap<SurveyAssistantThreadLauncher, LauncherState>();\n\nexport const applySurveyAssistantLaunchUIContext = (\n snapshot: SurveyAssistantSnapshot | null,\n uiContext: SurveyAssistantLaunchUIContext | undefined,\n): SurveyAssistantSnapshot | null =>\n snapshot && uiContext\n ? {\n ...snapshot,\n ui: {\n ...snapshot.ui,\n ...uiContext,\n },\n }\n : snapshot;\n\nconst getLauncherState = (launcher: SurveyAssistantThreadLauncher) => {\n const state = launcherStates.get(launcher);\n if (!state) {\n throw new Error(\n \"The survey assistant thread launcher was not created by createSurveyAssistantThreadLauncher.\",\n );\n }\n return state;\n};\n\nconst drainPendingLaunches = async (state: LauncherState) => {\n if (state.draining) return;\n state.draining = true;\n try {\n while (state.handler && state.pending.length > 0) {\n const pending = state.pending.shift();\n if (!pending) continue;\n try {\n pending.resolve(await state.handler(pending.input));\n } catch (error) {\n pending.reject(error);\n }\n }\n } finally {\n state.draining = false;\n }\n};\n\nexport const createSurveyAssistantThreadLauncher = (): SurveyAssistantThreadLauncher => {\n const state: LauncherState = { handler: null, pending: [], draining: false };\n const launcher: SurveyAssistantThreadLauncher = {\n startThread(input) {\n const prompt = input.prompt.trim();\n if (!prompt && (input.files?.length ?? 0) === 0) {\n return Promise.reject(new Error(\"A survey assistant prompt or attachment is required.\"));\n }\n\n return new Promise((resolve, reject) => {\n state.pending.push({\n input: {\n ...input,\n prompt,\n ...(input.files ? { files: [...input.files] } : {}),\n ...(input.modelId ? { modelId: input.modelId.trim() } : {}),\n ...(input.title ? { title: input.title.trim() } : {}),\n },\n reject,\n resolve,\n });\n void drainPendingLaunches(state);\n });\n },\n };\n launcherStates.set(launcher, state);\n return launcher;\n};\n\nexport const connectSurveyAssistantThreadLauncher = (\n launcher: SurveyAssistantThreadLauncher,\n handler: LaunchHandler,\n) => {\n const state = getLauncherState(launcher);\n if (state.handler && state.handler !== handler) {\n throw new Error(\"A survey assistant thread launcher can only control one mounted panel.\");\n }\n state.handler = handler;\n void drainPendingLaunches(state);\n\n return () => {\n if (state.handler === handler) state.handler = null;\n };\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 resourceId?: string;\n surveyId?: string;\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 resourceId,\n surveyId,\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 ...(resourceId ? { resourceId } : {}),\n ...(surveyId ? { surveyId } : {}),\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;CACA;CAEA,YAAY,MAAgC,SAAiB,YAAY,OAAO;AAC9E,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,YAAY;;;AAIrB,MAAa,0BAA0B,OACrC,UACA,WAAW,oDACR;AACH,KAAI,CAAC,SAAS,IAAI;EAChB,MAAM,eAAe,MAAM,SAAS,MAAM,CAAC,YAAY,GAAG;EAC1D,IAAI;AACJ,MAAI;AACF,UAAO,eAAe,KAAK,MAAM,aAAa,GAAG,KAAA;UAC3C;AACN,UAAO,KAAA;;EAET,MAAM,SACJ,OAAO,SAAS,YAChB,SAAS,QACT,WAAW,QACX,OAAO,KAAK,UAAU,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CACJ;AAED,MAAa,yCACX,YACoC;CACpC,IAAI;AACJ,QAAO;EACL,YAAY,2CAA2C,mBAAmB,QAAQ;EAClF,cAAc,YAAY;AACxB,uBAAoB;;EAEvB"}
|
|
1
|
+
{"version":3,"file":"controller-proxy-DMTqer6T.mjs","names":[],"sources":["../src/react/client-error.ts","../src/react/thread-launcher.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 readonly retryable: boolean;\n\n constructor(code: SurveyAssistantErrorCode, message: string, retryable = false) {\n super(message);\n this.name = \"SurveyAssistantClientError\";\n this.code = code;\n this.retryable = retryable;\n }\n}\n\nexport const readSurveyAssistantJson = async (\n response: Response,\n fallback = \"The assistant request could not be completed.\",\n) => {\n if (!response.ok) {\n const responseText = await response.text().catch(() => \"\");\n let body: unknown;\n try {\n body = responseText ? JSON.parse(responseText) : undefined;\n } catch {\n body = undefined;\n }\n const detail =\n typeof body === \"object\" &&\n body !== null &&\n \"error\" in body &&\n typeof body.error === \"string\"\n ? body.error\n : responseText.trim() || fallback;\n const parsed = parseSurveyAssistantError(\n typeof body === \"object\" &&\n body !== null &&\n \"code\" in body &&\n typeof body.code === \"string\"\n ? { code: body.code, detail }\n : detail,\n );\n const explicitRetryable =\n typeof body === \"object\" &&\n body !== null &&\n \"retryable\" in body &&\n typeof body.retryable === \"boolean\"\n ? body.retryable\n : undefined;\n const retryable =\n explicitRetryable ??\n (parsed.code === \"rate_limited\" ||\n ((parsed.code === \"request_failed\" || parsed.code === \"attachment_unavailable\") &&\n response.status >= 500));\n throw new SurveyAssistantClientError(parsed.code, parsed.detail ?? detail, retryable);\n }\n return response.json().catch(() => ({}));\n};\n","import type {\n SurveyAssistantSnapshot,\n SurveyAssistantThread,\n SurveyEditorUIContext,\n} from \"../protocol\";\nimport type { FileUIPart } from \"ai\";\n\nexport type SurveyAssistantLaunchUIContext = Partial<Omit<SurveyEditorUIContext, \"history\">>;\n\nexport interface SurveyAssistantThreadLaunch {\n /** User-visible prompt submitted as the first message in the new thread. */\n prompt: string;\n files?: FileUIPart[];\n /** Optional model used for the opening assistant turn. */\n modelId?: string;\n /** Optional manual thread title. The prompt-derived automatic title is used by default. */\n title?: string;\n /** Turn-local editor context merged into the snapshot captured when the prompt is submitted. */\n uiContext?: SurveyAssistantLaunchUIContext;\n}\n\nexport interface SurveyAssistantThreadLauncher {\n /**\n * Creates a new thread and submits its first prompt when a connected panel is ready.\n * Calls made before the panel mounts are queued.\n */\n startThread(input: SurveyAssistantThreadLaunch): Promise<SurveyAssistantThread>;\n}\n\ntype LaunchHandler = (input: SurveyAssistantThreadLaunch) => Promise<SurveyAssistantThread>;\n\ninterface PendingLaunch {\n input: SurveyAssistantThreadLaunch;\n reject(error: unknown): void;\n resolve(thread: SurveyAssistantThread): void;\n}\n\ninterface LauncherState {\n handler: LaunchHandler | null;\n pending: PendingLaunch[];\n draining: boolean;\n}\n\nconst launcherStates = new WeakMap<SurveyAssistantThreadLauncher, LauncherState>();\n\nexport const applySurveyAssistantLaunchUIContext = (\n snapshot: SurveyAssistantSnapshot | null,\n uiContext: SurveyAssistantLaunchUIContext | undefined,\n): SurveyAssistantSnapshot | null =>\n snapshot && uiContext\n ? {\n ...snapshot,\n ui: {\n ...snapshot.ui,\n ...uiContext,\n },\n }\n : snapshot;\n\nconst getLauncherState = (launcher: SurveyAssistantThreadLauncher) => {\n const state = launcherStates.get(launcher);\n if (!state) {\n throw new Error(\n \"The survey assistant thread launcher was not created by createSurveyAssistantThreadLauncher.\",\n );\n }\n return state;\n};\n\nconst drainPendingLaunches = async (state: LauncherState) => {\n if (state.draining) return;\n state.draining = true;\n try {\n while (state.handler && state.pending.length > 0) {\n const pending = state.pending.shift();\n if (!pending) continue;\n try {\n pending.resolve(await state.handler(pending.input));\n } catch (error) {\n pending.reject(error);\n }\n }\n } finally {\n state.draining = false;\n }\n};\n\nexport const createSurveyAssistantThreadLauncher = (): SurveyAssistantThreadLauncher => {\n const state: LauncherState = { handler: null, pending: [], draining: false };\n const launcher: SurveyAssistantThreadLauncher = {\n startThread(input) {\n const prompt = input.prompt.trim();\n if (!prompt && (input.files?.length ?? 0) === 0) {\n return Promise.reject(new Error(\"A survey assistant prompt or attachment is required.\"));\n }\n\n return new Promise((resolve, reject) => {\n state.pending.push({\n input: {\n ...input,\n prompt,\n ...(input.files ? { files: [...input.files] } : {}),\n ...(input.modelId ? { modelId: input.modelId.trim() } : {}),\n ...(input.title ? { title: input.title.trim() } : {}),\n },\n reject,\n resolve,\n });\n void drainPendingLaunches(state);\n });\n },\n };\n launcherStates.set(launcher, state);\n return launcher;\n};\n\nexport const connectSurveyAssistantThreadLauncher = (\n launcher: SurveyAssistantThreadLauncher,\n handler: LaunchHandler,\n) => {\n const state = getLauncherState(launcher);\n if (state.handler && state.handler !== handler) {\n throw new Error(\"A survey assistant thread launcher can only control one mounted panel.\");\n }\n state.handler = handler;\n void drainPendingLaunches(state);\n\n return () => {\n if (state.handler === handler) state.handler = null;\n };\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 resourceId?: string;\n surveyId?: string;\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 resourceId,\n surveyId,\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 ...(resourceId ? { resourceId } : {}),\n ...(surveyId ? { surveyId } : {}),\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;CACA;CAEA,YAAY,MAAgC,SAAiB,YAAY,OAAO;AAC9E,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,YAAY;;;AAIrB,MAAa,0BAA0B,OACrC,UACA,WAAW,oDACR;AACH,KAAI,CAAC,SAAS,IAAI;EAChB,MAAM,eAAe,MAAM,SAAS,MAAM,CAAC,YAAY,GAAG;EAC1D,IAAI;AACJ,MAAI;AACF,UAAO,eAAe,KAAK,MAAM,aAAa,GAAG,KAAA;UAC3C;AACN,UAAO,KAAA;;EAET,MAAM,SACJ,OAAO,SAAS,YAChB,SAAS,QACT,WAAW,QACX,OAAO,KAAK,UAAU,WAClB,KAAK,QACL,aAAa,MAAM,IAAI;EAC7B,MAAM,SAAS,0BACb,OAAO,SAAS,YACd,SAAS,Q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Q;EAClF,cAAc,YAAY;AACxB,uBAAoB;;EAEvB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as SurveyAssistantThread, c as SurveyAssistantSuggestItemKeyInput, d as SurveyAssistantSuggestItemLabelResult, l as SurveyAssistantSuggestItemKeyResult, m as SurveyAssistantTaskInvocationMode, p as SurveyAssistantTaskContext, u as SurveyAssistantSuggestItemLabelInput, v as SurveyAssistantTranslateContentInput, y as SurveyAssistantTranslateContentResult } from "./index-
|
|
2
|
-
import { Tt as SurveyEditorUIContext, h as SurveyChangeSet, i as SurveyApplyResult, m as SurveyBatchApplyResult, xt as SurveyAssistantSnapshot } from "./lifecycle-
|
|
1
|
+
import { L as SurveyAssistantThread, c as SurveyAssistantSuggestItemKeyInput, d as SurveyAssistantSuggestItemLabelResult, l as SurveyAssistantSuggestItemKeyResult, m as SurveyAssistantTaskInvocationMode, p as SurveyAssistantTaskContext, u as SurveyAssistantSuggestItemLabelInput, v as SurveyAssistantTranslateContentInput, y as SurveyAssistantTranslateContentResult } from "./index-DvTqML-0.mjs";
|
|
2
|
+
import { Tt as SurveyEditorUIContext, h as SurveyChangeSet, i as SurveyApplyResult, m as SurveyBatchApplyResult, xt as SurveyAssistantSnapshot } from "./lifecycle-BmGAIUlv.mjs";
|
|
3
3
|
import { FileUIPart } from "ai";
|
|
4
4
|
|
|
5
5
|
//#region src/react/thread-launcher.d.ts
|
|
@@ -82,4 +82,4 @@ declare const createSurveyAssistantControllerProxy: (getController: () => Survey
|
|
|
82
82
|
declare const createSurveyAssistantControllerBridge: (options?: CreateSurveyAssistantControllerProxyOptions) => SurveyAssistantControllerBridge;
|
|
83
83
|
//#endregion
|
|
84
84
|
export { createSurveyAssistantThreadLauncher as _, SurveyAssistantController as a, SurveyAssistantTaskExecutionOptions as c, SurveyAssistantTaskExecutorRequestOptions as d, createSurveyAssistantTaskClient as f, SurveyAssistantThreadLauncher as g, SurveyAssistantThreadLaunch as h, createSurveyAssistantControllerProxy as i, SurveyAssistantTaskExecutor as l, SurveyAssistantLaunchUIContext as m, SurveyAssistantControllerBridge as n, SurveyAssistantTaskClient as o, createSurveyAssistantTaskExecutor as p, createSurveyAssistantControllerBridge as r, SurveyAssistantTaskClientOptions as s, CreateSurveyAssistantControllerProxyOptions as t, SurveyAssistantTaskExecutorCacheContext as u };
|
|
85
|
-
//# sourceMappingURL=controller-proxy-
|
|
85
|
+
//# sourceMappingURL=controller-proxy-mRvez2qw.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-proxy-
|
|
1
|
+
{"version":3,"file":"controller-proxy-mRvez2qw.d.mts","names":[],"sources":["../src/react/thread-launcher.ts","../src/react/task-client.ts","../src/react/controller.ts","../src/react/controller-proxy.ts"],"mappings":";;;;;KAOY,8BAAA,GAAiC,OAAA,CAAQ,IAAA,CAAK,qBAAA;AAAA,UAEzC,2BAAA;;EAEf,MAAA;EACA,KAAA,GAAQ,UAAA;;EAER,OAAA;EAPmD;EASnD,KAAA;EATkD;EAWlD,SAAA,GAAY,8BAAA;AAAA;AAAA,UAGG,6BAAA;EAdyC;;;AAE1D;EAiBE,WAAA,CAAY,KAAA,EAAO,2BAAA,GAA8B,OAAA,CAAQ,qBAAA;AAAA;AAAA,cA6D9C,mCAAA,QAA0C,6BAAA;;;UCxEtC,gCAAA;EACf,GAAA;EACA,UAAA;EACA,UAAA;EACA,QAAA;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,E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AssistantCapabilityManifest } from "./capabilities-
|
|
1
|
+
import { o as SurveyAssistantCapabilityManifest } from "./capabilities-DVTfogjv.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/protocol/digest.d.ts
|
|
4
4
|
declare const stableStringify: (value: unknown) => string;
|
|
@@ -6,4 +6,4 @@ declare const hashString: (input: string) => string;
|
|
|
6
6
|
declare const buildCapabilityDigest: (manifest: Omit<SurveyAssistantCapabilityManifest, "digest">) => string;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { hashString as n, stableStringify as r, buildCapabilityDigest as t };
|
|
9
|
-
//# sourceMappingURL=digest-
|
|
9
|
+
//# sourceMappingURL=digest-SJmoYVaK.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digest-
|
|
1
|
+
{"version":3,"file":"digest-SJmoYVaK.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"}
|
package/dist/digest.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as hashString, r as stableStringify, t as buildCapabilityDigest } from "./digest-
|
|
1
|
+
import { n as hashString, r as stableStringify, t as buildCapabilityDigest } from "./digest-SJmoYVaK.mjs";
|
|
2
2
|
export { buildCapabilityDigest, hashString, stableStringify };
|