@synergenius/flowweaver-pack-weaver 0.1.0

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 (49) hide show
  1. package/dist/bot/agent-provider.d.ts +24 -0
  2. package/dist/bot/agent-provider.d.ts.map +1 -0
  3. package/dist/bot/agent-provider.js +95 -0
  4. package/dist/bot/agent-provider.js.map +1 -0
  5. package/dist/bot/bot-agent-channel.d.ts +30 -0
  6. package/dist/bot/bot-agent-channel.d.ts.map +1 -0
  7. package/dist/bot/bot-agent-channel.js +44 -0
  8. package/dist/bot/bot-agent-channel.js.map +1 -0
  9. package/dist/bot/cli-provider.d.ts +12 -0
  10. package/dist/bot/cli-provider.d.ts.map +1 -0
  11. package/dist/bot/cli-provider.js +50 -0
  12. package/dist/bot/cli-provider.js.map +1 -0
  13. package/dist/bot/index.d.ts +11 -0
  14. package/dist/bot/index.d.ts.map +1 -0
  15. package/dist/bot/index.js +7 -0
  16. package/dist/bot/index.js.map +1 -0
  17. package/dist/bot/notifications.d.ts +18 -0
  18. package/dist/bot/notifications.d.ts.map +1 -0
  19. package/dist/bot/notifications.js +144 -0
  20. package/dist/bot/notifications.js.map +1 -0
  21. package/dist/bot/runner.d.ts +8 -0
  22. package/dist/bot/runner.d.ts.map +1 -0
  23. package/dist/bot/runner.js +123 -0
  24. package/dist/bot/runner.js.map +1 -0
  25. package/dist/bot/system-prompt.d.ts +6 -0
  26. package/dist/bot/system-prompt.d.ts.map +1 -0
  27. package/dist/bot/system-prompt.js +161 -0
  28. package/dist/bot/system-prompt.js.map +1 -0
  29. package/dist/bot/types.d.ts +44 -0
  30. package/dist/bot/types.d.ts.map +1 -0
  31. package/dist/bot/types.js +2 -0
  32. package/dist/bot/types.js.map +1 -0
  33. package/dist/docs/docs/weaver-config.md +141 -0
  34. package/dist/docs/weaver-config.md +141 -0
  35. package/dist/index.d.ts +9 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +9 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/templates/index.d.ts +5 -0
  40. package/dist/templates/index.d.ts.map +1 -0
  41. package/dist/templates/index.js +4 -0
  42. package/dist/templates/index.js.map +1 -0
  43. package/dist/templates/weaver-template.d.ts +11 -0
  44. package/dist/templates/weaver-template.d.ts.map +1 -0
  45. package/dist/templates/weaver-template.js +672 -0
  46. package/dist/templates/weaver-template.js.map +1 -0
  47. package/flowweaver.manifest.json +42 -0
  48. package/package.json +45 -0
  49. package/templates.js +1 -0
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Builds the Weaver expert system prompt from flow-weaver's doc-metadata.
3
+ * This ensures Weaver's knowledge stays in sync with the installed flow-weaver version.
4
+ */
5
+ export declare function buildSystemPrompt(): Promise<string>;
6
+ //# sourceMappingURL=system-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/bot/system-prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyLH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAmBzD"}
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Builds the Weaver expert system prompt from flow-weaver's doc-metadata.
3
+ * This ensures Weaver's knowledge stays in sync with the installed flow-weaver version.
4
+ */
5
+ let cachedPrompt = null;
6
+ function formatAnnotations(annotations) {
7
+ // Group by category, show syntax + description
8
+ const groups = new Map();
9
+ for (const a of annotations) {
10
+ const list = groups.get(a.category) ?? [];
11
+ list.push(a);
12
+ groups.set(a.category, list);
13
+ }
14
+ const lines = [];
15
+ for (const [category, items] of groups) {
16
+ lines.push(`[${category}]`);
17
+ for (const item of items) {
18
+ lines.push(` ${item.syntax} -- ${item.description}`);
19
+ }
20
+ }
21
+ return lines.join('\n');
22
+ }
23
+ function formatModifiers(portMods, nodeMods) {
24
+ const lines = [];
25
+ if (portMods.length > 0) {
26
+ lines.push('Port modifiers (after port name):');
27
+ for (const m of portMods) {
28
+ lines.push(` ${m.syntax} -- ${m.description}`);
29
+ }
30
+ }
31
+ if (nodeMods.length > 0) {
32
+ lines.push('Node instance modifiers (in @node declaration):');
33
+ for (const m of nodeMods) {
34
+ lines.push(` ${m.syntax} -- ${m.description}`);
35
+ }
36
+ }
37
+ return lines.join('\n');
38
+ }
39
+ function formatErrors(codes) {
40
+ const errors = codes.filter((c) => c.severity === 'error').slice(0, 15);
41
+ return errors
42
+ .map((c) => ` ${c.code}: ${c.title} -- ${c.description}`)
43
+ .join('\n');
44
+ }
45
+ function formatCliCommands(commands) {
46
+ const top = commands.filter((c) => !c.group);
47
+ return top
48
+ .map((c) => ` flow-weaver ${c.name} -- ${c.description}`)
49
+ .join('\n');
50
+ }
51
+ function buildPromptFromMetadata(annotations, portModifiers, nodeModifiers, validationCodes, cliCommands) {
52
+ return `You are Weaver, an expert AI companion for Flow Weaver workflows. You have deep knowledge of the entire Flow Weaver ecosystem: annotation grammar, compilation, CLI tools, node patterns, error diagnosis, and the Genesis self-evolution protocol.
53
+
54
+ ## Core Mental Model
55
+
56
+ The code IS the workflow. Flow Weaver workflows are plain TypeScript files with JSDoc annotations above functions. The compiler reads annotations and generates deterministic execution code between @flow-weaver-body-start/end markers. Compiled code is standalone with no runtime dependency on flow-weaver.
57
+
58
+ Three block types:
59
+ - @flowWeaver nodeType: A reusable function (node) with typed inputs/outputs
60
+ - @flowWeaver workflow: A DAG orchestration that wires node instances together
61
+ - @flowWeaver pattern: A reusable fragment with boundary ports (IN/OUT instead of Start/Exit)
62
+
63
+ ## Annotation Grammar
64
+
65
+ ${formatAnnotations(annotations)}
66
+
67
+ ${formatModifiers(portModifiers, nodeModifiers)}
68
+
69
+ ## Node Execution Model
70
+
71
+ Expression nodes (@expression):
72
+ - No execute/onSuccess/onFailure params. Just inputs and return value.
73
+ - throw = failure path, return = success path
74
+ - Synchronous. Use execSync for shell commands.
75
+ - Preferred for deterministic operations.
76
+
77
+ Standard nodes:
78
+ - execute: boolean param gates execution
79
+ - Return { onSuccess: boolean, onFailure: boolean, ...outputs }
80
+ - Can be async for I/O operations
81
+
82
+ Async agent nodes:
83
+ - Use (globalThis as any).__fw_agent_channel__ to pause workflow
84
+ - Call channel.request({ agentId, context, prompt }) which returns a Promise
85
+ - Workflow suspends until agent responds
86
+ - NOT @expression (must be async)
87
+
88
+ Pass-through pattern:
89
+ - FW auto-connects ports by matching names on adjacent nodes
90
+ - To forward data through intermediate nodes, declare it as both @input and @output with the same name
91
+ - For non-adjacent wiring, use @connect sourceNode.port -> targetNode.port
92
+
93
+ Data flow:
94
+ - @path A -> B -> C: Linear execution path (sugar for multiple @connect)
95
+ - @autoConnect: Auto-wire all nodes in declaration order
96
+ - @connect: Explicit port-to-port wiring
97
+ - Merge strategies for fan-in: FIRST, LAST, COLLECT, MERGE, CONCAT
98
+
99
+ ## CLI Commands
100
+
101
+ ${formatCliCommands(cliCommands)}
102
+
103
+ Key workflows:
104
+ flow-weaver compile <file> -- Generate executable code (in-place)
105
+ flow-weaver validate <file> -- Check for errors without compiling
106
+ flow-weaver modify <op> --file <f> -- Structural changes (addNode, removeNode, addConnection, removeConnection)
107
+ flow-weaver implement <file> -- Replace declare stubs with implementations
108
+ flow-weaver diff <a> <b> -- Semantic diff between two workflow versions
109
+ flow-weaver diagram <file> -f ascii-compact -- Generate ASCII diagram
110
+
111
+ ## Validation Errors
112
+
113
+ ${formatErrors(validationCodes)}
114
+
115
+ When you encounter validation errors, suggest the specific fix. Common resolutions:
116
+ - UNKNOWN_NODE_TYPE: Ensure the referenced function has @flowWeaver nodeType annotation
117
+ - MISSING_REQUIRED_INPUT: Add a @connect from a source port or make the input optional with [brackets]
118
+ - UNKNOWN_SOURCE_PORT / UNKNOWN_TARGET_PORT: Check port name spelling in @connect
119
+ - CYCLE_DETECTED: Break the cycle; use scoped iteration (@scope, @map) instead of circular dependencies
120
+
121
+ ## Genesis Protocol
122
+
123
+ Genesis is a 17-step self-evolving workflow engine:
124
+ 1. Load config (.genesis/config.json with intent, focus, constraints, approval thresholds)
125
+ 2. Observe project (fingerprint: files, package.json, git, CI, tests, existing FW workflows)
126
+ 3. Load task workflow (genesis-task.ts)
127
+ 4. Diff fingerprint against last cycle
128
+ 5. Check stabilize mode (3+ rollbacks/rejections = read-only, or explicit flag)
129
+ 6. Wait for agent (YOU decide what evolutions to propose)
130
+ 7. Propose evolution (map your decisions to FwModifyOperation[])
131
+ 8. Validate proposal (budget: max 3 cost units per cycle. addNode=1, removeNode=1, addConnection=1, removeConnection=1, implementNode=2)
132
+ 9. Snapshot current task workflow for rollback
133
+ 10. Apply changes via flow-weaver CLI
134
+ 11. Compile and validate (auto-rollback on failure)
135
+ 12. Diff workflow (semantic diff)
136
+ 13. Check approval threshold (CRITICAL > BREAKING > MINOR > COSMETIC)
137
+ 14. Wait for approval (if impact >= threshold)
138
+ 15. Commit or rollback based on approval
139
+ 16. Update history (.genesis/history.json)
140
+ 17. Report summary
141
+
142
+ When stabilize mode is active, only fix-up operations are allowed: removeNode, removeConnection, implementNode. No new nodes or connections.
143
+
144
+ ## Response Format
145
+
146
+ Return ONLY valid JSON. No markdown, no code fences, no explanation outside the JSON structure. Your response must parse with JSON.parse() directly.`;
147
+ }
148
+ export async function buildSystemPrompt() {
149
+ if (cachedPrompt)
150
+ return cachedPrompt;
151
+ try {
152
+ const docMeta = await import('@synergenius/flow-weaver/doc-metadata');
153
+ cachedPrompt = buildPromptFromMetadata(docMeta.ALL_ANNOTATIONS ?? [], docMeta.PORT_MODIFIERS ?? [], docMeta.NODE_MODIFIERS ?? [], docMeta.VALIDATION_CODES ?? [], docMeta.CLI_COMMANDS ?? []);
154
+ }
155
+ catch {
156
+ // Fallback if doc-metadata not available (e.g., older flow-weaver version)
157
+ cachedPrompt = buildPromptFromMetadata([], [], [], [], []);
158
+ }
159
+ return cachedPrompt;
160
+ }
161
+ //# sourceMappingURL=system-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/bot/system-prompt.ts"],"names":[],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;;;;;;;;;;;;;;;;;;;;;;;EAkC7C,iBAAiB,CAAC,WAAW,CAAC;;;;;;;;;;;;EAY9B,YAAY,CAAC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qJAiCsH,CAAC;AACtJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,IAAI,YAAY;QAAE,OAAO,YAAY,CAAC;IAEtC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,uCAAuC,CAAC,CAAC;QAEtE,YAAY,GAAG,uBAAuB,CACpC,OAAO,CAAC,eAAe,IAAI,EAAE,EAC7B,OAAO,CAAC,cAAc,IAAI,EAAE,EAC5B,OAAO,CAAC,cAAc,IAAI,EAAE,EAC5B,OAAO,CAAC,gBAAgB,IAAI,EAAE,EAC9B,OAAO,CAAC,YAAY,IAAI,EAAE,CAC3B,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,2EAA2E;QAC3E,YAAY,GAAG,uBAAuB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -0,0 +1,44 @@
1
+ export type ProviderName = 'anthropic' | 'claude-cli' | 'copilot-cli';
2
+ export interface BotProviderConfig {
3
+ name: ProviderName;
4
+ model?: string;
5
+ maxTokens?: number;
6
+ }
7
+ export interface BotApprovalConfig {
8
+ mode: 'auto' | 'timeout-auto';
9
+ timeoutSeconds?: number;
10
+ }
11
+ export interface BotNotifyConfig {
12
+ channel: 'discord' | 'slack' | 'webhook';
13
+ url: string;
14
+ events?: NotificationEventType[];
15
+ headers?: Record<string, string>;
16
+ }
17
+ export type NotificationEventType = 'workflow-start' | 'workflow-complete' | 'cycle-start' | 'cycle-complete' | 'approval-needed' | 'error';
18
+ export interface NotificationEvent {
19
+ type: NotificationEventType;
20
+ workflowFile?: string;
21
+ cycle?: number;
22
+ projectDir: string;
23
+ summary?: string;
24
+ proposal?: Record<string, unknown>;
25
+ diff?: Record<string, unknown>;
26
+ outcome?: string;
27
+ error?: string;
28
+ }
29
+ export interface BotConfig {
30
+ provider: 'auto' | ProviderName | BotProviderConfig;
31
+ approval?: 'auto' | 'timeout-auto' | BotApprovalConfig;
32
+ notify?: BotNotifyConfig | BotNotifyConfig[];
33
+ target?: string;
34
+ }
35
+ /** Standalone Weaver config (same schema as BotConfig, used in .weaver.json) */
36
+ export type WeaverConfig = BotConfig;
37
+ export interface WorkflowResult {
38
+ success: boolean;
39
+ summary: string;
40
+ outcome: string;
41
+ functionName?: string;
42
+ executionTime?: number;
43
+ }
44
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bot/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,aAAa,CAAC;AAEtE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,MAAM,qBAAqB,GAC7B,gBAAgB,GAChB,mBAAmB,GACnB,aAAa,GACb,gBAAgB,GAChB,iBAAiB,GACjB,OAAO,CAAC;AAEZ,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,iBAAiB,CAAC;IACpD,QAAQ,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,iBAAiB,CAAC;IACvD,MAAM,CAAC,EAAE,eAAe,GAAG,eAAe,EAAE,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,gFAAgF;AAChF,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;AAErC,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bot/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,141 @@
1
+ # Weaver Configuration Reference
2
+
3
+ Weaver is a Flow Weaver workflow template that runs any other workflow autonomously. It auto-detects AI providers, resolves the target workflow, executes it with an agent channel, and sends notifications.
4
+
5
+ Weaver has deep knowledge of the full flow-weaver ecosystem: annotation grammar, CLI tools, node patterns, error diagnosis, and the genesis protocol (loaded dynamically from `@synergenius/flow-weaver/doc-metadata`).
6
+
7
+ ## Getting started
8
+
9
+ Scaffold via `flow-weaver init` and select the "AI Workflow Runner" use case, or use it programmatically:
10
+
11
+ ```typescript
12
+ import { weaverTemplate } from '@synergenius/flowweaver-pack-weaver/templates';
13
+ const source = weaverTemplate.generate({ projectDir: '.' });
14
+ ```
15
+
16
+ Then compile and run:
17
+
18
+ ```bash
19
+ flow-weaver compile weaver.ts
20
+ tsx weaver.ts
21
+ ```
22
+
23
+ Or run via MCP: `fw_execute_workflow` pointing at the compiled `weaver.ts`.
24
+
25
+ ## .weaver.json
26
+
27
+ Place a `.weaver.json` in your project root to configure the weaver workflow:
28
+
29
+ ```json
30
+ {
31
+ "provider": "auto",
32
+ "target": "scripts/my-pipeline.ts",
33
+ "notify": [
34
+ { "channel": "discord", "url": "https://discord.com/api/webhooks/ID/TOKEN" }
35
+ ]
36
+ }
37
+ ```
38
+
39
+ ## Provider options
40
+
41
+ **Auto-detect** (tries each in order):
42
+ ```json
43
+ { "provider": "auto" }
44
+ ```
45
+
46
+ **Anthropic API** (best quality, requires API key):
47
+ ```json
48
+ { "provider": "anthropic" }
49
+ ```
50
+
51
+ **Claude CLI** (uses your CLI subscription, no API key needed):
52
+ ```json
53
+ { "provider": "claude-cli" }
54
+ ```
55
+
56
+ **GitHub Copilot CLI** (uses your Copilot subscription):
57
+ ```json
58
+ { "provider": "copilot-cli" }
59
+ ```
60
+
61
+ ## Workflow nodes
62
+
63
+ The weaver workflow has 6 nodes, visible and editable in Studio:
64
+
65
+ 1. **Load Config** - Reads `.weaver.json`, falls back to `{ provider: 'auto' }`
66
+ 2. **Detect Provider** - Auto-detects installed CLIs and API keys
67
+ 3. **Resolve Target** - Finds the workflow to run (from config or by scanning)
68
+ 4. **Execute Target** - Runs the target with an AI agent channel
69
+ 5. **Notify Result** - Sends Discord/Slack/webhook notifications
70
+ 6. **Report** - Prints summary to console
71
+
72
+ You can customize any node, add pre/post-processing steps, or insert approval gates in Studio.
73
+
74
+ ## Full .weaver.json reference
75
+
76
+ | Field | Type | Default | Description |
77
+ |-------|------|---------|-------------|
78
+ | `provider` | string or object | `"auto"` | AI provider (see options above) |
79
+ | `target` | string | auto-scan | Path to target workflow file |
80
+ | `approval` | `"auto"` / `"timeout-auto"` / object | `"auto"` | Approval gate behavior |
81
+ | `notify` | array | `[]` | Webhook notification channels |
82
+
83
+ ### Provider (verbose form)
84
+
85
+ | Field | Type | Default | Description |
86
+ |-------|------|---------|-------------|
87
+ | `name` | `"anthropic"` / `"claude-cli"` / `"copilot-cli"` | required | Provider name |
88
+ | `model` | string | `"claude-sonnet-4-6"` | Model to use (Anthropic only) |
89
+ | `maxTokens` | number | `4096` | Max response tokens (Anthropic only) |
90
+
91
+ Shorthand values:
92
+
93
+ - `"anthropic"` requires `ANTHROPIC_API_KEY` env var and `@anthropic-ai/sdk` package
94
+ - `"claude-cli"` uses the Claude Code CLI (`claude -p`), requires Claude CLI installed
95
+ - `"copilot-cli"` uses GitHub Copilot CLI (`copilot -p`), requires Copilot CLI installed
96
+ - `"auto"` auto-detects in order: `ANTHROPIC_API_KEY` > `claude` CLI > `copilot` CLI
97
+
98
+ ### Approval
99
+
100
+ How approval gates are handled.
101
+
102
+ | Field | Type | Default | Description |
103
+ |-------|------|---------|-------------|
104
+ | `mode` | `"auto"` / `"timeout-auto"` | `"auto"` | `auto`: approve immediately. `timeout-auto`: wait, then approve |
105
+ | `timeoutSeconds` | number | `300` | Seconds to wait before auto-approving (timeout-auto only) |
106
+
107
+ ### Notifications
108
+
109
+ Webhook notifications. Array of notification targets. Supports Discord, Slack, and custom webhooks.
110
+
111
+ | Field | Type | Default | Description |
112
+ |-------|------|---------|-------------|
113
+ | `channel` | `"discord"` / `"slack"` / `"webhook"` | required | Notification target |
114
+ | `url` | string | required | Webhook URL |
115
+ | `events` | array | all events | Event types to send: `workflow-start`, `workflow-complete`, `error` |
116
+ | `headers` | object | `{}` | Extra HTTP headers (custom webhooks only) |
117
+
118
+ Discord notifications use rich embeds with color-coded outcomes. Slack uses Block Kit formatting.
119
+
120
+ ## Programmatic usage
121
+
122
+ The pack also exports library functions for building custom runners:
123
+
124
+ ```typescript
125
+ import {
126
+ createProvider,
127
+ detectProvider,
128
+ runWorkflow,
129
+ BotAgentChannel,
130
+ } from '@synergenius/flowweaver-pack-weaver';
131
+
132
+ // Auto-detect and run
133
+ const result = await runWorkflow('path/to/workflow.ts', { verbose: true });
134
+
135
+ // Or build a custom agent channel
136
+ const providerConfig = detectProvider();
137
+ const provider = createProvider(providerConfig);
138
+ const channel = new BotAgentChannel(provider, { ... });
139
+ ```
140
+
141
+ Scheduling is left to the user: cron, GitHub Actions, git hooks, etc.
@@ -0,0 +1,141 @@
1
+ # Weaver Configuration Reference
2
+
3
+ Weaver is a Flow Weaver workflow template that runs any other workflow autonomously. It auto-detects AI providers, resolves the target workflow, executes it with an agent channel, and sends notifications.
4
+
5
+ Weaver has deep knowledge of the full flow-weaver ecosystem: annotation grammar, CLI tools, node patterns, error diagnosis, and the genesis protocol (loaded dynamically from `@synergenius/flow-weaver/doc-metadata`).
6
+
7
+ ## Getting started
8
+
9
+ Scaffold via `flow-weaver init` and select the "AI Workflow Runner" use case, or use it programmatically:
10
+
11
+ ```typescript
12
+ import { weaverTemplate } from '@synergenius/flowweaver-pack-weaver/templates';
13
+ const source = weaverTemplate.generate({ projectDir: '.' });
14
+ ```
15
+
16
+ Then compile and run:
17
+
18
+ ```bash
19
+ flow-weaver compile weaver.ts
20
+ tsx weaver.ts
21
+ ```
22
+
23
+ Or run via MCP: `fw_execute_workflow` pointing at the compiled `weaver.ts`.
24
+
25
+ ## .weaver.json
26
+
27
+ Place a `.weaver.json` in your project root to configure the weaver workflow:
28
+
29
+ ```json
30
+ {
31
+ "provider": "auto",
32
+ "target": "scripts/my-pipeline.ts",
33
+ "notify": [
34
+ { "channel": "discord", "url": "https://discord.com/api/webhooks/ID/TOKEN" }
35
+ ]
36
+ }
37
+ ```
38
+
39
+ ## Provider options
40
+
41
+ **Auto-detect** (tries each in order):
42
+ ```json
43
+ { "provider": "auto" }
44
+ ```
45
+
46
+ **Anthropic API** (best quality, requires API key):
47
+ ```json
48
+ { "provider": "anthropic" }
49
+ ```
50
+
51
+ **Claude CLI** (uses your CLI subscription, no API key needed):
52
+ ```json
53
+ { "provider": "claude-cli" }
54
+ ```
55
+
56
+ **GitHub Copilot CLI** (uses your Copilot subscription):
57
+ ```json
58
+ { "provider": "copilot-cli" }
59
+ ```
60
+
61
+ ## Workflow nodes
62
+
63
+ The weaver workflow has 6 nodes, visible and editable in Studio:
64
+
65
+ 1. **Load Config** - Reads `.weaver.json`, falls back to `{ provider: 'auto' }`
66
+ 2. **Detect Provider** - Auto-detects installed CLIs and API keys
67
+ 3. **Resolve Target** - Finds the workflow to run (from config or by scanning)
68
+ 4. **Execute Target** - Runs the target with an AI agent channel
69
+ 5. **Notify Result** - Sends Discord/Slack/webhook notifications
70
+ 6. **Report** - Prints summary to console
71
+
72
+ You can customize any node, add pre/post-processing steps, or insert approval gates in Studio.
73
+
74
+ ## Full .weaver.json reference
75
+
76
+ | Field | Type | Default | Description |
77
+ |-------|------|---------|-------------|
78
+ | `provider` | string or object | `"auto"` | AI provider (see options above) |
79
+ | `target` | string | auto-scan | Path to target workflow file |
80
+ | `approval` | `"auto"` / `"timeout-auto"` / object | `"auto"` | Approval gate behavior |
81
+ | `notify` | array | `[]` | Webhook notification channels |
82
+
83
+ ### Provider (verbose form)
84
+
85
+ | Field | Type | Default | Description |
86
+ |-------|------|---------|-------------|
87
+ | `name` | `"anthropic"` / `"claude-cli"` / `"copilot-cli"` | required | Provider name |
88
+ | `model` | string | `"claude-sonnet-4-6"` | Model to use (Anthropic only) |
89
+ | `maxTokens` | number | `4096` | Max response tokens (Anthropic only) |
90
+
91
+ Shorthand values:
92
+
93
+ - `"anthropic"` requires `ANTHROPIC_API_KEY` env var and `@anthropic-ai/sdk` package
94
+ - `"claude-cli"` uses the Claude Code CLI (`claude -p`), requires Claude CLI installed
95
+ - `"copilot-cli"` uses GitHub Copilot CLI (`copilot -p`), requires Copilot CLI installed
96
+ - `"auto"` auto-detects in order: `ANTHROPIC_API_KEY` > `claude` CLI > `copilot` CLI
97
+
98
+ ### Approval
99
+
100
+ How approval gates are handled.
101
+
102
+ | Field | Type | Default | Description |
103
+ |-------|------|---------|-------------|
104
+ | `mode` | `"auto"` / `"timeout-auto"` | `"auto"` | `auto`: approve immediately. `timeout-auto`: wait, then approve |
105
+ | `timeoutSeconds` | number | `300` | Seconds to wait before auto-approving (timeout-auto only) |
106
+
107
+ ### Notifications
108
+
109
+ Webhook notifications. Array of notification targets. Supports Discord, Slack, and custom webhooks.
110
+
111
+ | Field | Type | Default | Description |
112
+ |-------|------|---------|-------------|
113
+ | `channel` | `"discord"` / `"slack"` / `"webhook"` | required | Notification target |
114
+ | `url` | string | required | Webhook URL |
115
+ | `events` | array | all events | Event types to send: `workflow-start`, `workflow-complete`, `error` |
116
+ | `headers` | object | `{}` | Extra HTTP headers (custom webhooks only) |
117
+
118
+ Discord notifications use rich embeds with color-coded outcomes. Slack uses Block Kit formatting.
119
+
120
+ ## Programmatic usage
121
+
122
+ The pack also exports library functions for building custom runners:
123
+
124
+ ```typescript
125
+ import {
126
+ createProvider,
127
+ detectProvider,
128
+ runWorkflow,
129
+ BotAgentChannel,
130
+ } from '@synergenius/flowweaver-pack-weaver';
131
+
132
+ // Auto-detect and run
133
+ const result = await runWorkflow('path/to/workflow.ts', { verbose: true });
134
+
135
+ // Or build a custom agent channel
136
+ const providerConfig = detectProvider();
137
+ const provider = createProvider(providerConfig);
138
+ const channel = new BotAgentChannel(provider, { ... });
139
+ ```
140
+
141
+ Scheduling is left to the user: cron, GitHub Actions, git hooks, etc.
@@ -0,0 +1,9 @@
1
+ export type { BotConfig, BotProviderConfig, BotApprovalConfig, BotNotifyConfig, NotificationEvent, NotificationEventType, WeaverConfig, WorkflowResult, ProviderName, } from './bot/types.js';
2
+ export type { BotAgentProvider, BotChannelContext } from './bot/index.js';
3
+ export { AnthropicAgentProvider, CliAgentProvider, resolveProviderConfig, createProvider, detectProvider, } from './bot/index.js';
4
+ export { BotAgentChannel } from './bot/index.js';
5
+ export { WebhookNotificationChannel, createNotifier, } from './bot/index.js';
6
+ export type { NotificationChannel } from './bot/index.js';
7
+ export { buildSystemPrompt } from './bot/index.js';
8
+ export { runWorkflow } from './bot/index.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,0BAA0B,EAC1B,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { AnthropicAgentProvider, CliAgentProvider, resolveProviderConfig, createProvider, detectProvider, } from './bot/index.js';
2
+ // Agent channel & notifications
3
+ export { BotAgentChannel } from './bot/index.js';
4
+ export { WebhookNotificationChannel, createNotifier, } from './bot/index.js';
5
+ // System prompt
6
+ export { buildSystemPrompt } from './bot/index.js';
7
+ // Runner
8
+ export { runWorkflow } from './bot/index.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AAExB,gCAAgC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,0BAA0B,EAC1B,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,SAAS;AACT,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { weaverTemplate } from './weaver-template.js';
2
+ export type { WorkflowTemplate } from './weaver-template.js';
3
+ export { weaverTemplate };
4
+ export declare const workflowTemplates: import("./weaver-template.js").WorkflowTemplate[];
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,eAAO,MAAM,iBAAiB,mDAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { weaverTemplate } from './weaver-template.js';
2
+ export { weaverTemplate };
3
+ export const workflowTemplates = [weaverTemplate];
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,cAAc,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export interface WorkflowTemplate {
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ category: string;
6
+ generate: (opts: {
7
+ projectDir?: string;
8
+ }) => string;
9
+ }
10
+ export declare const weaverTemplate: WorkflowTemplate;
11
+ //# sourceMappingURL=weaver-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weaver-template.d.ts","sourceRoot":"","sources":["../../src/templates/weaver-template.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAC;CACrD;AAED,eAAO,MAAM,cAAc,EAAE,gBA8pB5B,CAAC"}