@asterxsk/kiln 0.1.0

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 (263) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +170 -0
  3. package/agent/AGENTS.md +67 -0
  4. package/agent/README.md +5 -0
  5. package/agent/extensions/AGENTS.md +68 -0
  6. package/agent/extensions/ask-user/index.ts +418 -0
  7. package/agent/extensions/ask-user/install.ps1 +23 -0
  8. package/agent/extensions/ask-user/install.sh +21 -0
  9. package/agent/extensions/ask-user/package-lock.json +769 -0
  10. package/agent/extensions/ask-user/package.json +19 -0
  11. package/agent/extensions/ask-user/prompt.ts +45 -0
  12. package/agent/extensions/ask-user/tsconfig.json +7 -0
  13. package/agent/extensions/background-terminals/docs/implementation-guide.md +942 -0
  14. package/agent/extensions/background-terminals/index.ts +627 -0
  15. package/agent/extensions/background-terminals/install.ps1 +23 -0
  16. package/agent/extensions/background-terminals/install.sh +21 -0
  17. package/agent/extensions/background-terminals/manager.test.ts +735 -0
  18. package/agent/extensions/background-terminals/output.test.ts +109 -0
  19. package/agent/extensions/background-terminals/package-lock.json +769 -0
  20. package/agent/extensions/background-terminals/package.json +17 -0
  21. package/agent/extensions/background-terminals/prompt.test.ts +125 -0
  22. package/agent/extensions/background-terminals/ps.test.ts +82 -0
  23. package/agent/extensions/background-terminals/result-delivery.test.ts +44 -0
  24. package/agent/extensions/background-terminals/src/domain.ts +87 -0
  25. package/agent/extensions/background-terminals/src/manager.ts +907 -0
  26. package/agent/extensions/background-terminals/src/output.ts +84 -0
  27. package/agent/extensions/background-terminals/src/prompt.ts +142 -0
  28. package/agent/extensions/background-terminals/src/result-delivery.ts +27 -0
  29. package/agent/extensions/background-terminals/src/runtime.ts +36 -0
  30. package/agent/extensions/background-terminals/src/ui/output-view.ts +79 -0
  31. package/agent/extensions/background-terminals/src/ui/ps.ts +621 -0
  32. package/agent/extensions/background-terminals/tsconfig.json +7 -0
  33. package/agent/extensions/destructive/README.md +31 -0
  34. package/agent/extensions/destructive/index.ts +88 -0
  35. package/agent/extensions/destructive/install.ps1 +23 -0
  36. package/agent/extensions/destructive/install.sh +21 -0
  37. package/agent/extensions/file-search/index.spec.ts +443 -0
  38. package/agent/extensions/file-search/index.ts +459 -0
  39. package/agent/extensions/file-search/install.ps1 +23 -0
  40. package/agent/extensions/file-search/install.sh +21 -0
  41. package/agent/extensions/file-search/package-lock.json +2253 -0
  42. package/agent/extensions/file-search/package.json +23 -0
  43. package/agent/extensions/file-search/src/args.ts +122 -0
  44. package/agent/extensions/file-search/src/binaries.ts +422 -0
  45. package/agent/extensions/file-search/src/output.ts +126 -0
  46. package/agent/extensions/file-search/src/process.ts +146 -0
  47. package/agent/extensions/file-search/src/prompt.ts +52 -0
  48. package/agent/extensions/file-search/tsconfig.json +7 -0
  49. package/agent/extensions/goal/README.md +50 -0
  50. package/agent/extensions/goal/index.ts +155 -0
  51. package/agent/extensions/goal/install.ps1 +23 -0
  52. package/agent/extensions/goal/install.sh +21 -0
  53. package/agent/extensions/modelconf/PLAN.md +915 -0
  54. package/agent/extensions/modelconf/README.md +66 -0
  55. package/agent/extensions/modelconf/index.ts +296 -0
  56. package/agent/extensions/modelconf/install.ps1 +23 -0
  57. package/agent/extensions/modelconf/install.sh +21 -0
  58. package/agent/extensions/modelconf/package-lock.json +1809 -0
  59. package/agent/extensions/modelconf/package.json +13 -0
  60. package/agent/extensions/modelconf/src/fuzzy.ts +26 -0
  61. package/agent/extensions/modelconf/src/glob.ts +13 -0
  62. package/agent/extensions/modelconf/src/persistence.test.ts +46 -0
  63. package/agent/extensions/modelconf/src/persistence.ts +164 -0
  64. package/agent/extensions/modelconf/src/ui/ModelConfView.test.ts +75 -0
  65. package/agent/extensions/modelconf/src/ui/ModelConfView.ts +1101 -0
  66. package/agent/extensions/modelconf/tsconfig.json +15 -0
  67. package/agent/extensions/pi-web-access/CHANGELOG.md +690 -0
  68. package/agent/extensions/pi-web-access/LICENSE +21 -0
  69. package/agent/extensions/pi-web-access/README.md +470 -0
  70. package/agent/extensions/pi-web-access/SECURITY.md +5 -0
  71. package/agent/extensions/pi-web-access/activity.ts +101 -0
  72. package/agent/extensions/pi-web-access/auth-fetch.ts +148 -0
  73. package/agent/extensions/pi-web-access/banner.png +0 -0
  74. package/agent/extensions/pi-web-access/brightdata-unlocker.ts +272 -0
  75. package/agent/extensions/pi-web-access/chrome-cookies.ts +669 -0
  76. package/agent/extensions/pi-web-access/content-find.ts +139 -0
  77. package/agent/extensions/pi-web-access/credential-source.ts +191 -0
  78. package/agent/extensions/pi-web-access/data-uri-sanitize.ts +406 -0
  79. package/agent/extensions/pi-web-access/datalab-pdf-extract.ts +568 -0
  80. package/agent/extensions/pi-web-access/declared-web-links.ts +173 -0
  81. package/agent/extensions/pi-web-access/evidence/CONTRACT-EVIDENCE.md +496 -0
  82. package/agent/extensions/pi-web-access/evidence/contract-probe.mjs +140 -0
  83. package/agent/extensions/pi-web-access/exa.ts +526 -0
  84. package/agent/extensions/pi-web-access/extract.ts +1196 -0
  85. package/agent/extensions/pi-web-access/feature-config.ts +29 -0
  86. package/agent/extensions/pi-web-access/fetch-params.ts +111 -0
  87. package/agent/extensions/pi-web-access/gemini-adc.ts +298 -0
  88. package/agent/extensions/pi-web-access/gemini-api.ts +353 -0
  89. package/agent/extensions/pi-web-access/gemini-pdf-extract.ts +108 -0
  90. package/agent/extensions/pi-web-access/gemini-search.ts +21 -0
  91. package/agent/extensions/pi-web-access/gemini-url-context.ts +128 -0
  92. package/agent/extensions/pi-web-access/gemini-web-config.ts +101 -0
  93. package/agent/extensions/pi-web-access/gemini-web.ts +487 -0
  94. package/agent/extensions/pi-web-access/github-api.ts +197 -0
  95. package/agent/extensions/pi-web-access/github-extract.ts +746 -0
  96. package/agent/extensions/pi-web-access/github-issue-pr.ts +700 -0
  97. package/agent/extensions/pi-web-access/index.ts +1737 -0
  98. package/agent/extensions/pi-web-access/package-lock.json +5808 -0
  99. package/agent/extensions/pi-web-access/package.json +64 -0
  100. package/agent/extensions/pi-web-access/page-query.ts +96 -0
  101. package/agent/extensions/pi-web-access/pdf-extract.ts +409 -0
  102. package/agent/extensions/pi-web-access/pi-web-fetch-demo.mp4 +0 -0
  103. package/agent/extensions/pi-web-access/promise-try.d.ts +7 -0
  104. package/agent/extensions/pi-web-access/query-rewrite.ts +51 -0
  105. package/agent/extensions/pi-web-access/render-search-error.ts +170 -0
  106. package/agent/extensions/pi-web-access/rsc-extract.ts +338 -0
  107. package/agent/extensions/pi-web-access/search-types.ts +20 -0
  108. package/agent/extensions/pi-web-access/source-check.ts +282 -0
  109. package/agent/extensions/pi-web-access/ssrf-protection.ts +526 -0
  110. package/agent/extensions/pi-web-access/storage.ts +521 -0
  111. package/agent/extensions/pi-web-access/summary-model-scope.ts +125 -0
  112. package/agent/extensions/pi-web-access/test/auth-fetch.test.mjs +208 -0
  113. package/agent/extensions/pi-web-access/test/brightdata-unlocker.test.mjs +840 -0
  114. package/agent/extensions/pi-web-access/test/chrome-cookie-extraction.test.mjs +441 -0
  115. package/agent/extensions/pi-web-access/test/config-path.test.mjs +283 -0
  116. package/agent/extensions/pi-web-access/test/content-find.test.mjs +25 -0
  117. package/agent/extensions/pi-web-access/test/credential-source.test.mjs +118 -0
  118. package/agent/extensions/pi-web-access/test/data-uri-sanitize.test.mjs +210 -0
  119. package/agent/extensions/pi-web-access/test/datalab-pdf-extract.test.mjs +552 -0
  120. package/agent/extensions/pi-web-access/test/declared-web-links.test.mjs +212 -0
  121. package/agent/extensions/pi-web-access/test/fetch-answer-storage.test.mjs +40 -0
  122. package/agent/extensions/pi-web-access/test/fetch-cache-storage.test.mjs +334 -0
  123. package/agent/extensions/pi-web-access/test/fetch-content-domain-policy.test.mjs +95 -0
  124. package/agent/extensions/pi-web-access/test/fetch-modes.test.mjs +53 -0
  125. package/agent/extensions/pi-web-access/test/fetch-not-found-guidance.test.mjs +92 -0
  126. package/agent/extensions/pi-web-access/test/fetch-params.test.mjs +86 -0
  127. package/agent/extensions/pi-web-access/test/fetch-render-call.test.mjs +34 -0
  128. package/agent/extensions/pi-web-access/test/fetch-routing.test.mjs +173 -0
  129. package/agent/extensions/pi-web-access/test/gemini-adc-auth.test.mjs +257 -0
  130. package/agent/extensions/pi-web-access/test/gemini-api-transport.test.mjs +170 -0
  131. package/agent/extensions/pi-web-access/test/gemini-pdf-extract.test.mjs +133 -0
  132. package/agent/extensions/pi-web-access/test/gemini-web-cookie-opt-in.test.mjs +178 -0
  133. package/agent/extensions/pi-web-access/test/gemini-web-header-overflow.test.mjs +148 -0
  134. package/agent/extensions/pi-web-access/test/get-search-content.test.mjs +223 -0
  135. package/agent/extensions/pi-web-access/test/github-extract.test.mjs +378 -0
  136. package/agent/extensions/pi-web-access/test/github-issue-pr.test.mjs +565 -0
  137. package/agent/extensions/pi-web-access/test/inline-content-config.test.mjs +99 -0
  138. package/agent/extensions/pi-web-access/test/lazy-extract-load.test.mjs +118 -0
  139. package/agent/extensions/pi-web-access/test/local-video-oversize.test.mjs +52 -0
  140. package/agent/extensions/pi-web-access/test/package-typebox-dependency.test.mjs +50 -0
  141. package/agent/extensions/pi-web-access/test/page-query.test.mjs +51 -0
  142. package/agent/extensions/pi-web-access/test/pdf-config.test.mjs +140 -0
  143. package/agent/extensions/pi-web-access/test/pdf-extract.test.mjs +500 -0
  144. package/agent/extensions/pi-web-access/test/proxy-transport.test.mjs +286 -0
  145. package/agent/extensions/pi-web-access/test/query-rewrite.test.mjs +52 -0
  146. package/agent/extensions/pi-web-access/test/rsc-fallback.test.mjs +102 -0
  147. package/agent/extensions/pi-web-access/test/search-error-render.test.mjs +152 -0
  148. package/agent/extensions/pi-web-access/test/search-providers.test.mjs +274 -0
  149. package/agent/extensions/pi-web-access/test/source-check.test.mjs +179 -0
  150. package/agent/extensions/pi-web-access/test/ssrf-allow-ranges-config.test.mjs +205 -0
  151. package/agent/extensions/pi-web-access/test/ssrf-protection.test.mjs +456 -0
  152. package/agent/extensions/pi-web-access/test/summary-model-scope.test.mjs +106 -0
  153. package/agent/extensions/pi-web-access/test/tool-registration-config.test.mjs +182 -0
  154. package/agent/extensions/pi-web-access/test/web-search-answer-render.test.mjs +66 -0
  155. package/agent/extensions/pi-web-access/test/youtube-extract-errors.test.mjs +64 -0
  156. package/agent/extensions/pi-web-access/tsconfig.json +11 -0
  157. package/agent/extensions/pi-web-access/utils.ts +451 -0
  158. package/agent/extensions/pi-web-access/video-extract.ts +392 -0
  159. package/agent/extensions/pi-web-access/youtube-extract.ts +328 -0
  160. package/agent/extensions/shared/activity-status.ts +31 -0
  161. package/agent/extensions/shared/child-session.test.ts +270 -0
  162. package/agent/extensions/shared/child-session.ts +148 -0
  163. package/agent/extensions/shared/context-utilization.test.ts +48 -0
  164. package/agent/extensions/shared/context-utilization.ts +47 -0
  165. package/agent/extensions/shared/dashboard-state.ts +99 -0
  166. package/agent/extensions/shared/install.ps1 +23 -0
  167. package/agent/extensions/shared/install.sh +21 -0
  168. package/agent/extensions/shared/tool-call-timeout.test.ts +117 -0
  169. package/agent/extensions/shared/tool-call-timeout.ts +104 -0
  170. package/agent/extensions/skillsconf/README.md +74 -0
  171. package/agent/extensions/skillsconf/index.ts +92 -0
  172. package/agent/extensions/skillsconf/install.ps1 +23 -0
  173. package/agent/extensions/skillsconf/install.sh +21 -0
  174. package/agent/extensions/skillsconf/package-lock.json +1809 -0
  175. package/agent/extensions/skillsconf/package.json +18 -0
  176. package/agent/extensions/skillsconf/src/delete-skill.test.ts +64 -0
  177. package/agent/extensions/skillsconf/src/delete-skill.ts +45 -0
  178. package/agent/extensions/skillsconf/src/filter.test.ts +80 -0
  179. package/agent/extensions/skillsconf/src/filter.ts +74 -0
  180. package/agent/extensions/skillsconf/src/fuzzy.ts +26 -0
  181. package/agent/extensions/skillsconf/src/persistence.test.ts +72 -0
  182. package/agent/extensions/skillsconf/src/persistence.ts +169 -0
  183. package/agent/extensions/skillsconf/src/ui/SkillConfView.test.ts +337 -0
  184. package/agent/extensions/skillsconf/src/ui/SkillConfView.ts +758 -0
  185. package/agent/extensions/skillsconf/src/ui/text-input.ts +91 -0
  186. package/agent/extensions/skillsconf/src/ui/tui-helpers.ts +144 -0
  187. package/agent/extensions/skillsconf/tsconfig.json +15 -0
  188. package/agent/extensions/status line/index.ts +282 -0
  189. package/agent/extensions/status line/install.ps1 +23 -0
  190. package/agent/extensions/status line/install.sh +21 -0
  191. package/agent/extensions/subagents/by-the-way.test.ts +29 -0
  192. package/agent/extensions/subagents/claude.test.ts +119 -0
  193. package/agent/extensions/subagents/codex.test.ts +102 -0
  194. package/agent/extensions/subagents/context-usage.test.ts +107 -0
  195. package/agent/extensions/subagents/docs/design-plan.md +568 -0
  196. package/agent/extensions/subagents/docs/effect-v4-extension-guide.md +354 -0
  197. package/agent/extensions/subagents/docs/effect-v4-notes.md +571 -0
  198. package/agent/extensions/subagents/index.ts +779 -0
  199. package/agent/extensions/subagents/install.ps1 +23 -0
  200. package/agent/extensions/subagents/install.sh +21 -0
  201. package/agent/extensions/subagents/manager.test.ts +276 -0
  202. package/agent/extensions/subagents/package-lock.json +2244 -0
  203. package/agent/extensions/subagents/package.json +19 -0
  204. package/agent/extensions/subagents/result-delivery.test.ts +27 -0
  205. package/agent/extensions/subagents/src/backend.ts +73 -0
  206. package/agent/extensions/subagents/src/backends/claude.ts +701 -0
  207. package/agent/extensions/subagents/src/backends/codex.ts +1060 -0
  208. package/agent/extensions/subagents/src/backends/pi.ts +575 -0
  209. package/agent/extensions/subagents/src/backends/stub.ts +300 -0
  210. package/agent/extensions/subagents/src/by-the-way.ts +21 -0
  211. package/agent/extensions/subagents/src/domain.ts +253 -0
  212. package/agent/extensions/subagents/src/format.ts +74 -0
  213. package/agent/extensions/subagents/src/manager.ts +736 -0
  214. package/agent/extensions/subagents/src/prompt.ts +92 -0
  215. package/agent/extensions/subagents/src/result-delivery.ts +20 -0
  216. package/agent/extensions/subagents/src/runtime.ts +53 -0
  217. package/agent/extensions/subagents/src/ui/takeover.ts +583 -0
  218. package/agent/extensions/subagents/src/ui/transcript.ts +201 -0
  219. package/agent/extensions/subagents/takeover.test.ts +29 -0
  220. package/agent/extensions/subagents/tsconfig.json +7 -0
  221. package/agent/extensions/taste/index.ts +443 -0
  222. package/agent/extensions/taste/install.ps1 +23 -0
  223. package/agent/extensions/taste/install.sh +21 -0
  224. package/agent/extensions/todo/AGENTS.md +38 -0
  225. package/agent/extensions/todo/LICENSE +21 -0
  226. package/agent/extensions/todo/config.ts +55 -0
  227. package/agent/extensions/todo/index.ts +151 -0
  228. package/agent/extensions/todo/install.ps1 +23 -0
  229. package/agent/extensions/todo/install.sh +21 -0
  230. package/agent/extensions/todo/locales/de.json +17 -0
  231. package/agent/extensions/todo/locales/en.json +15 -0
  232. package/agent/extensions/todo/locales/es.json +17 -0
  233. package/agent/extensions/todo/locales/fr.json +17 -0
  234. package/agent/extensions/todo/locales/pt-BR.json +17 -0
  235. package/agent/extensions/todo/locales/pt.json +17 -0
  236. package/agent/extensions/todo/locales/ru.json +17 -0
  237. package/agent/extensions/todo/locales/uk.json +17 -0
  238. package/agent/extensions/todo/locales/zh.json +17 -0
  239. package/agent/extensions/todo/package-lock.json +3358 -0
  240. package/agent/extensions/todo/package.json +67 -0
  241. package/agent/extensions/todo/state/i18n-bridge.ts +64 -0
  242. package/agent/extensions/todo/state/invariants.ts +20 -0
  243. package/agent/extensions/todo/state/replay.ts +38 -0
  244. package/agent/extensions/todo/state/selectors.ts +107 -0
  245. package/agent/extensions/todo/state/state-reducer.ts +326 -0
  246. package/agent/extensions/todo/state/state.ts +18 -0
  247. package/agent/extensions/todo/state/store.ts +82 -0
  248. package/agent/extensions/todo/state/task-graph.ts +57 -0
  249. package/agent/extensions/todo/todo-overlay.ts +200 -0
  250. package/agent/extensions/todo/todo.ts +155 -0
  251. package/agent/extensions/todo/tool/response-envelope.ts +109 -0
  252. package/agent/extensions/todo/tool/types.ts +206 -0
  253. package/agent/extensions/todo/verify-ref-system.js +0 -0
  254. package/agent/extensions/todo/view/format.ts +177 -0
  255. package/agent/extensions/trim-context/README.md +54 -0
  256. package/agent/extensions/trim-context/index.ts +487 -0
  257. package/agent/extensions/trim-context/install.ps1 +23 -0
  258. package/agent/extensions/trim-context/install.sh +21 -0
  259. package/agent/install.ps1 +527 -0
  260. package/agent/install.sh +511 -0
  261. package/agent/keybindings.json +7 -0
  262. package/bin/kiln.js +359 -0
  263. package/package.json +21 -0
