@zixt/host 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +190 -138
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ import { homedir } from "node:os";
|
|
|
31
31
|
// package.json
|
|
32
32
|
var package_default = {
|
|
33
33
|
name: "@zixt/host",
|
|
34
|
-
version: "0.0.
|
|
34
|
+
version: "0.0.24",
|
|
35
35
|
type: "module",
|
|
36
36
|
exports: {
|
|
37
37
|
".": "./src/client.ts",
|
|
@@ -17579,7 +17579,7 @@ var SetAgentStatusRequest = external_exports.object({
|
|
|
17579
17579
|
status: AgentStatus.exclude(["draft"]),
|
|
17580
17580
|
/**
|
|
17581
17581
|
* Backwards-compatible override for older clients. When omitted, activation
|
|
17582
|
-
* keeps
|
|
17582
|
+
* keeps configured Integration access; legacy rows without it inherit `all`.
|
|
17583
17583
|
*/
|
|
17584
17584
|
activation: external_exports.object({
|
|
17585
17585
|
autonomyPreset: AutonomyPreset,
|
|
@@ -18994,7 +18994,7 @@ async function generateTaskTitle(instructions, runner) {
|
|
|
18994
18994
|
instructions.slice(0, INSTRUCTIONS_BUDGET),
|
|
18995
18995
|
"</task_request>"
|
|
18996
18996
|
].join("\n");
|
|
18997
|
-
return new Promise((
|
|
18997
|
+
return new Promise((resolve14) => {
|
|
18998
18998
|
const child = spawnCli(
|
|
18999
18999
|
command,
|
|
19000
19000
|
[
|
|
@@ -19017,7 +19017,7 @@ async function generateTaskTitle(instructions, runner) {
|
|
|
19017
19017
|
if (settled) return;
|
|
19018
19018
|
settled = true;
|
|
19019
19019
|
clearTimeout(timer);
|
|
19020
|
-
|
|
19020
|
+
resolve14(value);
|
|
19021
19021
|
};
|
|
19022
19022
|
const timer = setTimeout(() => {
|
|
19023
19023
|
child.kill();
|
|
@@ -19543,7 +19543,7 @@ async function waitForOperationGrantRetry(retryAt, signal) {
|
|
|
19543
19543
|
const deadline = Date.parse(retryAt);
|
|
19544
19544
|
if (!Number.isFinite(deadline) || signal.aborted) return false;
|
|
19545
19545
|
if (deadline <= Date.now()) return true;
|
|
19546
|
-
return await new Promise((
|
|
19546
|
+
return await new Promise((resolve14) => {
|
|
19547
19547
|
let settled = false;
|
|
19548
19548
|
let timer;
|
|
19549
19549
|
const finish = (ready) => {
|
|
@@ -19551,7 +19551,7 @@ async function waitForOperationGrantRetry(retryAt, signal) {
|
|
|
19551
19551
|
settled = true;
|
|
19552
19552
|
if (timer) clearTimeout(timer);
|
|
19553
19553
|
signal.removeEventListener("abort", onAbort);
|
|
19554
|
-
|
|
19554
|
+
resolve14(ready);
|
|
19555
19555
|
};
|
|
19556
19556
|
const onAbort = () => finish(false);
|
|
19557
19557
|
const schedule = () => {
|
|
@@ -19815,22 +19815,22 @@ var HostClient = class _HostClient {
|
|
|
19815
19815
|
const unwindingAssignments = [...this.activeAssignments.values()];
|
|
19816
19816
|
for (const cancel of this.cancels.values()) cancel(stopReason);
|
|
19817
19817
|
for (const entry of this.secretGrants.values()) {
|
|
19818
|
-
for (const
|
|
19818
|
+
for (const resolve14 of entry.resolvers) resolve14({});
|
|
19819
19819
|
entry.resolvers = [];
|
|
19820
19820
|
delete entry.value;
|
|
19821
19821
|
}
|
|
19822
19822
|
for (const entry of this.connectionGrants.values()) {
|
|
19823
|
-
for (const
|
|
19823
|
+
for (const resolve14 of entry.resolvers) resolve14([]);
|
|
19824
19824
|
entry.resolvers = [];
|
|
19825
19825
|
delete entry.value;
|
|
19826
19826
|
}
|
|
19827
19827
|
for (const entry of this.providerGrants.values()) {
|
|
19828
|
-
for (const
|
|
19828
|
+
for (const resolve14 of entry.resolvers) resolve14([]);
|
|
19829
19829
|
entry.resolvers = [];
|
|
19830
19830
|
delete entry.value;
|
|
19831
19831
|
}
|
|
19832
19832
|
for (const waiters of this.approvalWaiters.values()) {
|
|
19833
|
-
for (const
|
|
19833
|
+
for (const resolve14 of waiters.values()) resolve14({ approved: false, guidance: reason });
|
|
19834
19834
|
}
|
|
19835
19835
|
for (const waiters of this.agentOpWaiters.values()) {
|
|
19836
19836
|
for (const waiter of waiters.values()) {
|
|
@@ -19856,9 +19856,9 @@ var HostClient = class _HostClient {
|
|
|
19856
19856
|
let drainTimer;
|
|
19857
19857
|
const drained = await Promise.race([
|
|
19858
19858
|
Promise.allSettled(runs).then(() => true),
|
|
19859
|
-
new Promise((
|
|
19859
|
+
new Promise((resolve14) => {
|
|
19860
19860
|
drainTimer = setTimeout(
|
|
19861
|
-
() =>
|
|
19861
|
+
() => resolve14(false),
|
|
19862
19862
|
this.opts.unwindTimeoutMs ?? _HostClient.DEFAULT_UNWIND_TIMEOUT_MS
|
|
19863
19863
|
);
|
|
19864
19864
|
drainTimer.unref?.();
|
|
@@ -19938,9 +19938,9 @@ var HostClient = class _HostClient {
|
|
|
19938
19938
|
let frameDrainTimer;
|
|
19939
19939
|
const framesDrained = await Promise.race([
|
|
19940
19940
|
frameTail.then(() => true),
|
|
19941
|
-
new Promise((
|
|
19941
|
+
new Promise((resolve14) => {
|
|
19942
19942
|
frameDrainTimer = setTimeout(
|
|
19943
|
-
() =>
|
|
19943
|
+
() => resolve14(false),
|
|
19944
19944
|
this.opts.unwindTimeoutMs ?? _HostClient.DEFAULT_UNWIND_TIMEOUT_MS
|
|
19945
19945
|
);
|
|
19946
19946
|
frameDrainTimer.unref?.();
|
|
@@ -20442,7 +20442,7 @@ var HostClient = class _HostClient {
|
|
|
20442
20442
|
const entry = this.secretGrants.get(key) ?? { resolvers: [] };
|
|
20443
20443
|
entry.value = message.secrets;
|
|
20444
20444
|
entry.expiresAt = expiresAt;
|
|
20445
|
-
for (const
|
|
20445
|
+
for (const resolve14 of entry.resolvers) resolve14(message.secrets);
|
|
20446
20446
|
entry.resolvers = [];
|
|
20447
20447
|
this.secretGrants.set(key, entry);
|
|
20448
20448
|
return;
|
|
@@ -20473,13 +20473,13 @@ var HostClient = class _HostClient {
|
|
|
20473
20473
|
const entry = this.connectionGrants.get(key) ?? { resolvers: [] };
|
|
20474
20474
|
entry.value = message.connections;
|
|
20475
20475
|
entry.expiresAt = expiresAt;
|
|
20476
|
-
for (const
|
|
20476
|
+
for (const resolve14 of entry.resolvers) resolve14(message.connections);
|
|
20477
20477
|
entry.resolvers = [];
|
|
20478
20478
|
this.connectionGrants.set(key, entry);
|
|
20479
20479
|
const providerEntry = this.providerGrants.get(key) ?? { resolvers: [] };
|
|
20480
20480
|
providerEntry.value = providers;
|
|
20481
20481
|
providerEntry.expiresAt = authorityExpiresAt;
|
|
20482
|
-
for (const
|
|
20482
|
+
for (const resolve14 of providerEntry.resolvers) resolve14(providers);
|
|
20483
20483
|
providerEntry.resolvers = [];
|
|
20484
20484
|
this.providerGrants.set(key, providerEntry);
|
|
20485
20485
|
return;
|
|
@@ -20568,8 +20568,8 @@ var HostClient = class _HostClient {
|
|
|
20568
20568
|
return redactCredentialText(text, sensitiveSnapshot()).slice(0, maxLength);
|
|
20569
20569
|
};
|
|
20570
20570
|
let resolveCancelled;
|
|
20571
|
-
const cancelledPromise = new Promise((
|
|
20572
|
-
resolveCancelled =
|
|
20571
|
+
const cancelledPromise = new Promise((resolve14) => {
|
|
20572
|
+
resolveCancelled = resolve14;
|
|
20573
20573
|
});
|
|
20574
20574
|
const endAuthority = (reason = "cloud_cancel") => {
|
|
20575
20575
|
if (stopReason) return;
|
|
@@ -20578,21 +20578,21 @@ var HostClient = class _HostClient {
|
|
|
20578
20578
|
authorityController.abort(reason);
|
|
20579
20579
|
const secretEntry = this.secretGrants.get(cancelKey);
|
|
20580
20580
|
if (secretEntry) {
|
|
20581
|
-
for (const
|
|
20581
|
+
for (const resolve14 of secretEntry.resolvers) resolve14({});
|
|
20582
20582
|
secretEntry.resolvers = [];
|
|
20583
20583
|
delete secretEntry.value;
|
|
20584
20584
|
}
|
|
20585
20585
|
this.secretGrants.delete(cancelKey);
|
|
20586
20586
|
const connectionEntry = this.connectionGrants.get(cancelKey);
|
|
20587
20587
|
if (connectionEntry) {
|
|
20588
|
-
for (const
|
|
20588
|
+
for (const resolve14 of connectionEntry.resolvers) resolve14([]);
|
|
20589
20589
|
connectionEntry.resolvers = [];
|
|
20590
20590
|
delete connectionEntry.value;
|
|
20591
20591
|
}
|
|
20592
20592
|
this.connectionGrants.delete(cancelKey);
|
|
20593
20593
|
const providerEntry = this.providerGrants.get(cancelKey);
|
|
20594
20594
|
if (providerEntry) {
|
|
20595
|
-
for (const
|
|
20595
|
+
for (const resolve14 of providerEntry.resolvers) resolve14([]);
|
|
20596
20596
|
providerEntry.resolvers = [];
|
|
20597
20597
|
delete providerEntry.value;
|
|
20598
20598
|
}
|
|
@@ -20600,8 +20600,8 @@ var HostClient = class _HostClient {
|
|
|
20600
20600
|
this.clearAuthorityExpiry(cancelKey);
|
|
20601
20601
|
const approvalWaiters = this.approvalWaiters.get(cancelKey);
|
|
20602
20602
|
if (approvalWaiters) {
|
|
20603
|
-
for (const
|
|
20604
|
-
|
|
20603
|
+
for (const resolve14 of approvalWaiters.values()) {
|
|
20604
|
+
resolve14({ approved: false, guidance: "task was cancelled" });
|
|
20605
20605
|
}
|
|
20606
20606
|
approvalWaiters.clear();
|
|
20607
20607
|
}
|
|
@@ -20727,9 +20727,9 @@ var HostClient = class _HostClient {
|
|
|
20727
20727
|
return value;
|
|
20728
20728
|
};
|
|
20729
20729
|
if (entry.value) return Promise.resolve(capture(entry.value));
|
|
20730
|
-
return new Promise((
|
|
20731
|
-
entry.resolvers.push((value) =>
|
|
20732
|
-
setTimeout(() =>
|
|
20730
|
+
return new Promise((resolve14) => {
|
|
20731
|
+
entry.resolvers.push((value) => resolve14(capture(value)));
|
|
20732
|
+
setTimeout(() => resolve14(capture(entry.value ?? {})), _HostClient.SECRETS_WAIT_MS);
|
|
20733
20733
|
});
|
|
20734
20734
|
};
|
|
20735
20735
|
const connections = () => {
|
|
@@ -20746,9 +20746,9 @@ var HostClient = class _HostClient {
|
|
|
20746
20746
|
return value;
|
|
20747
20747
|
};
|
|
20748
20748
|
if (entry.value) return Promise.resolve(capture(entry.value));
|
|
20749
|
-
return new Promise((
|
|
20750
|
-
entry.resolvers.push((value) =>
|
|
20751
|
-
setTimeout(() =>
|
|
20749
|
+
return new Promise((resolve14) => {
|
|
20750
|
+
entry.resolvers.push((value) => resolve14(capture(value)));
|
|
20751
|
+
setTimeout(() => resolve14(capture(entry.value ?? [])), _HostClient.SECRETS_WAIT_MS);
|
|
20752
20752
|
});
|
|
20753
20753
|
};
|
|
20754
20754
|
const providers = () => {
|
|
@@ -20765,9 +20765,9 @@ var HostClient = class _HostClient {
|
|
|
20765
20765
|
return value;
|
|
20766
20766
|
};
|
|
20767
20767
|
if (entry.value !== void 0) return Promise.resolve(capture(entry.value));
|
|
20768
|
-
return new Promise((
|
|
20769
|
-
entry.resolvers.push((value) =>
|
|
20770
|
-
setTimeout(() =>
|
|
20768
|
+
return new Promise((resolve14) => {
|
|
20769
|
+
entry.resolvers.push((value) => resolve14(capture(value)));
|
|
20770
|
+
setTimeout(() => resolve14(capture(entry.value ?? [])), _HostClient.SECRETS_WAIT_MS);
|
|
20771
20771
|
});
|
|
20772
20772
|
};
|
|
20773
20773
|
const linear = async () => {
|
|
@@ -20793,13 +20793,13 @@ var HostClient = class _HostClient {
|
|
|
20793
20793
|
payload: safe(payload, 5e4),
|
|
20794
20794
|
...questionChoices ? { questionChoices: [...questionChoices] } : {}
|
|
20795
20795
|
});
|
|
20796
|
-
return new Promise((
|
|
20796
|
+
return new Promise((resolve14) => {
|
|
20797
20797
|
const waiters = this.approvalWaiters.get(cancelKey) ?? /* @__PURE__ */ new Map();
|
|
20798
20798
|
this.approvalWaiters.set(cancelKey, waiters);
|
|
20799
|
-
waiters.set(requestId,
|
|
20799
|
+
waiters.set(requestId, resolve14);
|
|
20800
20800
|
void cancelledPromise.then(() => {
|
|
20801
20801
|
if (waiters.delete(requestId)) {
|
|
20802
|
-
|
|
20802
|
+
resolve14({ approved: false, guidance: "task was cancelled" });
|
|
20803
20803
|
}
|
|
20804
20804
|
});
|
|
20805
20805
|
});
|
|
@@ -20837,11 +20837,11 @@ var HostClient = class _HostClient {
|
|
|
20837
20837
|
if (existing) message = existing;
|
|
20838
20838
|
else terminalMessages.set(requestId, message);
|
|
20839
20839
|
}
|
|
20840
|
-
return new Promise((
|
|
20840
|
+
return new Promise((resolve14) => {
|
|
20841
20841
|
const waiters = this.agentOpWaiters.get(cancelKey) ?? /* @__PURE__ */ new Map();
|
|
20842
20842
|
this.agentOpWaiters.set(cancelKey, waiters);
|
|
20843
20843
|
if (waiters.has(requestId)) {
|
|
20844
|
-
|
|
20844
|
+
resolve14({ ok: false, error: "provider settlement request is already in flight" });
|
|
20845
20845
|
return;
|
|
20846
20846
|
}
|
|
20847
20847
|
const timer = setTimeout(() => {
|
|
@@ -20852,7 +20852,7 @@ var HostClient = class _HostClient {
|
|
|
20852
20852
|
(pending) => !(pending.type === "agent.op" && pending.requestId === requestId)
|
|
20853
20853
|
);
|
|
20854
20854
|
}
|
|
20855
|
-
|
|
20855
|
+
resolve14({
|
|
20856
20856
|
ok: false,
|
|
20857
20857
|
error: terminal ? "The provider call completed, but Zixt could not record its outcome. Do not retry; wait for reconciliation." : "the platform did not answer in time; verify with a list_* tool before retrying a mutating call"
|
|
20858
20858
|
});
|
|
@@ -20860,7 +20860,7 @@ var HostClient = class _HostClient {
|
|
|
20860
20860
|
}, _HostClient.AGENT_OP_TIMEOUT_MS);
|
|
20861
20861
|
timer.unref?.();
|
|
20862
20862
|
waiters.set(requestId, {
|
|
20863
|
-
resolve:
|
|
20863
|
+
resolve: resolve14,
|
|
20864
20864
|
timer,
|
|
20865
20865
|
...terminal ? { terminalMessage: message } : {}
|
|
20866
20866
|
});
|
|
@@ -20906,12 +20906,12 @@ var HostClient = class _HostClient {
|
|
|
20906
20906
|
"No GitHub change was attempted; the authority grant request was invalid."
|
|
20907
20907
|
);
|
|
20908
20908
|
}
|
|
20909
|
-
const outcome = await new Promise((
|
|
20909
|
+
const outcome = await new Promise((resolve14) => {
|
|
20910
20910
|
const timer = setTimeout(() => {
|
|
20911
20911
|
const waiter = this.operationGrantWaiters.get(requestId);
|
|
20912
20912
|
if (!waiter) return;
|
|
20913
20913
|
this.operationGrantWaiters.delete(requestId);
|
|
20914
|
-
|
|
20914
|
+
resolve14({ grant: null, retryable: true, reason: "no_reply_from_zixt" });
|
|
20915
20915
|
}, this.operationGrantTimeoutMs);
|
|
20916
20916
|
timer.unref?.();
|
|
20917
20917
|
this.operationGrantWaiters.set(requestId, {
|
|
@@ -20924,9 +20924,9 @@ var HostClient = class _HostClient {
|
|
|
20924
20924
|
timer,
|
|
20925
20925
|
accept: (grant) => {
|
|
20926
20926
|
addSensitiveValues(providerGrantSensitiveValues(grant));
|
|
20927
|
-
|
|
20927
|
+
resolve14({ grant });
|
|
20928
20928
|
},
|
|
20929
|
-
deny: (retryable, reason, detail, retryAt, retryCode) =>
|
|
20929
|
+
deny: (retryable, reason, detail, retryAt, retryCode) => resolve14({
|
|
20930
20930
|
grant: null,
|
|
20931
20931
|
retryable,
|
|
20932
20932
|
reason,
|
|
@@ -20940,7 +20940,7 @@ var HostClient = class _HostClient {
|
|
|
20940
20940
|
} catch {
|
|
20941
20941
|
clearTimeout(timer);
|
|
20942
20942
|
this.operationGrantWaiters.delete(requestId);
|
|
20943
|
-
|
|
20943
|
+
resolve14({ grant: null, retryable: false, reason: "connection_unavailable" });
|
|
20944
20944
|
}
|
|
20945
20945
|
});
|
|
20946
20946
|
if (outcome.grant) {
|
|
@@ -20996,7 +20996,7 @@ var HostClient = class _HostClient {
|
|
|
20996
20996
|
)
|
|
20997
20997
|
);
|
|
20998
20998
|
}
|
|
20999
|
-
return new Promise((
|
|
20999
|
+
return new Promise((resolve14, reject3) => {
|
|
21000
21000
|
const timer = setTimeout(() => {
|
|
21001
21001
|
if (this.browserCredentialWaiters.delete(requestId)) {
|
|
21002
21002
|
reject3(
|
|
@@ -21015,7 +21015,7 @@ var HostClient = class _HostClient {
|
|
|
21015
21015
|
timer,
|
|
21016
21016
|
accept: (credential) => {
|
|
21017
21017
|
addSensitiveValues(webLoginSensitiveValues(credential));
|
|
21018
|
-
|
|
21018
|
+
resolve14(credential);
|
|
21019
21019
|
},
|
|
21020
21020
|
deny: (reason) => reject3(new Error(reason))
|
|
21021
21021
|
});
|
|
@@ -21313,14 +21313,14 @@ async function observeWindowsGuardianNonce(pid, nonce) {
|
|
|
21313
21313
|
"Windows runner identity could not be observed"
|
|
21314
21314
|
);
|
|
21315
21315
|
}
|
|
21316
|
-
return new Promise((
|
|
21316
|
+
return new Promise((resolve14, reject3) => {
|
|
21317
21317
|
let done = false;
|
|
21318
21318
|
const finish = (result) => {
|
|
21319
21319
|
if (done) return;
|
|
21320
21320
|
done = true;
|
|
21321
21321
|
clearTimeout(timeout);
|
|
21322
21322
|
if (result instanceof Error) reject3(result);
|
|
21323
|
-
else
|
|
21323
|
+
else resolve14(result);
|
|
21324
21324
|
};
|
|
21325
21325
|
const timeout = setTimeout(
|
|
21326
21326
|
() => finish(
|
|
@@ -21365,7 +21365,7 @@ async function observePosixGuardianNonce(pid, nonce) {
|
|
|
21365
21365
|
);
|
|
21366
21366
|
}
|
|
21367
21367
|
}
|
|
21368
|
-
return new Promise((
|
|
21368
|
+
return new Promise((resolve14, reject3) => {
|
|
21369
21369
|
const observer = spawn2("/bin/ps", ["-ww", "-o", "command=", "-p", String(pid)], {
|
|
21370
21370
|
stdio: ["ignore", "pipe", "ignore"]
|
|
21371
21371
|
});
|
|
@@ -21376,7 +21376,7 @@ async function observePosixGuardianNonce(pid, nonce) {
|
|
|
21376
21376
|
done = true;
|
|
21377
21377
|
clearTimeout(timeout);
|
|
21378
21378
|
if (result instanceof Error) reject3(result);
|
|
21379
|
-
else
|
|
21379
|
+
else resolve14(result);
|
|
21380
21380
|
};
|
|
21381
21381
|
const timeout = setTimeout(() => {
|
|
21382
21382
|
observer.kill("SIGKILL");
|
|
@@ -21423,7 +21423,7 @@ async function observeGuardianIdentity(pid, identity) {
|
|
|
21423
21423
|
return process.platform === "win32" ? observeWindowsGuardianNonce(pid, identity.nonce) : observePosixGuardianNonce(pid, identity.nonce);
|
|
21424
21424
|
}
|
|
21425
21425
|
function delay(ms) {
|
|
21426
|
-
return new Promise((
|
|
21426
|
+
return new Promise((resolve14) => setTimeout(resolve14, ms));
|
|
21427
21427
|
}
|
|
21428
21428
|
function posixProcessRecordsFromPs(output) {
|
|
21429
21429
|
const records = [];
|
|
@@ -21456,7 +21456,7 @@ function posixProcessRecordsFromPs(output) {
|
|
|
21456
21456
|
return records;
|
|
21457
21457
|
}
|
|
21458
21458
|
async function snapshotPosixProcesses() {
|
|
21459
|
-
return new Promise((
|
|
21459
|
+
return new Promise((resolve14, reject3) => {
|
|
21460
21460
|
const observer = spawn2("/bin/ps", ["-axo", "uid=,pid=,ppid=,pgid=,stat="], {
|
|
21461
21461
|
stdio: ["ignore", "pipe", "ignore"]
|
|
21462
21462
|
});
|
|
@@ -21469,7 +21469,7 @@ async function snapshotPosixProcesses() {
|
|
|
21469
21469
|
if (error52) reject3(error52);
|
|
21470
21470
|
else {
|
|
21471
21471
|
try {
|
|
21472
|
-
|
|
21472
|
+
resolve14(posixProcessRecordsFromPs(output));
|
|
21473
21473
|
} catch (caught) {
|
|
21474
21474
|
reject3(caught);
|
|
21475
21475
|
}
|
|
@@ -21804,7 +21804,7 @@ async function snapshotWindowsDescendants(rootPid) {
|
|
|
21804
21804
|
"Windows process-tree observation could not start"
|
|
21805
21805
|
);
|
|
21806
21806
|
}
|
|
21807
|
-
return new Promise((
|
|
21807
|
+
return new Promise((resolve14, reject3) => {
|
|
21808
21808
|
let done = false;
|
|
21809
21809
|
const timeout = setTimeout(() => {
|
|
21810
21810
|
if (done) return;
|
|
@@ -21831,7 +21831,7 @@ async function snapshotWindowsDescendants(rootPid) {
|
|
|
21831
21831
|
return;
|
|
21832
21832
|
}
|
|
21833
21833
|
try {
|
|
21834
|
-
|
|
21834
|
+
resolve14(completeWindowsDescendantPids(rootPid, processes));
|
|
21835
21835
|
} catch (caught) {
|
|
21836
21836
|
reject3(caught);
|
|
21837
21837
|
}
|
|
@@ -21878,7 +21878,7 @@ async function waitForProcessesExit(pids, timeoutMs) {
|
|
|
21878
21878
|
}
|
|
21879
21879
|
async function runTaskkill(pid, command, timeoutMs = TASKKILL_TIMEOUT_MS, independentlyTrackedPids = []) {
|
|
21880
21880
|
const trustedCommand = command ?? defaultTaskkillCommand();
|
|
21881
|
-
const result = await new Promise((
|
|
21881
|
+
const result = await new Promise((resolve14, reject3) => {
|
|
21882
21882
|
const killer = spawn2(trustedCommand, ["/PID", String(pid), "/T", "/F"], {
|
|
21883
21883
|
stdio: ["ignore", "pipe", "pipe"],
|
|
21884
21884
|
windowsHide: true
|
|
@@ -21913,7 +21913,7 @@ async function runTaskkill(pid, command, timeoutMs = TASKKILL_TIMEOUT_MS, indepe
|
|
|
21913
21913
|
done = true;
|
|
21914
21914
|
clearTimeout(timeout);
|
|
21915
21915
|
if (error52) reject3(error52);
|
|
21916
|
-
else
|
|
21916
|
+
else resolve14({ code: killer.exitCode, output, outputTruncated });
|
|
21917
21917
|
};
|
|
21918
21918
|
killer.once(
|
|
21919
21919
|
"error",
|
|
@@ -22590,12 +22590,12 @@ async function createWindowsJobContainment(pid, options) {
|
|
|
22590
22590
|
stderr = `${stderr}${String(chunk)}`.slice(-HELPER_OUTPUT_LIMIT);
|
|
22591
22591
|
});
|
|
22592
22592
|
const helperEvents = helper;
|
|
22593
|
-
const exited = new Promise((
|
|
22593
|
+
const exited = new Promise((resolve14) => {
|
|
22594
22594
|
let completed = false;
|
|
22595
22595
|
const complete = (code, signal) => {
|
|
22596
22596
|
if (completed) return;
|
|
22597
22597
|
completed = true;
|
|
22598
|
-
|
|
22598
|
+
resolve14({ code, signal });
|
|
22599
22599
|
};
|
|
22600
22600
|
helperEvents.once("error", () => {
|
|
22601
22601
|
failProtocol(new Error("Windows Job Object helper could not start"));
|
|
@@ -22608,7 +22608,7 @@ async function createWindowsJobContainment(pid, options) {
|
|
|
22608
22608
|
});
|
|
22609
22609
|
const nextLine = async (expected) => {
|
|
22610
22610
|
if (protocolFailure) throw protocolFailure;
|
|
22611
|
-
const line = lines.shift() ?? await new Promise((
|
|
22611
|
+
const line = lines.shift() ?? await new Promise((resolve14, reject3) => {
|
|
22612
22612
|
const timer = setTimeout(
|
|
22613
22613
|
() => reject3(timeoutError("Windows Job Object helper did not answer in time")),
|
|
22614
22614
|
timeoutMs
|
|
@@ -22616,7 +22616,7 @@ async function createWindowsJobContainment(pid, options) {
|
|
|
22616
22616
|
timer.unref?.();
|
|
22617
22617
|
lineWaiters.push((value) => {
|
|
22618
22618
|
clearTimeout(timer);
|
|
22619
|
-
|
|
22619
|
+
resolve14(value);
|
|
22620
22620
|
});
|
|
22621
22621
|
});
|
|
22622
22622
|
if (protocolFailure) throw protocolFailure;
|
|
@@ -22629,8 +22629,8 @@ async function createWindowsJobContainment(pid, options) {
|
|
|
22629
22629
|
}
|
|
22630
22630
|
const stopped = await Promise.race([
|
|
22631
22631
|
exited.then(() => true),
|
|
22632
|
-
new Promise((
|
|
22633
|
-
const timer = setTimeout(() =>
|
|
22632
|
+
new Promise((resolve14) => {
|
|
22633
|
+
const timer = setTimeout(() => resolve14(false), timeoutMs);
|
|
22634
22634
|
timer.unref?.();
|
|
22635
22635
|
})
|
|
22636
22636
|
]);
|
|
@@ -22689,7 +22689,7 @@ async function awaitWindowsContainmentGate(env = process.env, input = process.st
|
|
|
22689
22689
|
if (nonce === void 0) return true;
|
|
22690
22690
|
if (!SAFE_NONCE2.test(nonce)) return false;
|
|
22691
22691
|
const expected = windowsContainmentGate(nonce).trimEnd();
|
|
22692
|
-
return new Promise((
|
|
22692
|
+
return new Promise((resolve14) => {
|
|
22693
22693
|
let pending = Buffer.alloc(0);
|
|
22694
22694
|
let settled = false;
|
|
22695
22695
|
const finish = (result) => {
|
|
@@ -22700,7 +22700,7 @@ async function awaitWindowsContainmentGate(env = process.env, input = process.st
|
|
|
22700
22700
|
input.off("end", onEnd);
|
|
22701
22701
|
input.off("error", onEnd);
|
|
22702
22702
|
if (result) input.pause();
|
|
22703
|
-
|
|
22703
|
+
resolve14(result);
|
|
22704
22704
|
};
|
|
22705
22705
|
const onData = (chunk) => {
|
|
22706
22706
|
pending = Buffer.concat([pending, chunk]);
|
|
@@ -23125,7 +23125,7 @@ async function installRelease(version2, options = {}) {
|
|
|
23125
23125
|
installerContainmentSetupError = error52;
|
|
23126
23126
|
return null;
|
|
23127
23127
|
}) : Promise.resolve(null);
|
|
23128
|
-
const installed = await new Promise((
|
|
23128
|
+
const installed = await new Promise((resolve14, reject3) => {
|
|
23129
23129
|
let finished = false;
|
|
23130
23130
|
let cleanupStarted = false;
|
|
23131
23131
|
let exitObserved = false;
|
|
@@ -23141,7 +23141,7 @@ async function installRelease(version2, options = {}) {
|
|
|
23141
23141
|
finished = true;
|
|
23142
23142
|
clearTimeout(timer);
|
|
23143
23143
|
options.signal?.removeEventListener("abort", requestCleanup);
|
|
23144
|
-
|
|
23144
|
+
resolve14(result);
|
|
23145
23145
|
};
|
|
23146
23146
|
const requestCleanup = () => {
|
|
23147
23147
|
if (cleanupStarted || finished) return;
|
|
@@ -23454,11 +23454,11 @@ async function runWorkerCompatibilityProxy(env = process.env, argv = process.arg
|
|
|
23454
23454
|
child.stdin?.on("error", () => {
|
|
23455
23455
|
});
|
|
23456
23456
|
process.stdin.pipe(child.stdin);
|
|
23457
|
-
return new Promise((
|
|
23458
|
-
child.once("error", () =>
|
|
23457
|
+
return new Promise((resolve14) => {
|
|
23458
|
+
child.once("error", () => resolve14(1));
|
|
23459
23459
|
child.once("exit", (code) => {
|
|
23460
23460
|
process.stdin.unpipe(child.stdin);
|
|
23461
|
-
|
|
23461
|
+
resolve14(code ?? 1);
|
|
23462
23462
|
});
|
|
23463
23463
|
});
|
|
23464
23464
|
}
|
|
@@ -23536,11 +23536,11 @@ async function launchHostSupervisor(options = {}) {
|
|
|
23536
23536
|
const waitOrStop = async (ms) => {
|
|
23537
23537
|
if (stopping) return false;
|
|
23538
23538
|
if (!customDelay) {
|
|
23539
|
-
await new Promise((
|
|
23539
|
+
await new Promise((resolve14) => {
|
|
23540
23540
|
const finish = () => {
|
|
23541
23541
|
clearTimeout(timer);
|
|
23542
23542
|
stopController.signal.removeEventListener("abort", finish);
|
|
23543
|
-
|
|
23543
|
+
resolve14();
|
|
23544
23544
|
};
|
|
23545
23545
|
const timer = setTimeout(finish, ms);
|
|
23546
23546
|
stopController.signal.addEventListener("abort", finish, { once: true });
|
|
@@ -23548,8 +23548,8 @@ async function launchHostSupervisor(options = {}) {
|
|
|
23548
23548
|
return !stopping;
|
|
23549
23549
|
}
|
|
23550
23550
|
let finishStop;
|
|
23551
|
-
const stopped = new Promise((
|
|
23552
|
-
finishStop = () =>
|
|
23551
|
+
const stopped = new Promise((resolve14) => {
|
|
23552
|
+
finishStop = () => resolve14();
|
|
23553
23553
|
stopController.signal.addEventListener("abort", finishStop, { once: true });
|
|
23554
23554
|
});
|
|
23555
23555
|
await Promise.race([customDelay(ms), stopped]);
|
|
@@ -23672,19 +23672,19 @@ async function launchHostSupervisor(options = {}) {
|
|
|
23672
23672
|
child = spawnSupervisor(entry, version2, ownershipDirectory, containmentGateNonce);
|
|
23673
23673
|
const launchedSupervisor = child;
|
|
23674
23674
|
let resolveChildExited;
|
|
23675
|
-
const childExited = new Promise((
|
|
23676
|
-
resolveChildExited =
|
|
23675
|
+
const childExited = new Promise((resolve14) => {
|
|
23676
|
+
resolveChildExited = resolve14;
|
|
23677
23677
|
});
|
|
23678
23678
|
const supervisorContainmentAbort = new AbortController();
|
|
23679
23679
|
void childExited.then(() => supervisorContainmentAbort.abort());
|
|
23680
23680
|
const outcomePromise = new Promise(
|
|
23681
|
-
(
|
|
23681
|
+
(resolve14) => {
|
|
23682
23682
|
let observed = false;
|
|
23683
23683
|
const finish = (code, signal) => {
|
|
23684
23684
|
if (observed) return;
|
|
23685
23685
|
observed = true;
|
|
23686
23686
|
resolveChildExited();
|
|
23687
|
-
|
|
23687
|
+
resolve14({ code, signal });
|
|
23688
23688
|
};
|
|
23689
23689
|
child.once("error", () => finish(1, null));
|
|
23690
23690
|
child.once("exit", finish);
|
|
@@ -23705,12 +23705,12 @@ async function launchHostSupervisor(options = {}) {
|
|
|
23705
23705
|
if (!supervisorContainment || !launchedSupervisor.stdin) {
|
|
23706
23706
|
throw new Error("supervisor Job Object gate is unavailable");
|
|
23707
23707
|
}
|
|
23708
|
-
await new Promise((
|
|
23708
|
+
await new Promise((resolve14, reject3) => {
|
|
23709
23709
|
launchedSupervisor.stdin.write(
|
|
23710
23710
|
windowsContainmentGate(containmentGateNonce),
|
|
23711
23711
|
(error52) => {
|
|
23712
23712
|
if (error52) reject3(error52);
|
|
23713
|
-
else
|
|
23713
|
+
else resolve14();
|
|
23714
23714
|
}
|
|
23715
23715
|
);
|
|
23716
23716
|
});
|
|
@@ -23852,18 +23852,18 @@ async function superviseHost(options = {}) {
|
|
|
23852
23852
|
}
|
|
23853
23853
|
}
|
|
23854
23854
|
let announceShutdown;
|
|
23855
|
-
const shutdownAnnounced = new Promise((
|
|
23856
|
-
announceShutdown =
|
|
23855
|
+
const shutdownAnnounced = new Promise((resolve14) => {
|
|
23856
|
+
announceShutdown = resolve14;
|
|
23857
23857
|
});
|
|
23858
23858
|
const attempted = /* @__PURE__ */ new Set();
|
|
23859
23859
|
const waitOrShutdown = async (ms) => {
|
|
23860
23860
|
if (shuttingDown2) return false;
|
|
23861
23861
|
if (!customDelay) {
|
|
23862
|
-
await new Promise((
|
|
23862
|
+
await new Promise((resolve14) => {
|
|
23863
23863
|
const finish = () => {
|
|
23864
23864
|
clearTimeout(timer);
|
|
23865
23865
|
shutdownController.signal.removeEventListener("abort", finish);
|
|
23866
|
-
|
|
23866
|
+
resolve14();
|
|
23867
23867
|
};
|
|
23868
23868
|
const timer = setTimeout(finish, ms);
|
|
23869
23869
|
shutdownController.signal.addEventListener("abort", finish, { once: true });
|
|
@@ -24006,19 +24006,19 @@ async function superviseHost(options = {}) {
|
|
|
24006
24006
|
child = spawnWorker(command, watchdogLaunch, compatibilityOwnership, containmentGateNonce);
|
|
24007
24007
|
const watchedChild = child;
|
|
24008
24008
|
let resolveChildExited;
|
|
24009
|
-
const childExited = new Promise((
|
|
24010
|
-
resolveChildExited =
|
|
24009
|
+
const childExited = new Promise((resolve14) => {
|
|
24010
|
+
resolveChildExited = resolve14;
|
|
24011
24011
|
});
|
|
24012
24012
|
const workerContainmentAbort = new AbortController();
|
|
24013
24013
|
void childExited.then(() => workerContainmentAbort.abort());
|
|
24014
24014
|
const outcomePromise = new Promise(
|
|
24015
|
-
(
|
|
24015
|
+
(resolve14) => {
|
|
24016
24016
|
let observed = false;
|
|
24017
24017
|
const finish = (result) => {
|
|
24018
24018
|
if (observed) return;
|
|
24019
24019
|
observed = true;
|
|
24020
24020
|
resolveChildExited();
|
|
24021
|
-
|
|
24021
|
+
resolve14(result);
|
|
24022
24022
|
};
|
|
24023
24023
|
watchedChild.once("error", () => finish({ code: 1, signal: null }));
|
|
24024
24024
|
watchedChild.once(
|
|
@@ -24040,10 +24040,10 @@ async function superviseHost(options = {}) {
|
|
|
24040
24040
|
if (!workerContainment || !watchedChild.stdin) {
|
|
24041
24041
|
throw new Error("worker Job Object gate is unavailable");
|
|
24042
24042
|
}
|
|
24043
|
-
await new Promise((
|
|
24043
|
+
await new Promise((resolve14, reject3) => {
|
|
24044
24044
|
watchedChild.stdin.write(windowsContainmentGate(containmentGateNonce), (error52) => {
|
|
24045
24045
|
if (error52) reject3(error52);
|
|
24046
|
-
else
|
|
24046
|
+
else resolve14();
|
|
24047
24047
|
});
|
|
24048
24048
|
});
|
|
24049
24049
|
}
|
|
@@ -25231,7 +25231,7 @@ import { spawn as spawn8 } from "node:child_process";
|
|
|
25231
25231
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
25232
25232
|
import { lstat as lstat9, mkdir as mkdir10, realpath as realpath7 } from "node:fs/promises";
|
|
25233
25233
|
import { homedir as homedir4 } from "node:os";
|
|
25234
|
-
import { dirname as dirname6, join as join14 } from "node:path";
|
|
25234
|
+
import { dirname as dirname6, isAbsolute as isAbsolute13, join as join14, resolve as resolve7 } from "node:path";
|
|
25235
25235
|
|
|
25236
25236
|
// src/tool-packs/browser/tool-definitions.ts
|
|
25237
25237
|
function definition(name, description, properties, required2 = []) {
|
|
@@ -28282,8 +28282,8 @@ async function runGit(input, args, env) {
|
|
|
28282
28282
|
let settled = false;
|
|
28283
28283
|
let stopping = false;
|
|
28284
28284
|
let resolveExited;
|
|
28285
|
-
const exited = new Promise((
|
|
28286
|
-
resolveExited =
|
|
28285
|
+
const exited = new Promise((resolve14) => {
|
|
28286
|
+
resolveExited = resolve14;
|
|
28287
28287
|
});
|
|
28288
28288
|
child.once("exit", resolveExited);
|
|
28289
28289
|
const cleanup = () => {
|
|
@@ -30771,8 +30771,8 @@ var linearToolPackFactory = {
|
|
|
30771
30771
|
async create(grant, context) {
|
|
30772
30772
|
let resolveCancelled;
|
|
30773
30773
|
let closed = false;
|
|
30774
|
-
const cancelled = new Promise((
|
|
30775
|
-
resolveCancelled =
|
|
30774
|
+
const cancelled = new Promise((resolve14) => {
|
|
30775
|
+
resolveCancelled = resolve14;
|
|
30776
30776
|
});
|
|
30777
30777
|
const cancel = () => {
|
|
30778
30778
|
if (closed) return;
|
|
@@ -31386,7 +31386,7 @@ function createAskUserServer() {
|
|
|
31386
31386
|
let server;
|
|
31387
31387
|
let listening;
|
|
31388
31388
|
function ensureListening() {
|
|
31389
|
-
listening ??= new Promise((
|
|
31389
|
+
listening ??= new Promise((resolve14, reject3) => {
|
|
31390
31390
|
server = createServer2((req, res) => {
|
|
31391
31391
|
res.on("error", () => {
|
|
31392
31392
|
});
|
|
@@ -31402,7 +31402,7 @@ function createAskUserServer() {
|
|
|
31402
31402
|
server.on("error", reject3);
|
|
31403
31403
|
server.listen(0, "127.0.0.1", () => {
|
|
31404
31404
|
const address = server.address();
|
|
31405
|
-
if (address && typeof address === "object")
|
|
31405
|
+
if (address && typeof address === "object") resolve14(address.port);
|
|
31406
31406
|
else reject3(new Error("ask_user server failed to bind"));
|
|
31407
31407
|
});
|
|
31408
31408
|
server.unref();
|
|
@@ -32715,18 +32715,26 @@ async function repositoryState(directory, git, env, signal) {
|
|
|
32715
32715
|
};
|
|
32716
32716
|
}
|
|
32717
32717
|
async function collectWorkingContext(input) {
|
|
32718
|
-
const
|
|
32718
|
+
const fixedDirectories = [
|
|
32719
32719
|
{ path: input.workingDirectory, kind: "working" }
|
|
32720
32720
|
];
|
|
32721
32721
|
if (input.preparedWorkspace && input.preparedWorkspace.path !== input.workingDirectory) {
|
|
32722
|
-
|
|
32722
|
+
fixedDirectories.push({ path: input.preparedWorkspace.path, kind: "repository" });
|
|
32723
32723
|
}
|
|
32724
|
+
const candidateDirectories = [
|
|
32725
|
+
.../* @__PURE__ */ new Set([...input.observedDirectories ?? [], ...fixedDirectories.map(({ path }) => path)])
|
|
32726
|
+
].slice(0, 20);
|
|
32724
32727
|
const repositories = (await Promise.all(
|
|
32725
|
-
|
|
32728
|
+
candidateDirectories.map((path) => repositoryState(path, input.git, input.env, input.signal))
|
|
32726
32729
|
)).filter((repository) => repository !== null);
|
|
32727
32730
|
const uniqueRepositories = [
|
|
32728
32731
|
...new Map(repositories.map((repository) => [repository.root, repository])).values()
|
|
32729
|
-
];
|
|
32732
|
+
].slice(0, 20);
|
|
32733
|
+
const fixedPaths = new Set(fixedDirectories.map(({ path }) => path));
|
|
32734
|
+
const directories = [
|
|
32735
|
+
...fixedDirectories,
|
|
32736
|
+
...uniqueRepositories.filter(({ root }) => !fixedPaths.has(root)).map(({ root }) => ({ path: root, kind: "repository" }))
|
|
32737
|
+
].slice(0, 20);
|
|
32730
32738
|
return TaskWorkingContextObservation.parse({
|
|
32731
32739
|
workingDirectory: input.workingDirectory,
|
|
32732
32740
|
directories,
|
|
@@ -33770,6 +33778,8 @@ function createCliRunner(adapter, opts = {}) {
|
|
|
33770
33778
|
${attachmentSection}` : prompt;
|
|
33771
33779
|
let activeWorkingContextReport = null;
|
|
33772
33780
|
let previousWorkingContext = "";
|
|
33781
|
+
const observedWorkingDirectories = /* @__PURE__ */ new Set();
|
|
33782
|
+
let observedPathRefreshPending = false;
|
|
33773
33783
|
const workingContextAbort = new AbortController();
|
|
33774
33784
|
const abortWorkingContext = () => workingContextAbort.abort();
|
|
33775
33785
|
task.authoritySignal.addEventListener("abort", abortWorkingContext, { once: true });
|
|
@@ -33781,6 +33791,7 @@ ${attachmentSection}` : prompt;
|
|
|
33781
33791
|
activeWorkingContextReport = collectWorkingContext({
|
|
33782
33792
|
workingDirectory: cwd,
|
|
33783
33793
|
preparedWorkspace,
|
|
33794
|
+
observedDirectories: [...observedWorkingDirectories].reverse(),
|
|
33784
33795
|
git,
|
|
33785
33796
|
env: workingContextEnvironments.git,
|
|
33786
33797
|
signal: workingContextAbort.signal
|
|
@@ -33801,9 +33812,36 @@ ${attachmentSection}` : prompt;
|
|
|
33801
33812
|
if (options.required) throw error52;
|
|
33802
33813
|
}).finally(() => {
|
|
33803
33814
|
activeWorkingContextReport = null;
|
|
33815
|
+
if (observedPathRefreshPending && !task.cancelledNow() && !workingContextAbort.signal.aborted) {
|
|
33816
|
+
observedPathRefreshPending = false;
|
|
33817
|
+
void reportWorkingContext({ forceReport: true });
|
|
33818
|
+
}
|
|
33804
33819
|
});
|
|
33805
33820
|
return activeWorkingContextReport;
|
|
33806
33821
|
};
|
|
33822
|
+
const observeLocalPaths = (paths) => {
|
|
33823
|
+
if (!git.available) return;
|
|
33824
|
+
let changed = false;
|
|
33825
|
+
for (const path of paths) {
|
|
33826
|
+
if (!path || path.length > 4096) continue;
|
|
33827
|
+
const absolutePath = isAbsolute13(path) ? path : resolve7(cwd, path);
|
|
33828
|
+
const directory = dirname6(absolutePath);
|
|
33829
|
+
observedWorkingDirectories.delete(directory);
|
|
33830
|
+
observedWorkingDirectories.add(directory);
|
|
33831
|
+
while (observedWorkingDirectories.size > 19) {
|
|
33832
|
+
const oldest = observedWorkingDirectories.values().next().value;
|
|
33833
|
+
if (oldest === void 0) break;
|
|
33834
|
+
observedWorkingDirectories.delete(oldest);
|
|
33835
|
+
}
|
|
33836
|
+
changed = true;
|
|
33837
|
+
}
|
|
33838
|
+
if (!changed) return;
|
|
33839
|
+
if (activeWorkingContextReport) {
|
|
33840
|
+
observedPathRefreshPending = true;
|
|
33841
|
+
return;
|
|
33842
|
+
}
|
|
33843
|
+
void reportWorkingContext({ forceReport: true });
|
|
33844
|
+
};
|
|
33807
33845
|
await reportWorkingContext({
|
|
33808
33846
|
forcePullRequest: true,
|
|
33809
33847
|
forceReport: true,
|
|
@@ -33888,7 +33926,18 @@ ${attachmentSection}` : prompt;
|
|
|
33888
33926
|
clockPaused: () => pendingAsks > 0,
|
|
33889
33927
|
cancelled: task.cancelled,
|
|
33890
33928
|
cancelledNow: task.cancelledNow,
|
|
33891
|
-
onStream: (kind, summary, detail) =>
|
|
33929
|
+
onStream: (kind, summary, detail) => {
|
|
33930
|
+
if (detail?.localPaths?.length) observeLocalPaths(detail.localPaths);
|
|
33931
|
+
if (!detail) {
|
|
33932
|
+
task.event(kind, summary);
|
|
33933
|
+
return;
|
|
33934
|
+
}
|
|
33935
|
+
task.event(kind, summary, {
|
|
33936
|
+
...detail.tool ? { tool: detail.tool } : {},
|
|
33937
|
+
...detail.parameter ? { parameter: detail.parameter } : {},
|
|
33938
|
+
...detail.ephemeral === void 0 ? {} : { ephemeral: detail.ephemeral }
|
|
33939
|
+
});
|
|
33940
|
+
},
|
|
33892
33941
|
createParser: prepared.createParser,
|
|
33893
33942
|
notFoundMessage: adapter.notFoundMessage,
|
|
33894
33943
|
cliLabel: adapter.type,
|
|
@@ -34197,7 +34246,7 @@ function runCliProcess(options) {
|
|
|
34197
34246
|
usage: { inputTokens: 0, outputTokens: 0 }
|
|
34198
34247
|
});
|
|
34199
34248
|
}
|
|
34200
|
-
return new Promise((
|
|
34249
|
+
return new Promise((resolve14) => {
|
|
34201
34250
|
const platform = options.platform ?? process.platform;
|
|
34202
34251
|
const containmentGateNonce = options.guardian && platform === "win32" ? randomUUID10() : void 0;
|
|
34203
34252
|
const child = options.guardian ? spawn8(
|
|
@@ -34254,7 +34303,7 @@ function runCliProcess(options) {
|
|
|
34254
34303
|
if (settled) return;
|
|
34255
34304
|
settled = true;
|
|
34256
34305
|
clearInterval(timer);
|
|
34257
|
-
|
|
34306
|
+
resolve14(result);
|
|
34258
34307
|
};
|
|
34259
34308
|
const terminate = (result) => {
|
|
34260
34309
|
if (settled || forcedResult) return;
|
|
@@ -34563,7 +34612,7 @@ async function readCodexSessionRuntime(input) {
|
|
|
34563
34612
|
}
|
|
34564
34613
|
var codexCatalogCache = /* @__PURE__ */ new Map();
|
|
34565
34614
|
async function loadCodexModelCatalog(command, prefixArgs, env) {
|
|
34566
|
-
const output = await new Promise((
|
|
34615
|
+
const output = await new Promise((resolve14) => {
|
|
34567
34616
|
const child = spawnCli(command, [...prefixArgs, "debug", "models"], {
|
|
34568
34617
|
stdio: ["ignore", "pipe", "ignore"],
|
|
34569
34618
|
windowsHide: true,
|
|
@@ -34578,7 +34627,7 @@ async function loadCodexModelCatalog(command, prefixArgs, env) {
|
|
|
34578
34627
|
if (settled) return;
|
|
34579
34628
|
settled = true;
|
|
34580
34629
|
clearTimeout(timer);
|
|
34581
|
-
|
|
34630
|
+
resolve14(value);
|
|
34582
34631
|
};
|
|
34583
34632
|
const timer = setTimeout(() => {
|
|
34584
34633
|
child.kill();
|
|
@@ -34681,8 +34730,8 @@ function createRuntimeReporter(input, sessionId) {
|
|
|
34681
34730
|
var EFFORT_READ_ATTEMPTS = 5;
|
|
34682
34731
|
var EFFORT_READ_INTERVAL_MS = 3e3;
|
|
34683
34732
|
function delay2(ms) {
|
|
34684
|
-
return new Promise((
|
|
34685
|
-
const timer = setTimeout(
|
|
34733
|
+
return new Promise((resolve14) => {
|
|
34734
|
+
const timer = setTimeout(resolve14, ms);
|
|
34686
34735
|
timer.unref?.();
|
|
34687
34736
|
});
|
|
34688
34737
|
}
|
|
@@ -34775,10 +34824,12 @@ function createStreamParser(onStream, hooks = {}) {
|
|
|
34775
34824
|
const tool = String(block["name"]).slice(0, 200);
|
|
34776
34825
|
const parameter = String(target).slice(0, 2e3);
|
|
34777
34826
|
const shortParameter = parameter.slice(0, 100);
|
|
34827
|
+
const localPath = typeof input?.["file_path"] === "string" ? input["file_path"] : null;
|
|
34778
34828
|
onStream("action", `${tool}${shortParameter ? `: ${shortParameter}` : ""}`, {
|
|
34779
34829
|
tool,
|
|
34780
34830
|
...parameter ? { parameter } : {},
|
|
34781
|
-
ephemeral: true
|
|
34831
|
+
ephemeral: true,
|
|
34832
|
+
...localPath ? { localPaths: [localPath] } : {}
|
|
34782
34833
|
});
|
|
34783
34834
|
}
|
|
34784
34835
|
}
|
|
@@ -35007,8 +35058,8 @@ ${prompt2}` : prompt2;
|
|
|
35007
35058
|
var RUNTIME_READ_ATTEMPTS = 5;
|
|
35008
35059
|
var RUNTIME_READ_INTERVAL_MS = 2e3;
|
|
35009
35060
|
function delay3(ms) {
|
|
35010
|
-
return new Promise((
|
|
35011
|
-
const timer = setTimeout(
|
|
35061
|
+
return new Promise((resolve14) => {
|
|
35062
|
+
const timer = setTimeout(resolve14, ms);
|
|
35012
35063
|
timer.unref?.();
|
|
35013
35064
|
});
|
|
35014
35065
|
}
|
|
@@ -35083,7 +35134,8 @@ function createCodexStreamParser(onStream, hooks = {}) {
|
|
|
35083
35134
|
onStream("action", `file_change${parameter ? `: ${parameter.slice(0, 100)}` : ""}`, {
|
|
35084
35135
|
tool: "file_change",
|
|
35085
35136
|
...parameter ? { parameter } : {},
|
|
35086
|
-
ephemeral: true
|
|
35137
|
+
ephemeral: true,
|
|
35138
|
+
...changes.length > 0 ? { localPaths: changes } : {}
|
|
35087
35139
|
});
|
|
35088
35140
|
} else if (itemType === "error") {
|
|
35089
35141
|
if (typeof item["message"] === "string") lastError = item["message"];
|
|
@@ -35178,7 +35230,7 @@ function improveCodexErrorMessage(error52) {
|
|
|
35178
35230
|
// src/runners/git-preflight.ts
|
|
35179
35231
|
import { spawn as spawn9 } from "node:child_process";
|
|
35180
35232
|
import { realpath as realpath9 } from "node:fs/promises";
|
|
35181
|
-
import { isAbsolute as
|
|
35233
|
+
import { isAbsolute as isAbsolute14, resolve as resolve8 } from "node:path";
|
|
35182
35234
|
var OUTPUT_LIMIT = 8192;
|
|
35183
35235
|
var DEFAULT_TIMEOUT_MS4 = 1e4;
|
|
35184
35236
|
var VERSION_PATTERN = /^git version [^\r\n]{1,108}$/;
|
|
@@ -35194,10 +35246,10 @@ function unavailable(error52, checkedAt, executablePath = null) {
|
|
|
35194
35246
|
async function preflightGit(options = {}) {
|
|
35195
35247
|
const checkedAt = (options.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
|
|
35196
35248
|
const configured = options.command;
|
|
35197
|
-
if (configured !== void 0 && !
|
|
35249
|
+
if (configured !== void 0 && !isAbsolute14(configured)) {
|
|
35198
35250
|
return unavailable("configured git command must be an absolute file", checkedAt);
|
|
35199
35251
|
}
|
|
35200
|
-
const trustedCwd = await realpath9(
|
|
35252
|
+
const trustedCwd = await realpath9(resolve8(options.trustedCwd ?? process.cwd())).catch(() => null);
|
|
35201
35253
|
if (!trustedCwd)
|
|
35202
35254
|
return unavailable("Host-owned git preflight directory is unavailable", checkedAt);
|
|
35203
35255
|
const executablePath = await resolveTrustedCliCommand(configured ?? "git", {
|
|
@@ -35419,7 +35471,7 @@ function parseAuth(result) {
|
|
|
35419
35471
|
return "unknown";
|
|
35420
35472
|
}
|
|
35421
35473
|
function run2(command, args) {
|
|
35422
|
-
return new Promise((
|
|
35474
|
+
return new Promise((resolve14) => {
|
|
35423
35475
|
const child = spawnCli(command, args, {
|
|
35424
35476
|
stdio: ["ignore", "pipe", "pipe"],
|
|
35425
35477
|
windowsHide: true
|
|
@@ -35435,7 +35487,7 @@ function run2(command, args) {
|
|
|
35435
35487
|
if (settled) return;
|
|
35436
35488
|
settled = true;
|
|
35437
35489
|
clearTimeout(timeout);
|
|
35438
|
-
|
|
35490
|
+
resolve14(result);
|
|
35439
35491
|
};
|
|
35440
35492
|
const timeout = setTimeout(() => {
|
|
35441
35493
|
child.kill();
|
|
@@ -35451,7 +35503,7 @@ import { spawn as spawn10 } from "node:child_process";
|
|
|
35451
35503
|
import { constants as constants2 } from "node:fs";
|
|
35452
35504
|
import { access as access4, chmod as chmod7, mkdir as mkdir12, open as open6, rename as rename5, rm as rm7 } from "node:fs/promises";
|
|
35453
35505
|
import { homedir as homedir7, userInfo } from "node:os";
|
|
35454
|
-
import { basename as basename3, dirname as dirname7, join as join17, relative as relative8, resolve as
|
|
35506
|
+
import { basename as basename3, dirname as dirname7, join as join17, relative as relative8, resolve as resolve9, sep as sep4 } from "node:path";
|
|
35455
35507
|
var SERVICE_NAME = "zixt-host.service";
|
|
35456
35508
|
var SYSTEM_SERVICE_COMMAND_TIMEOUT_MS = 7e4;
|
|
35457
35509
|
var SERVICE_STABILITY_DELAY_MS = 2e3;
|
|
@@ -35479,7 +35531,7 @@ function boundedAppend(current, chunk) {
|
|
|
35479
35531
|
}
|
|
35480
35532
|
async function defaultRunCommand(command, args) {
|
|
35481
35533
|
const commandEnvironment3 = systemServiceCommandEnvironment();
|
|
35482
|
-
return new Promise((
|
|
35534
|
+
return new Promise((resolve14) => {
|
|
35483
35535
|
const child = spawn10(command, [...args], {
|
|
35484
35536
|
stdio: ["ignore", "pipe", "pipe"],
|
|
35485
35537
|
env: commandEnvironment3,
|
|
@@ -35493,7 +35545,7 @@ async function defaultRunCommand(command, args) {
|
|
|
35493
35545
|
if (settled) return;
|
|
35494
35546
|
settled = true;
|
|
35495
35547
|
if (timer) clearTimeout(timer);
|
|
35496
|
-
|
|
35548
|
+
resolve14(result);
|
|
35497
35549
|
};
|
|
35498
35550
|
child.stdout?.on("data", (chunk) => {
|
|
35499
35551
|
stdout = boundedAppend(stdout, chunk);
|
|
@@ -35549,8 +35601,8 @@ async function defaultSyncDirectory(path) {
|
|
|
35549
35601
|
async function ensureDirectory(path, mode, syncDirectory7) {
|
|
35550
35602
|
const firstCreated = await mkdir12(path, { recursive: true, mode });
|
|
35551
35603
|
if (!firstCreated) return;
|
|
35552
|
-
const first =
|
|
35553
|
-
const target =
|
|
35604
|
+
const first = resolve9(firstCreated);
|
|
35605
|
+
const target = resolve9(path);
|
|
35554
35606
|
await syncDirectory7(dirname7(first));
|
|
35555
35607
|
let current = first;
|
|
35556
35608
|
const descendants = relative8(first, target);
|
|
@@ -35624,7 +35676,7 @@ async function installLinuxService(options) {
|
|
|
35624
35676
|
const resolveCommand = options.resolveCommand ?? defaultResolveCommand;
|
|
35625
35677
|
const run3 = options.runCommand ?? defaultRunCommand;
|
|
35626
35678
|
const syncDirectory7 = options.syncDirectory ?? defaultSyncDirectory;
|
|
35627
|
-
const stabilityDelay = options.delay ?? ((ms) => new Promise((
|
|
35679
|
+
const stabilityDelay = options.delay ?? ((ms) => new Promise((resolve14) => setTimeout(resolve14, ms)));
|
|
35628
35680
|
const [systemctl, loginctl] = await Promise.all([
|
|
35629
35681
|
resolveCommand("systemctl"),
|
|
35630
35682
|
resolveCommand("loginctl")
|
|
@@ -35739,7 +35791,7 @@ import { spawn as spawn11 } from "node:child_process";
|
|
|
35739
35791
|
import { constants as constants3 } from "node:fs";
|
|
35740
35792
|
import { access as access5, chmod as chmod8, mkdir as mkdir13, open as open7, rename as rename6, rm as rm8 } from "node:fs/promises";
|
|
35741
35793
|
import { homedir as homedir8, userInfo as userInfo2 } from "node:os";
|
|
35742
|
-
import { basename as basename4, dirname as dirname8, join as join18, relative as relative9, resolve as
|
|
35794
|
+
import { basename as basename4, dirname as dirname8, join as join18, relative as relative9, resolve as resolve10, sep as sep5 } from "node:path";
|
|
35743
35795
|
var LAUNCH_AGENT_LABEL = "ai.zixt.host";
|
|
35744
35796
|
var SERVICE_STABILITY_DELAY_MS2 = 2e3;
|
|
35745
35797
|
var COMMAND_TIMEOUT_MS2 = 7e4;
|
|
@@ -35765,8 +35817,8 @@ async function syncDirectory4(path) {
|
|
|
35765
35817
|
async function ensureDirectory2(path, sync) {
|
|
35766
35818
|
const firstCreated = await mkdir13(path, { recursive: true, mode: 448 });
|
|
35767
35819
|
if (!firstCreated) return;
|
|
35768
|
-
const first =
|
|
35769
|
-
const target =
|
|
35820
|
+
const first = resolve10(firstCreated);
|
|
35821
|
+
const target = resolve10(path);
|
|
35770
35822
|
await sync(dirname8(first));
|
|
35771
35823
|
let current = first;
|
|
35772
35824
|
for (const part of relative9(first, target).split(sep5).filter(Boolean)) {
|
|
@@ -35970,7 +36022,7 @@ import { spawn as spawn12 } from "node:child_process";
|
|
|
35970
36022
|
import { constants as constants4 } from "node:fs";
|
|
35971
36023
|
import { access as access6, mkdir as mkdir14, open as open8, readFile as readFile8, rename as rename7, rm as rm9 } from "node:fs/promises";
|
|
35972
36024
|
import { homedir as homedir9 } from "node:os";
|
|
35973
|
-
import { basename as basename5, dirname as dirname9, isAbsolute as
|
|
36025
|
+
import { basename as basename5, dirname as dirname9, isAbsolute as isAbsolute15, join as join19, relative as relative10, resolve as resolve11, sep as sep6 } from "node:path";
|
|
35974
36026
|
var TASK_NAME = "Zixt Host";
|
|
35975
36027
|
var COMMAND_TIMEOUT_MS3 = 7e4;
|
|
35976
36028
|
var SERVICE_STABILITY_DELAY_MS3 = 2e3;
|
|
@@ -35998,8 +36050,8 @@ async function syncDirectory5(path) {
|
|
|
35998
36050
|
async function ensureDirectory3(path, sync) {
|
|
35999
36051
|
const firstCreated = await mkdir14(path, { recursive: true, mode: 448 });
|
|
36000
36052
|
if (!firstCreated) return;
|
|
36001
|
-
const first =
|
|
36002
|
-
const target =
|
|
36053
|
+
const first = resolve11(firstCreated);
|
|
36054
|
+
const target = resolve11(path);
|
|
36003
36055
|
await sync(dirname9(first));
|
|
36004
36056
|
let current = first;
|
|
36005
36057
|
for (const part of relative10(first, target).split(sep6).filter(Boolean)) {
|
|
@@ -36064,7 +36116,7 @@ async function runChild(command, args, env, input) {
|
|
|
36064
36116
|
}
|
|
36065
36117
|
async function defaultResolveCommand3(name, env) {
|
|
36066
36118
|
const root = env.SYSTEMROOT ?? env.WINDIR;
|
|
36067
|
-
if (!root || !
|
|
36119
|
+
if (!root || !isAbsolute15(root)) return null;
|
|
36068
36120
|
const candidate = name === "powershell" ? join19(root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe") : join19(root, "System32", `${name}.exe`);
|
|
36069
36121
|
return access6(candidate, constants4.X_OK).then(
|
|
36070
36122
|
() => candidate,
|
|
@@ -36196,7 +36248,7 @@ async function installWindowsService(options) {
|
|
|
36196
36248
|
const env = options.env ?? process.env;
|
|
36197
36249
|
const home = options.home ?? homedir9();
|
|
36198
36250
|
const localAppData = options.localAppData ?? env.LOCALAPPDATA;
|
|
36199
|
-
if (!localAppData || !
|
|
36251
|
+
if (!localAppData || !isAbsolute15(localAppData)) {
|
|
36200
36252
|
throw new Error("Windows local application data path is unavailable.");
|
|
36201
36253
|
}
|
|
36202
36254
|
const token2 = oneLine3(options.token, "pairing code");
|
|
@@ -36309,7 +36361,7 @@ async function installSystemService(options) {
|
|
|
36309
36361
|
// src/terminal-outcomes.ts
|
|
36310
36362
|
import { chmod as chmod9, lstat as lstat10, mkdir as mkdir15, open as open9, readdir as readdir5, readFile as readFile9, rename as rename8, rm as rm10 } from "node:fs/promises";
|
|
36311
36363
|
import { homedir as homedir10 } from "node:os";
|
|
36312
|
-
import { dirname as dirname10, join as join20, relative as relative11, resolve as
|
|
36364
|
+
import { dirname as dirname10, join as join20, relative as relative11, resolve as resolve12, sep as sep7 } from "node:path";
|
|
36313
36365
|
var DIRECTORY_MODE5 = 448;
|
|
36314
36366
|
var FILE_MODE4 = 384;
|
|
36315
36367
|
var MAX_OUTCOME_BYTES = 4 * 1024 * 1024;
|
|
@@ -36337,8 +36389,8 @@ async function syncDirectory6(root) {
|
|
|
36337
36389
|
async function requirePrivateRoot(root, sync = syncDirectory6) {
|
|
36338
36390
|
const firstCreated = await mkdir15(root, { recursive: true, mode: DIRECTORY_MODE5 });
|
|
36339
36391
|
if (firstCreated) {
|
|
36340
|
-
const first =
|
|
36341
|
-
const target =
|
|
36392
|
+
const first = resolve12(firstCreated);
|
|
36393
|
+
const target = resolve12(root);
|
|
36342
36394
|
await sync(dirname10(first));
|
|
36343
36395
|
let current = first;
|
|
36344
36396
|
for (const part of relative11(first, target).split(sep7).filter(Boolean)) {
|
|
@@ -36589,13 +36641,13 @@ function createHostLogger(options = {}) {
|
|
|
36589
36641
|
}
|
|
36590
36642
|
|
|
36591
36643
|
// src/demo-state.ts
|
|
36592
|
-
import { isAbsolute as
|
|
36644
|
+
import { isAbsolute as isAbsolute16, join as join21, parse as parse3, resolve as resolve13 } from "node:path";
|
|
36593
36645
|
var DEMO_STATE_ROOT_ENV = "ZIXT_DEMO_STATE_ROOT";
|
|
36594
36646
|
function resolveDemoHostStatePaths(env = process.env) {
|
|
36595
36647
|
const configured = env.ZIXT_RUNNER === "demo" ? env[DEMO_STATE_ROOT_ENV] : void 0;
|
|
36596
36648
|
if (!configured) return null;
|
|
36597
|
-
const root =
|
|
36598
|
-
if (!
|
|
36649
|
+
const root = resolve13(configured);
|
|
36650
|
+
if (!isAbsolute16(configured) || root === parse3(root).root) {
|
|
36599
36651
|
throw new Error(`${DEMO_STATE_ROOT_ENV} must be a dedicated absolute directory`);
|
|
36600
36652
|
}
|
|
36601
36653
|
return {
|