@willjackson/claude-code-bridge 0.1.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/LICENSE +21 -0
- package/README.md +690 -0
- package/dist/chunk-BRH476VK.js +1993 -0
- package/dist/chunk-BRH476VK.js.map +1 -0
- package/dist/cli.d.ts +40 -0
- package/dist/cli.js +844 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +1848 -0
- package/dist/index.js +976 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1848 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import pino from 'pino';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Protocol definitions for Claude Code Bridge
|
|
6
|
+
* Defines message types, schemas, and serialization utilities
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare const MessageType: z.ZodEnum<["request", "response", "context_sync", "task_delegate", "notification"]>;
|
|
10
|
+
type MessageType = z.infer<typeof MessageType>;
|
|
11
|
+
declare const FileChunkSchema: z.ZodObject<{
|
|
12
|
+
path: z.ZodString;
|
|
13
|
+
content: z.ZodString;
|
|
14
|
+
startLine: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
language: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
path: string;
|
|
19
|
+
content: string;
|
|
20
|
+
startLine?: number | undefined;
|
|
21
|
+
endLine?: number | undefined;
|
|
22
|
+
language?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
path: string;
|
|
25
|
+
content: string;
|
|
26
|
+
startLine?: number | undefined;
|
|
27
|
+
endLine?: number | undefined;
|
|
28
|
+
language?: string | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
type FileChunk = z.infer<typeof FileChunkSchema>;
|
|
31
|
+
declare const DirectoryTreeSchema: z.ZodType<DirectoryTree>;
|
|
32
|
+
interface DirectoryTree {
|
|
33
|
+
name: string;
|
|
34
|
+
type: 'file' | 'directory';
|
|
35
|
+
children?: DirectoryTree[];
|
|
36
|
+
}
|
|
37
|
+
declare const ArtifactSchema: z.ZodObject<{
|
|
38
|
+
path: z.ZodString;
|
|
39
|
+
action: z.ZodEnum<["created", "modified", "deleted"]>;
|
|
40
|
+
diff: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
path: string;
|
|
43
|
+
action: "created" | "modified" | "deleted";
|
|
44
|
+
diff?: string | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
path: string;
|
|
47
|
+
action: "created" | "modified" | "deleted";
|
|
48
|
+
diff?: string | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
type Artifact = z.infer<typeof ArtifactSchema>;
|
|
51
|
+
declare const ContextSchema: z.ZodObject<{
|
|
52
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
53
|
+
path: z.ZodString;
|
|
54
|
+
content: z.ZodString;
|
|
55
|
+
startLine: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
language: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
path: string;
|
|
60
|
+
content: string;
|
|
61
|
+
startLine?: number | undefined;
|
|
62
|
+
endLine?: number | undefined;
|
|
63
|
+
language?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
path: string;
|
|
66
|
+
content: string;
|
|
67
|
+
startLine?: number | undefined;
|
|
68
|
+
endLine?: number | undefined;
|
|
69
|
+
language?: string | undefined;
|
|
70
|
+
}>, "many">>;
|
|
71
|
+
tree: z.ZodOptional<z.ZodType<DirectoryTree, z.ZodTypeDef, DirectoryTree>>;
|
|
72
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
73
|
+
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
files?: {
|
|
76
|
+
path: string;
|
|
77
|
+
content: string;
|
|
78
|
+
startLine?: number | undefined;
|
|
79
|
+
endLine?: number | undefined;
|
|
80
|
+
language?: string | undefined;
|
|
81
|
+
}[] | undefined;
|
|
82
|
+
tree?: DirectoryTree | undefined;
|
|
83
|
+
summary?: string | undefined;
|
|
84
|
+
variables?: Record<string, any> | undefined;
|
|
85
|
+
}, {
|
|
86
|
+
files?: {
|
|
87
|
+
path: string;
|
|
88
|
+
content: string;
|
|
89
|
+
startLine?: number | undefined;
|
|
90
|
+
endLine?: number | undefined;
|
|
91
|
+
language?: string | undefined;
|
|
92
|
+
}[] | undefined;
|
|
93
|
+
tree?: DirectoryTree | undefined;
|
|
94
|
+
summary?: string | undefined;
|
|
95
|
+
variables?: Record<string, any> | undefined;
|
|
96
|
+
}>;
|
|
97
|
+
type Context = z.infer<typeof ContextSchema>;
|
|
98
|
+
declare const TaskRequestSchema: z.ZodObject<{
|
|
99
|
+
id: z.ZodString;
|
|
100
|
+
description: z.ZodString;
|
|
101
|
+
scope: z.ZodEnum<["execute", "analyze", "suggest"]>;
|
|
102
|
+
constraints: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
103
|
+
returnFormat: z.ZodOptional<z.ZodEnum<["full", "summary", "diff"]>>;
|
|
104
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
id: string;
|
|
107
|
+
description: string;
|
|
108
|
+
scope: "execute" | "analyze" | "suggest";
|
|
109
|
+
constraints?: string[] | undefined;
|
|
110
|
+
returnFormat?: "diff" | "summary" | "full" | undefined;
|
|
111
|
+
timeout?: number | undefined;
|
|
112
|
+
}, {
|
|
113
|
+
id: string;
|
|
114
|
+
description: string;
|
|
115
|
+
scope: "execute" | "analyze" | "suggest";
|
|
116
|
+
constraints?: string[] | undefined;
|
|
117
|
+
returnFormat?: "diff" | "summary" | "full" | undefined;
|
|
118
|
+
timeout?: number | undefined;
|
|
119
|
+
}>;
|
|
120
|
+
type TaskRequest = z.infer<typeof TaskRequestSchema>;
|
|
121
|
+
declare const TaskResultSchema: z.ZodObject<{
|
|
122
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
123
|
+
success: z.ZodBoolean;
|
|
124
|
+
data: z.ZodAny;
|
|
125
|
+
artifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
126
|
+
path: z.ZodString;
|
|
127
|
+
action: z.ZodEnum<["created", "modified", "deleted"]>;
|
|
128
|
+
diff: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
path: string;
|
|
131
|
+
action: "created" | "modified" | "deleted";
|
|
132
|
+
diff?: string | undefined;
|
|
133
|
+
}, {
|
|
134
|
+
path: string;
|
|
135
|
+
action: "created" | "modified" | "deleted";
|
|
136
|
+
diff?: string | undefined;
|
|
137
|
+
}>, "many">>;
|
|
138
|
+
followUp: z.ZodOptional<z.ZodString>;
|
|
139
|
+
error: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, "strip", z.ZodTypeAny, {
|
|
141
|
+
success: boolean;
|
|
142
|
+
error?: string | undefined;
|
|
143
|
+
taskId?: string | undefined;
|
|
144
|
+
data?: any;
|
|
145
|
+
artifacts?: {
|
|
146
|
+
path: string;
|
|
147
|
+
action: "created" | "modified" | "deleted";
|
|
148
|
+
diff?: string | undefined;
|
|
149
|
+
}[] | undefined;
|
|
150
|
+
followUp?: string | undefined;
|
|
151
|
+
}, {
|
|
152
|
+
success: boolean;
|
|
153
|
+
error?: string | undefined;
|
|
154
|
+
taskId?: string | undefined;
|
|
155
|
+
data?: any;
|
|
156
|
+
artifacts?: {
|
|
157
|
+
path: string;
|
|
158
|
+
action: "created" | "modified" | "deleted";
|
|
159
|
+
diff?: string | undefined;
|
|
160
|
+
}[] | undefined;
|
|
161
|
+
followUp?: string | undefined;
|
|
162
|
+
}>;
|
|
163
|
+
type TaskResult = z.infer<typeof TaskResultSchema>;
|
|
164
|
+
declare const BridgeMessageSchema: z.ZodObject<{
|
|
165
|
+
id: z.ZodString;
|
|
166
|
+
type: z.ZodEnum<["request", "response", "context_sync", "task_delegate", "notification"]>;
|
|
167
|
+
source: z.ZodString;
|
|
168
|
+
timestamp: z.ZodNumber;
|
|
169
|
+
context: z.ZodOptional<z.ZodObject<{
|
|
170
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
171
|
+
path: z.ZodString;
|
|
172
|
+
content: z.ZodString;
|
|
173
|
+
startLine: z.ZodOptional<z.ZodNumber>;
|
|
174
|
+
endLine: z.ZodOptional<z.ZodNumber>;
|
|
175
|
+
language: z.ZodOptional<z.ZodString>;
|
|
176
|
+
}, "strip", z.ZodTypeAny, {
|
|
177
|
+
path: string;
|
|
178
|
+
content: string;
|
|
179
|
+
startLine?: number | undefined;
|
|
180
|
+
endLine?: number | undefined;
|
|
181
|
+
language?: string | undefined;
|
|
182
|
+
}, {
|
|
183
|
+
path: string;
|
|
184
|
+
content: string;
|
|
185
|
+
startLine?: number | undefined;
|
|
186
|
+
endLine?: number | undefined;
|
|
187
|
+
language?: string | undefined;
|
|
188
|
+
}>, "many">>;
|
|
189
|
+
tree: z.ZodOptional<z.ZodType<DirectoryTree, z.ZodTypeDef, DirectoryTree>>;
|
|
190
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
191
|
+
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
192
|
+
}, "strip", z.ZodTypeAny, {
|
|
193
|
+
files?: {
|
|
194
|
+
path: string;
|
|
195
|
+
content: string;
|
|
196
|
+
startLine?: number | undefined;
|
|
197
|
+
endLine?: number | undefined;
|
|
198
|
+
language?: string | undefined;
|
|
199
|
+
}[] | undefined;
|
|
200
|
+
tree?: DirectoryTree | undefined;
|
|
201
|
+
summary?: string | undefined;
|
|
202
|
+
variables?: Record<string, any> | undefined;
|
|
203
|
+
}, {
|
|
204
|
+
files?: {
|
|
205
|
+
path: string;
|
|
206
|
+
content: string;
|
|
207
|
+
startLine?: number | undefined;
|
|
208
|
+
endLine?: number | undefined;
|
|
209
|
+
language?: string | undefined;
|
|
210
|
+
}[] | undefined;
|
|
211
|
+
tree?: DirectoryTree | undefined;
|
|
212
|
+
summary?: string | undefined;
|
|
213
|
+
variables?: Record<string, any> | undefined;
|
|
214
|
+
}>>;
|
|
215
|
+
task: z.ZodOptional<z.ZodObject<{
|
|
216
|
+
id: z.ZodString;
|
|
217
|
+
description: z.ZodString;
|
|
218
|
+
scope: z.ZodEnum<["execute", "analyze", "suggest"]>;
|
|
219
|
+
constraints: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
220
|
+
returnFormat: z.ZodOptional<z.ZodEnum<["full", "summary", "diff"]>>;
|
|
221
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
222
|
+
}, "strip", z.ZodTypeAny, {
|
|
223
|
+
id: string;
|
|
224
|
+
description: string;
|
|
225
|
+
scope: "execute" | "analyze" | "suggest";
|
|
226
|
+
constraints?: string[] | undefined;
|
|
227
|
+
returnFormat?: "diff" | "summary" | "full" | undefined;
|
|
228
|
+
timeout?: number | undefined;
|
|
229
|
+
}, {
|
|
230
|
+
id: string;
|
|
231
|
+
description: string;
|
|
232
|
+
scope: "execute" | "analyze" | "suggest";
|
|
233
|
+
constraints?: string[] | undefined;
|
|
234
|
+
returnFormat?: "diff" | "summary" | "full" | undefined;
|
|
235
|
+
timeout?: number | undefined;
|
|
236
|
+
}>>;
|
|
237
|
+
result: z.ZodOptional<z.ZodObject<{
|
|
238
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
239
|
+
success: z.ZodBoolean;
|
|
240
|
+
data: z.ZodAny;
|
|
241
|
+
artifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
242
|
+
path: z.ZodString;
|
|
243
|
+
action: z.ZodEnum<["created", "modified", "deleted"]>;
|
|
244
|
+
diff: z.ZodOptional<z.ZodString>;
|
|
245
|
+
}, "strip", z.ZodTypeAny, {
|
|
246
|
+
path: string;
|
|
247
|
+
action: "created" | "modified" | "deleted";
|
|
248
|
+
diff?: string | undefined;
|
|
249
|
+
}, {
|
|
250
|
+
path: string;
|
|
251
|
+
action: "created" | "modified" | "deleted";
|
|
252
|
+
diff?: string | undefined;
|
|
253
|
+
}>, "many">>;
|
|
254
|
+
followUp: z.ZodOptional<z.ZodString>;
|
|
255
|
+
error: z.ZodOptional<z.ZodString>;
|
|
256
|
+
}, "strip", z.ZodTypeAny, {
|
|
257
|
+
success: boolean;
|
|
258
|
+
error?: string | undefined;
|
|
259
|
+
taskId?: string | undefined;
|
|
260
|
+
data?: any;
|
|
261
|
+
artifacts?: {
|
|
262
|
+
path: string;
|
|
263
|
+
action: "created" | "modified" | "deleted";
|
|
264
|
+
diff?: string | undefined;
|
|
265
|
+
}[] | undefined;
|
|
266
|
+
followUp?: string | undefined;
|
|
267
|
+
}, {
|
|
268
|
+
success: boolean;
|
|
269
|
+
error?: string | undefined;
|
|
270
|
+
taskId?: string | undefined;
|
|
271
|
+
data?: any;
|
|
272
|
+
artifacts?: {
|
|
273
|
+
path: string;
|
|
274
|
+
action: "created" | "modified" | "deleted";
|
|
275
|
+
diff?: string | undefined;
|
|
276
|
+
}[] | undefined;
|
|
277
|
+
followUp?: string | undefined;
|
|
278
|
+
}>>;
|
|
279
|
+
}, "strip", z.ZodTypeAny, {
|
|
280
|
+
type: "request" | "response" | "context_sync" | "task_delegate" | "notification";
|
|
281
|
+
id: string;
|
|
282
|
+
source: string;
|
|
283
|
+
timestamp: number;
|
|
284
|
+
context?: {
|
|
285
|
+
files?: {
|
|
286
|
+
path: string;
|
|
287
|
+
content: string;
|
|
288
|
+
startLine?: number | undefined;
|
|
289
|
+
endLine?: number | undefined;
|
|
290
|
+
language?: string | undefined;
|
|
291
|
+
}[] | undefined;
|
|
292
|
+
tree?: DirectoryTree | undefined;
|
|
293
|
+
summary?: string | undefined;
|
|
294
|
+
variables?: Record<string, any> | undefined;
|
|
295
|
+
} | undefined;
|
|
296
|
+
task?: {
|
|
297
|
+
id: string;
|
|
298
|
+
description: string;
|
|
299
|
+
scope: "execute" | "analyze" | "suggest";
|
|
300
|
+
constraints?: string[] | undefined;
|
|
301
|
+
returnFormat?: "diff" | "summary" | "full" | undefined;
|
|
302
|
+
timeout?: number | undefined;
|
|
303
|
+
} | undefined;
|
|
304
|
+
result?: {
|
|
305
|
+
success: boolean;
|
|
306
|
+
error?: string | undefined;
|
|
307
|
+
taskId?: string | undefined;
|
|
308
|
+
data?: any;
|
|
309
|
+
artifacts?: {
|
|
310
|
+
path: string;
|
|
311
|
+
action: "created" | "modified" | "deleted";
|
|
312
|
+
diff?: string | undefined;
|
|
313
|
+
}[] | undefined;
|
|
314
|
+
followUp?: string | undefined;
|
|
315
|
+
} | undefined;
|
|
316
|
+
}, {
|
|
317
|
+
type: "request" | "response" | "context_sync" | "task_delegate" | "notification";
|
|
318
|
+
id: string;
|
|
319
|
+
source: string;
|
|
320
|
+
timestamp: number;
|
|
321
|
+
context?: {
|
|
322
|
+
files?: {
|
|
323
|
+
path: string;
|
|
324
|
+
content: string;
|
|
325
|
+
startLine?: number | undefined;
|
|
326
|
+
endLine?: number | undefined;
|
|
327
|
+
language?: string | undefined;
|
|
328
|
+
}[] | undefined;
|
|
329
|
+
tree?: DirectoryTree | undefined;
|
|
330
|
+
summary?: string | undefined;
|
|
331
|
+
variables?: Record<string, any> | undefined;
|
|
332
|
+
} | undefined;
|
|
333
|
+
task?: {
|
|
334
|
+
id: string;
|
|
335
|
+
description: string;
|
|
336
|
+
scope: "execute" | "analyze" | "suggest";
|
|
337
|
+
constraints?: string[] | undefined;
|
|
338
|
+
returnFormat?: "diff" | "summary" | "full" | undefined;
|
|
339
|
+
timeout?: number | undefined;
|
|
340
|
+
} | undefined;
|
|
341
|
+
result?: {
|
|
342
|
+
success: boolean;
|
|
343
|
+
error?: string | undefined;
|
|
344
|
+
taskId?: string | undefined;
|
|
345
|
+
data?: any;
|
|
346
|
+
artifacts?: {
|
|
347
|
+
path: string;
|
|
348
|
+
action: "created" | "modified" | "deleted";
|
|
349
|
+
diff?: string | undefined;
|
|
350
|
+
}[] | undefined;
|
|
351
|
+
followUp?: string | undefined;
|
|
352
|
+
} | undefined;
|
|
353
|
+
}>;
|
|
354
|
+
type BridgeMessage = z.infer<typeof BridgeMessageSchema>;
|
|
355
|
+
/**
|
|
356
|
+
* Creates a base message with auto-generated UUID and timestamp
|
|
357
|
+
* @param type The message type
|
|
358
|
+
* @param source The source instance identifier
|
|
359
|
+
* @returns A partial BridgeMessage with id, type, source, and timestamp
|
|
360
|
+
*/
|
|
361
|
+
declare function createMessage(type: MessageType, source: string): BridgeMessage;
|
|
362
|
+
/**
|
|
363
|
+
* Validates a message against the BridgeMessage schema
|
|
364
|
+
* @param data The data to validate
|
|
365
|
+
* @returns The validated BridgeMessage or throws if invalid
|
|
366
|
+
*/
|
|
367
|
+
declare function validateMessage(data: unknown): BridgeMessage;
|
|
368
|
+
/**
|
|
369
|
+
* Safe validation that returns a result object instead of throwing
|
|
370
|
+
* @param data The data to validate
|
|
371
|
+
* @returns A Zod SafeParseReturnType with success/error information
|
|
372
|
+
*/
|
|
373
|
+
declare function safeValidateMessage(data: unknown): z.SafeParseReturnType<{
|
|
374
|
+
type: "request" | "response" | "context_sync" | "task_delegate" | "notification";
|
|
375
|
+
id: string;
|
|
376
|
+
source: string;
|
|
377
|
+
timestamp: number;
|
|
378
|
+
context?: {
|
|
379
|
+
files?: {
|
|
380
|
+
path: string;
|
|
381
|
+
content: string;
|
|
382
|
+
startLine?: number | undefined;
|
|
383
|
+
endLine?: number | undefined;
|
|
384
|
+
language?: string | undefined;
|
|
385
|
+
}[] | undefined;
|
|
386
|
+
tree?: DirectoryTree | undefined;
|
|
387
|
+
summary?: string | undefined;
|
|
388
|
+
variables?: Record<string, any> | undefined;
|
|
389
|
+
} | undefined;
|
|
390
|
+
task?: {
|
|
391
|
+
id: string;
|
|
392
|
+
description: string;
|
|
393
|
+
scope: "execute" | "analyze" | "suggest";
|
|
394
|
+
constraints?: string[] | undefined;
|
|
395
|
+
returnFormat?: "diff" | "summary" | "full" | undefined;
|
|
396
|
+
timeout?: number | undefined;
|
|
397
|
+
} | undefined;
|
|
398
|
+
result?: {
|
|
399
|
+
success: boolean;
|
|
400
|
+
error?: string | undefined;
|
|
401
|
+
taskId?: string | undefined;
|
|
402
|
+
data?: any;
|
|
403
|
+
artifacts?: {
|
|
404
|
+
path: string;
|
|
405
|
+
action: "created" | "modified" | "deleted";
|
|
406
|
+
diff?: string | undefined;
|
|
407
|
+
}[] | undefined;
|
|
408
|
+
followUp?: string | undefined;
|
|
409
|
+
} | undefined;
|
|
410
|
+
}, {
|
|
411
|
+
type: "request" | "response" | "context_sync" | "task_delegate" | "notification";
|
|
412
|
+
id: string;
|
|
413
|
+
source: string;
|
|
414
|
+
timestamp: number;
|
|
415
|
+
context?: {
|
|
416
|
+
files?: {
|
|
417
|
+
path: string;
|
|
418
|
+
content: string;
|
|
419
|
+
startLine?: number | undefined;
|
|
420
|
+
endLine?: number | undefined;
|
|
421
|
+
language?: string | undefined;
|
|
422
|
+
}[] | undefined;
|
|
423
|
+
tree?: DirectoryTree | undefined;
|
|
424
|
+
summary?: string | undefined;
|
|
425
|
+
variables?: Record<string, any> | undefined;
|
|
426
|
+
} | undefined;
|
|
427
|
+
task?: {
|
|
428
|
+
id: string;
|
|
429
|
+
description: string;
|
|
430
|
+
scope: "execute" | "analyze" | "suggest";
|
|
431
|
+
constraints?: string[] | undefined;
|
|
432
|
+
returnFormat?: "diff" | "summary" | "full" | undefined;
|
|
433
|
+
timeout?: number | undefined;
|
|
434
|
+
} | undefined;
|
|
435
|
+
result?: {
|
|
436
|
+
success: boolean;
|
|
437
|
+
error?: string | undefined;
|
|
438
|
+
taskId?: string | undefined;
|
|
439
|
+
data?: any;
|
|
440
|
+
artifacts?: {
|
|
441
|
+
path: string;
|
|
442
|
+
action: "created" | "modified" | "deleted";
|
|
443
|
+
diff?: string | undefined;
|
|
444
|
+
}[] | undefined;
|
|
445
|
+
followUp?: string | undefined;
|
|
446
|
+
} | undefined;
|
|
447
|
+
}>;
|
|
448
|
+
/**
|
|
449
|
+
* Serializes a BridgeMessage to JSON string
|
|
450
|
+
* @param message The message to serialize
|
|
451
|
+
* @returns JSON string representation
|
|
452
|
+
*/
|
|
453
|
+
declare function serializeMessage(message: BridgeMessage): string;
|
|
454
|
+
/**
|
|
455
|
+
* Deserializes a JSON string to a validated BridgeMessage
|
|
456
|
+
* @param json The JSON string to deserialize
|
|
457
|
+
* @returns The validated BridgeMessage
|
|
458
|
+
* @throws Error if JSON is invalid or message doesn't match schema
|
|
459
|
+
*/
|
|
460
|
+
declare function deserializeMessage(json: string): BridgeMessage;
|
|
461
|
+
/**
|
|
462
|
+
* Safe deserialization that returns a result object instead of throwing
|
|
463
|
+
* @param json The JSON string to deserialize
|
|
464
|
+
* @returns A Zod SafeParseReturnType with success/error information
|
|
465
|
+
*/
|
|
466
|
+
declare function safeDeserializeMessage(json: string): z.SafeParseSuccess<{
|
|
467
|
+
type: "request" | "response" | "context_sync" | "task_delegate" | "notification";
|
|
468
|
+
id: string;
|
|
469
|
+
source: string;
|
|
470
|
+
timestamp: number;
|
|
471
|
+
context?: {
|
|
472
|
+
files?: {
|
|
473
|
+
path: string;
|
|
474
|
+
content: string;
|
|
475
|
+
startLine?: number | undefined;
|
|
476
|
+
endLine?: number | undefined;
|
|
477
|
+
language?: string | undefined;
|
|
478
|
+
}[] | undefined;
|
|
479
|
+
tree?: DirectoryTree | undefined;
|
|
480
|
+
summary?: string | undefined;
|
|
481
|
+
variables?: Record<string, any> | undefined;
|
|
482
|
+
} | undefined;
|
|
483
|
+
task?: {
|
|
484
|
+
id: string;
|
|
485
|
+
description: string;
|
|
486
|
+
scope: "execute" | "analyze" | "suggest";
|
|
487
|
+
constraints?: string[] | undefined;
|
|
488
|
+
returnFormat?: "diff" | "summary" | "full" | undefined;
|
|
489
|
+
timeout?: number | undefined;
|
|
490
|
+
} | undefined;
|
|
491
|
+
result?: {
|
|
492
|
+
success: boolean;
|
|
493
|
+
error?: string | undefined;
|
|
494
|
+
taskId?: string | undefined;
|
|
495
|
+
data?: any;
|
|
496
|
+
artifacts?: {
|
|
497
|
+
path: string;
|
|
498
|
+
action: "created" | "modified" | "deleted";
|
|
499
|
+
diff?: string | undefined;
|
|
500
|
+
}[] | undefined;
|
|
501
|
+
followUp?: string | undefined;
|
|
502
|
+
} | undefined;
|
|
503
|
+
}> | {
|
|
504
|
+
success: false;
|
|
505
|
+
error: z.ZodError<any>;
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Bridge Core - Main orchestration class for Claude Code Bridge
|
|
510
|
+
* Handles peer connections, message routing, and lifecycle management
|
|
511
|
+
*/
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Bridge operation mode
|
|
515
|
+
* - 'host': Listen for incoming connections only
|
|
516
|
+
* - 'client': Connect to a remote bridge only
|
|
517
|
+
* - 'peer': Both listen and connect (bidirectional)
|
|
518
|
+
*/
|
|
519
|
+
type BridgeMode = 'host' | 'client' | 'peer';
|
|
520
|
+
/**
|
|
521
|
+
* Configuration for the bridge's listening server
|
|
522
|
+
*/
|
|
523
|
+
interface BridgeListenConfig {
|
|
524
|
+
/** Port to listen on */
|
|
525
|
+
port: number;
|
|
526
|
+
/** Host to bind to (default: 0.0.0.0) */
|
|
527
|
+
host?: string;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Configuration for connecting to a remote bridge
|
|
531
|
+
*/
|
|
532
|
+
interface BridgeConnectConfig {
|
|
533
|
+
/** Full WebSocket URL (e.g., ws://localhost:8765) */
|
|
534
|
+
url?: string;
|
|
535
|
+
/** Use host.docker.internal for container-to-host connection */
|
|
536
|
+
hostGateway?: boolean;
|
|
537
|
+
/** Port to connect to (used if url is not provided) */
|
|
538
|
+
port?: number;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Context sharing configuration
|
|
542
|
+
*/
|
|
543
|
+
interface ContextSharingConfig$1 {
|
|
544
|
+
/** Enable automatic context synchronization */
|
|
545
|
+
autoSync?: boolean;
|
|
546
|
+
/** Interval in milliseconds for auto-sync (default: 5000) */
|
|
547
|
+
syncInterval?: number;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Full configuration for Bridge initialization
|
|
551
|
+
*/
|
|
552
|
+
interface BridgeConfig$1 {
|
|
553
|
+
/** Operation mode: 'host', 'client', or 'peer' */
|
|
554
|
+
mode: BridgeMode;
|
|
555
|
+
/** Unique identifier for this bridge instance */
|
|
556
|
+
instanceName: string;
|
|
557
|
+
/** Server configuration (required for 'host' and 'peer' modes) */
|
|
558
|
+
listen?: BridgeListenConfig;
|
|
559
|
+
/** Connection configuration (required for 'client' and 'peer' modes) */
|
|
560
|
+
connect?: BridgeConnectConfig;
|
|
561
|
+
/** Task timeout in milliseconds (default: 300000 / 5 minutes) */
|
|
562
|
+
taskTimeout?: number;
|
|
563
|
+
/** Context sharing configuration */
|
|
564
|
+
contextSharing?: ContextSharingConfig$1;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Information about a connected peer
|
|
568
|
+
*/
|
|
569
|
+
interface PeerInfo {
|
|
570
|
+
/** Unique identifier for the peer connection */
|
|
571
|
+
id: string;
|
|
572
|
+
/** Name of the peer instance */
|
|
573
|
+
name: string;
|
|
574
|
+
/** Environment type of the peer */
|
|
575
|
+
environment?: string;
|
|
576
|
+
/** Timestamp when the peer connected */
|
|
577
|
+
connectedAt: number;
|
|
578
|
+
/** Timestamp of last activity from the peer */
|
|
579
|
+
lastActivity: number;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Handler for peer connection events
|
|
583
|
+
*/
|
|
584
|
+
type PeerConnectedHandler = (peer: PeerInfo) => void;
|
|
585
|
+
/**
|
|
586
|
+
* Handler for peer disconnection events
|
|
587
|
+
*/
|
|
588
|
+
type PeerDisconnectedHandler = (peer: PeerInfo) => void;
|
|
589
|
+
/**
|
|
590
|
+
* Handler for incoming messages from peers
|
|
591
|
+
*/
|
|
592
|
+
type MessageReceivedHandler = (message: BridgeMessage, peerId: string) => void;
|
|
593
|
+
/**
|
|
594
|
+
* Handler for incoming task delegation requests
|
|
595
|
+
* Returns a TaskResult or Promise<TaskResult>
|
|
596
|
+
*/
|
|
597
|
+
type TaskReceivedHandler = (task: TaskRequest, peerId: string) => TaskResult | Promise<TaskResult>;
|
|
598
|
+
/**
|
|
599
|
+
* Handler for incoming context synchronization
|
|
600
|
+
*/
|
|
601
|
+
type ContextReceivedHandler = (context: Context, peerId: string) => void;
|
|
602
|
+
/**
|
|
603
|
+
* Handler for incoming context requests
|
|
604
|
+
* Returns FileChunk[] or Promise<FileChunk[]>
|
|
605
|
+
*/
|
|
606
|
+
type ContextRequestedHandler = (query: string, peerId: string) => FileChunk[] | Promise<FileChunk[]>;
|
|
607
|
+
/**
|
|
608
|
+
* Main Bridge class for managing peer-to-peer communication
|
|
609
|
+
* Supports three modes of operation:
|
|
610
|
+
* - 'host': Acts as a server, accepting incoming connections
|
|
611
|
+
* - 'client': Acts as a client, connecting to a remote server
|
|
612
|
+
* - 'peer': Both listens for connections and connects to a remote peer
|
|
613
|
+
*/
|
|
614
|
+
declare class Bridge {
|
|
615
|
+
private config;
|
|
616
|
+
private server;
|
|
617
|
+
private clientTransport;
|
|
618
|
+
private peers;
|
|
619
|
+
private started;
|
|
620
|
+
private peerConnectedHandlers;
|
|
621
|
+
private peerDisconnectedHandlers;
|
|
622
|
+
private messageReceivedHandlers;
|
|
623
|
+
private taskReceivedHandler;
|
|
624
|
+
private contextReceivedHandlers;
|
|
625
|
+
private contextRequestedHandler;
|
|
626
|
+
private pendingTasks;
|
|
627
|
+
private pendingContextRequests;
|
|
628
|
+
private autoSyncIntervalId;
|
|
629
|
+
/**
|
|
630
|
+
* Create a new Bridge instance
|
|
631
|
+
* @param config Bridge configuration
|
|
632
|
+
*/
|
|
633
|
+
constructor(config: BridgeConfig$1);
|
|
634
|
+
/**
|
|
635
|
+
* Validate the configuration based on mode requirements
|
|
636
|
+
*/
|
|
637
|
+
private validateConfig;
|
|
638
|
+
/**
|
|
639
|
+
* Start the bridge based on configured mode
|
|
640
|
+
* - 'host': Starts WebSocket server
|
|
641
|
+
* - 'client': Connects to remote bridge
|
|
642
|
+
* - 'peer': Both starts server and connects to remote
|
|
643
|
+
*/
|
|
644
|
+
start(): Promise<void>;
|
|
645
|
+
/**
|
|
646
|
+
* Stop the bridge and close all connections
|
|
647
|
+
*/
|
|
648
|
+
stop(): Promise<void>;
|
|
649
|
+
/**
|
|
650
|
+
* Get list of connected peers
|
|
651
|
+
*/
|
|
652
|
+
getPeers(): PeerInfo[];
|
|
653
|
+
/**
|
|
654
|
+
* Connect to a remote bridge
|
|
655
|
+
* @param url WebSocket URL to connect to
|
|
656
|
+
*/
|
|
657
|
+
connectToPeer(url: string): Promise<void>;
|
|
658
|
+
/**
|
|
659
|
+
* Disconnect from a specific peer
|
|
660
|
+
* @param peerId ID of the peer to disconnect from
|
|
661
|
+
*/
|
|
662
|
+
disconnectFromPeer(peerId: string): Promise<void>;
|
|
663
|
+
/**
|
|
664
|
+
* Send a message to a specific peer
|
|
665
|
+
* @param peerId ID of the peer to send to
|
|
666
|
+
* @param message Message to send
|
|
667
|
+
*/
|
|
668
|
+
sendToPeer(peerId: string, message: BridgeMessage): Promise<void>;
|
|
669
|
+
/**
|
|
670
|
+
* Broadcast a message to all connected peers
|
|
671
|
+
* @param message Message to broadcast
|
|
672
|
+
*/
|
|
673
|
+
broadcast(message: BridgeMessage): Promise<void>;
|
|
674
|
+
/**
|
|
675
|
+
* Register a handler for peer connection events
|
|
676
|
+
*/
|
|
677
|
+
onPeerConnected(handler: PeerConnectedHandler): void;
|
|
678
|
+
/**
|
|
679
|
+
* Register a handler for peer disconnection events
|
|
680
|
+
*/
|
|
681
|
+
onPeerDisconnected(handler: PeerDisconnectedHandler): void;
|
|
682
|
+
/**
|
|
683
|
+
* Register a handler for incoming messages
|
|
684
|
+
*/
|
|
685
|
+
onMessage(handler: MessageReceivedHandler): void;
|
|
686
|
+
/**
|
|
687
|
+
* Register a handler for incoming task delegation requests
|
|
688
|
+
* Only one handler can be registered at a time
|
|
689
|
+
* @param handler Function that receives a TaskRequest and returns a TaskResult
|
|
690
|
+
*/
|
|
691
|
+
onTaskReceived(handler: TaskReceivedHandler): void;
|
|
692
|
+
/**
|
|
693
|
+
* Register a handler for incoming context synchronization
|
|
694
|
+
* Multiple handlers can be registered
|
|
695
|
+
* @param handler Function that receives context and peerId
|
|
696
|
+
*/
|
|
697
|
+
onContextReceived(handler: ContextReceivedHandler): void;
|
|
698
|
+
/**
|
|
699
|
+
* Register a handler for incoming context requests
|
|
700
|
+
* Only one handler can be registered at a time
|
|
701
|
+
* @param handler Function that receives a query and returns FileChunk[]
|
|
702
|
+
*/
|
|
703
|
+
onContextRequested(handler: ContextRequestedHandler): void;
|
|
704
|
+
/**
|
|
705
|
+
* Delegate a task to a peer and wait for the result
|
|
706
|
+
* @param task The task request to delegate
|
|
707
|
+
* @param peerId Optional peer ID to send to (defaults to first peer)
|
|
708
|
+
* @returns Promise that resolves with the task result
|
|
709
|
+
* @throws Error if no peers are connected or task times out
|
|
710
|
+
*/
|
|
711
|
+
delegateTask(task: TaskRequest, peerId?: string): Promise<TaskResult>;
|
|
712
|
+
/**
|
|
713
|
+
* Synchronize context with connected peers
|
|
714
|
+
* @param context Optional context to sync. If not provided, broadcasts to all peers
|
|
715
|
+
* @param peerId Optional peer ID to send to (defaults to all peers)
|
|
716
|
+
*/
|
|
717
|
+
syncContext(context?: Context, peerId?: string): Promise<void>;
|
|
718
|
+
/**
|
|
719
|
+
* Request context from a peer based on a query
|
|
720
|
+
* @param query Description of what context is being requested
|
|
721
|
+
* @param peerId Optional peer ID to request from (defaults to first peer)
|
|
722
|
+
* @param timeout Optional timeout in milliseconds (default: 30000)
|
|
723
|
+
* @returns Promise that resolves with FileChunk[] from the peer
|
|
724
|
+
* @throws Error if no peers are connected or request times out
|
|
725
|
+
*/
|
|
726
|
+
requestContext(query: string, peerId?: string, timeout?: number): Promise<FileChunk[]>;
|
|
727
|
+
/**
|
|
728
|
+
* Start automatic context synchronization
|
|
729
|
+
* Uses interval from config.contextSharing.syncInterval (default: 5000ms)
|
|
730
|
+
* @param contextProvider Optional function that returns context to sync
|
|
731
|
+
*/
|
|
732
|
+
startAutoSync(contextProvider?: () => Context | Promise<Context>): void;
|
|
733
|
+
/**
|
|
734
|
+
* Stop automatic context synchronization
|
|
735
|
+
*/
|
|
736
|
+
stopAutoSync(): void;
|
|
737
|
+
/**
|
|
738
|
+
* Start the WebSocket server
|
|
739
|
+
*/
|
|
740
|
+
private startServer;
|
|
741
|
+
/**
|
|
742
|
+
* Handle a new incoming connection
|
|
743
|
+
*/
|
|
744
|
+
private handleNewConnection;
|
|
745
|
+
/**
|
|
746
|
+
* Connect to a remote bridge as a client
|
|
747
|
+
*/
|
|
748
|
+
private connectToRemote;
|
|
749
|
+
/**
|
|
750
|
+
* Handle client transport disconnect
|
|
751
|
+
*/
|
|
752
|
+
private handleClientDisconnect;
|
|
753
|
+
/**
|
|
754
|
+
* Handle an incoming message
|
|
755
|
+
*/
|
|
756
|
+
private handleMessage;
|
|
757
|
+
/**
|
|
758
|
+
* Handle incoming task delegation request
|
|
759
|
+
*/
|
|
760
|
+
private handleTaskDelegate;
|
|
761
|
+
/**
|
|
762
|
+
* Handle task response message (correlate with pending task)
|
|
763
|
+
*/
|
|
764
|
+
private handleTaskResponse;
|
|
765
|
+
/**
|
|
766
|
+
* Handle incoming context sync message
|
|
767
|
+
*/
|
|
768
|
+
private handleContextSync;
|
|
769
|
+
/**
|
|
770
|
+
* Handle incoming context request message
|
|
771
|
+
*/
|
|
772
|
+
private handleContextRequest;
|
|
773
|
+
/**
|
|
774
|
+
* Handle context response message (correlate with pending context request)
|
|
775
|
+
*/
|
|
776
|
+
private handleContextResponse;
|
|
777
|
+
private notifyPeerConnected;
|
|
778
|
+
private notifyPeerDisconnected;
|
|
779
|
+
private notifyMessageReceived;
|
|
780
|
+
private notifyContextReceived;
|
|
781
|
+
/**
|
|
782
|
+
* Clean up all resources
|
|
783
|
+
*/
|
|
784
|
+
private cleanup;
|
|
785
|
+
/**
|
|
786
|
+
* Check if the bridge is started
|
|
787
|
+
*/
|
|
788
|
+
isStarted(): boolean;
|
|
789
|
+
/**
|
|
790
|
+
* Get the instance name
|
|
791
|
+
*/
|
|
792
|
+
getInstanceName(): string;
|
|
793
|
+
/**
|
|
794
|
+
* Get the operation mode
|
|
795
|
+
*/
|
|
796
|
+
getMode(): BridgeMode;
|
|
797
|
+
/**
|
|
798
|
+
* Get the number of connected peers
|
|
799
|
+
*/
|
|
800
|
+
getPeerCount(): number;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Message builder factory functions for Claude Code Bridge
|
|
805
|
+
* Provides convenient functions to create specific message types
|
|
806
|
+
*/
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* Notification data structure for notification messages
|
|
810
|
+
*/
|
|
811
|
+
interface NotificationData {
|
|
812
|
+
type: string;
|
|
813
|
+
message: string;
|
|
814
|
+
data?: Record<string, unknown>;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* Creates a context synchronization message
|
|
818
|
+
* Used to share context (files, tree, summary) with a peer
|
|
819
|
+
* @param source The source instance identifier
|
|
820
|
+
* @param context The context to synchronize
|
|
821
|
+
* @returns A BridgeMessage with type 'context_sync'
|
|
822
|
+
*/
|
|
823
|
+
declare function createContextSyncMessage(source: string, context: Context): BridgeMessage;
|
|
824
|
+
/**
|
|
825
|
+
* Creates a task delegation message
|
|
826
|
+
* Used to delegate a task to a peer instance
|
|
827
|
+
* @param source The source instance identifier
|
|
828
|
+
* @param task The task to delegate
|
|
829
|
+
* @returns A BridgeMessage with type 'task_delegate'
|
|
830
|
+
*/
|
|
831
|
+
declare function createTaskDelegateMessage(source: string, task: TaskRequest): BridgeMessage;
|
|
832
|
+
/**
|
|
833
|
+
* Creates a task response message
|
|
834
|
+
* Used to respond to a delegated task
|
|
835
|
+
* @param source The source instance identifier
|
|
836
|
+
* @param taskId The ID of the task being responded to
|
|
837
|
+
* @param result The result of the task execution
|
|
838
|
+
* @returns A BridgeMessage with type 'response'
|
|
839
|
+
*/
|
|
840
|
+
declare function createTaskResponseMessage(source: string, taskId: string, result: Omit<TaskResult, 'taskId'>): BridgeMessage;
|
|
841
|
+
/**
|
|
842
|
+
* Creates a context request message
|
|
843
|
+
* Used to request specific context from a peer
|
|
844
|
+
* @param source The source instance identifier
|
|
845
|
+
* @param query A description of what context is being requested
|
|
846
|
+
* @returns A BridgeMessage with type 'request'
|
|
847
|
+
*/
|
|
848
|
+
declare function createContextRequestMessage(source: string, query: string): BridgeMessage;
|
|
849
|
+
/**
|
|
850
|
+
* Creates a notification message
|
|
851
|
+
* Used to send notifications to peers (events, status updates, etc.)
|
|
852
|
+
* @param source The source instance identifier
|
|
853
|
+
* @param notification The notification data
|
|
854
|
+
* @returns A BridgeMessage with type 'notification'
|
|
855
|
+
*/
|
|
856
|
+
declare function createNotificationMessage(source: string, notification: NotificationData): BridgeMessage;
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Context Manager for Claude Code Bridge
|
|
860
|
+
*
|
|
861
|
+
* Handles project context management including:
|
|
862
|
+
* - Project snapshot generation
|
|
863
|
+
* - Relevant context extraction with token limits
|
|
864
|
+
* - Delta synchronization between snapshots
|
|
865
|
+
*/
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Options for building a directory tree
|
|
869
|
+
*/
|
|
870
|
+
interface BuildDirectoryTreeOptions {
|
|
871
|
+
/** Glob patterns for files to include */
|
|
872
|
+
includePatterns?: string[];
|
|
873
|
+
/** Glob patterns for files to exclude */
|
|
874
|
+
excludePatterns?: string[];
|
|
875
|
+
/** Maximum depth for directory tree building (default: 10) */
|
|
876
|
+
maxDepth?: number;
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Build a directory tree structure starting from a root path
|
|
880
|
+
*
|
|
881
|
+
* This standalone function creates a DirectoryTree representation
|
|
882
|
+
* of the file system, respecting include/exclude patterns and depth limits.
|
|
883
|
+
* Symlinks are handled safely to prevent infinite loops.
|
|
884
|
+
*
|
|
885
|
+
* @param rootPath The root path to start building from
|
|
886
|
+
* @param options Configuration options
|
|
887
|
+
* @returns DirectoryTree representation of the directory structure
|
|
888
|
+
*
|
|
889
|
+
* @example
|
|
890
|
+
* ```typescript
|
|
891
|
+
* const tree = buildDirectoryTree('/path/to/project', {
|
|
892
|
+
* includePatterns: ['src/**\/*.ts'],
|
|
893
|
+
* excludePatterns: ['node_modules/**'],
|
|
894
|
+
* maxDepth: 5
|
|
895
|
+
* });
|
|
896
|
+
* ```
|
|
897
|
+
*/
|
|
898
|
+
declare function buildDirectoryTree(rootPath: string, options?: BuildDirectoryTreeOptions): DirectoryTree;
|
|
899
|
+
/**
|
|
900
|
+
* Configuration options for ContextManager
|
|
901
|
+
*/
|
|
902
|
+
interface ContextManagerOptions {
|
|
903
|
+
/** Root path of the project to manage context for */
|
|
904
|
+
rootPath: string;
|
|
905
|
+
/** Glob patterns for files to include */
|
|
906
|
+
includePatterns: string[];
|
|
907
|
+
/** Glob patterns for files to exclude */
|
|
908
|
+
excludePatterns: string[];
|
|
909
|
+
/** Maximum depth for directory tree building (default: 10) */
|
|
910
|
+
maxDepth?: number;
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* Snapshot of the project state at a point in time
|
|
914
|
+
*/
|
|
915
|
+
interface ProjectSnapshot {
|
|
916
|
+
/** Unique identifier for this snapshot */
|
|
917
|
+
id: string;
|
|
918
|
+
/** Unix timestamp when snapshot was created */
|
|
919
|
+
timestamp: number;
|
|
920
|
+
/** Directory tree structure */
|
|
921
|
+
tree: DirectoryTree;
|
|
922
|
+
/** Summary of the project (file count, languages, etc.) */
|
|
923
|
+
summary: string;
|
|
924
|
+
/** List of key files identified in the project */
|
|
925
|
+
keyFiles: string[];
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Represents a change to a file between snapshots
|
|
929
|
+
*/
|
|
930
|
+
interface FileChange {
|
|
931
|
+
/** Relative path of the file */
|
|
932
|
+
path: string;
|
|
933
|
+
/** Type of change detected */
|
|
934
|
+
action: 'added' | 'modified' | 'deleted';
|
|
935
|
+
/** Diff content for modified files */
|
|
936
|
+
diff?: string;
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Delta between two snapshots
|
|
940
|
+
*/
|
|
941
|
+
interface ContextDelta {
|
|
942
|
+
/** ID of the source snapshot */
|
|
943
|
+
fromSyncId: string;
|
|
944
|
+
/** ID of the target snapshot */
|
|
945
|
+
toSyncId: string;
|
|
946
|
+
/** List of file changes */
|
|
947
|
+
changes: FileChange[];
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* ContextManager handles project context extraction and management
|
|
951
|
+
*/
|
|
952
|
+
declare class ContextManager {
|
|
953
|
+
private readonly rootPath;
|
|
954
|
+
private readonly includePatterns;
|
|
955
|
+
private readonly excludePatterns;
|
|
956
|
+
private readonly maxDepth;
|
|
957
|
+
/** Stored snapshots for delta comparison */
|
|
958
|
+
private readonly snapshotStates;
|
|
959
|
+
/**
|
|
960
|
+
* Create a new ContextManager
|
|
961
|
+
* @param options Configuration options
|
|
962
|
+
*/
|
|
963
|
+
constructor(options: ContextManagerOptions);
|
|
964
|
+
/**
|
|
965
|
+
* Generate a complete snapshot of the current project state
|
|
966
|
+
* @returns ProjectSnapshot with tree structure, summary, and key files
|
|
967
|
+
*/
|
|
968
|
+
generateSnapshot(): Promise<ProjectSnapshot>;
|
|
969
|
+
/**
|
|
970
|
+
* Get changes since the last snapshot
|
|
971
|
+
*
|
|
972
|
+
* Compares the current file system state with a previously stored snapshot
|
|
973
|
+
* to detect added, modified, and deleted files.
|
|
974
|
+
*
|
|
975
|
+
* @param lastSyncId ID of the last snapshot to compare against
|
|
976
|
+
* @returns ContextDelta with changes since the last sync
|
|
977
|
+
* @throws Error if lastSyncId is not found
|
|
978
|
+
*/
|
|
979
|
+
getDelta(lastSyncId: string): Promise<ContextDelta>;
|
|
980
|
+
/**
|
|
981
|
+
* Generate a simple diff for a modified file
|
|
982
|
+
* Returns the new content (simplified diff for now)
|
|
983
|
+
*/
|
|
984
|
+
private generateFileDiff;
|
|
985
|
+
/**
|
|
986
|
+
* Get relevant file chunks based on a task description, respecting token limits
|
|
987
|
+
* @param task Description of the task to get context for
|
|
988
|
+
* @param maxTokens Maximum tokens for the returned context
|
|
989
|
+
* @returns Array of FileChunk objects within the token limit
|
|
990
|
+
*/
|
|
991
|
+
getRelevantContext(task: string, maxTokens: number): Promise<FileChunk[]>;
|
|
992
|
+
/**
|
|
993
|
+
* Collect all files matching include patterns and not matching exclude patterns
|
|
994
|
+
*/
|
|
995
|
+
private collectMatchingFiles;
|
|
996
|
+
private collectFilesRecursive;
|
|
997
|
+
/**
|
|
998
|
+
* Check if a path matches any include pattern
|
|
999
|
+
*/
|
|
1000
|
+
private isIncluded;
|
|
1001
|
+
/**
|
|
1002
|
+
* Check if a path matches any exclude pattern
|
|
1003
|
+
*/
|
|
1004
|
+
private isExcluded;
|
|
1005
|
+
/**
|
|
1006
|
+
* Check if a directory should be traversed based on include patterns
|
|
1007
|
+
*/
|
|
1008
|
+
private shouldIncludeDirectory;
|
|
1009
|
+
/**
|
|
1010
|
+
* Identify key files in the project (config files, entry points, etc.)
|
|
1011
|
+
*/
|
|
1012
|
+
private identifyKeyFiles;
|
|
1013
|
+
/**
|
|
1014
|
+
* Generate a summary string describing the project
|
|
1015
|
+
*/
|
|
1016
|
+
private generateSummary;
|
|
1017
|
+
/**
|
|
1018
|
+
* Rank files by relevance to a task description
|
|
1019
|
+
* Files with matching keywords are ranked higher
|
|
1020
|
+
*/
|
|
1021
|
+
private rankFilesForTask;
|
|
1022
|
+
/**
|
|
1023
|
+
* Get programming language from file extension
|
|
1024
|
+
*/
|
|
1025
|
+
private getLanguage;
|
|
1026
|
+
/**
|
|
1027
|
+
* Truncate file content to fit within a token limit
|
|
1028
|
+
*/
|
|
1029
|
+
private truncateContent;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Transport layer interface and types for Claude Code Bridge
|
|
1034
|
+
* Defines the abstract transport interface for communication between bridge instances
|
|
1035
|
+
*/
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Represents the current state of a transport connection
|
|
1039
|
+
*/
|
|
1040
|
+
declare enum ConnectionState {
|
|
1041
|
+
/** Not connected to any peer */
|
|
1042
|
+
DISCONNECTED = "DISCONNECTED",
|
|
1043
|
+
/** Currently attempting to establish connection */
|
|
1044
|
+
CONNECTING = "CONNECTING",
|
|
1045
|
+
/** Successfully connected and ready for communication */
|
|
1046
|
+
CONNECTED = "CONNECTED",
|
|
1047
|
+
/** Connection lost, attempting to reconnect */
|
|
1048
|
+
RECONNECTING = "RECONNECTING"
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Authentication configuration for transport connections
|
|
1052
|
+
*/
|
|
1053
|
+
interface AuthConfig {
|
|
1054
|
+
/** Authentication type */
|
|
1055
|
+
type: 'token' | 'none';
|
|
1056
|
+
/** Authentication token (required if type is 'token') */
|
|
1057
|
+
token?: string;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Configuration for establishing a transport connection
|
|
1061
|
+
*/
|
|
1062
|
+
interface ConnectionConfig {
|
|
1063
|
+
/** Full WebSocket URL (e.g., ws://localhost:8765) */
|
|
1064
|
+
url?: string;
|
|
1065
|
+
/** Host to connect to (used if url is not provided) */
|
|
1066
|
+
host?: string;
|
|
1067
|
+
/** Port to connect to (used if url is not provided) */
|
|
1068
|
+
port?: number;
|
|
1069
|
+
/** Enable automatic reconnection on disconnect */
|
|
1070
|
+
reconnect?: boolean;
|
|
1071
|
+
/** Interval between reconnection attempts in milliseconds */
|
|
1072
|
+
reconnectInterval?: number;
|
|
1073
|
+
/** Maximum number of reconnection attempts before giving up */
|
|
1074
|
+
maxReconnectAttempts?: number;
|
|
1075
|
+
/** Authentication configuration */
|
|
1076
|
+
auth?: AuthConfig;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Handler for incoming messages
|
|
1080
|
+
*/
|
|
1081
|
+
type MessageHandler = (message: BridgeMessage) => void;
|
|
1082
|
+
/**
|
|
1083
|
+
* Handler for disconnect events
|
|
1084
|
+
*/
|
|
1085
|
+
type DisconnectHandler = () => void;
|
|
1086
|
+
/**
|
|
1087
|
+
* Handler for error events
|
|
1088
|
+
*/
|
|
1089
|
+
type ErrorHandler = (error: Error) => void;
|
|
1090
|
+
/**
|
|
1091
|
+
* Abstract transport interface for bridge communication
|
|
1092
|
+
* Implementations handle the actual network protocol (WebSocket, TCP, etc.)
|
|
1093
|
+
*/
|
|
1094
|
+
interface Transport {
|
|
1095
|
+
/**
|
|
1096
|
+
* Establish connection to a remote peer
|
|
1097
|
+
* @param config Connection configuration
|
|
1098
|
+
* @returns Promise that resolves when connection is established
|
|
1099
|
+
* @throws Error if connection fails
|
|
1100
|
+
*/
|
|
1101
|
+
connect(config: ConnectionConfig): Promise<void>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Cleanly close the current connection
|
|
1104
|
+
* @returns Promise that resolves when disconnection is complete
|
|
1105
|
+
*/
|
|
1106
|
+
disconnect(): Promise<void>;
|
|
1107
|
+
/**
|
|
1108
|
+
* Send a message to the connected peer
|
|
1109
|
+
* @param message The message to send
|
|
1110
|
+
* @returns Promise that resolves when message is sent
|
|
1111
|
+
* @throws Error if not connected and message cannot be queued
|
|
1112
|
+
*/
|
|
1113
|
+
send(message: BridgeMessage): Promise<void>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Register a handler for incoming messages
|
|
1116
|
+
* @param handler Function to call when a message is received
|
|
1117
|
+
*/
|
|
1118
|
+
onMessage(handler: MessageHandler): void;
|
|
1119
|
+
/**
|
|
1120
|
+
* Register a handler for disconnect events
|
|
1121
|
+
* @param handler Function to call when connection is lost
|
|
1122
|
+
*/
|
|
1123
|
+
onDisconnect(handler: DisconnectHandler): void;
|
|
1124
|
+
/**
|
|
1125
|
+
* Register a handler for error events
|
|
1126
|
+
* @param handler Function to call when an error occurs
|
|
1127
|
+
*/
|
|
1128
|
+
onError(handler: ErrorHandler): void;
|
|
1129
|
+
/**
|
|
1130
|
+
* Check if the transport is currently connected
|
|
1131
|
+
* @returns true if connected, false otherwise
|
|
1132
|
+
*/
|
|
1133
|
+
isConnected(): boolean;
|
|
1134
|
+
/**
|
|
1135
|
+
* Get the current connection state
|
|
1136
|
+
* @returns The current ConnectionState
|
|
1137
|
+
*/
|
|
1138
|
+
getState(): ConnectionState;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* WebSocket Transport implementation for Claude Code Bridge
|
|
1143
|
+
* Provides WebSocket-based communication between bridge instances
|
|
1144
|
+
*/
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* WebSocket-based transport implementation
|
|
1148
|
+
* Handles connection lifecycle, message sending/receiving, and event handling
|
|
1149
|
+
* Supports auto-reconnection, message queuing, and heartbeat monitoring
|
|
1150
|
+
*/
|
|
1151
|
+
declare class WebSocketTransport implements Transport {
|
|
1152
|
+
private ws;
|
|
1153
|
+
private state;
|
|
1154
|
+
private config;
|
|
1155
|
+
private reconnectAttempts;
|
|
1156
|
+
private reconnectTimer;
|
|
1157
|
+
private intentionalDisconnect;
|
|
1158
|
+
private messageQueue;
|
|
1159
|
+
private heartbeatInterval;
|
|
1160
|
+
private heartbeatTimeout;
|
|
1161
|
+
private awaitingPong;
|
|
1162
|
+
private messageHandlers;
|
|
1163
|
+
private disconnectHandlers;
|
|
1164
|
+
private errorHandlers;
|
|
1165
|
+
private reconnectingHandlers;
|
|
1166
|
+
/**
|
|
1167
|
+
* Build the WebSocket URL from the connection configuration
|
|
1168
|
+
*/
|
|
1169
|
+
private buildUrl;
|
|
1170
|
+
/**
|
|
1171
|
+
* Establish connection to a remote peer
|
|
1172
|
+
*/
|
|
1173
|
+
connect(config: ConnectionConfig): Promise<void>;
|
|
1174
|
+
/**
|
|
1175
|
+
* Internal method to establish WebSocket connection
|
|
1176
|
+
* Used for both initial connection and reconnection attempts
|
|
1177
|
+
*/
|
|
1178
|
+
private establishConnection;
|
|
1179
|
+
/**
|
|
1180
|
+
* Cleanly close the current connection
|
|
1181
|
+
*/
|
|
1182
|
+
disconnect(): Promise<void>;
|
|
1183
|
+
/**
|
|
1184
|
+
* Send a message to the connected peer
|
|
1185
|
+
* If disconnected and reconnection is enabled, queues the message for later delivery
|
|
1186
|
+
*/
|
|
1187
|
+
send(message: BridgeMessage): Promise<void>;
|
|
1188
|
+
/**
|
|
1189
|
+
* Immediately send a message over the WebSocket
|
|
1190
|
+
*/
|
|
1191
|
+
private sendImmediate;
|
|
1192
|
+
/**
|
|
1193
|
+
* Queue a message for later delivery when reconnected
|
|
1194
|
+
*/
|
|
1195
|
+
private queueMessage;
|
|
1196
|
+
/**
|
|
1197
|
+
* Flush all queued messages after reconnection
|
|
1198
|
+
*/
|
|
1199
|
+
private flushMessageQueue;
|
|
1200
|
+
/**
|
|
1201
|
+
* Register a handler for incoming messages
|
|
1202
|
+
*/
|
|
1203
|
+
onMessage(handler: MessageHandler): void;
|
|
1204
|
+
/**
|
|
1205
|
+
* Register a handler for disconnect events
|
|
1206
|
+
*/
|
|
1207
|
+
onDisconnect(handler: DisconnectHandler): void;
|
|
1208
|
+
/**
|
|
1209
|
+
* Register a handler for error events
|
|
1210
|
+
*/
|
|
1211
|
+
onError(handler: ErrorHandler): void;
|
|
1212
|
+
/**
|
|
1213
|
+
* Register a handler for reconnecting events
|
|
1214
|
+
*/
|
|
1215
|
+
onReconnecting(handler: (attempt: number, maxAttempts: number) => void): void;
|
|
1216
|
+
/**
|
|
1217
|
+
* Check if the transport is currently connected
|
|
1218
|
+
*/
|
|
1219
|
+
isConnected(): boolean;
|
|
1220
|
+
/**
|
|
1221
|
+
* Get the current connection state
|
|
1222
|
+
*/
|
|
1223
|
+
getState(): ConnectionState;
|
|
1224
|
+
/**
|
|
1225
|
+
* Handle incoming WebSocket messages
|
|
1226
|
+
*/
|
|
1227
|
+
private handleIncomingMessage;
|
|
1228
|
+
/**
|
|
1229
|
+
* Notify all disconnect handlers
|
|
1230
|
+
*/
|
|
1231
|
+
private notifyDisconnect;
|
|
1232
|
+
/**
|
|
1233
|
+
* Notify all error handlers
|
|
1234
|
+
*/
|
|
1235
|
+
private notifyError;
|
|
1236
|
+
/**
|
|
1237
|
+
* Notify all reconnecting handlers
|
|
1238
|
+
*/
|
|
1239
|
+
private notifyReconnecting;
|
|
1240
|
+
/**
|
|
1241
|
+
* Check if reconnection should be attempted
|
|
1242
|
+
*/
|
|
1243
|
+
private shouldReconnect;
|
|
1244
|
+
/**
|
|
1245
|
+
* Schedule a reconnection attempt
|
|
1246
|
+
*/
|
|
1247
|
+
private scheduleReconnect;
|
|
1248
|
+
/**
|
|
1249
|
+
* Clear any pending reconnection timer
|
|
1250
|
+
*/
|
|
1251
|
+
private clearReconnectTimer;
|
|
1252
|
+
/**
|
|
1253
|
+
* Start the heartbeat monitoring
|
|
1254
|
+
*/
|
|
1255
|
+
private startHeartbeat;
|
|
1256
|
+
/**
|
|
1257
|
+
* Stop the heartbeat monitoring
|
|
1258
|
+
*/
|
|
1259
|
+
private stopHeartbeat;
|
|
1260
|
+
/**
|
|
1261
|
+
* Send a ping to the peer
|
|
1262
|
+
*/
|
|
1263
|
+
private sendPing;
|
|
1264
|
+
/**
|
|
1265
|
+
* Handle pong response from peer
|
|
1266
|
+
*/
|
|
1267
|
+
private handlePong;
|
|
1268
|
+
/**
|
|
1269
|
+
* Handle heartbeat timeout (no pong received)
|
|
1270
|
+
*/
|
|
1271
|
+
private handleHeartbeatTimeout;
|
|
1272
|
+
/**
|
|
1273
|
+
* Get the current message queue length (for testing)
|
|
1274
|
+
*/
|
|
1275
|
+
getQueueLength(): number;
|
|
1276
|
+
/**
|
|
1277
|
+
* Get the number of reconnection attempts (for testing)
|
|
1278
|
+
*/
|
|
1279
|
+
getReconnectAttempts(): number;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* Peer Discovery Module
|
|
1284
|
+
*
|
|
1285
|
+
* Provides functions to discover bridge-enabled Docker containers
|
|
1286
|
+
* and development environment projects.
|
|
1287
|
+
*/
|
|
1288
|
+
/**
|
|
1289
|
+
* Discovered peer information
|
|
1290
|
+
*/
|
|
1291
|
+
interface DiscoveredPeer {
|
|
1292
|
+
name: string;
|
|
1293
|
+
source: 'docker' | 'docksal' | 'ddev' | 'lando';
|
|
1294
|
+
url: string;
|
|
1295
|
+
containerId?: string;
|
|
1296
|
+
status?: string;
|
|
1297
|
+
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Bridge label configuration parsed from Docker container labels
|
|
1300
|
+
*/
|
|
1301
|
+
interface BridgeLabelConfig {
|
|
1302
|
+
enabled: boolean;
|
|
1303
|
+
port?: number;
|
|
1304
|
+
name?: string;
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Parse Docker container labels to extract bridge configuration
|
|
1308
|
+
*
|
|
1309
|
+
* @param labels - Comma-separated label string from Docker
|
|
1310
|
+
* @returns Parsed bridge configuration or null if bridge not enabled
|
|
1311
|
+
*/
|
|
1312
|
+
declare function parseDockerLabels(labels: string): BridgeLabelConfig | null;
|
|
1313
|
+
/**
|
|
1314
|
+
* Check if Docker daemon is available and running
|
|
1315
|
+
*/
|
|
1316
|
+
declare function isDockerAvailable(): boolean;
|
|
1317
|
+
/**
|
|
1318
|
+
* Discover Docker containers with bridge labels
|
|
1319
|
+
*
|
|
1320
|
+
* Searches for running containers that have the claude.bridge.enabled=true label
|
|
1321
|
+
* and extracts connection information from their labels.
|
|
1322
|
+
*
|
|
1323
|
+
* @returns Array of discovered peers with connection URLs
|
|
1324
|
+
*/
|
|
1325
|
+
declare function discoverDockerPeers(): DiscoveredPeer[];
|
|
1326
|
+
/**
|
|
1327
|
+
* Discover Docksal projects with bridges
|
|
1328
|
+
*
|
|
1329
|
+
* Uses the `fin project list` command to find running Docksal projects.
|
|
1330
|
+
*
|
|
1331
|
+
* @returns Array of discovered peers with connection URLs
|
|
1332
|
+
*/
|
|
1333
|
+
declare function discoverDocksalProjects(): DiscoveredPeer[];
|
|
1334
|
+
/**
|
|
1335
|
+
* Discover DDEV projects with bridges
|
|
1336
|
+
*
|
|
1337
|
+
* Uses the `ddev list` command to find running DDEV projects.
|
|
1338
|
+
*
|
|
1339
|
+
* @returns Array of discovered peers with connection URLs
|
|
1340
|
+
*/
|
|
1341
|
+
declare function discoverDdevProjects(): DiscoveredPeer[];
|
|
1342
|
+
/**
|
|
1343
|
+
* Discover Lando projects with bridges
|
|
1344
|
+
*
|
|
1345
|
+
* Uses the `lando list` command to find running Lando apps.
|
|
1346
|
+
*
|
|
1347
|
+
* @returns Array of discovered peers with connection URLs
|
|
1348
|
+
*/
|
|
1349
|
+
declare function discoverLandoProjects(): DiscoveredPeer[];
|
|
1350
|
+
/**
|
|
1351
|
+
* Discover all peers from all sources
|
|
1352
|
+
*
|
|
1353
|
+
* Aggregates peers from Docker containers and all supported development
|
|
1354
|
+
* environments (Docksal, DDEV, Lando).
|
|
1355
|
+
*
|
|
1356
|
+
* @returns Array of all discovered peers
|
|
1357
|
+
*/
|
|
1358
|
+
declare function discoverAllPeers(): DiscoveredPeer[];
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* Transport module exports
|
|
1362
|
+
*/
|
|
1363
|
+
|
|
1364
|
+
type TransportType = 'websocket';
|
|
1365
|
+
/**
|
|
1366
|
+
* Options for creating a transport
|
|
1367
|
+
*/
|
|
1368
|
+
interface CreateTransportOptions {
|
|
1369
|
+
/** Configuration to use when connecting */
|
|
1370
|
+
config?: ConnectionConfig;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Factory function to create transport instances
|
|
1374
|
+
* @param type The type of transport to create
|
|
1375
|
+
* @param options Optional configuration options
|
|
1376
|
+
* @returns A Transport instance
|
|
1377
|
+
* @throws Error if the transport type is not supported
|
|
1378
|
+
*/
|
|
1379
|
+
declare function createTransport(type: TransportType, options?: CreateTransportOptions): Transport;
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* Configuration for the bridge's listening socket
|
|
1383
|
+
*/
|
|
1384
|
+
interface ListenConfig {
|
|
1385
|
+
port: number;
|
|
1386
|
+
host: string;
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Configuration for connecting to a remote bridge
|
|
1390
|
+
*/
|
|
1391
|
+
interface ConnectConfig {
|
|
1392
|
+
url?: string;
|
|
1393
|
+
hostGateway?: boolean;
|
|
1394
|
+
port?: number;
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Configuration for context sharing behavior
|
|
1398
|
+
*/
|
|
1399
|
+
interface ContextSharingConfig {
|
|
1400
|
+
autoSync: boolean;
|
|
1401
|
+
syncInterval: number;
|
|
1402
|
+
maxChunkTokens: number;
|
|
1403
|
+
includePatterns: string[];
|
|
1404
|
+
excludePatterns: string[];
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Configuration for interaction behavior
|
|
1408
|
+
*/
|
|
1409
|
+
interface InteractionConfig {
|
|
1410
|
+
requireConfirmation: boolean;
|
|
1411
|
+
notifyOnActivity: boolean;
|
|
1412
|
+
taskTimeout: number;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Full bridge configuration
|
|
1416
|
+
*/
|
|
1417
|
+
interface BridgeConfig {
|
|
1418
|
+
instanceName?: string;
|
|
1419
|
+
mode?: 'host' | 'client' | 'peer';
|
|
1420
|
+
listen: ListenConfig;
|
|
1421
|
+
connect?: ConnectConfig;
|
|
1422
|
+
contextSharing: ContextSharingConfig;
|
|
1423
|
+
interaction: InteractionConfig;
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Default configuration values
|
|
1427
|
+
*/
|
|
1428
|
+
declare const DEFAULT_CONFIG: BridgeConfig;
|
|
1429
|
+
/**
|
|
1430
|
+
* Deep merges a partial config with the default config
|
|
1431
|
+
*
|
|
1432
|
+
* @param partial - Partial configuration to merge
|
|
1433
|
+
* @returns Complete configuration with defaults for missing values
|
|
1434
|
+
*/
|
|
1435
|
+
declare function mergeConfig(partial: Partial<BridgeConfig>): BridgeConfig;
|
|
1436
|
+
/**
|
|
1437
|
+
* Loads configuration from file(s) and merges with defaults
|
|
1438
|
+
*
|
|
1439
|
+
* Searches for config files in the following order:
|
|
1440
|
+
* 1. Explicit path (if provided)
|
|
1441
|
+
* 2. .claude-bridge.yml in current working directory
|
|
1442
|
+
* 3. ~/.claude-bridge/config.yml
|
|
1443
|
+
*
|
|
1444
|
+
* @param configPath - Optional explicit path to config file
|
|
1445
|
+
* @returns Complete configuration with defaults for missing values
|
|
1446
|
+
*
|
|
1447
|
+
* @example
|
|
1448
|
+
* ```typescript
|
|
1449
|
+
* // Load from default locations
|
|
1450
|
+
* const config = await loadConfig();
|
|
1451
|
+
*
|
|
1452
|
+
* // Load from specific path
|
|
1453
|
+
* const config = await loadConfig('/path/to/config.yml');
|
|
1454
|
+
* ```
|
|
1455
|
+
*/
|
|
1456
|
+
declare function loadConfig(configPath?: string): Promise<BridgeConfig>;
|
|
1457
|
+
/**
|
|
1458
|
+
* Synchronous version of loadConfig for simpler usage patterns
|
|
1459
|
+
*
|
|
1460
|
+
* @param configPath - Optional explicit path to config file
|
|
1461
|
+
* @returns Complete configuration with defaults for missing values
|
|
1462
|
+
*/
|
|
1463
|
+
declare function loadConfigSync(configPath?: string): BridgeConfig;
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* Environment detection utilities for Claude Code Bridge
|
|
1467
|
+
*
|
|
1468
|
+
* Detects the runtime environment (Docksal, DDEV, Lando, Docker, or native)
|
|
1469
|
+
* and provides appropriate configuration defaults.
|
|
1470
|
+
*/
|
|
1471
|
+
|
|
1472
|
+
/**
|
|
1473
|
+
* Supported Docker environment types
|
|
1474
|
+
*/
|
|
1475
|
+
type DockerEnvironment = 'docksal' | 'ddev' | 'lando' | 'docker-compose' | 'docker' | 'native';
|
|
1476
|
+
/**
|
|
1477
|
+
* Information about the detected runtime environment
|
|
1478
|
+
*/
|
|
1479
|
+
interface EnvironmentInfo {
|
|
1480
|
+
/** The type of environment detected */
|
|
1481
|
+
type: DockerEnvironment;
|
|
1482
|
+
/** Whether running inside a container */
|
|
1483
|
+
isContainer: boolean;
|
|
1484
|
+
/** Project name (if applicable) */
|
|
1485
|
+
projectName?: string;
|
|
1486
|
+
/** Project root path (if applicable) */
|
|
1487
|
+
projectRoot?: string;
|
|
1488
|
+
/** Host gateway address for container-to-host communication */
|
|
1489
|
+
hostGateway?: string;
|
|
1490
|
+
/** Operating system platform */
|
|
1491
|
+
platform: NodeJS.Platform;
|
|
1492
|
+
/** Additional environment-specific metadata */
|
|
1493
|
+
meta?: Record<string, string>;
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Detect the current runtime environment
|
|
1497
|
+
*
|
|
1498
|
+
* Detection order (first match wins):
|
|
1499
|
+
* 1. Docksal (DOCKSAL_STACK env var)
|
|
1500
|
+
* 2. DDEV (IS_DDEV_PROJECT=true env var)
|
|
1501
|
+
* 3. Lando (LANDO=ON env var)
|
|
1502
|
+
* 4. Docker Compose (COMPOSE_PROJECT_NAME env var)
|
|
1503
|
+
* 5. Generic Docker (/.dockerenv file exists)
|
|
1504
|
+
* 6. Native (fallback)
|
|
1505
|
+
*
|
|
1506
|
+
* @returns EnvironmentInfo object with detected environment details
|
|
1507
|
+
*/
|
|
1508
|
+
declare function detectEnvironment(): EnvironmentInfo;
|
|
1509
|
+
/**
|
|
1510
|
+
* Get the host gateway address for container-to-host communication
|
|
1511
|
+
*
|
|
1512
|
+
* - macOS and Windows: Use host.docker.internal (provided by Docker Desktop)
|
|
1513
|
+
* - Linux: May need to use bridge gateway IP or host-gateway flag
|
|
1514
|
+
*
|
|
1515
|
+
* @returns The hostname or IP to reach the Docker host from inside a container
|
|
1516
|
+
*/
|
|
1517
|
+
declare function getHostGateway(): string;
|
|
1518
|
+
/**
|
|
1519
|
+
* Get default bridge configuration based on the detected environment
|
|
1520
|
+
*
|
|
1521
|
+
* Different environments may have different port defaults or connection
|
|
1522
|
+
* preferences.
|
|
1523
|
+
*
|
|
1524
|
+
* @param env - The detected environment info
|
|
1525
|
+
* @returns Partial BridgeConfig with environment-specific defaults
|
|
1526
|
+
*/
|
|
1527
|
+
declare function getDefaultConfig(env: EnvironmentInfo): Partial<BridgeConfig>;
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* Docksal-specific helper functions for Claude Code Bridge
|
|
1531
|
+
*
|
|
1532
|
+
* Provides utilities to extract project information from the Docksal environment.
|
|
1533
|
+
* Docksal is a Docker-based development environment primarily used for
|
|
1534
|
+
* Drupal and other PHP projects.
|
|
1535
|
+
*
|
|
1536
|
+
* @see https://docksal.io/
|
|
1537
|
+
*/
|
|
1538
|
+
/**
|
|
1539
|
+
* Information about a Docksal project
|
|
1540
|
+
*/
|
|
1541
|
+
interface DocksalProjectInfo {
|
|
1542
|
+
/** Project name from DOCKSAL_PROJECT env var */
|
|
1543
|
+
projectName: string;
|
|
1544
|
+
/** Project root path from PROJECT_ROOT env var */
|
|
1545
|
+
projectRoot: string;
|
|
1546
|
+
/** Docksal stack name from DOCKSAL_STACK env var */
|
|
1547
|
+
stack: string;
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
* Get Docksal project information from environment variables
|
|
1551
|
+
*
|
|
1552
|
+
* Extracts project details from the standard Docksal environment variables:
|
|
1553
|
+
* - DOCKSAL_PROJECT: The project name
|
|
1554
|
+
* - PROJECT_ROOT: The project root directory
|
|
1555
|
+
* - DOCKSAL_STACK: The Docksal stack being used (e.g., 'default', 'acquia')
|
|
1556
|
+
*
|
|
1557
|
+
* @returns DocksalProjectInfo if in Docksal environment, null otherwise
|
|
1558
|
+
*
|
|
1559
|
+
* @example
|
|
1560
|
+
* ```typescript
|
|
1561
|
+
* const info = getDocksalProjectInfo();
|
|
1562
|
+
* if (info) {
|
|
1563
|
+
* console.log(`Project: ${info.projectName}`);
|
|
1564
|
+
* console.log(`Root: ${info.projectRoot}`);
|
|
1565
|
+
* console.log(`Stack: ${info.stack}`);
|
|
1566
|
+
* }
|
|
1567
|
+
* ```
|
|
1568
|
+
*/
|
|
1569
|
+
declare function getDocksalProjectInfo(): DocksalProjectInfo | null;
|
|
1570
|
+
|
|
1571
|
+
/**
|
|
1572
|
+
* DDEV-specific helper functions for Claude Code Bridge
|
|
1573
|
+
*
|
|
1574
|
+
* Provides utilities to extract project information from the DDEV environment.
|
|
1575
|
+
* DDEV is a Docker-based development environment for PHP and other projects.
|
|
1576
|
+
*
|
|
1577
|
+
* @see https://ddev.readthedocs.io/
|
|
1578
|
+
*/
|
|
1579
|
+
/**
|
|
1580
|
+
* Information about a DDEV project
|
|
1581
|
+
*/
|
|
1582
|
+
interface DdevProjectInfo {
|
|
1583
|
+
/** Project name from DDEV_PROJECT env var */
|
|
1584
|
+
projectName: string;
|
|
1585
|
+
/** Project document root from DDEV_DOCROOT env var */
|
|
1586
|
+
projectRoot: string;
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Get DDEV project information from environment variables
|
|
1590
|
+
*
|
|
1591
|
+
* Extracts project details from the standard DDEV environment variables:
|
|
1592
|
+
* - DDEV_PROJECT: The project name
|
|
1593
|
+
* - DDEV_DOCROOT: The document root directory (web root)
|
|
1594
|
+
*
|
|
1595
|
+
* @returns DdevProjectInfo if in DDEV environment, null otherwise
|
|
1596
|
+
*
|
|
1597
|
+
* @example
|
|
1598
|
+
* ```typescript
|
|
1599
|
+
* const info = getDdevProjectInfo();
|
|
1600
|
+
* if (info) {
|
|
1601
|
+
* console.log(`Project: ${info.projectName}`);
|
|
1602
|
+
* console.log(`Root: ${info.projectRoot}`);
|
|
1603
|
+
* }
|
|
1604
|
+
* ```
|
|
1605
|
+
*/
|
|
1606
|
+
declare function getDdevProjectInfo(): DdevProjectInfo | null;
|
|
1607
|
+
|
|
1608
|
+
/**
|
|
1609
|
+
* Lando-specific helper functions for Claude Code Bridge
|
|
1610
|
+
*
|
|
1611
|
+
* Provides utilities to extract project information from the Lando environment.
|
|
1612
|
+
* Lando is a Docker-based development environment for PHP, Node.js, and other projects.
|
|
1613
|
+
*
|
|
1614
|
+
* @see https://docs.lando.dev/
|
|
1615
|
+
*/
|
|
1616
|
+
/**
|
|
1617
|
+
* Information about a Lando project
|
|
1618
|
+
*/
|
|
1619
|
+
interface LandoProjectInfo {
|
|
1620
|
+
/** Project name (app name) from LANDO_APP_NAME env var */
|
|
1621
|
+
projectName: string;
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Get Lando project information from environment variables
|
|
1625
|
+
*
|
|
1626
|
+
* Extracts project details from the standard Lando environment variables:
|
|
1627
|
+
* - LANDO_APP_NAME: The application/project name
|
|
1628
|
+
*
|
|
1629
|
+
* @returns LandoProjectInfo if in Lando environment, null otherwise
|
|
1630
|
+
*
|
|
1631
|
+
* @example
|
|
1632
|
+
* ```typescript
|
|
1633
|
+
* const info = getLandoProjectInfo();
|
|
1634
|
+
* if (info) {
|
|
1635
|
+
* console.log(`Project: ${info.projectName}`);
|
|
1636
|
+
* }
|
|
1637
|
+
* ```
|
|
1638
|
+
*/
|
|
1639
|
+
declare function getLandoProjectInfo(): LandoProjectInfo | null;
|
|
1640
|
+
|
|
1641
|
+
/**
|
|
1642
|
+
* Log levels supported by the logger
|
|
1643
|
+
*/
|
|
1644
|
+
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
1645
|
+
/**
|
|
1646
|
+
* Logger interface (subset of pino.Logger for public API)
|
|
1647
|
+
*/
|
|
1648
|
+
type Logger = pino.Logger;
|
|
1649
|
+
/**
|
|
1650
|
+
* Creates a logger instance with the given component name
|
|
1651
|
+
*
|
|
1652
|
+
* @param name - Component name to include in log output
|
|
1653
|
+
* @param level - Optional log level override (defaults to LOG_LEVEL env var or 'info')
|
|
1654
|
+
* @returns A pino logger instance configured for the component
|
|
1655
|
+
*
|
|
1656
|
+
* @example
|
|
1657
|
+
* ```typescript
|
|
1658
|
+
* const logger = createLogger('bridge');
|
|
1659
|
+
* logger.info('Bridge started');
|
|
1660
|
+
* logger.error({ err }, 'Connection failed');
|
|
1661
|
+
* ```
|
|
1662
|
+
*/
|
|
1663
|
+
declare function createLogger(name: string, level?: LogLevel): Logger;
|
|
1664
|
+
/**
|
|
1665
|
+
* Creates a child logger from an existing logger with additional context
|
|
1666
|
+
*
|
|
1667
|
+
* @param parent - Parent logger instance
|
|
1668
|
+
* @param bindings - Additional context to include in all log messages
|
|
1669
|
+
* @returns A child logger instance
|
|
1670
|
+
*/
|
|
1671
|
+
declare function createChildLogger(parent: Logger, bindings: Record<string, unknown>): Logger;
|
|
1672
|
+
|
|
1673
|
+
/**
|
|
1674
|
+
* Token counting utilities for context chunking.
|
|
1675
|
+
* Uses word-based approximation since exact token counting requires
|
|
1676
|
+
* a tokenizer specific to the model being used.
|
|
1677
|
+
*/
|
|
1678
|
+
/**
|
|
1679
|
+
* Estimates the number of tokens in a given text.
|
|
1680
|
+
* Uses a simple word-based approximation (roughly 1.3 tokens per word).
|
|
1681
|
+
*
|
|
1682
|
+
* @param text - The text to estimate tokens for
|
|
1683
|
+
* @returns Estimated number of tokens
|
|
1684
|
+
*/
|
|
1685
|
+
declare function estimateTokens(text: string): number;
|
|
1686
|
+
/**
|
|
1687
|
+
* Truncates text to fit within a token limit while preserving complete words.
|
|
1688
|
+
*
|
|
1689
|
+
* @param text - The text to truncate
|
|
1690
|
+
* @param maxTokens - The maximum number of tokens allowed
|
|
1691
|
+
* @returns Truncated text that fits within the token limit
|
|
1692
|
+
*/
|
|
1693
|
+
declare function truncateToTokenLimit(text: string, maxTokens: number): string;
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* Custom error classes for Claude Code Bridge
|
|
1697
|
+
*
|
|
1698
|
+
* Provides structured error types with clear, actionable messages
|
|
1699
|
+
* for different error scenarios.
|
|
1700
|
+
*/
|
|
1701
|
+
/**
|
|
1702
|
+
* Base error class for bridge errors
|
|
1703
|
+
*/
|
|
1704
|
+
declare class BridgeError extends Error {
|
|
1705
|
+
readonly code: string;
|
|
1706
|
+
readonly context?: Record<string, unknown>;
|
|
1707
|
+
constructor(message: string, code: string, context?: Record<string, unknown>);
|
|
1708
|
+
/**
|
|
1709
|
+
* Get formatted error message with context
|
|
1710
|
+
*/
|
|
1711
|
+
toDetailedString(): string;
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Error codes for bridge errors
|
|
1715
|
+
*/
|
|
1716
|
+
declare const ErrorCodes: {
|
|
1717
|
+
readonly CONFIG_INVALID: "CONFIG_INVALID";
|
|
1718
|
+
readonly CONFIG_MISSING: "CONFIG_MISSING";
|
|
1719
|
+
readonly CONFIG_PARSE_ERROR: "CONFIG_PARSE_ERROR";
|
|
1720
|
+
readonly CONNECTION_FAILED: "CONNECTION_FAILED";
|
|
1721
|
+
readonly CONNECTION_REFUSED: "CONNECTION_REFUSED";
|
|
1722
|
+
readonly CONNECTION_TIMEOUT: "CONNECTION_TIMEOUT";
|
|
1723
|
+
readonly CONNECTION_CLOSED: "CONNECTION_CLOSED";
|
|
1724
|
+
readonly NOT_CONNECTED: "NOT_CONNECTED";
|
|
1725
|
+
readonly ALREADY_CONNECTED: "ALREADY_CONNECTED";
|
|
1726
|
+
readonly PEER_NOT_FOUND: "PEER_NOT_FOUND";
|
|
1727
|
+
readonly NO_PEERS_CONNECTED: "NO_PEERS_CONNECTED";
|
|
1728
|
+
readonly PEER_DISCONNECTED: "PEER_DISCONNECTED";
|
|
1729
|
+
readonly TASK_TIMEOUT: "TASK_TIMEOUT";
|
|
1730
|
+
readonly TASK_FAILED: "TASK_FAILED";
|
|
1731
|
+
readonly NO_TASK_HANDLER: "NO_TASK_HANDLER";
|
|
1732
|
+
readonly CONTEXT_TIMEOUT: "CONTEXT_TIMEOUT";
|
|
1733
|
+
readonly CONTEXT_SYNC_FAILED: "CONTEXT_SYNC_FAILED";
|
|
1734
|
+
readonly SNAPSHOT_NOT_FOUND: "SNAPSHOT_NOT_FOUND";
|
|
1735
|
+
readonly INVALID_MESSAGE: "INVALID_MESSAGE";
|
|
1736
|
+
readonly SERIALIZATION_ERROR: "SERIALIZATION_ERROR";
|
|
1737
|
+
readonly BRIDGE_ALREADY_STARTED: "BRIDGE_ALREADY_STARTED";
|
|
1738
|
+
readonly BRIDGE_NOT_STARTED: "BRIDGE_NOT_STARTED";
|
|
1739
|
+
readonly BRIDGE_SHUTDOWN: "BRIDGE_SHUTDOWN";
|
|
1740
|
+
readonly UNKNOWN: "UNKNOWN";
|
|
1741
|
+
};
|
|
1742
|
+
type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
1743
|
+
/**
|
|
1744
|
+
* Configuration error
|
|
1745
|
+
*/
|
|
1746
|
+
declare class ConfigurationError extends BridgeError {
|
|
1747
|
+
readonly setting?: string;
|
|
1748
|
+
constructor(message: string, code: ErrorCode, setting?: string, context?: Record<string, unknown>);
|
|
1749
|
+
static missing(setting: string): ConfigurationError;
|
|
1750
|
+
static invalid(setting: string, reason: string, value?: unknown): ConfigurationError;
|
|
1751
|
+
static parseError(filePath: string, error: Error): ConfigurationError;
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Connection error with network details
|
|
1755
|
+
*/
|
|
1756
|
+
declare class ConnectionError extends BridgeError {
|
|
1757
|
+
readonly url?: string;
|
|
1758
|
+
readonly host?: string;
|
|
1759
|
+
readonly port?: number;
|
|
1760
|
+
constructor(message: string, code?: ErrorCode, options?: {
|
|
1761
|
+
url?: string;
|
|
1762
|
+
host?: string;
|
|
1763
|
+
port?: number;
|
|
1764
|
+
cause?: Error;
|
|
1765
|
+
});
|
|
1766
|
+
static refused(url: string): ConnectionError;
|
|
1767
|
+
static timeout(url: string, timeoutMs: number): ConnectionError;
|
|
1768
|
+
static closed(url: string, reason?: string): ConnectionError;
|
|
1769
|
+
static notConnected(): ConnectionError;
|
|
1770
|
+
static alreadyConnected(): ConnectionError;
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Peer-related error
|
|
1774
|
+
*/
|
|
1775
|
+
declare class PeerError extends BridgeError {
|
|
1776
|
+
readonly peerId?: string;
|
|
1777
|
+
constructor(message: string, code: ErrorCode, peerId?: string);
|
|
1778
|
+
static notFound(peerId: string): PeerError;
|
|
1779
|
+
static noPeersConnected(): PeerError;
|
|
1780
|
+
static disconnected(peerId: string): PeerError;
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Task-related error
|
|
1784
|
+
*/
|
|
1785
|
+
declare class TaskError extends BridgeError {
|
|
1786
|
+
readonly taskId?: string;
|
|
1787
|
+
constructor(message: string, code: ErrorCode, taskId?: string, context?: Record<string, unknown>);
|
|
1788
|
+
static timeout(taskId: string, timeoutMs: number): TaskError;
|
|
1789
|
+
static failed(taskId: string, reason: string): TaskError;
|
|
1790
|
+
static noHandler(): TaskError;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Context synchronization error
|
|
1794
|
+
*/
|
|
1795
|
+
declare class ContextError extends BridgeError {
|
|
1796
|
+
constructor(message: string, code: ErrorCode, context?: Record<string, unknown>);
|
|
1797
|
+
static timeout(timeoutMs: number): ContextError;
|
|
1798
|
+
static syncFailed(reason: string): ContextError;
|
|
1799
|
+
static snapshotNotFound(snapshotId: string): ContextError;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Protocol/message error
|
|
1803
|
+
*/
|
|
1804
|
+
declare class ProtocolError extends BridgeError {
|
|
1805
|
+
constructor(message: string, code?: ErrorCode, context?: Record<string, unknown>);
|
|
1806
|
+
static invalidMessage(reason: string, data?: unknown): ProtocolError;
|
|
1807
|
+
static serializationError(error: Error): ProtocolError;
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* Bridge lifecycle error
|
|
1811
|
+
*/
|
|
1812
|
+
declare class BridgeLifecycleError extends BridgeError {
|
|
1813
|
+
constructor(message: string, code: ErrorCode);
|
|
1814
|
+
static alreadyStarted(): BridgeLifecycleError;
|
|
1815
|
+
static notStarted(): BridgeLifecycleError;
|
|
1816
|
+
static shuttingDown(): BridgeLifecycleError;
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Format an error for logging with context
|
|
1820
|
+
*/
|
|
1821
|
+
declare function formatErrorForLogging(error: unknown): {
|
|
1822
|
+
message: string;
|
|
1823
|
+
code?: string;
|
|
1824
|
+
context?: Record<string, unknown>;
|
|
1825
|
+
stack?: string;
|
|
1826
|
+
};
|
|
1827
|
+
/**
|
|
1828
|
+
* Wrap an error with additional context
|
|
1829
|
+
*/
|
|
1830
|
+
declare function wrapError(error: unknown, context: string): BridgeError;
|
|
1831
|
+
/**
|
|
1832
|
+
* Check if an error is of a specific type
|
|
1833
|
+
*/
|
|
1834
|
+
declare function isErrorCode(error: unknown, code: ErrorCode): boolean;
|
|
1835
|
+
|
|
1836
|
+
/**
|
|
1837
|
+
* Claude Code Bridge
|
|
1838
|
+
*
|
|
1839
|
+
* A bidirectional communication system that enables two separate Claude Code instances
|
|
1840
|
+
* to collaborate across different environments. The primary use case is connecting a
|
|
1841
|
+
* native macOS Claude Code instance with a Claude Code instance running inside a
|
|
1842
|
+
* Docker-based development environment (Docksal, DDEV, Lando, or plain Docker).
|
|
1843
|
+
*
|
|
1844
|
+
* @packageDocumentation
|
|
1845
|
+
*/
|
|
1846
|
+
declare const VERSION = "0.1.0";
|
|
1847
|
+
|
|
1848
|
+
export { type Artifact, ArtifactSchema, Bridge, type BridgeConfig$1 as BridgeConfig, type BridgeConnectConfig, BridgeError, type BridgeLabelConfig, BridgeLifecycleError, type BridgeListenConfig, type BridgeMessage, BridgeMessageSchema, type BridgeMode, type BuildDirectoryTreeOptions, ConfigurationError, type ConnectConfig, type ConnectionConfig, ConnectionError, ConnectionState, type Context, type ContextDelta, ContextError, ContextManager, type ContextManagerOptions, type ContextReceivedHandler, type ContextRequestedHandler, ContextSchema, type ContextSharingConfig$1 as ContextSharingConfig, DEFAULT_CONFIG, type DdevProjectInfo, type DirectoryTree, DirectoryTreeSchema, type DiscoveredPeer, type DockerEnvironment, type DocksalProjectInfo, type EnvironmentInfo, type ErrorCode, ErrorCodes, type FileChange, type FileChunk, FileChunkSchema, type InteractionConfig, type LandoProjectInfo, type ListenConfig, type LogLevel, type Logger, type MessageReceivedHandler, MessageType, type NotificationData, type PeerConnectedHandler, type PeerDisconnectedHandler, PeerError, type PeerInfo, type ProjectSnapshot, ProtocolError, TaskError, type TaskReceivedHandler, type TaskRequest, TaskRequestSchema, type TaskResult, TaskResultSchema, type Transport, type BridgeConfig as UtilsBridgeConfig, type ContextSharingConfig as UtilsContextSharingConfig, VERSION, WebSocketTransport, buildDirectoryTree, createChildLogger, createContextRequestMessage, createContextSyncMessage, createLogger, createMessage, createNotificationMessage, createTaskDelegateMessage, createTaskResponseMessage, createTransport, deserializeMessage, detectEnvironment, discoverAllPeers, discoverDdevProjects, discoverDockerPeers, discoverDocksalProjects, discoverLandoProjects, estimateTokens, formatErrorForLogging, getDdevProjectInfo, getDefaultConfig, getDocksalProjectInfo, getHostGateway, getLandoProjectInfo, isDockerAvailable, isErrorCode, loadConfig, loadConfigSync, mergeConfig, parseDockerLabels, safeDeserializeMessage, safeValidateMessage, serializeMessage, truncateToTokenLimit, validateMessage, wrapError };
|