@case-framework/survey-assistant 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +71 -11
  2. package/dist/{authoring-references-X6uRaWuf.mjs → authoring-references-DYuOAdVx.mjs} +26 -2
  3. package/dist/authoring-references-DYuOAdVx.mjs.map +1 -0
  4. package/dist/{capabilities-B6tvE7fK.mjs → capabilities-DZ0a_o2y.mjs} +2 -2
  5. package/dist/{capabilities-B6tvE7fK.mjs.map → capabilities-DZ0a_o2y.mjs.map} +1 -1
  6. package/dist/{capabilities-DvSKtjAw.d.mts → capabilities-DlC1l6qy.d.mts} +4 -1
  7. package/dist/capabilities-DlC1l6qy.d.mts.map +1 -0
  8. package/dist/capabilities-default.d.mts +1 -1
  9. package/dist/capabilities-default.d.mts.map +1 -1
  10. package/dist/capabilities-default.mjs +6 -3
  11. package/dist/capabilities-default.mjs.map +1 -1
  12. package/dist/{constants-Jw0k8ojS.d.mts → constants-56jf_4ls.d.mts} +36 -9
  13. package/dist/constants-56jf_4ls.d.mts.map +1 -0
  14. package/dist/{controller-proxy-BRDusFiO.d.mts → controller-proxy-2VH0b_5E.d.mts} +29 -4
  15. package/dist/controller-proxy-2VH0b_5E.d.mts.map +1 -0
  16. package/dist/{controller-proxy-Duxo2IFE.mjs → controller-proxy-ClsY4lFI.mjs} +74 -5
  17. package/dist/controller-proxy-ClsY4lFI.mjs.map +1 -0
  18. package/dist/{digest-BsoVq49o.d.mts → digest-BvXpeWcR.d.mts} +2 -2
  19. package/dist/{digest-BsoVq49o.d.mts.map → digest-BvXpeWcR.d.mts.map} +1 -1
  20. package/dist/digest.d.mts +1 -1
  21. package/dist/{engine-sPvuixWg.mjs → engine-DQrCO_ur.mjs} +392 -50
  22. package/dist/engine-DQrCO_ur.mjs.map +1 -0
  23. package/dist/engine.d.mts +2 -2
  24. package/dist/engine.mjs +2 -2
  25. package/dist/{index-MpEMQzTm.d.mts → index-B_x2IYi7.d.mts} +5 -1
  26. package/dist/index-B_x2IYi7.d.mts.map +1 -0
  27. package/dist/{index-BWNHkpkh.d.mts → index-C_x686M7.d.mts} +27 -5
  28. package/dist/index-C_x686M7.d.mts.map +1 -0
  29. package/dist/{index-TFtvBiSQ.d.mts → index-DVxVyhAu.d.mts} +31 -9
  30. package/dist/index-DVxVyhAu.d.mts.map +1 -0
  31. package/dist/{index-CUqbBjkc.d.mts → index-DZ6KBwVR.d.mts} +16 -3
  32. package/dist/index-DZ6KBwVR.d.mts.map +1 -0
  33. package/dist/{memory-thread-repository-CJkkVE2-.mjs → memory-thread-repository-Cm1BJyRw.mjs} +110 -41
  34. package/dist/memory-thread-repository-Cm1BJyRw.mjs.map +1 -0
  35. package/dist/{protocol-DV0ka9WT.mjs → protocol-7EEgcYja.mjs} +70 -97
  36. package/dist/protocol-7EEgcYja.mjs.map +1 -0
  37. package/dist/protocol.d.mts +3 -3
  38. package/dist/protocol.mjs +2 -2
  39. package/dist/{react-VuYe-cPh.mjs → react-B_5smfiK.mjs} +145 -38
  40. package/dist/react-B_5smfiK.mjs.map +1 -0
  41. package/dist/react-integration.d.mts +2 -2
  42. package/dist/react-integration.mjs +2 -2
  43. package/dist/react.d.mts +3 -3
  44. package/dist/react.mjs +3 -3
  45. package/dist/references/assistant-operations.md +6 -0
  46. package/dist/references/core-rules.md +6 -0
  47. package/dist/references/embedded-forms.md +21 -14
  48. package/dist/references/expressions.md +3 -0
  49. package/dist/references/item-types.md +37 -10
  50. package/dist/references/source-material-surveys.md +9 -1
  51. package/dist/references/survey-data-model.md +13 -0
  52. package/dist/request-context-BDBw4-Gw.mjs +79 -0
  53. package/dist/request-context-BDBw4-Gw.mjs.map +1 -0
  54. package/dist/request-guardrails-h4t6u8mP.mjs +129 -0
  55. package/dist/request-guardrails-h4t6u8mP.mjs.map +1 -0
  56. package/dist/server-agent.d.mts +6 -2
  57. package/dist/server-agent.d.mts.map +1 -1
  58. package/dist/server-agent.mjs +39 -24
  59. package/dist/server-agent.mjs.map +1 -1
  60. package/dist/server-runtime.d.mts +21 -5
  61. package/dist/server-runtime.d.mts.map +1 -1
  62. package/dist/server-runtime.mjs +98 -32
  63. package/dist/server-runtime.mjs.map +1 -1
  64. package/dist/server-tasks.d.mts +2 -78
  65. package/dist/server-tasks.mjs +103 -46
  66. package/dist/server-tasks.mjs.map +1 -1
  67. package/dist/server-tools.d.mts +1 -1
  68. package/dist/server-tools.mjs +1 -1
  69. package/dist/server.d.mts +89 -21
  70. package/dist/server.d.mts.map +1 -1
  71. package/dist/server.mjs +136 -5
  72. package/dist/server.mjs.map +1 -0
  73. package/dist/storage-postgres.d.mts +12 -2
  74. package/dist/storage-postgres.d.mts.map +1 -1
  75. package/dist/storage-postgres.mjs +11 -6
  76. package/dist/storage-postgres.mjs.map +1 -1
  77. package/dist/tasks-COQnhSeT.d.mts +140 -0
  78. package/dist/tasks-COQnhSeT.d.mts.map +1 -0
  79. package/dist/{thread-documents-DamIq9Od.d.mts → thread-documents-BlxNjc7S.d.mts} +21 -5
  80. package/dist/thread-documents-BlxNjc7S.d.mts.map +1 -0
  81. package/dist/{thread-handlers-DpynUc64.d.mts → thread-handlers-l79JBl5m.d.mts} +38 -5
  82. package/dist/thread-handlers-l79JBl5m.d.mts.map +1 -0
  83. package/dist/{tools-Hz2p7vyv.mjs → tools-DDXaJ8Za.mjs} +257 -38
  84. package/dist/tools-DDXaJ8Za.mjs.map +1 -0
  85. package/dist/ui.d.mts +5 -3
  86. package/dist/ui.d.mts.map +1 -1
  87. package/dist/ui.mjs +91 -12
  88. package/dist/ui.mjs.map +1 -1
  89. package/docs/integration.md +234 -0
  90. package/package.json +9 -7
  91. package/dist/authoring-references-Cy8J-DWt.d.mts +0 -48
  92. package/dist/authoring-references-Cy8J-DWt.d.mts.map +0 -1
  93. package/dist/authoring-references-X6uRaWuf.mjs.map +0 -1
  94. package/dist/capabilities-DvSKtjAw.d.mts.map +0 -1
  95. package/dist/constants-Jw0k8ojS.d.mts.map +0 -1
  96. package/dist/controller-proxy-BRDusFiO.d.mts.map +0 -1
  97. package/dist/controller-proxy-Duxo2IFE.mjs.map +0 -1
  98. package/dist/engine-sPvuixWg.mjs.map +0 -1
  99. package/dist/index-BWNHkpkh.d.mts.map +0 -1
  100. package/dist/index-CUqbBjkc.d.mts.map +0 -1
  101. package/dist/index-MpEMQzTm.d.mts.map +0 -1
  102. package/dist/index-TFtvBiSQ.d.mts.map +0 -1
  103. package/dist/memory-thread-repository-CJkkVE2-.mjs.map +0 -1
  104. package/dist/protocol-DV0ka9WT.mjs.map +0 -1
  105. package/dist/react-VuYe-cPh.mjs.map +0 -1
  106. package/dist/request-context-jcmXT_Q2.mjs +0 -44
  107. package/dist/request-context-jcmXT_Q2.mjs.map +0 -1
  108. package/dist/request-guardrails-C59IWnH8.mjs +0 -73
  109. package/dist/request-guardrails-C59IWnH8.mjs.map +0 -1
  110. package/dist/server-tasks.d.mts.map +0 -1
  111. package/dist/thread-documents-DamIq9Od.d.mts.map +0 -1
  112. package/dist/thread-handlers-DpynUc64.d.mts.map +0 -1
  113. package/dist/tools-Hz2p7vyv.mjs.map +0 -1
package/README.md CHANGED
@@ -24,6 +24,8 @@ import {
24
24
 
25
25
  import {
26
26
  createSurveyAssistantChatHandler,
27
+ createSurveyAssistantSurveyLifecycle,
28
+ createSurveyAssistantSurveyThreadMetadata,
27
29
  type SurveyAssistantAuthorize,
28
30
  } from "@case-framework/survey-assistant/server";
29
31
 
@@ -57,6 +59,7 @@ import {
57
59
  createSurveyAssistantControllerBridge,
58
60
  createSurveyAssistantTaskClient,
59
61
  createSurveyAssistantTaskExecutor,
62
+ createSurveyAssistantThreadLauncher,
60
63
  } from "@case-framework/survey-assistant/react/integration";
61
64
 
62
65
  import { useSurveyAssistantModelCatalog } from "@case-framework/survey-assistant/react";
@@ -83,8 +86,9 @@ instructions, thread-scoped Observational Memory defaults, and optional
83
86
  history-compatibility policy for custom memory setups. `/server/runtime` is the
84
87
  high-level composition layer: it parses an injected environment, resolves the
85
88
  approved provider/model catalog (including optional Azure deployment
86
- discovery), exposes standard Mastra agents and gateways, and creates the Web
87
- handlers. The host still constructs the standard Mastra instance and owns
89
+ discovery), applies independent same-provider task and memory model policy,
90
+ exposes standard Mastra agents and gateways, and creates the Web handlers. The
91
+ host still constructs the standard Mastra instance and owns
88
92
  credentials, authorization, storage connection lifecycle, logging, and route
