codebuff 1.0.301 → 1.0.303
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/chat-storage.d.ts +2 -2
- package/dist/chat-storage.js +23 -29
- package/dist/chat-storage.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +2 -36
- package/dist/code-map/tsconfig.tsbuildinfo +1 -1
- package/dist/common/actions.d.ts +30 -1002
- package/dist/common/browser-actions.d.ts +48 -48
- package/dist/common/types/agent-state.d.ts +5 -261
- package/dist/common/types/agent-state.js +2 -2
- package/dist/common/types/agent-state.js.map +1 -1
- package/dist/common/types/message.d.ts +10 -10
- package/dist/common/util/messages.d.ts +3 -1
- package/dist/common/util/messages.js +15 -3
- package/dist/common/util/messages.js.map +1 -1
- package/dist/common/websockets/websocket-schema.d.ts +74 -1642
- package/dist/index.js +4 -22
- package/dist/project-files.d.ts +1 -1
- package/dist/project-files.js +4 -1
- package/dist/project-files.js.map +1 -1
- package/dist/tool-handlers.js +5 -3
- package/dist/tool-handlers.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli-handlers/initialization-flow.d.ts +0 -1
- package/dist/cli-handlers/initialization-flow.js +0 -24
- package/dist/cli-handlers/initialization-flow.js.map +0 -1
- package/dist/cli-modules/command-processor.d.ts +0 -2
- package/dist/cli-modules/command-processor.js +0 -112
- package/dist/cli-modules/command-processor.js.map +0 -1
- package/dist/cli-modules/input-handler.d.ts +0 -4
- package/dist/cli-modules/input-handler.js +0 -75
- package/dist/cli-modules/input-handler.js.map +0 -1
- package/dist/cli-modules/readline-handler.d.ts +0 -11
- package/dist/cli-modules/readline-handler.js +0 -158
- package/dist/cli-modules/readline-handler.js.map +0 -1
- package/dist/cli-modules/signal-handler.d.ts +0 -7
- package/dist/cli-modules/signal-handler.js +0 -128
- package/dist/cli-modules/signal-handler.js.map +0 -1
- package/dist/cli-modules/types.d.ts +0 -51
- package/dist/cli-modules/types.js +0 -3
- package/dist/cli-modules/types.js.map +0 -1
- package/dist/cli-modules/websocket-handler.d.ts +0 -16
- package/dist/cli-modules/websocket-handler.js +0 -53
- package/dist/cli-modules/websocket-handler.js.map +0 -1
- package/dist/code-map/__mocks__/tree-sitter-typescript.d.ts +0 -12
- package/dist/code-map/__mocks__/tree-sitter-typescript.d.ts.map +0 -1
- package/dist/code-map/__mocks__/tree-sitter-typescript.js +0 -14
- package/dist/code-map/__mocks__/tree-sitter-typescript.js.map +0 -1
- package/dist/code-map/__mocks__/wasm-mock.d.ts +0 -2
- package/dist/code-map/__mocks__/wasm-mock.d.ts.map +0 -1
- package/dist/code-map/__mocks__/wasm-mock.js +0 -3
- package/dist/code-map/__mocks__/wasm-mock.js.map +0 -1
- package/dist/code-map/__tests__/parse.test.d.ts +0 -2
- package/dist/code-map/__tests__/parse.test.d.ts.map +0 -1
- package/dist/code-map/__tests__/parse.test.js +0 -231
- package/dist/code-map/__tests__/parse.test.js.map +0 -1
- package/dist/code-map/__tests__/test-langs/consumer.d.ts +0 -2
- package/dist/code-map/__tests__/test-langs/consumer.d.ts.map +0 -1
- package/dist/code-map/__tests__/test-langs/consumer.js +0 -6
- package/dist/code-map/__tests__/test-langs/consumer.js.map +0 -1
- package/dist/code-map/__tests__/test-langs/empty.d.ts +0 -1
- package/dist/code-map/__tests__/test-langs/empty.d.ts.map +0 -1
- package/dist/code-map/__tests__/test-langs/empty.js +0 -2
- package/dist/code-map/__tests__/test-langs/empty.js.map +0 -1
- package/dist/code-map/__tests__/test-langs/test.d.ts +0 -12
- package/dist/code-map/__tests__/test-langs/test.d.ts.map +0 -1
- package/dist/code-map/__tests__/test-langs/test.js +0 -23
- package/dist/code-map/__tests__/test-langs/test.js.map +0 -1
- package/dist/code-map/__tests__/test-langs/unused.d.ts +0 -2
- package/dist/code-map/__tests__/test-langs/unused.d.ts.map +0 -1
- package/dist/code-map/__tests__/test-langs/unused.js +0 -7
- package/dist/code-map/__tests__/test-langs/unused.js.map +0 -1
- package/dist/code-map/__tests__/test-langs/utils1.d.ts +0 -2
- package/dist/code-map/__tests__/test-langs/utils1.d.ts.map +0 -1
- package/dist/code-map/__tests__/test-langs/utils1.js +0 -7
- package/dist/code-map/__tests__/test-langs/utils1.js.map +0 -1
- package/dist/code-map/__tests__/test-langs/utils2.d.ts +0 -2
- package/dist/code-map/__tests__/test-langs/utils2.d.ts.map +0 -1
- package/dist/code-map/__tests__/test-langs/utils2.js +0 -8
- package/dist/code-map/__tests__/test-langs/utils2.js.map +0 -1
- package/dist/code-map/__tests__/tree-sitter-minimal.test.d.ts +0 -2
- package/dist/code-map/__tests__/tree-sitter-minimal.test.d.ts.map +0 -1
- package/dist/code-map/__tests__/tree-sitter-minimal.test.js +0 -79
- package/dist/code-map/__tests__/tree-sitter-minimal.test.js.map +0 -1
- package/dist/code-map/jest.config.d.ts +0 -4
- package/dist/code-map/jest.config.d.ts.map +0 -1
- package/dist/code-map/jest.config.js +0 -18
- package/dist/code-map/jest.config.js.map +0 -1
- package/dist/code-map/parse.test.d.ts +0 -2
- package/dist/code-map/parse.test.d.ts.map +0 -1
- package/dist/code-map/parse.test.js +0 -218
- package/dist/code-map/parse.test.js.map +0 -1
- package/dist/code-map/scripts/tree-sitter-test.cjs +0 -27
- package/dist/code-map/scripts/tree-sitter-test.cjs.map +0 -1
- package/dist/code-map/scripts/tree-sitter-test.d.cts +0 -2
- package/dist/code-map/scripts/tree-sitter-test.d.cts.map +0 -1
- package/dist/code-map/scripts/tree-sitter-test.d.ts +0 -2
- package/dist/code-map/scripts/tree-sitter-test.d.ts.map +0 -1
- package/dist/code-map/scripts/tree-sitter-test.js +0 -54
- package/dist/code-map/scripts/tree-sitter-test.js.map +0 -1
- package/dist/code-map/test-parser.d.ts +0 -2
- package/dist/code-map/test-parser.d.ts.map +0 -1
- package/dist/code-map/test-parser.js +0 -42
- package/dist/code-map/test-parser.js.map +0 -1
- package/dist/common/bigquery/client.d.ts +0 -15
- package/dist/common/bigquery/client.js +0 -265
- package/dist/common/bigquery/client.js.map +0 -1
- package/dist/common/bigquery/schema.d.ts +0 -55
- package/dist/common/bigquery/schema.js +0 -24
- package/dist/common/bigquery/schema.js.map +0 -1
- package/dist/common/util/file-metadata.d.ts +0 -9
- package/dist/common/util/file-metadata.js +0 -24
- package/dist/common/util/file-metadata.js.map +0 -1
|
@@ -6,12 +6,12 @@ export declare const ToolCallSchema: z.ZodObject<{
|
|
|
6
6
|
id: z.ZodString;
|
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
|
8
8
|
name: string;
|
|
9
|
-
id: string;
|
|
10
9
|
parameters: Record<string, string>;
|
|
10
|
+
id: string;
|
|
11
11
|
}, {
|
|
12
12
|
name: string;
|
|
13
|
-
id: string;
|
|
14
13
|
parameters: Record<string, string>;
|
|
14
|
+
id: string;
|
|
15
15
|
}>;
|
|
16
16
|
export type ToolCall = z.infer<typeof ToolCallSchema>;
|
|
17
17
|
export declare const ToolResultSchema: z.ZodObject<{
|
|
@@ -142,195 +142,7 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
142
142
|
content: string;
|
|
143
143
|
}[][] | undefined;
|
|
144
144
|
}>;
|
|
145
|
-
messageHistory: z.ZodArray<z.
|
|
146
|
-
role: z.ZodUnion<[z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
|
|
147
|
-
content: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
148
|
-
type: z.ZodLiteral<"text">;
|
|
149
|
-
text: z.ZodString;
|
|
150
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
151
|
-
type: z.ZodLiteral<"ephemeral">;
|
|
152
|
-
}, "strip", z.ZodTypeAny, {
|
|
153
|
-
type: "ephemeral";
|
|
154
|
-
}, {
|
|
155
|
-
type: "ephemeral";
|
|
156
|
-
}>>;
|
|
157
|
-
}, "strip", z.ZodTypeAny, {
|
|
158
|
-
type: "text";
|
|
159
|
-
text: string;
|
|
160
|
-
cache_control?: {
|
|
161
|
-
type: "ephemeral";
|
|
162
|
-
} | undefined;
|
|
163
|
-
}, {
|
|
164
|
-
type: "text";
|
|
165
|
-
text: string;
|
|
166
|
-
cache_control?: {
|
|
167
|
-
type: "ephemeral";
|
|
168
|
-
} | undefined;
|
|
169
|
-
}>, z.ZodObject<{
|
|
170
|
-
type: z.ZodLiteral<"tool_use">;
|
|
171
|
-
id: z.ZodString;
|
|
172
|
-
name: z.ZodString;
|
|
173
|
-
input: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
174
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
175
|
-
type: z.ZodLiteral<"ephemeral">;
|
|
176
|
-
}, "strip", z.ZodTypeAny, {
|
|
177
|
-
type: "ephemeral";
|
|
178
|
-
}, {
|
|
179
|
-
type: "ephemeral";
|
|
180
|
-
}>>;
|
|
181
|
-
}, "strip", z.ZodTypeAny, {
|
|
182
|
-
type: "tool_use";
|
|
183
|
-
name: string;
|
|
184
|
-
id: string;
|
|
185
|
-
input: Record<string, any>;
|
|
186
|
-
cache_control?: {
|
|
187
|
-
type: "ephemeral";
|
|
188
|
-
} | undefined;
|
|
189
|
-
}, {
|
|
190
|
-
type: "tool_use";
|
|
191
|
-
name: string;
|
|
192
|
-
id: string;
|
|
193
|
-
input: Record<string, any>;
|
|
194
|
-
cache_control?: {
|
|
195
|
-
type: "ephemeral";
|
|
196
|
-
} | undefined;
|
|
197
|
-
}>, z.ZodObject<{
|
|
198
|
-
type: z.ZodLiteral<"tool_result">;
|
|
199
|
-
tool_use_id: z.ZodString;
|
|
200
|
-
content: z.ZodString;
|
|
201
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
202
|
-
type: z.ZodLiteral<"ephemeral">;
|
|
203
|
-
}, "strip", z.ZodTypeAny, {
|
|
204
|
-
type: "ephemeral";
|
|
205
|
-
}, {
|
|
206
|
-
type: "ephemeral";
|
|
207
|
-
}>>;
|
|
208
|
-
}, "strip", z.ZodTypeAny, {
|
|
209
|
-
type: "tool_result";
|
|
210
|
-
content: string;
|
|
211
|
-
tool_use_id: string;
|
|
212
|
-
cache_control?: {
|
|
213
|
-
type: "ephemeral";
|
|
214
|
-
} | undefined;
|
|
215
|
-
}, {
|
|
216
|
-
type: "tool_result";
|
|
217
|
-
content: string;
|
|
218
|
-
tool_use_id: string;
|
|
219
|
-
cache_control?: {
|
|
220
|
-
type: "ephemeral";
|
|
221
|
-
} | undefined;
|
|
222
|
-
}>, z.ZodObject<{
|
|
223
|
-
type: z.ZodLiteral<"image">;
|
|
224
|
-
source: z.ZodObject<{
|
|
225
|
-
type: z.ZodLiteral<"base64">;
|
|
226
|
-
media_type: z.ZodLiteral<"image/jpeg">;
|
|
227
|
-
data: z.ZodString;
|
|
228
|
-
}, "strip", z.ZodTypeAny, {
|
|
229
|
-
type: "base64";
|
|
230
|
-
media_type: "image/jpeg";
|
|
231
|
-
data: string;
|
|
232
|
-
}, {
|
|
233
|
-
type: "base64";
|
|
234
|
-
media_type: "image/jpeg";
|
|
235
|
-
data: string;
|
|
236
|
-
}>;
|
|
237
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
238
|
-
type: z.ZodLiteral<"ephemeral">;
|
|
239
|
-
}, "strip", z.ZodTypeAny, {
|
|
240
|
-
type: "ephemeral";
|
|
241
|
-
}, {
|
|
242
|
-
type: "ephemeral";
|
|
243
|
-
}>>;
|
|
244
|
-
}, "strip", z.ZodTypeAny, {
|
|
245
|
-
type: "image";
|
|
246
|
-
source: {
|
|
247
|
-
type: "base64";
|
|
248
|
-
media_type: "image/jpeg";
|
|
249
|
-
data: string;
|
|
250
|
-
};
|
|
251
|
-
cache_control?: {
|
|
252
|
-
type: "ephemeral";
|
|
253
|
-
} | undefined;
|
|
254
|
-
}, {
|
|
255
|
-
type: "image";
|
|
256
|
-
source: {
|
|
257
|
-
type: "base64";
|
|
258
|
-
media_type: "image/jpeg";
|
|
259
|
-
data: string;
|
|
260
|
-
};
|
|
261
|
-
cache_control?: {
|
|
262
|
-
type: "ephemeral";
|
|
263
|
-
} | undefined;
|
|
264
|
-
}>]>, "many">]>;
|
|
265
|
-
}, "strip", z.ZodTypeAny, {
|
|
266
|
-
content: string | ({
|
|
267
|
-
type: "text";
|
|
268
|
-
text: string;
|
|
269
|
-
cache_control?: {
|
|
270
|
-
type: "ephemeral";
|
|
271
|
-
} | undefined;
|
|
272
|
-
} | {
|
|
273
|
-
type: "tool_use";
|
|
274
|
-
name: string;
|
|
275
|
-
id: string;
|
|
276
|
-
input: Record<string, any>;
|
|
277
|
-
cache_control?: {
|
|
278
|
-
type: "ephemeral";
|
|
279
|
-
} | undefined;
|
|
280
|
-
} | {
|
|
281
|
-
type: "tool_result";
|
|
282
|
-
content: string;
|
|
283
|
-
tool_use_id: string;
|
|
284
|
-
cache_control?: {
|
|
285
|
-
type: "ephemeral";
|
|
286
|
-
} | undefined;
|
|
287
|
-
} | {
|
|
288
|
-
type: "image";
|
|
289
|
-
source: {
|
|
290
|
-
type: "base64";
|
|
291
|
-
media_type: "image/jpeg";
|
|
292
|
-
data: string;
|
|
293
|
-
};
|
|
294
|
-
cache_control?: {
|
|
295
|
-
type: "ephemeral";
|
|
296
|
-
} | undefined;
|
|
297
|
-
})[];
|
|
298
|
-
role: "user" | "assistant";
|
|
299
|
-
}, {
|
|
300
|
-
content: string | ({
|
|
301
|
-
type: "text";
|
|
302
|
-
text: string;
|
|
303
|
-
cache_control?: {
|
|
304
|
-
type: "ephemeral";
|
|
305
|
-
} | undefined;
|
|
306
|
-
} | {
|
|
307
|
-
type: "tool_use";
|
|
308
|
-
name: string;
|
|
309
|
-
id: string;
|
|
310
|
-
input: Record<string, any>;
|
|
311
|
-
cache_control?: {
|
|
312
|
-
type: "ephemeral";
|
|
313
|
-
} | undefined;
|
|
314
|
-
} | {
|
|
315
|
-
type: "tool_result";
|
|
316
|
-
content: string;
|
|
317
|
-
tool_use_id: string;
|
|
318
|
-
cache_control?: {
|
|
319
|
-
type: "ephemeral";
|
|
320
|
-
} | undefined;
|
|
321
|
-
} | {
|
|
322
|
-
type: "image";
|
|
323
|
-
source: {
|
|
324
|
-
type: "base64";
|
|
325
|
-
media_type: "image/jpeg";
|
|
326
|
-
data: string;
|
|
327
|
-
};
|
|
328
|
-
cache_control?: {
|
|
329
|
-
type: "ephemeral";
|
|
330
|
-
} | undefined;
|
|
331
|
-
})[];
|
|
332
|
-
role: "user" | "assistant";
|
|
333
|
-
}>, "many">;
|
|
145
|
+
messageHistory: z.ZodArray<z.ZodType<import("ai").CoreMessage, z.ZodTypeDef, import("ai").CoreMessage>, "many">;
|
|
334
146
|
consecutiveAssistantMessages: z.ZodOptional<z.ZodNumber>;
|
|
335
147
|
}, "strip", z.ZodTypeAny, {
|
|
336
148
|
agentContext: string;
|
|
@@ -362,41 +174,7 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
362
174
|
content: string;
|
|
363
175
|
}[][] | undefined;
|
|
364
176
|
};
|
|
365
|
-
messageHistory:
|
|
366
|
-
content: string | ({
|
|
367
|
-
type: "text";
|
|
368
|
-
text: string;
|
|
369
|
-
cache_control?: {
|
|
370
|
-
type: "ephemeral";
|
|
371
|
-
} | undefined;
|
|
372
|
-
} | {
|
|
373
|
-
type: "tool_use";
|
|
374
|
-
name: string;
|
|
375
|
-
id: string;
|
|
376
|
-
input: Record<string, any>;
|
|
377
|
-
cache_control?: {
|
|
378
|
-
type: "ephemeral";
|
|
379
|
-
} | undefined;
|
|
380
|
-
} | {
|
|
381
|
-
type: "tool_result";
|
|
382
|
-
content: string;
|
|
383
|
-
tool_use_id: string;
|
|
384
|
-
cache_control?: {
|
|
385
|
-
type: "ephemeral";
|
|
386
|
-
} | undefined;
|
|
387
|
-
} | {
|
|
388
|
-
type: "image";
|
|
389
|
-
source: {
|
|
390
|
-
type: "base64";
|
|
391
|
-
media_type: "image/jpeg";
|
|
392
|
-
data: string;
|
|
393
|
-
};
|
|
394
|
-
cache_control?: {
|
|
395
|
-
type: "ephemeral";
|
|
396
|
-
} | undefined;
|
|
397
|
-
})[];
|
|
398
|
-
role: "user" | "assistant";
|
|
399
|
-
}[];
|
|
177
|
+
messageHistory: import("ai").CoreMessage[];
|
|
400
178
|
consecutiveAssistantMessages?: number | undefined;
|
|
401
179
|
}, {
|
|
402
180
|
agentContext: string;
|
|
@@ -428,41 +206,7 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
428
206
|
content: string;
|
|
429
207
|
}[][] | undefined;
|
|
430
208
|
};
|
|
431
|
-
messageHistory:
|
|
432
|
-
content: string | ({
|
|
433
|
-
type: "text";
|
|
434
|
-
text: string;
|
|
435
|
-
cache_control?: {
|
|
436
|
-
type: "ephemeral";
|
|
437
|
-
} | undefined;
|
|
438
|
-
} | {
|
|
439
|
-
type: "tool_use";
|
|
440
|
-
name: string;
|
|
441
|
-
id: string;
|
|
442
|
-
input: Record<string, any>;
|
|
443
|
-
cache_control?: {
|
|
444
|
-
type: "ephemeral";
|
|
445
|
-
} | undefined;
|
|
446
|
-
} | {
|
|
447
|
-
type: "tool_result";
|
|
448
|
-
content: string;
|
|
449
|
-
tool_use_id: string;
|
|
450
|
-
cache_control?: {
|
|
451
|
-
type: "ephemeral";
|
|
452
|
-
} | undefined;
|
|
453
|
-
} | {
|
|
454
|
-
type: "image";
|
|
455
|
-
source: {
|
|
456
|
-
type: "base64";
|
|
457
|
-
media_type: "image/jpeg";
|
|
458
|
-
data: string;
|
|
459
|
-
};
|
|
460
|
-
cache_control?: {
|
|
461
|
-
type: "ephemeral";
|
|
462
|
-
} | undefined;
|
|
463
|
-
})[];
|
|
464
|
-
role: "user" | "assistant";
|
|
465
|
-
}[];
|
|
209
|
+
messageHistory: import("ai").CoreMessage[];
|
|
466
210
|
consecutiveAssistantMessages?: number | undefined;
|
|
467
211
|
}>;
|
|
468
212
|
export type AgentState = z.infer<typeof AgentStateSchema>;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AgentStateSchema = exports.ToolResultSchema = exports.ToolCallSchema = void 0;
|
|
4
4
|
exports.getInitialAgentState = getInitialAgentState;
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
|
+
const ai_1 = require("ai");
|
|
6
7
|
const file_1 = require("../util/file");
|
|
7
|
-
const message_1 = require("./message");
|
|
8
8
|
exports.ToolCallSchema = zod_1.z.object({
|
|
9
9
|
name: zod_1.z.string(),
|
|
10
10
|
parameters: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
|
|
@@ -18,7 +18,7 @@ exports.ToolResultSchema = zod_1.z.object({
|
|
|
18
18
|
exports.AgentStateSchema = zod_1.z.object({
|
|
19
19
|
agentContext: zod_1.z.string(),
|
|
20
20
|
fileContext: file_1.ProjectFileContextSchema,
|
|
21
|
-
messageHistory: zod_1.z.array(
|
|
21
|
+
messageHistory: zod_1.z.array(ai_1.coreMessageSchema),
|
|
22
22
|
consecutiveAssistantMessages: zod_1.z.number().optional(),
|
|
23
23
|
});
|
|
24
24
|
function getInitialAgentState(fileContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-state.js","sourceRoot":"","sources":["../../src/types/agent-state.ts"],"names":[],"mappings":";;;AA0BA,oDASC;AAnCD,6BAAuB;AAEvB,
|
|
1
|
+
{"version":3,"file":"agent-state.js","sourceRoot":"","sources":["../../src/types/agent-state.ts"],"names":[],"mappings":";;;AA0BA,oDASC;AAnCD,6BAAuB;AAEvB,2BAAsC;AACtC,uCAA2E;AAE9D,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC;IAC5C,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;CACf,CAAC,CAAA;AAEW,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;CACf,CAAC,CAAA;AAGW,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;IACxB,WAAW,EAAE,+BAAwB;IACrC,cAAc,EAAE,OAAC,CAAC,KAAK,CAAC,sBAAiB,CAAC;IAC1C,4BAA4B,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACpD,CAAC,CAAA;AAGF,SAAgB,oBAAoB,CAClC,WAA+B;IAE/B,OAAO;QACL,YAAY,EAAE,EAAE;QAChB,cAAc,EAAE,EAAE;QAClB,WAAW;QACX,4BAA4B,EAAE,CAAC;KAChC,CAAA;AACH,CAAC"}
|
|
@@ -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
|
-
media_type: "image/jpeg";
|
|
86
85
|
data: string;
|
|
86
|
+
media_type: "image/jpeg";
|
|
87
87
|
}, {
|
|
88
88
|
type: "base64";
|
|
89
|
-
media_type: "image/jpeg";
|
|
90
89
|
data: string;
|
|
90
|
+
media_type: "image/jpeg";
|
|
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
|
-
media_type: "image/jpeg";
|
|
104
103
|
data: string;
|
|
104
|
+
media_type: "image/jpeg";
|
|
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
|
-
media_type: "image/jpeg";
|
|
114
113
|
data: string;
|
|
114
|
+
media_type: "image/jpeg";
|
|
115
115
|
};
|
|
116
116
|
cache_control?: {
|
|
117
117
|
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
|
-
media_type: "image/jpeg";
|
|
206
205
|
data: string;
|
|
206
|
+
media_type: "image/jpeg";
|
|
207
207
|
}, {
|
|
208
208
|
type: "base64";
|
|
209
|
-
media_type: "image/jpeg";
|
|
210
209
|
data: string;
|
|
210
|
+
media_type: "image/jpeg";
|
|
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
|
-
media_type: "image/jpeg";
|
|
224
223
|
data: string;
|
|
224
|
+
media_type: "image/jpeg";
|
|
225
225
|
};
|
|
226
226
|
cache_control?: {
|
|
227
227
|
type: "ephemeral";
|
|
@@ -230,8 +230,8 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
230
230
|
type: "image";
|
|
231
231
|
source: {
|
|
232
232
|
type: "base64";
|
|
233
|
-
media_type: "image/jpeg";
|
|
234
233
|
data: string;
|
|
234
|
+
media_type: "image/jpeg";
|
|
235
235
|
};
|
|
236
236
|
cache_control?: {
|
|
237
237
|
type: "ephemeral";
|
|
@@ -263,8 +263,8 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
263
263
|
type: "image";
|
|
264
264
|
source: {
|
|
265
265
|
type: "base64";
|
|
266
|
-
media_type: "image/jpeg";
|
|
267
266
|
data: string;
|
|
267
|
+
media_type: "image/jpeg";
|
|
268
268
|
};
|
|
269
269
|
cache_control?: {
|
|
270
270
|
type: "ephemeral";
|
|
@@ -297,8 +297,8 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
297
297
|
type: "image";
|
|
298
298
|
source: {
|
|
299
299
|
type: "base64";
|
|
300
|
-
media_type: "image/jpeg";
|
|
301
300
|
data: string;
|
|
301
|
+
media_type: "image/jpeg";
|
|
302
302
|
};
|
|
303
303
|
cache_control?: {
|
|
304
304
|
type: "ephemeral";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { CoreMessage } from 'ai';
|
|
1
2
|
import { Message } from '../types/message';
|
|
2
3
|
/**
|
|
3
4
|
* Limits the total number of screenshots across all messages to maxCount,
|
|
4
5
|
* keeping only the most recent ones.
|
|
5
6
|
*/
|
|
6
7
|
export declare function limitScreenshots(messages: Message[], maxCount: number): Message[];
|
|
7
|
-
export declare function toContentString(msg:
|
|
8
|
+
export declare function toContentString(msg: CoreMessage): string;
|
|
9
|
+
export declare function withCacheControlCore(msg: CoreMessage): CoreMessage;
|
|
8
10
|
export declare function withCacheControl(msg: Message): Message;
|
|
9
11
|
export declare function removeCache(messages: Message[]): Message[];
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.limitScreenshots = limitScreenshots;
|
|
4
4
|
exports.toContentString = toContentString;
|
|
5
|
+
exports.withCacheControlCore = withCacheControlCore;
|
|
5
6
|
exports.withCacheControl = withCacheControl;
|
|
6
7
|
exports.removeCache = removeCache;
|
|
7
8
|
/**
|
|
@@ -30,6 +31,17 @@ function toContentString(msg) {
|
|
|
30
31
|
return content;
|
|
31
32
|
return content.map((item) => item?.text ?? '').join('\n');
|
|
32
33
|
}
|
|
34
|
+
function withCacheControlCore(msg) {
|
|
35
|
+
const message = { ...msg };
|
|
36
|
+
if (!message.providerOptions) {
|
|
37
|
+
message.providerOptions = {};
|
|
38
|
+
}
|
|
39
|
+
if (!message.providerOptions.anthropic) {
|
|
40
|
+
message.providerOptions.anthropic = {};
|
|
41
|
+
}
|
|
42
|
+
message.providerOptions.anthropic.cacheControl = { type: 'ephemeral' };
|
|
43
|
+
return message;
|
|
44
|
+
}
|
|
33
45
|
function withCacheControl(msg) {
|
|
34
46
|
if (typeof msg.content === 'string') {
|
|
35
47
|
return {
|
|
@@ -53,14 +65,14 @@ function withCacheControl(msg) {
|
|
|
53
65
|
}
|
|
54
66
|
}
|
|
55
67
|
function removeCache(messages) {
|
|
56
|
-
return messages.map(msg => {
|
|
68
|
+
return messages.map((msg) => {
|
|
57
69
|
if (typeof msg.content === 'object' && Array.isArray(msg.content)) {
|
|
58
70
|
return {
|
|
59
71
|
...msg,
|
|
60
|
-
content: msg.content.map(item => {
|
|
72
|
+
content: msg.content.map((item) => {
|
|
61
73
|
const { cache_control, ...rest } = item;
|
|
62
74
|
return rest;
|
|
63
|
-
})
|
|
75
|
+
}),
|
|
64
76
|
};
|
|
65
77
|
}
|
|
66
78
|
return msg;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/util/messages.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/util/messages.ts"],"names":[],"mappings":";;AAYA,4CA+BC;AAED,0CAIC;AAED,oDAUC;AAED,4CAsBC;AAED,kCAaC;AA5FD;;;GAGG;AACH,SAAgB,gBAAgB,CAC9B,QAAmB,EACnB,QAAgB;IAEhB,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CACnD,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;QACxB,CAAC,CAAC,GAAG,CAAC,OAAO;aACR,GAAG,CAAC,CAAC,IAAI,EAAE,U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