@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
|
@@ -1,50 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export * from "./orchestrator-prompts.js";
|
|
7
|
-
/**
|
|
8
|
-
* Represents a complete plan with execution results
|
|
9
|
-
* @hidden
|
|
10
|
-
*/
|
|
11
|
-
export interface FullPlanWithResult {
|
|
12
|
-
/**
|
|
13
|
-
* The overall objective
|
|
14
|
-
*/
|
|
15
|
-
objective: string;
|
|
16
|
-
/**
|
|
17
|
-
* The generated complete plan
|
|
18
|
-
*/
|
|
19
|
-
plan?: FullPlanOutput;
|
|
20
|
-
/**
|
|
21
|
-
* List of executed steps with their results
|
|
22
|
-
*/
|
|
23
|
-
steps: StepWithResult[];
|
|
24
|
-
/**
|
|
25
|
-
* Final result
|
|
26
|
-
*/
|
|
27
|
-
result?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Plan completion status
|
|
30
|
-
*/
|
|
31
|
-
status?: boolean;
|
|
32
|
-
}
|
|
1
|
+
import { type AgentInvokeOptions, type AgentOptions, AIAgent, type AIAgentOptions, type Message, type PromptBuilder } from "@aigne/core";
|
|
2
|
+
import { type Instructions, type NestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
|
|
3
|
+
import { type LoadOptions } from "@aigne/core/loader/index.js";
|
|
4
|
+
import { type StateManagementOptions } from "./type.js";
|
|
33
5
|
/**
|
|
34
6
|
* Configuration options for the Orchestrator Agent
|
|
35
7
|
*/
|
|
36
|
-
export interface OrchestratorAgentOptions<I extends Message = Message, O extends Message = Message> extends
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
maxIterations?: number;
|
|
8
|
+
export interface OrchestratorAgentOptions<I extends Message = Message, O extends Message = Message> extends Omit<AIAgentOptions<I, O>, "instructions"> {
|
|
9
|
+
objective: PromptBuilder;
|
|
10
|
+
planner?: OrchestratorAgent<I, O>["planner"];
|
|
11
|
+
worker?: OrchestratorAgent<I, O>["worker"];
|
|
12
|
+
completer?: OrchestratorAgent<I, O>["completer"];
|
|
42
13
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
14
|
+
* Configuration for managing execution state
|
|
15
|
+
* Prevents context overflow during long-running executions
|
|
45
16
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
17
|
+
stateManagement?: StateManagementOptions;
|
|
18
|
+
}
|
|
19
|
+
export interface LoadOrchestratorAgentOptions<I extends Message = Message, O extends Message = Message> extends Omit<AIAgentOptions<I, O>, "instructions"> {
|
|
20
|
+
objective: string | PromptBuilder | Instructions;
|
|
21
|
+
planner?: NestAgentSchema | {
|
|
22
|
+
instructions?: string | PromptBuilder | Instructions;
|
|
23
|
+
};
|
|
24
|
+
worker?: NestAgentSchema | {
|
|
25
|
+
instructions?: string | PromptBuilder | Instructions;
|
|
26
|
+
};
|
|
27
|
+
completer?: NestAgentSchema | {
|
|
28
|
+
instructions?: string | PromptBuilder | Instructions;
|
|
29
|
+
};
|
|
30
|
+
stateManagement?: StateManagementOptions;
|
|
48
31
|
}
|
|
49
32
|
/**
|
|
50
33
|
* Orchestrator Agent Class
|
|
@@ -61,8 +44,13 @@ export interface OrchestratorAgentOptions<I extends Message = Message, O extends
|
|
|
61
44
|
* - Executes tasks and steps according to the plan
|
|
62
45
|
* - Synthesizes final result through completer
|
|
63
46
|
*/
|
|
64
|
-
export declare class OrchestratorAgent<I extends Message = Message, O extends Message = Message> extends
|
|
47
|
+
export declare class OrchestratorAgent<I extends Message = Message, O extends Message = Message> extends AIAgent<I, O> {
|
|
65
48
|
tag: string;
|
|
49
|
+
static load<I extends Message = Message, O extends Message = Message>({ filepath, parsed, options, }: {
|
|
50
|
+
filepath: string;
|
|
51
|
+
parsed: AgentOptions<I, O> & LoadOrchestratorAgentOptions<I, O>;
|
|
52
|
+
options?: LoadOptions;
|
|
53
|
+
}): Promise<OrchestratorAgent<I, O>>;
|
|
66
54
|
/**
|
|
67
55
|
* Factory method to create an OrchestratorAgent instance
|
|
68
56
|
* @param options - Configuration options for the Orchestrator Agent
|
|
@@ -74,36 +62,16 @@ export declare class OrchestratorAgent<I extends Message = Message, O extends Me
|
|
|
74
62
|
* @param options - Configuration options for the Orchestrator Agent
|
|
75
63
|
*/
|
|
76
64
|
constructor(options: OrchestratorAgentOptions<I, O>);
|
|
65
|
+
private objective;
|
|
77
66
|
private planner;
|
|
67
|
+
private worker;
|
|
78
68
|
private completer;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Maximum number of iterations
|
|
82
|
-
* Prevents infinite execution loops
|
|
83
|
-
*/
|
|
84
|
-
maxIterations?: number;
|
|
85
|
-
/**
|
|
86
|
-
* Number of concurrent tasks
|
|
87
|
-
* Controls how many tasks can be executed simultaneously
|
|
88
|
-
*/
|
|
89
|
-
tasksConcurrency?: number;
|
|
69
|
+
private stateManagement?;
|
|
90
70
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* Workflow:
|
|
94
|
-
* 1. Extract the objective
|
|
95
|
-
* 2. Loop until plan completion or maximum iterations:
|
|
96
|
-
* a. Generate/update execution plan
|
|
97
|
-
* b. If plan is complete, synthesize result
|
|
98
|
-
* c. Otherwise, execute steps in the plan
|
|
99
|
-
*
|
|
100
|
-
* @param input - Input message containing the objective
|
|
101
|
-
* @param options - Agent invocation options
|
|
102
|
-
* @returns Processing result
|
|
71
|
+
* Compress execution state to prevent context overflow
|
|
72
|
+
* Uses reverse accumulation to efficiently find optimal task count
|
|
103
73
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
private getFullPlan;
|
|
107
|
-
private synthesizePlanResult;
|
|
108
|
-
private executeStep;
|
|
74
|
+
private compressState;
|
|
75
|
+
process(input: I, options: AgentInvokeOptions): AsyncGenerator<import("@aigne/core").AgentResponseChunk<O>, void, unknown>;
|
|
109
76
|
}
|
|
77
|
+
export default OrchestratorAgent;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const ORCHESTRATOR_COMPLETE_PROMPT = "You are an intelligent assistant that synthesizes and presents the results of completed tasks.\n\n## User Objective\n{{ objective }}\n\n## Execution Results\n{{ executionState | yaml.stringify }}\n\n## Your Task\nBased on the execution results above, provide a comprehensive and helpful response to the user's objective.\n";
|
|
2
|
+
export declare const TODO_PLANNER_PROMPT_TEMPLATE = "You are an intelligent task planner that determines what needs to be done next to achieve the user's objective.\n\n## Your Role\nContinuously evaluate progress and decide the next task to execute. You work iteratively - planning one task at a time based on the current state and previous results.\n\n## Available Skills\n{{ skills | yaml.stringify }}\n\n## User Objective\n{{ objective }}\n\n## Current State\n{{ executionState | yaml.stringify }}\n\n## Understanding Task Status\nEach task in the execution state has a status:\n- **completed**: Task finished successfully, result is available\n- **failed**: Task encountered an error, check error field for details\n- **pending**: Task has not been executed yet\n\n## Your Task\nBased on the objective, current state, and any previous results, determine what should happen next:\n\n1. **If the objective is achieved or all work is complete:** Set finished: true and leave nextTask empty\n2. **If a previous task failed:** Decide whether to retry, skip, or use an alternative approach\n3. **If more work is needed:** Provide a clear, actionable nextTask description\n\n### Guidelines:\n- Focus on the immediate next step, not the entire plan\n- Review task history to avoid repeating work and build on previous results\n- Pay attention to task status - handle failures appropriately\n- Write self-contained task descriptions that the worker can execute independently\n- Set finished: true when the objective is satisfied\n- Consider retrying failed tasks with different approaches if appropriate\n";
|
|
3
|
+
export declare const TODO_WORKER_PROMPT_TEMPLATE = "You are a task execution agent. Your job is to execute the specific task assigned to you - nothing more, nothing less.\n\n## Overall Objective (For Context Only)\n{{ objective }}\n\n**CRITICAL CONSTRAINT**: The objective above is provided ONLY for context. You must NOT attempt to:\n- Solve the entire objective\n- Plan additional steps beyond your current task\n- Make decisions about what should happen next\n- Execute any tasks other than the one explicitly assigned to you below\n\nYour SOLE responsibility is to execute the specific task described below and return the result.\n\n## Current Execution State\n{{ executionState | yaml.stringify }}\n\n## Your Current Task\n{{ task }}\n\n## Important Instructions\n- Focus EXCLUSIVELY on completing the current task described above\n- The task is self-contained - execute it completely and accurately\n- Do NOT perform additional tasks beyond what is specified\n- Do NOT try to determine what should happen after this task\n- Use the available tools and skills to accomplish this specific task\n- Return a clear result that the planner can use to decide the next step\n\n## Output Format\nReturn your task execution result as a structured response. The output schema will guide you on the required fields.\n";
|
|
@@ -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
|
+
}>;
|