@case-framework/survey-assistant 0.2.0 → 0.2.2

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 (71) hide show
  1. package/dist/{capabilities-DZ0a_o2y.mjs → capabilities-DKbNCnBf.mjs} +2 -2
  2. package/dist/{capabilities-DZ0a_o2y.mjs.map → capabilities-DKbNCnBf.mjs.map} +1 -1
  3. package/dist/capabilities-default.d.mts +1 -1
  4. package/dist/capabilities-default.mjs +1 -1
  5. package/dist/{constants-56jf_4ls.d.mts → constants-D-5m_KGB.d.mts} +7 -7
  6. package/dist/constants-D-5m_KGB.d.mts.map +1 -0
  7. package/dist/{controller-proxy-ClsY4lFI.mjs → controller-proxy-0WJZUZYx.mjs} +2 -2
  8. package/dist/{controller-proxy-ClsY4lFI.mjs.map → controller-proxy-0WJZUZYx.mjs.map} +1 -1
  9. package/dist/{controller-proxy-2VH0b_5E.d.mts → controller-proxy-Hkuub9dt.d.mts} +2 -2
  10. package/dist/{controller-proxy-2VH0b_5E.d.mts.map → controller-proxy-Hkuub9dt.d.mts.map} +1 -1
  11. package/dist/{engine-DQrCO_ur.mjs → engine-0AJrv0hI.mjs} +543 -76
  12. package/dist/engine-0AJrv0hI.mjs.map +1 -0
  13. package/dist/engine.d.mts +2 -2
  14. package/dist/engine.mjs +3 -3
  15. package/dist/{index-B_x2IYi7.d.mts → index-BcyfBeDj.d.mts} +3 -12
  16. package/dist/index-BcyfBeDj.d.mts.map +1 -0
  17. package/dist/{index-C_x686M7.d.mts → index-CneD8ibB.d.mts} +3 -3
  18. package/dist/{index-C_x686M7.d.mts.map → index-CneD8ibB.d.mts.map} +1 -1
  19. package/dist/{index-DZ6KBwVR.d.mts → index-JXH-t2EJ.d.mts} +45 -14
  20. package/dist/index-JXH-t2EJ.d.mts.map +1 -0
  21. package/dist/{index-DVxVyhAu.d.mts → index-MEOL9_Gr.d.mts} +4 -12
  22. package/dist/{index-DVxVyhAu.d.mts.map → index-MEOL9_Gr.d.mts.map} +1 -1
  23. package/dist/{memory-thread-repository-Cm1BJyRw.mjs → memory-thread-repository-1ocPOda8.mjs} +17 -17
  24. package/dist/memory-thread-repository-1ocPOda8.mjs.map +1 -0
  25. package/dist/{protocol-7EEgcYja.mjs → protocol-DpCYmCjr.mjs} +1 -8
  26. package/dist/{protocol-7EEgcYja.mjs.map → protocol-DpCYmCjr.mjs.map} +1 -1
  27. package/dist/protocol.d.mts +1 -1
  28. package/dist/protocol.mjs +1 -1
  29. package/dist/{react-B_5smfiK.mjs → react-DXK5zWNo.mjs} +3 -3
  30. package/dist/{react-B_5smfiK.mjs.map → react-DXK5zWNo.mjs.map} +1 -1
  31. package/dist/react-integration.d.mts +1 -1
  32. package/dist/react-integration.mjs +1 -1
  33. package/dist/react.d.mts +2 -2
  34. package/dist/react.mjs +2 -2
  35. package/dist/references/assistant-operations.md +9 -14
  36. package/dist/references/localization.md +2 -0
  37. package/dist/references/source-material-surveys.md +1 -1
  38. package/dist/{request-context-BDBw4-Gw.mjs → request-context-BBzU3VdG.mjs} +17 -10
  39. package/dist/request-context-BBzU3VdG.mjs.map +1 -0
  40. package/dist/server-agent.d.mts +4 -12
  41. package/dist/server-agent.mjs +13 -13
  42. package/dist/server-agent.mjs.map +1 -1
  43. package/dist/server-runtime.d.mts +4 -4
  44. package/dist/server-runtime.mjs +2 -2
  45. package/dist/server-tasks.d.mts +1 -1
  46. package/dist/server-tasks.mjs +1 -1
  47. package/dist/server-tools.d.mts +1 -1
  48. package/dist/server-tools.mjs +1 -1
  49. package/dist/server.d.mts +6 -6
  50. package/dist/server.d.mts.map +1 -1
  51. package/dist/server.mjs +2 -2
  52. package/dist/{tasks-COQnhSeT.d.mts → tasks-DcfQNJwO.d.mts} +3 -3
  53. package/dist/{tasks-COQnhSeT.d.mts.map → tasks-DcfQNJwO.d.mts.map} +1 -1
  54. package/dist/thread-documents-BlxNjc7S.d.mts.map +1 -1
  55. package/dist/{thread-handlers-l79JBl5m.d.mts → thread-handlers-uddXwQjp.d.mts} +3 -3
  56. package/dist/{thread-handlers-l79JBl5m.d.mts.map → thread-handlers-uddXwQjp.d.mts.map} +1 -1
  57. package/dist/{tools-DDXaJ8Za.mjs → tools-wgLen05n.mjs} +97 -103
  58. package/dist/tools-wgLen05n.mjs.map +1 -0
  59. package/dist/ui.css +1 -1
  60. package/dist/ui.d.mts +3 -3
  61. package/dist/ui.d.mts.map +1 -1
  62. package/dist/ui.mjs +36 -6
  63. package/dist/ui.mjs.map +1 -1
  64. package/package.json +4 -4
  65. package/dist/constants-56jf_4ls.d.mts.map +0 -1
  66. package/dist/engine-DQrCO_ur.mjs.map +0 -1
  67. package/dist/index-B_x2IYi7.d.mts.map +0 -1
  68. package/dist/index-DZ6KBwVR.d.mts.map +0 -1
  69. package/dist/memory-thread-repository-Cm1BJyRw.mjs.map +0 -1
  70. package/dist/request-context-BDBw4-Gw.mjs.map +0 -1
  71. package/dist/tools-DDXaJ8Za.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"server-agent.mjs","names":[],"sources":["../src/server/agent.ts"],"sourcesContent":["import { Agent, type AgentConfig } from \"@mastra/core/agent\";\nimport type { InputProcessor } from \"@mastra/core/processors\";\nimport type { RequestContext } from \"@mastra/core/request-context\";\nimport { Memory } from \"@mastra/memory\";\nimport { createHash } from \"node:crypto\";\nimport {\n getDeterministicCreateItemTypes,\n type SurveyAssistantEngineContext as SurveyAssistantSnapshot,\n} from \"../engine\";\nimport type { SurveyAssistantRequestContext } from \"./request-context\";\nimport { SURVEY_ASSISTANT_AGENT_ID } from \"./constants\";\nimport { SURVEY_ASSISTANT_TOOL_IDS, surveyAssistantTools } from \"./tools\";\n\nconst [\n INSPECT_TOOL_NAME,\n CHANGE_TOOL_NAME,\n EXPRESSION_TOOL_NAME,\n AUTHORING_REFERENCE_TOOL_NAME,\n ATTACHMENT_TOOL_NAME,\n AUDIT_TOOL_NAME,\n ASSET_TOOL_NAME,\n] = SURVEY_ASSISTANT_TOOL_IDS;\n\nexport const surveyAssistantThreadAttachmentProcessor: InputProcessor = {\n id: \"survey-assistant-thread-attachments\",\n processLLMRequest({ prompt, requestContext }) {\n const surveyRequestContext = requestContext as\n | RequestContext<SurveyAssistantRequestContext>\n | undefined;\n const attachments =\n surveyRequestContext?.get(\"modelAttachments\") ??\n surveyRequestContext?.get(\"attachmentAccess\")?.selectedAttachments;\n\n let userIndex = -1;\n for (let index = prompt.length - 1; index >= 0; index -= 1) {\n if (prompt[index]?.role === \"user\") {\n userIndex = index;\n break;\n }\n }\n if (userIndex < 0) return;\n const userMessage = prompt[userIndex];\n if (!userMessage || userMessage.role !== \"user\") return;\n\n let normalizedCurrentFile = false;\n const currentContent = userMessage.content.map((part) => {\n if (part.type !== \"file\" || typeof part.data !== \"string\") return part;\n const match = /^data:[^;,]+;base64,([A-Za-z0-9+/]*={0,2})$/.exec(part.data);\n if (!match?.[1]) return part;\n normalizedCurrentFile = true;\n return { ...part, data: match[1] };\n });\n const currentFileKeys = new Set(\n currentContent.flatMap((part) =>\n part.type === \"file\" && typeof part.data === \"string\"\n ? [`${part.mediaType}\\u0000${createHash(\"sha256\").update(part.data).digest(\"hex\")}`]\n : [],\n ),\n );\n const attachmentsToAdd = (attachments ?? []).filter(\n (attachment) =>\n !currentFileKeys.has(`${attachment.mediaType}\\u0000${attachment.contentHash}`),\n );\n if (!normalizedCurrentFile && attachmentsToAdd.length === 0) return;\n\n const nextPrompt = [...prompt];\n nextPrompt[userIndex] = {\n ...userMessage,\n content: [\n ...attachmentsToAdd.map((attachment) => ({\n type: \"file\" as const,\n filename: attachment.filename,\n mediaType: attachment.mediaType,\n data: attachment.data,\n })),\n ...currentContent,\n ],\n };\n return { prompt: nextPrompt };\n },\n};\n\nconst formatCurrentEditorContext = (snapshot: SurveyAssistantSnapshot | undefined): string => {\n if (!snapshot) {\n return [\n \"No live editor snapshot was provided with this turn.\",\n \"If the user asks about the current survey, selected item, or current screen, say that current editor context is unavailable for this request.\",\n ].join(\" \");\n }\n\n const selectedItem = snapshot.ui.selectedItemId ?? \"none\";\n const focusedItem = snapshot.ui.focusItemId ?? \"none\";\n const recentItems = snapshot.ui.recentItemIds?.join(\", \") ?? \"none\";\n const highlights =\n snapshot.ui.highlights\n ?.map((entry) =>\n [\n `kind=${entry.kind}`,\n entry.itemId ? `itemId=${entry.itemId}` : undefined,\n entry.componentId ? `componentId=${entry.componentId}` : undefined,\n entry.label ? `label=${entry.label}` : undefined,\n entry.details ? `details=${entry.details}` : undefined,\n ]\n .filter(Boolean)\n .join(\"; \"),\n )\n .join(\", \") ?? \"none\";\n const history = snapshot.ui.history;\n const currentHistoryEntry = history?.recent.find((entry) => entry.isCurrent);\n const surveyKey = snapshot.inspection.surveyKey ?? \"not set\";\n const locales =\n snapshot.inspection.locales.length > 0 ? snapshot.inspection.locales.join(\", \") : \"none\";\n const deterministicCreateItemTypes = getDeterministicCreateItemTypes(snapshot.capabilities);\n const creatableItemTypes =\n deterministicCreateItemTypes.length > 0 ? deterministicCreateItemTypes.join(\", \") : \"none\";\n const rootItem = snapshot.inspection.outline.find((item) => item.depth === 0);\n const rootItemDescription = rootItem\n ? `${rootItem.fullKey} (id=${rootItem.itemId}, key=${rootItem.key})`\n : \"not found in the inspection outline\";\n const itemTypeDetails =\n snapshot.capabilities.itemTypes.length > 0\n ? snapshot.capabilities.itemTypes\n .map((entry) => {\n const primaryContentKey = entry.contentSurfaces.find(\n (surface) => surface.role === \"primary\",\n )?.key;\n const details = [\n `create=${entry.create}`,\n primaryContentKey ? `primary=${primaryContentKey}` : undefined,\n entry.authoring?.compactHint,\n ]\n .filter((value): value is string => Boolean(value))\n .join(\"; \");\n return details ? `${entry.itemType} (${details})` : entry.itemType;\n })\n .join(\", \")\n : \"none\";\n return [\n \"Use this live editor snapshot as the authoritative current survey state for this turn.\",\n `Only a derived snapshot header is included here. Use it directly for current view, selected item id, selected locale, survey key, root group, locale list, item count, and deterministically creatable item types. Item count excludes the structural root group; the authoritative raw survey remains available to inspection tools in request context.`,\n `Current view: ${snapshot.ui.view}`,\n `Selected item id: ${selectedItem}`,\n `Focused item id: ${focusedItem}`,\n `Recent item ids: ${recentItems}`,\n `Active UI surface: ${snapshot.ui.activeSurface ?? \"not provided\"}`,\n `Open UI panels: ${snapshot.ui.openPanels?.join(\", \") ?? \"not provided\"}`,\n `Highlighted UI targets: ${highlights}`,\n `History state: ${history ? `index=${history.currentIndex}; total=${history.totalEntries}; canUndo=${history.canUndo}; canRedo=${history.canRedo}; currentAction=${currentHistoryEntry?.label ?? \"not available\"}` : \"not provided\"}`,\n `Selected locale: ${snapshot.ui.selectedLocale}`,\n `Survey key: ${surveyKey}`,\n `Root group for top-level create-item target.parentItemId: ${rootItemDescription}`,\n `Survey locales: ${locales}`,\n `Survey item count (excluding the structural root group): ${snapshot.inspection.itemCount}`,\n `Deterministically creatable item types: ${creatableItemTypes}`,\n `Installed item capabilities (compact): ${itemTypeDetails}. Load a composed assistant-operations reference with operationKind and itemType for supported operations, configuration, content surfaces, and focused authoring guidance.`,\n ]\n .filter((line): line is string => Boolean(line))\n .join(\"\\n\");\n};\n\nconst formatDocumentTransition = (\n transition: SurveyAssistantRequestContext[\"documentTransition\"],\n): string => {\n if (!transition) {\n return \"Document continuity is unavailable because no live editor snapshot was provided.\";\n }\n\n if (transition.status === \"no-baseline\") {\n return [\n \"Document continuity: no settled baseline is available for comparison.\",\n \"Do not infer whether historical survey observations are still current. Inspect the targets relevant to the user's request before relying on prior survey state.\",\n ].join(\"\\n\");\n }\n\n if (transition.status === \"session-changed\") {\n return [\n \"Document continuity: the editor session changed since the last settled assistant turn.\",\n \"Treat all historical observations about survey content, structure, ids, and selections as stale. Inspect the current targets needed for this request.\",\n ].join(\"\\n\");\n }\n\n if (transition.status === \"unchanged\") {\n return [\n \"Document continuity: survey content is unchanged since the last settled assistant turn.\",\n transition.capabilitiesChanged\n ? \"Installed editor capabilities changed; re-check capability-dependent assumptions.\"\n : \"Relevant prior inspected survey facts may be reused, while the current snapshot and tools remain authoritative.\",\n ].join(\"\\n\");\n }\n\n const sources =\n transition.recordedSources.length > 0 ? transition.recordedSources.join(\", \") : \"unrecorded\";\n return [\n \"Document continuity: survey content changed since the last settled assistant turn.\",\n `History movement: ${transition.historyDirection}; recorded change sources: ${sources}.`,\n transition.capabilitiesChanged ? \"Installed editor capabilities also changed.\" : undefined,\n \"Treat historical observations about affected survey content, structure, ids, and expressions as potentially stale. Before answering or editing, inspect the current targets relevant to the user's request; do not reload unrelated survey state.\",\n ]\n .filter((line): line is string => Boolean(line))\n .join(\"\\n\");\n};\n\nconst buildInstructions = ({\n requestContext,\n}: {\n requestContext: RequestContext<SurveyAssistantRequestContext>;\n}) => {\n const snapshot = requestContext.get(\"engineContext\");\n const documentTransition = requestContext.get(\"documentTransition\");\n const attachmentAccess = requestContext.get(\"attachmentAccess\");\n const attachmentManifest = attachmentAccess?.documents.length\n ? attachmentAccess.documents\n .map((document) =>\n JSON.stringify({\n id: document.id,\n filename: document.name,\n mediaType: document.mediaType,\n attachmentRole: attachmentAccess.currentDocumentIds?.includes(document.id)\n ? \"current-message-context\"\n : \"stored\",\n }),\n )\n .join(\"\\n\")\n : \"none\";\n\n return [\n \"You help users inspect, explain, create, and edit CASE surveys in the Survey Editor.\",\n \"Infer whether the user wants an answer, explanation, critique, clarification, or concrete edit from their message and current editor context. Keep routine answers concise.\",\n \"Reply in the language of the user's current message unless they request another language. Respondent-facing survey text follows the requested survey locale, which may differ from the reply language.\",\n \"Authority order: the current request snapshot and inspection tools define live survey state; the capability manifest defines installed item behavior; authoring references define stable CASE conventions; Mastra memory is conversational history only.\",\n \"The capability manifest is authoritative for available item types, create modes, supported operations, content surfaces, response slots, and capability-owned references. Never guess unsupported item behavior.\",\n \"Never claim that an item type, field type, controller, operation, or other editor capability is unavailable unless the current capability manifest or a loaded authoring reference explicitly excludes it. For a capability question, inspect or load the focused reference before answering; if support remains unclear, say that it is unverified rather than unsupported.\",\n \"For an installed custom item type, use survey_authoring_reference with both itemType and one of its advertised reference topics before creating or changing unfamiliar config. Use survey_inspect item-details to obtain capability-provided inspection details for existing items.\",\n `Use ${INSPECT_TOOL_NAME} to inspect current context, UI context/highlights, recent editor history, search, item details, image assets, complete paged outlines, response slots, and exact raw JSON paths. Use action \"assets\" to obtain explicit assetId values, metadata, and usage locations before asset changes; the key of /assets/<key> is the asset ID even though the stored asset object does not repeat it. Never guess what \"this\", \"here\", or \"the highlighted part\" refers to when the snapshot can resolve it. History explains recent actions but the current snapshot remains authoritative.`,\n `Use ${AUTHORING_REFERENCE_TOOL_NAME} to load one narrow convention when needed: core-rules, survey-data-model, source-material-surveys, localization, rich-text-content, item-types, embedded-forms, expressions, assistant-operations, or survey-quality. For item-types, pass itemType to load only the relevant installed type; omit itemType only for a genuine cross-type comparison. Load survey-quality before giving a substantive questionnaire-quality critique.`,\n `Use ${AUDIT_TOOL_NAME} for read-only deterministic technical checks and a structured questionnaire-quality review rubric. For quality feedback, combine its exact findings with survey-quality and inspect the relevant wording and flow. Clearly distinguish technical defects, design recommendations, and claims that would require cognitive testing or psychometric evidence.`,\n `Use ${CHANGE_TOOL_NAME} for ordinary mutations and ${EXPRESSION_TOOL_NAME} for expressions on items already present in the immutable snapshot. Prefer typed operations; use one inspected survey-json-patch operation only when no typed operation covers the requested field.`,\n `The typed ${CHANGE_TOOL_NAME} operations cover item structure/content/config, choices, forms, survey content, and assets. For an unfamiliar operation shape, load assistant-operations with operationKind and, when targeting an item type, itemType to receive a compact composed contract. Request full contract detail only for protocol debugging. Omit operationKind only when broader conventions are needed. Reorders replace the complete inspected list and use optionIds, groupIds, or itemIds as documented by the tool.`,\n \"Canonical create-item shape: put parentItemId and optional index in target; put id, key, itemType, config, and any creation-time expressions in item; put respondent-visible plainText or structured content in top-level translations. Put choice maxSelection and options inside item.config. For top-level creation, target the root group identified by the snapshot or inspection.\",\n \"Use update-item-translation with itemId, locale, contentKey, and plainText for ordinary respondent-visible text. Use content only for a complete structured Content value when formatting carries meaning. Item title, subtitle, topContent, bottomContent, cardFooter, info content, option labels, and field labels are translations, not item labels.\",\n \"Use update-placed-image only for an image already embedded in rich text in the immutable snapshot. It can switch the placement between a local asset and an external URL and update its rendered ALT text, caption, width, height, maximum dimensions, and alignment. For a new item, put the complete richText value with the image block directly in create-item.translations[].content; never create placeholder text and try to update the new placement later. Do not use image asset metadata when the user asked to change one placed image.\",\n \"An unqualified request to add or change a survey item or question label means the editor-only item label and uses update-item-label. A question title/text, option label, or field label is respondent-visible translated content.\",\n \"A group is a hierarchy/container, not a decorative heading. Use a group for meaningful nested structure, an info item for standalone explanatory content, and a page break when only a respondent page boundary is needed. Create a non-root group empty, then create its children in parent-before-child order.\",\n \"Write respondent-visible content under its actual locale. A real typed translation may introduce a missing locale; never place target-language text under an existing wrong locale or create dummy content merely to introduce a locale.\",\n \"Use plainText for ordinary unformatted copy. Load rich-text-content and use structured richText only for meaningful headings, lists, emphasis, links, images, info boxes, or other formatting. Markdown syntax inside md/plain content is not rendered as rich formatting.\",\n \"Do not refuse an edit merely because no narrow typed operation exists. Inspect the exact current raw item/path and use survey-json-patch for assistant-editable survey fields that have no typed or expression helper.\",\n \"A survey-json-patch proposal contains exactly one operation with kind survey-json-patch and one plural patches array containing every related raw edit. It must be the only operation in that survey_change call. Paths are rooted at the survey document, such as /surveyItems/<index>/config or /translations/<locale>; never start at /config or modify /$schema. Patch translation leaves rather than replacing existing locale or item-translation containers.\",\n \"A choice free-text follow-up such as Other, please specify is an option embeddedForm, not allowOther. Load embedded-forms and prefer set-embedded-form with its relative translations. If the option is also new, put add-choice-option with an explicit id immediately before set-embedded-form in the same survey_change proposal. Use a raw patch only when the typed operations cannot express the requested change.\",\n \"For choiceItem, maxSelection 1 is single choice, null is unlimited multiple choice, and a positive number is capped multiple choice. Choice config options use ids/keys/configuration; respondent-visible option labels belong in translations at options.<optionId>.label.\",\n \"Every form or embedded-form select option needs a visible translation. Do not rely on raw controller values as respondent labels.\",\n \"When the user asks to implement or convert supplied source material, completeness is part of the task. Load source-material-surveys and implement coherent bounded chunks without sampling or silently omitting difficult respondent content.\",\n `Files attached to the current user message are already available directly. When an earlier stored attachment is relevant, call ${ATTACHMENT_TOOL_NAME} with only the needed document ids before answering or editing. Always load the relevant stored source for factual document questions or source-faithful authoring; conversational memory is not a lossless copy. After the tool succeeds, the selected original PDFs/images are attached to your next model input: read them directly and continue the task. Never claim that a successfully loaded attachment is unavailable, ask for extracted text, or describe the attachment tool as an extraction limitation. Do not load unrelated attachments, and do not ask the user to upload a listed file again.`,\n `Use ${ASSET_TOOL_NAME} to import an attached image into survey assets without copying base64 through ${CHANGE_TOOL_NAME}, and to update or remove unreferenced image-asset metadata. Current-message images are already model context but still have document ids for explicit asset import. When the user asks to create a new item containing an attached image: first import it, then make exactly one ${CHANGE_TOOL_NAME} call with continuationMode \"append\" whose create-item translation contains the asset image block from the start. To delete referenced images and their assets together, make one ${CHANGE_TOOL_NAME} call containing the reference-removal operations first and remove-image-asset last; do not split dependent deletions across ${CHANGE_TOOL_NAME} and ${ASSET_TOOL_NAME}. Never import a screenshot or other image merely because it is attached; do so only when the user asks to use it as survey content.`,\n \"For branching, conditions, expression validations, prefills, and template values on existing state, use survey_expression and exact inspected response refs/value types. For newly created dependent items, embed expressions directly in the same survey_change creation proposal.\",\n \"Treat every turn snapshot as immutable. Do not inspect or target a newly created id with item-editing operations in the same response, even inside the same survey_change call. Put each new item's complete initial config, content, fields, options, and embedded expressions directly in its create-item operation. Multiple new items may share one bounded proposal in parent/dependency order.\",\n `Prefer one mutation-preparation call for an ordinary request. Omit continuationMode only on the first mutation call in a response. Every later ${CHANGE_TOOL_NAME} or prepare-mode ${EXPRESSION_TOOL_NAME} call must use \"append\" for independent additional work or \"replace\" for a complete correction that discards active candidates.`,\n `A validated ${CHANGE_TOOL_NAME} or prepare-mode ${EXPRESSION_TOOL_NAME} result is a candidate, not proof of application. The successful turn-final event alone authorizes final candidate ids. Any rejected mutation blocks the whole turn until a complete corrected candidate uses continuationMode \"replace\". Never obtain validation by dropping requested behavior.`,\n \"When a proposal is rejected, use its concrete issues and target summary to correct the full request once. For an unfamiliar operation or raw shape, load assistant-operations and inspect the exact raw state before retrying. If a complete request exceeds the operation limit, replace it with the first complete bounded chunk and append later independent chunks.\",\n \"Before answering, reconcile every requested target against the final validated candidates. Never claim rejected, superseded, missing, partial, or failed work was completed. If a request remains incomplete, correct it once or state the exact remaining work.\",\n \"When required structure or behavior is clear but ordinary respondent wording is open, choose concise, neutral, internally consistent wording. Ask only when ambiguity materially affects purpose, domain, language, or compliance.\",\n \"For concrete supported edits, inspect the relevant live state, load every reference explicitly required above before the first mutation attempt, prepare the complete change, then summarize only the final validated candidates concisely. Do not ask the user to choose an output mode.\",\n \"Do not write tool syntax, hidden chain-of-thought, or invented validation results in normal text. Never claim persistence outside the editor.\",\n `Attachment document ids available for explicit loading or asset import:\\n${attachmentManifest}`,\n formatDocumentTransition(documentTransition),\n formatCurrentEditorContext(snapshot),\n ].join(\"\\n\\n\");\n};\n\ntype SurveyAssistantAgentConfig = AgentConfig<\n typeof SURVEY_ASSISTANT_AGENT_ID,\n typeof surveyAssistantTools,\n undefined,\n SurveyAssistantRequestContext\n>;\n\ntype SurveyAssistantMemoryOptions = NonNullable<\n NonNullable<ConstructorParameters<typeof Memory>[0]>[\"options\"]\n>;\n\nconst isInitialMessageRecall = (inputData: unknown): inputData is Record<string, unknown> => {\n if (!inputData || typeof inputData !== \"object\" || Array.isArray(inputData)) return false;\n\n const input = inputData as Record<string, unknown>;\n const mode = input.mode;\n const hasCursor = typeof input.cursor === \"string\" && input.cursor.length > 0;\n const hasThreadId = typeof input.threadId === \"string\" && input.threadId.length > 0;\n return (mode === undefined || mode === \"messages\") && !hasCursor && !hasThreadId;\n};\n\n// Mastra's thread-scoped recall schema omits threadId and rejects the first page\n// when the model provides neither a cursor nor a thread ID. Bind the active\n// thread internally so retrieval stays thread-scoped instead of widening to a resource.\nclass ThreadScopedSurveyAssistantMemory extends Memory {\n override listTools(config?: Parameters<Memory[\"listTools\"]>[0]) {\n const tools = super.listTools(config);\n const recall = tools.recall;\n if (!recall?.execute) return tools;\n\n const executeRecall = recall.execute;\n return {\n ...tools,\n recall: {\n ...recall,\n execute: async (\n inputData: Parameters<typeof executeRecall>[0],\n context: Parameters<typeof executeRecall>[1],\n ) => {\n if (!isInitialMessageRecall(inputData)) return executeRecall(inputData, context);\n\n const threadId = context.agent?.threadId;\n return executeRecall(threadId ? { ...inputData, threadId } : inputData, context);\n },\n },\n };\n }\n}\n\nexport type SurveyAssistantObservationalMemoryOptions = Exclude<\n SurveyAssistantMemoryOptions[\"observationalMemory\"],\n boolean | undefined\n>;\n\ntype SurveyAssistantObservationalMemoryOptionsInput = Partial<\n Omit<SurveyAssistantObservationalMemoryOptions, \"model\">\n> & {\n model: NonNullable<SurveyAssistantObservationalMemoryOptions[\"model\"]>;\n};\n\nexport const SURVEY_ASSISTANT_OBSERVATIONAL_MEMORY_DEFAULTS = {\n messageTokens: 48_000,\n observationTokens: 80_000,\n previousObserverTokens: 24_000,\n} as const;\n\nexport const createSurveyAssistantObservationalMemoryOptions = ({\n model,\n observation,\n reflection,\n ...overrides\n}: SurveyAssistantObservationalMemoryOptionsInput): SurveyAssistantObservationalMemoryOptions => ({\n model,\n scope: \"thread\",\n activateAfterIdle: false,\n activateOnProviderChange: true,\n retrieval: { scope: \"thread\" },\n shareTokenBudget: false,\n temporalMarkers: false,\n ...overrides,\n observation: {\n messageTokens: SURVEY_ASSISTANT_OBSERVATIONAL_MEMORY_DEFAULTS.messageTokens,\n bufferTokens: 0.2,\n bufferActivation: 0.75,\n blockAfter: 1.5,\n bufferOnIdle: false,\n previousObserverTokens: SURVEY_ASSISTANT_OBSERVATIONAL_MEMORY_DEFAULTS.previousObserverTokens,\n threadTitle: true,\n observeAttachments: false,\n instruction:\n \"Prioritize the user's survey-authoring requirements, corrections, decisions, referenced source sections, unfinished tasks, and what the assistant actually completed or failed to complete. Preserve exact wording when the user marks it as required. Treat survey ids, structure, translations, expressions, selections, and tool output as historical observations only; the live editor snapshot and survey tools remain authoritative for current state. Do not imply that an attached source document was preserved when only its conversational use was observed.\",\n ...observation,\n },\n reflection: {\n observationTokens: SURVEY_ASSISTANT_OBSERVATIONAL_MEMORY_DEFAULTS.observationTokens,\n bufferActivation: 0.5,\n blockAfter: 1.5,\n activateAfterIdle: false,\n activateOnProviderChange: true,\n instruction:\n \"Consolidate related survey requirements and decisions while preserving corrections, explicit constraints, unresolved work, source references, and completion or failure status. Remove superseded assumptions and repetitive tool detail. Never promote historical survey state into current truth and never summarize an attachment as though it were a lossless copy of the source.\",\n ...reflection,\n },\n});\n\nexport interface CreateSurveyAssistantAgentOptions {\n model: SurveyAssistantAgentConfig[\"model\"];\n memory?: SurveyAssistantAgentConfig[\"memory\"];\n observationalMemory?: SurveyAssistantObservationalMemoryOptions | false;\n}\n\nexport const createSurveyAssistantAgent = ({\n memory,\n model,\n observationalMemory,\n}: CreateSurveyAssistantAgentOptions) =>\n new Agent<\n typeof SURVEY_ASSISTANT_AGENT_ID,\n typeof surveyAssistantTools,\n undefined,\n SurveyAssistantRequestContext\n >({\n id: SURVEY_ASSISTANT_AGENT_ID,\n name: \"Survey Assistant\",\n instructions: buildInstructions,\n model,\n tools: surveyAssistantTools,\n memory:\n memory ??\n new ThreadScopedSurveyAssistantMemory({\n options: {\n lastMessages: false,\n observationalMemory:\n observationalMemory === false\n ? false\n : (observationalMemory ??\n createSurveyAssistantObservationalMemoryOptions({\n model: model as NonNullable<SurveyAssistantObservationalMemoryOptions[\"model\"]>,\n })),\n },\n }),\n inputProcessors: [surveyAssistantThreadAttachmentProcessor],\n });\n"],"mappings":";;;;;;;AAaA,MAAM,CACJ,mBACA,kBACA,sBACA,+BACA,sBACA,iBACA,mBACE;AAEJ,MAAa,2CAA2D;CACtE,IAAI;CACJ,kBAAkB,EAAE,QAAQ,kBAAkB;EAC5C,MAAM,uBAAuB;EAG7B,MAAM,cACJ,sBAAsB,IAAI,mBAAmB,IAC7C,sBAAsB,IAAI,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Q,MAAM,UAAU,OAAO;EACrC,MAAM,SAAS,MAAM;AACrB,MAAI,CAAC,QAAQ,QAAS,QAAO;EAE7B,MAAM,gBAAgB,OAAO;AAC7B,SAAO;GACL,GAAG;GACH,QAAQ;IACN,GAAG;IACH,SAAS,OACP,WACA,YACG;AACH,SAAI,CAAC,uBAAuB,UAAU,CAAE,QAAO,cAAc,WAAW,QAAQ;KAEhF,MAAM,WAAW,QAAQ,OAAO;AAChC,YAAO,cAAc,WAAW;MAAE,GAAG;MAAW;MAAU,GAAG,WAAW,QAAQ;;IAEnF;GACF;;;AAeL,MAAa,iDAAiD;CAC5D,eAAe;CACf,mBAAmB;CACnB,wBAAwB;CACzB;AAED,MAAa,mDAAmD,EAC9D,OACA,aACA,YACA,GAAG,iBAC6F;CAChG;CACA,OAAO;CACP,mBAAmB;CACnB,0BAA0B;CAC1B,WAAW,EAAE,OAAO,UAAU;CAC9B,kBAAkB;CAClB,iBAAiB;CACjB,GAAG;CACH,aAAa;EACX,eAAe,+CAA+C;EAC9D,cAAc;EACd,kBAAkB;EAClB,YAAY;EACZ,cAAc;EACd,wBAAwB,+CAA+C;EACvE,aAAa;EACb,oBAAoB;EACpB,aACE;EACF,GAAG;EACJ;CACD,YAAY;EACV,mBAAmB,+CAA+C;EAClE,kBAAkB;EAClB,YAAY;EACZ,mBAAmB;EACnB,0BAA0B;EAC1B,aACE;EACF,GAAG;EACJ;CACF;AAQD,MAAa,8BAA8B,EACzC,QACA,OACA,0BAEA,IAAI,MAKF;CACA,IAAI;CACJ,MAAM;CACN,cAAc;CACd;CACA,OAAO;CACP,QACE,UACA,IAAI,kCAAkC,EACpC,SAAS;EACP,cAAc;EACd,qBACE,wBAAwB,QACpB,QACC,uBACD,gDAAgD,EACvC,OACR,CAAC;EACT,EACF,CAAC;CACJ,iBAAiB,CAAC,yCAAyC;CAC5D,CAAC"}
