failproofai 1.0.5-beta.0 → 1.0.5-beta.2

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 (166) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +6 -6
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +3 -3
  6. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  7. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  8. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  11. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
  12. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  13. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +3 -3
  15. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  16. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  17. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.rsc +14 -14
  20. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
  21. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
  22. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  23. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/audit/run/route.js +4 -4
  25. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js +1 -1
  32. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/audit/page/build-manifest.json +3 -3
  34. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
  35. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  37. package/.next/standalone/.next/server/app/index.html +1 -1
  38. package/.next/standalone/.next/server/app/index.rsc +14 -14
  39. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +13 -13
  40. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +14 -14
  41. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  42. package/.next/standalone/.next/server/app/page/build-manifest.json +3 -3
  43. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  44. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  46. package/.next/standalone/.next/server/app/policies/page/build-manifest.json +3 -3
  47. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
  48. package/.next/standalone/.next/server/app/policies/page.js +1 -1
  49. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  51. package/.next/standalone/.next/server/app/project/[name]/page/build-manifest.json +3 -3
  52. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  53. package/.next/standalone/.next/server/app/project/[name]/page.js +2 -2
  54. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  56. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/build-manifest.json +3 -3
  57. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  58. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  59. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +2 -2
  60. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  61. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  62. package/.next/standalone/.next/server/app/projects/page/build-manifest.json +3 -3
  63. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  64. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  65. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  66. package/.next/standalone/.next/server/app/settings/page/build-manifest.json +3 -3
  67. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -4
  68. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  69. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  70. package/.next/standalone/.next/server/chunks/{[externals]__0-9ti7z._.js → [externals]__1_bftcl._.js} +1 -1
  71. package/.next/standalone/.next/server/chunks/{[externals]__0u3wrvq._.js → [externals]__1msfs-h._.js} +1 -1
  72. package/.next/standalone/.next/server/chunks/[root-of-the-server]__08dchfu._.js +1 -1
  73. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0faqz9x._.js +22 -0
  74. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
  75. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zyc_nm._.js +3 -0
  76. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1p-qi2t._.js → [root-of-the-server]__112b4go._.js} +22 -3
  77. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1l71g3y._.js +22 -0
  78. package/.next/standalone/.next/server/chunks/_09dz7xv._.js +1 -1
  79. package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
  80. package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
  81. package/.next/standalone/.next/server/chunks/{_1-akg6w._.js → _1c3k-8x._.js} +2 -2
  82. package/.next/standalone/.next/server/chunks/_1ek68ln._.js +1 -1
  83. package/.next/standalone/.next/server/chunks/_1vslkoe._.js +1 -1
  84. package/.next/standalone/.next/server/chunks/lib_openclaw-projects_ts_0gc-p24._.js +3 -0
  85. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
  86. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1sc84bb._.js → [root-of-the-server]__00y9ww2._.js} +21 -2
  87. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__013jr2b._.js +2 -2
  88. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01wy8d-._.js +2 -2
  89. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02npjtd._.js +2 -2
  90. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0n_lxhg._.js → [root-of-the-server]__0bym1os._.js} +1 -1
  91. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0da85px._.js +2 -2
  92. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ftmoxc._.js +2 -2
  93. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0oa1lav._.js +1 -1
  94. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0p-5p8u._.js +2 -2
  95. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s740oi._.js +2 -2
  96. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__190won8._.js → [root-of-the-server]__0sz_5na._.js} +1 -1
  97. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1ctpynv._.js +1 -1
  98. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1kaotix._.js +22 -0
  99. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1p2otjt._.js +2 -2
  100. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__00-s7h8._.js → [root-of-the-server]__1u6sn69._.js} +1 -1
  101. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0x1aj1_._.js → [root-of-the-server]__1xu5t8b._.js} +2 -2
  102. package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
  103. package/.next/standalone/.next/server/chunks/ssr/{_1if9ixi._.js → _14c6q09._.js} +21 -2
  104. package/.next/standalone/.next/server/chunks/ssr/_1_ozgif._.js +1 -1
  105. package/.next/standalone/.next/server/chunks/ssr/_1es2j7i._.js +2 -2
  106. package/.next/standalone/.next/server/chunks/ssr/{_0zs_4uu._.js → _1mo4bp9._.js} +1 -1
  107. package/.next/standalone/.next/server/chunks/ssr/{_0u3xxgc._.js → _1olen4g._.js} +2 -2
  108. package/.next/standalone/.next/server/chunks/ssr/_1u8-lu2._.js +1 -1
  109. package/.next/standalone/.next/server/chunks/ssr/_1zopuov._.js +1 -1
  110. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +2 -2
  111. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
  112. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
  113. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
  114. package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +1 -1
  115. package/.next/standalone/.next/server/chunks/ssr/lib_openclaw-projects_ts_0qxq3bp._.js +1 -1
  116. package/.next/standalone/.next/server/middleware-build-manifest.js +6 -6
  117. package/.next/standalone/.next/server/pages/404.html +1 -1
  118. package/.next/standalone/.next/server/pages/500.html +1 -1
  119. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  120. package/.next/standalone/.next/server/server-reference-manifest.json +19 -19
  121. package/.next/standalone/.next/static/chunks/{0oos8qpc1ugos.js → 04cawl3i7gqi5.js} +1 -1
  122. package/.next/standalone/.next/static/chunks/{0hw6-c206lsma.js → 0671mdu5plc8o.js} +1 -1
  123. package/.next/standalone/.next/static/chunks/{33umhy-x204qj.js → 0cn62s92buqr1.js} +2 -2
  124. package/.next/standalone/.next/static/chunks/{2zafgs90r_leq.js → 0h95tsad4_-gr.js} +1 -1
  125. package/.next/standalone/.next/static/chunks/{3nux7kkrc3eps.js → 0pdmk3xha1zih.js} +1 -1
  126. package/.next/standalone/.next/static/chunks/{40tpgs4fjct5p.js → 1oey07bwm1ayr.js} +1 -1
  127. package/.next/standalone/.next/static/chunks/{0unrx9g_x0u7j.js → 1qwk_vp6dsat_.js} +1 -1
  128. package/.next/standalone/.next/static/chunks/{40uih96wnkowy.js → 2pnvnpg-kdbyt.js} +1 -1
  129. package/.next/standalone/.next/static/chunks/{3i8rg2fv9nd6e.js → 315zh293r-n7v.js} +1 -1
  130. package/.next/standalone/.next/static/chunks/{2xbxkaszi1xnw.js → 3aoj_ov89ym_h.js} +1 -1
  131. package/.next/standalone/.next/static/chunks/{2qjn-leir0x_s.js → 3gfi5ixrc6v1z.js} +1 -1
  132. package/.next/standalone/.next/static/chunks/{0m9sx3khjrl1q.js → 3k3g_4k13t9za.js} +1 -1
  133. package/.next/standalone/.next/static/chunks/{turbopack-3p73obe0xmrxm.js → turbopack-44avr18ueo9ob.js} +1 -1
  134. package/.next/standalone/fp-cloud-cli/CHANGELOG.md +7 -0
  135. package/.next/standalone/fp-cloud-cli/fp_cli/_version.py +1 -1
  136. package/.next/standalone/lib/download-session.ts +58 -13
  137. package/.next/standalone/lib/openclaw-db.ts +271 -0
  138. package/.next/standalone/lib/openclaw-profiles.ts +78 -0
  139. package/.next/standalone/lib/openclaw-projects.ts +57 -21
  140. package/.next/standalone/lib/openclaw-sessions.ts +75 -17
  141. package/.next/standalone/lib/sqlite-reader.ts +165 -9
  142. package/.next/standalone/package.json +9 -9
  143. package/.next/standalone/sdk/python/CHANGELOG.md +7 -0
  144. package/.next/standalone/sdk/python/failproofai_sdk/_version.py +1 -1
  145. package/.next/standalone/server.js +1 -1
  146. package/dist/cli.mjs +1065 -693
  147. package/dist/worker.mjs +425 -102
  148. package/lib/download-session.ts +58 -13
  149. package/lib/openclaw-db.ts +271 -0
  150. package/lib/openclaw-profiles.ts +78 -0
  151. package/lib/openclaw-projects.ts +57 -21
  152. package/lib/openclaw-sessions.ts +75 -17
  153. package/lib/sqlite-reader.ts +165 -9
  154. package/openclaw-plugin/index.js +22 -12
  155. package/openclaw-plugin/instruct-retry-gate.js +89 -0
  156. package/openclaw-plugin/workspace-context.js +93 -0
  157. package/package.json +9 -9
  158. package/src/hooks/integrations.ts +22 -14
  159. package/src/hooks/policy-evaluator.ts +22 -3
  160. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-219ec._.js +0 -3
  161. package/.next/standalone/.next/server/chunks/[root-of-the-server]__04_h-a5._.js +0 -3
  162. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1le9jqc._.js +0 -3
  163. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1nq7ivq._.js +0 -3
  164. /package/.next/standalone/.next/static/{4_QeL7mSPYsuiSVJmBOTj → GDwSJ81wNHeh1pQdxpvk_}/_buildManifest.js +0 -0
  165. /package/.next/standalone/.next/static/{4_QeL7mSPYsuiSVJmBOTj → GDwSJ81wNHeh1pQdxpvk_}/_clientMiddlewareManifest.js +0 -0
  166. /package/.next/standalone/.next/static/{4_QeL7mSPYsuiSVJmBOTj → GDwSJ81wNHeh1pQdxpvk_}/_ssgManifest.js +0 -0
