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,21 @@
|
|
|
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
|
+
McpOAuthCredentialStore,
|
|
4
|
+
McpServerConnection,
|
|
5
|
+
McpServerLog,
|
|
6
|
+
McpSignInCancelledError,
|
|
7
|
+
createDefaultTransport,
|
|
8
|
+
signInMcpServer
|
|
9
|
+
} from "./c-OBQDHSXM.mjs";
|
|
10
|
+
import "./c-E4Z3Y5B5.mjs";
|
|
11
|
+
import "./c-6ZO2SADQ.mjs";
|
|
12
|
+
import "./c-PTN4S6G2.mjs";
|
|
13
|
+
import "./c-CN77DCGF.mjs";
|
|
14
|
+
export {
|
|
15
|
+
McpOAuthCredentialStore,
|
|
16
|
+
McpServerConnection,
|
|
17
|
+
McpServerLog,
|
|
18
|
+
McpSignInCancelledError,
|
|
19
|
+
createDefaultTransport,
|
|
20
|
+
signInMcpServer
|
|
21
|
+
};
|
|
@@ -0,0 +1,319 @@
|
|
|
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
|
+
defaultFusionModelConfig
|
|
4
|
+
} from "./c-CRIHASQ6.mjs";
|
|
5
|
+
import {
|
|
6
|
+
CURRENT_MODEL_SELECTION
|
|
7
|
+
} from "./c-G4DLN7Q4.mjs";
|
|
8
|
+
import "./c-37GM3GMU.mjs";
|
|
9
|
+
import "./c-DR7XQI32.mjs";
|
|
10
|
+
import "./c-I3C6LBW4.mjs";
|
|
11
|
+
import "./c-B2Y7VNHU.mjs";
|
|
12
|
+
import "./c-SKMK3PEE.mjs";
|
|
13
|
+
import "./c-I54OKQHW.mjs";
|
|
14
|
+
import "./c-UPBH5AXY.mjs";
|
|
15
|
+
import "./c-7UOG7POX.mjs";
|
|
16
|
+
import "./c-E4Z3Y5B5.mjs";
|
|
17
|
+
import "./c-6ZO2SADQ.mjs";
|
|
18
|
+
import "./c-JKTFXTGF.mjs";
|
|
19
|
+
import "./c-CRBXNKFO.mjs";
|
|
20
|
+
import "./c-KP6CRIP4.mjs";
|
|
21
|
+
import "./c-RSKCUPJF.mjs";
|
|
22
|
+
import "./c-PTN4S6G2.mjs";
|
|
23
|
+
import "./c-P6N5DQGZ.mjs";
|
|
24
|
+
import "./c-6LOBR4I6.mjs";
|
|
25
|
+
import "./c-3STKRSVO.mjs";
|
|
26
|
+
import "./c-YRDO2WEF.mjs";
|
|
27
|
+
import "./c-BHNIF2AR.mjs";
|
|
28
|
+
import "./c-ABXULAFL.mjs";
|
|
29
|
+
import "./c-2G3BBHRJ.mjs";
|
|
30
|
+
import "./c-O5PP6CTX.mjs";
|
|
31
|
+
import "./c-CDBEJSBF.mjs";
|
|
32
|
+
import "./c-DEE67DJO.mjs";
|
|
33
|
+
import "./c-WO3QSZUU.mjs";
|
|
34
|
+
import "./c-S2RVHR3M.mjs";
|
|
35
|
+
import {
|
|
36
|
+
Key,
|
|
37
|
+
matchesKey,
|
|
38
|
+
truncateToWidth
|
|
39
|
+
} from "./c-EQBKXWNX.mjs";
|
|
40
|
+
import "./c-RQJJ26T4.mjs";
|
|
41
|
+
import "./c-L5GHWG5G.mjs";
|
|
42
|
+
import {
|
|
43
|
+
__name
|
|
44
|
+
} from "./c-CN77DCGF.mjs";
|
|
45
|
+
|
|
46
|
+
// node_modules/pi-background-tasks/src/ui/fusion-model-selector.ts?ext=pi-background-tasks
|
|
47
|
+
var FUSION_MODEL_SLOT_IDS = [
|
|
48
|
+
"candidate-1",
|
|
49
|
+
"candidate-2",
|
|
50
|
+
"candidate-3",
|
|
51
|
+
"evaluator",
|
|
52
|
+
"merger"
|
|
53
|
+
];
|
|
54
|
+
function slotLabel(id) {
|
|
55
|
+
if (id === "candidate-1") return "Candidate 1";
|
|
56
|
+
if (id === "candidate-2") return "Candidate 2";
|
|
57
|
+
if (id === "candidate-3") return "Candidate 3";
|
|
58
|
+
if (id === "evaluator") return "Evaluator";
|
|
59
|
+
return "Merger";
|
|
60
|
+
}
|
|
61
|
+
__name(slotLabel, "slotLabel");
|
|
62
|
+
function configValue(config, id) {
|
|
63
|
+
if (id === "candidate-1") return config.candidates[0];
|
|
64
|
+
if (id === "candidate-2") return config.candidates[1];
|
|
65
|
+
if (id === "candidate-3") return config.candidates[2];
|
|
66
|
+
if (id === "evaluator") return config.evaluator;
|
|
67
|
+
return config.merger;
|
|
68
|
+
}
|
|
69
|
+
__name(configValue, "configValue");
|
|
70
|
+
function updateConfig(config, id, value) {
|
|
71
|
+
if (id === "candidate-1")
|
|
72
|
+
return { ...config, candidates: [value, config.candidates[1], config.candidates[2]] };
|
|
73
|
+
if (id === "candidate-2")
|
|
74
|
+
return { ...config, candidates: [config.candidates[0], value, config.candidates[2]] };
|
|
75
|
+
if (id === "candidate-3")
|
|
76
|
+
return { ...config, candidates: [config.candidates[0], config.candidates[1], value] };
|
|
77
|
+
if (id === "evaluator") return { ...config, evaluator: value };
|
|
78
|
+
return { ...config, merger: value };
|
|
79
|
+
}
|
|
80
|
+
__name(updateConfig, "updateConfig");
|
|
81
|
+
function queryMatches(choice, query) {
|
|
82
|
+
if (query.length === 0) return true;
|
|
83
|
+
const haystack = `${choice.label} ${choice.description} ${choice.value}`.toLowerCase();
|
|
84
|
+
return haystack.includes(query.toLowerCase());
|
|
85
|
+
}
|
|
86
|
+
__name(queryMatches, "queryMatches");
|
|
87
|
+
function printable(data) {
|
|
88
|
+
if (data.length !== 1) return void 0;
|
|
89
|
+
const code = data.charCodeAt(0);
|
|
90
|
+
if (code < 32 || code === 127) return void 0;
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
__name(printable, "printable");
|
|
94
|
+
function modelChoiceLine(choice) {
|
|
95
|
+
const status = choice.available ? "" : " (unavailable)";
|
|
96
|
+
return `${choice.label}${status}${choice.description ? ` \u2014 ${choice.description}` : ""}`;
|
|
97
|
+
}
|
|
98
|
+
__name(modelChoiceLine, "modelChoiceLine");
|
|
99
|
+
function slotViews(config) {
|
|
100
|
+
return FUSION_MODEL_SLOT_IDS.map((id) => ({
|
|
101
|
+
id,
|
|
102
|
+
label: slotLabel(id),
|
|
103
|
+
value: configValue(config, id)
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
__name(slotViews, "slotViews");
|
|
107
|
+
var FusionModelSelector = class {
|
|
108
|
+
static {
|
|
109
|
+
__name(this, "FusionModelSelector");
|
|
110
|
+
}
|
|
111
|
+
choices;
|
|
112
|
+
theme;
|
|
113
|
+
onSave;
|
|
114
|
+
onDone;
|
|
115
|
+
onRenderRequest;
|
|
116
|
+
draft;
|
|
117
|
+
mode = "slots";
|
|
118
|
+
selectedSlot = 0;
|
|
119
|
+
selectedChoice = 0;
|
|
120
|
+
search = "";
|
|
121
|
+
saving = false;
|
|
122
|
+
error;
|
|
123
|
+
cachedWidth;
|
|
124
|
+
cachedLines;
|
|
125
|
+
constructor(options) {
|
|
126
|
+
this.draft = options.initialConfig;
|
|
127
|
+
this.choices = options.choices;
|
|
128
|
+
this.theme = options.theme;
|
|
129
|
+
this.onSave = options.onSave;
|
|
130
|
+
this.onDone = options.onDone;
|
|
131
|
+
this.onRenderRequest = options.onRenderRequest;
|
|
132
|
+
}
|
|
133
|
+
render(width) {
|
|
134
|
+
if (this.cachedWidth === width && this.cachedLines !== void 0) return this.cachedLines;
|
|
135
|
+
const lines = this.mode === "slots" ? this.renderSlots(width) : this.renderChoices(width);
|
|
136
|
+
this.cachedWidth = width;
|
|
137
|
+
this.cachedLines = lines.map((line) => truncateToWidth(line, Math.max(1, width)));
|
|
138
|
+
return this.cachedLines;
|
|
139
|
+
}
|
|
140
|
+
handleInput(data) {
|
|
141
|
+
if (this.saving) return;
|
|
142
|
+
if (this.mode === "slots") this.handleSlotInput(data);
|
|
143
|
+
else this.handleChoiceInput(data);
|
|
144
|
+
}
|
|
145
|
+
invalidate() {
|
|
146
|
+
this.cachedWidth = void 0;
|
|
147
|
+
this.cachedLines = void 0;
|
|
148
|
+
}
|
|
149
|
+
renderSlots(width) {
|
|
150
|
+
const slots = slotViews(this.draft);
|
|
151
|
+
const lines = [
|
|
152
|
+
this.theme.fg("accent", this.theme.bold("Fusion models")),
|
|
153
|
+
this.theme.fg("dim", "Select five slots. Duplicate models are allowed."),
|
|
154
|
+
""
|
|
155
|
+
];
|
|
156
|
+
for (const [index, slot] of slots.entries()) {
|
|
157
|
+
const marker = index === this.selectedSlot ? this.theme.fg("accent", "\u203A") : " ";
|
|
158
|
+
const value = this.describeSelection(slot.value);
|
|
159
|
+
lines.push(`${marker} ${slot.label.padEnd(12)} ${value}`);
|
|
160
|
+
}
|
|
161
|
+
lines.push("");
|
|
162
|
+
if (this.error !== void 0) lines.push(this.theme.fg("error", this.error));
|
|
163
|
+
const saveText = this.saving ? "saving\u2026" : "s save";
|
|
164
|
+
lines.push(this.theme.fg("dim", `\u2191\u2193 slot \u2022 enter choose \u2022 r reset \u2022 ${saveText} \u2022 esc cancel`));
|
|
165
|
+
return lines.map((line) => truncateToWidth(line, width));
|
|
166
|
+
}
|
|
167
|
+
renderChoices(width) {
|
|
168
|
+
const selectedSlot = FUSION_MODEL_SLOT_IDS[this.selectedSlot];
|
|
169
|
+
const title = selectedSlot === void 0 ? "Choose model" : `Choose model for ${slotLabel(selectedSlot)}`;
|
|
170
|
+
const filtered = this.filteredChoices();
|
|
171
|
+
const lines = [
|
|
172
|
+
this.theme.fg("accent", this.theme.bold(title)),
|
|
173
|
+
`${this.theme.fg("dim", "Search:")} ${this.search || this.theme.fg("dim", "(type to filter)")}`,
|
|
174
|
+
""
|
|
175
|
+
];
|
|
176
|
+
if (filtered.length === 0) {
|
|
177
|
+
lines.push(this.theme.fg("warning", "No matching models."));
|
|
178
|
+
} else {
|
|
179
|
+
const windowStart = Math.max(
|
|
180
|
+
0,
|
|
181
|
+
Math.min(this.selectedChoice - 6, Math.max(0, filtered.length - 12))
|
|
182
|
+
);
|
|
183
|
+
const windowItems = filtered.slice(windowStart, windowStart + 12);
|
|
184
|
+
for (const [offset, choice] of windowItems.entries()) {
|
|
185
|
+
const index = windowStart + offset;
|
|
186
|
+
const marker = index === this.selectedChoice ? this.theme.fg("accent", "\u203A") : " ";
|
|
187
|
+
const label = choice.available ? choice.label : this.theme.fg("warning", choice.label);
|
|
188
|
+
const description = choice.description ? this.theme.fg("dim", ` \u2014 ${choice.description}`) : "";
|
|
189
|
+
const stale = choice.available ? "" : this.theme.fg("warning", " (unavailable)");
|
|
190
|
+
lines.push(`${marker} ${label}${stale}${description}`);
|
|
191
|
+
}
|
|
192
|
+
if (filtered.length > windowItems.length) {
|
|
193
|
+
lines.push(
|
|
194
|
+
this.theme.fg(
|
|
195
|
+
"dim",
|
|
196
|
+
`${String(windowStart + 1)}-${String(windowStart + windowItems.length)} of ${String(filtered.length)}`
|
|
197
|
+
)
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
lines.push("");
|
|
202
|
+
lines.push(this.theme.fg("dim", "\u2191\u2193 choose \u2022 enter apply \u2022 backspace edit search \u2022 esc back"));
|
|
203
|
+
return lines.map((line) => truncateToWidth(line, width));
|
|
204
|
+
}
|
|
205
|
+
handleSlotInput(data) {
|
|
206
|
+
if (matchesKey(data, Key.up)) {
|
|
207
|
+
this.selectedSlot = Math.max(0, this.selectedSlot - 1);
|
|
208
|
+
this.changed();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (matchesKey(data, Key.down)) {
|
|
212
|
+
this.selectedSlot = Math.min(FUSION_MODEL_SLOT_IDS.length - 1, this.selectedSlot + 1);
|
|
213
|
+
this.changed();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (matchesKey(data, Key.enter) || data === "\r") {
|
|
217
|
+
this.mode = "models";
|
|
218
|
+
this.search = "";
|
|
219
|
+
this.selectedChoice = this.selectedChoiceForCurrentSlot();
|
|
220
|
+
this.changed();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (data === "r") {
|
|
224
|
+
this.draft = defaultFusionModelConfig();
|
|
225
|
+
this.error = void 0;
|
|
226
|
+
this.changed();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (data === "s") {
|
|
230
|
+
void this.save();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (matchesKey(data, Key.escape) || data === "q") {
|
|
234
|
+
this.onDone({ type: "cancelled" });
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
handleChoiceInput(data) {
|
|
238
|
+
const filtered = this.filteredChoices();
|
|
239
|
+
if (matchesKey(data, Key.up)) {
|
|
240
|
+
this.selectedChoice = Math.max(0, this.selectedChoice - 1);
|
|
241
|
+
this.changed();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (matchesKey(data, Key.down)) {
|
|
245
|
+
this.selectedChoice = Math.min(Math.max(0, filtered.length - 1), this.selectedChoice + 1);
|
|
246
|
+
this.changed();
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (matchesKey(data, Key.enter) || data === "\r") {
|
|
250
|
+
const choice = filtered[this.selectedChoice];
|
|
251
|
+
const slot = FUSION_MODEL_SLOT_IDS[this.selectedSlot];
|
|
252
|
+
if (choice !== void 0 && slot !== void 0) {
|
|
253
|
+
this.draft = updateConfig(this.draft, slot, choice.value);
|
|
254
|
+
this.mode = "slots";
|
|
255
|
+
this.error = void 0;
|
|
256
|
+
}
|
|
257
|
+
this.changed();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
if (matchesKey(data, Key.escape)) {
|
|
261
|
+
this.mode = "slots";
|
|
262
|
+
this.changed();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (matchesKey(data, Key.backspace) || data === "\x7F") {
|
|
266
|
+
this.search = this.search.slice(0, -1);
|
|
267
|
+
this.selectedChoice = 0;
|
|
268
|
+
this.changed();
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const char = printable(data);
|
|
272
|
+
if (char !== void 0) {
|
|
273
|
+
this.search += char;
|
|
274
|
+
this.selectedChoice = 0;
|
|
275
|
+
this.changed();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
async save() {
|
|
279
|
+
this.saving = true;
|
|
280
|
+
this.error = void 0;
|
|
281
|
+
this.changed();
|
|
282
|
+
try {
|
|
283
|
+
await this.onSave(this.draft);
|
|
284
|
+
this.onDone({ type: "saved", config: this.draft });
|
|
285
|
+
} catch (error) {
|
|
286
|
+
this.error = error instanceof Error ? error.message : String(error);
|
|
287
|
+
this.saving = false;
|
|
288
|
+
this.changed();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
changed() {
|
|
292
|
+
this.invalidate();
|
|
293
|
+
this.onRenderRequest?.();
|
|
294
|
+
}
|
|
295
|
+
filteredChoices() {
|
|
296
|
+
return this.choices.filter((choice) => queryMatches(choice, this.search));
|
|
297
|
+
}
|
|
298
|
+
selectedChoiceForCurrentSlot() {
|
|
299
|
+
const slot = FUSION_MODEL_SLOT_IDS[this.selectedSlot];
|
|
300
|
+
if (slot === void 0) return 0;
|
|
301
|
+
const current = configValue(this.draft, slot);
|
|
302
|
+
const filtered = this.filteredChoices();
|
|
303
|
+
const index = filtered.findIndex((choice) => choice.value === current);
|
|
304
|
+
return index >= 0 ? index : 0;
|
|
305
|
+
}
|
|
306
|
+
describeSelection(value) {
|
|
307
|
+
if (value === CURRENT_MODEL_SELECTION) {
|
|
308
|
+
const current = this.choices.find((choice) => choice.value === CURRENT_MODEL_SELECTION);
|
|
309
|
+
return current === void 0 ? CURRENT_MODEL_SELECTION : modelChoiceLine(current);
|
|
310
|
+
}
|
|
311
|
+
const found = this.choices.find((choice) => choice.value === value);
|
|
312
|
+
if (found === void 0) return `${value} (unavailable)`;
|
|
313
|
+
return modelChoiceLine(found);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
export {
|
|
317
|
+
FUSION_MODEL_SLOT_IDS,
|
|
318
|
+
FusionModelSelector
|
|
319
|
+
};
|