@claude-flow/plugin-gastown-bridge 0.1.3 → 0.1.4

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 (60) hide show
  1. package/dist/bd-bridge-C9wTbkhi.d.cts +318 -0
  2. package/dist/bd-bridge-C9wTbkhi.d.ts +318 -0
  3. package/dist/bridges.cjs +1 -1
  4. package/dist/bridges.d.cts +13 -612
  5. package/dist/bridges.d.ts +13 -612
  6. package/dist/bridges.js +1 -1
  7. package/dist/chunk-2KNTWGUX.js +12 -0
  8. package/dist/chunk-2KNTWGUX.js.map +1 -0
  9. package/dist/chunk-46PJFOMY.cjs +11 -0
  10. package/dist/chunk-46PJFOMY.cjs.map +1 -0
  11. package/dist/chunk-7UPWLRZX.js +11 -0
  12. package/dist/chunk-7UPWLRZX.js.map +1 -0
  13. package/dist/chunk-7VD5N6NG.cjs +11 -0
  14. package/dist/chunk-7VD5N6NG.cjs.map +1 -0
  15. package/dist/chunk-EBOVUTYL.js +12 -0
  16. package/dist/chunk-EBOVUTYL.js.map +1 -0
  17. package/dist/chunk-I2TLUPMJ.cjs +12 -0
  18. package/dist/chunk-I2TLUPMJ.cjs.map +1 -0
  19. package/dist/chunk-Q7MLH722.cjs +11 -0
  20. package/dist/chunk-Q7MLH722.cjs.map +1 -0
  21. package/dist/chunk-QFMFM7NE.cjs +13 -0
  22. package/dist/chunk-QFMFM7NE.cjs.map +1 -0
  23. package/dist/chunk-SUKPSMVK.cjs +12 -0
  24. package/dist/chunk-SUKPSMVK.cjs.map +1 -0
  25. package/dist/chunk-TGFYZY3C.js +11 -0
  26. package/dist/chunk-TGFYZY3C.js.map +1 -0
  27. package/dist/chunk-U74VYTRV.js +11 -0
  28. package/dist/chunk-U74VYTRV.js.map +1 -0
  29. package/dist/chunk-UJ56JMNG.js +13 -0
  30. package/dist/chunk-UJ56JMNG.js.map +1 -0
  31. package/dist/convoy.cjs +2 -0
  32. package/dist/convoy.cjs.map +1 -0
  33. package/dist/convoy.d.cts +6 -0
  34. package/dist/convoy.d.ts +6 -0
  35. package/dist/convoy.js +2 -0
  36. package/dist/convoy.js.map +1 -0
  37. package/dist/formula.cjs +2 -0
  38. package/dist/formula.cjs.map +1 -0
  39. package/dist/formula.d.cts +317 -0
  40. package/dist/formula.d.ts +317 -0
  41. package/dist/formula.js +2 -0
  42. package/dist/formula.js.map +1 -0
  43. package/dist/gt-bridge-B7hZz5vC.d.cts +291 -0
  44. package/dist/gt-bridge-B7hZz5vC.d.ts +291 -0
  45. package/dist/index-BzkAx4ho.d.ts +785 -0
  46. package/dist/index-CGJs8eMa.d.cts +785 -0
  47. package/dist/index.cjs +8 -9
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.d.cts +17 -2241
  50. package/dist/index.d.ts +17 -2241
  51. package/dist/index.js +8 -9
  52. package/dist/index.js.map +1 -1
  53. package/dist/types-CMoOZXrm.d.cts +1146 -0
  54. package/dist/types-CMoOZXrm.d.ts +1146 -0
  55. package/dist/wasm-loader.js +1 -1
  56. package/package.json +16 -18
  57. package/dist/chunk-IBKUMYUL.js +0 -14
  58. package/dist/chunk-IBKUMYUL.js.map +0 -1
  59. package/dist/chunk-JF2GA7QE.cjs +0 -14
  60. package/dist/chunk-JF2GA7QE.cjs.map +0 -1
package/dist/bridges.d.ts CHANGED
@@ -1,607 +1,8 @@
1
+ export { A as AddressSchema, a as GasEstimate, b as GasLimitSchema, c as GasPriceSchema, d as GtArgumentSchema, G as GtBridge, e as GtBridgeConfig, f as GtBridgeError, g as GtErrorCode, I as GtIdentifierSchema, h as GtLogger, i as GtResult, S as GtSafeStringSchema, N as NetworkSchema, j as NetworkStatus, T as TxHashSchema, k as TxStatus, l as createGtBridge } from './gt-bridge-B7hZz5vC.js';
2
+ import { b as BdBridgeConfig, j as Bead, B as BdBridge } from './bd-bridge-C9wTbkhi.js';
3
+ export { a as BdArgumentSchema, c as BdBridgeError, d as BdErrorCode, e as BdLogger, f as BdResult, g as BdStreamResult, h as BeadIdSchema, i as BeadQuery, k as CliBeadSchema, l as CliBeadType, m as CliBeadTypeSchema, C as CreateBeadParams, n as createBdBridge } from './bd-bridge-C9wTbkhi.js';
1
4
  import { z } from 'zod';
