@case-framework/survey-assistant 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +9 -4
  2. package/dist/attachments-B0hg3vpT.mjs +11 -0
  3. package/dist/attachments-B0hg3vpT.mjs.map +1 -0
  4. package/dist/authoring-references-BJQ_1nMX.mjs +115 -0
  5. package/dist/authoring-references-BJQ_1nMX.mjs.map +1 -0
  6. package/dist/capabilities-1KNnNO1_.mjs +73 -0
  7. package/dist/capabilities-1KNnNO1_.mjs.map +1 -0
  8. package/dist/{capabilities-CnsVuJ1k.d.mts → capabilities-DVTfogjv.d.mts} +1 -1
  9. package/dist/{capabilities-CnsVuJ1k.d.mts.map → capabilities-DVTfogjv.d.mts.map} +1 -1
  10. package/dist/capabilities-default.d.mts +1 -1
  11. package/dist/capabilities-default.d.mts.map +1 -1
  12. package/dist/capabilities-default.mjs +47 -20
  13. package/dist/capabilities-default.mjs.map +1 -1
  14. package/dist/{constants-CFUWrRtl.mjs → constants-0UHGFcRJ.mjs} +1 -1
  15. package/dist/{constants-CFUWrRtl.mjs.map → constants-0UHGFcRJ.mjs.map} +1 -1
  16. package/dist/{constants-DbrJxxOh.d.mts → constants-Be91Gay9.d.mts} +4 -4
  17. package/dist/{constants-DbrJxxOh.d.mts.map → constants-Be91Gay9.d.mts.map} +1 -1
  18. package/dist/{controller-proxy-jWIPOZAv.mjs → controller-proxy-BH05e-C2.mjs} +21 -8
  19. package/dist/controller-proxy-BH05e-C2.mjs.map +1 -0
  20. package/dist/{controller-proxy-BdKF2yrq.d.mts → controller-proxy-Bd0ZHBPF.d.mts} +11 -11
  21. package/dist/controller-proxy-Bd0ZHBPF.d.mts.map +1 -0
  22. package/dist/{digest-Dyjch_sC.d.mts → digest-SJmoYVaK.d.mts} +2 -2
  23. package/dist/{digest-Dyjch_sC.d.mts.map → digest-SJmoYVaK.d.mts.map} +1 -1
  24. package/dist/digest.d.mts +1 -1
  25. package/dist/{engine-DcSdLRle.mjs → engine-Bo85Oyj0.mjs} +3129 -2435
  26. package/dist/engine-Bo85Oyj0.mjs.map +1 -0
  27. package/dist/engine.d.mts +3 -3
  28. package/dist/engine.mjs +3 -3
  29. package/dist/{fair-guidance-CEdJYccK.mjs → fair-guidance-CRYCRxQm.mjs} +1 -1
  30. package/dist/{fair-guidance-CEdJYccK.mjs.map → fair-guidance-CRYCRxQm.mjs.map} +1 -1
  31. package/dist/{index-Da_Hb9-1.d.mts → index-Tnqv-yKW.d.mts} +73 -67
  32. package/dist/index-Tnqv-yKW.d.mts.map +1 -0
  33. package/dist/index-l_EK4yK7.d.mts +404 -0
  34. package/dist/index-l_EK4yK7.d.mts.map +1 -0
  35. package/dist/{index-BApnIiCI.d.mts → index-nhrgbgO5.d.mts} +24 -5
  36. package/dist/index-nhrgbgO5.d.mts.map +1 -0
  37. package/dist/{index-DhNQKOwr.d.mts → index-x0qprHgK.d.mts} +19 -7
  38. package/dist/index-x0qprHgK.d.mts.map +1 -0
  39. package/dist/{lifecycle-DWv5CiSu.d.mts → lifecycle-Bx0aq_4S.d.mts} +8 -2
  40. package/dist/{lifecycle-DWv5CiSu.d.mts.map → lifecycle-Bx0aq_4S.d.mts.map} +1 -1
  41. package/dist/{memory-thread-repository-CvYZwni6.mjs → memory-thread-repository-KWHQWFEW.mjs} +45 -14
  42. package/dist/memory-thread-repository-KWHQWFEW.mjs.map +1 -0
  43. package/dist/{protocol-DJUP4gc0.mjs → protocol-BhzQbx81.mjs} +66 -16
  44. package/dist/protocol-BhzQbx81.mjs.map +1 -0
  45. package/dist/protocol.d.mts +4 -4
  46. package/dist/protocol.mjs +3 -2
  47. package/dist/react-B3ybjJ-X.mjs +1620 -0
  48. package/dist/react-B3ybjJ-X.mjs.map +1 -0
  49. package/dist/react-integration.d.mts +1 -1
  50. package/dist/react-integration.mjs +1 -1
  51. package/dist/react.d.mts +3 -3
  52. package/dist/react.mjs +3 -3
  53. package/dist/references/assistant-operations.md +45 -39
  54. package/dist/references/expressions.md +28 -0
  55. package/dist/references/item-types.md +1 -1
  56. package/dist/references/localization.md +5 -4
  57. package/dist/references/rich-text-content.md +60 -27
  58. package/dist/references/source-material-surveys.md +9 -2
  59. package/dist/references/survey-data-model.md +9 -1
  60. package/dist/{request-context-D1sC54ZA.mjs → request-context-CG4SWijt.mjs} +3 -3
  61. package/dist/{request-context-D1sC54ZA.mjs.map → request-context-CG4SWijt.mjs.map} +1 -1
  62. package/dist/{request-guardrails-h4t6u8mP.mjs → request-guardrails-TmgQtqp4.mjs} +5 -12
  63. package/dist/request-guardrails-TmgQtqp4.mjs.map +1 -0
  64. package/dist/server-agent.d.mts +19 -8
  65. package/dist/server-agent.d.mts.map +1 -1
  66. package/dist/server-agent.mjs +11 -13
  67. package/dist/server-agent.mjs.map +1 -1
  68. package/dist/server-runtime.d.mts +12 -6
  69. package/dist/server-runtime.d.mts.map +1 -1
  70. package/dist/server-runtime.mjs +9 -4
  71. package/dist/server-runtime.mjs.map +1 -1
  72. package/dist/server-tasks.d.mts +1 -1
  73. package/dist/server-tasks.mjs +5 -5
  74. package/dist/server-tools.d.mts +1 -1
  75. package/dist/server-tools.mjs +1 -1
  76. package/dist/server.d.mts +7 -7
  77. package/dist/server.mjs +6 -6
  78. package/dist/storage-postgres.d.mts +1 -1
  79. package/dist/storage-postgres.mjs +1 -1
  80. package/dist/{tasks-CCtxjhwh.d.mts → tasks-CYqrcaRO.d.mts} +16 -4
  81. package/dist/tasks-CYqrcaRO.d.mts.map +1 -0
  82. package/dist/{thread-documents-Dvo6XS7o.d.mts → thread-documents-rmd6nyX9.d.mts} +1 -1
  83. package/dist/{thread-documents-Dvo6XS7o.d.mts.map → thread-documents-rmd6nyX9.d.mts.map} +1 -1
  84. package/dist/{thread-handlers-Bt9cDo-F.d.mts → thread-handlers-DBAaU7BA.d.mts} +7 -5
  85. package/dist/thread-handlers-DBAaU7BA.d.mts.map +1 -0
  86. package/dist/{tools-3tq-XqI0.mjs → tools-BvSovehT.mjs} +433 -495
  87. package/dist/tools-BvSovehT.mjs.map +1 -0
  88. package/dist/ui.css +1 -1
  89. package/dist/ui.d.mts +5 -4
  90. package/dist/ui.d.mts.map +1 -1
  91. package/dist/ui.mjs +744 -131
  92. package/dist/ui.mjs.map +1 -1
  93. package/docs/integration.md +43 -3
  94. package/package.json +21 -19
  95. package/dist/authoring-references-yyYC4Ydi.mjs +0 -98
  96. package/dist/authoring-references-yyYC4Ydi.mjs.map +0 -1
  97. package/dist/controller-proxy-BdKF2yrq.d.mts.map +0 -1
  98. package/dist/controller-proxy-jWIPOZAv.mjs.map +0 -1
  99. package/dist/engine-DcSdLRle.mjs.map +0 -1
  100. package/dist/form-authoring-BQh40yDb.mjs +0 -155
  101. package/dist/form-authoring-BQh40yDb.mjs.map +0 -1
  102. package/dist/index-BApnIiCI.d.mts.map +0 -1
  103. package/dist/index-Da_Hb9-1.d.mts.map +0 -1
  104. package/dist/index-DhNQKOwr.d.mts.map +0 -1
  105. package/dist/index-dV6df0W3.d.mts +0 -224
  106. package/dist/index-dV6df0W3.d.mts.map +0 -1
  107. package/dist/memory-thread-repository-CvYZwni6.mjs.map +0 -1
  108. package/dist/protocol-DJUP4gc0.mjs.map +0 -1
  109. package/dist/react-CY6N7lVi.mjs +0 -768
  110. package/dist/react-CY6N7lVi.mjs.map +0 -1
  111. package/dist/request-guardrails-h4t6u8mP.mjs.map +0 -1
  112. package/dist/tasks-CCtxjhwh.d.mts.map +0 -1
  113. package/dist/thread-handlers-Bt9cDo-F.d.mts.map +0 -1
  114. package/dist/tools-3tq-XqI0.mjs.map +0 -1
