@zibby/agent-workflow 0.6.6 → 2.0.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.
@@ -51,6 +51,31 @@ export declare function listStrategies(): any;
51
51
  * config is one more chance to drift; this wires the last container-side one.
52
52
  */
53
53
  export declare function resolveInvocationModel({ config, options, strategyName, envModel, nodeConfigModel }?: any): any;
54
+ /**
55
+ * The per-invocation PASSTHROUGH options — the fields a strategy needs that are
56
+ * sourced from (in order) the explicit per-call options, the run state, then the
57
+ * node context. ONE implementation, imported by every invokeAgent.
58
+ *
59
+ * WHY IT IS A SHARED FUNCTION: this package's invokeAgent (the engine path) and
60
+ * @zibby/core's invokeAgent (what a template CODE NODE imports) each built this
61
+ * object by hand, and the two lists drifted — core's never carried
62
+ * `extraMcpServers` at all, so an agent's custom MCP servers reached prompt
63
+ * nodes and silently vanished for every code node. Found live 2026-08-18: a
64
+ * browser MCP server attached to frontend-specialist, resolved by the executor,
65
+ * delivered into the run container, parsed by the CLI onto
66
+ * state.extraMcpServers — and then dropped one line before the strategy, so the
67
+ * QA node reported "no browser tools". Same executor-drift class as the model
68
+ * chain (resolveInvocationModel, above), same cure: derive, don't duplicate.
69
+ * A field added here now reaches BOTH paths by construction.
70
+ */
71
+ export declare function resolveInvocationExtras({ options, stateView, context }?: any): {
72
+ workspace: any;
73
+ schema: any;
74
+ images: any;
75
+ skills: any;
76
+ extraMcpServers: any;
77
+ plugins: any;
78
+ };
54
79
  export declare function getAgentStrategy(context?: any): any;
