@zibby/agent-workflow 0.4.37 → 0.4.39

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.
@@ -18,7 +18,19 @@ export function listStrategies(): string[];
18
18
  * @param {object} [context]
19
19
  * @returns {AgentStrategy}
20
20
  */
21
- export function getAgentStrategy(context?: object): AgentStrategy;
21
+ /**
22
+ * The ONE place an invocation's model is resolved. Chain, most-specific first:
23
+ * config.models[node] > config.models.default > config.agent[vendor].model
24
+ * > options.model (the node's explicit per-call pick, e.g. triage's cheap tier)
25
+ * Pure function so the contract is unit-tested — the o4-mini incident was this
26
+ * chain resolving to null and the strategy silently substituting its vendor
27
+ * default underneath us.
28
+ */
29
+ export function resolveInvocationModel({ config, options, strategyName, envModel }?: {
30
+ config?: {};
31
+ options?: {};
32
+ }): any;
33
+ export function getAgentStrategy(context?: {}): any;
22
34
  /**
23
35
  * Invoke an agent with automatic strategy selection.
24
36
  * @param {string} prompt
@@ -1,17 +1,17 @@
1
- var A=()=>{},P={debug:A,info:A,warn:(...e)=>console.warn("[workflow]",...e),error:(...e)=>console.error("[workflow]",...e)},f={impl:P};var m={debug:(...e)=>f.impl.debug?.(...e),info:(...e)=>f.impl.info?.(...e),warn:(...e)=>f.impl.warn?.(...e),error:(...e)=>f.impl.error?.(...e)};var u=Symbol.for("@zibby/agent-workflow.skills"),h=Symbol.for("@zibby/agent-workflow.skills.sources");globalThis[u]||(globalThis[u]=new Map);globalThis[h]||(globalThis[h]=new Map);var C=globalThis[u],G=globalThis[h];function $(e){return C.get(e)||null}var w=Symbol.for("@zibby/agent-workflow.strategies");globalThis[w]||(globalThis[w]=[]);var l=globalThis[w];function q(e){if(!e||typeof e.getName!="function"||typeof e.invoke!="function")throw new Error("strategy must implement getName() and invoke() (AgentStrategy shape)");let r=l.findIndex(n=>n.getName()===e.getName());r>=0?l[r]=e:l.push(e)}function D(){return l.map(e=>e.getName())}function L(e={}){let{state:r={},preferredAgent:n=null}=e,o=n||r.agentType||process.env.AGENT_TYPE;if(!o){let i=l.map(s=>s.getName()).join(", ")||"none registered";throw new Error(`No agent specified. Set agentType in state or AGENT_TYPE env var. Available: ${i}`)}m.debug(`[workflow] agent selection: requested=${o}`);let a=l.find(i=>i.getName()===o);if(!a){let i=l.map(s=>s.getName()).join(", ")||"none registered";throw new Error(`Unknown agent '${o}'. Available: ${i}`)}if(!a.canHandle(e))throw new Error(`Agent '${o}' is not available in this environment. Check credentials/environment.`);return m.debug(`[workflow] using agent: ${a.getName()}`),a}async function F(e,r={},n={}){let o=r.state&&typeof r.state.getAll=="function"?r.state.getAll():r.state||{},a={...r,state:o},i=L(a),s=o.config||n.config||{},b=s.models||{},v=n.nodeName&&b[n.nodeName]||null,I=b.default||null,O=s.agent?.[i.name]?.model||null,_=v||I||O||n.model||null,y={...n,model:_,workspace:o.workspace||n.workspace,schema:n.schema||r.schema,images:n.images||r.images||[],skills:n.skills||r.skills||[],plugins:n.plugins||r.plugins||[],config:s},c=e,k=y.skills||[];if(k.length>0&&!n.skipPromptFragments){let p=k.map(d=>{let t=$(d)?.promptFragment;return typeof t=="function"?t():t}).filter(Boolean);p.length>0&&(c+=`
1
+ var v=()=>{},_={debug:v,info:v,warn:(...e)=>console.warn("[workflow]",...e),error:(...e)=>console.error("[workflow]",...e)},m={impl:_};var d={debug:(...e)=>m.impl.debug?.(...e),info:(...e)=>m.impl.info?.(...e),warn:(...e)=>m.impl.warn?.(...e),error:(...e)=>m.impl.error?.(...e)};var w=Symbol.for("@zibby/agent-workflow.skills"),b=Symbol.for("@zibby/agent-workflow.skills.sources");globalThis[w]||(globalThis[w]=new Map);globalThis[b]||(globalThis[b]=new Map);var x=globalThis[w],P=globalThis[b];function A(e){return x.get(e)||null}var y=Symbol.for("@zibby/agent-workflow.strategies");globalThis[y]||(globalThis[y]=[]);var a=globalThis[y];function D(e){if(!e||typeof e.getName!="function"||typeof e.invoke!="function")throw new Error("strategy must implement getName() and invoke() (AgentStrategy shape)");let t=a.findIndex(r=>r.getName()===e.getName());t>=0?a[t]=e:a.push(e)}function H(){return a.map(e=>e.getName())}function R({config:e={},options:t={},strategyName:r,envModel:o}={}){let s=e.models||{},i=t.nodeName&&s[t.nodeName]||null,l=s.default||null,u=e.agent?.[r]?.model||null,p=(typeof o=="string"?o.trim():"")||null;return i||l||u||t.model||p||null}function j(e={}){let{state:t={},preferredAgent:r=null}=e,o=r||t.agentType||process.env.AGENT_TYPE;if(!o){let i=a.map(l=>l.getName()).join(", ")||"none registered";throw new Error(`No agent specified. Set agentType in state or AGENT_TYPE env var. Available: ${i}`)}d.debug(`[workflow] agent selection: requested=${o}`);let s=a.find(i=>i.getName()===o);if(!s){let i=a.map(l=>l.getName()).join(", ")||"none registered";throw new Error(`Unknown agent '${o}'. Available: ${i}`)}if(!s.canHandle(e))throw new Error(`Agent '${o}' is not available in this environment. Check credentials/environment.`);return d.debug(`[workflow] using agent: ${s.getName()}`),s}async function K(e,t={},r={}){let o=t.state&&typeof t.state.getAll=="function"?t.state.getAll():t.state||{},s={...t,state:o},i=j(s),l=o.config||r.config||{},u=R({config:l,options:r,strategyName:i.name,envModel:process.env.MODEL}),p={...r,model:u,workspace:o.workspace||r.workspace,schema:r.schema||t.schema,images:r.images||t.images||[],skills:r.skills||t.skills||[],plugins:r.plugins||t.plugins||[],config:l},c=e,k=p.skills||[];if(k.length>0&&!r.skipPromptFragments){let f=k.map(h=>{let n=A(h)?.promptFragment;return typeof n=="function"?n():n}).filter(Boolean);f.length>0&&(c+=`
2
2
 
3
- ${p.join(`
3
+ ${f.join(`
4
4
 
5
- `)}`)}let g=o._currentNodeConfig?.stores;if(Array.isArray(g)&&g.length>0&&typeof g[0]=="object"){let p=g.length<=8,d=g.map(t=>{let E=t?.id??t?.storeId??"",x=(t?.name??"").toString().trim()||E,R=t?.type?` \xB7 ${t.type}`:"",j=(t?.description||"").toString().replace(/\s+/g," ").trim(),T=`- ${x} \xB7 ${j||"(no description)"}${R} (id: ${E})`;if(p&&t?.schema&&typeof t.schema=="object"){let N=t.schema.properties&&typeof t.schema.properties=="object"?Object.keys(t.schema.properties):Object.keys(t.schema);N.length&&(T+=`
6
- fields: ${N.join(", ")}`)}return T});c+=`
5
+ `)}`)}let g=o._currentNodeConfig?.stores;if(Array.isArray(g)&&g.length>0&&typeof g[0]=="object"){let f=g.length<=8,h=g.map(n=>{let S=n?.id??n?.storeId??"",$=(n?.name??"").toString().trim()||S,I=n?.type?` \xB7 ${n.type}`:"",O=(n?.description||"").toString().replace(/\s+/g," ").trim(),N=`- ${$} \xB7 ${O||"(no description)"}${I} (id: ${S})`;if(f&&n?.schema&&typeof n.schema=="object"){let T=n.schema.properties&&typeof n.schema.properties=="object"?Object.keys(n.schema.properties):Object.keys(n.schema);T.length&&(N+=`
6
+ fields: ${T.join(", ")}`)}return N});c+=`
7
7
 
8
8
  AVAILABLE STORES (pick a store by its description and pass its NAME to the store tool):
9
- ${d.join(`
10
- `)}`}let S=o._currentNodeConfig?.extraPromptInstructions?.trim();return S&&(c+=`
9
+ ${h.join(`
10
+ `)}`}let E=o._currentNodeConfig?.extraPromptInstructions?.trim();return E&&(c+=`
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
- ${S}
17
- `),m.debug(`[workflow] prompt length: ${c.length} chars`),i.invoke(c,y)}export{L as getAgentStrategy,F as invokeAgent,D as listStrategies,q as registerStrategy};
16
+ ${E}
17
+ `),d.debug(`[workflow] prompt length: ${c.length} chars`),i.invoke(c,p)}export{j as getAgentStrategy,K as invokeAgent,H as listStrategies,D as registerStrategy,R as resolveInvocationModel};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/agent-workflow",
3
- "version": "0.4.37",
3
+ "version": "0.4.39",
4
4
  "description": "Graph-based AI agent workflow orchestration. Bring your own agent strategies.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",