agentic-coding-harness 0.12.1__tar.gz → 0.13.0__tar.gz
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.
- {agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/PKG-INFO +1 -1
- {agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/pyproject.toml +1 -1
- {agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/src/agentic_coding_harness/__init__.py +1 -1
- {agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/src/agentic_coding_harness/_vendor/ach.mjs +14 -6
- {agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/.gitignore +0 -0
- {agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/README.md +0 -0
- {agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/src/agentic_coding_harness/_cli.py +0 -0
- {agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/src/agentic_coding_harness/py.typed +0 -0
- {agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/tests/test_cli.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: agentic-coding-harness
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: Run, watch, and meter Claude Code, Codex CLI, Gemini CLI, OpenCode, and Kiro from one CLI — verified cost tracking, token usage, budget caps, OTel gen_ai spans, Langfuse traces, and a live dashboard + MCP server.
|
|
5
5
|
Project-URL: Homepage, https://github.com/sblattj/agentic-coding-harness
|
|
6
6
|
Project-URL: Repository, https://github.com/sblattj/agentic-coding-harness
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "agentic-coding-harness"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.13.0"
|
|
8
8
|
description = "Run, watch, and meter Claude Code, Codex CLI, Gemini CLI, OpenCode, and Kiro from one CLI — verified cost tracking, token usage, budget caps, OTel gen_ai spans, Langfuse traces, and a live dashboard + MCP server."
|
|
9
9
|
keywords = ["claude-code", "codex-cli", "gemini-cli", "opencode", "kiro", "coding-agent", "agent-observability", "cost-tracking", "token-usage", "opentelemetry", "langfuse", "mcp-server", "llm", "ai-agents", "cli"]
|
|
10
10
|
authors = [{ name = "Stephen Blatt" }]
|
|
@@ -94,7 +94,7 @@ ${s.join(`
|
|
|
94
94
|
FROM session
|
|
95
95
|
ORDER BY time_created DESC
|
|
96
96
|
LIMIT ?
|
|
97
|
-
`;var F_=E(()=>{Me();qt();$1={headless:!0,streaming:!0,resume:!0,acp:!0,tmuxFallback:!0},bB=c.object({type:c.string(),sessionID:c.string().nullish(),part:c.unknown()}),wB=c.object({read:c.number().nullish(),write:c.number().nullish()}),CB=c.object({total:c.number().nullish(),input:c.number().nullish(),output:c.number().nullish(),reasoning:c.number().nullish(),cache:wB.nullish()}),SB=c.object({type:c.literal("step-start")}).passthrough(),yB=c.object({type:c.literal("text"),text:c.string()}).passthrough(),kB=c.object({type:c.literal("step-finish"),reason:c.string().nullish(),tokens:CB,cost:c.number().nullish()}).passthrough()});function Ot(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ki(e,t){for(let r of t){let n=e[r];if(typeof n==="string"&&n!=="")return n}return}function vh(e){return e!==void 0&&e!==null}function sx(e){return!vh(e)||e===""||Ot(e)&&Object.keys(e).length===0}function UB(e,t){if(!vh(t))return e;if(!vh(e)||sx(e))return t;if(sx(t))return e;let r=(n)=>{try{return JSON.stringify(n)?.length??0}catch{return 0}};return r(t)>=r(e)?t:e}function Fo(e){if(typeof e==="number"&&Number.isFinite(e))return e;if(typeof e==="string"&&e.trim()!==""&&Number.isFinite(Number(e)))return Number(e);return 0}function NB(e){if(!Array.isArray(e))return null;let t=0;for(let r of e)if(Ot(r))t+=Fo(r.value);return t}function PB(e){let t=e.tokenUsage??e.usage??e;return{inputTokens:Fo(t.inputTokens??t.uncachedInputTokens),cacheReadTokens:Fo(t.cacheReadTokens??t.cacheReadInputTokens),cacheWriteTokens:Fo(t.cacheWriteTokens??t.cacheWriteInputTokens),outputTokens:Fo(t.outputTokens),reasoningTokens:null,totalTokens:Fo(t.totalTokens??t.total)||null,durationMs:null,raw:e}}function _x(e){let t=/^\s*\[warn\]\s+failed to set model\s+'([^']*)'\s*:/.exec(e);if(!t)return null;return{kind:"modelAckUnsupported",model:t[1]??""}}function lx(e){if(!/^\s*Dynamic registration failed:/.test(e))return null;return{notice:"mcpRegistrationFailed",warning:"kiro: MCP dynamic client registration failed (a server in ~/.kiro/settings/mcp.json or the agent's mcpServers rejected registration): "+e}}function mh(e={}){let t=e.transport??"headless",r=new Map,n=new Map,i,o=!1,s,_,l=null,u=0,a,h=0,d="",p=null,f="",g=null,v=0;function m(I,O,Y={}){return{type:"step",payload:{kind:I,transport:t,countsAsTurn:!1,...Y,raw:O}}}function b(I,O){if(typeof I!=="string"||I==="")return;if(i===void 0)i=I;if(!o)o=!0,O.push({type:"session",sessionId:I})}function L(I){let O=p,Y=f;if(p=null,f="",O===null||Y.trim()==="")return;I.push({type:"message",role:"assistant",text:Y,...O==="reasoning"?{reasoning:!0}:{}})}function C(I){if(t!=="acp"||g!==null)return;v+=1,g=`kiro-acp-est-${v}`,I.push({type:"model_call",phase:"start",callId:g,provenance:"estimated"})}function w(I){if(g===null)return;I.push({type:"model_call",phase:"end",callId:g,provenance:"estimated"}),g=null}function D(I){L(I),w(I)}function N(I,O){if(b(I.sessionId,O),typeof I.contextUsagePercentage==="number")a=I.contextUsagePercentage;let Y=NB(I.meteringUsage);if(Y===null){O.push(m("metadata",I));return}D(O);let ee=l??0;if(l!==null&&Y===l){O.push(m("metadata",I,{duplicateSnapshot:!0}));return}l=Y,u+=1;let oe={credits:Y-ee,creditsCumulative:Y,source:"native",tokensAvailable:!1,...a!==void 0?{contextUsagePercentage:a}:{},meteringUsage:I.meteringUsage,...typeof I.turnDurationMs==="number"?{turnDurationMs:I.turnDurationMs}:{}},we={inputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,outputTokens:0,reasoningTokens:null,totalTokens:null,durationMs:typeof I.turnDurationMs==="number"?I.turnDurationMs:null,raw:I,extra:oe};O.push({type:"usage",tokens:we})}function X(I,O){let Y=typeof I.sessionUpdate==="string"?I.sessionUpdate:"";switch(Y){case"agent_message_chunk":case"agent_thought_chunk":{let ee=Ot(I.content)?I.content:void 0,oe=ee&&typeof ee.text==="string"?ee.text:"";if(ie(O),oe!==""){C(O);let we=Y==="agent_thought_chunk"?"reasoning":"message";if(p!==null&&p!==we)L(O);p=we,f+=oe}if(Y==="agent_message_chunk")d+=oe;O.push(m("chunk",I,{text:oe,chunkKind:Y}));return}case"tool_call":case"tool_call_chunk":{D(O);let ee=typeof I.toolCallId==="string"?I.toolCallId:"";if(ee===""){let Ge=S("");T(Ge,I),O.push(F(Ge));return}let oe=r.get(ee);if(oe&&oe.startedSeen){let Ge=A(I);if(Ge!=="unknown")oe.name=Ge;O.push(m("toolCallDuplicate",I,{toolCallId:ee}));return}let we=n.get(ee),Te=we??S(ee);if(T(Te,I),oe)oe.name=Te.name;else r.set(ee,{name:Te.name,status:"started",startedSeen:!1,resultSeen:!1});if(vh(Te.input)){if(W(Te,O),we)O.push(m("toolCallDuplicate",I,{toolCallId:ee}));return}n.set(ee,Te),O.push(m(we?"toolCallDuplicate":"toolCallPending",I,{toolCallId:ee}));return}case"tool_call_update":{let ee=typeof I.toolCallId==="string"?I.toolCallId:"",oe=typeof I.status==="string"?I.status:"",we=ee!==""?n.get(ee):void 0;if(we){T(we,I);let Ge=r.get(ee);if(Ge)Ge.name=we.name;W(we,O)}let Te=ee!==""?r.get(ee):void 0;if(oe!=="completed"&&oe!=="failed"){if(Te)Te.status=oe==="in_progress"?"in_progress":Te.status;O.push(m("toolCallUpdate",I,{toolCallId:ee,status:oe}));return}if(Te)Te.status=oe,Te.resultSeen=!0;O.push({type:"tool",toolName:Te?Te.name:"unknown",phase:"result",...ee!==""?{toolCallId:ee}:{},output:I.rawOutput??null,status:oe==="completed"?"success":"error"});return}default:O.push(m("vendor",I,{sessionUpdate:Y}))}}function re(I){let O=Ot(I._meta)?I._meta:void 0,Y=O&&Ot(O.kiro)?O.kiro:void 0;if(Y&&typeof Y.toolName==="string"&&Y.toolName!=="")return Y.toolName;return}function A(I){return re(I)??ki(I,["kind","title"])??"unknown"}function S(I){return{id:I,name:"unknown",nameFromMeta:!1,input:void 0}}function T(I,O){let Y=re(O);if(Y!==void 0)I.name=Y,I.nameFromMeta=!0;else if(!I.nameFromMeta){let ee=ki(O,["kind","title"]);if(ee!==void 0)I.name=ee}if(I.input=UB(I.input,O.rawInput),typeof O.title==="string"&&O.title!=="")I.title=O.title;if(Array.isArray(O.locations)&&O.locations.length>0)I.locations=O.locations}function F(I){return{type:"tool",toolName:I.name,phase:"start",...I.id!==""?{toolCallId:I.id}:{},input:I.input??null,...I.title!==void 0?{title:I.title}:{},...I.locations!==void 0?{locations:I.locations}:{}}}function W(I,O){n.delete(I.id);let Y=r.get(I.id);if(Y)Y.startedSeen=!0;O.push(F(I))}function ie(I){for(let O of[...n.values()])W(O,I)}function Ae(I,O){if(b(I.sessionId,O),ie(O),D(O),typeof I.status==="string")_=I.status;if(typeof I.stopReason==="string")s=I.stopReason;h+=1,O.push(m("runFinished",I,{...typeof I.status==="string"?{status:I.status}:{},...typeof I.stopReason==="string"?{stopReason:I.stopReason}:{},turn:h}))}function Q(I,O,Y){let ee=ki(I,["sessionId","session_id","sessionID"]);if($B.has(O)){if(ee)b(ee,Y);else Y.push(m("vendor",I));return!0}if(AB.has(O)){let oe=ki(I,["role"]);return Y.push({type:"message",role:oe==="user"||oe==="system"?oe:"assistant",text:ki(I,["text","content","message"])??""}),!0}if(MB.has(O)){let oe=ki(I,["toolCallId","tool_call_id","id"]);return Y.push({type:"tool",toolName:ki(I,["name","tool_name","toolName"])??"unknown",phase:"start",...oe?{toolCallId:oe}:{},input:I.input??I.arguments??I.args??null}),!0}if(TB.has(O)){let oe=ki(I,["toolCallId","tool_call_id","id"]);return Y.push({type:"tool",toolName:ki(I,["name","tool_name","toolName"])??"unknown",phase:"result",...oe?{toolCallId:oe}:{},output:I.output??I.result??I.content??null,...typeof I.isError==="boolean"?{status:I.isError?"error":"success"}:{}}),!0}if(OB.has(O))return Y.push({type:"usage",tokens:PB(I)}),!0;if(BB.has(O))return Y.push({type:"error",message:ki(I,["message","error","reason"])??"unknown error"}),!0;return!1}function G(I){let O=[];if(typeof I!=="string"||I.trim()==="")return O;let Y;try{Y=JSON.parse(I.trim())}catch{return O}if(!Ot(Y))return O;let ee=Y,oe=typeof ee.type==="string"?ee.type:"",we=Ot(ee.data)?ee.data:{};switch(oe){case"runStarted":return O.push(m("runStarted",we)),O;case"metadata":return N(we,O),O;case"sessionUpdate":{if(b(we.sessionId,O),Ot(we.update))X(we.update,O);else O.push(m("vendor",ee));return O}case"runFinished":return Ae(we,O),O;default:if(Q(ee,oe,O))return O;return O.push(m("vendor",ee)),O}}function pe(I){let O=[];if(!Ot(I))return O;if(I.kind==="promptResult")return Ae(Ot(I.result)?I.result:{},O),O;let Y=typeof I.method==="string"?I.method:"",ee=Ot(I.params)?I.params:{};if(Y==="session/update"||Y==="_kiro.dev/session/update"){if(b(ee.sessionId,O),Ot(ee.update))X(ee.update,O);else O.push(m("vendor",I));return O}if(Y==="_kiro.dev/metadata")return N(ee,O),O;if(Y!=="")return b(ee.sessionId,O),O.push(m("vendor",I,{method:Y})),O;if(Ot(I.result))b(I.result.sessionId,O);return O.push(m("vendor",I)),O}function ke(){let I=[];return ie(I),D(I),I}function ot(){return{...i!==void 0?{nativeSessionId:i}:{},...s!==void 0?{stopReason:s}:{},..._!==void 0?{status:_}:{},credits:{latest:l,snapshots:u},...a!==void 0?{contextUsagePercentage:a}:{},toolCalls:r,turns:h,messageText:d}}return{pushHeadlessLine:G,pushAcpMessage:pe,flush:ke,state:ot}}var $B,AB,MB,TB,OB,BB;var M1=E(()=>{$B=new Set(["session","session_start"]),AB=new Set(["assistant","assistant_message","assistantResponse","message"]),MB=new Set(["tool_use","toolUse","toolInvocation"]),TB=new Set(["tool_result","toolResult"]),OB=new Set(["usage","metering","token_usage"]),BB=new Set(["error","systemError"])});import{readFileSync as FB}from"node:fs";function WB(){try{let e=FB(new URL("../package.json",import.meta.url),"utf8"),t=JSON.parse(e).version;if(typeof t==="string"&&t!=="")return t}catch{}return"0.12.1"}var it;var Hi=E(()=>{it=WB()});function bh(e={}){let t=["acp"];if(e.agent)t.push("--agent",e.agent);if(e.model)t.push("--model",e.model);if(e.effort)t.push("--effort",e.effort);if(e.tools==="all")t.push("--trust-all-tools");else if(e.tools==="none")t.push("--trust-tools=");else if(Array.isArray(e.tools))t.push(`--trust-tools=${e.tools.join(",")}`);if(e.engine)t.push("--agent-engine",e.engine);return t}class W_{#e;#t;#i;#r;#n;#s;#o;#_;#u;#h;#l;#a;#c=null;#b=0;#p=new Map;#f=[];#d=!1;#m=null;#w=[];pid;exitCode=null;notifications=new jt;constructor(e){this.#e=e.command??"kiro-cli",this.#t=e.args,this.#i=e.cwd,this.#r=e.env,this.#n=e.scrubEnv,this.#s=e.spawnFn??Ki,this.#o=e.startupMs??60000,this.#_=e.clientInfo??{name:"agentic-coding-harness",version:it},this.#u=e.onPermission??KB,this.#h=e.termGraceMs??2000,this.#l=e.killGraceMs??3000,this.#a=e.stderrLines??200}stderrTail(e=20){return this.#f.slice(-e).join(`
|
|
97
|
+
`;var F_=E(()=>{Me();qt();$1={headless:!0,streaming:!0,resume:!0,acp:!0,tmuxFallback:!0},bB=c.object({type:c.string(),sessionID:c.string().nullish(),part:c.unknown()}),wB=c.object({read:c.number().nullish(),write:c.number().nullish()}),CB=c.object({total:c.number().nullish(),input:c.number().nullish(),output:c.number().nullish(),reasoning:c.number().nullish(),cache:wB.nullish()}),SB=c.object({type:c.literal("step-start")}).passthrough(),yB=c.object({type:c.literal("text"),text:c.string()}).passthrough(),kB=c.object({type:c.literal("step-finish"),reason:c.string().nullish(),tokens:CB,cost:c.number().nullish()}).passthrough()});function Ot(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ki(e,t){for(let r of t){let n=e[r];if(typeof n==="string"&&n!=="")return n}return}function vh(e){return e!==void 0&&e!==null}function sx(e){return!vh(e)||e===""||Ot(e)&&Object.keys(e).length===0}function UB(e,t){if(!vh(t))return e;if(!vh(e)||sx(e))return t;if(sx(t))return e;let r=(n)=>{try{return JSON.stringify(n)?.length??0}catch{return 0}};return r(t)>=r(e)?t:e}function Fo(e){if(typeof e==="number"&&Number.isFinite(e))return e;if(typeof e==="string"&&e.trim()!==""&&Number.isFinite(Number(e)))return Number(e);return 0}function NB(e){if(!Array.isArray(e))return null;let t=0;for(let r of e)if(Ot(r))t+=Fo(r.value);return t}function PB(e){let t=e.tokenUsage??e.usage??e;return{inputTokens:Fo(t.inputTokens??t.uncachedInputTokens),cacheReadTokens:Fo(t.cacheReadTokens??t.cacheReadInputTokens),cacheWriteTokens:Fo(t.cacheWriteTokens??t.cacheWriteInputTokens),outputTokens:Fo(t.outputTokens),reasoningTokens:null,totalTokens:Fo(t.totalTokens??t.total)||null,durationMs:null,raw:e}}function _x(e){let t=/^\s*\[warn\]\s+failed to set model\s+'([^']*)'\s*:/.exec(e);if(!t)return null;return{kind:"modelAckUnsupported",model:t[1]??""}}function lx(e){if(!/^\s*Dynamic registration failed:/.test(e))return null;return{notice:"mcpRegistrationFailed",warning:"kiro: MCP dynamic client registration failed (a server in ~/.kiro/settings/mcp.json or the agent's mcpServers rejected registration): "+e}}function mh(e={}){let t=e.transport??"headless",r=new Map,n=new Map,i,o=!1,s,_,l=null,u=0,a,h=0,d="",p=null,f="",g=null,v=0;function m(I,O,Y={}){return{type:"step",payload:{kind:I,transport:t,countsAsTurn:!1,...Y,raw:O}}}function b(I,O){if(typeof I!=="string"||I==="")return;if(i===void 0)i=I;if(!o)o=!0,O.push({type:"session",sessionId:I})}function L(I){let O=p,Y=f;if(p=null,f="",O===null||Y.trim()==="")return;I.push({type:"message",role:"assistant",text:Y,...O==="reasoning"?{reasoning:!0}:{}})}function C(I){if(t!=="acp"||g!==null)return;v+=1,g=`kiro-acp-est-${v}`,I.push({type:"model_call",phase:"start",callId:g,provenance:"estimated"})}function w(I){if(g===null)return;I.push({type:"model_call",phase:"end",callId:g,provenance:"estimated"}),g=null}function D(I){L(I),w(I)}function N(I,O){if(b(I.sessionId,O),typeof I.contextUsagePercentage==="number")a=I.contextUsagePercentage;let Y=NB(I.meteringUsage);if(Y===null){O.push(m("metadata",I));return}D(O);let ee=l??0;if(l!==null&&Y===l){O.push(m("metadata",I,{duplicateSnapshot:!0}));return}l=Y,u+=1;let oe={credits:Y-ee,creditsCumulative:Y,source:"native",tokensAvailable:!1,...a!==void 0?{contextUsagePercentage:a}:{},meteringUsage:I.meteringUsage,...typeof I.turnDurationMs==="number"?{turnDurationMs:I.turnDurationMs}:{}},we={inputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,outputTokens:0,reasoningTokens:null,totalTokens:null,durationMs:typeof I.turnDurationMs==="number"?I.turnDurationMs:null,raw:I,extra:oe};O.push({type:"usage",tokens:we})}function X(I,O){let Y=typeof I.sessionUpdate==="string"?I.sessionUpdate:"";switch(Y){case"agent_message_chunk":case"agent_thought_chunk":{let ee=Ot(I.content)?I.content:void 0,oe=ee&&typeof ee.text==="string"?ee.text:"";if(ie(O),oe!==""){C(O);let we=Y==="agent_thought_chunk"?"reasoning":"message";if(p!==null&&p!==we)L(O);p=we,f+=oe}if(Y==="agent_message_chunk")d+=oe;O.push(m("chunk",I,{text:oe,chunkKind:Y}));return}case"tool_call":case"tool_call_chunk":{D(O);let ee=typeof I.toolCallId==="string"?I.toolCallId:"";if(ee===""){let Ge=S("");T(Ge,I),O.push(F(Ge));return}let oe=r.get(ee);if(oe&&oe.startedSeen){let Ge=A(I);if(Ge!=="unknown")oe.name=Ge;O.push(m("toolCallDuplicate",I,{toolCallId:ee}));return}let we=n.get(ee),Te=we??S(ee);if(T(Te,I),oe)oe.name=Te.name;else r.set(ee,{name:Te.name,status:"started",startedSeen:!1,resultSeen:!1});if(vh(Te.input)){if(W(Te,O),we)O.push(m("toolCallDuplicate",I,{toolCallId:ee}));return}n.set(ee,Te),O.push(m(we?"toolCallDuplicate":"toolCallPending",I,{toolCallId:ee}));return}case"tool_call_update":{let ee=typeof I.toolCallId==="string"?I.toolCallId:"",oe=typeof I.status==="string"?I.status:"",we=ee!==""?n.get(ee):void 0;if(we){T(we,I);let Ge=r.get(ee);if(Ge)Ge.name=we.name;W(we,O)}let Te=ee!==""?r.get(ee):void 0;if(oe!=="completed"&&oe!=="failed"){if(Te)Te.status=oe==="in_progress"?"in_progress":Te.status;O.push(m("toolCallUpdate",I,{toolCallId:ee,status:oe}));return}if(Te)Te.status=oe,Te.resultSeen=!0;O.push({type:"tool",toolName:Te?Te.name:"unknown",phase:"result",...ee!==""?{toolCallId:ee}:{},output:I.rawOutput??null,status:oe==="completed"?"success":"error"});return}default:O.push(m("vendor",I,{sessionUpdate:Y}))}}function re(I){let O=Ot(I._meta)?I._meta:void 0,Y=O&&Ot(O.kiro)?O.kiro:void 0;if(Y&&typeof Y.toolName==="string"&&Y.toolName!=="")return Y.toolName;return}function A(I){return re(I)??ki(I,["kind","title"])??"unknown"}function S(I){return{id:I,name:"unknown",nameFromMeta:!1,input:void 0}}function T(I,O){let Y=re(O);if(Y!==void 0)I.name=Y,I.nameFromMeta=!0;else if(!I.nameFromMeta){let ee=ki(O,["kind","title"]);if(ee!==void 0)I.name=ee}if(I.input=UB(I.input,O.rawInput),typeof O.title==="string"&&O.title!=="")I.title=O.title;if(Array.isArray(O.locations)&&O.locations.length>0)I.locations=O.locations}function F(I){return{type:"tool",toolName:I.name,phase:"start",...I.id!==""?{toolCallId:I.id}:{},input:I.input??null,...I.title!==void 0?{title:I.title}:{},...I.locations!==void 0?{locations:I.locations}:{}}}function W(I,O){n.delete(I.id);let Y=r.get(I.id);if(Y)Y.startedSeen=!0;O.push(F(I))}function ie(I){for(let O of[...n.values()])W(O,I)}function Ae(I,O){if(b(I.sessionId,O),ie(O),D(O),typeof I.status==="string")_=I.status;if(typeof I.stopReason==="string")s=I.stopReason;h+=1,O.push(m("runFinished",I,{...typeof I.status==="string"?{status:I.status}:{},...typeof I.stopReason==="string"?{stopReason:I.stopReason}:{},turn:h}))}function Q(I,O,Y){let ee=ki(I,["sessionId","session_id","sessionID"]);if($B.has(O)){if(ee)b(ee,Y);else Y.push(m("vendor",I));return!0}if(AB.has(O)){let oe=ki(I,["role"]);return Y.push({type:"message",role:oe==="user"||oe==="system"?oe:"assistant",text:ki(I,["text","content","message"])??""}),!0}if(MB.has(O)){let oe=ki(I,["toolCallId","tool_call_id","id"]);return Y.push({type:"tool",toolName:ki(I,["name","tool_name","toolName"])??"unknown",phase:"start",...oe?{toolCallId:oe}:{},input:I.input??I.arguments??I.args??null}),!0}if(TB.has(O)){let oe=ki(I,["toolCallId","tool_call_id","id"]);return Y.push({type:"tool",toolName:ki(I,["name","tool_name","toolName"])??"unknown",phase:"result",...oe?{toolCallId:oe}:{},output:I.output??I.result??I.content??null,...typeof I.isError==="boolean"?{status:I.isError?"error":"success"}:{}}),!0}if(OB.has(O))return Y.push({type:"usage",tokens:PB(I)}),!0;if(BB.has(O))return Y.push({type:"error",message:ki(I,["message","error","reason"])??"unknown error"}),!0;return!1}function G(I){let O=[];if(typeof I!=="string"||I.trim()==="")return O;let Y;try{Y=JSON.parse(I.trim())}catch{return O}if(!Ot(Y))return O;let ee=Y,oe=typeof ee.type==="string"?ee.type:"",we=Ot(ee.data)?ee.data:{};switch(oe){case"runStarted":return O.push(m("runStarted",we)),O;case"metadata":return N(we,O),O;case"sessionUpdate":{if(b(we.sessionId,O),Ot(we.update))X(we.update,O);else O.push(m("vendor",ee));return O}case"runFinished":return Ae(we,O),O;default:if(Q(ee,oe,O))return O;return O.push(m("vendor",ee)),O}}function pe(I){let O=[];if(!Ot(I))return O;if(I.kind==="promptResult")return Ae(Ot(I.result)?I.result:{},O),O;let Y=typeof I.method==="string"?I.method:"",ee=Ot(I.params)?I.params:{};if(Y==="session/update"||Y==="_kiro.dev/session/update"){if(b(ee.sessionId,O),Ot(ee.update))X(ee.update,O);else O.push(m("vendor",I));return O}if(Y==="_kiro.dev/metadata")return N(ee,O),O;if(Y!=="")return b(ee.sessionId,O),O.push(m("vendor",I,{method:Y})),O;if(Ot(I.result))b(I.result.sessionId,O);return O.push(m("vendor",I)),O}function ke(){let I=[];return ie(I),D(I),I}function ot(){return{...i!==void 0?{nativeSessionId:i}:{},...s!==void 0?{stopReason:s}:{},..._!==void 0?{status:_}:{},credits:{latest:l,snapshots:u},...a!==void 0?{contextUsagePercentage:a}:{},toolCalls:r,turns:h,messageText:d}}return{pushHeadlessLine:G,pushAcpMessage:pe,flush:ke,state:ot}}var $B,AB,MB,TB,OB,BB;var M1=E(()=>{$B=new Set(["session","session_start"]),AB=new Set(["assistant","assistant_message","assistantResponse","message"]),MB=new Set(["tool_use","toolUse","toolInvocation"]),TB=new Set(["tool_result","toolResult"]),OB=new Set(["usage","metering","token_usage"]),BB=new Set(["error","systemError"])});import{readFileSync as FB}from"node:fs";function WB(){try{let e=FB(new URL("../package.json",import.meta.url),"utf8"),t=JSON.parse(e).version;if(typeof t==="string"&&t!=="")return t}catch{}return"0.13.0"}var it;var Hi=E(()=>{it=WB()});function bh(e={}){let t=["acp"];if(e.agent)t.push("--agent",e.agent);if(e.model)t.push("--model",e.model);if(e.effort)t.push("--effort",e.effort);if(e.tools==="all")t.push("--trust-all-tools");else if(e.tools==="none")t.push("--trust-tools=");else if(Array.isArray(e.tools))t.push(`--trust-tools=${e.tools.join(",")}`);if(e.engine)t.push("--agent-engine",e.engine);return t}class W_{#e;#t;#i;#r;#n;#s;#o;#_;#u;#h;#l;#a;#c=null;#b=0;#p=new Map;#f=[];#d=!1;#m=null;#w=[];pid;exitCode=null;notifications=new jt;constructor(e){this.#e=e.command??"kiro-cli",this.#t=e.args,this.#i=e.cwd,this.#r=e.env,this.#n=e.scrubEnv,this.#s=e.spawnFn??Ki,this.#o=e.startupMs??60000,this.#_=e.clientInfo??{name:"agentic-coding-harness",version:it},this.#u=e.onPermission??KB,this.#h=e.termGraceMs??2000,this.#l=e.killGraceMs??3000,this.#a=e.stderrLines??200}stderrTail(e=20){return this.#f.slice(-e).join(`
|
|
98
98
|
`)}start(){if(this.#c)return;let e;try{e=this.#s(this.#e,this.#t,{cwd:this.#i,env:N_(this.#r?{...process.env,...this.#r}:process.env,this.#n),stdio:["pipe","pipe","pipe"]})}catch(n){throw new Dt("spawn",`failed to spawn ${this.#e}`,"",n)}this.#c=e,this.pid=e.pid;let t=new Si;e.stdout?.setEncoding("utf8"),e.stdout?.on("data",(n)=>{for(let i of t.push(n))this.#x(i)}),e.stdout?.on("end",()=>{for(let n of t.flush())this.#x(n)});let r=new Si;e.stderr?.setEncoding("utf8"),e.stderr?.on("data",(n)=>{for(let i of r.push(n))this.#C(i)}),e.once("error",(n)=>{this.#C(`spawn error: ${n.message}`),this.#S(null)}),e.once("close",(n)=>{this.#S(n)})}#C(e){if(this.#f.push(e),this.#f.length>this.#a)this.#f.splice(0,this.#f.length-this.#a)}#S(e){if(this.#d)return;this.#d=!0,this.exitCode=e;for(let[,r]of this.#p){if(r.timer)clearTimeout(r.timer);r.reject(new Dt(r.phase,`child exited (code ${e??"null"}) with ${r.method} in flight`,this.stderrTail()))}this.#p.clear(),this.notifications.close();let t=this.#w;this.#w=[];for(let r of t)r(e)}#y(){if(this.#d)return Promise.resolve(this.exitCode);return new Promise((e)=>this.#w.push(e))}close(){if(this.#m)return this.#m;return this.#m=this.#E(),this.#m}async#E(){let e=this.#c;if(!e)return this.exitCode;if(this.#d)return this.exitCode;try{e.stdin?.end()}catch{}if(await this.#k(this.#h))return this.exitCode;try{e.kill("SIGTERM")}catch{}if(await this.#k(this.#l))return this.exitCode;try{e.kill("SIGKILL")}catch{}return await this.#y()}#k(e){if(this.#d)return Promise.resolve(!0);return new Promise((t)=>{let r=setTimeout(()=>t(this.#d),e);r.unref?.(),this.#y().then(()=>{clearTimeout(r),t(!0)})})}#g(e){let t=this.#c;if(!t||this.#d)return;t.stdin?.write(`${JSON.stringify(e)}
|
|
99
99
|
`)}#x(e){let t=e.trim();if(!t)return;let r;try{r=JSON.parse(t)}catch{this.#C(`non-json stdout: ${t.slice(0,400)}`);return}let n=r.id!==void 0&&r.id!==null;if(n&&typeof r.method==="string"){this.#L(r.id,r.method,r.params);return}if(n){this.#D(r);return}if(typeof r.method==="string")this.notifications.push({method:r.method,params:r.params})}#D(e){let t=Number(e.id),r=this.#p.get(t);if(!r)return;if(this.#p.delete(t),r.timer)clearTimeout(r.timer);let n=e.error;if(n){r.reject(new Dt(r.phase,`${r.method} failed: ${n.message??"unknown error"} (code ${n.code??"?"})`,this.stderrTail(),n));return}r.resolve(e.result)}async#L(e,t,r){let n;if(t==="session/request_permission"){let i;try{i=await this.#u(r)}catch{i={outcome:{outcome:"cancelled"}}}n=i,this.#g({jsonrpc:"2.0",id:e,result:i})}else if(HB.test(t)){let i={code:-32601,message:`Method not found: ${t} (client advertises fs:false, terminal:false)`};n={error:i},this.#g({jsonrpc:"2.0",id:e,error:i})}else{let i={code:-32601,message:`Method not found: ${t}`};n={error:i},this.#g({jsonrpc:"2.0",id:e,error:i})}this.notifications.push({method:"__client_request",params:{method:t,params:r,answered:n}})}#v(e,t,r,n){if(!this.#c)this.start();if(this.#d)return Promise.reject(new Dt(r,`child already exited (code ${this.exitCode??"null"})`,this.stderrTail()));let i=this.#b++;return new Promise((o,s)=>{let _={phase:r,method:e,resolve:o,reject:s,timer:null};if(n!==null){let l=setTimeout(()=>{this.#p.delete(i),this.close().then(()=>{s(new Dt(r,`${e} did not respond within ${n}ms`,this.stderrTail()))})},n);l.unref?.(),_.timer=l}this.#p.set(i,_),this.#g({jsonrpc:"2.0",id:i,method:e,params:t})})}initialize(){return this.#v("initialize",{protocolVersion:1,clientCapabilities:{fs:{readTextFile:!1,writeTextFile:!1},terminal:!1},clientInfo:this.#_},"initialize",this.#o)}newSession(e){return this.#v("session/new",{cwd:e.cwd,mcpServers:e.mcpServers??[]},"session/new",this.#o)}loadSession(e,t={}){return this.#v("session/load",{sessionId:e,cwd:t.cwd??this.#i,mcpServers:t.mcpServers??[]},"session/new",this.#o)}setModel(e,t){return this.#v("session/set_model",{sessionId:e,modelId:t},"session/set_model",this.#o)}prompt(e,t){return this.#v("session/prompt",{sessionId:e,prompt:[{type:"text",text:t}]},"session/prompt",null)}cancel(e){this.#g({jsonrpc:"2.0",method:"session/cancel",params:{sessionId:e}})}async handshake(e){let t=[],r=(o)=>{if(jB.test(o.method))t.push(o.method)},n=this.#I(r),i=Date.now();try{let o=Date.now(),s=await this.initialize(),_=Date.now()-o,l=Date.now(),u=await this.newSession({cwd:e.cwd,mcpServers:e.mcpServers}),a=Date.now()-l,h=u.modes?.currentModeId??null,d=u.modes?.availableModes??[],p=u.models?.currentModelId??null,f=u.models?.availableModels??[];if(e.agent&&h!==e.agent)throw new Dt("session/new",`requested agent '${e.agent}' is not the session mode (current '${h??"none"}'); available: ${d.map((b)=>b.id).join(", ")||"none"}`,this.stderrTail());let g=e.model?f.some((b)=>b.modelId===e.model):!1,v="not-requested",m=0;if(e.model){if(e.requireModelAck&&!g)throw new Dt("session/set_model",`model '${e.model}' is not offered by this session; available: ${f.map((L)=>L.modelId).join(", ")||"none"}`,this.stderrTail());let b=Date.now();try{await this.setModel(u.sessionId,e.model),v="acknowledged"}catch(L){if(e.requireModelAck)throw L;v="rejected"}m=Date.now()-b}return{cliVersion:s.agentInfo?.version??null,sessionId:u.sessionId,currentModeId:h,availableModes:d,currentModelId:p,availableModels:f,modelAck:v,agentVerified:e.agent!==void 0&&h===e.agent,modelVerified:g,mcpNotices:t,durationsMs:{initialize:_,newSession:a,setModel:m,total:Date.now()-i}}}finally{n()}}#I(e){let t=this.notifications,r=t.push.bind(t);return t.push=(...n)=>{for(let i of n)e(i);r(...n)},()=>{t.push=r}}}var Dt,KB=async()=>({outcome:{outcome:"cancelled"}}),HB,jB;var T1=E(()=>{Hi();qt();Dt=class Dt extends Error{phase;stderrTail;cause;constructor(e,t,r="",n){super(`kiro acp [${e}]: ${t}`);this.name="KiroAcpError",this.phase=e,this.stderrTail=r,this.cause=n}};HB=/^(fs\/|terminal\/)/,jB=/^_kiro\.dev\/(mcp|webTools)\//});import{createHash as GB}from"node:crypto";function zB(e){return GB("sha256").update(JSON.stringify(e)).digest("hex")}function ax(e){if(e instanceof Dt){let t=e.stderrTail.trim();return t===""?e.message:`${e.message}
|
|
100
100
|
stderr: ${t}`}return e instanceof Error?e.message:String(e)}function YB(e){return e instanceof Dt?e.phase:"unknown"}async function hx(e,t){let r=e.kiro??{},n=[...bh({...r.agent!==void 0?{agent:r.agent}:{},...e.model!==void 0?{model:e.model}:{},...r.effort!==void 0?{effort:r.effort}:{},...r.tools!==void 0?{tools:r.tools}:{},...r.engine!==void 0?{engine:r.engine}:{}}),...e.extraArgs??[]],i=new W_({...t.command!==void 0?{command:t.command}:{},args:n,...e.cwd!==void 0?{cwd:e.cwd}:{},...e.env!==void 0?{env:e.env}:{},...e.sandbox?.scrubEnv!==void 0?{scrubEnv:e.sandbox.scrubEnv}:{},...t.spawnFn!==void 0?{spawnFn:t.spawnFn}:{},...r.startupMs!==void 0?{startupMs:r.startupMs}:{},...t.onPermission!==void 0?{onPermission:t.onPermission}:{}}),o=mh({transport:"acp"}),s=new jt,_=[],l=[],u=()=>{},a=new Promise((C)=>{u=C}),h=!1,d,p,f,g=(C)=>{for(let w of C)s.push(w)},v=(C)=>{let w=Et("kiro",C);if(w)s.push(w)},m=(C)=>{let w=[];for(let D of o.pushAcpMessage(C)){let N=Et("kiro",D);if(!N)continue;if(D.type==="usage"&&N.type==="usage"){let X=D.tokens?.extra;if(X){let re=N.usage;re.extra={...re.extra??{},...X}}}w.push(N)}g(w)},b=(async()=>{for await(let C of i.notifications){if(C.method==="__client_request"){let w=C.params??{};v({type:"step",payload:{kind:"clientRequest",transport:"acp",countsAsTurn:!1,...w}});continue}if(l.push(C.method),ux.test(C.method))_.push(C.method);m(C)}})();(async()=>{let C=1;try{if(i.start(),p=await i.handshake({cwd:e.cwd??process.cwd(),mcpServers:r.mcpServers??[],...r.agent!==void 0?{agent:r.agent}:{},...e.model!==void 0?{model:e.model}:{},requireModelAck:r.requireModelAck??e.model!==void 0}),d=p.sessionId,m({jsonrpc:"2.0",result:{sessionId:p.sessionId}}),r.requireMcpStartup===!0){if(_.length===0)await XB(50);let N=[...new Set([..._,...p.mcpNotices.filter((X)=>ux.test(X))])];if(N.length>0)throw new Dt("mcp",`requireMcpStartup: MCP failed to start (${N.join(", ")}); no prompt was sent`,i.stderrTail())}if(e.resume!==void 0&&e.resume!=="")try{await i.loadSession(e.resume,{...e.cwd!==void 0?{cwd:e.cwd}:{}}),d=e.resume}catch(N){v({type:"progress",text:`[warn] kiro acp: session/load '${e.resume}' failed (${ax(N)}); continuing on the new session ${p.sessionId}`}),d=p.sessionId}let w=await i.prompt(d,e.prompt);m({kind:"promptResult",result:w});let D=typeof w.stopReason==="string"?w.stopReason:"";if(C=D===""||qB.has(D)?0:1,D==="cancelled")h=!0}catch(w){v({type:"error",message:`kiro acp failed in phase '${YB(w)}': ${ax(w)}`}),C=1}finally{f=JB({kiro:r,spec:e,receipt:p,args:n,notices:l,sessionId:d}),await i.close(),await b;for(let w of o.flush())v(w);s.close(),u(C)}})();let L=await vt({agent:"kiro",events:s,mapEvent:(C)=>C,exit:a,abort:()=>{if(h=!0,d!==void 0)i.cancel(d);i.close()},isAborted:()=>h,...e.resume!==void 0?{fallbackSessionId:e.resume}:{},sessionIdWaitMs:0});return L.kiro=()=>f,L}function JB(e){let{kiro:t,spec:r,receipt:n,args:i}=e,o={...t,transport:"acp"},s={argv:i,sessionId:e.sessionId??null,currentModeId:n?.currentModeId??null,currentModelId:n?.currentModelId??null,modelVerified:n?.modelVerified??!1,agentVerified:n?.agentVerified??!1,mcpNotices:[...new Set([...n?.mcpNotices??[],...e.notices])],...r.model!==void 0?{requestedModel:r.model}:{}};return{cliVersion:n?.cliVersion??"unknown",transport:"acp",requested:o,effective:s,...e.sessionId!==void 0?{nativeSessionId:e.sessionId}:{},modelAck:n?.modelAck??(r.model===void 0?"not-requested":"rejected"),configHash:zB({requested:o,effective:s})}}var qB,ux,XB=(e)=>new Promise((t)=>{setTimeout(t,e).unref?.()});var cx=E(()=>{T1();M1();qt();qB=new Set(["end_turn","max_tokens","max_turn_requests","refusal"]),ux=/^_kiro\.dev\/mcp\//});import{spawn as QB,spawnSync as VB}from"node:child_process";import{EventEmitter as ZB}from"node:events";import{existsSync as eU,writeFileSync as tU}from"node:fs";import iU from"node:net";import fx from"node:os";import gx from"node:path";import{createInterface as dx}from"node:readline";function Wo(e,t=0){if(typeof e==="number"&&Number.isFinite(e))return e;if(typeof e==="string"&&e.trim()!==""&&Number.isFinite(Number(e)))return Number(e);return t}function px(e){if(e===null||e===void 0||e==="")return null;let t=Wo(e,Number.NaN);return Number.isFinite(t)?t:null}function rU(e,t=Date.now()){let r=e.trim();if(!r.startsWith("{"))return null;let n;try{n=JSON.parse(r)}catch{return null}if(typeof n!=="object"||n===null||Array.isArray(n))return null;let i=n;if(typeof i.event!=="string"||i.event.length===0)return null;let o=i.tokenUsage??{};if(!["uncachedInputTokens","cacheReadInputTokens","cacheWriteInputTokens","outputTokens","totalTokens"].some((u)=>(u in o))&&i.credits===void 0&&i.contextUsagePercentage===void 0)return null;let _=typeof i.ts==="number"&&Number.isFinite(i.ts)?Math.round(i.ts*1000):t,l={event:i.event,totalTokens:Wo(o.totalTokens??o.total),credits:px(i.credits??i.units),contextUsagePercentage:px(i.contextUsagePercentage??i.contextUsage),raw:i};if(typeof i.url==="string")l.url=i.url;return{agent:"kiro",...typeof i.model==="string"&&i.model!==""?{model:i.model}:{},inputTokens:Wo(o.uncachedInputTokens),outputTokens:Wo(o.outputTokens),cacheReadTokens:Wo(o.cacheReadInputTokens),cacheWriteTokens:Wo(o.cacheWriteInputTokens),timestamp:_,extra:l}}function oU(e=fx.tmpdir()){let t=gx.join(e,`kiro-mitm-addon-${process.pid}.py`);return tU(t,nU,{mode:493}),t}async function mx(e=8900,t=8999,r="127.0.0.1"){let n=(i)=>new Promise((o)=>{let s=iU.createServer();s.once("error",()=>o(!1)),s.listen(i,r,()=>s.close(()=>o(!0)))});for(let i=e;i<=t;i++)if(await n(i))return i;return null}function B1(e=process.env.MITMDUMP_BIN??"mitmdump"){if(O1?.bin===e)return O1.available;let t=e.includes("/")?eU(e):VB("/bin/sh",["-c",`command -v ${e}`],{stdio:"ignore"}).status===0;return O1={bin:e,available:t},t}function bx(e=vx,t=gx.join(fx.homedir(),".mitmproxy","mitmproxy-ca-cert.pem")){return{HTTPS_PROXY:`http://127.0.0.1:${e}`,SSL_CERT_FILE:t}}function wx(e=vx,t={}){let r=t.scriptPath??oU(),n=t.mitmdumpBin??process.env.MITMDUMP_BIN??"mitmdump",i=QB(n,["-p",String(e),"-s",r],{stdio:["ignore","pipe","pipe"],env:{...process.env,...t.env??{}}}),o=new ZB;return o.port=e,o.child=i,o.scriptPath=r,dx({input:i.stdout}).on("line",(l)=>{o.emit("line",l);let u=rU(l);if(u)o.emit("record",u);else o.emit("unparsed",l)}),dx({input:i.stderr}).on("line",(l)=>o.emit("stderr",l)),i.on("error",(l)=>o.emit("error",l)),o.stop=()=>new Promise((l)=>{if(i.exitCode!==null||i.signalCode!==null)return l();let u=!1,a=()=>{if(u)return;u=!0,l()};i.once("close",a),i.kill("SIGTERM"),setTimeout(()=>{if(i.exitCode===null&&i.signalCode===null)i.kill("SIGKILL")},2000).unref(),setTimeout(a,3000).unref()}),o}var vx=8888,UZ,nU,O1=null;var Cx=E(()=>{UZ=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let r=t;for(let n=0;n<8;n++)r=r&1?(3988292384^r>>>1)>>>0:r>>>1;e[t]=r>>>0}return e})();nU=String.raw`"""kiro-mitm addon: AWS EventStream token tap for kiro-cli traffic.
|
|
@@ -282,7 +282,7 @@ if __name__ == "__main__":
|
|
|
282
282
|
`)}function vb(e,t){return e.descriptors.find((r)=>r.descriptor.name===t)}function mb(e){return[...eb(),...e.descriptors.map((t)=>t.descriptor.name)]}function eP(e,t){return new k(`unknown agent '${e}' (expected one of: ${mb(t).join(", ")})`,"UNKNOWN_AGENT")}function Hh(e,t,r){let n=t.template!==void 0||t["prompt-stdin"]===!0||t["template-shell"]===!0;if(e===kr){if(t.template===void 0||t.template.trim()==="")throw new k("run --agent custom requires --template '<cmd with {prompt}>' (placeholders: {prompt} {model} {workspace})","USAGE");return{adapter:Oh({name:kr,template:t.template,promptVia:t["prompt-stdin"]===!0?"stdin":"argv",shell:t["template-shell"]===!0})}}if(n)throw new k("--template/--prompt-stdin/--template-shell only apply to --agent custom","USAGE");if(tt(e))return{};let i=vb(r,e);if(!i)throw eP(e,r);let o=Gx(i);if(!o)throw new k(`agent '${e}' (${i.file}) is meter-only (launch: null): it can be read by stats but not run`,"USAGE");let s=i.descriptor.pricingHints;return{adapter:Oh(o),...s!==void 0&&Object.keys(s).length>0?{wrapPricer:(_)=>Ko(_,s,i.file)}:{}}}function DE(e,t={}){let r={runs:0,byAgent:{}};for(let n of t.records??xt(e)){if(n.metering!=="none")continue;if(t.agent&&n.agent!==t.agent)continue;if(t.sinceTs!==void 0&&n.startedAt<t.sinceTs)continue;r.runs+=1,(r.byAgent[n.agent]??={runs:0}).runs+=1}return r}async function LE(e,t,r={}){let n=[],i=[];for(let o of e.descriptors){if(!o.descriptor.usageTap)continue;if(r.agent&&o.descriptor.name!==r.agent)continue;let s=o.descriptor.pricingHints,_=s?Ko(t,s,o.file):t;for(let l of await Uh(o)){if(r.sinceTs!==void 0){let d=l.ts?Date.parse(l.ts):NaN;if(!Number.isFinite(d)||d<r.sinceTs)continue}let u;if(l.model&&(l.costUsd===void 0||r.costMode==="calculate")){let d=_.price({model:l.model,inputTokens:l.inputTokens,outputTokens:l.outputTokens,cacheReadTokens:l.cacheReadTokens,cacheWriteTokens:l.cacheWriteTokens});if(!Number.isNaN(d))u=d}let{costUsd:a,...h}=l;n.push({...h,...qo(r.costMode??"auto",a,u)})}if(_!==t)i.push(..._.drainWarnings())}return{rows:n,warnings:i}}async function IE(e){let t=ZN({args:e,options:{json:{type:"boolean",default:!1}},allowPositionals:!1}),r=Xo();Er(r);let n=r.descriptors.map((i)=>({name:i.descriptor.name,file:i.file,...i.descriptor.description!==void 0?{description:i.descriptor.description}:{},launch:i.descriptor.launch?!0:!1,usageTap:i.descriptor.usageTap?!0:!1,pricingHints:Object.keys(i.descriptor.pricingHints??{})}));if(t.values.json)return process.stdout.write(JSON.stringify({builtins:[...Be,kr],descriptors:n,errors:r.errors,warnings:r.warnings},null,2)+`
|
|
283
283
|
`),0;process.stdout.write(`built-in ${[...Be,kr].join(", ")}
|
|
284
284
|
`);for(let i of n){let o=[i.launch?"run":null,i.usageTap?"meter":null].filter(Boolean).join("+");process.stdout.write(`agents.d ${i.name.padEnd(16)} ${o.padEnd(9)} ${i.file}
|
|
285
|
-
`)}return 0}var jh=E(()=>{Kh();_e();j_();G_();Ke();He()});import zo from"node:path";function RE(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function iP(e){if(e===void 0)return[];return(Array.isArray(e)?e:e.split(",")).map((r)=>r.trim()).filter((r)=>r.length>0)}function Gh(e,t=process.env){let r=e.gateway!==void 0?e.gateway:t.AGENTIC_CODING_HARNESS_GATEWAY==="1",n=e.root??t.AGENTIC_CODING_HARNESS_ROOT,i=e.maxJobs??RE(t.AGENTIC_CODING_HARNESS_MAX_JOBS??"")??tP,o=e.maxOutputBytes??RE(t.AGENTIC_CODING_HARNESS_MAX_OUTPUT_BYTES??""),s=iP(e.allowExtraArgs??t.AGENTIC_CODING_HARNESS_ALLOW_EXTRA_ARGS);return{enabled:r,...n!==void 0?{root:zo.resolve(n)}:{},maxJobs:i,...o!==void 0?{maxOutputBytes:o}:{},allowExtraArgs:s}}function $E(e,t){let r=t.endsWith(zo.sep)?t:t+zo.sep;return e===t||e.startsWith(r)}function Yo(e,t){if(!e?.enabled)return{ok:!0};if(e.root===void 0)return{ok:!1,error:"gateway root: required in gateway mode (pass --root or set AGENTIC_CODING_HARNESS_ROOT)"};if(t===void 0)return{ok:!0};let r=zo.resolve(t);if(!$E(r,e.root))return{ok:!1,error:`cwd: '${t}' must resolve under gateway root '${e.root}' (resolved '${r}')`};return{ok:!0}}function Jo(e,t){if(!e?.enabled||t===void 0)return{allowed:t===void 0?[]:[...t],stripped:[]};let r=new Set(e.allowExtraArgs),n=[],i=[];for(let o of t)(r.has(o)?n:i).push(o);return{allowed:n,stripped:i}}function bb(e,t,r){if(!r?.enabled)return{ok:!0};if(t===void 0)return{ok:!0};let n=zo.resolve(t),i=zo.resolve(e);if(!$E(n,i))return{ok:!1,error:`out: '${t}' must resolve under state dir '${i}' in gateway mode (resolved '${n}')`};return{ok:!0}}function AE(e){let t=0;for(let r of e)if(Ci(r)==="running")t++;return t}var tP=4;var yn=E(()=>{Ke()});import{spawnSync as rP}from"node:child_process";function nP(e,t){return`ancestor instructions: ${e} loaded ${t.length} instruction file(s) from ancestor directories of cwd: ${t.join(", ")} — pass hermetic: true for an isolated run (#106)`}function ME(e){switch(e){case"claude":return{command:"claude",capabilities:R1()};case"opencode":return{command:"opencode",capabilities:$1};case"kiro":return{command:process.env.KIRO_CLI_BIN??"kiro-cli",capabilities:U1};case"codex":return{command:"codex",capabilities:F1};case"gemini":return{command:"gemini",capabilities:K1};case"null":return{command:null,capabilities:Eh};default:return{command:e}}}function oP(e,t){let r={...e.budgetUsd!==void 0?{usd:e.budgetUsd}:{},...e.maxTurns!==void 0?{maxTurns:e.maxTurns}:{},...e.wallMs!==void 0?{wallMs:e.wallMs}:{},...e.idleMs!==void 0?{idleMs:e.idleMs}:{}};return{prompt:e.prompt,...e.model!==void 0?{model:e.model}:{},...e.cwd!==void 0?{cwd:e.cwd}:{},...r.usd!==void 0||r.maxTurns!==void 0||r.wallMs!==void 0||r.idleMs!==void 0?{budget:r}:{},...e.extraArgs!==void 0?{extraArgs:t}:{},...e.kiro!==void 0?{kiro:e.kiro}:{}}}function sP(e){return rP("which",[e],{stdio:"ignore"}).status===0}function Cb(e){let{command:t}=ME(e);return{command:t,available:t===null?!0:sP(t)}}function TE(e,t){e.registerTool({name:"harness_run",description:"Run one harness agent (claude|opencode|kiro|codex|gemini) with a prompt and optional model/cwd/budget/turn limits; resolves with the full RunResult (sessionId, events, tokens, totalCost, durationMs, exitStatus, warnings).",inputSchema:{type:"object",properties:{agent:{type:"string",enum:[...Be],description:"Agent to run"},prompt:{type:"string",description:"Prompt sent to the agent"},model:{type:"string",description:"Model override"},cwd:{type:"string",description:"Working directory for the agent subprocess"},budgetUsd:{type:"number",description:"Abort the run once cumulative cost exceeds this USD amount"},maxTurns:{type:"integer",description:"Abort the run after this many agent turns"},wallMs:{type:"number",description:"Abort the run if it exceeds this wall-clock duration in milliseconds from launch"},idleMs:{type:"number",description:"Abort the run if no agent events arrive for this many milliseconds"},extraArgs:{type:"array",items:{type:"string"},description:"Extra CLI args appended verbatim"},kiro:Q_,hermetic:{type:"boolean",description:"Run in a fresh temp copy of cwd whose ancestor directories hold no CLAUDE.md/AGENTS.md/GEMINI.md, then sync the edits (and deletions) back; fails if the temp root is not clean (#106)"}},required:["agent","prompt"]},handler:async(r)=>{let n=wb.safeParse(r);if(!n.success){let h=n.error.issues[0];if(!h)throw Error("invalid harness_run arguments");let d=h.path.join(".")||"(root)",p=d==="agent"?` (received '${String(r.agent)}')`:"";throw Error(`invalid harness_run arguments: bad field '${d}': ${h.message}${p}`)}let i=n.data;if(t.gateway){let h=Yo(t.gateway,i.cwd);if(!h.ok)throw Error(h.error)}let o=Jo(t.gateway,i.extraArgs),s=oP(i,o.allowed),_=o.stripped.length>0?`gateway: stripped extraArgs not in allowlist: ${o.stripped.map((h)=>`'${h}'`).join(", ")}`:void 0,l=ti({adapters:await Ut(),stateDir:t.stateDir,registry:{stateDir:t.stateDir},pricer:Ee()}),u=i.hermetic===!0?await Ho(l,i.agent,s,{stateDir:t.stateDir}):await l.run(i.agent,s),a=[...u.ancestorInstructions!==void 0&&u.ancestorInstructions.length>0?[nP(i.agent,u.ancestorInstructions)]:[],..._!==void 0?[_]:[]];return a.length===0?u:{...u,warnings:[...u.warnings,...a]}}}),e.registerTool({name:"harness_agents",description:"List known harness agents with their backing CLI command, whether the binary is resolvable on PATH, and the adapter's capability flags.",inputSchema:{type:"object",properties:{}},handler:async()=>{let r=await Ut();return{agents:Object.keys(r).map((n)=>{let i=ME(n);return{name:n,...Cb(n),capabilities:i.capabilities}})}}})}var wb,Q_;var V_=E(()=>{Me();_e();yr();Ht();ph();F_();K_();yh();xh();Lh();yn();q_();wb=c.object({agent:c.string().refine((e)=>Be.includes(e),{message:"unknown agent (expected one of: "+Be.join(", ")+")"}),prompt:c.string().min(1),model:c.string().optional(),cwd:c.string().optional(),budgetUsd:c.number().positive().optional(),maxTurns:c.number().int().positive().optional(),wallMs:c.number().positive().optional(),idleMs:c.number().positive().optional(),extraArgs:c.array(c.string()).optional(),kiro:wi.optional(),hermetic:c.boolean().optional()}),Q_={type:"object",description:"Kiro-specific run configuration (ignored by other agents)",additionalProperties:!1,properties:{transport:{type:"string",enum:["headless","acp"],description:"Transport: headless CLI chat (default) or the ACP JSON-RPC protocol"},agent:{type:"string",description:"Native Kiro agent / ACP mode id"},engine:{type:"string",enum:["v1","v2","v3"],description:"Agent engine version (default v2)"},effort:{type:"string",enum:["low","medium","high","xhigh","max"],description:"Reasoning effort passed to the CLI"},tools:{description:"Tool trust policy; omit to leave the native agent config in charge",oneOf:[{type:"string",enum:["all"],description:"Trust every tool"},{type:"string",enum:["none"],description:"Trust no tool"},{type:"array",items:{type:"string"},description:"Trust exactly these tool names"}]},requireMcpStartup:{type:"boolean",description:"Fail the run unless every configured MCP server starts before the prompt"},mcpServers:{type:"array",description:"ACP only: MCP servers forwarded to session/new",items:{type:"object",additionalProperties:!1,properties:{name:{type:"string",description:"Server name reported to the agent"},command:{type:"string",description:"Executable launched for the server"},args:{type:"array",items:{type:"string"},description:"Arguments passed to the command"},env:{type:"object",additionalProperties:{type:"string"},description:"Environment variables layered over the server process env"}},required:["name","command"]}},startupMs:{type:"number",description:"Milliseconds allowed for CLI startup/handshake before failing (default 60000)"},requireModelAck:{type:"boolean",description:"ACP: fail before prompting if the model request is not acknowledged"}}}});import Lr from"node:fs/promises";import Dr from"node:path";function Sb(e){if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=e;return Array.isArray(t.events)&&(("tokens"in t)||("exitStatus"in t)||("durationMs"in t))}function UE(e){if(typeof e!=="object"||e===null||Array.isArray(e))return null;let t=e;if(typeof t.repeat!=="object"||t.repeat===null||!Array.isArray(t.runs))return null;let r=t.runs.filter(Sb);return r.length>0?r:null}function Z_(e){let t=typeof e==="number"?e:Number(e);return Number.isFinite(t)?t:0}function qh(e){if(typeof e==="number")return Number.isFinite(e)?e:void 0;if(typeof e==="string"&&e.trim()!==""){let t=Number(e);if(Number.isFinite(t))return t}return}function _P(e){for(let t of e){let r=t.prompt;if(typeof r==="string"&&r.trim())return r.trim()}for(let t of e)if(t.type==="message"&&(t.source==="user"||t.role==="user")){let r=typeof t.content==="string"?t.content:"";if(r.trim())return r.trim()}return null}function OE(e,t,r,n,i,o){let s=Array.isArray(t.tokens)?t.tokens:[],_=0,l=0,u=0,a=0,h=0,d,p=!1,f=null,g=null;for(let re of s){if(_+=Z_(re.inputTokens),l+=Z_(re.outputTokens),u+=Z_(re.cacheReadTokens),a+=Z_(re.cacheWriteTokens),h+=Z_(re.reasoningTokens),typeof re.model==="string"&&re.model!==""&&re.model!=="unknown")g=re.model;let A=qh(re.costUsd);if(A!==void 0)d=(d??0)+A,p=!0;let S=re.extra??{},T=qh(S.credits);if(T!==void 0)f=(f??0)+T}let v=qh(t.totalCost),m=$_.safeParse(t.usage),b=m.success?m.data:void 0,L=b?.tokens.available===!1,C=b?.usd.available===!1,w=C?void 0:p?d:v,D=w===void 0?void 0:p?"reported":"computed",N=Array.isArray(t.events)?t.events:[],X=A_.safeParse(t.verify);return{agent:typeof t.agent==="string"&&t.agent?t.agent:e,trialDir:r,trialLabel:n,result:{...t,tokens:s,events:N},wallSecs:i,hasStderr:o,model:g,inputTokens:_,outputTokens:l,cacheReadTokens:u,cacheWriteTokens:a,reasoningTokens:h,costUsd:w,...D!==void 0?{costProvenance:D}:{},credits:f,task:_P(N),...typeof t.variant==="string"&&t.variant!==""?{variant:t.variant}:{},...b!==void 0?{usage:b}:{},tokensUnavailable:L,usdUnavailable:C,...X.success?{verify:X.data}:{}}}async function NE(e){let t;try{t=await Lr.readFile(e,"utf8")}catch{return null}try{return JSON.parse(t)}catch{return null}}async function BE(e){let t=await Lr.readdir(e,{withFileTypes:!0}).catch(()=>{throw new k(`cannot read trials directory '${e}'`,"IO")}),r=Dr.basename(Dr.resolve(e)),n=[];for(let i of t.sort((o,s)=>o.name.localeCompare(s.name))){if(!i.isFile()||!i.name.endsWith(".json"))continue;let o=await NE(Dr.join(e,i.name)),s=i.name.slice(0,-5),_=UE(o);if(_!==null){_.forEach((h)=>n.push(OE(s,h,e,r,null,!1)));continue}if(!Sb(o))continue;let l=await Lr.readFile(Dr.join(e,`${s}.secs`),"utf8").catch(()=>null),u=l===null?null:qh(l.trim())??null,a=!1;try{await Lr.access(Dr.join(e,`${s}.stderr`)),a=!0}catch{a=!1}n.push(OE(s,o,e,r,u,a))}return n}async function lP(e){try{let t=await Lr.readdir(e,{withFileTypes:!0});for(let r of t){if(!r.isFile()||!r.name.endsWith(".json"))continue;let n=await NE(Dr.join(e,r.name));if(Sb(n)||UE(n)!==null)return!0}}catch{return!1}return!1}async function Xh(e){let t=Dr.resolve(e);if(!(await Lr.stat(t).catch(()=>{throw new k(`trials directory '${e}' does not exist`,"IO")})).isDirectory())throw new k(`'${e}' is not a directory`,"IO");let n=[];if(await lP(t))n.push(...await BE(t));else{let o=(await Lr.readdir(t,{withFileTypes:!0})).sort((s,_)=>s.name.localeCompare(_.name));for(let s of o){if(!s.isDirectory())continue;n.push(...await BE(Dr.join(t,s.name)))}}if(n.length===0)throw new k(`no RunResult JSON files found under '${e}'`,"IO");let i=[...new Set(n.map((o)=>o.trialLabel))].sort();return{rootDir:t,labels:i,runs:n}}var yb=E(()=>{_e();ln()});function uP(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}function xb(e,t){let r=e!==void 0&&e!=="",i=r?e:!r&&t!==void 0&&t!==""?t:"local",o=i.toLowerCase();if(o==="local")return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";if(o==="utc"||o==="z"||o==="gmt")return"UTC";if(!uP(i))throw kn(`${r?"--tz":zh}: unknown time zone '${i}' (expected an IANA zone name such as America/Los_Angeles or Asia/Tokyo, or 'utc' / 'local')`);return new Intl.DateTimeFormat("en-US",{timeZone:i}).resolvedOptions().timeZone}function aP(e){let t=PE.get(e);if(!t)t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),PE.set(e,t);return t}function Zo(e,t){let r={};for(let n of aP(t).formatToParts(new Date(e)))if(n.type!=="literal")r[n.type]=Number(n.value);return{y:r.year,m:r.month,d:r.day,hh:r.hour%24,mm:r.minute,ss:r.second}}function FE(e,t){let r=Zo(e,t);return Date.UTC(r.y,r.m-1,r.d,r.hh,r.mm,r.ss)-(e-(e%1000+1000)%1000)}function kb(e,t,r,n){let i=Date.UTC(e,t-1,r),o=i-FE(i,n),s=i-FE(o,n);if(s!==o)o=s;return o}function hP(e,t){let r=Zo(e,t);return`${Vo(r.y,4)}-${Vo(r.m)}-${Vo(r.d)}`}function cP(e,t){let r=Zo(e,t);return`${Vo(r.y,4)}-${Vo(r.m)}`}function dP(e,t){let r=Zo(e,t),n=new Date(Date.UTC(r.y,r.m-1,r.d)),i=n.getUTCDay()||7;n.setUTCDate(n.getUTCDate()+4-i);let o=n.getUTCFullYear(),s=Date.UTC(o,0,1),_=Math.ceil(((n.getTime()-s)/86400000+1)/7);return`${o}-W${Vo(_)}`}function Di(e,t,r){let n=e?Date.parse(e):NaN;if(!Number.isFinite(n))return"unknown";return t==="day"?hP(n,r):t==="week"?dP(n,r):cP(n,r)}function KE(e){let t=fP.exec(e.trim());if(!t)return;return Number(t[1])*gP[t[2].toLowerCase()]}function WE(e,t,r="date"){let n=e.trim(),i=()=>kn(`${r}: cannot parse '${e}' (${pP})`),o=n.toLowerCase();if(o==="now")return t.now;if(o==="today"||o==="yesterday"){let l=Zo(t.now,t.timeZone),u=kb(l.y,l.m,l.d,t.timeZone);if(o==="today")return u;let a=Zo(u-43200000,t.timeZone);return kb(a.y,a.m,a.d,t.timeZone)}let s=/^(.+?)\s+ago$/i.exec(n);if(s){let l=KE(s[1]);if(l===void 0)throw i();return t.now-l}let _=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(_){let[l,u,a]=[Number(_[1]),Number(_[2]),Number(_[3])],h=new Date(Date.UTC(l,u-1,a));if(u<1||u>12||h.getUTCMonth()!==u-1||h.getUTCDate()!==a)throw i();return kb(l,u,a,t.timeZone)}if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})$/i.test(n)){let l=Date.parse(n.replace(" ","T"));if(Number.isFinite(l))return l}throw i()}function Eb(e){if(e.days!==void 0){let r=e.since!==void 0?"--since":e.until!==void 0?"--until":e.last!==void 0?"--last":void 0;if(r)throw kn(`--days cannot be combined with ${r} (use one way to express the window)`);return{sinceMs:e.now-e.days*86400000}}if(e.last!==void 0&&e.since!==void 0)throw kn(`--last cannot be combined with --since ('--last 7d' is sugar for '--since "7d ago"')`);let t={};if(e.last!==void 0){let r=KE(e.last);if(r===void 0)throw kn(`--last: cannot parse '${e.last}' (expected <N>m|h|d|w, e.g. 7d)`);t.sinceMs=e.now-r}else if(e.since!==void 0)t.sinceMs=WE(e.since,e,"--since");if(e.until!==void 0)t.untilMs=WE(e.until,e,"--until");if(t.sinceMs!==void 0&&t.untilMs!==void 0&&t.sinceMs>=t.untilMs)throw kn(`empty window: --since ${new Date(t.sinceMs).toISOString()} is not before --until ${new Date(t.untilMs).toISOString()}`);return t}function es(e,t){if(t.sinceMs===void 0&&t.untilMs===void 0)return!0;if(!Number.isFinite(e))return!1;if(t.sinceMs!==void 0&&e<t.sinceMs)return!1;if(t.untilMs!==void 0&&e>=t.untilMs)return!1;return!0}function HE(e){return{since:e.sinceMs===void 0?null:new Date(e.sinceMs).toISOString(),until:e.untilMs===void 0?null:new Date(e.untilMs).toISOString()}}function Db(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r];if((n==="--since"||n==="--until")&&e[r+2]==="ago"){t.push(n,`${e[r+1]} ago`),r+=2;continue}if((n.startsWith("--since=")||n.startsWith("--until="))&&e[r+1]==="ago"){t.push(`${n} ago`),r+=1;continue}t.push(n)}return t}function jE(e){if(!e||e.length===0)return["day"];let t=new Set;for(let r of e.flatMap((n)=>n.split(","))){let n=r.trim().toLowerCase();if(n==="")continue;if(!Qo.includes(n))throw kn(`--by: unknown granularity '${r}' (expected one of: ${Qo.join(", ")})`);t.add(n)}if(t.size===0)return["day"];return Qo.filter((r)=>t.has(r))}var zh="AGENTIC_CODING_HARNESS_TZ",Qo,kn=(e)=>new k(e,"USAGE"),PE,Vo=(e,t=2)=>String(e).padStart(t,"0"),pP="accepted: YYYY-MM-DD (midnight in the --tz zone), an RFC 3339 timestamp (2026-09-01T12:00:00Z), '<N>m|h|d|w ago' (e.g. '7d ago'), today, yesterday, now",fP,gP;var el=E(()=>{_e();Qo=["day","week","month"];PE=new Map;fP=/^(\d+(?:\.\d+)?)\s*(m|min|h|d|w)$/i,gP={m:60000,min:60000,h:3600000,d:86400000,w:604800000}});import GE from"node:path";function mt(e,t){let r=e.dir,n=e[t];if(r!==void 0&&n!==void 0&&GE.resolve(r)!==GE.resolve(n))throw new k(`--${t} '${n}' and --dir '${r}' disagree (--dir is an alias of --${t}; pass one)`,"USAGE");return n??r}function qE(e){for(let t of e){if(t==="--")return!1;if(t==="-h"||t==="--help")return!0}return!1}function XE(e,t){let r=new Set(t.map((i)=>`--${i}`)),n=[];for(let i=0;i<e.length;i++){let o=e[i];if(o==="--")return n.push(...e.slice(i)),n;if(r.has(o)&&i+1<e.length){n.push(`${o}=${e[i+1]}`),i+=1;continue}n.push(o)}return n}function Rb(e){if(e===void 0)return;return e.flatMap((t)=>t.split(" ")).filter(Boolean)}function vP(e){let t=new Date(e);return`${Lb(t.getHours())}:${Lb(t.getMinutes())}:${Lb(t.getSeconds())}`}function se(e){return e.toLocaleString("en-US")}function Ie(e){return`$${e.toFixed(4)}`}function Yh(e,t=mP){let r=e.replace(/\s+/g," ").trim();return r.length>t?r.slice(0,t-1)+"…":r}function zE(e,t){let r=vP(Date.now());switch(e.type){case"model_call_start":if(t&&e.callId&&typeof e.timestamp==="number")t.set(e.callId,e.timestamp);return null;case"model_call_end":{let n=e.callId?t?.get(e.callId):void 0;if(e.callId)t?.delete(e.callId);let i=[e.model??""];if(typeof e.outputTokens==="number")i.push(`${e.outputTokens} out`);if(n!==void 0&&typeof e.timestamp==="number")i.push(`${e.timestamp-n}ms`);if(e.provenance==="estimated")i.push("estimated");return`[${r}] model ${i.filter(Boolean).join(" · ")}`.trimEnd()}case"step":return`[${r}] step`;case"usage_raw":return`[${r}] usage (${typeof e.agent==="string"?e.agent:"agent"})`;case"usage":return`[${r}] usage`;case"message":return`[${r}] text ${Yh(typeof e.data==="string"?e.data:String(e.content??""))}`;case"tool_call":return`[${r}] tool ${String(e.functionName??"?")}`;case"tool_result":return`[${r}] result ${String(e.toolCallId??"")}`;case"progress":return`[${r}] » ${Yh(String(e.data??""))}`;case"error":return`[${r}] error ${Yh(typeof e.data==="string"?e.data:String(e.message??""))}`;default:{let n=typeof e.data==="string"?e.data:"";return`[${r}] ${e.type.padEnd(7)} ${Yh(n)}`.trimEnd()}}}function YE(e){let t=e.tokens,r=e.usage?.tokens.available===!1,n=e.usage?.usd.available===!1,i=[`sessionId ${e.sessionId??"-"}`,r?"tokens input=n/a output=n/a cacheRead=n/a cacheWrite=n/a reasoning=n/a":`tokens input=${se(t.input)} output=${se(t.output)} cacheRead=${se(t.cacheRead)} cacheWrite=${se(t.cacheWrite)} reasoning=${se(t.reasoning)}`,`cost ${n?"n/a":Ie(e.costUsd)}`],o=e.usage?.context;if(o?.available===!0&&o.tokens!==void 0)i.push(`context ${bP(o)}${o.windowSource==="assumed"?" (assumed window)":""}`+(o.toolOutputShare!==void 0?` tool-output ~${(o.toolOutputShare*100).toFixed(0)}% (estimated)`:""));return i.push(`duration ${(e.durationMs/1000).toFixed(1)}s`,`exit ${e.exitStatus}`),i.join(`
|
|
285
|
+
`)}return 0}var jh=E(()=>{Kh();_e();j_();G_();Ke();He()});import zo from"node:path";function RE(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function iP(e){if(e===void 0)return[];return(Array.isArray(e)?e:e.split(",")).map((r)=>r.trim()).filter((r)=>r.length>0)}function Gh(e,t=process.env){let r=e.gateway!==void 0?e.gateway:t.AGENTIC_CODING_HARNESS_GATEWAY==="1",n=e.root??t.AGENTIC_CODING_HARNESS_ROOT,i=e.maxJobs??RE(t.AGENTIC_CODING_HARNESS_MAX_JOBS??"")??tP,o=e.maxOutputBytes??RE(t.AGENTIC_CODING_HARNESS_MAX_OUTPUT_BYTES??""),s=iP(e.allowExtraArgs??t.AGENTIC_CODING_HARNESS_ALLOW_EXTRA_ARGS);return{enabled:r,...n!==void 0?{root:zo.resolve(n)}:{},maxJobs:i,...o!==void 0?{maxOutputBytes:o}:{},allowExtraArgs:s}}function $E(e,t){let r=t.endsWith(zo.sep)?t:t+zo.sep;return e===t||e.startsWith(r)}function Yo(e,t){if(!e?.enabled)return{ok:!0};if(e.root===void 0)return{ok:!1,error:"gateway root: required in gateway mode (pass --root or set AGENTIC_CODING_HARNESS_ROOT)"};if(t===void 0)return{ok:!0};let r=zo.resolve(t);if(!$E(r,e.root))return{ok:!1,error:`cwd: '${t}' must resolve under gateway root '${e.root}' (resolved '${r}')`};return{ok:!0}}function Jo(e,t){if(!e?.enabled||t===void 0)return{allowed:t===void 0?[]:[...t],stripped:[]};let r=new Set(e.allowExtraArgs),n=[],i=[];for(let o of t)(r.has(o)?n:i).push(o);return{allowed:n,stripped:i}}function bb(e,t,r){if(!r?.enabled)return{ok:!0};if(t===void 0)return{ok:!0};let n=zo.resolve(t),i=zo.resolve(e);if(!$E(n,i))return{ok:!1,error:`out: '${t}' must resolve under state dir '${i}' in gateway mode (resolved '${n}')`};return{ok:!0}}function AE(e){let t=0;for(let r of e)if(Ci(r)==="running")t++;return t}var tP=4;var yn=E(()=>{Ke()});import{spawnSync as rP}from"node:child_process";function nP(e,t){return`ancestor instructions: ${e} loaded ${t.length} instruction file(s) from ancestor directories of cwd: ${t.join(", ")} — pass hermetic: true for an isolated run (#106)`}function ME(e){switch(e){case"claude":return{command:"claude",capabilities:R1()};case"opencode":return{command:"opencode",capabilities:$1};case"kiro":return{command:process.env.KIRO_CLI_BIN??"kiro-cli",capabilities:U1};case"codex":return{command:"codex",capabilities:F1};case"gemini":return{command:"gemini",capabilities:K1};case"null":return{command:null,capabilities:Eh};default:return{command:e}}}function oP(e,t){let r={...e.budgetUsd!==void 0?{usd:e.budgetUsd}:{},...e.maxTurns!==void 0?{maxTurns:e.maxTurns}:{},...e.wallMs!==void 0?{wallMs:e.wallMs}:{},...e.idleMs!==void 0?{idleMs:e.idleMs}:{}};return{prompt:e.prompt,...e.model!==void 0?{model:e.model}:{},...e.cwd!==void 0?{cwd:e.cwd}:{},...r.usd!==void 0||r.maxTurns!==void 0||r.wallMs!==void 0||r.idleMs!==void 0?{budget:r}:{},...e.extraArgs!==void 0?{extraArgs:t}:{},...e.kiro!==void 0?{kiro:e.kiro}:{}}}function sP(e){return rP("which",[e],{stdio:"ignore"}).status===0}function Cb(e){let{command:t}=ME(e);return{command:t,available:t===null?!0:sP(t)}}function TE(e,t){e.registerTool({name:"harness_run",description:"Run one harness agent (claude|opencode|kiro|codex|gemini) with a prompt and optional model/cwd/budget/turn limits; resolves with the full RunResult (sessionId, events, tokens, totalCost, durationMs, exitStatus, warnings).",inputSchema:{type:"object",properties:{agent:{type:"string",enum:[...Be],description:"Agent to run"},prompt:{type:"string",description:"Prompt sent to the agent"},model:{type:"string",description:"Model override"},cwd:{type:"string",description:"Working directory for the agent subprocess"},budgetUsd:{type:"number",description:"Abort the run once cumulative cost exceeds this USD amount"},maxTurns:{type:"integer",description:"Abort the run after this many agent turns"},wallMs:{type:"number",description:"Abort the run if it exceeds this wall-clock duration in milliseconds from launch"},idleMs:{type:"number",description:"Abort the run if no agent events arrive for this many milliseconds"},extraArgs:{type:"array",items:{type:"string"},description:"Extra CLI args appended verbatim"},kiro:Q_,hermetic:{type:"boolean",description:"Run in a fresh temp copy of cwd whose ancestor directories hold no CLAUDE.md/AGENTS.md/GEMINI.md, then sync the edits (and deletions) back; fails if the temp root is not clean (#106)"}},required:["agent","prompt"]},handler:async(r)=>{let n=wb.safeParse(r);if(!n.success){let h=n.error.issues[0];if(!h)throw Error("invalid harness_run arguments");let d=h.path.join(".")||"(root)",p=d==="agent"?` (received '${String(r.agent)}')`:"";throw Error(`invalid harness_run arguments: bad field '${d}': ${h.message}${p}`)}let i=n.data;if(t.gateway){let h=Yo(t.gateway,i.cwd);if(!h.ok)throw Error(h.error)}let o=Jo(t.gateway,i.extraArgs),s=oP(i,o.allowed),_=o.stripped.length>0?`gateway: stripped extraArgs not in allowlist: ${o.stripped.map((h)=>`'${h}'`).join(", ")}`:void 0,l=ti({adapters:await Ut(),stateDir:t.stateDir,registry:{stateDir:t.stateDir},pricer:Ee()}),u=i.hermetic===!0?await Ho(l,i.agent,s,{stateDir:t.stateDir}):await l.run(i.agent,s),a=[...u.ancestorInstructions!==void 0&&u.ancestorInstructions.length>0?[nP(i.agent,u.ancestorInstructions)]:[],..._!==void 0?[_]:[]];return a.length===0?u:{...u,warnings:[...u.warnings,...a]}}}),e.registerTool({name:"harness_agents",description:"List known harness agents with their backing CLI command, whether the binary is resolvable on PATH, and the adapter's capability flags.",inputSchema:{type:"object",properties:{}},handler:async()=>{let r=await Ut();return{agents:Object.keys(r).map((n)=>{let i=ME(n);return{name:n,...Cb(n),capabilities:i.capabilities}})}}})}var wb,Q_;var V_=E(()=>{Me();_e();yr();Ht();ph();F_();K_();yh();xh();Lh();yn();q_();wb=c.object({agent:c.string().refine((e)=>Be.includes(e),{message:"unknown agent (expected one of: "+Be.join(", ")+")"}),prompt:c.string().min(1),model:c.string().optional(),cwd:c.string().optional(),budgetUsd:c.number().positive().optional(),maxTurns:c.number().int().positive().optional(),wallMs:c.number().positive().optional(),idleMs:c.number().positive().optional(),extraArgs:c.array(c.string()).optional(),kiro:wi.optional(),hermetic:c.boolean().optional()}),Q_={type:"object",description:"Kiro-specific run configuration (ignored by other agents)",additionalProperties:!1,properties:{transport:{type:"string",enum:["headless","acp"],description:"Transport: headless CLI chat (default) or the ACP JSON-RPC protocol"},agent:{type:"string",description:"Native Kiro agent / ACP mode id"},engine:{type:"string",enum:["v1","v2","v3"],description:"Agent engine version (default v2)"},effort:{type:"string",enum:["low","medium","high","xhigh","max"],description:"Reasoning effort passed to the CLI"},tools:{description:"Tool trust policy; omit to leave the native agent config in charge",oneOf:[{type:"string",enum:["all"],description:"Trust every tool"},{type:"string",enum:["none"],description:"Trust no tool"},{type:"array",items:{type:"string"},description:"Trust exactly these tool names"}]},requireMcpStartup:{type:"boolean",description:"Fail the run unless every configured MCP server starts before the prompt"},mcpServers:{type:"array",description:"ACP only: MCP servers forwarded to session/new",items:{type:"object",additionalProperties:!1,properties:{name:{type:"string",description:"Server name reported to the agent"},command:{type:"string",description:"Executable launched for the server"},args:{type:"array",items:{type:"string"},description:"Arguments passed to the command"},env:{type:"object",additionalProperties:{type:"string"},description:"Environment variables layered over the server process env"}},required:["name","command"]}},startupMs:{type:"number",description:"Milliseconds allowed for CLI startup/handshake before failing (default 60000)"},requireModelAck:{type:"boolean",description:"ACP: fail before prompting if the model request is not acknowledged"}}}});import Lr from"node:fs/promises";import Dr from"node:path";function Sb(e){if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=e;return Array.isArray(t.events)&&(("tokens"in t)||("exitStatus"in t)||("durationMs"in t))}function UE(e){if(typeof e!=="object"||e===null||Array.isArray(e))return null;let t=e;if(typeof t.repeat!=="object"||t.repeat===null||!Array.isArray(t.runs))return null;let r=t.runs.filter(Sb);return r.length>0?r:null}function Z_(e){let t=typeof e==="number"?e:Number(e);return Number.isFinite(t)?t:0}function qh(e){if(typeof e==="number")return Number.isFinite(e)?e:void 0;if(typeof e==="string"&&e.trim()!==""){let t=Number(e);if(Number.isFinite(t))return t}return}function _P(e){for(let t of e){let r=t.prompt;if(typeof r==="string"&&r.trim())return r.trim()}for(let t of e)if(t.type==="message"&&(t.source==="user"||t.role==="user")){let r=typeof t.content==="string"?t.content:"";if(r.trim())return r.trim()}return null}function OE(e,t,r,n,i,o){let s=Array.isArray(t.tokens)?t.tokens:[],_=0,l=0,u=0,a=0,h=0,d,p=!1,f=null,g=null;for(let re of s){if(_+=Z_(re.inputTokens),l+=Z_(re.outputTokens),u+=Z_(re.cacheReadTokens),a+=Z_(re.cacheWriteTokens),h+=Z_(re.reasoningTokens),typeof re.model==="string"&&re.model!==""&&re.model!=="unknown")g=re.model;let A=qh(re.costUsd);if(A!==void 0)d=(d??0)+A,p=!0;let S=re.extra??{},T=qh(S.credits);if(T!==void 0)f=(f??0)+T}let v=qh(t.totalCost),m=$_.safeParse(t.usage),b=m.success?m.data:void 0,L=b?.tokens.available===!1,C=b?.usd.available===!1,w=C?void 0:p?d:v,D=w===void 0?void 0:p?"reported":"computed",N=Array.isArray(t.events)?t.events:[],X=A_.safeParse(t.verify);return{agent:typeof t.agent==="string"&&t.agent?t.agent:e,trialDir:r,trialLabel:n,result:{...t,tokens:s,events:N},wallSecs:i,hasStderr:o,model:g,inputTokens:_,outputTokens:l,cacheReadTokens:u,cacheWriteTokens:a,reasoningTokens:h,costUsd:w,...D!==void 0?{costProvenance:D}:{},credits:f,task:_P(N),...typeof t.variant==="string"&&t.variant!==""?{variant:t.variant}:{},...b!==void 0?{usage:b}:{},tokensUnavailable:L,usdUnavailable:C,...X.success?{verify:X.data}:{}}}async function NE(e){let t;try{t=await Lr.readFile(e,"utf8")}catch{return null}try{return JSON.parse(t)}catch{return null}}async function BE(e){let t=await Lr.readdir(e,{withFileTypes:!0}).catch(()=>{throw new k(`cannot read trials directory '${e}'`,"IO")}),r=Dr.basename(Dr.resolve(e)),n=[];for(let i of t.sort((o,s)=>o.name.localeCompare(s.name))){if(!i.isFile()||!i.name.endsWith(".json"))continue;let o=await NE(Dr.join(e,i.name)),s=i.name.slice(0,-5),_=UE(o);if(_!==null){_.forEach((h)=>n.push(OE(s,h,e,r,null,!1)));continue}if(!Sb(o))continue;let l=await Lr.readFile(Dr.join(e,`${s}.secs`),"utf8").catch(()=>null),u=l===null?null:qh(l.trim())??null,a=!1;try{await Lr.access(Dr.join(e,`${s}.stderr`)),a=!0}catch{a=!1}n.push(OE(s,o,e,r,u,a))}return n}async function lP(e){try{let t=await Lr.readdir(e,{withFileTypes:!0});for(let r of t){if(!r.isFile()||!r.name.endsWith(".json"))continue;let n=await NE(Dr.join(e,r.name));if(Sb(n)||UE(n)!==null)return!0}}catch{return!1}return!1}async function Xh(e){let t=Dr.resolve(e);if(!(await Lr.stat(t).catch(()=>{throw new k(`trials directory '${e}' does not exist`,"IO")})).isDirectory())throw new k(`'${e}' is not a directory`,"IO");let n=[];if(await lP(t))n.push(...await BE(t));else{let o=(await Lr.readdir(t,{withFileTypes:!0})).sort((s,_)=>s.name.localeCompare(_.name));for(let s of o){if(!s.isDirectory())continue;n.push(...await BE(Dr.join(t,s.name)))}}if(n.length===0)throw new k(`no RunResult JSON files found under '${e}'`,"IO");let i=[...new Set(n.map((o)=>o.trialLabel))].sort();return{rootDir:t,labels:i,runs:n}}var yb=E(()=>{_e();ln()});function uP(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}function xb(e,t){let r=e!==void 0&&e!=="",i=r?e:!r&&t!==void 0&&t!==""?t:"local",o=i.toLowerCase();if(o==="local")return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";if(o==="utc"||o==="z"||o==="gmt")return"UTC";if(!uP(i))throw kn(`${r?"--tz":zh}: unknown time zone '${i}' (expected an IANA zone name such as America/Los_Angeles or Asia/Tokyo, or 'utc' / 'local')`);return new Intl.DateTimeFormat("en-US",{timeZone:i}).resolvedOptions().timeZone}function aP(e){let t=PE.get(e);if(!t)t=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),PE.set(e,t);return t}function Zo(e,t){let r={};for(let n of aP(t).formatToParts(new Date(e)))if(n.type!=="literal")r[n.type]=Number(n.value);return{y:r.year,m:r.month,d:r.day,hh:r.hour%24,mm:r.minute,ss:r.second}}function FE(e,t){let r=Zo(e,t);return Date.UTC(r.y,r.m-1,r.d,r.hh,r.mm,r.ss)-(e-(e%1000+1000)%1000)}function kb(e,t,r,n){let i=Date.UTC(e,t-1,r),o=i-FE(i,n),s=i-FE(o,n);if(s!==o)o=s;return o}function hP(e,t){let r=Zo(e,t);return`${Vo(r.y,4)}-${Vo(r.m)}-${Vo(r.d)}`}function cP(e,t){let r=Zo(e,t);return`${Vo(r.y,4)}-${Vo(r.m)}`}function dP(e,t){let r=Zo(e,t),n=new Date(Date.UTC(r.y,r.m-1,r.d)),i=n.getUTCDay()||7;n.setUTCDate(n.getUTCDate()+4-i);let o=n.getUTCFullYear(),s=Date.UTC(o,0,1),_=Math.ceil(((n.getTime()-s)/86400000+1)/7);return`${o}-W${Vo(_)}`}function Di(e,t,r){let n=e?Date.parse(e):NaN;if(!Number.isFinite(n))return"unknown";return t==="day"?hP(n,r):t==="week"?dP(n,r):cP(n,r)}function KE(e){let t=fP.exec(e.trim());if(!t)return;return Number(t[1])*gP[t[2].toLowerCase()]}function WE(e,t,r="date"){let n=e.trim(),i=()=>kn(`${r}: cannot parse '${e}' (${pP})`),o=n.toLowerCase();if(o==="now")return t.now;if(o==="today"||o==="yesterday"){let l=Zo(t.now,t.timeZone),u=kb(l.y,l.m,l.d,t.timeZone);if(o==="today")return u;let a=Zo(u-43200000,t.timeZone);return kb(a.y,a.m,a.d,t.timeZone)}let s=/^(.+?)\s+ago$/i.exec(n);if(s){let l=KE(s[1]);if(l===void 0)throw i();return t.now-l}let _=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(_){let[l,u,a]=[Number(_[1]),Number(_[2]),Number(_[3])],h=new Date(Date.UTC(l,u-1,a));if(u<1||u>12||h.getUTCMonth()!==u-1||h.getUTCDate()!==a)throw i();return kb(l,u,a,t.timeZone)}if(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})$/i.test(n)){let l=Date.parse(n.replace(" ","T"));if(Number.isFinite(l))return l}throw i()}function Eb(e){if(e.days!==void 0){let r=e.since!==void 0?"--since":e.until!==void 0?"--until":e.last!==void 0?"--last":void 0;if(r)throw kn(`--days cannot be combined with ${r} (use one way to express the window)`);return{sinceMs:e.now-e.days*86400000}}if(e.last!==void 0&&e.since!==void 0)throw kn(`--last cannot be combined with --since ('--last 7d' is sugar for '--since "7d ago"')`);let t={};if(e.last!==void 0){let r=KE(e.last);if(r===void 0)throw kn(`--last: cannot parse '${e.last}' (expected <N>m|h|d|w, e.g. 7d)`);t.sinceMs=e.now-r}else if(e.since!==void 0)t.sinceMs=WE(e.since,e,"--since");if(e.until!==void 0)t.untilMs=WE(e.until,e,"--until");if(t.sinceMs!==void 0&&t.untilMs!==void 0&&t.sinceMs>=t.untilMs)throw kn(`empty window: --since ${new Date(t.sinceMs).toISOString()} is not before --until ${new Date(t.untilMs).toISOString()}`);return t}function es(e,t){if(t.sinceMs===void 0&&t.untilMs===void 0)return!0;if(!Number.isFinite(e))return!1;if(t.sinceMs!==void 0&&e<t.sinceMs)return!1;if(t.untilMs!==void 0&&e>=t.untilMs)return!1;return!0}function HE(e){return{since:e.sinceMs===void 0?null:new Date(e.sinceMs).toISOString(),until:e.untilMs===void 0?null:new Date(e.untilMs).toISOString()}}function Db(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r];if((n==="--since"||n==="--until")&&e[r+2]==="ago"){t.push(n,`${e[r+1]} ago`),r+=2;continue}if((n.startsWith("--since=")||n.startsWith("--until="))&&e[r+1]==="ago"){t.push(`${n} ago`),r+=1;continue}t.push(n)}return t}function jE(e){if(!e||e.length===0)return["day"];let t=new Set;for(let r of e.flatMap((n)=>n.split(","))){let n=r.trim().toLowerCase();if(n==="")continue;if(!Qo.includes(n))throw kn(`--by: unknown granularity '${r}' (expected one of: ${Qo.join(", ")})`);t.add(n)}if(t.size===0)return["day"];return Qo.filter((r)=>t.has(r))}var zh="AGENTIC_CODING_HARNESS_TZ",Qo,kn=(e)=>new k(e,"USAGE"),PE,Vo=(e,t=2)=>String(e).padStart(t,"0"),pP="accepted: YYYY-MM-DD (midnight in the --tz zone), an RFC 3339 timestamp (2026-09-01T12:00:00Z), '<N>m|h|d|w ago' (e.g. '7d ago'), today, yesterday, now",fP,gP;var el=E(()=>{_e();Qo=["day","week","month"];PE=new Map;fP=/^(\d+(?:\.\d+)?)\s*(m|min|h|d|w)$/i,gP={m:60000,min:60000,h:3600000,d:86400000,w:604800000}});import GE from"node:path";function mt(e,t){let r=e.dir,n=e[t];if(r!==void 0&&n!==void 0&&GE.resolve(r)!==GE.resolve(n))throw new k(`--${t} '${n}' and --dir '${r}' disagree (--dir is an alias of --${t}; pass one)`,"USAGE");return n??r}function qE(e){for(let t of e){if(t==="--")return!1;if(t==="-h"||t==="--help")return!0}return!1}function XE(e,t){let r=new Set(t.map((i)=>`--${i}`)),n=[];for(let i=0;i<e.length;i++){let o=e[i];if(o==="--")return n.push(...e.slice(i)),n;if(r.has(o)&&i+1<e.length){n.push(`${o}=${e[i+1]}`),i+=1;continue}n.push(o)}return n}function Rb(e){if(e===void 0)return;let t=!1,r=[];for(let n of e){if(n.kind!=="option"||n.value===void 0)continue;if(n.name==="extra-args")t=!0,r.push(...n.value.split(" ").filter(Boolean));else if(n.name==="extra-arg")t=!0,r.push(n.value)}return t?r:void 0}function vP(e){let t=new Date(e);return`${Lb(t.getHours())}:${Lb(t.getMinutes())}:${Lb(t.getSeconds())}`}function se(e){return e.toLocaleString("en-US")}function Ie(e){return`$${e.toFixed(4)}`}function Yh(e,t=mP){let r=e.replace(/\s+/g," ").trim();return r.length>t?r.slice(0,t-1)+"…":r}function zE(e,t){let r=vP(Date.now());switch(e.type){case"model_call_start":if(t&&e.callId&&typeof e.timestamp==="number")t.set(e.callId,e.timestamp);return null;case"model_call_end":{let n=e.callId?t?.get(e.callId):void 0;if(e.callId)t?.delete(e.callId);let i=[e.model??""];if(typeof e.outputTokens==="number")i.push(`${e.outputTokens} out`);if(n!==void 0&&typeof e.timestamp==="number")i.push(`${e.timestamp-n}ms`);if(e.provenance==="estimated")i.push("estimated");return`[${r}] model ${i.filter(Boolean).join(" · ")}`.trimEnd()}case"step":return`[${r}] step`;case"usage_raw":return`[${r}] usage (${typeof e.agent==="string"?e.agent:"agent"})`;case"usage":return`[${r}] usage`;case"message":return`[${r}] text ${Yh(typeof e.data==="string"?e.data:String(e.content??""))}`;case"tool_call":return`[${r}] tool ${String(e.functionName??"?")}`;case"tool_result":return`[${r}] result ${String(e.toolCallId??"")}`;case"progress":return`[${r}] » ${Yh(String(e.data??""))}`;case"error":return`[${r}] error ${Yh(typeof e.data==="string"?e.data:String(e.message??""))}`;default:{let n=typeof e.data==="string"?e.data:"";return`[${r}] ${e.type.padEnd(7)} ${Yh(n)}`.trimEnd()}}}function YE(e){let t=e.tokens,r=e.usage?.tokens.available===!1,n=e.usage?.usd.available===!1,i=[`sessionId ${e.sessionId??"-"}`,r?"tokens input=n/a output=n/a cacheRead=n/a cacheWrite=n/a reasoning=n/a":`tokens input=${se(t.input)} output=${se(t.output)} cacheRead=${se(t.cacheRead)} cacheWrite=${se(t.cacheWrite)} reasoning=${se(t.reasoning)}`,`cost ${n?"n/a":Ie(e.costUsd)}`],o=e.usage?.context;if(o?.available===!0&&o.tokens!==void 0)i.push(`context ${bP(o)}${o.windowSource==="assumed"?" (assumed window)":""}`+(o.toolOutputShare!==void 0?` tool-output ~${(o.toolOutputShare*100).toFixed(0)}% (estimated)`:""));return i.push(`duration ${(e.durationMs/1000).toFixed(1)}s`,`exit ${e.exitStatus}`),i.join(`
|
|
286
286
|
`)}function bP(e){if(e.available!==!0||e.tokens===void 0)return"n/a";let t=e.percentage===void 0?"":` (${e.percentage.toFixed(1)}%)`;return`ctx ${e.basis==="turn-total"?"<=":"~="} ${se(e.tokens)} tok${t}`}function tl(e){return e<1000?`${Math.round(e)}ms`:`${(e/1000).toFixed(e<1e4?2:1)}s`}function JE(e){if(e===void 0)return[];let t=[];if(e.ttft!==null){let r=e.ttft;t.push(`ttft avg ${tl(r.avgMs)} · p50 ${tl(r.p50Ms)} · p95 ${tl(r.p95Ms)} (${r.count} call${r.count===1?"":"s"})`)}if(e.outputTokensPerSec!==null&&e.tpotMs!==null)t.push(`throughput ${e.outputTokensPerSec.toFixed(1)} tok/s · tpot ${e.tpotMs.toFixed(1)}ms`);if(e.tools.length>0){let r=e.tools.slice(0,5).map((i)=>`${i.name} ${i.count}× avg ${tl(i.avgMs)} max ${tl(i.maxMs)}`),n=e.tools.length>5?` · +${e.tools.length-5} more`:"";t.push(`tools ${r.join(" · ")}${n}`)}return t}function qi(){return{records:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,reasoningTokens:0,costUsd:0,costSource:null,costBySource:{reported:null,computed:null},unpricedRecords:0}}function il(e,t){if(e.records+=1,e.inputTokens+=t.inputTokens,e.outputTokens+=t.outputTokens,e.cacheReadTokens+=t.cacheReadTokens,e.cacheWriteTokens+=t.cacheWriteTokens,e.reasoningTokens+=t.reasoningTokens,e.costUsd+=t.costUsd??0,t.costUsd===void 0)e.unpricedRecords+=1;if(t.costSource!==void 0&&t.costUsd!==void 0)e.costBySource[t.costSource]=(e.costBySource[t.costSource]??0)+t.costUsd}function QE(e){e.costUsd=Ib(e.costUsd);let{reported:t,computed:r}=e.costBySource;return e.costBySource={reported:t===null?null:Ib(t),computed:r===null?null:Ib(r)},e.costSource=t!==null&&r===null?"reported":r!==null&&t===null?"computed":null,e}function Ir(e,t={}){let r=qi(),n={},i={},o=t.timeZone,s=t.by?.includes("week")?{}:void 0,_=t.by?.includes("month")?{}:void 0;for(let u of e){il(r,u),il(n[u.agent]??=qi(),u);let a=o===void 0?u.ts?u.ts.slice(0,10):"unknown":Di(u.ts,"day",o);if(il(i[a]??=qi(),u),s)il(s[Di(u.ts,"week",o??"UTC")]??=qi(),u);if(_)il(_[Di(u.ts,"month",o??"UTC")]??=qi(),u)}let l={totals:QE(r),byAgent:Jh(n),byDay:Jh(i)};if(s)l.byWeek=Jh(s);if(_)l.byMonth=Jh(_);return l}function Jh(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,QE(r)]))}var Lb=(e)=>String(e).padStart(2,"0"),mP=60,Ib=(e)=>Math.round(e*1e6)/1e6;var Lt=E(()=>{_e();el()});import $b from"node:fs";import Qh from"node:path";import{parseArgs as wP}from"node:util";function Vh(e){try{return $b.readFileSync(e,"utf8")}catch{return null}}function Rr(e,t,r){return{status:t,runId:e,records:0,sealed:!1,notes:[r],checks:[]}}function VE(e,t){if(e.status!=="open"||typeof t!=="string"||t==="running")return e;let r=e.checks.at(-1)?.line??0;return{...e,status:"tampered",firstBad:{line:r+1,seq:e.records,reason:`run is recorded as finished (status "${t}") but its chain has no seal (seal record and anchor removed?)`},notes:e.notes.filter((n)=>!n.startsWith("open:"))}}function rl(e,t){let r=ei(e,t);if(!r)return{...t.seal?{...Rr(t.runId,"tampered","record is sealed but carries no transcript path"),firstBad:{line:0,reason:"rawTranscript removed from a sealed RunRecord"}}:Rr(t.runId,"unsealed","unsealed (legacy): no raw transcript path (external record)"),target:"run-record"};let n=Vh(r);if(n===null)return{...t.seal?{...Rr(t.runId,"tampered","sealed transcript is missing"),firstBad:{line:0,reason:`transcript ${r} is missing`}}:Rr(t.runId,"unsealed","unsealed (legacy): raw transcript missing"),target:"run-record",file:r};let i=oh(n,{runId:t.runId,...t.seal?{anchor:t.seal}:{},...t.totals?{totals:t.totals}:{},...t.corrections?{corrections:t.corrections}:{}});return{...VE(i,t.status),target:"run-record",file:r}}function SP(e){let t=Qh.join(e,"events.jsonl"),r=Vh(Qh.join(e,"status.json")),n={},i=null;try{if(r!==null)n=JSON.parse(r)}catch(u){i=`status.json is unreadable (${u instanceof Error?u.message:String(u)})`}let o=typeof n.runId==="string"?n.runId:void 0;if(o===void 0)try{let u=JSON.parse($b.readFileSync(Qh.join(e,"invocation.json"),"utf8"));if(typeof u.runId==="string")o=u.runId}catch{}if(o===void 0)throw new k(`verify-run: ${e} has no status.json/invocation.json naming a runId`,"USAGE");let s;if(n.seal!==void 0){let u=Fi.shape.seal.safeParse(n.seal);if(u.success)s=u.data;else i="status.json seal is malformed"}if(i!==null)return{...Rr(o,"tampered","the run's seal anchor is damaged"),firstBad:{line:0,reason:i},target:"run-dir",file:t};let _=Vh(t);if(_===null)return{...s?{...Rr(o,"tampered","sealed events.jsonl is missing"),firstBad:{line:0,reason:`${t} is missing`}}:Rr(o,"unsealed","unsealed (legacy): events.jsonl missing"),target:"run-dir",file:t};let l=VE(oh(_,{runId:o,...s?{anchor:s}:{}}),n.status);if(l.sealed)l.notes.push("run-dir mode: status.json carries no totals, so sealed totals are shown, not compared");return{...l,target:"run-dir",file:t}}function yP(e,t){let r=Vh(Qh.join(We(e),`${t}.json`));if(r===null)return{ok:!1,missing:!0};let n;try{n=JSON.parse(r)}catch(o){return{ok:!1,reason:`invalid JSON: ${o instanceof Error?o.message:String(o)}`}}let i=Fi.safeParse(n);if(!i.success){let o=i.error.issues[0];return{ok:!1,reason:`schema: ${o?.path.join(".")||"(root)"}: ${o?.message??"invalid"}`}}return{ok:!0,record:i.data}}function ZE(e){switch(e.status){case"ok":return`sealed ✓ (${e.records} records)`;case"tampered":return`TAMPERED at line ${e.firstBad?.line??"?"}: ${e.firstBad?.reason??"chain broken"}`;case"unsealed":return"unsealed (legacy)";case"open":return`open (${e.records} records, no seal)`}}function kP(e,t){let r=[];if(r.push(`run ${e.runId}${e.file?` (${e.target==="run-dir"?"events.jsonl":"transcript"} ${e.file})`:""}`),t){for(let i of e.checks)r.push(` line ${String(i.line).padStart(5)} seq ${String(i.seq).padStart(5)} ${i.type.padEnd(14)} ${i.hash.slice(0,16)} ok`);if(e.firstBad)r.push(` line ${String(e.firstBad.line).padStart(5)} ${e.firstBad.seq!==void 0?`seq ${String(e.firstBad.seq).padStart(5)} `:""}BROKEN`)}if(r.push(` records: ${e.records} chained${e.sealed?" + seal":""}`),e.sealed)r.push(` seal: ${e.status==="tampered"?"present":"OK"} sha256 ${e.sealHash}`);if(e.totals){let i=e.totals,o=i.status==="match"?"match the seal":i.status==="match-after-corrections"?`match the seal after undoing ${i.corrections} audit correction(s)`:i.status==="mismatch"?`DIFFER from the seal: ${i.fields.map((s)=>`${s.field} sealed=${s.sealed} recorded=${s.recorded}`).join(", ")}`:`not checked (${i.reason})`;r.push(` totals: ${o}`)}for(let i of e.notes)r.push(` note: ${i}`);let n=e.status==="ok"?"OK — chain intact and sealed":e.status==="tampered"?`TAMPERED — first bad record at line ${e.firstBad?.line}${e.firstBad?.seq!==void 0?` (seq ${e.firstBad.seq})`:""}: ${e.firstBad?.reason}`:e.status==="unsealed"?"UNSEALED (legacy) — no hash chain to verify":"OPEN — chain intact but not sealed";return r.push(`verdict: ${n}`),r.join(`
|
|
287
287
|
`)+`
|
|
288
288
|
`}async function e6(e){let t=wP({args:e,options:{json:{type:"boolean",default:!1},records:{type:"boolean",default:!1},dir:{type:"string"},"state-dir":{type:"string"},help:{type:"boolean",short:"h",default:!1}},allowPositionals:!0});if(t.values.help)return process.stdout.write(xP+`
|
|
@@ -5472,6 +5472,12 @@ usage:
|
|
|
5472
5472
|
the agent exits; verdict on the RunRecord, failed checker exits 1; passing checker keeps the run exit code)
|
|
5473
5473
|
[--repeat N [--parallel K]] (N fresh sessions, one repeat group; exits with the most severe child code)
|
|
5474
5474
|
[--experiment E] [--variant V] (compare-view labels on the RunRecord)
|
|
5475
|
+
[--extra-args '<a b>']... [--extra-arg <token>]... (extra CLI args for the
|
|
5476
|
+
launched agent, every launchable agent; both repeatable and kept in
|
|
5477
|
+
command-line order. --extra-args splits each value on spaces;
|
|
5478
|
+
--extra-arg is ONE verbatim argv token, never split, so a value with
|
|
5479
|
+
spaces works. e.g. route codex to a custom provider:
|
|
5480
|
+
--extra-arg -c --extra-arg 'model_provider=ferry')
|
|
5475
5481
|
[--hermetic] (run in a temp copy of cwd whose ancestor dirs hold no
|
|
5476
5482
|
CLAUDE.md/AGENTS.md/GEMINI.md, then sync edits (and deletions)
|
|
5477
5483
|
back before --verify; fails if the temp root is not clean.
|
|
@@ -5505,6 +5511,8 @@ usage:
|
|
|
5505
5511
|
ach agents [--json] list built-in agents, agents.d descriptors and descriptor errors
|
|
5506
5512
|
ach preflight --agent kiro [--model M] [--kiro-agent A] [--kiro-transport acp]
|
|
5507
5513
|
[--cwd DIR] [--json] [--kiro-startup-ms MS] [--kiro-mcp-server '<json>']...
|
|
5514
|
+
[--extra-args '<a b>']... [--extra-arg <token>]...
|
|
5515
|
+
(same as ach run: --extra-args splits on spaces, --extra-arg is verbatim)
|
|
5508
5516
|
(proves binary/auth/agent/model/set_model-ack/MCP over a real
|
|
5509
5517
|
ACP handshake; sends NO prompt, so it spends no tokens)
|
|
5510
5518
|
ach doctor [--agent A] [--model M] [--cwd DIR] [--claude-default-config] [--json]
|
|
@@ -5660,8 +5668,8 @@ env:
|
|
|
5660
5668
|
AGENTIC_CODING_HARNESS_QUOTA_CODEX_DIR quota: Codex rollouts dir (default ~/.codex/sessions)
|
|
5661
5669
|
AGENTIC_CODING_HARNESS_QUOTA_CLAUDE_FILE quota: Claude snapshot (default <state>/quota/claude.json)
|
|
5662
5670
|
AGENTIC_CODING_HARNESS_NULL_EXIT --agent null only: force exitStatus (error|timeout|budget_exceeded)
|
|
5663
|
-
AGENTIC_CODING_HARNESS_NULL_TURNS --agent null only: scripted turn count (default 1)`;function Kw(e,t){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new k(`${t} expects a non-negative number, got '${e}'`,"USAGE");return r}function _7(e,t){if(e===void 0)return;let r=Number(e);if(!Number.isInteger(r)||r<0)throw new k(`${t} expects a non-negative integer, got '${e}'`,"USAGE");return r}function Pn(e,t,r){if(e!==void 0)return Kw(e,t);let n=process.env[r];if(n===void 0||n==="")return;return Kw(n,r)}function YX(e,t,r){if(e!==void 0)return _7(e,t);let n=process.env[r];if(n===void 0||n==="")return;return _7(n,r)}function Wl(e,t){if(e===void 0)return;let r=Number(e);if(!Number.isInteger(r)||r<=0)throw new k(`${t} expects a positive integer, got '${e}'`,"USAGE");return r}function a7(e,t){if(e===void 0)return;return e.map((r)=>{let n;try{n=JSON.parse(r)}catch(o){throw new k(`${t} expects a JSON object, got '${r}': ${o instanceof Error?o.message:String(o)}`,"USAGE")}let i=o1.safeParse(n);if(!i.success)throw new k(`${t} '${r}' does not match {name, command, args?, env?}: ${i.error.issues.map((o)=>`${o.path.join(".")||"(root)"}: ${o.message}`).join("; ")}`,"USAGE");return i.data})}function JX(e){let t={};if(e["kiro-transport"]!==void 0)t.transport=e["kiro-transport"];if(e["kiro-agent"]!==void 0)t.agent=e["kiro-agent"];if(e["kiro-engine"]!==void 0)t.engine=e["kiro-engine"];if(e["kiro-effort"]!==void 0)t.effort=e["kiro-effort"];if(e["kiro-tools"]!==void 0){let o=e["kiro-tools"];t.tools=o==="all"||o==="none"?o:o.split(",").map((s)=>s.trim()).filter(Boolean)}if(e["kiro-require-mcp-startup"])t.requireMcpStartup=!0;let r=Wl(e["kiro-startup-ms"],"--kiro-startup-ms");if(r!==void 0)t.startupMs=r;if(e["kiro-require-model-ack"])t.requireModelAck=!0;let n=a7(e["kiro-mcp-server"],"--kiro-mcp-server");if(n!==void 0)t.mcpServers=n;if(Object.keys(t).length===0)return;let i=wi.safeParse(t);if(!i.success)throw new k(`invalid --kiro-* flags: ${i.error.issues.map((o)=>`${o.path.join(".")}: ${o.message}`).join("; ")}`,"USAGE");return i.data}async function QX(e){let t=Kl({args:e,options:{agent:{type:"string"},model:{type:"string"},resume:{type:"string"},"budget-usd":{type:"string"},"max-turns":{type:"string"},"wall-ms":{type:"string"},"idle-ms":{type:"string"},"budget-alerts":{type:"string"},"warn-at":{type:"string"},"on-budget":{type:"string"},"extra-args":{type:"string",multiple:!0},"kiro-transport":{type:"string"},"kiro-agent":{type:"string"},"kiro-engine":{type:"string"},"kiro-effort":{type:"string"},"kiro-tools":{type:"string"},"kiro-require-mcp-startup":{type:"boolean",default:!1},"kiro-startup-ms":{type:"string"},"kiro-require-model-ack":{type:"boolean",default:!1},"claude-default-config":{type:"boolean",default:!1},"kiro-mcp-server":{type:"string",multiple:!0},template:{type:"string"},"prompt-stdin":{type:"boolean",default:!1},"template-shell":{type:"boolean",default:!1},json:{type:"boolean",default:!1},"exit-codes":{type:"string"},verify:{type:"string"},"verify-timeout-ms":{type:"string"},repeat:{type:"string"},parallel:{type:"string"},experiment:{type:"string"},variant:{type:"string"},hermetic:{type:"boolean",default:!1}},allowPositionals:!0}),r=xs(t.values["exit-codes"]),n=ZX(t.values),i=t.values.hermetic===!0;if(i&&t.values.resume!==void 0)throw new k("--hermetic runs in a fresh temp copy of the workspace; it cannot be combined with --resume","USAGE");if(i&&n.parallel!==void 0&&n.parallel>1)throw new k("--hermetic syncs each run back into the one workspace; it cannot be combined with --parallel > 1","USAGE");let o=t.values.agent;if(!o)throw new k("run requires --agent <name>","USAGE");if(Sn(o))throw new k(Wh(o),"READ_ONLY_SOURCE");let s=tt(o)?null:Xo();if(s)Er(s);let _=Hh(o,t.values,s??{descriptors:[],errors:[],warnings:[]}),l=t.positionals.join(" ").trim();if(!l)throw new k("run requires a prompt argument","USAGE");if(t.values["claude-default-config"])process.env.AGENTIC_CODING_HARNESS_DEFAULT_CLAUDE_CONFIG="1";let u=new Map,a=(C)=>{let w=zE(C,u);if(w!==null)process.stderr.write(w+`
|
|
5664
|
-
`)},h=Ee(),d=ti({adapters:_.adapter?{...await Ut(),[o]:_.adapter}:await Ut(),stateDir:Z(),pricer:_.wrapPricer?_.wrapPricer(h):h,onEvent:a,registry:{stateDir:Z()}}),p={usd:Pn(t.values["budget-usd"],"--budget-usd","AGENTIC_CODING_HARNESS_BUDGET_USD"),maxTurns:YX(t.values["max-turns"],"--max-turns","AGENTIC_CODING_HARNESS_MAX_TURNS"),wallMs:Pn(t.values["wall-ms"],"--wall-ms","AGENTIC_CODING_HARNESS_WALL_MS"),idleMs:Pn(t.values["idle-ms"],"--idle-ms","AGENTIC_CODING_HARNESS_IDLE_MS")},f=TR(t.values,p),g=Rb(t.
|
|
5671
|
+
AGENTIC_CODING_HARNESS_NULL_TURNS --agent null only: scripted turn count (default 1)`;function Kw(e,t){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new k(`${t} expects a non-negative number, got '${e}'`,"USAGE");return r}function _7(e,t){if(e===void 0)return;let r=Number(e);if(!Number.isInteger(r)||r<0)throw new k(`${t} expects a non-negative integer, got '${e}'`,"USAGE");return r}function Pn(e,t,r){if(e!==void 0)return Kw(e,t);let n=process.env[r];if(n===void 0||n==="")return;return Kw(n,r)}function YX(e,t,r){if(e!==void 0)return _7(e,t);let n=process.env[r];if(n===void 0||n==="")return;return _7(n,r)}function Wl(e,t){if(e===void 0)return;let r=Number(e);if(!Number.isInteger(r)||r<=0)throw new k(`${t} expects a positive integer, got '${e}'`,"USAGE");return r}function a7(e,t){if(e===void 0)return;return e.map((r)=>{let n;try{n=JSON.parse(r)}catch(o){throw new k(`${t} expects a JSON object, got '${r}': ${o instanceof Error?o.message:String(o)}`,"USAGE")}let i=o1.safeParse(n);if(!i.success)throw new k(`${t} '${r}' does not match {name, command, args?, env?}: ${i.error.issues.map((o)=>`${o.path.join(".")||"(root)"}: ${o.message}`).join("; ")}`,"USAGE");return i.data})}function JX(e){let t={};if(e["kiro-transport"]!==void 0)t.transport=e["kiro-transport"];if(e["kiro-agent"]!==void 0)t.agent=e["kiro-agent"];if(e["kiro-engine"]!==void 0)t.engine=e["kiro-engine"];if(e["kiro-effort"]!==void 0)t.effort=e["kiro-effort"];if(e["kiro-tools"]!==void 0){let o=e["kiro-tools"];t.tools=o==="all"||o==="none"?o:o.split(",").map((s)=>s.trim()).filter(Boolean)}if(e["kiro-require-mcp-startup"])t.requireMcpStartup=!0;let r=Wl(e["kiro-startup-ms"],"--kiro-startup-ms");if(r!==void 0)t.startupMs=r;if(e["kiro-require-model-ack"])t.requireModelAck=!0;let n=a7(e["kiro-mcp-server"],"--kiro-mcp-server");if(n!==void 0)t.mcpServers=n;if(Object.keys(t).length===0)return;let i=wi.safeParse(t);if(!i.success)throw new k(`invalid --kiro-* flags: ${i.error.issues.map((o)=>`${o.path.join(".")}: ${o.message}`).join("; ")}`,"USAGE");return i.data}async function QX(e){let t=Kl({args:e,options:{agent:{type:"string"},model:{type:"string"},resume:{type:"string"},"budget-usd":{type:"string"},"max-turns":{type:"string"},"wall-ms":{type:"string"},"idle-ms":{type:"string"},"budget-alerts":{type:"string"},"warn-at":{type:"string"},"on-budget":{type:"string"},"extra-args":{type:"string",multiple:!0},"extra-arg":{type:"string",multiple:!0},"kiro-transport":{type:"string"},"kiro-agent":{type:"string"},"kiro-engine":{type:"string"},"kiro-effort":{type:"string"},"kiro-tools":{type:"string"},"kiro-require-mcp-startup":{type:"boolean",default:!1},"kiro-startup-ms":{type:"string"},"kiro-require-model-ack":{type:"boolean",default:!1},"claude-default-config":{type:"boolean",default:!1},"kiro-mcp-server":{type:"string",multiple:!0},template:{type:"string"},"prompt-stdin":{type:"boolean",default:!1},"template-shell":{type:"boolean",default:!1},json:{type:"boolean",default:!1},"exit-codes":{type:"string"},verify:{type:"string"},"verify-timeout-ms":{type:"string"},repeat:{type:"string"},parallel:{type:"string"},experiment:{type:"string"},variant:{type:"string"},hermetic:{type:"boolean",default:!1}},allowPositionals:!0,tokens:!0}),r=xs(t.values["exit-codes"]),n=ZX(t.values),i=t.values.hermetic===!0;if(i&&t.values.resume!==void 0)throw new k("--hermetic runs in a fresh temp copy of the workspace; it cannot be combined with --resume","USAGE");if(i&&n.parallel!==void 0&&n.parallel>1)throw new k("--hermetic syncs each run back into the one workspace; it cannot be combined with --parallel > 1","USAGE");let o=t.values.agent;if(!o)throw new k("run requires --agent <name>","USAGE");if(Sn(o))throw new k(Wh(o),"READ_ONLY_SOURCE");let s=tt(o)?null:Xo();if(s)Er(s);let _=Hh(o,t.values,s??{descriptors:[],errors:[],warnings:[]}),l=t.positionals.join(" ").trim();if(!l)throw new k("run requires a prompt argument","USAGE");if(t.values["claude-default-config"])process.env.AGENTIC_CODING_HARNESS_DEFAULT_CLAUDE_CONFIG="1";let u=new Map,a=(C)=>{let w=zE(C,u);if(w!==null)process.stderr.write(w+`
|
|
5672
|
+
`)},h=Ee(),d=ti({adapters:_.adapter?{...await Ut(),[o]:_.adapter}:await Ut(),stateDir:Z(),pricer:_.wrapPricer?_.wrapPricer(h):h,onEvent:a,registry:{stateDir:Z()}}),p={usd:Pn(t.values["budget-usd"],"--budget-usd","AGENTIC_CODING_HARNESS_BUDGET_USD"),maxTurns:YX(t.values["max-turns"],"--max-turns","AGENTIC_CODING_HARNESS_MAX_TURNS"),wallMs:Pn(t.values["wall-ms"],"--wall-ms","AGENTIC_CODING_HARNESS_WALL_MS"),idleMs:Pn(t.values["idle-ms"],"--idle-ms","AGENTIC_CODING_HARNESS_IDLE_MS")},f=TR(t.values,p),g=Rb(t.tokens),v={prompt:l,model:t.values.model,resume:t.values.resume,budget:{...p,...f},...g!==void 0?{extraArgs:g}:{},...o==="kiro"?{kiro:JX(t.values)}:{},...n.labels.variant!==void 0?{variant:n.labels.variant}:{}};if(!i){let C=process.cwd(),w=cn(o,C);if(w.length>0)process.stderr.write(Ox(o,C,w)+`
|
|
5665
5673
|
`)}let m={driver:d,agent:o,spec:v,stateDir:Z(),...n.verify!==void 0?{verify:n.verify}:{},labels:n.labels,...i?{hermetic:{onPrepared:(C)=>{let w=C.avoided.length>0?` (avoids ${C.avoided.length} ancestor instruction file${C.avoided.length===1?"":"s"}: ${C.avoided.join(", ")})`:"";process.stderr.write(`[hermetic] running in ${C.dir}, synced back to ${C.source} afterwards${w}
|
|
5666
5674
|
`)}}}:{}};if(n.repeat!==void 0)return VX(m,n.repeat,n.parallel,t.values.json,t.values.model,r);let b;try{b=await X_(m)}catch(C){let w=C instanceof Error?C.message:String(C);if(C instanceof k&&C.code==="UNAVAILABLE")throw new k(w,"UNAVAILABLE",r==="ladder"?Ne.indeterminate:1);throw new k(w,"RUN_FAILED")}let L=b.result;for(let C of L.warnings)process.stderr.write(`[warn] ${C}
|
|
5667
5675
|
`);if(b.annotateFailed)process.stderr.write(`[warn] registry: could not record verify/labels on run ${L.runId}
|
|
@@ -5683,7 +5691,7 @@ kiroSession ${_}`;for(let u of JE(an(t.events)))l+=`
|
|
|
5683
5691
|
${u}`;if(t.ancestorInstructions!==void 0&&t.ancestorInstructions.length>0)l+=`
|
|
5684
5692
|
ancestors ${t.ancestorInstructions.length} instruction file${t.ancestorInstructions.length===1?"":"s"} from ancestor dirs: ${t.ancestorInstructions.join(", ")}`;if(t.hermetic!==void 0)l+=`
|
|
5685
5693
|
${Qx(t.hermetic)}`;if(n!==void 0)l+=`
|
|
5686
|
-
${Ph(n)}`;return l}async function ez(e){let t=Kl({args:e,options:{agent:{type:"string"},model:{type:"string"},cwd:{type:"string"},"kiro-agent":{type:"string"},"kiro-transport":{type:"string"},"kiro-startup-ms":{type:"string"},"kiro-mcp-server":{type:"string",multiple:!0},"extra-args":{type:"string",multiple:!0},json:{type:"boolean",default:!1}},allowPositionals:!0}),r=t.values.agent;if(r!=="kiro")throw new k(`preflight supports --agent kiro only (got '${r??"<missing>"}')`,"USAGE");let n=t.values["kiro-transport"]??"acp";if(n!=="acp")throw new k(`preflight requires --kiro-transport acp (got '${n}'): the checks are ACP handshake observations`,"USAGE");let i=Wl(t.values["kiro-startup-ms"],"--kiro-startup-ms"),o=a7(t.values["kiro-mcp-server"],"--kiro-mcp-server"),s=Rb(t.
|
|
5694
|
+
${Ph(n)}`;return l}async function ez(e){let t=Kl({args:e,options:{agent:{type:"string"},model:{type:"string"},cwd:{type:"string"},"kiro-agent":{type:"string"},"kiro-transport":{type:"string"},"kiro-startup-ms":{type:"string"},"kiro-mcp-server":{type:"string",multiple:!0},"extra-args":{type:"string",multiple:!0},"extra-arg":{type:"string",multiple:!0},json:{type:"boolean",default:!1}},allowPositionals:!0,tokens:!0}),r=t.values.agent;if(r!=="kiro")throw new k(`preflight supports --agent kiro only (got '${r??"<missing>"}')`,"USAGE");let n=t.values["kiro-transport"]??"acp";if(n!=="acp")throw new k(`preflight requires --kiro-transport acp (got '${n}'): the checks are ACP handshake observations`,"USAGE");let i=Wl(t.values["kiro-startup-ms"],"--kiro-startup-ms"),o=a7(t.values["kiro-mcp-server"],"--kiro-mcp-server"),s=Rb(t.tokens),_=await hs({cwd:t.values.cwd??process.cwd(),...t.values.model!==void 0?{model:t.values.model}:{},kiro:{transport:"acp",...t.values["kiro-agent"]!==void 0?{agent:t.values["kiro-agent"]}:{},...i!==void 0?{startupMs:i}:{},...o!==void 0?{mcpServers:o}:{}},...s!==void 0?{extraArgs:s}:{}});if(t.values.json)process.stdout.write(JSON.stringify(_,null,2)+`
|
|
5687
5695
|
`);else{for(let l of _.checks)process.stdout.write(`${l.status.padEnd(8)} ${l.name.padEnd(11)} ${l.detail} (${l.ms}ms)
|
|
5688
5696
|
`);process.stdout.write(`ok ${String(_.ok)}
|
|
5689
5697
|
`);for(let l of _.unproven)process.stdout.write(`unproven ${l}
|
|
@@ -5725,7 +5733,7 @@ ${m.join(`
|
|
|
5725
5733
|
`,t.values.out)await Fl.writeFile(t.values.out,p)}if(t.values.out)process.stdout.write(`wrote ${t.values.out}
|
|
5726
5734
|
`);else process.stdout.write(p);return 0}var sz=new Set(["run","preflight","doctor","watch","stats","audit","verify-run","status","statusline","archive","emit","regrade","report","dash","serve","web","mcp","quota","agents","import","trial"]);function _z(e){let t=/^ ach (\S+)/,r=t0.split(`
|
|
5727
5735
|
`),n=r.findIndex((o)=>t.exec(o)?.[1]===e);if(n===-1)return[];let i=[];for(let o=n;o<r.length;o++){let s=r[o],_=t.exec(s);if(o>n&&_!==null&&_[1]!==void 0&&_[1]!==e)break;if(o>n&&(s==="env:"||/^ --/.test(s)))break;i.push(s)}return i}function lz(e){let t=_z(e);return t.length>0?["usage:",...t].join(`
|
|
5728
|
-
`):t0}async function uz(e){let[t,...r]=e,n=t==="run"||t==="preflight"?XE(r,["extra-args"]):r;if(t!==void 0&&sz.has(t)&&qE(n))return process.stdout.write(lz(t)+`
|
|
5736
|
+
`):t0}async function uz(e){let[t,...r]=e,n=t==="run"||t==="preflight"?XE(r,["extra-args","extra-arg"]):r;if(t!==void 0&&sz.has(t)&&qE(n))return process.stdout.write(lz(t)+`
|
|
5729
5737
|
`),0;switch(t){case"run":return QX(n);case"preflight":return ez(n);case"doctor":return o7(n);case"watch":return tz(n);case"stats":return iz(n);case"audit":return mR(n);case"import":return kR(n);case"verify-run":return e6(n);case"status":return WR(n);case"statusline":return HR(n);case"archive":return JR(n);case"emit":return oz(n);case"regrade":return uE(n);case"trial":return F6(n);case"report":return y6(n);case"dash":return m3(n);case"serve":return O3(n);case"web":return uR(n);case"mcp":return hR(n);case"quota":return jR(n);case"agents":return IE(n);case"help":case"--help":case"-h":return process.stdout.write(t0+`
|
|
5730
5738
|
`),0;case"--version":case"-v":return process.stdout.write(it+`
|
|
5731
5739
|
`),0;default:if(process.stderr.write(t0+`
|
|
File without changes
|
|
File without changes
|
{agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/src/agentic_coding_harness/_cli.py
RENAMED
|
File without changes
|
{agentic_coding_harness-0.12.1 → agentic_coding_harness-0.13.0}/src/agentic_coding_harness/py.typed
RENAMED
|
File without changes
|
|
File without changes
|