55
80
  /**
56
81
  * Invoke an agent with automatic strategy selection.
@@ -1,17 +1,17 @@
1
- var x=()=>{},M={debug:x,info:x,warn:(...e)=>console.warn("[workflow]",...e),error:(...e)=>console.error("[workflow]",...e)},k={impl:M};var S={debug:(...e)=>k.impl.debug?.(...e),info:(...e)=>k.impl.info?.(...e),warn:(...e)=>k.impl.warn?.(...e),error:(...e)=>k.impl.error?.(...e)};var T=Symbol.for("@zibby/agent-workflow.skills"),A=Symbol.for("@zibby/agent-workflow.skills.sources");globalThis[T]||(globalThis[T]=new Map);globalThis[A]||(globalThis[A]=new Map);var P=globalThis[T],G=globalThis[A];function R(e){return P.get(e)||null}var I=Symbol.for("@zibby/agent-workflow.strategies");globalThis[I]||(globalThis[I]=[]);var p=globalThis[I];function F(e){if(!e||typeof e.getName!="function"||typeof e.invoke!="function")throw new Error("strategy must implement getName() and invoke() (AgentStrategy shape)");let t=p.findIndex(n=>n.getName()===e.getName());t>=0?p[t]=e:p.push(e)}function H(){return p.map(e=>e.getName())}function j({config:e={},options:t={},strategyName:n,envModel:r,nodeConfigModel:l}={}){let i=e.models||{},g=typeof l=="string"&&l.trim()&&l.trim()!=="auto"?l.trim():null,f=t.nodeName&&i[t.nodeName]||null,y=i.default||null,E=e.agent?.[n]?.model||null,N=(typeof r=="string"?r.trim():"")||null;return g||f||y||E||t.model||N||null}function L(e={}){let{state:t={},preferredAgent:n=null}=e,r=n||t.agentType||process.env.AGENT_TYPE;if(!r){let i=p.map(g=>g.getName()).join(", ")||"none registered";throw new Error(`No agent specified. Set agentType in state or AGENT_TYPE env var. Available: ${i}`)}S.debug(`[workflow] agent selection: requested=${r}`);let l=p.find(i=>i.getName()===r);if(!l){let i=p.map(g=>g.getName()).join(", ")||"none registered";throw new Error(`Unknown agent '${r}'. Available: ${i}`)}if(!l.canHandle(e))throw new Error(`Agent '${r}' is not available in this environment. Check credentials/environment.`);return S.debug(`[workflow] using agent: ${l.getName()}`),l}async function U(e,t={},n={}){let r=t.state&&typeof t.state.getAll=="function"?t.state.getAll():t.state||{},l={...t,state:r},i=L(l),g=r.config||n.config||{},f=r._currentNodeConfig||{},y=typeof f.agent=="string"?f.agent.trim():"",E=!y||y===i.name?f.model:null,N=j({config:g,options:n,strategyName:i.name,envModel:process.env.MODEL,nodeConfigModel:E}),O={...n,model:N,workspace:r.workspace||n.workspace,schema:n.schema||t.schema,images:n.images||t.images||[],skills:n.skills||t.skills||[],extraMcpServers:n.extraMcpServers||r.extraMcpServers||t.extraMcpServers||[],plugins:n.plugins||t.plugins||[],config:g},u=e,$=O.skills||[];if($.length>0&&!n.skipPromptFragments){let m=n.connectedIntegrations;if(!m){let s=process.env.WORKFLOW_CONNECTED_INTEGRATIONS;if(typeof s=="string"&&s.trim()!==""){m={};for(let a of s.split(",").map(c=>c.trim()).filter(Boolean))m[a]=!0}}let v=s=>{let a=s&&s.requiresIntegration;return!a||!m?!0:(Array.isArray(a)?a:[a]).some(b=>m[b]===!0)},o=i.name==="assistant",h=s=>s?.inProcessOnly!==!0||o,w=$.map(s=>{let a=R(s);if(!v(a)||!h(a))return null;let c=a?.promptFragment;return typeof c=="function"?c():c}).filter(Boolean);w.length>0&&(u+=`
1
+ var _=()=>{},M={debug:_,info:_,warn:(...e)=>console.warn("[workflow]",...e),error:(...e)=>console.error("[workflow]",...e)},k={impl:M};var S={debug:(...e)=>k.impl.debug?.(...e),info:(...e)=>k.impl.info?.(...e),warn:(...e)=>k.impl.warn?.(...e),error:(...e)=>k.impl.error?.(...e)};var T=Symbol.for("@zibby/agent-workflow.skills"),A=Symbol.for("@zibby/agent-workflow.skills.sources");globalThis[T]||(globalThis[T]=new Map);globalThis[A]||(globalThis[A]=new Map);var P=globalThis[T],D=globalThis[A];function R(e){return P.get(e)||null}var I=Symbol.for("@zibby/agent-workflow.strategies");globalThis[I]||(globalThis[I]=[]);var m=globalThis[I];function U(e){if(!e||typeof e.getName!="function"||typeof e.invoke!="function")throw new Error("strategy must implement getName() and invoke() (AgentStrategy shape)");let t=m.findIndex(n=>n.getName()===e.getName());t>=0?m[t]=e:m.push(e)}function V(){return m.map(e=>e.getName())}function j({config:e={},options:t={},strategyName:n,envModel:r,nodeConfigModel:l}={}){let i=e.models||{},g=typeof l=="string"&&l.trim()&&l.trim()!=="auto"?l.trim():null,f=t.nodeName&&i[t.nodeName]||null,y=i.default||null,E=e.agent?.[n]?.model||null,v=(typeof r=="string"?r.trim():"")||null;return g||f||y||E||t.model||v||null}function L({options:e={},stateView:t={},context:n={}}={}){return{workspace:t.workspace||e.workspace,schema:e.schema||n.schema,images:e.images||n.images||[],skills:e.skills||n.skills||[],extraMcpServers:e.extraMcpServers||t.extraMcpServers||n.extraMcpServers||[],plugins:e.plugins||n.plugins||[]}}function C(e={}){let{state:t={},preferredAgent:n=null}=e,r=n||t.agentType||process.env.AGENT_TYPE;if(!r){let i=m.map(g=>g.getName()).join(", ")||"none registered";throw new Error(`No agent specified. Set agentType in state or AGENT_TYPE env var. Available: ${i}`)}S.debug(`[workflow] agent selection: requested=${r}`);let l=m.find(i=>i.getName()===r);if(!l){let i=m.map(g=>g.getName()).join(", ")||"none registered";throw new Error(`Unknown agent '${r}'. Available: ${i}`)}if(!l.canHandle(e))throw new Error(`Agent '${r}' is not available in this environment. Check credentials/environment.`);return S.debug(`[workflow] using agent: ${l.getName()}`),l}async function B(e,t={},n={}){let r=t.state&&typeof t.state.getAll=="function"?t.state.getAll():t.state||{},l={...t,state:r},i=C(l),g=r.config||n.config||{},f=r._currentNodeConfig||{},y=typeof f.agent=="string"?f.agent.trim():"",E=!y||y===i.name?f.model:null,v=j({config:g,options:n,strategyName:i.name,envModel:process.env.MODEL,nodeConfigModel:E}),O={...n,model:v,...L({options:n,stateView:r,context:t}),config:g},u=e,$=O.skills||[];if($.length>0&&!n.skipPromptFragments){let p=n.connectedIntegrations;if(!p){let s=process.env.WORKFLOW_CONNECTED_INTEGRATIONS;if(typeof s=="string"&&s.trim()!==""){p={};for(let a of s.split(",").map(c=>c.trim()).filter(Boolean))p[a]=!0}}let N=s=>{let a=s&&s.requiresIntegration;return!a||!p?!0:(Array.isArray(a)?a:[a]).some(b=>p[b]===!0)},o=i.name==="assistant",h=s=>s?.inProcessOnly!==!0||o,w=$.map(s=>{let a=R(s);if(!N(a)||!h(a))return null;let c=a?.promptFragment;return typeof c=="function"?c():c}).filter(Boolean);w.length>0&&(u+=`
2
2
 
3
3
  ${w.join(`
4
4
 
5
- `)}`)}let d=r._currentNodeConfig?.stores;if(Array.isArray(d)&&d.length>0&&typeof d[0]=="object"){let m=d.length<=8,v=d.map(o=>{let h=o?.id??o?.storeId??"",w=(o?.name??"").toString().trim()||h,s=o?.type?` \xB7 ${o.type}`:"",a=(o?.description||"").toString().replace(/\s+/g," ").trim(),c=`- ${w} \xB7 ${a||"(no description)"}${s} (id: ${h})`;if(m&&o?.schema&&typeof o.schema=="object"){let b=o.schema.properties&&typeof o.schema.properties=="object"?Object.keys(o.schema.properties):Object.keys(o.schema);b.length&&(c+=`
5
+ `)}`)}let d=r._currentNodeConfig?.stores;if(Array.isArray(d)&&d.length>0&&typeof d[0]=="object"){let p=d.length<=8,N=d.map(o=>{let h=o?.id??o?.storeId??"",w=(o?.name??"").toString().trim()||h,s=o?.type?` \xB7 ${o.type}`:"",a=(o?.description||"").toString().replace(/\s+/g," ").trim(),c=`- ${w} \xB7 ${a||"(no description)"}${s} (id: ${h})`;if(p&&o?.schema&&typeof o.schema=="object"){let b=o.schema.properties&&typeof o.schema.properties=="object"?Object.keys(o.schema.properties):Object.keys(o.schema);b.length&&(c+=`
6
6
  fields: ${b.join(", ")}`)}return c});u+=`
7
7
 
8
8
  AVAILABLE STORES (pick a store by its description and pass its NAME to the store tool):
9
- ${v.join(`
10
- `)}`}let _=r._currentNodeConfig?.extraPromptInstructions?.trim();return _&&(u+=`
9
+ ${N.join(`
10
+ `)}`}let x=r._currentNodeConfig?.extraPromptInstructions?.trim();return x&&(u+=`
11
11
 
12
12
  \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
13
13
  PRIORITY OVERRIDE \u2014 THE FOLLOWING INSTRUCTIONS TAKE PRECEDENCE OVER ALL PREVIOUS CONTENT
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
- ${_}
17
- `),S.debug(`[workflow] prompt length: ${u.length} chars`),i.invoke(u,O)}export{L as getAgentStrategy,U as invokeAgent,H as listStrategies,F as registerStrategy,j as resolveInvocationModel};
16
+ ${x}
17
+ `),S.debug(`[workflow] prompt length: ${u.length} chars`),i.invoke(u,O)}export{C as getAgentStrategy,B as invokeAgent,V as listStrategies,U as registerStrategy,L as resolveInvocationExtras,j as resolveInvocationModel};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/agent-workflow",
3
- "version": "0.6.6",
3
+ "version": "2.0.0",
4
4
  "description": "Graph-based AI agent workflow orchestration. Bring your own agent strategies.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",