@inkeep/agents-run-api 0.1.3 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +7 -0
- package/README.md +5 -5
- package/SUPPLEMENTAL_TERMS.md +40 -0
- package/dist/chunk-HO5J26MO.js +234 -0
- package/dist/conversations-ZQXUNCNE.js +1 -0
- package/dist/index.cjs +9048 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +13 -21
- package/dist/index.js +8702 -27
- package/package.json +9 -8
- package/dist/AgentExecutionServer.d.ts +0 -28
- package/dist/AgentExecutionServer.d.ts.map +0 -1
- package/dist/AgentExecutionServer.js +0 -41
- package/dist/__tests__/setup.d.ts +0 -4
- package/dist/__tests__/setup.d.ts.map +0 -1
- package/dist/__tests__/setup.js +0 -80
- package/dist/__tests__/utils/testProject.d.ts +0 -18
- package/dist/__tests__/utils/testProject.d.ts.map +0 -1
- package/dist/__tests__/utils/testProject.js +0 -26
- package/dist/__tests__/utils/testRequest.d.ts +0 -8
- package/dist/__tests__/utils/testRequest.d.ts.map +0 -1
- package/dist/__tests__/utils/testRequest.js +0 -32
- package/dist/__tests__/utils/testTenant.d.ts +0 -64
- package/dist/__tests__/utils/testTenant.d.ts.map +0 -1
- package/dist/__tests__/utils/testTenant.js +0 -71
- package/dist/a2a/client.d.ts +0 -182
- package/dist/a2a/client.d.ts.map +0 -1
- package/dist/a2a/client.js +0 -645
- package/dist/a2a/handlers.d.ts +0 -4
- package/dist/a2a/handlers.d.ts.map +0 -1
- package/dist/a2a/handlers.js +0 -656
- package/dist/a2a/transfer.d.ts +0 -18
- package/dist/a2a/transfer.d.ts.map +0 -1
- package/dist/a2a/transfer.js +0 -22
- package/dist/a2a/types.d.ts +0 -63
- package/dist/a2a/types.d.ts.map +0 -1
- package/dist/a2a/types.js +0 -1
- package/dist/agents/Agent.d.ts +0 -154
- package/dist/agents/Agent.d.ts.map +0 -1
- package/dist/agents/Agent.js +0 -1110
- package/dist/agents/ModelFactory.d.ts +0 -62
- package/dist/agents/ModelFactory.d.ts.map +0 -1
- package/dist/agents/ModelFactory.js +0 -208
- package/dist/agents/SystemPromptBuilder.d.ts +0 -14
- package/dist/agents/SystemPromptBuilder.d.ts.map +0 -1
- package/dist/agents/SystemPromptBuilder.js +0 -62
- package/dist/agents/ToolSessionManager.d.ts +0 -61
- package/dist/agents/ToolSessionManager.d.ts.map +0 -1
- package/dist/agents/ToolSessionManager.js +0 -143
- package/dist/agents/artifactTools.d.ts +0 -30
- package/dist/agents/artifactTools.d.ts.map +0 -1
- package/dist/agents/artifactTools.js +0 -463
- package/dist/agents/generateTaskHandler.d.ts +0 -41
- package/dist/agents/generateTaskHandler.d.ts.map +0 -1
- package/dist/agents/generateTaskHandler.js +0 -350
- package/dist/agents/relationTools.d.ts +0 -35
- package/dist/agents/relationTools.d.ts.map +0 -1
- package/dist/agents/relationTools.js +0 -246
- package/dist/agents/types.d.ts +0 -23
- package/dist/agents/types.d.ts.map +0 -1
- package/dist/agents/types.js +0 -1
- package/dist/agents/versions/V1Config.d.ts +0 -21
- package/dist/agents/versions/V1Config.d.ts.map +0 -1
- package/dist/agents/versions/V1Config.js +0 -285
- package/dist/app.d.ts +0 -12
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -216
- package/dist/data/agentGraph.d.ts +0 -4
- package/dist/data/agentGraph.d.ts.map +0 -1
- package/dist/data/agentGraph.js +0 -73
- package/dist/data/agents.d.ts +0 -4
- package/dist/data/agents.d.ts.map +0 -1
- package/dist/data/agents.js +0 -78
- package/dist/data/conversations.d.ts +0 -59
- package/dist/data/conversations.d.ts.map +0 -1
- package/dist/data/conversations.js +0 -216
- package/dist/data/db/clean.d.ts +0 -6
- package/dist/data/db/clean.d.ts.map +0 -1
- package/dist/data/db/clean.js +0 -77
- package/dist/data/db/dbClient.d.ts +0 -3
- package/dist/data/db/dbClient.d.ts.map +0 -1
- package/dist/data/db/dbClient.js +0 -13
- package/dist/env.d.ts +0 -45
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -64
- package/dist/handlers/executionHandler.d.ts +0 -36
- package/dist/handlers/executionHandler.d.ts.map +0 -1
- package/dist/handlers/executionHandler.js +0 -399
- package/dist/index.d.ts.map +0 -1
- package/dist/instrumentation.d.ts +0 -13
- package/dist/instrumentation.d.ts.map +0 -1
- package/dist/instrumentation.js +0 -66
- package/dist/logger.d.ts +0 -4
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -32
- package/dist/middleware/api-key-auth.d.ts +0 -22
- package/dist/middleware/api-key-auth.d.ts.map +0 -1
- package/dist/middleware/api-key-auth.js +0 -139
- package/dist/middleware/index.d.ts +0 -2
- package/dist/middleware/index.d.ts.map +0 -1
- package/dist/middleware/index.js +0 -1
- package/dist/openapi.d.ts +0 -2
- package/dist/openapi.d.ts.map +0 -1
- package/dist/openapi.js +0 -36
- package/dist/routes/agents.d.ts +0 -10
- package/dist/routes/agents.d.ts.map +0 -1
- package/dist/routes/agents.js +0 -158
- package/dist/routes/chat.d.ts +0 -10
- package/dist/routes/chat.d.ts.map +0 -1
- package/dist/routes/chat.js +0 -307
- package/dist/routes/chatDataStream.d.ts +0 -10
- package/dist/routes/chatDataStream.d.ts.map +0 -1
- package/dist/routes/chatDataStream.js +0 -179
- package/dist/routes/mcp.d.ts +0 -10
- package/dist/routes/mcp.d.ts.map +0 -1
- package/dist/routes/mcp.js +0 -500
- package/dist/server.d.ts +0 -5
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -61
- package/dist/tracer.d.ts +0 -24
- package/dist/tracer.d.ts.map +0 -1
- package/dist/tracer.js +0 -107
- package/dist/types/chat.d.ts +0 -25
- package/dist/types/chat.d.ts.map +0 -1
- package/dist/types/chat.js +0 -1
- package/dist/types/execution-context.d.ts +0 -14
- package/dist/types/execution-context.d.ts.map +0 -1
- package/dist/types/execution-context.js +0 -14
- package/dist/utils/agent-operations.d.ts +0 -92
- package/dist/utils/agent-operations.d.ts.map +0 -1
- package/dist/utils/agent-operations.js +0 -78
- package/dist/utils/artifact-component-schema.d.ts +0 -29
- package/dist/utils/artifact-component-schema.d.ts.map +0 -1
- package/dist/utils/artifact-component-schema.js +0 -119
- package/dist/utils/artifact-parser.d.ts +0 -71
- package/dist/utils/artifact-parser.d.ts.map +0 -1
- package/dist/utils/artifact-parser.js +0 -251
- package/dist/utils/cleanup.d.ts +0 -19
- package/dist/utils/cleanup.d.ts.map +0 -1
- package/dist/utils/cleanup.js +0 -66
- package/dist/utils/data-component-schema.d.ts +0 -6
- package/dist/utils/data-component-schema.d.ts.map +0 -1
- package/dist/utils/data-component-schema.js +0 -43
- package/dist/utils/graph-session.d.ts +0 -200
- package/dist/utils/graph-session.d.ts.map +0 -1
- package/dist/utils/graph-session.js +0 -1016
- package/dist/utils/incremental-stream-parser.d.ts +0 -57
- package/dist/utils/incremental-stream-parser.d.ts.map +0 -1
- package/dist/utils/incremental-stream-parser.js +0 -289
- package/dist/utils/response-formatter.d.ts +0 -27
- package/dist/utils/response-formatter.d.ts.map +0 -1
- package/dist/utils/response-formatter.js +0 -160
- package/dist/utils/stream-helpers.d.ts +0 -174
- package/dist/utils/stream-helpers.d.ts.map +0 -1
- package/dist/utils/stream-helpers.js +0 -466
- package/dist/utils/stream-registry.d.ts +0 -18
- package/dist/utils/stream-registry.d.ts.map +0 -1
- package/dist/utils/stream-registry.js +0 -33
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import type { OperationEvent } from './agent-operations';
|
|
2
|
-
export interface StreamHelper {
|
|
3
|
-
writeRole(role?: string): Promise<void>;
|
|
4
|
-
writeContent(content: string): Promise<void>;
|
|
5
|
-
streamData(data: any): Promise<void>;
|
|
6
|
-
streamText(text: string, delayMs?: number): Promise<void>;
|
|
7
|
-
writeError(errorMessage: string): Promise<void>;
|
|
8
|
-
complete(): Promise<void>;
|
|
9
|
-
writeData(type: string, data: any): Promise<void>;
|
|
10
|
-
writeOperation(operation: OperationEvent): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export interface HonoSSEStream {
|
|
13
|
-
writeSSE(message: {
|
|
14
|
-
data: string;
|
|
15
|
-
event?: string;
|
|
16
|
-
id?: string;
|
|
17
|
-
}): Promise<void>;
|
|
18
|
-
sleep(ms: number): Promise<unknown>;
|
|
19
|
-
}
|
|
20
|
-
export interface ChatCompletionChunk {
|
|
21
|
-
id: string;
|
|
22
|
-
object: string;
|
|
23
|
-
created: number;
|
|
24
|
-
model: string;
|
|
25
|
-
choices: Array<{
|
|
26
|
-
index: number;
|
|
27
|
-
delta: {
|
|
28
|
-
role?: string;
|
|
29
|
-
content?: string;
|
|
30
|
-
};
|
|
31
|
-
finish_reason: string | null;
|
|
32
|
-
}>;
|
|
33
|
-
}
|
|
34
|
-
export declare class SSEStreamHelper implements StreamHelper {
|
|
35
|
-
private stream;
|
|
36
|
-
private requestId;
|
|
37
|
-
private timestamp;
|
|
38
|
-
private isTextStreaming;
|
|
39
|
-
private queuedOperations;
|
|
40
|
-
constructor(stream: HonoSSEStream, requestId: string, timestamp: number);
|
|
41
|
-
private get sessionId();
|
|
42
|
-
/**
|
|
43
|
-
* Write the initial role message
|
|
44
|
-
*/
|
|
45
|
-
writeRole(role?: string): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Write content chunk
|
|
48
|
-
*/
|
|
49
|
-
writeContent(content: string): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Stream text word by word with optional delay
|
|
52
|
-
*/
|
|
53
|
-
streamText(text: string, delayMs?: number): Promise<void>;
|
|
54
|
-
streamData(data: any): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Write error message
|
|
57
|
-
*/
|
|
58
|
-
writeError(errorMessage: string): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Write the final completion message
|
|
61
|
-
*/
|
|
62
|
-
writeCompletion(finishReason?: string): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Write the final [DONE] message
|
|
65
|
-
*/
|
|
66
|
-
writeDone(): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Complete the stream with finish reason and done message
|
|
69
|
-
*/
|
|
70
|
-
complete(finishReason?: string): Promise<void>;
|
|
71
|
-
writeData(type: string, data: any): Promise<void>;
|
|
72
|
-
writeOperation(operation: OperationEvent): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Flush all queued operations in order after text streaming completes
|
|
75
|
-
*/
|
|
76
|
-
private flushQueuedOperations;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Factory function to create SSE stream helper
|
|
80
|
-
*/
|
|
81
|
-
export declare function createSSEStreamHelper(stream: HonoSSEStream, requestId: string, timestamp: number): SSEStreamHelper;
|
|
82
|
-
export interface VercelUIWriter {
|
|
83
|
-
write(chunk: any): void;
|
|
84
|
-
merge(stream: any): void;
|
|
85
|
-
onError?: (error: Error) => void;
|
|
86
|
-
}
|
|
87
|
-
export declare class VercelDataStreamHelper implements StreamHelper {
|
|
88
|
-
private writer;
|
|
89
|
-
private textId;
|
|
90
|
-
private jsonBuffer;
|
|
91
|
-
private sentItems;
|
|
92
|
-
private completedItems;
|
|
93
|
-
private sessionId;
|
|
94
|
-
private static readonly MAX_BUFFER_SIZE;
|
|
95
|
-
private isCompleted;
|
|
96
|
-
private isTextStreaming;
|
|
97
|
-
private queuedOperations;
|
|
98
|
-
constructor(writer: VercelUIWriter);
|
|
99
|
-
setSessionId(sessionId: string): void;
|
|
100
|
-
writeRole(_?: string): Promise<void>;
|
|
101
|
-
writeContent(content: string): Promise<void>;
|
|
102
|
-
streamText(text: string, delayMs?: number): Promise<void>;
|
|
103
|
-
writeData(type: 'operation', data: {
|
|
104
|
-
type: string;
|
|
105
|
-
ctx: any;
|
|
106
|
-
}): Promise<void>;
|
|
107
|
-
writeError(errorMessage: string): Promise<void>;
|
|
108
|
-
streamData(data: any): Promise<void>;
|
|
109
|
-
mergeStream(stream: any): Promise<void>;
|
|
110
|
-
writeCompletion(_finishReason?: string): Promise<void>;
|
|
111
|
-
writeDone(): Promise<void>;
|
|
112
|
-
/**
|
|
113
|
-
* Complete the stream and clean up all memory
|
|
114
|
-
* This is the primary cleanup point to prevent memory leaks between requests
|
|
115
|
-
*/
|
|
116
|
-
complete(): Promise<void>;
|
|
117
|
-
/**
|
|
118
|
-
* Clean up all memory allocations
|
|
119
|
-
* Should be called when the stream helper is no longer needed
|
|
120
|
-
*/
|
|
121
|
-
cleanup(): void;
|
|
122
|
-
/**
|
|
123
|
-
* Check if the stream has been completed and cleaned up
|
|
124
|
-
*/
|
|
125
|
-
isStreamCompleted(): boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Get current memory usage stats (for debugging/monitoring)
|
|
128
|
-
*/
|
|
129
|
-
getMemoryStats(): {
|
|
130
|
-
bufferSize: number;
|
|
131
|
-
sentItemsCount: number;
|
|
132
|
-
completedItemsCount: number;
|
|
133
|
-
isCompleted: boolean;
|
|
134
|
-
};
|
|
135
|
-
writeOperation(operation: OperationEvent): Promise<void>;
|
|
136
|
-
/**
|
|
137
|
-
* Flush all queued operations in order after text streaming completes
|
|
138
|
-
*/
|
|
139
|
-
private flushQueuedOperations;
|
|
140
|
-
}
|
|
141
|
-
export declare function createVercelStreamHelper(writer: VercelUIWriter): VercelDataStreamHelper;
|
|
142
|
-
/**
|
|
143
|
-
* MCP Stream Helper that captures content instead of streaming
|
|
144
|
-
* Used for MCP tool responses which require a single response message
|
|
145
|
-
*/
|
|
146
|
-
export declare class MCPStreamHelper implements StreamHelper {
|
|
147
|
-
private capturedText;
|
|
148
|
-
private capturedData;
|
|
149
|
-
private capturedOperations;
|
|
150
|
-
private hasError;
|
|
151
|
-
private errorMessage;
|
|
152
|
-
private sessionId;
|
|
153
|
-
setSessionId(sessionId: string): void;
|
|
154
|
-
writeRole(_role?: string): Promise<void>;
|
|
155
|
-
writeContent(content: string): Promise<void>;
|
|
156
|
-
streamText(text: string, _delayMs?: number): Promise<void>;
|
|
157
|
-
streamData(data: any): Promise<void>;
|
|
158
|
-
writeData(_type: string, data: any): Promise<void>;
|
|
159
|
-
writeError(errorMessage: string): Promise<void>;
|
|
160
|
-
complete(): Promise<void>;
|
|
161
|
-
writeOperation(operation: OperationEvent): Promise<void>;
|
|
162
|
-
/**
|
|
163
|
-
* Get the captured response for MCP tool result
|
|
164
|
-
*/
|
|
165
|
-
getCapturedResponse(): {
|
|
166
|
-
text: string;
|
|
167
|
-
data: any[];
|
|
168
|
-
operations: OperationEvent[];
|
|
169
|
-
hasError: boolean;
|
|
170
|
-
errorMessage: string;
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
export declare function createMCPStreamHelper(): MCPStreamHelper;
|
|
174
|
-
//# sourceMappingURL=stream-helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/stream-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,UAAU,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElD,cAAc,CAAC,SAAS,EAAE,cAAc,GAAG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CAAS;IACzB,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,SAAS,CAAuB;IAExC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/B,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5C,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1D,UAAU,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,cAAc,CAAC,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9D;;OAEG;IACH,mBAAmB,IAAI;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,GAAG,EAAE,CAAC;QACZ,UAAU,EAAE,cAAc,EAAE,CAAC;QAC7B,QAAQ,EAAE,OAAO,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;KACtB;CASF;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAEvD"}
|
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
import { parsePartialJson } from 'ai';
|
|
2
|
-
export class SSEStreamHelper {
|
|
3
|
-
stream;
|
|
4
|
-
requestId;
|
|
5
|
-
timestamp;
|
|
6
|
-
// Stream queuing for proper event ordering
|
|
7
|
-
isTextStreaming = false;
|
|
8
|
-
queuedOperations = [];
|
|
9
|
-
constructor(stream, requestId, timestamp) {
|
|
10
|
-
this.stream = stream;
|
|
11
|
-
this.requestId = requestId;
|
|
12
|
-
this.timestamp = timestamp;
|
|
13
|
-
}
|
|
14
|
-
get sessionId() {
|
|
15
|
-
return this.requestId;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Write the initial role message
|
|
19
|
-
*/
|
|
20
|
-
async writeRole(role = 'assistant') {
|
|
21
|
-
await this.stream.writeSSE({
|
|
22
|
-
data: JSON.stringify({
|
|
23
|
-
id: this.requestId,
|
|
24
|
-
object: 'chat.completion.chunk',
|
|
25
|
-
created: this.timestamp,
|
|
26
|
-
choices: [
|
|
27
|
-
{
|
|
28
|
-
index: 0,
|
|
29
|
-
delta: {
|
|
30
|
-
role,
|
|
31
|
-
},
|
|
32
|
-
finish_reason: null,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
}),
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Write content chunk
|
|
40
|
-
*/
|
|
41
|
-
async writeContent(content) {
|
|
42
|
-
await this.stream.writeSSE({
|
|
43
|
-
data: JSON.stringify({
|
|
44
|
-
id: this.requestId,
|
|
45
|
-
object: 'chat.completion.chunk',
|
|
46
|
-
created: this.timestamp,
|
|
47
|
-
choices: [
|
|
48
|
-
{
|
|
49
|
-
index: 0,
|
|
50
|
-
delta: {
|
|
51
|
-
content,
|
|
52
|
-
},
|
|
53
|
-
finish_reason: null,
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
}),
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Stream text word by word with optional delay
|
|
61
|
-
*/
|
|
62
|
-
async streamText(text, delayMs = 100) {
|
|
63
|
-
const words = text.split(' ');
|
|
64
|
-
// Mark that text streaming is starting
|
|
65
|
-
this.isTextStreaming = true;
|
|
66
|
-
try {
|
|
67
|
-
for (let i = 0; i < words.length; i++) {
|
|
68
|
-
await this.stream.sleep(delayMs);
|
|
69
|
-
const content = i === 0 ? words[i] : ` ${words[i]}`;
|
|
70
|
-
await this.writeContent(content);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
finally {
|
|
74
|
-
// Mark that text streaming has finished
|
|
75
|
-
this.isTextStreaming = false;
|
|
76
|
-
// Flush any queued operations now that text sequence is complete
|
|
77
|
-
await this.flushQueuedOperations();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
async streamData(data) {
|
|
81
|
-
await this.writeContent(JSON.stringify(data));
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Write error message
|
|
85
|
-
*/
|
|
86
|
-
async writeError(errorMessage) {
|
|
87
|
-
await this.writeContent(`\n\n${errorMessage}`);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Write the final completion message
|
|
91
|
-
*/
|
|
92
|
-
async writeCompletion(finishReason = 'stop') {
|
|
93
|
-
await this.stream.writeSSE({
|
|
94
|
-
data: JSON.stringify({
|
|
95
|
-
id: this.requestId,
|
|
96
|
-
object: 'chat.completion.chunk',
|
|
97
|
-
created: this.timestamp,
|
|
98
|
-
choices: [
|
|
99
|
-
{
|
|
100
|
-
index: 0,
|
|
101
|
-
delta: {},
|
|
102
|
-
finish_reason: finishReason,
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
}),
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Write the final [DONE] message
|
|
110
|
-
*/
|
|
111
|
-
async writeDone() {
|
|
112
|
-
await this.stream.writeSSE({
|
|
113
|
-
data: '[DONE]',
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Complete the stream with finish reason and done message
|
|
118
|
-
*/
|
|
119
|
-
async complete(finishReason = 'stop') {
|
|
120
|
-
// Flush any remaining queued operations before completing
|
|
121
|
-
await this.flushQueuedOperations();
|
|
122
|
-
await this.writeCompletion(finishReason);
|
|
123
|
-
await this.writeDone();
|
|
124
|
-
}
|
|
125
|
-
async writeData(type, data) {
|
|
126
|
-
await this.stream.writeSSE({
|
|
127
|
-
data: JSON.stringify({
|
|
128
|
-
id: this.requestId,
|
|
129
|
-
object: 'chat.completion.chunk',
|
|
130
|
-
created: this.timestamp,
|
|
131
|
-
choices: [
|
|
132
|
-
{
|
|
133
|
-
index: 0,
|
|
134
|
-
delta: {
|
|
135
|
-
content: JSON.stringify({ type, data }),
|
|
136
|
-
},
|
|
137
|
-
finish_reason: null,
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
}),
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
async writeOperation(operation) {
|
|
144
|
-
if (operation.type === 'status_update' && operation.ctx.operationType) {
|
|
145
|
-
operation = {
|
|
146
|
-
type: operation.ctx.operationType,
|
|
147
|
-
ctx: operation.ctx.data,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
// Queue operation if text is currently streaming
|
|
151
|
-
if (this.isTextStreaming) {
|
|
152
|
-
this.queuedOperations.push(operation);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
// If not streaming, flush any queued operations first, then send this one
|
|
156
|
-
await this.flushQueuedOperations();
|
|
157
|
-
await this.writeData('data-operation', operation);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Flush all queued operations in order after text streaming completes
|
|
161
|
-
*/
|
|
162
|
-
async flushQueuedOperations() {
|
|
163
|
-
if (this.queuedOperations.length === 0) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
const operationsToFlush = [...this.queuedOperations];
|
|
167
|
-
this.queuedOperations = []; // Clear the queue
|
|
168
|
-
for (const operation of operationsToFlush) {
|
|
169
|
-
await this.writeData('data-operation', operation);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Factory function to create SSE stream helper
|
|
175
|
-
*/
|
|
176
|
-
export function createSSEStreamHelper(stream, requestId, timestamp) {
|
|
177
|
-
return new SSEStreamHelper(stream, requestId, timestamp);
|
|
178
|
-
}
|
|
179
|
-
export class VercelDataStreamHelper {
|
|
180
|
-
writer;
|
|
181
|
-
textId = null;
|
|
182
|
-
jsonBuffer = '';
|
|
183
|
-
sentItems = new Map(); // Track what we've sent for each index
|
|
184
|
-
completedItems = new Set(); // Track completed items
|
|
185
|
-
sessionId = null;
|
|
186
|
-
// Memory management - focused on connection completion cleanup
|
|
187
|
-
static MAX_BUFFER_SIZE = 5 * 1024 * 1024; // 5MB limit (more generous during request)
|
|
188
|
-
isCompleted = false;
|
|
189
|
-
// Stream queuing for proper event ordering
|
|
190
|
-
isTextStreaming = false;
|
|
191
|
-
queuedOperations = [];
|
|
192
|
-
constructor(writer) {
|
|
193
|
-
this.writer = writer;
|
|
194
|
-
}
|
|
195
|
-
setSessionId(sessionId) {
|
|
196
|
-
this.sessionId = sessionId;
|
|
197
|
-
}
|
|
198
|
-
// This mirrors SSEStreamHelper API but outputs using Vercel AI SDK writer
|
|
199
|
-
async writeRole(_ = 'assistant') {
|
|
200
|
-
// noop
|
|
201
|
-
}
|
|
202
|
-
async writeContent(content) {
|
|
203
|
-
if (this.isCompleted) {
|
|
204
|
-
console.warn('Attempted to write content to completed stream');
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
if (!this.textId)
|
|
208
|
-
this.textId = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
209
|
-
// Only prevent catastrophic buffer growth during request
|
|
210
|
-
if (this.jsonBuffer.length + content.length > VercelDataStreamHelper.MAX_BUFFER_SIZE) {
|
|
211
|
-
// Keep more context since we're not cleaning up during request
|
|
212
|
-
const keepSize = Math.floor(VercelDataStreamHelper.MAX_BUFFER_SIZE * 0.8);
|
|
213
|
-
this.jsonBuffer = this.jsonBuffer.slice(-keepSize);
|
|
214
|
-
}
|
|
215
|
-
this.jsonBuffer += content;
|
|
216
|
-
const { value, state } = await parsePartialJson(this.jsonBuffer);
|
|
217
|
-
if (!['repaired-parse', 'successful-parse'].includes(state))
|
|
218
|
-
return;
|
|
219
|
-
if (!Array.isArray(value))
|
|
220
|
-
return;
|
|
221
|
-
for (let i = 0; i < value.length; i++) {
|
|
222
|
-
const { type, ...data } = value[i];
|
|
223
|
-
// TODO: Check for kind data and JSON.stringify
|
|
224
|
-
// Create a content hash to check if this item has changed
|
|
225
|
-
const currentContent = JSON.stringify(data);
|
|
226
|
-
const lastSentContent = this.sentItems.get(i);
|
|
227
|
-
// Only send if content has changed or is new
|
|
228
|
-
if (currentContent !== lastSentContent) {
|
|
229
|
-
const chunk = {
|
|
230
|
-
type: 'data-component',
|
|
231
|
-
id: `${this.textId}-${i}`,
|
|
232
|
-
data: { type, ...data },
|
|
233
|
-
};
|
|
234
|
-
this.writer.write(chunk);
|
|
235
|
-
this.sentItems.set(i, currentContent);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
async streamText(text, delayMs = 100) {
|
|
240
|
-
if (this.isCompleted) {
|
|
241
|
-
console.warn('Attempted to stream text to completed stream');
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
// For plain text, write directly to the stream as text chunks
|
|
245
|
-
if (!this.textId)
|
|
246
|
-
this.textId = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
247
|
-
const words = text.split(' ');
|
|
248
|
-
// ------------------------------
|
|
249
|
-
// New Vercel data-stream v2 format
|
|
250
|
-
// ------------------------------
|
|
251
|
-
// Emit "text-start" once at the beginning, followed by "text-delta" chunks
|
|
252
|
-
// for each word (with preceding space when necessary) and finish with
|
|
253
|
-
// a single "text-end".
|
|
254
|
-
const id = this.textId;
|
|
255
|
-
// Mark that text streaming is starting
|
|
256
|
-
this.isTextStreaming = true;
|
|
257
|
-
try {
|
|
258
|
-
this.writer.write({
|
|
259
|
-
type: 'text-start',
|
|
260
|
-
id,
|
|
261
|
-
});
|
|
262
|
-
// Deltas (optionally throttled)
|
|
263
|
-
for (let i = 0; i < words.length; i++) {
|
|
264
|
-
if (delayMs > 0) {
|
|
265
|
-
await new Promise((r) => setTimeout(r, delayMs));
|
|
266
|
-
}
|
|
267
|
-
const delta = i === 0 ? words[i] : ` ${words[i]}`;
|
|
268
|
-
this.writer.write({
|
|
269
|
-
type: 'text-delta',
|
|
270
|
-
id,
|
|
271
|
-
delta,
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
// End
|
|
275
|
-
this.writer.write({
|
|
276
|
-
type: 'text-end',
|
|
277
|
-
id,
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
finally {
|
|
281
|
-
// Mark that text streaming has finished
|
|
282
|
-
this.isTextStreaming = false;
|
|
283
|
-
// Flush any queued operations now that text sequence is complete
|
|
284
|
-
await this.flushQueuedOperations();
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
async writeData(type, data) {
|
|
288
|
-
if (this.isCompleted) {
|
|
289
|
-
console.warn('Attempted to write data to completed stream');
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
this.writer.write({
|
|
293
|
-
type: `${type}`,
|
|
294
|
-
data,
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
async writeError(errorMessage) {
|
|
298
|
-
if (this.isCompleted) {
|
|
299
|
-
console.warn('Attempted to write error to completed stream');
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
this.writer.write({
|
|
303
|
-
type: 'error',
|
|
304
|
-
errorText: errorMessage,
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
async streamData(data) {
|
|
308
|
-
await this.writeContent(JSON.stringify(data));
|
|
309
|
-
}
|
|
310
|
-
async mergeStream(stream) {
|
|
311
|
-
if (this.isCompleted) {
|
|
312
|
-
console.warn('Attempted to merge stream to completed stream');
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
this.writer.merge(stream);
|
|
316
|
-
}
|
|
317
|
-
async writeCompletion(_finishReason = 'stop') {
|
|
318
|
-
// Completion is handled automatically by Vercel's writer
|
|
319
|
-
}
|
|
320
|
-
async writeDone() {
|
|
321
|
-
// Done is handled automatically by Vercel's writer
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Complete the stream and clean up all memory
|
|
325
|
-
* This is the primary cleanup point to prevent memory leaks between requests
|
|
326
|
-
*/
|
|
327
|
-
async complete() {
|
|
328
|
-
if (this.isCompleted)
|
|
329
|
-
return;
|
|
330
|
-
// Flush any remaining queued operations before completing
|
|
331
|
-
await this.flushQueuedOperations();
|
|
332
|
-
// Mark as completed to prevent further writes
|
|
333
|
-
this.isCompleted = true;
|
|
334
|
-
// Clean up all buffers and references
|
|
335
|
-
this.cleanup();
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Clean up all memory allocations
|
|
339
|
-
* Should be called when the stream helper is no longer needed
|
|
340
|
-
*/
|
|
341
|
-
cleanup() {
|
|
342
|
-
this.jsonBuffer = '';
|
|
343
|
-
this.sentItems.clear();
|
|
344
|
-
this.completedItems.clear();
|
|
345
|
-
this.textId = null;
|
|
346
|
-
this.queuedOperations = [];
|
|
347
|
-
this.isTextStreaming = false;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Check if the stream has been completed and cleaned up
|
|
351
|
-
*/
|
|
352
|
-
isStreamCompleted() {
|
|
353
|
-
return this.isCompleted;
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Get current memory usage stats (for debugging/monitoring)
|
|
357
|
-
*/
|
|
358
|
-
getMemoryStats() {
|
|
359
|
-
return {
|
|
360
|
-
bufferSize: this.jsonBuffer.length,
|
|
361
|
-
sentItemsCount: this.sentItems.size,
|
|
362
|
-
completedItemsCount: this.completedItems.size,
|
|
363
|
-
isCompleted: this.isCompleted,
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
async writeOperation(operation) {
|
|
367
|
-
if (this.isCompleted) {
|
|
368
|
-
console.warn('Attempted to write operation to completed stream');
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
if (operation.type === 'status_update' && operation.ctx.operationType) {
|
|
372
|
-
operation = {
|
|
373
|
-
type: operation.ctx.operationType,
|
|
374
|
-
ctx: operation.ctx.data,
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
// Queue operation if text is currently streaming
|
|
378
|
-
if (this.isTextStreaming) {
|
|
379
|
-
this.queuedOperations.push(operation);
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
// If not streaming, flush any queued operations first, then send this one
|
|
383
|
-
await this.flushQueuedOperations();
|
|
384
|
-
this.writer.write({
|
|
385
|
-
id: 'id' in operation ? operation.id : undefined,
|
|
386
|
-
type: 'data-operation',
|
|
387
|
-
data: operation,
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Flush all queued operations in order after text streaming completes
|
|
392
|
-
*/
|
|
393
|
-
async flushQueuedOperations() {
|
|
394
|
-
if (this.queuedOperations.length === 0) {
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
const operationsToFlush = [...this.queuedOperations];
|
|
398
|
-
this.queuedOperations = []; // Clear the queue
|
|
399
|
-
for (const operation of operationsToFlush) {
|
|
400
|
-
this.writer.write({
|
|
401
|
-
id: 'id' in operation ? operation.id : undefined,
|
|
402
|
-
type: 'data-operation',
|
|
403
|
-
data: operation,
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
export function createVercelStreamHelper(writer) {
|
|
409
|
-
return new VercelDataStreamHelper(writer);
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* MCP Stream Helper that captures content instead of streaming
|
|
413
|
-
* Used for MCP tool responses which require a single response message
|
|
414
|
-
*/
|
|
415
|
-
export class MCPStreamHelper {
|
|
416
|
-
capturedText = '';
|
|
417
|
-
capturedData = [];
|
|
418
|
-
capturedOperations = [];
|
|
419
|
-
hasError = false;
|
|
420
|
-
errorMessage = '';
|
|
421
|
-
sessionId = null;
|
|
422
|
-
setSessionId(sessionId) {
|
|
423
|
-
this.sessionId = sessionId;
|
|
424
|
-
}
|
|
425
|
-
async writeRole(_role) {
|
|
426
|
-
// No-op for MCP
|
|
427
|
-
}
|
|
428
|
-
async writeContent(content) {
|
|
429
|
-
this.capturedText += content;
|
|
430
|
-
}
|
|
431
|
-
async streamText(text, _delayMs) {
|
|
432
|
-
// Capture text without streaming delay
|
|
433
|
-
this.capturedText += text;
|
|
434
|
-
}
|
|
435
|
-
async streamData(data) {
|
|
436
|
-
this.capturedData.push(data);
|
|
437
|
-
}
|
|
438
|
-
async writeData(_type, data) {
|
|
439
|
-
this.capturedData.push(data);
|
|
440
|
-
}
|
|
441
|
-
async writeError(errorMessage) {
|
|
442
|
-
this.hasError = true;
|
|
443
|
-
this.errorMessage = errorMessage;
|
|
444
|
-
}
|
|
445
|
-
async complete() {
|
|
446
|
-
// No-op for MCP
|
|
447
|
-
}
|
|
448
|
-
async writeOperation(operation) {
|
|
449
|
-
this.capturedOperations.push(operation);
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Get the captured response for MCP tool result
|
|
453
|
-
*/
|
|
454
|
-
getCapturedResponse() {
|
|
455
|
-
return {
|
|
456
|
-
text: this.capturedText,
|
|
457
|
-
data: this.capturedData,
|
|
458
|
-
operations: this.capturedOperations,
|
|
459
|
-
hasError: this.hasError,
|
|
460
|
-
errorMessage: this.errorMessage,
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
export function createMCPStreamHelper() {
|
|
465
|
-
return new MCPStreamHelper();
|
|
466
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { StreamHelper } from './stream-helpers';
|
|
2
|
-
/**
|
|
3
|
-
* Register a StreamHelper for a specific request ID
|
|
4
|
-
*/
|
|
5
|
-
export declare function registerStreamHelper(requestId: string, streamHelper: StreamHelper): void;
|
|
6
|
-
/**
|
|
7
|
-
* Get a StreamHelper by request ID
|
|
8
|
-
*/
|
|
9
|
-
export declare function getStreamHelper(requestId: string): StreamHelper | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Unregister a StreamHelper for a specific request ID
|
|
12
|
-
*/
|
|
13
|
-
export declare function unregisterStreamHelper(requestId: string): void;
|
|
14
|
-
/**
|
|
15
|
-
* Get registry size (for debugging)
|
|
16
|
-
*/
|
|
17
|
-
export declare function getRegistrySize(): number;
|
|
18
|
-
//# sourceMappingURL=stream-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream-registry.d.ts","sourceRoot":"","sources":["../../src/utils/stream-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQrD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI,CAOxF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAE3E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
|