89
93
  files.
90
94
 
@@ -109,20 +113,77 @@ defaults without supplying a complete catalog.
109
113
  localizations={assistantLocalizations}
110
114
  onModelChange={setSelectedModelId}
111
115
  resourceId={authenticatedUserId}
116
+ surveyId={surveyId}
112
117
  threadApi="/api/survey-assistant/threads"
113
118
  />
114
119
  ```
115
120
 
121
+ Host UI can start a fresh assistant thread with an already-submitted prompt. The
122
+ launcher queues requests made before the panel mounts, which supports replacing
123
+ a prompt-only new-survey screen with the chat after submission:
124
+
125
+ ```tsx
126
+ const threadLauncher = useMemo(() => createSurveyAssistantThreadLauncher(), []);
127
+
128
+ const describeNewItem = (prompt: string, parentItemId: string, afterItemId?: string) => {
129
+ setAssistantOpen(true);
130
+ void threadLauncher.startThread({
131
+ prompt,
132
+ uiContext: {
133
+ activeSurface: "new-item",
134
+ focusItemId: parentItemId,
135
+ highlights: [
136
+ {
137
+ kind: "insertion-target",
138
+ itemId: parentItemId,
139
+ label: "Requested item position",
140
+ details: afterItemId ? `Insert after item ${afterItemId}` : "Insert as the first child",
141
+ },
142
+ ],
143
+ },
144
+ });
145
+ };
146
+
147
+ return assistantOpen ? (
148
+ <ConnectedSurveyAssistantPanel
149
+ api="/api/survey-assistant/chat"
150
+ applyPolicy="auto"
151
+ controller={assistantController}
152
+ resourceId={authenticatedUserId}
153
+ threadApi="/api/survey-assistant/threads"
154
+ threadLauncher={threadLauncher}
155
+ />
156
+ ) : (
157
+ <NewSurveyPrompt onSubmit={(prompt) => describeNewItem(prompt, "root")} />
158
+ );
159
+ ```
160
+
161
+ `startThread()` resolves after the new thread has been selected and its first
162
+ turn has been accepted by the chat session. `uiContext` is layered over the
163
+ controller snapshot for that turn only; it does not mutate editor selection or
164
+ navigation state. Use typed highlights for transient targets such as an
165
+ insertion position.
166
+
116
167
  The browser-supplied `resourceId` is request metadata, not authorization. A
117
168
  production host must derive user, survey, and thread ownership in the server
118
169
  handler's required `authorize` callback.
119
170
 
171
+ For the supported real-app setup, configuration reference, route/auth contract,
172
+ attachment policy, apply settlement, observability, cleanup, and acceptance
173
+ checklist, see [Real-host integration](./docs/integration.md).
174
+
175
+ `createSurveyAssistantSurveyLifecycle(...).forSurvey(surveyId, resourceId)`
176
+ provides one shared thread identity, chat authorizer, panel-prop object, and
177
+ per-user cleanup method so those paths cannot drift onto different survey
178
+ metadata.
179
+
120
180
  `/protocol`, `/engine`, and `/capabilities/default` may not import React,
121
- Next.js, Mastra, AI SDK, `survey-ui`, or Node-only storage. `/protocol` has only
122
- Zod runtime dependencies; `/engine` may use `survey-core`. `/server` is
181
+ Next.js, Mastra, AI SDK, `survey-ui`, or Node-only storage. `/protocol` has Zod
182
+ plus the narrow browser-safe `survey-core/editor/colors` runtime dependency;
183
+ `/engine` may use the full `survey-core` API. `/server` is
123
184
  server-only and may import Mastra, AI SDK, and Node APIs, but never React,
124
185
  Next.js, or `survey-ui`. The separate server entries prevent handler-only
125
- consumers from eagerly loading Agent/Memory code. `@case-framework/survey-ui`
186
+ consumers from eagerly loading Agent/Memory code. `@case-framework/survey-editor-ui`
126
187
  owns the optional live-editor bridge, snapshot/apply functions, and snapshot-backed
127
188
  one-shot provider because those functions must operate on its editor instance
128
189
  and item registry. The assistant package supplies the standard task Web handler
@@ -163,7 +224,7 @@ export const ratingAssistantCapability = {
163
224
  } satisfies AssistantItemCapabilityAdapter;
164
225
 
165
226
  // rating-entry.tsx (client/editor module)
166
- import type { ItemRegistryEntry } from "@case-framework/survey-ui";
227
+ import type { ItemRegistryEntry } from "@case-framework/survey-editor-ui";
167
228
 
168
229
  export const ratingQuestionEntry = {
169
230
  itemType: "ratingQuestion",
@@ -181,15 +242,14 @@ once. Server configuration imports `ratingAssistantCapability` directly and
181
242
  adds it to the trusted capability set; it must not trust capability functions
182
243
  received from a browser snapshot.
183
244
 
184
- See [Custom item registration](../../docs/survey-assistant/survey-ui-bridge.md#custom-item-registration)
185
- for the complete editor and server composition example.
186
-
187
245
  ```bash
188
246
  pnpm --filter @case-framework/survey-assistant check