1
+ {"version":3,"file":"server-agent.mjs","names":[],"sources":["../src/server/agent.ts"],"sourcesContent":["import { Agent, type AgentConfig } from \"@mastra/core/agent\";\nimport type { InputProcessor } from \"@mastra/core/processors\";\nimport type { RequestContext } from \"@mastra/core/request-context\";\nimport { Memory } from \"@mastra/memory\";\nimport { createHash } from \"node:crypto\";\nimport {\n getDeterministicCreateItemTypes,\n type SurveyAssistantEngineContext as SurveyAssistantSnapshot,\n} from \"../engine\";\nimport type { SurveyAssistantRequestContext } from \"./request-context\";\nimport { SURVEY_ASSISTANT_AGENT_ID } from \"./constants\";\nimport { SURVEY_ASSISTANT_TOOL_IDS, surveyAssistantTools } from \"./tools\";\n\nconst [\n INSPECT_TOOL_NAME,\n CHANGE_TOOL_NAME,\n EXPRESSION_TOOL_NAME,\n AUTHORING_REFERENCE_TOOL_NAME,\n ATTACHMENT_TOOL_NAME,\n AUDIT_TOOL_NAME,\n ASSET_TOOL_NAME,\n] = SURVEY_ASSISTANT_TOOL_IDS;\n\nexport const surveyAssistantThreadAttachmentProcessor: InputProcessor = {\n id: \"survey-assistant-thread-attachments\",\n processLLMRequest({ prompt, requestContext }) {\n const surveyRequestContext = requestContext as\n | RequestContext<SurveyAssistantRequestContext>\n | undefined;\n const attachments =\n surveyRequestContext?.get(\"modelAttachments\") ??\n surveyRequestContext?.get(\"attachmentAccess\")?.selectedAttachments;\n\n let userIndex = -1;\n for (let index = prompt.length - 1; index >= 0; index -= 1) {\n if (prompt[index]?.role === \"user\") {\n userIndex = index;\n break;\n }\n }\n if (userIndex < 0) return;\n const userMessage = prompt[userIndex];\n if (!userMessage || userMessage.role !== \"user\") return;\n\n let normalizedCurrentFile = false;\n const currentContent = userMessage.content.map((part) => {\n if (part.type !== \"file\" || typeof part.data !== \"string\") return part;\n const match = /^data:[^;,]+;base64,([A-Za-z0-9+/]*={0,2})$/.exec(part.data);\n if (!match?.[1]) return part;\n normalizedCurrentFile = true;\n return { ...part, data: match[1] };\n });\n const currentFileKeys = new Set(\n currentContent.flatMap((part) =>\n part.type === \"file\" && typeof part.data === \"string\"\n ? [`${part.mediaType}\\u0000${createHash(\"sha256\").update(part.data).digest(\"hex\")}`]\n : [],\n ),\n );\n const attachmentsToAdd = (attachments ?? []).filter(\n (attachment) =>\n !currentFileKeys.has(`${attachment.mediaType}\\u0000${attachment.contentHash}`),\n );\n if (!normalizedCurrentFile && attachmentsToAdd.length === 0) return;\n\n const nextPrompt = [...prompt];\n nextPrompt[userIndex] = {\n ...userMessage,\n content: [\n ...attachmentsToAdd.map((attachment) => ({\n type: \"file\" as const,\n filename: attachment.filename,\n mediaType: attachment.mediaType,\n data: attachment.data,\n })),\n ...currentContent,\n ],\n };\n return { prompt: nextPrompt };\n },\n};\n\nconst formatCurrentEditorContext = (snapshot: SurveyAssistantSnapshot | undefined): string => {\n if (!snapshot) {\n return [\n \"No live editor snapshot was provided with this turn.\",\n \"If the user asks about the current survey, selected item, or current screen, say that current editor context is unavailable for this request.\",\n ].join(\" \");\n }\n\n const selectedItem = snapshot.ui.selectedItemId ?? \"none\";\n const focusedItem = snapshot.ui.focusItemId ?? \"none\";\n const recentItems = snapshot.ui.recentItemIds?.join(\", \") ?? \"none\";\n const highlights =\n snapshot.ui.highlights\n ?.map((entry) =>\n [\n `kind=${entry.kind}`,\n entry.itemId ? `itemId=${entry.itemId}` : undefined,\n entry.componentId ? `componentId=${entry.componentId}` : undefined,\n entry.label ? `label=${entry.label}` : undefined,\n entry.details ? `details=${entry.details}` : undefined,\n ]\n .filter(Boolean)\n .join(\"; \"),\n )\n .join(\", \") ?? \"none\";\n const history = snapshot.ui.history;\n const currentHistoryEntry = history?.recent.find((entry) => entry.isCurrent);\n const surveyKey = snapshot.inspection.surveyKey ?? \"not set\";\n const locales =\n snapshot.inspection.locales.length > 0 ? snapshot.inspection.locales.join(\", \") : \"none\";\n const deterministicCreateItemTypes = getDeterministicCreateItemTypes(snapshot.capabilities);\n const creatableItemTypes =\n deterministicCreateItemTypes.length > 0 ? deterministicCreateItemTypes.join(\", \") : \"none\";\n const rootItem = snapshot.inspection.outline.find((item) => item.depth === 0);\n const rootItemDescription = rootItem\n ? `${rootItem.fullKey} (id=${rootItem.itemId}, key=${rootItem.key})`\n : \"not found in the inspection outline\";\n const itemTypeDetails =\n snapshot.capabilities.itemTypes.length > 0\n ? snapshot.capabilities.itemTypes\n .map((entry) => {\n const primaryContentKey = entry.contentSurfaces.find(\n (surface) => surface.role === \"primary\",\n )?.key;\n const details = [\n `create=${entry.create}`,\n primaryContentKey ? `primary=${primaryContentKey}` : undefined,\n entry.authoring?.compactHint,\n ]\n .filter((value): value is string => Boolean(value))\n .join(\"; \");\n return details ? `${entry.itemType} (${details})` : entry.itemType;\n })\n .join(\", \")\n : \"none\";\n return [\n \"Use this live editor snapshot as the authoritative current survey state for this turn.\",\n `Only a derived snapshot header is included here. Use it directly for current view, selected item id, selected locale, survey key, root group, locale list, item count, and deterministically creatable item types. Item count excludes the structural root group; the authoritative raw survey remains available to inspection tools in request context.`,\n `Current view: ${snapshot.ui.view}`,\n `Selected item id: ${selectedItem}`,\n `Focused item id: ${focusedItem}`,\n `Recent item ids: ${recentItems}`,\n `Active UI surface: ${snapshot.ui.activeSurface ?? \"not provided\"}`,\n `Open UI panels: ${snapshot.ui.openPanels?.join(\", \") ?? \"not provided\"}`,\n `Highlighted UI targets: ${highlights}`,\n `History state: ${history ? `index=${history.currentIndex}; total=${history.totalEntries}; canUndo=${history.canUndo}; canRedo=${history.canRedo}; currentAction=${currentHistoryEntry?.label ?? \"not available\"}` : \"not provided\"}`,\n `Selected locale: ${snapshot.ui.selectedLocale}`,\n `Survey key: ${surveyKey}`,\n `Root group for top-level create-item target.parentItemId: ${rootItemDescription}`,\n `Survey locales: ${locales}`,\n `Survey item count (excluding the structural root group): ${snapshot.inspection.itemCount}`,\n `Deterministically creatable item types: ${creatableItemTypes}`,\n `Installed item capabilities (compact): ${itemTypeDetails}. Load a composed assistant-operations reference with operationKind and itemType for supported operations, configuration, content surfaces, and focused authoring guidance.`,\n ]\n .filter((line): line is string => Boolean(line))\n .join(\"\\n\");\n};\n\nconst formatDocumentTransition = (\n transition: SurveyAssistantRequestContext[\"documentTransition\"],\n): string => {\n if (!transition) {\n return \"Document continuity is unavailable because no live editor snapshot was provided.\";\n }\n\n if (transition.status === \"no-baseline\") {\n return [\n \"Document continuity: no settled baseline is available for comparison.\",\n \"Do not infer whether historical survey observations are still current. Inspect the targets relevant to the user's request before relying on prior survey state.\",\n ].join(\"\\n\");\n }\n\n if (transition.status === \"session-changed\") {\n return [\n \"Document continuity: the editor session changed since the last settled assistant turn.\",\n \"Treat all historical observations about survey content, structure, ids, and selections as stale. Inspect the current targets needed for this request.\",\n ].join(\"\\n\");\n }\n\n if (transition.status === \"unchanged\") {\n return [\n \"Document continuity: survey content is unchanged since the last settled assistant turn.\",\n transition.capabilitiesChanged\n ? \"Installed editor capabilities changed; re-check capability-dependent assumptions.\"\n : \"Relevant prior inspected survey facts may be reused, while the current snapshot and tools remain authoritative.\",\n ].join(\"\\n\");\n }\n\n const sources =\n transition.recordedSources.length > 0 ? transition.recordedSources.join(\", \") : \"unrecorded\";\n return [\n \"Document continuity: survey content changed since the last settled assistant turn.\",\n `History movement: ${transition.historyDirection}; recorded change sources: ${sources}.`,\n transition.capabilitiesChanged ? \"Installed editor capabilities also changed.\" : undefined,\n \"Treat historical observations about affected survey content, structure, ids, and expressions as potentially stale. Before answering or editing, inspect the current targets relevant to the user's request; do not reload unrelated survey state.\",\n ]\n .filter((line): line is string => Boolean(line))\n .join(\"\\n\");\n};\n\nconst buildInstructions = ({\n requestContext,\n}: {\n requestContext: RequestContext<SurveyAssistantRequestContext>;\n}) => {\n const snapshot = requestContext.get(\"engineContext\");\n const documentTransition = requestContext.get(\"documentTransition\");\n const attachmentAccess = requestContext.get(\"attachmentAccess\");\n const attachmentManifest = attachmentAccess?.documents.length\n ? attachmentAccess.documents\n .map((document) =>\n JSON.stringify({\n id: document.id,\n filename: document.name,\n mediaType: document.mediaType,\n attachmentRole: attachmentAccess.currentDocumentIds?.includes(document.id)\n ? \"current-message-context\"\n : \"stored\",\n }),\n )\n .join(\"\\n\")\n : \"none\";\n\n return [\n \"You help users inspect, explain, create, and edit CASE surveys in the Survey Editor.\",\n \"Infer whether the user wants an answer, explanation, critique, clarification, or concrete edit from their message and current editor context. Keep routine answers concise.\",\n \"Reply in the language of the user's current message unless they request another language. Respondent-facing survey text follows the requested survey locale, which may differ from the reply language.\",\n \"Authority order: the request-scoped survey draft and inspection tools define current turn state; the submitted snapshot is its immutable baseline and apply precondition; the capability manifest defines installed item behavior; authoring references define stable CASE conventions; Mastra memory is conversational history only.\",\n \"The capability manifest is authoritative for available item types, create modes, supported operations, content surfaces, response slots, and capability-owned references. Never guess unsupported item behavior.\",\n \"Never claim that an item type, field type, controller, operation, or other editor capability is unavailable unless the current capability manifest or a loaded authoring reference explicitly excludes it. For a capability question, inspect or load the focused reference before answering; if support remains unclear, say that it is unverified rather than unsupported.\",\n \"For an installed custom item type, use survey_authoring_reference with both itemType and one of its advertised reference topics before creating or changing unfamiliar config. Use survey_inspect item-details to obtain capability-provided inspection details for existing items.\",\n `Use ${INSPECT_TOOL_NAME} to inspect current draft context, UI context/highlights, recent editor history, search, item details, image assets, complete paged outlines, response slots, and exact raw JSON paths. Successful same-turn edits are immediately visible there. Use action \"assets\" to obtain explicit assetId values, metadata, and usage locations before asset changes; the key of /assets/<key> is the asset ID even though the stored asset object does not repeat it. Never guess what \"this\", \"here\", or \"the highlighted part\" refers to when the draft can resolve it. History explains recent actions but the current draft remains authoritative within the turn.`,\n `Use ${AUTHORING_REFERENCE_TOOL_NAME} to load one narrow convention when needed: core-rules, survey-data-model, source-material-surveys, localization, rich-text-content, item-types, embedded-forms, expressions, assistant-operations, or survey-quality. For item-types, pass itemType to load only the relevant installed type; omit itemType only for a genuine cross-type comparison. Load survey-quality before giving a substantive questionnaire-quality critique.`,\n `Use ${AUDIT_TOOL_NAME} for read-only deterministic technical checks and a structured questionnaire-quality review rubric. For quality feedback, combine its exact findings with survey-quality and inspect the relevant wording and flow. Clearly distinguish technical defects, design recommendations, and claims that would require cognitive testing or psychometric evidence.`,\n `Use ${CHANGE_TOOL_NAME} for typed survey operations and ${EXPRESSION_TOOL_NAME} for expressions. Prefer typed operations; use one inspected survey-json-patch operation only when no typed operation covers the requested field.`,\n `The typed ${CHANGE_TOOL_NAME} operations cover item structure/content/config, choices, forms, survey content, and assets. For an unfamiliar operation shape, load assistant-operations with operationKind and, when targeting an item type, itemType to receive a compact composed contract. Request full contract detail only for protocol debugging. Omit operationKind only when broader conventions are needed. Reorders replace the complete inspected list and use optionIds, groupIds, or itemIds as documented by the tool.`,\n \"Canonical create-item shape: put parentItemId and optional index in target; put id, key, itemType, config, and any creation-time expressions in item; put respondent-visible plainText or structured content in top-level translations. Put choice maxSelection and options inside item.config. For top-level creation, target the root group identified by the snapshot or inspection.\",\n \"Use update-item-translation with itemId, locale, contentKey, and plainText for ordinary respondent-visible text. Use content only for a complete structured Content value when formatting carries meaning. Item title, subtitle, topContent, bottomContent, cardFooter, info content, option labels, and field labels are translations, not item labels.\",\n \"Survey languages are locale branches. When the user asks to remove or delete a survey language, use remove-survey-locale with the exact existing locale code; load its assistant-operations contract before proposing the change. Never substitute translation-by-translation deletion or a raw patch. The final remaining locale cannot be removed.\",\n \"Use update-placed-image only for an image already embedded in rich text in the live survey or validated turn draft. It can switch the placement between a local asset and an external URL and update its rendered ALT text, caption, width, height, maximum dimensions, and alignment. For a new item, prefer putting the complete richText value with the image block directly in create-item.translations[].content. Do not use image asset metadata when the user asked to change one placed image.\",\n \"An unqualified request to add or change a survey item or question label means the editor-only item label and uses update-item-label. A question title/text, option label, or field label is respondent-visible translated content.\",\n \"A group is a hierarchy/container, not a decorative heading. Use a group for meaningful nested structure, an info item for standalone explanatory content, and a page break when only a respondent page boundary is needed. Create a non-root group empty, then create its children in parent-before-child order.\",\n \"Write respondent-visible content under its actual locale. A real typed translation may introduce a missing locale; never place target-language text under an existing wrong locale or create dummy content merely to introduce a locale.\",\n \"Use plainText for ordinary unformatted copy. Load rich-text-content and use structured richText only for meaningful headings, lists, emphasis, links, images, info boxes, or other formatting. Markdown syntax inside md/plain content is not rendered as rich formatting.\",\n \"Do not refuse an edit merely because no narrow typed operation exists. Inspect the exact current raw item/path and use survey-json-patch for assistant-editable survey fields that have no typed or expression helper.\",\n \"A survey-json-patch proposal contains exactly one operation with kind survey-json-patch and one plural patches array containing every related raw edit. It must be the only operation in that survey_change call. Paths are rooted at the survey document, such as /surveyItems/<index>/config or /translations/<locale>; never start at /config or modify /$schema. Patch translation leaves rather than replacing existing locale or item-translation containers.\",\n \"A choice free-text follow-up such as Other, please specify is an option embeddedForm, not allowOther. Load embedded-forms and prefer set-embedded-form with its relative translations. If the option is also new, put add-choice-option with an explicit id immediately before set-embedded-form in the same survey_change proposal. Use a raw patch only when the typed operations cannot express the requested change.\",\n \"For choiceItem, maxSelection 1 is single choice, null is unlimited multiple choice, and a positive number is capped multiple choice. Choice config options use ids/keys/configuration; respondent-visible option labels belong in translations at options.<optionId>.label.\",\n \"Every form or embedded-form select option needs a visible translation. Do not rely on raw controller values as respondent labels.\",\n \"When the user asks to implement or convert supplied source material, completeness is part of the task. Load source-material-surveys and implement coherent bounded chunks without sampling or silently omitting difficult respondent content.\",\n `Files attached to the current user message are already available directly. When an earlier stored attachment is relevant, call ${ATTACHMENT_TOOL_NAME} with only the needed document ids before answering or editing. Always load the relevant stored source for factual document questions or source-faithful authoring; conversational memory is not a lossless copy. After the tool succeeds, the selected original PDFs/images are attached to your next model input: read them directly and continue the task. Never claim that a successfully loaded attachment is unavailable, ask for extracted text, or describe the attachment tool as an extraction limitation. Do not load unrelated attachments, and do not ask the user to upload a listed file again.`,\n `Use ${ASSET_TOOL_NAME} to import an attached image into the turn draft without copying base64 through ${CHANGE_TOOL_NAME}, and to update or remove unreferenced image-asset metadata. A successful import makes its asset id available to later mutation calls in the same turn. To delete referenced images and their assets together, make one ${CHANGE_TOOL_NAME} call containing the reference-removal operations first and remove-image-asset last. Never import an image merely because it is attached; do so only when the user asks to use it as survey content.`,\n \"For branching, conditions, expression validations, prefills, and template values, use survey_expression with exact inspected response refs and value types. Creation-time expressions may also be embedded directly in create-item.\",\n `Mutation tools maintain one request-scoped draft. Each successful call adds only its new delta, and later calls may target ids or assets created by earlier successful calls. The live editor remains unchanged during the response. Successful turn completion authorizes only the latest cumulative draft, which the editor applies as one undoable change.`,\n \"A rejected mutation leaves the validated draft unchanged and blocks turn authorization. Correct the same rejected target in another mutation call; unrelated valid edits do not clear the block. Never drop requested behavior merely to obtain validation.\",\n \"Prefer one mutation call for an ordinary request. Split work only for genuine dependencies or bounded chunks; accumulation is automatic.\",\n \"Before answering, reconcile every requested target against the latest validated draft. Never claim rejected, missing, partial, or failed work was completed. If a request remains incomplete, correct it once or state the exact remaining work.\",\n \"When required structure or behavior is clear but ordinary respondent wording is open, choose concise, neutral, internally consistent wording. Ask only when ambiguity materially affects purpose, domain, language, or compliance.\",\n \"For concrete supported edits, inspect the relevant live state, load every reference explicitly required above before the first mutation attempt, prepare the complete change, then summarize only the final validated candidates concisely. Do not ask the user to choose an output mode.\",\n \"Do not write tool syntax, hidden chain-of-thought, or invented validation results in normal text. Never claim persistence outside the editor.\",\n `Attachment document ids available for explicit loading or asset import:\\n${attachmentManifest}`,\n formatDocumentTransition(documentTransition),\n formatCurrentEditorContext(snapshot),\n ].join(\"\\n\\n\");\n};\n\ntype SurveyAssistantAgentConfig = AgentConfig<\n typeof SURVEY_ASSISTANT_AGENT_ID,\n typeof surveyAssistantTools,\n undefined,\n SurveyAssistantRequestContext\n>;\n\ntype SurveyAssistantMemoryOptions = NonNullable<\n NonNullable<ConstructorParameters<typeof Memory>[0]>[\"options\"]\n>;\n\nconst isInitialMessageRecall = (inputData: unknown): inputData is Record<string, unknown> => {\n if (!inputData || typeof inputData !== \"object\" || Array.isArray(inputData)) return false;\n\n const input = inputData as Record<string, unknown>;\n const mode = input.mode;\n const hasCursor = typeof input.cursor === \"string\" && input.cursor.length > 0;\n const hasThreadId = typeof input.threadId === \"string\" && input.threadId.length > 0;\n return (mode === undefined || mode === \"messages\") && !hasCursor && !hasThreadId;\n};\n\n// Mastra's thread-scoped recall schema omits threadId and rejects the first page\n// when the model provides neither a cursor nor a thread ID. Bind the active\n// thread internally so retrieval stays thread-scoped instead of widening to a resource.\nclass ThreadScopedSurveyAssistantMemory extends Memory {\n override listTools(config?: Parameters<Memory[\"listTools\"]>[0]) {\n const tools = super.listTools(config);\n const recall = tools.recall;\n if (!recall?.execute) return tools;\n\n const executeRecall = recall.execute;\n return {\n ...tools,\n recall: {\n ...recall,\n execute: async (\n inputData: Parameters<typeof executeRecall>[0],\n context: Parameters<typeof executeRecall>[1],\n ) => {\n if (!isInitialMessageRecall(inputData)) return executeRecall(inputData, context);\n\n const threadId = context.agent?.threadId;\n return executeRecall(threadId ? { ...inputData, threadId } : inputData, context);\n },\n },\n };\n }\n}\n\nexport type SurveyAssistantObservationalMemoryOptions = Exclude<\n SurveyAssistantMemoryOptions[\"observationalMemory\"],\n boolean | undefined\n>;\n\ntype SurveyAssistantObservationalMemoryOptionsInput = Partial<\n Omit<SurveyAssistantObservationalMemoryOptions, \"model\">\n> & {\n model: NonNullable<SurveyAssistantObservationalMemoryOptions[\"model\"]>;\n};\n\nexport const SURVEY_ASSISTANT_OBSERVATIONAL_MEMORY_DEFAULTS = {\n messageTokens: 48_000,\n observationTokens: 80_000,\n previousObserverTokens: 24_000,\n} as const;\n\nexport const createSurveyAssistantObservationalMemoryOptions = ({\n model,\n observation,\n reflection,\n ...overrides\n}: SurveyAssistantObservationalMemoryOptionsInput): SurveyAssistantObservationalMemoryOptions => ({\n model,\n scope: \"thread\",\n activateAfterIdle: false,\n activateOnProviderChange: true,\n retrieval: { scope: \"thread\" },\n shareTokenBudget: false,\n temporalMarkers: false,\n ...overrides,\n observation: {\n messageTokens: SURVEY_ASSISTANT_OBSERVATIONAL_MEMORY_DEFAULTS.messageTokens,\n bufferTokens: 0.2,\n bufferActivation: 0.75,\n blockAfter: 1.5,\n bufferOnIdle: false,\n previousObserverTokens: SURVEY_ASSISTANT_OBSERVATIONAL_MEMORY_DEFAULTS.previousObserverTokens,\n threadTitle: true,\n observeAttachments: false,\n instruction:\n \"Prioritize the user's survey-authoring requirements, corrections, decisions, referenced source sections, unfinished tasks, and what the assistant actually completed or failed to complete. Preserve exact wording when the user marks it as required. Treat survey ids, structure, translations, expressions, selections, and tool output as historical observations only; the live editor snapshot and survey tools remain authoritative for current state. Do not imply that an attached source document was preserved when only its conversational use was observed.\",\n ...observation,\n },\n reflection: {\n observationTokens: SURVEY_ASSISTANT_OBSERVATIONAL_MEMORY_DEFAULTS.observationTokens,\n bufferActivation: 0.5,\n blockAfter: 1.5,\n activateAfterIdle: false,\n activateOnProviderChange: true,\n instruction:\n \"Consolidate related survey requirements and decisions while preserving corrections, explicit constraints, unresolved work, source references, and completion or failure status. Remove superseded assumptions and repetitive tool detail. Never promote historical survey state into current truth and never summarize an attachment as though it were a lossless copy of the source.\",\n ...reflection,\n },\n});\n\nexport interface CreateSurveyAssistantAgentOptions {\n model: SurveyAssistantAgentConfig[\"model\"];\n memory?: SurveyAssistantAgentConfig[\"memory\"];\n observationalMemory?: SurveyAssistantObservationalMemoryOptions | false;\n}\n\nexport const createSurveyAssistantAgent = ({\n memory,\n model,\n observationalMemory,\n}: CreateSurveyAssistantAgentOptions) =>\n new Agent<\n typeof SURVEY_ASSISTANT_AGENT_ID,\n typeof surveyAssistantTools,\n undefined,\n SurveyAssistantRequestContext\n >({\n id: SURVEY_ASSISTANT_AGENT_ID,\n name: \"Survey Assistant\",\n instructions: buildInstructions,\n model,\n tools: surveyAssistantTools,\n memory:\n memory ??\n new ThreadScopedSurveyAssistantMemory({\n options: {\n lastMessages: false,\n observationalMemory:\n observationalMemory === false\n ? false\n : (observationalMemory ??\n createSurveyAssistantObservationalMemoryOptions({\n model: model as NonNullable<SurveyAssistantObservationalMemoryOptions[\"model\"]>,\n })),\n },\n }),\n inputProcessors: [surveyAssistantThreadAttachmentProcessor],\n });\n"],"mappings":";;;;;;;AA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CAC5D,CAAC"}
@@ -1,9 +1,9 @@
1
- import { S as SurveyAssistantModelCatalog } from "./index-DVxVyhAu.mjs";
2
- import { Ft as SurveyAssistantCapabilitySet } from "./index-DZ6KBwVR.mjs";
1
+ import { S as SurveyAssistantModelCatalog } from "./index-MEOL9_Gr.mjs";
2
+ import { Nt as SurveyAssistantCapabilitySet } from "./index-JXH-t2EJ.mjs";
3
3
  import { a as SurveyAssistantThreadDocumentRepository } from "./thread-documents-BlxNjc7S.mjs";