@@ -73,6 +73,8 @@ roles locally:
73
73
  ```yaml
74
74
  version: 1
75
75
  activeProvider: openai
76
+ supportBundle:
77
+ enabled: true
76
78
  providers:
77
79
  openai:
78
80
  type: openai
@@ -122,6 +124,13 @@ Only the active provider's secret is required. `SURVEY_ASSISTANT_ENABLED` is an
122
124
  optional operational override; provider, model, role, memory, request-limit, and
123
125
  execution policy remains document-owned.
124
126
 
127
+ Support-bundle export is enabled by default. Set `supportBundle.enabled: false`
128
+ in the configuration document to remove the built-in panel actions and reject
129
+ package preparation or generation calls that receive the disabled config.
130
+ `SURVEY_ASSISTANT_SUPPORT_BUNDLE_ENABLED` is an optional strict boolean
131
+ operational override. Both values are resolved by the package configuration
132
+ parser.
133
+
125
134
  #### Optional experimental-identity rollout gate
126
135
 
127
136
  Importing hosts can pass `requireExperimentalIdentityOptIn: true` as a third
@@ -288,9 +297,26 @@ const assistant = useSurveyEditorAssistantIntegration({
288
297
  applyPolicy="auto"
289
298
  controller={assistant.controller}
290
299
  onSettleApply={persistAndAuditAssistantApply}
300
+ supportBundle={{
301
+ enabled: supportBundleEnabled,
302
+ hostBuildVersion: deploymentRelease,
303
+ supportEmail: "survey-support@example.org",
304
+ }}
291
305
  />;
292
306
  ```
