@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.
- package/dist/code-generator.js +18 -18
- package/dist/constants.js +1 -1
- package/dist/graph-compiler.js +16 -16
- package/dist/graph.js +15 -15
- package/dist/index.js +23 -23
- package/dist/node-registry.js +11 -11
- package/dist/node.js +18 -18
- package/dist/strategy-registry.d.ts +13 -1
- package/dist/strategy-registry.js +8 -8
- package/package.json +1 -1
|
@@ -18,7 +18,19 @@ export function listStrategies(): string[];
|
|
|
18
18
|
* @param {object} [context]
|
|
19
19
|
* @returns {AgentStrategy}
|
|
20
20
|
*/
|
|
21
|
-
|
|
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
|
|
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
|
-
${
|
|
3
|
+
${f.join(`
|
|
4
4
|
|
|
5
|
-
`)}`)}let g=o._currentNodeConfig?.stores;if(Array.isArray(g)&&g.length>0&&typeof g[0]=="object"){let
|
|
6
|
-
fields: ${
|
|
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
|
-
${
|
|
10
|
-
`)}`}let
|
|
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
|
-
${
|
|
17
|
-
`),
|
|
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};
|