@automattic/agenttic-client 0.1.10 → 0.1.11
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/index.d.ts.map +1 -1
- package/dist/client/types/index.d.ts +5 -1
- package/dist/client/types/index.d.ts.map +1 -1
- package/dist/client/utils/core.d.ts +2 -1
- package/dist/client/utils/core.d.ts.map +1 -1
- package/dist/client/utils/index.d.ts +1 -1
- package/dist/client/utils/index.d.ts.map +1 -1
- package/dist/client/utils/internal/requests.d.ts +1 -0
- package/dist/client/utils/internal/requests.d.ts.map +1 -1
- package/dist/client/utils/internal/streaming.d.ts +63 -3
- package/dist/client/utils/internal/streaming.d.ts.map +1 -1
- package/dist/index.js +328 -55
- package/dist/react/useAgentChat.d.ts +1 -0
- package/dist/react/useAgentChat.d.ts.map +1 -1
- package/dist/utils/markdownParser.d.ts +2 -2
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EACN,YAAY,EAGZ,iBAAiB,EAEjB,UAAU,EAIV,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EACN,YAAY,EAGZ,iBAAiB,EAEjB,UAAU,EAIV,MAAM,eAAe,CAAC;AAsEvB;;GAEG;AACH,iBAAS,uBAAuB,IAAI,IAAI,CAEvC;AAED;;;;GAIG;AACH,iBAAS,qCAAqC,CAAE,WAAW,EAAE,GAAG,EAAE,GAAI,GAAG,EAAE,CA4B1E;AAmsBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,qCAAqC,EAAE,uBAAuB,EAAE,CAAC;AAE1E,wBAAgB,YAAY,CAAE,MAAM,EAAE,YAAY,GAAI,MAAM,CAsV3D;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,GACvB,OAAO,CAAE,UAAU,CAAE,CAavB"}
|
|
@@ -106,7 +106,9 @@ export interface MessageSendParams {
|
|
|
106
106
|
message: Message;
|
|
107
107
|
metadata?: Record<string, unknown>;
|
|
108
108
|
}
|
|
109
|
-
export
|
|
109
|
+
export interface SendMessageRequest extends JsonRpcRequest<MessageSendParams> {
|
|
110
|
+
tokenStreaming?: boolean;
|
|
111
|
+
}
|
|
110
112
|
export type SendMessageResponse = JsonRpcResponse<Task>;
|
|
111
113
|
export interface TaskStatusUpdateEvent {
|
|
112
114
|
id: string;
|
|
@@ -137,6 +139,7 @@ export interface ClientConfig {
|
|
|
137
139
|
toolProvider?: ToolProvider;
|
|
138
140
|
contextProvider?: ContextProvider;
|
|
139
141
|
conversationStorageKey?: string;
|
|
142
|
+
enableStreaming?: boolean;
|
|
140
143
|
}
|
|
141
144
|
export interface SendMessageParams {
|
|
142
145
|
message: Message;
|
|
@@ -145,6 +148,7 @@ export interface SendMessageParams {
|
|
|
145
148
|
metadata?: Record<string, unknown>;
|
|
146
149
|
withHistory?: boolean;
|
|
147
150
|
abortSignal?: AbortSignal;
|
|
151
|
+
enableStreaming?: boolean;
|
|
148
152
|
}
|
|
149
153
|
export interface TaskUpdate {
|
|
150
154
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/types/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExC,MAAM,WAAW,cAAc,CAAE,OAAO,GAAG,OAAO;IACjD,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,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QACf,UAAU,EAAE,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;QACtC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACF;AAED,MAAM,WAAW,mBAAmB;IACnC,MAAM,EAAE,GAAG,CAAC;IACZ,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC5B,iBAAiB,IAAI,OAAO,CAAE,IAAI,EAAE,CAAE,CAAC;IACvC,WAAW,CACV,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACT,SAAS,CAAC,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,MAAM,GACjB,OAAO,CAAE,GAAG,GAAG,mBAAmB,CAAE,CAAC;CACxC;AAED,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,MAAM,aAAa,GAAG,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC/B,gBAAgB,IAAI,aAAa,CAAC;CAClC"}
|
|
@@ -24,8 +24,9 @@ export declare function createTextPart(text: string): TextPart;
|
|
|
24
24
|
* Create a message/send request payload
|
|
25
25
|
* @param params
|
|
26
26
|
* @param method
|
|
27
|
+
* @param tokenStreaming - Whether to enable token streaming
|
|
27
28
|
*/
|
|
28
|
-
export declare function createSendMessageRequest(params: MessageSendParams, method?: string): SendMessageRequest;
|
|
29
|
+
export declare function createSendMessageRequest(params: MessageSendParams, method?: string, tokenStreaming?: boolean): SendMessageRequest;
|
|
29
30
|
/**
|
|
30
31
|
* Extract text content from a message
|
|
31
32
|
* @param message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/client/utils/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,eAAe,EACf,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAQzC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAE,IAAI,EAAE,MAAM,GAAI,QAAQ,CAKvD;AAED
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/client/utils/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,eAAe,EACf,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,kBAAkB,EAClB,QAAQ,EACR,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAQzC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAE,IAAI,EAAE,MAAM,GAAI,QAAQ,CAKvD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,iBAAiB,EACzB,MAAM,GAAE,MAAuB,EAC/B,cAAc,GAAE,OAAe,GAC7B,kBAAkB,CAgBpB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAE,OAAO,EAAE,OAAO,GAAI,MAAM,CASjE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAE,IAAI,EAAE,IAAI,GAAI,YAAY,CAW7D;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,OAAO,GACd,gBAAgB,EAAE,CAYpB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACvC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,MAAM,GACZ,kBAAkB,CAUpB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,aAAa,EAAE,aAAa,GAC1B,eAAe,CAQjB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAE,IAAI,EAAE,MAAM,GAAI,OAAO,CAUzD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAE,IAAI,EAAE,MAAM,GAAI,OAAO,CAU9D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAE,eAAe,EAAE,GAAG,GAAI;IACnE,MAAM,EAAE,GAAG,CAAC;IACZ,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAmBA;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,WAAW,EAAE,kBAAkB,EAAE,EACjC,gBAAgB,GAAE,GAAG,EAAO,GAC1B,OAAO,CAUT;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAEvD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createRequestId, createTaskId, createTextPart, createSendMessageRequest, extractTextFromMessage, extractToolCallsFromMessage, createToolDataPart, createToolResultDataPart, createContextDataPart, createTextMessage, createAgentTextMessage, createToolResultMessage, processToolExecutionResult, generateMessageId, } from './core';
|
|
2
2
|
export { executeRequest, executeStreamingRequest, prepareRequest, type RequestConfig, type RequestOptions, } from './internal/requests';
|
|
3
|
-
export { parseStreamChunk, parseSSEStream, streamToTask, } from './internal/streaming';
|
|
3
|
+
export { parseStreamChunk, parseSSEStream, streamToTask, type ParseSSEStreamOptions, } from './internal/streaming';
|
|
4
4
|
export { enhanceMessage, enhanceMessageWithTools, enhanceMessageWithContext, } from './internal/messages';
|
|
5
5
|
export { getToolCallCount, hasToolCalls } from './internal/tools';
|
|
6
6
|
export { createTimeoutHandler, handleRequestError, validateHttpResponse, validateJsonRpcResponse, validateStreamingResponse, } from './internal/errors';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,eAAe,EACf,YAAY,EACZ,cAAc,EACd,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,iBAAiB,GACjB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACN,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,eAAe,EACf,YAAY,EACZ,cAAc,EACd,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,iBAAiB,GACjB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACN,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,KAAK,qBAAqB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACN,cAAc,EACd,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/internal/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EAEZ,iBAAiB,EACjB,IAAI,EACJ,UAAU,EACV,MAAM,mBAAmB,CAAC;AAa3B;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAaD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;CAC1B;AAkHD;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CACnC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,EACvB,YAAY,CAAC,EAAE,GAAG,EAClB,eAAe,CAAC,EAAE,GAAG,EACrB,gBAAgB,CAAC,EAAE,MAAM;;;;;;
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/internal/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EAEZ,iBAAiB,EACjB,IAAI,EACJ,UAAU,EACV,MAAM,mBAAmB,CAAC;AAa3B;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAaD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;CAC1B;AAkHD;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CACnC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,EACvB,YAAY,CAAC,EAAE,GAAG,EAClB,eAAe,CAAC,EAAE,GAAG,EACrB,gBAAgB,CAAC,EAAE,MAAM;;;;;;GA0CzB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CACnC,eAAe,EAAE,OAAO,CAAE,UAAU,CAAE,OAAO,cAAc,CAAE,CAAE,EAC/D,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,cAAmB,GAC1B,OAAO,CAAE,IAAI,CAAE,CAkDjB;AAED;;;;;;;GAOG;AACH,wBAAuB,uBAAuB,CAC7C,eAAe,EAAE,OAAO,CAAE,UAAU,CAAE,OAAO,cAAc,CAAE,CAAE,EAC/D,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,GACrB,aAAa,CAAE,UAAU,CAAE,CA+C7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Task, TaskUpdate } from '../../types/index';
|
|
1
|
+
import type { Message, Task, TaskUpdate } from '../../types/index';
|
|
2
2
|
/**
|
|
3
3
|
* Parse a stream chunk from a server-sent events stream.
|
|
4
4
|
* This function processes an incoming chunk of data, potentially combined with a buffer
|
|
@@ -10,14 +10,74 @@ export declare function parseStreamChunk(chunk: string, buffer?: string): {
|
|
|
10
10
|
events: Record<string, any>[];
|
|
11
11
|
nextBuffer: string;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Options for parsing SSE streams
|
|
15
|
+
*/
|
|
16
|
+
export interface ParseSSEStreamOptions {
|
|
17
|
+
/** Whether to process delta messages for token streaming. Default: false */
|
|
18
|
+
supportDeltas?: boolean;
|
|
19
|
+
}
|
|
13
20
|
/**
|
|
14
21
|
* Parse SSE stream and yield task updates
|
|
15
|
-
*
|
|
22
|
+
* Handles delta messages, regular task updates, and JSON-RPC responses
|
|
23
|
+
* @param stream - The readable stream to parse
|
|
24
|
+
* @param options - Configuration options for parsing
|
|
16
25
|
*/
|
|
17
|
-
export declare function parseSSEStream(stream: ReadableStream<Uint8Array
|
|
26
|
+
export declare function parseSSEStream(stream: ReadableStream<Uint8Array>, options?: ParseSSEStreamOptions): AsyncIterable<TaskUpdate>;
|
|
18
27
|
/**
|
|
19
28
|
* Convert a streaming response to a final task result
|
|
20
29
|
* @param stream
|
|
21
30
|
*/
|
|
22
31
|
export declare function streamToTask(stream: AsyncIterable<TaskUpdate>): Promise<Task>;
|
|
32
|
+
/**
|
|
33
|
+
* Delta message types from the server
|
|
34
|
+
*/
|
|
35
|
+
export interface ContentDelta {
|
|
36
|
+
type: 'content';
|
|
37
|
+
content: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ToolNameDelta {
|
|
40
|
+
type: 'tool_name';
|
|
41
|
+
content: string;
|
|
42
|
+
toolCallId: string;
|
|
43
|
+
toolCallIndex: number;
|
|
44
|
+
}
|
|
45
|
+
export interface ToolArgumentDelta {
|
|
46
|
+
type: 'tool_argument';
|
|
47
|
+
content: string;
|
|
48
|
+
toolCallId: string;
|
|
49
|
+
toolCallIndex: number;
|
|
50
|
+
}
|
|
51
|
+
export type DeltaMessage = ContentDelta | ToolNameDelta | ToolArgumentDelta;
|
|
52
|
+
/**
|
|
53
|
+
* Accumulator for delta messages
|
|
54
|
+
* Manages the state of partial messages during streaming
|
|
55
|
+
*/
|
|
56
|
+
export declare class DeltaAccumulator {
|
|
57
|
+
private textContent;
|
|
58
|
+
private toolCalls;
|
|
59
|
+
/**
|
|
60
|
+
* Process a simple content delta (server's actual format)
|
|
61
|
+
* @param content - The text content to append
|
|
62
|
+
*/
|
|
63
|
+
processContentDelta(content: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Process a delta message and accumulate the content (original format)
|
|
66
|
+
* @param delta - The delta message to process
|
|
67
|
+
*/
|
|
68
|
+
processDelta(delta: DeltaMessage): void;
|
|
69
|
+
/**
|
|
70
|
+
* Get the accumulated text content
|
|
71
|
+
*/
|
|
72
|
+
getTextContent(): string;
|
|
73
|
+
/**
|
|
74
|
+
* Get the current accumulated message
|
|
75
|
+
* @param role - The role for the message (default: 'agent')
|
|
76
|
+
*/
|
|
77
|
+
getCurrentMessage(role?: 'agent' | 'user'): Message;
|
|
78
|
+
/**
|
|
79
|
+
* Reset the accumulator
|
|
80
|
+
*/
|
|
81
|
+
reset(): void;
|
|
82
|
+
}
|
|
23
83
|
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/internal/streaming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../../../src/client/utils/internal/streaming.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,mBAAmB,C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AE,YAAY,GAAI,IAAI;IAgChD;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;;OAGG;IACI,iBAAiB,CAAE,IAAI,GAAE,OAAO,GAAG,MAAgB,GAAI,OAAO;IAgDrE;;OAEG;IACI,KAAK,IAAI,IAAI;CAIpB"}
|
package/dist/index.js
CHANGED
|
@@ -113,8 +113,8 @@ function createTextPart(text) {
|
|
|
113
113
|
text
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
function createSendMessageRequest(params, method = "message/send") {
|
|
117
|
-
|
|
116
|
+
function createSendMessageRequest(params, method = "message/send", tokenStreaming = false) {
|
|
117
|
+
const request = {
|
|
118
118
|
jsonrpc: "2.0",
|
|
119
119
|
id: createRequestId(),
|
|
120
120
|
method,
|
|
@@ -123,6 +123,10 @@ function createSendMessageRequest(params, method = "message/send") {
|
|
|
123
123
|
...params
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
+
if (tokenStreaming && method === "message/stream") {
|
|
127
|
+
request.tokenStreaming = true;
|
|
128
|
+
}
|
|
129
|
+
return request;
|
|
126
130
|
}
|
|
127
131
|
function extractTextFromMessage(message) {
|
|
128
132
|
if (!message || !message.parts || !Array.isArray(message.parts)) {
|
|
@@ -315,10 +319,14 @@ function parseStreamChunk(chunk, buffer = "") {
|
|
|
315
319
|
const nextBuffer = currentStreamData.substring(lastCompleteEventEnd);
|
|
316
320
|
return { events, nextBuffer };
|
|
317
321
|
}
|
|
318
|
-
async function* parseSSEStream(stream) {
|
|
322
|
+
async function* parseSSEStream(stream, options = {}) {
|
|
323
|
+
const { supportDeltas = false } = options;
|
|
319
324
|
const reader = stream.getReader();
|
|
320
325
|
const decoder = new TextDecoder();
|
|
321
326
|
let buffer = "";
|
|
327
|
+
const accumulator = new DeltaAccumulator();
|
|
328
|
+
let currentTaskId = null;
|
|
329
|
+
let lastStatus = null;
|
|
322
330
|
try {
|
|
323
331
|
while (true) {
|
|
324
332
|
const { done, value } = await reader.read();
|
|
@@ -328,13 +336,50 @@ async function* parseSSEStream(stream) {
|
|
|
328
336
|
const chunk = decoder.decode(value, { stream: true });
|
|
329
337
|
const { events, nextBuffer } = parseStreamChunk(chunk, buffer);
|
|
330
338
|
if (events && Array.isArray(events)) {
|
|
331
|
-
for (
|
|
339
|
+
for (let i = 0; i < events.length; i++) {
|
|
340
|
+
const event = events[i];
|
|
341
|
+
if (i > 0 && event.method === "message/delta" && typeof requestAnimationFrame !== "undefined") {
|
|
342
|
+
await new Promise((resolve) => {
|
|
343
|
+
requestAnimationFrame(() => resolve(void 0));
|
|
344
|
+
});
|
|
345
|
+
}
|
|
332
346
|
if (event.error) {
|
|
333
347
|
throw new Error(
|
|
334
348
|
`Streaming error: ${event.error.message}`
|
|
335
349
|
);
|
|
336
350
|
}
|
|
337
|
-
if (event.
|
|
351
|
+
if (supportDeltas && event.method === "message/delta" && event.params?.delta) {
|
|
352
|
+
const delta = event.params.delta;
|
|
353
|
+
try {
|
|
354
|
+
if (delta.deltaType === "content") {
|
|
355
|
+
accumulator.processContentDelta(
|
|
356
|
+
delta.content
|
|
357
|
+
);
|
|
358
|
+
if (!currentTaskId && event.params.id) {
|
|
359
|
+
currentTaskId = event.params.id;
|
|
360
|
+
}
|
|
361
|
+
if (currentTaskId) {
|
|
362
|
+
const currentMessage = accumulator.getCurrentMessage();
|
|
363
|
+
yield {
|
|
364
|
+
id: currentTaskId,
|
|
365
|
+
status: {
|
|
366
|
+
state: "working",
|
|
367
|
+
message: currentMessage
|
|
368
|
+
},
|
|
369
|
+
final: false,
|
|
370
|
+
text: accumulator.getTextContent()
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
} catch (error) {
|
|
375
|
+
logger("Failed to process delta: %o", error);
|
|
376
|
+
}
|
|
377
|
+
} else if (event.result && event.result.status) {
|
|
378
|
+
currentTaskId = event.result.id;
|
|
379
|
+
lastStatus = event.result.status;
|
|
380
|
+
if (accumulator.getTextContent() || accumulator.getCurrentMessage().parts.length > 0) {
|
|
381
|
+
accumulator.reset();
|
|
382
|
+
}
|
|
338
383
|
const update = {
|
|
339
384
|
id: event.result.id,
|
|
340
385
|
status: event.result.status,
|
|
@@ -347,6 +392,22 @@ async function* parseSSEStream(stream) {
|
|
|
347
392
|
)
|
|
348
393
|
};
|
|
349
394
|
yield update;
|
|
395
|
+
} else if (event.id && event.result) {
|
|
396
|
+
currentTaskId = event.result.id;
|
|
397
|
+
if (event.result.status) {
|
|
398
|
+
const update = {
|
|
399
|
+
id: event.result.id,
|
|
400
|
+
status: event.result.status,
|
|
401
|
+
final: event.result.status.state === "completed" || event.result.status.state === "failed" || event.result.status.state === "canceled",
|
|
402
|
+
text: extractTextFromMessage(
|
|
403
|
+
event.result.status?.message || {
|
|
404
|
+
role: "agent",
|
|
405
|
+
parts: []
|
|
406
|
+
}
|
|
407
|
+
)
|
|
408
|
+
};
|
|
409
|
+
yield update;
|
|
410
|
+
}
|
|
350
411
|
}
|
|
351
412
|
}
|
|
352
413
|
}
|
|
@@ -356,6 +417,103 @@ async function* parseSSEStream(stream) {
|
|
|
356
417
|
reader.releaseLock();
|
|
357
418
|
}
|
|
358
419
|
}
|
|
420
|
+
var DeltaAccumulator = class {
|
|
421
|
+
textContent = "";
|
|
422
|
+
toolCalls = /* @__PURE__ */ new Map();
|
|
423
|
+
/**
|
|
424
|
+
* Process a simple content delta (server's actual format)
|
|
425
|
+
* @param content - The text content to append
|
|
426
|
+
*/
|
|
427
|
+
processContentDelta(content) {
|
|
428
|
+
this.textContent += content;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Process a delta message and accumulate the content (original format)
|
|
432
|
+
* @param delta - The delta message to process
|
|
433
|
+
*/
|
|
434
|
+
processDelta(delta) {
|
|
435
|
+
switch (delta.type) {
|
|
436
|
+
case "content":
|
|
437
|
+
this.textContent += delta.content;
|
|
438
|
+
break;
|
|
439
|
+
case "tool_name":
|
|
440
|
+
if (!this.toolCalls.has(delta.toolCallIndex)) {
|
|
441
|
+
this.toolCalls.set(delta.toolCallIndex, {
|
|
442
|
+
toolCallId: delta.toolCallId,
|
|
443
|
+
toolName: "",
|
|
444
|
+
argumentFragments: []
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
const toolCall = this.toolCalls.get(delta.toolCallIndex);
|
|
448
|
+
toolCall.toolName += delta.content;
|
|
449
|
+
break;
|
|
450
|
+
case "tool_argument":
|
|
451
|
+
if (!this.toolCalls.has(delta.toolCallIndex)) {
|
|
452
|
+
this.toolCalls.set(delta.toolCallIndex, {
|
|
453
|
+
toolCallId: delta.toolCallId,
|
|
454
|
+
toolName: "",
|
|
455
|
+
argumentFragments: []
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
const call = this.toolCalls.get(delta.toolCallIndex);
|
|
459
|
+
call.argumentFragments.push(delta.content);
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Get the accumulated text content
|
|
465
|
+
*/
|
|
466
|
+
getTextContent() {
|
|
467
|
+
return this.textContent;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Get the current accumulated message
|
|
471
|
+
* @param role - The role for the message (default: 'agent')
|
|
472
|
+
*/
|
|
473
|
+
getCurrentMessage(role = "agent") {
|
|
474
|
+
const parts = [];
|
|
475
|
+
if (this.textContent) {
|
|
476
|
+
parts.push({
|
|
477
|
+
type: "text",
|
|
478
|
+
text: this.textContent
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
for (const [index, toolCall] of this.toolCalls) {
|
|
482
|
+
if (toolCall.toolName) {
|
|
483
|
+
const argumentsStr = toolCall.argumentFragments.join("");
|
|
484
|
+
let args = {};
|
|
485
|
+
if (argumentsStr) {
|
|
486
|
+
try {
|
|
487
|
+
args = JSON.parse(argumentsStr);
|
|
488
|
+
} catch {
|
|
489
|
+
args = { _raw: argumentsStr };
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
parts.push({
|
|
493
|
+
type: "data",
|
|
494
|
+
data: {
|
|
495
|
+
toolCallId: toolCall.toolCallId,
|
|
496
|
+
toolId: toolCall.toolName,
|
|
497
|
+
arguments: args
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return {
|
|
503
|
+
role,
|
|
504
|
+
parts,
|
|
505
|
+
kind: "message",
|
|
506
|
+
messageId: generateMessageId()
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Reset the accumulator
|
|
511
|
+
*/
|
|
512
|
+
reset() {
|
|
513
|
+
this.textContent = "";
|
|
514
|
+
this.toolCalls.clear();
|
|
515
|
+
}
|
|
516
|
+
};
|
|
359
517
|
|
|
360
518
|
// src/client/utils/internal/errors.ts
|
|
361
519
|
function handleRequestError(error, timeoutId, operation = "request") {
|
|
@@ -457,7 +615,7 @@ function createFetchOptions(headers, body, signal) {
|
|
|
457
615
|
async function prepareRequest(params, config, options, toolProvider, contextProvider, defaultSessionId) {
|
|
458
616
|
const { message, sessionId, taskId, metadata } = params;
|
|
459
617
|
const { agentId, agentUrl, authProvider, proxy } = config;
|
|
460
|
-
const { isStreaming = false } = options;
|
|
618
|
+
const { isStreaming = false, enableTokenStreaming = false } = options;
|
|
461
619
|
const effectiveSessionId = sessionId || defaultSessionId;
|
|
462
620
|
const fullAgentUrl = constructAgentUrl(agentUrl, agentId);
|
|
463
621
|
const enhancedMessage = await enhanceMessage(
|
|
@@ -472,7 +630,9 @@ async function prepareRequest(params, config, options, toolProvider, contextProv
|
|
|
472
630
|
message: enhancedMessage,
|
|
473
631
|
metadata
|
|
474
632
|
},
|
|
475
|
-
isStreaming ? "message/stream" : "message/send"
|
|
633
|
+
isStreaming ? "message/stream" : "message/send",
|
|
634
|
+
enableTokenStreaming && isStreaming
|
|
635
|
+
// Only enable token streaming if using SSE
|
|
476
636
|
);
|
|
477
637
|
const headers = await getHeaders(authProvider, isStreaming);
|
|
478
638
|
logRequest("POST", fullAgentUrl, headers, request);
|
|
@@ -521,22 +681,31 @@ async function executeRequest(preparedRequest, config, options = {}) {
|
|
|
521
681
|
async function* executeStreamingRequest(preparedRequest, config, options) {
|
|
522
682
|
const { request, headers, fullAgentUrl } = preparedRequest;
|
|
523
683
|
const {} = config;
|
|
524
|
-
const {
|
|
684
|
+
const {
|
|
685
|
+
streamingTimeout = 6e4,
|
|
686
|
+
abortSignal: externalSignal,
|
|
687
|
+
enableTokenStreaming = false
|
|
688
|
+
} = options;
|
|
525
689
|
const { timeoutId, controller } = createTimeoutHandler(
|
|
526
690
|
streamingTimeout,
|
|
527
691
|
"streaming request"
|
|
528
692
|
);
|
|
529
693
|
const signal = externalSignal ? combineSignals(controller.signal, externalSignal) : controller.signal;
|
|
530
694
|
try {
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
JSON.stringify(request),
|
|
534
|
-
signal
|
|
535
|
-
);
|
|
695
|
+
const requestBody = JSON.stringify(request);
|
|
696
|
+
const fetchOptions = createFetchOptions(headers, requestBody, signal);
|
|
536
697
|
const response = await fetch(fullAgentUrl, fetchOptions);
|
|
537
698
|
clearTimeout(timeoutId);
|
|
538
699
|
validateStreamingResponse(response, "streaming request");
|
|
539
|
-
|
|
700
|
+
if (!response.body) {
|
|
701
|
+
throw new Error(
|
|
702
|
+
"Response body is null - server may not support streaming"
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
const supportDeltas = enableTokenStreaming && request.tokenStreaming === true;
|
|
706
|
+
yield* parseSSEStream(response.body, {
|
|
707
|
+
supportDeltas
|
|
708
|
+
});
|
|
540
709
|
} catch (error) {
|
|
541
710
|
handleRequestError(error, timeoutId, "streaming request");
|
|
542
711
|
}
|
|
@@ -673,23 +842,27 @@ async function continueTask(taskId, message, requestConfig, toolProvider, contex
|
|
|
673
842
|
abortSignal
|
|
674
843
|
});
|
|
675
844
|
}
|
|
676
|
-
async function continueTaskStreamed(taskId, message, requestConfig, toolProvider, contextProvider, sessionId, abortSignal) {
|
|
845
|
+
async function continueTaskStreamed(taskId, message, requestConfig, toolProvider, contextProvider, sessionId, abortSignal, requestOptions) {
|
|
677
846
|
const continueParams = {
|
|
678
847
|
message,
|
|
679
848
|
taskId,
|
|
680
849
|
sessionId: void 0
|
|
681
850
|
// Use task's session
|
|
682
851
|
};
|
|
852
|
+
const options = requestOptions || { isStreaming: true };
|
|
683
853
|
const preparedRequest = await prepareRequest(
|
|
684
854
|
continueParams,
|
|
685
855
|
requestConfig,
|
|
686
|
-
{
|
|
856
|
+
{
|
|
857
|
+
...options,
|
|
858
|
+
abortSignal
|
|
859
|
+
},
|
|
687
860
|
toolProvider,
|
|
688
861
|
contextProvider,
|
|
689
862
|
sessionId
|
|
690
863
|
);
|
|
691
864
|
const stream = executeStreamingRequest(preparedRequest, requestConfig, {
|
|
692
|
-
|
|
865
|
+
...options,
|
|
693
866
|
abortSignal
|
|
694
867
|
});
|
|
695
868
|
return processAgentResponseStream(
|
|
@@ -702,10 +875,12 @@ async function continueTaskStreamed(taskId, message, requestConfig, toolProvider
|
|
|
702
875
|
// withHistory
|
|
703
876
|
[],
|
|
704
877
|
// newConversationParts - empty for continueTask
|
|
705
|
-
abortSignal
|
|
878
|
+
abortSignal,
|
|
879
|
+
options
|
|
880
|
+
// Pass through the same request options
|
|
706
881
|
);
|
|
707
882
|
}
|
|
708
|
-
async function* processAgentResponseStream(stream, toolProvider, contextProvider, requestConfig, sessionId, withHistory = true, newConversationParts = [], abortSignal) {
|
|
883
|
+
async function* processAgentResponseStream(stream, toolProvider, contextProvider, requestConfig, sessionId, withHistory = true, newConversationParts = [], abortSignal, requestOptions) {
|
|
709
884
|
for await (const update of stream) {
|
|
710
885
|
yield update;
|
|
711
886
|
if (update.status.state === "running" && update.status.message && toolProvider && await hasMatchingToolCallbacks(
|
|
@@ -838,7 +1013,8 @@ async function* processAgentResponseStream(stream, toolProvider, contextProvider
|
|
|
838
1013
|
toolProvider,
|
|
839
1014
|
contextProvider,
|
|
840
1015
|
sessionId,
|
|
841
|
-
abortSignal
|
|
1016
|
+
abortSignal,
|
|
1017
|
+
requestOptions
|
|
842
1018
|
);
|
|
843
1019
|
let continuedTaskUpdate = null;
|
|
844
1020
|
for await (const streamUpdate of continuedTaskStream) {
|
|
@@ -924,7 +1100,8 @@ async function* processAgentResponseStream(stream, toolProvider, contextProvider
|
|
|
924
1100
|
toolProvider,
|
|
925
1101
|
contextProvider,
|
|
926
1102
|
sessionId,
|
|
927
|
-
abortSignal
|
|
1103
|
+
abortSignal,
|
|
1104
|
+
requestOptions
|
|
928
1105
|
);
|
|
929
1106
|
let moreFinalTask = null;
|
|
930
1107
|
for await (const streamUpdate of moreTaskStream) {
|
|
@@ -1017,7 +1194,8 @@ function createClient(config) {
|
|
|
1017
1194
|
defaultSessionId,
|
|
1018
1195
|
timeout = DEFAULT_TIMEOUT,
|
|
1019
1196
|
toolProvider,
|
|
1020
|
-
contextProvider
|
|
1197
|
+
contextProvider,
|
|
1198
|
+
enableStreaming = false
|
|
1021
1199
|
} = config;
|
|
1022
1200
|
const requestConfig = {
|
|
1023
1201
|
agentId,
|
|
@@ -1150,14 +1328,26 @@ function createClient(config) {
|
|
|
1150
1328
|
};
|
|
1151
1329
|
},
|
|
1152
1330
|
async *sendMessageStream(params) {
|
|
1153
|
-
const {
|
|
1331
|
+
const {
|
|
1332
|
+
withHistory = true,
|
|
1333
|
+
abortSignal,
|
|
1334
|
+
enableStreaming: requestStreaming
|
|
1335
|
+
} = params;
|
|
1154
1336
|
const sessionId = params.sessionId || defaultSessionId || void 0;
|
|
1337
|
+
const useTokenStreaming = requestStreaming ?? enableStreaming;
|
|
1155
1338
|
const newConversationParts = [];
|
|
1156
1339
|
newConversationParts.push(params.message);
|
|
1157
1340
|
const preparedRequest = await prepareRequest(
|
|
1158
1341
|
params,
|
|
1159
1342
|
requestConfig,
|
|
1160
|
-
{
|
|
1343
|
+
{
|
|
1344
|
+
isStreaming: true,
|
|
1345
|
+
// Always use message/stream endpoint for SSE
|
|
1346
|
+
enableTokenStreaming: useTokenStreaming,
|
|
1347
|
+
// Optional token-by-token streaming
|
|
1348
|
+
streamingTimeout: timeout,
|
|
1349
|
+
abortSignal
|
|
1350
|
+
},
|
|
1161
1351
|
toolProvider,
|
|
1162
1352
|
contextProvider,
|
|
1163
1353
|
sessionId
|
|
@@ -1167,6 +1357,8 @@ function createClient(config) {
|
|
|
1167
1357
|
requestConfig,
|
|
1168
1358
|
{
|
|
1169
1359
|
isStreaming: true,
|
|
1360
|
+
enableTokenStreaming: useTokenStreaming,
|
|
1361
|
+
// Token streaming is optional
|
|
1170
1362
|
streamingTimeout: timeout,
|
|
1171
1363
|
abortSignal
|
|
1172
1364
|
}
|
|
@@ -1179,7 +1371,12 @@ function createClient(config) {
|
|
|
1179
1371
|
sessionId,
|
|
1180
1372
|
withHistory,
|
|
1181
1373
|
newConversationParts,
|
|
1182
|
-
abortSignal
|
|
1374
|
+
abortSignal,
|
|
1375
|
+
{
|
|
1376
|
+
isStreaming: true,
|
|
1377
|
+
enableTokenStreaming: useTokenStreaming,
|
|
1378
|
+
streamingTimeout: timeout
|
|
1379
|
+
}
|
|
1183
1380
|
);
|
|
1184
1381
|
},
|
|
1185
1382
|
async continueTask(taskId, userInput, sessionId) {
|
|
@@ -1759,7 +1956,7 @@ function getAgentManager() {
|
|
|
1759
1956
|
}
|
|
1760
1957
|
|
|
1761
1958
|
// src/utils/createMessageRenderer.tsx
|
|
1762
|
-
import Markdown from "
|
|
1959
|
+
import Markdown from "streamdown";
|
|
1763
1960
|
|
|
1764
1961
|
// src/markdown-extensions/index.ts
|
|
1765
1962
|
import remarkGfm from "remark-gfm";
|
|
@@ -2072,7 +2269,8 @@ function useAgentChat(config) {
|
|
|
2072
2269
|
sessionId: agentConfig.sessionId,
|
|
2073
2270
|
contextProvider: config.contextProvider || createNoOpContextProvider(),
|
|
2074
2271
|
toolProvider: config.toolProvider || createNoOpToolProvider(),
|
|
2075
|
-
authProvider: config.authProvider
|
|
2272
|
+
authProvider: config.authProvider,
|
|
2273
|
+
enableStreaming: config.enableStreaming
|
|
2076
2274
|
});
|
|
2077
2275
|
const clientHistory = agentManager.getConversationHistory(agentKey);
|
|
2078
2276
|
setState((prev) => {
|
|
@@ -2101,6 +2299,7 @@ function useAgentChat(config) {
|
|
|
2101
2299
|
config.contextProvider,
|
|
2102
2300
|
config.toolProvider,
|
|
2103
2301
|
config.authProvider,
|
|
2302
|
+
config.enableStreaming,
|
|
2104
2303
|
isValidConfig
|
|
2105
2304
|
]);
|
|
2106
2305
|
const onSubmit = useCallback3(
|
|
@@ -2128,7 +2327,8 @@ function useAgentChat(config) {
|
|
|
2128
2327
|
currentAbortController: abortController
|
|
2129
2328
|
}));
|
|
2130
2329
|
try {
|
|
2131
|
-
let
|
|
2330
|
+
let streamingMessageId = null;
|
|
2331
|
+
let finalMessageAdded = false;
|
|
2132
2332
|
for await (const update of agentManager.sendMessageStream(
|
|
2133
2333
|
agentKey,
|
|
2134
2334
|
message,
|
|
@@ -2136,34 +2336,107 @@ function useAgentChat(config) {
|
|
|
2136
2336
|
abortSignal: abortController.signal
|
|
2137
2337
|
}
|
|
2138
2338
|
)) {
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2339
|
+
if (!update.final && update.text) {
|
|
2340
|
+
if (!streamingMessageId) {
|
|
2341
|
+
streamingMessageId = `agent-streaming-${Date.now()}`;
|
|
2342
|
+
const streamingMessage = {
|
|
2343
|
+
id: streamingMessageId,
|
|
2344
|
+
role: "agent",
|
|
2345
|
+
content: [
|
|
2346
|
+
{ type: "text", text: update.text }
|
|
2347
|
+
],
|
|
2348
|
+
timestamp: Date.now(),
|
|
2349
|
+
archived: false,
|
|
2350
|
+
showIcon: true,
|
|
2351
|
+
icon: "assistant"
|
|
2352
|
+
};
|
|
2353
|
+
setState((prev) => ({
|
|
2354
|
+
...prev,
|
|
2355
|
+
uiMessages: [
|
|
2356
|
+
...prev.uiMessages,
|
|
2357
|
+
streamingMessage
|
|
2358
|
+
]
|
|
2359
|
+
}));
|
|
2360
|
+
} else {
|
|
2361
|
+
setState((prev) => ({
|
|
2362
|
+
...prev,
|
|
2363
|
+
uiMessages: prev.uiMessages.map(
|
|
2364
|
+
(msg) => msg.id === streamingMessageId ? {
|
|
2365
|
+
...msg,
|
|
2366
|
+
content: [
|
|
2367
|
+
{
|
|
2368
|
+
type: "text",
|
|
2369
|
+
text: update.text
|
|
2370
|
+
}
|
|
2371
|
+
]
|
|
2372
|
+
} : msg
|
|
2373
|
+
)
|
|
2374
|
+
}));
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
if (update.final && update.status?.message && streamingMessageId) {
|
|
2378
|
+
finalMessageAdded = true;
|
|
2379
|
+
const currentStreamingId = streamingMessageId;
|
|
2380
|
+
const finalMessage = transformClientMessageToUI(
|
|
2381
|
+
update.status.message,
|
|
2146
2382
|
registrationsRef.current
|
|
2147
|
-
)
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2383
|
+
);
|
|
2384
|
+
if (finalMessage) {
|
|
2385
|
+
setState((prev) => {
|
|
2386
|
+
const updatedMessages = prev.uiMessages.map(
|
|
2387
|
+
(msg) => msg.id === currentStreamingId ? finalMessage : msg
|
|
2388
|
+
);
|
|
2389
|
+
const updatedClientHistory = agentManager.getConversationHistory(
|
|
2390
|
+
agentKey
|
|
2391
|
+
);
|
|
2392
|
+
return {
|
|
2393
|
+
...prev,
|
|
2394
|
+
clientMessages: updatedClientHistory,
|
|
2395
|
+
uiMessages: updatedMessages,
|
|
2396
|
+
isProcessing: false,
|
|
2397
|
+
currentAbortController: null
|
|
2398
|
+
};
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2401
|
+
streamingMessageId = null;
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
if (!finalMessageAdded) {
|
|
2405
|
+
const updatedClientHistory = agentManager.getConversationHistory(agentKey);
|
|
2406
|
+
setState((prev) => {
|
|
2407
|
+
let filteredMessages = prev.uiMessages;
|
|
2408
|
+
if (streamingMessageId) {
|
|
2409
|
+
filteredMessages = prev.uiMessages.filter(
|
|
2410
|
+
(msg) => msg.id !== streamingMessageId
|
|
2411
|
+
);
|
|
2412
|
+
}
|
|
2413
|
+
const transformedClientMessages = updatedClientHistory.map(
|
|
2414
|
+
(msg) => transformClientMessageToUI(
|
|
2415
|
+
msg,
|
|
2416
|
+
registrationsRef.current
|
|
2417
|
+
)
|
|
2418
|
+
).filter(
|
|
2419
|
+
(msg) => msg !== null
|
|
2420
|
+
);
|
|
2421
|
+
const clientMessageIds = new Set(
|
|
2422
|
+
updatedClientHistory.map((msg) => msg.messageId)
|
|
2423
|
+
);
|
|
2424
|
+
const uiOnlyMessages = filteredMessages.filter(
|
|
2425
|
+
(msg) => !clientMessageIds.has(msg.id) && msg.content[0]?.type === "component"
|
|
2426
|
+
);
|
|
2427
|
+
const mergedUIMessages = sortUIMessagesByTime([
|
|
2428
|
+
...transformedClientMessages,
|
|
2429
|
+
...uiOnlyMessages
|
|
2430
|
+
]);
|
|
2431
|
+
return {
|
|
2432
|
+
...prev,
|
|
2433
|
+
clientMessages: updatedClientHistory,
|
|
2434
|
+
uiMessages: mergedUIMessages,
|
|
2435
|
+
isProcessing: false,
|
|
2436
|
+
currentAbortController: null
|
|
2437
|
+
};
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2167
2440
|
} catch (error) {
|
|
2168
2441
|
if (error instanceof Error && error.name === "AbortError") {
|
|
2169
2442
|
console.log("Request was aborted by user");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{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,UAAU,EAAE,KAAM,IAAI,CAAC;IAC3D,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,0BAA0B,EAAE,CAAE,UAAU,EAAE,kBAAkB,KAAM,IAAI,CAAC;IACvE,0BAA0B,EAAE,CAAE,UAAU,EAAE,kBAAkB,KAAM,IAAI,CAAC;IAGvE,sBAAsB,EAAE,CACvB,YAAY,EAAE,0BAA0B,KACpC,IAAI,CAAC;IACV,wBAAwB,EAAE,CAAE,EAAE,EAAE,MAAM,KAAM,IAAI,CAAC;IACjD,sBAAsB,EAAE,MAAM,IAAI,CAAC;IACnC,qBAAqB,EAAE,OAAO,qBAAqB,CAAC;IAGpD,UAAU,EAAE,CAAE,OAAO,EAAE,SAAS,KAAM,IAAI,CAAC;IAG3C,mBAAmB,EAAE,MAAM,IAAI,CAAC;CAChC;AAcD;;;;GAIG;AACH,wBAAgB,YAAY,CAAE,MAAM,EAAE,kBAAkB,GAAI,kBAAkB,CAggB7E;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Markdown Parser Utility
|
|
3
3
|
*
|
|
4
|
-
* Converts markdown text to React components using
|
|
4
|
+
* Converts markdown text to React components using streamdown
|
|
5
5
|
* with custom components and extensions support.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
@@ -16,7 +16,7 @@ interface ParseMarkdownOptions {
|
|
|
16
16
|
remarkPlugins?: PluggableList;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Parses markdown text into a React component using
|
|
19
|
+
* Parses markdown text into a React component using streamdown
|
|
20
20
|
* @param text - The markdown text to parse
|
|
21
21
|
* @param options - Custom components and extensions to use
|
|
22
22
|
* @return React element containing the parsed markdown
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/agenttic-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A TypeScript client library for A2A (Agent2Agent) protocol communication",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"@wordpress/i18n": "^6.1.0",
|
|
51
51
|
"react": "^18.0.0",
|
|
52
52
|
"react-markdown": "^10.1.0",
|
|
53
|
-
"remark-gfm": "^4.0.1"
|
|
53
|
+
"remark-gfm": "^4.0.1",
|
|
54
|
+
"streamdown": "1.1.1"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
57
|
"@wordpress/api-fetch": "^6.0.0 || ^7.0.0",
|