@convex-dev/agent 0.0.17-alpha.0 → 0.0.17-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 CHANGED
@@ -7,6 +7,7 @@
7
7
  AI Agent framework built on Convex.
8
8
 
9
9
  - Automatic storage of chat history, per-user or per-thread, that can span multiple agents.
10
+ - Playground UI for testing, debugging, and development. See [playground/README.md](playground/README.md) for more.
10
11
  - RAG for chat context, via hybrid text & vector search, with configuration options.
11
12
  Use the API to query the history yourself and do it your way.
12
13
  - Opt-in search for messages from other threads (for the same specified user).
@@ -385,6 +386,15 @@ await ctx.runMutation(components.agent.threads.updateThread, {
385
386
  });
386
387
  ```
387
388
 
389
+ ## Using the Playground UI
390
+
391
+ The Playground UI is a simple way to test, debug, and develop with the agent.
392
+ - First configure it with instructions [here](./playground/README.md).
393
+ - Then you can use the [hosted version on GitHub pages](https://get-convex.github.io/agent/)
394
+ or run it locally with `npx @convex-dev/agent-playground`.
395
+
396
+ [Playground UI Screenshot](./playground/screenshot.png)
397
+
388
398
  ## Using the Workflow component for long-lived durable workflows
389
399
 
390
400
  The [Workflow component](https://convex.dev/components/workflow) is a great way to build long-lived, durable workflows.
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "email": "support@convex.dev",
8
8
  "url": "https://github.com/get-convex/agent/issues"
9
9
  },
10
- "version": "0.0.17-alpha.0",
10
+ "version": "0.0.17-alpha.2",
11
11
  "license": "Apache-2.0",
12
12
  "keywords": [
13
13
  "convex",
@@ -50,13 +50,6 @@
50
50
  "default": "./dist/commonjs/client/index.js"
51
51
  }
52
52
  },
53
- "./playground": {
54
- "import": {
55
- "@convex-dev/component-source": "./src/client/playground.ts",
56
- "types": "./dist/esm/client/playground.d.ts",
57
- "default": "./dist/esm/client/playground.js"
58
- }
59
- },
60
53
  "./validators": {
61
54
  "import": {
62
55
  "@convex-dev/component-source": "./src/validators.ts",
@@ -1,609 +0,0 @@
1
- import { GenericDataModel, GenericQueryCtx, ApiFromModules } from "convex/server";
2
- import { type AgentComponent, type Agent } from "./index";
3
- import type { ToolSet } from "ai";
4
- export type PlaygroundAPI = ApiFromModules<{
5
- playground: ReturnType<typeof definePlaygroundAPI>;
6
- }>["playground"];
7
- export declare function definePlaygroundAPI(component: AgentComponent, { agents, userNameLookup, }: {
8
- agents: Agent<ToolSet>[];
9
- userNameLookup?: <DataModel extends GenericDataModel>(ctx: GenericQueryCtx<DataModel>, userId: string) => string | Promise<string>;
10
- }): {
11
- isApiKeyValid: import("convex/server").RegisteredQuery<"public", {
12
- apiKey: string;
13
- }, Promise<boolean>>;
14
- listUsers: import("convex/server").RegisteredQuery<"public", {
15
- apiKey: string;
16
- paginationOpts: {
17
- id?: number | undefined;
18
- endCursor?: string | null | undefined;
19
- maximumRowsRead?: number | undefined;
20
- maximumBytesRead?: number | undefined;
21
- numItems: number;
22
- cursor: string | null;
23
- };
24
- }, Promise<{
25
- page: {
26
- _id: string;
27
- name: string;
28
- }[];
29
- continueCursor: string;
30
- isDone: boolean;
31
- pageStatus?: "SplitRecommended" | "SplitRequired" | null | undefined;
32
- splitCursor?: string | null | undefined;
33
- }>>;
34
- listThreads: import("convex/server").RegisteredQuery<"public", {
35
- userId: string;
36
- apiKey: string;
37
- paginationOpts: {
38
- id?: number | undefined;
39
- endCursor?: string | null | undefined;
40
- maximumRowsRead?: number | undefined;
41
- maximumBytesRead?: number | undefined;
42
- numItems: number;
43
- cursor: string | null;
44
- };
45
- }, Promise<{
46
- page: {
47
- latestMessage: string | undefined;
48
- lastMessageAt: number;
49
- _creationTime: number;
50
- _id: string;
51
- status: "active" | "archived";
52
- summary?: string | undefined;
53
- title?: string | undefined;
54
- userId?: string | undefined;
55
- }[];
56
- continueCursor: string;
57
- isDone: boolean;
58
- pageStatus?: "SplitRecommended" | "SplitRequired" | null | undefined;
59
- splitCursor?: string | null | undefined;
60
- }>>;
61
- listMessages: import("convex/server").RegisteredQuery<"public", {
62
- threadId: string;
63
- apiKey: string;
64
- paginationOpts: {
65
- id?: number | undefined;
66
- endCursor?: string | null | undefined;
67
- maximumRowsRead?: number | undefined;
68
- maximumBytesRead?: number | undefined;
69
- numItems: number;
70
- cursor: string | null;
71
- };
72
- }, Promise<{
73
- continueCursor: string;
74
- isDone: boolean;
75
- page: {
76
- _creationTime: number;
77
- _id: string;
78
- agentName?: string | undefined;
79
- embeddingId?: string | string | string | string | string | string | string | string | string | undefined;
80
- error?: string | undefined;
81
- files?: {
82
- data?: (ArrayBuffer | string) | undefined;
83
- fileId?: string | undefined;
84
- mimeType: string;
85
- url?: string | undefined;
86
- }[] | undefined;
87
- finishReason?: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown" | undefined;
88
- id?: string | undefined;
89
- message?: {
90
- content: string | ({
91
- providerOptions?: {
92
- [x: string]: {
93
- [x: string]: any;
94
- };
95
- } | undefined;
96
- text: string;
97
- type: "text";
98
- } | {
99
- image: string | ArrayBuffer;
100
- mimeType?: string | undefined;
101
- providerOptions?: {
102
- [x: string]: {
103
- [x: string]: any;
104
- };
105
- } | undefined;
106
- type: "image";
107
- } | {
108
- data: string | ArrayBuffer;
109
- mimeType: string;
110
- providerOptions?: {
111
- [x: string]: {
112
- [x: string]: any;
113
- };
114
- } | undefined;
115
- type: "file";
116
- })[];
117
- providerOptions?: {
118
- [x: string]: {
119
- [x: string]: any;
120
- };
121
- } | undefined;
122
- role: "user";
123
- } | {
124
- content: string | ({
125
- providerOptions?: {
126
- [x: string]: {
127
- [x: string]: any;
128
- };
129
- } | undefined;
130
- text: string;
131
- type: "text";
132
- } | {
133
- data: string | ArrayBuffer;
134
- mimeType: string;
135
- providerOptions?: {
136
- [x: string]: {
137
- [x: string]: any;
138
- };
139
- } | undefined;
140
- type: "file";
141
- } | {
142
- providerOptions?: {
143
- [x: string]: {
144
- [x: string]: any;
145
- };
146
- } | undefined;
147
- signature?: string | undefined;
148
- text: string;
149
- type: "reasoning";
150
- } | {
151
- data: string;
152
- providerOptions?: {
153
- [x: string]: {
154
- [x: string]: any;
155
- };
156
- } | undefined;
157
- type: "redacted-reasoning";
158
- } | {
159
- args: any;
160
- providerOptions?: {
161
- [x: string]: {
162
- [x: string]: any;
163
- };
164
- } | undefined;
165
- toolCallId: string;
166
- toolName: string;
167
- type: "tool-call";
168
- })[];
169
- providerOptions?: {
170
- [x: string]: {
171
- [x: string]: any;
172
- };
173
- } | undefined;
174
- role: "assistant";
175
- } | {
176
- content: {
177
- args?: any;
178
- experimental_content?: ({
179
- text: string;
180
- type: "text";
181
- } | {
182
- data: string;
183
- mimeType?: string | undefined;
184
- type: "image";
185
- })[] | undefined;
186
- isError?: boolean | undefined;
187
- providerOptions?: {
188
- [x: string]: {
189
- [x: string]: any;
190
- };
191
- } | undefined;
192
- result: any;
193
- toolCallId: string;
194
- toolName: string;
195
- type: "tool-result";
196
- }[];
197
- providerOptions?: {
198
- [x: string]: {
199
- [x: string]: any;
200
- };
201
- } | undefined;
202
- role: "tool";
203
- } | {
204
- content: string;
205
- providerOptions?: {
206
- [x: string]: {
207
- [x: string]: any;
208
- };
209
- } | undefined;
210
- role: "system";
211
- } | undefined;
212
- model?: string | undefined;
213
- order: number;
214
- parentMessageId?: string | undefined;
215
- provider?: string | undefined;
216
- providerMetadata?: {
217
- [x: string]: {
218
- [x: string]: any;
219
- };
220
- } | undefined;
221
- providerOptions?: {
222
- [x: string]: {
223
- [x: string]: any;
224
- };
225
- } | undefined;
226
- reasoning?: string | undefined;
227
- reasoningDetails?: ({
228
- signature?: string | undefined;
229
- text: string;
230
- type: "text";
231
- } | {
232
- data: string;
233
- type: "redacted";
234
- })[] | undefined;
235
- sources?: {
236
- id: string;
237
- providerOptions?: {
238
- [x: string]: {
239
- [x: string]: any;
240
- };
241
- } | undefined;
242
- sourceType: "url";
243
- title?: string | undefined;
244
- url: string;
245
- }[] | undefined;
246
- status: "pending" | "success" | "failed";
247
- stepId?: string | undefined;
248
- stepOrder: number;
249
- text?: string | undefined;
250
- threadId: string;
251
- tool: boolean;
252
- usage?: {
253
- completionTokens: number;
254
- promptTokens: number;
255
- totalTokens: number;
256
- } | undefined;
257
- userId?: string | undefined;
258
- warnings?: ({
259
- details?: string | undefined;
260
- setting: string;
261
- type: "unsupported-setting";
262
- } | {
263
- details?: string | undefined;
264
- tool: any;
265
- type: "unsupported-tool";
266
- } | {
267
- message: string;
268
- type: "other";
269
- })[] | undefined;
270
- }[];
271
- pageStatus?: "SplitRecommended" | "SplitRequired" | null | undefined;
272
- splitCursor?: string | null | undefined;
273
- }>>;
274
- listAgents: import("convex/server").RegisteredQuery<"public", {
275
- apiKey: string;
276
- }, Promise<string[]>>;
277
- createThread: import("convex/server").RegisteredMutation<"public", {
278
- title?: string | undefined;
279
- summary?: string | undefined;
280
- userId: string;
281
- agentName: string;
282
- apiKey: string;
283
- }, Promise<{
284
- threadId: string;
285
- }>>;
286
- generateText: import("convex/server").RegisteredAction<"public", {
287
- messages?: ({
288
- providerOptions?: Record<string, Record<string, any>> | undefined;
289
- role: "user";
290
- content: string | ({
291
- providerOptions?: Record<string, Record<string, any>> | undefined;
292
- type: "text";
293
- text: string;
294
- } | {
295
- providerOptions?: Record<string, Record<string, any>> | undefined;
296
- mimeType?: string | undefined;
297
- type: "image";
298
- image: string | ArrayBuffer;
299
- } | {
300
- providerOptions?: Record<string, Record<string, any>> | undefined;
301
- type: "file";
302
- mimeType: string;
303
- data: string | ArrayBuffer;
304
- })[];
305
- } | {
306
- providerOptions?: Record<string, Record<string, any>> | undefined;
307
- role: "assistant";
308
- content: string | ({
309
- providerOptions?: Record<string, Record<string, any>> | undefined;
310
- type: "text";
311
- text: string;
312
- } | {
313
- providerOptions?: Record<string, Record<string, any>> | undefined;
314
- type: "file";
315
- mimeType: string;
316
- data: string | ArrayBuffer;
317
- } | {
318
- providerOptions?: Record<string, Record<string, any>> | undefined;
319
- signature?: string | undefined;
320
- type: "reasoning";
321
- text: string;
322
- } | {
323
- providerOptions?: Record<string, Record<string, any>> | undefined;
324
- type: "redacted-reasoning";
325
- data: string;
326
- } | {
327
- providerOptions?: Record<string, Record<string, any>> | undefined;
328
- type: "tool-call";
329
- toolCallId: string;
330
- toolName: string;
331
- args: any;
332
- })[];
333
- } | {
334
- providerOptions?: Record<string, Record<string, any>> | undefined;
335
- role: "tool";
336
- content: {
337
- providerOptions?: Record<string, Record<string, any>> | undefined;
338
- args?: any;
339
- experimental_content?: ({
340
- type: "text";
341
- text: string;
342
- } | {
343
- mimeType?: string | undefined;
344
- type: "image";
345
- data: string;
346
- })[] | undefined;
347
- isError?: boolean | undefined;
348
- type: "tool-result";
349
- toolCallId: string;
350
- toolName: string;
351
- result: any;
352
- }[];
353
- } | {
354
- providerOptions?: Record<string, Record<string, any>> | undefined;
355
- role: "system";
356
- content: string;
357
- })[] | undefined;
358
- prompt?: string | undefined;
359
- contextOptions?: {
360
- excludeToolMessages?: boolean | undefined;
361
- recentMessages?: number | undefined;
362
- searchOptions?: {
363
- messageRange?: {
364
- before: number;
365
- after: number;
366
- } | undefined;
367
- textSearch?: boolean | undefined;
368
- vectorSearch?: boolean | undefined;
369
- limit: number;
370
- } | undefined;
371
- searchOtherThreads?: boolean | undefined;
372
- } | undefined;
373
- storageOptions?: {
374
- saveAllInputMessages?: boolean | undefined;
375
- saveAnyInputMessages?: boolean | undefined;
376
- saveOutputMessages?: boolean | undefined;
377
- } | undefined;
378
- userId: string;
379
- threadId: string;
380
- agentName: string;
381
- apiKey: string;
382
- }, Promise<import("ai").GenerateTextResult<ToolSet, never> & import("./index").GenerationOutputMetadata & {
383
- messageId: string;
384
- }>>;
385
- fetchPromptContext: import("convex/server").RegisteredAction<"public", {
386
- userId?: string | undefined;
387
- threadId?: string | undefined;
388
- beforeMessageId?: string | undefined;
389
- messages: ({
390
- providerOptions?: Record<string, Record<string, any>> | undefined;
391
- role: "user";
392
- content: string | ({
393
- providerOptions?: Record<string, Record<string, any>> | undefined;
394
- type: "text";
395
- text: string;
396
- } | {
397
- providerOptions?: Record<string, Record<string, any>> | undefined;
398
- mimeType?: string | undefined;
399
- type: "image";
400
- image: string | ArrayBuffer;
401
- } | {
402
- providerOptions?: Record<string, Record<string, any>> | undefined;
403
- type: "file";
404
- mimeType: string;
405
- data: string | ArrayBuffer;
406
- })[];
407
- } | {
408
- providerOptions?: Record<string, Record<string, any>> | undefined;
409
- role: "assistant";
410
- content: string | ({
411
- providerOptions?: Record<string, Record<string, any>> | undefined;
412
- type: "text";
413
- text: string;
414
- } | {
415
- providerOptions?: Record<string, Record<string, any>> | undefined;
416
- type: "file";
417
- mimeType: string;
418
- data: string | ArrayBuffer;
419
- } | {
420
- providerOptions?: Record<string, Record<string, any>> | undefined;
421
- signature?: string | undefined;
422
- type: "reasoning";
423
- text: string;
424
- } | {
425
- providerOptions?: Record<string, Record<string, any>> | undefined;
426
- type: "redacted-reasoning";
427
- data: string;
428
- } | {
429
- providerOptions?: Record<string, Record<string, any>> | undefined;
430
- type: "tool-call";
431
- toolCallId: string;
432
- toolName: string;
433
- args: any;
434
- })[];
435
- } | {
436
- providerOptions?: Record<string, Record<string, any>> | undefined;
437
- role: "tool";
438
- content: {
439
- providerOptions?: Record<string, Record<string, any>> | undefined;
440
- args?: any;
441
- experimental_content?: ({
442
- type: "text";
443
- text: string;
444
- } | {
445
- mimeType?: string | undefined;
446
- type: "image";
447
- data: string;
448
- })[] | undefined;
449
- isError?: boolean | undefined;
450
- type: "tool-result";
451
- toolCallId: string;
452
- toolName: string;
453
- result: any;
454
- }[];
455
- } | {
456
- providerOptions?: Record<string, Record<string, any>> | undefined;
457
- role: "system";
458
- content: string;
459
- })[];
460
- agentName: string;
461
- contextOptions: {
462
- excludeToolMessages?: boolean | undefined;
463
- recentMessages?: number | undefined;
464
- searchOptions?: {
465
- messageRange?: {
466
- before: number;
467
- after: number;
468
- } | undefined;
469
- textSearch?: boolean | undefined;
470
- vectorSearch?: boolean | undefined;
471
- limit: number;
472
- } | undefined;
473
- searchOtherThreads?: boolean | undefined;
474
- };
475
- apiKey: string;
476
- }, Promise<{
477
- id?: string | undefined;
478
- userId?: string | undefined;
479
- parentMessageId?: string | undefined;
480
- stepId?: string | undefined;
481
- embeddingId?: string | undefined;
482
- error?: string | undefined;
483
- agentName?: string | undefined;
484
- model?: string | undefined;
485
- provider?: string | undefined;
486
- providerOptions?: Record<string, Record<string, any>> | undefined;
487
- message?: {
488
- providerOptions?: Record<string, Record<string, any>> | undefined;
489
- role: "user";
490
- content: string | ({
491
- providerOptions?: Record<string, Record<string, any>> | undefined;
492
- type: "text";
493
- text: string;
494
- } | {
495
- providerOptions?: Record<string, Record<string, any>> | undefined;
496
- mimeType?: string | undefined;
497
- type: "image";
498
- image: string | ArrayBuffer;
499
- } | {
500
- providerOptions?: Record<string, Record<string, any>> | undefined;
501
- type: "file";
502
- mimeType: string;
503
- data: string | ArrayBuffer;
504
- })[];
505
- } | {
506
- providerOptions?: Record<string, Record<string, any>> | undefined;
507
- role: "assistant";
508
- content: string | ({
509
- providerOptions?: Record<string, Record<string, any>> | undefined;
510
- type: "text";
511
- text: string;
512
- } | {
513
- providerOptions?: Record<string, Record<string, any>> | undefined;
514
- type: "file";
515
- mimeType: string;
516
- data: string | ArrayBuffer;
517
- } | {
518
- providerOptions?: Record<string, Record<string, any>> | undefined;
519
- signature?: string | undefined;
520
- type: "reasoning";
521
- text: string;
522
- } | {
523
- providerOptions?: Record<string, Record<string, any>> | undefined;
524
- type: "redacted-reasoning";
525
- data: string;
526
- } | {
527
- providerOptions?: Record<string, Record<string, any>> | undefined;
528
- type: "tool-call";
529
- toolCallId: string;
530
- toolName: string;
531
- args: any;
532
- })[];
533
- } | {
534
- providerOptions?: Record<string, Record<string, any>> | undefined;
535
- role: "tool";
536
- content: {
537
- providerOptions?: Record<string, Record<string, any>> | undefined;
538
- args?: any;
539
- experimental_content?: ({
540
- type: "text";
541
- text: string;
542
- } | {
543
- mimeType?: string | undefined;
544
- type: "image";
545
- data: string;
546
- })[] | undefined;
547
- isError?: boolean | undefined;
548
- type: "tool-result";
549
- toolCallId: string;
550
- toolName: string;
551
- result: any;
552
- }[];
553
- } | {
554
- providerOptions?: Record<string, Record<string, any>> | undefined;
555
- role: "system";
556
- content: string;
557
- } | undefined;
558
- text?: string | undefined;
559
- reasoning?: string | undefined;
560
- files?: {
561
- bytes?: ArrayBuffer | undefined;
562
- url?: string | undefined;
563
- fileId?: string | undefined;
564
- mimeType: string;
565
- }[] | undefined;
566
- usage?: {
567
- promptTokens: number;
568
- completionTokens: number;
569
- totalTokens: number;
570
- } | undefined;
571
- providerMetadata?: Record<string, Record<string, any>> | undefined;
572
- sources?: {
573
- title?: string | undefined;
574
- providerOptions?: Record<string, Record<string, any>> | undefined;
575
- id: string;
576
- url: string;
577
- sourceType: "url";
578
- }[] | undefined;
579
- reasoningDetails?: ({
580
- signature?: string | undefined;
581
- type: "text";
582
- text: string;
583
- } | {
584
- type: "redacted";
585
- data: string;
586
- })[] | undefined;
587
- warnings?: ({
588
- details?: string | undefined;
589
- type: "unsupported-setting";
590
- setting: string;
591
- } | {
592
- details?: string | undefined;
593
- type: "unsupported-tool";
594
- tool: any;
595
- } | {
596
- type: "other";
597
- message: string;
598
- })[] | undefined;
599
- finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
600
- status: "pending" | "success" | "failed";
601
- order: number;
602
- _creationTime: number;
603
- threadId: string;
604
- stepOrder: number;
605
- tool: boolean;
606
- _id: string;
607
- }[]>>;
608
- };
609
- //# sourceMappingURL=playground.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../src/client/playground.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAOL,KAAK,cAAc,EACnB,KAAK,KAAK,EACX,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAGlC,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;IACzC,UAAU,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;CACpD,CAAC,CAAC,YAAY,CAAC,CAAC;AAGjB,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,cAAc,EACzB,EACE,MAAM,EACN,cAAc,GACf,EAAE;IACD,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;IACzB,cAAc,CAAC,EAAE,CAAC,SAAS,SAAS,gBAAgB,EAClD,GAAG,EAAE,eAAe,CAAC,SAAS,CAAC,EAC/B,MAAM,EAAE,MAAM,KACX,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwNF"}