247
+ pnpm --filter @case-framework/survey-assistant check:release
189
248
  ```
190
249
 
191
- This typechecks and builds all entries, copies server references, then verifies
192
- their source and built import graphs. The optional Postgres entry accepts a
250
+ `check` typechecks and builds all entries, copies server references, verifies
251
+ their source and built import graphs, and runs unit tests. `check:release` also
252
+ builds the clean Next host fixture. The optional Postgres entry accepts a
193
253
  host-owned `PostgresStore` or store configuration; it does not read environment
194
254
  variables, create hidden singletons, or own connection shutdown.
195
255
 
@@ -20,6 +20,21 @@ const surveyAuthoringReferenceTopics = [
20
20
  "assistant-operations",
21
21
  "survey-quality"
22
22
  ];
23
+ const ITEM_TYPE_SECTION_HEADINGS = {
24
+ group: "group",
25
+ "page-break": "page-break",
26
+ infoItem: "infoItem",
27
+ choiceItem: "choiceItem",
28
+ formItem: "formItem"
29
+ };
30
+ const extractLevelTwoSection = (markdown, heading) => {
31
+ const lines = markdown.split("\n");
32
+ const sectionStart = lines.findIndex((line) => line.trim() === `## ${heading}`);
33
+ if (sectionStart < 0) return;
34
+ const nextSectionOffset = lines.slice(sectionStart + 1).findIndex((line) => line.startsWith("## "));
35
+ const sectionEnd = nextSectionOffset < 0 ? lines.length : sectionStart + 1 + nextSectionOffset;
36
+ return lines.slice(sectionStart, sectionEnd).join("\n").trim();
37
+ };
23
38
  const surveyAuthoringReferences = {
24
39
  "core-rules": {
25
40
  title: "Core authoring rules",
@@ -62,7 +77,16 @@ const surveyAuthoringReferences = {
62
77
  content: loadReference("survey-quality.md")
63
78
  }
64
79
  };
80
+ const getBuiltInItemTypeAuthoringReference = (itemType) => {
81
+ const heading = ITEM_TYPE_SECTION_HEADINGS[itemType];
82
+ if (!heading) return;
83
+ const content = extractLevelTwoSection(surveyAuthoringReferences["item-types"].content, heading);
84
+ return content ? {
85
+ title: `${heading} item type`,
86
+ content
87
+ } : void 0;
88
+ };
65
89
  //#endregion
66
- export { surveyAuthoringReferences as n, surveyAuthoringReferenceTopics as t };
90
+ export { surveyAuthoringReferenceTopics as n, surveyAuthoringReferences as r, getBuiltInItemTypeAuthoringReference as t };
67
91
 
68
- //# sourceMappingURL=authoring-references-X6uRaWuf.mjs.map
92
+ //# sourceMappingURL=authoring-references-DYuOAdVx.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring-references-DYuOAdVx.mjs","names":[],"sources":["../../../node_modules/.pnpm/tsdown@0.21.10_synckit@0.11.12_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 \"survey-quality\",\n] as const;\n\nexport type SurveyAuthoringReferenceTopic = (typeof surveyAuthoringReferenceTopics)[number];\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\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 },\n \"survey-data-model\": {\n title: \"Survey data model\",\n content: loadReference(\"survey-data-model.md\"),\n },\n \"source-material-surveys\": {\n title: \"Source-material survey implementation\",\n content: loadReference(\"source-material-surveys.md\"),\n },\n localization: {\n title: \"Survey localization\",\n content: loadReference(\"localization.md\"),\n },\n \"rich-text-content\": {\n title: \"Rich text content\",\n content: loadReference(\"rich-text-content.md\"),\n },\n \"item-types\": {\n title: \"Item types\",\n content: loadReference(\"item-types.md\"),\n },\n \"embedded-forms\": {\n title: \"Choice option embedded forms\",\n content: loadReference(\"embedded-forms.md\"),\n },\n expressions: {\n title: \"Expressions\",\n content: loadReference(\"expressions.md\"),\n },\n \"assistant-operations\": {\n title: \"Assistant operations\",\n content: loadReference(\"assistant-operations.md\"),\n },\n \"survey-quality\": {\n title: \"Survey quality review\",\n content: loadReference(\"survey-quality.md\"),\n },\n} as const satisfies Record<SurveyAuthoringReferenceTopic, { title: string; content: string }>;\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,K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cAAc,oBAAoB;EAC5C;CACF;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"}
@@ -1,4 +1,4 @@
1
- import { W as assistantItemTypeManifestSchema } from "./protocol-DV0ka9WT.mjs";
1
+ import { G as assistantItemTypeManifestSchema } from "./protocol-7EEgcYja.mjs";
2
2
  import { buildCapabilityDigest } from "./digest.mjs";
3
3
  //#region src/engine/capabilities.ts
4
4
  const resolveAssistantCapabilityReference = ({ capabilities, itemType, topic }) => capabilities?.byItemType.get(itemType)?.references?.find((reference) => reference.topic === topic);
@@ -63,4 +63,4 @@ const assertSurveyAssistantCapabilities = ({ manifest, trustedCapabilities, vers
63
63
  //#endregion
64
64
  export { getDeterministicCreateItemTypes as a, resolveAssistantItemCreation as c, createUnsupportedItemCapability as i, assertSurveyAssistantCapabilities as n, inspectAssistantItem as o, createSurveyAssistantCapabilities as r, resolveAssistantCapabilityReference as s, SurveyAssistantCapabilityMismatchError as t };
65
65
 
66
- //# sourceMappingURL=capabilities-B6tvE7fK.mjs.map
66
+ //# sourceMappingURL=capabilities-DZ0a_o2y.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities-B6tvE7fK.mjs","names":[],"sources":["../src/engine/capabilities.ts"],"sourcesContent":["import type { RawSurveyItem, ValueType } from \"@case-framework/survey-core\";\nimport type {\n AssistantItemTypeManifest,\n JsonValue,\n SurveyAssistantCapabilityManifest,\n SurveyOperation,\n SurveyValidationIssue,\n} from \"../protocol\";\nimport { assistantItemTypeManifestSchema } from \"../protocol\";\nimport { buildCapabilityDigest } from \"../protocol/digest\";\n\nexport interface AssistantCapabilityReference {\n topic: string;\n title?: string;\n markdown: string;\n}\n\nexport interface AssistantItemInspection {\n summary: string;\n details?: JsonValue;\n}\n\nexport interface AssistantItemCapabilityAdapter {\n manifest: AssistantItemTypeManifest;\n references?: AssistantCapabilityReference[];\n normalizeCreate?: (item: RawSurveyItem) => RawSurveyItem;\n validateItem?: (item: RawSurveyItem) => SurveyValidationIssue[];\n supportsOperation?: (operation: SurveyOperation) => boolean;\n deriveResponseSlots?: (item: RawSurveyItem) => Record<string, ValueType>;\n inspectItem?: (item: RawSurveyItem) => AssistantItemInspection;\n}\n\nexport interface SurveyAssistantCapabilitySet {\n manifest: SurveyAssistantCapabilityManifest;\n byItemType: ReadonlyMap<string, AssistantItemCapabilityAdapter>;\n}\n\nexport const resolveAssistantCapabilityReference = ({\n capabilities,\n itemType,\n topic,\n}: {\n capabilities: SurveyAssistantCapabilitySet | undefined;\n itemType: string;\n topic: string;\n}): AssistantCapabilityReference | undefined =>\n capabilities?.byItemType\n .get(itemType)\n ?.references?.find((reference) => reference.topic === topic);\n\nexport const inspectAssistantItem = ({\n capabilities,\n item,\n}: {\n capabilities: SurveyAssistantCapabilitySet | undefined;\n item: RawSurveyItem;\n}): AssistantItemInspection | undefined =>\n capabilities?.byItemType.get(item.itemType)?.inspectItem?.(item);\n\nexport type AssistantItemCreationResolution =\n | { kind: \"deterministic\" }\n | {\n kind: \"ui-intent\";\n intent: { kind: \"open-create-item\"; itemType: string; parentItemId?: string };\n }\n | { kind: \"unsupported\"; reason: string };\n\nexport const createSurveyAssistantCapabilities = (\n capabilities: readonly AssistantItemCapabilityAdapter[],\n): SurveyAssistantCapabilitySet => {\n const byItemType = new Map<string, AssistantItemCapabilityAdapter>();\n\n for (const capability of capabilities) {\n const manifest = assistantItemTypeManifestSchema.parse(capability.manifest);\n const itemType = manifest.itemType;\n if (byItemType.has(itemType)) {\n throw new Error(`Duplicate survey assistant capability for item type \"${itemType}\".`);\n }\n if (\n manifest.create === \"deterministic\" &&\n !manifest.supportedOperations.includes(\"create-item\")\n ) {\n throw new Error(\n `Deterministically creatable item type \"${itemType}\" must support \"create-item\".`,\n );\n }\n const declaredReferenceTopics = new Set(manifest.referenceTopics ?? []);\n for (const reference of capability.references ?? []) {\n if (!declaredReferenceTopics.has(reference.topic)) {\n throw new Error(\n `Capability reference \"${reference.topic}\" for item type \"${itemType}\" is missing from manifest.referenceTopics.`,\n );\n }\n }\n byItemType.set(itemType, capability);\n }\n\n const itemTypes = Array.from(byItemType.values())\n .map((capability) => capability.manifest)\n .sort((left, right) => left.itemType.localeCompare(right.itemType));\n const manifestWithoutDigest = { itemTypes };\n\n return {\n manifest: {\n ...manifestWithoutDigest,\n digest: buildCapabilityDigest(manifestWithoutDigest),\n },\n byItemType,\n };\n};\n\nexport const getDeterministicCreateItemTypes = (\n manifest: SurveyAssistantCapabilityManifest,\n): string[] =>\n manifest.itemTypes\n .filter((entry) => entry.create === \"deterministic\")\n .map((entry) => entry.itemType);\n\nexport const resolveAssistantItemCreation = ({\n itemType,\n manifest,\n parentItemId,\n}: {\n itemType: string;\n manifest: SurveyAssistantCapabilityManifest;\n parentItemId?: string;\n}): AssistantItemCreationResolution => {\n const capability = manifest.itemTypes.find((entry) => entry.itemType === itemType);\n if (capability?.create === \"deterministic\") {\n return { kind: \"deterministic\" };\n }\n if (capability?.create === \"interactive-only\") {\n return {\n kind: \"ui-intent\",\n intent: { kind: \"open-create-item\", itemType, parentItemId },\n };\n }\n return {\n kind: \"unsupported\",\n reason: capability\n ? `Item type \"${itemType}\" does not support assistant creation.`\n : `Item type \"${itemType}\" is not installed.`,\n };\n};\n\nexport const createUnsupportedItemCapability = ({\n displayName,\n itemType,\n}: {\n displayName: string;\n itemType: string;\n}): AssistantItemCapabilityAdapter => ({\n manifest: {\n itemType,\n capabilityVersion: \"unsupported-v1\",\n displayName,\n create: \"unsupported\",\n supportedOperations: [],\n contentSurfaces: [],\n },\n});\n\nexport class SurveyAssistantCapabilityMismatchError extends Error {\n readonly code = \"survey-assistant-capability-mismatch\";\n\n constructor(message = \"Survey assistant capabilities changed; start a fresh turn and retry.\") {\n super(message);\n this.name = \"SurveyAssistantCapabilityMismatchError\";\n }\n}\n\nexport const assertSurveyAssistantCapabilities = ({\n manifest,\n trustedCapabilities,\n versionDigest,\n}: {\n manifest: SurveyAssistantCapabilityManifest;\n trustedCapabilities?: SurveyAssistantCapabilitySet;\n versionDigest: string;\n}): void => {\n const { digest: claimedDigest, ...manifestWithoutDigest } = manifest;\n const computedDigest = buildCapabilityDigest(manifestWithoutDigest);\n if (claimedDigest !== computedDigest || versionDigest !== claimedDigest) {\n throw new SurveyAssistantCapabilityMismatchError();\n }\n\n if (trustedCapabilities && trustedCapabilities.manifest.digest !== claimedDigest) {\n throw new SurveyAssistantCapabilityMismatchError(\n \"The editor and server use different survey assistant capabilities; refresh and retry.\",\n );\n }\n};\n"],"mappings":";;;AAqCA,MAAa,uCAAuC,EAClD,cACA,UACA,YAMA,cAAc,WACX,IAAI,SAAS,EACZ,YAAY,MAAM,cAAc,UAAU,UAAU,MAAM;AAEhE,MAAa,wBAAwB,EACnC,cACA,WAKA,cAAc,WAAW,IAAI,KAAK,SAAS,EAAE,cAAc,KAAK;AAUlE,MAAa,qCACX,iBACiC;CACjC,MAAM,6BAAa,IAAI,KAA6C;AAEpE,MAAK,MAAM,cAAc,cAAc;EACrC,MAAM,WAAW,gCAAgC,MAAM,WAAW,SAAS;EAC3E,MAAM,WAAW,SAAS;AAC1B,MAAI,WAAW,IAAI,SAAS,CAC1B,OAAM,IAAI,MAAM,wDAAwD,SAAS,IAAI;AAEvF,MACE,SAAS,WAAW,mBACpB,CAAC,SAAS,oBAAoB,SAAS,cAAc,CAErD,OAAM,IAAI,MACR,0CAA0C,SAAS,+BACpD;EAEH,MAAM,0BAA0B,IAAI,IAAI,SAAS,mBAAmB,EAAE,CAAC;AACvE,OAAK,MAAM,aAAa,WAAW,cAAc,EAAE,CACjD,KAAI,CAAC,wBAAwB,IAAI,UAAU,MAAM,CAC/C,OAAM,IAAI,MACR,yBAAyB,UAAU,MAAM,mBAAmB,SAAS,6CACtE;AAGL,aAAW,IAAI,UA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[],"sources":["../src/engine/capabilities.ts"],"sourcesContent":["import type { RawSurveyItem, ValueType } from \"@case-framework/survey-core\";\nimport type {\n AssistantItemTypeManifest,\n JsonValue,\n SurveyAssistantCapabilityManifest,\n SurveyOperation,\n SurveyValidationIssue,\n} from \"../protocol\";\nimport { assistantItemTypeManifestSchema } from \"../protocol\";\nimport { buildCapabilityDigest } from \"../protocol/digest\";\n\nexport interface AssistantCapabilityReference {\n topic: string;\n title?: string;\n markdown: string;\n}\n\nexport interface AssistantItemInspection {\n summary: string;\n details?: JsonValue;\n}\n\nexport interface AssistantItemCapabilityAdapter {\n manifest: AssistantItemTypeManifest;\n references?: AssistantCapabilityReference[];\n normalizeCreate?: (item: RawSurveyItem) => RawSurveyItem;\n validateItem?: (item: RawSurveyItem) => SurveyValidationIssue[];\n supportsOperation?: (operation: SurveyOperation) => boolean;\n deriveResponseSlots?: (item: RawSurveyItem) => Record<string, ValueType>;\n inspectItem?: (item: RawSurveyItem) => AssistantItemInspection;\n}\n\nexport interface SurveyAssistantCapabilitySet {\n manifest: SurveyAssistantCapabilityManifest;\n byItemType: ReadonlyMap<string, AssistantItemCapabilityAdapter>;\n}\n\nexport const resolveAssistantCapabilityReference = ({\n capabilities,\n itemType,\n topic,\n}: {\n capabilities: SurveyAssistantCapabilitySet | undefined;\n itemType: string;\n topic: string;\n}): AssistantCapabilityReference | undefined =>\n capabilities?.byItemType\n .get(itemType)\n ?.references?.find((reference) => reference.topic === topic);\n\nexport const inspectAssistantItem = ({\n capabilities,\n item,\n}: {\n capabilities: SurveyAssistantCapabilitySet | undefined;\n item: RawSurveyItem;\n}): AssistantItemInspection | undefined =>\n capabilities?.byItemType.get(item.itemType)?.inspectItem?.(item);\n\nexport type AssistantItemCreationResolution =\n | { kind: \"deterministic\" }\n | {\n kind: \"ui-intent\";\n intent: { kind: \"open-create-item\"; itemType: string; parentItemId?: string };\n }\n | { kind: \"unsupported\"; reason: string };\n\nexport const createSurveyAssistantCapabilities = (\n capabilities: readonly AssistantItemCapabilityAdapter[],\n): SurveyAssistantCapabilitySet => {\n const byItemType = new Map<string, AssistantItemCapabilityAdapter>();\n\n for (const capability of capabilities) {\n const manifest = assistantItemTypeManifestSchema.parse(capability.manifest);\n const itemType = manifest.itemType;\n if (byItemType.has(itemType)) {\n throw new Error(`Duplicate survey assistant capability for item type \"${itemType}\".`);\n }\n if (\n manifest.create === \"deterministic\" &&\n !manifest.supportedOperations.includes(\"create-item\")\n ) {\n throw new Error(\n `Deterministically creatable item type \"${itemType}\" must support \"create-item\".`,\n );\n }\n const declaredReferenceTopics = new Set(manifest.referenceTopics ?? []);\n for (const reference of capability.references ?? []) {\n if (!declaredReferenceTopics.has(reference.topic)) {\n throw new Error(\n `Capability reference \"${reference.topic}\" for item type \"${itemType}\" is missing from manifest.referenceTopics.`,\n );\n }\n }\n byItemType.set(itemType, capability);\n }\n\n const itemTypes = Array.from(byItemType.values())\n .map((capability) => capability.manifest)\n .sort((left, right) => left.itemType.localeCompare(right.itemType));\n const manifestWithoutDigest = { itemTypes };\n\n return {\n manifest: {\n ...manifestWithoutDigest,\n digest: buildCapabilityDigest(manifestWithoutDigest),\n },\n byItemType,\n };\n};\n\nexport const getDeterministicCreateItemTypes = (\n manifest: SurveyAssistantCapabilityManifest,\n): string[] =>\n manifest.itemTypes\n .filter((entry) => entry.create === \"deterministic\")\n .map((entry) => entry.itemType);\n\nexport const resolveAssistantItemCreation = ({\n itemType,\n manifest,\n parentItemId,\n}: {\n itemType: string;\n manifest: SurveyAssistantCapabilityManifest;\n parentItemId?: string;\n}): AssistantItemCreationResolution => {\n const capability = manifest.itemTypes.find((entry) => entry.itemType === itemType);\n if (capability?.create === \"deterministic\") {\n return { kind: \"deterministic\" };\n }\n if (capability?.create === \"interactive-only\") {\n return {\n kind: \"ui-intent\",\n intent: { kind: \"open-create-item\", itemType, parentItemId },\n };\n }\n return {\n kind: \"unsupported\",\n reason: capability\n ? `Item type \"${itemType}\" does not support assistant creation.`\n : `Item type \"${itemType}\" is not installed.`,\n };\n};\n\nexport const createUnsupportedItemCapability = ({\n displayName,\n itemType,\n}: {\n displayName: string;\n itemType: string;\n}): AssistantItemCapabilityAdapter => ({\n manifest: {\n itemType,\n capabilityVersion: \"unsupported-v1\",\n displayName,\n create: \"unsupported\",\n supportedOperations: [],\n contentSurfaces: [],\n },\n});\n\nexport class SurveyAssistantCapabilityMismatchError extends Error {\n readonly code = \"survey-assistant-capability-mismatch\";\n\n constructor(message = \"Survey assistant capabilities changed; start a fresh turn and retry.\") {\n super(message);\n this.name = \"SurveyAssistantCapabilityMismatchError\";\n }\n}\n\nexport const assertSurveyAssistantCapabilities = ({\n manifest,\n trustedCapabilities,\n versionDigest,\n}: {\n manifest: SurveyAssistantCapabilityManifest;\n trustedCapabilities?: SurveyAssistantCapabilitySet;\n versionDigest: string;\n}): void => {\n const { digest: claimedDigest, ...manifestWithoutDigest } = manifest;\n const computedDigest = buildCapabilityDigest(manifestWithoutDigest);\n if (claimedDigest !== computedDigest || versionDigest !== claimedDigest) {\n throw new SurveyAssistantCapabilityMismatchError();\n }\n\n if (trustedCapabilities && trustedCapabilities.manifest.digest !== claimedDigest) {\n throw new SurveyAssistantCapabilityMismatchError(\n \"The editor and server use different survey assistant capabilities; refresh and retry.\",\n );\n }\n};\n"],"mappings":";;;AAqCA,MAAa,uCAAuC,EAClD,cACA,UACA,YAMA,cAAc,WACX,IAAI,SAAS,EACZ,YAAY,MAAM,cAAc,UAAU,UAAU,MAAM;AAEhE,MAAa,wBAAwB,EACnC,cACA,WAKA,cAAc,WAAW,IAAI,KAAK,SAAS,EAAE,cAAc,KAAK;AAUlE,MAAa,qCACX,iBACiC;CACjC,MAAM,6BAAa,IAAI,KAA6C;AAEpE,MAAK,MAAM,cAAc,cAAc;EACrC,MAAM,WAAW,gCAAgC,MAAM,WAAW,SAAS;EAC3E,MAAM,WAAW,SAAS;AAC1B,MAAI,WAAW,IAAI,SAAS,CAC1B,OAAM,IAAI,MAAM,wDAAwD,SAAS,IA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,YAAY,UAAU,wEAAwE;AAC5F,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAIhB,MAAa,qCAAqC,EAChD,UACA,qBACA,oBAKU;CACV,MAAM,EAAE,QAAQ,eAAe,GAAG,0BAA0B;AAE5D,KAAI,kBADmB,sBAAsB,sBACT,IAAI,kBAAkB,cACxD,OAAM,IAAI,wCAAwC;AAGpD,KAAI,uBAAuB,oBAAoB,SAAS,WAAW,cACjE,OAAM,IAAI,uCACR,wFACD"}
@@ -28,6 +28,7 @@ declare const assistantResponseSlotSchema: z.ZodObject<{
28
28
  valueType: z.ZodString;
29
29
  }, z.core.$strip>;
30
30
  declare const assistantItemAuthoringSchema: z.ZodObject<{
31
+ compactHint: z.ZodOptional<z.ZodString>;
31
32
  configSummary: z.ZodOptional<z.ZodString>;
32
33
  }, z.core.$strip>;
33
34
  declare const assistantItemTypeManifestSchema: z.ZodObject<{
@@ -96,6 +97,7 @@ declare const assistantItemTypeManifestSchema: z.ZodObject<{
96
97
  }, z.core.$strip>>>;
97
98
  referenceTopics: z.ZodOptional<z.ZodArray<z.ZodString>>;
98
99
  authoring: z.ZodOptional<z.ZodObject<{
100
+ compactHint: z.ZodOptional<z.ZodString>;
99
101
  configSummary: z.ZodOptional<z.ZodString>;
100
102
  }, z.core.$strip>>;
101
103
  }, z.core.$strip>;
@@ -167,6 +169,7 @@ declare const surveyAssistantCapabilityManifestSchema: z.ZodObject<{
167
169
  }, z.core.$strip>>>;
168
170
  referenceTopics: z.ZodOptional<z.ZodArray<z.ZodString>>;
169
171
  authoring: z.ZodOptional<z.ZodObject<{
172
+ compactHint: z.ZodOptional<z.ZodString>;
170
173
  configSummary: z.ZodOptional<z.ZodString>;
171
174
  }, z.core.$strip>>;
172
175
  }, z.core.$strip>>;
@@ -179,4 +182,4 @@ type AssistantItemTypeManifest = z.infer<typeof assistantItemTypeManifestSchema>
179
182
  type SurveyAssistantCapabilityManifest = z.infer<typeof surveyAssistantCapabilityManifestSchema>;
180
183
  //#endregion
181
184
  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 };
182
- //# sourceMappingURL=capabilities-DvSKtjAw.d.mts.map
185
+ //# sourceMappingURL=capabilities-DlC1l6qy.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities-DlC1l6qy.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;;;;cAK5B,+BAAA,EAA+B,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAc/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,KACxC,yBAAA,GAA4B,CAAA,CAAE,KAAA,QAAa,+BAAA;AAAA,KAC3C,iCAAA,GAAoC,CAAA,CAAE,KAAA,QACzC,uCAAA"}
@@ -1,4 +1,4 @@
1
- import { Ft as SurveyAssistantCapabilitySet, jt as AssistantItemCapabilityAdapter } from "./index-CUqbBjkc.mjs";
1
+ import { Ft as SurveyAssistantCapabilitySet, jt as AssistantItemCapabilityAdapter } from "./index-DZ6KBwVR.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":";;;cAqIa,2BAAA,EAA6B,8BAAA;AAAA,cAY7B,4BAAA,EAA8B,8BAAA;AAAA,cAqB9B,gCAAA,EAAkC,8BAAA;AAAA,cAqBlC,2BAAA,EAA6B,8BAAA;AAAA,cA4B7B,6BAAA,EAA+B,8BAAA;AAAA,cA4E/B,2BAAA,EAA6B,8BAAA;AAAA,cAuD7B,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
+ {"version":3,"file":"capabilities-default.d.mts","names":[],"sources":["../src/capabilities/default.ts"],"mappings":";;;cAqIa,2BAAA,EAA6B,8BAAA;AAAA,cAY7B,4BAAA,EAA8B,8BAAA;AAAA,cAqB9B,gCAAA,EAAkC,8BAAA;AAAA,cAqBlC,2BAAA,EAA6B,8BAAA;AAAA,cA4B7B,6BAAA,EAA+B,8BAAA;AAAA,cA4E/B,2BAAA,EAA6B,8BAAA;AAAA,cAyD7B,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 { r as createSurveyAssistantCapabilities } from "./capabilities-B6tvE7fK.mjs";
1
+ import { r as createSurveyAssistantCapabilities } from "./capabilities-DZ0a_o2y.mjs";
2
2
  import { ValueType } from "@case-framework/survey-core";
3
3
  //#region src/capabilities/default.ts
4
4
  const COMMON_OPERATIONS = [
@@ -267,7 +267,7 @@ const choiceItemAssistantCapability = {
267
267
  "expressions",
268
268
  "rich-text-content"
269
269
  ],
270
- authoring: { configSummary: "Config stores id, maxSelection, shuffleOptions, and options. Use choice option operations for ordinary option edits." }
270
+ authoring: { configSummary: "Config stores id, maxSelection, shuffleOptions, and options. Put every initial option in create-item config; choice option operations edit only choice items already present in the live snapshot. 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." }
271
271
  }),
272
272
  references: [QUESTION_REFERENCE],
273
273
  deriveResponseSlots: deriveChoiceResponseSlots
@@ -326,7 +326,10 @@ const formItemAssistantCapability = {
326
326
  "expressions",
327
327
  "rich-text-content"
328
328
  ],
329
- authoring: { configSummary: "Config stores fieldGroups with layouts and typed fields. Inspect current config and load item-types before editing fields." }
329
+ authoring: {
330
+ compactHint: "fields=input|textarea|number|datepicker|switch|select|slider; full date=datepicker/year-month-day",
331
+ configSummary: "Config stores fieldGroups with typed fields. Supported field types are input, textarea, number, datepicker, switch, select, and slider; the controller type must match the field type. Use datepicker with mode year-month-day for an ordinary full date. Put every initial group and field in create-item config; field operations edit only forms already present in the live snapshot. Layout values are column counts 1-4, not spans; one column makes a lone field full width."
332
+ }
330
333
  }),
