@zibby/agent-workflow 0.4.35 → 0.4.37

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.
@@ -11,6 +11,13 @@
11
11
  * @param {string} [skill.cursorKey] - Override key for ~/.cursor/mcp.json
12
12
  * @param {Function} [skill.promptFragment] - () => string | string injected into agent prompt
13
13
  * @param {Function} [skill.middleware] - async () => middlewareFn | null
14
+ * @param {Object} [opts]
15
+ * @param {string} [opts.source] - Provenance (package name) registering this skill.
16
+ * The Phase-3 loader tags each package's skills with
17
+ * its name; first-party callers omit it (trusted).
18
+ * @param {boolean} [opts.override] - Explicit escape hatch: replace an existing id even
19
+ * across sources. First-party / intentional only.
20
+ * @throws if a DIFFERENT source tries to overwrite an already-registered id (collision).
14
21
  */
15
22
  export function registerSkill(skill: {
16
23
  id: string;
@@ -23,11 +30,22 @@ export function registerSkill(skill: {
23
30
  cursorKey?: string;
24
31
  promptFragment?: Function;
25
32
  middleware?: Function;
33
+ }, opts?: {
34
+ source?: string;
35
+ override?: boolean;
26
36
  }): void;
27
37
  /** @returns {object|null} */
28
38
  export function getSkill(id: any): object | null;
29
39
  /** @returns {boolean} */
30
40
  export function hasSkill(id: any): boolean;
41
+ /**
42
+ * The provenance (package name) that registered an id, or `null` for a
43
+ * first-party (untagged) registration / an unknown id. Lets the runtime decide
44
+ * secret-scoping: a skill with a non-null third-party source must NOT receive
45
+ * ambient tenant tokens / the egress JWT (Phase-3 secret-scoping prereq).
46
+ * @returns {string|null}
47
+ */
48
+ export function getSkillSource(id: any): string | null;
31
49
  /** @returns {Map<string, object>} shallow copy */
32
50
  export function getAllSkills(): Map<string, object>;
33
51
  /** @returns {string[]} */
@@ -1 +1 @@
1
- var e=Symbol.for("@zibby/agent-workflow.skills");globalThis[e]||(globalThis[e]=new Map);var r=globalThis[e];function i(t){if(!t||typeof t.id!="string")throw new Error("Skill definition must include a string id");r.set(t.id,Object.freeze({...t}))}function n(t){return r.get(t)||null}function l(t){return r.has(t)}function o(){return new Map(r)}function s(){return Array.from(r.keys())}function f(){r.clear()}export{f as clearSkills,o as getAllSkills,n as getSkill,l as hasSkill,s as listSkillIds,i as registerSkill};
1
+ var n=Symbol.for("@zibby/agent-workflow.skills"),s=Symbol.for("@zibby/agent-workflow.skills.sources");globalThis[n]||(globalThis[n]=new Map);globalThis[s]||(globalThis[s]=new Map);var r=globalThis[n],i=globalThis[s];function g(e,a={}){if(!e||typeof e.id!="string")throw new Error("Skill definition must include a string id");let{source:o,override:c=!1}=a,t=e.id;if(r.has(t)&&!c){let l=i.get(t);if(!(l===o)){let f=l||"first-party",u=o||"first-party";throw new Error(`Skill id collision: "${t}" is already registered by ${f}; ${u} may not overwrite it. Ids are append-only and first-party ids cannot be shadowed. Pick a unique id (or pass { override: true } for a deliberate first-party replacement).`)}}r.set(t,Object.freeze({...e})),o===void 0?i.delete(t):i.set(t,o)}function p(e){return r.get(e)||null}function b(e){return r.has(e)}function y(e){return i.get(e)||null}function S(){return new Map(r)}function w(){return Array.from(r.keys())}function h(){r.clear(),i.clear()}export{h as clearSkills,S as getAllSkills,p as getSkill,y as getSkillSource,b as hasSkill,w as listSkillIds,g as registerSkill};
@@ -1,17 +1,17 @@
1
- var T=()=>{},x={debug:T,info:T,warn:(...e)=>console.warn("[workflow]",...e),error:(...e)=>console.error("[workflow]",...e)},p={impl:x};var f={debug:(...e)=>p.impl.debug?.(...e),info:(...e)=>p.impl.info?.(...e),warn:(...e)=>p.impl.warn?.(...e),error:(...e)=>p.impl.error?.(...e)};var d=Symbol.for("@zibby/agent-workflow.skills");globalThis[d]||(globalThis[d]=new Map);var P=globalThis[d];function A(e){return P.get(e)||null}var h=Symbol.for("@zibby/agent-workflow.strategies");globalThis[h]||(globalThis[h]=[]);var l=globalThis[h];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 o=l.findIndex(n=>n.getName()===e.getName());o>=0?l[o]=e:l.push(e)}function F(){return l.map(e=>e.getName())}function C(e={}){let{state:o={},preferredAgent:n=null}=e,r=n||o.agentType||process.env.AGENT_TYPE;if(!r){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}`)}f.debug(`[workflow] agent selection: requested=${r}`);let a=l.find(i=>i.getName()===r);if(!a){let i=l.map(s=>s.getName()).join(", ")||"none registered";throw new Error(`Unknown agent '${r}'. Available: ${i}`)}if(!a.canHandle(e))throw new Error(`Agent '${r}' is not available in this environment. Check credentials/environment.`);return f.debug(`[workflow] using agent: ${a.getName()}`),a}async function K(e,o={},n={}){let r=o.state&&typeof o.state.getAll=="function"?o.state.getAll():o.state||{},a={...o,state:r},i=C(a),s=r.config||n.config||{},w=s.models||{},$=n.nodeName&&w[n.nodeName]||null,v=w.default||null,I=s.agent?.[i.name]?.model||null,_=$||v||I||n.model||null,k={...n,model:_,workspace:r.workspace||n.workspace,schema:n.schema||o.schema,images:n.images||o.images||[],skills:n.skills||o.skills||[],plugins:n.plugins||o.plugins||[],config:s},c=e,b=k.skills||[];if(b.length>0&&!n.skipPromptFragments){let m=b.map(u=>{let t=A(u)?.promptFragment;return typeof t=="function"?t():t}).filter(Boolean);m.length>0&&(c+=`
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+=`
2
2
 
3
- ${m.join(`
3
+ ${p.join(`
4
4
 
5
- `)}`)}let g=r._currentNodeConfig?.stores;if(Array.isArray(g)&&g.length>0&&typeof g[0]=="object"){let m=g.length<=8,u=g.map(t=>{let E=t?.id??t?.storeId??"",O=(t?.name??"").toString().trim()||E,R=t?.type?` \xB7 ${t.type}`:"",j=(t?.description||"").toString().replace(/\s+/g," ").trim(),S=`- ${O} \xB7 ${j||"(no description)"}${R} (id: ${E})`;if(m&&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&&(S+=`
6
- fields: ${N.join(", ")}`)}return S});c+=`
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+=`
7
7
 
8
8
  AVAILABLE STORES (pick a store by its description and pass its NAME to the store tool):
9
- ${u.join(`
10
- `)}`}let y=r._currentNodeConfig?.extraPromptInstructions?.trim();return y&&(c+=`
9
+ ${d.join(`
10
+ `)}`}let S=o._currentNodeConfig?.extraPromptInstructions?.trim();return S&&(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
- ${y}
17
- `),f.debug(`[workflow] prompt length: ${c.length} chars`),i.invoke(c,k)}export{C as getAgentStrategy,K as invokeAgent,F as listStrategies,D as registerStrategy};
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};
@@ -1 +1 @@
1
- var f=Symbol.for("@zibby/agent-workflow.skills");globalThis[f]||(globalThis[f]=new Map);var d=globalThis[f];function u(o){return d.get(o)||null}var p=()=>{},w={debug:p,info:p,warn:(...o)=>console.warn("[workflow]",...o),error:(...o)=>console.error("[workflow]",...o)},l={impl:w};var g={debug:(...o)=>l.impl.debug?.(...o),info:(...o)=>l.impl.info?.(...o),warn:(...o)=>l.impl.warn?.(...o),error:(...o)=>l.impl.error?.(...o)};var k={};function S(o,t){if(Array.isArray(t))return m(t);let n=k[o];return!n||n.length===0?null:m(n)}function m(o){if(!Array.isArray(o)||o.length===0)return null;let t=[],n={},s=[];for(let i of o){let e=u(i);if(!e){g.warn(`[workflow] unknown skill "${i}" \u2014 skipping`);continue}s.push(i);for(let r of e.tools||[])t.push({name:r.name,description:r.description,input_schema:r.input_schema||{type:"object",properties:{}}});if(!n[e.serverName])if(typeof e.resolve=="function"){let r=e.resolve();r&&(n[e.serverName]={...r,toolPrefix:i})}else{let r={};for(let c of e.envKeys||[]){let a=process.env[c];a&&(r[c]=a)}n[e.serverName]={command:e.command,args:[...e.args||[]],env:r,toolPrefix:i}}}return s.length===0?null:{toolIds:s,claudeTools:t,mcpServers:n}}export{k as NODE_DEFAULT_TOOLS,m as getResolvedToolDefinitions,S as resolveNodeTools};
1
+ var a=Symbol.for("@zibby/agent-workflow.skills"),c=Symbol.for("@zibby/agent-workflow.skills.sources");globalThis[a]||(globalThis[a]=new Map);globalThis[c]||(globalThis[c]=new Map);var w=globalThis[a],k=globalThis[c];function p(e){return w.get(e)||null}var g=()=>{},y={debug:g,info:g,warn:(...e)=>console.warn("[workflow]",...e),error:(...e)=>console.error("[workflow]",...e)},s={impl:y};var d={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 b={};function T(e,t){if(Array.isArray(t))return m(t);let n=b[e];return!n||n.length===0?null:m(n)}function m(e){if(!Array.isArray(e)||e.length===0)return null;let t=[],n={},l=[];for(let i of e){let o=p(i);if(!o){d.warn(`[workflow] unknown skill "${i}" \u2014 skipping`);continue}l.push(i);for(let r of o.tools||[])t.push({name:r.name,description:r.description,input_schema:r.input_schema||{type:"object",properties:{}}});if(!n[o.serverName])if(typeof o.resolve=="function"){let r=o.resolve();r&&(n[o.serverName]={...r,toolPrefix:i})}else{let r={};for(let f of o.envKeys||[]){let u=process.env[f];u&&(r[f]=u)}n[o.serverName]={command:o.command,args:[...o.args||[]],env:r,toolPrefix:i}}}return l.length===0?null:{toolIds:l,claudeTools:t,mcpServers:n}}export{b as NODE_DEFAULT_TOOLS,m as getResolvedToolDefinitions,T as resolveNodeTools};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/agent-workflow",
3
- "version": "0.4.35",
3
+ "version": "0.4.37",
4
4
  "description": "Graph-based AI agent workflow orchestration. Bring your own agent strategies.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",