@convex-dev/agent 0.1.18-alpha.1 → 0.5.0-alpha.1
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 +30 -9
- package/dist/client/createTool.d.ts.map +1 -1
- package/dist/client/createTool.js +24 -9
- package/dist/client/createTool.js.map +1 -1
- package/dist/client/definePlaygroundAPI.d.ts +174 -199
- package/dist/client/definePlaygroundAPI.d.ts.map +1 -1
- package/dist/client/definePlaygroundAPI.js +12 -19
- package/dist/client/definePlaygroundAPI.js.map +1 -1
- package/dist/client/files.js +4 -4
- package/dist/client/files.js.map +1 -1
- package/dist/client/index.d.ts +166 -63
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +75 -45
- package/dist/client/index.js.map +1 -1
- package/dist/client/search.d.ts +27 -6
- package/dist/client/search.d.ts.map +1 -1
- 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/types.d.ts +27 -41
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +436 -73
- package/dist/component/messages.d.ts +246 -43
- package/dist/component/messages.d.ts.map +1 -1
- package/dist/component/messages.js +2 -2
- package/dist/component/messages.js.map +1 -1
- package/dist/component/schema.d.ts +1453 -152
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +2 -2
- 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 +12 -14
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +187 -47
- 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/optimisticallySendMessage.d.ts.map +1 -1
- package/dist/react/optimisticallySendMessage.js +2 -1
- package/dist/react/optimisticallySendMessage.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 +1798 -259
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +79 -15
- package/dist/validators.js.map +1 -1
- package/package.json +2 -2
- package/src/client/createTool.ts +68 -37
- package/src/client/definePlaygroundAPI.ts +24 -25
- package/src/client/files.ts +4 -4
- package/src/client/index.test.ts +14 -12
- package/src/client/index.ts +134 -94
- package/src/client/search.ts +3 -2
- package/src/client/streaming.ts +4 -3
- package/src/client/types.ts +34 -70
- package/src/component/_generated/api.d.ts +436 -73
- package/src/component/messages.ts +2 -2
- package/src/component/schema.ts +2 -2
- package/src/mapping.ts +228 -75
- package/src/react/deltas.ts +165 -52
- package/src/react/optimisticallySendMessage.ts +4 -1
- package/src/react/toUIMessages.test.ts +154 -36
- package/src/react/toUIMessages.ts +136 -57
- package/src/validators.test.ts +2 -99
- package/src/validators.ts +95 -17
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Schema, Tool,
|
|
1
|
+
import type { Schema, Tool, ToolCallOptions, ToolSet } from "ai";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import type { Agent } from "./index.js";
|
|
4
4
|
import type { GenericActionCtx, GenericDataModel } from "convex/server";
|
|
5
|
+
import type { ProviderOptions } from "../validators.js";
|
|
5
6
|
export type ToolCtx<DataModel extends GenericDataModel = GenericDataModel> = GenericActionCtx<DataModel> & {
|
|
6
7
|
agent: Agent;
|
|
7
8
|
userId?: string;
|
|
@@ -15,7 +16,7 @@ export type ToolCtx<DataModel extends GenericDataModel = GenericDataModel> = Gen
|
|
|
15
16
|
* but swap parameters for args and handler for execute.
|
|
16
17
|
* @returns A tool to be used with the AI SDK.
|
|
17
18
|
*/
|
|
18
|
-
export declare function createTool<
|
|
19
|
+
export declare function createTool<INPUT, OUTPUT, Ctx extends ToolCtx = ToolCtx>(def: {
|
|
19
20
|
/**
|
|
20
21
|
An optional description of what the tool does.
|
|
21
22
|
Will be used by the language model to decide whether to use the tool.
|
|
@@ -27,7 +28,7 @@ export declare function createTool<PARAMETERS extends ToolParameters, RESULT, Ct
|
|
|
27
28
|
It is also used to validate the output of the language model.
|
|
28
29
|
Use descriptions to make the input understandable for the language model.
|
|
29
30
|
*/
|
|
30
|
-
args:
|
|
31
|
+
args: ToolParameters<INPUT>;
|
|
31
32
|
/**
|
|
32
33
|
An async function that is called with the arguments from the tool call and produces a result.
|
|
33
34
|
If not provided, the tool will not be executed automatically.
|
|
@@ -35,13 +36,33 @@ export declare function createTool<PARAMETERS extends ToolParameters, RESULT, Ct
|
|
|
35
36
|
@args is the input of the tool call.
|
|
36
37
|
@options.abortSignal is a signal that can be used to abort the tool call.
|
|
37
38
|
*/
|
|
38
|
-
handler: (ctx: Ctx, args:
|
|
39
|
+
handler: (ctx: Ctx, args: INPUT, options: ToolCallOptions) => PromiseLike<OUTPUT>;
|
|
40
|
+
/**
|
|
41
|
+
* Provide the context to use, e.g. when defining the tool at runtime.
|
|
42
|
+
*/
|
|
39
43
|
ctx?: Ctx;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Optional function that is called when the argument streaming starts.
|
|
46
|
+
* Only called when the tool is used in a streaming context.
|
|
47
|
+
*/
|
|
48
|
+
onInputStart?: (ctx: Ctx, options: ToolCallOptions) => void | PromiseLike<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Optional function that is called when an argument streaming delta is available.
|
|
51
|
+
* Only called when the tool is used in a streaming context.
|
|
52
|
+
*/
|
|
53
|
+
onInputDelta?: (ctx: Ctx, options: {
|
|
54
|
+
inputTextDelta: string;
|
|
55
|
+
} & ToolCallOptions) => void | PromiseLike<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Optional function that is called when a tool call can be started,
|
|
58
|
+
* even if the execute function is not provided.
|
|
59
|
+
*/
|
|
60
|
+
onInputAvailable?: (ctx: Ctx, options: {
|
|
61
|
+
input: [INPUT] extends [never] ? undefined : INPUT;
|
|
62
|
+
} & ToolCallOptions) => void | PromiseLike<void>;
|
|
63
|
+
providerOptions?: ProviderOptions;
|
|
64
|
+
}): Tool<INPUT, OUTPUT>;
|
|
43
65
|
export declare function wrapTools(ctx: ToolCtx, ...toolSets: (ToolSet | undefined)[]): ToolSet;
|
|
44
|
-
type ToolParameters = z.
|
|
45
|
-
type inferParameters<PARAMETERS extends ToolParameters> = PARAMETERS extends Schema<any> ? PARAMETERS["_type"] : PARAMETERS extends z.ZodTypeAny ? z.infer<PARAMETERS> : never;
|
|
66
|
+
type ToolParameters<T> = z.Schema<T> | Schema<T>;
|
|
46
67
|
export {};
|
|
47
68
|
//# sourceMappingURL=createTool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTool.d.ts","sourceRoot":"","sources":["../../src/client/createTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"createTool.d.ts","sourceRoot":"","sources":["../../src/client/createTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAEjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,MAAM,OAAO,CAAC,SAAS,SAAS,gBAAgB,GAAG,gBAAgB,IACvE,gBAAgB,CAAC,SAAS,CAAC,GAAG;IAC5B,KAAK,EAAE,KAA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,GAAG,QAAQ,EAAE,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE,GACnC,OAAO,CAiBT;AAGD,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -7,22 +7,37 @@ import { z } from "zod";
|
|
|
7
7
|
* but swap parameters for args and handler for execute.
|
|
8
8
|
* @returns A tool to be used with the AI SDK.
|
|
9
9
|
*/
|
|
10
|
-
export function createTool(
|
|
11
|
-
const
|
|
10
|
+
export function createTool(def) {
|
|
11
|
+
const t = tool({
|
|
12
|
+
type: "function",
|
|
12
13
|
__acceptsCtx: true,
|
|
13
|
-
ctx:
|
|
14
|
-
description:
|
|
15
|
-
|
|
14
|
+
ctx: def.ctx,
|
|
15
|
+
description: def.description,
|
|
16
|
+
inputSchema: def.args,
|
|
16
17
|
async execute(args, options) {
|
|
17
|
-
if (!this
|
|
18
|
+
if (!getCtx(this)) {
|
|
18
19
|
throw new Error("To use a Convex tool, you must either provide the ctx" +
|
|
19
20
|
" at definition time (dynamically in an action), or use the Agent to" +
|
|
20
21
|
" call it (which injects the ctx, userId and threadId)");
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
+
return def.handler(getCtx(this), args, options);
|
|
23
24
|
},
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
providerOptions: def.providerOptions,
|
|
26
|
+
});
|
|
27
|
+
if (def.onInputStart) {
|
|
28
|
+
t.onInputStart = def.onInputStart.bind(t, getCtx(t));
|
|
29
|
+
}
|
|
30
|
+
if (def.onInputDelta) {
|
|
31
|
+
t.onInputDelta = def.onInputDelta.bind(t, getCtx(t));
|
|
32
|
+
}
|
|
33
|
+
if (def.onInputAvailable) {
|
|
34
|
+
t.onInputAvailable = def.onInputAvailable.bind(t, getCtx(t));
|
|
35
|
+
}
|
|
36
|
+
return t;
|
|
37
|
+
}
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
function getCtx(tool) {
|
|
40
|
+
return tool.ctx;
|
|
26
41
|
}
|
|
27
42
|
export function wrapTools(ctx, ...toolSets) {
|
|
28
43
|
const output = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTool.js","sourceRoot":"","sources":["../../src/client/createTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"createTool.js","sourceRoot":"","sources":["../../src/client/createTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAA+C,GA4DxE;IACC,MAAM,CAAC,GAAG,IAAI,CAAC;QACb,IAAI,EAAE,UAAU;QAChB,YAAY,EAAE,IAAI;QAClB,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,WAAW,EAAE,GAAG,CAAC,IAAI;QACrB,KAAK,CAAC,OAAO,CAAC,IAAW,EAAE,OAAwB;YACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBAClB,MAAM,IAAI,KAAK,CACb,uDAAuD;oBACrD,qEAAqE;oBACrE,uDAAuD,CAC1D,CAAC;YACJ,CAAC;YACD,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC;QACD,eAAe,EAAE,GAAG,CAAC,eAAe;KACrC,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;QACrB,CAAC,CAAC,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAA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ionCtx, type GenericDataModel, type GenericQueryCtx } from "convex/server";
|
|
2
|
+
import { type Agent, type AgentComponent } from "./index.js";
|
|
3
3
|
export type PlaygroundAPI = ApiFromModules<{
|
|
4
4
|
playground: ReturnType<typeof definePlaygroundAPI>;
|
|
5
5
|
}>["playground"];
|
|
@@ -73,203 +73,153 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
73
73
|
numItems: number;
|
|
74
74
|
cursor: string | null;
|
|
75
75
|
};
|
|
76
|
-
}, Promise<{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
} | undefined;
|
|
95
|
-
text: string;
|
|
96
|
-
type: "text";
|
|
97
|
-
} | {
|
|
98
|
-
image: string | ArrayBuffer;
|
|
99
|
-
mimeType?: string | undefined;
|
|
100
|
-
providerOptions?: {
|
|
101
|
-
[x: string]: {
|
|
102
|
-
[x: string]: any;
|
|
103
|
-
};
|
|
104
|
-
} | undefined;
|
|
105
|
-
type: "image";
|
|
106
|
-
} | {
|
|
107
|
-
data: string | ArrayBuffer;
|
|
108
|
-
filename?: string | undefined;
|
|
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";
|
|
76
|
+
}, Promise<import("convex/server").PaginationResult<{
|
|
77
|
+
id?: string | undefined;
|
|
78
|
+
userId?: string | undefined;
|
|
79
|
+
embeddingId?: string | undefined;
|
|
80
|
+
fileIds?: string[] | undefined;
|
|
81
|
+
error?: string | undefined;
|
|
82
|
+
agentName?: string | undefined;
|
|
83
|
+
model?: string | undefined;
|
|
84
|
+
provider?: string | undefined;
|
|
85
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
86
|
+
message?: {
|
|
87
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
88
|
+
role: "user";
|
|
89
|
+
content: string | ({
|
|
90
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
91
|
+
type: "text";
|
|
92
|
+
text: string;
|
|
123
93
|
} | {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
};
|
|
129
|
-
} | undefined;
|
|
130
|
-
text: string;
|
|
131
|
-
type: "text";
|
|
132
|
-
} | {
|
|
133
|
-
data: string | ArrayBuffer;
|
|
134
|
-
filename?: string | undefined;
|
|
135
|
-
mimeType: string;
|
|
136
|
-
providerOptions?: {
|
|
137
|
-
[x: string]: {
|
|
138
|
-
[x: string]: any;
|
|
139
|
-
};
|
|
140
|
-
} | undefined;
|
|
141
|
-
type: "file";
|
|
142
|
-
} | {
|
|
143
|
-
providerOptions?: {
|
|
144
|
-
[x: string]: {
|
|
145
|
-
[x: string]: any;
|
|
146
|
-
};
|
|
147
|
-
} | undefined;
|
|
148
|
-
signature?: string | undefined;
|
|
149
|
-
text: string;
|
|
150
|
-
type: "reasoning";
|
|
151
|
-
} | {
|
|
152
|
-
data: string;
|
|
153
|
-
providerOptions?: {
|
|
154
|
-
[x: string]: {
|
|
155
|
-
[x: string]: any;
|
|
156
|
-
};
|
|
157
|
-
} | undefined;
|
|
158
|
-
type: "redacted-reasoning";
|
|
159
|
-
} | {
|
|
160
|
-
args: any;
|
|
161
|
-
providerOptions?: {
|
|
162
|
-
[x: string]: {
|
|
163
|
-
[x: string]: any;
|
|
164
|
-
};
|
|
165
|
-
} | undefined;
|
|
166
|
-
toolCallId: string;
|
|
167
|
-
toolName: string;
|
|
168
|
-
type: "tool-call";
|
|
169
|
-
})[];
|
|
170
|
-
providerOptions?: {
|
|
171
|
-
[x: string]: {
|
|
172
|
-
[x: string]: any;
|
|
173
|
-
};
|
|
174
|
-
} | undefined;
|
|
175
|
-
role: "assistant";
|
|
94
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
95
|
+
mimeType?: string | undefined;
|
|
96
|
+
type: "image";
|
|
97
|
+
image: string | ArrayBuffer;
|
|
176
98
|
} | {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
[x: string]: any;
|
|
191
|
-
};
|
|
192
|
-
} | undefined;
|
|
193
|
-
result: any;
|
|
194
|
-
toolCallId: string;
|
|
195
|
-
toolName: string;
|
|
196
|
-
type: "tool-result";
|
|
197
|
-
}[];
|
|
198
|
-
providerOptions?: {
|
|
199
|
-
[x: string]: {
|
|
200
|
-
[x: string]: any;
|
|
201
|
-
};
|
|
202
|
-
} | undefined;
|
|
203
|
-
role: "tool";
|
|
99
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
100
|
+
filename?: string | undefined;
|
|
101
|
+
type: "file";
|
|
102
|
+
mimeType: string;
|
|
103
|
+
data: string | ArrayBuffer;
|
|
104
|
+
})[];
|
|
105
|
+
} | {
|
|
106
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
107
|
+
role: "assistant";
|
|
108
|
+
content: string | ({
|
|
109
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
110
|
+
type: "text";
|
|
111
|
+
text: string;
|
|
204
112
|
} | {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
} | undefined;
|
|
213
|
-
model?: string | undefined;
|
|
214
|
-
order: number;
|
|
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?: ({
|
|
113
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
114
|
+
filename?: string | undefined;
|
|
115
|
+
type: "file";
|
|
116
|
+
mimeType: string;
|
|
117
|
+
data: string | ArrayBuffer;
|
|
118
|
+
} | {
|
|
119
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
228
120
|
signature?: string | undefined;
|
|
121
|
+
state?: "streaming" | "done" | undefined;
|
|
122
|
+
type: "reasoning";
|
|
229
123
|
text: string;
|
|
230
|
-
type: "text";
|
|
231
124
|
} | {
|
|
125
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
126
|
+
type: "redacted-reasoning";
|
|
232
127
|
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
|
-
stepOrder: number;
|
|
248
|
-
text?: string | undefined;
|
|
249
|
-
threadId: string;
|
|
250
|
-
tool: boolean;
|
|
251
|
-
usage?: {
|
|
252
|
-
completionTokens: number;
|
|
253
|
-
promptTokens: number;
|
|
254
|
-
totalTokens: number;
|
|
255
|
-
} | undefined;
|
|
256
|
-
userId?: string | undefined;
|
|
257
|
-
warnings?: ({
|
|
258
|
-
details?: string | undefined;
|
|
259
|
-
setting: string;
|
|
260
|
-
type: "unsupported-setting";
|
|
261
|
-
} | {
|
|
262
|
-
details?: string | undefined;
|
|
263
|
-
tool: any;
|
|
264
|
-
type: "unsupported-tool";
|
|
265
128
|
} | {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
129
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
130
|
+
providerExecuted?: boolean | undefined;
|
|
131
|
+
type: "tool-call";
|
|
132
|
+
toolCallId: string;
|
|
133
|
+
toolName: string;
|
|
134
|
+
args: any;
|
|
135
|
+
})[];
|
|
136
|
+
} | {
|
|
137
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
138
|
+
role: "tool";
|
|
139
|
+
content: {
|
|
140
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
141
|
+
args?: any;
|
|
142
|
+
providerExecuted?: boolean | undefined;
|
|
143
|
+
isError?: boolean | undefined;
|
|
144
|
+
experimental_content?: ({
|
|
145
|
+
type: "text";
|
|
146
|
+
text: string;
|
|
147
|
+
} | {
|
|
148
|
+
mimeType?: string | undefined;
|
|
149
|
+
type: "image";
|
|
150
|
+
data: string;
|
|
151
|
+
})[] | undefined;
|
|
152
|
+
type: "tool-result";
|
|
153
|
+
toolCallId: string;
|
|
154
|
+
toolName: string;
|
|
155
|
+
result: any;
|
|
156
|
+
}[];
|
|
157
|
+
} | {
|
|
158
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
159
|
+
role: "system";
|
|
160
|
+
content: string;
|
|
161
|
+
} | undefined;
|
|
162
|
+
text?: string | undefined;
|
|
163
|
+
reasoning?: string | undefined;
|
|
164
|
+
usage?: {
|
|
165
|
+
reasoningTokens?: number | undefined;
|
|
166
|
+
cachedInputTokens?: number | undefined;
|
|
167
|
+
promptTokens: number;
|
|
168
|
+
completionTokens: number;
|
|
169
|
+
totalTokens: number;
|
|
170
|
+
} | undefined;
|
|
171
|
+
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
172
|
+
sources?: ({
|
|
173
|
+
title?: string | undefined;
|
|
174
|
+
type?: "source" | undefined;
|
|
175
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
176
|
+
url?: string | undefined;
|
|
177
|
+
id: string;
|
|
178
|
+
sourceType: "url";
|
|
179
|
+
} | {
|
|
180
|
+
filename?: string | undefined;
|
|
181
|
+
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
182
|
+
id: string;
|
|
183
|
+
title: string;
|
|
184
|
+
type: "source";
|
|
185
|
+
sourceType: "document";
|
|
186
|
+
mediaType: string;
|
|
187
|
+
})[] | undefined;
|
|
188
|
+
reasoningDetails?: ({
|
|
189
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
190
|
+
signature?: string | undefined;
|
|
191
|
+
state?: "streaming" | "done" | undefined;
|
|
192
|
+
type: "reasoning";
|
|
193
|
+
text: string;
|
|
194
|
+
} | {
|
|
195
|
+
signature?: string | undefined;
|
|
196
|
+
type: "text";
|
|
197
|
+
text: string;
|
|
198
|
+
} | {
|
|
199
|
+
type: "redacted";
|
|
200
|
+
data: string;
|
|
201
|
+
})[] | undefined;
|
|
202
|
+
warnings?: ({
|
|
203
|
+
details?: string | undefined;
|
|
204
|
+
type: "unsupported-setting";
|
|
205
|
+
setting: string;
|
|
206
|
+
} | {
|
|
207
|
+
details?: string | undefined;
|
|
208
|
+
type: "unsupported-tool";
|
|
209
|
+
tool: any;
|
|
210
|
+
} | {
|
|
211
|
+
type: "other";
|
|
212
|
+
message: string;
|
|
213
|
+
})[] | undefined;
|
|
214
|
+
finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
|
|
215
|
+
_id: string;
|
|
216
|
+
_creationTime: number;
|
|
217
|
+
status: "pending" | "success" | "failed";
|
|
218
|
+
order: number;
|
|
219
|
+
threadId: string;
|
|
220
|
+
stepOrder: number;
|
|
221
|
+
tool: boolean;
|
|
222
|
+
}>>>;
|
|
273
223
|
listAgents: import("convex/server").RegisteredQuery<"public", {
|
|
274
224
|
userId?: string | undefined;
|
|
275
225
|
threadId?: string | undefined;
|
|
@@ -279,7 +229,6 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
279
229
|
instructions: string | undefined;
|
|
280
230
|
contextOptions: import("./types.js").ContextOptions | undefined;
|
|
281
231
|
storageOptions: import("./types.js").StorageOptions | undefined;
|
|
282
|
-
maxSteps: number | undefined;
|
|
283
232
|
maxRetries: number | undefined;
|
|
284
233
|
tools: string[];
|
|
285
234
|
}[]>>;
|
|
@@ -329,6 +278,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
329
278
|
} | {
|
|
330
279
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
331
280
|
signature?: string | undefined;
|
|
281
|
+
state?: "streaming" | "done" | undefined;
|
|
332
282
|
type: "reasoning";
|
|
333
283
|
text: string;
|
|
334
284
|
} | {
|
|
@@ -337,6 +287,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
337
287
|
data: string;
|
|
338
288
|
} | {
|
|
339
289
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
290
|
+
providerExecuted?: boolean | undefined;
|
|
340
291
|
type: "tool-call";
|
|
341
292
|
toolCallId: string;
|
|
342
293
|
toolName: string;
|
|
@@ -348,6 +299,8 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
348
299
|
content: {
|
|
349
300
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
350
301
|
args?: any;
|
|
302
|
+
providerExecuted?: boolean | undefined;
|
|
303
|
+
isError?: boolean | undefined;
|
|
351
304
|
experimental_content?: ({
|
|
352
305
|
type: "text";
|
|
353
306
|
text: string;
|
|
@@ -356,7 +309,6 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
356
309
|
type: "image";
|
|
357
310
|
data: string;
|
|
358
311
|
})[] | undefined;
|
|
359
|
-
isError?: boolean | undefined;
|
|
360
312
|
type: "tool-result";
|
|
361
313
|
toolCallId: string;
|
|
362
314
|
toolName: string;
|
|
@@ -391,7 +343,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
391
343
|
agentName: string;
|
|
392
344
|
apiKey: string;
|
|
393
345
|
}, Promise<{
|
|
394
|
-
messageId: string;
|
|
346
|
+
messageId: string | undefined;
|
|
395
347
|
text: string;
|
|
396
348
|
}>>;
|
|
397
349
|
fetchPromptContext: import("convex/server").RegisteredAction<"public", {
|
|
@@ -434,6 +386,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
434
386
|
} | {
|
|
435
387
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
436
388
|
signature?: string | undefined;
|
|
389
|
+
state?: "streaming" | "done" | undefined;
|
|
437
390
|
type: "reasoning";
|
|
438
391
|
text: string;
|
|
439
392
|
} | {
|
|
@@ -442,6 +395,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
442
395
|
data: string;
|
|
443
396
|
} | {
|
|
444
397
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
398
|
+
providerExecuted?: boolean | undefined;
|
|
445
399
|
type: "tool-call";
|
|
446
400
|
toolCallId: string;
|
|
447
401
|
toolName: string;
|
|
@@ -453,6 +407,8 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
453
407
|
content: {
|
|
454
408
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
455
409
|
args?: any;
|
|
410
|
+
providerExecuted?: boolean | undefined;
|
|
411
|
+
isError?: boolean | undefined;
|
|
456
412
|
experimental_content?: ({
|
|
457
413
|
type: "text";
|
|
458
414
|
text: string;
|
|
@@ -461,7 +417,6 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
461
417
|
type: "image";
|
|
462
418
|
data: string;
|
|
463
419
|
})[] | undefined;
|
|
464
|
-
isError?: boolean | undefined;
|
|
465
420
|
type: "tool-result";
|
|
466
421
|
toolCallId: string;
|
|
467
422
|
toolName: string;
|
|
@@ -533,6 +488,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
533
488
|
} | {
|
|
534
489
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
535
490
|
signature?: string | undefined;
|
|
491
|
+
state?: "streaming" | "done" | undefined;
|
|
536
492
|
type: "reasoning";
|
|
537
493
|
text: string;
|
|
538
494
|
} | {
|
|
@@ -541,6 +497,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
541
497
|
data: string;
|
|
542
498
|
} | {
|
|
543
499
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
500
|
+
providerExecuted?: boolean | undefined;
|
|
544
501
|
type: "tool-call";
|
|
545
502
|
toolCallId: string;
|
|
546
503
|
toolName: string;
|
|
@@ -552,6 +509,8 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
552
509
|
content: {
|
|
553
510
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
554
511
|
args?: any;
|
|
512
|
+
providerExecuted?: boolean | undefined;
|
|
513
|
+
isError?: boolean | undefined;
|
|
555
514
|
experimental_content?: ({
|
|
556
515
|
type: "text";
|
|
557
516
|
text: string;
|
|
@@ -560,7 +519,6 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
560
519
|
type: "image";
|
|
561
520
|
data: string;
|
|
562
521
|
})[] | undefined;
|
|
563
|
-
isError?: boolean | undefined;
|
|
564
522
|
type: "tool-result";
|
|
565
523
|
toolCallId: string;
|
|
566
524
|
toolName: string;
|
|
@@ -574,19 +532,36 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
|
|
|
574
532
|
text?: string | undefined;
|
|
575
533
|
reasoning?: string | undefined;
|
|
576
534
|
usage?: {
|
|
535
|
+
reasoningTokens?: number | undefined;
|
|
536
|
+
cachedInputTokens?: number | undefined;
|
|
577
537
|
promptTokens: number;
|
|
578
538
|
completionTokens: number;
|
|
579
539
|
totalTokens: number;
|
|
580
540
|
} | undefined;
|
|
581
541
|
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
582
|
-
sources?: {
|
|
542
|
+
sources?: ({
|
|
583
543
|
title?: string | undefined;
|
|
544
|
+
type?: "source" | undefined;
|
|
584
545
|
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
546
|
+
url?: string | undefined;
|
|
585
547
|
id: string;
|
|
586
548
|
sourceType: "url";
|
|
587
|
-
|
|
588
|
-
|
|
549
|
+
} | {
|
|
550
|
+
filename?: string | undefined;
|
|
551
|
+
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
552
|
+
id: string;
|
|
553
|
+
title: string;
|
|
554
|
+
type: "source";
|
|
555
|
+
sourceType: "document";
|
|
556
|
+
mediaType: string;
|
|
557
|
+
})[] | undefined;
|
|
589
558
|
reasoningDetails?: ({
|
|
559
|
+
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
560
|
+
signature?: string | undefined;
|
|
561
|
+
state?: "streaming" | "done" | undefined;
|
|
562
|
+
type: "reasoning";
|
|
563
|
+
text: string;
|
|
564
|
+
} | {
|
|
590
565
|
signature?: string | undefined;
|
|
591
566
|
type: "text";
|
|
592
567
|
text: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definePlaygroundAPI.d.ts","sourceRoot":"","sources":["../../src/client/definePlaygroundAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,
|
|
1
|
+
{"version":3,"file":"definePlaygroundAPI.d.ts","sourceRoot":"","sources":["../../src/client/definePlaygroundAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK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