@dexto/orchestration 1.5.8

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.
Files changed (50) hide show
  1. package/LICENSE +44 -0
  2. package/dist/agent-controller.cjs +265 -0
  3. package/dist/agent-controller.d.cts +116 -0
  4. package/dist/agent-controller.d.ts +116 -0
  5. package/dist/agent-controller.js +241 -0
  6. package/dist/condition-engine.cjs +276 -0
  7. package/dist/condition-engine.d.cts +87 -0
  8. package/dist/condition-engine.d.ts +87 -0
  9. package/dist/condition-engine.js +252 -0
  10. package/dist/index.cjs +57 -0
  11. package/dist/index.d.cts +11 -0
  12. package/dist/index.d.ts +11 -0
  13. package/dist/index.js +32 -0
  14. package/dist/signal-bus.cjs +186 -0
  15. package/dist/signal-bus.d.cts +78 -0
  16. package/dist/signal-bus.d.ts +78 -0
  17. package/dist/signal-bus.js +162 -0
  18. package/dist/task-registry.cjs +345 -0
  19. package/dist/task-registry.d.cts +124 -0
  20. package/dist/task-registry.d.ts +124 -0
  21. package/dist/task-registry.js +321 -0
  22. package/dist/tools/check-task.cjs +65 -0
  23. package/dist/tools/check-task.d.cts +56 -0
  24. package/dist/tools/check-task.d.ts +56 -0
  25. package/dist/tools/check-task.js +40 -0
  26. package/dist/tools/index.cjs +51 -0
  27. package/dist/tools/index.d.cts +10 -0
  28. package/dist/tools/index.d.ts +10 -0
  29. package/dist/tools/index.js +19 -0
  30. package/dist/tools/list-tasks.cjs +80 -0
  31. package/dist/tools/list-tasks.d.cts +64 -0
  32. package/dist/tools/list-tasks.d.ts +64 -0
  33. package/dist/tools/list-tasks.js +55 -0
  34. package/dist/tools/start-task.cjs +149 -0
  35. package/dist/tools/start-task.d.cts +102 -0
  36. package/dist/tools/start-task.d.ts +102 -0
  37. package/dist/tools/start-task.js +123 -0
  38. package/dist/tools/types.cjs +16 -0
  39. package/dist/tools/types.d.cts +30 -0
  40. package/dist/tools/types.d.ts +30 -0
  41. package/dist/tools/types.js +0 -0
  42. package/dist/tools/wait-for.cjs +116 -0
  43. package/dist/tools/wait-for.d.cts +74 -0
  44. package/dist/tools/wait-for.d.ts +74 -0
  45. package/dist/tools/wait-for.js +91 -0
  46. package/dist/types.cjs +16 -0
  47. package/dist/types.d.cts +165 -0
  48. package/dist/types.d.ts +165 -0
  49. package/dist/types.js +0 -0
  50. package/package.json +38 -0
