@orbit-build/cli 0.4.9 → 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 +282 -110
- 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`);
|
|
@@ -253968,11 +254100,12 @@ import fs3 from "fs";
|
|
|
253968
254100
|
import os22 from "os";
|
|
253969
254101
|
import path22 from "path";
|
|
253970
254102
|
var DANGEROUS_COMMAND_REGEXES = [
|
|
253971
|
-
/\brm\s
|
|
253972
|
-
/\brm\
|
|
254103
|
+
/\brm\b[^\r\n;&|]*\s-[a-z]*r[a-z]*(?=\s|$)/i,
|
|
254104
|
+
/\brm\b[^\r\n;&|]*--recursive\b/i,
|
|
253973
254105
|
/\bdel\s+\/s\b/i,
|
|
253974
254106
|
/\b(?:rmdir|rd)\s+\/s\b/i,
|
|
253975
254107
|
/\bremove-item\b.*(?:-recurse|-force)\b/i,
|
|
254108
|
+
/\b(?:ri|rmdir|rd|del|erase)\b[^\r\n;&|]*(?:-recurse\b|\s-r[a-z]*(?=\s|$))/i,
|
|
253976
254109
|
/\bchmod\s+-R\b/i,
|
|
253977
254110
|
/\bchown\s+-R\b/i,
|
|
253978
254111
|
/\bsudo\b/i,
|
|
@@ -254390,6 +254523,32 @@ var PermissionEngine = class {
|
|
|
254390
254523
|
risk
|
|
254391
254524
|
};
|
|
254392
254525
|
}
|
|
254526
|
+
const linkedWorkspaceEscape = commandPaths.pathTokens.find((token) => {
|
|
254527
|
+
const resolved = resolveCommandPathCandidate(token, workspaceRoot);
|
|
254528
|
+
if (resolved === null || !checkWorkspaceBoundary(workspaceRoot, resolved) || !fs3.existsSync(workspaceRoot)) {
|
|
254529
|
+
return false;
|
|
254530
|
+
}
|
|
254531
|
+
try {
|
|
254532
|
+
resolveSafePath(workspaceRoot, resolved);
|
|
254533
|
+
return false;
|
|
254534
|
+
} catch {
|
|
254535
|
+
return true;
|
|
254536
|
+
}
|
|
254537
|
+
});
|
|
254538
|
+
if (linkedWorkspaceEscape) {
|
|
254539
|
+
if (mode === "strict") {
|
|
254540
|
+
return {
|
|
254541
|
+
action: "deny",
|
|
254542
|
+
reason: `Command path "${linkedWorkspaceEscape}" does not resolve safely inside the workspace, blocked under strict mode.`,
|
|
254543
|
+
risk
|
|
254544
|
+
};
|
|
254545
|
+
}
|
|
254546
|
+
return {
|
|
254547
|
+
action: "ask",
|
|
254548
|
+
reason: `Command path "${linkedWorkspaceEscape}" does not resolve safely inside the workspace. It may traverse a symbolic link or junction.`,
|
|
254549
|
+
risk
|
|
254550
|
+
};
|
|
254551
|
+
}
|
|
254393
254552
|
const outsidePath = commandPaths.pathTokens.find((token) => {
|
|
254394
254553
|
const resolved = resolveCommandPathCandidate(token, workspaceRoot);
|
|
254395
254554
|
return resolved !== null && !checkWorkspaceBoundary(workspaceRoot, resolved) && !trustedRoots.some(
|
|
@@ -254516,14 +254675,14 @@ import {
|
|
|
254516
254675
|
mkdirSync as mkdirSync5,
|
|
254517
254676
|
openSync as openSync3,
|
|
254518
254677
|
readdirSync as readdirSync3,
|
|
254519
|
-
renameSync as
|
|
254678
|
+
renameSync as renameSync5,
|
|
254520
254679
|
rmSync as rmSync4,
|
|
254521
254680
|
writeFileSync as writeFileSync7
|
|
254522
254681
|
} from "fs";
|
|
254523
254682
|
import { createHash as createHash23 } from "crypto";
|
|
254524
254683
|
import {
|
|
254525
254684
|
closeSync as closeSync22,
|
|
254526
|
-
lstatSync as
|
|
254685
|
+
lstatSync as lstatSync23,
|
|
254527
254686
|
openSync as openSync22,
|
|
254528
254687
|
realpathSync as realpathSync2,
|
|
254529
254688
|
statSync,
|
|
@@ -254532,7 +254691,7 @@ import {
|
|
|
254532
254691
|
import { homedir as homedir5 } from "os";
|
|
254533
254692
|
import { basename as basename2, dirname as dirname23, isAbsolute as isAbsolute23, join as join25, parse as parse2, resolve as resolve24 } from "path";
|
|
254534
254693
|
import { z as z210 } from "zod";
|
|
254535
|
-
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";
|
|
254536
254695
|
import { basename as basename22, join as join34, resolve as resolve32 } from "path";
|
|
254537
254696
|
import { z as z37 } from "zod";
|
|
254538
254697
|
var SafeObjectKeySchema = z29.string().refine(
|
|
@@ -254936,7 +255095,7 @@ function preserveLastKnownGoodFile(filePath, schema) {
|
|
|
254936
255095
|
}
|
|
254937
255096
|
function replaceFileAtomically(temporaryPath, destinationPath) {
|
|
254938
255097
|
try {
|
|
254939
|
-
|
|
255098
|
+
renameSync5(temporaryPath, destinationPath);
|
|
254940
255099
|
return;
|
|
254941
255100
|
} catch (error) {
|
|
254942
255101
|
const code = typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" ? error.code : "";
|
|
@@ -254946,10 +255105,10 @@ function replaceFileAtomically(temporaryPath, destinationPath) {
|
|
|
254946
255105
|
let previousMoved = false;
|
|
254947
255106
|
try {
|
|
254948
255107
|
if (existsSync10(destinationPath)) {
|
|
254949
|
-
|
|
255108
|
+
renameSync5(destinationPath, backupPath);
|
|
254950
255109
|
previousMoved = true;
|
|
254951
255110
|
}
|
|
254952
|
-
|
|
255111
|
+
renameSync5(temporaryPath, destinationPath);
|
|
254953
255112
|
if (previousMoved) {
|
|
254954
255113
|
try {
|
|
254955
255114
|
rmSync4(backupPath, { force: true });
|
|
@@ -254959,7 +255118,7 @@ function replaceFileAtomically(temporaryPath, destinationPath) {
|
|
|
254959
255118
|
} catch (error) {
|
|
254960
255119
|
if (previousMoved && existsSync10(backupPath) && !existsSync10(destinationPath)) {
|
|
254961
255120
|
try {
|
|
254962
|
-
|
|
255121
|
+
renameSync5(backupPath, destinationPath);
|
|
254963
255122
|
} catch {
|
|
254964
255123
|
}
|
|
254965
255124
|
}
|
|
@@ -256082,7 +256241,7 @@ function isDirectory(targetPath) {
|
|
|
256082
256241
|
}
|
|
256083
256242
|
function removeStaleLock(lockPath) {
|
|
256084
256243
|
try {
|
|
256085
|
-
const lock =
|
|
256244
|
+
const lock = lstatSync23(lockPath);
|
|
256086
256245
|
if (!lock.isFile() || Date.now() - lock.mtimeMs <= PROJECT_REGISTRY_STALE_LOCK_MS) {
|
|
256087
256246
|
return false;
|
|
256088
256247
|
}
|
|
@@ -256146,7 +256305,7 @@ var AgentRunStore = class {
|
|
|
256146
256305
|
directory;
|
|
256147
256306
|
initialized = false;
|
|
256148
256307
|
initialize() {
|
|
256149
|
-
|
|
256308
|
+
mkdirSync23(this.directory, { recursive: true, mode: 448 });
|
|
256150
256309
|
this.assertRunDirectorySafe();
|
|
256151
256310
|
this.initialized = true;
|
|
256152
256311
|
}
|
|
@@ -262279,15 +262438,15 @@ ${diff.substring(0, 2e4)}`
|
|
|
262279
262438
|
}
|
|
262280
262439
|
const checkpointsToRollback = checkpoints.slice(targetIndex).reverse();
|
|
262281
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);
|
|
262282
262449
|
for (const checkpoint of checkpointsToRollback) {
|
|
262283
|
-
const result = this.rollbackManager.rollback(checkpoint);
|
|
262284
|
-
if (!result.success) {
|
|
262285
|
-
this.interaction.showText(
|
|
262286
|
-
`Rewind failed at checkpoint ${checkpoint.id}: ${result.error || "unknown error"}`
|
|
262287
|
-
);
|
|
262288
|
-
return false;
|
|
262289
|
-
}
|
|
262290
|
-
for (const file of result.restored) restored.add(file);
|
|
262291
262450
|
this.checkpointManager.removeCheckpoint(checkpoint.id);
|
|
262292
262451
|
}
|
|
262293
262452
|
this.interaction.showText(
|
|
@@ -262313,19 +262472,10 @@ ${diff.substring(0, 2e4)}`
|
|
|
262313
262472
|
}
|
|
262314
262473
|
});
|
|
262315
262474
|
if (backup) {
|
|
262316
|
-
|
|
262317
|
-
|
|
262318
|
-
|
|
262319
|
-
|
|
262320
|
-
fs32.unlinkSync(safePath);
|
|
262321
|
-
}
|
|
262322
|
-
} else {
|
|
262323
|
-
fs32.writeFileSync(safePath, backup.originalContent, "utf8");
|
|
262324
|
-
}
|
|
262325
|
-
return true;
|
|
262326
|
-
} catch {
|
|
262327
|
-
return false;
|
|
262328
|
-
}
|
|
262475
|
+
return this.rollbackManager.rollback({
|
|
262476
|
+
...cp,
|
|
262477
|
+
backups: [backup]
|
|
262478
|
+
}).success;
|
|
262329
262479
|
}
|
|
262330
262480
|
}
|
|
262331
262481
|
return false;
|
|
@@ -262788,12 +262938,28 @@ var AgentTaskScheduler = class {
|
|
|
262788
262938
|
timeout = setTimeout(() => {
|
|
262789
262939
|
const error = new Error(`Agent task timed out after ${timeoutMs}ms.`);
|
|
262790
262940
|
taskController.abort(error);
|
|
262941
|
+
resolve20({ id: task.id, status: "failed", error });
|
|
262791
262942
|
this.abort(
|
|
262792
262943
|
`Agent task ${task.id} timed out; the remaining task graph was cancelled.`
|
|
262793
262944
|
);
|
|
262794
|
-
resolve20({ id: task.id, status: "failed", error });
|
|
262795
262945
|
}, timeoutMs);
|
|
262796
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
|
+
});
|
|
262797
262963
|
const runResult = Promise.resolve().then(() => task.run(signal)).then((value) => ({
|
|
262798
262964
|
id: task.id,
|
|
262799
262965
|
status: "completed",
|
|
@@ -262806,8 +262972,13 @@ var AgentTaskScheduler = class {
|
|
|
262806
262972
|
};
|
|
262807
262973
|
});
|
|
262808
262974
|
try {
|
|
262809
|
-
const result = await Promise.race([
|
|
262810
|
-
|
|
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) {
|
|
262811
262982
|
return result;
|
|
262812
262983
|
}
|
|
262813
262984
|
let graceTimer;
|
|
@@ -262825,6 +262996,7 @@ var AgentTaskScheduler = class {
|
|
|
262825
262996
|
return result;
|
|
262826
262997
|
} finally {
|
|
262827
262998
|
if (timeout) clearTimeout(timeout);
|
|
262999
|
+
removeSchedulerAbortListener();
|
|
262828
263000
|
}
|
|
262829
263001
|
}
|
|
262830
263002
|
};
|
|
@@ -293022,7 +293194,7 @@ import {
|
|
|
293022
293194
|
existsSync as existsSync20,
|
|
293023
293195
|
lstatSync as lstatSync6,
|
|
293024
293196
|
mkdirSync as mkdirSync7,
|
|
293025
|
-
renameSync as
|
|
293197
|
+
renameSync as renameSync6,
|
|
293026
293198
|
rmSync as rmSync7,
|
|
293027
293199
|
writeFileSync as writeFileSync8
|
|
293028
293200
|
} from "fs";
|
|
@@ -293063,7 +293235,7 @@ function runTraceExport(cwd, sessionId, options = {}) {
|
|
|
293063
293235
|
mode: 384
|
|
293064
293236
|
});
|
|
293065
293237
|
if (existsSync20(outputPath)) rmSync7(outputPath, { force: true });
|
|
293066
|
-
|
|
293238
|
+
renameSync6(temporaryPath, outputPath);
|
|
293067
293239
|
} finally {
|
|
293068
293240
|
rmSync7(temporaryPath, { force: true });
|
|
293069
293241
|
}
|
|
@@ -293077,7 +293249,7 @@ import {
|
|
|
293077
293249
|
existsSync as existsSync21,
|
|
293078
293250
|
lstatSync as lstatSync7,
|
|
293079
293251
|
mkdirSync as mkdirSync8,
|
|
293080
|
-
renameSync as
|
|
293252
|
+
renameSync as renameSync7,
|
|
293081
293253
|
rmSync as rmSync8,
|
|
293082
293254
|
writeFileSync as writeFileSync9
|
|
293083
293255
|
} from "fs";
|
|
@@ -293429,7 +293601,7 @@ function writeJsonAtomically2(filePath, value) {
|
|
|
293429
293601
|
mode: 384
|
|
293430
293602
|
});
|
|
293431
293603
|
if (existsSync21(filePath)) rmSync8(filePath, { force: true });
|
|
293432
|
-
|
|
293604
|
+
renameSync7(temporaryPath, filePath);
|
|
293433
293605
|
} finally {
|
|
293434
293606
|
rmSync8(temporaryPath, { force: true });
|
|
293435
293607
|
}
|
|
@@ -293703,7 +293875,7 @@ import {
|
|
|
293703
293875
|
lstatSync as lstatSync9,
|
|
293704
293876
|
mkdirSync as mkdirSync9,
|
|
293705
293877
|
readdirSync as readdirSync9,
|
|
293706
|
-
renameSync as
|
|
293878
|
+
renameSync as renameSync8,
|
|
293707
293879
|
rmSync as rmSync10,
|
|
293708
293880
|
writeFileSync as writeFileSync10
|
|
293709
293881
|
} from "fs";
|
|
@@ -293826,7 +293998,7 @@ function writeProjectBackup(outputPath, bundle) {
|
|
|
293826
293998
|
`,
|
|
293827
293999
|
{ encoding: "utf8", mode: 384 }
|
|
293828
294000
|
);
|
|
293829
|
-
|
|
294001
|
+
renameSync8(temporaryPath, destination);
|
|
293830
294002
|
} finally {
|
|
293831
294003
|
rmSync10(temporaryPath, { force: true });
|
|
293832
294004
|
}
|
|
@@ -293953,17 +294125,17 @@ function assertDirectoryChainHasNoSymlink(root, target) {
|
|
|
293953
294125
|
}
|
|
293954
294126
|
function replaceFileAtomically2(temporaryPath, destination) {
|
|
293955
294127
|
if (!existsSync28(destination)) {
|
|
293956
|
-
|
|
294128
|
+
renameSync8(temporaryPath, destination);
|
|
293957
294129
|
return;
|
|
293958
294130
|
}
|
|
293959
294131
|
const previousPath = `${destination}.${process.pid}.${randomUUID14()}.bak`;
|
|
293960
|
-
|
|
294132
|
+
renameSync8(destination, previousPath);
|
|
293961
294133
|
try {
|
|
293962
|
-
|
|
294134
|
+
renameSync8(temporaryPath, destination);
|
|
293963
294135
|
rmSync10(previousPath, { force: true });
|
|
293964
294136
|
} catch (error) {
|
|
293965
294137
|
if (!existsSync28(destination) && existsSync28(previousPath)) {
|
|
293966
|
-
|
|
294138
|
+
renameSync8(previousPath, destination);
|
|
293967
294139
|
}
|
|
293968
294140
|
throw error;
|
|
293969
294141
|
}
|
|
@@ -294078,7 +294250,7 @@ import {
|
|
|
294078
294250
|
lstatSync as lstatSync10,
|
|
294079
294251
|
mkdirSync as mkdirSync10,
|
|
294080
294252
|
readdirSync as readdirSync10,
|
|
294081
|
-
renameSync as
|
|
294253
|
+
renameSync as renameSync9,
|
|
294082
294254
|
rmSync as rmSync11,
|
|
294083
294255
|
writeFileSync as writeFileSync11
|
|
294084
294256
|
} from "fs";
|
|
@@ -294167,16 +294339,16 @@ var ExtensionManager = class {
|
|
|
294167
294339
|
copyDirectorySafely(sourceRoot, staging);
|
|
294168
294340
|
const digest = hashExtensionDirectory(staging);
|
|
294169
294341
|
if (existsSync29(target)) {
|
|
294170
|
-
|
|
294342
|
+
renameSync9(target, targetBackup);
|
|
294171
294343
|
targetBackedUp = true;
|
|
294172
294344
|
}
|
|
294173
294345
|
for (const prompt of promptTargets) {
|
|
294174
294346
|
if (!existsSync29(prompt.target)) continue;
|
|
294175
294347
|
mkdirSync10(dirname14(prompt.backup), { recursive: true });
|
|
294176
|
-
|
|
294348
|
+
renameSync9(prompt.target, prompt.backup);
|
|
294177
294349
|
prompt.backedUp = true;
|
|
294178
294350
|
}
|
|
294179
|
-
|
|
294351
|
+
renameSync9(staging, target);
|
|
294180
294352
|
targetInstalled = true;
|
|
294181
294353
|
promptMutationStarted = true;
|
|
294182
294354
|
materializePromptContributions(target, manifest, this.orbitDir);
|
|
@@ -294208,7 +294380,7 @@ var ExtensionManager = class {
|
|
|
294208
294380
|
rmSync11(target, { recursive: true, force: true });
|
|
294209
294381
|
}
|
|
294210
294382
|
if (targetBackedUp && existsSync29(targetBackup)) {
|
|
294211
|
-
|
|
294383
|
+
renameSync9(targetBackup, target);
|
|
294212
294384
|
}
|
|
294213
294385
|
for (const prompt of promptTargets) {
|
|
294214
294386
|
if (promptMutationStarted) {
|
|
@@ -294216,7 +294388,7 @@ var ExtensionManager = class {
|
|
|
294216
294388
|
}
|
|
294217
294389
|
if (prompt.backedUp && existsSync29(prompt.backup)) {
|
|
294218
294390
|
mkdirSync10(dirname14(prompt.target), { recursive: true });
|
|
294219
|
-
|
|
294391
|
+
renameSync9(prompt.backup, prompt.target);
|
|
294220
294392
|
}
|
|
294221
294393
|
}
|
|
294222
294394
|
rmSync11(promptRollbackRoot, { recursive: true, force: true });
|
|
@@ -294264,7 +294436,7 @@ var ExtensionManager = class {
|
|
|
294264
294436
|
for (const entry of targets) {
|
|
294265
294437
|
if (!existsSync29(entry.target)) continue;
|
|
294266
294438
|
mkdirSync10(dirname14(entry.backup), { recursive: true });
|
|
294267
|
-
|
|
294439
|
+
renameSync9(entry.target, entry.backup);
|
|
294268
294440
|
entry.backedUp = true;
|
|
294269
294441
|
}
|
|
294270
294442
|
this.writeRegistry(registry.filter((entry) => entry.id !== id));
|
|
@@ -294275,7 +294447,7 @@ var ExtensionManager = class {
|
|
|
294275
294447
|
for (const entry of targets) {
|
|
294276
294448
|
if (!entry.backedUp || !existsSync29(entry.backup)) continue;
|
|
294277
294449
|
mkdirSync10(dirname14(entry.target), { recursive: true });
|
|
294278
|
-
|
|
294450
|
+
renameSync9(entry.backup, entry.target);
|
|
294279
294451
|
}
|
|
294280
294452
|
rmSync11(rollbackRoot, { recursive: true, force: true });
|
|
294281
294453
|
} catch (rollbackError) {
|