@case-framework/survey-assistant 0.4.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/README.md +8 -0
- 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-k1b_evIb.d.mts → constants-BMGTgfjv.d.mts} +4 -4
- package/dist/{constants-k1b_evIb.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-quQjtA7j.d.mts → controller-proxy-mRvez2qw.d.mts} +3 -3
- package/dist/{controller-proxy-quQjtA7j.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-BvfUx_Jx.mjs → engine-CQwOAcwK.mjs} +167 -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-biZnRl-h.d.mts → index-B0lxsAzx.d.mts} +10 -6
- package/dist/index-B0lxsAzx.d.mts.map +1 -0
- package/dist/{index-BDp6S7r9.d.mts → index-BS-Xjk1h.d.mts} +4 -4
- package/dist/{index-BDp6S7r9.d.mts.map → index-BS-Xjk1h.d.mts.map} +1 -1
- package/dist/{index-r8HVcn5b.d.mts → index-D6nqkz0O.d.mts} +49 -8
- package/dist/{index-r8HVcn5b.d.mts.map → index-D6nqkz0O.d.mts.map} +1 -1
- package/dist/{index-8x1Eqlnz.d.mts → index-DvTqML-0.d.mts} +10 -5
- 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-xBZOog_q.mjs → memory-thread-repository-CjFGVNZh.mjs} +44 -13
- package/dist/{memory-thread-repository-xBZOog_q.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-DixY5DYu.mjs → request-context-BjTHNcDd.mjs} +2 -2
- package/dist/{request-context-DixY5DYu.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 +9 -7
- package/dist/server-agent.d.mts.map +1 -1
- package/dist/server-agent.mjs +8 -6
- package/dist/server-agent.mjs.map +1 -1
- package/dist/server-runtime.d.mts +28 -14
- package/dist/server-runtime.d.mts.map +1 -1
- package/dist/server-runtime.mjs +47 -8
- package/dist/server-runtime.mjs.map +1 -1
- 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 +4 -1
- package/dist/storage-postgres.mjs.map +1 -1
- package/dist/{tasks-BWmTMXoK.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-D8gkLfU6.d.mts → thread-handlers-AbQbt4sX.d.mts} +13 -6
- package/dist/{thread-handlers-D8gkLfU6.d.mts.map → thread-handlers-AbQbt4sX.d.mts.map} +1 -1
- package/dist/{tools-TXI8bfzZ.mjs → tools-CFh35R4d.mjs} +14 -6
- 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 +198 -83
- package/dist/ui.mjs.map +1 -1
- package/docs/integration.md +37 -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-BvfUx_Jx.mjs.map +0 -1
- package/dist/index-8x1Eqlnz.d.mts.map +0 -1
- package/dist/index-biZnRl-h.d.mts.map +0 -1
- package/dist/request-guardrails-h4t6u8mP.mjs.map +0 -1
- package/dist/tasks-BWmTMXoK.d.mts.map +0 -1
- package/dist/tools-TXI8bfzZ.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { I as rawSurveyDocumentSchema, f as surveyChangeSetSchema, l as surveyAssistantTurnFinalSchema } from "./protocol-DJUP4gc0.mjs";
|
|
2
|
-
import { a as normalizeFormAuthoringConfig, c as assertSurveyAssistantCapabilities, i as isValidSimpleFormConfig, o as transitionFormAuthoringMode, r as isCompatibleSimpleFieldUpsert, t as getFormAuthoringMode } from "./form-authoring-
|
|
2
|
+
import { a as normalizeFormAuthoringConfig, c as assertSurveyAssistantCapabilities, i as isValidSimpleFormConfig, o as transitionFormAuthoringMode, r as isCompatibleSimpleFieldUpsert, t as getFormAuthoringMode } from "./form-authoring-kQDgC5oz.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ContentType, Expression, ExpressionType, FunctionExpressionNames, JsonPatchError, ReservedSurveyItemTypes, SurveyItemTranslations, SurveyTranslations, ValueReference, ValueReferenceMethod, ValueType, analyzeSurveyExpressionReferences, applyJsonPatch, findIntroducedExpressionReferenceDiagnostics, generateId, getContentPlainText, isContentEmpty, parseJsonPointer, structuredCloneMethod } from "@case-framework/survey-core";
|
|
5
5
|
//#region src/engine/context.ts
|
|
@@ -2398,10 +2398,20 @@ const validateSurveyTreeStructure = (survey, operationId, availableItemTypes) =>
|
|
|
2398
2398
|
for (const item of itemsById.values()) {
|
|
2399
2399
|
const childRefs = (isRecord$2(item.config) ? item.config : void 0)?.items;
|
|
2400
2400
|
if (childRefs === void 0) continue;
|
|
2401
|
-
if (
|
|
2401
|
+
if (!Array.isArray(childRefs)) {
|
|
2402
2402
|
issues.push(createStructureIssue({
|
|
2403
2403
|
code: "invalid-group-items",
|
|
2404
|
-
message: `Item "${item.id}" has an
|
|
2404
|
+
message: `Item "${item.id}" has an invalid group items value.`,
|
|
2405
|
+
operationId,
|
|
2406
|
+
itemId: item.id
|
|
2407
|
+
}));
|
|
2408
|
+
continue;
|
|
2409
|
+
}
|
|
2410
|
+
if (item.itemType !== ReservedSurveyItemTypes.Group) {
|
|
2411
|
+
if (childRefs.length === 0) continue;
|
|
2412
|
+
issues.push(createStructureIssue({
|
|
2413
|
+
code: "invalid-group-items",
|
|
2414
|
+
message: `Item "${item.id}" has child references but is not a valid group item.`,
|
|
2405
2415
|
operationId,
|
|
2406
2416
|
itemId: item.id
|
|
2407
2417
|
}));
|
|
@@ -2510,7 +2520,7 @@ const collectIntroducedExpressionIntegrityIssues = ({ after, before, operationId
|
|
|
2510
2520
|
operationId,
|
|
2511
2521
|
itemId: diagnostic.ownerItemId
|
|
2512
2522
|
}));
|
|
2513
|
-
const validateSurveyJsonPatchOperation = ({ operation, snapshot }) => {
|
|
2523
|
+
const validateSurveyJsonPatchOperation = ({ allowExpressionJsonPatches, operation, snapshot }) => {
|
|
2514
2524
|
const operationId = getOperationId(operation);
|
|
2515
2525
|
const issues = [];
|
|
2516
2526
|
const warnings = [];
|
|
@@ -2525,6 +2535,19 @@ const validateSurveyJsonPatchOperation = ({ operation, snapshot }) => {
|
|
|
2525
2535
|
operationIndex: 0,
|
|
2526
2536
|
operationId
|
|
2527
2537
|
}));
|
|
2538
|
+
const segments = parseJsonPointer(path);
|
|
2539
|
+
const expressionOwnedPath = segments[0] === "templateValues" || segments[0] === "surveyItems" && [
|
|
2540
|
+
"displayConditions",
|
|
2541
|
+
"disabledConditions",
|
|
2542
|
+
"validations",
|
|
2543
|
+
"prefills"
|
|
2544
|
+
].includes(segments[2] ?? "");
|
|
2545
|
+
if (!allowExpressionJsonPatches && expressionOwnedPath) issues.push(createIssue({
|
|
2546
|
+
code: "expression-patch-requires-specialized-tool",
|
|
2547
|
+
message: "Use survey_expression for display conditions, disabled conditions, expression validations, prefills, and template values. A raw survey patch cannot modify an expression-owned location.",
|
|
2548
|
+
operationIndex: 0,
|
|
2549
|
+
operationId
|
|
2550
|
+
}));
|
|
2528
2551
|
} catch (error) {
|
|
2529
2552
|
issues.push(createIssue({
|
|
2530
2553
|
code: "invalid-json-pointer",
|
|
@@ -3456,7 +3479,7 @@ const getDeletedAncestor = (itemId, parentByChildId, deletedItemIds) => {
|
|
|
3456
3479
|
};
|
|
3457
3480
|
const buildSurveyDocumentVersion = (snapshot) => ({ ...snapshot.version });
|
|
3458
3481
|
const resolveEngineContext = (snapshot) => "document" in snapshot ? snapshot : createSurveyAssistantEngineContext(snapshot);
|
|
3459
|
-
const validateSurveyOperations = ({ maxOperations = 200, operations, snapshot: snapshotInput }) => {
|
|
3482
|
+
const validateSurveyOperations = ({ allowExpressionJsonPatches = false, maxOperations = 200, operations, snapshot: snapshotInput }) => {
|
|
3460
3483
|
if (!snapshotInput) return createEmptyValidationResult(createIssue({
|
|
3461
3484
|
code: "missing-snapshot",
|
|
3462
3485
|
message: "No live editor snapshot was provided for this assistant turn."
|
|
@@ -3479,6 +3502,7 @@ const validateSurveyOperations = ({ maxOperations = 200, operations, snapshot: s
|
|
|
3479
3502
|
operationId: surveyJsonPatchOperations[0]?.id
|
|
3480
3503
|
}), operations);
|
|
3481
3504
|
return validateSurveyJsonPatchOperation({
|
|
3505
|
+
allowExpressionJsonPatches,
|
|
3482
3506
|
operation: surveyJsonPatchOperations[0],
|
|
3483
3507
|
snapshot
|
|
3484
3508
|
});
|
|
@@ -4675,7 +4699,7 @@ const validateSurveyOperations = ({ maxOperations = 200, operations, snapshot: s
|
|
|
4675
4699
|
}
|
|
4676
4700
|
});
|
|
4677
4701
|
if (issues.length === 0) try {
|
|
4678
|
-
const prospectiveSurvey =
|
|
4702
|
+
const prospectiveSurvey = executeSurveyOperationsOnRawSurvey({
|
|
4679
4703
|
operations: normalizedOperations,
|
|
4680
4704
|
survey: snapshot.survey
|
|
4681
4705
|
});
|
|
@@ -4719,11 +4743,12 @@ const removeDraftTranslationPrefix = ({ itemId, prefix, survey }) => {
|
|
|
4719
4743
|
survey.translations = surveyTranslations.serialize();
|
|
4720
4744
|
};
|
|
4721
4745
|
/**
|
|
4722
|
-
*
|
|
4723
|
-
*
|
|
4724
|
-
*
|
|
4746
|
+
* Canonical pure executor for already-normalized, validated survey operation
|
|
4747
|
+
* semantics. Raw-draft simulation uses the returned survey directly; editor
|
|
4748
|
+
* adapters use it to decide domain results before recording them through the
|
|
4749
|
+
* editor's normal mutation and history APIs.
|
|
4725
4750
|
*/
|
|
4726
|
-
const
|
|
4751
|
+
const executeSurveyOperationsOnRawSurvey = ({ operations, survey: inputSurvey }) => {
|
|
4727
4752
|
let survey = structuredCloneMethod(inputSurvey);
|
|
4728
4753
|
const getItem = (itemId) => {
|
|
4729
4754
|
const item = survey.surveyItems.find((candidate) => candidate.id === itemId);
|
|
@@ -4957,12 +4982,21 @@ const applyValidatedSurveyOperationsToDraft = ({ operations, survey: inputSurvey
|
|
|
4957
4982
|
translations: operation.translations
|
|
4958
4983
|
});
|
|
4959
4984
|
} else if (operation.kind === "remove-form-field-group") {
|
|
4985
|
+
const removedGroup = groups.find((group) => group.id === operation.groupId);
|
|
4960
4986
|
groups = groups.filter((group) => group.id !== operation.groupId);
|
|
4961
4987
|
removeDraftTranslationPrefix({
|
|
4962
4988
|
itemId: item.id,
|
|
4963
4989
|
prefix: `${operation.target.optionId ? `embeddedForms.${operation.target.optionId}.` : ""}fieldGroups.${operation.groupId}`,
|
|
4964
4990
|
survey
|
|
4965
4991
|
});
|
|
4992
|
+
for (const field of removedGroup?.fields ?? []) {
|
|
4993
|
+
if (typeof field.id !== "string") continue;
|
|
4994
|
+
removeDraftTranslationPrefix({
|
|
4995
|
+
itemId: item.id,
|
|
4996
|
+
prefix: `${operation.target.optionId ? `embeddedForms.${operation.target.optionId}.` : ""}fields.${field.id}`,
|
|
4997
|
+
survey
|
|
4998
|
+
});
|
|
4999
|
+
}
|
|
4966
5000
|
} else if (operation.kind === "reorder-form-field-groups") {
|
|
4967
5001
|
const byId = new Map(groups.map((group) => [group.id, group]));
|
|
4968
5002
|
groups = operation.groupIds.map((groupId) => byId.get(groupId));
|
|
@@ -5008,13 +5042,17 @@ const applyValidatedSurveyOperationsToDraft = ({ operations, survey: inputSurvey
|
|
|
5008
5042
|
case "remove-item": {
|
|
5009
5043
|
const removeIds = collectDescendantIds(operation.itemId, new Map(survey.surveyItems.map((item) => [item.id, item])));
|
|
5010
5044
|
removeIds.add(operation.itemId);
|
|
5011
|
-
survey.surveyItems = survey.surveyItems.filter((item) => !removeIds.has(item.id)).map((item) =>
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5045
|
+
survey.surveyItems = survey.surveyItems.filter((item) => !removeIds.has(item.id)).map((item) => {
|
|
5046
|
+
if (!isRecord$2(item.config) || !Array.isArray(item.config.items)) return item;
|
|
5047
|
+
const items = item.config.items.filter((itemId) => typeof itemId === "string" && !removeIds.has(itemId));
|
|
5048
|
+
return items.length === item.config.items.length ? item : {
|
|
5049
|
+
...item,
|
|
5050
|
+
config: {
|
|
5051
|
+
...item.config,
|
|
5052
|
+
items
|
|
5053
|
+
}
|
|
5054
|
+
};
|
|
5055
|
+
});
|
|
5018
5056
|
const translations = new SurveyTranslations(survey.translations);
|
|
5019
5057
|
for (const itemId of removeIds) translations.setItemTranslations(itemId, void 0);
|
|
5020
5058
|
survey.translations = translations.serialize();
|
|
@@ -5121,8 +5159,11 @@ const applyValidatedSurveyOperationsToDraft = ({ operations, survey: inputSurvey
|
|
|
5121
5159
|
}
|
|
5122
5160
|
return rawSurveyDocumentSchema.parse(survey);
|
|
5123
5161
|
};
|
|
5124
|
-
|
|
5162
|
+
/** @deprecated Prefer `executeSurveyOperationsOnRawSurvey` for new integrations. */
|
|
5163
|
+
const applyValidatedSurveyOperationsToDraft = executeSurveyOperationsOnRawSurvey;
|
|
5164
|
+
const createSurveyChangeSet = ({ allowExpressionJsonPatches, maxOperations, operations, snapshot, summary, turnId }) => {
|
|
5125
5165
|
const validation = validateSurveyOperations({
|
|
5166
|
+
allowExpressionJsonPatches,
|
|
5126
5167
|
maxOperations,
|
|
5127
5168
|
operations,
|
|
5128
5169
|
snapshot
|
|
@@ -5170,6 +5211,11 @@ const QUALITY_PRINCIPLES = [
|
|
|
5170
5211
|
title: "Response option quality",
|
|
5171
5212
|
prompt: "Are options mutually exclusive, collectively sufficient, balanced, ordered, and consistently scaled?"
|
|
5172
5213
|
},
|
|
5214
|
+
{
|
|
5215
|
+
id: "key-semantic-consistency",
|
|
5216
|
+
title: "Coding-key consistency",
|
|
5217
|
+
prompt: "Do item, option, and field keys follow the survey's established convention and avoid contradicting the content they currently identify? Generic, numeric, or opaque keys are acceptable when that is the survey's consistent pattern; flag descriptive keys when they have become stale or misleading, and mixed conventions when the inconsistency appears accidental."
|
|
5218
|
+
},
|
|
5173
5219
|
{
|
|
5174
5220
|
id: "flow",
|
|
5175
5221
|
title: "Flow and completeness",
|
|
@@ -5207,6 +5253,75 @@ const translationText = (context, locale, itemId, contentKey) => {
|
|
|
5207
5253
|
const content = (isRecord$1(itemTranslations?.[itemId]) ? itemTranslations[itemId] : void 0)?.[contentKey];
|
|
5208
5254
|
return content ? getContentPlainText(content).trim() : "";
|
|
5209
5255
|
};
|
|
5256
|
+
const summarizeItemContent = (context, locale, item) => {
|
|
5257
|
+
if (!locale) return {};
|
|
5258
|
+
const itemContent = context.survey.translations?.[locale]?.itemTranslations?.[item.id];
|
|
5259
|
+
if (!isRecord$1(itemContent)) return {};
|
|
5260
|
+
for (const contentKey of [
|
|
5261
|
+
"title",
|
|
5262
|
+
"content",
|
|
5263
|
+
"subtitle",
|
|
5264
|
+
"topContent",
|
|
5265
|
+
"bottomContent"
|
|
5266
|
+
]) {
|
|
5267
|
+
const content = itemContent[contentKey];
|
|
5268
|
+
if (!content) continue;
|
|
5269
|
+
const text = getContentPlainText(content).trim();
|
|
5270
|
+
if (text) return {
|
|
5271
|
+
contentKey,
|
|
5272
|
+
content: text
|
|
5273
|
+
};
|
|
5274
|
+
}
|
|
5275
|
+
return {};
|
|
5276
|
+
};
|
|
5277
|
+
const collectKeyReviewEntries = (context, sourceLocale) => {
|
|
5278
|
+
const entries = [];
|
|
5279
|
+
const addFormFields = (item, groups, contentPrefix) => {
|
|
5280
|
+
for (const group of groups) for (const field of records(group.fields)) {
|
|
5281
|
+
if (typeof field.id !== "string" || typeof field.key !== "string") continue;
|
|
5282
|
+
const contentKey = `${contentPrefix}fields.${field.id}.label`;
|
|
5283
|
+
const content = sourceLocale ? translationText(context, sourceLocale, item.id, contentKey) : "";
|
|
5284
|
+
entries.push({
|
|
5285
|
+
kind: "form-field",
|
|
5286
|
+
itemId: item.id,
|
|
5287
|
+
itemKey: item.key,
|
|
5288
|
+
key: field.key,
|
|
5289
|
+
keySource: "explicit",
|
|
5290
|
+
contentKey,
|
|
5291
|
+
...content ? { content } : {}
|
|
5292
|
+
});
|
|
5293
|
+
}
|
|
5294
|
+
};
|
|
5295
|
+
for (const item of context.survey.surveyItems) {
|
|
5296
|
+
entries.push({
|
|
5297
|
+
kind: "item",
|
|
5298
|
+
itemId: item.id,
|
|
5299
|
+
itemKey: item.key,
|
|
5300
|
+
key: item.key,
|
|
5301
|
+
keySource: "explicit",
|
|
5302
|
+
...summarizeItemContent(context, sourceLocale, item)
|
|
5303
|
+
});
|
|
5304
|
+
const config = isRecord$1(item.config) ? item.config : {};
|
|
5305
|
+
if (item.itemType === "choiceItem") for (const option of records(config.options)) {
|
|
5306
|
+
if (typeof option.id !== "string") continue;
|
|
5307
|
+
const explicitKey = typeof option.key === "string" && option.key.trim() ? option.key : null;
|
|
5308
|
+
const contentKey = `options.${option.id}.label`;
|
|
5309
|
+
const content = sourceLocale ? translationText(context, sourceLocale, item.id, contentKey) : "";
|
|
5310
|
+
entries.push({
|
|
5311
|
+
kind: "choice-option",
|
|
5312
|
+
itemId: item.id,
|
|
5313
|
+
itemKey: item.key,
|
|
5314
|
+
key: explicitKey ?? option.id,
|
|
5315
|
+
keySource: explicitKey ? "explicit" : "fallback-id",
|
|
5316
|
+
contentKey,
|
|
5317
|
+
...content ? { content } : {}
|
|
5318
|
+
});
|
|
5319
|
+
if (option.embeddedForm) addFormFields(item, getGroups(item, option.id), `embeddedForms.${option.id}.`);
|
|
5320
|
+
}
|
|
5321
|
+
else if (item.itemType === "formItem") addFormFields(item, getGroups(item), "");
|
|
5322
|
+
}
|
|
5323
|
+
return entries;
|
|
5324
|
+
};
|
|
5210
5325
|
const getGroups = (item, optionId) => {
|
|
5211
5326
|
const config = isRecord$1(item.config) ? item.config : {};
|
|
5212
5327
|
if (!optionId) return records(config.fieldGroups);
|
|
@@ -5285,6 +5400,10 @@ const auditSurvey = (context, options = {}) => {
|
|
|
5285
5400
|
const locales = context.inspection.locales;
|
|
5286
5401
|
const sourceLocale = options.sourceLocale ?? context.ui.selectedLocale ?? locales[0];
|
|
5287
5402
|
const targetLocales = options.targetLocales ?? locales.filter((locale) => locale !== sourceLocale);
|
|
5403
|
+
const allKeyReviewEntries = collectKeyReviewEntries(context, sourceLocale);
|
|
5404
|
+
const keyReviewOffset = Math.min(options.keyReviewOffset ?? 0, allKeyReviewEntries.length);
|
|
5405
|
+
const keyReviewLimit = options.keyReviewLimit ?? 30;
|
|
5406
|
+
const keyReviewEntries = allKeyReviewEntries.slice(keyReviewOffset, keyReviewOffset + keyReviewLimit);
|
|
5288
5407
|
const manifests = new Map(context.capabilities.itemTypes.map((entry) => [entry.itemType, entry]));
|
|
5289
5408
|
for (const item of items) {
|
|
5290
5409
|
const manifest = manifests.get(item.itemType);
|
|
@@ -5416,6 +5535,15 @@ const auditSurvey = (context, options = {}) => {
|
|
|
5416
5535
|
},
|
|
5417
5536
|
findings: limited,
|
|
5418
5537
|
qualityReviewPrinciples: QUALITY_PRINCIPLES,
|
|
5538
|
+
keyReview: {
|
|
5539
|
+
sourceLocale,
|
|
5540
|
+
entryCount: allKeyReviewEntries.length,
|
|
5541
|
+
offset: keyReviewOffset,
|
|
5542
|
+
returnedEntryCount: keyReviewEntries.length,
|
|
5543
|
+
truncated: keyReviewOffset + keyReviewEntries.length < allKeyReviewEntries.length,
|
|
5544
|
+
entries: keyReviewEntries,
|
|
5545
|
+
note: "These key/content pairs are evidence for qualitative review, not deterministic defects. Judge them against the survey's own naming pattern; generic or opaque keys are not inherently problematic."
|
|
5546
|
+
},
|
|
5419
5547
|
note: "Technical findings are deterministic. Quality principles are a structured review rubric; apply them with human/model judgment and domain context, and do not present them as psychometric validation."
|
|
5420
5548
|
};
|
|
5421
5549
|
};
|
|
@@ -5458,6 +5586,16 @@ const operationTargets = (operation) => {
|
|
|
5458
5586
|
}
|
|
5459
5587
|
};
|
|
5460
5588
|
const collectOperationTargets = (operations) => new Set(operations.flatMap(operationTargets));
|
|
5589
|
+
const mutationRecoveryRouteByIssueCode = { "expression-patch-requires-specialized-tool": "expression" };
|
|
5590
|
+
const mutationRouteTarget = (route) => `mutation-route:${route}`;
|
|
5591
|
+
const collectExclusiveMutationRecoveryTargets = (changeSet) => {
|
|
5592
|
+
const errorIssues = changeSet.validation.issues.filter((issue) => issue.severity === "error");
|
|
5593
|
+
if (errorIssues.length === 0) return void 0;
|
|
5594
|
+
const routes = errorIssues.map((issue) => mutationRecoveryRouteByIssueCode[issue.code]);
|
|
5595
|
+
const knownRoutes = routes.filter((route) => route !== void 0);
|
|
5596
|
+
if (knownRoutes.length !== routes.length) return void 0;
|
|
5597
|
+
return new Set(knownRoutes.map(mutationRouteTarget));
|
|
5598
|
+
};
|
|
5461
5599
|
const MAX_POST_CHANGE_TARGETS = 16;
|
|
5462
5600
|
const MAX_POST_CHANGE_ITEMS = 6;
|
|
5463
5601
|
const MAX_POST_CHANGE_TRANSLATIONS = 12;
|
|
@@ -5584,18 +5722,23 @@ var TurnSurveyDraft = class {
|
|
|
5584
5722
|
if (this.#context) throw new Error("The survey turn draft was initialized more than once.");
|
|
5585
5723
|
this.#context = context;
|
|
5586
5724
|
}
|
|
5587
|
-
stage({ addressedTargets = [], operations, snapshot, summary }) {
|
|
5725
|
+
stage({ addressedTargets = [], allowExpressionJsonPatches = false, handledMutationRoutes = [], operations, snapshot, summary }) {
|
|
5588
5726
|
this.#assertOpen();
|
|
5589
5727
|
if (!this.#context && snapshot && "document" in snapshot && "trustedCapabilities" in snapshot) this.#context = snapshot;
|
|
5590
5728
|
const currentContext = this.#context ?? snapshot;
|
|
5591
|
-
const targets = new Set([
|
|
5729
|
+
const targets = new Set([
|
|
5730
|
+
...collectOperationTargets(operations),
|
|
5731
|
+
...addressedTargets,
|
|
5732
|
+
...handledMutationRoutes.map(mutationRouteTarget)
|
|
5733
|
+
]);
|
|
5592
5734
|
const delta = createSurveyChangeSet({
|
|
5735
|
+
allowExpressionJsonPatches,
|
|
5593
5736
|
operations,
|
|
5594
5737
|
snapshot: currentContext,
|
|
5595
5738
|
summary,
|
|
5596
5739
|
turnId: this.turnId
|
|
5597
5740
|
});
|
|
5598
|
-
if (delta.status !== "validated" || !delta.validation.valid) return this.reject(delta, targets);
|
|
5741
|
+
if (delta.status !== "validated" || !delta.validation.valid) return this.reject(delta, collectExclusiveMutationRecoveryTargets(delta) ?? targets);
|
|
5599
5742
|
const cumulativeOperations = [...this.#draftOperations, ...delta.operations];
|
|
5600
5743
|
if (cumulativeOperations.length > 1e3) return this.reject(createSurveyChangeSet({
|
|
5601
5744
|
maxOperations: MAX_SURVEY_ASSISTANT_OPERATIONS_PER_TURN_DRAFT,
|
|
@@ -5606,7 +5749,7 @@ var TurnSurveyDraft = class {
|
|
|
5606
5749
|
}), targets);
|
|
5607
5750
|
const beforeContext = this.#context;
|
|
5608
5751
|
if (this.#context) {
|
|
5609
|
-
const survey =
|
|
5752
|
+
const survey = executeSurveyOperationsOnRawSurvey({
|
|
5610
5753
|
operations: delta.operations,
|
|
5611
5754
|
survey: this.#context.survey
|
|
5612
5755
|
});
|
|
@@ -5937,6 +6080,6 @@ var SurveyAssistantTaskResultCache = class {
|
|
|
5937
6080
|
}
|
|
5938
6081
|
};
|
|
5939
6082
|
//#endregion
|
|
5940
|
-
export {
|
|
6083
|
+
export { inferExpressionReturnType as $, getKeyIndexEntries as A, parseCursor as B, choiceOptionDetailsSchema as C, formFieldGroupDetailsSchema as D, formFieldDetailsSchema as E, itemSummarySchema as F, summarizeKeyIndexEntries as G, sliceWithCursor as H, mapKeyIndexById as I, summarizeRawItem as J, summarizeKeyIndexEntry as K, mapOutlineById as L, getRawSurveyItems as M, itemConfigDetailsSchema as N, formFieldGroupLayoutSchema as O, itemMatchesQuery as P, deriveSurveyExpressionResponseSlots as Q, mapRawItemsById as R, buildSurveyTranslations as S, findDirectChildrenByFullKey as T, summarizeFocusItemNode as U, resolveItemSummary as V, summarizeItemById as W, unique as X, translationEntrySchema as Y, analyzeSurveyAssistantExpressionReferences as Z, MAX_LIMIT as _, MAX_SURVEY_ASSISTANT_OPERATIONS_PER_PROPOSAL as a, buildItemConfigDetails as b, buildSurveyDocumentVersion as c, validateSurveyOperations as d, validateExpression as et, normalizeSurveyChangeOperations as f, DEFAULT_LIMIT as g, expressionSchema as h, auditSurvey as i, getRawSurvey$1 as j, formSelectOptionDetailsSchema as k, createSurveyChangeSet as l, expressionMutationSchema as m, buildSurveyAssistantTaskContext as n, deriveResponseSlotTypes as nt, MAX_SURVEY_ASSISTANT_OPERATIONS_PER_TURN_DRAFT as o, buildExpressionMutationPatches as p, summarizeOutlineNode as q, TurnSurveyDraft as r, applyValidatedSurveyOperationsToDraft as s, SurveyAssistantTaskResultCache as t, createSurveyAssistantEngineContext as tt, executeSurveyOperationsOnRawSurvey as u, buildConfigSearchText as v, clampLimit as w, buildItemTranslationEntries as x, buildEmbeddedFormDetails as y, normalizeText as z };
|
|
5941
6084
|
|
|
5942
|
-
//# sourceMappingURL=engine-
|
|
6085
|
+
//# sourceMappingURL=engine-CQwOAcwK.mjs.map
|