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.
Files changed (229) hide show
  1. package/README.md +11 -0
  2. package/bin/boot-bundle.d.mts +2 -0
  3. package/bin/boot-bundle.mjs +44 -0
  4. package/bin/fresh-supervisor.d.mts +5 -1
  5. package/bin/fresh-supervisor.mjs +47 -10
  6. package/bin/privateer-launch.mjs +27 -3
  7. package/bin/privateer-subagent.mjs +5 -2
  8. package/bin/privateer-verify.mjs +12 -0
  9. package/bin/session-recovery.d.mts +53 -0
  10. package/bin/session-recovery.mjs +240 -0
  11. package/bin/session-seal-preload.mjs +17 -0
  12. package/bin/session-seal.d.mts +25 -0
  13. package/bin/session-seal.mjs +242 -0
  14. package/dist-boot/boot.mjs +3 -0
  15. package/dist-boot/c-27JKSMWL.mjs +1460 -0
  16. package/dist-boot/c-2BMRFV24.mjs +269 -0
  17. package/dist-boot/c-2CTF6JA3.mjs +166 -0
  18. package/dist-boot/c-2G3BBHRJ.mjs +84 -0
  19. package/dist-boot/c-2IDLKXX6.mjs +250 -0
  20. package/dist-boot/c-2NJD5VYM.mjs +8 -0
  21. package/dist-boot/c-2S5EEQPW.mjs +1602 -0
  22. package/dist-boot/c-2WRDCUVI.mjs +25 -0
  23. package/dist-boot/c-2YN3M256.mjs +14 -0
  24. package/dist-boot/c-37GM3GMU.mjs +187 -0
  25. package/dist-boot/c-3STKRSVO.mjs +2480 -0
  26. package/dist-boot/c-3TPV6TQQ.mjs +2320 -0
  27. package/dist-boot/c-3UVHLQDJ.mjs +225 -0
  28. package/dist-boot/c-42PUUZYC.mjs +697 -0
  29. package/dist-boot/c-4D5UMWVW.mjs +683 -0
  30. package/dist-boot/c-4ETZRMTA.mjs +46 -0
  31. package/dist-boot/c-4QT25BD5.mjs +1482 -0
  32. package/dist-boot/c-4WVR32AP.mjs +2579 -0
  33. package/dist-boot/c-5EMM567G.mjs +152 -0
  34. package/dist-boot/c-5FA4CV63.mjs +145 -0
  35. package/dist-boot/c-5GV3X3RB.mjs +14 -0
  36. package/dist-boot/c-5JCEPRIY.mjs +52 -0
  37. package/dist-boot/c-5NDKIIWT.mjs +16 -0
  38. package/dist-boot/c-5QL3AR26.mjs +4665 -0
  39. package/dist-boot/c-5XY6MFKN.mjs +5142 -0
  40. package/dist-boot/c-65UZIZC7.mjs +2897 -0
  41. package/dist-boot/c-6FUXKHOK.mjs +1969 -0
  42. package/dist-boot/c-6JHWQE4V.mjs +18242 -0
  43. package/dist-boot/c-6LOBR4I6.mjs +5280 -0
  44. package/dist-boot/c-6QHOZXKQ.mjs +14394 -0
  45. package/dist-boot/c-6ZO2SADQ.mjs +178 -0
  46. package/dist-boot/c-6ZORVVZP.mjs +1449 -0
  47. package/dist-boot/c-76QH4UCP.mjs +2441 -0
  48. package/dist-boot/c-77GO5L5Y.mjs +20982 -0
  49. package/dist-boot/c-7M23XFTN.mjs +5052 -0
  50. package/dist-boot/c-7TC367E2.mjs +32 -0
  51. package/dist-boot/c-7UOG7POX.mjs +1524 -0
  52. package/dist-boot/c-7VHP3FLN.mjs +376 -0
  53. package/dist-boot/c-A73JHZP2.mjs +13207 -0
  54. package/dist-boot/c-ABXULAFL.mjs +71 -0
  55. package/dist-boot/c-ANDD2AQO.mjs +74 -0
  56. package/dist-boot/c-AOY77AZL.mjs +1430 -0
  57. package/dist-boot/c-AXEPZ22I.mjs +108 -0
  58. package/dist-boot/c-B2Y7VNHU.mjs +427 -0
  59. package/dist-boot/c-B7VJUH73.mjs +77 -0
  60. package/dist-boot/c-BFW6CDVL.mjs +24 -0
  61. package/dist-boot/c-BHNIF2AR.mjs +188 -0
  62. package/dist-boot/c-BKF2O6BL.mjs +23 -0
  63. package/dist-boot/c-BOZXFTZN.mjs +8 -0
  64. package/dist-boot/c-BRNYJWZL.mjs +28 -0
  65. package/dist-boot/c-C3N4Z2HO.mjs +93 -0
  66. package/dist-boot/c-C4IV7ZFG.mjs +717 -0
  67. package/dist-boot/c-C5NK6UYV.mjs +793 -0
  68. package/dist-boot/c-C67644MB.mjs +1659 -0
  69. package/dist-boot/c-C6S2YB53.mjs +620 -0
  70. package/dist-boot/c-CDBEJSBF.mjs +37 -0
  71. package/dist-boot/c-CG47HBKU.mjs +435 -0
  72. package/dist-boot/c-CKCTWCT5.mjs +51 -0
  73. package/dist-boot/c-CN77DCGF.mjs +60 -0
  74. package/dist-boot/c-CRBXNKFO.mjs +1795 -0
  75. package/dist-boot/c-CRIHASQ6.mjs +973 -0
  76. package/dist-boot/c-CU4NGAUO.mjs +3786 -0
  77. package/dist-boot/c-CWRFLGQU.mjs +1883 -0
  78. package/dist-boot/c-CYQB2USO.mjs +32 -0
  79. package/dist-boot/c-DEE67DJO.mjs +379 -0
  80. package/dist-boot/c-DIFDBYOP.mjs +1258 -0
  81. package/dist-boot/c-DOSGVXDZ.mjs +34879 -0
  82. package/dist-boot/c-DR7XQI32.mjs +381 -0
  83. package/dist-boot/c-DTGPSB46.mjs +14666 -0
  84. package/dist-boot/c-DTHDNA4P.mjs +320 -0
  85. package/dist-boot/c-E4Z3Y5B5.mjs +3864 -0
  86. package/dist-boot/c-E66Z2TI7.mjs +203 -0
  87. package/dist-boot/c-EBU6RLRV.mjs +1527 -0
  88. package/dist-boot/c-EBZZNGSF.mjs +432 -0
  89. package/dist-boot/c-EC3LJ2KF.mjs +1032 -0
  90. package/dist-boot/c-EQBKXWNX.mjs +15829 -0
  91. package/dist-boot/c-EUEPIW4S.mjs +574 -0
  92. package/dist-boot/c-EX4YVWAT.mjs +378 -0
  93. package/dist-boot/c-EYZGSAJU.mjs +98 -0
  94. package/dist-boot/c-F75VRKY4.mjs +172 -0
  95. package/dist-boot/c-FH4NXKHV.mjs +177 -0
  96. package/dist-boot/c-FHNUCTEM.mjs +140 -0
  97. package/dist-boot/c-FJ5T42DS.mjs +5349 -0
  98. package/dist-boot/c-FPCNRL7G.mjs +1728 -0
  99. package/dist-boot/c-G4DLN7Q4.mjs +8 -0
  100. package/dist-boot/c-G56GYQFZ.mjs +2507 -0
  101. package/dist-boot/c-GLIOERDQ.mjs +1200 -0
  102. package/dist-boot/c-GMJ5HUBM.mjs +14 -0
  103. package/dist-boot/c-H3HSGMAQ.mjs +461 -0
  104. package/dist-boot/c-HIKTO6P7.mjs +275 -0
  105. package/dist-boot/c-I2MCJ34O.mjs +464 -0
  106. package/dist-boot/c-I3C6LBW4.mjs +765 -0
  107. package/dist-boot/c-I54OKQHW.mjs +387 -0
  108. package/dist-boot/c-IFSP3R4D.mjs +80 -0
  109. package/dist-boot/c-IZK77VB7.mjs +171 -0
  110. package/dist-boot/c-J3Y25UGE.mjs +54 -0
  111. package/dist-boot/c-J5IESS7W.mjs +27750 -0
  112. package/dist-boot/c-JJWZBY7L.mjs +254 -0
  113. package/dist-boot/c-JKTFXTGF.mjs +463 -0
  114. package/dist-boot/c-JN57AXQ4.mjs +77 -0
  115. package/dist-boot/c-KFIO6LUW.mjs +1096 -0
  116. package/dist-boot/c-KIEMEFWW.mjs +478 -0
  117. package/dist-boot/c-KIVXWBYD.mjs +28 -0
  118. package/dist-boot/c-KP6CRIP4.mjs +580 -0
  119. package/dist-boot/c-L26VOJX4.mjs +11558 -0
  120. package/dist-boot/c-L5GHWG5G.mjs +5988 -0
  121. package/dist-boot/c-M7NSQAKK.mjs +353 -0
  122. package/dist-boot/c-MCEWOPBW.mjs +56 -0
  123. package/dist-boot/c-MGPIEG7I.mjs +20 -0
  124. package/dist-boot/c-NREXJV3M.mjs +393 -0
  125. package/dist-boot/c-O5PP6CTX.mjs +162 -0
  126. package/dist-boot/c-OBQDHSXM.mjs +1774 -0
  127. package/dist-boot/c-OLQHHDD4.mjs +21 -0
  128. package/dist-boot/c-OXW4JQQH.mjs +319 -0
  129. package/dist-boot/c-P3D7ZUWN.mjs +1288 -0
  130. package/dist-boot/c-P4PQZVV5.mjs +948 -0
  131. package/dist-boot/c-P63T3XL2.mjs +26373 -0
  132. package/dist-boot/c-P6N5DQGZ.mjs +194 -0
  133. package/dist-boot/c-P7MLKQFC.mjs +58 -0
  134. package/dist-boot/c-PB3PZJL5.mjs +1276 -0
  135. package/dist-boot/c-PTN4S6G2.mjs +1259 -0
  136. package/dist-boot/c-PYCE5J7U.mjs +1083 -0
  137. package/dist-boot/c-Q4HYCRLB.mjs +19410 -0
  138. package/dist-boot/c-QUXMETGG.mjs +68 -0
  139. package/dist-boot/c-RDMJZCOX.mjs +356 -0
  140. package/dist-boot/c-ROGJK76M.mjs +17 -0
  141. package/dist-boot/c-RQJJ26T4.mjs +708 -0
  142. package/dist-boot/c-RSKCUPJF.mjs +7559 -0
  143. package/dist-boot/c-RVJU4O6P.mjs +37 -0
  144. package/dist-boot/c-S2RVHR3M.mjs +165 -0
  145. package/dist-boot/c-SKMK3PEE.mjs +91120 -0
  146. package/dist-boot/c-TI7SM4EG.mjs +20 -0
  147. package/dist-boot/c-TILJ6GXD.mjs +1235 -0
  148. package/dist-boot/c-TT6BCUJD.mjs +114 -0
  149. package/dist-boot/c-U4ITOXAN.mjs +2107 -0
  150. package/dist-boot/c-UGERXVO2.mjs +7120 -0
  151. package/dist-boot/c-UPBH5AXY.mjs +1363 -0
  152. package/dist-boot/c-US2PUNZL.mjs +597 -0
  153. package/dist-boot/c-UU4WZPPE.mjs +20 -0
  154. package/dist-boot/c-UWVIYPQS.mjs +39 -0
  155. package/dist-boot/c-V4RHQBPQ.mjs +17683 -0
  156. package/dist-boot/c-V5MRVK47.mjs +351 -0
  157. package/dist-boot/c-V6CL266R.mjs +1755 -0
  158. package/dist-boot/c-VJTMFKYE.mjs +14975 -0
  159. package/dist-boot/c-VJTRUKIB.mjs +773 -0
  160. package/dist-boot/c-W4IFSHPW.mjs +43 -0
  161. package/dist-boot/c-WETGB2CF.mjs +113 -0
  162. package/dist-boot/c-WO3QSZUU.mjs +1337 -0
  163. package/dist-boot/c-WQLH73TY.mjs +242 -0
  164. package/dist-boot/c-XL735JW5.mjs +500 -0
  165. package/dist-boot/c-Y7HADL5B.mjs +1107 -0
  166. package/dist-boot/c-YGQHSVSK.mjs +41 -0
  167. package/dist-boot/c-YMP2AMEB.mjs +10350 -0
  168. package/dist-boot/c-YRDO2WEF.mjs +12012 -0
  169. package/dist-boot/c-YUSTRATJ.mjs +8 -0
  170. package/dist-boot/c-Z2262R22.mjs +2697 -0
  171. package/dist-boot/c-Z4ALQMJC.mjs +709 -0
  172. package/dist-boot/c-Z5ZUQVUY.mjs +62 -0
  173. package/dist-boot/c-ZDZUKXF7.mjs +874 -0
  174. package/dist-boot/c-ZJYLGIC3.mjs +32 -0
  175. package/dist-boot/c-ZNA5CDMI.mjs +77 -0
  176. package/dist-boot/c-ZSO6DI3M.mjs +204 -0
  177. package/dist-boot/c-ZWUVHKMK.mjs +100 -0
  178. package/dist-boot/c-ZY4MESEW.mjs +832 -0
  179. package/dist-boot/c-ZZ5REI4L.mjs +329 -0
  180. package/dist-boot/cli.mjs +51 -0
  181. package/dist-boot/ext-anthropic-attribution.mjs +207 -0
  182. package/dist-boot/ext-pi-background-tasks.mjs +7234 -0
  183. package/dist-boot/ext-pi-subagents.mjs +37 -0
  184. package/dist-boot/ext-privateer-account.mjs +4426 -0
  185. package/dist-boot/ext-privateer-brand.mjs +5274 -0
  186. package/dist-boot/ext-privateer-codemode.mjs +37 -0
  187. package/dist-boot/ext-privateer-computer.mjs +626 -0
  188. package/dist-boot/ext-privateer-connect.mjs +1862 -0
  189. package/dist-boot/ext-privateer-context.mjs +323 -0
  190. package/dist-boot/ext-privateer-desktop.mjs +92 -0
  191. package/dist-boot/ext-privateer-final-audit.mjs +48 -0
  192. package/dist-boot/ext-privateer-fresh.mjs +81 -0
  193. package/dist-boot/ext-privateer-gate.mjs +5959 -0
  194. package/dist-boot/ext-privateer-hints.mjs +236 -0
  195. package/dist-boot/ext-privateer-media.mjs +2626 -0
  196. package/dist-boot/ext-privateer-models.mjs +3397 -0
  197. package/dist-boot/ext-privateer-posture.mjs +3006 -0
  198. package/dist-boot/ext-privateer-privacy.mjs +4578 -0
  199. package/dist-boot/ext-privateer-recovery.mjs +287 -0
  200. package/dist-boot/ext-privateer-speak.mjs +4754 -0
  201. package/dist-boot/ext-privateer-terminals.mjs +725 -0
  202. package/dist-boot/ext-privateer-tools.mjs +528 -0
  203. package/dist-boot/ext-privateer-truncation.mjs +74 -0
  204. package/dist-boot/ext-privateer-update.mjs +210 -0
  205. package/dist-boot/ext-privateer-vision.mjs +148 -0
  206. package/dist-boot/ext-privateer-web.mjs +543 -0
  207. package/dist-boot/ext-rpiv-ask-user-question.mjs +710 -0
  208. package/dist-boot/manifest.json +9 -0
  209. package/extensions/privateer-brand.ts +3 -1
  210. package/extensions/privateer-context.ts +4 -2
  211. package/extensions/privateer-final-audit.ts +17 -0
  212. package/extensions/privateer-gate.ts +55 -9
  213. package/extensions/privateer-recovery.ts +175 -0
  214. package/extensions/privateer-web.ts +4 -4
  215. package/package.json +3 -1
  216. package/patches/@earendil-works+pi-coding-agent+1.3.0.patch +199 -2
  217. package/patches/pi-background-tasks+2.6.10.patch +91 -7
  218. package/src/cli/chat.ts +7 -1
  219. package/src/config/moatManifest.json +2 -0
  220. package/src/config/whatsNew.json +4 -4
  221. package/src/context.ts +33 -5
  222. package/src/engine/finalAudit.ts +38 -0
  223. package/src/engine/stallWatchdog.ts +8 -1
  224. package/src/providers/account.ts +34 -3
  225. package/src/remote/attentionPush.ts +40 -0
  226. package/src/remote/liveTaskSession.ts +7 -1
  227. package/src/remote/relayClient.ts +38 -4
  228. package/src/remote/remoteBridge.ts +17 -0
  229. package/src/remote/transcriptSnapshot.ts +104 -0