331
334
  references: [QUESTION_REFERENCE],
332
335
  deriveResponseSlots: (item) => deriveFormResponseSlots(item.config)
@@ -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\";\n\nconst COMMON_OPERATIONS = [\n \"create-item\",\n \"update-item-key\",\n \"update-item-label\",\n \"update-item-color\",\n \"update-item-translation\",\n \"update-placed-image\",\n \"patch-item-config\",\n \"remove-item\",\n \"move-item\",\n \"survey-json-patch\",\n] satisfies AssistantItemTypeManifest[\"supportedOperations\"];\n\nconst QUESTION_CONTENT_SURFACES: AssistantContentSurface[] = [\n {\n key: \"title\",\n role: \"primary\",\n format: \"rich\",\n requiredOnCreate: true,\n aliases: [\"content\", \"label\", \"prompt\", \"question\", \"text\"],\n },\n {\n key: \"subtitle\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"subheading\", \"subtext\"],\n },\n {\n key: \"topContent\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"preContent\", \"preResponse\"],\n },\n {\n key: \"bottomContent\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"postContent\", \"postResponse\"],\n },\n {\n key: \"cardFooter\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"footer\"],\n },\n];\n\nconst FIELD_CONTENT_SURFACES: AssistantContentSurface[] = [\n \"label\",\n \"description\",\n \"error\",\n \"placeholder\",\n \"unit\",\n \"checkedLabel\",\n \"uncheckedLabel\",\n].map((key) => ({\n key: `fields.<fieldId>.${key}`,\n role: key === \"error\" ? \"validation\" : \"field\",\n format: \"rich\",\n pattern: true,\n}));\n\nconst createManifest = (\n manifest: Omit<AssistantItemTypeManifest, \"capabilityVersion\">,\n): AssistantItemTypeManifest => ({ capabilityVersion: \"1\", ...manifest });\n\nconst STRUCTURE_REFERENCE = {\n topic: \"item-types\",\n markdown:\n \"Groups are containers. Create a group without child ids, then create or move children through separate operations. Page breaks are standalone structural boundaries.\",\n};\nconst QUESTION_REFERENCE = {\n topic: \"item-types\",\n markdown:\n \"Question titles and supporting text are translations. Configuration stores response behavior; respondent-visible option and field labels use the declared dynamic content surfaces.\",\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst getFieldValueType = (field: Record<string, unknown>): ValueType => {\n switch (field.type) {\n case \"number\":\n case \"slider\":\n return ValueType.number;\n case \"datepicker\":\n return ValueType.date;\n case \"switch\":\n return ValueType.boolean;\n default:\n return ValueType.string;\n }\n};\n\nconst deriveFormResponseSlots = (config: unknown, prefix?: string): Record<string, ValueType> => {\n if (!isRecord(config) || !Array.isArray(config.fieldGroups)) {\n return {};\n }\n\n const slots: Record<string, ValueType> = {};\n for (const group of config.fieldGroups.filter(isRecord)) {\n if (!Array.isArray(group.fields)) continue;\n for (const field of group.fields.filter(isRecord)) {\n if (typeof field.key !== \"string\" || field.key.length === 0) continue;\n slots[prefix ? `${prefix}.${field.key}` : field.key] = getFieldValueType(field);\n }\n }\n return slots;\n};\n\nconst deriveChoiceResponseSlots = (item: RawSurveyItem): Record<string, ValueType> => {\n const config = isRecord(item.config) ? item.config : {};\n const responseId = typeof config.id === \"string\" && config.id.length > 0 ? config.id : item.id;\n const slots: Record<string, ValueType> = {\n [responseId]: config.maxSelection === 1 ? ValueType.reference : ValueType.referenceArray,\n };\n\n if (Array.isArray(config.options)) {\n for (const option of config.options.filter(isRecord)) {\n if (typeof option.id !== \"string\" || !option.embeddedForm) continue;\n Object.assign(slots, deriveFormResponseSlots(option.embeddedForm, `embedded.${option.id}`));\n }\n }\n return slots;\n};\n\nexport const rootItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"root\",\n displayName: \"Survey root\",\n description: \"The existing root container. A second root cannot be created.\",\n create: \"unsupported\",\n supportedOperations: [\"update-item-key\", \"update-item-label\", \"update-item-color\"],\n contentSurfaces: [],\n referenceTopics: [\"survey-data-model\", \"item-types\"],\n }),\n};\n\nexport const groupItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"group\",\n displayName: \"Group\",\n description: \"A structural container whose children are created as separate items.\",\n defaultItemKeyPrefix: \"group\",\n create: \"deterministic\",\n supportedOperations: [...COMMON_OPERATIONS, \"reorder-items\"],\n contentSurfaces: [\n {\n key: \"title\",\n role: \"primary\",\n format: \"rich\",\n aliases: [\"content\", \"label\", \"name\", \"text\"],\n },\n ],\n referenceTopics: [\"survey-data-model\", \"item-types\"],\n }),\n references: [STRUCTURE_REFERENCE],\n};\n\nexport const pageBreakItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"page-break\",\n displayName: \"Page break\",\n description: \"A structural page boundary.\",\n defaultItemKeyPrefix: \"page\",\n create: \"deterministic\",\n supportedOperations: COMMON_OPERATIONS,\n contentSurfaces: [\n {\n key: \"title\",\n role: \"primary\",\n format: \"rich\",\n aliases: [\"content\", \"label\", \"name\", \"text\"],\n },\n ],\n referenceTopics: [\"survey-data-model\", \"item-types\"],\n }),\n references: [STRUCTURE_REFERENCE],\n};\n\nexport const infoItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"infoItem\",\n displayName: \"Info\",\n description: \"Display-only formatted content without a response slot.\",\n defaultItemKeyPrefix: \"info\",\n create: \"deterministic\",\n supportedOperations: COMMON_OPERATIONS,\n contentSurfaces: [\n {\n key: \"content\",\n role: \"primary\",\n format: \"rich\",\n requiredOnCreate: true,\n aliases: [\"body\", \"label\", \"prompt\", \"question\", \"text\", \"title\"],\n },\n ],\n referenceTopics: [\"item-types\", \"rich-text-content\"],\n }),\n references: [\n {\n topic: \"rich-text-content\",\n markdown:\n \"Info content uses the rich `content` surface. Markdown strings are not parsed; send structured rich text when formatting matters.\",\n },\n ],\n};\n\nexport const choiceItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"choiceItem\",\n displayName: \"Choice question\",\n description: \"A single- or multiple-choice question with optional embedded forms.\",\n defaultItemKeyPrefix: \"choice\",\n create: \"deterministic\",\n supportedOperations: [\n ...COMMON_OPERATIONS,\n \"add-choice-option\",\n \"update-choice-option-label\",\n \"remove-choice-option\",\n \"reorder-choice-options\",\n \"upsert-form-field-group\",\n \"remove-form-field-group\",\n \"reorder-form-field-groups\",\n \"upsert-form-field\",\n \"remove-form-field\",\n \"move-form-field\",\n \"set-embedded-form\",\n \"remove-embedded-form\",\n ],\n contentSurfaces: [\n ...QUESTION_CONTENT_SURFACES,\n {\n key: \"options.<optionId>.label\",\n role: \"option\",\n format: \"rich\",\n pattern: true,\n },\n ...FIELD_CONTENT_SURFACES.map((surface) => ({\n ...surface,\n key: `embeddedForms.<optionId>.${surface.key}`,\n })),\n {\n key: \"embeddedForms.<optionId>.fields.<fieldId>.options.<optionId>.label\",\n role: \"option\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"embeddedForms.<optionId>.fields.<fieldId>.validations.<validationId>.message\",\n role: \"validation\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"embeddedForms.<optionId>.fieldGroups.<groupId>.title\",\n role: \"field\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"embeddedForms.<optionId>.fieldGroups.<groupId>.description\",\n role: \"field\",\n format: \"rich\",\n pattern: true,\n },\n ],\n responseSlots: [{ key: \"<responseId>\", valueType: \"reference|referenceArray\" }],\n referenceTopics: [\n \"item-types\",\n \"embedded-forms\",\n \"localization\",\n \"expressions\",\n \"rich-text-content\",\n ],\n authoring: {\n configSummary:\n \"Config stores id, maxSelection, shuffleOptions, and options. Use choice option operations for ordinary option edits.\",\n },\n }),\n references: [QUESTION_REFERENCE],\n deriveResponseSlots: deriveChoiceResponseSlots,\n};\n\nexport const formItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"formItem\",\n displayName: \"Form\",\n description: \"A form with groups, typed fields, validations, and select options.\",\n defaultItemKeyPrefix: \"form\",\n create: \"deterministic\",\n supportedOperations: [\n ...COMMON_OPERATIONS,\n \"upsert-form-field-group\",\n \"remove-form-field-group\",\n \"reorder-form-field-groups\",\n \"upsert-form-field\",\n \"remove-form-field\",\n \"move-form-field\",\n ],\n contentSurfaces: [\n ...QUESTION_CONTENT_SURFACES,\n {\n key: \"fieldGroups.<groupId>.title\",\n role: \"field\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"fieldGroups.<groupId>.description\",\n role: \"field\",\n format: \"rich\",\n pattern: true,\n },\n ...FIELD_CONTENT_SURFACES,\n {\n key: \"fields.<fieldId>.options.<optionId>.label\",\n role: \"option\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"fields.<fieldId>.validations.<validationId>.message\",\n role: \"validation\",\n format: \"rich\",\n pattern: true,\n },\n ],\n responseSlots: [{ key: \"<fieldKey>\", valueType: \"field-dependent\" }],\n referenceTopics: [\"item-types\", \"localization\", \"expressions\", \"rich-text-content\"],\n authoring: {\n configSummary:\n \"Config stores fieldGroups with layouts and typed fields. Inspect current config and load item-types before editing fields.\",\n },\n }),\n references: [QUESTION_REFERENCE],\n deriveResponseSlots: (item) => deriveFormResponseSlots(item.config),\n};\n\nexport const defaultSurveyAssistantCapabilities = [\n rootItemAssistantCapability,\n groupItemAssistantCapability,\n pageBreakItemAssistantCapability,\n infoItemAssistantCapability,\n choiceItemAssistantCapability,\n formItemAssistantCapability,\n] as const;\n\nexport const defaultSurveyAssistantCapabilitySet = createSurveyAssistantCapabilities(\n defaultSurveyAssistantCapabilities,\n);\n\nexport const getDefaultSurveyAssistantCapability = (\n itemType: string,\n): AssistantItemCapabilityAdapter | undefined =>\n defaultSurveyAssistantCapabilitySet.byItemType.get(itemType);\n"],"mappings":";;;AAOA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,4BAAuD;CAC3D;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,kBAAkB;EAClB,SAAS;GAAC;GAAW;GAAS;GAAU;GAAY;GAAO;EAC5D;CACD;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,cAAc,UAAU;EACnC;CACD;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,cAAc,cAAc;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A;GACA;GACA;GACA;GACA;GACD;EACD,iBAAiB;GACf,GAAG;GACH;IACE,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACV;GACD;IACE,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACV;GACD,GAAG;GACH;IACE,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACV;GACD;IACE,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACV;GACF;EACD,eAAe,CAAC;GAAE,KAAK;GAAc,WAAW;GAAmB,CAAC;EACpE,iBAAiB;GAAC;GAAc;GAAgB;GAAe;GAAoB;EACnF,WAAW,EACT,eACE,8HACH;EACF,CAAC;CACF,YAAY,CAAC,mBAAmB;CAChC,sBAAsB,SAAS,wBAAwB,KAAK,OAAO;CACpE;AAED,MAAa,qCAAqC;CAChD;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,sCAAsC,kCACjD,mCACD;AAED,MAAa,uCACX,aAEA,oCAAoC,WAAW,IAAI,SAAS"}
1
+ {"version":3,"file":"capabilities-default.mjs","names":[],"sources":["../src/capabilities/default.ts"],"sourcesContent":["import type { AssistantContentSurface, AssistantItemTypeManifest } from \"../protocol\";\nimport { ValueType, type RawSurveyItem } from \"@case-framework/survey-core\";\nimport {\n createSurveyAssistantCapabilities,\n type AssistantItemCapabilityAdapter,\n} from \"../engine/capabilities\";\n\nconst COMMON_OPERATIONS = [\n \"create-item\",\n \"update-item-key\",\n \"update-item-label\",\n \"update-item-color\",\n \"update-item-translation\",\n \"update-placed-image\",\n \"patch-item-config\",\n \"remove-item\",\n \"move-item\",\n \"survey-json-patch\",\n] satisfies AssistantItemTypeManifest[\"supportedOperations\"];\n\nconst QUESTION_CONTENT_SURFACES: AssistantContentSurface[] = [\n {\n key: \"title\",\n role: \"primary\",\n format: \"rich\",\n requiredOnCreate: true,\n aliases: [\"content\", \"label\", \"prompt\", \"question\", \"text\"],\n },\n {\n key: \"subtitle\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"subheading\", \"subtext\"],\n },\n {\n key: \"topContent\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"preContent\", \"preResponse\"],\n },\n {\n key: \"bottomContent\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"postContent\", \"postResponse\"],\n },\n {\n key: \"cardFooter\",\n role: \"secondary\",\n format: \"rich\",\n aliases: [\"footer\"],\n },\n];\n\nconst FIELD_CONTENT_SURFACES: AssistantContentSurface[] = [\n \"label\",\n \"description\",\n \"error\",\n \"placeholder\",\n \"unit\",\n \"checkedLabel\",\n \"uncheckedLabel\",\n].map((key) => ({\n key: `fields.<fieldId>.${key}`,\n role: key === \"error\" ? \"validation\" : \"field\",\n format: \"rich\",\n pattern: true,\n}));\n\nconst createManifest = (\n manifest: Omit<AssistantItemTypeManifest, \"capabilityVersion\">,\n): AssistantItemTypeManifest => ({ capabilityVersion: \"1\", ...manifest });\n\nconst STRUCTURE_REFERENCE = {\n topic: \"item-types\",\n markdown:\n \"Groups are containers. Create a group without child ids, then create or move children through separate operations. Page breaks are standalone structural boundaries.\",\n};\nconst QUESTION_REFERENCE = {\n topic: \"item-types\",\n markdown:\n \"Question titles and supporting text are translations. Configuration stores response behavior; respondent-visible option and field labels use the declared dynamic content surfaces.\",\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst getFieldValueType = (field: Record<string, unknown>): ValueType => {\n switch (field.type) {\n case \"number\":\n case \"slider\":\n return ValueType.number;\n case \"datepicker\":\n return ValueType.date;\n case \"switch\":\n return ValueType.boolean;\n default:\n return ValueType.string;\n }\n};\n\nconst deriveFormResponseSlots = (config: unknown, prefix?: string): Record<string, ValueType> => {\n if (!isRecord(config) || !Array.isArray(config.fieldGroups)) {\n return {};\n }\n\n const slots: Record<string, ValueType> = {};\n for (const group of config.fieldGroups.filter(isRecord)) {\n if (!Array.isArray(group.fields)) continue;\n for (const field of group.fields.filter(isRecord)) {\n if (typeof field.key !== \"string\" || field.key.length === 0) continue;\n slots[prefix ? `${prefix}.${field.key}` : field.key] = getFieldValueType(field);\n }\n }\n return slots;\n};\n\nconst deriveChoiceResponseSlots = (item: RawSurveyItem): Record<string, ValueType> => {\n const config = isRecord(item.config) ? item.config : {};\n const responseId = typeof config.id === \"string\" && config.id.length > 0 ? config.id : item.id;\n const slots: Record<string, ValueType> = {\n [responseId]: config.maxSelection === 1 ? ValueType.reference : ValueType.referenceArray,\n };\n\n if (Array.isArray(config.options)) {\n for (const option of config.options.filter(isRecord)) {\n if (typeof option.id !== \"string\" || !option.embeddedForm) continue;\n Object.assign(slots, deriveFormResponseSlots(option.embeddedForm, `embedded.${option.id}`));\n }\n }\n return slots;\n};\n\nexport const rootItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"root\",\n displayName: \"Survey root\",\n description: \"The existing root container. A second root cannot be created.\",\n create: \"unsupported\",\n supportedOperations: [\"update-item-key\", \"update-item-label\", \"update-item-color\"],\n contentSurfaces: [],\n referenceTopics: [\"survey-data-model\", \"item-types\"],\n }),\n};\n\nexport const groupItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"group\",\n displayName: \"Group\",\n description: \"A structural container whose children are created as separate items.\",\n defaultItemKeyPrefix: \"group\",\n create: \"deterministic\",\n supportedOperations: [...COMMON_OPERATIONS, \"reorder-items\"],\n contentSurfaces: [\n {\n key: \"title\",\n role: \"primary\",\n format: \"rich\",\n aliases: [\"content\", \"label\", \"name\", \"text\"],\n },\n ],\n referenceTopics: [\"survey-data-model\", \"item-types\"],\n }),\n references: [STRUCTURE_REFERENCE],\n};\n\nexport const pageBreakItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"page-break\",\n displayName: \"Page break\",\n description: \"A structural page boundary.\",\n defaultItemKeyPrefix: \"page\",\n create: \"deterministic\",\n supportedOperations: COMMON_OPERATIONS,\n contentSurfaces: [\n {\n key: \"title\",\n role: \"primary\",\n format: \"rich\",\n aliases: [\"content\", \"label\", \"name\", \"text\"],\n },\n ],\n referenceTopics: [\"survey-data-model\", \"item-types\"],\n }),\n references: [STRUCTURE_REFERENCE],\n};\n\nexport const infoItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"infoItem\",\n displayName: \"Info\",\n description: \"Display-only formatted content without a response slot.\",\n defaultItemKeyPrefix: \"info\",\n create: \"deterministic\",\n supportedOperations: COMMON_OPERATIONS,\n contentSurfaces: [\n {\n key: \"content\",\n role: \"primary\",\n format: \"rich\",\n requiredOnCreate: true,\n aliases: [\"body\", \"label\", \"prompt\", \"question\", \"text\", \"title\"],\n },\n ],\n referenceTopics: [\"item-types\", \"rich-text-content\"],\n }),\n references: [\n {\n topic: \"rich-text-content\",\n markdown:\n \"Info content uses the rich `content` surface. Markdown strings are not parsed; send structured rich text when formatting matters.\",\n },\n ],\n};\n\nexport const choiceItemAssistantCapability: AssistantItemCapabilityAdapter = {\n manifest: createManifest({\n itemType: \"choiceItem\",\n displayName: \"Choice question\",\n description: \"A single- or multiple-choice question with optional embedded forms.\",\n defaultItemKeyPrefix: \"choice\",\n create: \"deterministic\",\n supportedOperations: [\n ...COMMON_OPERATIONS,\n \"add-choice-option\",\n \"update-choice-option-label\",\n \"remove-choice-option\",\n \"reorder-choice-options\",\n \"upsert-form-field-group\",\n \"remove-form-field-group\",\n \"reorder-form-field-groups\",\n \"upsert-form-field\",\n \"remove-form-field\",\n \"move-form-field\",\n \"set-embedded-form\",\n \"remove-embedded-form\",\n ],\n contentSurfaces: [\n ...QUESTION_CONTENT_SURFACES,\n {\n key: \"options.<optionId>.label\",\n role: \"option\",\n format: \"rich\",\n pattern: true,\n },\n ...FIELD_CONTENT_SURFACES.map((surface) => ({\n ...surface,\n key: `embeddedForms.<optionId>.${surface.key}`,\n })),\n {\n key: \"embeddedForms.<optionId>.fields.<fieldId>.options.<optionId>.label\",\n role: \"option\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"embeddedForms.<optionId>.fields.<fieldId>.validations.<validationId>.message\",\n role: \"validation\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"embeddedForms.<optionId>.fieldGroups.<groupId>.title\",\n role: \"field\",\n format: \"rich\",\n pattern: true,\n },\n {\n key: \"embeddedForms.<optionId>.fieldGroups.<groupId>.description\",\n role: \"field\",\n format: \"rich\",\n pattern: true,\n },\n ],\n responseSlots: [{ key: \"<responseId>\", valueType: \"reference|referenceArray\" }],\n referenceTopics: [\n \"item-types\",\n \"embedded-forms\",\n \"localization\",\n \"expressions\",\n \"rich-text-content\",\n ],\n authoring: {\n configSummary:\n \"Config stores id, maxSelection, shuffleOptions, and options. Put every initial option in create-item config; choice option operations edit only choice items already present in the live snapshot. 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 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 \"fields=input|textarea|number|datepicker|switch|select|slider; full date=datepicker/year-month-day\",\n configSummary:\n \"Config stores fieldGroups with typed fields. Supported field types are input, textarea, number, datepicker, switch, select, and slider; the controller type must match the field type. Use datepicker with mode year-month-day for an ordinary full date. Put every initial group and field in create-item config; field operations edit only forms already present in the live snapshot. Layout values are column counts 1-4, not spans; one column makes a lone field full width.\",\n },\n }),\n references: [QUESTION_REFERENCE],\n deriveResponseSlots: (item) => deriveFormResponseSlots(item.config),\n};\n\nexport const defaultSurveyAssistantCapabilities = [\n rootItemAssistantCapability,\n groupItemAssistantCapability,\n pageBreakItemAssistantCapability,\n infoItemAssistantCapability,\n choiceItemAssistantCapability,\n formItemAssistantCapability,\n] as const;\n\nexport const defaultSurveyAssistantCapabilitySet = createSurveyAssistantCapabilities(\n defaultSurveyAssistantCapabilities,\n);\n\nexport const getDefaultSurveyAssistantCapability = (\n itemType: string,\n): AssistantItemCapabilityAdapter | undefined =>\n defaultSurveyAssistantCapabilitySet.byItemType.get(itemType);\n"],"mappings":";;;AAOA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,4BAAuD;CAC3D;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,kBAAkB;EAClB,SAAS;GAAC;GAAW;GAAS;GAAU;GAAY;GAAO;EAC5D;CACD;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,cAAc,UAAU;EACnC;CACD;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,cAAc,cAAc;EACvC;CACD;EACE,KAAK;EACL,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,eAAe,eAAe;EACzC;CACD;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AQ;IACR,SAAS;IACV;GACD;IACE,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACV;GACD,GAAG;GACH;IACE,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACV;GACD;IACE,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACV;GACF;EACD,eAAe,CAAC;GAAE,KAAK;GAAc,WAAW;GAAmB,CAAC;EACpE,iBAAiB;GAAC;GAAc;GAAgB;GAAe;GAAoB;EACnF,WAAW;GACT,aACE;GACF,eACE;GACH;EACF,CAAC;CACF,YAAY,CAAC,mBAAmB;CAChC,sBAAsB,SAAS,wBAAwB,KAAK,OAAO;CACpE;AAED,MAAa,qCAAqC;CAChD;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,sCAAsC,kCACjD,mCACD;AAED,MAAa,uCACX,aAEA,oCAAoC,WAAW,IAAI,SAAS"}
@@ -1,6 +1,6 @@
1
- import { cn as SurveyDocumentSnapshot } from "./index-TFtvBiSQ.mjs";
2
- import { Ft as SurveyAssistantCapabilitySet, g as TurnChangeCollector, xt as SurveyAssistantEngineContext } from "./index-CUqbBjkc.mjs";
3
- import { n as SurveyAssistantModelAttachment, t as SurveyAssistantAttachmentAccess } from "./thread-documents-DamIq9Od.mjs";
1
+ import { dn as SurveyDocumentVersion, un as SurveyDocumentSnapshot } from "./index-DVxVyhAu.mjs";
2
+ import { Ft as SurveyAssistantCapabilitySet, g as TurnChangeCollector, xt as SurveyAssistantEngineContext } from "./index-DZ6KBwVR.mjs";
3
+ import { n as SurveyAssistantModelAttachment, t as SurveyAssistantAttachmentAccess } from "./thread-documents-BlxNjc7S.mjs";
4
4
  import { RequestContext } from "@mastra/core/request-context";