package/dist/worker.mjs CHANGED
@@ -3483,7 +3483,7 @@ function parsePackPolicyName(canonicalName) {
3483
3483
  }
3484
3484
 
3485
3485
  // package.json
3486
- var version = "1.0.5-beta.0";
3486
+ var version = "1.0.5-beta.2";
3487
3487
  var init_package = () => {};
3488
3488
 
3489
3489
  // src/posthog-key.ts
@@ -4290,6 +4290,22 @@ You MUST complete the above action(s) NOW. Do NOT ask the user for confirmation
4290
4290
  decision: "instruct"
4291
4291
  };
4292
4292
  }
4293
+ if (eventType === "PreToolUse") {
4294
+ return {
4295
+ exitCode: 0,
4296
+ stdout: JSON.stringify({
4297
+ permission: "instruct",
4298
+ reason: `Instruction from failproofai: ${combined}`,
4299
+ policyName: policyNames[0],
4300
+ policyNames
4301
+ }),
4302
+ stderr: "",
4303
+ policyName: policyNames[0],
4304
+ policyNames,
4305
+ reason: combined,
4306
+ decision: "instruct"
4307
+ };
4308
+ }
4293
4309
  const stderrMsg = instructEntries.map((e) => `[failproofai] ${e.policyName}: ${e.reason}`).join(`
4294
4310
  `);
