clawconnect-agent 0.2.10 → 0.2.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/dist/commands/pair.d.ts +13 -0
- package/dist/commands/pair.js +68 -41
- package/dist/commands/pair.js.map +1 -1
- package/dist/commands/profile-hints.d.ts +1 -0
- package/dist/commands/profile-hints.js +3 -0
- package/dist/commands/profile-hints.js.map +1 -1
- package/dist/commands/run.js +16 -2
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/status.js +15 -6
- package/dist/commands/status.js.map +1 -1
- package/dist/config/config-backups.d.ts +12 -0
- package/dist/config/config-backups.js +44 -0
- package/dist/config/config-backups.js.map +1 -0
- package/dist/core/relay/file-upload.d.ts +4 -0
- package/dist/core/relay/file-upload.js +17 -0
- package/dist/core/relay/file-upload.js.map +1 -1
- package/dist/core/relay/relay-server-connection.d.ts +10 -1
- package/dist/core/relay/relay-server-connection.js +11 -2
- package/dist/core/relay/relay-server-connection.js.map +1 -1
- package/dist/core/relay/source-commit-checkpoint-client.d.ts +42 -0
- package/dist/core/relay/source-commit-checkpoint-client.js +112 -0
- package/dist/core/relay/source-commit-checkpoint-client.js.map +1 -0
- package/dist/core/relay/source-commit.d.ts +12 -1
- package/dist/core/relay/source-commit.js +29 -9
- package/dist/core/relay/source-commit.js.map +1 -1
- package/dist/hermes/hermes-relay-manager.d.ts +1 -1
- package/dist/hermes/hermes-relay-manager.js +1 -1
- package/dist/hermes/hermes-relay-manager.js.map +1 -1
- package/dist/i18n/index.js +4 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/openclaw/relay/openclaw-source-commit-watcher.d.ts +3 -2
- package/dist/openclaw/relay/openclaw-source-commit-watcher.js +2 -2
- package/dist/openclaw/relay/openclaw-source-commit-watcher.js.map +1 -1
- package/dist/openclaw/relay/outgoing-media-relay.js +18 -1
- package/dist/openclaw/relay/outgoing-media-relay.js.map +1 -1
- package/dist/openclaw/relay/relay-manager-protocol.d.ts +1 -1
- package/dist/openclaw/relay-manager.js +20 -10
- package/dist/openclaw/relay-manager.js.map +1 -1
- package/dist/runtime-adapters.d.ts +1 -1
- package/package.json +1 -1
- package/dist/hermes/hermes-runtime-test-support.d.ts +0 -27
- package/dist/hermes/hermes-runtime-test-support.js +0 -709
- package/dist/hermes/hermes-runtime-test-support.js.map +0 -1
- package/dist/openclaw/relay/openclaw-message-tool-real-shape.fixture.d.ts +0 -12
- package/dist/openclaw/relay/openclaw-message-tool-real-shape.fixture.js +0 -48
- package/dist/openclaw/relay/openclaw-message-tool-real-shape.fixture.js.map +0 -1
|
@@ -1,709 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { execFileSync } from "node:child_process";
|
|
3
|
-
import { chmodSync, existsSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
export function restoreEnv(name, previousValue) {
|
|
6
|
-
if (previousValue === undefined) {
|
|
7
|
-
delete process.env[name];
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
process.env[name] = previousValue;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export function writeHermesStateDb(root) {
|
|
14
|
-
const dbPath = join(root, "state.db");
|
|
15
|
-
const script = String.raw `
|
|
16
|
-
import sqlite3
|
|
17
|
-
import sys
|
|
18
|
-
|
|
19
|
-
db_path = sys.argv[1]
|
|
20
|
-
conn = sqlite3.connect(db_path)
|
|
21
|
-
conn.executescript("""
|
|
22
|
-
CREATE TABLE IF NOT EXISTS sessions (
|
|
23
|
-
id TEXT PRIMARY KEY,
|
|
24
|
-
source TEXT NOT NULL,
|
|
25
|
-
user_id TEXT,
|
|
26
|
-
model TEXT,
|
|
27
|
-
model_config TEXT,
|
|
28
|
-
system_prompt TEXT,
|
|
29
|
-
parent_session_id TEXT,
|
|
30
|
-
started_at REAL NOT NULL,
|
|
31
|
-
ended_at REAL,
|
|
32
|
-
end_reason TEXT,
|
|
33
|
-
message_count INTEGER DEFAULT 0,
|
|
34
|
-
tool_call_count INTEGER DEFAULT 0,
|
|
35
|
-
input_tokens INTEGER DEFAULT 0,
|
|
36
|
-
output_tokens INTEGER DEFAULT 0,
|
|
37
|
-
cache_read_tokens INTEGER DEFAULT 0,
|
|
38
|
-
cache_write_tokens INTEGER DEFAULT 0,
|
|
39
|
-
reasoning_tokens INTEGER DEFAULT 0,
|
|
40
|
-
billing_provider TEXT,
|
|
41
|
-
billing_base_url TEXT,
|
|
42
|
-
billing_mode TEXT,
|
|
43
|
-
estimated_cost_usd REAL,
|
|
44
|
-
actual_cost_usd REAL,
|
|
45
|
-
cost_status TEXT,
|
|
46
|
-
cost_source TEXT,
|
|
47
|
-
pricing_version TEXT,
|
|
48
|
-
title TEXT,
|
|
49
|
-
api_call_count INTEGER DEFAULT 0,
|
|
50
|
-
handoff_state TEXT,
|
|
51
|
-
handoff_platform TEXT,
|
|
52
|
-
handoff_error TEXT,
|
|
53
|
-
cwd TEXT,
|
|
54
|
-
rewind_count INTEGER NOT NULL DEFAULT 0,
|
|
55
|
-
archived INTEGER NOT NULL DEFAULT 0
|
|
56
|
-
);
|
|
57
|
-
CREATE TABLE IF NOT EXISTS messages (
|
|
58
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
59
|
-
session_id TEXT NOT NULL REFERENCES sessions(id),
|
|
60
|
-
role TEXT NOT NULL,
|
|
61
|
-
content TEXT,
|
|
62
|
-
tool_call_id TEXT,
|
|
63
|
-
tool_calls TEXT,
|
|
64
|
-
tool_name TEXT,
|
|
65
|
-
timestamp REAL NOT NULL,
|
|
66
|
-
token_count INTEGER,
|
|
67
|
-
finish_reason TEXT,
|
|
68
|
-
reasoning TEXT,
|
|
69
|
-
reasoning_content TEXT,
|
|
70
|
-
reasoning_details TEXT,
|
|
71
|
-
codex_reasoning_items TEXT,
|
|
72
|
-
codex_message_items TEXT,
|
|
73
|
-
platform_message_id TEXT,
|
|
74
|
-
observed INTEGER DEFAULT 0,
|
|
75
|
-
active INTEGER NOT NULL DEFAULT 1
|
|
76
|
-
);
|
|
77
|
-
""")
|
|
78
|
-
conn.commit()
|
|
79
|
-
conn.close()
|
|
80
|
-
`;
|
|
81
|
-
execFileSync("python3", ["-c", script, dbPath], { stdio: "pipe" });
|
|
82
|
-
return dbPath;
|
|
83
|
-
}
|
|
84
|
-
export function writeStateDbHistoryCompletingHermesBin(root) {
|
|
85
|
-
const binPath = join(root, "hermes-state-db-history-completion");
|
|
86
|
-
const readyPath = join(root, "state-db-history-ready");
|
|
87
|
-
const exportCalledPath = join(root, "state-db-export-called");
|
|
88
|
-
const dbPath = join(root, "state.db");
|
|
89
|
-
const sessionId = "20260622_100613_8947a8";
|
|
90
|
-
writeFileSync(binPath, [
|
|
91
|
-
"#!/usr/bin/env node",
|
|
92
|
-
"const fs = require('fs');",
|
|
93
|
-
"const { execFileSync } = require('child_process');",
|
|
94
|
-
"const args = process.argv.slice(2);",
|
|
95
|
-
`const readyPath = ${JSON.stringify(readyPath)};`,
|
|
96
|
-
`const exportCalledPath = ${JSON.stringify(exportCalledPath)};`,
|
|
97
|
-
`const dbPath = ${JSON.stringify(dbPath)};`,
|
|
98
|
-
`const sessionId = ${JSON.stringify(sessionId)};`,
|
|
99
|
-
"function writeCompletedTurn(query) {",
|
|
100
|
-
" const script = String.raw`",
|
|
101
|
-
"import sqlite3",
|
|
102
|
-
"import sys",
|
|
103
|
-
"db_path, session_id, query = sys.argv[1:4]",
|
|
104
|
-
"conn = sqlite3.connect(db_path)",
|
|
105
|
-
"conn.execute(\"INSERT OR REPLACE INTO sessions (id, source, model, started_at, title, message_count) VALUES (?, 'cli', 'gpt-5.5', 1780000000.0, 'Greeting', 2)\", (session_id,))",
|
|
106
|
-
"conn.execute(\"DELETE FROM messages WHERE session_id = ?\", (session_id,))",
|
|
107
|
-
"conn.execute(\"INSERT INTO messages (session_id, role, content, timestamp, active) VALUES (?, 'user', ?, 1780000001.0, 1)\", (session_id, query))",
|
|
108
|
-
"conn.execute(\"INSERT INTO messages (session_id, role, content, timestamp, active) VALUES (?, 'assistant', 'direct-db reply', 1780000002.0, 1)\", (session_id,))",
|
|
109
|
-
"conn.commit()",
|
|
110
|
-
"conn.close()",
|
|
111
|
-
"`;",
|
|
112
|
-
" execFileSync('python3', ['-c', script, dbPath, sessionId, query], { stdio: 'ignore' });",
|
|
113
|
-
" fs.writeFileSync(readyPath, '1');",
|
|
114
|
-
"}",
|
|
115
|
-
"if (args[0] === 'sessions' && args[1] === 'list') {",
|
|
116
|
-
" console.log('Title Preview Last Active ID');",
|
|
117
|
-
" if (fs.existsSync(readyPath)) console.log('Greeting direct-db reply just now 20260622_100613_8947a8');",
|
|
118
|
-
" process.exit(0);",
|
|
119
|
-
"}",
|
|
120
|
-
"if (args[0] === 'sessions' && args[1] === 'export') {",
|
|
121
|
-
" fs.writeFileSync(exportCalledPath, args.join(' '));",
|
|
122
|
-
" console.error('sessions export should not be needed for state.db completion');",
|
|
123
|
-
" process.exit(2);",
|
|
124
|
-
"}",
|
|
125
|
-
"if (args[0] === 'chat') {",
|
|
126
|
-
" const queryIndex = args.indexOf('--query');",
|
|
127
|
-
" const query = queryIndex >= 0 ? args[queryIndex + 1] : '';",
|
|
128
|
-
" setTimeout(() => writeCompletedTurn(query), 100);",
|
|
129
|
-
" setTimeout(() => process.exit(0), 3500);",
|
|
130
|
-
" return;",
|
|
131
|
-
"}",
|
|
132
|
-
"if (args[0] === 'status') { process.exit(0); }",
|
|
133
|
-
"console.error(`unexpected args: ${args.join(' ')}`);",
|
|
134
|
-
"process.exit(2);",
|
|
135
|
-
"",
|
|
136
|
-
].join("\n"), "utf8");
|
|
137
|
-
chmodSync(binPath, 0o755);
|
|
138
|
-
assert.equal(existsSync(binPath), true);
|
|
139
|
-
return { binPath, exportCalledPath };
|
|
140
|
-
}
|
|
141
|
-
export function writeMutableHistoryHermesBin(root, payloadPath) {
|
|
142
|
-
const binPath = join(root, "hermes-history-mutable");
|
|
143
|
-
writeFileSync(binPath, [
|
|
144
|
-
"#!/bin/sh",
|
|
145
|
-
"if [ \"$1\" = \"sessions\" ] && [ \"$2\" = \"export\" ]; then",
|
|
146
|
-
` cat '${payloadPath.replace(/'/g, "'\\''")}'`,
|
|
147
|
-
" printf '\\n'",
|
|
148
|
-
" exit 0",
|
|
149
|
-
"fi",
|
|
150
|
-
"if [ \"$1\" = \"sessions\" ] && [ \"$2\" = \"list\" ]; then",
|
|
151
|
-
" echo 'Title Preview Last Active ID'",
|
|
152
|
-
" echo 'History visible reply just now 20260529_100000_history'",
|
|
153
|
-
" exit 0",
|
|
154
|
-
"fi",
|
|
155
|
-
"if [ \"$1\" = \"status\" ]; then exit 0; fi",
|
|
156
|
-
"echo \"unexpected args: $@\" >&2",
|
|
157
|
-
"exit 2",
|
|
158
|
-
"",
|
|
159
|
-
].join("\n"), "utf8");
|
|
160
|
-
chmodSync(binPath, 0o755);
|
|
161
|
-
assert.equal(existsSync(binPath), true);
|
|
162
|
-
return binPath;
|
|
163
|
-
}
|
|
164
|
-
export function writePagedHistoryHermesBin(root) {
|
|
165
|
-
const binPath = join(root, "hermes-history-paged");
|
|
166
|
-
const payload = JSON.stringify({
|
|
167
|
-
sessionId: "20260529_100000_history",
|
|
168
|
-
messages: Array.from({ length: 4 }, (_, index) => {
|
|
169
|
-
const seq = index + 1;
|
|
170
|
-
return {
|
|
171
|
-
id: `m${seq}`,
|
|
172
|
-
role: seq % 2 === 0 ? "assistant" : "user",
|
|
173
|
-
content: `message ${seq}`,
|
|
174
|
-
createdAt: new Date(Date.UTC(2026, 4, 29, 2, 0, seq)).toISOString(),
|
|
175
|
-
};
|
|
176
|
-
}),
|
|
177
|
-
});
|
|
178
|
-
writeFileSync(binPath, [
|
|
179
|
-
"#!/bin/sh",
|
|
180
|
-
"if [ \"$1\" = \"sessions\" ] && [ \"$2\" = \"export\" ]; then",
|
|
181
|
-
` printf '%s\\n' '${payload.replace(/'/g, "'\\''")}'`,
|
|
182
|
-
" exit 0",
|
|
183
|
-
"fi",
|
|
184
|
-
"if [ \"$1\" = \"sessions\" ] && [ \"$2\" = \"list\" ]; then",
|
|
185
|
-
" echo 'Title Preview Last Active ID'",
|
|
186
|
-
" echo 'History visible reply just now 20260529_100000_history'",
|
|
187
|
-
" exit 0",
|
|
188
|
-
"fi",
|
|
189
|
-
"if [ \"$1\" = \"status\" ]; then exit 0; fi",
|
|
190
|
-
"echo \"unexpected args: $@\" >&2",
|
|
191
|
-
"exit 2",
|
|
192
|
-
"",
|
|
193
|
-
].join("\n"), "utf8");
|
|
194
|
-
chmodSync(binPath, 0o755);
|
|
195
|
-
assert.equal(existsSync(binPath), true);
|
|
196
|
-
return binPath;
|
|
197
|
-
}
|
|
198
|
-
export function writeFakeHermesBin(root) {
|
|
199
|
-
const binPath = join(root, "hermes");
|
|
200
|
-
writeFileSync(binPath, [
|
|
201
|
-
"#!/bin/sh",
|
|
202
|
-
"if [ \"$1\" = \"sessions\" ] && [ \"$2\" = \"list\" ]; then",
|
|
203
|
-
" echo 'Title Preview Last Active ID'",
|
|
204
|
-
" echo 'Fresh reply fresh reply just now 20260528_181500_abcd12'",
|
|
205
|
-
" exit 0",
|
|
206
|
-
"fi",
|
|
207
|
-
"if [ \"$1\" = \"sessions\" ] && [ \"$2\" = \"export\" ]; then",
|
|
208
|
-
" previous=''",
|
|
209
|
-
" for arg in \"$@\"; do",
|
|
210
|
-
" if [ \"$previous\" = \"--session-id\" ] && [ \"$arg\" = \"missing\" ]; then",
|
|
211
|
-
" echo 'Session not found: missing' >&2",
|
|
212
|
-
" echo 'Use a session ID from a previous CLI run (hermes sessions list).' >&2",
|
|
213
|
-
" exit 1",
|
|
214
|
-
" fi",
|
|
215
|
-
" previous=\"$arg\"",
|
|
216
|
-
" done",
|
|
217
|
-
" echo '{\"model\":\"gpt-5.5\",\"input_tokens\":1,\"model_config\":{\"max_input_tokens\":10}}'",
|
|
218
|
-
" exit 0",
|
|
219
|
-
"fi",
|
|
220
|
-
"if [ \"$1\" = \"status\" ]; then",
|
|
221
|
-
" echo ' Model: gpt-5.5'",
|
|
222
|
-
" echo ' Provider: OpenAI Codex'",
|
|
223
|
-
" exit 0",
|
|
224
|
-
"fi",
|
|
225
|
-
"if [ \"$1\" = \"chat\" ]; then",
|
|
226
|
-
" printf '%s\\n' \"$@\" > \"$0.args\"",
|
|
227
|
-
" previous=''",
|
|
228
|
-
" for arg in \"$@\"; do",
|
|
229
|
-
" if [ \"$previous\" = \"--resume\" ] && [ \"$arg\" = \"missing\" ]; then",
|
|
230
|
-
" echo 'Session not found: missing' >&2",
|
|
231
|
-
" echo 'Use a session ID from a previous CLI run (hermes sessions list).' >&2",
|
|
232
|
-
" exit 1",
|
|
233
|
-
" fi",
|
|
234
|
-
" previous=\"$arg\"",
|
|
235
|
-
" done",
|
|
236
|
-
" echo 'fresh reply'",
|
|
237
|
-
" exit 0",
|
|
238
|
-
"fi",
|
|
239
|
-
"echo \"unexpected args: $@\" >&2",
|
|
240
|
-
"exit 2",
|
|
241
|
-
"",
|
|
242
|
-
].join("\n"), "utf8");
|
|
243
|
-
chmodSync(binPath, 0o755);
|
|
244
|
-
assert.equal(existsSync(binPath), true);
|
|
245
|
-
return binPath;
|
|
246
|
-
}
|
|
247
|
-
export function writeTimeoutDeniedHermesBin(root) {
|
|
248
|
-
const binPath = join(root, "hermes-timeout-denied");
|
|
249
|
-
writeFileSync(binPath, [
|
|
250
|
-
"#!/usr/bin/env node",
|
|
251
|
-
"const args = process.argv.slice(2);",
|
|
252
|
-
"if (args[0] === 'sessions' && args[1] === 'list') {",
|
|
253
|
-
" console.log('Title Preview Last Active ID');",
|
|
254
|
-
" process.exit(0);",
|
|
255
|
-
"}",
|
|
256
|
-
"if (args[0] === 'chat') {",
|
|
257
|
-
" console.log('⏱ Timeout – denying command');",
|
|
258
|
-
" process.on('SIGTERM', () => process.exit(143));",
|
|
259
|
-
" setInterval(() => {}, 1000);",
|
|
260
|
-
" return;",
|
|
261
|
-
"}",
|
|
262
|
-
"if (args[0] === 'status') { process.exit(0); }",
|
|
263
|
-
"console.error(`unexpected args: ${args.join(' ')}`);",
|
|
264
|
-
"process.exit(2);",
|
|
265
|
-
"",
|
|
266
|
-
].join("\n"), "utf8");
|
|
267
|
-
chmodSync(binPath, 0o755);
|
|
268
|
-
assert.equal(existsSync(binPath), true);
|
|
269
|
-
return binPath;
|
|
270
|
-
}
|
|
271
|
-
export function writeAbortPartialHermesBin(root) {
|
|
272
|
-
const binPath = join(root, "hermes-abort-partial");
|
|
273
|
-
writeFileSync(binPath, [
|
|
274
|
-
"#!/usr/bin/env node",
|
|
275
|
-
"const args = process.argv.slice(2);",
|
|
276
|
-
"if (args[0] === 'sessions' && args[1] === 'list') {",
|
|
277
|
-
" console.log('Title Preview Last Active ID');",
|
|
278
|
-
" process.exit(0);",
|
|
279
|
-
"}",
|
|
280
|
-
"if (args[0] === 'chat') {",
|
|
281
|
-
" process.stdout.write('partial ');",
|
|
282
|
-
" process.on('SIGTERM', () => process.exit(143));",
|
|
283
|
-
" setInterval(() => {}, 1000);",
|
|
284
|
-
" return;",
|
|
285
|
-
"}",
|
|
286
|
-
"if (args[0] === 'status') { process.exit(0); }",
|
|
287
|
-
"console.error(`unexpected args: ${args.join(' ')}`);",
|
|
288
|
-
"process.exit(2);",
|
|
289
|
-
"",
|
|
290
|
-
].join("\n"), "utf8");
|
|
291
|
-
chmodSync(binPath, 0o755);
|
|
292
|
-
assert.equal(existsSync(binPath), true);
|
|
293
|
-
return binPath;
|
|
294
|
-
}
|
|
295
|
-
export function writeSlowPartialHermesBin(root) {
|
|
296
|
-
const binPath = join(root, "hermes-slow-partial");
|
|
297
|
-
const partialStartedPath = join(root, "partial-started");
|
|
298
|
-
writeFileSync(binPath, [
|
|
299
|
-
"#!/usr/bin/env node",
|
|
300
|
-
"const fs = require('fs');",
|
|
301
|
-
"const args = process.argv.slice(2);",
|
|
302
|
-
`const partialStartedPath = ${JSON.stringify(partialStartedPath)};`,
|
|
303
|
-
"if (args[0] === 'sessions' && args[1] === 'list') {",
|
|
304
|
-
" console.log('Title Preview Last Active ID');",
|
|
305
|
-
" process.exit(0);",
|
|
306
|
-
"}",
|
|
307
|
-
"if (args[0] === 'chat') {",
|
|
308
|
-
" fs.writeFileSync(partialStartedPath, '1');",
|
|
309
|
-
" process.stdout.write('partial ');",
|
|
310
|
-
" setTimeout(() => {",
|
|
311
|
-
" console.log('reply');",
|
|
312
|
-
" }, 1200);",
|
|
313
|
-
" return;",
|
|
314
|
-
"}",
|
|
315
|
-
"if (args[0] === 'status') { process.exit(0); }",
|
|
316
|
-
"console.error(`unexpected args: ${args.join(' ')}`);",
|
|
317
|
-
"process.exit(2);",
|
|
318
|
-
"",
|
|
319
|
-
].join("\n"), "utf8");
|
|
320
|
-
chmodSync(binPath, 0o755);
|
|
321
|
-
assert.equal(existsSync(binPath), true);
|
|
322
|
-
return binPath;
|
|
323
|
-
}
|
|
324
|
-
export async function waitForFile(path, timeoutMs) {
|
|
325
|
-
const deadline = Date.now() + timeoutMs;
|
|
326
|
-
while (Date.now() < deadline) {
|
|
327
|
-
if (existsSync(path)) {
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
331
|
-
}
|
|
332
|
-
assert.fail(`Timed out waiting for ${path}`);
|
|
333
|
-
}
|
|
334
|
-
export async function waitForHermesDelta(events, expectedText, timeoutMs) {
|
|
335
|
-
const deadline = Date.now() + timeoutMs;
|
|
336
|
-
while (Date.now() < deadline) {
|
|
337
|
-
if (JSON.stringify(events).includes(`"state":"delta"`) && JSON.stringify(events).includes(expectedText)) {
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
341
|
-
}
|
|
342
|
-
assert.fail(`Timed out waiting for Hermes delta containing ${expectedText}`);
|
|
343
|
-
}
|
|
344
|
-
export function writeHistoryCompletingHermesBin(root, sourceRunId) {
|
|
345
|
-
const binPath = join(root, "hermes-history-completion");
|
|
346
|
-
const readyPath = join(root, "history-ready");
|
|
347
|
-
const payload = JSON.stringify({
|
|
348
|
-
sessionId: "20260622_100613_8947a8",
|
|
349
|
-
messages: [
|
|
350
|
-
{
|
|
351
|
-
id: "user-hi",
|
|
352
|
-
role: "user",
|
|
353
|
-
content: sourceRunId
|
|
354
|
-
? `Hi\n\n[ClawConnect mobile turn]\nsourceRunId: ${sourceRunId}\nsessionKey: main`
|
|
355
|
-
: "Hi",
|
|
356
|
-
createdAt: "2026-06-22T02:06:26.000Z",
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
id: "assistant-hi",
|
|
360
|
-
role: "assistant",
|
|
361
|
-
content: "你好!有什么我能帮你的吗?",
|
|
362
|
-
createdAt: "2026-06-22T02:06:33.000Z",
|
|
363
|
-
},
|
|
364
|
-
],
|
|
365
|
-
});
|
|
366
|
-
writeFileSync(binPath, [
|
|
367
|
-
"#!/usr/bin/env node",
|
|
368
|
-
"const fs = require('fs');",
|
|
369
|
-
"const args = process.argv.slice(2);",
|
|
370
|
-
`const readyPath = ${JSON.stringify(readyPath)};`,
|
|
371
|
-
`const payload = ${JSON.stringify(payload)};`,
|
|
372
|
-
"if (args[0] === 'sessions' && args[1] === 'list') {",
|
|
373
|
-
" console.log('Title Preview Last Active ID');",
|
|
374
|
-
" if (fs.existsSync(readyPath)) console.log('Greeting 你好! just now 20260622_100613_8947a8');",
|
|
375
|
-
" process.exit(0);",
|
|
376
|
-
"}",
|
|
377
|
-
"if (args[0] === 'sessions' && args[1] === 'export') {",
|
|
378
|
-
" if (fs.existsSync(readyPath)) { console.log(payload); process.exit(0); }",
|
|
379
|
-
" console.log(JSON.stringify({ sessionId: '20260622_100613_8947a8', messages: [] }));",
|
|
380
|
-
" process.exit(0);",
|
|
381
|
-
"}",
|
|
382
|
-
"if (args[0] === 'chat') {",
|
|
383
|
-
" setTimeout(() => fs.writeFileSync(readyPath, '1'), 100);",
|
|
384
|
-
" process.on('SIGTERM', () => process.exit(0));",
|
|
385
|
-
" setInterval(() => {}, 1000);",
|
|
386
|
-
" return;",
|
|
387
|
-
"}",
|
|
388
|
-
"if (args[0] === 'status') { process.exit(0); }",
|
|
389
|
-
"console.error(`unexpected args: ${args.join(' ')}`);",
|
|
390
|
-
"process.exit(2);",
|
|
391
|
-
"",
|
|
392
|
-
].join("\n"), "utf8");
|
|
393
|
-
chmodSync(binPath, 0o755);
|
|
394
|
-
assert.equal(existsSync(binPath), true);
|
|
395
|
-
return binPath;
|
|
396
|
-
}
|
|
397
|
-
export function writeStaleHistoryHermesBin(root, sourceRunId) {
|
|
398
|
-
const binPath = join(root, "hermes-stale-history");
|
|
399
|
-
const payload = JSON.stringify({
|
|
400
|
-
sessionId: "20260622_100613_8947a8",
|
|
401
|
-
messages: [
|
|
402
|
-
{
|
|
403
|
-
id: "user-hi",
|
|
404
|
-
role: "user",
|
|
405
|
-
content: sourceRunId
|
|
406
|
-
? `Hi\n\n[ClawConnect mobile turn]\nsourceRunId: ${sourceRunId}\nsessionKey: main`
|
|
407
|
-
: "Hi",
|
|
408
|
-
createdAt: "2026-06-22T02:06:26.000Z",
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
id: "assistant-hi",
|
|
412
|
-
role: "assistant",
|
|
413
|
-
content: "你好!👋 我在这里,随时准备帮你解决问题。有什么需要我协助的吗?",
|
|
414
|
-
createdAt: "2026-06-22T02:06:33.000Z",
|
|
415
|
-
},
|
|
416
|
-
],
|
|
417
|
-
});
|
|
418
|
-
writeFileSync(binPath, [
|
|
419
|
-
"#!/usr/bin/env node",
|
|
420
|
-
"const args = process.argv.slice(2);",
|
|
421
|
-
`const payload = ${JSON.stringify(payload)};`,
|
|
422
|
-
"if (args[0] === 'sessions' && args[1] === 'list') {",
|
|
423
|
-
" console.log('Title Preview Last Active ID');",
|
|
424
|
-
" console.log('Greeting 你好! just now 20260622_100613_8947a8');",
|
|
425
|
-
" process.exit(0);",
|
|
426
|
-
"}",
|
|
427
|
-
"if (args[0] === 'sessions' && args[1] === 'export') {",
|
|
428
|
-
" console.log(payload);",
|
|
429
|
-
" process.exit(0);",
|
|
430
|
-
"}",
|
|
431
|
-
"if (args[0] === 'chat') {",
|
|
432
|
-
" setTimeout(() => { console.log('Pong! 🏓'); process.exit(0); }, 2500);",
|
|
433
|
-
" return;",
|
|
434
|
-
"}",
|
|
435
|
-
"if (args[0] === 'status') { process.exit(0); }",
|
|
436
|
-
"console.error(`unexpected args: ${args.join(' ')}`);",
|
|
437
|
-
"process.exit(2);",
|
|
438
|
-
"",
|
|
439
|
-
].join("\n"), "utf8");
|
|
440
|
-
chmodSync(binPath, 0o755);
|
|
441
|
-
assert.equal(existsSync(binPath), true);
|
|
442
|
-
return binPath;
|
|
443
|
-
}
|
|
444
|
-
export function writeRepeatedUserStaleHistoryHermesBin(root, sourceRunId) {
|
|
445
|
-
const binPath = join(root, "hermes-repeated-user-stale-history");
|
|
446
|
-
const payload = JSON.stringify({
|
|
447
|
-
sessionId: "20260622_100613_8947a8",
|
|
448
|
-
messages: [
|
|
449
|
-
{
|
|
450
|
-
id: "user-old-hi",
|
|
451
|
-
role: "user",
|
|
452
|
-
content: "Hi",
|
|
453
|
-
createdAt: "2026-06-22T02:06:26.000Z",
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
id: "assistant-old-hi",
|
|
457
|
-
role: "assistant",
|
|
458
|
-
content: "old hi reply",
|
|
459
|
-
createdAt: "2026-06-22T02:06:33.000Z",
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
id: "user-visible",
|
|
463
|
-
role: "user",
|
|
464
|
-
content: sourceRunId
|
|
465
|
-
? `iOS final visible\n\n[ClawConnect mobile turn]\nsourceRunId: ${sourceRunId}\nsessionKey: main`
|
|
466
|
-
: "iOS final visible",
|
|
467
|
-
createdAt: "2026-06-22T06:18:04.000Z",
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
id: "assistant-visible",
|
|
471
|
-
role: "assistant",
|
|
472
|
-
content: "stale visible reply",
|
|
473
|
-
createdAt: "2026-06-22T06:18:12.000Z",
|
|
474
|
-
},
|
|
475
|
-
],
|
|
476
|
-
});
|
|
477
|
-
writeFileSync(binPath, [
|
|
478
|
-
"#!/usr/bin/env node",
|
|
479
|
-
"const args = process.argv.slice(2);",
|
|
480
|
-
`const payload = ${JSON.stringify(payload)};`,
|
|
481
|
-
"if (args[0] === 'sessions' && args[1] === 'list') {",
|
|
482
|
-
" console.log('Title Preview Last Active ID');",
|
|
483
|
-
" console.log('Greeting stale just now 20260622_100613_8947a8');",
|
|
484
|
-
" process.exit(0);",
|
|
485
|
-
"}",
|
|
486
|
-
"if (args[0] === 'sessions' && args[1] === 'export') {",
|
|
487
|
-
" console.log(payload);",
|
|
488
|
-
" process.exit(0);",
|
|
489
|
-
"}",
|
|
490
|
-
"if (args[0] === 'chat') {",
|
|
491
|
-
" setTimeout(() => { console.log('fresh hi reply'); process.exit(0); }, 2500);",
|
|
492
|
-
" return;",
|
|
493
|
-
"}",
|
|
494
|
-
"if (args[0] === 'status') { process.exit(0); }",
|
|
495
|
-
"console.error(`unexpected args: ${args.join(' ')}`);",
|
|
496
|
-
"process.exit(2);",
|
|
497
|
-
"",
|
|
498
|
-
].join("\n"), "utf8");
|
|
499
|
-
chmodSync(binPath, 0o755);
|
|
500
|
-
assert.equal(existsSync(binPath), true);
|
|
501
|
-
return binPath;
|
|
502
|
-
}
|
|
503
|
-
export function writeConcurrentDetectingHermesBin(root) {
|
|
504
|
-
const binPath = join(root, "hermes-concurrent-detect");
|
|
505
|
-
const activePath = join(root, "active");
|
|
506
|
-
const concurrentPath = join(root, "concurrent");
|
|
507
|
-
writeFileSync(binPath, [
|
|
508
|
-
"#!/usr/bin/env node",
|
|
509
|
-
"const fs = require('fs');",
|
|
510
|
-
"const args = process.argv.slice(2);",
|
|
511
|
-
`const activePath = ${JSON.stringify(activePath)};`,
|
|
512
|
-
`const concurrentPath = ${JSON.stringify(concurrentPath)};`,
|
|
513
|
-
"if (args[0] === 'sessions' && args[1] === 'list') {",
|
|
514
|
-
" console.log('Title Preview Last Active ID');",
|
|
515
|
-
" process.exit(0);",
|
|
516
|
-
"}",
|
|
517
|
-
"if (args[0] === 'chat') {",
|
|
518
|
-
" const queryIndex = args.indexOf('--query');",
|
|
519
|
-
" const rawQuery = queryIndex >= 0 ? args[queryIndex + 1] : '';",
|
|
520
|
-
" const query = rawQuery.split('\\n\\n[ClawConnect mobile bridge]')[0];",
|
|
521
|
-
" if (fs.existsSync(activePath)) fs.writeFileSync(concurrentPath, '1');",
|
|
522
|
-
" fs.writeFileSync(activePath, query);",
|
|
523
|
-
" setTimeout(() => {",
|
|
524
|
-
" try { fs.unlinkSync(activePath); } catch {}",
|
|
525
|
-
" console.log(`reply:${query}`);",
|
|
526
|
-
" process.exit(0);",
|
|
527
|
-
" }, 200);",
|
|
528
|
-
" return;",
|
|
529
|
-
"}",
|
|
530
|
-
"if (args[0] === 'status') { process.exit(0); }",
|
|
531
|
-
"console.error(`unexpected args: ${args.join(' ')}`);",
|
|
532
|
-
"process.exit(2);",
|
|
533
|
-
"",
|
|
534
|
-
].join("\n"), "utf8");
|
|
535
|
-
chmodSync(binPath, 0o755);
|
|
536
|
-
assert.equal(existsSync(binPath), true);
|
|
537
|
-
return binPath;
|
|
538
|
-
}
|
|
539
|
-
export function writeBarrieredHistoryExportHermesBin(root, sessionId = "20260529_100000_history") {
|
|
540
|
-
const binPath = join(root, "hermes-history-export-concurrent");
|
|
541
|
-
const exportActivePath = join(root, "history-export-active");
|
|
542
|
-
const allowExportCompletePath = join(root, "history-export-complete");
|
|
543
|
-
const concurrentPath = join(root, "history-export-concurrent");
|
|
544
|
-
const payload = JSON.stringify({
|
|
545
|
-
sessionId,
|
|
546
|
-
messages: [
|
|
547
|
-
{
|
|
548
|
-
id: "m1",
|
|
549
|
-
role: "user",
|
|
550
|
-
content: "hello",
|
|
551
|
-
createdAt: "2026-05-29T02:00:00.000Z",
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
id: "m2",
|
|
555
|
-
role: "assistant",
|
|
556
|
-
content: "visible reply",
|
|
557
|
-
createdAt: "2026-05-29T02:00:01.000Z",
|
|
558
|
-
},
|
|
559
|
-
],
|
|
560
|
-
});
|
|
561
|
-
writeFileSync(binPath, [
|
|
562
|
-
"#!/usr/bin/env node",
|
|
563
|
-
"const fs = require('fs');",
|
|
564
|
-
"const args = process.argv.slice(2);",
|
|
565
|
-
`const exportActivePath = ${JSON.stringify(exportActivePath)};`,
|
|
566
|
-
`const allowExportCompletePath = ${JSON.stringify(allowExportCompletePath)};`,
|
|
567
|
-
`const concurrentPath = ${JSON.stringify(concurrentPath)};`,
|
|
568
|
-
`const payload = ${JSON.stringify(payload)};`,
|
|
569
|
-
"if (args[0] === 'sessions' && args[1] === 'list') {",
|
|
570
|
-
" console.log('Title Preview Last Active ID');",
|
|
571
|
-
` console.log('History visible reply just now ${sessionId}');`,
|
|
572
|
-
" process.exit(0);",
|
|
573
|
-
"}",
|
|
574
|
-
"if (args[0] === 'sessions' && args[1] === 'export') {",
|
|
575
|
-
" fs.writeFileSync(exportActivePath, '1');",
|
|
576
|
-
" const interval = setInterval(() => {",
|
|
577
|
-
" if (!fs.existsSync(allowExportCompletePath)) return;",
|
|
578
|
-
" clearInterval(interval);",
|
|
579
|
-
" try { fs.unlinkSync(exportActivePath); } catch {}",
|
|
580
|
-
" console.log(payload);",
|
|
581
|
-
" process.exit(0);",
|
|
582
|
-
" }, 10);",
|
|
583
|
-
" setTimeout(() => process.exit(3), 5000);",
|
|
584
|
-
" return;",
|
|
585
|
-
"}",
|
|
586
|
-
"if (args[0] === 'chat') {",
|
|
587
|
-
" const queryIndex = args.indexOf('--query');",
|
|
588
|
-
" const rawQuery = queryIndex >= 0 ? args[queryIndex + 1] : '';",
|
|
589
|
-
" const query = rawQuery.split('\\n\\n[ClawConnect mobile bridge]')[0];",
|
|
590
|
-
" if (fs.existsSync(exportActivePath)) fs.writeFileSync(concurrentPath, '1');",
|
|
591
|
-
" console.log(`reply:${query}`);",
|
|
592
|
-
" process.exit(0);",
|
|
593
|
-
"}",
|
|
594
|
-
"if (args[0] === 'status') { process.exit(0); }",
|
|
595
|
-
"console.error(`unexpected args: ${args.join(' ')}`);",
|
|
596
|
-
"process.exit(2);",
|
|
597
|
-
"",
|
|
598
|
-
].join("\n"), "utf8");
|
|
599
|
-
chmodSync(binPath, 0o755);
|
|
600
|
-
assert.equal(existsSync(binPath), true);
|
|
601
|
-
return { binPath, exportActivePath, allowExportCompletePath, concurrentPath };
|
|
602
|
-
}
|
|
603
|
-
export function writeResumeMetadataHermesBin(root) {
|
|
604
|
-
const binPath = join(root, "hermes-resume-metadata");
|
|
605
|
-
writeFileSync(binPath, [
|
|
606
|
-
"#!/bin/sh",
|
|
607
|
-
"if [ \"$1\" = \"sessions\" ] && [ \"$2\" = \"list\" ]; then",
|
|
608
|
-
" echo 'Title Preview Last Active ID'",
|
|
609
|
-
" echo 'Visible reply visible reply just now 20260528_181501_abcd12'",
|
|
610
|
-
" exit 0",
|
|
611
|
-
"fi",
|
|
612
|
-
"if [ \"$1\" = \"chat\" ]; then",
|
|
613
|
-
" echo '↻ Resumed session 20260525_114940_1cccb9'",
|
|
614
|
-
" printf \"%s\\n\" \"Error: 'NoneType' object is not iterable\"",
|
|
615
|
-
" echo 'session_id: 20260525_114940_1cccb9'",
|
|
616
|
-
" echo 'visible reply'",
|
|
617
|
-
" exit 0",
|
|
618
|
-
"fi",
|
|
619
|
-
"if [ \"$1\" = \"status\" ]; then",
|
|
620
|
-
" echo ' Model: gpt-5.5'",
|
|
621
|
-
" echo ' Provider: OpenAI Codex'",
|
|
622
|
-
" exit 0",
|
|
623
|
-
"fi",
|
|
624
|
-
"echo \"unexpected args: $@\" >&2",
|
|
625
|
-
"exit 2",
|
|
626
|
-
"",
|
|
627
|
-
].join("\n"), "utf8");
|
|
628
|
-
chmodSync(binPath, 0o755);
|
|
629
|
-
assert.equal(existsSync(binPath), true);
|
|
630
|
-
return binPath;
|
|
631
|
-
}
|
|
632
|
-
export function writeHistoryHermesBin(root) {
|
|
633
|
-
const binPath = join(root, "hermes-history");
|
|
634
|
-
const payload = JSON.stringify({
|
|
635
|
-
sessionId: "20260529_100000_history",
|
|
636
|
-
messages: [
|
|
637
|
-
{
|
|
638
|
-
id: "m1",
|
|
639
|
-
role: "user",
|
|
640
|
-
content: "hello",
|
|
641
|
-
createdAt: "2026-05-29T02:00:00.000Z",
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
id: "m2",
|
|
645
|
-
role: "assistant",
|
|
646
|
-
content: [
|
|
647
|
-
{ type: "text", text: "↻ Resumed session 20260525_114940_1cccb9" },
|
|
648
|
-
{ type: "text", text: "Error: 'NoneType' object is not iterable" },
|
|
649
|
-
{ type: "text", text: "session_id: 20260525_114940_1cccb9" },
|
|
650
|
-
{ type: "text", text: "visible reply" },
|
|
651
|
-
{ type: "file", fileId: "file-history-1", fileName: "report.pdf", mimeType: "application/pdf" },
|
|
652
|
-
],
|
|
653
|
-
createdAt: "2026-05-29T02:00:01.000Z",
|
|
654
|
-
},
|
|
655
|
-
],
|
|
656
|
-
});
|
|
657
|
-
writeFileSync(binPath, [
|
|
658
|
-
"#!/bin/sh",
|
|
659
|
-
"if [ \"$1\" = \"sessions\" ] && [ \"$2\" = \"export\" ]; then",
|
|
660
|
-
` printf '%s\\n' '${payload.replace(/'/g, "'\\''")}'`,
|
|
661
|
-
" exit 0",
|
|
662
|
-
"fi",
|
|
663
|
-
"if [ \"$1\" = \"sessions\" ] && [ \"$2\" = \"list\" ]; then",
|
|
664
|
-
" echo 'Title Preview Last Active ID'",
|
|
665
|
-
" echo 'History visible reply just now 20260529_100000_history'",
|
|
666
|
-
" exit 0",
|
|
667
|
-
"fi",
|
|
668
|
-
"if [ \"$1\" = \"status\" ]; then exit 0; fi",
|
|
669
|
-
"echo \"unexpected args: $@\" >&2",
|
|
670
|
-
"exit 2",
|
|
671
|
-
"",
|
|
672
|
-
].join("\n"), "utf8");
|
|
673
|
-
chmodSync(binPath, 0o755);
|
|
674
|
-
assert.equal(existsSync(binPath), true);
|
|
675
|
-
return binPath;
|
|
676
|
-
}
|
|
677
|
-
export function writeUntimedHistoryHermesBin(root) {
|
|
678
|
-
const binPath = join(root, "hermes-history-untimed");
|
|
679
|
-
const payload = JSON.stringify({
|
|
680
|
-
sessionId: "20260529_100000_history",
|
|
681
|
-
messages: [
|
|
682
|
-
{
|
|
683
|
-
id: "m1",
|
|
684
|
-
role: "user",
|
|
685
|
-
content: "hello",
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
id: "m2",
|
|
689
|
-
role: "assistant",
|
|
690
|
-
content: "visible reply",
|
|
691
|
-
},
|
|
692
|
-
],
|
|
693
|
-
});
|
|
694
|
-
writeFileSync(binPath, [
|
|
695
|
-
"#!/bin/sh",
|
|
696
|
-
"if [ \"$1\" = \"sessions\" ] && [ \"$2\" = \"export\" ]; then",
|
|
697
|
-
` printf '%s\\n' '${payload.replace(/'/g, "'\\''")}'`,
|
|
698
|
-
" exit 0",
|
|
699
|
-
"fi",
|
|
700
|
-
"if [ \"$1\" = \"status\" ]; then exit 0; fi",
|
|
701
|
-
"echo \"unexpected args: $@\" >&2",
|
|
702
|
-
"exit 2",
|
|
703
|
-
"",
|
|
704
|
-
].join("\n"), "utf8");
|
|
705
|
-
chmodSync(binPath, 0o755);
|
|
706
|
-
assert.equal(existsSync(binPath), true);
|
|
707
|
-
return binPath;
|
|
708
|
-
}
|
|
709
|
-
//# sourceMappingURL=hermes-runtime-test-support.js.map
|