@@ -0,0 +1,441 @@
1
+ import assert from "node:assert/strict";
2
+ import { execFileSync, spawnSync } from "node:child_process";
3
+ import { createCipheriv, createHash } from "node:crypto";
4
+ import { chmodSync, existsSync, mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, symlinkSync } from "node:fs";
5
+ import { homedir, tmpdir } from "node:os";
6
+ import { dirname, join } from "node:path";
7
+ import { test } from "node:test";
8
+
9
+ const moduleUrl = new URL("../chrome-cookies.ts", import.meta.url).href;
10
+ const python = process.platform === "win32" ? null : "python3";
11
+
12
+ function createFixture(home, profile, rows = [], options = {}) {
13
+ if (!python) return;
14
+ const { browser = "Chrome", targetPlatform = process.platform } = options;
15
+ const base = targetPlatform === "darwin"
16
+ ? browser === "Brave"
17
+ ? join(home, "Library", "Application Support", "BraveSoftware", "Brave-Browser")
18
+ : browser === "Helium"
19
+ ? join(home, "Library", "Application Support", "net.imput.helium")
20
+ : browser === "Arc"
21
+ ? join(home, "Library", "Application Support", "Arc", "User Data")
22
+ : join(home, "Library", "Application Support", "Google", "Chrome")
23
+ : targetPlatform === "win32"
24
+ ? browser === "Edge"
25
+ ? join(home, "AppData", "Local", "Microsoft", "Edge", "User Data")
26
+ : join(home, "AppData", "Local", "Google", "Chrome", "User Data")
27
+ : join(home, ".config", "google-chrome");
28
+ const dbPath = targetPlatform === "win32" ? join(base, profile, "Network", "Cookies") : join(base, profile, "Cookies");
29
+ mkdirSync(dirname(dbPath), { recursive: true });
30
+ execFileSync(python, ["-c", `
31
+ import json, sqlite3, sys
32
+ c = sqlite3.connect(sys.argv[1])
33
+ c.execute("create table meta (key text, value integer)")
34
+ c.execute("insert into meta values ('version', 24)")
35
+ c.execute("create table cookies (name text, value text, host_key text, encrypted_value blob, expires_utc integer)")
36
+ for row in json.loads(sys.argv[2]):
37
+ encrypted = bytes.fromhex(row[3][4:]) if isinstance(row[3], str) and row[3].startswith('hex:') else row[3]
38
+ c.execute("insert into cookies values (?, ?, ?, ?, ?)", [row[0], row[1], row[2], encrypted, row[4]])
39
+ c.commit()
40
+ c.close()
41
+ `, dbPath, JSON.stringify(rows)], { stdio: "ignore" });
42
+ if (options.windowsKey) {
43
+ writeFileSync(join(base, "Local State"), JSON.stringify({ os_crypt: { encrypted_key: Buffer.concat([Buffer.from("DPAPI"), Buffer.from("protected")]).toString("base64") } }));
44
+ }
45
+ }
46
+
47
+ function encryptWindowsCookie(value, key, version = "v10", hostKey) {
48
+ const nonce = Buffer.alloc(12, 7);
49
+ const cipher = createCipheriv("aes-256-gcm", key, nonce);
50
+ const plaintext = hostKey ? Buffer.concat([createHash("sha256").update(hostKey).digest(), Buffer.from(value)]) : Buffer.from(value);
51
+ return Buffer.concat([Buffer.from(version), nonce, cipher.update(plaintext), cipher.final(), cipher.getAuthTag()]).toString("hex");
52
+ }
53
+
54
+ function writeWindowsDpapiCommand(bin, argsPath) {
55
+ const script = "#!/bin/sh\n[ -n \"$ARGS_FILE\" ] && printf '%s\\n' \"$@\" > \"$ARGS_FILE\"\nencoded=0\nfor arg do [ \"$arg\" = \"-EncodedCommand\" ] && encoded=1; [ \"$arg\" = \"$DPAPI_PROTECTED\" ] && exit 1; done\n[ \"$encoded\" = 1 ] || exit 1\n[ \"$PIWA_PROTECTED\" = \"$DPAPI_PROTECTED\" ] || exit 1\nprintf '%s' \"$DPAPI_KEY\"\n";
56
+ writeFileSync(join(bin, "powershell.exe"), script);
57
+ chmodSync(join(bin, "powershell.exe"), 0o755);
58
+ return argsPath ? { ARGS_FILE: argsPath } : {};
59
+ }
60
+
61
+ function makeEnvironment(home, bin, extra = {}) {
62
+ const env = {
63
+ ...process.env,
64
+ HOME: home,
65
+ USERPROFILE: home,
66
+ PI_ALLOW_BROWSER_COOKIES: "1",
67
+ PATH: `${bin}:${process.env.PATH ?? ""}`,
68
+ ...extra,
69
+ };
70
+ delete env.PI_CODING_AGENT_DIR;
71
+ delete env.XDG_CONFIG_HOME;
72
+ return env;
73
+ }
74
+
75
+ function writePasswordCommand(bin, countPath, targetPlatform = process.platform, argsPath) {
76
+ const command = targetPlatform === "darwin" ? "security" : "secret-tool";
77
+ const script = `#!/bin/sh\nn=0\n[ -f "$COUNT_FILE" ] && n=$(cat "$COUNT_FILE")\nprintf '%s' $((n + 1)) > "$COUNT_FILE"\n[ -n "$ARGS_FILE" ] && printf '%s\\n' "$@" > "$ARGS_FILE"\nprintf peanuts\n`;
78
+ writeFileSync(join(bin, command), script);
79
+ chmodSync(join(bin, command), 0o755);
80
+ return { COUNT_FILE: countPath, ...(argsPath ? { ARGS_FILE: argsPath } : {}) };
81
+ }
82
+
83
+ function writeFailThenSucceedPasswordCommand(bin, countPath) {
84
+ const command = process.platform === "darwin" ? "security" : "secret-tool";
85
+ const script = `#!/bin/sh\nn=0\n[ -f "$COUNT_FILE" ] && n=$(cat "$COUNT_FILE")\nn=$((n + 1))\nprintf '%s' $n > "$COUNT_FILE"\n[ "$n" = 1 ] && exit 1\nprintf peanuts\n`;
86
+ writeFileSync(join(bin, command), script);
87
+ chmodSync(join(bin, command), 0o755);
88
+ return { COUNT_FILE: countPath };
89
+ }
90
+
91
+ function writeFailPasswordCommand(bin, countPath, targetPlatform = process.platform) {
92
+ const command = targetPlatform === "darwin" ? "security" : "secret-tool";
93
+ const script = `#!/bin/sh\nn=0\n[ -f "$COUNT_FILE" ] && n=$(cat "$COUNT_FILE")\nprintf '%s' $((n + 1)) > "$COUNT_FILE"\nprintf 'sensitive stderr' >&2\nexit 1\n`;
94
+ writeFileSync(join(bin, command), script);
95
+ chmodSync(join(bin, command), 0o755);
96
+ return { COUNT_FILE: countPath };
97
+ }
98
+
99
+ function runCookies(home, env, options = "{ requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }", platformOverride) {
100
+ return runCookieScript(env, `const r = await m.getGoogleCookies(${options}); console.log(JSON.stringify({ result: r, diagnostic: m.getLastGoogleCookieDiagnostic(), details: m.getLastGoogleCookieDiagnosticDetails() }));`, platformOverride);
101
+ }
102
+
103
+ function runCookieScript(env, body, platformOverride) {
104
+ const override = platformOverride
105
+ ? `Object.defineProperty(process, "platform", { value: ${JSON.stringify(platformOverride)} }); `
106
+ : "";
107
+ const child = spawnSync(process.execPath, ["--experimental-strip-types", "--input-type=module"], {
108
+ encoding: "utf8",
109
+ env,
110
+ input: `${override}const m = await import(${JSON.stringify(moduleUrl)}); ${body}`,
111
+ });
112
+ assert.equal(child.status, 0, child.stderr);
113
+ return JSON.parse(child.stdout);
114
+ }
115
+
116
+ function skipWithoutPython(t) {
117
+ if (!python) t.skip("fixture creation requires Python on macOS/Linux");
118
+ }
119
+
120
+ test("cookie extraction remains opt-in even when a browser database exists", (t) => {
121
+ skipWithoutPython(t);
122
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-opt-out-"));
123
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
124
+ createFixture(home, "Default", [["__Secure-1PSID", "one", ".google.com", null, 1]]);
125
+ const env = makeEnvironment(home, bin);
126
+ delete env.PI_ALLOW_BROWSER_COOKIES;
127
+ const result = runCookies(home, env);
128
+ assert.equal(result.result, null);
129
+ assert.match(result.diagnostic, /disabled/);
130
+ rmSync(home, { recursive: true, force: true });
131
+ rmSync(bin, { recursive: true, force: true });
132
+ });
133
+
134
+ test("auto-discovery finds a non-default Chromium profile", (t) => {
135
+ skipWithoutPython(t);
136
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-profile-"));
137
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
138
+ createFixture(home, "Profile 2", [
139
+ ["__Secure-1PSID", "one", ".google.com", null, 1],
140
+ ["__Secure-1PSIDTS", "two", ".google.com", null, 2],
141
+ ]);
142
+ const env = makeEnvironment(home, bin);
143
+ Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
144
+ const result = runCookies(home, env);
145
+ assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
146
+ rmSync(home, { recursive: true, force: true });
147
+ rmSync(bin, { recursive: true, force: true });
148
+ });
149
+
150
+ test("auto-discovery finds a Brave profile on macOS", (t) => {
151
+ skipWithoutPython(t);
152
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-brave-profile-"));
153
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
154
+ createFixture(home, "Default", [
155
+ ["__Secure-1PSID", "one", ".google.com", null, 1],
156
+ ["__Secure-1PSIDTS", "two", ".google.com", null, 2],
157
+ ], { browser: "Brave", targetPlatform: "darwin" });
158
+ const env = makeEnvironment(home, bin);
159
+ const argsPath = join(home, "password-args");
160
+ Object.assign(env, writePasswordCommand(bin, join(home, "password-count"), "darwin", argsPath));
161
+ const result = runCookies(home, env, undefined, "darwin");
162
+ assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
163
+ assert.deepEqual(readFileSync(argsPath, "utf8").trim().split("\n"), [
164
+ "find-generic-password", "-w", "-a", "Brave", "-s", "Brave Safe Storage",
165
+ ]);
166
+ rmSync(home, { recursive: true, force: true });
167
+ rmSync(bin, { recursive: true, force: true });
168
+ });
169
+
170
+ test("browser selection checks only the requested preset", (t) => {
171
+ skipWithoutPython(t);
172
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-selected-browser-"));
173
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
174
+ createFixture(home, "Profile 1", [
175
+ ["__Secure-1PSID", "helium-one", ".google.com", null, 1],
176
+ ["__Secure-1PSIDTS", "helium-two", ".google.com", null, 2],
177
+ ], { browser: "Helium", targetPlatform: "darwin" });
178
+ createFixture(home, "Profile 1", [
179
+ ["__Secure-1PSID", "chrome-one", ".google.com", null, 1],
180
+ ["__Secure-1PSIDTS", "chrome-two", ".google.com", null, 2],
181
+ ], { browser: "Chrome", targetPlatform: "darwin" });
182
+ const env = makeEnvironment(home, bin);
183
+ const argsPath = join(home, "password-args");
184
+ Object.assign(env, writePasswordCommand(bin, join(home, "password-count"), "darwin", argsPath));
185
+ const result = runCookies(home, env, "{ browser: 'helium', profile: 'Profile 1', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }", "darwin");
186
+ assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "helium-two", "__Secure-1PSID": "helium-one" });
187
+ assert.deepEqual(readFileSync(argsPath, "utf8").trim().split("\n"), [
188
+ "find-generic-password", "-w", "-a", "Helium", "-s", "Helium Storage Key",
189
+ ]);
190
+ rmSync(home, { recursive: true, force: true });
191
+ rmSync(bin, { recursive: true, force: true });
192
+ });
193
+
194
+ test("Windows Chrome profiles decrypt v10 cookies with DPAPI keys", (t) => {
195
+ skipWithoutPython(t);
196
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-windows-"));
197
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
198
+ const argsPath = join(home, "powershell-args");
199
+ const key = Buffer.alloc(32, 3);
200
+ createFixture(home, "Default", [
201
+ ["__Secure-1PSID", "", ".google.com", `hex:${encryptWindowsCookie("one", key, "v10", ".google.com")}`, 1],
202
+ ["__Secure-1PSIDTS", "", ".google.com", `hex:${encryptWindowsCookie("two", key, "v10", ".google.com")}`, 2],
203
+ ], { targetPlatform: "win32", windowsKey: key });
204
+ const protectedValue = Buffer.from("protected").toString("base64");
205
+ const env = makeEnvironment(home, bin, { LOCALAPPDATA: join(home, "AppData", "Local"), DPAPI_KEY: key.toString("base64"), DPAPI_PROTECTED: protectedValue, TEMP: tmpdir(), TMP: tmpdir(), ...writeWindowsDpapiCommand(bin, argsPath) });
206
+ const result = runCookies(home, env, undefined, "win32");
207
+ assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
208
+ const args = readFileSync(argsPath, "utf8").trim().split("\n");
209
+ assert.equal(args.includes("-EncodedCommand"), true);
210
+ assert.equal(args.includes(protectedValue), false);
211
+ rmSync(home, { recursive: true, force: true });
212
+ rmSync(bin, { recursive: true, force: true });
213
+ });
214
+
215
+ test("cookie queries keep high Chromium expiry values safe", (t) => {
216
+ skipWithoutPython(t);
217
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-high-expiry-"));
218
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
219
+ createFixture(home, "Profile 2", [
220
+ ["__Secure-1PSID", "expired", ".google.com", null, 1],
221
+ ["__Secure-1PSID", "future", ".google.com", null, "9223372036854775807"],
222
+ ["__Secure-1PSIDTS", "session", ".google.com", null, 0],
223
+ ]);
224
+ const env = makeEnvironment(home, bin);
225
+ Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
226
+ const result = runCookieScript(env, "const r = await m.getBrowserCookiesForHosts({ hosts: ['www.google.com'], requestUrl: new URL('https://www.google.com/'), requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }); console.log(JSON.stringify({ result: r, diagnostic: m.getLastBrowserCookieDiagnostic() }));");
227
+ assert.deepEqual(result.result.cookies, { "__Secure-1PSID": "future", "__Secure-1PSIDTS": "session" });
228
+ rmSync(home, { recursive: true, force: true });
229
+ rmSync(bin, { recursive: true, force: true });
230
+ });
231
+
232
+ test("cookie expiry filtering preserves same-second validity", (t) => {
233
+ skipWithoutPython(t);
234
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-subsecond-expiry-"));
235
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
236
+ const nowMs = 1_700_000_000_500;
237
+ const sameSecondFutureChromeMicros = (nowMs + 400 + 11644473600000) * 1000;
238
+ createFixture(home, "Profile 2", [
239
+ ["__Secure-1PSID", "future", ".google.com", null, sameSecondFutureChromeMicros],
240
+ ["__Secure-1PSIDTS", "session", ".google.com", null, 0],
241
+ ]);
242
+ const env = makeEnvironment(home, bin);
243
+ Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
244
+ const result = runCookieScript(env, `Date.now = () => ${nowMs}; const r = await m.getBrowserCookiesForHosts({ hosts: ['www.google.com'], requestUrl: new URL('https://www.google.com/'), requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }); console.log(JSON.stringify({ result: r, diagnostic: m.getLastBrowserCookieDiagnostic() }));`);
245
+ assert.deepEqual(result.result.cookies, { "__Secure-1PSID": "future", "__Secure-1PSIDTS": "session" });
246
+ rmSync(home, { recursive: true, force: true });
247
+ rmSync(bin, { recursive: true, force: true });
248
+ });
249
+
250
+ test("Windows Edge uses the USERPROFILE AppData fallback and reports unsupported v20 cookies", (t) => {
251
+ skipWithoutPython(t);
252
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-windows-edge-"));
253
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
254
+ const key = Buffer.alloc(32, 4);
255
+ createFixture(home, "Default", [
256
+ ["__Secure-1PSID", "", ".google.com", `hex:${encryptWindowsCookie("one", key, "v20")}`, 1],
257
+ ["__Secure-1PSIDTS", "", ".google.com", `hex:${encryptWindowsCookie("two", key, "v20")}`, 2],
258
+ ], { browser: "Edge", targetPlatform: "win32", windowsKey: key });
259
+ const env = makeEnvironment(home, bin, { DPAPI_KEY: key.toString("base64"), DPAPI_PROTECTED: Buffer.from("protected").toString("base64"), TEMP: tmpdir(), TMP: tmpdir() });
260
+ delete env.LOCALAPPDATA;
261
+ writeWindowsDpapiCommand(bin);
262
+ const result = runCookies(home, env, undefined, "win32");
263
+ assert.equal(result.result, null);
264
+ assert.match(result.diagnostic, /v20 app-bound cookies are not supported/);
265
+ rmSync(home, { recursive: true, force: true });
266
+ rmSync(bin, { recursive: true, force: true });
267
+ });
268
+
269
+ test("required-cookie preflight avoids password invocation for unrelated profiles", (t) => {
270
+ skipWithoutPython(t);
271
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-preflight-"));
272
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
273
+ createFixture(home, "Profile 1", [["NID", "unrelated", ".google.com", null, 1]]);
274
+ const countPath = join(home, "password-count");
275
+ const env = makeEnvironment(home, bin);
276
+ Object.assign(env, writePasswordCommand(bin, countPath));
277
+ const result = runCookies(home, env);
278
+ assert.equal(result.result, null);
279
+ assert.equal(result.diagnostic.includes("required Gemini cookies"), true);
280
+ assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 1" && attempt.status === "missing-required-cookies"), true);
281
+ assert.equal(existsSync(countPath), false);
282
+ rmSync(home, { recursive: true, force: true });
283
+ rmSync(bin, { recursive: true, force: true });
284
+ });
285
+
286
+ test("diagnostics report browser profile when password-store access fails", (t) => {
287
+ skipWithoutPython(t);
288
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-keychain-failure-"));
289
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
290
+ createFixture(home, "Default", [
291
+ ["__Secure-1PSID", "one", ".google.com", null, 1],
292
+ ["__Secure-1PSIDTS", "two", ".google.com", null, 2],
293
+ ], { browser: "Helium", targetPlatform: "darwin" });
294
+ const env = makeEnvironment(home, bin);
295
+ Object.assign(env, writeFailPasswordCommand(bin, join(home, "password-count"), "darwin"));
296
+ const result = runCookies(home, env, undefined, "darwin");
297
+ assert.equal(result.result, null);
298
+ assert.equal(result.diagnostic, "Could not read Helium cookie encryption password");
299
+ assert.deepEqual(result.details.attempts[0], { browser: "Helium", profile: "Default", status: "password-read-failed" });
300
+ assert.doesNotMatch(JSON.stringify(result), /one|two|peanuts|sensitive stderr/);
301
+ rmSync(home, { recursive: true, force: true });
302
+ rmSync(bin, { recursive: true, force: true });
303
+ });
304
+
305
+ test("diagnostics distinguish required cookie decryption failure", (t) => {
306
+ skipWithoutPython(t);
307
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-decrypt-failure-"));
308
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
309
+ const encrypted = `hex:${Buffer.from("v10bad-ciphertext").toString("hex")}`;
310
+ createFixture(home, "Profile 2", [
311
+ ["__Secure-1PSID", "", ".google.com", encrypted, 1],
312
+ ["__Secure-1PSIDTS", "", ".google.com", encrypted, 2],
313
+ ]);
314
+ const env = makeEnvironment(home, bin);
315
+ Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
316
+ const result = runCookies(home, env);
317
+ assert.equal(result.result, null);
318
+ assert.match(result.diagnostic, /could not be decrypted/);
319
+ assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 2" && attempt.status === "decryption-failed"), true);
320
+ assert.doesNotMatch(JSON.stringify(result), /peanuts|bad-ciphertext/);
321
+ rmSync(home, { recursive: true, force: true });
322
+ rmSync(bin, { recursive: true, force: true });
323
+ });
324
+
325
+ test("browser encryption password is cached within a process", (t) => {
326
+ skipWithoutPython(t);
327
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-cache-"));
328
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
329
+ createFixture(home, "Profile 2", [
330
+ ["__Secure-1PSID", "one", ".google.com", null, 1],
331
+ ["__Secure-1PSIDTS", "two", ".google.com", null, 2],
332
+ ]);
333
+ const countPath = join(home, "password-count");
334
+ const env = makeEnvironment(home, bin);
335
+ Object.assign(env, writePasswordCommand(bin, countPath));
336
+ const child = spawnSync(process.execPath, ["--experimental-strip-types", "--input-type=module"], {
337
+ encoding: "utf8",
338
+ env,
339
+ input: `const { getGoogleCookies } = await import(${JSON.stringify(moduleUrl)}); await getGoogleCookies({ profile: 'Profile 2', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }); await getGoogleCookies({ profile: 'Profile 2', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] });`,
340
+ });
341
+ assert.equal(child.status, 0, child.stderr);
342
+ assert.equal(readFileSync(countPath, "utf8"), "1");
343
+ rmSync(home, { recursive: true, force: true });
344
+ rmSync(bin, { recursive: true, force: true });
345
+ });
346
+
347
+ test("failed password lookups are retried instead of cached", (t) => {
348
+ skipWithoutPython(t);
349
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-cache-failure-"));
350
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
351
+ createFixture(home, "Profile 2", [
352
+ ["__Secure-1PSID", "one", ".google.com", null, 1],
353
+ ["__Secure-1PSIDTS", "two", ".google.com", null, 2],
354
+ ]);
355
+ const countPath = join(home, "password-count");
356
+ const env = makeEnvironment(home, bin);
357
+ Object.assign(env, writeFailThenSucceedPasswordCommand(bin, countPath));
358
+ const child = spawnSync(process.execPath, ["--experimental-strip-types", "--input-type=module"], {
359
+ encoding: "utf8",
360
+ env,
361
+ input: `const { getGoogleCookies } = await import(${JSON.stringify(moduleUrl)}); const options = { profile: 'Profile 2', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }; const first = await getGoogleCookies(options); const second = await getGoogleCookies(options); console.log(JSON.stringify({ first, second }));`,
362
+ });
363
+ assert.equal(child.status, 0, child.stderr);
364
+ const result = JSON.parse(child.stdout);
365
+ assert.equal(result.first, null);
366
+ assert.deepEqual(result.second.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
367
+ assert.equal(readFileSync(countPath, "utf8"), "2");
368
+ rmSync(home, { recursive: true, force: true });
369
+ rmSync(bin, { recursive: true, force: true });
370
+ });
371
+
372
+ test("configured profile names cannot escape the browser profile root", (t) => {
373
+ skipWithoutPython(t);
374
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-profile-traversal-"));
375
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
376
+ const env = makeEnvironment(home, bin);
377
+ const result = runCookies(home, env, "{ profile: '../Profile 2', requiredCookies: ['__Secure-1PSID'] }");
378
+ assert.equal(result.result, null);
379
+ assert.match(result.diagnostic, /profile directory name/);
380
+ rmSync(home, { recursive: true, force: true });
381
+ rmSync(bin, { recursive: true, force: true });
382
+ });
383
+
384
+ test("explicit profile symlinks cannot escape the browser profile root", (t) => {
385
+ skipWithoutPython(t);
386
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-profile-symlink-"));
387
+ const outsideHome = mkdtempSync(join(tmpdir(), "pi-cookie-outside-"));
388
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
389
+ createFixture(outsideHome, "Outside", [
390
+ ["__Secure-1PSID", "one", ".google.com", null, 1],
391
+ ["__Secure-1PSIDTS", "two", ".google.com", null, 2],
392
+ ]);
393
+ const browserRoot = process.platform === "darwin"
394
+ ? join(home, "Library", "Application Support", "Google", "Chrome")
395
+ : join(home, ".config", "google-chrome");
396
+ const outsideProfile = process.platform === "darwin"
397
+ ? join(outsideHome, "Library", "Application Support", "Google", "Chrome", "Outside")
398
+ : join(outsideHome, ".config", "google-chrome", "Outside");
399
+ mkdirSync(browserRoot, { recursive: true });
400
+ symlinkSync(outsideProfile, join(browserRoot, "link"), "dir");
401
+ const env = makeEnvironment(home, bin);
402
+ Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
403
+ const result = runCookies(home, env, "{ profile: 'link', requiredCookies: ['__Secure-1PSID', '__Secure-1PSIDTS'] }");
404
+ assert.equal(result.result, null);
405
+ assert.match(result.diagnostic, /inside the browser profile root/);
406
+ rmSync(home, { recursive: true, force: true });
407
+ rmSync(outsideHome, { recursive: true, force: true });
408
+ rmSync(bin, { recursive: true, force: true });
409
+ });
410
+
411
+ test("sqlite3 CLI fallback reads a copied database when node sqlite is unavailable", (t) => {
412
+ skipWithoutPython(t);
413
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-fallback-"));
414
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
415
+ createFixture(home, "Profile 2", [
416
+ ["__Secure-1PSID", "one", ".google.com", null, 1],
417
+ ["__Secure-1PSIDTS", "two", ".google.com", null, 2],
418
+ ]);
419
+ const env = makeEnvironment(home, bin, { PI_WEB_ACCESS_DISABLE_NODE_SQLITE: "1" });
420
+ Object.assign(env, writePasswordCommand(bin, join(home, "password-count")));
421
+ const result = runCookies(home, env);
422
+ assert.deepEqual(result.result.cookies, { "__Secure-1PSIDTS": "two", "__Secure-1PSID": "one" });
423
+ rmSync(home, { recursive: true, force: true });
424
+ rmSync(bin, { recursive: true, force: true });
425
+ });
426
+
427
+ test("unavailable SQLite backends produce actionable sanitized diagnostics", (t) => {
428
+ skipWithoutPython(t);
429
+ const home = mkdtempSync(join(tmpdir(), "pi-cookie-diagnostic-"));
430
+ const bin = mkdtempSync(join(tmpdir(), "pi-cookie-bin-"));
431
+ createFixture(home, "Profile 2", [["__Secure-1PSID", "one", ".google.com", null, 1]]);
432
+ const env = makeEnvironment(home, bin, { PI_WEB_ACCESS_DISABLE_NODE_SQLITE: "1", PATH: bin });
433
+ const result = runCookies(home, env);
434
+ assert.equal(result.result, null);
435
+ assert.match(result.diagnostic, /SQLite backend unavailable/);
436
+ assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 2" && attempt.status === "sqlite-unavailable"), true);
437
+ assert.equal(result.details.attempts.some((attempt) => attempt.browser === "Chrome" && attempt.profile === "Profile 2" && attempt.status === "missing-required-cookies"), false);
438
+ assert.doesNotMatch(result.diagnostic, /one|peanuts|stderr|password/i);
439
+ rmSync(home, { recursive: true, force: true });
440
+ rmSync(bin, { recursive: true, force: true });
441
+ });