@synergenius/flow-weaver 0.17.6 → 0.17.8

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.
Files changed (52) hide show
  1. package/dist/api/parse.d.ts +5 -0
  2. package/dist/api/parse.js +4 -0
  3. package/dist/ast/types.d.ts +2 -0
  4. package/dist/cli/commands/compile.js +2 -1
  5. package/dist/cli/commands/init.js +15 -9
  6. package/dist/cli/commands/validate.js +1 -1
  7. package/dist/cli/exports.d.ts +17 -0
  8. package/dist/cli/exports.js +23 -0
  9. package/dist/cli/flow-weaver.mjs +59021 -62127
  10. package/dist/cli/templates/index.js +8 -1
  11. package/dist/extensions/index.d.ts +10 -6
  12. package/dist/extensions/index.js +11 -6
  13. package/dist/generated-version.d.ts +1 -1
  14. package/dist/generated-version.js +1 -1
  15. package/dist/generator/index.d.ts +11 -0
  16. package/dist/generator/index.js +11 -0
  17. package/dist/parser.d.ts +7 -0
  18. package/dist/parser.js +29 -0
  19. package/package.json +11 -7
  20. package/dist/extensions/cicd/base-target.d.ts +0 -110
  21. package/dist/extensions/cicd/base-target.js +0 -397
  22. package/dist/extensions/cicd/detection.d.ts +0 -33
  23. package/dist/extensions/cicd/detection.js +0 -88
  24. package/dist/extensions/cicd/docs/cicd.md +0 -395
  25. package/dist/extensions/cicd/index.d.ts +0 -15
  26. package/dist/extensions/cicd/index.js +0 -15
  27. package/dist/extensions/cicd/register.d.ts +0 -11
  28. package/dist/extensions/cicd/register.js +0 -62
  29. package/dist/extensions/cicd/rules.d.ts +0 -30
  30. package/dist/extensions/cicd/rules.js +0 -288
  31. package/dist/extensions/cicd/tag-handler.d.ts +0 -14
  32. package/dist/extensions/cicd/tag-handler.js +0 -504
  33. package/dist/extensions/cicd/templates/cicd-docker.d.ts +0 -9
  34. package/dist/extensions/cicd/templates/cicd-docker.js +0 -110
  35. package/dist/extensions/cicd/templates/cicd-matrix.d.ts +0 -9
  36. package/dist/extensions/cicd/templates/cicd-matrix.js +0 -112
  37. package/dist/extensions/cicd/templates/cicd-multi-env.d.ts +0 -9
  38. package/dist/extensions/cicd/templates/cicd-multi-env.js +0 -126
  39. package/dist/extensions/cicd/templates/cicd-test-deploy.d.ts +0 -11
  40. package/dist/extensions/cicd/templates/cicd-test-deploy.js +0 -156
  41. package/dist/extensions/inngest/dev-mode.d.ts +0 -9
  42. package/dist/extensions/inngest/dev-mode.js +0 -213
  43. package/dist/extensions/inngest/generator.d.ts +0 -53
  44. package/dist/extensions/inngest/generator.js +0 -1176
  45. package/dist/extensions/inngest/index.d.ts +0 -2
  46. package/dist/extensions/inngest/index.js +0 -2
  47. package/dist/extensions/inngest/register.d.ts +0 -6
  48. package/dist/extensions/inngest/register.js +0 -23
  49. package/dist/extensions/inngest/templates/ai-agent-durable.d.ts +0 -8
  50. package/dist/extensions/inngest/templates/ai-agent-durable.js +0 -334
  51. package/dist/extensions/inngest/templates/ai-pipeline-durable.d.ts +0 -8
  52. package/dist/extensions/inngest/templates/ai-pipeline-durable.js +0 -326
