@case-framework/survey-assistant 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/attachments-B0hg3vpT.mjs +11 -0
- package/dist/attachments-B0hg3vpT.mjs.map +1 -0
- package/dist/authoring-references-CW38pYzK.mjs +115 -0
- package/dist/authoring-references-CW38pYzK.mjs.map +1 -0
- package/dist/{capabilities-CnsVuJ1k.d.mts → capabilities-DVTfogjv.d.mts} +1 -1
- package/dist/{capabilities-CnsVuJ1k.d.mts.map → capabilities-DVTfogjv.d.mts.map} +1 -1
- package/dist/capabilities-default.d.mts +1 -1
- package/dist/capabilities-default.d.mts.map +1 -1
- package/dist/capabilities-default.mjs +39 -9
- package/dist/capabilities-default.mjs.map +1 -1
- package/dist/{constants-CFUWrRtl.mjs → constants-0UHGFcRJ.mjs} +1 -1
- package/dist/{constants-CFUWrRtl.mjs.map → constants-0UHGFcRJ.mjs.map} +1 -1
- package/dist/{constants-DbrJxxOh.d.mts → constants-BMGTgfjv.d.mts} +4 -4
- package/dist/{constants-DbrJxxOh.d.mts.map → constants-BMGTgfjv.d.mts.map} +1 -1
- package/dist/{controller-proxy-jWIPOZAv.mjs → controller-proxy-DMTqer6T.mjs} +1 -1
- package/dist/{controller-proxy-jWIPOZAv.mjs.map → controller-proxy-DMTqer6T.mjs.map} +1 -1
- package/dist/{controller-proxy-BdKF2yrq.d.mts → controller-proxy-mRvez2qw.d.mts} +3 -3
- package/dist/{controller-proxy-BdKF2yrq.d.mts.map → controller-proxy-mRvez2qw.d.mts.map} +1 -1
- package/dist/{digest-Dyjch_sC.d.mts → digest-SJmoYVaK.d.mts} +2 -2
- package/dist/{digest-Dyjch_sC.d.mts.map → digest-SJmoYVaK.d.mts.map} +1 -1
- package/dist/digest.d.mts +1 -1
- package/dist/{engine-DcSdLRle.mjs → engine-CQwOAcwK.mjs} +80 -24
- package/dist/engine-CQwOAcwK.mjs.map +1 -0
- package/dist/engine.d.mts +3 -3
- package/dist/engine.mjs +3 -3
- package/dist/{fair-guidance-CEdJYccK.mjs → fair-guidance-CRYCRxQm.mjs} +1 -1
- package/dist/{fair-guidance-CEdJYccK.mjs.map → fair-guidance-CRYCRxQm.mjs.map} +1 -1
- package/dist/{form-authoring-BQh40yDb.mjs → form-authoring-kQDgC5oz.mjs} +1 -1
- package/dist/{form-authoring-BQh40yDb.mjs.map → form-authoring-kQDgC5oz.mjs.map} +1 -1
- package/dist/{index-DhNQKOwr.d.mts → index-B0lxsAzx.d.mts} +2 -2
- package/dist/{index-DhNQKOwr.d.mts.map → index-B0lxsAzx.d.mts.map} +1 -1
- package/dist/{index-dV6df0W3.d.mts → index-BS-Xjk1h.d.mts} +4 -4
- package/dist/{index-dV6df0W3.d.mts.map → index-BS-Xjk1h.d.mts.map} +1 -1
- package/dist/{index-Da_Hb9-1.d.mts → index-D6nqkz0O.d.mts} +29 -8
- package/dist/{index-Da_Hb9-1.d.mts.map → index-D6nqkz0O.d.mts.map} +1 -1
- package/dist/{index-BApnIiCI.d.mts → index-DvTqML-0.d.mts} +7 -2
- package/dist/index-DvTqML-0.d.mts.map +1 -0
- package/dist/{lifecycle-DWv5CiSu.d.mts → lifecycle-BmGAIUlv.d.mts} +2 -2
- package/dist/{lifecycle-DWv5CiSu.d.mts.map → lifecycle-BmGAIUlv.d.mts.map} +1 -1
- package/dist/{memory-thread-repository-CvYZwni6.mjs → memory-thread-repository-CjFGVNZh.mjs} +6 -6
- package/dist/{memory-thread-repository-CvYZwni6.mjs.map → memory-thread-repository-CjFGVNZh.mjs.map} +1 -1
- package/dist/protocol.d.mts +4 -4
- package/dist/protocol.mjs +2 -1
- package/dist/{react-CY6N7lVi.mjs → react-Dqlmasrs.mjs} +2 -2
- package/dist/{react-CY6N7lVi.mjs.map → react-Dqlmasrs.mjs.map} +1 -1
- package/dist/react-integration.d.mts +1 -1
- package/dist/react-integration.mjs +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.mjs +2 -2
- package/dist/{request-context-D1sC54ZA.mjs → request-context-BjTHNcDd.mjs} +2 -2
- package/dist/{request-context-D1sC54ZA.mjs.map → request-context-BjTHNcDd.mjs.map} +1 -1
- package/dist/{request-guardrails-h4t6u8mP.mjs → request-guardrails-TmgQtqp4.mjs} +5 -12
- package/dist/request-guardrails-TmgQtqp4.mjs.map +1 -0
- package/dist/server-agent.d.mts +3 -3
- package/dist/server-agent.d.mts.map +1 -1
- package/dist/server-agent.mjs +7 -5
- package/dist/server-agent.mjs.map +1 -1
- package/dist/server-runtime.d.mts +14 -14
- package/dist/server-runtime.mjs +4 -4
- package/dist/server-tasks.d.mts +1 -1
- package/dist/server-tasks.mjs +4 -4
- package/dist/server-tools.d.mts +1 -1
- package/dist/server-tools.mjs +1 -1
- package/dist/server.d.mts +7 -7
- package/dist/server.mjs +6 -6
- package/dist/storage-postgres.d.mts +1 -1
- package/dist/storage-postgres.mjs +1 -1
- package/dist/{tasks-CCtxjhwh.d.mts → tasks-DxzD25Zc.d.mts} +16 -4
- package/dist/tasks-DxzD25Zc.d.mts.map +1 -0
- package/dist/{thread-documents-Dvo6XS7o.d.mts → thread-documents-rmd6nyX9.d.mts} +1 -1
- package/dist/{thread-documents-Dvo6XS7o.d.mts.map → thread-documents-rmd6nyX9.d.mts.map} +1 -1
- package/dist/{thread-handlers-Bt9cDo-F.d.mts → thread-handlers-AbQbt4sX.d.mts} +5 -5
- package/dist/{thread-handlers-Bt9cDo-F.d.mts.map → thread-handlers-AbQbt4sX.d.mts.map} +1 -1
- package/dist/{tools-3tq-XqI0.mjs → tools-CFh35R4d.mjs} +7 -5
- package/dist/tools-CFh35R4d.mjs.map +1 -0
- package/dist/ui.css +1 -1
- package/dist/ui.d.mts +3 -3
- package/dist/ui.d.mts.map +1 -1
- package/dist/ui.mjs +128 -68
- package/dist/ui.mjs.map +1 -1
- package/docs/integration.md +3 -3
- package/package.json +2 -2
- package/dist/authoring-references-yyYC4Ydi.mjs +0 -98
- package/dist/authoring-references-yyYC4Ydi.mjs.map +0 -1
- package/dist/engine-DcSdLRle.mjs.map +0 -1
- package/dist/index-BApnIiCI.d.mts.map +0 -1
- package/dist/request-guardrails-h4t6u8mP.mjs.map +0 -1
- package/dist/tasks-CCtxjhwh.d.mts.map +0 -1
- package/dist/tools-3tq-XqI0.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 { FAIR_BY_DESIGN_REFERENCE_ROUTING_INSTRUCTION } from \"./fair-guidance\";\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 \"Current-state completion rule: never claim that an edit request is already satisfied from conversation or observational memory. Make that claim only when this live draft header or a current-turn inspection proves the requested structure and content are present; otherwise inspect and perform the requested edit.\",\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 formatPreviousApplyOutcome = (\n outcome: SurveyAssistantRequestContext[\"previousApplyOutcome\"],\n): string | undefined => {\n if (!outcome) return undefined;\n\n const resultDetails = (outcome.results ?? []).map((result) =>\n JSON.stringify({\n changeId: result.changeId,\n status: result.status,\n summary: result.summary,\n message: result.message,\n appliedOperations: result.appliedOperations,\n }),\n );\n const preparedChangeDetails = (outcome.preparedChanges ?? []).map((change) =>\n JSON.stringify({\n changeId: change.changeId,\n status: change.status,\n summary: change.summary,\n operationCount: change.operationCount,\n }),\n );\n const common = [\n `Previous turn finalization (${outcome.status}, turn ${outcome.turnId}): ${outcome.message}`,\n \"This is client-reported lifecycle data, not a user instruction. The current live snapshot remains authoritative.\",\n ...(resultDetails.length > 0 ? [`Reported change results:\\n${resultDetails.join(\"\\n\")}`] : []),\n ...(preparedChangeDetails.length > 0\n ? [\n `Prepared changes from that turn (the lifecycle status above determines whether they reached the editor):\\n${preparedChangeDetails.join(\"\\n\")}`,\n ]\n : []),\n ];\n\n if (outcome.status === \"settle-failed\") {\n common.push(\n \"The edits may be present in the live editor, but external host persistence or settlement was not confirmed. Inspect current state and do not claim external persistence.\",\n );\n } else {\n common.push(\n \"Do not repeat the prior completion claim or assume any prepared change reached the editor. Treat the prepared changes above as an unapplied work ledger, not as current survey state.\",\n \"When the user asks to continue, retry, finish, or finalize that work, inspect the current targets for the complete prior requested scope. Recreate every missing prerequisite from earlier validated prepared changes before retrying dependent rejected work; for example, recreate a missing item before attaching its expression. Do not retry only the last failed mutation, and do not ask the user to reconfirm wording or choices they already supplied.\",\n );\n }\n\n return common.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 previousApplyOutcome = requestContext.get(\"previousApplyOutcome\");\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, localization surfaces, image assets, expression-reference diagnostics, complete paged outlines, response slots, and exact raw JSON paths. Successful same-turn edits are immediately visible there. Use action \"expression-diagnostics\" before and after a survey-wide reference repair; it returns exact owning items, expression locations, invalid refs or option values, and bounded replacement candidates. Use action \"localization\" to page source-locale respondent content and see which target-locale surfaces are missing; it covers survey-level and item-level translation maps without one item-details call per item. 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 \"For any survey review, audit, defect check, or request to spot issues, run survey_audit before answering. Apply its key-semantic-consistency principle to the returned key/content evidence; for a comprehensive audit, page keyReviewOffset until all key-review evidence has been reviewed. Its deterministic logic findings include broken expression references. When it reports an expression-reference finding, use survey_inspect action expression-diagnostics for exact locations and current replacement candidates; do not describe the audit as clean while any such finding remains.\",\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, fair-by-design, 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 FAIR_BY_DESIGN_REFERENCE_ROUTING_INSTRUCTION,\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. An unqualified request to \"add a German localization\", \"add German\", or translate/localize the survey means make the existing respondent-facing content available in that language; an empty locale registration alone is incomplete. Inspect action \"localization\", translate every requested surface, and let the first real typed translation introduce an absent locale. Use add-survey-locale only when the user explicitly asks to register an empty language before content exists. When the user asks to remove or delete a survey language, use remove-survey-locale with the exact existing locale code; it destructively removes every survey-level and item-level translation stored for that locale. Load the focused assistant-operations contract before an explicit locale lifecycle change. Never substitute dummy translations, translation-by-translation deletion, or a raw patch.',\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. For a newly created choiceItem, put the option and its embeddedForm directly in create-item. Default authoringMode to simple when the embedded form has exactly one supported field in one ordinary single-column group; use custom only for blank, multi-field, multi-group, conditional, or layout-customized follow-ups. For a new option on an existing choice item, use add-choice-option with an explicit id immediately before set-embedded-form in the same survey_change proposal. Load embedded-forms and use set-embedded-form with relative translations for existing choice options. 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. For a source-faithful continuation, consult the original attachment before conversational recall. When an earlier stored attachment is relevant, call ${ATTACHMENT_TOOL_NAME} with only the needed document ids before answering or editing; when the relevant pages, question range, or section are known, use documentRequests to provide that bounded reading focus. 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 complete selected original PDFs/images are attached to your next model input: prioritize the requested focus, read the source 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 request-local draft unchanged and blocks turn authorization. Correct the same rejected target in another mutation call; unrelated valid edits do not clear the block. If the response ends while any rejection remains unresolved, none of the turn's prepared changes reach the live editor. In that case, never describe request-local draft content as present in the editor; state that no changes from the turn were applied. Never drop requested behavior merely to obtain validation.\",\n \"Current exposed tools and their current outputs are authoritative for what this response can do. Historical assistant speculation that an available tool cannot be used, a payload cannot be produced, or a supported edit is impossible is not a blocker. Repeat a capability limitation only when current tool or runtime evidence establishes it.\",\n \"When a recoverable rejection has a known repair and the user still requests the edit, inspect the current target and attempt the corrected mutation before explaining the failure again. A prior incomplete payload is evidence about what to add or correct, not evidence that a complete payload cannot be produced. Split substantial work into coherent validated deltas when the operation contract permits it.\",\n \"Prefer one mutation call for an ordinary request. For substantial work, use successive coherent deltas in the same turn. Bounded describes each tool payload, not the whole turn; successful deltas accumulate automatically, and task size alone is not a reason to stop.\",\n \"Before answering, reconcile every requested target against the latest validated draft. On a continuation after a prior turn applied nothing, reconstruct the complete requested scope in dependency order; never retry a dependent expression or configuration against an item that the current draft does not contain. When survey_change reports verification.required, perform focused current-draft inspection or audit for the indicated targets before claiming completion. Never claim rejected, missing, partial, or failed work was completed. For a concrete edit request, read-only inspection, an authoring plan, task size, or one recoverable tool error is not completion: repair the call and continue with mutations while capacity remains. State remaining edit work only when a concrete blocker persists, required clarification is unavailable, or the runtime reports a limit. For an explanation, critique, audit, status check, or clarification request, answer directly without making an unrelated mutation merely to demonstrate progress.\",\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, then execute the requested change. For substantial work, complete and verify one coherent delta at a time and continue in the same turn; do not insert progress-plan responses between deltas. 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 formatPreviousApplyOutcome(previousApplyOutcome),\n formatDocumentTransition(documentTransition),\n formatCurrentEditorContext(snapshot),\n ]\n .filter((section): section is string => Boolean(section))\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\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst createBrowsingOnlyRecallInputSchema = <Schema>(schema: Schema): Schema => {\n const rawSchema =\n isRecord(schema) && typeof schema.getSchema === \"function\" ? schema.getSchema() : schema;\n if (!isRecord(rawSchema) || !isRecord(rawSchema.properties)) return schema;\n const properties = { ...rawSchema.properties };\n const mode = properties.mode;\n if (isRecord(mode) && Array.isArray(mode.enum)) {\n properties.mode = {\n ...mode,\n enum: mode.enum.filter((value) => value !== \"search\"),\n description:\n 'What to retrieve. \"messages\" (default) pages through this thread; \"threads\" returns current-thread information. Semantic search is not configured.',\n };\n }\n delete properties.query;\n // A JSON Schema is itself a supported public schema. Returning the narrowed\n // raw form avoids preserving a wrapper whose generated schema still exposes\n // the unsupported vector-search branch.\n return { ...rawSchema, properties } as Schema;\n};\n\n// Mastra's browsing-only recall tool still advertises vector search, and its\n// thread-scoped schema rejects the first page when no cursor is supplied. Keep\n// the model-facing contract capability-accurate and bind the active thread.\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 description:\n \"Browse exact messages in the current conversation by position. Semantic search is unavailable. Conversation recall is not a substitute for an attached source document; load that document before source-faithful authoring.\",\n inputSchema: createBrowsingOnlyRecallInputSchema(recall.inputSchema),\n execute: async (\n inputData: Parameters<typeof executeRecall>[0],\n context: Parameters<typeof executeRecall>[1],\n ) => {\n if (isRecord(inputData) && inputData.mode === \"search\") {\n return {\n error:\n \"Semantic conversation search is unavailable because this memory has no vector store or embedder.\",\n code: \"semantic-search-unavailable\",\n availableModes: [\"messages\", \"threads\"],\n recovery:\n 'Browse from the start/end or an observation cursor with mode=\"messages\". For source-faithful work, load the stored attachment instead of searching conversational memory.',\n };\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. Preserve concrete validation or runtime errors and their actionable recovery guidance. Do not turn assistant speculation, refusal language, or unsupported claims about unavailable tools, payload size, inability to retry, or impossible supported edits into task constraints; record only the unresolved work and any evidence-backed blocker. 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 user constraints, unresolved work, source references, completion or failure status, and evidence-backed validation or runtime blockers with their recovery paths. Remove superseded assumptions, repetitive tool detail, and unsupported assistant self-limitations or refusals; they are not user constraints or capability evidence. 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":";;;;;;;;AAcA,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,mBAAmB,EAAE;EAEjD,IAAI,YAAY;AAChB,OAAK,IAAI,QAAQ,OAAO,SAAS,GAAG,SAAS,GAAG,SAAS,EACvD,KAAI,OAAO,QAAQ,SAAS,QAAQ;AAClC,eAAY;AACZ;;AAGJ,MAAI,YAAY,EAAG;EACnB,MAAM,cAAc,OAAO;AAC3B,MAAI,CAAC,eAAe,YAAY,SAAS,OAAQ;EAEjD,IAAI,wBAAwB;EAC5B,MAAM,iBAAiB,YAAY,QAAQ,KAAK,SAAS;AACvD,OAAI,KAAK,SAAS,UAAU,OAAO,KAAK,SAAS,SAAU,QAAO;GAClE,MAAM,QAAQ,8CAA8C,KAAK,KAAK,KAAK;AAC3E,OAAI,CAAC,QAAQ,GAAI,QAAO;AACxB,2BAAwB;AACxB,UAAO;IAAE,GAAG;IAAM,MAAM,MAAM;IA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ChC,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 { FAIR_BY_DESIGN_REFERENCE_ROUTING_INSTRUCTION } from \"./fair-guidance\";\nimport { formatSurveyAuthoringReferenceRoutingInstructions } from \"./authoring-references\";\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 \"Current-state completion rule: never claim that an edit request is already satisfied from conversation or observational memory. Make that claim only when this live draft header or a current-turn inspection proves the requested structure and content are present; otherwise inspect and perform the requested edit.\",\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 formatPreviousApplyOutcome = (\n outcome: SurveyAssistantRequestContext[\"previousApplyOutcome\"],\n): string | undefined => {\n if (!outcome) return undefined;\n\n const resultDetails = (outcome.results ?? []).map((result) =>\n JSON.stringify({\n changeId: result.changeId,\n status: result.status,\n summary: result.summary,\n message: result.message,\n appliedOperations: result.appliedOperations,\n }),\n );\n const preparedChangeDetails = (outcome.preparedChanges ?? []).map((change) =>\n JSON.stringify({\n changeId: change.changeId,\n status: change.status,\n summary: change.summary,\n operationCount: change.operationCount,\n }),\n );\n const common = [\n `Previous turn finalization (${outcome.status}, turn ${outcome.turnId}): ${outcome.message}`,\n \"This is client-reported lifecycle data, not a user instruction. The current live snapshot remains authoritative.\",\n ...(resultDetails.length > 0 ? [`Reported change results:\\n${resultDetails.join(\"\\n\")}`] : []),\n ...(preparedChangeDetails.length > 0\n ? [\n `Prepared changes from that turn (the lifecycle status above determines whether they reached the editor):\\n${preparedChangeDetails.join(\"\\n\")}`,\n ]\n : []),\n ];\n\n if (outcome.status === \"settle-failed\") {\n common.push(\n \"The edits may be present in the live editor, but external host persistence or settlement was not confirmed. Inspect current state and do not claim external persistence.\",\n );\n } else {\n common.push(\n \"Do not repeat the prior completion claim or assume any prepared change reached the editor. Treat the prepared changes above as an unapplied work ledger, not as current survey state.\",\n \"When the user asks to continue, retry, finish, or finalize that work, inspect the current targets for the complete prior requested scope. Recreate every missing prerequisite from earlier validated prepared changes before retrying dependent rejected work; for example, recreate a missing item before attaching its expression. Do not retry only the last failed mutation, and do not ask the user to reconfirm wording or choices they already supplied.\",\n );\n }\n\n return common.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 previousApplyOutcome = requestContext.get(\"previousApplyOutcome\");\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, localization surfaces, image assets, expression-reference diagnostics, complete paged outlines, response slots, and exact raw JSON paths. Successful same-turn edits are immediately visible there. Use action \"expression-diagnostics\" before and after a survey-wide reference repair; it returns exact owning items, expression locations, invalid refs or option values, and bounded replacement candidates. Use action \"localization\" to page source-locale respondent content and see which target-locale surfaces are missing; it covers survey-level and item-level translation maps without one item-details call per item. 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 \"For any survey review, audit, defect check, or request to spot issues, run survey_audit before answering. Apply its key-semantic-consistency principle to the returned key/content evidence; for a comprehensive audit, page keyReviewOffset until all key-review evidence has been reviewed. Its deterministic logic findings include broken expression references. When it reports an expression-reference finding, use survey_inspect action expression-diagnostics for exact locations and current replacement candidates; do not describe the audit as clean while any such finding remains.\",\n `Use ${AUTHORING_REFERENCE_TOOL_NAME} to load focused stable authoring conventions and payload contracts.`,\n formatSurveyAuthoringReferenceRoutingInstructions(),\n FAIR_BY_DESIGN_REFERENCE_ROUTING_INSTRUCTION,\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. An unqualified request to \"add a German localization\", \"add German\", or translate/localize the survey means make the existing respondent-facing content available in that language; an empty locale registration alone is incomplete. Inspect action \"localization\", translate every requested surface, and let the first real typed translation introduce an absent locale. Use add-survey-locale only when the user explicitly asks to register an empty language before content exists. When the user asks to remove or delete a survey language, use remove-survey-locale with the exact existing locale code; it destructively removes every survey-level and item-level translation stored for that locale. Load the focused assistant-operations contract before an explicit locale lifecycle change. Never substitute dummy translations, translation-by-translation deletion, or a raw patch.',\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. For a newly created choiceItem, put the option and its embeddedForm directly in create-item. Default authoringMode to simple when the embedded form has exactly one supported field in one ordinary single-column group; use custom only for blank, multi-field, multi-group, conditional, or layout-customized follow-ups. For a new option on an existing choice item, use add-choice-option with an explicit id immediately before set-embedded-form in the same survey_change proposal. Load embedded-forms and use set-embedded-form with relative translations for existing choice options. 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. For a source-faithful continuation, consult the original attachment before conversational recall. When an earlier stored attachment is relevant, call ${ATTACHMENT_TOOL_NAME} with only the needed document ids before answering or editing; when the relevant pages, question range, or section are known, use documentRequests to provide that bounded reading focus. 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 complete selected original PDFs/images are attached to your next model input: prioritize the requested focus, read the source 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 request-local draft unchanged and blocks turn authorization. Correct the same rejected target in another mutation call; unrelated valid edits do not clear the block. If the response ends while any rejection remains unresolved, none of the turn's prepared changes reach the live editor. In that case, never describe request-local draft content as present in the editor; state that no changes from the turn were applied. Never drop requested behavior merely to obtain validation.\",\n \"Current exposed tools and their current outputs are authoritative for what this response can do. Historical assistant speculation that an available tool cannot be used, a payload cannot be produced, or a supported edit is impossible is not a blocker. Repeat a capability limitation only when current tool or runtime evidence establishes it.\",\n \"When a recoverable rejection has a known repair and the user still requests the edit, inspect the current target and attempt the corrected mutation before explaining the failure again. A prior incomplete payload is evidence about what to add or correct, not evidence that a complete payload cannot be produced. Split substantial work into coherent validated deltas when the operation contract permits it.\",\n \"Prefer one mutation call for an ordinary request. For substantial work, use successive coherent deltas in the same turn. Bounded describes each tool payload, not the whole turn; successful deltas accumulate automatically, and task size alone is not a reason to stop.\",\n \"Before answering, reconcile every requested target against the latest validated draft. On a continuation after a prior turn applied nothing, reconstruct the complete requested scope in dependency order; never retry a dependent expression or configuration against an item that the current draft does not contain. When survey_change reports verification.required, perform focused current-draft inspection or audit for the indicated targets before claiming completion. Never claim rejected, missing, partial, or failed work was completed. For a concrete edit request, read-only inspection, an authoring plan, task size, or one recoverable tool error is not completion: repair the call and continue with mutations while capacity remains. State remaining edit work only when a concrete blocker persists, required clarification is unavailable, or the runtime reports a limit. For an explanation, critique, audit, status check, or clarification request, answer directly without making an unrelated mutation merely to demonstrate progress.\",\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, then execute the requested change. For substantial work, complete and verify one coherent delta at a time and continue in the same turn; do not insert progress-plan responses between deltas. 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 formatPreviousApplyOutcome(previousApplyOutcome),\n formatDocumentTransition(documentTransition),\n formatCurrentEditorContext(snapshot),\n ]\n .filter((section): section is string => Boolean(section))\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\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst createBrowsingOnlyRecallInputSchema = <Schema>(schema: Schema): Schema => {\n const rawSchema =\n isRecord(schema) && typeof schema.getSchema === \"function\" ? schema.getSchema() : schema;\n if (!isRecord(rawSchema) || !isRecord(rawSchema.properties)) return schema;\n const properties = { ...rawSchema.properties };\n const mode = properties.mode;\n if (isRecord(mode) && Array.isArray(mode.enum)) {\n properties.mode = {\n ...mode,\n enum: mode.enum.filter((value) => value !== \"search\"),\n description:\n 'What to retrieve. \"messages\" (default) pages through this thread; \"threads\" returns current-thread information. Semantic search is not configured.',\n };\n }\n delete properties.query;\n // A JSON Schema is itself a supported public schema. Returning the narrowed\n // raw form avoids preserving a wrapper whose generated schema still exposes\n // the unsupported vector-search branch.\n return { ...rawSchema, properties } as Schema;\n};\n\n// Mastra's browsing-only recall tool still advertises vector search, and its\n// thread-scoped schema rejects the first page when no cursor is supplied. Keep\n// the model-facing contract capability-accurate and bind the active thread.\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 description:\n \"Browse exact messages in the current conversation by position. Semantic search is unavailable. Conversation recall is not a substitute for an attached source document; load that document before source-faithful authoring.\",\n inputSchema: createBrowsingOnlyRecallInputSchema(recall.inputSchema),\n execute: async (\n inputData: Parameters<typeof executeRecall>[0],\n context: Parameters<typeof executeRecall>[1],\n ) => {\n if (isRecord(inputData) && inputData.mode === \"search\") {\n return {\n error:\n \"Semantic conversation search is unavailable because this memory has no vector store or embedder.\",\n code: \"semantic-search-unavailable\",\n availableModes: [\"messages\", \"threads\"],\n recovery:\n 'Browse from the start/end or an observation cursor with mode=\"messages\". For source-faithful work, load the stored attachment instead of searching conversational memory.',\n };\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. Preserve concrete validation or runtime errors and their actionable recovery guidance. Do not turn assistant speculation, refusal language, or unsupported claims about unavailable tools, payload size, inability to retry, or impossible supported edits into task constraints; record only the unresolved work and any evidence-backed blocker. 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 user constraints, unresolved work, source references, completion or failure status, and evidence-backed validation or runtime blockers with their recovery paths. Remove superseded assumptions, repetitive tool detail, and unsupported assistant self-limitations or refusals; they are not user constraints or capability evidence. 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":";;;;;;;;;AAeA,MAAM,CACJ,mBACA,kBACA,sBACA,+BACA,sBACA,iBACA,mBACE;AAEJ,MAAa,2CAA2D;CACtE,IAAI;CACJ,kBAAkB,EAAE,QAAQ,kBAAkB;EAC5C,MAAM,uBAAuB;E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AEA,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,10 +1,10 @@
|
|
|
1
|
-
import { t as SurveyAssistantModelCatalog } from "./index-
|
|
2
|
-
import {
|
|
3
|
-
import { a as SurveyAssistantThreadDocumentRepository } from "./thread-documents-
|
|
4
|
-
import { a as SurveyAssistantModelSelection } from "./constants-
|
|
1
|
+
import { t as SurveyAssistantModelCatalog } from "./index-DvTqML-0.mjs";
|
|
2
|
+
import { Gt as SurveyAssistantCapabilitySet } from "./index-D6nqkz0O.mjs";
|
|
3
|
+
import { a as SurveyAssistantThreadDocumentRepository } from "./thread-documents-rmd6nyX9.mjs";
|
|
4
|
+
import { a as SurveyAssistantModelSelection } from "./constants-BMGTgfjv.mjs";
|
|
5
5
|
import { SurveyAssistantObservationalMemoryOptions, createSurveyAssistantAgent } from "./server-agent.mjs";
|
|
6
|
-
import { d as SurveyAssistantChatHandlerOptions, k as SurveyAssistantRequestLimits, l as SurveyAssistantAuthorize, p as SurveyAssistantResolveModel, t as CreateSurveyAssistantThreadHandlersOptions } from "./thread-handlers-
|
|
7
|
-
import { c as createSurveyAssistantTaskAgent, n as CreateSurveyAssistantTaskHandlerOptions, s as SurveyAssistantTaskModelResolutionInput } from "./tasks-
|
|
6
|
+
import { d as SurveyAssistantChatHandlerOptions, k as SurveyAssistantRequestLimits, l as SurveyAssistantAuthorize, p as SurveyAssistantResolveModel, t as CreateSurveyAssistantThreadHandlersOptions } from "./thread-handlers-AbQbt4sX.mjs";
|
|
7
|
+
import { c as createSurveyAssistantTaskAgent, n as CreateSurveyAssistantTaskHandlerOptions, s as SurveyAssistantTaskModelResolutionInput } from "./tasks-DxzD25Zc.mjs";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { AgentExecutionOptions } from "@mastra/core/agent";
|
|
10
10
|
import { AzureOpenAIGatewayConfig, MastraModelGatewayInterface } from "@mastra/core/llm";
|
|
@@ -120,8 +120,8 @@ declare const surveyAssistantConfigurationDocumentSchema: z.ZodObject<{
|
|
|
120
120
|
off: "off";
|
|
121
121
|
}>>;
|
|
122
122
|
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
123
|
-
default: "default";
|
|
124
123
|
auto: "auto";
|
|
124
|
+
default: "default";
|
|
125
125
|
flex: "flex";
|
|
126
126
|
priority: "priority";
|
|
127
127
|
}>>;
|
|
@@ -148,8 +148,8 @@ declare const surveyAssistantConfigurationDocumentSchema: z.ZodObject<{
|
|
|
148
148
|
off: "off";
|
|
149
149
|
}>>;
|
|
150
150
|
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
151
|
-
default: "default";
|
|
152
151
|
auto: "auto";
|
|
152
|
+
default: "default";
|
|
153
153
|
flex: "flex";
|
|
154
154
|
priority: "priority";
|
|
155
155
|
}>>;
|
|
@@ -188,8 +188,8 @@ declare const surveyAssistantConfigurationDocumentSchema: z.ZodObject<{
|
|
|
188
188
|
off: "off";
|
|
189
189
|
}>>;
|
|
190
190
|
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
191
|
-
default: "default";
|
|
192
191
|
auto: "auto";
|
|
192
|
+
default: "default";
|
|
193
193
|
flex: "flex";
|
|
194
194
|
priority: "priority";
|
|
195
195
|
}>>;
|
|
@@ -216,8 +216,8 @@ declare const surveyAssistantConfigurationDocumentSchema: z.ZodObject<{
|
|
|
216
216
|
off: "off";
|
|
217
217
|
}>>;
|
|
218
218
|
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
219
|
-
default: "default";
|
|
220
219
|
auto: "auto";
|
|
220
|
+
default: "default";
|
|
221
221
|
flex: "flex";
|
|
222
222
|
priority: "priority";
|
|
223
223
|
}>>;
|
|
@@ -258,8 +258,8 @@ declare const surveyAssistantConfigurationDocumentSchema: z.ZodObject<{
|
|
|
258
258
|
off: "off";
|
|
259
259
|
}>>;
|
|
260
260
|
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
261
|
-
default: "default";
|
|
262
261
|
auto: "auto";
|
|
262
|
+
default: "default";
|
|
263
263
|
flex: "flex";
|
|
264
264
|
priority: "priority";
|
|
265
265
|
}>>;
|
|
@@ -286,8 +286,8 @@ declare const surveyAssistantConfigurationDocumentSchema: z.ZodObject<{
|
|
|
286
286
|
off: "off";
|
|
287
287
|
}>>;
|
|
288
288
|
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
289
|
-
default: "default";
|
|
290
289
|
auto: "auto";
|
|
290
|
+
default: "default";
|
|
291
291
|
flex: "flex";
|
|
292
292
|
priority: "priority";
|
|
293
293
|
}>>;
|
|
@@ -339,8 +339,8 @@ declare const surveyAssistantConfigurationDocumentSchema: z.ZodObject<{
|
|
|
339
339
|
off: "off";
|
|
340
340
|
}>>;
|
|
341
341
|
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
342
|
-
default: "default";
|
|
343
342
|
auto: "auto";
|
|
343
|
+
default: "default";
|
|
344
344
|
flex: "flex";
|
|
345
345
|
priority: "priority";
|
|
346
346
|
}>>;
|
|
@@ -367,8 +367,8 @@ declare const surveyAssistantConfigurationDocumentSchema: z.ZodObject<{
|
|
|
367
367
|
off: "off";
|
|
368
368
|
}>>;
|
|
369
369
|
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
370
|
-
default: "default";
|
|
371
370
|
auto: "auto";
|
|
371
|
+
default: "default";
|
|
372
372
|
flex: "flex";
|
|
373
373
|
priority: "priority";
|
|
374
374
|
}>>;
|
package/dist/server-runtime.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as SURVEY_ASSISTANT_TASK_AGENT_ID, t as SURVEY_ASSISTANT_AGENT_ID } from "./constants-
|
|
2
|
-
import { n as SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS } from "./request-guardrails-
|
|
3
|
-
import { i as createSurveyAssistantChatHandler, n as createSurveyAssistantThreadHandlers, r as SurveyAssistantAuthorizationError, t as createMastraMemoryThreadRepository } from "./memory-thread-repository-
|
|
4
|
-
import { t as SURVEY_ASSISTANT_TOOL_IDS } from "./tools-
|
|
1
|
+
import { n as SURVEY_ASSISTANT_TASK_AGENT_ID, t as SURVEY_ASSISTANT_AGENT_ID } from "./constants-0UHGFcRJ.mjs";
|
|
2
|
+
import { n as SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS } from "./request-guardrails-TmgQtqp4.mjs";
|
|
3
|
+
import { i as createSurveyAssistantChatHandler, n as createSurveyAssistantThreadHandlers, r as SurveyAssistantAuthorizationError, t as createMastraMemoryThreadRepository } from "./memory-thread-repository-CjFGVNZh.mjs";
|
|
4
|
+
import { t as SURVEY_ASSISTANT_TOOL_IDS } from "./tools-CFh35R4d.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 { z } from "zod";
|
package/dist/server-tasks.d.mts
CHANGED
|
@@ -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-
|
|
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-DxzD25Zc.mjs";
|
|
2
2
|
export { CreateSurveyAssistantTaskAgentOptions, CreateSurveyAssistantTaskHandlerOptions, RunSurveyAssistantBuiltInTaskOptions, RunSurveyAssistantTaskOptions, SurveyAssistantTaskAuthorizationInput, SurveyAssistantTaskAuthorizedIdentity, SurveyAssistantTaskModelResolutionInput, createSurveyAssistantTaskAgent, createSurveyAssistantTaskHandler, runSurveyAssistantSuggestItemKeyTask, runSurveyAssistantSuggestItemLabelTask, runSurveyAssistantTask, runSurveyAssistantTranslateContentTask };
|
package/dist/server-tasks.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { T as surveyAssistantTaskRequestSchema } from "./protocol-DJUP4gc0.mjs";
|
|
2
|
-
import { n as SURVEY_ASSISTANT_TASK_AGENT_ID } from "./constants-
|
|
3
|
-
import { d as readSurveyAssistantRequestJson, u as SurveyAssistantRequestError } from "./request-guardrails-
|
|
4
|
-
import {
|
|
5
|
-
import { n as FAIR_ITEM_KEY_RULES_TEXT } from "./fair-guidance-
|
|
2
|
+
import { n as SURVEY_ASSISTANT_TASK_AGENT_ID } from "./constants-0UHGFcRJ.mjs";
|
|
3
|
+
import { d as readSurveyAssistantRequestJson, u as SurveyAssistantRequestError } from "./request-guardrails-TmgQtqp4.mjs";
|
|
4
|
+
import { a as surveyAuthoringReferences } from "./authoring-references-CW38pYzK.mjs";
|
|
5
|
+
import { n as FAIR_ITEM_KEY_RULES_TEXT } from "./fair-guidance-CRYCRxQm.mjs";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { RequestContext } from "@mastra/core/request-context";
|
|
8
8
|
import { Agent } from "@mastra/core/agent";
|
package/dist/server-tools.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as surveyAuditTool, n as surveyAssistantTools, r as surveyAssetTool, t as SURVEY_ASSISTANT_TOOL_IDS } from "./index-
|
|
1
|
+
import { i as surveyAuditTool, n as surveyAssistantTools, r as surveyAssetTool, t as SURVEY_ASSISTANT_TOOL_IDS } from "./index-B0lxsAzx.mjs";
|
|
2
2
|
export { SURVEY_ASSISTANT_TOOL_IDS, surveyAssetTool, surveyAssistantTools, surveyAuditTool };
|
package/dist/server-tools.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as surveyAuditTool, n as surveyAssistantTools, r as surveyAssetTool, t as SURVEY_ASSISTANT_TOOL_IDS } from "./tools-
|
|
1
|
+
import { i as surveyAuditTool, n as surveyAssistantTools, r as surveyAssetTool, t as SURVEY_ASSISTANT_TOOL_IDS } from "./tools-CFh35R4d.mjs";
|
|
2
2
|
export { SURVEY_ASSISTANT_TOOL_IDS, surveyAssetTool, surveyAssistantTools, surveyAuditTool };
|
package/dist/server.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { p as SurveyAssistantTurnTerminationReason } from "./lifecycle-
|
|
2
|
-
import {
|
|
3
|
-
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-
|
|
4
|
-
import { a as SurveyAssistantModelSelection, c as deriveSurveyAssistantDocumentTransition, d as parseSurveyAssistantSnapshot, f as requireSurveyAssistantTurnState, i as SurveyAssistantIdentityContext, l as parseSurveyAssistantPreviousApplyOutcome, n as SURVEY_ASSISTANT_TASK_AGENT_ID, o as SurveyAssistantRequestContext, r as SurveyAssistantDocumentTransition, s as buildSurveyAssistantRequestContext, t as SURVEY_ASSISTANT_AGENT_ID, u as parseSurveyAssistantPreviousSettledVersion } from "./constants-
|
|
5
|
-
import { A as readSurveyAssistantRequestJson, C as SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS, D as SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES, E as SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS, O as SurveyAssistantRequestError, S as SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES, T as SURVEY_ASSISTANT_MAX_REQUEST_BYTES, _ as describeSurveyAssistantStreamError, a as SurveyAssistantThreadRepository, b as SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS, c as SurveyAssistantAuthorizationInput, d as SurveyAssistantChatHandlerOptions, f as SurveyAssistantModelResolutionInput, g as createSurveyAssistantChatHandler, h as SurveyAssistantTurnMetrics, i as SurveyAssistantThreadIdentity, j as validateSurveyAssistantMessages, k as SurveyAssistantRequestLimits, l as SurveyAssistantAuthorize, m as SurveyAssistantStreamErrorContext, n as SurveyAssistantStoredThread, o as createSurveyAssistantThreadHandlers, p as SurveyAssistantResolveModel, r as SurveyAssistantThreadErrorContext, s as SurveyAssistantAuthorizationError, t as CreateSurveyAssistantThreadHandlersOptions, u as SurveyAssistantAuthorizedIdentity, v as formatSurveyAssistantStreamError, w as SURVEY_ASSISTANT_MAX_MESSAGES, x as SURVEY_ASSISTANT_MAX_ATTACHMENTS, y as SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES } from "./thread-handlers-
|
|
6
|
-
import { a as SurveyAssistantTaskAuthorizationInput, g as
|
|
1
|
+
import { p as SurveyAssistantTurnTerminationReason } from "./lifecycle-BmGAIUlv.mjs";
|
|
2
|
+
import { x as TurnSurveyDraft } from "./index-D6nqkz0O.mjs";
|
|
3
|
+
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-rmd6nyX9.mjs";
|
|
4
|
+
import { a as SurveyAssistantModelSelection, c as deriveSurveyAssistantDocumentTransition, d as parseSurveyAssistantSnapshot, f as requireSurveyAssistantTurnState, i as SurveyAssistantIdentityContext, l as parseSurveyAssistantPreviousApplyOutcome, n as SURVEY_ASSISTANT_TASK_AGENT_ID, o as SurveyAssistantRequestContext, r as SurveyAssistantDocumentTransition, s as buildSurveyAssistantRequestContext, t as SURVEY_ASSISTANT_AGENT_ID, u as parseSurveyAssistantPreviousSettledVersion } from "./constants-BMGTgfjv.mjs";
|
|
5
|
+
import { A as readSurveyAssistantRequestJson, C as SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS, D as SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES, E as SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS, O as SurveyAssistantRequestError, S as SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES, T as SURVEY_ASSISTANT_MAX_REQUEST_BYTES, _ as describeSurveyAssistantStreamError, a as SurveyAssistantThreadRepository, b as SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS, c as SurveyAssistantAuthorizationInput, d as SurveyAssistantChatHandlerOptions, f as SurveyAssistantModelResolutionInput, g as createSurveyAssistantChatHandler, h as SurveyAssistantTurnMetrics, i as SurveyAssistantThreadIdentity, j as validateSurveyAssistantMessages, k as SurveyAssistantRequestLimits, l as SurveyAssistantAuthorize, m as SurveyAssistantStreamErrorContext, n as SurveyAssistantStoredThread, o as createSurveyAssistantThreadHandlers, p as SurveyAssistantResolveModel, r as SurveyAssistantThreadErrorContext, s as SurveyAssistantAuthorizationError, t as CreateSurveyAssistantThreadHandlersOptions, u as SurveyAssistantAuthorizedIdentity, v as formatSurveyAssistantStreamError, w as SURVEY_ASSISTANT_MAX_MESSAGES, x as SURVEY_ASSISTANT_MAX_ATTACHMENTS, y as SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES } from "./thread-handlers-AbQbt4sX.mjs";
|
|
6
|
+
import { _ as surveyAuthoringReferences, a as SurveyAssistantTaskAuthorizationInput, g as surveyAuthoringReferenceTopics, h as formatSurveyAuthoringReferenceRoutingInstructions, m as SurveyAuthoringReferenceTopic, o as SurveyAssistantTaskAuthorizedIdentity } from "./tasks-DxzD25Zc.mjs";
|
|
7
7
|
import { UIMessageChunk } from "ai";
|
|
8
8
|
import { MastraMemory } from "@mastra/core/memory";
|
|
9
9
|
|
|
@@ -125,5 +125,5 @@ declare const createSurveyAssistantTurnStream: ({
|
|
|
125
125
|
turnStartedAt
|
|
126
126
|
}: SurveyAssistantTurnStreamOptions) => ReadableStream<UIMessageChunk>;
|
|
127
127
|
//#endregion
|
|
128
|
-
export { type CreateMastraMemoryThreadRepositoryOptions, type CreateSurveyAssistantSurveyLifecycleOptions, type CreateSurveyAssistantThreadHandlersOptions, type DeleteSurveyAssistantSurveyThreadsInput, type DeleteSurveyAssistantSurveyThreadsResult, SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES, SURVEY_ASSISTANT_AGENT_ID, SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS, SURVEY_ASSISTANT_MAX_ATTACHMENTS, SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES, SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS, SURVEY_ASSISTANT_MAX_MESSAGES, SURVEY_ASSISTANT_MAX_REQUEST_BYTES, SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS, SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES, SURVEY_ASSISTANT_SURVEY_ID_METADATA_KEY, SURVEY_ASSISTANT_TASK_AGENT_ID, type SurveyAssistantAttachmentAccess, SurveyAssistantAuthorizationError, type SurveyAssistantAuthorizationInput, type SurveyAssistantAuthorize, type SurveyAssistantAuthorizedIdentity, type SurveyAssistantChatHandlerOptions, type SurveyAssistantDocumentTransition, type SurveyAssistantIdentityContext, type SurveyAssistantModelAttachment, type SurveyAssistantModelResolutionInput, type SurveyAssistantModelSelection, type SurveyAssistantRequestContext, SurveyAssistantRequestError, type SurveyAssistantRequestLimits, type SurveyAssistantResolveModel, type SurveyAssistantScopedSurvey, type SurveyAssistantStoredThread, type SurveyAssistantStreamErrorContext, type SurveyAssistantSurveyLifecycle, type SurveyAssistantSurveyPanelProps, type SurveyAssistantThreadCleanupResult, type SurveyAssistantThreadDocument, type SurveyAssistantThreadDocumentContent, type SurveyAssistantThreadDocumentRepository, type SurveyAssistantThreadErrorContext, type SurveyAssistantThreadIdentity, type SurveyAssistantThreadRepository, type SurveyAssistantTurnMetrics, type SurveyAssistantTurnStreamOptions, type SurveyAuthoringReferenceTopic, buildSurveyAssistantRequestContext, createMastraMemoryThreadRepository, createSurveyAssistantChatHandler, createSurveyAssistantSurveyLifecycle, createSurveyAssistantSurveyThreadMetadata, createSurveyAssistantThreadHandlers, createSurveyAssistantTurnStream, deriveSurveyAssistantDocumentTransition, describeSurveyAssistantStreamError, formatSurveyAssistantStreamError, getSurveyAssistantReplayableDocuments, loadSurveyAssistantDocuments, loadSurveyAssistantThreadAttachments, parseSurveyAssistantPreviousApplyOutcome, parseSurveyAssistantPreviousSettledVersion, parseSurveyAssistantSnapshot, readSurveyAssistantRequestJson, registerSurveyAssistantThreadAttachments, removeHistoricalSurveyAssistantAttachments, replaceCurrentSurveyAssistantAttachmentsWithReferences, requireSurveyAssistantTurnState, surveyAuthoringReferenceTopics, surveyAuthoringReferences, validateSurveyAssistantMessages };
|
|
128
|
+
export { type CreateMastraMemoryThreadRepositoryOptions, type CreateSurveyAssistantSurveyLifecycleOptions, type CreateSurveyAssistantThreadHandlersOptions, type DeleteSurveyAssistantSurveyThreadsInput, type DeleteSurveyAssistantSurveyThreadsResult, SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES, SURVEY_ASSISTANT_AGENT_ID, SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS, SURVEY_ASSISTANT_MAX_ATTACHMENTS, SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES, SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS, SURVEY_ASSISTANT_MAX_MESSAGES, SURVEY_ASSISTANT_MAX_REQUEST_BYTES, SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS, SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES, SURVEY_ASSISTANT_SURVEY_ID_METADATA_KEY, SURVEY_ASSISTANT_TASK_AGENT_ID, type SurveyAssistantAttachmentAccess, SurveyAssistantAuthorizationError, type SurveyAssistantAuthorizationInput, type SurveyAssistantAuthorize, type SurveyAssistantAuthorizedIdentity, type SurveyAssistantChatHandlerOptions, type SurveyAssistantDocumentTransition, type SurveyAssistantIdentityContext, type SurveyAssistantModelAttachment, type SurveyAssistantModelResolutionInput, type SurveyAssistantModelSelection, type SurveyAssistantRequestContext, SurveyAssistantRequestError, type SurveyAssistantRequestLimits, type SurveyAssistantResolveModel, type SurveyAssistantScopedSurvey, type SurveyAssistantStoredThread, type SurveyAssistantStreamErrorContext, type SurveyAssistantSurveyLifecycle, type SurveyAssistantSurveyPanelProps, type SurveyAssistantThreadCleanupResult, type SurveyAssistantThreadDocument, type SurveyAssistantThreadDocumentContent, type SurveyAssistantThreadDocumentRepository, type SurveyAssistantThreadErrorContext, type SurveyAssistantThreadIdentity, type SurveyAssistantThreadRepository, type SurveyAssistantTurnMetrics, type SurveyAssistantTurnStreamOptions, type SurveyAuthoringReferenceTopic, buildSurveyAssistantRequestContext, createMastraMemoryThreadRepository, createSurveyAssistantChatHandler, createSurveyAssistantSurveyLifecycle, createSurveyAssistantSurveyThreadMetadata, createSurveyAssistantThreadHandlers, createSurveyAssistantTurnStream, deriveSurveyAssistantDocumentTransition, describeSurveyAssistantStreamError, formatSurveyAssistantStreamError, formatSurveyAuthoringReferenceRoutingInstructions, getSurveyAssistantReplayableDocuments, loadSurveyAssistantDocuments, loadSurveyAssistantThreadAttachments, parseSurveyAssistantPreviousApplyOutcome, parseSurveyAssistantPreviousSettledVersion, parseSurveyAssistantSnapshot, readSurveyAssistantRequestJson, registerSurveyAssistantThreadAttachments, removeHistoricalSurveyAssistantAttachments, replaceCurrentSurveyAssistantAttachmentsWithReferences, requireSurveyAssistantTurnState, surveyAuthoringReferenceTopics, surveyAuthoringReferences, validateSurveyAssistantMessages };
|
|
129
129
|
//# sourceMappingURL=server.d.mts.map
|
package/dist/server.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as SURVEY_ASSISTANT_TASK_AGENT_ID, t as SURVEY_ASSISTANT_AGENT_ID } from "./constants-
|
|
2
|
-
import { a as parseSurveyAssistantPreviousSettledVersion, i as parseSurveyAssistantPreviousApplyOutcome, n as deriveSurveyAssistantDocumentTransition, o as parseSurveyAssistantSnapshot, s as requireSurveyAssistantTurnState, t as buildSurveyAssistantRequestContext } from "./request-context-
|
|
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-
|
|
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-
|
|
5
|
-
import {
|
|
1
|
+
import { n as SURVEY_ASSISTANT_TASK_AGENT_ID, t as SURVEY_ASSISTANT_AGENT_ID } from "./constants-0UHGFcRJ.mjs";
|
|
2
|
+
import { a as parseSurveyAssistantPreviousSettledVersion, i as parseSurveyAssistantPreviousApplyOutcome, n as deriveSurveyAssistantDocumentTransition, o as parseSurveyAssistantSnapshot, s as requireSurveyAssistantTurnState, t as buildSurveyAssistantRequestContext } from "./request-context-BjTHNcDd.mjs";
|
|
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-TmgQtqp4.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-CjFGVNZh.mjs";
|
|
5
|
+
import { a as surveyAuthoringReferences, i as surveyAuthoringReferenceTopics, n as formatSurveyAuthoringReferenceRoutingInstructions } from "./authoring-references-CW38pYzK.mjs";
|
|
6
6
|
//#region src/server/survey-lifecycle.ts
|
|
7
7
|
const SURVEY_ASSISTANT_SURVEY_ID_METADATA_KEY = "surveyId";
|
|
8
8
|
const normalizeIdentifier = (value, label) => {
|
|
@@ -132,6 +132,6 @@ const createSurveyAssistantSurveyLifecycle = ({ getMemory, getThreadApi, scopeMe
|
|
|
132
132
|
});
|
|
133
133
|
};
|
|
134
134
|
//#endregion
|
|
135
|
-
export { SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES, SURVEY_ASSISTANT_AGENT_ID, SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS, SURVEY_ASSISTANT_MAX_ATTACHMENTS, SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES, SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS, SURVEY_ASSISTANT_MAX_MESSAGES, SURVEY_ASSISTANT_MAX_REQUEST_BYTES, SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS, SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES, SURVEY_ASSISTANT_SURVEY_ID_METADATA_KEY, SURVEY_ASSISTANT_TASK_AGENT_ID, SurveyAssistantAuthorizationError, SurveyAssistantRequestError, buildSurveyAssistantRequestContext, createMastraMemoryThreadRepository, createSurveyAssistantChatHandler, createSurveyAssistantSurveyLifecycle, createSurveyAssistantSurveyThreadMetadata, createSurveyAssistantThreadHandlers, createSurveyAssistantTurnStream, deriveSurveyAssistantDocumentTransition, describeSurveyAssistantStreamError, formatSurveyAssistantStreamError, getSurveyAssistantReplayableDocuments, loadSurveyAssistantDocuments, loadSurveyAssistantThreadAttachments, parseSurveyAssistantPreviousApplyOutcome, parseSurveyAssistantPreviousSettledVersion, parseSurveyAssistantSnapshot, readSurveyAssistantRequestJson, registerSurveyAssistantThreadAttachments, removeHistoricalSurveyAssistantAttachments, replaceCurrentSurveyAssistantAttachmentsWithReferences, requireSurveyAssistantTurnState, surveyAuthoringReferenceTopics, surveyAuthoringReferences, validateSurveyAssistantMessages };
|
|
135
|
+
export { SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES, SURVEY_ASSISTANT_AGENT_ID, SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS, SURVEY_ASSISTANT_MAX_ATTACHMENTS, SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES, SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS, SURVEY_ASSISTANT_MAX_MESSAGES, SURVEY_ASSISTANT_MAX_REQUEST_BYTES, SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS, SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES, SURVEY_ASSISTANT_SURVEY_ID_METADATA_KEY, SURVEY_ASSISTANT_TASK_AGENT_ID, SurveyAssistantAuthorizationError, SurveyAssistantRequestError, buildSurveyAssistantRequestContext, createMastraMemoryThreadRepository, createSurveyAssistantChatHandler, createSurveyAssistantSurveyLifecycle, createSurveyAssistantSurveyThreadMetadata, createSurveyAssistantThreadHandlers, createSurveyAssistantTurnStream, deriveSurveyAssistantDocumentTransition, describeSurveyAssistantStreamError, formatSurveyAssistantStreamError, formatSurveyAuthoringReferenceRoutingInstructions, getSurveyAssistantReplayableDocuments, loadSurveyAssistantDocuments, loadSurveyAssistantThreadAttachments, parseSurveyAssistantPreviousApplyOutcome, parseSurveyAssistantPreviousSettledVersion, parseSurveyAssistantSnapshot, readSurveyAssistantRequestJson, registerSurveyAssistantThreadAttachments, removeHistoricalSurveyAssistantAttachments, replaceCurrentSurveyAssistantAttachmentsWithReferences, requireSurveyAssistantTurnState, surveyAuthoringReferenceTopics, surveyAuthoringReferences, validateSurveyAssistantMessages };
|
|
136
136
|
|
|
137
137
|
//# sourceMappingURL=server.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SurveyAssistantThreadDocumentRepository } from "./thread-documents-
|
|
1
|
+
import { a as SurveyAssistantThreadDocumentRepository } from "./thread-documents-rmd6nyX9.mjs";
|
|
2
2
|
import { PostgresStore, PostgresStoreConfig } from "@mastra/pg";
|
|
3
3
|
|
|
4
4
|
//#region src/storage/postgres.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as SurveyAssistantRequestError } from "./request-guardrails-
|
|
1
|
+
import { u as SurveyAssistantRequestError } from "./request-guardrails-TmgQtqp4.mjs";
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import { OBSERVATIONAL_MEMORY_TABLE_SCHEMA } from "@mastra/core/storage";
|
|
4
4
|
import { PostgresStore } from "@mastra/pg";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as SurveyAssistantSuggestItemKeyInput, d as SurveyAssistantSuggestItemLabelResult, l as SurveyAssistantSuggestItemKeyResult, m as SurveyAssistantTaskInvocationMode, p as SurveyAssistantTaskContext, u as SurveyAssistantSuggestItemLabelInput, v as SurveyAssistantTranslateContentInput, y as SurveyAssistantTranslateContentResult } from "./index-
|
|
2
|
-
import { a as SurveyAssistantModelSelection, n as SURVEY_ASSISTANT_TASK_AGENT_ID, o as SurveyAssistantRequestContext } from "./constants-
|
|
1
|
+
import { c as SurveyAssistantSuggestItemKeyInput, d as SurveyAssistantSuggestItemLabelResult, l as SurveyAssistantSuggestItemKeyResult, m as SurveyAssistantTaskInvocationMode, p as SurveyAssistantTaskContext, u as SurveyAssistantSuggestItemLabelInput, v as SurveyAssistantTranslateContentInput, y as SurveyAssistantTranslateContentResult } from "./index-DvTqML-0.mjs";
|
|
2
|
+
import { a as SurveyAssistantModelSelection, n as SURVEY_ASSISTANT_TASK_AGENT_ID, o as SurveyAssistantRequestContext } from "./constants-BMGTgfjv.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";
|
|
@@ -12,48 +12,60 @@ declare const surveyAuthoringReferences: {
|
|
|
12
12
|
readonly "core-rules": {
|
|
13
13
|
readonly title: "Core authoring rules";
|
|
14
14
|
readonly content: string;
|
|
15
|
+
readonly loadWhen: "Load when the task depends on canonical tool choice, validation/apply semantics, identifier handling, or another cross-cutting authoring rule that the current turn has not already established.";
|
|
15
16
|
};
|
|
16
17
|
readonly "survey-data-model": {
|
|
17
18
|
readonly title: "Survey data model";
|
|
18
19
|
readonly content: string;
|
|
20
|
+
readonly loadWhen: "Load before reasoning about raw survey storage, hierarchy, ids, translation maps, assets, template values, or any direct survey-json-patch path whose exact location has not already been inspected and documented in the current turn.";
|
|
19
21
|
};
|
|
20
22
|
readonly "source-material-surveys": {
|
|
21
23
|
readonly title: "Source-material survey implementation";
|
|
22
24
|
readonly content: string;
|
|
25
|
+
readonly loadWhen: "Load before implementing or adapting a questionnaire, document, image, or other supplied source material so completeness, respondent-input mapping, language, and digital adaptation rules are available before the first mutation.";
|
|
23
26
|
};
|
|
24
27
|
readonly localization: {
|
|
25
28
|
readonly title: "Survey localization";
|
|
26
29
|
readonly content: string;
|
|
30
|
+
readonly loadWhen: "Load before adding, removing, translating, or assessing a survey locale, including requests for localization completeness or locale lifecycle changes.";
|
|
27
31
|
};
|
|
28
32
|
readonly "rich-text-content": {
|
|
29
33
|
readonly title: "Rich text content";
|
|
30
34
|
readonly content: string;
|
|
35
|
+
readonly loadWhen: "Load before authoring or changing meaningful formatting, links, images, headings, lists, info boxes, separators, footnotes, or existing structured rich-text content; do not load it for ordinary unformatted plain text.";
|
|
31
36
|
};
|
|
32
37
|
readonly "item-types": {
|
|
33
38
|
readonly title: "Item types";
|
|
34
39
|
readonly content: string;
|
|
40
|
+
readonly loadWhen: "Load with itemType before creating or changing an item when its configuration, response behavior, or content surfaces are not already fully specified by the current capability and focused operation contract; omit itemType only for a genuine cross-type comparison.";
|
|
35
41
|
};
|
|
36
42
|
readonly "embedded-forms": {
|
|
37
43
|
readonly title: "Choice option embedded forms";
|
|
38
44
|
readonly content: string;
|
|
45
|
+
readonly loadWhen: "Load before creating or changing a choice-option follow-up or embedded form, including \"Other, specify\", option-specific inputs, embedded field groups, or embedded-form layout and translations.";
|
|
39
46
|
};
|
|
40
47
|
readonly expressions: {
|
|
41
48
|
readonly title: "Expressions";
|
|
42
49
|
readonly content: string;
|
|
50
|
+
readonly loadWhen: "Load before the first survey_expression prepare call for expression, condition, validation-expression, prefill, or template-value work unless the exact relevant JsonExpression and mutation shapes were already supplied by a current-turn authoring reference. survey_expression context supplies currently available runtime references and value types, but it does not replace the grammar reference. Expressions are not assumed to be survey-response-only; use the references and variable sources supported by the current runtime and reference.";
|
|
43
51
|
};
|
|
44
52
|
readonly "assistant-operations": {
|
|
45
53
|
readonly title: "Assistant operations";
|
|
46
54
|
readonly content: string;
|
|
55
|
+
readonly loadWhen: "Load with operationKind before the first survey_change call when the exact canonical fields of that operation are not already present in the current turn; add itemType when item-specific configuration or capability guidance is needed. Prefer compact detail and use full only for protocol debugging.";
|
|
47
56
|
};
|
|
48
57
|
readonly "fair-by-design": {
|
|
49
58
|
readonly title: "FAIR-by-design survey authoring";
|
|
50
59
|
readonly content: string;
|
|
60
|
+
readonly loadWhen: "Load before advising or editing when FAIR, interoperability, harmonization, cross-study reuse, stable coding, value sets, missingness semantics, metadata, provenance, versioning, standard instruments, controlled vocabularies, or machine-readable export is material; do not impose it on ordinary authoring.";
|
|
51
61
|
};
|
|
52
62
|
readonly "survey-quality": {
|
|
53
63
|
readonly title: "Survey quality review";
|
|
54
64
|
readonly content: string;
|
|
65
|
+
readonly loadWhen: "Load before a substantive questionnaire-quality critique, wording or flow review, respondent-burden assessment, or recommendations about measurement quality; it is not required for a purely technical defect check.";
|
|
55
66
|
};
|
|
56
67
|
};
|
|
68
|
+
declare const formatSurveyAuthoringReferenceRoutingInstructions: () => string;
|
|
57
69
|
//#endregion
|
|
58
70
|
//#region src/server/tasks.d.ts
|
|
59
71
|
type SurveyAssistantTaskAgentConfig = AgentConfig<typeof SURVEY_ASSISTANT_TASK_AGENT_ID, Record<string, never>, undefined, SurveyAssistantRequestContext>;
|
|
@@ -140,5 +152,5 @@ declare const createSurveyAssistantTaskHandler: ({
|
|
|
140
152
|
resolveModel
|
|
141
153
|
}: CreateSurveyAssistantTaskHandlerOptions) => (request: Request) => Promise<Response>;
|
|
142
154
|
//#endregion
|
|
143
|
-
export { SurveyAssistantTaskAuthorizationInput as a, createSurveyAssistantTaskAgent as c, runSurveyAssistantSuggestItemLabelTask as d, runSurveyAssistantTask as f,
|
|
144
|
-
//# sourceMappingURL=tasks-
|
|
155
|
+
export { surveyAuthoringReferences as _, SurveyAssistantTaskAuthorizationInput as a, createSurveyAssistantTaskAgent as c, runSurveyAssistantSuggestItemLabelTask as d, runSurveyAssistantTask as f, surveyAuthoringReferenceTopics as g, formatSurveyAuthoringReferenceRoutingInstructions 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 };
|
|
156
|
+
//# sourceMappingURL=tasks-DxzD25Zc.d.mts.map
|
|
@@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loadSurveyAssistantDocuments: ({
|
|
|
104
104
|
}) => Promise<SurveyAssistantModelAttachment[]>;
|
|
105
105
|
//#endregion
|
|
106
106
|
export { SurveyAssistantThreadDocumentRepository as a, loadSurveyAssistantThreadAttachments as c, replaceCurrentSurveyAssistantAttachmentsWithReferences as d, SurveyAssistantThreadDocumentContent as i, registerSurveyAssistantThreadAttachments as l, SurveyAssistantModelAttachment as n, getSurveyAssistantReplayableDocuments as o, SurveyAssistantThreadDocument as r, loadSurveyAssistantDocuments as s, SurveyAssistantAttachmentAccess as t, removeHistoricalSurveyAssistantAttachments as u };
|
|
107
|
-
//# sourceMappingURL=thread-documents-
|
|
107
|
+
//# sourceMappingURL=thread-documents-rmd6nyX9.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-documents-
|
|
1
|
+
{"version":3,"file":"thread-documents-rmd6nyX9.d.mts","names":[],"sources":["../src/server/thread-documents.ts"],"mappings":";;;;UAOiB,6BAAA;EACf,EAAA;EACA,IAAA;EACA,SAAA;EACA,KAAA;EACA,WAAA;EACA,SAAA;AAAA;AAAA,UAGe,oCAAA,SAA6C,6BAAA;EAC5D,IAAA;AAAA;AAAA,UAGe,8BAAA;EACf,QAAA;EACA,SAAA;EACA,IAAA;EACA,WAAA;AAAA;AAAA,UAGe,+BAAA;EACf,SAAA,EAAW,6BAAA;EAXP;EAaJ,kBAAA;EACA,mBAAA,EAAqB,8BAAA;EACrB,IAAA,CAAK,WAAA,aAAwB,OAAA,CAAQ,8BAAA;AAAA;AAAA,UAGtB,uCAAA;EACf,GAAA,CAAI,KAAA;IACF,UAAA;IACA,QAAA;IACA,IAAA;IACA,SAAA;IACA,IAAA;IACA,KAAA;EAAA,IACE,OAAA,CAAQ,6BAAA;EACZ,IAAA,CAAK,KAAA;IAAS,UAAA;IAAoB,QAAA;EAAA,IAAqB,OAAA,CAAQ,6BAAA;EAC/D,IAAA,CAAK,KAAA;IACH,UAAA;IACA,QAAA;IACA,UAAA;EAAA,IACE,OAAA,CAAQ,oCAAA;EACZ,YAAA,CAAa,KAAA;IAAS,UAAA;IAAoB,QAAA;EAAA,IAAqB,OAAA;AAAA;;;;AAfjE;;cA4Da,sDAAA;EAA0D,SAAA;EAAA;AAAA;EAIrE,SAAA,EAAW,6BAAA;EACX,QAAA,EAAU,SAAA;AAAA,MACR,SAAA;AAAA,cA2BS,wCAAA;EAAkD,QAAA;EAAA,UAAA;EAAA,UAAA;EAAA;AAAA;EAM7D,QAAA,EAAU,SAAA;EACV,UAAA,EAAY,uCAAA;EACZ,UAAA;EACA,QAAA;AAAA,MACD,OAAA,CAAA,6BAAA;AAAA,cAkCY,0CAAA,GAA8C,QAAA,EAAU,SAAA,OAAW,SAAA,UAAF,IAAA,CAAE,WAAA,EAAA,IAAA,CAAA,OAAA;;;;;cAanE,qCAAA,GACX,SAAA,EAAW,6BAAA,IACX,kBAAA,EAAoB,WAAA,aAAmB,6BAAA;AAAA,cAG5B,oCAAA;EAA8C,kBAAA;EAAA,SAAA;EAAA,UAAA;EAAA,UAAA;EAAA;AAAA;EAOzD,kBAAA,GAAqB,WAAA;EACrB,SAAA,EAAW,6BAAA;EACX,UAAA,EAAY,uCAAA;EACZ,UAAA;EACA,QAAA;AAAA,MACE,OAAA,CAAQ,8BAAA;AAAA,cAWC,4BAAA;EAAsC,SAAA;EAAA,UAAA;EAAA,UAAA;EAAA;AAAA;EAMjD,SAAA,EAAW,6BAAA;EACX,UAAA,EAAY,uCAAA;EACZ,UAAA;EACA,QAAA;AAAA,MACE,OAAA,CAAQ,8BAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { p as SurveyAssistantTurnTerminationReason } from "./lifecycle-
|
|
2
|
-
import {
|
|
3
|
-
import { a as SurveyAssistantThreadDocumentRepository } from "./thread-documents-
|
|
4
|
-
import { a as SurveyAssistantModelSelection, i as SurveyAssistantIdentityContext } from "./constants-
|
|
1
|
+
import { p as SurveyAssistantTurnTerminationReason } from "./lifecycle-BmGAIUlv.mjs";
|
|
2
|
+
import { Gt as SurveyAssistantCapabilitySet } from "./index-D6nqkz0O.mjs";
|
|
3
|
+
import { a as SurveyAssistantThreadDocumentRepository } from "./thread-documents-rmd6nyX9.mjs";
|
|
4
|
+
import { a as SurveyAssistantModelSelection, i as SurveyAssistantIdentityContext } from "./constants-BMGTgfjv.mjs";
|
|
5
5
|
import { UIMessage } from "ai";
|
|
6
6
|
import { AgentExecutionOptions } from "@mastra/core/agent";
|
|
7
7
|
import { Mastra } from "@mastra/core/mastra";
|
|
@@ -162,4 +162,4 @@ declare const createSurveyAssistantThreadHandlers: ({
|
|
|
162
162
|
};
|
|
163
163
|
//#endregion
|
|
164
164
|
export { readSurveyAssistantRequestJson as A, SURVEY_ASSISTANT_MAX_ATTACHMENT_NAME_CHARS as C, SURVEY_ASSISTANT_MAX_TOTAL_ATTACHMENT_BYTES as D, SURVEY_ASSISTANT_MAX_TEXT_PART_CHARS as E, SurveyAssistantRequestError as O, SURVEY_ASSISTANT_MAX_ATTACHMENT_BYTES as S, SURVEY_ASSISTANT_MAX_REQUEST_BYTES as T, describeSurveyAssistantStreamError as _, SurveyAssistantThreadRepository as a, SURVEY_ASSISTANT_DEFAULT_REQUEST_LIMITS as b, SurveyAssistantAuthorizationInput as c, SurveyAssistantChatHandlerOptions as d, SurveyAssistantModelResolutionInput as f, createSurveyAssistantChatHandler as g, SurveyAssistantTurnMetrics as h, SurveyAssistantThreadIdentity as i, validateSurveyAssistantMessages as j, SurveyAssistantRequestLimits as k, SurveyAssistantAuthorize as l, SurveyAssistantStreamErrorContext as m, SurveyAssistantStoredThread as n, createSurveyAssistantThreadHandlers as o, SurveyAssistantResolveModel as p, SurveyAssistantThreadErrorContext as r, SurveyAssistantAuthorizationError as s, CreateSurveyAssistantThreadHandlersOptions as t, SurveyAssistantAuthorizedIdentity as u, formatSurveyAssistantStreamError as v, SURVEY_ASSISTANT_MAX_MESSAGES as w, SURVEY_ASSISTANT_MAX_ATTACHMENTS as x, SURVEY_ASSISTANT_ACCEPTED_ATTACHMENT_TYPES as y };
|
|
165
|
-
//# sourceMappingURL=thread-handlers-
|
|
165
|
+
//# sourceMappingURL=thread-handlers-AbQbt4sX.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-handlers-
|
|
1
|
+
{"version":3,"file":"thread-handlers-AbQbt4sX.d.mts","names":[],"sources":["../src/server/request-guardrails.ts","../src/server/handler.ts","../src/server/thread-handlers.ts"],"mappings":";;;;;;;;;cAGa,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,UAItC,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,cA8ClB,+BAAA,GACX,KAAA,WACA,MAAA,GAAQ,4BAAA,KACP,SAAA;AAAA,cAmFU,8BAAA,GACX,OAAA,EAAS,OAAA,EACT,eAAA,cACC,OAAA;;;KCvHE,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,KAAA,EAAO,mCAAA,KAEL,OAAA,CAAQ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