@animalabs/membrane 0.5.51 → 0.5.53
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/context/index.d.ts +12 -0
- package/dist/context/index.js +11 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/process.d.ts +43 -0
- package/dist/context/process.js +381 -0
- package/dist/context/process.js.map +1 -0
- package/dist/context/types.d.ts +164 -0
- package/dist/context/types.js +61 -0
- package/dist/context/types.js.map +1 -0
- package/dist/formatters/anthropic-xml.d.ts +63 -0
- package/dist/formatters/anthropic-xml.js +417 -0
- package/dist/formatters/anthropic-xml.js.map +1 -0
- package/dist/formatters/completions.d.ts +68 -0
- package/dist/formatters/completions.js +261 -0
- package/dist/formatters/completions.js.map +1 -0
- package/dist/formatters/index.d.ts +10 -0
- package/dist/formatters/index.d.ts.map +1 -1
- package/dist/formatters/index.js +8 -0
- package/dist/formatters/index.js.map +1 -0
- package/dist/formatters/native.d.ts +35 -0
- package/dist/formatters/native.d.ts.map +1 -1
- package/dist/formatters/native.js +346 -0
- package/dist/formatters/native.js.map +1 -0
- package/dist/formatters/normalize-tool-pairs.d.ts +75 -0
- package/dist/formatters/normalize-tool-pairs.d.ts.map +1 -0
- package/dist/formatters/normalize-tool-pairs.js +498 -0
- package/dist/formatters/normalize-tool-pairs.js.map +1 -0
- package/dist/formatters/types.d.ts +222 -0
- package/dist/formatters/types.d.ts.map +1 -1
- package/dist/formatters/types.js +7 -0
- package/dist/formatters/types.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/membrane.d.ts +155 -0
- package/dist/providers/anthropic.d.ts +36 -0
- package/dist/providers/bedrock.d.ts +43 -0
- package/dist/providers/gemini.d.ts +68 -0
- package/dist/providers/gemini.js +538 -0
- package/dist/providers/gemini.js.map +1 -0
- package/dist/providers/index.d.ts +13 -0
- package/dist/providers/index.js +13 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/mock.d.ts +90 -0
- package/dist/providers/mock.d.ts.map +1 -0
- package/dist/providers/mock.js +210 -0
- package/dist/providers/mock.js.map +1 -0
- package/dist/providers/openai-compatible.d.ts +82 -0
- package/dist/providers/openai-compatible.js +480 -0
- package/dist/providers/openai-compatible.js.map +1 -0
- package/dist/providers/openai-completions.d.ts +89 -0
- package/dist/providers/openai-completions.js +347 -0
- package/dist/providers/openai-completions.js.map +1 -0
- package/dist/providers/openai-responses.d.ts +77 -0
- package/dist/providers/openai-responses.js +333 -0
- package/dist/providers/openai-responses.js.map +1 -0
- package/dist/providers/openai.d.ts +77 -0
- package/dist/providers/openai.js +533 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/openrouter.d.ts +82 -0
- package/dist/providers/openrouter.js +556 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/providers/utils.d.ts +44 -0
- package/dist/providers/utils.d.ts.map +1 -0
- package/dist/providers/utils.js +100 -0
- package/dist/providers/utils.js.map +1 -0
- package/dist/registry/default-pricing.d.ts +3 -0
- package/dist/registry/default-pricing.d.ts.map +1 -0
- package/dist/registry/default-pricing.js +75 -0
- package/dist/registry/default-pricing.js.map +1 -0
- package/dist/transforms/chat.d.ts +52 -0
- package/dist/transforms/chat.js +136 -0
- package/dist/transforms/chat.js.map +1 -0
- package/dist/transforms/index.d.ts +5 -0
- package/dist/transforms/index.js +7 -0
- package/dist/transforms/index.js.map +1 -0
- package/dist/types/config.d.ts +110 -0
- package/dist/types/config.js +21 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/content.d.ts +87 -0
- package/dist/types/content.d.ts.map +1 -0
- package/dist/types/content.js +40 -0
- package/dist/types/content.js.map +1 -0
- package/dist/types/errors.d.ts +50 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +253 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/message.d.ts +52 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +38 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/provider.d.ts +169 -0
- package/dist/types/provider.d.ts.map +1 -0
- package/dist/types/provider.js +5 -0
- package/dist/types/provider.js.map +1 -0
- package/dist/types/request.d.ts +116 -0
- package/dist/types/request.d.ts.map +1 -0
- package/dist/types/request.js +5 -0
- package/dist/types/request.js.map +1 -0
- package/dist/types/response.d.ts +131 -0
- package/dist/types/response.d.ts.map +1 -0
- package/dist/types/response.js +7 -0
- package/dist/types/response.js.map +1 -0
- package/dist/types/streaming.d.ts +194 -0
- package/dist/types/streaming.js +5 -0
- package/dist/types/streaming.js.map +1 -0
- package/dist/types/tools.d.ts +71 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +5 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/cost.d.ts +10 -0
- package/dist/utils/cost.d.ts.map +1 -0
- package/dist/utils/cost.js +19 -0
- package/dist/utils/cost.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/stream-parser.d.ts +84 -0
- package/dist/utils/stream-parser.js +418 -0
- package/dist/utils/stream-parser.js.map +1 -0
- package/dist/utils/tool-parser.d.ts +134 -0
- package/dist/utils/tool-parser.js +600 -0
- package/dist/utils/tool-parser.js.map +1 -0
- package/dist/yielding-stream.d.ts +60 -0
- package/dist/yielding-stream.js +206 -0
- package/dist/yielding-stream.js.map +1 -0
- package/package.json +1 -1
- package/src/formatters/index.ts +9 -0
- package/src/formatters/native.ts +12 -1
- package/src/formatters/normalize-tool-pairs.ts +622 -0
- package/src/formatters/types.ts +39 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool definition and execution types
|
|
3
|
+
*/
|
|
4
|
+
export interface ToolParameter {
|
|
5
|
+
type: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
enum?: string[];
|
|
8
|
+
items?: ToolParameter;
|
|
9
|
+
properties?: Record<string, ToolParameter>;
|
|
10
|
+
required?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface ToolDefinition {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object';
|
|
17
|
+
properties?: Record<string, ToolParameter>;
|
|
18
|
+
required?: string[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface ToolCall {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
input: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface ToolResult {
|
|
27
|
+
toolUseId: string;
|
|
28
|
+
/**
|
|
29
|
+
* Result content - can be string or structured content blocks (for images).
|
|
30
|
+
* For XML mode, images are noted in text. For native mode, passed as content blocks.
|
|
31
|
+
*/
|
|
32
|
+
content: string | ToolResultContentBlock[];
|
|
33
|
+
isError?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Content block types allowed in tool results
|
|
37
|
+
*/
|
|
38
|
+
export type ToolResultContentBlock = {
|
|
39
|
+
type: 'text';
|
|
40
|
+
text: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: 'image';
|
|
43
|
+
source: {
|
|
44
|
+
type: 'base64';
|
|
45
|
+
data: string;
|
|
46
|
+
mediaType: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export interface ToolContext {
|
|
50
|
+
/** The raw text that contained the tool calls */
|
|
51
|
+
rawText: string;
|
|
52
|
+
/** Text before the tool calls (already streamed to user) */
|
|
53
|
+
preamble: string;
|
|
54
|
+
/** Current depth in tool execution loop */
|
|
55
|
+
depth: number;
|
|
56
|
+
/** Previous tool results in this execution chain */
|
|
57
|
+
previousResults: ToolResult[];
|
|
58
|
+
/** Accumulated output so far */
|
|
59
|
+
accumulated: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ParsedToolCalls {
|
|
62
|
+
/** Parsed tool calls */
|
|
63
|
+
calls: ToolCall[];
|
|
64
|
+
/** Text before the tool calls block */
|
|
65
|
+
beforeText: string;
|
|
66
|
+
/** Text after the tool calls block */
|
|
67
|
+
afterText: string;
|
|
68
|
+
/** The full matched tool calls XML block */
|
|
69
|
+
fullMatch: string;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QAC3C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAMD,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,sBAAsB,EAAE,CAAC;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAMnF,MAAM,WAAW,WAAW;IAC1B,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAEhB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IAEjB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IAEd,oDAAoD;IACpD,eAAe,EAAE,UAAU,EAAE,CAAC;IAE9B,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;CACrB;AAMD,MAAM,WAAW,eAAe;IAC9B,wBAAwB;IACxB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAElB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IAEnB,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAElB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CostBreakdown } from '../types/response.js';
|
|
2
|
+
import type { ModelPricing } from '../types/provider.js';
|
|
3
|
+
export interface CostableUsage {
|
|
4
|
+
inputTokens: number;
|
|
5
|
+
outputTokens: number;
|
|
6
|
+
cacheCreationTokens?: number;
|
|
7
|
+
cacheReadTokens?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function calculateCost(usage: CostableUsage, pricing: ModelPricing): CostBreakdown;
|
|
10
|
+
//# sourceMappingURL=cost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../src/utils/cost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,aAAa,CAkBxF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function calculateCost(usage, pricing) {
|
|
2
|
+
const input = usage.inputTokens * pricing.inputPerMillion / 1_000_000;
|
|
3
|
+
const output = usage.outputTokens * pricing.outputPerMillion / 1_000_000;
|
|
4
|
+
const cacheWrite = pricing.cacheWritePerMillion != null
|
|
5
|
+
? (usage.cacheCreationTokens ?? 0) * pricing.cacheWritePerMillion / 1_000_000
|
|
6
|
+
: undefined;
|
|
7
|
+
const cacheRead = pricing.cacheReadPerMillion != null
|
|
8
|
+
? (usage.cacheReadTokens ?? 0) * pricing.cacheReadPerMillion / 1_000_000
|
|
9
|
+
: undefined;
|
|
10
|
+
return {
|
|
11
|
+
input,
|
|
12
|
+
output,
|
|
13
|
+
cacheWrite,
|
|
14
|
+
cacheRead,
|
|
15
|
+
total: input + output + (cacheWrite ?? 0) + (cacheRead ?? 0),
|
|
16
|
+
currency: pricing.currency,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=cost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.js","sourceRoot":"","sources":["../../src/utils/cost.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,aAAa,CAAC,KAAoB,EAAE,OAAqB;IACvE,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IACtE,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACzE,MAAM,UAAU,GAAG,OAAO,CAAC,oBAAoB,IAAI,IAAI;QACrD,CAAC,CAAC,CAAC,KAAK,CAAC,mBAAmB,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS;QAC7E,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,SAAS,GAAG,OAAO,CAAC,mBAAmB,IAAI,IAAI;QACnD,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS;QACxE,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO;QACL,KAAK;QACL,MAAM;QACN,UAAU;QACV,SAAS;QACT,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,CAAC,UAAU,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,CAAC;QAC5D,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility exports
|
|
3
|
+
*/
|
|
4
|
+
export { parseToolCalls, formatToolResults, formatToolResult, formatToolDefinitions, getToolInstructions, hasUnclosedToolBlock, endsWithPartialToolBlock, unescapeXml, type ToolDefinitionForPrompt, } from './tool-parser.js';
|
|
5
|
+
export { calculateCost } from './cost.js';
|
|
6
|
+
export type { CostableUsage } from './cost.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility exports
|
|
3
|
+
*/
|
|
4
|
+
export { parseToolCalls, formatToolResults, formatToolResult, formatToolDefinitions, getToolInstructions, hasUnclosedToolBlock, endsWithPartialToolBlock, unescapeXml, } from './tool-parser.js';
|
|
5
|
+
export { calculateCost } from './cost.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,GAEZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Incremental XML parser for streaming
|
|
3
|
+
*
|
|
4
|
+
* Tracks nesting depth of XML blocks as tokens arrive, enabling:
|
|
5
|
+
* - False-positive stop sequence detection
|
|
6
|
+
* - Structured block events for UI
|
|
7
|
+
* - Enriched chunk metadata for TTS/display filtering
|
|
8
|
+
*/
|
|
9
|
+
import type { BlockEvent, ChunkMeta, MembraneBlockType } from '../types/streaming.js';
|
|
10
|
+
/**
|
|
11
|
+
* A single emission from processChunk - either content or a block event.
|
|
12
|
+
* Emissions are in the correct order for interleaved processing.
|
|
13
|
+
*/
|
|
14
|
+
export type StreamEmission = {
|
|
15
|
+
kind: 'content';
|
|
16
|
+
text: string;
|
|
17
|
+
meta: ChunkMeta;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'blockEvent';
|
|
20
|
+
event: BlockEvent;
|
|
21
|
+
};
|
|
22
|
+
export interface ProcessChunkResult {
|
|
23
|
+
/** Ordered emissions for correct interleaving */
|
|
24
|
+
emissions: StreamEmission[];
|
|
25
|
+
/** @deprecated Use emissions instead - content may be out of order with blockEvents */
|
|
26
|
+
content: Array<{
|
|
27
|
+
text: string;
|
|
28
|
+
meta: ChunkMeta;
|
|
29
|
+
}>;
|
|
30
|
+
/** @deprecated Use emissions instead - blockEvents may be out of order with content */
|
|
31
|
+
blockEvents: BlockEvent[];
|
|
32
|
+
}
|
|
33
|
+
export declare class IncrementalXmlParser {
|
|
34
|
+
private state;
|
|
35
|
+
constructor();
|
|
36
|
+
push(chunk: string): BlockEvent[];
|
|
37
|
+
/**
|
|
38
|
+
* Reset streaming state for a new API response iteration.
|
|
39
|
+
* Keeps accumulated text and depths, but resets block tracking
|
|
40
|
+
* so processChunk will resync currentBlockType with current depths.
|
|
41
|
+
*/
|
|
42
|
+
resetForNewIteration(): void;
|
|
43
|
+
isInsideBlock(): boolean;
|
|
44
|
+
isInsideFunctionResults(): boolean;
|
|
45
|
+
isInsideFunctionCalls(): boolean;
|
|
46
|
+
getContext(): string;
|
|
47
|
+
getAccumulated(): string;
|
|
48
|
+
getDepths(): {
|
|
49
|
+
functionCalls: number;
|
|
50
|
+
functionResults: number;
|
|
51
|
+
thinking: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Get the current block index (for external block event emission).
|
|
55
|
+
*/
|
|
56
|
+
getBlockIndex(): number;
|
|
57
|
+
/**
|
|
58
|
+
* Increment the block index (call after emitting external block events).
|
|
59
|
+
*/
|
|
60
|
+
incrementBlockIndex(): void;
|
|
61
|
+
reset(): void;
|
|
62
|
+
finish(): BlockEvent[];
|
|
63
|
+
processChunk(chunk: string): ProcessChunkResult;
|
|
64
|
+
flush(): ProcessChunkResult;
|
|
65
|
+
getCurrentBlockType(): MembraneBlockType;
|
|
66
|
+
private isCompleteMembraneTag;
|
|
67
|
+
private cantBeMembraneTag;
|
|
68
|
+
private handleMembraneTag;
|
|
69
|
+
private ensureBlockStarted;
|
|
70
|
+
private ensureBlockStartedWithEmit;
|
|
71
|
+
private makeBlockStart;
|
|
72
|
+
private makeBlockComplete;
|
|
73
|
+
private getCurrentMeta;
|
|
74
|
+
private scanForDepth;
|
|
75
|
+
private scan;
|
|
76
|
+
private findPartialTagAtEnd;
|
|
77
|
+
}
|
|
78
|
+
export declare function hasUnclosedXmlBlock(text: string): boolean;
|
|
79
|
+
export declare function countTags(text: string, openPattern: RegExp, closePattern: RegExp): {
|
|
80
|
+
open: number;
|
|
81
|
+
close: number;
|
|
82
|
+
depth: number;
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=stream-parser.d.ts.map
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Incremental XML parser for streaming
|
|
3
|
+
*
|
|
4
|
+
* Tracks nesting depth of XML blocks as tokens arrive, enabling:
|
|
5
|
+
* - False-positive stop sequence detection
|
|
6
|
+
* - Structured block events for UI
|
|
7
|
+
* - Enriched chunk metadata for TTS/display filtering
|
|
8
|
+
*/
|
|
9
|
+
function createInitialState() {
|
|
10
|
+
return {
|
|
11
|
+
functionCallsDepth: 0,
|
|
12
|
+
functionResultsDepth: 0,
|
|
13
|
+
thinkingDepth: 0,
|
|
14
|
+
accumulated: '',
|
|
15
|
+
lastScanPos: 0,
|
|
16
|
+
blockIndex: 0,
|
|
17
|
+
currentBlockStarted: false,
|
|
18
|
+
currentBlockContent: '',
|
|
19
|
+
currentBlockType: 'text',
|
|
20
|
+
tagBuffer: '',
|
|
21
|
+
toolCallState: {
|
|
22
|
+
inInvoke: false,
|
|
23
|
+
currentToolName: '',
|
|
24
|
+
currentToolId: '',
|
|
25
|
+
inParameter: false,
|
|
26
|
+
currentParamName: '',
|
|
27
|
+
paramContent: '',
|
|
28
|
+
allParams: {},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// For finding all membrane tags in one pass
|
|
33
|
+
const ALL_TAGS = /<\/?(?:antml:)?(?:function_calls|function_results|thinking)>/g;
|
|
34
|
+
// For matching complete membrane tags
|
|
35
|
+
const COMPLETE_MEMBRANE_TAG = /^<\/?(?:antml:)?(?:function_calls|function_results|thinking|invoke|parameter)(?:\s[^>]*)?>$/;
|
|
36
|
+
// Known membrane tag prefixes
|
|
37
|
+
const MEMBRANE_TAG_PREFIXES = [
|
|
38
|
+
'<thinking', '<\/thinking>',
|
|
39
|
+
'<function_calls', '<\/function_calls>',
|
|
40
|
+
'<function_results', '<\/function_results>',
|
|
41
|
+
'<invoke', '<\/invoke>',
|
|
42
|
+
'<parameter', '<\/parameter>',
|
|
43
|
+
'<function_calls', '<\/antml:function_calls>',
|
|
44
|
+
'<invoke', '<\/antml:invoke>',
|
|
45
|
+
];
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Incremental XML Parser
|
|
48
|
+
// ============================================================================
|
|
49
|
+
export class IncrementalXmlParser {
|
|
50
|
+
state;
|
|
51
|
+
constructor() {
|
|
52
|
+
this.state = createInitialState();
|
|
53
|
+
}
|
|
54
|
+
push(chunk) {
|
|
55
|
+
this.state.accumulated += chunk;
|
|
56
|
+
return this.scan();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Reset streaming state for a new API response iteration.
|
|
60
|
+
* Keeps accumulated text and depths, but resets block tracking
|
|
61
|
+
* so processChunk will resync currentBlockType with current depths.
|
|
62
|
+
*/
|
|
63
|
+
resetForNewIteration() {
|
|
64
|
+
this.state.currentBlockStarted = false;
|
|
65
|
+
this.state.currentBlockContent = '';
|
|
66
|
+
this.state.currentBlockType = this.getCurrentBlockType();
|
|
67
|
+
this.state.tagBuffer = '';
|
|
68
|
+
}
|
|
69
|
+
isInsideBlock() {
|
|
70
|
+
return (this.state.functionCallsDepth > 0 ||
|
|
71
|
+
this.state.functionResultsDepth > 0 ||
|
|
72
|
+
this.state.thinkingDepth > 0);
|
|
73
|
+
}
|
|
74
|
+
isInsideFunctionResults() {
|
|
75
|
+
return this.state.functionResultsDepth > 0;
|
|
76
|
+
}
|
|
77
|
+
isInsideFunctionCalls() {
|
|
78
|
+
return this.state.functionCallsDepth > 0;
|
|
79
|
+
}
|
|
80
|
+
getContext() {
|
|
81
|
+
const parts = [];
|
|
82
|
+
if (this.state.functionCallsDepth > 0) {
|
|
83
|
+
parts.push('function_calls(' + this.state.functionCallsDepth + ')');
|
|
84
|
+
}
|
|
85
|
+
if (this.state.functionResultsDepth > 0) {
|
|
86
|
+
parts.push('function_results(' + this.state.functionResultsDepth + ')');
|
|
87
|
+
}
|
|
88
|
+
if (this.state.thinkingDepth > 0) {
|
|
89
|
+
parts.push('thinking(' + this.state.thinkingDepth + ')');
|
|
90
|
+
}
|
|
91
|
+
return parts.length > 0 ? parts.join(' > ') : 'none';
|
|
92
|
+
}
|
|
93
|
+
getAccumulated() {
|
|
94
|
+
return this.state.accumulated;
|
|
95
|
+
}
|
|
96
|
+
getDepths() {
|
|
97
|
+
return {
|
|
98
|
+
functionCalls: this.state.functionCallsDepth,
|
|
99
|
+
functionResults: this.state.functionResultsDepth,
|
|
100
|
+
thinking: this.state.thinkingDepth,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get the current block index (for external block event emission).
|
|
105
|
+
*/
|
|
106
|
+
getBlockIndex() {
|
|
107
|
+
return this.state.blockIndex;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Increment the block index (call after emitting external block events).
|
|
111
|
+
*/
|
|
112
|
+
incrementBlockIndex() {
|
|
113
|
+
this.state.blockIndex++;
|
|
114
|
+
}
|
|
115
|
+
reset() {
|
|
116
|
+
this.state = createInitialState();
|
|
117
|
+
}
|
|
118
|
+
finish() {
|
|
119
|
+
return this.flush().blockEvents;
|
|
120
|
+
}
|
|
121
|
+
// ============================================================================
|
|
122
|
+
// Enriched Streaming API
|
|
123
|
+
// ============================================================================
|
|
124
|
+
processChunk(chunk) {
|
|
125
|
+
const emissions = [];
|
|
126
|
+
const content = [];
|
|
127
|
+
const blockEvents = [];
|
|
128
|
+
// Helper to emit content (adds to both emissions and legacy content array)
|
|
129
|
+
const emitContent = (text, meta) => {
|
|
130
|
+
emissions.push({ kind: 'content', text, meta });
|
|
131
|
+
content.push({ text, meta });
|
|
132
|
+
};
|
|
133
|
+
// Helper to emit block event (adds to both emissions and legacy blockEvents array)
|
|
134
|
+
const emitBlockEvent = (event) => {
|
|
135
|
+
emissions.push({ kind: 'blockEvent', event });
|
|
136
|
+
blockEvents.push(event);
|
|
137
|
+
};
|
|
138
|
+
// Sync currentBlockType with depths before processing
|
|
139
|
+
// This handles the case where push() was used for prefill initialization
|
|
140
|
+
// and now we're streaming with processChunk()
|
|
141
|
+
if (!this.state.currentBlockStarted) {
|
|
142
|
+
this.state.currentBlockType = this.getCurrentBlockType();
|
|
143
|
+
}
|
|
144
|
+
// Note: We intentionally do NOT call scanForDepth() here anymore.
|
|
145
|
+
// The character-by-character handling via handleMembraneTag() tracks depths.
|
|
146
|
+
// Calling scanForDepth() would pre-update depths before content is emitted,
|
|
147
|
+
// causing the last tokens before a closing tag to have wrong type.
|
|
148
|
+
this.state.accumulated += chunk;
|
|
149
|
+
let pos = 0;
|
|
150
|
+
while (pos < chunk.length) {
|
|
151
|
+
if (this.state.tagBuffer) {
|
|
152
|
+
const char = chunk[pos];
|
|
153
|
+
this.state.tagBuffer += char;
|
|
154
|
+
pos++;
|
|
155
|
+
if (this.isCompleteMembraneTag(this.state.tagBuffer)) {
|
|
156
|
+
const events = this.handleMembraneTag(this.state.tagBuffer);
|
|
157
|
+
for (const event of events) {
|
|
158
|
+
emitBlockEvent(event);
|
|
159
|
+
}
|
|
160
|
+
this.state.tagBuffer = '';
|
|
161
|
+
}
|
|
162
|
+
else if (this.cantBeMembraneTag(this.state.tagBuffer)) {
|
|
163
|
+
this.ensureBlockStartedWithEmit(emitBlockEvent);
|
|
164
|
+
emitContent(this.state.tagBuffer, this.getCurrentMeta());
|
|
165
|
+
this.state.currentBlockContent += this.state.tagBuffer;
|
|
166
|
+
this.state.tagBuffer = '';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const nextLt = chunk.indexOf('<', pos);
|
|
171
|
+
if (nextLt === -1) {
|
|
172
|
+
const text = chunk.slice(pos);
|
|
173
|
+
if (text) {
|
|
174
|
+
this.ensureBlockStartedWithEmit(emitBlockEvent);
|
|
175
|
+
emitContent(text, this.getCurrentMeta());
|
|
176
|
+
this.state.currentBlockContent += text;
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
if (nextLt > pos) {
|
|
182
|
+
const text = chunk.slice(pos, nextLt);
|
|
183
|
+
this.ensureBlockStartedWithEmit(emitBlockEvent);
|
|
184
|
+
emitContent(text, this.getCurrentMeta());
|
|
185
|
+
this.state.currentBlockContent += text;
|
|
186
|
+
}
|
|
187
|
+
this.state.tagBuffer = '<';
|
|
188
|
+
pos = nextLt + 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Update lastScanPos so scanForDepth won't re-process tags we handled
|
|
193
|
+
this.state.lastScanPos = this.state.accumulated.length;
|
|
194
|
+
return { emissions, content, blockEvents };
|
|
195
|
+
}
|
|
196
|
+
flush() {
|
|
197
|
+
const emissions = [];
|
|
198
|
+
const content = [];
|
|
199
|
+
const blockEvents = [];
|
|
200
|
+
if (this.state.tagBuffer) {
|
|
201
|
+
if (!this.state.currentBlockStarted) {
|
|
202
|
+
const event = this.makeBlockStart(this.state.currentBlockType);
|
|
203
|
+
emissions.push({ kind: 'blockEvent', event });
|
|
204
|
+
blockEvents.push(event);
|
|
205
|
+
}
|
|
206
|
+
const meta = this.getCurrentMeta();
|
|
207
|
+
emissions.push({ kind: 'content', text: this.state.tagBuffer, meta });
|
|
208
|
+
content.push({ text: this.state.tagBuffer, meta });
|
|
209
|
+
this.state.currentBlockContent += this.state.tagBuffer;
|
|
210
|
+
this.state.tagBuffer = '';
|
|
211
|
+
}
|
|
212
|
+
if (this.state.currentBlockStarted) {
|
|
213
|
+
const event = this.makeBlockComplete();
|
|
214
|
+
emissions.push({ kind: 'blockEvent', event });
|
|
215
|
+
blockEvents.push(event);
|
|
216
|
+
}
|
|
217
|
+
return { emissions, content, blockEvents };
|
|
218
|
+
}
|
|
219
|
+
getCurrentBlockType() {
|
|
220
|
+
if (this.state.thinkingDepth > 0)
|
|
221
|
+
return 'thinking';
|
|
222
|
+
if (this.state.functionCallsDepth > 0)
|
|
223
|
+
return 'tool_call';
|
|
224
|
+
if (this.state.functionResultsDepth > 0)
|
|
225
|
+
return 'tool_result';
|
|
226
|
+
return 'text';
|
|
227
|
+
}
|
|
228
|
+
// ============================================================================
|
|
229
|
+
// Private Methods
|
|
230
|
+
// ============================================================================
|
|
231
|
+
isCompleteMembraneTag(buffer) {
|
|
232
|
+
if (!buffer.endsWith('>'))
|
|
233
|
+
return false;
|
|
234
|
+
return COMPLETE_MEMBRANE_TAG.test(buffer);
|
|
235
|
+
}
|
|
236
|
+
cantBeMembraneTag(buffer) {
|
|
237
|
+
if (buffer.endsWith('>')) {
|
|
238
|
+
return !this.isCompleteMembraneTag(buffer);
|
|
239
|
+
}
|
|
240
|
+
for (const prefix of MEMBRANE_TAG_PREFIXES) {
|
|
241
|
+
if (prefix.startsWith(buffer) || buffer.startsWith(prefix.slice(0, buffer.length))) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
handleMembraneTag(tag) {
|
|
248
|
+
const events = [];
|
|
249
|
+
const isClosing = tag.startsWith('</');
|
|
250
|
+
if (tag.includes('thinking')) {
|
|
251
|
+
if (!isClosing) {
|
|
252
|
+
if (this.state.currentBlockStarted) {
|
|
253
|
+
events.push(this.makeBlockComplete());
|
|
254
|
+
}
|
|
255
|
+
this.state.thinkingDepth++;
|
|
256
|
+
this.state.currentBlockType = 'thinking';
|
|
257
|
+
events.push(this.makeBlockStart('thinking'));
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
events.push(this.makeBlockComplete());
|
|
261
|
+
this.state.thinkingDepth--;
|
|
262
|
+
this.state.currentBlockType = this.getCurrentBlockType();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else if (tag.includes('function_calls')) {
|
|
266
|
+
if (!isClosing) {
|
|
267
|
+
if (this.state.currentBlockStarted) {
|
|
268
|
+
events.push(this.makeBlockComplete());
|
|
269
|
+
}
|
|
270
|
+
this.state.functionCallsDepth++;
|
|
271
|
+
this.state.currentBlockType = 'tool_call';
|
|
272
|
+
events.push(this.makeBlockStart('tool_call'));
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
events.push(this.makeBlockComplete());
|
|
276
|
+
this.state.functionCallsDepth--;
|
|
277
|
+
this.state.currentBlockType = this.getCurrentBlockType();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else if (tag.includes('function_results')) {
|
|
281
|
+
if (!isClosing) {
|
|
282
|
+
if (this.state.currentBlockStarted) {
|
|
283
|
+
events.push(this.makeBlockComplete());
|
|
284
|
+
}
|
|
285
|
+
this.state.functionResultsDepth++;
|
|
286
|
+
this.state.currentBlockType = 'tool_result';
|
|
287
|
+
events.push(this.makeBlockStart('tool_result'));
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
events.push(this.makeBlockComplete());
|
|
291
|
+
this.state.functionResultsDepth--;
|
|
292
|
+
this.state.currentBlockType = this.getCurrentBlockType();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return events;
|
|
296
|
+
}
|
|
297
|
+
ensureBlockStarted(events) {
|
|
298
|
+
if (!this.state.currentBlockStarted) {
|
|
299
|
+
events.push(this.makeBlockStart(this.state.currentBlockType));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
ensureBlockStartedWithEmit(emit) {
|
|
303
|
+
if (!this.state.currentBlockStarted) {
|
|
304
|
+
emit(this.makeBlockStart(this.state.currentBlockType));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
makeBlockStart(type) {
|
|
308
|
+
this.state.currentBlockStarted = true;
|
|
309
|
+
this.state.currentBlockContent = '';
|
|
310
|
+
this.state.currentBlockType = type;
|
|
311
|
+
return {
|
|
312
|
+
event: 'block_start',
|
|
313
|
+
index: this.state.blockIndex,
|
|
314
|
+
block: { type }
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
makeBlockComplete() {
|
|
318
|
+
const block = {
|
|
319
|
+
type: this.state.currentBlockType,
|
|
320
|
+
content: this.state.currentBlockContent,
|
|
321
|
+
};
|
|
322
|
+
const event = {
|
|
323
|
+
event: 'block_complete',
|
|
324
|
+
index: this.state.blockIndex,
|
|
325
|
+
block
|
|
326
|
+
};
|
|
327
|
+
this.state.blockIndex++;
|
|
328
|
+
this.state.currentBlockStarted = false;
|
|
329
|
+
this.state.currentBlockContent = '';
|
|
330
|
+
return event;
|
|
331
|
+
}
|
|
332
|
+
getCurrentMeta() {
|
|
333
|
+
// Use currentBlockType (updated only after tag is fully handled)
|
|
334
|
+
// not getCurrentBlockType() (which checks depths that may be pre-updated by scanForDepth)
|
|
335
|
+
const type = this.state.currentBlockType;
|
|
336
|
+
return {
|
|
337
|
+
type,
|
|
338
|
+
visible: type === 'text',
|
|
339
|
+
blockIndex: this.state.blockIndex,
|
|
340
|
+
depth: Math.max(this.state.functionCallsDepth, this.state.functionResultsDepth),
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
scanForDepth() {
|
|
344
|
+
const text = this.state.accumulated;
|
|
345
|
+
const lookbackChars = 30;
|
|
346
|
+
const scanStart = Math.max(0, this.state.lastScanPos - lookbackChars);
|
|
347
|
+
const textToScan = text.slice(scanStart);
|
|
348
|
+
ALL_TAGS.lastIndex = 0;
|
|
349
|
+
let match;
|
|
350
|
+
while ((match = ALL_TAGS.exec(textToScan)) !== null) {
|
|
351
|
+
const absolutePos = scanStart + match.index;
|
|
352
|
+
if (absolutePos < this.state.lastScanPos)
|
|
353
|
+
continue;
|
|
354
|
+
const tag = match[0];
|
|
355
|
+
const isClosing = tag.startsWith('</');
|
|
356
|
+
if (tag.includes('function_calls')) {
|
|
357
|
+
if (isClosing) {
|
|
358
|
+
this.state.functionCallsDepth = Math.max(0, this.state.functionCallsDepth - 1);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
this.state.functionCallsDepth++;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
else if (tag.includes('function_results')) {
|
|
365
|
+
if (isClosing) {
|
|
366
|
+
this.state.functionResultsDepth = Math.max(0, this.state.functionResultsDepth - 1);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
this.state.functionResultsDepth++;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
else if (tag.includes('thinking')) {
|
|
373
|
+
if (isClosing) {
|
|
374
|
+
this.state.thinkingDepth = Math.max(0, this.state.thinkingDepth - 1);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this.state.thinkingDepth++;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
const partialTagLen = this.findPartialTagAtEnd(text);
|
|
382
|
+
this.state.lastScanPos = text.length - partialTagLen;
|
|
383
|
+
}
|
|
384
|
+
scan() {
|
|
385
|
+
this.scanForDepth();
|
|
386
|
+
return [];
|
|
387
|
+
}
|
|
388
|
+
findPartialTagAtEnd(text) {
|
|
389
|
+
const tail = text.slice(-30);
|
|
390
|
+
const lastLt = tail.lastIndexOf('<');
|
|
391
|
+
if (lastLt === -1)
|
|
392
|
+
return 0;
|
|
393
|
+
const afterLt = tail.slice(lastLt);
|
|
394
|
+
if (afterLt.includes('>'))
|
|
395
|
+
return 0;
|
|
396
|
+
return afterLt.length;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
// ============================================================================
|
|
400
|
+
// Utility Functions
|
|
401
|
+
// ============================================================================
|
|
402
|
+
export function hasUnclosedXmlBlock(text) {
|
|
403
|
+
const parser = new IncrementalXmlParser();
|
|
404
|
+
parser.push(text);
|
|
405
|
+
return parser.isInsideBlock();
|
|
406
|
+
}
|
|
407
|
+
export function countTags(text, openPattern, closePattern) {
|
|
408
|
+
openPattern.lastIndex = 0;
|
|
409
|
+
closePattern.lastIndex = 0;
|
|
410
|
+
const openMatches = text.match(openPattern) || [];
|
|
411
|
+
const closeMatches = text.match(closePattern) || [];
|
|
412
|
+
return {
|
|
413
|
+
open: openMatches.length,
|
|
414
|
+
close: closeMatches.length,
|
|
415
|
+
depth: openMatches.length - closeMatches.length,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
//# sourceMappingURL=stream-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-parser.js","sourceRoot":"","sources":["../../src/utils/stream-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwDH,SAAS,kBAAkB;IACzB,OAAO;QACL,kBAAkB,EAAE,CAAC;QACrB,oBAAoB,EAAE,CAAC;QACvB,aAAa,EAAE,CAAC;QAChB,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,CAAC;QACb,mBAAmB,EAAE,KAAK;QAC1B,mBAAmB,EAAE,EAAE;QACvB,gBAAgB,EAAE,MAAM;QACxB,SAAS,EAAE,EAAE;QACb,aAAa,EAAE;YACb,QAAQ,EAAE,KAAK;YACf,eAAe,EAAE,EAAE;YACnB,aAAa,EAAE,EAAE;YACjB,WAAW,EAAE,KAAK;YAClB,gBAAgB,EAAE,EAAE;YACpB,YAAY,EAAE,EAAE;YAChB,SAAS,EAAE,EAAE;SACd;KACF,CAAC;AACJ,CAAC;AAED,4CAA4C;AAC5C,MAAM,QAAQ,GAAG,+DAA+D,CAAC;AAEjF,wCAAwC;AACxC,MAAM,qBAAqB,GAAG,6FAA6F,CAAC;AAE5H,8BAA8B;AAC9B,MAAM,qBAAqB,GAAG;IAC5B,WAAW,EAAE,cAAc;IAC3B,iBAAiB,EAAE,oBAAoB;IACvC,mBAAmB,EAAE,sBAAsB;IAC3C,SAAS,EAAE,YAAY;IACvB,YAAY,EAAE,eAAe;IAC7B,iBAAiB,EAAE,0BAA0B;IAC7C,SAAS,EAAE,kBAAkB;CAC9B,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