@productbrain/mcp 0.0.1-beta.6660 → 0.0.1-beta.6668
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.
|
@@ -2753,39 +2753,47 @@ async function runConflictPreflight(name, description, collectionHint) {
|
|
|
2753
2753
|
}
|
|
2754
2754
|
|
|
2755
2755
|
// src/tools/knowledge/updateEntryAppliedFields.ts
|
|
2756
|
-
function computeUpdateEntryAppliedFields(args, normalization) {
|
|
2756
|
+
function computeUpdateEntryAppliedFields(args, normalization, provenanceApplied = {}, revertedFields = []) {
|
|
2757
2757
|
const rejectedDataFields = normalization?.rejected ?? [];
|
|
2758
|
-
const
|
|
2758
|
+
const revertedSet = new Set(revertedFields);
|
|
2759
|
+
const acceptedDataFields = (normalization?.accepted ?? []).filter((field) => !revertedSet.has(field));
|
|
2759
2760
|
const appliedFields = [];
|
|
2760
2761
|
if (args.name !== void 0) appliedFields.push("name");
|
|
2761
2762
|
if (args.status !== void 0) appliedFields.push("status");
|
|
2762
2763
|
if (args.workflowStatus !== void 0) appliedFields.push("workflowStatus");
|
|
2763
2764
|
if (args.order !== void 0) appliedFields.push("order");
|
|
2764
2765
|
if (args.canonicalKey !== void 0) appliedFields.push("canonicalKey");
|
|
2766
|
+
if (args.sourceRef && provenanceApplied.sourceRef) appliedFields.push("sourceRef");
|
|
2767
|
+
if (args.sourceExcerpt && provenanceApplied.sourceExcerpt) appliedFields.push("sourceExcerpt");
|
|
2765
2768
|
appliedFields.push(...acceptedDataFields);
|
|
2766
|
-
|
|
2769
|
+
const effectiveReverted = [...revertedFields];
|
|
2770
|
+
if (args.sourceRef && provenanceApplied.sourceRef === false) effectiveReverted.push("sourceRef");
|
|
2771
|
+
if (args.sourceExcerpt && provenanceApplied.sourceExcerpt === false) effectiveReverted.push("sourceExcerpt");
|
|
2772
|
+
return { appliedFields, rejectedDataFields, revertedFields: effectiveReverted };
|
|
2767
2773
|
}
|
|
2768
|
-
function buildFieldsRejectedFailure(entryId, fieldsProvided, appliedFields, rejectedDataFields) {
|
|
2774
|
+
function buildFieldsRejectedFailure(entryId, fieldsProvided, appliedFields, rejectedDataFields, revertedFields = []) {
|
|
2769
2775
|
if (!(fieldsProvided.length > 0 && appliedFields.length === 0)) return null;
|
|
2770
2776
|
const rejectedNote = rejectedDataFields.length > 0 ? ` Rejected: ${rejectedDataFields.join(", ")}.` : "";
|
|
2777
|
+
const revertedNote = revertedFields.length > 0 ? ` Reverted (platform-owned or write-once, cannot be set by this call): ${revertedFields.join(", ")}.` : "";
|
|
2778
|
+
const message = `No fields were applied to ${entryId}.${rejectedNote}${revertedNote}`;
|
|
2771
2779
|
return failureResult(
|
|
2772
|
-
|
|
2780
|
+
message,
|
|
2773
2781
|
"FIELDS_REJECTED",
|
|
2774
|
-
|
|
2782
|
+
message,
|
|
2775
2783
|
"Run `collections action=describe` for this entry's collection to see valid fields."
|
|
2776
2784
|
);
|
|
2777
2785
|
}
|
|
2778
|
-
function
|
|
2779
|
-
if (rejectedDataFields.length === 0) return warnings;
|
|
2780
|
-
return warnings.filter((warning) => !rejectedDataFields.some((field) => warning.includes(field)));
|
|
2781
|
-
}
|
|
2782
|
-
function pushAppliedFieldsLines(responseLines, fieldsProvided, appliedFields, rejectedDataFields) {
|
|
2786
|
+
function pushAppliedFieldsLines(responseLines, fieldsProvided, appliedFields, rejectedDataFields, revertedFields = []) {
|
|
2783
2787
|
if (fieldsProvided.length > 0) {
|
|
2784
2788
|
responseLines.push(`**Fields applied:** ${appliedFields.join(", ")}`);
|
|
2785
2789
|
if (rejectedDataFields.length > 0) {
|
|
2786
2790
|
responseLines.push("");
|
|
2787
2791
|
responseLines.push(`\u26A0\uFE0F **Fields rejected:** ${rejectedDataFields.join(", ")}`);
|
|
2788
2792
|
}
|
|
2793
|
+
if (revertedFields.length > 0) {
|
|
2794
|
+
responseLines.push("");
|
|
2795
|
+
responseLines.push(`\u26A0\uFE0F **Fields reverted (platform-owned or write-once):** ${revertedFields.join(", ")}`);
|
|
2796
|
+
}
|
|
2789
2797
|
} else {
|
|
2790
2798
|
responseLines.push("");
|
|
2791
2799
|
responseLines.push("\u26A0\uFE0F No fields to update were provided \u2014 only `entryId` was set.");
|
|
@@ -2868,7 +2876,7 @@ async function handleUpdateEntry({ entryId, name, status: rawStatus, workflowSta
|
|
|
2868
2876
|
if (rawWorkflowStatus !== void 0) fieldsProvided.push("workflowStatus");
|
|
2869
2877
|
if (data !== void 0) fieldsProvided.push("data");
|
|
2870
2878
|
if (order !== void 0) fieldsProvided.push("order");
|
|
2871
|
-
|
|
2879
|
+
for (const [k, v] of [["canonicalKey", canonicalKey], ["sourceRef", sourceRef], ["sourceExcerpt", sourceExcerpt]]) if (v !== void 0) fieldsProvided.push(k);
|
|
2872
2880
|
const status2 = rawStatus;
|
|
2873
2881
|
const workflowStatus = rawWorkflowStatus;
|
|
2874
2882
|
const updateResult = await kernelMutation("chain.updateEntry", {
|
|
@@ -2882,8 +2890,8 @@ async function handleUpdateEntry({ entryId, name, status: rawStatus, workflowSta
|
|
|
2882
2890
|
autoPublish,
|
|
2883
2891
|
changeNote,
|
|
2884
2892
|
changedBy: getAgentSessionId() ? `agent:${getAgentSessionId()}` : void 0,
|
|
2885
|
-
...sourceRef ? { sourceRef } : {},
|
|
2886
|
-
...sourceExcerpt ? { sourceExcerpt } : {},
|
|
2893
|
+
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
2894
|
+
...sourceExcerpt !== void 0 ? { sourceExcerpt } : {},
|
|
2887
2895
|
...steeringOverrideReason ? { steeringOverrideReason } : {},
|
|
2888
2896
|
...coherencyAcknowledgement ? { coherencyAcknowledgement } : {}
|
|
2889
2897
|
});
|
|
@@ -2892,9 +2900,10 @@ async function handleUpdateEntry({ entryId, name, status: rawStatus, workflowSta
|
|
|
2892
2900
|
return coherencyRefusedResult(`${toolName} action=update`, entryId, maybeRefused.refusal);
|
|
2893
2901
|
}
|
|
2894
2902
|
const id = updateResult.id;
|
|
2895
|
-
const fieldArgs = { name, status: rawStatus, workflowStatus: rawWorkflowStatus, order, canonicalKey };
|
|
2896
|
-
const
|
|
2897
|
-
const
|
|
2903
|
+
const fieldArgs = { name, status: rawStatus, workflowStatus: rawWorkflowStatus, order, canonicalKey, sourceRef, sourceExcerpt };
|
|
2904
|
+
const revertedByServer = updateResult.revertedFields ?? [];
|
|
2905
|
+
const { appliedFields, rejectedDataFields, revertedFields } = computeUpdateEntryAppliedFields(fieldArgs, updateResult.normalization, updateResult.provenanceApplied, revertedByServer);
|
|
2906
|
+
const totalFailure = buildFieldsRejectedFailure(entryId, fieldsProvided, appliedFields, rejectedDataFields, revertedFields);
|
|
2898
2907
|
if (totalFailure) return totalFailure;
|
|
2899
2908
|
await recordSessionActivity({ entryModified: id });
|
|
2900
2909
|
const wsCtx = await getWorkspaceContext();
|
|
@@ -2909,12 +2918,12 @@ async function handleUpdateEntry({ entryId, name, status: rawStatus, workflowSta
|
|
|
2909
2918
|
`Internal ID: ${id}`,
|
|
2910
2919
|
`**Workspace:** ${wsCtx.workspaceSlug} (${wsCtx.workspaceId})`
|
|
2911
2920
|
];
|
|
2912
|
-
pushAppliedFieldsLines(responseLines, fieldsProvided, appliedFields, rejectedDataFields);
|
|
2913
|
-
const
|
|
2914
|
-
if (
|
|
2921
|
+
pushAppliedFieldsLines(responseLines, fieldsProvided, appliedFields, rejectedDataFields, revertedFields);
|
|
2922
|
+
const warnings = updateResult.normalizationWarnings ?? [];
|
|
2923
|
+
if (warnings.length > 0) {
|
|
2915
2924
|
responseLines.push("");
|
|
2916
2925
|
responseLines.push("\u26A0\uFE0F **Normalization warnings:**");
|
|
2917
|
-
for (const warning of
|
|
2926
|
+
for (const warning of warnings) responseLines.push(` - ${warning}`);
|
|
2918
2927
|
}
|
|
2919
2928
|
if ((updateResult.validationWarnings ?? []).length > 0) {
|
|
2920
2929
|
responseLines.push("");
|
|
@@ -2947,7 +2956,9 @@ async function handleUpdateEntry({ entryId, name, status: rawStatus, workflowSta
|
|
|
2947
2956
|
},
|
|
2948
2957
|
...(updateResult.validationWarnings ?? []).length > 0 && {
|
|
2949
2958
|
validationWarnings: updateResult.validationWarnings
|
|
2950
|
-
}
|
|
2959
|
+
},
|
|
2960
|
+
...revertedFields.length > 0 && { revertedFields }
|
|
2961
|
+
// #1026 R2: symmetric with the text above
|
|
2951
2962
|
}, next)
|
|
2952
2963
|
};
|
|
2953
2964
|
}
|
|
@@ -14955,4 +14966,4 @@ export {
|
|
|
14955
14966
|
createProductBrainServer,
|
|
14956
14967
|
initFeatureFlags
|
|
14957
14968
|
};
|
|
14958
|
-
//# sourceMappingURL=chunk-
|
|
14969
|
+
//# sourceMappingURL=chunk-MEJLUGP4.js.map
|