@openclawbrain/openclaw 0.1.11 → 0.1.12
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/README.md +12 -6
- package/dist/src/cli.d.ts +14 -1
- package/dist/src/cli.js +212 -9
- package/dist/src/cli.js.map +1 -1
- package/dist/src/index.d.ts +359 -4
- package/dist/src/index.js +1627 -77
- package/dist/src/index.js.map +1 -1
- package/dist/src/local-session-passive-learning.d.ts +60 -0
- package/dist/src/local-session-passive-learning.js +359 -0
- package/dist/src/local-session-passive-learning.js.map +1 -0
- package/dist/src/session-store.d.ts +150 -0
- package/dist/src/session-store.js +199 -0
- package/dist/src/session-store.js.map +1 -0
- package/dist/src/session-tail.d.ts +68 -0
- package/dist/src/session-tail.js +519 -0
- package/dist/src/session-tail.js.map +1 -0
- package/package.json +7 -6
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
export function loadOpenClawSessionIndex(indexFilePath) {
|
|
5
|
+
return parseJsonFile(indexFilePath);
|
|
6
|
+
}
|
|
7
|
+
export function readOpenClawSessionFile(sessionFilePath) {
|
|
8
|
+
return readJsonlFile(sessionFilePath, parseOpenClawSessionRecord);
|
|
9
|
+
}
|
|
10
|
+
export function readOpenClawAcpStreamFile(streamFilePath) {
|
|
11
|
+
return readJsonlFile(streamFilePath, parseOpenClawAcpStreamRecord);
|
|
12
|
+
}
|
|
13
|
+
export function discoverOpenClawMainSessionStores(options = {}) {
|
|
14
|
+
const candidateRoots = options.profileRoots !== undefined
|
|
15
|
+
? [...new Set(options.profileRoots.map((root) => path.resolve(root)))]
|
|
16
|
+
: discoverOpenClawProfileRoots(options.homeDir);
|
|
17
|
+
return candidateRoots
|
|
18
|
+
.map((profileRoot) => {
|
|
19
|
+
const sessionsDir = path.join(profileRoot, "agents", "main", "sessions");
|
|
20
|
+
const indexPath = path.join(sessionsDir, "sessions.json");
|
|
21
|
+
if (!existsSync(indexPath)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
profileRoot,
|
|
26
|
+
agentId: "main",
|
|
27
|
+
sessionsDir,
|
|
28
|
+
indexPath
|
|
29
|
+
};
|
|
30
|
+
})
|
|
31
|
+
.filter((store) => store !== null)
|
|
32
|
+
.sort((left, right) => left.indexPath.localeCompare(right.indexPath));
|
|
33
|
+
}
|
|
34
|
+
function discoverOpenClawProfileRoots(homeDir) {
|
|
35
|
+
const rootDir = path.resolve(homeDir ?? homedir());
|
|
36
|
+
if (!existsSync(rootDir)) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
return readdirSync(rootDir, { withFileTypes: true })
|
|
40
|
+
.filter((entry) => entry.isDirectory() && entry.name.startsWith(".openclaw-"))
|
|
41
|
+
.map((entry) => path.join(rootDir, entry.name))
|
|
42
|
+
.sort((left, right) => left.localeCompare(right));
|
|
43
|
+
}
|
|
44
|
+
function parseJsonFile(filePath) {
|
|
45
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
46
|
+
}
|
|
47
|
+
function readJsonlFile(filePath, parseRecord) {
|
|
48
|
+
const text = readFileSync(filePath, "utf8");
|
|
49
|
+
if (text.trim() === "") {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
return text
|
|
53
|
+
.split(/\r?\n/)
|
|
54
|
+
.filter((line) => line.trim().length > 0)
|
|
55
|
+
.map((line, index) => {
|
|
56
|
+
try {
|
|
57
|
+
return parseRecord(JSON.parse(line), index + 1);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
61
|
+
throw new Error(`Could not parse JSONL record at ${filePath}:${index + 1}: ${message}`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function parseOpenClawSessionRecord(value, lineNumber) {
|
|
66
|
+
const record = expectRecord(value, lineNumber);
|
|
67
|
+
const type = expectString(record.type, `${lineNumber}.type`);
|
|
68
|
+
switch (type) {
|
|
69
|
+
case "session":
|
|
70
|
+
return {
|
|
71
|
+
type,
|
|
72
|
+
version: expectNumber(record.version, `${lineNumber}.version`),
|
|
73
|
+
id: expectString(record.id, `${lineNumber}.id`),
|
|
74
|
+
timestamp: expectString(record.timestamp, `${lineNumber}.timestamp`),
|
|
75
|
+
cwd: expectString(record.cwd, `${lineNumber}.cwd`)
|
|
76
|
+
};
|
|
77
|
+
case "model_change":
|
|
78
|
+
return {
|
|
79
|
+
type,
|
|
80
|
+
id: expectString(record.id, `${lineNumber}.id`),
|
|
81
|
+
parentId: expectNullableString(record.parentId, `${lineNumber}.parentId`),
|
|
82
|
+
timestamp: expectString(record.timestamp, `${lineNumber}.timestamp`),
|
|
83
|
+
provider: expectString(record.provider, `${lineNumber}.provider`),
|
|
84
|
+
modelId: expectString(record.modelId, `${lineNumber}.modelId`)
|
|
85
|
+
};
|
|
86
|
+
case "thinking_level_change":
|
|
87
|
+
return {
|
|
88
|
+
type,
|
|
89
|
+
id: expectString(record.id, `${lineNumber}.id`),
|
|
90
|
+
parentId: expectNullableString(record.parentId, `${lineNumber}.parentId`),
|
|
91
|
+
timestamp: expectString(record.timestamp, `${lineNumber}.timestamp`),
|
|
92
|
+
thinkingLevel: expectString(record.thinkingLevel, `${lineNumber}.thinkingLevel`)
|
|
93
|
+
};
|
|
94
|
+
case "custom":
|
|
95
|
+
return {
|
|
96
|
+
type,
|
|
97
|
+
customType: expectString(record.customType, `${lineNumber}.customType`),
|
|
98
|
+
data: expectRecord(record.data, `${lineNumber}.data`),
|
|
99
|
+
id: expectString(record.id, `${lineNumber}.id`),
|
|
100
|
+
parentId: expectNullableString(record.parentId, `${lineNumber}.parentId`),
|
|
101
|
+
timestamp: expectString(record.timestamp, `${lineNumber}.timestamp`)
|
|
102
|
+
};
|
|
103
|
+
case "message":
|
|
104
|
+
return {
|
|
105
|
+
type,
|
|
106
|
+
id: expectString(record.id, `${lineNumber}.id`),
|
|
107
|
+
parentId: expectNullableString(record.parentId, `${lineNumber}.parentId`),
|
|
108
|
+
timestamp: expectString(record.timestamp, `${lineNumber}.timestamp`),
|
|
109
|
+
message: parseMessagePayload(record.message, `${lineNumber}.message`)
|
|
110
|
+
};
|
|
111
|
+
default:
|
|
112
|
+
throw new Error(`Unknown OpenClaw session record type: ${type}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function parseMessagePayload(value, path) {
|
|
116
|
+
const payload = expectRecord(value, path);
|
|
117
|
+
const content = expectArray(payload.content, `${path}.content`).map((entry, index) => parseContentPart(entry, `${path}.content[${index}]`));
|
|
118
|
+
return {
|
|
119
|
+
...payload,
|
|
120
|
+
role: expectString(payload.role, `${path}.role`),
|
|
121
|
+
content,
|
|
122
|
+
timestamp: expectNumber(payload.timestamp, `${path}.timestamp`)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function parseContentPart(value, path) {
|
|
126
|
+
const content = expectRecord(value, path);
|
|
127
|
+
const type = expectString(content.type, `${path}.type`);
|
|
128
|
+
if (type === "text") {
|
|
129
|
+
return {
|
|
130
|
+
...content,
|
|
131
|
+
type,
|
|
132
|
+
text: expectString(content.text, `${path}.text`)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (type === "thinking") {
|
|
136
|
+
return {
|
|
137
|
+
...content,
|
|
138
|
+
type,
|
|
139
|
+
thinking: expectString(content.thinking, `${path}.thinking`)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (type === "toolCall") {
|
|
143
|
+
return {
|
|
144
|
+
...content,
|
|
145
|
+
type,
|
|
146
|
+
id: expectString(content.id, `${path}.id`),
|
|
147
|
+
name: expectString(content.name, `${path}.name`),
|
|
148
|
+
arguments: expectRecord(content.arguments, `${path}.arguments`)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
...content,
|
|
153
|
+
type
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function parseOpenClawAcpStreamRecord(value, lineNumber) {
|
|
157
|
+
const record = expectRecord(value, lineNumber);
|
|
158
|
+
return {
|
|
159
|
+
...record,
|
|
160
|
+
ts: expectString(record.ts, `${lineNumber}.ts`),
|
|
161
|
+
epochMs: expectNumber(record.epochMs, `${lineNumber}.epochMs`),
|
|
162
|
+
runId: expectString(record.runId, `${lineNumber}.runId`),
|
|
163
|
+
parentSessionKey: expectString(record.parentSessionKey, `${lineNumber}.parentSessionKey`),
|
|
164
|
+
childSessionKey: expectString(record.childSessionKey, `${lineNumber}.childSessionKey`),
|
|
165
|
+
agentId: expectString(record.agentId, `${lineNumber}.agentId`),
|
|
166
|
+
kind: expectString(record.kind, `${lineNumber}.kind`)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function expectRecord(value, path) {
|
|
170
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
171
|
+
throw new Error(`${path} must be an object`);
|
|
172
|
+
}
|
|
173
|
+
return value;
|
|
174
|
+
}
|
|
175
|
+
function expectArray(value, path) {
|
|
176
|
+
if (!Array.isArray(value)) {
|
|
177
|
+
throw new Error(`${path} must be an array`);
|
|
178
|
+
}
|
|
179
|
+
return value;
|
|
180
|
+
}
|
|
181
|
+
function expectString(value, path) {
|
|
182
|
+
if (typeof value !== "string") {
|
|
183
|
+
throw new Error(`${path} must be a string`);
|
|
184
|
+
}
|
|
185
|
+
return value;
|
|
186
|
+
}
|
|
187
|
+
function expectNullableString(value, path) {
|
|
188
|
+
if (value === null) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
return expectString(value, path);
|
|
192
|
+
}
|
|
193
|
+
function expectNumber(value, path) {
|
|
194
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
195
|
+
throw new Error(`${path} must be a finite number`);
|
|
196
|
+
}
|
|
197
|
+
return value;
|
|
198
|
+
}
|
|
199
|
+
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AED,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,YAAY,CAAC,KAAc,EAAE,IAAY;IAChD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,0BAA0B,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type OpenClawMainSessionStoreV1 } from "./session-store.js";
|
|
2
|
+
import type { ScannedEventExportInputV1 } from "./index.js";
|
|
3
|
+
export type OpenClawLocalSessionTailNoopReasonV1 = "seeded_existing_sessions" | "no_local_session_stores" | "no_session_changes";
|
|
4
|
+
export type OpenClawLocalSessionTailChangeKindV1 = "new_session" | "appended_records" | "metadata_only" | "session_reset" | "missing_session_path" | "missing_session_file";
|
|
5
|
+
export interface OpenClawLocalSessionTailCursorV1 {
|
|
6
|
+
sourceIndexPath: string;
|
|
7
|
+
sessionKey: string;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
sessionFile: string | null;
|
|
10
|
+
updatedAt: number;
|
|
11
|
+
rawRecordCount: number;
|
|
12
|
+
bridgedEventCount: number;
|
|
13
|
+
}
|
|
14
|
+
export interface OpenClawLocalSessionTailChangeV1 {
|
|
15
|
+
source: OpenClawMainSessionStoreV1;
|
|
16
|
+
sessionKey: string;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
sessionFile: string | null;
|
|
19
|
+
changeKind: OpenClawLocalSessionTailChangeKindV1;
|
|
20
|
+
rawRecordCount: number;
|
|
21
|
+
bridgedEventCount: number;
|
|
22
|
+
emittedEventCount: number;
|
|
23
|
+
warnings: string[];
|
|
24
|
+
scannedEventExport: ScannedEventExportInputV1 | null;
|
|
25
|
+
}
|
|
26
|
+
export interface OpenClawLocalSessionTailPollResultV1 {
|
|
27
|
+
runtimeOwner: "openclaw";
|
|
28
|
+
lane: "local_session_tail";
|
|
29
|
+
polledAt: string;
|
|
30
|
+
sources: OpenClawMainSessionStoreV1[];
|
|
31
|
+
changes: OpenClawLocalSessionTailChangeV1[];
|
|
32
|
+
noopReason: OpenClawLocalSessionTailNoopReasonV1 | null;
|
|
33
|
+
warnings: string[];
|
|
34
|
+
cursor: OpenClawLocalSessionTailCursorV1[];
|
|
35
|
+
}
|
|
36
|
+
export interface OpenClawLocalSessionTailInput {
|
|
37
|
+
homeDir?: string;
|
|
38
|
+
profileRoots?: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
export interface OpenClawLocalSessionTailLoopOptionsV1 {
|
|
41
|
+
pollIntervalMs?: number;
|
|
42
|
+
maxPasses?: number;
|
|
43
|
+
stopWhenIdle?: boolean;
|
|
44
|
+
signal?: AbortSignal;
|
|
45
|
+
onPass?: (result: OpenClawLocalSessionTailPollResultV1) => void | Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export interface OpenClawLocalSessionTailLoopResultV1 {
|
|
48
|
+
runtimeOwner: "openclaw";
|
|
49
|
+
passCount: number;
|
|
50
|
+
changedSessionCount: number;
|
|
51
|
+
emittedEventCount: number;
|
|
52
|
+
stoppedReason: "idle" | "max_passes" | "aborted";
|
|
53
|
+
lastPoll: OpenClawLocalSessionTailPollResultV1 | null;
|
|
54
|
+
cursor: OpenClawLocalSessionTailCursorV1[];
|
|
55
|
+
}
|
|
56
|
+
export declare class OpenClawLocalSessionTail {
|
|
57
|
+
readonly homeDir: string | undefined;
|
|
58
|
+
readonly profileRoots: readonly string[] | undefined;
|
|
59
|
+
private initialized;
|
|
60
|
+
private readonly cursorBySession;
|
|
61
|
+
constructor(input?: OpenClawLocalSessionTailInput);
|
|
62
|
+
snapshot(): OpenClawLocalSessionTailCursorV1[];
|
|
63
|
+
pollOnce(options?: {
|
|
64
|
+
observedAt?: string;
|
|
65
|
+
}): OpenClawLocalSessionTailPollResultV1;
|
|
66
|
+
runLoop(options?: OpenClawLocalSessionTailLoopOptionsV1): Promise<OpenClawLocalSessionTailLoopResultV1>;
|
|
67
|
+
}
|
|
68
|
+
export declare function createOpenClawLocalSessionTail(input?: OpenClawLocalSessionTailInput): OpenClawLocalSessionTail;
|