clawpowers 1.1.4 → 2.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/LICENSE +44 -0
  3. package/README.md +204 -228
  4. package/SECURITY.md +72 -0
  5. package/dist/index.d.ts +844 -0
  6. package/dist/index.js +2536 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +50 -44
  9. package/.claude-plugin/manifest.json +0 -19
  10. package/.codex/INSTALL.md +0 -36
  11. package/.cursor-plugin/manifest.json +0 -21
  12. package/.opencode/INSTALL.md +0 -52
  13. package/ARCHITECTURE.md +0 -69
  14. package/bin/clawpowers.js +0 -625
  15. package/bin/clawpowers.sh +0 -91
  16. package/docs/demo/clawpowers-demo.cast +0 -197
  17. package/docs/demo/clawpowers-demo.gif +0 -0
  18. package/docs/launch-images/25-skills-breakdown.jpg +0 -0
  19. package/docs/launch-images/clawpowers-vs-superpowers.jpg +0 -0
  20. package/docs/launch-images/economic-code-optimization.jpg +0 -0
  21. package/docs/launch-images/native-vs-bridge-2.jpg +0 -0
  22. package/docs/launch-images/native-vs-bridge.jpg +0 -0
  23. package/docs/launch-images/post1-hero-lobster.jpg +0 -0
  24. package/docs/launch-images/post2-dashboard.jpg +0 -0
  25. package/docs/launch-images/post3-superpowers.jpg +0 -0
  26. package/docs/launch-images/post4-before-after.jpg +0 -0
  27. package/docs/launch-images/post5-install-now.jpg +0 -0
  28. package/docs/launch-images/ultimate-stack.jpg +0 -0
  29. package/docs/launch-posts.md +0 -76
  30. package/docs/quickstart-first-transaction.md +0 -204
  31. package/gemini-extension.json +0 -32
  32. package/hooks/session-start +0 -205
  33. package/hooks/session-start.cmd +0 -43
  34. package/hooks/session-start.js +0 -163
  35. package/runtime/demo/README.md +0 -78
  36. package/runtime/demo/x402-mock-server.js +0 -230
  37. package/runtime/feedback/analyze.js +0 -621
  38. package/runtime/feedback/analyze.sh +0 -546
  39. package/runtime/init.js +0 -210
  40. package/runtime/init.sh +0 -178
  41. package/runtime/metrics/collector.js +0 -361
  42. package/runtime/metrics/collector.sh +0 -308
  43. package/runtime/payments/ledger.js +0 -305
  44. package/runtime/payments/ledger.sh +0 -262
  45. package/runtime/payments/pipeline.js +0 -455
  46. package/runtime/persistence/store.js +0 -433
  47. package/runtime/persistence/store.sh +0 -303
  48. package/skill.json +0 -106
  49. package/skills/agent-bounties/SKILL.md +0 -553
  50. package/skills/agent-payments/SKILL.md +0 -479
  51. package/skills/brainstorming/SKILL.md +0 -233
  52. package/skills/content-pipeline/SKILL.md +0 -282
  53. package/skills/cross-project-knowledge/SKILL.md +0 -345
  54. package/skills/dispatching-parallel-agents/SKILL.md +0 -305
  55. package/skills/economic-code-optimization/SKILL.md +0 -265
  56. package/skills/executing-plans/SKILL.md +0 -255
  57. package/skills/finishing-a-development-branch/SKILL.md +0 -260
  58. package/skills/formal-verification-lite/SKILL.md +0 -441
  59. package/skills/learn-how-to-learn/SKILL.md +0 -235
  60. package/skills/market-intelligence/SKILL.md +0 -323
  61. package/skills/meta-skill-evolution/SKILL.md +0 -325
  62. package/skills/prospecting/SKILL.md +0 -454
  63. package/skills/receiving-code-review/SKILL.md +0 -225
  64. package/skills/requesting-code-review/SKILL.md +0 -206
  65. package/skills/security-audit/SKILL.md +0 -353
  66. package/skills/self-healing-code/SKILL.md +0 -369
  67. package/skills/subagent-driven-development/SKILL.md +0 -244
  68. package/skills/systematic-debugging/SKILL.md +0 -355
  69. package/skills/test-driven-development/SKILL.md +0 -416
  70. package/skills/using-clawpowers/SKILL.md +0 -160
  71. package/skills/using-git-worktrees/SKILL.md +0 -261
  72. package/skills/validator/SKILL.md +0 -281
  73. package/skills/verification-before-completion/SKILL.md +0 -254
  74. package/skills/writing-plans/SKILL.md +0 -276
  75. package/skills/writing-skills/SKILL.md +0 -260