2
- import { ChildProcess } from 'child_process';
3
-
4
- /**
5
- * Gas Town CLI Bridge
6
- *
7
- * Provides a secure wrapper around the `gt` (Gas Town) CLI tool.
8
- * Implements command execution with proper input sanitization,
9
- * argument validation, and error handling.
10
- *
11
- * Security Features:
12
- * - All inputs validated with Zod schemas
13
- * - No shell execution (uses execFile)
14
- * - Command allowlist enforcement
15
- * - Argument sanitization
16
- *
17
- * @module v3/plugins/gastown-bridge/bridges/gt-bridge
18
- */
19
-
20
- /**
21
- * Safe string pattern - no shell metacharacters
22
- */
23
- declare const SafeStringSchema: z.ZodEffects<z.ZodString, string, string>;
24
- /**
25
- * Safe identifier pattern - alphanumeric with underscore/hyphen
26
- */
27
- declare const IdentifierSchema: z.ZodString;
28
- /**
29
- * Gas price schema
30
- */
31
- declare const GasPriceSchema: z.ZodNumber;
32
- /**
33
- * Gas limit schema
34
- */
35
- declare const GasLimitSchema: z.ZodNumber;
36
- /**
37
- * Transaction hash schema (0x prefixed hex)
38
- */
39
- declare const TxHashSchema: z.ZodString;
40
- /**
41
- * Address schema (0x prefixed hex)
42
- */
43
- declare const AddressSchema: z.ZodString;
44
- /**
45
- * Network schema
46
- */
47
- declare const NetworkSchema: z.ZodEnum<["mainnet", "goerli", "sepolia", "polygon", "arbitrum", "optimism", "base", "local"]>;
48
- /**
49
- * GT command argument schema
50
- */
51
- declare const GtArgumentSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
52
- /**
53
- * Gas Town executor configuration
54
- */
55
- interface GtBridgeConfig {
56
- /**
57
- * Path to gt executable
58
- * Default: 'gt' (assumes in PATH)
59
- */
60
- gtPath?: string;
61
- /**
62
- * Working directory for execution
63
- */
64
- cwd?: string;
65
- /**
66
- * Execution timeout in milliseconds
67
- * Default: 30000 (30 seconds)
68
- */
69
- timeout?: number;
70
- /**
71
- * Maximum buffer size for output
72
- * Default: 10MB
73
- */
74
- maxBuffer?: number;
75
- /**
76
- * Environment variables
77
- */
78
- env?: NodeJS.ProcessEnv;
79
- /**
80
- * Default network
81
- */
82
- defaultNetwork?: z.infer<typeof NetworkSchema>;
83
- }
84
- /**
85
- * Gas estimation result
86
- */
87
- interface GasEstimate {
88
- gasLimit: number;
89
- gasPrice: string;
90
- maxFeePerGas?: string;
91
- maxPriorityFeePerGas?: string;
92
- estimatedCost: string;
93
- estimatedCostUsd?: number;
94
- }
95
- /**
96
- * Transaction status
97
- */
98
- interface TxStatus {
99
- hash: string;
100
- status: 'pending' | 'confirmed' | 'failed' | 'dropped';
101
- blockNumber?: number;
102
- confirmations?: number;
103
- gasUsed?: number;
104
- effectiveGasPrice?: string;
105
- error?: string;
106
- }
107
- /**
108
- * Network status
109
- */
110
- interface NetworkStatus {
111
- network: string;
112
- chainId: number;
113
- blockNumber: number;
114
- baseFee?: string;
115
- gasPrice?: string;
116
- connected: boolean;
117
- }
118
- /**
119
- * GT execution result
120
- */
121
- interface GtResult<T = unknown> {
122
- success: boolean;
123
- data?: T;
124
- error?: string;
125
- command: string;
126
- args: string[];
127
- durationMs: number;
128
- }
129
- /**
130
- * Logger interface
131
- */
132
- interface GtLogger {
133
- debug: (msg: string, meta?: Record<string, unknown>) => void;
134
- info: (msg: string, meta?: Record<string, unknown>) => void;
135
- warn: (msg: string, meta?: Record<string, unknown>) => void;
136
- error: (msg: string, meta?: Record<string, unknown>) => void;
137
- }
138
- /**
139
- * Gas Town bridge error codes
140
- */
141
- type GtErrorCode = 'COMMAND_NOT_FOUND' | 'EXECUTION_FAILED' | 'TIMEOUT' | 'INVALID_ARGUMENT' | 'INVALID_OUTPUT' | 'NETWORK_ERROR' | 'VALIDATION_ERROR';
142
- /**
143
- * Gas Town bridge error
144
- */
145
- declare class GtBridgeError extends Error {
146
- readonly code: GtErrorCode;
147
- readonly command?: string | undefined;
148
- readonly args?: string[] | undefined;
149
- readonly cause?: Error | undefined;
150
- constructor(message: string, code: GtErrorCode, command?: string | undefined, args?: string[] | undefined, cause?: Error | undefined);
151
- }
152
- /**
153
- * Gas Town CLI Bridge
154
- *
155
- * Secure wrapper around the `gt` CLI tool for gas estimation
156
- * and transaction management.
157
- *
158
- * @example
159
- * ```typescript
160
- * const gtBridge = new GtBridge({ gtPath: '/usr/local/bin/gt' });
161
- * await gtBridge.initialize();
162
- *
163
- * const estimate = await gtBridge.estimateGas({
164
- * to: '0x...',
165
- * data: '0x...',
166
- * network: 'mainnet',
167
- * });
168
- * ```
169
- */
170
- declare class GtBridge {
171
- private config;
172
- private logger;
173
- private initialized;
174
- /** Commands that can be cached (read-only, no side effects) */
175
- private static readonly CACHEABLE_COMMANDS;
176
- /** Commands that should use longer cache (static data) */
177
- private static readonly STATIC_COMMANDS;
178
- constructor(config?: GtBridgeConfig, logger?: GtLogger);
179
- /**
180
- * Initialize the bridge and verify gt is available
181
- */
182
- initialize(): Promise<void>;
183
- /**
184
- * Execute a gt command with validated arguments
185
- *
186
- * @param args - Command arguments (validated and sanitized)
187
- * @returns Command output
188
- */
189
- execGt(args: string[], skipCache?: boolean): Promise<GtResult<string>>;
190
- /**
191
- * Parse JSON output from gt command
192
- *
193
- * @param output - Raw command output
194
- * @returns Parsed JSON object
195
- */
196
- parseGtOutput<T>(output: string): T;
197
- /**
198
- * Estimate gas for a transaction
199
- */
200
- estimateGas(params: {
201
- to: string;
202
- data?: string;
203
- value?: string;
204
- from?: string;
205
- network?: z.infer<typeof NetworkSchema>;
206
- }): Promise<GasEstimate>;
207
- /**
208
- * Get transaction status
209
- */
210
- getTxStatus(txHash: string, network?: z.infer<typeof NetworkSchema>): Promise<TxStatus>;
211
- /**
212
- * Get network status
213
- */
214
- getNetworkStatus(network?: z.infer<typeof NetworkSchema>): Promise<NetworkStatus>;
215
- /**
216
- * Get current gas price
217
- */
218
- getGasPrice(network?: z.infer<typeof NetworkSchema>): Promise<{
219
- gasPrice: string;
220
- maxFeePerGas?: string;
221
- maxPriorityFeePerGas?: string;
222
- baseFee?: string;
223
- }>;
224
- /**
225
- * Simulate a transaction
226
- */
227
- simulate(params: {
228
- to: string;
229
- data: string;
230
- value?: string;
231
- from?: string;
232
- network?: z.infer<typeof NetworkSchema>;
233
- blockNumber?: number;
234
- }): Promise<{
235
- success: boolean;
236
- returnData?: string;
237
- gasUsed?: number;
238
- logs?: unknown[];
239
- error?: string;
240
- }>;
241
- /**
242
- * Decode transaction data
243
- */
244
- decode(data: string, abi?: string): Promise<{
245
- method: string;
246
- args: unknown[];
247
- signature: string;
248
- }>;
249
- /**
250
- * Validate and sanitize command arguments
251
- */
252
- private validateAndSanitizeArgs;
253
- /**
254
- * Ensure bridge is initialized
255
- */
256
- private ensureInitialized;
257
- /**
258
- * Check if bridge is initialized
259
- */
260
- isInitialized(): boolean;
261
- /**
262
- * Get current configuration
263
- */
264
- getConfig(): Readonly<Required<GtBridgeConfig>>;
265
- /**
266
- * Get cache statistics for performance monitoring
267
- */
268
- getCacheStats(): {
269
- resultCache: {
270
- entries: number;
271
- sizeBytes: number;
272
- };
273
- staticCache: {
274
- entries: number;
275
- sizeBytes: number;
276
- };
277
- parsedCache: {
278
- entries: number;
279
- sizeBytes: number;
280
- };
281
- };
282
- /**
283
- * Clear all caches (useful for testing or memory pressure)
284
- */
285
- clearCaches(): void;
286
- }
287
- /**
288
- * Create a new Gas Town bridge instance
289
- */
290
- declare function createGtBridge(config?: GtBridgeConfig, logger?: GtLogger): GtBridge;
291
-
292
- /**
293
- * Beads CLI Bridge
294
- *
295
- * Provides a secure wrapper around the `bd` (Beads) CLI tool.
296
- * Implements command execution with proper input sanitization,
297
- * argument validation, JSONL parsing, and error handling.
298
- *
299
- * Security Features:
300
- * - All inputs validated with Zod schemas
301
- * - No shell execution (uses execFile)
302
- * - Command allowlist enforcement
303
- * - Argument sanitization
304
- * - JSONL streaming support
305
- *
306
- * @module v3/plugins/gastown-bridge/bridges/bd-bridge
307
- */
308
-
309
- /**
310
- * Bead ID schema (UUID or custom format)
311
- */
312
- declare const BeadIdSchema: z.ZodString;
313
- /**
314
- * Bead type schema
315
- */
316
- declare const BeadTypeSchema: z.ZodEnum<["prompt", "response", "code", "context", "memory", "tool-call", "tool-result", "system", "error", "metadata"]>;
317
- /**
318
- * Bead schema
319
- */
320
- declare const BeadSchema: z.ZodObject<{
321
- id: z.ZodString;
322
- type: z.ZodEnum<["prompt", "response", "code", "context", "memory", "tool-call", "tool-result", "system", "error", "metadata"]>;
323
- content: z.ZodString;
324
- timestamp: z.ZodOptional<z.ZodString>;
325
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
326
- parentId: z.ZodOptional<z.ZodString>;
327
- threadId: z.ZodOptional<z.ZodString>;
328
- agentId: z.ZodOptional<z.ZodString>;
329
- tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
330
- embedding: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
331
- hash: z.ZodOptional<z.ZodString>;
332
- }, "strip", z.ZodTypeAny, {
333
- type: "error" | "metadata" | "code" | "prompt" | "response" | "context" | "memory" | "tool-call" | "tool-result" | "system";
334
- id: string;
335
- content: string;
336
- metadata?: Record<string, unknown> | undefined;
337
- embedding?: number[] | undefined;
338
- parentId?: string | undefined;
339
- timestamp?: string | undefined;
340
- threadId?: string | undefined;
341
- agentId?: string | undefined;
342
- tags?: string[] | undefined;
343
- hash?: string | undefined;
344
- }, {
345
- type: "error" | "metadata" | "code" | "prompt" | "response" | "context" | "memory" | "tool-call" | "tool-result" | "system";
346
- id: string;
347
- content: string;
348
- metadata?: Record<string, unknown> | undefined;
349
- embedding?: number[] | undefined;
350
- parentId?: string | undefined;
351
- timestamp?: string | undefined;
352
- threadId?: string | undefined;
353
- agentId?: string | undefined;
354
- tags?: string[] | undefined;
355
- hash?: string | undefined;
356
- }>;
357
- /**
358
- * BD command argument schema
359
- */
360
- declare const BdArgumentSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
361
- /**
362
- * Bead type (inferred from schema)
363
- */
364
- type Bead = z.infer<typeof BeadSchema>;
365
- /**
366
- * Bead type enum
367
- */
368
- type BeadType = z.infer<typeof BeadTypeSchema>;
369
- /**
370
- * Beads bridge configuration
371
- */
372
- interface BdBridgeConfig {
373
- /**
374
- * Path to bd executable
375
- * Default: 'bd' (assumes in PATH)
376
- */
377
- bdPath?: string;
378
- /**
379
- * Working directory for execution
380
- */
381
- cwd?: string;
382
- /**
383
- * Execution timeout in milliseconds
384
- * Default: 60000 (60 seconds)
385
- */
386
- timeout?: number;
387
- /**
388
- * Maximum buffer size for output
389
- * Default: 50MB (beads can be large)
390
- */
391
- maxBuffer?: number;
392
- /**
393
- * Environment variables
394
- */
395
- env?: NodeJS.ProcessEnv;
396
- /**
397
- * Default storage path
398
- */
399
- storagePath?: string;
400
- }
401
- /**
402
- * Bead query parameters
403
- */
404
- interface BeadQuery {
405
- type?: BeadType | BeadType[];
406
- threadId?: string;
407
- agentId?: string;
408
- tags?: string[];
409
- after?: string;
410
- before?: string;
411
- limit?: number;
412
- offset?: number;
413
- sortBy?: 'timestamp' | 'id' | 'type';
414
- sortOrder?: 'asc' | 'desc';
415
- }
416
- /**
417
- * Bead creation parameters
418
- */
419
- interface CreateBeadParams {
420
- type: BeadType;
421
- content: string;
422
- parentId?: string;
423
- threadId?: string;
424
- agentId?: string;
425
- tags?: string[];
426
- metadata?: Record<string, unknown>;
427
- }
428
- /**
429
- * BD execution result
430
- */
431
- interface BdResult<T = unknown> {
432
- success: boolean;
433
- data?: T;
434
- error?: string;
435
- command: string;
436
- args: string[];
437
- durationMs: number;
438
- }
439
- /**
440
- * Streaming execution result
441
- */
442
- interface BdStreamResult {
443
- process: ChildProcess;
444
- stdout: NodeJS.ReadableStream | null;
445
- stderr: NodeJS.ReadableStream | null;
446
- promise: Promise<BdResult<string>>;
447
- }
448
- /**
449
- * Logger interface
450
- */
451
- interface BdLogger {
452
- debug: (msg: string, meta?: Record<string, unknown>) => void;
453
- info: (msg: string, meta?: Record<string, unknown>) => void;
454
- warn: (msg: string, meta?: Record<string, unknown>) => void;
455
- error: (msg: string, meta?: Record<string, unknown>) => void;
456
- }
457
- /**
458
- * Beads bridge error codes
459
- */
460
- type BdErrorCode = 'COMMAND_NOT_FOUND' | 'EXECUTION_FAILED' | 'TIMEOUT' | 'INVALID_ARGUMENT' | 'INVALID_OUTPUT' | 'PARSE_ERROR' | 'VALIDATION_ERROR' | 'BEAD_NOT_FOUND';
461
- /**
462
- * Beads bridge error
463
- */
464
- declare class BdBridgeError extends Error {
465
- readonly code: BdErrorCode;
466
- readonly command?: string | undefined;
467
- readonly args?: string[] | undefined;
468
- readonly cause?: Error | undefined;
469
- constructor(message: string, code: BdErrorCode, command?: string | undefined, args?: string[] | undefined, cause?: Error | undefined);
470
- }
471
- /**
472
- * Beads CLI Bridge
473
- *
474
- * Secure wrapper around the `bd` CLI tool for bead management.
475
- * Supports JSONL output parsing for streaming large datasets.
476
- *
477
- * @example
478
- * ```typescript
479
- * const bdBridge = new BdBridge({ bdPath: '/usr/local/bin/bd' });
480
- * await bdBridge.initialize();
481
- *
482
- * const beads = await bdBridge.listBeads({ type: 'prompt', limit: 100 });
483
- * ```
484
- */
485
- declare class BdBridge {
486
- private config;
487
- private logger;
488
- private initialized;
489
- /** Commands that can be cached (read-only, no side effects) */
490
- private static readonly CACHEABLE_COMMANDS;
491
- /** Commands that should use longer cache (static data) */
492
- private static readonly STATIC_COMMANDS;
493
- constructor(config?: BdBridgeConfig, logger?: BdLogger);
494
- /**
495
- * Initialize the bridge and verify bd is available
496
- */
497
- initialize(): Promise<void>;
498
- /**
499
- * Execute a bd command with validated arguments
500
- *
501
- * @param args - Command arguments (validated and sanitized)
502
- * @returns Command output
503
- */
504
- execBd(args: string[], skipCache?: boolean): Promise<BdResult<string>>;
505
- /**
506
- * Execute bd command with streaming output
507
- */
508
- execBdStreaming(args: string[]): BdStreamResult;
509
- /**
510
- * Parse JSONL output from bd command into Bead array
511
- *
512
- * @param output - JSONL formatted output
513
- * @returns Array of parsed and validated beads
514
- */
515
- parseBdOutput(output: string): Bead[];
516
- /**
517
- * Parse single bead from JSON output
518
- */
519
- parseSingleBead(output: string): Bead;
520
- /**
521
- * List beads with optional query parameters
522
- */
523
- listBeads(query?: BeadQuery): Promise<Bead[]>;
524
- /**
525
- * Get a single bead by ID
526
- */
527
- getBead(beadId: string): Promise<Bead>;
528
- /**
529
- * Create a new bead
530
- */
531
- createBead(params: CreateBeadParams): Promise<Bead>;
532
- /**
533
- * Search beads with semantic query
534
- */
535
- searchBeads(query: string, options?: {
536
- limit?: number;
537
- threshold?: number;
538
- type?: BeadType | BeadType[];
539
- }): Promise<Bead[]>;
540
- /**
541
- * Export beads to JSONL format
542
- */
543
- exportBeads(query?: BeadQuery): Promise<string>;
544
- /**
545
- * Get bead statistics
546
- */
547
- getStats(): Promise<{
548
- totalBeads: number;
549
- beadsByType: Record<string, number>;
550
- totalThreads: number;
551
- oldestBead?: string;
552
- newestBead?: string;
553
- storageSize?: number;
554
- }>;
555
- /**
556
- * Validate and sanitize command arguments
557
- */
558
- private validateAndSanitizeArgs;
559
- /**
560
- * Ensure bridge is initialized
561
- */
562
- private ensureInitialized;
563
- /**
564
- * Check if bridge is initialized
565
- */
566
- isInitialized(): boolean;
567
- /**
568
- * Get current configuration
569
- */
570
- getConfig(): Readonly<Required<BdBridgeConfig>>;
571
- /**
572
- * Get cache statistics for performance monitoring
573
- */
574
- getCacheStats(): {
575
- beadQueryCache: {
576
- entries: number;
577
- sizeBytes: number;
578
- };
579
- singleBeadCache: {
580
- entries: number;
581
- sizeBytes: number;
582
- };
583
- staticCache: {
584
- entries: number;
585
- sizeBytes: number;
586
- };
587
- parsedCache: {
588
- entries: number;
589
- sizeBytes: number;
590
- };
591
- };
592
- /**
593
- * Clear all caches (useful for testing or memory pressure)
594
- */
595
- clearCaches(): void;
596
- /**
597
- * Invalidate cache for a specific bead (after create/update/delete)
598
- */
599
- invalidateBeadCache(beadId: string): void;
600
- }
601
- /**
602
- * Create a new Beads bridge instance
603
- */
604
- declare function createBdBridge(config?: BdBridgeConfig, logger?: BdLogger): BdBridge;
5
+ import 'child_process';
605
6
 
