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.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +6 -6
- package/.next/standalone/.next/prerender-manifest.json +4 -4
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +14 -14
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/run/route.js +4 -4
- package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +14 -14
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +13 -13
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +14 -14
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js +2 -2
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -4
- package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/{[externals]__0-9ti7z._.js → [externals]__1_bftcl._.js} +1 -1
- package/.next/standalone/.next/server/chunks/{[externals]__0u3wrvq._.js → [externals]__1msfs-h._.js} +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__08dchfu._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0faqz9x._.js +22 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zyc_nm._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1p-qi2t._.js → [root-of-the-server]__112b4go._.js} +22 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1l71g3y._.js +22 -0
- package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
- package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
- package/.next/standalone/.next/server/chunks/{_1-akg6w._.js → _1c3k-8x._.js} +2 -2
- package/.next/standalone/.next/server/chunks/_1ek68ln._.js +1 -1
- package/.next/standalone/.next/server/chunks/lib_openclaw-projects_ts_0gc-p24._.js +3 -0
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__00y9ww2._.js +22 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__013jr2b._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01wy8d-._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02npjtd._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__09flfsx._.js → [root-of-the-server]__05g1k7_._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0da85px._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ftmoxc._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0oa1lav._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0p-5p8u._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s740oi._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0sz_5na._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1ctpynv._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1kaotix._.js +22 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1p2otjt._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1u6sn69._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_02yoeej._.js → _0iv28v5._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_1if9ixi._.js → _14c6q09._.js} +21 -2
- package/.next/standalone/.next/server/chunks/ssr/{_04rbnaq._.js → _17noq1a._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_1u8-lu2._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1zopuov._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/lib_codex-projects_ts_0pqlw37._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/lib_openclaw-projects_ts_0qxq3bp._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +6 -6
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +19 -19
- package/.next/standalone/.next/static/chunks/{3tjji451hrgc0.js → 074xcclgow3yh.js} +1 -1
- package/.next/standalone/.next/static/chunks/{31u94yukw9fz-.js → 0qytob94jbzs6.js} +1 -1
- package/.next/standalone/.next/static/chunks/25cn9xpv4r1ow.js +1 -0
- package/.next/standalone/.next/static/chunks/{1j6o9min_6qa9.js → 26tf_lpco5n-v.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0-tyrpwuc3lla.js → 2b014kj28p0vz.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2lwipmv5etc8m.js → 3_fnbc-v5r-9e.js} +1 -1
- package/.next/standalone/.next/static/chunks/{1c6aptmytnu6q.js → 3kltzmx9k_t6x.js} +1 -1
- package/.next/standalone/.next/static/chunks/{27cl8h-c2w7cd.js → 3pmi7qhtmniku.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2u8vh73tpw28_.js → 3q1rji38vuvr4.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0ca7octhod0g2.js → 3qxl_gibq3bas.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3p9_8x5ezce-9.js → 3vjaz4hld9oo8.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2zafgs90r_leq.js → 41ejnuj2d9g7_.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-3p73obe0xmrxm.js → turbopack-1xgsp63yhrdu5.js} +1 -1
- package/.next/standalone/fp-cloud-cli/CHANGELOG.md +7 -0
- package/.next/standalone/fp-cloud-cli/fp_cli/_version.py +1 -1
- package/.next/standalone/lib/download-session.ts +58 -13
- package/.next/standalone/lib/openclaw-db.ts +271 -0
- package/.next/standalone/lib/openclaw-projects.ts +54 -18
- package/.next/standalone/lib/openclaw-sessions.ts +75 -17
- package/.next/standalone/package.json +9 -9
- package/.next/standalone/sdk/python/CHANGELOG.md +38 -8
- package/.next/standalone/sdk/python/failproofai_sdk/_events.py +20 -0
- package/.next/standalone/sdk/python/failproofai_sdk/_redact.py +233 -0
- package/.next/standalone/sdk/python/failproofai_sdk/_version.py +1 -1
- package/.next/standalone/sdk/python/failproofai_sdk/_writer.py +4 -1
- package/.next/standalone/sdk/python/failproofai_sdk/integrations/llama_index.py +5 -5
- package/.next/standalone/sdk/python/tests/integrations/test_llama_index.py +2 -2
- package/.next/standalone/sdk/python/tests/test_redaction.py +140 -0
- package/.next/standalone/sdk/python/tests/test_sdk.py +87 -0
- package/.next/standalone/sdk/python/tests/test_server_contract.py +60 -0
- package/.next/standalone/sdk/python/tests/test_site_docs.py +2 -2
- package/.next/standalone/server.js +1 -1
- package/dist/cli.mjs +466 -255
- package/dist/worker.mjs +301 -90
- package/lib/download-session.ts +58 -13
- package/lib/openclaw-db.ts +271 -0
- package/lib/openclaw-projects.ts +54 -18
- package/lib/openclaw-sessions.ts +75 -17
- package/openclaw-plugin/index.js +10 -6
- package/openclaw-plugin/instruct-retry-gate.js +89 -0
- package/package.json +9 -9
- package/src/hooks/policy-evaluator.ts +22 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-219ec._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__04_h-a5._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1le9jqc._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__00-s7h8._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__190won8._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1nq7ivq._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1sc84bb._.js +0 -3
- package/.next/standalone/.next/static/chunks/2pd16tn5qmx13.js +0 -1
- /package/.next/standalone/.next/static/{dg8VQ7Ejlo0Qsh_x92oIt → Qexks15mjEoPt6cN3D2jb}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{dg8VQ7Ejlo0Qsh_x92oIt → Qexks15mjEoPt6cN3D2jb}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{dg8VQ7Ejlo0Qsh_x92oIt → Qexks15mjEoPt6cN3D2jb}/_ssgManifest.js +0 -0
package/lib/download-session.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Per-CLI dispatcher for the dashboard's Download Logs endpoint.
|
|
3
3
|
*
|
|
4
4
|
* Returns either a real on-disk path (so the route can `createReadStream` and
|
|
5
|
-
* stream the bytes verbatim) or a synthesized JSONL body
|
|
6
|
-
*
|
|
5
|
+
* stream the bytes verbatim) or a synthesized JSON/JSONL body for agents whose
|
|
6
|
+
* transcripts live in SQLite.
|
|
7
7
|
*
|
|
8
8
|
* Per-CLI session loaders / transcript finders already exist in their own
|
|
9
9
|
* files; this module is the thin glue that picks the right one. Imports of
|
|
@@ -34,7 +34,12 @@ export const GOOSE_SESSION_RE = /^\d{8}_\d+$/;
|
|
|
34
34
|
|
|
35
35
|
export type DownloadSource =
|
|
36
36
|
| { kind: "file"; path: string }
|
|
37
|
-
| {
|
|
37
|
+
| {
|
|
38
|
+
kind: "synthesized";
|
|
39
|
+
body: string;
|
|
40
|
+
contentType: string;
|
|
41
|
+
extension: string;
|
|
42
|
+
};
|
|
38
43
|
|
|
39
44
|
/** Validate a session ID against the per-CLI shape. OpenCode uses `ses_*`
|
|
40
45
|
* prefixes; everyone else is a UUID. */
|
|
@@ -98,7 +103,12 @@ export async function resolveDownloadSource(
|
|
|
98
103
|
const result = await getOpenCodeSessionExport(sessionId);
|
|
99
104
|
if (!result) return null;
|
|
100
105
|
const body = JSON.stringify(result, null, 2) + "\n";
|
|
101
|
-
return {
|
|
106
|
+
return {
|
|
107
|
+
kind: "synthesized",
|
|
108
|
+
body,
|
|
109
|
+
contentType: "application/json",
|
|
110
|
+
extension: "json",
|
|
111
|
+
};
|
|
102
112
|
}
|
|
103
113
|
|
|
104
114
|
if (cli === "hermes") {
|
|
@@ -107,13 +117,35 @@ export async function resolveDownloadSource(
|
|
|
107
117
|
const { getHermesSessionLog } = await import("./hermes-sessions");
|
|
108
118
|
const result = await getHermesSessionLog(sessionId);
|
|
109
119
|
if (!result) return null;
|
|
110
|
-
const body =
|
|
111
|
-
|
|
120
|
+
const body =
|
|
121
|
+
result.rawLines.map((r) => JSON.stringify(r)).join("\n") + "\n";
|
|
122
|
+
return {
|
|
123
|
+
kind: "synthesized",
|
|
124
|
+
body,
|
|
125
|
+
contentType: "application/x-ndjson",
|
|
126
|
+
extension: "jsonl",
|
|
127
|
+
};
|
|
112
128
|
}
|
|
113
129
|
|
|
114
130
|
if (cli === "openclaw") {
|
|
115
|
-
// OpenClaw
|
|
116
|
-
|
|
131
|
+
// New OpenClaw versions keep live transcripts in SQLite. Export the exact
|
|
132
|
+
// event_json rows as JSONL; fall back to streaming archived JSONL files.
|
|
133
|
+
const { findOpenClawTranscript, listOpenClawAgents, openclawHome } =
|
|
134
|
+
await import("./openclaw-sessions");
|
|
135
|
+
const { readOpenClawSqliteTranscript } = await import("./openclaw-db");
|
|
136
|
+
const sqlite = await readOpenClawSqliteTranscript(
|
|
137
|
+
openclawHome(),
|
|
138
|
+
listOpenClawAgents(),
|
|
139
|
+
sessionId,
|
|
140
|
+
);
|
|
141
|
+
if (sqlite) {
|
|
142
|
+
return {
|
|
143
|
+
kind: "synthesized",
|
|
144
|
+
body: sqlite.eventJsonLines.join("\n") + "\n",
|
|
145
|
+
contentType: "application/x-ndjson",
|
|
146
|
+
extension: "jsonl",
|
|
147
|
+
};
|
|
148
|
+
}
|
|
117
149
|
const path = findOpenClawTranscript(sessionId);
|
|
118
150
|
return path ? { kind: "file", path } : null;
|
|
119
151
|
}
|
|
@@ -131,13 +163,20 @@ export async function resolveDownloadSource(
|
|
|
131
163
|
const { getDevinSessionLog } = await import("./devin-sessions");
|
|
132
164
|
const result = await getDevinSessionLog(sessionId);
|
|
133
165
|
if (!result) return null;
|
|
134
|
-
const body =
|
|
135
|
-
|
|
166
|
+
const body =
|
|
167
|
+
result.rawLines.map((r) => JSON.stringify(r)).join("\n") + "\n";
|
|
168
|
+
return {
|
|
169
|
+
kind: "synthesized",
|
|
170
|
+
body,
|
|
171
|
+
contentType: "application/x-ndjson",
|
|
172
|
+
extension: "jsonl",
|
|
173
|
+
};
|
|
136
174
|
}
|
|
137
175
|
|
|
138
176
|
if (cli === "antigravity") {
|
|
139
177
|
// Antigravity (agy) writes real JSONL transcripts on disk — stream verbatim.
|
|
140
|
-
const { findAntigravityTranscript } =
|
|
178
|
+
const { findAntigravityTranscript } =
|
|
179
|
+
await import("./antigravity-sessions");
|
|
141
180
|
const path = findAntigravityTranscript(sessionId);
|
|
142
181
|
return path ? { kind: "file", path } : null;
|
|
143
182
|
}
|
|
@@ -148,8 +187,14 @@ export async function resolveDownloadSource(
|
|
|
148
187
|
const { getGooseSessionLog } = await import("./goose-sessions");
|
|
149
188
|
const result = await getGooseSessionLog(sessionId);
|
|
150
189
|
if (!result) return null;
|
|
151
|
-
const body =
|
|
152
|
-
|
|
190
|
+
const body =
|
|
191
|
+
result.rawLines.map((r) => JSON.stringify(r)).join("\n") + "\n";
|
|
192
|
+
return {
|
|
193
|
+
kind: "synthesized",
|
|
194
|
+
body,
|
|
195
|
+
contentType: "application/x-ndjson",
|
|
196
|
+
extension: "jsonl",
|
|
197
|
+
};
|
|
153
198
|
}
|
|
154
199
|
|
|
155
200
|
// Exhaustive — but TypeScript can't always see CliId is exhausted across the
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read OpenClaw 2026.9.2+ transcripts from the per-agent SQLite databases at
|
|
3
|
+
* `agents/<agentId>/agent/openclaw-agent.sqlite`.
|
|
4
|
+
*
|
|
5
|
+
* `event_json` is the exact logical JSONL record, so the dashboard can feed it
|
|
6
|
+
* through the same parser and download format used by archived JSONL files.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { openSqliteReadonly, type SqliteReader } from "./sqlite-reader";
|
|
11
|
+
|
|
12
|
+
const DB_NAME = "openclaw-agent.sqlite";
|
|
13
|
+
|
|
14
|
+
export interface OpenClawSqliteSession {
|
|
15
|
+
sessionId: string;
|
|
16
|
+
agentId: string;
|
|
17
|
+
dbPath: string;
|
|
18
|
+
transcriptPath: string;
|
|
19
|
+
mtimeMs: number;
|
|
20
|
+
sizeBytes: number;
|
|
21
|
+
channel: string;
|
|
22
|
+
label?: string;
|
|
23
|
+
chatId?: string;
|
|
24
|
+
chatType?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface OpenClawSqliteTranscript {
|
|
28
|
+
agentId: string;
|
|
29
|
+
dbPath: string;
|
|
30
|
+
filePath: string;
|
|
31
|
+
rawLines: Record<string, unknown>[];
|
|
32
|
+
eventJsonLines: string[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface WindowRow {
|
|
36
|
+
session_id: string;
|
|
37
|
+
session_key: string;
|
|
38
|
+
updated_at: number;
|
|
39
|
+
transcript_updated_at: number | null;
|
|
40
|
+
ended_at: number | null;
|
|
41
|
+
channel: string | null;
|
|
42
|
+
chat_type: string | null;
|
|
43
|
+
display_name: string | null;
|
|
44
|
+
event_updated_at: number;
|
|
45
|
+
size_bytes: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface NodeRow {
|
|
49
|
+
current_session_id: string;
|
|
50
|
+
entry_json: string;
|
|
51
|
+
label: string | null;
|
|
52
|
+
display_name: string | null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
interface ConversationRow {
|
|
56
|
+
session_id: string;
|
|
57
|
+
channel: string;
|
|
58
|
+
kind: string;
|
|
59
|
+
peer_id: string;
|
|
60
|
+
delivery_target: string;
|
|
61
|
+
label: string | null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface EventRow {
|
|
65
|
+
event_json: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface SessionMeta {
|
|
69
|
+
channel?: string;
|
|
70
|
+
label?: string;
|
|
71
|
+
chatId?: string;
|
|
72
|
+
chatType?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function str(value: unknown): string | undefined {
|
|
76
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function parseObject(value: string): Record<string, unknown> | undefined {
|
|
80
|
+
try {
|
|
81
|
+
const parsed: unknown = JSON.parse(value);
|
|
82
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed)
|
|
83
|
+
? (parsed as Record<string, unknown>)
|
|
84
|
+
: undefined;
|
|
85
|
+
} catch {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function syntheticPath(agentId: string, sessionId: string): string {
|
|
91
|
+
return `openclaw-sqlite://${encodeURIComponent(agentId)}/${sessionId}`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Existing per-agent SQLite databases, derived from the configured agents. */
|
|
95
|
+
export function listOpenClawDatabases(
|
|
96
|
+
home: string,
|
|
97
|
+
agentIds: string[],
|
|
98
|
+
): Array<{ agentId: string; dbPath: string }> {
|
|
99
|
+
const out: Array<{ agentId: string; dbPath: string }> = [];
|
|
100
|
+
for (const agentId of agentIds) {
|
|
101
|
+
const dbPath = join(home, "agents", agentId, "agent", DB_NAME);
|
|
102
|
+
if (existsSync(dbPath)) out.push({ agentId, dbPath });
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function readNodeMetadata(db: SqliteReader): Map<string, SessionMeta> {
|
|
108
|
+
const out = new Map<string, SessionMeta>();
|
|
109
|
+
let rows: NodeRow[];
|
|
110
|
+
try {
|
|
111
|
+
rows = db.query<NodeRow>(
|
|
112
|
+
`SELECT current_session_id, entry_json, label, display_name
|
|
113
|
+
FROM session_nodes`,
|
|
114
|
+
);
|
|
115
|
+
} catch {
|
|
116
|
+
return out;
|
|
117
|
+
}
|
|
118
|
+
for (const row of rows) {
|
|
119
|
+
const entry = parseObject(row.entry_json) ?? {};
|
|
120
|
+
const origin =
|
|
121
|
+
entry.origin &&
|
|
122
|
+
typeof entry.origin === "object" &&
|
|
123
|
+
!Array.isArray(entry.origin)
|
|
124
|
+
? (entry.origin as Record<string, unknown>)
|
|
125
|
+
: {};
|
|
126
|
+
out.set(row.current_session_id, {
|
|
127
|
+
channel:
|
|
128
|
+
str(entry.lastChannel) ?? str(origin.provider) ?? str(origin.surface),
|
|
129
|
+
label:
|
|
130
|
+
str(row.label) ??
|
|
131
|
+
str(row.display_name) ??
|
|
132
|
+
str(entry.displayName) ??
|
|
133
|
+
str(origin.label),
|
|
134
|
+
chatId: str(entry.lastTo) ?? str(origin.from),
|
|
135
|
+
chatType: str(entry.chatType) ?? str(origin.chatType),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function readConversationMetadata(db: SqliteReader): Map<string, SessionMeta> {
|
|
142
|
+
const out = new Map<string, SessionMeta>();
|
|
143
|
+
let rows: ConversationRow[];
|
|
144
|
+
try {
|
|
145
|
+
rows = db.query<ConversationRow>(
|
|
146
|
+
`SELECT sc.session_id, c.channel, c.kind, c.peer_id,
|
|
147
|
+
c.delivery_target, c.label
|
|
148
|
+
FROM session_conversations sc
|
|
149
|
+
JOIN conversations c ON c.conversation_id = sc.conversation_id
|
|
150
|
+
ORDER BY CASE sc.role WHEN 'primary' THEN 0 ELSE 1 END, sc.last_seen_at DESC`,
|
|
151
|
+
);
|
|
152
|
+
} catch {
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
for (const row of rows) {
|
|
156
|
+
if (out.has(row.session_id)) continue;
|
|
157
|
+
out.set(row.session_id, {
|
|
158
|
+
channel: str(row.channel),
|
|
159
|
+
label: str(row.label),
|
|
160
|
+
chatId: str(row.delivery_target) ?? str(row.peer_id),
|
|
161
|
+
chatType: str(row.kind),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return out;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** List every transcript-bearing session in all per-agent databases. */
|
|
168
|
+
export async function listOpenClawSqliteSessions(
|
|
169
|
+
home: string,
|
|
170
|
+
agentIds: string[],
|
|
171
|
+
): Promise<OpenClawSqliteSession[]> {
|
|
172
|
+
const sessions: OpenClawSqliteSession[] = [];
|
|
173
|
+
for (const { agentId, dbPath } of listOpenClawDatabases(home, agentIds)) {
|
|
174
|
+
const db = await openSqliteReadonly(dbPath);
|
|
175
|
+
if (!db) continue;
|
|
176
|
+
try {
|
|
177
|
+
let rows: WindowRow[];
|
|
178
|
+
try {
|
|
179
|
+
rows = db.query<WindowRow>(
|
|
180
|
+
`SELECT w.session_id, w.session_key, w.updated_at,
|
|
181
|
+
w.transcript_updated_at, w.ended_at, w.channel,
|
|
182
|
+
w.chat_type, w.display_name,
|
|
183
|
+
COALESCE((SELECT MAX(e.created_at)
|
|
184
|
+
FROM transcript_events e
|
|
185
|
+
WHERE e.session_id = w.session_id), 0) AS event_updated_at,
|
|
186
|
+
COALESCE((SELECT SUM(length(e.event_json) + 1)
|
|
187
|
+
FROM transcript_events e
|
|
188
|
+
WHERE e.session_id = w.session_id), 0) AS size_bytes
|
|
189
|
+
FROM session_windows w
|
|
190
|
+
WHERE EXISTS (SELECT 1 FROM transcript_events e
|
|
191
|
+
WHERE e.session_id = w.session_id)`,
|
|
192
|
+
);
|
|
193
|
+
} catch {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const nodes = readNodeMetadata(db);
|
|
198
|
+
const conversations = readConversationMetadata(db);
|
|
199
|
+
for (const row of rows) {
|
|
200
|
+
const node = nodes.get(row.session_id);
|
|
201
|
+
const conversation = conversations.get(row.session_id);
|
|
202
|
+
sessions.push({
|
|
203
|
+
sessionId: row.session_id,
|
|
204
|
+
agentId,
|
|
205
|
+
dbPath,
|
|
206
|
+
transcriptPath: syntheticPath(agentId, row.session_id),
|
|
207
|
+
mtimeMs: Math.max(
|
|
208
|
+
Number(row.updated_at) || 0,
|
|
209
|
+
Number(row.transcript_updated_at) || 0,
|
|
210
|
+
Number(row.ended_at) || 0,
|
|
211
|
+
Number(row.event_updated_at) || 0,
|
|
212
|
+
),
|
|
213
|
+
sizeBytes: Number(row.size_bytes) || 0,
|
|
214
|
+
channel:
|
|
215
|
+
str(row.channel) ??
|
|
216
|
+
conversation?.channel ??
|
|
217
|
+
node?.channel ??
|
|
218
|
+
"local",
|
|
219
|
+
label: str(row.display_name) ?? conversation?.label ?? node?.label,
|
|
220
|
+
chatId: conversation?.chatId ?? node?.chatId,
|
|
221
|
+
chatType:
|
|
222
|
+
str(row.chat_type) ?? conversation?.chatType ?? node?.chatType,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
} finally {
|
|
226
|
+
db.close();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return sessions;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Read one SQLite transcript by UUID. The first matching agent wins. */
|
|
233
|
+
export async function readOpenClawSqliteTranscript(
|
|
234
|
+
home: string,
|
|
235
|
+
agentIds: string[],
|
|
236
|
+
sessionId: string,
|
|
237
|
+
): Promise<OpenClawSqliteTranscript | null> {
|
|
238
|
+
for (const { agentId, dbPath } of listOpenClawDatabases(home, agentIds)) {
|
|
239
|
+
const db = await openSqliteReadonly(dbPath);
|
|
240
|
+
if (!db) continue;
|
|
241
|
+
try {
|
|
242
|
+
let rows: EventRow[];
|
|
243
|
+
try {
|
|
244
|
+
rows = db.query<EventRow>(
|
|
245
|
+
`SELECT event_json
|
|
246
|
+
FROM transcript_events
|
|
247
|
+
WHERE session_id = ?
|
|
248
|
+
ORDER BY seq ASC`,
|
|
249
|
+
[sessionId],
|
|
250
|
+
);
|
|
251
|
+
} catch {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (rows.length === 0) continue;
|
|
255
|
+
const eventJsonLines = rows.map((row) => row.event_json);
|
|
256
|
+
const rawLines = eventJsonLines
|
|
257
|
+
.map(parseObject)
|
|
258
|
+
.filter((line): line is Record<string, unknown> => line !== undefined);
|
|
259
|
+
return {
|
|
260
|
+
agentId,
|
|
261
|
+
dbPath,
|
|
262
|
+
filePath: syntheticPath(agentId, sessionId),
|
|
263
|
+
rawLines,
|
|
264
|
+
eventJsonLines,
|
|
265
|
+
};
|
|
266
|
+
} finally {
|
|
267
|
+
db.close();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return null;
|
|
271
|
+
}
|
package/lib/openclaw-projects.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OpenClaw (openclaw gateway) session enumeration — AUDIT-ONLY.
|
|
3
3
|
*
|
|
4
|
-
* Surfaces
|
|
5
|
-
* synthetic dashboard "projects" grouped by
|
|
6
|
-
*
|
|
7
|
-
* recover the sessionKey (which encodes the channel for gateway sessions) and a
|
|
8
|
-
* reliable last-activity time. Verified live against openclaw v2026.7.1.
|
|
4
|
+
* Surfaces both legacy JSONL transcripts and OpenClaw 2026.9.2+ per-agent
|
|
5
|
+
* SQLite transcripts as synthetic dashboard "projects" grouped by
|
|
6
|
+
* (agentId, channel).
|
|
9
7
|
*/
|
|
10
8
|
import { readFileSync } from "node:fs";
|
|
11
9
|
import { join } from "node:path";
|
|
12
10
|
import { runtimeCache } from "./runtime-cache";
|
|
13
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
listOpenClawAgents,
|
|
13
|
+
listOpenClawTranscripts,
|
|
14
|
+
openclawHome,
|
|
15
|
+
} from "./openclaw-sessions";
|
|
14
16
|
import type { ProjectFolder, SessionFile } from "./projects";
|
|
15
17
|
import { formatDate } from "./format-date";
|
|
18
|
+
import { listOpenClawSqliteSessions } from "./openclaw-db";
|
|
16
19
|
|
|
17
20
|
export interface OpenClawSessionRef {
|
|
18
21
|
sessionId: string;
|
|
@@ -51,7 +54,13 @@ function str(v: unknown): string | undefined {
|
|
|
51
54
|
* than in the key — verified live against v2026.7.1. */
|
|
52
55
|
function readSessionsIndex(agentId: string): Map<string, SessionIndexMeta> {
|
|
53
56
|
const out = new Map<string, SessionIndexMeta>();
|
|
54
|
-
const indexPath = join(
|
|
57
|
+
const indexPath = join(
|
|
58
|
+
openclawHome(),
|
|
59
|
+
"agents",
|
|
60
|
+
agentId,
|
|
61
|
+
"sessions",
|
|
62
|
+
"sessions.json",
|
|
63
|
+
);
|
|
55
64
|
let raw: unknown;
|
|
56
65
|
try {
|
|
57
66
|
raw = JSON.parse(readFileSync(indexPath, "utf-8"));
|
|
@@ -64,7 +73,9 @@ function readSessionsIndex(agentId: string): Map<string, SessionIndexMeta> {
|
|
|
64
73
|
const e = v as Record<string, unknown>;
|
|
65
74
|
const sessionId = str(e.sessionId);
|
|
66
75
|
if (!sessionId) continue;
|
|
67
|
-
const origin = (
|
|
76
|
+
const origin = (
|
|
77
|
+
e.origin && typeof e.origin === "object" ? e.origin : {}
|
|
78
|
+
) as Record<string, unknown>;
|
|
68
79
|
const lastMs =
|
|
69
80
|
typeof e.lastInteractionAt === "number"
|
|
70
81
|
? e.lastInteractionAt
|
|
@@ -73,7 +84,8 @@ function readSessionsIndex(agentId: string): Map<string, SessionIndexMeta> {
|
|
|
73
84
|
: undefined;
|
|
74
85
|
out.set(sessionId, {
|
|
75
86
|
lastMs,
|
|
76
|
-
channel:
|
|
87
|
+
channel:
|
|
88
|
+
str(e.lastChannel) ?? str(origin.provider) ?? str(origin.surface),
|
|
77
89
|
chatType: str(e.chatType) ?? str(origin.chatType),
|
|
78
90
|
label: str(origin.label),
|
|
79
91
|
chatId: str(e.lastTo) ?? str(origin.from),
|
|
@@ -86,7 +98,7 @@ function readSessionsIndex(agentId: string): Map<string, SessionIndexMeta> {
|
|
|
86
98
|
export async function getOpenClawSessions(): Promise<OpenClawSessionRef[]> {
|
|
87
99
|
const transcripts = listOpenClawTranscripts();
|
|
88
100
|
const indexByAgent = new Map<string, Map<string, SessionIndexMeta>>();
|
|
89
|
-
const refs
|
|
101
|
+
const refs = new Map<string, OpenClawSessionRef>();
|
|
90
102
|
for (const t of transcripts) {
|
|
91
103
|
let idx = indexByAgent.get(t.agentId);
|
|
92
104
|
if (!idx) {
|
|
@@ -94,7 +106,7 @@ export async function getOpenClawSessions(): Promise<OpenClawSessionRef[]> {
|
|
|
94
106
|
indexByAgent.set(t.agentId, idx);
|
|
95
107
|
}
|
|
96
108
|
const meta = idx.get(t.sessionId);
|
|
97
|
-
refs.
|
|
109
|
+
refs.set(`${t.agentId}\0${t.sessionId}`, {
|
|
98
110
|
sessionId: t.sessionId,
|
|
99
111
|
agentId: t.agentId,
|
|
100
112
|
// Gateway sessions group by channel; CLI/local runs have none.
|
|
@@ -107,8 +119,18 @@ export async function getOpenClawSessions(): Promise<OpenClawSessionRef[]> {
|
|
|
107
119
|
sizeBytes: t.sizeBytes,
|
|
108
120
|
});
|
|
109
121
|
}
|
|
110
|
-
|
|
111
|
-
|
|
122
|
+
|
|
123
|
+
// SQLite is the live source on OpenClaw 2026.9.2+. Insert it second so it
|
|
124
|
+
// replaces an archived JSONL copy of the same agent/session.
|
|
125
|
+
const sqliteSessions = await listOpenClawSqliteSessions(
|
|
126
|
+
openclawHome(),
|
|
127
|
+
listOpenClawAgents(),
|
|
128
|
+
);
|
|
129
|
+
for (const s of sqliteSessions) {
|
|
130
|
+
refs.set(`${s.agentId}\0${s.sessionId}`, s);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return [...refs.values()].sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
112
134
|
}
|
|
113
135
|
|
|
114
136
|
export const getCachedOpenClawSessions = runtimeCache(getOpenClawSessions, 2);
|
|
@@ -145,7 +167,9 @@ export interface OpenClawNameSplit {
|
|
|
145
167
|
* form (`agentId: null`), so links shared before agents became part of the name
|
|
146
168
|
* keep resolving — to every agent on that channel, which is what they meant.
|
|
147
169
|
*/
|
|
148
|
-
export function openClawProjectNameCandidates(
|
|
170
|
+
export function openClawProjectNameCandidates(
|
|
171
|
+
name: string,
|
|
172
|
+
): OpenClawNameSplit[] {
|
|
149
173
|
if (!name.startsWith("openclaw-")) return [];
|
|
150
174
|
const rest = name.slice("openclaw-".length);
|
|
151
175
|
if (!rest) return [];
|
|
@@ -163,7 +187,9 @@ export function openClawProjectNameCandidates(name: string): OpenClawNameSplit[]
|
|
|
163
187
|
}
|
|
164
188
|
|
|
165
189
|
/** The best-guess split for a project name — `null` if it isn't an OpenClaw one. */
|
|
166
|
-
export function parseOpenClawProjectName(
|
|
190
|
+
export function parseOpenClawProjectName(
|
|
191
|
+
name: string,
|
|
192
|
+
): OpenClawNameSplit | null {
|
|
167
193
|
return openClawProjectNameCandidates(name)[0] ?? null;
|
|
168
194
|
}
|
|
169
195
|
|
|
@@ -190,7 +216,12 @@ export async function getOpenClawProjects(): Promise<ProjectFolder[]> {
|
|
|
190
216
|
prev.latest = Math.max(prev.latest, s.mtimeMs);
|
|
191
217
|
prev.count += 1;
|
|
192
218
|
} else {
|
|
193
|
-
groups.set(key, {
|
|
219
|
+
groups.set(key, {
|
|
220
|
+
agentId: s.agentId,
|
|
221
|
+
channel: s.channel,
|
|
222
|
+
latest: s.mtimeMs,
|
|
223
|
+
count: 1,
|
|
224
|
+
});
|
|
194
225
|
}
|
|
195
226
|
}
|
|
196
227
|
const out: ProjectFolder[] = [];
|
|
@@ -228,7 +259,9 @@ export async function getOpenClawSessionsByEncodedName(
|
|
|
228
259
|
const sessions = await getOpenClawSessions();
|
|
229
260
|
const matching = (split: OpenClawNameSplit) =>
|
|
230
261
|
sessions.filter(
|
|
231
|
-
(s) =>
|
|
262
|
+
(s) =>
|
|
263
|
+
s.channel === split.channel &&
|
|
264
|
+
(split.agentId === null || s.agentId === split.agentId),
|
|
232
265
|
);
|
|
233
266
|
|
|
234
267
|
// Take the first split that actually owns sessions — length alone picks the
|
|
@@ -250,7 +283,10 @@ export async function getOpenClawSessionsByEncodedName(
|
|
|
250
283
|
return {
|
|
251
284
|
// Legacy channel-only names keep their old cwd label, since they really do
|
|
252
285
|
// span every agent on that channel.
|
|
253
|
-
cwd:
|
|
286
|
+
cwd:
|
|
287
|
+
agentId === null
|
|
288
|
+
? `openclaw:${channel}`
|
|
289
|
+
: openClawProjectPath(agentId, channel),
|
|
254
290
|
sessions: matched.map((s) => {
|
|
255
291
|
const lastModified = new Date(s.mtimeMs);
|
|
256
292
|
return {
|