failproofai 1.0.4 → 1.0.5-beta.1

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 (168) 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 +4 -4
  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.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  50. package/.next/standalone/.next/server/app/project/[name]/page/build-manifest.json +3 -3
  51. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  52. package/.next/standalone/.next/server/app/project/[name]/page.js +2 -2
  53. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  54. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  55. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/build-manifest.json +3 -3
  56. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  57. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  58. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +2 -2
  59. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  60. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  61. package/.next/standalone/.next/server/app/projects/page/build-manifest.json +3 -3
  62. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  63. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  64. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  65. package/.next/standalone/.next/server/app/settings/page/build-manifest.json +3 -3
  66. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -4
  67. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  68. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  69. package/.next/standalone/.next/server/chunks/{[externals]__0-9ti7z._.js → [externals]__1_bftcl._.js} +1 -1
  70. package/.next/standalone/.next/server/chunks/{[externals]__0u3wrvq._.js → [externals]__1msfs-h._.js} +1 -1
  71. package/.next/standalone/.next/server/chunks/[root-of-the-server]__08dchfu._.js +1 -1
  72. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0faqz9x._.js +22 -0
  73. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
  74. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zyc_nm._.js +3 -0
  75. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1p-qi2t._.js → [root-of-the-server]__112b4go._.js} +22 -3
  76. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1l71g3y._.js +22 -0
  77. package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
  78. package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
  79. package/.next/standalone/.next/server/chunks/{_1-akg6w._.js → _1c3k-8x._.js} +2 -2
  80. package/.next/standalone/.next/server/chunks/_1ek68ln._.js +1 -1
  81. package/.next/standalone/.next/server/chunks/lib_openclaw-projects_ts_0gc-p24._.js +3 -0
  82. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
  83. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__00y9ww2._.js +22 -0
  84. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__013jr2b._.js +2 -2
  85. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01wy8d-._.js +2 -2
  86. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02npjtd._.js +2 -2
  87. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__09flfsx._.js → [root-of-the-server]__05g1k7_._.js} +2 -2
  88. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0da85px._.js +2 -2
  89. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ftmoxc._.js +2 -2
  90. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0oa1lav._.js +1 -1
  91. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0p-5p8u._.js +2 -2
  92. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s740oi._.js +2 -2
  93. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0sz_5na._.js +3 -0
  94. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1ctpynv._.js +1 -1
  95. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1kaotix._.js +22 -0
  96. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1p2otjt._.js +2 -2
  97. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1u6sn69._.js +3 -0
  98. package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
  99. package/.next/standalone/.next/server/chunks/ssr/{_02yoeej._.js → _0iv28v5._.js} +1 -1
  100. package/.next/standalone/.next/server/chunks/ssr/{_1if9ixi._.js → _14c6q09._.js} +21 -2
  101. package/.next/standalone/.next/server/chunks/ssr/{_04rbnaq._.js → _17noq1a._.js} +2 -2
  102. package/.next/standalone/.next/server/chunks/ssr/_1u8-lu2._.js +1 -1
  103. package/.next/standalone/.next/server/chunks/ssr/_1zopuov._.js +1 -1
  104. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +2 -2
  105. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
  106. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
  107. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
  108. package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +1 -1
  109. package/.next/standalone/.next/server/chunks/ssr/lib_codex-projects_ts_0pqlw37._.js +1 -1
  110. package/.next/standalone/.next/server/chunks/ssr/lib_openclaw-projects_ts_0qxq3bp._.js +1 -1
  111. package/.next/standalone/.next/server/middleware-build-manifest.js +6 -6
  112. package/.next/standalone/.next/server/pages/404.html +1 -1
  113. package/.next/standalone/.next/server/pages/500.html +1 -1
  114. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  115. package/.next/standalone/.next/server/server-reference-manifest.json +19 -19
  116. package/.next/standalone/.next/static/chunks/{3tjji451hrgc0.js → 074xcclgow3yh.js} +1 -1
  117. package/.next/standalone/.next/static/chunks/{31u94yukw9fz-.js → 0qytob94jbzs6.js} +1 -1
  118. package/.next/standalone/.next/static/chunks/25cn9xpv4r1ow.js +1 -0
  119. package/.next/standalone/.next/static/chunks/{1j6o9min_6qa9.js → 26tf_lpco5n-v.js} +1 -1
  120. package/.next/standalone/.next/static/chunks/{0-tyrpwuc3lla.js → 2b014kj28p0vz.js} +1 -1
  121. package/.next/standalone/.next/static/chunks/{2lwipmv5etc8m.js → 3_fnbc-v5r-9e.js} +1 -1
  122. package/.next/standalone/.next/static/chunks/{1c6aptmytnu6q.js → 3kltzmx9k_t6x.js} +1 -1
  123. package/.next/standalone/.next/static/chunks/{27cl8h-c2w7cd.js → 3pmi7qhtmniku.js} +1 -1
  124. package/.next/standalone/.next/static/chunks/{2u8vh73tpw28_.js → 3q1rji38vuvr4.js} +1 -1
  125. package/.next/standalone/.next/static/chunks/{0ca7octhod0g2.js → 3qxl_gibq3bas.js} +1 -1
  126. package/.next/standalone/.next/static/chunks/{3p9_8x5ezce-9.js → 3vjaz4hld9oo8.js} +1 -1
  127. package/.next/standalone/.next/static/chunks/{2zafgs90r_leq.js → 41ejnuj2d9g7_.js} +1 -1
  128. package/.next/standalone/.next/static/chunks/{turbopack-3p73obe0xmrxm.js → turbopack-1xgsp63yhrdu5.js} +1 -1
  129. package/.next/standalone/fp-cloud-cli/CHANGELOG.md +7 -0
  130. package/.next/standalone/fp-cloud-cli/fp_cli/_version.py +1 -1
  131. package/.next/standalone/lib/download-session.ts +58 -13
  132. package/.next/standalone/lib/openclaw-db.ts +271 -0
  133. package/.next/standalone/lib/openclaw-projects.ts +54 -18
  134. package/.next/standalone/lib/openclaw-sessions.ts +75 -17
  135. package/.next/standalone/package.json +9 -9
  136. package/.next/standalone/sdk/python/CHANGELOG.md +38 -8
  137. package/.next/standalone/sdk/python/failproofai_sdk/_events.py +20 -0
  138. package/.next/standalone/sdk/python/failproofai_sdk/_redact.py +233 -0
  139. package/.next/standalone/sdk/python/failproofai_sdk/_version.py +1 -1
  140. package/.next/standalone/sdk/python/failproofai_sdk/_writer.py +4 -1
  141. package/.next/standalone/sdk/python/failproofai_sdk/integrations/llama_index.py +5 -5
  142. package/.next/standalone/sdk/python/tests/integrations/test_llama_index.py +2 -2
  143. package/.next/standalone/sdk/python/tests/test_redaction.py +140 -0
  144. package/.next/standalone/sdk/python/tests/test_sdk.py +87 -0
  145. package/.next/standalone/sdk/python/tests/test_server_contract.py +60 -0
  146. package/.next/standalone/sdk/python/tests/test_site_docs.py +2 -2
  147. package/.next/standalone/server.js +1 -1
  148. package/dist/cli.mjs +466 -255
  149. package/dist/worker.mjs +301 -90
  150. package/lib/download-session.ts +58 -13
  151. package/lib/openclaw-db.ts +271 -0
  152. package/lib/openclaw-projects.ts +54 -18
  153. package/lib/openclaw-sessions.ts +75 -17
  154. package/openclaw-plugin/index.js +10 -6
  155. package/openclaw-plugin/instruct-retry-gate.js +89 -0
  156. package/package.json +9 -9
  157. package/src/hooks/policy-evaluator.ts +22 -3
  158. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-219ec._.js +0 -3
  159. package/.next/standalone/.next/server/chunks/[root-of-the-server]__04_h-a5._.js +0 -3
  160. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1le9jqc._.js +0 -3
  161. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__00-s7h8._.js +0 -3
  162. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__190won8._.js +0 -3
  163. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1nq7ivq._.js +0 -3
  164. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1sc84bb._.js +0 -3
  165. package/.next/standalone/.next/static/chunks/2pd16tn5qmx13.js +0 -1
  166. /package/.next/standalone/.next/static/{dg8VQ7Ejlo0Qsh_x92oIt → Qexks15mjEoPt6cN3D2jb}/_buildManifest.js +0 -0
  167. /package/.next/standalone/.next/static/{dg8VQ7Ejlo0Qsh_x92oIt → Qexks15mjEoPt6cN3D2jb}/_clientMiddlewareManifest.js +0 -0
  168. /package/.next/standalone/.next/static/{dg8VQ7Ejlo0Qsh_x92oIt → Qexks15mjEoPt6cN3D2jb}/_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.4";