5
5
 
6
6
  //#region src/server/request-context.d.ts
@@ -10,13 +10,32 @@ interface SurveyAssistantInvocationContext {
10
10
  interface SurveyAssistantIdentityContext {
11
11
  authority: "experimental-client-request" | "authenticated-host";
12
12
  resourceId: string;
13
+ surveyId?: string;
13
14
  threadId: string;
14
15
  }
15
16
  interface SurveyAssistantModelSelection {
16
17
  id: string;
17
18
  model: string;
18
19
  }
19
- type SurveyAssistantSnapshotSource = "full" | "missing";
20
+ type SurveyAssistantDocumentTransition = {
21
+ status: "no-baseline";
22
+ } | {
23
+ status: "session-changed";
24
+ previousHistoryIndex: number;
25
+ currentHistoryIndex: number;
26
+ } | {
27
+ status: "unchanged";
28
+ previousHistoryIndex: number;
29
+ currentHistoryIndex: number;
30
+ capabilitiesChanged: boolean;
31
+ } | {
32
+ status: "changed";
33
+ previousHistoryIndex: number;
34
+ currentHistoryIndex: number;
35
+ historyDirection: "backward" | "forward" | "same-index";
36
+ recordedSources: Array<"user" | "system" | "assistant">;
37
+ capabilitiesChanged: boolean;
38
+ };
20
39
  interface SurveyAssistantRequestContext {
21
40
  invocation: SurveyAssistantInvocationContext;
22
41
  turnId: string;
@@ -27,7 +46,7 @@ interface SurveyAssistantRequestContext {
27
46
  applyPolicy?: "auto" | "review" | "deny";
28
47
  mastra__resourceId?: string;
29
48
  mastra__threadId?: string;
30
- snapshotSource?: SurveyAssistantSnapshotSource;
49
+ documentTransition?: SurveyAssistantDocumentTransition;
31
50
  engineContext?: SurveyAssistantEngineContext;
32
51
  documentSnapshot?: SurveyDocumentSnapshot;
33
52
  modelAttachments?: SurveyAssistantModelAttachment[];
@@ -35,11 +54,19 @@ interface SurveyAssistantRequestContext {
35
54
  modelSelection?: SurveyAssistantModelSelection;
36
55
  }
37
56
  declare const parseSurveyAssistantSnapshot: (value: unknown) => SurveyDocumentSnapshot | null;
57
+ declare const parseSurveyAssistantPreviousSettledVersion: (value: unknown) => SurveyDocumentVersion | null;
58
+ declare const deriveSurveyAssistantDocumentTransition: ({
59
+ current,
60
+ previous
61
+ }: {
62
+ current: SurveyDocumentSnapshot | null;
63
+ previous: SurveyDocumentVersion | null;
64
+ }) => SurveyAssistantDocumentTransition | undefined;
38
65
  declare const buildSurveyAssistantRequestContext: ({
39
66
  changeCollector,
40
67
  identity,
41
68
  snapshot,
42
- snapshotSource,
69
+ previousSettledVersion,
43
70
  trustedCapabilities,
44
71
  attachmentAccess,
45
72
  modelAttachments,
@@ -48,7 +75,7 @@ declare const buildSurveyAssistantRequestContext: ({
48
75
  changeCollector: TurnChangeCollector;
49
76
  identity: SurveyAssistantIdentityContext;
50
77
  snapshot: SurveyDocumentSnapshot | null;
51
- snapshotSource?: SurveyAssistantSnapshotSource;
78
+ previousSettledVersion?: SurveyDocumentVersion | null;
52
79
  trustedCapabilities?: SurveyAssistantCapabilitySet;
53
80
  attachmentAccess?: SurveyAssistantAttachmentAccess;
54
81
  modelAttachments?: SurveyAssistantModelAttachment[];
@@ -63,5 +90,5 @@ declare const requireSurveyAssistantTurnState: (requestContext: RequestContext<S
63
90
  declare const SURVEY_ASSISTANT_AGENT_ID = "survey-assistant-agent";
64
91
  declare const SURVEY_ASSISTANT_TASK_AGENT_ID = "survey-assistant-task-agent";
65
92
  //#endregion
66
- export { SurveyAssistantRequestContext as a, parseSurveyAssistantSnapshot as c, SurveyAssistantModelSelection as i, requireSurveyAssistantTurnState as l, SURVEY_ASSISTANT_TASK_AGENT_ID as n, SurveyAssistantSnapshotSource as o, SurveyAssistantIdentityContext as r, buildSurveyAssistantRequestContext as s, SURVEY_ASSISTANT_AGENT_ID as t };
67
- //# sourceMappingURL=constants-Jw0k8ojS.d.mts.map
93
+ export { SurveyAssistantModelSelection as a, deriveSurveyAssistantDocumentTransition as c, requireSurveyAssistantTurnState as d, SurveyAssistantIdentityContext as i, parseSurveyAssistantPreviousSettledVersion as l, SURVEY_ASSISTANT_TASK_AGENT_ID as n, SurveyAssistantRequestContext as o, SurveyAssistantDocumentTransition as r, buildSurveyAssistantRequestContext as s, SURVEY_ASSISTANT_AGENT_ID as t, parseSurveyAssistantSnapshot as u };
94
+ //# sourceMappingURL=constants-56jf_4ls.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-56jf_4ls.d.mts","names":[],"sources":["../src/server/request-context.ts","../src/server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8BAAA;EACnB,cAAA,GAAiB,6BAAA;AAAA,MACf,cAAA,CAAe,6BAAA;AAAA,cAyCN,+BAAA,GACX,cAAA,EAAgB,cAAA,CAAe,6BAAA;;;;;;cCxNpB,yBAAA;AAAA,cACA,8BAAA"}
@@ -1,9 +1,32 @@
1
- import { A as SurveyAssistantSuggestItemKeyResult, B as SurveyAssistantTranslateContentResult, F as SurveyAssistantTaskInvocationMode, M as SurveyAssistantSuggestItemLabelResult, P as SurveyAssistantTaskContext, f as SurveyBatchApplyResult, i as SurveyApplyResult, j as SurveyAssistantSuggestItemLabelInput, k as SurveyAssistantSuggestItemKeyInput, on as SurveyAssistantSnapshot, p as SurveyChangeSet, z as SurveyAssistantTranslateContentInput } from "./index-TFtvBiSQ.mjs";
1
+ import { A as SurveyAssistantSuggestItemKeyResult, B as SurveyAssistantTranslateContentResult, F as SurveyAssistantTaskInvocationMode, M as SurveyAssistantSuggestItemLabelResult, P as SurveyAssistantTaskContext, cn as SurveyAssistantSnapshot, f as SurveyBatchApplyResult, fn as SurveyEditorUIContext, i as SurveyApplyResult, it as SurveyAssistantThread, j as SurveyAssistantSuggestItemLabelInput, k as SurveyAssistantSuggestItemKeyInput, p as SurveyChangeSet, z as SurveyAssistantTranslateContentInput } from "./index-DVxVyhAu.mjs";
2
+ import { FileUIPart } from "ai";
2
3
 
4
+ //#region src/react/thread-launcher.d.ts
5
+ type SurveyAssistantLaunchUIContext = Partial<Omit<SurveyEditorUIContext, "history">>;
6
+ interface SurveyAssistantThreadLaunch {
7
+ /** User-visible prompt submitted as the first message in the new thread. */
8
+ prompt: string;
9
+ files?: FileUIPart[];
10
+ /** Optional manual thread title. The prompt-derived automatic title is used by default. */
11
+ title?: string;
12
+ /** Turn-local editor context merged into the snapshot captured when the prompt is submitted. */
13
+ uiContext?: SurveyAssistantLaunchUIContext;
14
+ }
15
+ interface SurveyAssistantThreadLauncher {
16
+ /**
17
+ * Creates a new thread and submits its first prompt when a connected panel is ready.
18
+ * Calls made before the panel mounts are queued.
19
+ */
20
+ startThread(input: SurveyAssistantThreadLaunch): Promise<SurveyAssistantThread>;
21
+ }
22
+ declare const createSurveyAssistantThreadLauncher: () => SurveyAssistantThreadLauncher;
23
+ //#endregion
3
24
  //#region src/react/task-client.d.ts
4
25
  interface SurveyAssistantTaskClientOptions {
5
26
  api?: string;
6
27
  getModelId?: () => string | undefined;
28
+ resourceId?: string;
29
+ surveyId?: string;
7
30
  }
8
31
  interface SurveyAssistantTaskExecutionOptions {
9
32
  mode?: SurveyAssistantTaskInvocationMode;
@@ -29,7 +52,9 @@ interface SurveyAssistantTaskExecutor {
29
52
  }
30
53
  declare const createSurveyAssistantTaskClient: ({
31
54
  api,
32
- getModelId
55
+ getModelId,
56
+ resourceId,
57
+ surveyId
33
58
  }?: SurveyAssistantTaskClientOptions) => SurveyAssistantTaskClient;
34
59
  declare const createSurveyAssistantTaskExecutor: (options?: SurveyAssistantTaskClientOptions) => SurveyAssistantTaskExecutor;
35
60
  //#endregion
@@ -53,5 +78,5 @@ declare const createSurveyAssistantControllerProxy: (getController: () => Survey
53
78
  }?: CreateSurveyAssistantControllerProxyOptions) => SurveyAssistantController;
54
79
  declare const createSurveyAssistantControllerBridge: (options?: CreateSurveyAssistantControllerProxyOptions) => SurveyAssistantControllerBridge;
55
80
  //#endregion
56
- export { SurveyAssistantController as a, SurveyAssistantTaskExecutionOptions as c, SurveyAssistantTaskExecutorRequestOptions as d, createSurveyAssistantTaskClient as f, createSurveyAssistantControllerProxy as i, SurveyAssistantTaskExecutor as l, SurveyAssistantControllerBridge as n, SurveyAssistantTaskClient as o, createSurveyAssistantTaskExecutor as p, createSurveyAssistantControllerBridge as r, SurveyAssistantTaskClientOptions as s, CreateSurveyAssistantControllerProxyOptions as t, SurveyAssistantTaskExecutorCacheContext as u };
57
- //# sourceMappingURL=controller-proxy-BRDusFiO.d.mts.map
81
+ 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 };
82
+ //# sourceMappingURL=controller-proxy-2VH0b_5E.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller-proxy-2VH0b_5E.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;EAFL;EAIV,MAAA;EACA,KAAA,GAAQ,UAAA;EALgD;EAOxD,KAAA;EAP2C;EAS3C,SAAA,GAAY,8BAAA;AAAA;AAAA,UAGG,6BAAA;EAZoC;;;;EAiBnD,WAAA,CAAY,KAAA,EAAO,2BAAA,GAA8B,OAAA,CAAQ,qBAAA;AAAA;AAAA,cA6D9C,mCAAA,QAA0C,6BAAA;;;UCtEtC,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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