606
7
  /**
607
8
  * Beads-AgentDB Sync Bridge
@@ -646,22 +47,22 @@ declare const AgentDBEntrySchema: z.ZodObject<{
646
47
  version: z.ZodOptional<z.ZodNumber>;
647
48
  }, "strip", z.ZodTypeAny, {
648
49
  key: string;
649
- namespace?: string | undefined;
650
- version?: number | undefined;
651
- metadata?: Record<string, unknown> | undefined;
652
50
  value?: unknown;
653
- embedding?: number[] | undefined;
654
51
  createdAt?: string | undefined;
655
52
  updatedAt?: string | undefined;
53
+ metadata?: Record<string, unknown> | undefined;
54
+ version?: number | undefined;
55
+ embedding?: number[] | undefined;
56
+ namespace?: string | undefined;
656
57
  }, {
657
58
  key: string;
658
- namespace?: string | undefined;
659
- version?: number | undefined;
660
- metadata?: Record<string, unknown> | undefined;
661
59
  value?: unknown;
662
- embedding?: number[] | undefined;
663
60
  createdAt?: string | undefined;
664
61
  updatedAt?: string | undefined;
62
+ metadata?: Record<string, unknown> | undefined;
63
+ version?: number | undefined;
64
+ embedding?: number[] | undefined;
65
+ namespace?: string | undefined;
665
66
  }>;
666
67
  /**
667
68
  * Conflict resolution strategy type
@@ -921,4 +322,4 @@ declare class SyncBridge {
921
322
  */