3486
+ var version = "1.0.5-beta.1";
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 {
@@ -6636,13 +6652,169 @@ var init_hermes_projects = __esm(() => {
6636
6652
  getCachedHermesSessionsByEncodedName = runtimeCache((name) => getHermesSessionsByEncodedName(name), 2, { maxSize: 50 });
6637
6653
  });
6638
6654
 
6655
+ // lib/openclaw-db.ts
6656
+ import { existsSync as existsSync9 } from "node:fs";
6657
+ import { join as join13 } from "node:path";
6658
+ function str(value) {
6659
+ return typeof value === "string" && value.length > 0 ? value : undefined;
6660
+ }
6661
+ function parseObject(value) {
6662
+ try {
6663
+ const parsed = JSON.parse(value);
6664
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
6665
+ } catch {
6666
+ return;
6667
+ }
6668
+ }
6669
+ function syntheticPath(agentId, sessionId) {
6670
+ return `openclaw-sqlite://${encodeURIComponent(agentId)}/${sessionId}`;
6671
+ }
6672
+ function listOpenClawDatabases(home, agentIds) {
6673
+ const out = [];
6674
+ for (const agentId of agentIds) {
6675
+ const dbPath = join13(home, "agents", agentId, "agent", DB_NAME);
6676
+ if (existsSync9(dbPath))
6677
+ out.push({ agentId, dbPath });
6678
+ }
6679
+ return out;
6680
+ }
6681
+ function readNodeMetadata(db) {
6682
+ const out = new Map;
6683
+ let rows;
6684
+ try {
6685
+ rows = db.query(`SELECT current_session_id, entry_json, label, display_name
6686
+ FROM session_nodes`);
6687
+ } catch {
6688
+ return out;
6689
+ }
6690
+ for (const row of rows) {
6691
+ const entry = parseObject(row.entry_json) ?? {};
6692
+ const origin = entry.origin && typeof entry.origin === "object" && !Array.isArray(entry.origin) ? entry.origin : {};
6693
+ out.set(row.current_session_id, {
6694
+ channel: str(entry.lastChannel) ?? str(origin.provider) ?? str(origin.surface),
6695
+ label: str(row.label) ?? str(row.display_name) ?? str(entry.displayName) ?? str(origin.label),
6696
+ chatId: str(entry.lastTo) ?? str(origin.from),
6697
+ chatType: str(entry.chatType) ?? str(origin.chatType)
6698
+ });
6699
+ }
6700
+ return out;
6701
+ }
6702
+ function readConversationMetadata(db) {
6703
+ const out = new Map;
6704
+ let rows;
6705
+ try {
6706
+ rows = db.query(`SELECT sc.session_id, c.channel, c.kind, c.peer_id,
6707
+ c.delivery_target, c.label
6708
+ FROM session_conversations sc
6709
+ JOIN conversations c ON c.conversation_id = sc.conversation_id
6710
+ ORDER BY CASE sc.role WHEN 'primary' THEN 0 ELSE 1 END, sc.last_seen_at DESC`);
6711
+ } catch {
6712
+ return out;
6713
+ }
6714
+ for (const row of rows) {
6715
+ if (out.has(row.session_id))
6716
+ continue;
6717
+ out.set(row.session_id, {
6718
+ channel: str(row.channel),
6719
+ label: str(row.label),
6720
+ chatId: str(row.delivery_target) ?? str(row.peer_id),
6721
+ chatType: str(row.kind)
6722
+ });
6723
+ }
6724
+ return out;
6725
+ }
6726
+ async function listOpenClawSqliteSessions(home, agentIds) {
6727
+ const sessions = [];
6728
+ for (const { agentId, dbPath } of listOpenClawDatabases(home, agentIds)) {
6729
+ const db = await openSqliteReadonly(dbPath);
6730
+ if (!db)
6731
+ continue;
6732
+ try {
6733
+ let rows;
6734
+ try {
6735
+ rows = db.query(`SELECT w.session_id, w.session_key, w.updated_at,
6736
+ w.transcript_updated_at, w.ended_at, w.channel,
6737
+ w.chat_type, w.display_name,
6738
+ COALESCE((SELECT MAX(e.created_at)
6739
+ FROM transcript_events e
6740
+ WHERE e.session_id = w.session_id), 0) AS event_updated_at,
6741
+ COALESCE((SELECT SUM(length(e.event_json) + 1)
6742
+ FROM transcript_events e
6743
+ WHERE e.session_id = w.session_id), 0) AS size_bytes
6744
+ FROM session_windows w
6745
+ WHERE EXISTS (SELECT 1 FROM transcript_events e
6746
+ WHERE e.session_id = w.session_id)`);
6747
+ } catch {
6748
+ continue;
6749
+ }
6750
+ const nodes = readNodeMetadata(db);
6751
+ const conversations = readConversationMetadata(db);
6752
+ for (const row of rows) {
6753
+ const node = nodes.get(row.session_id);
6754
+ const conversation = conversations.get(row.session_id);
6755
+ sessions.push({
6756
+ sessionId: row.session_id,
6757
+ agentId,
6758
+ dbPath,
6759
+ transcriptPath: syntheticPath(agentId, row.session_id),
6760
+ 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),
6761
+ sizeBytes: Number(row.size_bytes) || 0,
6762
+ channel: str(row.channel) ?? conversation?.channel ?? node?.channel ?? "local",
6763
+ label: str(row.display_name) ?? conversation?.label ?? node?.label,
6764
+ chatId: conversation?.chatId ?? node?.chatId,
6765
+ chatType: str(row.chat_type) ?? conversation?.chatType ?? node?.chatType
6766
+ });
6767
+ }
6768
+ } finally {
6769
+ db.close();
6770
+ }
6771
+ }
6772
+ return sessions;
6773
+ }
6774
+ async function readOpenClawSqliteTranscript(home, agentIds, sessionId) {
6775
+ for (const { agentId, dbPath } of listOpenClawDatabases(home, agentIds)) {
6776
+ const db = await openSqliteReadonly(dbPath);
6777
+ if (!db)
6778
+ continue;
6779
+ try {
6780
+ let rows;
6781
+ try {
6782
+ rows = db.query(`SELECT event_json
6783
+ FROM transcript_events
6784
+ WHERE session_id = ?
6785
+ ORDER BY seq ASC`, [sessionId]);
6786
+ } catch {
6787
+ continue;
6788
+ }
6789
+ if (rows.length === 0)
6790
+ continue;
6791
+ const eventJsonLines = rows.map((row) => row.event_json);
6792
+ const rawLines = eventJsonLines.map(parseObject).filter((line) => line !== undefined);
6793
+ return {
6794
+ agentId,
6795
+ dbPath,
6796
+ filePath: syntheticPath(agentId, sessionId),
6797
+ rawLines,
6798
+ eventJsonLines
6799
+ };
6800
+ } finally {
6801
+ db.close();
6802
+ }
6803
+ }
6804
+ return null;
6805
+ }
6806
+ var DB_NAME = "openclaw-agent.sqlite";
6807
+ var init_openclaw_db = __esm(() => {
6808
+ init_sqlite_reader();
6809
+ });
6810
+
6639
6811
  // lib/openclaw-sessions.ts
