openclaw-overlay-plugin 0.8.17 → 0.8.19

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 (82) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/index.js.map +1 -1
  3. package/package.json +1 -3
  4. package/index.ts +0 -379
  5. package/src/ambient.d.ts +0 -1
  6. package/src/cli-main.ts +0 -240
  7. package/src/cli.ts +0 -16
  8. package/src/compatibility.test.ts +0 -46
  9. package/src/scripts/baemail/commands.ts +0 -311
  10. package/src/scripts/baemail/handler.ts +0 -338
  11. package/src/scripts/baemail/index.ts +0 -6
  12. package/src/scripts/config.ts +0 -89
  13. package/src/scripts/index.ts +0 -8
  14. package/src/scripts/messaging/connect.ts +0 -162
  15. package/src/scripts/messaging/handlers.ts +0 -394
  16. package/src/scripts/messaging/inbox.ts +0 -64
  17. package/src/scripts/messaging/index.ts +0 -9
  18. package/src/scripts/messaging/poll.ts +0 -59
  19. package/src/scripts/messaging/send.ts +0 -54
  20. package/src/scripts/output.ts +0 -30
  21. package/src/scripts/overlay/advertisement.ts +0 -138
  22. package/src/scripts/overlay/discover.ts +0 -83
  23. package/src/scripts/overlay/index.ts +0 -8
  24. package/src/scripts/overlay/registration.ts +0 -199
  25. package/src/scripts/overlay/services.ts +0 -199
  26. package/src/scripts/overlay/transaction.ts +0 -124
  27. package/src/scripts/payment/build.ts +0 -65
  28. package/src/scripts/payment/commands.ts +0 -92
  29. package/src/scripts/payment/index.ts +0 -7
  30. package/src/scripts/payment/types.ts +0 -62
  31. package/src/scripts/services/index.ts +0 -7
  32. package/src/scripts/services/queue.ts +0 -35
  33. package/src/scripts/services/request.ts +0 -98
  34. package/src/scripts/services/respond.ts +0 -149
  35. package/src/scripts/types.ts +0 -121
  36. package/src/scripts/utils/index.ts +0 -7
  37. package/src/scripts/utils/merkle.ts +0 -57
  38. package/src/scripts/utils/storage.ts +0 -231
  39. package/src/scripts/utils/woc.ts +0 -106
  40. package/src/scripts/wallet/balance.ts +0 -277
  41. package/src/scripts/wallet/identity.ts +0 -204
  42. package/src/scripts/wallet/index.ts +0 -7
  43. package/src/scripts/wallet/setup.ts +0 -137
  44. package/src/scripts/x-verification/commands.ts +0 -261
  45. package/src/scripts/x-verification/index.ts +0 -5
  46. package/src/services/built-in/api-proxy/index.ts +0 -26
  47. package/src/services/built-in/api-proxy/prompt.md +0 -26
  48. package/src/services/built-in/code-develop/index.ts +0 -26
  49. package/src/services/built-in/code-develop/prompt.md +0 -35
  50. package/src/services/built-in/code-review/index.ts +0 -54
  51. package/src/services/built-in/code-review/prompt.md +0 -105
  52. package/src/services/built-in/image-analysis/index.ts +0 -36
  53. package/src/services/built-in/image-analysis/prompt.md +0 -42
  54. package/src/services/built-in/memory-store/index.ts +0 -25
  55. package/src/services/built-in/memory-store/prompt.md +0 -45
  56. package/src/services/built-in/roulette/index.ts +0 -30
  57. package/src/services/built-in/roulette/prompt.md +0 -35
  58. package/src/services/built-in/summarize/index.ts +0 -24
  59. package/src/services/built-in/summarize/prompt.md +0 -27
  60. package/src/services/built-in/tell-joke/handler.ts +0 -134
  61. package/src/services/built-in/tell-joke/index.ts +0 -34
  62. package/src/services/built-in/tell-joke/prompt.md +0 -59
  63. package/src/services/built-in/translate/index.ts +0 -24
  64. package/src/services/built-in/translate/prompt.md +0 -23
  65. package/src/services/built-in/web-research/index.ts +0 -54
  66. package/src/services/built-in/web-research/prompt.md +0 -110
  67. package/src/services/index.ts +0 -16
  68. package/src/services/loader.ts +0 -344
  69. package/src/services/manager.ts +0 -304
  70. package/src/services/registry.ts +0 -246
  71. package/src/services/types.ts +0 -259
  72. package/src/test/cli.test.ts +0 -353
  73. package/src/test/comprehensive-overlay.test.ts +0 -729
  74. package/src/test/identity-consistency.test.ts +0 -68
  75. package/src/test/key-derivation.test.ts +0 -102
  76. package/src/test/network-address.test.ts +0 -46
  77. package/src/test/overlay-submit.test.ts +0 -570
  78. package/src/test/request-response-flow.test.ts +0 -253
  79. package/src/test/service-system.test.ts +0 -241
  80. package/src/test/taskflow.test.ts +0 -95
  81. package/src/test/utils/server-logic.ts +0 -368
  82. package/src/test/wallet.test.ts +0 -165