@@ -1,2 +0,0 @@
1
- export { generateInngestFunction, type InngestGenerationOptions } from './generator.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +0,0 @@
1
- export { generateInngestFunction } from './generator.js';
2
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- /**
2
- * Inngest extension self-registration module.
3
- * Loaded as a side-effect import from src/extensions/index.ts.
4
- */
5
- export {};
6
- //# sourceMappingURL=register.d.ts.map
@@ -1,23 +0,0 @@
1
- /**
2
- * Inngest extension self-registration module.
3
- * Loaded as a side-effect import from src/extensions/index.ts.
4
- */
5
- import { compileTargetRegistry } from '../../generator/compile-target-registry.js';
6
- import { devModeRegistry } from '../../generator/dev-mode-registry.js';
7
- import { registerWorkflowTemplates } from '../../cli/templates/index.js';
8
- import { generateInngestFunction } from './generator.js';
9
- import { runInngestDevMode } from './dev-mode.js';
10
- import { aiAgentDurableTemplate } from './templates/ai-agent-durable.js';
11
- import { aiPipelineDurableTemplate } from './templates/ai-pipeline-durable.js';
12
- compileTargetRegistry.register({
13
- name: 'inngest',
14
- compile(workflow, nodeTypes, options) {
15
- return generateInngestFunction(workflow, nodeTypes, options);
16
- },
17
- });
18
- devModeRegistry.register({
19
- name: 'inngest',
20
- run: runInngestDevMode,
21
- });
22
- registerWorkflowTemplates([aiAgentDurableTemplate, aiPipelineDurableTemplate]);
23
- //# sourceMappingURL=register.js.map
@@ -1,8 +0,0 @@
1
- /**
2
- * Durable AI Agent Template
3
- * Linear agent pipeline with durability annotations.
4
- * Each node maps to a checkpointed step when compiled to a durable target.
5
- */
6
- import type { WorkflowTemplate } from '../../../cli/templates/index.js';
7
- export declare const aiAgentDurableTemplate: WorkflowTemplate;
8
- //# sourceMappingURL=ai-agent-durable.d.ts.map
@@ -1,334 +0,0 @@
1
- import { getProviderCode } from '../../../cli/templates/providers/index.js';
2
- import { aiConfigSchema } from '../../../cli/templates/workflows/ai-agent.js';
3
- import { LLM_CORE_TYPES, LLM_MOCK_PROVIDER_WITH_TOOLS } from '../../../cli/templates/shared/llm-types.js';
4
- export const aiAgentDurableTemplate = {
5
- id: 'ai-agent-durable',
6
- name: 'Durable AI Agent',
7
- description: 'Linear agent pipeline with durability — classify, tools, approval, respond',
8
- category: 'ai',
9
- configSchema: aiConfigSchema,
10
- generate: ({ workflowName, config }) => {
11
- const provider = config?.provider || 'mock';
12
- const model = config?.model || '';
13
- const providerCode = provider === 'mock'
14
- ? `
15
- /* ============================================================
16
- * MOCK PROVIDER (REPLACE IN REAL USE)
17
- * ============================================================ */
18
-
19
- ${LLM_MOCK_PROVIDER_WITH_TOOLS}
20
- `
21
- : getProviderCode(provider, model);
22
- return `
23
- // ============================================================
24
- // Durable AI Agent
25
- // ============================================================
26
- //
27
- // Each node becomes a checkpointed step when compiled to a durable target.
28
- // If a step fails, it retries from that step, not from scratch.
29
- //
30
- // Compile: flow-weaver compile <file>
31
- // Export: fw export --target <target>
32
- //
33
- // Flow: classify → executeTool → requestApproval → respond
34
-
35
- /* ============================================================
36
- * CORE TYPES
37
- * ============================================================ */
38
-
39
- ${LLM_CORE_TYPES}
40
-
41
- /* ============================================================
42
- * TOOL DEFINITIONS
43
- * ============================================================ */
44
-
45
- type ToolResult =
46
- | { ok: true; value: string }
47
- | { ok: false; error: string };
48
-
49
- type ToolFn = (args: Record<string, unknown>) => Promise<ToolResult>;
50
-
51
- const AVAILABLE_TOOLS: LLMTool[] = [
52
- {
53
- name: 'search',
54
- description: 'Search for information',
55
- parameters: {
56
- type: 'object',
57
- properties: {
58
- query: { type: 'string' },
59
- },
60
- required: ['query'],
61
- },
62
- },
63
- ];
64
-
65
- const TOOL_IMPLEMENTATIONS: Record<string, ToolFn> = {
66
- async search(args) {
67
- if (typeof args.query !== 'string') {
68
- return { ok: false, error: 'Invalid query' };
69
- }
70
- return { ok: true, value: '[Search results for: ' + args.query + ']' };
71
- },
72
- };
73
-
74
- /* ============================================================
75
- * APPROVAL BACKEND (mock — replace with real backend)
76
- * ============================================================
77
- *
78
- * On durable targets, this node compiles to a platform-native wait primitive.
79
- * The function pauses (zero compute cost) until an approval event arrives.
80
- */
81
-
82
- interface ApprovalResult {
83
- approved: boolean;
84
- response: string;
85
- reviewer: string;
86
- }
87
-
88
- async function requestApproval(prompt: string, context?: Record<string, unknown>): Promise<ApprovalResult> {
89
- console.log('[Mock Approval] Auto-approving:', prompt);
90
- return { approved: true, response: 'Auto-approved (mock)', reviewer: 'system' };
91
- }
92
-
93
- ${providerCode}
94
-
95
- const SYSTEM_PROMPT = \`You are a helpful AI assistant with access to tools.
96
- Use tools when necessary. Respond directly when the task is complete.\`;
97
-
98
- /* ============================================================
99
- * NODES
100
- * ============================================================ */
101
-
102
- /**
103
- * Classify the user's request and determine if tools are needed
104
- *
105
- * @flowWeaver nodeType
106
- * @label Classify
107
- * @color purple
108
- * @icon psychology
109
- * @input execute [order:0] - Execute
110
- * @input userMessage [order:1] - User's input message
111
- * @output onSuccess [order:0] - On Success
112
- * @output onFailure [order:1] - On Failure
113
- * @output content [order:2] - LLM response text
114
- * @output toolCalls [order:3] - Tool calls requested by LLM
115
- * @output hasToolCalls [order:4] - Whether LLM wants to call tools
116
- * @output messages [order:5] - Updated conversation messages
117
- */
118
- async function classify(
119
- execute: boolean,
120
- userMessage: string
121
- ): Promise<{
122
- onSuccess: boolean;
123
- onFailure: boolean;
124
- content: string | null;
125
- toolCalls: LLMToolCall[];
126
- hasToolCalls: boolean;
127
- messages: LLMMessage[];
128
- }> {
129
- if (!execute) {
130
- return { onSuccess: false, onFailure: false, content: null, toolCalls: [], hasToolCalls: false, messages: [] };
131
- }
132
-
133
- try {
134
- const messages: LLMMessage[] = [{ role: 'user', content: userMessage }];
135
- const response = await llmProvider.chat(messages, {
136
- tools: AVAILABLE_TOOLS,
137
- systemPrompt: SYSTEM_PROMPT,
138
- });
139
-
140
- return {
141
- onSuccess: true,
142
- onFailure: false,
143
- content: response.content,
144
- toolCalls: response.toolCalls,
145
- hasToolCalls: response.toolCalls.length > 0,
146
- messages: [
147
- ...messages,
148
- { role: 'assistant', content: response.content || '' },
149
- ],
150
- };
151
- } catch {
152
- return { onSuccess: false, onFailure: true, content: null, toolCalls: [], hasToolCalls: false, messages: [] };
153
- }
154
- }
155
-
156
- /**
157
- * Execute tool calls from the LLM response
158
- *
159
- * @flowWeaver nodeType
160
- * @label Execute Tools
161
- * @color cyan
162
- * @icon build
163
- * @input execute [order:0] - Execute
164
- * @input toolCalls [order:1] - Tool calls to execute
165
- * @output onSuccess [order:0] - On Success
166
- * @output onFailure [order:1] - On Failure
167
- * @output results [order:2] - Tool execution results as messages
168
- */
169
- async function executeTool(
170
- execute: boolean,
171
- toolCalls: LLMToolCall[]
172
- ): Promise<{
173
- onSuccess: boolean;
174
- onFailure: boolean;
175
- results: LLMMessage[];
176
- }> {
177
- if (!execute || !toolCalls || toolCalls.length === 0) {
178
- return { onSuccess: true, onFailure: false, results: [] };
179
- }
180
-
181
- const results: LLMMessage[] = [];
182
-
183
- for (const call of toolCalls) {
184
- const impl = TOOL_IMPLEMENTATIONS[call.name];
185
- if (!impl) {
186
- results.push({ role: 'tool', content: 'Unknown tool: ' + call.name, toolCallId: call.id });
187
- continue;
188
- }
189
-
190
- const result = await impl(call.arguments);
191
- results.push({
192
- role: 'tool',
193
- content: result.ok ? result.value : 'Error: ' + result.error,
194
- toolCallId: call.id,
195
- });
196
- }
197
-
198
- return { onSuccess: true, onFailure: false, results };
199
- }
200
-
201
- /**
202
- * Request human approval before proceeding
203
- *
204
- * @flowWeaver nodeType
205
- * @label Request Approval
206
- * @color orange
207
- * @icon verified
208
- * @input execute [order:0] - Execute
209
- * @input toolResults [order:1] - Tool results to review
210
- * @output onSuccess [order:0] - On Success
211
- * @output onFailure [order:1] - On Failure (rejected or timeout)
212
- * @output approved [order:2] - Whether the request was approved
213
- */
214
- async function approvalGate(
215
- execute: boolean,
216
- toolResults: LLMMessage[]
217
- ): Promise<{
218
- onSuccess: boolean;
219
- onFailure: boolean;
220
- approved: boolean;
221
- }> {
222
- if (!execute) {
223
- return { onSuccess: false, onFailure: false, approved: false };
224
- }
225
-
226
- try {
227
- const summary = toolResults.map((m) => m.content).join('; ');
228
- const result = await requestApproval(
229
- 'Review tool execution results before responding to user',
230
- { toolResults: summary }
231
- );
232
-
233
- if (!result.approved) {
234
- return { onSuccess: false, onFailure: true, approved: false };
235
- }
236
-
237
- return { onSuccess: true, onFailure: false, approved: true };
238
- } catch {
239
- return { onSuccess: false, onFailure: true, approved: false };
240
- }
241
- }
242
-
243
- /**
244
- * Generate the final response incorporating tool results
245
- *
246
- * @flowWeaver nodeType
247
- * @label Respond
248
- * @color purple
249
- * @icon psychology
250
- * @input execute [order:0] - Execute
251
- * @input messages [order:1] - Conversation history including tool results
252
- * @input toolResults [order:2] - Tool result messages to append
253
- * @output onSuccess [order:0] - On Success
254
- * @output onFailure [order:1] - On Failure
255
- * @output response [order:2] - Final response text
256
- */
257
- async function respond(
258
- execute: boolean,
259
- messages: LLMMessage[],
260
- toolResults: LLMMessage[]
261
- ): Promise<{
262
- onSuccess: boolean;
263
- onFailure: boolean;
264
- response: string;
265
- }> {
266
- if (!execute) {
267
- return { onSuccess: false, onFailure: false, response: '' };
268
- }
269
-
270
- try {
271
- const fullMessages = [...messages, ...toolResults];
272
- const result = await llmProvider.chat(fullMessages, {
273
- systemPrompt: SYSTEM_PROMPT,
274
- });
275
-
276
- return {
277
- onSuccess: true,
278
- onFailure: false,
279
- response: result.content || 'No response generated',
280
- };
281
- } catch {
282
- return { onSuccess: false, onFailure: true, response: '' };
283
- }
284
- }
285
-
286
- /* ============================================================
287
- * WORKFLOW
288
- * ============================================================ */
289
-
290
- /**
291
- * Durable AI Agent — linear pipeline with tool calling and human approval.
292
- * Each node becomes a checkpointed step when compiled to a durable target.
293
- *
294
- * @flowWeaver workflow
295
- * @trigger event="agent/request"
296
- * @retries 3
297
- * @node cls classify [position: -280 0]
298
- * @node tools executeTool [position: -40 0]
299
- * @node approval approvalGate [position: 200 0]
300
- * @node resp respond [position: 440 0]
301
- * @position Start -500 0
302
- * @position Exit 680 0
303
- * @connect Start.execute -> cls.execute
304
- * @connect Start.userMessage -> cls.userMessage
305
- * @connect cls.onSuccess -> tools.execute
306
- * @connect cls.toolCalls -> tools.toolCalls
307
- * @connect tools.onSuccess -> approval.execute
308
- * @connect tools.results -> approval.toolResults
309
- * @connect approval.onSuccess -> resp.execute
310
- * @connect cls.messages -> resp.messages
311
- * @connect tools.results -> resp.toolResults
312
- * @connect cls.onFailure -> Exit.onFailure
313
- * @connect resp.onSuccess -> Exit.onSuccess
314
- * @connect resp.response -> Exit.response
315
- * @param execute [order:0] - Execute
316
- * @param userMessage [order:1] - User's message to the agent
317
- * @returns onSuccess [order:0] - Agent completed successfully
318
- * @returns onFailure [order:1] - Agent encountered an error
319
- * @returns response [order:2] - Agent's final response
320
- */
321
- export async function ${workflowName}(
322
- execute: boolean,
323
- params: { userMessage: string }
324
- ): Promise<{
325
- onSuccess: boolean;
326
- onFailure: boolean;
327
- response: string;
328
- }> {
329
- throw new Error('Compile with: flow-weaver compile <file>');
330
- }
331
- `.trim();
332
- },
333
- };
334
- //# sourceMappingURL=ai-agent-durable.js.map
@@ -1,8 +0,0 @@
1
- /**
2
- * Durable AI Pipeline Template
3
- * Sequential data processing pipeline with durability annotations.
4
- * Each node maps to a checkpointed step — if step 3 fails, it retries from step 3, not from scratch.
5
- */
6
- import type { WorkflowTemplate } from '../../../cli/templates/index.js';
7
- export declare const aiPipelineDurableTemplate: WorkflowTemplate;
8
- //# sourceMappingURL=ai-pipeline-durable.d.ts.map