293
307
 
308
+ Resolve `config.supportBundle.enabled` in server-only host code and pass that
309
+ boolean through the server-to-client boundary as `supportBundleEnabled`. Do not
310
+ send the complete runtime config to the browser because it contains
311
+ server-only provider credentials.
312
+
313
+ The assistant controller requires `getSnapshot()` and
314
+ `applyAssistantChanges(changes)`. The session passes all authorized change sets
315
+ in one call, including a one-element array for a single change set. Return one
316
+ result per change set with its original ID, including any failed changes; the
317
+ session settles only when every result is applied. The shared Survey Editor
318
+ provides this adapter through its normal mutation and undo/redo path.
319
+
294
320
  `applyPolicy` is required because immediate apply, review, and denial are
295
321
  material host decisions. For a real editing host, `onSettleApply` should save
296
322
  the already-applied editor state and durable audit receipts. The session remains
@@ -306,6 +332,20 @@ silently discarding a requested approval. Use `"deny"` for read-only
306
332
  deployments. These policies do not remove inspection, chat, tasks, or
307
333
  attachments.
308
334
 
335
+ Support bundles include the Survey Assistant package version automatically. Set
336
+ `supportBundle.hostBuildVersion` to the host's release tag or commit so a
337
+ customer export identifies the deployed application code as well. The optional
338
+ `supportEmail` enables the post-download email draft; it does not upload or
339
+ attach the bundle automatically. Do not expose credentials or other secrets in
340
+ these values.
341
+
342
+ When `supportBundle.enabled` is false, the package removes both the history
343
+ action and the error-state export action. Its preparation and generation APIs
344
+ also reject when passed the same disabled config. A custom export integration
345
+ must pass the resolved config to those APIs; the setting is not a browser
346
+ security boundary against arbitrary host-authored code. The size estimator
347
+ returns `0` and the mailto helper returns `undefined` for a disabled config.
348
+
309
349
  The client carries the latest unsuccessful post-generation outcome into the
310
350
  next request. This lets the model distinguish a server-validated draft from a
311
351
  change that was later rejected by the editor, declined during review, or left
@@ -316,9 +356,9 @@ bounded lifecycle evidence, not an authorization input.
316
356
 
317
357
  ## Attachments
318
358
 
319
- Uploads remain enabled by default for PDF, GIF, JPEG, PNG, and WebP. The server
320
- checks request size, count, per-file and total bytes, filename controls, data
321
- URL/media-type agreement, and common file signatures before provider use.
359
+ Uploads remain enabled by default for PDF, JPEG, and PNG. The server checks
360
+ request size, count, per-file and total bytes, filename controls,
361
+ data URL/media-type agreement, and common file signatures before provider use.
322
362
 
323
363
  Passing `threadDocuments` enables persistence and safe replay in later turns.
324
364
  Passing `false` to the lifecycle means only persistence/replay is disabled;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@case-framework/survey-assistant",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Shared protocol, engine, and runtime for the CASE survey assistant.",
5
5
  "license": "ISC",
6
6
  "files": [
@@ -85,9 +85,12 @@
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",
88
90
  "@radix-ui/react-use-controllable-state": "^1.2.3",
89
91
  "class-variance-authority": "^0.7.1",
90
92
  "clsx": "^2.1.1",
93
+ "fflate": "^0.8.3",
91
94
  "lucide-react": "^1.11.0",
92
95
  "motion": "^12.42.2",
93
96
  "radix-ui": "^1.6.7",
@@ -96,22 +99,22 @@
96
99
  "tailwind-merge": "^3.5.0",
97
100
  "tw-animate-css": "^1.4.0",
98
101
  "use-stick-to-bottom": "^1.1.6",
99
- "zod": "^4.4.3",
100
- "@case-framework/ui-localization": "0.2.1"
102
+ "zod": "^4.4.3"
101
103
  },
