@clawswarm/core 0.1.0-alpha

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/swarm.js ADDED
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ /**
3
+ * ClawSwarm — the top-level orchestrator.
4
+ * @module @clawswarm/core/swarm
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ClawSwarm = void 0;
11
+ const eventemitter3_1 = __importDefault(require("eventemitter3"));
12
+ const agent_js_1 = require("./agent.js");
13
+ const task_js_1 = require("./task.js");
14
+ const goal_js_1 = require("./goal.js");
15
+ const chief_js_1 = require("./chief.js");
16
+ /**
17
+ * ClawSwarm — deploy and orchestrate a team of AI agents.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const swarm = new ClawSwarm({
22
+ * agents: [
23
+ * Agent.research({ model: 'claude-sonnet-4' }),
24
+ * Agent.code({ model: 'gpt-4o' }),
25
+ * Agent.ops({ model: 'gemini-pro' }),
26
+ * ],
27
+ * chiefReview: {
28
+ * autoApproveThreshold: 8,
29
+ * humanReviewThreshold: 5,
30
+ * },
31
+ * });
32
+ *
33
+ * swarm.on('task:completed', (task) => console.log('Done:', task.title));
34
+ *
35
+ * const goal = await swarm.createGoal({
36
+ * title: 'Write a blog post about AI',
37
+ * description: 'Research AI trends and write a 1000-word post',
38
+ * });
39
+ *
40
+ * const result = await swarm.execute(goal);
41
+ * ```
42
+ */
43
+ class ClawSwarm extends eventemitter3_1.default {
44
+ config;
45
+ agents;
46
+ taskManager;
47
+ goalManager;
48
+ planner;
49
+ reviewer;
50
+ constructor(config) {
51
+ super();
52
+ this.config = config;
53
+ this.agents = config.agents.map(c => new agent_js_1.Agent(c));
54
+ this.taskManager = new task_js_1.TaskManager();
55
+ this.goalManager = new goal_js_1.GoalManager();
56
+ this.planner = new goal_js_1.GoalPlanner(config);
57
+ this.reviewer = new chief_js_1.ChiefReviewer(config.chiefReview);
58
+ }
59
+ /**
60
+ * Create a new goal. Does not start execution yet.
61
+ *
62
+ * @param input - Goal title, description, and optional metadata
63
+ * @returns The created goal
64
+ */
65
+ async createGoal(input) {
66
+ const goal = this.goalManager.create(input);
67
+ this.emit('goal:created', goal);
68
+ return goal;
69
+ }
70
+ /**
71
+ * Execute a goal: plan, assign, run, review, and collect results.
72
+ *
73
+ * @param goal - The goal to execute (from createGoal)
74
+ * @returns Final result with deliverables and cost summary
75
+ */
76
+ async execute(goal) {
77
+ const startTime = Date.now();
78
+ try {
79
+ // 1. Planning phase
80
+ this.goalManager.setStatus(goal.id, 'planning');
81
+ this.emit('goal:planning', goal);
82
+ const tasks = await this.planner.decompose(goal, this.taskManager);
83
+ this.goalManager.setTasks(goal.id, tasks);
84
+ // 2. Execution phase
85
+ this.goalManager.setStatus(goal.id, 'in_progress');
86
+ let hadHumanReview = false;
87
+ // Execute tasks in dependency order
88
+ while (!this.taskManager.isGoalDone(goal.id)) {
89
+ const readyTasks = this.taskManager.getReady(goal.id);
90
+ if (readyTasks.length === 0)
91
+ break;
92
+ // Run all ready tasks (can parallelize)
93
+ await Promise.all(readyTasks.map(async (task) => {
94
+ const result = await this._executeTask(task);
95
+ if (result.hadHumanReview)
96
+ hadHumanReview = true;
97
+ }));
98
+ }
99
+ // 3. Collect results
100
+ const completedTasks = this.taskManager
101
+ .getByGoal(goal.id)
102
+ .filter(t => t.status === 'completed');
103
+ const deliverables = completedTasks.flatMap(t => t.deliverables);
104
+ const finalGoal = this.goalManager.setStatus(goal.id, 'completed');
105
+ this.emit('goal:completed', finalGoal);
106
+ return {
107
+ goal: finalGoal,
108
+ deliverables,
109
+ cost: finalGoal.cost,
110
+ hadHumanReview,
111
+ durationMs: Date.now() - startTime,
112
+ };
113
+ }
114
+ catch (error) {
115
+ const err = error instanceof Error ? error : new Error(String(error));
116
+ const failedGoal = this.goalManager.setStatus(goal.id, 'failed');
117
+ this.emit('goal:failed', failedGoal, err);
118
+ throw err;
119
+ }
120
+ }
121
+ /**
122
+ * Get all agents in this swarm.
123
+ */
124
+ getAgents() {
125
+ return [...this.agents];
126
+ }
127
+ /**
128
+ * Get an agent by type.
129
+ */
130
+ getAgent(type) {
131
+ return this.agents.find(a => a.type === type && a.status === 'idle');
132
+ }
133
+ // ─── Private ──────────────────────────────────────────────────────────────
134
+ async _executeTask(task) {
135
+ let hadHumanReview = false;
136
+ try {
137
+ // Assign to agent
138
+ const agentType = task.assignedTo ?? 'code';
139
+ const agent = this.getAgent(agentType);
140
+ if (!agent) {
141
+ throw new Error(`No available agent of type: ${agentType}`);
142
+ }
143
+ this.taskManager.assign(task.id, agentType);
144
+ this.emit('task:assigned', task, agentType);
145
+ // Execute
146
+ agent.status = 'busy';
147
+ this.taskManager.start(task.id);
148
+ this.emit('task:started', task);
149
+ const deliverables = await agent.execute(task);
150
+ agent.status = 'idle';
151
+ // Submit for review
152
+ const updatedTask = this.taskManager.submitForReview(task.id, deliverables);
153
+ // Run through chief review
154
+ let approved = false;
155
+ while (!approved) {
156
+ const review = await this.reviewer.review(updatedTask);
157
+ this.emit('task:review', updatedTask, review);
158
+ if (review.decision === 'approved') {
159
+ this.taskManager.approve(task.id);
160
+ this.taskManager.complete(task.id);
161
+ this.emit('task:completed', updatedTask);
162
+ approved = true;
163
+ }
164
+ else if (review.decision === 'human_review') {
165
+ hadHumanReview = true;
166
+ this.emit('human:review_required', updatedTask, review);
167
+ // In production: wait for human decision via webhook/callback
168
+ // For now, auto-approve after emitting
169
+ this.taskManager.approve(task.id);
170
+ this.taskManager.complete(task.id);
171
+ approved = true;
172
+ }
173
+ else {
174
+ // Rejected — attempt rework
175
+ this.emit('task:rejected', updatedTask, review);
176
+ try {
177
+ this.taskManager.rework(task.id, review.feedback);
178
+ this.emit('task:rework', updatedTask, review);
179
+ // Re-run with agent
180
+ const reworkDeliverables = await agent.execute(updatedTask);
181
+ this.taskManager.submitForReview(task.id, reworkDeliverables);
182
+ }
183
+ catch {
184
+ // Max rework exceeded
185
+ this.taskManager.reject(task.id, review.feedback);
186
+ this.emit('task:failed', updatedTask, new Error('Max rework cycles exceeded'));
187
+ approved = true; // exit loop
188
+ }
189
+ }
190
+ }
191
+ }
192
+ catch (error) {
193
+ const err = error instanceof Error ? error : new Error(String(error));
194
+ this.taskManager.fail(task.id, err);
195
+ this.emit('task:failed', task, err);
196
+ }
197
+ return { hadHumanReview };
198
+ }
199
+ }
200
+ exports.ClawSwarm = ClawSwarm;
201
+ //# sourceMappingURL=swarm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swarm.js","sourceRoot":"","sources":["../src/swarm.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kEAAyC;AAUzC,yCAAmC;AACnC,uCAAwC;AACxC,uCAAqD;AACrD,yCAA2C;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,SAAU,SAAQ,uBAAyB;IACrC,MAAM,CAAc;IACpB,MAAM,CAAU;IAChB,WAAW,CAAc;IACzB,WAAW,CAAc;IACzB,OAAO,CAAc;IACrB,QAAQ,CAAgB;IAEzC,YAAY,MAAmB;QAC7B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,gBAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,GAAG,IAAI,qBAAW,EAAE,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,qBAAW,EAAE,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,qBAAW,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,wBAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACxD,CAAC;I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M,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;wBAC5D,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,EAAE,kBAAkB,CAAC,CAAC;oBAChE,CAAC;oBAAC,MAAM,CAAC;wBACP,sBAAsB;wBACtB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;wBAClD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC;wBAC/E,QAAQ,GAAG,IAAI,CAAC,CAAC,YAAY;oBAC/B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACtE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,EAAE,cAAc,EAAE,CAAC;IAC5B,CAAC;CACF;AAjLD,8BAiLC"}
package/dist/task.d.ts ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Task lifecycle management.
3
+ * @module @clawswarm/core/task
4
+ */
5
+ import { Task, AgentType, Deliverable } from './types.js';
6
+ /**
7
+ * Manages the lifecycle of tasks within a goal.
8
+ * Handles state transitions, rework cycles, and deliverable collection.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const manager = new TaskManager();
13
+ * const task = manager.create({
14
+ * goalId: 'goal-123',
15
+ * title: 'Research AI trends',
16
+ * description: 'Find the top 5 AI trends in 2026',
17
+ * assignedTo: 'research',
18
+ * });
19
+ *
20
+ * manager.start(task.id);
21
+ * manager.complete(task.id, [{ type: 'text', label: 'Report', content: '...' }]);
22
+ * ```
23
+ */
24
+ export declare class TaskManager {
25
+ private tasks;
26
+ /**
27
+ * Create a new task.
28
+ */
29
+ create(input: Omit<Task, 'id' | 'status' | 'deliverables' | 'reworkCount' | 'maxReworkCycles' | 'createdAt' | 'updatedAt'>): Task;
30
+ /**
31
+ * Get a task by ID.
32
+ */
33
+ get(taskId: string): Task | undefined;
34
+ /**
35
+ * Get all tasks.
36
+ */
37
+ getAll(): Task[];
38
+ /**
39
+ * Get tasks by goal ID.
40
+ */
41
+ getByGoal(goalId: string): Task[];
42
+ /**
43
+ * Get tasks that are ready to run (all dependencies completed).
44
+ */
45
+ getReady(goalId: string): Task[];
46
+ /**
47
+ * Assign a task to an agent type.
48
+ */
49
+ assign(taskId: string, agentType: AgentType): Task;
50
+ /**
51
+ * Mark a task as in progress.
52
+ */
53
+ start(taskId: string): Task;
54
+ /**
55
+ * Submit a task for review with its deliverables.
56
+ */
57
+ submitForReview(taskId: string, deliverables: Deliverable[]): Task;
58
+ /**
59
+ * Mark a task as approved.
60
+ */
61
+ approve(taskId: string): Task;
62
+ /**
63
+ * Mark a task as completed (after approval and any post-processing).
64
+ */
65
+ complete(taskId: string): Task;
66
+ /**
67
+ * Mark a task for rework. Increments rework counter.
68
+ * @throws If max rework cycles exceeded
69
+ */
70
+ rework(taskId: string, feedback: string): Task;
71
+ /**
72
+ * Mark a task as rejected (max rework exceeded or explicitly rejected).
73
+ */
74
+ reject(taskId: string, reason: string): Task;
75
+ /**
76
+ * Mark a task as failed (unexpected error).
77
+ */
78
+ fail(taskId: string, error: Error): Task;
79
+ /**
80
+ * Check if a goal has all tasks completed or failed.
81
+ */
82
+ isGoalDone(goalId: string): boolean;
83
+ private _transition;
84
+ private _getOrThrow;
85
+ }
86
+ //# sourceMappingURL=task.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.d.ts","s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KAAK,GAAG,IAAI;IASxC;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAQnC,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,WAAW;CAKpB"}
package/dist/task.js ADDED
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ /**
3
+ * Task lifecycle management.
4
+ * @module @clawswarm/core/task
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.TaskManager = void 0;
8
+ // ─── Task Manager ─────────────────────────────────────────────────────────────
9
+ /**
10
+ * Manages the lifecycle of tasks within a goal.
11
+ * Handles state transitions, rework cycles, and deliverable collection.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const manager = new TaskManager();
16
+ * const task = manager.create({
17
+ * goalId: 'goal-123',
18
+ * title: 'Research AI trends',
19
+ * description: 'Find the top 5 AI trends in 2026',
20
+ * assignedTo: 'research',
21
+ * });
22
+ *
23
+ * manager.start(task.id);
24
+ * manager.complete(task.id, [{ type: 'text', label: 'Report', content: '...' }]);
25
+ * ```
26
+ */
27
+ class TaskManager {
28
+ tasks = new Map();
29
+ /**
30
+ * Create a new task.
31
+ */
32
+ create(input) {
33
+ const task = {
34
+ ...input,
35
+ id: `task-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
36
+ status: 'pending',
37
+ deliverables: [],
38
+ reworkCount: 0,
39
+ maxReworkCycles: 3,
40
+ dependsOn: input.dependsOn ?? [],
41
+ createdAt: new Date().toISOString(),
42
+ updatedAt: new Date().toISOString(),
43
+ };
44
+ this.tasks.set(task.id, task);
45
+ return task;
46
+ }
47
+ /**
48
+ * Get a task by ID.
49
+ */
50
+ get(taskId) {
51
+ return this.tasks.get(taskId);
52
+ }
53
+ /**
54
+ * Get all tasks.
55
+ */
56
+ getAll() {
57
+ return Array.from(this.tasks.values());
58
+ }
59
+ /**
60
+ * Get tasks by goal ID.
61
+ */
62
+ getByGoal(goalId) {
63
+ return this.getAll().filter(t => t.goalId === goalId);
64
+ }
65
+ /**
66
+ * Get tasks that are ready to run (all dependencies completed).
67
+ */
68
+ getReady(goalId) {
69
+ const tasks = this.getByGoal(goalId);
70
+ const completedIds = new Set(tasks.filter(t => t.status === 'completed').map(t => t.id));
71
+ return tasks.filter(t => t.status === 'pending' &&
72
+ t.dependsOn.every(depId => completedIds.has(depId)));
73
+ }
74
+ /**
75
+ * Assign a task to an agent type.
76
+ */
77
+ assign(taskId, agentType) {
78
+ return this._transition(taskId, 'assigned', task => {
79
+ task.assignedTo = agentType;
80
+ });
81
+ }
82
+ /**
83
+ * Mark a task as in progress.
84
+ */
85
+ start(taskId) {
86
+ return this._transition(taskId, 'in_progress');
87
+ }
88
+ /**
89
+ * Submit a task for review with its deliverables.
90
+ */
91
+ submitForReview(taskId, deliverables) {
92
+ return this._transition(taskId, 'review', task => {
93
+ task.deliverables = deliverables;
94
+ });
95
+ }
96
+ /**
97
+ * Mark a task as approved.
98
+ */
99
+ approve(taskId) {
100
+ return this._transition(taskId, 'approved');
101
+ }
102
+ /**
103
+ * Mark a task as completed (after approval and any post-processing).
104
+ */
105
+ complete(taskId) {
106
+ return this._transition(taskId, 'completed');
107
+ }
108
+ /**
109
+ * Mark a task for rework. Increments rework counter.
110
+ * @throws If max rework cycles exceeded
111
+ */
112
+ rework(taskId, feedback) {
113
+ const task = this._getOrThrow(taskId);
114
+ if (task.reworkCount >= task.maxReworkCycles) {
115
+ throw new Error(`Task ${taskId} has exceeded max rework cycles (${task.maxReworkCycles}). Failing task.`);
116
+ }
117
+ return this._transition(taskId, 'rework', t => {
118
+ t.reworkCount += 1;
119
+ // Store feedback as a note in deliverables for the agent to reference
120
+ t.deliverables = [
121
+ ...t.deliverables,
122
+ {
123
+ type: 'text',
124
+ label: `Rework Feedback (Cycle ${t.reworkCount})`,
125
+ content: feedback,
126
+ },
127
+ ];
128
+ });
129
+ }
130
+ /**
131
+ * Mark a task as rejected (max rework exceeded or explicitly rejected).
132
+ */
133
+ reject(taskId, reason) {
134
+ return this._transition(taskId, 'rejected', task => {
135
+ task.deliverables = [
136
+ ...task.deliverables,
137
+ { type: 'text', label: 'Rejection Reason', content: reason },
138
+ ];
139
+ });
140
+ }
141
+ /**
142
+ * Mark a task as failed (unexpected error).
143
+ */
144
+ fail(taskId, error) {
145
+ return this._transition(taskId, 'failed', task => {
146
+ task.deliverables = [
147
+ ...task.deliverables,
148
+ { type: 'text', label: 'Error', content: error.message },
149
+ ];
150
+ });
151
+ }
152
+ /**
153
+ * Check if a goal has all tasks completed or failed.
154
+ */
155
+ isGoalDone(goalId) {
156
+ const tasks = this.getByGoal(goalId);
157
+ if (tasks.length === 0)
158
+ return false;
159
+ return tasks.every(t => t.status === 'completed' || t.status === 'failed' || t.status === 'rejected');
160
+ }
161
+ // ─── Private ──────────────────────────────────────────────────────────────
162
+ _transition(taskId, status, mutate) {
163
+ const task = this._getOrThrow(taskId);
164
+ task.status = status;
165
+ task.updatedAt = new Date().toISOString();
166
+ mutate?.(task);
167
+ return task;
168
+ }
169
+ _getOrThrow(taskId) {
170
+ const task = this.tasks.get(taskId);
171
+ if (!task)
172
+ throw new Error(`Task not found: ${taskId}`);
173
+ return task;
174
+ }
175
+ }
176
+ exports.TaskManager = TaskManager;
177
+ //# sourceMappingURL=task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.js","sourceRoot":"","sources":["../src/task.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,iFAAiF;AAEjF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,WAAW;IACd,KAAK,GAAsB,IAAI,GAAG,EAAE,CAAC;IAE7C;;OAEG;IACH,MAAM,CAAC,KAAmH;QACxH,MAAM,IAAI,GAAS;YACjB,GAAG,KAAK;YACR,EAAE,EAAE,QAAQ,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;YAClE,MAAM,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C;IACxG,CAAC;IAED,6EAA6E;IAErE,WAAW,CACjB,MAAc,EACd,MAAkB,EAClB,MAA6B;QAE7B,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1C,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,WAAW,CAAC,MAAc;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAhLD,kCAgLC"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Shared types for the ClawSwarm core framework.
3
+ * @module @clawswarm/core/types
4
+ */
5
+ /** Supported LLM model identifiers */
6
+ export type ModelId = 'claude-sonnet-4' | 'claude-opus-4' | 'gpt-4o' | 'gpt-4o-mini' | 'gemini-pro' | 'gemini-flash' | string;
7
+ /** Agent specializations available in ClawSwarm */
8
+ export type AgentType = 'research' | 'code' | 'ops' | 'planner' | 'custom';
9
+ /** Current status of an agent */
10
+ export type AgentStatus = 'idle' | 'busy' | 'error' | 'offline';
11
+ /** Configuration for creating an agent */
12
+ export interface AgentConfig {
13
+ /** Agent type/specialization */
14
+ type: AgentType;
15
+ /** LLM model to use */
16
+ model: ModelId;
17
+ /** Optional display name */
18
+ name?: string;
19
+ /** System prompt override */
20
+ systemPrompt?: string;
21
+ /** Max tokens per request */
22
+ maxTokens?: number;
23
+ /** Temperature (0-1) */
24
+ temperature?: number;
25
+ /** Tools/capabilities this agent has access to */
26
+ tools?: string[];
27
+ }
28
+ /** Task lifecycle states */
29
+ export type TaskStatus = 'pending' | 'assigned' | 'in_progress' | 'review' | 'approved' | 'rejected' | 'rework' | 'completed' | 'failed';
30
+ /** A deliverable produced by a task */
31
+ export interface Deliverable {
32
+ /** Type of deliverable */
33
+ type: 'text' | 'code' | 'file' | 'url' | 'data';
34
+ /** Human-readable label */
35
+ label: string;
36
+ /** The content */
37
+ content: string;
38
+ /** MIME type if applicable */
39
+ mimeType?: string;
40
+ /** File path if type is 'file' */
41
+ filePath?: string;
42
+ }
43
+ /** A task within a goal */
44
+ export interface Task {
45
+ /** Unique task ID */
46
+ id: string;
47
+ /** Parent goal ID */
48
+ goalId: string;
49
+ /** Task title */
50
+ title: string;
51
+ /** Detailed description of what to do */
52
+ description: string;
53
+ /** Current lifecycle status */
54
+ status: TaskStatus;
55
+ /** Agent type assigned to this task */
56
+ assignedTo?: AgentType;
57
+ /** Task outputs/deliverables */
58
+ deliverables: Deliverable[];
59
+ /** Number of rework cycles attempted */
60
+ reworkCount: number;
61
+ /** Max rework cycles allowed */
62
+ maxReworkCycles: number;
63
+ /** ISO timestamp when created */
64
+ createdAt: string;
65
+ /** ISO timestamp when last updated */
66
+ updatedAt: string;
67
+ /** Dependencies: task IDs that must complete before this one */
68
+ dependsOn: string[];
69
+ }
70
+ /** Goal lifecycle states */
71
+ export type GoalStatus = 'created' | 'planning' | 'in_progress' | 'review' | 'completed' | 'failed';
72
+ /** Input for creating a goal */
73
+ export interface CreateGoalInput {
74
+ /** Short title for the goal */
75
+ title: string;
76
+ /** Full description of what to accomplish */
77
+ description: string;
78
+ /** Priority (higher = more urgent) */
79
+ priority?: number;
80
+ /** Deadline as ISO timestamp */
81
+ deadline?: string;
82
+ /** Tags for categorization */
83
+ tags?: string[];
84
+ }
85
+ /** A goal with all its tasks */
86
+ export interface Goal extends CreateGoalInput {
87
+ /** Unique goal ID */
88
+ id: string;
89
+ /** Current status */
90
+ status: GoalStatus;
91
+ /** Tasks decomposed from this goal */
92
+ tasks: Task[];
93
+ /** Combined deliverables from all completed tasks */
94
+ deliverables: Deliverable[];
95
+ /** Cost tracking */
96
+ cost: CostSummary;
97
+ /** ISO timestamp when created */
98
+ createdAt: string;
99
+ /** ISO timestamp when completed */
100
+ completedAt?: string;
101
+ }
102
+ /** Result of a chief review */
103
+ export interface ReviewResult {
104
+ /** Task ID that was reviewed */
105
+ taskId: string;
106
+ /** Score from 0-10 */
107
+ score: number;
108
+ /** Decision based on score thresholds */
109
+ decision: 'approved' | 'human_review' | 'rejected';
110
+ /** Reviewer's feedback */
111
+ feedback: string;
112
+ /** Specific issues found (if any) */
113
+ issues: string[];
114
+ /** Suggestions for improvement */
115
+ suggestions: string[];
116
+ /** ISO timestamp of review */
117
+ reviewedAt: string;
118
+ }
119
+ /** Configuration for the chief review pipeline */
120
+ export interface ChiefReviewConfig {
121
+ /** Score threshold for auto-approval (default: 8) */
122
+ autoApproveThreshold?: number;
123
+ /** Score threshold for human review (default: 5) */
124
+ humanReviewThreshold?: number;
125
+ /** Model to use for the reviewer */
126
+ reviewerModel?: ModelId;
127
+ /** Custom review criteria */
128
+ criteria?: string[];
129
+ }
130
+ /** Token usage for a single request */
131
+ export interface TokenUsage {
132
+ promptTokens: number;
133
+ completionTokens: number;
134
+ totalTokens: number;
135
+ }
136
+ /** Cost summary for a goal or task */
137
+ export interface CostSummary {
138
+ /** Total tokens used */
139
+ totalTokens: number;
140
+ /** Estimated cost in USD */
141
+ estimatedCostUsd: number;
142
+ /** Per-agent breakdown */
143
+ byAgent: Record<string, {
144
+ tokens: number;
145
+ costUsd: number;
146
+ }>;
147
+ }
148
+ /** Events emitted by ClawSwarm */
149
+ export interface SwarmEvents {
150
+ 'goal:created': (goal: Goal) => void;
151
+ 'goal:planning': (goal: Goal) => void;
152
+ 'goal:completed': (goal: Goal) => void;
153
+ 'goal:failed': (goal: Goal, error: Error) => void;
154
+ 'task:assigned': (task: Task, agentType: AgentType) => void;
155
+ 'task:started': (task: Task) => void;
156
+ 'task:completed': (task: Task) => void;
157
+ 'task:review': (task: Task, review: ReviewResult) => void;
158
+ 'task:rejected': (task: Task, review: ReviewResult) => void;
159
+ 'task:rework': (task: Task, review: ReviewResult) => void;
160
+ 'task:failed': (task: Task, error: Error) => void;
161
+ 'human:review_required': (task: Task, review: ReviewResult) => void;
162
+ }
163
+ /** Top-level ClawSwarm configuration */
164
+ export interface SwarmConfig {
165
+ /** Agents to deploy */
166
+ agents: AgentConfig[];
167
+ /** Chief review configuration */
168
+ chiefReview?: ChiefReviewConfig;
169
+ /** Bridge URL for real-time communication */
170
+ bridgeUrl?: string;
171
+ /** Organization ID (for multi-tenant setups) */
172
+ orgId?: string;
173
+ /** Max concurrent goals */
174
+ maxConcurrentGoals?: number;
175
+ }
176
+ /** Result of executing a goal */
177
+ export interface GoalResult {
178
+ /** The completed goal */
179
+ goal: Goal;
180
+ /** All deliverables from all tasks */
181
+ deliverables: Deliverable[];
182
+ /** Total cost */
183
+ cost: CostSummary;
184
+ /** Whether any tasks required human review */
185
+ hadHumanReview: boolean;
186
+ /** Duration in milliseconds */
187
+ durationMs: number;
188
+ }
189
+ //# sourceMappingURL=types.d.ts.map