6640
6812
  import { readFile as readFile7 } from "node:fs/promises";
6641
6813
  import { readdirSync as readdirSync4, statSync as statSync6 } from "node:fs";
6642
6814
  import { homedir as homedir11 } from "node:os";
6643
- import { join as join13 } from "node:path";
6815
+ import { join as join14 } from "node:path";
6644
6816
  function openclawHome() {
6645
- return process.env.OPENCLAW_HOME || join13(homedir11(), ".openclaw");
6817
+ return process.env.OPENCLAW_STATE_DIR || process.env.OPENCLAW_HOME || join14(homedir11(), ".openclaw");
6646
6818
  }
6647
6819
  function isPlainObject2(v) {
6648
6820
  return !!v && typeof v === "object" && !Array.isArray(v);
@@ -6729,7 +6901,11 @@ function openclawLinesToLogEntries(lines, source = "session") {
6729
6901
  entries.push({
6730
6902
  type: "assistant",
6731
6903
  ...base,
6732
- message: { role: "assistant", content: blocks, model: typeof m.model === "string" ? m.model : undefined }
6904
+ message: {
6905
+ role: "assistant",
6906
+ content: blocks,
6907
+ model: typeof m.model === "string" ? m.model : undefined
6908
+ }
6733
6909
  });
6734
6910
  continue;
6735
6911
  }
@@ -6757,13 +6933,13 @@ function openclawLinesToLogEntries(lines, source = "session") {
6757
6933
  }
6758
6934
  function listOpenClawAgents() {
6759
6935
  try {
6760
- return readdirSync4(join13(openclawHome(), "agents"), { withFileTypes: true }).filter((d) => d.isDirectory() && !d.name.startsWith(".")).map((d) => d.name).sort();
6936
+ return readdirSync4(join14(openclawHome(), "agents"), { withFileTypes: true }).filter((d) => d.isDirectory() && !d.name.startsWith(".")).map((d) => d.name).sort();
6761
6937
  } catch {
6762
6938
  return [];
6763
6939
  }
6764
6940
  }
6765
6941
  function listOpenClawTranscripts() {
6766
- const agentsDir = join13(openclawHome(), "agents");
6942
+ const agentsDir = join14(openclawHome(), "agents");
6767
6943
  const out = [];
6768
6944
  let agentIds;
6769
6945
  try {
@@ -6772,7 +6948,7 @@ function listOpenClawTranscripts() {
6772
6948
  return out;
6773
6949
  }
6774
6950
  for (const agentId of agentIds) {
6775
- const sessionsDir = join13(agentsDir, agentId, "sessions");
6951
+ const sessionsDir = join14(agentsDir, agentId, "sessions");
6776
6952
  let files;
6777
6953
  try {
6778
6954
  files = readdirSync4(sessionsDir);
@@ -6785,10 +6961,16 @@ function listOpenClawTranscripts() {
6785
6961
  const sessionId = file.slice(0, -".jsonl".length);
6786
6962
  if (!OPENCLAW_SESSION_ID_RE.test(sessionId))
6787
6963
  continue;
6788
- const transcriptPath = join13(sessionsDir, file);
6964
+ const transcriptPath = join14(sessionsDir, file);
6789
6965
  try {
6790
6966
  const st = statSync6(transcriptPath);
6791
- out.push({ agentId, sessionId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
6967
+ out.push({
6968
+ agentId,
6969
+ sessionId,
6970
+ transcriptPath,
6971
+ mtimeMs: st.mtimeMs,
6972
+ sizeBytes: st.size
6973
+ });
6792
6974
  } catch {}
6793
6975
  }
6794
6976
  }
@@ -6804,6 +6986,25 @@ function findOpenClawTranscript(sessionId) {
6804
6986
  return null;
6805
6987
  }
6806
6988
  async function getOpenClawSessionLog(sessionId) {
6989
+ if (!OPENCLAW_SESSION_ID_RE.test(sessionId))
6990
+ return null;
6991
+ const sqlite = await readOpenClawSqliteTranscript(openclawHome(), listOpenClawAgents(), sessionId);
6992
+ if (sqlite) {
6993
+ const entries = openclawLinesToLogEntries(sqlite.rawLines, "session");
6994
+ let cwd;
6995
+ for (const line of sqlite.rawLines) {
6996
+ if (line.type === "session" && typeof line.cwd === "string" && line.cwd.length > 0) {
6997
+ cwd = line.cwd;
6998
+ break;
6999
+ }
7000
+ }
7001
+ return {
7002
+ entries,
7003
+ rawLines: sqlite.rawLines,
7004
+ cwd,
7005
+ filePath: sqlite.filePath
7006
+ };
7007
+ }
6807
7008
  const filePath = findOpenClawTranscript(sessionId);
6808
7009
  if (!filePath)
6809
7010
  return null;
@@ -6827,6 +7028,7 @@ async function getOpenClawSessionLog(sessionId) {
6827
7028
  var OPENCLAW_SESSION_ID_RE, getCachedOpenClawSessionLog;
6828
7029
  var init_openclaw_sessions = __esm(() => {
6829
7030
  init_log_entries();
7031
+ init_openclaw_db();
6830
7032
  OPENCLAW_SESSION_ID_RE = /^[0-9a-fA-F-]{36}$/;
6831
7033
  getCachedOpenClawSessionLog = runtimeCache((sessionId) => getOpenClawSessionLog(sessionId), 2, { maxSize: 50 });
6832
7034
  });
@@ -6837,13 +7039,13 @@ __export(exports_openclaw_projects, {
6837
7039
  getOpenClawProjects: () => getOpenClawProjects
6838
7040
  });
6839
7041
  import { readFileSync as readFileSync7 } from "node:fs";
6840
- import { join as join14 } from "node:path";
6841
- function str(v) {
7042
+ import { join as join15 } from "node:path";
7043
+ function str2(v) {
6842
7044
  return typeof v === "string" && v.length > 0 ? v : undefined;
6843
7045
  }
6844
7046
  function readSessionsIndex(agentId) {
6845
7047
  const out = new Map;
6846
- const indexPath = join14(openclawHome(), "agents", agentId, "sessions", "sessions.json");
7048
+ const indexPath = join15(openclawHome(), "agents", agentId, "sessions", "sessions.json");
6847
7049
  let raw;
6848
7050
  try {
6849
7051
  raw = JSON.parse(readFileSync7(indexPath, "utf-8"));
@@ -6856,17 +7058,17 @@ function readSessionsIndex(agentId) {
6856
7058
  if (!v || typeof v !== "object")
6857
7059
  continue;
6858
7060
  const e = v;
6859
- const sessionId = str(e.sessionId);
7061
+ const sessionId = str2(e.sessionId);
6860
7062
  if (!sessionId)
6861
7063
  continue;
6862
7064
  const origin = e.origin && typeof e.origin === "object" ? e.origin : {};
6863
7065
  const lastMs = typeof e.lastInteractionAt === "number" ? e.lastInteractionAt : typeof e.updatedAt === "number" ? e.updatedAt : undefined;
6864
7066
  out.set(sessionId, {
6865
7067
  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)
7068
+ channel: str2(e.lastChannel) ?? str2(origin.provider) ?? str2(origin.surface),
7069
+ chatType: str2(e.chatType) ?? str2(origin.chatType),
7070
+ label: str2(origin.label),
7071
+ chatId: str2(e.lastTo) ?? str2(origin.from)
6870
7072
  });
6871
7073
  }
6872
7074
  return out;
@@ -6874,7 +7076,7 @@ function readSessionsIndex(agentId) {
6874
7076
  async function getOpenClawSessions() {
6875
7077
  const transcripts = listOpenClawTranscripts();
6876
7078
  const indexByAgent = new Map;
6877
- const refs = [];
7079
+ const refs = new Map;
6878
7080
  for (const t of transcripts) {
6879
7081
  let idx = indexByAgent.get(t.agentId);
6880
7082
  if (!idx) {
@@ -6882,7 +7084,7 @@ async function getOpenClawSessions() {
6882
7084
  indexByAgent.set(t.agentId, idx);
6883
7085
  }
6884
7086
  const meta = idx.get(t.sessionId);
6885
- refs.push({
7087
+ refs.set(`${t.agentId}\x00${t.sessionId}`, {
6886
7088
  sessionId: t.sessionId,
6887
7089
  agentId: t.agentId,
6888
7090
  channel: meta?.channel ?? "local",
@@ -6894,8 +7096,11 @@ async function getOpenClawSessions() {
6894
7096
  sizeBytes: t.sizeBytes
6895
7097
  });
6896
7098
  }
6897
- refs.sort((a, b) => b.mtimeMs - a.mtimeMs);
6898
- return refs;
7099
+ const sqliteSessions = await listOpenClawSqliteSessions(openclawHome(), listOpenClawAgents());
7100
+ for (const s of sqliteSessions) {
7101
+ refs.set(`${s.agentId}\x00${s.sessionId}`, s);
7102
+ }
7103
+ return [...refs.values()].sort((a, b) => b.mtimeMs - a.mtimeMs);
6899
7104
  }
6900
7105
  function openClawProjectName(agentId, channel) {
6901
7106
  return `openclaw-${agentId}-${channel}`;
@@ -6930,7 +7135,12 @@ async function getOpenClawProjects() {
6930
7135
  prev.latest = Math.max(prev.latest, s.mtimeMs);
6931
7136
  prev.count += 1;
6932
7137
  } else {
6933
- groups.set(key, { agentId: s.agentId, channel: s.channel, latest: s.mtimeMs, count: 1 });
7138
+ groups.set(key, {
7139
+ agentId: s.agentId,
7140
+ channel: s.channel,
7141
+ latest: s.mtimeMs,
7142
+ count: 1
7143
+ });
6934
7144
  }
6935
7145
  }
6936
7146
  const out = [];
@@ -6988,6 +7198,7 @@ async function getOpenClawSessionsByEncodedName(name) {
6988
7198
  var getCachedOpenClawSessions, getCachedOpenClawProjects, getCachedOpenClawSessionsByEncodedName;
6989
7199
  var init_openclaw_projects = __esm(() => {
6990
7200
  init_openclaw_sessions();
7201
+ init_openclaw_db();
6991
7202
  getCachedOpenClawSessions = runtimeCache(getOpenClawSessions, 2);
6992
7203
  getCachedOpenClawProjects = runtimeCache(getOpenClawProjects, 2);
6993
7204
  getCachedOpenClawSessionsByEncodedName = runtimeCache((name) => getOpenClawSessionsByEncodedName(name), 2, { maxSize: 50 });
@@ -6997,12 +7208,12 @@ var init_openclaw_projects = __esm(() => {
6997
7208
  import { readFile as readFile8 } from "node:fs/promises";
6998
7209
  import { readdirSync as readdirSync5, statSync as statSync7 } from "node:fs";
6999
7210
  import { homedir as homedir12 } from "node:os";
7000
- import { join as join15 } from "node:path";
7211
+ import { join as join16 } from "node:path";
7001
7212
  function factoryHome() {
7002
- return process.env.FACTORY_HOME || join15(homedir12(), ".factory");
7213
+ return process.env.FACTORY_HOME || join16(homedir12(), ".factory");
7003
7214
  }
7004
7215
  function factorySessionsRoot() {
7005
- return join15(factoryHome(), "sessions");
7216
+ return join16(factoryHome(), "sessions");
7006
7217
  }
7007
7218
  function isPlainObject3(v) {
7008
7219
  return !!v && typeof v === "object" && !Array.isArray(v);
@@ -7148,7 +7359,7 @@ function listFactoryTranscripts() {
7148
7359
  for (const dir of projectDirs) {
7149
7360
  const projectName = dir.name;
7150
7361
  const cwd = decodeFolderName(projectName);
7151
- const projectPath = join15(root, projectName);
7362
+ const projectPath = join16(root, projectName);
7152
7363
  let files;
7153
7364
  try {
7154
7365
  files = readdirSync5(projectPath);
@@ -7161,7 +7372,7 @@ function listFactoryTranscripts() {
7161
7372
  const sessionId = file.slice(0, -".jsonl".length);
7162
7373
  if (!FACTORY_SESSION_ID_RE.test(sessionId))
7163
7374
  continue;
7164
- const transcriptPath = join15(projectPath, file);
7375
+ const transcriptPath = join16(projectPath, file);
7165
7376
  try {
7166
7377
  const st = statSync7(transcriptPath);
7167
7378
  out.push({ projectName, cwd, sessionId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
@@ -7285,12 +7496,12 @@ var init_factory_projects = __esm(() => {
7285
7496
 
7286
7497
  // lib/devin-sessions.ts
7287
7498
  import { homedir as homedir13 } from "node:os";
7288
- import { join as join16 } from "node:path";
7499
+ import { join as join17 } from "node:path";
7289
7500
  function devinHome() {
7290
- return process.env.DEVIN_HOME || join16(homedir13(), ".local", "share", "devin");
7501
+ return process.env.DEVIN_HOME || join17(homedir13(), ".local", "share", "devin");
7291
7502
  }
7292
7503
  function devinDbPath() {
7293
- return process.env.DEVIN_DB_PATH || join16(devinHome(), "cli", "sessions.db");
7504
+ return process.env.DEVIN_DB_PATH || join17(devinHome(), "cli", "sessions.db");
7294
7505
  }
7295
7506
  function devinEpochToMs(value) {
7296
7507
  if (typeof value === "number" && Number.isFinite(value)) {
@@ -7584,15 +7795,15 @@ var init_devin_projects = __esm(() => {
7584
7795
  import { readFile as readFile9 } from "node:fs/promises";
7585
7796
  import { readdirSync as readdirSync6, statSync as statSync8 } from "node:fs";
7586
7797
  import { homedir as homedir14 } from "node:os";
7587
- import { join as join17 } from "node:path";
7798
+ import { join as join18 } from "node:path";
7588
7799
  function antigravityHome() {
7589
- return process.env.ANTIGRAVITY_HOME || join17(homedir14(), ".gemini", "antigravity-cli");
7800
+ return process.env.ANTIGRAVITY_HOME || join18(homedir14(), ".gemini", "antigravity-cli");
7590
7801
  }
7591
7802
  function antigravityBrainRoot() {
7592
- return join17(antigravityHome(), "brain");
7803
+ return join18(antigravityHome(), "brain");
7593
7804
  }
7594
7805
  function antigravityTranscriptRelPath() {
7595
- return join17(".system_generated", "logs", "transcript_full.jsonl");
7806
+ return join18(".system_generated", "logs", "transcript_full.jsonl");
7596
7807
  }
7597
7808
  function isPlainObject5(v) {
7598
7809
  return !!v && typeof v === "object" && !Array.isArray(v);
@@ -7715,7 +7926,7 @@ function listAntigravityTranscripts() {
7715
7926
  const conversationId = dir.name;
7716
7927
  if (!ANTIGRAVITY_CONVERSATION_ID_RE.test(conversationId))
7717
7928
  continue;
7718
- const transcriptPath = join17(root, conversationId, rel);
7929
+ const transcriptPath = join18(root, conversationId, rel);
7719
7930
  try {
7720
7931
  const st = statSync8(transcriptPath);
7721
7932
  if (!st.isFile())
@@ -7728,7 +7939,7 @@ function listAntigravityTranscripts() {
7728
7939
  function findAntigravityTranscript(conversationId) {
7729
7940
  if (!ANTIGRAVITY_CONVERSATION_ID_RE.test(conversationId))
7730
7941
  return null;
7731
- const transcriptPath = join17(antigravityBrainRoot(), conversationId, antigravityTranscriptRelPath());
7942
+ const transcriptPath = join18(antigravityBrainRoot(), conversationId, antigravityTranscriptRelPath());
7732
7943
  try {
7733
7944
  if (statSync8(transcriptPath).isFile())
7734
7945
  return transcriptPath;
@@ -7763,9 +7974,9 @@ var exports_antigravity_projects = {};
7763
7974
  __export(exports_antigravity_projects, {
7764
7975
  getAntigravityProjects: () => getAntigravityProjects
7765
7976
  });
7766
- import { join as join18 } from "node:path";
7977
+ import { join as join19 } from "node:path";
7767
7978
  function antigravitySummariesDbPath() {
7768
- return join18(antigravityHome(), "conversation_summaries.db");
7979
+ return join19(antigravityHome(), "conversation_summaries.db");
7769
7980
  }
7770
7981
  function parseWorkspaceCwd(raw) {
7771
7982
  if (!raw)
@@ -7909,15 +8120,15 @@ var init_antigravity_projects = __esm(() => {
7909
8120
 
7910
8121
  // lib/goose-sessions.ts
7911
8122
  import { homedir as homedir15 } from "node:os";
7912
- import { join as join19 } from "node:path";
8123
+ import { join as join20 } from "node:path";
7913
8124
  function gooseHome() {
7914
8125
  if (process.env.GOOSE_HOME)
7915
8126
  return process.env.GOOSE_HOME;
7916
8127
  const xdg = process.env.XDG_DATA_HOME;
7917
- return join19(xdg && xdg.length > 0 ? xdg : join19(homedir15(), ".local", "share"), "goose");
8128
+ return join20(xdg && xdg.length > 0 ? xdg : join20(homedir15(), ".local", "share"), "goose");
7918
8129
  }
7919
8130
  function gooseDbPath() {
7920
- return process.env.GOOSE_DB_PATH || join19(gooseHome(), "sessions", "sessions.db");
8131
+ return process.env.GOOSE_DB_PATH || join20(gooseHome(), "sessions", "sessions.db");
7921
8132
  }
7922
8133
  function gooseTimestampToMs(value) {
7923
8134
  if (typeof value === "number" && Number.isFinite(value)) {
@@ -8180,7 +8391,7 @@ var init_goose_projects = __esm(() => {
8180
8391
 
8181
8392
  // lib/projects.ts
8182
8393
  import { readdir as readdir5, stat as stat4 } from "node:fs/promises";
8183
- import { join as join20, resolve as resolve9, sep } from "node:path";
8394
+ import { join as join21, resolve as resolve9, sep } from "node:path";
8184
8395
  async function getMtime(path, label) {
8185
8396
  try {
8186
8397
  return (await stat4(path)).mtime;
@@ -8206,7 +8417,7 @@ async function getClaudeProjectFolders() {
8206
8417
  if (!entries)
8207
8418
  return [];
8208
8419
  const settled = await batchAll(entries.filter((entry) => entry.isDirectory()).map((entry) => async () => {
8209
- const folderPath = join20(projectsPath, entry.name);
8420
+ const folderPath = join21(projectsPath, entry.name);
8210
8421
  const mtime = await getMtime(folderPath, entry.name);
8211
8422
  return {
8212
8423
  name: entry.name,
@@ -8333,7 +8544,7 @@ function resolveProjectPath(projectName) {
8333
8544
  if (/^[/\\]/.test(projectName))
8334
8545
  throw new RangeError("Absolute project name");
8335
8546
  const projectsPath = resolve9(getClaudeProjectsPath());
8336
- const candidate = resolve9(join20(projectsPath, projectName));
8547
+ const candidate = resolve9(join21(projectsPath, projectName));
8337
8548
  if (!candidate.startsWith(projectsPath + sep)) {
8338
8549
  throw new RangeError("Project path escapes root");
8339
8550
  }
@@ -8351,7 +8562,7 @@ async function getSessionFiles(projectPath) {
8351
8562
  return [];
8352
8563
  const jsonlEntries = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl") && extractSessionId2(entry.name));
8353
8564
  const settled = await batchAll(jsonlEntries.map((entry) => async () => {
8354
- const filePath = join20(projectPath, entry.name);
8565
+ const filePath = join21(projectPath, entry.name);
8355
8566
  const mtime = await getMtime(filePath, entry.name);
8356
8567
  return {
8357
8568
  name: entry.name,
@@ -8380,13 +8591,13 @@ var init_projects = __esm(() => {
8380
8591
 
8381
8592
  // lib/resolve-subagent-path.ts
8382
8593
  import { access as access2 } from "fs/promises";
8383
- import { join as join21, relative as relative3 } from "path";
8594
+ import { join as join22, relative as relative3 } from "path";
8384
8595
  async function resolveSubagentPath(projectsPath, projectName, sessionId, agentId) {
8385
8596
  const fileName = `agent-${agentId}.jsonl`;
8386
8597
  const candidatePaths = [
8387
- join21(projectsPath, projectName, fileName),
8388
- join21(projectsPath, projectName, sessionId, fileName),
8389
- join21(projectsPath, projectName, sessionId, "subagents", fileName)
8598
+ join22(projectsPath, projectName, fileName),
8599
+ join22(projectsPath, projectName, sessionId, fileName),
8600
+ join22(projectsPath, projectName, sessionId, "subagents", fileName)
8390
8601
  ];
8391
8602
  for (const candidatePath of candidatePaths) {
8392
8603
  if (relative3(projectsPath, candidatePath).startsWith("..")) {
@@ -8408,7 +8619,7 @@ var init_resolve_subagent_path = () => {};
8408
8619
 
8409
8620
  // lib/log-entries.ts
8410
8621
  import { readFile as readFile10 } from "fs/promises";
8411
- import { join as join22 } from "path";
8622
+ import { join as join23 } from "path";
8412
8623
  function formatTimestamp(date) {
8413
8624
  const base = formatDate(date);
8414
8625
  const ms = date.getMilliseconds().toString().padStart(3, "0");
@@ -8602,7 +8813,7 @@ async function parseFileContent(fileContent, source) {
8602
8813
  async function parseSessionLog(projectName, sessionId) {
8603
8814
  const projectDir = resolveProjectPath(projectName);
8604
8815
  const projectsPath = getClaudeProjectsPath();
8605
- const filePath = join22(projectDir, `${sessionId}.jsonl`);
8816
+ const filePath = join23(projectDir, `${sessionId}.jsonl`);
8606
8817
  const fileContent = await readFile10(filePath, "utf-8");
8607
8818
  const { entries: sessionEntries, rawLines: sessionRawLines, subagentIds } = await parseFileContent(fileContent, "session");
8608
8819
  if (subagentIds.length === 0) {
@@ -8639,13 +8850,13 @@ var init_log_entries = __esm(() => {
8639
8850
  });
8640
8851
 
8641
8852
  // 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";
8853
+ import { readFileSync as readFileSync8, readdirSync as readdirSync7, existsSync as existsSync10, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, statSync as statSync9 } from "node:fs";
8643
8854
  import { readFile as readFile11 } from "node:fs/promises";
8644
- import { dirname as dirname4, join as join23 } from "node:path";
8855
+ import { dirname as dirname4, join as join24 } from "node:path";
8645
8856
  import { homedir as homedir16 } from "node:os";
8646
8857
  function readCache() {
8647
8858
  try {
8648
- if (!existsSync9(CACHE_PATH))
8859
+ if (!existsSync10(CACHE_PATH))
8649
8860
  return {};
8650
8861
  return JSON.parse(readFileSync8(CACHE_PATH, "utf-8"));
8651
8862
  } catch {
@@ -8664,7 +8875,7 @@ function dirSearch(dir, sessionId) {
8664
8875
  try {
8665
8876
  for (const f of readdirSync7(dir, { withFileTypes: true })) {
8666
8877
  if (f.isFile() && f.name.includes(sessionId) && f.name.endsWith(".jsonl")) {
8667
- return join23(dir, f.name);
8878
+ return join24(dir, f.name);
8668
8879
  }
8669
8880
  }
8670
8881
  } catch {}
@@ -8673,16 +8884,16 @@ function dirSearch(dir, sessionId) {
8673
8884
  function findCodexTranscript(sessionId) {
8674
8885
  const cache = readCache();
8675
8886
  const cached = cache[sessionId];
8676
- if (cached && existsSync9(cached))
8887
+ if (cached && existsSync10(cached))
8677
8888
  return cached;
8678
- const root = join23(homedir16(), ".codex", "sessions");
8889
+ const root = join24(homedir16(), ".codex", "sessions");
8679
8890
  const today = new Date;
8680
8891
  const yesterday = new Date(today.getTime() - 24 * 60 * 60 * 1000);
8681
8892
  const datedDirs = [today, yesterday].map((d) => {
8682
8893
  const y = String(d.getUTCFullYear());
8683
8894
  const m = String(d.getUTCMonth() + 1).padStart(2, "0");
8684
8895
  const day = String(d.getUTCDate()).padStart(2, "0");
8685
- return join23(root, y, m, day);
8896
+ return join24(root, y, m, day);
8686
8897
  });
8687
8898
  for (const dir of datedDirs) {
8688
8899
  const hit = dirSearch(dir, sessionId);
@@ -8695,13 +8906,13 @@ function findCodexTranscript(sessionId) {
8695
8906
  for (const y of readdirSync7(root, { withFileTypes: true })) {
8696
8907
  if (!y.isDirectory())
8697
8908
  continue;
8698
- for (const m of readdirSync7(join23(root, y.name), { withFileTypes: true })) {
8909
+ for (const m of readdirSync7(join24(root, y.name), { withFileTypes: true })) {
8699
8910
  if (!m.isDirectory())
8700
8911
  continue;
8701
- for (const d of readdirSync7(join23(root, y.name, m.name), { withFileTypes: true })) {
8912
+ for (const d of readdirSync7(join24(root, y.name, m.name), { withFileTypes: true })) {
8702
8913
  if (!d.isDirectory())
8703
8914
  continue;
8704
- const hit = dirSearch(join23(root, y.name, m.name, d.name), sessionId);
8915
+ const hit = dirSearch(join24(root, y.name, m.name, d.name), sessionId);
8705
8916
  if (hit) {
8706
8917
  writeCacheEntry(sessionId, hit);
8707
8918
  return hit;
@@ -8967,15 +9178,15 @@ var init_resolve_permission_mode = __esm(() => {
8967
9178
  });
8968
9179
 
8969
9180
  // lib/copilot-sessions.ts
8970
- import { readFileSync as readFileSync10, readdirSync as readdirSync8, existsSync as existsSync10, statSync as statSync10 } from "node:fs";
9181
+ import { readFileSync as readFileSync10, readdirSync as readdirSync8, existsSync as existsSync11, statSync as statSync10 } from "node:fs";
8971
9182
  import { readFile as readFile12 } from "node:fs/promises";
8972
- import { join as join24, resolve as resolve10, sep as sep2 } from "node:path";
9183
+ import { join as join25, resolve as resolve10, sep as sep2 } from "node:path";
8973
9184
  import { homedir as homedir17 } from "node:os";
8974
9185
  function getCopilotHome() {
8975
- return process.env.COPILOT_HOME || join24(homedir17(), ".copilot");
9186
+ return process.env.COPILOT_HOME || join25(homedir17(), ".copilot");
8976
9187
  }
8977
9188
  function getCopilotSessionStateRoot2() {
8978
- return join24(getCopilotHome(), "session-state");
9189
+ return join25(getCopilotHome(), "session-state");
8979
9190
  }
8980
9191
  function getCopilotSessionDir(sessionId) {
8981
9192
  if (!sessionId)
@@ -8990,19 +9201,19 @@ function resolveSessionFile(sessionId, filename) {
8990
9201
  const dir = getCopilotSessionDir(sessionId);
8991
9202
  if (!dir)
8992
9203
  return null;
8993
- return join24(dir, filename);
9204
+ return join25(dir, filename);
8994
9205
  }
8995
9206
  function findCopilotTranscript(sessionId) {
8996
9207
  const candidate = resolveSessionFile(sessionId, "events.jsonl");
8997
9208
  if (!candidate)
8998
9209
  return null;
8999
- return existsSync10(candidate) ? candidate : null;
9210
+ return existsSync11(candidate) ? candidate : null;
9000
9211
  }
9001
9212
  function findCopilotWorkspace(sessionId) {
9002
9213
  const candidate = resolveSessionFile(sessionId, "workspace.yaml");
9003
9214
  if (!candidate)
9004
9215
  return null;
9005
- return existsSync10(candidate) ? candidate : null;
9216
+ return existsSync11(candidate) ? candidate : null;
9006
9217
  }
9007
9218
  function readYamlScalar(path, key) {
9008
9219
  try {
@@ -9184,12 +9395,12 @@ var init_copilot_sessions = __esm(() => {
9184
9395
  });
9185
9396
 
9186
9397
  // lib/cursor-sessions.ts
9187
- import { readFileSync as readFileSync11, readdirSync as readdirSync9, existsSync as existsSync11, statSync as statSync11 } from "node:fs";
9398
+ import { readFileSync as readFileSync11, readdirSync as readdirSync9, existsSync as existsSync12, statSync as statSync11 } from "node:fs";
9188
9399
  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";
9400
+ import { basename as basename3, join as join26, resolve as resolve11, sep as sep3 } from "node:path";
9190
9401
  import { homedir as homedir18 } from "node:os";
9191
9402
  function getCursorHome2() {
9192
- return process.env.CURSOR_HOME || join25(homedir18(), ".cursor");
9403
+ return process.env.CURSOR_HOME || join26(homedir18(), ".cursor");
9193
9404
  }
9194
9405
  function getCursorSessionDir(sessionId) {
9195
9406
  if (!sessionId)
@@ -9207,7 +9418,7 @@ function getCursorSessionDir(sessionId) {
9207
9418
  const transcriptRoot = resolve11(projectsRoot, entry.name, NEW_AGENT_TRANSCRIPTS_DIR2);
9208
9419
  if (candidate === transcriptRoot || !candidate.startsWith(`${transcriptRoot}${sep3}`))
9209
9420
  continue;
9210
- if (existsSync11(candidate))
9421
+ if (existsSync12(candidate))
9211
9422
  return candidate;
9212
9423
  }
9213
9424
  for (const sub of LEGACY_SESSION_ROOT_CANDIDATES2) {
@@ -9215,7 +9426,7 @@ function getCursorSessionDir(sessionId) {
9215
9426
  const candidate = resolve11(root, sessionId);
9216
9427
  if (candidate === root || !candidate.startsWith(`${root}${sep3}`))
9217
9428
  continue;
9218
- if (existsSync11(candidate))
9429
+ if (existsSync12(candidate))
9219
9430
  return candidate;
9220
9431
  }
9221
9432
  return null;
@@ -9224,12 +9435,12 @@ function findCursorTranscript(sessionId) {
9224
9435
  const dir = getCursorSessionDir(sessionId);
9225
9436
  if (!dir)
9226
9437
  return null;
9227
- const newCandidate = join25(dir, `${basename3(dir)}.jsonl`);
9228
- if (existsSync11(newCandidate))
9438
+ const newCandidate = join26(dir, `${basename3(dir)}.jsonl`);
9439
+ if (existsSync12(newCandidate))
9229
9440
  return newCandidate;
9230
9441
  for (const name of LEGACY_TRANSCRIPT_FILE_CANDIDATES2) {
9231
- const candidate = join25(dir, name);
9232
- if (existsSync11(candidate))
9442
+ const candidate = join26(dir, name);
9443
+ if (existsSync12(candidate))
9233
9444
  return candidate;
9234
9445
  }
9235
9446
  return null;
@@ -9440,12 +9651,12 @@ var init_cursor_sessions = __esm(() => {
9440
9651
  });
9441
9652
 
9442
9653
  // lib/pi-sessions.ts
9443
- import { readFileSync as readFileSync12, readdirSync as readdirSync10, existsSync as existsSync12, statSync as statSync12 } from "node:fs";
9654
+ import { readFileSync as readFileSync12, readdirSync as readdirSync10, existsSync as existsSync13, statSync as statSync12 } from "node:fs";
9444
9655
  import { readFile as readFile14 } from "node:fs/promises";
9445
- import { join as join26, resolve as resolve12, sep as sep4 } from "node:path";
9656
+ import { join as join27, resolve as resolve12, sep as sep4 } from "node:path";
9446
9657
  import { homedir as homedir19 } from "node:os";
9447
9658
  function getPiSessionStateRoot() {
9448
- return process.env.PI_SESSIONS_DIR || join26(homedir19(), ".pi", "agent", "sessions");
9659
+ return process.env.PI_SESSIONS_DIR || join27(homedir19(), ".pi", "agent", "sessions");
9449
9660
  }
9450
9661
  function isSafeSessionId(sessionId) {
9451
9662
  return UUID_RE.test(sessionId);
@@ -9477,7 +9688,7 @@ function findPiTranscript(sessionId) {
9477
9688
  const candidate = resolve12(cwdPath, f);
9478
9689
  if (!candidate.startsWith(`${cwdPath}${sep4}`))
9479
9690
  continue;
9480
- if (existsSync12(candidate))
9691
+ if (existsSync13(candidate))
9481
9692
  return candidate;
9482
9693
  }
9483
9694
  }
@@ -9837,9 +10048,9 @@ var init_pack_failclosed = __esm(() => {
9837
10048
  var init_atomic_write = () => {};
9838
10049
 
9839
10050
  // 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";
10051
+ import { existsSync as existsSync14, mkdirSync as mkdirSync6, readdirSync as readdirSync11, readFileSync as readFileSync13, rmSync as rmSync2 } from "node:fs";
9841
10052
  import { createHash as createHash5 } from "node:crypto";
9842
- import { join as join27, resolve as resolve13 } from "node:path";
10053
+ import { join as join28, resolve as resolve13 } from "node:path";
9843
10054
  function pauseStateDir() {
9844
10055
  const override = process.env.FAILPROOFAI_STATE_DIR;
9845
10056
  if (override)
@@ -9848,7 +10059,7 @@ function pauseStateDir() {
9848
10059
  }
9849
10060
  function pauseFilePath(sessionId) {
9850
10061
  const digest = createHash5("sha256").update(sessionId).digest("hex").slice(0, 32);
9851
- return join27(pauseStateDir(), `${digest}.json`);
10062
+ return join28(pauseStateDir(), `${digest}.json`);
9852
10063
  }
9853
10064
  function parseStored(raw) {
9854
10065
  if (!raw || typeof raw !== "object")
@@ -9877,7 +10088,7 @@ function readActivePause(sessionId, now = Date.now()) {
9877
10088
  return null;
9878
10089
  try {
9879
10090
  const path = pauseFilePath(sessionId);
9880
- if (!existsSync13(path))
10091
+ if (!existsSync14(path))
9881
10092
  return null;
9882
10093
  const stored = parseStored(JSON.parse(readFileSync13(path, "utf8")));
9883
10094
  if (!stored)
@@ -9918,7 +10129,7 @@ var init_daemon_service = __esm(() => {
9918
10129
  // src/hooks/fp-reset.ts
9919
10130
  import {
9920
10131
  copyFileSync,
9921
- existsSync as existsSync14,
10132
+ existsSync as existsSync15,
9922
10133
  mkdirSync as mkdirSync7,
9923
10134
  readFileSync as readFileSync14,
9924
10135
  readdirSync as readdirSync12,
@@ -9935,7 +10146,7 @@ function layoutWarningForHook() {
9935
10146
  if (state.kind === "future") {
9936
10147
  return `[failproofai] this directory was written by a newer version (layout ${state.found} vs ${LAYOUT_VERSION}) — policies are NOT being enforced. ` + `Upgrade failproofai.`;
9937
10148
  }
9938
- if (existsSync14(globalPolicyConfigFile()))
10149
+ if (existsSync15(globalPolicyConfigFile()))
9939
10150
  return null;
9940
10151
  return `[failproofai] setup predates this version — global policies are NOT being enforced. ` + `Run \`failproofai config\` to re-create it.`;
9941
10152
  }
@@ -10312,7 +10523,7 @@ var init_handler = __esm(() => {
10312
10523
 
10313
10524
  // src/hooks/worker-server.ts
10314
10525
  import { createConnection, createServer } from "node:net";
10315
- import { existsSync as existsSync15, unlinkSync as unlinkSync2 } from "node:fs";
10526
+ import { existsSync as existsSync16, unlinkSync as unlinkSync2 } from "node:fs";
10316
10527
  function isWorkerHookRequest(msg) {
10317
10528
  if (!msg || typeof msg !== "object")
10318
10529
  return false;
@@ -10445,14 +10656,14 @@ function requestExistingWorkerShutdown(socketPath) {
10445
10656
  function startWorkerServer(socketPath, shutdown) {
10446
10657
  const server = createServer((socket) => handleConnection(socket, shutdown ?? (() => server.close())));
10447
10658
  const listen = () => {
10448
- if (existsSync15(socketPath)) {
10659
+ if (existsSync16(socketPath)) {
10449
10660
  try {
10450
10661
  unlinkSync2(socketPath);
10451
10662
  } catch {}
10452
10663
  }
10453
10664
  server.listen(socketPath);
10454
10665
  };
10455
- if (!existsSync15(socketPath))
10666
+ if (!existsSync16(socketPath))
10456
10667
  listen();
10457
10668
  else
10458
10669
  requestExistingWorkerShutdown(socketPath).then(listen, (err) => server.emit("error", err));