@@ -0,0 +1,844 @@
1
+ /**
2
+ * ClawPowers Skills — Core Type System
3
+ * Zero `any` types. Discriminated unions for all status fields.
4
+ * Agent control-loop types (AgentStatus, AgentState, Goal, Plan, Step) removed —
5
+ * this is a skills library, not an agent runtime.
6
+ */
7
+ type GoalSource = 'cli' | 'interactive' | 'resume';
8
+ interface Goal {
9
+ readonly taskId: string;
10
+ readonly description: string;
11
+ readonly constraints: readonly string[];
12
+ readonly successCriteria: readonly string[];
13
+ readonly createdAt: string;
14
+ readonly source: GoalSource;
15
+ }
16
+ type StepStatus = 'pending' | 'in-progress' | 'complete' | 'failed' | 'skipped';
17
+ interface Step {
18
+ readonly stepId: string;
19
+ readonly description: string;
20
+ readonly assignedSkills: readonly string[];
21
+ readonly status: StepStatus;
22
+ readonly dependsOn: readonly string[];
23
+ readonly output: string | null;
24
+ readonly retryCount: number;
25
+ readonly maxRetries: number;
26
+ }
27
+ type PlanStatus = 'draft' | 'approved' | 'executing' | 'complete' | 'failed';
28
+ interface Plan {
29
+ readonly taskId: string;
30
+ readonly steps: readonly Step[];
31
+ readonly status: PlanStatus;
32
+ readonly createdAt: string;
33
+ readonly approvedAt: string | null;
34
+ readonly parallelizable: boolean;
35
+ }
36
+ type AgentStatus = 'idle' | 'intake' | 'planning' | 'executing' | 'reviewing' | 'complete' | 'failed' | 'paused';
37
+ interface MemoryStats {
38
+ readonly workingCount: number;
39
+ readonly episodicCount: number;
40
+ readonly proceduralCount: number;
41
+ readonly lastCheckpoint: string | null;
42
+ readonly memoryBytes: number;
43
+ }
44
+ type MemoryOutcome = 'success' | 'failure' | 'partial';
45
+ interface MemoryEntry {
46
+ readonly taskId: string;
47
+ readonly timestamp: string;
48
+ readonly description: string;
49
+ readonly outcome: MemoryOutcome;
50
+ readonly lessonsLearned: readonly string[];
51
+ readonly skillsUsed: readonly string[];
52
+ readonly durationMs: number;
53
+ readonly tags: readonly string[];
54
+ }
55
+ type ProfileName = 'dev' | 'lead' | 'secure' | 'growth' | 'full';
56
+ interface Profile {
57
+ readonly name: ProfileName;
58
+ readonly description: string;
59
+ readonly skills: readonly string[];
60
+ readonly defaultModel: string;
61
+ readonly maxConcurrentAgents: number;
62
+ readonly paymentEnabled: boolean;
63
+ readonly rsiEnabled: boolean;
64
+ }
65
+ interface SkillRequirements {
66
+ readonly bins: readonly string[];
67
+ readonly env: readonly string[];
68
+ readonly config: readonly string[];
69
+ }
70
+ interface SkillManifest {
71
+ readonly name: string;
72
+ readonly description: string;
73
+ readonly path: string;
74
+ readonly requirements: SkillRequirements | null;
75
+ }
76
+ type RSITierMode = 'auto' | 'ask' | 'off';
77
+ type RSITierT4Mode = 'ask' | 'off';
78
+ interface RSITier {
79
+ readonly t1: RSITierMode;
80
+ readonly t2: RSITierMode;
81
+ readonly t3: RSITierMode;
82
+ readonly t4: RSITierT4Mode;
83
+ }
84
+ type RSIMutationStatus = 'active' | 'rolled-back';
85
+ interface RSIMutation {
86
+ readonly mutationId: string;
87
+ readonly appliedAt: string;
88
+ readonly delta: number;
89
+ readonly status: RSIMutationStatus;
90
+ }
91
+ type PaymentMode = 'human-first' | 'auto' | 'disabled';
92
+ interface PaymentConfig {
93
+ readonly mode: PaymentMode;
94
+ readonly dailyLimitUsd: number;
95
+ readonly weeklyLimitUsd: number;
96
+ readonly allowedDomains: readonly string[];
97
+ }
98
+ interface RSIConfig {
99
+ readonly enabled: boolean;
100
+ readonly tiers: RSITier;
101
+ }
102
+ interface LoggingConfig {
103
+ readonly level: 'debug' | 'info' | 'warn' | 'error';
104
+ readonly retentionDays: number;
105
+ }
106
+ interface ConfigFile {
107
+ readonly version: string;
108
+ readonly profile: ProfileName;
109
+ readonly rsi: RSIConfig;
110
+ readonly payments: PaymentConfig;
111
+ readonly logging: LoggingConfig;
112
+ readonly skillsDir: string;
113
+ readonly dataDir: string;
114
+ }
115
+ interface StepResult {
116
+ readonly stepId: string;
117
+ readonly status: 'success' | 'failure';
118
+ readonly output: string;
119
+ readonly durationMs: number;
120
+ readonly retriesUsed: number;
121
+ readonly error: string | null;
122
+ }
123
+ interface PlanResult {
124
+ readonly taskId: string;
125
+ readonly status: 'success' | 'failure' | 'partial';
126
+ readonly stepResults: readonly StepResult[];
127
+ readonly durationMs: number;
128
+ readonly completedSteps: number;
129
+ readonly failedSteps: number;
130
+ readonly skippedSteps: number;
131
+ }
132
+ interface CriterionResult {
133
+ readonly criterion: string;
134
+ readonly met: boolean;
135
+ readonly evidence: string;
136
+ }
137
+ interface ReviewResult {
138
+ readonly passed: boolean;
139
+ readonly criteria: readonly CriterionResult[];
140
+ readonly suggestions: readonly string[];
141
+ }
142
+ type TaskOutcome = 'success' | 'failure' | 'partial';
143
+ interface TaskCompletion {
144
+ readonly taskId: string;
145
+ readonly outcome: TaskOutcome;
146
+ readonly summary: string;
147
+ readonly durationMs: number;
148
+ readonly skillsUsed: readonly string[];
149
+ readonly lessonsLearned: readonly string[];
150
+ }
151
+ interface WorkingMemory {
152
+ readonly taskId: string;
153
+ readonly goal: Goal;
154
+ readonly plan: Plan;
155
+ readonly currentStepId: string | null;
156
+ readonly intermediateOutputs: Readonly<Record<string, string>>;
157
+ readonly contextWindow: readonly string[];
158
+ }
159
+ interface PaymentRequired {
160
+ readonly amount: number;
161
+ readonly currency: string;
162
+ readonly recipient: string;
163
+ readonly network: string;
164
+ readonly x402Headers: Readonly<Record<string, string>>;
165
+ }
166
+ interface PaymentRequest {
167
+ readonly amount: number;
168
+ readonly currency: string;
169
+ readonly recipient: string;
170
+ readonly x402Headers: Readonly<Record<string, string>>;
171
+ readonly domain: string;
172
+ }
173
+ interface PaymentResult {
174
+ readonly success: boolean;
175
+ readonly txHash?: string;
176
+ readonly error?: string;
177
+ }
178
+ interface SpendingDecision {
179
+ readonly allowed: boolean;
180
+ readonly reason: string;
181
+ readonly remainingDaily: number;
182
+ }
183
+ interface PaymentAuditEntry {
184
+ readonly timestamp: string;
185
+ readonly request: PaymentRequest;
186
+ readonly result: PaymentResult;
187
+ readonly spendingSnapshot: {
188
+ readonly dailySpent: number;
189
+ readonly dailyLimit: number;
190
+ };
191
+ }
192
+ interface EpisodicEntry {
193
+ readonly taskId: string;
194
+ readonly timestamp: string;
195
+ readonly description: string;
196
+ readonly outcome: MemoryOutcome;
197
+ readonly lessonsLearned: readonly string[];
198
+ readonly skillsUsed: readonly string[];
199
+ readonly durationMs: number;
200
+ readonly tags: readonly string[];
201
+ }
202
+ interface MutationRecord {
203
+ readonly mutationId: string;
204
+ readonly description: string;
205
+ readonly appliedAt: string;
206
+ readonly revertedAt: string | null;
207
+ readonly status: 'active' | 'reverted';
208
+ }
209
+ interface ProceduralEntry {
210
+ readonly skillName: string;
211
+ readonly invocationCount: number;
212
+ readonly successRate: number;
213
+ readonly avgContribution: number;
214
+ readonly preferredContexts: readonly string[];
215
+ readonly lastUsed: string;
216
+ readonly mutations: readonly MutationRecord[];
217
+ }
218
+ interface CheckpointState {
219
+ readonly taskId: string;
220
+ readonly goal: Goal;
221
+ readonly plan: Plan;
222
+ readonly currentStepId: string | null;
223
+ readonly intermediateOutputs: Readonly<Record<string, string>>;
224
+ readonly workingMemory: WorkingMemory;
225
+ readonly savedAt: string;
226
+ readonly agentStatus: AgentStatus;
227
+ }
228
+ interface CheckpointInfo {
229
+ readonly taskId: string;
230
+ readonly description: string;
231
+ readonly savedAt: string;
232
+ readonly isStale: boolean;
233
+ }
234
+ interface TaskMetrics {
235
+ readonly taskId: string;
236
+ readonly timestamp: string;
237
+ readonly durationMs: number;
238
+ readonly stepCount: number;
239
+ readonly stepsCompleted: number;
240
+ readonly stepsFailed: number;
241
+ readonly retryCount: number;
242
+ readonly skillsUsed: readonly string[];
243
+ readonly outcome: TaskOutcome;
244
+ readonly memoryEntriesCreated: number;
245
+ }
246
+ interface SkillMetrics {
247
+ readonly skillName: string;
248
+ readonly timestamp: string;
249
+ readonly invoked: boolean;
250
+ readonly succeeded: boolean;
251
+ readonly durationMs: number;
252
+ readonly taskId: string;
253
+ readonly mutationActive: boolean;
254
+ }
255
+ type TrendDirection = 'improving' | 'declining' | 'stable';
256
+ interface SkillAggregateStats {
257
+ readonly skillName: string;
258
+ readonly totalInvocations: number;
259
+ readonly successRate: number;
260
+ readonly avgDurationMs: number;
261
+ readonly trendDirection: TrendDirection;
262
+ }
263
+ type RSITierLabel = 'T1' | 'T2' | 'T3' | 'T4';
264
+ interface RSIHypothesis {
265
+ readonly hypothesisId: string;
266
+ readonly skillName: string;
267
+ readonly description: string;
268
+ readonly expectedImprovement: number;
269
+ readonly tier: RSITierLabel;
270
+ readonly confidence: number;
271
+ readonly evidence: readonly string[];
272
+ }
273
+ type RSIMutationExtendedStatus = 'proposed' | 'applied' | 'reverted' | 'promoted';
274
+ interface RSIMutationExtended {
275
+ readonly mutationId: string;
276
+ readonly hypothesisId: string;
277
+ readonly skillName: string;
278
+ readonly tier: RSITierLabel;
279
+ readonly description: string;
280
+ readonly originalValue: string;
281
+ readonly mutatedValue: string;
282
+ readonly status: RSIMutationExtendedStatus;
283
+ readonly appliedAt: string | null;
284
+ readonly revertedAt: string | null;
285
+ }
286
+ type ABTestStatus = 'running' | 'completed' | 'cancelled';
287
+ type ABTestDecision = 'promote' | 'rollback' | 'continue';
288
+ interface ABTest {
289
+ readonly testId: string;
290
+ readonly mutationId: string;
291
+ readonly skillName: string;
292
+ readonly baselineStats: SkillAggregateStats;
293
+ readonly variantStats: SkillAggregateStats;
294
+ readonly sampleSize: number;
295
+ readonly minSampleSize: number;
296
+ readonly startedAt: string;
297
+ readonly status: ABTestStatus;
298
+ }
299
+ interface ABTestResult {
300
+ readonly testId: string;
301
+ readonly decision: ABTestDecision;
302
+ readonly improvement: number;
303
+ readonly confidence: number;
304
+ }
305
+ interface RSIAuditMetrics {
306
+ readonly baseline: number;
307
+ readonly current: number;
308
+ readonly delta: number;
309
+ }
310
+ interface RSIAuditEntry {
311
+ readonly timestamp: string;
312
+ readonly action: string;
313
+ readonly skillName: string;
314
+ readonly mutationId: string;
315
+ readonly hypothesis: string;
316
+ readonly metrics: RSIAuditMetrics;
317
+ readonly decision: string;
318
+ }
319
+
320
+ /**
321
+ * ClawPowers Agent — Config Manager
322
+ * CRUD for ~/.clawpowers/config.json with Zod validation.
323
+ * T4 can never be set to "auto" — enforced at validation layer.
324
+ */
325
+
326
+ declare function loadConfig(configPath?: string): ConfigFile;
327
+ /**
328
+ * Safe config loader — returns defaults if file is missing or invalid.
329
+ * Used by CLI where crashing on stale config is bad UX.
330
+ */
331
+ declare function loadConfigSafe(configPath?: string): ConfigFile;
332
+ declare function saveConfig(config: ConfigFile, configPath?: string): void;
333
+ declare function initConfig(configPath?: string): ConfigFile;
334
+ /**
335
+ * Get a value from config using dot notation (e.g., "rsi.tiers.t1")
336
+ */
337
+ declare function getConfigValue(config: ConfigFile, key: string): unknown;
338
+ /**
339
+ * Set a value in config using dot notation. Returns the updated config.
340
+ * Validates the entire config after the set to ensure consistency.
341
+ * Throws on invalid values (e.g., T4 = "auto").
342
+ */
343
+ declare function setConfigValue(config: ConfigFile, key: string, value: string): ConfigFile;
344
+
345
+ /**
346
+ * ClawPowers Skills — Constants
347
+ * Default paths, version, config values, RSI tier boundaries.
348
+ */
349
+
350
+ declare const VERSION = "2.0.0";
351
+ declare const PACKAGE_NAME = "clawpowers";
352
+ declare const CLAWPOWERS_HOME: string;
353
+ declare const DEFAULT_CONFIG: ConfigFile;
354
+
355
+ /**
356
+ * ClawPowers Agent — Payment Discovery
357
+ * Detects HTTP 402 Payment Required responses and parses x402 headers.
358
+ */
359
+
360
+ interface HttpResponse {
361
+ readonly status: number;
362
+ readonly headers: Readonly<Record<string, string>>;
363
+ }
364
+ /**
365
+ * Detect a 402 Payment Required response and extract payment details from x402 headers.
366
+ * Returns null if the response is not a 402 or if required headers are missing.
367
+ */
368
+ declare function detect402(response: HttpResponse): PaymentRequired | null;
369
+ /**
370
+ * Type guard to check if an error represents a 402 Payment Required response.
371
+ */
372
+ declare function isPaymentRequired(error: unknown): boolean;
373
+
374
+ /**
375
+ * ClawPowers Agent — Spending Policy
376
+ * Enforces daily limits, per-transaction limits, and domain allowlists.
377
+ * Fail-closed: any policy error results in rejection.
378
+ */
379
+
380
+ interface SpendingRecord {
381
+ amount: number;
382
+ timestamp: number;
383
+ domain: string;
384
+ }
385
+ declare class SpendingPolicy {
386
+ readonly dailyLimit: number;
387
+ readonly transactionLimit: number;
388
+ readonly allowedDomains: readonly string[];
389
+ private spendingLog;
390
+ constructor(options: {
391
+ dailyLimit: number;
392
+ transactionLimit: number;
393
+ allowedDomains: readonly string[];
394
+ });
395
+ /**
396
+ * Get total spending for the current UTC day.
397
+ */
398
+ getDailySpent(): number;
399
+ /**
400
+ * Check whether a transaction is allowed under the current policy.
401
+ * Fail-closed: any validation error results in rejection.
402
+ */
403
+ checkTransaction(amount: number, domain: string): SpendingDecision;
404
+ /**
405
+ * Record a completed spending transaction.
406
+ */
407
+ recordSpend(amount: number, domain: string): void;
408
+ /**
409
+ * Reset all spending records (used for testing).
410
+ */
411
+ reset(): void;
412
+ /**
413
+ * Get the full spending log (for audit purposes).
414
+ */
415
+ getSpendingLog(): readonly SpendingRecord[];
416
+ }
417
+
418
+ /**
419
+ * ClawPowers Agent — Payment Executor
420
+ * Executes payments via agentpay-mcp with spending policy enforcement.
421
+ * Never auto-retries failed payments (financial safety).
422
+ */
423
+
424
+ /**
425
+ * Interface for an MCP payment client.
426
+ * In production, this wraps agentpay-mcp; in tests, it can be substituted.
427
+ */
428
+ interface MCPPaymentClient {
429
+ executePayment(params: {
430
+ amount: number;
431
+ currency: string;
432
+ recipient: string;
433
+ x402Headers: Readonly<Record<string, string>>;
434
+ }): Promise<{
435
+ txHash: string;
436
+ status: 'success' | 'failed';
437
+ }>;
438
+ }
439
+ /**
440
+ * Payment executor that enforces spending policy and logs all attempts.
441
+ */
442
+ declare class PaymentExecutor {
443
+ private readonly policy;
444
+ private readonly client;
445
+ private readonly auditLog;
446
+ constructor(policy: SpendingPolicy, client: MCPPaymentClient);
447
+ /**
448
+ * Execute a payment request.
449
+ * 1. Check spending policy
450
+ * 2. If allowed, execute via MCP client
451
+ * 3. Log the result (success or failure)
452
+ * 4. Never auto-retry on failure
453
+ */
454
+ executePayment(request: PaymentRequest): Promise<PaymentResult>;
455
+ /**
456
+ * Get the full payment audit log.
457
+ */
458
+ getAuditLog(): readonly PaymentAuditEntry[];
459
+ /**
460
+ * Log a payment attempt to the audit trail.
461
+ */
462
+ private logAudit;
463
+ }
464
+
465
+ /**
466
+ * ClawPowers Agent — Working Memory Manager
467
+ * In-process working memory with token budget enforcement.
468
+ */
469
+
470
+ declare class WorkingMemoryManager {
471
+ private memory;
472
+ create(taskId: string, goal: Goal): WorkingMemory;
473
+ updateCurrentStep(stepId: string): void;
474
+ addIntermediateOutput(stepId: string, output: string): void;
475
+ /**
476
+ * Inject context entries into working memory, enforcing token budget.
477
+ * Entries are added until the budget is exhausted, then truncated.
478
+ */
479
+ injectContext(entries: readonly string[]): void;
480
+ getSnapshot(): WorkingMemory;
481
+ clear(): void;
482
+ }
483
+
484
+ /**
485
+ * ClawPowers Agent — Episodic Memory
486
+ * JSONL append-only storage for task episodes.
487
+ */
488
+
489
+ declare class EpisodicMemory {
490
+ private readonly filePath;
491
+ constructor(filePath: string);
492
+ private ensureDir;
493
+ append(entry: EpisodicEntry): Promise<void>;
494
+ readAll(): Promise<EpisodicEntry[]>;
495
+ search(query: string, limit?: number): Promise<EpisodicEntry[]>;
496
+ readRecent(count: number): Promise<EpisodicEntry[]>;
497
+ recoverFromCorruption(): Promise<{
498
+ recovered: number;
499
+ lost: number;
500
+ }>;
501
+ private parseLines;
502
+ }
503
+
504
+ /**
505
+ * ClawPowers Agent — Procedural Memory
506
+ * JSON-based skill effectiveness tracking with atomic writes.
507
+ */
508
+
509
+ declare class ProceduralMemory {
510
+ private readonly filePath;
511
+ private cache;
512
+ constructor(filePath: string);
513
+ private ensureDir;
514
+ load(): Promise<ProceduralEntry[]>;
515
+ update(skillName: string, result: {
516
+ succeeded: boolean;
517
+ durationMs: number;
518
+ taskId: string;
519
+ }): Promise<void>;
520
+ getSkillScore(skillName: string): ProceduralEntry | null;
521
+ getTopSkills(context: string, limit: number): ProceduralEntry[];
522
+ recordMutation(skillName: string, mutation: MutationRecord): Promise<void>;
523
+ rollbackMutation(skillName: string, mutationId: string): Promise<void>;
524
+ private atomicWrite;
525
+ }
526
+
527
+ /**
528
+ * ClawPowers Agent — Checkpoint Manager
529
+ * Crash recovery via atomic checkpoint files.
530
+ */
531
+
532
+ declare class CheckpointManager {
533
+ private readonly dir;
534
+ constructor(dir: string);
535
+ private ensureDir;
536
+ private filePath;
537
+ save(taskId: string, state: CheckpointState): Promise<void>;
538
+ load(taskId: string): Promise<CheckpointState | null>;
539
+ remove(taskId: string): Promise<void>;
540
+ listIncomplete(): Promise<CheckpointInfo[]>;
541
+ isStale(checkpoint: CheckpointState, maxAgeMs?: number): boolean;
542
+ }
543
+
544
+ /**
545
+ * ClawPowers Agent — Context Injector
546
+ * Selects and compresses relevant memories for working memory injection.
547
+ */
548
+
549
+ declare class ContextInjector {
550
+ private readonly episodic;
551
+ private readonly procedural;
552
+ constructor(episodic: EpisodicMemory, procedural: ProceduralMemory);
553
+ inject(goal: Goal, maxTokens?: number): Promise<string[]>;
554
+ }
555
+
556
+ /**
557
+ * ClawPowers Agent — RSI Metrics Collector
558
+ * Per-task and per-skill metric collection in JSONL format.
559
+ */
560
+
561
+ declare class MetricsCollector {
562
+ private readonly taskMetricsPath;
563
+ private readonly skillMetricsPath;
564
+ constructor(taskMetricsPath: string, skillMetricsPath: string);
565
+ private ensureDir;
566
+ recordTaskMetrics(task: TaskMetrics): Promise<void>;
567
+ recordSkillMetrics(skill: SkillMetrics): Promise<void>;
568
+ getTaskHistory(limit?: number): Promise<TaskMetrics[]>;
569
+ getSkillHistory(skillName: string, limit?: number): Promise<SkillMetrics[]>;
570
+ getAggregatedSkillStats(skillName: string): Promise<SkillAggregateStats>;
571
+ private calculateTrend;
572
+ private readJsonl;
573
+ }
574
+
575
+ /**
576
+ * ClawPowers Agent — RSI Hypothesis Engine
577
+ * Analyzes skill stats and task history to generate improvement hypotheses.
578
+ */
579
+
580
+ declare class HypothesisEngine {
581
+ analyze(skillStats: readonly SkillAggregateStats[], taskHistory: readonly TaskMetrics[]): RSIHypothesis[];
582
+ private detectLowSuccessRate;
583
+ private detectSlowSkills;
584
+ private detectFrequentlyPairedSkills;
585
+ private detectUnusedInSuccessful;
586
+ }
587
+
588
+ /**
589
+ * ClawPowers Agent — RSI Mutation Engine
590
+ * Creates and manages mutations from hypotheses with tier enforcement.
591
+ */
592
+
593
+ declare class MutationEngine {
594
+ private readonly historyPath;
595
+ constructor(historyPath: string);
596
+ private ensureDir;
597
+ createMutation(hypothesis: RSIHypothesis): RSIMutationExtended;
598
+ applyMutation(mutation: RSIMutationExtended): Promise<void>;
599
+ revertMutation(mutation: RSIMutationExtended): Promise<void>;
600
+ getMutationHistory(): Promise<RSIMutationExtended[]>;
601
+ private appendHistory;
602
+ private validateSafety;
603
+ private isSafetyInvariant;
604
+ }
605
+
606
+ /**
607
+ * ClawPowers Agent — A/B Test Manager
608
+ * Orchestrates A/B tests for RSI mutations.
609
+ */
610
+
611
+ declare class ABTestManager {
612
+ private readonly tests;
613
+ private readonly results;
614
+ startTest(mutation: RSIMutationExtended, baselineMetrics: SkillAggregateStats): ABTest;
615
+ recordResult(testId: string, taskMetrics: TaskMetrics): void;
616
+ evaluateTest(testId: string): ABTestResult;
617
+ getActiveTests(): ABTest[];
618
+ }
619
+
620
+ /**
621
+ * ClawPowers Agent — RSI Audit Log
622
+ * Append-only JSONL audit trail for all RSI actions.
623
+ */
624
+
625
+ declare class RSIAuditLog {
626
+ private readonly filePath;
627
+ constructor(filePath: string);
628
+ private ensureDir;
629
+ log(entry: RSIAuditEntry): Promise<void>;
630
+ getHistory(limit?: number): Promise<RSIAuditEntry[]>;
631
+ getByMutation(mutationId: string): Promise<RSIAuditEntry[]>;
632
+ }
633
+
634
+ /**
635
+ * ClawPowers Agent — RSI AutoResearch Module
636
+ *
637
+ * Runs BEFORE the mutation engine when T3 is triggered.
638
+ * Searches for solutions to task failures, tests candidates in sandbox,
639
+ * and promotes successful solutions to new skills.
640
+ */
641
+ interface FailureTrace {
642
+ taskDescription: string;
643
+ error: string;
644
+ executionSteps: string[];
645
+ skillsUsed: string[];
646
+ attemptCount: number;
647
+ }
648
+ interface CandidateSolution {
649
+ source: 'web-search' | 'npm-registry' | 'skill-catalog';
650
+ description: string;
651
+ approach: string;
652
+ confidence: number;
653
+ }
654
+ interface TestResult {
655
+ passed: boolean;
656
+ output: string;
657
+ durationMs: number;
658
+ attempt: number;
659
+ }
660
+ interface SkillDefinition {
661
+ skillId: string;
662
+ name: string;
663
+ description: string;
664
+ approach: string;
665
+ source: CandidateSolution['source'];
666
+ promotedAt: string;
667
+ testResults: TestResult[];
668
+ }
669
+ interface TaskContext {
670
+ taskId: string;
671
+ description: string;
672
+ constraints: string[];
673
+ successCriteria: string[];
674
+ }
675
+ declare class AutoResearcher {
676
+ private readonly skillsDir;
677
+ constructor(skillsDir?: string);
678
+ /**
679
+ * Search for candidate solutions to a failure.
680
+ *
681
+ * Sources queried (in order of reliability):
682
+ * 1. skill-catalog — skills already available that match the error domain
683
+ * 2. npm-registry — packages that match the error keywords
684
+ * 3. web-search — constructs a query from the failure trace
685
+ *
686
+ * Returns candidates sorted by confidence (highest first).
687
+ */
688
+ research(failure: FailureTrace): Promise<CandidateSolution[]>;
689
+ /**
690
+ * Test a candidate solution in an isolated sandbox.
691
+ * Runs the candidate's approach as a shell command in a temp directory.
692
+ * Returns a TestResult with pass/fail, output, and duration.
693
+ */
694
+ testCandidate(candidate: CandidateSolution, task: TaskContext): Promise<TestResult>;
695
+ /**
696
+ * Run a candidate through REQUIRED_PASSING_RUNS sandbox tests.
697
+ * Returns all TestResult objects. If fewer than REQUIRED_PASSING_RUNS pass,
698
+ * the candidate is NOT promoted (caller must check).
699
+ */
700
+ runSandboxTests(candidate: CandidateSolution, task: TaskContext): Promise<TestResult[]>;
701
+ /**
702
+ * Promote a candidate solution to a new skill definition.
703
+ * Writes a minimal SKILL.md to the skills directory and returns
704
+ * the SkillDefinition.
705
+ */
706
+ promoteToSkill(candidate: CandidateSolution, testResults: TestResult[]): Promise<SkillDefinition>;
707
+ private searchSkillCatalog;
708
+ private searchNpmRegistry;
709
+ private buildWebSearchCandidates;
710
+ /**
711
+ * Build a sandboxed test script for a candidate solution.
712
+ * Validates the candidate's approach by checking its core prerequisites
713
+ * (e.g. that a package is installed, or a command is available).
714
+ */
715
+ private buildTestScript;
716
+ private deriveSkillName;
717
+ private renderSkillMd;
718
+ }
719
+ /**
720
+ * Run the full AutoResearch cycle for a failed task.
721
+ * Returns the promoted SkillDefinition if a solution was found and promoted,
722
+ * or null if no solution was found (caller should fall through to mutation).
723
+ */
724
+ declare function runAutoResearch(failure: FailureTrace, task: TaskContext, skillsDir?: string): Promise<SkillDefinition | null>;
725
+
726
+ /**
727
+ * ClawPowers Agent — Skill Loader
728
+ * Discovers skills from skill directories, validates SKILL.md frontmatter.
729
+ */
730
+
731
+ interface ParsedFrontmatter {
732
+ name?: string;
733
+ description?: string;
734
+ metadata?: {
735
+ openclaw?: {
736
+ requires?: {
737
+ bins?: string[];
738
+ env?: string[];
739
+ config?: string[];
740
+ };
741
+ };
742
+ };
743
+ }
744
+ /**
745
+ * Parse YAML frontmatter from a SKILL.md file content.
746
+ * Expects format: ---\n<yaml>\n---\n<content>
747
+ */
748
+ declare function parseFrontmatter(content: string): ParsedFrontmatter;
749
+ /**
750
+ * Load a single skill manifest from a directory containing SKILL.md
751
+ */
752
+ declare function loadSkillManifest(skillDir: string): SkillManifest | null;
753
+ /**
754
+ * Discover all skills in a directory. Each subdirectory with a valid SKILL.md
755
+ * becomes a skill manifest.
756
+ */
757
+ declare function discoverSkills(skillsDir: string): SkillManifest[];
758
+ /**
759
+ * Filter skills based on active profile.
760
+ * Returns only skills that are listed in the profile's skill list.
761
+ */
762
+ declare function getActiveSkills(allSkills: SkillManifest[], profile: Profile): SkillManifest[];
763
+ /**
764
+ * List skills with their active/inactive status for a given profile.
765
+ */
766
+ declare function listSkillsWithStatus(allSkills: SkillManifest[], profile: Profile): Array<{
767
+ skill: SkillManifest;
768
+ active: boolean;
769
+ }>;
770
+
771
+ /**
772
+ * ClawPowers Skills — Skill Executor
773
+ * Execute skills and track outcomes in procedural memory.
774
+ */
775
+
776
+ interface SkillExecutionContext {
777
+ readonly taskId: string;
778
+ readonly input: string;
779
+ readonly metadata?: Record<string, unknown>;
780
+ }
781
+ interface SkillExecutionResult {
782
+ readonly success: boolean;
783
+ readonly output: string;
784
+ readonly durationMs: number;
785
+ readonly error?: string;
786
+ }
787
+ declare class SkillExecutor {
788
+ private readonly skillsDir;
789
+ private readonly memory;
790
+ constructor(skillsDir: string, memory: ProceduralMemory);
791
+ execute(skillName: string, context: SkillExecutionContext): Promise<SkillExecutionResult>;
792
+ }
793
+
794
+ interface WalletConfig {
795
+ readonly chain: 'base' | 'ethereum' | 'polygon';
796
+ readonly dataDir: string;
797
+ }
798
+ interface WalletInfo {
799
+ readonly address: string;
800
+ readonly chain: string;
801
+ readonly createdAt: string;
802
+ readonly keyFile: string;
803
+ }
804
+ interface SignedMessage {
805
+ readonly message: string;
806
+ readonly signature: string;
807
+ readonly address: string;
808
+ }
809
+
810
+ /**
811
+ * ClawPowers Skills — Wallet Manager
812
+ * High-level wallet management: generate, import, sign, list.
813
+ */
814
+
815
+ declare class WalletManager {
816
+ private readonly config;
817
+ constructor(config: WalletConfig);
818
+ generate(): Promise<WalletInfo>;
819
+ import(privateKey: string): Promise<WalletInfo>;
820
+ sign(message: string, walletInfo: WalletInfo, passphrase: string): Promise<string>;
821
+ listWallets(): Promise<WalletInfo[]>;
822
+ }
823
+
824
+ /**
825
+ * ClawPowers Skills — Wallet Crypto
826
+ * Ethereum-compatible wallet generation, import, and signing using Node.js crypto.
827
+ * No external dependencies for key generation.
828
+ */
829
+
830
+ /**
831
+ * Generate a new Ethereum-compatible wallet.
832
+ * Private key is encrypted with a random passphrase and stored to disk.
833
+ */
834
+ declare function generateWallet(config: WalletConfig): Promise<WalletInfo>;
835
+ /**
836
+ * Import an existing wallet from a private key hex string.
837
+ */
838
+ declare function importWallet(privateKeyHex: string, config: WalletConfig): Promise<WalletInfo>;
839
+ /**
840
+ * Sign a message using an encrypted key file and passphrase.
841
+ */
842
+ declare function signMessage(message: string, keyFile: string, passphrase: string): Promise<SignedMessage>;
843
+
844
+ export { type ABTest, type ABTestDecision, ABTestManager, type ABTestResult, type ABTestStatus, type AgentStatus, AutoResearcher, CLAWPOWERS_HOME, type CheckpointInfo, CheckpointManager, type CheckpointState, type ConfigFile, ContextInjector, type CriterionResult, DEFAULT_CONFIG, type EpisodicEntry, EpisodicMemory, type Goal, type GoalSource, HypothesisEngine, type LoggingConfig, type MCPPaymentClient, type MemoryEntry, type MemoryOutcome, type MemoryStats, MetricsCollector, MutationEngine, type MutationRecord, PACKAGE_NAME, type PaymentAuditEntry, type PaymentConfig, PaymentExecutor, type PaymentMode, type PaymentRequest, type PaymentRequired, type PaymentResult, type Plan, type PlanResult, type PlanStatus, type ProceduralEntry, ProceduralMemory, type Profile, type ProfileName, type RSIAuditEntry, RSIAuditLog, type RSIAuditMetrics, type RSIConfig, type RSIHypothesis, type RSIMutation, type RSIMutationExtended, type RSIMutationExtendedStatus, type RSIMutationStatus, type RSITier, type RSITierLabel, type RSITierMode, type RSITierT4Mode, type ReviewResult, type SignedMessage, type SkillAggregateStats, type SkillExecutionContext, type SkillExecutionResult, SkillExecutor, type SkillManifest, type SkillMetrics, type SkillRequirements, type SpendingDecision, SpendingPolicy, type Step, type StepResult, type StepStatus, type TaskCompletion, type TaskMetrics, type TaskOutcome, type TrendDirection, VERSION, type WalletConfig, type WalletInfo, WalletManager, type WorkingMemory, WorkingMemoryManager, detect402, discoverSkills, generateWallet, getActiveSkills, getConfigValue, importWallet, initConfig, isPaymentRequired, listSkillsWithStatus, loadConfig, loadConfigSafe, loadSkillManifest, parseFrontmatter, runAutoResearch, saveConfig, setConfigValue, signMessage };