@synergenius/flow-weaver-pack-weaver 0.9.62 → 0.9.78
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/ai-chat-provider.d.ts +12 -0
- package/dist/ai-chat-provider.d.ts.map +1 -1
- package/dist/ai-chat-provider.js +173 -19
- package/dist/ai-chat-provider.js.map +1 -1
- package/dist/bot/agent-loop.d.ts +20 -0
- package/dist/bot/agent-loop.d.ts.map +1 -0
- package/dist/bot/agent-loop.js +331 -0
- package/dist/bot/agent-loop.js.map +1 -0
- package/dist/bot/ai-router.d.ts +19 -0
- package/dist/bot/ai-router.d.ts.map +1 -0
- package/dist/bot/ai-router.js +104 -0
- package/dist/bot/ai-router.js.map +1 -0
- package/dist/bot/bot-registry.js +2 -2
- package/dist/bot/bot-registry.js.map +1 -1
- package/dist/bot/conversation-store.d.ts +1 -0
- package/dist/bot/conversation-store.d.ts.map +1 -1
- package/dist/bot/conversation-store.js.map +1 -1
- package/dist/bot/improve-loop.js.map +1 -1
- package/dist/bot/instance-manager.d.ts +31 -0
- package/dist/bot/instance-manager.d.ts.map +1 -0
- package/dist/bot/instance-manager.js +115 -0
- package/dist/bot/instance-manager.js.map +1 -0
- package/dist/bot/orchestrator.d.ts +36 -0
- package/dist/bot/orchestrator.d.ts.map +1 -0
- package/dist/bot/orchestrator.js +176 -0
- package/dist/bot/orchestrator.js.map +1 -0
- package/dist/bot/profile-store.d.ts +36 -0
- package/dist/bot/profile-store.d.ts.map +1 -0
- package/dist/bot/profile-store.js +208 -0
- package/dist/bot/profile-store.js.map +1 -0
- package/dist/bot/profile-types.d.ts +126 -0
- package/dist/bot/profile-types.d.ts.map +1 -0
- package/dist/bot/profile-types.js +7 -0
- package/dist/bot/profile-types.js.map +1 -0
- package/dist/bot/session-state.d.ts +25 -0
- package/dist/bot/session-state.d.ts.map +1 -0
- package/dist/bot/session-state.js +110 -0
- package/dist/bot/session-state.js.map +1 -0
- package/dist/bot/swarm-controller.d.ts +37 -21
- package/dist/bot/swarm-controller.d.ts.map +1 -1
- package/dist/bot/swarm-controller.js +344 -163
- package/dist/bot/swarm-controller.js.map +1 -1
- package/dist/bot/task-prompt-builder.d.ts +2 -1
- package/dist/bot/task-prompt-builder.d.ts.map +1 -1
- package/dist/bot/task-prompt-builder.js +33 -10
- package/dist/bot/task-prompt-builder.js.map +1 -1
- package/dist/bot/task-queue.d.ts +46 -0
- package/dist/bot/task-queue.d.ts.map +1 -0
- package/dist/bot/task-queue.js +237 -0
- package/dist/bot/task-queue.js.map +1 -0
- package/dist/bot/task-store.d.ts +1 -6
- package/dist/bot/task-store.d.ts.map +1 -1
- package/dist/bot/task-store.js +27 -78
- package/dist/bot/task-store.js.map +1 -1
- package/dist/bot/task-types.d.ts +8 -4
- package/dist/bot/task-types.d.ts.map +1 -1
- package/dist/cli-handlers.d.ts.map +1 -1
- package/dist/cli-handlers.js +2 -3
- package/dist/cli-handlers.js.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +749 -0
- package/dist/cli.js.map +1 -0
- package/dist/docs/docs/weaver-bot-usage.md +35 -18
- package/dist/docs/docs/weaver-config.md +20 -0
- package/dist/docs/docs/weaver-task-queue.md +31 -19
- package/dist/docs/weaver-config.md +15 -9
- package/dist/mcp-tools.d.ts +17 -0
- package/dist/mcp-tools.d.ts.map +1 -1
- package/dist/mcp-tools.js +98 -232
- package/dist/mcp-tools.js.map +1 -1
- package/dist/node-types/orchestrator-dispatch.d.ts +17 -0
- package/dist/node-types/orchestrator-dispatch.d.ts.map +1 -0
- package/dist/node-types/orchestrator-dispatch.js +63 -0
- package/dist/node-types/orchestrator-dispatch.js.map +1 -0
- package/dist/node-types/orchestrator-load-state.d.ts +16 -0
- package/dist/node-types/orchestrator-load-state.d.ts.map +1 -0
- package/dist/node-types/orchestrator-load-state.js +60 -0
- package/dist/node-types/orchestrator-load-state.js.map +1 -0
- package/dist/node-types/orchestrator-route.d.ts +16 -0
- package/dist/node-types/orchestrator-route.d.ts.map +1 -0
- package/dist/node-types/orchestrator-route.js +28 -0
- package/dist/node-types/orchestrator-route.js.map +1 -0
- package/dist/node-types/receive-task.d.ts +2 -3
- package/dist/node-types/receive-task.d.ts.map +1 -1
- package/dist/node-types/receive-task.js +3 -28
- package/dist/node-types/receive-task.js.map +1 -1
- package/dist/templates/weaver-template.d.ts +11 -0
- package/dist/templates/weaver-template.d.ts.map +1 -0
- package/dist/templates/weaver-template.js +53 -0
- package/dist/templates/weaver-template.js.map +1 -0
- package/dist/ui/bot-constants.d.ts +14 -0
- package/dist/ui/bot-constants.d.ts.map +1 -0
- package/dist/ui/bot-constants.js +189 -0
- package/dist/ui/bot-constants.js.map +1 -0
- package/dist/ui/bot-panel.js +51 -90
- package/dist/ui/bot-slot-card.js +87 -122
- package/dist/ui/budget-bar.js +5 -3
- package/dist/ui/chat-task-result.js +4 -7
- package/dist/ui/decision-log.js +136 -0
- package/dist/ui/profile-card.js +158 -0
- package/dist/ui/profile-editor.js +597 -0
- package/dist/ui/swarm-controls.js +36 -27
- package/dist/ui/swarm-dashboard.js +2034 -736
- package/dist/ui/task-create-form.js +39 -116
- package/dist/ui/task-detail-view.js +490 -239
- package/dist/ui/task-pool-list.js +69 -94
- package/dist/workflows/orchestrator.d.ts +21 -0
- package/dist/workflows/orchestrator.d.ts.map +1 -0
- package/dist/workflows/orchestrator.js +281 -0
- package/dist/workflows/orchestrator.js.map +1 -0
- package/dist/workflows/weaver-bot-session.d.ts +65 -0
- package/dist/workflows/weaver-bot-session.d.ts.map +1 -0
- package/dist/workflows/weaver-bot-session.js +68 -0
- package/dist/workflows/weaver-bot-session.js.map +1 -0
- package/dist/workflows/weaver.d.ts +24 -0
- package/dist/workflows/weaver.d.ts.map +1 -0
- package/dist/workflows/weaver.js +28 -0
- package/dist/workflows/weaver.js.map +1 -0
- package/flowweaver.manifest.json +253 -66
- package/package.json +1 -1
- package/src/ai-chat-provider.ts +184 -18
- package/src/bot/ai-router.ts +132 -0
- package/src/bot/bot-registry.ts +2 -2
- package/src/bot/conversation-store.ts +2 -1
- package/src/bot/improve-loop.ts +6 -6
- package/src/bot/instance-manager.ts +128 -0
- package/src/bot/orchestrator.ts +244 -0
- package/src/bot/profile-store.ts +225 -0
- package/src/bot/profile-types.ts +141 -0
- package/src/bot/swarm-controller.ts +385 -186
- package/src/bot/task-prompt-builder.ts +37 -6
- package/src/bot/task-store.ts +28 -89
- package/src/bot/task-types.ts +10 -4
- package/src/cli-handlers.ts +2 -3
- package/src/docs/weaver-bot-usage.md +35 -18
- package/src/docs/weaver-config.md +20 -0
- package/src/docs/weaver-task-queue.md +31 -19
- package/src/mcp-tools.ts +129 -320
- package/src/node-types/orchestrator-dispatch.ts +71 -0
- package/src/node-types/orchestrator-load-state.ts +66 -0
- package/src/node-types/orchestrator-route.ts +33 -0
- package/src/node-types/receive-task.ts +3 -26
- package/src/ui/bot-constants.ts +192 -0
- package/src/ui/bot-panel.tsx +55 -79
- package/src/ui/bot-slot-card.tsx +69 -117
- package/src/ui/budget-bar.tsx +5 -3
- package/src/ui/chat-task-result.tsx +6 -9
- package/src/ui/decision-log.tsx +148 -0
- package/src/ui/profile-card.tsx +157 -0
- package/src/ui/profile-editor.tsx +384 -0
- package/src/ui/swarm-controls.tsx +35 -31
- package/src/ui/swarm-dashboard.tsx +409 -80
- package/src/ui/task-create-form.tsx +29 -119
- package/src/ui/task-detail-view.tsx +461 -215
- package/src/ui/task-pool-list.tsx +74 -95
- package/src/workflows/orchestrator.ts +302 -0
- package/dist/docs/weaver-bot-usage.md +0 -34
- package/dist/docs/weaver-genesis.md +0 -32
- package/dist/docs/weaver-task-queue.md +0 -34
- package/src/bot/error-guide.ts +0 -4
- package/src/bot/retry-utils.ts +0 -4
package/dist/mcp-tools.js
CHANGED
|
@@ -1,240 +1,106 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool registrations for the Weaver pack.
|
|
3
|
+
*
|
|
4
|
+
* Reads tool schemas from the manifest (single source of truth) and delegates
|
|
5
|
+
* every handler to `handleWeaverTool` from ai-chat-provider — so MCP and the
|
|
6
|
+
* platform AI chat always run the exact same logic.
|
|
7
|
+
*/
|
|
8
|
+
import * as fs from 'node:fs';
|
|
9
|
+
import * as path from 'node:path';
|
|
2
10
|
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
params: args.params,
|
|
16
|
-
verbose: args.verbose,
|
|
17
|
-
dryRun: args.dryRun,
|
|
18
|
-
});
|
|
19
|
-
return {
|
|
20
|
-
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
mcp.tool('fw_weaver_history', 'Query weaver run history. Returns recent workflow executions with outcome, duration, and summary.', {
|
|
24
|
-
id: z.string().optional().describe('Specific run ID to look up'),
|
|
25
|
-
limit: z.number().optional().describe('Max number of entries (default 20)'),
|
|
26
|
-
outcome: z.enum(['completed', 'failed', 'error', 'skipped']).optional().describe('Filter by outcome'),
|
|
27
|
-
workflowFile: z.string().optional().describe('Filter by workflow file path'),
|
|
28
|
-
}, async (args) => {
|
|
29
|
-
const store = new RunStore();
|
|
30
|
-
if (args.id) {
|
|
31
|
-
const record = store.get(args.id);
|
|
32
|
-
if (!record) {
|
|
33
|
-
return { content: [{ type: 'text', text: `No run found matching "${args.id}"` }] };
|
|
34
|
-
}
|
|
35
|
-
return { content: [{ type: 'text', text: JSON.stringify(record, null, 2) }] };
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { handleWeaverTool } from './ai-chat-provider.js';
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// JSON Schema → Zod conversion (shallow, covers the manifest's patterns)
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
export function jsonSchemaPropertyToZod(prop) {
|
|
17
|
+
const type = prop.type;
|
|
18
|
+
if (type === 'array') {
|
|
19
|
+
const items = prop.items;
|
|
20
|
+
// For nested object arrays (e.g. subtasks) just accept unknown[]
|
|
21
|
+
if (items && (items.type === 'object' || !items.type)) {
|
|
22
|
+
return z.array(z.unknown()).describe(prop.description ?? '');
|
|
36
23
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
return z.array(jsonSchemaPropertyToZod(items ?? { type: 'string' })).describe(prop.description ?? '');
|
|
25
|
+
}
|
|
26
|
+
if (type === 'number') {
|
|
27
|
+
let s = z.number();
|
|
28
|
+
if (prop.description)
|
|
29
|
+
s = s.describe(prop.description);
|
|
30
|
+
return s;
|
|
31
|
+
}
|
|
32
|
+
if (type === 'boolean') {
|
|
33
|
+
let s = z.boolean();
|
|
34
|
+
if (prop.description)
|
|
35
|
+
s = s.describe(prop.description);
|
|
36
|
+
return s;
|
|
37
|
+
}
|
|
38
|
+
if (type === 'object') {
|
|
39
|
+
// Generic object — accept anything
|
|
40
|
+
let s = z.record(z.unknown());
|
|
41
|
+
if (prop.description)
|
|
42
|
+
s = s.describe(prop.description);
|
|
43
|
+
return s;
|
|
44
|
+
}
|
|
45
|
+
// Default: string (possibly with enum)
|
|
46
|
+
if (prop.enum) {
|
|
47
|
+
const values = prop.enum;
|
|
48
|
+
let s = z.enum(values);
|
|
49
|
+
if (prop.description)
|
|
50
|
+
s = s.describe(prop.description);
|
|
51
|
+
return s;
|
|
52
|
+
}
|
|
53
|
+
let s = z.string();
|
|
54
|
+
if (prop.description)
|
|
55
|
+
s = s.describe(prop.description);
|
|
56
|
+
return s;
|
|
57
|
+
}
|
|
58
|
+
export function jsonSchemaToZodShape(params) {
|
|
59
|
+
const properties = (params.properties ?? {});
|
|
60
|
+
const required = new Set((params.required ?? []));
|
|
61
|
+
const shape = {};
|
|
62
|
+
for (const [key, prop] of Object.entries(properties)) {
|
|
63
|
+
let zodType = jsonSchemaPropertyToZod(prop);
|
|
64
|
+
if (!required.has(key)) {
|
|
65
|
+
zodType = zodType.optional();
|
|
44
66
|
}
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
shape[key] = zodType;
|
|
68
|
+
}
|
|
69
|
+
return shape;
|
|
70
|
+
}
|
|
71
|
+
export function loadManifestTools() {
|
|
72
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
73
|
+
const manifestPath = path.resolve(__dirname, '..', 'flowweaver.manifest.json');
|
|
74
|
+
const raw = fs.readFileSync(manifestPath, 'utf-8');
|
|
75
|
+
const manifest = JSON.parse(raw);
|
|
76
|
+
return (manifest.aiChat?.tools ?? []);
|
|
77
|
+
}
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// Registration
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
export async function registerMcpTools(mcp) {
|
|
82
|
+
const tools = loadManifestTools();
|
|
83
|
+
const projectDir = process.env.WEAVER_PROJECT_DIR ?? process.cwd();
|
|
84
|
+
for (const tool of tools) {
|
|
85
|
+
const zodShape = jsonSchemaToZodShape(tool.parameters);
|
|
86
|
+
mcp.tool(tool.name, tool.description, zodShape, async (args) => {
|
|
87
|
+
try {
|
|
88
|
+
const { result, isError } = await handleWeaverTool(tool.name, args, projectDir);
|
|
89
|
+
return {
|
|
90
|
+
content: [{ type: 'text', text: result }],
|
|
91
|
+
...(isError ? { isError: true } : {}),
|
|
92
|
+
};
|
|
66
93
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
name,
|
|
76
|
-
source: metadata.source,
|
|
77
|
-
description: metadata.description,
|
|
78
|
-
requiredEnvVars: metadata.requiredEnvVars,
|
|
79
|
-
envVarsSet: metadata.requiredEnvVars?.every((v) => process.env[v]) ?? false,
|
|
80
|
-
detectCliCommand: metadata.detectCliCommand,
|
|
81
|
-
}));
|
|
82
|
-
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
83
|
-
});
|
|
84
|
-
// --- Task Tools ---
|
|
85
|
-
mcp.tool('fw_weaver_task_create', 'Create a new task for the bot swarm to execute. Provide a title and description.', {
|
|
86
|
-
title: z.string().describe('Short task title'),
|
|
87
|
-
description: z.string().optional().describe('Detailed task description'),
|
|
88
|
-
assignedBots: z.array(z.string()).optional().describe('Bot IDs to assign'),
|
|
89
|
-
priority: z.number().optional().describe('Priority (higher = more urgent)'),
|
|
90
|
-
projectDir: z.string().optional().describe('Project directory'),
|
|
91
|
-
}, async (args) => {
|
|
92
|
-
const { TaskStore } = await import('./bot/task-store.js');
|
|
93
|
-
const projectDir = args.projectDir ?? process.env.WEAVER_PROJECT_DIR ?? process.cwd();
|
|
94
|
-
const store = new TaskStore(projectDir);
|
|
95
|
-
const task = await store.create({
|
|
96
|
-
title: args.title,
|
|
97
|
-
description: args.description ?? '',
|
|
98
|
-
assignedBots: args.assignedBots,
|
|
99
|
-
priority: args.priority,
|
|
100
|
-
});
|
|
101
|
-
return { content: [{ type: 'text', text: JSON.stringify(task, null, 2) }] };
|
|
102
|
-
});
|
|
103
|
-
mcp.tool('fw_weaver_task_list', 'List tasks in the swarm task store. Optionally filter by status, parentId, or botId.', {
|
|
104
|
-
status: z.string().optional().describe('Filter by status (pending, in-progress, done, failed, cancelled)'),
|
|
105
|
-
parentId: z.string().optional().describe('Filter by parent task ID'),
|
|
106
|
-
botId: z.string().optional().describe('Filter by assigned bot ID'),
|
|
107
|
-
limit: z.number().optional().describe('Max entries to return'),
|
|
108
|
-
projectDir: z.string().optional().describe('Project directory'),
|
|
109
|
-
}, async (args) => {
|
|
110
|
-
const { TaskStore } = await import('./bot/task-store.js');
|
|
111
|
-
const projectDir = args.projectDir ?? process.env.WEAVER_PROJECT_DIR ?? process.cwd();
|
|
112
|
-
const store = new TaskStore(projectDir);
|
|
113
|
-
const tasks = await store.list({
|
|
114
|
-
status: args.status,
|
|
115
|
-
parentId: args.parentId,
|
|
116
|
-
botId: args.botId,
|
|
117
|
-
limit: args.limit,
|
|
118
|
-
});
|
|
119
|
-
return { content: [{ type: 'text', text: JSON.stringify(tasks, null, 2) }] };
|
|
120
|
-
});
|
|
121
|
-
mcp.tool('fw_weaver_task_cancel', 'Cancel a pending or running task by ID.', {
|
|
122
|
-
id: z.string().describe('Task ID to cancel'),
|
|
123
|
-
projectDir: z.string().optional().describe('Project directory'),
|
|
124
|
-
}, async (args) => {
|
|
125
|
-
const { TaskStore } = await import('./bot/task-store.js');
|
|
126
|
-
const projectDir = args.projectDir ?? process.env.WEAVER_PROJECT_DIR ?? process.cwd();
|
|
127
|
-
const store = new TaskStore(projectDir);
|
|
128
|
-
const task = await store.update(args.id, { status: 'cancelled' });
|
|
129
|
-
return { content: [{ type: 'text', text: JSON.stringify({ cancelled: true, task }) }] };
|
|
130
|
-
});
|
|
131
|
-
mcp.tool('fw_weaver_steer', 'Send a steering command to a running bot (pause, resume, cancel, redirect, queue).', {
|
|
132
|
-
command: z.enum(['pause', 'resume', 'cancel', 'redirect', 'queue']).describe('Steering command'),
|
|
133
|
-
payload: z.string().optional().describe('Payload for redirect/queue commands'),
|
|
134
|
-
}, async (args) => {
|
|
135
|
-
const { SteeringController } = await import('./bot/steering.js');
|
|
136
|
-
const controller = new SteeringController();
|
|
137
|
-
await controller.write({
|
|
138
|
-
command: args.command,
|
|
139
|
-
payload: args.payload,
|
|
140
|
-
timestamp: Date.now(),
|
|
141
|
-
});
|
|
142
|
-
return { content: [{ type: 'text', text: `Steering command sent: ${args.command}` }] };
|
|
143
|
-
});
|
|
144
|
-
mcp.tool('fw_weaver_status', 'Get current swarm status: active bots, task counts, budget usage.', {}, async () => {
|
|
145
|
-
const { TaskStore } = await import('./bot/task-store.js');
|
|
146
|
-
const projectDir = process.env.WEAVER_PROJECT_DIR ?? process.cwd();
|
|
147
|
-
const store = new TaskStore(projectDir);
|
|
148
|
-
const tasks = await store.list();
|
|
149
|
-
const pending = tasks.filter(t => t.status === 'pending').length;
|
|
150
|
-
const inProgress = tasks.filter(t => t.status === 'in-progress').length;
|
|
151
|
-
const done = tasks.filter(t => t.status === 'done').length;
|
|
152
|
-
const failed = tasks.filter(t => t.status === 'failed').length;
|
|
153
|
-
return { content: [{ type: 'text', text: JSON.stringify({ pending, inProgress, done, failed, total: tasks.length }, null, 2) }] };
|
|
154
|
-
});
|
|
155
|
-
mcp.tool('fw_weaver_events', 'Read live execution events from a running or completed bot task. Returns events since the given offset for progressive streaming.', {
|
|
156
|
-
runId: z.string().describe('Run ID from a task execution'),
|
|
157
|
-
offset: z.number().optional().describe('Event offset to read from (default 0)'),
|
|
158
|
-
}, async (args) => {
|
|
159
|
-
const { EventLog } = await import('./bot/event-log.js');
|
|
160
|
-
const runId = args.runId;
|
|
161
|
-
const offset = args.offset ?? 0;
|
|
162
|
-
const log = new EventLog(runId);
|
|
163
|
-
const events = log.tail(offset);
|
|
164
|
-
const done = log.isDone();
|
|
165
|
-
return { content: [{ type: 'text', text: JSON.stringify({ events, done }) }] };
|
|
166
|
-
});
|
|
167
|
-
mcp.tool('fw_weaver_approve', 'Approve or reject a pending bot plan. Writes the decision so the bot can continue or abort.', {
|
|
168
|
-
approved: z.boolean().describe('Whether to approve the plan'),
|
|
169
|
-
reason: z.string().optional().describe('Reason for rejection'),
|
|
170
|
-
}, async (args) => {
|
|
171
|
-
const { writeFileSync } = await import('node:fs');
|
|
172
|
-
const { join } = await import('node:path');
|
|
173
|
-
const { homedir } = await import('node:os');
|
|
174
|
-
const dir = process.env.WEAVER_HISTORY_DIR ?? join(homedir(), '.weaver');
|
|
175
|
-
const decisionPath = join(dir, 'approval-decision.json');
|
|
176
|
-
writeFileSync(decisionPath, JSON.stringify({
|
|
177
|
-
approved: args.approved,
|
|
178
|
-
reason: args.reason ?? undefined,
|
|
179
|
-
timestamp: Date.now(),
|
|
180
|
-
}), 'utf-8');
|
|
181
|
-
return { content: [{ type: 'text', text: JSON.stringify({ ok: true }) }] };
|
|
182
|
-
});
|
|
183
|
-
mcp.tool('fw_weaver_genesis', 'Run a single Genesis self-evolution cycle on a target workflow. Genesis observes the project, proposes changes within a budget, validates, and commits or rolls back.', {
|
|
184
|
-
projectDir: z.string().optional().describe('Project directory (defaults to cwd)'),
|
|
185
|
-
dryRun: z.boolean().optional().describe('Preview without executing'),
|
|
186
|
-
}, async (args) => {
|
|
187
|
-
const packRoot = new URL('..', import.meta.url);
|
|
188
|
-
let workflowPath;
|
|
189
|
-
try {
|
|
190
|
-
const { existsSync } = await import('node:fs');
|
|
191
|
-
workflowPath = fileURLToPath(new URL('src/workflows/genesis-task.ts', packRoot));
|
|
192
|
-
if (!existsSync(workflowPath)) {
|
|
193
|
-
workflowPath = fileURLToPath(new URL('dist/workflows/genesis-task.js', packRoot));
|
|
94
|
+
catch (err) {
|
|
95
|
+
return {
|
|
96
|
+
content: [{
|
|
97
|
+
type: 'text',
|
|
98
|
+
text: err instanceof Error ? err.message : String(err),
|
|
99
|
+
}],
|
|
100
|
+
isError: true,
|
|
101
|
+
};
|
|
194
102
|
}
|
|
195
|
-
}
|
|
196
|
-
catch {
|
|
197
|
-
workflowPath = fileURLToPath(new URL('dist/workflows/genesis-task.js', packRoot));
|
|
198
|
-
}
|
|
199
|
-
const result = await runWorkflow(workflowPath, {
|
|
200
|
-
params: { projectDir: args.projectDir ?? process.cwd() },
|
|
201
|
-
dryRun: args.dryRun,
|
|
202
103
|
});
|
|
203
|
-
|
|
204
|
-
});
|
|
205
|
-
mcp.tool('fw_weaver_insights', 'Get project health, insights, trust level, and cost summary. Returns structured JSON with actionable recommendations.', {
|
|
206
|
-
projectDir: z.string().describe('Project directory path'),
|
|
207
|
-
}, async (args) => {
|
|
208
|
-
try {
|
|
209
|
-
const { ProjectModelStore } = await import('./bot/project-model.js');
|
|
210
|
-
const { InsightEngine } = await import('./bot/insight-engine.js');
|
|
211
|
-
const pms = new ProjectModelStore(args.projectDir);
|
|
212
|
-
const model = await pms.getOrBuild();
|
|
213
|
-
const engine = new InsightEngine();
|
|
214
|
-
const insights = engine.analyze(model);
|
|
215
|
-
return {
|
|
216
|
-
content: [{
|
|
217
|
-
type: 'text',
|
|
218
|
-
text: JSON.stringify({
|
|
219
|
-
health: model.health,
|
|
220
|
-
bots: model.bots,
|
|
221
|
-
insights: insights.slice(0, 10),
|
|
222
|
-
trust: model.trust,
|
|
223
|
-
cost: model.cost,
|
|
224
|
-
evolution: {
|
|
225
|
-
totalCycles: model.evolution.totalCycles,
|
|
226
|
-
successRate: model.evolution.successRate,
|
|
227
|
-
recentCycles: (model.evolution.recentCycles ?? []).slice(0, 20),
|
|
228
|
-
},
|
|
229
|
-
}, null, 2),
|
|
230
|
-
}],
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
catch (err) {
|
|
234
|
-
return {
|
|
235
|
-
content: [{ type: 'text', text: `Error: ${err instanceof Error ? err.message : String(err)}` }],
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
});
|
|
104
|
+
}
|
|
239
105
|
}
|
|
240
106
|
//# sourceMappingURL=mcp-tools.js.map
|
package/dist/mcp-tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tools.js","sourceRoot":"","sources":["../src/mcp-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE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AM,KAAK,GAAG,iBAAiB,EAAE,CAAC;IAClC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEnE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEvD,GAAG,CAAC,IAAI,CACN,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,WAAW,EAChB,QAAQ,EACR,KAAK,EAAE,IAAI,EAAE,EAAE;YACb,IAAI,CAAC;gBACH,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,gBAAgB,CAChD,IAAI,CAAC,IAAI,EACT,IAAI,EACJ,UAAU,CACX,CAAC;gBACF,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oBACzC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACtC,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO;oBACL,OAAO,EAAE,CAAC;4BACR,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;yBACvD,CAAC;oBACF,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies orchestrator routing decisions — assigns tasks, scales instances.
|
|
3
|
+
*
|
|
4
|
+
* @flowWeaver nodeType
|
|
5
|
+
* @label Dispatch Tasks
|
|
6
|
+
* @input decisions [order:0] - JSON OrchestratorOutput
|
|
7
|
+
* @input projectDir [order:1] - Project directory path
|
|
8
|
+
* @output results [order:0] - JSON dispatch results
|
|
9
|
+
* @output onSuccess [order:-2] - Dispatch complete
|
|
10
|
+
* @output onFailure [order:-1] [hidden] - Dispatch failed
|
|
11
|
+
*/
|
|
12
|
+
export declare function orchestratorDispatch(execute: boolean, decisions: string, projectDir: string): Promise<{
|
|
13
|
+
onSuccess: boolean;
|
|
14
|
+
onFailure: boolean;
|
|
15
|
+
results: string | null;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=orchestrator-dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator-dispatch.d.ts","sourceRoot":"","sources":["../../src/node-types/orchestrator-dispatch.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAqD7E"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies orchestrator routing decisions — assigns tasks, scales instances.
|
|
3
|
+
*
|
|
4
|
+
* @flowWeaver nodeType
|
|
5
|
+
* @label Dispatch Tasks
|
|
6
|
+
* @input decisions [order:0] - JSON OrchestratorOutput
|
|
7
|
+
* @input projectDir [order:1] - Project directory path
|
|
8
|
+
* @output results [order:0] - JSON dispatch results
|
|
9
|
+
* @output onSuccess [order:-2] - Dispatch complete
|
|
10
|
+
* @output onFailure [order:-1] [hidden] - Dispatch failed
|
|
11
|
+
*/
|
|
12
|
+
export async function orchestratorDispatch(execute, decisions, projectDir) {
|
|
13
|
+
if (!execute) {
|
|
14
|
+
return { onSuccess: true, onFailure: false, results: '{"assigned":0,"scaled":0,"skipped":0}' };
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const output = JSON.parse(decisions);
|
|
18
|
+
const { SwarmController } = await import('../bot/swarm-controller.js');
|
|
19
|
+
const controller = SwarmController.getInstance(projectDir);
|
|
20
|
+
const instanceManager = controller.getInstanceManager();
|
|
21
|
+
const profileStore = controller.getProfileStore();
|
|
22
|
+
let assigned = 0;
|
|
23
|
+
let scaled = 0;
|
|
24
|
+
let skipped = 0;
|
|
25
|
+
const appliedAssignments = [];
|
|
26
|
+
// Apply scale actions
|
|
27
|
+
for (const sa of output.scaleActions) {
|
|
28
|
+
const profile = profileStore.get(sa.profileId);
|
|
29
|
+
if (profile) {
|
|
30
|
+
instanceManager.scaleTo(profile, sa.targetInstances);
|
|
31
|
+
scaled++;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
skipped++;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Apply assignments — note: full task execution is handled by SwarmController's
|
|
38
|
+
// dispatch loop. This node only records the assignment in the task store.
|
|
39
|
+
// For actual task execution, the dispatch loop picks up assigned tasks.
|
|
40
|
+
for (const assignment of output.assignments) {
|
|
41
|
+
try {
|
|
42
|
+
appliedAssignments.push({
|
|
43
|
+
taskId: assignment.taskId,
|
|
44
|
+
profileId: assignment.profileId,
|
|
45
|
+
instanceId: assignment.instanceId,
|
|
46
|
+
});
|
|
47
|
+
assigned++;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
skipped++;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
skipped += output.skippedTasks.length;
|
|
54
|
+
const results = { assigned, scaled, skipped, appliedAssignments };
|
|
55
|
+
return { onSuccess: true, onFailure: false, results: JSON.stringify(results) };
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
59
|
+
console.error(`\x1b[31m→ Dispatch tasks failed: ${msg}\x1b[0m`);
|
|
60
|
+
return { onSuccess: false, onFailure: true, results: null };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=orchestrator-dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator-dispatch.js","sourceRoot":"","sources":["../../src/node-types/orchestrator-dispatch.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAgB,EAChB,SAAiB,EACjB,UAAkB;IAElB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,uCAAuC,EAAE,CAAC;IACjG,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAuB,CAAC;QAC3D,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;QACvE,MAAM,UAAU,GAAG,eAAe,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC3D,MAAM,eAAe,GAAG,UAAU,CAAC,kBAAkB,EAAE,CAAC;QACxD,MAAM,YAAY,GAAG,UAAU,CAAC,eAAe,EAAE,CAAC;QAElD,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,MAAM,kBAAkB,GAAqE,EAAE,CAAC;QAEhG,sBAAsB;QACtB,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACrC,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;YAC/C,IAAI,OAAO,EAAE,CAAC;gBACZ,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC;gBACrD,MAAM,E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
* @label Load Swarm State
|
|
6
|
+
* @input projectDir [order:0] - Project directory path
|
|
7
|
+
* @output state [order:0] - JSON OrchestratorInput snapshot
|
|
8
|
+
* @output onSuccess [order:-2] - Loaded successfully
|
|
9
|
+
* @output onFailure [order:-1] [hidden] - Load failed
|
|
10
|
+
*/
|
|
11
|
+
export declare function orchestratorLoadState(execute: boolean, projectDir: string): Promise<{
|
|
12
|
+
onSuccess: boolean;
|
|
13
|
+
onFailure: boolean;
|
|
14
|
+
state: string | null;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=orchestrator-load-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator-load-state.d.ts","sourceRoot":"","sources":["../../src/node-types/orchestrator-load-state.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAkD3E"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the current swarm state for the orchestrator to make routing decisions.
|
|
3
|
+
*
|
|
4
|
+
* @flowWeaver nodeType
|
|
5
|
+
* @label Load Swarm State
|
|
6
|
+
* @input projectDir [order:0] - Project directory path
|
|
7
|
+
* @output state [order:0] - JSON OrchestratorInput snapshot
|
|
8
|
+
* @output onSuccess [order:-2] - Loaded successfully
|
|
9
|
+
* @output onFailure [order:-1] [hidden] - Load failed
|
|
10
|
+
*/
|
|
11
|
+
export async function orchestratorLoadState(execute, projectDir) {
|
|
12
|
+
if (!execute) {
|
|
13
|
+
return { onSuccess: true, onFailure: false, state: '{"pendingTasks":[],"profiles":[],"instances":[],"budgetRemaining":{"tokens":0,"cost":0}}' };
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const { SwarmController } = await import('../bot/swarm-controller.js');
|
|
17
|
+
const controller = SwarmController.getInstance(projectDir);
|
|
18
|
+
const profileStore = controller.getProfileStore();
|
|
19
|
+
const instanceManager = controller.getInstanceManager();
|
|
20
|
+
const swarmStatus = controller.getStatus();
|
|
21
|
+
// Load profiles
|
|
22
|
+
const profiles = profileStore.list();
|
|
23
|
+
// Load instances
|
|
24
|
+
const instances = instanceManager.listAll();
|
|
25
|
+
// Calculate budget remaining from swarm state
|
|
26
|
+
const { workspace, session } = swarmStatus.budgets;
|
|
27
|
+
const remainingTokens = [];
|
|
28
|
+
const remainingCost = [];
|
|
29
|
+
if (session.limitTokens > 0)
|
|
30
|
+
remainingTokens.push(session.limitTokens - session.usedTokens);
|
|
31
|
+
if (workspace.limitTokens > 0)
|
|
32
|
+
remainingTokens.push(workspace.limitTokens - workspace.usedTokens);
|
|
33
|
+
if (session.limitCost > 0)
|
|
34
|
+
remainingCost.push(session.limitCost - session.usedCost);
|
|
35
|
+
if (workspace.limitCost > 0)
|
|
36
|
+
remainingCost.push(workspace.limitCost - workspace.usedCost);
|
|
37
|
+
const budgetRemaining = {
|
|
38
|
+
tokens: remainingTokens.length > 0 ? Math.min(...remainingTokens) : Infinity,
|
|
39
|
+
cost: remainingCost.length > 0 ? Math.min(...remainingCost) : Infinity,
|
|
40
|
+
};
|
|
41
|
+
// Note: pending tasks are not loaded here — the node only loads
|
|
42
|
+
// profiles, instances, and budget. Task loading requires TaskStore
|
|
43
|
+
// access which is internal to SwarmController's dispatch loop.
|
|
44
|
+
// The caller should provide tasks via the workflow or the dispatch loop
|
|
45
|
+
// builds the full OrchestratorInput itself.
|
|
46
|
+
const input = {
|
|
47
|
+
pendingTasks: [],
|
|
48
|
+
profiles,
|
|
49
|
+
instances,
|
|
50
|
+
budgetRemaining,
|
|
51
|
+
};
|
|
52
|
+
return { onSuccess: true, onFailure: false, state: JSON.stringify(input) };
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
56
|
+
console.error(`\x1b[31m→ Load swarm state failed: ${msg}\x1b[0m`);
|
|
57
|
+
return { onSuccess: false, onFailure: true, state: null };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=orchestrator-load-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator-load-state.js","sourceRoot":"","sources":["../../src/node-types/orchestrator-load-state.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAgB,EAChB,UAAkB;IAElB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,0FAA0F,EAAE,CAAC;IAClJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;QACvE,MAAM,UAAU,GAAG,eAAe,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,UAAU,CAAC,eAAe,EAAE,CAAC;QAClD,MAAM,eAAe,GAAG,UAAU,CAAC,kBAAkB,EAAE,CAAC;QACxD,MAAM,WAAW,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;QAE3C,gBAAgB;QAChB,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;QAErC,iBAAiB;QACjB,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,EAAE,CAAC;QAE5C,8CAA8C;QAC9C,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC;QACnD,MAAM,eAAe,GAAa,EAAE,CAAC;QACrC,MAAM,aAAa,GAAa,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,WAAW,GAAG,CAAC;Y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,CAAC;QAC7D,OAAO,CAAC,KAAK,CAAC,sCAAsC,GAAG,SAAS,CAAC,CAAC;QAClE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routes pending tasks to appropriate bot profiles using the orchestrator brain.
|
|
3
|
+
*
|
|
4
|
+
* @flowWeaver nodeType
|
|
5
|
+
* @label Route Tasks
|
|
6
|
+
* @input state [order:0] - JSON OrchestratorInput
|
|
7
|
+
* @output decisions [order:0] - JSON OrchestratorOutput
|
|
8
|
+
* @output onSuccess [order:-2] - Routing complete
|
|
9
|
+
* @output onFailure [order:-1] [hidden] - Routing failed
|
|
10
|
+
*/
|
|
11
|
+
export declare function orchestratorRoute(execute: boolean, state: string): Promise<{
|
|
12
|
+
onSuccess: boolean;
|
|
13
|
+
onFailure: boolean;
|
|
14
|
+
decisions: string | null;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=orchestrator-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator-route.d.ts","sourceRoot":"","sources":["../../src/node-types/orchestrator-route.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAgB/E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Orchestrator } from '../bot/orchestrator.js';
|
|
2
|
+
/**
|
|
3
|
+
* Routes pending tasks to appropriate bot profiles using the orchestrator brain.
|
|
4
|
+
*
|
|
5
|
+
* @flowWeaver nodeType
|
|
6
|
+
* @label Route Tasks
|
|
7
|
+
* @input state [order:0] - JSON OrchestratorInput
|
|
8
|
+
* @output decisions [order:0] - JSON OrchestratorOutput
|
|
9
|
+
* @output onSuccess [order:-2] - Routing complete
|
|
10
|
+
* @output onFailure [order:-1] [hidden] - Routing failed
|
|
11
|
+
*/
|
|
12
|
+
export async function orchestratorRoute(execute, state) {
|
|
13
|
+
if (!execute) {
|
|
14
|
+
return { onSuccess: true, onFailure: false, decisions: '{"assignments":[],"scaleActions":[],"skippedTasks":[]}' };
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const input = JSON.parse(state);
|
|
18
|
+
const orchestrator = new Orchestrator();
|
|
19
|
+
const output = await orchestrator.route(input);
|
|
20
|
+
return { onSuccess: true, onFailure: false, decisions: JSON.stringify(output) };
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
24
|
+
console.error(`\x1b[31m→ Route tasks failed: ${msg}\x1b[0m`);
|
|
25
|
+
return { onSuccess: false, onFailure: true, decisions: null };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=orchestrator-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator-route.js","sourceRoot":"","sources":["../../src/node-types/orchestrator-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAgB,EAChB,KAAa;IAEb,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,wDAAwD,EAAE,CAAC;IACpH,CAAC;IAED,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAsB,CAAC;QACrD,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE/C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAClF,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,OAAO,CAAC,KAAK,CAAC,iCAAiC,GAAG,SAAS,CAAC,CAAC;QAC7D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { WeaverEnv } from '../bot/types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Receives a task
|
|
4
|
-
*
|
|
5
|
-
* WeaverContext that threads through the bot pipeline.
|
|
3
|
+
* Receives a pre-supplied task and creates the WeaverContext that
|
|
4
|
+
* threads through the bot pipeline.
|
|
6
5
|
*
|
|
7
6
|
* @flowWeaver nodeType
|
|
8
7
|
* @label Receive Task
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"receive-task.d.ts","sourceRoot":"","sources":["../../src/node-types/receive-task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"receive-task.d.ts","sourceRoot":"","sources":["../../src/node-types/receive-task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,SAAS,EACd,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;IACT,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IACvC,GAAG,EAAE,MAAM,CAAC;CACb,CAAC,CAqBD"}
|