@workglow/ai 0.0.116 → 0.0.118
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/browser.js +1145 -393
- package/dist/browser.js.map +13 -9
- package/dist/bun.js +1145 -393
- package/dist/bun.js.map +13 -9
- package/dist/node.js +1145 -393
- package/dist/node.js.map +13 -9
- package/dist/task/AgentTask.d.ts +524 -0
- package/dist/task/AgentTask.d.ts.map +1 -0
- package/dist/task/AgentTypes.d.ts +181 -0
- package/dist/task/AgentTypes.d.ts.map +1 -0
- package/dist/task/AgentUtils.d.ts +50 -0
- package/dist/task/AgentUtils.d.ts.map +1 -0
- package/dist/task/ChunkRetrievalTask.d.ts +2 -2
- package/dist/task/ChunkVectorSearchTask.d.ts +2 -2
- package/dist/task/ChunkVectorUpsertTask.d.ts +1 -1
- package/dist/task/HierarchicalChunkerTask.d.ts +2 -2
- package/dist/task/HierarchyJoinTask.d.ts +1 -1
- package/dist/task/MessageConversion.d.ts +52 -0
- package/dist/task/MessageConversion.d.ts.map +1 -0
- package/dist/task/QueryExpanderTask.d.ts +1 -1
- package/dist/task/RerankerTask.d.ts +1 -1
- package/dist/task/ToolCallingTask.d.ts +152 -25
- package/dist/task/ToolCallingTask.d.ts.map +1 -1
- package/dist/task/VectorSimilarityTask.d.ts +1 -1
- package/dist/task/VectorSimilarityTask.d.ts.map +1 -1
- package/dist/task/index.d.ts +6 -1
- package/dist/task/index.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { CreateWorkflow, Task, type IExecuteContext, type StreamEvent, type TaskConfig } from "@workglow/task-graph";
|
|
7
|
+
import type { AgentHooks, ChatMessage, UserContentBlock } from "./AgentTypes";
|
|
8
|
+
import type { ToolDefinition } from "./ToolCallingTask";
|
|
9
|
+
export interface AgentTaskConfig extends TaskConfig {
|
|
10
|
+
/** Lifecycle hooks for intercepting the agent loop. */
|
|
11
|
+
readonly hooks?: AgentHooks;
|
|
12
|
+
/** Max concurrent tool executions per iteration (default: 5). */
|
|
13
|
+
readonly maxConcurrency?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Input for the AgentTask. The JSON Schema ({@link AgentInputSchema}) is
|
|
17
|
+
* used for runtime validation and UI; this interface is the TypeScript
|
|
18
|
+
* source of truth.
|
|
19
|
+
*
|
|
20
|
+
* Tools follow the same resolution pattern as `model`: each entry is
|
|
21
|
+
* either a **string** (task type name resolved from the TaskRegistry) or
|
|
22
|
+
* a full **{@link ToolDefinition}** object. Configurable tasks (e.g.
|
|
23
|
+
* `McpToolCallTask`, `JavaScriptTask`) can be pre-configured via the
|
|
24
|
+
* `config` field on the definition — the LLM never sees this config.
|
|
25
|
+
*/
|
|
26
|
+
export interface AgentTaskInput {
|
|
27
|
+
readonly [key: string]: unknown;
|
|
28
|
+
readonly model: string;
|
|
29
|
+
readonly prompt: string | ReadonlyArray<UserContentBlock>;
|
|
30
|
+
readonly systemPrompt?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Tools available to the agent. Each entry is either:
|
|
33
|
+
* - A **string** — resolved from the TaskRegistry by name (like `model`).
|
|
34
|
+
* - A **{@link ToolDefinition}** — inline definition with optional `config`
|
|
35
|
+
* for configurable tasks and optional `execute` for custom function tools.
|
|
36
|
+
*/
|
|
37
|
+
readonly tools?: ReadonlyArray<string | ToolDefinition>;
|
|
38
|
+
readonly maxIterations?: number;
|
|
39
|
+
readonly maxTokens?: number;
|
|
40
|
+
readonly temperature?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Name of a "stop tool". When the LLM calls this tool the agent loop
|
|
43
|
+
* ends and the tool's input becomes the {@link AgentTaskOutput.structuredOutput}.
|
|
44
|
+
* If no tool source with this name exists, a synthetic definition is
|
|
45
|
+
* added automatically.
|
|
46
|
+
*/
|
|
47
|
+
readonly stopTool?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Maximum number of messages to keep in the conversation window sent
|
|
50
|
+
* to the LLM. When exceeded, the oldest messages (after the initial
|
|
51
|
+
* user message) are dropped. Helps prevent context-window overflow.
|
|
52
|
+
*/
|
|
53
|
+
readonly maxContextMessages?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface AgentTaskOutput {
|
|
56
|
+
readonly [key: string]: unknown;
|
|
57
|
+
readonly text: string;
|
|
58
|
+
readonly messages: ReadonlyArray<ChatMessage>;
|
|
59
|
+
readonly iterations: number;
|
|
60
|
+
readonly toolCallCount: number;
|
|
61
|
+
/** Present when the agent terminated via a stop tool. */
|
|
62
|
+
readonly structuredOutput?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
export declare const AgentInputSchema: {
|
|
65
|
+
readonly type: "object";
|
|
66
|
+
readonly properties: {
|
|
67
|
+
readonly model: {
|
|
68
|
+
readonly oneOf: readonly [{
|
|
69
|
+
readonly title: "Model";
|
|
70
|
+
readonly description: `The model ${string}`;
|
|
71
|
+
} & {
|
|
72
|
+
readonly format: import(".").TypeModelSemantic;
|
|
73
|
+
readonly type: "string";
|
|
74
|
+
}, {
|
|
75
|
+
readonly type: "object";
|
|
76
|
+
readonly properties: {
|
|
77
|
+
readonly model_id: {
|
|
78
|
+
readonly type: "string";
|
|
79
|
+
};
|
|
80
|
+
readonly tasks: {
|
|
81
|
+
readonly type: "array";
|
|
82
|
+
readonly items: {
|
|
83
|
+
readonly type: "string";
|
|
84
|
+
};
|
|
85
|
+
readonly "x-ui-editor": "multiselect";
|
|
86
|
+
};
|
|
87
|
+
readonly title: {
|
|
88
|
+
readonly type: "string";
|
|
89
|
+
};
|
|
90
|
+
readonly description: {
|
|
91
|
+
readonly type: "string";
|
|
92
|
+
readonly "x-ui-editor": "textarea";
|
|
93
|
+
};
|
|
94
|
+
readonly provider: {
|
|
95
|
+
readonly type: "string";
|
|
96
|
+
};
|
|
97
|
+
readonly provider_config: {
|
|
98
|
+
readonly type: "object";
|
|
99
|
+
readonly properties: {
|
|
100
|
+
readonly credential_key: {
|
|
101
|
+
readonly type: "string";
|
|
102
|
+
readonly format: "credential";
|
|
103
|
+
readonly "x-ui-hidden": true;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
readonly additionalProperties: true;
|
|
107
|
+
readonly default: {};
|
|
108
|
+
};
|
|
109
|
+
readonly metadata: {
|
|
110
|
+
readonly type: "object";
|
|
111
|
+
readonly default: {};
|
|
112
|
+
readonly "x-ui-hidden": true;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
readonly required: readonly ["provider", "provider_config"];
|
|
116
|
+
readonly format: "model";
|
|
117
|
+
readonly additionalProperties: true;
|
|
118
|
+
} & {
|
|
119
|
+
readonly format: import(".").TypeModelSemantic;
|
|
120
|
+
}];
|
|
121
|
+
} & {
|
|
122
|
+
readonly format: import(".").TypeModelSemantic;
|
|
123
|
+
};
|
|
124
|
+
readonly prompt: {
|
|
125
|
+
readonly oneOf: readonly [{
|
|
126
|
+
readonly type: "string";
|
|
127
|
+
}, {
|
|
128
|
+
readonly type: "array";
|
|
129
|
+
readonly items: {
|
|
130
|
+
readonly type: "object";
|
|
131
|
+
readonly properties: {
|
|
132
|
+
readonly type: {
|
|
133
|
+
readonly type: "string";
|
|
134
|
+
readonly enum: readonly ["text", "image", "audio"];
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
readonly required: readonly ["type"];
|
|
138
|
+
readonly additionalProperties: true;
|
|
139
|
+
};
|
|
140
|
+
}];
|
|
141
|
+
readonly title: "Prompt";
|
|
142
|
+
readonly description: "The user prompt to start the agent loop. Can be a string or an array of content blocks (text, image, audio).";
|
|
143
|
+
};
|
|
144
|
+
readonly systemPrompt: {
|
|
145
|
+
readonly type: "string";
|
|
146
|
+
readonly title: "System Prompt";
|
|
147
|
+
readonly description: "Optional system instructions for the agent";
|
|
148
|
+
};
|
|
149
|
+
readonly tools: {
|
|
150
|
+
readonly type: "array";
|
|
151
|
+
readonly format: "tasks";
|
|
152
|
+
readonly title: "Tools";
|
|
153
|
+
readonly description: "Tools available to the agent. Each entry is a task type name (string, resolved from TaskRegistry) or a full ToolDefinition object with optional config for configurable tasks.";
|
|
154
|
+
readonly items: {
|
|
155
|
+
readonly oneOf: readonly [{
|
|
156
|
+
readonly type: "string";
|
|
157
|
+
readonly format: "tasks";
|
|
158
|
+
readonly description: "Task type name";
|
|
159
|
+
}, {
|
|
160
|
+
readonly type: "object";
|
|
161
|
+
readonly properties: {
|
|
162
|
+
readonly name: {
|
|
163
|
+
readonly type: "string";
|
|
164
|
+
readonly title: "Name";
|
|
165
|
+
readonly description: "The tool name";
|
|
166
|
+
};
|
|
167
|
+
readonly description: {
|
|
168
|
+
readonly type: "string";
|
|
169
|
+
readonly title: "Description";
|
|
170
|
+
readonly description: "A description of what the tool does";
|
|
171
|
+
};
|
|
172
|
+
readonly inputSchema: {
|
|
173
|
+
readonly type: "object";
|
|
174
|
+
readonly title: "Input Schema";
|
|
175
|
+
readonly description: "JSON Schema describing the tool's input parameters";
|
|
176
|
+
readonly additionalProperties: true;
|
|
177
|
+
};
|
|
178
|
+
readonly outputSchema: {
|
|
179
|
+
readonly type: "object";
|
|
180
|
+
readonly title: "Output Schema";
|
|
181
|
+
readonly description: "JSON Schema describing what the tool returns";
|
|
182
|
+
readonly additionalProperties: true;
|
|
183
|
+
};
|
|
184
|
+
readonly configSchema: {
|
|
185
|
+
readonly type: "object";
|
|
186
|
+
readonly title: "Config Schema";
|
|
187
|
+
readonly description: "JSON Schema describing the task's configuration options (not sent to the LLM)";
|
|
188
|
+
readonly additionalProperties: true;
|
|
189
|
+
};
|
|
190
|
+
readonly config: {
|
|
191
|
+
readonly type: "object";
|
|
192
|
+
readonly title: "Config";
|
|
193
|
+
readonly description: "Concrete configuration values for the backing task (not sent to the LLM)";
|
|
194
|
+
readonly additionalProperties: true;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
readonly required: readonly ["name", "description", "inputSchema"];
|
|
198
|
+
readonly additionalProperties: true;
|
|
199
|
+
}];
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
readonly stopTool: {
|
|
203
|
+
readonly type: "string";
|
|
204
|
+
readonly title: "Stop Tool";
|
|
205
|
+
readonly description: "Name of a tool that signals agent completion. When called, the loop ends and the tool input becomes structuredOutput.";
|
|
206
|
+
readonly "x-ui-group": "Configuration";
|
|
207
|
+
};
|
|
208
|
+
readonly maxIterations: {
|
|
209
|
+
readonly type: "number";
|
|
210
|
+
readonly title: "Max Iterations";
|
|
211
|
+
readonly description: "Maximum number of agent loop iterations (default: 10)";
|
|
212
|
+
readonly minimum: 1;
|
|
213
|
+
readonly "x-ui-group": "Configuration";
|
|
214
|
+
};
|
|
215
|
+
readonly maxContextMessages: {
|
|
216
|
+
readonly type: "number";
|
|
217
|
+
readonly title: "Max Context Messages";
|
|
218
|
+
readonly description: "Maximum messages in conversation history. Older messages are trimmed to prevent context overflow.";
|
|
219
|
+
readonly minimum: 3;
|
|
220
|
+
readonly "x-ui-group": "Configuration";
|
|
221
|
+
};
|
|
222
|
+
readonly maxTokens: {
|
|
223
|
+
readonly type: "number";
|
|
224
|
+
readonly title: "Max Tokens";
|
|
225
|
+
readonly description: "Maximum tokens per LLM call";
|
|
226
|
+
readonly minimum: 1;
|
|
227
|
+
readonly "x-ui-group": "Configuration";
|
|
228
|
+
};
|
|
229
|
+
readonly temperature: {
|
|
230
|
+
readonly type: "number";
|
|
231
|
+
readonly title: "Temperature";
|
|
232
|
+
readonly description: "Sampling temperature for LLM calls";
|
|
233
|
+
readonly minimum: 0;
|
|
234
|
+
readonly maximum: 2;
|
|
235
|
+
readonly "x-ui-group": "Configuration";
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
readonly required: readonly ["model", "prompt"];
|
|
239
|
+
readonly additionalProperties: false;
|
|
240
|
+
};
|
|
241
|
+
export declare const AgentOutputSchema: {
|
|
242
|
+
readonly type: "object";
|
|
243
|
+
readonly properties: {
|
|
244
|
+
readonly text: {
|
|
245
|
+
readonly type: "string";
|
|
246
|
+
readonly title: "Text";
|
|
247
|
+
readonly description: "The final text response from the agent";
|
|
248
|
+
readonly "x-stream": "append";
|
|
249
|
+
};
|
|
250
|
+
readonly messages: {
|
|
251
|
+
readonly type: "array";
|
|
252
|
+
readonly title: "Messages";
|
|
253
|
+
readonly description: "Full conversation history including all tool calls and results";
|
|
254
|
+
readonly items: {
|
|
255
|
+
readonly type: "object";
|
|
256
|
+
readonly additionalProperties: true;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
readonly iterations: {
|
|
260
|
+
readonly type: "number";
|
|
261
|
+
readonly title: "Iterations";
|
|
262
|
+
readonly description: "Number of LLM calls made during the agent loop";
|
|
263
|
+
};
|
|
264
|
+
readonly toolCallCount: {
|
|
265
|
+
readonly type: "number";
|
|
266
|
+
readonly title: "Tool Call Count";
|
|
267
|
+
readonly description: "Total number of tool calls executed";
|
|
268
|
+
};
|
|
269
|
+
readonly structuredOutput: {
|
|
270
|
+
readonly type: "object";
|
|
271
|
+
readonly title: "Structured Output";
|
|
272
|
+
readonly description: "Present when the agent terminated via a stop tool";
|
|
273
|
+
readonly additionalProperties: true;
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
readonly required: readonly ["text", "messages", "iterations", "toolCallCount"];
|
|
277
|
+
readonly additionalProperties: false;
|
|
278
|
+
};
|
|
279
|
+
export declare class AgentTask extends Task<AgentTaskInput, AgentTaskOutput, AgentTaskConfig> {
|
|
280
|
+
static type: string;
|
|
281
|
+
static category: string;
|
|
282
|
+
static title: string;
|
|
283
|
+
static description: string;
|
|
284
|
+
static cacheable: boolean;
|
|
285
|
+
static inputSchema(): {
|
|
286
|
+
readonly type: "object";
|
|
287
|
+
readonly properties: {
|
|
288
|
+
readonly model: {
|
|
289
|
+
readonly oneOf: readonly [{
|
|
290
|
+
readonly title: "Model";
|
|
291
|
+
readonly description: `The model ${string}`;
|
|
292
|
+
} & {
|
|
293
|
+
readonly format: import(".").TypeModelSemantic;
|
|
294
|
+
readonly type: "string";
|
|
295
|
+
}, {
|
|
296
|
+
readonly type: "object";
|
|
297
|
+
readonly properties: {
|
|
298
|
+
readonly model_id: {
|
|
299
|
+
readonly type: "string";
|
|
300
|
+
};
|
|
301
|
+
readonly tasks: {
|
|
302
|
+
readonly type: "array";
|
|
303
|
+
readonly items: {
|
|
304
|
+
readonly type: "string";
|
|
305
|
+
};
|
|
306
|
+
readonly "x-ui-editor": "multiselect";
|
|
307
|
+
};
|
|
308
|
+
readonly title: {
|
|
309
|
+
readonly type: "string";
|
|
310
|
+
};
|
|
311
|
+
readonly description: {
|
|
312
|
+
readonly type: "string";
|
|
313
|
+
readonly "x-ui-editor": "textarea";
|
|
314
|
+
};
|
|
315
|
+
readonly provider: {
|
|
316
|
+
readonly type: "string";
|
|
317
|
+
};
|
|
318
|
+
readonly provider_config: {
|
|
319
|
+
readonly type: "object";
|
|
320
|
+
readonly properties: {
|
|
321
|
+
readonly credential_key: {
|
|
322
|
+
readonly type: "string";
|
|
323
|
+
readonly format: "credential";
|
|
324
|
+
readonly "x-ui-hidden": true;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
readonly additionalProperties: true;
|
|
328
|
+
readonly default: {};
|
|
329
|
+
};
|
|
330
|
+
readonly metadata: {
|
|
331
|
+
readonly type: "object";
|
|
332
|
+
readonly default: {};
|
|
333
|
+
readonly "x-ui-hidden": true;
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
readonly required: readonly ["provider", "provider_config"];
|
|
337
|
+
readonly format: "model";
|
|
338
|
+
readonly additionalProperties: true;
|
|
339
|
+
} & {
|
|
340
|
+
readonly format: import(".").TypeModelSemantic;
|
|
341
|
+
}];
|
|
342
|
+
} & {
|
|
343
|
+
readonly format: import(".").TypeModelSemantic;
|
|
344
|
+
};
|
|
345
|
+
readonly prompt: {
|
|
346
|
+
readonly oneOf: readonly [{
|
|
347
|
+
readonly type: "string";
|
|
348
|
+
}, {
|
|
349
|
+
readonly type: "array";
|
|
350
|
+
readonly items: {
|
|
351
|
+
readonly type: "object";
|
|
352
|
+
readonly properties: {
|
|
353
|
+
readonly type: {
|
|
354
|
+
readonly type: "string";
|
|
355
|
+
readonly enum: readonly ["text", "image", "audio"];
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
readonly required: readonly ["type"];
|
|
359
|
+
readonly additionalProperties: true;
|
|
360
|
+
};
|
|
361
|
+
}];
|
|
362
|
+
readonly title: "Prompt";
|
|
363
|
+
readonly description: "The user prompt to start the agent loop. Can be a string or an array of content blocks (text, image, audio).";
|
|
364
|
+
};
|
|
365
|
+
readonly systemPrompt: {
|
|
366
|
+
readonly type: "string";
|
|
367
|
+
readonly title: "System Prompt";
|
|
368
|
+
readonly description: "Optional system instructions for the agent";
|
|
369
|
+
};
|
|
370
|
+
readonly tools: {
|
|
371
|
+
readonly type: "array";
|
|
372
|
+
readonly format: "tasks";
|
|
373
|
+
readonly title: "Tools";
|
|
374
|
+
readonly description: "Tools available to the agent. Each entry is a task type name (string, resolved from TaskRegistry) or a full ToolDefinition object with optional config for configurable tasks.";
|
|
375
|
+
readonly items: {
|
|
376
|
+
readonly oneOf: readonly [{
|
|
377
|
+
readonly type: "string";
|
|
378
|
+
readonly format: "tasks";
|
|
379
|
+
readonly description: "Task type name";
|
|
380
|
+
}, {
|
|
381
|
+
readonly type: "object";
|
|
382
|
+
readonly properties: {
|
|
383
|
+
readonly name: {
|
|
384
|
+
readonly type: "string";
|
|
385
|
+
readonly title: "Name";
|
|
386
|
+
readonly description: "The tool name";
|
|
387
|
+
};
|
|
388
|
+
readonly description: {
|
|
389
|
+
readonly type: "string";
|
|
390
|
+
readonly title: "Description";
|
|
391
|
+
readonly description: "A description of what the tool does";
|
|
392
|
+
};
|
|
393
|
+
readonly inputSchema: {
|
|
394
|
+
readonly type: "object";
|
|
395
|
+
readonly title: "Input Schema";
|
|
396
|
+
readonly description: "JSON Schema describing the tool's input parameters";
|
|
397
|
+
readonly additionalProperties: true;
|
|
398
|
+
};
|
|
399
|
+
readonly outputSchema: {
|
|
400
|
+
readonly type: "object";
|
|
401
|
+
readonly title: "Output Schema";
|
|
402
|
+
readonly description: "JSON Schema describing what the tool returns";
|
|
403
|
+
readonly additionalProperties: true;
|
|
404
|
+
};
|
|
405
|
+
readonly configSchema: {
|
|
406
|
+
readonly type: "object";
|
|
407
|
+
readonly title: "Config Schema";
|
|
408
|
+
readonly description: "JSON Schema describing the task's configuration options (not sent to the LLM)";
|
|
409
|
+
readonly additionalProperties: true;
|
|
410
|
+
};
|
|
411
|
+
readonly config: {
|
|
412
|
+
readonly type: "object";
|
|
413
|
+
readonly title: "Config";
|
|
414
|
+
readonly description: "Concrete configuration values for the backing task (not sent to the LLM)";
|
|
415
|
+
readonly additionalProperties: true;
|
|
416
|
+
};
|
|
417
|
+
};
|
|
418
|
+
readonly required: readonly ["name", "description", "inputSchema"];
|
|
419
|
+
readonly additionalProperties: true;
|
|
420
|
+
}];
|
|
421
|
+
};
|
|
422
|
+
};
|
|
423
|
+
readonly stopTool: {
|
|
424
|
+
readonly type: "string";
|
|
425
|
+
readonly title: "Stop Tool";
|
|
426
|
+
readonly description: "Name of a tool that signals agent completion. When called, the loop ends and the tool input becomes structuredOutput.";
|
|
427
|
+
readonly "x-ui-group": "Configuration";
|
|
428
|
+
};
|
|
429
|
+
readonly maxIterations: {
|
|
430
|
+
readonly type: "number";
|
|
431
|
+
readonly title: "Max Iterations";
|
|
432
|
+
readonly description: "Maximum number of agent loop iterations (default: 10)";
|
|
433
|
+
readonly minimum: 1;
|
|
434
|
+
readonly "x-ui-group": "Configuration";
|
|
435
|
+
};
|
|
436
|
+
readonly maxContextMessages: {
|
|
437
|
+
readonly type: "number";
|
|
438
|
+
readonly title: "Max Context Messages";
|
|
439
|
+
readonly description: "Maximum messages in conversation history. Older messages are trimmed to prevent context overflow.";
|
|
440
|
+
readonly minimum: 3;
|
|
441
|
+
readonly "x-ui-group": "Configuration";
|
|
442
|
+
};
|
|
443
|
+
readonly maxTokens: {
|
|
444
|
+
readonly type: "number";
|
|
445
|
+
readonly title: "Max Tokens";
|
|
446
|
+
readonly description: "Maximum tokens per LLM call";
|
|
447
|
+
readonly minimum: 1;
|
|
448
|
+
readonly "x-ui-group": "Configuration";
|
|
449
|
+
};
|
|
450
|
+
readonly temperature: {
|
|
451
|
+
readonly type: "number";
|
|
452
|
+
readonly title: "Temperature";
|
|
453
|
+
readonly description: "Sampling temperature for LLM calls";
|
|
454
|
+
readonly minimum: 0;
|
|
455
|
+
readonly maximum: 2;
|
|
456
|
+
readonly "x-ui-group": "Configuration";
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
readonly required: readonly ["model", "prompt"];
|
|
460
|
+
readonly additionalProperties: false;
|
|
461
|
+
};
|
|
462
|
+
static outputSchema(): {
|
|
463
|
+
readonly type: "object";
|
|
464
|
+
readonly properties: {
|
|
465
|
+
readonly text: {
|
|
466
|
+
readonly type: "string";
|
|
467
|
+
readonly title: "Text";
|
|
468
|
+
readonly description: "The final text response from the agent";
|
|
469
|
+
readonly "x-stream": "append";
|
|
470
|
+
};
|
|
471
|
+
readonly messages: {
|
|
472
|
+
readonly type: "array";
|
|
473
|
+
readonly title: "Messages";
|
|
474
|
+
readonly description: "Full conversation history including all tool calls and results";
|
|
475
|
+
readonly items: {
|
|
476
|
+
readonly type: "object";
|
|
477
|
+
readonly additionalProperties: true;
|
|
478
|
+
};
|
|
479
|
+
};
|
|
480
|
+
readonly iterations: {
|
|
481
|
+
readonly type: "number";
|
|
482
|
+
readonly title: "Iterations";
|
|
483
|
+
readonly description: "Number of LLM calls made during the agent loop";
|
|
484
|
+
};
|
|
485
|
+
readonly toolCallCount: {
|
|
486
|
+
readonly type: "number";
|
|
487
|
+
readonly title: "Tool Call Count";
|
|
488
|
+
readonly description: "Total number of tool calls executed";
|
|
489
|
+
};
|
|
490
|
+
readonly structuredOutput: {
|
|
491
|
+
readonly type: "object";
|
|
492
|
+
readonly title: "Structured Output";
|
|
493
|
+
readonly description: "Present when the agent terminated via a stop tool";
|
|
494
|
+
readonly additionalProperties: true;
|
|
495
|
+
};
|
|
496
|
+
};
|
|
497
|
+
readonly required: readonly ["text", "messages", "iterations", "toolCallCount"];
|
|
498
|
+
readonly additionalProperties: false;
|
|
499
|
+
};
|
|
500
|
+
execute(input: AgentTaskInput, context: IExecuteContext): Promise<AgentTaskOutput>;
|
|
501
|
+
executeStream(input: AgentTaskInput, context: IExecuteContext): AsyncIterable<StreamEvent<AgentTaskOutput>>;
|
|
502
|
+
private agentLoop;
|
|
503
|
+
private resolveToolSources;
|
|
504
|
+
/**
|
|
505
|
+
* Build the tool definitions to send to the LLM.
|
|
506
|
+
* If a stopTool is configured and no matching source exists, adds a
|
|
507
|
+
* synthetic tool definition so the LLM can call it.
|
|
508
|
+
*/
|
|
509
|
+
private resolveToolDefs;
|
|
510
|
+
/**
|
|
511
|
+
* Trim messages to stay within maxContextMessages.
|
|
512
|
+
* Keeps the first message (initial user prompt) and the most recent
|
|
513
|
+
* messages. Trims at assistant/tool pair boundaries so that a
|
|
514
|
+
* tool_use message is never separated from its tool_result message.
|
|
515
|
+
*/
|
|
516
|
+
private trimMessages;
|
|
517
|
+
}
|
|
518
|
+
export declare const agent: (input: AgentTaskInput, config?: AgentTaskConfig) => Promise<AgentTaskOutput>;
|
|
519
|
+
declare module "@workglow/task-graph" {
|
|
520
|
+
interface Workflow {
|
|
521
|
+
agent: CreateWorkflow<AgentTaskInput, AgentTaskOutput, AgentTaskConfig>;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
//# sourceMappingURL=AgentTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentTask.d.ts","sourceRoot":"","sources":["../../src/task/AgentTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,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