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,32 @@
|
|
|
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
|
+
__name
|
|
4
|
+
} from "./c-CN77DCGF.mjs";
|
|
5
|
+
|
|
6
|
+
// node_modules/@earendil-works/pi-ai/dist/utils/headers.js
|
|
7
|
+
function headersToRecord(headers) {
|
|
8
|
+
const result = {};
|
|
9
|
+
for (const [key, value] of headers.entries()) {
|
|
10
|
+
result[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
__name(headersToRecord, "headersToRecord");
|
|
15
|
+
function providerHeadersToRecord(...headerSources) {
|
|
16
|
+
const merged = /* @__PURE__ */ new Map();
|
|
17
|
+
for (const source of headerSources) {
|
|
18
|
+
for (const [name, value] of Object.entries(source ?? {})) {
|
|
19
|
+
const normalizedName = name.toLowerCase();
|
|
20
|
+
merged.delete(normalizedName);
|
|
21
|
+
if (value !== null)
|
|
22
|
+
merged.set(normalizedName, [name, value]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return merged.size > 0 ? Object.fromEntries(merged.values()) : void 0;
|
|
26
|
+
}
|
|
27
|
+
__name(providerHeadersToRecord, "providerHeadersToRecord");
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
headersToRecord,
|
|
31
|
+
providerHeadersToRecord
|
|
32
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
createCheckServerIdentity
|
|
4
|
+
} from "./c-2CTF6JA3.mjs";
|
|
5
|
+
import {
|
|
6
|
+
ConfigurationError,
|
|
7
|
+
isBun
|
|
8
|
+
} from "./c-C67644MB.mjs";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./c-CN77DCGF.mjs";
|
|
12
|
+
|
|
13
|
+
// node_modules/tinfoil/dist/pinned-ws.js
|
|
14
|
+
var FORBIDDEN_WS_OPTION_KEYS = [
|
|
15
|
+
"createConnection",
|
|
16
|
+
"agent",
|
|
17
|
+
"followRedirects",
|
|
18
|
+
"session",
|
|
19
|
+
"socket",
|
|
20
|
+
"servername",
|
|
21
|
+
"pskCallback"
|
|
22
|
+
];
|
|
23
|
+
function stripUnsafeWebSocketOptions(wsOptions) {
|
|
24
|
+
if (!wsOptions)
|
|
25
|
+
return wsOptions;
|
|
26
|
+
const sanitized = { ...wsOptions };
|
|
27
|
+
for (const key of FORBIDDEN_WS_OPTION_KEYS) {
|
|
28
|
+
delete sanitized[key];
|
|
29
|
+
}
|
|
30
|
+
return sanitized;
|
|
31
|
+
}
|
|
32
|
+
__name(stripUnsafeWebSocketOptions, "stripUnsafeWebSocketOptions");
|
|
33
|
+
async function pinnedWsClientOptions(expectedFingerprintHex) {
|
|
34
|
+
if (isBun()) {
|
|
35
|
+
throw new ConfigurationError("WebSocket TLS pinning is not supported on Bun: Bun replaces the 'ws' package with a native implementation that does not honor checkServerIdentity.");
|
|
36
|
+
}
|
|
37
|
+
const tls = await import("tls");
|
|
38
|
+
const fingerprintCheck = createCheckServerIdentity(expectedFingerprintHex);
|
|
39
|
+
const checkServerIdentity = /* @__PURE__ */ __name((host, cert) => {
|
|
40
|
+
const result = fingerprintCheck(host, cert);
|
|
41
|
+
if (result)
|
|
42
|
+
return result;
|
|
43
|
+
return tls.checkServerIdentity(host, cert);
|
|
44
|
+
}, "checkServerIdentity");
|
|
45
|
+
const pinnedOptions = {
|
|
46
|
+
rejectUnauthorized: true,
|
|
47
|
+
createConnection: void 0,
|
|
48
|
+
agent: void 0,
|
|
49
|
+
followRedirects: false,
|
|
50
|
+
session: void 0,
|
|
51
|
+
socket: void 0,
|
|
52
|
+
servername: void 0,
|
|
53
|
+
pskCallback: void 0,
|
|
54
|
+
checkServerIdentity
|
|
55
|
+
};
|
|
56
|
+
return pinnedOptions;
|
|
57
|
+
}
|
|
58
|
+
__name(pinnedWsClientOptions, "pinnedWsClientOptions");
|
|
59
|
+
async function createPinnedWebSocket(url, expectedFingerprintHex, options) {
|
|
60
|
+
const parsed = new URL(url);
|
|
61
|
+
if (parsed.protocol !== "wss:") {
|
|
62
|
+
throw new ConfigurationError(`Insecure connection rejected: only wss:// is allowed. Got ${url}`);
|
|
63
|
+
}
|
|
64
|
+
const pinnedOptions = await pinnedWsClientOptions(expectedFingerprintHex);
|
|
65
|
+
const { WebSocket } = await import("./c-7TC367E2.mjs");
|
|
66
|
+
return new WebSocket(parsed, options?.protocols, {
|
|
67
|
+
...stripUnsafeWebSocketOptions(options?.wsOptions),
|
|
68
|
+
...pinnedOptions
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
__name(createPinnedWebSocket, "createPinnedWebSocket");
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
stripUnsafeWebSocketOptions,
|
|
75
|
+
pinnedWsClientOptions,
|
|
76
|
+
createPinnedWebSocket
|
|
77
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
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
|
+
readFusionCommittedResult,
|
|
4
|
+
readFusionFailureResult
|
|
5
|
+
} from "./c-P4PQZVV5.mjs";
|
|
6
|
+
import "./c-Z4ALQMJC.mjs";
|
|
7
|
+
import "./c-EBZZNGSF.mjs";
|
|
8
|
+
import "./c-37GM3GMU.mjs";
|
|
9
|
+
import {
|
|
10
|
+
adjudicateDelegateTerminal
|
|
11
|
+
} from "./c-KFIO6LUW.mjs";
|
|
12
|
+
import "./c-C5NK6UYV.mjs";
|
|
13
|
+
import "./c-IFSP3R4D.mjs";
|
|
14
|
+
import "./c-I2MCJ34O.mjs";
|
|
15
|
+
import "./c-US2PUNZL.mjs";
|
|
16
|
+
import "./c-KIVXWBYD.mjs";
|
|
17
|
+
import {
|
|
18
|
+
HOST_MAX_INLINE_RESULT_BYTES,
|
|
19
|
+
HostApiError,
|
|
20
|
+
boundedHostErrorMessage
|
|
21
|
+
} from "./c-CG47HBKU.mjs";
|
|
22
|
+
import "./c-BFW6CDVL.mjs";
|
|
23
|
+
import "./c-DR7XQI32.mjs";
|
|
24
|
+
import "./c-I3C6LBW4.mjs";
|
|
25
|
+
import "./c-B2Y7VNHU.mjs";
|
|
26
|
+
import "./c-SKMK3PEE.mjs";
|
|
27
|
+
import "./c-I54OKQHW.mjs";
|
|
28
|
+
import "./c-UPBH5AXY.mjs";
|
|
29
|
+
import "./c-7UOG7POX.mjs";
|
|
30
|
+
import "./c-E4Z3Y5B5.mjs";
|
|
31
|
+
import "./c-6ZO2SADQ.mjs";
|
|
32
|
+
import "./c-JKTFXTGF.mjs";
|
|
33
|
+
import "./c-CRBXNKFO.mjs";
|
|
34
|
+
import "./c-KP6CRIP4.mjs";
|
|
35
|
+
import "./c-RSKCUPJF.mjs";
|
|
36
|
+
import "./c-PTN4S6G2.mjs";
|
|
37
|
+
import "./c-P6N5DQGZ.mjs";
|
|
38
|
+
import "./c-6LOBR4I6.mjs";
|
|
39
|
+
import "./c-3STKRSVO.mjs";
|
|
40
|
+
import "./c-YRDO2WEF.mjs";
|
|
41
|
+
import "./c-BHNIF2AR.mjs";
|
|
42
|
+
import "./c-ABXULAFL.mjs";
|
|
43
|
+
import "./c-2G3BBHRJ.mjs";
|
|
44
|
+
import "./c-O5PP6CTX.mjs";
|
|
45
|
+
import "./c-CDBEJSBF.mjs";
|
|
46
|
+
import "./c-DEE67DJO.mjs";
|
|
47
|
+
import "./c-WO3QSZUU.mjs";
|
|
48
|
+
import "./c-S2RVHR3M.mjs";
|
|
49
|
+
import "./c-EQBKXWNX.mjs";
|
|
50
|
+
import "./c-RQJJ26T4.mjs";
|
|
51
|
+
import "./c-L5GHWG5G.mjs";
|
|
52
|
+
import {
|
|
53
|
+
__name
|
|
54
|
+
} from "./c-CN77DCGF.mjs";
|
|
55
|
+
|
|
56
|
+
// node_modules/pi-background-tasks/src/core/host-results.ts?ext=pi-background-tasks
|
|
57
|
+
import { createHash } from "node:crypto";
|
|
58
|
+
import { join } from "node:path";
|
|
59
|
+
var DELEGATE_INTEGRITY_FAILURE_CODES = /* @__PURE__ */ new Set([
|
|
60
|
+
"child_result_invalid",
|
|
61
|
+
"child_result_encoding_invalid",
|
|
62
|
+
"route_attestation_missing",
|
|
63
|
+
"route_mismatch",
|
|
64
|
+
"seed_hash_mismatch",
|
|
65
|
+
"answer_hash_mismatch",
|
|
66
|
+
"artifact_read_failed",
|
|
67
|
+
"artifact_error"
|
|
68
|
+
]);
|
|
69
|
+
function sha256Hex(bytes) {
|
|
70
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
71
|
+
}
|
|
72
|
+
__name(sha256Hex, "sha256Hex");
|
|
73
|
+
function plainSha256(value) {
|
|
74
|
+
return value.startsWith("sha256:") ? value.slice("sha256:".length) : value;
|
|
75
|
+
}
|
|
76
|
+
__name(plainSha256, "plainSha256");
|
|
77
|
+
function committedView(task, kind, answer, answerBytes, answerSha256, artifactPath) {
|
|
78
|
+
const encoded = Buffer.from(answer, "utf8");
|
|
79
|
+
if (encoded.length !== answerBytes || sha256Hex(encoded) !== answerSha256) {
|
|
80
|
+
throw new HostApiError(
|
|
81
|
+
"RESULT_INVALID",
|
|
82
|
+
`${kind} result for ${task.id} does not match its verified length and digest`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
const view = {
|
|
86
|
+
taskId: task.id,
|
|
87
|
+
kind,
|
|
88
|
+
state: "committed",
|
|
89
|
+
delivery: answerBytes <= HOST_MAX_INLINE_RESULT_BYTES ? "inline" : "artifact",
|
|
90
|
+
answerBytes,
|
|
91
|
+
answerSha256,
|
|
92
|
+
artifactPath
|
|
93
|
+
};
|
|
94
|
+
if (view.delivery === "inline") view.text = answer;
|
|
95
|
+
return view;
|
|
96
|
+
}
|
|
97
|
+
__name(committedView, "committedView");
|
|
98
|
+
async function readDelegateResult(task) {
|
|
99
|
+
const facts = task.delegate;
|
|
100
|
+
if (facts === void 0) {
|
|
101
|
+
throw new HostApiError("NO_RESULT", `task ${task.id} has no delegate result`);
|
|
102
|
+
}
|
|
103
|
+
const status = task.status;
|
|
104
|
+
if (status === "running") {
|
|
105
|
+
return { taskId: task.id, kind: "delegate", state: "running", delivery: "none" };
|
|
106
|
+
}
|
|
107
|
+
const evaluation = await adjudicateDelegateTerminal({
|
|
108
|
+
artifactDirAbs: facts.artifactDirAbs,
|
|
109
|
+
taskId: facts.taskId,
|
|
110
|
+
launchNonce: facts.launchNonce,
|
|
111
|
+
seedSha256: facts.seedSha256,
|
|
112
|
+
route: { provider: facts.route.provider, model: facts.route.model },
|
|
113
|
+
taskStatus: status,
|
|
114
|
+
taskError: task.error,
|
|
115
|
+
taskOutputPath: task.outputPath,
|
|
116
|
+
taskOutputAbsPath: task.outputAbsPath
|
|
117
|
+
});
|
|
118
|
+
const verified = evaluation.result;
|
|
119
|
+
if (verified !== void 0) {
|
|
120
|
+
return committedView(
|
|
121
|
+
task,
|
|
122
|
+
"delegate",
|
|
123
|
+
verified.answer,
|
|
124
|
+
verified.package.answer.byte_length,
|
|
125
|
+
plainSha256(verified.package.answer.sha256),
|
|
126
|
+
join(facts.artifactDir, "result.json")
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const code = evaluation.error?.code;
|
|
130
|
+
if (code !== void 0 && DELEGATE_INTEGRITY_FAILURE_CODES.has(code)) {
|
|
131
|
+
throw new HostApiError(
|
|
132
|
+
"RESULT_INVALID",
|
|
133
|
+
`delegate result for ${task.id} failed integrity verification (${code}): ${evaluation.error?.message ?? "no detail"}`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
const view = {
|
|
137
|
+
taskId: task.id,
|
|
138
|
+
kind: "delegate",
|
|
139
|
+
state: evaluation.outcome.status === "cancelled" ? "cancelled" : "failed",
|
|
140
|
+
delivery: "none"
|
|
141
|
+
};
|
|
142
|
+
if (code !== void 0) view.errorCode = code;
|
|
143
|
+
if (evaluation.error !== void 0) {
|
|
144
|
+
view.message = boundedHostErrorMessage(evaluation.error.message);
|
|
145
|
+
}
|
|
146
|
+
return view;
|
|
147
|
+
}
|
|
148
|
+
__name(readDelegateResult, "readDelegateResult");
|
|
149
|
+
async function readFusionResult(task) {
|
|
150
|
+
const fusion = task.fusion;
|
|
151
|
+
if (fusion === void 0) {
|
|
152
|
+
throw new HostApiError("NO_RESULT", `task ${task.id} has no Fusion result`);
|
|
153
|
+
}
|
|
154
|
+
if (task.status === "running") {
|
|
155
|
+
return { taskId: task.id, kind: "fusion", state: "running", delivery: "none" };
|
|
156
|
+
}
|
|
157
|
+
const options = {
|
|
158
|
+
artifactDirAbs: fusion.artifactDirAbs,
|
|
159
|
+
artifactDir: fusion.artifactDir,
|
|
160
|
+
runId: fusion.runId,
|
|
161
|
+
workflow: fusion.workflow
|
|
162
|
+
};
|
|
163
|
+
if (task.status !== "completed" || fusion.outcome?.status !== "committed") {
|
|
164
|
+
const failure = await readFusionFailureResult(options);
|
|
165
|
+
return {
|
|
166
|
+
taskId: task.id,
|
|
167
|
+
kind: "fusion",
|
|
168
|
+
state: fusion.outcome?.status === "cancelled" || task.status === "killed" ? "cancelled" : "failed",
|
|
169
|
+
delivery: "none",
|
|
170
|
+
fusionFailure: failure
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
let verified;
|
|
174
|
+
try {
|
|
175
|
+
verified = await readFusionCommittedResult(options);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
throw new HostApiError(
|
|
178
|
+
"RESULT_INVALID",
|
|
179
|
+
`Fusion result for ${task.id} failed integrity verification: ${boundedHostErrorMessage(error)}`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
const bytes = Buffer.from(verified.mergedText, "utf8");
|
|
183
|
+
return committedView(
|
|
184
|
+
task,
|
|
185
|
+
"fusion",
|
|
186
|
+
verified.mergedText,
|
|
187
|
+
bytes.length,
|
|
188
|
+
sha256Hex(bytes),
|
|
189
|
+
join(fusion.artifactDir, "merged.md")
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
__name(readFusionResult, "readFusionResult");
|
|
193
|
+
async function readHostTaskResult(task) {
|
|
194
|
+
if (task.fusion !== void 0) return readFusionResult(task);
|
|
195
|
+
if (task.delegate !== void 0) return readDelegateResult(task);
|
|
196
|
+
throw new HostApiError(
|
|
197
|
+
"NO_RESULT",
|
|
198
|
+
`task ${task.id} has no delegate or Fusion result; read ordinary task output with logs`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
__name(readHostTaskResult, "readHostTaskResult");
|
|
202
|
+
export {
|
|
203
|
+
readHostTaskResult
|
|
204
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
__name
|
|
4
|
+
} from "./c-CN77DCGF.mjs";
|
|
5
|
+
|
|
6
|
+
// node_modules/@earendil-works/pi-ai/dist/utils/error-body.js
|
|
7
|
+
var MAX_PROVIDER_ERROR_BODY_CHARS = 4e3;
|
|
8
|
+
function normalizeProviderError(error) {
|
|
9
|
+
if (!(error instanceof Error)) {
|
|
10
|
+
return { message: safeJsonStringify(error), messageCarriesBody: false };
|
|
11
|
+
}
|
|
12
|
+
const sdkError = error;
|
|
13
|
+
const status = extractStatus(sdkError);
|
|
14
|
+
const body = extractBody(sdkError);
|
|
15
|
+
const messageCarriesBody = body === void 0 || error.message.includes(body);
|
|
16
|
+
return {
|
|
17
|
+
status,
|
|
18
|
+
body,
|
|
19
|
+
message: error.message,
|
|
20
|
+
messageCarriesBody
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
__name(normalizeProviderError, "normalizeProviderError");
|
|
24
|
+
function extractStatus(error) {
|
|
25
|
+
if (typeof error.statusCode === "number")
|
|
26
|
+
return error.statusCode;
|
|
27
|
+
if (typeof error.status === "number")
|
|
28
|
+
return error.status;
|
|
29
|
+
if (typeof error.$metadata?.httpStatusCode === "number")
|
|
30
|
+
return error.$metadata.httpStatusCode;
|
|
31
|
+
if (typeof error.$response?.statusCode === "number")
|
|
32
|
+
return error.$response.statusCode;
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
__name(extractStatus, "extractStatus");
|
|
36
|
+
function extractBody(error) {
|
|
37
|
+
const bodyText = pickBodyText(error);
|
|
38
|
+
if (bodyText === void 0)
|
|
39
|
+
return void 0;
|
|
40
|
+
const trimmed = bodyText.trim();
|
|
41
|
+
if (trimmed.length === 0)
|
|
42
|
+
return void 0;
|
|
43
|
+
return truncateErrorText(trimmed, MAX_PROVIDER_ERROR_BODY_CHARS);
|
|
44
|
+
}
|
|
45
|
+
__name(extractBody, "extractBody");
|
|
46
|
+
function pickBodyText(error) {
|
|
47
|
+
if (typeof error.body === "string")
|
|
48
|
+
return error.body;
|
|
49
|
+
if (isPlainNonEmptyObject(error.error))
|
|
50
|
+
return safeJsonStringify(error.error);
|
|
51
|
+
const responseBody = error.$response?.body;
|
|
52
|
+
if (typeof responseBody === "string")
|
|
53
|
+
return responseBody;
|
|
54
|
+
if (isReadableStreamLike(responseBody))
|
|
55
|
+
return void 0;
|
|
56
|
+
if (isPlainNonEmptyObject(responseBody))
|
|
57
|
+
return safeJsonStringify(responseBody);
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
__name(pickBodyText, "pickBodyText");
|
|
61
|
+
function isReadableStreamLike(value) {
|
|
62
|
+
return typeof value === "object" && value !== null && "pipe" in value && typeof value.pipe === "function";
|
|
63
|
+
}
|
|
64
|
+
__name(isReadableStreamLike, "isReadableStreamLike");
|
|
65
|
+
function isPlainNonEmptyObject(value) {
|
|
66
|
+
if (typeof value !== "object" || value === null)
|
|
67
|
+
return false;
|
|
68
|
+
const proto = Object.getPrototypeOf(value);
|
|
69
|
+
if (proto !== Object.prototype && proto !== null)
|
|
70
|
+
return false;
|
|
71
|
+
return Object.keys(value).length > 0;
|
|
72
|
+
}
|
|
73
|
+
__name(isPlainNonEmptyObject, "isPlainNonEmptyObject");
|
|
74
|
+
function formatProviderError(norm, prefix) {
|
|
75
|
+
if (norm.messageCarriesBody || norm.status === void 0 || norm.body === void 0) {
|
|
76
|
+
return prefix !== void 0 && norm.status !== void 0 ? `${prefix} (${norm.status}): ${norm.message}` : norm.message;
|
|
77
|
+
}
|
|
78
|
+
return prefix !== void 0 ? `${prefix} (${norm.status}): ${norm.body}` : `${norm.status}: ${norm.body}`;
|
|
79
|
+
}
|
|
80
|
+
__name(formatProviderError, "formatProviderError");
|
|
81
|
+
function truncateErrorText(text, maxChars) {
|
|
82
|
+
if (text.length <= maxChars)
|
|
83
|
+
return text;
|
|
84
|
+
return `${text.slice(0, maxChars)}... [truncated ${text.length - maxChars} chars]`;
|
|
85
|
+
}
|
|
86
|
+
__name(truncateErrorText, "truncateErrorText");
|
|
87
|
+
function safeJsonStringify(value) {
|
|
88
|
+
try {
|
|
89
|
+
const serialized = JSON.stringify(value);
|
|
90
|
+
return serialized === void 0 ? String(value) : serialized;
|
|
91
|
+
} catch {
|
|
92
|
+
return String(value);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
__name(safeJsonStringify, "safeJsonStringify");
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
normalizeProviderError,
|
|
99
|
+
formatProviderError
|
|
100
|
+
};
|