@synergenius/flow-weaver-pack-weaver 0.9.193 → 0.9.196
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/bot/ai-client.d.ts +5 -0
- package/dist/bot/ai-client.d.ts.map +1 -1
- package/dist/bot/ai-client.js +43 -0
- package/dist/bot/ai-client.js.map +1 -1
- package/dist/bot/assistant-core.js +2 -2
- package/dist/bot/assistant-core.js.map +1 -1
- package/dist/bot/behavior-defaults.d.ts +3 -1
- package/dist/bot/behavior-defaults.d.ts.map +1 -1
- package/dist/bot/behavior-defaults.js +7 -0
- package/dist/bot/behavior-defaults.js.map +1 -1
- package/dist/bot/capability-registry.js +3 -3
- package/dist/bot/capability-registry.js.map +1 -1
- package/dist/bot/context-compactor.d.ts +35 -0
- package/dist/bot/context-compactor.d.ts.map +1 -0
- package/dist/bot/context-compactor.js +130 -0
- package/dist/bot/context-compactor.js.map +1 -0
- package/dist/bot/dream-task.d.ts +45 -0
- package/dist/bot/dream-task.d.ts.map +1 -0
- package/dist/bot/dream-task.js +125 -0
- package/dist/bot/dream-task.js.map +1 -0
- package/dist/bot/knowledge-store.d.ts +9 -0
- package/dist/bot/knowledge-store.d.ts.map +1 -1
- package/dist/bot/knowledge-store.js +21 -0
- package/dist/bot/knowledge-store.js.map +1 -1
- package/dist/bot/memory-extraction-worker.d.ts +14 -0
- package/dist/bot/memory-extraction-worker.d.ts.map +1 -0
- package/dist/bot/memory-extraction-worker.js +42 -0
- package/dist/bot/memory-extraction-worker.js.map +1 -0
- package/dist/bot/memory-extractor.d.ts +27 -0
- package/dist/bot/memory-extractor.d.ts.map +1 -0
- package/dist/bot/memory-extractor.js +155 -0
- package/dist/bot/memory-extractor.js.map +1 -0
- package/dist/bot/operations.d.ts +3 -1
- package/dist/bot/operations.d.ts.map +1 -1
- package/dist/bot/operations.js +3 -1
- package/dist/bot/operations.js.map +1 -1
- package/dist/bot/post-turn-hooks.d.ts +57 -0
- package/dist/bot/post-turn-hooks.d.ts.map +1 -0
- package/dist/bot/post-turn-hooks.js +108 -0
- package/dist/bot/post-turn-hooks.js.map +1 -0
- package/dist/bot/profile-types.d.ts +16 -0
- package/dist/bot/profile-types.d.ts.map +1 -1
- package/dist/bot/swarm-controller.d.ts +7 -0
- package/dist/bot/swarm-controller.d.ts.map +1 -1
- package/dist/bot/swarm-controller.js +121 -1
- package/dist/bot/swarm-controller.js.map +1 -1
- package/dist/bot/task-prompt-builder.js +35 -21
- package/dist/bot/task-prompt-builder.js.map +1 -1
- package/dist/bot/task-types.d.ts +13 -0
- package/dist/bot/task-types.d.ts.map +1 -1
- package/dist/bot/tool-registry.d.ts +13 -0
- package/dist/bot/tool-registry.d.ts.map +1 -1
- package/dist/bot/tool-registry.js +80 -0
- package/dist/bot/tool-registry.js.map +1 -1
- package/dist/bot/types.d.ts +2 -0
- package/dist/bot/types.d.ts.map +1 -1
- package/dist/node-types/agent-execute.d.ts.map +1 -1
- package/dist/node-types/agent-execute.js +38 -17
- package/dist/node-types/agent-execute.js.map +1 -1
- package/dist/node-types/build-context.d.ts +4 -3
- package/dist/node-types/build-context.d.ts.map +1 -1
- package/dist/node-types/build-context.js +37 -6
- package/dist/node-types/build-context.js.map +1 -1
- package/dist/node-types/receive-task.d.ts +2 -1
- package/dist/node-types/receive-task.d.ts.map +1 -1
- package/dist/node-types/receive-task.js +4 -1
- package/dist/node-types/receive-task.js.map +1 -1
- package/dist/node-types/review-result.d.ts +9 -0
- package/dist/node-types/review-result.d.ts.map +1 -1
- package/dist/node-types/review-result.js +20 -5
- package/dist/node-types/review-result.js.map +1 -1
- package/dist/node-types/verify-task.d.ts +22 -0
- package/dist/node-types/verify-task.d.ts.map +1 -0
- package/dist/node-types/verify-task.js +143 -0
- package/dist/node-types/verify-task.js.map +1 -0
- package/dist/ui/capability-editor.js +3 -3
- package/dist/ui/profile-editor.js +3 -3
- package/dist/ui/swarm-dashboard.js +3 -3
- package/dist/workflows/weaver-agent.d.ts +3 -3
- package/dist/workflows/weaver-agent.d.ts.map +1 -1
- package/dist/workflows/weaver-agent.js +267 -18
- package/dist/workflows/weaver-agent.js.map +1 -1
- package/dist/workflows/weaver-bot-batch.d.ts +3 -3
- package/dist/workflows/weaver-bot-batch.d.ts.map +1 -1
- package/dist/workflows/weaver-bot-batch.js +280 -24
- package/dist/workflows/weaver-bot-batch.js.map +1 -1
- package/dist/workflows/weaver-bot.d.ts +2 -0
- package/dist/workflows/weaver-bot.d.ts.map +1 -1
- package/dist/workflows/weaver-bot.js +15 -10
- package/dist/workflows/weaver-bot.js.map +1 -1
- package/flowweaver.manifest.json +1 -1
- package/package.json +3 -3
- package/src/bot/ai-client.ts +54 -0
- package/src/bot/assistant-core.ts +2 -2
- package/src/bot/behavior-defaults.ts +9 -1
- package/src/bot/capability-registry.ts +3 -3
- package/src/bot/context-compactor.ts +147 -0
- package/src/bot/dream-task.ts +167 -0
- package/src/bot/knowledge-store.ts +27 -0
- package/src/bot/memory-extraction-worker.ts +58 -0
- package/src/bot/memory-extractor.ts +213 -0
- package/src/bot/operations.ts +3 -1
- package/src/bot/post-turn-hooks.ts +137 -0
- package/src/bot/profile-types.ts +17 -0
- package/src/bot/swarm-controller.ts +129 -2
- package/src/bot/task-prompt-builder.ts +37 -21
- package/src/bot/task-types.ts +21 -0
- package/src/bot/tool-registry.ts +89 -0
- package/src/bot/types.ts +2 -0
- package/src/node-types/agent-execute.ts +44 -17
- package/src/node-types/build-context.ts +45 -7
- package/src/node-types/receive-task.ts +3 -0
- package/src/node-types/review-result.ts +22 -5
- package/src/node-types/verify-task.ts +181 -0
- package/src/workflows/weaver-agent.ts +429 -18
- package/src/workflows/weaver-bot-batch.ts +443 -24
- package/src/workflows/weaver-bot.ts +16 -11
|
@@ -16,21 +16,413 @@ import { weaverBotReport } from '../node-types/bot-report.js';
|
|
|
16
16
|
// DO NOT EDIT - This section is auto-generated by Flow Weaver
|
|
17
17
|
// ============================================================================
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Runtime Types
|
|
21
|
+
// ============================================================================
|
|
22
|
+
|
|
23
|
+
type TStatusType =
|
|
24
|
+
| "RUNNING"
|
|
25
|
+
| "SCHEDULED"
|
|
26
|
+
| "SUCCEEDED"
|
|
27
|
+
| "FAILED"
|
|
28
|
+
| "CANCELLED"
|
|
29
|
+
| "PENDING";
|
|
30
|
+
|
|
31
|
+
type TVariableIdentification = {
|
|
32
|
+
nodeTypeName: string;
|
|
33
|
+
id: string;
|
|
34
|
+
scope?: string | undefined;
|
|
35
|
+
side?: "start" | "exit" | undefined;
|
|
36
|
+
portName: string;
|
|
37
|
+
executionIndex: number;
|
|
38
|
+
key?: string | undefined;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type TStatusChangedEvent = {
|
|
42
|
+
type: "STATUS_CHANGED";
|
|
43
|
+
nodeTypeName: string;
|
|
44
|
+
id: string;
|
|
45
|
+
scope?: string;
|
|
46
|
+
side?: "start" | "exit";
|
|
47
|
+
executionIndex: number;
|
|
48
|
+
status: TStatusType;
|
|
49
|
+
innerFlowInvocation?: boolean;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type TVariableSetEvent = {
|
|
53
|
+
type: "VARIABLE_SET";
|
|
54
|
+
identifier: TVariableIdentification;
|
|
55
|
+
value?: unknown;
|
|
56
|
+
innerFlowInvocation?: boolean;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
type TErrorLogEvent = {
|
|
60
|
+
type: "LOG_ERROR";
|
|
61
|
+
nodeTypeName: string;
|
|
62
|
+
id: string;
|
|
63
|
+
scope?: string;
|
|
64
|
+
side?: "start" | "exit";
|
|
65
|
+
executionIndex: number;
|
|
66
|
+
error: string;
|
|
67
|
+
innerFlowInvocation?: boolean;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
type TWorkflowCompletedEvent = {
|
|
71
|
+
type: "WORKFLOW_COMPLETED";
|
|
72
|
+
executionIndex: number;
|
|
73
|
+
status: "SUCCEEDED" | "FAILED" | "CANCELLED";
|
|
74
|
+
result?: unknown;
|
|
75
|
+
innerFlowInvocation?: boolean;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
type TEvent =
|
|
79
|
+
| TStatusChangedEvent
|
|
80
|
+
| TVariableSetEvent
|
|
81
|
+
| TErrorLogEvent
|
|
82
|
+
| TWorkflowCompletedEvent;
|
|
83
|
+
|
|
84
|
+
type TDebugger = {
|
|
85
|
+
sendEvent: (event: TEvent) => void | Promise<void>;
|
|
86
|
+
innerFlowInvocation: boolean;
|
|
87
|
+
sessionId?: string;
|
|
88
|
+
};
|
|
89
|
+
|
|
21
90
|
declare const __flowWeaverDebugger__: TDebugger | undefined;
|
|
91
|
+
|
|
92
|
+
type TDebugController = {
|
|
93
|
+
beforeNode(nodeId: string, ctx: GeneratedExecutionContext): Promise<boolean> | boolean;
|
|
94
|
+
afterNode(nodeId: string, ctx: GeneratedExecutionContext): Promise<void> | void;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
declare const __abortSignal__: AbortSignal | undefined;
|
|
98
|
+
|
|
99
|
+
interface VariableAddress {
|
|
100
|
+
id: string;
|
|
101
|
+
portName: string;
|
|
102
|
+
executionIndex: number;
|
|
103
|
+
nodeTypeName?: string | undefined;
|
|
104
|
+
scope?: string | undefined;
|
|
105
|
+
side?: 'start' | 'exit' | undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface ExecutionInfo {
|
|
109
|
+
id: string;
|
|
110
|
+
index: number;
|
|
111
|
+
parentIndex?: number | undefined;
|
|
112
|
+
scopeName?: string | undefined;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
type VariableValue = unknown | (() => unknown) | (() => Promise<unknown>);
|
|
116
|
+
|
|
117
|
+
// ============================================================================
|
|
118
|
+
// Cancellation Error
|
|
119
|
+
// ============================================================================
|
|
120
|
+
|
|
121
|
+
class CancellationError extends Error {
|
|
122
|
+
public readonly executionIndex: number;
|
|
123
|
+
public readonly nodeId?: string;
|
|
124
|
+
public readonly timestamp: number;
|
|
125
|
+
|
|
126
|
+
constructor(
|
|
127
|
+
message: string = 'Workflow execution cancelled',
|
|
128
|
+
executionIndex: number = 0,
|
|
129
|
+
nodeId?: string,
|
|
130
|
+
timestamp: number = Date.now()
|
|
131
|
+
) {
|
|
132
|
+
super(message);
|
|
133
|
+
this.name = 'CancellationError';
|
|
134
|
+
this.executionIndex = executionIndex;
|
|
135
|
+
this.nodeId = nodeId;
|
|
136
|
+
this.timestamp = timestamp;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static isCancellationError(error: unknown): error is CancellationError {
|
|
140
|
+
return (
|
|
141
|
+
error instanceof CancellationError ||
|
|
142
|
+
(error instanceof Error && error.name === 'CancellationError')
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ============================================================================
|
|
148
|
+
// Execution Context
|
|
149
|
+
// ============================================================================
|
|
150
|
+
|
|
151
|
+
class GeneratedExecutionContext {
|
|
152
|
+
private variables: Map<string, VariableValue> = new Map();
|
|
153
|
+
private executions: Map<string, ExecutionInfo> = new Map();
|
|
154
|
+
private executionCounter: number = 0;
|
|
155
|
+
private nodeExecutionCounts: Map<string, number> = new Map();
|
|
156
|
+
private isAsync: boolean;
|
|
157
|
+
private flowWeaverDebugger?: TDebugger | undefined;
|
|
158
|
+
private pullExecutors: Map<string, () => void | Promise<void>> = new Map();
|
|
159
|
+
private nodeExecutionIndices: Map<string, number> = new Map();
|
|
160
|
+
private abortSignal?: AbortSignal | undefined;
|
|
161
|
+
|
|
162
|
+
constructor(isAsync: boolean = true, flowWeaverDebugger?: TDebugger, abortSignal?: AbortSignal) {
|
|
163
|
+
this.isAsync = isAsync;
|
|
164
|
+
this.flowWeaverDebugger = flowWeaverDebugger;
|
|
165
|
+
this.abortSignal = abortSignal;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
registerPullExecutor(id: string, executor: () => void | Promise<void>): void {
|
|
169
|
+
this.pullExecutors.set(id, executor);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
addExecution(id: string, parentIndex?: number, scopeName?: string): number {
|
|
173
|
+
// Use per-node execution counter (each node starts at 0)
|
|
174
|
+
const currentCount = this.nodeExecutionCounts.get(id) || 0;
|
|
175
|
+
const index = currentCount;
|
|
176
|
+
this.nodeExecutionCounts.set(id, currentCount + 1);
|
|
177
|
+
this.executionCounter++;
|
|
178
|
+
this.executions.set(this.getExecutionKey(id, index), {
|
|
179
|
+
id,
|
|
180
|
+
index,
|
|
181
|
+
parentIndex,
|
|
182
|
+
scopeName,
|
|
183
|
+
});
|
|
184
|
+
this.nodeExecutionIndices.set(id, index);
|
|
185
|
+
return index;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
setVariable(address: VariableAddress, value: VariableValue): void | Promise<void> {
|
|
189
|
+
const key = this.getVariableKey(address);
|
|
190
|
+
this.variables.set(key, value);
|
|
191
|
+
if (this.flowWeaverDebugger) {
|
|
192
|
+
const actualValue = typeof value === "function" ? value() : value;
|
|
193
|
+
this.sendVariableSetEvent({
|
|
194
|
+
identifier: {
|
|
195
|
+
nodeTypeName: address.nodeTypeName || "unknown",
|
|
196
|
+
id: address.id,
|
|
197
|
+
portName: address.portName,
|
|
198
|
+
executionIndex: address.executionIndex,
|
|
199
|
+
key: "default",
|
|
200
|
+
...(address.scope && { scope: address.scope }),
|
|
201
|
+
...(address.side && { side: address.side }),
|
|
202
|
+
},
|
|
203
|
+
value: actualValue,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return this.isAsync ? Promise.resolve() : undefined;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
getVariable(address: VariableAddress): unknown | Promise<unknown> {
|
|
210
|
+
const executor = this.pullExecutors.get(address.id);
|
|
211
|
+
if (executor) {
|
|
212
|
+
if (!this.hasVariable(address)) {
|
|
213
|
+
const result = executor();
|
|
214
|
+
// Handle async executor (returns Promise)
|
|
215
|
+
if (result instanceof Promise) {
|
|
216
|
+
return result.then(() => {
|
|
217
|
+
const trackedIndex = this.nodeExecutionIndices.get(address.id);
|
|
218
|
+
const finalAddress = trackedIndex !== undefined
|
|
219
|
+
? { ...address, executionIndex: trackedIndex }
|
|
220
|
+
: address;
|
|
221
|
+
return this.retrieveVariable(finalAddress);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
// Handle sync executor (returns void)
|
|
225
|
+
const trackedIndex = this.nodeExecutionIndices.get(address.id);
|
|
226
|
+
const finalAddress = trackedIndex !== undefined
|
|
227
|
+
? { ...address, executionIndex: trackedIndex }
|
|
228
|
+
: address;
|
|
229
|
+
return this.retrieveVariable(finalAddress);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return this.retrieveVariable(address);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
private retrieveVariable(address: VariableAddress): unknown | Promise<unknown> {
|
|
236
|
+
const key = this.getVariableKey(address);
|
|
237
|
+
if (!this.variables.has(key)) {
|
|
238
|
+
throw new Error(`Variable not found: ${address.id}.${address.portName}[${address.executionIndex}]`);
|
|
239
|
+
}
|
|
240
|
+
const value = this.variables.get(key);
|
|
241
|
+
if (typeof value === "function") {
|
|
242
|
+
const result = value();
|
|
243
|
+
if (result instanceof Promise) {
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
246
|
+
return this.isAsync ? Promise.resolve(result) : result;
|
|
247
|
+
}
|
|
248
|
+
return this.isAsync ? Promise.resolve(value) : value;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
hasVariable(address: VariableAddress): boolean {
|
|
252
|
+
const key = this.getVariableKey(address);
|
|
253
|
+
return this.variables.has(key);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
getExecution(id: string, index: number): ExecutionInfo | undefined {
|
|
257
|
+
return this.executions.get(this.getExecutionKey(id, index));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
createScope(_parentNodeName: string, _parentIndex: number, _scopeName: string, cleanScope: boolean = false, isAsyncOverride?: boolean): GeneratedExecutionContext {
|
|
261
|
+
const effectiveIsAsync = isAsyncOverride !== undefined ? isAsyncOverride : this.isAsync;
|
|
262
|
+
const scopedContext = new GeneratedExecutionContext(effectiveIsAsync, this.flowWeaverDebugger, this.abortSignal);
|
|
263
|
+
// For per-port function scopes (cleanScope=true), start with empty variables
|
|
264
|
+
// For node-level scopes (cleanScope=false), inherit parent variables
|
|
265
|
+
scopedContext.variables = cleanScope ? new Map() : new Map(this.variables);
|
|
266
|
+
scopedContext.executions = new Map(this.executions);
|
|
267
|
+
scopedContext.executionCounter = this.executionCounter;
|
|
268
|
+
scopedContext.nodeExecutionCounts = new Map(this.nodeExecutionCounts);
|
|
269
|
+
return scopedContext;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
mergeScope(scopedContext: GeneratedExecutionContext): void {
|
|
273
|
+
scopedContext.executions.forEach((info, key) => {
|
|
274
|
+
this.executions.set(key, info);
|
|
275
|
+
});
|
|
276
|
+
scopedContext.variables.forEach((value, key) => {
|
|
277
|
+
this.variables.set(key, value);
|
|
278
|
+
});
|
|
279
|
+
this.executionCounter = Math.max(this.executionCounter, scopedContext.executionCounter);
|
|
280
|
+
scopedContext.nodeExecutionCounts.forEach((count, id) => {
|
|
281
|
+
const currentCount = this.nodeExecutionCounts.get(id) || 0;
|
|
282
|
+
this.nodeExecutionCounts.set(id, Math.max(currentCount, count));
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
private getVariableKey(address: VariableAddress): string {
|
|
287
|
+
return `${address.id}:${address.portName}:${address.executionIndex}`;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private getExecutionKey(id: string, index: number): string {
|
|
291
|
+
return `${id}:${index}`;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
getExecutionCount(): number {
|
|
295
|
+
return this.executionCounter;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
reset(): void {
|
|
299
|
+
this.variables.clear();
|
|
300
|
+
this.executions.clear();
|
|
301
|
+
this.executionCounter = 0;
|
|
302
|
+
this.nodeExecutionCounts.clear();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
isAborted(): boolean {
|
|
306
|
+
return this.abortSignal?.aborted ?? false;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
checkAborted(nodeId?: string): void {
|
|
310
|
+
if (this.abortSignal?.aborted) {
|
|
311
|
+
throw new CancellationError(
|
|
312
|
+
`Workflow execution cancelled${nodeId ? ` at ${nodeId}` : ''}`,
|
|
313
|
+
this.executionCounter,
|
|
314
|
+
nodeId
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async sendStatusChangedEvent(args: {
|
|
320
|
+
nodeTypeName: string;
|
|
321
|
+
id: string;
|
|
322
|
+
scope?: string;
|
|
323
|
+
side?: "start" | "exit";
|
|
324
|
+
executionIndex: number;
|
|
325
|
+
status: TStatusType;
|
|
326
|
+
}): Promise<void> {
|
|
327
|
+
if (this.flowWeaverDebugger) {
|
|
328
|
+
await this.flowWeaverDebugger.sendEvent({
|
|
329
|
+
type: "STATUS_CHANGED",
|
|
330
|
+
...args,
|
|
331
|
+
innerFlowInvocation: this.flowWeaverDebugger.innerFlowInvocation,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
private async sendVariableSetEvent(args: {
|
|
337
|
+
identifier: TVariableIdentification;
|
|
338
|
+
value: unknown;
|
|
339
|
+
}): Promise<void> {
|
|
340
|
+
if (this.flowWeaverDebugger) {
|
|
341
|
+
await this.flowWeaverDebugger.sendEvent({
|
|
342
|
+
type: "VARIABLE_SET",
|
|
343
|
+
...args,
|
|
344
|
+
innerFlowInvocation: this.flowWeaverDebugger.innerFlowInvocation,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
async sendLogErrorEvent(args: {
|
|
350
|
+
nodeTypeName: string;
|
|
351
|
+
id: string;
|
|
352
|
+
scope?: string;
|
|
353
|
+
side?: "start" | "exit";
|
|
354
|
+
executionIndex: number;
|
|
355
|
+
error: string;
|
|
356
|
+
}): Promise<void> {
|
|
357
|
+
if (this.flowWeaverDebugger) {
|
|
358
|
+
await this.flowWeaverDebugger.sendEvent({
|
|
359
|
+
type: "LOG_ERROR",
|
|
360
|
+
...args,
|
|
361
|
+
innerFlowInvocation: this.flowWeaverDebugger.innerFlowInvocation,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
async sendWorkflowCompletedEvent(args: {
|
|
367
|
+
executionIndex: number;
|
|
368
|
+
status: "SUCCEEDED" | "FAILED" | "CANCELLED";
|
|
369
|
+
result?: unknown;
|
|
370
|
+
}): Promise<void> {
|
|
371
|
+
if (this.flowWeaverDebugger) {
|
|
372
|
+
await this.flowWeaverDebugger.sendEvent({
|
|
373
|
+
type: "WORKFLOW_COMPLETED",
|
|
374
|
+
...args,
|
|
375
|
+
innerFlowInvocation: this.flowWeaverDebugger.innerFlowInvocation,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
serialize(): {
|
|
381
|
+
variables: Record<string, unknown>;
|
|
382
|
+
executions: Record<string, ExecutionInfo>;
|
|
383
|
+
executionCounter: number;
|
|
384
|
+
nodeExecutionCounts: Record<string, number>;
|
|
385
|
+
} {
|
|
386
|
+
const vars: Record<string, unknown> = {};
|
|
387
|
+
for (const [key, value] of this.variables) {
|
|
388
|
+
if (typeof value === "function") {
|
|
389
|
+
try { vars[key] = (value as () => unknown)(); } catch { vars[key] = value; }
|
|
390
|
+
} else {
|
|
391
|
+
vars[key] = value;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const execs: Record<string, ExecutionInfo> = {};
|
|
395
|
+
for (const [key, info] of this.executions) { execs[key] = { ...info }; }
|
|
396
|
+
const nodeCounts: Record<string, number> = {};
|
|
397
|
+
for (const [key, count] of this.nodeExecutionIndices) { nodeCounts[key] = count; }
|
|
398
|
+
return { variables: vars, executions: execs, executionCounter: this.executionCounter, nodeExecutionCounts: nodeCounts };
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
restore(data: {
|
|
402
|
+
variables: Record<string, unknown>;
|
|
403
|
+
executions: Record<string, ExecutionInfo>;
|
|
404
|
+
executionCounter: number;
|
|
405
|
+
nodeExecutionCounts: Record<string, number>;
|
|
406
|
+
}): void {
|
|
407
|
+
this.variables = new Map(Object.entries(data.variables));
|
|
408
|
+
this.executions = new Map(Object.entries(data.executions));
|
|
409
|
+
this.executionCounter = data.executionCounter;
|
|
410
|
+
this.nodeExecutionIndices = new Map(Object.entries(data.nodeExecutionCounts));
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
22
414
|
// @flow-weaver-runtime-end
|
|
23
415
|
|
|
24
416
|
/**
|
|
25
417
|
* @flowWeaver workflow
|
|
26
418
|
* @node cfg weaverLoadConfig [color: "teal"] [icon: "settings"] [position: 200 200]
|
|
27
|
-
* @node detect weaverDetectProvider [color: "cyan"] [icon: "search"] [
|
|
419
|
+
* @node detect weaverDetectProvider [color: "cyan"] [icon: "search"] [suppress: "OBJECT_TYPE_MISMATCH", "ANNOTATION_SIGNATURE_TYPE_MISMATCH"] [position: 400 200]
|
|
28
420
|
* @node receive weaverReceiveTask [color: "blue"] [icon: "send"] [position: 600 200]
|
|
29
421
|
* @node context weaverBuildContext [color: "teal"] [icon: "code"] [position: 800 200]
|
|
30
422
|
* @node agent weaverAgentExecute [color: "purple"] [icon: "psychology"] [position: 1000 200]
|
|
31
423
|
* @node gitOps weaverGitOps [color: "green"] [icon: "code"] [position: 1200 100]
|
|
32
|
-
* @node notify weaverSendNotify [color: "yellow"] [icon: "send"] [
|
|
33
|
-
* @node report weaverBotReport [color: "green"] [icon: "description"] [
|
|
424
|
+
* @node notify weaverSendNotify [color: "yellow"] [icon: "send"] [suppress: "UNUSED_OUTPUT_PORT"] [position: 1200 300]
|
|
425
|
+
* @node report weaverBotReport [color: "green"] [icon: "description"] [suppress: "UNUSED_OUTPUT_PORT", "DESIGN_ASYNC_NO_ERROR_PATH"] [position: 1400 200]
|
|
34
426
|
* @path Start -> cfg -> detect -> receive -> context -> agent -> gitOps -> report -> Exit
|
|
35
427
|
* @path agent -> notify
|
|
36
428
|
* @path receive:fail -> report
|
|
@@ -94,11 +486,14 @@ export async function weaverAgent(
|
|
|
94
486
|
let gitOpsIdx: number | undefined;
|
|
95
487
|
let notifyIdx: number | undefined;
|
|
96
488
|
let reportIdx: number | undefined;
|
|
97
|
-
|
|
489
|
+
let notify_success = false;
|
|
98
490
|
let cfg_success = false;
|
|
99
491
|
let detect_success = false;
|
|
100
492
|
let receive_success = false;
|
|
101
493
|
let context_success = false;
|
|
494
|
+
let agent_success = false;
|
|
495
|
+
let gitOps_success = false;
|
|
496
|
+
|
|
102
497
|
|
|
103
498
|
if (await __ctrl__.beforeNode('cfg', ctx)) {
|
|
104
499
|
|
|
@@ -298,7 +693,9 @@ export async function weaverAgent(
|
|
|
298
693
|
await ctx.setVariable({ id: 'receive', portName: 'env', executionIndex: receiveIdx, nodeTypeName: 'weaverReceiveTask' }, receive_env);
|
|
299
694
|
const receive_taskJson = await ctx.getVariable({ id: 'Start', portName: 'taskJson', executionIndex: startIdx }) as string;
|
|
300
695
|
await ctx.setVariable({ id: 'receive', portName: 'taskJson', executionIndex: receiveIdx, nodeTypeName: 'weaverReceiveTask' }, receive_taskJson);
|
|
301
|
-
const
|
|
696
|
+
const receive_frozenPromptPrefix = undefined;
|
|
697
|
+
await ctx.setVariable({ id: 'receive', portName: 'frozenPromptPrefix', executionIndex: receiveIdx, nodeTypeName: 'weaverReceiveTask' }, receive_frozenPromptPrefix);
|
|
698
|
+
const receiveResult = await weaverReceiveTask(receive_execute, receive_env, receive_taskJson, receive_frozenPromptPrefix);
|
|
302
699
|
await ctx.setVariable({ id: 'receive', portName: 'ctx', executionIndex: receiveIdx, nodeTypeName: 'weaverReceiveTask' }, receiveResult.ctx);
|
|
303
700
|
await ctx.setVariable({ id: 'receive', portName: 'onSuccess', executionIndex: receiveIdx, nodeTypeName: 'weaverReceiveTask' }, receiveResult.onSuccess);
|
|
304
701
|
await ctx.setVariable({ id: 'receive', portName: 'onFailure', executionIndex: receiveIdx, nodeTypeName: 'weaverReceiveTask' }, receiveResult.onFailure);
|
|
@@ -400,14 +797,14 @@ export async function weaverAgent(
|
|
|
400
797
|
context_success = false;
|
|
401
798
|
|
|
402
799
|
try {
|
|
403
|
-
await ctx.
|
|
800
|
+
const context_execute = receiveIdx !== undefined ? await ctx.getVariable({ id: 'receive', portName: 'onSuccess', executionIndex: receiveIdx }) as boolean : false;
|
|
801
|
+
await ctx.setVariable({ id: 'context', portName: 'execute', executionIndex: contextIdx, nodeTypeName: 'weaverBuildContext' }, context_execute);
|
|
404
802
|
const context_ctx = await ctx.getVariable({ id: 'receive', portName: 'ctx', executionIndex: receiveIdx! }) as string;
|
|
405
803
|
await ctx.setVariable({ id: 'context', portName: 'ctx', executionIndex: contextIdx, nodeTypeName: 'weaverBuildContext' }, context_ctx);
|
|
406
|
-
const contextResult = weaverBuildContext(context_ctx);
|
|
407
|
-
|
|
408
|
-
await ctx.setVariable({ id: 'context', portName: '
|
|
409
|
-
await ctx.setVariable({ id: 'context', portName: 'onSuccess', executionIndex: contextIdx, nodeTypeName: 'weaverBuildContext' },
|
|
410
|
-
await ctx.setVariable({ id: 'context', portName: 'onFailure', executionIndex: contextIdx, nodeTypeName: 'weaverBuildContext' }, false);
|
|
804
|
+
const contextResult = await weaverBuildContext(context_execute, context_ctx);
|
|
805
|
+
await ctx.setVariable({ id: 'context', portName: 'ctx', executionIndex: contextIdx, nodeTypeName: 'weaverBuildContext' }, contextResult.ctx);
|
|
806
|
+
await ctx.setVariable({ id: 'context', portName: 'onFailure', executionIndex: contextIdx, nodeTypeName: 'weaverBuildContext' }, contextResult.onFailure);
|
|
807
|
+
await ctx.setVariable({ id: 'context', portName: 'onSuccess', executionIndex: contextIdx, nodeTypeName: 'weaverBuildContext' }, contextResult.onSuccess);
|
|
411
808
|
await ctx.sendStatusChangedEvent({
|
|
412
809
|
nodeTypeName: 'weaverBuildContext',
|
|
413
810
|
id: 'context',
|
|
@@ -415,7 +812,7 @@ export async function weaverAgent(
|
|
|
415
812
|
status: 'SUCCEEDED',
|
|
416
813
|
});
|
|
417
814
|
await __ctrl__.afterNode('context', ctx);
|
|
418
|
-
context_success =
|
|
815
|
+
context_success = contextResult.onSuccess;
|
|
419
816
|
} catch (error: unknown) {
|
|
420
817
|
const isCancellation = CancellationError.isCancellationError(error);
|
|
421
818
|
await ctx.sendStatusChangedEvent({
|
|
@@ -481,7 +878,6 @@ export async function weaverAgent(
|
|
|
481
878
|
});
|
|
482
879
|
}
|
|
483
880
|
if (cfg_success && detect_success && receive_success && context_success) {
|
|
484
|
-
let agent_success = false;
|
|
485
881
|
if (await __ctrl__.beforeNode('agent', ctx)) {
|
|
486
882
|
|
|
487
883
|
// ── agent (weaverAgentExecute) ──
|
|
@@ -502,7 +898,9 @@ export async function weaverAgent(
|
|
|
502
898
|
await ctx.setVariable({ id: 'agent', portName: 'execute', executionIndex: agentIdx, nodeTypeName: 'weaverAgentExecute' }, agent_execute);
|
|
503
899
|
const agent_ctx = await ctx.getVariable({ id: 'context', portName: 'ctx', executionIndex: contextIdx! }) as string;
|
|
504
900
|
await ctx.setVariable({ id: 'agent', portName: 'ctx', executionIndex: agentIdx, nodeTypeName: 'weaverAgentExecute' }, agent_ctx);
|
|
505
|
-
const
|
|
901
|
+
const agent_modelOverride = undefined;
|
|
902
|
+
await ctx.setVariable({ id: 'agent', portName: 'modelOverride', executionIndex: agentIdx, nodeTypeName: 'weaverAgentExecute' }, agent_modelOverride);
|
|
903
|
+
const agentResult = await weaverAgentExecute(agent_execute, agent_ctx, agent_modelOverride);
|
|
506
904
|
await ctx.setVariable({ id: 'agent', portName: 'ctx', executionIndex: agentIdx, nodeTypeName: 'weaverAgentExecute' }, agentResult.ctx);
|
|
507
905
|
await ctx.setVariable({ id: 'agent', portName: 'onSuccess', executionIndex: agentIdx, nodeTypeName: 'weaverAgentExecute' }, agentResult.onSuccess);
|
|
508
906
|
await ctx.setVariable({ id: 'agent', portName: 'onFailure', executionIndex: agentIdx, nodeTypeName: 'weaverAgentExecute' }, agentResult.onFailure);
|
|
@@ -572,6 +970,8 @@ export async function weaverAgent(
|
|
|
572
970
|
status: 'RUNNING',
|
|
573
971
|
});
|
|
574
972
|
|
|
973
|
+
gitOps_success = false;
|
|
974
|
+
|
|
575
975
|
try {
|
|
576
976
|
await ctx.setVariable({ id: 'gitOps', portName: 'execute', executionIndex: gitOpsIdx, nodeTypeName: 'weaverGitOps' }, true);
|
|
577
977
|
const gitOps_ctx = await ctx.getVariable({ id: 'agent', portName: 'ctx', executionIndex: agentIdx! }) as string;
|
|
@@ -588,6 +988,7 @@ export async function weaverAgent(
|
|
|
588
988
|
status: 'SUCCEEDED',
|
|
589
989
|
});
|
|
590
990
|
await __ctrl__.afterNode('gitOps', ctx);
|
|
991
|
+
gitOps_success = true;
|
|
591
992
|
} catch (error: unknown) {
|
|
592
993
|
const isCancellation = CancellationError.isCancellationError(error);
|
|
593
994
|
await ctx.sendStatusChangedEvent({
|
|
@@ -605,11 +1006,13 @@ export async function weaverAgent(
|
|
|
605
1006
|
});
|
|
606
1007
|
await ctx.setVariable({ id: 'gitOps', portName: 'onSuccess', executionIndex: gitOpsIdx, nodeTypeName: 'weaverGitOps' }, false);
|
|
607
1008
|
await ctx.setVariable({ id: 'gitOps', portName: 'onFailure', executionIndex: gitOpsIdx, nodeTypeName: 'weaverGitOps' }, true);
|
|
1009
|
+
gitOps_success = false;
|
|
608
1010
|
}
|
|
609
1011
|
throw error;
|
|
610
1012
|
}
|
|
611
1013
|
} else {
|
|
612
1014
|
gitOpsIdx = ctx.addExecution('gitOps');
|
|
1015
|
+
gitOps_success = true;
|
|
613
1016
|
}
|
|
614
1017
|
|
|
615
1018
|
if (await __ctrl__.beforeNode('notify', ctx)) {
|
|
@@ -625,6 +1028,8 @@ export async function weaverAgent(
|
|
|
625
1028
|
status: 'RUNNING',
|
|
626
1029
|
});
|
|
627
1030
|
|
|
1031
|
+
notify_success = false;
|
|
1032
|
+
|
|
628
1033
|
try {
|
|
629
1034
|
await ctx.setVariable({ id: 'notify', portName: 'execute', executionIndex: notifyIdx, nodeTypeName: 'weaverSendNotify' }, true);
|
|
630
1035
|
const notify_ctx = await ctx.getVariable({ id: 'agent', portName: 'ctx', executionIndex: agentIdx! }) as string;
|
|
@@ -641,6 +1046,7 @@ export async function weaverAgent(
|
|
|
641
1046
|
status: 'SUCCEEDED',
|
|
642
1047
|
});
|
|
643
1048
|
await __ctrl__.afterNode('notify', ctx);
|
|
1049
|
+
notify_success = true;
|
|
644
1050
|
} catch (error: unknown) {
|
|
645
1051
|
const isCancellation = CancellationError.isCancellationError(error);
|
|
646
1052
|
await ctx.sendStatusChangedEvent({
|
|
@@ -658,11 +1064,13 @@ export async function weaverAgent(
|
|
|
658
1064
|
});
|
|
659
1065
|
await ctx.setVariable({ id: 'notify', portName: 'onSuccess', executionIndex: notifyIdx, nodeTypeName: 'weaverSendNotify' }, false);
|
|
660
1066
|
await ctx.setVariable({ id: 'notify', portName: 'onFailure', executionIndex: notifyIdx, nodeTypeName: 'weaverSendNotify' }, true);
|
|
1067
|
+
notify_success = false;
|
|
661
1068
|
}
|
|
662
1069
|
throw error;
|
|
663
1070
|
}
|
|
664
1071
|
} else {
|
|
665
1072
|
notifyIdx = ctx.addExecution('notify');
|
|
1073
|
+
notify_success = true;
|
|
666
1074
|
}
|
|
667
1075
|
|
|
668
1076
|
} else {
|
|
@@ -728,7 +1136,7 @@ export async function weaverAgent(
|
|
|
728
1136
|
});
|
|
729
1137
|
|
|
730
1138
|
try {
|
|
731
|
-
const report_execute = (notifyIdx !== undefined ? await ctx.getVariable({ id: 'notify', portName: 'onSuccess', executionIndex: notifyIdx }) as boolean : false) || (gitOpsIdx !== undefined ? await ctx.getVariable({ id: 'gitOps', portName: 'onSuccess', executionIndex: gitOpsIdx }) as boolean : false);
|
|
1139
|
+
const report_execute = (notifyIdx !== undefined ? await ctx.getVariable({ id: 'notify', portName: 'onSuccess', executionIndex: notifyIdx }) as boolean : false) || (gitOpsIdx !== undefined ? await ctx.getVariable({ id: 'gitOps', portName: 'onSuccess', executionIndex: gitOpsIdx }) as boolean : false) || (receiveIdx !== undefined ? await ctx.getVariable({ id: 'receive', portName: 'onFailure', executionIndex: receiveIdx }) as boolean : false) || (agentIdx !== undefined ? await ctx.getVariable({ id: 'agent', portName: 'onFailure', executionIndex: agentIdx }) as boolean : false);
|
|
732
1140
|
await ctx.setVariable({ id: 'report', portName: 'execute', executionIndex: reportIdx, nodeTypeName: 'weaverBotReport' }, report_execute);
|
|
733
1141
|
const report_mainCtx = gitOpsIdx !== undefined ? await ctx.getVariable({ id: 'gitOps', portName: 'ctx', executionIndex: gitOpsIdx }) as string : undefined;
|
|
734
1142
|
await ctx.setVariable({ id: 'report', portName: 'mainCtx', executionIndex: reportIdx, nodeTypeName: 'weaverBotReport' }, report_mainCtx);
|
|
@@ -736,8 +1144,11 @@ export async function weaverAgent(
|
|
|
736
1144
|
await ctx.setVariable({ id: 'report', portName: 'readCtx', executionIndex: reportIdx, nodeTypeName: 'weaverBotReport' }, report_readCtx);
|
|
737
1145
|
const report_abortCtx = undefined;
|
|
738
1146
|
await ctx.setVariable({ id: 'report', portName: 'abortCtx', executionIndex: reportIdx, nodeTypeName: 'weaverBotReport' }, report_abortCtx);
|
|
739
|
-
const
|
|
1147
|
+
const report_failCtx = undefined;
|
|
1148
|
+
await ctx.setVariable({ id: 'report', portName: 'failCtx', executionIndex: reportIdx, nodeTypeName: 'weaverBotReport' }, report_failCtx);
|
|
1149
|
+
const reportResult = await weaverBotReport(report_execute, report_mainCtx, report_readCtx, report_abortCtx, report_failCtx);
|
|
740
1150
|
await ctx.setVariable({ id: 'report', portName: 'summary', executionIndex: reportIdx, nodeTypeName: 'weaverBotReport' }, reportResult.summary);
|
|
1151
|
+
await ctx.setVariable({ id: 'report', portName: 'report', executionIndex: reportIdx, nodeTypeName: 'weaverBotReport' }, reportResult.report);
|
|
741
1152
|
await ctx.setVariable({ id: 'report', portName: 'reportJson', executionIndex: reportIdx, nodeTypeName: 'weaverBotReport' }, reportResult.reportJson);
|
|
742
1153
|
await ctx.setVariable({ id: 'report', portName: 'onFailure', executionIndex: reportIdx, nodeTypeName: 'weaverBotReport' }, reportResult.onFailure);
|
|
743
1154
|
await ctx.setVariable({ id: 'report', portName: 'onSuccess', executionIndex: reportIdx, nodeTypeName: 'weaverBotReport' }, reportResult.onSuccess);
|