@convex-dev/agent 0.1.15-alpha.0 → 0.1.15-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/README.md +13 -12
- package/dist/client/index.d.ts +494 -173
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +148 -170
- package/dist/client/index.js.map +1 -1
- package/dist/client/listMessages.d.ts +22 -0
- package/dist/client/listMessages.d.ts.map +1 -0
- package/dist/client/listMessages.js +25 -0
- package/dist/client/listMessages.js.map +1 -0
- package/dist/client/search.d.ts +162 -0
- package/dist/client/search.d.ts.map +1 -0
- package/dist/client/search.js +113 -0
- package/dist/client/search.js.map +1 -0
- package/dist/client/streaming.d.ts +17 -3
- package/dist/client/streaming.d.ts.map +1 -1
- package/dist/client/streaming.js +32 -0
- package/dist/client/streaming.js.map +1 -1
- package/dist/client/types.d.ts +5 -1
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +2 -2
- package/dist/component/messages.d.ts +3 -3
- package/dist/component/messages.d.ts.map +1 -1
- package/dist/component/messages.js +12 -7
- package/dist/component/messages.js.map +1 -1
- package/dist/component/vector/index.js +3 -3
- package/dist/component/vector/index.js.map +1 -1
- package/dist/react/optimisticallySendMessage.d.ts +1 -0
- package/dist/react/optimisticallySendMessage.d.ts.map +1 -1
- package/dist/react/optimisticallySendMessage.js +8 -1
- package/dist/react/optimisticallySendMessage.js.map +1 -1
- package/dist/react/toUIMessages.d.ts +1 -0
- package/dist/react/toUIMessages.d.ts.map +1 -1
- package/dist/react/toUIMessages.js +2 -0
- package/dist/react/toUIMessages.js.map +1 -1
- package/dist/validators.d.ts +41 -52
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +1 -8
- package/dist/validators.js.map +1 -1
- package/package.json +6 -4
- package/src/client/index.ts +283 -274
- package/src/client/listMessages.ts +38 -0
- package/src/client/search.ts +172 -0
- package/src/client/streaming.ts +49 -2
- package/src/client/types.ts +5 -1
- package/src/component/_generated/api.d.ts +2 -2
- package/src/component/messages.ts +13 -7
- package/src/component/vector/index.ts +4 -4
- package/src/react/optimisticallySendMessage.ts +11 -1
- package/src/react/toUIMessages.ts +3 -0
- package/src/validators.ts +2 -10
package/dist/client/index.d.ts
CHANGED
|
@@ -5,18 +5,22 @@ import type { MessageDoc, ThreadDoc } from "../component/schema.js";
|
|
|
5
5
|
import { type VectorDimension } from "../component/vector/tables.js";
|
|
6
6
|
import { type AIMessageWithoutId } from "../mapping.js";
|
|
7
7
|
import { extractText, isTool } from "../shared.js";
|
|
8
|
-
import { type MessageWithMetadata, type MessageStatus, type ProviderMetadata, type
|
|
8
|
+
import { type MessageWithMetadata, type MessageStatus, type ProviderMetadata, type StreamArgs, type Usage, type MessageEmbeddings } from "../validators.js";
|
|
9
9
|
import { createTool } from "./createTool.js";
|
|
10
10
|
import { type StreamingOptions } from "./streaming.js";
|
|
11
11
|
import type { AgentComponent, ContextOptions, GenerationOutputMetadata, Options, OurObjectArgs, OurStreamObjectArgs, RawRequestResponseHandler, RunActionCtx, RunMutationCtx, RunQueryCtx, ActionCtx, StorageOptions, StreamingTextArgs, SyncStreamsReturnValue, TextArgs, Thread, UsageHandler } from "./types.js";
|
|
12
12
|
import type { threadFieldsSupportingPatch } from "../component/threads.js";
|
|
13
|
+
import { listMessages } from "./listMessages.js";
|
|
14
|
+
import { syncStreams } from "./streaming.js";
|
|
15
|
+
import { fetchContextMessages } from "./search.js";
|
|
13
16
|
export { storeFile, getFile } from "./files.js";
|
|
14
17
|
export { serializeDataOrUrl } from "../mapping.js";
|
|
15
18
|
export { vMessageDoc, vThreadDoc } from "../component/schema.js";
|
|
16
19
|
export { vAssistantMessage, vContextOptions, vMessage, vPaginationResult, vProviderMetadata, vStorageOptions, vStreamArgs, vSystemMessage, vToolMessage, vUsage, vUserMessage, } from "../validators.js";
|
|
17
20
|
export type { ToolCtx } from "./createTool.js";
|
|
18
|
-
export {
|
|
19
|
-
export
|
|
21
|
+
export { filterOutOrphanedToolMessages } from "./search.js";
|
|
22
|
+
export { createTool, extractText, fetchContextMessages, isTool, listMessages, syncStreams, };
|
|
23
|
+
export type { AgentComponent, ContextOptions, MessageDoc, ProviderMetadata, RawRequestResponseHandler, StorageOptions, StreamArgs, SyncStreamsReturnValue, Thread, ThreadDoc, Usage, UsageHandler, };
|
|
20
24
|
export declare class Agent<AgentTools extends ToolSet = ToolSet> {
|
|
21
25
|
component: AgentComponent;
|
|
22
26
|
options: {
|
|
@@ -381,14 +385,7 @@ export declare class Agent<AgentTools extends ToolSet = ToolSet> {
|
|
|
381
385
|
* You can pass extra metadata alongside the message, e.g. associated fileIds.
|
|
382
386
|
* @returns The messageId of the saved message.
|
|
383
387
|
*/
|
|
384
|
-
saveMessage(ctx: RunMutationCtx, args: {
|
|
385
|
-
threadId: string;
|
|
386
|
-
userId?: string;
|
|
387
|
-
/**
|
|
388
|
-
* Metadata to save with the messages. Each element corresponds to the
|
|
389
|
-
* message at the same index.
|
|
390
|
-
*/
|
|
391
|
-
metadata?: Omit<MessageWithMetadata, "message">;
|
|
388
|
+
saveMessage(ctx: RunMutationCtx, args: SaveMessageArgs & {
|
|
392
389
|
/**
|
|
393
390
|
* If true, it will not generate embeddings for the message.
|
|
394
391
|
* Useful if you're saving messages in a mutation where you can't run `fetch`.
|
|
@@ -396,16 +393,7 @@ export declare class Agent<AgentTools extends ToolSet = ToolSet> {
|
|
|
396
393
|
* action later that calls `agent.generateAndSaveEmbeddings`.
|
|
397
394
|
*/
|
|
398
395
|
skipEmbeddings?: boolean;
|
|
399
|
-
}
|
|
400
|
-
prompt?: undefined;
|
|
401
|
-
/**
|
|
402
|
-
* The message to save.
|
|
403
|
-
*/
|
|
404
|
-
message: CoreMessage;
|
|
405
|
-
} | {
|
|
406
|
-
prompt: string;
|
|
407
|
-
message?: undefined;
|
|
408
|
-
})): Promise<{
|
|
396
|
+
}): Promise<{
|
|
409
397
|
messageId: string;
|
|
410
398
|
message: {
|
|
411
399
|
id?: string | undefined;
|
|
@@ -537,38 +525,13 @@ export declare class Agent<AgentTools extends ToolSet = ToolSet> {
|
|
|
537
525
|
}>;
|
|
538
526
|
/**
|
|
539
527
|
* Explicitly save messages associated with the thread (& user if provided)
|
|
528
|
+
* If you have an embedding model set, it will also generate embeddings for
|
|
529
|
+
* the messages.
|
|
540
530
|
* @param ctx The ctx parameter to a mutation or action.
|
|
541
531
|
* @param args The messages and context to save
|
|
542
532
|
* @returns
|
|
543
533
|
*/
|
|
544
|
-
saveMessages(ctx: RunMutationCtx | RunActionCtx, args: {
|
|
545
|
-
threadId: string;
|
|
546
|
-
userId?: string;
|
|
547
|
-
/**
|
|
548
|
-
* The message that these messages are in response to. They will be
|
|
549
|
-
* the same "order" as this message, at increasing stepOrder(s).
|
|
550
|
-
*/
|
|
551
|
-
promptMessageId?: string;
|
|
552
|
-
/**
|
|
553
|
-
* The messages to save.
|
|
554
|
-
*/
|
|
555
|
-
messages: CoreMessageMaybeWithId[];
|
|
556
|
-
/**
|
|
557
|
-
* Metadata to save with the messages. Each element corresponds to the
|
|
558
|
-
* message at the same index.
|
|
559
|
-
*/
|
|
560
|
-
metadata?: Omit<MessageWithMetadata, "message">[];
|
|
561
|
-
/**
|
|
562
|
-
* If false, it will "commit" the messages immediately.
|
|
563
|
-
* If true, it will mark them as pending until the final step has finished.
|
|
564
|
-
* Defaults to false.
|
|
565
|
-
*/
|
|
566
|
-
pending?: boolean;
|
|
567
|
-
/**
|
|
568
|
-
* If true, it will fail any pending steps.
|
|
569
|
-
* Defaults to false.
|
|
570
|
-
*/
|
|
571
|
-
failPendingSteps?: boolean;
|
|
534
|
+
saveMessages(ctx: RunMutationCtx | RunActionCtx, args: SaveMessagesArgs & {
|
|
572
535
|
/**
|
|
573
536
|
* Skip generating embeddings for the messages. Useful if you're
|
|
574
537
|
* saving messages in a mutation where you can't run `fetch`.
|
|
@@ -872,10 +835,6 @@ export declare class Agent<AgentTools extends ToolSet = ToolSet> {
|
|
|
872
835
|
}>;
|
|
873
836
|
_shouldSaveOutputMessages(storageOpts?: StorageOptions): boolean;
|
|
874
837
|
_mergedContextOptions(opts: ContextOptions | undefined): ContextOptions;
|
|
875
|
-
_searchOptionsWithEmbeddingAndDefaults(ctx: RunActionCtx, { userId, threadId }: {
|
|
876
|
-
userId?: string;
|
|
877
|
-
threadId?: string;
|
|
878
|
-
}, contextOptions: ContextOptions, messages: CoreMessage[]): Promise<SearchOptions>;
|
|
879
838
|
doEmbed(ctx: RunActionCtx, options: {
|
|
880
839
|
userId: string | undefined;
|
|
881
840
|
threadId: string | undefined;
|
|
@@ -1058,12 +1017,13 @@ export declare class Agent<AgentTools extends ToolSet = ToolSet> {
|
|
|
1058
1017
|
excludeToolMessages?: boolean | undefined;
|
|
1059
1018
|
recentMessages?: number | undefined;
|
|
1060
1019
|
searchOptions?: {
|
|
1020
|
+
textSearch?: boolean | undefined;
|
|
1021
|
+
vectorSearch?: boolean | undefined;
|
|
1022
|
+
vectorScoreThreshold?: number | undefined;
|
|
1061
1023
|
messageRange?: {
|
|
1062
1024
|
before: number;
|
|
1063
1025
|
after: number;
|
|
1064
1026
|
} | undefined;
|
|
1065
|
-
textSearch?: boolean | undefined;
|
|
1066
|
-
vectorSearch?: boolean | undefined;
|
|
1067
1027
|
limit: number;
|
|
1068
1028
|
} | undefined;
|
|
1069
1029
|
searchOtherThreads?: boolean | undefined;
|
|
@@ -1184,12 +1144,13 @@ export declare class Agent<AgentTools extends ToolSet = ToolSet> {
|
|
|
1184
1144
|
excludeToolMessages?: boolean | undefined;
|
|
1185
1145
|
recentMessages?: number | undefined;
|
|
1186
1146
|
searchOptions?: {
|
|
1147
|
+
textSearch?: boolean | undefined;
|
|
1148
|
+
vectorSearch?: boolean | undefined;
|
|
1149
|
+
vectorScoreThreshold?: number | undefined;
|
|
1187
1150
|
messageRange?: {
|
|
1188
1151
|
before: number;
|
|
1189
1152
|
after: number;
|
|
1190
1153
|
} | undefined;
|
|
1191
|
-
textSearch?: boolean | undefined;
|
|
1192
|
-
vectorSearch?: boolean | undefined;
|
|
1193
1154
|
limit: number;
|
|
1194
1155
|
} | undefined;
|
|
1195
1156
|
searchOtherThreads?: boolean | undefined;
|
|
@@ -1350,134 +1311,494 @@ export declare class Agent<AgentTools extends ToolSet = ToolSet> {
|
|
|
1350
1311
|
messageIds: string[];
|
|
1351
1312
|
}>>;
|
|
1352
1313
|
}
|
|
1353
|
-
|
|
1314
|
+
type CoreMessageMaybeWithId = CoreMessage & {
|
|
1354
1315
|
id?: string | undefined;
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1316
|
+
};
|
|
1317
|
+
/**
|
|
1318
|
+
* Create a thread to store messages with an Agent.
|
|
1319
|
+
* @param ctx The context from a mutation or action.
|
|
1320
|
+
* @param component The Agent component, usually `components.agent`.
|
|
1321
|
+
* @param args The associated thread metadata.
|
|
1322
|
+
* @returns The id of the created thread.
|
|
1323
|
+
*/
|
|
1324
|
+
export declare function createThread(ctx: RunMutationCtx, component: AgentComponent, args?: {
|
|
1325
|
+
userId?: string;
|
|
1326
|
+
title?: string;
|
|
1327
|
+
summary?: string;
|
|
1328
|
+
}): Promise<string>;
|
|
1329
|
+
/**
|
|
1330
|
+
* Get the metadata for a thread.
|
|
1331
|
+
* @param ctx A ctx object from a query, mutation, or action.
|
|
1332
|
+
* @param args.threadId The thread to get the metadata for.
|
|
1333
|
+
* @returns The metadata for the thread.
|
|
1334
|
+
*/
|
|
1335
|
+
export declare function getThreadMetadata(ctx: RunQueryCtx, component: AgentComponent, args: {
|
|
1336
|
+
threadId: string;
|
|
1337
|
+
}): Promise<ThreadDoc>;
|
|
1338
|
+
type SaveMessagesArgs = {
|
|
1339
|
+
threadId: string;
|
|
1340
|
+
userId?: string;
|
|
1341
|
+
/**
|
|
1342
|
+
* The message that these messages are in response to. They will be
|
|
1343
|
+
* the same "order" as this message, at increasing stepOrder(s).
|
|
1344
|
+
*/
|
|
1345
|
+
promptMessageId?: string;
|
|
1346
|
+
/**
|
|
1347
|
+
* The messages to save.
|
|
1348
|
+
*/
|
|
1349
|
+
messages: CoreMessageMaybeWithId[];
|
|
1350
|
+
/**
|
|
1351
|
+
* Metadata to save with the messages. Each element corresponds to the
|
|
1352
|
+
* message at the same index.
|
|
1353
|
+
*/
|
|
1354
|
+
metadata?: Omit<MessageWithMetadata, "message">[];
|
|
1355
|
+
/**
|
|
1356
|
+
* If false, it will "commit" the messages immediately.
|
|
1357
|
+
* If true, it will mark them as pending until the final step has finished.
|
|
1358
|
+
* Defaults to false.
|
|
1359
|
+
*/
|
|
1360
|
+
pending?: boolean;
|
|
1361
|
+
/**
|
|
1362
|
+
* If true, it will fail any pending steps.
|
|
1363
|
+
* Defaults to false.
|
|
1364
|
+
*/
|
|
1365
|
+
failPendingSteps?: boolean;
|
|
1366
|
+
/**
|
|
1367
|
+
* The embeddings to save with the messages.
|
|
1368
|
+
*/
|
|
1369
|
+
embeddings?: Omit<MessageEmbeddings, "dimension">;
|
|
1370
|
+
};
|
|
1371
|
+
/**
|
|
1372
|
+
* Explicitly save messages associated with the thread (& user if provided)
|
|
1373
|
+
*/
|
|
1374
|
+
export declare function saveMessages(ctx: RunMutationCtx, component: AgentComponent, args: SaveMessagesArgs & {
|
|
1375
|
+
/**
|
|
1376
|
+
* The agent name to associate with the messages.
|
|
1377
|
+
*/
|
|
1378
|
+
agentName?: string;
|
|
1379
|
+
}): Promise<{
|
|
1380
|
+
lastMessageId: string;
|
|
1381
|
+
messages: {
|
|
1382
|
+
_creationTime: number;
|
|
1383
|
+
_id: string;
|
|
1384
|
+
agentName?: string | undefined;
|
|
1385
|
+
embeddingId?: string | undefined;
|
|
1386
|
+
error?: string | undefined;
|
|
1387
|
+
fileIds?: string[] | undefined;
|
|
1388
|
+
finishReason?: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown" | undefined;
|
|
1389
|
+
id?: string | undefined;
|
|
1390
|
+
message?: {
|
|
1391
|
+
content: string | ({
|
|
1392
|
+
providerOptions?: {
|
|
1393
|
+
[x: string]: {
|
|
1394
|
+
[x: string]: any;
|
|
1395
|
+
};
|
|
1396
|
+
} | undefined;
|
|
1397
|
+
text: string;
|
|
1398
|
+
type: "text";
|
|
1399
|
+
} | {
|
|
1400
|
+
image: string | ArrayBuffer;
|
|
1401
|
+
mimeType?: string | undefined;
|
|
1402
|
+
providerOptions?: {
|
|
1403
|
+
[x: string]: {
|
|
1404
|
+
[x: string]: any;
|
|
1405
|
+
};
|
|
1406
|
+
} | undefined;
|
|
1407
|
+
type: "image";
|
|
1408
|
+
} | {
|
|
1409
|
+
data: string | ArrayBuffer;
|
|
1410
|
+
filename?: string | undefined;
|
|
1411
|
+
mimeType: string;
|
|
1412
|
+
providerOptions?: {
|
|
1413
|
+
[x: string]: {
|
|
1414
|
+
[x: string]: any;
|
|
1415
|
+
};
|
|
1416
|
+
} | undefined;
|
|
1417
|
+
type: "file";
|
|
1418
|
+
})[];
|
|
1419
|
+
providerOptions?: {
|
|
1420
|
+
[x: string]: {
|
|
1421
|
+
[x: string]: any;
|
|
1422
|
+
};
|
|
1423
|
+
} | undefined;
|
|
1424
|
+
role: "user";
|
|
1375
1425
|
} | {
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1426
|
+
content: string | ({
|
|
1427
|
+
providerOptions?: {
|
|
1428
|
+
[x: string]: {
|
|
1429
|
+
[x: string]: any;
|
|
1430
|
+
};
|
|
1431
|
+
} | undefined;
|
|
1432
|
+
text: string;
|
|
1433
|
+
type: "text";
|
|
1434
|
+
} | {
|
|
1435
|
+
data: string | ArrayBuffer;
|
|
1436
|
+
filename?: string | undefined;
|
|
1437
|
+
mimeType: string;
|
|
1438
|
+
providerOptions?: {
|
|
1439
|
+
[x: string]: {
|
|
1440
|
+
[x: string]: any;
|
|
1441
|
+
};
|
|
1442
|
+
} | undefined;
|
|
1443
|
+
type: "file";
|
|
1444
|
+
} | {
|
|
1445
|
+
providerOptions?: {
|
|
1446
|
+
[x: string]: {
|
|
1447
|
+
[x: string]: any;
|
|
1448
|
+
};
|
|
1449
|
+
} | undefined;
|
|
1450
|
+
signature?: string | undefined;
|
|
1451
|
+
text: string;
|
|
1452
|
+
type: "reasoning";
|
|
1453
|
+
} | {
|
|
1454
|
+
data: string;
|
|
1455
|
+
providerOptions?: {
|
|
1456
|
+
[x: string]: {
|
|
1457
|
+
[x: string]: any;
|
|
1458
|
+
};
|
|
1459
|
+
} | undefined;
|
|
1460
|
+
type: "redacted-reasoning";
|
|
1461
|
+
} | {
|
|
1462
|
+
args: any;
|
|
1463
|
+
providerOptions?: {
|
|
1464
|
+
[x: string]: {
|
|
1465
|
+
[x: string]: any;
|
|
1466
|
+
};
|
|
1467
|
+
} | undefined;
|
|
1468
|
+
toolCallId: string;
|
|
1469
|
+
toolName: string;
|
|
1470
|
+
type: "tool-call";
|
|
1471
|
+
})[];
|
|
1472
|
+
providerOptions?: {
|
|
1473
|
+
[x: string]: {
|
|
1474
|
+
[x: string]: any;
|
|
1475
|
+
};
|
|
1476
|
+
} | undefined;
|
|
1477
|
+
role: "assistant";
|
|
1389
1478
|
} | {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1479
|
+
content: {
|
|
1480
|
+
args?: any;
|
|
1481
|
+
experimental_content?: ({
|
|
1482
|
+
text: string;
|
|
1483
|
+
type: "text";
|
|
1484
|
+
} | {
|
|
1485
|
+
data: string;
|
|
1486
|
+
mimeType?: string | undefined;
|
|
1487
|
+
type: "image";
|
|
1488
|
+
})[] | undefined;
|
|
1489
|
+
isError?: boolean | undefined;
|
|
1490
|
+
providerOptions?: {
|
|
1491
|
+
[x: string]: {
|
|
1492
|
+
[x: string]: any;
|
|
1493
|
+
};
|
|
1494
|
+
} | undefined;
|
|
1495
|
+
result: any;
|
|
1496
|
+
toolCallId: string;
|
|
1497
|
+
toolName: string;
|
|
1498
|
+
type: "tool-result";
|
|
1499
|
+
}[];
|
|
1500
|
+
providerOptions?: {
|
|
1501
|
+
[x: string]: {
|
|
1502
|
+
[x: string]: any;
|
|
1503
|
+
};
|
|
1504
|
+
} | undefined;
|
|
1505
|
+
role: "tool";
|
|
1395
1506
|
} | {
|
|
1396
|
-
|
|
1507
|
+
content: string;
|
|
1508
|
+
providerOptions?: {
|
|
1509
|
+
[x: string]: {
|
|
1510
|
+
[x: string]: any;
|
|
1511
|
+
};
|
|
1512
|
+
} | undefined;
|
|
1513
|
+
role: "system";
|
|
1514
|
+
} | undefined;
|
|
1515
|
+
model?: string | undefined;
|
|
1516
|
+
order: number;
|
|
1517
|
+
provider?: string | undefined;
|
|
1518
|
+
providerMetadata?: {
|
|
1519
|
+
[x: string]: {
|
|
1520
|
+
[x: string]: any;
|
|
1521
|
+
};
|
|
1522
|
+
} | undefined;
|
|
1523
|
+
providerOptions?: {
|
|
1524
|
+
[x: string]: {
|
|
1525
|
+
[x: string]: any;
|
|
1526
|
+
};
|
|
1527
|
+
} | undefined;
|
|
1528
|
+
reasoning?: string | undefined;
|
|
1529
|
+
reasoningDetails?: ({
|
|
1397
1530
|
signature?: string | undefined;
|
|
1398
|
-
type: "reasoning";
|
|
1399
1531
|
text: string;
|
|
1532
|
+
type: "text";
|
|
1400
1533
|
} | {
|
|
1401
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1402
|
-
type: "redacted-reasoning";
|
|
1403
1534
|
data: string;
|
|
1535
|
+
type: "redacted";
|
|
1536
|
+
})[] | undefined;
|
|
1537
|
+
sources?: {
|
|
1538
|
+
id: string;
|
|
1539
|
+
providerOptions?: {
|
|
1540
|
+
[x: string]: {
|
|
1541
|
+
[x: string]: any;
|
|
1542
|
+
};
|
|
1543
|
+
} | undefined;
|
|
1544
|
+
sourceType: "url";
|
|
1545
|
+
title?: string | undefined;
|
|
1546
|
+
url: string;
|
|
1547
|
+
}[] | undefined;
|
|
1548
|
+
status: "pending" | "success" | "failed";
|
|
1549
|
+
stepOrder: number;
|
|
1550
|
+
text?: string | undefined;
|
|
1551
|
+
threadId: string;
|
|
1552
|
+
tool: boolean;
|
|
1553
|
+
usage?: {
|
|
1554
|
+
completionTokens: number;
|
|
1555
|
+
promptTokens: number;
|
|
1556
|
+
totalTokens: number;
|
|
1557
|
+
} | undefined;
|
|
1558
|
+
userId?: string | undefined;
|
|
1559
|
+
warnings?: ({
|
|
1560
|
+
details?: string | undefined;
|
|
1561
|
+
setting: string;
|
|
1562
|
+
type: "unsupported-setting";
|
|
1404
1563
|
} | {
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1564
|
+
details?: string | undefined;
|
|
1565
|
+
tool: any;
|
|
1566
|
+
type: "unsupported-tool";
|
|
1567
|
+
} | {
|
|
1568
|
+
message: string;
|
|
1569
|
+
type: "other";
|
|
1570
|
+
})[] | undefined;
|
|
1571
|
+
}[];
|
|
1572
|
+
}>;
|
|
1573
|
+
type SaveMessageArgs = {
|
|
1574
|
+
threadId: string;
|
|
1575
|
+
userId?: string;
|
|
1576
|
+
/**
|
|
1577
|
+
* Metadata to save with the messages. Each element corresponds to the
|
|
1578
|
+
* message at the same index.
|
|
1579
|
+
*/
|
|
1580
|
+
metadata?: Omit<MessageWithMetadata, "message">;
|
|
1581
|
+
/**
|
|
1582
|
+
* The embedding to save with the message.
|
|
1583
|
+
*/
|
|
1584
|
+
embedding?: {
|
|
1585
|
+
vector: number[];
|
|
1586
|
+
model: string;
|
|
1587
|
+
};
|
|
1588
|
+
} & ({
|
|
1589
|
+
prompt?: undefined;
|
|
1590
|
+
/**
|
|
1591
|
+
* The message to save.
|
|
1592
|
+
*/
|
|
1593
|
+
message: CoreMessage;
|
|
1594
|
+
} | {
|
|
1595
|
+
prompt: string;
|
|
1596
|
+
message?: undefined;
|
|
1597
|
+
});
|
|
1598
|
+
/**
|
|
1599
|
+
* Save a message to the thread.
|
|
1600
|
+
* @param ctx A ctx object from a mutation or action.
|
|
1601
|
+
* @param args The message and what to associate it with (user / thread)
|
|
1602
|
+
* You can pass extra metadata alongside the message, e.g. associated fileIds.
|
|
1603
|
+
* @returns The messageId of the saved message.
|
|
1604
|
+
*/
|
|
1605
|
+
export declare function saveMessage(ctx: RunMutationCtx, component: AgentComponent, args: SaveMessageArgs & {
|
|
1606
|
+
/**
|
|
1607
|
+
* The agent name to associate with the message.
|
|
1608
|
+
*/
|
|
1609
|
+
agentName?: string;
|
|
1610
|
+
}): Promise<{
|
|
1611
|
+
messageId: string;
|
|
1612
|
+
message: {
|
|
1613
|
+
_creationTime: number;
|
|
1614
|
+
_id: string;
|
|
1615
|
+
agentName?: string | undefined;
|
|
1616
|
+
embeddingId?: string | undefined;
|
|
1617
|
+
error?: string | undefined;
|
|
1618
|
+
fileIds?: string[] | undefined;
|
|
1619
|
+
finishReason?: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown" | undefined;
|
|
1620
|
+
id?: string | undefined;
|
|
1621
|
+
message?: {
|
|
1622
|
+
content: string | ({
|
|
1623
|
+
providerOptions?: {
|
|
1624
|
+
[x: string]: {
|
|
1625
|
+
[x: string]: any;
|
|
1626
|
+
};
|
|
1627
|
+
} | undefined;
|
|
1419
1628
|
text: string;
|
|
1629
|
+
type: "text";
|
|
1420
1630
|
} | {
|
|
1631
|
+
image: string | ArrayBuffer;
|
|
1421
1632
|
mimeType?: string | undefined;
|
|
1633
|
+
providerOptions?: {
|
|
1634
|
+
[x: string]: {
|
|
1635
|
+
[x: string]: any;
|
|
1636
|
+
};
|
|
1637
|
+
} | undefined;
|
|
1422
1638
|
type: "image";
|
|
1639
|
+
} | {
|
|
1640
|
+
data: string | ArrayBuffer;
|
|
1641
|
+
filename?: string | undefined;
|
|
1642
|
+
mimeType: string;
|
|
1643
|
+
providerOptions?: {
|
|
1644
|
+
[x: string]: {
|
|
1645
|
+
[x: string]: any;
|
|
1646
|
+
};
|
|
1647
|
+
} | undefined;
|
|
1648
|
+
type: "file";
|
|
1649
|
+
})[];
|
|
1650
|
+
providerOptions?: {
|
|
1651
|
+
[x: string]: {
|
|
1652
|
+
[x: string]: any;
|
|
1653
|
+
};
|
|
1654
|
+
} | undefined;
|
|
1655
|
+
role: "user";
|
|
1656
|
+
} | {
|
|
1657
|
+
content: string | ({
|
|
1658
|
+
providerOptions?: {
|
|
1659
|
+
[x: string]: {
|
|
1660
|
+
[x: string]: any;
|
|
1661
|
+
};
|
|
1662
|
+
} | undefined;
|
|
1663
|
+
text: string;
|
|
1664
|
+
type: "text";
|
|
1665
|
+
} | {
|
|
1666
|
+
data: string | ArrayBuffer;
|
|
1667
|
+
filename?: string | undefined;
|
|
1668
|
+
mimeType: string;
|
|
1669
|
+
providerOptions?: {
|
|
1670
|
+
[x: string]: {
|
|
1671
|
+
[x: string]: any;
|
|
1672
|
+
};
|
|
1673
|
+
} | undefined;
|
|
1674
|
+
type: "file";
|
|
1675
|
+
} | {
|
|
1676
|
+
providerOptions?: {
|
|
1677
|
+
[x: string]: {
|
|
1678
|
+
[x: string]: any;
|
|
1679
|
+
};
|
|
1680
|
+
} | undefined;
|
|
1681
|
+
signature?: string | undefined;
|
|
1682
|
+
text: string;
|
|
1683
|
+
type: "reasoning";
|
|
1684
|
+
} | {
|
|
1423
1685
|
data: string;
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1686
|
+
providerOptions?: {
|
|
1687
|
+
[x: string]: {
|
|
1688
|
+
[x: string]: any;
|
|
1689
|
+
};
|
|
1690
|
+
} | undefined;
|
|
1691
|
+
type: "redacted-reasoning";
|
|
1692
|
+
} | {
|
|
1693
|
+
args: any;
|
|
1694
|
+
providerOptions?: {
|
|
1695
|
+
[x: string]: {
|
|
1696
|
+
[x: string]: any;
|
|
1697
|
+
};
|
|
1698
|
+
} | undefined;
|
|
1699
|
+
toolCallId: string;
|
|
1700
|
+
toolName: string;
|
|
1701
|
+
type: "tool-call";
|
|
1702
|
+
})[];
|
|
1703
|
+
providerOptions?: {
|
|
1704
|
+
[x: string]: {
|
|
1705
|
+
[x: string]: any;
|
|
1706
|
+
};
|
|
1707
|
+
} | undefined;
|
|
1708
|
+
role: "assistant";
|
|
1709
|
+
} | {
|
|
1710
|
+
content: {
|
|
1711
|
+
args?: any;
|
|
1712
|
+
experimental_content?: ({
|
|
1713
|
+
text: string;
|
|
1714
|
+
type: "text";
|
|
1715
|
+
} | {
|
|
1716
|
+
data: string;
|
|
1717
|
+
mimeType?: string | undefined;
|
|
1718
|
+
type: "image";
|
|
1719
|
+
})[] | undefined;
|
|
1720
|
+
isError?: boolean | undefined;
|
|
1721
|
+
providerOptions?: {
|
|
1722
|
+
[x: string]: {
|
|
1723
|
+
[x: string]: any;
|
|
1724
|
+
};
|
|
1725
|
+
} | undefined;
|
|
1726
|
+
result: any;
|
|
1727
|
+
toolCallId: string;
|
|
1728
|
+
toolName: string;
|
|
1729
|
+
type: "tool-result";
|
|
1730
|
+
}[];
|
|
1731
|
+
providerOptions?: {
|
|
1732
|
+
[x: string]: {
|
|
1733
|
+
[x: string]: any;
|
|
1734
|
+
};
|
|
1735
|
+
} | undefined;
|
|
1736
|
+
role: "tool";
|
|
1737
|
+
} | {
|
|
1738
|
+
content: string;
|
|
1739
|
+
providerOptions?: {
|
|
1740
|
+
[x: string]: {
|
|
1741
|
+
[x: string]: any;
|
|
1742
|
+
};
|
|
1743
|
+
} | undefined;
|
|
1744
|
+
role: "system";
|
|
1745
|
+
} | undefined;
|
|
1746
|
+
model?: string | undefined;
|
|
1747
|
+
order: number;
|
|
1748
|
+
provider?: string | undefined;
|
|
1749
|
+
providerMetadata?: {
|
|
1750
|
+
[x: string]: {
|
|
1751
|
+
[x: string]: any;
|
|
1752
|
+
};
|
|
1753
|
+
} | undefined;
|
|
1754
|
+
providerOptions?: {
|
|
1755
|
+
[x: string]: {
|
|
1756
|
+
[x: string]: any;
|
|
1757
|
+
};
|
|
1758
|
+
} | undefined;
|
|
1759
|
+
reasoning?: string | undefined;
|
|
1760
|
+
reasoningDetails?: ({
|
|
1761
|
+
signature?: string | undefined;
|
|
1762
|
+
text: string;
|
|
1763
|
+
type: "text";
|
|
1764
|
+
} | {
|
|
1765
|
+
data: string;
|
|
1766
|
+
type: "redacted";
|
|
1767
|
+
})[] | undefined;
|
|
1768
|
+
sources?: {
|
|
1769
|
+
id: string;
|
|
1770
|
+
providerOptions?: {
|
|
1771
|
+
[x: string]: {
|
|
1772
|
+
[x: string]: any;
|
|
1773
|
+
};
|
|
1774
|
+
} | undefined;
|
|
1775
|
+
sourceType: "url";
|
|
1776
|
+
title?: string | undefined;
|
|
1777
|
+
url: string;
|
|
1778
|
+
}[] | undefined;
|
|
1779
|
+
status: "pending" | "success" | "failed";
|
|
1780
|
+
stepOrder: number;
|
|
1781
|
+
text?: string | undefined;
|
|
1782
|
+
threadId: string;
|
|
1783
|
+
tool: boolean;
|
|
1784
|
+
usage?: {
|
|
1785
|
+
completionTokens: number;
|
|
1786
|
+
promptTokens: number;
|
|
1787
|
+
totalTokens: number;
|
|
1788
|
+
} | undefined;
|
|
1789
|
+
userId?: string | undefined;
|
|
1790
|
+
warnings?: ({
|
|
1791
|
+
details?: string | undefined;
|
|
1792
|
+
setting: string;
|
|
1793
|
+
type: "unsupported-setting";
|
|
1794
|
+
} | {
|
|
1795
|
+
details?: string | undefined;
|
|
1796
|
+
tool: any;
|
|
1797
|
+
type: "unsupported-tool";
|
|
1798
|
+
} | {
|
|
1799
|
+
message: string;
|
|
1800
|
+
type: "other";
|
|
1801
|
+
})[] | undefined;
|
|
1802
|
+
};
|
|
1803
|
+
}>;
|
|
1483
1804
|
//# sourceMappingURL=index.d.ts.map
|