@case-framework/survey-assistant 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +58 -3
  2. package/dist/{attachments-B0hg3vpT.mjs → attachments-BuNni5vB.mjs} +1 -1
  3. package/dist/{attachments-B0hg3vpT.mjs.map → attachments-BuNni5vB.mjs.map} +1 -1
  4. package/dist/{authoring-references-BJQ_1nMX.mjs → authoring-references-CmwLc_C8.mjs} +49 -32
  5. package/dist/authoring-references-CmwLc_C8.mjs.map +1 -0
  6. package/dist/capabilities-D55dq-fO.mjs +582 -0
  7. package/dist/capabilities-D55dq-fO.mjs.map +1 -0
  8. package/dist/capabilities-default.d.mts +5 -12
  9. package/dist/capabilities-default.d.mts.map +1 -1
  10. package/dist/capabilities-default.mjs +2 -411
  11. package/dist/capabilities-z95e1mti.d.mts +117 -0
  12. package/dist/capabilities-z95e1mti.d.mts.map +1 -0
  13. package/dist/{constants-0UHGFcRJ.mjs → constants-Ct-vv9cu.mjs} +1 -1
  14. package/dist/{constants-0UHGFcRJ.mjs.map → constants-Ct-vv9cu.mjs.map} +1 -1
  15. package/dist/{constants-Be91Gay9.d.mts → constants-HL_klgJl.d.mts} +7 -28
  16. package/dist/constants-HL_klgJl.d.mts.map +1 -0
  17. package/dist/{controller-proxy-BH05e-C2.mjs → controller-proxy-BQ1YsVxJ.mjs} +12 -21
  18. package/dist/controller-proxy-BQ1YsVxJ.mjs.map +1 -0
  19. package/dist/controller-proxy-Cmzdr9tV.d.mts +65 -0
  20. package/dist/controller-proxy-Cmzdr9tV.d.mts.map +1 -0
  21. package/dist/default-D22AKTqE.mjs +233 -0
  22. package/dist/default-D22AKTqE.mjs.map +1 -0
  23. package/dist/{digest-SJmoYVaK.d.mts → digest-FnTTDBq2.d.mts} +2 -3
  24. package/dist/digest-FnTTDBq2.d.mts.map +1 -0
  25. package/dist/digest.d.mts +1 -1
  26. package/dist/digest.mjs.map +1 -1
  27. package/dist/engine-D950TfvC.mjs +3098 -0
  28. package/dist/engine-D950TfvC.mjs.map +1 -0
  29. package/dist/engine.d.mts +4 -3
  30. package/dist/engine.mjs +3 -3
  31. package/dist/{fair-guidance-CRYCRxQm.mjs → fair-guidance-BmO4PswW.mjs} +1 -1
  32. package/dist/{fair-guidance-CRYCRxQm.mjs.map → fair-guidance-BmO4PswW.mjs.map} +1 -1
  33. package/dist/{index-l_EK4yK7.d.mts → index-B8TLBd1G.d.mts} +18 -72
  34. package/dist/index-B8TLBd1G.d.mts.map +1 -0
  35. package/dist/index-CaX3hZmr.d.mts +23813 -0
  36. package/dist/index-CaX3hZmr.d.mts.map +1 -0
  37. package/dist/{index-x0qprHgK.d.mts → index-CeUlGkoU.d.mts} +58 -28
  38. package/dist/index-CeUlGkoU.d.mts.map +1 -0
  39. package/dist/{index-nhrgbgO5.d.mts → index-DYHdvSE8.d.mts} +347 -88
  40. package/dist/index-DYHdvSE8.d.mts.map +1 -0
  41. package/dist/lifecycle-DFzxVxpq.d.mts +54346 -0
  42. package/dist/lifecycle-DFzxVxpq.d.mts.map +1 -0
  43. package/dist/{memory-thread-repository-KWHQWFEW.mjs → memory-thread-repository-DmLadygY.mjs} +60 -30
  44. package/dist/memory-thread-repository-DmLadygY.mjs.map +1 -0
  45. package/dist/protocol-BQ7uIDYT.mjs +569 -0
  46. package/dist/protocol-BQ7uIDYT.mjs.map +1 -0
  47. package/dist/protocol.d.mts +4 -4
  48. package/dist/protocol.mjs +4 -3
  49. package/dist/{react-B3ybjJ-X.mjs → react-DybJ5pWw.mjs} +159 -46
  50. package/dist/react-DybJ5pWw.mjs.map +1 -0
  51. package/dist/react-integration.d.mts +2 -2
  52. package/dist/react-integration.mjs +2 -2
  53. package/dist/react.d.mts +3 -3
  54. package/dist/react.mjs +3 -3
  55. package/dist/references/assistant-operations.md +224 -180
  56. package/dist/references/core-rules.md +6 -3
  57. package/dist/references/element-types.md +189 -0
  58. package/dist/references/expressions.md +307 -168
  59. package/dist/references/fair-by-design.md +9 -9
  60. package/dist/references/follow-ups.md +151 -0
  61. package/dist/references/localization.md +26 -12
  62. package/dist/references/response-variables.md +38 -0
  63. package/dist/references/rich-text-content.md +22 -43
  64. package/dist/references/source-material-surveys.md +20 -24
  65. package/dist/references/survey-data-model.md +36 -102
  66. package/dist/{request-context-CG4SWijt.mjs → request-context-KVh8VjgH.mjs} +4 -10
  67. package/dist/request-context-KVh8VjgH.mjs.map +1 -0
  68. package/dist/{request-guardrails-TmgQtqp4.mjs → request-guardrails-C0ugBOp0.mjs} +6 -5
  69. package/dist/request-guardrails-C0ugBOp0.mjs.map +1 -0
  70. package/dist/server-agent.d.mts +62 -43
  71. package/dist/server-agent.d.mts.map +1 -1
  72. package/dist/server-agent.mjs +73 -40
  73. package/dist/server-agent.mjs.map +1 -1
  74. package/dist/server-runtime.d.mts +24 -42
  75. package/dist/server-runtime.d.mts.map +1 -1
  76. package/dist/server-runtime.mjs +12 -12
  77. package/dist/server-runtime.mjs.map +1 -1
  78. package/dist/server-tasks.d.mts +2 -2
  79. package/dist/server-tasks.mjs +2 -313
  80. package/dist/server-tools.d.mts +1 -1
  81. package/dist/server-tools.mjs +1 -1
  82. package/dist/server.d.mts +14 -36
  83. package/dist/server.d.mts.map +1 -1
  84. package/dist/server.mjs +5 -5
  85. package/dist/server.mjs.map +1 -1
  86. package/dist/storage-postgres.d.mts +9 -25
  87. package/dist/storage-postgres.d.mts.map +1 -1
  88. package/dist/storage-postgres.mjs +5 -4
  89. package/dist/storage-postgres.mjs.map +1 -1
  90. package/dist/tasks-Coh5N027.mjs +397 -0
  91. package/dist/tasks-Coh5N027.mjs.map +1 -0
  92. package/dist/{tasks-CYqrcaRO.d.mts → tasks-wb9M-bak.d.mts} +25 -41
  93. package/dist/tasks-wb9M-bak.d.mts.map +1 -0
  94. package/dist/thread-documents-DrHbaXqP.d.mts +119 -0
  95. package/dist/thread-documents-DrHbaXqP.d.mts.map +1 -0
  96. package/dist/{thread-handlers-DBAaU7BA.d.mts → thread-handlers-C3Iya92v.d.mts} +9 -40
  97. package/dist/thread-handlers-C3Iya92v.d.mts.map +1 -0
  98. package/dist/{tools-BvSovehT.mjs → tools-D0KBDolR.mjs} +677 -459
  99. package/dist/tools-D0KBDolR.mjs.map +1 -0
  100. package/dist/turn-survey-draft-B34lggSG.d.mts +185 -0
  101. package/dist/turn-survey-draft-B34lggSG.d.mts.map +1 -0
  102. package/dist/ui.css +1 -1
  103. package/dist/ui.d.mts +15 -54
  104. package/dist/ui.d.mts.map +1 -1
  105. package/dist/ui.mjs +203 -156
  106. package/dist/ui.mjs.map +1 -1
  107. package/docs/integration.md +11 -1
  108. package/package.json +41 -36
  109. package/dist/authoring-references-BJQ_1nMX.mjs.map +0 -1
  110. package/dist/capabilities-1KNnNO1_.mjs +0 -73
  111. package/dist/capabilities-1KNnNO1_.mjs.map +0 -1
  112. package/dist/capabilities-DVTfogjv.d.mts +0 -193
  113. package/dist/capabilities-DVTfogjv.d.mts.map +0 -1
  114. package/dist/capabilities-default.mjs.map +0 -1
  115. package/dist/constants-Be91Gay9.d.mts.map +0 -1
  116. package/dist/controller-proxy-BH05e-C2.mjs.map +0 -1
  117. package/dist/controller-proxy-Bd0ZHBPF.d.mts +0 -85
  118. package/dist/controller-proxy-Bd0ZHBPF.d.mts.map +0 -1
  119. package/dist/digest-SJmoYVaK.d.mts.map +0 -1
  120. package/dist/engine-Bo85Oyj0.mjs +0 -6723
  121. package/dist/engine-Bo85Oyj0.mjs.map +0 -1
  122. package/dist/index-Tnqv-yKW.d.mts +0 -777
  123. package/dist/index-Tnqv-yKW.d.mts.map +0 -1
  124. package/dist/index-l_EK4yK7.d.mts.map +0 -1
  125. package/dist/index-nhrgbgO5.d.mts.map +0 -1
  126. package/dist/index-x0qprHgK.d.mts.map +0 -1
  127. package/dist/lifecycle-Bx0aq_4S.d.mts +0 -529
  128. package/dist/lifecycle-Bx0aq_4S.d.mts.map +0 -1
  129. package/dist/memory-thread-repository-KWHQWFEW.mjs.map +0 -1
  130. package/dist/protocol-BhzQbx81.mjs +0 -1173
  131. package/dist/protocol-BhzQbx81.mjs.map +0 -1
  132. package/dist/react-B3ybjJ-X.mjs.map +0 -1
  133. package/dist/references/embedded-forms.md +0 -126
  134. package/dist/references/item-types.md +0 -407
  135. package/dist/request-context-CG4SWijt.mjs.map +0 -1
  136. package/dist/request-guardrails-TmgQtqp4.mjs.map +0 -1
  137. package/dist/server-tasks.mjs.map +0 -1
  138. package/dist/tasks-CYqrcaRO.d.mts.map +0 -1
  139. package/dist/thread-documents-rmd6nyX9.d.mts +0 -107
  140. package/dist/thread-documents-rmd6nyX9.d.mts.map +0 -1
  141. package/dist/thread-handlers-DBAaU7BA.d.mts.map +0 -1
  142. package/dist/tools-BvSovehT.mjs.map +0 -1
