@sparkleideas/swarm 3.0.0-alpha.6-patch.17 → 3.0.0-alpha.6-patch.18
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/package.json +1 -1
- package/dist/agent-pool.d.ts +0 -52
- package/dist/agent-pool.d.ts.map +0 -1
- package/dist/agent-pool.js +0 -365
- package/dist/agent-pool.js.map +0 -1
- package/dist/application/commands/create-task.command.d.ts +0 -64
- package/dist/application/commands/create-task.command.d.ts.map +0 -1
- package/dist/application/commands/create-task.command.js +0 -77
- package/dist/application/commands/create-task.command.js.map +0 -1
- package/dist/application/commands/spawn-agent.command.d.ts +0 -63
- package/dist/application/commands/spawn-agent.command.d.ts.map +0 -1
- package/dist/application/commands/spawn-agent.command.js +0 -74
- package/dist/application/commands/spawn-agent.command.js.map +0 -1
- package/dist/application/index.d.ts +0 -9
- package/dist/application/index.d.ts.map +0 -1
- package/dist/application/index.js +0 -11
- package/dist/application/index.js.map +0 -1
- package/dist/application/services/swarm-application-service.d.ts +0 -112
- package/dist/application/services/swarm-application-service.d.ts.map +0 -1
- package/dist/application/services/swarm-application-service.js +0 -153
- package/dist/application/services/swarm-application-service.js.map +0 -1
- package/dist/attention-coordinator.d.ts +0 -212
- package/dist/attention-coordinator.d.ts.map +0 -1
- package/dist/attention-coordinator.js +0 -667
- package/dist/attention-coordinator.js.map +0 -1
- package/dist/consensus/byzantine.d.ts +0 -63
- package/dist/consensus/byzantine.d.ts.map +0 -1
- package/dist/consensus/byzantine.js +0 -316
- package/dist/consensus/byzantine.js.map +0 -1
- package/dist/consensus/gossip.d.ts +0 -69
- package/dist/consensus/gossip.d.ts.map +0 -1
- package/dist/consensus/gossip.js +0 -378
- package/dist/consensus/gossip.js.map +0 -1
- package/dist/consensus/index.d.ts +0 -49
- package/dist/consensus/index.d.ts.map +0 -1
- package/dist/consensus/index.js +0 -203
- package/dist/consensus/index.js.map +0 -1
- package/dist/consensus/raft.d.ts +0 -62
- package/dist/consensus/raft.d.ts.map +0 -1
- package/dist/consensus/raft.js +0 -324
- package/dist/consensus/raft.js.map +0 -1
- package/dist/coordination/agent-registry.d.ts +0 -68
- package/dist/coordination/agent-registry.d.ts.map +0 -1
- package/dist/coordination/agent-registry.js +0 -412
- package/dist/coordination/agent-registry.js.map +0 -1
- package/dist/coordination/index.d.ts +0 -8
- package/dist/coordination/index.d.ts.map +0 -1
- package/dist/coordination/index.js +0 -8
- package/dist/coordination/index.js.map +0 -1
- package/dist/coordination/swarm-hub.d.ts +0 -150
- package/dist/coordination/swarm-hub.d.ts.map +0 -1
- package/dist/coordination/swarm-hub.js +0 -617
- package/dist/coordination/swarm-hub.js.map +0 -1
- package/dist/coordination/task-orchestrator.d.ts +0 -96
- package/dist/coordination/task-orchestrator.d.ts.map +0 -1
- package/dist/coordination/task-orchestrator.js +0 -412
- package/dist/coordination/task-orchestrator.js.map +0 -1
- package/dist/domain/entities/agent.d.ts +0 -151
- package/dist/domain/entities/agent.d.ts.map +0 -1
- package/dist/domain/entities/agent.js +0 -280
- package/dist/domain/entities/agent.js.map +0 -1
- package/dist/domain/entities/task.d.ts +0 -133
- package/dist/domain/entities/task.d.ts.map +0 -1
- package/dist/domain/entities/task.js +0 -261
- package/dist/domain/entities/task.js.map +0 -1
- package/dist/domain/index.d.ts +0 -11
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js +0 -11
- package/dist/domain/index.js.map +0 -1
- package/dist/domain/repositories/agent-repository.interface.d.ts +0 -57
- package/dist/domain/repositories/agent-repository.interface.d.ts.map +0 -1
- package/dist/domain/repositories/agent-repository.interface.js +0 -9
- package/dist/domain/repositories/agent-repository.interface.js.map +0 -1
- package/dist/domain/repositories/task-repository.interface.d.ts +0 -61
- package/dist/domain/repositories/task-repository.interface.d.ts.map +0 -1
- package/dist/domain/repositories/task-repository.interface.js +0 -9
- package/dist/domain/repositories/task-repository.interface.js.map +0 -1
- package/dist/domain/services/coordination-service.d.ts +0 -84
- package/dist/domain/services/coordination-service.d.ts.map +0 -1
- package/dist/domain/services/coordination-service.js +0 -231
- package/dist/domain/services/coordination-service.js.map +0 -1
- package/dist/federation-hub.d.ts +0 -284
- package/dist/federation-hub.d.ts.map +0 -1
- package/dist/federation-hub.js +0 -692
- package/dist/federation-hub.js.map +0 -1
- package/dist/index.d.ts +0 -107
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -142
- package/dist/index.js.map +0 -1
- package/dist/message-bus.d.ts +0 -48
- package/dist/message-bus.d.ts.map +0 -1
- package/dist/message-bus.js +0 -499
- package/dist/message-bus.js.map +0 -1
- package/dist/queen-coordinator.d.ts +0 -577
- package/dist/queen-coordinator.d.ts.map +0 -1
- package/dist/queen-coordinator.js +0 -1308
- package/dist/queen-coordinator.js.map +0 -1
- package/dist/shared/events.d.ts +0 -63
- package/dist/shared/events.d.ts.map +0 -1
- package/dist/shared/events.js +0 -203
- package/dist/shared/events.js.map +0 -1
- package/dist/shared/types.d.ts +0 -212
- package/dist/shared/types.d.ts.map +0 -1
- package/dist/shared/types.js +0 -22
- package/dist/shared/types.js.map +0 -1
- package/dist/topology-manager.d.ts +0 -62
- package/dist/topology-manager.d.ts.map +0 -1
- package/dist/topology-manager.js +0 -538
- package/dist/topology-manager.js.map +0 -1
- package/dist/types.d.ts +0 -353
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -43
- package/dist/types.js.map +0 -1
- package/dist/unified-coordinator.d.ts +0 -260
- package/dist/unified-coordinator.d.ts.map +0 -1
- package/dist/unified-coordinator.js +0 -1460
- package/dist/unified-coordinator.js.map +0 -1
- package/dist/workers/index.d.ts +0 -29
- package/dist/workers/index.d.ts.map +0 -1
- package/dist/workers/index.js +0 -49
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/worker-dispatch.d.ts +0 -239
- package/dist/workers/worker-dispatch.d.ts.map +0 -1
- package/dist/workers/worker-dispatch.js +0 -846
- package/dist/workers/worker-dispatch.js.map +0 -1
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spawn-agent.command.d.ts","sourceRoot":"","sources":["../../../src/application/commands/spawn-agent.command.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAc,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yDAAyD,CAAC;AAE3F;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;IACb,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,qBAAa,wBAAwB;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,gBAAgB;IAEnD,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAkCjE;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,4BAA4B;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,gBAAgB;IAEnD,OAAO,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAqBzE"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Spawn Agent Command - Application Layer (CQRS)
|
|
3
|
-
*
|
|
4
|
-
* Command for spawning a new agent in the swarm.
|
|
5
|
-
*
|
|
6
|
-
* @module v3/swarm/application/commands
|
|
7
|
-
*/
|
|
8
|
-
import { Agent } from '../../domain/entities/agent.js';
|
|
9
|
-
/**
|
|
10
|
-
* Spawn Agent Command Handler
|
|
11
|
-
*/
|
|
12
|
-
export class SpawnAgentCommandHandler {
|
|
13
|
-
repository;
|
|
14
|
-
constructor(repository) {
|
|
15
|
-
this.repository = repository;
|
|
16
|
-
}
|
|
17
|
-
async execute(input) {
|
|
18
|
-
// Check if agent with same name exists
|
|
19
|
-
const existing = await this.repository.findByName(input.name);
|
|
20
|
-
if (existing) {
|
|
21
|
-
throw new Error(`Agent with name '${input.name}' already exists`);
|
|
22
|
-
}
|
|
23
|
-
// Create agent
|
|
24
|
-
const agent = Agent.create({
|
|
25
|
-
name: input.name,
|
|
26
|
-
role: input.role,
|
|
27
|
-
domain: input.domain,
|
|
28
|
-
capabilities: input.capabilities,
|
|
29
|
-
parentId: input.parentId,
|
|
30
|
-
metadata: input.metadata,
|
|
31
|
-
maxConcurrentTasks: input.maxConcurrentTasks,
|
|
32
|
-
});
|
|
33
|
-
// Auto-start if requested
|
|
34
|
-
let startedAutomatically = false;
|
|
35
|
-
if (input.autoStart) {
|
|
36
|
-
agent.start();
|
|
37
|
-
startedAutomatically = true;
|
|
38
|
-
}
|
|
39
|
-
await this.repository.save(agent);
|
|
40
|
-
return {
|
|
41
|
-
success: true,
|
|
42
|
-
agentId: agent.id,
|
|
43
|
-
agent,
|
|
44
|
-
startedAutomatically,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Terminate Agent Command Handler
|
|
50
|
-
*/
|
|
51
|
-
export class TerminateAgentCommandHandler {
|
|
52
|
-
repository;
|
|
53
|
-
constructor(repository) {
|
|
54
|
-
this.repository = repository;
|
|
55
|
-
}
|
|
56
|
-
async execute(input) {
|
|
57
|
-
const agent = await this.repository.findById(input.agentId);
|
|
58
|
-
if (!agent) {
|
|
59
|
-
throw new Error(`Agent '${input.agentId}' not found`);
|
|
60
|
-
}
|
|
61
|
-
const currentTasks = agent.currentTaskCount;
|
|
62
|
-
if (currentTasks > 0 && !input.force) {
|
|
63
|
-
throw new Error(`Agent has ${currentTasks} active tasks. Use force=true to terminate anyway.`);
|
|
64
|
-
}
|
|
65
|
-
agent.terminate();
|
|
66
|
-
await this.repository.save(agent);
|
|
67
|
-
return {
|
|
68
|
-
success: true,
|
|
69
|
-
agentId: input.agentId,
|
|
70
|
-
tasksReassigned: currentTasks,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=spawn-agent.command.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spawn-agent.command.js","sourceRoot":"","sources":["../../../src/application/commands/spawn-agent.command.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAyB,MAAM,gCAAgC,CAAC;AA2B9E;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACN;IAA7B,YAA6B,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;IAAG,CAAC;IAE7D,KAAK,CAAC,OAAO,CAAC,KAAsB;QAClC,uCAAuC;QACvC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,CAAC,IAAI,kB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AAM,IAAI,KAAK,CAAC,aAAa,YAAY,oDAAoD,CAAC,CAAC;QACjG,CAAC;QAED,KAAK,CAAC,SAAS,EAAE,CAAC;QAClB,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAElC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,eAAe,EAAE,YAAY;SAC9B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Swarm Application Layer - Public Exports
|
|
3
|
-
*
|
|
4
|
-
* @module v3/swarm/application
|
|
5
|
-
*/
|
|
6
|
-
export { SpawnAgentCommandHandler, TerminateAgentCommandHandler, type SpawnAgentInput, type SpawnAgentResult, type TerminateAgentInput, type TerminateAgentResult, } from './commands/spawn-agent.command.js';
|
|
7
|
-
export { CreateTaskCommandHandler, CancelTaskCommandHandler, type CreateTaskInput, type CreateTaskResult, type CancelTaskInput, type CancelTaskResult, } from './commands/create-task.command.js';
|
|
8
|
-
export { SwarmApplicationService, type SwarmConfig, } from './services/swarm-application-service.js';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EACL,uBAAuB,EACvB,KAAK,WAAW,GACjB,MAAM,yCAAyC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Swarm Application Layer - Public Exports
|
|
3
|
-
*
|
|
4
|
-
* @module v3/swarm/application
|
|
5
|
-
*/
|
|
6
|
-
// Commands
|
|
7
|
-
export { SpawnAgentCommandHandler, TerminateAgentCommandHandler, } from './commands/spawn-agent.command.js';
|
|
8
|
-
export { CreateTaskCommandHandler, CancelTaskCommandHandler, } from './commands/create-task.command.js';
|
|
9
|
-
// Application Service
|
|
10
|
-
export { SwarmApplicationService, } from './services/swarm-application-service.js';
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,WAAW;AACX,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAK7B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GAKzB,MAAM,mCAAmC,CAAC;AAE3C,sBAAsB;AACtB,OAAO,EACL,uBAAuB,GAExB,MAAM,yCAAyC,CAAC"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Swarm Application Service - Application Layer
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates swarm operations and provides simplified interface.
|
|
5
|
-
*
|
|
6
|
-
* @module v3/swarm/application/services
|
|
7
|
-
*/
|
|
8
|
-
import { Agent, AgentRole, AgentStatus } from '../../domain/entities/agent.js';
|
|
9
|
-
import { Task, TaskStatus, TaskPriority } from '../../domain/entities/task.js';
|
|
10
|
-
import { IAgentRepository, AgentStatistics } from '../../domain/repositories/agent-repository.interface.js';
|
|
11
|
-
import { ITaskRepository, TaskStatistics } from '../../domain/repositories/task-repository.interface.js';
|
|
12
|
-
import { LoadBalancingStrategy, SwarmHealth } from '../../domain/services/coordination-service.js';
|
|
13
|
-
import { SpawnAgentInput } from '../commands/spawn-agent.command.js';
|
|
14
|
-
import { CreateTaskInput } from '../commands/create-task.command.js';
|
|
15
|
-
/**
|
|
16
|
-
* Swarm configuration
|
|
17
|
-
*/
|
|
18
|
-
export interface SwarmConfig {
|
|
19
|
-
loadBalancingStrategy?: LoadBalancingStrategy;
|
|
20
|
-
autoScaling?: boolean;
|
|
21
|
-
minAgents?: number;
|
|
22
|
-
maxAgents?: number;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Swarm Application Service
|
|
26
|
-
*/
|
|
27
|
-
export declare class SwarmApplicationService {
|
|
28
|
-
private readonly agentRepository;
|
|
29
|
-
private readonly taskRepository;
|
|
30
|
-
private readonly config;
|
|
31
|
-
private readonly coordinationService;
|
|
32
|
-
private readonly spawnHandler;
|
|
33
|
-
private readonly terminateHandler;
|
|
34
|
-
private readonly createTaskHandler;
|
|
35
|
-
private readonly cancelTaskHandler;
|
|
36
|
-
constructor(agentRepository: IAgentRepository, taskRepository: ITaskRepository, config?: SwarmConfig);
|
|
37
|
-
/**
|
|
38
|
-
* Spawn a new agent
|
|
39
|
-
*/
|
|
40
|
-
spawnAgent(input: SpawnAgentInput): Promise<Agent>;
|
|
41
|
-
/**
|
|
42
|
-
* Terminate an agent
|
|
43
|
-
*/
|
|
44
|
-
terminateAgent(agentId: string, force?: boolean): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Get agent by ID
|
|
47
|
-
*/
|
|
48
|
-
getAgent(agentId: string): Promise<Agent | null>;
|
|
49
|
-
/**
|
|
50
|
-
* List all agents
|
|
51
|
-
*/
|
|
52
|
-
listAgents(options?: {
|
|
53
|
-
status?: AgentStatus;
|
|
54
|
-
role?: AgentRole;
|
|
55
|
-
domain?: string;
|
|
56
|
-
}): Promise<Agent[]>;
|
|
57
|
-
/**
|
|
58
|
-
* Get agent statistics
|
|
59
|
-
*/
|
|
60
|
-
getAgentStatistics(): Promise<AgentStatistics>;
|
|
61
|
-
/**
|
|
62
|
-
* Create a new task
|
|
63
|
-
*/
|
|
64
|
-
createTask(input: CreateTaskInput): Promise<Task>;
|
|
65
|
-
/**
|
|
66
|
-
* Cancel a task
|
|
67
|
-
*/
|
|
68
|
-
cancelTask(taskId: string): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Get task by ID
|
|
71
|
-
*/
|
|
72
|
-
getTask(taskId: string): Promise<Task | null>;
|
|
73
|
-
/**
|
|
74
|
-
* List tasks
|
|
75
|
-
*/
|
|
76
|
-
listTasks(options?: {
|
|
77
|
-
status?: TaskStatus;
|
|
78
|
-
priority?: TaskPriority;
|
|
79
|
-
assignedAgentId?: string;
|
|
80
|
-
}): Promise<Task[]>;
|
|
81
|
-
/**
|
|
82
|
-
* Get task statistics
|
|
83
|
-
*/
|
|
84
|
-
getTaskStatistics(): Promise<TaskStatistics>;
|
|
85
|
-
/**
|
|
86
|
-
* Assign pending tasks to available agents
|
|
87
|
-
*/
|
|
88
|
-
processPendingTasks(): Promise<number>;
|
|
89
|
-
/**
|
|
90
|
-
* Complete a task
|
|
91
|
-
*/
|
|
92
|
-
completeTask(taskId: string, output?: unknown): Promise<void>;
|
|
93
|
-
/**
|
|
94
|
-
* Fail a task
|
|
95
|
-
*/
|
|
96
|
-
failTask(taskId: string, error: string): Promise<boolean>;
|
|
97
|
-
/**
|
|
98
|
-
* Get swarm health
|
|
99
|
-
*/
|
|
100
|
-
getHealth(): Promise<SwarmHealth>;
|
|
101
|
-
/**
|
|
102
|
-
* Get scaling recommendation
|
|
103
|
-
*/
|
|
104
|
-
getScalingRecommendation(): Promise<{
|
|
105
|
-
action: "scale-up" | "scale-down" | "none";
|
|
106
|
-
count: number;
|
|
107
|
-
reason: string;
|
|
108
|
-
}>;
|
|
109
|
-
initialize(): Promise<void>;
|
|
110
|
-
shutdown(): Promise<void>;
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=swarm-application-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swarm-application-service.d.ts","sourceRoot":"","sources":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,CAAC;IAI/D;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC;IAIvC;;OAEG;IACG,wBAAwB;;;;;IAQxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIhC"}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Swarm Application Service - Application Layer
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates swarm operations and provides simplified interface.
|
|
5
|
-
*
|
|
6
|
-
* @module v3/swarm/application/services
|
|
7
|
-
*/
|
|
8
|
-
import { CoordinationService } from '../../domain/services/coordination-service.js';
|
|
9
|
-
import { SpawnAgentCommandHandler, TerminateAgentCommandHandler } from '../commands/spawn-agent.command.js';
|
|
10
|
-
import { CreateTaskCommandHandler, CancelTaskCommandHandler } from '../commands/create-task.command.js';
|
|
11
|
-
/**
|
|
12
|
-
* Swarm Application Service
|
|
13
|
-
*/
|
|
14
|
-
export class SwarmApplicationService {
|
|
15
|
-
agentRepository;
|
|
16
|
-
taskRepository;
|
|
17
|
-
config;
|
|
18
|
-
coordinationService;
|
|
19
|
-
spawnHandler;
|
|
20
|
-
terminateHandler;
|
|
21
|
-
createTaskHandler;
|
|
22
|
-
cancelTaskHandler;
|
|
23
|
-
constructor(agentRepository, taskRepository, config = {}) {
|
|
24
|
-
this.agentRepository = agentRepository;
|
|
25
|
-
this.taskRepository = taskRepository;
|
|
26
|
-
this.config = config;
|
|
27
|
-
this.coordinationService = new CoordinationService(agentRepository, taskRepository);
|
|
28
|
-
this.spawnHandler = new SpawnAgentCommandHandler(agentRepository);
|
|
29
|
-
this.terminateHandler = new TerminateAgentCommandHandler(agentRepository);
|
|
30
|
-
this.createTaskHandler = new CreateTaskCommandHandler(taskRepository);
|
|
31
|
-
this.cancelTaskHandler = new CancelTaskCommandHandler(taskRepository);
|
|
32
|
-
}
|
|
33
|
-
// ============================================================================
|
|
34
|
-
// Agent Operations
|
|
35
|
-
// ============================================================================
|
|
36
|
-
/**
|
|
37
|
-
* Spawn a new agent
|
|
38
|
-
*/
|
|
39
|
-
async spawnAgent(input) {
|
|
40
|
-
const result = await this.spawnHandler.execute(input);
|
|
41
|
-
return result.agent;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Terminate an agent
|
|
45
|
-
*/
|
|
46
|
-
async terminateAgent(agentId, force = false) {
|
|
47
|
-
await this.terminateHandler.execute({ agentId, force });
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get agent by ID
|
|
51
|
-
*/
|
|
52
|
-
async getAgent(agentId) {
|
|
53
|
-
return this.agentRepository.findById(agentId);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* List all agents
|
|
57
|
-
*/
|
|
58
|
-
async listAgents(options) {
|
|
59
|
-
return this.agentRepository.findAll(options);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get agent statistics
|
|
63
|
-
*/
|
|
64
|
-
async getAgentStatistics() {
|
|
65
|
-
return this.agentRepository.getStatistics();
|
|
66
|
-
}
|
|
67
|
-
// ============================================================================
|
|
68
|
-
// Task Operations
|
|
69
|
-
// ============================================================================
|
|
70
|
-
/**
|
|
71
|
-
* Create a new task
|
|
72
|
-
*/
|
|
73
|
-
async createTask(input) {
|
|
74
|
-
const result = await this.createTaskHandler.execute(input);
|
|
75
|
-
return result.task;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Cancel a task
|
|
79
|
-
*/
|
|
80
|
-
async cancelTask(taskId) {
|
|
81
|
-
await this.cancelTaskHandler.execute({ taskId });
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Get task by ID
|
|
85
|
-
*/
|
|
86
|
-
async getTask(taskId) {
|
|
87
|
-
return this.taskRepository.findById(taskId);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* List tasks
|
|
91
|
-
*/
|
|
92
|
-
async listTasks(options) {
|
|
93
|
-
return this.taskRepository.findAll(options);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Get task statistics
|
|
97
|
-
*/
|
|
98
|
-
async getTaskStatistics() {
|
|
99
|
-
return this.taskRepository.getStatistics();
|
|
100
|
-
}
|
|
101
|
-
// ============================================================================
|
|
102
|
-
// Orchestration
|
|
103
|
-
// ============================================================================
|
|
104
|
-
/**
|
|
105
|
-
* Assign pending tasks to available agents
|
|
106
|
-
*/
|
|
107
|
-
async processPendingTasks() {
|
|
108
|
-
const queuedTasks = await this.taskRepository.findQueued();
|
|
109
|
-
let assigned = 0;
|
|
110
|
-
for (const task of queuedTasks) {
|
|
111
|
-
const result = await this.coordinationService.assignTask(task.id, this.config.loadBalancingStrategy ?? 'capability-match');
|
|
112
|
-
if (result.success)
|
|
113
|
-
assigned++;
|
|
114
|
-
}
|
|
115
|
-
return assigned;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Complete a task
|
|
119
|
-
*/
|
|
120
|
-
async completeTask(taskId, output) {
|
|
121
|
-
await this.coordinationService.processTaskCompletion(taskId, output);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Fail a task
|
|
125
|
-
*/
|
|
126
|
-
async failTask(taskId, error) {
|
|
127
|
-
return this.coordinationService.processTaskFailure(taskId, error);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Get swarm health
|
|
131
|
-
*/
|
|
132
|
-
async getHealth() {
|
|
133
|
-
return this.coordinationService.getSwarmHealth();
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Get scaling recommendation
|
|
137
|
-
*/
|
|
138
|
-
async getScalingRecommendation() {
|
|
139
|
-
return this.coordinationService.calculateScalingRecommendation();
|
|
140
|
-
}
|
|
141
|
-
// ============================================================================
|
|
142
|
-
// Lifecycle
|
|
143
|
-
// ============================================================================
|
|
144
|
-
async initialize() {
|
|
145
|
-
await this.agentRepository.initialize();
|
|
146
|
-
await this.taskRepository.initialize();
|
|
147
|
-
}
|
|
148
|
-
async shutdown() {
|
|
149
|
-
await this.agentRepository.shutdown();
|
|
150
|
-
await this.taskRepository.shutdown();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
//# sourceMappingURL=swarm-application-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swarm-application-service.js","sourceRoot":"","sources":["../../../src/application/services/swarm-application-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,mBAAmB,EAAsC,MAAM,+CAA+C,CAAC;AACxH,OAAO,EAAE,wBAAwB,EAAmB,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAC7H,OAAO,EAAE,wBAAwB,EAAmB,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAYzH;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAQf;IACA;IACA;IATF,mBAAmB,CAAsB;IACzC,YAAY,CAA2B;IACvC,gBAAgB,CAA+B;IAC/C,iBAAiB,CAA2B;IAC5C,iBAAiB,CAA2B;IAE7D,YACmB,eAAiC,EACjC,cAA+B,EAC/B,SAAsB,EAAE;QAFxB,oBAAe,GAAf,eAAe,CAAkB;QACjC,mBAAc,GAAd,cAAc,CAAiB;QAC/B,WAAM,GAAN,MAAM,CAAkB;QAEzC,IAAI,CAAC,mBAAmB,GAAG,IAAI,mBAAmB,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;QACpF,IAAI,CAAC,YAAY,GAAG,IAAI,wBAAwB,CAAC,eAAe,CAAC,CAAC;QAClE,IAAI,CAAC,gBAAgB,GAAG,IAAI,4BAA4B,CAAC,eAAe,CAAC,CAAC;QAC1E,IAAI,CAAC,iBAAiB,GAAG,IAAI,wBAAwB,CAAC,cAAc,CAAC,CAAC;QACtE,IAAI,CAAC,iBAAiB,GAAG,IAAI,wBAAwB,CAAC,cAAc,CAAC,CAAC;IACxE,CAAC;IAED,+EAA+E;IAC/E,mBAAmB;IACnB,+EAA+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E,CAAC;IAED,+EAA+E;IAC/E,YAAY;IACZ,+EAA+E;IAE/E,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;QACxC,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;QACtC,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Attention Coordinator
|
|
3
|
-
*
|
|
4
|
-
* Implements attention-based coordination mechanisms from agentic-flow@alpha:
|
|
5
|
-
* - multi-head: Standard multi-head attention
|
|
6
|
-
* - flash: 2.49x-7.47x speedup, 75% memory reduction
|
|
7
|
-
* - linear: For long sequences
|
|
8
|
-
* - hyperbolic: Hierarchical data
|
|
9
|
-
* - moe: Mixture of Experts routing
|
|
10
|
-
* - graph-rope: Graph-aware positional embeddings
|
|
11
|
-
*
|
|
12
|
-
* Performance Targets:
|
|
13
|
-
* - Flash Attention: 2.49x-7.47x speedup
|
|
14
|
-
* - Memory Reduction: 50-75%
|
|
15
|
-
* - MoE Routing: <5ms
|
|
16
|
-
*
|
|
17
|
-
* @module v3/swarm/attention-coordinator
|
|
18
|
-
*/
|
|
19
|
-
import { EventEmitter } from 'events';
|
|
20
|
-
/**
|
|
21
|
-
* Attention mechanism types
|
|
22
|
-
*/
|
|
23
|
-
export type AttentionType = 'multi-head' | 'flash' | 'linear' | 'hyperbolic' | 'moe' | 'graph-rope';
|
|
24
|
-
/**
|
|
25
|
-
* Agent output for coordination
|
|
26
|
-
*/
|
|
27
|
-
export interface AgentOutput {
|
|
28
|
-
agentId: string;
|
|
29
|
-
content: string | Record<string, unknown>;
|
|
30
|
-
embedding?: Float32Array | number[];
|
|
31
|
-
confidence?: number;
|
|
32
|
-
tokens?: number;
|
|
33
|
-
metadata?: Record<string, unknown>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Task for routing
|
|
37
|
-
*/
|
|
38
|
-
export interface Task {
|
|
39
|
-
id: string;
|
|
40
|
-
type: string;
|
|
41
|
-
content: string;
|
|
42
|
-
embedding?: Float32Array | number[];
|
|
43
|
-
priority?: number;
|
|
44
|
-
metadata?: Record<string, unknown>;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Specialized agent for MoE routing
|
|
48
|
-
*/
|
|
49
|
-
export interface SpecializedAgent {
|
|
50
|
-
id: string;
|
|
51
|
-
name: string;
|
|
52
|
-
expertise: string[];
|
|
53
|
-
embedding: Float32Array | number[];
|
|
54
|
-
capacity: number;
|
|
55
|
-
currentLoad: number;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Swarm topology for GraphRoPE
|
|
59
|
-
*/
|
|
60
|
-
export interface SwarmTopology {
|
|
61
|
-
type: 'mesh' | 'hierarchical' | 'star' | 'ring';
|
|
62
|
-
nodes: string[];
|
|
63
|
-
edges: Array<{
|
|
64
|
-
from: string;
|
|
65
|
-
to: string;
|
|
66
|
-
weight?: number;
|
|
67
|
-
}>;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Graph context for topology-aware coordination
|
|
71
|
-
*/
|
|
72
|
-
export interface GraphContext {
|
|
73
|
-
adjacencyMatrix?: number[][];
|
|
74
|
-
nodeFeatures?: number[][];
|
|
75
|
-
edgeWeights?: number[];
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Coordination result
|
|
79
|
-
*/
|
|
80
|
-
export interface CoordinationResult {
|
|
81
|
-
success: boolean;
|
|
82
|
-
mechanism: AttentionType;
|
|
83
|
-
consensusOutput: string | Record<string, unknown>;
|
|
84
|
-
attentionWeights?: number[];
|
|
85
|
-
confidence: number;
|
|
86
|
-
latency: number;
|
|
87
|
-
memoryUsed?: number;
|
|
88
|
-
participatingAgents: string[];
|
|
89
|
-
metadata?: Record<string, unknown>;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Expert routing result
|
|
93
|
-
*/
|
|
94
|
-
export interface ExpertRoutingResult {
|
|
95
|
-
success: boolean;
|
|
96
|
-
selectedExperts: Array<{
|
|
97
|
-
agentId: string;
|
|
98
|
-
name: string;
|
|
99
|
-
score: number;
|
|
100
|
-
assignedTokens?: number;
|
|
101
|
-
}>;
|
|
102
|
-
routingLatency: number;
|
|
103
|
-
loadBalanced: boolean;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Attention coordinator configuration
|
|
107
|
-
*/
|
|
108
|
-
export interface AttentionCoordinatorConfig {
|
|
109
|
-
defaultMechanism: AttentionType;
|
|
110
|
-
flashAttention: {
|
|
111
|
-
blockSize: number;
|
|
112
|
-
causal: boolean;
|
|
113
|
-
};
|
|
114
|
-
moe: {
|
|
115
|
-
topK: number;
|
|
116
|
-
capacityFactor: number;
|
|
117
|
-
loadBalancingLoss: boolean;
|
|
118
|
-
};
|
|
119
|
-
hyperbolic: {
|
|
120
|
-
curvature: number;
|
|
121
|
-
dimension: number;
|
|
122
|
-
};
|
|
123
|
-
graphRope: {
|
|
124
|
-
maxDistance: number;
|
|
125
|
-
distanceScale: number;
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* AttentionCoordinator
|
|
130
|
-
*
|
|
131
|
-
* Coordinates multiple agents using various attention mechanisms for
|
|
132
|
-
* consensus building and task routing.
|
|
133
|
-
*/
|
|
134
|
-
export declare class AttentionCoordinator extends EventEmitter {
|
|
135
|
-
private config;
|
|
136
|
-
private performanceStats;
|
|
137
|
-
constructor(config?: Partial<AttentionCoordinatorConfig>);
|
|
138
|
-
/**
|
|
139
|
-
* Coordinate agents using specified attention mechanism
|
|
140
|
-
*
|
|
141
|
-
* @param agentOutputs - Outputs from multiple agents
|
|
142
|
-
* @param mechanism - Attention mechanism to use
|
|
143
|
-
* @returns Coordination result with consensus
|
|
144
|
-
*/
|
|
145
|
-
coordinateAgents(agentOutputs: AgentOutput[], mechanism?: AttentionType): Promise<CoordinationResult>;
|
|
146
|
-
/**
|
|
147
|
-
* Route task to specialized experts using MoE
|
|
148
|
-
*
|
|
149
|
-
* @param task - Task to route
|
|
150
|
-
* @param agents - Available specialized agents
|
|
151
|
-
* @param topK - Number of experts to select
|
|
152
|
-
* @returns Routing result with selected experts
|
|
153
|
-
*/
|
|
154
|
-
routeToExperts(task: Task, agents: SpecializedAgent[], topK?: number): Promise<ExpertRoutingResult>;
|
|
155
|
-
/**
|
|
156
|
-
* Topology-aware coordination using GraphRoPE
|
|
157
|
-
*
|
|
158
|
-
* @param agentOutputs - Agent outputs
|
|
159
|
-
* @param topology - Swarm topology
|
|
160
|
-
* @param graphContext - Optional graph context
|
|
161
|
-
* @returns Coordination result
|
|
162
|
-
*/
|
|
163
|
-
topologyAwareCoordination(agentOutputs: AgentOutput[], topology: SwarmTopology, graphContext?: GraphContext): Promise<CoordinationResult>;
|
|
164
|
-
/**
|
|
165
|
-
* Hierarchical coordination for queen-worker swarms
|
|
166
|
-
*
|
|
167
|
-
* @param queenOutputs - Outputs from queen agents
|
|
168
|
-
* @param workerOutputs - Outputs from worker agents
|
|
169
|
-
* @param curvature - Hyperbolic curvature (default: -1)
|
|
170
|
-
* @returns Coordination result
|
|
171
|
-
*/
|
|
172
|
-
hierarchicalCoordination(queenOutputs: AgentOutput[], workerOutputs: AgentOutput[], curvature?: number): Promise<CoordinationResult>;
|
|
173
|
-
/**
|
|
174
|
-
* Flash Attention - 2.49x-7.47x speedup
|
|
175
|
-
*/
|
|
176
|
-
private flashAttentionCoordination;
|
|
177
|
-
/**
|
|
178
|
-
* Standard Multi-Head Attention
|
|
179
|
-
*/
|
|
180
|
-
private multiHeadAttentionCoordination;
|
|
181
|
-
/**
|
|
182
|
-
* Linear Attention for long sequences
|
|
183
|
-
*/
|
|
184
|
-
private linearAttentionCoordination;
|
|
185
|
-
/**
|
|
186
|
-
* Hyperbolic Attention for hierarchical data
|
|
187
|
-
*/
|
|
188
|
-
private hyperbolicAttentionCoordination;
|
|
189
|
-
/**
|
|
190
|
-
* Mixture of Experts coordination
|
|
191
|
-
*/
|
|
192
|
-
private moeCoordination;
|
|
193
|
-
/**
|
|
194
|
-
* Graph-aware RoPE coordination
|
|
195
|
-
*/
|
|
196
|
-
private graphRopeCoordination;
|
|
197
|
-
private graphRopeCoordinationWithPositions;
|
|
198
|
-
private computeAttentionScore;
|
|
199
|
-
private getOrCreateEmbedding;
|
|
200
|
-
private computeWeightedConsensus;
|
|
201
|
-
private computeConfidence;
|
|
202
|
-
private calculateExpertScores;
|
|
203
|
-
private selectTopKExperts;
|
|
204
|
-
private buildGraphPositionEncodings;
|
|
205
|
-
private computeRotaryEncoding;
|
|
206
|
-
private updateStats;
|
|
207
|
-
getPerformanceStats(): typeof this.performanceStats;
|
|
208
|
-
getConfig(): AttentionCoordinatorConfig;
|
|
209
|
-
}
|
|
210
|
-
export declare function createAttentionCoordinator(config?: Partial<AttentionCoordinatorConfig>): AttentionCoordinator;
|
|
211
|
-
export default AttentionCoordinator;
|
|
212
|
-
//# sourceMappingURL=attention-coordinator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attention-coordinator.d.ts","sourceRoot":"","sources":["../src/attention-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAMtC;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,OAAO,GACP,QAAQ,GACR,YAAY,GACZ,KAAK,GACL,YAAY,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,SAAS,CAAC,EAA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