























@@ -453,12 +453,19 @@ function getAtPath(root: unknown, path: PathSegment[]): { found: boolean; value?
453453return { found: true, value: current };
454454}
455455456-function setAtPath(root: Record<string, unknown>, path: PathSegment[], value: unknown): void {
456+type SetAtPathOptions = { numericObjectKeys?: boolean };
457+458+function setAtPath(
459+root: Record<string, unknown>,
460+path: PathSegment[],
461+value: unknown,
462+options?: SetAtPathOptions,
463+): void {
457464let current: unknown = root;
458465for (let i = 0; i < path.length - 1; i += 1) {
459466const segment = path[i];
460467const next = path[i + 1];
461-const nextIsIndex = Boolean(next && isIndexSegment(next));
468+const nextIsIndex = !options?.numericObjectKeys && Boolean(next && isIndexSegment(next));
462469if (Array.isArray(current)) {
463470if (!isIndexSegment(segment)) {
464471throw new Error(`Expected numeric index for array segment "${segment}"`);
@@ -554,13 +561,18 @@ function mergeConfigValue(existing: unknown, patch: unknown, path: PathSegment[]
554561throw new Error(`Cannot merge ${toDotPath(path)}; use --replace to replace intentionally.`);
555562}
556563557-function mergeAtPath(root: Record<string, unknown>, path: PathSegment[], value: unknown): void {
564+function mergeAtPath(
565+root: Record<string, unknown>,
566+path: PathSegment[],
567+value: unknown,
568+options?: SetAtPathOptions,
569+): void {
558570const existing = getAtPath(root, path);
559571if (!existing.found) {
560-setAtPath(root, path, value);
572+setAtPath(root, path, value, options);
561573return;
562574}
563-setAtPath(root, path, mergeConfigValue(existing.value, value, path));
575+setAtPath(root, path, mergeConfigValue(existing.value, value, path), options);
564576}
565577566578function isProviderModelListPath(path: PathSegment[]): boolean {
@@ -1675,15 +1687,19 @@ async function runConfigOperations(params: {
16751687}
16761688explicitSetPaths.push(operation.setPath);
16771689if (operation.mutation === "merge" || (options.merge && operation.mutation !== "replace")) {
1678-mergeAtPath(next, operation.setPath, operation.value);
1690+mergeAtPath(next, operation.setPath, operation.value, {
1691+numericObjectKeys: params.successMode === "patch",
1692+});
16791693} else {
16801694assertNonDestructiveReplacement({
16811695root: next,
16821696path: operation.setPath,
16831697value: operation.value,
16841698allowReplace: options.replace || operation.mutation === "replace",
16851699});
1686-setAtPath(next, operation.setPath, operation.value);
1700+setAtPath(next, operation.setPath, operation.value, {
1701+numericObjectKeys: params.successMode === "patch",
1702+});
16871703}
16881704}
16891705const removedGatewayAuthPaths = pruneInactiveGatewayAuthCredentials({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。