@@ -7,7 +7,7 @@ storage credentials, logs, and deployment policy.
7
7
 
8
8
  ## Compatibility and release gate
9
9
 
10
- - Node.js 22.13.0 or newer and standard Web `Request`/`Response` route handlers.
10
+ - Node.js 22.22.2+ on the 22.x line, 24.15.0+ on the 24.x line, or 26.0.0+ and standard Web `Request`/`Response` route handlers.
11
11
  - React and React DOM 19.2 or newer for `/react` and `/ui`.
12
12
  - `@case-framework/survey-core` 0.4.2 or newer within the 0.4 line; the
13
13
  assistant uses its browser-safe `editor/colors` entry.
@@ -310,6 +310,16 @@ boolean through the server-to-client boundary as `supportBundleEnabled`. Do not
310
310
  send the complete runtime config to the browser because it contains
311
311
  server-only provider credentials.
312
312
 
313
+ The shared task client accepts an explicit `modelId`, invocation `mode`, and
314
+ abort `signal` per request. The editor integration captures its selected model
315
+ once per task and uses it for both the request and the snapshot-scoped suggestion
316
+ cache. Model selection also applies when caching is disabled and to uncached
317
+ translation requests.
318
+
319
+ Custom thread clients implement `SurveyAssistantThreadClient`, including the
320
+ required `listPage({ cursor })` method. Each page returns `threads` and an optional
321
+ `nextCursor`; omit the cursor to read the first page.
322
+
313
323
  The assistant controller requires `getSnapshot()` and
