network-ai 4.14.0 → 4.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INTEGRATION_GUIDE.md +2 -2
- package/README.md +7 -4
- package/SKILL.md +1 -1
- package/dist/adapters/nemoclaw-adapter.d.ts.map +1 -1
- package/dist/adapters/nemoclaw-adapter.js +35 -2
- package/dist/adapters/nemoclaw-adapter.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/goal-decomposer.d.ts +216 -0
- package/dist/lib/goal-decomposer.d.ts.map +1 -0
- package/dist/lib/goal-decomposer.js +553 -0
- package/dist/lib/goal-decomposer.js.map +1 -0
- package/dist/security.js +1 -1
- package/dist/security.js.map +1 -1
- package/package.json +4 -2
- package/scripts/postinstall.js +34 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Goal Decomposer — LLM-powered goal → task DAG → parallel execution
|
|
4
|
+
*
|
|
5
|
+
* Provides the `runTeam()` one-liner: describe a goal in plain English,
|
|
6
|
+
* specify which agents to use, and let an LLM plan the task graph.
|
|
7
|
+
* Execution respects all Network-AI guardrails (budgets, permissions, audit).
|
|
8
|
+
*
|
|
9
|
+
* Zero external dependencies — LLM calls go through the adapter system.
|
|
10
|
+
*
|
|
11
|
+
* @module GoalDecomposer
|
|
12
|
+
* @version 1.0.0
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TeamRunner = exports.GoalDecomposer = void 0;
|
|
16
|
+
exports.validateDAG = validateDAG;
|
|
17
|
+
exports.topologicalLayers = topologicalLayers;
|
|
18
|
+
exports.createLLMPlanner = createLLMPlanner;
|
|
19
|
+
exports.parsePlanJSON = parsePlanJSON;
|
|
20
|
+
exports.runTeam = runTeam;
|
|
21
|
+
const events_1 = require("events");
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// DAG UTILITIES
|
|
24
|
+
// ============================================================================
|
|
25
|
+
/**
|
|
26
|
+
* Validate that a set of planned tasks forms a valid DAG (no cycles, valid refs).
|
|
27
|
+
* @throws Error if the graph contains cycles or invalid dependency references
|
|
28
|
+
*/
|
|
29
|
+
function validateDAG(tasks) {
|
|
30
|
+
const ids = new Set(tasks.map((t) => t.id));
|
|
31
|
+
// Check for duplicate IDs
|
|
32
|
+
if (ids.size !== tasks.length) {
|
|
33
|
+
throw new Error('Duplicate task IDs in plan');
|
|
34
|
+
}
|
|
35
|
+
// Check all dependency references are valid
|
|
36
|
+
for (const task of tasks) {
|
|
37
|
+
for (const dep of task.dependencies) {
|
|
38
|
+
if (!ids.has(dep)) {
|
|
39
|
+
throw new Error(`Task "${task.id}" depends on unknown task "${dep}"`);
|
|
40
|
+
}
|
|
41
|
+
if (dep === task.id) {
|
|
42
|
+
throw new Error(`Task "${task.id}" depends on itself`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Cycle detection via topological sort (Kahn's algorithm)
|
|
47
|
+
const inDegree = new Map();
|
|
48
|
+
const adj = new Map();
|
|
49
|
+
for (const task of tasks) {
|
|
50
|
+
inDegree.set(task.id, 0);
|
|
51
|
+
adj.set(task.id, []);
|
|
52
|
+
}
|
|
53
|
+
for (const task of tasks) {
|
|
54
|
+
for (const dep of task.dependencies) {
|
|
55
|
+
adj.get(dep).push(task.id);
|
|
56
|
+
inDegree.set(task.id, (inDegree.get(task.id) ?? 0) + 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const queue = [];
|
|
60
|
+
for (const [id, deg] of inDegree) {
|
|
61
|
+
if (deg === 0)
|
|
62
|
+
queue.push(id);
|
|
63
|
+
}
|
|
64
|
+
let visited = 0;
|
|
65
|
+
while (queue.length > 0) {
|
|
66
|
+
const node = queue.shift();
|
|
67
|
+
visited++;
|
|
68
|
+
for (const neighbor of adj.get(node) ?? []) {
|
|
69
|
+
const newDeg = (inDegree.get(neighbor) ?? 1) - 1;
|
|
70
|
+
inDegree.set(neighbor, newDeg);
|
|
71
|
+
if (newDeg === 0)
|
|
72
|
+
queue.push(neighbor);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (visited !== tasks.length) {
|
|
76
|
+
throw new Error('Task graph contains a cycle');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Compute topological layers — tasks in the same layer can execute in parallel.
|
|
81
|
+
* Returns arrays of task IDs grouped by execution layer.
|
|
82
|
+
*/
|
|
83
|
+
function topologicalLayers(tasks) {
|
|
84
|
+
const inDegree = new Map();
|
|
85
|
+
const adj = new Map();
|
|
86
|
+
for (const task of tasks) {
|
|
87
|
+
inDegree.set(task.id, 0);
|
|
88
|
+
adj.set(task.id, []);
|
|
89
|
+
}
|
|
90
|
+
for (const task of tasks) {
|
|
91
|
+
for (const dep of task.dependencies) {
|
|
92
|
+
adj.get(dep).push(task.id);
|
|
93
|
+
inDegree.set(task.id, (inDegree.get(task.id) ?? 0) + 1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const layers = [];
|
|
97
|
+
let remaining = new Set(tasks.map((t) => t.id));
|
|
98
|
+
while (remaining.size > 0) {
|
|
99
|
+
const layer = [];
|
|
100
|
+
for (const id of remaining) {
|
|
101
|
+
if ((inDegree.get(id) ?? 0) === 0) {
|
|
102
|
+
layer.push(id);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (layer.length === 0) {
|
|
106
|
+
throw new Error('Cycle detected during layer computation');
|
|
107
|
+
}
|
|
108
|
+
layers.push(layer);
|
|
109
|
+
for (const id of layer) {
|
|
110
|
+
remaining.delete(id);
|
|
111
|
+
for (const neighbor of adj.get(id) ?? []) {
|
|
112
|
+
inDegree.set(neighbor, (inDegree.get(neighbor) ?? 1) - 1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return layers;
|
|
117
|
+
}
|
|
118
|
+
// ============================================================================
|
|
119
|
+
// BUILT-IN PLANNER — Structured prompt → LLM → JSON parse
|
|
120
|
+
// ============================================================================
|
|
121
|
+
/**
|
|
122
|
+
* Create a planner function that uses an LLM (via executor) to decompose goals.
|
|
123
|
+
*
|
|
124
|
+
* The planner sends a structured prompt to the specified agent and parses
|
|
125
|
+
* the JSON response into PlannedTask[]. Falls back gracefully on parse errors.
|
|
126
|
+
*
|
|
127
|
+
* @param executor - Function to call the LLM agent
|
|
128
|
+
* @param plannerAgent - Agent ID for the LLM that does planning
|
|
129
|
+
* @param plannerAdapter - Adapter name (optional, defaults to agent's adapter)
|
|
130
|
+
*/
|
|
131
|
+
function createLLMPlanner(executor, plannerAgent) {
|
|
132
|
+
return async (goal, agents, context) => {
|
|
133
|
+
const agentDescriptions = agents
|
|
134
|
+
.map((a) => `- ${a.id}: ${a.role}${a.defaultAction ? ` (action: ${a.defaultAction})` : ''}`)
|
|
135
|
+
.join('\n');
|
|
136
|
+
const prompt = [
|
|
137
|
+
'You are a task planning agent. Decompose the following goal into a set of tasks.',
|
|
138
|
+
'Each task must be assigned to one of the available agents.',
|
|
139
|
+
'Tasks can depend on other tasks (they will wait for dependencies to complete).',
|
|
140
|
+
'Tasks without dependencies will run in parallel.',
|
|
141
|
+
'',
|
|
142
|
+
`GOAL: ${goal}`,
|
|
143
|
+
'',
|
|
144
|
+
'AVAILABLE AGENTS:',
|
|
145
|
+
agentDescriptions,
|
|
146
|
+
'',
|
|
147
|
+
context ? `CONTEXT: ${JSON.stringify(context)}` : '',
|
|
148
|
+
'',
|
|
149
|
+
'Respond with ONLY a JSON array of task objects. Each object must have:',
|
|
150
|
+
'- "id": unique string identifier (e.g. "task-1")',
|
|
151
|
+
'- "description": what this task does',
|
|
152
|
+
'- "agent": agent ID from the list above',
|
|
153
|
+
'- "action": the action to perform',
|
|
154
|
+
'- "params": object with parameters',
|
|
155
|
+
'- "dependencies": array of task IDs this depends on (empty array if none)',
|
|
156
|
+
'- "priority": number (higher = more urgent, default 1)',
|
|
157
|
+
'',
|
|
158
|
+
'Example:',
|
|
159
|
+
'[{"id":"task-1","description":"Research the topic","agent":"researcher","action":"research","params":{"query":"..."},"dependencies":[],"priority":2},',
|
|
160
|
+
' {"id":"task-2","description":"Write summary","agent":"writer","action":"write","params":{"input":"from task-1"},"dependencies":["task-1"],"priority":1}]',
|
|
161
|
+
].filter(Boolean).join('\n');
|
|
162
|
+
const payload = {
|
|
163
|
+
action: 'plan',
|
|
164
|
+
params: { prompt, goal, agents: agents.map((a) => ({ id: a.id, role: a.role })) },
|
|
165
|
+
};
|
|
166
|
+
const result = await executor(plannerAgent, payload, {
|
|
167
|
+
agentId: plannerAgent,
|
|
168
|
+
taskId: `plan-${Date.now()}`,
|
|
169
|
+
metadata: { type: 'goal-decomposition', ...(context ?? {}) },
|
|
170
|
+
});
|
|
171
|
+
if (!result.success || !result.data) {
|
|
172
|
+
throw new Error(`Planner agent failed: ${result.error?.message ?? 'no data returned'}`);
|
|
173
|
+
}
|
|
174
|
+
// Parse the LLM response — handle both string and pre-parsed responses
|
|
175
|
+
let tasks;
|
|
176
|
+
if (Array.isArray(result.data)) {
|
|
177
|
+
tasks = result.data;
|
|
178
|
+
}
|
|
179
|
+
else if (typeof result.data === 'string') {
|
|
180
|
+
tasks = parsePlanJSON(result.data);
|
|
181
|
+
}
|
|
182
|
+
else if (typeof result.data === 'object' && result.data !== null) {
|
|
183
|
+
const dataObj = result.data;
|
|
184
|
+
if (Array.isArray(dataObj.tasks)) {
|
|
185
|
+
tasks = dataObj.tasks;
|
|
186
|
+
}
|
|
187
|
+
else if (typeof dataObj.text === 'string') {
|
|
188
|
+
tasks = parsePlanJSON(dataObj.text);
|
|
189
|
+
}
|
|
190
|
+
else if (typeof dataObj.content === 'string') {
|
|
191
|
+
tasks = parsePlanJSON(dataObj.content);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
throw new Error('Planner returned unrecognized data shape');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
throw new Error('Planner returned unrecognized data type');
|
|
199
|
+
}
|
|
200
|
+
// Validate required fields
|
|
201
|
+
for (const task of tasks) {
|
|
202
|
+
if (!task.id || typeof task.id !== 'string')
|
|
203
|
+
throw new Error('Task missing "id"');
|
|
204
|
+
if (!task.description || typeof task.description !== 'string')
|
|
205
|
+
throw new Error(`Task "${task.id}" missing "description"`);
|
|
206
|
+
if (!task.agent || typeof task.agent !== 'string')
|
|
207
|
+
throw new Error(`Task "${task.id}" missing "agent"`);
|
|
208
|
+
if (!task.action || typeof task.action !== 'string')
|
|
209
|
+
throw new Error(`Task "${task.id}" missing "action"`);
|
|
210
|
+
if (!task.params || typeof task.params !== 'object')
|
|
211
|
+
task.params = {};
|
|
212
|
+
if (!Array.isArray(task.dependencies))
|
|
213
|
+
task.dependencies = [];
|
|
214
|
+
if (typeof task.priority !== 'number')
|
|
215
|
+
task.priority = 1;
|
|
216
|
+
}
|
|
217
|
+
return tasks;
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Parse JSON from an LLM response string, handling markdown fences and preamble.
|
|
222
|
+
*/
|
|
223
|
+
function parsePlanJSON(text) {
|
|
224
|
+
// Strip markdown code fences (indexOf-based to avoid ReDoS — CodeQL #105)
|
|
225
|
+
let cleaned = text.trim();
|
|
226
|
+
const fenceOpen = cleaned.indexOf('```');
|
|
227
|
+
if (fenceOpen !== -1) {
|
|
228
|
+
const afterOpen = cleaned.indexOf('\n', fenceOpen);
|
|
229
|
+
const fenceClose = cleaned.indexOf('```', afterOpen !== -1 ? afterOpen : fenceOpen + 3);
|
|
230
|
+
if (afterOpen !== -1 && fenceClose > afterOpen) {
|
|
231
|
+
cleaned = cleaned.substring(afterOpen + 1, fenceClose).trim();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// Find the JSON array in the text
|
|
235
|
+
const arrayStart = cleaned.indexOf('[');
|
|
236
|
+
const arrayEnd = cleaned.lastIndexOf(']');
|
|
237
|
+
if (arrayStart !== -1 && arrayEnd > arrayStart) {
|
|
238
|
+
cleaned = cleaned.substring(arrayStart, arrayEnd + 1);
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
const parsed = JSON.parse(cleaned);
|
|
242
|
+
if (!Array.isArray(parsed)) {
|
|
243
|
+
throw new Error('Expected JSON array of tasks');
|
|
244
|
+
}
|
|
245
|
+
return parsed;
|
|
246
|
+
}
|
|
247
|
+
catch (err) {
|
|
248
|
+
throw new Error(`Failed to parse planner response as JSON: ${err.message}`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// ============================================================================
|
|
252
|
+
// GOAL DECOMPOSER
|
|
253
|
+
// ============================================================================
|
|
254
|
+
/**
|
|
255
|
+
* LLM-powered goal decomposition engine.
|
|
256
|
+
*
|
|
257
|
+
* Takes a natural language goal, creates a task DAG via an LLM planner,
|
|
258
|
+
* validates the graph, and returns a ready-to-execute TaskDAG.
|
|
259
|
+
*/
|
|
260
|
+
class GoalDecomposer {
|
|
261
|
+
planner;
|
|
262
|
+
constructor(planner) {
|
|
263
|
+
this.planner = planner;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Decompose a goal into a validated TaskDAG.
|
|
267
|
+
* @param goal - Natural language description of the goal
|
|
268
|
+
* @param agents - Available team agents
|
|
269
|
+
* @param context - Optional context to feed to the planner
|
|
270
|
+
* @param retries - Number of retries on planning failure (default: 1)
|
|
271
|
+
*/
|
|
272
|
+
async decompose(goal, agents, context, retries = 1) {
|
|
273
|
+
if (!goal || typeof goal !== 'string' || goal.trim().length === 0) {
|
|
274
|
+
throw new Error('Goal must be a non-empty string');
|
|
275
|
+
}
|
|
276
|
+
if (!agents || agents.length === 0) {
|
|
277
|
+
throw new Error('At least one agent is required');
|
|
278
|
+
}
|
|
279
|
+
// Validate agent IDs are unique
|
|
280
|
+
const agentIds = new Set(agents.map((a) => a.id));
|
|
281
|
+
if (agentIds.size !== agents.length) {
|
|
282
|
+
throw new Error('Duplicate agent IDs');
|
|
283
|
+
}
|
|
284
|
+
let lastError;
|
|
285
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
286
|
+
try {
|
|
287
|
+
const planned = await this.planner(goal, agents, context);
|
|
288
|
+
validateDAG(planned);
|
|
289
|
+
// Validate that all assigned agents exist in the team
|
|
290
|
+
for (const task of planned) {
|
|
291
|
+
if (!agentIds.has(task.agent)) {
|
|
292
|
+
throw new Error(`Task "${task.id}" assigned to unknown agent "${task.agent}"`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Build the TaskDAG
|
|
296
|
+
const nodes = planned.map((t) => ({
|
|
297
|
+
id: t.id,
|
|
298
|
+
description: t.description,
|
|
299
|
+
agent: t.agent,
|
|
300
|
+
action: t.action,
|
|
301
|
+
params: t.params,
|
|
302
|
+
dependencies: t.dependencies,
|
|
303
|
+
priority: t.priority ?? 1,
|
|
304
|
+
status: 'pending',
|
|
305
|
+
}));
|
|
306
|
+
const edges = new Map();
|
|
307
|
+
for (const task of planned) {
|
|
308
|
+
edges.set(task.id, []);
|
|
309
|
+
}
|
|
310
|
+
for (const task of planned) {
|
|
311
|
+
for (const dep of task.dependencies) {
|
|
312
|
+
edges.get(dep).push(task.id);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return { goal, nodes, edges, createdAt: Date.now() };
|
|
316
|
+
}
|
|
317
|
+
catch (err) {
|
|
318
|
+
lastError = err;
|
|
319
|
+
if (attempt < retries)
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
throw lastError ?? new Error('Planning failed');
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
exports.GoalDecomposer = GoalDecomposer;
|
|
327
|
+
// ============================================================================
|
|
328
|
+
// TEAM RUNNER — The one-liner execution engine
|
|
329
|
+
// ============================================================================
|
|
330
|
+
/**
|
|
331
|
+
* Executes a TaskDAG by running tasks in parallel layers, respecting
|
|
332
|
+
* dependencies, concurrency limits, and timeouts.
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* ```typescript
|
|
336
|
+
* const runner = new TeamRunner(executor);
|
|
337
|
+
* const result = await runner.run(dag, { concurrency: 3 });
|
|
338
|
+
* console.log(result.summary);
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
class TeamRunner extends events_1.EventEmitter {
|
|
342
|
+
executor;
|
|
343
|
+
constructor(executor) {
|
|
344
|
+
super();
|
|
345
|
+
this.executor = executor;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Execute a TaskDAG with parallel scheduling.
|
|
349
|
+
*/
|
|
350
|
+
async run(dag, options = {}) {
|
|
351
|
+
const { concurrency = 5, taskTimeout = 30_000, totalTimeout = 300_000, continueOnFailure = false, sessionId, metadata, } = options;
|
|
352
|
+
const start = Date.now();
|
|
353
|
+
const deadline = start + totalTimeout;
|
|
354
|
+
const results = new Map();
|
|
355
|
+
const nodeMap = new Map();
|
|
356
|
+
for (const node of dag.nodes) {
|
|
357
|
+
nodeMap.set(node.id, node);
|
|
358
|
+
}
|
|
359
|
+
this.emit('dag:created', dag);
|
|
360
|
+
// Compute layers for parallel execution
|
|
361
|
+
const planned = dag.nodes.map((n) => ({
|
|
362
|
+
id: n.id,
|
|
363
|
+
description: n.description,
|
|
364
|
+
agent: n.agent,
|
|
365
|
+
action: n.action,
|
|
366
|
+
params: n.params,
|
|
367
|
+
dependencies: n.dependencies,
|
|
368
|
+
priority: n.priority,
|
|
369
|
+
}));
|
|
370
|
+
const layers = topologicalLayers(planned);
|
|
371
|
+
let aborted = false;
|
|
372
|
+
for (const layer of layers) {
|
|
373
|
+
if (aborted)
|
|
374
|
+
break;
|
|
375
|
+
// Check total timeout
|
|
376
|
+
if (Date.now() >= deadline) {
|
|
377
|
+
for (const taskId of layer) {
|
|
378
|
+
const node = nodeMap.get(taskId);
|
|
379
|
+
node.status = 'skipped';
|
|
380
|
+
node.error = 'Total timeout exceeded';
|
|
381
|
+
this.emit('task:skip', node, 'Total timeout exceeded');
|
|
382
|
+
}
|
|
383
|
+
aborted = true;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
// Sort by priority within the layer (higher first)
|
|
387
|
+
const sorted = [...layer].sort((a, b) => {
|
|
388
|
+
const na = nodeMap.get(a);
|
|
389
|
+
const nb = nodeMap.get(b);
|
|
390
|
+
return nb.priority - na.priority;
|
|
391
|
+
});
|
|
392
|
+
// Execute in batches respecting concurrency
|
|
393
|
+
for (let i = 0; i < sorted.length; i += concurrency) {
|
|
394
|
+
if (aborted)
|
|
395
|
+
break;
|
|
396
|
+
const batch = sorted.slice(i, i + concurrency);
|
|
397
|
+
const batchPromises = batch.map(async (taskId) => {
|
|
398
|
+
const node = nodeMap.get(taskId);
|
|
399
|
+
// Skip if a dependency failed and we're not continuing on failure
|
|
400
|
+
if (!continueOnFailure) {
|
|
401
|
+
for (const depId of node.dependencies) {
|
|
402
|
+
const dep = nodeMap.get(depId);
|
|
403
|
+
if (dep && dep.status === 'failed') {
|
|
404
|
+
node.status = 'skipped';
|
|
405
|
+
node.error = `Dependency "${depId}" failed`;
|
|
406
|
+
this.emit('task:skip', node, node.error);
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
node.status = 'running';
|
|
412
|
+
node.startedAt = Date.now();
|
|
413
|
+
this.emit('task:start', node);
|
|
414
|
+
// Build payload with dependency results injected
|
|
415
|
+
const depResults = {};
|
|
416
|
+
for (const depId of node.dependencies) {
|
|
417
|
+
const depResult = results.get(depId);
|
|
418
|
+
if (depResult)
|
|
419
|
+
depResults[depId] = depResult.data;
|
|
420
|
+
}
|
|
421
|
+
const payload = {
|
|
422
|
+
action: node.action,
|
|
423
|
+
params: { ...node.params, _dependencyResults: depResults },
|
|
424
|
+
};
|
|
425
|
+
const context = {
|
|
426
|
+
agentId: node.agent,
|
|
427
|
+
taskId: node.id,
|
|
428
|
+
sessionId,
|
|
429
|
+
metadata: { ...metadata, goal: dag.goal, layer: layers.indexOf(layer) },
|
|
430
|
+
};
|
|
431
|
+
try {
|
|
432
|
+
const result = await withTimeout(this.executor(node.agent, payload, context), taskTimeout, `Task "${taskId}" timed out after ${taskTimeout}ms`);
|
|
433
|
+
results.set(taskId, result);
|
|
434
|
+
if (result.success) {
|
|
435
|
+
node.status = 'completed';
|
|
436
|
+
node.result = result;
|
|
437
|
+
node.completedAt = Date.now();
|
|
438
|
+
this.emit('task:complete', node, result);
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
node.status = 'failed';
|
|
442
|
+
node.error = result.error?.message ?? 'Agent returned failure';
|
|
443
|
+
node.result = result;
|
|
444
|
+
node.completedAt = Date.now();
|
|
445
|
+
this.emit('task:fail', node, node.error);
|
|
446
|
+
if (!continueOnFailure)
|
|
447
|
+
aborted = true;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
catch (err) {
|
|
451
|
+
const errMsg = err.message ?? String(err);
|
|
452
|
+
node.status = 'failed';
|
|
453
|
+
node.error = errMsg;
|
|
454
|
+
node.completedAt = Date.now();
|
|
455
|
+
this.emit('task:fail', node, errMsg);
|
|
456
|
+
results.set(taskId, {
|
|
457
|
+
success: false,
|
|
458
|
+
error: { code: 'EXECUTION_ERROR', message: errMsg, recoverable: false },
|
|
459
|
+
});
|
|
460
|
+
if (!continueOnFailure)
|
|
461
|
+
aborted = true;
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
await Promise.all(batchPromises);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
// Skip remaining unexecuted nodes
|
|
468
|
+
for (const node of dag.nodes) {
|
|
469
|
+
if (node.status === 'pending') {
|
|
470
|
+
node.status = 'skipped';
|
|
471
|
+
node.error = aborted ? 'Aborted due to prior failure' : 'Not reached';
|
|
472
|
+
this.emit('task:skip', node, node.error);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
const stats = {
|
|
476
|
+
total: dag.nodes.length,
|
|
477
|
+
completed: dag.nodes.filter((n) => n.status === 'completed').length,
|
|
478
|
+
failed: dag.nodes.filter((n) => n.status === 'failed').length,
|
|
479
|
+
skipped: dag.nodes.filter((n) => n.status === 'skipped').length,
|
|
480
|
+
};
|
|
481
|
+
const success = stats.failed === 0 && stats.skipped === 0;
|
|
482
|
+
const durationMs = Date.now() - start;
|
|
483
|
+
const summary = `Goal: "${dag.goal}" — ${stats.completed}/${stats.total} tasks completed${stats.failed ? `, ${stats.failed} failed` : ''}${stats.skipped ? `, ${stats.skipped} skipped` : ''} in ${durationMs}ms`;
|
|
484
|
+
const teamResult = { success, dag, results, summary, durationMs, stats };
|
|
485
|
+
this.emit('run:complete', teamResult);
|
|
486
|
+
return teamResult;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
exports.TeamRunner = TeamRunner;
|
|
490
|
+
// ============================================================================
|
|
491
|
+
// runTeam() — THE ONE-LINER
|
|
492
|
+
// ============================================================================
|
|
493
|
+
/**
|
|
494
|
+
* Decompose a goal into tasks and execute them with a team of agents.
|
|
495
|
+
*
|
|
496
|
+
* This is the main entry point — one line to go from goal to results:
|
|
497
|
+
*
|
|
498
|
+
* ```typescript
|
|
499
|
+
* const result = await runTeam(
|
|
500
|
+
* "Build a REST API for user management",
|
|
501
|
+
* [
|
|
502
|
+
* { id: "architect", role: "System design and API specification" },
|
|
503
|
+
* { id: "coder", role: "Write TypeScript code" },
|
|
504
|
+
* { id: "reviewer", role: "Code review and quality checks" },
|
|
505
|
+
* ],
|
|
506
|
+
* { planner, executor }
|
|
507
|
+
* );
|
|
508
|
+
* ```
|
|
509
|
+
*
|
|
510
|
+
* @param goal - Natural language description of what to achieve
|
|
511
|
+
* @param agents - Team of agents available for task execution
|
|
512
|
+
* @param config - Planner (LLM decomposition) and executor (agent invocation) functions
|
|
513
|
+
* @param options - Optional concurrency, timeout, and failure handling settings
|
|
514
|
+
* @returns Full result with DAG, individual results, and stats
|
|
515
|
+
*/
|
|
516
|
+
async function runTeam(goal, agents, config, options = {}) {
|
|
517
|
+
const decomposer = new GoalDecomposer(config.planner);
|
|
518
|
+
const runner = new TeamRunner(config.executor);
|
|
519
|
+
const dag = await decomposer.decompose(goal, agents, options.metadata, options.plannerRetries ?? 1);
|
|
520
|
+
// Optional approval gate
|
|
521
|
+
if (options.approvalCallback) {
|
|
522
|
+
const approved = await options.approvalCallback(dag);
|
|
523
|
+
if (!approved) {
|
|
524
|
+
// Mark all tasks as skipped
|
|
525
|
+
for (const node of dag.nodes) {
|
|
526
|
+
node.status = 'skipped';
|
|
527
|
+
node.error = 'Execution not approved';
|
|
528
|
+
}
|
|
529
|
+
return {
|
|
530
|
+
success: false,
|
|
531
|
+
dag,
|
|
532
|
+
results: new Map(),
|
|
533
|
+
summary: `Goal: "${goal}" — execution not approved`,
|
|
534
|
+
durationMs: 0,
|
|
535
|
+
stats: { total: dag.nodes.length, completed: 0, failed: 0, skipped: dag.nodes.length },
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return runner.run(dag, options);
|
|
540
|
+
}
|
|
541
|
+
// ============================================================================
|
|
542
|
+
// HELPERS
|
|
543
|
+
// ============================================================================
|
|
544
|
+
/** Promise wrapper that rejects after a timeout */
|
|
545
|
+
function withTimeout(promise, ms, message) {
|
|
546
|
+
if (ms <= 0 || ms === Infinity)
|
|
547
|
+
return promise;
|
|
548
|
+
return new Promise((resolve, reject) => {
|
|
549
|
+
const timer = setTimeout(() => reject(new Error(message)), ms);
|
|
550
|
+
promise.then((val) => { clearTimeout(timer); resolve(val); }, (err) => { clearTimeout(timer); reject(err); });
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
//# sourceMappingURL=goal-decomposer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goal-decomposer.js","sourceRoot":"","sources":["../../lib/goal-decomposer.ts"],"names":[],"mapp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,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/security.js
CHANGED
|
@@ -143,7 +143,7 @@ class InputSanitizer {
|
|
|
143
143
|
// Dangerous patterns that could indicate injection attempts
|
|
144
144
|
static DANGEROUS_PATTERNS = [
|
|
145
145
|
/\$\{.*\}/g, // Template injection
|
|
146
|
-
/<script[
|
|
146
|
+
/<script\b[^>]*>[\s\S]*?<\/script>/gi, // XSS (non-backtracking open-tag)
|
|
147
147
|
/javascript:/gi, // JavaScript protocol
|
|
148
148
|
/on\w+\s*=/gi, // Event handlers
|
|
149
149
|
/\.\.\//g, // Path traversal
|