@convex-dev/agent 0.2.6 → 0.2.8-alpha.0
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/UIMessages.d.ts +43 -0
- package/dist/UIMessages.d.ts.map +1 -0
- package/dist/{react/toUIMessages.js → UIMessages.js} +97 -4
- package/dist/UIMessages.js.map +1 -0
- package/dist/client/createTool.js +1 -1
- package/dist/client/createTool.js.map +1 -1
- package/dist/client/index.d.ts +39 -19
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +22 -19
- package/dist/client/index.js.map +1 -1
- package/dist/client/mockModel.d.ts +2 -0
- package/dist/client/mockModel.d.ts.map +1 -1
- package/dist/client/mockModel.js +11 -7
- package/dist/client/mockModel.js.map +1 -1
- package/dist/client/search.d.ts.map +1 -1
- package/dist/client/search.js +2 -0
- package/dist/client/search.js.map +1 -1
- package/dist/client/start.d.ts +1 -0
- package/dist/client/start.d.ts.map +1 -1
- package/dist/client/start.js +0 -1
- package/dist/client/start.js.map +1 -1
- package/dist/client/streaming.d.ts +23 -4
- package/dist/client/streaming.d.ts.map +1 -1
- package/dist/client/streaming.js +32 -6
- package/dist/client/streaming.js.map +1 -1
- package/dist/client/types.d.ts +19 -13
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +2 -0
- package/dist/component/messages.js +1 -1
- package/dist/component/messages.js.map +1 -1
- package/dist/component/schema.d.ts +10 -4
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +4 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/streams.d.ts +2 -4
- package/dist/component/streams.d.ts.map +1 -1
- package/dist/component/streams.js +42 -43
- package/dist/component/streams.js.map +1 -1
- package/dist/deltas.d.ts +48 -0
- package/dist/deltas.d.ts.map +1 -0
- package/dist/deltas.js +468 -0
- package/dist/deltas.js.map +1 -0
- package/dist/react/index.d.ts +4 -77
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +4 -178
- package/dist/react/index.js.map +1 -1
- package/dist/react/optimisticallySendMessage.d.ts +36 -3
- package/dist/react/optimisticallySendMessage.d.ts.map +1 -1
- package/dist/react/optimisticallySendMessage.js +37 -5
- package/dist/react/optimisticallySendMessage.js.map +1 -1
- package/dist/react/types.d.ts +4 -18
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/useStreamingUIMessages.d.ts +22 -0
- package/dist/react/useStreamingUIMessages.d.ts.map +1 -0
- package/dist/react/useStreamingUIMessages.js +204 -0
- package/dist/react/useStreamingUIMessages.js.map +1 -0
- package/dist/react/useThreadMessages.d.ts +103 -0
- package/dist/react/useThreadMessages.d.ts.map +1 -0
- package/dist/react/useThreadMessages.js +139 -0
- package/dist/react/useThreadMessages.js.map +1 -0
- package/dist/react/useUIMessages.d.ts +91 -0
- package/dist/react/useUIMessages.d.ts.map +1 -0
- package/dist/react/useUIMessages.js +115 -0
- package/dist/react/useUIMessages.js.map +1 -0
- package/dist/validators.d.ts +3 -1
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +1 -0
- package/dist/validators.js.map +1 -1
- package/package.json +4 -4
- package/src/{react/toUIMessages.ts → UIMessages.ts} +132 -15
- package/src/client/createTool.ts +1 -1
- package/src/client/index.ts +60 -41
- package/src/client/mockModel.ts +13 -8
- package/src/client/search.ts +2 -0
- package/src/client/start.ts +2 -1
- package/src/client/streaming.test.ts +186 -0
- package/src/client/streaming.ts +50 -9
- package/src/client/types.ts +19 -21
- package/src/component/_generated/api.d.ts +2 -0
- package/src/component/messages.ts +1 -1
- package/src/component/schema.ts +6 -0
- package/src/component/streams.ts +49 -66
- package/src/{react/deltas.test.ts → deltas.test.ts} +57 -46
- package/src/deltas.ts +589 -0
- package/src/{react/fromUIMessages.test.ts → fromUIMessages.test.ts} +108 -43
- package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/src/react/index.ts +8 -250
- package/src/react/optimisticallySendMessage.ts +57 -8
- package/src/react/types.ts +6 -39
- package/src/react/useStreamingUIMessages.ts +294 -0
- package/src/react/useThreadMessages.ts +251 -0
- package/src/react/useUIMessages.ts +206 -0
- package/src/{react/toUIMessages.test.ts → toUIMessages.test.ts} +3 -3
- package/src/validators.ts +3 -0
- package/dist/client/textStreamParts.d.ts +0 -5
- package/dist/client/textStreamParts.d.ts.map +0 -1
- package/dist/client/textStreamParts.js +0 -44
- package/dist/client/textStreamParts.js.map +0 -1
- package/dist/react/deltas.d.ts +0 -27
- package/dist/react/deltas.d.ts.map +0 -1
- package/dist/react/deltas.js +0 -627
- package/dist/react/deltas.js.map +0 -1
- package/dist/react/fromUIMessages.d.ts +0 -13
- package/dist/react/fromUIMessages.d.ts.map +0 -1
- package/dist/react/fromUIMessages.js +0 -70
- package/dist/react/fromUIMessages.js.map +0 -1
- package/dist/react/toUIMessages.d.ts +0 -19
- package/dist/react/toUIMessages.d.ts.map +0 -1
- package/dist/react/toUIMessages.js.map +0 -1
- package/src/client/textStreamParts.ts +0 -62
- package/src/react/deltas.ts +0 -774
- package/src/react/fromUIMessages.ts +0 -85
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
type BetterOmit,
|
|
4
|
+
type ErrorMessage,
|
|
5
|
+
type Expand,
|
|
6
|
+
} from "convex-helpers";
|
|
7
|
+
import {
|
|
8
|
+
usePaginatedQuery,
|
|
9
|
+
type PaginatedQueryArgs,
|
|
10
|
+
type UsePaginatedQueryResult,
|
|
11
|
+
} from "convex/react";
|
|
12
|
+
import type {
|
|
13
|
+
FunctionArgs,
|
|
14
|
+
FunctionReference,
|
|
15
|
+
PaginationOptions,
|
|
16
|
+
PaginationResult,
|
|
17
|
+
} from "convex/server";
|
|
18
|
+
import { useMemo } from "react";
|
|
19
|
+
import type { SyncStreamsReturnValue } from "../client/types.js";
|
|
20
|
+
import type { MessageStatus, StreamArgs } from "../validators.js";
|
|
21
|
+
import type { StreamQuery } from "./types.js";
|
|
22
|
+
import { type UIMessage } from "../UIMessages.js";
|
|
23
|
+
import { sorted } from "../shared.js";
|
|
24
|
+
import { useStreamingUIMessages } from "./useStreamingUIMessages.js";
|
|
25
|
+
|
|
26
|
+
export type UIMessageLike = {
|
|
27
|
+
order: number;
|
|
28
|
+
stepOrder: number;
|
|
29
|
+
status: MessageStatus | "streaming";
|
|
30
|
+
parts: UIMessage["parts"];
|
|
31
|
+
role: UIMessage["role"];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type UIMessagesQuery<
|
|
35
|
+
Args = unknown,
|
|
36
|
+
M extends UIMessageLike = UIMessageLike,
|
|
37
|
+
> = FunctionReference<
|
|
38
|
+
"query",
|
|
39
|
+
"public",
|
|
40
|
+
{
|
|
41
|
+
threadId: string;
|
|
42
|
+
paginationOpts: PaginationOptions;
|
|
43
|
+
/**
|
|
44
|
+
* If { stream: true } is passed, it will also query for stream deltas.
|
|
45
|
+
* In order for this to work, the query must take as an argument streamArgs.
|
|
46
|
+
*/
|
|
47
|
+
streamArgs?: StreamArgs;
|
|
48
|
+
} & Args,
|
|
49
|
+
PaginationResult<M> & { streams?: SyncStreamsReturnValue }
|
|
50
|
+
>;
|
|
51
|
+
|
|
52
|
+
export type UIMessagesQueryArgs<
|
|
53
|
+
Query extends UIMessagesQuery<unknown, UIMessageLike>,
|
|
54
|
+
> =
|
|
55
|
+
Query extends UIMessagesQuery<unknown, UIMessageLike>
|
|
56
|
+
? Expand<BetterOmit<FunctionArgs<Query>, "paginationOpts" | "streamArgs">>
|
|
57
|
+
: never;
|
|
58
|
+
|
|
59
|
+
export type UIMessagesQueryResult<
|
|
60
|
+
Query extends UIMessagesQuery<unknown, UIMessageLike>,
|
|
61
|
+
> = Query extends UIMessagesQuery<unknown, infer M> ? M : never;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A hook that fetches UIMessages from a thread.
|
|
65
|
+
*
|
|
66
|
+
* It's similar to useThreadMessages, for endpoints that return UIMessages.
|
|
67
|
+
* The streaming messages are materialized as UIMessages. The rest are passed
|
|
68
|
+
* through from the query.
|
|
69
|
+
*
|
|
70
|
+
* This hook is a wrapper around `usePaginatedQuery` and `useStreamingUIMessages`.
|
|
71
|
+
* It will fetch both full messages and streaming messages, and merge them together.
|
|
72
|
+
*
|
|
73
|
+
* The query must take as arguments `{ threadId, paginationOpts }` and return a
|
|
74
|
+
* pagination result of objects similar to UIMessage:
|
|
75
|
+
*
|
|
76
|
+
* For streaming, it should look like this:
|
|
77
|
+
* ```ts
|
|
78
|
+
* export const listThreadMessages = query({
|
|
79
|
+
* args: {
|
|
80
|
+
* threadId: v.string(),
|
|
81
|
+
* paginationOpts: paginationOptsValidator,
|
|
82
|
+
* streamArgs: vStreamArgs,
|
|
83
|
+
* ... other arguments you want
|
|
84
|
+
* },
|
|
85
|
+
* handler: async (ctx, args) => {
|
|
86
|
+
* // await authorizeThreadAccess(ctx, threadId);
|
|
87
|
+
* const paginated = listUIMessages(ctx, components.agent, args);
|
|
88
|
+
* const streams = await syncStreams(ctx, components.agent, args);
|
|
89
|
+
* // Here you could filter out / modify the documents & stream deltas.
|
|
90
|
+
* return { ...paginated, streams };
|
|
91
|
+
* },
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* Then the hook can be used like this:
|
|
96
|
+
* ```ts
|
|
97
|
+
* const { results, status, loadMore } = useUIMessages(
|
|
98
|
+
* api.myModule.listThreadMessages,
|
|
99
|
+
* { threadId },
|
|
100
|
+
* { initialNumItems: 10, stream: true }
|
|
101
|
+
* );
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @param query The query to use to fetch messages.
|
|
105
|
+
* It must take as arguments `{ threadId, paginationOpts }` and return a
|
|
106
|
+
* pagination result of objects similar to UIMessage:
|
|
107
|
+
* Required fields: (role, parts, status, order, stepOrder).
|
|
108
|
+
* To support streaming, it must also take in `streamArgs: vStreamArgs` and
|
|
109
|
+
* return a `streams` object returned from `syncStreams`.
|
|
110
|
+
* @param args The arguments to pass to the query other than `paginationOpts`
|
|
111
|
+
* and `streamArgs`. So `{ threadId }` at minimum, plus any other arguments that
|
|
112
|
+
* you want to pass to the query.
|
|
113
|
+
* @param options The options for the query. Similar to usePaginatedQuery.
|
|
114
|
+
* To enable streaming, pass `stream: true`.
|
|
115
|
+
* @returns The messages. If stream is true, it will return a list of messages
|
|
116
|
+
* that includes both full messages and streaming messages.
|
|
117
|
+
* The streaming messages are materialized as UIMessages. The rest are passed
|
|
118
|
+
* through from the query.
|
|
119
|
+
*/
|
|
120
|
+
export function useUIMessages<
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
|
+
Query extends UIMessagesQuery<any, any>,
|
|
123
|
+
>(
|
|
124
|
+
query: Query,
|
|
125
|
+
args: UIMessagesQueryArgs<Query> | "skip",
|
|
126
|
+
options: {
|
|
127
|
+
initialNumItems: number;
|
|
128
|
+
stream?: Query extends StreamQuery
|
|
129
|
+
? boolean
|
|
130
|
+
: ErrorMessage<"To enable streaming, your query must take in streamArgs: vStreamArgs and return a streams object returned from syncStreams. See docs.">;
|
|
131
|
+
},
|
|
132
|
+
): UsePaginatedQueryResult<
|
|
133
|
+
UIMessagesQueryResult<Query> & { streaming: boolean }
|
|
134
|
+
> {
|
|
135
|
+
// These are full messages
|
|
136
|
+
const paginated = usePaginatedQuery(
|
|
137
|
+
query,
|
|
138
|
+
args as PaginatedQueryArgs<Query> | "skip",
|
|
139
|
+
{ initialNumItems: options.initialNumItems },
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
let startOrder = paginated.results.at(-1)?.order ?? 0;
|
|
143
|
+
for (let i = paginated.results.length - 1; i >= 0; i--) {
|
|
144
|
+
const m = paginated.results[i];
|
|
145
|
+
if (!m.streaming && m.status === "pending") {
|
|
146
|
+
// round down to the nearest 10 for some cache benefits
|
|
147
|
+
startOrder = m.order - (m.order % 10);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// These are streaming messages that will not include full messages.
|
|
152
|
+
const streamMessages = useStreamingUIMessages(
|
|
153
|
+
query as StreamQuery<UIMessagesQueryArgs<Query>>,
|
|
154
|
+
!options.stream ||
|
|
155
|
+
args === "skip" ||
|
|
156
|
+
paginated.status === "LoadingFirstPage"
|
|
157
|
+
? "skip"
|
|
158
|
+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
|
+
({ ...args, paginationOpts: { cursor: null, numItems: 0 } } as any),
|
|
160
|
+
{ startOrder },
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const merged = useMemo(() => {
|
|
164
|
+
const streamListMessages =
|
|
165
|
+
streamMessages?.map((m) => ({
|
|
166
|
+
...m,
|
|
167
|
+
streaming: m.status === "streaming",
|
|
168
|
+
})) ?? [];
|
|
169
|
+
return {
|
|
170
|
+
...paginated,
|
|
171
|
+
results: sorted(
|
|
172
|
+
paginated.results
|
|
173
|
+
.map((m) => ({ ...m, streaming: false }))
|
|
174
|
+
// Note: this is intentionally after paginated results.
|
|
175
|
+
.concat(streamListMessages),
|
|
176
|
+
).reduce(
|
|
177
|
+
(msgs, msg) => {
|
|
178
|
+
const last = msgs.at(-1);
|
|
179
|
+
if (!last) {
|
|
180
|
+
return [msg];
|
|
181
|
+
}
|
|
182
|
+
if (last.order !== msg.order || last.stepOrder !== msg.stepOrder) {
|
|
183
|
+
return [...msgs, msg];
|
|
184
|
+
}
|
|
185
|
+
if (
|
|
186
|
+
last.status === "pending" &&
|
|
187
|
+
(msg.streaming || msg.status !== "pending")
|
|
188
|
+
) {
|
|
189
|
+
// Let's prefer a streaming or finalized message over a pending
|
|
190
|
+
// one.
|
|
191
|
+
return [...msgs.slice(0, -1), msg];
|
|
192
|
+
}
|
|
193
|
+
// skip the new one if the previous one (listed) was finalized
|
|
194
|
+
return msgs;
|
|
195
|
+
},
|
|
196
|
+
[] as (UIMessagesQueryResult<Query> & {
|
|
197
|
+
streaming: boolean;
|
|
198
|
+
})[],
|
|
199
|
+
),
|
|
200
|
+
};
|
|
201
|
+
}, [paginated, streamMessages]);
|
|
202
|
+
|
|
203
|
+
return merged as UIMessagesQueryResult<Query> & {
|
|
204
|
+
streaming: boolean;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { toUIMessages } from "./toUIMessages.js";
|
|
3
|
-
import type { MessageDoc } from "../client/index.js";
|
|
4
1
|
import { assert } from "convex-helpers";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { toUIMessages } from "./UIMessages.js";
|
|
4
|
+
import type { MessageDoc } from "./validators.js";
|
|
5
5
|
|
|
6
6
|
// Helper to create a base message doc
|
|
7
7
|
function baseMessageDoc(overrides: Partial<MessageDoc> = {}): MessageDoc {
|
package/src/validators.ts
CHANGED
|
@@ -442,6 +442,9 @@ export const vStreamMessage = v.object({
|
|
|
442
442
|
v.literal("finished"),
|
|
443
443
|
v.literal("aborted"),
|
|
444
444
|
),
|
|
445
|
+
format: v.optional(
|
|
446
|
+
v.union(v.literal("UIMessageChunk"), v.literal("TextStreamPart")),
|
|
447
|
+
),
|
|
445
448
|
order: v.number(),
|
|
446
449
|
stepOrder: v.number(),
|
|
447
450
|
// metadata
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type StreamTextTransform, type ToolSet, type TextStreamPart } from "ai";
|
|
2
|
-
import { type StreamingOptions } from "./streaming.js";
|
|
3
|
-
export declare function serializeTextStreamingPartsV5(parts: TextStreamPart<ToolSet>[]): TextStreamPart<ToolSet>[];
|
|
4
|
-
export declare function mergeTransforms<TOOLS extends ToolSet>(options: StreamingOptions | boolean | undefined, existing: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>> | undefined): StreamTextTransform<TOOLS> | StreamTextTransform<TOOLS>[] | undefined;
|
|
5
|
-
//# sourceMappingURL=textStreamParts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"textStreamParts.d.ts","sourceRoot":"","sources":["../../src/client/textStreamParts.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,OAAO,EACZ,KAAK,cAAc,EACpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE,GAC/B,cAAc,CAAC,OAAO,CAAC,EAAE,CAyB3B;AAED,wBAAgB,eAAe,CAAC,KAAK,SAAS,OAAO,EACnD,OAAO,EAAE,gBAAgB,GAAG,OAAO,GAAG,SAAS,EAC/C,QAAQ,EACJ,mBAAmB,CAAC,KAAK,CAAC,GAC1B,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,GACjC,SAAS,yEAgBd"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { smoothStream, } from "ai";
|
|
2
|
-
import { DEFAULT_STREAMING_OPTIONS, } from "./streaming.js";
|
|
3
|
-
export function serializeTextStreamingPartsV5(parts) {
|
|
4
|
-
const compressed = [];
|
|
5
|
-
for (const part of parts) {
|
|
6
|
-
const last = compressed.at(-1);
|
|
7
|
-
if (part.type === "text-delta" && last?.type === "text-delta") {
|
|
8
|
-
last.text += part.text;
|
|
9
|
-
}
|
|
10
|
-
else if (part.type === "reasoning-delta" &&
|
|
11
|
-
last?.type === "reasoning-delta") {
|
|
12
|
-
last.text += part.text;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
if (part.type === "file") {
|
|
16
|
-
compressed.push({
|
|
17
|
-
type: "file",
|
|
18
|
-
file: {
|
|
19
|
-
...part.file,
|
|
20
|
-
uint8Array: undefined,
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
compressed.push(part);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return compressed;
|
|
28
|
-
}
|
|
29
|
-
export function mergeTransforms(options, existing) {
|
|
30
|
-
if (!options) {
|
|
31
|
-
return existing;
|
|
32
|
-
}
|
|
33
|
-
const chunking = typeof options === "boolean"
|
|
34
|
-
? DEFAULT_STREAMING_OPTIONS.chunking
|
|
35
|
-
: options.chunking;
|
|
36
|
-
const transforms = Array.isArray(existing)
|
|
37
|
-
? existing
|
|
38
|
-
: existing
|
|
39
|
-
? [existing]
|
|
40
|
-
: [];
|
|
41
|
-
transforms.push(smoothStream({ delayInMs: null, chunking }));
|
|
42
|
-
return transforms;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=textStreamParts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"textStreamParts.js","sourceRoot":"","sources":["../../src/client/textStreamParts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAIb,MAAM,IAAI,CAAC;AACZ,OAAO,EACL,yBAAyB,GAE1B,MAAM,gBAAgB,CAAC;AAExB,MAAM,UAAU,6BAA6B,CAC3C,KAAgC;IAEhC,MAAM,UAAU,GAA8B,EAAE,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;YAC9D,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;QACzB,CAAC;aAAM,IACL,IAAI,CAAC,IAAI,KAAK,iBAAiB;YAC/B,IAAI,EAAE,IAAI,KAAK,iBAAiB,EAChC,CAAC;YACD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACzB,UAAU,CAAC,IAAI,CAAC;oBACd,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;wBACJ,GAAG,IAAI,CAAC,IAAI;wBACZ,UAAU,EAAE,SAAkC;qBAC/C;iBACF,CAAC,CAAC;YACL,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,OAA+C,EAC/C,QAGa;IAEb,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,QAAQ,GACZ,OAAO,OAAO,KAAK,SAAS;QAC1B,CAAC,CAAC,yBAAyB,CAAC,QAAQ;QACpC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACvB,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QACxC,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,QAAQ;YACR,CAAC,CAAC,CAAC,QAAQ,CAAC;YACZ,CAAC,CAAC,EAAE,CAAC;IACT,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC7D,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/react/deltas.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { TextStreamPart, ToolSet, UIMessageChunk } from "ai";
|
|
2
|
-
import type { MessageDoc } from "../client/index.js";
|
|
3
|
-
import { type StreamDelta, type StreamMessage } from "../validators.js";
|
|
4
|
-
export declare function mergeDeltas(threadId: string, streamMessages: StreamMessage[], existingStreams: Array<{
|
|
5
|
-
streamId: string;
|
|
6
|
-
cursor: number;
|
|
7
|
-
messages: MessageDoc[];
|
|
8
|
-
}>, allDeltas: StreamDelta[]): [
|
|
9
|
-
MessageDoc[],
|
|
10
|
-
Array<{
|
|
11
|
-
streamId: string;
|
|
12
|
-
cursor: number;
|
|
13
|
-
messages: MessageDoc[];
|
|
14
|
-
}>,
|
|
15
|
-
boolean
|
|
16
|
-
];
|
|
17
|
-
export declare function applyDeltasToStreamMessage(threadId: string, streamMessage: StreamMessage, existing: {
|
|
18
|
-
streamId: string;
|
|
19
|
-
cursor: number;
|
|
20
|
-
messages: MessageDoc[];
|
|
21
|
-
} | undefined, deltas: StreamDelta[]): [{
|
|
22
|
-
streamId: string;
|
|
23
|
-
cursor: number;
|
|
24
|
-
messages: MessageDoc[];
|
|
25
|
-
}, boolean];
|
|
26
|
-
export declare function createStreamingMessage(threadId: string, message: StreamMessage, part: UIMessageChunk<ToolSet> | TextStreamPart<ToolSet>, index: number): MessageDoc;
|
|
27
|
-
//# sourceMappingURL=deltas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deltas.d.ts","sourceRoot":"","sources":["../../src/react/deltas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,cAAc,EACd,OAAO,EACP,cAAc,EACf,MAAM,IAAI,CAAC;AACZ,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,aAAa,EAMnB,MAAM,kBAAkB,CAAC;AAM1B,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,aAAa,EAAE,EAC/B,eAAe,EAAE,KAAK,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB,CAAC,EACF,SAAS,EAAE,WAAW,EAAE,GACvB;IACD,UAAU,EAAE;IACZ,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;IACnE,OAAO;CACR,CAgCA;AAGD,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,aAAa,EAC5B,QAAQ,EACJ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAE,GAC5D,SAAS,EACb,MAAM,EAAE,WAAW,EAAE,GACpB,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAE,EAAE,OAAO,CAAC,CAkZzE;AA2FD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,EACvD,KAAK,EAAE,MAAM,GACZ,UAAU,CAmMZ"}
|