codebuff 1.0.199 → 1.0.200
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/client.d.ts +1 -1
- package/dist/client.js +13 -15
- package/dist/client.js.map +1 -1
- package/dist/code-map/tsconfig.tsbuildinfo +1 -1
- 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/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/types/agent-state.d.ts +12 -12
- package/dist/common/types/message.d.ts +14 -14
- package/dist/common/types/usage.d.ts +2 -2
- package/dist/common/util/credentials.d.ts +2 -2
- package/dist/common/util/lru-cache.d.ts +23 -2
- package/dist/common/util/lru-cache.js +44 -18
- package/dist/common/util/lru-cache.js.map +1 -1
- package/dist/common/util/min-heap.js +2 -2
- package/dist/common/util/min-heap.js.map +1 -1
- 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/util/referral-credits.d.ts +1 -0
- package/dist/common/util/referral-credits.js +48 -0
- package/dist/common/util/referral-credits.js.map +1 -0
- package/dist/fingerprint.js +7 -2
- package/dist/fingerprint.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/menu.js +1 -1
- package/dist/menu.js.map +1 -1
- package/package.json +1 -1
- package/dist/common/logger.d.ts +0 -1
- package/dist/common/logger.js +0 -7
- package/dist/common/logger.js.map +0 -1
- package/dist/common/util/constants.d.ts +0 -1
- package/dist/common/util/constants.js +0 -7
- package/dist/common/util/constants.js.map +0 -1
- package/dist/common/util/helpers.d.ts +0 -1
- package/dist/common/util/helpers.js +0 -6
- package/dist/common/util/helpers.js.map +0 -1
- package/dist/common/util/token-counter.d.ts +0 -3
- package/dist/common/util/token-counter.js +0 -27
- package/dist/common/util/token-counter.js.map +0 -1
|
@@ -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,OAAgB,EAAE,OAA0B;QAC3D,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;gBAChD,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC7B,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAC1D;gBACH,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;YACpB,OAAO,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;QAC9C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAhBD,kDAgBC;AAED;;GAEG;AACH,MAAM,oBAAoB,GAAkC,EAAE,CAAC;AAE/D;;GAEG;AACH,SAAgB,oBAAoB,CAAC,QAAgB,EAAE,OAAsB;IAC3E,oBAAoB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CACzC,OAAgB,EAChB,QAAgB,EAChB,OAA0B;IAE1B,MAAM,OAAO,GAAG,oBAAoB,CAAC,QAAQ,CAAC,IAAI,IAAI,mBAAmB,EAAE,CAAC;IAC5E,OAAO,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,SAAgB,4BAA4B,CAC1C,QAAmB,EACnB,QAAgB,EAChB,OAA0B;IAE1B,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -176,16 +176,16 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
176
176
|
type: "ephemeral";
|
|
177
177
|
}>>;
|
|
178
178
|
}, "strip", z.ZodTypeAny, {
|
|
179
|
-
name: string;
|
|
180
179
|
type: "tool_use";
|
|
180
|
+
name: string;
|
|
181
181
|
id: string;
|
|
182
182
|
input: Record<string, any>;
|
|
183
183
|
cache_control?: {
|
|
184
184
|
type: "ephemeral";
|
|
185
185
|
} | undefined;
|
|
186
186
|
}, {
|
|
187
|
-
name: string;
|
|
188
187
|
type: "tool_use";
|
|
188
|
+
name: string;
|
|
189
189
|
id: string;
|
|
190
190
|
input: Record<string, any>;
|
|
191
191
|
cache_control?: {
|
|
@@ -203,15 +203,15 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
203
203
|
type: "ephemeral";
|
|
204
204
|
}>>;
|
|
205
205
|
}, "strip", z.ZodTypeAny, {
|
|
206
|
-
type: "tool_result";
|
|
207
206
|
content: string;
|
|
207
|
+
type: "tool_result";
|
|
208
208
|
tool_use_id: string;
|
|
209
209
|
cache_control?: {
|
|
210
210
|
type: "ephemeral";
|
|
211
211
|
} | undefined;
|
|
212
212
|
}, {
|
|
213
|
-
type: "tool_result";
|
|
214
213
|
content: string;
|
|
214
|
+
type: "tool_result";
|
|
215
215
|
tool_use_id: string;
|
|
216
216
|
cache_control?: {
|
|
217
217
|
type: "ephemeral";
|
|
@@ -267,16 +267,16 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
267
267
|
type: "ephemeral";
|
|
268
268
|
} | undefined;
|
|
269
269
|
} | {
|
|
270
|
-
name: string;
|
|
271
270
|
type: "tool_use";
|
|
271
|
+
name: string;
|
|
272
272
|
id: string;
|
|
273
273
|
input: Record<string, any>;
|
|
274
274
|
cache_control?: {
|
|
275
275
|
type: "ephemeral";
|
|
276
276
|
} | undefined;
|
|
277
277
|
} | {
|
|
278
|
-
type: "tool_result";
|
|
279
278
|
content: string;
|
|
279
|
+
type: "tool_result";
|
|
280
280
|
tool_use_id: string;
|
|
281
281
|
cache_control?: {
|
|
282
282
|
type: "ephemeral";
|
|
@@ -301,16 +301,16 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
301
301
|
type: "ephemeral";
|
|
302
302
|
} | undefined;
|
|
303
303
|
} | {
|
|
304
|
-
name: string;
|
|
305
304
|
type: "tool_use";
|
|
305
|
+
name: string;
|
|
306
306
|
id: string;
|
|
307
307
|
input: Record<string, any>;
|
|
308
308
|
cache_control?: {
|
|
309
309
|
type: "ephemeral";
|
|
310
310
|
} | undefined;
|
|
311
311
|
} | {
|
|
312
|
-
type: "tool_result";
|
|
313
312
|
content: string;
|
|
313
|
+
type: "tool_result";
|
|
314
314
|
tool_use_id: string;
|
|
315
315
|
cache_control?: {
|
|
316
316
|
type: "ephemeral";
|
|
@@ -366,16 +366,16 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
366
366
|
type: "ephemeral";
|
|
367
367
|
} | undefined;
|
|
368
368
|
} | {
|
|
369
|
-
name: string;
|
|
370
369
|
type: "tool_use";
|
|
370
|
+
name: string;
|
|
371
371
|
id: string;
|
|
372
372
|
input: Record<string, any>;
|
|
373
373
|
cache_control?: {
|
|
374
374
|
type: "ephemeral";
|
|
375
375
|
} | undefined;
|
|
376
376
|
} | {
|
|
377
|
-
type: "tool_result";
|
|
378
377
|
content: string;
|
|
378
|
+
type: "tool_result";
|
|
379
379
|
tool_use_id: string;
|
|
380
380
|
cache_control?: {
|
|
381
381
|
type: "ephemeral";
|
|
@@ -431,16 +431,16 @@ export declare const AgentStateSchema: z.ZodObject<{
|
|
|
431
431
|
type: "ephemeral";
|
|
432
432
|
} | undefined;
|
|
433
433
|
} | {
|
|
434
|
-
name: string;
|
|
435
434
|
type: "tool_use";
|
|
435
|
+
name: string;
|
|
436
436
|
id: string;
|
|
437
437
|
input: Record<string, any>;
|
|
438
438
|
cache_control?: {
|
|
439
439
|
type: "ephemeral";
|
|
440
440
|
} | undefined;
|
|
441
441
|
} | {
|
|
442
|
-
type: "tool_result";
|
|
443
442
|
content: string;
|
|
443
|
+
type: "tool_result";
|
|
444
444
|
tool_use_id: string;
|
|
445
445
|
cache_control?: {
|
|
446
446
|
type: "ephemeral";
|
|
@@ -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";
|
|
@@ -61,15 +61,15 @@ declare const MessageContentObjectSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
61
61
|
type: "ephemeral";
|
|
62
62
|
}>>;
|
|
63
63
|
}, "strip", z.ZodTypeAny, {
|
|
64
|
-
content: string;
|
|
65
64
|
type: "tool_result";
|
|
65
|
+
content: string;
|
|
66
66
|
tool_use_id: string;
|
|
67
67
|
cache_control?: {
|
|
68
68
|
type: "ephemeral";
|
|
69
69
|
} | undefined;
|
|
70
70
|
}, {
|
|
71
|
-
content: string;
|
|
72
71
|
type: "tool_result";
|
|
72
|
+
content: string;
|
|
73
73
|
tool_use_id: string;
|
|
74
74
|
cache_control?: {
|
|
75
75
|
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";
|
|
@@ -181,15 +181,15 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
181
181
|
type: "ephemeral";
|
|
182
182
|
}>>;
|
|
183
183
|
}, "strip", z.ZodTypeAny, {
|
|
184
|
-
content: string;
|
|
185
184
|
type: "tool_result";
|
|
185
|
+
content: string;
|
|
186
186
|
tool_use_id: string;
|
|
187
187
|
cache_control?: {
|
|
188
188
|
type: "ephemeral";
|
|
189
189
|
} | undefined;
|
|
190
190
|
}, {
|
|
191
|
-
content: string;
|
|
192
191
|
type: "tool_result";
|
|
192
|
+
content: string;
|
|
193
193
|
tool_use_id: string;
|
|
194
194
|
cache_control?: {
|
|
195
195
|
type: "ephemeral";
|
|
@@ -238,6 +238,7 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
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,15 +247,15 @@ 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";
|
|
254
255
|
} | undefined;
|
|
255
256
|
} | {
|
|
256
|
-
content: string;
|
|
257
257
|
type: "tool_result";
|
|
258
|
+
content: string;
|
|
258
259
|
tool_use_id: string;
|
|
259
260
|
cache_control?: {
|
|
260
261
|
type: "ephemeral";
|
|
@@ -270,8 +271,8 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
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,15 +281,15 @@ 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";
|
|
288
289
|
} | undefined;
|
|
289
290
|
} | {
|
|
290
|
-
content: string;
|
|
291
291
|
type: "tool_result";
|
|
292
|
+
content: string;
|
|
292
293
|
tool_use_id: string;
|
|
293
294
|
cache_control?: {
|
|
294
295
|
type: "ephemeral";
|
|
@@ -304,7 +305,6 @@ export declare const MessageSchema: z.ZodObject<{
|
|
|
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>;
|
|
@@ -8,17 +8,17 @@ export declare const usageDataSchema: z.ZodObject<{
|
|
|
8
8
|
overageRate: z.ZodNullable<z.ZodNumber>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
10
|
creditsUsed: number;
|
|
11
|
+
overageRate: number | null;
|
|
11
12
|
totalQuota: number;
|
|
12
13
|
remainingCredits: number;
|
|
13
14
|
subscriptionActive: boolean;
|
|
14
15
|
nextQuotaReset: Date;
|
|
15
|
-
overageRate: number | null;
|
|
16
16
|
}, {
|
|
17
17
|
creditsUsed: number;
|
|
18
|
+
overageRate: number | null;
|
|
18
19
|
totalQuota: number;
|
|
19
20
|
remainingCredits: number;
|
|
20
21
|
subscriptionActive: boolean;
|
|
21
22
|
nextQuotaReset: Date;
|
|
22
|
-
overageRate: number | null;
|
|
23
23
|
}>;
|
|
24
24
|
export type UsageData = z.infer<typeof usageDataSchema>;
|
|
@@ -7,15 +7,15 @@ export declare const userSchema: z.ZodObject<{
|
|
|
7
7
|
fingerprintId: z.ZodString;
|
|
8
8
|
fingerprintHash: z.ZodString;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
email: string;
|
|
11
10
|
name: string | null;
|
|
11
|
+
email: string;
|
|
12
12
|
id: string;
|
|
13
13
|
fingerprintId: string;
|
|
14
14
|
authToken: string;
|
|
15
15
|
fingerprintHash: string;
|
|
16
16
|
}, {
|
|
17
|
-
email: string;
|
|
18
17
|
name: string | null;
|
|
18
|
+
email: string;
|
|
19
19
|
id: string;
|
|
20
20
|
fingerprintId: string;
|
|
21
21
|
authToken: string;
|
|
@@ -1,9 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple Least Recently Used (LRU) cache implementation using a Map.
|
|
3
|
+
* It leverages the fact that Map objects maintain insertion order.
|
|
4
|
+
*/
|
|
1
5
|
export declare class LRUCache<K, V> {
|
|
2
6
|
private maxSize;
|
|
3
7
|
private cache;
|
|
4
|
-
private heap;
|
|
5
|
-
private accessCounter;
|
|
6
8
|
constructor(maxSize: number);
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves an item from the cache. If found, marks it as recently used.
|
|
11
|
+
* @param key The key of the item to retrieve.
|
|
12
|
+
* @returns The value associated with the key, or undefined if not found.
|
|
13
|
+
*/
|
|
7
14
|
get(key: K): V | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Adds or updates an item in the cache. If the cache exceeds maxSize,
|
|
17
|
+
* the least recently used item is evicted.
|
|
18
|
+
* @param key The key of the item to set.
|
|
19
|
+
* @param value The value to associate with the key.
|
|
20
|
+
*/
|
|
8
21
|
set(key: K, value: V): void;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the current number of items in the cache.
|
|
24
|
+
*/
|
|
25
|
+
get size(): number;
|
|
26
|
+
/**
|
|
27
|
+
* Clears all items from the cache.
|
|
28
|
+
*/
|
|
29
|
+
clear(): void;
|
|
9
30
|
}
|
|
@@ -1,41 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LRUCache = void 0;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* A simple Least Recently Used (LRU) cache implementation using a Map.
|
|
6
|
+
* It leverages the fact that Map objects maintain insertion order.
|
|
7
|
+
*/
|
|
5
8
|
class LRUCache {
|
|
6
9
|
maxSize;
|
|
7
10
|
cache = new Map();
|
|
8
|
-
heap = new min_heap_1.MinHeap();
|
|
9
|
-
accessCounter = 0;
|
|
10
11
|
constructor(maxSize) {
|
|
11
12
|
this.maxSize = maxSize;
|
|
13
|
+
if (maxSize <= 0) {
|
|
14
|
+
throw new Error('LRUCache maxSize must be a positive number.');
|
|
15
|
+
}
|
|
12
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves an item from the cache. If found, marks it as recently used.
|
|
19
|
+
* @param key The key of the item to retrieve.
|
|
20
|
+
* @returns The value associated with the key, or undefined if not found.
|
|
21
|
+
*/
|
|
13
22
|
get(key) {
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
return
|
|
23
|
+
const value = this.cache.get(key);
|
|
24
|
+
if (value !== undefined) {
|
|
25
|
+
// Mark as recently used by deleting and re-setting
|
|
26
|
+
this.cache.delete(key);
|
|
27
|
+
this.cache.set(key, value);
|
|
28
|
+
return value;
|
|
20
29
|
}
|
|
21
30
|
return undefined;
|
|
22
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Adds or updates an item in the cache. If the cache exceeds maxSize,
|
|
34
|
+
* the least recently used item is evicted.
|
|
35
|
+
* @param key The key of the item to set.
|
|
36
|
+
* @param value The value to associate with the key.
|
|
37
|
+
*/
|
|
23
38
|
set(key, value) {
|
|
24
|
-
// If key exists,
|
|
39
|
+
// If key already exists, delete it first to update its position
|
|
25
40
|
if (this.cache.has(key)) {
|
|
26
|
-
|
|
27
|
-
this.heap.insert(key, -this.accessCounter); // Dummy insert to replace old entry
|
|
41
|
+
this.cache.delete(key);
|
|
28
42
|
}
|
|
29
|
-
//
|
|
43
|
+
// Check if cache is full before adding the new item
|
|
30
44
|
else if (this.cache.size >= this.maxSize) {
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
// Evict the least recently used item (the first item in the Map's iteration order)
|
|
46
|
+
const oldestKey = this.cache.keys().next().value;
|
|
47
|
+
if (oldestKey !== undefined) { // Should always be defined if size >= maxSize > 0
|
|
33
48
|
this.cache.delete(oldestKey);
|
|
34
49
|
}
|
|
35
50
|
}
|
|
36
|
-
|
|
37
|
-
this.cache.set(key,
|
|
38
|
-
|
|
51
|
+
// Add the new item (or re-add the updated item)
|
|
52
|
+
this.cache.set(key, value);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns the current number of items in the cache.
|
|
56
|
+
*/
|
|
57
|
+
get size() {
|
|
58
|
+
return this.cache.size;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Clears all items from the cache.
|
|
62
|
+
*/
|
|
63
|
+
clear() {
|
|
64
|
+
this.cache.clear();
|
|
39
65
|
}
|
|
40
66
|
}
|
|
41
67
|
exports.LRUCache = LRUCache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lru-cache.js","sourceRoot":"","sources":["../../src/util/lru-cache.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"lru-cache.js","sourceRoot":"","sources":["../../src/util/lru-cache.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,MAAa,QAAQ;IAGC;IAFZ,KAAK,GAAG,IAAI,GAAG,EAAQ,CAAA;IAE/B,YAAoB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QACjC,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,GAAM;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACjC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,mDAAmD;YACnD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACtB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YAC1B,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,GAAM,EAAE,KAAQ;QAClB,gEAAgE;QAChE,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACxB,CAAC;QACD,oDAAoD;aAC/C,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACzC,mFAAmF;YACnF,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;YAChD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC,CAAC,kDAAkD;gBAC7E,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YAChC,CAAC;QACH,CAAC;QACD,gDAAgD;QAChD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF;AA7DD,4BA6DC"}
|
|
@@ -57,13 +57,13 @@ class MinHeap {
|
|
|
57
57
|
extractMin() {
|
|
58
58
|
if (this.heap.length === 0)
|
|
59
59
|
return undefined;
|
|
60
|
-
const
|
|
60
|
+
const minItem = this.heap[0].item;
|
|
61
61
|
const last = this.heap.pop();
|
|
62
62
|
if (this.heap.length > 0) {
|
|
63
63
|
this.heap[0] = last;
|
|
64
64
|
this.siftDown(0);
|
|
65
65
|
}
|
|
66
|
-
return
|
|
66
|
+
return minItem;
|
|
67
67
|
}
|
|
68
68
|
get size() {
|
|
69
69
|
return this.heap.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"min-heap.js","sourceRoot":"","sources":["../../src/util/min-heap.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,OAAO;IACV,IAAI,GAAiC,EAAE,CAAA;IAEvC,cAAc,CAAC,KAAa;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACpC,CAAC;IAEO,iBAAiB,CAAC,KAAa;QACrC,OAAO,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;IACtB,CAAC;IAEO,kBAAkB,CAAC,KAAa;QACtC,OAAO,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;IACtB,CAAC;IAEO,IAAI,CAAC,MAAc,EAAE,MAAc;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC9B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACrC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;IAC1B,CAAC;IAEO,MAAM,CAAC,KAAa;QAC1B,OAAO,KAAK,GAAG,CAAC,EAAE,CAAC;YACjB,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;YAC9C,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;gBAC3D,MAAK;YACP,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE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AC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;YACnB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;QAClB,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAA;IACzB,CAAC;CACF;AAnFD,0BAmFC"}
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-stream.js","sourceRoot":"","sources":["../../src/util/process-stream.ts"],"names":[],"mappings":";;AAAA,sDAoHC;AAED,0CAWC;AAjIM,KAAK,SAAS,CAAC,CAAC,qBAAqB,CAC1C,MAA6C,EAC7C,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