102
104
  "devDependencies": {
103
- "@ai-sdk/react": "^4.0.55",
105
+ "@ai-sdk/react": "^4.0.81",
106
+ "@case-framework/survey-core": "0.7.0",
104
107
  "@jest/globals": "30.3.0",
105
- "@mastra/ai-sdk": "^1.7.1",
106
- "@mastra/core": "^1.56.0",
107
- "@mastra/memory": "^1.25.0",
108
- "@mastra/pg": "^1.19.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",
109
112
  "@tailwindcss/vite": "^4.3.2",
110
113
  "@types/jest": "^30.0.0",
111
114
  "@types/node": "^25.6.0",
112
115
  "@types/react": "^19.2.18",
113
116
  "@types/react-test-renderer": "19.1.0",
114
- "ai": "^7.0.52",
117
+ "ai": "^7.0.78",
115
118
  "jest": "^30.3.0",
116
119
  "react": "~19.2.8",
117
120
  "react-dom": "~19.2.8",
@@ -119,19 +122,18 @@
119
122
  "ts-jest": "^29.4.9",
120
123
  "tsdown": "^0.21.10",
121
124
  "typescript": "^6.0.3",
122
- "vite": "^8.0.10",
123
- "@case-framework/survey-core": "0.6.2"
125
+ "vite": "^8.0.10"
124
126
  },
125
127
  "peerDependencies": {
126
- "@ai-sdk/react": "^4.0.55",
127
- "@mastra/ai-sdk": "^1.7.1",
128
- "@mastra/core": "^1.56.0",
129
- "@mastra/memory": "^1.25.0",
130
- "@mastra/pg": "^1.19.0",
131
- "ai": "^7.0.52",
128
+ "@ai-sdk/react": "^4.0.81",
129
+ "@case-framework/survey-core": "^0.7.0",
130
+ "@mastra/ai-sdk": "^1.9.1",
131
+ "@mastra/core": "^1.61.0",
132
+ "@mastra/memory": "^1.27.0",
133
+ "@mastra/pg": "^1.21.1",
134
+ "ai": "^7.0.78",
132
135
  "react": ">=19.2.0",
133
- "react-dom": ">=19.2.0",
134
- "@case-framework/survey-core": "0.6.2"
136
+ "react-dom": ">=19.2.0"
135
137
  },