4
4
  import { SurveyAssistantObservationalMemoryOptions, createSurveyAssistantAgent } from "./server-agent.mjs";
5
- import { O as SurveyAssistantRequestLimits, c as SurveyAssistantAuthorize, f as SurveyAssistantResolveModel, t as CreateSurveyAssistantThreadHandlersOptions, u as SurveyAssistantChatHandlerOptions } from "./thread-handlers-l79JBl5m.mjs";
6
- import { c as createSurveyAssistantTaskAgent, n as CreateSurveyAssistantTaskHandlerOptions, s as SurveyAssistantTaskModelResolutionInput } from "./tasks-COQnhSeT.mjs";
5
+ import { O as SurveyAssistantRequestLimits, c as SurveyAssistantAuthorize, f as SurveyAssistantResolveModel, t as CreateSurveyAssistantThreadHandlersOptions, u as SurveyAssistantChatHandlerOptions } from "./thread-handlers-uddXwQjp.mjs";
6
+ import { c as createSurveyAssistantTaskAgent, n as CreateSurveyAssistantTaskHandlerOptions, s as SurveyAssistantTaskModelResolutionInput } from "./tasks-DcfQNJwO.mjs";
7
7
  import { AgentExecutionOptions } from "@mastra/core/agent";
8
8
  import { AzureOpenAIGatewayConfig, MastraModelGatewayInterface } from "@mastra/core/llm";
