@case-framework/survey-assistant 0.1.1 → 0.2.1

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 (72) hide show
  1. package/README.md +2 -2
  2. package/dist/{capabilities-DZ0a_o2y.mjs → capabilities-DKbNCnBf.mjs} +2 -2
  3. package/dist/{capabilities-DZ0a_o2y.mjs.map → capabilities-DKbNCnBf.mjs.map} +1 -1
  4. package/dist/capabilities-default.d.mts +1 -1
  5. package/dist/capabilities-default.mjs +1 -1
  6. package/dist/{constants-56jf_4ls.d.mts → constants-CgV4cTg5.d.mts} +7 -7
  7. package/dist/constants-CgV4cTg5.d.mts.map +1 -0
  8. package/dist/{controller-proxy-ClsY4lFI.mjs → controller-proxy-0WJZUZYx.mjs} +2 -2
  9. package/dist/{controller-proxy-ClsY4lFI.mjs.map → controller-proxy-0WJZUZYx.mjs.map} +1 -1
  10. package/dist/{controller-proxy-2VH0b_5E.d.mts → controller-proxy-BzpEOygv.d.mts} +2 -2
  11. package/dist/{controller-proxy-2VH0b_5E.d.mts.map → controller-proxy-BzpEOygv.d.mts.map} +1 -1
  12. package/dist/{engine-DQrCO_ur.mjs → engine-0AJrv0hI.mjs} +543 -76
  13. package/dist/engine-0AJrv0hI.mjs.map +1 -0
  14. package/dist/engine.d.mts +2 -2
  15. package/dist/engine.mjs +3 -3
  16. package/dist/{index-C_x686M7.d.mts → index-BNdvGEaq.d.mts} +3 -3
  17. package/dist/{index-C_x686M7.d.mts.map → index-BNdvGEaq.d.mts.map} +1 -1
  18. package/dist/{index-B_x2IYi7.d.mts → index-BUF-sE8j.d.mts} +1 -10
  19. package/dist/index-BUF-sE8j.d.mts.map +1 -0
  20. package/dist/{index-DZ6KBwVR.d.mts → index-BdXb6jER.d.mts} +45 -14
  21. package/dist/index-BdXb6jER.d.mts.map +1 -0
  22. package/dist/{index-DVxVyhAu.d.mts → index-BiTT71Xp.d.mts} +1 -9
  23. package/dist/{index-DVxVyhAu.d.mts.map → index-BiTT71Xp.d.mts.map} +1 -1
  24. package/dist/{memory-thread-repository-Cm1BJyRw.mjs → memory-thread-repository-1ocPOda8.mjs} +17 -17
  25. package/dist/memory-thread-repository-1ocPOda8.mjs.map +1 -0
  26. package/dist/{protocol-7EEgcYja.mjs → protocol-DpCYmCjr.mjs} +1 -8
  27. package/dist/{protocol-7EEgcYja.mjs.map → protocol-DpCYmCjr.mjs.map} +1 -1
  28. package/dist/protocol.d.mts +1 -1
  29. package/dist/protocol.mjs +1 -1
  30. package/dist/{react-B_5smfiK.mjs → react-DXK5zWNo.mjs} +3 -3
  31. package/dist/{react-B_5smfiK.mjs.map → react-DXK5zWNo.mjs.map} +1 -1
  32. package/dist/react-integration.d.mts +1 -1
  33. package/dist/react-integration.mjs +1 -1
  34. package/dist/react.d.mts +2 -2
  35. package/dist/react.mjs +2 -2
  36. package/dist/references/assistant-operations.md +9 -14
  37. package/dist/references/localization.md +2 -0
  38. package/dist/references/source-material-surveys.md +1 -1
  39. package/dist/{request-context-BDBw4-Gw.mjs → request-context-BBzU3VdG.mjs} +17 -10
  40. package/dist/request-context-BBzU3VdG.mjs.map +1 -0
  41. package/dist/server-agent.d.mts +2 -10
  42. package/dist/server-agent.mjs +13 -13
  43. package/dist/server-agent.mjs.map +1 -1
  44. package/dist/server-runtime.d.mts +4 -4
  45. package/dist/server-runtime.mjs +2 -2
  46. package/dist/server-tasks.d.mts +1 -1
  47. package/dist/server-tasks.mjs +1 -1
  48. package/dist/server-tools.d.mts +1 -1
  49. package/dist/server-tools.mjs +1 -1
  50. package/dist/server.d.mts +6 -6
  51. package/dist/server.d.mts.map +1 -1
  52. package/dist/server.mjs +2 -2
  53. package/dist/{tasks-COQnhSeT.d.mts → tasks-BuLnWrR4.d.mts} +3 -3
  54. package/dist/{tasks-COQnhSeT.d.mts.map → tasks-BuLnWrR4.d.mts.map} +1 -1
  55. package/dist/thread-documents-BlxNjc7S.d.mts.map +1 -1
  56. package/dist/{thread-handlers-l79JBl5m.d.mts → thread-handlers-6L8sAreR.d.mts} +3 -3
  57. package/dist/{thread-handlers-l79JBl5m.d.mts.map → thread-handlers-6L8sAreR.d.mts.map} +1 -1
  58. package/dist/{tools-DDXaJ8Za.mjs → tools-wgLen05n.mjs} +97 -103
  59. package/dist/tools-wgLen05n.mjs.map +1 -0
  60. package/dist/ui.css +1 -1
  61. package/dist/ui.d.mts +3 -3
  62. package/dist/ui.d.mts.map +1 -1
  63. package/dist/ui.mjs +36 -6
  64. package/dist/ui.mjs.map +1 -1
  65. package/package.json +3 -3
  66. package/dist/constants-56jf_4ls.d.mts.map +0 -1
  67. package/dist/engine-DQrCO_ur.mjs.map +0 -1
  68. package/dist/index-B_x2IYi7.d.mts.map +0 -1
  69. package/dist/index-DZ6KBwVR.d.mts.map +0 -1
  70. package/dist/memory-thread-repository-Cm1BJyRw.mjs.map +0 -1
  71. package/dist/request-context-BDBw4-Gw.mjs.map +0 -1
  72. package/dist/tools-DDXaJ8Za.mjs.map +0 -1
