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,210 @@
|
|
|
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 "./c-B2Y7VNHU.mjs";
|
|
3
|
+
import {
|
|
4
|
+
DefaultPackageManager,
|
|
5
|
+
SettingsManager
|
|
6
|
+
} from "./c-SKMK3PEE.mjs";
|
|
7
|
+
import "./c-I54OKQHW.mjs";
|
|
8
|
+
import "./c-UPBH5AXY.mjs";
|
|
9
|
+
import "./c-7UOG7POX.mjs";
|
|
10
|
+
import "./c-E4Z3Y5B5.mjs";
|
|
11
|
+
import "./c-6ZO2SADQ.mjs";
|
|
12
|
+
import "./c-JKTFXTGF.mjs";
|
|
13
|
+
import "./c-CRBXNKFO.mjs";
|
|
14
|
+
import "./c-KP6CRIP4.mjs";
|
|
15
|
+
import "./c-RSKCUPJF.mjs";
|
|
16
|
+
import {
|
|
17
|
+
getAgentDir
|
|
18
|
+
} from "./c-PTN4S6G2.mjs";
|
|
19
|
+
import "./c-P6N5DQGZ.mjs";
|
|
20
|
+
import "./c-6LOBR4I6.mjs";
|
|
21
|
+
import "./c-3STKRSVO.mjs";
|
|
22
|
+
import "./c-YRDO2WEF.mjs";
|
|
23
|
+
import "./c-BHNIF2AR.mjs";
|
|
24
|
+
import "./c-ABXULAFL.mjs";
|
|
25
|
+
import "./c-2G3BBHRJ.mjs";
|
|
26
|
+
import "./c-O5PP6CTX.mjs";
|
|
27
|
+
import "./c-CDBEJSBF.mjs";
|
|
28
|
+
import "./c-DEE67DJO.mjs";
|
|
29
|
+
import "./c-WO3QSZUU.mjs";
|
|
30
|
+
import "./c-S2RVHR3M.mjs";
|
|
31
|
+
import "./c-EQBKXWNX.mjs";
|
|
32
|
+
import "./c-RQJJ26T4.mjs";
|
|
33
|
+
import "./c-L5GHWG5G.mjs";
|
|
34
|
+
import {
|
|
35
|
+
__name
|
|
36
|
+
} from "./c-CN77DCGF.mjs";
|
|
37
|
+
|
|
38
|
+
// src/config/version.ts?ext=privateer-update
|
|
39
|
+
import { createRequire } from "node:module";
|
|
40
|
+
var __pvMetaUrl = __pvUrl("../src/config/version.ts");
|
|
41
|
+
var cached = null;
|
|
42
|
+
function agentVersion() {
|
|
43
|
+
if (cached === null) {
|
|
44
|
+
try {
|
|
45
|
+
cached = String(createRequire(__pvMetaUrl)("../../package.json").version ?? "");
|
|
46
|
+
} catch {
|
|
47
|
+
cached = "";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return cached;
|
|
51
|
+
}
|
|
52
|
+
__name(agentVersion, "agentVersion");
|
|
53
|
+
|
|
54
|
+
// src/updates.ts?ext=privateer-update
|
|
55
|
+
import { readFileSync } from "node:fs";
|
|
56
|
+
import { join as join2 } from "node:path";
|
|
57
|
+
|
|
58
|
+
// src/config/paths.ts?ext=privateer-update
|
|
59
|
+
import { homedir } from "node:os";
|
|
60
|
+
import { join } from "node:path";
|
|
61
|
+
function globalDir() {
|
|
62
|
+
return process.env.PRIVATEER_HOME ?? join(homedir(), ".privateer");
|
|
63
|
+
}
|
|
64
|
+
__name(globalDir, "globalDir");
|
|
65
|
+
|
|
66
|
+
// src/updates.ts?ext=privateer-update
|
|
67
|
+
function isNewer(a, b) {
|
|
68
|
+
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
69
|
+
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
70
|
+
for (let i = 0; i < 3; i++) {
|
|
71
|
+
if ((pa[i] ?? 0) > (pb[i] ?? 0)) return true;
|
|
72
|
+
if ((pa[i] ?? 0) < (pb[i] ?? 0)) return false;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
__name(isNewer, "isNewer");
|
|
77
|
+
function pendingCliUpdate(current) {
|
|
78
|
+
try {
|
|
79
|
+
const { latest } = JSON.parse(readFileSync(join2(globalDir(), "update-check.json"), "utf8"));
|
|
80
|
+
if (typeof latest === "string" && isNewer(latest, current)) return latest;
|
|
81
|
+
} catch {
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
__name(pendingCliUpdate, "pendingCliUpdate");
|
|
86
|
+
var STATE = /* @__PURE__ */ Symbol.for("privateer.updates.packs");
|
|
87
|
+
var state = globalThis[STATE] ??= {
|
|
88
|
+
pending: [],
|
|
89
|
+
listeners: /* @__PURE__ */ new Set()
|
|
90
|
+
};
|
|
91
|
+
function pendingPackUpdates() {
|
|
92
|
+
return state.pending;
|
|
93
|
+
}
|
|
94
|
+
__name(pendingPackUpdates, "pendingPackUpdates");
|
|
95
|
+
function setPendingPackUpdates(next) {
|
|
96
|
+
state.pending = [...next];
|
|
97
|
+
for (const fn of state.listeners) {
|
|
98
|
+
try {
|
|
99
|
+
fn();
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
__name(setPendingPackUpdates, "setPendingPackUpdates");
|
|
105
|
+
|
|
106
|
+
// extensions/privateer-update.ts?ext=privateer-update
|
|
107
|
+
var RECHECK_AFTER_MS = 6e4;
|
|
108
|
+
var lastCheckedAt = 0;
|
|
109
|
+
function packageManagerFor(ctx) {
|
|
110
|
+
const cwd = ctx?.cwd ?? process.cwd();
|
|
111
|
+
const agentDir = getAgentDir();
|
|
112
|
+
const settingsManager = SettingsManager.create(cwd, agentDir, {
|
|
113
|
+
projectTrusted: ctx?.isProjectTrusted?.() ?? false
|
|
114
|
+
});
|
|
115
|
+
return new DefaultPackageManager({ cwd, agentDir, settingsManager });
|
|
116
|
+
}
|
|
117
|
+
__name(packageManagerFor, "packageManagerFor");
|
|
118
|
+
async function runCheck(ctx, opts = {}) {
|
|
119
|
+
if (!opts.force && Date.now() - lastCheckedAt < RECHECK_AFTER_MS) return pendingPackUpdates();
|
|
120
|
+
if (process.env.PI_OFFLINE) return pendingPackUpdates();
|
|
121
|
+
lastCheckedAt = Date.now();
|
|
122
|
+
const updates = await packageManagerFor(ctx).checkForAvailableUpdates();
|
|
123
|
+
const packs = updates.map((u) => ({
|
|
124
|
+
source: u.source,
|
|
125
|
+
displayName: u.displayName,
|
|
126
|
+
type: u.type,
|
|
127
|
+
scope: u.scope
|
|
128
|
+
}));
|
|
129
|
+
setPendingPackUpdates(packs);
|
|
130
|
+
return packs;
|
|
131
|
+
}
|
|
132
|
+
__name(runCheck, "runCheck");
|
|
133
|
+
function nameList(packs) {
|
|
134
|
+
const names = packs.map((p) => p.displayName);
|
|
135
|
+
if (names.length <= 2) return names.join(" and ");
|
|
136
|
+
return `${names.slice(0, 2).join(", ")} and ${names.length - 2} more`;
|
|
137
|
+
}
|
|
138
|
+
__name(nameList, "nameList");
|
|
139
|
+
function cliNote() {
|
|
140
|
+
const latest = pendingCliUpdate(agentVersion());
|
|
141
|
+
return latest ? `Privateer v${latest} is out too \u2014 that one replaces the running program, so run \`privateer update\` from a shell.` : null;
|
|
142
|
+
}
|
|
143
|
+
__name(cliNote, "cliNote");
|
|
144
|
+
function privateerUpdate(pi) {
|
|
145
|
+
pi.on("session_start", (event, ctx) => {
|
|
146
|
+
if (!ctx?.hasUI) return;
|
|
147
|
+
if (event?.reason !== "startup" && event?.reason !== "reload") return;
|
|
148
|
+
void runCheck(ctx).catch(() => {
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
pi.registerCommand?.("update", {
|
|
152
|
+
description: "Fetch tool pack updates in place: /update [<pack> | check]",
|
|
153
|
+
handler: /* @__PURE__ */ __name(async (args, ctx) => {
|
|
154
|
+
const arg = String(args ?? "").trim();
|
|
155
|
+
const notify = /* @__PURE__ */ __name((msg, kind = "info") => ctx?.ui?.notify?.(msg, kind), "notify");
|
|
156
|
+
if (arg === "check") {
|
|
157
|
+
try {
|
|
158
|
+
const packs = await runCheck(ctx, { force: true });
|
|
159
|
+
const cli = cliNote();
|
|
160
|
+
notify(
|
|
161
|
+
packs.length ? `${packs.length} tool pack update${packs.length === 1 ? "" : "s"} ready: ${nameList(packs)} \u2014 /update to fetch${cli ? `. ${cli}` : ""}` : `Tool packs are current.${cli ? ` ${cli}` : ""}`
|
|
162
|
+
);
|
|
163
|
+
} catch (err) {
|
|
164
|
+
notify(`Update check failed: ${err instanceof Error ? err.message : String(err)}`, "error");
|
|
165
|
+
}
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
let targets = pendingPackUpdates();
|
|
169
|
+
if (!arg) {
|
|
170
|
+
try {
|
|
171
|
+
targets = await runCheck(ctx, { force: pendingPackUpdates().length === 0 });
|
|
172
|
+
} catch {
|
|
173
|
+
}
|
|
174
|
+
if (targets.length === 0) {
|
|
175
|
+
const cli = cliNote();
|
|
176
|
+
notify(`Tool packs are current.${cli ? ` ${cli}` : ""}`);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const label = arg || nameList(targets);
|
|
181
|
+
ctx?.ui?.setStatus?.("update", `\u2691 updating ${arg || `${targets.length} pack${targets.length === 1 ? "" : "s"}`}`);
|
|
182
|
+
try {
|
|
183
|
+
const pm = packageManagerFor(ctx);
|
|
184
|
+
pm.setProgressCallback((e) => {
|
|
185
|
+
if (e?.type === "error") return;
|
|
186
|
+
ctx?.ui?.setStatus?.("update", `\u2691 ${e?.action ?? "update"} ${e?.source ?? ""}`.trimEnd());
|
|
187
|
+
});
|
|
188
|
+
await pm.update(arg || void 0);
|
|
189
|
+
pm.setProgressCallback(void 0);
|
|
190
|
+
} catch (err) {
|
|
191
|
+
ctx?.ui?.setStatus?.("update", void 0);
|
|
192
|
+
notify(`Update failed: ${err instanceof Error ? err.message : String(err)}`, "error");
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
ctx?.ui?.setStatus?.("update", void 0);
|
|
196
|
+
setPendingPackUpdates([]);
|
|
197
|
+
lastCheckedAt = 0;
|
|
198
|
+
if (ctx?.isIdle?.() === false) {
|
|
199
|
+
notify(`Updated ${label}. Run /reload when this turn finishes to load it.`);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
notify(`Updated ${label} \u2014 reloading.`);
|
|
203
|
+
await ctx.reload();
|
|
204
|
+
}, "handler")
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
__name(privateerUpdate, "privateerUpdate");
|
|
208
|
+
export {
|
|
209
|
+
privateerUpdate as default
|
|
210
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
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 "./c-4WVR32AP.mjs";
|
|
3
|
+
import {
|
|
4
|
+
__name
|
|
5
|
+
} from "./c-CN77DCGF.mjs";
|
|
6
|
+
|
|
7
|
+
// src/providers/visionDelegate.ts?ext=privateer-vision
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
|
+
|
|
10
|
+
// src/providers/defaultModel.ts?ext=privateer-vision
|
|
11
|
+
var TINFOIL_MODEL_ID = "tinfoil/gemma4-31b";
|
|
12
|
+
var ACCOUNT_DEFAULT_MODEL_ID = TINFOIL_MODEL_ID;
|
|
13
|
+
var ACCOUNT_DEFAULT_SPEC = `privateer/${ACCOUNT_DEFAULT_MODEL_ID}`;
|
|
14
|
+
|
|
15
|
+
// src/providers/visionDelegate.ts?ext=privateer-vision
|
|
16
|
+
var specOf = /* @__PURE__ */ __name((m) => `${m.provider}/${m.id}`, "specOf");
|
|
17
|
+
var seesImages = /* @__PURE__ */ __name((m) => Array.isArray(m.input) && m.input.includes("image"), "seesImages");
|
|
18
|
+
var PREFERRED = {
|
|
19
|
+
privateer: [ACCOUNT_DEFAULT_MODEL_ID],
|
|
20
|
+
tinfoil: [TINFOIL_MODEL_ID.replace(/^tinfoil\//, "")],
|
|
21
|
+
openrouter: ["google/gemini-2.5-flash", "openai/gpt-4o-mini", "anthropic/claude-haiku-4.5"]
|
|
22
|
+
};
|
|
23
|
+
function pickVisionDelegate(current, registry, env = process.env) {
|
|
24
|
+
if (!current || seesImages(current)) return void 0;
|
|
25
|
+
const usable = /* @__PURE__ */ __name((m) => !!m && seesImages(m) && registry.hasConfiguredAuth(m), "usable");
|
|
26
|
+
const override = env.PRIVATEER_VISION_MODEL?.trim();
|
|
27
|
+
if (override) {
|
|
28
|
+
const slash = override.indexOf("/");
|
|
29
|
+
const m = slash > 0 ? registry.find(override.slice(0, slash), override.slice(slash + 1)) : void 0;
|
|
30
|
+
if (usable(m)) return m;
|
|
31
|
+
}
|
|
32
|
+
for (const id of PREFERRED[current.provider] ?? []) {
|
|
33
|
+
const m = registry.find(current.provider, id);
|
|
34
|
+
if (usable(m)) return m;
|
|
35
|
+
}
|
|
36
|
+
return registry.getAvailable().find((m) => m.provider === current.provider && usable(m));
|
|
37
|
+
}
|
|
38
|
+
__name(pickVisionDelegate, "pickVisionDelegate");
|
|
39
|
+
var OMITTED_NOTE = /\n?\[Current model does not support images\. The image will be omitted from this request\.\]/g;
|
|
40
|
+
var SYSTEM_PROMPT = [
|
|
41
|
+
"You are the eyes for another AI model that cannot see images.",
|
|
42
|
+
"Describe the image so that model can act on it without seeing it.",
|
|
43
|
+
"Transcribe ALL legible text verbatim (code, error messages, labels, numbers), preserving line breaks.",
|
|
44
|
+
"Then describe layout, UI elements and their state, colors where meaningful, charts/diagrams and what they show, and anything unusual.",
|
|
45
|
+
"Be precise and factual. Do not speculate beyond what is visible. No preamble."
|
|
46
|
+
].join(" ");
|
|
47
|
+
var cache = /* @__PURE__ */ new Map();
|
|
48
|
+
function describe(registry, delegate, image, hint, signal) {
|
|
49
|
+
const key = `${specOf(delegate)}:${createHash("sha256").update(image.data ?? "").digest("hex")}`;
|
|
50
|
+
const hit = cache.get(key);
|
|
51
|
+
if (hit) return hit;
|
|
52
|
+
const job = (async () => {
|
|
53
|
+
const res = await registry.complete(
|
|
54
|
+
delegate,
|
|
55
|
+
{
|
|
56
|
+
systemPrompt: SYSTEM_PROMPT,
|
|
57
|
+
messages: [
|
|
58
|
+
{
|
|
59
|
+
role: "user",
|
|
60
|
+
content: [
|
|
61
|
+
{ type: "text", text: hint ? `Context it appeared in:
|
|
62
|
+
${hint.slice(0, 2e3)}
|
|
63
|
+
|
|
64
|
+
Describe this image.` : "Describe this image." },
|
|
65
|
+
{ type: "image", data: image.data, mimeType: image.mimeType }
|
|
66
|
+
],
|
|
67
|
+
timestamp: Date.now()
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{ signal, cacheRetention: "none" }
|
|
72
|
+
);
|
|
73
|
+
if (res.stopReason === "error" || res.stopReason === "aborted") {
|
|
74
|
+
throw new Error(res.errorMessage || `vision model ${res.stopReason}`);
|
|
75
|
+
}
|
|
76
|
+
const text = res.content.filter((c) => c?.type === "text").map((c) => c.text).join("\n").trim();
|
|
77
|
+
if (!text) throw new Error("vision model returned no description");
|
|
78
|
+
return text;
|
|
79
|
+
})();
|
|
80
|
+
cache.set(key, job);
|
|
81
|
+
job.catch(() => cache.delete(key));
|
|
82
|
+
return job;
|
|
83
|
+
}
|
|
84
|
+
__name(describe, "describe");
|
|
85
|
+
async function describeImagesInMessages(messages, delegate, registry, opts = { currentSpec: "" }) {
|
|
86
|
+
const jobs = [];
|
|
87
|
+
for (const msg of messages) {
|
|
88
|
+
if (!msg || msg.role === "assistant" || !Array.isArray(msg.content)) continue;
|
|
89
|
+
const hint = msg.content.filter((b) => b?.type === "text").map((b) => b.text ?? "").join("\n").replace(OMITTED_NOTE, "");
|
|
90
|
+
for (const b of msg.content) if (b?.type === "image" && b.data) jobs.push({ block: b, hint });
|
|
91
|
+
}
|
|
92
|
+
if (jobs.length === 0) return void 0;
|
|
93
|
+
opts.onDescribe?.(jobs.length);
|
|
94
|
+
const results = /* @__PURE__ */ new Map();
|
|
95
|
+
await Promise.all(
|
|
96
|
+
jobs.map(async ({ block, hint }) => {
|
|
97
|
+
try {
|
|
98
|
+
const text = await describe(registry, delegate, block, hint, opts.signal);
|
|
99
|
+
results.set(block, `[Image \u2014 ${opts.currentSpec || "this model"} can't see images, so ${specOf(delegate)} described it:]
|
|
100
|
+
${text}`);
|
|
101
|
+
} catch (err) {
|
|
102
|
+
const why = err instanceof Error ? err.message : String(err);
|
|
103
|
+
results.set(block, `[Image omitted \u2014 ${specOf(delegate)} could not describe it: ${why}]`);
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
);
|
|
107
|
+
return messages.map((msg) => {
|
|
108
|
+
if (!msg || msg.role === "assistant" || !Array.isArray(msg.content)) return msg;
|
|
109
|
+
if (!msg.content.some((b) => results.has(b))) return msg;
|
|
110
|
+
const content = msg.content.map((b) => {
|
|
111
|
+
const described = results.get(b);
|
|
112
|
+
if (described !== void 0) return { type: "text", text: described };
|
|
113
|
+
if (b?.type === "text" && b.text) return { ...b, text: b.text.replace(OMITTED_NOTE, "") };
|
|
114
|
+
return b;
|
|
115
|
+
});
|
|
116
|
+
return { ...msg, content };
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
__name(describeImagesInMessages, "describeImagesInMessages");
|
|
120
|
+
|
|
121
|
+
// extensions/privateer-vision.ts?ext=privateer-vision
|
|
122
|
+
function privateerVision(pi) {
|
|
123
|
+
const announced = /* @__PURE__ */ new Set();
|
|
124
|
+
pi.on("context", async (event, ctx) => {
|
|
125
|
+
const model = ctx?.model;
|
|
126
|
+
const registry = ctx?.modelRegistry;
|
|
127
|
+
if (!model || !registry) return;
|
|
128
|
+
const delegate = pickVisionDelegate(model, registry);
|
|
129
|
+
if (!delegate) return;
|
|
130
|
+
const currentSpec = `${model.provider}/${model.id}`;
|
|
131
|
+
const delegateSpec = `${delegate.provider}/${delegate.id}`;
|
|
132
|
+
const messages = await describeImagesInMessages(event.messages, delegate, registry, {
|
|
133
|
+
currentSpec,
|
|
134
|
+
signal: ctx.signal,
|
|
135
|
+
onDescribe: /* @__PURE__ */ __name(() => {
|
|
136
|
+
const key = `${currentSpec}\u2192${delegateSpec}`;
|
|
137
|
+
if (announced.has(key) || !ctx.hasUI) return;
|
|
138
|
+
announced.add(key);
|
|
139
|
+
ctx.ui.notify(`${currentSpec} can't see images \u2014 ${delegateSpec} will describe them for it.`, "info");
|
|
140
|
+
}, "onDescribe")
|
|
141
|
+
});
|
|
142
|
+
return messages ? { messages } : void 0;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
__name(privateerVision, "privateerVision");
|
|
146
|
+
export {
|
|
147
|
+
privateerVision as default
|
|
148
|
+
};
|