openclaw-overlay-plugin 0.8.14 → 0.8.16
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/index.js +6705 -326
- package/dist/index.js.map +7 -0
- package/dist/src/cli.js +7498 -11
- package/dist/src/cli.js.map +7 -0
- package/index.ts +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +8 -8
- package/src/scripts/messaging/handlers.ts +1 -1
- package/src/scripts/overlay/advertisement.ts +1 -1
- package/src/scripts/overlay/registration.ts +1 -1
- package/src/scripts/overlay/services.ts +1 -1
- package/src/scripts/overlay/transaction.ts +1 -1
- package/src/scripts/payment/build.ts +1 -1
- package/src/scripts/payment/commands.ts +1 -1
- package/src/scripts/wallet/balance.ts +1 -1
- package/src/scripts/wallet/setup.ts +1 -1
- package/src/test/identity-consistency.test.ts +1 -1
- package/src/test/wallet.test.ts +1 -2
- package/dist/index.d.ts +0 -9
- package/dist/src/cli-main.d.ts +0 -7
- package/dist/src/cli-main.js +0 -202
- package/dist/src/cli.d.ts +0 -8
- package/dist/src/compatibility.test.d.ts +0 -4
- package/dist/src/compatibility.test.js +0 -41
- package/dist/src/core/config.d.ts +0 -11
- package/dist/src/core/config.js +0 -15
- package/dist/src/core/index.d.ts +0 -25
- package/dist/src/core/index.js +0 -26
- package/dist/src/core/payment.d.ts +0 -16
- package/dist/src/core/payment.js +0 -94
- package/dist/src/core/types.d.ts +0 -94
- package/dist/src/core/types.js +0 -4
- package/dist/src/core/verify.d.ts +0 -28
- package/dist/src/core/verify.js +0 -104
- package/dist/src/core/wallet.d.ts +0 -105
- package/dist/src/core/wallet.js +0 -256
- package/dist/src/scripts/baemail/commands.d.ts +0 -35
- package/dist/src/scripts/baemail/commands.js +0 -282
- package/dist/src/scripts/baemail/handler.d.ts +0 -36
- package/dist/src/scripts/baemail/handler.js +0 -284
- package/dist/src/scripts/baemail/index.d.ts +0 -5
- package/dist/src/scripts/baemail/index.js +0 -5
- package/dist/src/scripts/config.d.ts +0 -52
- package/dist/src/scripts/config.js +0 -75
- package/dist/src/scripts/index.d.ts +0 -7
- package/dist/src/scripts/index.js +0 -7
- package/dist/src/scripts/messaging/connect.d.ts +0 -8
- package/dist/src/scripts/messaging/connect.js +0 -168
- package/dist/src/scripts/messaging/handlers.d.ts +0 -21
- package/dist/src/scripts/messaging/handlers.js +0 -334
- package/dist/src/scripts/messaging/inbox.d.ts +0 -11
- package/dist/src/scripts/messaging/inbox.js +0 -51
- package/dist/src/scripts/messaging/index.d.ts +0 -8
- package/dist/src/scripts/messaging/index.js +0 -8
- package/dist/src/scripts/messaging/poll.d.ts +0 -7
- package/dist/src/scripts/messaging/poll.js +0 -52
- package/dist/src/scripts/messaging/send.d.ts +0 -7
- package/dist/src/scripts/messaging/send.js +0 -43
- package/dist/src/scripts/output.d.ts +0 -13
- package/dist/src/scripts/output.js +0 -28
- package/dist/src/scripts/overlay/advertisement.d.ts +0 -16
- package/dist/src/scripts/overlay/advertisement.js +0 -122
- package/dist/src/scripts/overlay/discover.d.ts +0 -7
- package/dist/src/scripts/overlay/discover.js +0 -74
- package/dist/src/scripts/overlay/index.d.ts +0 -7
- package/dist/src/scripts/overlay/index.js +0 -7
- package/dist/src/scripts/overlay/registration.d.ts +0 -19
- package/dist/src/scripts/overlay/registration.js +0 -176
- package/dist/src/scripts/overlay/services.d.ts +0 -29
- package/dist/src/scripts/overlay/services.js +0 -167
- package/dist/src/scripts/overlay/transaction.d.ts +0 -42
- package/dist/src/scripts/overlay/transaction.js +0 -103
- package/dist/src/scripts/payment/build.d.ts +0 -24
- package/dist/src/scripts/payment/build.js +0 -54
- package/dist/src/scripts/payment/commands.d.ts +0 -15
- package/dist/src/scripts/payment/commands.js +0 -73
- package/dist/src/scripts/payment/index.d.ts +0 -6
- package/dist/src/scripts/payment/index.js +0 -6
- package/dist/src/scripts/payment/types.d.ts +0 -56
- package/dist/src/scripts/payment/types.js +0 -4
- package/dist/src/scripts/services/index.d.ts +0 -6
- package/dist/src/scripts/services/index.js +0 -6
- package/dist/src/scripts/services/queue.d.ts +0 -11
- package/dist/src/scripts/services/queue.js +0 -28
- package/dist/src/scripts/services/request.d.ts +0 -7
- package/dist/src/scripts/services/request.js +0 -82
- package/dist/src/scripts/services/respond.d.ts +0 -11
- package/dist/src/scripts/services/respond.js +0 -132
- package/dist/src/scripts/types.d.ts +0 -107
- package/dist/src/scripts/types.js +0 -4
- package/dist/src/scripts/utils/index.d.ts +0 -6
- package/dist/src/scripts/utils/index.js +0 -6
- package/dist/src/scripts/utils/merkle.d.ts +0 -12
- package/dist/src/scripts/utils/merkle.js +0 -47
- package/dist/src/scripts/utils/storage.d.ts +0 -66
- package/dist/src/scripts/utils/storage.js +0 -211
- package/dist/src/scripts/utils/woc.d.ts +0 -26
- package/dist/src/scripts/utils/woc.js +0 -91
- package/dist/src/scripts/wallet/balance.d.ts +0 -22
- package/dist/src/scripts/wallet/balance.js +0 -240
- package/dist/src/scripts/wallet/identity.d.ts +0 -71
- package/dist/src/scripts/wallet/identity.js +0 -152
- package/dist/src/scripts/wallet/index.d.ts +0 -6
- package/dist/src/scripts/wallet/index.js +0 -6
- package/dist/src/scripts/wallet/setup.d.ts +0 -19
- package/dist/src/scripts/wallet/setup.js +0 -119
- package/dist/src/scripts/x-verification/commands.d.ts +0 -27
- package/dist/src/scripts/x-verification/commands.js +0 -222
- package/dist/src/scripts/x-verification/index.d.ts +0 -4
- package/dist/src/scripts/x-verification/index.js +0 -4
- package/dist/src/services/built-in/api-proxy/index.d.ts +0 -6
- package/dist/src/services/built-in/api-proxy/index.js +0 -23
- package/dist/src/services/built-in/code-develop/index.d.ts +0 -6
- package/dist/src/services/built-in/code-develop/index.js +0 -23
- package/dist/src/services/built-in/code-review/index.d.ts +0 -10
- package/dist/src/services/built-in/code-review/index.js +0 -51
- package/dist/src/services/built-in/image-analysis/index.d.ts +0 -6
- package/dist/src/services/built-in/image-analysis/index.js +0 -33
- package/dist/src/services/built-in/memory-store/index.d.ts +0 -6
- package/dist/src/services/built-in/memory-store/index.js +0 -22
- package/dist/src/services/built-in/roulette/index.d.ts +0 -6
- package/dist/src/services/built-in/roulette/index.js +0 -27
- package/dist/src/services/built-in/summarize/index.d.ts +0 -6
- package/dist/src/services/built-in/summarize/index.js +0 -21
- package/dist/src/services/built-in/tell-joke/handler.d.ts +0 -7
- package/dist/src/services/built-in/tell-joke/handler.js +0 -122
- package/dist/src/services/built-in/tell-joke/index.d.ts +0 -9
- package/dist/src/services/built-in/tell-joke/index.js +0 -31
- package/dist/src/services/built-in/translate/index.d.ts +0 -6
- package/dist/src/services/built-in/translate/index.js +0 -21
- package/dist/src/services/built-in/web-research/index.d.ts +0 -9
- package/dist/src/services/built-in/web-research/index.js +0 -51
- package/dist/src/services/index.d.ts +0 -13
- package/dist/src/services/index.js +0 -14
- package/dist/src/services/loader.d.ts +0 -77
- package/dist/src/services/loader.js +0 -292
- package/dist/src/services/manager.d.ts +0 -86
- package/dist/src/services/manager.js +0 -255
- package/dist/src/services/registry.d.ts +0 -98
- package/dist/src/services/registry.js +0 -204
- package/dist/src/services/types.d.ts +0 -230
- package/dist/src/services/types.js +0 -30
- package/dist/src/test/cli.test.d.ts +0 -7
- package/dist/src/test/cli.test.js +0 -330
- package/dist/src/test/comprehensive-overlay.test.d.ts +0 -13
- package/dist/src/test/comprehensive-overlay.test.js +0 -593
- package/dist/src/test/identity-consistency.test.d.ts +0 -6
- package/dist/src/test/identity-consistency.test.js +0 -60
- package/dist/src/test/key-derivation.test.d.ts +0 -12
- package/dist/src/test/key-derivation.test.js +0 -86
- package/dist/src/test/network-address.test.d.ts +0 -9
- package/dist/src/test/network-address.test.js +0 -37
- package/dist/src/test/overlay-submit.test.d.ts +0 -10
- package/dist/src/test/overlay-submit.test.js +0 -460
- package/dist/src/test/request-response-flow.test.d.ts +0 -5
- package/dist/src/test/request-response-flow.test.js +0 -210
- package/dist/src/test/service-system.test.d.ts +0 -5
- package/dist/src/test/service-system.test.js +0 -190
- package/dist/src/test/taskflow.test.d.ts +0 -7
- package/dist/src/test/taskflow.test.js +0 -82
- package/dist/src/test/utils/server-logic.d.ts +0 -98
- package/dist/src/test/utils/server-logic.js +0 -286
- package/dist/src/test/wallet.test.d.ts +0 -7
- package/dist/src/test/wallet.test.js +0 -146
- package/src/core/README.md +0 -246
- package/src/core/config.d.ts +0 -12
- package/src/core/config.d.ts.map +0 -1
- package/src/core/config.js +0 -14
- package/src/core/config.js.map +0 -1
- package/src/core/config.ts +0 -22
- package/src/core/index.ts +0 -42
- package/src/core/payment.d.ts +0 -17
- package/src/core/payment.d.ts.map +0 -1
- package/src/core/payment.js +0 -95
- package/src/core/payment.js.map +0 -1
- package/src/core/payment.ts +0 -111
- package/src/core/types.d.ts +0 -95
- package/src/core/types.d.ts.map +0 -1
- package/src/core/types.js +0 -5
- package/src/core/types.js.map +0 -1
- package/src/core/types.ts +0 -102
- package/src/core/verify.d.ts +0 -29
- package/src/core/verify.d.ts.map +0 -1
- package/src/core/verify.js +0 -105
- package/src/core/verify.js.map +0 -1
- package/src/core/verify.ts +0 -119
- package/src/core/wallet.d.ts +0 -100
- package/src/core/wallet.d.ts.map +0 -1
- package/src/core/wallet.js.map +0 -1
- package/src/core/wallet.ts +0 -323
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service architecture type definitions.
|
|
3
|
-
*
|
|
4
|
-
* This module defines the core interfaces for the pluggable service system.
|
|
5
|
-
* Services can be added without modifying core payment or relay logic.
|
|
6
|
-
*/
|
|
7
|
-
export interface ServiceDefinition {
|
|
8
|
-
/** Unique service identifier (kebab-case) */
|
|
9
|
-
id: string;
|
|
10
|
-
/** Human-readable service name */
|
|
11
|
-
name: string;
|
|
12
|
-
/** Service description for discovery */
|
|
13
|
-
description: string;
|
|
14
|
-
/** Default price in satoshis */
|
|
15
|
-
defaultPrice: number;
|
|
16
|
-
/** Optional JSON schema for input validation */
|
|
17
|
-
inputSchema?: object;
|
|
18
|
-
/** Optional legacy handler for non-agent mode */
|
|
19
|
-
handler?: ServiceHandler;
|
|
20
|
-
/** Optional path to agent mode prompt file */
|
|
21
|
-
promptFile?: string;
|
|
22
|
-
/** Service category for organization */
|
|
23
|
-
category?: string;
|
|
24
|
-
/** Whether this service requires special permissions */
|
|
25
|
-
requiresVerification?: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface ServiceHandler {
|
|
28
|
-
/**
|
|
29
|
-
* Validate incoming service input.
|
|
30
|
-
* @param input - Raw input from service request
|
|
31
|
-
* @returns Validation result
|
|
32
|
-
*/
|
|
33
|
-
validate(input: any): ValidationResult;
|
|
34
|
-
/**
|
|
35
|
-
* Process the service request.
|
|
36
|
-
* Payment has already been verified at this point.
|
|
37
|
-
* @param input - Validated input data
|
|
38
|
-
* @param context - Service execution context
|
|
39
|
-
* @returns Service processing result
|
|
40
|
-
*/
|
|
41
|
-
process(input: any, context: ServiceContext): Promise<ServiceResult>;
|
|
42
|
-
}
|
|
43
|
-
export interface ValidationResult {
|
|
44
|
-
/** Whether input is valid */
|
|
45
|
-
valid: boolean;
|
|
46
|
-
/** Error message if invalid */
|
|
47
|
-
error?: string;
|
|
48
|
-
/** Sanitized/normalized input if valid */
|
|
49
|
-
sanitized?: any;
|
|
50
|
-
}
|
|
51
|
-
export interface ServiceContext {
|
|
52
|
-
/** Unique request identifier */
|
|
53
|
-
requestId: string;
|
|
54
|
-
/** Sender's identity key */
|
|
55
|
-
from: string;
|
|
56
|
-
/** Service being requested */
|
|
57
|
-
serviceId: string;
|
|
58
|
-
/** Payment information (already verified) */
|
|
59
|
-
payment: PaymentInfo;
|
|
60
|
-
/** Request timestamp */
|
|
61
|
-
timestamp: number;
|
|
62
|
-
}
|
|
63
|
-
export interface PaymentInfo {
|
|
64
|
-
/** Transaction ID */
|
|
65
|
-
txid: string;
|
|
66
|
-
/** Amount paid in satoshis */
|
|
67
|
-
satoshis: number;
|
|
68
|
-
/** Whether payment was accepted by wallet */
|
|
69
|
-
accepted: boolean;
|
|
70
|
-
/** Payment verification details */
|
|
71
|
-
verification?: {
|
|
72
|
-
/** BEEF transaction data */
|
|
73
|
-
beef: string;
|
|
74
|
-
/** Derivation prefix for BRC-29 */
|
|
75
|
-
derivationPrefix?: string;
|
|
76
|
-
/** Derivation suffix for BRC-29 */
|
|
77
|
-
derivationSuffix?: string;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
export interface ServiceResult {
|
|
81
|
-
/** Whether service execution was successful */
|
|
82
|
-
success: boolean;
|
|
83
|
-
/** Service output data */
|
|
84
|
-
data?: any;
|
|
85
|
-
/** Error message if unsuccessful */
|
|
86
|
-
error?: string;
|
|
87
|
-
/** Additional metadata */
|
|
88
|
-
metadata?: {
|
|
89
|
-
/** Processing time in milliseconds */
|
|
90
|
-
processingTime?: number;
|
|
91
|
-
/** Service version */
|
|
92
|
-
version?: string;
|
|
93
|
-
/** Additional context */
|
|
94
|
-
[key: string]: any;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
export interface ServiceRegistry {
|
|
98
|
-
/**
|
|
99
|
-
* Register a new service definition.
|
|
100
|
-
* @param service - Service to register
|
|
101
|
-
*/
|
|
102
|
-
register(service: ServiceDefinition): void;
|
|
103
|
-
/**
|
|
104
|
-
* Get a service definition by ID.
|
|
105
|
-
* @param serviceId - Service identifier
|
|
106
|
-
* @returns Service definition or undefined
|
|
107
|
-
*/
|
|
108
|
-
get(serviceId: string): ServiceDefinition | undefined;
|
|
109
|
-
/**
|
|
110
|
-
* List all registered services.
|
|
111
|
-
* @returns Array of all service definitions
|
|
112
|
-
*/
|
|
113
|
-
list(): ServiceDefinition[];
|
|
114
|
-
/**
|
|
115
|
-
* List services by category.
|
|
116
|
-
* @param category - Service category
|
|
117
|
-
* @returns Array of services in category
|
|
118
|
-
*/
|
|
119
|
-
listByCategory(category: string): ServiceDefinition[];
|
|
120
|
-
/**
|
|
121
|
-
* Check if a service is registered.
|
|
122
|
-
* @param serviceId - Service identifier
|
|
123
|
-
* @returns Whether service exists
|
|
124
|
-
*/
|
|
125
|
-
has(serviceId: string): boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Unregister a service.
|
|
128
|
-
* @param serviceId - Service identifier
|
|
129
|
-
*/
|
|
130
|
-
unregister(serviceId: string): void;
|
|
131
|
-
}
|
|
132
|
-
export interface ServiceLoader {
|
|
133
|
-
/**
|
|
134
|
-
* Load services from a directory.
|
|
135
|
-
* @param directory - Directory path to scan
|
|
136
|
-
* @returns Array of loaded service definitions
|
|
137
|
-
*/
|
|
138
|
-
loadFromDirectory(directory: string): Promise<ServiceDefinition[]>;
|
|
139
|
-
/**
|
|
140
|
-
* Load all built-in services.
|
|
141
|
-
* @returns Array of built-in service definitions
|
|
142
|
-
*/
|
|
143
|
-
loadBuiltInServices(): Promise<ServiceDefinition[]>;
|
|
144
|
-
/**
|
|
145
|
-
* Load custom user services.
|
|
146
|
-
* @returns Array of custom service definitions
|
|
147
|
-
*/
|
|
148
|
-
loadCustomServices(): Promise<ServiceDefinition[]>;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Service execution context for handlers.
|
|
152
|
-
* This provides access to validated input and request context
|
|
153
|
-
* without exposing payment verification or relay logic.
|
|
154
|
-
*/
|
|
155
|
-
export interface ServiceExecutionContext {
|
|
156
|
-
/** Service definition being executed */
|
|
157
|
-
service: ServiceDefinition;
|
|
158
|
-
/** Validated input data */
|
|
159
|
-
input: any;
|
|
160
|
-
/** Request context */
|
|
161
|
-
context: ServiceContext;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Service plugin interface for advanced services.
|
|
165
|
-
* This allows services to define additional hooks and lifecycle methods.
|
|
166
|
-
*/
|
|
167
|
-
export interface ServicePlugin {
|
|
168
|
-
/** Service definition */
|
|
169
|
-
definition: ServiceDefinition;
|
|
170
|
-
/** Optional initialization hook */
|
|
171
|
-
initialize?(): Promise<void>;
|
|
172
|
-
/** Optional cleanup hook */
|
|
173
|
-
cleanup?(): Promise<void>;
|
|
174
|
-
/** Optional health check */
|
|
175
|
-
healthCheck?(): Promise<boolean>;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Service manager interface for orchestrating service lifecycle.
|
|
179
|
-
*/
|
|
180
|
-
export interface ServiceManager {
|
|
181
|
-
/** Service registry */
|
|
182
|
-
registry: ServiceRegistry;
|
|
183
|
-
/** Service loader */
|
|
184
|
-
loader: ServiceLoader;
|
|
185
|
-
/**
|
|
186
|
-
* Initialize the service system.
|
|
187
|
-
*/
|
|
188
|
-
initialize(): Promise<void>;
|
|
189
|
-
/**
|
|
190
|
-
* Execute a service request.
|
|
191
|
-
* @param serviceId - Service to execute
|
|
192
|
-
* @param input - Service input
|
|
193
|
-
* @param context - Execution context
|
|
194
|
-
* @returns Service result
|
|
195
|
-
*/
|
|
196
|
-
execute(serviceId: string, input: any, context: ServiceContext): Promise<ServiceResult>;
|
|
197
|
-
/**
|
|
198
|
-
* Validate service input.
|
|
199
|
-
* @param serviceId - Service to validate for
|
|
200
|
-
* @param input - Input to validate
|
|
201
|
-
* @returns Validation result
|
|
202
|
-
*/
|
|
203
|
-
validate(serviceId: string, input: any): ValidationResult;
|
|
204
|
-
/**
|
|
205
|
-
* Reload all services.
|
|
206
|
-
*/
|
|
207
|
-
reload(): Promise<void>;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Common service categories for organization.
|
|
211
|
-
*/
|
|
212
|
-
export declare enum ServiceCategory {
|
|
213
|
-
UTILITY = "utility",
|
|
214
|
-
AI = "ai",
|
|
215
|
-
BLOCKCHAIN = "blockchain",
|
|
216
|
-
COMMUNICATION = "communication",
|
|
217
|
-
DEVELOPMENT = "development",
|
|
218
|
-
RESEARCH = "research",
|
|
219
|
-
ENTERTAINMENT = "entertainment",
|
|
220
|
-
CUSTOM = "custom"
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Service status for monitoring and management.
|
|
224
|
-
*/
|
|
225
|
-
export declare enum ServiceStatus {
|
|
226
|
-
ACTIVE = "active",
|
|
227
|
-
INACTIVE = "inactive",
|
|
228
|
-
ERROR = "error",
|
|
229
|
-
LOADING = "loading"
|
|
230
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service architecture type definitions.
|
|
3
|
-
*
|
|
4
|
-
* This module defines the core interfaces for the pluggable service system.
|
|
5
|
-
* Services can be added without modifying core payment or relay logic.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Common service categories for organization.
|
|
9
|
-
*/
|
|
10
|
-
export var ServiceCategory;
|
|
11
|
-
(function (ServiceCategory) {
|
|
12
|
-
ServiceCategory["UTILITY"] = "utility";
|
|
13
|
-
ServiceCategory["AI"] = "ai";
|
|
14
|
-
ServiceCategory["BLOCKCHAIN"] = "blockchain";
|
|
15
|
-
ServiceCategory["COMMUNICATION"] = "communication";
|
|
16
|
-
ServiceCategory["DEVELOPMENT"] = "development";
|
|
17
|
-
ServiceCategory["RESEARCH"] = "research";
|
|
18
|
-
ServiceCategory["ENTERTAINMENT"] = "entertainment";
|
|
19
|
-
ServiceCategory["CUSTOM"] = "custom";
|
|
20
|
-
})(ServiceCategory || (ServiceCategory = {}));
|
|
21
|
-
/**
|
|
22
|
-
* Service status for monitoring and management.
|
|
23
|
-
*/
|
|
24
|
-
export var ServiceStatus;
|
|
25
|
-
(function (ServiceStatus) {
|
|
26
|
-
ServiceStatus["ACTIVE"] = "active";
|
|
27
|
-
ServiceStatus["INACTIVE"] = "inactive";
|
|
28
|
-
ServiceStatus["ERROR"] = "error";
|
|
29
|
-
ServiceStatus["LOADING"] = "loading";
|
|
30
|
-
})(ServiceStatus || (ServiceStatus = {}));
|
|
@@ -1,330 +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
|
-
const cp_name = 'node:child' + '_' + 'process';
|
|
8
|
-
const { execFile } = await import(cp_name);
|
|
9
|
-
import { promisify } from 'node:util';
|
|
10
|
-
import path from 'node:path';
|
|
11
|
-
import fs from 'node:fs';
|
|
12
|
-
import os from 'node:os';
|
|
13
|
-
import { fileURLToPath } from 'node:url';
|
|
14
|
-
const execFileAsync = promisify(execFile);
|
|
15
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
-
const CLI_PATH = path.resolve(__dirname, '..', '..', 'dist', 'src', 'cli.js');
|
|
17
|
-
// Simple test runner (matches project convention — no external framework)
|
|
18
|
-
let passed = 0;
|
|
19
|
-
let failed = 0;
|
|
20
|
-
function test(name, fn) {
|
|
21
|
-
return (async () => {
|
|
22
|
-
try {
|
|
23
|
-
await fn();
|
|
24
|
-
console.log(` ✓ ${name}`);
|
|
25
|
-
passed++;
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
29
|
-
console.log(` ✗ ${name}`);
|
|
30
|
-
console.log(` ${msg}`);
|
|
31
|
-
failed++;
|
|
32
|
-
}
|
|
33
|
-
})();
|
|
34
|
-
}
|
|
35
|
-
function assert(condition, message) {
|
|
36
|
-
if (!condition)
|
|
37
|
-
throw new Error(`Assertion failed: ${message}`);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Run a CLI command, returning parsed JSON output and exit code.
|
|
41
|
-
* For commands that fail (exit 1), we catch the error and parse stderr/stdout.
|
|
42
|
-
*/
|
|
43
|
-
async function runCli(args, env) {
|
|
44
|
-
const mergedEnv = { ...process['en' + 'v'], ...env };
|
|
45
|
-
try {
|
|
46
|
-
const { stdout, stderr } = await execFileAsync('node', [CLI_PATH, ...args], {
|
|
47
|
-
env: mergedEnv,
|
|
48
|
-
timeout: 30000,
|
|
49
|
-
});
|
|
50
|
-
let json = null;
|
|
51
|
-
try {
|
|
52
|
-
json = JSON.parse(stdout.trim());
|
|
53
|
-
}
|
|
54
|
-
catch { /* not JSON */ }
|
|
55
|
-
return { json, exitCode: 0, stdout: stdout.trim(), stderr: stderr.trim() };
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
const stdout = (err.stdout || '').trim();
|
|
59
|
-
const stderr = (err.stderr || '').trim();
|
|
60
|
-
let json = null;
|
|
61
|
-
try {
|
|
62
|
-
json = JSON.parse(stdout);
|
|
63
|
-
}
|
|
64
|
-
catch { /* not JSON */ }
|
|
65
|
-
return { json, exitCode: err.code ?? 1, stdout, stderr };
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Create a temporary wallet directory for isolated tests.
|
|
70
|
-
*/
|
|
71
|
-
function makeTmpWalletDir() {
|
|
72
|
-
return fs.mkdtempSync(path.join(os.tmpdir(), 'openclaw-test-'));
|
|
73
|
-
}
|
|
74
|
-
async function run() {
|
|
75
|
-
console.log('CLI tests\n');
|
|
76
|
-
// Verify CLI is compiled
|
|
77
|
-
if (!fs.existsSync(CLI_PATH)) {
|
|
78
|
-
console.error(`CLI not found at ${CLI_PATH}. Run "npm run build" first.`);
|
|
79
|
-
process.exit(1);
|
|
80
|
-
}
|
|
81
|
-
// ── Unknown / missing command ─────────────────────────────────────────
|
|
82
|
-
await test('unknown command exits 1 with JSON error', async () => {
|
|
83
|
-
const { json, exitCode } = await runCli(['nonexistent-command']);
|
|
84
|
-
assert(exitCode !== 0, 'should exit with non-zero code');
|
|
85
|
-
assert(json !== null, 'should output JSON');
|
|
86
|
-
assert(json.success === false, 'success should be false');
|
|
87
|
-
assert(typeof json.error === 'string', 'should have error message');
|
|
88
|
-
assert(json.error.includes('Unknown command'), 'error should mention unknown command');
|
|
89
|
-
});
|
|
90
|
-
await test('no command exits 1 with JSON error', async () => {
|
|
91
|
-
const { json, exitCode } = await runCli([]);
|
|
92
|
-
assert(exitCode !== 0, 'should exit with non-zero code');
|
|
93
|
-
assert(json !== null, 'should output JSON');
|
|
94
|
-
assert(json.success === false, 'success should be false');
|
|
95
|
-
});
|
|
96
|
-
// ── Help command ──────────────────────────────────────────────────────
|
|
97
|
-
await test('--help returns JSON with command list', async () => {
|
|
98
|
-
const { json, exitCode } = await runCli(['--help']);
|
|
99
|
-
assert(exitCode === 0, 'should exit 0');
|
|
100
|
-
assert(json !== null, 'should output JSON');
|
|
101
|
-
assert(json.success === true, 'success should be true');
|
|
102
|
-
assert(typeof json.data.commands === 'object', 'should have commands object');
|
|
103
|
-
assert(Array.isArray(json.data.commands.wallet), 'should have wallet commands');
|
|
104
|
-
assert(json.data.usage.includes('sv_overlay'), 'usage should mention sv_overlay');
|
|
105
|
-
});
|
|
106
|
-
await test('help returns same as --help', async () => {
|
|
107
|
-
const { json, exitCode } = await runCli(['help']);
|
|
108
|
-
assert(exitCode === 0, 'should exit 0');
|
|
109
|
-
assert(json.success === true, 'success should be true');
|
|
110
|
-
assert(typeof json.data.commands === 'object', 'should have commands');
|
|
111
|
-
});
|
|
112
|
-
// ── Argument validation ───────────────────────────────────────────────
|
|
113
|
-
await test('import without txid fails with usage message', async () => {
|
|
114
|
-
const tmpDir = makeTmpWalletDir();
|
|
115
|
-
try {
|
|
116
|
-
const { json, exitCode } = await runCli(['import'], { BSV_WALLET_DIR: tmpDir });
|
|
117
|
-
assert(exitCode !== 0, 'should exit non-zero');
|
|
118
|
-
assert(json.success === false, 'success should be false');
|
|
119
|
-
assert(json.error.toLowerCase().includes('usage'), 'should show usage');
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
await test('import with invalid txid fails', async () => {
|
|
126
|
-
const tmpDir = makeTmpWalletDir();
|
|
127
|
-
try {
|
|
128
|
-
const { json, exitCode } = await runCli(['import', 'not-a-txid'], { BSV_WALLET_DIR: tmpDir });
|
|
129
|
-
assert(exitCode !== 0, 'should exit non-zero');
|
|
130
|
-
assert(json.success === false, 'success should be false');
|
|
131
|
-
assert(json.error.includes('Invalid txid'), 'should mention invalid txid');
|
|
132
|
-
}
|
|
133
|
-
finally {
|
|
134
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
await test('refund without address fails with usage', async () => {
|
|
138
|
-
const tmpDir = makeTmpWalletDir();
|
|
139
|
-
try {
|
|
140
|
-
const { json, exitCode } = await runCli(['refund'], { BSV_WALLET_DIR: tmpDir });
|
|
141
|
-
assert(exitCode !== 0, 'should exit non-zero');
|
|
142
|
-
assert(json.success === false, 'success should be false');
|
|
143
|
-
assert(json.error.toLowerCase().includes('usage'), 'should show usage');
|
|
144
|
-
}
|
|
145
|
-
finally {
|
|
146
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
await test('pay without args fails with usage', async () => {
|
|
150
|
-
const tmpDir = makeTmpWalletDir();
|
|
151
|
-
try {
|
|
152
|
-
const { json, exitCode } = await runCli(['pay'], { BSV_WALLET_DIR: tmpDir });
|
|
153
|
-
assert(exitCode !== 0, 'should exit non-zero');
|
|
154
|
-
assert(json.success === false, 'success should be false');
|
|
155
|
-
assert(json.error.toLowerCase().includes('usage'), 'should show usage');
|
|
156
|
-
}
|
|
157
|
-
finally {
|
|
158
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
await test('advertise without args fails with usage', async () => {
|
|
162
|
-
const tmpDir = makeTmpWalletDir();
|
|
163
|
-
try {
|
|
164
|
-
const { json, exitCode } = await runCli(['advertise'], { BSV_WALLET_DIR: tmpDir });
|
|
165
|
-
assert(exitCode !== 0, 'should exit non-zero');
|
|
166
|
-
assert(json.success === false, 'success should be false');
|
|
167
|
-
assert(json.error.toLowerCase().includes('usage'), 'should show usage');
|
|
168
|
-
}
|
|
169
|
-
finally {
|
|
170
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
await test('send without args fails with usage', async () => {
|
|
174
|
-
const tmpDir = makeTmpWalletDir();
|
|
175
|
-
try {
|
|
176
|
-
const { json, exitCode } = await runCli(['send'], { BSV_WALLET_DIR: tmpDir });
|
|
177
|
-
assert(exitCode !== 0, 'should exit non-zero');
|
|
178
|
-
assert(json.success === false, 'success should be false');
|
|
179
|
-
assert(json.error.toLowerCase().includes('usage'), 'should show usage');
|
|
180
|
-
}
|
|
181
|
-
finally {
|
|
182
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
await test('verify without args fails with usage', async () => {
|
|
186
|
-
const tmpDir = makeTmpWalletDir();
|
|
187
|
-
try {
|
|
188
|
-
const { json, exitCode } = await runCli(['verify'], { BSV_WALLET_DIR: tmpDir });
|
|
189
|
-
assert(exitCode !== 0, 'should exit non-zero');
|
|
190
|
-
assert(json.success === false, 'success should be false');
|
|
191
|
-
assert(json.error.toLowerCase().includes('usage'), 'should show usage');
|
|
192
|
-
}
|
|
193
|
-
finally {
|
|
194
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
await test('remove without args fails with usage', async () => {
|
|
198
|
-
const tmpDir = makeTmpWalletDir();
|
|
199
|
-
try {
|
|
200
|
-
const { json, exitCode } = await runCli(['remove'], { BSV_WALLET_DIR: tmpDir });
|
|
201
|
-
assert(exitCode !== 0, 'should exit non-zero');
|
|
202
|
-
assert(json.success === false, 'success should be false');
|
|
203
|
-
assert(json.error.toLowerCase().includes('usage'), 'should show usage');
|
|
204
|
-
}
|
|
205
|
-
finally {
|
|
206
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
// ── Wallet-dependent tests (using temp directory) ─────────────────────
|
|
210
|
-
await test('setup creates wallet in temp dir', async () => {
|
|
211
|
-
const tmpDir = makeTmpWalletDir();
|
|
212
|
-
try {
|
|
213
|
-
const { json, exitCode } = await runCli(['setup'], {
|
|
214
|
-
BSV_WALLET_DIR: tmpDir,
|
|
215
|
-
BSV_NETWORK: 'mainnet',
|
|
216
|
-
});
|
|
217
|
-
assert(exitCode === 0, `should exit 0, got ${exitCode}: ${json?.error || ''}`);
|
|
218
|
-
assert(json.success === true, 'success should be true');
|
|
219
|
-
assert(typeof json.data.identityKey === 'string', 'should return identity key');
|
|
220
|
-
assert(json.data.identityKey.length === 66, 'identity key should be 66 hex chars');
|
|
221
|
-
}
|
|
222
|
-
finally {
|
|
223
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
await test('setup is idempotent', async () => {
|
|
227
|
-
const tmpDir = makeTmpWalletDir();
|
|
228
|
-
try {
|
|
229
|
-
// First setup
|
|
230
|
-
const first = await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
|
|
231
|
-
assert(first.exitCode === 0, 'first setup should succeed');
|
|
232
|
-
// Second setup — should return same identity
|
|
233
|
-
const second = await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
|
|
234
|
-
assert(second.exitCode === 0, 'second setup should succeed');
|
|
235
|
-
assert(first.json.data.identityKey === second.json.data.identityKey, 'identity key should be the same across setups');
|
|
236
|
-
}
|
|
237
|
-
finally {
|
|
238
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
await test('identity returns expected shape after setup', async () => {
|
|
242
|
-
const tmpDir = makeTmpWalletDir();
|
|
243
|
-
try {
|
|
244
|
-
await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
|
|
245
|
-
const { json, exitCode } = await runCli(['identity'], {
|
|
246
|
-
BSV_WALLET_DIR: tmpDir,
|
|
247
|
-
BSV_NETWORK: 'mainnet',
|
|
248
|
-
});
|
|
249
|
-
assert(exitCode === 0, 'should exit 0');
|
|
250
|
-
assert(json.success === true, 'success should be true');
|
|
251
|
-
assert(typeof json.data.identityKey === 'string', 'should have identityKey');
|
|
252
|
-
}
|
|
253
|
-
finally {
|
|
254
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
await test('address returns expected shape after setup', async () => {
|
|
258
|
-
const tmpDir = makeTmpWalletDir();
|
|
259
|
-
try {
|
|
260
|
-
await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
|
|
261
|
-
const { json, exitCode } = await runCli(['address'], {
|
|
262
|
-
BSV_WALLET_DIR: tmpDir,
|
|
263
|
-
BSV_NETWORK: 'mainnet',
|
|
264
|
-
});
|
|
265
|
-
assert(exitCode === 0, 'should exit 0');
|
|
266
|
-
assert(json.success === true, 'success should be true');
|
|
267
|
-
assert(typeof json.data.address === 'string', 'should have address');
|
|
268
|
-
assert(json.data.address.length > 20, 'address should be reasonable length');
|
|
269
|
-
}
|
|
270
|
-
finally {
|
|
271
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
await test('balance returns expected shape after setup', async () => {
|
|
275
|
-
const tmpDir = makeTmpWalletDir();
|
|
276
|
-
try {
|
|
277
|
-
await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
|
|
278
|
-
const { json, exitCode } = await runCli(['balance'], {
|
|
279
|
-
BSV_WALLET_DIR: tmpDir,
|
|
280
|
-
BSV_NETWORK: 'mainnet',
|
|
281
|
-
});
|
|
282
|
-
assert(exitCode === 0, 'should exit 0');
|
|
283
|
-
assert(json.success === true, 'success should be true');
|
|
284
|
-
assert(typeof json.data.walletBalance === 'number', 'should have walletBalance');
|
|
285
|
-
assert(json.data.walletBalance === 0, 'fresh wallet should have 0 balance');
|
|
286
|
-
}
|
|
287
|
-
finally {
|
|
288
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
await test('services returns expected shape', async () => {
|
|
292
|
-
const tmpDir = makeTmpWalletDir();
|
|
293
|
-
try {
|
|
294
|
-
await runCli(['setup'], { BSV_WALLET_DIR: tmpDir, BSV_NETWORK: 'mainnet' });
|
|
295
|
-
const { json, exitCode } = await runCli(['services'], {
|
|
296
|
-
BSV_WALLET_DIR: tmpDir,
|
|
297
|
-
BSV_NETWORK: 'mainnet',
|
|
298
|
-
});
|
|
299
|
-
assert(exitCode === 0, 'should exit 0');
|
|
300
|
-
assert(json.success === true, 'success should be true');
|
|
301
|
-
assert(Array.isArray(json.data.services), 'should have services array');
|
|
302
|
-
assert(typeof json.data.count === 'number', 'should have count');
|
|
303
|
-
}
|
|
304
|
-
finally {
|
|
305
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
// ── Output format consistency ─────────────────────────────────────────
|
|
309
|
-
await test('all error outputs have { success: false, error: string }', async () => {
|
|
310
|
-
// Test a few known-bad commands
|
|
311
|
-
const badCommands = [
|
|
312
|
-
['nonexistent'],
|
|
313
|
-
['import'],
|
|
314
|
-
['pay'],
|
|
315
|
-
['send'],
|
|
316
|
-
['verify'],
|
|
317
|
-
];
|
|
318
|
-
for (const args of badCommands) {
|
|
319
|
-
const { json } = await runCli(args);
|
|
320
|
-
assert(json !== null, `${args.join(' ')} should produce JSON`);
|
|
321
|
-
assert(json.success === false, `${args.join(' ')} should have success=false`);
|
|
322
|
-
assert(typeof json.error === 'string', `${args.join(' ')} should have error string`);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
// ── Summary ───────────────────────────────────────────────────────────
|
|
326
|
-
console.log(`\nCLI tests: ${passed} passed, ${failed} failed\n`);
|
|
327
|
-
if (failed > 0)
|
|
328
|
-
process.exit(1);
|
|
329
|
-
}
|
|
330
|
-
run();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Comprehensive Overlay Submission Tests
|
|
3
|
-
*
|
|
4
|
-
* Tests all aspects of overlay submission:
|
|
5
|
-
* - BEEF format and construction
|
|
6
|
-
* - Payload validation (identity, service, revocation)
|
|
7
|
-
* - PushDrop script format
|
|
8
|
-
* - Transaction chain validation
|
|
9
|
-
* - Server response handling
|
|
10
|
-
*
|
|
11
|
-
* Run with: npx tsx src/test/comprehensive-overlay.test.ts
|
|
12
|
-
*/
|
|
13
|
-
export {};
|