@@ -0,0 +1,124 @@
1
+ import { Task, RegisterTaskOptions, TaskEntry, TaskStatus, TaskInfo, TaskFilter } from './types.js';
2
+ import { SignalBus } from './signal-bus.js';
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 };
@@ -0,0 +1,321 @@
1
+ class TaskRegistry {
2
+ tasks = /* @__PURE__ */ new Map();
3
+ signalBus;
4
+ config;
5
+ constructor(signalBus, config = {}) {
6
+ this.signalBus = signalBus;
7
+ this.config = {
8
+ maxTasks: config.maxTasks ?? 20,
9
+ resultTTL: config.resultTTL ?? 5 * 60 * 1e3
10
+ // 5 minutes
11
+ };
12
+ }
13
+ /**
14
+ * Generate a unique task ID
15
+ */
16
+ generateTaskId() {
17
+ return `task-${Math.random().toString(36).slice(2, 10)}`;
18
+ }
19
+ /**
20
+ * Get description from task for display
21
+ */
22
+ getTaskDescription(task) {
23
+ switch (task.type) {
24
+ case "agent":
25
+ return task.taskDescription;
26
+ case "process":
27
+ return task.command;
28
+ case "generic":
29
+ return task.description;
30
+ }
31
+ }
32
+ /**
33
+ * Register a new task and start tracking it
34
+ * @param task Task to register (must include promise)
35
+ * @param options Registration options
36
+ * @returns Task ID
37
+ */
38
+ register(task, options = {}) {
39
+ const runningCount = this.getRunningCount();
40
+ if (runningCount >= this.config.maxTasks) {
41
+ throw new Error(
42
+ `Maximum concurrent tasks (${this.config.maxTasks}) exceeded. ${runningCount} tasks currently running.`
43
+ );
44
+ }
45
+ const entry = {
46
+ task,
47
+ status: "running",
48
+ startedAt: /* @__PURE__ */ new Date(),
49
+ timeoutHandle: void 0,
50
+ ...options.notify !== void 0 && { notify: options.notify }
51
+ };
52
+ this.tasks.set(task.taskId, entry);
53
+ task.promise.then((result) => {
54
+ this.onTaskComplete(task.taskId, result);
55
+ }).catch((error) => {
56
+ const errorMessage = error instanceof Error ? error.message : String(error);
57
+ this.onTaskFailed(task.taskId, errorMessage);
58
+ });
59
+ if (options.timeout !== void 0 && options.timeout > 0) {
60
+ const timeoutHandle = setTimeout(() => {
61
+ const currentEntry = this.tasks.get(task.taskId);
62
+ if (currentEntry && currentEntry.status === "running") {
63
+ this.onTaskFailed(task.taskId, `Task timed out after ${options.timeout}ms`);
64
+ }
65
+ }, options.timeout);
66
+ entry.timeoutHandle = timeoutHandle;
67
+ }
68
+ return task.taskId;
69
+ }
70
+ /**
71
+ * Create and register an agent task
72
+ *
73
+ * Note: Uses agentId as the taskId so the caller can use the same ID
74
+ * for wait_for/check_task operations.
75
+ */
76
+ registerAgentTask(agentId, taskDescription, promise, options = {}) {
77
+ const taskId = agentId;
78
+ if (this.tasks.has(taskId)) {
79
+ throw new Error(`Task '${taskId}' already exists`);
80
+ }
81
+ const task = {
82
+ type: "agent",
83
+ taskId,
84
+ agentId,
85
+ taskDescription,
86
+ promise
87
+ };
88
+ return this.register(task, options);
89
+ }
90
+ /**
91
+ * Create and register a process task
92
+ */
93
+ registerProcessTask(processId, command, promise, options = {}) {
94
+ const taskId = this.generateTaskId();
95
+ const task = {
96
+ type: "process",
97
+ taskId,
98
+ processId,
99
+ command,
100
+ promise
101
+ };
102
+ return this.register(task, options);
103
+ }
104
+ /**
105
+ * Create and register a generic task
106
+ */
107
+ registerGenericTask(description, promise, options = {}) {
108
+ const taskId = this.generateTaskId();
109
+ const task = {
110
+ type: "generic",
111
+ taskId,
112
+ description,
113
+ promise
114
+ };
115
+ return this.register(task, options);
116
+ }
117
+ /**
118
+ * Called when a task completes successfully
119
+ */
120
+ onTaskComplete(taskId, result) {
121
+ const entry = this.tasks.get(taskId);
122
+ if (!entry || entry.status !== "running") {
123
+ return;
124
+ }
125
+ if (entry.timeoutHandle) {
126
+ clearTimeout(entry.timeoutHandle);
127
+ entry.timeoutHandle = void 0;
128
+ }
129
+ entry.status = "completed";
130
+ entry.completedAt = /* @__PURE__ */ new Date();
131
+ entry.result = result;
132
+ this.signalBus.emit({
133
+ type: "task:completed",
134
+ taskId,
135
+ result
136
+ });
137
+ }
138
+ /**
139
+ * Called when a task fails
140
+ */
141
+ onTaskFailed(taskId, error) {
142
+ const entry = this.tasks.get(taskId);
143
+ if (!entry || entry.status !== "running") {
144
+ return;
145
+ }
146
+ if (entry.timeoutHandle) {
147
+ clearTimeout(entry.timeoutHandle);
148
+ entry.timeoutHandle = void 0;
149
+ }
150
+ entry.status = "failed";
151
+ entry.completedAt = /* @__PURE__ */ new Date();
152
+ entry.error = error;
153
+ this.signalBus.emit({
154
+ type: "task:failed",
155
+ taskId,
156
+ error
157
+ });
158
+ }
159
+ /**
160
+ * Cancel a running task
161
+ */
162
+ cancel(taskId) {
163
+ const entry = this.tasks.get(taskId);
164
+ if (!entry) {
165
+ throw new Error(`Task '${taskId}' not found`);
166
+ }
167
+ if (entry.status !== "running") {
168
+ return;
169
+ }
170
+ if (entry.timeoutHandle) {
171
+ clearTimeout(entry.timeoutHandle);
172
+ entry.timeoutHandle = void 0;
173
+ }
174
+ entry.status = "cancelled";
175
+ entry.completedAt = /* @__PURE__ */ new Date();
176
+ entry.error = entry.error ?? "Cancelled";
177
+ this.signalBus.emit({
178
+ type: "task:cancelled",
179
+ taskId
180
+ });
181
+ }
182
+ /**
183
+ * Get task entry by ID
184
+ */
185
+ get(taskId) {
186
+ return this.tasks.get(taskId);
187
+ }
188
+ /**
189
+ * Get task status
190
+ */
191
+ getStatus(taskId) {
192
+ return this.tasks.get(taskId)?.status;
193
+ }
194
+ /**
195
+ * Get task result (if completed)
196
+ */
197
+ getResult(taskId) {
198
+ const entry = this.tasks.get(taskId);
199
+ if (!entry) {
200
+ return void 0;
201
+ }
202
+ return {
203
+ status: entry.status,
204
+ ...entry.result !== void 0 && { result: entry.result },
205
+ ...entry.error !== void 0 && { error: entry.error }
206
+ };
207
+ }
208
+ /**
209
+ * Get task info (safe for serialization - no promise)
210
+ */
211
+ getInfo(taskId) {
212
+ const entry = this.tasks.get(taskId);
213
+ if (!entry) {
214
+ return void 0;
215
+ }
216
+ const duration = entry.completedAt ? entry.completedAt.getTime() - entry.startedAt.getTime() : void 0;
217
+ return {
218
+ taskId: entry.task.taskId,
219
+ type: entry.task.type,
220
+ status: entry.status,
221
+ startedAt: entry.startedAt,
222
+ description: this.getTaskDescription(entry.task),
223
+ ...entry.completedAt !== void 0 && { completedAt: entry.completedAt },
224
+ ...duration !== void 0 && { duration },
225
+ ...entry.result !== void 0 && { result: entry.result },
226
+ ...entry.error !== void 0 && { error: entry.error },
227
+ ...entry.status === "cancelled" && entry.error !== void 0 && {
228
+ cancelReason: entry.error
229
+ }
230
+ };
231
+ }
232
+ /**
233
+ * List tasks matching filter
234
+ */
235
+ list(filter) {
236
+ const results = [];
237
+ for (const entry of this.tasks.values()) {
238
+ if (filter?.status) {
239
+ const statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
240
+ if (!statuses.includes(entry.status)) {
241
+ continue;
242
+ }
243
+ }
244
+ if (filter?.type && entry.task.type !== filter.type) {
245
+ continue;
246
+ }
247
+ const info = this.getInfo(entry.task.taskId);
248
+ if (info) {
249
+ results.push(info);
250
+ }
251
+ }
252
+ return results.sort((a, b) => b.startedAt.getTime() - a.startedAt.getTime());
253
+ }
254
+ /**
255
+ * Get count of running tasks
256
+ */
257
+ getRunningCount() {
258
+ let count = 0;
259
+ for (const entry of this.tasks.values()) {
260
+ if (entry.status === "running") {
261
+ count++;
262
+ }
263
+ }
264
+ return count;
265
+ }
266
+ /**
267
+ * Get tasks that completed with notify=true and haven't been acknowledged
268
+ */
269
+ getNotifyPending() {
270
+ return this.list({ status: ["completed", "failed"] }).filter((info) => {
271
+ const entry = this.tasks.get(info.taskId);
272
+ return entry?.notify === true;
273
+ });
274
+ }
275
+ /**
276
+ * Mark notify tasks as acknowledged (clear notify flag)
277
+ */
278
+ acknowledgeNotify(taskIds) {
279
+ for (const taskId of taskIds) {
280
+ const entry = this.tasks.get(taskId);
281
+ if (entry) {
282
+ entry.notify = false;
283
+ }
284
+ }
285
+ }
286
+ /**
287
+ * Clean up old completed tasks
288
+ */
289
+ cleanup(olderThan) {
290
+ const cutoff = olderThan ?? new Date(Date.now() - this.config.resultTTL);
291
+ let cleaned = 0;
292
+ for (const [taskId, entry] of this.tasks.entries()) {
293
+ if (entry.status !== "running" && entry.completedAt && entry.completedAt < cutoff) {
294
+ this.tasks.delete(taskId);
295
+ cleaned++;
296
+ }
297
+ }
298
+ return cleaned;
299
+ }
300
+ /**
301
+ * Clear all tasks
302
+ */
303
+ clear() {
304
+ this.tasks.clear();
305
+ }
306
+ /**
307
+ * Check if a task exists
308
+ */
309
+ has(taskId) {
310
+ return this.tasks.has(taskId);
311
+ }
312
+ /**
313
+ * Get total task count
314
+ */
315
+ get size() {
316
+ return this.tasks.size;
317
+ }
318
+ }
319
+ export {
320
+ TaskRegistry
321
+ };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var check_task_exports = {};
20
+ __export(check_task_exports, {
21
+ CheckTaskInputSchema: () => CheckTaskInputSchema,
22
+ createCheckTaskTool: () => createCheckTaskTool
23
+ });
24
+ module.exports = __toCommonJS(check_task_exports);
25
+ var import_zod = require("zod");
26
+ const CheckTaskInputSchema = import_zod.z.object({
27
+ /** Task ID to check */
28
+ taskId: import_zod.z.string().describe("Task ID to check status of")
29
+ }).strict();
30
+ function createCheckTaskTool() {
31
+ return {
32
+ id: "check_task",
33
+ description: "Check the status of a background task. Returns immediately without waiting. Use this to poll task status or check if a task is done.",
34
+ inputSchema: CheckTaskInputSchema,
35
+ execute: async (rawInput, context) => {
36
+ const input = CheckTaskInputSchema.parse(rawInput);
37
+ const info = context.taskRegistry.getInfo(input.taskId);
38
+ if (!info) {
39
+ return {
40
+ taskId: input.taskId,
41
+ found: false
42
+ };
43
+ }
44
+ return {
45
+ taskId: info.taskId,
46
+ found: true,
47
+ type: info.type,
48
+ status: info.status,
49
+ startedAt: info.startedAt.toISOString(),
50
+ ...info.description !== void 0 && { description: info.description },
51
+ ...info.completedAt !== void 0 && {
52
+ completedAt: info.completedAt.toISOString()
53
+ },
54
+ ...info.duration !== void 0 && { duration: info.duration },
55
+ ...info.result !== void 0 && { result: info.result },
56
+ ...info.error !== void 0 && { error: info.error }
57
+ };
58
+ }
59
+ };
60
+ }
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ CheckTaskInputSchema,
64
+ createCheckTaskTool
65
+ });
@@ -0,0 +1,56 @@
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 };
@@ -0,0 +1,56 @@
1
+ import { z } from 'zod';
2
+ import { OrchestrationTool } from './types.js';
3
+ import '../task-registry.js';
4
+ import '../types.js';
5
+ import '../signal-bus.js';
6
+ import '../condition-engine.js';
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 };
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ const CheckTaskInputSchema = z.object({
3
+ /** Task ID to check */
4
+ taskId: z.string().describe("Task ID to check status of")
5
+ }).strict();
6
+ function createCheckTaskTool() {
7
+ return {
8
+ id: "check_task",
9
+ description: "Check the status of a background task. Returns immediately without waiting. Use this to poll task status or check if a task is done.",
10
+ inputSchema: CheckTaskInputSchema,
11
+ execute: async (rawInput, context) => {
12
+ const input = CheckTaskInputSchema.parse(rawInput);
13
+ const info = context.taskRegistry.getInfo(input.taskId);
14
+ if (!info) {
15
+ return {
16
+ taskId: input.taskId,
17
+ found: false
18
+ };
19
+ }
20
+ return {
21
+ taskId: info.taskId,
22
+ found: true,
23
+ type: info.type,
24
+ status: info.status,
25
+ startedAt: info.startedAt.toISOString(),
26
+ ...info.description !== void 0 && { description: info.description },
27
+ ...info.completedAt !== void 0 && {
28
+ completedAt: info.completedAt.toISOString()
29
+ },
30
+ ...info.duration !== void 0 && { duration: info.duration },
31
+ ...info.result !== void 0 && { result: info.result },
32
+ ...info.error !== void 0 && { error: info.error }
33
+ };
34
+ }
35
+ };
36
+ }
37
+ export {
38
+ CheckTaskInputSchema,
39
+ createCheckTaskTool
40
+ };