@case-framework/survey-assistant 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{authoring-references-DYuOAdVx.mjs → authoring-references-ChDTVnms.mjs} +8 -2
- package/dist/authoring-references-ChDTVnms.mjs.map +1 -0
- package/dist/{capabilities-DlC1l6qy.d.mts → capabilities-CnsVuJ1k.d.mts} +12 -4
- package/dist/capabilities-CnsVuJ1k.d.mts.map +1 -0
- package/dist/capabilities-default.d.mts +1 -1
- package/dist/capabilities-default.d.mts.map +1 -1
- package/dist/capabilities-default.mjs +38 -4
- package/dist/capabilities-default.mjs.map +1 -1
- package/dist/{constants-CgV4cTg5.d.mts → constants-BK1-g6pR.d.mts} +12 -7
- package/dist/constants-BK1-g6pR.d.mts.map +1 -0
- package/dist/{controller-proxy-BzpEOygv.d.mts → controller-proxy-CIDRd8Wu.d.mts} +2 -2
- package/dist/{controller-proxy-BzpEOygv.d.mts.map → controller-proxy-CIDRd8Wu.d.mts.map} +1 -1
- package/dist/{controller-proxy-0WJZUZYx.mjs → controller-proxy-DY36XFV3.mjs} +2 -2
- package/dist/{controller-proxy-0WJZUZYx.mjs.map → controller-proxy-DY36XFV3.mjs.map} +1 -1
- package/dist/{digest-BvXpeWcR.d.mts → digest-Dyjch_sC.d.mts} +2 -2
- package/dist/{digest-BvXpeWcR.d.mts.map → digest-Dyjch_sC.d.mts.map} +1 -1
- package/dist/digest.d.mts +1 -1
- package/dist/{engine-0AJrv0hI.mjs → engine-CWTuN3o2.mjs} +866 -663
- package/dist/engine-CWTuN3o2.mjs.map +1 -0
- package/dist/engine.d.mts +3 -3
- package/dist/engine.mjs +3 -3
- package/dist/fair-guidance-CEdJYccK.mjs +21 -0
- package/dist/fair-guidance-CEdJYccK.mjs.map +1 -0
- package/dist/form-authoring-DCd9XfXf.mjs +155 -0
- package/dist/form-authoring-DCd9XfXf.mjs.map +1 -0
- package/dist/{index-BUF-sE8j.d.mts → index-Bp5W_oPa.d.mts} +27 -7
- package/dist/index-Bp5W_oPa.d.mts.map +1 -0
- package/dist/{index-BdXb6jER.d.mts → index-CPOQgkTN.d.mts} +67 -6
- package/dist/index-CPOQgkTN.d.mts.map +1 -0
- package/dist/{index-BiTT71Xp.d.mts → index-EDL1V168.d.mts} +101 -7
- package/dist/{index-BiTT71Xp.d.mts.map → index-EDL1V168.d.mts.map} +1 -1
- package/dist/{index-BNdvGEaq.d.mts → index-SPHf3OoJ.d.mts} +9 -3
- package/dist/index-SPHf3OoJ.d.mts.map +1 -0
- package/dist/{memory-thread-repository-1ocPOda8.mjs → memory-thread-repository-acbz6HZJ.mjs} +181 -26
- package/dist/memory-thread-repository-acbz6HZJ.mjs.map +1 -0
- package/dist/{protocol-DpCYmCjr.mjs → protocol-DATvkr1S.mjs} +125 -6
- package/dist/protocol-DATvkr1S.mjs.map +1 -0
- package/dist/protocol.d.mts +3 -3
- package/dist/protocol.mjs +2 -2
- package/dist/{react-DXK5zWNo.mjs → react-3kSE6WtS.mjs} +127 -9
- package/dist/react-3kSE6WtS.mjs.map +1 -0
- package/dist/react-integration.d.mts +1 -1
- package/dist/react-integration.mjs +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.mjs +2 -2
- package/dist/references/assistant-operations.md +13 -18
- package/dist/references/embedded-forms.md +41 -2
- package/dist/references/expressions.md +17 -9
- package/dist/references/fair-by-design.md +80 -0
- package/dist/references/item-types.md +19 -3
- package/dist/references/localization.md +7 -4
- package/dist/references/source-material-surveys.md +6 -4
- package/dist/{request-context-BBzU3VdG.mjs → request-context-BEjnaaFr.mjs} +10 -5
- package/dist/request-context-BEjnaaFr.mjs.map +1 -0
- package/dist/server-agent.d.mts +28 -8
- package/dist/server-agent.d.mts.map +1 -1
- package/dist/server-agent.mjs +70 -13
- package/dist/server-agent.mjs.map +1 -1
- package/dist/server-runtime.d.mts +22 -11
- package/dist/server-runtime.d.mts.map +1 -1
- package/dist/server-runtime.mjs +47 -19
- package/dist/server-runtime.mjs.map +1 -1
- package/dist/server-tasks.d.mts +1 -1
- package/dist/server-tasks.mjs +4 -3
- package/dist/server-tasks.mjs.map +1 -1
- package/dist/server-tools.d.mts +1 -1
- package/dist/server-tools.mjs +1 -1
- package/dist/server.d.mts +16 -7
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +4 -4
- package/dist/storage-postgres.d.mts +1 -1
- package/dist/{tasks-BuLnWrR4.d.mts → tasks-DIZgr4nD.d.mts} +8 -4
- package/dist/tasks-DIZgr4nD.d.mts.map +1 -0
- package/dist/{thread-documents-BlxNjc7S.d.mts → thread-documents-C3kf0Vds.d.mts} +1 -1
- package/dist/{thread-documents-BlxNjc7S.d.mts.map → thread-documents-C3kf0Vds.d.mts.map} +1 -1
- package/dist/{thread-handlers-6L8sAreR.d.mts → thread-handlers-DZ1WsorO.d.mts} +9 -4
- package/dist/thread-handlers-DZ1WsorO.d.mts.map +1 -0
- package/dist/{tools-wgLen05n.mjs → tools-GDd5_GUh.mjs} +403 -77
- package/dist/tools-GDd5_GUh.mjs.map +1 -0
- package/dist/ui.css +1 -1
- package/dist/ui.d.mts +3 -3
- package/dist/ui.d.mts.map +1 -1
- package/dist/ui.mjs +152 -36
- package/dist/ui.mjs.map +1 -1
- package/docs/integration.md +73 -5
- package/package.json +4 -4
- package/dist/authoring-references-DYuOAdVx.mjs.map +0 -1
- package/dist/capabilities-DKbNCnBf.mjs +0 -66
- package/dist/capabilities-DKbNCnBf.mjs.map +0 -1
- package/dist/capabilities-DlC1l6qy.d.mts.map +0 -1
- package/dist/constants-CgV4cTg5.d.mts.map +0 -1
- package/dist/engine-0AJrv0hI.mjs.map +0 -1
- package/dist/index-BNdvGEaq.d.mts.map +0 -1
- package/dist/index-BUF-sE8j.d.mts.map +0 -1
- package/dist/index-BdXb6jER.d.mts.map +0 -1
- package/dist/memory-thread-repository-1ocPOda8.mjs.map +0 -1
- package/dist/protocol-DpCYmCjr.mjs.map +0 -1
- package/dist/react-DXK5zWNo.mjs.map +0 -1
- package/dist/request-context-BBzU3VdG.mjs.map +0 -1
- package/dist/tasks-BuLnWrR4.d.mts.map +0 -1
- package/dist/thread-handlers-6L8sAreR.d.mts.map +0 -1
- package/dist/tools-wgLen05n.mjs.map +0 -1
package/docs/integration.md
CHANGED
|
@@ -62,10 +62,26 @@ OPENAI_API_KEY=...
|
|
|
62
62
|
DATABASE_URL=...
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
One deployment uses one provider.
|
|
66
|
-
`SURVEY_ASSISTANT_MODELS`, `SURVEY_ASSISTANT_TASK_MODEL`,
|
|
67
|
-
`SURVEY_ASSISTANT_MEMORY_MODEL`
|
|
68
|
-
|
|
65
|
+
One deployment uses one provider. For OpenAI, Mistral, and Azure,
|
|
66
|
+
`SURVEY_ASSISTANT_MODEL`, `SURVEY_ASSISTANT_MODELS`, `SURVEY_ASSISTANT_TASK_MODEL`,
|
|
67
|
+
and `SURVEY_ASSISTANT_MEMORY_MODEL` contain bare model or deployment ids, not
|
|
68
|
+
`provider/model` strings. Provider-prefixed values fail at startup.
|
|
69
|
+
|
|
70
|
+
LM Studio is available as an opt-in local development provider through Mastra's
|
|
71
|
+
built-in OpenAI-compatible model configuration. Set an explicit native model id;
|
|
72
|
+
the endpoint defaults to LM Studio's standard local server:
|
|
73
|
+
|
|
74
|
+
```dotenv
|
|
75
|
+
SURVEY_ASSISTANT_PROVIDER=lmstudio
|
|
76
|
+
SURVEY_ASSISTANT_MODEL=qwen/qwen3.6-27b
|
|
77
|
+
SURVEY_ASSISTANT_MODELS=qwen/qwen3.6-27b,qwen/qwen3.6-35b-a3b
|
|
78
|
+
# SURVEY_ASSISTANT_LMSTUDIO_BASE_URL=http://127.0.0.1:1234/v1
|
|
79
|
+
# SURVEY_ASSISTANT_LMSTUDIO_API_KEY=
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
LM Studio model ids are passed through verbatim and may contain slashes. The
|
|
83
|
+
configured model list remains the server-owned allowlist; the integration does
|
|
84
|
+
not discover or expose every model loaded in the local server.
|
|
69
85
|
|
|
70
86
|
`SURVEY_ASSISTANT_MODEL` is the default chat model and
|
|
71
87
|
`SURVEY_ASSISTANT_MODELS` is the server-owned chat picker allowlist. When
|
|
@@ -74,6 +90,12 @@ server-authorized chat selection; setting it pins all built-in tasks to that
|
|
|
74
90
|
model. The memory model is fixed per runtime and defaults to the configured chat
|
|
75
91
|
default. It is shared by Mastra's Observer and Reflector.
|
|
76
92
|
|
|
93
|
+
The default observational-memory instructions retain user requirements, actual
|
|
94
|
+
completion state, concrete validation/runtime failures, and actionable recovery
|
|
95
|
+
guidance. Unsupported assistant refusals or speculative claims about tool
|
|
96
|
+
availability, payload size, or inability to retry are not promoted into durable
|
|
97
|
+
task constraints.
|
|
98
|
+
|
|
77
99
|
This same-provider rule applies to the standard runtime. Hosts that genuinely
|
|
78
100
|
need custom dynamic or cross-provider model routing can compose the exported
|
|
79
101
|
low-level Agent and handler factories instead.
|
|
@@ -82,7 +104,9 @@ Optional operational settings have useful defaults:
|
|
|
82
104
|
|
|
83
105
|
```dotenv
|
|
84
106
|
SURVEY_ASSISTANT_MAX_CONCURRENT_REQUESTS=4
|
|
85
|
-
|
|
107
|
+
SURVEY_ASSISTANT_FIRST_RESPONSE_TIMEOUT_MS=900000
|
|
108
|
+
SURVEY_ASSISTANT_IDLE_TIMEOUT_MS=300000
|
|
109
|
+
SURVEY_ASSISTANT_MAX_DURATION_MS=3600000
|
|
86
110
|
SURVEY_ASSISTANT_MAX_STEPS=48
|
|
87
111
|
SURVEY_ASSISTANT_SEND_REASONING=true
|
|
88
112
|
SURVEY_ASSISTANT_MEMORY_ENABLED=true
|
|
@@ -94,6 +118,36 @@ SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES=12582912
|
|
|
94
118
|
SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS=64000
|
|
95
119
|
```
|
|
96
120
|
|
|
121
|
+
Chat execution uses three complementary limits. The first-response timeout
|
|
122
|
+
covers model loading and prompt processing until meaningful output begins. The
|
|
123
|
+
idle timeout resets whenever text, reasoning, or tool activity is streamed. The
|
|
124
|
+
maximum duration is a final safety ceiling and does not reset. Client disconnects
|
|
125
|
+
and explicit Stop actions still abort immediately. One-shot tasks are not
|
|
126
|
+
streamed, so they use only the maximum-duration ceiling.
|
|
127
|
+
|
|
128
|
+
Every streamed turn ends with a versioned turn-final part. New turn finals also
|
|
129
|
+
carry authoritative `startedAt`/`durationMs` timing and, for failed or aborted
|
|
130
|
+
turns, a machine-readable `terminationReason`. Hosts should preserve that part
|
|
131
|
+
in history and render its terminal state instead of inferring completion from
|
|
132
|
+
whether an assistant text part exists. Validated `survey_change` results include
|
|
133
|
+
an explicitly bounded `postChange` preview derived from the canonical
|
|
134
|
+
request-scoped draft. It preserves operation order, reports shown/total coverage
|
|
135
|
+
for every bounded collection, and labels shortened text with its full character
|
|
136
|
+
count. The complete draft remains authoritative when the preview omits a target
|
|
137
|
+
or field. Substantial, complex, truncated, or newly regressing changes also
|
|
138
|
+
carry bounded `verification` metadata. The agent must use focused inspection or
|
|
139
|
+
the deterministic audit before claiming those changes are complete; this does
|
|
140
|
+
not lower the global operation limits for legitimate large edits.
|
|
141
|
+
|
|
142
|
+
Model-facing recovery remains registry-derived and explicit. Unknown focused
|
|
143
|
+
reference, operation, or item-type names return bounded canonical suggestions
|
|
144
|
+
without silently accepting an alias. Oversized `survey_inspect` raw-path lists
|
|
145
|
+
are processed in request order with shown/total coverage, while an explicit
|
|
146
|
+
`itemRef` takes precedence over conflicting paths. `survey_audit` retains its
|
|
147
|
+
full structured report for the application but gives the model grouped counts,
|
|
148
|
+
bounded ordered examples, and an explicit reminder that deterministic findings
|
|
149
|
+
do not establish fidelity to an attached source.
|
|
150
|
+
|
|
97
151
|
Explicit malformed booleans, enums, or positive integers fail at startup.
|
|
98
152
|
`readinessError` reports missing credentials/storage without exposing them.
|
|
99
153
|
|
|
@@ -197,6 +251,14 @@ silently discarding a requested approval. Use `"deny"` for read-only
|
|
|
197
251
|
deployments. These policies do not remove inspection, chat, tasks, or
|
|
198
252
|
attachments.
|
|
199
253
|
|
|
254
|
+
The client carries the latest unsuccessful post-generation outcome into the
|
|
255
|
+
next request. This lets the model distinguish a server-validated draft from a
|
|
256
|
+
change that was later rejected by the editor, declined during review, or left
|
|
257
|
+
unsettled by the host. Failed, interrupted, and unresolved blocked turns also
|
|
258
|
+
report their bounded prepared-change summaries as discarded and not applied.
|
|
259
|
+
The current editor snapshot remains authoritative; the reported outcome is
|
|
260
|
+
bounded lifecycle evidence, not an authorization input.
|
|
261
|
+
|
|
200
262
|
## Attachments
|
|
201
263
|
|
|
202
264
|
Uploads remain enabled by default for PDF, GIF, JPEG, PNG, and WebP. The server
|
|
@@ -210,6 +272,12 @@ files and 200 MiB per thread, independently from the stricter per-request
|
|
|
210
272
|
defaults. Both storage limits are configurable when constructing the repository
|
|
211
273
|
or Postgres runtime.
|
|
212
274
|
|
|
275
|
+
The attachment tool can include an optional one-based PDF page range and short
|
|
276
|
+
section/question focus. The complete original is still attached and remains
|
|
277
|
+
authoritative; the range is a bounded reading cue, not extracted or cached
|
|
278
|
+
document text. Source-faithful continuation loads the original before browsing
|
|
279
|
+
lossy conversational memory.
|
|
280
|
+
|
|
213
281
|
For higher-risk deployments, add malware scanning before the route or in a
|
|
214
282
|
host-owned repository wrapper. Never render attachment bytes as executable
|
|
215
283
|
HTML, and keep provider/storage retention in the host privacy policy.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@case-framework/survey-assistant",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Shared protocol, engine, and runtime for the CASE survey assistant.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"files": [
|
|
@@ -117,18 +117,18 @@
|
|
|
117
117
|
"tsdown": "^0.21.10",
|
|
118
118
|
"typescript": "^6.0.3",
|
|
119
119
|
"vite": "^8.0.10",
|
|
120
|
-
"@case-framework/survey-core": "0.
|
|
120
|
+
"@case-framework/survey-core": "0.6.1"
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|
|
123
123
|
"@ai-sdk/react": "^4.0.10",
|
|
124
|
-
"@case-framework/survey-core": "^0.4.2",
|
|
125
124
|
"@mastra/ai-sdk": "^1.6.0",
|
|
126
125
|
"@mastra/core": "^1.47.0",
|
|
127
126
|
"@mastra/memory": "^1.21.2",
|
|
128
127
|
"@mastra/pg": "^1.14.2",
|
|
129
128
|
"ai": "^7.0.15",
|
|
130
129
|
"react": ">=19.2.0",
|
|
131
|
-
"react-dom": ">=19.2.0"
|
|
130
|
+
"react-dom": ">=19.2.0",
|
|
131
|
+
"@case-framework/survey-core": "0.6.1"
|
|
132
132
|
},
|
|
133
133
|
"peerDependenciesMeta": {
|
|
134
134
|
"@mastra/ai-sdk": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-references-DYuOAdVx.mjs","names":[],"sources":["../../../node_modules/.pnpm/tsdown@0.21.10_synckit@0.11.12_typescript@6.0.3/node_modules/tsdown/esm-shims.js","../src/server/authoring-references.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nconst loadReference = (fileName: string) =>\n readFileSync(resolve(__dirname, \"references\", fileName), \"utf8\").trim();\n\nexport const surveyAuthoringReferenceTopics = [\n \"core-rules\",\n \"survey-data-model\",\n \"source-material-surveys\",\n \"localization\",\n \"rich-text-content\",\n \"item-types\",\n \"embedded-forms\",\n \"expressions\",\n \"assistant-operations\",\n \"survey-quality\",\n] as const;\n\nexport type SurveyAuthoringReferenceTopic = (typeof surveyAuthoringReferenceTopics)[number];\n\nconst ITEM_TYPE_SECTION_HEADINGS: Readonly<Record<string, string>> = {\n group: \"group\",\n \"page-break\": \"page-break\",\n infoItem: \"infoItem\",\n choiceItem: \"choiceItem\",\n formItem: \"formItem\",\n};\n\nconst extractLevelTwoSection = (markdown: string, heading: string): string | undefined => {\n const lines = markdown.split(\"\\n\");\n const sectionStart = lines.findIndex((line) => line.trim() === `## ${heading}`);\n if (sectionStart < 0) {\n return undefined;\n }\n\n const nextSectionOffset = lines\n .slice(sectionStart + 1)\n .findIndex((line) => line.startsWith(\"## \"));\n const sectionEnd = nextSectionOffset < 0 ? lines.length : sectionStart + 1 + nextSectionOffset;\n\n return lines.slice(sectionStart, sectionEnd).join(\"\\n\").trim();\n};\n\nexport const surveyAuthoringReferences = {\n \"core-rules\": {\n title: \"Core authoring rules\",\n content: loadReference(\"core-rules.md\"),\n },\n \"survey-data-model\": {\n title: \"Survey data model\",\n content: loadReference(\"survey-data-model.md\"),\n },\n \"source-material-surveys\": {\n title: \"Source-material survey implementation\",\n content: loadReference(\"source-material-surveys.md\"),\n },\n localization: {\n title: \"Survey localization\",\n content: loadReference(\"localization.md\"),\n },\n \"rich-text-content\": {\n title: \"Rich text content\",\n content: loadReference(\"rich-text-content.md\"),\n },\n \"item-types\": {\n title: \"Item types\",\n content: loadReference(\"item-types.md\"),\n },\n \"embedded-forms\": {\n title: \"Choice option embedded forms\",\n content: loadReference(\"embedded-forms.md\"),\n },\n expressions: {\n title: \"Expressions\",\n content: loadReference(\"expressions.md\"),\n },\n \"assistant-operations\": {\n title: \"Assistant operations\",\n content: loadReference(\"assistant-operations.md\"),\n },\n \"survey-quality\": {\n title: \"Survey quality review\",\n content: loadReference(\"survey-quality.md\"),\n },\n} as const satisfies Record<SurveyAuthoringReferenceTopic, { title: string; content: string }>;\n\nexport const getBuiltInItemTypeAuthoringReference = (\n itemType: string,\n): { title: string; content: string } | undefined => {\n const heading = ITEM_TYPE_SECTION_HEADINGS[itemType];\n if (!heading) {\n return undefined;\n }\n\n const content = extractLevelTwoSection(surveyAuthoringReferences[\"item-types\"].content, heading);\n return content ? { title: `${heading} item type`, content } : undefined;\n};\n"],"x_google_ignoreList":[0],"mappings":";;;;AAIA,MAAM,oBAAoB,cAAc,OAAO,KAAK,IAAI;AACxD,MAAM,mBAAmB,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;CACD;AAID,MAAM,6BAA+D;CACnE,OAAO;CACP,cAAc;CACd,UAAU;CACV,YAAY;CACZ,UAAU;CACX;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;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,66 +0,0 @@
|
|
|
1
|
-
import { G as assistantItemTypeManifestSchema } from "./protocol-DpCYmCjr.mjs";
|
|
2
|
-
import { buildCapabilityDigest } 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
|
-
for (const capability of capabilities) {
|
|
9
|
-
const manifest = assistantItemTypeManifestSchema.parse(capability.manifest);
|
|
10
|
-
const itemType = manifest.itemType;
|
|
11
|
-
if (byItemType.has(itemType)) throw new Error(`Duplicate survey assistant capability for item type "${itemType}".`);
|
|
12
|
-
if (manifest.create === "deterministic" && !manifest.supportedOperations.includes("create-item")) throw new Error(`Deterministically creatable item type "${itemType}" must support "create-item".`);
|
|
13
|
-
const declaredReferenceTopics = new Set(manifest.referenceTopics ?? []);
|
|
14
|
-
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.`);
|
|
15
|
-
byItemType.set(itemType, capability);
|
|
16
|
-
}
|
|
17
|
-
const manifestWithoutDigest = { itemTypes: Array.from(byItemType.values()).map((capability) => capability.manifest).sort((left, right) => left.itemType.localeCompare(right.itemType)) };
|
|
18
|
-
return {
|
|
19
|
-
manifest: {
|
|
20
|
-
...manifestWithoutDigest,
|
|
21
|
-
digest: buildCapabilityDigest(manifestWithoutDigest)
|
|
22
|
-
},
|
|
23
|
-
byItemType
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const getDeterministicCreateItemTypes = (manifest) => manifest.itemTypes.filter((entry) => entry.create === "deterministic").map((entry) => entry.itemType);
|
|
27
|
-
const resolveAssistantItemCreation = ({ itemType, manifest, parentItemId }) => {
|
|
28
|
-
const capability = manifest.itemTypes.find((entry) => entry.itemType === itemType);
|
|
29
|
-
if (capability?.create === "deterministic") return { kind: "deterministic" };
|
|
30
|
-
if (capability?.create === "interactive-only") return {
|
|
31
|
-
kind: "ui-intent",
|
|
32
|
-
intent: {
|
|
33
|
-
kind: "open-create-item",
|
|
34
|
-
itemType,
|
|
35
|
-
parentItemId
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
return {
|
|
39
|
-
kind: "unsupported",
|
|
40
|
-
reason: capability ? `Item type "${itemType}" does not support assistant creation.` : `Item type "${itemType}" is not installed.`
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
const createUnsupportedItemCapability = ({ displayName, itemType }) => ({ manifest: {
|
|
44
|
-
itemType,
|
|
45
|
-
capabilityVersion: "unsupported-v1",
|
|
46
|
-
displayName,
|
|
47
|
-
create: "unsupported",
|
|
48
|
-
supportedOperations: [],
|
|
49
|
-
contentSurfaces: []
|
|
50
|
-
} });
|
|
51
|
-
var SurveyAssistantCapabilityMismatchError = class extends Error {
|
|
52
|
-
code = "survey-assistant-capability-mismatch";
|
|
53
|
-
constructor(message = "Survey assistant capabilities changed; start a fresh turn and retry.") {
|
|
54
|
-
super(message);
|
|
55
|
-
this.name = "SurveyAssistantCapabilityMismatchError";
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const assertSurveyAssistantCapabilities = ({ manifest, trustedCapabilities, versionDigest }) => {
|
|
59
|
-
const { digest: claimedDigest, ...manifestWithoutDigest } = manifest;
|
|
60
|
-
if (claimedDigest !== buildCapabilityDigest(manifestWithoutDigest) || versionDigest !== claimedDigest) throw new SurveyAssistantCapabilityMismatchError();
|
|
61
|
-
if (trustedCapabilities && trustedCapabilities.manifest.digest !== claimedDigest) throw new SurveyAssistantCapabilityMismatchError("The editor and server use different survey assistant capabilities; refresh and retry.");
|
|
62
|
-
};
|
|
63
|
-
//#endregion
|
|
64
|
-
export { getDeterministicCreateItemTypes as a, resolveAssistantItemCreation as c, createUnsupportedItemCapability as i, assertSurveyAssistantCapabilities as n, inspectAssistantItem as o, createSurveyAssistantCapabilities as r, resolveAssistantCapabilityReference as s, SurveyAssistantCapabilityMismatchError as t };
|
|
65
|
-
|
|
66
|
-
//# sourceMappingURL=capabilities-DKbNCnBf.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities-DKbNCnBf.mjs","names":[],"sources":["../src/engine/capabilities.ts"],"sourcesContent":["import type { RawSurveyItem, ValueType } from \"@case-framework/survey-core\";\nimport type {\n AssistantItemTypeManifest,\n JsonValue,\n SurveyAssistantCapabilityManifest,\n SurveyOperation,\n SurveyValidationIssue,\n} from \"../protocol\";\nimport { assistantItemTypeManifestSchema } from \"../protocol\";\nimport { buildCapabilityDigest } from \"../protocol/digest\";\n\nexport interface AssistantCapabilityReference {\n topic: string;\n title?: string;\n markdown: string;\n}\n\nexport interface AssistantItemInspection {\n summary: string;\n details?: JsonValue;\n}\n\nexport interface AssistantItemCapabilityAdapter {\n manifest: AssistantItemTypeManifest;\n references?: AssistantCapabilityReference[];\n normalizeCreate?: (item: RawSurveyItem) => RawSurveyItem;\n validateItem?: (item: RawSurveyItem) => SurveyValidationIssue[];\n supportsOperation?: (operation: SurveyOperation) => boolean;\n deriveResponseSlots?: (item: RawSurveyItem) => Record<string, ValueType>;\n inspectItem?: (item: RawSurveyItem) => AssistantItemInspection;\n}\n\nexport interface SurveyAssistantCapabilitySet {\n manifest: SurveyAssistantCapabilityManifest;\n byItemType: ReadonlyMap<string, AssistantItemCapabilityAdapter>;\n}\n\nexport const resolveAssistantCapabilityReference = ({\n capabilities,\n itemType,\n topic,\n}: {\n capabilities: SurveyAssistantCapabilitySet | undefined;\n itemType: string;\n topic: string;\n}): AssistantCapabilityReference | undefined =>\n capabilities?.byItemType\n .get(itemType)\n ?.references?.find((reference) => reference.topic === topic);\n\nexport const inspectAssistantItem = ({\n capabilities,\n item,\n}: {\n capabilities: SurveyAssistantCapabilitySet | undefined;\n item: RawSurveyItem;\n}): AssistantItemInspection | undefined =>\n capabilities?.byItemType.get(item.itemType)?.inspectItem?.(item);\n\nexport type AssistantItemCreationResolution =\n | { kind: \"deterministic\" }\n | {\n kind: \"ui-intent\";\n intent: { kind: \"open-create-item\"; itemType: string; parentItemId?: string };\n }\n | { kind: \"unsupported\"; reason: string };\n\nexport const createSurveyAssistantCapabilities = (\n capabilities: readonly AssistantItemCapabilityAdapter[],\n): SurveyAssistantCapabilitySet => {\n const byItemType = new Map<string, AssistantItemCapabilityAdapter>();\n\n for (const capability of capabilities) {\n const manifest = assistantItemTypeManifestSchema.parse(capability.manifest);\n const itemType = manifest.itemType;\n if (byItemType.has(itemType)) {\n throw new Error(`Duplicate survey assistant capability for item type \"${itemType}\".`);\n }\n if (\n manifest.create === \"deterministic\" &&\n !manifest.supportedOperations.includes(\"create-item\")\n ) {\n throw new Error(\n `Deterministically creatable item type \"${itemType}\" must support \"create-item\".`,\n );\n }\n const declaredReferenceTopics = new Set(manifest.referenceTopics ?? []);\n for (const reference of capability.references ?? []) {\n if (!declaredReferenceTopics.has(reference.topic)) {\n throw new Error(\n `Capability reference \"${reference.topic}\" for item type \"${itemType}\" is missing from manifest.referenceTopics.`,\n );\n }\n }\n byItemType.set(itemType, capability);\n }\n\n const itemTypes = Array.from(byItemType.values())\n .map((capability) => capability.manifest)\n .sort((left, right) => left.itemType.localeCompare(right.itemType));\n const manifestWithoutDigest = { itemTypes };\n\n return {\n manifest: {\n ...manifestWithoutDigest,\n digest: buildCapabilityDigest(manifestWithoutDigest),\n },\n byItemType,\n };\n};\n\nexport const getDeterministicCreateItemTypes = (\n manifest: SurveyAssistantCapabilityManifest,\n): string[] =>\n manifest.itemTypes\n .filter((entry) => entry.create === \"deterministic\")\n .map((entry) => entry.itemType);\n\nexport const resolveAssistantItemCreation = ({\n itemType,\n manifest,\n parentItemId,\n}: {\n itemType: string;\n manifest: SurveyAssistantCapabilityManifest;\n parentItemId?: string;\n}): AssistantItemCreationResolution => {\n const capability = manifest.itemTypes.find((entry) => entry.itemType === itemType);\n if (capability?.create === \"deterministic\") {\n return { kind: \"deterministic\" };\n }\n if (capability?.create === \"interactive-only\") {\n return {\n kind: \"ui-intent\",\n intent: { kind: \"open-create-item\", itemType, parentItemId },\n };\n }\n return {\n kind: \"unsupported\",\n reason: capability\n ? `Item type \"${itemType}\" does not support assistant creation.`\n : `Item type \"${itemType}\" is not installed.`,\n };\n};\n\nexport const createUnsupportedItemCapability = ({\n displayName,\n itemType,\n}: {\n displayName: string;\n itemType: string;\n}): AssistantItemCapabilityAdapter => ({\n manifest: {\n itemType,\n capabilityVersion: \"unsupported-v1\",\n displayName,\n create: \"unsupported\",\n supportedOperations: [],\n contentSurfaces: [],\n },\n});\n\nexport class SurveyAssistantCapabilityMismatchError extends Error {\n readonly code = \"survey-assistant-capability-mismatch\";\n\n constructor(message = \"Survey assistant capabilities changed; start a fresh turn and retry.\") {\n super(message);\n this.name = \"SurveyAssistantCapabilityMismatchError\";\n }\n}\n\nexport const assertSurveyAssistantCapabilities = ({\n manifest,\n trustedCapabilities,\n versionDigest,\n}: {\n manifest: SurveyAssistantCapabilityManifest;\n trustedCapabilities?: SurveyAssistantCapabilitySet;\n versionDigest: string;\n}): void => {\n const { digest: claimedDigest, ...manifestWithoutDigest } = manifest;\n const computedDigest = buildCapabilityDigest(manifestWithoutDigest);\n if (claimedDigest !== computedDigest || versionDigest !== claimedDigest) {\n throw new SurveyAssistantCapabilityMismatchError();\n }\n\n if (trustedCapabilities && trustedCapabilities.manifest.digest !== claimedDigest) {\n throw new SurveyAssistantCapabilityMismatchError(\n \"The editor and server use different survey assistant capabilities; refresh and retry.\",\n );\n }\n};\n"],"mappings":";;;AAqCA,MAAa,uCAAuC,EAClD,cACA,UACA,YAMA,cAAc,WACX,IAAI,SAAS,EACZ,YAAY,MAAM,cAAc,UAAU,UAAU,MAAM;AAEhE,MAAa,wBAAwB,EACnC,cACA,WAKA,cAAc,WAAW,IAAI,KAAK,SAAS,EAAE,cAAc,KAAK;AAUlE,MAAa,qCACX,iBACiC;CACjC,MAAM,6BAAa,IAAI,KAA6C;AAEpE,MAAK,MAAM,cAAc,cAAc;EACrC,MAAM,WAAW,gCAAgC,MAAM,WAAW,SAAS;EAC3E,MAAM,WAAW,SAAS;AAC1B,MAAI,WAAW,IAAI,SAAS,CAC1B,OAAM,IAAI,MAAM,wDAAwD,SAAS,IAAI;AAEvF,MACE,SAAS,WAAW,mBACpB,CAAC,SAAS,oBAAoB,SAAS,cAAc,CAErD,OAAM,IAAI,MACR,0CAA0C,SAAS,+BACpD;EAEH,MAAM,0BAA0B,IAAI,IAAI,SAAS,mBAAmB,EAAE,CAAC;AACvE,OAAK,MAAM,aAAa,WAAW,cAAc,EAAE,CACjD,KAAI,CAAC,wBAAwB,IAAI,UAAU,MAAM,CAC/C,OAAM,IAAI,MACR,yBAAyB,UAAU,MAAM,mBAAmB,SAAS,6CACtE;AAGL,aAAW,IAAI,UAAU,WAAW;;CAMtC,MAAM,wBAAwB,EAAE,WAHd,MAAM,KAAK,WAAW,QAAQ,CAAC,CAC9C,KAAK,eAAe,WAAW,SAAS,CACxC,MAAM,MAAM,UAAU,KAAK,SAAS,cAAc,MAAM,SAAS,CAC3B,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,uBAAuB,oBAAoB,SAAS,WAAW,cACjE,OAAM,IAAI,uCACR,wFACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities-DlC1l6qy.d.mts","names":[],"sources":["../src/protocol/capabilities.ts"],"mappings":";;;cAGa,6BAAA,EAA6B,CAAA,CAAA,OAAA;;;;;cAM7B,6BAAA,EAA6B,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;cAS7B,2BAAA,EAA2B,CAAA,CAAA,SAAA;;;;cAK3B,4BAAA,EAA4B,CAAA,CAAA,SAAA;;;;cAK5B,+BAAA,EAA+B,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAc/B,uCAAA,EAAuC,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKxC,uBAAA,GAA0B,CAAA,CAAE,KAAA,QAAa,6BAAA;AAAA,KACzC,uBAAA,GAA0B,CAAA,CAAE,KAAA,QAAa,6BAAA;AAAA,KACzC,qBAAA,GAAwB,CAAA,CAAE,KAAA,QAAa,2BAAA;AAAA,KACvC,sBAAA,GAAyB,CAAA,CAAE,KAAA,QAAa,4BAAA;AAAA,KACxC,yBAAA,GAA4B,CAAA,CAAE,KAAA,QAAa,+BAAA;AAAA,KAC3C,iCAAA,GAAoC,CAAA,CAAE,KAAA,QACzC,uCAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants-CgV4cTg5.d.mts","names":[],"sources":["../src/server/request-context.ts","../src/server/constants.ts"],"mappings":";;;;;;UAuBiB,gCAAA;EACf,IAAA;AAAA;AAAA,UAGe,8BAAA;EACf,SAAA;EACA,UAAA;EACA,QAAA;EACA,QAAA;AAAA;AAAA,UAGe,6BAAA;EACf,EAAA;EACA,KAAA;AAAA;AAAA,KAGU,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;AAAA;AAAA,cAGN,4BAAA,GAAgC,KAAA,cAAiB,sBAAA;AAAA,cAQjD,0CAAA,GACX,KAAA,cACC,qBAAA;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;AAAA;EAUjD,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;AAAA,MACf,cAAA,CAAe,6BAAA;AAAA,cAoDN,+BAAA,GACX,cAAA,EAAgB,cAAA,CAAe,6BAAA;;;;;;cCnOpB,yBAAA;AAAA,cACA,8BAAA"}
|