314
324
  `applyAssistantChanges(changes)`. The session passes all authorized change sets
315
325
  in one call, including a one-element array for a single change set. Return one
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@case-framework/survey-assistant",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Shared protocol, engine, and runtime for the CASE survey assistant.",
5
5
  "license": "ISC",
6
6
  "files": [
@@ -85,48 +85,47 @@
85
85
  "./package.json": "./package.json"
86
86
  },
87
87
  "dependencies": {
88
- "@case-framework/survey-items": "0.1.0",
89
- "@case-framework/ui-localization": "0.2.1",
90
- "@radix-ui/react-use-controllable-state": "^1.2.3",
88
+ "@case-framework/survey-items": "0.3.0",
89
+ "@case-framework/ui-localization": "0.3.0",
91
90
  "class-variance-authority": "^0.7.1",
92
91
  "clsx": "^2.1.1",
93
92
  "fflate": "^0.8.3",
94
- "lucide-react": "^1.11.0",
93
+ "lucide-react": "^1.47.0",
95
94
  "motion": "^12.42.2",
96
- "radix-ui": "^1.6.7",
97
- "shiki": "^4.3.0",
95
+ "shiki": "^4.4.3",
98
96
  "streamdown": "2.5.0",
99
- "tailwind-merge": "^3.5.0",
97
+ "tailwind-merge": "^3.7.0",
100
98
  "tw-animate-css": "^1.4.0",
101
99
  "use-stick-to-bottom": "^1.1.6",
102
- "zod": "^4.4.3"
100
+ "zod": "^4.6.5"
103
101
  },
104
102
  "devDependencies": {
105
- "@ai-sdk/react": "^4.0.81",
106
- "@case-framework/survey-core": "0.7.0",
107
- "@jest/globals": "30.3.0",
108
- "@mastra/ai-sdk": "^1.9.1",
109
- "@mastra/core": "^1.61.0",
110
- "@mastra/memory": "^1.27.0",
111
- "@mastra/pg": "^1.21.1",
103
+ "@ai-sdk/react": "^4.0.96",
104
+ "@base-ui/react": "^1.8.0",
105
+ "@case-framework/survey-core": "0.9.0",
106
+ "@mastra/ai-sdk": "^1.10.1",
107
+ "@mastra/core": "^1.64.0",
108
+ "@mastra/memory": "^1.28.2",
109
+ "@mastra/pg": "^1.22.3",
112
110
  "@tailwindcss/vite": "^4.3.2",
113
- "@types/jest": "^30.0.0",
114
- "@types/node": "^25.6.0",
115
- "@types/react": "^19.2.18",
116
- "@types/react-test-renderer": "19.1.0",
117
- "ai": "^7.0.78",
118
- "jest": "^30.3.0",
119
- "react": "~19.2.8",
120
- "react-dom": "~19.2.8",
121
- "react-test-renderer": "19.2.8",
122
- "ts-jest": "^29.4.9",
123
- "tsdown": "^0.21.10",
111
+ "@types/node": "^25.9.8",
112
+ "@types/react": "^19.3.0",
113
+ "@types/react-dom": "19.3.0",
114
+ "@types/react-test-renderer": "19.3.0",
115
+ "ai": "^7.0.93",
116
+ "jsdom": "^30.1.0",
117
+ "react": "~19.3.0",
118
+ "react-dom": "~19.3.0",
119
+ "react-test-renderer": "19.3.0",
120
+ "tsdown": "^0.23.0",
124
121
  "typescript": "^6.0.3",
125
- "vite": "^8.0.10"
122
+ "vite": "^8.3.0",
123
+ "vitest": "^5.0.1"
126
124
  },
