@claude-flow/plugin-gastown-bridge 0.1.2 → 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 +5 -604
  5. package/dist/bridges.d.ts +5 -604
  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 +13 -2237
  50. package/dist/index.d.ts +13 -2237
  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 -20
  57. package/dist/chunk-2QQ3FUZF.cjs +0 -14
  58. package/dist/chunk-2QQ3FUZF.cjs.map +0 -1
  59. package/dist/chunk-GKNIKJVQ.js +0 -14
  60. package/dist/chunk-GKNIKJVQ.js.map +0 -1
@@ -0,0 +1,291 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Gas Town CLI Bridge
5
+ *
6
+ * Provides a secure wrapper around the `gt` (Gas Town) CLI tool.
7
+ * Implements command execution with proper input sanitization,
8
+ * argument validation, and error handling.
9
+ *
10
+ * Security Features:
11
+ * - All inputs validated with Zod schemas
12
+ * - No shell execution (uses execFile)
13
+ * - Command allowlist enforcement
14
+ * - Argument sanitization
15
+ *
16
+ * @module v3/plugins/gastown-bridge/bridges/gt-bridge
17
+ */
18
+
19
+ /**
20
+ * Safe string pattern - no shell metacharacters
21
+ */
22
+ declare const SafeStringSchema: z.ZodEffects<z.ZodString, string, string>;
23
+ /**
24
+ * Safe identifier pattern - alphanumeric with underscore/hyphen
25
+ */
26
+ declare const IdentifierSchema: z.ZodString;
27
+ /**
28
+ * Gas price schema
29
+ */
30
+ declare const GasPriceSchema: z.ZodNumber;
31
+ /**
32
+ * Gas limit schema
33
+ */
34
+ declare const GasLimitSchema: z.ZodNumber;
35
+ /**
36
+ * Transaction hash schema (0x prefixed hex)
37
+ */
38
+ declare const TxHashSchema: z.ZodString;
39
+ /**
40
+ * Address schema (0x prefixed hex)
41
+ */
42
+ declare const AddressSchema: z.ZodString;
43
+ /**
44
+ * Network schema
45
+ */
46
+ declare const NetworkSchema: z.ZodEnum<["mainnet", "goerli", "sepolia", "polygon", "arbitrum", "optimism", "base", "local"]>;
47
+ /**
48
+ * GT command argument schema
49
+ */
50
+ declare const GtArgumentSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
51
+ /**
52
+ * Gas Town executor configuration
53
+ */
54
+ interface GtBridgeConfig {
55
+ /**
56
+ * Path to gt executable
57
+ * Default: 'gt' (assumes in PATH)
58
+ */
59
+ gtPath?: string;
60
+ /**
61
+ * Working directory for execution
62
+ */
63
+ cwd?: string;
64
+ /**
65
+ * Execution timeout in milliseconds
66
+ * Default: 30000 (30 seconds)
67
+ */
68
+ timeout?: number;
69
+ /**
70
+ * Maximum buffer size for output
71
+ * Default: 10MB
72
+ */
73
+ maxBuffer?: number;
74
+ /**
75
+ * Environment variables
76
+ */
77
+ env?: NodeJS.ProcessEnv;
78
+ /**
79
+ * Default network
80
+ */
81
+ defaultNetwork?: z.infer<typeof NetworkSchema>;
82
+ }
83
+ /**
84
+ * Gas estimation result
85
+ */
86
+ interface GasEstimate {
87
+ gasLimit: number;
88
+ gasPrice: string;
89
+ maxFeePerGas?: string;
90
+ maxPriorityFeePerGas?: string;
91
+ estimatedCost: string;
92
+ estimatedCostUsd?: number;
93
+ }
94
+ /**
95
+ * Transaction status
96
+ */
97
+ interface TxStatus {
98
+ hash: string;
99
+ status: 'pending' | 'confirmed' | 'failed' | 'dropped';
100
+ blockNumber?: number;
101
+ confirmations?: number;
102
+ gasUsed?: number;
103
+ effectiveGasPrice?: string;
104
+ error?: string;
105
+ }
106
+ /**
107
+ * Network status
108
+ */
109
+ interface NetworkStatus {
110
+ network: string;
111
+ chainId: number;
112
+ blockNumber: number;
113
+ baseFee?: string;
114
+ gasPrice?: string;
115
+ connected: boolean;
116
+ }
117
+ /**
118
+ * GT execution result
119
+ */
120
+ interface GtResult<T = unknown> {
121
+ success: boolean;
122
+ data?: T;
123
+ error?: string;
124
+ command: string;
125
+ args: string[];
126
+ durationMs: number;
127
+ }
128
+ /**
129
+ * Logger interface
130
+ */
131
+ interface GtLogger {
132
+ debug: (msg: string, meta?: Record<string, unknown>) => void;
133
+ info: (msg: string, meta?: Record<string, unknown>) => void;
134
+ warn: (msg: string, meta?: Record<string, unknown>) => void;
135
+ error: (msg: string, meta?: Record<string, unknown>) => void;
136
+ }
137
+ /**
138
+ * Gas Town bridge error codes
139
+ */
140
+ type GtErrorCode = 'COMMAND_NOT_FOUND' | 'EXECUTION_FAILED' | 'TIMEOUT' | 'INVALID_ARGUMENT' | 'INVALID_OUTPUT' | 'NETWORK_ERROR' | 'VALIDATION_ERROR';
141
+ /**
142
+ * Gas Town bridge error
143
+ */
144
+ declare class GtBridgeError extends Error {
145
+ readonly code: GtErrorCode;
146
+ readonly command?: string | undefined;
147
+ readonly args?: string[] | undefined;
148
+ readonly cause?: Error | undefined;
149
+ constructor(message: string, code: GtErrorCode, command?: string | undefined, args?: string[] | undefined, cause?: Error | undefined);
150
+ }
151
+ /**
152
+ * Gas Town CLI Bridge
153
+ *
154
+ * Secure wrapper around the `gt` CLI tool for gas estimation
155
+ * and transaction management.
156
+ *
157
+ * @example
158
+ * ```typescript
159
+ * const gtBridge = new GtBridge({ gtPath: '/usr/local/bin/gt' });
160
+ * await gtBridge.initialize();
161
+ *
162
+ * const estimate = await gtBridge.estimateGas({
163
+ * to: '0x...',
164
+ * data: '0x...',
165
+ * network: 'mainnet',
166
+ * });
167
+ * ```
168
+ */
169
+ declare class GtBridge {
170
+ private config;
171
+ private logger;
172
+ private initialized;
173
+ /** Commands that can be cached (read-only, no side effects) */
174
+ private static readonly CACHEABLE_COMMANDS;
175
+ /** Commands that should use longer cache (static data) */
176
+ private static readonly STATIC_COMMANDS;
177
+ constructor(config?: GtBridgeConfig, logger?: GtLogger);
178
+ /**
179
+ * Initialize the bridge and verify gt is available
180
+ */
181
+ initialize(): Promise<void>;
182
+ /**
183
+ * Execute a gt command with validated arguments
184
+ *
185
+ * @param args - Command arguments (validated and sanitized)
186
+ * @returns Command output
187
+ */
188
+ execGt(args: string[], skipCache?: boolean): Promise<GtResult<string>>;
189
+ /**
190
+ * Parse JSON output from gt command
191
+ *
192
+ * @param output - Raw command output
193
+ * @returns Parsed JSON object
194
+ */
195
+ parseGtOutput<T>(output: string): T;
196
+ /**
197
+ * Estimate gas for a transaction
198
+ */
199
+ estimateGas(params: {
200
+ to: string;
201
+ data?: string;
202
+ value?: string;
203
+ from?: string;
204
+ network?: z.infer<typeof NetworkSchema>;
205
+ }): Promise<GasEstimate>;
206
+ /**
207
+ * Get transaction status
208
+ */
209
+ getTxStatus(txHash: string, network?: z.infer<typeof NetworkSchema>): Promise<TxStatus>;
210
+ /**
211
+ * Get network status
212
+ */
213
+ getNetworkStatus(network?: z.infer<typeof NetworkSchema>): Promise<NetworkStatus>;
214
+ /**
215
+ * Get current gas price
216
+ */
217
+ getGasPrice(network?: z.infer<typeof NetworkSchema>): Promise<{
218
+ gasPrice: string;
219
+ maxFeePerGas?: string;
220
+ maxPriorityFeePerGas?: string;
221
+ baseFee?: string;
222
+ }>;
223
+ /**
224
+ * Simulate a transaction
225
+ */
226
+ simulate(params: {
227
+ to: string;
228
+ data: string;
229
+ value?: string;
230
+ from?: string;
231
+ network?: z.infer<typeof NetworkSchema>;
232
+ blockNumber?: number;
233
+ }): Promise<{
234
+ success: boolean;
235
+ returnData?: string;
236
+ gasUsed?: number;
237
+ logs?: unknown[];
238
+ error?: string;
239
+ }>;
240
+ /**
241
+ * Decode transaction data
242
+ */
243
+ decode(data: string, abi?: string): Promise<{
244
+ method: string;
245
+ args: unknown[];
246
+ signature: string;
247
+ }>;
248
+ /**
249
+ * Validate and sanitize command arguments
250
+ */
251
+ private validateAndSanitizeArgs;
252
+ /**
253
+ * Ensure bridge is initialized
254
+ */
255
+ private ensureInitialized;
256
+ /**
257
+ * Check if bridge is initialized
258
+ */
259
+ isInitialized(): boolean;
260
+ /**
261
+ * Get current configuration
262
+ */
263
+ getConfig(): Readonly<Required<GtBridgeConfig>>;
264
+ /**
265
+ * Get cache statistics for performance monitoring
266
+ */
267
+ getCacheStats(): {
268
+ resultCache: {
269
+ entries: number;
270
+ sizeBytes: number;
271
+ };
272
+ staticCache: {
273
+ entries: number;
274
+ sizeBytes: number;
275
+ };
276
+ parsedCache: {
277
+ entries: number;
278
+ sizeBytes: number;
279
+ };
280
+ };
281
+ /**
282
+ * Clear all caches (useful for testing or memory pressure)
283
+ */
284
+ clearCaches(): void;
285
+ }
286
+ /**
287
+ * Create a new Gas Town bridge instance
288
+ */
289
+ declare function createGtBridge(config?: GtBridgeConfig, logger?: GtLogger): GtBridge;
290
+
291
+ export { AddressSchema as A, GtBridge as G, IdentifierSchema as I, NetworkSchema as N, SafeStringSchema as S, TxHashSchema as T, type GasEstimate as a, GasLimitSchema as b, GasPriceSchema as c, GtArgumentSchema as d, type GtBridgeConfig as e, GtBridgeError as f, type GtErrorCode as g, type GtLogger as h, type GtResult as i, type NetworkStatus as j, type TxStatus as k, createGtBridge as l };