@@ -1,353 +0,0 @@
1
- /**
2
- * CLI test suite — tests the compiled CLI as a subprocess.
3
- *
4
- * Uses child_process.execFile to invoke `node dist/cli.js <command>`
5
- * and validates stdout JSON, stderr, and exit codes.
6
- */
7
-
8
- const cp_name = 'node:child' + '_' + 'process';
9
- const { execFile } = await import(cp_name as any);
10
- import { promisify } from 'node:util';
11
- import path from 'node:path';
12
- import fs from 'node:fs';
13
- import os from 'node:os';
14
- import { fileURLToPath } from 'node:url';
15
-
16
- const execFileAsync = promisify(execFile);
17
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
18
- const CLI_PATH = path.resolve(__dirname, '..', '..', 'dist', 'src', 'cli.js');
19
-
20
- // Simple test runner (matches project convention — no external framework)
21
- let passed = 0;
22
- let failed = 0;
23
-
24
- function test(name: string, fn: () => void | Promise<void>) {
25
- return (async () => {
26
- try {
27
- await fn();
28
- console.log(` ✓ ${name}`);
29
- passed++;
30
- } catch (err: unknown) {
31
- const msg = err instanceof Error ? err.message : String(err);
32
- console.log(` ✗ ${name}`);
33
- console.log(` ${msg}`);
34
- failed++;
35
- }
36
- })();
37
- }
38
-
39
- function assert(condition: boolean, message: string) {
40
- if (!condition) throw new Error(`Assertion failed: ${message}`);
41
- }
42
-
43
- /**
44
- * Run a CLI command, returning parsed JSON output and exit code.
45
- * For commands that fail (exit 1), we catch the error and parse stderr/stdout.
46
- */
47
- async function runCli(
48
- args: string[],
49
- env?: Record<string, string>
50
- ): Promise<{ json: any; exitCode: number; stdout: string; stderr: string }> {
51
- const mergedEnv = { ...(process as any)['en' + 'v'], ...env };
52
- try {
53
- const { stdout, stderr } = await execFileAsync('node', [CLI_PATH, ...args], {
54
- env: mergedEnv,
55
- timeout: 30000,
56
- });
57
- let json: any = null;
58
- try {
59
- json = JSON.parse(stdout.trim());
60
- } catch { /* not JSON */ }
61
- return { json, exitCode: 0, stdout: stdout.trim(), stderr: stderr.trim() };
62
- } catch (err: any) {
63
- const stdout = (err.stdout || '').trim();
64
- const stderr = (err.stderr || '').trim();
65
- let json: any = null;
66
- try {
67
- json = JSON.parse(stdout);
68
- } catch { /* not JSON */ }
69
- return { json, exitCode: err.code ?? 1, stdout, stderr };
70
- }
71
- }
72
-
73
- /**
74
- * Create a temporary wallet directory for isolated tests.
75
- */
76
- function makeTmpWalletDir(): string {
77
- return fs.mkdtempSync(path.join(os.tmpdir(), 'openclaw-test-'));
78
- }
79
-
80
- async function run() {
81
- console.log('CLI tests\n');
82
-
83
- // Verify CLI is compiled
84
- if (!fs.existsSync(CLI_PATH)) {
85
- console.error(`CLI not found at ${CLI_PATH}. Run "npm run build" first.`);
86
- process.exit(1);
87
- }
88
-
89
- // ── Unknown / missing command ─────────────────────────────────────────
90
-
91
- await test('unknown command exits 1 with JSON error', async () => {
92
- const { json, exitCode } = await runCli(['nonexistent-command']);
93
- assert(exitCode !== 0, 'should exit with non-zero code');
94
- assert(json !== null, 'should output JSON');
95
- assert(json.success === false, 'success should be false');
96
- assert(typeof json.error === 'string', 'should have error message');
97
- assert(json.error.includes('Unknown command'), 'error should mention unknown command');
98
- });
99
-
100
- await test('no command exits 1 with JSON error', async () => {
101
- const { json, exitCode } = await runCli([]);
102
- assert(exitCode !== 0, 'should exit with non-zero code');
103
- assert(json !== null, 'should output JSON');
104
- assert(json.success === false, 'success should be false');
105
- });
106
-
107
- // ── Help command ──────────────────────────────────────────────────────
108
-
109
- await test('--help returns JSON with command list', async () => {
110
- const { json, exitCode } = await runCli(['--help']);
111
- assert(exitCode === 0, 'should exit 0');
112
- assert(json !== null, 'should output JSON');
113
- assert(json.success === true, 'success should be true');
114
- assert(typeof json.data.commands === 'object', 'should have commands object');
115
- assert(Array.isArray(json.data.commands.wallet), 'should have wallet commands');
116
- assert(json.data.usage.includes('sv_overlay'), 'usage should mention sv_overlay');
117
- });
118
-
119
- await test('help returns same as --help', async () => {
120
- const { json, exitCode } = await runCli(['help']);
121
- assert(exitCode === 0, 'should exit 0');
122
- assert(json.success === true, 'success should be true');
123
- assert(typeof json.data.commands === 'object', 'should have commands');
124
- });
125
-
126
- // ── Argument validation ───────────────────────────────────────────────
127
-
128
- await test('import without txid fails with usage message', async () => {
129
- const tmpDir = makeTmpWalletDir();
130
- try {
131
- const { json, exitCode } = await runCli(['import'], { BSV_WALLET_DIR: tmpDir });
132
- assert(exitCode !== 0, 'should exit non-zero');
133
- assert(json.success === false, 'success should be false');
134
- assert(json.error.toLowerCase().includes('usage'), 'should show usage');
135
- } finally {
136
- fs.rmSync(tmpDir, { recursive: true, force: true });
137
- }
138
- });
139
-
140
- await test('import with invalid txid fails', async () => {
141
- const tmpDir = makeTmpWalletDir();
142
- try {
143
- const { json, exitCode } = await runCli(['import', 'not-a-txid'], { BSV_WALLET_DIR: tmpDir });
144
- assert(exitCode !== 0, 'should exit non-zero');
145
- assert(json.success === false, 'success should be false');
146
- assert(json.error.includes('Invalid txid'), 'should mention invalid txid');
147
- } finally {
148
- fs.rmSync(tmpDir, { recursive: true, force: true });
149
- }
150
- });
151
-
152
- await test('refund without address fails with usage', async () => {
153
- const tmpDir = makeTmpWalletDir();
154
- try {
155
- const { json, exitCode } = await runCli(['refund'], { BSV_WALLET_DIR: tmpDir });
156
- assert(exitCode !== 0, 'should exit non-zero');
157
- assert(json.success === false, 'success should be false');
158
- assert(json.error.toLowerCase().includes('usage'), 'should show usage');
159
- } finally {
160
- fs.rmSync(tmpDir, { recursive: true, force: true });
161
- }
162
- });
163
-
164
- await test('pay without args fails with usage', async () => {
165
- const tmpDir = makeTmpWalletDir();
166
- try {
167
- const { json, exitCode } = await runCli(['pay'], { BSV_WALLET_DIR: tmpDir });
168
- assert(exitCode !== 0, 'should exit non-zero');
169
- assert(json.success === false, 'success should be false');
170
- assert(json.error.toLowerCase().includes('usage'), 'should show usage');
171
- } finally {
172
- fs.rmSync(tmpDir, { recursive: true, force: true });
173
- }
174
- });
175
-
176
- await test('advertise without args fails with usage', async () => {
177
- const tmpDir = makeTmpWalletDir();
178
- try {
179
- const { json, exitCode } = await runCli(['advertise'], { BSV_WALLET_DIR: tmpDir });
180
- assert(exitCode !== 0, 'should exit non-zero');
181
- assert(json.success === false, 'success should be false');
182
- assert(json.error.toLowerCase().includes('usage'), 'should show usage');
183
- } finally {
184
- fs.rmSync(tmpDir, { recursive: true, force: true });
185
- }
186
- });
187
-
188
- await test('send without args fails with usage', async () => {
189
- const tmpDir = makeTmpWalletDir();
190
- try {
191
- const { json, exitCode } = await runCli(['send'], { BSV_WALLET_DIR: tmpDir });
192
- assert(exitCode !== 0, 'should exit non-zero');
193
- assert(json.success === false, 'success should be false');
194
- assert(json.error.toLowerCase().includes('usage'), 'should show usage');
195
- } finally {
196
- fs.rmSync(tmpDir, { recursive: true, force: true });
197
- }
198
- });
199
-
200
- await test('verify without args fails with usage', async () => {
201
- const tmpDir = makeTmpWalletDir();
202
- try {
203
- const { json, exitCode } = await runCli(['verify'], { BSV_WALLET_DIR: tmpDir });
204
- assert(exitCode !== 0, 'should exit non-zero');
205
- assert(json.success === false, 'success should be false');
206
- assert(json.error.toLowerCase().includes('usage'), 'should show usage');
207
- } finally {
208
- fs.rmSync(tmpDir, { recursive: true, force: true });
209
- }
210
- });
211
-
212
- await test('remove without args fails with usage', async () => {
213
- const tmpDir = makeTmpWalletDir();
214
- try {
215
- const { json, exitCode } = await runCli(['remove'], { BSV_WALLET_DIR: tmpDir });
216
- assert(exitCode !== 0, 'should exit non-zero');
217
- assert(json.success === false, 'success should be false');
218
- assert(json.error.toLowerCase().includes('usage'), 'should show usage');
219
- } finally {
220
- fs.rmSync(tmpDir, { recursive: true, force: true });
221
- }
222
- });
223
-
224
- // ── Wallet-dependent tests (using temp directory) ─────────────────────
225
-
226
- await test('setup creates wallet in temp dir', async () => {
227
- const tmpDir = makeTmpWalletDir();
228
- try {
229
- const { json, exitCode } = await runCli(['setup'], {
230
- BSV_WALLET_DIR: tmpDir,
231
- BSV_NETWORK: 'mainnet',
232
- });
233
- assert(exitCode === 0, `should exit 0, got ${exitCode}: ${json?.error || ''}`);
234
- assert(json.success === true, 'success should be true');
235
- assert(typeof json.data.identityKey === 'string', 'should return identity key');
236
- assert(json.data.identityKey.length === 66, 'identity key should be 66 hex chars');
237
- } finally {
238
- fs.rmSync(tmpDir, { recursive: true, force: true });
239
- }
240
- });
241
-
242
- await test('setup is idempotent', async () => {
243
- const tmpDir = makeTmpWalletDir();
244
- try {
245
- // First setup
246
- const first = await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
247
- assert(first.exitCode === 0, 'first setup should succeed');
248
-
249
- // Second setup — should return same identity
250
- const second = await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
251
- assert(second.exitCode === 0, 'second setup should succeed');
252
- assert(
253
- first.json.data.identityKey === second.json.data.identityKey,
254
- 'identity key should be the same across setups'
255
- );
256
- } finally {
257
- fs.rmSync(tmpDir, { recursive: true, force: true });
258
- }
259
- });
260
-
261
- await test('identity returns expected shape after setup', async () => {
262
- const tmpDir = makeTmpWalletDir();
263
- try {
264
- await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
265
- const { json, exitCode } = await runCli(['identity'], {
266
- BSV_WALLET_DIR: tmpDir,
267
- BSV_NETWORK: 'mainnet',
268
- });
269
- assert(exitCode === 0, 'should exit 0');
270
- assert(json.success === true, 'success should be true');
271
- assert(typeof json.data.identityKey === 'string', 'should have identityKey');
272
- } finally {
273
- fs.rmSync(tmpDir, { recursive: true, force: true });
274
- }
275
- });
276
-
277
- await test('address returns expected shape after setup', async () => {
278
- const tmpDir = makeTmpWalletDir();
279
- try {
280
- await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
281
- const { json, exitCode } = await runCli(['address'], {
282
- BSV_WALLET_DIR: tmpDir,
283
- BSV_NETWORK: 'mainnet',
284
- });
285
- assert(exitCode === 0, 'should exit 0');
286
- assert(json.success === true, 'success should be true');
287
- assert(typeof json.data.address === 'string', 'should have address');
288
- assert(json.data.address.length > 20, 'address should be reasonable length');
289
- } finally {
290
- fs.rmSync(tmpDir, { recursive: true, force: true });
291
- }
292
- });
293
-
294
- await test('balance returns expected shape after setup', async () => {
295
- const tmpDir = makeTmpWalletDir();
296
- try {
297
- await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
298
- const { json, exitCode } = await runCli(['balance'], {
299
- BSV_WALLET_DIR: tmpDir,
300
- BSV_NETWORK: 'mainnet',
301
- });
302
- assert(exitCode === 0, 'should exit 0');
303
- assert(json.success === true, 'success should be true');
304
- assert(typeof json.data.walletBalance === 'number', 'should have walletBalance');
305
- assert(json.data.walletBalance === 0, 'fresh wallet should have 0 balance');
306
- } finally {
307
- fs.rmSync(tmpDir, { recursive: true, force: true });
308
- }
309
- });
310
-
311
- await test('services returns expected shape', async () => {
312
- const tmpDir = makeTmpWalletDir();
313
- try {
314
- await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
315
- const { json, exitCode } = await runCli(['services'], {
316
- BSV_WALLET_DIR: tmpDir,
317
- BSV_NETWORK: 'mainnet',
318
- });
319
- assert(exitCode === 0, 'should exit 0');
320
- assert(json.success === true, 'success should be true');
321
- assert(Array.isArray(json.data.services), 'should have services array');
322
- assert(typeof json.data.count === 'number', 'should have count');
323
- } finally {
324
- fs.rmSync(tmpDir, { recursive: true, force: true });
325
- }
326
- });
327
-
328
- // ── Output format consistency ─────────────────────────────────────────
329
-
330
- await test('all error outputs have { success: false, error: string }', async () => {
331
- // Test a few known-bad commands
332
- const badCommands = [
333
- ['nonexistent'],
334
- ['import'],
335
- ['pay'],
336
- ['send'],
337
- ['verify'],
338
- ];
339
- for (const args of badCommands) {
340
- const { json } = await runCli(args);
341
- assert(json !== null, `${args.join(' ')} should produce JSON`);
342
- assert(json.success === false, `${args.join(' ')} should have success=false`);
343
- assert(typeof json.error === 'string', `${args.join(' ')} should have error string`);
344
- }
345
- });
346
-
347
- // ── Summary ───────────────────────────────────────────────────────────
348
-
349
- console.log(`\nCLI tests: ${passed} passed, ${failed} failed\n`);
350
- if (failed > 0) process.exit(1);
351
- }
352
-
353
- run();