127
125
  "peerDependencies": {
128
126
  "@ai-sdk/react": "^4.0.81",
129
- "@case-framework/survey-core": "^0.7.0",
127
+ "@base-ui/react": "^1.8.0",
128
+ "@case-framework/survey-core": "^0.9.0",
130
129
  "@mastra/ai-sdk": "^1.9.1",
131
130
  "@mastra/core": "^1.61.0",
132
131
  "@mastra/memory": "^1.27.0",
@@ -136,6 +135,12 @@
136
135
  "react-dom": ">=19.2.0"
137
136
  },
138
137
  "peerDependenciesMeta": {
138
+ "@ai-sdk/react": {
139
+ "optional": true
140
+ },
141
+ "@base-ui/react": {
142
+ "optional": true
143
+ },
139
144
  "@mastra/ai-sdk": {
140
145
  "optional": true
141
146
  },
@@ -148,9 +153,6 @@
148
153
  "@mastra/pg": {
149
154
  "optional": true
150
155
  },
151
- "@ai-sdk/react": {
152
- "optional": true
153
- },
154
156
  "ai": {
155
157
  "optional": true
156
158
  },
@@ -162,15 +164,18 @@
162
164
  }
163
165
  },
164
166
  "engines": {
165
- "node": ">=22.13.0"
167
+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"
166
168
  },
167
169
  "scripts": {
168
170
  "build": "tsdown && vite build --config vite.ui.config.ts",
169
- "test": "jest --config jest.config.cjs --runInBand",
171
+ "test": "pnpm typecheck:tests && vitest run",
170
172
  "typecheck": "tsc --noEmit",
171
173
  "check:imports": "node scripts/check-protocol-imports.mjs",
172
174
  "check:next-host": "node scripts/check-next-host-fixture.mjs",
173
- "check": "pnpm typecheck && pnpm build && pnpm check:imports && pnpm test",
174
- "check:release": "pnpm check && pnpm check:next-host"
175
+ "check": "pnpm typecheck && pnpm build && pnpm check:imports && pnpm test && pnpm test:integration",
176
+ "check:release": "pnpm check && pnpm check:next-host",
177
+ "typecheck:tests": "tsc --noEmit -p tsconfig.test.json",
178
+ "test:integration": "node --test tests/integration/runtime.test.mjs",
179
+ "test:postgres": "node --test tests/integration/postgres.test.mjs"
175
180
  }
