agent-contracts 0.22.7 → 0.22.8

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/cli.js CHANGED
@@ -50222,7 +50222,7 @@ var InsertAfterOperatorSchema = z16.object({
50222
50222
  });
50223
50223
  var ReplaceOperatorSchema = z16.object({ $replace: z16.any() });
50224
50224
  var RemoveOperatorSchema = z16.object({
50225
- $remove: z16.array(z16.string())
50225
+ $remove: z16.array(z16.union([z16.string(), z16.object({ id: z16.string() })]))
50226
50226
  });
50227
50227
 
50228
50228
  // src/config/loader.ts
@@ -50836,10 +50836,13 @@ function hasOperator(obj) {
50836
50836
  }
50837
50837
  return null;
50838
50838
  }
50839
- function findIndexById(arr, id) {
50840
- return arr.findIndex(
50841
- (item) => isRecord2(item) && item["id"] === id
50842
- );
50839
+ function findIndexByIdOrValue(arr, target) {
50840
+ return arr.findIndex((item) => {
50841
+ if (typeof item === "string") {
50842
+ return item === target;
50843
+ }
50844
+ return isRecord2(item) && item["id"] === target;
50845
+ });
50843
50846
  }
50844
50847
  function applyArrayMergeOperator(baseArray, operatorObj, path) {
50845
50848
  const op = hasOperator(operatorObj);
@@ -50857,7 +50860,7 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
50857
50860
  const spec = operatorObj["$insert_after"];
50858
50861
  const target = spec["target"];
50859
50862
  const items = spec["items"];
50860
- const idx = findIndexById(baseArray, target);
50863
+ const idx = findIndexByIdOrValue(baseArray, target);
50861
50864
  if (idx === -1) {
50862
50865
  throw new MergeError(
50863
50866
  `$insert_after target "${target}" not found in base at ${path}`
@@ -50872,7 +50875,28 @@ function applyArrayMergeOperator(baseArray, operatorObj, path) {
50872
50875
  }
50873
50876
  case "$remove": {
50874
50877
  const removeList = operatorObj["$remove"];
50875
- const idsToRemove = new Set(removeList.map((r3) => r3["id"]));
50878
+ if (removeList.length === 0) {
50879
+ return baseArray;
50880
+ }
50881
+ if (typeof removeList[0] === "string") {
50882
+ const valuesToRemove = new Set(removeList);
50883
+ const result2 = baseArray.filter((item) => {
50884
+ if (typeof item === "string" && valuesToRemove.has(item)) {
50885
+ valuesToRemove.delete(item);
50886
+ return false;
50887
+ }
50888
+ return true;
50889
+ });
50890
+ if (valuesToRemove.size > 0) {
50891
+ throw new MergeError(
50892
+ `$remove values not found in base at ${path}: ${[...valuesToRemove].join(", ")}`
50893
+ );
50894
+ }
50895
+ return result2;
50896
+ }
50897
+ const idsToRemove = new Set(
50898
+ removeList.map((r3) => r3["id"])
50899
+ );
50876
50900
  const result = baseArray.filter((item) => {
50877
50901
  if (isRecord2(item) && typeof item["id"] === "string") {
50878
50902
  const itemId = item["id"];