agentix-cli 0.220.0 → 0.221.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.
- package/dist/{agent-UDKXN4QV.js → agent-DXKDG4DQ.js} +2 -2
- package/dist/{board-dashboard-CZXKVKK7.js → board-dashboard-QV7OD4SO.js} +4 -4
- package/dist/{board-dashboard-CZXKVKK7.js.map → board-dashboard-QV7OD4SO.js.map} +1 -1
- package/dist/chunk-3323WFVK.js +13 -0
- package/dist/chunk-3323WFVK.js.map +1 -0
- package/dist/{chunk-RHNOMUYZ.js → chunk-575LJSX2.js} +3 -3
- package/dist/{chunk-XQH4LCZR.js → chunk-74MHOALB.js} +2 -2
- package/dist/{chunk-5XN2OMBS.js → chunk-AAPHOKWS.js} +2 -2
- package/dist/{chunk-3XS7M5LM.js → chunk-AAQOXNLE.js} +260 -260
- package/dist/chunk-AAQOXNLE.js.map +1 -0
- package/dist/chunk-EFXZACH4.js +2 -0
- package/dist/chunk-EFXZACH4.js.map +1 -0
- package/dist/chunk-FG2FPOML.js +2 -0
- package/dist/chunk-FG2FPOML.js.map +1 -0
- package/dist/{chunk-5RCWAXVK.js → chunk-FRYEUVYD.js} +21 -21
- package/dist/chunk-FRYEUVYD.js.map +1 -0
- package/dist/{chunk-SYIDD7CI.js → chunk-KQ3LPQ2Z.js} +2 -2
- package/dist/{chunk-M6TZ7IIJ.js → chunk-LO5A3VKY.js} +2 -2
- package/dist/{chunk-PSUOF7O5.js → chunk-O4EQAPBB.js} +2 -2
- package/dist/{chunk-E3SA7KIZ.js → chunk-RMB6G7X2.js} +2 -2
- package/dist/{chunk-5CUOKXOD.js → chunk-VYNM7HYU.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{doctor-PLN3QJE4.js → doctor-AW53DQDU.js} +2 -2
- package/dist/{follow-up-tool-LS4OUMLZ.js → follow-up-tool-N5U7U5WN.js} +2 -2
- package/dist/{grants-ZA35QVTX.js → grants-AIUWETYP.js} +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{org-tool-NVCSDX4I.js → org-tool-VNDHR7WM.js} +2 -2
- package/dist/{program-BRFPOZLO.js → program-Q4DXWAQU.js} +8 -8
- package/dist/{program-BRFPOZLO.js.map → program-Q4DXWAQU.js.map} +1 -1
- package/dist/registry-Q3H6QR6Q.js +2 -0
- package/dist/runner-KWSARUS4.js +2 -0
- package/dist/{sprint-tool-B2LNMNPB.js → sprint-tool-5NJYOFIZ.js} +2 -2
- package/dist/step-proof-GLY7XVPD.js +2 -0
- package/dist/{tool-OVW6DDOO.js → tool-2DOU5XCQ.js} +2 -2
- package/dist/tool-AR4BLSYC.js +1 -1
- package/dist/{tool-EG6PL6NM.js → tool-ZSNE7YWS.js} +2 -2
- package/dist/{workspace-setup-CQ5FMT2B.js → workspace-setup-W32C7WXN.js} +2 -2
- package/dist/workspace-setup-W32C7WXN.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-3XS7M5LM.js.map +0 -1
- package/dist/chunk-5RCWAXVK.js.map +0 -1
- package/dist/chunk-BXK5S2KK.js +0 -13
- package/dist/chunk-BXK5S2KK.js.map +0 -1
- package/dist/chunk-SZDACK6O.js +0 -2
- package/dist/chunk-SZDACK6O.js.map +0 -1
- package/dist/registry-3J5U67DS.js +0 -2
- package/dist/runner-56G3N7M4.js +0 -2
- /package/dist/{agent-UDKXN4QV.js.map → agent-DXKDG4DQ.js.map} +0 -0
- /package/dist/{chunk-RHNOMUYZ.js.map → chunk-575LJSX2.js.map} +0 -0
- /package/dist/{chunk-XQH4LCZR.js.map → chunk-74MHOALB.js.map} +0 -0
- /package/dist/{chunk-5XN2OMBS.js.map → chunk-AAPHOKWS.js.map} +0 -0
- /package/dist/{chunk-SYIDD7CI.js.map → chunk-KQ3LPQ2Z.js.map} +0 -0
- /package/dist/{chunk-M6TZ7IIJ.js.map → chunk-LO5A3VKY.js.map} +0 -0
- /package/dist/{chunk-PSUOF7O5.js.map → chunk-O4EQAPBB.js.map} +0 -0
- /package/dist/{chunk-E3SA7KIZ.js.map → chunk-RMB6G7X2.js.map} +0 -0
- /package/dist/{chunk-5CUOKXOD.js.map → chunk-VYNM7HYU.js.map} +0 -0
- /package/dist/{doctor-PLN3QJE4.js.map → doctor-AW53DQDU.js.map} +0 -0
- /package/dist/{follow-up-tool-LS4OUMLZ.js.map → follow-up-tool-N5U7U5WN.js.map} +0 -0
- /package/dist/{grants-ZA35QVTX.js.map → grants-AIUWETYP.js.map} +0 -0
- /package/dist/{org-tool-NVCSDX4I.js.map → org-tool-VNDHR7WM.js.map} +0 -0
- /package/dist/{registry-3J5U67DS.js.map → registry-Q3H6QR6Q.js.map} +0 -0
- /package/dist/{runner-56G3N7M4.js.map → runner-KWSARUS4.js.map} +0 -0
- /package/dist/{sprint-tool-B2LNMNPB.js.map → sprint-tool-5NJYOFIZ.js.map} +0 -0
- /package/dist/{workspace-setup-CQ5FMT2B.js.map → step-proof-GLY7XVPD.js.map} +0 -0
- /package/dist/{tool-OVW6DDOO.js.map → tool-2DOU5XCQ.js.map} +0 -0
- /package/dist/{tool-EG6PL6NM.js.map → tool-ZSNE7YWS.js.map} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as w,c as A,f as a}from"./chunk-FG2FPOML.js";import{exec as b}from"child_process";var g=32*1024;function l(n,r){return n.replace(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g,(o,e)=>{let t=r[e];return t==null?"":String(t)}).replace(/\$\{?([A-Z_][A-Z0-9_]*)\}?/g,(o,e)=>process.env[e]??"")}function E(n,r){let o={};for(let e of n.inputs){let t=r[e.name]??e.defaultValue;if(t===void 0||t===""){if(e.required)throw new Error(`input "${e.name}" is required`);continue}if(e.type==="number"){let s=typeof t=="number"?t:Number(t);if(!Number.isFinite(s))throw new Error(`input "${e.name}" must be a number`);t=s}else e.type==="boolean"?t=t===!0||t==="true"||t==="1"||t===1:t=String(t);o[e.name]=t}return o}async function T(n,r={},o={}){let e=Date.now(),t=E(n,r);if(n.kind==="shell")return y(n,t,e,o.stepProof);if(n.kind==="http")return x(n,t,e,o.stepProof);throw new Error(`unsupported action kind: ${n.kind}`)}function y(n,r,o,e){let t=l(n.command,r),s={...process.env};if(n.env)for(let[f,d]of Object.entries(n.env))s[f]=l(d,r);delete s[w],e&&(s[w]=e);let c=n.cwd?l(n.cwd,r):process.cwd();return new Promise(f=>{let d=!1,p=i=>{d||(d=!0,f(i))};b(t,{cwd:c,env:s,timeout:n.timeoutMs,maxBuffer:g},(i,u,m)=>{let h=a(String(u||""),e).slice(0,g),k=a(String(m||""),e).slice(0,g),R=i?i.code??1:0;p({ok:!i,output:h,errors:k||(i?a(i.message,e):void 0),status:typeof R=="number"?R:1,durationMs:Date.now()-o})})})}async function x(n,r,o,e){let t=l(n.url,r),s={},c=e&&S(t)?e:"",f={...r,[A]:c};if(n.headers)for(let[u,m]of Object.entries(n.headers))s[u]=l(m,f);let d=n.method==="GET"||n.method==="DELETE"?void 0:n.body?l(n.body,r):void 0,p=new AbortController,i=setTimeout(()=>p.abort(),n.timeoutMs);try{let u=await fetch(t,{method:n.method,headers:s,body:d,signal:p.signal,...c?{redirect:"manual"}:{}}),m=a(await u.text(),c).slice(0,g);return{ok:u.ok,output:m,status:u.status,durationMs:Date.now()-o}}catch(u){return{ok:!1,output:"",errors:a(u?.message||String(u),c),status:0,durationMs:Date.now()-o}}finally{clearTimeout(i)}}function S(n){try{let r=new URL(n).hostname.replace(/^\[|\]$/g,"");return r==="127.0.0.1"||r==="localhost"||r==="::1"}catch{return!1}}export{l as a,E as b,T as c,S as d};
|
|
2
|
+
//# sourceMappingURL=chunk-EFXZACH4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/runner.ts"],"sourcesContent":["import { exec } from \"child_process\"\nimport type { Action, ActionRunResult, ActionInput } from \"./types\"\nimport { STEP_PROOF_ENV, STEP_PROOF_TEMPLATE, maskStepProof } from \"../workflows/step-proof\"\n\n// --- Action runner ---\n//\n// Resolves {{name}} markers from `inputs` and ${VAR} from process.env,\n// then dispatches by kind:\n// - \"shell\" — exec the command (cwd-aware, env-merge)\n// - \"http\" — fetch the url with method/headers/body\n//\n// Output is capped at ~32KB so a runaway command doesn't blow up the\n// dashboard JSON response.\n\nconst MAX_OUTPUT = 32 * 1024\n\n/** Fill {{name}} markers from values; ${VAR} from process.env. */\nexport function template(s: string, values: Record<string, unknown>): string {\n return s\n .replace(/\\{\\{\\s*([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\}\\}/g, (_, name) => {\n const v = values[name]\n return v === undefined || v === null ? \"\" : String(v)\n })\n .replace(/\\$\\{?([A-Z_][A-Z0-9_]*)\\}?/g, (_, name) => process.env[name] ?? \"\")\n}\n\n/** Validate inputs against the action's declared schema, applying defaults\n * and rejecting missing required fields. Returns the cleaned values\n * (booleans/numbers coerced from string CLI input). */\nexport function resolveInputs(action: Action, raw: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {}\n for (const def of action.inputs as ActionInput[]) {\n let v: unknown = raw[def.name] ?? def.defaultValue\n if (v === undefined || v === \"\") {\n if (def.required) throw new Error(`input \"${def.name}\" is required`)\n continue\n }\n if (def.type === \"number\") {\n const n = typeof v === \"number\" ? v : Number(v)\n if (!Number.isFinite(n)) throw new Error(`input \"${def.name}\" must be a number`)\n v = n\n } else if (def.type === \"boolean\") {\n v = v === true || v === \"true\" || v === \"1\" || v === 1\n } else {\n v = String(v)\n }\n out[def.name] = v\n }\n return out\n}\n\nexport interface RunActionOptions {\n /** A workflow step's proof (#1849): the env var AGENTX_STEP_PROOF of a\n * shell action, `{{agentx_step_proof}}` in an http action's headers.\n * Never put into the command, url or body, and masked in the output\n * the action returns (#1852). */\n stepProof?: string\n}\n\nexport async function runAction(action: Action, rawInputs: Record<string, unknown> = {}, opts: RunActionOptions = {}): Promise<ActionRunResult> {\n const start = Date.now()\n const values = resolveInputs(action, rawInputs)\n if (action.kind === \"shell\") return runShell(action, values, start, opts.stepProof)\n if (action.kind === \"http\") return runHttp(action, values, start, opts.stepProof)\n throw new Error(`unsupported action kind: ${(action as Action).kind}`)\n}\n\nfunction runShell(action: Extract<Action, { kind: \"shell\" }>, values: Record<string, unknown>, start: number, stepProof?: string): Promise<ActionRunResult> {\n const cmd = template(action.command, values)\n const env: NodeJS.ProcessEnv = { ...process.env }\n if (action.env) {\n for (const [k, v] of Object.entries(action.env)) env[k] = template(v, values)\n }\n // Set last, so the action's own env cannot stand in for the daemon's.\n delete env[STEP_PROOF_ENV]\n if (stepProof) env[STEP_PROOF_ENV] = stepProof\n const cwd = action.cwd ? template(action.cwd, values) : process.cwd()\n\n return new Promise<ActionRunResult>((resolve) => {\n let settled = false\n const finish = (r: ActionRunResult) => { if (settled) return; settled = true; resolve(r) }\n exec(cmd, { cwd, env, timeout: action.timeoutMs, maxBuffer: MAX_OUTPUT }, (err, stdout, stderr) => {\n // Masked before the cut; a token the buffer cut short is masked too.\n const out = maskStepProof(String(stdout || \"\"), stepProof).slice(0, MAX_OUTPUT)\n const errs = maskStepProof(String(stderr || \"\"), stepProof).slice(0, MAX_OUTPUT)\n const status = err ? (err as NodeJS.ErrnoException & { code?: number }).code ?? 1 : 0\n finish({\n ok: !err,\n output: out,\n errors: errs || (err ? maskStepProof(err.message, stepProof) : undefined),\n status: typeof status === \"number\" ? status : 1,\n durationMs: Date.now() - start,\n })\n })\n })\n}\n\nasync function runHttp(action: Extract<Action, { kind: \"http\" }>, values: Record<string, unknown>, start: number, stepProof?: string): Promise<ActionRunResult> {\n const url = template(action.url, values)\n const headers: Record<string, string> = {}\n // The proof is offered to headers only, so it never lands in a url or\n // body that may be logged; an input of the same name cannot fake it.\n // Only to this machine, so it cannot be sent off to a host a run input\n // names; and no redirect may carry it elsewhere.\n const proof = stepProof && isLoopbackUrl(url) ? stepProof : \"\"\n const headerValues = { ...values, [STEP_PROOF_TEMPLATE]: proof }\n if (action.headers) for (const [k, v] of Object.entries(action.headers)) headers[k] = template(v, headerValues)\n const body = action.method === \"GET\" || action.method === \"DELETE\" ? undefined : (action.body ? template(action.body, values) : undefined)\n const ac = new AbortController()\n const timer = setTimeout(() => ac.abort(), action.timeoutMs)\n try {\n const res = await fetch(url, { method: action.method, headers, body, signal: ac.signal, ...(proof ? { redirect: \"manual\" as const } : {}) })\n const text = maskStepProof(await res.text(), proof).slice(0, MAX_OUTPUT)\n return {\n ok: res.ok,\n output: text,\n status: res.status,\n durationMs: Date.now() - start,\n }\n } catch (e: any) {\n return {\n ok: false,\n output: \"\",\n errors: maskStepProof(e?.message || String(e), proof),\n status: 0,\n durationMs: Date.now() - start,\n }\n } finally {\n clearTimeout(timer)\n }\n}\n\n/** True for an http(s) url on this machine's loopback address. */\nexport function isLoopbackUrl(url: string): boolean {\n try {\n const h = new URL(url).hostname.replace(/^\\[|\\]$/g, \"\")\n return h === \"127.0.0.1\" || h === \"localhost\" || h === \"::1\"\n } catch {\n return false\n }\n}\n"],"mappings":"sDAAA,OAAS,QAAAA,MAAY,gBAcrB,IAAMC,EAAa,GAAK,KAGjB,SAASC,EAASC,EAAWC,EAAyC,CAC3E,OAAOD,EACJ,QAAQ,0CAA2C,CAACE,EAAGC,IAAS,CAC/D,IAAMC,EAAIH,EAAOE,CAAI,EACrB,OAA0BC,GAAM,KAAO,GAAK,OAAOA,CAAC,CACtD,CAAC,EACA,QAAQ,8BAA+B,CAACF,EAAGC,IAAS,QAAQ,IAAIA,CAAI,GAAK,EAAE,CAChF,CAKO,SAASE,EAAcC,EAAgBC,EAAuD,CACnG,IAAMC,EAA+B,CAAC,EACtC,QAAWC,KAAOH,EAAO,OAAyB,CAChD,IAAIF,EAAaG,EAAIE,EAAI,IAAI,GAAKA,EAAI,aACtC,GAAIL,IAAM,QAAaA,IAAM,GAAI,CAC/B,GAAIK,EAAI,SAAU,MAAM,IAAI,MAAM,UAAUA,EAAI,mBAAmB,EACnE,SAEF,GAAIA,EAAI,OAA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,CAAE,SAAU,QAAkB,EAAI,CAAC,CAAG,CAAC,EACrIQ,EAAOb,EAAc,MAAMY,EAAI,KAAK,EAAGP,CAAK,EAAE,MAAM,EAAGtC,CAAU,EACvE,MAAO,CACL,GAAI6C,EAAI,GACR,OAAQC,EACR,OAAQD,EAAI,OACZ,WAAY,KAAK,IAAI,EAAI7B,CAC3B,CACF,OAAS+B,EAAP,CACA,MAAO,CACL,GAAI,GACJ,OAAQ,GACR,OAAQd,EAAcc,GAAG,SAAW,OAAOA,CAAC,EAAGT,CAAK,EACpD,OAAQ,EACR,WAAY,KAAK,IAAI,EAAItB,CAC3B,CACF,QAAE,CACA,aAAa4B,CAAK,CACpB,CACF,CAGO,SAASL,EAAcH,EAAsB,CAClD,GAAI,CACF,IAAMY,EAAI,IAAI,IAAIZ,CAAG,EAAE,SAAS,QAAQ,WAAY,EAAE,EACtD,OAAOY,IAAM,aAAeA,IAAM,aAAeA,IAAM,KACzD,MAAE,CACA,MAAO,EACT,CACF","names":["exec","MAX_OUTPUT","template","s","values","_","name","v","resolveInputs","action","raw","out","def","n","runAction","rawInputs","opts","start","runShell","runHttp","stepProof","cmd","env","k","STEP_PROOF_ENV","cwd","resolve","settled","finish","r","exec","err","stdout","stderr","maskStepProof","errs","status","url","headers","proof","isLoopbackUrl","headerValues","STEP_PROOF_TEMPLATE","body","ac","timer","res","text","e","h"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createHash as u,randomBytes as a}from"crypto";var g="x-agentx-step",c="AGENTX_STEP_PROOF",h="agentx_step_proof",P=3e4,s="[step proof hidden]";function S(r,e){if(!e||!r)return r;let n=r.includes(e)?r.split(e).join(s):r;for(let t=e.length-1;t>=Math.min(8,e.length-1)&&t>0;t--)if(n.endsWith(e.slice(0,t))){n=n.slice(0,-t)+s;break}return n}var d=r=>u("sha256").update(r).digest("hex"),l=class{constructor(e=Date.now){this.now=e}live=new Map;mint(e,n){this.sweep();let t=a(32).toString("base64url"),o=d(t);return this.live.set(o,{...e,expiresAt:this.now()+Math.max(0,n)}),{token:t,revoke:()=>{this.live.delete(o)}}}check(e){if(typeof e!="string"||!e)return null;let n=d(e),t=this.live.get(n);return t?t.expiresAt<=this.now()?(this.live.delete(n),null):t:null}get size(){return this.live.size}sweep(){let e=this.now();for(let[n,t]of this.live)t.expiresAt<=e&&this.live.delete(n)}};function m(r,e){return({workflow:n,run:t,node:o},p)=>{let i=t.meta?.startedBy??n.ownerAgent;return!i||!e(i)?null:r.mint({runId:t.id,nodeId:o.id,workflowId:n.id,agentId:i},p)}}function I(r,e){let n=e.headers[g],t=Array.isArray(n)?n[0]:n;if(!t||!e.fromLoopback)return null;let o=r.check(t);return o?{agentId:o.agentId,runId:o.runId,nodeId:o.nodeId}:null}export{g as a,c as b,h as c,P as d,s as e,S as f,l as g,m as h,I as i};
|
|
2
|
+
//# sourceMappingURL=chunk-FG2FPOML.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/workflows/step-proof.ts"],"sourcesContent":["import { createHash, randomBytes } from \"crypto\"\n\n// --- Step proof (#1849) ---\n//\n// A workflow `action.run` step has no task and no turn, so it cannot prove\n// which agent it acts for when it calls the daemon back. The daemon mints a\n// token for the step while it runs: random, held only in this process (by\n// its SHA-256), never written to the run context, log, output or disk\n// (masked in what the step prints, #1852), and revoked when the step ends.\n// A shell action gets it in its environment, which other processes of the\n// same OS user can read while the step runs: a limit the docs state, since\n// that user can read the daemon's own files and memory anyway. The step carries it as the `X-AgentX-Step`\n// header. Only `POST /approvals/:id/resolve` accepts it, and only from\n// loopback: it proves that agent closes its own card, nothing else.\n\n/** The header a step sends its proof in. Fixed: CX callers use it. */\nexport const STEP_PROOF_HEADER = \"x-agentx-step\"\n/** The env var a shell action reads its proof from. Fixed: CX callers use it. */\nexport const STEP_PROOF_ENV = \"AGENTX_STEP_PROOF\"\n/** The value an http action names in a header to send its proof. */\nexport const STEP_PROOF_TEMPLATE = \"agentx_step_proof\"\n/** Slack past the action's own timeout before a token expires anyway. */\nexport const STEP_PROOF_GRACE_MS = 30_000\n\n/** What stands in for the token in captured step output. */\nexport const STEP_PROOF_MASK = \"[step proof hidden]\"\n\n/** Captured step output with the token taken out (#1852): a script that\n * prints its environment must not write the proof into the run log. A\n * token the output cap cut short at the very end goes too. */\nexport function maskStepProof(text: string, token: string | undefined | null): string {\n if (!token || !text) return text\n let out = text.includes(token) ? text.split(token).join(STEP_PROOF_MASK) : text\n for (let k = token.length - 1; k >= Math.min(8, token.length - 1) && k > 0; k--) {\n if (out.endsWith(token.slice(0, k))) { out = out.slice(0, -k) + STEP_PROOF_MASK; break }\n }\n return out\n}\n\nexport interface StepProofEntry {\n runId: string\n nodeId: string\n workflowId: string\n /** The agent the step acts for: run.meta.startedBy ?? workflow.ownerAgent. */\n agentId: string\n expiresAt: number\n}\n\nexport interface MintedStepProof {\n token: string\n /** Ends the proof. Safe to call more than once. */\n revoke: () => void\n}\n\nconst hash = (token: string) => createHash(\"sha256\").update(token).digest(\"hex\")\n\nexport class StepProofs {\n private readonly live = new Map<string, StepProofEntry>()\n\n constructor(private readonly now: () => number = Date.now) {}\n\n mint(entry: Omit<StepProofEntry, \"expiresAt\">, ttlMs: number): MintedStepProof {\n this.sweep()\n const token = randomBytes(32).toString(\"base64url\")\n const key = hash(token)\n this.live.set(key, { ...entry, expiresAt: this.now() + Math.max(0, ttlMs) })\n return { token, revoke: () => { this.live.delete(key) } }\n }\n\n /** The live entry a token names, or null (unknown, revoked or expired). */\n check(token: string | undefined | null): StepProofEntry | null {\n if (typeof token !== \"string\" || !token) return null\n const key = hash(token)\n const entry = this.live.get(key)\n if (!entry) return null\n if (entry.expiresAt <= this.now()) {\n this.live.delete(key)\n return null\n }\n return entry\n }\n\n get size(): number {\n return this.live.size\n }\n\n private sweep(): void {\n const t = this.now()\n for (const [k, e] of this.live) if (e.expiresAt <= t) this.live.delete(k)\n }\n}\n\n/** The minting rule the daemon uses: a step acts for the run's starter,\n * else the workflow's owner (the agent a card from the run is raised in\n * the name of). No agent of this node: no proof. */\nexport function stepProofMinter(\n proofs: StepProofs,\n hasAgent: (agentId: string) => boolean,\n): (step: { workflow: { id: string; ownerAgent?: string }; run: { id: string; meta?: { startedBy?: string } }; node: { id: string } }, ttlMs: number) => MintedStepProof | null {\n return ({ workflow, run, node }, ttlMs) => {\n const agentId = run.meta?.startedBy ?? workflow.ownerAgent\n if (!agentId || !hasAgent(agentId)) return null\n return proofs.mint({ runId: run.id, nodeId: node.id, workflowId: workflow.id, agentId }, ttlMs)\n }\n}\n\n/** The step a request proves: its X-AgentX-Step header names a live proof\n * and it comes from this machine. Null otherwise. */\nexport function provenStep(\n proofs: StepProofs,\n req: { headers: Record<string, string | string[] | undefined>; fromLoopback: boolean },\n): { agentId: string; runId: string; nodeId: string } | null {\n const v = req.headers[STEP_PROOF_HEADER]\n const token = Array.isArray(v) ? v[0] : v\n if (!token || !req.fromLoopback) return null\n const e = proofs.check(token)\n return e ? { agentId: e.agentId, runId: e.runId, nodeId: e.nodeId } : null\n}\n"],"mappings":"AAAA,OAAS,cAAAA,EAAY,eAAAC,MAAmB,SAgBjC,IAAMC,EAAoB,gBAEpBC,EAAiB,oBAEjBC,EAAsB,oBAEtBC,EAAsB,IAGtBC,EAAkB,sBAKxB,SAASC,EAAcC,EAAcC,EAA0C,CACpF,GAAI,CAACA,GAAS,CAACD,EAAM,OAAOA,EAC5B,IAAIE,EAAMF,EAAK,SAASC,CAAK,EAAID,EAAK,MAAMC,CAAK,EAAE,KAAKH,CAAe,EAAIE,EAC3E,QAASG,EAAIF,EAAM,OAAS,EAAGE,GAAK,KAAK,IAAI,EAAGF,EAAM,OAAS,CAAC,GAAKE,EAAI,EAAGA,IAC1E,GAAID,EAAI,SAASD,EAAM,MAAM,EAAGE,CAAC,CAAC,EAAG,CAAED,EAAMA,EAAI,MAAM,EAAG,CAACC,CAAC,EAAIL,EAAiB,MAEnF,OAAOI,CACT,CAiBA,IAAME,EAAQH,GAAkBT,EAAW,Q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CAChG,CACF,CAIO,SAASW,EACdN,EACAO,EAC2D,CAC3D,IAAMC,EAAID,EAAI,QAAQ1B,CAAiB,EACjCO,EAAQ,MAAM,QAAQoB,CAAC,EAAIA,EAAE,CAAC,EAAIA,EACxC,GAAI,CAACpB,GAAS,CAACmB,EAAI,aAAc,OAAO,KACxC,IAAMT,EAAIE,EAAO,MAAMZ,CAAK,EAC5B,OAAOU,EAAI,CAAE,QAASA,EAAE,QAAS,MAAOA,EAAE,MAAO,OAAQA,EAAE,MAAO,EAAI,IACxE","names":["createHash","randomBytes","STEP_PROOF_HEADER","STEP_PROOF_ENV","STEP_PROOF_TEMPLATE","STEP_PROOF_GRACE_MS","STEP_PROOF_MASK","maskStepProof","text","token","out","k","hash","StepProofs","now","entry","ttlMs","key","t","e","stepProofMinter","proofs","hasAgent","workflow","run","node","agentId","provenStep","req","v"]}
|