176
181
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"authoring-references-BJQ_1nMX.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, meaningful layout, 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;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AAS,QAAQ;AAChG,QAAO,UAAU;EAAE,OAAO,GAAG,QAAQ;EAAa;EAAS,GAAG,KAAA"}
@@ -1,73 +0,0 @@
1
- import { q as assistantItemTypeManifestSchema } from "./protocol-BhzQbx81.mjs";
2
- import { buildCapabilityDigest, stableStringify } from "./digest.mjs";
3
- //#region src/engine/capabilities.ts
4
- const resolveAssistantCapabilityReference = ({ capabilities, itemType, topic }) => capabilities?.byItemType.get(itemType)?.references?.find((reference) => reference.topic === topic);
5
- const inspectAssistantItem = ({ capabilities, item }) => capabilities?.byItemType.get(item.itemType)?.inspectItem?.(item);
6
- const createSurveyAssistantCapabilities = (capabilities) => {
7
- const byItemType = /* @__PURE__ */ new Map();
8
- const normalizedManifests = [];
9
- for (const capability of capabilities) {
10
- const manifest = assistantItemTypeManifestSchema.parse(capability.manifest);
11
- const itemType = manifest.itemType;
12
- if (byItemType.has(itemType)) throw new Error(`Duplicate survey assistant capability for item type "${itemType}".`);
13
- if (manifest.create === "deterministic" && !manifest.supportedOperations.includes("create-item")) throw new Error(`Deterministically creatable item type "${itemType}" must support "create-item".`);
14
- const declaredReferenceTopics = new Set(manifest.referenceTopics ?? []);
15
- for (const reference of capability.references ?? []) if (!declaredReferenceTopics.has(reference.topic)) throw new Error(`Capability reference "${reference.topic}" for item type "${itemType}" is missing from manifest.referenceTopics.`);
16
- byItemType.set(itemType, capability);
17
- normalizedManifests.push(assistantItemTypeManifestSchema.parse(JSON.parse(JSON.stringify(manifest))));
18
- }
19
- const manifestWithoutDigest = { itemTypes: normalizedManifests.sort((left, right) => left.itemType.localeCompare(right.itemType)) };
20
- return {
21
- manifest: {
22
- ...manifestWithoutDigest,
23
- digest: buildCapabilityDigest(manifestWithoutDigest)
24
- },
25
- byItemType
26
- };
27
- };
28
- const getDeterministicCreateItemTypes = (manifest) => manifest.itemTypes.filter((entry) => entry.create === "deterministic").map((entry) => entry.itemType);
29
- const resolveAssistantItemCreation = ({ itemType, manifest, parentItemId }) => {
30
- const capability = manifest.itemTypes.find((entry) => entry.itemType === itemType);
31
- if (capability?.create === "deterministic") return { kind: "deterministic" };
32
- if (capability?.create === "interactive-only") return {
33
- kind: "ui-intent",
34
- intent: {
35
- kind: "open-create-item",
36
- itemType,
37
- parentItemId
38
- }
39
- };
40
- return {
41
- kind: "unsupported",
42
- reason: capability ? `Item type "${itemType}" does not support assistant creation.` : `Item type "${itemType}" is not installed.`
43
- };
44
- };
45
- const createUnsupportedItemCapability = ({ displayName, itemType }) => ({ manifest: {
46
- itemType,
47
- capabilityVersion: "unsupported-v1",
48
- displayName,
49
- create: "unsupported",
50
- supportedOperations: [],
51
- contentSurfaces: []
52
- } });
53
- var SurveyAssistantCapabilityMismatchError = class extends Error {
54
- code = "survey-assistant-capability-mismatch";
55
- constructor(message = "Survey assistant capabilities changed; start a fresh turn and retry.") {
56
- super(message);
57
- this.name = "SurveyAssistantCapabilityMismatchError";
58
- }
59
- };
60
- const assertSurveyAssistantCapabilities = ({ manifest, trustedCapabilities, versionDigest }) => {
61
- const { digest: claimedDigest, ...manifestWithoutDigest } = manifest;
62
- if (claimedDigest !== buildCapabilityDigest(manifestWithoutDigest) || versionDigest !== claimedDigest) throw new SurveyAssistantCapabilityMismatchError();
63
- if (trustedCapabilities) {
64
- const withoutContextualPresets = ({ creationPresets: _creationPresets, ...capability }) => capability;
65
- const claimedBaseCapabilities = manifest.itemTypes.map(withoutContextualPresets);
66
- const trustedBaseCapabilities = trustedCapabilities.manifest.itemTypes.map(withoutContextualPresets);
67
- if (stableStringify(claimedBaseCapabilities) !== stableStringify(trustedBaseCapabilities)) throw new SurveyAssistantCapabilityMismatchError("The editor and server use different survey assistant capabilities; refresh and retry.");
68
- }
69
- };
70
- //#endregion
71
- 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 };
72
-
73
- //# sourceMappingURL=capabilities-1KNnNO1_.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capabilities-1KNnNO1_.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, stableStringify } 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 const normalizedManifests: AssistantItemTypeManifest[] = [];\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 normalizedManifests.push(\n assistantItemTypeManifestSchema.parse(JSON.parse(JSON.stringify(manifest))),\n );\n }\n\n const itemTypes = normalizedManifests.sort((left, right) =>\n left.itemType.localeCompare(right.itemType),\n );\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) {\n const withoutContextualPresets = ({\n creationPresets: _creationPresets,\n ...capability\n }: AssistantItemTypeManifest): Omit<AssistantItemTypeManifest, \"creationPresets\"> => capability;\n const claimedBaseCapabilities = manifest.itemTypes.map(withoutContextualPresets);\n const trustedBaseCapabilities =\n trustedCapabilities.manifest.itemTypes.map(withoutContextualPresets);\n\n // Creation presets are editor-registry context for the model. They do not\n // grant operations or install executable adapters, so the server validates\n // the stable capability contract while retaining its own trusted adapters.\n if (stableStringify(claimedBaseCapabilities) !== stableStringify(trustedBaseCapabilities)) {\n throw new SurveyAssistantCapabilityMismatchError(\n \"The editor and server use different survey assistant capabilities; refresh and retry.\",\n );\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;CACpE,MAAM,sBAAmD,EAAE;AAE3D,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,UAAU,WAAW;AACpC,sBAAoB,KAClB,gCAAgC,MAAM,KAAK,MAAM,KAAK,UAAU,SAAS,CAAC,CAAC,CAC5E;;CAMH,MAAM,wBAAwB,EAAE,WAHd,oBAAoB,MAAM,MAAM,UAChD,KAAK,SAAS,cAAc,MAAM,SAAS,CAEJ,EAAE;AAE3C,QAAO;EACL,UAAU;GACR,GAAG;GACH,QAAQ,sBAAsB,sBAAsB;GACrD;EACD;EACD;;AAGH,MAAa,mCACX,aAEA,SAAS,UACN,QAAQ,UAAU,MAAM,WAAW,gBAAgB,CACnD,KAAK,UAAU,MAAM,SAAS;AAEnC,MAAa,gCAAgC,EAC3C,UACA,UACA,mBAKqC;CACrC,MAAM,aAAa,SAAS,UAAU,MAAM,UAAU,MAAM,aAAa,SAAS;AAClF,KAAI,YAAY,WAAW,gBACzB,QAAO,EAAE,MAAM,iBAAiB;AAElC,KAAI,YAAY,WAAW,mBACzB,QAAO;EACL,MAAM;EACN,QAAQ;GAAE,MAAM;GAAoB;GAAU;GAAc;EAC7D;AAEH,QAAO;EACL,MAAM;EACN,QAAQ,aACJ,cAAc,SAAS,0CACvB,cAAc,SAAS;EAC5B;;AAGH,MAAa,mCAAmC,EAC9C,aACA,gBAIqC,EACrC,UAAU;CACR;CACA,mBAAmB;CACnB;CACA,QAAQ;CACR,qBAAqB,EAAE;CACvB,iBAAiB,EAAE;CACpB,EACF;AAED,IAAa,yCAAb,cAA4D,MAAM;CAChE,OAAgB;CAEhB,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,qBAAqB;EACvB,MAAM,4BAA4B,EAChC,iBAAiB,kBACjB,GAAG,iBACgF;EACrF,MAAM,0BAA0B,SAAS,UAAU,IAAI,yBAAyB;EAChF,MAAM,0BACJ,oBAAoB,SAAS,UAAU,IAAI,yBAAyB;AAKtE,MAAI,gBAAgB,wBAAwB,KAAK,gBAAgB,wBAAwB,CACvF,OAAM,IAAI,uCACR,wFACD"}
@@ -1,193 +0,0 @@
1
- import { z } from "zod";
2
-
3
- //#region src/protocol/capabilities.d.ts
4
- declare const assistantItemCreateModeSchema: z.ZodEnum<{
5
- deterministic: "deterministic";
6
- "interactive-only": "interactive-only";
7
- unsupported: "unsupported";
8
- }>;
9
- declare const assistantContentSurfaceSchema: z.ZodObject<{
10
- key: z.ZodString;
11
- role: z.ZodEnum<{
12
- primary: "primary";
13
- secondary: "secondary";
14
- option: "option";
15
- field: "field";
16
- validation: "validation";
17
- }>;
18
- format: z.ZodEnum<{
19
- plain: "plain";
20
- rich: "rich";
21
- }>;
22
- requiredOnCreate: z.ZodOptional<z.ZodBoolean>;
23
- pattern: z.ZodOptional<z.ZodBoolean>;
24
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
- }, z.core.$strip>;
26
- declare const assistantResponseSlotSchema: z.ZodObject<{
27
- key: z.ZodString;
28
- valueType: z.ZodString;
29
- }, z.core.$strip>;
30
- declare const assistantItemAuthoringSchema: z.ZodObject<{
31
- compactHint: z.ZodOptional<z.ZodString>;
32
- configSummary: z.ZodOptional<z.ZodString>;
33
- }, z.core.$strip>;
34
- declare const assistantItemTypeManifestSchema: z.ZodObject<{
35
- itemType: z.ZodString;
36
- capabilityVersion: z.ZodString;
37
- displayName: z.ZodString;
38
- description: z.ZodOptional<z.ZodString>;
39
- defaultItemKeyPrefix: z.ZodOptional<z.ZodString>;
40
- create: z.ZodEnum<{
41
- deterministic: "deterministic";
42
- "interactive-only": "interactive-only";
43
- unsupported: "unsupported";
44
- }>;
45
- supportedOperations: z.ZodArray<z.ZodEnum<{
46
- "create-item": "create-item";
47
- "update-item-key": "update-item-key";
48
- "update-item-label": "update-item-label";
49
- "update-item-color": "update-item-color";
50
- "update-item-translation": "update-item-translation";
51
- "update-placed-image": "update-placed-image";
52
- "patch-item-config": "patch-item-config";
53
- "upsert-form-field-group": "upsert-form-field-group";
54
- "remove-form-field-group": "remove-form-field-group";
55
- "reorder-form-field-groups": "reorder-form-field-groups";
56
- "upsert-form-field": "upsert-form-field";
57
- "remove-form-field": "remove-form-field";
58
- "move-form-field": "move-form-field";
59
- "set-embedded-form": "set-embedded-form";
60
- "remove-embedded-form": "remove-embedded-form";
61
- "add-choice-option": "add-choice-option";
62
- "update-choice-option-label": "update-choice-option-label";
63
- "remove-choice-option": "remove-choice-option";
64
- "reorder-choice-options": "reorder-choice-options";
65
- "remove-item": "remove-item";
66
- "move-item": "move-item";
67
- "reorder-items": "reorder-items";
68
- "update-survey-metadata": "update-survey-metadata";
69
- "update-survey-pagination": "update-survey-pagination";
70
- "update-survey-translation": "update-survey-translation";
71
- "add-survey-locale": "add-survey-locale";
72
- "remove-survey-locale": "remove-survey-locale";
73
- "set-image-asset": "set-image-asset";
74
- "update-image-asset-metadata": "update-image-asset-metadata";
75
- "remove-image-asset": "remove-image-asset";
76
- "survey-json-patch": "survey-json-patch";
77
- }>>;
78
- contentSurfaces: z.ZodArray<z.ZodObject<{
79
- key: z.ZodString;
80
- role: z.ZodEnum<{
81
- primary: "primary";
82
- secondary: "secondary";
83
- option: "option";
84
- field: "field";
85
- validation: "validation";
86
- }>;
87
- format: z.ZodEnum<{
88
- plain: "plain";
89
- rich: "rich";
90
- }>;
91
- requiredOnCreate: z.ZodOptional<z.ZodBoolean>;
92
- pattern: z.ZodOptional<z.ZodBoolean>;
93
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
94
- }, z.core.$strip>>;
95
- responseSlots: z.ZodOptional<z.ZodArray<z.ZodObject<{
96
- key: z.ZodString;
97
- valueType: z.ZodString;
98
- }, z.core.$strip>>>;
99
- creationPresets: z.ZodOptional<z.ZodArray<z.ZodObject<{
100
- id: z.ZodString;
101
- }, z.core.$strip>>>;
102
- referenceTopics: z.ZodOptional<z.ZodArray<z.ZodString>>;
103
- authoring: z.ZodOptional<z.ZodObject<{
104
- compactHint: z.ZodOptional<z.ZodString>;
105
- configSummary: z.ZodOptional<z.ZodString>;
106
- }, z.core.$strip>>;
107
- }, z.core.$strip>;
108
- declare const surveyAssistantCapabilityManifestSchema: z.ZodObject<{
109
- digest: z.ZodString;
110
- itemTypes: z.ZodArray<z.ZodObject<{
111
- itemType: z.ZodString;
112
- capabilityVersion: z.ZodString;
113
- displayName: z.ZodString;
114
- description: z.ZodOptional<z.ZodString>;
115
- defaultItemKeyPrefix: z.ZodOptional<z.ZodString>;
116
- create: z.ZodEnum<{
117
- deterministic: "deterministic";
118
- "interactive-only": "interactive-only";
119
- unsupported: "unsupported";
120
- }>;
121
- supportedOperations: z.ZodArray<z.ZodEnum<{
122
- "create-item": "create-item";
123
- "update-item-key": "update-item-key";
124
- "update-item-label": "update-item-label";
125
- "update-item-color": "update-item-color";
126
- "update-item-translation": "update-item-translation";
127
- "update-placed-image": "update-placed-image";
128
- "patch-item-config": "patch-item-config";
129
- "upsert-form-field-group": "upsert-form-field-group";
130
- "remove-form-field-group": "remove-form-field-group";
131
- "reorder-form-field-groups": "reorder-form-field-groups";
132
- "upsert-form-field": "upsert-form-field";
133
- "remove-form-field": "remove-form-field";
134
- "move-form-field": "move-form-field";
135
- "set-embedded-form": "set-embedded-form";
136
- "remove-embedded-form": "remove-embedded-form";
137
- "add-choice-option": "add-choice-option";
138
- "update-choice-option-label": "update-choice-option-label";
139
- "remove-choice-option": "remove-choice-option";
140
- "reorder-choice-options": "reorder-choice-options";
141
- "remove-item": "remove-item";
142
- "move-item": "move-item";
143
- "reorder-items": "reorder-items";
144
- "update-survey-metadata": "update-survey-metadata";
145
- "update-survey-pagination": "update-survey-pagination";
146
- "update-survey-translation": "update-survey-translation";
147
- "add-survey-locale": "add-survey-locale";
148
- "remove-survey-locale": "remove-survey-locale";
149
- "set-image-asset": "set-image-asset";
150
- "update-image-asset-metadata": "update-image-asset-metadata";
151
- "remove-image-asset": "remove-image-asset";
152
- "survey-json-patch": "survey-json-patch";
153
- }>>;
154
- contentSurfaces: z.ZodArray<z.ZodObject<{
155
- key: z.ZodString;
156
- role: z.ZodEnum<{
157
- primary: "primary";
158
- secondary: "secondary";
159
- option: "option";
160
- field: "field";
161
- validation: "validation";
162
- }>;
163
- format: z.ZodEnum<{
164
- plain: "plain";
165
- rich: "rich";
166
- }>;
167
- requiredOnCreate: z.ZodOptional<z.ZodBoolean>;
168
- pattern: z.ZodOptional<z.ZodBoolean>;
169
- aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
170
- }, z.core.$strip>>;
171
- responseSlots: z.ZodOptional<z.ZodArray<z.ZodObject<{
172
- key: z.ZodString;
173
- valueType: z.ZodString;
174
- }, z.core.$strip>>>;
175
- creationPresets: z.ZodOptional<z.ZodArray<z.ZodObject<{
176
- id: z.ZodString;
177
- }, z.core.$strip>>>;
178
- referenceTopics: z.ZodOptional<z.ZodArray<z.ZodString>>;
179
- authoring: z.ZodOptional<z.ZodObject<{
180
- compactHint: z.ZodOptional<z.ZodString>;
181
- configSummary: z.ZodOptional<z.ZodString>;
182
- }, z.core.$strip>>;
183
- }, z.core.$strip>>;
184
- }, z.core.$strip>;
185
- type AssistantItemCreateMode = z.infer<typeof assistantItemCreateModeSchema>;
186
- type AssistantContentSurface = z.infer<typeof assistantContentSurfaceSchema>;
187
- type AssistantResponseSlot = z.infer<typeof assistantResponseSlotSchema>;
188
- type AssistantItemAuthoring = z.infer<typeof assistantItemAuthoringSchema>;
189
- type AssistantItemTypeManifest = z.infer<typeof assistantItemTypeManifestSchema>;
190
- type SurveyAssistantCapabilityManifest = z.infer<typeof surveyAssistantCapabilityManifestSchema>;
191
- //#endregion
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-DVTfogjv.d.mts.map
@@ -1 +0,0 @@
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 +0,0 @@
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 createChoiceItemConfig,\n getChoiceOptionEmbeddedFormResponseSlotPrefix,\n getChoiceResponseValueType,\n} from \"@case-framework/survey-items/choice\";\nimport {\n createSurveyAssistantCapabilities,\n type AssistantItemCapabilityAdapter,\n} from \"../engine/capabilities\";\nimport {\n createFormItemConfig,\n getFormFieldValueType,\n isValidSimpleFormConfig,\n normalizeFormAuthoringConfig,\n} from \"@case-framework/survey-items/form\";\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 const config = isRecord(item.config) ? item.config : {};\n const defaults = createChoiceItemConfig(item.id);\n\n return normalizeEmbeddedFormAuthoringModes({\n ...item,\n config: {\n ...defaults,\n ...config,\n id: item.id,\n maxSelection: \"maxSelection\" in config ? config.maxSelection : defaults.maxSelection,\n shuffleOptions: \"shuffleOptions\" in config ? config.shuffleOptions : defaults.shuffleOptions,\n options: Array.isArray(config.options) ? config.options : defaults.options,\n },\n });\n};\n\nconst materializeFormCreate = (item: RawSurveyItem): RawSurveyItem => ({\n ...item,\n config: normalizeFormAuthoringConfig({\n ...createFormItemConfig(item.id),\n ...(isRecord(item.config) ? item.config : {}),\n id: item.id,\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] = getFormFieldValueType(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]: getChoiceResponseValueType(config.maxSelection === 1 ? 1 : null),\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(\n slots,\n deriveFormResponseSlots(\n option.embeddedForm,\n getChoiceOptionEmbeddedFormResponseSlotPrefix(option.id),\n ),\n );\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":";;;;AAkBA,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,SAA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F,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 +0,0 @@
1
- {"version":3,"file":"constants-Be91Gay9.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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"controller-proxy-BH05e-C2.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 {\n isSurveyAssistantErrorRetryable,\n parseSurveyAssistantError,\n type SurveyAssistantErrorCode,\n type SurveyAssistantErrorInfo,\n} from \"../protocol\";\n\nexport class SurveyAssistantClientError extends Error {\n readonly code: SurveyAssistantErrorCode;\n readonly retryable: boolean;\n readonly upstreamStatus?: number;\n readonly providerRequestId?: string;\n readonly providerMessage?: string;\n\n constructor(\n code: SurveyAssistantErrorCode,\n message: string,\n retryable = false,\n diagnostics: Pick<\n SurveyAssistantErrorInfo,\n \"providerMessage\" | \"providerRequestId\" | \"upstreamStatus\"\n > = {},\n ) {\n super(message);\n this.name = \"SurveyAssistantClientError\";\n this.code = code;\n this.retryable = retryable;\n this.upstreamStatus = diagnostics.upstreamStatus;\n this.providerRequestId = diagnostics.providerRequestId;\n this.providerMessage = diagnostics.providerMessage;\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\" && body !== null && \"error\" in body && typeof body.error === \"string\"\n ? body.error\n : responseText.trim() || fallback;\n const parsed = parseSurveyAssistantError(\n typeof body === \"object\" && body !== null && \"code\" in body && typeof body.code === \"string\"\n ? {\n code: body.code,\n detail,\n retryable:\n \"retryable\" in body && typeof body.retryable === \"boolean\"\n ? body.retryable\n : undefined,\n upstreamStatus:\n \"upstreamStatus\" in body && typeof body.upstreamStatus === \"number\"\n ? body.upstreamStatus\n : undefined,\n providerRequestId:\n \"providerRequestId\" in body && typeof body.providerRequestId === \"string\"\n ? body.providerRequestId\n : undefined,\n providerMessage:\n \"providerMessage\" in body && typeof body.providerMessage === \"string\"\n ? body.providerMessage\n : undefined,\n }\n : detail,\n );\n const retryable = isSurveyAssistantErrorRetryable(parsed, response.status);\n throw new SurveyAssistantClientError(parsed.code, parsed.detail ?? detail, retryable, parsed);\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 applyAssistantChanges: (changes): SurveyBatchApplyResult => {\n const controller = getController();\n if (!controller) {\n return { results: changes.map((change) => failedResult(change, notReadyMessage)) };\n }\n return controller.applyAssistantChanges(changes);\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":";;AAOA,IAAa,6BAAb,cAAgD,MAAM;CACpD;CACA;CACA;CACA;CACA;CAEA,YACE,MACA,SACA,YAAY,OACZ,cAGI,EAAE,EACN;AACA,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,YAAY;AACjB,OAAK,iBAAiB,YAAY;AAClC,OAAK,oBAAoB,YAAY;AACrC,OAAK,kBAAkB,YAAY;;;AAIvC,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,YAAY,SAAS,QAAQ,WAAW,QAAQ,OAAO,KAAK,UAAU,WAClF,KAAK,QACL,aAAa,MAAM,IAAI;EAC7B,MAAM,SAAS,0BACb,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU,QAAQ,OAAO,KAAK,SAAS,WAChF;GACE,MAAM,KAAK;GACX;GACA,WACE,eAAe,QAAQ,OAAO,KAAK,cAAc,YAC7C,KAAK,YACL,KAAA;GACN,gBACE,oBAAoB,QAAQ,OAAO,KAAK,mBAAmB,WACvD,KAAK,iBACL,KAAA;GACN,mBACE,u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