@convex-dev/agent 0.1.18 → 0.2.0-alpha.2
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/createTool.d.ts +31 -10
- package/dist/client/createTool.d.ts.map +1 -1
- package/dist/client/createTool.js +25 -10
- package/dist/client/createTool.js.map +1 -1
- package/dist/client/defaultComponent.d.ts +11 -0
- package/dist/client/defaultComponent.d.ts.map +1 -0
- package/dist/client/defaultComponent.js +7 -0
- package/dist/client/defaultComponent.js.map +1 -0
- package/dist/client/definePlaygroundAPI.d.ts +58 -13
- package/dist/client/definePlaygroundAPI.d.ts.map +1 -1
- package/dist/client/definePlaygroundAPI.js +7 -20
- package/dist/client/definePlaygroundAPI.js.map +1 -1
- package/dist/client/files.d.ts +6 -3
- package/dist/client/files.d.ts.map +1 -1
- package/dist/client/files.js +7 -7
- package/dist/client/files.js.map +1 -1
- package/dist/client/index.d.ts +143 -584
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +128 -212
- package/dist/client/index.js.map +1 -1
- package/dist/client/messages.d.ts +538 -0
- package/dist/client/messages.d.ts.map +1 -0
- package/dist/client/messages.js +91 -0
- package/dist/client/messages.js.map +1 -0
- package/dist/client/search.d.ts +30 -7
- package/dist/client/search.d.ts.map +1 -1
- package/dist/client/search.js +20 -3
- package/dist/client/search.js.map +1 -1
- package/dist/client/streaming.d.ts +3 -2
- package/dist/client/streaming.d.ts.map +1 -1
- package/dist/client/streaming.js.map +1 -1
- package/dist/client/threads.d.ts +46 -0
- package/dist/client/threads.d.ts.map +1 -0
- package/dist/client/threads.js +49 -0
- package/dist/client/threads.js.map +1 -0
- package/dist/client/types.d.ts +39 -42
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +437 -75
- package/dist/component/messages.d.ts +249 -47
- package/dist/component/messages.d.ts.map +1 -1
- package/dist/component/messages.js +28 -24
- package/dist/component/messages.js.map +1 -1
- package/dist/component/schema.d.ts +1459 -158
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +8 -14
- package/dist/component/schema.js.map +1 -1
- package/dist/component/streams.d.ts +180 -6
- package/dist/component/streams.d.ts.map +1 -1
- package/dist/mapping.d.ts +11 -15
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +191 -61
- package/dist/mapping.js.map +1 -1
- package/dist/react/deltas.d.ts +0 -3
- package/dist/react/deltas.d.ts.map +1 -1
- package/dist/react/deltas.js +140 -44
- package/dist/react/deltas.js.map +1 -1
- package/dist/react/toUIMessages.d.ts +5 -4
- package/dist/react/toUIMessages.d.ts.map +1 -1
- package/dist/react/toUIMessages.js +103 -40
- package/dist/react/toUIMessages.js.map +1 -1
- package/dist/validators.d.ts +1978 -1210
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +90 -54
- package/dist/validators.js.map +1 -1
- package/package.json +32 -28
- package/src/client/createTool.ts +69 -38
- package/src/client/defaultComponent.ts +17 -0
- package/src/client/definePlaygroundAPI.ts +17 -31
- package/src/client/files.ts +7 -8
- package/src/client/index.test.ts +20 -18
- package/src/client/index.ts +218 -424
- package/src/client/messages.ts +191 -0
- package/src/client/search.ts +30 -6
- package/src/client/streaming.ts +4 -3
- package/src/client/threads.ts +78 -0
- package/src/client/types.ts +50 -72
- package/src/component/_generated/api.d.ts +437 -75
- package/src/component/messages.test.ts +182 -40
- package/src/component/messages.ts +27 -31
- package/src/component/schema.ts +8 -14
- package/src/mapping.ts +230 -94
- package/src/react/deltas.ts +165 -52
- package/src/react/toUIMessages.test.ts +154 -36
- package/src/react/toUIMessages.ts +136 -57
- package/src/validators.test.ts +2 -101
- package/src/validators.ts +111 -68
- package/dist/client/listMessages.d.ts +0 -22
- package/dist/client/listMessages.d.ts.map +0 -1
- package/dist/client/listMessages.js +0 -25
- package/dist/client/listMessages.js.map +0 -1
- package/src/client/listMessages.ts +0 -38
package/dist/client/index.d.ts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { LanguageModelV2 } from "@ai-sdk/provider";
|
|
2
|
+
import type { ModelMessage, DeepPartial, GenerateObjectResult, GenerateTextResult, StepResult, StreamObjectResult, StreamTextResult, ToolSet, StopCondition, Schema, LanguageModel, EmbeddingModel, CallSettings } from "ai";
|
|
3
3
|
import { type GenericActionCtx, type GenericDataModel, type PaginationOptions, type PaginationResult } from "convex/server";
|
|
4
4
|
import type { MessageDoc, ThreadDoc } from "../component/schema.js";
|
|
5
5
|
import type { threadFieldsSupportingPatch } from "../component/threads.js";
|
|
6
6
|
import { type VectorDimension } from "../component/vector/tables.js";
|
|
7
|
-
import { type AIMessageWithoutId } from "../mapping.js";
|
|
8
7
|
import { extractText, isTool } from "../shared.js";
|
|
9
|
-
import { type
|
|
8
|
+
import { type Message, type MessageStatus, type MessageWithMetadata, type ProviderMetadata, type StreamArgs, type Usage } from "../validators.js";
|
|
10
9
|
import { createTool } from "./createTool.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { type StreamingOptions, syncStreams } from "./streaming.js";
|
|
10
|
+
import { type SaveMessageArgs, type SaveMessagesArgs } from "./messages.js";
|
|
11
|
+
import { type StreamingOptions } from "./streaming.js";
|
|
14
12
|
import type { ActionCtx, AgentComponent, ContextOptions, GenerationOutputMetadata, Options, OurObjectArgs, OurStreamObjectArgs, RawRequestResponseHandler, RunActionCtx, RunMutationCtx, RunQueryCtx, StorageOptions, StreamingTextArgs, SyncStreamsReturnValue, TextArgs, Thread, UsageHandler } from "./types.js";
|
|
13
|
+
import type z from "zod/v3";
|
|
14
|
+
export { stepCountIs } from "ai";
|
|
15
15
|
export { vMessageDoc, vThreadDoc } from "../component/schema.js";
|
|
16
|
-
export { serializeDataOrUrl } from "../mapping.js";
|
|
16
|
+
export { serializeDataOrUrl, deserializeMessage, serializeMessage, } from "../mapping.js";
|
|
17
17
|
export { vAssistantMessage, vContextOptions, vMessage, vPaginationResult, vProviderMetadata, vStorageOptions, vStreamArgs, vSystemMessage, vToolMessage, vUsage, vUserMessage, } from "../validators.js";
|
|
18
18
|
export type { ToolCtx } from "./createTool.js";
|
|
19
19
|
export { getFile, storeFile } from "./files.js";
|
|
20
|
-
export { filterOutOrphanedToolMessages } from "./search.js";
|
|
21
|
-
export { abortStream, listStreams } from "./streaming.js";
|
|
22
|
-
export {
|
|
20
|
+
export { filterOutOrphanedToolMessages, fetchContextMessages, } from "./search.js";
|
|
21
|
+
export { abortStream, listStreams, syncStreams } from "./streaming.js";
|
|
22
|
+
export { listMessages, saveMessage, saveMessages, type SaveMessageArgs, type SaveMessagesArgs, } from "./messages.js";
|
|
23
|
+
export { createThread, getThreadMetadata } from "./threads.js";
|
|
24
|
+
export { createTool, extractText, isTool };
|
|
23
25
|
export { definePlaygroundAPI, type PlaygroundAPI, type AgentsFn, } from "./definePlaygroundAPI.js";
|
|
24
26
|
export type { AgentComponent, ContextOptions, MessageDoc, ProviderMetadata, RawRequestResponseHandler, StorageOptions, StreamArgs, SyncStreamsReturnValue, Thread, ThreadDoc, Usage, UsageHandler, };
|
|
25
27
|
export declare class Agent<
|
|
@@ -57,7 +59,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
57
59
|
* const myAgent = new Agent(components.agent, {
|
|
58
60
|
* chat: openai.chat("gpt-4o-mini"),
|
|
59
61
|
*/
|
|
60
|
-
chat:
|
|
62
|
+
chat: LanguageModel;
|
|
61
63
|
/**
|
|
62
64
|
* The model to use for text embeddings. Optional.
|
|
63
65
|
* If specified, it will use this for generating vector embeddings
|
|
@@ -68,7 +70,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
68
70
|
* const myAgent = new Agent(components.agent, {
|
|
69
71
|
* textEmbedding: openai.embedding("text-embedding-3-small")
|
|
70
72
|
*/
|
|
71
|
-
textEmbedding?:
|
|
73
|
+
textEmbedding?: EmbeddingModel<string>;
|
|
72
74
|
/**
|
|
73
75
|
* The default system prompt to put in each request.
|
|
74
76
|
* Override per-prompt by passing the "system" parameter.
|
|
@@ -94,14 +96,15 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
94
96
|
storageOptions?: StorageOptions;
|
|
95
97
|
/**
|
|
96
98
|
* When generating or streaming text with tools available, this
|
|
97
|
-
* determines
|
|
99
|
+
* determines when to stop. Defaults to stepCountIs(1).
|
|
98
100
|
*/
|
|
99
|
-
|
|
101
|
+
stopWhen?: StopCondition<AgentTools> | Array<StopCondition<AgentTools>>;
|
|
100
102
|
/**
|
|
101
|
-
* The
|
|
102
|
-
* This can be overridden at each generate/stream callsite
|
|
103
|
+
* The default settings to use for the LLM calls.
|
|
104
|
+
* This can be overridden at each generate/stream callsite on a per-field
|
|
105
|
+
* basis. To clear a default setting, you'll need to pass `undefined`.
|
|
103
106
|
*/
|
|
104
|
-
|
|
107
|
+
callSettings?: CallSettings;
|
|
105
108
|
/**
|
|
106
109
|
* The usage handler to use for this agent.
|
|
107
110
|
*/
|
|
@@ -125,7 +128,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
125
128
|
* const myAgent = new Agent(components.agent, {
|
|
126
129
|
* chat: openai.chat("gpt-4o-mini"),
|
|
127
130
|
*/
|
|
128
|
-
chat:
|
|
131
|
+
chat: LanguageModel;
|
|
129
132
|
/**
|
|
130
133
|
* The model to use for text embeddings. Optional.
|
|
131
134
|
* If specified, it will use this for generating vector embeddings
|
|
@@ -136,7 +139,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
136
139
|
* const myAgent = new Agent(components.agent, {
|
|
137
140
|
* textEmbedding: openai.embedding("text-embedding-3-small")
|
|
138
141
|
*/
|
|
139
|
-
textEmbedding?:
|
|
142
|
+
textEmbedding?: EmbeddingModel<string>;
|
|
140
143
|
/**
|
|
141
144
|
* The default system prompt to put in each request.
|
|
142
145
|
* Override per-prompt by passing the "system" parameter.
|
|
@@ -162,14 +165,15 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
162
165
|
storageOptions?: StorageOptions;
|
|
163
166
|
/**
|
|
164
167
|
* When generating or streaming text with tools available, this
|
|
165
|
-
* determines
|
|
168
|
+
* determines when to stop. Defaults to stepCountIs(1).
|
|
166
169
|
*/
|
|
167
|
-
|
|
170
|
+
stopWhen?: StopCondition<AgentTools> | Array<StopCondition<AgentTools>>;
|
|
168
171
|
/**
|
|
169
|
-
* The
|
|
170
|
-
* This can be overridden at each generate/stream callsite
|
|
172
|
+
* The default settings to use for the LLM calls.
|
|
173
|
+
* This can be overridden at each generate/stream callsite on a per-field
|
|
174
|
+
* basis. To clear a default setting, you'll need to pass `undefined`.
|
|
171
175
|
*/
|
|
172
|
-
|
|
176
|
+
callSettings?: CallSettings;
|
|
173
177
|
/**
|
|
174
178
|
* The usage handler to use for this agent.
|
|
175
179
|
*/
|
|
@@ -285,16 +289,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
285
289
|
}): Promise<{
|
|
286
290
|
thread: Thread<ThreadTools extends undefined ? AgentTools : ThreadTools>;
|
|
287
291
|
}>;
|
|
288
|
-
/**
|
|
289
|
-
* Search for threads by title, paginated.
|
|
290
|
-
* @param ctx The context passed from the query/mutation/action.
|
|
291
|
-
* @returns The threads matching the search, paginated.
|
|
292
|
-
*/
|
|
293
|
-
searchThreadTitles(ctx: RunQueryCtx, { userId, query, limit, }: {
|
|
294
|
-
userId?: string | undefined;
|
|
295
|
-
query: string;
|
|
296
|
-
limit?: number;
|
|
297
|
-
}): Promise<ThreadDoc[]>;
|
|
298
292
|
/**
|
|
299
293
|
* This behaves like {@link generateText} from the "ai" package except that
|
|
300
294
|
* it add context based on the userId and threadId and saves the input and
|
|
@@ -382,7 +376,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
382
376
|
* Use {@link continueThread} to get a version of this function already scoped
|
|
383
377
|
* to a thread (and optionally userId).
|
|
384
378
|
*/
|
|
385
|
-
streamObject<T>(ctx: ActionCtx, { userId: argsUserId, threadId, ...usageHandler }: {
|
|
379
|
+
streamObject<T extends z.Schema | Schema>(ctx: ActionCtx, { userId: argsUserId, threadId, ...usageHandler }: {
|
|
386
380
|
userId?: string | null;
|
|
387
381
|
threadId?: string;
|
|
388
382
|
usageHandler?: UsageHandler;
|
|
@@ -458,6 +452,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
458
452
|
} | {
|
|
459
453
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
460
454
|
signature?: string | undefined;
|
|
455
|
+
state?: "streaming" | "done" | undefined;
|
|
461
456
|
type: "reasoning";
|
|
462
457
|
text: string;
|
|
463
458
|
} | {
|
|
@@ -466,6 +461,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
466
461
|
data: string;
|
|
467
462
|
} | {
|
|
468
463
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
464
|
+
providerExecuted?: boolean | undefined;
|
|
469
465
|
type: "tool-call";
|
|
470
466
|
toolCallId: string;
|
|
471
467
|
toolName: string;
|
|
@@ -477,6 +473,8 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
477
473
|
content: {
|
|
478
474
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
479
475
|
args?: any;
|
|
476
|
+
providerExecuted?: boolean | undefined;
|
|
477
|
+
isError?: boolean | undefined;
|
|
480
478
|
experimental_content?: ({
|
|
481
479
|
type: "text";
|
|
482
480
|
text: string;
|
|
@@ -485,7 +483,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
485
483
|
type: "image";
|
|
486
484
|
data: string;
|
|
487
485
|
})[] | undefined;
|
|
488
|
-
isError?: boolean | undefined;
|
|
489
486
|
type: "tool-result";
|
|
490
487
|
toolCallId: string;
|
|
491
488
|
toolName: string;
|
|
@@ -499,19 +496,36 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
499
496
|
text?: string | undefined;
|
|
500
497
|
reasoning?: string | undefined;
|
|
501
498
|
usage?: {
|
|
499
|
+
reasoningTokens?: number | undefined;
|
|
500
|
+
cachedInputTokens?: number | undefined;
|
|
502
501
|
promptTokens: number;
|
|
503
502
|
completionTokens: number;
|
|
504
503
|
totalTokens: number;
|
|
505
504
|
} | undefined;
|
|
506
505
|
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
507
|
-
sources?: {
|
|
506
|
+
sources?: ({
|
|
508
507
|
title?: string | undefined;
|
|
508
|
+
type?: "source" | undefined;
|
|
509
509
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
510
|
+
url?: string | undefined;
|
|
510
511
|
id: string;
|
|
511
512
|
sourceType: "url";
|
|
512
|
-
|
|
513
|
-
|
|
513
|
+
} | {
|
|
514
|
+
filename?: string | undefined;
|
|
515
|
+
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
516
|
+
id: string;
|
|
517
|
+
title: string;
|
|
518
|
+
type: "source";
|
|
519
|
+
sourceType: "document";
|
|
520
|
+
mediaType: string;
|
|
521
|
+
})[] | undefined;
|
|
514
522
|
reasoningDetails?: ({
|
|
523
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
524
|
+
signature?: string | undefined;
|
|
525
|
+
state?: "streaming" | "done" | undefined;
|
|
526
|
+
type: "reasoning";
|
|
527
|
+
text: string;
|
|
528
|
+
} | {
|
|
515
529
|
signature?: string | undefined;
|
|
516
530
|
type: "text";
|
|
517
531
|
text: string;
|
|
@@ -558,7 +572,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
558
572
|
*/
|
|
559
573
|
skipEmbeddings?: boolean;
|
|
560
574
|
}): Promise<{
|
|
561
|
-
lastMessageId: string;
|
|
562
575
|
messages: MessageDoc[];
|
|
563
576
|
}>;
|
|
564
577
|
/**
|
|
@@ -601,7 +614,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
601
614
|
fetchContextMessages(ctx: RunQueryCtx | RunActionCtx, args: {
|
|
602
615
|
userId: string | undefined;
|
|
603
616
|
threadId: string | undefined;
|
|
604
|
-
messages:
|
|
617
|
+
messages: (ModelMessage | Message)[];
|
|
605
618
|
/**
|
|
606
619
|
* If provided, it will search for messages up to and including this message.
|
|
607
620
|
* Note: if this is far in the past, text and vector search results may be more
|
|
@@ -638,7 +651,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
638
651
|
generateEmbeddings(ctx: RunActionCtx, { userId, threadId, }: {
|
|
639
652
|
userId: string | undefined;
|
|
640
653
|
threadId: string | undefined;
|
|
641
|
-
}, messages:
|
|
654
|
+
}, messages: (ModelMessage | Message)[]): Promise<{
|
|
642
655
|
vectors: (number[] | null)[];
|
|
643
656
|
dimension: VectorDimension;
|
|
644
657
|
model: string;
|
|
@@ -682,7 +695,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
682
695
|
provider?: string;
|
|
683
696
|
}): Promise<{
|
|
684
697
|
messages: MessageDoc[];
|
|
685
|
-
pending?: MessageDoc;
|
|
686
698
|
}>;
|
|
687
699
|
/**
|
|
688
700
|
* Manually save the result of a generateObject call to the thread.
|
|
@@ -699,7 +711,9 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
699
711
|
provider: string | undefined;
|
|
700
712
|
result: GenerateObjectResult<unknown>;
|
|
701
713
|
metadata?: Omit<MessageWithMetadata, "message">;
|
|
702
|
-
}): Promise<
|
|
714
|
+
}): Promise<{
|
|
715
|
+
messages: MessageDoc[];
|
|
716
|
+
}>;
|
|
703
717
|
/**
|
|
704
718
|
* Commit or rollback a message that was pending.
|
|
705
719
|
* This is done automatically when saving messages by default.
|
|
@@ -728,9 +742,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
728
742
|
messageId: string;
|
|
729
743
|
patch: {
|
|
730
744
|
/** The message to replace the existing message. */
|
|
731
|
-
message:
|
|
732
|
-
id?: string;
|
|
733
|
-
};
|
|
745
|
+
message: ModelMessage | Message;
|
|
734
746
|
/** The status to set on the message. */
|
|
735
747
|
status: "success" | "error";
|
|
736
748
|
/** The error message to set on the message. */
|
|
@@ -838,23 +850,23 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
838
850
|
}): Promise<void>;
|
|
839
851
|
_saveMessagesAndFetchContext<T extends {
|
|
840
852
|
id?: string;
|
|
841
|
-
prompt?: string;
|
|
842
|
-
messages?:
|
|
853
|
+
prompt?: string | (ModelMessage | Message)[];
|
|
854
|
+
messages?: (ModelMessage | Message)[];
|
|
843
855
|
system?: string;
|
|
844
856
|
promptMessageId?: string;
|
|
845
|
-
model?:
|
|
846
|
-
maxRetries?: number;
|
|
857
|
+
model?: LanguageModelV2;
|
|
847
858
|
}>(ctx: RunActionCtx, args: T, { userId: argsUserId, threadId, contextOptions, storageOptions, }: {
|
|
848
859
|
userId: string | undefined;
|
|
849
860
|
threadId: string | undefined;
|
|
850
861
|
} & Options): Promise<{
|
|
851
862
|
args: T & {
|
|
852
|
-
model:
|
|
863
|
+
model: LanguageModelV2;
|
|
853
864
|
};
|
|
854
865
|
userId: string | undefined;
|
|
855
866
|
messageId: string | undefined;
|
|
856
867
|
order: number | undefined;
|
|
857
868
|
stepOrder: number | undefined;
|
|
869
|
+
savedMessages: MessageDoc[] | undefined;
|
|
858
870
|
}>;
|
|
859
871
|
doEmbed(ctx: RunActionCtx, options: {
|
|
860
872
|
userId: string | undefined;
|
|
@@ -911,14 +923,14 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
911
923
|
* Create an action out of this agent so you can call it from workflows or other actions
|
|
912
924
|
* without a wrapping function.
|
|
913
925
|
* @param spec Configuration for the agent acting as an action, including
|
|
914
|
-
* {@link ContextOptions}, {@link StorageOptions}, and
|
|
926
|
+
* {@link ContextOptions}, {@link StorageOptions}, and {@link stopWhen}.
|
|
915
927
|
*/
|
|
916
928
|
asTextAction<DataModel extends GenericDataModel>(spec?: {
|
|
917
929
|
/**
|
|
918
|
-
*
|
|
919
|
-
* Defaults to the {@link Agent.
|
|
930
|
+
* When to stop generating text.
|
|
931
|
+
* Defaults to the {@link Agent["options"].stopWhen} option.
|
|
920
932
|
*/
|
|
921
|
-
|
|
933
|
+
stopWhen?: StopCondition<AgentTools> | Array<StopCondition<AgentTools>>;
|
|
922
934
|
/**
|
|
923
935
|
* The {@link ContextOptions} to use for fetching contextual messages and
|
|
924
936
|
* saving input/output messages.
|
|
@@ -1001,6 +1013,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1001
1013
|
} | {
|
|
1002
1014
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1003
1015
|
signature?: string | undefined;
|
|
1016
|
+
state?: "streaming" | "done" | undefined;
|
|
1004
1017
|
type: "reasoning";
|
|
1005
1018
|
text: string;
|
|
1006
1019
|
} | {
|
|
@@ -1009,6 +1022,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1009
1022
|
data: string;
|
|
1010
1023
|
} | {
|
|
1011
1024
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1025
|
+
providerExecuted?: boolean | undefined;
|
|
1012
1026
|
type: "tool-call";
|
|
1013
1027
|
toolCallId: string;
|
|
1014
1028
|
toolName: string;
|
|
@@ -1020,6 +1034,8 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1020
1034
|
content: {
|
|
1021
1035
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1022
1036
|
args?: any;
|
|
1037
|
+
providerExecuted?: boolean | undefined;
|
|
1038
|
+
isError?: boolean | undefined;
|
|
1023
1039
|
experimental_content?: ({
|
|
1024
1040
|
type: "text";
|
|
1025
1041
|
text: string;
|
|
@@ -1028,7 +1044,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1028
1044
|
type: "image";
|
|
1029
1045
|
data: string;
|
|
1030
1046
|
})[] | undefined;
|
|
1031
|
-
isError?: boolean | undefined;
|
|
1032
1047
|
type: "tool-result";
|
|
1033
1048
|
toolCallId: string;
|
|
1034
1049
|
toolName: string;
|
|
@@ -1039,15 +1054,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1039
1054
|
role: "system";
|
|
1040
1055
|
content: string;
|
|
1041
1056
|
})[] | undefined;
|
|
1042
|
-
headers?: Record<string, string> | undefined;
|
|
1043
|
-
maxTokens?: number | undefined;
|
|
1044
|
-
temperature?: number | undefined;
|
|
1045
|
-
topP?: number | undefined;
|
|
1046
|
-
topK?: number | undefined;
|
|
1047
|
-
presencePenalty?: number | undefined;
|
|
1048
|
-
frequencyPenalty?: number | undefined;
|
|
1049
|
-
seed?: number | undefined;
|
|
1050
|
-
maxRetries?: number | undefined;
|
|
1051
1057
|
stream?: boolean | undefined;
|
|
1052
1058
|
toolChoice?: "required" | "none" | "auto" | {
|
|
1053
1059
|
type: "tool";
|
|
@@ -1075,29 +1081,39 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1075
1081
|
storageOptions?: {
|
|
1076
1082
|
saveMessages?: "all" | "none" | "promptAndOutput" | undefined;
|
|
1077
1083
|
} | undefined;
|
|
1084
|
+
callSettings?: {
|
|
1085
|
+
headers?: Record<string, string> | undefined;
|
|
1086
|
+
maxOutputTokens?: number | undefined;
|
|
1087
|
+
temperature?: number | undefined;
|
|
1088
|
+
topP?: number | undefined;
|
|
1089
|
+
topK?: number | undefined;
|
|
1090
|
+
presencePenalty?: number | undefined;
|
|
1091
|
+
frequencyPenalty?: number | undefined;
|
|
1092
|
+
stopSequences?: string[] | undefined;
|
|
1093
|
+
seed?: number | undefined;
|
|
1094
|
+
maxRetries?: number | undefined;
|
|
1095
|
+
} | undefined;
|
|
1078
1096
|
}, Promise<{
|
|
1079
1097
|
text: string;
|
|
1080
1098
|
messageId: string | undefined;
|
|
1081
1099
|
order: number | undefined;
|
|
1082
|
-
finishReason: import("@ai-sdk/provider").
|
|
1083
|
-
warnings: Promise<import("@ai-sdk/provider").
|
|
1100
|
+
finishReason: import("@ai-sdk/provider").LanguageModelV2FinishReason;
|
|
1101
|
+
warnings: Promise<import("@ai-sdk/provider").LanguageModelV2CallWarning[] | undefined>;
|
|
1084
1102
|
} | {
|
|
1085
1103
|
text: string;
|
|
1086
1104
|
messageId: string | undefined;
|
|
1087
1105
|
order: number | undefined;
|
|
1088
|
-
finishReason: import("@ai-sdk/provider").
|
|
1089
|
-
warnings: import("@ai-sdk/provider").
|
|
1106
|
+
finishReason: import("@ai-sdk/provider").LanguageModelV2FinishReason;
|
|
1107
|
+
warnings: import("@ai-sdk/provider").LanguageModelV2CallWarning[] | undefined;
|
|
1090
1108
|
}>>;
|
|
1091
1109
|
/**
|
|
1092
1110
|
* Create an action that generates an object out of this agent so you can call
|
|
1093
1111
|
* it from workflows or other actions without a wrapping function.
|
|
1094
1112
|
* @param spec Configuration for the agent acting as an action, including
|
|
1095
1113
|
* the normal parameters to {@link generateObject}, plus {@link ContextOptions}
|
|
1096
|
-
* and
|
|
1114
|
+
* and stopWhen.
|
|
1097
1115
|
*/
|
|
1098
|
-
asObjectAction<T>(spec: OurObjectArgs<T
|
|
1099
|
-
maxSteps?: number;
|
|
1100
|
-
}, options?: {
|
|
1116
|
+
asObjectAction<T>(spec: OurObjectArgs<T>, options?: {
|
|
1101
1117
|
contextOptions?: ContextOptions;
|
|
1102
1118
|
storageOptions?: StorageOptions;
|
|
1103
1119
|
}): import("convex/server").RegisteredAction<"internal", {
|
|
@@ -1140,6 +1156,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1140
1156
|
} | {
|
|
1141
1157
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1142
1158
|
signature?: string | undefined;
|
|
1159
|
+
state?: "streaming" | "done" | undefined;
|
|
1143
1160
|
type: "reasoning";
|
|
1144
1161
|
text: string;
|
|
1145
1162
|
} | {
|
|
@@ -1148,6 +1165,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1148
1165
|
data: string;
|
|
1149
1166
|
} | {
|
|
1150
1167
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1168
|
+
providerExecuted?: boolean | undefined;
|
|
1151
1169
|
type: "tool-call";
|
|
1152
1170
|
toolCallId: string;
|
|
1153
1171
|
toolName: string;
|
|
@@ -1159,6 +1177,8 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1159
1177
|
content: {
|
|
1160
1178
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1161
1179
|
args?: any;
|
|
1180
|
+
providerExecuted?: boolean | undefined;
|
|
1181
|
+
isError?: boolean | undefined;
|
|
1162
1182
|
experimental_content?: ({
|
|
1163
1183
|
type: "text";
|
|
1164
1184
|
text: string;
|
|
@@ -1167,7 +1187,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1167
1187
|
type: "image";
|
|
1168
1188
|
data: string;
|
|
1169
1189
|
})[] | undefined;
|
|
1170
|
-
isError?: boolean | undefined;
|
|
1171
1190
|
type: "tool-result";
|
|
1172
1191
|
toolCallId: string;
|
|
1173
1192
|
toolName: string;
|
|
@@ -1178,15 +1197,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1178
1197
|
role: "system";
|
|
1179
1198
|
content: string;
|
|
1180
1199
|
})[] | undefined;
|
|
1181
|
-
headers?: Record<string, string> | undefined;
|
|
1182
|
-
maxTokens?: number | undefined;
|
|
1183
|
-
temperature?: number | undefined;
|
|
1184
|
-
topP?: number | undefined;
|
|
1185
|
-
topK?: number | undefined;
|
|
1186
|
-
presencePenalty?: number | undefined;
|
|
1187
|
-
frequencyPenalty?: number | undefined;
|
|
1188
|
-
seed?: number | undefined;
|
|
1189
|
-
maxRetries?: number | undefined;
|
|
1190
1200
|
prompt?: string | undefined;
|
|
1191
1201
|
promptMessageId?: string | undefined;
|
|
1192
1202
|
contextOptions?: {
|
|
@@ -1207,12 +1217,24 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1207
1217
|
storageOptions?: {
|
|
1208
1218
|
saveMessages?: "all" | "none" | "promptAndOutput" | undefined;
|
|
1209
1219
|
} | undefined;
|
|
1220
|
+
callSettings?: {
|
|
1221
|
+
headers?: Record<string, string> | undefined;
|
|
1222
|
+
maxOutputTokens?: number | undefined;
|
|
1223
|
+
temperature?: number | undefined;
|
|
1224
|
+
topP?: number | undefined;
|
|
1225
|
+
topK?: number | undefined;
|
|
1226
|
+
presencePenalty?: number | undefined;
|
|
1227
|
+
frequencyPenalty?: number | undefined;
|
|
1228
|
+
stopSequences?: string[] | undefined;
|
|
1229
|
+
seed?: number | undefined;
|
|
1230
|
+
maxRetries?: number | undefined;
|
|
1231
|
+
} | undefined;
|
|
1210
1232
|
}, Promise<{
|
|
1211
1233
|
object: T;
|
|
1212
1234
|
messageId: string | undefined;
|
|
1213
1235
|
order: number | undefined;
|
|
1214
|
-
finishReason: import("@ai-sdk/provider").
|
|
1215
|
-
warnings: import("@ai-sdk/provider").
|
|
1236
|
+
finishReason: import("@ai-sdk/provider").LanguageModelV2FinishReason;
|
|
1237
|
+
warnings: import("@ai-sdk/provider").LanguageModelV2CallWarning[] | undefined;
|
|
1216
1238
|
}>>;
|
|
1217
1239
|
/**
|
|
1218
1240
|
* Save messages to the thread.
|
|
@@ -1236,12 +1258,15 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1236
1258
|
*/
|
|
1237
1259
|
asSaveMessagesMutation(): import("convex/server").RegisteredMutation<"internal", {
|
|
1238
1260
|
userId?: string | undefined;
|
|
1239
|
-
pending?: boolean | undefined;
|
|
1240
1261
|
promptMessageId?: string | undefined;
|
|
1262
|
+
embeddings?: {
|
|
1263
|
+
model: string;
|
|
1264
|
+
vectors: (number[] | null)[];
|
|
1265
|
+
} | undefined;
|
|
1241
1266
|
failPendingSteps?: boolean | undefined;
|
|
1242
1267
|
threadId: string;
|
|
1243
1268
|
messages: {
|
|
1244
|
-
|
|
1269
|
+
status?: "pending" | "success" | "failed" | undefined;
|
|
1245
1270
|
fileIds?: string[] | undefined;
|
|
1246
1271
|
error?: string | undefined;
|
|
1247
1272
|
model?: string | undefined;
|
|
@@ -1249,19 +1274,36 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1249
1274
|
text?: string | undefined;
|
|
1250
1275
|
reasoning?: string | undefined;
|
|
1251
1276
|
usage?: {
|
|
1277
|
+
reasoningTokens?: number | undefined;
|
|
1278
|
+
cachedInputTokens?: number | undefined;
|
|
1252
1279
|
promptTokens: number;
|
|
1253
1280
|
completionTokens: number;
|
|
1254
1281
|
totalTokens: number;
|
|
1255
1282
|
} | undefined;
|
|
1256
1283
|
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
1257
|
-
sources?: {
|
|
1284
|
+
sources?: ({
|
|
1258
1285
|
title?: string | undefined;
|
|
1286
|
+
type?: "source" | undefined;
|
|
1259
1287
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1288
|
+
url?: string | undefined;
|
|
1260
1289
|
id: string;
|
|
1261
1290
|
sourceType: "url";
|
|
1262
|
-
|
|
1263
|
-
|
|
1291
|
+
} | {
|
|
1292
|
+
filename?: string | undefined;
|
|
1293
|
+
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
1294
|
+
id: string;
|
|
1295
|
+
title: string;
|
|
1296
|
+
type: "source";
|
|
1297
|
+
sourceType: "document";
|
|
1298
|
+
mediaType: string;
|
|
1299
|
+
})[] | undefined;
|
|
1264
1300
|
reasoningDetails?: ({
|
|
1301
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1302
|
+
signature?: string | undefined;
|
|
1303
|
+
state?: "streaming" | "done" | undefined;
|
|
1304
|
+
type: "reasoning";
|
|
1305
|
+
text: string;
|
|
1306
|
+
} | {
|
|
1265
1307
|
signature?: string | undefined;
|
|
1266
1308
|
type: "text";
|
|
1267
1309
|
text: string;
|
|
@@ -1317,6 +1359,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1317
1359
|
} | {
|
|
1318
1360
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1319
1361
|
signature?: string | undefined;
|
|
1362
|
+
state?: "streaming" | "done" | undefined;
|
|
1320
1363
|
type: "reasoning";
|
|
1321
1364
|
text: string;
|
|
1322
1365
|
} | {
|
|
@@ -1325,6 +1368,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1325
1368
|
data: string;
|
|
1326
1369
|
} | {
|
|
1327
1370
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1371
|
+
providerExecuted?: boolean | undefined;
|
|
1328
1372
|
type: "tool-call";
|
|
1329
1373
|
toolCallId: string;
|
|
1330
1374
|
toolName: string;
|
|
@@ -1336,6 +1380,8 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1336
1380
|
content: {
|
|
1337
1381
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1338
1382
|
args?: any;
|
|
1383
|
+
providerExecuted?: boolean | undefined;
|
|
1384
|
+
isError?: boolean | undefined;
|
|
1339
1385
|
experimental_content?: ({
|
|
1340
1386
|
type: "text";
|
|
1341
1387
|
text: string;
|
|
@@ -1344,7 +1390,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1344
1390
|
type: "image";
|
|
1345
1391
|
data: string;
|
|
1346
1392
|
})[] | undefined;
|
|
1347
|
-
isError?: boolean | undefined;
|
|
1348
1393
|
type: "tool-result";
|
|
1349
1394
|
toolCallId: string;
|
|
1350
1395
|
toolName: string;
|
|
@@ -1358,497 +1403,11 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
|
|
|
1358
1403
|
}[];
|
|
1359
1404
|
}, Promise<{
|
|
1360
1405
|
lastMessageId: string;
|
|
1361
|
-
|
|
1406
|
+
messages: {
|
|
1407
|
+
_id: string;
|
|
1408
|
+
order: number;
|
|
1409
|
+
stepOrder: number;
|
|
1410
|
+
}[];
|
|
1362
1411
|
}>>;
|
|
1363
1412
|
}
|
|
1364
|
-
type CoreMessageMaybeWithId = CoreMessage & {
|
|
1365
|
-
id?: string | undefined;
|
|
1366
|
-
};
|
|
1367
|
-
/**
|
|
1368
|
-
* Create a thread to store messages with an Agent.
|
|
1369
|
-
* @param ctx The context from a mutation or action.
|
|
1370
|
-
* @param component The Agent component, usually `components.agent`.
|
|
1371
|
-
* @param args The associated thread metadata.
|
|
1372
|
-
* @returns The id of the created thread.
|
|
1373
|
-
*/
|
|
1374
|
-
export declare function createThread(ctx: RunMutationCtx, component: AgentComponent, args?: {
|
|
1375
|
-
userId?: string | null;
|
|
1376
|
-
title?: string;
|
|
1377
|
-
summary?: string;
|
|
1378
|
-
}): Promise<string>;
|
|
1379
|
-
/**
|
|
1380
|
-
* Get the metadata for a thread.
|
|
1381
|
-
* @param ctx A ctx object from a query, mutation, or action.
|
|
1382
|
-
* @param args.threadId The thread to get the metadata for.
|
|
1383
|
-
* @returns The metadata for the thread.
|
|
1384
|
-
*/
|
|
1385
|
-
export declare function getThreadMetadata(ctx: RunQueryCtx, component: AgentComponent, args: {
|
|
1386
|
-
threadId: string;
|
|
1387
|
-
}): Promise<ThreadDoc>;
|
|
1388
|
-
type SaveMessagesArgs = {
|
|
1389
|
-
threadId: string;
|
|
1390
|
-
userId?: string | null;
|
|
1391
|
-
/**
|
|
1392
|
-
* The message that these messages are in response to. They will be
|
|
1393
|
-
* the same "order" as this message, at increasing stepOrder(s).
|
|
1394
|
-
*/
|
|
1395
|
-
promptMessageId?: string;
|
|
1396
|
-
/**
|
|
1397
|
-
* The messages to save.
|
|
1398
|
-
*/
|
|
1399
|
-
messages: CoreMessageMaybeWithId[];
|
|
1400
|
-
/**
|
|
1401
|
-
* Metadata to save with the messages. Each element corresponds to the
|
|
1402
|
-
* message at the same index.
|
|
1403
|
-
*/
|
|
1404
|
-
metadata?: Omit<MessageWithMetadata, "message">[];
|
|
1405
|
-
/**
|
|
1406
|
-
* If false, it will "commit" the messages immediately.
|
|
1407
|
-
* If true, it will mark them as pending until the final step has finished.
|
|
1408
|
-
* Defaults to false.
|
|
1409
|
-
*/
|
|
1410
|
-
pending?: boolean;
|
|
1411
|
-
/**
|
|
1412
|
-
* If true, it will fail any pending steps.
|
|
1413
|
-
* Defaults to false.
|
|
1414
|
-
*/
|
|
1415
|
-
failPendingSteps?: boolean;
|
|
1416
|
-
/**
|
|
1417
|
-
* The embeddings to save with the messages.
|
|
1418
|
-
*/
|
|
1419
|
-
embeddings?: Omit<MessageEmbeddings, "dimension">;
|
|
1420
|
-
};
|
|
1421
|
-
/**
|
|
1422
|
-
* Explicitly save messages associated with the thread (& user if provided)
|
|
1423
|
-
*/
|
|
1424
|
-
export declare function saveMessages(ctx: RunMutationCtx, component: AgentComponent, args: SaveMessagesArgs & {
|
|
1425
|
-
/**
|
|
1426
|
-
* The agent name to associate with the messages.
|
|
1427
|
-
*/
|
|
1428
|
-
agentName?: string;
|
|
1429
|
-
}): Promise<{
|
|
1430
|
-
lastMessageId: string;
|
|
1431
|
-
messages: {
|
|
1432
|
-
_creationTime: number;
|
|
1433
|
-
_id: string;
|
|
1434
|
-
agentName?: string | undefined;
|
|
1435
|
-
embeddingId?: string | undefined;
|
|
1436
|
-
error?: string | undefined;
|
|
1437
|
-
fileIds?: string[] | undefined;
|
|
1438
|
-
finishReason?: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown" | undefined;
|
|
1439
|
-
id?: string | undefined;
|
|
1440
|
-
message?: {
|
|
1441
|
-
content: string | ({
|
|
1442
|
-
providerOptions?: {
|
|
1443
|
-
[x: string]: {
|
|
1444
|
-
[x: string]: any;
|
|
1445
|
-
};
|
|
1446
|
-
} | undefined;
|
|
1447
|
-
text: string;
|
|
1448
|
-
type: "text";
|
|
1449
|
-
} | {
|
|
1450
|
-
image: string | ArrayBuffer;
|
|
1451
|
-
mimeType?: string | undefined;
|
|
1452
|
-
providerOptions?: {
|
|
1453
|
-
[x: string]: {
|
|
1454
|
-
[x: string]: any;
|
|
1455
|
-
};
|
|
1456
|
-
} | undefined;
|
|
1457
|
-
type: "image";
|
|
1458
|
-
} | {
|
|
1459
|
-
data: string | ArrayBuffer;
|
|
1460
|
-
filename?: string | undefined;
|
|
1461
|
-
mimeType: string;
|
|
1462
|
-
providerOptions?: {
|
|
1463
|
-
[x: string]: {
|
|
1464
|
-
[x: string]: any;
|
|
1465
|
-
};
|
|
1466
|
-
} | undefined;
|
|
1467
|
-
type: "file";
|
|
1468
|
-
})[];
|
|
1469
|
-
providerOptions?: {
|
|
1470
|
-
[x: string]: {
|
|
1471
|
-
[x: string]: any;
|
|
1472
|
-
};
|
|
1473
|
-
} | undefined;
|
|
1474
|
-
role: "user";
|
|
1475
|
-
} | {
|
|
1476
|
-
content: string | ({
|
|
1477
|
-
providerOptions?: {
|
|
1478
|
-
[x: string]: {
|
|
1479
|
-
[x: string]: any;
|
|
1480
|
-
};
|
|
1481
|
-
} | undefined;
|
|
1482
|
-
text: string;
|
|
1483
|
-
type: "text";
|
|
1484
|
-
} | {
|
|
1485
|
-
data: string | ArrayBuffer;
|
|
1486
|
-
filename?: string | undefined;
|
|
1487
|
-
mimeType: string;
|
|
1488
|
-
providerOptions?: {
|
|
1489
|
-
[x: string]: {
|
|
1490
|
-
[x: string]: any;
|
|
1491
|
-
};
|
|
1492
|
-
} | undefined;
|
|
1493
|
-
type: "file";
|
|
1494
|
-
} | {
|
|
1495
|
-
providerOptions?: {
|
|
1496
|
-
[x: string]: {
|
|
1497
|
-
[x: string]: any;
|
|
1498
|
-
};
|
|
1499
|
-
} | undefined;
|
|
1500
|
-
signature?: string | undefined;
|
|
1501
|
-
text: string;
|
|
1502
|
-
type: "reasoning";
|
|
1503
|
-
} | {
|
|
1504
|
-
data: string;
|
|
1505
|
-
providerOptions?: {
|
|
1506
|
-
[x: string]: {
|
|
1507
|
-
[x: string]: any;
|
|
1508
|
-
};
|
|
1509
|
-
} | undefined;
|
|
1510
|
-
type: "redacted-reasoning";
|
|
1511
|
-
} | {
|
|
1512
|
-
args: any;
|
|
1513
|
-
providerOptions?: {
|
|
1514
|
-
[x: string]: {
|
|
1515
|
-
[x: string]: any;
|
|
1516
|
-
};
|
|
1517
|
-
} | undefined;
|
|
1518
|
-
toolCallId: string;
|
|
1519
|
-
toolName: string;
|
|
1520
|
-
type: "tool-call";
|
|
1521
|
-
})[];
|
|
1522
|
-
providerOptions?: {
|
|
1523
|
-
[x: string]: {
|
|
1524
|
-
[x: string]: any;
|
|
1525
|
-
};
|
|
1526
|
-
} | undefined;
|
|
1527
|
-
role: "assistant";
|
|
1528
|
-
} | {
|
|
1529
|
-
content: {
|
|
1530
|
-
args?: any;
|
|
1531
|
-
experimental_content?: ({
|
|
1532
|
-
text: string;
|
|
1533
|
-
type: "text";
|
|
1534
|
-
} | {
|
|
1535
|
-
data: string;
|
|
1536
|
-
mimeType?: string | undefined;
|
|
1537
|
-
type: "image";
|
|
1538
|
-
})[] | undefined;
|
|
1539
|
-
isError?: boolean | undefined;
|
|
1540
|
-
providerOptions?: {
|
|
1541
|
-
[x: string]: {
|
|
1542
|
-
[x: string]: any;
|
|
1543
|
-
};
|
|
1544
|
-
} | undefined;
|
|
1545
|
-
result: any;
|
|
1546
|
-
toolCallId: string;
|
|
1547
|
-
toolName: string;
|
|
1548
|
-
type: "tool-result";
|
|
1549
|
-
}[];
|
|
1550
|
-
providerOptions?: {
|
|
1551
|
-
[x: string]: {
|
|
1552
|
-
[x: string]: any;
|
|
1553
|
-
};
|
|
1554
|
-
} | undefined;
|
|
1555
|
-
role: "tool";
|
|
1556
|
-
} | {
|
|
1557
|
-
content: string;
|
|
1558
|
-
providerOptions?: {
|
|
1559
|
-
[x: string]: {
|
|
1560
|
-
[x: string]: any;
|
|
1561
|
-
};
|
|
1562
|
-
} | undefined;
|
|
1563
|
-
role: "system";
|
|
1564
|
-
} | undefined;
|
|
1565
|
-
model?: string | undefined;
|
|
1566
|
-
order: number;
|
|
1567
|
-
provider?: string | undefined;
|
|
1568
|
-
providerMetadata?: {
|
|
1569
|
-
[x: string]: {
|
|
1570
|
-
[x: string]: any;
|
|
1571
|
-
};
|
|
1572
|
-
} | undefined;
|
|
1573
|
-
providerOptions?: {
|
|
1574
|
-
[x: string]: {
|
|
1575
|
-
[x: string]: any;
|
|
1576
|
-
};
|
|
1577
|
-
} | undefined;
|
|
1578
|
-
reasoning?: string | undefined;
|
|
1579
|
-
reasoningDetails?: ({
|
|
1580
|
-
signature?: string | undefined;
|
|
1581
|
-
text: string;
|
|
1582
|
-
type: "text";
|
|
1583
|
-
} | {
|
|
1584
|
-
data: string;
|
|
1585
|
-
type: "redacted";
|
|
1586
|
-
})[] | undefined;
|
|
1587
|
-
sources?: {
|
|
1588
|
-
id: string;
|
|
1589
|
-
providerOptions?: {
|
|
1590
|
-
[x: string]: {
|
|
1591
|
-
[x: string]: any;
|
|
1592
|
-
};
|
|
1593
|
-
} | undefined;
|
|
1594
|
-
sourceType: "url";
|
|
1595
|
-
title?: string | undefined;
|
|
1596
|
-
url: string;
|
|
1597
|
-
}[] | undefined;
|
|
1598
|
-
status: "pending" | "success" | "failed";
|
|
1599
|
-
stepOrder: number;
|
|
1600
|
-
text?: string | undefined;
|
|
1601
|
-
threadId: string;
|
|
1602
|
-
tool: boolean;
|
|
1603
|
-
usage?: {
|
|
1604
|
-
completionTokens: number;
|
|
1605
|
-
promptTokens: number;
|
|
1606
|
-
totalTokens: number;
|
|
1607
|
-
} | undefined;
|
|
1608
|
-
userId?: string | undefined;
|
|
1609
|
-
warnings?: ({
|
|
1610
|
-
details?: string | undefined;
|
|
1611
|
-
setting: string;
|
|
1612
|
-
type: "unsupported-setting";
|
|
1613
|
-
} | {
|
|
1614
|
-
details?: string | undefined;
|
|
1615
|
-
tool: any;
|
|
1616
|
-
type: "unsupported-tool";
|
|
1617
|
-
} | {
|
|
1618
|
-
message: string;
|
|
1619
|
-
type: "other";
|
|
1620
|
-
})[] | undefined;
|
|
1621
|
-
}[];
|
|
1622
|
-
}>;
|
|
1623
|
-
type SaveMessageArgs = {
|
|
1624
|
-
threadId: string;
|
|
1625
|
-
userId?: string | null;
|
|
1626
|
-
/**
|
|
1627
|
-
* Metadata to save with the messages. Each element corresponds to the
|
|
1628
|
-
* message at the same index.
|
|
1629
|
-
*/
|
|
1630
|
-
metadata?: Omit<MessageWithMetadata, "message">;
|
|
1631
|
-
/**
|
|
1632
|
-
* The embedding to save with the message.
|
|
1633
|
-
*/
|
|
1634
|
-
embedding?: {
|
|
1635
|
-
vector: number[];
|
|
1636
|
-
model: string;
|
|
1637
|
-
};
|
|
1638
|
-
} & ({
|
|
1639
|
-
prompt?: undefined;
|
|
1640
|
-
/**
|
|
1641
|
-
* The message to save.
|
|
1642
|
-
*/
|
|
1643
|
-
message: CoreMessage;
|
|
1644
|
-
} | {
|
|
1645
|
-
prompt: string;
|
|
1646
|
-
message?: undefined;
|
|
1647
|
-
});
|
|
1648
|
-
/**
|
|
1649
|
-
* Save a message to the thread.
|
|
1650
|
-
* @param ctx A ctx object from a mutation or action.
|
|
1651
|
-
* @param args The message and what to associate it with (user / thread)
|
|
1652
|
-
* You can pass extra metadata alongside the message, e.g. associated fileIds.
|
|
1653
|
-
* @returns The messageId of the saved message.
|
|
1654
|
-
*/
|
|
1655
|
-
export declare function saveMessage(ctx: RunMutationCtx, component: AgentComponent, args: SaveMessageArgs & {
|
|
1656
|
-
/**
|
|
1657
|
-
* The agent name to associate with the message.
|
|
1658
|
-
*/
|
|
1659
|
-
agentName?: string;
|
|
1660
|
-
}): Promise<{
|
|
1661
|
-
messageId: string;
|
|
1662
|
-
message: {
|
|
1663
|
-
_creationTime: number;
|
|
1664
|
-
_id: string;
|
|
1665
|
-
agentName?: string | undefined;
|
|
1666
|
-
embeddingId?: string | undefined;
|
|
1667
|
-
error?: string | undefined;
|
|
1668
|
-
fileIds?: string[] | undefined;
|
|
1669
|
-
finishReason?: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown" | undefined;
|
|
1670
|
-
id?: string | undefined;
|
|
1671
|
-
message?: {
|
|
1672
|
-
content: string | ({
|
|
1673
|
-
providerOptions?: {
|
|
1674
|
-
[x: string]: {
|
|
1675
|
-
[x: string]: any;
|
|
1676
|
-
};
|
|
1677
|
-
} | undefined;
|
|
1678
|
-
text: string;
|
|
1679
|
-
type: "text";
|
|
1680
|
-
} | {
|
|
1681
|
-
image: string | ArrayBuffer;
|
|
1682
|
-
mimeType?: string | undefined;
|
|
1683
|
-
providerOptions?: {
|
|
1684
|
-
[x: string]: {
|
|
1685
|
-
[x: string]: any;
|
|
1686
|
-
};
|
|
1687
|
-
} | undefined;
|
|
1688
|
-
type: "image";
|
|
1689
|
-
} | {
|
|
1690
|
-
data: string | ArrayBuffer;
|
|
1691
|
-
filename?: string | undefined;
|
|
1692
|
-
mimeType: string;
|
|
1693
|
-
providerOptions?: {
|
|
1694
|
-
[x: string]: {
|
|
1695
|
-
[x: string]: any;
|
|
1696
|
-
};
|
|
1697
|
-
} | undefined;
|
|
1698
|
-
type: "file";
|
|
1699
|
-
})[];
|
|
1700
|
-
providerOptions?: {
|
|
1701
|
-
[x: string]: {
|
|
1702
|
-
[x: string]: any;
|
|
1703
|
-
};
|
|
1704
|
-
} | undefined;
|
|
1705
|
-
role: "user";
|
|
1706
|
-
} | {
|
|
1707
|
-
content: string | ({
|
|
1708
|
-
providerOptions?: {
|
|
1709
|
-
[x: string]: {
|
|
1710
|
-
[x: string]: any;
|
|
1711
|
-
};
|
|
1712
|
-
} | undefined;
|
|
1713
|
-
text: string;
|
|
1714
|
-
type: "text";
|
|
1715
|
-
} | {
|
|
1716
|
-
data: string | ArrayBuffer;
|
|
1717
|
-
filename?: string | undefined;
|
|
1718
|
-
mimeType: string;
|
|
1719
|
-
providerOptions?: {
|
|
1720
|
-
[x: string]: {
|
|
1721
|
-
[x: string]: any;
|
|
1722
|
-
};
|
|
1723
|
-
} | undefined;
|
|
1724
|
-
type: "file";
|
|
1725
|
-
} | {
|
|
1726
|
-
providerOptions?: {
|
|
1727
|
-
[x: string]: {
|
|
1728
|
-
[x: string]: any;
|
|
1729
|
-
};
|
|
1730
|
-
} | undefined;
|
|
1731
|
-
signature?: string | undefined;
|
|
1732
|
-
text: string;
|
|
1733
|
-
type: "reasoning";
|
|
1734
|
-
} | {
|
|
1735
|
-
data: string;
|
|
1736
|
-
providerOptions?: {
|
|
1737
|
-
[x: string]: {
|
|
1738
|
-
[x: string]: any;
|
|
1739
|
-
};
|
|
1740
|
-
} | undefined;
|
|
1741
|
-
type: "redacted-reasoning";
|
|
1742
|
-
} | {
|
|
1743
|
-
args: any;
|
|
1744
|
-
providerOptions?: {
|
|
1745
|
-
[x: string]: {
|
|
1746
|
-
[x: string]: any;
|
|
1747
|
-
};
|
|
1748
|
-
} | undefined;
|
|
1749
|
-
toolCallId: string;
|
|
1750
|
-
toolName: string;
|
|
1751
|
-
type: "tool-call";
|
|
1752
|
-
})[];
|
|
1753
|
-
providerOptions?: {
|
|
1754
|
-
[x: string]: {
|
|
1755
|
-
[x: string]: any;
|
|
1756
|
-
};
|
|
1757
|
-
} | undefined;
|
|
1758
|
-
role: "assistant";
|
|
1759
|
-
} | {
|
|
1760
|
-
content: {
|
|
1761
|
-
args?: any;
|
|
1762
|
-
experimental_content?: ({
|
|
1763
|
-
text: string;
|
|
1764
|
-
type: "text";
|
|
1765
|
-
} | {
|
|
1766
|
-
data: string;
|
|
1767
|
-
mimeType?: string | undefined;
|
|
1768
|
-
type: "image";
|
|
1769
|
-
})[] | undefined;
|
|
1770
|
-
isError?: boolean | undefined;
|
|
1771
|
-
providerOptions?: {
|
|
1772
|
-
[x: string]: {
|
|
1773
|
-
[x: string]: any;
|
|
1774
|
-
};
|
|
1775
|
-
} | undefined;
|
|
1776
|
-
result: any;
|
|
1777
|
-
toolCallId: string;
|
|
1778
|
-
toolName: string;
|
|
1779
|
-
type: "tool-result";
|
|
1780
|
-
}[];
|
|
1781
|
-
providerOptions?: {
|
|
1782
|
-
[x: string]: {
|
|
1783
|
-
[x: string]: any;
|
|
1784
|
-
};
|
|
1785
|
-
} | undefined;
|
|
1786
|
-
role: "tool";
|
|
1787
|
-
} | {
|
|
1788
|
-
content: string;
|
|
1789
|
-
providerOptions?: {
|
|
1790
|
-
[x: string]: {
|
|
1791
|
-
[x: string]: any;
|
|
1792
|
-
};
|
|
1793
|
-
} | undefined;
|
|
1794
|
-
role: "system";
|
|
1795
|
-
} | undefined;
|
|
1796
|
-
model?: string | undefined;
|
|
1797
|
-
order: number;
|
|
1798
|
-
provider?: string | undefined;
|
|
1799
|
-
providerMetadata?: {
|
|
1800
|
-
[x: string]: {
|
|
1801
|
-
[x: string]: any;
|
|
1802
|
-
};
|
|
1803
|
-
} | undefined;
|
|
1804
|
-
providerOptions?: {
|
|
1805
|
-
[x: string]: {
|
|
1806
|
-
[x: string]: any;
|
|
1807
|
-
};
|
|
1808
|
-
} | undefined;
|
|
1809
|
-
reasoning?: string | undefined;
|
|
1810
|
-
reasoningDetails?: ({
|
|
1811
|
-
signature?: string | undefined;
|
|
1812
|
-
text: string;
|
|
1813
|
-
type: "text";
|
|
1814
|
-
} | {
|
|
1815
|
-
data: string;
|
|
1816
|
-
type: "redacted";
|
|
1817
|
-
})[] | undefined;
|
|
1818
|
-
sources?: {
|
|
1819
|
-
id: string;
|
|
1820
|
-
providerOptions?: {
|
|
1821
|
-
[x: string]: {
|
|
1822
|
-
[x: string]: any;
|
|
1823
|
-
};
|
|
1824
|
-
} | undefined;
|
|
1825
|
-
sourceType: "url";
|
|
1826
|
-
title?: string | undefined;
|
|
1827
|
-
url: string;
|
|
1828
|
-
}[] | undefined;
|
|
1829
|
-
status: "pending" | "success" | "failed";
|
|
1830
|
-
stepOrder: number;
|
|
1831
|
-
text?: string | undefined;
|
|
1832
|
-
threadId: string;
|
|
1833
|
-
tool: boolean;
|
|
1834
|
-
usage?: {
|
|
1835
|
-
completionTokens: number;
|
|
1836
|
-
promptTokens: number;
|
|
1837
|
-
totalTokens: number;
|
|
1838
|
-
} | undefined;
|
|
1839
|
-
userId?: string | undefined;
|
|
1840
|
-
warnings?: ({
|
|
1841
|
-
details?: string | undefined;
|
|
1842
|
-
setting: string;
|
|
1843
|
-
type: "unsupported-setting";
|
|
1844
|
-
} | {
|
|
1845
|
-
details?: string | undefined;
|
|
1846
|
-
tool: any;
|
|
1847
|
-
type: "unsupported-tool";
|
|
1848
|
-
} | {
|
|
1849
|
-
message: string;
|
|
1850
|
-
type: "other";
|
|
1851
|
-
})[] | undefined;
|
|
1852
|
-
};
|
|
1853
|
-
}>;
|
|
1854
1413
|
//# sourceMappingURL=index.d.ts.map
|