9
9
  import { Mastra } from "@mastra/core/mastra";
@@ -1,7 +1,7 @@
1
1
  import { n as SURVEY_ASSISTANT_TASK_AGENT_ID, t as SURVEY_ASSISTANT_AGENT_ID } from "./constants-CFUWrRtl.mjs";
2
2
  import { n as SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS } from "./request-guardrails-h4t6u8mP.mjs";
3
- import { i as createSurveyAssistantChatHandler, n as createSurveyAssistantThreadHandlers, r as SurveyAssistantAuthorizationError, t as createMastraMemoryThreadRepository } from "./memory-thread-repository-Cm1BJyRw.mjs";
4
- import { t as SURVEY_ASSISTANT_TOOL_IDS } from "./tools-DDXaJ8Za.mjs";
3
+ import { i as createSurveyAssistantChatHandler, n as createSurveyAssistantThreadHandlers, r as SurveyAssistantAuthorizationError, t as createMastraMemoryThreadRepository } from "./memory-thread-repository-1ocPOda8.mjs";
4
+ import { t as SURVEY_ASSISTANT_TOOL_IDS } from "./tools-wgLen05n.mjs";
5
5
  import { SURVEY_ASSISTANT_OBSERVATIONAL_MEMORY_DEFAULTS, createSurveyAssistantAgent, createSurveyAssistantObservationalMemoryOptions } from "./server-agent.mjs";
