@sparkleideas/swarm 3.0.0-alpha.7
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/MIGRATION.md +472 -0
- package/README.md +634 -0
- package/__tests__/consensus.test.ts +577 -0
- package/__tests__/coordinator.test.ts +501 -0
- package/__tests__/queen-coordinator.test.ts +1335 -0
- package/__tests__/topology.test.ts +621 -0
- package/package.json +32 -0
- package/src/agent-pool.ts +476 -0
- package/src/application/commands/create-task.command.ts +124 -0
- package/src/application/commands/spawn-agent.command.ts +122 -0
- package/src/application/index.ts +30 -0
- package/src/application/services/swarm-application-service.ts +200 -0
- package/src/attention-coordinator.ts +1000 -0
- package/src/consensus/byzantine.ts +431 -0
- package/src/consensus/gossip.ts +513 -0
- package/src/consensus/index.ts +267 -0
- package/src/consensus/raft.ts +443 -0
- package/src/coordination/agent-registry.ts +544 -0
- package/src/coordination/index.ts +23 -0
- package/src/coordination/swarm-hub.ts +776 -0
- package/src/coordination/task-orchestrator.ts +605 -0
- package/src/domain/entities/agent.d.ts +151 -0
- package/src/domain/entities/agent.d.ts.map +1 -0
- package/src/domain/entities/agent.js +280 -0
- package/src/domain/entities/agent.js.map +1 -0
- package/src/domain/entities/agent.ts +370 -0
- package/src/domain/entities/task.d.ts +133 -0
- package/src/domain/entities/task.d.ts.map +1 -0
- package/src/domain/entities/task.js +261 -0
- package/src/domain/entities/task.js.map +1 -0
- package/src/domain/entities/task.ts +319 -0
- package/src/domain/index.ts +41 -0
- package/src/domain/repositories/agent-repository.interface.d.ts +57 -0
- package/src/domain/repositories/agent-repository.interface.d.ts.map +1 -0
- package/src/domain/repositories/agent-repository.interface.js +9 -0
- package/src/domain/repositories/agent-repository.interface.js.map +1 -0
- package/src/domain/repositories/agent-repository.interface.ts +69 -0
- package/src/domain/repositories/task-repository.interface.d.ts +61 -0
- package/src/domain/repositories/task-repository.interface.d.ts.map +1 -0
- package/src/domain/repositories/task-repository.interface.js +9 -0
- package/src/domain/repositories/task-repository.interface.js.map +1 -0
- package/src/domain/repositories/task-repository.interface.ts +75 -0
- package/src/domain/services/coordination-service.ts +320 -0
- package/src/federation-hub.d.ts +284 -0
- package/src/federation-hub.d.ts.map +1 -0
- package/src/federation-hub.js +692 -0
- package/src/federation-hub.js.map +1 -0
- package/src/federation-hub.ts +979 -0
- package/src/index.ts +348 -0
- package/src/message-bus.ts +607 -0
- package/src/queen-coordinator.ts +2025 -0
- package/src/shared/events.ts +285 -0
- package/src/shared/types.ts +389 -0
- package/src/topology-manager.ts +656 -0
- package/src/types.ts +545 -0
- package/src/unified-coordinator.ts +1844 -0
- package/src/workers/index.ts +65 -0
- package/src/workers/worker-dispatch.d.ts +234 -0
- package/src/workers/worker-dispatch.d.ts.map +1 -0
- package/src/workers/worker-dispatch.js +842 -0
- package/src/workers/worker-dispatch.js.map +1 -0
- package/src/workers/worker-dispatch.ts +1076 -0
- package/tmp.json +0 -0
- package/tsconfig.json +9 -0
- package/vitest.config.ts +20 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Entity - Domain Layer
|
|
3
|
+
*
|
|
4
|
+
* Core domain entity representing an AI agent in the swarm.
|
|
5
|
+
* Implements DDD aggregate root pattern with encapsulated business logic.
|
|
6
|
+
*
|
|
7
|
+
* @module v3/swarm/domain/entities
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { randomUUID } from 'crypto';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Agent status types
|
|
14
|
+
*/
|
|
15
|
+
export type AgentStatus = 'idle' | 'active' | 'busy' | 'paused' | 'terminated' | 'error';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Agent role types - following 15-agent hierarchy
|
|
19
|
+
*/
|
|
20
|
+
export type AgentRole =
|
|
21
|
+
| 'queen-coordinator'
|
|
22
|
+
| 'security-architect'
|
|
23
|
+
| 'security-auditor'
|
|
24
|
+
| 'memory-specialist'
|
|
25
|
+
| 'swarm-specialist'
|
|
26
|
+
| 'integration-architect'
|
|
27
|
+
| 'performance-engineer'
|
|
28
|
+
| 'core-architect'
|
|
29
|
+
| 'test-architect'
|
|
30
|
+
| 'project-coordinator'
|
|
31
|
+
| 'coder'
|
|
32
|
+
| 'reviewer'
|
|
33
|
+
| 'tester'
|
|
34
|
+
| 'planner'
|
|
35
|
+
| 'researcher'
|
|
36
|
+
| 'custom';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Agent properties
|
|
40
|
+
*/
|
|
41
|
+
export interface AgentProps {
|
|
42
|
+
id?: string;
|
|
43
|
+
name: string;
|
|
44
|
+
role: AgentRole;
|
|
45
|
+
domain: string;
|
|
46
|
+
capabilities: string[];
|
|
47
|
+
status?: AgentStatus;
|
|
48
|
+
parentId?: string;
|
|
49
|
+
metadata?: Record<string, unknown>;
|
|
50
|
+
maxConcurrentTasks?: number;
|
|
51
|
+
currentTaskIds?: string[];
|
|
52
|
+
completedTaskCount?: number;
|
|
53
|
+
createdAt?: Date;
|
|
54
|
+
updatedAt?: Date;
|
|
55
|
+
lastActiveAt?: Date;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Agent - Aggregate Root
|
|
60
|
+
*
|
|
61
|
+
* Represents an individual agent with lifecycle management,
|
|
62
|
+
* task tracking, and hierarchical relationships.
|
|
63
|
+
*/
|
|
64
|
+
export class Agent {
|
|
65
|
+
private _id: string;
|
|
66
|
+
private _name: string;
|
|
67
|
+
private _role: AgentRole;
|
|
68
|
+
private _domain: string;
|
|
69
|
+
private _capabilities: Set<string>;
|
|
70
|
+
private _status: AgentStatus;
|
|
71
|
+
private _parentId?: string;
|
|
72
|
+
private _metadata: Record<string, unknown>;
|
|
73
|
+
private _maxConcurrentTasks: number;
|
|
74
|
+
private _currentTaskIds: Set<string>;
|
|
75
|
+
private _completedTaskCount: number;
|
|
76
|
+
private _createdAt: Date;
|
|
77
|
+
private _updatedAt: Date;
|
|
78
|
+
private _lastActiveAt: Date;
|
|
79
|
+
|
|
80
|
+
private constructor(props: AgentProps) {
|
|
81
|
+
const now = new Date();
|
|
82
|
+
this._id = props.id ?? randomUUID();
|
|
83
|
+
this._name = props.name;
|
|
84
|
+
this._role = props.role;
|
|
85
|
+
this._domain = props.domain;
|
|
86
|
+
this._capabilities = new Set(props.capabilities);
|
|
87
|
+
this._status = props.status ?? 'idle';
|
|
88
|
+
this._parentId = props.parentId;
|
|
89
|
+
this._metadata = props.metadata ?? {};
|
|
90
|
+
this._maxConcurrentTasks = props.maxConcurrentTasks ?? 3;
|
|
91
|
+
this._currentTaskIds = new Set(props.currentTaskIds ?? []);
|
|
92
|
+
this._completedTaskCount = props.completedTaskCount ?? 0;
|
|
93
|
+
this._createdAt = props.createdAt ?? now;
|
|
94
|
+
this._updatedAt = props.updatedAt ?? now;
|
|
95
|
+
this._lastActiveAt = props.lastActiveAt ?? now;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Factory method - Create new agent
|
|
100
|
+
*/
|
|
101
|
+
static create(props: AgentProps): Agent {
|
|
102
|
+
return new Agent(props);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Factory method - Reconstruct from persistence
|
|
107
|
+
*/
|
|
108
|
+
static fromPersistence(props: AgentProps): Agent {
|
|
109
|
+
return new Agent(props);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Getters
|
|
113
|
+
get id(): string {
|
|
114
|
+
return this._id;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get name(): string {
|
|
118
|
+
return this._name;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
get role(): AgentRole {
|
|
122
|
+
return this._role;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
get domain(): string {
|
|
126
|
+
return this._domain;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
get capabilities(): string[] {
|
|
130
|
+
return Array.from(this._capabilities);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
get status(): AgentStatus {
|
|
134
|
+
return this._status;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get parentId(): string | undefined {
|
|
138
|
+
return this._parentId;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
get metadata(): Record<string, unknown> {
|
|
142
|
+
return { ...this._metadata };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
get maxConcurrentTasks(): number {
|
|
146
|
+
return this._maxConcurrentTasks;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
get currentTaskIds(): string[] {
|
|
150
|
+
return Array.from(this._currentTaskIds);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
get currentTaskCount(): number {
|
|
154
|
+
return this._currentTaskIds.size;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
get completedTaskCount(): number {
|
|
158
|
+
return this._completedTaskCount;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
get createdAt(): Date {
|
|
162
|
+
return new Date(this._createdAt);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
get updatedAt(): Date {
|
|
166
|
+
return new Date(this._updatedAt);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
get lastActiveAt(): Date {
|
|
170
|
+
return new Date(this._lastActiveAt);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// Business Logic Methods
|
|
175
|
+
// ============================================================================
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Start the agent (transition to active)
|
|
179
|
+
*/
|
|
180
|
+
start(): void {
|
|
181
|
+
if (this._status === 'terminated') {
|
|
182
|
+
throw new Error('Cannot start terminated agent');
|
|
183
|
+
}
|
|
184
|
+
this._status = 'active';
|
|
185
|
+
this._lastActiveAt = new Date();
|
|
186
|
+
this._updatedAt = new Date();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Pause the agent
|
|
191
|
+
*/
|
|
192
|
+
pause(): void {
|
|
193
|
+
if (this._status !== 'active' && this._status !== 'busy') {
|
|
194
|
+
throw new Error('Can only pause active or busy agent');
|
|
195
|
+
}
|
|
196
|
+
this._status = 'paused';
|
|
197
|
+
this._updatedAt = new Date();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Resume paused agent
|
|
202
|
+
*/
|
|
203
|
+
resume(): void {
|
|
204
|
+
if (this._status !== 'paused') {
|
|
205
|
+
throw new Error('Can only resume paused agent');
|
|
206
|
+
}
|
|
207
|
+
this._status = this._currentTaskIds.size > 0 ? 'busy' : 'active';
|
|
208
|
+
this._lastActiveAt = new Date();
|
|
209
|
+
this._updatedAt = new Date();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Terminate the agent
|
|
214
|
+
*/
|
|
215
|
+
terminate(): void {
|
|
216
|
+
this._status = 'terminated';
|
|
217
|
+
this._currentTaskIds.clear();
|
|
218
|
+
this._updatedAt = new Date();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Mark agent as having an error
|
|
223
|
+
*/
|
|
224
|
+
setError(errorMessage?: string): void {
|
|
225
|
+
this._status = 'error';
|
|
226
|
+
if (errorMessage) {
|
|
227
|
+
this._metadata['lastError'] = errorMessage;
|
|
228
|
+
this._metadata['lastErrorAt'] = new Date().toISOString();
|
|
229
|
+
}
|
|
230
|
+
this._updatedAt = new Date();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Recover from error state
|
|
235
|
+
*/
|
|
236
|
+
recover(): void {
|
|
237
|
+
if (this._status !== 'error') {
|
|
238
|
+
throw new Error('Can only recover from error state');
|
|
239
|
+
}
|
|
240
|
+
this._status = 'idle';
|
|
241
|
+
delete this._metadata['lastError'];
|
|
242
|
+
this._updatedAt = new Date();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Assign a task to this agent
|
|
247
|
+
*/
|
|
248
|
+
assignTask(taskId: string): void {
|
|
249
|
+
if (this._status === 'terminated') {
|
|
250
|
+
throw new Error('Cannot assign task to terminated agent');
|
|
251
|
+
}
|
|
252
|
+
if (this._currentTaskIds.size >= this._maxConcurrentTasks) {
|
|
253
|
+
throw new Error('Agent at maximum concurrent task capacity');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
this._currentTaskIds.add(taskId);
|
|
257
|
+
this._status = 'busy';
|
|
258
|
+
this._lastActiveAt = new Date();
|
|
259
|
+
this._updatedAt = new Date();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Complete a task
|
|
264
|
+
*/
|
|
265
|
+
completeTask(taskId: string): void {
|
|
266
|
+
if (!this._currentTaskIds.has(taskId)) {
|
|
267
|
+
throw new Error(`Task ${taskId} not assigned to this agent`);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
this._currentTaskIds.delete(taskId);
|
|
271
|
+
this._completedTaskCount++;
|
|
272
|
+
|
|
273
|
+
if (this._currentTaskIds.size === 0) {
|
|
274
|
+
this._status = 'active';
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
this._lastActiveAt = new Date();
|
|
278
|
+
this._updatedAt = new Date();
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Check if agent can accept more tasks
|
|
283
|
+
*/
|
|
284
|
+
canAcceptTask(): boolean {
|
|
285
|
+
return (
|
|
286
|
+
this._status !== 'terminated' &&
|
|
287
|
+
this._status !== 'error' &&
|
|
288
|
+
this._status !== 'paused' &&
|
|
289
|
+
this._currentTaskIds.size < this._maxConcurrentTasks
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Check if agent has a specific capability
|
|
295
|
+
*/
|
|
296
|
+
hasCapability(capability: string): boolean {
|
|
297
|
+
return this._capabilities.has(capability);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Add a capability
|
|
302
|
+
*/
|
|
303
|
+
addCapability(capability: string): void {
|
|
304
|
+
this._capabilities.add(capability);
|
|
305
|
+
this._updatedAt = new Date();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Remove a capability
|
|
310
|
+
*/
|
|
311
|
+
removeCapability(capability: string): void {
|
|
312
|
+
this._capabilities.delete(capability);
|
|
313
|
+
this._updatedAt = new Date();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Update metadata
|
|
318
|
+
*/
|
|
319
|
+
setMetadata(key: string, value: unknown): void {
|
|
320
|
+
this._metadata[key] = value;
|
|
321
|
+
this._updatedAt = new Date();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Check if agent is a child of given parent
|
|
326
|
+
*/
|
|
327
|
+
isChildOf(parentId: string): boolean {
|
|
328
|
+
return this._parentId === parentId;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Calculate agent utilization (0-1)
|
|
333
|
+
*/
|
|
334
|
+
getUtilization(): number {
|
|
335
|
+
return this._currentTaskIds.size / this._maxConcurrentTasks;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Check if agent is available for work
|
|
340
|
+
*/
|
|
341
|
+
isAvailable(): boolean {
|
|
342
|
+
return this._status === 'idle' || (this._status === 'active' && this.canAcceptTask());
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Convert to plain object for persistence
|
|
347
|
+
*/
|
|
348
|
+
toPersistence(): Record<string, unknown> {
|
|
349
|
+
return {
|
|
350
|
+
id: this._id,
|
|
351
|
+
name: this._name,
|
|
352
|
+
role: this._role,
|
|
353
|
+
domain: this._domain,
|
|
354
|
+
capabilities: Array.from(this._capabilities),
|
|
355
|
+
status: this._status,
|
|
356
|
+
parentId: this._parentId,
|
|
357
|
+
metadata: this._metadata,
|
|
358
|
+
maxConcurrentTasks: this._maxConcurrentTasks,
|
|
359
|
+
currentTaskIds: Array.from(this._currentTaskIds),
|
|
360
|
+
completedTaskCount: this._completedTaskCount,
|
|
361
|
+
createdAt: this._createdAt.toISOString(),
|
|
362
|
+
updatedAt: this._updatedAt.toISOString(),
|
|
363
|
+
lastActiveAt: this._lastActiveAt.toISOString(),
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
toJSON(): Record<string, unknown> {
|
|
368
|
+
return this.toPersistence();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Entity - Domain Layer
|
|
3
|
+
*
|
|
4
|
+
* Core domain entity representing a task in the swarm.
|
|
5
|
+
* Tasks are units of work assigned to agents.
|
|
6
|
+
*
|
|
7
|
+
* @module v3/swarm/domain/entities
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Task status types
|
|
11
|
+
*/
|
|
12
|
+
export type TaskStatus = 'pending' | 'queued' | 'assigned' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
13
|
+
/**
|
|
14
|
+
* Task priority levels
|
|
15
|
+
*/
|
|
16
|
+
export type TaskPriority = 'critical' | 'high' | 'normal' | 'low';
|
|
17
|
+
/**
|
|
18
|
+
* Task properties
|
|
19
|
+
*/
|
|
20
|
+
export interface TaskProps {
|
|
21
|
+
id?: string;
|
|
22
|
+
title: string;
|
|
23
|
+
description: string;
|
|
24
|
+
type: string;
|
|
25
|
+
priority?: TaskPriority;
|
|
26
|
+
status?: TaskStatus;
|
|
27
|
+
assignedAgentId?: string;
|
|
28
|
+
dependencies?: string[];
|
|
29
|
+
metadata?: Record<string, unknown>;
|
|
30
|
+
input?: unknown;
|
|
31
|
+
output?: unknown;
|
|
32
|
+
error?: string;
|
|
33
|
+
retryCount?: number;
|
|
34
|
+
maxRetries?: number;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
createdAt?: Date;
|
|
37
|
+
startedAt?: Date;
|
|
38
|
+
completedAt?: Date;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Task - Entity
|
|
42
|
+
*
|
|
43
|
+
* Represents a unit of work with lifecycle management,
|
|
44
|
+
* dependency tracking, and result storage.
|
|
45
|
+
*/
|
|
46
|
+
export declare class Task {
|
|
47
|
+
private _id;
|
|
48
|
+
private _title;
|
|
49
|
+
private _description;
|
|
50
|
+
private _type;
|
|
51
|
+
private _priority;
|
|
52
|
+
private _status;
|
|
53
|
+
private _assignedAgentId?;
|
|
54
|
+
private _dependencies;
|
|
55
|
+
private _metadata;
|
|
56
|
+
private _input?;
|
|
57
|
+
private _output?;
|
|
58
|
+
private _error?;
|
|
59
|
+
private _retryCount;
|
|
60
|
+
private _maxRetries;
|
|
61
|
+
private _timeout;
|
|
62
|
+
private _createdAt;
|
|
63
|
+
private _startedAt?;
|
|
64
|
+
private _completedAt?;
|
|
65
|
+
private constructor();
|
|
66
|
+
static create(props: TaskProps): Task;
|
|
67
|
+
static fromPersistence(props: TaskProps): Task;
|
|
68
|
+
get id(): string;
|
|
69
|
+
get title(): string;
|
|
70
|
+
get description(): string;
|
|
71
|
+
get type(): string;
|
|
72
|
+
get priority(): TaskPriority;
|
|
73
|
+
get status(): TaskStatus;
|
|
74
|
+
get assignedAgentId(): string | undefined;
|
|
75
|
+
get dependencies(): string[];
|
|
76
|
+
get metadata(): Record<string, unknown>;
|
|
77
|
+
get input(): unknown;
|
|
78
|
+
get output(): unknown;
|
|
79
|
+
get error(): string | undefined;
|
|
80
|
+
get retryCount(): number;
|
|
81
|
+
get maxRetries(): number;
|
|
82
|
+
get timeout(): number;
|
|
83
|
+
get createdAt(): Date;
|
|
84
|
+
get startedAt(): Date | undefined;
|
|
85
|
+
get completedAt(): Date | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Queue the task for execution
|
|
88
|
+
*/
|
|
89
|
+
queue(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Assign task to an agent
|
|
92
|
+
*/
|
|
93
|
+
assign(agentId: string): void;
|
|
94
|
+
/**
|
|
95
|
+
* Start task execution
|
|
96
|
+
*/
|
|
97
|
+
start(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Complete the task successfully
|
|
100
|
+
*/
|
|
101
|
+
complete(output?: unknown): void;
|
|
102
|
+
/**
|
|
103
|
+
* Mark task as failed
|
|
104
|
+
*/
|
|
105
|
+
fail(error: string): void;
|
|
106
|
+
/**
|
|
107
|
+
* Cancel the task
|
|
108
|
+
*/
|
|
109
|
+
cancel(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Check if all dependencies are satisfied
|
|
112
|
+
*/
|
|
113
|
+
areDependenciesSatisfied(completedTaskIds: Set<string>): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Check if task can be retried
|
|
116
|
+
*/
|
|
117
|
+
canRetry(): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Get execution duration in milliseconds
|
|
120
|
+
*/
|
|
121
|
+
getExecutionDuration(): number | null;
|
|
122
|
+
/**
|
|
123
|
+
* Check if task is timed out
|
|
124
|
+
*/
|
|
125
|
+
isTimedOut(): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Priority comparison (for sorting)
|
|
128
|
+
*/
|
|
129
|
+
comparePriority(other: Task): number;
|
|
130
|
+
toPersistence(): Record<string, unknown>;
|
|
131
|
+
toJSON(): Record<string, unknown>;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["task.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,QAAQ,GACR,UAAU,GACV,SAAS,GACT,WAAW,GACX,QAAQ,GACR,WAAW,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,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