codebuff 1.0.175 → 1.0.177
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checkpoints/checkpoint-manager.d.ts +73 -0
- package/dist/checkpoints/checkpoint-manager.js +193 -0
- package/dist/checkpoints/checkpoint-manager.js.map +1 -0
- package/dist/{checkpoint-file-manager.d.ts → checkpoints/file-manager.d.ts} +10 -0
- package/dist/{checkpoint-file-manager.js → checkpoints/file-manager.js} +92 -35
- package/dist/checkpoints/file-manager.js.map +1 -0
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +35 -58
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +6 -4
- package/dist/client.js +28 -16
- package/dist/client.js.map +1 -1
- package/dist/code-map/tsconfig.tsbuildinfo +1 -1
- package/dist/common/actions.d.ts +36 -36
- package/dist/common/advanced-analyzer.d.ts +19 -0
- package/dist/common/advanced-analyzer.js +140 -0
- package/dist/common/advanced-analyzer.js.map +1 -0
- package/dist/common/browser-actions.d.ts +48 -48
- package/dist/common/constants.d.ts +0 -1
- package/dist/common/constants.js +1 -44
- package/dist/common/constants.js.map +1 -1
- package/dist/common/message-image-handling.d.ts +41 -0
- package/dist/common/message-image-handling.js +57 -0
- package/dist/common/message-image-handling.js.map +1 -0
- package/dist/common/project-file-tree.d.ts +1 -0
- package/dist/common/project-file-tree.js +3 -1
- package/dist/common/project-file-tree.js.map +1 -1
- package/dist/common/types/agent-state.d.ts +22 -22
- package/dist/common/types/message.d.ts +18 -18
- package/dist/common/util/file.d.ts +4 -4
- package/dist/common/util/process-stream.d.ts +8 -0
- package/dist/common/util/process-stream.js +102 -0
- package/dist/common/util/process-stream.js.map +1 -0
- package/dist/common/websockets/websocket-schema.d.ts +72 -72
- package/dist/menu.js +1 -1
- package/dist/menu.js.map +1 -1
- package/dist/project-files.d.ts +2 -2
- package/dist/project-files.js +2 -2
- package/dist/project-files.js.map +1 -1
- package/dist/tool-handlers.d.ts +2 -1
- package/dist/tool-handlers.js +3 -3
- package/dist/tool-handlers.js.map +1 -1
- package/dist/utils/terminal.js +4 -40
- package/dist/utils/terminal.js.map +1 -1
- package/dist/utils/tool-renderers.js +14 -2
- package/dist/utils/tool-renderers.js.map +1 -1
- package/dist/workers/checkpoint-worker.js +47 -0
- package/dist/workers/checkpoint-worker.js.map +1 -0
- package/dist/workers/project-context.d.ts +1 -0
- package/dist/{worker-script-project-context.js → workers/project-context.js} +5 -5
- package/dist/workers/project-context.js.map +1 -0
- package/package.json +1 -1
- package/dist/checkpoint-file-manager.js.map +0 -1
- package/dist/checkpoints.d.ts +0 -63
- package/dist/checkpoints.js +0 -159
- package/dist/checkpoints.js.map +0 -1
- package/dist/worker-script-project-context.js.map +0 -1
- /package/dist/{worker-script-project-context.d.ts → workers/checkpoint-worker.d.ts} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Message } from './actions';
|
|
2
|
+
/**
|
|
3
|
+
* Contexts where message processing may occur
|
|
4
|
+
*/
|
|
5
|
+
export declare enum ProcessingContext {
|
|
6
|
+
ModelCall = "model-call",
|
|
7
|
+
FileCache = "file-cache",
|
|
8
|
+
WarmCache = "warm-cache"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Interface for provider-specific image handling
|
|
12
|
+
*/
|
|
13
|
+
export interface IImageHandler {
|
|
14
|
+
/**
|
|
15
|
+
* Returns whether images should be passed along in the given context
|
|
16
|
+
*/
|
|
17
|
+
supportsImages(context: ProcessingContext): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Transform a message by either stripping, replacing, or modifying image blocks
|
|
20
|
+
*/
|
|
21
|
+
transformMessage(message: Message, context: ProcessingContext): Message;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Base handler that removes all images unless explicitly allowed
|
|
25
|
+
*/
|
|
26
|
+
export declare class DefaultImageHandler implements IImageHandler {
|
|
27
|
+
supportsImages(context: ProcessingContext): boolean;
|
|
28
|
+
transformMessage(message: Message, context: ProcessingContext): Message;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Register a new image handler for a provider
|
|
32
|
+
*/
|
|
33
|
+
export declare function registerImageHandler(provider: string, handler: IImageHandler): void;
|
|
34
|
+
/**
|
|
35
|
+
* Transform a message for a specific provider and context
|
|
36
|
+
*/
|
|
37
|
+
export declare function transformMessageForProvider(message: Message, provider: string, context: ProcessingContext): Message;
|
|
38
|
+
/**
|
|
39
|
+
* Transform an array of messages for a specific provider and context
|
|
40
|
+
*/
|
|
41
|
+
export declare function transformMessagesForProvider(messages: Message[], provider: string, context: ProcessingContext): Message[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultImageHandler = exports.ProcessingContext = void 0;
|
|
4
|
+
exports.registerImageHandler = registerImageHandler;
|
|
5
|
+
exports.transformMessageForProvider = transformMessageForProvider;
|
|
6
|
+
exports.transformMessagesForProvider = transformMessagesForProvider;
|
|
7
|
+
/**
|
|
8
|
+
* Contexts where message processing may occur
|
|
9
|
+
*/
|
|
10
|
+
var ProcessingContext;
|
|
11
|
+
(function (ProcessingContext) {
|
|
12
|
+
ProcessingContext["ModelCall"] = "model-call";
|
|
13
|
+
ProcessingContext["FileCache"] = "file-cache";
|
|
14
|
+
ProcessingContext["WarmCache"] = "warm-cache";
|
|
15
|
+
})(ProcessingContext || (exports.ProcessingContext = ProcessingContext = {}));
|
|
16
|
+
/**
|
|
17
|
+
* Base handler that removes all images unless explicitly allowed
|
|
18
|
+
*/
|
|
19
|
+
class DefaultImageHandler {
|
|
20
|
+
supportsImages(context) {
|
|
21
|
+
return context === ProcessingContext.FileCache;
|
|
22
|
+
}
|
|
23
|
+
transformMessage(message, context) {
|
|
24
|
+
if (!this.supportsImages(context)) {
|
|
25
|
+
const transformed = Array.isArray(message.content)
|
|
26
|
+
? message.content.filter(block => typeof block === 'string' ? true : block.type !== 'image')
|
|
27
|
+
: message.content;
|
|
28
|
+
return { ...message, content: transformed };
|
|
29
|
+
}
|
|
30
|
+
return message;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.DefaultImageHandler = DefaultImageHandler;
|
|
34
|
+
/**
|
|
35
|
+
* Registry mapping provider names to their image handlers
|
|
36
|
+
*/
|
|
37
|
+
const imageHandlerRegistry = {};
|
|
38
|
+
/**
|
|
39
|
+
* Register a new image handler for a provider
|
|
40
|
+
*/
|
|
41
|
+
function registerImageHandler(provider, handler) {
|
|
42
|
+
imageHandlerRegistry[provider] = handler;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Transform a message for a specific provider and context
|
|
46
|
+
*/
|
|
47
|
+
function transformMessageForProvider(message, provider, context) {
|
|
48
|
+
const handler = imageHandlerRegistry[provider] || new DefaultImageHandler();
|
|
49
|
+
return handler.transformMessage(message, context);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Transform an array of messages for a specific provider and context
|
|
53
|
+
*/
|
|
54
|
+
function transformMessagesForProvider(messages, provider, context) {
|
|
55
|
+
return messages.map(message => transformMessageForProvider(message, provider, context));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=message-image-handling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-image-handling.js","sourceRoot":"","sources":["../src/message-image-handling.ts"],"names":[],"mappings":";;;AAuDA,oDAEC;AAKD,kEAOC;AAKD,oEAMC;AA9ED;;GAEG;AACH,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,6CAAwB,CAAA;IACxB,6CAAwB,CAAA;IACxB,6CAAwB,CAAA;AAC1B,CAAC,EAJW,iBAAiB,iCAAjB,iBAAiB,QAI5B;AAiBD;;GAEG;AACH,MAAa,mBAAmB;IAC9B,cAAc,CAAC,OAA0B;QACvC,OAAO,OAAO,KAAK,iBAAiB,CAAC,SAAS,CAAC;IACjD,CAAC;IAED,gBAAgB,CAAC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mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.DEFAULT_MAX_FILES = void 0;
|
|
29
30
|
exports.getProjectFileTree = getProjectFileTree;
|
|
30
31
|
exports.parseGitignore = parseGitignore;
|
|
31
32
|
exports.getAllFilePaths = getAllFilePaths;
|
|
@@ -37,7 +38,8 @@ const os_1 = __importDefault(require("os"));
|
|
|
37
38
|
const ignore = __importStar(require("ignore"));
|
|
38
39
|
const lodash_1 = require("lodash");
|
|
39
40
|
const constants_1 = require("./constants");
|
|
40
|
-
|
|
41
|
+
exports.DEFAULT_MAX_FILES = 10_000;
|
|
42
|
+
function getProjectFileTree(projectRoot, { maxFiles = exports.DEFAULT_MAX_FILES } = {}) {
|
|
41
43
|
const defaultIgnore = ignore.default();
|
|
42
44
|
for (const pattern of constants_1.DEFAULT_IGNORED_FILES) {
|
|
43
45
|
defaultIgnore.add(pattern);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-file-tree.js","sourceRoot":"","sources":["../src/project-file-tree.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"project-file-tree.js","sourceRoot":"","sources":["../src/project-file-tree.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gDAoFC;AAED,wCA+BC;AAED,0CAUC;AAED,kCAOC;AAED,oDAWC;AAjKD,4CAAmB;AACnB,gDAAuB;AACvB,4CAAmB;AACnB,+CAAgC;AAEhC,mCAA+B;AAC/B,2CAAmD;AAEtC,QAAA,iBAAiB,GAAG,MAAM,CAAA;AAEvC,SAAgB,kBAAkB,CAChC,WAAmB,EACnB,EAAE,QAAQ,GAAG,yBAAiB,KAA4B,EAAE;IAE5D,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;IACtC,KAAK,MAAM,OAAO,IAAI,iCAAqB,EAAE,CAAC;QAC5C,aAAa,CAAC,GAAG,CA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AA;AACjC,CAAC"}
|
|
@@ -5,12 +5,12 @@ export declare const ToolCallSchema: z.ZodObject<{
|
|
|
5
5
|
parameters: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
6
6
|
id: z.ZodString;
|
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
name: string;
|
|
9
8
|
id: string;
|
|
9
|
+
name: string;
|
|
10
10
|
parameters: Record<string, string>;
|
|
11
11
|
}, {
|
|
12
|
-
name: string;
|
|
13
12
|
id: string;
|
|
13
|
+
name: string;
|
|
14
14
|
parameters: Record<string, string>;
|
|
15
15
|
}>;
|
|
16
16
|
export type ToolCall = z.infer<typeof ToolCallSchema>;
|
|
@@ -19,12 +19,12 @@ export declare const ToolResultSchema: z.ZodObject<{
|
|
|
19
19
|
result: z.ZodString;
|
|
20
20
|
id: z.ZodString;
|
|
21
21
|
}, "strip", z.ZodTypeAny, {
|
|
22
|
-
name: string;
|
|
23
22
|
id: string;
|
|
23
|
+
name: string;
|
|
24
24
|
result: string;
|
|
25
25
|
}, {
|
|
26
|
-
name: string;
|
|
27
26
|
id: string;
|
|
27
|
+
name: string;
|
|
28
28
|
result: string;
|
|
29
29
|
}>;
|
|
30
30
|
export type ToolResult = z.infer<typeof ToolResultSchema>;
|
|
@@ -177,16 +177,16 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
177
177
|
}>>;
|
|
178
178
|
}, "strip", z.ZodTypeAny, {
|
|
179
179
|
type: "tool_use";
|
|
180
|
-
name: string;
|
|
181
180
|
id: string;
|
|
181
|
+
name: string;
|
|
182
182
|
input: Record<string, any>;
|
|
183
183
|
cache_control?: {
|
|
184
184
|
type: "ephemeral";
|
|
185
185
|
} | undefined;
|
|
186
186
|
}, {
|
|
187
187
|
type: "tool_use";
|
|
188
|
-
name: string;
|
|
189
188
|
id: string;
|
|
189
|
+
name: string;
|
|
190
190
|
input: Record<string, any>;
|
|
191
191
|
cache_control?: {
|
|
192
192
|
type: "ephemeral";
|
|
@@ -224,12 +224,12 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
224
224
|
data: z.ZodString;
|
|
225
225
|
}, "strip", z.ZodTypeAny, {
|
|
226
226
|
type: "base64";
|
|
227
|
-
data: string;
|
|
228
227
|
media_type: "image/jpeg";
|
|
228
|
+
data: string;
|
|
229
229
|
}, {
|
|
230
230
|
type: "base64";
|
|
231
|
-
data: string;
|
|
232
231
|
media_type: "image/jpeg";
|
|
232
|
+
data: string;
|
|
233
233
|
}>;
|
|
234
234
|
cache_control: z.ZodOptional<z.ZodObject<{
|
|
235
235
|
type: z.ZodLiteral<"ephemeral">;
|
|
@@ -242,8 +242,8 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
242
242
|
type: "image";
|
|
243
243
|
source: {
|
|
244
244
|
type: "base64";
|
|
245
|
-
data: string;
|
|
246
245
|
media_type: "image/jpeg";
|
|
246
|
+
data: string;
|
|
247
247
|
};
|
|
248
248
|
cache_control?: {
|
|
249
249
|
type: "ephemeral";
|
|
@@ -252,14 +252,15 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
252
252
|
type: "image";
|
|
253
253
|
source: {
|
|
254
254
|
type: "base64";
|
|
255
|
-
data: string;
|
|
256
255
|
media_type: "image/jpeg";
|
|
256
|
+
data: string;
|
|
257
257
|
};
|
|
258
258
|
cache_control?: {
|
|
259
259
|
type: "ephemeral";
|
|
260
260
|
} | undefined;
|
|
261
261
|
}>]>, "many">]>;
|
|
262
262
|
}, "strip", z.ZodTypeAny, {
|
|
263
|
+
role: "user" | "assistant";
|
|
263
264
|
content: string | ({
|
|
264
265
|
type: "text";
|
|
265
266
|
text: string;
|
|
@@ -268,8 +269,8 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
268
269
|
} | undefined;
|
|
269
270
|
} | {
|
|
270
271
|
type: "tool_use";
|
|
271
|
-
name: string;
|
|
272
272
|
id: string;
|
|
273
|
+
name: string;
|
|
273
274
|
input: Record<string, any>;
|
|
274
275
|
cache_control?: {
|
|
275
276
|
type: "ephemeral";
|
|
@@ -285,15 +286,15 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
285
286
|
type: "image";
|
|
286
287
|
source: {
|
|
287
288
|
type: "base64";
|
|
288
|
-
data: string;
|
|
289
289
|
media_type: "image/jpeg";
|
|
290
|
+
data: string;
|
|
290
291
|
};
|
|
291
292
|
cache_control?: {
|
|
292
293
|
type: "ephemeral";
|
|
293
294
|
} | undefined;
|
|
294
295
|
})[];
|
|
295
|
-
role: "user" | "assistant";
|
|
296
296
|
}, {
|
|
297
|
+
role: "user" | "assistant";
|
|
297
298
|
content: string | ({
|
|
298
299
|
type: "text";
|
|
299
300
|
text: string;
|
|
@@ -302,8 +303,8 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
302
303
|
} | undefined;
|
|
303
304
|
} | {
|
|
304
305
|
type: "tool_use";
|
|
305
|
-
name: string;
|
|
306
306
|
id: string;
|
|
307
|
+
name: string;
|
|
307
308
|
input: Record<string, any>;
|
|
308
309
|
cache_control?: {
|
|
309
310
|
type: "ephemeral";
|
|
@@ -319,14 +320,13 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
319
320
|
type: "image";
|
|
320
321
|
source: {
|
|
321
322
|
type: "base64";
|
|
322
|
-
data: string;
|
|
323
323
|
media_type: "image/jpeg";
|
|
324
|
+
data: string;
|
|
324
325
|
};
|
|
325
326
|
cache_control?: {
|
|
326
327
|
type: "ephemeral";
|
|
327
328
|
} | undefined;
|
|
328
329
|
})[];
|
|
329
|
-
role: "user" | "assistant";
|
|
330
330
|
}>, "many">;
|
|
331
331
|
}, "strip", z.ZodTypeAny, {
|
|
332
332
|
agentContext: string;
|
|
@@ -358,6 +358,7 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
358
358
|
userKnowledgeFiles?: Record<string, string> | undefined;
|
|
359
359
|
};
|
|
360
360
|
messageHistory: {
|
|
361
|
+
role: "user" | "assistant";
|
|
361
362
|
content: string | ({
|
|
362
363
|
type: "text";
|
|
363
364
|
text: string;
|
|
@@ -366,8 +367,8 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
366
367
|
} | undefined;
|
|
367
368
|
} | {
|
|
368
369
|
type: "tool_use";
|
|
369
|
-
name: string;
|
|
370
370
|
id: string;
|
|
371
|
+
name: string;
|
|
371
372
|
input: Record<string, any>;
|
|
372
373
|
cache_control?: {
|
|
373
374
|
type: "ephemeral";
|
|
@@ -383,14 +384,13 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
383
384
|
type: "image";
|
|
384
385
|
source: {
|
|
385
386
|
type: "base64";
|
|
386
|
-
data: string;
|
|
387
387
|
media_type: "image/jpeg";
|
|
388
|
+
data: string;
|
|
388
389
|
};
|
|
389
390
|
cache_control?: {
|
|
390
391
|
type: "ephemeral";
|
|
391
392
|
} | undefined;
|
|
392
393
|
})[];
|
|
393
|
-
role: "user" | "assistant";
|
|
394
394
|
}[];
|
|
395
395
|
}, {
|
|
396
396
|
agentContext: string;
|
|
@@ -422,6 +422,7 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
422
422
|
userKnowledgeFiles?: Record<string, string> | undefined;
|
|
423
423
|
};
|
|
424
424
|
messageHistory: {
|
|
425
|
+
role: "user" | "assistant";
|
|
425
426
|
content: string | ({
|
|
426
427
|
type: "text";
|
|
427
428
|
text: string;
|
|
@@ -430,8 +431,8 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
430
431
|
} | undefined;
|
|
431
432
|
} | {
|
|
432
433
|
type: "tool_use";
|
|
433
|
-
name: string;
|
|
434
434
|
id: string;
|
|
435
|
+
name: string;
|
|
435
436
|
input: Record<string, any>;
|
|
436
437
|
cache_control?: {
|
|
437
438
|
type: "ephemeral";
|
|
@@ -447,14 +448,13 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
447
448
|
type: "image";
|
|
448
449
|
source: {
|
|
449
450
|
type: "base64";
|
|
450
|
-
data: string;
|
|
451
451
|
media_type: "image/jpeg";
|
|
452
|
+
data: string;
|
|
452
453
|
};
|
|
453
454
|
cache_control?: {
|
|
454
455
|
type: "ephemeral";
|
|
455
456
|
} | undefined;
|
|
456
457
|
})[];
|
|
457
|
-
role: "user" | "assistant";
|
|
458
458
|
}[];
|
|
459
459
|
}>;
|
|
460
460
|
export type AgentState = z.infer<typeof AgentStateSchema>;
|
|
@@ -35,16 +35,16 @@ declare const MessageContentObjectSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
35
35
|
}>>;
|
|
36
36
|
}, "strip", z.ZodTypeAny, {
|
|
37
37
|
type: "tool_use";
|
|
38
|
-
name: string;
|
|
39
38
|
id: string;
|
|
39
|
+
name: string;
|
|
40
40
|
input: Record<string, any>;
|
|
41
41
|
cache_control?: {
|
|
42
42
|
type: "ephemeral";
|
|
43
43
|
} | undefined;
|
|
44
44
|
}, {
|
|
45
45
|
type: "tool_use";
|
|
46
|
-
name: string;
|
|
47
46
|
id: string;
|
|
47
|
+
name: string;
|
|
48
48
|
input: Record<string, any>;
|
|
49
49
|
cache_control?: {
|
|
50
50
|
type: "ephemeral";
|
|
@@ -82,12 +82,12 @@ declare const MessageContentObjectSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
82
82
|
data: z.ZodString;
|
|
83
83
|
}, "strip", z.ZodTypeAny, {
|
|
84
84
|
type: "base64";
|
|
85
|
-
data: string;
|
|
86
85
|
media_type: "image/jpeg";
|
|
86
|
+
data: string;
|
|
87
87
|
}, {
|
|
88
88
|
type: "base64";
|
|
89
|
-
data: string;
|
|
90
89
|
media_type: "image/jpeg";
|
|
90
|
+
data: string;
|
|
91
91
|
}>;
|
|
92
92
|
cache_control: z.ZodOptional<z.ZodObject<{
|
|
93
93
|
type: z.ZodLiteral<"ephemeral">;
|
|
@@ -100,8 +100,8 @@ declare const MessageContentObjectSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
100
100
|
type: "image";
|
|
101
101
|
source: {
|
|
102
102
|
type: "base64";
|
|
103
|
-
data: string;
|
|
104
103
|
media_type: "image/jpeg";
|
|
104
|
+
data: string;
|
|
105
105
|
};
|
|
106
106
|
cache_control?: {
|
|
107
107
|
type: "ephemeral";
|
|
@@ -110,8 +110,8 @@ declare const MessageContentObjectSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
110
110
|
type: "image";
|
|
111
111
|
source: {
|
|
112
112
|
type: "base64";
|
|
113
|
-
data: string;
|
|
114
113
|
media_type: "image/jpeg";
|
|
114
|
+
data: string;
|
|
115
115
|
};
|
|
116
116
|
cache_control?: {
|
|
117
117
|
type: "ephemeral";
|
|
@@ -155,16 +155,16 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
155
155
|
}>>;
|
|
156
156
|
}, "strip", z.ZodTypeAny, {
|
|
157
157
|
type: "tool_use";
|
|
158
|
-
name: string;
|
|
159
158
|
id: string;
|
|
159
|
+
name: string;
|
|
160
160
|
input: Record<string, any>;
|
|
161
161
|
cache_control?: {
|
|
162
162
|
type: "ephemeral";
|
|
163
163
|
} | undefined;
|
|
164
164
|
}, {
|
|
165
165
|
type: "tool_use";
|
|
166
|
-
name: string;
|
|
167
166
|
id: string;
|
|
167
|
+
name: string;
|
|
168
168
|
input: Record<string, any>;
|
|
169
169
|
cache_control?: {
|
|
170
170
|
type: "ephemeral";
|
|
@@ -202,12 +202,12 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
202
202
|
data: z.ZodString;
|
|
203
203
|
}, "strip", z.ZodTypeAny, {
|
|
204
204
|
type: "base64";
|
|
205
|
-
data: string;
|
|
206
205
|
media_type: "image/jpeg";
|
|
206
|
+
data: string;
|
|
207
207
|
}, {
|
|
208
208
|
type: "base64";
|
|
209
|
-
data: string;
|
|
210
209
|
media_type: "image/jpeg";
|
|
210
|
+
data: string;
|
|
211
211
|
}>;
|
|
212
212
|
cache_control: z.ZodOptional<z.ZodObject<{
|
|
213
213
|
type: z.ZodLiteral<"ephemeral">;
|
|
@@ -220,8 +220,8 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
220
220
|
type: "image";
|
|
221
221
|
source: {
|
|
222
222
|
type: "base64";
|
|
223
|
-
data: string;
|
|
224
223
|
media_type: "image/jpeg";
|
|
224
|
+
data: string;
|
|
225
225
|
};
|
|
226
226
|
cache_control?: {
|
|
227
227
|
type: "ephemeral";
|
|
@@ -230,14 +230,15 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
230
230
|
type: "image";
|
|
231
231
|
source: {
|
|
232
232
|
type: "base64";
|
|
233
|
-
data: string;
|
|
234
233
|
media_type: "image/jpeg";
|
|
234
|
+
data: string;
|
|
235
235
|
};
|
|
236
236
|
cache_control?: {
|
|
237
237
|
type: "ephemeral";
|
|
238
238
|
} | undefined;
|
|
239
239
|
}>]>, "many">]>;
|
|
240
240
|
}, "strip", z.ZodTypeAny, {
|
|
241
|
+
role: "user" | "assistant";
|
|
241
242
|
content: string | ({
|
|
242
243
|
type: "text";
|
|
243
244
|
text: string;
|
|
@@ -246,8 +247,8 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
246
247
|
} | undefined;
|
|
247
248
|
} | {
|
|
248
249
|
type: "tool_use";
|
|
249
|
-
name: string;
|
|
250
250
|
id: string;
|
|
251
|
+
name: string;
|
|
251
252
|
input: Record<string, any>;
|
|
252
253
|
cache_control?: {
|
|
253
254
|
type: "ephemeral";
|
|
@@ -263,15 +264,15 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
263
264
|
type: "image";
|
|
264
265
|
source: {
|
|
265
266
|
type: "base64";
|
|
266
|
-
data: string;
|
|
267
267
|
media_type: "image/jpeg";
|
|
268
|
+
data: string;
|
|
268
269
|
};
|
|
269
270
|
cache_control?: {
|
|
270
271
|
type: "ephemeral";
|
|
271
272
|
} | undefined;
|
|
272
273
|
})[];
|
|
273
|
-
role: "user" | "assistant";
|
|
274
274
|
}, {
|
|
275
|
+
role: "user" | "assistant";
|
|
275
276
|
content: string | ({
|
|
276
277
|
type: "text";
|
|
277
278
|
text: string;
|
|
@@ -280,8 +281,8 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
280
281
|
} | undefined;
|
|
281
282
|
} | {
|
|
282
283
|
type: "tool_use";
|
|
283
|
-
name: string;
|
|
284
284
|
id: string;
|
|
285
|
+
name: string;
|
|
285
286
|
input: Record<string, any>;
|
|
286
287
|
cache_control?: {
|
|
287
288
|
type: "ephemeral";
|
|
@@ -297,14 +298,13 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
297
298
|
type: "image";
|
|
298
299
|
source: {
|
|
299
300
|
type: "base64";
|
|
300
|
-
data: string;
|
|
301
301
|
media_type: "image/jpeg";
|
|
302
|
+
data: string;
|
|
302
303
|
};
|
|
303
304
|
cache_control?: {
|
|
304
305
|
type: "ephemeral";
|
|
305
306
|
} | undefined;
|
|
306
307
|
})[];
|
|
307
|
-
role: "user" | "assistant";
|
|
308
308
|
}>;
|
|
309
309
|
export type Message = z.infer<typeof MessageSchema>;
|
|
310
310
|
export type MessageContentObject = z.infer<typeof MessageContentObjectSchema>;
|
|
@@ -38,13 +38,13 @@ export declare const ProjectFileContextSchema: z.ZodObject<{
|
|
|
38
38
|
diffCached: z.ZodString;
|
|
39
39
|
lastCommitMessages: z.ZodString;
|
|
40
40
|
}, "strip", z.ZodTypeAny, {
|
|
41
|
-
diff: string;
|
|
42
41
|
status: string;
|
|
42
|
+
diff: string;
|
|
43
43
|
diffCached: string;
|
|
44
44
|
lastCommitMessages: string;
|
|
45
45
|
}, {
|
|
46
|
-
diff: string;
|
|
47
46
|
status: string;
|
|
47
|
+
diff: string;
|
|
48
48
|
diffCached: string;
|
|
49
49
|
lastCommitMessages: string;
|
|
50
50
|
}>;
|
|
@@ -88,8 +88,8 @@ export declare const ProjectFileContextSchema: z.ZodObject<{
|
|
|
88
88
|
fileTokenScores: Record<string, Record<string, number>>;
|
|
89
89
|
knowledgeFiles: Record<string, string>;
|
|
90
90
|
gitChanges: {
|
|
91
|
-
diff: string;
|
|
92
91
|
status: string;
|
|
92
|
+
diff: string;
|
|
93
93
|
diffCached: string;
|
|
94
94
|
lastCommitMessages: string;
|
|
95
95
|
};
|
|
@@ -114,8 +114,8 @@ export declare const ProjectFileContextSchema: z.ZodObject<{
|
|
|
114
114
|
fileTokenScores: Record<string, Record<string, number>>;
|
|
115
115
|
knowledgeFiles: Record<string, string>;
|
|
116
116
|
gitChanges: {
|
|
117
|
-
diff: string;
|
|
118
117
|
status: string;
|
|
118
|
+
diff: string;
|
|
119
119
|
diffCached: string;
|
|
120
120
|
lastCommitMessages: string;
|
|
121
121
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function processStreamWithTags<T extends string>(stream: AsyncGenerator<T> | ReadableStream<T>, tags: {
|
|
2
|
+
[tagName: string]: {
|
|
3
|
+
attributeNames: string[];
|
|
4
|
+
onTagStart: (attributes: Record<string, string>) => void;
|
|
5
|
+
onTagEnd: (content: string, attributes: Record<string, string>) => boolean;
|
|
6
|
+
};
|
|
7
|
+
}): AsyncGenerator<string, void, unknown>;
|
|
8
|
+
export declare function parseAttributes(attributesString: string, attributeNames: string[]): Record<string, string>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processStreamWithTags = processStreamWithTags;
|
|
4
|
+
exports.parseAttributes = parseAttributes;
|
|
5
|
+
async function* processStreamWithTags(stream, tags) {
|
|
6
|
+
let buffer = '';
|
|
7
|
+
let insideTag = null;
|
|
8
|
+
let currentAttributes = {};
|
|
9
|
+
let streamCompleted = false;
|
|
10
|
+
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
11
|
+
const tagNames = Object.keys(tags);
|
|
12
|
+
const openTagRegex = new RegExp(`<(${tagNames.map(escapeRegExp).join('|')})\\s*([^>]*)>`);
|
|
13
|
+
const closeTagRegex = new RegExp(`</(${tagNames.map(escapeRegExp).join('|')})>`);
|
|
14
|
+
function* parseBuffer(chunk) {
|
|
15
|
+
const isEOF = chunk === undefined;
|
|
16
|
+
if (chunk) {
|
|
17
|
+
yield chunk;
|
|
18
|
+
}
|
|
19
|
+
let didParse = true;
|
|
20
|
+
while (!streamCompleted && didParse) {
|
|
21
|
+
didParse = false;
|
|
22
|
+
if (insideTag === null) {
|
|
23
|
+
// Outside a tag: try to find the next opening tag
|
|
24
|
+
const openMatch = buffer.match(openTagRegex);
|
|
25
|
+
if (openMatch && openMatch.index !== undefined) {
|
|
26
|
+
const [fullMatch, openTag, attributesString] = openMatch;
|
|
27
|
+
const beforeTag = buffer.slice(0, openMatch.index);
|
|
28
|
+
const afterMatchIndex = openMatch.index + fullMatch.length;
|
|
29
|
+
// Move buffer forward
|
|
30
|
+
buffer = buffer.slice(afterMatchIndex);
|
|
31
|
+
// We are now inside this tag
|
|
32
|
+
insideTag = openTag;
|
|
33
|
+
currentAttributes = parseAttributes(attributesString, tags[openTag].attributeNames);
|
|
34
|
+
// Call onTagStart
|
|
35
|
+
tags[openTag].onTagStart(currentAttributes);
|
|
36
|
+
didParse = true;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// No opening tag found. If it's EOF, yield remaining text.
|
|
40
|
+
if (isEOF && buffer.length > 0) {
|
|
41
|
+
buffer = '';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Inside a tag: try to find the closing tag
|
|
47
|
+
const closeMatch = buffer.match(closeTagRegex);
|
|
48
|
+
if (closeMatch && closeMatch.index !== undefined) {
|
|
49
|
+
const [fullMatch, closeTag] = closeMatch;
|
|
50
|
+
const content = buffer.slice(0, closeMatch.index);
|
|
51
|
+
// Move buffer forward
|
|
52
|
+
buffer = buffer.slice(closeMatch.index + fullMatch.length);
|
|
53
|
+
// Close the tag
|
|
54
|
+
const complete = tags[insideTag].onTagEnd(content, currentAttributes);
|
|
55
|
+
insideTag = null;
|
|
56
|
+
currentAttributes = {};
|
|
57
|
+
if (complete) {
|
|
58
|
+
// If onTagEnd signals completion, set streamCompleted and return
|
|
59
|
+
streamCompleted = true;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
didParse = true;
|
|
63
|
+
}
|
|
64
|
+
else if (isEOF) {
|
|
65
|
+
// We reached EOF without finding a closing tag
|
|
66
|
+
// Treat remaining buffer as content and close the tag
|
|
67
|
+
if (buffer.length > 0) {
|
|
68
|
+
const complete = tags[insideTag].onTagEnd(buffer, currentAttributes);
|
|
69
|
+
yield '</' + insideTag + '>';
|
|
70
|
+
buffer = '';
|
|
71
|
+
insideTag = null;
|
|
72
|
+
currentAttributes = {};
|
|
73
|
+
if (complete) {
|
|
74
|
+
streamCompleted = true;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for await (const chunk of stream) {
|
|
83
|
+
if (streamCompleted)
|
|
84
|
+
continue;
|
|
85
|
+
buffer += chunk;
|
|
86
|
+
yield* parseBuffer(chunk);
|
|
87
|
+
}
|
|
88
|
+
if (!streamCompleted) {
|
|
89
|
+
// After the stream ends, try parsing one last time in case there's leftover text
|
|
90
|
+
yield* parseBuffer(undefined);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function parseAttributes(attributesString, attributeNames) {
|
|
94
|
+
const attributes = {};
|
|
95
|
+
const regex = new RegExp(`(${attributeNames.join('|')})="([^"]*)"`, 'g');
|
|
96
|
+
let match;
|
|
97
|
+
while ((match = regex.exec(attributesString)) !== null) {
|
|
98
|
+
attributes[match[1]] = match[2];
|
|
99
|
+
}
|
|
100
|
+
return attributes;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=process-stream.js.map
|