6
6
  import { createSurveyAssistantTaskAgent, createSurveyAssistantTaskHandler } from "./server-tasks.mjs";
7
7
  import { AzureOpenAIGateway } from "@mastra/core/llm";
@@ -1,2 +1,2 @@
1
- import { a as SurveyAssistantTaskAuthorizationInput, c as createSurveyAssistantTaskAgent, d as runSurveyAssistantSuggestItemLabelTask, f as runSurveyAssistantTask, i as RunSurveyAssistantTaskOptions, l as createSurveyAssistantTaskHandler, n as CreateSurveyAssistantTaskHandlerOptions, o as SurveyAssistantTaskAuthorizedIdentity, p as runSurveyAssistantTranslateContentTask, r as RunSurveyAssistantBuiltInTaskOptions, s as SurveyAssistantTaskModelResolutionInput, t as CreateSurveyAssistantTaskAgentOptions, u as runSurveyAssistantSuggestItemKeyTask } from "./tasks-COQnhSeT.mjs";
1
+ import { a as SurveyAssistantTaskAuthorizationInput, c as createSurveyAssistantTaskAgent, d as runSurveyAssistantSuggestItemLabelTask, f as runSurveyAssistantTask, i as RunSurveyAssistantTaskOptions, l as createSurveyAssistantTaskHandler, n as CreateSurveyAssistantTaskHandlerOptions, o as SurveyAssistantTaskAuthorizedIdentity, p as runSurveyAssistantTranslateContentTask, r as RunSurveyAssistantBuiltInTaskOptions, s as SurveyAssistantTaskModelResolutionInput, t as CreateSurveyAssistantTaskAgentOptions, u as runSurveyAssistantSuggestItemKeyTask } from "./tasks-DcfQNJwO.mjs";
2
2
  export { CreateSurveyAssistantTaskAgentOptions, CreateSurveyAssistantTaskHandlerOptions, RunSurveyAssistantBuiltInTaskOptions, RunSurveyAssistantTaskOptions, SurveyAssistantTaskAuthorizationInput, SurveyAssistantTaskAuthorizedIdentity, SurveyAssistantTaskModelResolutionInput, createSurveyAssistantTaskAgent, createSurveyAssistantTaskHandler, runSurveyAssistantSuggestItemKeyTask, runSurveyAssistantSuggestItemLabelTask, runSurveyAssistantTask, runSurveyAssistantTranslateContentTask };
