@quantiya/codevibe-core 2.0.79 → 2.0.81
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 +7 -1
- package/dist/appsync/index.d.ts +2 -0
- package/dist/appsync/sync-mobile-echo.d.ts +9 -0
- package/dist/appsync/sync-source-cursor.d.ts +14 -0
- package/dist/appsync/sync-source-file.d.ts +15 -0
- package/dist/appsync/sync-source-pair.d.ts +2 -1
- package/dist/appsync/sync-source-recovery.d.ts +35 -0
- 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 +4 -1
- package/dist/index.js +517 -517
- package/dist/orchestration-shell/cli.js +370 -213
- package/dist/tool-activity/replay-cursor.d.ts +11 -1
- 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() {
|
|
@@ -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);
|
|
@@ -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");
|
|
@@ -8927,7 +8943,15 @@ var import_zod = require("zod"), MAX_SYNC_SOURCE_ANCHOR_BYTES = 64 * 1024, count
|
|
|
8927
8943
|
anchor,
|
|
8928
8944
|
reason: import_zod.z.enum(["BACKLOG_LIMIT", "OVERSIZED_RECORD", "PARTIAL_RECORD", "MALFORMED_RECORD", "EMPTY_RECORD"]),
|
|
8929
8945
|
discardUntilNewline: import_zod.z.boolean()
|
|
8930
|
-
}).strict().refine((value) => value.endOffset > value.startOffset && value.anchor.endOffset === value.endOffset && value.anchor.startOffset >= value.startOffset && (!value.discardUntilNewline || ["BACKLOG_LIMIT", "OVERSIZED_RECORD", "PARTIAL_RECORD"].includes(value.reason))), position = import_zod.z.object({ byteOffset: count2, anchor: anchor.nullable(), discardUntilNewline: import_zod.z.boolean() }).strict().refine((value) => value.byteOffset === 0 ? value.anchor === null && !value.discardUntilNewline : value.anchor?.endOffset === value.byteOffset)
|
|
8946
|
+
}).strict().refine((value) => value.endOffset > value.startOffset && value.anchor.endOffset === value.endOffset && value.anchor.startOffset >= value.startOffset && (!value.discardUntilNewline || ["BACKLOG_LIMIT", "OVERSIZED_RECORD", "PARTIAL_RECORD"].includes(value.reason))), position = import_zod.z.object({ byteOffset: count2, anchor: anchor.nullable(), discardUntilNewline: import_zod.z.boolean() }).strict().refine((value) => value.byteOffset === 0 ? value.anchor === null && !value.discardUntilNewline : value.anchor?.endOffset === value.byteOffset);
|
|
8947
|
+
function validSourceRebase(previous, target2, skipped) {
|
|
8948
|
+
return position.safeParse({
|
|
8949
|
+
byteOffset: previous.byteOffset,
|
|
8950
|
+
anchor: previous.anchor,
|
|
8951
|
+
discardUntilNewline: previous.discardUntilNewline
|
|
8952
|
+
}).success && previous.byteOffset > 0 && anchor.safeParse(target2).success && typeof skipped == "boolean";
|
|
8953
|
+
}
|
|
8954
|
+
var frameAnchor = (value) => value.anchor ?? {
|
|
8931
8955
|
startOffset: value.startOffset,
|
|
8932
8956
|
endOffset: value.endOffset,
|
|
8933
8957
|
sha256: value.sourceSha256
|
|
@@ -9039,6 +9063,26 @@ function createSourceJournal(options) {
|
|
|
9039
9063
|
row3.byteOffset = next.endOffset, row3.anchor = next.anchor, row3.discardUntilNewline = next.discardUntilNewline, row3.skippedBytes += next.endOffset - next.startOffset, row3.lastGap = next, row3.lastFrame = null, row3.projection = null, await write(row3, assertOwnership);
|
|
9040
9064
|
});
|
|
9041
9065
|
},
|
|
9066
|
+
rebase: async (previous, target2, skippedHistory, recordedAt, recoveryProjection = null) => {
|
|
9067
|
+
if (!validSourceRebase(previous, target2, skippedHistory) || !Number.isSafeInteger(recordedAt) || recordedAt < 1 || !projection.safeParse(recoveryProjection).success) return options.invalid();
|
|
9068
|
+
await options.locked(async (assertOwnership) => {
|
|
9069
|
+
await recoverLocked(assertOwnership);
|
|
9070
|
+
let row3 = await required(), occurrence = `rebase:${previous.byteOffset}:${previous.anchor.sha256}:${Number(skippedHistory)}:${recordedAt}`;
|
|
9071
|
+
if (row3.lastFrame?.occurrence === occurrence && row3.byteOffset === target2.endOffset && JSON.stringify(row3.anchor) === JSON.stringify(target2))
|
|
9072
|
+
return row3.projection !== recoveryProjection ? options.invalid() : void 0;
|
|
9073
|
+
if (row3.entries.length) throw Error("SYNC_SOURCE_RECOVERY_PENDING");
|
|
9074
|
+
if (row3.byteOffset !== previous.byteOffset || row3.discardUntilNewline !== previous.discardUntilNewline || JSON.stringify(row3.anchor) !== JSON.stringify(previous.anchor)) return options.invalid();
|
|
9075
|
+
if (row3.skippedBytes > target2.endOffset) throw Error("SYNC_SOURCE_RECOVERY_UNAVAILABLE");
|
|
9076
|
+
row3.byteOffset = target2.endOffset, row3.anchor = { ...target2 }, row3.discardUntilNewline = !1, row3.lastGap = null, row3.projection = recoveryProjection, row3.lastFrame = {
|
|
9077
|
+
...stream,
|
|
9078
|
+
occurrence,
|
|
9079
|
+
sourceSha256: target2.sha256,
|
|
9080
|
+
startOffset: target2.startOffset,
|
|
9081
|
+
endOffset: target2.endOffset,
|
|
9082
|
+
anchor: { ...target2 }
|
|
9083
|
+
}, await write(row3, assertOwnership);
|
|
9084
|
+
});
|
|
9085
|
+
},
|
|
9042
9086
|
recover: () => options.locked(recoverLocked),
|
|
9043
9087
|
drain: (maximum = 64, signal) => options.drainLocked(async () => {
|
|
9044
9088
|
if (!Number.isSafeInteger(maximum) || maximum < 1 || maximum > 256) return options.invalid();
|
|
@@ -9063,6 +9107,23 @@ function createSourceJournal(options) {
|
|
|
9063
9107
|
function createSourcePair(options) {
|
|
9064
9108
|
let { source: source2, lanes, laneStreams } = options, recover = async () => {
|
|
9065
9109
|
for (let lane of lanes) await lane.recover();
|
|
9110
|
+
}, rebaseMarker = (row3) => /^rebase:([1-9][0-9]*):([a-f0-9]{64}):([01]):([1-9][0-9]*)$/.exec(row3.lastFrame?.occurrence ?? ""), finishRebase = async () => {
|
|
9111
|
+
let rows = await Promise.all(lanes.map((lane) => lane.load())), candidates = [];
|
|
9112
|
+
for (let index2 of [0, 1]) {
|
|
9113
|
+
let row4 = rows[index2];
|
|
9114
|
+
if (!row4) continue;
|
|
9115
|
+
let marker2 = rebaseMarker(row4);
|
|
9116
|
+
if (!marker2) continue;
|
|
9117
|
+
let peer2 = rows[1 - index2];
|
|
9118
|
+
if (!peer2) return options.invalid();
|
|
9119
|
+
row4.byteOffset === peer2.byteOffset && JSON.stringify(row4.anchor) === JSON.stringify(peer2.anchor) && row4.projection === peer2.projection && row4.lastFrame?.occurrence === peer2.lastFrame?.occurrence || peer2.byteOffset === Number(marker2[1]) && peer2.anchor?.sha256 === marker2[2] && candidates.push({ index: index2, marker: marker2 });
|
|
9120
|
+
}
|
|
9121
|
+
if (!candidates.length) return;
|
|
9122
|
+
if (candidates.sort((a, b) => Number(b.marker[4]) - Number(a.marker[4])), candidates.length > 1 && candidates[0].marker[4] === candidates[1].marker[4])
|
|
9123
|
+
throw Error("SYNC_SOURCE_RECOVERY_UNAVAILABLE");
|
|
9124
|
+
let { index, marker } = candidates[0], row3 = rows[index], peer = rows[1 - index];
|
|
9125
|
+
if (row3.entries.length || peer.entries.length) throw Error("SYNC_SOURCE_RECOVERY_PENDING");
|
|
9126
|
+
await lanes[1 - index].rebase(position2(peer), row3.anchor, marker[3] === "1", Number(marker[4]), row3.projection);
|
|
9066
9127
|
}, position2 = (row3) => ({
|
|
9067
9128
|
byteOffset: row3.byteOffset,
|
|
9068
9129
|
anchor: row3.anchor ? { ...row3.anchor } : null,
|
|
@@ -9070,14 +9131,33 @@ function createSourcePair(options) {
|
|
|
9070
9131
|
}), earliest = (rows) => {
|
|
9071
9132
|
let ordered = [...rows].sort((a, b) => a.byteOffset - b.byteOffset);
|
|
9072
9133
|
if (ordered.length === 2 && ordered[0].byteOffset === ordered[1].byteOffset && JSON.stringify(position2(ordered[0])) !== JSON.stringify(position2(ordered[1]))) return options.invalid();
|
|
9073
|
-
let baseline = position2(ordered[0]), pending2 = rows.flatMap((row3) =>
|
|
9074
|
-
|
|
9134
|
+
let baseline = position2(ordered[0]), pending2 = rows.flatMap((row3) => {
|
|
9135
|
+
let frames = row3.entries.filter((entry5) => entry5.state === "PREPARING" && entry5.frame.startOffset === baseline.byteOffset).map((entry5) => entry5.frame);
|
|
9136
|
+
return row3.byteOffset > baseline.byteOffset && row3.lastFrame && !rebaseMarker(row3) && row3.lastFrame.startOffset === baseline.byteOffset && row3.lastFrame.endOffset === row3.byteOffset && frames.push(row3.lastFrame), frames.map((frame3) => ({
|
|
9137
|
+
startOffset: frame3.startOffset,
|
|
9138
|
+
endOffset: frame3.endOffset,
|
|
9139
|
+
sourceSha256: frame3.sourceSha256
|
|
9140
|
+
}));
|
|
9141
|
+
});
|
|
9142
|
+
if (pending2.some((value) => JSON.stringify(value) !== JSON.stringify(pending2[0]))) return options.invalid();
|
|
9143
|
+
let marker = rebaseMarker(ordered[0]);
|
|
9144
|
+
return {
|
|
9145
|
+
...baseline,
|
|
9146
|
+
...pending2.length && { pendingFrameEndOffset: pending2[0].endOffset, pendingFrame: pending2[0] },
|
|
9147
|
+
...marker && { recovered: {
|
|
9148
|
+
previousOffset: Number(marker[1]),
|
|
9149
|
+
boundaryOffset: baseline.byteOffset,
|
|
9150
|
+
skippedHistory: marker[3] === "1",
|
|
9151
|
+
recordedAt: Number(marker[4]),
|
|
9152
|
+
projection: ordered[0].projection
|
|
9153
|
+
} }
|
|
9154
|
+
};
|
|
9075
9155
|
};
|
|
9076
9156
|
return Object.freeze({
|
|
9077
9157
|
open: (initial, validateInitial) => {
|
|
9078
9158
|
let snapshot2 = typeof initial == "number" ? initial : position2(initial);
|
|
9079
9159
|
return options.locked(async () => {
|
|
9080
|
-
await recover();
|
|
9160
|
+
await recover(), await finishRebase();
|
|
9081
9161
|
let present = (await Promise.all(lanes.map((lane) => lane.load()))).filter((row3) => row3 !== null);
|
|
9082
9162
|
if (present.length === 1 && (present[0].lastFrame !== null || present[0].entries.length !== 0 || present[0].skippedBytes !== 0 || present[0].projection !== null))
|
|
9083
9163
|
return options.invalid();
|
|
@@ -9092,8 +9172,14 @@ function createSourcePair(options) {
|
|
|
9092
9172
|
let snapshot2 = { ...frame3, ...frame3.anchor && { anchor: { ...frame3.anchor } } }, factories = [...prepare];
|
|
9093
9173
|
return options.locked(async () => {
|
|
9094
9174
|
let result = [null, null];
|
|
9095
|
-
for (let index of [0, 1])
|
|
9096
|
-
|
|
9175
|
+
for (let index of [0, 1]) {
|
|
9176
|
+
let row3 = await lanes[index].load();
|
|
9177
|
+
result[index] = await lanes[index].admit(
|
|
9178
|
+
{ ...snapshot2, streamSha256: laneStreams[index] },
|
|
9179
|
+
factories[index],
|
|
9180
|
+
row3 && rebaseMarker(row3) ? null : void 0
|
|
9181
|
+
);
|
|
9182
|
+
}
|
|
9097
9183
|
return result;
|
|
9098
9184
|
});
|
|
9099
9185
|
},
|
|
@@ -9104,6 +9190,20 @@ function createSourcePair(options) {
|
|
|
9104
9190
|
for (let lane of lanes) await lane.skip(snapshot2);
|
|
9105
9191
|
});
|
|
9106
9192
|
},
|
|
9193
|
+
rebase: async (previous, target2, skippedHistory, recoveryProjection = null) => {
|
|
9194
|
+
if (!validSourceRebase(previous, target2, skippedHistory)) return options.invalid();
|
|
9195
|
+
let before = position2(previous), next = { ...target2 };
|
|
9196
|
+
return options.locked(async () => {
|
|
9197
|
+
await recover(), await finishRebase();
|
|
9198
|
+
let rows = await Promise.all(lanes.map((lane) => lane.load()));
|
|
9199
|
+
if (rows.some((row3) => !row3)) return options.invalid();
|
|
9200
|
+
if (rows.some((row3) => row3.entries.length || JSON.stringify(position2(row3)) !== JSON.stringify(before)))
|
|
9201
|
+
throw Error("SYNC_SOURCE_RECOVERY_PENDING");
|
|
9202
|
+
let recordedAt = Math.max(Date.now(), ...rows.map((row3) => Number(rebaseMarker(row3)?.[4] ?? 0) + 1));
|
|
9203
|
+
for (let lane of lanes) await lane.rebase(before, next, skippedHistory, recordedAt, recoveryProjection);
|
|
9204
|
+
return earliest(await Promise.all(lanes.map(async (lane) => await lane.load())));
|
|
9205
|
+
});
|
|
9206
|
+
},
|
|
9107
9207
|
recover: () => options.locked(recover),
|
|
9108
9208
|
drain: async (maximumPerLane = 64, signal) => {
|
|
9109
9209
|
let count4 = 0, failure2, failed = !1;
|
|
@@ -10166,7 +10266,19 @@ var import_zod6 = require("zod"), import_node_crypto11 = require("node:crypto"),
|
|
|
10166
10266
|
sessionGenerationId: uuid7,
|
|
10167
10267
|
provider: import_zod6.z.enum(["codex", "claude", "agy"]),
|
|
10168
10268
|
entries: import_zod6.z.array(entry3).max(64)
|
|
10169
|
-
}).strict(), normalize = (text2, mode) => mode === "trim" ? text2.trim() : text2.replace(/\s+/g, " ").trim(), tokenFor = (target2) => (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify(target2)).digest("hex")
|
|
10269
|
+
}).strict(), normalize = (text2, mode) => mode === "trim" ? text2.trim() : text2.replace(/\s+/g, " ").trim(), tokenFor = (target2) => (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify(target2)).digest("hex"), omissionPlan = import_zod6.z.object({
|
|
10270
|
+
kind: import_zod6.z.literal("omitted-echoes-v1"),
|
|
10271
|
+
ownerSha256: hash2,
|
|
10272
|
+
matches: import_zod6.z.array(import_zod6.z.tuple([hash2, hash2, hash2])).max(64)
|
|
10273
|
+
}).strict(), ownerHash = (row3) => (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify([
|
|
10274
|
+
row3.operationId,
|
|
10275
|
+
row3.sessionId,
|
|
10276
|
+
row3.sessionGenerationId,
|
|
10277
|
+
row3.provider
|
|
10278
|
+
])).digest("hex"), reservationHash = (e) => (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify({ ...e, claim: null, claimedEchoSha256: null })).digest("hex"), matchesText = (e, content, nativeMs) => {
|
|
10279
|
+
let normalized = normalize(content, e.normalization);
|
|
10280
|
+
return nativeMs >= Math.floor(e.armedAt / e.clockPrecisionMs) * e.clockPrecisionMs && nativeMs <= e.expiresAt && (e.normalized === normalized || e.allowSuffix && normalized.length >= 16 && normalized.length / e.normalized.length >= 0.35 && e.normalized.endsWith(normalized));
|
|
10281
|
+
};
|
|
10170
10282
|
function decodeMobileEcho(value) {
|
|
10171
10283
|
let parsed = row2.parse(value);
|
|
10172
10284
|
if (new Set(parsed.entries.map((e) => e.token)).size !== parsed.entries.length || parsed.entries.some((e) => e.token !== tokenFor(e.target))) throw Error("SYNC_MOBILE_ECHO_INVALID");
|
|
@@ -10196,6 +10308,31 @@ function createMobileEchoJournal(options) {
|
|
|
10196
10308
|
row3.entries.push(snapshot2), await save();
|
|
10197
10309
|
});
|
|
10198
10310
|
},
|
|
10311
|
+
planOmitted: (records) => options.mutate(async (row3) => {
|
|
10312
|
+
let eligible = row3.entries.filter((e) => !e.claim), used = /* @__PURE__ */ new Set(), proofs = /* @__PURE__ */ new Set(), matches2 = [];
|
|
10313
|
+
if (eligible.length) for (let record2 of records) {
|
|
10314
|
+
hash2.parse(record2.sourceSha256);
|
|
10315
|
+
let nativeMs = Date.parse(record2.timestamp);
|
|
10316
|
+
if (!Number.isFinite(nativeMs) || proofs.has(record2.sourceSha256)) continue;
|
|
10317
|
+
let match = eligible.find((e) => !used.has(e.token) && matchesText(e, record2.content, nativeMs));
|
|
10318
|
+
if (match && (used.add(match.token), proofs.add(record2.sourceSha256), matches2.push([match.token, reservationHash(match), record2.sourceSha256])), used.size === eligible.length) break;
|
|
10319
|
+
}
|
|
10320
|
+
let plan = JSON.stringify({ kind: "omitted-echoes-v1", ownerSha256: ownerHash(row3), matches: matches2 });
|
|
10321
|
+
if (Buffer.byteLength(plan) > 16384) throw Error("SYNC_MOBILE_ECHO_INVALID");
|
|
10322
|
+
return plan;
|
|
10323
|
+
}),
|
|
10324
|
+
settleOmitted: (value) => {
|
|
10325
|
+
if (Buffer.byteLength(value) > 16384) throw Error("SYNC_MOBILE_ECHO_INVALID");
|
|
10326
|
+
let plan = omissionPlan.parse(JSON.parse(value)), tokens = new Set(plan.matches.map((m) => m[0])), proofs = new Set(plan.matches.map((m) => m[2]));
|
|
10327
|
+
if (tokens.size !== plan.matches.length || proofs.size !== plan.matches.length) throw Error("SYNC_MOBILE_ECHO_INVALID");
|
|
10328
|
+
return options.mutate(async (row3, save) => {
|
|
10329
|
+
if (ownerHash(row3) !== plan.ownerSha256) throw Error("SYNC_MOBILE_ECHO_INVALID");
|
|
10330
|
+
let exact2 = new Map(plan.matches.map(([token4, fingerprint2]) => [token4, fingerprint2])), before = row3.entries.length;
|
|
10331
|
+
row3.entries = row3.entries.filter((e) => e.claim || exact2.get(e.token) !== reservationHash(e));
|
|
10332
|
+
let count4 = before - row3.entries.length;
|
|
10333
|
+
return count4 && await save(), count4;
|
|
10334
|
+
});
|
|
10335
|
+
},
|
|
10199
10336
|
claim: (value, content, timestamp5) => {
|
|
10200
10337
|
let next = frame2.parse(value), echoHash = (e) => (0, import_node_crypto11.createHash)("sha256").update(normalize(content, e.normalization)).digest("hex"), nativeMs = Date.parse(timestamp5);
|
|
10201
10338
|
if (!Number.isFinite(nativeMs)) throw Error("SYNC_MOBILE_ECHO_TIMESTAMP_INVALID");
|
|
@@ -10203,10 +10340,7 @@ function createMobileEchoJournal(options) {
|
|
|
10203
10340
|
let claimed = row3.entries.find((e) => e.claim?.streamSha256 === next.streamSha256 && e.claim?.occurrence === next.occurrence);
|
|
10204
10341
|
if (claimed)
|
|
10205
10342
|
return JSON.stringify(claimed.claim) !== JSON.stringify(next) || claimed.claimedEchoSha256 !== echoHash(claimed) ? options.collision() : !0;
|
|
10206
|
-
let pending2 = row3.entries.find((e) =>
|
|
10207
|
-
let normalized = normalize(content, e.normalization);
|
|
10208
|
-
return !e.claim && nativeMs >= Math.floor(e.armedAt / e.clockPrecisionMs) * e.clockPrecisionMs && nativeMs <= e.expiresAt && (e.normalized === normalized || e.allowSuffix && normalized.length >= 16 && normalized.length / e.normalized.length >= 0.35 && e.normalized.endsWith(normalized));
|
|
10209
|
-
});
|
|
10343
|
+
let pending2 = row3.entries.find((e) => !e.claim && matchesText(e, content, nativeMs));
|
|
10210
10344
|
return pending2 ? (pending2.claim = next, pending2.claimedEchoSha256 = echoHash(pending2), await save(), !0) : !1;
|
|
10211
10345
|
});
|
|
10212
10346
|
},
|
|
@@ -10882,8 +11016,8 @@ var sourceCursorId = (scope, stream) => stableUuid("codevibe-sync-source-cursor-
|
|
|
10882
11016
|
* serializes original callers and restarted owners without holding the
|
|
10883
11017
|
* account store lock across network awaits. Only an exact ACK permits removal.
|
|
10884
11018
|
* Admission closure/PAUSED does not authorize dropping pending control work. */
|
|
10885
|
-
async runPromptResolution(value,
|
|
10886
|
-
if (typeof
|
|
11019
|
+
async runPromptResolution(value, resolve29, options = {}) {
|
|
11020
|
+
if (typeof resolve29 != "function") return invalid7();
|
|
10887
11021
|
let input = snapshotSyncPromptResolution(value), id5 = input.clientOperationId, expected = decodePromptResolution({ schemaVersion: 1, kind: "PROMPT_RESOLUTION", operationId: id5, input }, this.options.userId, invalid7);
|
|
10888
11022
|
if (!this.matchesPromptResolutionScope(input)) return invalid7();
|
|
10889
11023
|
this.options.assertAccount(), await this.ensureDirectory();
|
|
@@ -10903,7 +11037,7 @@ var sourceCursorId = (scope, stream) => stableUuid("codevibe-sync-source-cursor-
|
|
|
10903
11037
|
let sealed = this.seal(expected, key);
|
|
10904
11038
|
return await this.checkCapacity(Buffer.byteLength(sealed), id5 + ".resolution"), await this.write(id5, sealed, ".resolution"), expected;
|
|
10905
11039
|
});
|
|
10906
|
-
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) => {
|
|
10907
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));
|
|
10908
11042
|
}), await fence(), !0) : !0;
|
|
10909
11043
|
} finally {
|
|
@@ -11631,6 +11765,7 @@ var sourceCursorId = (scope, stream) => stableUuid("codevibe-sync-source-cursor-
|
|
|
11631
11765
|
lockDir: path19.join(this.directory, name),
|
|
11632
11766
|
ownerlessGraceMs: 1 / 0,
|
|
11633
11767
|
maxWaitMs: 2e3,
|
|
11768
|
+
role: name === "store.lockdir" ? "sync-journal-store" : "sync-journal",
|
|
11634
11769
|
requireRemovalOnRelease
|
|
11635
11770
|
});
|
|
11636
11771
|
}
|
|
@@ -11849,8 +11984,8 @@ var count3 = import_zod9.z.string().regex(/^(0|[1-9][0-9]{0,18})$/).refine((s) =
|
|
|
11849
11984
|
if (this.starting) return this.starting;
|
|
11850
11985
|
if (this.phase !== "new") return Promise.reject(failure());
|
|
11851
11986
|
this.phase = "opening";
|
|
11852
|
-
let ready = new Promise((
|
|
11853
|
-
this.resolveReady =
|
|
11987
|
+
let ready = new Promise((resolve29, reject) => {
|
|
11988
|
+
this.resolveReady = resolve29, this.rejectReady = reject;
|
|
11854
11989
|
});
|
|
11855
11990
|
return ready.catch(() => {
|
|
11856
11991
|
}), this.starting = Promise.resolve().then(async () => {
|
|
@@ -12108,9 +12243,9 @@ var count3 = import_zod9.z.string().regex(/^(0|[1-9][0-9]{0,18})$/).refine((s) =
|
|
|
12108
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);
|
|
12109
12244
|
let ws = this.ws;
|
|
12110
12245
|
this.ws = void 0;
|
|
12111
|
-
let socketClosed = new Promise((
|
|
12246
|
+
let socketClosed = new Promise((resolve29) => {
|
|
12112
12247
|
if (!ws || ws.readyState === import_ws.default.CLOSED) {
|
|
12113
|
-
|
|
12248
|
+
resolve29();
|
|
12114
12249
|
return;
|
|
12115
12250
|
}
|
|
12116
12251
|
ws.removeAllListeners(), ws.on("error", () => {
|
|
@@ -12119,7 +12254,7 @@ var count3 = import_zod9.z.string().regex(/^(0|[1-9][0-9]{0,18})$/).refine((s) =
|
|
|
12119
12254
|
ws.terminate();
|
|
12120
12255
|
}, 5e3);
|
|
12121
12256
|
timer.unref?.(), ws.once("close", () => {
|
|
12122
|
-
clearTimeout(timer),
|
|
12257
|
+
clearTimeout(timer), resolve29();
|
|
12123
12258
|
});
|
|
12124
12259
|
try {
|
|
12125
12260
|
ws.close(1e3);
|
|
@@ -12874,6 +13009,7 @@ var RESERVED_STATE_FILES = /* @__PURE__ */ new Set(["ledger.json", "legacy-owned
|
|
|
12874
13009
|
if (!identity.isDirectory() || identity.isSymbolicLink() || typeof process.getuid == "function" && identity.uid !== process.getuid()) throw new Error("Tool sync directory invalid");
|
|
12875
13010
|
let owner = await createOAuthAccountLock({
|
|
12876
13011
|
lockDir: path22.join(dir, ".sync-recovery.lockdir"),
|
|
13012
|
+
role: "tool-sync-recovery",
|
|
12877
13013
|
ownerlessGraceMs: 1 / 0,
|
|
12878
13014
|
maxWaitMs: 2e3,
|
|
12879
13015
|
requireRemovalOnRelease: !0
|
|
@@ -13335,8 +13471,8 @@ var DecisionAttemptReceiptStore = class _DecisionAttemptReceiptStore {
|
|
|
13335
13471
|
return path23.join(path23.resolve(this.rootDir), opaqueSegment(sessionId));
|
|
13336
13472
|
}
|
|
13337
13473
|
async withSessionLock(sessionId, operation) {
|
|
13338
|
-
let key = this.sessionQueueKey(sessionId), prior = _DecisionAttemptReceiptStore.sessionQueues.get(key) ?? Promise.resolve(), release, gate = new Promise((
|
|
13339
|
-
release =
|
|
13474
|
+
let key = this.sessionQueueKey(sessionId), prior = _DecisionAttemptReceiptStore.sessionQueues.get(key) ?? Promise.resolve(), release, gate = new Promise((resolve29) => {
|
|
13475
|
+
release = resolve29;
|
|
13340
13476
|
}), tail = prior.then(() => gate);
|
|
13341
13477
|
_DecisionAttemptReceiptStore.sessionQueues.set(key, tail), await prior;
|
|
13342
13478
|
try {
|
|
@@ -13975,6 +14111,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
13975
14111
|
this.syncRegistrations = /* @__PURE__ */ new Map();
|
|
13976
14112
|
// MARK: - Heartbeat
|
|
13977
14113
|
this.heartbeatTimers = /* @__PURE__ */ new Map();
|
|
14114
|
+
this.heartbeatReadiness = /* @__PURE__ */ new Map();
|
|
13978
14115
|
/** Identity tokens invalidate in-flight pulses when a session is stopped. */
|
|
13979
14116
|
this.heartbeatTokens = /* @__PURE__ */ new Map();
|
|
13980
14117
|
/** Shared initial confirmation makes duplicate start calls idempotent. */
|
|
@@ -14087,9 +14224,9 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14087
14224
|
if (signal?.aborted) throw _AppSyncClient.abortReason(signal);
|
|
14088
14225
|
}
|
|
14089
14226
|
static async waitForSyncStateRetry(delayMs, signal) {
|
|
14090
|
-
_AppSyncClient.throwIfAborted(signal), await new Promise((
|
|
14227
|
+
_AppSyncClient.throwIfAborted(signal), await new Promise((resolve29, reject) => {
|
|
14091
14228
|
let timer = setTimeout(() => {
|
|
14092
|
-
signal?.removeEventListener("abort", onAbort),
|
|
14229
|
+
signal?.removeEventListener("abort", onAbort), resolve29();
|
|
14093
14230
|
}, delayMs), onAbort = () => {
|
|
14094
14231
|
clearTimeout(timer), signal?.removeEventListener("abort", onAbort), reject(_AppSyncClient.abortReason(signal));
|
|
14095
14232
|
};
|
|
@@ -14137,7 +14274,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14137
14274
|
* the operation itself settles.
|
|
14138
14275
|
*/
|
|
14139
14276
|
static awaitSharedFlightForCaller(flight, signal) {
|
|
14140
|
-
return signal ? (_AppSyncClient.throwIfAborted(signal), new Promise((
|
|
14277
|
+
return signal ? (_AppSyncClient.throwIfAborted(signal), new Promise((resolve29, reject) => {
|
|
14141
14278
|
let settled = !1, finish = (operation) => {
|
|
14142
14279
|
settled || (settled = !0, signal.removeEventListener("abort", onAbort), operation());
|
|
14143
14280
|
}, onAbort = () => {
|
|
@@ -14148,7 +14285,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14148
14285
|
return;
|
|
14149
14286
|
}
|
|
14150
14287
|
flight.then(
|
|
14151
|
-
(value) => finish(() =>
|
|
14288
|
+
(value) => finish(() => resolve29(value)),
|
|
14152
14289
|
(error) => finish(() => reject(error))
|
|
14153
14290
|
);
|
|
14154
14291
|
})) : flight;
|
|
@@ -14486,7 +14623,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14486
14623
|
owned2.promise.then(settled, settled);
|
|
14487
14624
|
}
|
|
14488
14625
|
let owned = flight;
|
|
14489
|
-
return owned.waiters++, new Promise((
|
|
14626
|
+
return owned.waiters++, new Promise((resolve29, reject) => {
|
|
14490
14627
|
let finished = !1, finish = (error) => {
|
|
14491
14628
|
if (!finished) {
|
|
14492
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")));
|
|
@@ -14494,7 +14631,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
14494
14631
|
if (check(), error !== void 0) throw error;
|
|
14495
14632
|
let state = this.companionSyncStatusSnapshot(userId);
|
|
14496
14633
|
if (!state) throw new SyncEventClientError("INVALID_SYNC_STATE");
|
|
14497
|
-
|
|
14634
|
+
resolve29(state);
|
|
14498
14635
|
} catch (failure2) {
|
|
14499
14636
|
reject(failure2);
|
|
14500
14637
|
}
|
|
@@ -15191,8 +15328,8 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
15191
15328
|
* its existing domain authority to obtain a validated resolution ACK. This
|
|
15192
15329
|
* method grants no backend authority and creates no new visible occurrence.
|
|
15193
15330
|
* False, thrown or account-switched acknowledgements retain the source. */
|
|
15194
|
-
resolvePromptPublication(value,
|
|
15195
|
-
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))
|
|
15196
15333
|
return Promise.reject(new SyncEventClientError("INVALID_SYNC_INPUT"));
|
|
15197
15334
|
let input = { ...value }, { root, signal } = options, userId = this.getCurrentUserId(), check = () => {
|
|
15198
15335
|
this.assertSyncAccount(userId), _AppSyncClient.throwIfAborted(signal);
|
|
@@ -15203,7 +15340,7 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
15203
15340
|
let journals = records.map((scope) => this.desktopSyncWriter({ root, sessionScope: scope }).promptPublication(input.promptId));
|
|
15204
15341
|
for (let journal of journals)
|
|
15205
15342
|
await journal.settle(signal), check();
|
|
15206
|
-
let acknowledged = await
|
|
15343
|
+
let acknowledged = await resolve29(records.length > 0);
|
|
15207
15344
|
if (check(), acknowledged !== !0) return !1;
|
|
15208
15345
|
for (let journal of journals)
|
|
15209
15346
|
await journal.close(), check();
|
|
@@ -15623,16 +15760,16 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
15623
15760
|
/**
|
|
15624
15761
|
* Update a session
|
|
15625
15762
|
*/
|
|
15626
|
-
async updateSession(input) {
|
|
15763
|
+
async updateSession(input, options = {}) {
|
|
15627
15764
|
if (input.status === void 0)
|
|
15628
|
-
return this.doUpdateSession(input);
|
|
15629
|
-
let
|
|
15630
|
-
}).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));
|
|
15631
15768
|
return this.statusWriteChains.set(input.sessionId, next.catch(() => {
|
|
15632
15769
|
})), next;
|
|
15633
15770
|
}
|
|
15634
|
-
async doUpdateSession(input) {
|
|
15635
|
-
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([
|
|
15636
15773
|
this.joinSyncSubscriptionClosures(input.sessionId),
|
|
15637
15774
|
...[...this.syncReadOwners.get(input.sessionId) ?? []].map((reader) => reader.close())
|
|
15638
15775
|
]));
|
|
@@ -15641,12 +15778,12 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
15641
15778
|
metadata: input.metadata ? JSON.stringify(input.metadata) : void 0
|
|
15642
15779
|
}, response;
|
|
15643
15780
|
try {
|
|
15644
|
-
response = await this.graphqlRequest(mutations.updateSession, { input: preparedInput });
|
|
15781
|
+
response = await this.graphqlRequest(mutations.updateSession, { input: preparedInput }, !1, void 0, expectedUserId);
|
|
15645
15782
|
} catch (error) {
|
|
15646
15783
|
if (!hasCleanExitFields(preparedInput) || !isUnknownCleanExitFieldError(error)) throw error;
|
|
15647
15784
|
logger.warn("[AppSyncClient] Server rejected the P61 clean-exit fields; retrying without them", {
|
|
15648
15785
|
sessionId: input.sessionId
|
|
15649
|
-
}), response = await this.graphqlRequest(mutations.updateSession, { input: withoutCleanExitFields(preparedInput) });
|
|
15786
|
+
}), response = await this.graphqlRequest(mutations.updateSession, { input: withoutCleanExitFields(preparedInput) }, !1, void 0, expectedUserId);
|
|
15650
15787
|
}
|
|
15651
15788
|
logger.debug("[AppSyncClient] Session updated", { sessionId: response.data.updateSession.sessionId });
|
|
15652
15789
|
let session2 = response.data.updateSession;
|
|
@@ -18300,6 +18437,13 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
18300
18437
|
cleanupApplyUserDecisionWatcherState(state) {
|
|
18301
18438
|
state.destroyed = !0, this.cancelReconnectReconciliationWait(state), state.reconnectTimer && (clearTimeout(state.reconnectTimer), state.reconnectTimer = void 0), state.keepAliveTimer && (clearTimeout(state.keepAliveTimer), state.keepAliveTimer = void 0), state.ws && (disposeWatcherSocket(state.ws, state.subscriptionId), state.ws = null);
|
|
18302
18439
|
}
|
|
18440
|
+
/** Local producer health, not a quota/transport flag. Reconnect must not
|
|
18441
|
+
* advertise readiness while the owning transcript reader is degraded. */
|
|
18442
|
+
setHeartbeatReadiness(sessionId, ready) {
|
|
18443
|
+
return this.heartbeatReadiness.set(sessionId, ready), () => {
|
|
18444
|
+
this.heartbeatReadiness.get(sessionId) === ready && this.heartbeatReadiness.delete(sessionId);
|
|
18445
|
+
};
|
|
18446
|
+
}
|
|
18303
18447
|
/**
|
|
18304
18448
|
* Start periodic heartbeat for a session.
|
|
18305
18449
|
* Updates lastHeartbeatAt on the session every intervalMs (default 2 minutes).
|
|
@@ -18382,6 +18526,11 @@ var AppSyncClient = class _AppSyncClient {
|
|
|
18382
18526
|
*/
|
|
18383
18527
|
async sendHeartbeat(sessionId, token4) {
|
|
18384
18528
|
if (this.heartbeatTokens.get(sessionId) !== token4) return "stopped";
|
|
18529
|
+
try {
|
|
18530
|
+
if (this.heartbeatReadiness.get(sessionId)?.() === !1) return "stopped";
|
|
18531
|
+
} catch {
|
|
18532
|
+
return "stopped";
|
|
18533
|
+
}
|
|
18385
18534
|
try {
|
|
18386
18535
|
let heartbeatAt = (/* @__PURE__ */ new Date()).toISOString(), refreshed = await this.updateSession({
|
|
18387
18536
|
sessionId,
|
|
@@ -18750,6 +18899,14 @@ async function updateMobileInputStatus(update, event, status) {
|
|
|
18750
18899
|
return receipt2;
|
|
18751
18900
|
}
|
|
18752
18901
|
|
|
18902
|
+
// src/appsync/sync-source-recovery.ts
|
|
18903
|
+
var DEFAULT_SYNC_SOURCE_RECOVERY_POLICY = Object.freeze({
|
|
18904
|
+
staleAfterMs: 5 * 6e4,
|
|
18905
|
+
maximumRecentMessages: 20,
|
|
18906
|
+
anchorSearchBytes: 8 * 1024 * 1024,
|
|
18907
|
+
maximumScanBytes: 64 * 1024 * 1024
|
|
18908
|
+
});
|
|
18909
|
+
|
|
18753
18910
|
// src/appsync/sync-source-file.ts
|
|
18754
18911
|
var CHUNK = 64 * 1024;
|
|
18755
18912
|
|
|
@@ -19187,7 +19344,7 @@ async function prepareSessionEncryption(sessionId, appSyncClient, logger2) {
|
|
|
19187
19344
|
sessionId,
|
|
19188
19345
|
attempt: attempt + 1,
|
|
19189
19346
|
delayMs
|
|
19190
|
-
}), await new Promise((
|
|
19347
|
+
}), await new Promise((resolve29) => setTimeout(resolve29, delayMs));
|
|
19191
19348
|
}
|
|
19192
19349
|
}
|
|
19193
19350
|
if (serviceDeviceKeys.length === 0)
|
|
@@ -20849,8 +21006,8 @@ function finishedResumeMessage(predecessorSessionId, successorSessionId) {
|
|
|
20849
21006
|
async function publishThenRetire(args) {
|
|
20850
21007
|
let { deps } = args, preview = args.encryptedLastPrompt ? { encryptedLastPrompt: args.encryptedLastPrompt } : {}, note = { successorSessionId: args.successorSessionId, predecessorSessionId: args.predecessorSessionId, marker: args.marker, ...preview };
|
|
20851
21008
|
try {
|
|
20852
|
-
let timer, drained = deps.drain(args.successorSessionId).then(() => !0, () => !1), timedOut = new Promise((
|
|
20853
|
-
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?.();
|
|
20854
21011
|
}), ok = await Promise.race([drained, timedOut]);
|
|
20855
21012
|
return timer && clearTimeout(timer), ok ? (await deps.updateSession({
|
|
20856
21013
|
sessionId: args.successorSessionId,
|
|
@@ -21361,22 +21518,22 @@ function ResumeChoice(props) {
|
|
|
21361
21518
|
}
|
|
21362
21519
|
async function runResumePicker(rows) {
|
|
21363
21520
|
let { ink } = getInkRuntime();
|
|
21364
|
-
return new Promise((
|
|
21521
|
+
return new Promise((resolve29) => {
|
|
21365
21522
|
let instance = null, done = (value) => {
|
|
21366
|
-
instance?.unmount(),
|
|
21523
|
+
instance?.unmount(), resolve29(value);
|
|
21367
21524
|
};
|
|
21368
21525
|
instance = ink.render(React.createElement(ResumePicker, { rows, onSelect: (id5) => done(id5), onCancel: () => done(null) }));
|
|
21369
21526
|
});
|
|
21370
21527
|
}
|
|
21371
21528
|
async function runResumeChoice(prompt, continueLabel) {
|
|
21372
21529
|
let { ink } = getInkRuntime();
|
|
21373
|
-
return new Promise((
|
|
21530
|
+
return new Promise((resolve29) => {
|
|
21374
21531
|
let instance = null;
|
|
21375
21532
|
instance = ink.render(React.createElement(ResumeChoice, {
|
|
21376
21533
|
prompt,
|
|
21377
21534
|
...continueLabel ? { continueLabel } : {},
|
|
21378
21535
|
onChoose: (value) => {
|
|
21379
|
-
instance?.unmount(),
|
|
21536
|
+
instance?.unmount(), resolve29(value);
|
|
21380
21537
|
}
|
|
21381
21538
|
}));
|
|
21382
21539
|
});
|
|
@@ -21487,8 +21644,8 @@ CodeVibe \u2014 choose mode (${tier} tier):
|
|
|
21487
21644
|
`), process.stdout.write(` \x1B[36m[1]\x1B[0m \x1B[1mCompanion\x1B[0m \x1B[2m(route to local agent wrapper)\x1B[0m
|
|
21488
21645
|
`), process.stdout.write(` \x1B[35m[2]\x1B[0m \x1B[1mOrchestration\x1B[0m \x1B[2m(CodeVibe-owned shell)\x1B[0m
|
|
21489
21646
|
`)); ; ) {
|
|
21490
|
-
let promptStr = plain6 ? "Mode [1/2]: " : "\x1B[36mMode [1/2]: \x1B[0m", trimmed = (await new Promise((
|
|
21491
|
-
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);
|
|
21492
21649
|
})).trim();
|
|
21493
21650
|
if (trimmed === "1" || trimmed.toLowerCase() === "companion") return "companion";
|
|
21494
21651
|
if (trimmed === "2" || trimmed.toLowerCase() === "orchestration") return "orchestration";
|
|
@@ -22366,7 +22523,7 @@ function requestOllamaJson(config, pathname, body, opts) {
|
|
|
22366
22523
|
let err = new Error("Ollama request aborted by signal");
|
|
22367
22524
|
return err.name = "AbortError", Promise.reject(err);
|
|
22368
22525
|
}
|
|
22369
|
-
return new Promise((
|
|
22526
|
+
return new Promise((resolve29, reject) => {
|
|
22370
22527
|
let settled = !1, responseBytes = 0, responseBody = "", finish = (fn) => {
|
|
22371
22528
|
settled || (settled = !0, clearTimeout(timeout), fn());
|
|
22372
22529
|
}, req = chooseHttpClient(url).request(
|
|
@@ -22393,7 +22550,7 @@ function requestOllamaJson(config, pathname, body, opts) {
|
|
|
22393
22550
|
}
|
|
22394
22551
|
responseBody += decoder.write(chunk);
|
|
22395
22552
|
}), res.on("end", () => {
|
|
22396
|
-
responseBody += decoder.end(), finish(() =>
|
|
22553
|
+
responseBody += decoder.end(), finish(() => resolve29(responseBody));
|
|
22397
22554
|
});
|
|
22398
22555
|
}
|
|
22399
22556
|
), timeout = setTimeout(() => {
|
|
@@ -22533,7 +22690,7 @@ function requestOllamaGenerateStream(config, promptText, opts) {
|
|
|
22533
22690
|
num_ctx: numCtx
|
|
22534
22691
|
}
|
|
22535
22692
|
}), url = new URL("/api/generate", config.host), timeoutMs = opts?.timeoutMs ?? config.timeoutMs;
|
|
22536
|
-
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) => {
|
|
22537
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 = () => {
|
|
22538
22695
|
idleTimer && (clearTimeout(idleTimer), idleTimer = null);
|
|
22539
22696
|
}, finish = (fn) => {
|
|
@@ -22557,7 +22714,7 @@ function requestOllamaGenerateStream(config, promptText, opts) {
|
|
|
22557
22714
|
visibleChars: out.text.length,
|
|
22558
22715
|
idleMs: streamIdleCutoffMs,
|
|
22559
22716
|
chunks
|
|
22560
|
-
}), finish(() =>
|
|
22717
|
+
}), finish(() => resolve29(out)), activeRes?.destroy());
|
|
22561
22718
|
}, streamIdleCutoffMs);
|
|
22562
22719
|
}, handleLine = (line, res) => {
|
|
22563
22720
|
if (settled) return;
|
|
@@ -22590,14 +22747,14 @@ function requestOllamaGenerateStream(config, promptText, opts) {
|
|
|
22590
22747
|
return;
|
|
22591
22748
|
}
|
|
22592
22749
|
if (lastDone = chunk.done, chunk.done === !0) {
|
|
22593
|
-
sawDone = !0, finish(() =>
|
|
22750
|
+
sawDone = !0, finish(() => resolve29(out));
|
|
22594
22751
|
return;
|
|
22595
22752
|
}
|
|
22596
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", {
|
|
22597
22754
|
visibleChars: out.text.length,
|
|
22598
22755
|
emptyRun,
|
|
22599
22756
|
chunks
|
|
22600
|
-
}), finish(() =>
|
|
22757
|
+
}), finish(() => resolve29(out)), res.destroy());
|
|
22601
22758
|
}, req = chooseHttpClient(url).request(
|
|
22602
22759
|
url,
|
|
22603
22760
|
{
|
|
@@ -22639,7 +22796,7 @@ function requestOllamaGenerateStream(config, promptText, opts) {
|
|
|
22639
22796
|
);
|
|
22640
22797
|
return;
|
|
22641
22798
|
}
|
|
22642
|
-
finish(() =>
|
|
22799
|
+
finish(() => resolve29(out));
|
|
22643
22800
|
}
|
|
22644
22801
|
}));
|
|
22645
22802
|
}
|
|
@@ -22669,7 +22826,7 @@ function describeRecordError(value) {
|
|
|
22669
22826
|
function requestOllamaPull(config, onProgress = () => {
|
|
22670
22827
|
}, options) {
|
|
22671
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;
|
|
22672
|
-
return new Promise((
|
|
22829
|
+
return new Promise((resolve29, reject) => {
|
|
22673
22830
|
let settled = !1, buffer = "", pullDecoder = new import_string_decoder.StringDecoder("utf8"), stallTimer = null, clearStall = () => {
|
|
22674
22831
|
stallTimer && (clearTimeout(stallTimer), stallTimer = null);
|
|
22675
22832
|
}, finish = (fn) => {
|
|
@@ -22711,7 +22868,7 @@ function requestOllamaPull(config, onProgress = () => {
|
|
|
22711
22868
|
status,
|
|
22712
22869
|
completed: typeof parsed.completed == "number" ? parsed.completed : void 0,
|
|
22713
22870
|
total: typeof parsed.total == "number" ? parsed.total : void 0
|
|
22714
|
-
}), status === "success" && finish(() =>
|
|
22871
|
+
}), status === "success" && finish(() => resolve29()));
|
|
22715
22872
|
}, req = chooseHttpClient(url).request(
|
|
22716
22873
|
url,
|
|
22717
22874
|
{
|
|
@@ -22748,7 +22905,7 @@ function requestOllamaPull(config, onProgress = () => {
|
|
|
22748
22905
|
}
|
|
22749
22906
|
buffer.length > MAX_PULL_LINE_BYTES && (finish(() => reject(new Error("Ollama pull response line exceeded the size limit"))), res.destroy());
|
|
22750
22907
|
})), res.on("end", () => guarded(() => {
|
|
22751
|
-
settled || (buffer += pullDecoder.end(), handleLine(buffer), buffer = "", finish(() =>
|
|
22908
|
+
settled || (buffer += pullDecoder.end(), handleLine(buffer), buffer = "", finish(() => resolve29()));
|
|
22752
22909
|
}));
|
|
22753
22910
|
}
|
|
22754
22911
|
);
|
|
@@ -24017,8 +24174,8 @@ function createBoundedSharedShutdownOperation(options) {
|
|
|
24017
24174
|
let operation = null, normalWait = null, signalWait = null, getOperation = () => {
|
|
24018
24175
|
if (!operation) {
|
|
24019
24176
|
let resolveOperation, rejectOperation;
|
|
24020
|
-
operation = new Promise((
|
|
24021
|
-
resolveOperation =
|
|
24177
|
+
operation = new Promise((resolve29, reject) => {
|
|
24178
|
+
resolveOperation = resolve29, rejectOperation = reject;
|
|
24022
24179
|
});
|
|
24023
24180
|
try {
|
|
24024
24181
|
Promise.resolve(options.start()).then(resolveOperation, rejectOperation);
|
|
@@ -24032,8 +24189,8 @@ function createBoundedSharedShutdownOperation(options) {
|
|
|
24032
24189
|
try {
|
|
24033
24190
|
if (await Promise.race([
|
|
24034
24191
|
getOperation().then(() => "settled"),
|
|
24035
|
-
new Promise((
|
|
24036
|
-
timer = setTimeout(() =>
|
|
24192
|
+
new Promise((resolve29) => {
|
|
24193
|
+
timer = setTimeout(() => resolve29("timeout"), timeoutMs), timer.unref?.();
|
|
24037
24194
|
})
|
|
24038
24195
|
]) === "timeout") {
|
|
24039
24196
|
options.onTimeout?.(deadlineClass, timeoutMs);
|
|
@@ -24147,8 +24304,8 @@ function createExplicitTtyExitCoordinator(deps) {
|
|
|
24147
24304
|
let started = !1, resolveCompletion = () => {
|
|
24148
24305
|
};
|
|
24149
24306
|
return {
|
|
24150
|
-
completion: new Promise((
|
|
24151
|
-
resolveCompletion =
|
|
24307
|
+
completion: new Promise((resolve29) => {
|
|
24308
|
+
resolveCompletion = resolve29;
|
|
24152
24309
|
}),
|
|
24153
24310
|
start: () => {
|
|
24154
24311
|
started || (started = !0, Promise.resolve().then(deps.runTeardown).catch(() => {
|
|
@@ -28564,8 +28721,8 @@ function spawnIsolatedHelper(command, args, options) {
|
|
|
28564
28721
|
}), child;
|
|
28565
28722
|
}
|
|
28566
28723
|
function observeChildClose(child) {
|
|
28567
|
-
return new Promise((
|
|
28568
|
-
child.once("error", reject), child.once("close",
|
|
28724
|
+
return new Promise((resolve29, reject) => {
|
|
28725
|
+
child.once("error", reject), child.once("close", resolve29);
|
|
28569
28726
|
});
|
|
28570
28727
|
}
|
|
28571
28728
|
async function withHelperDeadline(work, timeoutMs, label, signal) {
|
|
@@ -28596,8 +28753,8 @@ async function waitBounded(work, timeoutMs) {
|
|
|
28596
28753
|
work.then(() => {
|
|
28597
28754
|
}, () => {
|
|
28598
28755
|
}),
|
|
28599
|
-
new Promise((
|
|
28600
|
-
timer = setTimeout(
|
|
28756
|
+
new Promise((resolve29) => {
|
|
28757
|
+
timer = setTimeout(resolve29, timeoutMs), timer.unref?.();
|
|
28601
28758
|
})
|
|
28602
28759
|
]);
|
|
28603
28760
|
} finally {
|
|
@@ -28836,7 +28993,7 @@ async function ensureDurableDirectoryTree(target2, opts = {}) {
|
|
|
28836
28993
|
process.env[key] !== void 0 && (env[key] = process.env[key]);
|
|
28837
28994
|
let child, closed4;
|
|
28838
28995
|
try {
|
|
28839
|
-
let resultPromise = new Promise((
|
|
28996
|
+
let resultPromise = new Promise((resolve29, reject) => {
|
|
28840
28997
|
try {
|
|
28841
28998
|
child = spawnIsolatedHelper(process.execPath, ["-e", DURABLE_DIRECTORY_BOOTSTRAP], {
|
|
28842
28999
|
env,
|
|
@@ -28863,7 +29020,7 @@ async function ensureDurableDirectoryTree(target2, opts = {}) {
|
|
|
28863
29020
|
try {
|
|
28864
29021
|
let value = JSON.parse(Buffer.concat(chunks, bytes).toString("utf8"));
|
|
28865
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");
|
|
28866
|
-
|
|
29023
|
+
resolve29(value);
|
|
28867
29024
|
} catch (err) {
|
|
28868
29025
|
reject(err);
|
|
28869
29026
|
}
|
|
@@ -28987,13 +29144,13 @@ async function acquireWorkspaceRootLease(authority, opts = {}) {
|
|
|
28987
29144
|
}), closed4 = observeChildClose(child);
|
|
28988
29145
|
let stderr = new BoundedOutputBuffer(4096);
|
|
28989
29146
|
child.stderr?.on("data", (chunk) => stderr.push(chunk));
|
|
28990
|
-
let ready = await withHelperDeadline(new Promise((
|
|
29147
|
+
let ready = await withHelperDeadline(new Promise((resolve29, reject) => {
|
|
28991
29148
|
let value = "";
|
|
28992
29149
|
child.stdout?.on("data", (chunk) => {
|
|
28993
29150
|
value += chunk.toString("utf8"), value.length > 4096 && reject(new Error("workspace-lease helper exceeded output limit"));
|
|
28994
29151
|
let at = value.indexOf(`
|
|
28995
29152
|
`);
|
|
28996
|
-
at >= 0 &&
|
|
29153
|
+
at >= 0 && resolve29(value.slice(0, at));
|
|
28997
29154
|
}), child.once("error", reject), closed4.then((code) => {
|
|
28998
29155
|
code !== null && code !== 0 && reject(new Error(`workspace-lease helper failed (${code}): ${stderr.toString()}`));
|
|
28999
29156
|
});
|
|
@@ -29053,7 +29210,7 @@ async function captureWorkspaceRootAuthority(workingDir, opts = {}) {
|
|
|
29053
29210
|
process.env[key] !== void 0 && (env[key] = process.env[key]);
|
|
29054
29211
|
let child, closed4;
|
|
29055
29212
|
try {
|
|
29056
|
-
let resultPromise = new Promise((
|
|
29213
|
+
let resultPromise = new Promise((resolve29, reject) => {
|
|
29057
29214
|
try {
|
|
29058
29215
|
child = spawnIsolatedHelper(process.execPath, ["-e", WORKSPACE_AUTHORITY_BOOTSTRAP], {
|
|
29059
29216
|
env,
|
|
@@ -29088,7 +29245,7 @@ async function captureWorkspaceRootAuthority(workingDir, opts = {}) {
|
|
|
29088
29245
|
}
|
|
29089
29246
|
try {
|
|
29090
29247
|
let value = JSON.parse(Buffer.concat(chunks, bytes).toString("utf8"));
|
|
29091
|
-
assertWorkspaceRootAuthoritySchema(value),
|
|
29248
|
+
assertWorkspaceRootAuthoritySchema(value), resolve29(value);
|
|
29092
29249
|
} catch (err) {
|
|
29093
29250
|
reject(err);
|
|
29094
29251
|
}
|
|
@@ -32206,8 +32363,8 @@ async function runAnchoredReadWithinRoot(root, relativePath, opts) {
|
|
|
32206
32363
|
let nextMessage = () => {
|
|
32207
32364
|
let queued = messages.shift();
|
|
32208
32365
|
return queued ? Promise.resolve(queued) : protocolError ? Promise.reject(protocolError) : withHelperDeadline(Promise.race([
|
|
32209
|
-
new Promise((
|
|
32210
|
-
waiter = { resolve:
|
|
32366
|
+
new Promise((resolve29, reject) => {
|
|
32367
|
+
waiter = { resolve: resolve29, reject };
|
|
32211
32368
|
}),
|
|
32212
32369
|
childClosed.then((code) => {
|
|
32213
32370
|
throw new Error(`anchored read helper closed before result (${code}): ${stderr.toString()}`);
|
|
@@ -32685,8 +32842,8 @@ var writeChains = /* @__PURE__ */ new Map();
|
|
|
32685
32842
|
function withWriteLock(filePath, operation, opts) {
|
|
32686
32843
|
if (opts?.signal?.aborted)
|
|
32687
32844
|
return Promise.reject(new Error("anchored operation aborted by signal"));
|
|
32688
|
-
let prior = writeChains.get(filePath) ?? Promise.resolve(), isCancelled = !1, timer, abortListener, rejectCaller, resolveCaller, callerPromise = new Promise((
|
|
32689
|
-
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;
|
|
32690
32847
|
}), cleanupWait = () => {
|
|
32691
32848
|
timer !== void 0 && (clearTimeout(timer), timer = void 0), abortListener !== void 0 && opts?.signal && (opts.signal.removeEventListener("abort", abortListener), abortListener = void 0);
|
|
32692
32849
|
};
|
|
@@ -32765,8 +32922,8 @@ async function runAnchored(parent, request3, beforeCommit, afterRename, afterWri
|
|
|
32765
32922
|
let nextLine = async () => {
|
|
32766
32923
|
let line = lines.shift();
|
|
32767
32924
|
return line !== void 0 ? (backlog.onLineConsumed(utf8Bytes(line)), line) : withHelperDeadline(Promise.race([
|
|
32768
|
-
new Promise((
|
|
32769
|
-
waiter =
|
|
32925
|
+
new Promise((resolve29) => {
|
|
32926
|
+
waiter = resolve29;
|
|
32770
32927
|
}),
|
|
32771
32928
|
childClosed.then((code2) => {
|
|
32772
32929
|
throw new Error(`anchored-fs helper closed before replying (${code2}): ${stderr.toString()}`);
|
|
@@ -34517,8 +34674,8 @@ function ReviewerSetupWizard(props) {
|
|
|
34517
34674
|
// src/orchestration-shell/resume-modal.ts
|
|
34518
34675
|
var pending = /* @__PURE__ */ new WeakMap();
|
|
34519
34676
|
function open9(store, modal) {
|
|
34520
|
-
return pending.get(store)?.(modal.kind === "picker" ? null : !1), new Promise((
|
|
34521
|
-
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 });
|
|
34522
34679
|
});
|
|
34523
34680
|
}
|
|
34524
34681
|
async function pickInShell(store, rows) {
|
|
@@ -34529,8 +34686,8 @@ async function chooseInShell(store, prompt, continueLabel) {
|
|
|
34529
34686
|
return await open9(store, { kind: "choice", prompt, continueLabel }) === !0;
|
|
34530
34687
|
}
|
|
34531
34688
|
function settleResumeModal(store, value) {
|
|
34532
|
-
let
|
|
34533
|
-
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);
|
|
34534
34691
|
}
|
|
34535
34692
|
|
|
34536
34693
|
// src/orchestration-shell/task-lifecycle-lines.ts
|
|
@@ -35015,7 +35172,7 @@ async function htmlToTextWorker(html, options) {
|
|
|
35015
35172
|
if (signal?.aborted)
|
|
35016
35173
|
throw new WebExtractAbortError();
|
|
35017
35174
|
let workerPath = resolveExtractWorkerPath();
|
|
35018
|
-
return new Promise((
|
|
35175
|
+
return new Promise((resolve29, reject) => {
|
|
35019
35176
|
let settled = !1, timer = null, worker = null, cleanup = () => {
|
|
35020
35177
|
timer && (clearTimeout(timer), timer = null), signal && signal.removeEventListener("abort", onAbort);
|
|
35021
35178
|
}, onAbort = () => {
|
|
@@ -35036,7 +35193,7 @@ async function htmlToTextWorker(html, options) {
|
|
|
35036
35193
|
}), reject(new WebExtractTimeoutError(timeoutMs)));
|
|
35037
35194
|
}, timeoutMs), worker.on("message", (msg) => {
|
|
35038
35195
|
settled || (settled = !0, cleanup(), worker?.terminate().catch(() => {
|
|
35039
|
-
}), msg.success && msg.result ?
|
|
35196
|
+
}), msg.success && msg.result ? resolve29(msg.result) : reject(new Error(msg.error || "HTML extraction failed in worker")));
|
|
35040
35197
|
}), worker.on("error", (err) => {
|
|
35041
35198
|
settled || (settled = !0, cleanup(), worker?.terminate().catch(() => {
|
|
35042
35199
|
}), reject(err));
|
|
@@ -35700,14 +35857,14 @@ async function resolveValidatedIps(host, signal, customLookup = dns2.lookup) {
|
|
|
35700
35857
|
}
|
|
35701
35858
|
let records;
|
|
35702
35859
|
try {
|
|
35703
|
-
records = await new Promise((
|
|
35860
|
+
records = await new Promise((resolve29, reject) => {
|
|
35704
35861
|
if (signal?.aborted) {
|
|
35705
35862
|
reject(new FetchError("timeout", "aborted before DNS"));
|
|
35706
35863
|
return;
|
|
35707
35864
|
}
|
|
35708
35865
|
let onAbort = () => reject(new FetchError("timeout", "DNS aborted"));
|
|
35709
35866
|
signal?.addEventListener("abort", onAbort, { once: !0 }), customLookup(host, { all: !0 }, (err, addrs) => {
|
|
35710
|
-
signal?.removeEventListener("abort", onAbort), err ? reject(err) :
|
|
35867
|
+
signal?.removeEventListener("abort", onAbort), err ? reject(err) : resolve29(addrs);
|
|
35711
35868
|
});
|
|
35712
35869
|
});
|
|
35713
35870
|
} catch (e) {
|
|
@@ -35759,7 +35916,7 @@ function decodeBody(buf, contentType) {
|
|
|
35759
35916
|
return buf.toString("utf-8");
|
|
35760
35917
|
}
|
|
35761
35918
|
function getOnce(url, frozen, signal, options) {
|
|
35762
|
-
return new Promise((
|
|
35919
|
+
return new Promise((resolve29, reject) => {
|
|
35763
35920
|
let req = (url.protocol === "https:" ? https3 : http2).request(
|
|
35764
35921
|
url,
|
|
35765
35922
|
{
|
|
@@ -35779,7 +35936,7 @@ function getOnce(url, frozen, signal, options) {
|
|
|
35779
35936
|
(res) => {
|
|
35780
35937
|
let status = res.statusCode ?? 0, contentType = String(res.headers["content-type"] ?? "");
|
|
35781
35938
|
if (status >= 300 && status < 400 && res.headers.location) {
|
|
35782
|
-
res.resume(),
|
|
35939
|
+
res.resume(), resolve29({ status, location: res.headers.location, contentType });
|
|
35783
35940
|
return;
|
|
35784
35941
|
}
|
|
35785
35942
|
if (status >= 400) {
|
|
@@ -35810,7 +35967,7 @@ function getOnce(url, frozen, signal, options) {
|
|
|
35810
35967
|
return;
|
|
35811
35968
|
}
|
|
35812
35969
|
chunks.push(c);
|
|
35813
|
-
}), 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")));
|
|
35814
35971
|
}
|
|
35815
35972
|
);
|
|
35816
35973
|
req.setTimeout(TIMEOUT_MS, () => {
|
|
@@ -36472,10 +36629,10 @@ async function startAgentWebTurn(options) {
|
|
|
36472
36629
|
});
|
|
36473
36630
|
});
|
|
36474
36631
|
try {
|
|
36475
|
-
await new Promise((
|
|
36632
|
+
await new Promise((resolve29, reject) => {
|
|
36476
36633
|
server.listen(socketPath, () => {
|
|
36477
36634
|
try {
|
|
36478
|
-
fs33.chmodSync(socketPath, 384),
|
|
36635
|
+
fs33.chmodSync(socketPath, 384), resolve29();
|
|
36479
36636
|
} catch (err) {
|
|
36480
36637
|
reject(err);
|
|
36481
36638
|
}
|
|
@@ -37370,7 +37527,7 @@ function isTransientDirectoryEnumeration(error) {
|
|
|
37370
37527
|
return error instanceof Error && error.message.includes(TRANSIENT_DIRECTORY_ENUMERATION);
|
|
37371
37528
|
}
|
|
37372
37529
|
function sleep(ms) {
|
|
37373
|
-
return new Promise((
|
|
37530
|
+
return new Promise((resolve29) => setTimeout(resolve29, ms));
|
|
37374
37531
|
}
|
|
37375
37532
|
async function withTransientDirectoryEnumerationRetry(operation, opts = {}) {
|
|
37376
37533
|
let maxAttempts = opts.maxAttempts ?? 4, retryDelaysMs = opts.retryDelaysMs ?? [10, 25, 50], sleepFn = opts.sleep ?? sleep;
|
|
@@ -37510,8 +37667,8 @@ function nextDirectoryWorkerMessage(worker, deadlineAt, label, signal) {
|
|
|
37510
37667
|
if (worker.protocolError) return Promise.reject(worker.protocolError);
|
|
37511
37668
|
let remaining = deadlineAt - Date.now();
|
|
37512
37669
|
return remaining <= 0 ? Promise.reject(new Error(`${label} helper timed out`)) : withHelperDeadline(Promise.race([
|
|
37513
|
-
new Promise((
|
|
37514
|
-
worker.waiter = { resolve:
|
|
37670
|
+
new Promise((resolve29, reject) => {
|
|
37671
|
+
worker.waiter = { resolve: resolve29, reject };
|
|
37515
37672
|
}),
|
|
37516
37673
|
worker.closed.then((code) => {
|
|
37517
37674
|
throw new Error(
|
|
@@ -38040,10 +38197,10 @@ function readPosixHostProtocol(child, persistOwner, syncOwnerDirectory) {
|
|
|
38040
38197
|
let status = child.stdio?.[3];
|
|
38041
38198
|
if (!status || typeof status.on != "function")
|
|
38042
38199
|
return { cleanupSafe: Promise.resolve(!1), owner: Promise.resolve(void 0) };
|
|
38043
|
-
let resolveCleanup, resolveOwner, cleanupSafe = new Promise((
|
|
38044
|
-
resolveCleanup =
|
|
38045
|
-
}), owner = new Promise((
|
|
38046
|
-
resolveOwner =
|
|
38200
|
+
let resolveCleanup, resolveOwner, cleanupSafe = new Promise((resolve29) => {
|
|
38201
|
+
resolveCleanup = resolve29;
|
|
38202
|
+
}), owner = new Promise((resolve29) => {
|
|
38203
|
+
resolveOwner = resolve29;
|
|
38047
38204
|
}), pending2 = "", bytes = 0, ownerSettled = !1, cleanupSettled = !1, finish = () => {
|
|
38048
38205
|
ownerSettled || (ownerSettled = !0, resolveOwner(void 0)), cleanupSettled || (cleanupSettled = !0, resolveCleanup(!1));
|
|
38049
38206
|
}, consume = (line) => {
|
|
@@ -38406,11 +38563,11 @@ async function spawnWindowsJobProcess(command, args, options, seams = {}) {
|
|
|
38406
38563
|
throw await anchoredRemoveTree(hostDir, hostIdentity).catch(() => {
|
|
38407
38564
|
}), err;
|
|
38408
38565
|
}
|
|
38409
|
-
let cleanupStarted = !1, cleanupPromise = new Promise((
|
|
38566
|
+
let cleanupStarted = !1, cleanupPromise = new Promise((resolve29) => {
|
|
38410
38567
|
let cleanup = () => {
|
|
38411
38568
|
cleanupStarted || (cleanupStarted = !0, anchoredRemoveTree(hostDir, hostIdentity).then(
|
|
38412
|
-
() =>
|
|
38413
|
-
() =>
|
|
38569
|
+
() => resolve29(!0),
|
|
38570
|
+
() => resolve29(!1)
|
|
38414
38571
|
));
|
|
38415
38572
|
};
|
|
38416
38573
|
child.once("close", cleanup), child.once("error", cleanup);
|
|
@@ -38445,7 +38602,7 @@ async function waitForProcessIdentity(pid) {
|
|
|
38445
38602
|
for (let attempt = 0; attempt < 100; attempt++) {
|
|
38446
38603
|
let identity = await readProcessIdentity(pid);
|
|
38447
38604
|
if (identity) return identity;
|
|
38448
|
-
await new Promise((
|
|
38605
|
+
await new Promise((resolve29) => setTimeout(resolve29, 10));
|
|
38449
38606
|
}
|
|
38450
38607
|
return null;
|
|
38451
38608
|
}
|
|
@@ -38664,7 +38821,7 @@ async function terminateOwnedProcessTree(args) {
|
|
|
38664
38821
|
} catch (err) {
|
|
38665
38822
|
err.code !== "ESRCH" && directKill();
|
|
38666
38823
|
}
|
|
38667
|
-
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)));
|
|
38668
38825
|
for (; ; ) {
|
|
38669
38826
|
try {
|
|
38670
38827
|
kill(-pid, 0);
|
|
@@ -38805,17 +38962,17 @@ function isInsideDir(candidate, dir) {
|
|
|
38805
38962
|
return root.startsWith("/") ? candidate === root || candidate.startsWith(`${root}/`) : !1;
|
|
38806
38963
|
}
|
|
38807
38964
|
function run(command, args, okExitCodes = []) {
|
|
38808
|
-
return new Promise((
|
|
38965
|
+
return new Promise((resolve29, reject) => {
|
|
38809
38966
|
(0, import_node_child_process5.execFile)(
|
|
38810
38967
|
command,
|
|
38811
38968
|
args,
|
|
38812
38969
|
// `LC_ALL=C` pins the `lstart` column format the parser reads.
|
|
38813
38970
|
{ timeout: 5e3, maxBuffer: 64 * 1024 * 1024, windowsHide: !0, env: { ...process.env, LC_ALL: "C" } },
|
|
38814
38971
|
(err, stdout) => {
|
|
38815
|
-
if (!err) return
|
|
38972
|
+
if (!err) return resolve29(stdout);
|
|
38816
38973
|
let code = err.code;
|
|
38817
38974
|
if (typeof code == "number" && okExitCodes.includes(code) && !err.killed)
|
|
38818
|
-
return
|
|
38975
|
+
return resolve29(stdout);
|
|
38819
38976
|
reject(err);
|
|
38820
38977
|
}
|
|
38821
38978
|
);
|
|
@@ -39079,8 +39236,8 @@ function wireLifecycle(internal, args) {
|
|
|
39079
39236
|
}
|
|
39080
39237
|
return descendantReap;
|
|
39081
39238
|
}, resolveDone = () => {
|
|
39082
|
-
}, done = new Promise((
|
|
39083
|
-
resolveDone =
|
|
39239
|
+
}, done = new Promise((resolve29) => {
|
|
39240
|
+
resolveDone = resolve29;
|
|
39084
39241
|
}), cleanupAbort = () => {
|
|
39085
39242
|
}, cleanupTimeout = () => {
|
|
39086
39243
|
}, settling = !1, forcedExit = null, settle = async (failureClass, exitCode, workspaceCleanupSafe = !0) => {
|
|
@@ -41535,8 +41692,8 @@ async function runShellCommand(args) {
|
|
|
41535
41692
|
}, aborted = args.signal?.aborted === !0, onAbort = () => {
|
|
41536
41693
|
aborted = !0, killProcessTree();
|
|
41537
41694
|
}, resolveResult = () => {
|
|
41538
|
-
}, settled = new Promise((
|
|
41539
|
-
resolveResult =
|
|
41695
|
+
}, settled = new Promise((resolve29) => {
|
|
41696
|
+
resolveResult = resolve29;
|
|
41540
41697
|
}), settle = (result) => {
|
|
41541
41698
|
alreadySettled || (alreadySettled = !0, timer !== void 0 && clearTimeout(timer), args.signal?.removeEventListener("abort", onAbort), resolveResult(result));
|
|
41542
41699
|
}, finalize = async (exitCode, workspaceCleanupSafe = !0) => {
|
|
@@ -42246,8 +42403,8 @@ function createWorkspaceMaterializerSession(opts) {
|
|
|
42246
42403
|
if (queued) return Promise.resolve(queued);
|
|
42247
42404
|
if (protocolError) return Promise.reject(protocolError);
|
|
42248
42405
|
let remaining = deadlineAt - Date.now();
|
|
42249
|
-
return remaining <= 0 ? Promise.reject(new Error("workspace-materializer helper timed out")) : withHelperDeadline(new Promise((
|
|
42250
|
-
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 };
|
|
42251
42408
|
}), remaining, "workspace-materializer helper");
|
|
42252
42409
|
}
|
|
42253
42410
|
function serialize(operation) {
|
|
@@ -43524,8 +43681,8 @@ async function runAnchoredCasHelper(workingDir, relativePath, expectedRoot, requ
|
|
|
43524
43681
|
"anchored CAS helper exit"
|
|
43525
43682
|
), nextMessageRaw = () => {
|
|
43526
43683
|
let queued = messages.shift();
|
|
43527
|
-
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((
|
|
43528
|
-
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 };
|
|
43529
43686
|
});
|
|
43530
43687
|
}, nextMessage = () => withHelperDeadline(
|
|
43531
43688
|
nextMessageRaw(),
|
|
@@ -45920,8 +46077,8 @@ async function readSnapshotOwnerAnchor(shadowDir, opts) {
|
|
|
45920
46077
|
});
|
|
45921
46078
|
!hasError && !opts?.signal?.aborted ? await closePromise : await Promise.race([
|
|
45922
46079
|
closePromise,
|
|
45923
|
-
new Promise((
|
|
45924
|
-
let t = setTimeout(
|
|
46080
|
+
new Promise((resolve29) => {
|
|
46081
|
+
let t = setTimeout(resolve29, 0);
|
|
45925
46082
|
typeof t.unref == "function" && t.unref();
|
|
45926
46083
|
})
|
|
45927
46084
|
]);
|
|
@@ -47806,8 +47963,8 @@ var WorkspaceShadow = class _WorkspaceShadow {
|
|
|
47806
47963
|
this.exposureFileAuthority = { ...fileAuthority };
|
|
47807
47964
|
}
|
|
47808
47965
|
async runOwnedStateFileWrite(write) {
|
|
47809
|
-
let settle, admission = new Promise((
|
|
47810
|
-
settle =
|
|
47966
|
+
let settle, admission = new Promise((resolve29) => {
|
|
47967
|
+
settle = resolve29;
|
|
47811
47968
|
});
|
|
47812
47969
|
this.stateFileWriteAdmissions.add(admission);
|
|
47813
47970
|
try {
|
|
@@ -49237,7 +49394,7 @@ var DEFAULT_MERGE_PLAN_MAX_WORK = 16e6, DEFAULT_MERGE_PLAN_TIMEOUT_MS = 5e3, MER
|
|
|
49237
49394
|
this.used += units, this.workSinceYield += units, this.assertActive();
|
|
49238
49395
|
}
|
|
49239
49396
|
async cooperate(force = !1) {
|
|
49240
|
-
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());
|
|
49241
49398
|
}
|
|
49242
49399
|
};
|
|
49243
49400
|
function assertSnapshotBundleFileOccurrenceBounds(bundles, budget = createMetadataBudget(), label = "snapshot bundle file-occurrence aggregate") {
|
|
@@ -50593,7 +50750,7 @@ init_logger2();
|
|
|
50593
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");
|
|
50594
50751
|
|
|
50595
50752
|
// src/local-executor/git-lock-retry.ts
|
|
50596
|
-
var realSleep = (ms) => new Promise((
|
|
50753
|
+
var realSleep = (ms) => new Promise((resolve29) => setTimeout(resolve29, ms));
|
|
50597
50754
|
function isGitLockContention(msg) {
|
|
50598
50755
|
let m = msg.toLowerCase();
|
|
50599
50756
|
return (
|
|
@@ -50881,7 +51038,7 @@ async function pinnedGit(repoDir, args, opts = {}) {
|
|
|
50881
51038
|
}
|
|
50882
51039
|
async function pinnedGitWithInput(repoDir, args, input, opts = {}) {
|
|
50883
51040
|
let configPrefix = [...W2_HERMETIC_CONFIG, ...PINNED_GIT_CONFIG];
|
|
50884
|
-
return await new Promise((
|
|
51041
|
+
return await new Promise((resolve29, reject) => {
|
|
50885
51042
|
let child = (0, import_node_child_process7.spawn)("git", ["-C", repoDir, ...configPrefix, ...args], {
|
|
50886
51043
|
env: sanitizeGitEnv(),
|
|
50887
51044
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -50891,7 +51048,7 @@ async function pinnedGitWithInput(repoDir, args, input, opts = {}) {
|
|
|
50891
51048
|
}), child.stderr.on("data", (c) => {
|
|
50892
51049
|
stderr += c.toString("utf8");
|
|
50893
51050
|
}), child.on("error", (err) => reject(err)), child.on("close", (code) => {
|
|
50894
|
-
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)}`));
|
|
50895
51052
|
}), child.stdin.on("error", () => {
|
|
50896
51053
|
}), child.stdin.end(input);
|
|
50897
51054
|
});
|
|
@@ -56656,8 +56813,8 @@ var LocalExecutorImpl = class {
|
|
|
56656
56813
|
throw new Error("LocalExecutor session shutdown has fenced new advisory spawns");
|
|
56657
56814
|
let resolveSettled, admission = {
|
|
56658
56815
|
controller: new AbortController(),
|
|
56659
|
-
settled: new Promise((
|
|
56660
|
-
resolveSettled =
|
|
56816
|
+
settled: new Promise((resolve29) => {
|
|
56817
|
+
resolveSettled = resolve29;
|
|
56661
56818
|
}),
|
|
56662
56819
|
resolveSettled: () => resolveSettled(),
|
|
56663
56820
|
handle: null,
|
|
@@ -57745,7 +57902,7 @@ var LocalExecutorImpl = class {
|
|
|
57745
57902
|
this.integrationAbort.signal
|
|
57746
57903
|
), ranGate || this.workspaceShutdown) return;
|
|
57747
57904
|
let remaining = deadline - Date.now();
|
|
57748
|
-
!retryMissing || remaining <= 0 || await new Promise((
|
|
57905
|
+
!retryMissing || remaining <= 0 || await new Promise((resolve29) => setTimeout(resolve29, Math.min(TRACK_TIP_POLL_MS, remaining)));
|
|
57749
57906
|
}
|
|
57750
57907
|
}
|
|
57751
57908
|
/** True only for a missing exact current-generation bundle; malformed input is classified inside the gate. */
|
|
@@ -59429,8 +59586,8 @@ var RevertManifestStore = class {
|
|
|
59429
59586
|
let nextLine = async () => {
|
|
59430
59587
|
let line = lines.shift();
|
|
59431
59588
|
return line !== void 0 ? (backlog.onLineConsumed(utf8Bytes(line)), line) : withHelperDeadline(Promise.race([
|
|
59432
|
-
new Promise((
|
|
59433
|
-
waiter =
|
|
59589
|
+
new Promise((resolve29) => {
|
|
59590
|
+
waiter = resolve29;
|
|
59434
59591
|
}),
|
|
59435
59592
|
childClosed.then((code2) => {
|
|
59436
59593
|
throw new Error(`store helper closed before replying (${code2}): ${stderr.toString()}`);
|
|
@@ -62353,7 +62510,7 @@ var import_node_child_process9 = require("node:child_process");
|
|
|
62353
62510
|
init_env_scrub();
|
|
62354
62511
|
var ChildProcessCommandRunner = class {
|
|
62355
62512
|
run(argv, opts = {}) {
|
|
62356
|
-
return new Promise((
|
|
62513
|
+
return new Promise((resolve29, reject) => {
|
|
62357
62514
|
let child = (0, import_node_child_process9.spawn)(argv[0], argv.slice(1), {
|
|
62358
62515
|
stdio: ["pipe", "pipe", "pipe"],
|
|
62359
62516
|
windowsHide: !0,
|
|
@@ -62369,7 +62526,7 @@ var ChildProcessCommandRunner = class {
|
|
|
62369
62526
|
}, opts.timeoutMs)), child.on("error", (err) => {
|
|
62370
62527
|
timer && clearTimeout(timer), reject(err);
|
|
62371
62528
|
}), child.on("close", (code) => {
|
|
62372
|
-
timer && clearTimeout(timer),
|
|
62529
|
+
timer && clearTimeout(timer), resolve29({
|
|
62373
62530
|
exitCode: code,
|
|
62374
62531
|
stdout: Buffer.concat(stdoutChunks).toString("utf8"),
|
|
62375
62532
|
stderr: Buffer.concat(stderrChunks).toString("utf8")
|
|
@@ -62456,12 +62613,12 @@ var denialCounter = 0, HostEgressForwarder = class {
|
|
|
62456
62613
|
*/
|
|
62457
62614
|
async start() {
|
|
62458
62615
|
return await import_node_fs29.promises.rm(this.udsPath, { force: !0 }).catch(() => {
|
|
62459
|
-
}), new Promise((
|
|
62616
|
+
}), new Promise((resolve29, reject) => {
|
|
62460
62617
|
let onError = (err) => {
|
|
62461
62618
|
this.server.removeListener("error", onError), reject(err);
|
|
62462
62619
|
};
|
|
62463
62620
|
this.server.once("error", onError), this.server.listen(this.udsPath, () => {
|
|
62464
|
-
this.server.removeListener("error", onError), this.listening = !0,
|
|
62621
|
+
this.server.removeListener("error", onError), this.listening = !0, resolve29({ udsPath: this.udsPath });
|
|
62465
62622
|
});
|
|
62466
62623
|
});
|
|
62467
62624
|
}
|
|
@@ -62479,8 +62636,8 @@ var denialCounter = 0, HostEgressForwarder = class {
|
|
|
62479
62636
|
});
|
|
62480
62637
|
return;
|
|
62481
62638
|
}
|
|
62482
|
-
this.listening = !1, await new Promise((
|
|
62483
|
-
this.server.close(() =>
|
|
62639
|
+
this.listening = !1, await new Promise((resolve29) => {
|
|
62640
|
+
this.server.close(() => resolve29());
|
|
62484
62641
|
}), await import_node_fs29.promises.rm(this.udsPath, { force: !0 }).catch(() => {
|
|
62485
62642
|
});
|
|
62486
62643
|
}
|
|
@@ -63574,7 +63731,7 @@ async function runReviewer(opts) {
|
|
|
63574
63731
|
});
|
|
63575
63732
|
}
|
|
63576
63733
|
let acquiredChild = child;
|
|
63577
|
-
return new Promise((
|
|
63734
|
+
return new Promise((resolve29, reject) => {
|
|
63578
63735
|
let child2 = acquiredChild, settled = !1, stdoutChunks = [], stderrChunks = [], cleanupStreams = () => {
|
|
63579
63736
|
try {
|
|
63580
63737
|
child2.stdin && !child2.stdin.destroyed && child2.stdin.destroy();
|
|
@@ -63596,7 +63753,7 @@ async function runReviewer(opts) {
|
|
|
63596
63753
|
}, cleanupAbortListener = () => {
|
|
63597
63754
|
}, cleanupTimeoutTimer = () => {
|
|
63598
63755
|
}, settleSuccess = (outcome2) => {
|
|
63599
|
-
settled || (settled = !0, cleanupAbortListener(), cleanupTimeoutTimer(),
|
|
63756
|
+
settled || (settled = !0, cleanupAbortListener(), cleanupTimeoutTimer(), resolve29(outcome2));
|
|
63600
63757
|
}, settleError = (err) => {
|
|
63601
63758
|
settled || (settled = !0, cleanupAbortListener(), cleanupTimeoutTimer(), cleanupStreams(), killChild(), reject(err));
|
|
63602
63759
|
};
|
|
@@ -66394,8 +66551,8 @@ var QuorumLoop = class _QuorumLoop {
|
|
|
66394
66551
|
return this.trackExistingSessionWork(recovery);
|
|
66395
66552
|
}
|
|
66396
66553
|
acquireRecoveryRelaunchPermit() {
|
|
66397
|
-
return this.shuttingDown ? Promise.resolve(!1) : this.activeRecoveryRelaunches < TEAM_RECOVERY_RELAUNCH_CONCURRENCY ? (this.activeRecoveryRelaunches++, Promise.resolve(!0)) : new Promise((
|
|
66398
|
-
this.recoveryRelaunchWaiters.push(
|
|
66554
|
+
return this.shuttingDown ? Promise.resolve(!1) : this.activeRecoveryRelaunches < TEAM_RECOVERY_RELAUNCH_CONCURRENCY ? (this.activeRecoveryRelaunches++, Promise.resolve(!0)) : new Promise((resolve29) => {
|
|
66555
|
+
this.recoveryRelaunchWaiters.push(resolve29);
|
|
66399
66556
|
});
|
|
66400
66557
|
}
|
|
66401
66558
|
releaseRecoveryRelaunchPermit() {
|
|
@@ -66426,12 +66583,12 @@ var QuorumLoop = class _QuorumLoop {
|
|
|
66426
66583
|
}
|
|
66427
66584
|
}
|
|
66428
66585
|
awaitBackgroundRecoveryStep(work, signal) {
|
|
66429
|
-
return signal ? signal.aborted ? Promise.reject(BACKGROUND_RECOVERY_ABORTED) : new Promise((
|
|
66586
|
+
return signal ? signal.aborted ? Promise.reject(BACKGROUND_RECOVERY_ABORTED) : new Promise((resolve29, reject) => {
|
|
66430
66587
|
let settled = !1, finish = (complete) => {
|
|
66431
66588
|
settled || (settled = !0, signal.removeEventListener("abort", onAbort), complete());
|
|
66432
66589
|
}, onAbort = () => finish(() => reject(BACKGROUND_RECOVERY_ABORTED));
|
|
66433
66590
|
signal.addEventListener("abort", onAbort, { once: !0 }), work.then(
|
|
66434
|
-
(value) => finish(() =>
|
|
66591
|
+
(value) => finish(() => resolve29(value)),
|
|
66435
66592
|
(err) => finish(() => reject(err))
|
|
66436
66593
|
);
|
|
66437
66594
|
}) : work;
|
|
@@ -66560,8 +66717,8 @@ var QuorumLoop = class _QuorumLoop {
|
|
|
66560
66717
|
gateId,
|
|
66561
66718
|
entry: entry5,
|
|
66562
66719
|
authority,
|
|
66563
|
-
settled: new Promise((
|
|
66564
|
-
settle =
|
|
66720
|
+
settled: new Promise((resolve29) => {
|
|
66721
|
+
settle = resolve29;
|
|
66565
66722
|
})
|
|
66566
66723
|
}, admissions = this.teamDispatchAdmissionsByTask.get(taskId) ?? /* @__PURE__ */ new Set();
|
|
66567
66724
|
admissions.add(admission), this.teamDispatchAdmissionsByTask.set(taskId, admissions);
|
|
@@ -67842,8 +67999,8 @@ ${section}`);
|
|
|
67842
67999
|
taskId: args.taskId,
|
|
67843
68000
|
gateId,
|
|
67844
68001
|
abortController,
|
|
67845
|
-
settled: new Promise((
|
|
67846
|
-
settlePending =
|
|
68002
|
+
settled: new Promise((resolve29) => {
|
|
68003
|
+
settlePending = resolve29;
|
|
67847
68004
|
}),
|
|
67848
68005
|
...args.teamAuthority ? { teamAuthority: args.teamAuthority } : {}
|
|
67849
68006
|
}, needsWeb = this.webAccessByTask.get(args.taskId);
|
|
@@ -70048,8 +70205,8 @@ ${section}`);
|
|
|
70048
70205
|
() => {
|
|
70049
70206
|
}
|
|
70050
70207
|
));
|
|
70051
|
-
let displayTimeout = new Promise((
|
|
70052
|
-
timeout = setTimeout(() =>
|
|
70208
|
+
let displayTimeout = new Promise((resolve29) => {
|
|
70209
|
+
timeout = setTimeout(() => resolve29(void 0), TICK_SCAN_TIMEOUT_MS);
|
|
70053
70210
|
});
|
|
70054
70211
|
return await Promise.race([scan, displayTimeout]);
|
|
70055
70212
|
} catch {
|
|
@@ -76189,7 +76346,7 @@ var AdvisoryAttachmentJournal = class {
|
|
|
76189
76346
|
artifactTargets.add(target2);
|
|
76190
76347
|
}
|
|
76191
76348
|
if (retirementNames.length > 0 && Date.now() < retirementDeadlineMs)
|
|
76192
|
-
return await new Promise((
|
|
76349
|
+
return await new Promise((resolve29) => setTimeout(resolve29, 20)), this.listRecords(root, retirementDeadlineMs, artifactRetry);
|
|
76193
76350
|
for (let name of retirementNames.sort()) {
|
|
76194
76351
|
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);
|
|
76195
76352
|
if (!ownedHere && !ownerDead)
|
|
@@ -80413,8 +80570,8 @@ var PromptPublicationTracker = class {
|
|
|
80413
80570
|
return this.active.has(promptId2);
|
|
80414
80571
|
}
|
|
80415
80572
|
async run(promptId2, publish) {
|
|
80416
|
-
let settle, settled = new Promise((
|
|
80417
|
-
settle =
|
|
80573
|
+
let settle, settled = new Promise((resolve29) => {
|
|
80574
|
+
settle = resolve29;
|
|
80418
80575
|
}), writes = this.active.get(promptId2) ?? /* @__PURE__ */ new Set();
|
|
80419
80576
|
writes.add(settled), this.active.set(promptId2, writes);
|
|
80420
80577
|
try {
|
|
@@ -82787,9 +82944,9 @@ async function runOrchestrationShellSession(args) {
|
|
|
82787
82944
|
await durableDecisionEffectDispatcher.dispatch(resolution);
|
|
82788
82945
|
}, settleInitialSubscription = () => {
|
|
82789
82946
|
}, rejectInitialSubscription = () => {
|
|
82790
|
-
}, initialSubscriptionSettled = !startupReadinessRequired, initialCatchUpStarted = !1, initialSubscriptionTimer = null, initialSubscriptionReady = startupReadinessRequired ? new Promise((
|
|
82947
|
+
}, initialSubscriptionSettled = !startupReadinessRequired, initialCatchUpStarted = !1, initialSubscriptionTimer = null, initialSubscriptionReady = startupReadinessRequired ? new Promise((resolve29, reject) => {
|
|
82791
82948
|
settleInitialSubscription = () => {
|
|
82792
|
-
initialSubscriptionSettled || (initialSubscriptionSettled = !0,
|
|
82949
|
+
initialSubscriptionSettled || (initialSubscriptionSettled = !0, resolve29());
|
|
82793
82950
|
}, rejectInitialSubscription = (error) => {
|
|
82794
82951
|
initialSubscriptionSettled || (initialSubscriptionSettled = !0, reject(error));
|
|
82795
82952
|
}, initialSubscriptionTimer = setTimeout(() => {
|
|
@@ -82972,9 +83129,9 @@ async function runOrchestrationShellSession(args) {
|
|
|
82972
83129
|
}
|
|
82973
83130
|
let unsubscribePromptActions = null, promptActionStartupSettled = !startupReadinessRequired, settlePromptActionStartup = () => {
|
|
82974
83131
|
}, rejectPromptActionStartup = () => {
|
|
82975
|
-
}, promptActionStartupTimer = null, promptActionStartupReady = startupReadinessRequired ? new Promise((
|
|
83132
|
+
}, promptActionStartupTimer = null, promptActionStartupReady = startupReadinessRequired ? new Promise((resolve29, reject) => {
|
|
82976
83133
|
settlePromptActionStartup = () => {
|
|
82977
|
-
promptActionStartupSettled || (promptActionStartupSettled = !0,
|
|
83134
|
+
promptActionStartupSettled || (promptActionStartupSettled = !0, resolve29());
|
|
82978
83135
|
}, rejectPromptActionStartup = (error) => {
|
|
82979
83136
|
promptActionStartupSettled || (promptActionStartupSettled = !0, reject(error));
|
|
82980
83137
|
}, promptActionStartupTimer = setTimeout(() => {
|
|
@@ -83289,9 +83446,9 @@ async function runOrchestrationShellSession(args) {
|
|
|
83289
83446
|
try {
|
|
83290
83447
|
let released = await Promise.race([
|
|
83291
83448
|
args.appsyncClient.releaseSessionWork(args.session.sessionId, { signal: controller.signal }),
|
|
83292
|
-
new Promise((
|
|
83449
|
+
new Promise((resolve29) => {
|
|
83293
83450
|
timer = setTimeout(() => {
|
|
83294
|
-
controller.abort(),
|
|
83451
|
+
controller.abort(), resolve29(null);
|
|
83295
83452
|
}, SESSION_WORK_RELEASE_TIMEOUT_MS), timer.unref?.();
|
|
83296
83453
|
})
|
|
83297
83454
|
]);
|
|
@@ -83472,8 +83629,8 @@ async function runOrchestrationShellSession(args) {
|
|
|
83472
83629
|
errorName: reason?.name ?? "Error"
|
|
83473
83630
|
});
|
|
83474
83631
|
}),
|
|
83475
|
-
new Promise((
|
|
83476
|
-
timer = setTimeout(
|
|
83632
|
+
new Promise((resolve29) => {
|
|
83633
|
+
timer = setTimeout(resolve29, SESSION_RETIRE_TIMEOUT_MS2), timer.unref?.();
|
|
83477
83634
|
})
|
|
83478
83635
|
]);
|
|
83479
83636
|
} finally {
|
|
@@ -83519,8 +83676,8 @@ async function runOrchestrationShellSession(args) {
|
|
|
83519
83676
|
disableBracketedPaste();
|
|
83520
83677
|
let teardownSweepAbort = new AbortController(), TEARDOWN_SWEEP_TIMEOUT_MS = 2e3, teardownSweepTimer = setTimeout(() => teardownSweepAbort.abort(), TEARDOWN_SWEEP_TIMEOUT_MS);
|
|
83521
83678
|
teardownSweepTimer.unref?.();
|
|
83522
|
-
let hardDeadline = new Promise((
|
|
83523
|
-
setTimeout(
|
|
83679
|
+
let hardDeadline = new Promise((resolve29) => {
|
|
83680
|
+
setTimeout(resolve29, SIGNAL_SHUTDOWN_TIMEOUT_MS + SESSION_RETIRE_TIMEOUT_MS2 + 500).unref?.();
|
|
83524
83681
|
}), teardownOperations = Promise.allSettled([
|
|
83525
83682
|
runPlannerTeardown("signal"),
|
|
83526
83683
|
reapOrphanShadows(/* @__PURE__ */ new Set(), {
|
|
@@ -84185,9 +84342,9 @@ function maybeFetchAndDispatchReviewSummary(event, envelope, store, reviewSummar
|
|
|
84185
84342
|
}
|
|
84186
84343
|
async function fetchAndDispatchReviewSummary(event, envelope, store, reviewSummaryFetcher) {
|
|
84187
84344
|
try {
|
|
84188
|
-
let abandoned = !1, timer, timeout = new Promise((
|
|
84345
|
+
let abandoned = !1, timer, timeout = new Promise((resolve29) => {
|
|
84189
84346
|
timer = setTimeout(() => {
|
|
84190
|
-
abandoned = !0,
|
|
84347
|
+
abandoned = !0, resolve29(null);
|
|
84191
84348
|
}, TASK_REVIEW_SUMMARY_FETCH_TIMEOUT_MS);
|
|
84192
84349
|
}), summary;
|
|
84193
84350
|
try {
|
|
@@ -88740,8 +88897,8 @@ async function loadTrackBudgetForStatus(args) {
|
|
|
88740
88897
|
try {
|
|
88741
88898
|
let budget = await Promise.race([
|
|
88742
88899
|
args.appsyncClient.getTrackBudgetStatus(args.session.sessionId),
|
|
88743
|
-
new Promise((
|
|
88744
|
-
timer = setTimeout(() =>
|
|
88900
|
+
new Promise((resolve29) => {
|
|
88901
|
+
timer = setTimeout(() => resolve29(null), TRACK_BUDGET_STATUS_TIMEOUT_MS), timer.unref?.();
|
|
88745
88902
|
})
|
|
88746
88903
|
]);
|
|
88747
88904
|
if (budget && typeof args.quorumLoop.markQueuedTaskCancelled == "function")
|
|
@@ -89160,7 +89317,7 @@ async function bindOAuthServer(handler) {
|
|
|
89160
89317
|
for (let i = 0; i < PORT_RANGE_SIZE; i++) {
|
|
89161
89318
|
let port = PRIMARY_PORT + i;
|
|
89162
89319
|
try {
|
|
89163
|
-
let server = await new Promise((
|
|
89320
|
+
let server = await new Promise((resolve29, reject) => {
|
|
89164
89321
|
let s = http3.createServer(handler), onError = (err) => {
|
|
89165
89322
|
s.removeListener("listening", onListening), reject(err);
|
|
89166
89323
|
}, onListening = () => {
|
|
@@ -89170,7 +89327,7 @@ async function bindOAuthServer(handler) {
|
|
|
89170
89327
|
code: postErr?.code,
|
|
89171
89328
|
message: postErr?.message
|
|
89172
89329
|
});
|
|
89173
|
-
}),
|
|
89330
|
+
}), resolve29(s);
|
|
89174
89331
|
};
|
|
89175
89332
|
s.once("error", onError), s.once("listening", onListening), s.listen(port, "localhost");
|
|
89176
89333
|
});
|
|
@@ -89393,14 +89550,14 @@ var AuthService = class _AuthService {
|
|
|
89393
89550
|
if (existing && !keychainManager.isTokenExpired(existing))
|
|
89394
89551
|
return existing;
|
|
89395
89552
|
let state = this.generateState();
|
|
89396
|
-
return new Promise((
|
|
89553
|
+
return new Promise((resolve29, reject) => {
|
|
89397
89554
|
let serverRef = {}, timeoutHandle = null, isResolved = !1, callbackInFlight = !1, forceCloseSockets = (srv) => {
|
|
89398
89555
|
srv.closeAllConnections?.();
|
|
89399
89556
|
}, cleanupAndResolve = (tokens) => {
|
|
89400
89557
|
if (isResolved) return;
|
|
89401
89558
|
isResolved = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null);
|
|
89402
89559
|
let srv = serverRef.server;
|
|
89403
|
-
srv ? (forceCloseSockets(srv), srv.close(() =>
|
|
89560
|
+
srv ? (forceCloseSockets(srv), srv.close(() => resolve29(tokens))) : resolve29(tokens);
|
|
89404
89561
|
}, cleanupAndReject = (err) => {
|
|
89405
89562
|
if (isResolved) return;
|
|
89406
89563
|
isResolved = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null);
|
|
@@ -89461,7 +89618,7 @@ var AuthService = class _AuthService {
|
|
|
89461
89618
|
</html>
|
|
89462
89619
|
`), isResolved = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null), setTimeout(() => {
|
|
89463
89620
|
let srv = serverRef.server;
|
|
89464
|
-
srv ? (forceCloseSockets(srv), srv.close(() =>
|
|
89621
|
+
srv ? (forceCloseSockets(srv), srv.close(() => resolve29(tokenData))) : resolve29(tokenData);
|
|
89465
89622
|
}, 500);
|
|
89466
89623
|
} catch (err) {
|
|
89467
89624
|
let safeMessage = String(err?.message || err).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -89501,12 +89658,12 @@ var AuthService = class _AuthService {
|
|
|
89501
89658
|
*/
|
|
89502
89659
|
async logout() {
|
|
89503
89660
|
let config = getConfig(), deleted = await keychainManager.deleteTokens(getEnvironment());
|
|
89504
|
-
return deleted && new Promise((
|
|
89661
|
+
return deleted && new Promise((resolve29) => {
|
|
89505
89662
|
let serverRef = {}, timeoutHandle = null, isCleanedUp = !1, cleanupAndResolve = (value) => {
|
|
89506
89663
|
if (isCleanedUp) return;
|
|
89507
89664
|
isCleanedUp = !0, timeoutHandle && (clearTimeout(timeoutHandle), timeoutHandle = null);
|
|
89508
89665
|
let srv = serverRef.server;
|
|
89509
|
-
srv ? (srv.closeAllConnections?.(), srv.close(() =>
|
|
89666
|
+
srv ? (srv.closeAllConnections?.(), srv.close(() => resolve29(value))) : resolve29(value);
|
|
89510
89667
|
};
|
|
89511
89668
|
(async () => {
|
|
89512
89669
|
try {
|
|
@@ -91575,9 +91732,9 @@ var LocalModelGatewayBroker = class {
|
|
|
91575
91732
|
let server = http4.createServer((req, res) => {
|
|
91576
91733
|
this.handleHttp(req, res);
|
|
91577
91734
|
});
|
|
91578
|
-
await new Promise((
|
|
91735
|
+
await new Promise((resolve29, reject) => {
|
|
91579
91736
|
server.once("error", reject), server.listen(0, "127.0.0.1", () => {
|
|
91580
|
-
server.removeListener("error", reject),
|
|
91737
|
+
server.removeListener("error", reject), resolve29();
|
|
91581
91738
|
});
|
|
91582
91739
|
});
|
|
91583
91740
|
let addr = server.address();
|
|
@@ -91621,7 +91778,7 @@ var LocalModelGatewayBroker = class {
|
|
|
91621
91778
|
}
|
|
91622
91779
|
if (await Promise.allSettled(survivors.map((r) => r.done)), this.upstreamKeys.clear(), this.credentialGeneration.clear(), this.inflightRefresh.clear(), this.tokenMinter.clear(), this.server) {
|
|
91623
91780
|
let server = this.server;
|
|
91624
|
-
this.server = null, this.boundAddr = null, await new Promise((
|
|
91781
|
+
this.server = null, this.boundAddr = null, await new Promise((resolve29) => server.close(() => resolve29()));
|
|
91625
91782
|
}
|
|
91626
91783
|
logger.info("[Broker] Stopped + zeroized upstream credentials", {
|
|
91627
91784
|
taskId: this.taskId
|
|
@@ -92190,9 +92347,9 @@ var LocalModelGatewayBroker = class {
|
|
|
92190
92347
|
return auth.slice(7).trim();
|
|
92191
92348
|
}
|
|
92192
92349
|
readBody(req) {
|
|
92193
|
-
return new Promise((
|
|
92350
|
+
return new Promise((resolve29, reject) => {
|
|
92194
92351
|
let chunks = [];
|
|
92195
|
-
req.on("data", (c) => chunks.push(c)), req.on("end", () =>
|
|
92352
|
+
req.on("data", (c) => chunks.push(c)), req.on("end", () => resolve29(Buffer.concat(chunks).toString("utf8"))), req.on("error", reject);
|
|
92196
92353
|
});
|
|
92197
92354
|
}
|
|
92198
92355
|
writeJson(res, status, body) {
|
|
@@ -93231,7 +93388,7 @@ var LocalGemmaProcessRunner = class {
|
|
|
93231
93388
|
}
|
|
93232
93389
|
invoke(promptText, purpose, options) {
|
|
93233
93390
|
let responseFormat = options?.responseFormat ?? "json";
|
|
93234
|
-
return new Promise((
|
|
93391
|
+
return new Promise((resolve29, reject) => {
|
|
93235
93392
|
let stdout = "", stderr = "", settled = !1, terminalError = null, timeoutTimer, killTimer = null, child = (0, import_child_process8.spawn)(this.config.command, this.config.args, {
|
|
93236
93393
|
env: scrubSearchApiKeys({
|
|
93237
93394
|
...this.config.env,
|
|
@@ -93291,11 +93448,11 @@ var LocalGemmaProcessRunner = class {
|
|
|
93291
93448
|
return;
|
|
93292
93449
|
}
|
|
93293
93450
|
if (responseFormat === "text") {
|
|
93294
|
-
|
|
93451
|
+
resolve29(trimmed);
|
|
93295
93452
|
return;
|
|
93296
93453
|
}
|
|
93297
93454
|
try {
|
|
93298
|
-
|
|
93455
|
+
resolve29(enforceStrictJsonStdout(trimmed));
|
|
93299
93456
|
} catch (err) {
|
|
93300
93457
|
reject(err);
|
|
93301
93458
|
}
|
|
@@ -93396,12 +93553,12 @@ var FileSystemLocalModelStore = class {
|
|
|
93396
93553
|
}, defaultLocalModelStore = new FileSystemLocalModelStore();
|
|
93397
93554
|
async function fileDigest(pathname) {
|
|
93398
93555
|
let hash3 = (0, import_crypto19.createHash)("sha256"), bytes = 0;
|
|
93399
|
-
return await new Promise((
|
|
93556
|
+
return await new Promise((resolve29, reject) => {
|
|
93400
93557
|
let stream = (0, import_fs4.createReadStream)(pathname);
|
|
93401
93558
|
stream.on("data", (chunk) => {
|
|
93402
93559
|
let buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
93403
93560
|
bytes += buffer.byteLength, hash3.update(buffer);
|
|
93404
|
-
}), stream.on("error", reject), stream.on("end",
|
|
93561
|
+
}), stream.on("error", reject), stream.on("end", resolve29);
|
|
93405
93562
|
}), { sha256: hash3.digest("hex"), bytes };
|
|
93406
93563
|
}
|
|
93407
93564
|
function resolveRedirectUrl(currentUrl, location) {
|
|
@@ -93414,7 +93571,7 @@ function resolveRedirectUrl(currentUrl, location) {
|
|
|
93414
93571
|
}
|
|
93415
93572
|
}
|
|
93416
93573
|
async function downloadHttpsToFile(url, destinationPath, expectedBytes, redirectBudget = 3) {
|
|
93417
|
-
await new Promise((
|
|
93574
|
+
await new Promise((resolve29, reject) => {
|
|
93418
93575
|
let req = import_https2.default.get(url, (res) => {
|
|
93419
93576
|
let status = res.statusCode ?? 0;
|
|
93420
93577
|
if ([301, 302, 303, 307, 308].includes(status)) {
|
|
@@ -93424,7 +93581,7 @@ async function downloadHttpsToFile(url, destinationPath, expectedBytes, redirect
|
|
|
93424
93581
|
reject(new Error("local Gemma download redirect was invalid or exceeded the limit"));
|
|
93425
93582
|
return;
|
|
93426
93583
|
}
|
|
93427
|
-
downloadHttpsToFile(redirected, destinationPath, expectedBytes, redirectBudget - 1).then(
|
|
93584
|
+
downloadHttpsToFile(redirected, destinationPath, expectedBytes, redirectBudget - 1).then(resolve29).catch(reject);
|
|
93428
93585
|
return;
|
|
93429
93586
|
}
|
|
93430
93587
|
if (status !== 200) {
|
|
@@ -93452,7 +93609,7 @@ async function downloadHttpsToFile(url, destinationPath, expectedBytes, redirect
|
|
|
93452
93609
|
`local Gemma download exceeded pinned bytes ${expectedBytes}`
|
|
93453
93610
|
)
|
|
93454
93611
|
);
|
|
93455
|
-
}), (0, import_promises3.pipeline)(res, file).then(() =>
|
|
93612
|
+
}), (0, import_promises3.pipeline)(res, file).then(() => resolve29()).catch(reject);
|
|
93456
93613
|
});
|
|
93457
93614
|
req.on("error", reject), req.setTimeout(3e4, () => {
|
|
93458
93615
|
req.destroy(new Error("local Gemma download timed out"));
|
|
@@ -93470,7 +93627,7 @@ var defaultLocalModelDownloadTransport = {
|
|
|
93470
93627
|
this.stallTimeoutMs = stallTimeoutMs;
|
|
93471
93628
|
}
|
|
93472
93629
|
pull(model, localOllamaHost, onProgress) {
|
|
93473
|
-
return new Promise((
|
|
93630
|
+
return new Promise((resolve29, reject) => {
|
|
93474
93631
|
let env = scrubSearchApiKeys({ ...process.env });
|
|
93475
93632
|
localOllamaHost ? env.OLLAMA_HOST = localOllamaHost : delete env.OLLAMA_HOST;
|
|
93476
93633
|
let resolvedCommand = this.command || process.env.CODEVIBE_OLLAMA_COMMAND || DEFAULT_OLLAMA_COMMAND, child = this.spawnPull(resolvedCommand, ["pull", model], {
|
|
@@ -93506,7 +93663,7 @@ var defaultLocalModelDownloadTransport = {
|
|
|
93506
93663
|
}), child.on("close", (code, signal) => {
|
|
93507
93664
|
if (timer && clearTimeout(timer), !stalled) {
|
|
93508
93665
|
if (code === 0) {
|
|
93509
|
-
|
|
93666
|
+
resolve29();
|
|
93510
93667
|
return;
|
|
93511
93668
|
}
|
|
93512
93669
|
reject(
|
|
@@ -94201,8 +94358,8 @@ async function retireUnownedAdmittedSession(appsyncClient, sessionId) {
|
|
|
94201
94358
|
try {
|
|
94202
94359
|
await Promise.race([
|
|
94203
94360
|
appsyncClient.updateSession({ sessionId, status: "INACTIVE" /* INACTIVE */, ...cleanExit }),
|
|
94204
|
-
new Promise((
|
|
94205
|
-
timer = setTimeout(
|
|
94361
|
+
new Promise((resolve29) => {
|
|
94362
|
+
timer = setTimeout(resolve29, SESSION_RETIRE_TIMEOUT_MS), timer.unref?.();
|
|
94206
94363
|
})
|
|
94207
94364
|
]);
|
|
94208
94365
|
} catch (err) {
|
|
@@ -94497,10 +94654,10 @@ Run \`codevibe vendor-key setup\`` + (checksCodex ? " (or `codevibe vendor-key i
|
|
|
94497
94654
|
async function promptInstallLocalModel() {
|
|
94498
94655
|
let rl = require("readline").createInterface({ input: process.stdin, output: process.stdout });
|
|
94499
94656
|
try {
|
|
94500
|
-
let trimmed = (await new Promise((
|
|
94657
|
+
let trimmed = (await new Promise((resolve29) => {
|
|
94501
94658
|
rl.question(
|
|
94502
94659
|
"Orchestration Mode needs the local model (~7GB), which isn't installed. Install it now? [Y/n]: ",
|
|
94503
|
-
|
|
94660
|
+
resolve29
|
|
94504
94661
|
);
|
|
94505
94662
|
})).trim().toLowerCase();
|
|
94506
94663
|
return trimmed === "" || trimmed.startsWith("y");
|