136
138
  "peerDependenciesMeta": {
137
139
  "@mastra/ai-sdk": {
@@ -1,98 +0,0 @@
1
- import path, { resolve } from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import { readFileSync } from "node:fs";
4
- //#region ../../node_modules/.pnpm/tsdown@0.21.10_synckit@0.11.13_typescript@6.0.3/node_modules/tsdown/esm-shims.js
5
- const getFilename = () => fileURLToPath(import.meta.url);
6
- const getDirname = () => path.dirname(getFilename());
7
- const __dirname = /* @__PURE__ */ getDirname();
8
- //#endregion
9
- //#region src/server/authoring-references.ts
10
- const loadReference = (fileName) => readFileSync(resolve(__dirname, "references", fileName), "utf8").trim();
11
- const surveyAuthoringReferenceTopics = [
12
- "core-rules",
13
- "survey-data-model",
14
- "source-material-surveys",
15
- "localization",
16
- "rich-text-content",
17
- "item-types",
18
- "embedded-forms",
19
- "expressions",
20
- "assistant-operations",
21
- "fair-by-design",
22
- "survey-quality"
23
- ];
24
- const ITEM_TYPE_SECTION_HEADINGS = {
25
- group: "group",
26
- "page-break": "page-break",
27
- infoItem: "infoItem",
28
- choiceItem: "choiceItem",
29
- formItem: "formItem"
30
- };
31
- const builtInSurveyAuthoringItemTypes = Object.freeze(Object.keys(ITEM_TYPE_SECTION_HEADINGS));
32
- const extractLevelTwoSection = (markdown, heading) => {
33
- const lines = markdown.split("\n");
34
- const sectionStart = lines.findIndex((line) => line.trim() === `## ${heading}`);
35
- if (sectionStart < 0) return;
36
- const nextSectionOffset = lines.slice(sectionStart + 1).findIndex((line) => line.startsWith("## "));
37
- const sectionEnd = nextSectionOffset < 0 ? lines.length : sectionStart + 1 + nextSectionOffset;
38
- return lines.slice(sectionStart, sectionEnd).join("\n").trim();
39
- };
40
- const surveyAuthoringReferences = {
41
- "core-rules": {
42
- title: "Core authoring rules",
43
- content: loadReference("core-rules.md")
44
- },
45
- "survey-data-model": {
46
- title: "Survey data model",
47
- content: loadReference("survey-data-model.md")
48
- },
49
- "source-material-surveys": {
50
- title: "Source-material survey implementation",
51
- content: loadReference("source-material-surveys.md")
52
- },
53
- localization: {
54
- title: "Survey localization",
55
- content: loadReference("localization.md")
56
- },
57
- "rich-text-content": {
58
- title: "Rich text content",
59
- content: loadReference("rich-text-content.md")
60
- },
61
- "item-types": {
62
- title: "Item types",
63
- content: loadReference("item-types.md")
64
- },
65
- "embedded-forms": {
66
- title: "Choice option embedded forms",
67
- content: loadReference("embedded-forms.md")
68
- },
69
- expressions: {
70
- title: "Expressions",
71
- content: loadReference("expressions.md")
72
- },
73
- "assistant-operations": {
74
- title: "Assistant operations",
75
- content: loadReference("assistant-operations.md")
76
- },
77
- "fair-by-design": {
78
- title: "FAIR-by-design survey authoring",
79
- content: loadReference("fair-by-design.md")
80
- },
81
- "survey-quality": {
82
- title: "Survey quality review",
83
- content: loadReference("survey-quality.md")
84
- }
85
- };
86
- const getBuiltInItemTypeAuthoringReference = (itemType) => {
87
- const heading = ITEM_TYPE_SECTION_HEADINGS[itemType];
88
- if (!heading) return;
89
- const content = extractLevelTwoSection(surveyAuthoringReferences["item-types"].content, heading);
90
- return content ? {
91
- title: `${heading} item type`,
92
- content
93
- } : void 0;
94
- };
95
- //#endregion
96
- export { surveyAuthoringReferences as i, getBuiltInItemTypeAuthoringReference as n, surveyAuthoringReferenceTopics as r, builtInSurveyAuthoringItemTypes as t };
97
-
98
- //# sourceMappingURL=authoring-references-yyYC4Ydi.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authoring-references-yyYC4Ydi.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\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 },\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 \"fair-by-design\": {\n title: \"FAIR-by-design survey authoring\",\n content: loadReference(\"fair-by-design.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,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;AAID,MAAM,6BAA+D;CACnE,OAAO;CACP,cAAc;CACd,UAAU;CACV,YAAY;CACZ,UAAU;CACX;AAED,MAAa,kCAAkC,OAAO,OACpD,OAAO,KAAK,2BAA2B,CACxC;AAED,MAAM,0BAA0B,UAAkB,YAAwC;CACxF,MAAM,QAAQ,SAAS,MAAM,KAAK;CAClC,MAAM,eAAe,MAAM,WAAW,SAAS,KAAK,MAAM,KAAK,MAAM,UAAU;AAC/E,KAAI,eAAe,EACjB;CAGF,MAAM,oBAAoB,MACvB,MAAM,eAAe,EAAE,CACvB,WAAW,SAAS,KAAK,WAAW,MAAM,CAAC;CAC9C,MAAM,aAAa,oBAAoB,IAAI,MAAM,SAAS,eAAe,IAAI;AAE7E,QAAO,MAAM,MAAM,cAAc,WAAW,CAAC,KAAK,KAAK,CAAC,MAAM;;AAGhE,MAAa,4BAA4B;CACvC,cAAc;EACZ,OAAO;EACP,SAAS,cAAc,gBAAgB;EACxC;CACD,qBAAqB;EACnB,OAAO;EACP,SAAS,cAAc,uBAAuB;EAC/C;CACD,2BAA2B;EACzB,OAAO;EACP,SAAS,cAAc,6BAA6B;EACrD;CACD,cAAc;EACZ,OAAO;EACP,SAAS,cAAc,kBAAkB;EAC1C;CACD,qBAAqB;EACnB,OAAO;EACP,SAAS,cAAc,uBAAuB;EAC/C;CACD,cAAc;EACZ,OAAO;EACP,SAAS,cAAc,gBAAgB;EACxC;CACD,kBAAkB;EAChB,OAAO;EACP,SAAS,cAAc,oBAAoB;EAC5C;CACD,aAAa;EACX,OAAO;EACP,SAAS,cAAc,iBAAiB;EACzC;CACD,wBAAwB;EACtB,OAAO;EACP,SAAS,cAAc,0BAA0B;EAClD;CACD,kBAAkB;EAChB,OAAO;EACP,SAAS,cAAc,oBAAoB;EAC5C;CACD,kBAAkB;EAChB,OAAO;EACP,SAAS,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 +0,0 @@
1
- {"version":3,"file":"controller-proxy-BdKF2yrq.d.mts","names":[],"sources":["../src/react/thread-launcher.ts","../src/react/task-client.ts","../src/react/controller.ts","../src/react/controller-proxy.ts"],"mappings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ACX,gBAAA,CACE,KAAA,EAAO,oCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,yCAAA,EACV,KAAA,GAAQ,uCAAA,GACP,OAAA,CAAQ,qCAAA;AAAA;AAAA,cAGA,+BAAA;EAAmC,GAAA;EAAA,UAAA;EAAA,UAAA;EAAA;AAAA,IAK7C,gCAAA,KAAwC,yBAAA;AAAA,cA8C9B,iCAAA,GACX,OAAA,GAAS,gCAAA,KACR,2BAAA;;;UC1Hc,yBAAA;EACf,WAAA,IAAe,uBAAA;EACf,oBAAA,EAAsB,MAAA,EAAQ,eAAA,GAAkB,iBAAA;EAChD,qBAAA,EAAuB,OAAA,EAAS,eAAA,KAAoB,sBAAA;AAAA;;;UCPrC,2CAAA;EACf,eAAA;AAAA;AAAA,UAGe,+BAAA;EACf,UAAA,EAAY,yBAAA;EACZ,aAAA,CAAc,UAAA,EAAY,yBAAA;AAAA;AAAA,cAWf,oCAAA,GACX,aAAA,QAAqB,yBAAA;EACrB;AAAA,IAEG,2CAAA,KACF,yBAAA;AAAA,cAUU,qCAAA,GACX,OAAA,GAAU,2CAAA,KACT,+BAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"controller-proxy-jWIPOZAv.mjs","names":[],"sources":["../src/react/client-error.ts","../src/react/thread-launcher.ts","../src/react/task-client.ts","../src/react/controller-proxy.ts"],"sourcesContent":["import { parseSurveyAssistantError, type SurveyAssistantErrorCode } from \"../protocol\";\n\nexport class SurveyAssistantClientError extends Error {\n readonly code: SurveyAssistantErrorCode;\n readonly retryable: boolean;\n\n constructor(code: SurveyAssistantErrorCode, message: string, retryable = false) {\n super(message);\n this.name = \"SurveyAssistantClientError\";\n this.code = code;\n this.retryable = retryable;\n }\n}\n\nexport const readSurveyAssistantJson = async (\n response: Response,\n fallback = \"The assistant request could not be completed.\",\n) => {\n if (!response.ok) {\n const responseText = await response.text().catch(() => \"\");\n let body: unknown;\n try {\n body = responseText ? JSON.parse(responseText) : undefined;\n } catch {\n body = undefined;\n }\n const detail =\n typeof body === \"object\" &&\n body !== null &&\n \"error\" in body &&\n typeof body.error === \"string\"\n ? body.error\n : responseText.trim() || fallback;\n const parsed = parseSurveyAssistantError(\n typeof body === \"object\" &&\n body !== null &&\n \"code\" in body &&\n typeof body.code === \"string\"\n ? { code: body.code, detail }\n : detail,\n );\n const explicitRetryable =\n typeof body === \"object\" &&\n body !== null &&\n \"retryable\" in body &&\n typeof body.retryable === \"boolean\"\n ? body.retryable\n : undefined;\n const retryable =\n explicitRetryable ??\n (parsed.code === \"rate_limited\" ||\n ((parsed.code === \"request_failed\" || parsed.code === \"attachment_unavailable\") &&\n response.status >= 500));\n throw new SurveyAssistantClientError(parsed.code, parsed.detail ?? detail, retryable);\n }\n return response.json().catch(() => ({}));\n};\n","import type {\n SurveyAssistantSnapshot,\n SurveyAssistantThread,\n SurveyEditorUIContext,\n} from \"../protocol\";\nimport type { FileUIPart } from \"ai\";\n\nexport type SurveyAssistantLaunchUIContext = Partial<Omit<SurveyEditorUIContext, \"history\">>;\n\nexport interface SurveyAssistantThreadLaunch {\n /** User-visible prompt submitted as the first message in the new thread. */\n prompt: string;\n files?: FileUIPart[];\n /** Optional model used for the opening assistant turn. */\n modelId?: string;\n /** Optional manual thread title. The prompt-derived automatic title is used by default. */\n title?: string;\n /** Turn-local editor context merged into the snapshot captured when the prompt is submitted. */\n uiContext?: SurveyAssistantLaunchUIContext;\n}\n\nexport interface SurveyAssistantThreadLauncher {\n /**\n * Creates a new thread and submits its first prompt when a connected panel is ready.\n * Calls made before the panel mounts are queued.\n */\n startThread(input: SurveyAssistantThreadLaunch): Promise<SurveyAssistantThread>;\n}\n\ntype LaunchHandler = (input: SurveyAssistantThreadLaunch) => Promise<SurveyAssistantThread>;\n\ninterface PendingLaunch {\n input: SurveyAssistantThreadLaunch;\n reject(error: unknown): void;\n resolve(thread: SurveyAssistantThread): void;\n}\n\ninterface LauncherState {\n handler: LaunchHandler | null;\n pending: PendingLaunch[];\n draining: boolean;\n}\n\nconst launcherStates = new WeakMap<SurveyAssistantThreadLauncher, LauncherState>();\n\nexport const applySurveyAssistantLaunchUIContext = (\n snapshot: SurveyAssistantSnapshot | null,\n uiContext: SurveyAssistantLaunchUIContext | undefined,\n): SurveyAssistantSnapshot | null =>\n snapshot && uiContext\n ? {\n ...snapshot,\n ui: {\n ...snapshot.ui,\n ...uiContext,\n },\n }\n : snapshot;\n\nconst getLauncherState = (launcher: SurveyAssistantThreadLauncher) => {\n const state = launcherStates.get(launcher);\n if (!state) {\n throw new Error(\n \"The survey assistant thread launcher was not created by createSurveyAssistantThreadLauncher.\",\n );\n }\n return state;\n};\n\nconst drainPendingLaunches = async (state: LauncherState) => {\n if (state.draining) return;\n state.draining = true;\n try {\n while (state.handler && state.pending.length > 0) {\n const pending = state.pending.shift();\n if (!pending) continue;\n try {\n pending.resolve(await state.handler(pending.input));\n } catch (error) {\n pending.reject(error);\n }\n }\n } finally {\n state.draining = false;\n }\n};\n\nexport const createSurveyAssistantThreadLauncher = (): SurveyAssistantThreadLauncher => {\n const state: LauncherState = { handler: null, pending: [], draining: false };\n const launcher: SurveyAssistantThreadLauncher = {\n startThread(input) {\n const prompt = input.prompt.trim();\n if (!prompt && (input.files?.length ?? 0) === 0) {\n return Promise.reject(new Error(\"A survey assistant prompt or attachment is required.\"));\n }\n\n return new Promise((resolve, reject) => {\n state.pending.push({\n input: {\n ...input,\n prompt,\n ...(input.files ? { files: [...input.files] } : {}),\n ...(input.modelId ? { modelId: input.modelId.trim() } : {}),\n ...(input.title ? { title: input.title.trim() } : {}),\n },\n reject,\n resolve,\n });\n void drainPendingLaunches(state);\n });\n },\n };\n launcherStates.set(launcher, state);\n return launcher;\n};\n\nexport const connectSurveyAssistantThreadLauncher = (\n launcher: SurveyAssistantThreadLauncher,\n handler: LaunchHandler,\n) => {\n const state = getLauncherState(launcher);\n if (state.handler && state.handler !== handler) {\n throw new Error(\"A survey assistant thread launcher can only control one mounted panel.\");\n }\n state.handler = handler;\n void drainPendingLaunches(state);\n\n return () => {\n if (state.handler === handler) state.handler = null;\n };\n};\n","import {\n surveyAssistantSuggestItemKeyResultSchema,\n surveyAssistantSuggestItemLabelResultSchema,\n surveyAssistantTranslateContentResultSchema,\n type SurveyAssistantSuggestItemKeyInput,\n type SurveyAssistantSuggestItemKeyResult,\n type SurveyAssistantSuggestItemLabelInput,\n type SurveyAssistantSuggestItemLabelResult,\n type SurveyAssistantTaskContext,\n type SurveyAssistantTaskInvocationMode,\n type SurveyAssistantTranslateContentInput,\n type SurveyAssistantTranslateContentResult,\n} from \"../protocol\";\nimport { readSurveyAssistantJson } from \"./client-error\";\n\nexport interface SurveyAssistantTaskClientOptions {\n api?: string;\n getModelId?: () => string | undefined;\n resourceId?: string;\n surveyId?: string;\n}\n\nexport interface SurveyAssistantTaskExecutionOptions {\n mode?: SurveyAssistantTaskInvocationMode;\n modelId?: string;\n signal?: AbortSignal;\n}\n\nexport interface SurveyAssistantTaskClient {\n suggestItemKey(\n input: SurveyAssistantSuggestItemKeyInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutionOptions,\n ): Promise<SurveyAssistantSuggestItemKeyResult>;\n suggestItemLabel(\n input: SurveyAssistantSuggestItemLabelInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutionOptions,\n ): Promise<SurveyAssistantSuggestItemLabelResult>;\n translateContent(\n input: SurveyAssistantTranslateContentInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutionOptions,\n ): Promise<SurveyAssistantTranslateContentResult>;\n}\n\nexport interface SurveyAssistantTaskExecutorRequestOptions {\n mode?: SurveyAssistantTaskInvocationMode;\n signal?: AbortSignal;\n}\n\nexport interface SurveyAssistantTaskExecutorCacheContext {\n cacheScope?: string;\n}\n\nexport interface SurveyAssistantTaskExecutor {\n suggestItemKey(\n input: SurveyAssistantSuggestItemKeyInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutorRequestOptions,\n cache?: SurveyAssistantTaskExecutorCacheContext,\n ): Promise<SurveyAssistantSuggestItemKeyResult>;\n suggestItemLabel(\n input: SurveyAssistantSuggestItemLabelInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutorRequestOptions,\n cache?: SurveyAssistantTaskExecutorCacheContext,\n ): Promise<SurveyAssistantSuggestItemLabelResult>;\n translateContent(\n input: SurveyAssistantTranslateContentInput,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutorRequestOptions,\n cache?: SurveyAssistantTaskExecutorCacheContext,\n ): Promise<SurveyAssistantTranslateContentResult>;\n}\n\nexport const createSurveyAssistantTaskClient = ({\n api = \"/api/survey-assistant/tasks\",\n getModelId,\n resourceId,\n surveyId,\n}: SurveyAssistantTaskClientOptions = {}): SurveyAssistantTaskClient => {\n const run = async (\n taskId: \"suggest-item-key\" | \"suggest-item-label\" | \"translate-content\",\n input: unknown,\n context: SurveyAssistantTaskContext,\n options?: SurveyAssistantTaskExecutionOptions,\n ) => {\n const modelId = options?.modelId ?? getModelId?.();\n return readSurveyAssistantJson(\n await fetch(api, {\n body: JSON.stringify({\n taskId,\n input,\n context,\n ...(options?.mode ? { mode: options.mode } : {}),\n ...(modelId ? { modelId } : {}),\n ...(resourceId ? { resourceId } : {}),\n ...(surveyId ? { surveyId } : {}),\n }),\n headers: { \"content-type\": \"application/json\" },\n method: \"POST\",\n signal: options?.signal,\n }),\n \"The survey assistant task could not be completed.\",\n );\n };\n\n return {\n async suggestItemKey(input, context, options) {\n return surveyAssistantSuggestItemKeyResultSchema.parse(\n await run(\"suggest-item-key\", input, context, options),\n );\n },\n async suggestItemLabel(input, context, options) {\n return surveyAssistantSuggestItemLabelResultSchema.parse(\n await run(\"suggest-item-label\", input, context, options),\n );\n },\n async translateContent(input, context, options) {\n return surveyAssistantTranslateContentResultSchema.parse(\n await run(\"translate-content\", input, context, options),\n );\n },\n };\n};\n\nexport const createSurveyAssistantTaskExecutor = (\n options: SurveyAssistantTaskClientOptions = {},\n): SurveyAssistantTaskExecutor => {\n const client = createSurveyAssistantTaskClient(options);\n const executionOptions = (\n request?: SurveyAssistantTaskExecutorRequestOptions,\n cache?: SurveyAssistantTaskExecutorCacheContext,\n ): SurveyAssistantTaskExecutionOptions => ({\n mode: request?.mode,\n modelId: cache?.cacheScope,\n signal: request?.signal,\n });\n\n return {\n suggestItemKey: (input, context, request, cache) =>\n client.suggestItemKey(input, context, executionOptions(request, cache)),\n suggestItemLabel: (input, context, request, cache) =>\n client.suggestItemLabel(input, context, executionOptions(request, cache)),\n translateContent: (input, context, request, cache) =>\n client.translateContent(input, context, executionOptions(request, cache)),\n };\n};\n","import type { SurveyApplyResult, SurveyBatchApplyResult, SurveyChangeSet } from \"../protocol\";\nimport type { SurveyAssistantController } from \"./controller\";\n\nexport interface CreateSurveyAssistantControllerProxyOptions {\n notReadyMessage?: string;\n}\n\nexport interface SurveyAssistantControllerBridge {\n controller: SurveyAssistantController;\n setController(controller: SurveyAssistantController | null | undefined): void;\n}\n\nconst failedResult = (change: SurveyChangeSet, message: string): SurveyApplyResult => ({\n status: \"failed\",\n changeId: change.id,\n summary: change.summary,\n message,\n appliedOperations: 0,\n});\n\nexport const createSurveyAssistantControllerProxy = (\n getController: () => SurveyAssistantController | null | undefined,\n {\n notReadyMessage = \"The survey editor is not ready.\",\n }: CreateSurveyAssistantControllerProxyOptions = {},\n): SurveyAssistantController => ({\n getSnapshot: () => getController()?.getSnapshot() ?? null,\n applyAssistantChange: (change) =>\n getController()?.applyAssistantChange?.(change) ?? failedResult(change, notReadyMessage),\n applyAssistantChanges: (changes): SurveyBatchApplyResult =>\n getController()?.applyAssistantChanges?.(changes) ?? {\n results: changes.map((change) => failedResult(change, notReadyMessage)),\n },\n});\n\nexport const createSurveyAssistantControllerBridge = (\n options?: CreateSurveyAssistantControllerProxyOptions,\n): SurveyAssistantControllerBridge => {\n let currentController: SurveyAssistantController | null | undefined;\n return {\n controller: createSurveyAssistantControllerProxy(() => currentController, options),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