@@ -1,4 +1,4 @@
1
- import { C as surveyAssistantTaskRequestSchema } from "./protocol-7EEgcYja.mjs";
1
+ import { C as surveyAssistantTaskRequestSchema } from "./protocol-DpCYmCjr.mjs";
2
2
  import { n as SURVEY_ASSISTANT_TASK_AGENT_ID } from "./constants-CFUWrRtl.mjs";
3
3
  import { d as readSurveyAssistantRequestJson, u as SurveyAssistantRequestError } from "./request-guardrails-h4t6u8mP.mjs";
4
4
  import { r as surveyAuthoringReferences } from "./authoring-references-DYuOAdVx.mjs";
@@ -1,2 +1,2 @@
1
- import { i as surveyAuditTool, n as surveyAssistantTools, r as surveyAssetTool, t as SURVEY_ASSISTANT_TOOL_IDS } from "./index-B_x2IYi7.mjs";
1
+ import { i as surveyAuditTool, n as surveyAssistantTools, r as surveyAssetTool, t as SURVEY_ASSISTANT_TOOL_IDS } from "./index-BcyfBeDj.mjs";
2
2
  export { SURVEY_ASSISTANT_TOOL_IDS, surveyAssetTool, surveyAssistantTools, surveyAuditTool };
@@ -1,2 +1,2 @@
1
- import { i as surveyAuditTool, n as surveyAssistantTools, r as surveyAssetTool, t as SURVEY_ASSISTANT_TOOL_IDS } from "./tools-DDXaJ8Za.mjs";
1
+ import { i as surveyAuditTool, n as surveyAssistantTools, r as surveyAssetTool, t as SURVEY_ASSISTANT_TOOL_IDS } from "./tools-wgLen05n.mjs";
2
2
  export { SURVEY_ASSISTANT_TOOL_IDS, surveyAssetTool, surveyAssistantTools, surveyAuditTool };