922
323
  declare function createSyncBridge(agentDB: IAgentDBService, config?: SyncBridgeConfig, logger?: SyncLogger): SyncBridge;
923
324
 
924
- export { AddressSchema, type AgentDBEntry, AgentDBEntrySchema, BdArgumentSchema, BdBridge, type BdBridgeConfig, BdBridgeError, type BdErrorCode, type BdLogger, type BdResult, type BdStreamResult, BeadIdSchema, type BeadQuery, type Bead as CliBead, BeadSchema as CliBeadSchema, type BeadType as CliBeadType, BeadTypeSchema as CliBeadTypeSchema, type SyncDirection as CliSyncDirection, SyncDirectionSchema as CliSyncDirectionSchema, type SyncResult as CliSyncResult, type ConflictStrategy, ConflictStrategySchema, type CreateBeadParams, type GasEstimate, GasLimitSchema, GasPriceSchema, GtArgumentSchema, GtBridge, type GtBridgeConfig, GtBridgeError, type GtErrorCode, IdentifierSchema as GtIdentifierSchema, type GtLogger, type GtResult, SafeStringSchema as GtSafeStringSchema, type IAgentDBService, NetworkSchema, type NetworkStatus, SyncBridge, type SyncBridgeConfig, SyncBridgeError, type SyncConflict, type SyncErrorCode, type SyncLogger, type SyncState, type SyncStatus, SyncStatusSchema, TxHashSchema, type TxStatus, createBdBridge, createGtBridge, createSyncBridge };
325
+ export { type AgentDBEntry, AgentDBEntrySchema, BdBridge, BdBridgeConfig, Bead as CliBead, type SyncDirection as CliSyncDirection, SyncDirectionSchema as CliSyncDirectionSchema, type SyncResult as CliSyncResult, type ConflictStrategy, ConflictStrategySchema, type IAgentDBService, SyncBridge, type SyncBridgeConfig, SyncBridgeError, type SyncConflict, type SyncErrorCode, type SyncLogger, type SyncState, type SyncStatus, SyncStatusSchema, createSyncBridge };
package/dist/bridges.js CHANGED
@@ -1,2 +1,2 @@
1
- export{k as AddressSchema,A as AgentDBEntrySchema,t as BdArgumentSchema,v as BdBridge,u as BdBridgeError,q as BeadIdSchema,s as CliBeadSchema,r as CliBeadTypeSchema,y as CliSyncDirectionSchema,x as ConflictStrategySchema,i as GasLimitSchema,h as GasPriceSchema,m as GtArgumentSchema,o as GtBridge,n as GtBridgeError,g as GtIdentifierSchema,f as GtSafeStringSchema,l as NetworkSchema,C as SyncBridge,B as SyncBridgeError,z as SyncStatusSchema,j as TxHashSchema,w as createBdBridge,p as createGtBridge,D as createSyncBridge}from'./chunk-IBKUMYUL.js';//# sourceMappingURL=bridges.js.map
1
+ export{f as AddressSchema,o as AgentDBEntrySchema,m as CliSyncDirectionSchema,l as ConflictStrategySchema,d as GasLimitSchema,c as GasPriceSchema,h as GtArgumentSchema,j as GtBridge,i as GtBridgeError,b as GtIdentifierSchema,a as GtSafeStringSchema,g as NetworkSchema,q as SyncBridge,p as SyncBridgeError,n as SyncStatusSchema,e as TxHashSchema,k as createGtBridge,r as createSyncBridge}from'./chunk-UJ56JMNG.js';export{d as BdArgumentSchema,f as BdBridge,e as BdBridgeError,a as BeadIdSchema,c as CliBeadSchema,b as CliBeadTypeSchema,g as createBdBridge}from'./chunk-EBOVUTYL.js';//# sourceMappingURL=bridges.js.map
2
2
  //# sourceMappingURL=bridges.js.map
