@zibby/agent-workflow 0.4.40 → 0.6.1

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 (41) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/base.d.ts +10 -19
  3. package/dist/agents/base.js +1 -1
  4. package/dist/code-generator.d.ts +2 -2
  5. package/dist/code-generator.js +12 -12
  6. package/dist/compose-knowledge.d.ts +1 -1
  7. package/dist/constants.d.ts +9 -9
  8. package/dist/context-loader.d.ts +2 -2
  9. package/dist/context-loader.js +2 -2
  10. package/dist/exec-context.d.ts +40 -14
  11. package/dist/exec-context.js +1 -1
  12. package/dist/graph-compiler.d.ts +6 -6
  13. package/dist/graph-compiler.js +20 -20
  14. package/dist/graph.d.ts +46 -63
  15. package/dist/graph.js +20 -20
  16. package/dist/in-process-subgraph.d.ts +58 -25
  17. package/dist/in-process-subgraph.js +1 -1
  18. package/dist/index.d.ts +45 -18
  19. package/dist/index.js +28 -28
  20. package/dist/logger.d.ts +13 -12
  21. package/dist/logger.js +1 -1
  22. package/dist/node-registry.d.ts +5 -5
  23. package/dist/node-registry.js +6 -6
  24. package/dist/node.d.ts +14 -12
  25. package/dist/node.js +12 -12
  26. package/dist/output-parser.d.ts +3 -27
  27. package/dist/output-parser.js +2 -2
  28. package/dist/skill-registry.d.ts +7 -21
  29. package/dist/state.d.ts +8 -4
  30. package/dist/state.js +1 -1
  31. package/dist/stores.d.ts +8 -11
  32. package/dist/strategy-registry.d.ts +18 -12
  33. package/dist/strategy-registry.js +4 -4
  34. package/dist/sub-graph-executor.d.ts +36 -8
  35. package/dist/sub-graph-executor.js +1 -1
  36. package/dist/subgraph-registry.d.ts +37 -16
  37. package/dist/timeline.d.ts +35 -20
  38. package/dist/timeline.js +8 -8
  39. package/dist/tool-resolver.d.ts +8 -15
  40. package/dist/tool-resolver.js +1 -1
  41. package/package.json +5 -3
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  [Deutsch](./i18n/README.de.md) | [Español](./i18n/README.es.md) | [français](./i18n/README.fr.md) | [日本語](./i18n/README.ja.md) | [한국어](./i18n/README.ko.md) | [Português](./i18n/README.pt.md) | [Русский](./i18n/README.ru.md) | [中文](./i18n/README.zh.md)
9
9
 