package/dist/server.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { g as TurnChangeCollector } from "./index-DZ6KBwVR.mjs";
1
+ import { f as TurnSurveyDraft } from "./index-JXH-t2EJ.mjs";
2
2
  import { a as SurveyAssistantThreadDocumentRepository, c as loadSurveyAssistantThreadAttachments, d as replaceCurrentSurveyAssistantAttachmentsWithReferences, i as SurveyAssistantThreadDocumentContent, l as registerSurveyAssistantThreadAttachments, n as SurveyAssistantModelAttachment, o as getSurveyAssistantReplayableDocuments, r as SurveyAssistantThreadDocument, s as loadSurveyAssistantDocuments, t as SurveyAssistantAttachmentAccess, u as removeHistoricalSurveyAssistantAttachments } from "./thread-documents-BlxNjc7S.mjs";
3
- import { a as SurveyAssistantModelSelection, c as deriveSurveyAssistantDocumentTransition, d as requireSurveyAssistantTurnState, i as SurveyAssistantIdentityContext, l as parseSurveyAssistantPreviousSettledVersion, n as SURVEY_ASSISTANT_TASK_AGENT_ID, o as SurveyAssistantRequestContext, r as SurveyAssistantDocumentTransition, s as buildSurveyAssistantRequestContext, t as SURVEY_ASSISTANT_AGENT_ID, u as parseSurveyAssistantSnapshot } from "./constants-56jf_4ls.mjs";
4
- import { A as validateSurveyAssistantMessages, C as SURVEY_ASSISTANT_MAX_MESSAGES, D as SurveyAssistantRequestError, E as SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES, O as SurveyAssistantRequestLimits, S as SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS, T as SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS, _ as formatSurveyAssistantStreamError, a as createSurveyAssistantThreadHandlers, b as SURVEY_ASSISTANT_MAX_ATTACHMENTS, c as SurveyAssistantAuthorize, d as SurveyAssistantModelResolutionInput, f as SurveyAssistantResolveModel, g as describeSurveyAssistantStreamError, h as createSurveyAssistantChatHandler, i as SurveyAssistantThreadRepository, k as readSurveyAssistantRequestJson, l as SurveyAssistantAuthorizedIdentity, m as SurveyAssistantTurnMetrics, n as SurveyAssistantStoredThread, o as SurveyAssistantAuthorizationError, p as SurveyAssistantStreamErrorContext, r as SurveyAssistantThreadIdentity, s as SurveyAssistantAuthorizationInput, t as CreateSurveyAssistantThreadHandlersOptions, u as SurveyAssistantChatHandlerOptions, v as SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES, w as SURVEY_ASSISTANT_MAX_REQUEST_BYTES, x as SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES, y as SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS } from "./thread-handlers-l79JBl5m.mjs";
5
- import { a as SurveyAssistantTaskAuthorizationInput, g as surveyAuthoringReferences, h as surveyAuthoringReferenceTopics, m as SurveyAuthoringReferenceTopic, o as SurveyAssistantTaskAuthorizedIdentity } from "./tasks-COQnhSeT.mjs";
3
+ import { a as SurveyAssistantModelSelection, c as deriveSurveyAssistantDocumentTransition, d as requireSurveyAssistantTurnState, i as SurveyAssistantIdentityContext, l as parseSurveyAssistantPreviousSettledVersion, n as SURVEY_ASSISTANT_TASK_AGENT_ID, o as SurveyAssistantRequestContext, r as SurveyAssistantDocumentTransition, s as buildSurveyAssistantRequestContext, t as SURVEY_ASSISTANT_AGENT_ID, u as parseSurveyAssistantSnapshot } from "./constants-D-5m_KGB.mjs";
4
+ import { A as validateSurveyAssistantMessages, C as SURVEY_ASSISTANT_MAX_MESSAGES, D as SurveyAssistantRequestError, E as SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES, O as SurveyAssistantRequestLimits, S as SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS, T as SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS, _ as formatSurveyAssistantStreamError, a as createSurveyAssistantThreadHandlers, b as SURVEY_ASSISTANT_MAX_ATTACHMENTS, c as SurveyAssistantAuthorize, d as SurveyAssistantModelResolutionInput, f as SurveyAssistantResolveModel, g as describeSurveyAssistantStreamError, h as createSurveyAssistantChatHandler, i as SurveyAssistantThreadRepository, k as readSurveyAssistantRequestJson, l as SurveyAssistantAuthorizedIdentity, m as SurveyAssistantTurnMetrics, n as SurveyAssistantStoredThread, o as SurveyAssistantAuthorizationError, p as SurveyAssistantStreamErrorContext, r as SurveyAssistantThreadIdentity, s as SurveyAssistantAuthorizationInput, t as CreateSurveyAssistantThreadHandlersOptions, u as SurveyAssistantChatHandlerOptions, v as SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES, w as SURVEY_ASSISTANT_MAX_REQUEST_BYTES, x as SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES, y as SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS } from "./thread-handlers-uddXwQjp.mjs";
5
+ import { a as SurveyAssistantTaskAuthorizationInput, g as surveyAuthoringReferences, h as surveyAuthoringReferenceTopics, m as SurveyAuthoringReferenceTopic, o as SurveyAssistantTaskAuthorizedIdentity } from "./tasks-DcfQNJwO.mjs";
6
6
  import { UIMessageChunk } from "ai";
7
7
  import { MastraMemory } from "@mastra/core/memory";
8
8
 
