@dexto/orchestration 1.5.8 → 1.6.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/condition-engine.d.ts +6 -8
- package/dist/condition-engine.d.ts.map +1 -0
- package/dist/index.cjs +0 -9
- package/dist/index.d.cts +615 -11
- package/dist/index.d.ts +41 -10
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -18
- package/dist/signal-bus.d.ts +5 -8
- package/dist/signal-bus.d.ts.map +1 -0
- package/dist/task-registry.d.ts +5 -8
- package/dist/task-registry.d.ts.map +1 -0
- package/dist/tools/check-task.cjs +10 -4
- package/dist/tools/check-task.d.ts +8 -14
- package/dist/tools/check-task.d.ts.map +1 -0
- package/dist/tools/check-task.js +10 -4
- package/dist/tools/index.cjs +0 -8
- package/dist/tools/index.d.ts +15 -10
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +0 -5
- package/dist/tools/list-tasks.cjs +17 -5
- package/dist/tools/list-tasks.d.ts +10 -15
- package/dist/tools/list-tasks.d.ts.map +1 -0
- package/dist/tools/list-tasks.js +17 -5
- package/dist/tools/wait-for.cjs +13 -4
- package/dist/tools/wait-for.d.ts +8 -14
- package/dist/tools/wait-for.d.ts.map +1 -0
- package/dist/tools/wait-for.js +13 -4
- package/dist/types.d.ts +14 -15
- package/dist/types.d.ts.map +1 -0
- package/package.json +4 -3
- package/dist/agent-controller.cjs +0 -265
- package/dist/agent-controller.d.cts +0 -116
- package/dist/agent-controller.d.ts +0 -116
- package/dist/agent-controller.js +0 -241
- package/dist/condition-engine.d.cts +0 -87
- package/dist/signal-bus.d.cts +0 -78
- package/dist/task-registry.d.cts +0 -124
- package/dist/tools/check-task.d.cts +0 -56
- package/dist/tools/index.d.cts +0 -10
- package/dist/tools/list-tasks.d.cts +0 -64
- package/dist/tools/start-task.cjs +0 -149
- package/dist/tools/start-task.d.cts +0 -102
- package/dist/tools/start-task.d.ts +0 -102
- package/dist/tools/start-task.js +0 -123
- package/dist/tools/types.cjs +0 -16
- package/dist/tools/types.d.cts +0 -30
- package/dist/tools/types.d.ts +0 -30
- package/dist/tools/types.js +0 -0
- package/dist/tools/wait-for.d.cts +0 -74
- package/dist/types.d.cts +0 -165
package/dist/agent-controller.js
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { SignalBus } from "./signal-bus.js";
|
|
2
|
-
import { TaskRegistry } from "./task-registry.js";
|
|
3
|
-
import { ConditionEngine } from "./condition-engine.js";
|
|
4
|
-
class AgentController {
|
|
5
|
-
agent;
|
|
6
|
-
logger;
|
|
7
|
-
state = "idle";
|
|
8
|
-
sessionId;
|
|
9
|
-
/** Signal bus for event routing */
|
|
10
|
-
signalBus;
|
|
11
|
-
/** Task registry for tracking background tasks */
|
|
12
|
-
taskRegistry;
|
|
13
|
-
/** Condition engine for evaluating wait conditions */
|
|
14
|
-
conditionEngine;
|
|
15
|
-
/** Signals that arrived while agent was busy */
|
|
16
|
-
pendingSignals = [];
|
|
17
|
-
/** Unsubscribe function for notify listener */
|
|
18
|
-
notifyUnsubscribe;
|
|
19
|
-
constructor(config) {
|
|
20
|
-
this.agent = config.agent;
|
|
21
|
-
if (config.logger) {
|
|
22
|
-
this.logger = config.logger;
|
|
23
|
-
}
|
|
24
|
-
this.sessionId = config.sessionId ?? `session-${Date.now()}`;
|
|
25
|
-
this.signalBus = new SignalBus();
|
|
26
|
-
this.taskRegistry = new TaskRegistry(this.signalBus, config.taskRegistry);
|
|
27
|
-
this.conditionEngine = new ConditionEngine(this.taskRegistry, this.signalBus, this.logger);
|
|
28
|
-
this.setupNotifyListener();
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Set up listener for tasks with notify=true
|
|
32
|
-
*/
|
|
33
|
-
setupNotifyListener() {
|
|
34
|
-
this.notifyUnsubscribe = this.signalBus.onAny((signal) => {
|
|
35
|
-
if (signal.type === "task:completed" || signal.type === "task:failed" || signal.type === "task:cancelled") {
|
|
36
|
-
const entry = this.taskRegistry.get(signal.taskId);
|
|
37
|
-
if (entry?.notify) {
|
|
38
|
-
if (this.state === "idle") {
|
|
39
|
-
this.logger?.debug(`Auto-notify triggered for task ${signal.taskId}`);
|
|
40
|
-
void this.processNotify(signal).catch((error) => {
|
|
41
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
42
|
-
const signalContext = `signal.type=${signal.type} taskId=${signal.taskId}`;
|
|
43
|
-
this.logger?.error?.(
|
|
44
|
-
`AgentController.processNotify failed for ${signalContext}: ${message}`
|
|
45
|
-
);
|
|
46
|
-
});
|
|
47
|
-
} else {
|
|
48
|
-
this.pendingSignals.push(signal);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Process an auto-notify task completion
|
|
56
|
-
*/
|
|
57
|
-
async processNotify(signal) {
|
|
58
|
-
if (this.state !== "idle") {
|
|
59
|
-
this.pendingSignals.push(signal);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
this.state = "processing";
|
|
64
|
-
const taskInfo = signal.type === "task:completed" || signal.type === "task:failed" || signal.type === "task:cancelled" ? this.taskRegistry.getInfo(signal.taskId) : void 0;
|
|
65
|
-
const contextMessage = this.buildNotifyContext(signal, taskInfo);
|
|
66
|
-
await this.agent.generate(contextMessage, this.sessionId);
|
|
67
|
-
if (taskInfo) {
|
|
68
|
-
this.taskRegistry.acknowledgeNotify([taskInfo.taskId]);
|
|
69
|
-
}
|
|
70
|
-
} finally {
|
|
71
|
-
this.state = "idle";
|
|
72
|
-
this.processPendingSignals();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Build context message for auto-notify
|
|
77
|
-
*/
|
|
78
|
-
buildNotifyContext(signal, taskInfo) {
|
|
79
|
-
if (signal.type === "task:completed" && taskInfo) {
|
|
80
|
-
const resultStr = typeof taskInfo.result === "string" ? taskInfo.result : JSON.stringify(taskInfo.result, null, 2);
|
|
81
|
-
const durationLine = taskInfo.duration !== void 0 ? `Duration: ${taskInfo.duration}ms
|
|
82
|
-
` : "";
|
|
83
|
-
return `[Background Task Completed]
|
|
84
|
-
Task ID: ${taskInfo.taskId}
|
|
85
|
-
Type: ${taskInfo.type}
|
|
86
|
-
Description: ${taskInfo.description}
|
|
87
|
-
` + durationLine + `Result:
|
|
88
|
-
${resultStr}`;
|
|
89
|
-
}
|
|
90
|
-
if (signal.type === "task:failed" && taskInfo) {
|
|
91
|
-
return `[Background Task Failed]
|
|
92
|
-
Task ID: ${taskInfo.taskId}
|
|
93
|
-
Type: ${taskInfo.type}
|
|
94
|
-
Description: ${taskInfo.description}
|
|
95
|
-
Error: ${taskInfo.error}`;
|
|
96
|
-
}
|
|
97
|
-
if (signal.type === "task:cancelled" && taskInfo) {
|
|
98
|
-
const cancelReason = taskInfo.error ?? "Cancelled";
|
|
99
|
-
return `[Background Task Cancelled]
|
|
100
|
-
Task ID: ${taskInfo.taskId}
|
|
101
|
-
Type: ${taskInfo.type}
|
|
102
|
-
Description: ${taskInfo.description}
|
|
103
|
-
Reason: ${cancelReason}`;
|
|
104
|
-
}
|
|
105
|
-
return `[Background Signal]
|
|
106
|
-
${JSON.stringify(signal, null, 2)}`;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Process any pending signals
|
|
110
|
-
*/
|
|
111
|
-
processPendingSignals() {
|
|
112
|
-
while (this.pendingSignals.length > 0 && this.state === "idle") {
|
|
113
|
-
const signal = this.pendingSignals.shift();
|
|
114
|
-
if (signal) {
|
|
115
|
-
void this.processNotify(signal).catch((error) => {
|
|
116
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
117
|
-
const signalContext = signal.type === "task:completed" || signal.type === "task:failed" || signal.type === "task:cancelled" ? `signal.type=${signal.type} taskId=${signal.taskId}` : `signal.type=${signal.type}`;
|
|
118
|
-
this.logger?.error?.(
|
|
119
|
-
`AgentController.processNotify failed for ${signalContext}: ${message}`
|
|
120
|
-
);
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Process user input and generate response
|
|
127
|
-
* @param content User message content
|
|
128
|
-
* @returns Agent response
|
|
129
|
-
*/
|
|
130
|
-
async process(content) {
|
|
131
|
-
if (this.state !== "idle") {
|
|
132
|
-
throw new Error(`Cannot process while agent is ${this.state}`);
|
|
133
|
-
}
|
|
134
|
-
try {
|
|
135
|
-
this.state = "processing";
|
|
136
|
-
const { contextPrefix, notifyTaskIds } = this.buildTaskContext();
|
|
137
|
-
const fullContent = contextPrefix ? `${contextPrefix}
|
|
138
|
-
|
|
139
|
-
${content}` : content;
|
|
140
|
-
const response = await this.agent.generate(fullContent, this.sessionId);
|
|
141
|
-
if (notifyTaskIds.length > 0) {
|
|
142
|
-
this.taskRegistry.acknowledgeNotify(notifyTaskIds);
|
|
143
|
-
}
|
|
144
|
-
return response.content;
|
|
145
|
-
} finally {
|
|
146
|
-
this.state = "idle";
|
|
147
|
-
this.processPendingSignals();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Process a signal trigger (e.g., from external source)
|
|
152
|
-
*/
|
|
153
|
-
async processSignal(signal) {
|
|
154
|
-
if (this.state !== "idle") {
|
|
155
|
-
this.pendingSignals.push(signal);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
await this.processNotify(signal);
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Build context about pending/completed tasks
|
|
162
|
-
*/
|
|
163
|
-
buildTaskContext() {
|
|
164
|
-
const running = this.taskRegistry.list({ status: "running" });
|
|
165
|
-
const notifyPending = this.taskRegistry.getNotifyPending();
|
|
166
|
-
if (running.length === 0 && notifyPending.length === 0) {
|
|
167
|
-
return { contextPrefix: "", notifyTaskIds: [] };
|
|
168
|
-
}
|
|
169
|
-
const parts = [];
|
|
170
|
-
if (running.length > 0) {
|
|
171
|
-
parts.push(
|
|
172
|
-
`[Background Tasks Running: ${running.length}]
|
|
173
|
-
` + running.map((t) => `- ${t.taskId}: ${t.description}`).join("\n")
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
if (notifyPending.length > 0) {
|
|
177
|
-
parts.push(
|
|
178
|
-
`[Background Tasks Completed: ${notifyPending.length}]
|
|
179
|
-
` + notifyPending.map((t) => {
|
|
180
|
-
const status = t.error ? `FAILED: ${t.error}` : t.status === "cancelled" ? "CANCELLED" : "SUCCESS";
|
|
181
|
-
return `- ${t.taskId}: ${t.description} [${status}]`;
|
|
182
|
-
}).join("\n")
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
return {
|
|
186
|
-
contextPrefix: parts.join("\n\n"),
|
|
187
|
-
notifyTaskIds: notifyPending.map((task) => task.taskId)
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Get current agent state
|
|
192
|
-
*/
|
|
193
|
-
getState() {
|
|
194
|
-
return this.state;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Get the wrapped agent
|
|
198
|
-
*/
|
|
199
|
-
getAgent() {
|
|
200
|
-
return this.agent;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Get session ID
|
|
204
|
-
*/
|
|
205
|
-
getSessionId() {
|
|
206
|
-
return this.sessionId;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Inject a signal for processing
|
|
210
|
-
*/
|
|
211
|
-
injectSignal(signal) {
|
|
212
|
-
this.signalBus.emit(signal);
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Clean up resources
|
|
216
|
-
*/
|
|
217
|
-
cleanup() {
|
|
218
|
-
if (this.notifyUnsubscribe) {
|
|
219
|
-
this.notifyUnsubscribe();
|
|
220
|
-
}
|
|
221
|
-
this.pendingSignals = [];
|
|
222
|
-
this.signalBus.clear();
|
|
223
|
-
this.taskRegistry.clear();
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Start the agent (delegates to wrapped agent)
|
|
227
|
-
*/
|
|
228
|
-
async start() {
|
|
229
|
-
await this.agent.start();
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Stop the agent (delegates to wrapped agent)
|
|
233
|
-
*/
|
|
234
|
-
async stop() {
|
|
235
|
-
this.cleanup();
|
|
236
|
-
await this.agent.stop();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
export {
|
|
240
|
-
AgentController
|
|
241
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { WaitCondition, WaitResult } from './types.cjs';
|
|
2
|
-
import { SignalBus } from './signal-bus.cjs';
|
|
3
|
-
import { TaskRegistry } from './task-registry.cjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* ConditionEngine
|
|
7
|
-
*
|
|
8
|
-
* Evaluates wait conditions and resolves when met.
|
|
9
|
-
* Supports single task, any/all of multiple tasks, timeouts, and races.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
type LoggerLike = {
|
|
13
|
-
debug: (message: string) => void;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* ConditionEngine - Evaluates composable wait conditions
|
|
17
|
-
*/
|
|
18
|
-
declare class ConditionEngine {
|
|
19
|
-
private taskRegistry;
|
|
20
|
-
private signalBus;
|
|
21
|
-
private logger?;
|
|
22
|
-
constructor(taskRegistry: TaskRegistry, signalBus: SignalBus, logger?: LoggerLike | undefined);
|
|
23
|
-
/**
|
|
24
|
-
* Wait for a condition to be met
|
|
25
|
-
* @param condition Wait condition to evaluate
|
|
26
|
-
* @returns Promise resolving to the signal(s) that satisfied the condition
|
|
27
|
-
*/
|
|
28
|
-
wait(condition: WaitCondition): Promise<WaitResult>;
|
|
29
|
-
/**
|
|
30
|
-
* Check if a condition is already satisfied (non-blocking)
|
|
31
|
-
* @returns WaitResult if satisfied, null if not
|
|
32
|
-
*/
|
|
33
|
-
check(condition: WaitCondition): WaitResult | null;
|
|
34
|
-
/**
|
|
35
|
-
* Check if a single task is completed
|
|
36
|
-
*/
|
|
37
|
-
private checkTask;
|
|
38
|
-
/**
|
|
39
|
-
* Check if any of the conditions is satisfied
|
|
40
|
-
*/
|
|
41
|
-
private checkAny;
|
|
42
|
-
/**
|
|
43
|
-
* Check if all conditions are satisfied
|
|
44
|
-
*/
|
|
45
|
-
private checkAll;
|
|
46
|
-
/**
|
|
47
|
-
* Evaluate a condition asynchronously
|
|
48
|
-
*/
|
|
49
|
-
private evaluate;
|
|
50
|
-
/**
|
|
51
|
-
* Wait for a single task to complete
|
|
52
|
-
*
|
|
53
|
-
* Uses subscribe-then-check pattern to avoid race conditions where
|
|
54
|
-
* the task completes between checking and subscribing.
|
|
55
|
-
*/
|
|
56
|
-
private evaluateTask;
|
|
57
|
-
/**
|
|
58
|
-
* Wait for any of the conditions to be satisfied
|
|
59
|
-
*/
|
|
60
|
-
private evaluateAny;
|
|
61
|
-
/**
|
|
62
|
-
* Wait for all conditions to be satisfied
|
|
63
|
-
*/
|
|
64
|
-
private evaluateAll;
|
|
65
|
-
/**
|
|
66
|
-
* Wait for a timeout
|
|
67
|
-
*/
|
|
68
|
-
private evaluateTimeout;
|
|
69
|
-
/**
|
|
70
|
-
* Race a task condition against a timeout
|
|
71
|
-
*/
|
|
72
|
-
private evaluateRace;
|
|
73
|
-
/**
|
|
74
|
-
* Helper to create a race condition with timeout
|
|
75
|
-
*/
|
|
76
|
-
static createRaceWithTimeout(taskId: string, timeoutMs: number): WaitCondition;
|
|
77
|
-
/**
|
|
78
|
-
* Helper to create an 'any' condition from task IDs
|
|
79
|
-
*/
|
|
80
|
-
static createAnyTask(taskIds: string[]): WaitCondition;
|
|
81
|
-
/**
|
|
82
|
-
* Helper to create an 'all' condition from task IDs
|
|
83
|
-
*/
|
|
84
|
-
static createAllTasks(taskIds: string[]): WaitCondition;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { ConditionEngine };
|
package/dist/signal-bus.d.cts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Signal, SignalType } from './types.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* SignalBus
|
|
5
|
-
*
|
|
6
|
-
* Event emitter for routing orchestration signals.
|
|
7
|
-
* Supports typed subscriptions and promise-based waiting.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Handler function for signal subscriptions
|
|
12
|
-
*/
|
|
13
|
-
type SignalHandler<T extends Signal = Signal> = (signal: T) => void;
|
|
14
|
-
/**
|
|
15
|
-
* Predicate function for filtering signals
|
|
16
|
-
*/
|
|
17
|
-
type SignalPredicate = (signal: Signal) => boolean;
|
|
18
|
-
/**
|
|
19
|
-
* SignalBus - Routes signals between orchestration components
|
|
20
|
-
*/
|
|
21
|
-
declare class SignalBus {
|
|
22
|
-
private emitter;
|
|
23
|
-
constructor();
|
|
24
|
-
/**
|
|
25
|
-
* Emit a signal to all subscribers
|
|
26
|
-
*/
|
|
27
|
-
emit(signal: Signal): void;
|
|
28
|
-
/**
|
|
29
|
-
* Subscribe to signals of a specific type
|
|
30
|
-
* @returns Unsubscribe function
|
|
31
|
-
*/
|
|
32
|
-
on<T extends SignalType>(type: T, handler: SignalHandler<Extract<Signal, {
|
|
33
|
-
type: T;
|
|
34
|
-
}>>): () => void;
|
|
35
|
-
/**
|
|
36
|
-
* Subscribe to all signals
|
|
37
|
-
* @returns Unsubscribe function
|
|
38
|
-
*/
|
|
39
|
-
onAny(handler: SignalHandler): () => void;
|
|
40
|
-
/**
|
|
41
|
-
* Subscribe to a signal type once
|
|
42
|
-
*/
|
|
43
|
-
once<T extends SignalType>(type: T, handler: SignalHandler<Extract<Signal, {
|
|
44
|
-
type: T;
|
|
45
|
-
}>>): void;
|
|
46
|
-
/**
|
|
47
|
-
* Remove a specific handler
|
|
48
|
-
*/
|
|
49
|
-
off<T extends SignalType>(type: T, handler: SignalHandler<Extract<Signal, {
|
|
50
|
-
type: T;
|
|
51
|
-
}>>): void;
|
|
52
|
-
/**
|
|
53
|
-
* Wait for a signal matching the predicate
|
|
54
|
-
* @param predicate Function to test signals
|
|
55
|
-
* @param timeout Optional timeout in milliseconds
|
|
56
|
-
* @returns Promise that resolves with the matching signal
|
|
57
|
-
*/
|
|
58
|
-
waitFor(predicate: SignalPredicate, timeout?: number): Promise<Signal>;
|
|
59
|
-
/**
|
|
60
|
-
* Wait for a signal for a specific task
|
|
61
|
-
*/
|
|
62
|
-
waitForTask(taskId: string, timeout?: number): Promise<Signal>;
|
|
63
|
-
/**
|
|
64
|
-
* Wait for any of multiple tasks to complete
|
|
65
|
-
*/
|
|
66
|
-
waitForAnyTask(taskIds: string[], timeout?: number): Promise<Signal>;
|
|
67
|
-
/**
|
|
68
|
-
* Wait for all tasks to complete
|
|
69
|
-
* @returns Promise that resolves with all signals
|
|
70
|
-
*/
|
|
71
|
-
waitForAllTasks(taskIds: string[], timeout?: number, resolveInitial?: (taskId: string) => Signal | undefined): Promise<Signal[]>;
|
|
72
|
-
/**
|
|
73
|
-
* Remove all listeners
|
|
74
|
-
*/
|
|
75
|
-
clear(): void;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export { SignalBus, type SignalHandler, type SignalPredicate };
|
package/dist/task-registry.d.cts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { Task, RegisterTaskOptions, TaskEntry, TaskStatus, TaskInfo, TaskFilter } from './types.cjs';
|
|
2
|
-
import { SignalBus } from './signal-bus.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TaskRegistry
|
|
6
|
-
*
|
|
7
|
-
* Tracks all background tasks and their results.
|
|
8
|
-
* Emits signals on task completion for the ConditionEngine.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Configuration for TaskRegistry
|
|
13
|
-
*/
|
|
14
|
-
interface TaskRegistryConfig {
|
|
15
|
-
/** Maximum number of concurrent tasks (default: 20) */
|
|
16
|
-
maxTasks?: number;
|
|
17
|
-
/** TTL for completed task results in ms (default: 5 minutes) */
|
|
18
|
-
resultTTL?: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* TaskRegistry - Manages background task lifecycle
|
|
22
|
-
*/
|
|
23
|
-
declare class TaskRegistry {
|
|
24
|
-
private tasks;
|
|
25
|
-
private signalBus;
|
|
26
|
-
private config;
|
|
27
|
-
constructor(signalBus: SignalBus, config?: TaskRegistryConfig);
|
|
28
|
-
/**
|
|
29
|
-
* Generate a unique task ID
|
|
30
|
-
*/
|
|
31
|
-
private generateTaskId;
|
|
32
|
-
/**
|
|
33
|
-
* Get description from task for display
|
|
34
|
-
*/
|
|
35
|
-
private getTaskDescription;
|
|
36
|
-
/**
|
|
37
|
-
* Register a new task and start tracking it
|
|
38
|
-
* @param task Task to register (must include promise)
|
|
39
|
-
* @param options Registration options
|
|
40
|
-
* @returns Task ID
|
|
41
|
-
*/
|
|
42
|
-
register(task: Task, options?: RegisterTaskOptions): string;
|
|
43
|
-
/**
|
|
44
|
-
* Create and register an agent task
|
|
45
|
-
*
|
|
46
|
-
* Note: Uses agentId as the taskId so the caller can use the same ID
|
|
47
|
-
* for wait_for/check_task operations.
|
|
48
|
-
*/
|
|
49
|
-
registerAgentTask(agentId: string, taskDescription: string, promise: Promise<unknown>, options?: RegisterTaskOptions): string;
|
|
50
|
-
/**
|
|
51
|
-
* Create and register a process task
|
|
52
|
-
*/
|
|
53
|
-
registerProcessTask(processId: string, command: string, promise: Promise<unknown>, options?: RegisterTaskOptions): string;
|
|
54
|
-
/**
|
|
55
|
-
* Create and register a generic task
|
|
56
|
-
*/
|
|
57
|
-
registerGenericTask(description: string, promise: Promise<unknown>, options?: RegisterTaskOptions): string;
|
|
58
|
-
/**
|
|
59
|
-
* Called when a task completes successfully
|
|
60
|
-
*/
|
|
61
|
-
private onTaskComplete;
|
|
62
|
-
/**
|
|
63
|
-
* Called when a task fails
|
|
64
|
-
*/
|
|
65
|
-
private onTaskFailed;
|
|
66
|
-
/**
|
|
67
|
-
* Cancel a running task
|
|
68
|
-
*/
|
|
69
|
-
cancel(taskId: string): void;
|
|
70
|
-
/**
|
|
71
|
-
* Get task entry by ID
|
|
72
|
-
*/
|
|
73
|
-
get(taskId: string): TaskEntry | undefined;
|
|
74
|
-
/**
|
|
75
|
-
* Get task status
|
|
76
|
-
*/
|
|
77
|
-
getStatus(taskId: string): TaskStatus | undefined;
|
|
78
|
-
/**
|
|
79
|
-
* Get task result (if completed)
|
|
80
|
-
*/
|
|
81
|
-
getResult(taskId: string): {
|
|
82
|
-
status: TaskStatus;
|
|
83
|
-
result?: unknown;
|
|
84
|
-
error?: string;
|
|
85
|
-
} | undefined;
|
|
86
|
-
/**
|
|
87
|
-
* Get task info (safe for serialization - no promise)
|
|
88
|
-
*/
|
|
89
|
-
getInfo(taskId: string): TaskInfo | undefined;
|
|
90
|
-
/**
|
|
91
|
-
* List tasks matching filter
|
|
92
|
-
*/
|
|
93
|
-
list(filter?: TaskFilter): TaskInfo[];
|
|
94
|
-
/**
|
|
95
|
-
* Get count of running tasks
|
|
96
|
-
*/
|
|
97
|
-
getRunningCount(): number;
|
|
98
|
-
/**
|
|
99
|
-
* Get tasks that completed with notify=true and haven't been acknowledged
|
|
100
|
-
*/
|
|
101
|
-
getNotifyPending(): TaskInfo[];
|
|
102
|
-
/**
|
|
103
|
-
* Mark notify tasks as acknowledged (clear notify flag)
|
|
104
|
-
*/
|
|
105
|
-
acknowledgeNotify(taskIds: string[]): void;
|
|
106
|
-
/**
|
|
107
|
-
* Clean up old completed tasks
|
|
108
|
-
*/
|
|
109
|
-
cleanup(olderThan?: Date): number;
|
|
110
|
-
/**
|
|
111
|
-
* Clear all tasks
|
|
112
|
-
*/
|
|
113
|
-
clear(): void;
|
|
114
|
-
/**
|
|
115
|
-
* Check if a task exists
|
|
116
|
-
*/
|
|
117
|
-
has(taskId: string): boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Get total task count
|
|
120
|
-
*/
|
|
121
|
-
get size(): number;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export { TaskRegistry, type TaskRegistryConfig };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { OrchestrationTool } from './types.cjs';
|
|
3
|
-
import '../task-registry.cjs';
|
|
4
|
-
import '../types.cjs';
|
|
5
|
-
import '../signal-bus.cjs';
|
|
6
|
-
import '../condition-engine.cjs';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* check_task Tool
|
|
10
|
-
*
|
|
11
|
-
* Non-blocking status check for a background task.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Input schema for check_task tool
|
|
16
|
-
*/
|
|
17
|
-
declare const CheckTaskInputSchema: z.ZodObject<{
|
|
18
|
-
/** Task ID to check */
|
|
19
|
-
taskId: z.ZodString;
|
|
20
|
-
}, "strict", z.ZodTypeAny, {
|
|
21
|
-
taskId: string;
|
|
22
|
-
}, {
|
|
23
|
-
taskId: string;
|
|
24
|
-
}>;
|
|
25
|
-
type CheckTaskInput = z.output<typeof CheckTaskInputSchema>;
|
|
26
|
-
/**
|
|
27
|
-
* Output from check_task tool
|
|
28
|
-
*/
|
|
29
|
-
interface CheckTaskOutput {
|
|
30
|
-
/** Task ID */
|
|
31
|
-
taskId: string;
|
|
32
|
-
/** Whether task was found */
|
|
33
|
-
found: boolean;
|
|
34
|
-
/** Task type */
|
|
35
|
-
type?: 'agent' | 'process' | 'generic';
|
|
36
|
-
/** Current status */
|
|
37
|
-
status?: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
38
|
-
/** Description of what the task is doing */
|
|
39
|
-
description?: string;
|
|
40
|
-
/** When the task started */
|
|
41
|
-
startedAt?: string;
|
|
42
|
-
/** When the task completed (if done) */
|
|
43
|
-
completedAt?: string;
|
|
44
|
-
/** Duration in milliseconds (if completed) */
|
|
45
|
-
duration?: number;
|
|
46
|
-
/** Result (if completed successfully) */
|
|
47
|
-
result?: unknown;
|
|
48
|
-
/** Error message (if failed) */
|
|
49
|
-
error?: string;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Create the check_task tool
|
|
53
|
-
*/
|
|
54
|
-
declare function createCheckTaskTool(): OrchestrationTool;
|
|
55
|
-
|
|
56
|
-
export { type CheckTaskInput, CheckTaskInputSchema, type CheckTaskOutput, createCheckTaskTool };
|
package/dist/tools/index.d.cts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { StartTaskInput, StartTaskInputSchema, StartTaskOutput, TaskStarter, createGenericTaskStarter, createStartTaskTool } from './start-task.cjs';
|
|
2
|
-
export { WaitForInput, WaitForInputSchema, WaitForOutput, createWaitForTool } from './wait-for.cjs';
|
|
3
|
-
export { CheckTaskInput, CheckTaskInputSchema, CheckTaskOutput, createCheckTaskTool } from './check-task.cjs';
|
|
4
|
-
export { ListTasksInput, ListTasksInputSchema, ListTasksOutput, TaskListItem, createListTasksTool } from './list-tasks.cjs';
|
|
5
|
-
export { OrchestrationTool, OrchestrationToolContext } from './types.cjs';
|
|
6
|
-
import 'zod';
|
|
7
|
-
import '../types.cjs';
|
|
8
|
-
import '../task-registry.cjs';
|
|
9
|
-
import '../signal-bus.cjs';
|
|
10
|
-
import '../condition-engine.cjs';
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { TaskStatus } from '../types.cjs';
|
|
3
|
-
import { OrchestrationTool } from './types.cjs';
|
|
4
|
-
import '../task-registry.cjs';
|
|
5
|
-
import '../signal-bus.cjs';
|
|
6
|
-
import '../condition-engine.cjs';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* list_tasks Tool
|
|
10
|
-
*
|
|
11
|
-
* List all tracked background tasks with optional filtering.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Input schema for list_tasks tool
|
|
16
|
-
*/
|
|
17
|
-
declare const ListTasksInputSchema: z.ZodObject<{
|
|
18
|
-
/** Filter by status */
|
|
19
|
-
status: z.ZodDefault<z.ZodOptional<z.ZodEnum<["pending", "running", "completed", "failed", "cancelled", "all"]>>>;
|
|
20
|
-
/** Filter by type */
|
|
21
|
-
type: z.ZodOptional<z.ZodEnum<["agent", "process", "generic"]>>;
|
|
22
|
-
}, "strict", z.ZodTypeAny, {
|
|
23
|
-
status: "pending" | "running" | "completed" | "failed" | "cancelled" | "all";
|
|
24
|
-
type?: "agent" | "process" | "generic" | undefined;
|
|
25
|
-
}, {
|
|
26
|
-
type?: "agent" | "process" | "generic" | undefined;
|
|
27
|
-
status?: "pending" | "running" | "completed" | "failed" | "cancelled" | "all" | undefined;
|
|
28
|
-
}>;
|
|
29
|
-
type ListTasksInput = z.output<typeof ListTasksInputSchema>;
|
|
30
|
-
/**
|
|
31
|
-
* Task info in list output
|
|
32
|
-
*/
|
|
33
|
-
interface TaskListItem {
|
|
34
|
-
taskId: string;
|
|
35
|
-
type: 'agent' | 'process' | 'generic';
|
|
36
|
-
status: TaskStatus;
|
|
37
|
-
description?: string;
|
|
38
|
-
startedAt: string;
|
|
39
|
-
completedAt?: string;
|
|
40
|
-
duration?: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Output from list_tasks tool
|
|
44
|
-
*/
|
|
45
|
-
interface ListTasksOutput {
|
|
46
|
-
/** List of tasks matching filter */
|
|
47
|
-
tasks: TaskListItem[];
|
|
48
|
-
/** Total count */
|
|
49
|
-
count: number;
|
|
50
|
-
/** Counts by status */
|
|
51
|
-
counts: {
|
|
52
|
-
running: number;
|
|
53
|
-
completed: number;
|
|
54
|
-
failed: number;
|
|
55
|
-
cancelled: number;
|
|
56
|
-
pending: number;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Create the list_tasks tool
|
|
61
|
-
*/
|
|
62
|
-
declare function createListTasksTool(): OrchestrationTool;
|
|
63
|
-
|
|
64
|
-
export { type ListTasksInput, ListTasksInputSchema, type ListTasksOutput, type TaskListItem, createListTasksTool };
|