@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.
- package/README.md +58 -3
- package/dist/{attachments-B0hg3vpT.mjs → attachments-BuNni5vB.mjs} +1 -1
- package/dist/{attachments-B0hg3vpT.mjs.map → attachments-BuNni5vB.mjs.map} +1 -1
- package/dist/{authoring-references-BJQ_1nMX.mjs → authoring-references-CmwLc_C8.mjs} +49 -32
- package/dist/authoring-references-CmwLc_C8.mjs.map +1 -0
- package/dist/capabilities-D55dq-fO.mjs +582 -0
- package/dist/capabilities-D55dq-fO.mjs.map +1 -0
- package/dist/capabilities-default.d.mts +5 -12
- package/dist/capabilities-default.d.mts.map +1 -1
- package/dist/capabilities-default.mjs +2 -411
- package/dist/capabilities-z95e1mti.d.mts +117 -0
- package/dist/capabilities-z95e1mti.d.mts.map +1 -0
- package/dist/{constants-0UHGFcRJ.mjs → constants-Ct-vv9cu.mjs} +1 -1
- package/dist/{constants-0UHGFcRJ.mjs.map → constants-Ct-vv9cu.mjs.map} +1 -1
- package/dist/{constants-Be91Gay9.d.mts → constants-HL_klgJl.d.mts} +7 -28
- package/dist/constants-HL_klgJl.d.mts.map +1 -0
- package/dist/{controller-proxy-BH05e-C2.mjs → controller-proxy-BQ1YsVxJ.mjs} +12 -21
- package/dist/controller-proxy-BQ1YsVxJ.mjs.map +1 -0
- package/dist/controller-proxy-Cmzdr9tV.d.mts +65 -0
- package/dist/controller-proxy-Cmzdr9tV.d.mts.map +1 -0
- package/dist/default-D22AKTqE.mjs +233 -0
- package/dist/default-D22AKTqE.mjs.map +1 -0
- package/dist/{digest-SJmoYVaK.d.mts → digest-FnTTDBq2.d.mts} +2 -3
- package/dist/digest-FnTTDBq2.d.mts.map +1 -0
- package/dist/digest.d.mts +1 -1
- package/dist/digest.mjs.map +1 -1
- package/dist/engine-D950TfvC.mjs +3098 -0
- package/dist/engine-D950TfvC.mjs.map +1 -0
- package/dist/engine.d.mts +4 -3
- package/dist/engine.mjs +3 -3
- package/dist/{fair-guidance-CRYCRxQm.mjs → fair-guidance-BmO4PswW.mjs} +1 -1
- package/dist/{fair-guidance-CRYCRxQm.mjs.map → fair-guidance-BmO4PswW.mjs.map} +1 -1
- package/dist/{index-l_EK4yK7.d.mts → index-B8TLBd1G.d.mts} +18 -72
- package/dist/index-B8TLBd1G.d.mts.map +1 -0
- package/dist/index-CaX3hZmr.d.mts +23813 -0
- package/dist/index-CaX3hZmr.d.mts.map +1 -0
- package/dist/{index-x0qprHgK.d.mts → index-CeUlGkoU.d.mts} +58 -28
- package/dist/index-CeUlGkoU.d.mts.map +1 -0
- package/dist/{index-nhrgbgO5.d.mts → index-DYHdvSE8.d.mts} +347 -88
- package/dist/index-DYHdvSE8.d.mts.map +1 -0
- package/dist/lifecycle-DFzxVxpq.d.mts +54346 -0
- package/dist/lifecycle-DFzxVxpq.d.mts.map +1 -0
- package/dist/{memory-thread-repository-KWHQWFEW.mjs → memory-thread-repository-DmLadygY.mjs} +60 -30
- package/dist/memory-thread-repository-DmLadygY.mjs.map +1 -0
- package/dist/protocol-BQ7uIDYT.mjs +569 -0
- package/dist/protocol-BQ7uIDYT.mjs.map +1 -0
- package/dist/protocol.d.mts +4 -4
- package/dist/protocol.mjs +4 -3
- package/dist/{react-B3ybjJ-X.mjs → react-DybJ5pWw.mjs} +159 -46
- package/dist/react-DybJ5pWw.mjs.map +1 -0
- package/dist/react-integration.d.mts +2 -2
- package/dist/react-integration.mjs +2 -2
- package/dist/react.d.mts +3 -3
- package/dist/react.mjs +3 -3
- package/dist/references/assistant-operations.md +224 -180
- package/dist/references/core-rules.md +6 -3
- package/dist/references/element-types.md +189 -0
- package/dist/references/expressions.md +307 -168
- package/dist/references/fair-by-design.md +9 -9
- package/dist/references/follow-ups.md +151 -0
- package/dist/references/localization.md +26 -12
- package/dist/references/response-variables.md +38 -0
- package/dist/references/rich-text-content.md +22 -43
- package/dist/references/source-material-surveys.md +20 -24
- package/dist/references/survey-data-model.md +36 -102
- package/dist/{request-context-CG4SWijt.mjs → request-context-KVh8VjgH.mjs} +4 -10
- package/dist/request-context-KVh8VjgH.mjs.map +1 -0
- package/dist/{request-guardrails-TmgQtqp4.mjs → request-guardrails-C0ugBOp0.mjs} +6 -5
- package/dist/request-guardrails-C0ugBOp0.mjs.map +1 -0
- package/dist/server-agent.d.mts +62 -43
- package/dist/server-agent.d.mts.map +1 -1
- package/dist/server-agent.mjs +73 -40
- package/dist/server-agent.mjs.map +1 -1
- package/dist/server-runtime.d.mts +24 -42
- package/dist/server-runtime.d.mts.map +1 -1
- package/dist/server-runtime.mjs +12 -12
- package/dist/server-runtime.mjs.map +1 -1
- package/dist/server-tasks.d.mts +2 -2
- package/dist/server-tasks.mjs +2 -313
- package/dist/server-tools.d.mts +1 -1
- package/dist/server-tools.mjs +1 -1
- package/dist/server.d.mts +14 -36
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +5 -5
- package/dist/server.mjs.map +1 -1
- package/dist/storage-postgres.d.mts +9 -25
- package/dist/storage-postgres.d.mts.map +1 -1
- package/dist/storage-postgres.mjs +5 -4
- package/dist/storage-postgres.mjs.map +1 -1
- package/dist/tasks-Coh5N027.mjs +397 -0
- package/dist/tasks-Coh5N027.mjs.map +1 -0
- package/dist/{tasks-CYqrcaRO.d.mts → tasks-wb9M-bak.d.mts} +25 -41
- package/dist/tasks-wb9M-bak.d.mts.map +1 -0
- package/dist/thread-documents-DrHbaXqP.d.mts +119 -0
- package/dist/thread-documents-DrHbaXqP.d.mts.map +1 -0
- package/dist/{thread-handlers-DBAaU7BA.d.mts → thread-handlers-C3Iya92v.d.mts} +9 -40
- package/dist/thread-handlers-C3Iya92v.d.mts.map +1 -0
- package/dist/{tools-BvSovehT.mjs → tools-D0KBDolR.mjs} +677 -459
- package/dist/tools-D0KBDolR.mjs.map +1 -0
- package/dist/turn-survey-draft-B34lggSG.d.mts +185 -0
- package/dist/turn-survey-draft-B34lggSG.d.mts.map +1 -0
- package/dist/ui.css +1 -1
- package/dist/ui.d.mts +15 -54
- package/dist/ui.d.mts.map +1 -1
- package/dist/ui.mjs +203 -156
- package/dist/ui.mjs.map +1 -1
- package/docs/integration.md +11 -1
- package/package.json +41 -36
- package/dist/authoring-references-BJQ_1nMX.mjs.map +0 -1
- package/dist/capabilities-1KNnNO1_.mjs +0 -73
- package/dist/capabilities-1KNnNO1_.mjs.map +0 -1
- package/dist/capabilities-DVTfogjv.d.mts +0 -193
- package/dist/capabilities-DVTfogjv.d.mts.map +0 -1
- package/dist/capabilities-default.mjs.map +0 -1
- package/dist/constants-Be91Gay9.d.mts.map +0 -1
- package/dist/controller-proxy-BH05e-C2.mjs.map +0 -1
- package/dist/controller-proxy-Bd0ZHBPF.d.mts +0 -85
- package/dist/controller-proxy-Bd0ZHBPF.d.mts.map +0 -1
- package/dist/digest-SJmoYVaK.d.mts.map +0 -1
- package/dist/engine-Bo85Oyj0.mjs +0 -6723
- package/dist/engine-Bo85Oyj0.mjs.map +0 -1
- package/dist/index-Tnqv-yKW.d.mts +0 -777
- package/dist/index-Tnqv-yKW.d.mts.map +0 -1
- package/dist/index-l_EK4yK7.d.mts.map +0 -1
- package/dist/index-nhrgbgO5.d.mts.map +0 -1
- package/dist/index-x0qprHgK.d.mts.map +0 -1
- package/dist/lifecycle-Bx0aq_4S.d.mts +0 -529
- package/dist/lifecycle-Bx0aq_4S.d.mts.map +0 -1
- package/dist/memory-thread-repository-KWHQWFEW.mjs.map +0 -1
- package/dist/protocol-BhzQbx81.mjs +0 -1173
- package/dist/protocol-BhzQbx81.mjs.map +0 -1
- package/dist/react-B3ybjJ-X.mjs.map +0 -1
- package/dist/references/embedded-forms.md +0 -126
- package/dist/references/item-types.md +0 -407
- package/dist/request-context-CG4SWijt.mjs.map +0 -1
- package/dist/request-guardrails-TmgQtqp4.mjs.map +0 -1
- package/dist/server-tasks.mjs.map +0 -1
- package/dist/tasks-CYqrcaRO.d.mts.map +0 -1
- package/dist/thread-documents-rmd6nyX9.d.mts +0 -107
- package/dist/thread-documents-rmd6nyX9.d.mts.map +0 -1
- package/dist/thread-handlers-DBAaU7BA.d.mts.map +0 -1
- package/dist/tools-BvSovehT.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -59,7 +59,6 @@ import {
|
|
|
59
59
|
import {
|
|
60
60
|
createSurveyAssistantControllerBridge,
|
|
61
61
|
createSurveyAssistantTaskClient,
|
|
62
|
-
createSurveyAssistantTaskExecutor,
|
|
63
62
|
createSurveyAssistantThreadLauncher,
|
|
64
63
|
} from "@case-framework/survey-assistant/react/integration";
|
|
65
64
|
|
|
@@ -106,6 +105,11 @@ stylesheet has no preflight and scopes generated utilities beneath the panel
|
|
|
106
105
|
root. A host can pass a partial localization catalog to extend or override the
|
|
107
106
|
defaults without supplying a complete catalog.
|
|
108
107
|
|
|
108
|
+
Hosts using `/ui` must install `@base-ui/react@^1.8.0` alongside React and
|
|
109
|
+
React DOM. Base UI is an optional peer dependency so server and protocol consumers
|
|
110
|
+
do not need to install it. Use the same Base UI installation for the assistant,
|
|
111
|
+
survey player, editor, and host components.
|
|
112
|
+
|
|
109
113
|
```tsx
|
|
110
114
|
<ConnectedSurveyAssistantPanel
|
|
111
115
|
api="/api/survey-assistant/chat"
|
|
@@ -215,7 +219,7 @@ export const ratingAssistantCapability = {
|
|
|
215
219
|
create: "deterministic",
|
|
216
220
|
supportedOperations: [
|
|
217
221
|
"create-item",
|
|
218
|
-
"update-
|
|
222
|
+
"update-response-settings",
|
|
219
223
|
"update-item-translation",
|
|
220
224
|
"patch-item-config",
|
|
221
225
|
],
|
|
@@ -230,6 +234,19 @@ export const ratingAssistantCapability = {
|
|
|
230
234
|
markdown: "Use min < max and a positive step.",
|
|
231
235
|
},
|
|
232
236
|
],
|
|
237
|
+
// Match the host core's declaration; item identity can seed a new scalar slot.
|
|
238
|
+
normalizeCreate: (item) => ({
|
|
239
|
+
...item,
|
|
240
|
+
config: { responseId: item.id, variableName: "rating", ...item.config },
|
|
241
|
+
}),
|
|
242
|
+
deriveResponseSlotDefinitions: (item) => [
|
|
243
|
+
{
|
|
244
|
+
slotId: item.config.responseId,
|
|
245
|
+
variableName: item.config.variableName,
|
|
246
|
+
valueType: "number",
|
|
247
|
+
naming: { kind: "variable", path: ["variableName"] },
|
|
248
|
+
},
|
|
249
|
+
],
|
|
233
250
|
} satisfies AssistantItemCapabilityAdapter;
|
|
234
251
|
|
|
235
252
|
// rating-entry.tsx (client/editor module)
|
|
@@ -258,7 +275,8 @@ pnpm benchmark:survey-assistant-operations
|
|
|
258
275
|
```
|
|
259
276
|
|
|
260
277
|
`check` typechecks and builds all entries, copies server references, verifies
|
|
261
|
-
their source and built import graphs, and runs unit tests
|
|
278
|
+
their source and built import graphs, and runs typed unit/DOM tests plus the real
|
|
279
|
+
SDK streaming integration tests (with a scripted model, no provider requests). `check:release` also
|
|
262
280
|
builds the clean Next host fixture. `benchmark:survey-assistant-operations`
|
|
263
281
|
uses the current built engine output to profile maximum-size typed validation
|
|
264
282
|
and the raw-patch path against a synthetic 5,002-item survey; run `build` first
|
|
@@ -266,6 +284,31 @@ when source has changed. The optional Postgres entry accepts a host-owned
|
|
|
266
284
|
`PostgresStore` or store configuration; it does not read environment variables,
|
|
267
285
|
create hidden singletons, or own connection shutdown.
|
|
268
286
|
|
|
287
|
+
## Test boundaries
|
|
288
|
+
|
|
289
|
+
- `test` checks fixtures and runs the Vitest source suite. Its tool-constructor mock
|
|
290
|
+
deliberately bypasses SDK validation for handler-level negative inputs; the
|
|
291
|
+
test TypeScript config reflects that mock and keeps schema input/output types.
|
|
292
|
+
The separate production `typecheck` uses the real SDK types.
|
|
293
|
+
- `test:integration` runs built output through native `node:test` with the real Agent, tools, HTTP handler,
|
|
294
|
+
stream adapter, transport, and session hook. Only model responses are scripted.
|
|
295
|
+
Build changed package output first. The editor UI suite also feeds these real
|
|
296
|
+
streamed candidates through its apply/undo boundary in a separate native ESM
|
|
297
|
+
process so source-test aliases and mocks cannot replace the SDKs.
|
|
298
|
+
- `test:postgres` also uses native `node:test` and requires
|
|
299
|
+
`SURVEY_ASSISTANT_TEST_DATABASE_URL`. Use a disposable
|
|
300
|
+
PostgreSQL database: the test creates a unique schema and drops only that schema
|
|
301
|
+
in cleanup. It tests isolation, BYTEA roundtrips, deduplication, and concurrent
|
|
302
|
+
quotas against real PostgreSQL. Missing configuration fails explicitly; this
|
|
303
|
+
opt-in test is not part of the database-free `check` command.
|
|
304
|
+
- Live model evaluations remain opt-in. DOM tests exercise events but do not
|
|
305
|
+
establish browser layout, focus, scrolling, or accessibility acceptance.
|
|
306
|
+
|
|
307
|
+
```sh
|
|
308
|
+
SURVEY_ASSISTANT_TEST_DATABASE_URL=postgresql://localhost/assistant_test \
|
|
309
|
+
pnpm --filter @case-framework/survey-assistant test:postgres
|
|
310
|
+
```
|
|
311
|
+
|
|
269
312
|
## Integration Levels
|
|
270
313
|
|
|
271
314
|
Use the highest level that fits the host; the lower layers remain available for
|
|
@@ -291,3 +334,15 @@ The option does not choose or authorize an identity, and most authenticated
|
|
|
291
334
|
hosts should omit it unless they want that extra deployment switch. See
|
|
292
335
|
[Real-host integration](./docs/integration.md#optional-experimental-identity-rollout-gate)
|
|
293
336
|
for the exact enablement rules.
|
|
337
|
+
|
|
338
|
+
### Response-variable authoring (survey schema version 2)
|
|
339
|
+
|
|
340
|
+
Assistant mutations target exact persistent item IDs. Search exposes resolved editor names and breadcrumbs for discovery; names may repeat. Response-slot declarations from the shared item packages provide persistent IDs, coding names, domains, matrix ownership and computed dependencies. Expressions serialize references as `{slotId, method: "get" | "isDefined"}`.
|
|
341
|
+
|
|
342
|
+
Use `update-response-settings` with `naming` and `settings` arrays for atomic scalar names, matrix naming components, option export codes and export defaults. Shared core previews validate names, derived families and projected headers; editor application remains a single normal undoable transaction. The built-in registry supports consent, choice and form matrices alongside scalar and embedded forms.
|
|
343
|
+
|
|
344
|
+
One-shot tasks are `suggest-response-name` (a scalar `itemId` and `slotId`) and `suggest-response-settings` (`slotIds` and a naming category). Response Settings offers selected-variable or filtered-visible-variable suggestions, validates a before/after preview, and applies only on user action. Categories are `fair`, `survey-pattern`, `compact`, and `preferred`. All obey the same naming syntax; FAIR guidance is a project convention, not a certification.
|
|
345
|
+
|
|
346
|
+
Custom capabilities with conditional components, projected answers or computed behavior need a trusted server-safe `itemCore` constructor shared with the player for complete proposal-time validation. Without it, the assistant cannot inspect those activation dependencies and may propose a change that the editor rejects at apply; no partial change is applied, but the model cannot repair that failure within the original turn. Standard form, choice, consent and matrix items already use shared headless cores.
|
|
347
|
+
|
|
348
|
+
Slot-only capabilities can use `deriveResponseSlotDefinitions`; creatable custom response capabilities must expose full slot definitions through one of these contracts, including persistent slot IDs, separate variable names, and naming paths and categorical domains where supported. The type-only `deriveResponseSlots` adapter is insufficient for creation under the current schema; it remains an inspection-only adapter. Pass the same capability set to `buildSurveyAssistantTaskContext`, or the editor AI provider/integration's optional `capabilities`, for custom-variable tasks. The server must continue to supply trusted capabilities independently of browser data.
|
|
@@ -8,4 +8,4 @@ const isSurveyAssistantAttachmentMediaType = (mediaType) => SURVEY_ASSISTANT_ATT
|
|
|
8
8
|
//#endregion
|
|
9
9
|
export { isSurveyAssistantAttachmentMediaType as n, SURVEY_ASSISTANT_ATTACHMENT_MEDIA_TYPES as t };
|
|
10
10
|
|
|
11
|
-
//# sourceMappingURL=attachments-
|
|
11
|
+
//# sourceMappingURL=attachments-BuNni5vB.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachments-
|
|
1
|
+
{"version":3,"file":"attachments-BuNni5vB.mjs","names":[],"sources":["../src/protocol/attachments.ts"],"sourcesContent":["export const SURVEY_ASSISTANT_ATTACHMENT_MEDIA_TYPES = [\n \"application/pdf\",\n \"image/png\",\n \"image/jpeg\",\n] as const;\n\nexport type SurveyAssistantAttachmentMediaType =\n (typeof SURVEY_ASSISTANT_ATTACHMENT_MEDIA_TYPES)[number];\n\nexport const isSurveyAssistantAttachmentMediaType = (\n mediaType: string,\n): mediaType is SurveyAssistantAttachmentMediaType =>\n (SURVEY_ASSISTANT_ATTACHMENT_MEDIA_TYPES as readonly string[]).includes(mediaType.toLowerCase());\n"],"mappings":";AAAA,MAAa,0CAA0C;CACrD;CACA;CACA;AACF;AAKA,MAAa,wCACX,cAEC,wCAA8D,SAAS,UAAU,YAAY,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path, { resolve } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
|
-
//#region ../../node_modules/.pnpm/tsdown@0.
|
|
4
|
+
//#region ../../node_modules/.pnpm/tsdown@0.23.0_@volar+typescript@2.4.28_typescript@6.0.3__typescript@6.0.3_unrun@0.2.39/node_modules/tsdown/esm-shims.js
|
|
5
5
|
const getFilename = () => fileURLToPath(import.meta.url);
|
|
6
6
|
const getDirname = () => path.dirname(getFilename());
|
|
7
7
|
const __dirname = /* @__PURE__ */ getDirname();
|
|
@@ -11,29 +11,38 @@ const loadReference = (fileName) => readFileSync(resolve(__dirname, "references"
|
|
|
11
11
|
const surveyAuthoringReferenceTopics = [
|
|
12
12
|
"core-rules",
|
|
13
13
|
"survey-data-model",
|
|
14
|
+
"response-variables",
|
|
14
15
|
"source-material-surveys",
|
|
15
16
|
"localization",
|
|
16
17
|
"rich-text-content",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
18
|
+
"element-types",
|
|
19
|
+
"follow-ups",
|
|
19
20
|
"expressions",
|
|
20
21
|
"assistant-operations",
|
|
21
22
|
"fair-by-design",
|
|
22
23
|
"survey-quality"
|
|
23
24
|
];
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const ELEMENT_TYPE_SECTION_HEADINGS = {
|
|
26
|
+
information: "information",
|
|
27
|
+
text: "text",
|
|
28
|
+
number: "number",
|
|
29
|
+
date: "date",
|
|
30
|
+
boolean: "boolean",
|
|
31
|
+
choice: "choice",
|
|
32
|
+
consent: "consent",
|
|
33
|
+
choiceMatrix: "choiceMatrix",
|
|
34
|
+
formMatrix: "formMatrix"
|
|
30
35
|
};
|
|
31
|
-
const
|
|
32
|
-
const
|
|
36
|
+
const builtInSurveyAuthoringElementTypes = Object.freeze(Object.keys(ELEMENT_TYPE_SECTION_HEADINGS));
|
|
37
|
+
const extractSection = (markdown, heading, level = 2) => {
|
|
33
38
|
const lines = markdown.split("\n");
|
|
34
|
-
const
|
|
39
|
+
const prefix = "#".repeat(level);
|
|
40
|
+
const sectionStart = lines.findIndex((line) => line.trim() === `${prefix} ${heading}`);
|
|
35
41
|
if (sectionStart < 0) return;
|
|
36
|
-
const nextSectionOffset = lines.slice(sectionStart + 1).findIndex((line) =>
|
|
42
|
+
const nextSectionOffset = lines.slice(sectionStart + 1).findIndex((line) => {
|
|
43
|
+
const match = /^(#+) /.exec(line);
|
|
44
|
+
return match !== null && match[1].length <= level;
|
|
45
|
+
});
|
|
37
46
|
const sectionEnd = nextSectionOffset < 0 ? lines.length : sectionStart + 1 + nextSectionOffset;
|
|
38
47
|
return lines.slice(sectionStart, sectionEnd).join("\n").trim();
|
|
39
48
|
};
|
|
@@ -43,6 +52,11 @@ const surveyAuthoringReferences = {
|
|
|
43
52
|
content: loadReference("core-rules.md"),
|
|
44
53
|
loadWhen: "Load when the task depends on canonical tool choice, validation/apply semantics, identifier handling, or another cross-cutting authoring rule that the current turn has not already established."
|
|
45
54
|
},
|
|
55
|
+
"response-variables": {
|
|
56
|
+
title: "Response variables and coding",
|
|
57
|
+
content: loadReference("response-variables.md"),
|
|
58
|
+
loadWhen: "Load before creating response inputs, changing variable names, option codes, matrix coding components, or export settings. Inspect current response slots for exact IDs and domains."
|
|
59
|
+
},
|
|
46
60
|
"survey-data-model": {
|
|
47
61
|
title: "Survey data model",
|
|
48
62
|
content: loadReference("survey-data-model.md"),
|
|
@@ -63,15 +77,15 @@ const surveyAuthoringReferences = {
|
|
|
63
77
|
content: loadReference("rich-text-content.md"),
|
|
64
78
|
loadWhen: "Load before authoring or changing meaningful formatting, links, images, headings, lists, info boxes, separators, footnotes, or existing structured rich-text content; do not load it for ordinary unformatted plain text."
|
|
65
79
|
},
|
|
66
|
-
"
|
|
67
|
-
title: "
|
|
68
|
-
content: loadReference("
|
|
69
|
-
loadWhen: "Load with
|
|
80
|
+
"element-types": {
|
|
81
|
+
title: "Element types",
|
|
82
|
+
content: loadReference("element-types.md"),
|
|
83
|
+
loadWhen: "Load with elementType 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 elementType only for a genuine cross-type comparison."
|
|
70
84
|
},
|
|
71
|
-
"
|
|
72
|
-
title: "
|
|
73
|
-
content: loadReference("
|
|
74
|
-
loadWhen: "Load before creating or changing a choice-option follow-up
|
|
85
|
+
"follow-ups": {
|
|
86
|
+
title: "Option-inline follow-ups",
|
|
87
|
+
content: loadReference("follow-ups.md"),
|
|
88
|
+
loadWhen: "Load before creating or changing a choice-option follow-up, including \"Other, specify\", option-specific inputs, semantic sections, layout and owner-role translations."
|
|
75
89
|
},
|
|
76
90
|
expressions: {
|
|
77
91
|
title: "Expressions",
|
|
@@ -81,7 +95,7 @@ const surveyAuthoringReferences = {
|
|
|
81
95
|
"assistant-operations": {
|
|
82
96
|
title: "Assistant operations",
|
|
83
97
|
content: loadReference("assistant-operations.md"),
|
|
84
|
-
loadWhen: "Load with operationKind before the first survey_change call when the exact canonical fields of that operation are not already present in the current turn; add
|
|
98
|
+
loadWhen: "Load with operationKind before the first survey_change call when the exact canonical fields of that operation are not already present in the current turn; add elementType when item-specific configuration or capability guidance is needed. Prefer compact detail and use full only for protocol debugging."
|
|
85
99
|
},
|
|
86
100
|
"fair-by-design": {
|
|
87
101
|
title: "FAIR-by-design survey authoring",
|
|
@@ -97,19 +111,22 @@ const surveyAuthoringReferences = {
|
|
|
97
111
|
const formatSurveyAuthoringReferenceRoutingInstructions = () => [
|
|
98
112
|
"Authoring-reference routing rules:",
|
|
99
113
|
"Load a relevant focused reference before the first affected mutation or substantive advice, not after guessing a payload or learning through validator failures. Do not reload a reference when its exact relevant contract is already present in the current turn. References define stable authoring conventions and payload grammar; current survey state and currently available runtime references still come from inspection and context tools.",
|
|
100
|
-
"For installed capability-specific references, use the capability manifest's advertised reference topics. Load a relevant topic with
|
|
114
|
+
"For installed capability-specific references, use the capability manifest's advertised reference topics. Load a relevant topic with elementType before changing unfamiliar capability configuration or behavior.",
|
|
101
115
|
...surveyAuthoringReferenceTopics.map((topic) => `- ${topic}: ${surveyAuthoringReferences[topic].loadWhen}`)
|
|
102
116
|
].join("\n");
|
|
103
|
-
const
|
|
104
|
-
const heading =
|
|
117
|
+
const getBuiltInElementTypeAuthoringReference = (elementType) => {
|
|
118
|
+
const heading = ELEMENT_TYPE_SECTION_HEADINGS[elementType];
|
|
105
119
|
if (!heading) return;
|
|
106
|
-
const content =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
const content = extractSection(surveyAuthoringReferences["element-types"].content, heading);
|
|
121
|
+
if (!content) return void 0;
|
|
122
|
+
const exampleHeading = elementType === "choice" ? "Full worked example: a single-choice question" : elementType === "text" || elementType === "number" ? "Full worked example: a composed question with two inputs" : void 0;
|
|
123
|
+
const example = exampleHeading ? extractSection(surveyAuthoringReferences["assistant-operations"].content, exampleHeading, 3) : void 0;
|
|
124
|
+
return {
|
|
125
|
+
title: `${heading} element type`,
|
|
126
|
+
content: example ? `${content}\n\n${example}` : content
|
|
127
|
+
};
|
|
111
128
|
};
|
|
112
129
|
//#endregion
|
|
113
|
-
export { surveyAuthoringReferences as a, surveyAuthoringReferenceTopics as i, formatSurveyAuthoringReferenceRoutingInstructions as n,
|
|
130
|
+
export { surveyAuthoringReferences as a, surveyAuthoringReferenceTopics as i, formatSurveyAuthoringReferenceRoutingInstructions as n, getBuiltInElementTypeAuthoringReference as r, builtInSurveyAuthoringElementTypes as t };
|
|
114
131
|
|
|
115
|
-
//# sourceMappingURL=authoring-references-
|
|
132
|
+
//# sourceMappingURL=authoring-references-CmwLc_C8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring-references-CmwLc_C8.mjs","names":[],"sources":["../../../node_modules/.pnpm/tsdown@0.23.0_@volar+typescript@2.4.28_typescript@6.0.3__typescript@6.0.3_unrun@0.2.39/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 \"response-variables\",\n \"source-material-surveys\",\n \"localization\",\n \"rich-text-content\",\n \"element-types\",\n \"follow-ups\",\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 ELEMENT_TYPE_SECTION_HEADINGS: Readonly<Record<string, string>> = {\n information: \"information\",\n text: \"text\",\n number: \"number\",\n date: \"date\",\n boolean: \"boolean\",\n choice: \"choice\",\n consent: \"consent\",\n choiceMatrix: \"choiceMatrix\",\n formMatrix: \"formMatrix\",\n};\n\nexport const builtInSurveyAuthoringElementTypes = Object.freeze(\n Object.keys(ELEMENT_TYPE_SECTION_HEADINGS),\n);\n\nconst extractSection = (markdown: string, heading: string, level = 2): string | undefined => {\n const lines = markdown.split(\"\\n\");\n const prefix = \"#\".repeat(level);\n const sectionStart = lines.findIndex((line) => line.trim() === `${prefix} ${heading}`);\n if (sectionStart < 0) {\n return undefined;\n }\n\n const nextSectionOffset = lines.slice(sectionStart + 1).findIndex((line) => {\n const match = /^(#+) /.exec(line);\n return match !== null && match[1].length <= level;\n });\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 \"response-variables\": {\n title: \"Response variables and coding\",\n content: loadReference(\"response-variables.md\"),\n loadWhen:\n \"Load before creating response inputs, changing variable names, option codes, matrix coding components, or export settings. Inspect current response slots for exact IDs and domains.\",\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 \"element-types\": {\n title: \"Element types\",\n content: loadReference(\"element-types.md\"),\n loadWhen:\n \"Load with elementType 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 elementType only for a genuine cross-type comparison.\",\n },\n \"follow-ups\": {\n title: \"Option-inline follow-ups\",\n content: loadReference(\"follow-ups.md\"),\n loadWhen:\n 'Load before creating or changing a choice-option follow-up, including \"Other, specify\", option-specific inputs, semantic sections, layout and owner-role 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 elementType 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 elementType before changing unfamiliar capability configuration or behavior.\",\n ...surveyAuthoringReferenceTopics.map(\n (topic) => `- ${topic}: ${surveyAuthoringReferences[topic].loadWhen}`,\n ),\n ].join(\"\\n\");\n\nexport const getBuiltInElementTypeAuthoringReference = (\n elementType: string,\n): { title: string; content: string } | undefined => {\n const heading = ELEMENT_TYPE_SECTION_HEADINGS[elementType];\n if (!heading) {\n return undefined;\n }\n\n const content = extractSection(surveyAuthoringReferences[\"element-types\"].content, heading);\n if (!content) return undefined;\n // Keep executable examples in one source while retaining them in focused lookups.\n // Most authoring turns deliberately never load the full operations catalog.\n const exampleHeading =\n elementType === \"choice\"\n ? \"Full worked example: a single-choice question\"\n : elementType === \"text\" || elementType === \"number\"\n ? \"Full worked example: a composed question with two inputs\"\n : undefined;\n const example = exampleHeading\n ? extractSection(surveyAuthoringReferences[\"assistant-operations\"].content, exampleHeading, 3)\n : undefined;\n return {\n title: `${heading} element type`,\n content: example ? `${content}\\n\\n${example}` : content,\n };\n};\n"],"x_google_ignoreList":[0],"mappings":"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"}
|