package/README.md CHANGED
@@ -183,7 +183,7 @@ plus the narrow browser-safe `survey-core/editor/colors` runtime dependency;
183
183
  `/engine` may use the full `survey-core` API. `/server` is
184
184
  server-only and may import Mastra, AI SDK, and Node APIs, but never React,
185
185
  Next.js, or `survey-ui`. The separate server entries prevent handler-only
186
- consumers from eagerly loading Agent/Memory code. `@case-framework/survey-ui`
186
+ consumers from eagerly loading Agent/Memory code. `@case-framework/survey-editor-ui`
187
187
  owns the optional live-editor bridge, snapshot/apply functions, and snapshot-backed
188
188
  one-shot provider because those functions must operate on its editor instance
189
189
  and item registry. The assistant package supplies the standard task Web handler
@@ -224,7 +224,7 @@ export const ratingAssistantCapability = {
224
224
  } satisfies AssistantItemCapabilityAdapter;
225
225
 
226
226
  // rating-entry.tsx (client/editor module)
227
- import type { ItemRegistryEntry } from "@case-framework/survey-ui";
227
+ import type { ItemRegistryEntry } from "@case-framework/survey-editor-ui";
228
228
 
229
229
  export const ratingQuestionEntry = {
230
230
  itemType: "ratingQuestion",
@@ -1,4 +1,4 @@
1
- import { G as assistantItemTypeManifestSchema } from "./protocol-7EEgcYja.mjs";
1
+ import { G as assistantItemTypeManifestSchema } from "./protocol-DpCYmCjr.mjs";
2
2
  import { buildCapabilityDigest } from "./digest.mjs";
3
3
  //#region src/engine/capabilities.ts
4
4
  const resolveAssistantCapabilityReference = ({ capabilities, itemType, topic }) => capabilities?.byItemType.get(itemType)?.references?.find((reference) => reference.topic === topic);
@@ -63,4 +63,4 @@ const assertSurveyAssistantCapabilities = ({ manifest, trustedCapabilities, vers
63
63
  //#endregion
64
64
  export { getDeterministicCreateItemTypes as a, resolveAssistantItemCreation as c, createUnsupportedItemCapability as i, assertSurveyAssistantCapabilities as n, inspectAssistantItem as o, createSurveyAssistantCapabilities as r, resolveAssistantCapabilityReference as s, SurveyAssistantCapabilityMismatchError as t };
65
65
 
66
- //# sourceMappingURL=capabilities-DZ0a_o2y.mjs.map
66
+ //# sourceMappingURL=capabilities-DKbNCnBf.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities-DZ0a_o2y.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
+ {"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,C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AAI,wCAAwC;AAGpD,KAAI,uBAAuB,oBAAoB,SAAS,WAAW,cACjE,OAAM,IAAI,uCACR,wFACD"}
@@ -1,4 +1,4 @@
1
- import { Ft as SurveyAssistantCapabilitySet, jt as AssistantItemCapabilityAdapter } from "./index-DZ6KBwVR.mjs";
1
+ import { Nt as SurveyAssistantCapabilitySet, kt as AssistantItemCapabilityAdapter } from "./index-BdXb6jER.mjs";
2
2
 
3
3
  //#region src/capabilities/default.d.ts
4
4
  declare const rootItemAssistantCapability: AssistantItemCapabilityAdapter;
@@ -1,4 +1,4 @@
1
- import { r as createSurveyAssistantCapabilities } from "./capabilities-DZ0a_o2y.mjs";
1
+ import { r as createSurveyAssistantCapabilities } from "./capabilities-DKbNCnBf.mjs";
2
2
  import { ValueType } from "@case-framework/survey-core";
3
3
  //#region src/capabilities/default.ts
4
4
  const COMMON_OPERATIONS = [
@@ -1,5 +1,5 @@
1
- import { dn as SurveyDocumentVersion, un as SurveyDocumentSnapshot } from "./index-DVxVyhAu.mjs";
2
- import { Ft as SurveyAssistantCapabilitySet, g as TurnChangeCollector, xt as SurveyAssistantEngineContext } from "./index-DZ6KBwVR.mjs";
1
+ import { dn as SurveyDocumentVersion, un as SurveyDocumentSnapshot } from "./index-BiTT71Xp.mjs";
2
+ import { Nt as SurveyAssistantCapabilitySet, f as TurnSurveyDraft, yt as SurveyAssistantEngineContext } from "./index-BdXb6jER.mjs";
3
3
  import { n as SurveyAssistantModelAttachment, t as SurveyAssistantAttachmentAccess } from "./thread-documents-BlxNjc7S.mjs";
4
4
  import { RequestContext } from "@mastra/core/request-context";
5
5
 
@@ -39,7 +39,7 @@ type SurveyAssistantDocumentTransition = {
39
39
  interface SurveyAssistantRequestContext {
40
40
  invocation: SurveyAssistantInvocationContext;
41
41
  turnId: string;
42
- changeCollector: TurnChangeCollector;
42
+ turnDraft: TurnSurveyDraft;
43
43
  identity: SurveyAssistantIdentityContext;
44
44
  authenticatedResourceId?: string;
45
45
  authorizedThreadId?: string;
@@ -63,7 +63,7 @@ declare const deriveSurveyAssistantDocumentTransition: ({
63
63
  previous: SurveyDocumentVersion | null;
64
64
  }) => SurveyAssistantDocumentTransition | undefined;
65
65
  declare const buildSurveyAssistantRequestContext: ({
66
- changeCollector,
66
+ turnDraft,
67
67
  identity,
68
68
  snapshot,
69
69
  previousSettledVersion,
@@ -72,7 +72,7 @@ declare const buildSurveyAssistantRequestContext: ({
72
72
  modelAttachments,
73
73
  modelSelection
74
74
  }: {
75
- changeCollector: TurnChangeCollector;
75
+ turnDraft: TurnSurveyDraft;
76
76
  identity: SurveyAssistantIdentityContext;
77
77
  snapshot: SurveyDocumentSnapshot | null;
78
78
  previousSettledVersion?: SurveyDocumentVersion | null;
@@ -83,7 +83,7 @@ declare const buildSurveyAssistantRequestContext: ({
83
83
  }) => RequestContext<SurveyAssistantRequestContext>;
84
84
  declare const requireSurveyAssistantTurnState: (requestContext: RequestContext<SurveyAssistantRequestContext> | undefined) => {
85
85
  turnId: string;
86
- changeCollector: TurnChangeCollector;
86
+ turnDraft: TurnSurveyDraft;
87
87
  };
88
88
  //#endregion
89
89
  //#region src/server/constants.d.ts
@@ -91,4 +91,4 @@ declare const SURVEY_ASSISTANT_AGENT_ID = "survey-assistant-agent";
91
91
  declare const SURVEY_ASSISTANT_TASK_AGENT_ID = "survey-assistant-task-agent";
92
92
  //#endregion
93
93
  export { SurveyAssistantModelSelection as a, deriveSurveyAssistantDocumentTransition as c, requireSurveyAssistantTurnState as d, SurveyAssistantIdentityContext as i, parseSurveyAssistantPreviousSettledVersion as l, SURVEY_ASSISTANT_TASK_AGENT_ID as n, SurveyAssistantRequestContext as o, SurveyAssistantDocumentTransition as r, buildSurveyAssistantRequestContext as s, SURVEY_ASSISTANT_AGENT_ID as t, parseSurveyAssistantSnapshot as u };
94
- //# sourceMappingURL=constants-56jf_4ls.d.mts.map
94
+ //# sourceMappingURL=constants-CgV4cTg5.d.mts.map
@@ -0,0 +1 @@
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"}
@@ -1,4 +1,4 @@
1
- import { E as surveyAssistantTranslateContentResultSchema, g as surveyAssistantSuggestItemKeyResultSchema, kt as parseSurveyAssistantError, v as surveyAssistantSuggestItemLabelResultSchema } from "./protocol-7EEgcYja.mjs";
1
+ import { E as surveyAssistantTranslateContentResultSchema, g as surveyAssistantSuggestItemKeyResultSchema, kt as parseSurveyAssistantError, v as surveyAssistantSuggestItemLabelResultSchema } from "./protocol-DpCYmCjr.mjs";
2
2
  //#region src/react/client-error.ts
3
3
  var SurveyAssistantClientError = class extends Error {
4
4
  code;
@@ -158,4 +158,4 @@ const createSurveyAssistantControllerBridge = (options) => {
158
158
  //#endregion
159
159
  export { applySurveyAssistantLaunchUIContext as a, SurveyAssistantClientError as c, createSurveyAssistantTaskExecutor as i, readSurveyAssistantJson as l, createSurveyAssistantControllerProxy as n, connectSurveyAssistantThreadLauncher as o, createSurveyAssistantTaskClient as r, createSurveyAssistantThreadLauncher as s, createSurveyAssistantControllerBridge as t };
160
160
 
161
- //# sourceMappingURL=controller-proxy-ClsY4lFI.mjs.map
161
+ //# sourceMappingURL=controller-proxy-0WJZUZYx.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"controller-proxy-ClsY4lFI.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\n constructor(code: SurveyAssistantErrorCode, message: string) {\n super(message);\n this.name = \"SurveyAssistantClientError\";\n this.code = code;\n }\n}\n\nexport const readSurveyAssistantJson = async (\n response: Response,\n fallback = \"The assistant request could not be completed.\",\n) => {\n const body = await response.json().catch(() => ({}));\n if (!response.ok) {\n const detail = typeof body?.error === \"string\" ? body.error : fallback;\n const parsed = parseSurveyAssistantError(\n typeof body?.code === \"string\" ? { code: body.code, detail } : detail,\n );\n throw new SurveyAssistantClientError(parsed.code, parsed.detail ?? detail);\n }\n return body;\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 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.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),\n setController(controller) {\n currentController = controller;\n },\n };\n};\n"],"mappings":";;AAEA,IAAa,6BAAb,cAAgD,MAAM;CACpD;CAEA,YAAY,MAAgC,SAAiB;AAC3D,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;;;AAIhB,MAAa,0BAA0B,OACrC,UACA,WAAW,oDACR;CACH,MAAM,OAAO,MAAM,SAAS,MAAM,CAAC,aAAa,EAAE,EAAE;AACpD,KAAI,CAAC,SAAS,IAAI;EA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MACjD,MAAM,IAAI,qBAAqB,OAAO,SAAS,QAAQ,CACxD;;EAEJ;;AAGH,MAAa,qCACX,UAA4C,EAAE,KACd;CAChC,MAAM,SAAS,gCAAgC,QAAQ;CACvD,MAAM,oBACJ,SACA,WACyC;EACzC,MAAM,SAAS;EACf,SAAS,OAAO;EAChB,QAAQ,SAAS;EAClB;AAED,QAAO;EACL,iBAAiB,OAAO,SAAS,SAAS,UACxC,OAAO,eAAe,OAAO,SAAS,iBAAiB,SAAS,MAAM,CAAC;EACzE,mBAAmB,OAAO,SAAS,SAAS,UAC1C,OAAO,iBAAiB,OAAO,SAAS,iBAAiB,SAAS,MAAM,CAAC;EAC3E,mBAAmB,OAAO,SAAS,SAAS,UAC1C,OAAO,iBAAiB,OAAO,SAAS,iBAAiB,SAAS,MAAM,CAAC;EAC5E;;;;ACvIH,MAAM,gBAAgB,QAAyB,aAAwC;CACrF,QAAQ;CACR,UAAU,OAAO;CACjB,SAAS,OAAO;CAChB;CACA,mBAAmB;CACpB;AAED,MAAa,wCACX,eACA,EACE,kBAAkB,sCAC6B,EAAE,MACpB;CAC/B,mBAAmB,eAAe,EAAE,aAAa,IAAI;CACrD,uBAAuB,WACrB,eAAe,EAAE,uBAAuB,OAAO,IAAI,aAAa,QAAQ,gBAAgB;CAC1F,wBAAwB,YACtB,eAAe,EAAE,wBAAwB,QAAQ,IAAI,EACnD,SAAS,QAAQ,KAAK,WAAW,aAAa,QAAQ,gBAAgB,CAAC,EACxE;CACJ;AAED,MAAa,yCACX,YACoC;CACpC,IAAI;AACJ,QAAO;EACL,YAAY,2CAA2C,mBAAmB,QAAQ;EAClF,cAAc,YAAY;AACxB,uBAAoB;;EAEvB"}
1
+ {"version":3,"file":"controller-proxy-0WJZUZYx.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\n constructor(code: SurveyAssistantErrorCode, message: string) {\n super(message);\n this.name = \"SurveyAssistantClientError\";\n this.code = code;\n }\n}\n\nexport const readSurveyAssistantJson = async (\n response: Response,\n fallback = \"The assistant request could not be completed.\",\n) => {\n const body = await response.json().catch(() => ({}));\n if (!response.ok) {\n const detail = typeof body?.error === \"string\" ? body.error : fallback;\n const parsed = parseSurveyAssistantError(\n typeof body?.code === \"string\" ? { code: body.code, detail } : detail,\n );\n throw new SurveyAssistantClientError(parsed.code, parsed.detail ?? detail);\n }\n return body;\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 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.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),\n setController(controller) {\n currentController = controller;\n },\n };\n};\n"],"mappings":";;AAEA,IAAa,6BAAb,cAAgD,MAAM;CACpD;CAEA,YAAY,MAAgC,SAAiB;AAC3D,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;;;AAI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B as SurveyAssistantTranslateContentResult, F as SurveyAssistantTaskInvocationMode, M as SurveyAssistantSuggestItemLabelResult, P as SurveyAssistantTaskContext, cn as SurveyAssistantSnapshot, f as SurveyBatchApplyResult, fn as SurveyEditorUIContext, i as SurveyApplyResult, it as SurveyAssistantThread, j as SurveyAssistantSuggestItemLabelInput, k as SurveyAssistantSuggestItemKeyInput, p as SurveyChangeSet, z as SurveyAssistantTranslateContentInput } from "./index-DVxVyhAu.mjs";
1
+ import { A as SurveyAssistantSuggestItemKeyResult, B as SurveyAssistantTranslateContentResult, F as SurveyAssistantTaskInvocationMode, M as SurveyAssistantSuggestItemLabelResult, P as SurveyAssistantTaskContext, cn as SurveyAssistantSnapshot, f as SurveyBatchApplyResult, fn as SurveyEditorUIContext, i as SurveyApplyResult, it as SurveyAssistantThread, j as SurveyAssistantSuggestItemLabelInput, k as SurveyAssistantSuggestItemKeyInput, p as SurveyChangeSet, z as SurveyAssistantTranslateContentInput } from "./index-BiTT71Xp.mjs";
2
2
  import { FileUIPart } from "ai";
3
3
 
4
4
  //#region src/react/thread-launcher.d.ts
@@ -79,4 +79,4 @@ declare const createSurveyAssistantControllerProxy: (getController: () => Survey
79
79
  declare const createSurveyAssistantControllerBridge: (options?: CreateSurveyAssistantControllerProxyOptions) => SurveyAssistantControllerBridge;
80
80
  //#endregion
81
81
  export { createSurveyAssistantThreadLauncher as _, SurveyAssistantController as a, SurveyAssistantTaskExecutionOptions as c, SurveyAssistantTaskExecutorRequestOptions as d, createSurveyAssistantTaskClient as f, SurveyAssistantThreadLauncher as g, SurveyAssistantThreadLaunch as h, createSurveyAssistantControllerProxy as i, SurveyAssistantTaskExecutor as l, SurveyAssistantLaunchUIContext as m, SurveyAssistantControllerBridge as n, SurveyAssistantTaskClient as o, createSurveyAssistantTaskExecutor as p, createSurveyAssistantControllerBridge as r, SurveyAssistantTaskClientOptions as s, CreateSurveyAssistantControllerProxyOptions as t, SurveyAssistantTaskExecutorCacheContext as u };
82
- //# sourceMappingURL=controller-proxy-2VH0b_5E.d.mts.map
82
+ //# sourceMappingURL=controller-proxy-BzpEOygv.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"controller-proxy-2VH0b_5E.d.mts","names":[],"sources":["../src/react/thread-launcher.ts","../src/react/task-client.ts","../src/react/controller.ts","../src/react/controller-proxy.ts"],"mappings":";;;;KAOY,8BAAA,GAAiC,OAAA,CAAQ,IAAA,CAAK,qBAAA;AAAA,UAEzC,2BAAA;EAFL;EAIV,MAAA;EACA,KAAA,GAAQ,UAAA;EALgD;EAOxD,KAAA;EAP2C;EAS3C,SAAA,GAAY,8BAAA;AAAA;AAAA,UAGG,6BAAA;EAZoC;;;;EAiBnD,WAAA,CAAY,KAAA,EAAO,2BAAA,GAA8B,OAAA,CAAQ,qBAAA;AAAA;AAAA,cA6D9C,mCAAA,QAA0C,6BAAA;;;UCtEtC,gCAAA;EACf,GAAA;EACA,UAAA;EACA,UAAA;EACA,QAAA;AAAA;AAAA,UAGe,mCAAA;EACf,IAAA,GAAO,iCAAA;EACP,OAAA;EACA,MAAA,GAAS,WAAA;AAAA;AAAA,UAGM,yBAAA;EACf,cAAA,CACE,KAAA,EAAO,kCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,mCAAA,GACT,OAAA,CAAQ,mCAAA;EACX,gBAAA,CACE,KAAA,EAAO,oCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,mCAAA,GACT,OAAA,CAAQ,qCAAA;EACX,gBAAA,CACE,KAAA,EAAO,oCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,mCAAA,GACT,OAAA,CAAQ,qCAAA;AAAA;AAAA,UAGI,yCAAA;EACf,IAAA,GAAO,iCAAA;EACP,MAAA,GAAS,WAAA;AAAA;AAAA,UAGM,uCAAA;EACf,UAAA;AAAA;AAAA,UAGe,2BAAA;EACf,cAAA,CACE,KAAA,EAAO,kCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,yCAAA,EACV,KAAA,GAAQ,uCAAA,GACP,OAAA,CAAQ,mCAAA;EACX,gBAAA,CACE,KAAA,EAAO,oCAAA,EACP,OAAA,EAAS,0BAAA,EACT,OAAA,GAAU,yCAAA,EACV,KAAA,GAAQ,uCAAA,GACP,OAAA,CAAQ,qCAAA;EACX,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
+ {"version":3,"file":"controller-proxy-BzpEOygv.d.mts","names":[],"sources":["../src/react/thread-launcher.ts","../src/react/task-client.ts","../src/react/controller.ts","../src/react/controller-proxy.ts"],"mappings":";;;;KAOY,8BAAA,GAAiC,OAAA,CAAQ,IAAA,CAAK,qBAAA;AAAA,UAEzC,2BAAA;EAFL;EAIV,MAAA;EACA,KAAA,GAAQ,UAAA;EALgD;EAOxD,KAAA;EAP2C;EAS3C,SAAA,GAAY,8BAAA;AAAA;AAAA,UAGG,6BAAA;EA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