@aigne/agent-library 1.22.4-beta → 1.23.0-beta
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/CHANGELOG.md +25 -0
- package/README.md +6 -94
- package/lib/cjs/orchestrator/index.d.ts +39 -71
- package/lib/cjs/orchestrator/index.js +174 -169
- package/lib/cjs/orchestrator/prompt.d.ts +3 -0
- package/lib/cjs/orchestrator/prompt.js +82 -0
- package/lib/cjs/orchestrator/type.d.ts +505 -0
- package/lib/cjs/orchestrator/type.js +83 -0
- package/lib/dts/orchestrator/index.d.ts +39 -71
- package/lib/dts/orchestrator/prompt.d.ts +3 -0
- package/lib/dts/orchestrator/type.d.ts +505 -0
- package/lib/esm/orchestrator/index.d.ts +39 -71
- package/lib/esm/orchestrator/index.js +176 -154
- package/lib/esm/orchestrator/prompt.d.ts +3 -0
- package/lib/esm/orchestrator/prompt.js +79 -0
- package/lib/esm/orchestrator/type.d.ts +505 -0
- package/lib/esm/orchestrator/type.js +77 -0
- package/package.json +12 -6
- package/lib/cjs/orchestrator/orchestrator-prompts.d.ts +0 -130
- package/lib/cjs/orchestrator/orchestrator-prompts.js +0 -135
- package/lib/dts/orchestrator/orchestrator-prompts.d.ts +0 -130
- package/lib/esm/orchestrator/orchestrator-prompts.d.ts +0 -130
- package/lib/esm/orchestrator/orchestrator-prompts.js +0 -131
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import type { Message } from "@aigne/core";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Task execution status
|
|
5
|
+
*/
|
|
6
|
+
export type TaskStatus = "pending" | "completed" | "failed";
|
|
7
|
+
/**
|
|
8
|
+
* Individual task execution record
|
|
9
|
+
*/
|
|
10
|
+
export interface TaskRecord {
|
|
11
|
+
/** Task description */
|
|
12
|
+
task: string;
|
|
13
|
+
/** Task execution status */
|
|
14
|
+
status: TaskStatus;
|
|
15
|
+
/** Task execution result (can be any type) */
|
|
16
|
+
result?: unknown;
|
|
17
|
+
/** Error information if task failed */
|
|
18
|
+
error?: {
|
|
19
|
+
message: string;
|
|
20
|
+
};
|
|
21
|
+
/** Timestamp when task was created */
|
|
22
|
+
createdAt?: number;
|
|
23
|
+
/** Timestamp when task was completed or failed */
|
|
24
|
+
completedAt?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Execution state tracking all tasks
|
|
28
|
+
*/
|
|
29
|
+
export interface ExecutionState {
|
|
30
|
+
tasks: TaskRecord[];
|
|
31
|
+
}
|
|
32
|
+
export declare const taskRecordSchema: z.ZodObject<{
|
|
33
|
+
task: z.ZodString;
|
|
34
|
+
status: z.ZodEnum<["pending", "completed", "failed"]>;
|
|
35
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
36
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
message: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
message: string;
|
|
40
|
+
}, {
|
|
41
|
+
message: string;
|
|
42
|
+
}>>;
|
|
43
|
+
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
status: "pending" | "completed" | "failed";
|
|
47
|
+
task: string;
|
|
48
|
+
error?: {
|
|
49
|
+
message: string;
|
|
50
|
+
} | undefined;
|
|
51
|
+
result?: unknown;
|
|
52
|
+
createdAt?: number | undefined;
|
|
53
|
+
completedAt?: number | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
status: "pending" | "completed" | "failed";
|
|
56
|
+
task: string;
|
|
57
|
+
error?: {
|
|
58
|
+
message: string;
|
|
59
|
+
} | undefined;
|
|
60
|
+
result?: unknown;
|
|
61
|
+
createdAt?: number | undefined;
|
|
62
|
+
completedAt?: number | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const executionStateSchema: z.ZodObject<{
|
|
65
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
66
|
+
task: z.ZodString;
|
|
67
|
+
status: z.ZodEnum<["pending", "completed", "failed"]>;
|
|
68
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
69
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
message: z.ZodString;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
message: string;
|
|
73
|
+
}, {
|
|
74
|
+
message: string;
|
|
75
|
+
}>>;
|
|
76
|
+
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
status: "pending" | "completed" | "failed";
|
|
80
|
+
task: string;
|
|
81
|
+
error?: {
|
|
82
|
+
message: string;
|
|
83
|
+
} | undefined;
|
|
84
|
+
result?: unknown;
|
|
85
|
+
createdAt?: number | undefined;
|
|
86
|
+
completedAt?: number | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
status: "pending" | "completed" | "failed";
|
|
89
|
+
task: string;
|
|
90
|
+
error?: {
|
|
91
|
+
message: string;
|
|
92
|
+
} | undefined;
|
|
93
|
+
result?: unknown;
|
|
94
|
+
createdAt?: number | undefined;
|
|
95
|
+
completedAt?: number | undefined;
|
|
96
|
+
}>, "many">;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
tasks: {
|
|
99
|
+
status: "pending" | "completed" | "failed";
|
|
100
|
+
task: string;
|
|
101
|
+
error?: {
|
|
102
|
+
message: string;
|
|
103
|
+
} | undefined;
|
|
104
|
+
result?: unknown;
|
|
105
|
+
createdAt?: number | undefined;
|
|
106
|
+
completedAt?: number | undefined;
|
|
107
|
+
}[];
|
|
108
|
+
}, {
|
|
109
|
+
tasks: {
|
|
110
|
+
status: "pending" | "completed" | "failed";
|
|
111
|
+
task: string;
|
|
112
|
+
error?: {
|
|
113
|
+
message: string;
|
|
114
|
+
} | undefined;
|
|
115
|
+
result?: unknown;
|
|
116
|
+
createdAt?: number | undefined;
|
|
117
|
+
completedAt?: number | undefined;
|
|
118
|
+
}[];
|
|
119
|
+
}>;
|
|
120
|
+
export interface PlannerInput extends Message {
|
|
121
|
+
objective: string;
|
|
122
|
+
skills: {
|
|
123
|
+
name: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
}[];
|
|
126
|
+
executionState: ExecutionState;
|
|
127
|
+
}
|
|
128
|
+
export declare const plannerInputSchema: z.ZodObject<{
|
|
129
|
+
objective: z.ZodString;
|
|
130
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
131
|
+
name: z.ZodString;
|
|
132
|
+
description: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
name: string;
|
|
135
|
+
description?: string | undefined;
|
|
136
|
+
}, {
|
|
137
|
+
name: string;
|
|
138
|
+
description?: string | undefined;
|
|
139
|
+
}>, "many">;
|
|
140
|
+
executionState: z.ZodObject<{
|
|
141
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
142
|
+
task: z.ZodString;
|
|
143
|
+
status: z.ZodEnum<["pending", "completed", "failed"]>;
|
|
144
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
145
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
146
|
+
message: z.ZodString;
|
|
147
|
+
}, "strip", z.ZodTypeAny, {
|
|
148
|
+
message: string;
|
|
149
|
+
}, {
|
|
150
|
+
message: string;
|
|
151
|
+
}>>;
|
|
152
|
+
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
153
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
}, "strip", z.ZodTypeAny, {
|
|
155
|
+
status: "pending" | "completed" | "failed";
|
|
156
|
+
task: string;
|
|
157
|
+
error?: {
|
|
158
|
+
message: string;
|
|
159
|
+
} | undefined;
|
|
160
|
+
result?: unknown;
|
|
161
|
+
createdAt?: number | undefined;
|
|
162
|
+
completedAt?: number | undefined;
|
|
163
|
+
}, {
|
|
164
|
+
status: "pending" | "completed" | "failed";
|
|
165
|
+
task: string;
|
|
166
|
+
error?: {
|
|
167
|
+
message: string;
|
|
168
|
+
} | undefined;
|
|
169
|
+
result?: unknown;
|
|
170
|
+
createdAt?: number | undefined;
|
|
171
|
+
completedAt?: number | undefined;
|
|
172
|
+
}>, "many">;
|
|
173
|
+
}, "strip", z.ZodTypeAny, {
|
|
174
|
+
tasks: {
|
|
175
|
+
status: "pending" | "completed" | "failed";
|
|
176
|
+
task: string;
|
|
177
|
+
error?: {
|
|
178
|
+
message: string;
|
|
179
|
+
} | undefined;
|
|
180
|
+
result?: unknown;
|
|
181
|
+
createdAt?: number | undefined;
|
|
182
|
+
completedAt?: number | undefined;
|
|
183
|
+
}[];
|
|
184
|
+
}, {
|
|
185
|
+
tasks: {
|
|
186
|
+
status: "pending" | "completed" | "failed";
|
|
187
|
+
task: string;
|
|
188
|
+
error?: {
|
|
189
|
+
message: string;
|
|
190
|
+
} | undefined;
|
|
191
|
+
result?: unknown;
|
|
192
|
+
createdAt?: number | undefined;
|
|
193
|
+
completedAt?: number | undefined;
|
|
194
|
+
}[];
|
|
195
|
+
}>;
|
|
196
|
+
}, "strip", z.ZodTypeAny, {
|
|
197
|
+
skills: {
|
|
198
|
+
name: string;
|
|
199
|
+
description?: string | undefined;
|
|
200
|
+
}[];
|
|
201
|
+
objective: string;
|
|
202
|
+
executionState: {
|
|
203
|
+
tasks: {
|
|
204
|
+
status: "pending" | "completed" | "failed";
|
|
205
|
+
task: string;
|
|
206
|
+
error?: {
|
|
207
|
+
message: string;
|
|
208
|
+
} | undefined;
|
|
209
|
+
result?: unknown;
|
|
210
|
+
createdAt?: number | undefined;
|
|
211
|
+
completedAt?: number | undefined;
|
|
212
|
+
}[];
|
|
213
|
+
};
|
|
214
|
+
}, {
|
|
215
|
+
skills: {
|
|
216
|
+
name: string;
|
|
217
|
+
description?: string | undefined;
|
|
218
|
+
}[];
|
|
219
|
+
objective: string;
|
|
220
|
+
executionState: {
|
|
221
|
+
tasks: {
|
|
222
|
+
status: "pending" | "completed" | "failed";
|
|
223
|
+
task: string;
|
|
224
|
+
error?: {
|
|
225
|
+
message: string;
|
|
226
|
+
} | undefined;
|
|
227
|
+
result?: unknown;
|
|
228
|
+
createdAt?: number | undefined;
|
|
229
|
+
completedAt?: number | undefined;
|
|
230
|
+
}[];
|
|
231
|
+
};
|
|
232
|
+
}>;
|
|
233
|
+
export interface PlannerOutput extends Message {
|
|
234
|
+
nextTask?: string;
|
|
235
|
+
finished?: boolean;
|
|
236
|
+
}
|
|
237
|
+
export declare const plannerOutputSchema: z.ZodObject<{
|
|
238
|
+
nextTask: z.ZodOptional<z.ZodString>;
|
|
239
|
+
finished: z.ZodOptional<z.ZodBoolean>;
|
|
240
|
+
}, "strip", z.ZodTypeAny, {
|
|
241
|
+
nextTask?: string | undefined;
|
|
242
|
+
finished?: boolean | undefined;
|
|
243
|
+
}, {
|
|
244
|
+
nextTask?: string | undefined;
|
|
245
|
+
finished?: boolean | undefined;
|
|
246
|
+
}>;
|
|
247
|
+
export interface WorkerInput extends Message {
|
|
248
|
+
objective: string;
|
|
249
|
+
executionState: ExecutionState;
|
|
250
|
+
task: string;
|
|
251
|
+
}
|
|
252
|
+
export declare const workerInputSchema: z.ZodObject<{
|
|
253
|
+
objective: z.ZodString;
|
|
254
|
+
task: z.ZodString;
|
|
255
|
+
executionState: z.ZodObject<{
|
|
256
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
257
|
+
task: z.ZodString;
|
|
258
|
+
status: z.ZodEnum<["pending", "completed", "failed"]>;
|
|
259
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
260
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
261
|
+
message: z.ZodString;
|
|
262
|
+
}, "strip", z.ZodTypeAny, {
|
|
263
|
+
message: string;
|
|
264
|
+
}, {
|
|
265
|
+
message: string;
|
|
266
|
+
}>>;
|
|
267
|
+
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
268
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
269
|
+
}, "strip", z.ZodTypeAny, {
|
|
270
|
+
status: "pending" | "completed" | "failed";
|
|
271
|
+
task: string;
|
|
272
|
+
error?: {
|
|
273
|
+
message: string;
|
|
274
|
+
} | undefined;
|
|
275
|
+
result?: unknown;
|
|
276
|
+
createdAt?: number | undefined;
|
|
277
|
+
completedAt?: number | undefined;
|
|
278
|
+
}, {
|
|
279
|
+
status: "pending" | "completed" | "failed";
|
|
280
|
+
task: string;
|
|
281
|
+
error?: {
|
|
282
|
+
message: string;
|
|
283
|
+
} | undefined;
|
|
284
|
+
result?: unknown;
|
|
285
|
+
createdAt?: number | undefined;
|
|
286
|
+
completedAt?: number | undefined;
|
|
287
|
+
}>, "many">;
|
|
288
|
+
}, "strip", z.ZodTypeAny, {
|
|
289
|
+
tasks: {
|
|
290
|
+
status: "pending" | "completed" | "failed";
|
|
291
|
+
task: string;
|
|
292
|
+
error?: {
|
|
293
|
+
message: string;
|
|
294
|
+
} | undefined;
|
|
295
|
+
result?: unknown;
|
|
296
|
+
createdAt?: number | undefined;
|
|
297
|
+
completedAt?: number | undefined;
|
|
298
|
+
}[];
|
|
299
|
+
}, {
|
|
300
|
+
tasks: {
|
|
301
|
+
status: "pending" | "completed" | "failed";
|
|
302
|
+
task: string;
|
|
303
|
+
error?: {
|
|
304
|
+
message: string;
|
|
305
|
+
} | undefined;
|
|
306
|
+
result?: unknown;
|
|
307
|
+
createdAt?: number | undefined;
|
|
308
|
+
completedAt?: number | undefined;
|
|
309
|
+
}[];
|
|
310
|
+
}>;
|
|
311
|
+
}, "strip", z.ZodTypeAny, {
|
|
312
|
+
task: string;
|
|
313
|
+
objective: string;
|
|
314
|
+
executionState: {
|
|
315
|
+
tasks: {
|
|
316
|
+
status: "pending" | "completed" | "failed";
|
|
317
|
+
task: string;
|
|
318
|
+
error?: {
|
|
319
|
+
message: string;
|
|
320
|
+
} | undefined;
|
|
321
|
+
result?: unknown;
|
|
322
|
+
createdAt?: number | undefined;
|
|
323
|
+
completedAt?: number | undefined;
|
|
324
|
+
}[];
|
|
325
|
+
};
|
|
326
|
+
}, {
|
|
327
|
+
task: string;
|
|
328
|
+
objective: string;
|
|
329
|
+
executionState: {
|
|
330
|
+
tasks: {
|
|
331
|
+
status: "pending" | "completed" | "failed";
|
|
332
|
+
task: string;
|
|
333
|
+
error?: {
|
|
334
|
+
message: string;
|
|
335
|
+
} | undefined;
|
|
336
|
+
result?: unknown;
|
|
337
|
+
createdAt?: number | undefined;
|
|
338
|
+
completedAt?: number | undefined;
|
|
339
|
+
}[];
|
|
340
|
+
};
|
|
341
|
+
}>;
|
|
342
|
+
/**
|
|
343
|
+
* Worker output structure
|
|
344
|
+
*/
|
|
345
|
+
export interface WorkerOutput extends Message {
|
|
346
|
+
/** Task execution result */
|
|
347
|
+
result?: string;
|
|
348
|
+
/** Whether the task was completed successfully */
|
|
349
|
+
success: boolean;
|
|
350
|
+
/** Error information if task failed */
|
|
351
|
+
error?: {
|
|
352
|
+
message: string;
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
export declare const workerOutputSchema: z.ZodObject<{
|
|
356
|
+
result: z.ZodOptional<z.ZodString>;
|
|
357
|
+
success: z.ZodBoolean;
|
|
358
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
359
|
+
message: z.ZodString;
|
|
360
|
+
}, "strip", z.ZodTypeAny, {
|
|
361
|
+
message: string;
|
|
362
|
+
}, {
|
|
363
|
+
message: string;
|
|
364
|
+
}>>;
|
|
365
|
+
}, "strip", z.ZodTypeAny, {
|
|
366
|
+
success: boolean;
|
|
367
|
+
error?: {
|
|
368
|
+
message: string;
|
|
369
|
+
} | undefined;
|
|
370
|
+
result?: string | undefined;
|
|
371
|
+
}, {
|
|
372
|
+
success: boolean;
|
|
373
|
+
error?: {
|
|
374
|
+
message: string;
|
|
375
|
+
} | undefined;
|
|
376
|
+
result?: string | undefined;
|
|
377
|
+
}>;
|
|
378
|
+
export interface CompleterInput extends Message {
|
|
379
|
+
objective: string;
|
|
380
|
+
executionState: ExecutionState;
|
|
381
|
+
}
|
|
382
|
+
export declare const completerInputSchema: z.ZodObject<{
|
|
383
|
+
objective: z.ZodString;
|
|
384
|
+
executionState: z.ZodObject<{
|
|
385
|
+
tasks: z.ZodArray<z.ZodObject<{
|
|
386
|
+
task: z.ZodString;
|
|
387
|
+
status: z.ZodEnum<["pending", "completed", "failed"]>;
|
|
388
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
389
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
390
|
+
message: z.ZodString;
|
|
391
|
+
}, "strip", z.ZodTypeAny, {
|
|
392
|
+
message: string;
|
|
393
|
+
}, {
|
|
394
|
+
message: string;
|
|
395
|
+
}>>;
|
|
396
|
+
createdAt: z.ZodOptional<z.ZodNumber>;
|
|
397
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
398
|
+
}, "strip", z.ZodTypeAny, {
|
|
399
|
+
status: "pending" | "completed" | "failed";
|
|
400
|
+
task: string;
|
|
401
|
+
error?: {
|
|
402
|
+
message: string;
|
|
403
|
+
} | undefined;
|
|
404
|
+
result?: unknown;
|
|
405
|
+
createdAt?: number | undefined;
|
|
406
|
+
completedAt?: number | undefined;
|
|
407
|
+
}, {
|
|
408
|
+
status: "pending" | "completed" | "failed";
|
|
409
|
+
task: string;
|
|
410
|
+
error?: {
|
|
411
|
+
message: string;
|
|
412
|
+
} | undefined;
|
|
413
|
+
result?: unknown;
|
|
414
|
+
createdAt?: number | undefined;
|
|
415
|
+
completedAt?: number | undefined;
|
|
416
|
+
}>, "many">;
|
|
417
|
+
}, "strip", z.ZodTypeAny, {
|
|
418
|
+
tasks: {
|
|
419
|
+
status: "pending" | "completed" | "failed";
|
|
420
|
+
task: string;
|
|
421
|
+
error?: {
|
|
422
|
+
message: string;
|
|
423
|
+
} | undefined;
|
|
424
|
+
result?: unknown;
|
|
425
|
+
createdAt?: number | undefined;
|
|
426
|
+
completedAt?: number | undefined;
|
|
427
|
+
}[];
|
|
428
|
+
}, {
|
|
429
|
+
tasks: {
|
|
430
|
+
status: "pending" | "completed" | "failed";
|
|
431
|
+
task: string;
|
|
432
|
+
error?: {
|
|
433
|
+
message: string;
|
|
434
|
+
} | undefined;
|
|
435
|
+
result?: unknown;
|
|
436
|
+
createdAt?: number | undefined;
|
|
437
|
+
completedAt?: number | undefined;
|
|
438
|
+
}[];
|
|
439
|
+
}>;
|
|
440
|
+
}, "strip", z.ZodTypeAny, {
|
|
441
|
+
objective: string;
|
|
442
|
+
executionState: {
|
|
443
|
+
tasks: {
|
|
444
|
+
status: "pending" | "completed" | "failed";
|
|
445
|
+
task: string;
|
|
446
|
+
error?: {
|
|
447
|
+
message: string;
|
|
448
|
+
} | undefined;
|
|
449
|
+
result?: unknown;
|
|
450
|
+
createdAt?: number | undefined;
|
|
451
|
+
completedAt?: number | undefined;
|
|
452
|
+
}[];
|
|
453
|
+
};
|
|
454
|
+
}, {
|
|
455
|
+
objective: string;
|
|
456
|
+
executionState: {
|
|
457
|
+
tasks: {
|
|
458
|
+
status: "pending" | "completed" | "failed";
|
|
459
|
+
task: string;
|
|
460
|
+
error?: {
|
|
461
|
+
message: string;
|
|
462
|
+
} | undefined;
|
|
463
|
+
result?: unknown;
|
|
464
|
+
createdAt?: number | undefined;
|
|
465
|
+
completedAt?: number | undefined;
|
|
466
|
+
}[];
|
|
467
|
+
};
|
|
468
|
+
}>;
|
|
469
|
+
/**
|
|
470
|
+
* Default maximum number of task execution iterations
|
|
471
|
+
*/
|
|
472
|
+
export declare const DEFAULT_MAX_ITERATIONS = 20;
|
|
473
|
+
/**
|
|
474
|
+
* Options for managing execution state to prevent context overflow
|
|
475
|
+
*/
|
|
476
|
+
export interface StateManagementOptions {
|
|
477
|
+
/**
|
|
478
|
+
* Maximum tokens allowed for execution state
|
|
479
|
+
* When exceeded, triggers compression
|
|
480
|
+
*/
|
|
481
|
+
maxTokens?: number;
|
|
482
|
+
/**
|
|
483
|
+
* Number of recent tasks to keep when compression is triggered
|
|
484
|
+
*/
|
|
485
|
+
keepRecent?: number;
|
|
486
|
+
/**
|
|
487
|
+
* Maximum number of task execution iterations
|
|
488
|
+
* When reached, orchestrator will stop and synthesize final result
|
|
489
|
+
* @default 20
|
|
490
|
+
*/
|
|
491
|
+
maxIterations?: number;
|
|
492
|
+
}
|
|
493
|
+
export declare const stateManagementOptionsSchema: z.ZodObject<{
|
|
494
|
+
maxTokens: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
495
|
+
keepRecent: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
496
|
+
maxIterations: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
497
|
+
}, "strip", z.ZodTypeAny, {
|
|
498
|
+
maxTokens?: number | undefined;
|
|
499
|
+
keepRecent?: number | undefined;
|
|
500
|
+
maxIterations?: number | undefined;
|
|
501
|
+
}, {
|
|
502
|
+
maxTokens?: number | undefined;
|
|
503
|
+
keepRecent?: number | undefined;
|
|
504
|
+
maxIterations?: number | undefined;
|
|
505
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { optionalize } from "@aigne/core/loader/schema.js";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
export const taskRecordSchema = z.object({
|
|
4
|
+
task: z.string().describe("The description of the executed task."),
|
|
5
|
+
status: z
|
|
6
|
+
.enum(["pending", "completed", "failed"])
|
|
7
|
+
.describe("The execution status of the task: pending, completed, or failed."),
|
|
8
|
+
result: z.unknown().optional().describe("The result produced by executing the task."),
|
|
9
|
+
error: z
|
|
10
|
+
.object({
|
|
11
|
+
message: z.string().describe("Error message if the task failed."),
|
|
12
|
+
})
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Error information if the task failed."),
|
|
15
|
+
createdAt: z.number().optional().describe("Timestamp when the task was created."),
|
|
16
|
+
completedAt: z.number().optional().describe("Timestamp when the task completed or failed."),
|
|
17
|
+
});
|
|
18
|
+
export const executionStateSchema = z.object({
|
|
19
|
+
tasks: z
|
|
20
|
+
.array(taskRecordSchema)
|
|
21
|
+
.describe("The list of tasks that have been executed along with their results."),
|
|
22
|
+
});
|
|
23
|
+
export const plannerInputSchema = z.object({
|
|
24
|
+
objective: z.string().describe("The user's overall objective."),
|
|
25
|
+
skills: z
|
|
26
|
+
.array(z.object({
|
|
27
|
+
name: z.string().describe("The name of the skill."),
|
|
28
|
+
description: z.string().optional().describe("A brief description of the skill."),
|
|
29
|
+
}))
|
|
30
|
+
.describe("The list of available skills the agent can use."),
|
|
31
|
+
executionState: executionStateSchema,
|
|
32
|
+
});
|
|
33
|
+
export const plannerOutputSchema = z.object({
|
|
34
|
+
nextTask: z
|
|
35
|
+
.string()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe("The next task to be executed by the worker. Should contain a clear, actionable description of what needs to be done."),
|
|
38
|
+
finished: z
|
|
39
|
+
.boolean()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Indicates if all tasks are completed and the objective has been achieved. Set to true when no more work is needed."),
|
|
42
|
+
});
|
|
43
|
+
export const workerInputSchema = z.object({
|
|
44
|
+
objective: z.string().describe("The user's overall objective."),
|
|
45
|
+
task: z.string().describe("The specific task assigned to the worker for execution."),
|
|
46
|
+
executionState: executionStateSchema,
|
|
47
|
+
});
|
|
48
|
+
export const workerOutputSchema = z.object({
|
|
49
|
+
result: z
|
|
50
|
+
.string()
|
|
51
|
+
.optional()
|
|
52
|
+
.describe("The text result or output produced by executing the task. Include key findings, data retrieved, or actions taken. Can be omitted if the task failed with no partial results."),
|
|
53
|
+
success: z
|
|
54
|
+
.boolean()
|
|
55
|
+
.describe("Whether the task completed successfully. Set to true if the task achieved its goal, false if it encountered errors or could not be completed."),
|
|
56
|
+
error: z
|
|
57
|
+
.object({
|
|
58
|
+
message: z
|
|
59
|
+
.string()
|
|
60
|
+
.describe("A clear description of what went wrong, including error type and relevant context to help with debugging or retry strategies."),
|
|
61
|
+
})
|
|
62
|
+
.optional()
|
|
63
|
+
.describe("Error details if the task failed. Only include when success is false."),
|
|
64
|
+
});
|
|
65
|
+
export const completerInputSchema = z.object({
|
|
66
|
+
objective: z.string().describe("The user's overall objective."),
|
|
67
|
+
executionState: executionStateSchema,
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Default maximum number of task execution iterations
|
|
71
|
+
*/
|
|
72
|
+
export const DEFAULT_MAX_ITERATIONS = 20;
|
|
73
|
+
export const stateManagementOptionsSchema = z.object({
|
|
74
|
+
maxTokens: optionalize(z.number().int().positive()),
|
|
75
|
+
keepRecent: optionalize(z.number().int().positive()),
|
|
76
|
+
maxIterations: optionalize(z.number().int().positive()),
|
|
77
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/agent-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0-beta",
|
|
4
4
|
"description": "Collection of agent libraries for AIGNE framework",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -29,9 +29,14 @@
|
|
|
29
29
|
"types": "./lib/dts/index.d.ts",
|
|
30
30
|
"exports": {
|
|
31
31
|
"./*": {
|
|
32
|
-
"import": "./lib/esm
|
|
33
|
-
"require": "./lib/cjs
|
|
32
|
+
"import": "./lib/esm/*/index.js",
|
|
33
|
+
"require": "./lib/cjs/*/index.js",
|
|
34
34
|
"types": "./lib/dts/*"
|
|
35
|
+
},
|
|
36
|
+
"./utils/*": {
|
|
37
|
+
"import": "./lib/esm/utils/*",
|
|
38
|
+
"require": "./lib/cjs/utils/*",
|
|
39
|
+
"types": "./lib/dts/utils/*"
|
|
35
40
|
}
|
|
36
41
|
},
|
|
37
42
|
"typesVersions": {
|
|
@@ -49,9 +54,10 @@
|
|
|
49
54
|
"jsonschema": "^1.5.0",
|
|
50
55
|
"yaml": "^2.8.1",
|
|
51
56
|
"zod": "^3.25.67",
|
|
52
|
-
"
|
|
53
|
-
"@aigne/core": "^1.
|
|
54
|
-
"@aigne/openai": "^0.16.
|
|
57
|
+
"zod-to-json-schema": "^3.24.6",
|
|
58
|
+
"@aigne/core": "^1.71.0-beta",
|
|
59
|
+
"@aigne/openai": "^0.16.15-beta",
|
|
60
|
+
"@aigne/sqlite": "^0.4.7"
|
|
55
61
|
},
|
|
56
62
|
"devDependencies": {
|
|
57
63
|
"@types/bun": "^1.2.22",
|