@@ -0,0 +1,12 @@
1
+ import {b,a as a$1,f,x}from'./chunk-TGFYZY3C.js';import {a,c,e}from'./chunk-U74VYTRV.js';import {EventEmitter}from'events';import {randomUUID}from'crypto';/**
2
+ * @claude-flow/plugin-gastown-bridge v0.1.4
3
+ *
4
+ * WASM-accelerated Gas Town orchestration for Claude Flow V3
5
+ * Bundle optimized: <100KB gzipped total
6
+ *
7
+ * @license MIT
8
+ * @copyright 2024 rUv
9
+ */
10
+ var F=new a({maxEntries:500,ttlMs:300*1e3}),P=new a({maxEntries:200,ttlMs:600*1e3}),Q=new c,H=new c,W=class{constructor(e){this.numWorkers=e;for(let r=0;r<e;r++)this.queues.push([]);}numWorkers;queues=[];nextQueueId=0;enqueue(e){let r=0,s=this.queues[0]?.length??0;for(let n=1;n<this.queues.length;n++){let a=this.queues[n]?.length??0;a<s&&(s=a,r=n);}this.queues[r]?.push(e);}dequeue(e){let r=this.queues[e];if(r&&r.length>0)return r.shift();for(let s=1;s<this.queues.length;s++){let n=(e+s)%this.queues.length,a=this.queues[n];if(a&&a.length>1)return a.pop()}}isEmpty(){return this.queues.every(e=>e.length===0)}get size(){return this.queues.reduce((e,r)=>e+r.length,0)}};function B(h){let e=2166136261;for(let r of h){for(let s=0;s<r.length;s++)e^=r.charCodeAt(s),e=e*16777619>>>0;e^=255;}return e.toString(36)}var J={debug:(h,e)=>console.debug(`[formula-executor] ${h}`,e??""),info:(h,e)=>console.info(`[formula-executor] ${h}`,e??""),warn:(h,e)=>console.warn(`[formula-executor] ${h}`,e??""),error:(h,e)=>console.error(`[formula-executor] ${h}`,e??"")},L=class{isInitialized(){return true}parseFormula(e){try{let r=e.split(`
11
+ `),s="parsed-formula",n="",a="workflow",i=1,t=[],c={},o="",d=null;for(let w of r){let g=w.trim();if(!g||g.startsWith("#"))continue;if(g.startsWith("[")){d&&d.id&&t.push(d);let u=g.match(/\[(\w+)(?:\.(\w+))?\]/);u&&(o=u[1],u[2]?d={id:u[2],title:"",description:""}:d=null);continue}let R=g.match(/^(\w+)\s*=\s*"?([^"]*)"?$/);if(R){let[,u,x]=R;o==="formula"?u==="name"?s=x:u==="description"?n=x:u==="type"?a=x:u==="version"&&(i=parseInt(x,10)):d&&(u==="title"?d.title=x:u==="description"?d.description=x:u==="needs"&&(d.needs=x.split(",").map(f=>f.trim())));}}return d&&d.id&&t.push(d),{name:s,description:n,type:a,version:i,steps:t,vars:c}}catch(r){throw f.parseFailed("js-parse","Failed to parse formula content",r)}}cookFormula(e,r){let s=i=>i.replace(/\{\{(\w+)\}\}/g,(t,c)=>r[c]??t),n=e.steps?.map(i=>({...i,title:s(i.title),description:s(i.description)})),a=e.legs?.map(i=>({...i,title:s(i.title),description:s(i.description),focus:s(i.focus)}));return {...e,steps:n,legs:a,cookedAt:new Date,cookedVars:{...r},originalName:e.name}}batchCook(e,r){return e.map((s,n)=>{let a=r[n]??{};return this.cookFormula(s,a)})}resolveStepDependencies(e){let r=new Map,s=new Map,n=new Map;for(let t of e)r.set(t.id,t),s.set(t.id,0),n.set(t.id,[]);for(let t of e)if(t.needs){for(let c of t.needs)if(r.has(c)){let o=n.get(c);o&&o.push(t.id),s.set(t.id,(s.get(t.id)??0)+1);}}let a=[];s.forEach((t,c)=>{t===0&&a.push(c);});let i=[];for(;a.length>0;){let t=a.shift(),c=r.get(t);c&&i.push(c);for(let o of n.get(t)??[]){let d=(s.get(o)??1)-1;s.set(o,d),d===0&&a.push(o);}}if(i.length!==e.length)throw new b("Cycle detected in step dependencies",a$1.DEPENDENCY_CYCLE,{sortedCount:i.length,totalCount:e.length});return i}detectCycle(e){let r=new Set,s=new Set,n=new Map;for(let i of e)n.set(i.id,i);let a=(i,t)=>{r.add(i),s.add(i);let c=n.get(i);if(c?.needs)for(let o of c.needs)if(r.has(o)){if(s.has(o))return [...t,o]}else {let d=a(o,[...t,o]);if(d)return d}return s.delete(i),null};for(let i of e)if(!r.has(i.id)){let t=a(i.id,[i.id]);if(t)return {hasCycle:true,cycleSteps:t}}return {hasCycle:false}}},A=class extends EventEmitter{gtBridge;wasmLoader;logger;jsFallback;executions=new Map;cancellations=new Map;progressEmitters=new Map;defaultMaxParallel=4;constructor(e,r,s){super(),this.gtBridge=e,this.wasmLoader=r??new L,this.logger=s??J,this.jsFallback=new L;}async execute(e$1,r,s={}){let n=randomUUID(),a=new AbortController;this.cancellations.set(n,a);let i=s.signal?this.mergeSignals(s.signal,a.signal):a.signal;try{this.logger.info("Starting formula execution",{executionId:n,formulaName:e$1});let t=await this.cook(e$1,r),c=t.steps??[],o=t.legs??[],d=c.length||o.length,l={executionId:n,formulaName:e$1,status:"running",totalSteps:d,completedSteps:0,failedSteps:0,startTime:new Date,stepResults:[],percentage:0};this.executions.set(n,l),this.emit("execution:start",n,t);let w=new e(f=>this.emit("execution:progress",f),100);this.progressEmitters.set(n,w);let g=this.getOrderedExecutionUnits(t),R=[],u=new Map,x=s.maxParallel??this.defaultMaxParallel;if(x>1&&g.length>1){let f=new Map,v=new Map,D=new Map;for(let y=0;y<g.length;y++){let S=g[y];v.set(S.id,S),D.set(S.id,y),f.set(S.id,new Set(S.needs??[]));}let p=new Set,I=new Set,Y=new W(x),V=()=>{let y=[];for(let S of g){if(p.has(S.id)||I.has(S.id))continue;let k=f.get(S.id);(!k||[...k].every(T=>p.has(T)))&&y.push(S);}return y};for(;p.size<g.length;){if(i.aborted)throw l.status="cancelled",this.emit("execution:cancelled",n),new b("Execution cancelled",a$1.UNKNOWN,{executionId:n});let y=V();if(y.length===0&&I.size===0)break;let S=Math.min(y.length,x-I.size),k=y.slice(0,S);if(k.length===0){await new Promise(m=>setTimeout(m,10));continue}for(let m of k)I.add(m.id);let T=k.map(async m=>{let U=D.get(m.id)??0;l.currentStep=m.id;let K={executionId:n,formula:t,stepIndex:U,totalSteps:g.length,variables:t.cookedVars,previousResults:u,signal:i,startTime:l.startTime};this.emit("step:start",n,m);try{let b=await this.runStep(m,K,s);return u.set(m.id,b),p.add(m.id),I.delete(m.id),b.success?l.completedSteps++:l.failedSteps++,l.stepResults.push(b),l.percentage=Math.round(p.size/g.length*100),this.emit("step:complete",n,b),w.update({...l}),b}catch(b){let z={stepId:m.id,success:!1,error:b instanceof Error?b.message:String(b),durationMs:0};if(u.set(m.id,z),p.add(m.id),I.delete(m.id),l.failedSteps++,l.stepResults.push(z),this.emit("step:error",n,m.id,b),w.update({...l}),!m.metadata?.continueOnError)throw b;return z}}),G=await Promise.all(T);R.push(...G);}w.flush();}else {for(let f=0;f<g.length;f++){if(i.aborted)throw l.status="cancelled",this.emit("execution:cancelled",n),new b("Execution cancelled",a$1.UNKNOWN,{executionId:n});let v=g[f];l.currentStep=v.id;let D={executionId:n,formula:t,stepIndex:f,totalSteps:g.length,variables:t.cookedVars,previousResults:u,signal:i,startTime:l.startTime};this.emit("step:start",n,v);try{let p=await this.runStep(v,D,s);R.push(p),u.set(v.id,p),p.success?l.completedSteps++:l.failedSteps++,l.stepResults.push(p),l.percentage=Math.round((f+1)/g.length*100),this.emit("step:complete",n,p),w.update({...l});}catch(p){let I={stepId:v.id,success:!1,error:p instanceof Error?p.message:String(p),durationMs:0};if(R.push(I),u.set(v.id,I),l.failedSteps++,l.stepResults.push(I),this.emit("step:error",n,v.id,p),!v.metadata?.continueOnError)throw p}}w.flush();}return l.status=l.failedSteps>0?"failed":"completed",l.endTime=new Date,l.percentage=100,this.emit("execution:complete",n,R),this.logger.info("Formula execution completed",{executionId:n,formulaName:e$1,completed:l.completedSteps,failed:l.failedSteps}),R}catch(t){let c=this.executions.get(n);throw c&&(c.status="failed",c.endTime=new Date,c.error=t instanceof Error?t.message:String(t)),this.emit("execution:error",n,t),t}finally{this.cancellations.delete(n);let t=this.progressEmitters.get(n);t&&(t.cancel(),this.progressEmitters.delete(n));}}async cook(e,r){this.logger.debug("Cooking formula",{formulaName:e,varsCount:Object.keys(r).length});let s=Object.keys(r).sort(),n=s.map(t=>r[t]),a=B([e,...s,...n]),i=P.get(a);return i?(this.logger.debug("Cook cache hit",{formulaName:e}),i):Q.dedupe(a,async()=>{try{let t;e.includes("[")||e.includes("=")?t=this.parseFormula(e):t=await H.dedupe(e,()=>this.fetchFormula(e)),this.validateVariables(t,r);let o=(this.wasmLoader.isInitialized()?this.wasmLoader:this.jsFallback).cookFormula(t,r);return P.set(a,o),this.logger.debug("Formula cooked successfully",{formulaName:e,wasmAccelerated:this.wasmLoader.isInitialized()}),o}catch(t){throw t instanceof b?t:f.cookFailed(e,t instanceof Error?t.message:String(t),t)}})}async generateMolecules(e){this.logger.debug("Generating molecules",{formulaName:e.name});let r=[],s=new Map;if(e.type==="convoy"&&e.legs){let n=[...e.legs].sort((a,i)=>(a.order??0)-(i.order??0));for(let a=0;a<n.length;a++){let i=n[a],t=`mol-${e.name}-${i.id}-${randomUUID().slice(0,8)}`;s.set(i.id,t);let c=x.acquire();c.id=t,c.formulaName=e.name,c.title=i.title,c.description=i.description,c.type=e.type,c.sourceId=i.id,c.agent=i.agent,c.dependencies=a>0?[s.get(n[a-1].id)]:[],c.order=a,c.metadata={focus:i.focus,legOrder:i.order},c.createdAt=new Date;let o={id:c.id,formulaName:c.formulaName,title:c.title,description:c.description,type:c.type,sourceId:c.sourceId,agent:c.agent,dependencies:[...c.dependencies],order:c.order,metadata:{...c.metadata},createdAt:c.createdAt};x.release(c),r.push(o),this.emit("molecule:created",o);}}else if(e.steps){let n=this.resolveStepDependencies(e.steps);for(let a=0;a<n.length;a++){let i=n[a],t=`mol-${e.name}-${i.id}-${randomUUID().slice(0,8)}`;s.set(i.id,t);let c=[];if(i.needs)for(let l of i.needs){let w=s.get(l);w&&c.push(w);}let o=x.acquire();o.id=t,o.formulaName=e.name,o.title=i.title,o.description=i.description,o.type=e.type,o.sourceId=i.id,o.agent=void 0,o.dependencies=c,o.order=a,o.metadata={duration:i.duration,requires:i.requires,...i.metadata},o.createdAt=new Date;let d={id:o.id,formulaName:o.formulaName,title:o.title,description:o.description,type:o.type,sourceId:o.sourceId,agent:o.agent,dependencies:[...o.dependencies],order:o.order,metadata:{...o.metadata},createdAt:o.createdAt};x.release(o),r.push(d),this.emit("molecule:created",d);}}return this.logger.info("Molecules generated",{formulaName:e.name,count:r.length}),r}async runStep(e,r,s={}){let n=Date.now();this.logger.debug("Running step",{stepId:e.id,executionId:r.executionId});let i=e.metadata?.cacheable!==false&&!e.metadata?.hasSideEffects?B([e.id,r.formula.name,JSON.stringify(r.variables),JSON.stringify(e.needs??[])]):null;if(i){let t=F.get(i);if(t)return this.logger.debug("Step cache hit",{stepId:e.id}),{...t,metadata:{...t.metadata,fromCache:true}}}try{if(r.signal?.aborted)throw new b("Step cancelled",a$1.UNKNOWN);if(e.needs)for(let o of e.needs){let d=r.previousResults.get(o);if(!d||!d.success)throw new b(`Dependency not satisfied: ${o}`,a$1.UNKNOWN,{stepId:e.id,dependency:o})}if(s.stepHandler){let o=await s.stepHandler(e,r);return i&&o.success&&F.set(i,o),o}if(s.dryRun)return {stepId:e.id,success:!0,output:{dryRun:!0,step:e},durationMs:Date.now()-n,metadata:{dryRun:!0}};let t=await this.executeStepViaCli(e,r,s),c={stepId:e.id,success:!0,output:t,durationMs:Date.now()-n};return i&&F.set(i,c),c}catch(t){return {stepId:e.id,success:false,error:t instanceof Error?t.message:String(t),durationMs:Date.now()-n}}}getProgress(e){return this.executions.get(e)}cancel(e){let r=this.cancellations.get(e);return r?(r.abort(),true):false}getActiveExecutions(){return Array.from(this.executions.values()).filter(e=>e.status==="running"||e.status==="pending")}isWasmAvailable(){return this.wasmLoader.isInitialized()}getCacheStats(){return {stepResultCache:F.stats(),cookCache:P.stats()}}clearCaches(){F.clear(),P.clear();}parseFormula(e){return (this.wasmLoader.isInitialized()?this.wasmLoader:this.jsFallback).parseFormula(e)}async fetchFormula(e){if(!this.gtBridge.isInitialized())throw new b("GtBridge not initialized",a$1.NOT_INITIALIZED);return this.logger.debug("Fetching formula from CLI",{formulaName:e}),{name:e,description:`Formula: ${e}`,type:"workflow",version:1,steps:[{id:"init",title:"Initialize",description:"Initialize the workflow"},{id:"process",title:"Process",description:"Process the data",needs:["init"]},{id:"finalize",title:"Finalize",description:"Finalize the workflow",needs:["process"]}],vars:{}}}validateVariables(e,r){if(!e.vars)return;let s=[];for(let[n,a]of Object.entries(e.vars))a.required&&!(n in r)&&!a.default&&s.push(n);if(s.length>0)throw new b(`Missing required variables: ${s.join(", ")}`,a$1.INVALID_ARGUMENTS,{missing:s})}resolveStepDependencies(e){return (this.wasmLoader.isInitialized()?this.wasmLoader:this.jsFallback).resolveStepDependencies(e)}getOrderedExecutionUnits(e){if(e.type==="convoy"&&e.legs){let r=[...e.legs].sort((s,n)=>(s.order??0)-(n.order??0));return r.map((s,n)=>({id:s.id,title:s.title,description:s.description,needs:n>0?[r[n-1].id]:void 0,metadata:{agent:s.agent,focus:s.focus}}))}return e.steps?this.resolveStepDependencies(e.steps):[]}async executeStepViaCli(e,r,s){let n=["formula","step",e.id,"--execution-id",r.executionId,"--json"];s.targetAgent&&n.push("--agent",s.targetAgent),s.stepTimeout&&n.push("--timeout",String(s.stepTimeout));let a=await this.gtBridge.execGt(n);if(!a.success)throw new b(`Step execution failed: ${a.error}`,a$1.CLI_EXECUTION_FAILED,{stepId:e.id,error:a.error});return a.data?JSON.parse(a.data):null}mergeSignals(...e){let r=new AbortController;for(let s of e){if(s.aborted){r.abort();break}s.addEventListener("abort",()=>r.abort(),{once:true});}return r.signal}};function le(h,e,r){return new A(h,e,r)}var de=A;export{A as a,le as b,de as c};//# sourceMappingURL=chunk-2KNTWGUX.js.map
12
+ //# sourceMappingURL=chunk-2KNTWGUX.js.map