4295
4311
  return {
@@ -5874,7 +5890,7 @@ var init_cursor_projects = __esm(() => {
5874
5890
  });
5875
5891
 
5876
5892
  // lib/sqlite-reader.ts
5877
- import { existsSync as existsSync8, readFileSync as readFileSync6 } from "node:fs";
5893
+ import { existsSync as existsSync8, readFileSync as readFileSync6, statSync as statSync6 } from "node:fs";
5878
5894
  import initSqlJs from "sql.js/dist/sql-asm.js";
5879
5895
  async function tryNodeSqlite(dbPath) {
5880
5896
  try {
@@ -5898,10 +5914,117 @@ function loadSqlJs() {
5898
5914
  sqlPromise = initSqlJs();
5899
5915
  return sqlPromise;
5900
5916
  }
5917
+ function fileVersion(path) {
5918
+ const stat = statSync6(path);
5919
+ return { size: stat.size, mtimeMs: stat.mtimeMs, ctimeMs: stat.ctimeMs };
5920
+ }
5921
+ function sameVersion(a, b) {
5922
+ return a.size === b.size && a.mtimeMs === b.mtimeMs && a.ctimeMs === b.ctimeMs;
5923
+ }
5924
+ function sqlitePageSize(db) {
5925
+ if (db.length < 100)
5926
+ return null;
5927
+ if (Buffer.from(db.subarray(0, 16)).toString("binary") !== "SQLite format 3\x00")
5928
+ return null;
5929
+ const encoded = db[16] << 8 | db[17];
5930
+ const pageSize = encoded === 1 ? 65536 : encoded;
5931
+ return pageSize >= 512 && pageSize <= 65536 && (pageSize & pageSize - 1) === 0 ? pageSize : null;
5932
+ }
5933
+ function walChecksum(bytes, offset, length, bigEndian, initial = [0, 0]) {
5934
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
5935
+ let [sum1, sum2] = initial;
5936
+ for (let cursor = offset;cursor < offset + length; cursor += 8) {
5937
+ const first = view.getUint32(cursor, !bigEndian);
5938
+ const second = view.getUint32(cursor + 4, !bigEndian);
5939
+ sum1 = sum1 + first + sum2 >>> 0;
5940
+ sum2 = sum2 + second + sum1 >>> 0;
5941
+ }
5942
+ return [sum1, sum2];
5943
+ }
5944
+ function applyCommittedWal(db, wal) {
5945
+ const pageSize = sqlitePageSize(db);
5946
+ if (pageSize === null || wal.length < 32)
5947
+ return db;
5948
+ const view = new DataView(wal.buffer, wal.byteOffset, wal.byteLength);
5949
+ const magic = view.getUint32(0, false);
5950
+ if (magic !== 931071618 && magic !== 931071619)
5951
+ return db;
5952
+ if (view.getUint32(4, false) !== 3007000)
5953
+ return db;
5954
+ if (view.getUint32(8, false) !== pageSize)
5955
+ return db;
5956
+ const checksumBigEndian = (magic & 1) === 1;
5957
+ let checksum = walChecksum(wal, 0, 24, checksumBigEndian);
5958
+ if (view.getUint32(24, false) !== checksum[0] || view.getUint32(28, false) !== checksum[1]) {
5959
+ return db;
5960
+ }
5961
+ const salt1 = view.getUint32(16, false);
5962
+ const salt2 = view.getUint32(20, false);
5963
+ const frameSize = 24 + pageSize;
5964
+ const frameCount = Math.floor((wal.length - 32) / frameSize);
5965
+ let lastCommit = -1;
5966
+ let committedPages = 0;
5967
+ for (let index = 0;index < frameCount; index += 1) {
5968
+ const offset = 32 + index * frameSize;
5969
+ const pageNumber = view.getUint32(offset, false);
5970
+ if (pageNumber === 0 || view.getUint32(offset + 8, false) !== salt1 || view.getUint32(offset + 12, false) !== salt2) {
5971
+ break;
5972
+ }
5973
+ checksum = walChecksum(wal, offset, 8, checksumBigEndian, checksum);
5974
+ checksum = walChecksum(wal, offset + 24, pageSize, checksumBigEndian, checksum);
5975
+ if (view.getUint32(offset + 16, false) !== checksum[0] || view.getUint32(offset + 20, false) !== checksum[1]) {
5976
+ break;
5977
+ }
5978
+ const databasePages = view.getUint32(offset + 4, false);
5979
+ if (databasePages > 0) {
5980
+ lastCommit = index;
5981
+ committedPages = databasePages;
5982
+ }
5983
+ }
5984
+ if (lastCommit < 0 || committedPages === 0)
5985
+ return db;
5986
+ const targetSize = committedPages * pageSize;
5987
+ if (!Number.isSafeInteger(targetSize) || targetSize > db.length + frameCount * pageSize) {
5988
+ return db;
5989
+ }
5990
+ const snapshot = new Uint8Array(targetSize);
5991
+ snapshot.set(db.subarray(0, targetSize));
5992
+ for (let index = 0;index <= lastCommit; index += 1) {
5993
+ const offset = 32 + index * frameSize;
5994
+ const pageNumber = view.getUint32(offset, false);
5995
+ const destination = (pageNumber - 1) * pageSize;
5996
+ if (destination >= targetSize)
5997
+ continue;
5998
+ snapshot.set(wal.subarray(offset + 24, offset + frameSize), destination);
5999
+ }
6000
+ return snapshot;
6001
+ }
6002
+ function readPortableSnapshot(dbPath) {
6003
+ const walPath = `${dbPath}-wal`;
6004
+ for (let attempt = 0;attempt < 3; attempt += 1) {
6005
+ const before = fileVersion(dbPath);
6006
+ const main = readFileSync6(dbPath);
6007
+ const afterMain = fileVersion(dbPath);
6008
+ if (!sameVersion(before, afterMain))
6009
+ continue;
6010
+ let wal = null;
6011
+ try {
6012
+ wal = readFileSync6(walPath);
6013
+ } catch (error) {
6014
+ if (error.code !== "ENOENT")
6015
+ throw error;
6016
+ }
6017
+ const afterWal = fileVersion(dbPath);
6018
+ if (!sameVersion(before, afterWal))
6019
+ continue;
6020
+ return wal ? applyCommittedWal(main, wal) : main;
6021
+ }
6022
+ throw new Error(`SQLite database changed while reading: ${dbPath}`);
6023
+ }
5901
6024
  async function trySqlJs(dbPath) {
5902
6025
  try {
5903
6026
  const SQL = await loadSqlJs();
5904
- const db = new SQL.Database(readFileSync6(dbPath));
6027
+ const db = new SQL.Database(readPortableSnapshot(dbPath));
5905
6028
  return {
5906
6029
  query(sql, params) {
5907
6030
  const stmt = db.prepare(sql);
@@ -5924,10 +6047,15 @@ async function trySqlJs(dbPath) {
5924
6047
  return null;
5925
6048
  }
5926
6049
  }
5927
- async function openSqliteReadonly(dbPath) {
6050
+ async function openSqliteReadonly(dbPath, options = {}) {
5928
6051
  if (!existsSync8(dbPath))
5929
6052
  return null;
5930
- return await tryNodeSqlite(dbPath) ?? await trySqlJs(dbPath);
6053
+ if (!options.forcePortable) {
6054
+ const native = await tryNodeSqlite(dbPath);
6055
+ if (native)
6056
+ return native;
6057
+ }
6058
+ return trySqlJs(dbPath);
5931
6059
  }
5932
6060
  var sqlPromise = null;
5933
6061
  var init_sqlite_reader = () => {};
@@ -6636,13 +6764,169 @@ var init_hermes_projects = __esm(() => {
6636
6764
  getCachedHermesSessionsByEncodedName = runtimeCache((name) => getHermesSessionsByEncodedName(name), 2, { maxSize: 50 });
6637
6765
  });
6638
6766
 
6767
+ // lib/openclaw-db.ts
6768
+ import { existsSync as existsSync9 } from "node:fs";
6769
+ import { join as join13 } from "node:path";
6770
+ function str(value) {
6771
+ return typeof value === "string" && value.length > 0 ? value : undefined;
6772
+ }
6773
+ function parseObject(value) {
6774
+ try {
6775
+ const parsed = JSON.parse(value);
6776
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
6777
+ } catch {
6778
+ return;
6779
+ }
6780
+ }
6781
+ function syntheticPath(agentId, sessionId) {
6782
+ return `openclaw-sqlite://${encodeURIComponent(agentId)}/${sessionId}`;
6783
+ }
6784
+ function listOpenClawDatabases(home, agentIds) {
6785
+ const out = [];
6786
+ for (const agentId of agentIds) {
6787
+ const dbPath = join13(home, "agents", agentId, "agent", DB_NAME);
6788
+ if (existsSync9(dbPath))
6789
+ out.push({ agentId, dbPath });
6790
+ }
6791
+ return out;
6792
+ }
6793
+ function readNodeMetadata(db) {
6794
+ const out = new Map;
6795
+ let rows;
6796
+ try {
6797
+ rows = db.query(`SELECT current_session_id, entry_json, label, display_name
6798
+ FROM session_nodes`);
6799
+ } catch {
6800
+ return out;
6801
+ }
6802
+ for (const row of rows) {
6803
+ const entry = parseObject(row.entry_json) ?? {};
6804
+ const origin = entry.origin && typeof entry.origin === "object" && !Array.isArray(entry.origin) ? entry.origin : {};
6805
+ out.set(row.current_session_id, {
6806
+ channel: str(entry.lastChannel) ?? str(origin.provider) ?? str(origin.surface),
6807
+ label: str(row.label) ?? str(row.display_name) ?? str(entry.displayName) ?? str(origin.label),
6808
+ chatId: str(entry.lastTo) ?? str(origin.from),
6809
+ chatType: str(entry.chatType) ?? str(origin.chatType)
6810
+ });
6811
+ }
6812
+ return out;
6813
+ }
6814
+ function readConversationMetadata(db) {
6815
+ const out = new Map;
6816
+ let rows;
6817
+ try {
6818
+ rows = db.query(`SELECT sc.session_id, c.channel, c.kind, c.peer_id,
6819
+ c.delivery_target, c.label
6820
+ FROM session_conversations sc
6821
+ JOIN conversations c ON c.conversation_id = sc.conversation_id
6822
+ ORDER BY CASE sc.role WHEN 'primary' THEN 0 ELSE 1 END, sc.last_seen_at DESC`);
6823
+ } catch {
6824
+ return out;
6825
+ }
6826
+ for (const row of rows) {
6827
+ if (out.has(row.session_id))
6828
+ continue;
6829
+ out.set(row.session_id, {
6830
+ channel: str(row.channel),
6831
+ label: str(row.label),
6832
+ chatId: str(row.delivery_target) ?? str(row.peer_id),
6833
+ chatType: str(row.kind)
6834
+ });
6835
+ }
6836
+ return out;
6837
+ }
6838
+ async function listOpenClawSqliteSessions(home, agentIds) {
6839
+ const sessions = [];
6840
+ for (const { agentId, dbPath } of listOpenClawDatabases(home, agentIds)) {
6841
+ const db = await openSqliteReadonly(dbPath);
6842
+ if (!db)
6843
+ continue;
6844
+ try {
6845
+ let rows;
6846
+ try {
6847
+ rows = db.query(`SELECT w.session_id, w.session_key, w.updated_at,
6848
+ w.transcript_updated_at, w.ended_at, w.channel,
6849
+ w.chat_type, w.display_name,
6850
+ COALESCE((SELECT MAX(e.created_at)
6851
+ FROM transcript_events e
6852
+ WHERE e.session_id = w.session_id), 0) AS event_updated_at,
6853
+ COALESCE((SELECT SUM(length(e.event_json) + 1)
6854
+ FROM transcript_events e
6855
+ WHERE e.session_id = w.session_id), 0) AS size_bytes
6856
+ FROM session_windows w
6857
+ WHERE EXISTS (SELECT 1 FROM transcript_events e
6858
+ WHERE e.session_id = w.session_id)`);
6859
+ } catch {
6860
+ continue;
6861
+ }
6862
+ const nodes = readNodeMetadata(db);
6863
+ const conversations = readConversationMetadata(db);
6864
+ for (const row of rows) {
6865
+ const node = nodes.get(row.session_id);
6866
+ const conversation = conversations.get(row.session_id);
6867
+ sessions.push({
6868
+ sessionId: row.session_id,
6869
+ agentId,
6870
+ dbPath,
6871
+ transcriptPath: syntheticPath(agentId, row.session_id),
6872
+ mtimeMs: Math.max(Number(row.updated_at) || 0, Number(row.transcript_updated_at) || 0, Number(row.ended_at) || 0, Number(row.event_updated_at) || 0),
6873
+ sizeBytes: Number(row.size_bytes) || 0,
6874
+ channel: str(row.channel) ?? conversation?.channel ?? node?.channel ?? "local",
6875
+ label: str(row.display_name) ?? conversation?.label ?? node?.label,
6876
+ chatId: conversation?.chatId ?? node?.chatId,
6877
+ chatType: str(row.chat_type) ?? conversation?.chatType ?? node?.chatType
6878
+ });
6879
+ }
6880
+ } finally {
6881
+ db.close();
6882
+ }
6883
+ }
6884
+ return sessions;
6885
+ }
6886
+ async function readOpenClawSqliteTranscript(home, agentIds, sessionId) {
6887
+ for (const { agentId, dbPath } of listOpenClawDatabases(home, agentIds)) {
6888
+ const db = await openSqliteReadonly(dbPath);
6889
+ if (!db)
6890
+ continue;
6891
+ try {
6892
+ let rows;
6893
+ try {
6894
+ rows = db.query(`SELECT event_json
6895
+ FROM transcript_events
6896
+ WHERE session_id = ?
6897
+ ORDER BY seq ASC`, [sessionId]);
6898
+ } catch {
6899
+ continue;
6900
+ }
6901
+ if (rows.length === 0)
6902
+ continue;
6903
+ const eventJsonLines = rows.map((row) => row.event_json);
6904
+ const rawLines = eventJsonLines.map(parseObject).filter((line) => line !== undefined);
6905
+ return {
6906
+ agentId,
6907
+ dbPath,
6908
+ filePath: syntheticPath(agentId, sessionId),
6909
+ rawLines,
6910
+ eventJsonLines
6911
+ };
6912
+ } finally {
6913
+ db.close();
6914
+ }
6915
+ }
6916
+ return null;
6917
+ }
6918
+ var DB_NAME = "openclaw-agent.sqlite";
6919
+ var init_openclaw_db = __esm(() => {
6920
+ init_sqlite_reader();
6921
+ });
6922
+
6639
6923
  // lib/openclaw-sessions.ts
6640
6924
  import { readFile as readFile7 } from "node:fs/promises";
6641
- import { readdirSync as readdirSync4, statSync as statSync6 } from "node:fs";
6925
+ import { readdirSync as readdirSync4, statSync as statSync7 } from "node:fs";
6642
6926
  import { homedir as homedir11 } from "node:os";
6643
- import { join as join13 } from "node:path";
6927
+ import { join as join14 } from "node:path";
6644
6928
  function openclawHome() {
6645
- return process.env.OPENCLAW_HOME || join13(homedir11(), ".openclaw");
6929
+ return process.env.OPENCLAW_STATE_DIR || process.env.OPENCLAW_HOME || join14(homedir11(), ".openclaw");
6646
6930
  }
6647
6931
  function isPlainObject2(v) {
6648
6932
  return !!v && typeof v === "object" && !Array.isArray(v);
@@ -6729,7 +7013,11 @@ function openclawLinesToLogEntries(lines, source = "session") {
6729
7013
  entries.push({
6730
7014
  type: "assistant",
6731
7015
  ...base,
6732
- message: { role: "assistant", content: blocks, model: typeof m.model === "string" ? m.model : undefined }
7016
+ message: {
7017
+ role: "assistant",
7018
+ content: blocks,
7019
+ model: typeof m.model === "string" ? m.model : undefined
7020
+ }
6733
7021
  });
6734
7022
  continue;
6735
7023
  }
@@ -6757,13 +7045,13 @@ function openclawLinesToLogEntries(lines, source = "session") {
6757
7045
  }
6758
7046
  function listOpenClawAgents() {
6759
7047
  try {
6760
- return readdirSync4(join13(openclawHome(), "agents"), { withFileTypes: true }).filter((d) => d.isDirectory() && !d.name.startsWith(".")).map((d) => d.name).sort();
7048
+ return readdirSync4(join14(openclawHome(), "agents"), { withFileTypes: true }).filter((d) => d.isDirectory() && !d.name.startsWith(".")).map((d) => d.name).sort();
6761
7049
  } catch {
6762
7050
  return [];
6763
7051
  }
6764
7052
  }
6765
7053
  function listOpenClawTranscripts() {
6766
- const agentsDir = join13(openclawHome(), "agents");
7054
+ const agentsDir = join14(openclawHome(), "agents");
6767
7055
  const out = [];
6768
7056
  let agentIds;
6769
7057
  try {
@@ -6772,7 +7060,7 @@ function listOpenClawTranscripts() {
6772
7060
  return out;
6773
7061
  }
6774
7062
  for (const agentId of agentIds) {
6775
- const sessionsDir = join13(agentsDir, agentId, "sessions");
7063
+ const sessionsDir = join14(agentsDir, agentId, "sessions");
6776
7064
  let files;
6777
7065
  try {
6778
7066
  files = readdirSync4(sessionsDir);
@@ -6785,10 +7073,16 @@ function listOpenClawTranscripts() {
6785
7073
  const sessionId = file.slice(0, -".jsonl".length);
6786
7074
  if (!OPENCLAW_SESSION_ID_RE.test(sessionId))
6787
7075
  continue;
6788
- const transcriptPath = join13(sessionsDir, file);
7076
+ const transcriptPath = join14(sessionsDir, file);
6789
7077
  try {
6790
- const st = statSync6(transcriptPath);
6791
- out.push({ agentId, sessionId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
7078
+ const st = statSync7(transcriptPath);
7079
+ out.push({
7080
+ agentId,
7081
+ sessionId,
7082
+ transcriptPath,
7083
+ mtimeMs: st.mtimeMs,
7084
+ sizeBytes: st.size
7085
+ });
6792
7086
  } catch {}
6793
7087
  }
6794
7088
  }
@@ -6804,6 +7098,25 @@ function findOpenClawTranscript(sessionId) {
6804
7098
  return null;
6805
7099
  }
6806
7100
  async function getOpenClawSessionLog(sessionId) {
7101
+ if (!OPENCLAW_SESSION_ID_RE.test(sessionId))
7102
+ return null;
7103
+ const sqlite = await readOpenClawSqliteTranscript(openclawHome(), listOpenClawAgents(), sessionId);
7104
+ if (sqlite) {
7105
+ const entries = openclawLinesToLogEntries(sqlite.rawLines, "session");
7106
+ let cwd;
7107
+ for (const line of sqlite.rawLines) {
7108
+ if (line.type === "session" && typeof line.cwd === "string" && line.cwd.length > 0) {
7109
+ cwd = line.cwd;
7110
+ break;
7111
+ }
7112
+ }
7113
+ return {
7114
+ entries,
7115
+ rawLines: sqlite.rawLines,
7116
+ cwd,
7117
+ filePath: sqlite.filePath
7118
+ };
7119
+ }
6807
7120
  const filePath = findOpenClawTranscript(sessionId);
6808
7121
  if (!filePath)
6809
7122
  return null;
@@ -6827,6 +7140,7 @@ async function getOpenClawSessionLog(sessionId) {
6827
7140
  var OPENCLAW_SESSION_ID_RE, getCachedOpenClawSessionLog;
6828
7141
  var init_openclaw_sessions = __esm(() => {
6829
7142
  init_log_entries();
7143
+ init_openclaw_db();
6830
7144
  OPENCLAW_SESSION_ID_RE = /^[0-9a-fA-F-]{36}$/;
6831
7145
  getCachedOpenClawSessionLog = runtimeCache((sessionId) => getOpenClawSessionLog(sessionId), 2, { maxSize: 50 });
6832
7146
  });
@@ -6837,13 +7151,13 @@ __export(exports_openclaw_projects, {
6837
7151
  getOpenClawProjects: () => getOpenClawProjects
6838
7152
  });
6839
7153
  import { readFileSync as readFileSync7 } from "node:fs";
6840
- import { join as join14 } from "node:path";
6841
- function str(v) {
7154
+ import { join as join15 } from "node:path";
7155
+ function str2(v) {
6842
7156
  return typeof v === "string" && v.length > 0 ? v : undefined;
6843
7157
  }
6844
7158
  function readSessionsIndex(agentId) {
6845
7159
  const out = new Map;
6846
- const indexPath = join14(openclawHome(), "agents", agentId, "sessions", "sessions.json");
7160
+ const indexPath = join15(openclawHome(), "agents", agentId, "sessions", "sessions.json");
6847
7161
  let raw;
6848
7162
  try {
6849
7163
  raw = JSON.parse(readFileSync7(indexPath, "utf-8"));
@@ -6856,17 +7170,17 @@ function readSessionsIndex(agentId) {
6856
7170
  if (!v || typeof v !== "object")
6857
7171
  continue;
6858
7172
  const e = v;
6859
- const sessionId = str(e.sessionId);
7173
+ const sessionId = str2(e.sessionId);
6860
7174
  if (!sessionId)
6861
7175
  continue;
6862
7176
  const origin = e.origin && typeof e.origin === "object" ? e.origin : {};
6863
7177
  const lastMs = typeof e.lastInteractionAt === "number" ? e.lastInteractionAt : typeof e.updatedAt === "number" ? e.updatedAt : undefined;
6864
7178
  out.set(sessionId, {
6865
7179
  lastMs,
6866
- channel: str(e.lastChannel) ?? str(origin.provider) ?? str(origin.surface),
6867
- chatType: str(e.chatType) ?? str(origin.chatType),
6868
- label: str(origin.label),
6869
- chatId: str(e.lastTo) ?? str(origin.from)
7180
+ channel: str2(e.lastChannel) ?? str2(origin.provider) ?? str2(origin.surface),
7181
+ chatType: str2(e.chatType) ?? str2(origin.chatType),
7182
+ label: str2(origin.label),
7183
+ chatId: str2(e.lastTo) ?? str2(origin.from)
6870
7184
  });
6871
7185
  }
6872
7186
  return out;
@@ -6874,7 +7188,7 @@ function readSessionsIndex(agentId) {
6874
7188
  async function getOpenClawSessions() {
6875
7189
  const transcripts = listOpenClawTranscripts();
6876
7190
  const indexByAgent = new Map;
6877
- const refs = [];
7191
+ const refs = new Map;
6878
7192
  for (const t of transcripts) {
6879
7193
  let idx = indexByAgent.get(t.agentId);
6880
7194
  if (!idx) {
@@ -6882,7 +7196,7 @@ async function getOpenClawSessions() {
6882
7196
  indexByAgent.set(t.agentId, idx);
6883
7197
  }
6884
7198
  const meta = idx.get(t.sessionId);
6885
- refs.push({
7199
+ refs.set(`${t.agentId}\x00${t.sessionId}`, {
6886
7200
  sessionId: t.sessionId,
6887
7201
  agentId: t.agentId,
6888
7202
  channel: meta?.channel ?? "local",
@@ -6894,8 +7208,11 @@ async function getOpenClawSessions() {
6894
7208
  sizeBytes: t.sizeBytes
6895
7209
  });
6896
7210
  }
6897
- refs.sort((a, b) => b.mtimeMs - a.mtimeMs);
6898
- return refs;
7211
+ const sqliteSessions = await listOpenClawSqliteSessions(openclawHome(), listOpenClawAgents());
7212
+ for (const s of sqliteSessions) {
7213
+ refs.set(`${s.agentId}\x00${s.sessionId}`, s);
7214
+ }
7215
+ return [...refs.values()].sort((a, b) => b.mtimeMs - a.mtimeMs);
6899
7216
  }
6900
7217
  function openClawProjectName(agentId, channel) {
6901
7218
  return `openclaw-${agentId}-${channel}`;
@@ -6930,7 +7247,12 @@ async function getOpenClawProjects() {
6930
7247
  prev.latest = Math.max(prev.latest, s.mtimeMs);
6931
7248
  prev.count += 1;
6932
7249
  } else {
6933
- groups.set(key, { agentId: s.agentId, channel: s.channel, latest: s.mtimeMs, count: 1 });
7250
+ groups.set(key, {
7251
+ agentId: s.agentId,
7252
+ channel: s.channel,
7253
+ latest: s.mtimeMs,
7254
+ count: 1
7255
+ });
6934
7256
  }
6935
7257
  }
6936
7258
  const out = [];
@@ -6988,6 +7310,7 @@ async function getOpenClawSessionsByEncodedName(name) {
6988
7310
  var getCachedOpenClawSessions, getCachedOpenClawProjects, getCachedOpenClawSessionsByEncodedName;
6989
7311
  var init_openclaw_projects = __esm(() => {
6990
7312
  init_openclaw_sessions();
7313
+ init_openclaw_db();
6991
7314
  getCachedOpenClawSessions = runtimeCache(getOpenClawSessions, 2);
6992
7315
  getCachedOpenClawProjects = runtimeCache(getOpenClawProjects, 2);
6993
7316
  getCachedOpenClawSessionsByEncodedName = runtimeCache((name) => getOpenClawSessionsByEncodedName(name), 2, { maxSize: 50 });
@@ -6995,14 +7318,14 @@ var init_openclaw_projects = __esm(() => {
6995
7318
 
6996
7319
  // lib/factory-sessions.ts
6997
7320
  import { readFile as readFile8 } from "node:fs/promises";
6998
- import { readdirSync as readdirSync5, statSync as statSync7 } from "node:fs";
7321
+ import { readdirSync as readdirSync5, statSync as statSync8 } from "node:fs";
6999
7322
  import { homedir as homedir12 } from "node:os";
7000
- import { join as join15 } from "node:path";
7323
+ import { join as join16 } from "node:path";
7001
7324
  function factoryHome() {
7002
- return process.env.FACTORY_HOME || join15(homedir12(), ".factory");
7325
+ return process.env.FACTORY_HOME || join16(homedir12(), ".factory");
7003
7326
  }
7004
7327
  function factorySessionsRoot() {
7005
- return join15(factoryHome(), "sessions");
7328
+ return join16(factoryHome(), "sessions");
7006
7329
  }
7007
7330
  function isPlainObject3(v) {
7008
7331
  return !!v && typeof v === "object" && !Array.isArray(v);
@@ -7148,7 +7471,7 @@ function listFactoryTranscripts() {
7148
7471
  for (const dir of projectDirs) {
7149
7472
  const projectName = dir.name;
7150
7473
  const cwd = decodeFolderName(projectName);
7151
- const projectPath = join15(root, projectName);
7474
+ const projectPath = join16(root, projectName);
7152
7475
  let files;
7153
7476
  try {
7154
7477
  files = readdirSync5(projectPath);
@@ -7161,9 +7484,9 @@ function listFactoryTranscripts() {
7161
7484
  const sessionId = file.slice(0, -".jsonl".length);
7162
7485
  if (!FACTORY_SESSION_ID_RE.test(sessionId))
7163
7486
  continue;
7164
- const transcriptPath = join15(projectPath, file);
7487
+ const transcriptPath = join16(projectPath, file);
7165
7488
  try {
7166
- const st = statSync7(transcriptPath);
7489
+ const st = statSync8(transcriptPath);
7167
7490
  out.push({ projectName, cwd, sessionId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
7168
7491
  } catch {}
7169
7492
  }
@@ -7285,12 +7608,12 @@ var init_factory_projects = __esm(() => {
7285
7608
 
7286
7609
  // lib/devin-sessions.ts
7287
7610
  import { homedir as homedir13 } from "node:os";
7288
- import { join as join16 } from "node:path";
7611
+ import { join as join17 } from "node:path";
7289
7612
  function devinHome() {
7290
- return process.env.DEVIN_HOME || join16(homedir13(), ".local", "share", "devin");
7613
+ return process.env.DEVIN_HOME || join17(homedir13(), ".local", "share", "devin");
7291
7614
  }
7292
7615
  function devinDbPath() {
7293
- return process.env.DEVIN_DB_PATH || join16(devinHome(), "cli", "sessions.db");
7616
+ return process.env.DEVIN_DB_PATH || join17(devinHome(), "cli", "sessions.db");
7294
7617
  }
7295
7618
  function devinEpochToMs(value) {
7296
7619
  if (typeof value === "number" && Number.isFinite(value)) {
@@ -7582,17 +7905,17 @@ var init_devin_projects = __esm(() => {
7582
7905
 
7583
7906
  // lib/antigravity-sessions.ts
7584
7907
  import { readFile as readFile9 } from "node:fs/promises";
7585
- import { readdirSync as readdirSync6, statSync as statSync8 } from "node:fs";
7908
+ import { readdirSync as readdirSync6, statSync as statSync9 } from "node:fs";
7586
7909
  import { homedir as homedir14 } from "node:os";
7587
- import { join as join17 } from "node:path";
7910
+ import { join as join18 } from "node:path";
7588
7911
  function antigravityHome() {
7589
- return process.env.ANTIGRAVITY_HOME || join17(homedir14(), ".gemini", "antigravity-cli");
7912
+ return process.env.ANTIGRAVITY_HOME || join18(homedir14(), ".gemini", "antigravity-cli");
7590
7913
  }
7591
7914
  function antigravityBrainRoot() {
7592
- return join17(antigravityHome(), "brain");
7915
+ return join18(antigravityHome(), "brain");
7593
7916
  }
7594
7917
  function antigravityTranscriptRelPath() {
7595
- return join17(".system_generated", "logs", "transcript_full.jsonl");
7918
+ return join18(".system_generated", "logs", "transcript_full.jsonl");
7596
7919
  }
7597
7920
  function isPlainObject5(v) {
7598
7921
  return !!v && typeof v === "object" && !Array.isArray(v);
@@ -7715,9 +8038,9 @@ function listAntigravityTranscripts() {
7715
8038
  const conversationId = dir.name;
7716
8039
  if (!ANTIGRAVITY_CONVERSATION_ID_RE.test(conversationId))
7717
8040
  continue;
7718
- const transcriptPath = join17(root, conversationId, rel);
8041
+ const transcriptPath = join18(root, conversationId, rel);
7719
8042
  try {
7720
- const st = statSync8(transcriptPath);
8043
+ const st = statSync9(transcriptPath);
7721
8044
  if (!st.isFile())
7722
8045
  continue;
7723
8046
  out.push({ conversationId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
@@ -7728,9 +8051,9 @@ function listAntigravityTranscripts() {
7728
8051
  function findAntigravityTranscript(conversationId) {
7729
8052
  if (!ANTIGRAVITY_CONVERSATION_ID_RE.test(conversationId))
7730
8053
  return null;
7731
- const transcriptPath = join17(antigravityBrainRoot(), conversationId, antigravityTranscriptRelPath());
8054
+ const transcriptPath = join18(antigravityBrainRoot(), conversationId, antigravityTranscriptRelPath());
7732
8055
  try {
7733
- if (statSync8(transcriptPath).isFile())
8056
+ if (statSync9(transcriptPath).isFile())
7734
8057
  return transcriptPath;
7735
8058
  } catch {}
7736
8059
  return null;
@@ -7763,9 +8086,9 @@ var exports_antigravity_projects = {};
7763
8086
  __export(exports_antigravity_projects, {
7764
8087
  getAntigravityProjects: () => getAntigravityProjects
7765
8088
  });
7766
- import { join as join18 } from "node:path";
8089
+ import { join as join19 } from "node:path";
7767
8090
  function antigravitySummariesDbPath() {
7768
- return join18(antigravityHome(), "conversation_summaries.db");
8091
+ return join19(antigravityHome(), "conversation_summaries.db");
7769
8092
  }
7770
8093
  function parseWorkspaceCwd(raw) {
7771
8094
  if (!raw)
@@ -7909,15 +8232,15 @@ var init_antigravity_projects = __esm(() => {
7909
8232
 
7910
8233
  // lib/goose-sessions.ts
7911
8234
  import { homedir as homedir15 } from "node:os";
7912
- import { join as join19 } from "node:path";
8235
+ import { join as join20 } from "node:path";
7913
8236
  function gooseHome() {
7914
8237
  if (process.env.GOOSE_HOME)
7915
8238
  return process.env.GOOSE_HOME;
7916
8239
  const xdg = process.env.XDG_DATA_HOME;
7917
- return join19(xdg && xdg.length > 0 ? xdg : join19(homedir15(), ".local", "share"), "goose");
8240
+ return join20(xdg && xdg.length > 0 ? xdg : join20(homedir15(), ".local", "share"), "goose");
7918
8241
  }
7919
8242
  function gooseDbPath() {
7920
- return process.env.GOOSE_DB_PATH || join19(gooseHome(), "sessions", "sessions.db");
8243
+ return process.env.GOOSE_DB_PATH || join20(gooseHome(), "sessions", "sessions.db");
7921
8244
  }
7922
8245
  function gooseTimestampToMs(value) {
7923
8246
  if (typeof value === "number" && Number.isFinite(value)) {
@@ -8180,7 +8503,7 @@ var init_goose_projects = __esm(() => {
8180
8503
 
8181
8504
  // lib/projects.ts
8182
8505
  import { readdir as readdir5, stat as stat4 } from "node:fs/promises";
8183
- import { join as join20, resolve as resolve9, sep } from "node:path";
8506
+ import { join as join21, resolve as resolve9, sep } from "node:path";
8184
8507
  async function getMtime(path, label) {
8185
8508
  try {
8186
8509
  return (await stat4(path)).mtime;
@@ -8206,7 +8529,7 @@ async function getClaudeProjectFolders() {
8206
8529
  if (!entries)
8207
8530
  return [];
8208
8531
  const settled = await batchAll(entries.filter((entry) => entry.isDirectory()).map((entry) => async () => {
8209
- const folderPath = join20(projectsPath, entry.name);
8532
+ const folderPath = join21(projectsPath, entry.name);
8210
8533
  const mtime = await getMtime(folderPath, entry.name);
8211
8534
  return {
8212
8535
  name: entry.name,
@@ -8333,7 +8656,7 @@ function resolveProjectPath(projectName) {
8333
8656
  if (/^[/\\]/.test(projectName))
8334
8657
  throw new RangeError("Absolute project name");
8335
8658
  const projectsPath = resolve9(getClaudeProjectsPath());
8336
- const candidate = resolve9(join20(projectsPath, projectName));
8659
+ const candidate = resolve9(join21(projectsPath, projectName));
8337
8660
  if (!candidate.startsWith(projectsPath + sep)) {
8338
8661
  throw new RangeError("Project path escapes root");
8339
8662
  }
@@ -8351,7 +8674,7 @@ async function getSessionFiles(projectPath) {
8351
8674
  return [];
8352
8675
  const jsonlEntries = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl") && extractSessionId2(entry.name));
8353
8676
  const settled = await batchAll(jsonlEntries.map((entry) => async () => {
8354
- const filePath = join20(projectPath, entry.name);
8677
+ const filePath = join21(projectPath, entry.name);
8355
8678
  const mtime = await getMtime(filePath, entry.name);
8356
8679
  return {
8357
8680
  name: entry.name,
@@ -8380,13 +8703,13 @@ var init_projects = __esm(() => {
8380
8703
 
8381
8704
  // lib/resolve-subagent-path.ts
8382
8705
  import { access as access2 } from "fs/promises";
8383
- import { join as join21, relative as relative3 } from "path";
8706
+ import { join as join22, relative as relative3 } from "path";
8384
8707
  async function resolveSubagentPath(projectsPath, projectName, sessionId, agentId) {
8385
8708
  const fileName = `agent-${agentId}.jsonl`;
8386
8709
  const candidatePaths = [
8387
- join21(projectsPath, projectName, fileName),
8388
- join21(projectsPath, projectName, sessionId, fileName),
8389
- join21(projectsPath, projectName, sessionId, "subagents", fileName)
8710
+ join22(projectsPath, projectName, fileName),
8711
+ join22(projectsPath, projectName, sessionId, fileName),
8712
+ join22(projectsPath, projectName, sessionId, "subagents", fileName)
8390
8713
  ];
8391
8714
  for (const candidatePath of candidatePaths) {
8392
8715
  if (relative3(projectsPath, candidatePath).startsWith("..")) {
@@ -8408,7 +8731,7 @@ var init_resolve_subagent_path = () => {};
8408
8731
 
8409
8732
  // lib/log-entries.ts
8410
8733
  import { readFile as readFile10 } from "fs/promises";
8411
- import { join as join22 } from "path";
8734
+ import { join as join23 } from "path";
8412
8735
  function formatTimestamp(date) {
8413
8736
  const base = formatDate(date);
8414
8737
  const ms = date.getMilliseconds().toString().padStart(3, "0");
@@ -8602,7 +8925,7 @@ async function parseFileContent(fileContent, source) {
8602
8925
  async function parseSessionLog(projectName, sessionId) {
8603
8926
  const projectDir = resolveProjectPath(projectName);
8604
8927
  const projectsPath = getClaudeProjectsPath();
8605
- const filePath = join22(projectDir, `${sessionId}.jsonl`);
8928
+ const filePath = join23(projectDir, `${sessionId}.jsonl`);
8606
8929
  const fileContent = await readFile10(filePath, "utf-8");
8607
8930
  const { entries: sessionEntries, rawLines: sessionRawLines, subagentIds } = await parseFileContent(fileContent, "session");
8608
8931
  if (subagentIds.length === 0) {
@@ -8639,13 +8962,13 @@ var init_log_entries = __esm(() => {
8639
8962
  });
8640
8963
 
8641
8964
  // lib/codex-sessions.ts
8642
- import { readFileSync as readFileSync8, readdirSync as readdirSync7, existsSync as existsSync9, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, statSync as statSync9 } from "node:fs";
8965
+ import { readFileSync as readFileSync8, readdirSync as readdirSync7, existsSync as existsSync10, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, statSync as statSync10 } from "node:fs";
8643
8966
  import { readFile as readFile11 } from "node:fs/promises";
8644
- import { dirname as dirname4, join as join23 } from "node:path";
8967
+ import { dirname as dirname4, join as join24 } from "node:path";
8645
8968
  import { homedir as homedir16 } from "node:os";
8646
8969
  function readCache() {
8647
8970
  try {
8648
- if (!existsSync9(CACHE_PATH))
8971
+ if (!existsSync10(CACHE_PATH))
8649
8972
  return {};
8650
8973
  return JSON.parse(readFileSync8(CACHE_PATH, "utf-8"));
8651
8974
  } catch {
@@ -8664,7 +8987,7 @@ function dirSearch(dir, sessionId) {
8664
8987
  try {
8665
8988
  for (const f of readdirSync7(dir, { withFileTypes: true })) {
8666
8989
  if (f.isFile() && f.name.includes(sessionId) && f.name.endsWith(".jsonl")) {
8667
- return join23(dir, f.name);
8990
+ return join24(dir, f.name);
8668
8991
  }
8669
8992
  }
8670
8993
  } catch {}
@@ -8673,16 +8996,16 @@ function dirSearch(dir, sessionId) {
8673
8996
  function findCodexTranscript(sessionId) {
8674
8997
  const cache = readCache();
8675
8998
  const cached = cache[sessionId];
8676
- if (cached && existsSync9(cached))
8999
+ if (cached && existsSync10(cached))
8677
9000
  return cached;
8678
- const root = join23(homedir16(), ".codex", "sessions");
9001
+ const root = join24(homedir16(), ".codex", "sessions");
8679
9002
  const today = new Date;
8680
9003
  const yesterday = new Date(today.getTime() - 24 * 60 * 60 * 1000);
8681
9004
  const datedDirs = [today, yesterday].map((d) => {
8682
9005
  const y = String(d.getUTCFullYear());
8683
9006
  const m = String(d.getUTCMonth() + 1).padStart(2, "0");
8684
9007
  const day = String(d.getUTCDate()).padStart(2, "0");
8685
- return join23(root, y, m, day);
9008
+ return join24(root, y, m, day);
8686
9009
  });
8687
9010
  for (const dir of datedDirs) {
8688
9011
  const hit = dirSearch(dir, sessionId);
@@ -8695,13 +9018,13 @@ function findCodexTranscript(sessionId) {
8695
9018
  for (const y of readdirSync7(root, { withFileTypes: true })) {
8696
9019
  if (!y.isDirectory())
8697
9020
  continue;
8698
- for (const m of readdirSync7(join23(root, y.name), { withFileTypes: true })) {
9021
+ for (const m of readdirSync7(join24(root, y.name), { withFileTypes: true })) {
8699
9022
  if (!m.isDirectory())
8700
9023
  continue;
8701
- for (const d of readdirSync7(join23(root, y.name, m.name), { withFileTypes: true })) {
9024
+ for (const d of readdirSync7(join24(root, y.name, m.name), { withFileTypes: true })) {
8702
9025
  if (!d.isDirectory())
8703
9026
  continue;
8704
- const hit = dirSearch(join23(root, y.name, m.name, d.name), sessionId);
9027
+ const hit = dirSearch(join24(root, y.name, m.name, d.name), sessionId);
8705
9028
  if (hit) {
8706
9029
  writeCacheEntry(sessionId, hit);
8707
9030
  return hit;
@@ -8967,15 +9290,15 @@ var init_resolve_permission_mode = __esm(() => {
8967
9290
  });
8968
9291
 
8969
9292
  // lib/copilot-sessions.ts
8970
- import { readFileSync as readFileSync10, readdirSync as readdirSync8, existsSync as existsSync10, statSync as statSync10 } from "node:fs";
9293
+ import { readFileSync as readFileSync10, readdirSync as readdirSync8, existsSync as existsSync11, statSync as statSync11 } from "node:fs";
8971
9294
  import { readFile as readFile12 } from "node:fs/promises";
8972
- import { join as join24, resolve as resolve10, sep as sep2 } from "node:path";
9295
+ import { join as join25, resolve as resolve10, sep as sep2 } from "node:path";
8973
9296
  import { homedir as homedir17 } from "node:os";
8974
9297
  function getCopilotHome() {
8975
- return process.env.COPILOT_HOME || join24(homedir17(), ".copilot");
9298
+ return process.env.COPILOT_HOME || join25(homedir17(), ".copilot");
8976
9299
  }
8977
9300
  function getCopilotSessionStateRoot2() {
8978
- return join24(getCopilotHome(), "session-state");
9301
+ return join25(getCopilotHome(), "session-state");
8979
9302
  }
8980
9303
  function getCopilotSessionDir(sessionId) {
8981
9304
  if (!sessionId)
@@ -8990,19 +9313,19 @@ function resolveSessionFile(sessionId, filename) {
8990
9313
  const dir = getCopilotSessionDir(sessionId);
8991
9314
  if (!dir)
8992
9315
  return null;
8993
- return join24(dir, filename);
9316
+ return join25(dir, filename);
8994
9317
  }
8995
9318
  function findCopilotTranscript(sessionId) {
8996
9319
  const candidate = resolveSessionFile(sessionId, "events.jsonl");
8997
9320
  if (!candidate)
8998
9321
  return null;
8999
- return existsSync10(candidate) ? candidate : null;
9322
+ return existsSync11(candidate) ? candidate : null;
9000
9323
  }
9001
9324
  function findCopilotWorkspace(sessionId) {
9002
9325
  const candidate = resolveSessionFile(sessionId, "workspace.yaml");
9003
9326
  if (!candidate)
9004
9327
  return null;
9005
- return existsSync10(candidate) ? candidate : null;
9328
+ return existsSync11(candidate) ? candidate : null;
9006
9329
  }
9007
9330
  function readYamlScalar(path, key) {
9008
9331
  try {
@@ -9184,12 +9507,12 @@ var init_copilot_sessions = __esm(() => {
9184
9507
  });
9185
9508
 
9186
9509
  // lib/cursor-sessions.ts
9187
- import { readFileSync as readFileSync11, readdirSync as readdirSync9, existsSync as existsSync11, statSync as statSync11 } from "node:fs";
9510
+ import { readFileSync as readFileSync11, readdirSync as readdirSync9, existsSync as existsSync12, statSync as statSync12 } from "node:fs";
9188
9511
  import { readFile as readFile13 } from "node:fs/promises";
9189
- import { basename as basename3, join as join25, resolve as resolve11, sep as sep3 } from "node:path";
9512
+ import { basename as basename3, join as join26, resolve as resolve11, sep as sep3 } from "node:path";
9190
9513
  import { homedir as homedir18 } from "node:os";
9191
9514
  function getCursorHome2() {
9192
- return process.env.CURSOR_HOME || join25(homedir18(), ".cursor");
9515
+ return process.env.CURSOR_HOME || join26(homedir18(), ".cursor");
9193
9516
  }
9194
9517
  function getCursorSessionDir(sessionId) {
9195
9518
  if (!sessionId)
@@ -9207,7 +9530,7 @@ function getCursorSessionDir(sessionId) {
9207
9530
  const transcriptRoot = resolve11(projectsRoot, entry.name, NEW_AGENT_TRANSCRIPTS_DIR2);
9208
9531
  if (candidate === transcriptRoot || !candidate.startsWith(`${transcriptRoot}${sep3}`))
9209
9532
  continue;
9210
- if (existsSync11(candidate))
9533
+ if (existsSync12(candidate))
9211
9534
  return candidate;
9212
9535
  }
9213
9536
  for (const sub of LEGACY_SESSION_ROOT_CANDIDATES2) {
@@ -9215,7 +9538,7 @@ function getCursorSessionDir(sessionId) {
9215
9538
  const candidate = resolve11(root, sessionId);
9216
9539
  if (candidate === root || !candidate.startsWith(`${root}${sep3}`))
9217
9540
  continue;
9218
- if (existsSync11(candidate))
9541
+ if (existsSync12(candidate))
9219
9542
  return candidate;
9220
9543
  }
9221
9544
  return null;
@@ -9224,12 +9547,12 @@ function findCursorTranscript(sessionId) {
9224
9547
  const dir = getCursorSessionDir(sessionId);
9225
9548
  if (!dir)
9226
9549
  return null;
9227
- const newCandidate = join25(dir, `${basename3(dir)}.jsonl`);
9228
- if (existsSync11(newCandidate))
9550
+ const newCandidate = join26(dir, `${basename3(dir)}.jsonl`);
9551
+ if (existsSync12(newCandidate))
9229
9552
  return newCandidate;
9230
9553
  for (const name of LEGACY_TRANSCRIPT_FILE_CANDIDATES2) {
9231
- const candidate = join25(dir, name);
9232
- if (existsSync11(candidate))
9554
+ const candidate = join26(dir, name);
9555
+ if (existsSync12(candidate))
9233
9556
  return candidate;
9234
9557
  }
9235
9558
  return null;
@@ -9440,12 +9763,12 @@ var init_cursor_sessions = __esm(() => {
9440
9763
  });
9441
9764
 
9442
9765
  // lib/pi-sessions.ts
9443
- import { readFileSync as readFileSync12, readdirSync as readdirSync10, existsSync as existsSync12, statSync as statSync12 } from "node:fs";
9766
+ import { readFileSync as readFileSync12, readdirSync as readdirSync10, existsSync as existsSync13, statSync as statSync13 } from "node:fs";
9444
9767
  import { readFile as readFile14 } from "node:fs/promises";
9445
- import { join as join26, resolve as resolve12, sep as sep4 } from "node:path";
9768
+ import { join as join27, resolve as resolve12, sep as sep4 } from "node:path";
9446
9769
  import { homedir as homedir19 } from "node:os";
9447
9770
  function getPiSessionStateRoot() {
9448
- return process.env.PI_SESSIONS_DIR || join26(homedir19(), ".pi", "agent", "sessions");
9771
+ return process.env.PI_SESSIONS_DIR || join27(homedir19(), ".pi", "agent", "sessions");
9449
9772
  }
9450
9773
  function isSafeSessionId(sessionId) {
9451
9774
  return UUID_RE.test(sessionId);
@@ -9477,7 +9800,7 @@ function findPiTranscript(sessionId) {
9477
9800
  const candidate = resolve12(cwdPath, f);
9478
9801
  if (!candidate.startsWith(`${cwdPath}${sep4}`))
9479
9802
  continue;
9480
- if (existsSync12(candidate))
9803
+ if (existsSync13(candidate))
9481
9804
  return candidate;
9482
9805
  }
9483
9806
  }
@@ -9837,9 +10160,9 @@ var init_pack_failclosed = __esm(() => {
9837
10160
  var init_atomic_write = () => {};
9838
10161
 
9839
10162
  // src/hooks/session-pause.ts
9840
- import { existsSync as existsSync13, mkdirSync as mkdirSync6, readdirSync as readdirSync11, readFileSync as readFileSync13, rmSync as rmSync2 } from "node:fs";
10163
+ import { existsSync as existsSync14, mkdirSync as mkdirSync6, readdirSync as readdirSync11, readFileSync as readFileSync13, rmSync as rmSync2 } from "node:fs";
9841
10164
  import { createHash as createHash5 } from "node:crypto";
9842
- import { join as join27, resolve as resolve13 } from "node:path";
10165
+ import { join as join28, resolve as resolve13 } from "node:path";
9843
10166
  function pauseStateDir() {
9844
10167
  const override = process.env.FAILPROOFAI_STATE_DIR;
9845
10168
  if (override)
@@ -9848,7 +10171,7 @@ function pauseStateDir() {
9848
10171
  }
9849
10172
  function pauseFilePath(sessionId) {
9850
10173
  const digest = createHash5("sha256").update(sessionId).digest("hex").slice(0, 32);
9851
- return join27(pauseStateDir(), `${digest}.json`);
10174
+ return join28(pauseStateDir(), `${digest}.json`);
9852
10175
  }
9853
10176
  function parseStored(raw) {
9854
10177
  if (!raw || typeof raw !== "object")
@@ -9877,7 +10200,7 @@ function readActivePause(sessionId, now = Date.now()) {
9877
10200
  return null;
9878
10201
  try {
9879
10202
  const path = pauseFilePath(sessionId);
9880
- if (!existsSync13(path))
10203
+ if (!existsSync14(path))
9881
10204
  return null;
9882
10205
  const stored = parseStored(JSON.parse(readFileSync13(path, "utf8")));
9883
10206
  if (!stored)
@@ -9918,14 +10241,14 @@ var init_daemon_service = __esm(() => {
9918
10241
  // src/hooks/fp-reset.ts
9919
10242
  import {
9920
10243
  copyFileSync,
9921
- existsSync as existsSync14,
10244
+ existsSync as existsSync15,
9922
10245
  mkdirSync as mkdirSync7,
9923
10246
  readFileSync as readFileSync14,
9924
10247
  readdirSync as readdirSync12,
9925
10248
  renameSync as renameSync3,
9926
10249
  rmSync as rmSync3,
9927
10250
  rmdirSync,
9928
- statSync as statSync13,
10251
+ statSync as statSync14,
9929
10252
  writeFileSync as writeFileSync5
9930
10253
  } from "node:fs";
9931
10254
  function layoutWarningForHook() {
@@ -9935,7 +10258,7 @@ function layoutWarningForHook() {
9935
10258
  if (state.kind === "future") {
9936
10259
  return `[failproofai] this directory was written by a newer version (layout ${state.found} vs ${LAYOUT_VERSION}) — policies are NOT being enforced. ` + `Upgrade failproofai.`;
9937
10260
  }
9938
- if (existsSync14(globalPolicyConfigFile()))
10261
+ if (existsSync15(globalPolicyConfigFile()))
9939
10262
  return null;
9940
10263
  return `[failproofai] setup predates this version — global policies are NOT being enforced. ` + `Run \`failproofai config\` to re-create it.`;
9941
10264
  }
@@ -10312,7 +10635,7 @@ var init_handler = __esm(() => {
10312
10635
 
10313
10636
  // src/hooks/worker-server.ts
10314
10637
  import { createConnection, createServer } from "node:net";
10315
- import { existsSync as existsSync15, unlinkSync as unlinkSync2 } from "node:fs";
10638
+ import { existsSync as existsSync16, unlinkSync as unlinkSync2 } from "node:fs";
10316
10639
  function isWorkerHookRequest(msg) {
10317
10640
  if (!msg || typeof msg !== "object")
10318
10641
  return false;
@@ -10445,14 +10768,14 @@ function requestExistingWorkerShutdown(socketPath) {
10445
10768
  function startWorkerServer(socketPath, shutdown) {
10446
10769
  const server = createServer((socket) => handleConnection(socket, shutdown ?? (() => server.close())));
10447
10770
  const listen = () => {
10448
- if (existsSync15(socketPath)) {
10771
+ if (existsSync16(socketPath)) {
10449
10772
  try {
10450
10773
  unlinkSync2(socketPath);
10451
10774
  } catch {}
10452
10775
  }
10453
10776
  server.listen(socketPath);
10454
10777
  };
10455
- if (!existsSync15(socketPath))
10778
+ if (!existsSync16(socketPath))
10456
10779
  listen();
10457
10780
  else
10458
10781
  requestExistingWorkerShutdown(socketPath).then(listen, (err) => server.emit("error", err));