@ateam-ai/mcp 0.3.37 → 0.3.38
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/package.json +1 -1
- package/src/tools.js +25 -2
package/package.json
CHANGED
package/src/tools.js
CHANGED
|
@@ -1939,7 +1939,25 @@ const handlers = {
|
|
|
1939
1939
|
}
|
|
1940
1940
|
const field = key.replace(/_delete$/, "");
|
|
1941
1941
|
const { parent, leaf } = _resolveDottedField(patched, field);
|
|
1942
|
-
|
|
1942
|
+
const arr = Array.isArray(parent[leaf]) ? parent[leaf] : [];
|
|
1943
|
+
// Match by EITHER id OR name OR primitive value. Old logic short-
|
|
1944
|
+
// circuited on item.name first ("name || id || self"), which silently
|
|
1945
|
+
// failed when an item had both name and id and the caller passed the
|
|
1946
|
+
// id. Now we check both keys + the primitive case.
|
|
1947
|
+
const matchValues = new Set(value.map(v => (v && typeof v === 'object') ? (v.id ?? v.name) : v));
|
|
1948
|
+
const before = arr.length;
|
|
1949
|
+
parent[leaf] = arr.filter(item => {
|
|
1950
|
+
if (item == null) return true;
|
|
1951
|
+
if (typeof item !== 'object') return !matchValues.has(item);
|
|
1952
|
+
if (item.id !== undefined && matchValues.has(item.id)) return false;
|
|
1953
|
+
if (item.name !== undefined && matchValues.has(item.name)) return false;
|
|
1954
|
+
return true;
|
|
1955
|
+
});
|
|
1956
|
+
if (parent[leaf].length === before && value.length > 0) {
|
|
1957
|
+
// Surface a "not found" hint instead of silent ok:true. Helps
|
|
1958
|
+
// agents catch typos and the "wrong key" class of bugs.
|
|
1959
|
+
phases.push({ phase: 'patch', warning: `${key}: nothing matched [${value.join(', ')}] — array unchanged` });
|
|
1960
|
+
}
|
|
1943
1961
|
} else if (key.endsWith("_update")) {
|
|
1944
1962
|
if (!Array.isArray(value)) {
|
|
1945
1963
|
return { ok: false, phase: "patch", error: `${key} requires an array of update objects (got ${typeof value}). Pass {"${key}": [{name: "x", description: "..."}]}.` };
|
|
@@ -1947,8 +1965,13 @@ const handlers = {
|
|
|
1947
1965
|
const field = key.replace(/_update$/, "");
|
|
1948
1966
|
const { parent, leaf } = _resolveDottedField(patched, field);
|
|
1949
1967
|
const arr = Array.isArray(parent[leaf]) ? parent[leaf] : [];
|
|
1968
|
+
// Same fix as _delete — match upd → existing by EITHER id OR name.
|
|
1950
1969
|
for (const upd of value) {
|
|
1951
|
-
const
|
|
1970
|
+
const updKey = (upd && typeof upd === 'object') ? (upd.id ?? upd.name) : upd;
|
|
1971
|
+
const idx = arr.findIndex(item => {
|
|
1972
|
+
if (!item || typeof item !== 'object') return item === updKey;
|
|
1973
|
+
return item.id === updKey || item.name === updKey;
|
|
1974
|
+
});
|
|
1952
1975
|
if (idx >= 0) arr[idx] = { ...arr[idx], ...upd };
|
|
1953
1976
|
else arr.push(upd);
|
|
1954
1977
|
}
|