@synergenius/flow-weaver-pack-weaver 0.9.199 → 0.9.201
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.js +5 -5
- package/dist/ai-chat-provider.js.map +1 -1
- package/dist/bot/acceptance-merge.d.ts +21 -0
- package/dist/bot/acceptance-merge.d.ts.map +1 -0
- package/dist/bot/acceptance-merge.js +46 -0
- package/dist/bot/acceptance-merge.js.map +1 -0
- package/dist/bot/ai-client.d.ts +14 -2
- package/dist/bot/ai-client.d.ts.map +1 -1
- package/dist/bot/ai-client.js +71 -24
- package/dist/bot/ai-client.js.map +1 -1
- package/dist/bot/assistant-tools.js +3 -3
- package/dist/bot/assistant-tools.js.map +1 -1
- package/dist/bot/audit-logger.d.ts.map +1 -1
- package/dist/bot/audit-logger.js +34 -14
- package/dist/bot/audit-logger.js.map +1 -1
- package/dist/bot/audit-trail.d.ts +67 -0
- package/dist/bot/audit-trail.d.ts.map +1 -0
- package/dist/bot/audit-trail.js +153 -0
- package/dist/bot/audit-trail.js.map +1 -0
- package/dist/bot/behavior-defaults.d.ts +1 -1
- package/dist/bot/behavior-defaults.d.ts.map +1 -1
- package/dist/bot/behavior-defaults.js +7 -3
- package/dist/bot/behavior-defaults.js.map +1 -1
- package/dist/bot/capability-registry.d.ts +9 -0
- package/dist/bot/capability-registry.d.ts.map +1 -1
- package/dist/bot/capability-registry.js +81 -27
- package/dist/bot/capability-registry.js.map +1 -1
- package/dist/bot/capability-types.d.ts +10 -0
- package/dist/bot/capability-types.d.ts.map +1 -1
- package/dist/bot/cli-provider.d.ts.map +1 -1
- package/dist/bot/cli-provider.js +8 -7
- package/dist/bot/cli-provider.js.map +1 -1
- package/dist/bot/preflight.d.ts +48 -0
- package/dist/bot/preflight.d.ts.map +1 -0
- package/dist/bot/preflight.js +247 -0
- package/dist/bot/preflight.js.map +1 -0
- package/dist/bot/provider-shim.d.ts +74 -0
- package/dist/bot/provider-shim.d.ts.map +1 -0
- package/dist/bot/provider-shim.js +176 -0
- package/dist/bot/provider-shim.js.map +1 -0
- package/dist/bot/runner.d.ts +2 -0
- package/dist/bot/runner.d.ts.map +1 -1
- package/dist/bot/runner.js +60 -17
- package/dist/bot/runner.js.map +1 -1
- package/dist/bot/step-executor.d.ts.map +1 -1
- package/dist/bot/step-executor.js +72 -115
- package/dist/bot/step-executor.js.map +1 -1
- package/dist/bot/swarm-controller.d.ts +2 -0
- package/dist/bot/swarm-controller.d.ts.map +1 -1
- package/dist/bot/swarm-controller.js +92 -20
- package/dist/bot/swarm-controller.js.map +1 -1
- package/dist/bot/task-create-handler.d.ts +37 -0
- package/dist/bot/task-create-handler.d.ts.map +1 -0
- package/dist/bot/task-create-handler.js +124 -0
- package/dist/bot/task-create-handler.js.map +1 -0
- package/dist/bot/task-store.d.ts +1 -0
- package/dist/bot/task-store.d.ts.map +1 -1
- package/dist/bot/task-store.js +67 -0
- package/dist/bot/task-store.js.map +1 -1
- package/dist/bot/types.d.ts +1 -1
- package/dist/bot/types.d.ts.map +1 -1
- package/dist/bot/weaver-tools.d.ts.map +1 -1
- package/dist/bot/weaver-tools.js +7 -39
- package/dist/bot/weaver-tools.js.map +1 -1
- package/dist/node-types/agent-execute.d.ts +25 -8
- package/dist/node-types/agent-execute.d.ts.map +1 -1
- package/dist/node-types/agent-execute.js +89 -23
- package/dist/node-types/agent-execute.js.map +1 -1
- package/dist/node-types/bot-report.d.ts.map +1 -1
- package/dist/node-types/bot-report.js +24 -3
- package/dist/node-types/bot-report.js.map +1 -1
- package/dist/node-types/plan-task.d.ts +8 -17
- package/dist/node-types/plan-task.d.ts.map +1 -1
- package/dist/node-types/plan-task.js +217 -256
- package/dist/node-types/plan-task.js.map +1 -1
- package/dist/node-types/review-result.js +8 -6
- package/dist/node-types/review-result.js.map +1 -1
- package/dist/palindrome.d.ts +9 -0
- package/dist/palindrome.d.ts.map +1 -0
- package/dist/palindrome.js +14 -0
- package/dist/palindrome.js.map +1 -0
- package/dist/ui/approval-card.js +91 -82
- package/dist/ui/bot-activity.js +73 -56
- package/dist/ui/bot-config.js +48 -31
- package/dist/ui/bot-dashboard.js +52 -36
- package/dist/ui/bot-panel.js +230 -228
- package/dist/ui/bot-slot-card.js +100 -90
- package/dist/ui/bot-status.js +37 -15
- package/dist/ui/budget-bar.js +57 -31
- package/dist/ui/capability-editor.js +447 -378
- package/dist/ui/chat-task-result.js +78 -71
- package/dist/ui/decision-log.js +68 -81
- package/dist/ui/genesis-block.js +86 -95
- package/dist/ui/instance-stream-view.js +722 -0
- package/dist/ui/profile-card.js +96 -221
- package/dist/ui/profile-editor.js +532 -575
- package/dist/ui/settings-section.js +41 -45
- package/dist/ui/swarm-controls.js +212 -135
- package/dist/ui/swarm-dashboard.js +3992 -2715
- package/dist/ui/task-detail-view.js +415 -521
- package/dist/ui/task-editor.js +339 -390
- package/dist/ui/task-pool-list.js +60 -55
- package/dist/workflows/src/palindrome.d.ts +11 -0
- package/dist/workflows/src/palindrome.d.ts.map +1 -0
- package/dist/workflows/src/palindrome.js +16 -0
- package/dist/workflows/src/palindrome.js.map +1 -0
- package/dist/workflows/tests/palindrome.test.d.ts +2 -0
- package/dist/workflows/tests/palindrome.test.d.ts.map +1 -0
- package/dist/workflows/tests/palindrome.test.js +41 -0
- package/dist/workflows/tests/palindrome.test.js.map +1 -0
- package/dist/workflows/weaver-bot-batch.js +1 -1
- package/dist/workflows/weaver-bot-batch.js.map +1 -1
- package/dist/workflows/weaver-bot.js +1 -1
- package/dist/workflows/weaver-bot.js.map +1 -1
- package/flowweaver.manifest.json +1 -1
- package/package.json +8 -2
- package/src/ai-chat-provider.ts +5 -5
- package/src/bot/acceptance-merge.ts +62 -0
- package/src/bot/ai-client.ts +77 -21
- package/src/bot/assistant-tools.ts +3 -3
- package/src/bot/audit-logger.ts +42 -14
- package/src/bot/audit-trail.ts +211 -0
- package/src/bot/behavior-defaults.ts +7 -2
- package/src/bot/capability-registry.ts +84 -28
- package/src/bot/capability-types.ts +11 -0
- package/src/bot/cli-provider.ts +8 -7
- package/src/bot/preflight.ts +285 -0
- package/src/bot/provider-shim.ts +218 -0
- package/src/bot/runner.ts +68 -20
- package/src/bot/step-executor.ts +69 -127
- package/src/bot/swarm-controller.ts +94 -20
- package/src/bot/task-create-handler.ts +164 -0
- package/src/bot/task-store.ts +83 -0
- package/src/bot/types.ts +4 -1
- package/src/bot/weaver-tools.ts +7 -45
- package/src/node-types/agent-execute.ts +102 -16
- package/src/node-types/bot-report.ts +24 -3
- package/src/node-types/plan-task.ts +238 -280
- package/src/node-types/review-result.ts +8 -6
- package/src/palindrome.ts +14 -0
- package/src/ui/approval-card.tsx +78 -62
- package/src/ui/bot-activity.tsx +12 -10
- package/src/ui/bot-config.tsx +12 -10
- package/src/ui/bot-dashboard.tsx +13 -11
- package/src/ui/bot-panel.tsx +189 -171
- package/src/ui/bot-slot-card.tsx +125 -70
- package/src/ui/bot-status.tsx +4 -4
- package/src/ui/budget-bar.tsx +86 -25
- package/src/ui/capability-editor.tsx +392 -257
- package/src/ui/chat-task-result.tsx +81 -78
- package/src/ui/decision-log.tsx +76 -73
- package/src/ui/genesis-block.tsx +91 -61
- package/src/ui/instance-stream-view.tsx +861 -0
- package/src/ui/profile-card.tsx +195 -168
- package/src/ui/profile-editor.tsx +453 -370
- package/src/ui/settings-section.tsx +46 -39
- package/src/ui/swarm-controls.tsx +252 -123
- package/src/ui/swarm-dashboard.tsx +999 -466
- package/src/ui/task-detail-view.tsx +485 -428
- package/src/ui/task-editor.tsx +329 -271
- package/src/ui/task-pool-list.tsx +68 -62
- package/src/workflows/src/palindrome.ts +16 -0
- package/src/workflows/tests/palindrome.test.ts +49 -0
- package/src/workflows/weaver-bot-batch.ts +1 -1
- package/src/workflows/weaver-bot.ts +1 -1
- package/dist/ui/bot-constants.d.ts +0 -14
- package/dist/ui/bot-constants.d.ts.map +0 -1
- package/dist/ui/bot-constants.js +0 -189
- package/dist/ui/bot-constants.js.map +0 -1
- package/dist/ui/steer-api.d.ts +0 -7
- package/dist/ui/steer-api.d.ts.map +0 -1
- package/dist/ui/steer-api.js +0 -11
- package/dist/ui/steer-api.js.map +0 -1
- package/dist/ui/trace-to-timeline.d.ts +0 -91
- package/dist/ui/trace-to-timeline.d.ts.map +0 -1
- package/dist/ui/trace-to-timeline.js +0 -116
- package/dist/ui/trace-to-timeline.js.map +0 -1
- package/dist/ui/use-stream-timeline.d.ts +0 -50
- package/dist/ui/use-stream-timeline.d.ts.map +0 -1
- package/dist/ui/use-stream-timeline.js +0 -245
- package/dist/ui/use-stream-timeline.js.map +0 -1
|
@@ -5,8 +5,10 @@ import {
|
|
|
5
5
|
getOrCreateCliSession,
|
|
6
6
|
killAllCliSessions,
|
|
7
7
|
joinSplitPrompt,
|
|
8
|
+
createMcpBridge,
|
|
8
9
|
type AgentProvider,
|
|
9
10
|
type AgentMessage,
|
|
11
|
+
type McpBridge,
|
|
10
12
|
type ToolDefinition,
|
|
11
13
|
type StreamEvent,
|
|
12
14
|
type StreamOptions,
|
|
@@ -20,12 +22,21 @@ import { withRetry, getErrorGuidance } from '../bot/error-classifier.js';
|
|
|
20
22
|
import { CostTracker } from '../bot/cost-tracker.js';
|
|
21
23
|
import { PostTurnHookRunner, CostCheckpointHook, ProgressReportHook } from '../bot/post-turn-hooks.js';
|
|
22
24
|
|
|
23
|
-
//
|
|
25
|
+
// Track MCP bridges for cleanup alongside CLI sessions
|
|
26
|
+
const activeBridges: McpBridge[] = [];
|
|
27
|
+
|
|
28
|
+
// Clean up persistent sessions and MCP bridges on process exit
|
|
24
29
|
let cleanupRegistered = false;
|
|
25
30
|
function registerCleanup(): void {
|
|
26
31
|
if (cleanupRegistered) return;
|
|
27
32
|
cleanupRegistered = true;
|
|
28
|
-
const cleanup = () => {
|
|
33
|
+
const cleanup = () => {
|
|
34
|
+
try { killAllCliSessions(); } catch (err) { if (process.env.WEAVER_VERBOSE) console.error('[agent-execute] session cleanup failed:', err); }
|
|
35
|
+
for (const bridge of activeBridges) {
|
|
36
|
+
try { bridge.cleanup(); } catch { /* non-fatal */ }
|
|
37
|
+
}
|
|
38
|
+
activeBridges.length = 0;
|
|
39
|
+
};
|
|
29
40
|
process.on('exit', cleanup);
|
|
30
41
|
process.on('SIGTERM', cleanup);
|
|
31
42
|
process.on('SIGINT', cleanup);
|
|
@@ -37,13 +48,42 @@ function registerCleanup(): void {
|
|
|
37
48
|
* we only forward the latest user/tool messages since the session
|
|
38
49
|
* maintains its own conversation state.
|
|
39
50
|
*/
|
|
51
|
+
/** Events emitted by the CLI when the model calls a tool — filtered when MCP bridge handles execution. */
|
|
52
|
+
const TOOL_USE_EVENT_TYPES = new Set(['tool_use_start', 'tool_use_delta', 'tool_use_end']);
|
|
53
|
+
|
|
54
|
+
/** Cumulative stats from CliSessionProvider — read by callers for audit/observability. */
|
|
55
|
+
export interface CliSessionProviderStats {
|
|
56
|
+
bridgeActive: boolean;
|
|
57
|
+
bridgeConfigPath: string | undefined;
|
|
58
|
+
toolUseFiltered: number;
|
|
59
|
+
toolResultPassthrough: number;
|
|
60
|
+
textToolCallDetected: number;
|
|
61
|
+
streamCalls: number;
|
|
62
|
+
setHandlersCalls: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
40
65
|
class CliSessionProvider implements AgentProvider {
|
|
41
66
|
private sentCount = 0;
|
|
67
|
+
private _stats: CliSessionProviderStats;
|
|
42
68
|
|
|
43
69
|
constructor(
|
|
44
70
|
private session: { ready: boolean; spawn: () => Promise<void>; send: (msg: string, systemPrompt?: string) => AsyncGenerator<StreamEvent> },
|
|
45
71
|
readonly model: string = 'claude-sonnet-4-6',
|
|
46
|
-
|
|
72
|
+
private bridge?: McpBridge,
|
|
73
|
+
) {
|
|
74
|
+
this._stats = {
|
|
75
|
+
bridgeActive: !!bridge,
|
|
76
|
+
bridgeConfigPath: bridge?.configPath,
|
|
77
|
+
toolUseFiltered: 0,
|
|
78
|
+
toolResultPassthrough: 0,
|
|
79
|
+
textToolCallDetected: 0,
|
|
80
|
+
streamCalls: 0,
|
|
81
|
+
setHandlersCalls: 0,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Observable stats — read after runAgentLoop to audit bridge behavior. */
|
|
86
|
+
get stats(): Readonly<CliSessionProviderStats> { return this._stats; }
|
|
47
87
|
|
|
48
88
|
async *stream(
|
|
49
89
|
messages: AgentMessage[],
|
|
@@ -51,6 +91,14 @@ class CliSessionProvider implements AgentProvider {
|
|
|
51
91
|
options?: StreamOptions,
|
|
52
92
|
): AsyncGenerator<StreamEvent> {
|
|
53
93
|
if (!this.session.ready) await this.session.spawn();
|
|
94
|
+
this._stats.streamCalls++;
|
|
95
|
+
|
|
96
|
+
// When MCP bridge is present, update its handlers so tool execution and
|
|
97
|
+
// onToolEvent callbacks use this request's executor/callback.
|
|
98
|
+
if (this.bridge && options?.executor) {
|
|
99
|
+
this.bridge.setHandlers(options.executor, options.onToolEvent);
|
|
100
|
+
this._stats.setHandlersCalls++;
|
|
101
|
+
}
|
|
54
102
|
|
|
55
103
|
// Only send new messages (session has history of previous ones)
|
|
56
104
|
const newMessages = messages.slice(this.sentCount);
|
|
@@ -78,6 +126,26 @@ class CliSessionProvider implements AgentProvider {
|
|
|
78
126
|
((model: string, usage: { inputTokens: number; outputTokens: number }) => void) | undefined;
|
|
79
127
|
|
|
80
128
|
for await (const event of this.session.send(prompt, systemPromptStr)) {
|
|
129
|
+
// When MCP bridge is active, the bridge already executed tools and fired
|
|
130
|
+
// onToolEvent. Filter tool_use_* events so runAgentLoop doesn't re-execute.
|
|
131
|
+
// tool_result events pass through — the loop counts them without executing.
|
|
132
|
+
if (this.bridge && TOOL_USE_EVENT_TYPES.has(event.type)) {
|
|
133
|
+
this._stats.toolUseFiltered++;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (event.type === 'tool_result') {
|
|
138
|
+
this._stats.toolResultPassthrough++;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Detect model outputting tool calls as text (MCP not connected)
|
|
142
|
+
if (event.type === 'text_delta') {
|
|
143
|
+
const text = (event as { text?: string }).text ?? '';
|
|
144
|
+
if (text.includes('<tool_call>') || text.includes('**Tool Call') || text.includes('<function_calls>')) {
|
|
145
|
+
this._stats.textToolCallDetected++;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
81
149
|
if (event.type === 'usage' && usageCb) {
|
|
82
150
|
usageCb(this.model, {
|
|
83
151
|
inputTokens: event.promptTokens,
|
|
@@ -274,10 +342,13 @@ export async function weaverAgentExecute(
|
|
|
274
342
|
);
|
|
275
343
|
|
|
276
344
|
const usage = result.usage;
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
345
|
+
// Use real cost from CLI if available, fall back to estimate
|
|
346
|
+
const estimatedCost = usage.costUsd > 0
|
|
347
|
+
? usage.costUsd
|
|
348
|
+
: CostTracker.estimateCost(model, {
|
|
349
|
+
inputTokens: usage.promptTokens,
|
|
350
|
+
outputTokens: usage.completionTokens,
|
|
351
|
+
});
|
|
281
352
|
|
|
282
353
|
const uniqueCreated = [...new Set(filesCreated)];
|
|
283
354
|
const uniqueModified = [...new Set(filesModified)];
|
|
@@ -397,7 +468,7 @@ export async function weaverAgentExecute(
|
|
|
397
468
|
/**
|
|
398
469
|
* Create an AgentProvider from pack-weaver's ProviderInfo.
|
|
399
470
|
*/
|
|
400
|
-
async function createProvider(
|
|
471
|
+
export async function createProvider(
|
|
401
472
|
pInfo: { type: string; apiKey?: string; model?: string; maxTokens?: number },
|
|
402
473
|
projectDir?: string,
|
|
403
474
|
): Promise<AgentProvider> {
|
|
@@ -433,7 +504,7 @@ async function createProvider(
|
|
|
433
504
|
|
|
434
505
|
// Claude CLI — use persistent session for warm start
|
|
435
506
|
if (type === 'claude-cli') {
|
|
436
|
-
return createSessionProvider(pInfo.model, projectDir);
|
|
507
|
+
return await createSessionProvider(pInfo.model, projectDir);
|
|
437
508
|
}
|
|
438
509
|
|
|
439
510
|
// Auto mode: try platform login, then Anthropic API key, then Claude CLI
|
|
@@ -459,7 +530,7 @@ async function createProvider(
|
|
|
459
530
|
});
|
|
460
531
|
}
|
|
461
532
|
// No API key — use Claude CLI with persistent session
|
|
462
|
-
return createSessionProvider(pInfo.model, projectDir);
|
|
533
|
+
return await createSessionProvider(pInfo.model, projectDir);
|
|
463
534
|
}
|
|
464
535
|
|
|
465
536
|
throw new Error(
|
|
@@ -467,13 +538,28 @@ async function createProvider(
|
|
|
467
538
|
);
|
|
468
539
|
}
|
|
469
540
|
|
|
470
|
-
function createSessionProvider(model?: string, projectDir?: string): CliSessionProvider {
|
|
541
|
+
async function createSessionProvider(model?: string, projectDir?: string): Promise<CliSessionProvider> {
|
|
471
542
|
registerCleanup();
|
|
472
543
|
const key = projectDir ?? process.cwd();
|
|
473
|
-
const
|
|
474
|
-
|
|
544
|
+
const resolvedModel = model ?? 'claude-sonnet-4-6';
|
|
545
|
+
|
|
546
|
+
// Create MCP bridge so the CLI session has pack tools (read_file, write_file,
|
|
547
|
+
// run_shell, etc.) registered. The bridge uses a placeholder executor that is
|
|
548
|
+
// swapped per-request via setHandlers() in CliSessionProvider.stream().
|
|
549
|
+
const executor = createWeaverExecutor(key);
|
|
550
|
+
const bridge = await createMcpBridge(WEAVER_TOOLS, executor);
|
|
551
|
+
activeBridges.push(bridge);
|
|
552
|
+
|
|
553
|
+
// NOTE: auditEmit from this module is unreliable under symlinks (dual module
|
|
554
|
+
// instance — currentRunId may be null). Observability is handled by the caller
|
|
555
|
+
// (plan-task.ts / agent-execute node) via provider.stats after runAgentLoop.
|
|
556
|
+
|
|
557
|
+
const { getCliSessionConfig } = await import('@synergenius/flow-weaver/agent');
|
|
558
|
+
const session = getOrCreateCliSession(key, getCliSessionConfig({
|
|
475
559
|
cwd: key,
|
|
476
|
-
model:
|
|
477
|
-
|
|
478
|
-
|
|
560
|
+
model: resolvedModel,
|
|
561
|
+
mcpConfigPath: bridge.configPath,
|
|
562
|
+
appendSystemPrompt: 'You are Weaver, an AI workflow bot. Use the provided tools to complete tasks. Never attempt to use built-in tools.',
|
|
563
|
+
}));
|
|
564
|
+
return new CliSessionProvider(session, resolvedModel, bridge);
|
|
479
565
|
}
|
|
@@ -120,12 +120,33 @@ export async function weaverBotReport(
|
|
|
120
120
|
|
|
121
121
|
const summary = parts.join(' | ');
|
|
122
122
|
|
|
123
|
-
// Mark queue task as completed or failed via TaskStore
|
|
123
|
+
// Mark queue task as completed or failed via TaskStore.
|
|
124
|
+
// Ensures task is in-progress before releasing (assigns if needed).
|
|
124
125
|
if (task.queueId && context.env?.projectDir) {
|
|
125
126
|
try {
|
|
126
127
|
const store = new TaskStore(context.env.projectDir);
|
|
127
|
-
await store.
|
|
128
|
-
|
|
128
|
+
const current = await store.get(task.queueId);
|
|
129
|
+
if (current && current.status === 'open') {
|
|
130
|
+
// Standalone mode: task was never assigned. Assign first.
|
|
131
|
+
await store.assignToInstance(task.queueId, `standalone-${Date.now()}`, 'default');
|
|
132
|
+
}
|
|
133
|
+
if (current && (current.status === 'in-progress' || current.status === 'open')) {
|
|
134
|
+
const releaseStatus = success ? 'done' as const : 'open' as const;
|
|
135
|
+
await store.release(task.queueId, releaseStatus, {
|
|
136
|
+
runId: `report-${Date.now()}`,
|
|
137
|
+
botId: 'standalone',
|
|
138
|
+
profileId: 'default',
|
|
139
|
+
outcome: success ? 'completed' : 'stalled',
|
|
140
|
+
filesCreated: [],
|
|
141
|
+
filesModified: files,
|
|
142
|
+
summary: summary,
|
|
143
|
+
tokensUsed: 0,
|
|
144
|
+
cost: 0,
|
|
145
|
+
durationMs: 0,
|
|
146
|
+
endedAt: new Date().toISOString(),
|
|
147
|
+
});
|
|
148
|
+
console.log(`\x1b[36m→ Queue task ${task.queueId}: ${releaseStatus}\x1b[0m`);
|
|
149
|
+
}
|
|
129
150
|
} catch (err) { if (process.env.WEAVER_VERBOSE) console.error('[bot-report] queue update failed:', err); }
|
|
130
151
|
}
|
|
131
152
|
|