@quantiya/codevibe-core 2.0.80 → 2.0.82
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/appsync/appsync-client.d.ts +3 -1
- package/dist/credential-broker/index.d.ts +1 -1
- package/dist/credential-broker/oauth-account-lock.d.ts +24 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +496 -487
- package/dist/local-executor/index.d.ts +1 -0
- package/dist/local-executor/spawn-sweep.d.ts +75 -0
- package/dist/orchestration-shell/cli.js +525 -291
- package/dist/orchestration-shell/index.d.ts +17 -0
- package/dist/substrate/bwrap.d.ts +93 -0
- package/dist/substrate/command-runner.d.ts +1 -0
- package/dist/substrate/index.d.ts +4 -0
- package/dist/substrate/pasta.d.ts +36 -0
- package/dist/substrate/types.d.ts +3 -1
- package/dist/substrate-launch/engage-substrate.d.ts +4 -0
- package/package.json +1 -1
|
@@ -149,7 +149,7 @@ async function fireBeacon(name, params, clientId = getClientId()) {
|
|
|
149
149
|
client_id: clientId,
|
|
150
150
|
events: [{ name, params }]
|
|
151
151
|
});
|
|
152
|
-
await new Promise((
|
|
152
|
+
await new Promise((resolve29) => {
|
|
153
153
|
let req = https.request(
|
|
154
154
|
{
|
|
155
155
|
hostname: GA4_HOSTNAME,
|
|
@@ -157,9 +157,9 @@ async function fireBeacon(name, params, clientId = getClientId()) {
|
|
|
157
157
|
method: "POST",
|
|
158
158
|
headers: { "Content-Type": "application/json" }
|
|
159
159
|
},
|
|
160
|
-
() =>
|
|
160
|
+
() => resolve29()
|
|
161
161
|
);
|
|
162
|
-
req.on("error", () =>
|
|
162
|
+
req.on("error", () => resolve29()), req.write(payload), req.end(), setTimeout(resolve29, 2e3);
|
|
163
163
|
});
|
|
164
164
|
} catch {
|
|
165
165
|
}
|
|
@@ -641,7 +641,7 @@ var import_node_child_process8, path66, GIT_TIMEOUT_MS, SCRUBBED_ENV, defaultGit
|
|
|
641
641
|
import_node_child_process8 = require("node:child_process"), path66 = __toESM(require("node:path")), GIT_TIMEOUT_MS = 5e3, SCRUBBED_ENV = (() => {
|
|
642
642
|
let out = {};
|
|
643
643
|
return process.env.PATH && (out.PATH = process.env.PATH), process.env.LANG && (out.LANG = process.env.LANG), process.env.LC_ALL && (out.LC_ALL = process.env.LC_ALL), out;
|
|
644
|
-
})(), defaultGitExec = (args, options) => new Promise((
|
|
644
|
+
})(), defaultGitExec = (args, options) => new Promise((resolve29, reject) => {
|
|
645
645
|
(0, import_node_child_process8.execFile)(
|
|
646
646
|
"git",
|
|
647
647
|
args,
|
|
@@ -658,7 +658,7 @@ var import_node_child_process8, path66, GIT_TIMEOUT_MS, SCRUBBED_ENV, defaultGit
|
|
|
658
658
|
return;
|
|
659
659
|
}
|
|
660
660
|
let out = stdout;
|
|
661
|
-
|
|
661
|
+
resolve29(typeof out == "string" ? out : out.toString("utf8"));
|
|
662
662
|
}
|
|
663
663
|
).on("error", reject);
|
|
664
664
|
});
|
|
@@ -887,8 +887,8 @@ var import_node_fs28, path67, os39, crypto26, import_json_freeze15, import_yaml,
|
|
|
887
887
|
this.locked = !0;
|
|
888
888
|
return;
|
|
889
889
|
}
|
|
890
|
-
return new Promise((
|
|
891
|
-
this.waiters.push(
|
|
890
|
+
return new Promise((resolve29) => {
|
|
891
|
+
this.waiters.push(resolve29);
|
|
892
892
|
});
|
|
893
893
|
}
|
|
894
894
|
release() {
|
|
@@ -951,7 +951,7 @@ function companionPreferenceFilePath() {
|
|
|
951
951
|
async function readCompanionPreference() {
|
|
952
952
|
let filePath = companionPreferenceFilePath(), raw, st;
|
|
953
953
|
try {
|
|
954
|
-
st = await
|
|
954
|
+
st = await fs65.stat(filePath);
|
|
955
955
|
} catch (err) {
|
|
956
956
|
return err?.code !== "ENOENT" && logger.debug("[companion-preference] stat error \u2014 treating as missing", {
|
|
957
957
|
filePath,
|
|
@@ -964,7 +964,7 @@ async function readCompanionPreference() {
|
|
|
964
964
|
`
|
|
965
965
|
), null;
|
|
966
966
|
try {
|
|
967
|
-
raw = await
|
|
967
|
+
raw = await fs65.readFile(filePath, "utf8");
|
|
968
968
|
} catch (err) {
|
|
969
969
|
return logger.debug("[companion-preference] read error \u2014 treating as missing", {
|
|
970
970
|
filePath,
|
|
@@ -982,19 +982,19 @@ async function readCompanionPreference() {
|
|
|
982
982
|
}
|
|
983
983
|
async function persistCompanionPreference(pref) {
|
|
984
984
|
let filePath = companionPreferenceFilePath(), dir = path85.dirname(filePath);
|
|
985
|
-
await
|
|
985
|
+
await fs65.mkdir(dir, { recursive: !0 }), await fs65.writeFile(filePath, JSON.stringify(pref, null, 2), {
|
|
986
986
|
encoding: "utf8",
|
|
987
987
|
mode: 384
|
|
988
988
|
});
|
|
989
989
|
try {
|
|
990
|
-
await
|
|
990
|
+
await fs65.chmod(filePath, 384);
|
|
991
991
|
} catch {
|
|
992
992
|
}
|
|
993
993
|
}
|
|
994
|
-
var
|
|
994
|
+
var fs65, path85, os52, import_zod16, CompanionPreferenceSchema, init_persist_preference = __esm({
|
|
995
995
|
"src/companion-mode/persist-preference.ts"() {
|
|
996
996
|
"use strict";
|
|
997
|
-
|
|
997
|
+
fs65 = __toESM(require("fs/promises")), path85 = __toESM(require("path")), os52 = __toESM(require("os")), import_zod16 = require("zod");
|
|
998
998
|
init_logger2();
|
|
999
999
|
CompanionPreferenceSchema = import_zod16.z.object({
|
|
1000
1000
|
lastAgent: import_zod16.z.union([
|
|
@@ -1018,8 +1018,8 @@ CodeVibe \u2014 choose an agent:
|
|
|
1018
1018
|
out.write(` ${marker} [${i + 1}] ${a.kind.padEnd(8)} ${a.binPath}
|
|
1019
1019
|
`);
|
|
1020
1020
|
}); ; ) {
|
|
1021
|
-
let trimmed = (await new Promise((
|
|
1022
|
-
rl.question(`Agent [1-${args.healthy.length}] (default ${args.defaultIndex + 1}): `,
|
|
1021
|
+
let trimmed = (await new Promise((resolve29) => {
|
|
1022
|
+
rl.question(`Agent [1-${args.healthy.length}] (default ${args.defaultIndex + 1}): `, resolve29);
|
|
1023
1023
|
})).trim();
|
|
1024
1024
|
if (trimmed === "") return args.healthy[args.defaultIndex];
|
|
1025
1025
|
let n = Number.parseInt(trimmed, 10);
|
|
@@ -1059,13 +1059,13 @@ function isContainedPath(parent, candidate) {
|
|
|
1059
1059
|
}
|
|
1060
1060
|
function resolveDeclaredCompanionLauncher(packageJsonPath) {
|
|
1061
1061
|
try {
|
|
1062
|
-
let packageRoot =
|
|
1063
|
-
|
|
1062
|
+
let packageRoot = fs66.realpathSync(path86.dirname(packageJsonPath)), declared = JSON.parse(
|
|
1063
|
+
fs66.readFileSync(packageJsonPath, "utf8")
|
|
1064
1064
|
).codevibe?.companionLauncher;
|
|
1065
1065
|
if (typeof declared != "string" || declared.trim().length === 0)
|
|
1066
1066
|
return null;
|
|
1067
|
-
let launcherPath =
|
|
1068
|
-
return !isContainedPath(packageRoot, launcherPath) || !
|
|
1067
|
+
let launcherPath = fs66.realpathSync(path86.resolve(packageRoot, declared));
|
|
1068
|
+
return !isContainedPath(packageRoot, launcherPath) || !fs66.statSync(launcherPath).isFile() ? null : (fs66.accessSync(launcherPath, fs66.constants.X_OK), launcherPath);
|
|
1069
1069
|
} catch {
|
|
1070
1070
|
return null;
|
|
1071
1071
|
}
|
|
@@ -1175,10 +1175,10 @@ async function runCompanionMode(args) {
|
|
|
1175
1175
|
process.kill(process.pid, signal);
|
|
1176
1176
|
}))(child.signal), 1) : child.status ?? 1;
|
|
1177
1177
|
}
|
|
1178
|
-
var import_child_process10, import_module, path86,
|
|
1178
|
+
var import_child_process10, import_module, path86, fs66, NoAgentInstalledError, COMPANION_PLUGIN, ACTIVE_COMPANION_AGENTS, ACTIVATION_AGENT, init_companion_mode = __esm({
|
|
1179
1179
|
"src/companion-mode/index.ts"() {
|
|
1180
1180
|
"use strict";
|
|
1181
|
-
import_child_process10 = require("child_process"), import_module = require("module"), path86 = __toESM(require("path")),
|
|
1181
|
+
import_child_process10 = require("child_process"), import_module = require("module"), path86 = __toESM(require("path")), fs66 = __toESM(require("fs"));
|
|
1182
1182
|
init_env_scrub();
|
|
1183
1183
|
init_logger2();
|
|
1184
1184
|
init_detect_agents();
|
|
@@ -1702,7 +1702,14 @@ function getConfig() {
|
|
|
1702
1702
|
// src/credential-broker/oauth-account-lock.ts
|
|
1703
1703
|
var import_node_fs = require("node:fs"), os4 = __toESM(require("node:os")), path3 = __toESM(require("node:path")), import_node_crypto = require("node:crypto");
|
|
1704
1704
|
init_logger2();
|
|
1705
|
-
var
|
|
1705
|
+
var LocalLockBusyError = class extends Error {
|
|
1706
|
+
constructor(diagnostic) {
|
|
1707
|
+
super(`[oauth-account-lock] timed out acquiring OAuth-account lock after ${diagnostic.waitMs}ms (holder not reclaimable) ${JSON.stringify(diagnostic)}`);
|
|
1708
|
+
this.diagnostic = diagnostic;
|
|
1709
|
+
this.code = "LOCAL_LOCK_BUSY";
|
|
1710
|
+
this.name = "LocalLockBusyError";
|
|
1711
|
+
}
|
|
1712
|
+
}, DEFAULT_TTL_MS = 3e4, DEFAULT_HEARTBEAT_MS = 5e3, DEFAULT_MAX_WAIT_MS = 6e4, DEFAULT_BACKOFF_MS = 25;
|
|
1706
1713
|
function errCode(err) {
|
|
1707
1714
|
return err?.code;
|
|
1708
1715
|
}
|
|
@@ -1719,7 +1726,7 @@ function defaultIsProcessAlive(selfHost) {
|
|
|
1719
1726
|
}
|
|
1720
1727
|
var OAuthAccountLock = class {
|
|
1721
1728
|
constructor(opts) {
|
|
1722
|
-
this.lockDir = opts.lockDir, this.requireRemovalOnRelease = opts.requireRemovalOnRelease === !0, this.ownerFile = path3.join(this.lockDir, "owner.json"), this.reclaimGuardDir = `${this.lockDir}.reclaim`, this.ttlMs = opts.ttlMs ?? DEFAULT_TTL_MS, this.heartbeatMs = opts.heartbeatMs ?? DEFAULT_HEARTBEAT_MS, this.maxWaitMs = opts.maxWaitMs ?? DEFAULT_MAX_WAIT_MS, this.ownerlessGraceMs = opts.ownerlessGraceMs ?? this.ttlMs * 2, this.backoffMs = opts.backoffMs ?? DEFAULT_BACKOFF_MS, this.now = opts.now ?? Date.now, this.delayFn = opts.delay ?? ((ms) => new Promise((r) => setTimeout(r, ms))), this.pid = opts.pid ?? process.pid, this.hostId = opts.hostId ?? os4.hostname(), this.isProcessAlive = opts.isProcessAlive ?? defaultIsProcessAlive(this.hostId), this.randomId = opts.randomId ?? (() => (0, import_node_crypto.randomUUID)()), this.utimesFn = opts.utimesFn ?? ((dir) => import_node_fs.promises.utimes(dir, /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date())), this.disableAutoHeartbeat = opts.disableAutoHeartbeat ?? !1;
|
|
1729
|
+
this.lockDir = opts.lockDir, this.role = opts.role ?? "oauth-account", this.requireRemovalOnRelease = opts.requireRemovalOnRelease === !0, this.ownerFile = path3.join(this.lockDir, "owner.json"), this.reclaimGuardDir = `${this.lockDir}.reclaim`, this.ttlMs = opts.ttlMs ?? DEFAULT_TTL_MS, this.heartbeatMs = opts.heartbeatMs ?? DEFAULT_HEARTBEAT_MS, this.maxWaitMs = opts.maxWaitMs ?? DEFAULT_MAX_WAIT_MS, this.ownerlessGraceMs = opts.ownerlessGraceMs ?? this.ttlMs * 2, this.backoffMs = opts.backoffMs ?? DEFAULT_BACKOFF_MS, this.now = opts.now ?? Date.now, this.delayFn = opts.delay ?? ((ms) => new Promise((r) => setTimeout(r, ms))), this.pid = opts.pid ?? process.pid, this.hostId = opts.hostId ?? os4.hostname(), this.isProcessAlive = opts.isProcessAlive ?? defaultIsProcessAlive(this.hostId), this.randomId = opts.randomId ?? (() => (0, import_node_crypto.randomUUID)()), this.utimesFn = opts.utimesFn ?? ((dir) => import_node_fs.promises.utimes(dir, /* @__PURE__ */ new Date(), /* @__PURE__ */ new Date())), this.disableAutoHeartbeat = opts.disableAutoHeartbeat ?? !1;
|
|
1723
1730
|
}
|
|
1724
1731
|
/**
|
|
1725
1732
|
* Acquire the lock (bounded by `maxWaitMs`). Resolves a {@link LockHandle} on
|
|
@@ -1746,12 +1753,21 @@ var OAuthAccountLock = class {
|
|
|
1746
1753
|
if (handle) return handle;
|
|
1747
1754
|
}
|
|
1748
1755
|
if (this.now() - start >= this.maxWaitMs)
|
|
1749
|
-
throw
|
|
1750
|
-
`[oauth-account-lock] timed out acquiring OAuth-account lock after ${this.maxWaitMs}ms (holder not reclaimable)`
|
|
1751
|
-
);
|
|
1756
|
+
throw await this.contentionError();
|
|
1752
1757
|
await this.backoff(attempt);
|
|
1753
1758
|
}
|
|
1754
1759
|
}
|
|
1760
|
+
async contentionError() {
|
|
1761
|
+
let snapshot2 = await this.readOwnerState(this.lockDir), owner = snapshot2.kind === "owner" ? snapshot2.owner : null, startedAt = owner ? Date.parse(owner.startedAt) : NaN;
|
|
1762
|
+
return new LocalLockBusyError({
|
|
1763
|
+
role: this.role,
|
|
1764
|
+
lockId: (0, import_node_crypto.createHash)("sha256").update(path3.resolve(this.lockDir)).digest("hex"),
|
|
1765
|
+
holderPid: owner?.pid ?? null,
|
|
1766
|
+
holderState: owner ? this.isProcessAlive(owner.pid, owner.host) : snapshot2.kind,
|
|
1767
|
+
heldMs: Number.isFinite(startedAt) ? Math.max(0, this.now() - startedAt) : null,
|
|
1768
|
+
waitMs: this.maxWaitMs
|
|
1769
|
+
});
|
|
1770
|
+
}
|
|
1755
1771
|
/** Whether the EXISTING lockdir holder is reclaimable (dead), an ownerless strand
|
|
1756
1772
|
* (F6), or must be waited on. */
|
|
1757
1773
|
async classifyExistingHolder() {
|
|
@@ -4362,8 +4378,8 @@ async function settleWithin(p, ms) {
|
|
|
4362
4378
|
try {
|
|
4363
4379
|
return await Promise.race([
|
|
4364
4380
|
p,
|
|
4365
|
-
new Promise((
|
|
4366
|
-
timer = setTimeout(() =>
|
|
4381
|
+
new Promise((resolve29) => {
|
|
4382
|
+
timer = setTimeout(() => resolve29(void 0), Math.max(0, ms));
|
|
4367
4383
|
})
|
|
4368
4384
|
]);
|
|
4369
4385
|
} finally {
|
|
@@ -4432,9 +4448,9 @@ async function classifyGitWorkspace(workspaceRoot, timeoutMs) {
|
|
|
4432
4448
|
}
|
|
4433
4449
|
}
|
|
4434
4450
|
async function probeAdvisoryWorkspaceFingerprint(workspaceRoot, options = {}) {
|
|
4435
|
-
let started = Date.now(), timeoutMs = options.timeoutMs ?? ADVISORY_WALK_FINGERPRINT_TIMEOUT_MS, state = { method: "marker", expired: !1 }, timer, deadlineHit = new Promise((
|
|
4451
|
+
let started = Date.now(), timeoutMs = options.timeoutMs ?? ADVISORY_WALK_FINGERPRINT_TIMEOUT_MS, state = { method: "marker", expired: !1 }, timer, deadlineHit = new Promise((resolve29) => {
|
|
4436
4452
|
timer = setTimeout(() => {
|
|
4437
|
-
state.expired = !0,
|
|
4453
|
+
state.expired = !0, resolve29({ kind: "probe-failed", method: state.method, reason: "timeout", durationMs: Date.now() - started });
|
|
4438
4454
|
}, Math.max(0, timeoutMs));
|
|
4439
4455
|
});
|
|
4440
4456
|
try {
|
|
@@ -6096,8 +6112,8 @@ async function cleanExitFieldsAfterPrime(sessionId, maxWaitMs = PRIME_WAIT_MAX_M
|
|
|
6096
6112
|
let pending2 = pendingPrimes.get(sessionId);
|
|
6097
6113
|
if (pending2) {
|
|
6098
6114
|
let timer;
|
|
6099
|
-
await Promise.race([pending2, new Promise((
|
|
6100
|
-
timer = setTimeout(
|
|
6115
|
+
await Promise.race([pending2, new Promise((resolve29) => {
|
|
6116
|
+
timer = setTimeout(resolve29, maxWaitMs), timer.unref?.();
|
|
6101
6117
|
})]), timer && clearTimeout(timer);
|
|
6102
6118
|
}
|
|
6103
6119
|
return buildCleanExitFields(sessionId);
|
|
@@ -6134,7 +6150,7 @@ async function holdAfterResumeLock(predecessorSessionId, opts = {}) {
|
|
|
6134
6150
|
let write = opts.write ?? ((text2) => process.stdout.write(text2));
|
|
6135
6151
|
write(`CODEVIBE_E2E_HOLD ${predecessorSessionId}
|
|
6136
6152
|
`);
|
|
6137
|
-
let exists = opts.exists ?? import_node_fs2.existsSync, sleep2 = opts.sleep ?? ((ms) => new Promise((
|
|
6153
|
+
let exists = opts.exists ?? import_node_fs2.existsSync, sleep2 = opts.sleep ?? ((ms) => new Promise((resolve29) => setTimeout(resolve29, ms))), now = opts.now ?? Date.now, started = now();
|
|
6138
6154
|
for (; !exists(releaseFile); ) {
|
|
6139
6155
|
if (now() - started >= E2E_HOLD_MAX_MS) {
|
|
6140
6156
|
write(`CODEVIBE_E2E_HOLD_TIMEOUT ${predecessorSessionId}
|
|
@@ -6304,7 +6320,7 @@ function validPid(pid) {
|
|
|
6304
6320
|
return Number.isSafeInteger(pid) && pid > 0;
|
|
6305
6321
|
}
|
|
6306
6322
|
async function boundedExec(command, args) {
|
|
6307
|
-
return new Promise((
|
|
6323
|
+
return new Promise((resolve29) => {
|
|
6308
6324
|
let child;
|
|
6309
6325
|
try {
|
|
6310
6326
|
child = (0, import_node_child_process2.spawn)(command, args, {
|
|
@@ -6313,11 +6329,11 @@ async function boundedExec(command, args) {
|
|
|
6313
6329
|
env: scrubSearchApiKeys({ ...process.env })
|
|
6314
6330
|
});
|
|
6315
6331
|
} catch {
|
|
6316
|
-
|
|
6332
|
+
resolve29(null);
|
|
6317
6333
|
return;
|
|
6318
6334
|
}
|
|
6319
6335
|
let chunks = [], bytes = 0, settled = !1, finish = (value) => {
|
|
6320
|
-
settled || (settled = !0, clearTimeout(timer),
|
|
6336
|
+
settled || (settled = !0, clearTimeout(timer), resolve29(value));
|
|
6321
6337
|
}, timer = setTimeout(() => {
|
|
6322
6338
|
try {
|
|
6323
6339
|
child.kill("SIGKILL");
|
|
@@ -11000,8 +11016,8 @@ var sourceCursorId = (scope, stream) => stableUuid("codevibe-sync-source-cursor-
|
|
|
11000
11016
|
* serializes original callers and restarted owners without holding the
|
|
11001
11017
|
* account store lock across network awaits. Only an exact ACK permits removal.
|
|
11002
11018
|
* Admission closure/PAUSED does not authorize dropping pending control work. */
|
|
11003
|
-
async runPromptResolution(value,
|
|
11004
|
-
if (typeof
|
|
11019
|
+
async runPromptResolution(value, resolve29, options = {}) {
|
|
11020
|
+
if (typeof resolve29 != "function") return invalid7();
|
|
11005
11021
|
let input = snapshotSyncPromptResolution(value), id5 = input.clientOperationId, expected = decodePromptResolution({ schemaVersion: 1, kind: "PROMPT_RESOLUTION", operationId: id5, input }, this.options.userId, invalid7);
|
|
11006
11022
|
if (!this.matchesPromptResolutionScope(input)) return invalid7();
|
|
11007
11023
|
this.options.assertAccount(), await this.ensureDirectory();
|
|
@@ -11021,7 +11037,7 @@ var sourceCursorId = (scope, stream) => stableUuid("codevibe-sync-source-cursor-
|
|
|
11021
11037
|
let sealed = this.seal(expected, key);
|
|
11022
11038
|
return await this.checkCapacity(Buffer.byteLength(sealed), id5 + ".resolution"), await this.write(id5, sealed, ".resolution"), expected;
|
|
11023
11039
|
});
|
|
11024
|
-
return await fence(), row3 ? await
|
|
11040
|
+
return await fence(), row3 ? await resolve29(row3.input, fence) !== !0 ? (await fence(), !1) : (await fence(), await this.withStore(async (key) => {
|
|
11025
11041
|
await this.readValue(id5, key, ".resolution", validate) && (await fence(), await import_node_fs5.promises.unlink(this.file(id5, ".resolution")), await this.syncDirectory(this.directory));
|
|
11026
11042
|
}), await fence(), !0) : !0;
|
|
11027
11043
|
} finally {
|
|
@@ -11749,6 +11765,7 @@ var sourceCursorId = (scope, stream) => stableUuid("codevibe-sync-source-cursor-
|
|
|
11749
11765
|
lockDir: path19.join(this.directory, name),
|
|
11750
11766
|
ownerlessGraceMs: 1 / 0,
|
|
11751
11767
|
maxWaitMs: 2e3,
|
|
11768
|
+
role: name === "store.lockdir" ? "sync-journal-store" : "sync-journal",
|
|
11752
11769
|
requireRemovalOnRelease
|
|
11753
11770
|
});
|
|
11754
11771
|
}
|
|
@@ -11967,8 +11984,8 @@ var count3 = import_zod9.z.string().regex(/^(0|[1-9][0-9]{0,18})$/).refine((s) =
|
|
|
11967
11984
|
if (this.starting) return this.starting;
|
|
11968
11985
|
if (this.phase !== "new") return Promise.reject(failure());
|
|
11969
11986
|
this.phase = "opening";
|
|
11970
|
-
let ready = new Promise((
|
|
11971
|
-
this.resolveReady =
|
|
11987
|
+
let ready = new Promise((resolve29, reject) => {
|
|
11988
|
+
this.resolveReady = resolve29, this.rejectReady = reject;
|
|
11972
11989
|
});
|
|
11973
11990
|
return ready.catch(() => {
|
|
11974
11991
|
}), this.starting = Promise.resolve().then(async () => {
|
|
@@ -12226,9 +12243,9 @@ var count3 = import_zod9.z.string().regex(/^(0|[1-9][0-9]{0,18})$/).refine((s) =
|
|
|
12226
12243
|
this.phase = "closed", this.abort.abort(failure()), this.rejectReady?.(failure()), clearTimeout(this.controlTimer), clearTimeout(this.pongTimer), clearTimeout(this.heartbeatTimer), clearTimeout(this.recoveryTimer), clearInterval(this.pingTimer);
|
|
12227
12244
|
let ws = this.ws;
|
|
12228
12245
|
this.ws = void 0;
|
|
12229
|
-
let socketClosed = new Promise((
|
|
12246
|
+
let socketClosed = new Promise((resolve29) => {
|
|
12230
12247
|
if (!ws || ws.readyState === import_ws.default.CLOSED) {
|
|
12231
|
-
|
|
12248
|
+
resolve29();
|
|
12232
12249
|
return;
|
|
12233
12250
|
}
|
|
12234
12251
|
ws.removeAllListeners(), ws.on("error", () => {
|
|
@@ -12237,7 +12254,7 @@ var count3 = import_zod9.z.string().regex(/^(0|[1-9][0-9]{0,18})$/).refine((s) =
|
|
|
12237
12254
|
ws.terminate();
|
|
12238
12255
|
}, 5e3);
|
|
12239
12256
|
timer.unref?.(), ws.once("close", () => {
|
|
12240
|
-
clearTimeout(timer),
|
|
12257
|
+
clearTimeout(timer), resolve29();
|
|
12241
12258
|
});
|
|
12242
12259
|
try {
|
|
12243
12260
|
ws.close(1e3);
|
|
@@ -12992,6 +13009,7 @@ var RESERVED_STATE_FILES = /* @__PURE__ */ new Set(["ledger.json", "legacy-owned
|
|
|
12992
13009
|
if (!identity.isDirectory() || identity.isSymbolicLink() || typeof process.getuid == "function" && identity.uid !== process.getuid()) throw new Error("Tool sync directory invalid");
|
|
12993
13010
|
let owner = await createOAuthAccountLock({
|
|
12994
13011
|
lockDir: path22.join(dir, ".sync-recovery.lockdir"),
|
|
13012
|
+
role: "tool-sync-recovery",
|
|
12995
13013
|
ownerlessGraceMs: 1 / 0,
|
|
12996
13014
|
maxWaitMs: 2e3,
|
|
12997
13015
|
requireRemovalOnRelease: !0
|
|
@@ -13453,8 +13471,8 @@ var DecisionAttemptReceiptStore = class _DecisionAttemptReceiptStore {
|
|
|
13453
13471
|
return path23.join(path23.resolve(this.rootDir), opaqueSegment(sessionId));
|
|
13454
13472
|
}
|
|
13455
13473
|
async withSessionLock(sessionId, operation) {
|
|
13456
|
-
let key = this.sessionQueueKey(sessionId), prior = _DecisionAttemptReceiptStore.sessionQueues.get(key) ?? Promise.resolve(), release, gate = new Promise((
|
|
13457
|
-
release =
|
|
13474
|
+
let key = this.sessionQueueKey(sessionId), prior = _DecisionAttemptReceiptStore.sessionQueues.get(key) ?? Promise.resolve(), release, gate = new Promise((resolve29) => {
|
|
13475
|
+
release = resolve29;
|
|
13458
13476
|
}), tail = prior.then(() => gate);
|
|
13459
13477
|
_DecisionAttemptReceiptStore.sessionQueues.set(key, tail), await prior;
|
|
13460
13478
|
try {
|
|
@@ -14206,9 +14224,9 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14206
14224
|
if (signal?.aborted) throw _AppSyncClient.abortReason(signal);
|
|
14207
14225
|
}
|
|
14208
14226
|
static async waitForSyncStateRetry(delayMs, signal) {
|
|
14209
|
-
_AppSyncClient.throwIfAborted(signal), await new Promise((
|
|
14227
|
+
_AppSyncClient.throwIfAborted(signal), await new Promise((resolve29, reject) => {
|
|
14210
14228
|
let timer = setTimeout(() => {
|
|
14211
|
-
signal?.removeEventListener("abort", onAbort),
|
|
14229
|
+
signal?.removeEventListener("abort", onAbort), resolve29();
|
|
14212
14230
|
}, delayMs), onAbort = () => {
|
|
14213
14231
|
clearTimeout(timer), signal?.removeEventListener("abort", onAbort), reject(_AppSyncClient.abortReason(signal));
|
|
14214
14232
|
};
|
|
@@ -14256,7 +14274,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14256
14274
|
* the operation itself settles.
|
|
14257
14275
|
*/
|
|
14258
14276
|
static awaitSharedFlightForCaller(flight, signal) {
|
|
14259
|
-
return signal ? (_AppSyncClient.throwIfAborted(signal), new Promise((
|
|
14277
|
+
return signal ? (_AppSyncClient.throwIfAborted(signal), new Promise((resolve29, reject) => {
|
|
14260
14278
|
let settled = !1, finish = (operation) => {
|
|
14261
14279
|
settled || (settled = !0, signal.removeEventListener("abort", onAbort), operation());
|
|
14262
14280
|
}, onAbort = () => {
|
|
@@ -14267,7 +14285,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14267
14285
|
return;
|
|
14268
14286
|
}
|
|
14269
14287
|
flight.then(
|
|
14270
|
-
(value) => finish(() =>
|
|
14288
|
+
(value) => finish(() => resolve29(value)),
|
|
14271
14289
|
(error) => finish(() => reject(error))
|
|
14272
14290
|
);
|
|
14273
14291
|
})) : flight;
|
|
@@ -14605,7 +14623,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14605
14623
|
owned2.promise.then(settled, settled);
|
|
14606
14624
|
}
|
|
14607
14625
|
let owned = flight;
|
|
14608
|
-
return owned.waiters++, new Promise((
|
|
14626
|
+
return owned.waiters++, new Promise((resolve29, reject) => {
|
|
14609
14627
|
let finished = !1, finish = (error) => {
|
|
14610
14628
|
if (!finished) {
|
|
14611
14629
|
finished = !0, signal?.removeEventListener("abort", onAbort), --owned.waiters === 0 && !owned.settled && (this.syncStateRead === owned && (this.syncStateRead = null), owned.controller.abort(new Error("Sync state read has no callers")));
|
|
@@ -14613,7 +14631,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14613
14631
|
if (check(), error !== void 0) throw error;
|
|
14614
14632
|
let state = this.companionSyncStatusSnapshot(userId);
|
|
14615
14633
|
if (!state) throw new SyncEventClientError("INVALID_SYNC_STATE");
|
|
14616
|
-
|
|
14634
|
+
resolve29(state);
|
|
14617
14635
|
} catch (failure2) {
|
|
14618
14636
|
reject(failure2);
|
|
14619
14637
|
}
|
|
@@ -15310,8 +15328,8 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
15310
15328
|
* its existing domain authority to obtain a validated resolution ACK. This
|
|
15311
15329
|
* method grants no backend authority and creates no new visible occurrence.
|
|
15312
15330
|
* False, thrown or account-switched acknowledgements retain the source. */
|
|
15313
|
-
resolvePromptPublication(value,
|
|
15314
|
-
if (!value || typeof value != "object" || Array.isArray(value) || typeof
|
|
15331
|
+
resolvePromptPublication(value, resolve29, options = {}) {
|
|
15332
|
+
if (!value || typeof value != "object" || Array.isArray(value) || typeof resolve29 != "function" || Object.keys(value).some((field2) => !["sessionId", "promptId"].includes(field2)) || typeof value.sessionId != "string" || !/^[A-Za-z0-9_-]{1,256}$/.test(value.sessionId) || typeof value.promptId != "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(value.promptId))
|
|
15315
15333
|
return Promise.reject(new SyncEventClientError("INVALID_SYNC_INPUT"));
|
|
15316
15334
|
let input = { ...value }, { root, signal } = options, userId = this.getCurrentUserId(), check = () => {
|
|
15317
15335
|
this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal);
|
|
@@ -15322,7 +15340,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
15322
15340
|
let journals = records.map((scope) => this.desktopSyncWriter({ root, sessionScope: scope }).promptPublication(input.promptId));
|
|
15323
15341
|
for (let journal of journals)
|
|
15324
15342
|
await journal.settle(signal), check();
|
|
15325
|
-
let acknowledged = await
|
|
15343
|
+
let acknowledged = await resolve29(records.length > 0);
|
|
15326
15344
|
if (check(), acknowledged !== !0) return !1;
|
|
15327
15345
|
for (let journal of journals)
|
|
15328
15346
|
await journal.close(), check();
|
|
@@ -15742,16 +15760,16 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
15742
15760
|
/**
|
|
15743
15761
|
* Update a session
|
|
15744
15762
|
*/
|
|
15745
|
-
async updateSession(input) {
|
|
15763
|
+
async updateSession(input, options = {}) {
|
|
15746
15764
|
if (input.status === void 0)
|
|
15747
|
-
return this.doUpdateSession(input);
|
|
15748
|
-
let
|
|
15749
|
-
}).then(() => this.doUpdateSession(input));
|
|
15765
|
+
return this.doUpdateSession(input, options.expectedUserId);
|
|
15766
|
+
let prior = this.statusWriteChains.get(input.sessionId) ?? Promise.resolve(), expectedUserId = options.expectedUserId, next = prior.catch(() => {
|
|
15767
|
+
}).then(() => this.doUpdateSession(input, expectedUserId));
|
|
15750
15768
|
return this.statusWriteChains.set(input.sessionId, next.catch(() => {
|
|
15751
15769
|
})), next;
|
|
15752
15770
|
}
|
|
15753
|
-
async doUpdateSession(input) {
|
|
15754
|
-
input.status === "INACTIVE" /* INACTIVE */ && (this.syncRetiringSessions.add(input.sessionId), this.cleanupSubscription(input.sessionId), await Promise.all([
|
|
15771
|
+
async doUpdateSession(input, expectedUserId) {
|
|
15772
|
+
expectedUserId !== void 0 && this.assertSyncAccount(expectedUserId), input.status === "INACTIVE" /* INACTIVE */ && (this.syncRetiringSessions.add(input.sessionId), this.cleanupSubscription(input.sessionId), await Promise.all([
|
|
15755
15773
|
this.joinSyncSubscriptionClosures(input.sessionId),
|
|
15756
15774
|
...[...this.syncReadOwners.get(input.sessionId) ?? []].map((reader) => reader.close())
|
|
15757
15775
|
]));
|
|
@@ -15760,12 +15778,12 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
15760
15778
|
metadata: input.metadata ? JSON.stringify(input.metadata) : void 0
|
|
15761
15779
|
}, response;
|
|
15762
15780
|
try {
|
|
15763
|
-
response = await this.graphqlRequest(mutations.updateSession, { input: preparedInput });
|
|
15781
|
+
response = await this.graphqlRequest(mutations.updateSession, { input: preparedInput }, !1, void 0, expectedUserId);
|
|
15764
15782
|
} catch (error) {
|
|
15765
15783
|
if (!hasCleanExitFields(preparedInput) || !isUnknownCleanExitFieldError(error)) throw error;
|
|
15766
15784
|
logger.warn("[AppSyncClient] Server rejected the P61 clean-exit fields; retrying without them", {
|
|
15767
15785
|
sessionId: input.sessionId
|
|
15768
|
-
}), response = await this.graphqlRequest(mutations.updateSession, { input: withoutCleanExitFields(preparedInput) });
|
|
15786
|
+
}), response = await this.graphqlRequest(mutations.updateSession, { input: withoutCleanExitFields(preparedInput) }, !1, void 0, expectedUserId);
|
|
15769
15787
|
}
|
|
15770
15788
|
logger.debug("[AppSyncClient] Session updated", { sessionId: response.data.updateSession.sessionId });
|
|
15771
15789
|
let session2 = response.data.updateSession;
|
|
@@ -19326,7 +19344,7 @@ async function prepareSessionEncryption(sessionId, appSyncClient, logger2) {
|
|
|
19326
19344
|
sessionId,
|
|
19327
19345
|
attempt: attempt + 1,
|
|
19328
19346
|
delayMs
|
|
19329
|
-
}), await new Promise((
|
|
19347
|
+
}), await new Promise((resolve29) => setTimeout(resolve29, delayMs));
|
|
19330
19348
|
}
|
|
19331
19349
|
}
|
|
19332
19350
|
if (serviceDeviceKeys.length === 0)
|
|
@@ -20988,8 +21006,8 @@ function finishedResumeMessage(predecessorSessionId, successorSessionId) {
|
|
|
20988
21006
|
async function publishThenRetire(args) {
|
|
20989
21007
|
let { deps } = args, preview = args.encryptedLastPrompt ? { encryptedLastPrompt: args.encryptedLastPrompt } : {}, note = { successorSessionId: args.successorSessionId, predecessorSessionId: args.predecessorSessionId, marker: args.marker, ...preview };
|
|
20990
21008
|
try {
|
|
20991
|
-
let timer, drained = deps.drain(args.successorSessionId).then(() => !0, () => !1), timedOut = new Promise((
|
|
20992
|
-
timer = setTimeout(() =>
|
|
21009
|
+
let timer, drained = deps.drain(args.successorSessionId).then(() => !0, () => !1), timedOut = new Promise((resolve29) => {
|
|
21010
|
+
timer = setTimeout(() => resolve29(!1), deps.timeoutMs ?? PUBLISH_DRAIN_TIMEOUT_MS), timer.unref?.();
|
|
20993
21011
|
}), ok = await Promise.race([drained, timedOut]);
|
|
20994
21012
|
return timer && clearTimeout(timer), ok ? (await deps.updateSession({
|
|
20995
21013
|
sessionId: args.successorSessionId,
|
|
@@ -21500,22 +21518,22 @@ function ResumeChoice(props) {
|
|
|
21500
21518
|
}
|
|
21501
21519
|
async function runResumePicker(rows) {
|
|
21502
21520
|
let { ink } = getInkRuntime();
|
|
21503
|
-
return new Promise((
|
|
21521
|
+
return new Promise((resolve29) => {
|
|
21504
21522
|
let instance = null, done = (value) => {
|
|
21505
|
-
instance?.unmount(),
|
|
21523
|
+
instance?.unmount(), resolve29(value);
|
|
21506
21524
|
};
|
|
21507
21525
|
instance = ink.render(React.createElement(ResumePicker, { rows, onSelect: (id5) => done(id5), onCancel: () => done(null) }));
|
|
21508
21526
|
});
|
|
21509
21527
|
}
|
|
21510
21528
|
async function runResumeChoice(prompt, continueLabel) {
|
|
21511
21529
|
let { ink } = getInkRuntime();
|
|
21512
|
-
return new Promise((
|
|
21530
|
+
return new Promise((resolve29) => {
|
|
21513
21531
|
let instance = null;
|
|
21514
21532
|
instance = ink.render(React.createElement(ResumeChoice, {
|
|
21515
21533
|
prompt,
|
|
21516
21534
|
...continueLabel ? { continueLabel } : {},
|
|
21517
21535
|
onChoose: (value) => {
|
|
21518
|
-
instance?.unmount(),
|
|
21536
|
+
instance?.unmount(), resolve29(value);
|
|
21519
21537
|
}
|
|
21520
21538
|
}));
|
|
21521
21539
|
});
|
|
@@ -21626,8 +21644,8 @@ CodeVibe \u2014 choose mode (${tier} tier):
|
|
|
21626
21644
|
`), process.stdout.write(` \x1B[36m[1]\x1B[0m \x1B[1mCompanion\x1B[0m \x1B[2m(route to local agent wrapper)\x1B[0m
|
|
21627
21645
|
`), process.stdout.write(` \x1B[35m[2]\x1B[0m \x1B[1mOrchestration\x1B[0m \x1B[2m(CodeVibe-owned shell)\x1B[0m
|
|
21628
21646
|
`)); ; ) {
|
|
21629
|
-
let promptStr = plain6 ? "Mode [1/2]: " : "\x1B[36mMode [1/2]: \x1B[0m", trimmed = (await new Promise((
|
|
21630
|
-
rl.question(promptStr,
|
|
21647
|
+
let promptStr = plain6 ? "Mode [1/2]: " : "\x1B[36mMode [1/2]: \x1B[0m", trimmed = (await new Promise((resolve29) => {
|
|
21648
|
+
rl.question(promptStr, resolve29);
|
|
21631
21649
|
})).trim();
|
|
21632
21650
|
if (trimmed === "1" || trimmed.toLowerCase() === "companion") return "companion";
|
|
21633
21651
|
if (trimmed === "2" || trimmed.toLowerCase() === "orchestration") return "orchestration";
|
|
@@ -21808,7 +21826,7 @@ async function clearRetiredPlannerCache(userId, cacheRoot = process.env.CODEVIBE
|
|
|
21808
21826
|
}
|
|
21809
21827
|
|
|
21810
21828
|
// src/orchestration-shell/index.ts
|
|
21811
|
-
var path79 = __toESM(require("path")), os48 = __toESM(require("os")), import_promises = require("node:fs/promises"), import_node_fs37 = require("node:fs"), import_node_child_process10 = require("node:child_process"), import_node_util3 = require("node:util"), import_node_async_hooks = require("node:async_hooks");
|
|
21829
|
+
var path79 = __toESM(require("path")), os48 = __toESM(require("os")), import_promises = require("node:fs/promises"), fs59 = __toESM(require("node:fs")), import_node_fs37 = require("node:fs"), import_node_child_process10 = require("node:child_process"), import_node_util3 = require("node:util"), import_node_async_hooks = require("node:async_hooks");
|
|
21812
21830
|
|
|
21813
21831
|
// src/orchestration-shell/web/sanitize.ts
|
|
21814
21832
|
function sanitizeForTerminal(input) {
|
|
@@ -22505,7 +22523,7 @@ function requestOllamaJson(config, pathname, body, opts) {
|
|
|
22505
22523
|
let err = new Error("Ollama request aborted by signal");
|
|
22506
22524
|
return err.name = "AbortError", Promise.reject(err);
|
|
22507
22525
|
}
|
|
22508
|
-
return new Promise((
|
|
22526
|
+
return new Promise((resolve29, reject) => {
|
|
22509
22527
|
let settled = !1, responseBytes = 0, responseBody = "", finish = (fn) => {
|
|
22510
22528
|
settled || (settled = !0, clearTimeout(timeout), fn());
|
|
22511
22529
|
}, req = chooseHttpClient(url).request(
|
|
@@ -22532,7 +22550,7 @@ function requestOllamaJson(config, pathname, body, opts) {
|
|
|
22532
22550
|
}
|
|
22533
22551
|
responseBody += decoder.write(chunk);
|
|
22534
22552
|
}), res.on("end", () => {
|
|
22535
|
-
responseBody += decoder.end(), finish(() =>
|
|
22553
|
+
responseBody += decoder.end(), finish(() => resolve29(responseBody));
|
|
22536
22554
|
});
|
|
22537
22555
|
}
|
|
22538
22556
|
), timeout = setTimeout(() => {
|
|
@@ -22672,7 +22690,7 @@ function requestOllamaGenerateStream(config, promptText, opts) {
|
|
|
22672
22690
|
num_ctx: numCtx
|
|
22673
22691
|
}
|
|
22674
22692
|
}), url = new URL("/api/generate", config.host), timeoutMs = opts?.timeoutMs ?? config.timeoutMs;
|
|
22675
|
-
return opts?.signal?.aborted ? Promise.reject(new Error("Ollama generation aborted by signal")) : new Promise((
|
|
22693
|
+
return opts?.signal?.aborted ? Promise.reject(new Error("Ollama generation aborted by signal")) : new Promise((resolve29, reject) => {
|
|
22676
22694
|
let settled = !1, responseBytes = 0, buffer = "", decoder = new import_string_decoder.StringDecoder("utf8"), out = { text: "" }, emptyRun = 0, chunks = 0, sawDone = !1, lastDone, ndjson = !1, timeout = null, idleTimer = null, activeRes = null, clearIdle = () => {
|
|
22677
22695
|
idleTimer && (clearTimeout(idleTimer), idleTimer = null);
|
|
22678
22696
|
}, finish = (fn) => {
|
|
@@ -22696,7 +22714,7 @@ function requestOllamaGenerateStream(config, promptText, opts) {
|
|
|
22696
22714
|
visibleChars: out.text.length,
|
|
22697
22715
|
idleMs: streamIdleCutoffMs,
|
|
22698
22716
|
chunks
|
|
22699
|
-
}), finish(() =>
|
|
22717
|
+
}), finish(() => resolve29(out)), activeRes?.destroy());
|
|
22700
22718
|
}, streamIdleCutoffMs);
|
|
22701
22719
|
}, handleLine = (line, res) => {
|
|
22702
22720
|
if (settled) return;
|
|
@@ -22729,14 +22747,14 @@ function requestOllamaGenerateStream(config, promptText, opts) {
|
|
|
22729
22747
|
return;
|
|
22730
22748
|
}
|
|
22731
22749
|
if (lastDone = chunk.done, chunk.done === !0) {
|
|
22732
|
-
sawDone = !0, finish(() =>
|
|
22750
|
+
sawDone = !0, finish(() => resolve29(out));
|
|
22733
22751
|
return;
|
|
22734
22752
|
}
|
|
22735
22753
|
out.text.length > 0 && armIdle(), emptyRun = piece.length === 0 ? emptyRun + 1 : 0, emptyRun >= EMPTY_TOKEN_WATCHDOG && (out.cutOff = "empty-token-loop", logger.warn("[ollama] generation cut off \u2014 empty-token loop", {
|
|
22736
22754
|
visibleChars: out.text.length,
|
|
22737
22755
|
emptyRun,
|
|
22738
22756
|
chunks
|
|
22739
|
-
}), finish(() =>
|
|
22757
|
+
}), finish(() => resolve29(out)), res.destroy());
|
|
22740
22758
|
}, req = chooseHttpClient(url).request(
|
|
22741
22759
|
url,
|
|
22742
22760
|
{
|
|
@@ -22778,7 +22796,7 @@ function requestOllamaGenerateStream(config, promptText, opts) {
|
|
|
22778
22796
|
);
|
|
22779
22797
|
return;
|
|
22780
22798
|
}
|
|
22781
|
-
finish(() =>
|
|
22799
|
+
finish(() => resolve29(out));
|
|
22782
22800
|
}
|
|
22783
22801
|
}));
|
|
22784
22802
|
}
|
|
@@ -22808,7 +22826,7 @@ function describeRecordError(value) {
|
|
|
22808
22826
|
function requestOllamaPull(config, onProgress = () => {
|
|
22809
22827
|
}, options) {
|
|
22810
22828
|
let url = new URL("/api/pull", config.host), body = JSON.stringify({ name: config.model, stream: !0 }), stallTimeoutMs = typeof options?.stallTimeoutMs == "number" && options.stallTimeoutMs > 0 ? options.stallTimeoutMs : PULL_STALL_TIMEOUT_MS;
|
|
22811
|
-
return new Promise((
|
|
22829
|
+
return new Promise((resolve29, reject) => {
|
|
22812
22830
|
let settled = !1, buffer = "", pullDecoder = new import_string_decoder.StringDecoder("utf8"), stallTimer = null, clearStall = () => {
|
|
22813
22831
|
stallTimer && (clearTimeout(stallTimer), stallTimer = null);
|
|
22814
22832
|
}, finish = (fn) => {
|
|
@@ -22850,7 +22868,7 @@ function requestOllamaPull(config, onProgress = () => {
|
|
|
22850
22868
|
status,
|
|
22851
22869
|
completed: typeof parsed.completed == "number" ? parsed.completed : void 0,
|
|
22852
22870
|
total: typeof parsed.total == "number" ? parsed.total : void 0
|
|
22853
|
-
}), status === "success" && finish(() =>
|
|
22871
|
+
}), status === "success" && finish(() => resolve29()));
|
|
22854
22872
|
}, req = chooseHttpClient(url).request(
|
|
22855
22873
|
url,
|
|
22856
22874
|
{
|
|
@@ -22887,7 +22905,7 @@ function requestOllamaPull(config, onProgress = () => {
|
|
|
22887
22905
|
}
|
|
22888
22906
|
buffer.length > MAX_PULL_LINE_BYTES && (finish(() => reject(new Error("Ollama pull response line exceeded the size limit"))), res.destroy());
|
|
22889
22907
|
})), res.on("end", () => guarded(() => {
|
|
22890
|
-
settled || (buffer += pullDecoder.end(), handleLine(buffer), buffer = "", finish(() =>
|
|
22908
|
+
settled || (buffer += pullDecoder.end(), handleLine(buffer), buffer = "", finish(() => resolve29()));
|
|
22891
22909
|
}));
|
|
22892
22910
|
}
|
|
22893
22911
|
);
|
|
@@ -24156,8 +24174,8 @@ function createBoundedSharedShutdownOperation(options) {
|
|
|
24156
24174
|
let operation = null, normalWait = null, signalWait = null, getOperation = () => {
|
|
24157
24175
|
if (!operation) {
|
|
24158
24176
|
let resolveOperation, rejectOperation;
|
|
24159
|
-
operation = new Promise((
|
|
24160
|
-
resolveOperation =
|
|
24177
|
+
operation = new Promise((resolve29, reject) => {
|
|
24178
|
+
resolveOperation = resolve29, rejectOperation = reject;
|
|
24161
24179
|
});
|
|
24162
24180
|
try {
|
|
24163
24181
|
Promise.resolve(options.start()).then(resolveOperation, rejectOperation);
|
|
@@ -24171,8 +24189,8 @@ function createBoundedSharedShutdownOperation(options) {
|
|
|
24171
24189
|
try {
|
|
24172
24190
|
if (await Promise.race([
|
|
24173
24191
|
getOperation().then(() => "settled"),
|
|
24174
|
-
new Promise((
|
|
24175
|
-
timer = setTimeout(() =>
|
|
24192
|
+
new Promise((resolve29) => {
|
|
24193
|
+
timer = setTimeout(() => resolve29("timeout"), timeoutMs), timer.unref?.();
|
|
24176
24194
|
})
|
|
24177
24195
|
]) === "timeout") {
|
|
24178
24196
|
options.onTimeout?.(deadlineClass, timeoutMs);
|
|
@@ -24286,8 +24304,8 @@ function createExplicitTtyExitCoordinator(deps) {
|
|
|
24286
24304
|
let started = !1, resolveCompletion = () => {
|
|
24287
24305
|
};
|
|
24288
24306
|
return {
|
|
24289
|
-
completion: new Promise((
|
|
24290
|
-
resolveCompletion =
|
|
24307
|
+
completion: new Promise((resolve29) => {
|
|
24308
|
+
resolveCompletion = resolve29;
|
|
24291
24309
|
}),
|
|
24292
24310
|
start: () => {
|
|
24293
24311
|
started || (started = !0, Promise.resolve().then(deps.runTeardown).catch(() => {
|
|
@@ -28703,8 +28721,8 @@ function spawnIsolatedHelper(command, args, options) {
|
|
|
28703
28721
|
}), child;
|
|
28704
28722
|
}
|
|
28705
28723
|
function observeChildClose(child) {
|
|
28706
|
-
return new Promise((
|
|
28707
|
-
child.once("error", reject), child.once("close",
|
|
28724
|
+
return new Promise((resolve29, reject) => {
|
|
28725
|
+
child.once("error", reject), child.once("close", resolve29);
|
|
28708
28726
|
});
|
|
28709
28727
|
}
|
|
28710
28728
|
async function withHelperDeadline(work, timeoutMs, label, signal) {
|
|
@@ -28735,8 +28753,8 @@ async function waitBounded(work, timeoutMs) {
|
|
|
28735
28753
|
work.then(() => {
|
|
28736
28754
|
}, () => {
|
|
28737
28755
|
}),
|
|
28738
|
-
new Promise((
|
|
28739
|
-
timer = setTimeout(
|
|
28756
|
+
new Promise((resolve29) => {
|
|
28757
|
+
timer = setTimeout(resolve29, timeoutMs), timer.unref?.();
|
|
28740
28758
|
})
|
|
28741
28759
|
]);
|
|
28742
28760
|
} finally {
|
|
@@ -28975,7 +28993,7 @@ async function ensureDurableDirectoryTree(target2, opts = {}) {
|
|
|
28975
28993
|
process.env[key] !== void 0 && (env[key] = process.env[key]);
|
|
28976
28994
|
let child, closed4;
|
|
28977
28995
|
try {
|
|
28978
|
-
let resultPromise = new Promise((
|
|
28996
|
+
let resultPromise = new Promise((resolve29, reject) => {
|
|
28979
28997
|
try {
|
|
28980
28998
|
child = spawnIsolatedHelper(process.execPath, ["-e", DURABLE_DIRECTORY_BOOTSTRAP], {
|
|
28981
28999
|
env,
|
|
@@ -29002,7 +29020,7 @@ async function ensureDurableDirectoryTree(target2, opts = {}) {
|
|
|
29002
29020
|
try {
|
|
29003
29021
|
let value = JSON.parse(Buffer.concat(chunks, bytes).toString("utf8"));
|
|
29004
29022
|
if (typeof value.canonicalPath != "string" || typeof value.dev != "string" || typeof value.ino != "string" || typeof value.birthtimeNs != "string" || !/^\d+$/.test(value.birthtimeNs) || typeof value.mtimeMs != "number" || typeof value.created != "boolean") throw new Error("invalid durable-directory result");
|
|
29005
|
-
|
|
29023
|
+
resolve29(value);
|
|
29006
29024
|
} catch (err) {
|
|
29007
29025
|
reject(err);
|
|
29008
29026
|
}
|
|
@@ -29126,13 +29144,13 @@ async function acquireWorkspaceRootLease(authority, opts = {}) {
|
|
|
29126
29144
|
}), closed4 = observeChildClose(child);
|
|
29127
29145
|
let stderr = new BoundedOutputBuffer(4096);
|
|
29128
29146
|
child.stderr?.on("data", (chunk) => stderr.push(chunk));
|
|
29129
|
-
let ready = await withHelperDeadline(new Promise((
|
|
29147
|
+
let ready = await withHelperDeadline(new Promise((resolve29, reject) => {
|
|
29130
29148
|
let value = "";
|
|
29131
29149
|
child.stdout?.on("data", (chunk) => {
|
|
29132
29150
|
value += chunk.toString("utf8"), value.length > 4096 && reject(new Error("workspace-lease helper exceeded output limit"));
|
|
29133
29151
|
let at = value.indexOf(`
|
|
29134
29152
|
`);
|
|
29135
|
-
at >= 0 &&
|
|
29153
|
+
at >= 0 && resolve29(value.slice(0, at));
|
|
29136
29154
|
}), child.once("error", reject), closed4.then((code) => {
|
|
29137
29155
|
code !== null && code !== 0 && reject(new Error(`workspace-lease helper failed (${code}): ${stderr.toString()}`));
|
|
29138
29156
|
});
|
|
@@ -29192,7 +29210,7 @@ async function captureWorkspaceRootAuthority(workingDir, opts = {}) {
|
|
|
29192
29210
|
process.env[key] !== void 0 && (env[key] = process.env[key]);
|
|
29193
29211
|
let child, closed4;
|
|
29194
29212
|
try {
|
|
29195
|
-
let resultPromise = new Promise((
|
|
29213
|
+
let resultPromise = new Promise((resolve29, reject) => {
|
|
29196
29214
|
try {
|
|
29197
29215
|
child = spawnIsolatedHelper(process.execPath, ["-e", WORKSPACE_AUTHORITY_BOOTSTRAP], {
|
|
29198
29216
|
env,
|
|
@@ -29227,7 +29245,7 @@ async function captureWorkspaceRootAuthority(workingDir, opts = {}) {
|
|
|
29227
29245
|
}
|
|
29228
29246
|
try {
|
|
29229
29247
|
let value = JSON.parse(Buffer.concat(chunks, bytes).toString("utf8"));
|
|
29230
|
-
assertWorkspaceRootAuthoritySchema(value),
|
|
29248
|
+
assertWorkspaceRootAuthoritySchema(value), resolve29(value);
|
|
29231
29249
|
} catch (err) {
|
|
29232
29250
|
reject(err);
|
|
29233
29251
|
}
|
|
@@ -32345,8 +32363,8 @@ async function runAnchoredReadWithinRoot(root, relativePath, opts) {
|
|
|
32345
32363
|
let nextMessage = () => {
|
|
32346
32364
|
let queued = messages.shift();
|
|
32347
32365
|
return queued ? Promise.resolve(queued) : protocolError ? Promise.reject(protocolError) : withHelperDeadline(Promise.race([
|
|
32348
|
-
new Promise((
|
|
32349
|
-
waiter = { resolve:
|
|
32366
|
+
new Promise((resolve29, reject) => {
|
|
32367
|
+
waiter = { resolve: resolve29, reject };
|
|
32350
32368
|
}),
|
|
32351
32369
|
childClosed.then((code) => {
|
|
32352
32370
|
throw new Error(`anchored read helper closed before result (${code}): ${stderr.toString()}`);
|
|
@@ -32824,8 +32842,8 @@ var writeChains = /* @__PURE__ */ new Map();
|
|
|
32824
32842
|
function withWriteLock(filePath, operation, opts) {
|
|
32825
32843
|
if (opts?.signal?.aborted)
|
|
32826
32844
|
return Promise.reject(new Error("anchored operation aborted by signal"));
|
|
32827
|
-
let prior = writeChains.get(filePath) ?? Promise.resolve(), isCancelled = !1, timer, abortListener, rejectCaller, resolveCaller, callerPromise = new Promise((
|
|
32828
|
-
resolveCaller =
|
|
32845
|
+
let prior = writeChains.get(filePath) ?? Promise.resolve(), isCancelled = !1, timer, abortListener, rejectCaller, resolveCaller, callerPromise = new Promise((resolve29, reject) => {
|
|
32846
|
+
resolveCaller = resolve29, rejectCaller = reject;
|
|
32829
32847
|
}), cleanupWait = () => {
|
|
32830
32848
|
timer !== void 0 && (clearTimeout(timer), timer = void 0), abortListener !== void 0 && opts?.signal && (opts.signal.removeEventListener("abort", abortListener), abortListener = void 0);
|
|
32831
32849
|
};
|
|
@@ -32904,8 +32922,8 @@ async function runAnchored(parent, request3, beforeCommit, afterRename, afterWri
|
|
|
32904
32922
|
let nextLine = async () => {
|
|
32905
32923
|
let line = lines.shift();
|
|
32906
32924
|
return line !== void 0 ? (backlog.onLineConsumed(utf8Bytes(line)), line) : withHelperDeadline(Promise.race([
|
|
32907
|
-
new Promise((
|
|
32908
|
-
waiter =
|
|
32925
|
+
new Promise((resolve29) => {
|
|
32926
|
+
waiter = resolve29;
|
|
32909
32927
|
}),
|
|
32910
32928
|
childClosed.then((code2) => {
|
|
32911
32929
|
throw new Error(`anchored-fs helper closed before replying (${code2}): ${stderr.toString()}`);
|
|
@@ -34656,8 +34674,8 @@ function ReviewerSetupWizard(props) {
|
|
|
34656
34674
|
// src/orchestration-shell/resume-modal.ts
|
|
34657
34675
|
var pending = /* @__PURE__ */ new WeakMap();
|
|
34658
34676
|
function open9(store, modal) {
|
|
34659
|
-
return pending.get(store)?.(modal.kind === "picker" ? null : !1), new Promise((
|
|
34660
|
-
pending.set(store,
|
|
34677
|
+
return pending.get(store)?.(modal.kind === "picker" ? null : !1), new Promise((resolve29) => {
|
|
34678
|
+
pending.set(store, resolve29), store.dispatch({ type: "RESUME_MODAL_OPEN", modal });
|
|
34661
34679
|
});
|
|
34662
34680
|
}
|
|
34663
34681
|
async function pickInShell(store, rows) {
|
|
@@ -34668,8 +34686,8 @@ async function chooseInShell(store, prompt, continueLabel) {
|
|
|
34668
34686
|
return await open9(store, { kind: "choice", prompt, continueLabel }) === !0;
|
|
34669
34687
|
}
|
|
34670
34688
|
function settleResumeModal(store, value) {
|
|
34671
|
-
let
|
|
34672
|
-
pending.delete(store), store.dispatch({ type: "RESUME_MODAL_CLOSE" }),
|
|
34689
|
+
let resolve29 = pending.get(store);
|
|
34690
|
+
pending.delete(store), store.dispatch({ type: "RESUME_MODAL_CLOSE" }), resolve29?.(value);
|
|
34673
34691
|
}
|
|
34674
34692
|
|
|
34675
34693
|
// src/orchestration-shell/task-lifecycle-lines.ts
|
|
@@ -35154,7 +35172,7 @@ async function htmlToTextWorker(html, options) {
|
|
|
35154
35172
|
if (signal?.aborted)
|
|
35155
35173
|
throw new WebExtractAbortError();
|
|
35156
35174
|
let workerPath = resolveExtractWorkerPath();
|
|
35157
|
-
return new Promise((
|
|
35175
|
+
return new Promise((resolve29, reject) => {
|
|
35158
35176
|
let settled = !1, timer = null, worker = null, cleanup = () => {
|
|
35159
35177
|
timer && (clearTimeout(timer), timer = null), signal && signal.removeEventListener("abort", onAbort);
|
|
35160
35178
|
}, onAbort = () => {
|
|
@@ -35175,7 +35193,7 @@ async function htmlToTextWorker(html, options) {
|
|
|
35175
35193
|
}), reject(new WebExtractTimeoutError(timeoutMs)));
|
|
35176
35194
|
}, timeoutMs), worker.on("message", (msg) => {
|
|
35177
35195
|
settled || (settled = !0, cleanup(), worker?.terminate().catch(() => {
|
|
35178
|
-
}), msg.success && msg.result ?
|
|
35196
|
+
}), msg.success && msg.result ? resolve29(msg.result) : reject(new Error(msg.error || "HTML extraction failed in worker")));
|
|
35179
35197
|
}), worker.on("error", (err) => {
|
|
35180
35198
|
settled || (settled = !0, cleanup(), worker?.terminate().catch(() => {
|
|
35181
35199
|
}), reject(err));
|
|
@@ -35839,14 +35857,14 @@ async function resolveValidatedIps(host, signal, customLookup = dns2.lookup) {
|
|
|
35839
35857
|
}
|
|
35840
35858
|
let records;
|
|
35841
35859
|
try {
|
|
35842
|
-
records = await new Promise((
|
|
35860
|
+
records = await new Promise((resolve29, reject) => {
|
|
35843
35861
|
if (signal?.aborted) {
|
|
35844
35862
|
reject(new FetchError("timeout", "aborted before DNS"));
|
|
35845
35863
|
return;
|
|
35846
35864
|
}
|
|
35847
35865
|
let onAbort = () => reject(new FetchError("timeout", "DNS aborted"));
|
|
35848
35866
|
signal?.addEventListener("abort", onAbort, { once: !0 }), customLookup(host, { all: !0 }, (err, addrs) => {
|
|
35849
|
-
signal?.removeEventListener("abort", onAbort), err ? reject(err) :
|
|
35867
|
+
signal?.removeEventListener("abort", onAbort), err ? reject(err) : resolve29(addrs);
|
|
35850
35868
|
});
|
|
35851
35869
|
});
|
|
35852
35870
|
} catch (e) {
|
|
@@ -35898,7 +35916,7 @@ function decodeBody(buf, contentType) {
|
|
|
35898
35916
|
return buf.toString("utf-8");
|
|
35899
35917
|
}
|
|
35900
35918
|
function getOnce(url, frozen, signal, options) {
|
|
35901
|
-
return new Promise((
|
|
35919
|
+
return new Promise((resolve29, reject) => {
|
|
35902
35920
|
let req = (url.protocol === "https:" ? https3 : http2).request(
|
|
35903
35921
|
url,
|
|
35904
35922
|
{
|
|
@@ -35918,7 +35936,7 @@ function getOnce(url, frozen, signal, options) {
|
|
|
35918
35936
|
(res) => {
|
|
35919
35937
|
let status = res.statusCode ?? 0, contentType = String(res.headers["content-type"] ?? "");
|
|
35920
35938
|
if (status >= 300 && status < 400 && res.headers.location) {
|
|
35921
|
-
res.resume(),
|
|
35939
|
+
res.resume(), resolve29({ status, location: res.headers.location, contentType });
|
|
35922
35940
|
return;
|
|
35923
35941
|
}
|
|
35924
35942
|
if (status >= 400) {
|
|
@@ -35949,7 +35967,7 @@ function getOnce(url, frozen, signal, options) {
|
|
|
35949
35967
|
return;
|
|
35950
35968
|
}
|
|
35951
35969
|
chunks.push(c);
|
|
35952
|
-
}), stream.on("end", () =>
|
|
35970
|
+
}), stream.on("end", () => resolve29({ status, contentType, body: Buffer.concat(chunks) })), stream.on("error", (e) => reject(new FetchError("network", e?.code ?? "stream error")));
|
|
35953
35971
|
}
|
|
35954
35972
|
);
|
|
35955
35973
|
req.setTimeout(TIMEOUT_MS, () => {
|
|
@@ -36611,10 +36629,10 @@ async function startAgentWebTurn(options) {
|
|
|
36611
36629
|
});
|
|
36612
36630
|
});
|
|
36613
36631
|
try {
|
|
36614
|
-
await new Promise((
|
|
36632
|
+
await new Promise((resolve29, reject) => {
|
|
36615
36633
|
server.listen(socketPath, () => {
|
|
36616
36634
|
try {
|
|
36617
|
-
fs33.chmodSync(socketPath, 384),
|
|
36635
|
+
fs33.chmodSync(socketPath, 384), resolve29();
|
|
36618
36636
|
} catch (err) {
|
|
36619
36637
|
reject(err);
|
|
36620
36638
|
}
|
|
@@ -37509,7 +37527,7 @@ function isTransientDirectoryEnumeration(error) {
|
|
|
37509
37527
|
return error instanceof Error && error.message.includes(TRANSIENT_DIRECTORY_ENUMERATION);
|
|
37510
37528
|
}
|
|
37511
37529
|
function sleep(ms) {
|
|
37512
|
-
return new Promise((
|
|
37530
|
+
return new Promise((resolve29) => setTimeout(resolve29, ms));
|
|
37513
37531
|
}
|
|
37514
37532
|
async function withTransientDirectoryEnumerationRetry(operation, opts = {}) {
|
|
37515
37533
|
let maxAttempts = opts.maxAttempts ?? 4, retryDelaysMs = opts.retryDelaysMs ?? [10, 25, 50], sleepFn = opts.sleep ?? sleep;
|
|
@@ -37649,8 +37667,8 @@ function nextDirectoryWorkerMessage(worker, deadlineAt, label, signal) {
|
|
|
37649
37667
|
if (worker.protocolError) return Promise.reject(worker.protocolError);
|
|
37650
37668
|
let remaining = deadlineAt - Date.now();
|
|
37651
37669
|
return remaining <= 0 ? Promise.reject(new Error(`${label} helper timed out`)) : withHelperDeadline(Promise.race([
|
|
37652
|
-
new Promise((
|
|
37653
|
-
worker.waiter = { resolve:
|
|
37670
|
+
new Promise((resolve29, reject) => {
|
|
37671
|
+
worker.waiter = { resolve: resolve29, reject };
|
|
37654
37672
|
}),
|
|
37655
37673
|
worker.closed.then((code) => {
|
|
37656
37674
|
throw new Error(
|
|
@@ -38179,10 +38197,10 @@ function readPosixHostProtocol(child, persistOwner, syncOwnerDirectory) {
|
|
|
38179
38197
|
let status = child.stdio?.[3];
|
|
38180
38198
|
if (!status || typeof status.on != "function")
|
|
38181
38199
|
return { cleanupSafe: Promise.resolve(!1), owner: Promise.resolve(void 0) };
|
|
38182
|
-
let resolveCleanup, resolveOwner, cleanupSafe = new Promise((
|
|
38183
|
-
resolveCleanup =
|
|
38184
|
-
}), owner = new Promise((
|
|
38185
|
-
resolveOwner =
|
|
38200
|
+
let resolveCleanup, resolveOwner, cleanupSafe = new Promise((resolve29) => {
|
|
38201
|
+
resolveCleanup = resolve29;
|
|
38202
|
+
}), owner = new Promise((resolve29) => {
|
|
38203
|
+
resolveOwner = resolve29;
|
|
38186
38204
|
}), pending2 = "", bytes = 0, ownerSettled = !1, cleanupSettled = !1, finish = () => {
|
|
38187
38205
|
ownerSettled || (ownerSettled = !0, resolveOwner(void 0)), cleanupSettled || (cleanupSettled = !0, resolveCleanup(!1));
|
|
38188
38206
|
}, consume = (line) => {
|
|
@@ -38545,11 +38563,11 @@ async function spawnWindowsJobProcess(command, args, options, seams = {}) {
|
|
|
38545
38563
|
throw await anchoredRemoveTree(hostDir, hostIdentity).catch(() => {
|
|
38546
38564
|
}), err;
|
|
38547
38565
|
}
|
|
38548
|
-
let cleanupStarted = !1, cleanupPromise = new Promise((
|
|
38566
|
+
let cleanupStarted = !1, cleanupPromise = new Promise((resolve29) => {
|
|
38549
38567
|
let cleanup = () => {
|
|
38550
38568
|
cleanupStarted || (cleanupStarted = !0, anchoredRemoveTree(hostDir, hostIdentity).then(
|
|
38551
|
-
() =>
|
|
38552
|
-
() =>
|
|
38569
|
+
() => resolve29(!0),
|
|
38570
|
+
() => resolve29(!1)
|
|
38553
38571
|
));
|
|
38554
38572
|
};
|
|
38555
38573
|
child.once("close", cleanup), child.once("error", cleanup);
|
|
@@ -38584,7 +38602,7 @@ async function waitForProcessIdentity(pid) {
|
|
|
38584
38602
|
for (let attempt = 0; attempt < 100; attempt++) {
|
|
38585
38603
|
let identity = await readProcessIdentity(pid);
|
|
38586
38604
|
if (identity) return identity;
|
|
38587
|
-
await new Promise((
|
|
38605
|
+
await new Promise((resolve29) => setTimeout(resolve29, 10));
|
|
38588
38606
|
}
|
|
38589
38607
|
return null;
|
|
38590
38608
|
}
|
|
@@ -38803,7 +38821,7 @@ async function terminateOwnedProcessTree(args) {
|
|
|
38803
38821
|
} catch (err) {
|
|
38804
38822
|
err.code !== "ESRCH" && directKill();
|
|
38805
38823
|
}
|
|
38806
|
-
let timeoutMs = args.timeoutMs ?? 1e4, deadline = Date.now() + timeoutMs, sleep2 = args.sleep ?? ((ms) => new Promise((
|
|
38824
|
+
let timeoutMs = args.timeoutMs ?? 1e4, deadline = Date.now() + timeoutMs, sleep2 = args.sleep ?? ((ms) => new Promise((resolve29) => setTimeout(resolve29, ms)));
|
|
38807
38825
|
for (; ; ) {
|
|
38808
38826
|
try {
|
|
38809
38827
|
kill(-pid, 0);
|
|
@@ -38944,17 +38962,17 @@ function isInsideDir(candidate, dir) {
|
|
|
38944
38962
|
return root.startsWith("/") ? candidate === root || candidate.startsWith(`${root}/`) : !1;
|
|
38945
38963
|
}
|
|
38946
38964
|
function run(command, args, okExitCodes = []) {
|
|
38947
|
-
return new Promise((
|
|
38965
|
+
return new Promise((resolve29, reject) => {
|
|
38948
38966
|
(0, import_node_child_process5.execFile)(
|
|
38949
38967
|
command,
|
|
38950
38968
|
args,
|
|
38951
38969
|
// `LC_ALL=C` pins the `lstart` column format the parser reads.
|
|
38952
38970
|
{ timeout: 5e3, maxBuffer: 64 * 1024 * 1024, windowsHide: !0, env: { ...process.env, LC_ALL: "C" } },
|
|
38953
38971
|
(err, stdout) => {
|
|
38954
|
-
if (!err) return
|
|
38972
|
+
if (!err) return resolve29(stdout);
|
|
38955
38973
|
let code = err.code;
|
|
38956
38974
|
if (typeof code == "number" && okExitCodes.includes(code) && !err.killed)
|
|
38957
|
-
return
|
|
38975
|
+
return resolve29(stdout);
|
|
38958
38976
|
reject(err);
|
|
38959
38977
|
}
|
|
38960
38978
|
);
|
|
@@ -39218,8 +39236,8 @@ function wireLifecycle(internal, args) {
|
|
|
39218
39236
|
}
|
|
39219
39237
|
return descendantReap;
|
|
39220
39238
|
}, resolveDone = () => {
|
|
39221
|
-
}, done = new Promise((
|
|
39222
|
-
resolveDone =
|
|
39239
|
+
}, done = new Promise((resolve29) => {
|
|
39240
|
+
resolveDone = resolve29;
|
|
39223
39241
|
}), cleanupAbort = () => {
|
|
39224
39242
|
}, cleanupTimeout = () => {
|
|
39225
39243
|
}, settling = !1, forcedExit = null, settle = async (failureClass, exitCode, workspaceCleanupSafe = !0) => {
|
|
@@ -41674,8 +41692,8 @@ async function runShellCommand(args) {
|
|
|
41674
41692
|
}, aborted = args.signal?.aborted === !0, onAbort = () => {
|
|
41675
41693
|
aborted = !0, killProcessTree();
|
|
41676
41694
|
}, resolveResult = () => {
|
|
41677
|
-
}, settled = new Promise((
|
|
41678
|
-
resolveResult =
|
|
41695
|
+
}, settled = new Promise((resolve29) => {
|
|
41696
|
+
resolveResult = resolve29;
|
|
41679
41697
|
}), settle = (result) => {
|
|
41680
41698
|
alreadySettled || (alreadySettled = !0, timer !== void 0 && clearTimeout(timer), args.signal?.removeEventListener("abort", onAbort), resolveResult(result));
|
|
41681
41699
|
}, finalize = async (exitCode, workspaceCleanupSafe = !0) => {
|
|
@@ -42385,8 +42403,8 @@ function createWorkspaceMaterializerSession(opts) {
|
|
|
42385
42403
|
if (queued) return Promise.resolve(queued);
|
|
42386
42404
|
if (protocolError) return Promise.reject(protocolError);
|
|
42387
42405
|
let remaining = deadlineAt - Date.now();
|
|
42388
|
-
return remaining <= 0 ? Promise.reject(new Error("workspace-materializer helper timed out")) : withHelperDeadline(new Promise((
|
|
42389
|
-
waiter = { resolve:
|
|
42406
|
+
return remaining <= 0 ? Promise.reject(new Error("workspace-materializer helper timed out")) : withHelperDeadline(new Promise((resolve29, reject) => {
|
|
42407
|
+
waiter = { resolve: resolve29, reject };
|
|
42390
42408
|
}), remaining, "workspace-materializer helper");
|
|
42391
42409
|
}
|
|
42392
42410
|
function serialize(operation) {
|
|
@@ -43663,8 +43681,8 @@ async function runAnchoredCasHelper(workingDir, relativePath, expectedRoot, requ
|
|
|
43663
43681
|
"anchored CAS helper exit"
|
|
43664
43682
|
), nextMessageRaw = () => {
|
|
43665
43683
|
let queued = messages.shift();
|
|
43666
|
-
return queued !== void 0 && backlog.onLineConsumed(messageSizes.shift() ?? 0), queued ? Promise.resolve(queued) : closed4 ? Promise.reject(new Error(`anchored CAS helper exited ${closeCode}: ${stderr.toString()}`)) : new Promise((
|
|
43667
|
-
lineWaiter = { resolve:
|
|
43684
|
+
return queued !== void 0 && backlog.onLineConsumed(messageSizes.shift() ?? 0), queued ? Promise.resolve(queued) : closed4 ? Promise.reject(new Error(`anchored CAS helper exited ${closeCode}: ${stderr.toString()}`)) : new Promise((resolve29, reject) => {
|
|
43685
|
+
lineWaiter = { resolve: resolve29, reject };
|
|
43668
43686
|
});
|
|
43669
43687
|
}, nextMessage = () => withHelperDeadline(
|
|
43670
43688
|
nextMessageRaw(),
|
|
@@ -46059,8 +46077,8 @@ async function readSnapshotOwnerAnchor(shadowDir, opts) {
|
|
|
46059
46077
|
});
|
|
46060
46078
|
!hasError && !opts?.signal?.aborted ? await closePromise : await Promise.race([
|
|
46061
46079
|
closePromise,
|
|
46062
|
-
new Promise((
|
|
46063
|
-
let t = setTimeout(
|
|
46080
|
+
new Promise((resolve29) => {
|
|
46081
|
+
let t = setTimeout(resolve29, 0);
|
|
46064
46082
|
typeof t.unref == "function" && t.unref();
|
|
46065
46083
|
})
|
|
46066
46084
|
]);
|
|
@@ -47945,8 +47963,8 @@ var WorkspaceShadow = class _WorkspaceShadow {
|
|
|
47945
47963
|
this.exposureFileAuthority = { ...fileAuthority };
|
|
47946
47964
|
}
|
|
47947
47965
|
async runOwnedStateFileWrite(write) {
|
|
47948
|
-
let settle, admission = new Promise((
|
|
47949
|
-
settle =
|
|
47966
|
+
let settle, admission = new Promise((resolve29) => {
|
|
47967
|
+
settle = resolve29;
|
|
47950
47968
|
});
|
|
47951
47969
|
this.stateFileWriteAdmissions.add(admission);
|
|
47952
47970
|
try {
|
|
@@ -49376,7 +49394,7 @@ var DEFAULT_MERGE_PLAN_MAX_WORK = 16e6, DEFAULT_MERGE_PLAN_TIMEOUT_MS = 5e3, MER
|
|
|
49376
49394
|
this.used += units, this.workSinceYield += units, this.assertActive();
|
|
49377
49395
|
}
|
|
49378
49396
|
async cooperate(force = !1) {
|
|
49379
|
-
this.assertActive(), !(!force && this.workSinceYield < MERGE_PLAN_YIELD_INTERVAL) && (this.workSinceYield = 0, await new Promise((
|
|
49397
|
+
this.assertActive(), !(!force && this.workSinceYield < MERGE_PLAN_YIELD_INTERVAL) && (this.workSinceYield = 0, await new Promise((resolve29) => setImmediate(resolve29)), this.assertActive());
|
|
49380
49398
|
}
|
|
49381
49399
|
};
|
|
49382
49400
|
function assertSnapshotBundleFileOccurrenceBounds(bundles, budget = createMetadataBudget(), label = "snapshot bundle file-occurrence aggregate") {
|
|
@@ -50732,7 +50750,7 @@ init_logger2();
|
|
|
50732
50750
|
var import_node_child_process7 = require("node:child_process"), crypto20 = __toESM(require("node:crypto")), fs44 = __toESM(require("node:fs/promises")), os32 = __toESM(require("node:os")), path56 = __toESM(require("node:path")), import_node_util = require("node:util");
|
|
50733
50751
|
|
|
50734
50752
|
// src/local-executor/git-lock-retry.ts
|
|
50735
|
-
var realSleep = (ms) => new Promise((
|
|
50753
|
+
var realSleep = (ms) => new Promise((resolve29) => setTimeout(resolve29, ms));
|
|
50736
50754
|
function isGitLockContention(msg) {
|
|
50737
50755
|
let m = msg.toLowerCase();
|
|
50738
50756
|
return (
|
|
@@ -51020,7 +51038,7 @@ async function pinnedGit(repoDir, args, opts = {}) {
|
|
|
51020
51038
|
}
|
|
51021
51039
|
async function pinnedGitWithInput(repoDir, args, input, opts = {}) {
|
|
51022
51040
|
let configPrefix = [...W2_HERMETIC_CONFIG, ...PINNED_GIT_CONFIG];
|
|
51023
|
-
return await new Promise((
|
|
51041
|
+
return await new Promise((resolve29, reject) => {
|
|
51024
51042
|
let child = (0, import_node_child_process7.spawn)("git", ["-C", repoDir, ...configPrefix, ...args], {
|
|
51025
51043
|
env: sanitizeGitEnv(),
|
|
51026
51044
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -51030,7 +51048,7 @@ async function pinnedGitWithInput(repoDir, args, input, opts = {}) {
|
|
|
51030
51048
|
}), child.stderr.on("data", (c) => {
|
|
51031
51049
|
stderr += c.toString("utf8");
|
|
51032
51050
|
}), child.on("error", (err) => reject(err)), child.on("close", (code) => {
|
|
51033
|
-
code === 0 || opts.allowFail ?
|
|
51051
|
+
code === 0 || opts.allowFail ? resolve29({ stdout, stderr, code: code ?? -1 }) : reject(new Error(`git ${args[0] ?? ""} exited ${code}: ${stderr.slice(0, 400)}`));
|
|
51034
51052
|
}), child.stdin.on("error", () => {
|
|
51035
51053
|
}), child.stdin.end(input);
|
|
51036
51054
|
});
|
|
@@ -56795,8 +56813,8 @@ var LocalExecutorImpl = class {
|
|
|
56795
56813
|
throw new Error("LocalExecutor session shutdown has fenced new advisory spawns");
|
|
56796
56814
|
let resolveSettled, admission = {
|
|
56797
56815
|
controller: new AbortController(),
|
|
56798
|
-
settled: new Promise((
|
|
56799
|
-
resolveSettled =
|
|
56816
|
+
settled: new Promise((resolve29) => {
|
|
56817
|
+
resolveSettled = resolve29;
|
|
56800
56818
|
}),
|
|
56801
56819
|
resolveSettled: () => resolveSettled(),
|
|
56802
56820
|
handle: null,
|
|
@@ -57884,7 +57902,7 @@ var LocalExecutorImpl = class {
|
|
|
57884
57902
|
this.integrationAbort.signal
|
|
57885
57903
|
), ranGate || this.workspaceShutdown) return;
|
|
57886
57904
|
let remaining = deadline - Date.now();
|
|
57887
|
-
!retryMissing || remaining <= 0 || await new Promise((
|
|
57905
|
+
!retryMissing || remaining <= 0 || await new Promise((resolve29) => setTimeout(resolve29, Math.min(TRACK_TIP_POLL_MS, remaining)));
|
|
57888
57906
|
}
|
|
57889
57907
|
}
|
|
57890
57908
|
/** True only for a missing exact current-generation bundle; malformed input is classified inside the gate. */
|
|
@@ -59568,8 +59586,8 @@ var RevertManifestStore = class {
|
|
|
59568
59586
|
let nextLine = async () => {
|
|
59569
59587
|
let line = lines.shift();
|
|
59570
59588
|
return line !== void 0 ? (backlog.onLineConsumed(utf8Bytes(line)), line) : withHelperDeadline(Promise.race([
|
|
59571
|
-
new Promise((
|
|
59572
|
-
waiter =
|
|
59589
|
+
new Promise((resolve29) => {
|
|
59590
|
+
waiter = resolve29;
|
|
59573
59591
|
}),
|
|
59574
59592
|
childClosed.then((code2) => {
|
|
59575
59593
|
throw new Error(`store helper closed before replying (${code2}): ${stderr.toString()}`);
|
|
@@ -61142,6 +61160,9 @@ function resolveTeamExecution(_override, _env = process.env) {
|
|
|
61142
61160
|
return DEFAULT_TEAM_EXECUTION;
|
|
61143
61161
|
}
|
|
61144
61162
|
|
|
61163
|
+
// src/local-executor/spawn-sweep.ts
|
|
61164
|
+
init_logger2();
|
|
61165
|
+
|
|
61145
61166
|
// src/orchestration-shell/quorum-loop.ts
|
|
61146
61167
|
init_env_scrub();
|
|
61147
61168
|
|
|
@@ -62492,7 +62513,7 @@ var import_node_child_process9 = require("node:child_process");
|
|
|
62492
62513
|
init_env_scrub();
|
|
62493
62514
|
var ChildProcessCommandRunner = class {
|
|
62494
62515
|
run(argv, opts = {}) {
|
|
62495
|
-
return new Promise((
|
|
62516
|
+
return new Promise((resolve29, reject) => {
|
|
62496
62517
|
let child = (0, import_node_child_process9.spawn)(argv[0], argv.slice(1), {
|
|
62497
62518
|
stdio: ["pipe", "pipe", "pipe"],
|
|
62498
62519
|
windowsHide: !0,
|
|
@@ -62508,7 +62529,7 @@ var ChildProcessCommandRunner = class {
|
|
|
62508
62529
|
}, opts.timeoutMs)), child.on("error", (err) => {
|
|
62509
62530
|
timer && clearTimeout(timer), reject(err);
|
|
62510
62531
|
}), child.on("close", (code) => {
|
|
62511
|
-
timer && clearTimeout(timer),
|
|
62532
|
+
timer && clearTimeout(timer), resolve29({
|
|
62512
62533
|
exitCode: code,
|
|
62513
62534
|
stdout: Buffer.concat(stdoutChunks).toString("utf8"),
|
|
62514
62535
|
stderr: Buffer.concat(stderrChunks).toString("utf8")
|
|
@@ -62531,6 +62552,7 @@ var ChildProcessCommandRunner = class {
|
|
|
62531
62552
|
let spawnOptions = {
|
|
62532
62553
|
stdio: opts.stdinTty ? ["pipe", "pipe", "pipe"] : ["ignore", "pipe", "pipe"],
|
|
62533
62554
|
windowsHide: !0,
|
|
62555
|
+
detached: opts.detached ?? !1,
|
|
62534
62556
|
signal: opts.signal,
|
|
62535
62557
|
env: opts.env !== void 0 ? scrubSearchApiKeys({ ...opts.env }) : scrubSearchApiKeys({ ...process.env }),
|
|
62536
62558
|
...opts.cwd !== void 0 ? { cwd: opts.cwd } : {}
|
|
@@ -62595,12 +62617,12 @@ var denialCounter = 0, HostEgressForwarder = class {
|
|
|
62595
62617
|
*/
|
|
62596
62618
|
async start() {
|
|
62597
62619
|
return await import_node_fs29.promises.rm(this.udsPath, { force: !0 }).catch(() => {
|
|
62598
|
-
}), new Promise((
|
|
62620
|
+
}), new Promise((resolve29, reject) => {
|
|
62599
62621
|
let onError = (err) => {
|
|
62600
62622
|
this.server.removeListener("error", onError), reject(err);
|
|
62601
62623
|
};
|
|
62602
62624
|
this.server.once("error", onError), this.server.listen(this.udsPath, () => {
|
|
62603
|
-
this.server.removeListener("error", onError), this.listening = !0,
|
|
62625
|
+
this.server.removeListener("error", onError), this.listening = !0, resolve29({ udsPath: this.udsPath });
|
|
62604
62626
|
});
|
|
62605
62627
|
});
|
|
62606
62628
|
}
|
|
@@ -62618,8 +62640,8 @@ var denialCounter = 0, HostEgressForwarder = class {
|
|
|
62618
62640
|
});
|
|
62619
62641
|
return;
|
|
62620
62642
|
}
|
|
62621
|
-
this.listening = !1, await new Promise((
|
|
62622
|
-
this.server.close(() =>
|
|
62643
|
+
this.listening = !1, await new Promise((resolve29) => {
|
|
62644
|
+
this.server.close(() => resolve29());
|
|
62623
62645
|
}), await import_node_fs29.promises.rm(this.udsPath, { force: !0 }).catch(() => {
|
|
62624
62646
|
});
|
|
62625
62647
|
}
|
|
@@ -63063,7 +63085,17 @@ function buildSeatbeltProfile(workdir, execPath = process.execPath, extraReadDir
|
|
|
63063
63085
|
'(allow file-read* (subpath "/Library"))',
|
|
63064
63086
|
'(allow file-read* (subpath "/private/var/db"))',
|
|
63065
63087
|
'(allow file-read* (subpath "/private/var/select"))',
|
|
63066
|
-
|
|
63088
|
+
// PD-MAC-DEV (§6.1): grant only literal reads of the device nodes agents
|
|
63089
|
+
// use, plus `/dev/fd`. Replaces the broad `/dev` subpath read so a confined
|
|
63090
|
+
// agent cannot open another terminal session's tty or its own controlling
|
|
63091
|
+
// terminal (/dev/tty, /dev/ttys*).
|
|
63092
|
+
'(allow file-read* (literal "/dev/null"))',
|
|
63093
|
+
'(allow file-read* (literal "/dev/zero"))',
|
|
63094
|
+
'(allow file-read* (literal "/dev/random"))',
|
|
63095
|
+
'(allow file-read* (literal "/dev/urandom"))',
|
|
63096
|
+
'(allow file-read* (literal "/dev/dtracehelper"))',
|
|
63097
|
+
'(allow file-read* (literal "/dev/autofs_nowait"))',
|
|
63098
|
+
'(allow file-read* (subpath "/dev/fd"))',
|
|
63067
63099
|
// Ordinary POSIX tooling opens `/dev/null` rw. Grant only that literal
|
|
63068
63100
|
// device (the `/dev` read above does not cover writes).
|
|
63069
63101
|
'(allow file-write* (literal "/dev/null"))'
|
|
@@ -63106,11 +63138,13 @@ function buildSeatbeltProfile(workdir, execPath = process.execPath, extraReadDir
|
|
|
63106
63138
|
);
|
|
63107
63139
|
}
|
|
63108
63140
|
return networkPosture === "open" ? lines.push(
|
|
63109
|
-
// A1d resolver-confinement row: deny all network,
|
|
63110
|
-
//
|
|
63141
|
+
// A1d resolver-confinement row (§6.1, SP-A5, SP-A5b): deny all network,
|
|
63142
|
+
// then allow IP outbound + only mDNSResponder Unix socket for name resolution
|
|
63143
|
+
// (external inbound stays denied). Loopback bind/inbound is permitted
|
|
63111
63144
|
// for local IPC (e.g. Antigravity local RPC daemon on 127.0.0.1).
|
|
63112
63145
|
"(deny network*)",
|
|
63113
|
-
|
|
63146
|
+
'(allow network-outbound (remote ip "*:*"))',
|
|
63147
|
+
'(allow network-outbound (remote unix-socket (path-literal "/private/var/run/mDNSResponder")))',
|
|
63114
63148
|
'(allow network-bind (local ip "localhost:*"))',
|
|
63115
63149
|
'(allow network-inbound (local ip "localhost:*"))',
|
|
63116
63150
|
""
|
|
@@ -63713,7 +63747,7 @@ async function runReviewer(opts) {
|
|
|
63713
63747
|
});
|
|
63714
63748
|
}
|
|
63715
63749
|
let acquiredChild = child;
|
|
63716
|
-
return new Promise((
|
|
63750
|
+
return new Promise((resolve29, reject) => {
|
|
63717
63751
|
let child2 = acquiredChild, settled = !1, stdoutChunks = [], stderrChunks = [], cleanupStreams = () => {
|
|
63718
63752
|
try {
|
|
63719
63753
|
child2.stdin && !child2.stdin.destroyed && child2.stdin.destroy();
|
|
@@ -63735,7 +63769,7 @@ async function runReviewer(opts) {
|
|
|
63735
63769
|
}, cleanupAbortListener = () => {
|
|
63736
63770
|
}, cleanupTimeoutTimer = () => {
|
|
63737
63771
|
}, settleSuccess = (outcome2) => {
|
|
63738
|
-
settled || (settled = !0, cleanupAbortListener(), cleanupTimeoutTimer(),
|
|
63772
|
+
settled || (settled = !0, cleanupAbortListener(), cleanupTimeoutTimer(), resolve29(outcome2));
|
|
63739
63773
|
}, settleError = (err) => {
|
|
63740
63774
|
settled || (settled = !0, cleanupAbortListener(), cleanupTimeoutTimer(), cleanupStreams(), killChild(), reject(err));
|
|
63741
63775
|
};
|
|
@@ -66533,8 +66567,8 @@ var QuorumLoop = class _QuorumLoop {
|
|
|
66533
66567
|
return this.trackExistingSessionWork(recovery);
|
|
66534
66568
|
}
|
|
66535
66569
|
acquireRecoveryRelaunchPermit() {
|
|
66536
|
-
return this.shuttingDown ? Promise.resolve(!1) : this.activeRecoveryRelaunches < TEAM_RECOVERY_RELAUNCH_CONCURRENCY ? (this.activeRecoveryRelaunches++, Promise.resolve(!0)) : new Promise((
|
|
66537
|
-
this.recoveryRelaunchWaiters.push(
|
|
66570
|
+
return this.shuttingDown ? Promise.resolve(!1) : this.activeRecoveryRelaunches < TEAM_RECOVERY_RELAUNCH_CONCURRENCY ? (this.activeRecoveryRelaunches++, Promise.resolve(!0)) : new Promise((resolve29) => {
|
|
66571
|
+
this.recoveryRelaunchWaiters.push(resolve29);
|
|
66538
66572
|
});
|
|
66539
66573
|
}
|
|
66540
66574
|
releaseRecoveryRelaunchPermit() {
|
|
@@ -66565,12 +66599,12 @@ var QuorumLoop = class _QuorumLoop {
|
|
|
66565
66599
|
}
|
|
66566
66600
|
}
|
|
66567
66601
|
awaitBackgroundRecoveryStep(work, signal) {
|
|
66568
|
-
return signal ? signal.aborted ? Promise.reject(BACKGROUND_RECOVERY_ABORTED) : new Promise((
|
|
66602
|
+
return signal ? signal.aborted ? Promise.reject(BACKGROUND_RECOVERY_ABORTED) : new Promise((resolve29, reject) => {
|
|
66569
66603
|
let settled = !1, finish = (complete) => {
|
|
66570
66604
|
settled || (settled = !0, signal.removeEventListener("abort", onAbort), complete());
|
|
66571
66605
|
}, onAbort = () => finish(() => reject(BACKGROUND_RECOVERY_ABORTED));
|
|
66572
66606
|
signal.addEventListener("abort", onAbort, { once: !0 }), work.then(
|
|
66573
|
-
(value) => finish(() =>
|
|
66607
|
+
(value) => finish(() => resolve29(value)),
|
|
66574
66608
|
(err) => finish(() => reject(err))
|
|
66575
66609
|
);
|
|
66576
66610
|
}) : work;
|
|
@@ -66699,8 +66733,8 @@ var QuorumLoop = class _QuorumLoop {
|
|
|
66699
66733
|
gateId,
|
|
66700
66734
|
entry: entry5,
|
|
66701
66735
|
authority,
|
|
66702
|
-
settled: new Promise((
|
|
66703
|
-
settle =
|
|
66736
|
+
settled: new Promise((resolve29) => {
|
|
66737
|
+
settle = resolve29;
|
|
66704
66738
|
})
|
|
66705
66739
|
}, admissions = this.teamDispatchAdmissionsByTask.get(taskId) ?? /* @__PURE__ */ new Set();
|
|
66706
66740
|
admissions.add(admission), this.teamDispatchAdmissionsByTask.set(taskId, admissions);
|
|
@@ -67981,8 +68015,8 @@ ${section}`);
|
|
|
67981
68015
|
taskId: args.taskId,
|
|
67982
68016
|
gateId,
|
|
67983
68017
|
abortController,
|
|
67984
|
-
settled: new Promise((
|
|
67985
|
-
settlePending =
|
|
68018
|
+
settled: new Promise((resolve29) => {
|
|
68019
|
+
settlePending = resolve29;
|
|
67986
68020
|
}),
|
|
67987
68021
|
...args.teamAuthority ? { teamAuthority: args.teamAuthority } : {}
|
|
67988
68022
|
}, needsWeb = this.webAccessByTask.get(args.taskId);
|
|
@@ -70187,8 +70221,8 @@ ${section}`);
|
|
|
70187
70221
|
() => {
|
|
70188
70222
|
}
|
|
70189
70223
|
));
|
|
70190
|
-
let displayTimeout = new Promise((
|
|
70191
|
-
timeout = setTimeout(() =>
|
|
70224
|
+
let displayTimeout = new Promise((resolve29) => {
|
|
70225
|
+
timeout = setTimeout(() => resolve29(void 0), TICK_SCAN_TIMEOUT_MS);
|
|
70192
70226
|
});
|
|
70193
70227
|
return await Promise.race([scan, displayTimeout]);
|
|
70194
70228
|
} catch {
|
|
@@ -76328,7 +76362,7 @@ var AdvisoryAttachmentJournal = class {
|
|
|
76328
76362
|
artifactTargets.add(target2);
|
|
76329
76363
|
}
|
|
76330
76364
|
if (retirementNames.length > 0 && Date.now() < retirementDeadlineMs)
|
|
76331
|
-
return await new Promise((
|
|
76365
|
+
return await new Promise((resolve29) => setTimeout(resolve29, 20)), this.listRecords(root, retirementDeadlineMs, artifactRetry);
|
|
76332
76366
|
for (let name of retirementNames.sort()) {
|
|
76333
76367
|
let retired = await this.readRetirementRecord(root, name), currentOwner = await this.currentOwner(), ownedHere = sameProcessIdentity(retired.value.owner, currentOwner) && this.activeBatchIds.has(retired.value.batchId), ownerDead = !await this.ownerIsAlive(retired.value.owner);
|
|
76334
76368
|
if (!ownedHere && !ownerDead)
|
|
@@ -80552,8 +80586,8 @@ var PromptPublicationTracker = class {
|
|
|
80552
80586
|
return this.active.has(promptId2);
|
|
80553
80587
|
}
|
|
80554
80588
|
async run(promptId2, publish) {
|
|
80555
|
-
let settle, settled = new Promise((
|
|
80556
|
-
settle =
|
|
80589
|
+
let settle, settled = new Promise((resolve29) => {
|
|
80590
|
+
settle = resolve29;
|
|
80557
80591
|
}), writes = this.active.get(promptId2) ?? /* @__PURE__ */ new Set();
|
|
80558
80592
|
writes.add(settled), this.active.set(promptId2, writes);
|
|
80559
80593
|
try {
|
|
@@ -82926,9 +82960,9 @@ async function runOrchestrationShellSession(args) {
|
|
|
82926
82960
|
await durableDecisionEffectDispatcher.dispatch(resolution);
|
|
82927
82961
|
}, settleInitialSubscription = () => {
|
|
82928
82962
|
}, rejectInitialSubscription = () => {
|
|
82929
|
-
}, initialSubscriptionSettled = !startupReadinessRequired, initialCatchUpStarted = !1, initialSubscriptionTimer = null, initialSubscriptionReady = startupReadinessRequired ? new Promise((
|
|
82963
|
+
}, initialSubscriptionSettled = !startupReadinessRequired, initialCatchUpStarted = !1, initialSubscriptionTimer = null, initialSubscriptionReady = startupReadinessRequired ? new Promise((resolve29, reject) => {
|
|
82930
82964
|
settleInitialSubscription = () => {
|
|
82931
|
-
initialSubscriptionSettled || (initialSubscriptionSettled = !0,
|
|
82965
|
+
initialSubscriptionSettled || (initialSubscriptionSettled = !0, resolve29());
|
|
82932
82966
|
}, rejectInitialSubscription = (error) => {
|
|
82933
82967
|
initialSubscriptionSettled || (initialSubscriptionSettled = !0, reject(error));
|
|
82934
82968
|
}, initialSubscriptionTimer = setTimeout(() => {
|
|
@@ -83111,9 +83145,9 @@ async function runOrchestrationShellSession(args) {
|
|
|
83111
83145
|
}
|
|
83112
83146
|
let unsubscribePromptActions = null, promptActionStartupSettled = !startupReadinessRequired, settlePromptActionStartup = () => {
|
|
83113
83147
|
}, rejectPromptActionStartup = () => {
|
|
83114
|
-
}, promptActionStartupTimer = null, promptActionStartupReady = startupReadinessRequired ? new Promise((
|
|
83148
|
+
}, promptActionStartupTimer = null, promptActionStartupReady = startupReadinessRequired ? new Promise((resolve29, reject) => {
|
|
83115
83149
|
settlePromptActionStartup = () => {
|
|
83116
|
-
promptActionStartupSettled || (promptActionStartupSettled = !0,
|
|
83150
|
+
promptActionStartupSettled || (promptActionStartupSettled = !0, resolve29());
|
|
83117
83151
|
}, rejectPromptActionStartup = (error) => {
|
|
83118
83152
|
promptActionStartupSettled || (promptActionStartupSettled = !0, reject(error));
|
|
83119
83153
|
}, promptActionStartupTimer = setTimeout(() => {
|
|
@@ -83428,9 +83462,9 @@ async function runOrchestrationShellSession(args) {
|
|
|
83428
83462
|
try {
|
|
83429
83463
|
let released = await Promise.race([
|
|
83430
83464
|
args.appsyncClient.releaseSessionWork(args.session.sessionId, { signal: controller.signal }),
|
|
83431
|
-
new Promise((
|
|
83465
|
+
new Promise((resolve29) => {
|
|
83432
83466
|
timer = setTimeout(() => {
|
|
83433
|
-
controller.abort(),
|
|
83467
|
+
controller.abort(), resolve29(null);
|
|
83434
83468
|
}, SESSION_WORK_RELEASE_TIMEOUT_MS), timer.unref?.();
|
|
83435
83469
|
})
|
|
83436
83470
|
]);
|
|
@@ -83611,8 +83645,8 @@ async function runOrchestrationShellSession(args) {
|
|
|
83611
83645
|
errorName: reason?.name ?? "Error"
|
|
83612
83646
|
});
|
|
83613
83647
|
}),
|
|
83614
|
-
new Promise((
|
|
83615
|
-
timer = setTimeout(
|
|
83648
|
+
new Promise((resolve29) => {
|
|
83649
|
+
timer = setTimeout(resolve29, SESSION_RETIRE_TIMEOUT_MS2), timer.unref?.();
|
|
83616
83650
|
})
|
|
83617
83651
|
]);
|
|
83618
83652
|
} finally {
|
|
@@ -83658,8 +83692,8 @@ async function runOrchestrationShellSession(args) {
|
|
|
83658
83692
|
disableBracketedPaste();
|
|
83659
83693
|
let teardownSweepAbort = new AbortController(), TEARDOWN_SWEEP_TIMEOUT_MS = 2e3, teardownSweepTimer = setTimeout(() => teardownSweepAbort.abort(), TEARDOWN_SWEEP_TIMEOUT_MS);
|
|
83660
83694
|
teardownSweepTimer.unref?.();
|
|
83661
|
-
let hardDeadline = new Promise((
|
|
83662
|
-
setTimeout(
|
|
83695
|
+
let hardDeadline = new Promise((resolve29) => {
|
|
83696
|
+
setTimeout(resolve29, SIGNAL_SHUTDOWN_TIMEOUT_MS + SESSION_RETIRE_TIMEOUT_MS2 + 500).unref?.();
|
|
83663
83697
|
}), teardownOperations = Promise.allSettled([
|
|
83664
83698
|
runPlannerTeardown("signal"),
|
|
83665
83699
|
reapOrphanShadows(/* @__PURE__ */ new Set(), {
|
|
@@ -84324,9 +84358,9 @@ function maybeFetchAndDispatchReviewSummary(event, envelope, store, reviewSummar
|
|
|
84324
84358
|
}
|
|
84325
84359
|
async function fetchAndDispatchReviewSummary(event, envelope, store, reviewSummaryFetcher) {
|
|
84326
84360
|
try {
|
|
84327
|
-
let abandoned = !1, timer, timeout = new Promise((
|
|
84361
|
+
let abandoned = !1, timer, timeout = new Promise((resolve29) => {
|
|
84328
84362
|
timer = setTimeout(() => {
|
|
84329
|
-
abandoned = !0,
|
|
84363
|
+
abandoned = !0, resolve29(null);
|
|
84330
84364
|
}, TASK_REVIEW_SUMMARY_FETCH_TIMEOUT_MS);
|
|
84331
84365
|
}), summary;
|
|
84332
84366
|
try {
|
|
@@ -84882,14 +84916,138 @@ function uniqueDetectedAgents(detected) {
|
|
|
84882
84916
|
item2 !== "CLAUDE" && item2 !== "CODEX" && item2 !== "ANTIGRAVITY" || out.includes(item2) || out.push(item2);
|
|
84883
84917
|
return out;
|
|
84884
84918
|
}
|
|
84885
|
-
|
|
84886
|
-
|
|
84919
|
+
var AGY_ADVISORY_LISTING_MAX_ENTRIES = 500, AGY_ADVISORY_LISTING_MAX_BYTES = 16384, AGY_ADVISORY_IGNORED_DIRS = /* @__PURE__ */ new Set([
|
|
84920
|
+
".git",
|
|
84921
|
+
"node_modules",
|
|
84922
|
+
"dist",
|
|
84923
|
+
"build",
|
|
84924
|
+
"coverage",
|
|
84925
|
+
"target",
|
|
84926
|
+
"venv",
|
|
84927
|
+
".venv",
|
|
84928
|
+
"__pycache__",
|
|
84929
|
+
"Pods",
|
|
84930
|
+
"DerivedData",
|
|
84931
|
+
".gradle",
|
|
84932
|
+
".idea",
|
|
84933
|
+
".next",
|
|
84934
|
+
".turbo",
|
|
84935
|
+
".cache",
|
|
84936
|
+
".gemini",
|
|
84937
|
+
".codevibe",
|
|
84938
|
+
".codevibe-audit",
|
|
84939
|
+
".codevibe-attachments",
|
|
84940
|
+
".agent-worktrees",
|
|
84941
|
+
".review-worktrees",
|
|
84942
|
+
".hard-gate",
|
|
84943
|
+
".dev-marketplace",
|
|
84944
|
+
".dev-marketplace-next"
|
|
84945
|
+
]), AGY_COMMAND_TOOL_SEATBELT_WARNING = "Your command tool cannot run in this sandbox: do not call it. CodeVibe listed the folder for you below (relative paths with '/' separator; literal backslashes escaped as \\\\, control characters escaped as \\xNN or \\uNNNN; a trailing / marks a folder). Read files with your file-reading tool, using absolute paths under the folder.";
|
|
84946
|
+
function sanitizeListingPath(relPath) {
|
|
84947
|
+
return relPath.replace(/\\/g, "\\\\").replace(/[\x00-\x1f\x7f]/g, (c) => `\\x${c.charCodeAt(0).toString(16).padStart(2, "0")}`).replace(/[\u0080-\u009f\u061c\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069\ufeff]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
84948
|
+
}
|
|
84949
|
+
function formatAgyWorkspaceListing(workdir, maxEntries = AGY_ADVISORY_LISTING_MAX_ENTRIES, maxBytes = AGY_ADVISORY_LISTING_MAX_BYTES) {
|
|
84950
|
+
try {
|
|
84951
|
+
if (!fs59.existsSync(workdir))
|
|
84952
|
+
return "Folder listing unavailable (directory does not exist)";
|
|
84953
|
+
if (!fs59.statSync(workdir).isDirectory())
|
|
84954
|
+
return "Folder listing unavailable (not a directory)";
|
|
84955
|
+
if (maxBytes <= 0 || maxEntries <= 0)
|
|
84956
|
+
return "Folder listing (listing omitted \u2014 prompt budget exhausted)";
|
|
84957
|
+
let entries = [], skippedTopLevel = [], totalBytes = 0, truncated = !1, hasUnreadableDirs = !1, queue = [""];
|
|
84958
|
+
for (; queue.length > 0 && !truncated; ) {
|
|
84959
|
+
let relDir = queue.shift(), absDir = relDir === "" ? workdir : path79.join(workdir, relDir), dir;
|
|
84960
|
+
try {
|
|
84961
|
+
dir = fs59.opendirSync(absDir);
|
|
84962
|
+
} catch (err) {
|
|
84963
|
+
if (relDir === "")
|
|
84964
|
+
return `Folder listing unavailable (directory unreadable: ${err?.code || (err instanceof Error ? err.message : String(err))})`;
|
|
84965
|
+
hasUnreadableDirs = !0;
|
|
84966
|
+
continue;
|
|
84967
|
+
}
|
|
84968
|
+
let dirEntries = [], dirScanLimit = maxEntries * 2;
|
|
84969
|
+
try {
|
|
84970
|
+
let entry5;
|
|
84971
|
+
for (; (entry5 = dir.readSync()) !== null; )
|
|
84972
|
+
if (dirEntries.push(entry5), dirEntries.length > dirScanLimit) {
|
|
84973
|
+
truncated = !0;
|
|
84974
|
+
break;
|
|
84975
|
+
}
|
|
84976
|
+
} catch (err) {
|
|
84977
|
+
if (relDir === "" && dirEntries.length === 0)
|
|
84978
|
+
return `Folder listing unavailable (directory unreadable: ${err?.code || (err instanceof Error ? err.message : String(err))})`;
|
|
84979
|
+
hasUnreadableDirs = !0;
|
|
84980
|
+
} finally {
|
|
84981
|
+
try {
|
|
84982
|
+
dir.closeSync();
|
|
84983
|
+
} catch {
|
|
84984
|
+
}
|
|
84985
|
+
}
|
|
84986
|
+
dirEntries.sort((a, b) => a.name.localeCompare(b.name));
|
|
84987
|
+
for (let entry5 of dirEntries) {
|
|
84988
|
+
let isDir = entry5.isDirectory(), isSymlinkToDir = !1;
|
|
84989
|
+
if (!isDir && entry5.isSymbolicLink())
|
|
84990
|
+
try {
|
|
84991
|
+
fs59.statSync(path79.join(absDir, entry5.name)).isDirectory() && (isSymlinkToDir = !0, isDir = !0);
|
|
84992
|
+
} catch {
|
|
84993
|
+
}
|
|
84994
|
+
if (entry5.name === ".git") {
|
|
84995
|
+
relDir === "" && skippedTopLevel.push(isDir ? ".git/" : ".git");
|
|
84996
|
+
continue;
|
|
84997
|
+
}
|
|
84998
|
+
if (isDir && AGY_ADVISORY_IGNORED_DIRS.has(entry5.name)) {
|
|
84999
|
+
relDir === "" && skippedTopLevel.push(`${entry5.name}/`);
|
|
85000
|
+
continue;
|
|
85001
|
+
}
|
|
85002
|
+
let rawRelPath = relDir === "" ? entry5.name : `${relDir}/${entry5.name}`, sanitizedRel = sanitizeListingPath(rawRelPath);
|
|
85003
|
+
if (entry5.isDirectory()) {
|
|
85004
|
+
let entryStr = `${sanitizedRel}/`, entryBytes = Buffer.byteLength(entryStr, "utf8") + 1;
|
|
85005
|
+
if (entries.length >= maxEntries || totalBytes + entryBytes > maxBytes) {
|
|
85006
|
+
truncated = !0;
|
|
85007
|
+
break;
|
|
85008
|
+
}
|
|
85009
|
+
entries.push(entryStr), totalBytes += entryBytes, queue.push(rawRelPath);
|
|
85010
|
+
} else if (isSymlinkToDir) {
|
|
85011
|
+
let entryStr = `${sanitizedRel}/`, entryBytes = Buffer.byteLength(entryStr, "utf8") + 1;
|
|
85012
|
+
if (entries.length >= maxEntries || totalBytes + entryBytes > maxBytes) {
|
|
85013
|
+
truncated = !0;
|
|
85014
|
+
break;
|
|
85015
|
+
}
|
|
85016
|
+
entries.push(entryStr), totalBytes += entryBytes;
|
|
85017
|
+
} else {
|
|
85018
|
+
let entryStr = sanitizedRel, entryBytes = Buffer.byteLength(entryStr, "utf8") + 1;
|
|
85019
|
+
if (entries.length >= maxEntries || totalBytes + entryBytes > maxBytes) {
|
|
85020
|
+
truncated = !0;
|
|
85021
|
+
break;
|
|
85022
|
+
}
|
|
85023
|
+
entries.push(entryStr), totalBytes += entryBytes;
|
|
85024
|
+
}
|
|
85025
|
+
}
|
|
85026
|
+
}
|
|
85027
|
+
if (entries.length === 0)
|
|
85028
|
+
return truncated ? "Folder listing (listing omitted \u2014 prompt budget exhausted)" : hasUnreadableDirs ? "Folder listing unavailable (directory unreadable)" : skippedTopLevel.length > 0 ? `Folder listing (0 entries listed, complete; not listed: ${skippedTopLevel.join(", ")}):
|
|
85029
|
+
(no other files found)` : `Folder listing (0 entries, complete):
|
|
85030
|
+
(no files found)`;
|
|
85031
|
+
let status = truncated ? "truncated" : hasUnreadableDirs ? "partial, some subdirectories unreadable" : "complete", notListedPart = skippedTopLevel.length > 0 ? `; not listed: ${skippedTopLevel.join(", ")}` : "";
|
|
85032
|
+
return `${`Folder listing (${entries.length} entries, ${status}${notListedPart}):`}
|
|
85033
|
+
${entries.join(`
|
|
85034
|
+
`)}`;
|
|
85035
|
+
} catch (err) {
|
|
85036
|
+
return `Folder listing unavailable (${err?.code || (err instanceof Error ? err.message : String(err))})`;
|
|
85037
|
+
}
|
|
85038
|
+
}
|
|
85039
|
+
function agyReadOnlyWorkdirPreamble(workdir, listing) {
|
|
85040
|
+
let parts = [
|
|
84887
85041
|
`You are reading the directory \`${workdir}\` (added to your workspace via --add-dir).`,
|
|
84888
85042
|
`Use absolute paths under \`${workdir}\` when you reference files.`,
|
|
84889
85043
|
"Do NOT use a relative 'current directory' \u2014 your process cwd is NOT the workspace.",
|
|
84890
|
-
"This is read-only advisory work: do not create, edit, delete, or move files."
|
|
84891
|
-
|
|
84892
|
-
|
|
85044
|
+
"This is read-only advisory work: do not create, edit, delete, or move files."
|
|
85045
|
+
];
|
|
85046
|
+
return listing !== void 0 && listing.length > 0 && parts.push(
|
|
85047
|
+
AGY_COMMAND_TOOL_SEATBELT_WARNING,
|
|
85048
|
+
"",
|
|
85049
|
+
listing
|
|
85050
|
+
), parts.push(""), parts.join(`
|
|
84893
85051
|
`);
|
|
84894
85052
|
}
|
|
84895
85053
|
function readOnlyAgentPrompt(args) {
|
|
@@ -84910,8 +85068,17 @@ function readOnlyAgentPrompt(args) {
|
|
|
84910
85068
|
args.advisoryBrief || args.intent.promptForPlanning || args.intent.rawMention,
|
|
84911
85069
|
""
|
|
84912
85070
|
].join(`
|
|
84913
|
-
`);
|
|
84914
|
-
|
|
85071
|
+
`), fullPrompt;
|
|
85072
|
+
if (args.agent === "ANTIGRAVITY" && args.allowRepositoryTools) {
|
|
85073
|
+
let basePreamble = agyReadOnlyWorkdirPreamble(args.workingDir), bodyBytes = Buffer.byteLength(body, "utf8"), basePreambleBytes = Buffer.byteLength(basePreamble, "utf8"), instructionPreambleText = `${AGY_COMMAND_TOOL_SEATBELT_WARNING}
|
|
85074
|
+
|
|
85075
|
+
`, instructionBytes = Buffer.byteLength(instructionPreambleText, "utf8"), totalScaffoldBytes = bodyBytes + basePreambleBytes + instructionBytes + 128 + 512, availableListingBytes = Math.max(0, 122880 - totalScaffoldBytes), maxListingBytes = Math.min(AGY_ADVISORY_LISTING_MAX_BYTES, availableListingBytes), listing;
|
|
85076
|
+
args.folderListing !== void 0 ? (listing = args.folderListing, Buffer.byteLength(listing, "utf8") > availableListingBytes && (listing = "Folder listing (listing omitted \u2014 prompt budget exhausted)")) : maxListingBytes >= 64 ? listing = formatAgyWorkspaceListing(args.workingDir, AGY_ADVISORY_LISTING_MAX_ENTRIES, maxListingBytes) : listing = "Folder listing (listing omitted \u2014 prompt budget exhausted)";
|
|
85077
|
+
let candidatePrompt = `${agyReadOnlyWorkdirPreamble(args.workingDir, listing)}${body}`;
|
|
85078
|
+
Buffer.byteLength(candidatePrompt, "utf8") <= 122880 ? fullPrompt = candidatePrompt : fullPrompt = `${basePreamble}${body}`;
|
|
85079
|
+
} else
|
|
85080
|
+
fullPrompt = body;
|
|
85081
|
+
return fullPrompt;
|
|
84915
85082
|
}
|
|
84916
85083
|
function readOnlyAdvisoryAllowsRepositoryTools(_input) {
|
|
84917
85084
|
return !0;
|
|
@@ -88879,8 +89046,8 @@ async function loadTrackBudgetForStatus(args) {
|
|
|
88879
89046
|
try {
|
|
88880
89047
|
let budget = await Promise.race([
|
|
88881
89048
|
args.appsyncClient.getTrackBudgetStatus(args.session.sessionId),
|
|
88882
|
-
new Promise((
|
|
88883
|
-
timer = setTimeout(() =>
|
|
89049
|
+
new Promise((resolve29) => {
|
|
89050
|
+
timer = setTimeout(() => resolve29(null), TRACK_BUDGET_STATUS_TIMEOUT_MS), timer.unref?.();
|
|
88884
89051
|
})
|
|
88885
89052
|
]);
|
|
88886
89053
|
if (budget && typeof args.quorumLoop.markQueuedTaskCancelled == "function")
|
|
@@ -89282,14 +89449,14 @@ var OllamaGemmaRunner = class {
|
|
|
89282
89449
|
};
|
|
89283
89450
|
|
|
89284
89451
|
// src/orchestration-shell/cli.ts
|
|
89285
|
-
var import_uuid18 = require("uuid"),
|
|
89452
|
+
var import_uuid18 = require("uuid"), fs67 = __toESM(require("fs"));
|
|
89286
89453
|
|
|
89287
89454
|
// src/orchestration-shell/doctor-cli.ts
|
|
89288
|
-
var
|
|
89455
|
+
var fs61 = __toESM(require("fs")), path80 = __toESM(require("path")), crypto32 = __toESM(require("crypto")), import_child_process7 = require("child_process");
|
|
89289
89456
|
init_detect_agents();
|
|
89290
89457
|
|
|
89291
89458
|
// src/auth/auth-service.ts
|
|
89292
|
-
var crypto31 = __toESM(require("crypto")),
|
|
89459
|
+
var crypto31 = __toESM(require("crypto")), fs60 = __toESM(require("fs")), http3 = __toESM(require("http")), import_child_process6 = require("child_process");
|
|
89293
89460
|
init_env_scrub();
|
|
89294
89461
|
init_logger2();
|
|
89295
89462
|
init_auth_telemetry();
|
|
@@ -89299,7 +89466,7 @@ async function bindOAuthServer(handler) {
|
|
|
89299
89466
|
for (let i = 0; i < PORT_RANGE_SIZE; i++) {
|
|
89300
89467
|
let port = PRIMARY_PORT + i;
|
|
89301
89468
|
try {
|
|
89302
|
-
let server = await new Promise((
|
|
89469
|
+
let server = await new Promise((resolve29, reject) => {
|
|
89303
89470
|
let s = http3.createServer(handler), onError = (err) => {
|
|
89304
89471
|
s.removeListener("listening", onListening), reject(err);
|
|
89305
89472
|
}, onListening = () => {
|
|
@@ -89309,7 +89476,7 @@ async function bindOAuthServer(handler) {
|
|
|
89309
89476
|
code: postErr?.code,
|
|
89310
89477
|
message: postErr?.message
|
|
89311
89478
|
});
|
|
89312
|
-
}),
|
|
89479
|
+
}), resolve29(s);
|
|
89313
89480
|
};
|
|
89314
89481
|
s.once("error", onError), s.once("listening", onListening), s.listen(port, "localhost");
|
|
89315
89482
|
});
|
|
@@ -89371,7 +89538,7 @@ var AuthService = class _AuthService {
|
|
|
89371
89538
|
isRunningInWSL() {
|
|
89372
89539
|
if (process.platform !== "linux") return !1;
|
|
89373
89540
|
try {
|
|
89374
|
-
let osRelease =
|
|
89541
|
+
let osRelease = fs60.readFileSync("/proc/sys/kernel/osrelease", "utf8");
|
|
89375
89542
|
return /microsoft|wsl/i.test(osRelease);
|
|
89376
89543
|
} catch {
|
|
89377
89544
|
return !1;
|
|
@@ -89532,14 +89699,14 @@ var AuthService = class _AuthService {
|
|
|
89532
89699
|
if (existing && !keychainManager.isTokenExpired(existing))
|
|
89533
89700
|
return existing;
|
|
89534
89701
|
let state = this.generateState();
|
|
89535
|
-
return new Promise((
|
|
89702
|
+
return new Promise((resolve29, reject) => {
|
|
89536
89703
|
let serverRef = {}, timeoutHandle = null, isResolved = !1, callbackInFlight = !1, forceCloseSockets = (srv) => {
|
|
89537
89704
|
srv.closeAllConnections?.();
|
|
89538
89705
|
}, cleanupAndResolve = (tokens) => {
|
|
89539
89706
|
if (isResolved) return;
|
|
89540
89707
|
isResolved = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null);
|
|
89541
89708
|
let srv = serverRef.server;
|
|
89542
|
-
srv ? (forceCloseSockets(srv), srv.close(() =>
|
|
89709
|
+
srv ? (forceCloseSockets(srv), srv.close(() => resolve29(tokens))) : resolve29(tokens);
|
|
89543
89710
|
}, cleanupAndReject = (err) => {
|
|
89544
89711
|
if (isResolved) return;
|
|
89545
89712
|
isResolved = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null);
|
|
@@ -89600,7 +89767,7 @@ var AuthService = class _AuthService {
|
|
|
89600
89767
|
</html>
|
|
89601
89768
|
`), isResolved = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null), setTimeout(() => {
|
|
89602
89769
|
let srv = serverRef.server;
|
|
89603
|
-
srv ? (forceCloseSockets(srv), srv.close(() =>
|
|
89770
|
+
srv ? (forceCloseSockets(srv), srv.close(() => resolve29(tokenData))) : resolve29(tokenData);
|
|
89604
89771
|
}, 500);
|
|
89605
89772
|
} catch (err) {
|
|
89606
89773
|
let safeMessage = String(err?.message || err).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -89640,12 +89807,12 @@ var AuthService = class _AuthService {
|
|
|
89640
89807
|
*/
|
|
89641
89808
|
async logout() {
|
|
89642
89809
|
let config = getConfig(), deleted = await keychainManager.deleteTokens(getEnvironment());
|
|
89643
|
-
return deleted && new Promise((
|
|
89810
|
+
return deleted && new Promise((resolve29) => {
|
|
89644
89811
|
let serverRef = {}, timeoutHandle = null, isCleanedUp = !1, cleanupAndResolve = (value) => {
|
|
89645
89812
|
if (isCleanedUp) return;
|
|
89646
89813
|
isCleanedUp = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null);
|
|
89647
89814
|
let srv = serverRef.server;
|
|
89648
|
-
srv ? (srv.closeAllConnections?.(), srv.close(() =>
|
|
89815
|
+
srv ? (srv.closeAllConnections?.(), srv.close(() => resolve29(value))) : resolve29(value);
|
|
89649
89816
|
};
|
|
89650
89817
|
(async () => {
|
|
89651
89818
|
try {
|
|
@@ -89865,9 +90032,9 @@ var colors = {
|
|
|
89865
90032
|
function probeAgentClis(env = process.env) {
|
|
89866
90033
|
return AGENT_SPECS.map(({ agent, command, name }) => {
|
|
89867
90034
|
let binPath;
|
|
89868
|
-
if (agent === "ANTIGRAVITY" && env.AGY_PATH &&
|
|
90035
|
+
if (agent === "ANTIGRAVITY" && env.AGY_PATH && fs61.existsSync(env.AGY_PATH))
|
|
89869
90036
|
try {
|
|
89870
|
-
|
|
90037
|
+
fs61.statSync(env.AGY_PATH).isFile() && (binPath = env.AGY_PATH);
|
|
89871
90038
|
} catch {
|
|
89872
90039
|
binPath = void 0;
|
|
89873
90040
|
}
|
|
@@ -89995,19 +90162,19 @@ async function probeBackendConnectivity(appsyncUrl) {
|
|
|
89995
90162
|
function readBoundedUtf8File(filePath, maxBytes) {
|
|
89996
90163
|
let fd;
|
|
89997
90164
|
try {
|
|
89998
|
-
let stat14 =
|
|
90165
|
+
let stat14 = fs61.statSync(filePath);
|
|
89999
90166
|
if (!stat14.isFile()) return { ok: !1, error: "not a regular file" };
|
|
90000
90167
|
if (stat14.size > maxBytes) return { ok: !1, error: `file exceeds ${maxBytes} byte limit (${stat14.size} bytes)` };
|
|
90001
90168
|
if (stat14.size === 0) return { ok: !1, error: "empty file (0 bytes)" };
|
|
90002
|
-
fd =
|
|
90003
|
-
let buf = Buffer.alloc(stat14.size), bytesRead =
|
|
90169
|
+
fd = fs61.openSync(filePath, "r");
|
|
90170
|
+
let buf = Buffer.alloc(stat14.size), bytesRead = fs61.readSync(fd, buf, 0, stat14.size, 0);
|
|
90004
90171
|
return { ok: !0, content: buf.subarray(0, bytesRead).toString("utf8") };
|
|
90005
90172
|
} catch (err) {
|
|
90006
90173
|
return { ok: !1, error: err.message };
|
|
90007
90174
|
} finally {
|
|
90008
90175
|
if (fd !== void 0)
|
|
90009
90176
|
try {
|
|
90010
|
-
|
|
90177
|
+
fs61.closeSync(fd);
|
|
90011
90178
|
} catch {
|
|
90012
90179
|
}
|
|
90013
90180
|
}
|
|
@@ -90133,8 +90300,8 @@ async function probeOrphanStatus(stateRoot, ownerRootOverride, shadowRootOverrid
|
|
|
90133
90300
|
scanErrors.push(`Exposure retention ${record2.marker.taskId}: ${err.message}`);
|
|
90134
90301
|
}
|
|
90135
90302
|
let ownerRoot = ownerRootOverride ?? resolveOwnerRoot({}, stateRoot), deadProcessOwnersCount = 0;
|
|
90136
|
-
if (
|
|
90137
|
-
let entries =
|
|
90303
|
+
if (fs61.existsSync(ownerRoot)) {
|
|
90304
|
+
let entries = fs61.readdirSync(ownerRoot, { withFileTypes: !0 });
|
|
90138
90305
|
for (let entry5 of entries) {
|
|
90139
90306
|
if (!entry5.isFile() || !/^owner-[0-9a-f-]{36}\.json$/i.test(entry5.name)) continue;
|
|
90140
90307
|
let readResult = readBoundedUtf8File(path80.join(ownerRoot, entry5.name), 4096);
|
|
@@ -90192,7 +90359,7 @@ function shadowStateRoot() {
|
|
|
90192
90359
|
function readRegistry(stateRoot) {
|
|
90193
90360
|
let file = path80.join(stateRoot, SHADOW_ROOT_REGISTRY_FILE), raw;
|
|
90194
90361
|
try {
|
|
90195
|
-
raw =
|
|
90362
|
+
raw = fs61.readFileSync(file, "utf8");
|
|
90196
90363
|
} catch {
|
|
90197
90364
|
return null;
|
|
90198
90365
|
}
|
|
@@ -90204,7 +90371,7 @@ function readRegistry(stateRoot) {
|
|
|
90204
90371
|
function collectMarkers(stateRoot) {
|
|
90205
90372
|
let index = /* @__PURE__ */ new Map(), taskDirs;
|
|
90206
90373
|
try {
|
|
90207
|
-
taskDirs =
|
|
90374
|
+
taskDirs = fs61.readdirSync(stateRoot, { withFileTypes: !0 });
|
|
90208
90375
|
} catch {
|
|
90209
90376
|
return index;
|
|
90210
90377
|
}
|
|
@@ -90212,7 +90379,7 @@ function collectMarkers(stateRoot) {
|
|
|
90212
90379
|
if (!taskDir.isDirectory() || taskDir.name.startsWith(".")) continue;
|
|
90213
90380
|
let dir = path80.join(stateRoot, taskDir.name), files;
|
|
90214
90381
|
try {
|
|
90215
|
-
files =
|
|
90382
|
+
files = fs61.readdirSync(dir);
|
|
90216
90383
|
} catch {
|
|
90217
90384
|
continue;
|
|
90218
90385
|
}
|
|
@@ -90220,8 +90387,8 @@ function collectMarkers(stateRoot) {
|
|
|
90220
90387
|
if (!SHADOW_STATE_FILE_RE.test(name) && !SHADOW_EXPOSURE_RETENTION_FILE_RE.test(name)) continue;
|
|
90221
90388
|
let file = path80.join(dir, name), marker;
|
|
90222
90389
|
try {
|
|
90223
|
-
if (
|
|
90224
|
-
marker = JSON.parse(
|
|
90390
|
+
if (fs61.statSync(file).size > MAX_STATE_MARKER_BYTES) continue;
|
|
90391
|
+
marker = JSON.parse(fs61.readFileSync(file, "utf8"));
|
|
90225
90392
|
} catch {
|
|
90226
90393
|
continue;
|
|
90227
90394
|
}
|
|
@@ -90237,19 +90404,19 @@ function inodeSurvivesInParent(root) {
|
|
|
90237
90404
|
if (!root.ino) return;
|
|
90238
90405
|
let parent = path80.dirname(root.path);
|
|
90239
90406
|
try {
|
|
90240
|
-
|
|
90407
|
+
fs61.lstatSync(parent);
|
|
90241
90408
|
} catch (err) {
|
|
90242
90409
|
return err.code === "ENOENT" ? !1 : void 0;
|
|
90243
90410
|
}
|
|
90244
90411
|
let entries;
|
|
90245
90412
|
try {
|
|
90246
|
-
entries =
|
|
90413
|
+
entries = fs61.readdirSync(parent);
|
|
90247
90414
|
} catch {
|
|
90248
90415
|
return;
|
|
90249
90416
|
}
|
|
90250
90417
|
for (let name of entries)
|
|
90251
90418
|
try {
|
|
90252
|
-
if (
|
|
90419
|
+
if (fs61.lstatSync(path80.join(parent, name), { bigint: !0 }).ino.toString() === root.ino) return !0;
|
|
90253
90420
|
} catch {
|
|
90254
90421
|
continue;
|
|
90255
90422
|
}
|
|
@@ -90260,7 +90427,7 @@ function diagnose(stateRoot, roots) {
|
|
|
90260
90427
|
return roots.map((root) => {
|
|
90261
90428
|
let markers = markerIndex.get(root.path) ?? [], present = !1;
|
|
90262
90429
|
try {
|
|
90263
|
-
present =
|
|
90430
|
+
present = fs61.lstatSync(root.path).isDirectory();
|
|
90264
90431
|
} catch {
|
|
90265
90432
|
present = !1;
|
|
90266
90433
|
}
|
|
@@ -90418,29 +90585,29 @@ ${colors.red}\u2717${colors.reset} ${withheld.length} entr${withheld.length ===
|
|
|
90418
90585
|
Nothing was written. Re-run with ${colors.bold}--yes${colors.reset} to apply${withheld.length ? " the entries listed first" : ""}.`), 0;
|
|
90419
90586
|
let locks = path80.join(stateRoot, SHADOW_QUOTA_LOCK_DIR), held = [];
|
|
90420
90587
|
try {
|
|
90421
|
-
held =
|
|
90588
|
+
held = fs61.readdirSync(locks);
|
|
90422
90589
|
} catch {
|
|
90423
90590
|
held = [];
|
|
90424
90591
|
}
|
|
90425
90592
|
if (held.length)
|
|
90426
90593
|
return console.error(`${colors.red}\u2717${colors.reset} A CodeVibe session is registering a root right now. Try again once it is idle.`), 1;
|
|
90427
|
-
let file = path80.join(stateRoot, SHADOW_ROOT_REGISTRY_FILE), current =
|
|
90594
|
+
let file = path80.join(stateRoot, SHADOW_ROOT_REGISTRY_FILE), current = fs61.readFileSync(file, "utf8");
|
|
90428
90595
|
if (crypto32.createHash("sha256").update(current).digest("hex") !== crypto32.createHash("sha256").update(registry.raw).digest("hex"))
|
|
90429
90596
|
return console.error(`${colors.red}\u2717${colors.reset} The registry changed while this ran. Nothing was written; re-run.`), 1;
|
|
90430
90597
|
let stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-"), backupDir = path80.join(path80.dirname(stateRoot), "shadow-root-backups", stamp), backup = path80.join(backupDir, "shadow-roots.json");
|
|
90431
90598
|
try {
|
|
90432
|
-
|
|
90599
|
+
fs61.mkdirSync(backupDir, { recursive: !0, mode: 448 }), fs61.copyFileSync(file, backup);
|
|
90433
90600
|
} catch (err) {
|
|
90434
90601
|
return console.error(`${colors.red}\u2717${colors.reset} Could not write the backup at ${backupDir} (${err.code ?? "unknown error"}). Nothing was changed \u2014 this command will not clear an entry it cannot restore.`), 1;
|
|
90435
90602
|
}
|
|
90436
90603
|
let removed = new Set(clearable.map((d) => d.root.path)), kept = registry.roots.filter((r) => !removed.has(r.path)), tmp = path80.join(backupDir, `.registry.next.${process.pid}`);
|
|
90437
90604
|
try {
|
|
90438
|
-
|
|
90605
|
+
fs61.writeFileSync(tmp, JSON.stringify({ version: 2, roots: kept }), { mode: 384 }), fs61.renameSync(tmp, file);
|
|
90439
90606
|
} catch (err) {
|
|
90440
90607
|
return console.error(`${colors.red}\u2717${colors.reset} Could not replace the registry (${err.code ?? "unknown error"}). Nothing was changed; a copy of it is at ${backup}.`), 1;
|
|
90441
90608
|
} finally {
|
|
90442
90609
|
try {
|
|
90443
|
-
|
|
90610
|
+
fs61.unlinkSync(tmp);
|
|
90444
90611
|
} catch {
|
|
90445
90612
|
}
|
|
90446
90613
|
}
|
|
@@ -90449,7 +90616,7 @@ ${colors.red}\u2717${colors.reset} ${withheld.length} entr${withheld.length ===
|
|
|
90449
90616
|
for (let marker of d.markers) {
|
|
90450
90617
|
let copy = path80.join(backupDir, `marker-${savedMarkers.length}-${path80.basename(marker)}`);
|
|
90451
90618
|
try {
|
|
90452
|
-
|
|
90619
|
+
fs61.copyFileSync(marker, copy), savedMarkers.push({ copy: path80.basename(copy), original: marker });
|
|
90453
90620
|
} catch (err) {
|
|
90454
90621
|
if (err.code !== "ENOENT") {
|
|
90455
90622
|
unbackedMarkers.push(marker);
|
|
@@ -90457,16 +90624,16 @@ ${colors.red}\u2717${colors.reset} ${withheld.length} entr${withheld.length ===
|
|
|
90457
90624
|
}
|
|
90458
90625
|
}
|
|
90459
90626
|
try {
|
|
90460
|
-
|
|
90627
|
+
fs61.unlinkSync(marker);
|
|
90461
90628
|
} catch {
|
|
90462
90629
|
}
|
|
90463
90630
|
try {
|
|
90464
|
-
|
|
90631
|
+
fs61.rmdirSync(path80.dirname(marker));
|
|
90465
90632
|
} catch {
|
|
90466
90633
|
}
|
|
90467
90634
|
}
|
|
90468
90635
|
try {
|
|
90469
|
-
|
|
90636
|
+
fs61.writeFileSync(path80.join(backupDir, "manifest.json"), `${JSON.stringify({
|
|
90470
90637
|
clearedAtUtc: (/* @__PURE__ */ new Date()).toISOString(),
|
|
90471
90638
|
registry: file,
|
|
90472
90639
|
registryBackup: path80.basename(backup),
|
|
@@ -90486,7 +90653,7 @@ ${colors.green}\u2713${colors.reset} Cleared ${clearable.length} entr${clearable
|
|
|
90486
90653
|
}
|
|
90487
90654
|
|
|
90488
90655
|
// src/substrate-launch/engage-substrate.ts
|
|
90489
|
-
var import_node_fs38 = require("node:fs"), os49 = __toESM(require("node:os")), path81 = __toESM(require("node:path"));
|
|
90656
|
+
var import_node_fs38 = require("node:fs"), os49 = __toESM(require("node:os")), path81 = __toESM(require("node:path")), crypto33 = __toESM(require("node:crypto"));
|
|
90490
90657
|
|
|
90491
90658
|
// src/credential-broker/types.ts
|
|
90492
90659
|
var BROKER_ROUTES = [
|
|
@@ -91714,9 +91881,9 @@ var LocalModelGatewayBroker = class {
|
|
|
91714
91881
|
let server = http4.createServer((req, res) => {
|
|
91715
91882
|
this.handleHttp(req, res);
|
|
91716
91883
|
});
|
|
91717
|
-
await new Promise((
|
|
91884
|
+
await new Promise((resolve29, reject) => {
|
|
91718
91885
|
server.once("error", reject), server.listen(0, "127.0.0.1", () => {
|
|
91719
|
-
server.removeListener("error", reject),
|
|
91886
|
+
server.removeListener("error", reject), resolve29();
|
|
91720
91887
|
});
|
|
91721
91888
|
});
|
|
91722
91889
|
let addr = server.address();
|
|
@@ -91760,7 +91927,7 @@ var LocalModelGatewayBroker = class {
|
|
|
91760
91927
|
}
|
|
91761
91928
|
if (await Promise.allSettled(survivors.map((r) => r.done)), this.upstreamKeys.clear(), this.credentialGeneration.clear(), this.inflightRefresh.clear(), this.tokenMinter.clear(), this.server) {
|
|
91762
91929
|
let server = this.server;
|
|
91763
|
-
this.server = null, this.boundAddr = null, await new Promise((
|
|
91930
|
+
this.server = null, this.boundAddr = null, await new Promise((resolve29) => server.close(() => resolve29()));
|
|
91764
91931
|
}
|
|
91765
91932
|
logger.info("[Broker] Stopped + zeroized upstream credentials", {
|
|
91766
91933
|
taskId: this.taskId
|
|
@@ -92329,9 +92496,9 @@ var LocalModelGatewayBroker = class {
|
|
|
92329
92496
|
return auth.slice(7).trim();
|
|
92330
92497
|
}
|
|
92331
92498
|
readBody(req) {
|
|
92332
|
-
return new Promise((
|
|
92499
|
+
return new Promise((resolve29, reject) => {
|
|
92333
92500
|
let chunks = [];
|
|
92334
|
-
req.on("data", (c) => chunks.push(c)), req.on("end", () =>
|
|
92501
|
+
req.on("data", (c) => chunks.push(c)), req.on("end", () => resolve29(Buffer.concat(chunks).toString("utf8"))), req.on("error", reject);
|
|
92335
92502
|
});
|
|
92336
92503
|
}
|
|
92337
92504
|
writeJson(res, status, body) {
|
|
@@ -92777,8 +92944,7 @@ async function engageSubstrate(input) {
|
|
|
92777
92944
|
}
|
|
92778
92945
|
}
|
|
92779
92946
|
var RESOLVER_AGENT_STATE_DIR_SEGMENTS = {
|
|
92780
|
-
GEMINI: [".gemini"]
|
|
92781
|
-
ANTIGRAVITY: [".gemini"]
|
|
92947
|
+
GEMINI: [".gemini"]
|
|
92782
92948
|
};
|
|
92783
92949
|
async function engageWriteConfinedResolverSandbox(input) {
|
|
92784
92950
|
let agentKind = input.agentKind;
|
|
@@ -92803,36 +92969,94 @@ async function engageWriteConfinedResolverSandbox(input) {
|
|
|
92803
92969
|
teardown: async () => {
|
|
92804
92970
|
}
|
|
92805
92971
|
};
|
|
92806
|
-
let homedir41 = os49.homedir(), stateDir =
|
|
92807
|
-
|
|
92808
|
-
|
|
92809
|
-
|
|
92810
|
-
|
|
92811
|
-
|
|
92812
|
-
|
|
92813
|
-
|
|
92814
|
-
|
|
92815
|
-
|
|
92816
|
-
|
|
92817
|
-
|
|
92972
|
+
let homedir41 = input.homedir ?? os49.homedir(), stateDir, privateHomeDir = null, spawnParentDir = null, spawnParentDirCreated = !1, env = {}, handle, finalEnv;
|
|
92973
|
+
if (agentKind === "ANTIGRAVITY") {
|
|
92974
|
+
let spawnId = input.spawnId ?? crypto33.randomUUID().slice(0, 8), taskSegment = input.taskId || "advisory";
|
|
92975
|
+
if (process.platform === "darwin")
|
|
92976
|
+
input.taskId ? (spawnParentDir = path81.join(homedir41, "Library", "Caches", "CodeVibe", "shadows", taskSegment, "agy-home", spawnId), privateHomeDir = spawnParentDir) : (spawnParentDir = path81.join(homedir41, "Library", "Caches", "CodeVibe", "shadows", `advisory-${spawnId}`), privateHomeDir = path81.join(spawnParentDir, "agy-home"));
|
|
92977
|
+
else {
|
|
92978
|
+
let cacheBase = process.env.XDG_CACHE_HOME || path81.join(homedir41, ".cache");
|
|
92979
|
+
input.taskId ? (spawnParentDir = path81.join(cacheBase, "codevibe", "shadows", taskSegment, "spawn", spawnId), privateHomeDir = path81.join(spawnParentDir, "home")) : (spawnParentDir = path81.join(cacheBase, "codevibe", "shadows", `advisory-${spawnId}`), privateHomeDir = path81.join(spawnParentDir, "home"));
|
|
92980
|
+
}
|
|
92981
|
+
stateDir = privateHomeDir, await import_node_fs38.promises.mkdir(path81.dirname(spawnParentDir), { recursive: !0 }), await import_node_fs38.promises.mkdir(spawnParentDir), spawnParentDirCreated = !0;
|
|
92982
|
+
try {
|
|
92983
|
+
let agyCliDir = path81.join(privateHomeDir, ".gemini", "antigravity-cli");
|
|
92984
|
+
await import_node_fs38.promises.mkdir(agyCliDir, { recursive: !0 });
|
|
92985
|
+
let hostAgyDir = path81.join(homedir41, ".gemini", "antigravity-cli"), tokenFile = path81.join(hostAgyDir, "antigravity-oauth-token"), idFile = path81.join(hostAgyDir, "installation_id");
|
|
92986
|
+
try {
|
|
92987
|
+
await import_node_fs38.promises.copyFile(tokenFile, path81.join(agyCliDir, "antigravity-oauth-token")), await import_node_fs38.promises.chmod(path81.join(agyCliDir, "antigravity-oauth-token"), 384);
|
|
92988
|
+
} catch {
|
|
92989
|
+
}
|
|
92990
|
+
try {
|
|
92991
|
+
await import_node_fs38.promises.copyFile(idFile, path81.join(agyCliDir, "installation_id")), await import_node_fs38.promises.chmod(path81.join(agyCliDir, "installation_id"), 384);
|
|
92992
|
+
} catch {
|
|
92993
|
+
}
|
|
92994
|
+
env.HOME = privateHomeDir;
|
|
92995
|
+
let nodeDir = process.execPath.slice(0, process.execPath.lastIndexOf("/"));
|
|
92996
|
+
env.PATH = `${SANDBOX_DEFAULT_PATH}:${nodeDir}`;
|
|
92997
|
+
let safeSource = input.localeSource ?? {};
|
|
92998
|
+
for (let key of SAFE_ENV_ALLOWLIST) {
|
|
92999
|
+
let v = safeSource[key];
|
|
93000
|
+
typeof v == "string" && v.length > 0 && (env[key] = v);
|
|
93001
|
+
}
|
|
93002
|
+
assertNoAmbientCreds(env), finalEnv = buildSubstrateImplementorEnv(input.role, env, input.processTreeId);
|
|
93003
|
+
let spec = {
|
|
93004
|
+
isolationTech: "sandbox_exec",
|
|
93005
|
+
workdir: input.workdir,
|
|
93006
|
+
...input.workdirAuthority ? { workdirAuthority: input.workdirAuthority } : {},
|
|
93007
|
+
hostBrokerAddr: "",
|
|
93008
|
+
sandboxBrokerUrl: "",
|
|
93009
|
+
taskId: input.taskId,
|
|
93010
|
+
sanitizedEnv: finalEnv,
|
|
93011
|
+
agentConfig: { hostDir: stateDir, sandboxDir: stateDir },
|
|
93012
|
+
networkPosture: "open",
|
|
93013
|
+
writableWorkdir: input.writableWorkdir !== !1
|
|
93014
|
+
};
|
|
93015
|
+
handle = await selection.substrate.launch(spec);
|
|
93016
|
+
} catch (launchErr) {
|
|
93017
|
+
let rollbackErrors = [];
|
|
93018
|
+
if (spawnParentDirCreated && spawnParentDir !== null)
|
|
93019
|
+
try {
|
|
93020
|
+
await import_node_fs38.promises.rm(spawnParentDir, { recursive: !0, force: !0 });
|
|
93021
|
+
} catch (rmErr) {
|
|
93022
|
+
rollbackErrors.push(rmErr);
|
|
93023
|
+
}
|
|
93024
|
+
if (rollbackErrors.length > 0) {
|
|
93025
|
+
let combinedError = new Error(
|
|
93026
|
+
`engageSubstrate initialization or launch failed and rollback failed: ${launchErr instanceof Error ? launchErr.message : String(launchErr)} (rollback: ${rollbackErrors.map((e) => e instanceof Error ? e.message : String(e)).join("; ")})`
|
|
93027
|
+
);
|
|
93028
|
+
throw combinedError.cause = launchErr, combinedError;
|
|
93029
|
+
}
|
|
93030
|
+
throw launchErr;
|
|
93031
|
+
}
|
|
93032
|
+
} else {
|
|
93033
|
+
stateDir = path81.join(
|
|
93034
|
+
homedir41,
|
|
93035
|
+
...RESOLVER_AGENT_STATE_DIR_SEGMENTS[agentKind]
|
|
93036
|
+
), await import_node_fs38.promises.mkdir(stateDir, { recursive: !0 }).catch(() => {
|
|
93037
|
+
}), env.HOME = homedir41;
|
|
93038
|
+
let nodeDir = process.execPath.slice(0, process.execPath.lastIndexOf("/"));
|
|
93039
|
+
env.PATH = `${SANDBOX_DEFAULT_PATH}:${nodeDir}`;
|
|
93040
|
+
let safeSource = input.localeSource ?? {};
|
|
93041
|
+
for (let key of SAFE_ENV_ALLOWLIST) {
|
|
93042
|
+
let v = safeSource[key];
|
|
93043
|
+
typeof v == "string" && v.length > 0 && (env[key] = v);
|
|
93044
|
+
}
|
|
93045
|
+
assertNoAmbientCreds(env), finalEnv = buildSubstrateImplementorEnv(input.role, env, input.processTreeId);
|
|
93046
|
+
let spec = {
|
|
93047
|
+
isolationTech: "sandbox_exec",
|
|
93048
|
+
workdir: input.workdir,
|
|
93049
|
+
...input.workdirAuthority ? { workdirAuthority: input.workdirAuthority } : {},
|
|
93050
|
+
hostBrokerAddr: "",
|
|
93051
|
+
sandboxBrokerUrl: "",
|
|
93052
|
+
taskId: input.taskId,
|
|
93053
|
+
sanitizedEnv: finalEnv,
|
|
93054
|
+
agentConfig: { hostDir: stateDir, sandboxDir: stateDir },
|
|
93055
|
+
networkPosture: "open",
|
|
93056
|
+
writableWorkdir: input.writableWorkdir !== !1
|
|
93057
|
+
};
|
|
93058
|
+
handle = await selection.substrate.launch(spec);
|
|
92818
93059
|
}
|
|
92819
|
-
assertNoAmbientCreds(env);
|
|
92820
|
-
let finalEnv = buildSubstrateImplementorEnv(input.role, env, input.processTreeId), spec = {
|
|
92821
|
-
isolationTech: "sandbox_exec",
|
|
92822
|
-
workdir: input.workdir,
|
|
92823
|
-
...input.workdirAuthority ? { workdirAuthority: input.workdirAuthority } : {},
|
|
92824
|
-
// No broker on this row — the addr/url fields are informational for A5
|
|
92825
|
-
// (the profile, not these strings, governs egress) and deliberately empty.
|
|
92826
|
-
hostBrokerAddr: "",
|
|
92827
|
-
sandboxBrokerUrl: "",
|
|
92828
|
-
taskId: input.taskId,
|
|
92829
|
-
sanitizedEnv: finalEnv,
|
|
92830
|
-
// The agent's own auth/state home — writable, read-granted (A5: sandbox fs
|
|
92831
|
-
// == host fs, so sandboxDir == hostDir).
|
|
92832
|
-
agentConfig: { hostDir: stateDir, sandboxDir: stateDir },
|
|
92833
|
-
networkPosture: "open",
|
|
92834
|
-
writableWorkdir: input.writableWorkdir !== !1
|
|
92835
|
-
}, handle = await selection.substrate.launch(spec);
|
|
92836
93060
|
return logger.info(
|
|
92837
93061
|
`[A1d] Resolver-confinement row engaged (tier=sandbox_exec, egress=open) \u2014 writes fenced to the disposable workspace; ${agentKind} runs on its own file-based auth (no broker)`,
|
|
92838
93062
|
{ taskId: input.taskId, agent: agentKind }
|
|
@@ -92850,8 +93074,18 @@ async function engageWriteConfinedResolverSandbox(input) {
|
|
|
92850
93074
|
refreshBrokerToken: async () => {
|
|
92851
93075
|
},
|
|
92852
93076
|
teardown: async () => {
|
|
92853
|
-
|
|
92854
|
-
|
|
93077
|
+
try {
|
|
93078
|
+
await handle.teardown();
|
|
93079
|
+
} catch (err) {
|
|
93080
|
+
throw logger.warn(
|
|
93081
|
+
"[engageSubstrate] resolver sandbox handle teardown failed, retaining state for recovery",
|
|
93082
|
+
{
|
|
93083
|
+
err,
|
|
93084
|
+
spawnParentDir
|
|
93085
|
+
}
|
|
93086
|
+
), err;
|
|
93087
|
+
}
|
|
93088
|
+
spawnParentDirCreated && spawnParentDir !== null && await import_node_fs38.promises.rm(spawnParentDir, { recursive: !0, force: !0 });
|
|
92855
93089
|
}
|
|
92856
93090
|
};
|
|
92857
93091
|
}
|
|
@@ -93370,7 +93604,7 @@ var LocalGemmaProcessRunner = class {
|
|
|
93370
93604
|
}
|
|
93371
93605
|
invoke(promptText, purpose, options) {
|
|
93372
93606
|
let responseFormat = options?.responseFormat ?? "json";
|
|
93373
|
-
return new Promise((
|
|
93607
|
+
return new Promise((resolve29, reject) => {
|
|
93374
93608
|
let stdout = "", stderr = "", settled = !1, terminalError = null, timeoutTimer, killTimer = null, child = (0, import_child_process8.spawn)(this.config.command, this.config.args, {
|
|
93375
93609
|
env: scrubSearchApiKeys({
|
|
93376
93610
|
...this.config.env,
|
|
@@ -93430,11 +93664,11 @@ var LocalGemmaProcessRunner = class {
|
|
|
93430
93664
|
return;
|
|
93431
93665
|
}
|
|
93432
93666
|
if (responseFormat === "text") {
|
|
93433
|
-
|
|
93667
|
+
resolve29(trimmed);
|
|
93434
93668
|
return;
|
|
93435
93669
|
}
|
|
93436
93670
|
try {
|
|
93437
|
-
|
|
93671
|
+
resolve29(enforceStrictJsonStdout(trimmed));
|
|
93438
93672
|
} catch (err) {
|
|
93439
93673
|
reject(err);
|
|
93440
93674
|
}
|
|
@@ -93535,12 +93769,12 @@ var FileSystemLocalModelStore = class {
|
|
|
93535
93769
|
}, defaultLocalModelStore = new FileSystemLocalModelStore();
|
|
93536
93770
|
async function fileDigest(pathname) {
|
|
93537
93771
|
let hash3 = (0, import_crypto19.createHash)("sha256"), bytes = 0;
|
|
93538
|
-
return await new Promise((
|
|
93772
|
+
return await new Promise((resolve29, reject) => {
|
|
93539
93773
|
let stream = (0, import_fs4.createReadStream)(pathname);
|
|
93540
93774
|
stream.on("data", (chunk) => {
|
|
93541
93775
|
let buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
93542
93776
|
bytes += buffer.byteLength, hash3.update(buffer);
|
|
93543
|
-
}), stream.on("error", reject), stream.on("end",
|
|
93777
|
+
}), stream.on("error", reject), stream.on("end", resolve29);
|
|
93544
93778
|
}), { sha256: hash3.digest("hex"), bytes };
|
|
93545
93779
|
}
|
|
93546
93780
|
function resolveRedirectUrl(currentUrl, location) {
|
|
@@ -93553,7 +93787,7 @@ function resolveRedirectUrl(currentUrl, location) {
|
|
|
93553
93787
|
}
|
|
93554
93788
|
}
|
|
93555
93789
|
async function downloadHttpsToFile(url, destinationPath, expectedBytes, redirectBudget = 3) {
|
|
93556
|
-
await new Promise((
|
|
93790
|
+
await new Promise((resolve29, reject) => {
|
|
93557
93791
|
let req = import_https2.default.get(url, (res) => {
|
|
93558
93792
|
let status = res.statusCode ?? 0;
|
|
93559
93793
|
if ([301, 302, 303, 307, 308].includes(status)) {
|
|
@@ -93563,7 +93797,7 @@ async function downloadHttpsToFile(url, destinationPath, expectedBytes, redirect
|
|
|
93563
93797
|
reject(new Error("local Gemma download redirect was invalid or exceeded the limit"));
|
|
93564
93798
|
return;
|
|
93565
93799
|
}
|
|
93566
|
-
downloadHttpsToFile(redirected, destinationPath, expectedBytes, redirectBudget - 1).then(
|
|
93800
|
+
downloadHttpsToFile(redirected, destinationPath, expectedBytes, redirectBudget - 1).then(resolve29).catch(reject);
|
|
93567
93801
|
return;
|
|
93568
93802
|
}
|
|
93569
93803
|
if (status !== 200) {
|
|
@@ -93591,7 +93825,7 @@ async function downloadHttpsToFile(url, destinationPath, expectedBytes, redirect
|
|
|
93591
93825
|
`local Gemma download exceeded pinned bytes ${expectedBytes}`
|
|
93592
93826
|
)
|
|
93593
93827
|
);
|
|
93594
|
-
}), (0, import_promises3.pipeline)(res, file).then(() =>
|
|
93828
|
+
}), (0, import_promises3.pipeline)(res, file).then(() => resolve29()).catch(reject);
|
|
93595
93829
|
});
|
|
93596
93830
|
req.on("error", reject), req.setTimeout(3e4, () => {
|
|
93597
93831
|
req.destroy(new Error("local Gemma download timed out"));
|
|
@@ -93609,7 +93843,7 @@ var defaultLocalModelDownloadTransport = {
|
|
|
93609
93843
|
this.stallTimeoutMs = stallTimeoutMs;
|
|
93610
93844
|
}
|
|
93611
93845
|
pull(model, localOllamaHost, onProgress) {
|
|
93612
|
-
return new Promise((
|
|
93846
|
+
return new Promise((resolve29, reject) => {
|
|
93613
93847
|
let env = scrubSearchApiKeys({ ...process.env });
|
|
93614
93848
|
localOllamaHost ? env.OLLAMA_HOST = localOllamaHost : delete env.OLLAMA_HOST;
|
|
93615
93849
|
let resolvedCommand = this.command || process.env.CODEVIBE_OLLAMA_COMMAND || DEFAULT_OLLAMA_COMMAND, child = this.spawnPull(resolvedCommand, ["pull", model], {
|
|
@@ -93645,7 +93879,7 @@ var defaultLocalModelDownloadTransport = {
|
|
|
93645
93879
|
}), child.on("close", (code, signal) => {
|
|
93646
93880
|
if (timer && clearTimeout(timer), !stalled) {
|
|
93647
93881
|
if (code === 0) {
|
|
93648
|
-
|
|
93882
|
+
resolve29();
|
|
93649
93883
|
return;
|
|
93650
93884
|
}
|
|
93651
93885
|
reject(
|
|
@@ -94340,8 +94574,8 @@ async function retireUnownedAdmittedSession(appsyncClient, sessionId) {
|
|
|
94340
94574
|
try {
|
|
94341
94575
|
await Promise.race([
|
|
94342
94576
|
appsyncClient.updateSession({ sessionId, status: "INACTIVE" /* INACTIVE */, ...cleanExit }),
|
|
94343
|
-
new Promise((
|
|
94344
|
-
timer = setTimeout(
|
|
94577
|
+
new Promise((resolve29) => {
|
|
94578
|
+
timer = setTimeout(resolve29, SESSION_RETIRE_TIMEOUT_MS), timer.unref?.();
|
|
94345
94579
|
})
|
|
94346
94580
|
]);
|
|
94347
94581
|
} catch (err) {
|
|
@@ -94636,10 +94870,10 @@ Run \`codevibe vendor-key setup\`` + (checksCodex ? " (or `codevibe vendor-key i
|
|
|
94636
94870
|
async function promptInstallLocalModel() {
|
|
94637
94871
|
let rl = require("readline").createInterface({ input: process.stdin, output: process.stdout });
|
|
94638
94872
|
try {
|
|
94639
|
-
let trimmed = (await new Promise((
|
|
94873
|
+
let trimmed = (await new Promise((resolve29) => {
|
|
94640
94874
|
rl.question(
|
|
94641
94875
|
"Orchestration Mode needs the local model (~7GB), which isn't installed. Install it now? [Y/n]: ",
|
|
94642
|
-
|
|
94876
|
+
resolve29
|
|
94643
94877
|
);
|
|
94644
94878
|
})).trim().toLowerCase();
|
|
94645
94879
|
return trimmed === "" || trimmed.startsWith("y");
|
|
@@ -94742,7 +94976,7 @@ Note: --export will overwrite any existing file at <path>.
|
|
|
94742
94976
|
offset: parsed.offset
|
|
94743
94977
|
});
|
|
94744
94978
|
if (result.kind === "ok" && parsed.exportPath) {
|
|
94745
|
-
let writeFile4 = deps?.writeFileFn ?? ((p, c) =>
|
|
94979
|
+
let writeFile4 = deps?.writeFileFn ?? ((p, c) => fs67.writeFileSync(p, c, "utf8"));
|
|
94746
94980
|
try {
|
|
94747
94981
|
let formatted = formatAuditExport(
|
|
94748
94982
|
result.model,
|