@orbit-build/cli 0.4.10 → 0.4.11
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/index.js +253 -108
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -249626,12 +249626,26 @@ function errorMessage(error) {
|
|
|
249626
249626
|
}
|
|
249627
249627
|
|
|
249628
249628
|
// ../sandbox/dist/index.js
|
|
249629
|
-
import {
|
|
249629
|
+
import {
|
|
249630
|
+
existsSync as existsSync8,
|
|
249631
|
+
lstatSync as lstatSync3,
|
|
249632
|
+
mkdirSync as mkdirSync3,
|
|
249633
|
+
readdirSync as readdirSync2,
|
|
249634
|
+
renameSync as renameSync3,
|
|
249635
|
+
rmSync as rmSync2
|
|
249636
|
+
} from "fs";
|
|
249630
249637
|
import { join as join6 } from "path";
|
|
249631
249638
|
import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
|
|
249632
249639
|
import { z as z24 } from "zod";
|
|
249633
249640
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
249634
|
-
import {
|
|
249641
|
+
import {
|
|
249642
|
+
existsSync as existsSync24,
|
|
249643
|
+
lstatSync as lstatSync22,
|
|
249644
|
+
mkdirSync as mkdirSync22,
|
|
249645
|
+
unlinkSync as unlinkSync3,
|
|
249646
|
+
writeFileSync as writeFileSync5
|
|
249647
|
+
} from "fs";
|
|
249648
|
+
import { dirname as dirname4 } from "path";
|
|
249635
249649
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
249636
249650
|
import fs from "fs";
|
|
249637
249651
|
import path3 from "path";
|
|
@@ -249796,34 +249810,45 @@ var CheckpointManager = class {
|
|
|
249796
249810
|
toolCallId: validToolCallId,
|
|
249797
249811
|
backups: [backup]
|
|
249798
249812
|
};
|
|
249799
|
-
this.
|
|
249800
|
-
ensurePrivateDirectory(
|
|
249801
|
-
const checkpointDir =
|
|
249802
|
-
|
|
249803
|
-
|
|
249804
|
-
|
|
249805
|
-
|
|
249806
|
-
|
|
249807
|
-
|
|
249808
|
-
|
|
249809
|
-
);
|
|
249810
|
-
|
|
249811
|
-
|
|
249812
|
-
|
|
249813
|
-
|
|
249814
|
-
|
|
249813
|
+
const sessionDir = this.getSessionCheckpointDir();
|
|
249814
|
+
ensurePrivateDirectory(sessionDir);
|
|
249815
|
+
const checkpointDir = resolveSafePath(sessionDir, checkpoint.id);
|
|
249816
|
+
const stagingDir = resolveSafePath(
|
|
249817
|
+
sessionDir,
|
|
249818
|
+
`.pending-${checkpoint.id}-${randomBytes(8).toString("hex")}`
|
|
249819
|
+
);
|
|
249820
|
+
mkdirSync3(stagingDir, { recursive: false, mode: 448 });
|
|
249821
|
+
try {
|
|
249822
|
+
if (originalContent !== null) {
|
|
249823
|
+
const key = this.resolveEncryptionKey();
|
|
249824
|
+
if (key) {
|
|
249825
|
+
writePrivateFile(
|
|
249826
|
+
join6(stagingDir, "backup_content.enc"),
|
|
249827
|
+
this.encryptBackup(originalContent, key)
|
|
249828
|
+
);
|
|
249829
|
+
} else {
|
|
249830
|
+
writePrivateFile(
|
|
249831
|
+
join6(stagingDir, "backup_content.txt"),
|
|
249832
|
+
originalContent
|
|
249833
|
+
);
|
|
249834
|
+
}
|
|
249815
249835
|
}
|
|
249836
|
+
writePrivateFile(
|
|
249837
|
+
join6(stagingDir, "meta.json"),
|
|
249838
|
+
JSON.stringify({
|
|
249839
|
+
id: checkpoint.id,
|
|
249840
|
+
timestamp: checkpoint.timestamp,
|
|
249841
|
+
toolCallId: validToolCallId,
|
|
249842
|
+
filePath: validFilePath,
|
|
249843
|
+
exists: originalContent !== null
|
|
249844
|
+
})
|
|
249845
|
+
);
|
|
249846
|
+
renameSync3(stagingDir, checkpointDir);
|
|
249847
|
+
} catch (error) {
|
|
249848
|
+
rmSync2(stagingDir, { recursive: true, force: true });
|
|
249849
|
+
throw error;
|
|
249816
249850
|
}
|
|
249817
|
-
|
|
249818
|
-
join6(checkpointDir, "meta.json"),
|
|
249819
|
-
JSON.stringify({
|
|
249820
|
-
id: checkpoint.id,
|
|
249821
|
-
timestamp: checkpoint.timestamp,
|
|
249822
|
-
toolCallId: validToolCallId,
|
|
249823
|
-
filePath: validFilePath,
|
|
249824
|
-
exists: originalContent !== null
|
|
249825
|
-
})
|
|
249826
|
-
);
|
|
249851
|
+
this.checkpoints.push(checkpoint);
|
|
249827
249852
|
return checkpoint;
|
|
249828
249853
|
}
|
|
249829
249854
|
getCheckpoints() {
|
|
@@ -249860,6 +249885,7 @@ function loadOrCreateCheckpointKey(credentials = new CredentialsManager()) {
|
|
|
249860
249885
|
return null;
|
|
249861
249886
|
}
|
|
249862
249887
|
}
|
|
249888
|
+
var ROLLBACK_FILE_MAX_BYTES = 16 * 1024 * 1024;
|
|
249863
249889
|
var RollbackManager = class {
|
|
249864
249890
|
constructor(cwd) {
|
|
249865
249891
|
this.cwd = cwd;
|
|
@@ -249867,36 +249893,141 @@ var RollbackManager = class {
|
|
|
249867
249893
|
cwd;
|
|
249868
249894
|
/** Restore a checkpoint without allowing one filesystem failure to crash the caller. */
|
|
249869
249895
|
rollback(checkpoint) {
|
|
249896
|
+
return this.rollbackMany([checkpoint]);
|
|
249897
|
+
}
|
|
249898
|
+
/**
|
|
249899
|
+
* Restore an ordered checkpoint sequence as one transaction. Every target
|
|
249900
|
+
* is validated and snapshotted before writes begin; an unexpected write
|
|
249901
|
+
* failure triggers best-effort compensation to the pre-rewind state.
|
|
249902
|
+
*/
|
|
249903
|
+
rollbackMany(checkpoints) {
|
|
249870
249904
|
const restored = [];
|
|
249871
|
-
|
|
249872
|
-
|
|
249873
|
-
|
|
249874
|
-
|
|
249875
|
-
|
|
249876
|
-
|
|
249877
|
-
|
|
249905
|
+
const currentStates = /* @__PURE__ */ new Map();
|
|
249906
|
+
try {
|
|
249907
|
+
for (const checkpoint of checkpoints) {
|
|
249908
|
+
for (const backup of checkpoint.backups) {
|
|
249909
|
+
const safePath = resolveSafePath(this.cwd, backup.path);
|
|
249910
|
+
if (!currentStates.has(safePath)) {
|
|
249911
|
+
currentStates.set(safePath, {
|
|
249912
|
+
path: backup.path,
|
|
249913
|
+
content: this.readCurrentContent(safePath, backup.path)
|
|
249914
|
+
});
|
|
249878
249915
|
}
|
|
249879
|
-
}
|
|
249880
|
-
|
|
249916
|
+
}
|
|
249917
|
+
}
|
|
249918
|
+
} catch (error) {
|
|
249919
|
+
return {
|
|
249920
|
+
success: false,
|
|
249921
|
+
error: `Rollback preflight failed: ${toErrorMessage(error)}`,
|
|
249922
|
+
restored
|
|
249923
|
+
};
|
|
249924
|
+
}
|
|
249925
|
+
try {
|
|
249926
|
+
for (const checkpoint of checkpoints) {
|
|
249927
|
+
for (const backup of checkpoint.backups) {
|
|
249928
|
+
this.restoreBackup(backup);
|
|
249881
249929
|
restored.push(backup.path);
|
|
249882
249930
|
}
|
|
249883
|
-
} catch (error) {
|
|
249884
|
-
const detail = error instanceof Error ? error.message : String(error);
|
|
249885
|
-
return {
|
|
249886
|
-
success: false,
|
|
249887
|
-
error: `Could not restore ${backup.path}: ${detail}`,
|
|
249888
|
-
restored
|
|
249889
|
-
};
|
|
249890
249931
|
}
|
|
249932
|
+
} catch (error) {
|
|
249933
|
+
const compensationErrors = [];
|
|
249934
|
+
for (const state of [...currentStates.values()].reverse()) {
|
|
249935
|
+
try {
|
|
249936
|
+
this.restoreContent(state.path, state.content);
|
|
249937
|
+
} catch (compensationError) {
|
|
249938
|
+
compensationErrors.push(
|
|
249939
|
+
`${state.path}: ${toErrorMessage(compensationError)}`
|
|
249940
|
+
);
|
|
249941
|
+
}
|
|
249942
|
+
}
|
|
249943
|
+
const compensationDetail = compensationErrors.length === 0 ? " Previous workspace state was restored." : ` Compensation was incomplete (${compensationErrors.join("; ")}).`;
|
|
249944
|
+
return {
|
|
249945
|
+
success: false,
|
|
249946
|
+
error: `Could not complete rewind: ${toErrorMessage(error)}.${compensationDetail}`,
|
|
249947
|
+
restored
|
|
249948
|
+
};
|
|
249891
249949
|
}
|
|
249892
249950
|
return {
|
|
249893
249951
|
success: true,
|
|
249894
249952
|
restored
|
|
249895
249953
|
};
|
|
249896
249954
|
}
|
|
249955
|
+
readCurrentContent(safePath, displayPath) {
|
|
249956
|
+
try {
|
|
249957
|
+
const stats = lstatSync22(safePath);
|
|
249958
|
+
if (stats.isSymbolicLink() || !stats.isFile()) {
|
|
249959
|
+
throw new Error(
|
|
249960
|
+
`Rollback target must be a regular file: ${displayPath}`
|
|
249961
|
+
);
|
|
249962
|
+
}
|
|
249963
|
+
const content = readBoundedRegularFileBuffer(
|
|
249964
|
+
safePath,
|
|
249965
|
+
ROLLBACK_FILE_MAX_BYTES
|
|
249966
|
+
);
|
|
249967
|
+
if (content === void 0) {
|
|
249968
|
+
throw new Error(`Rollback target disappeared: ${displayPath}`);
|
|
249969
|
+
}
|
|
249970
|
+
return content;
|
|
249971
|
+
} catch (error) {
|
|
249972
|
+
if (isFileSystemError2(error, "ENOENT")) return null;
|
|
249973
|
+
throw error;
|
|
249974
|
+
}
|
|
249975
|
+
}
|
|
249976
|
+
restoreBackup(backup) {
|
|
249977
|
+
this.restoreContent(backup.path, backup.originalContent);
|
|
249978
|
+
}
|
|
249979
|
+
restoreContent(path24, content) {
|
|
249980
|
+
let safePath = resolveSafePath(this.cwd, path24);
|
|
249981
|
+
try {
|
|
249982
|
+
const stats = lstatSync22(safePath);
|
|
249983
|
+
if (stats.isSymbolicLink() || !stats.isFile()) {
|
|
249984
|
+
throw new Error(`Rollback target must be a regular file: ${path24}`);
|
|
249985
|
+
}
|
|
249986
|
+
} catch (error) {
|
|
249987
|
+
if (!isFileSystemError2(error, "ENOENT")) throw error;
|
|
249988
|
+
}
|
|
249989
|
+
if (content === null) {
|
|
249990
|
+
if (existsSync24(safePath)) unlinkSync3(safePath);
|
|
249991
|
+
return;
|
|
249992
|
+
}
|
|
249993
|
+
mkdirSync22(dirname4(safePath), { recursive: true });
|
|
249994
|
+
safePath = resolveSafePath(this.cwd, path24);
|
|
249995
|
+
writeFileSync5(safePath, content);
|
|
249996
|
+
}
|
|
249897
249997
|
};
|
|
249998
|
+
function isFileSystemError2(error, code) {
|
|
249999
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
250000
|
+
}
|
|
250001
|
+
function toErrorMessage(error) {
|
|
250002
|
+
return error instanceof Error ? error.message : String(error);
|
|
250003
|
+
}
|
|
249898
250004
|
var SUBAGENT_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/;
|
|
249899
250005
|
var WORKTREE_BRANCH_PATTERN = /^orbit-wt-[a-zA-Z0-9_-]+$/;
|
|
250006
|
+
var SENSITIVE_SNAPSHOT_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
250007
|
+
".aws",
|
|
250008
|
+
".azure",
|
|
250009
|
+
".docker",
|
|
250010
|
+
".gem",
|
|
250011
|
+
".gnupg",
|
|
250012
|
+
".kube",
|
|
250013
|
+
".ssh",
|
|
250014
|
+
".terraform.d"
|
|
250015
|
+
]);
|
|
250016
|
+
var SENSITIVE_SNAPSHOT_NAMES = /* @__PURE__ */ new Set([
|
|
250017
|
+
".git-credentials",
|
|
250018
|
+
".netrc",
|
|
250019
|
+
".npmrc",
|
|
250020
|
+
".pypirc",
|
|
250021
|
+
".sentryclirc",
|
|
250022
|
+
"_netrc",
|
|
250023
|
+
"client_secret.json",
|
|
250024
|
+
"credentials.json",
|
|
250025
|
+
"credentials.tfrc.json",
|
|
250026
|
+
"id_dsa",
|
|
250027
|
+
"id_ecdsa",
|
|
250028
|
+
"id_ed25519",
|
|
250029
|
+
"id_rsa"
|
|
250030
|
+
]);
|
|
249900
250031
|
var WorktreeManager = class {
|
|
249901
250032
|
constructor(cwd) {
|
|
249902
250033
|
this.cwd = cwd;
|
|
@@ -249944,7 +250075,7 @@ var WorktreeManager = class {
|
|
|
249944
250075
|
} catch {
|
|
249945
250076
|
}
|
|
249946
250077
|
throw new Error(
|
|
249947
|
-
`Failed to snapshot the current workspace: ${
|
|
250078
|
+
`Failed to snapshot the current workspace: ${toErrorMessage2(error)}`
|
|
249948
250079
|
);
|
|
249949
250080
|
}
|
|
249950
250081
|
}
|
|
@@ -249954,7 +250085,7 @@ var WorktreeManager = class {
|
|
|
249954
250085
|
try {
|
|
249955
250086
|
this.assertManagedSession(session);
|
|
249956
250087
|
} catch (error) {
|
|
249957
|
-
return { success: false, error:
|
|
250088
|
+
return { success: false, error: toErrorMessage2(error), preserved: true };
|
|
249958
250089
|
}
|
|
249959
250090
|
if (!this.isGitRepo()) {
|
|
249960
250091
|
return {
|
|
@@ -249980,7 +250111,7 @@ var WorktreeManager = class {
|
|
|
249980
250111
|
} catch (error) {
|
|
249981
250112
|
return {
|
|
249982
250113
|
success: false,
|
|
249983
|
-
error: `Failed to commit worktree changes: ${
|
|
250114
|
+
error: `Failed to commit worktree changes: ${toErrorMessage2(error)}`,
|
|
249984
250115
|
preserved: true
|
|
249985
250116
|
};
|
|
249986
250117
|
}
|
|
@@ -249999,7 +250130,7 @@ var WorktreeManager = class {
|
|
|
249999
250130
|
return {
|
|
250000
250131
|
success: false,
|
|
250001
250132
|
conflictFiles,
|
|
250002
|
-
error: `Failed to merge worktree branch: ${
|
|
250133
|
+
error: `Failed to merge worktree branch: ${toErrorMessage2(error)}`,
|
|
250003
250134
|
preserved: true
|
|
250004
250135
|
};
|
|
250005
250136
|
}
|
|
@@ -250013,7 +250144,7 @@ var WorktreeManager = class {
|
|
|
250013
250144
|
} catch (error) {
|
|
250014
250145
|
return {
|
|
250015
250146
|
success: true,
|
|
250016
|
-
error: `Changes were merged, but cleanup is incomplete: ${
|
|
250147
|
+
error: `Changes were merged, but cleanup is incomplete: ${toErrorMessage2(error)}`,
|
|
250017
250148
|
preserved: true
|
|
250018
250149
|
};
|
|
250019
250150
|
}
|
|
@@ -250132,15 +250263,16 @@ var WorktreeManager = class {
|
|
|
250132
250263
|
function isSensitiveSnapshotPath(filePath) {
|
|
250133
250264
|
const normalized = filePath.replace(/\\/g, "/").toLowerCase();
|
|
250134
250265
|
const name = path3.basename(normalized);
|
|
250135
|
-
|
|
250266
|
+
const segments = normalized.split("/");
|
|
250267
|
+
return normalized === ".orbit" || normalized.startsWith(".orbit/") || segments.some((segment) => SENSITIVE_SNAPSHOT_DIRECTORIES.has(segment)) || SENSITIVE_SNAPSHOT_NAMES.has(name) || name === ".env" || name.startsWith(".env.") || name.startsWith("client_secret_") || /\.(?:jks|key|p12|pfx|pem)$/.test(name);
|
|
250136
250268
|
}
|
|
250137
|
-
function
|
|
250269
|
+
function toErrorMessage2(error) {
|
|
250138
250270
|
return error instanceof Error ? error.message : String(error);
|
|
250139
250271
|
}
|
|
250140
250272
|
|
|
250141
250273
|
// ../context-engine/dist/index.js
|
|
250142
250274
|
import { join as join62 } from "path";
|
|
250143
|
-
import { existsSync as existsSync33, writeFileSync as writeFileSync6, mkdirSync as mkdirSync4, renameSync as
|
|
250275
|
+
import { existsSync as existsSync33, writeFileSync as writeFileSync6, mkdirSync as mkdirSync4, renameSync as renameSync4, rmSync as rmSync3 } from "fs";
|
|
250144
250276
|
import { promises as fsPromises3 } from "fs";
|
|
250145
250277
|
import { join as join24, dirname as dirname32, isAbsolute as isAbsolute3, resolve as resolve3 } from "path";
|
|
250146
250278
|
import { createHash as createHash3, randomUUID as randomUUID32 } from "crypto";
|
|
@@ -250148,7 +250280,7 @@ import glob3 from "fast-glob";
|
|
|
250148
250280
|
import { z as z35 } from "zod";
|
|
250149
250281
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
250150
250282
|
import { existsSync as existsSync9, promises as fsPromises2 } from "fs";
|
|
250151
|
-
import { dirname as
|
|
250283
|
+
import { dirname as dirname5, resolve as resolve4 } from "path";
|
|
250152
250284
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
250153
250285
|
import { z as z25 } from "zod";
|
|
250154
250286
|
import { basename, join as join7 } from "path";
|
|
@@ -250159,7 +250291,7 @@ import { z as z26 } from "zod";
|
|
|
250159
250291
|
import { existsSync as existsSync43 } from "fs";
|
|
250160
250292
|
import { pathToFileURL } from "url";
|
|
250161
250293
|
import { z as z43 } from "zod";
|
|
250162
|
-
import { dirname as
|
|
250294
|
+
import { dirname as dirname52 } from "path";
|
|
250163
250295
|
import { isAbsolute as isAbsolute22, join as join33, resolve as resolve42 } from "path";
|
|
250164
250296
|
import { homedir as homedir4 } from "os";
|
|
250165
250297
|
import { existsSync as existsSync53, promises as fs2 } from "fs";
|
|
@@ -250462,7 +250594,7 @@ var JSVectorStore = class {
|
|
|
250462
250594
|
if (this.loading) await this.loading;
|
|
250463
250595
|
this.initializeCachePath();
|
|
250464
250596
|
try {
|
|
250465
|
-
const parentDir =
|
|
250597
|
+
const parentDir = dirname5(this.dbPath);
|
|
250466
250598
|
if (!existsSync9(parentDir)) {
|
|
250467
250599
|
await fsPromises2.mkdir(parentDir, { recursive: true });
|
|
250468
250600
|
}
|
|
@@ -251115,7 +251247,7 @@ var EmbeddingCache = class {
|
|
|
251115
251247
|
};
|
|
251116
251248
|
tmpPath = `${this.cachePath}.${process.pid}.${randomUUID32()}.tmp`;
|
|
251117
251249
|
writeFileSync6(tmpPath, JSON.stringify(data, null, 2), "utf8");
|
|
251118
|
-
|
|
251250
|
+
renameSync4(tmpPath, this.cachePath);
|
|
251119
251251
|
} catch {
|
|
251120
251252
|
} finally {
|
|
251121
251253
|
if (tmpPath) {
|
|
@@ -252222,7 +252354,7 @@ async function discoverSkills(cwd, config) {
|
|
|
252222
252354
|
...presentation.metadata,
|
|
252223
252355
|
allowImplicitInvocation: presentation.metadata.allowImplicitInvocation ?? parsed.skill.allowImplicitInvocation,
|
|
252224
252356
|
disabled: disabled.has(parsed.skill.name.toLowerCase()),
|
|
252225
|
-
rootDir: normalizePath2(
|
|
252357
|
+
rootDir: normalizePath2(dirname52(filePath))
|
|
252226
252358
|
});
|
|
252227
252359
|
} catch (error) {
|
|
252228
252360
|
const oversized = error instanceof Error && error.message.includes(`${MAX_SKILL_FILE_BYTES}-byte limit`);
|
|
@@ -254543,14 +254675,14 @@ import {
|
|
|
254543
254675
|
mkdirSync as mkdirSync5,
|
|
254544
254676
|
openSync as openSync3,
|
|
254545
254677
|
readdirSync as readdirSync3,
|
|
254546
|
-
renameSync as
|
|
254678
|
+
renameSync as renameSync5,
|
|
254547
254679
|
rmSync as rmSync4,
|
|
254548
254680
|
writeFileSync as writeFileSync7
|
|
254549
254681
|
} from "fs";
|
|
254550
254682
|
import { createHash as createHash23 } from "crypto";
|
|
254551
254683
|
import {
|
|
254552
254684
|
closeSync as closeSync22,
|
|
254553
|
-
lstatSync as
|
|
254685
|
+
lstatSync as lstatSync23,
|
|
254554
254686
|
openSync as openSync22,
|
|
254555
254687
|
realpathSync as realpathSync2,
|
|
254556
254688
|
statSync,
|
|
@@ -254559,7 +254691,7 @@ import {
|
|
|
254559
254691
|
import { homedir as homedir5 } from "os";
|
|
254560
254692
|
import { basename as basename2, dirname as dirname23, isAbsolute as isAbsolute23, join as join25, parse as parse2, resolve as resolve24 } from "path";
|
|
254561
254693
|
import { z as z210 } from "zod";
|
|
254562
|
-
import { existsSync as existsSync26, lstatSync as lstatSync32, mkdirSync as
|
|
254694
|
+
import { existsSync as existsSync26, lstatSync as lstatSync32, mkdirSync as mkdirSync23, readdirSync as readdirSync22 } from "fs";
|
|
254563
254695
|
import { basename as basename22, join as join34, resolve as resolve32 } from "path";
|
|
254564
254696
|
import { z as z37 } from "zod";
|
|
254565
254697
|
var SafeObjectKeySchema = z29.string().refine(
|
|
@@ -254963,7 +255095,7 @@ function preserveLastKnownGoodFile(filePath, schema) {
|
|
|
254963
255095
|
}
|
|
254964
255096
|
function replaceFileAtomically(temporaryPath, destinationPath) {
|
|
254965
255097
|
try {
|
|
254966
|
-
|
|
255098
|
+
renameSync5(temporaryPath, destinationPath);
|
|
254967
255099
|
return;
|
|
254968
255100
|
} catch (error) {
|
|
254969
255101
|
const code = typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : "";
|
|
@@ -254973,10 +255105,10 @@ function replaceFileAtomically(temporaryPath, destinationPath) {
|
|
|
254973
255105
|
let previousMoved = false;
|
|
254974
255106
|
try {
|
|
254975
255107
|
if (existsSync10(destinationPath)) {
|
|
254976
|
-
|
|
255108
|
+
renameSync5(destinationPath, backupPath);
|
|
254977
255109
|
previousMoved = true;
|
|
254978
255110
|
}
|
|
254979
|
-
|
|
255111
|
+
renameSync5(temporaryPath, destinationPath);
|
|
254980
255112
|
if (previousMoved) {
|
|
254981
255113
|
try {
|
|
254982
255114
|
rmSync4(backupPath, { force: true });
|
|
@@ -254986,7 +255118,7 @@ function replaceFileAtomically(temporaryPath, destinationPath) {
|
|
|
254986
255118
|
} catch (error) {
|
|
254987
255119
|
if (previousMoved && existsSync10(backupPath) && !existsSync10(destinationPath)) {
|
|
254988
255120
|
try {
|
|
254989
|
-
|
|
255121
|
+
renameSync5(backupPath, destinationPath);
|
|
254990
255122
|
} catch {
|
|
254991
255123
|
}
|
|
254992
255124
|
}
|
|
@@ -256109,7 +256241,7 @@ function isDirectory(targetPath) {
|
|
|
256109
256241
|
}
|
|
256110
256242
|
function removeStaleLock(lockPath) {
|
|
256111
256243
|
try {
|
|
256112
|
-
const lock =
|
|
256244
|
+
const lock = lstatSync23(lockPath);
|
|
256113
256245
|
if (!lock.isFile() || Date.now() - lock.mtimeMs <= PROJECT_REGISTRY_STALE_LOCK_MS) {
|
|
256114
256246
|
return false;
|
|
256115
256247
|
}
|
|
@@ -256173,7 +256305,7 @@ var AgentRunStore = class {
|
|
|
256173
256305
|
directory;
|
|
256174
256306
|
initialized = false;
|
|
256175
256307
|
initialize() {
|
|
256176
|
-
|
|
256308
|
+
mkdirSync23(this.directory, { recursive: true, mode: 448 });
|
|
256177
256309
|
this.assertRunDirectorySafe();
|
|
256178
256310
|
this.initialized = true;
|
|
256179
256311
|
}
|
|
@@ -262306,15 +262438,15 @@ ${diff.substring(0, 2e4)}`
|
|
|
262306
262438
|
}
|
|
262307
262439
|
const checkpointsToRollback = checkpoints.slice(targetIndex).reverse();
|
|
262308
262440
|
const restored = /* @__PURE__ */ new Set();
|
|
262441
|
+
const result = this.rollbackManager.rollbackMany(checkpointsToRollback);
|
|
262442
|
+
if (!result.success) {
|
|
262443
|
+
this.interaction.showText(
|
|
262444
|
+
`Rewind failed: ${result.error || "unknown error"}`
|
|
262445
|
+
);
|
|
262446
|
+
return false;
|
|
262447
|
+
}
|
|
262448
|
+
for (const file of result.restored) restored.add(file);
|
|
262309
262449
|
for (const checkpoint of checkpointsToRollback) {
|
|
262310
|
-
const result = this.rollbackManager.rollback(checkpoint);
|
|
262311
|
-
if (!result.success) {
|
|
262312
|
-
this.interaction.showText(
|
|
262313
|
-
`Rewind failed at checkpoint ${checkpoint.id}: ${result.error || "unknown error"}`
|
|
262314
|
-
);
|
|
262315
|
-
return false;
|
|
262316
|
-
}
|
|
262317
|
-
for (const file of result.restored) restored.add(file);
|
|
262318
262450
|
this.checkpointManager.removeCheckpoint(checkpoint.id);
|
|
262319
262451
|
}
|
|
262320
262452
|
this.interaction.showText(
|
|
@@ -262340,19 +262472,10 @@ ${diff.substring(0, 2e4)}`
|
|
|
262340
262472
|
}
|
|
262341
262473
|
});
|
|
262342
262474
|
if (backup) {
|
|
262343
|
-
|
|
262344
|
-
|
|
262345
|
-
|
|
262346
|
-
|
|
262347
|
-
fs32.unlinkSync(safePath);
|
|
262348
|
-
}
|
|
262349
|
-
} else {
|
|
262350
|
-
fs32.writeFileSync(safePath, backup.originalContent, "utf8");
|
|
262351
|
-
}
|
|
262352
|
-
return true;
|
|
262353
|
-
} catch {
|
|
262354
|
-
return false;
|
|
262355
|
-
}
|
|
262475
|
+
return this.rollbackManager.rollback({
|
|
262476
|
+
...cp,
|
|
262477
|
+
backups: [backup]
|
|
262478
|
+
}).success;
|
|
262356
262479
|
}
|
|
262357
262480
|
}
|
|
262358
262481
|
return false;
|
|
@@ -262815,12 +262938,28 @@ var AgentTaskScheduler = class {
|
|
|
262815
262938
|
timeout = setTimeout(() => {
|
|
262816
262939
|
const error = new Error(`Agent task timed out after ${timeoutMs}ms.`);
|
|
262817
262940
|
taskController.abort(error);
|
|
262941
|
+
resolve20({ id: task.id, status: "failed", error });
|
|
262818
262942
|
this.abort(
|
|
262819
262943
|
`Agent task ${task.id} timed out; the remaining task graph was cancelled.`
|
|
262820
262944
|
);
|
|
262821
|
-
resolve20({ id: task.id, status: "failed", error });
|
|
262822
262945
|
}, timeoutMs);
|
|
262823
262946
|
});
|
|
262947
|
+
let removeSchedulerAbortListener = () => void 0;
|
|
262948
|
+
const schedulerAbortResult = new Promise((resolve20) => {
|
|
262949
|
+
const onAbort = () => {
|
|
262950
|
+
if (taskController.signal.aborted) return;
|
|
262951
|
+
resolve20({
|
|
262952
|
+
id: task.id,
|
|
262953
|
+
status: "aborted",
|
|
262954
|
+
error: abortError2(this.controller.signal)
|
|
262955
|
+
});
|
|
262956
|
+
};
|
|
262957
|
+
removeSchedulerAbortListener = () => this.controller.signal.removeEventListener("abort", onAbort);
|
|
262958
|
+
this.controller.signal.addEventListener("abort", onAbort, {
|
|
262959
|
+
once: true
|
|
262960
|
+
});
|
|
262961
|
+
if (this.controller.signal.aborted) onAbort();
|
|
262962
|
+
});
|
|
262824
262963
|
const runResult = Promise.resolve().then(() => task.run(signal)).then((value) => ({
|
|
262825
262964
|
id: task.id,
|
|
262826
262965
|
status: "completed",
|
|
@@ -262833,8 +262972,13 @@ var AgentTaskScheduler = class {
|
|
|
262833
262972
|
};
|
|
262834
262973
|
});
|
|
262835
262974
|
try {
|
|
262836
|
-
const result = await Promise.race([
|
|
262837
|
-
|
|
262975
|
+
const result = await Promise.race([
|
|
262976
|
+
runResult,
|
|
262977
|
+
timeoutResult,
|
|
262978
|
+
schedulerAbortResult
|
|
262979
|
+
]);
|
|
262980
|
+
const cancellationNeedsGrace = result.status === "failed" && taskController.signal.aborted || result.status === "aborted" && this.controller.signal.aborted;
|
|
262981
|
+
if (!cancellationNeedsGrace) {
|
|
262838
262982
|
return result;
|
|
262839
262983
|
}
|
|
262840
262984
|
let graceTimer;
|
|
@@ -262852,6 +262996,7 @@ var AgentTaskScheduler = class {
|
|
|
262852
262996
|
return result;
|
|
262853
262997
|
} finally {
|
|
262854
262998
|
if (timeout) clearTimeout(timeout);
|
|
262999
|
+
removeSchedulerAbortListener();
|
|
262855
263000
|
}
|
|
262856
263001
|
}
|
|
262857
263002
|
};
|
|
@@ -293049,7 +293194,7 @@ import {
|
|
|
293049
293194
|
existsSync as existsSync20,
|
|
293050
293195
|
lstatSync as lstatSync6,
|
|
293051
293196
|
mkdirSync as mkdirSync7,
|
|
293052
|
-
renameSync as
|
|
293197
|
+
renameSync as renameSync6,
|
|
293053
293198
|
rmSync as rmSync7,
|
|
293054
293199
|
writeFileSync as writeFileSync8
|
|
293055
293200
|
} from "fs";
|
|
@@ -293090,7 +293235,7 @@ function runTraceExport(cwd, sessionId, options = {}) {
|
|
|
293090
293235
|
mode: 384
|
|
293091
293236
|
});
|
|
293092
293237
|
if (existsSync20(outputPath)) rmSync7(outputPath, { force: true });
|
|
293093
|
-
|
|
293238
|
+
renameSync6(temporaryPath, outputPath);
|
|
293094
293239
|
} finally {
|
|
293095
293240
|
rmSync7(temporaryPath, { force: true });
|
|
293096
293241
|
}
|
|
@@ -293104,7 +293249,7 @@ import {
|
|
|
293104
293249
|
existsSync as existsSync21,
|
|
293105
293250
|
lstatSync as lstatSync7,
|
|
293106
293251
|
mkdirSync as mkdirSync8,
|
|
293107
|
-
renameSync as
|
|
293252
|
+
renameSync as renameSync7,
|
|
293108
293253
|
rmSync as rmSync8,
|
|
293109
293254
|
writeFileSync as writeFileSync9
|
|
293110
293255
|
} from "fs";
|
|
@@ -293456,7 +293601,7 @@ function writeJsonAtomically2(filePath, value) {
|
|
|
293456
293601
|
mode: 384
|
|
293457
293602
|
});
|
|
293458
293603
|
if (existsSync21(filePath)) rmSync8(filePath, { force: true });
|
|
293459
|
-
|
|
293604
|
+
renameSync7(temporaryPath, filePath);
|
|
293460
293605
|
} finally {
|
|
293461
293606
|
rmSync8(temporaryPath, { force: true });
|
|
293462
293607
|
}
|
|
@@ -293730,7 +293875,7 @@ import {
|
|
|
293730
293875
|
lstatSync as lstatSync9,
|
|
293731
293876
|
mkdirSync as mkdirSync9,
|
|
293732
293877
|
readdirSync as readdirSync9,
|
|
293733
|
-
renameSync as
|
|
293878
|
+
renameSync as renameSync8,
|
|
293734
293879
|
rmSync as rmSync10,
|
|
293735
293880
|
writeFileSync as writeFileSync10
|
|
293736
293881
|
} from "fs";
|
|
@@ -293853,7 +293998,7 @@ function writeProjectBackup(outputPath, bundle) {
|
|
|
293853
293998
|
`,
|
|
293854
293999
|
{ encoding: "utf8", mode: 384 }
|
|
293855
294000
|
);
|
|
293856
|
-
|
|
294001
|
+
renameSync8(temporaryPath, destination);
|
|
293857
294002
|
} finally {
|
|
293858
294003
|
rmSync10(temporaryPath, { force: true });
|
|
293859
294004
|
}
|
|
@@ -293980,17 +294125,17 @@ function assertDirectoryChainHasNoSymlink(root, target) {
|
|
|
293980
294125
|
}
|
|
293981
294126
|
function replaceFileAtomically2(temporaryPath, destination) {
|
|
293982
294127
|
if (!existsSync28(destination)) {
|
|
293983
|
-
|
|
294128
|
+
renameSync8(temporaryPath, destination);
|
|
293984
294129
|
return;
|
|
293985
294130
|
}
|
|
293986
294131
|
const previousPath = `${destination}.${process.pid}.${randomUUID14()}.bak`;
|
|
293987
|
-
|
|
294132
|
+
renameSync8(destination, previousPath);
|
|
293988
294133
|
try {
|
|
293989
|
-
|
|
294134
|
+
renameSync8(temporaryPath, destination);
|
|
293990
294135
|
rmSync10(previousPath, { force: true });
|
|
293991
294136
|
} catch (error) {
|
|
293992
294137
|
if (!existsSync28(destination) && existsSync28(previousPath)) {
|
|
293993
|
-
|
|
294138
|
+
renameSync8(previousPath, destination);
|
|
293994
294139
|
}
|
|
293995
294140
|
throw error;
|
|
293996
294141
|
}
|
|
@@ -294105,7 +294250,7 @@ import {
|
|
|
294105
294250
|
lstatSync as lstatSync10,
|
|
294106
294251
|
mkdirSync as mkdirSync10,
|
|
294107
294252
|
readdirSync as readdirSync10,
|
|
294108
|
-
renameSync as
|
|
294253
|
+
renameSync as renameSync9,
|
|
294109
294254
|
rmSync as rmSync11,
|
|
294110
294255
|
writeFileSync as writeFileSync11
|
|
294111
294256
|
} from "fs";
|
|
@@ -294194,16 +294339,16 @@ var ExtensionManager = class {
|
|
|
294194
294339
|
copyDirectorySafely(sourceRoot, staging);
|
|
294195
294340
|
const digest = hashExtensionDirectory(staging);
|
|
294196
294341
|
if (existsSync29(target)) {
|
|
294197
|
-
|
|
294342
|
+
renameSync9(target, targetBackup);
|
|
294198
294343
|
targetBackedUp = true;
|
|
294199
294344
|
}
|
|
294200
294345
|
for (const prompt of promptTargets) {
|
|
294201
294346
|
if (!existsSync29(prompt.target)) continue;
|
|
294202
294347
|
mkdirSync10(dirname14(prompt.backup), { recursive: true });
|
|
294203
|
-
|
|
294348
|
+
renameSync9(prompt.target, prompt.backup);
|
|
294204
294349
|
prompt.backedUp = true;
|
|
294205
294350
|
}
|
|
294206
|
-
|
|
294351
|
+
renameSync9(staging, target);
|
|
294207
294352
|
targetInstalled = true;
|
|
294208
294353
|
promptMutationStarted = true;
|
|
294209
294354
|
materializePromptContributions(target, manifest, this.orbitDir);
|
|
@@ -294235,7 +294380,7 @@ var ExtensionManager = class {
|
|
|
294235
294380
|
rmSync11(target, { recursive: true, force: true });
|
|
294236
294381
|
}
|
|
294237
294382
|
if (targetBackedUp && existsSync29(targetBackup)) {
|
|
294238
|
-
|
|
294383
|
+
renameSync9(targetBackup, target);
|
|
294239
294384
|
}
|
|
294240
294385
|
for (const prompt of promptTargets) {
|
|
294241
294386
|
if (promptMutationStarted) {
|
|
@@ -294243,7 +294388,7 @@ var ExtensionManager = class {
|
|
|
294243
294388
|
}
|
|
294244
294389
|
if (prompt.backedUp && existsSync29(prompt.backup)) {
|
|
294245
294390
|
mkdirSync10(dirname14(prompt.target), { recursive: true });
|
|
294246
|
-
|
|
294391
|
+
renameSync9(prompt.backup, prompt.target);
|
|
294247
294392
|
}
|
|
294248
294393
|
}
|
|
294249
294394
|
rmSync11(promptRollbackRoot, { recursive: true, force: true });
|
|
@@ -294291,7 +294436,7 @@ var ExtensionManager = class {
|
|
|
294291
294436
|
for (const entry of targets) {
|
|
294292
294437
|
if (!existsSync29(entry.target)) continue;
|
|
294293
294438
|
mkdirSync10(dirname14(entry.backup), { recursive: true });
|
|
294294
|
-
|
|
294439
|
+
renameSync9(entry.target, entry.backup);
|
|
294295
294440
|
entry.backedUp = true;
|
|
294296
294441
|
}
|
|
294297
294442
|
this.writeRegistry(registry.filter((entry) => entry.id !== id));
|
|
@@ -294302,7 +294447,7 @@ var ExtensionManager = class {
|
|
|
294302
294447
|
for (const entry of targets) {
|
|
294303
294448
|
if (!entry.backedUp || !existsSync29(entry.backup)) continue;
|
|
294304
294449
|
mkdirSync10(dirname14(entry.target), { recursive: true });
|
|
294305
|
-
|
|
294450
|
+
renameSync9(entry.backup, entry.target);
|
|
294306
294451
|
}
|
|
294307
294452
|
rmSync11(rollbackRoot, { recursive: true, force: true });
|
|
294308
294453
|
} catch (rollbackError) {
|