10
- 📖 **Full docs:** [docs.zibby.app](https://docs.zibby.app) · [Get Started](https://docs.zibby.app/get-started/install) · [Concepts](https://docs.zibby.app/concepts/graph) · [CLI Reference](https://docs.zibby.app/cli-reference) · [Cloud](https://docs.zibby.app/cloud/triggering)
10
+ 📖 **Full docs:** [docs.zibby.app](https://docs.zibby.app) · [Get Started](https://docs.zibby.app/get-started/install) · [Concepts](https://docs.zibby.app/concepts/graph) · [Designing agents](https://docs.zibby.app/concepts/designing-agents) · [CLI Reference](https://docs.zibby.app/cli-reference) · [Cloud](https://docs.zibby.app/cloud/triggering)
11
11
 
12
12
  > **The cloud pipeline for Claude Code, Codex, and Gemini.** Compose them into structured workflows with Zod-validated handoff between nodes. Vendor-neutral, JavaScript-first, runs locally or in our cloud.
13
13
 
@@ -4,16 +4,16 @@
4
4
  *
5
5
  * @abstract
6
6
  */
7
- export class AgentStrategy {
7
+ export declare class AgentStrategy {
8
+ description?: any;
9
+ name?: any;
10
+ priority?: any;
8
11
  /**
9
12
  * @param {string} name - Provider identifier (e.g. 'claude', 'openai')
10
13
  * @param {string} description - Human-readable description
11
14
  * @param {number} [priority] - Selection priority (higher = preferred)
12
15
  */
13
- constructor(name: string, description: string, priority?: number);
14
- name: string;
15
- description: string;
16
- priority: number;
16
+ constructor(name: any, description: any, priority?: number);
17
17
  /**
18
18
  * Execute a prompt against this agent.
19
19
  *
@@ -39,25 +39,16 @@ export class AgentStrategy {
39
39
  * @property {string} raw - Raw agent output
40
40
  * @property {object} structured - Parsed and validated output
41
41
  */
42
- invoke(_prompt: any, _options?: {}): Promise<string | {
43
- /**
44
- * - Raw agent output
45
- */
46
- raw: string;
47
- /**
48
- * - Parsed and validated output
49
- */
50
- structured: object;
51
- }>;
42
+ invoke(_prompt: any, _options?: any): Promise<void>;
52
43
  /**
53
44
  * Return true if this strategy can run in the current environment.
54
45
  * @abstract
55
46
  * @param {object} [context]
56
47
  * @returns {boolean}
57
48
  */
58
- canHandle(_context: any): boolean;
59
- getName(): string;
60
- getDescription(): string;
61
- getPriority(): number;
49
+ canHandle(_context: any): void;
50
+ getName(): any;
51
+ getDescription(): any;
52
+ getPriority(): any;
62
53
  }
63
54
  export default AgentStrategy;
@@ -1 +1 @@
1
- var r=class{constructor(t,e,i=0){this.name=t,this.description=e,this.priority=i}async invoke(t,e={}){throw new Error(`${this.constructor.name}.invoke() must be implemented`)}canHandle(t){throw new Error(`${this.constructor.name}.canHandle() must be implemented`)}getName(){return this.name}getDescription(){return this.description}getPriority(){return this.priority}},o=r;export{r as AgentStrategy,o as default};
1
+ var r=class{constructor(t,e,n=0){this.name=t,this.description=e,this.priority=n}async invoke(t,e={}){throw new Error(`${this.constructor.name}.invoke() must be implemented`)}canHandle(t){throw new Error(`${this.constructor.name}.canHandle() must be implemented`)}getName(){return this.name}getDescription(){return this.description}getPriority(){return this.priority}},o=r;export{r as AgentStrategy,o as default};
@@ -1,2 +1,2 @@
1
- export function generateWorkflowCode(config: any, meta?: {}): string;
2
- export function generateNodeConfigsJson(nodeConfigs: any): {};
1
+ export declare function generateWorkflowCode(config: any, meta?: any): string;
2
+ export declare function generateNodeConfigsJson(nodeConfigs: any): any;
@@ -1,8 +1,8 @@
1
- var V=Object.defineProperty;var T=(e,o)=>()=>(e&&(o=e(e=0)),o);var Y=(e,o)=>{for(var n in o)V(e,n,{get:o[n],enumerable:!0})};function $(e){return U.get(e)||null}var b,N,U,ae,v=T(()=>{b=Symbol.for("@zibby/agent-workflow.skills"),N=Symbol.for("@zibby/agent-workflow.skills.sources");globalThis[b]||(globalThis[b]=new Map);globalThis[N]||(globalThis[N]=new Map);U=globalThis[b],ae=globalThis[N]});var I,K,S,k,E=T(()=>{I=()=>{},K={debug:I,info:I,warn:(...e)=>console.warn("[workflow]",...e),error:(...e)=>console.error("[workflow]",...e)},S={impl:K},k={debug:(...e)=>S.impl.debug?.(...e),info:(...e)=>S.impl.info?.(...e),warn:(...e)=>S.impl.warn?.(...e),error:(...e)=>S.impl.error?.(...e)}});var O=T(()=>{});var M={};Y(M,{getAgentStrategy:()=>P,invokeAgent:()=>J,listStrategies:()=>W,registerStrategy:()=>H,resolveInvocationModel:()=>R});function H(e){if(!e||typeof e.getName!="function"||typeof e.invoke!="function")throw new Error("strategy must implement getName() and invoke() (AgentStrategy shape)");let o=y.findIndex(n=>n.getName()===e.getName());o>=0?y[o]=e:y.push(e)}function W(){return y.map(e=>e.getName())}function R({config:e={},options:o={},strategyName:n,envModel:r}={}){let i=e.models||{},s=o.nodeName&&i[o.nodeName]||null,t=i.default||null,a=e.agent?.[n]?.model||null,c=(typeof r=="string"?r.trim():"")||null;return s||t||a||o.model||c||null}function P(e={}){let{state:o={},preferredAgent:n=null}=e,r=n||o.agentType||process.env.AGENT_TYPE;if(!r){let s=y.map(t=>t.getName()).join(", ")||"none registered";throw new Error(`No agent specified. Set agentType in state or AGENT_TYPE env var. Available: ${s}`)}k.debug(`[workflow] agent selection: requested=${r}`);let i=y.find(s=>s.getName()===r);if(!i){let s=y.map(t=>t.getName()).join(", ")||"none registered";throw new Error(`Unknown agent '${r}'. Available: ${s}`)}if(!i.canHandle(e))throw new Error(`Agent '${r}' is not available in this environment. Check credentials/environment.`);return k.debug(`[workflow] using agent: ${i.getName()}`),i}async function J(e,o={},n={}){let r=o.state&&typeof o.state.getAll=="function"?o.state.getAll():o.state||{},i={...o,state:r},s=P(i),t=r.config||n.config||{},a=R({config:t,options:n,strategyName:s.name,envModel:process.env.MODEL}),c={...n,model:a,workspace:r.workspace||n.workspace,schema:n.schema||o.schema,images:n.images||o.images||[],skills:n.skills||o.skills||[],extraMcpServers:n.extraMcpServers||r.extraMcpServers||o.extraMcpServers||[],plugins:n.plugins||o.plugins||[],config:t},l=e,g=c.skills||[];if(g.length>0&&!n.skipPromptFragments){let h=g.map(p=>{let f=$(p)?.promptFragment;return typeof f=="function"?f():f}).filter(Boolean);h.length>0&&(l+=`
1
+ var V=Object.defineProperty;var T=(e,o,t)=>()=>{if(t)throw t[0];try{return e&&(o=e(e=0)),o}catch(r){throw t=[r],r}};var Y=(e,o)=>{for(var t in o)V(e,t,{get:o[t],enumerable:!0})};function $(e){return U.get(e)||null}var b,N,U,ce,v=T(()=>{b=Symbol.for("@zibby/agent-workflow.skills"),N=Symbol.for("@zibby/agent-workflow.skills.sources");globalThis[b]||(globalThis[b]=new Map);globalThis[N]||(globalThis[N]=new Map);U=globalThis[b],ce=globalThis[N]});var I,K,S,k,E=T(()=>{I=()=>{},K={debug:I,info:I,warn:(...e)=>console.warn("[workflow]",...e),error:(...e)=>console.error("[workflow]",...e)},S={impl:K},k={debug:(...e)=>S.impl.debug?.(...e),info:(...e)=>S.impl.info?.(...e),warn:(...e)=>S.impl.warn?.(...e),error:(...e)=>S.impl.error?.(...e)}});var O=T(()=>{});var M={};Y(M,{getAgentStrategy:()=>P,invokeAgent:()=>J,listStrategies:()=>W,registerStrategy:()=>H,resolveInvocationModel:()=>R});function H(e){if(!e||typeof e.getName!="function"||typeof e.invoke!="function")throw new Error("strategy must implement getName() and invoke() (AgentStrategy shape)");let o=w.findIndex(t=>t.getName()===e.getName());o>=0?w[o]=e:w.push(e)}function W(){return w.map(e=>e.getName())}function R({config:e={},options:o={},strategyName:t,envModel:r}={}){let i=e.models||{},s=o.nodeName&&i[o.nodeName]||null,n=i.default||null,c=e.agent?.[t]?.model||null,a=(typeof r=="string"?r.trim():"")||null;return s||n||c||o.model||a||null}function P(e={}){let{state:o={},preferredAgent:t=null}=e,r=t||o.agentType||process.env.AGENT_TYPE;if(!r){let s=w.map(n=>n.getName()).join(", ")||"none registered";throw new Error(`No agent specified. Set agentType in state or AGENT_TYPE env var. Available: ${s}`)}k.debug(`[workflow] agent selection: requested=${r}`);let i=w.find(s=>s.getName()===r);if(!i){let s=w.map(n=>n.getName()).join(", ")||"none registered";throw new Error(`Unknown agent '${r}'. Available: ${s}`)}if(!i.canHandle(e))throw new Error(`Agent '${r}' is not available in this environment. Check credentials/environment.`);return k.debug(`[workflow] using agent: ${i.getName()}`),i}async function J(e,o={},t={}){let r=o.state&&typeof o.state.getAll=="function"?o.state.getAll():o.state||{},i={...o,state:r},s=P(i),n=r.config||t.config||{},c=R({config:n,options:t,strategyName:s.name,envModel:process.env.MODEL}),a={...t,model:c,workspace:r.workspace||t.workspace,schema:t.schema||o.schema,images:t.images||o.images||[],skills:t.skills||o.skills||[],extraMcpServers:t.extraMcpServers||r.extraMcpServers||o.extraMcpServers||[],plugins:t.plugins||o.plugins||[],config:n},l=e,g=a.skills||[];if(g.length>0&&!t.skipPromptFragments){let h=g.map(p=>{let f=$(p)?.promptFragment;return typeof f=="function"?f():f}).filter(Boolean);h.length>0&&(l+=`
2
2
 
3
3
  ${h.join(`
4
4
 
5
- `)}`)}let u=r._currentNodeConfig?.stores;if(Array.isArray(u)&&u.length>0&&typeof u[0]=="object"){let h=u.length<=8,p=u.map(f=>{let d=f?.id??f?.storeId??"",w=(f?.name??"").toString().trim()||d,B=f?.type?` \xB7 ${f.type}`:"",F=(f?.description||"").toString().replace(/\s+/g," ").trim(),A=`- ${w} \xB7 ${F||"(no description)"}${B} (id: ${d})`;if(h&&f?.schema&&typeof f.schema=="object"){let j=f.schema.properties&&typeof f.schema.properties=="object"?Object.keys(f.schema.properties):Object.keys(f.schema);j.length&&(A+=`
5
+ `)}`)}let u=r._currentNodeConfig?.stores;if(Array.isArray(u)&&u.length>0&&typeof u[0]=="object"){let h=u.length<=8,p=u.map(f=>{let d=f?.id??f?.storeId??"",y=(f?.name??"").toString().trim()||d,B=f?.type?` \xB7 ${f.type}`:"",F=(f?.description||"").toString().replace(/\s+/g," ").trim(),A=`- ${y} \xB7 ${F||"(no description)"}${B} (id: ${d})`;if(h&&f?.schema&&typeof f.schema=="object"){let j=f.schema.properties&&typeof f.schema.properties=="object"?Object.keys(f.schema.properties):Object.keys(f.schema);j.length&&(A+=`
6
6
  fields: ${j.join(", ")}`)}return A});l+=`
7
7
 
8
8
  AVAILABLE STORES (pick a store by its description and pass its NAME to the store tool):
@@ -14,21 +14,21 @@ PRIORITY OVERRIDE \u2014 THE FOLLOWING INSTRUCTIONS TAKE PRECEDENCE OVER ALL PRE
14
14
  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
15
15
 
16
16
  ${m}
17
- `),k.debug(`[workflow] prompt length: ${l.length} chars`),s.invoke(l,c)}var x,y,L=T(()=>{O();E();v();x=Symbol.for("@zibby/agent-workflow.strategies");globalThis[x]||(globalThis[x]=[]);y=globalThis[x]});v();E();var C={};var _=Symbol.for("@zibby/agent-workflow.nodes");globalThis[_]||(globalThis[_]=new Map);var D=globalThis[_];function q(e,o){D.set(e,o)}function z(e){let o=D.get(e);return o?o.factory&&typeof o.create=="function"?o.create.toString():typeof o.execute=="function"?o.execute.toString():typeof o=="function"?o.toString():null:null}q("ai_agent",{name:"ai_agent",factory:!0,create:(e,o={})=>({name:e,_isCustomCode:!0,execute:async n=>{let r=n?._coreInvokeAgent;r||(r=(await Promise.resolve().then(()=>(L(),M))).invokeAgent);let i=o.extraPromptInstructions||"Execute the task based on the current state.",s=Z(i,n),t=await r(s,{cwd:n.workspace||process.cwd(),model:n.model,tools:o.resolvedTools||null});return{success:!0,output:{raw:t,nodeId:e},raw:typeof t=="string"?t:t.raw}}})});function Z(e,o){let n=/@([\w.]+)/g,r=new Set,i;for(;(i=n.exec(e))!==null;)r.add(i[1]);if(r.size===0)return e;let s=[],t=new Set;for(let a of r){let c=a.split(".")[0];if(t.has(c))continue;let l=a.split(".").reduce((m,h)=>m?.[h],o);if(l===void 0)continue;let g=typeof l=="string"?l:l?.raw??JSON.stringify(l,null,2),u=a.replace(/_/g," ").replace(/\b\w/g,m=>m.toUpperCase());s.push(`## ${u}
18
- ${g}`),a.includes(".")||t.add(c)}return s.length===0?e:`${e}
17
+ `),k.debug(`[workflow] prompt length: ${l.length} chars`),s.invoke(l,a)}var x,w,L=T(()=>{O();E();v();x=Symbol.for("@zibby/agent-workflow.strategies");globalThis[x]||(globalThis[x]=[]);w=globalThis[x]});v();E();var C={};var _=Symbol.for("@zibby/agent-workflow.nodes");globalThis[_]||(globalThis[_]=new Map);var D=globalThis[_];function q(e,o){D.set(e,o)}function z(e){let o=D.get(e);return o?o.factory&&typeof o.create=="function"?o.create.toString():typeof o.execute=="function"?o.execute.toString():typeof o=="function"?o.toString():null:null}q("ai_agent",{name:"ai_agent",factory:!0,create:(e,o={})=>({name:e,_isCustomCode:!0,execute:async t=>{let r=t?._coreInvokeAgent;r||(r=(await Promise.resolve().then(()=>(L(),M))).invokeAgent);let i=o.extraPromptInstructions||"Execute the task based on the current state.",s=Z(i,t),n=await r(s,{cwd:t.workspace||process.cwd(),model:t.model,tools:o.resolvedTools||null});return{success:!0,output:{raw:n,nodeId:e},raw:typeof n=="string"?n:n.raw}}})});function Z(e,o){let t=/@([\w.]+)/g,r=new Set,i;for(;(i=t.exec(e))!==null;)r.add(i[1]);if(r.size===0)return e;let s=[],n=new Set;for(let c of r){let a=c.split(".")[0];if(n.has(a))continue;let l=c.split(".").reduce((m,h)=>m?.[h],o);if(l===void 0)continue;let g=typeof l=="string"?l:l?.raw??JSON.stringify(l,null,2),u=c.replace(/_/g," ").replace(/\b\w/g,m=>m.toUpperCase());s.push(`## ${u}
18
+ ${g}`),c.includes(".")||n.add(a)}return s.length===0?e:`${e}
19
19
 
20
20
  ---
21
21
  # Referenced Context
22
22
 
23
23
  ${s.join(`
24
24
 
25
- `)}`}function be(e,o={}){let{nodes:n,edges:r,nodeConfigs:i={}}=e,s=new Set,t=[],a=new Map;for(let d of n){let w=d.data?.nodeType||d.type;a.set(d.id,w),w==="decision"?s.add(d.id):t.push({id:d.id,nodeType:w,label:d.data?.label||d.id})}let c=t.some(d=>{let w=i[d.id]||{};return!w.customCode&&!w.executeCode}),{toolsPerNode:l,toolIdsByVar:g}=re(t,i),{simpleEdges:u,conditionalEdges:m}=se(r,s),h=ie(t,r,s),p=[],f=o.workflowType||"workflow";return p.push(Q(o)),p.push(X(f,{usesRegisteredNodes:c})),p.push(ee(g)),p.push(oe(f)),p.push(te(t,i)),p.push(ne(t,h,u,m,l,f)),p.filter(Boolean).join(`
26
- `)}function Ne(e){let o={};for(let[n,r]of Object.entries(e)){let{tools:i,...s}=r;Object.keys(s).length>0&&(o[n]=s)}return o}function Q(e){let o=e.workflowType||"workflow";return["// Generated workflow",`// ${e.projectId?`Project: ${e.projectId} | `:""}Type: ${o} | Version: ${e.version??0}`,`// Downloaded: ${new Date().toISOString()}`,""].join(`
27
- `)}function X(e,{usesRegisteredNodes:o=!0}={}){let n=["import { WorkflowGraph, invokeAgent, getResolvedToolDefinitions } from '@zibby/agent-workflow';"];return o&&n.push("// import './register-nodes.js'; // register custom node types here"),n.push("import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';","import { join, dirname } from 'node:path';","import { fileURLToPath } from 'node:url';",""),n.join(`
28
- `)}function ee(e){if(e.size===0)return"";let o=["// \u2500\u2500 Tool Bindings \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];for(let[n,r]of e)o.push(`const ${n} = getResolvedToolDefinitions(${JSON.stringify(r)}); // ${r.join(", ")}`);return o.push(""),o.join(`
25
+ `)}`}function be(e,o={}){let{nodes:t,edges:r,nodeConfigs:i={}}=e,s=new Set,n=[],c=new Map;for(let d of t){let y=d.data?.nodeType||d.type;c.set(d.id,y),y==="decision"?s.add(d.id):n.push({id:d.id,nodeType:y,label:d.data?.label||d.id})}let a=n.some(d=>{let y=i[d.id]||{};return!y.customCode&&!y.executeCode}),{toolsPerNode:l,toolIdsByVar:g}=re(n,i),{simpleEdges:u,conditionalEdges:m}=se(r,s),h=ie(n,r,s),p=[],f=o.workflowType||"workflow";return p.push(Q(o)),p.push(X(f,{usesRegisteredNodes:a})),p.push(ee(g)),p.push(oe(f)),p.push(te(n,i)),p.push(ne(n,h,u,m,l,f)),p.filter(Boolean).join(`
26
+ `)}function Ne(e){let o={};for(let[t,r]of Object.entries(e)){let{tools:i,...s}=r;Object.keys(s).length>0&&(o[t]=s)}return o}function Q(e){let o=e.workflowType||"workflow";return["// Generated workflow",`// ${e.projectId?`Project: ${e.projectId} | `:""}Type: ${o} | Version: ${e.version??0}`,`// Downloaded: ${new Date().toISOString()}`,""].join(`
27
+ `)}function X(e,{usesRegisteredNodes:o=!0}={}){let t=["import { WorkflowGraph, invokeAgent, getResolvedToolDefinitions } from '@zibby/agent-workflow';"];return o&&t.push("// import './register-nodes.js'; // register custom node types here"),t.push("import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';","import { join, dirname } from 'node:path';","import { fileURLToPath } from 'node:url';",""),t.join(`
28
+ `)}function ee(e){if(e.size===0)return"";let o=["// \u2500\u2500 Tool Bindings \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];for(let[t,r]of e)o.push(`const ${t} = getResolvedToolDefinitions(${JSON.stringify(r)}); // ${r.join(", ")}`);return o.push(""),o.join(`
29
29
  `)}function oe(e){return["// \u2500\u2500 Node Configs \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500","const __filename = fileURLToPath(import.meta.url);","const __dirname = dirname(__filename);",`const configPath = join(__dirname, 'workflow-${e}.config.json');`,"const nodeConfigs = existsSync(configPath) ? JSON.parse(readFileSync(configPath, 'utf-8')) : {};",""].join(`
30
- `)}function te(e,o){let n=["// \u2500\u2500 Node Implementations \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",""];for(let r of e){let i=G(r.id),s=o[r.id]?.customCode;if(s)n.push(`// @custom \u2014 modified from default "${r.nodeType}" template`),n.push(`const ${i}_execute = ${s};`);else{let t=z(r.nodeType);t?(n.push(`// Default "${r.nodeType}" implementation`),n.push(`const ${i}_execute = ${t};`)):(n.push(`// No template for "${r.nodeType}" \u2014 passthrough`),n.push(`const ${i}_execute = async (state) => ({ success: true, output: {}, raw: null });`))}n.push("")}return n.join(`
31
- `)}function ne(e,o,n,r,i,s){let t=["// \u2500\u2500 Graph Builder \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];t.push("export function buildGraph(options = {}) {"),t.push(" const graph = new WorkflowGraph(options);",""),t.push(" // Nodes");for(let c of e){let l=G(c.id);t.push(` graph.addNode('${c.id}', { name: '${c.id}', execute: ${l}_execute });`),t.push(` graph.setNodeType('${c.id}', '${c.nodeType}');`)}t.push("",` graph.setEntryPoint('${o}');`,""),(n.length>0||r.length>0)&&t.push(" // Edges");for(let c of n)t.push(` graph.addEdge('${c.source}', '${c.target}');`);for(let c of r){let l=c.code.split(`
30
+ `)}function te(e,o){let t=["// \u2500\u2500 Node Implementations \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",""];for(let r of e){let i=G(r.id),s=o[r.id]?.customCode;if(s)t.push(`// @custom \u2014 modified from default "${r.nodeType}" template`),t.push(`const ${i}_execute = ${s};`);else{let n=z(r.nodeType);n?(t.push(`// Default "${r.nodeType}" implementation`),t.push(`const ${i}_execute = ${n};`)):(t.push(`// No template for "${r.nodeType}" \u2014 passthrough`),t.push(`const ${i}_execute = async (state) => ({ success: true, output: {}, raw: null });`))}t.push("")}return t.join(`
31
+ `)}function ne(e,o,t,r,i,s){let n=["// \u2500\u2500 Graph Builder \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"];n.push("export function buildGraph(options = {}) {"),n.push(" const graph = new WorkflowGraph(options);",""),n.push(" // Nodes");for(let a of e){let l=G(a.id);n.push(` graph.addNode('${a.id}', { name: '${a.id}', execute: ${l}_execute });`),n.push(` graph.setNodeType('${a.id}', '${a.nodeType}');`)}n.push("",` graph.setEntryPoint('${o}');`,""),(t.length>0||r.length>0)&&n.push(" // Edges");for(let a of t)n.push(` graph.addEdge('${a.source}', '${a.target}');`);for(let a of r){let l=a.code.split(`
32
32
  `).map((g,u)=>u===0?g:` ${g}`).join(`
33
- `);t.push(` graph.addConditionalEdges('${c.source}', ${l});`)}let a=[];for(let c of e){let l=i.get(c.id);l&&a.push(` '${c.id}': ${l},`)}return a.length>0&&t.push(""," graph.resolvedToolsMap = {",...a," };"),t.push(""," return graph;","}",""),t.push("export { nodeConfigs };",""),t.join(`
34
- `)}function re(e,o){let n=new Map,r=new Map;for(let i of e){let s=o[i.id]?.tools,t;if(Array.isArray(s)&&s.length>0)t=[...s].sort();else{let a=C[i.nodeType];a?.length>0&&(t=[...a].sort())}if(t){let a=`${t.map(c=>c.replace(/[^a-zA-Z0-9]/g,"")).join("And")}Tools`;n.set(i.id,a),r.has(a)||r.set(a,t)}}return{toolsPerNode:n,toolIdsByVar:r}}function se(e,o){let n=[],r=[],i=new Map,s=new Set;for(let t of e)i.has(t.source)||i.set(t.source,[]),i.get(t.source).push(t);for(let t of e)if(!o.has(t.source))if(o.has(t.target)){if(s.has(t.target))continue;s.add(t.target);let c=(i.get(t.target)||[]).find(l=>l.data?.conditionalCode||l.conditionalCode);c&&r.push({source:t.source,code:c.data?.conditionalCode||c.conditionalCode})}else n.push({source:t.source,target:t.target});return{simpleEdges:n,conditionalEdges:r}}function ie(e,o,n){let r=new Set;for(let s of o)n.has(s.target)||r.add(s.target);let i=e.find(s=>!r.has(s.id));return i?i.id:e[0]?.id}function G(e){return e.replace(/[^a-zA-Z0-9]/g,"_")}export{Ne as generateNodeConfigsJson,be as generateWorkflowCode};
33
+ `);n.push(` graph.addConditionalEdges('${a.source}', ${l});`)}let c=[];for(let a of e){let l=i.get(a.id);l&&c.push(` '${a.id}': ${l},`)}return c.length>0&&n.push(""," graph.resolvedToolsMap = {",...c," };"),n.push(""," return graph;","}",""),n.push("export { nodeConfigs };",""),n.join(`
34
+ `)}function re(e,o){let t=new Map,r=new Map;for(let i of e){let s=o[i.id]?.tools,n;if(Array.isArray(s)&&s.length>0)n=[...s].sort();else{let c=C[i.nodeType];c?.length>0&&(n=[...c].sort())}if(n){let c=`${n.map(a=>a.replace(/[^a-zA-Z0-9]/g,"")).join("And")}Tools`;t.set(i.id,c),r.has(c)||r.set(c,n)}}return{toolsPerNode:t,toolIdsByVar:r}}function se(e,o){let t=[],r=[],i=new Map,s=new Set;for(let n of e)i.has(n.source)||i.set(n.source,[]),i.get(n.source).push(n);for(let n of e)if(!o.has(n.source))if(o.has(n.target)){if(s.has(n.target))continue;s.add(n.target);let a=(i.get(n.target)||[]).find(l=>l.data?.conditionalCode||l.conditionalCode);a&&r.push({source:n.source,code:a.data?.conditionalCode||a.conditionalCode})}else t.push({source:n.source,target:n.target});return{simpleEdges:t,conditionalEdges:r}}function ie(e,o,t){let r=new Set;for(let s of o)t.has(s.target)||r.add(s.target);let i=e.find(s=>!r.has(s.id));return i?i.id:e[0]?.id}function G(e){return e.replace(/[^a-zA-Z0-9]/g,"_")}export{Ne as generateNodeConfigsJson,be as generateWorkflowCode};
@@ -23,5 +23,5 @@
23
23
  * The text is audience-neutral markdown addressed to "the wrapper author" —
24
24
  * an AI builder agent, a local Claude/Codex session, or a human.
25
25
  */
26
- export const COMPOSE_KNOWLEDGE: "## Composing deployed agents (wrapper over marketplace bricks)\n\n**Red line: wrapper only.** Marketplace agents are shared LEGO bricks \u2014 NEVER\nmodify a brick template's source and never rebuild its logic from scratch.\nThe composition is a small project-private WRAPPER workflow that dispatches\nalready-DEPLOYED bricks as sub-workflows. A forked/edited brick falls off the\nupgrade path.\n\n**Reuse policy \u2014 ask, never silently choose.** If a needed brick is already\ndeployed in the project, the user decides: reuse that instance (runs + config\nare shared with its standalone use) or deploy a dedicated instance under a\ncustom name (config isolation).\n\n**Sub-workflow node.** Declare a child dispatch by giving addNode a config\nwith a `workflow:` field \u2014 the DEPLOYED slug in the SAME project (the row's\nworkflowType, not the marketplace slug, when they differ):\n\n graph.addNode('review', {\n workflow: 'gitlab-code-review', // deployed slug\n input: (state) => ({ projectId: state.projectId, mrIid: state.mrIid }),\n timeoutMs: 15 * 60 * 1000,\n });\n\nThe engine runs the child in-process (same worker) when possible and the\nchild's FINAL state \u2014 whichever End it exited \u2014 lands at `state[nodeName]`.\nOptions: `workflow` (required), `input` (object or `(state) => object`),\n`output` (dot-path or `(finalState) => any` to extract just what's needed),\n`async: true` (fire-and-forget \u2192 `{ jobId }`), `timeoutMs`, `retries`.\nFor PARALLEL fan-out call `dispatchSubgraph(slug, { input })` (exported by\n@zibby/agent-workflow) inside one custom execute node with\n`Promise.allSettled` \u2014 one brick failing must not kill its siblings.\n\n**Chain conditions are EXPLICIT decision nodes.** Bricks are full multi-exit\ngraphs, so branch on the child's RETURNED state between dispatches \u2014 and model\nthe branch so the graph SHOWS it: a router node\n(`graph.addNode('<id>', { description })` \u2014 no execute/prompt/outputSchema;\nrenders as the Condition diamond) routed with\n`graph.addConditionalEdges('<id>', routeFn, { labels })`. Never an unlabeled\ndispatch\u2192End edge. Note the child's own node outputs are NESTED\n(`state.review.review.posted` = the child's `review` node output), e.g. only\nmeter when `state.review?.review?.posted === true && state.review?.trigger\n!== 'comment_reply'`.\n\n**Input mapping is the wrapper's job \u2014 use the brick's CANONICAL structured\nfields.** In-process children run the brick's graph directly and SKIP any\nconvenience normalization its class run() does on cold starts (e.g.\ngitlab-code-review parses mrUrl \u2192 projectId+mrIid only on cold runs \u2014 pass\nprojectId/mrIid yourself).\n\n**Credentials/config: children use their OWN row's env** (engine \u22650.4.32 +\nmatching backend). A brick's per-workflow env (Env tab / envSecret) applies to\nits in-process wrapped runs too \u2014 the child's value wins, the wrapper's env is\nonly the fallback for keys the brick doesn't define. So the wrapper needs ZERO\ncredential duplication: leave each brick's creds (e.g.\nCLAUDE_CODE_OAUTH_TOKEN) on the brick itself and give the wrapper none.\n(Env-carrying children serialize when dispatched in parallel; env-less ones\nkeep full parallelism. On older engines children inherit only the wrapper env\n\u2014 symptom: authentication_failed inside the child.) A brick's saved per-node\ncustom prompts (nodeConfigOverrides.<node>.extraPromptInstructions) apply\nin-process since \u22650.4.30, and its stores bindings ride along since \u22650.4.32.\n\n**Triggers \u2014 INHERIT the entry brick's events, read not invent.** The\nwrapper's trigger is AGENT-DRIVEN, never hardcoded: for webhook compositions\nthe wrapper's workflow.json `triggers.events` is a verbatim COPY of whatever\nthe ENTRY brick declares \u2014 read it from the brick's deployed row (or its\ntemplate workflow.json) and paste the exact array. The platform then\nautomatically SUPPRESSES the wrapped members' own subscriptions (any workflow\nlisted in a deployed wrapper's composedOf stops receiving standalone webhook\nevents), so the same event never double-fires a brick inside AND outside the\nwrapper. Cron / manual / chat-triggered compositions need nothing special.";
26
+ export declare const COMPOSE_KNOWLEDGE = "## Composing deployed agents (wrapper over marketplace bricks)\n\n**Red line: wrapper only.** Marketplace agents are shared LEGO bricks \u2014 NEVER\nmodify a brick template's source and never rebuild its logic from scratch.\nThe composition is a small project-private WRAPPER workflow that dispatches\nalready-DEPLOYED bricks as sub-workflows. A forked/edited brick falls off the\nupgrade path.\n\n**Reuse policy \u2014 ask, never silently choose.** If a needed brick is already\ndeployed in the project, the user decides: reuse that instance (runs + config\nare shared with its standalone use) or deploy a dedicated instance under a\ncustom name (config isolation).\n\n**Sub-workflow node.** Declare a child dispatch by giving addNode a config\nwith a `workflow:` field \u2014 the DEPLOYED slug in the SAME project (the row's\nworkflowType, not the marketplace slug, when they differ):\n\n graph.addNode('review', {\n workflow: 'gitlab-code-review', // deployed slug\n input: (state) => ({ projectId: state.projectId, mrIid: state.mrIid }),\n timeoutMs: 15 * 60 * 1000,\n });\n\nThe engine runs the child in-process (same worker) when possible and the\nchild's FINAL state \u2014 whichever End it exited \u2014 lands at `state[nodeName]`.\nOptions: `workflow` (required), `input` (object or `(state) => object`),\n`output` (dot-path or `(finalState) => any` to extract just what's needed),\n`async: true` (fire-and-forget \u2192 `{ jobId }`), `timeoutMs`, `retries`.\nFor PARALLEL fan-out call `dispatchSubgraph(slug, { input })` (exported by\n@zibby/agent-workflow) inside one custom execute node with\n`Promise.allSettled` \u2014 one brick failing must not kill its siblings.\n\n**Chain conditions are EXPLICIT decision nodes.** Bricks are full multi-exit\ngraphs, so branch on the child's RETURNED state between dispatches \u2014 and model\nthe branch so the graph SHOWS it: a router node\n(`graph.addNode('<id>', { description })` \u2014 no execute/prompt/outputSchema;\nrenders as the Condition diamond) routed with\n`graph.addConditionalEdges('<id>', routeFn, { labels })`. Never an unlabeled\ndispatch\u2192End edge. Note the child's own node outputs are NESTED\n(`state.review.review.posted` = the child's `review` node output), e.g. only\nmeter when `state.review?.review?.posted === true && state.review?.trigger\n!== 'comment_reply'`.\n\n**Input mapping is the wrapper's job \u2014 use the brick's CANONICAL structured\nfields.** In-process children run the brick's graph directly and SKIP any\nconvenience normalization its class run() does on cold starts (e.g.\ngitlab-code-review parses mrUrl \u2192 projectId+mrIid only on cold runs \u2014 pass\nprojectId/mrIid yourself).\n\n**Credentials/config: children use their OWN row's env** (engine \u22650.4.32 +\nmatching backend). A brick's per-workflow env (Env tab / envSecret) applies to\nits in-process wrapped runs too \u2014 the child's value wins, the wrapper's env is\nonly the fallback for keys the brick doesn't define. So the wrapper needs ZERO\ncredential duplication: leave each brick's creds (e.g.\nCLAUDE_CODE_OAUTH_TOKEN) on the brick itself and give the wrapper none.\n(Env-carrying children serialize when dispatched in parallel; env-less ones\nkeep full parallelism. On older engines children inherit only the wrapper env\n\u2014 symptom: authentication_failed inside the child.) A brick's saved per-node\ncustom prompts (nodeConfigOverrides.<node>.extraPromptInstructions) apply\nin-process since \u22650.4.30, and its stores bindings ride along since \u22650.4.32.\n\n**Triggers \u2014 INHERIT the entry brick's events, read not invent.** The\nwrapper's trigger is AGENT-DRIVEN, never hardcoded: for webhook compositions\nthe wrapper's workflow.json `triggers.events` is a verbatim COPY of whatever\nthe ENTRY brick declares \u2014 read it from the brick's deployed row (or its\ntemplate workflow.json) and paste the exact array. The platform then\nautomatically SUPPRESSES the wrapped members' own subscriptions (any workflow\nlisted in a deployed wrapper's composedOf stops receiving standalone webhook\nevents), so the same event never double-fires a brick inside AND outside the\nwrapper. Cron / manual / chat-triggered compositions need nothing special.";
27
27
  export default COMPOSE_KNOWLEDGE;
@@ -1,19 +1,19 @@
1
1
  /**
2
2
  * Framework constants — paths, filenames, and well-known skill IDs.
3
3
  */
4
- export const DEFAULT_OUTPUT_BASE: ".zibby/output";
5
- export const SESSIONS_DIR: "sessions";
6
- export const SESSION_INFO_FILE: ".session-info.json";
4
+ export declare const DEFAULT_OUTPUT_BASE = ".zibby/output";
5
+ export declare const SESSIONS_DIR = "sessions";
6
+ export declare const SESSION_INFO_FILE = ".session-info.json";
7
7
  /**
8
8
  * Written by any consumer (CLI Ctrl+C handler, IDE plugin, desktop app) to
9
9
  * request that an in-flight workflow stop at the next abort-checkpoint.
10
10
  * WorkflowGraph polls for this file between nodes and exits cleanly.
11
11
  * Consumers should prefer the AbortSignal contract (`graph.run({ signal })`).
12
12
  */
13
- export const STOP_REQUEST_FILE: ".zibby-stop";
14
- export const RESULT_FILE: "result.json";
15
- export const RAW_OUTPUT_FILE: "raw_stream_output.txt";
16
- export const EVENTS_FILE: "events.json";
13
+ export declare const STOP_REQUEST_FILE = ".zibby-stop";
14
+ export declare const RESULT_FILE = "result.json";
15
+ export declare const RAW_OUTPUT_FILE = "raw_stream_output.txt";
16
+ export declare const EVENTS_FILE = "events.json";
17
17
  /**
18
18
  * Well-known skill IDs no longer live here. The single authoritative map moved
19
19
  * to the zero-dep leaf @zibby/skill-ids (SKILL_IDS), re-exported as SKILLS by
@@ -37,6 +37,6 @@ export const EVENTS_FILE: "events.json";
37
37
  * the backend accepts these as valid allowlist ids + surfaces them in the
38
38
  * /workflows/{uuid}/integrations/status feed.
39
39
  */
40
- export const NO_INTEGRATION_TOGGLEABLE_SKILL_IDS: readonly string[];
40
+ export declare const NO_INTEGRATION_TOGGLEABLE_SKILL_IDS: readonly string[];
41
41
  /** CI env vars checked when generating session IDs. */
42
- export const CI_ENV_VARS: string[];
42
+ export declare const CI_ENV_VARS: string[];
@@ -1,5 +1,5 @@
1
- export class ContextLoader {
2
- static loadContext(specPath: any, cwd: any, config?: {}): Promise<{}>;
1
+ export declare class ContextLoader {
2
+ static loadContext(specPath: any, cwd: any, config?: any): Promise<any>;
3
3
  static findAndMergeContextFiles(filename: any, startDir: any, rootDir: any): Promise<any>;
4
4
  static loadFile(filePath: any): Promise<any>;
5
5
  }
@@ -1,5 +1,5 @@
1
- import{existsSync as f,readFileSync as y}from"node:fs";import{join as l,dirname as d}from"node:path";var m=class{static async loadContext(e,o,a={}){let t={},r=a.filenames||["CONTEXT.md","AGENTS.md"];if(e){let s=d(l(o,e));for(let i of r){let c=await this.findAndMergeContextFiles(i,s,o);if(c){let u=i.replace(/\.[^.]+$/,"").toLowerCase();t[u]=c}}}let n=a.discovery||{};for(let[s,i]of Object.entries(n))try{let c=l(o,i);f(c)&&(t[s]=await this.loadFile(c))}catch(c){console.warn(`[workflow] could not load context '${s}' from '${i}': ${c.message}`)}return t}static async findAndMergeContextFiles(e,o,a){let t=[],r=o;for(;r.startsWith(a);){let n=l(r,e);if(f(n))try{t.unshift(await this.loadFile(n))}catch(i){console.warn(`[workflow] could not load ${e} from ${n}: ${i.message}`)}let s=d(r);if(s===r)break;r=s}return t.length===0?null:t.every(n=>typeof n=="string")?t.join(`
1
+ import{existsSync as f,readFileSync as u}from"node:fs";import{join as l,dirname as d}from"node:path";var y=class{static async loadContext(e,o,c={}){let t={},r=c.filenames||["CONTEXT.md","AGENTS.md"];if(e){let s=d(l(o,e));for(let i of r){let a=await this.findAndMergeContextFiles(i,s,o);if(a){let m=i.replace(/\.[^.]+$/,"").toLowerCase();t[m]=a}}}let n=c.discovery||{};for(let[s,i]of Object.entries(n))try{let a=l(o,i);f(a)&&(t[s]=await this.loadFile(a))}catch(a){console.warn(`[workflow] could not load context '${s}' from '${i}': ${a.message}`)}return t}static async findAndMergeContextFiles(e,o,c){let t=[],r=o;for(;r.startsWith(c);){let n=l(r,e);if(f(n))try{t.unshift(await this.loadFile(n))}catch(i){console.warn(`[workflow] could not load ${e} from ${n}: ${i.message}`)}let s=d(r);if(s===r)break;r=s}return t.length===0?null:t.every(n=>typeof n=="string")?t.join(`
2
2
 
3
3
  ---
4
4
 
5
- `):t.every(n=>typeof n=="object")?Object.assign({},...t):t[t.length-1]}static async loadFile(e){let o=y(e,"utf-8");if(e.endsWith(".json"))return JSON.parse(o);if(e.endsWith(".js")||e.endsWith(".mjs")){let{pathToFileURL:a}=await import("url"),t=await import(a(e).href);return t.default||t}return o}};export{m as ContextLoader};
5
+ `):t.every(n=>typeof n=="object")?Object.assign({},...t):t[t.length-1]}static async loadFile(e){let o=u(e,"utf-8");if(e.endsWith(".json"))return JSON.parse(o);if(e.endsWith(".js")||e.endsWith(".mjs")){let{pathToFileURL:c}=await import("url"),t=await import(c(e).href);return t.default||t}return o}};export{y as ContextLoader};
@@ -1,3 +1,28 @@
1
+ /**
2
+ * Per-execution AsyncLocalStorage context.
3
+ *
4
+ * Holds the running execution's identity so anything inside the run
5
+ * (logger, progress-reporter, sub-graph dispatcher, custom node code)
6
+ * can read it without threading parameters through every call site.
7
+ *
8
+ * Why ALS over `process.env`:
9
+ * - In-process sub-graphs share the parent's process. Mutating
10
+ * `process.env.EXECUTION_ID` per child would race with sibling
11
+ * children, leaking the wrong id to anything that read env late.
12
+ * - ALS attaches values to the async call chain, so a child's
13
+ * `runInContext()` only affects its own descendants — siblings see
14
+ * the parent's context, the parent itself is unaffected after the
15
+ * child returns.
16
+ *
17
+ * Fallback contract:
18
+ * - When there's no enclosing ALS scope (e.g. legacy code paths that
19
+ * pre-date this module), `getExecContext()` falls back to env vars
20
+ * (`EXECUTION_ID`, `PARENT_EXECUTION_ID`). Top-level CLI entry
21
+ * `zibby run-workflow` wraps the workflow in a scope so that path
22
+ * is always populated for in-process children; the env fallback
23
+ * exists for unit tests and for the very first cloud run before
24
+ * the CLI is updated.
25
+ */
1
26
  /**
2
27
  * Read the active execution context. Returns a frozen object so callers
3
28
  * can't mutate the live store (use `runInContext` to push a child scope).
@@ -10,13 +35,7 @@
10
35
  * dispatchMode: 'cold'|'warm'|'inprocess'|null,
11
36
  * }}
12
37
  */
13
- export function getExecContext(): {
14
- executionId: string | null;
15
- parentExecutionId: string | null;
16
- depth: number;
17
- conversationId: string | null;
18
- dispatchMode: "cold" | "warm" | "inprocess" | null;
19
- };
38
+ export declare function getExecContext(): any;
20
39
  /**
21
40
  * Run `fn` with a fresh execution context. Nests cleanly: a child
22
41
  * scope's depth is parent.depth + 1, parentExecutionId is parent.executionId.
@@ -34,12 +53,19 @@ export function getExecContext(): {
34
53
  * @param {() => T | Promise<T>} fn
35
54
  * @returns {Promise<T> | T}
36
55
  */
37
- export function runInContext<T>(ctx: {
38
- executionId: string;
39
- parentExecutionId?: string | null;
40
- conversationId?: string | null;
41
- dispatchMode?: "cold" | "warm" | "inprocess" | null;
42
- }, fn: () => T | Promise<T>): Promise<T> | T;
56
+ export declare function runInContext(ctx: any, fn: any): unknown;
57
+ /**
58
+ * Add the currently-running graph's `agent` shell + abort `signal` to the
59
+ * active context WITHOUT touching executionId / parentExecutionId / depth.
60
+ *
61
+ * The engine wraps each node's execute() in this so a node that hand-rolls
62
+ * `dispatchSubgraph(slug, { input })` — the documented fan-out pattern — gets
63
+ * the parent agent + cancel signal AUTOMATICALLY, exactly like the built-in
64
+ * sub-workflow node form already does. Without it, a hand-rolled dispatch ran
65
+ * the in-process child with no agent (LLM nodes fail) or fell back to HTTP.
66
+ * Explicitly-passed `parentAgent`/`signal` still win — this only fills the gap.
67
+ */
68
+ export declare function withAgentContext(agent: any, signal: any, fn: any): unknown;
43
69
  /**
44
70
  * Synchronously initialize the root execution context. Use this at the
45
71
  * very top of the CLI entrypoint — `runInContext` is the preferred call
@@ -50,4 +76,4 @@ export function runInContext<T>(ctx: {
50
76
  * the entrypoint code read naturally and to document the "top-level"
51
77
  * intent.
52
78
  */
53
- export function withRootContext(ctx: any, fn: any): any;
79
+ export declare function withRootContext(ctx: any, fn: any): unknown;
@@ -1 +1 @@
1
- import{AsyncLocalStorage as d}from"node:async_hooks";var t=new d;function c(){let e=t.getStore();return e||Object.freeze({executionId:process.env.EXECUTION_ID||null,parentExecutionId:process.env.PARENT_EXECUTION_ID||null,depth:0,conversationId:process.env.ZIBBY_CONVERSATION_ID||null,dispatchMode:process.env.DISPATCH_MODE||null})}function i(e,o){let n=t.getStore()||c(),r=Object.freeze({executionId:e.executionId,parentExecutionId:e.parentExecutionId??n.executionId??null,depth:(n.depth||0)+(e.executionId!==n.executionId?1:0),conversationId:e.conversationId!==void 0?e.conversationId:n.conversationId??null,dispatchMode:e.dispatchMode??null});return t.run(r,o)}function I(e,o){return t.run(Object.freeze({executionId:e.executionId,parentExecutionId:e.parentExecutionId??null,depth:0,conversationId:e.conversationId??null,dispatchMode:e.dispatchMode??"cold"}),o)}export{c as getExecContext,i as runInContext,I as withRootContext};
1
+ import{AsyncLocalStorage as i}from"node:async_hooks";var t=new i;function l(){let n=t.getStore();return n||Object.freeze({executionId:process.env.EXECUTION_ID||null,parentExecutionId:process.env.PARENT_EXECUTION_ID||null,depth:0,conversationId:process.env.ZIBBY_CONVERSATION_ID||null,dispatchMode:process.env.DISPATCH_MODE||null,agent:null,signal:null})}function d(n,o){let e=t.getStore()||l(),r=Object.freeze({executionId:n.executionId,parentExecutionId:n.parentExecutionId??e.executionId??null,depth:(e.depth||0)+(n.executionId!==e.executionId?1:0),conversationId:n.conversationId!==void 0?n.conversationId:e.conversationId??null,dispatchMode:n.dispatchMode??null,agent:n.agent!==void 0?n.agent:e.agent??null,signal:n.signal!==void 0?n.signal:e.signal??null});return t.run(r,o)}function s(n,o,e){let r=t.getStore()||l(),u=Object.freeze({...r,agent:n??r.agent??null,signal:o??r.signal??null});return t.run(u,e)}function c(n,o){return t.run(Object.freeze({executionId:n.executionId,parentExecutionId:n.parentExecutionId??null,depth:0,conversationId:n.conversationId??null,dispatchMode:n.dispatchMode??"cold",agent:n.agent??null,signal:n.signal??null}),o)}export{l as getExecContext,d as runInContext,s as withAgentContext,c as withRootContext};
@@ -1,10 +1,10 @@
1
- export function compileGraph(config: any, options?: {}): WorkflowGraph;
2
- export function validateGraphConfig(config: any): {
1
+ import { WorkflowGraph } from './graph.js';
2
+ export declare function compileGraph(config: any, options?: any): WorkflowGraph;
3
+ export declare function validateGraphConfig(config: any): {
3
4
  valid: boolean;
4
- errors: string[];
5
+ errors: any[];
5
6
  };
6
- export function extractSteps(config: any): any;
7
- export class CompilationError extends Error {
7
+ export declare function extractSteps(config: any): any;
8
+ export declare class CompilationError extends Error {
8
9
  constructor(message: any);
9
10
  }
10
- import { WorkflowGraph } from './graph.js';