@@ -0,0 +1,254 @@
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
+ FUSION_SOURCE_POLICY_SCHEMA_VERSION,
4
+ FusionError
5
+ } from "./c-37GM3GMU.mjs";
6
+ import {
7
+ canonicalJson
8
+ } from "./c-KIVXWBYD.mjs";
9
+ import {
10
+ isJsonObject,
11
+ parseJsonText
12
+ } from "./c-I3C6LBW4.mjs";
13
+ import {
14
+ __name
15
+ } from "./c-CN77DCGF.mjs";
16
+
17
+ // node_modules/pi-background-tasks/src/core/fusion/source-policy.ts?ext=pi-background-tasks
18
+ import { createHash } from "node:crypto";
19
+ import { constants } from "node:fs";
20
+ import { open } from "node:fs/promises";
21
+ import { isIP } from "node:net";
22
+ var SHA256_HEX = /^[0-9a-f]{64}$/;
23
+ var O_NOFOLLOW = typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
24
+ function sha256Text(value) {
25
+ return createHash("sha256").update(value, "utf8").digest("hex");
26
+ }
27
+ __name(sha256Text, "sha256Text");
28
+ function stripIpv6Brackets(hostname) {
29
+ return hostname.startsWith("[") && hostname.endsWith("]") ? hostname.slice(1, -1) : hostname;
30
+ }
31
+ __name(stripIpv6Brackets, "stripIpv6Brackets");
32
+ function isBlockedHostname(hostname) {
33
+ const lower = hostname.toLowerCase();
34
+ return lower === "localhost" || lower.endsWith(".localhost") || lower === "metadata" || lower === "metadata.local" || lower === "metadata.google.internal" || lower === "metadata.goog" || lower === "instance-data" || lower === "instance-data.ec2.internal";
35
+ }
36
+ __name(isBlockedHostname, "isBlockedHostname");
37
+ function isBlockedIpv4(host) {
38
+ const parts = host.split(".").map((part) => Number.parseInt(part, 10));
39
+ if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255))
40
+ return true;
41
+ const [a = 0, b = 0, c = 0] = parts;
42
+ if (a === 0 || a === 10 || a === 127) return true;
43
+ if (a === 100 && b >= 64 && b <= 127) return true;
44
+ if (a === 169 && b === 254) return true;
45
+ if (a === 172 && b >= 16 && b <= 31) return true;
46
+ if (a === 192 && b === 168) return true;
47
+ if (a === 192 && b === 0 && c === 0) return true;
48
+ if (a === 192 && b === 0 && c === 2) return true;
49
+ if (a === 198 && (b === 18 || b === 19)) return true;
50
+ if (a === 198 && b === 51 && c === 100) return true;
51
+ if (a === 203 && b === 0 && c === 113) return true;
52
+ if (a >= 224) return true;
53
+ return host === "255.255.255.255" || host === "168.63.129.16";
54
+ }
55
+ __name(isBlockedIpv4, "isBlockedIpv4");
56
+ function isBlockedIpv6(host) {
57
+ const lower = host.toLowerCase();
58
+ return lower === "::" || lower === "::1" || lower.startsWith("::ffff:") || lower.startsWith("64:ff9b::") || lower.startsWith("64:ff9b:1:") || lower.startsWith("100:") || lower.startsWith("2001:2:") || lower.startsWith("2001:db8:") || lower.startsWith("2002:") || lower.startsWith("fc") || lower.startsWith("fd") || lower.startsWith("fe8") || lower.startsWith("fe9") || lower.startsWith("fea") || lower.startsWith("feb") || lower.startsWith("ff");
59
+ }
60
+ __name(isBlockedIpv6, "isBlockedIpv6");
61
+ function canonicalizeFusionPublicUrl(value) {
62
+ let url;
63
+ try {
64
+ url = new URL(value);
65
+ } catch (error) {
66
+ throw new FusionError(
67
+ `fusion research declared source URL is malformed: ${error instanceof Error ? error.message : String(error)}`,
68
+ { code: "orchestration_failed", childCreated: false }
69
+ );
70
+ }
71
+ if (url.username !== "" || url.password !== "") {
72
+ throw new FusionError("fusion research source URL must not contain credentials", {
73
+ code: "orchestration_failed",
74
+ childCreated: false
75
+ });
76
+ }
77
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
78
+ throw new FusionError("fusion research source URL must use http or https", {
79
+ code: "orchestration_failed",
80
+ childCreated: false
81
+ });
82
+ }
83
+ url.username = "";
84
+ url.password = "";
85
+ url.hash = "";
86
+ const normalizedHost = stripIpv6Brackets(url.hostname.toLowerCase().replace(/\.+$/u, ""));
87
+ url.hostname = normalizedHost;
88
+ if (isBlockedHostname(normalizedHost)) {
89
+ throw new FusionError("fusion research source URL must be public, not localhost/metadata", {
90
+ code: "orchestration_failed",
91
+ childCreated: false
92
+ });
93
+ }
94
+ const ipKind = isIP(normalizedHost);
95
+ if (ipKind === 4 && isBlockedIpv4(normalizedHost) || ipKind === 6 && isBlockedIpv6(normalizedHost)) {
96
+ throw new FusionError("fusion research source URL must be public, not private/reserved", {
97
+ code: "orchestration_failed",
98
+ childCreated: false
99
+ });
100
+ }
101
+ if (url.protocol === "http:" && url.port === "80" || url.protocol === "https:" && url.port === "443") {
102
+ url.port = "";
103
+ }
104
+ return url.toString();
105
+ }
106
+ __name(canonicalizeFusionPublicUrl, "canonicalizeFusionPublicUrl");
107
+ function normalizeFusionDeclaredSources(sources = []) {
108
+ const seen = /* @__PURE__ */ new Map();
109
+ return sources.map((source, index) => {
110
+ if (typeof source.url !== "string" || source.url.trim().length === 0) {
111
+ throw new FusionError(`fusion research source ${String(index)} requires non-blank URL`, {
112
+ code: "orchestration_failed",
113
+ childCreated: false
114
+ });
115
+ }
116
+ if (typeof source.purpose !== "string" || source.purpose.trim().length === 0) {
117
+ throw new FusionError(`fusion research source ${String(index)} requires non-blank purpose`, {
118
+ code: "orchestration_failed",
119
+ childCreated: false
120
+ });
121
+ }
122
+ const canonicalUrl = canonicalizeFusionPublicUrl(source.url.trim());
123
+ const previous = seen.get(canonicalUrl);
124
+ if (previous !== void 0) {
125
+ throw new FusionError(
126
+ `fusion research source ${String(index)} duplicates canonical URL from source ${String(previous)}: ${canonicalUrl}`,
127
+ { code: "orchestration_failed", childCreated: false }
128
+ );
129
+ }
130
+ seen.set(canonicalUrl, index);
131
+ const purpose = source.purpose.trim();
132
+ return {
133
+ url: canonicalUrl,
134
+ canonical_url: canonicalUrl,
135
+ purpose,
136
+ sha256: sha256Text(`${canonicalUrl}\0${purpose}`)
137
+ };
138
+ });
139
+ }
140
+ __name(normalizeFusionDeclaredSources, "normalizeFusionDeclaredSources");
141
+ function buildFusionSourcePolicy(cwd, sources) {
142
+ const body = {
143
+ schema_version: FUSION_SOURCE_POLICY_SCHEMA_VERSION,
144
+ workflow: "research",
145
+ cwd,
146
+ sources
147
+ };
148
+ return { ...body, root_sha256: sha256Text(canonicalJson(body)) };
149
+ }
150
+ __name(buildFusionSourcePolicy, "buildFusionSourcePolicy");
151
+ function sourcePolicyCanonicalBytes(policy) {
152
+ return canonicalJson(policy);
153
+ }
154
+ __name(sourcePolicyCanonicalBytes, "sourcePolicyCanonicalBytes");
155
+ function requireString(record, key, label) {
156
+ const value = record[key];
157
+ if (typeof value !== "string" || value.length === 0)
158
+ throw new Error(`${label}.${key} must be non-blank string`);
159
+ return value;
160
+ }
161
+ __name(requireString, "requireString");
162
+ function parseFusionSourcePolicy(value) {
163
+ if (!isJsonObject(value) || Array.isArray(value))
164
+ throw new Error("fusion source policy must be object");
165
+ const keys = Object.keys(value).sort();
166
+ const expected = ["cwd", "root_sha256", "schema_version", "sources", "workflow"];
167
+ if (keys.join("\0") !== expected.join("\0"))
168
+ throw new Error("fusion source policy keys mismatch");
169
+ if (value["schema_version"] !== FUSION_SOURCE_POLICY_SCHEMA_VERSION)
170
+ throw new Error("fusion source policy schema_version mismatch");
171
+ if (value["workflow"] !== "research")
172
+ throw new Error("fusion source policy workflow must be research");
173
+ const cwd = requireString(value, "cwd", "fusion source policy");
174
+ const rootSha256 = requireString(value, "root_sha256", "fusion source policy");
175
+ if (!SHA256_HEX.test(rootSha256))
176
+ throw new Error("fusion source policy.root_sha256 must be sha256");
177
+ if (!Array.isArray(value["sources"]))
178
+ throw new Error("fusion source policy.sources must be array");
179
+ const sources = value["sources"].map((item, index) => {
180
+ const label = `fusion source policy.sources[${String(index)}]`;
181
+ if (!isJsonObject(item) || Array.isArray(item)) throw new Error(`${label} must be object`);
182
+ const itemKeys = Object.keys(item).sort();
183
+ const itemExpected = ["canonical_url", "purpose", "sha256", "url"];
184
+ if (itemKeys.join("\0") !== itemExpected.join("\0")) throw new Error(`${label} keys mismatch`);
185
+ const url = requireString(item, "url", label);
186
+ const purpose = requireString(item, "purpose", label);
187
+ const canonical_url = requireString(item, "canonical_url", label);
188
+ const sha256 = requireString(item, "sha256", label);
189
+ if (!SHA256_HEX.test(sha256)) throw new Error(`${label}.sha256 must be sha256`);
190
+ if (canonicalizeFusionPublicUrl(url) !== canonical_url)
191
+ throw new Error(`${label}.canonical_url mismatch`);
192
+ if (url !== canonical_url) throw new Error(`${label}.url must equal canonical_url`);
193
+ if (purpose.trim() !== purpose) throw new Error(`${label}.purpose must be trimmed`);
194
+ if (sha256Text(`${canonical_url}\0${purpose}`) !== sha256)
195
+ throw new Error(`${label}.sha256 mismatch`);
196
+ return { url, canonical_url, purpose, sha256 };
197
+ });
198
+ const seen = /* @__PURE__ */ new Set();
199
+ for (const [index, source] of sources.entries()) {
200
+ if (seen.has(source.canonical_url)) {
201
+ throw new Error(`fusion source policy.sources[${String(index)}].canonical_url duplicate`);
202
+ }
203
+ seen.add(source.canonical_url);
204
+ }
205
+ const body = {
206
+ schema_version: FUSION_SOURCE_POLICY_SCHEMA_VERSION,
207
+ workflow: "research",
208
+ cwd,
209
+ sources
210
+ };
211
+ if (sha256Text(canonicalJson(body)) !== rootSha256)
212
+ throw new Error("fusion source policy root_sha256 mismatch");
213
+ return { ...body, root_sha256: rootSha256 };
214
+ }
215
+ __name(parseFusionSourcePolicy, "parseFusionSourcePolicy");
216
+ async function readRegularFileNoSymlink(path, label) {
217
+ let handle;
218
+ try {
219
+ handle = await open(path, constants.O_RDONLY | O_NOFOLLOW);
220
+ } catch (error) {
221
+ if (isJsonObject(error) && error["code"] === "ELOOP") {
222
+ throw new Error(`${label} at ${path} is a symlink; refusing to follow it`);
223
+ }
224
+ throw error;
225
+ }
226
+ try {
227
+ const stats = await handle.stat();
228
+ if (!stats.isFile()) throw new Error(`${label} at ${path} is not a regular file`);
229
+ return await handle.readFile();
230
+ } finally {
231
+ await handle.close();
232
+ }
233
+ }
234
+ __name(readRegularFileNoSymlink, "readRegularFileNoSymlink");
235
+ async function readFusionSourcePolicyFile(path, expectedSha256) {
236
+ if (!SHA256_HEX.test(expectedSha256))
237
+ throw new Error("fusion source policy expected hash is malformed");
238
+ const bytes = await readRegularFileNoSymlink(path, "fusion source policy");
239
+ const actual = createHash("sha256").update(bytes).digest("hex");
240
+ if (actual !== expectedSha256) throw new Error("fusion source policy artifact hash mismatch");
241
+ const text = bytes.toString("utf8");
242
+ if (!Buffer.from(text, "utf8").equals(bytes))
243
+ throw new Error("fusion source policy is not UTF-8");
244
+ return parseFusionSourcePolicy(parseJsonText(text));
245
+ }
246
+ __name(readFusionSourcePolicyFile, "readFusionSourcePolicyFile");
247
+
248
+ export {
249
+ canonicalizeFusionPublicUrl,
250
+ normalizeFusionDeclaredSources,
251
+ buildFusionSourcePolicy,
252
+ sourcePolicyCanonicalBytes,
253
+ readFusionSourcePolicyFile
254
+ };
@@ -0,0 +1,463 @@
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
+ theme
4
+ } from "./c-CRBXNKFO.mjs";
5
+ import {
6
+ __name
7
+ } from "./c-CN77DCGF.mjs";
8
+
9
+ // node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/armin.js
10
+ var ARMIN_WIDTH = 31;
11
+ var ARMIN_HEIGHT = 36;
12
+ var WIDTH = ARMIN_WIDTH;
13
+ var HEIGHT = ARMIN_HEIGHT;
14
+ var BITS = [
15
+ 255,
16
+ 255,
17
+ 255,
18
+ 127,
19
+ 255,
20
+ 240,
21
+ 255,
22
+ 127,
23
+ 255,
24
+ 237,
25
+ 255,
26
+ 127,
27
+ 255,
28
+ 219,
29
+ 255,
30
+ 127,
31
+ 255,
32
+ 183,
33
+ 255,
34
+ 127,
35
+ 255,
36
+ 119,
37
+ 254,
38
+ 127,
39
+ 63,
40
+ 248,
41
+ 254,
42
+ 127,
43
+ 223,
44
+ 255,
45
+ 254,
46
+ 127,
47
+ 223,
48
+ 63,
49
+ 252,
50
+ 127,
51
+ 159,
52
+ 195,
53
+ 251,
54
+ 127,
55
+ 111,
56
+ 252,
57
+ 244,
58
+ 127,
59
+ 247,
60
+ 15,
61
+ 247,
62
+ 127,
63
+ 247,
64
+ 255,
65
+ 247,
66
+ 127,
67
+ 247,
68
+ 255,
69
+ 227,
70
+ 127,
71
+ 247,
72
+ 7,
73
+ 232,
74
+ 127,
75
+ 239,
76
+ 248,
77
+ 103,
78
+ 112,
79
+ 15,
80
+ 255,
81
+ 187,
82
+ 111,
83
+ 241,
84
+ 0,
85
+ 208,
86
+ 91,
87
+ 253,
88
+ 63,
89
+ 236,
90
+ 83,
91
+ 193,
92
+ 255,
93
+ 239,
94
+ 87,
95
+ 159,
96
+ 253,
97
+ 238,
98
+ 95,
99
+ 159,
100
+ 252,
101
+ 174,
102
+ 95,
103
+ 31,
104
+ 120,
105
+ 172,
106
+ 95,
107
+ 63,
108
+ 0,
109
+ 80,
110
+ 108,
111
+ 127,
112
+ 0,
113
+ 220,
114
+ 119,
115
+ 255,
116
+ 192,
117
+ 63,
118
+ 120,
119
+ 255,
120
+ 1,
121
+ 248,
122
+ 127,
123
+ 255,
124
+ 3,
125
+ 156,
126
+ 120,
127
+ 255,
128
+ 7,
129
+ 140,
130
+ 124,
131
+ 255,
132
+ 15,
133
+ 206,
134
+ 120,
135
+ 255,
136
+ 255,
137
+ 207,
138
+ 127,
139
+ 255,
140
+ 255,
141
+ 207,
142
+ 120,
143
+ 255,
144
+ 255,
145
+ 223,
146
+ 120,
147
+ 255,
148
+ 255,
149
+ 223,
150
+ 125,
151
+ 255,
152
+ 255,
153
+ 63,
154
+ 126,
155
+ 255,
156
+ 255,
157
+ 255,
158
+ 127
159
+ ];
160
+ var BYTES_PER_ROW = Math.ceil(WIDTH / 8);
161
+ var DISPLAY_HEIGHT = Math.ceil(HEIGHT / 2);
162
+ var EFFECTS = ["typewriter", "scanline", "rain", "fade", "crt", "glitch", "dissolve"];
163
+ function isArminPixel(x, y) {
164
+ if (y >= HEIGHT)
165
+ return false;
166
+ const byteIndex = y * BYTES_PER_ROW + Math.floor(x / 8);
167
+ const bitIndex = x % 8;
168
+ return (BITS[byteIndex] >> bitIndex & 1) === 0;
169
+ }
170
+ __name(isArminPixel, "isArminPixel");
171
+ function getChar(x, row) {
172
+ const upper = isArminPixel(x, row * 2);
173
+ const lower = isArminPixel(x, row * 2 + 1);
174
+ if (upper && lower)
175
+ return "\u2588";
176
+ if (upper)
177
+ return "\u2580";
178
+ if (lower)
179
+ return "\u2584";
180
+ return " ";
181
+ }
182
+ __name(getChar, "getChar");
183
+ function buildFinalGrid() {
184
+ const grid = [];
185
+ for (let row = 0; row < DISPLAY_HEIGHT; row++) {
186
+ const line = [];
187
+ for (let x = 0; x < WIDTH; x++) {
188
+ line.push(getChar(x, row));
189
+ }
190
+ grid.push(line);
191
+ }
192
+ return grid;
193
+ }
194
+ __name(buildFinalGrid, "buildFinalGrid");
195
+ var ArminComponent = class {
196
+ static {
197
+ __name(this, "ArminComponent");
198
+ }
199
+ ui;
200
+ interval = null;
201
+ effect;
202
+ finalGrid;
203
+ currentGrid;
204
+ effectState = {};
205
+ cachedLines = [];
206
+ cachedWidth = 0;
207
+ gridVersion = 0;
208
+ cachedVersion = -1;
209
+ constructor(ui) {
210
+ this.ui = ui;
211
+ this.effect = EFFECTS[Math.floor(Math.random() * EFFECTS.length)];
212
+ this.finalGrid = buildFinalGrid();
213
+ this.currentGrid = this.createEmptyGrid();
214
+ this.initEffect();
215
+ this.startAnimation();
216
+ }
217
+ invalidate() {
218
+ this.cachedWidth = 0;
219
+ }
220
+ render(width) {
221
+ if (width === this.cachedWidth && this.cachedVersion === this.gridVersion) {
222
+ return this.cachedLines;
223
+ }
224
+ const padding = 1;
225
+ const availableWidth = width - padding;
226
+ this.cachedLines = this.currentGrid.map((row) => {
227
+ const clipped = row.slice(0, availableWidth).join("");
228
+ const padRight = Math.max(0, width - padding - clipped.length);
229
+ return ` ${theme.fg("accent", clipped)}${" ".repeat(padRight)}`;
230
+ });
231
+ const message = "ARMIN SAYS HI";
232
+ const msgPadRight = Math.max(0, width - padding - message.length);
233
+ this.cachedLines.push(` ${theme.fg("accent", message)}${" ".repeat(msgPadRight)}`);
234
+ this.cachedWidth = width;
235
+ this.cachedVersion = this.gridVersion;
236
+ return this.cachedLines;
237
+ }
238
+ createEmptyGrid() {
239
+ return Array.from({ length: DISPLAY_HEIGHT }, () => Array(WIDTH).fill(" "));
240
+ }
241
+ initEffect() {
242
+ switch (this.effect) {
243
+ case "typewriter":
244
+ this.effectState = { pos: 0 };
245
+ break;
246
+ case "scanline":
247
+ this.effectState = { row: 0 };
248
+ break;
249
+ case "rain":
250
+ this.effectState = {
251
+ drops: Array.from({ length: WIDTH }, () => ({
252
+ y: -Math.floor(Math.random() * DISPLAY_HEIGHT * 2),
253
+ settled: 0
254
+ }))
255
+ };
256
+ break;
257
+ case "fade": {
258
+ const positions = [];
259
+ for (let row = 0; row < DISPLAY_HEIGHT; row++) {
260
+ for (let x = 0; x < WIDTH; x++) {
261
+ positions.push([row, x]);
262
+ }
263
+ }
264
+ for (let i = positions.length - 1; i > 0; i--) {
265
+ const j = Math.floor(Math.random() * (i + 1));
266
+ [positions[i], positions[j]] = [positions[j], positions[i]];
267
+ }
268
+ this.effectState = { positions, idx: 0 };
269
+ break;
270
+ }
271
+ case "crt":
272
+ this.effectState = { expansion: 0 };
273
+ break;
274
+ case "glitch":
275
+ this.effectState = { phase: 0, glitchFrames: 8 };
276
+ break;
277
+ case "dissolve": {
278
+ this.currentGrid = Array.from({ length: DISPLAY_HEIGHT }, () => Array.from({ length: WIDTH }, () => {
279
+ const chars = [" ", "\u2591", "\u2592", "\u2593", "\u2588", "\u2580", "\u2584"];
280
+ return chars[Math.floor(Math.random() * chars.length)];
281
+ }));
282
+ const dissolvePositions = [];
283
+ for (let row = 0; row < DISPLAY_HEIGHT; row++) {
284
+ for (let x = 0; x < WIDTH; x++) {
285
+ dissolvePositions.push([row, x]);
286
+ }
287
+ }
288
+ for (let i = dissolvePositions.length - 1; i > 0; i--) {
289
+ const j = Math.floor(Math.random() * (i + 1));
290
+ [dissolvePositions[i], dissolvePositions[j]] = [dissolvePositions[j], dissolvePositions[i]];
291
+ }
292
+ this.effectState = { positions: dissolvePositions, idx: 0 };
293
+ break;
294
+ }
295
+ }
296
+ }
297
+ startAnimation() {
298
+ const fps = this.effect === "glitch" ? 60 : 30;
299
+ this.interval = setInterval(() => {
300
+ const done = this.tickEffect();
301
+ this.updateDisplay();
302
+ this.ui.requestRender();
303
+ if (done) {
304
+ this.stopAnimation();
305
+ }
306
+ }, 1e3 / fps);
307
+ }
308
+ stopAnimation() {
309
+ if (this.interval) {
310
+ clearInterval(this.interval);
311
+ this.interval = null;
312
+ }
313
+ }
314
+ tickEffect() {
315
+ switch (this.effect) {
316
+ case "typewriter":
317
+ return this.tickTypewriter();
318
+ case "scanline":
319
+ return this.tickScanline();
320
+ case "rain":
321
+ return this.tickRain();
322
+ case "fade":
323
+ return this.tickFade();
324
+ case "crt":
325
+ return this.tickCrt();
326
+ case "glitch":
327
+ return this.tickGlitch();
328
+ case "dissolve":
329
+ return this.tickDissolve();
330
+ default:
331
+ return true;
332
+ }
333
+ }
334
+ tickTypewriter() {
335
+ const state = this.effectState;
336
+ const pixelsPerFrame = 3;
337
+ for (let i = 0; i < pixelsPerFrame; i++) {
338
+ const row = Math.floor(state.pos / WIDTH);
339
+ const x = state.pos % WIDTH;
340
+ if (row >= DISPLAY_HEIGHT)
341
+ return true;
342
+ this.currentGrid[row][x] = this.finalGrid[row][x];
343
+ state.pos++;
344
+ }
345
+ return false;
346
+ }
347
+ tickScanline() {
348
+ const state = this.effectState;
349
+ if (state.row >= DISPLAY_HEIGHT)
350
+ return true;
351
+ for (let x = 0; x < WIDTH; x++) {
352
+ this.currentGrid[state.row][x] = this.finalGrid[state.row][x];
353
+ }
354
+ state.row++;
355
+ return false;
356
+ }
357
+ tickRain() {
358
+ const state = this.effectState;
359
+ let allSettled = true;
360
+ this.currentGrid = this.createEmptyGrid();
361
+ for (let x = 0; x < WIDTH; x++) {
362
+ const drop = state.drops[x];
363
+ for (let row = DISPLAY_HEIGHT - 1; row >= DISPLAY_HEIGHT - drop.settled; row--) {
364
+ if (row >= 0) {
365
+ this.currentGrid[row][x] = this.finalGrid[row][x];
366
+ }
367
+ }
368
+ if (drop.settled >= DISPLAY_HEIGHT)
369
+ continue;
370
+ allSettled = false;
371
+ let targetRow = -1;
372
+ for (let row = DISPLAY_HEIGHT - 1 - drop.settled; row >= 0; row--) {
373
+ if (this.finalGrid[row][x] !== " ") {
374
+ targetRow = row;
375
+ break;
376
+ }
377
+ }
378
+ drop.y++;
379
+ if (drop.y >= 0 && drop.y < DISPLAY_HEIGHT) {
380
+ if (targetRow >= 0 && drop.y >= targetRow) {
381
+ drop.settled = DISPLAY_HEIGHT - targetRow;
382
+ drop.y = -Math.floor(Math.random() * 5) - 1;
383
+ } else {
384
+ this.currentGrid[drop.y][x] = "\u2593";
385
+ }
386
+ }
387
+ }
388
+ return allSettled;
389
+ }
390
+ tickFade() {
391
+ const state = this.effectState;
392
+ const pixelsPerFrame = 15;
393
+ for (let i = 0; i < pixelsPerFrame; i++) {
394
+ if (state.idx >= state.positions.length)
395
+ return true;
396
+ const [row, x] = state.positions[state.idx];
397
+ this.currentGrid[row][x] = this.finalGrid[row][x];
398
+ state.idx++;
399
+ }
400
+ return false;
401
+ }
402
+ tickCrt() {
403
+ const state = this.effectState;
404
+ const midRow = Math.floor(DISPLAY_HEIGHT / 2);
405
+ this.currentGrid = this.createEmptyGrid();
406
+ const top = midRow - state.expansion;
407
+ const bottom = midRow + state.expansion;
408
+ for (let row = Math.max(0, top); row <= Math.min(DISPLAY_HEIGHT - 1, bottom); row++) {
409
+ for (let x = 0; x < WIDTH; x++) {
410
+ this.currentGrid[row][x] = this.finalGrid[row][x];
411
+ }
412
+ }
413
+ state.expansion++;
414
+ return state.expansion > DISPLAY_HEIGHT;
415
+ }
416
+ tickGlitch() {
417
+ const state = this.effectState;
418
+ if (state.phase < state.glitchFrames) {
419
+ this.currentGrid = this.finalGrid.map((row) => {
420
+ const offset = Math.floor(Math.random() * 7) - 3;
421
+ const glitchRow = [...row];
422
+ if (Math.random() < 0.3) {
423
+ const shifted = glitchRow.slice(offset).concat(glitchRow.slice(0, offset));
424
+ return shifted.slice(0, WIDTH);
425
+ }
426
+ if (Math.random() < 0.2) {
427
+ const swapRow = Math.floor(Math.random() * DISPLAY_HEIGHT);
428
+ return [...this.finalGrid[swapRow]];
429
+ }
430
+ return glitchRow;
431
+ });
432
+ state.phase++;
433
+ return false;
434
+ }
435
+ this.currentGrid = this.finalGrid.map((row) => [...row]);
436
+ return true;
437
+ }
438
+ tickDissolve() {
439
+ const state = this.effectState;
440
+ const pixelsPerFrame = 20;
441
+ for (let i = 0; i < pixelsPerFrame; i++) {
442
+ if (state.idx >= state.positions.length)
443
+ return true;
444
+ const [row, x] = state.positions[state.idx];
445
+ this.currentGrid[row][x] = this.finalGrid[row][x];
446
+ state.idx++;
447
+ }
448
+ return false;
449
+ }
450
+ updateDisplay() {
451
+ this.gridVersion++;
452
+ }
453
+ dispose() {
454
+ this.stopAnimation();
455
+ }
456
+ };
457
+
458
+ export {
459
+ ARMIN_WIDTH,
460
+ ARMIN_HEIGHT,
461
+ isArminPixel,
462
+ ArminComponent
463
+ };