@agent-pulse/openclaw-skill 1.0.0

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 ADDED
@@ -0,0 +1,408 @@
1
+ /**
2
+ * OpenClaw Skill - AgentPulse Gate Integration
3
+ *
4
+ * Main implementation of the OpenClaw skill framework integration.
5
+ * Provides startup hook, gate activation, and status reporting.
6
+ *
7
+ * @module openclaw-skill
8
+ */
9
+ import { isAddress } from "viem";
10
+ import { AgentPulse, AgentPulseError, } from "@agent-pulse/sdk";
11
+ import { Ajv } from "ajv";
12
+ import gateSchema from "./gate-schema.json" with { type: "json" };
13
+ // ============================================================================
14
+ // Constants
15
+ // ============================================================================
16
+ /** Default chain ID (Base Sepolia) */
17
+ const DEFAULT_CHAIN_ID = 84532;
18
+ /** Duration unit multipliers (to seconds) */
19
+ const DURATION_MULTIPLIERS = {
20
+ s: 1,
21
+ m: 60,
22
+ h: 3600,
23
+ d: 86400,
24
+ w: 604800,
25
+ };
26
+ // ============================================================================
27
+ // Configuration Validation
28
+ // ============================================================================
29
+ /**
30
+ * Validate gate configuration against JSON Schema
31
+ */
32
+ export function validateGateConfig(config) {
33
+ const ajv = new Ajv({ strict: false });
34
+ const validate = ajv.compile(gateSchema);
35
+ return validate(config) === true;
36
+ }
37
+ /**
38
+ * Parse duration string to seconds
39
+ * @param threshold - Duration string (e.g., "24h", "30m")
40
+ * @returns Parsed threshold or null if invalid
41
+ */
42
+ export function parseThreshold(threshold) {
43
+ const match = threshold.match(/^(\d+)([smhdw])$/);
44
+ if (!match)
45
+ return null;
46
+ const value = parseInt(match[1], 10);
47
+ const unit = match[2];
48
+ const multiplier = DURATION_MULTIPLIERS[unit];
49
+ return {
50
+ value,
51
+ unit,
52
+ seconds: value * multiplier,
53
+ };
54
+ }
55
+ // ============================================================================
56
+ // OpenClawGate Implementation
57
+ // ============================================================================
58
+ /**
59
+ * OpenClaw Gate implementation wrapping AgentPulse SDK
60
+ */
61
+ class OpenClawGate {
62
+ gate;
63
+ config;
64
+ _status;
65
+ _stats;
66
+ constructor(gate, config) {
67
+ this.gate = gate;
68
+ this.config = config;
69
+ this._status = {
70
+ active: true,
71
+ mode: config.mode,
72
+ threshold: config.threshold,
73
+ sdkInitialized: true,
74
+ lastCheck: Date.now(),
75
+ };
76
+ this._stats = {
77
+ agentsChecked: 0,
78
+ agentsRejected: 0,
79
+ incomingChecks: 0,
80
+ outgoingChecks: 0,
81
+ sdkErrors: 0,
82
+ lastCheck: null,
83
+ };
84
+ }
85
+ /**
86
+ * Gate an incoming request
87
+ * @param requesterAddr - Address of the requesting agent
88
+ * @returns true if allowed, throws in strict mode if rejected
89
+ */
90
+ async gateIncoming(requesterAddr) {
91
+ return this.performCheck("incoming", requesterAddr);
92
+ }
93
+ /**
94
+ * Gate an outgoing request
95
+ * @param targetAddr - Address of the target agent
96
+ * @returns true if allowed, throws in strict mode if rejected
97
+ */
98
+ async gateOutgoing(targetAddr) {
99
+ return this.performCheck("outgoing", targetAddr);
100
+ }
101
+ /**
102
+ * Internal check implementation
103
+ */
104
+ async performCheck(direction, address) {
105
+ // Update stats
106
+ this._stats.agentsChecked++;
107
+ if (direction === "incoming") {
108
+ this._stats.incomingChecks++;
109
+ }
110
+ else {
111
+ this._stats.outgoingChecks++;
112
+ }
113
+ const timestamp = Date.now();
114
+ try {
115
+ // Use the SDK gate based on direction
116
+ const allowed = direction === "incoming"
117
+ ? await this.gate.gateIncoming(address)
118
+ : await this.gate.gateOutgoing(address);
119
+ this._stats.lastCheck = timestamp;
120
+ this._status.lastCheck = timestamp;
121
+ if (!allowed) {
122
+ this._stats.agentsRejected++;
123
+ // In strict mode, gateIncoming/gateOutgoing already threw
124
+ // This handles any additional rejection logic
125
+ if (this.config.mode === "strict") {
126
+ throw new AgentPulseError(`[OpenClawGate] ${direction} agent ${address} is NOT alive - request rejected`, "API_ERROR", 403);
127
+ }
128
+ }
129
+ return allowed;
130
+ }
131
+ catch (error) {
132
+ this._stats.sdkErrors++;
133
+ if (error instanceof AgentPulseError) {
134
+ throw error;
135
+ }
136
+ // Handle unexpected errors
137
+ const errorMsg = error instanceof Error ? error.message : String(error);
138
+ console.error(`[OpenClawGate] Error during ${direction} check:`, errorMsg);
139
+ // In strict mode, fail closed (reject)
140
+ if (this.config.mode === "strict") {
141
+ throw new AgentPulseError(`[OpenClawGate] Gate check failed: ${errorMsg}`, "API_ERROR", 500);
142
+ }
143
+ // In warn/log mode, fail open (allow)
144
+ return true;
145
+ }
146
+ }
147
+ /**
148
+ * Get current gate status
149
+ */
150
+ getStatus() {
151
+ return { ...this._status };
152
+ }
153
+ /**
154
+ * Get gate statistics
155
+ */
156
+ getStats() {
157
+ return { ...this._stats };
158
+ }
159
+ /**
160
+ * Get full status output for orchestrator queries
161
+ */
162
+ getStatusOutput() {
163
+ return {
164
+ enabled: this.config.enabled,
165
+ mode: this.config.mode,
166
+ threshold: this.config.threshold,
167
+ status: this._status.active ? "active" : "degraded",
168
+ lastCheck: this._status.lastCheck || null,
169
+ stats: this.getStats(),
170
+ config: {
171
+ chainId: this.config.chainId || DEFAULT_CHAIN_ID,
172
+ hasCustomRpc: !!this.config.rpcUrl,
173
+ hasCustomContracts: !!this.config.contracts,
174
+ },
175
+ };
176
+ }
177
+ }
178
+ // ============================================================================
179
+ // Skill Startup Hook
180
+ // ============================================================================
181
+ /**
182
+ * Skill startup hook - initializes AgentPulse SDK
183
+ *
184
+ * This MUST be called before any skill action/evaluator runs.
185
+ * Gate initialization failure is surfaced based on mode:
186
+ * - strict: Throws error, skill startup fails
187
+ * - warn: Logs warning, continues without gating
188
+ * - log: Silent, continues without gating
189
+ *
190
+ * @param config - Gate configuration from skill YAML
191
+ * @returns Skill startup result with gate instance
192
+ */
193
+ export async function startup(config) {
194
+ // Check if gating is configured
195
+ if (!config || typeof config !== "object") {
196
+ return {
197
+ success: true,
198
+ status: {
199
+ active: false,
200
+ mode: "log",
201
+ threshold: "",
202
+ sdkInitialized: false,
203
+ },
204
+ };
205
+ }
206
+ // Extract raw mode before validation for error handling
207
+ const raw = config;
208
+ const requestedMode = (raw["mode"] === "strict" || raw["mode"] === "warn" || raw["mode"] === "log"
209
+ ? raw["mode"]
210
+ : "log");
211
+ // If disabled, return early
212
+ if (!raw["enabled"]) {
213
+ console.log("[OpenClawSkill] Gate is disabled, skipping initialization");
214
+ return {
215
+ success: true,
216
+ status: {
217
+ active: false,
218
+ mode: "log",
219
+ threshold: "",
220
+ sdkInitialized: false,
221
+ },
222
+ };
223
+ }
224
+ // Validate configuration
225
+ if (!validateGateConfig(config)) {
226
+ const error = "[OpenClawSkill] Invalid gate configuration";
227
+ console.error(error);
228
+ // In strict mode, fail startup
229
+ if (requestedMode === "strict") {
230
+ return {
231
+ success: false,
232
+ error,
233
+ status: {
234
+ active: false,
235
+ mode: requestedMode,
236
+ threshold: raw["threshold"] || "",
237
+ sdkInitialized: false,
238
+ lastError: error,
239
+ },
240
+ };
241
+ }
242
+ // In warn/log mode, continue without gating
243
+ return {
244
+ success: true,
245
+ status: {
246
+ active: false,
247
+ mode: requestedMode,
248
+ threshold: raw["threshold"] || "",
249
+ sdkInitialized: false,
250
+ lastError: error,
251
+ },
252
+ };
253
+ }
254
+ // config is now validated as GateConfig
255
+ const gateConfig = config;
256
+ // Parse and validate threshold
257
+ const parsedThreshold = parseThreshold(gateConfig.threshold);
258
+ if (!parsedThreshold) {
259
+ const error = `[OpenClawSkill] Invalid threshold format: ${gateConfig.threshold}`;
260
+ console.error(error);
261
+ if (gateConfig.mode === "strict") {
262
+ return {
263
+ success: false,
264
+ error,
265
+ status: {
266
+ active: false,
267
+ mode: gateConfig.mode,
268
+ threshold: gateConfig.threshold,
269
+ sdkInitialized: false,
270
+ lastError: error,
271
+ },
272
+ };
273
+ }
274
+ }
275
+ // Initialize AgentPulse SDK
276
+ try {
277
+ console.log(`[OpenClawSkill] Initializing AgentPulse SDK (mode: ${gateConfig.mode})...`);
278
+ const pulse = new AgentPulse({
279
+ chainId: gateConfig.chainId || DEFAULT_CHAIN_ID,
280
+ rpcUrl: gateConfig.rpcUrl,
281
+ contracts: gateConfig.contracts,
282
+ });
283
+ // Test SDK connection with a health check
284
+ const health = await pulse.getHealth();
285
+ console.log(`[OpenClawSkill] AgentPulse protocol health: ${health.health}`);
286
+ // Create gate with mode-specific options
287
+ const gateOptions = {
288
+ mode: gateConfig.mode,
289
+ gateIncoming: true,
290
+ gateOutgoing: true,
291
+ threshold: gateConfig.threshold,
292
+ logger: {
293
+ warn: (msg) => console.warn(msg),
294
+ error: (msg) => console.error(msg),
295
+ info: (msg) => console.info(msg),
296
+ },
297
+ };
298
+ const sdkGate = pulse.createGate(gateOptions);
299
+ const openClawGate = new OpenClawGate(sdkGate, gateConfig);
300
+ console.log(`[OpenClawSkill] Gate initialized successfully (threshold: ${gateConfig.threshold})`);
301
+ return {
302
+ success: true,
303
+ gate: openClawGate,
304
+ status: openClawGate.getStatus(),
305
+ };
306
+ }
307
+ catch (error) {
308
+ const errorMsg = error instanceof Error ? error.message : String(error);
309
+ console.error(`[OpenClawSkill] Failed to initialize AgentPulse SDK: ${errorMsg}`);
310
+ // Surface error based on mode
311
+ if (gateConfig.mode === "strict") {
312
+ return {
313
+ success: false,
314
+ error: `[OpenClawSkill] Gate init failed (strict mode): ${errorMsg}`,
315
+ status: {
316
+ active: false,
317
+ mode: gateConfig.mode,
318
+ threshold: gateConfig.threshold,
319
+ sdkInitialized: false,
320
+ lastError: errorMsg,
321
+ },
322
+ };
323
+ }
324
+ // In warn mode, log and continue
325
+ if (gateConfig.mode === "warn") {
326
+ console.warn("[OpenClawSkill] Gate initialization failed, continuing without gating (warn mode)");
327
+ }
328
+ // In log mode, silent continue
329
+ return {
330
+ success: true,
331
+ status: {
332
+ active: false,
333
+ mode: gateConfig.mode,
334
+ threshold: gateConfig.threshold,
335
+ sdkInitialized: false,
336
+ lastError: errorMsg,
337
+ },
338
+ };
339
+ }
340
+ }
341
+ // ============================================================================
342
+ // Pre-Action Gate Activation
343
+ // ============================================================================
344
+ /**
345
+ * Middleware that activates gate BEFORE any skill action/evaluator
346
+ *
347
+ * Usage in skill definition:
348
+ * ```typescript
349
+ * actions: {
350
+ * myAction: withGate((ctx, input) => { ... })
351
+ * }
352
+ * ```
353
+ */
354
+ export function withGate(action, options) {
355
+ return async (ctx, input) => {
356
+ if (ctx.gate) {
357
+ const direction = options?.direction || "incoming";
358
+ const address = options?.address || input.from || input.to;
359
+ if (address && isAddress(address)) {
360
+ if (direction === "incoming") {
361
+ await ctx.gate.gateIncoming(address);
362
+ }
363
+ else {
364
+ await ctx.gate.gateOutgoing(address);
365
+ }
366
+ }
367
+ }
368
+ return action(ctx, input);
369
+ };
370
+ }
371
+ // ============================================================================
372
+ // Status Query Handler
373
+ // ============================================================================
374
+ /**
375
+ * Get gate status for orchestrator queries
376
+ * @param gate - Gate instance (if initialized)
377
+ * @returns Gate status output
378
+ */
379
+ export function getGateStatus(gate) {
380
+ if (!gate) {
381
+ return null;
382
+ }
383
+ // OpenClawGate has getStatusOutput method
384
+ if (gate instanceof OpenClawGate) {
385
+ return gate.getStatusOutput();
386
+ }
387
+ // Fallback for generic gate interface
388
+ const status = gate.getStatus();
389
+ const stats = gate.getStats();
390
+ return {
391
+ enabled: status.active,
392
+ mode: status.mode,
393
+ threshold: status.threshold,
394
+ status: status.active ? "active" : "degraded",
395
+ lastCheck: status.lastCheck || null,
396
+ stats,
397
+ config: {
398
+ chainId: DEFAULT_CHAIN_ID,
399
+ hasCustomRpc: false,
400
+ hasCustomContracts: false,
401
+ },
402
+ };
403
+ }
404
+ // ============================================================================
405
+ // Exports
406
+ // ============================================================================
407
+ export { OpenClawGate };
408
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAgB,SAAS,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EACL,UAAU,EAIV,eAAe,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