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
|
+
classifySystemOne
|
|
4
|
+
} from "./c-TT6BCUJD.mjs";
|
|
5
|
+
import {
|
|
6
|
+
isRecord
|
|
7
|
+
} from "./c-WETGB2CF.mjs";
|
|
8
|
+
import "./c-ZWUVHKMK.mjs";
|
|
9
|
+
import "./c-EYZGSAJU.mjs";
|
|
10
|
+
import "./c-ZJYLGIC3.mjs";
|
|
11
|
+
import "./c-WO3QSZUU.mjs";
|
|
12
|
+
import "./c-S2RVHR3M.mjs";
|
|
13
|
+
import {
|
|
14
|
+
__name
|
|
15
|
+
} from "./c-CN77DCGF.mjs";
|
|
16
|
+
|
|
17
|
+
// node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.js
|
|
18
|
+
var transport = {
|
|
19
|
+
api: "typesafe-system-one",
|
|
20
|
+
label: "System One API",
|
|
21
|
+
url: /* @__PURE__ */ __name((model) => new URL("systemone", `${model.baseUrl.replace(/\/+$/u, "")}/`), "url"),
|
|
22
|
+
payload: /* @__PURE__ */ __name((model, request) => ({ model: model.id, ...request }), "payload"),
|
|
23
|
+
output: /* @__PURE__ */ __name((body) => {
|
|
24
|
+
if (!isRecord(body))
|
|
25
|
+
throw new Error("System One API returned an unexpected response");
|
|
26
|
+
return body;
|
|
27
|
+
}, "output")
|
|
28
|
+
};
|
|
29
|
+
var classify = /* @__PURE__ */ __name((model, context, options) => classifySystemOne(transport, model, context, options), "classify");
|
|
30
|
+
export {
|
|
31
|
+
classify
|
|
32
|
+
};
|
|
@@ -0,0 +1,379 @@
|
|
|
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
|
+
__commonJS,
|
|
4
|
+
__name,
|
|
5
|
+
__toESM
|
|
6
|
+
} from "./c-CN77DCGF.mjs";
|
|
7
|
+
|
|
8
|
+
// node_modules/partial-json/dist/options.js
|
|
9
|
+
var require_options = __commonJS({
|
|
10
|
+
"node_modules/partial-json/dist/options.js"(exports) {
|
|
11
|
+
"use strict";
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.Allow = exports.ALL = exports.COLLECTION = exports.ATOM = exports.SPECIAL = exports.INF = exports._INFINITY = exports.INFINITY = exports.NAN = exports.BOOL = exports.NULL = exports.OBJ = exports.ARR = exports.NUM = exports.STR = void 0;
|
|
14
|
+
exports.STR = 1;
|
|
15
|
+
exports.NUM = 2;
|
|
16
|
+
exports.ARR = 4;
|
|
17
|
+
exports.OBJ = 8;
|
|
18
|
+
exports.NULL = 16;
|
|
19
|
+
exports.BOOL = 32;
|
|
20
|
+
exports.NAN = 64;
|
|
21
|
+
exports.INFINITY = 128;
|
|
22
|
+
exports._INFINITY = 256;
|
|
23
|
+
exports.INF = exports.INFINITY | exports._INFINITY;
|
|
24
|
+
exports.SPECIAL = exports.NULL | exports.BOOL | exports.INF | exports.NAN;
|
|
25
|
+
exports.ATOM = exports.STR | exports.NUM | exports.SPECIAL;
|
|
26
|
+
exports.COLLECTION = exports.ARR | exports.OBJ;
|
|
27
|
+
exports.ALL = exports.ATOM | exports.COLLECTION;
|
|
28
|
+
exports.Allow = { STR: exports.STR, NUM: exports.NUM, ARR: exports.ARR, OBJ: exports.OBJ, NULL: exports.NULL, BOOL: exports.BOOL, NAN: exports.NAN, INFINITY: exports.INFINITY, _INFINITY: exports._INFINITY, INF: exports.INF, SPECIAL: exports.SPECIAL, ATOM: exports.ATOM, COLLECTION: exports.COLLECTION, ALL: exports.ALL };
|
|
29
|
+
exports.default = exports.Allow;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// node_modules/partial-json/dist/index.js
|
|
34
|
+
var require_dist = __commonJS({
|
|
35
|
+
"node_modules/partial-json/dist/index.js"(exports) {
|
|
36
|
+
"use strict";
|
|
37
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
38
|
+
if (k2 === void 0) k2 = k;
|
|
39
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
40
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
41
|
+
desc = { enumerable: true, get: /* @__PURE__ */ __name(function() {
|
|
42
|
+
return m[k];
|
|
43
|
+
}, "get") };
|
|
44
|
+
}
|
|
45
|
+
Object.defineProperty(o, k2, desc);
|
|
46
|
+
}) : (function(o, m, k, k2) {
|
|
47
|
+
if (k2 === void 0) k2 = k;
|
|
48
|
+
o[k2] = m[k];
|
|
49
|
+
}));
|
|
50
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
51
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.Allow = exports.MalformedJSON = exports.PartialJSON = exports.parseJSON = exports.parse = void 0;
|
|
55
|
+
var options_1 = require_options();
|
|
56
|
+
Object.defineProperty(exports, "Allow", { enumerable: true, get: /* @__PURE__ */ __name(function() {
|
|
57
|
+
return options_1.Allow;
|
|
58
|
+
}, "get") });
|
|
59
|
+
__exportStar(require_options(), exports);
|
|
60
|
+
var PartialJSON = class extends Error {
|
|
61
|
+
static {
|
|
62
|
+
__name(this, "PartialJSON");
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.PartialJSON = PartialJSON;
|
|
66
|
+
var MalformedJSON = class extends Error {
|
|
67
|
+
static {
|
|
68
|
+
__name(this, "MalformedJSON");
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.MalformedJSON = MalformedJSON;
|
|
72
|
+
function parseJSON(jsonString, allowPartial = options_1.Allow.ALL) {
|
|
73
|
+
if (typeof jsonString !== "string") {
|
|
74
|
+
throw new TypeError(`expecting str, got ${typeof jsonString}`);
|
|
75
|
+
}
|
|
76
|
+
if (!jsonString.trim()) {
|
|
77
|
+
throw new Error(`${jsonString} is empty`);
|
|
78
|
+
}
|
|
79
|
+
return _parseJSON(jsonString.trim(), allowPartial);
|
|
80
|
+
}
|
|
81
|
+
__name(parseJSON, "parseJSON");
|
|
82
|
+
exports.parseJSON = parseJSON;
|
|
83
|
+
var _parseJSON = /* @__PURE__ */ __name((jsonString, allow) => {
|
|
84
|
+
const length = jsonString.length;
|
|
85
|
+
let index = 0;
|
|
86
|
+
const markPartialJSON = /* @__PURE__ */ __name((msg) => {
|
|
87
|
+
throw new PartialJSON(`${msg} at position ${index}`);
|
|
88
|
+
}, "markPartialJSON");
|
|
89
|
+
const throwMalformedError = /* @__PURE__ */ __name((msg) => {
|
|
90
|
+
throw new MalformedJSON(`${msg} at position ${index}`);
|
|
91
|
+
}, "throwMalformedError");
|
|
92
|
+
const parseAny = /* @__PURE__ */ __name(() => {
|
|
93
|
+
skipBlank();
|
|
94
|
+
if (index >= length)
|
|
95
|
+
markPartialJSON("Unexpected end of input");
|
|
96
|
+
if (jsonString[index] === '"')
|
|
97
|
+
return parseStr();
|
|
98
|
+
if (jsonString[index] === "{")
|
|
99
|
+
return parseObj();
|
|
100
|
+
if (jsonString[index] === "[")
|
|
101
|
+
return parseArr();
|
|
102
|
+
if (jsonString.substring(index, index + 4) === "null" || options_1.Allow.NULL & allow && length - index < 4 && "null".startsWith(jsonString.substring(index))) {
|
|
103
|
+
index += 4;
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
if (jsonString.substring(index, index + 4) === "true" || options_1.Allow.BOOL & allow && length - index < 4 && "true".startsWith(jsonString.substring(index))) {
|
|
107
|
+
index += 4;
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
if (jsonString.substring(index, index + 5) === "false" || options_1.Allow.BOOL & allow && length - index < 5 && "false".startsWith(jsonString.substring(index))) {
|
|
111
|
+
index += 5;
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
if (jsonString.substring(index, index + 8) === "Infinity" || options_1.Allow.INFINITY & allow && length - index < 8 && "Infinity".startsWith(jsonString.substring(index))) {
|
|
115
|
+
index += 8;
|
|
116
|
+
return Infinity;
|
|
117
|
+
}
|
|
118
|
+
if (jsonString.substring(index, index + 9) === "-Infinity" || options_1.Allow._INFINITY & allow && 1 < length - index && length - index < 9 && "-Infinity".startsWith(jsonString.substring(index))) {
|
|
119
|
+
index += 9;
|
|
120
|
+
return -Infinity;
|
|
121
|
+
}
|
|
122
|
+
if (jsonString.substring(index, index + 3) === "NaN" || options_1.Allow.NAN & allow && length - index < 3 && "NaN".startsWith(jsonString.substring(index))) {
|
|
123
|
+
index += 3;
|
|
124
|
+
return NaN;
|
|
125
|
+
}
|
|
126
|
+
return parseNum();
|
|
127
|
+
}, "parseAny");
|
|
128
|
+
const parseStr = /* @__PURE__ */ __name(() => {
|
|
129
|
+
const start = index;
|
|
130
|
+
let escape = false;
|
|
131
|
+
index++;
|
|
132
|
+
while (index < length && (jsonString[index] !== '"' || escape && jsonString[index - 1] === "\\")) {
|
|
133
|
+
escape = jsonString[index] === "\\" ? !escape : false;
|
|
134
|
+
index++;
|
|
135
|
+
}
|
|
136
|
+
if (jsonString.charAt(index) == '"') {
|
|
137
|
+
try {
|
|
138
|
+
return JSON.parse(jsonString.substring(start, ++index - Number(escape)));
|
|
139
|
+
} catch (e) {
|
|
140
|
+
throwMalformedError(String(e));
|
|
141
|
+
}
|
|
142
|
+
} else if (options_1.Allow.STR & allow) {
|
|
143
|
+
try {
|
|
144
|
+
return JSON.parse(jsonString.substring(start, index - Number(escape)) + '"');
|
|
145
|
+
} catch (e) {
|
|
146
|
+
return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("\\")) + '"');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
markPartialJSON("Unterminated string literal");
|
|
150
|
+
}, "parseStr");
|
|
151
|
+
const parseObj = /* @__PURE__ */ __name(() => {
|
|
152
|
+
index++;
|
|
153
|
+
skipBlank();
|
|
154
|
+
const obj = {};
|
|
155
|
+
try {
|
|
156
|
+
while (jsonString[index] !== "}") {
|
|
157
|
+
skipBlank();
|
|
158
|
+
if (index >= length && options_1.Allow.OBJ & allow)
|
|
159
|
+
return obj;
|
|
160
|
+
const key = parseStr();
|
|
161
|
+
skipBlank();
|
|
162
|
+
index++;
|
|
163
|
+
try {
|
|
164
|
+
const value = parseAny();
|
|
165
|
+
obj[key] = value;
|
|
166
|
+
} catch (e) {
|
|
167
|
+
if (options_1.Allow.OBJ & allow)
|
|
168
|
+
return obj;
|
|
169
|
+
else
|
|
170
|
+
throw e;
|
|
171
|
+
}
|
|
172
|
+
skipBlank();
|
|
173
|
+
if (jsonString[index] === ",")
|
|
174
|
+
index++;
|
|
175
|
+
}
|
|
176
|
+
} catch (e) {
|
|
177
|
+
if (options_1.Allow.OBJ & allow)
|
|
178
|
+
return obj;
|
|
179
|
+
else
|
|
180
|
+
markPartialJSON("Expected '}' at end of object");
|
|
181
|
+
}
|
|
182
|
+
index++;
|
|
183
|
+
return obj;
|
|
184
|
+
}, "parseObj");
|
|
185
|
+
const parseArr = /* @__PURE__ */ __name(() => {
|
|
186
|
+
index++;
|
|
187
|
+
const arr = [];
|
|
188
|
+
try {
|
|
189
|
+
while (jsonString[index] !== "]") {
|
|
190
|
+
arr.push(parseAny());
|
|
191
|
+
skipBlank();
|
|
192
|
+
if (jsonString[index] === ",") {
|
|
193
|
+
index++;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
} catch (e) {
|
|
197
|
+
if (options_1.Allow.ARR & allow) {
|
|
198
|
+
return arr;
|
|
199
|
+
}
|
|
200
|
+
markPartialJSON("Expected ']' at end of array");
|
|
201
|
+
}
|
|
202
|
+
index++;
|
|
203
|
+
return arr;
|
|
204
|
+
}, "parseArr");
|
|
205
|
+
const parseNum = /* @__PURE__ */ __name(() => {
|
|
206
|
+
if (index === 0) {
|
|
207
|
+
if (jsonString === "-")
|
|
208
|
+
throwMalformedError("Not sure what '-' is");
|
|
209
|
+
try {
|
|
210
|
+
return JSON.parse(jsonString);
|
|
211
|
+
} catch (e) {
|
|
212
|
+
if (options_1.Allow.NUM & allow)
|
|
213
|
+
try {
|
|
214
|
+
return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf("e")));
|
|
215
|
+
} catch (e2) {
|
|
216
|
+
}
|
|
217
|
+
throwMalformedError(String(e));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const start = index;
|
|
221
|
+
if (jsonString[index] === "-")
|
|
222
|
+
index++;
|
|
223
|
+
while (jsonString[index] && ",]}".indexOf(jsonString[index]) === -1)
|
|
224
|
+
index++;
|
|
225
|
+
if (index == length && !(options_1.Allow.NUM & allow))
|
|
226
|
+
markPartialJSON("Unterminated number literal");
|
|
227
|
+
try {
|
|
228
|
+
return JSON.parse(jsonString.substring(start, index));
|
|
229
|
+
} catch (e) {
|
|
230
|
+
if (jsonString.substring(start, index) === "-")
|
|
231
|
+
markPartialJSON("Not sure what '-' is");
|
|
232
|
+
try {
|
|
233
|
+
return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("e")));
|
|
234
|
+
} catch (e2) {
|
|
235
|
+
throwMalformedError(String(e2));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}, "parseNum");
|
|
239
|
+
const skipBlank = /* @__PURE__ */ __name(() => {
|
|
240
|
+
while (index < length && " \n\r ".includes(jsonString[index])) {
|
|
241
|
+
index++;
|
|
242
|
+
}
|
|
243
|
+
}, "skipBlank");
|
|
244
|
+
return parseAny();
|
|
245
|
+
}, "_parseJSON");
|
|
246
|
+
var parse = parseJSON;
|
|
247
|
+
exports.parse = parse;
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js
|
|
252
|
+
var import_partial_json = __toESM(require_dist(), 1);
|
|
253
|
+
var VALID_JSON_ESCAPES = /* @__PURE__ */ new Set(['"', "\\", "/", "b", "f", "n", "r", "t"]);
|
|
254
|
+
function isControlCharacter(char) {
|
|
255
|
+
const codePoint = char.codePointAt(0);
|
|
256
|
+
return codePoint !== void 0 && codePoint >= 0 && codePoint <= 31;
|
|
257
|
+
}
|
|
258
|
+
__name(isControlCharacter, "isControlCharacter");
|
|
259
|
+
function escapeControlCharacter(char) {
|
|
260
|
+
switch (char) {
|
|
261
|
+
case "\b":
|
|
262
|
+
return "\\b";
|
|
263
|
+
case "\f":
|
|
264
|
+
return "\\f";
|
|
265
|
+
case "\n":
|
|
266
|
+
return "\\n";
|
|
267
|
+
case "\r":
|
|
268
|
+
return "\\r";
|
|
269
|
+
case " ":
|
|
270
|
+
return "\\t";
|
|
271
|
+
default:
|
|
272
|
+
return `\\u${char.codePointAt(0)?.toString(16).padStart(4, "0") ?? "0000"}`;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
__name(escapeControlCharacter, "escapeControlCharacter");
|
|
276
|
+
function repairJson(json) {
|
|
277
|
+
let repaired = "";
|
|
278
|
+
let inString = false;
|
|
279
|
+
for (let index = 0; index < json.length; index++) {
|
|
280
|
+
const char = json[index];
|
|
281
|
+
if (!inString) {
|
|
282
|
+
repaired += char;
|
|
283
|
+
if (char === '"') {
|
|
284
|
+
inString = true;
|
|
285
|
+
}
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (char === '"') {
|
|
289
|
+
repaired += char;
|
|
290
|
+
inString = false;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (char === "\\") {
|
|
294
|
+
const nextChar = json[index + 1];
|
|
295
|
+
if (nextChar === void 0) {
|
|
296
|
+
repaired += "\\\\";
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (nextChar === "u") {
|
|
300
|
+
const unicodeDigits = json.slice(index + 2, index + 6);
|
|
301
|
+
if (/^[0-9a-fA-F]{4}$/.test(unicodeDigits)) {
|
|
302
|
+
repaired += `\\u${unicodeDigits}`;
|
|
303
|
+
index += 5;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (VALID_JSON_ESCAPES.has(nextChar)) {
|
|
308
|
+
repaired += `\\${nextChar}`;
|
|
309
|
+
index += 1;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
repaired += "\\\\";
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
repaired += isControlCharacter(char) ? escapeControlCharacter(char) : char;
|
|
316
|
+
}
|
|
317
|
+
return repaired;
|
|
318
|
+
}
|
|
319
|
+
__name(repairJson, "repairJson");
|
|
320
|
+
function parseJsonWithRepair(json) {
|
|
321
|
+
try {
|
|
322
|
+
return JSON.parse(json);
|
|
323
|
+
} catch (error) {
|
|
324
|
+
const repairedJson = repairJson(json);
|
|
325
|
+
if (repairedJson !== json) {
|
|
326
|
+
return JSON.parse(repairedJson);
|
|
327
|
+
}
|
|
328
|
+
throw error;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
__name(parseJsonWithRepair, "parseJsonWithRepair");
|
|
332
|
+
function parseToolCallArguments(json) {
|
|
333
|
+
if (!json?.trim())
|
|
334
|
+
return { arguments: {} };
|
|
335
|
+
try {
|
|
336
|
+
const parsed = parseJsonWithRepair(json);
|
|
337
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
338
|
+
throw new Error("Tool arguments must be a JSON object");
|
|
339
|
+
}
|
|
340
|
+
return { arguments: parsed };
|
|
341
|
+
} catch (error) {
|
|
342
|
+
return {
|
|
343
|
+
arguments: {},
|
|
344
|
+
argumentsError: `${error instanceof Error ? error.message : String(error)}
|
|
345
|
+
|
|
346
|
+
Received arguments:
|
|
347
|
+
${json}`
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
__name(parseToolCallArguments, "parseToolCallArguments");
|
|
352
|
+
function parseStreamingJson(partialJson) {
|
|
353
|
+
if (!partialJson || partialJson.trim() === "") {
|
|
354
|
+
return {};
|
|
355
|
+
}
|
|
356
|
+
try {
|
|
357
|
+
return parseJsonWithRepair(partialJson);
|
|
358
|
+
} catch {
|
|
359
|
+
try {
|
|
360
|
+
const result = (0, import_partial_json.parse)(partialJson);
|
|
361
|
+
return result ?? {};
|
|
362
|
+
} catch {
|
|
363
|
+
try {
|
|
364
|
+
const result = (0, import_partial_json.parse)(repairJson(partialJson));
|
|
365
|
+
return result ?? {};
|
|
366
|
+
} catch {
|
|
367
|
+
return {};
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
__name(parseStreamingJson, "parseStreamingJson");
|
|
373
|
+
|
|
374
|
+
export {
|
|
375
|
+
repairJson,
|
|
376
|
+
parseJsonWithRepair,
|
|
377
|
+
parseToolCallArguments,
|
|
378
|
+
parseStreamingJson
|
|
379
|
+
};
|