@@ -103,13 +103,13 @@ declare const createSurveyAssistantSurveyLifecycle: ({
103
103
  //#region src/server/turn-stream.d.ts
104
104
  interface SurveyAssistantTurnStreamOptions {
105
105
  stream: ReadableStream<UIMessageChunk>;
106
- changeCollector: TurnChangeCollector;
106
+ turnDraft: TurnSurveyDraft;
107
107
  signal?: AbortSignal;
108
108
  onUnexpectedError?: (error: unknown) => string;
109
109
  onSettled?: () => void;
110
110
  }
111
111
  declare const createSurveyAssistantTurnStream: ({
112
- changeCollector,
112
+ turnDraft,
113
113
  onSettled,
114
114
  onUnexpectedError,
115
115
  signal,
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.mts","names":[],"sources":["../src/server/memory-thread-repository.ts","../src/server/survey-lifecycle.ts","../src/server/turn-stream.ts"],"mappings":";;;;;;;;;KAKK,YAAA,GAAe,IAAA,CAClB,YAAA;AAAA,UAIe,yCAAA;EACf,SAAA,IAAa,Y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AAA;EAA6C,aAAA;EAAA;AAAA;EAIxD,aAAA,EAAe,MAAA;EACf,QAAA;AAAA,MACE,MAAA;;;;;AAzGJ;;cAuHa,oCAAA;EAAwC,SAAA;EAAA,YAAA;EAAA,aAAA;EAAA;AAAA,GAKlD,2CAAA,KAA8C,8BAAA;;;UCrIhC,gCAAA;EACf,MAAA,EAAQ,cAAA,CAAe,cAAA;EACvB,eAAA,EAAiB,mBAAA;EACjB,MAAA,GAAS,WAAA;EACT,iBAAA,IAAqB,KAAA;EACrB,SAAA;AAAA;AAAA,cAGW,+BAAA;EAAmC,eAAA;EAAA,SAAA;EAAA,iBAAA;EAAA,MAAA;EAAA;AAAA,GAM7C,gCAAA,KAAmC,cAAA,CAAe,cAAA"}
1
+ {"version":3,"file":"server.d.mts","names":[],"sources":["../src/server/memory-thread-repository.ts","../src/server/survey-lifecycle.ts","../src/server/turn-stream.ts"],"mappings":";;;;;;;;;KAKK,YAAA,GAAe,IAAA,CAClB,YAAA;AAAA,UAIe,yCAAA;EACf,SAAA,IAAa,YAAA,GAAe,OAAA,CAAQ,YAAA;;EAEpC,wBAAA;;EAEA,iBAAA;EACA,eAAA,GAAkB,uCAAA;AAAA;AAAA,cAGP,kCAAA;EAAsC,SAAA;EAAA,wBAAA;EAAA,iBAAA;EAAA;AAAA,GAKhD,yCAAA,KAA4C,+BAAA;;;cCTlC,uCAAA;AAAA,KAER,qBAAA,GAAwB,IAAA,CAC3B,YAAA;AAAA,UAIe,2CAAA;EACf,SAAA,IAAa,qBAAA,GAAwB,OAAA,CAAQ,qBAAA;EDlB1C;ECoBH,YAAA,EAAc,QAAA;;;;ADfhB;ECoBE,aAAA,EAAe,MAAA;;;;;EAKf,eAAA,EAAiB,uCAAA;AAAA;AAAA,UAGF,uCAAA;EACf,QAAA;ED5Ba;EC8Bb,UAAA;AAAA;AAAA,UAGe,kCAAA;EACf,gBAAA;EACA,kBAAA;AAAA;AAAA,KAGU,wCAAA,GAA2C,kCAAA;AAAA,UAEtC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.mjs";
2
- import { a as requireSurveyAssistantTurnState, i as parseSurveyAssistantSnapshot, n as deriveSurveyAssistantDocumentTransition, r as parseSurveyAssistantPreviousSettledVersion, t as buildSurveyAssistantRequestContext } from "./request-context-BDBw4-Gw.mjs";
2
+ import { a as parseSurveyAssistantSnapshot, i as parseSurveyAssistantPreviousSettledVersion, n as deriveSurveyAssistantDocumentTransition, o as requireSurveyAssistantTurnState, t as buildSurveyAssistantRequestContext } from "./request-context-BBzU3VdG.mjs";
3
3
  import { a as SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS, c as SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS, d as readSurveyAssistantRequestJson, f as validateSurveyAssistantMessages, i as SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES, l as SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES, n as SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS, o as SURVEY_ASSISTANT_MAX_MESSAGES, r as SURVEY_ASSISTANT_MAX_ATTACHMENTS, s as SURVEY_ASSISTANT_MAX_REQUEST_BYTES, t as SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES, u as SurveyAssistantRequestError } from "./request-guardrails-h4t6u8mP.mjs";
4
- import { a as describeSurveyAssistantStreamError, c as loadSurveyAssistantDocuments, d as removeHistoricalSurveyAssistantAttachments, f as replaceCurrentSurveyAssistantAttachmentsWithReferences, i as createSurveyAssistantChatHandler, l as loadSurveyAssistantThreadAttachments, n as createSurveyAssistantThreadHandlers, o as formatSurveyAssistantStreamError, p as createSurveyAssistantTurnStream, r as SurveyAssistantAuthorizationError, s as getSurveyAssistantReplayableDocuments, t as createMastraMemoryThreadRepository, u as registerSurveyAssistantThreadAttachments } from "./memory-thread-repository-Cm1BJyRw.mjs";
4
+ import { a as describeSurveyAssistantStreamError, c as loadSurveyAssistantDocuments, d as removeHistoricalSurveyAssistantAttachments, f as replaceCurrentSurveyAssistantAttachmentsWithReferences, i as createSurveyAssistantChatHandler, l as loadSurveyAssistantThreadAttachments, n as createSurveyAssistantThreadHandlers, o as formatSurveyAssistantStreamError, p as createSurveyAssistantTurnStream, r as SurveyAssistantAuthorizationError, s as getSurveyAssistantReplayableDocuments, t as createMastraMemoryThreadRepository, u as registerSurveyAssistantThreadAttachments } from "./memory-thread-repository-1ocPOda8.mjs";
5
5
  import { n as surveyAuthoringReferenceTopics, r as surveyAuthoringReferences } from "./authoring-references-DYuOAdVx.mjs";
6
6
  //#region src/server/survey-lifecycle.ts
7
7
  const SURVEY_ASSISTANT_SURVEY_ID_METADATA_KEY = "surveyId";
@@ -1,5 +1,5 @@
1
- import { A as SurveyAssistantSuggestItemKeyResult, B as SurveyAssistantTranslateContentResult, F as SurveyAssistantTaskInvocationMode, M as SurveyAssistantSuggestItemLabelResult, P as SurveyAssistantTaskContext, j as SurveyAssistantSuggestItemLabelInput, k as SurveyAssistantSuggestItemKeyInput, z as SurveyAssistantTranslateContentInput } from "./index-DVxVyhAu.mjs";
2
- import { a as SurveyAssistantModelSelection, n as SURVEY_ASSISTANT_TASK_AGENT_ID, o as SurveyAssistantRequestContext } from "./constants-56jf_4ls.mjs";
1
+ import { A as SurveyAssistantSuggestItemKeyResult, B as SurveyAssistantTranslateContentResult, F as SurveyAssistantTaskInvocationMode, M as SurveyAssistantSuggestItemLabelResult, P as SurveyAssistantTaskContext, j as SurveyAssistantSuggestItemLabelInput, k as SurveyAssistantSuggestItemKeyInput, z as SurveyAssistantTranslateContentInput } from "./index-MEOL9_Gr.mjs";
2
+ import { a as SurveyAssistantModelSelection, n as SURVEY_ASSISTANT_TASK_AGENT_ID, o as SurveyAssistantRequestContext } from "./constants-D-5m_KGB.mjs";
3
3
  import { z } from "zod";
4
4
  import { RequestContext } from "@mastra/core/request-context";
5
5
  import * as _$_mastra_core_agent0 from "@mastra/core/agent";
@@ -137,4 +137,4 @@ declare const createSurveyAssistantTaskHandler: ({
137
137
  }: CreateSurveyAssistantTaskHandlerOptions) => (request: Request) => Promise<Response>;
138
138
  //#endregion
139
139
  export { SurveyAssistantTaskAuthorizationInput as a, createSurveyAssistantTaskAgent as c, runSurveyAssistantSuggestItemLabelTask as d, runSurveyAssistantTask as f, surveyAuthoringReferences as g, surveyAuthoringReferenceTopics as h, RunSurveyAssistantTaskOptions as i, createSurveyAssistantTaskHandler as l, SurveyAuthoringReferenceTopic as m, CreateSurveyAssistantTaskHandlerOptions as n, SurveyAssistantTaskAuthorizedIdentity as o, runSurveyAssistantTranslateContentTask as p, RunSurveyAssistantBuiltInTaskOptions as r, SurveyAssistantTaskModelResolutionInput as s, CreateSurveyAssistantTaskAgentOptions as t, runSurveyAssistantSuggestItemKeyTask as u };
140
- //# sourceMappingURL=tasks-COQnhSeT.d.mts.map
140
+ //# sourceMappingURL=tasks-DcfQNJwO.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tasks-COQnhSeT.d.mts","names":[],"sources":["../src/server/authoring-references.ts","../src/server/tasks.ts"],"mappings":";;;;;;;;cAMa,8BAAA;AAAA,KAaD,6BAAA,WAAwC,8BAAA;AAAA,cAyBvC,yBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KClBR,8BAAA,GAAiC,WAAA,QAC7B,8BAAA,EACP,MAAA,4BAEA,6BAAA;AAAA,UAGe,qCAAA;EACf,KAAA,EAAO,8BAAA;AAAA;AAAA,cAGI,8BAAA;EAAkC;AAAA,GAAW,qCAAA,KAAqC,KAAA,gCAAA,MAAA,4BAAA,6BAAA,EAAA,qBAAA,CAAA,iBAAA;AAAA,UAc9E,6BAAA,iBAA8C,CAAA,CAAE,OAAA;EAC/D,KAAA,EAAO,IAAA,CAAK,KAAA;EACZ,MAAA;EACA,KAAA;EACA,OAAA,EAAS,0BAAA;EACT,MAAA,EAAQ,OAAA;EACR,YAAA;EACA,eAAA,YAA2B,6BAAA;EAC3B,cAAA,GAAiB,cAAA,CAAe,6BAAA;EAChC,eAAA,GAAkB,qBAAA;EAClB,WAA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,QAAA;AAAA,MACE,OAAA,CAAQ,8BAAA"}
@@ -1,6 +1,6 @@
1
- import { Ft as SurveyAssistantCapabilitySet } from "./index-DZ6KBwVR.mjs";
1
+ import { Nt as SurveyAssistantCapabilitySet } from "./index-JXH-t2EJ.mjs";
2
2
  import { a as SurveyAssistantThreadDocumentRepository } from "./thread-documents-BlxNjc7S.mjs";
3
- import { a as SurveyAssistantModelSelection, i as SurveyAssistantIdentityContext } from "./constants-56jf_4ls.mjs";
3
+ import { a as SurveyAssistantModelSelection, i as SurveyAssistantIdentityContext } from "./constants-D-5m_KGB.mjs";
4
4
  import { UIMessage } from "ai";
5
5
  import { AgentExecutionOptions } from "@mastra/core/agent";
6
6
  import { Mastra } from "@mastra/core/mastra";
@@ -142,4 +142,4 @@ declare const createSurveyAssistantThreadHandlers: ({
142
142
  };
143
143
  //#endregion
144
144
  export { validateSurveyAssistantMessages as A, SURVEY_ASSISTANT_MAX_MESSAGES as C, SurveyAssistantRequestError as D, SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES as E, SurveyAssistantRequestLimits as O, SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS as S, SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS as T, formatSurveyAssistantStreamError as _, createSurveyAssistantThreadHandlers as a, SURVEY_ASSISTANT_MAX_ATTACHMENTS as b, SurveyAssistantAuthorize as c, SurveyAssistantModelResolutionInput as d, SurveyAssistantResolveModel as f, describeSurveyAssistantStreamError as g, createSurveyAssistantChatHandler as h, SurveyAssistantThreadRepository as i, readSurveyAssistantRequestJson as k, SurveyAssistantAuthorizedIdentity as l, SurveyAssistantTurnMetrics as m, SurveyAssistantStoredThread as n, SurveyAssistantAuthorizationError as o, SurveyAssistantStreamErrorContext as p, SurveyAssistantThreadIdentity as r, SurveyAssistantAuthorizationInput as s, CreateSurveyAssistantThreadHandlersOptions as t, SurveyAssistantChatHandlerOptions as u, SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES as v, SURVEY_ASSISTANT_MAX_REQUEST_BYTES as w, SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES as x, SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS as y };
145
- //# sourceMappingURL=thread-handlers-l79JBl5m.d.mts.map
145
+ //# sourceMappingURL=thread-handlers-uddXwQjp.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"thread-handlers-l79JBl5m.d.mts","names":[],"sources":["../src/server/request-guardrails.ts","../src/server/handler.ts","../src/server/thread-handlers.ts"],"mappings":";;;;;;;;cAEa,kCAAA;AAAA,cACA,6BAAA;AAAA,cACA,gCAAA;AAAA,cACA,qCAAA;AAAA,cACA,2CAAA;AAAA,cACA,oCAAA;AAAA,cACA,0CAAA;AAAA,cAEA,0CAAA,EAA0C,GAAA;AAAA,UAQtC,4BAAA;EACf,uBAAA,EAAyB,WAAA;EACzB,kBAAA;EACA,sBAAA;EACA,cAAA;EACA,WAAA;EACA,eAAA;EACA,gBAAA;EACA,uBAAA;AAAA;AAAA,cAGW,uCAAA,EAAyC,4BAAA;AAAA,cAWzC,2BAAA,SAAoC,KAAA;EAAA,SACtC,MAAA;cAEG,OAAA,UAAiB,MAAA;AAAA;AAAA,cAoDlB,+BAAA,GACX,KAAA,WACA,MAAA,GAAQ,4BAAA,KACP,SAAA;AAAA,cAmFU,8BAAA,GACX,OAAA,EAAS,OAAA,EACT,eAAA,cACC,OAAA;;;KCzIE,eAAA,GAAkB,qBAAA;AAAA,UAEN,iCAAA;EACf,OAAA,EAAS,OAAA;EACT,mBAAA;EACA,iBAAA;EACA,iBAAA;AAAA;AAAA,KAGU,iCAAA,GAAoC,8BAAA;AAAA,KAEpC,wBAAA,IACV,KAAA,EAAO,iCAAA,KACJ,OAAA,CAAQ,iCAAA,IAAqC,iCAAA;AAAA,UAEjC,mCAAA;EACf,QAAA,EAAU,iCAAA;EACV,OAAA,EAAS,OAAA;EACT,gBAAA;AAAA;AAAA,KAGU,2BAAA,IACV,KAA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AA,EAAS,OAAA,GACR,6BAAA,GAAgC,OAAA,CAAQ,6BAAA;EAC3C,UAAA,EAAY,+BAAA;AAAA;AAAA,UAGG,2BAAA;EACf,EAAA;EACA,KAAA;EACA,UAAA;EACA,SAAA,EAAW,IAAA;EACX,SAAA,EAAW,IAAA;EACX,QAAA,GAAW,MAAA;AAAA;AAAA,UAGI,+BAAA;EACf,MAAA,CAAO,KAAA;IACL,UAAA;IACA,KAAA;IACA,QAAA,EAAU,MAAA;EAAA,IACR,OAAA,CAAQ,2BAAA;EACZ,GAAA,CAAI,QAAA,WAAmB,OAAA,CAAQ,2BAAA;EAC/B,IAAA,CACE,UAAA,UACA,QAAA,EAAU,MAAA,mBACT,OAAA,CAAQ,2BAAA;EACX,YAAA,CAAa,QAAA,UAAkB,UAAA,WAAqB,OAAA;EACpD,MAAA,CAAO,QAAA,WAAmB,OAAA;EAC1B,MAAA,CAAO,KAAA;IACL,EAAA;IACA,KAAA;IACA,QAAA,EAAU,MAAA;EAAA,IACR,OAAA,CAAQ,2BAAA;AAAA;AAAA,cA6ED,mCAAA;EAAuC,SAAA;EAAA;AAAA,GAGjD,0CAAA;oBAiB8B,OAAA,KAAO,OAAA,CAAA,QAAA;oBAiFD,OAAA,EAAO,QAAA,aAAkB,OAAA,CAAA,QAAA;kBAjGjC,OAAA,KAAO,OAAA,CAAA,QAAA;kBAuCP,OAAA,EAAO,QAAA,aAAkB,OAAA,CAAA,QAAA;oBAgBvB,OAAA,EAAO,QAAA,aAAkB,OAAA,CAAA,QAAA;AAAA"}
1
+ {"version":3,"file":"thread-handlers-uddXwQjp.d.mts","names":[],"sources":["../src/server/request-guardrails.ts","../src/server/handler.ts","../src/server/thread-handlers.ts"],"mappings":";;;;;;;;cAEa,kCAAA;AAAA,cACA,6BAAA;AAAA,cACA,gCAAA;AAAA,cACA,qCAAA;AAAA,cACA,2CAAA;AAAA,cACA,oCAAA;AAAA,cACA,0CAAA;AAAA,cAEA,0CAAA,EAA0C,GAAA;AAAA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