agent-contracts-runtime 0.36.11 → 0.36.12
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/cli-contract.yaml
CHANGED
|
@@ -1109,7 +1109,7 @@ Common options for all commands:
|
|
|
1109
1109
|
|
|
1110
1110
|
info:
|
|
1111
1111
|
title: agent-runtime CLI
|
|
1112
|
-
version: 0.36.
|
|
1112
|
+
version: 0.36.12
|
|
1113
1113
|
description: |
|
|
1114
1114
|
Runtime bridge for executing agent-contracts workflows on Agent SDKs.
|
|
1115
1115
|
Generates typed contracts, handoff validators, and guardrail hooks from DSL,
|
|
@@ -2219,7 +2219,7 @@ components:
|
|
|
2219
2219
|
"cli_contracts": "0.1.0",
|
|
2220
2220
|
"info": {
|
|
2221
2221
|
"title": "agent-runtime CLI",
|
|
2222
|
-
"version": "0.36.
|
|
2222
|
+
"version": "0.36.12",
|
|
2223
2223
|
"description": "Runtime bridge for executing agent-contracts workflows on Agent SDKs.\\nGenerates typed contracts, handoff validators, and guardrail hooks from DSL,\\nthen runs workflows through pluggable SDK adapters.\\n",
|
|
2224
2224
|
"license": {
|
|
2225
2225
|
"name": "MIT"
|
|
@@ -5243,7 +5243,7 @@ Focus the audit on the "${e.focus}" layer only.`:"",r=["Audit the LLM command in
|
|
|
5243
5243
|
`+"=".repeat(72)+`
|
|
5244
5244
|
|
|
5245
5245
|
`;return{status:"dry_run",exitCode:0,data:{summary:b.join(w),riskLevel:"low",findings:[]}}}let o,s=qa._guardrailRules;s&&(s.commandRules?.length||s.fileRules?.length||s.contentRules?.length)&&(o=za(s));let l;try{l=await zke(e.adapter,n,e.model,o)}catch(v){return{status:"failed",exitCode:12,error:t.adapterError(v.message)}}console.error(t.auditStarting(e.adapter));let u={workflowRegistry:Gf,taskRegistry:Bu,agentRegistry:Ru,handoffSchemas:Lu},c={workflow:"audit-implementation",user_request:r,runtime:{maxFollowUps:2,maxRetries:1},hooks:{onGate:async()=>!0},context:{cwd:n},progressOutput:e.progressOutput},d=await Ma(l,c,u);if(d.status!=="completed"){let v=d.escalation_reason??d.error_message??d.status;return{status:"failed",exitCode:1,error:t.auditFailed(v)}}let m=d.steps[d.steps.length-1]?.outcome?.data??{summary:t.auditSuccess,riskLevel:"low",findings:[]};return{status:"success",exitCode:Uke(m,e.failOn)?10:0,data:m}}var qke={critical:"\u2717",error:"\u2717",warning:"!",info:"\xB7"};function SE(e){let t=GH();if(e.status==="dry_run")return e.data?.summary??t.dryRunHeader;if(e.status==="failed")return e.error??t.auditFailed("unknown");let n=e.data;if(!n)return t.auditSuccess;let i=[n.summary,""];if(i.push(t.riskLevel(n.riskLevel)),i.push(""),n.findings.length===0)i.push(t.noFindings);else{i.push(t.findingsHeader(n.findings.length));for(let r of n.findings){let a=qke[r.severity]??"\xB7",o=r.id?`[${r.id}] `:"",s=r.target?` (${r.target})`:"";i.push(` ${a} ${o}${r.severity.toUpperCase()}: ${r.message}${s}`),r.recommendation&&i.push(` \u2192 ${r.recommendation}`)}i.push("")}if(n.recommendedActions&&n.recommendedActions.length>0){i.push(t.recommendedActionsHeader);for(let r of n.recommendedActions){let a=r.command?` \u2014 ${r.command}`:"";i.push(` [${r.kind}] ${r.title}${a}`)}}return i.join(`
|
|
5246
|
-
`)}var Cs=to(Yo(),1);Hke();var Jke="0.36.
|
|
5246
|
+
`)}var Cs=to(Yo(),1);Hke();var Jke="0.36.12";async function AE(e){let n=`${(await ma(e)).generatedDir}/index`,i;if(CE(`${n}.js`))i=`${n}.js`;else if(CE(`${n}.ts`))i=`${n}.ts`;else throw new Error(`Generated index file not found at ${n}.{js,ts}. Run \`agent-runtime generate\` first.`);let r=await import(new URL(`file://${i}`).href),a,o=r.resolvedDsl;if(o){let s=o._guardrailRules;s&&(s.commandRules?.length||s.fileRules?.length||s.contentRules?.length)&&(a=za(s))}return{agentRegistry:r.agentRegistry??r.agents?.agentRegistry??{},taskRegistry:r.taskRegistry??r.tasks?.taskRegistry??{},handoffSchemas:r.handoffSchemas??r.handoffs?.handoffSchemas??{},workflowRegistry:r.workflowRegistry??r.workflows?.workflowRegistry??{},guardrailHooks:a,resolvedDsl:o}}async function Yke(e,t,n,i){switch(e){case"mock":{let{MockAdapter:r}=await Promise.resolve().then(()=>(Z4(),V4));return new r}case"claude":{let{ClaudeAgentSdkAdapter:r}=await Promise.resolve().then(()=>(q4(),U4));return new r({cwd:n,guardrailHooks:t,...i?{model:i}:{}})}case"gemini":{let{AdkSdkAdapter:r}=await Promise.resolve().then(()=>(JH(),HH));return new r({guardrailHooks:t,...i?{model:i}:{}})}case"openai":{let{OpenAIAgentsSdkAdapter:r}=await Promise.resolve().then(()=>(XH(),YH));return new r({guardrailHooks:t,...i?{model:i}:{}})}default:throw new Error(`Unknown adapter: ${e}. Available: mock, claude, gemini, openai`)}}function DE(e,t){let n=e.map((s,l)=>Math.max(s.length,...t.map(u=>(u[l]??"").length))),i=n.map(s=>"-".repeat(s)).join(" "),r=(s,l)=>s.padEnd(l),a=e.map((s,l)=>r(s,n[l])).join(" "),o=t.map(s=>s.map((l,u)=>r(l??"",n[u])).join(" "));return[a,i,...o].join(`
|
|
5247
5247
|
`)}function Xke(e,t,n,i){if(e)return Ua({stderr:!n,file:G4(e),naming:"single",label:i});if(t&&t.destination!=="none"){let r=t.destination;return Ua({stderr:!n&&(r==="stderr"||r==="both"),file:r==="file"||r==="both"?t.file:void 0,naming:t.naming,label:i})}if(!n)return Ua({stderr:!0})}var Qke={async init(e,t){try{let n=G4(e.output??"."),i=await MH({adapter:e.adapter??"mock",outputDir:n,force:e.force??!1});console.log(JSON.stringify(i,null,2))}catch(n){console.error(n.message),process.exit(1)}},async generate(e,t){try{let n=t.config??"./agents.conf.yaml",i=await oH({clean:e.clean,check:e.check,templates:e.templates,configPath:n});i.check_mode?(i.has_differences&&(console.error("Generated files are out of date. Run `agent-runtime generate` to update."),process.exit(1)),console.log(JSON.stringify({...i,status:"up-to-date"},null,2))):console.log(JSON.stringify(i,null,2))}catch(n){console.error("Generate failed:",n.message),process.exit(1)}},async run(e,t,n,i){let r=e,a=t,o;if(n.file)try{let x=Kke(n.file,"utf8"),j=Cs.default.parse(x);r=j.workflow,r||(console.error(`Error: invocation file "${n.file}" must contain a "workflow" field.`),process.exit(3)),o={workflow:r,user_request:j.user_request,handoff:j.handoff,runtime:j.runtime,context:j.context},a=o.user_request??""}catch(x){console.error(`Failed to read invocation file: ${x.message}`),process.exit(3)}r||(console.error("Error: workflow-id is required (provide as argument or via --file)"),process.exit(3)),!o&&!a&&(console.error("Error: user-request is required (provide as argument or via --file)"),process.exit(3));let s=i.config??"./agents.conf.yaml";await C4(s)||(console.error("Generated files are stale or missing. Run `agent-runtime generate` first."),process.exit(3));let u=await ma(s),c=await F4({pluginPaths:u.pluginPaths.length>0?u.pluginPaths:void 0,projectDir:u.configDir});c.loaded>0&&!i.quiet&&console.error(`Loaded ${c.loaded} plugin(s) from ${c.files.length} file(s)`);for(let x of c.errors)console.error(`Plugin load error (${x.file}): ${x.error}`);let d;try{d=await AE(s)}catch(x){console.error(`Failed to load generated contracts: ${x.message}`),process.exit(1);return}if(!d.workflowRegistry[r]){console.error(`Unknown workflow: ${r}`),console.error(`Available workflows: ${Object.keys(d.workflowRegistry).join(", ")}`),process.exit(3);return}let p=u.artifactBinding||u.bindingPaths.length>0,f={workflowRegistry:d.workflowRegistry,taskRegistry:d.taskRegistry,agentRegistry:d.agentRegistry,handoffSchemas:d.handoffSchemas},m=d.guardrailHooks;if(p){let{BoundResolver:x}=await Promise.resolve().then(()=>(L4(),wH)),{buildGuardrailRulesFromDsl:j}=await Promise.resolve().then(()=>(Vf(),_H)),B=d.resolvedDsl??qa,Z=await new x().resolve({id:u.configDir,embeddedDsl:B,bindingPaths:u.bindingPaths.length>0?u.bindingPaths:void 0,activeGuardrailPolicy:u.active_guardrail_policy,artifactBinding:u.artifactBinding,paths:u.paths});f=Z.registries;let Y=j(Z.dsl);if(Y&&(Y.commandRules.length>0||Y.fileRules.length>0||Y.contentRules.length>0))m=za(Y);else if(Z.guardrails.perAgent.size>0){let le=Z.guardrails.perAgent.values().next().value;le&&(m=za(le))}}let h=n.adapter??"mock",v=o?.context?.cwd??process.cwd(),{createModelResolver:y}=await Promise.resolve().then(()=>(yE(),CH)),b=y({modelMapping:u.model_mapping,fallbackAdapter:h}),w=new Map,k=async x=>{let j=b.resolve(x),B=`${j.adapter}:${j.model??""}`,Z=w.get(B);if(Z)return Z;let Y=await Yke(j.adapter,m,v,j.model);return w.set(B,Y),Y},D;try{D=await k()}catch(x){console.error(x.message),process.exit(12);return}let S=Object.values(u.model_mapping).some(Boolean)||process.env.AGENT_RUNTIME_MODEL||process.env.AGENT_RUNTIME_MODEL_FAST||process.env.AGENT_RUNTIME_MODEL_STANDARD||process.env.AGENT_RUNTIME_MODEL_THINKING?k:D,A=u.recovery,I=n.maxRetries?parseInt(n.maxRetries,10):void 0,P=n.maxFollowUps?parseInt(n.maxFollowUps,10):void 0,$=n.autoApproveGates?async()=>!0:async(x,j)=>(console.error(`Gate "${x}": ${j}`),console.error("Use --auto-approve-gates to auto-approve. Rejecting by default."),!1),E=Xke(n.logFile,u.resolvedLogging.progressLog,i.quiet,r),N;try{if(o){let x={...o,runtime:{...o.runtime,maxFollowUps:P??o.runtime?.maxFollowUps??A.max_follow_ups,maxRetries:I??o.runtime?.maxRetries??A.max_retries},hooks:{onGate:$},progressOutput:E};N=await Ma(S,x,f)}else N=await Ma(S,r,{user_request:a,maxRetries:I??A.max_retries,maxFollowUps:P??A.max_follow_ups,onGate:$,progressOutput:E},f)}finally{E?.close()}console.log(JSON.stringify(N,null,2)),N.status!=="completed"&&process.exit(1)},async list(e,t,n){e||(console.error("Error: resource is required (workflows, tasks, agents)"),process.exit(1));let i=["workflows","tasks","agents"];if(!i.includes(e)){console.error(`Unknown resource: ${e}`),console.error(`Available resources: ${i.join(", ")}`),process.exit(1);return}let r=n.config??"./agents.conf.yaml",a;try{a=await AE(r)}catch(s){console.error(`Failed to load generated contracts: ${s.message}`),console.error("Run `agent-runtime generate` first."),process.exit(1);return}let o=t.format??"table";if(e==="agents"){let s=Object.values(a.agentRegistry);if(o==="json")console.log(JSON.stringify(s,null,2));else{if(s.length===0){console.log("No agents defined.");return}console.log(DE(["ID","Role","Mode","Purpose"],s.map(l=>[l.id,l.role_name,l.mode,l.purpose])))}}else if(e==="tasks"){let s=Object.values(a.taskRegistry);if(o==="json")console.log(JSON.stringify(s,null,2));else{if(s.length===0){console.log("No tasks defined.");return}console.log(DE(["ID","Agent","Description"],s.map(l=>[l.id,l.target_agent,l.description])))}}else{let s=Object.values(a.workflowRegistry);if(o==="json")console.log(JSON.stringify(s,null,2));else{if(s.length===0){console.log("No workflows defined.");return}console.log(DE(["ID","Steps","Description"],s.map(l=>[l.id,String(l.steps.length),l.description])))}}},async showPrompt(e,t,n){e||(console.error("Error: task-id is required"),process.exit(1));let i=n.config??"./agents.conf.yaml",r;try{r=await AE(i)}catch(f){console.error(`Failed to load generated contracts: ${f.message}`),console.error("Run `agent-runtime generate` first."),process.exit(1);return}let a=r.taskRegistry[e];if(!a){console.error(`Unknown task: ${e}`),console.error(`Available tasks: ${Object.keys(r.taskRegistry).join(", ")}`),process.exit(1);return}let o=r.agentRegistry[a.target_agent];if(!o){console.error(`Unknown agent: ${a.target_agent} (referenced by task ${e})`),process.exit(1);return}let s=await ma(i),l=t.withPlugins??!1;l&&await F4({pluginPaths:s.pluginPaths.length>0?s.pluginPaths:void 0,projectDir:s.configDir});let c={user_request:t.userRequest??"(preview)"};if(l){let f=await Vr.runBeforeTask(e,c);if(f===null){console.error(`Task "${e}" skipped by plugin`),process.exit(1);return}c=Vr.applyContextEnhancers(e,f)}let d=Eo(o,a,c,{handoffSchemas:r.handoffSchemas});l&&(d=Vr.applyPromptEnhancers(e,d,c));let p=t.format??"markdown";console.log(p==="json"?JSON.stringify({task_id:e,agent_id:a.target_agent,prompt:d,handoff_schema:a.result_handoff,plugins_applied:l},null,2):d)},async implement(e,t,n){e||(console.error("Error: description is required"),process.exit(3));let i=n.quiet,r=t.logFile?Ua({stderr:!i,file:G4(t.logFile),naming:"single"}):i?void 0:Ua({stderr:!0}),a;try{a=await VH(e,{adapter:t.adapter??"claude",projectDir:t.projectDir??".",dryRun:t.dryRun??!1,model:t.model,reportFormat:t.reportFormat??"text",progressOutput:r})}finally{r?.close()}a.status==="failed"&&(t.reportFormat==="json"?console.log(JSON.stringify({error:a.error,status:"failed"},null,2)):t.reportFormat==="yaml"?console.log(Cs.default.stringify({error:a.error,status:"failed"})):console.error(kE(a)),process.exit(a.exitCode??1));let o=a.data??{status:a.status},s;t.reportFormat==="json"?s=JSON.stringify(o,null,2):t.reportFormat==="yaml"?s=Cs.default.stringify(o):s=kE(a);let l=t.output;l?xE(l,s+`
|
|
5248
5248
|
`):console.log(s)},async auditImplementation(e,t,n){let i=n.quiet,r=t.logFile?Ua({stderr:!i,file:G4(t.logFile),naming:"single"}):i?void 0:Ua({stderr:!0}),a;try{a=await WH({adapter:t.adapter??"claude",projectDir:e??".",focus:t.focus??"all",dryRun:t.dryRun??!1,failOn:t.failOn??"error",model:t.model,reportFormat:t.reportFormat??"text",progressOutput:r})}finally{r?.close()}a.status==="failed"&&(t.reportFormat==="json"?console.log(JSON.stringify({error:a.error,status:"failed"},null,2)):t.reportFormat==="yaml"?console.log(Cs.default.stringify({error:a.error,status:"failed"})):console.error(SE(a)),process.exit(a.exitCode));let o=a.data??{status:a.status},s;t.reportFormat==="json"?s=JSON.stringify(o,null,2):t.reportFormat==="yaml"?s=Cs.default.stringify(o):s=SE(a);let l=t.output;l?xE(l,s+`
|
|
5249
5249
|
`):console.log(s),a.exitCode!==0&&process.exit(a.exitCode)},async agents(e,t){let n=e.format??"yaml";try{console.log(n==="json"?JSON.stringify(qa,null,2):Cs.default.stringify(qa,{lineWidth:120}))}catch(i){console.error(`Failed to output DSL: ${i.message}`),process.exit(1)}},async doctor(e){let t=e.config??"./agents.conf.yaml",n=await RH(t),i=r=>r==="pass"?"\u2713":r==="warn"?"!":"\u2717";for(let r of n.checks){let a=i(r.status),o=r.message?` ${r.message}`:"";console.log(` ${a} ${r.name.padEnd(20)} ${r.status.toUpperCase()}${o}`)}console.log(""),n.all_passed?console.log("All checks passed."):console.log("Some checks failed."),console.log(JSON.stringify(n)),n.all_passed||(process.exitCode=1)},async navigationIndex(e,t){let n=t.config??"./agents.conf.yaml",i=e.format??"json";try{let r=await ma(n),a=qa;if(r.dsl!=="embedded"&&CE(r.dslPath)){let{resolve:d}=await Promise.resolve().then(()=>(Ds(),As));a=(await d(r.dslPath)).data}if(r.artifactBinding){let{resolveBound:d}=await Promise.resolve().then(()=>(Ds(),As));a=(await d(a,{artifactBinding:r.artifactBinding,paths:r.paths})).data}let{buildNavigationIndex:o,validateSchema:s}=await Promise.resolve().then(()=>(Ds(),As)),l=s(a);if(!l.success){let d=l.diagnostics.map(p=>` ${p.path}: ${p.message}`).join(`
|