privateer-agent 0.15.4 → 0.15.6
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/README.md +11 -0
- package/bin/boot-bundle.d.mts +2 -0
- package/bin/boot-bundle.mjs +44 -0
- package/bin/fresh-supervisor.d.mts +5 -1
- package/bin/fresh-supervisor.mjs +47 -10
- package/bin/privateer-launch.mjs +27 -3
- package/bin/privateer-subagent.mjs +5 -2
- package/bin/privateer-verify.mjs +12 -0
- package/bin/session-recovery.d.mts +53 -0
- package/bin/session-recovery.mjs +240 -0
- package/bin/session-seal-preload.mjs +17 -0
- package/bin/session-seal.d.mts +25 -0
- package/bin/session-seal.mjs +242 -0
- package/dist-boot/boot.mjs +3 -0
- package/dist-boot/c-27JKSMWL.mjs +1460 -0
- package/dist-boot/c-2BMRFV24.mjs +269 -0
- package/dist-boot/c-2CTF6JA3.mjs +166 -0
- package/dist-boot/c-2G3BBHRJ.mjs +84 -0
- package/dist-boot/c-2IDLKXX6.mjs +250 -0
- package/dist-boot/c-2NJD5VYM.mjs +8 -0
- package/dist-boot/c-2S5EEQPW.mjs +1602 -0
- package/dist-boot/c-2WRDCUVI.mjs +25 -0
- package/dist-boot/c-2YN3M256.mjs +14 -0
- package/dist-boot/c-37GM3GMU.mjs +187 -0
- package/dist-boot/c-3STKRSVO.mjs +2480 -0
- package/dist-boot/c-3TPV6TQQ.mjs +2320 -0
- package/dist-boot/c-3UVHLQDJ.mjs +225 -0
- package/dist-boot/c-42PUUZYC.mjs +697 -0
- package/dist-boot/c-4D5UMWVW.mjs +683 -0
- package/dist-boot/c-4ETZRMTA.mjs +46 -0
- package/dist-boot/c-4QT25BD5.mjs +1482 -0
- package/dist-boot/c-4WVR32AP.mjs +2579 -0
- package/dist-boot/c-5EMM567G.mjs +152 -0
- package/dist-boot/c-5FA4CV63.mjs +145 -0
- package/dist-boot/c-5GV3X3RB.mjs +14 -0
- package/dist-boot/c-5JCEPRIY.mjs +52 -0
- package/dist-boot/c-5NDKIIWT.mjs +16 -0
- package/dist-boot/c-5QL3AR26.mjs +4665 -0
- package/dist-boot/c-5XY6MFKN.mjs +5142 -0
- package/dist-boot/c-65UZIZC7.mjs +2897 -0
- package/dist-boot/c-6FUXKHOK.mjs +1969 -0
- package/dist-boot/c-6JHWQE4V.mjs +18242 -0
- package/dist-boot/c-6LOBR4I6.mjs +5280 -0
- package/dist-boot/c-6QHOZXKQ.mjs +14394 -0
- package/dist-boot/c-6ZO2SADQ.mjs +178 -0
- package/dist-boot/c-6ZORVVZP.mjs +1449 -0
- package/dist-boot/c-76QH4UCP.mjs +2441 -0
- package/dist-boot/c-77GO5L5Y.mjs +20982 -0
- package/dist-boot/c-7M23XFTN.mjs +5052 -0
- package/dist-boot/c-7TC367E2.mjs +32 -0
- package/dist-boot/c-7UOG7POX.mjs +1524 -0
- package/dist-boot/c-7VHP3FLN.mjs +376 -0
- package/dist-boot/c-A73JHZP2.mjs +13207 -0
- package/dist-boot/c-ABXULAFL.mjs +71 -0
- package/dist-boot/c-ANDD2AQO.mjs +74 -0
- package/dist-boot/c-AOY77AZL.mjs +1430 -0
- package/dist-boot/c-AXEPZ22I.mjs +108 -0
- package/dist-boot/c-B2Y7VNHU.mjs +427 -0
- package/dist-boot/c-B7VJUH73.mjs +77 -0
- package/dist-boot/c-BFW6CDVL.mjs +24 -0
- package/dist-boot/c-BHNIF2AR.mjs +188 -0
- package/dist-boot/c-BKF2O6BL.mjs +23 -0
- package/dist-boot/c-BOZXFTZN.mjs +8 -0
- package/dist-boot/c-BRNYJWZL.mjs +28 -0
- package/dist-boot/c-C3N4Z2HO.mjs +93 -0
- package/dist-boot/c-C4IV7ZFG.mjs +717 -0
- package/dist-boot/c-C5NK6UYV.mjs +793 -0
- package/dist-boot/c-C67644MB.mjs +1659 -0
- package/dist-boot/c-C6S2YB53.mjs +620 -0
- package/dist-boot/c-CDBEJSBF.mjs +37 -0
- package/dist-boot/c-CG47HBKU.mjs +435 -0
- package/dist-boot/c-CKCTWCT5.mjs +51 -0
- package/dist-boot/c-CN77DCGF.mjs +60 -0
- package/dist-boot/c-CRBXNKFO.mjs +1795 -0
- package/dist-boot/c-CRIHASQ6.mjs +973 -0
- package/dist-boot/c-CU4NGAUO.mjs +3786 -0
- package/dist-boot/c-CWRFLGQU.mjs +1883 -0
- package/dist-boot/c-CYQB2USO.mjs +32 -0
- package/dist-boot/c-DEE67DJO.mjs +379 -0
- package/dist-boot/c-DIFDBYOP.mjs +1258 -0
- package/dist-boot/c-DOSGVXDZ.mjs +34879 -0
- package/dist-boot/c-DR7XQI32.mjs +381 -0
- package/dist-boot/c-DTGPSB46.mjs +14666 -0
- package/dist-boot/c-DTHDNA4P.mjs +320 -0
- package/dist-boot/c-E4Z3Y5B5.mjs +3864 -0
- package/dist-boot/c-E66Z2TI7.mjs +203 -0
- package/dist-boot/c-EBU6RLRV.mjs +1527 -0
- package/dist-boot/c-EBZZNGSF.mjs +432 -0
- package/dist-boot/c-EC3LJ2KF.mjs +1032 -0
- package/dist-boot/c-EQBKXWNX.mjs +15829 -0
- package/dist-boot/c-EUEPIW4S.mjs +574 -0
- package/dist-boot/c-EX4YVWAT.mjs +378 -0
- package/dist-boot/c-EYZGSAJU.mjs +98 -0
- package/dist-boot/c-F75VRKY4.mjs +172 -0
- package/dist-boot/c-FH4NXKHV.mjs +177 -0
- package/dist-boot/c-FHNUCTEM.mjs +140 -0
- package/dist-boot/c-FJ5T42DS.mjs +5349 -0
- package/dist-boot/c-FPCNRL7G.mjs +1728 -0
- package/dist-boot/c-G4DLN7Q4.mjs +8 -0
- package/dist-boot/c-G56GYQFZ.mjs +2507 -0
- package/dist-boot/c-GLIOERDQ.mjs +1200 -0
- package/dist-boot/c-GMJ5HUBM.mjs +14 -0
- package/dist-boot/c-H3HSGMAQ.mjs +461 -0
- package/dist-boot/c-HIKTO6P7.mjs +275 -0
- package/dist-boot/c-I2MCJ34O.mjs +464 -0
- package/dist-boot/c-I3C6LBW4.mjs +765 -0
- package/dist-boot/c-I54OKQHW.mjs +387 -0
- package/dist-boot/c-IFSP3R4D.mjs +80 -0
- package/dist-boot/c-IZK77VB7.mjs +171 -0
- package/dist-boot/c-J3Y25UGE.mjs +54 -0
- package/dist-boot/c-J5IESS7W.mjs +27750 -0
- package/dist-boot/c-JJWZBY7L.mjs +254 -0
- package/dist-boot/c-JKTFXTGF.mjs +463 -0
- package/dist-boot/c-JN57AXQ4.mjs +77 -0
- package/dist-boot/c-KFIO6LUW.mjs +1096 -0
- package/dist-boot/c-KIEMEFWW.mjs +478 -0
- package/dist-boot/c-KIVXWBYD.mjs +28 -0
- package/dist-boot/c-KP6CRIP4.mjs +580 -0
- package/dist-boot/c-L26VOJX4.mjs +11558 -0
- package/dist-boot/c-L5GHWG5G.mjs +5988 -0
- package/dist-boot/c-M7NSQAKK.mjs +353 -0
- package/dist-boot/c-MCEWOPBW.mjs +56 -0
- package/dist-boot/c-MGPIEG7I.mjs +20 -0
- package/dist-boot/c-NREXJV3M.mjs +393 -0
- package/dist-boot/c-O5PP6CTX.mjs +162 -0
- package/dist-boot/c-OBQDHSXM.mjs +1774 -0
- package/dist-boot/c-OLQHHDD4.mjs +21 -0
- package/dist-boot/c-OXW4JQQH.mjs +319 -0
- package/dist-boot/c-P3D7ZUWN.mjs +1288 -0
- package/dist-boot/c-P4PQZVV5.mjs +948 -0
- package/dist-boot/c-P63T3XL2.mjs +26373 -0
- package/dist-boot/c-P6N5DQGZ.mjs +194 -0
- package/dist-boot/c-P7MLKQFC.mjs +58 -0
- package/dist-boot/c-PB3PZJL5.mjs +1276 -0
- package/dist-boot/c-PTN4S6G2.mjs +1259 -0
- package/dist-boot/c-PYCE5J7U.mjs +1083 -0
- package/dist-boot/c-Q4HYCRLB.mjs +19410 -0
- package/dist-boot/c-QUXMETGG.mjs +68 -0
- package/dist-boot/c-RDMJZCOX.mjs +356 -0
- package/dist-boot/c-ROGJK76M.mjs +17 -0
- package/dist-boot/c-RQJJ26T4.mjs +708 -0
- package/dist-boot/c-RSKCUPJF.mjs +7559 -0
- package/dist-boot/c-RVJU4O6P.mjs +37 -0
- package/dist-boot/c-S2RVHR3M.mjs +165 -0
- package/dist-boot/c-SKMK3PEE.mjs +91120 -0
- package/dist-boot/c-TI7SM4EG.mjs +20 -0
- package/dist-boot/c-TILJ6GXD.mjs +1235 -0
- package/dist-boot/c-TT6BCUJD.mjs +114 -0
- package/dist-boot/c-U4ITOXAN.mjs +2107 -0
- package/dist-boot/c-UGERXVO2.mjs +7120 -0
- package/dist-boot/c-UPBH5AXY.mjs +1363 -0
- package/dist-boot/c-US2PUNZL.mjs +597 -0
- package/dist-boot/c-UU4WZPPE.mjs +20 -0
- package/dist-boot/c-UWVIYPQS.mjs +39 -0
- package/dist-boot/c-V4RHQBPQ.mjs +17683 -0
- package/dist-boot/c-V5MRVK47.mjs +351 -0
- package/dist-boot/c-V6CL266R.mjs +1755 -0
- package/dist-boot/c-VJTMFKYE.mjs +14975 -0
- package/dist-boot/c-VJTRUKIB.mjs +773 -0
- package/dist-boot/c-W4IFSHPW.mjs +43 -0
- package/dist-boot/c-WETGB2CF.mjs +113 -0
- package/dist-boot/c-WO3QSZUU.mjs +1337 -0
- package/dist-boot/c-WQLH73TY.mjs +242 -0
- package/dist-boot/c-XL735JW5.mjs +500 -0
- package/dist-boot/c-Y7HADL5B.mjs +1107 -0
- package/dist-boot/c-YGQHSVSK.mjs +41 -0
- package/dist-boot/c-YMP2AMEB.mjs +10350 -0
- package/dist-boot/c-YRDO2WEF.mjs +12012 -0
- package/dist-boot/c-YUSTRATJ.mjs +8 -0
- package/dist-boot/c-Z2262R22.mjs +2697 -0
- package/dist-boot/c-Z4ALQMJC.mjs +709 -0
- package/dist-boot/c-Z5ZUQVUY.mjs +62 -0
- package/dist-boot/c-ZDZUKXF7.mjs +874 -0
- package/dist-boot/c-ZJYLGIC3.mjs +32 -0
- package/dist-boot/c-ZNA5CDMI.mjs +77 -0
- package/dist-boot/c-ZSO6DI3M.mjs +204 -0
- package/dist-boot/c-ZWUVHKMK.mjs +100 -0
- package/dist-boot/c-ZY4MESEW.mjs +832 -0
- package/dist-boot/c-ZZ5REI4L.mjs +329 -0
- package/dist-boot/cli.mjs +51 -0
- package/dist-boot/ext-anthropic-attribution.mjs +207 -0
- package/dist-boot/ext-pi-background-tasks.mjs +7234 -0
- package/dist-boot/ext-pi-subagents.mjs +37 -0
- package/dist-boot/ext-privateer-account.mjs +4426 -0
- package/dist-boot/ext-privateer-brand.mjs +5274 -0
- package/dist-boot/ext-privateer-codemode.mjs +37 -0
- package/dist-boot/ext-privateer-computer.mjs +626 -0
- package/dist-boot/ext-privateer-connect.mjs +1862 -0
- package/dist-boot/ext-privateer-context.mjs +323 -0
- package/dist-boot/ext-privateer-desktop.mjs +92 -0
- package/dist-boot/ext-privateer-final-audit.mjs +48 -0
- package/dist-boot/ext-privateer-fresh.mjs +81 -0
- package/dist-boot/ext-privateer-gate.mjs +5959 -0
- package/dist-boot/ext-privateer-hints.mjs +236 -0
- package/dist-boot/ext-privateer-media.mjs +2626 -0
- package/dist-boot/ext-privateer-models.mjs +3397 -0
- package/dist-boot/ext-privateer-posture.mjs +3006 -0
- package/dist-boot/ext-privateer-privacy.mjs +4578 -0
- package/dist-boot/ext-privateer-recovery.mjs +287 -0
- package/dist-boot/ext-privateer-speak.mjs +4754 -0
- package/dist-boot/ext-privateer-terminals.mjs +725 -0
- package/dist-boot/ext-privateer-tools.mjs +528 -0
- package/dist-boot/ext-privateer-truncation.mjs +74 -0
- package/dist-boot/ext-privateer-update.mjs +210 -0
- package/dist-boot/ext-privateer-vision.mjs +148 -0
- package/dist-boot/ext-privateer-web.mjs +543 -0
- package/dist-boot/ext-rpiv-ask-user-question.mjs +710 -0
- package/dist-boot/manifest.json +9 -0
- package/extensions/privateer-brand.ts +3 -1
- package/extensions/privateer-context.ts +4 -2
- package/extensions/privateer-final-audit.ts +17 -0
- package/extensions/privateer-gate.ts +55 -9
- package/extensions/privateer-recovery.ts +175 -0
- package/extensions/privateer-web.ts +4 -4
- package/package.json +3 -1
- package/patches/@earendil-works+pi-coding-agent+1.3.0.patch +199 -2
- package/patches/pi-background-tasks+2.6.10.patch +91 -7
- package/src/cli/chat.ts +7 -1
- package/src/config/moatManifest.json +2 -0
- package/src/config/whatsNew.json +4 -4
- package/src/context.ts +33 -5
- package/src/engine/finalAudit.ts +38 -0
- package/src/engine/stallWatchdog.ts +8 -1
- package/src/providers/account.ts +34 -3
- package/src/remote/attentionPush.ts +40 -0
- package/src/remote/liveTaskSession.ts +7 -1
- package/src/remote/relayClient.ts +38 -4
- package/src/remote/remoteBridge.ts +17 -0
- package/src/remote/transcriptSnapshot.ts +104 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import{createRequire as __pvCR}from"node:module";import{fileURLToPath as __pvF}from"node:url";import{dirname as __pvD}from"node:path";const require=__pvCR(import.meta.url);const __pvUrl=(r)=>new URL(r,import.meta.url).href;const __pvFile=(r)=>__pvF(new URL(r,import.meta.url));
|
|
2
|
+
import {
|
|
3
|
+
replaceFileDurable,
|
|
4
|
+
writeFileDurable
|
|
5
|
+
} from "./c-DR7XQI32.mjs";
|
|
6
|
+
import {
|
|
7
|
+
__name
|
|
8
|
+
} from "./c-CN77DCGF.mjs";
|
|
9
|
+
|
|
10
|
+
// node_modules/pi-background-tasks/src/core/attested-pi-contract.ts?ext=pi-background-tasks
|
|
11
|
+
var ATTESTED_TASK_ID_PATTERN = /^b[0-9a-f]{32}$/;
|
|
12
|
+
var ATTESTED_GIT_TIMEOUT_MS = 3e4;
|
|
13
|
+
var ATTESTED_GIT_KILL_GRACE_MS = 250;
|
|
14
|
+
var ATTESTED_GIT_MAX_OUTPUT_BYTES = 4 * 1024 * 1024;
|
|
15
|
+
|
|
16
|
+
// node_modules/pi-background-tasks/src/core/task-durable.ts?ext=pi-background-tasks
|
|
17
|
+
import { mkdir } from "node:fs/promises";
|
|
18
|
+
import { dirname } from "node:path";
|
|
19
|
+
function signalError(signal) {
|
|
20
|
+
const reason = signal.reason;
|
|
21
|
+
return reason instanceof Error ? reason : new Error(
|
|
22
|
+
`Attested Git preflight cancelled${reason === void 0 ? "" : `: ${String(reason)}`}`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
__name(signalError, "signalError");
|
|
26
|
+
function throwIfAborted(signal) {
|
|
27
|
+
if (signal?.aborted === true) throw signalError(signal);
|
|
28
|
+
}
|
|
29
|
+
__name(throwIfAborted, "throwIfAborted");
|
|
30
|
+
async function writeFileFsynced(path, data, signal) {
|
|
31
|
+
throwIfAborted(signal);
|
|
32
|
+
await mkdir(dirname(path), { recursive: true });
|
|
33
|
+
throwIfAborted(signal);
|
|
34
|
+
await writeFileDurable(path, data, signal === void 0 ? {} : { signal });
|
|
35
|
+
}
|
|
36
|
+
__name(writeFileFsynced, "writeFileFsynced");
|
|
37
|
+
async function writeJsonAtomic(path, value, signal) {
|
|
38
|
+
throwIfAborted(signal);
|
|
39
|
+
await replaceFileDurable(
|
|
40
|
+
path,
|
|
41
|
+
`${JSON.stringify(value, null, 2)}
|
|
42
|
+
`,
|
|
43
|
+
signal === void 0 ? {} : { signal }
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
__name(writeJsonAtomic, "writeJsonAtomic");
|
|
47
|
+
async function closeAndFsyncOutputStream(stream) {
|
|
48
|
+
if (!stream) return;
|
|
49
|
+
await new Promise((resolvePromise, reject) => {
|
|
50
|
+
let settled = false;
|
|
51
|
+
const finish = /* @__PURE__ */ __name(() => {
|
|
52
|
+
if (settled) return;
|
|
53
|
+
settled = true;
|
|
54
|
+
stream.off("error", fail);
|
|
55
|
+
stream.off("close", finish);
|
|
56
|
+
stream.off("finish", finish);
|
|
57
|
+
resolvePromise();
|
|
58
|
+
}, "finish");
|
|
59
|
+
const fail = /* @__PURE__ */ __name((error) => {
|
|
60
|
+
if (settled) return;
|
|
61
|
+
settled = true;
|
|
62
|
+
stream.off("close", finish);
|
|
63
|
+
reject(error);
|
|
64
|
+
}, "fail");
|
|
65
|
+
stream.once("close", finish);
|
|
66
|
+
stream.once("finish", finish);
|
|
67
|
+
stream.once("error", fail);
|
|
68
|
+
stream.end();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
__name(closeAndFsyncOutputStream, "closeAndFsyncOutputStream");
|
|
72
|
+
|
|
73
|
+
// node_modules/pi-background-tasks/src/core/windows-taskkill.ts?ext=pi-background-tasks
|
|
74
|
+
import { spawn as nodeSpawn } from "node:child_process";
|
|
75
|
+
import { win32 } from "node:path";
|
|
76
|
+
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
77
|
+
var DEFAULT_MAX_CAPTURE_BYTES = 8 * 1024;
|
|
78
|
+
var BoundedCapture = class {
|
|
79
|
+
constructor(maxBytes) {
|
|
80
|
+
this.maxBytes = maxBytes;
|
|
81
|
+
}
|
|
82
|
+
maxBytes;
|
|
83
|
+
static {
|
|
84
|
+
__name(this, "BoundedCapture");
|
|
85
|
+
}
|
|
86
|
+
chunks = [];
|
|
87
|
+
capturedBytes = 0;
|
|
88
|
+
truncated = false;
|
|
89
|
+
append(data) {
|
|
90
|
+
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data, "utf8");
|
|
91
|
+
if (buffer.length === 0) return;
|
|
92
|
+
const remaining = this.maxBytes - this.capturedBytes;
|
|
93
|
+
if (remaining > 0) {
|
|
94
|
+
const kept = buffer.length <= remaining ? buffer : buffer.subarray(0, remaining);
|
|
95
|
+
this.chunks.push(kept);
|
|
96
|
+
this.capturedBytes += kept.length;
|
|
97
|
+
}
|
|
98
|
+
if (buffer.length > Math.max(0, remaining)) this.truncated = true;
|
|
99
|
+
}
|
|
100
|
+
text() {
|
|
101
|
+
return Buffer.concat(this.chunks, this.capturedBytes).toString("utf8");
|
|
102
|
+
}
|
|
103
|
+
isTruncated() {
|
|
104
|
+
return this.truncated;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
function lookupEnv(env, name) {
|
|
108
|
+
const direct = env[name];
|
|
109
|
+
if (direct !== void 0) return direct;
|
|
110
|
+
const lowerName = name.toLowerCase();
|
|
111
|
+
for (const key of Object.keys(env)) {
|
|
112
|
+
if (key.toLowerCase() === lowerName) return env[key];
|
|
113
|
+
}
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
__name(lookupEnv, "lookupEnv");
|
|
117
|
+
function validateWindowsRoot(raw, label) {
|
|
118
|
+
const value = raw.trim();
|
|
119
|
+
if (value.length === 0) throw new Error(`${label} is empty; cannot resolve taskkill.exe`);
|
|
120
|
+
if (value.includes("\0")) throw new Error(`${label} contains a NUL byte; cannot resolve taskkill.exe`);
|
|
121
|
+
if (!win32.isAbsolute(value)) {
|
|
122
|
+
throw new Error(`${label} must be an absolute Windows path; cannot resolve taskkill.exe`);
|
|
123
|
+
}
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
__name(validateWindowsRoot, "validateWindowsRoot");
|
|
127
|
+
function resolveTaskkillPath(env = process.env) {
|
|
128
|
+
const systemRoot = lookupEnv(env, "SystemRoot");
|
|
129
|
+
if (systemRoot !== void 0) {
|
|
130
|
+
return win32.join(validateWindowsRoot(systemRoot, "SystemRoot"), "System32", "taskkill.exe");
|
|
131
|
+
}
|
|
132
|
+
const windir = lookupEnv(env, "WINDIR");
|
|
133
|
+
if (windir !== void 0) {
|
|
134
|
+
return win32.join(validateWindowsRoot(windir, "WINDIR"), "System32", "taskkill.exe");
|
|
135
|
+
}
|
|
136
|
+
throw new Error("Cannot resolve taskkill.exe: SystemRoot is missing and WINDIR fallback is missing");
|
|
137
|
+
}
|
|
138
|
+
__name(resolveTaskkillPath, "resolveTaskkillPath");
|
|
139
|
+
function validatePid(pid) {
|
|
140
|
+
if (!Number.isSafeInteger(pid) || pid <= 0) {
|
|
141
|
+
throw new Error(`Invalid Windows taskkill pid ${String(pid)}; expected a positive safe integer`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
__name(validatePid, "validatePid");
|
|
145
|
+
function validatePhase(phase) {
|
|
146
|
+
if (phase !== "terminate" && phase !== "force") {
|
|
147
|
+
throw new Error(`Invalid Windows taskkill phase ${String(phase)}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
__name(validatePhase, "validatePhase");
|
|
151
|
+
function positiveFiniteInteger(value, fallback, label) {
|
|
152
|
+
const candidate = value ?? fallback;
|
|
153
|
+
if (!Number.isFinite(candidate) || candidate <= 0) {
|
|
154
|
+
throw new Error(`${label} must be a positive finite number`);
|
|
155
|
+
}
|
|
156
|
+
return Math.max(1, Math.floor(candidate));
|
|
157
|
+
}
|
|
158
|
+
__name(positiveFiniteInteger, "positiveFiniteInteger");
|
|
159
|
+
function outcome(exitCode, signal, stdout, stderr) {
|
|
160
|
+
return {
|
|
161
|
+
exitCode,
|
|
162
|
+
signal,
|
|
163
|
+
stdout: stdout.text(),
|
|
164
|
+
stderr: stderr.text(),
|
|
165
|
+
stdoutTruncated: stdout.isTruncated(),
|
|
166
|
+
stderrTruncated: stderr.isTruncated()
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
__name(outcome, "outcome");
|
|
170
|
+
function defaultSpawn(command, args, options) {
|
|
171
|
+
return nodeSpawn(command, args, options);
|
|
172
|
+
}
|
|
173
|
+
__name(defaultSpawn, "defaultSpawn");
|
|
174
|
+
function runWindowsTaskkill(pid, phase, options = {}) {
|
|
175
|
+
validatePid(pid);
|
|
176
|
+
validatePhase(phase);
|
|
177
|
+
const env = options.env ?? process.env;
|
|
178
|
+
const taskkill = resolveTaskkillPath(env);
|
|
179
|
+
const timeoutMs = positiveFiniteInteger(options.timeoutMs, DEFAULT_TIMEOUT_MS, "timeoutMs");
|
|
180
|
+
const maxCaptureBytes = positiveFiniteInteger(
|
|
181
|
+
options.maxCaptureBytes,
|
|
182
|
+
DEFAULT_MAX_CAPTURE_BYTES,
|
|
183
|
+
"maxCaptureBytes"
|
|
184
|
+
);
|
|
185
|
+
const spawn = options.spawn ?? defaultSpawn;
|
|
186
|
+
const abortSignal = options.signal;
|
|
187
|
+
const args = ["/PID", String(pid), "/T"];
|
|
188
|
+
if (phase === "force") args.push("/F");
|
|
189
|
+
if (abortSignal?.aborted) {
|
|
190
|
+
const stdout = new BoundedCapture(maxCaptureBytes);
|
|
191
|
+
const stderr = new BoundedCapture(maxCaptureBytes);
|
|
192
|
+
stderr.append("Windows taskkill was aborted before launch");
|
|
193
|
+
return Promise.resolve(outcome(null, null, stdout, stderr));
|
|
194
|
+
}
|
|
195
|
+
return new Promise((resolve) => {
|
|
196
|
+
const stdout = new BoundedCapture(maxCaptureBytes);
|
|
197
|
+
const stderr = new BoundedCapture(maxCaptureBytes);
|
|
198
|
+
let settled = false;
|
|
199
|
+
let timeout;
|
|
200
|
+
let child;
|
|
201
|
+
let abortListener;
|
|
202
|
+
const settle = /* @__PURE__ */ __name((result) => {
|
|
203
|
+
if (settled) return;
|
|
204
|
+
settled = true;
|
|
205
|
+
if (timeout !== void 0) clearTimeout(timeout);
|
|
206
|
+
if (abortSignal !== void 0 && abortListener !== void 0) {
|
|
207
|
+
abortSignal.removeEventListener("abort", abortListener);
|
|
208
|
+
}
|
|
209
|
+
resolve(result);
|
|
210
|
+
}, "settle");
|
|
211
|
+
const stopHelper = /* @__PURE__ */ __name((reason) => {
|
|
212
|
+
stderr.append(reason);
|
|
213
|
+
if (child !== void 0) {
|
|
214
|
+
try {
|
|
215
|
+
child.kill("SIGKILL");
|
|
216
|
+
} catch (error) {
|
|
217
|
+
stderr.append(`; helper kill failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
settle(outcome(null, null, stdout, stderr));
|
|
221
|
+
}, "stopHelper");
|
|
222
|
+
const spawnOptions = {
|
|
223
|
+
env,
|
|
224
|
+
shell: false,
|
|
225
|
+
windowsVerbatimArguments: false,
|
|
226
|
+
windowsHide: true,
|
|
227
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
228
|
+
};
|
|
229
|
+
try {
|
|
230
|
+
child = spawn(taskkill, args, spawnOptions);
|
|
231
|
+
} catch (error) {
|
|
232
|
+
stderr.append(`Windows taskkill spawn failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
233
|
+
settle(outcome(null, null, stdout, stderr));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
child.stdout?.on("data", (data) => {
|
|
237
|
+
stdout.append(data);
|
|
238
|
+
});
|
|
239
|
+
child.stderr?.on("data", (data) => {
|
|
240
|
+
stderr.append(data);
|
|
241
|
+
});
|
|
242
|
+
child.on("error", (error) => {
|
|
243
|
+
stderr.append(`Windows taskkill spawn error: ${error.message}`);
|
|
244
|
+
settle(outcome(null, null, stdout, stderr));
|
|
245
|
+
});
|
|
246
|
+
child.on("close", (code, signal) => {
|
|
247
|
+
settle(outcome(code, signal, stdout, stderr));
|
|
248
|
+
});
|
|
249
|
+
abortListener = /* @__PURE__ */ __name(() => {
|
|
250
|
+
stopHelper("Windows taskkill was aborted");
|
|
251
|
+
}, "abortListener");
|
|
252
|
+
abortSignal?.addEventListener("abort", abortListener, { once: true });
|
|
253
|
+
timeout = setTimeout(() => {
|
|
254
|
+
stopHelper(`Windows taskkill timed out after ${String(timeoutMs)}ms`);
|
|
255
|
+
}, timeoutMs);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
__name(runWindowsTaskkill, "runWindowsTaskkill");
|
|
259
|
+
|
|
260
|
+
export {
|
|
261
|
+
ATTESTED_TASK_ID_PATTERN,
|
|
262
|
+
ATTESTED_GIT_TIMEOUT_MS,
|
|
263
|
+
ATTESTED_GIT_KILL_GRACE_MS,
|
|
264
|
+
ATTESTED_GIT_MAX_OUTPUT_BYTES,
|
|
265
|
+
writeFileFsynced,
|
|
266
|
+
writeJsonAtomic,
|
|
267
|
+
closeAndFsyncOutputStream,
|
|
268
|
+
runWindowsTaskkill
|
|
269
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import{createRequire as __pvCR}from"node:module";import{fileURLToPath as __pvF}from"node:url";import{dirname as __pvD}from"node:path";const require=__pvCR(import.meta.url);const __pvUrl=(r)=>new URL(r,import.meta.url).href;const __pvFile=(r)=>__pvF(new URL(r,import.meta.url));
|
|
2
|
+
import {
|
|
3
|
+
AttestationError,
|
|
4
|
+
ConfigurationError,
|
|
5
|
+
isBun
|
|
6
|
+
} from "./c-C67644MB.mjs";
|
|
7
|
+
import {
|
|
8
|
+
__name
|
|
9
|
+
} from "./c-CN77DCGF.mjs";
|
|
10
|
+
|
|
11
|
+
// node_modules/tinfoil/dist/pinned-tls-fetch.js
|
|
12
|
+
import { X509Certificate, createHash } from "crypto";
|
|
13
|
+
function createCheckServerIdentity(expectedFingerprintHex) {
|
|
14
|
+
return (host, cert) => {
|
|
15
|
+
const raw = cert?.raw;
|
|
16
|
+
if (!raw) {
|
|
17
|
+
return new AttestationError("TLS pinning failed: Certificate raw bytes are unavailable");
|
|
18
|
+
}
|
|
19
|
+
const x509 = new X509Certificate(raw);
|
|
20
|
+
const publicKeyDer = x509.publicKey.export({ type: "spki", format: "der" });
|
|
21
|
+
const fp = createHash("sha256").update(publicKeyDer).digest("hex");
|
|
22
|
+
if (fp !== expectedFingerprintHex) {
|
|
23
|
+
return new AttestationError("TLS pinning failed: Server certificate public key does not match the attested key");
|
|
24
|
+
}
|
|
25
|
+
return void 0;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
__name(createCheckServerIdentity, "createCheckServerIdentity");
|
|
29
|
+
async function createBunPinnedTlsFetch(baseURL, expectedFingerprintHex) {
|
|
30
|
+
const tls = await import("tls");
|
|
31
|
+
const fingerprintCheck = createCheckServerIdentity(expectedFingerprintHex);
|
|
32
|
+
const parsedBase = new URL(baseURL);
|
|
33
|
+
if (parsedBase.protocol !== "https:") {
|
|
34
|
+
throw new ConfigurationError(`Insecure connection rejected: HTTP is not allowed. Use HTTPS for ${baseURL}`);
|
|
35
|
+
}
|
|
36
|
+
return (async (input, init) => {
|
|
37
|
+
const makeURL = /* @__PURE__ */ __name((value) => {
|
|
38
|
+
if (typeof value === "string")
|
|
39
|
+
return new URL(value, baseURL);
|
|
40
|
+
if (value instanceof URL)
|
|
41
|
+
return value;
|
|
42
|
+
return new URL(value.url, baseURL);
|
|
43
|
+
}, "makeURL");
|
|
44
|
+
const url = makeURL(input);
|
|
45
|
+
if (url.protocol !== "https:") {
|
|
46
|
+
throw new ConfigurationError(`Insecure connection rejected: HTTP is not allowed. Use HTTPS for ${url.toString()}`);
|
|
47
|
+
}
|
|
48
|
+
const fetchInit = {
|
|
49
|
+
...init,
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
51
|
+
// @ts-ignore - Bun-specific option
|
|
52
|
+
tls: {
|
|
53
|
+
checkServerIdentity: /* @__PURE__ */ __name((host, cert) => {
|
|
54
|
+
const result = fingerprintCheck(host, cert);
|
|
55
|
+
if (result)
|
|
56
|
+
return result;
|
|
57
|
+
return tls.checkServerIdentity(host, cert);
|
|
58
|
+
}, "checkServerIdentity")
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return fetch(url.toString(), fetchInit);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
__name(createBunPinnedTlsFetch, "createBunPinnedTlsFetch");
|
|
65
|
+
async function createNodePinnedTlsFetch(baseURL, expectedFingerprintHex) {
|
|
66
|
+
const https = await import("https");
|
|
67
|
+
const tls = await import("tls");
|
|
68
|
+
const { Readable } = await import("stream");
|
|
69
|
+
const checkServerIdentity = createCheckServerIdentity(expectedFingerprintHex);
|
|
70
|
+
return (async (input, init) => {
|
|
71
|
+
const makeURL = /* @__PURE__ */ __name((value) => {
|
|
72
|
+
if (typeof value === "string")
|
|
73
|
+
return new URL(value, baseURL);
|
|
74
|
+
if (value instanceof URL)
|
|
75
|
+
return value;
|
|
76
|
+
return new URL(value.url, baseURL);
|
|
77
|
+
}, "makeURL");
|
|
78
|
+
const url = makeURL(input);
|
|
79
|
+
if (url.protocol !== "https:") {
|
|
80
|
+
throw new ConfigurationError(`Insecure connection rejected: HTTP is not allowed. Use HTTPS for ${url.toString()}`);
|
|
81
|
+
}
|
|
82
|
+
const method = (init?.method || input.method || "GET").toUpperCase();
|
|
83
|
+
const headers = new Headers(init?.headers || input?.headers || {});
|
|
84
|
+
const headerObj = {};
|
|
85
|
+
headers.forEach((v, k) => {
|
|
86
|
+
headerObj[k] = v;
|
|
87
|
+
});
|
|
88
|
+
let body = init?.body;
|
|
89
|
+
if (!body && input instanceof Request) {
|
|
90
|
+
const buf = await input.arrayBuffer();
|
|
91
|
+
if (buf && buf.byteLength)
|
|
92
|
+
body = Buffer.from(buf);
|
|
93
|
+
}
|
|
94
|
+
if (body && typeof body.getReader === "function") {
|
|
95
|
+
body = Readable.fromWeb(body);
|
|
96
|
+
}
|
|
97
|
+
if (body instanceof ArrayBuffer) {
|
|
98
|
+
body = Buffer.from(body);
|
|
99
|
+
}
|
|
100
|
+
if (ArrayBuffer.isView(body)) {
|
|
101
|
+
body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
102
|
+
}
|
|
103
|
+
const requestOptions = {
|
|
104
|
+
protocol: url.protocol,
|
|
105
|
+
hostname: url.hostname,
|
|
106
|
+
port: url.port ? Number(url.port) : 443,
|
|
107
|
+
path: `${url.pathname}${url.search}`,
|
|
108
|
+
method,
|
|
109
|
+
headers: headerObj,
|
|
110
|
+
checkServerIdentity: /* @__PURE__ */ __name((host, cert) => {
|
|
111
|
+
const result = checkServerIdentity(host, cert);
|
|
112
|
+
if (result)
|
|
113
|
+
return result;
|
|
114
|
+
return tls.checkServerIdentity(host, cert);
|
|
115
|
+
}, "checkServerIdentity")
|
|
116
|
+
};
|
|
117
|
+
const { signal } = init || {};
|
|
118
|
+
const res = await new Promise((resolve, reject) => {
|
|
119
|
+
const req = https.request(requestOptions, resolve);
|
|
120
|
+
req.on("error", reject);
|
|
121
|
+
if (signal) {
|
|
122
|
+
if (signal.aborted) {
|
|
123
|
+
req.destroy(new Error("Request aborted"));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
signal.addEventListener("abort", () => req.destroy(new Error("Request aborted")));
|
|
127
|
+
}
|
|
128
|
+
if (body === void 0 || body === null) {
|
|
129
|
+
req.end();
|
|
130
|
+
} else if (typeof body === "string" || Buffer.isBuffer(body) || ArrayBuffer.isView(body)) {
|
|
131
|
+
req.end(body);
|
|
132
|
+
} else if (typeof body.pipe === "function") {
|
|
133
|
+
body.pipe(req);
|
|
134
|
+
} else {
|
|
135
|
+
req.end(String(body));
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const responseHeaders = new Headers();
|
|
139
|
+
for (const [k, v] of Object.entries(res.headers)) {
|
|
140
|
+
if (Array.isArray(v)) {
|
|
141
|
+
v.forEach((item) => responseHeaders.append(k, item));
|
|
142
|
+
} else if (v != null) {
|
|
143
|
+
responseHeaders.set(k, String(v));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const webStream = Readable.toWeb(res);
|
|
147
|
+
return new Response(webStream, {
|
|
148
|
+
status: res.statusCode || 0,
|
|
149
|
+
statusText: res.statusMessage || "",
|
|
150
|
+
headers: responseHeaders
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
__name(createNodePinnedTlsFetch, "createNodePinnedTlsFetch");
|
|
155
|
+
async function createPinnedTlsFetch(baseURL, expectedFingerprintHex) {
|
|
156
|
+
if (isBun()) {
|
|
157
|
+
return createBunPinnedTlsFetch(baseURL, expectedFingerprintHex);
|
|
158
|
+
}
|
|
159
|
+
return createNodePinnedTlsFetch(baseURL, expectedFingerprintHex);
|
|
160
|
+
}
|
|
161
|
+
__name(createPinnedTlsFetch, "createPinnedTlsFetch");
|
|
162
|
+
|
|
163
|
+
export {
|
|
164
|
+
createCheckServerIdentity,
|
|
165
|
+
createPinnedTlsFetch
|
|
166
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import{createRequire as __pvCR}from"node:module";import{fileURLToPath as __pvF}from"node:url";import{dirname as __pvD}from"node:path";const require=__pvCR(import.meta.url);const __pvUrl=(r)=>new URL(r,import.meta.url).href;const __pvFile=(r)=>__pvF(new URL(r,import.meta.url));
|
|
2
|
+
import {
|
|
3
|
+
getProviderEnvValue
|
|
4
|
+
} from "./c-CDBEJSBF.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__name
|
|
7
|
+
} from "./c-CN77DCGF.mjs";
|
|
8
|
+
|
|
9
|
+
// node_modules/@earendil-works/pi-ai/dist/api/azure-openai-config.js
|
|
10
|
+
var DEFAULT_AZURE_API_VERSION = "v1";
|
|
11
|
+
function parseDeploymentNameMap(value) {
|
|
12
|
+
const map = /* @__PURE__ */ new Map();
|
|
13
|
+
if (!value)
|
|
14
|
+
return map;
|
|
15
|
+
for (const entry of value.split(",")) {
|
|
16
|
+
const trimmed = entry.trim();
|
|
17
|
+
if (!trimmed)
|
|
18
|
+
continue;
|
|
19
|
+
const [modelId, deploymentName] = trimmed.split("=", 2);
|
|
20
|
+
if (!modelId || !deploymentName)
|
|
21
|
+
continue;
|
|
22
|
+
map.set(modelId.trim(), deploymentName.trim());
|
|
23
|
+
}
|
|
24
|
+
return map;
|
|
25
|
+
}
|
|
26
|
+
__name(parseDeploymentNameMap, "parseDeploymentNameMap");
|
|
27
|
+
function resolveDeploymentName(model, options) {
|
|
28
|
+
if (options?.azureDeploymentName) {
|
|
29
|
+
return options.azureDeploymentName;
|
|
30
|
+
}
|
|
31
|
+
const mappedDeployment = parseDeploymentNameMap(getProviderEnvValue("AZURE_OPENAI_DEPLOYMENT_NAME_MAP", options?.env)).get(model.id);
|
|
32
|
+
return mappedDeployment || model.id;
|
|
33
|
+
}
|
|
34
|
+
__name(resolveDeploymentName, "resolveDeploymentName");
|
|
35
|
+
function normalizeAzureBaseUrl(baseUrl) {
|
|
36
|
+
const trimmed = baseUrl.trim().replace(/\/+$/, "");
|
|
37
|
+
let url;
|
|
38
|
+
try {
|
|
39
|
+
url = new URL(trimmed);
|
|
40
|
+
} catch {
|
|
41
|
+
throw new Error(`Invalid Azure OpenAI base URL: ${baseUrl}`);
|
|
42
|
+
}
|
|
43
|
+
const isAzureHost = url.hostname.endsWith(".openai.azure.com") || url.hostname.endsWith(".cognitiveservices.azure.com") || url.hostname.endsWith(".ai.azure.com");
|
|
44
|
+
const normalizedPath = url.pathname.replace(/\/+$/, "");
|
|
45
|
+
if (isAzureHost && (normalizedPath === "" || normalizedPath === "/" || normalizedPath === "/openai" || normalizedPath === "/openai/v1/responses")) {
|
|
46
|
+
url.pathname = "/openai/v1";
|
|
47
|
+
url.search = "";
|
|
48
|
+
}
|
|
49
|
+
return url.toString().replace(/\/+$/, "");
|
|
50
|
+
}
|
|
51
|
+
__name(normalizeAzureBaseUrl, "normalizeAzureBaseUrl");
|
|
52
|
+
function buildDefaultBaseUrl(resourceName) {
|
|
53
|
+
return `https://${resourceName}.openai.azure.com/openai/v1`;
|
|
54
|
+
}
|
|
55
|
+
__name(buildDefaultBaseUrl, "buildDefaultBaseUrl");
|
|
56
|
+
function resolveAzureBaseUrl(model, options) {
|
|
57
|
+
const baseUrl = options?.azureBaseUrl?.trim() || getProviderEnvValue("AZURE_OPENAI_BASE_URL", options?.env)?.trim() || void 0;
|
|
58
|
+
const resourceName = options?.azureResourceName || getProviderEnvValue("AZURE_OPENAI_RESOURCE_NAME", options?.env);
|
|
59
|
+
let resolvedBaseUrl = baseUrl;
|
|
60
|
+
if (!resolvedBaseUrl && resourceName) {
|
|
61
|
+
resolvedBaseUrl = buildDefaultBaseUrl(resourceName);
|
|
62
|
+
}
|
|
63
|
+
if (!resolvedBaseUrl && model.baseUrl) {
|
|
64
|
+
resolvedBaseUrl = model.baseUrl;
|
|
65
|
+
}
|
|
66
|
+
if (!resolvedBaseUrl) {
|
|
67
|
+
throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");
|
|
68
|
+
}
|
|
69
|
+
return normalizeAzureBaseUrl(resolvedBaseUrl);
|
|
70
|
+
}
|
|
71
|
+
__name(resolveAzureBaseUrl, "resolveAzureBaseUrl");
|
|
72
|
+
function resolveAzureConfig(model, options) {
|
|
73
|
+
return {
|
|
74
|
+
baseUrl: resolveAzureBaseUrl(model, options),
|
|
75
|
+
apiVersion: options?.azureApiVersion || getProviderEnvValue("AZURE_OPENAI_API_VERSION", options?.env) || DEFAULT_AZURE_API_VERSION
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
__name(resolveAzureConfig, "resolveAzureConfig");
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
resolveDeploymentName,
|
|
82
|
+
resolveAzureBaseUrl,
|
|
83
|
+
resolveAzureConfig
|
|
84
|
+
};
|