alchemylab 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -67,26 +67,27 @@ r.startsWith(o+m.sep)&&await a(e,t.address)?c+=await d(e,t.address,r):i.push(t.p
67
67
  const u=t(76982),h=t(79896),p=t(49786),f=t(43106),m=t(16928),g=t(14139)
68
68
  exports.z5="results",exports.COMPRESSED_SUFFIX=".z"
69
69
  const y=.95
70
- exports.TREE_MEDIA_TYPE="application/vnd.alchemy.tree+json",exports.ep=5e4,exports.pO="scratch",exports.POINTER_SUFFIX=".result.json"},44876(e,exports,t){var r,n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r)
70
+ exports.TREE_MEDIA_TYPE="application/vnd.alchemy.tree+json",exports.ep=5e4,exports.pO="scratch",exports.POINTER_SUFFIX=".result.json"},44876(e,exports,t){async function r(e,t,r){const n=await(0,l.declaredRuntimeFloor)(t,t=>{try{return a.readFileSync(c.join(e,t),"utf8")}catch{return null}}),o=(0,l.imageRuntime)(r)
71
+ return n&&o?(0,l.floorImage)(o,n):r}var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r)
71
72
  var o=Object.getOwnPropertyDescriptor(t,r)
72
- o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[]
73
+ o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[]
73
74
  for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r)
74
- return t},r(e)},function(e){if(e&&e.__esModule)return e
75
+ return t},n(e)},function(e){if(e&&e.__esModule)return e
75
76
  var t={}
76
- if(null!=e)for(var s=r(e),i=0;i<s.length;i++)"default"!==s[i]&&n(t,e,s[i])
77
- return o(t,e),t})
78
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.PYTHON_MANIFESTS=exports.NODE_IMAGE=exports.PYTHON_IMAGE=void 0,exports.defaultBoxFor=function(e){if(!e)return{language:null}
77
+ if(null!=e)for(var r=n(e),i=0;i<r.length;i++)"default"!==r[i]&&o(t,e,r[i])
78
+ return s(t,e),t})
79
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.PYTHON_MANIFESTS=exports.NODE_IMAGE=exports.PYTHON_IMAGE=void 0,exports.defaultBoxFor=async function(e){if(!e)return{language:null}
79
80
  let t=[]
80
- try{t=i.readdirSync(e)}catch{return{language:null}}const r=e=>t.includes(e)
81
- if(exports.PYTHON_MANIFESTS.some(r)||r("Pipfile")||!r("package.json")&&t.some(e=>e.endsWith(".py")))return{language:"python",image:exports.PYTHON_IMAGE,artifacts:[{path:".venv",prepare:c,manifests:exports.PYTHON_MANIFESTS,env:{PATH:"/work/.venv/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin",VIRTUAL_ENV:"/work/.venv"}}]}
82
- if(r("package.json")){const t=function(e){let t
83
- try{t=JSON.parse(i.readFileSync(a.join(e,"package.json"),"utf8"))}catch{return}if(!["dependencies","devDependencies","optionalDependencies"].some(e=>t&&"object"==typeof t[e]&&Object.keys(t[e]).length>0))return
84
- const r=t=>i.existsSync(a.join(e,t))
81
+ try{t=a.readdirSync(e)}catch{return{language:null}}const n=e=>t.includes(e)
82
+ if(exports.PYTHON_MANIFESTS.some(n)||n("Pipfile")||!n("package.json")&&t.some(e=>e.endsWith(".py")))return{language:"python",image:await r(e,"python",exports.PYTHON_IMAGE),artifacts:[{path:".venv",prepare:d,manifests:exports.PYTHON_MANIFESTS,env:{PATH:"/work/.venv/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin",VIRTUAL_ENV:"/work/.venv"}}]}
83
+ if(n("package.json")){const t=function(e){let t
84
+ try{t=JSON.parse(a.readFileSync(c.join(e,"package.json"),"utf8"))}catch{return}if(!["dependencies","devDependencies","optionalDependencies"].some(e=>t&&"object"==typeof t[e]&&Object.keys(t[e]).length>0))return
85
+ const r=t=>a.existsSync(c.join(e,t))
85
86
  return r("pnpm-lock.yaml")?"corepack enable >/dev/null 2>&1; pnpm install --frozen-lockfile":r("yarn.lock")?"corepack enable >/dev/null 2>&1; yarn install --frozen-lockfile":r("package-lock.json")||r("npm-shrinkwrap.json")?"npm ci":"npm install"}(e)
86
- return{language:"node",image:exports.NODE_IMAGE,...t?{install:t}:{}}}return{language:null}}
87
- const i=s(t(79896)),a=s(t(16928))
87
+ return{language:"node",image:await r(e,"node",exports.NODE_IMAGE),...t?{install:t}:{}}}return{language:null}}
88
+ const a=i(t(79896)),c=i(t(16928)),l=t(56844)
88
89
  exports.PYTHON_IMAGE="python:3.12-slim",exports.NODE_IMAGE="node:20-alpine",exports.PYTHON_MANIFESTS=["pyproject.toml","setup.py","setup.cfg","requirements.txt","requirements-dev.txt"]
89
- const c=["python -m venv /work/.venv","/work/.venv/bin/pip install -q --no-cache-dir pytest","if [ -f requirements.txt ]; then /work/.venv/bin/pip install -q --no-cache-dir -r requirements.txt; fi","if [ -f requirements-dev.txt ]; then /work/.venv/bin/pip install -q --no-cache-dir -r requirements-dev.txt; fi",'{ if [ -f pyproject.toml ] || [ -f setup.py ]; then /work/.venv/bin/pip install -q --no-cache-dir -e . || echo "the project could not be installed; its tests import it from /work"; fi; }'].join(" && ")},86776(e,exports,t){exports.registerAuthRoutes=function(e,t,n,o){const s=o.child({component:"auth-routes"}),i=t.apiClient
90
+ const d=["python -m venv /work/.venv","/work/.venv/bin/pip install -q --no-cache-dir pytest","if [ -f requirements.txt ]; then /work/.venv/bin/pip install -q --no-cache-dir -r requirements.txt; fi","if [ -f requirements-dev.txt ]; then /work/.venv/bin/pip install -q --no-cache-dir -r requirements-dev.txt; fi",'{ if [ -f pyproject.toml ] || [ -f setup.py ]; then /work/.venv/bin/pip install -q --no-cache-dir -e . || echo "the project could not be installed; its tests import it from /work"; fi; }'].join(" && ")},86776(e,exports,t){exports.registerAuthRoutes=function(e,t,n,o){const s=o.child({component:"auth-routes"}),i=t.apiClient
90
91
  e.post("/auth/login",async(e,o)=>{try{const{username:r,password:a}=e.body
91
92
  if(!r||!a)return o.status(400).json({success:!1,error:"Username and password are required",timestamp:(new Date).toISOString()})
92
93
  s.info("Attempting login",{username:r})
@@ -908,7 +909,8 @@ if(s?.length>0){const e=s[0].requestLocalId||s[0].request_local_id
908
909
  return e&&this.sessionRequestCache.set(n,{requestId:e,at:Date.now()}),this.log("getSessionRequestId.resolved",{sessionId:n,requestId:e}),e||null}return this.log("getSessionRequestId.none",{sessionId:n}),null}catch(e){const r=e instanceof Error?e.message:String(e)
909
910
  return t.warn("Error getting session request",{sessionId:n,error:r}),null}}noRequestReason(e){const t=e?this.endedUnderSession.get(e):void 0
910
911
  return t?`${t} was canceled or reverted, so your tools are on no request now. Do not continue its work: no task, file or command lands for it. A message about another request moves your tools there.`:null}clearSessionRequestCache(e){e?this.sessionRequestCache.delete(e):this.sessionRequestCache.clear()}buildCliOrigin(e){if(this.identity)return{providerId:this.identity.providerId,sessionId:this.identity.sessionId,messageId:e,createdAt:(new Date).toISOString()}}setCurrentCallOrigin(e){this.currentCallOrigin=e}getCurrentCallOrigin(){return this.currentCallOrigin||this.buildCliOrigin()}log(e,t){if(i.SESSION_IDENTITY_LOG_ENABLED)try{const o=process.env.ALCHEMY_PROJECT_PATH||process.cwd(),s=(0,n.join)(o,".alchemy_lab");(0,r.existsSync)(s)||(0,r.mkdirSync)(s,{recursive:!0})
911
- const i=(0,n.join)(s,"mcp-identity-debug.log"),a=(new Date).toISOString(),c=process.pid,l=t?" "+JSON.stringify(t):"";(0,r.appendFileSync)(i,`[${a}] [PID:${c}] identity.${e}${l}\n`)}catch{}}}a.SESSION_REQUEST_TTL_MS=3e3,exports.sessionIdentity=new a,exports.sessionIdentity.log("module-load",{ALCHEMY_ALLOW_PARALLEL:process.env.ALCHEMY_ALLOW_PARALLEL||null})},95122(e,exports,t){function r(e,t){const r=Array.isArray(e.pathGlobs)?e.pathGlobs.filter(e=>"string"==typeof e&&e.trim()):[]
912
+ const i=(0,n.join)(s,"mcp-identity-debug.log"),a=(new Date).toISOString(),c=process.pid,l=t?" "+JSON.stringify(t):"";(0,r.appendFileSync)(i,`[${a}] [PID:${c}] identity.${e}${l}\n`)}catch{}}}a.SESSION_REQUEST_TTL_MS=3e3,exports.sessionIdentity=new a,exports.sessionIdentity.log("module-load",{ALCHEMY_ALLOW_PARALLEL:process.env.ALCHEMY_ALLOW_PARALLEL||null})},70715(e,exports){exports.JZ=exports.hasBaseline=exports.Ql=exports.rh=void 0,exports.rh={tolerancePct:10,repeats:3,timeAtLeast:.1},exports.Ql=9,exports.hasBaseline=e=>!!e?.baseline&&"object"==typeof e.baseline,exports.JZ=e=>{const t=[...e].sort((e,t)=>e-t),r=Math.floor(t.length/2)
913
+ return t.length%2?t[r]:(t[r-1]+t[r])/2}},95122(e,exports,t){function r(e,t){const r=Array.isArray(e.pathGlobs)?e.pathGlobs.filter(e=>"string"==typeof e&&e.trim()):[]
912
914
  return 0===r.length?t:t.filter(t=>(0,s.processApplies)({id:e.id??"",pathGlobs:r},[t],[]))}async function n(e,t,n){const o=t.filter(e=>e&&!1!==e.isActive&&!e.config?.isStub)
913
915
  if(0===o.length||!Array.isArray(e))return[]
914
916
  const s=[],a=[]
@@ -1173,15 +1175,15 @@ try{const s=await fetch(`${(0,r.getActionServerBaseUrl)()}/api/sessions/${encode
1173
1175
  return s.ok?i?.data??{ok:!1,error:"deliver_route",detail:"empty response"}:{ok:!1,error:"deliver_route",detail:i?.error||`HTTP ${s.status}`}}catch(e){return{ok:!1,error:"deliver_route",detail:e instanceof Error?e.message:String(e)}}},exports.deliveryFailureText=function(e,t){return`\u274c NOT delivered to session ${e}: ${t.detail||t.error||"unknown reason"}. The session did not receive this and nothing will act on it.`}
1174
1176
  const r=t(79414)},4961(e,exports,t){exports.def=void 0
1175
1177
  const r=t(76183),n=t(23540)
1176
- exports.def={name:"directive_operations",description:'Standing guidance and the decision record.\n\n\u2022 set - Propose standing guidance the USER stated, in their words (userSaid, required): it becomes guidance when they press Adopt on the card. Use it when the user states a lasting preference, so it becomes a record instead of staying in chat. An instruction about one plan or request right now (hold it, do this first) is not guidance: act on it. Guidance the user did not state: guidance_propose.\n\u2022 list - The project\'s guidance.\n\u2022 search-decisions - Free-text search over recorded decisions and annotations, to answer "why did we choose X / who decided Y" from the record; cite the refs the result carries.\n\nGuidance shapes future work in its scope (it reaches in-flight workers at once) and never starts work: create a request for that.',schema:r.DirectiveOperationsSchema,annotations:{title:"Directive Operations",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1},handler:(e,t)=>(0,n.handleDirectiveOperations)(e,t.context,t.apiClient,t.logger,t.metrics,t.cliOrigin)}},23540(e,exports,t){exports.handleDirectiveOperations=async function(e,t,s,i,a,c){const l=i.child({tool:"directive_operations"}),d=a.startTimer("tool_execution_time"),u=e.operation
1178
+ exports.def={name:"directive_operations",description:'Standing guidance and the decision record.\n\n\u2022 set - Propose standing guidance the USER stated, in their words (userSaid, required): it becomes guidance when they press Adopt on the card. Use it when the user states a lasting preference or corrects how something was done in a way that should hold for later work, once per correction, so it becomes a record instead of staying in chat. An instruction about one plan or request right now (hold it, do this first) is not guidance: act on it. Guidance the user did not state: guidance_propose.\n\u2022 list - The project\'s guidance.\n\u2022 search-decisions - Free-text search over recorded decisions and annotations, to answer "why did we choose X / who decided Y" from the record; cite the refs the result carries.\n\nGuidance shapes future work in its scope (it reaches in-flight workers at once) and never starts work: create a request for that.',schema:r.DirectiveOperationsSchema,annotations:{title:"Directive Operations",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1},handler:(e,t)=>(0,n.handleDirectiveOperations)(e,t.context,t.apiClient,t.logger,t.metrics,t.cliOrigin)}},23540(e,exports,t){exports.handleDirectiveOperations=async function(e,t,s,i,a,c){const l=i.child({tool:"directive_operations"}),d=a.startTimer("tool_execution_time"),u=e.operation
1177
1179
  try{const i=t.projectId
1178
1180
  if(!i)throw new r.ValidationError("Project ID is required for directive operations")
1179
1181
  if("set"===u){const n=e.targetType
1180
- if(!n||!["project","area","request"].includes(n))throw new r.ValidationError("targetType must be one of project | area | request")
1182
+ if(!n||!["project","area","request","you"].includes(n))throw new r.ValidationError("targetType must be one of project | area | request | you")
1181
1183
  if("string"!=typeof e.body||0===e.body.trim().length)throw new r.ValidationError("body (the guidance) is required")
1182
1184
  if(!("area"!==n&&"request"!==n||e.targetId&&e.targetId.trim()))throw new r.ValidationError(`targetId is required for ${n} guidance (${"area"===n?"the area name":"the request local id"})`)
1183
1185
  const o={targetType:n,body:e.body.trim(),createdBy:c?.sessionId??t.currentSessionId}
1184
- "project"!==n&&(o.targetId=e.targetId.trim()),"string"==typeof e.note&&e.note.trim()&&(o.note=e.note.trim()),"string"==typeof e.userSaid&&e.userSaid.trim()&&(o.userSaid=e.userSaid.trim()),"string"==typeof e.revises&&e.revises.trim()&&(o.revises=e.revises.trim())
1186
+ "area"!==n&&"request"!==n||(o.targetId=e.targetId.trim()),"string"==typeof e.note&&e.note.trim()&&(o.note=e.note.trim()),"string"==typeof e.userSaid&&e.userSaid.trim()&&(o.userSaid=e.userSaid.trim()),"string"==typeof e.revises&&e.revises.trim()&&(o.revises=e.revises.trim())
1185
1187
  const a=await s.proxyPost(`/api/projects/${i}/directives`,o),u=a?.data??a
1186
1188
  if(u?.proposed)return d({operation:"set",success:!0}),{content:[{type:"text",text:`Proposed as guidance, quoting the user's words (${u.messageCode}). It becomes guidance only when they press Adopt on its card; until then nothing is recorded. Tell them it waits for their Adopt.`}]}
1187
1189
  const h=u,p="project"===h.target_type?"project":`${h.target_type} ${h.target_id}`
@@ -1335,7 +1337,7 @@ d({success:!0}),i(await o(l),c.map(e=>e?.id))
1335
1337
  const u=await async function(){try{const{actionServerFetch:e}=await Promise.resolve().then(()=>t(79414)),r=await e("/api/capabilities",{signal:AbortSignal.timeout(8e3)}),n=(await r.json().catch(()=>({})))?.data??{}
1336
1338
  return`Host capabilities: Docker ${!0===n.docker?"available":"UNAVAILABLE (no daemon reachable: `confined` environments and sealed images cannot run here; use the narrowest host level and expect the Tests gate to need sign-off)"} \xb7 OS sandbox for the \`host\` level: ${n.osSandbox?`${n.osSandbox}`:"none"} \xb7 platform ${n.platform??process.platform}`}catch{return"Host capabilities: unknown (the action server did not answer); assume Docker may be unavailable and verify before proposing a sealed environment."}}(),h=(0,m.presetsLine)(c.map(e=>e?.config?.image).filter(Boolean))
1337
1339
  let p=""
1338
- if(!c.some(e=>e?.config?.image)){const e=(0,g.defaultBoxFor)(r.mainBasePath)
1340
+ if(!c.some(e=>e?.config?.image)){const e=await(0,g.defaultBoxFor)(r.mainBasePath)
1339
1341
  e.language&&(p=`No sealed environment is set up, and none is needed to run this project's tests: \`run\` with no box starts one that fits it (${"python"===e.language?"Python":"Node"}, ${e.image}, with its dependencies installed). Set up an environment only when that box is not enough.`)}const f=(p?`\n\n${p}`:"")+(h?`\n\n${h}`:"")
1340
1342
  return 0===c.length?{content:[{type:"text",text:`${u}\n\nNo environments configured yet. Use \`environment_create\` to define one (the project's confined runtime: image, install, services, connection).`+f}]}:{content:[{type:"text",text:`${u}\n\n## Environments (${c.length})\n\n${c.map(a).join("\n\n")}${f}`}]}}catch(e){return d({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to list environments: ${(0,p.getErrorMessage)(e)}`}],isError:!0}}},exports.handleEnvironmentGet=async function(e,t,r,n,s,c){const l=s.startTimer("tool_execution_time")
1341
1343
  try{const n=await r.proxyGet(`/api/projects/${t.projectId}/environments/${e.environmentId}`),s=n?.data||n
@@ -1388,7 +1390,7 @@ u="setup"===e?.type}const h=u?d:void 0
1388
1390
  let f=!1
1389
1391
  if(o&&n)try{await t.getProxyClient().proxyPatch(`/api/projects/${n}/requests/${o}`,{status:"canceled",completionSummary:h?`Not needed: the same environment setup was already under way as ${h}.`:`Environment setup could not start: ${String(l?.error||"HTTP "+c).slice(0,300)}`}),f=!0}catch(e){r.warn("environment_setup: could not withdraw the unused setup request",{setupRequestId:o,error:(0,p.getErrorMessage)(e)})}const m=f?` ${o}, filed for this call, was withdrawn.`:""
1390
1392
  if(409===c&&h&&s&&n){let e=!1
1391
- try{await t.proxyPost(`/api/projects/${n}/requests/${s}/waits`,{waitsOn:h,reason:`environment setup: ${a}`.slice(0,300),...i?{sessionId:i}:{}}),e=!0}catch(e){r.warn("environment_setup: wait on the setup in progress not declared",{callerRequestId:s,covering:h,error:(0,p.getErrorMessage)(e)})}return{content:[{type:"text",text:`An environment setup is already under way as ${h}; a second architect would only ask the user the same thing twice.${m}`+(e?`\n\n\u23f3 Wait declared: ${s} waits on ${h}. You are idle by design until it settles, and you will be woken with its outcome. End your turn now, or check environment_list if it may already be done.`:" When it settles, whoever started it is woken with its outcome; check environment_list before you rely on it.")}]}}return{content:[{type:"text",text:`environment setup failed: ${l?.error||"HTTP "+c}.${m}`}],isError:!0}}({apiClient:n,logger:o,projectId:y,setupRequestId:c,callerRequestId:g,parentSessionId:m,firstLine:b,status:k.status,body:I})
1393
+ try{await t.proxyPost(`/api/projects/${n}/requests/${s}/waits`,{waitsOn:h,reason:`environment setup: ${a}`.slice(0,300),...i?{sessionId:i}:{}}),e=!0}catch(e){r.warn("environment_setup: wait on the setup in progress not declared",{callerRequestId:s,covering:h,error:(0,p.getErrorMessage)(e)})}return{content:[{type:"text",text:`A setup that builds this project's environment is already under way as ${h}; a second one would leave two environments and ask the user twice.${m}`+(e?`\n\n\u23f3 Wait declared: ${s} waits on ${h}. You are idle by design until it settles, and you will be woken with its outcome. End your turn now, or check environment_list if it may already be done.`:" When it settles, whoever started it is woken with its outcome; check environment_list before you rely on it.")}]}}return{content:[{type:"text",text:`environment setup failed: ${l?.error||"HTTP "+c}.${m}`}],isError:!0}}({apiClient:n,logger:o,projectId:y,setupRequestId:c,callerRequestId:g,parentSessionId:m,firstLine:b,status:k.status,body:I})
1392
1394
  if(c&&g&&y)try{await n.proxyPost(`/api/projects/${y}/requests/${g}/waits`,{waitsOn:c,reason:`environment setup: ${b}`.slice(0,300),...m?{sessionId:m}:{}}),l=!0}catch(e){o.warn("environment_setup: wait not declared",{callerRequestId:g,setupRequestId:c,error:(0,p.getErrorMessage)(e)})}a({success:!0})
1393
1395
  const $=l?`\n\n\u23f3 Wait declared: ${g} waits on ${c}. This is a registered wait: you are idle by design until ${c} settles, and you will be woken with its outcome the moment it does. End your turn now; do nothing else on ${g}.`:c?`\n\nFiled as ${c} (setup). When it settles you are woken with its outcome, so what the user asked for can go on then; end your turn if you have nothing else to do.`:"\n\nIts report wakes you when it has a verified environment saved (or when it gives up): end your turn if you have nothing else to do, or continue other work in the meantime."
1394
1396
  return{content:[{type:"text",text:`Environment setup started${c?` as ${c}`:""} (worktree ${I.data.worktreePath}). The setup-architect is inspecting the project.${$}`}],...h({kind:"spawn-subagent",spawnedSessionId:I.data.sessionId,agentType:"setup-architect",requestId:c??g??void 0,description:"Environment setup"})}}catch(e){return e instanceof Error&&/timeout|abort/i.test(e.message)?(a({success:!1,error:"spawn_slow"}),{content:[{type:"text",text:"Environment setup was requested and is probably still starting -- creating the setup worktree takes a while on a large repository. Do NOT call environment_setup again: the architect reports back on its own, and a second call would only ask the user the same question twice. Check with environment_list in a few minutes."}]}):(a({success:!1,error:"fetch_error"}),{content:[{type:"text",text:`environment setup failed: ${(0,p.getErrorMessage)(e)}`}],isError:!0})}},exports.handleEnvironmentProvision=async function(e,r,n,o,s,i){const a=s.startTimer("tool_execution_time")
@@ -1441,8 +1443,8 @@ const w=y.environmentName?`environment **${y.environmentName}** (${y.image}${y.h
1441
1443
  let b=""
1442
1444
  try{const e=y.environmentId||d
1443
1445
  if(o.projectId){const t=await s.proxyGet(`/api/projects/${o.projectId}/check-commands`),r=e?(t?.data||t||[]).filter(e=>e.isActive??e.is_active??!0).filter(t=>(t.environmentId??t.environment_id)===e).map(e=>`\`${e.name}\``):[]
1444
- r.length>0&&(b=`\nRegistered commands here: ${r.join(", ")} (run them via \`run\`).`)}}catch{}const v="write large output to /scratch (on disk) or /tmp (256 MB, in memory)",k=y.sourceWritable?` -- your live branch source. A command may change it (a formatter, a --fix, codegen): whatever a run changes is committed as that run's commit and listed in its result, so the tree stays clean; ${v}`:` -- your branch source, mounted READ-ONLY (edits you commit flow in; ${v})`,I=y.workdir?`Commands run in \`${y.workdir}\`${y.hostTier?" (a disposable writable worktree on the host)":k}. `:`The source is your branch${k}. `,$=function(e){return e.hostTier?"":e.hasGit&&!1===e.gitBinary?'This image has no git binary: a git command fails here ("git: not found"), so read the files themselves (grep, cat, or the project\'s own runtime); merge_preview and query_history show main and the history. ':e.hasGit?"git works here on your branch and its history, read-only (ls-files, log, diff, rev-parse); commits and other git writes fail. ":"git has no repository in this box: a command that needs one fails or reports nothing, so do not record such a run as proof. "}(y)
1445
- return{content:[{type:"text",text:`${y.reused?`\u{1f9ea} You already hold a box on ${w}; it is returned as it is (its files, servers and state are still there). To start clean, experiment_stop it and start again.`:`\u{1f9ea} Experiment started: ${w}.`}\nHandle: \`${y.handle}\`\n\n${I}${$}State persists across exec calls, including background processes (a server you start with \`&\` keeps running -- wait ~2s before its first request on a fresh box, and don't start it twice). Edits through the usual tools flow into the source live. It stops by itself when the request's work merges or it sits idle; experiment_stop frees it sooner.${b}`}]}}catch(e){return l({success:!1,error:"start_error"}),{content:[{type:"text",text:`Could not start experiment: ${(0,n.getErrorMessage)(e)}`}],isError:!0}}},exports.handleExperimentStop=async function(e,t,o,s,i,a){const c=i.startTimer("tool_execution_time")
1446
+ r.length>0&&(b=`\nRegistered commands here: ${r.join(", ")} (run them via \`run\`).`)}}catch{}const v="write large output to /scratch (on disk) or /tmp (256 MB, in memory)",k=y.sourceWritable?` -- your live branch source. A command may change it (a formatter, a --fix, codegen): whatever a run changes is committed as that run's commit and listed in its result, so the tree stays clean; ${v}`:` -- a copy of your branch made for this box: commands may write anywhere in it (build output, caches), and it goes when the box stops; ${v}`,I=y.workdir?`Commands run in \`${y.workdir}\`${y.hostTier?" (a disposable writable worktree on the host)":k}. `:`The source is your branch${k}. `,$=function(e){return e.hostTier?"":e.hasGit&&!1===e.gitBinary?'This image has no git binary: a git command fails here ("git: not found"), so read the files themselves (grep, cat, or the project\'s own runtime); merge_preview and query_history show main and the history. ':e.hasGit?"git works here on your branch and its history, read-only (ls-files, log, diff, rev-parse); commits and other git writes fail. ":"git has no repository in this box: a command that needs one fails or reports nothing, so do not record such a run as proof. "}(y)
1447
+ return{content:[{type:"text",text:`${y.reused?`\u{1f9ea} You already hold a box on ${w}; it is returned as it is (its files, servers and state are still there). To start clean, experiment_stop it and start again.`:`\u{1f9ea} Experiment started: ${w}.`}\nHandle: \`${y.handle}\`\n\n${I}${$}State persists across exec calls, including background processes (a server you start with \`&\` keeps running -- wait ~2s before its first request on a fresh box, and don't start it twice).${y.sourceWritable?" Edits through the usual tools flow into the source live.":""} It stops by itself when the request's work merges or it sits idle; experiment_stop frees it sooner.${b}`}]}}catch(e){return l({success:!1,error:"start_error"}),{content:[{type:"text",text:`Could not start experiment: ${(0,n.getErrorMessage)(e)}`}],isError:!0}}},exports.handleExperimentStop=async function(e,t,o,s,i,a){const c=i.startTimer("tool_execution_time")
1446
1448
  try{if(!e.handle)return c({success:!1,error:"bad_args"}),{content:[{type:"text",text:"experiment_stop needs a handle."}],isError:!0}
1447
1449
  const{ok:t,data:n}=await r("/api/experiments/stop","POST",{handle:e.handle,...a?.sessionId?{sessionId:a.sessionId}:{}},3e4)
1448
1450
  return c({success:t}),t&&n.success?{content:[{type:"text",text:n.data?.stopped?"\u{1f9ea} Experiment stopped and its environment torn down.":"That experiment was already gone."}]}:{content:[{type:"text",text:`experiment_stop failed: ${n.error||"unknown"}`}],isError:!0}}catch(e){return c({success:!1,error:"stop_error"}),{content:[{type:"text",text:`experiment_stop failed: ${(0,n.getErrorMessage)(e)}`}],isError:!0}}},exports.handleExperimentList=async function(e,t,o,s,i,a){const c=i.startTimer("tool_execution_time")
@@ -3188,33 +3190,33 @@ return c.filter(r=>!(r.debugOnly&&!t||("function"==typeof r.hidden?r.hidden(e):r
3188
3190
  return exports.SHORT_FORM_TOOLS.has(t.name)?{name:t.name,description:`${n(r)} (Short form: call tool_contract with { name: "${t.name}" } for its arguments before the first call.)`,inputSchema:{type:"object",properties:{},additionalProperties:!0},annotations:t.annotations}:{name:t.name,description:r,inputSchema:(0,s.zodToJsonSchema)(o(t)),annotations:t.annotations}})},exports.resolveSchema=o
3189
3191
  const s=t(25106),i=t(3444),a=t(92040),c=[],l=new Map
3190
3192
  let d=!1
3191
- exports.SHORT_FORM_TOOLS=new Set(["monitor_list","monitor_create","monitor_cancel","request_visual_feedback","ask_user_visual","fetch_asset","mcp_connections","show_user","guidance_feedback","followup_create","research_fanout"])},15715(e,exports,t){function r(e,t){return`Not completed yet: ${e} was completed before, and the summary you pass now REPLACES the one the user reads when it lands. The earlier one:\n "${t.length>600?`${t.slice(0,597)}...`:t}"\nWrite a summary that describes everything ${e} delivers, with this round's fixes folded in (not only the fixes), and call complete again with replacesSummary: true.`}exports.handleCompleteRequest=async function(e,t,S,E,_,x,C){const q=E.child({tool:"complete_request"}),T=_.startTimer("tool_execution_time")
3192
- try{const{requestId:s,summary:i,worthKnowing:j,skipTestsReason:P,skipTests:R,criteriaComments:A,couldNotCheck:O,guidance:M,replacesSummary:D}=e
3193
+ exports.SHORT_FORM_TOOLS=new Set(["monitor_list","monitor_create","monitor_cancel","request_visual_feedback","ask_user_visual","fetch_asset","mcp_connections","show_user","guidance_feedback","followup_create","research_fanout"])},15715(e,exports,t){function r(e,t){return`Not completed yet: ${e} was completed before, and the summary you pass now REPLACES the one the user reads when it lands. The earlier one:\n "${t.length>600?`${t.slice(0,597)}...`:t}"\nWrite a summary that describes everything ${e} delivers, with this round's fixes folded in (not only the fixes), and call complete again with replacesSummary: true.`}exports.handleCompleteRequest=async function(e,t,E,_,x,C,q){const T=_.child({tool:"complete_request"}),j=x.startTimer("tool_execution_time")
3194
+ try{const{requestId:s,summary:i,worthKnowing:P,skipTestsReason:R,skipTests:A,criteriaComments:O,couldNotCheck:M,guidance:D,replacesSummary:F,notChecked:N}=e
3193
3195
  if(!s)throw(0,o.createValidationError)("Request ID is required")
3194
3196
  if(!i)throw(0,o.createValidationError)("Summary is required")
3195
- if(P&&R&&R.length>0)throw(0,o.createValidationError)("Provide either skipTestsReason (skip all) or skipTests (per-command), not both.")
3196
- if(!0!==D)try{const e=await S.getRequestClient().getRequest(s),t=String(e?.completionSummary??"").trim()
3197
- if(t)return q.info("re-completion refused until the summary is confirmed to cover the whole request",{requestId:s}),{content:[{type:"text",text:r(s,t)}],isError:!0}}catch(e){q.debug("earlier-summary check could not run; completion continues",{requestId:s,error:(0,h.getErrorMessage)(e)})}q.info("Starting request completion",{requestId:s,skipAllRequested:!!P,perCommandSkipCount:R?.length||0})
3198
- const F=C?.sessionId??t.currentSessionId,N=C??(F?{providerId:"opencode",sessionId:F,createdAt:(new Date).toISOString()}:void 0)
3197
+ if(R&&A&&A.length>0)throw(0,o.createValidationError)("Provide either skipTestsReason (skip all) or skipTests (per-command), not both.")
3198
+ if(!0!==F)try{const e=await E.getRequestClient().getRequest(s),t=String(e?.completionSummary??"").trim()
3199
+ if(t)return T.info("re-completion refused until the summary is confirmed to cover the whole request",{requestId:s}),{content:[{type:"text",text:r(s,t)}],isError:!0}}catch(e){T.debug("earlier-summary check could not run; completion continues",{requestId:s,error:(0,h.getErrorMessage)(e)})}T.info("Starting request completion",{requestId:s,skipAllRequested:!!R,perCommandSkipCount:A?.length||0})
3200
+ const z=q?.sessionId??t.currentSessionId,L=q??(z?{providerId:"opencode",sessionId:z,createdAt:(new Date).toISOString()}:void 0)
3199
3201
  try{const e=await fetch(`${(0,f.getActionServerBaseUrl)()}/api/commit-worktree-leftovers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:s}),signal:AbortSignal.timeout(2e4)})
3200
3202
  if(e.ok){const t=await e.json()
3201
- t?.data?.committed&&q.info("Committed uncommitted worktree changes before completing",{requestId:s,sha:t.data.sha?.slice(0,8),files:t.data.files?.length??0})}}catch(e){q.debug("commit-worktree-leftovers unavailable; completing as before",{requestId:s,error:(0,h.getErrorMessage)(e)})}t.mainBasePath&&await(0,c.foldAtDoor)({repoDir:t.mainBasePath,branch:`requests/${s}`,defaultBranch:await(0,b.resolveDefaultBranch)(t.mainBasePath,t.gitBinary).catch(()=>"main"),requestId:s,door:"complete",gitBinary:t.gitBinary,postRecord:e=>S.proxyPost(`/api/projects/${t.projectId}/tool-records`,e),log:q})
3202
- let z=null,L=null
3203
+ t?.data?.committed&&T.info("Committed uncommitted worktree changes before completing",{requestId:s,sha:t.data.sha?.slice(0,8),files:t.data.files?.length??0})}}catch(e){T.debug("commit-worktree-leftovers unavailable; completing as before",{requestId:s,error:(0,h.getErrorMessage)(e)})}t.mainBasePath&&await(0,c.foldAtDoor)({repoDir:t.mainBasePath,branch:`requests/${s}`,defaultBranch:await(0,b.resolveDefaultBranch)(t.mainBasePath,t.gitBinary).catch(()=>"main"),requestId:s,door:"complete",gitBinary:t.gitBinary,postRecord:e=>E.proxyPost(`/api/projects/${t.projectId}/tool-records`,e),log:T})
3204
+ let B=null,H=null
3203
3205
  try{const e=await fetch(`${(0,f.getActionServerBaseUrl)()}/api/branch-head?requestId=${encodeURIComponent(s)}`,{signal:AbortSignal.timeout(5e3)})
3204
3206
  if(e.ok){const t=await e.json()
3205
- z=t?.data?.sha??null,L=t?.data?.tree??null}}catch(e){q.debug("branch-head fetch failed; server will fall back",{error:(0,h.getErrorMessage)(e)})}const B=z?{headSha:z,...L?{headTree:L}:{}}:{}
3206
- let H=null
3207
+ B=t?.data?.sha??null,H=t?.data?.tree??null}}catch(e){T.debug("branch-head fetch failed; server will fall back",{error:(0,h.getErrorMessage)(e)})}const U=B?{headSha:B,...H?{headTree:H}:{}}:{}
3208
+ let G=null
3207
3209
  try{const e=await fetch(`${(0,f.getActionServerBaseUrl)()}/api/request-diff-stats?requestId=${encodeURIComponent(s)}`,{signal:AbortSignal.timeout(5e3)})
3208
3210
  if(e.ok){const r=await e.json()
3209
3211
  if(r?.data&&"number"==typeof r.data.additions&&"number"==typeof r.data.deletions&&"number"==typeof r.data.filesChanged){const e=Array.isArray(r.data.files)?r.data.files.filter(e=>"string"==typeof e):void 0,n=Array.isArray(r.data.deleted)?r.data.deleted.filter(e=>"string"==typeof e):void 0
3210
- if(H={additions:r.data.additions,deletions:r.data.deletions,filesChanged:r.data.filesChanged,...e?{files:e}:{},docsOnly:!0===r.data.docsOnly,...n?{deleted:n}:{}},n&&n.length>0)try{const e=await S.proxyGet(`/api/projects/${t.projectId}/test-processes`),r=Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[],o=await S.getRequestClient().getRequest(s).catch(()=>null),i="string"==typeof o?.exchangeMessageCode&&o.exchangeMessageCode?await(S.getSessionMessageClient()?.getMessage(o.exchangeMessageCode).catch(()=>null)):null
3211
- H.checkLosses=await(0,l.signoffCheckLosses)(n,r,o?{...o,askedAt:i?.createdAt??null}:null)}catch(e){q.warn("checks could not be read; the sign-off card will not name deleted files a check covered",{requestId:s,error:(0,h.getErrorMessage)(e)})}}}}catch(e){q.debug("request-diff-stats fetch failed; review scaling falls back to the full panel",{error:(0,h.getErrorMessage)(e)})}const U=H?{diffStats:H}:{}
3212
- let G,W=null
3213
- try{const e=await S.proxyGet(`/api/projects/${t.projectId}/requests/${s}/kind`)
3214
- W=(e?.data??e)?.kind??null}catch(e){q.debug("request kind unavailable; kind checks skipped",{error:(0,h.getErrorMessage)(e)})}try{if("writing"===W){const e=await fetch(`${(0,f.getActionServerBaseUrl)()}/api/sibling-overlap?requestId=${encodeURIComponent(s)}`,{signal:AbortSignal.timeout(1e4)}),t=(e.ok?(await e.json())?.data??[]:[]).filter(e=>!g.DOC_PATH_RE.test(e.path))
3212
+ if(G={additions:r.data.additions,deletions:r.data.deletions,filesChanged:r.data.filesChanged,...e?{files:e}:{},docsOnly:!0===r.data.docsOnly,...n?{deleted:n}:{}},n&&n.length>0)try{const e=await E.proxyGet(`/api/projects/${t.projectId}/test-processes`),r=Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[],o=await E.getRequestClient().getRequest(s).catch(()=>null),i="string"==typeof o?.exchangeMessageCode&&o.exchangeMessageCode?await(E.getSessionMessageClient()?.getMessage(o.exchangeMessageCode).catch(()=>null)):null
3213
+ G.checkLosses=await(0,l.signoffCheckLosses)(n,r,o?{...o,askedAt:i?.createdAt??null}:null)}catch(e){T.warn("checks could not be read; the sign-off card will not name deleted files a check covered",{requestId:s,error:(0,h.getErrorMessage)(e)})}}}}catch(e){T.debug("request-diff-stats fetch failed; review scaling falls back to the full panel",{error:(0,h.getErrorMessage)(e)})}const W=G?{diffStats:G}:{}
3214
+ let V,K=null
3215
+ try{const e=await E.proxyGet(`/api/projects/${t.projectId}/requests/${s}/kind`)
3216
+ K=(e?.data??e)?.kind??null}catch(e){T.debug("request kind unavailable; kind checks skipped",{error:(0,h.getErrorMessage)(e)})}try{if("writing"===K){const e=await fetch(`${(0,f.getActionServerBaseUrl)()}/api/sibling-overlap?requestId=${encodeURIComponent(s)}`,{signal:AbortSignal.timeout(1e4)}),t=(e.ok?(await e.json())?.data??[]:[]).filter(e=>!g.DOC_PATH_RE.test(e.path))
3215
3217
  if(t.length>0){const e=t.slice(0,5).map(e=>{const t=e.mine.map(e=>e[0]===e[1]?`line ${e[0]}`:`lines ${e[0]}-${e[1]}`).join(", ")
3216
3218
  return`- ${e.path} (${t}) is also changed by ${e.sibling}${e.siblingTitle?` ("${e.siblingTitle}"`:""}${e.siblingStatus?`, ${e.siblingStatus.replace(/_/g," ")})`:e.siblingTitle?")":""}`}),r=[...new Set(t.map(e=>e.sibling))]
3217
- return{content:[{type:"text",text:`Completion NOT recorded: this is a writing request, and it changes code that a sibling request is changing.\n\n${e.join("\n")}\n\nA writing request documents the product as it is. Revert those changes on your branch. If your text depends on that work, wait on it: request_operations wait-on with waitsOn: ${JSON.stringify(r)}. Do not implement it and do not delete the text that describes it.`}],isError:!0}}}}catch(e){q.debug("sibling-overlap check could not run; completion continues",{error:(0,h.getErrorMessage)(e)})}try{if("drive"===W){const e=function(e,t){const r=Array.isArray(e?.acceptanceCriteria)?e.acceptanceCriteria:[]
3219
+ return{content:[{type:"text",text:`Completion NOT recorded: this is a writing request, and it changes code that a sibling request is changing.\n\n${e.join("\n")}\n\nA writing request documents the product as it is. Revert those changes on your branch. If your text depends on that work, wait on it: request_operations wait-on with waitsOn: ${JSON.stringify(r)}. Do not implement it and do not delete the text that describes it.`}],isError:!0}}}}catch(e){T.debug("sibling-overlap check could not run; completion continues",{error:(0,h.getErrorMessage)(e)})}try{if("drive"===K){const e=function(e,t){const r=Array.isArray(e?.acceptanceCriteria)?e.acceptanceCriteria:[]
3218
3220
  if(0===r.length)return null
3219
3221
  const o=e=>String(e??"").trim().toLowerCase(),s=new Set((Array.isArray(t?.couldNotCheck)?t.couldNotCheck:[]).map(o).filter(Boolean)),i=new Set((t?.commentedKeys??[]).map(o).filter(Boolean)),a=(e,t)=>e?.id?(0,n.criterionShortKey)(String(e.id),t):"",c=r.filter((e,t)=>{if((0,n.isUserOwnCheck)(e))return!1
3220
3222
  const r=(0,n.latestRow)(e,["driver"])?.verdict
@@ -3224,7 +3226,7 @@ return!(c&&s.has(c)&&i.has(c))})
3224
3226
  if(0===c.length)return null
3225
3227
  const l=c.slice(0,8).map(e=>{const t=r.indexOf(e),n=a(e,t),o=String(e?.description??"").trim()
3226
3228
  return` - ${n?`[${n}] `:""}${o.length>120?`${o.slice(0,117)}...`:o}`}).join("\n")
3227
- return`Completion NOT recorded: ${c.length} of this drive's ${r.length} claims ${1===c.length?"has":"have"} no verdict:\n${l}\n\nThe claims are the drive's result, and the card counts them from the stamps. Call record_criteria_verification with a verdict for each claim you checked (VERIFIED stamps met, DIVERGED stamps unmet, with the evidence), then complete again. A claim you could NOT check goes in couldNotCheck on this call, by its key, with the reason in that criterion's criteriaComments entry: it is not a verdict, and it reads as unchecked.`}(await S.getRequestClient().getRequest(s),{couldNotCheck:O,commentedKeys:(A??[]).map(e=>e.key)})
3229
+ return`Completion NOT recorded: ${c.length} of this drive's ${r.length} claims ${1===c.length?"has":"have"} no verdict:\n${l}\n\nThe claims are the drive's result, and the card counts them from the stamps. Call record_criteria_verification with a verdict for each claim you checked (VERIFIED stamps met, DIVERGED stamps unmet, with the evidence), then complete again. A claim you could NOT check goes in couldNotCheck on this call, by its key, with the reason in that criterion's criteriaComments entry: it is not a verdict, and it reads as unchecked.`}(await E.getRequestClient().getRequest(s),{couldNotCheck:M,commentedKeys:(O??[]).map(e=>e.key)})
3228
3230
  if(e)return{content:[{type:"text",text:e}],isError:!0}
3229
3231
  const r=await async function(e,t,r,o){const s=(Array.isArray(r)?r:[]).map(e=>String(e??"").trim().toLowerCase()).filter(Boolean)
3230
3232
  if(0===s.length)return[]
@@ -3233,129 +3235,140 @@ return a.forEach((e,t)=>{if(!e?.id)return
3233
3235
  const r=(0,n.criterionShortKey)(String(e.id),t).toLowerCase()
3234
3236
  if(!s.includes(r))return
3235
3237
  const i=(o??[]).find(e=>String(e?.key??"").trim().toLowerCase()===r)
3236
- c.push({criterionId:String(e.id),reason:i?.comment??null})}),c}(S.getRequestClient(),s,O,A)
3237
- r.length>0&&await S.proxyPost(`/api/projects/${t.projectId}/requests/${s}/drive-not-checked`,{items:r})}}catch(e){q.debug("drive-claim stamp check could not run; completion continues",{error:(0,h.getErrorMessage)(e)})}const V=[]
3238
- if(A&&A.length>0)try{const e=S.getRequestClient(),r=await e.getRequest(s),n=r?.acceptanceCriteria||[]
3239
- if(q.info("Recording coder criteria comments",{requestId:s,comments:A.length,criteriaFetched:n.length}),0===n.length)return q.error("Criteria comments provided but the request came back with no criteria",{requestId:s}),{content:[{type:"text",text:`Completion NOT recorded: your criteria comments could not be attached because ${s} came back with no acceptance criteria. This is a read failure on our side, not a mistake in your call. Retry complete once; if it repeats, report it to your parent as blocked and say the criteria read is failing.`}],isError:!0}
3238
+ c.push({criterionId:String(e.id),reason:i?.comment??null})}),c}(E.getRequestClient(),s,M,O)
3239
+ r.length>0&&await E.proxyPost(`/api/projects/${t.projectId}/requests/${s}/drive-not-checked`,{items:r})}}catch(e){T.debug("drive-claim stamp check could not run; completion continues",{error:(0,h.getErrorMessage)(e)})}const Y=[]
3240
+ if(O&&O.length>0)try{const e=E.getRequestClient(),r=await e.getRequest(s),n=r?.acceptanceCriteria||[]
3241
+ if(T.info("Recording coder criteria comments",{requestId:s,comments:O.length,criteriaFetched:n.length}),0===n.length)return T.error("Criteria comments provided but the request came back with no criteria",{requestId:s}),{content:[{type:"text",text:`Completion NOT recorded: your criteria comments could not be attached because ${s} came back with no acceptance criteria. This is a read failure on our side, not a mistake in your call. Retry complete once; if it repeats, report it to your parent as blocked and say the criteria read is failing.`}],isError:!0}
3240
3242
  {const e=(0,p.buildCriteriaKeyMap)(n),r=[],o=[]
3241
- for(const t of A){const n=e.get(t.key),s=Array.isArray(t.verify)?t.verify.filter(e=>"string"==typeof e&&e.trim()):[]
3243
+ for(const t of O){const n=e.get(t.key),s=Array.isArray(t.verify)?t.verify.filter(e=>"string"==typeof e&&e.trim()):[]
3242
3244
  n&&s.length>0&&"subjective"===n.kind?r.push({criterionId:n.id,evidence:`${t.comment}\n\nWhat I ran (a judgment decides this criterion, not these): ${s.join(" ; ")}`}):n?r.push({criterionId:n.id,evidence:t.comment,...s.length?{verify:s}:{}}):o.push(t.key)}if(o.length>0){const e=(0,p.formatCriteriaWithKeys)(n)
3243
- return q.warn("criteriaComments keys did not match any criterion",{requestId:s,unmatched:o}),{content:[{type:"text",text:`Completion NOT recorded: ${o.length} criteriaComments key(s) match no criterion on ${s}: ${o.join(", ")}.\n\nThe key's letter is a checksum over the criterion's id, so a wrong letter is refused rather than guessed at -- otherwise your evidence would attach to the wrong criterion. Copy the keys exactly as listed:\n\n${e}\n\nRe-run complete with the exact keys. Nothing was recorded, so no verdict was attached to the wrong criterion.`}],isError:!0}}const i=[]
3245
+ return T.warn("criteriaComments keys did not match any criterion",{requestId:s,unmatched:o}),{content:[{type:"text",text:`Completion NOT recorded: ${o.length} criteriaComments key(s) match no criterion on ${s}: ${o.join(", ")}.\n\nThe key's letter is a checksum over the criterion's id, so a wrong letter is refused rather than guessed at -- otherwise your evidence would attach to the wrong criterion. Copy the keys exactly as listed:\n\n${e}\n\nRe-run complete with the exact keys. Nothing was recorded, so no verdict was attached to the wrong criterion.`}],isError:!0}}const i=[]
3244
3246
  for(const e of r.flatMap(e=>e.verify??[])){const r=(0,m.gitVerifyProblem)(e)??(t.git?await(0,m.nodeCheckProblem)(t.git,`requests/${s}`,e):null)
3245
- r&&i.push(` ${e}\n -> ${r}`)}if(i.length>0)return q.warn("verify commands that cannot prove anything; completion refused",{requestId:s,count:i.length}),{content:[{type:"text",text:`Completion NOT recorded: ${i.length} verify command(s) can never prove their criterion.\n\n${i.join("\n")}\n\nReplace them and complete again. Nothing was recorded.`}],isError:!0}
3246
- const a=e=>{const t=n.find(t=>t?.id===e.criterionId),r="string"==typeof t?.command&&t.command.trim()?[t.command.trim()]:[],o=t?.standing&&Array.isArray(t.verify)?t.verify.filter(e=>"string"==typeof e&&!!e.trim()):r
3247
+ r&&i.push(` ${e}\n -> ${r}`)}if(i.length>0)return T.warn("verify commands that cannot prove anything; completion refused",{requestId:s,count:i.length}),{content:[{type:"text",text:`Completion NOT recorded: ${i.length} verify command(s) can never prove their criterion.\n\n${i.join("\n")}\n\nReplace them and complete again. Nothing was recorded.`}],isError:!0}
3248
+ const a=e=>{const t=n.find(t=>t?.id===e.criterionId)
3249
+ if((0,$.hasBaseline)(t))return[]
3250
+ const r="string"==typeof t?.command&&t.command.trim()?[t.command.trim()]:[],o=t?.standing&&Array.isArray(t.verify)?t.verify.filter(e=>"string"==typeof e&&!!e.trim()):r
3247
3251
  return e.verify?.length?[...o,...e.verify.filter(e=>!o.includes(e))]:[]},c=[...new Set(r.flatMap(a))]
3248
3252
  let l=null
3249
- const d=function(e,t,r){return!(!t||0===r.length)&&r.every(r=>(Array.isArray(e)?e:[]).some(e=>(Array.isArray(e?.ledger)?e.ledger:[]).some(e=>"verify"===e?.source&&"met"===e?.verdict&&e?.ran===r&&"string"==typeof e?.commit&&!!e.commit&&(e.commit.startsWith(t)||t.startsWith(e.commit)))))}(n,z,c)
3250
- if(d&&q.info("verify preflight: every proof already passed on this head; not run again",{requestId:s,sha:z}),c.length>0&&!d)try{const e=await fetch(`${(0,f.getActionServerBaseUrl)()}/api/verify-preflight`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:s,commands:c,background:!0,proofs:r.flatMap(e=>a(e).map(t=>({criterionId:e.criterionId,command:t})))}),signal:AbortSignal.timeout(18e4)}),t=e.ok?await e.json():null,n=t?.data
3251
- n?.pending&&q.info("verify preflight started beside the sign-off check; the merge waits for it",{requestId:s,sha:n.sha,commands:c.length}),n?.available&&Array.isArray(n.results)&&(l=n),n?.available&&(n.dropped??0)>0&&q.warn("verify preflight dropped commands over the ceiling",{requestId:s,dropped:n.dropped})
3253
+ const d=function(e,t,r){return!(!t||0===r.length)&&r.every(r=>(Array.isArray(e)?e:[]).some(e=>(Array.isArray(e?.ledger)?e.ledger:[]).some(e=>"verify"===e?.source&&"met"===e?.verdict&&e?.ran===r&&"string"==typeof e?.commit&&!!e.commit&&(e.commit.startsWith(t)||t.startsWith(e.commit)))))}(n,B,c)
3254
+ if(d&&T.info("verify preflight: every proof already passed on this head; not run again",{requestId:s,sha:B}),c.length>0&&!d)try{const e=await fetch(`${(0,f.getActionServerBaseUrl)()}/api/verify-preflight`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:s,commands:c,background:!0,proofs:r.flatMap(e=>a(e).map(t=>({criterionId:e.criterionId,command:t})))}),signal:AbortSignal.timeout(18e4)}),t=e.ok?await e.json():null,n=t?.data
3255
+ n?.pending&&T.info("verify preflight started beside the sign-off check; the merge waits for it",{requestId:s,sha:n.sha,commands:c.length}),n?.available&&Array.isArray(n.results)&&(l=n),n?.available&&(n.dropped??0)>0&&T.warn("verify preflight dropped commands over the ceiling",{requestId:s,dropped:n.dropped})
3252
3256
  const o=n?.available&&Array.isArray(n.results)?n.results.filter(e=>!e.ok&&!0===e.unparsed):[]
3253
3257
  if(o.length>0)return{content:[{type:"text",text:`Completion NOT recorded: ${o.length} of your own verify command(s) do not parse in the shell, so they never ran and prove nothing:\n\n`+o.map(e=>` ${e.command}\n -> ${e.output?e.output.split("\n")[0]:"syntax error"}`).join("\n")+"\n\nFix the command (quoting, backquotes, parentheses), then complete again. Nothing was recorded."}],isError:!0}
3254
3258
  const i=n?.available&&Array.isArray(n.results)?n.results.filter(e=>!e.ok&&(e.timedOut||e.couldNotRun)):[]
3255
- i.length>0&&q.info("verify preflight: some proofs did not finish or could not run here; the gate decides them",{requestId:s,count:i.length,sha:n?.sha})
3259
+ i.length>0&&T.info("verify preflight: some proofs did not finish or could not run here; the gate decides them",{requestId:s,count:i.length,sha:n?.sha})
3256
3260
  const d=n?.available&&Array.isArray(n.results)?n.results.filter(e=>!e.ok&&!e.timedOut&&!e.couldNotRun):[],u=d.filter(e=>!1!==(e.authoritative??n?.authoritative))
3257
- if(d.length>0&&0===u.length&&q.warn("verify preflight failed but the gate environment is ambiguous; completing anyway",{requestId:s,failed:d.length,sha:n?.sha}),u.length>0){q.warn("verify preflight failed; completion refused",{requestId:s,failed:u.length,sha:n?.sha})
3261
+ if(d.length>0&&0===u.length&&T.warn("verify preflight failed but the gate environment is ambiguous; completing anyway",{requestId:s,failed:d.length,sha:n?.sha}),u.length>0){T.warn("verify preflight failed; completion refused",{requestId:s,failed:u.length,sha:n?.sha})
3258
3262
  const e=u.map(e=>` ${e.command}\n -> exit ${e.exit}${e.timedOut?" (timed out)":""}${e.output?`: ${e.output.split("\n")[0]}`:""}`).join("\n")
3259
- return{content:[{type:"text",text:`Completion NOT recorded: ${u.length} of the criteria's verify command(s) (yours, and any a guidance check put there) FAIL on the tree you are completing (${String(n?.sha??"").slice(0,8)}).\n\n`+e+((n?.dropped??0)>0?`\n\n(${n.dropped} further command(s) were over the 20-command ceiling and were not run.)`:"")+"\n\nThis is the box your checks are judged in, so this is exactly what the sign-off card would show. Two things cause it: the check is wrong (it pins something you changed after writing it, such as a renamed local, or it matches by accident, such as a word found inside a longer word), or the code genuinely does not do what the criterion promises.\n\nFix whichever is wrong -- adjust the command to grep the observable thing (an id, a name, an exported symbol), or fix the code -- then complete again. Nothing was recorded."}],isError:!0}}}catch(e){q.debug("verify preflight unavailable; completing without it",{requestId:s,error:(0,h.getErrorMessage)(e)})}if(r.length>0&&(await S.proxyPost(`/api/projects/${t.projectId}/requests/${s}/verify-criteria`,{verifications:r,dimension:"coder"}),V.push(...r.map(e=>e.criterionId))),l?.sha&&l.results?.length){const e=r.flatMap(e=>a(e).flatMap(t=>{const r=l.results.find(e=>e.command===t)
3263
+ return{content:[{type:"text",text:`Completion NOT recorded: ${u.length} of the criteria's verify command(s) (yours, and any a guidance check put there) FAIL on the tree you are completing (${String(n?.sha??"").slice(0,8)}).\n\n`+e+((n?.dropped??0)>0?`\n\n(${n.dropped} further command(s) were over the 20-command ceiling and were not run.)`:"")+"\n\nThis is the box your checks are judged in, so this is exactly what the sign-off card would show. Two things cause it: the check is wrong (it pins something you changed after writing it, such as a renamed local, or it matches by accident, such as a word found inside a longer word), or the code genuinely does not do what the criterion promises.\n\nFix whichever is wrong -- adjust the command to grep the observable thing (an id, a name, an exported symbol), or fix the code -- then complete again. Nothing was recorded."}],isError:!0}}}catch(e){T.debug("verify preflight unavailable; completing without it",{requestId:s,error:(0,h.getErrorMessage)(e)})}if(r.length>0&&(await E.proxyPost(`/api/projects/${t.projectId}/requests/${s}/verify-criteria`,{verifications:r,dimension:"coder"}),Y.push(...r.map(e=>e.criterionId))),l?.sha&&l.results?.length){const e=r.flatMap(e=>a(e).flatMap(t=>{const r=l.results.find(e=>e.command===t)
3260
3264
  return r?[{criterionId:e.criterionId,command:t,ok:r.ok,...r.timedOut?{timedOut:!0}:{},...r.couldNotRun?{couldNotRun:!0}:{},output:String(r.output??"").split("\n")[0].slice(0,200)}]:[]}))
3261
- e.length>0&&await S.proxyPost(`/api/projects/${t.projectId}/requests/${s}/proof-evidence`,{commitSha:l.sha,tree:l.tree??null,proofs:e}).catch(e=>q.warn("the preflight's results were not recorded as evidence (the gate runs the proofs again)",{requestId:s,error:(0,h.getErrorMessage)(e)}))}}}catch(e){return q.error("Failed to persist coder criteria comments",{requestId:s,error:(0,h.getErrorMessage)(e)}),{content:[{type:"text",text:`Completion NOT recorded: your criteria comments could not be saved (${(0,h.getErrorMessage)(e)}). Retry complete -- without them, objective criteria stay unproven and completion is refused.`}],isError:!0}}if(t.git){try{const e=await(0,a.findCommittedMarkers)(t.git,`requests/${s}`)
3262
- if(e.determined&&e.files.length>0)return q.warn("completion refused: committed conflict markers on the branch",{requestId:s,files:e.files}),T({success:!1,reason:"unresolved_markers"}),{content:[{type:"text",text:`Completion NOT recorded: ${s}'s branch still contains committed conflict markers in ${e.files.join(", ")}.\n\nThe system merged the default branch into yours and committed the conflicted state so you could see it; those <<<<<<< / ======= / >>>>>>> lines are plain file content now. Resolve every block with your file tools, re-run your checks, then complete again.\n\nStopping here on purpose: a reviewer would only tell you the same thing a minute later.`}],isError:!0}}catch(e){q.warn("conflict-marker precheck could not run; leaving it to the merge gate",{requestId:s,error:(0,h.getErrorMessage)(e)})}if(!$.has(s))try{const e=await(0,d.scanStaleProse)(t.git,`requests/${s}`),r=(0,d.renderStaleProse)(e)
3263
- if(r)return $.add(s),q.info("completion paused once: prose the branch made stale",{requestId:s,gone:e.goneReferences.length,previewUrls:e.previewUrls.length}),T({success:!1,reason:"stale_prose_shown"}),{content:[{type:"text",text:`Completion paused for one look (${s}): your change may have made prose in the repository untrue.\n\n${r}\n\nFix what is wrong (READMEs and entry points are part of the work), then complete again. If a line is fine as it is, completing again goes straight through; this notice is shown once.`}],isError:!0}}catch(e){q.warn("stale-prose scan could not run; completing without it",{requestId:s,error:(0,h.getErrorMessage)(e)})}}let K,Y,J=null
3264
- try{const e=await S.getRequestClient().getRequest(s),r=Array.isArray(e?.acceptanceCriteria)?e.acceptanceCriteria:[],o=r.map(e=>(0,n.latestRow)(e,["reviewer"])).filter(e=>!(!e||"met"!==e.verdict&&"unmet"!==e.verdict||"string"!=typeof e.commit||!e.commit)).sort((e,t)=>String(t.at??"").localeCompare(String(e.at??"")))[0],i=t.mainBasePath?await(0,b.resolveDefaultBranch)(t.mainBasePath):null,a=`refs/heads/requests/${s}`
3265
- if(o&&t.mainBasePath&&i&&(J=await(0,y.measureChangesSinceReview)(t.mainBasePath,{branchRef:a,reviewedSha:o.commit,defaultBranch:i,acceptedSha:"string"==typeof e?.diffSummary?.reviewAcceptedSha?e.diffSummary.reviewAcceptedSha:null}),J&&(K=J.authoredCommits)),z&&t.mainBasePath&&i){const e=new Set
3265
+ e.length>0&&await E.proxyPost(`/api/projects/${t.projectId}/requests/${s}/proof-evidence`,{commitSha:l.sha,tree:l.tree??null,proofs:e}).catch(e=>T.warn("the preflight's results were not recorded as evidence (the gate runs the proofs again)",{requestId:s,error:(0,h.getErrorMessage)(e)}))}}}catch(e){return T.error("Failed to persist coder criteria comments",{requestId:s,error:(0,h.getErrorMessage)(e)}),{content:[{type:"text",text:`Completion NOT recorded: your criteria comments could not be saved (${(0,h.getErrorMessage)(e)}). Retry complete -- without them, objective criteria stay unproven and completion is refused.`}],isError:!0}}if(t.git){try{const e=await(0,a.findCommittedMarkers)(t.git,`requests/${s}`)
3266
+ if(e.determined&&e.files.length>0)return T.warn("completion refused: committed conflict markers on the branch",{requestId:s,files:e.files}),j({success:!1,reason:"unresolved_markers"}),{content:[{type:"text",text:`Completion NOT recorded: ${s}'s branch still contains committed conflict markers in ${e.files.join(", ")}.\n\nThe system merged the default branch into yours and committed the conflicted state so you could see it; those <<<<<<< / ======= / >>>>>>> lines are plain file content now. Resolve every block with your file tools, re-run your checks, then complete again.\n\nStopping here on purpose: a reviewer would only tell you the same thing a minute later.`}],isError:!0}}catch(e){T.warn("conflict-marker precheck could not run; leaving it to the merge gate",{requestId:s,error:(0,h.getErrorMessage)(e)})}if(!S.has(s))try{const e=await(0,d.scanStaleProse)(t.git,`requests/${s}`),r=(0,d.renderStaleProse)(e)
3267
+ if(r)return S.add(s),T.info("completion paused once: prose the branch made stale",{requestId:s,gone:e.goneReferences.length,previewUrls:e.previewUrls.length}),j({success:!1,reason:"stale_prose_shown"}),{content:[{type:"text",text:`Completion paused for one look (${s}): your change may have made prose in the repository untrue.\n\n${r}\n\nFix what is wrong (READMEs and entry points are part of the work), then complete again. If a line is fine as it is, completing again goes straight through; this notice is shown once.`}],isError:!0}}catch(e){T.warn("stale-prose scan could not run; completing without it",{requestId:s,error:(0,h.getErrorMessage)(e)})}}let J,Q,Z=null
3268
+ try{const e=await E.getRequestClient().getRequest(s),r=Array.isArray(e?.acceptanceCriteria)?e.acceptanceCriteria:[],o=r.map(e=>(0,n.latestRow)(e,["reviewer"])).filter(e=>!(!e||"met"!==e.verdict&&"unmet"!==e.verdict||"string"!=typeof e.commit||!e.commit)).sort((e,t)=>String(t.at??"").localeCompare(String(e.at??"")))[0],i=t.mainBasePath?await(0,b.resolveDefaultBranch)(t.mainBasePath):null,a=`refs/heads/requests/${s}`
3269
+ if(o&&t.mainBasePath&&i&&(Z=await(0,y.measureChangesSinceReview)(t.mainBasePath,{branchRef:a,reviewedSha:o.commit,defaultBranch:i,acceptedSha:"string"==typeof e?.diffSummary?.reviewAcceptedSha?e.diffSummary.reviewAcceptedSha:null}),Z&&(J=Z.authoredCommits)),B&&t.mainBasePath&&i){const e=new Set
3266
3270
  for(const t of r){const r=(0,n.latestRow)(t,[(0,n.isUserOwnCheck)(t)?"you":"reviewer"])
3267
- "met"===r?.verdict&&"string"==typeof r.commit&&r.commit&&r.commit!==z&&e.add(r.commit)}Y=[]
3271
+ "met"===r?.verdict&&"string"==typeof r.commit&&r.commit&&r.commit!==B&&e.add(r.commit)}Q=[]
3268
3272
  for(const r of[...e].slice(0,6)){const e=await(0,y.measureChangesSinceReview)(t.mainBasePath,{branchRef:a,reviewedSha:r,defaultBranch:i}).catch(()=>null)
3269
- Y.push({sha:r,since:e?e.newLines+e.droppedLines>0?"changed":"same":"unknown"})}}}catch(e){q.debug("changes-since-review measure unavailable; the server keeps the review as it is",{error:(0,h.getErrorMessage)(e)})}if(H&&H.filesChanged>0)try{const e=await S.getRequestClient().getRequest(s)
3270
- if("merge"===(0,v.kindProfile)(e?.type).finalize){const r=await(0,k.closeOneTask)(S.getTaskClient(),{projectId:t.projectId,requestId:s,title:String(e?.title||s),summary:i})
3271
- r&&((0,I.clearActiveTaskCache)(),q.info("work in one piece: the request's one task closed",{requestId:s,taskId:r}))}}catch(e){q.warn("could not record the one task; completion continues as before",{requestId:s,error:(0,h.getErrorMessage)(e)})}try{const e=await S.proxyPost(`/api/projects/${t.projectId}/requests/${s}/validate-completion`,(0,w.validateCompletionBody)("tool",{sessionId:F,skipTestsReason:P,skipTests:R,headSha:z,...void 0!==K?{authoredSinceReview:K}:{},...J?{reviewDelta:J}:{},...Y?{intentMoves:Y}:{},...H?.files?{files:H.files}:{}}))
3272
- G=e?.data||e}catch(e){const t=(0,h.getErrorMessage)(e)
3273
- return q.error("Server validation failed",{requestId:s,error:t}),T({success:!1,error:"validation_request_failed"}),{content:[{type:"text",text:`Failed to validate completion: ${t}`}],isError:!0}}if(!G.canComplete){let e=`Cannot complete request ${s}: ${G.reason}\n`
3274
- if(G.blockedByTasks&&G.blockedByTasks.length>0&&(e+="\n**Tasks that must be completed or canceled first:**\n",G.blockedByTasks.forEach((t,r)=>{e+=`${r+1}. **${t.taskId}** - ${t.title} (Status: ${t.status})\n`})),G.lifoViolation&&(e+="\n**Requests that must be re-completed first (LIFO order):**\n",G.lifoViolation.blockingRequests.forEach((t,r)=>{e+=`${r+1}. **${t.requestId}** - ${t.title} (Status: ${t.status})\n`})),V.length>0)try{const t=await S.getRequestClient().getRequest(s)
3273
+ Q.push({sha:r,since:e?e.newLines+e.droppedLines>0?"changed":"same":"unknown"})}}}catch(e){T.debug("changes-since-review measure unavailable; the server keeps the review as it is",{error:(0,h.getErrorMessage)(e)})}if(G&&G.filesChanged>0)try{const e=await E.getRequestClient().getRequest(s)
3274
+ if("merge"===(0,v.kindProfile)(e?.type).finalize){const r=await(0,k.closeOneTask)(E.getTaskClient(),{projectId:t.projectId,requestId:s,title:String(e?.title||s),summary:i})
3275
+ r&&((0,I.clearActiveTaskCache)(),T.info("work in one piece: the request's one task closed",{requestId:s,taskId:r}))}}catch(e){T.warn("could not record the one task; completion continues as before",{requestId:s,error:(0,h.getErrorMessage)(e)})}try{const e=await E.proxyPost(`/api/projects/${t.projectId}/requests/${s}/validate-completion`,(0,w.validateCompletionBody)("tool",{sessionId:z,skipTestsReason:R,skipTests:A,headSha:B,...void 0!==J?{authoredSinceReview:J}:{},...Z?{reviewDelta:Z}:{},...Q?{intentMoves:Q}:{},...G?.files?{files:G.files}:{}}))
3276
+ V=e?.data||e}catch(e){const t=(0,h.getErrorMessage)(e)
3277
+ return T.error("Server validation failed",{requestId:s,error:t}),j({success:!1,error:"validation_request_failed"}),{content:[{type:"text",text:`Failed to validate completion: ${t}`}],isError:!0}}if(!V.canComplete){let e=`Cannot complete request ${s}: ${V.reason}\n`
3278
+ if(V.blockedByTasks&&V.blockedByTasks.length>0&&(e+="\n**Tasks that must be completed or canceled first:**\n",V.blockedByTasks.forEach((t,r)=>{e+=`${r+1}. **${t.taskId}** - ${t.title} (Status: ${t.status})\n`})),V.lifoViolation&&(e+="\n**Requests that must be re-completed first (LIFO order):**\n",V.lifoViolation.blockingRequests.forEach((t,r)=>{e+=`${r+1}. **${t.requestId}** - ${t.title} (Status: ${t.status})\n`})),Y.length>0)try{const t=await E.getRequestClient().getRequest(s)
3275
3279
  e+=`\n${function(e,t){const r=(Array.isArray(e)?e:[]).map((e,t)=>({c:e,i:t})).filter(({c:e})=>e?.id&&t.includes(String(e.id))).map(({c:e,i:t})=>{const r=Array.isArray(e.verify)?e.verify.filter(e=>"string"==typeof e):[],o=(0,n.latestRow)(e,["verify","check"]),s=o?"met"===o.verdict?"passed":"unmet"===o.verdict?"failed":o.verdict:"not run yet"
3276
3280
  return`- [${(0,n.criterionShortKey)(String(e.id),t)}] ${r.length?`check now: ${r.map(e=>`\`${e.slice(0,120)}\``).join("; ")} (newest result: ${s})`:"no check of its own"}`})
3277
- return 0===r.length?"":`Recorded all the same, as the request reads now: your account on these criteria, and their checks as they stand:\n${r.join("\n")}\nOnly the completion was refused; say so if you tell the user.`}(t?.acceptanceCriteria,V)}`}catch{}return T({success:!1,reason:"server_blocked"}),{content:[{type:"text",text:e}],isError:!0}}const Q=G.plan
3278
- if("review-submit"===Q?.action&&z&&H&&(H.reviewAcceptedSha=z),Q?.reviewChange&&J&&H&&(H.afterReview={...J,outcome:Q.reviewChange},"restarted"===Q.reviewChange&&(H.sinceReview=J)),!Q)return T({success:!1,error:"plan_missing"}),{content:[{type:"text",text:`Server validation returned no completion plan for ${s} -- the remote is likely mid-deploy. Retry complete.`}],isError:!0}
3279
- const Z="testing"===Q.action||"human-review"===Q.action||"merge-cleared"===Q.action
3280
- if(Z&&G.testsSkipped&&(P||R&&R.length>0))try{const e=S.getToolRecordClient()
3281
- e&&await e.createToolRecord({projectId:t.projectId,requestId:s,type:"tests-skipped",metadata:{...P?{reason:P}:{},...R&&R.length>0?{skipTests:R}:{},testGate:G.gates.test,timestamp:(new Date).toISOString()}})}catch(e){q.warn("Failed to persist tests-skipped tool_record",{error:(0,h.getErrorMessage)(e)})}if(Z&&j&&j.length>0&&F){const e=S.getSessionMessageClient()
3281
+ return 0===r.length?"":`Recorded all the same, as the request reads now: your account on these criteria, and their checks as they stand:\n${r.join("\n")}\nOnly the completion was refused; say so if you tell the user.`}(t?.acceptanceCriteria,Y)}`}catch{}return j({success:!1,reason:"server_blocked"}),{content:[{type:"text",text:e}],isError:!0}}const X=V.plan
3282
+ if(await async function(e,t,r,n){try{const o=await e.getRequestClient().getRequest(t),s=function(e,t){return(Array.isArray(e)?e:[]).flatMap(e=>{if(!e?.id||!(0,$.hasBaseline)(e)||e.retired||e.standing&&e.waived)return[]
3283
+ const r="string"==typeof e.command?e.command.trim():""
3284
+ if(!r)return[]
3285
+ const n=Array.isArray(e.ledger)?e.ledger:[]
3286
+ return t&&n.some(e=>"verify"===e?.source&&"string"==typeof e?.instrument&&e.instrument.startsWith("baseline")&&("met"===e.verdict||"unmet"===e.verdict)&&"string"==typeof e.commit&&!!e.commit&&(e.commit.startsWith(t)||t.startsWith(e.commit)))?[]:[{criterionId:String(e.id),command:r,baseline:e.baseline}]})}(o?.acceptanceCriteria??[],r)
3287
+ if(0===s.length)return
3288
+ const i=await fetch(`${(0,f.getActionServerBaseUrl)()}/api/baseline-measure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:t,baselines:s}),signal:AbortSignal.timeout(2e4)})
3289
+ n.info("baseline measurement started beside the sign-off check; the merge waits for it",{requestId:t,baselines:s.length,ok:i.ok})}catch(e){n.debug("baseline measurement could not start; the card says it was not measured",{requestId:t,error:(0,h.getErrorMessage)(e)})}}(E,s,B,T),"review-submit"===X?.action&&B&&G&&(G.reviewAcceptedSha=B),X?.reviewChange&&Z&&G&&(G.afterReview={...Z,outcome:X.reviewChange},"restarted"===X.reviewChange&&(G.sinceReview=Z)),!X)return j({success:!1,error:"plan_missing"}),{content:[{type:"text",text:`Server validation returned no completion plan for ${s} -- the remote is likely mid-deploy. Retry complete.`}],isError:!0}
3290
+ const ee="testing"===X.action||"human-review"===X.action||"merge-cleared"===X.action
3291
+ if(ee&&V.testsSkipped&&(R||A&&A.length>0))try{const e=E.getToolRecordClient()
3292
+ e&&await e.createToolRecord({projectId:t.projectId,requestId:s,type:"tests-skipped",metadata:{...R?{reason:R}:{},...A&&A.length>0?{skipTests:A}:{},testGate:V.gates.test,timestamp:(new Date).toISOString()}})}catch(e){T.warn("Failed to persist tests-skipped tool_record",{error:(0,h.getErrorMessage)(e)})}if(ee&&P&&P.length>0&&z){const e=E.getSessionMessageClient()
3282
3293
  if(e){let r=new Set
3283
- try{const e=await S.proxyGet(`/api/projects/${t.projectId}/session-messages`,{requestId:s,messageType:"report",limit:200}),n=Array.isArray(e)?e:e?.data??[]
3284
- r=new Set(n.filter(e=>(e?.content?.requestId??e?.content?.anchor?.id)===s).map(e=>String(e?.content?.summary??"")))}catch{}for(const t of j.slice(0,5)){const n=t.length>140?`${t.slice(0,137)}\u2026`:t
3285
- if(!r.has(n))try{await e.createReport({fromSessionId:F,status:"success",summary:n,...t.length>140?{details:t}:{},attention:"fyi",requestId:s})}catch(e){q.warn("worthKnowing note failed (completion continues)",{error:(0,h.getErrorMessage)(e)})}}q.info("worthKnowing notes processed",{count:Math.min(j.length,5),requestId:s})}}if(M&&M.length>0&&F)for(const e of M.slice(0,2))try{await S.proxyPost(`/api/projects/${t.projectId}/guidance/propose`,{body:e.body,scope:"files",pathAnchors:e.files,evidence:e.evidence,requestId:s,sessionExternalId:F}),q.info("guidance proposed at completion",{requestId:s})}catch(e){q.info("guidance at completion not proposed (completion continues)",{requestId:s,reason:(0,h.getErrorMessage)(e)})}const X=S.getRequestClient()
3286
- for(const t of Q.patches)try{const r=await X.updateRequest(s,{...t,completionSummary:i,cliOrigin:N,...B,...U})
3287
- e.refsSeen&&r?.namedRefs&&(e.refsSeen.namedRefs=r.namedRefs)}catch(e){return T({success:!1,error:"plan_patch_failed"}),{content:[{type:"text",text:`Failed to apply completion transition (${Object.keys(t).join(", ")}): ${(0,h.getErrorMessage)(e)}`}],isError:!0}}if(T({success:!0}),"review-escalated"===Q.action)return{content:[{type:"text",text:`Request ${s}: agent review hit its pass cap and was escalated for human sign-off. No further action from you; a human finalizes or sends back must_fix items.`}]}
3288
- if("review-start"===Q.action)return{content:[{type:"text",text:`Request ${s}: review started. Read-only reviewers are reading your diff. STOP here and wait: do NOT poll, sleep, or call tools to pass the time; each reviewer's report is delivered to you automatically and wakes you, so just end your turn between reports. When their reports arrive (a detailed handoff follows with the specifics), act on the findings, finish your tasks, and call complete again. After review passes, the server runs any remaining gates and messages you the exact next step (re-run tests if your fixes changed code, await human sign-off, or merge) -- wait for that and don't merge until it tells you to.`}]}
3289
- if("review-submit"===Q.action)return{content:[{type:"text",text:`Request ${s}: review submitted. The server is evaluating it and will message you the exact next step (re-run tests if your fixes changed code, await human sign-off, or merge) -- wait for that before acting. If a criterion is still unmet, the criteria reviewer takes another pass and reports back; address any must_fix and call complete again.`}]}
3290
- if("signoff-park"===Q.action)return{content:[{type:"text",text:`Request ${s}: review is complete. This request now awaits the user's sign-off in the UI -- stop here and do NOT call merge.`}]}
3291
- if("merge-cleared-after-review"===Q.action)return{content:[{type:"text",text:`Request ${s}: review is complete and all gates are clear. Call merge to finalize (do not call complete again).`}]}
3292
- if("testing"===Q.action){const e="human"===Q.testResolver?"A notification has been created asking the user to choose how to handle testing (auto-test, interactive-test, or skip). Stop here; you will receive a report when testing finishes.":"Tests are running automatically in the background. Stop here; each active test process will run and post its own report back to you."
3293
- return{content:[{type:"text",text:`Request ${s}: tests are now running. ${e}\n\n## When reports arrive\nEach test process reports separately: an individual passed report does NOT mean you are cleared.\n- When every process has passed, the server advances the remaining gates automatically: agent review may start (reviewers report their findings to you), the request may wait for sign-off from the user, or the request merges. With your account of every criterion on the record (criteriaComments in this call), the server merges it and tells you so; you call nothing. Only if you are told explicitly that you are "cleared to merge" do you call \`merge\`, with evidence for the criteria you had not accounted for.\n- **Failed**: fix the issues and call \`complete\` again.\n\nDo NOT call merge, finalize, or any other tool before that explicit instruction: stop here and wait.`}]}}if("delivery-review"===Q.action){const e=G.testsSkipped&&P?`\n\n_Tests skipped: ${P}_`:""
3294
- return{content:[{type:"text",text:`Request ${s} is handed to the DELIVERY review, which is the last gate on this project and resolves the sign-off.${e}\n\nStop here and do NOT call merge: the review finalizes the request, or comes back to you with what it found.`}]}}if("human-review"===Q.action){const e=G.testsSkipped&&P?`\n\n_Tests skipped: ${P}_`:""
3295
- return{content:[{type:"text",text:`Request ${s} submitted for human review.${e}\n\nReview is human-only for this project: the user approves the merge in the UI. Do NOT call merge yourself.`}]}}let ee,te
3296
- try{ee=await X.getRequest(s)}catch(e){te=e}const re=(0,v.kindProfile)(W??ee?.type)
3297
- if("settle"===re.finalize)return{content:[{type:"text",text:`Request ${s} is complete. A ${re.label.toLowerCase()} request has no branch, so nothing merges: it closes on its own record now. Stop here and do not call merge.`}]}
3298
- if(void 0!==te)return{content:[{type:"text",text:`Request ${s} is cleared to merge, but fetching its criteria failed: ${(0,h.getErrorMessage)(te)}. Call merge with verification evidence for each acceptance criterion.`}]}
3299
- const ne=ee?.acceptanceCriteria||[]
3300
- if(!1===G?.gates?.review?.enabled&&!1===G?.gates?.test?.enabled&&!1===G?.gates?.signoff?.enabled&&"merge"===re.finalize&&(0===ne.length||Array.isArray(A)&&A.length>0)){q.info("gates off and account recorded: merging in the same call",{requestId:s})
3301
- const e=await(0,u.handleMergeRequest)({requestId:s,verifications:[]},t,S,E,_,x)
3302
- return e?.isError?e:{...e,content:[{type:"text",text:`Request ${s}: nothing gates this project (review, tests and sign-off are off) and your account per criterion is on the record, so it merged in this call.\n\n${e.content?.[0]?.text??""}`},...e.content?.slice(1)??[]]}}const oe=Q.skippedReason?`\n\n_Skipped re-running tests: ${Q.skippedReason}._\n`:"",se=Q.noTestsAutoMerge?"\n\n_No test processes are configured for this project, so the test gate has nothing to run; this completion merges without tests._\n":""
3303
- return 0===ne.length?{content:[{type:"text",text:`Request ${s} is ready. ${oe}${se}No acceptance criteria defined: call merge directly.`}]}:{content:[{type:"text",text:`Request ${s}: all gates are clear.${oe}${se}\n\n## Next Step: Verify & Merge\n\n${(0,p.formatVerifyInstructions)(ne)}\n\nUse the merge operation with your verification evidence to merge to main.`}]}}catch(r){let n="An unexpected error occurred",o=""
3304
- r instanceof s.ZodError?(n="Validation error",o=r.errors.map(e=>`${e.path.join(".")}: ${e.message}`).join(", ")):r instanceof Error?(n=r.message,o=r.stack||""):o=String(r),q.error("Complete request failed",{error:n,details:o})
3305
- try{await(0,i.createFailureToolRecord)("complete-request",r,{error:n,details:o,requestId:e?.requestId},S.getToolRecordClient(),q,_,{requestId:e?.requestId,projectId:t.projectId,note:"Failed to complete request"})}catch{}return _.startTimer("tool_execution_time")({success:!1,error:r instanceof Error?r.name:"unknown"}),{content:[{type:"text",text:`Error: ${n}`}],isError:!0}}}
3306
- const n=t(65454),o=t(59860),s=t(11569),i=t(18616),a=t(35510),c=t(82860),l=t(95122),d=t(7161),u=t(34306),h=t(58824),p=t(65454),f=t(79414),m=t(67071),g=t(92456),y=t(80331),w=t(63580),b=t(52232),v=t(87780),k=t(45391),I=t(43451),$=new Set},32283(e,exports,t){exports.def=void 0
3294
+ try{const e=await E.proxyGet(`/api/projects/${t.projectId}/session-messages`,{requestId:s,messageType:"report",limit:200}),n=Array.isArray(e)?e:e?.data??[]
3295
+ r=new Set(n.filter(e=>(e?.content?.requestId??e?.content?.anchor?.id)===s).map(e=>String(e?.content?.summary??"")))}catch{}for(const t of P.slice(0,5)){const n=t.length>140?`${t.slice(0,137)}\u2026`:t
3296
+ if(!r.has(n))try{await e.createReport({fromSessionId:z,status:"success",summary:n,...t.length>140?{details:t}:{},attention:"fyi",requestId:s})}catch(e){T.warn("worthKnowing note failed (completion continues)",{error:(0,h.getErrorMessage)(e)})}}T.info("worthKnowing notes processed",{count:Math.min(P.length,5),requestId:s})}}if(D&&D.length>0&&z)for(const e of D.slice(0,2))try{const r=Array.isArray(e.files)&&e.files.length>0
3297
+ await E.proxyPost(`/api/projects/${t.projectId}/guidance/propose`,{body:e.body,scope:r?"files":"project",...r?{pathAnchors:e.files}:{},...e.evidence?{evidence:e.evidence}:{},...e.userSaid?{userSaid:e.userSaid}:{},requestId:s,sessionExternalId:z}),T.info("guidance proposed at completion",{requestId:s})}catch(e){T.info("guidance at completion not proposed (completion continues)",{requestId:s,reason:(0,h.getErrorMessage)(e)})}const te=E.getRequestClient()
3298
+ for(const t of X.patches)try{const r=await te.updateRequest(s,{...t,completionSummary:i,completionNotChecked:"string"==typeof N&&N.trim()?N.trim():null,cliOrigin:L,...U,...W})
3299
+ e.refsSeen&&r?.namedRefs&&(e.refsSeen.namedRefs=r.namedRefs)}catch(e){return j({success:!1,error:"plan_patch_failed"}),{content:[{type:"text",text:`Failed to apply completion transition (${Object.keys(t).join(", ")}): ${(0,h.getErrorMessage)(e)}`}],isError:!0}}if(j({success:!0}),"review-escalated"===X.action)return{content:[{type:"text",text:`Request ${s}: agent review hit its pass cap and was escalated for human sign-off. No further action from you; a human finalizes or sends back must_fix items.`}]}
3300
+ if("review-start"===X.action)return{content:[{type:"text",text:`Request ${s}: review started. Read-only reviewers are reading your diff. STOP here and wait: do NOT poll, sleep, or call tools to pass the time; each reviewer's report is delivered to you automatically and wakes you, so just end your turn between reports. When their reports arrive (a detailed handoff follows with the specifics), act on the findings, finish your tasks, and call complete again. After review passes, the server runs any remaining gates and messages you the exact next step (re-run tests if your fixes changed code, await human sign-off, or merge) -- wait for that and don't merge until it tells you to.`}]}
3301
+ if("review-submit"===X.action)return{content:[{type:"text",text:`Request ${s}: review submitted. The server is evaluating it and will message you the exact next step (re-run tests if your fixes changed code, await human sign-off, or merge) -- wait for that before acting. If a criterion is still unmet, the criteria reviewer takes another pass and reports back; address any must_fix and call complete again.`}]}
3302
+ if("signoff-park"===X.action)return{content:[{type:"text",text:`Request ${s}: review is complete. This request now awaits the user's sign-off in the UI -- stop here and do NOT call merge.`}]}
3303
+ if("merge-cleared-after-review"===X.action)return{content:[{type:"text",text:`Request ${s}: review is complete and all gates are clear. Call merge to finalize (do not call complete again).`}]}
3304
+ if("testing"===X.action){const e="human"===X.testResolver?"A notification has been created asking the user to choose how to handle testing (auto-test, interactive-test, or skip). Stop here; you will receive a report when testing finishes.":"Tests are running automatically in the background. Stop here; each active test process will run and post its own report back to you."
3305
+ return{content:[{type:"text",text:`Request ${s}: tests are now running. ${e}\n\n## When reports arrive\nEach test process reports separately: an individual passed report does NOT mean you are cleared.\n- When every process has passed, the server advances the remaining gates automatically: agent review may start (reviewers report their findings to you), the request may wait for sign-off from the user, or the request merges. With your account of every criterion on the record (criteriaComments in this call), the server merges it and tells you so; you call nothing. Only if you are told explicitly that you are "cleared to merge" do you call \`merge\`, with evidence for the criteria you had not accounted for.\n- **Failed**: fix the issues and call \`complete\` again.\n\nDo NOT call merge, finalize, or any other tool before that explicit instruction: stop here and wait.`}]}}if("delivery-review"===X.action){const e=V.testsSkipped&&R?`\n\n_Tests skipped: ${R}_`:""
3306
+ return{content:[{type:"text",text:`Request ${s} is handed to the DELIVERY review, which is the last gate on this project and resolves the sign-off.${e}\n\nStop here and do NOT call merge: the review finalizes the request, or comes back to you with what it found.`}]}}if("human-review"===X.action){const e=V.testsSkipped&&R?`\n\n_Tests skipped: ${R}_`:""
3307
+ return{content:[{type:"text",text:`Request ${s} submitted for human review.${e}\n\nReview is human-only for this project: the user approves the merge in the UI. Do NOT call merge yourself.`}]}}let re,ne
3308
+ try{re=await te.getRequest(s)}catch(e){ne=e}const oe=(0,v.kindProfile)(K??re?.type)
3309
+ if("settle"===oe.finalize)return{content:[{type:"text",text:`Request ${s} is complete. A ${oe.label.toLowerCase()} request has no branch, so nothing merges: it closes on its own record now. Stop here and do not call merge.`}]}
3310
+ if(void 0!==ne)return{content:[{type:"text",text:`Request ${s} is cleared to merge, but fetching its criteria failed: ${(0,h.getErrorMessage)(ne)}. Call merge with verification evidence for each acceptance criterion.`}]}
3311
+ const se=re?.acceptanceCriteria||[]
3312
+ if(!1===V?.gates?.review?.enabled&&!1===V?.gates?.test?.enabled&&!1===V?.gates?.signoff?.enabled&&"merge"===oe.finalize&&(0===se.length||Array.isArray(O)&&O.length>0)){T.info("gates off and account recorded: merging in the same call",{requestId:s})
3313
+ const e=await(0,u.handleMergeRequest)({requestId:s,verifications:[]},t,E,_,x,C)
3314
+ return e?.isError?e:{...e,content:[{type:"text",text:`Request ${s}: nothing gates this project (review, tests and sign-off are off) and your account per criterion is on the record, so it merged in this call.\n\n${e.content?.[0]?.text??""}`},...e.content?.slice(1)??[]]}}const ie=X.skippedReason?`\n\n_Skipped re-running tests: ${X.skippedReason}._\n`:"",ae=X.noTestsAutoMerge?"\n\n_No test processes are configured for this project, so the test gate has nothing to run; this completion merges without tests._\n":""
3315
+ return 0===se.length?{content:[{type:"text",text:`Request ${s} is ready. ${ie}${ae}No acceptance criteria defined: call merge directly.`}]}:{content:[{type:"text",text:`Request ${s}: all gates are clear.${ie}${ae}\n\n## Next Step: Verify & Merge\n\n${(0,p.formatVerifyInstructions)(se)}\n\nUse the merge operation with your verification evidence to merge to main.`}]}}catch(r){let n="An unexpected error occurred",o=""
3316
+ r instanceof s.ZodError?(n="Validation error",o=r.errors.map(e=>`${e.path.join(".")}: ${e.message}`).join(", ")):r instanceof Error?(n=r.message,o=r.stack||""):o=String(r),T.error("Complete request failed",{error:n,details:o})
3317
+ try{await(0,i.createFailureToolRecord)("complete-request",r,{error:n,details:o,requestId:e?.requestId},E.getToolRecordClient(),T,x,{requestId:e?.requestId,projectId:t.projectId,note:"Failed to complete request"})}catch{}return x.startTimer("tool_execution_time")({success:!1,error:r instanceof Error?r.name:"unknown"}),{content:[{type:"text",text:`Error: ${n}`}],isError:!0}}}
3318
+ const n=t(65454),o=t(59860),s=t(11569),i=t(18616),a=t(35510),c=t(82860),l=t(95122),d=t(7161),u=t(34306),h=t(58824),p=t(65454),f=t(79414),m=t(67071),g=t(92456),y=t(80331),w=t(63580),b=t(52232),v=t(87780),k=t(45391),I=t(43451),$=t(70715),S=new Set},32283(e,exports,t){exports.def=void 0
3307
3319
  const r=t(76183),n=t(47334)
3308
- exports.def={name:"create_request",description:"Create a request. Working on it switches you to its branch. delegate: true with draft has a background planner write the description and criteria from your title and this session's context; it stays a draft. When the request comes out of an existing record (a drive's finding, a report, a decision, another request), name that record by id in the description (\"Found by drive req000042\"), looking the id up if needed: ids are the only followable trail.",schema:r.CreateRequestSchema,annotations:{title:"Create Request",readOnlyHint:!1,destructiveHint:!1},handler:(e,t)=>(0,n.handleCreateRequest)(e,t.context,t.apiClient,t.logger,t.metrics,t.mcpServer,t.cliOrigin)}},47334(e,exports,t){exports.q=void 0,exports.handleCreateRequest=async function(e,f,m,g,y,w,b){const v=g.child({tool:"create_request"})
3320
+ exports.def={name:"create_request",description:"Create a request. Working on it switches you to its branch. delegate: true with draft has a background planner write the description and criteria from your title and this session's context; it stays a draft. When the request comes out of an existing record (a drive's finding, a report, a decision, another request), name that record by id in the description (\"Found by drive req000042\"), looking the id up if needed: ids are the only followable trail.",schema:r.CreateRequestSchema,annotations:{title:"Create Request",readOnlyHint:!1,destructiveHint:!1},handler:(e,t)=>(0,n.handleCreateRequest)(e,t.context,t.apiClient,t.logger,t.metrics,t.mcpServer,t.cliOrigin)}},47334(e,exports,t){exports.qg=void 0,exports.handleCreateRequest=async function(e,f,m,g,y,w,b){const v=g.child({tool:"create_request"})
3309
3321
  v.info("Creating new request",{args:e})
3310
3322
  const k=y.startTimer("tool_handler_duration")
3311
3323
  try{const g=function(e){try{return e}catch(e){if(e instanceof l.ZodError&&e.errors.length>0)throw new i.ValidationError(e.errors[0].message)
3312
- throw new i.ValidationError(`Invalid input: ${(0,d.getErrorMessage)(e)}`)}}(e)
3324
+ throw new i.ValidationError(`Invalid input: ${(0,d.getErrorMessage)(e)}`)}}(e),I=function(e){return Array.isArray(e.waitsOn)&&0!==e.waitsOn.length?"string"==typeof e.waitReason&&e.waitReason.trim()?null:"Not created: waitsOn needs waitReason, what this request needs from the one it waits for, in a sentence the user reads. If it needs nothing from it, pass startsNow: true instead.":null}(g)
3325
+ if(I)throw new i.ValidationError(I)
3313
3326
  y.incrementCounter("create_request_attempts",1,{type:g.type,criteriaCounts:g.acceptanceCriteria?.length??0})
3314
- const I=f.projectId
3315
- if(!I)throw new i.ValidationError("Project ID is required for creating requests.")
3327
+ const $=f.projectId
3328
+ if(!$)throw new i.ValidationError("Project ID is required for creating requests.")
3316
3329
  if(!0===e?.quotesMessage){const t=await(0,s.userTextOfCall)(f.mainBasePath,b,"string"==typeof e?.userSaid?e.userSaid:void 0)
3317
3330
  if(!t)throw new i.ValidationError("quotesMessage: the user's message this call answers could not be read, so nothing was filed. Write their words into the description yourself and call again without quotesMessage.")
3318
3331
  const r=(g.description??"").trim()
3319
- g.description=`${exports.q}\n\n${t}${r?`\n\n${r}`:""}`}if(!g.draft){if(!g.description||!g.description.trim())throw new i.ValidationError("Description is required. To capture a request to author later, pass draft: true.")
3332
+ g.description=`${exports.qg}\n\n${t}${r?`\n\n${r}`:""}`}if(!g.draft){if(!g.description||!g.description.trim())throw new i.ValidationError("Description is required. To capture a request to author later, pass draft: true.")
3320
3333
  if(!g.acceptanceCriteria||0===g.acceptanceCriteria.length)throw new i.ValidationError("At least one acceptance criterion is required. To capture a request to author later, pass draft: true.")
3321
- if(!g.areas||0===g.areas.length)throw new i.ValidationError('At least one work area is required (areas: ["parent/child"]). List existing areas with request_operations { operation: "list-areas" } and pick 1-3; add a new lowercase-kebab name (nested under an existing parent when possible) only when nothing fits. To capture a request to author later, pass draft: true.')}m.setProjectId(I)
3334
+ if(!g.areas||0===g.areas.length)throw new i.ValidationError('At least one work area is required (areas: ["parent/child"]). List existing areas with request_operations { operation: "list-areas" } and pick 1-3; add a new lowercase-kebab name (nested under an existing parent when possible) only when nothing fits. To capture a request to author later, pass draft: true.')}m.setProjectId($)
3322
3335
  {const t=(0,n.gateCriteriaIn)(g.acceptanceCriteria)
3323
3336
  if(t.length>0){const r="string"==typeof e?.userSaid?e.userSaid:""
3324
- if(!r||!await(0,o.userSaidOnRequest)(m,I,"",r,{anywhere:!0}))return v.info("create refused: a gate criterion without the user asking for one",{count:t.length}),{content:[{type:"text",text:(0,n.gateRefusal)(t,"created",!!r)}],isError:!0}}}const $=m.getRequestClient()
3325
- let S=b,E=null
3337
+ if(!r||!await(0,o.userSaidOnRequest)(m,$,"",r,{anywhere:!0}))return v.info("create refused: a gate criterion without the user asking for one",{count:t.length}),{content:[{type:"text",text:(0,n.gateRefusal)(t,"created",!!r)}],isError:!0}}}const S=m.getRequestClient()
3338
+ let E=b,_=null
3326
3339
  if(b?.sessionId)try{const e=m.getCLISessionClient()
3327
3340
  if(e){const t=await e.getByExternalId(b.sessionId)
3328
- E=t?.agentType??null,"planner"!==t?.agentType&&"auto-planner"!==t?.agentType||(S=void 0,v.info("Skipping cliOrigin for planner-created request",{agentType:t.agentType}))}}catch{}E||(E=await p.sessionIdentity.getAgentTypeFor(b?.sessionId||f.currentSessionId))
3329
- const _=!g.draft&&("planner"===E||"auto-planner"===E)
3330
- _&&(g.draft=!0,v.info("Planner-created request filed as a draft",{agentType:E}))
3331
- const x=g.draft?"draft":"open",C=g.scheduleDocumentId||g.questDocumentId
3332
- let q=!1
3333
- g.planDocumentId&&C&&g.planDocumentId===C&&(g.planDocumentId=void 0,q=!0)
3334
- let T=g.planDocumentId
3335
- if(!T&&b?.sessionId)try{const e=await(0,u.getActiveSessionPlanId)(m,I,b.sessionId,v)
3336
- e&&await m.getDocumentClient().getDocument(e)&&(T=e,v.info("Auto-filled planDocumentId from session-plan association",{sessionId:b.sessionId,planDocumentId:e}))}catch(e){v.warn("planDocumentId auto-fill lookup failed (request created without plan link)",{error:(0,d.getErrorMessage)(e)})}T&&C&&T===C&&(T=void 0,q=!0)
3337
- const j=await(0,h.exchangeKeyOfCall)(f.mainBasePath,b,"string"==typeof e?.userSaid?e.userSaid:void 0),P=j?await(0,h.exchangeKeysWithCall)(f.mainBasePath,b):[],R={title:g.title,description:g.description||"",type:g.type,acceptanceCriteria:g.acceptanceCriteria||[],status:x,...T&&{planDocumentId:T},...C&&{scheduleDocumentId:C},...g.areas&&g.areas.length>0&&{areas:g.areas},...g.waitsOn&&g.waitsOn.length>0&&{waitsOn:g.waitsOn},...!0===g.startsNow&&{startsNow:!0},..."string"==typeof g.replaces&&g.replaces&&{replaces:g.replaces},...Array.isArray(g.asked)&&g.asked.length>0&&{asked:g.asked},...Array.isArray(g.userChoices)&&g.userChoices.length>0&&{userChoices:g.userChoices},..."string"==typeof g.process&&g.process.trim()&&{process:g.process.trim()},...void 0!==j&&{exchangeKey:j},...P.length>0&&{exchangeKeysWith:P},...S&&{cliOrigin:S},...b?.sessionId&&{creatorSessionId:b.sessionId},...g.follows&&"new"!==g.follows&&{originRequestId:String(g.follows).replace(/^round:/,"")},..."string"==typeof g.follows&&g.follows.startsWith("round:")&&{roundOf:g.follows.slice(6)}}
3338
- v.info("Creating request via request client",{projectId:I,title:g.title,type:g.type,criteriaCount:g.acceptanceCriteria?.length??0})
3339
- const A=await $.createRequest(R)
3340
- v.debug("Create request response structure",{type:typeof A,isArray:Array.isArray(A),hasData:null!=A,properties:A?Object.keys(A):[],dataPreview:A?JSON.stringify(A).substring(0,200)+"...":"null"})
3341
- const O=(0,c.extractDataFromResponse)(A,{logger:v,operationName:"createRequest",throwOnNoData:!0}),M="data"in O?O.data:O,D=!g.draft&&"draft"===M.status
3342
- let F,N={created:!1}
3343
- if(g.draft||D)v.info("Draft request - no branch created until registered",{requestId:M.id})
3344
- else if("none"===(0,r.kindProfile)(g.type).branch)v.info("Drive request - no branch created (drives own no branch)",{requestId:M.id})
3345
- else if(w?.workspaceManager)try{await w.workspaceManager.initializeRequest(M.id,M.title),N={created:!0,branchName:`requests/${M.id}`,message:"Branch created successfully"},v.info("Request branch initialized successfully",{requestId:M.id,branchName:N.branchName,title:M.title})}catch(e){v.warn("Failed to initialize request branch, will retry on first operation",{requestId:M.id,error:(0,d.getErrorMessage)(e)})}else v.debug("No workspace manager available, branch creation deferred",{requestId:M.id})
3346
- v.info("Request created successfully",{requestId:M.id,title:M.title,branchCreated:N.created,branchName:N.branchName})
3341
+ _=t?.agentType??null,"planner"!==t?.agentType&&"auto-planner"!==t?.agentType||(E=void 0,v.info("Skipping cliOrigin for planner-created request",{agentType:t.agentType}))}}catch{}_||(_=await p.sessionIdentity.getAgentTypeFor(b?.sessionId||f.currentSessionId))
3342
+ const x=!g.draft&&("planner"===_||"auto-planner"===_)
3343
+ x&&(g.draft=!0,v.info("Planner-created request filed as a draft",{agentType:_}))
3344
+ const C=g.draft?"draft":"open",q=g.scheduleDocumentId||g.questDocumentId
3345
+ let T=!1
3346
+ g.planDocumentId&&q&&g.planDocumentId===q&&(g.planDocumentId=void 0,T=!0)
3347
+ let j=g.planDocumentId
3348
+ if(!j&&b?.sessionId)try{const e=await(0,u.getActiveSessionPlanId)(m,$,b.sessionId,v)
3349
+ e&&await m.getDocumentClient().getDocument(e)&&(j=e,v.info("Auto-filled planDocumentId from session-plan association",{sessionId:b.sessionId,planDocumentId:e}))}catch(e){v.warn("planDocumentId auto-fill lookup failed (request created without plan link)",{error:(0,d.getErrorMessage)(e)})}j&&q&&j===q&&(j=void 0,T=!0)
3350
+ const P=await(0,h.exchangeKeyOfCall)(f.mainBasePath,b,"string"==typeof e?.userSaid?e.userSaid:void 0),R=P?await(0,h.exchangeKeysWithCall)(f.mainBasePath,b):[],A={title:g.title,description:g.description||"",type:g.type,acceptanceCriteria:g.acceptanceCriteria||[],status:C,...j&&{planDocumentId:j},...q&&{scheduleDocumentId:q},...g.areas&&g.areas.length>0&&{areas:g.areas},...g.waitsOn&&g.waitsOn.length>0&&{waitsOn:g.waitsOn,waitReason:String(g.waitReason).trim().slice(0,300)},...!0===g.startsNow&&{startsNow:!0},..."string"==typeof g.replaces&&g.replaces&&{replaces:g.replaces},...Array.isArray(g.asked)&&g.asked.length>0&&{asked:g.asked},...Array.isArray(g.userChoices)&&g.userChoices.length>0&&{userChoices:g.userChoices},..."string"==typeof g.process&&g.process.trim()&&{process:g.process.trim()},...void 0!==P&&{exchangeKey:P},...R.length>0&&{exchangeKeysWith:R},...E&&{cliOrigin:E},...b?.sessionId&&{creatorSessionId:b.sessionId},...g.follows&&"new"!==g.follows&&{originRequestId:String(g.follows).replace(/^round:/,"")},..."string"==typeof g.follows&&g.follows.startsWith("round:")&&{roundOf:g.follows.slice(6)}}
3351
+ v.info("Creating request via request client",{projectId:$,title:g.title,type:g.type,criteriaCount:g.acceptanceCriteria?.length??0})
3352
+ const O=await S.createRequest(A)
3353
+ v.debug("Create request response structure",{type:typeof O,isArray:Array.isArray(O),hasData:null!=O,properties:O?Object.keys(O):[],dataPreview:O?JSON.stringify(O).substring(0,200)+"...":"null"})
3354
+ const M=(0,c.extractDataFromResponse)(O,{logger:v,operationName:"createRequest",throwOnNoData:!0}),D="data"in M?M.data:M,F=!g.draft&&"draft"===D.status
3355
+ let N,z={created:!1}
3356
+ if(g.draft||F)v.info("Draft request - no branch created until registered",{requestId:D.id})
3357
+ else if("none"===(0,r.kindProfile)(g.type).branch)v.info("Drive request - no branch created (drives own no branch)",{requestId:D.id})
3358
+ else if(w?.workspaceManager)try{await w.workspaceManager.initializeRequest(D.id,D.title),z={created:!0,branchName:`requests/${D.id}`,message:"Branch created successfully"},v.info("Request branch initialized successfully",{requestId:D.id,branchName:z.branchName,title:D.title})}catch(e){v.warn("Failed to initialize request branch, will retry on first operation",{requestId:D.id,error:(0,d.getErrorMessage)(e)})}else v.debug("No workspace manager available, branch creation deferred",{requestId:D.id})
3359
+ v.info("Request created successfully",{requestId:D.id,title:D.title,branchCreated:z.created,branchName:z.branchName})
3347
3360
  try{const e=m.getToolRecordClient()
3348
- if(e){const t=await e.createToolRecord({requestId:M.id,projectId:I,type:"create-request",metadata:{status:"completed",timestamp:(new Date).toISOString(),requestType:M.type,requestTitle:M.title,requestDescription:M.description,criteriaCount:M.acceptanceCriteria.length,branchCreated:N.created,branchName:N.created?N.branchName:null},note:`Filed "${M.title}" (${M.type})${N.created?`, on its own branch ${N.branchName}`:"; its branch is made at its first file change"}`})
3349
- F=t?.id}}catch(e){v.warn("Failed to create tool record for request creation",{error:(0,d.getErrorMessage)(e),requestId:M.id})}if(k({success:!0,type:g.type,hasProjectId:!0}),v.info("Request created successfully",{requestId:M.id,title:M.title,type:M.type,projectId:I}),g.draft&&g.delegate)try{const{getActionServerBaseUrl:e}=t(79414)
3350
- await fetch(`${e()}/api/flesh-out-request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:M.id,sourceSessionId:b?.sessionId}),signal:AbortSignal.timeout(8e3)}),v.info("Delegated draft flesh-out to a request-shaping planner",{requestId:M.id})}catch(e){v.warn("Failed to delegate draft flesh-out (draft still created)",{requestId:M.id,error:(0,d.getErrorMessage)(e)})}const z=M.localId||M.id,L=D?`Created Request ${z}, held at the intake gate: this workflow reviews agent-created work before it starts. It is a draft for now; work begins if the intake resolver (the user or an independent reviewer) approves it. No action needed from you.`:_?`Created draft Request ${z}. A planner's requests are drafts: nothing starts until the user picks Start Building on your hand-off (session_message_operations offer-handoff with every request id you filed), which starts each one in the order its waitsOn gives.`:g.draft?g.delegate?`Created draft Request ${z} and handed it to a background planner to flesh out. It starts when the user presses Start.`:`Created draft Request ${z} (private; no branch, no work started). It starts when the user presses Start.`:`Created Request ${z}`,B=T&&!g.planDocumentId?" (linked to your session's plan)":q?" (note: the schedule document is the request's one guiding link; a duplicate plan link to the same doc was dropped)":"",H=M.asked,U=(H?.requested??[]).filter(e=>!(H?.linked??[]).includes(e)),G=H?`\n\n${H.linked?.length?`Put on ${z}: ${H.linked.join(", ")}. Its worker is told they are asked, and the user's answer reaches it.`:""}${U.length?` Not put on it (not your open question to the user, or on another request): ${U.join(", ")}.`:""}`:"",W=M.replaces,V=W?.requestId?`\n\nIt replaces ${W.requestId} (canceled). ${W.nowWaiting&&W.nowWaiting.length?`${W.nowWaiting.join(", ")} waited on ${W.requestId} and now ${1===W.nowWaiting.length?"waits":"wait"} for ${z} instead.`:`Nothing was waiting on ${W.requestId}.`}`:"",K=M.planStep,Y=K?.plan?`\n\nIt is filed as a DRAFT, like the other steps of ${K.plan}, which nobody has started yet: it starts with them when the user presses Start Building${K.startBuildingOffered?` (the card is on their timeline now, ${K.startBuildingOffered})`:""}. Do not start it yourself.`:""
3351
- return{content:[{type:"text",text:L+B+(M.process?.name?`\n\nIt follows the process "${M.process.name}": its criteria are on the request, listed first, and every request that follows the process carries them.`:M.processHint?`\n\n${M.processHint}`:"")+V+G+Y}],...(0,a.alchemyMeta)({kind:"create-request",toolRecordId:F})}}catch(t){if(v.error("Failed to create request",{error:t instanceof Error?t.stack:String(t),args:e}),f.projectId)try{if(t instanceof Error&&(t.message.includes("Project is disabled")||t.message.includes("Project cannot accept new requests")||t.message.includes("disabled due to tier limits")))v.info("Skipping tool record creation for disabled project error",{projectId:f.projectId,error:t.message})
3361
+ if(e){const t=await e.createToolRecord({requestId:D.id,projectId:$,type:"create-request",metadata:{status:"completed",timestamp:(new Date).toISOString(),requestType:D.type,requestTitle:D.title,requestDescription:D.description,criteriaCount:D.acceptanceCriteria.length,branchCreated:z.created,branchName:z.created?z.branchName:null},note:`Filed "${D.title}" (${D.type})${z.created?`, on its own branch ${z.branchName}`:"; its branch is made at its first file change"}`})
3362
+ N=t?.id}}catch(e){v.warn("Failed to create tool record for request creation",{error:(0,d.getErrorMessage)(e),requestId:D.id})}if(k({success:!0,type:g.type,hasProjectId:!0}),v.info("Request created successfully",{requestId:D.id,title:D.title,type:D.type,projectId:$}),g.draft&&g.delegate)try{const{getActionServerBaseUrl:e}=t(79414)
3363
+ await fetch(`${e()}/api/flesh-out-request`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:D.id,sourceSessionId:b?.sessionId}),signal:AbortSignal.timeout(8e3)}),v.info("Delegated draft flesh-out to a request-shaping planner",{requestId:D.id})}catch(e){v.warn("Failed to delegate draft flesh-out (draft still created)",{requestId:D.id,error:(0,d.getErrorMessage)(e)})}const L=D.localId||D.id,B=F?`Created Request ${L}, held at the intake gate: this workflow reviews agent-created work before it starts. It is a draft for now; work begins if the intake resolver (the user or an independent reviewer) approves it. No action needed from you.`:x?`Created draft Request ${L}. A planner's requests are drafts: nothing starts until the user picks Start Building on your hand-off (session_message_operations offer-handoff with every request id you filed), which starts each one in the order its waitsOn gives.`:g.draft?g.delegate?`Created draft Request ${L} and handed it to a background planner to flesh out. It starts when the user presses Start.`:`Created draft Request ${L} (private; no branch, no work started). It starts when the user presses Start.`:`Created Request ${L}`,H=j&&!g.planDocumentId?" (linked to your session's plan)":T?" (note: the schedule document is the request's one guiding link; a duplicate plan link to the same doc was dropped)":"",U=D.asked,G=(U?.requested??[]).filter(e=>!(U?.linked??[]).includes(e)),W=U?`\n\n${U.linked?.length?`Put on ${L}: ${U.linked.join(", ")}. Its worker is told they are asked, and the user's answer reaches it.`:""}${G.length?` Not put on it (not your open question to the user, or on another request): ${G.join(", ")}.`:""}`:"",V=D.replaces,K=V?.requestId?`\n\nIt replaces ${V.requestId} (canceled). ${V.nowWaiting&&V.nowWaiting.length?`${V.nowWaiting.join(", ")} waited on ${V.requestId} and now ${1===V.nowWaiting.length?"waits":"wait"} for ${L} instead.`:`Nothing was waiting on ${V.requestId}.`}`:"",Y=D.planStep,J=Y?.plan?`\n\nIt is filed as a DRAFT, like the other steps of ${Y.plan}, which nobody has started yet: it starts with them when the user presses Start Building${Y.startBuildingOffered?` (the card is on their timeline now, ${Y.startBuildingOffered})`:""}. Do not start it yourself.`:""
3364
+ return{content:[{type:"text",text:B+H+(D.process?.name?`\n\nIt follows the process "${D.process.name}": its criteria are on the request, listed first, and every request that follows the process carries them.`:D.processHint?`\n\n${D.processHint}`:"")+K+W+J}],...(0,a.alchemyMeta)({kind:"create-request",toolRecordId:N})}}catch(t){if(v.error("Failed to create request",{error:t instanceof Error?t.stack:String(t),args:e}),f.projectId)try{if(t instanceof Error&&(t.message.includes("Project is disabled")||t.message.includes("Project cannot accept new requests")||t.message.includes("disabled due to tier limits")))v.info("Skipping tool record creation for disabled project error",{projectId:f.projectId,error:t.message})
3352
3365
  else{const r=m.getToolRecordClient()
3353
3366
  r&&await r.createToolRecord({projectId:f.projectId,type:"create-request",metadata:{status:"failed",timestamp:(new Date).toISOString(),requestTitle:e.title,requestType:e.type,requestDescription:e.description?.substring(0,100)+(e.description?.length>100?"...":""),criteriaCount:e.acceptanceCriteria?e.acceptanceCriteria.length:0,branchCreated:!1,branchName:null,error:(0,d.getErrorMessage)(t),errorDetails:t instanceof Error?t.stack:String(t)},note:`Failed to create request: ${e.title}`})}}catch(e){v.error("Failed to create failure record for request creation",{error:e instanceof Error?e.message:String(e)})}if(k({success:!1,error:t instanceof Error?t.name:"unknown"}),t instanceof l.ZodError&&t.errors.length>0){const e=t.errors[0]
3354
3367
  let r=e.message
3355
3368
  return e.path.includes("acceptanceCriteria")&&(r=`Acceptance criteria: ${r}. Please provide a list of criteria descriptions.`),{content:[{type:"text",text:`Error: ${r}`}],isError:!0}}let r=(0,d.getErrorMessage)(t),n=/Not created: /.test(r)?"":"Unable to create request. Please check your input and try again."
3356
3369
  return(r.includes("Project cannot accept new requests")||r.includes("Project is inactive due to tier limits"))&&(n="This project is currently inactive due to tier limits. Only your oldest projects can accept new requests. Please use an active project or upgrade your tier for more simultaneous projects."),{content:[{type:"text",text:n?`Error: ${r}\n\n${n}`:r}],isError:!0}}}
3357
3370
  const r=t(87780),n=t(57115),o=t(29729),s=t(62032)
3358
- exports.q="Your words:"
3371
+ exports.qg="Your words:"
3359
3372
  const i=t(59860),a=t(82272),c=t(82960),l=t(11569),d=t(58824),u=t(53089),h=t(62032),p=t(6688)},44558(e,exports,t){exports.readEndedBranch=async function(e,t,r){if(null===await n(e,["rev-parse","--verify","--quiet",`refs/heads/${t}`]))return{branch:t,exists:!1,commits:[],count:0}
3360
3373
  const o=Number((await n(e,["rev-list","--count",`refs/heads/${r}..refs/heads/${t}`])??"0").trim())||0
3361
3374
  return{branch:t,exists:!0,commits:(await n(e,["log","--format=%h %s","-5",`refs/heads/${r}..refs/heads/${t}`])??"").split("\n").map(e=>e.trim()).filter(Boolean),count:o}},exports.endedBranchLine=function(e,t){if(!e.exists)return`Branch: ${e.branch} is gone; nothing of this request is on ${t} unless its outcome says it merged.`
@@ -3481,75 +3494,75 @@ n.push(i.length>0?`- PROVIDER CAP: ${t.providerID} is refusing turns${o}. Stoppe
3481
3494
  const r=t(51725),n=t(87780),o=/^\s*(?:Error:|\u26d4|\u274c|Not filed|Not started|Not kept|Cannot |STOP:)/},34306(e,exports,t){function r(e,t){const r=`STOP: Cannot merge request ${e}: it is awaiting human action`
3482
3495
  if(null===t)return`${r}. Before you tell the user anything about it, read which card holds it (request_operations get-info); do not assume it is a sign-off.`
3483
3496
  if(0===t.length)return`${r}, but no card is open for the user on it yet. Do not tell the user a sign-off is waiting: there is none. Stop here; you will be told when it moves.`
3484
- const n=t.map(e=>`${e.code} (${v[e.kind]??e.kind})`).join(", ")
3485
- return t.some(e=>"signoff-park"===e.kind)?`${r}: the user's sign-off card is open: ${n}. The user finalizes it from there.`:`${r}: the user's open card is ${n}. That card, not a sign-off, decides what happens next; if you report, say exactly that.`}exports.handleMergeRequest=async function(e,v,k,I,$){const S=I.child({tool:"merge_request"}),E=$.startTimer("tool_execution_time"),{requestId:_,verifications:x}=e,C=v.basePath
3486
- let q=!1,T=!1
3487
- try{if(!_)throw(0,i.createValidationError)("requestId is required")
3488
- S.info("Starting merge request",{requestId:_,verificationCount:x.length})
3489
- const e=k.getRequestClient(),l=await e.getRequest(_),h=(0,w.kindProfile)(l?.type)
3490
- if("none"===h.branch)return E({success:!0,reason:"no_branch_kind"}),{content:[{type:"text",text:`Nothing to merge for ${_}: a ${h.label.toLowerCase()} request has no branch. It closes on its own record when you complete it with request_operations complete.`}]}
3491
- if("running"===l?.testStatus||"choice-pending"===l?.testStatus){E({success:!1,reason:"running"===l.testStatus?"testing_in_progress":"testing_choice_pending"})
3497
+ const n=t.map(e=>`${e.code} (${k[e.kind]??e.kind})`).join(", ")
3498
+ return t.some(e=>"signoff-park"===e.kind)?`${r}: the user's sign-off card is open: ${n}. The user finalizes it from there.`:`${r}: the user's open card is ${n}. That card, not a sign-off, decides what happens next; if you report, say exactly that.`}exports.handleMergeRequest=async function(e,k,I,$,S){const E=$.child({tool:"merge_request"}),_=S.startTimer("tool_execution_time"),{requestId:x,verifications:C}=e,q=k.basePath
3499
+ let T=!1,j=!1
3500
+ try{if(!x)throw(0,i.createValidationError)("requestId is required")
3501
+ E.info("Starting merge request",{requestId:x,verificationCount:C.length})
3502
+ const e=I.getRequestClient(),l=await e.getRequest(x),h=(0,b.kindProfile)(l?.type)
3503
+ if("none"===h.branch)return _({success:!0,reason:"no_branch_kind"}),{content:[{type:"text",text:`Nothing to merge for ${x}: a ${h.label.toLowerCase()} request has no branch. It closes on its own record when you complete it with request_operations complete.`}]}
3504
+ if("running"===l?.testStatus||"choice-pending"===l?.testStatus){_({success:!1,reason:"running"===l.testStatus?"testing_in_progress":"testing_choice_pending"})
3492
3505
  const e="running"===l.testStatus?"tests are still running. Wait for the test report":"the user has not made the testing choice yet. Wait for their decision"
3493
- return{content:[{type:"text",text:`STOP: Cannot merge request ${_}: ${e}; you'll be cleared to merge when the Test gate resolves.`}],isError:!0}}if("ready_for_review"===l?.status){E({success:!1,reason:"awaiting_human"})
3506
+ return{content:[{type:"text",text:`STOP: Cannot merge request ${x}: ${e}; you'll be cleared to merge when the Test gate resolves.`}],isError:!0}}if("ready_for_review"===l?.status){_({success:!1,reason:"awaiting_human"})
3494
3507
  let e=null
3495
- try{const t=await k.proxyGet(`/api/projects/${v.projectId}/requests/${_}/wait-state`),r=t?.data??t??{}
3496
- Array.isArray(r.userParks)&&(e=r.userParks.filter(e=>"string"==typeof e?.code))}catch{}return{content:[{type:"text",text:r(_,e)}],isError:!0}}if("escalated"===l?.reviewStatus)return E({success:!1,reason:"review_escalated"}),{content:[{type:"text",text:`STOP: Cannot merge request ${_}: agent review hit its pass cap and was escalated to a human. A human either finalizes it ("Merge anyway") or sends back must_fix items; this tool cannot override that. If you were resolving merge conflicts: finish resolving, commit, and report: do not merge.`}],isError:!0}
3497
- if(x.length>0)try{const e=(0,g.buildCriteriaKeyMap)(l?.acceptanceCriteria??[]),t=[],r=[]
3498
- for(const n of x){const o=e.get(n.key)
3499
- o?t.push({criterionId:o.id,evidence:n.evidence}):r.push(n.key)}r.length>0&&S.warn("merge_request: verification keys did not match any criterion (dropped)",{requestId:_,unmatched:r}),t.length>0&&(await k.proxyPost(`/api/projects/${v.projectId}/requests/${_}/verify-criteria`,{verifications:t,dimension:"coder"}),S.info("Criteria verified",{requestId:_,count:t.length}))}catch(e){const t=(0,d.getErrorMessage)(e)
3500
- S.warn("Criteria verification failed, continuing with merge",{requestId:_,error:t})}let I,$,j
3501
- try{const e=await k.proxyPost(`/api/projects/${v.projectId}/requests/${_}/validate-completion`,(0,b.validateCompletionBody)("merge"))
3502
- I=e?.data||e}catch(e){const t=(0,d.getErrorMessage)(e)
3503
- return E({success:!1,error:"validation_failed"}),{content:[{type:"text",text:`Failed to validate merge: ${t}`}],isError:!0}}if(!I.canComplete){let e=`Cannot merge request ${_}: ${I.reason}\n`
3504
- return I.blockedByTasks?.length&&(e+="\n**Tasks that must be completed first:**\n",I.blockedByTasks.forEach((t,r)=>{e+=`${r+1}. **${t.taskId}** - ${t.title} (${t.status})\n`})),E({success:!1,reason:"server_blocked"}),{content:[{type:"text",text:e}],isError:!0}}if(!v.workspaceManager)throw new Error("WorkspaceManager not available")
3505
- try{const e=v.workspaceManager.getCurrentContext(v.currentSessionId)?.basePath||v.basePath,t=v.git??(0,o.simpleGit)({baseDir:e,binary:v.gitBinary}),r=await async function(e){for(const t of["main","master"])try{return await e.raw(["rev-parse","--verify",t]),t}catch{}return"main"}(t)
3506
- $=(await t.raw(["merge-base",r,`requests/${_}`])).trim()||void 0
3507
- const n=await(0,u.countCommitsAhead)(t,r,`requests/${_}`),s=(0,u.emptyBranchBlockMessage)(n,_,r)
3508
- if(s)return E({success:!1,reason:"empty_branch"}),{content:[{type:"text",text:s}],isError:!0}
3509
- if(await(0,u.branchAddsNoContent)(t,r,`requests/${_}`))return E({success:!1,reason:"identical_tree"}),{content:[{type:"text",text:(0,u.identicalTreeBlockMessage)(_,r)}],isError:!0}}catch(e){S.warn("Could not compute merge-base / ahead count; proceeding (the merge path surfaces a real branch error)",{requestId:_,error:(0,d.getErrorMessage)(e)})}let P="workspace-manager"
3510
- const R=await e.getRequest(_),A=R?.title||`Request ${_}`
3511
- let O="main"
3512
- try{v.git&&(await v.git.branch(),O=await(0,y.resolveDefaultBranch)(v.mainBasePath,v.gitBinary))}catch{}const M=v.git?await(0,a.findCommittedMarkers)(v.git,`requests/${_}`):{files:[],determined:!1}
3513
- if(!M.determined)return E({success:!1,reason:"marker_check_unavailable"}),{content:[{type:"text",text:`Cannot merge ${_}: the conflict-marker check could not run, so it is unknown whether unresolved markers remain on requests/${_}. Nothing was merged.`}],isError:!0}
3514
- if(M.files.length>0)return E({success:!1,reason:"unresolved_markers"}),{content:[{type:"text",text:`Cannot merge ${_}: committed conflict markers remain in ${M.files.join(", ")}. Resolve every <<<<<<< block with your file tools, verify, then merge again.`}],isError:!0}
3515
- let D
3516
- v.mainBasePath&&await(0,c.foldAtDoor)({repoDir:v.mainBasePath,branch:`requests/${_}`,defaultBranch:O,requestId:_,door:"merge",gitBinary:v.gitBinary,postRecord:e=>k.proxyPost(`/api/projects/${v.projectId}/tool-records`,e),log:S})
3517
- let F=null
3518
- {const e=await(0,p.runMergeQueueGate)({projectPath:C,requestId:_,branchName:`requests/${_}`,defaultBranch:O,requestTitle:R?.title,criteria:R?.acceptanceCriteria??R?.acceptance_criteria,testGateOff:!1===R?.gates?.test?.enabled,source:"merge_request",gitBinary:v.gitBinary,logger:S,fetchRequestRuns:async()=>{const e=await k.proxyGet(`/api/projects/${v.projectId}/requests/${_}/test-runs`),t=e?.data??e??[]
3519
- return Array.isArray(t)?t:[]},fetchActiveProcesses:async()=>{const e=await k.proxyGet(`/api/projects/${v.projectId}/test-processes/active`),t=e?.data??e??[]
3520
- return(Array.isArray(t)?t:[t]).filter(Boolean)},evaluatePromises:async({baseSha:e,headSha:r})=>{const{getActionServerBaseUrl:n}=await Promise.resolve().then(()=>t(79414)),o=await fetch(`${n()}/api/promise-checks-at-merge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:_,baseSha:e,headSha:r}),signal:AbortSignal.timeout(6e5)})
3508
+ try{const t=await I.proxyGet(`/api/projects/${k.projectId}/requests/${x}/wait-state`),r=t?.data??t??{}
3509
+ Array.isArray(r.userParks)&&(e=r.userParks.filter(e=>"string"==typeof e?.code))}catch{}return{content:[{type:"text",text:r(x,e)}],isError:!0}}if("escalated"===l?.reviewStatus)return _({success:!1,reason:"review_escalated"}),{content:[{type:"text",text:`STOP: Cannot merge request ${x}: agent review hit its pass cap and was escalated to a human. A human either finalizes it ("Merge anyway") or sends back must_fix items; this tool cannot override that. If you were resolving merge conflicts: finish resolving, commit, and report: do not merge.`}],isError:!0}
3510
+ if(C.length>0)try{const e=(0,g.buildCriteriaKeyMap)(l?.acceptanceCriteria??[]),t=[],r=[]
3511
+ for(const n of C){const o=e.get(n.key)
3512
+ o?t.push({criterionId:o.id,evidence:n.evidence}):r.push(n.key)}r.length>0&&E.warn("merge_request: verification keys did not match any criterion (dropped)",{requestId:x,unmatched:r}),t.length>0&&(await I.proxyPost(`/api/projects/${k.projectId}/requests/${x}/verify-criteria`,{verifications:t,dimension:"coder"}),E.info("Criteria verified",{requestId:x,count:t.length}))}catch(e){const t=(0,d.getErrorMessage)(e)
3513
+ E.warn("Criteria verification failed, continuing with merge",{requestId:x,error:t})}let $,S,P
3514
+ try{const e=await I.proxyPost(`/api/projects/${k.projectId}/requests/${x}/validate-completion`,(0,v.validateCompletionBody)("merge"))
3515
+ $=e?.data||e}catch(e){const t=(0,d.getErrorMessage)(e)
3516
+ return _({success:!1,error:"validation_failed"}),{content:[{type:"text",text:`Failed to validate merge: ${t}`}],isError:!0}}if(!$.canComplete){let e=`Cannot merge request ${x}: ${$.reason}\n`
3517
+ return $.blockedByTasks?.length&&(e+="\n**Tasks that must be completed first:**\n",$.blockedByTasks.forEach((t,r)=>{e+=`${r+1}. **${t.taskId}** - ${t.title} (${t.status})\n`})),_({success:!1,reason:"server_blocked"}),{content:[{type:"text",text:e}],isError:!0}}if(!k.workspaceManager)throw new Error("WorkspaceManager not available")
3518
+ try{const e=k.workspaceManager.getCurrentContext(k.currentSessionId)?.basePath||k.basePath,t=k.git??(0,o.simpleGit)({baseDir:e,binary:k.gitBinary}),r=await async function(e){for(const t of["main","master"])try{return await e.raw(["rev-parse","--verify",t]),t}catch{}return"main"}(t)
3519
+ S=(await t.raw(["merge-base",r,`requests/${x}`])).trim()||void 0
3520
+ const n=await(0,u.countCommitsAhead)(t,r,`requests/${x}`),s=(0,u.emptyBranchBlockMessage)(n,x,r)
3521
+ if(s)return _({success:!1,reason:"empty_branch"}),{content:[{type:"text",text:s}],isError:!0}
3522
+ if(await(0,u.branchAddsNoContent)(t,r,`requests/${x}`))return _({success:!1,reason:"identical_tree"}),{content:[{type:"text",text:(0,u.identicalTreeBlockMessage)(x,r)}],isError:!0}}catch(e){E.warn("Could not compute merge-base / ahead count; proceeding (the merge path surfaces a real branch error)",{requestId:x,error:(0,d.getErrorMessage)(e)})}let R="workspace-manager"
3523
+ const A=await e.getRequest(x),O=A?.title||`Request ${x}`
3524
+ let M="main"
3525
+ try{k.git&&(await k.git.branch(),M=await(0,y.resolveDefaultBranch)(k.mainBasePath,k.gitBinary))}catch{}const D=k.git?await(0,a.findCommittedMarkers)(k.git,`requests/${x}`):{files:[],determined:!1}
3526
+ if(!D.determined)return _({success:!1,reason:"marker_check_unavailable"}),{content:[{type:"text",text:`Cannot merge ${x}: the conflict-marker check could not run, so it is unknown whether unresolved markers remain on requests/${x}. Nothing was merged.`}],isError:!0}
3527
+ if(D.files.length>0)return _({success:!1,reason:"unresolved_markers"}),{content:[{type:"text",text:`Cannot merge ${x}: committed conflict markers remain in ${D.files.join(", ")}. Resolve every <<<<<<< block with your file tools, verify, then merge again.`}],isError:!0}
3528
+ let F
3529
+ k.mainBasePath&&await(0,c.foldAtDoor)({repoDir:k.mainBasePath,branch:`requests/${x}`,defaultBranch:M,requestId:x,door:"merge",gitBinary:k.gitBinary,postRecord:e=>I.proxyPost(`/api/projects/${k.projectId}/tool-records`,e),log:E})
3530
+ let N=null
3531
+ {const e=await(0,p.runMergeQueueGate)({projectPath:q,requestId:x,branchName:`requests/${x}`,defaultBranch:M,requestTitle:A?.title,criteria:A?.acceptanceCriteria??A?.acceptance_criteria,testGateOff:!1===A?.gates?.test?.enabled,source:"merge_request",gitBinary:k.gitBinary,logger:E,fetchRequestRuns:async()=>{const e=await I.proxyGet(`/api/projects/${k.projectId}/requests/${x}/test-runs`),t=e?.data??e??[]
3532
+ return Array.isArray(t)?t:[]},fetchActiveProcesses:async()=>{const e=await I.proxyGet(`/api/projects/${k.projectId}/test-processes/active?forRequest=${encodeURIComponent(x)}`),t=e?.data??e??[]
3533
+ return(Array.isArray(t)?t:[t]).filter(Boolean)},evaluatePromises:async({baseSha:e,headSha:r})=>{const{getActionServerBaseUrl:n}=await Promise.resolve().then(()=>t(79414)),o=await fetch(`${n()}/api/promise-checks-at-merge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:x,baseSha:e,headSha:r}),signal:AbortSignal.timeout(6e5)})
3521
3534
  if(!o.ok)return null
3522
3535
  const s=await o.json()
3523
- return s?.data??null},evaluateMainChange:async({landingSha:e})=>{const{getActionServerBaseUrl:r}=await Promise.resolve().then(()=>t(79414)),n=await fetch(`${r()}/api/main-change-at-landing`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:_,landingSha:e}),signal:AbortSignal.timeout(2e5)})
3536
+ return s?.data??null},evaluateMainChange:async({landingSha:e})=>{const{getActionServerBaseUrl:r}=await Promise.resolve().then(()=>t(79414)),n=await fetch(`${r()}/api/main-change-at-landing`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:x,landingSha:e}),signal:AbortSignal.timeout(2e5)})
3524
3537
  if(!n.ok)return null
3525
3538
  const o=await n.json()
3526
- return o?.data??null},dispatchCatchUp:async e=>{const{getActionServerBaseUrl:r}=await Promise.resolve().then(()=>t(79414)),n=await fetch(`${r()}/api/run-tests-now`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:_,parentSessionId:v.currentSessionId,catchUp:e}),signal:AbortSignal.timeout(6e4)})
3539
+ return o?.data??null},dispatchCatchUp:async e=>{const{getActionServerBaseUrl:r}=await Promise.resolve().then(()=>t(79414)),n=await fetch(`${r()}/api/run-tests-now`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:x,parentSessionId:k.currentSessionId,catchUp:e}),signal:AbortSignal.timeout(6e4)})
3527
3540
  if(!n.ok){const e=await n.text().catch(()=>"")
3528
3541
  return{success:!1,error:`action server returned ${n.status}: ${e.slice(0,300)}`}}const o=await n.json()
3529
3542
  return o?.success?{success:!0,testRunIds:o?.data?.testRunIds??[],settled:o?.data?.catchUp?.settled??null}:{success:!1,error:o?.error||"unknown error"}}})
3530
3543
  if("wait-slot"===e.action){const t=e.holder
3531
- return E({success:!1,reason:"merge_slot_busy"}),{content:[{type:"text",text:`STOP: Request ${_} was NOT merged: the project's merge slot is held by ${t?.requestId??"another request"} (${t?.phase??"merging"}, since ${t?.acquiredAt??"unknown"}). Merges land one at a time so each request lands exactly the tree its tests certified. Wait about a minute, then call merge again with the same arguments.`}],isError:!0}}if(q=!0,"catchup-running"===e.action)return T=!0,E({success:!1,reason:"merge_catchup_running"}),{content:[{type:"text",text:`Request ${_} is NOT merged yet: your recorded test runs no longer certify the exact tree this merge would land (another request landed first: ${O} moved, or its changes were freshened into your branch, after your tests ran). A catch-up test run of the applicable test processes is ${e.dispatched?"now running":"already running"} against the EXACT tree that would land (commit ${e.mergeCommitSha.slice(0,8)}), and the merge slot is held for you so ${O} cannot move again. STOP and wait: the test report is delivered to you automatically. On pass you'll be cleared to merge; that merge call lands the very tree that was tested. On failure the failing run is your rework evidence: fix, close the rework task, and re-complete.`}],isError:!1}
3532
- if("env-gap"===e.action){E({success:!1,reason:"merge_env_gap"})
3544
+ return _({success:!1,reason:"merge_slot_busy"}),{content:[{type:"text",text:`STOP: Request ${x} was NOT merged: the project's merge slot is held by ${t?.requestId??"another request"} (${t?.phase??"merging"}, since ${t?.acquiredAt??"unknown"}). Merges land one at a time so each request lands exactly the tree its tests certified. Wait about a minute, then call merge again with the same arguments.`}],isError:!0}}if(T=!0,"catchup-running"===e.action)return j=!0,_({success:!1,reason:"merge_catchup_running"}),{content:[{type:"text",text:`Request ${x} is NOT merged yet: your recorded test runs no longer certify the exact tree this merge would land (another request landed first: ${M} moved, or its changes were freshened into your branch, after your tests ran). A catch-up test run of the applicable test processes is ${e.dispatched?"now running":"already running"} against the EXACT tree that would land (commit ${e.mergeCommitSha.slice(0,8)}), and the merge slot is held for you so ${M} cannot move again. STOP and wait: the test report is delivered to you automatically. On pass you'll be cleared to merge; that merge call lands the very tree that was tested. On failure the failing run is your rework evidence: fix, close the rework task, and re-complete.`}],isError:!1}
3545
+ if("env-gap"===e.action){_({success:!1,reason:"merge_env_gap"})
3533
3546
  const t=e.missingCapabilities.length?e.missingCapabilities.join(", "):"a required tool"
3534
- return{content:[{type:"text",text:`Request ${_}'s real tests PASSED, but one acceptance check could not run: the confined box lacks ${t} (a missing tool, not a code defect). This is not a red gate and there is nothing for you to fix in the code. It waits on a card for the user to extend the box or merge anyway -- do NOT rewrite the code or re-run in a loop.`}],isError:!0}}if("catchup-failed"===e.action)return E({success:!1,reason:"merge_catchup_failed"}),{content:[{type:"text",text:`Cannot merge request ${_}: the merge-boundary catch-up test run FAILED against the prospective merge commit ${e.mergeCommitSha.slice(0,8)}${e.failedChecks?.length?` (failing: ${e.failedChecks.join(", ")})`:""}. The merge slot was released; the failing run is recorded as evidence and the request goes into the normal test-rework lane (the predecessor's changes were reconciled into your branch so your fix sees the real interaction). Fix the reported failures, complete the rework task, then re-complete the request.`}],isError:!0}
3535
- if("error"===e.action)return E({success:!1,error:"merge_queue_error"}),{content:[{type:"text",text:`Merge queue check failed: ${e.message}`}],isError:!0}
3536
- if("sent-back"===e.action)return E({success:!1,error:"sent_back"}),await(0,f.bringMainIn)({projectPath:C,requestId:_,defaultBranch:O,logger:S}),{content:[{type:"text",text:`Not merged: ${e.summary}\n\n${_} is back in progress with you and main's newer work is now on your branch: make your work hold alongside it, then complete again.`}],isError:!0}
3537
- if("review-held"===e.action){E({success:!1,error:"review_held"})
3538
- const t=await(0,f.holdForMainChangeReview)({projectPath:C,projectId:v.projectId,requestId:_,defaultBranch:O,touched:e.touched,logger:S,post:(e,t)=>k.proxyPost(e,t)})
3539
- return{content:[{type:"text",text:`Not merged yet: ${e.summary}\n\n${t.reviewing?`Main's newer work is now on your branch, and a reviewer is checking ${_}'s criteria against that change. Wait for its report: apply what it asks for, then complete again.`:"A review of that change could not be started; make sure your work holds alongside main's newer work, then merge again."}`}],isError:!0}}if("promises-held"===e.action)return E({success:!1,error:"promises_held"}),{content:[{type:"text",text:`Not merged: ${e.summary}.\n\nThe user decides on the promise card now in front of them, and only they answer it. Their answer sends the work back to you, or ends the promise (or keeps the new check) and merges it at once, with no sign-off after it. To change a promise's check yourself, add a criterion to this request with the promise's words, carries: "promise:<request>:<criterion>", and the new command; a reviewer checks it like any other.`}],isError:!0}
3540
- "conflicts"===e.action&&(F=new Error(`Merge of requests/${_} into ${O} has conflicts (detected on the prospective merge tree):\n${e.summary}`),F.conflictInfo={conflictedFiles:[],workingDirectory:void 0}),"land"===e.action&&(D=e.certifiedCommitSha,S.info("merge-queue: landing certified catch-up commit (tested tree == merged tree)",{requestId:_,certifiedCommitSha:D.slice(0,8)}))}try{if(F)throw F
3541
- j=await v.workspaceManager.completeRequest(_,A,D?{certifiedCommitSha:D}:void 0),P=D?"merge-queue-certified":j.autoMergeInfo?.strategy||"workspace-manager",S.info("Merge completed",{requestId:_,mergeCommitHash:j.mergeCommitHash,mergeMethod:P})}catch(t){if(!t.conflictInfo){const e=(0,d.getErrorMessage)(t)
3542
- return E({success:!1,error:"merge_failure"}),{content:[{type:"text",text:`Merge failed: ${e}`}],isError:!0}}{const r=t.conflictInfo.workingDirectory||v.workspaceManager?.getCurrentContext(v.currentSessionId)?.basePath||void 0,n=`requests/${_}`,o=await(0,a.reconcileBranchWithMain)({projectPath:v.basePath,requestId:_,branchName:n,defaultBranch:O,worktreePath:r})
3543
- if("clean"!==o.outcome){if("conflicts-committed"===o.outcome){try{await e.updateRequest(_,{status:"resolving_conflicts"}),S.info("Set status to resolving_conflicts",{requestId:_})}catch(e){S.error("Failed to set resolving_conflicts status",{requestId:_,error:(0,d.getErrorMessage)(e)})}const t=(0,a.buildResolveInstruction)({requestId:_,branchName:n,defaultBranch:O,landed:o.landed,conflictedFiles:o.conflictedFiles,retryVia:"merge"})
3544
- return E({success:!1,reason:"merge_conflicts"}),{content:[{type:"text",text:t}],isError:!1}}return E({success:!1,reason:"merge_conflicts"}),{content:[{type:"text",text:`Merge conflicts detected and auto-reconcile was not possible (${o.outcome}${o.error?`: ${o.error}`:""}). The branch worktree may be missing or dirty: resolve manually and merge again.`}],isError:!0}}S.info("Branch reconciled with main cleanly: retrying merge",{requestId:_})
3545
- try{j=await v.workspaceManager.completeRequest(_,A),P="reconcile-retry"}catch(e){return E({success:!1,error:"merge_failure_after_reconcile"}),{content:[{type:"text",text:`Merge failed after clean reconcile: ${(0,d.getErrorMessage)(e)}`}],isError:!0}}}}const N=v.workspaceManager.getCurrentContext(v.currentSessionId)?.basePath||v.basePath,z=D??j?.mergeCommitHash
3546
- z&&($=await(0,s.firstParentSha)((0,s.gitFor)(N,v.git,v.gitBinary),z)??$)
3547
- const L=await(0,s.computeDiffStats)((0,s.gitFor)(N,v.git,v.gitBinary),$,j?.mergeCommitHash)
3548
- try{await k.proxyPost(`/api/projects/${v.projectId}/requests/${_}/finalize-completion`,{summary:R?.completionSummary||`Merged request ${_}`,mergeResult:{mergeCommitHash:j.mergeCommitHash,mergeBaseSha:$,mergedFiles:j.mergedFiles,cleanedUp:j.cleanedUp,method:P,diffStats:L}})}catch(e){const t=(0,d.getErrorMessage)(e)
3549
- return S.error("CRITICAL: Merge succeeded but server finalization failed",{requestId:_,mergeCommitHash:j.mergeCommitHash,error:t}),E({success:!1,error:"api_update_failed"}),{content:[{type:"text",text:`CRITICAL: Code was merged (commit: ${j.mergeCommitHash.substring(0,8)}) but failed to update server: ${t}`}],isError:!0}}return(0,n.maybePublishReceiptOnMerge)(_),(0,m.clearMergeCandidate)(C,_,v.gitBinary).catch(()=>{}),E({success:!0}),{content:[{type:"text",text:`Request ${_} merged successfully.\nCommit: ${j.mergeCommitHash.substring(0,8)}`}]}}catch(e){const t=(0,d.getErrorMessage)(e)
3550
- S.error("Merge request failed",{error:t})
3551
- try{await(0,l.createFailureToolRecord)("merge-request",e,{error:t,requestId:_},k.getToolRecordClient(),S,$,{requestId:_,projectId:v.projectId,note:"Failed to merge request"})}catch{}return E({success:!1,error:e instanceof Error?e.name:"unknown"}),{content:[{type:"text",text:`Error: ${t}`}],isError:!0}}finally{if(q&&!T)try{(0,h.releaseMergeLease)(C,_)}catch{}}}
3552
- const n=t(19817),o=t(83807),s=t(92456),i=t(59860),a=t(35510),c=t(82860),l=t(18616),d=t(58824),u=t(27478),h=t(56509),p=t(14128),f=t(13922),m=t(87192),g=t(65454),y=t(52232),w=t(87780),b=t(63580),v={"signoff-park":"the sign-off","test-process-broken":"a test check that cannot run","test-cap-escalation":"tests that keep failing","review-cap-escalation":"review findings still open","review-gap":"a review that did not run","environment-gap":"the test box missing a tool","unprovable-criteria":"criteria nothing can prove"}},95994(e,exports,t){var r,n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r)
3547
+ return{content:[{type:"text",text:`Request ${x}'s real tests PASSED, but one acceptance check could not run: the confined box lacks ${t} (a missing tool, not a code defect). This is not a red gate and there is nothing for you to fix in the code. It waits on a card for the user to extend the box or merge anyway -- do NOT rewrite the code or re-run in a loop.`}],isError:!0}}if("catchup-failed"===e.action)return _({success:!1,reason:"merge_catchup_failed"}),{content:[{type:"text",text:`Cannot merge request ${x}: its checks FAILED on the tree the merge would land (${e.mainMergedIn?"the prospective merge commit":"the branch tip, which already contains main"} ${e.mergeCommitSha.slice(0,8)})${e.failedChecks?.length?` (failing: ${e.failedChecks.join(", ")})`:""}. The merge slot was released; the failing run is recorded as evidence and the request goes into the normal test-rework lane${e.mainMergedIn?" (main's newer changes were reconciled into your branch so your fix sees the real interaction)":""}. Fix the reported failures, complete the rework task, then re-complete the request.`}],isError:!0}
3548
+ if("error"===e.action)return _({success:!1,error:"merge_queue_error"}),{content:[{type:"text",text:`Merge queue check failed: ${e.message}`}],isError:!0}
3549
+ if("sent-back"===e.action)return _({success:!1,error:"sent_back"}),await(0,f.bringMainIn)({projectPath:q,requestId:x,defaultBranch:M,logger:E}),{content:[{type:"text",text:`Not merged: ${e.summary}\n\n${x} is back in progress with you and main's newer work is now on your branch: make your work hold alongside it, then complete again.`}],isError:!0}
3550
+ if("review-held"===e.action){_({success:!1,error:"review_held"})
3551
+ const t=await(0,f.holdForMainChangeReview)({projectPath:q,projectId:k.projectId,requestId:x,defaultBranch:M,touched:e.touched,logger:E,post:(e,t)=>I.proxyPost(e,t)})
3552
+ return{content:[{type:"text",text:`Not merged yet: ${e.summary}\n\n${t.reviewing?`Main's newer work is now on your branch, and a reviewer is checking ${x}'s criteria against that change. Wait for its report: apply what it asks for, then complete again.`:"A review of that change could not be started; make sure your work holds alongside main's newer work, then merge again."}`}],isError:!0}}if("promises-held"===e.action)return _({success:!1,error:"promises_held"}),{content:[{type:"text",text:`Not merged: ${e.summary}.\n\nThe user decides on the promise card now in front of them, and only they answer it. Their answer sends the work back to you, or ends the promise (or keeps the new check) and merges it at once, with no sign-off after it. To change a promise's check yourself, add a criterion to this request with the promise's words, carries: "promise:<request>:<criterion>", and the new command; a reviewer checks it like any other.`}],isError:!0}
3553
+ "conflicts"===e.action&&(N=new Error(`Merge of requests/${x} into ${M} has conflicts (detected on the prospective merge tree):\n${e.summary}`),N.conflictInfo={conflictedFiles:[],workingDirectory:void 0}),"land"===e.action&&(F=e.certifiedCommitSha,E.info("merge-queue: landing certified catch-up commit (tested tree == merged tree)",{requestId:x,certifiedCommitSha:F.slice(0,8)}))}try{if(N)throw N
3554
+ P=await k.workspaceManager.completeRequest(x,O,F?{certifiedCommitSha:F}:void 0),R=F?"merge-queue-certified":P.autoMergeInfo?.strategy||"workspace-manager",E.info("Merge completed",{requestId:x,mergeCommitHash:P.mergeCommitHash,mergeMethod:R})}catch(t){if(!t.conflictInfo){const e=(0,d.getErrorMessage)(t)
3555
+ return _({success:!1,error:"merge_failure"}),{content:[{type:"text",text:`Merge failed: ${e}`}],isError:!0}}{const r=t.conflictInfo.workingDirectory||k.workspaceManager?.getCurrentContext(k.currentSessionId)?.basePath||void 0,n=`requests/${x}`,o=await(0,a.reconcileBranchWithMain)({projectPath:k.basePath,requestId:x,branchName:n,defaultBranch:M,worktreePath:r})
3556
+ if("clean"!==o.outcome){if("conflicts-committed"===o.outcome){try{await e.updateRequest(x,{status:"resolving_conflicts"}),E.info("Set status to resolving_conflicts",{requestId:x})}catch(e){E.error("Failed to set resolving_conflicts status",{requestId:x,error:(0,d.getErrorMessage)(e)})}const t=(0,a.buildResolveInstruction)({requestId:x,branchName:n,defaultBranch:M,landed:o.landed,conflictedFiles:o.conflictedFiles,retryVia:"merge"})
3557
+ return _({success:!1,reason:"merge_conflicts"}),{content:[{type:"text",text:t}],isError:!1}}return _({success:!1,reason:"merge_conflicts"}),{content:[{type:"text",text:`Merge conflicts detected and auto-reconcile was not possible (${o.outcome}${o.error?`: ${o.error}`:""}). The branch worktree may be missing or dirty: resolve manually and merge again.`}],isError:!0}}E.info("Branch reconciled with main cleanly: retrying merge",{requestId:x})
3558
+ try{P=await k.workspaceManager.completeRequest(x,O),R="reconcile-retry"}catch(e){return _({success:!1,error:"merge_failure_after_reconcile"}),{content:[{type:"text",text:`Merge failed after clean reconcile: ${(0,d.getErrorMessage)(e)}`}],isError:!0}}}}const z=k.workspaceManager.getCurrentContext(k.currentSessionId)?.basePath||k.basePath,L=F??P?.mergeCommitHash
3559
+ L&&(S=await(0,s.firstParentSha)((0,s.gitFor)(z,k.git,k.gitBinary),L)??S)
3560
+ const B=await(0,s.computeDiffStats)((0,s.gitFor)(z,k.git,k.gitBinary),S,P?.mergeCommitHash),H=L&&!1===A?.gates?.test?.enabled?await(0,w.landedOnTopOf)(z,L,x).catch(()=>[]):[]
3561
+ try{await I.proxyPost(`/api/projects/${k.projectId}/requests/${x}/finalize-completion`,{summary:A?.completionSummary||`Merged request ${x}`,mergeResult:{mergeCommitHash:P.mergeCommitHash,mergeBaseSha:S,mergedFiles:P.mergedFiles,cleanedUp:P.cleanedUp,method:R,diffStats:B,...H.length?{notCheckedWith:H}:{}}})}catch(e){const t=(0,d.getErrorMessage)(e)
3562
+ return E.error("CRITICAL: Merge succeeded but server finalization failed",{requestId:x,mergeCommitHash:P.mergeCommitHash,error:t}),_({success:!1,error:"api_update_failed"}),{content:[{type:"text",text:`CRITICAL: Code was merged (commit: ${P.mergeCommitHash.substring(0,8)}) but failed to update server: ${t}`}],isError:!0}}return(0,n.maybePublishReceiptOnMerge)(x),(0,m.clearMergeCandidate)(q,x,k.gitBinary).catch(()=>{}),_({success:!0}),{content:[{type:"text",text:`Request ${x} merged successfully.\nCommit: ${P.mergeCommitHash.substring(0,8)}`}]}}catch(e){const t=(0,d.getErrorMessage)(e)
3563
+ E.error("Merge request failed",{error:t})
3564
+ try{await(0,l.createFailureToolRecord)("merge-request",e,{error:t,requestId:x},I.getToolRecordClient(),E,S,{requestId:x,projectId:k.projectId,note:"Failed to merge request"})}catch{}return _({success:!1,error:e instanceof Error?e.name:"unknown"}),{content:[{type:"text",text:`Error: ${t}`}],isError:!0}}finally{if(T&&!j)try{(0,h.releaseMergeLease)(q,x)}catch{}}}
3565
+ const n=t(19817),o=t(83807),s=t(92456),i=t(59860),a=t(35510),c=t(82860),l=t(18616),d=t(58824),u=t(27478),h=t(56509),p=t(14128),f=t(13922),m=t(87192),g=t(65454),y=t(52232),w=t(82865),b=t(87780),v=t(63580),k={"signoff-park":"the sign-off","test-process-broken":"a test check that cannot run","test-cap-escalation":"tests that keep failing","review-cap-escalation":"review findings still open","review-gap":"a review that did not run","environment-gap":"the test box missing a tool","unprovable-criteria":"criteria nothing can prove"}},95994(e,exports,t){var r,n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r)
3553
3566
  var o=Object.getOwnPropertyDescriptor(t,r)
3554
3567
  o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(r=function(e){return r=Object.getOwnPropertyNames||function(e){var t=[]
3555
3568
  for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r)
@@ -3613,11 +3626,11 @@ const t=new Map,r=(e,t)=>`${e}\0${t}`
3613
3626
  exports.SHAPING_AGENTS=new Set(["request-architect","planner"])
3614
3627
  const n=new Map},74165(e,exports,t){exports.def=void 0
3615
3628
  const r=t(76183),n=t(84648)
3616
- exports.def={name:"request_operations",description:"Operations on existing requests (create_request creates one).\n\n\u2022 complete - Phase one of completion: the summary; returns the criteria keys to verify.\n\u2022 merge - Phase two: evidence per criterion key; merges when all are met.\n\u2022 revert - Undo all changes of a completed request.\n\u2022 reopen - Send a finished, unmerged request back to rework with your reason; the worker is told. If the result already satisfies the feedback, say so instead. A merged request gets a follow-up instead.\n\u2022 update - Change title, description, type, criteria or process.\n\u2022 activate - Start a draft when the user asks. Refused for drafts held by intake: answer the intake ask instead.\n\u2022 get-info - Everything about a request.\n\u2022 list / search - List, or full-text search title, description and criteria.\n\u2022 list-areas / update-areas - The project's work areas, most recently used first / replace the request's areas.\n\u2022 wait-on - Record that this request waits for another (waitsOn: req######, reason in the user's words) whenever work must queue; a report does not record a wait. It ends when the blocker merges; a canceled blocker never merges, so move the wait to its replacement or clear it. clear-wait drops a wait (omit waitsOn to clear all).\n\u2022 cancel - Cancel a request the user no longer wants (before merge), with reason. Telling a worker in prose cancels nothing.\n\u2022 delete-empty - Delete a request that has no tasks.\n\u2022 dispute-criterion - Ask the user to waive a process criterion that does not fit this request.\n\u2022 asked-no-change - After answering a user message on this request that asked for no change (userSaid), so it is not listed as a change they made.\n\u2022 hand-over - Give the user's message you are answering to the worker still warm on requestId, for an adjustment to what that worker just did; it answers them on that request's thread. Refused when no worker is live there: then file it as usual.",schema:r.RequestOperationsSchema,annotations:{title:"Request Operations",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1},handler:(e,t)=>(0,n.handleRequestOperations)(e,t.context,t.apiClient,t.logger,t.metrics,t.mcpServer,t.cliOrigin)}},84648(e,exports,t){exports.handleRequestOperations=async function(e,t,k,I,$,S,E){const _=I.child({tool:"request_operations"})
3629
+ exports.def={name:"request_operations",description:"Operations on existing requests (create_request creates one).\n\n\u2022 complete - Phase one of completion: the summary; returns the criteria keys to verify.\n\u2022 merge - Phase two: evidence per criterion key; merges when all are met.\n\u2022 revert - Undo all changes of a completed request.\n\u2022 reopen - Send a finished, unmerged request back to rework with your reason; the worker is told. If the result already satisfies the feedback, say so instead. A merged request gets a follow-up instead.\n\u2022 update - Change title, description, type, criteria or process.\n\u2022 activate - Start a draft when the user asks. Refused for drafts held by intake: answer the intake ask instead.\n\u2022 get-info - Everything about a request.\n\u2022 list / search - List, or full-text search title, description and criteria.\n\u2022 status - Where live work stands, from the record, in one call: per thread or plan what is done, running and next, what waits on the user, spend at list price, anything stuck. requestId: that request's thread; planId: that plan; neither: everything live.\n\u2022 list-areas / update-areas - The project's work areas, most recently used first / replace the request's areas.\n\u2022 wait-on - Record that this request waits for another (waitsOn: req######, reason in the user's words) whenever work must queue; a report does not record a wait. It ends when the blocker merges; a canceled blocker never merges, so move the wait to its replacement or clear it. clear-wait drops a wait (omit waitsOn to clear all).\n\u2022 cancel - Cancel a request the user no longer wants (before merge), with reason. Telling a worker in prose cancels nothing.\n\u2022 delete-empty - Delete a request that has no tasks.\n\u2022 dispute-criterion - Ask the user to waive a process criterion that does not fit this request.\n\u2022 asked-no-change - After answering a user message on this request that asked for no change (userSaid), so it is not listed as a change they made.\n\u2022 hand-over - Give the user's message you are answering to the worker still warm on requestId, for an adjustment to what that worker just did; it answers them on that request's thread. Refused when no worker is live there: then file it as usual.",schema:r.RequestOperationsSchema,annotations:{title:"Request Operations",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1},handler:(e,t)=>(0,n.handleRequestOperations)(e,t.context,t.apiClient,t.logger,t.metrics,t.mcpServer,t.cliOrigin)}},84648(e,exports,t){exports.handleRequestOperations=async function(e,t,k,I,$,S,E){const _=I.child({tool:"request_operations"})
3617
3630
  try{const x=e
3618
3631
  let{requestId:C}=x
3619
3632
  const{operation:q}=x
3620
- if("list"!==q&&"search"!==q&&"list-areas"!==q&&!C){const e=await(0,f.resolveRequestIdOrError)(k,_,t.currentSessionId,`Error: requestId is required for '${q}' and could not be resolved from session`)
3633
+ if("list"!==q&&"search"!==q&&"list-areas"!==q&&"status"!==q&&!C){const e=await(0,f.resolveRequestIdOrError)(k,_,t.currentSessionId,`Error: requestId is required for '${q}' and could not be resolved from session`)
3621
3634
  if(!e.ok)return e.errorResult
3622
3635
  C=e.requestId}switch(_.info("Processing request operation",{requestId:C,operation:q}),q){case"update":return _.info("Routing to update-request handler"),(0,y.withAlchemyKind)(await(0,a.handleUpdateRequest)({requestId:C,title:x.update?.title,description:x.update?.description,type:x.update?.type,acceptanceCriteria:x.update?.acceptanceCriteria,arcName:x.update?.arcName,process:x.update?.process,userSaid:x.update?.userSaid??x.userSaid,removesCriteria:!0===x.update?.removesCriteria},t,k,I,$),v.update)
3623
3636
  case"activate":{_.info("Routing to activate-request (draft -> open)")
@@ -3648,7 +3661,12 @@ if(s?.reopened&&r)try{await(0,a.recordUserWordDecision)(k,{fromSessionId:t.curre
3648
3661
  const e={requestId:C}
3649
3662
  return(0,y.withAlchemyKind)(await(0,i.handleGetRequestInformation)(e,t,k,I,$),v["get-info"])}case"list":{_.info("Routing to list-requests handler")
3650
3663
  const e={filters:x.list?.filters}
3651
- return(0,y.withAlchemyKind)(await(0,l.handleListRequests)(e,t,k,I,$),v.list)}case"list-areas":return _.info("Routing to list-areas handler"),(0,y.withAlchemyKind)(await(0,u.handleListAreas)(t,k,I,$),v["list-areas"])
3664
+ return(0,y.withAlchemyKind)(await(0,l.handleListRequests)(e,t,k,I,$),v.list)}case"status":{const e=t.projectId
3665
+ if(!e)return{content:[{type:"text",text:"Error: no project for this session"}],isError:!0}
3666
+ const r=new URLSearchParams
3667
+ C&&r.set("requestId",C),"string"==typeof x.planId&&x.planId.trim()&&r.set("plan",x.planId.trim())
3668
+ const n=r.toString(),o=await k.proxyGet(`/api/projects/${e}/status-digest${n?`?${n}`:""}`),s=String(o?.data?.text??o?.text??"").trim()
3669
+ return(0,y.withAlchemyKind)({content:[{type:"text",text:s?`${s}\n\n(From the record. Answer from these lines, about three per thread; ids as written; no finishing time, it is not on the record.)`:"No status could be read."}]},v.status)}case"list-areas":return _.info("Routing to list-areas handler"),(0,y.withAlchemyKind)(await(0,u.handleListAreas)(t,k,I,$),v["list-areas"])
3652
3670
  case"wait-on":case"clear-wait":return _.info("Routing to request-wait handler",{operation:q}),(0,y.withAlchemyKind)(await(0,p.handleWaitOn)({requestId:C,waitsOn:x.waitsOn,reason:x.reason,clear:"clear-wait"===q},t,k,I,$),v[q])
3653
3671
  case"update-areas":return _.info("Routing to update-areas handler"),(0,y.withAlchemyKind)(await(0,h.handleUpdateAreas)({requestId:C,areas:x.areas},t,k,I,$),v["update-areas"])
3654
3672
  case"search":{_.info("Routing to search-requests handler")
@@ -3677,7 +3695,7 @@ return!1===r?.blocked?(0,y.withAlchemyKind)({content:[{type:"text",text:`\u26a0\
3677
3695
  try{const e=k.getProxyClient(),r=await e.proxyGet(`/api/projects/${t.projectId}/tasks`,{requestId:C,limit:1}),n=r?.data||r||[]
3678
3696
  return(Array.isArray(n)?n.length:0)>0?{content:[{type:"text",text:`\u274c Cannot delete ${C}: it has tasks. Only empty requests (no tasks created) can be deleted.`}],isError:!0}:(await e.proxyDelete(`/api/projects/${t.projectId}/requests/${C}`),_.info("Empty request deleted",{requestId:C}),(0,y.withAlchemyKind)({content:[{type:"text",text:`\u2705 Request ${C} deleted (had no tasks).`}]},v["delete-empty"]))}catch(e){return{content:[{type:"text",text:`\u274c **Failed to delete request:** ${(0,g.getErrorMessage)(e)}`}],isError:!0}}default:{const e=`Unknown operation type: ${q}`
3679
3697
  return _.error(e),{content:[{type:"text",text:`\u274c **Request Operations Failed:** ${e}`}],isError:!0}}}}catch(e){return _.error("Request operations failed",{error:e instanceof Error?e.stack:String(e)}),$.incrementCounter("request_operations_errors",1),{content:[{type:"text",text:`\u274c **Request Operations Failed:** ${(0,g.getErrorMessage)(e)}`}],isError:!0}}}
3680
- const r=t(95994),n=t(15715),o=t(16416),s=t(19670),i=t(5434),a=t(29729),c=new Set(["ready_for_review","ready_for_merge","resolving_conflicts","conflicted"]),l=t(98037),d=t(80233),u=t(49229),h=t(23130),p=t(72271),f=t(36651),m=t(34306),g=t(58824),y=t(82272),w=t(62032),b=t(12286),v={update:"update-request",activate:"activate-request",complete:"complete-request",merge:"finalize-request",revert:"revert-request","get-info":"get-request-info",list:"list-requests",search:"search-requests","list-areas":"list-areas","update-areas":"update-areas","delete-empty":"delete-empty-request",cancel:"cancel-request","premise-block":"premise-block-request","dispute-criterion":"dispute-criterion","asked-no-change":"asked-no-change","hand-over":"hand-over","wait-on":"declare-request-wait","clear-wait":"clear-request-wait"}},50129(e,exports){exports.requestPage=async function(e,t){return"function"==typeof e.listRequestsPage?e.listRequestsPage(t):{requests:await e.listRequests(t),total:null}},exports.countWords=function(e,t,r="request"){const n=e=>`${r}${1===e?"":"s"}`
3698
+ const r=t(95994),n=t(15715),o=t(16416),s=t(19670),i=t(5434),a=t(29729),c=new Set(["ready_for_review","ready_for_merge","resolving_conflicts","conflicted"]),l=t(98037),d=t(80233),u=t(49229),h=t(23130),p=t(72271),f=t(36651),m=t(34306),g=t(58824),y=t(82272),w=t(62032),b=t(12286),v={update:"update-request",activate:"activate-request",complete:"complete-request",merge:"finalize-request",revert:"revert-request","get-info":"get-request-info",list:"list-requests",search:"search-requests",status:"status-digest","list-areas":"list-areas","update-areas":"update-areas","delete-empty":"delete-empty-request",cancel:"cancel-request","premise-block":"premise-block-request","dispute-criterion":"dispute-criterion","asked-no-change":"asked-no-change","hand-over":"hand-over","wait-on":"declare-request-wait","clear-wait":"clear-request-wait"}},50129(e,exports){exports.requestPage=async function(e,t){return"function"==typeof e.listRequestsPage?e.listRequestsPage(t):{requests:await e.listRequests(t),total:null}},exports.countWords=function(e,t,r="request"){const n=e=>`${r}${1===e?"":"s"}`
3681
3699
  return null!==t&&t>e?`${e} of ${t} ${n(t)}`:`${e} ${n(e)}`},exports.statusParams=function(e){return e&&"undefined"!==e?"in_flight"===e?{inFlight:!0}:{status:e}:{}},exports.dateParams=function(e,t){const r={},n=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)
3682
3700
  if(e){const t=String(e)
3683
3701
  r.updatedAfter=n(t)?new Date(`${t}T00:00:00`).toISOString():new Date(t).toISOString()}if(t){const e=String(t)
@@ -4137,7 +4155,7 @@ try{const e=await i.proxyPost(`/api/projects/${s}/inbox-chat`,{text:l,anchor:m})
4137
4155
  if(!r?.delivered){const n=r?.reason?String(r.reason):e?.error?.message??"not delivered"
4138
4156
  return t.warn("commit_to_viewed_session:refused",{callId:a,viewedId:f,reason:n}),{content:[{type:"text",text:`Commit failed: ${n}`}],isError:!0}}}catch(e){return t.warn("commit_to_viewed_session:post-failed",{callId:a,error:(0,r.getErrorMessage)(e)}),{content:[{type:"text",text:`Commit failed: ${(0,r.getErrorMessage)(e)}`}],isError:!0}}return t.info("Translator forwarded message to viewed session",{callId:a,heraldId:u,viewedId:f,messageLength:l.length,preview:l.slice(0,120),durationMs:Date.now()-c}),{content:[{type:"text",text:"Committed."}]}}
4139
4157
  const r=t(58824),n=t(6688)},22316(e,exports){function t(e){return"autonomous"===e||"collaborative"===e?e:"balanced"}exports.me=exports.Ow=void 0,exports.offersNotYet=function(e){return Array.isArray(e)&&e.some(e=>!!e&&"object"==typeof e&&("not-yet"===e.effect||!0===e.notChecked))},exports.normalizePosture=t,exports.resolveQuestionGate=function(e,r){const n=t(r)
4140
- return e.targeted?{disposition:"ask-now",reason:"targeted at a session (agent-to-agent), not the human"}:e.userAskedToBeAsked?{disposition:"ask-now",reason:"the user asked to be asked -- their words outrank the posture"}:e.namesCriteria&&!e.offersNotYet?{disposition:"ask-now",reason:'blocking user-input question (no "not yet" option) -- the user must answer before the build goes on'}:"autonomous"===n?e.hasDefault||e.namesCriteria?{disposition:"self-answer",reason:e.namesCriteria?'autonomous posture and the question names [user-input] criteria -- answered "not yet"; the work goes on with its placeholder and the end card asks':"autonomous posture and the question carries a default -- the question is closed on it and the user can still change it"}:"high"===e.priority?{disposition:"ask-now",reason:"high priority and no default -- nothing to take, so it reaches the human"}:{disposition:"bounce",reason:"autonomous posture and no default -- the asker must choose for itself"}:e.humanInputFloor||e.namesCriteria?{disposition:"ask-now",reason:"user-input criterion on this request -- the user must be asked"}:"high"===e.priority?{disposition:"ask-now",reason:"high priority -- treated as blocking; always reaches the human"}:"escalate"===e.onExpiry?{disposition:"ask-now",reason:"asker requested escalate-on-expiry -- a human must see it"}:"collaborative"===n?{disposition:"ask-now",reason:"collaborative posture: the human wants to be consulted",hint:"Collaborative posture: keep surfacing the design choices in this work as specific, defaulted questions (options with tradeoffs, recommendation first) -- the user wants to weigh in."}:e.hasDefault&&"low"===e.priority?{disposition:"defer-batch",reason:"balanced posture, low priority, and a default to proceed on -- held for the next checkpoint bundle"}:{disposition:"ask-now",reason:"balanced posture: questions post normally (non-blocking when a default is set)"}},exports.resolveBriefHoldPolicy=function(e){return"collaborative"===t(e)?{holdMs:exports.me,reason:"collaborative posture: the user decides the brief before the work happens"}:{holdMs:0,reason:"the worker proceeds on its stated defaults; only collaborative holds a brief"}},exports.proceedsOnDefault=function(e){return("string"==typeof e.defaultOption?""!==e.defaultOption.trim():null!=e.defaultOption)&&"escalate"!==e.onExpiry&&"how"!==e.steer&&"high"!==e.priority&&!(e.namedCriteria&&e.namedCriteria>0)},exports.resolveHoldPolicy=function(e,r={}){const n=t(e)
4158
+ return e.targeted?{disposition:"ask-now",reason:"targeted at a session (agent-to-agent), not the human"}:e.userAskedToBeAsked?{disposition:"ask-now",reason:"the user asked to be asked -- their words outrank the posture"}:e.namesCriteria&&!e.offersNotYet?{disposition:"ask-now",reason:'blocking user-input question (no "not yet" option) -- the user must answer before the build goes on'}:"autonomous"===n?e.hasDefault||e.namesCriteria?{disposition:"self-answer",reason:e.namesCriteria?'autonomous posture and the question names [user-input] criteria -- answered "not yet"; the work goes on with its placeholder and the end card asks':"autonomous posture and the question carries a default -- the question is closed on it and the user can still change it"}:"high"===e.priority?{disposition:"ask-now",reason:"high priority and no default -- nothing to take, so it reaches the human"}:{disposition:"bounce",reason:"autonomous posture and no default -- the asker must choose for itself"}:e.humanInputFloor||e.namesCriteria?{disposition:"ask-now",reason:"user-input criterion on this request -- the user must be asked"}:"high"===e.priority?{disposition:"ask-now",reason:"high priority -- treated as blocking; always reaches the human"}:"escalate"===e.onExpiry?{disposition:"ask-now",reason:"asker requested escalate-on-expiry -- a human must see it"}:"collaborative"===n?{disposition:"ask-now",reason:"collaborative posture: the human wants to be consulted",hint:"Collaborative posture: keep surfacing the design choices in this work as specific, defaulted questions (each option with its consequence, recommendation first with why) -- the user wants to weigh in."}:e.hasDefault&&"low"===e.priority?{disposition:"defer-batch",reason:"balanced posture, low priority, and a default to proceed on -- held for the next checkpoint bundle"}:{disposition:"ask-now",reason:"balanced posture: questions post normally (non-blocking when a default is set)"}},exports.resolveBriefHoldPolicy=function(e){return"collaborative"===t(e)?{holdMs:exports.me,reason:"collaborative posture: the user decides the brief before the work happens"}:{holdMs:0,reason:"the worker proceeds on its stated defaults; only collaborative holds a brief"}},exports.proceedsOnDefault=function(e){return("string"==typeof e.defaultOption?""!==e.defaultOption.trim():null!=e.defaultOption)&&"escalate"!==e.onExpiry&&"how"!==e.steer&&"high"!==e.priority&&!(e.namedCriteria&&e.namedCriteria>0)},exports.resolveHoldPolicy=function(e,r={}){const n=t(e)
4141
4159
  return"balanced"===n&&r.proceedsOnDefault?{holdMs:0,reason:"balanced posture and the question goes ahead on its default: no wait"}:"collaborative"===n?{holdMs:exports.me,reason:"collaborative posture: courtesy window for an inline answer; then end-turn-and-wait indefinitely"}:"balanced"===n?{holdMs:exports.Ow,reason:"balanced posture: give the human a bounded window, then degrade to async"}:{holdMs:0,reason:"autonomous posture: never hold -- async delivery"}},exports.Ow=6e5,exports.me=18e4},70508(e,exports){exports.requestNeedingAnchor=function(e,n){if(r(n.requestId)||r(n.area))return null
4142
4160
  if(r(n.anchor)&&(!(o=n.anchor)||"object"!=typeof o||"project"!==o.type))return null
4143
4161
  var o
@@ -4184,19 +4202,19 @@ try{const e=await l.getInteractionPosture(C)
4184
4202
  n=e.posture,o=!0===e.humanInputFloor}catch(e){r.warn("Question gate: posture lookup failed, defaulting to balanced",{error:(0,w.getErrorMessage)(e)})}const s="string"==typeof e.userSaid?e.userSaid:"",i=!!s&&await(0,P.userSaidOnRequest)(c,t.projectId,"",s,{anywhere:!0}).catch(()=>!1)
4185
4203
  i&&(g.onExpiry="escalate",F=!0),"how"===g.steer&&g.defaultOption&&(g.onExpiry="escalate")
4186
4204
  const d=(0,I.resolveQuestionGate)({targeted:!1,hasDefault:!!g.defaultOption,priority:b,onExpiry:g.onExpiry,humanInputFloor:o,namesCriteria:_.length>0,offersNotYet:(0,I.offersNotYet)(g.options),userAskedToBeAsked:i},n)
4187
- if(o&&"ask-now"===d.disposition&&(S=!0),r.info("Question gate resolved",{posture:n,disposition:d.disposition,reason:d.reason}),"self-answer"===d.disposition)try{const e=await l.createQuestionSettleAware({fromSessionId:C,questionType:m,question:g.question,options:g.options,context:g.context,defaultOption:g.defaultOption,onExpiry:g.onExpiry,...g.steer?{steer:g.steer}:{},priority:b,expiresInHours:v,...k?{relatesTo:k}:{},...Array.isArray(g.fields)&&g.fields.length>0?{fields:g.fields}:{},...E,..._.length>0?{criteria:_}:{},takenOnDefault:!0})
4205
+ if(o&&"ask-now"===d.disposition&&(S=!0),r.info("Question gate resolved",{posture:n,disposition:d.disposition,reason:d.reason}),"self-answer"===d.disposition)try{const e=await l.createQuestionSettleAware({fromSessionId:C,questionType:m,question:g.question,options:g.options,context:g.context,defaultOption:g.defaultOption,onExpiry:g.onExpiry,...g.steer?{steer:g.steer}:{},...!0===g.changeableLater?{changeableLater:!0}:{},priority:b,expiresInHours:v,...k?{relatesTo:k}:{},...Array.isArray(g.fields)&&g.fields.length>0?{fields:g.fields}:{},...E,..._.length>0?{criteria:_}:{},takenOnDefault:!0})
4188
4206
  if("settled"===e.kind)return{content:[{type:"text",text:`\u{1f4da} **Already decided: no question needed.**\n\n${e.settled.guidance}`}]}
4189
4207
  const t=e.message
4190
4208
  if(t&&"responded"===t.status)return{content:[{type:"text",text:p(t,g)}]}
4191
4209
  if(t)return{content:[{type:"text",text:`\u2753 Question **${t.messageCode}** was posted to the user and is open: its default could not be taken for them. ${a(t)}`}]}}catch(e){r.warn("Question gate: taking the default failed, posting the question instead",{error:(0,w.getErrorMessage)(e)})}else{if("bounce"===d.disposition)return{content:[{type:"text",text:[`\u{1f916} **Question bounced by the question gate** (interaction posture: ${n}).`,"","Nobody is routinely answering questions at this posture -- you have to choose.","Pick your best option yourself, then re-call this tool with questionContent.defaultOption set to it: the question is closed on it at once, and the user can still change it from its card.",'Only if this genuinely cannot be decided without the user (credentials, out-of-band knowledge, irreversible external effects): re-ask with priority "high" and no default -- that reaches the user. Use it sparingly.'].join("\n")}]}
4192
4210
  if("defer-batch"===d.disposition){const e=g.defaultOption,t=(g.options||[]).find(t=>t?.id===e),n=t?t.label:e
4193
- try{const e=await l.createQuestionSettleAware({fromSessionId:C,questionType:m,question:g.question,options:g.options,context:g.context,allowMultiple:g.allowMultiple,...Array.isArray(g.fields)&&g.fields.length>0?{fields:g.fields}:{},defaultOption:g.defaultOption,onExpiry:g.onExpiry,proceededOnDefault:!0,...g.steer?{steer:g.steer}:{},priority:b,expiresInHours:v,...k?{relatesTo:k}:{},...S?{forceAsk:!0}:{},...E})
4211
+ try{const e=await l.createQuestionSettleAware({fromSessionId:C,questionType:m,question:g.question,options:g.options,context:g.context,allowMultiple:g.allowMultiple,...Array.isArray(g.fields)&&g.fields.length>0?{fields:g.fields}:{},defaultOption:g.defaultOption,onExpiry:g.onExpiry,proceededOnDefault:!0,...g.steer?{steer:g.steer}:{},...!0===g.changeableLater?{changeableLater:!0}:{},priority:b,expiresInHours:v,...k?{relatesTo:k}:{},...S?{forceAsk:!0}:{},...E})
4194
4212
  if("settled"===e.kind)return{content:[{type:"text",text:`\u{1f4da} **Already decided: no question needed.**\n\n${e.settled.guidance}`}]}
4195
4213
  const t=e.message
4196
4214
  return{content:[{type:"text",text:`\u{1f4e5} **Question held for the next checkpoint** (${d.reason}).\n\n**Proceed on your default now: ${n}**\n\nIt was recorded as **${t.messageCode}** and will be presented to the user as part of the next checkpoint bundle (e.g. when a request reaches review or a plan is handed off). If it expires first it resolves to your default. If the eventual answer differs from your default you will receive a correction: fold it in then.`}]}}catch(e){r.warn("Question gate: deferred create failed, posting the question normally",{error:(0,w.getErrorMessage)(e)})}}else d.hint&&(A=`\n\n\u{1f4a1} ${d.hint}`)}const u=g.context
4197
4215
  if(!("object"==typeof u&&null!==u||"string"==typeof u&&/^[\[{]/.test(u.trim()))){const e=(0,I.resolveHoldPolicy)(n,{proceedsOnDefault:(0,I.proceedsOnDefault)({defaultOption:g.defaultOption,onExpiry:g.onExpiry,steer:g.steer,priority:b,namedCriteria:_.length})})
4198
4216
  O=e.holdMs,M=n,D=0===O&&"balanced"===(0,I.normalizePosture)(n),O>0&&r.info("Question will sync-hold",{holdMs:O,posture:n,reason:e.reason})}}r.info("Creating question",{fromSessionId:C,toSessionId:q,questionType:m})
4199
- const N=await l.createQuestionSettleAware({fromSessionId:C,toSessionId:q,questionType:m,question:g.question,options:g.options,context:g.context,allowMultiple:g.allowMultiple,...Array.isArray(g.fields)&&g.fields.length>0?{fields:g.fields}:{},defaultOption:g.defaultOption,onExpiry:"collaborative"===M?"escalate":g.onExpiry,...g.steer?{steer:g.steer}:{},priority:b,expiresInHours:v,...k?{relatesTo:k}:{},...O>0?{holdUntil:new Date(Date.now()+O).toISOString()}:{},...D?{proceededOnDefault:!0}:{},...F?{userAsked:!0}:{},...S?{forceAsk:!0}:{},...E,..._.length>0?{criteria:_}:{}})
4217
+ const N=await l.createQuestionSettleAware({fromSessionId:C,toSessionId:q,questionType:m,question:g.question,options:g.options,context:g.context,allowMultiple:g.allowMultiple,...Array.isArray(g.fields)&&g.fields.length>0?{fields:g.fields}:{},defaultOption:g.defaultOption,onExpiry:"collaborative"===M?"escalate":g.onExpiry,...g.steer?{steer:g.steer}:{},...!0===g.changeableLater?{changeableLater:!0}:{},priority:b,expiresInHours:v,...k?{relatesTo:k}:{},...O>0?{holdUntil:new Date(Date.now()+O).toISOString()}:{},...D?{proceededOnDefault:!0}:{},...F?{userAsked:!0}:{},...S?{forceAsk:!0}:{},...E,..._.length>0?{criteria:_}:{}})
4200
4218
  if("settled"===N.kind)return{content:[{type:"text",text:`\u{1f4da} **Already decided: no question needed.**\n\n${N.settled.guidance}`}]}
4201
4219
  const z=N.message
4202
4220
  if(!q&&"responded"===z?.status&&"self-driving"===z?.response?.settledBy)return{content:[{type:"text",text:p(z,g)}]}
@@ -4276,9 +4294,9 @@ const d=s.getSessionMessageClient()
4276
4294
  if(!d)throw new y.ValidationError("Session message client not available")
4277
4295
  if(c.startsWith("Q-")){const{text:t,selectedOptions:n,notes:o,quote:s,sectionAnswers:l}=e,u=i?.sessionId
4278
4296
  if(!u)throw new y.ValidationError("Cannot answer: this call carries no session identity.")
4279
- if(!0===e.escalate){const{escalatedTo:e}=await d.escalateQuestion(c,{escalatedBySessionId:u,notes:o})
4280
- return{content:[{type:"text",text:`\u2934\ufe0f Question ${c} escalated to the user as **${e}**.\n\nYour recommendation${o?" was attached":" was not attached (none given)"}. The original asker keeps working and will receive the user's answer directly: you are done with this question.`}]}}r.info("Answering question",{messageCode:c,respondedBySessionId:u,quoted:!!s})
4281
- const h=await d.answerQuestion(c,{respondedBySessionId:u,text:t,selectedOptions:n,notes:o,...s?{quote:s}:{},...l&&"object"==typeof l?{sectionAnswers:l}:{}})
4297
+ if(!0===e.escalate){const{escalatedTo:t}=await d.escalateQuestion(c,{escalatedBySessionId:u,notes:o,...Array.isArray(e.questionContent?.options)?{options:e.questionContent.options}:{}})
4298
+ return{content:[{type:"text",text:`\u2934\ufe0f Question ${c} escalated to the user as **${t}**.\n\nYour recommendation${o?" was attached":" was not attached (none given)"}. The original asker keeps working and will receive the user's answer directly: you are done with this question.`}]}}r.info("Answering question",{messageCode:c,respondedBySessionId:u,quoted:!!s})
4299
+ const h=await d.answerQuestion(c,{respondedBySessionId:u,text:t,selectedOptions:n,notes:o,...s?{quote:s}:{},...l&&"object"==typeof l?{sectionAnswers:l}:{},..."number"==typeof e.spendCeiling?{spendCeiling:e.spendCeiling}:{}})
4282
4300
  if(h?.briefChange){const e=h.briefChange
4283
4301
  return{content:[{type:"text",text:`Recorded on the brief ${c} (${(e.recorded??[]).join(", ")}). ${e.message??""}`.trim()}]}}if(h?.points){const e=h.points
4284
4302
  return{content:[{type:"text",text:`Recorded on the brief ${c}: ${(e.answered??[]).join(", ")}. Still open on its card, not answered and not taken for the user: ${(e.open??[]).join(", ")}.`}]}}return{content:[{type:"text",text:`\u2705 Question answered! The asking session is resumed by the server with your answer.\n\n${a(h)}`}]}}if(c.startsWith("R-")){r.info("Acknowledging report",{messageCode:c})
@@ -4303,7 +4321,7 @@ try{const e=c?.projectId
4303
4321
  if(e){const t=await q.proxyGet(`/api/projects/${e}/session-plan-associations/by-session/${encodeURIComponent(r)}`),n=t?.data??t??[]
4304
4322
  if(u=n[0]?.documentLocalId??null,u)try{const t=await q.proxyGet(`/api/projects/${e}/documents/${encodeURIComponent(u)}`),r=t?.data??t;(!0===r?.metadata?.isStub||!String(r?.content??"").trim())&&(await q.proxyPatch(`/api/projects/${e}/documents/${encodeURIComponent(u)}/archive`,{}),D.info("offer-handoff: archived the empty stub plan document (no plan was written)",{planDocumentId:u}),u=null)}catch(e){D.warn("offer-handoff: stub plan check failed (handoff unaffected)",{planDocumentId:u,error:e instanceof Error?e.message:String(e)})}}}catch{}if(u&&Array.isArray(t.requestIds)&&t.requestIds.length>0){let e=[]
4305
4323
  try{e=(0,A.draftsLeftOut)(await(0,A.planLinkedRequests)(q.getRequestClient(),u),t.requestIds)}catch(e){D.warn("offer-handoff: plan-linked drafts unreadable (hand-off not checked)",{planDocumentId:u,error:(0,w.getErrorMessage)(e)})}if(e.length>0)throw new y.ValidationError(`Hand-off NOT offered: ${u} also guides draft${1===e.length?"":"s"} ${e.join(", ")}, which this hand-off leaves out. Each draft is a step of this plan. Include it in requestIds if it is still part of the plan (update it in place first if the plan changed it), or cancel it with request_operations cancel and a reason if your change replaced it. Then offer the hand-off again.`)}try{const e=q.getSessionMessageClient()
4306
- if(e){const n=await e.createQuestion({fromSessionId:r,toSessionId:o||void 0,questionType:"alternatives",question:h(t.summary),options:[{id:"build",label:"Start Building",description:"Start every draft step the plan has when you press it"},{id:"plan",label:"Keep Planning",description:"Continue refining the plan"},{id:"keep",label:"Keep the plan, no build",description:"Keep the plan and its drafts as a reference; nothing starts and the planner ends"}],context:JSON.stringify({type:"plan-completion",plannerSessionId:r,parentSessionId:o,requestIds:t.requestIds,summary:t.summary,planDocumentId:u}),priority:"high"})
4324
+ if(e){const n=await e.createQuestion({fromSessionId:r,toSessionId:o||void 0,questionType:"alternatives",question:h(t.summary),options:[{id:"build",label:"Start Building",description:"Start every draft step the plan has when you press it"},{id:"plan",label:"Keep Planning",description:"The planner keeps working on the plan; nothing starts yet"},{id:"keep",label:"Keep the plan, no build",description:"Keep the plan and its drafts as a reference; nothing starts and the planner ends"}],context:JSON.stringify({type:"plan-completion",plannerSessionId:r,parentSessionId:o,requestIds:t.requestIds,summary:t.summary,planDocumentId:u}),priority:"high"})
4307
4325
  d=n?.messageCode,D.info("offer-handoff: notification question created",{fromSessionId:r,parentSessionId:o,messageCode:d})}else D.warn("offer-handoff: skipping notification question: no message client")}catch(e){D.warn("offer-handoff: failed to create notification question",{error:(0,w.getErrorMessage)(e)})}if(l&&d)try{const e=q.getSessionMessageClient()
4308
4326
  e&&(await e.answerQuestion(d,{respondedBySessionId:"system",selectedOptions:["build"],notes:"auto-confirmed: the workflow plans automatically, so building starts without a hand-off question"}),a=!0,D.info("offer-handoff: auto-confirmed for autonomous planner",{fromSessionId:r,messageCode:d}))}catch(e){D.warn("offer-handoff: failed to auto-confirm for autonomous planner",{error:(0,w.getErrorMessage)(e)})}return(0,v.withAlchemyKind)({content:[{type:"text",text:a?"Handoff auto-confirmed (autonomous planner). Start-building has been queued: you can stop now.":'Handoff offered to user. STOP here and wait: the user will choose "Start Building" or "Keep Planning". You will receive their choice as a new message. Do NOT generate any further output until then.'}],isError:!1,...(0,v.alchemyMeta)({pendingAction:{kind:"plan-handoff",payload:{summary:t.summary,requestIds:t.requestIds,parentSessionId:o,fromSessionId:r,autoConfirmed:a}}})},"offer-handoff")}case"record-decision":{if(!e.decision||"string"!=typeof e.decision||!e.decision.trim())throw new y.ValidationError("record-decision requires 'decision' (the one-line call you made)")
4309
4327
  const t=q.getSessionMessageClient()
@@ -4355,7 +4373,7 @@ const s=await o.getMessage(n)
4355
4373
  return s?{content:[{type:"text",text:d(s)}]}:{content:[{type:"text",text:`\u274c Message with code ${n} not found.`}],isError:!0}}(e,D,q),"get-message")
4356
4374
  default:throw new y.ValidationError(`Unknown operation: ${F}. Valid operations: send, reply, list, get, offer-handoff, record-decision, brief`)}}catch(e){return D.error("Session message operation failed",{operation:F,error:(0,w.getErrorMessage)(e)}),{content:[{type:"text",text:`\u274c Error: ${(0,w.getErrorMessage)(e)}`}],isError:!0}}}
4357
4375
  const m=t(87780),g=t(70508),y=t(59860),w=t(58824),b=t(47617),v=t(82272),k=t(67904),I=t(22316),$=t(22746),S=t(4871),E=t(6688),_=t(69883),x=t(69048),C=t(34221),q=t(39844),T=t(43545),j=t(87280),P=t(29729),R=t(19670),A=t(53847),O=t(62032),M=new Map
4358
- exports.zk="A worker asks you this while it builds. Answer from what the user said and what the record holds: reply with your answer (quote the user's words when they settle it). If the answer changes what the request asks, update its criteria first (request_operations update). If only the user can decide, reply with escalate: true and your recommended default in notes; the default must be safe to happen without them."},22746(e,exports,t){exports.runSyncHold=async function(e){const{client:t,logger:n,messageCode:o,holdMs:s}=e,i=Date.now()+s,a=async e=>{try{await t.stampHoldOutcome(o,{holdDelivered:!0,clearHold:!0})}catch(e){n.warn("Hold claim failed; the arbiter may also inject this answer",{messageCode:o,error:(0,r.getErrorMessage)(e)})}return{kind:"answered",message:e}}
4376
+ exports.zk="A worker asks you this while it builds. Answer from what the user said and what the record holds: reply with your answer (quote the user's words when they settle it). If the answer changes what the request asks, update its criteria first (request_operations update). If only the user can decide, reply with escalate: true and your recommended default in notes; the default must be safe to happen without them. When the question has no options, give the ways forward in questionContent.options."},22746(e,exports,t){exports.runSyncHold=async function(e){const{client:t,logger:n,messageCode:o,holdMs:s}=e,i=Date.now()+s,a=async e=>{try{await t.stampHoldOutcome(o,{holdDelivered:!0,clearHold:!0})}catch(e){n.warn("Hold claim failed; the arbiter may also inject this answer",{messageCode:o,error:(0,r.getErrorMessage)(e)})}return{kind:"answered",message:e}}
4359
4377
  let c=!1
4360
4378
  for(;Date.now()<i;){await new Promise(e=>setTimeout(e,3e3))
4361
4379
  let e=null
@@ -4392,7 +4410,7 @@ if("interactive"===n)return"interactive"}catch(e){t.warn("Failed to read project
4392
4410
  if("ask"===p||"interactive"===p){g.info("Returning planner choice pending",{planningMode:p})
4393
4411
  try{const e=m?.sessionId||i.sessionIdentity.getIdentity()?.sessionId,t=f?.getSessionMessageClient()
4394
4412
  if(t&&e){const r=await i.sessionIdentity.getParentSessionId(e,f,g),n=h.description||h.prompt
4395
- await t.createQuestion({fromSessionId:e,toSessionId:r||void 0,questionType:"alternatives",question:`Planning requested: ${n}`,options:[{id:"auto",label:"Auto Plan",description:"Spawn an autonomous planner agent"},{id:"manual",label:"Manual Plan",description:"Open the interactive plan editor"},{id:"cancel",label:"Skip",description:"Dismiss this planning request"}],context:{type:"planner-request",prompt:h.prompt,description:h.description},priority:"high"}),g.info("planner-request: notification created",{fromSessionId:e})}else g.warn("planner-request: skipping notification",{hasClient:!!t,hasCallerSessionId:!!e})}catch(e){g.warn("planner-request: failed to create notification",{error:(0,n.getErrorMessage)(e)})}v={content:[{type:"text",text:"Planning request submitted: nothing is running yet. The user must pick the planning approach (Auto Plan / Manual Plan / Skip) from a card in Steer before any planner starts. If you reply to the user, tell them the planning choice is waiting on them; do NOT say planning has started. (If the user themselves explicitly asked for this plan, pass userRequested: true to start it immediately.) This is non-blocking: continue with your other work."}],...(0,d.alchemyMeta)({pendingAction:{kind:"planner-choice",payload:{prompt:h.prompt,description:h.description}}})}
4413
+ await t.createQuestion({fromSessionId:e,toSessionId:r||void 0,questionType:"alternatives",question:`Planning requested: ${n}`,options:[{id:"auto",label:"Auto Plan",description:"A planner agent writes the plan; nothing is built until you start it"},{id:"manual",label:"Manual Plan",description:"You write the plan yourself in the plan editor"},{id:"cancel",label:"Skip",description:"No plan is made"}],context:{type:"planner-request",prompt:h.prompt,description:h.description},priority:"high"}),g.info("planner-request: notification created",{fromSessionId:e})}else g.warn("planner-request: skipping notification",{hasClient:!!t,hasCallerSessionId:!!e})}catch(e){g.warn("planner-request: failed to create notification",{error:(0,n.getErrorMessage)(e)})}v={content:[{type:"text",text:"Planning request submitted: nothing is running yet. The user must pick the planning approach (Auto Plan / Manual Plan / Skip) from a card in Steer before any planner starts. If you reply to the user, tell them the planning choice is waiting on them; do NOT say planning has started. (If the user themselves explicitly asked for this plan, pass userRequested: true to start it immediately.) This is non-blocking: continue with your other work."}],...(0,d.alchemyMeta)({pendingAction:{kind:"planner-choice",payload:{prompt:h.prompt,description:h.description}}})}
4396
4414
  break}const w="planner"
4397
4415
  let b=null
4398
4416
  if(h.documentId){const e=await f.getDocumentClient().getDocument(h.documentId)
@@ -4456,11 +4474,11 @@ return s.incrementCounter("research_fanout_request_success",1),c.info("research_
4456
4474
  const r=t(58824),n=t(6688)},1540(e,exports,t){exports.def=void 0
4457
4475
  const r=t(76183),n=t(51725),o=t(8955)
4458
4476
  exports.def={name:"subagent_operations",description:`WHEN TO USE spawn (agent: coder): any change touching 2+ files, feature work, bug fixes, or anything needing acceptance-criteria verification.\n\nManage background subagents that work independently.\n\nOperations:\n\u2022 spawn - Create a new detached subagent to work in the background. Include a short 'description' for display in the UI.\n\u2022 continue - Send new instructions/feedback to an existing subagent session\n\u2022 check-status - Check if a subagent is idle or busy\n\u2022 abort - Stop a running subagent\n\u2022 read-messages - Read a subagent's messages. Default: the latest message in full (its text AND tool calls), skipping trailing empty turns so you always get the substantive result. Add compact:true for a one-line index of EVERY message with tool-call markers (its trajectory: what it actually did), then select:N to pull one message in full ({tool, input, status, output} per step).\n\nThe spawned subagent runs as a separate OpenCode process.\n\nAvailable agents: ${(0,o.formatAgentsForDescription)()}`,schema:r.SubagentOperationsSchema,annotations:{title:"Subagent Operations",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1},handler:(e,t)=>(0,n.handleSubagentOperations)(e,t.context,t.logger,t.metrics,t.apiClient??void 0,t.cliOrigin)}},51725(e,exports,t){function r(e,t,r){if(_)try{const n=`[${(new Date).toISOString()}] ${t}${r?" "+JSON.stringify(r):""}\n`,o=(0,I.join)(e.basePath||process.cwd(),".alchemy_lab","spawn-debug.log");(0,k.appendFileSync)(o,n)}catch{}}async function n(e,r,n,o,s,i){if(!(e&&r&&n&&o))return null
4459
- try{const s=await e.proxyPost(`/api/projects/${r}/requests/${n}/pickup-compose`,{sessionId:o}),a=s?.data?.text??s?.text,c="string"==typeof a&&a.trim()?a.trim():null
4460
- if(c&&/Project map/.test(c))return c
4461
- let l=null
4477
+ try{const s=await e.proxyPost(`/api/projects/${r}/requests/${n}/pickup-compose`,{sessionId:o}),a=s?.data?.text??s?.text,{withInFlightFiles:c}=await t.e(912).then(()=>t(47912)),l=await c(i||process.cwd(),"string"==typeof a&&a.trim()?a.trim():null,s?.data?.inFlightWithoutFiles??s?.inFlightWithoutFiles)
4478
+ if(l&&/Project map/.test(l))return l
4479
+ let d=null
4462
4480
  try{const{generateProjectMap:e}=await t.e(356).then(()=>t.t(69356,23))
4463
- l=e(i||process.cwd())}catch{l=null}return c||l?[c,l].filter(Boolean).join("\n\n"):null}catch(e){return s.warn("pickup-compose failed; the association hook will deliver guidance as an inject",{requestId:n,error:(0,v.getErrorMessage)(e)}),null}}async function o(e){const{apiClient:t,fromSessionId:r,toSessionId:n,body:o,requestId:s,logger:i}=e
4481
+ d=e(i||process.cwd())}catch{d=null}return l||d?[l,d].filter(Boolean).join("\n\n"):null}catch(e){return s.warn("pickup-compose failed; the association hook will deliver guidance as an inject",{requestId:n,error:(0,v.getErrorMessage)(e)}),null}}async function o(e){const{apiClient:t,fromSessionId:r,toSessionId:n,body:o,requestId:s,logger:i}=e
4464
4482
  if(!t||!r)return
4465
4483
  const a=t.getSessionMessageClient()
4466
4484
  if(a)try{const e=await a.createInstruction({fromSessionId:r,toSessionId:n,body:o,...s?{requestId:s}:{}})
@@ -4851,134 +4869,135 @@ if(null!=e)for(var s=r(e),i=0;i<s.length;i++)"default"!==s[i]&&n(t,e,s[i])
4851
4869
  return o(t,e),t})
4852
4870
  Object.defineProperty(exports,"__esModule",{value:!0}),exports.testingDefs=void 0
4853
4871
  const i=s(t(76183)),a=t(89671),c=e=>(t,r)=>e(t,r.context,r.apiClient,r.logger,r.metrics,r.cliOrigin,{progressToken:r.progressToken,sendNotification:r.sendNotification})
4854
- exports.testingDefs=[{name:"testing_process_list",description:"List all test processes for this project. Shows active/inactive status, command count, and scope.",schema:i.TestingProcessListSchema,annotations:{title:"List Test Processes",readOnlyHint:!0},handler:c(a.handleTestingProcessList)},{name:"testing_process_get",description:"Get detailed configuration of a test process including setup and test commands.",schema:i.TestingProcessGetSchema,annotations:{title:"Get Test Process",readOnlyHint:!0},handler:c(a.handleTestingProcessGet)},{name:"testing_process_create",description:"Create a new test process with optional setup commands and one or more test commands. Each command has a name, shell command, required flag, and timeout.",schema:i.TestingProcessCreateSchema,annotations:{title:"Create Test Process",readOnlyHint:!1},handler:c(a.handleTestingProcessCreate)},{name:"testing_process_update",description:"Update an existing test process. Can modify name, description, scope, active status, and test configuration.",schema:i.TestingProcessUpdateSchema,annotations:{title:"Update Test Process",readOnlyHint:!1},handler:c(a.handleTestingProcessUpdate)},{name:"testing_process_delete",description:"Delete a test process. Removes the registered process from the project; existing test runs against it stay in the database. Use when you want to fully reset bootstrapping (e.g. before re-running `tests setup`) rather than toggling active state.",schema:i.TestingProcessDeleteSchema,annotations:{title:"Delete Test Process",readOnlyHint:!1,destructiveHint:!0},handler:c(a.handleTestingProcessDelete)},{name:"execute_test_command",description:'Execute a specific command from a configured test process. Use commandName="setup" to run all setup commands, or specify a test command name to run it. Only commands defined in the test process can be executed.',schema:i.ExecuteTestCommandSchema,annotations:{title:"Execute Test Command",readOnlyHint:!1},handler:c(a.handleExecuteTestCommand)},{name:"report_test_results",description:"Report the results of a test run. Call this after running all test commands to record pass/fail status and per-command results. The test run is auto-discovered from the current request context.",schema:i.ReportTestResultsSchema,annotations:{title:"Report Test Results",readOnlyHint:!1},handler:c(a.handleReportTestResults)},{name:"tests",description:"Test processes for this project. list: the registered processes. setup: spawns a setup-architect session that proposes a process for the user to confirm; inside a request it opens only when the request carries a gate criterion, once the check it names is on your branch; you get a report when it finishes. run: an async test run for your request, reported on your next turn. switch-off / switch-on: turn one check off or back on, on the user's quoted words (userSaid).",schema:i.TestsSchema,annotations:{title:"Tests",readOnlyHint:!1},handler:c(a.handleTests)}]},89671(e,exports,t){function r(e){return e.map(e=>{const t=Array.isArray(e.config?.commands)?e.config.commands:[],r=t.map(e=>"string"==typeof e?.command&&e.command.trim()?`\n - runs \`${e.command.trim()}\`${"number"==typeof e?.timeout?` (up to ${e.timeout}s)`:""}`:"").join("")
4855
- return`**${e.name}** (${e.id})${e.scope?` [scope: ${e.scope}]`:""}\n ${e.isActive?"\u2705 Active":"\u23f8 Inactive"}: ${t.length} command${1===t.length?"":"s"}${r}${e.description?`\n ${e.description}`:""}`}).join("\n\n")}async function n(e,t,r,n,o){if(!e||!n.git)return{}
4872
+ exports.testingDefs=[{name:"testing_process_list",description:"List all test processes for this project. Shows active/inactive status, command count, and scope.",schema:i.TestingProcessListSchema,annotations:{title:"List Test Processes",readOnlyHint:!0},handler:c(a.handleTestingProcessList)},{name:"testing_process_get",description:"Get detailed configuration of a test process including setup and test commands.",schema:i.TestingProcessGetSchema,annotations:{title:"Get Test Process",readOnlyHint:!0},handler:c(a.handleTestingProcessGet)},{name:"testing_process_create",description:"Create a new test process with optional setup commands and one or more test commands. Each command has a name, shell command, required flag, and timeout.",schema:i.TestingProcessCreateSchema,annotations:{title:"Create Test Process",readOnlyHint:!1},handler:c(a.handleTestingProcessCreate)},{name:"testing_process_update",description:"Update an existing test process. Can modify name, description, scope, active status, and test configuration.",schema:i.TestingProcessUpdateSchema,annotations:{title:"Update Test Process",readOnlyHint:!1},handler:c(a.handleTestingProcessUpdate)},{name:"testing_process_delete",description:"Delete a test process. Removes the registered process from the project; existing test runs against it stay in the database. Use when you want to fully reset bootstrapping (e.g. before re-running `tests setup`) rather than toggling active state.",schema:i.TestingProcessDeleteSchema,annotations:{title:"Delete Test Process",readOnlyHint:!1,destructiveHint:!0},handler:c(a.handleTestingProcessDelete)},{name:"execute_test_command",description:'Execute a specific command from a configured test process. Use commandName="setup" to run all setup commands, or specify a test command name to run it. Only commands defined in the test process can be executed.',schema:i.ExecuteTestCommandSchema,annotations:{title:"Execute Test Command",readOnlyHint:!1},handler:c(a.handleExecuteTestCommand)},{name:"report_test_results",description:"Report the results of a test run. Call this after running all test commands to record pass/fail status and per-command results. The test run is auto-discovered from the current request context.",schema:i.ReportTestResultsSchema,annotations:{title:"Report Test Results",readOnlyHint:!1},handler:c(a.handleReportTestResults)},{name:"tests",description:"Test processes for this project. list: the registered processes. setup: spawns a setup-architect session that proposes a process for the user to confirm; inside a request it opens only when the request carries a gate criterion, once the check it names is on your branch; you get a report when it finishes. run: an async test run for your request, reported on your next turn. switch-off / switch-on: turn one check off or back on, on the user's quoted words (userSaid).",schema:i.TestsSchema,annotations:{title:"Tests",readOnlyHint:!1},handler:c(a.handleTests)}]},89671(e,exports,t){async function r(e,t,r){try{const n=await(0,h.resolveRequestIdOrError)(t,r,e.currentSessionId,"no active request")
4873
+ return n?.ok&&n.requestId?`?forRequest=${encodeURIComponent(n.requestId)}`:""}catch{return""}}function n(e){return e.map(e=>{const t=Array.isArray(e.config?.commands)?e.config.commands:[],r=t.map(e=>"string"==typeof e?.command&&e.command.trim()?`\n - runs \`${e.command.trim()}\`${"number"==typeof e?.timeout?` (up to ${e.timeout}s)`:""}`:"").join("")
4874
+ return`**${e.name}** (${e.id})${e.scope?` [scope: ${e.scope}]`:""}\n ${e.isActive?"\u2705 Active":"\u23f8 Inactive"}: ${t.length} command${1===t.length?"":"s"}${r}${e.description?`\n ${e.description}`:""}`}).join("\n\n")}async function o(e,t,r,n,o){if(!e||!n.git)return{}
4856
4875
  let s
4857
4876
  try{const t=await o.proxyGet(`/api/projects/${n.projectId}/environments/${encodeURIComponent(e)}`)
4858
- s=(t?.data??t)?.config?.image}catch{return{}}const i=n.git,a=await(0,c.compareToFloor)(s,async e=>{try{return await i.raw(["show",`${t}:${e}`])}catch{return null}})
4877
+ s=(t?.data??t)?.config?.image}catch{return{}}const i=n.git,a=await(0,l.compareToFloor)(s,async e=>{try{return await i.raw(["show",`${t}:${e}`])}catch{return null}})
4859
4878
  if("unknown"===a.status||!a.runsOn)return{}
4860
- const l=`${a.runsOn.runtime} ${a.runsOn.version}`,d={runsOn:l,...a.floor?{floor:`${a.floor.runtime} ${a.floor.version}`,floorSource:a.floor.source}:{}}
4879
+ const c=`${a.runsOn.runtime} ${a.runsOn.version}`,d={runsOn:c,...a.floor?{floor:`${a.floor.runtime} ${a.floor.version}`,floorSource:a.floor.source}:{}}
4861
4880
  if("match"===a.status)return{record:d}
4862
- if(String(r||"").trim().toLowerCase().replace(/\s+/g," ")===l)return{record:{...d,keptByUser:!0}}
4863
- const u=c.RUNTIME_LABEL[a.runsOn.runtime],h=a.floor.version
4864
- return{refuse:`Not registered: ${a.message}\n\nAsk the user before registering. The proposal question says this in plain words and offers the floor as an option, e.g. {id:"floor", label:"Run it on ${u} ${h}"} next to {id:"keep", label:"Keep ${u} ${a.runsOn.version}"}. If they pick the floor, set up an environment from ${a.suggestedImage} (environment_verify with the check's commands, then create it) and register the check with that environment. If they keep ${u} ${a.runsOn.version}, call again with runtimeKept: "${l}". Offer one version, the floor; propose a matrix of versions only when the user asks for one.`}}exports.handleTestingProcessList=async function(e,t,n,s,i){const a=i.startTimer("tool_execution_time")
4865
- try{const e=await n.proxyGet(`/api/projects/${t.projectId}/test-processes`),o=e?.data||e||[],s=Array.isArray(o)?o:[]
4866
- if(0===s.length)return a({success:!0}),{content:[{type:"text",text:"No test processes configured for this project yet. Use `testing_process_create` to create one."}]}
4867
- const i=r(s)
4868
- return a({success:!0}),{content:[{type:"text",text:`## Test Processes (${s.length})\n\n${i}`}]}}catch(e){return a({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to list test processes: ${(0,o.getErrorMessage)(e)}`}],isError:!0}}},exports.handleTestingProcessGet=async function(e,t,r,n,s){const i=s.startTimer("tool_execution_time")
4869
- try{const n=await r.proxyGet(`/api/projects/${t.projectId}/test-processes/${e.processId}`),process=n?.data||n
4870
- if(!process)return i({success:!1,error:"not_found"}),{content:[{type:"text",text:`Test process not found: ${e.processId}`}],isError:!0}
4871
- const o=process.config||{},s=o.commands||[]
4872
- let a=`## ${process.name}\n`
4873
- process.description&&(a+=`${process.description}\n`),process.scope&&(a+=`**Scope:** \`${process.scope}\`\n`),a+=`**Status:** ${process.isActive?"Active":"Inactive"}\n\n`,o.setup?.length&&(a+=`### Setup\n${o.setup.map(e=>`\`\`\`\n${e}\n\`\`\``).join("\n")}\n\n`),a+=`### Test Commands (${s.length})\n`
4874
- for(let e=0;e<s.length;e++){const t=s[e]
4875
- a+=`\n**${e+1}. ${t.name}**${t.required?": REQUIRED":": optional"}\n`,a+=` Command: \`${t.command}\`\n`,t.timeout&&(a+=` Timeout: ${t.timeout}s\n`)}return Array.isArray(o.fingerprint)&&o.fingerprint.length>0&&(a+=`\n### Fingerprint Files\n${o.fingerprint.map(e=>`- \`${e}\``).join("\n")}\n`),"number"==typeof o.poolSize&&(a+=`\n**Pool size:** ${o.poolSize}\n`),i({success:!0}),{content:[{type:"text",text:a}]}}catch(e){return i({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to get test process: ${(0,o.getErrorMessage)(e)}`}],isError:!0}}},exports.handleTestingProcessCreate=async function(e,r,s,i,a){const c=a.startTimer("tool_execution_time")
4881
+ if(String(r||"").trim().toLowerCase().replace(/\s+/g," ")===c)return{record:{...d,keptByUser:!0}}
4882
+ const u=l.RUNTIME_LABEL[a.runsOn.runtime],h=a.floor.version
4883
+ return{refuse:`Not registered: ${a.message}\n\nAsk the user before registering. The proposal question says this in plain words and offers the floor as an option, e.g. {id:"floor", label:"Run it on ${u} ${h}"} next to {id:"keep", label:"Keep ${u} ${a.runsOn.version}"}. If they pick the floor, set up an environment from ${a.suggestedImage} (environment_verify with the check's commands, then create it) and register the check with that environment. If they keep ${u} ${a.runsOn.version}, call again with runtimeKept: "${c}". Offer one version, the floor; propose a matrix of versions only when the user asks for one.`}}exports.handleTestingProcessList=async function(e,t,o,i,a){const c=a.startTimer("tool_execution_time")
4884
+ try{const e=await o.proxyGet(`/api/projects/${t.projectId}/test-processes${await r(t,o,i)}`),s=e?.data||e||[],a=Array.isArray(s)?s:[]
4885
+ if(0===a.length)return c({success:!0}),{content:[{type:"text",text:"No test processes configured for this project yet. Use `testing_process_create` to create one."}]}
4886
+ const l=n(a)
4887
+ return c({success:!0}),{content:[{type:"text",text:`## Test Processes (${a.length})\n\n${l}`}]}}catch(e){return c({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to list test processes: ${(0,s.getErrorMessage)(e)}`}],isError:!0}}},exports.handleTestingProcessGet=async function(e,t,n,o,i){const a=i.startTimer("tool_execution_time")
4888
+ try{const s=await n.proxyGet(`/api/projects/${t.projectId}/test-processes/${e.processId}${await r(t,n,o)}`),process=s?.data||s
4889
+ if(!process)return a({success:!1,error:"not_found"}),{content:[{type:"text",text:`Test process not found: ${e.processId}`}],isError:!0}
4890
+ const i=process.config||{},c=i.commands||[]
4891
+ let l=`## ${process.name}\n`
4892
+ process.description&&(l+=`${process.description}\n`),process.scope&&(l+=`**Scope:** \`${process.scope}\`\n`),l+=`**Status:** ${process.isActive?"Active":"Inactive"}\n\n`,i.setup?.length&&(l+=`### Setup\n${i.setup.map(e=>`\`\`\`\n${e}\n\`\`\``).join("\n")}\n\n`),l+=`### Test Commands (${c.length})\n`
4893
+ for(let e=0;e<c.length;e++){const t=c[e]
4894
+ l+=`\n**${e+1}. ${t.name}**${t.required?": REQUIRED":": optional"}\n`,l+=` Command: \`${t.command}\`\n`,t.timeout&&(l+=` Timeout: ${t.timeout}s\n`)}return Array.isArray(i.fingerprint)&&i.fingerprint.length>0&&(l+=`\n### Fingerprint Files\n${i.fingerprint.map(e=>`- \`${e}\``).join("\n")}\n`),"number"==typeof i.poolSize&&(l+=`\n**Pool size:** ${i.poolSize}\n`),Array.isArray(i.leavesOut)&&i.leavesOut.length>0&&(l+=`\n### Left out (not run by this check)\n${i.leavesOut.map(e=>`- ${e?.what}: ${(e?.paths??[]).map(e=>`\`${e}\``).join(", ")}`).join("\n")}\n`),a({success:!0}),{content:[{type:"text",text:l}]}}catch(e){return a({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to get test process: ${(0,s.getErrorMessage)(e)}`}],isError:!0}}},exports.handleTestingProcessCreate=async function(e,r,n,i,a){const c=a.startTimer("tool_execution_time")
4876
4895
  try{const a={setup:e.setup||[],commands:e.commands.map(e=>({name:e.name,command:e.command,required:!1!==e.required,timeout:e.timeout||300}))}
4877
- void 0!==e.fingerprint&&(a.fingerprint=e.fingerprint),void 0!==e.poolSize&&(a.poolSize=e.poolSize)
4896
+ void 0!==e.fingerprint&&(a.fingerprint=e.fingerprint),void 0!==e.poolSize&&(a.poolSize=e.poolSize),e.leavesOut?.length&&(a.leavesOut=e.leavesOut)
4878
4897
  try{const e=r.currentSessionId
4879
- if(e){const t=await s.proxyGet(`/api/projects/${r.projectId}/session-request-associations/by-session/${encodeURIComponent(e)}?activeOnly=true`),n=(Array.isArray(t?.data)?t.data:Array.isArray(t)?t:[]).map(e=>e.requestLocalId??e.request_local_id).find(e=>"string"==typeof e&&/^req\d{6}$/.test(e))
4880
- n&&(a.originRequest=n)}}catch{}let d=""
4881
- if(void 0===e.fingerprint){const e=a.originRequest?`requests/${a.originRequest}`:await(0,l.resolveDefaultBranch)(r.mainBasePath,r.gitBinary).catch(()=>"HEAD"),t=await async function(e,t,r){if(!e||!function(e){const t=e.flatMap(e=>e.split(/&&|;/)).map(e=>e.trim()).filter(Boolean)
4898
+ if(e){const t=await n.proxyGet(`/api/projects/${r.projectId}/session-request-associations/by-session/${encodeURIComponent(e)}?activeOnly=true`),o=(Array.isArray(t?.data)?t.data:Array.isArray(t)?t:[]).map(e=>e.requestLocalId??e.request_local_id).find(e=>"string"==typeof e&&/^req\d{6}$/.test(e))
4899
+ o&&(a.originRequest=o)}}catch{}let l=""
4900
+ if(void 0===e.fingerprint){const e=a.originRequest?`requests/${a.originRequest}`:await(0,d.resolveDefaultBranch)(r.mainBasePath,r.gitBinary).catch(()=>"HEAD"),t=await async function(e,t,r){if(!e||!function(e){const t=e.flatMap(e=>e.split(/&&|;/)).map(e=>e.trim()).filter(Boolean)
4882
4901
  return t.length>0&&t.every(e=>{const[t,...r]=e.split(/\s+/)
4883
4902
  if("go"===t)return"mod download"===r.join(" ")
4884
4903
  if(("pip"===t||"pip3"===t)&&"install"===r[0])return/^install -r \S+$/.test(r.join(" "))
4885
4904
  const n=r.filter(e=>!e.startsWith("-"))
4886
- return n.length<=1&&(h[t]??[]).includes(n[0]??"")})}(r))return null
4887
- try{const r=new Set((await e.raw(["ls-tree","--name-only",t])).split("\n").map(e=>e.trim())),n=u.filter(e=>r.has(e))
4905
+ return n.length<=1&&(f[t]??[]).includes(n[0]??"")})}(r))return null
4906
+ try{const r=new Set((await e.raw(["ls-tree","--name-only",t])).split("\n").map(e=>e.trim())),n=p.filter(e=>r.has(e))
4888
4907
  return n.length>0?n:null}catch{return null}}(r.git,e,a.setup)
4889
- t&&(a.fingerprint=t,d=`\nFingerprint not given, so it was set to the repository's lockfiles: ${t.map(e=>`\`${e}\``).join(", ")}. Setup now re-runs only when one of them changes; pass fingerprint: [] to run it every time.`)}const p=e.environmentId
4890
- {const t=a.originRequest?`requests/${a.originRequest}`:await(0,l.resolveDefaultBranch)(r.mainBasePath,r.gitBinary).catch(()=>"HEAD"),o=await n("string"==typeof p?p:void 0,t,e.runtimeKept,r,s)
4891
- if(o.refuse)return c({success:!1,error:"runtime_floor"}),{content:[{type:"text",text:o.refuse}],isError:!0}
4892
- o.record&&(a.runtime=o.record)}let f=""
4893
- if("string"==typeof p&&p&&r.currentSessionId){const{trialRun:e,trialFailures:n}=await t.e(579).then(()=>t(74579)),o=await e({sessionId:r.currentSessionId,environmentId:p,...a.originRequest?{branchName:`requests/${a.originRequest}`}:{},setup:a.setup,commands:a.commands})
4908
+ t&&(a.fingerprint=t,l=`\nFingerprint not given, so it was set to the repository's lockfiles: ${t.map(e=>`\`${e}\``).join(", ")}. Setup now re-runs only when one of them changes; pass fingerprint: [] to run it every time.`)}const u=e.environmentId
4909
+ {const t=a.originRequest?`requests/${a.originRequest}`:await(0,d.resolveDefaultBranch)(r.mainBasePath,r.gitBinary).catch(()=>"HEAD"),s=await o("string"==typeof u?u:void 0,t,e.runtimeKept,r,n)
4910
+ if(s.refuse)return c({success:!1,error:"runtime_floor"}),{content:[{type:"text",text:s.refuse}],isError:!0}
4911
+ s.record&&(a.runtime=s.record)}let h=""
4912
+ if("string"==typeof u&&u&&r.currentSessionId){const{trialRun:e,trialFailures:n}=await t.e(579).then(()=>t(74579)),o=await e({sessionId:r.currentSessionId,environmentId:u,...a.originRequest?{branchName:`requests/${a.originRequest}`}:{},setup:a.setup,commands:a.commands})
4894
4913
  if(o){const e=n(o)
4895
4914
  if(e.length>0)return c({success:!1,error:"trial_failed"}),{content:[{type:"text",text:`Not registered: the check was tried once in its environment first, and it cannot run there as written:\n${e.map(e=>`- ${e}`).join("\n")}\n\nPick an environment that has what the commands need (environment_list), or change the commands, then create it again. Tell the user in plain words if what they asked for cannot run in any environment yet.`}],isError:!0}
4896
- f=`\nTried once in its environment first: ${o.map(e=>`${e.name} exit ${e.exit}`).join(", ")}.`}else f="\n\u26a0\ufe0f Could not try it before registering (no box started); its first real run is its first trial."}const m=await s.proxyPost(`/api/projects/${r.projectId}/test-processes`,{name:e.name,description:e.description,scope:e.scope,pathGlobs:e.pathGlobs,areas:e.areas,config:a,environmentId:e.environmentId,createdBy:"setup-architect"}),process=m?.data||m
4897
- try{const{sessionIdentity:e}=await Promise.resolve().then(()=>t(6688)),n=e.getIdentity()
4898
- n?.sessionId&&process?.id&&await s.proxyPost(`/api/projects/${r.projectId}/session-test-process-associations`,{opencodeSessionId:n.sessionId,testProcessId:process.id})}catch(e){i.warn("Failed to write session-test-process association",{error:(0,o.getErrorMessage)(e)})}return c({success:!0}),{content:[{type:"text",text:`\u2705 Created test process **${process.name}** (${process.id}) with ${a.commands.length} test commands.${e.scope?`\nLabel (display only): \`${e.scope}\``:""}\n${e.pathGlobs?.length||e.areas?.length?`Runs when a change matches: ${[...e.pathGlobs||[],...(e.areas||[]).map(e=>`area ${e}`)].join(", ")}`:'\u26a0\ufe0f UNSCOPED: this runs on EVERY change to the project. If it should only run for some changes, set pathGlobs (e.g. ["sites/**"]).'}${f}${d}\n\nThe process is now active and will run when requests are completed.`}]}}catch(e){return c({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to create test process: ${(0,o.getErrorMessage)(e)}`}],isError:!0}}},exports.handleTestingProcessUpdate=async function(e,r,s,i,a){const c=a.startTimer("tool_execution_time")
4899
- try{const o={}
4900
- if(void 0!==e.name&&(o.name=e.name),void 0!==e.description&&(o.description=e.description),void 0!==e.scope&&(o.scope=e.scope),void 0!==e.pathGlobs&&(o.pathGlobs=e.pathGlobs),void 0!==e.areas&&(o.areas=e.areas),void 0!==e.isActive){let t=""
4901
- try{const e=r.currentSessionId,n=e?await s.proxyGet(`/api/projects/${r.projectId}/cli-sessions/external/opencode/${encodeURIComponent(e)}`):null
4902
- t=String((n?.data??n)?.agentType??"")}catch{t=""}if("alchemist"!==t)return{content:[{type:"text",text:"Refused: activating or deactivating a test process is the user's call, not the worker's -- it decides which checks may prove criteria and satisfy the test gate. Ask the user (question tool); they can toggle it in Settings, or tell the Alchemist in so many words."}],isError:!0}
4903
- o.isActive=e.isActive,i.info("testing_process_update: activation changed by the hub on the user's instruction",{processId:e.processId,isActive:e.isActive})}let a
4904
- void 0!==e.environmentId&&(o.environmentId=e.environmentId)
4905
- const d=e.environmentId
4906
- if("string"==typeof d&&d){let t="HEAD"
4907
- try{const n=await s.proxyGet(`/api/projects/${r.projectId}/test-processes/${e.processId}`),o=(n?.data??n)?.config?.originRequest
4908
- t="string"==typeof o&&o?`requests/${o}`:await(0,l.resolveDefaultBranch)(r.mainBasePath,r.gitBinary).catch(()=>"HEAD")}catch{t=await(0,l.resolveDefaultBranch)(r.mainBasePath,r.gitBinary).catch(()=>"HEAD")}const o=await n(d,t,e.runtimeKept,r,s)
4909
- if(o.refuse)return c({success:!1,error:"runtime_floor"}),{content:[{type:"text",text:o.refuse}],isError:!0}
4910
- a=o.record??{}}if(void 0!==e.commands||void 0!==e.setup||void 0!==e.fingerprint||void 0!==e.poolSize||void 0!==a){const n=await s.proxyGet(`/api/projects/${r.projectId}/test-processes/${e.processId}`),c=n?.data||n,l=c?.config||{},d={setup:e.setup??l.setup??[],commands:e.commands?e.commands.map(e=>({name:e.name,command:e.command,required:!1!==e.required,timeout:e.timeout||300})):l.commands??[]}
4911
- void 0!==e.fingerprint?d.fingerprint=e.fingerprint:void 0!==l.fingerprint&&(d.fingerprint=l.fingerprint),void 0!==e.poolSize?d.poolSize=e.poolSize:void 0!==l.poolSize&&(d.poolSize=l.poolSize),void 0!==l.verifyAcceptanceCriteria&&(d.verifyAcceptanceCriteria=l.verifyAcceptanceCriteria),void 0!==l.originRequest&&(d.originRequest=l.originRequest),void 0!==a?Object.keys(a).length&&(d.runtime=a):void 0!==l.runtime&&(d.runtime=l.runtime),o.config=d
4912
- try{const{resolveRequestIdOrError:e}=await Promise.resolve().then(()=>t(36651)),n=await e(s,i,r.currentSessionId,"no active request")
4913
- n?.ok&&n.requestId&&(o.changedFor=n.requestId)}catch{}}const u=await s.proxyPatch(`/api/projects/${r.projectId}/test-processes/${e.processId}`,o),process=u?.data||u
4914
- return c({success:!0}),{content:[{type:"text",text:`\u2705 Updated test process **${process.name}** (${process.id}).`}]}}catch(e){return c({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to update test process: ${(0,o.getErrorMessage)(e)}`}],isError:!0}}},exports.handleExecuteTestCommand=async function(e,r,n,s,i,c,l){const d=i.startTimer("tool_execution_time"),u=s.child({tool:"execute_test_command"})
4915
- try{const i=await n.proxyGet(`/api/projects/${r.projectId}/test-processes/${e.processId}`),process=i?.data||i
4916
- if(!process?.config)return d({success:!1,error:"not_found"}),{content:[{type:"text",text:`Test process ${e.processId} not found or has no config.`}],isError:!0}
4917
- let h
4915
+ h=`\nTried once in its environment first: ${o.map(e=>`${e.name} exit ${e.exit}`).join(", ")}.`}else h="\n\u26a0\ufe0f Could not try it before registering (no box started); its first real run is its first trial."}const m=await n.proxyPost(`/api/projects/${r.projectId}/test-processes`,{name:e.name,description:e.description,scope:e.scope,pathGlobs:e.pathGlobs,areas:e.areas,config:a,environmentId:e.environmentId,createdBy:"setup-architect"}),process=m?.data||m
4916
+ try{const{sessionIdentity:e}=await Promise.resolve().then(()=>t(6688)),o=e.getIdentity()
4917
+ o?.sessionId&&process?.id&&await n.proxyPost(`/api/projects/${r.projectId}/session-test-process-associations`,{opencodeSessionId:o.sessionId,testProcessId:process.id})}catch(e){i.warn("Failed to write session-test-process association",{error:(0,s.getErrorMessage)(e)})}return c({success:!0}),{content:[{type:"text",text:`\u2705 Created test process **${process.name}** (${process.id}) with ${a.commands.length} test commands.${e.scope?`\nLabel (display only): \`${e.scope}\``:""}\n${e.pathGlobs?.length||e.areas?.length?`Runs when a change matches: ${[...e.pathGlobs||[],...(e.areas||[]).map(e=>`area ${e}`)].join(", ")}`:'\u26a0\ufe0f UNSCOPED: this runs on EVERY change to the project. If it should only run for some changes, set pathGlobs (e.g. ["sites/**"]).'}${h}${l}\n\nThe process is now active and will run when requests are completed.`}]}}catch(e){return c({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to create test process: ${(0,s.getErrorMessage)(e)}`}],isError:!0}}},exports.handleTestingProcessUpdate=async function(e,t,n,i,a){const c=a.startTimer("tool_execution_time")
4918
+ try{const s={}
4919
+ if(void 0!==e.name&&(s.name=e.name),void 0!==e.description&&(s.description=e.description),void 0!==e.scope&&(s.scope=e.scope),void 0!==e.pathGlobs&&(s.pathGlobs=e.pathGlobs),void 0!==e.areas&&(s.areas=e.areas),void 0!==e.isActive){let r=""
4920
+ try{const e=t.currentSessionId,o=e?await n.proxyGet(`/api/projects/${t.projectId}/cli-sessions/external/opencode/${encodeURIComponent(e)}`):null
4921
+ r=String((o?.data??o)?.agentType??"")}catch{r=""}if("alchemist"!==r)return{content:[{type:"text",text:"Refused: activating or deactivating a test process is the user's call, not the worker's -- it decides which checks may prove criteria and satisfy the test gate. Ask the user (question tool); they can toggle it in Settings, or tell the Alchemist in so many words."}],isError:!0}
4922
+ s.isActive=e.isActive,i.info("testing_process_update: activation changed by the hub on the user's instruction",{processId:e.processId,isActive:e.isActive})}let a
4923
+ void 0!==e.environmentId&&(s.environmentId=e.environmentId)
4924
+ const l=e.environmentId
4925
+ if("string"==typeof l&&l){let s="HEAD"
4926
+ try{const o=await n.proxyGet(`/api/projects/${t.projectId}/test-processes/${e.processId}${await r(t,n,i)}`),a=(o?.data??o)?.config?.originRequest
4927
+ s="string"==typeof a&&a?`requests/${a}`:await(0,d.resolveDefaultBranch)(t.mainBasePath,t.gitBinary).catch(()=>"HEAD")}catch{s=await(0,d.resolveDefaultBranch)(t.mainBasePath,t.gitBinary).catch(()=>"HEAD")}const u=await o(l,s,e.runtimeKept,t,n)
4928
+ if(u.refuse)return c({success:!1,error:"runtime_floor"}),{content:[{type:"text",text:u.refuse}],isError:!0}
4929
+ a=u.record??{}}if(void 0!==e.commands||void 0!==e.setup||void 0!==e.fingerprint||void 0!==e.poolSize||void 0!==e.leavesOut||void 0!==a){const o=await n.proxyGet(`/api/projects/${t.projectId}/test-processes/${e.processId}${await r(t,n,i)}`),c=o?.data||o,l=c?.config||{},d={setup:e.setup??l.setup??[],commands:e.commands?e.commands.map(e=>({name:e.name,command:e.command,required:!1!==e.required,timeout:e.timeout||300})):l.commands??[]}
4930
+ void 0!==e.fingerprint?d.fingerprint=e.fingerprint:void 0!==l.fingerprint&&(d.fingerprint=l.fingerprint),void 0!==e.poolSize?d.poolSize=e.poolSize:void 0!==l.poolSize&&(d.poolSize=l.poolSize),void 0!==l.verifyAcceptanceCriteria&&(d.verifyAcceptanceCriteria=l.verifyAcceptanceCriteria),void 0!==l.originRequest&&(d.originRequest=l.originRequest),void 0!==e.leavesOut?d.leavesOut=e.leavesOut:void 0!==l.leavesOut&&(d.leavesOut=l.leavesOut),void 0!==a?Object.keys(a).length&&(d.runtime=a):void 0!==l.runtime&&(d.runtime=l.runtime),s.config=d
4931
+ try{const e=await(0,h.resolveRequestIdOrError)(n,i,t.currentSessionId,"no active request")
4932
+ e?.ok&&e.requestId&&(s.changedFor=e.requestId)}catch{}}const u=await n.proxyPatch(`/api/projects/${t.projectId}/test-processes/${e.processId}`,s),process=u?.data||u
4933
+ return c({success:!0}),{content:[{type:"text",text:`\u2705 Updated test process **${process.name}** (${process.id}).`}]}}catch(e){return c({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to update test process: ${(0,s.getErrorMessage)(e)}`}],isError:!0}}},exports.handleExecuteTestCommand=async function(e,n,o,i,a,l,d){const u=a.startTimer("tool_execution_time"),h=i.child({tool:"execute_test_command"})
4934
+ try{const a=await o.proxyGet(`/api/projects/${n.projectId}/test-processes/${e.processId}${await r(n,o,h)}`),process=a?.data||a
4935
+ if(!process?.config)return u({success:!1,error:"not_found"}),{content:[{type:"text",text:`Test process ${e.processId} not found or has no config.`}],isError:!0}
4936
+ let p
4918
4937
  if("setup"===e.commandName){const e=process.config.setup||[]
4919
- if(0===e.length)return d({success:!0}),{content:[{type:"text",text:"No setup commands configured for this test process."}]}
4920
- h=e.map((e,t)=>({name:`setup-${t+1}`,command:e,timeout:120}))}else{const t=process.config.commands||[],r=t.find(t=>t.name===e.commandName)
4938
+ if(0===e.length)return u({success:!0}),{content:[{type:"text",text:"No setup commands configured for this test process."}]}
4939
+ p=e.map((e,t)=>({name:`setup-${t+1}`,command:e,timeout:120}))}else{const t=process.config.commands||[],r=t.find(t=>t.name===e.commandName)
4921
4940
  if(!r){const r=t.map(e=>e.name).join(", ")
4922
- return d({success:!1,error:"command_not_found"}),{content:[{type:"text",text:`Command "${e.commandName}" not found in test process "${process.name}".\nAvailable commands: ${r}\nUse "setup" to run setup commands.`}],isError:!0}}h=[{name:r.name,command:r.command,timeout:r.timeout||300}]}const{runShellCommand:p}=await Promise.resolve().then(()=>t(44600)),f=globalThis.process
4923
- let m=null
4924
- const g=[]
4925
- try{const{sessionIdentity:e}=await Promise.resolve().then(()=>t(6688)),o=c?.sessionId??e.getIdentity()?.sessionId
4926
- if(g.push(`session: ${o||"NONE"}`),o){const t=await e.getSessionRequestId(n,s,o)
4927
- if(g.push(`reqId: ${t||"NONE"}`),t){const e=await n.proxyGet(`/api/projects/${r.projectId}/requests/${t}/test-runs`),o=e?.data||e||[],s=Array.isArray(o)?o.find(e=>e.worktreePath||e.worktree_path):null
4928
- g.push(`runs: ${Array.isArray(o)?o.length:0}, withWorktree: ${s?.id||"NONE"}, path: ${s?.worktreePath||s?.worktree_path||"NONE"}`),s&&(m=s.worktreePath||s.worktree_path,u.info("Using test worktree from request test run",{worktreePath:m,reqId:t}))}}}catch(e){u.warn("Failed to resolve test worktree",{error:(0,o.getErrorMessage)(e)})}if(!m)return d({success:!1,error:"no_worktree"}),{content:[{type:"text",text:`No test worktree found.\n\nDiagnostics:\n${g.length>0?g.map(e=>`\u2022 ${e}`).join("\n"):"\u2022 No session identity found"}\n\nEnsure this session is linked to a test process and a test run has been created.`}],isError:!0}
4929
- const y=[],{default:w}=await Promise.resolve().then(()=>t.t(16928,23)),{default:b}=await Promise.resolve().then(()=>t.t(79896,23)),{ALCHEMY_DIR_NAME:v}=await Promise.resolve().then(()=>t(14139)),k=w.join(m,v,"command-logs")
4930
- try{b.mkdirSync(k,{recursive:!0})}catch{}const{runTrackedShellCommand:I}=await Promise.resolve().then(()=>t(44600)),{formatCombinedOutput:$}=await t.e(816).then(()=>t(1816)),{sessionIdentity:S}=await Promise.resolve().then(()=>t(6688)),E=c?.sessionId??S.getIdentity()?.sessionId
4931
- for(const t of h){u.info("Executing test command",{name:t.name,command:t.command,timeout:t.timeout,cwd:m})
4932
- const r=`${t.name.replace(/[^a-zA-Z0-9._-]/g,"_")}-${Date.now()}`,n=w.join(k,`${r}.log`)
4941
+ return u({success:!1,error:"command_not_found"}),{content:[{type:"text",text:`Command "${e.commandName}" not found in test process "${process.name}".\nAvailable commands: ${r}\nUse "setup" to run setup commands.`}],isError:!0}}p=[{name:r.name,command:r.command,timeout:r.timeout||300}]}const{runShellCommand:f}=await Promise.resolve().then(()=>t(44600)),m=globalThis.process
4942
+ let g=null
4943
+ const y=[]
4944
+ try{const{sessionIdentity:e}=await Promise.resolve().then(()=>t(6688)),r=l?.sessionId??e.getIdentity()?.sessionId
4945
+ if(y.push(`session: ${r||"NONE"}`),r){const t=await e.getSessionRequestId(o,i,r)
4946
+ if(y.push(`reqId: ${t||"NONE"}`),t){const e=await o.proxyGet(`/api/projects/${n.projectId}/requests/${t}/test-runs`),r=e?.data||e||[],s=Array.isArray(r)?r.find(e=>e.worktreePath||e.worktree_path):null
4947
+ y.push(`runs: ${Array.isArray(r)?r.length:0}, withWorktree: ${s?.id||"NONE"}, path: ${s?.worktreePath||s?.worktree_path||"NONE"}`),s&&(g=s.worktreePath||s.worktree_path,h.info("Using test worktree from request test run",{worktreePath:g,reqId:t}))}}}catch(e){h.warn("Failed to resolve test worktree",{error:(0,s.getErrorMessage)(e)})}if(!g)return u({success:!1,error:"no_worktree"}),{content:[{type:"text",text:`No test worktree found.\n\nDiagnostics:\n${y.length>0?y.map(e=>`\u2022 ${e}`).join("\n"):"\u2022 No session identity found"}\n\nEnsure this session is linked to a test process and a test run has been created.`}],isError:!0}
4948
+ const w=[],{default:b}=await Promise.resolve().then(()=>t.t(16928,23)),{default:v}=await Promise.resolve().then(()=>t.t(79896,23)),{ALCHEMY_DIR_NAME:k}=await Promise.resolve().then(()=>t(14139)),I=b.join(g,k,"command-logs")
4949
+ try{v.mkdirSync(I,{recursive:!0})}catch{}const{runTrackedShellCommand:$}=await Promise.resolve().then(()=>t(44600)),{formatCombinedOutput:S}=await t.e(816).then(()=>t(1816)),{sessionIdentity:E}=await Promise.resolve().then(()=>t(6688)),_=l?.sessionId??E.getIdentity()?.sessionId
4950
+ for(const t of p){h.info("Executing test command",{name:t.name,command:t.command,timeout:t.timeout,cwd:g})
4951
+ const r=`${t.name.replace(/[^a-zA-Z0-9._-]/g,"_")}-${Date.now()}`,n=b.join(I,`${r}.log`)
4933
4952
  let o=null
4934
- try{o=b.createWriteStream(n,{flags:"w"}),o.write(`# ${(new Date).toISOString()} starting: ${t.command}\n# cwd: ${m}\n# timeout: ${t.timeout}s\n\n`)}catch(e){u.warn("Failed to open command log file",{logPath:n,error:String(e)})}const s=await(0,a.runTrackedShellWithHeartbeat)(t.command,{cwd:m,timeoutMs:1e3*t.timeout,env:{...f.env,FORCE_COLOR:"0"},onChunk:o?(e,t)=>{o?.write(t)}:void 0},{id:r,name:t.name,sessionId:E,logPath:n},l)
4953
+ try{o=v.createWriteStream(n,{flags:"w"}),o.write(`# ${(new Date).toISOString()} starting: ${t.command}\n# cwd: ${g}\n# timeout: ${t.timeout}s\n\n`)}catch(e){h.warn("Failed to open command log file",{logPath:n,error:String(e)})}const s=await(0,c.runTrackedShellWithHeartbeat)(t.command,{cwd:g,timeoutMs:1e3*t.timeout,env:{...m.env,FORCE_COLOR:"0"},onChunk:o?(e,t)=>{o?.write(t)}:void 0},{id:r,name:t.name,sessionId:_,logPath:n},d)
4935
4954
  o&&(o.write(`\n# exit: ${s.exitCode}${s.timedOut?" (timed out)":""}\n`),o.end())
4936
- const i=(s.stdout+(s.stderr?"\n"+s.stderr:"")).trim(),{output:c,truncatedNote:d,logFooter:h}=$(i,{invocationId:r})
4937
- if(y.push({name:t.name,command:t.command,exitCode:s.exitCode,output:c,timedOut:s.timedOut,invocationId:r,truncatedNote:d,logFooter:h}),"setup"===e.commandName&&0!==s.exitCode)break}const _=y.every(e=>0===e.exitCode),x=y.map(e=>{const t=e.timedOut?"\u23f1 TIMEOUT":0===e.exitCode?"\u2705 PASS":`\u274c FAIL (exit ${e.exitCode})`
4955
+ const i=(s.stdout+(s.stderr?"\n"+s.stderr:"")).trim(),{output:a,truncatedNote:l,logFooter:u}=S(i,{invocationId:r})
4956
+ if(w.push({name:t.name,command:t.command,exitCode:s.exitCode,output:a,timedOut:s.timedOut,invocationId:r,truncatedNote:l,logFooter:u}),"setup"===e.commandName&&0!==s.exitCode)break}const x=w.every(e=>0===e.exitCode),C=w.map(e=>{const t=e.timedOut?"\u23f1 TIMEOUT":0===e.exitCode?"\u2705 PASS":`\u274c FAIL (exit ${e.exitCode})`
4938
4957
  return`### ${e.name}: ${t}\n\`\`\`\n$ ${e.command}\n${e.output}\n\`\`\`${e.truncatedNote}\n${e.logFooter}`}).join("\n\n")
4939
- return d({success:!0}),{content:[{type:"text",text:`## ${"setup"===e.commandName?"Setup":e.commandName}: ${_?"PASSED":"FAILED"}\n\n${x}`}]}}catch(e){return d({success:!1,error:"execution_error"}),{content:[{type:"text",text:`Failed to execute test command: ${(0,o.getErrorMessage)(e)}`}],isError:!0}}},exports.handleReportTestResults=async function(e,r,n,i,a,c){const l=a.startTimer("tool_execution_time")
4940
- try{const{resolveRequestIdOrError:a}=await Promise.resolve().then(()=>t(36651)),d=await a(n,i,c?.sessionId,"Cannot report test results: this session is not associated with a request.")
4958
+ return u({success:!0}),{content:[{type:"text",text:`## ${"setup"===e.commandName?"Setup":e.commandName}: ${x?"PASSED":"FAILED"}\n\n${C}`}]}}catch(e){return u({success:!1,error:"execution_error"}),{content:[{type:"text",text:`Failed to execute test command: ${(0,s.getErrorMessage)(e)}`}],isError:!0}}},exports.handleReportTestResults=async function(e,r,n,o,a,c){const l=a.startTimer("tool_execution_time")
4959
+ try{const{resolveRequestIdOrError:a}=await Promise.resolve().then(()=>t(36651)),d=await a(n,o,c?.sessionId,"Cannot report test results: this session is not associated with a request.")
4941
4960
  if(!d.ok)return l({success:!1,error:"no_request_association"}),d.errorResult
4942
4961
  const u=d.requestId,h=await n.proxyGet(`/api/projects/${r.projectId}/requests/${u}/test-runs`),p=h?.data||h||[],f=Array.isArray(p)?p:[],m="string"==typeof e.testRunId&&e.testRunId.trim()?e.testRunId.trim():void 0,g=(m?f.find(e=>e.id===m):void 0)||f.find(e=>"pending"===e.status||"running"===e.status)||f[0]
4943
4962
  if(!g)return l({success:!1,error:"no_test_run"}),{content:[{type:"text",text:`No test run found for request ${u}.`}],isError:!0}
4944
4963
  const y=g.id
4945
- return await n.proxyPatch(`/api/projects/${r.projectId}/test-runs/${y}`,{status:e.status,results:e.results}),g.worktreePath&&fetch(`${(0,s.getActionServerBaseUrl)()}/api/release-pool-slot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreePath:g.worktreePath}),signal:AbortSignal.timeout(5e3)}).catch(e=>i.debug("release-pool-slot fire-and-forget failed (non-fatal)",{error:(0,o.getErrorMessage)(e)})),l({success:!0}),{content:[{type:"text",text:`Test run for request ${u} recorded as **${e.status}**. The server reports the result to the parent session along with its next step.\n\n${e.results.summary}`}]}}catch(e){return l({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to report test results: ${(0,o.getErrorMessage)(e)}`}],isError:!0}}},exports.handleTestingProcessDelete=async function(e,t,r,n,s){const i=s.startTimer("tool_execution_time")
4946
- try{return await r.proxyDelete(`/api/projects/${t.projectId}/test-processes/${e.processId}`),n.info("Deleted test process",{processId:e.processId}),i({success:!0}),{content:[{type:"text",text:`Deleted test process ${e.processId}.`}]}}catch(e){return i({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to delete test process: ${(0,o.getErrorMessage)(e)}`}],isError:!0}}},exports.handleTests=async function(e,n,a,c,l,u){const h=l.startTimer("tool_execution_time")
4964
+ return await n.proxyPatch(`/api/projects/${r.projectId}/test-runs/${y}`,{status:e.status,results:e.results}),g.worktreePath&&fetch(`${(0,i.getActionServerBaseUrl)()}/api/release-pool-slot`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreePath:g.worktreePath}),signal:AbortSignal.timeout(5e3)}).catch(e=>o.debug("release-pool-slot fire-and-forget failed (non-fatal)",{error:(0,s.getErrorMessage)(e)})),l({success:!0}),{content:[{type:"text",text:`Test run for request ${u} recorded as **${e.status}**. The server reports the result to the parent session along with its next step.\n\n${e.results.summary}`}]}}catch(e){return l({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to report test results: ${(0,s.getErrorMessage)(e)}`}],isError:!0}}},exports.handleTestingProcessDelete=async function(e,t,r,n,o){const i=o.startTimer("tool_execution_time")
4965
+ try{return await r.proxyDelete(`/api/projects/${t.projectId}/test-processes/${e.processId}`),n.info("Deleted test process",{processId:e.processId}),i({success:!0}),{content:[{type:"text",text:`Deleted test process ${e.processId}.`}]}}catch(e){return i({success:!1,error:"api_error"}),{content:[{type:"text",text:`Failed to delete test process: ${(0,s.getErrorMessage)(e)}`}],isError:!0}}},exports.handleTests=async function(e,o,c,l,d,h){const p=d.startTimer("tool_execution_time")
4947
4966
  try{if("switch-off"===e.operation||"switch-on"===e.operation){const t=await async function(e,t,r){const n="switch-on"===e.operation,o=await r.proxyGet(`/api/projects/${t.projectId}/test-processes`),s=Array.isArray(o)?o:Array.isArray(o?.data)?o.data:[],i=String(e.process??"").trim(),a=i?s.find(e=>e.id===i||"string"==typeof e.name&&e.name.toLowerCase()===i.toLowerCase()):1===s.length?s[0]:void 0
4948
4967
  if(!a)return{content:[{type:"text",text:`${i?`No check matched "${i}".`:"Name the check in `process` (its name or id)."} Registered: ${s.map(e=>`${e.name} (${e.id})`).join(", ")||"none"}.`}],isError:!0}
4949
4968
  if(!!a.isActive===n)return{content:[{type:"text",text:`"${a.name}" is already ${n?"on":"off"}; nothing changed.`}]}
4950
4969
  const c="string"==typeof e.userSaid?e.userSaid.trim():""
4951
- if(!c||!await(0,d.userSaidOnRequest)(r,t.projectId,"",c,{anywhere:!0})){if(c&&t.currentSessionId)try{await(r.getSessionMessageClient?.()?.createReport({fromSessionId:t.currentSessionId,status:"success",summary:`"${a.name}" was not switched ${n?"on":"off"}: the words given as yours ("${c.length>160?`${c.slice(0,157)}...`:c}") are not in anything you wrote here, so nothing changed. If you want it ${n?"on":"off"}, tell the Alchemist.`,extraContent:{reportKind:"outcome"}}))}catch{}return{content:[{type:"text",text:`Not switched ${n?"on":"off"}: that is the user's call. `+(c?"The words in userSaid are not in any message the user sent in this project; quote them exactly as they wrote them.":`Pass their words asking for it in userSaid, quoted exactly. If they have not asked, ask them, saying what ${n?"it will check again":"stops being checked"}.`)}],isError:!0}}return await r.proxyPatch(`/api/projects/${t.projectId}/test-processes/${a.id}`,{isActive:n,userSaid:c}),{content:[{type:"text",text:n?`"${a.name}" is on again: every change it covers must pass it before it merges.`:`"${a.name}" is off: changes now merge without it running. The user was told in Steer what no longer gets checked. Say it in your reply in one sentence too.`}]}}(e,n,a)
4952
- return h({success:!t.isError}),t}if("list"===e.operation){const e=await a.proxyGet(`/api/projects/${n.projectId}/test-processes`),t=e?.data||e||[],o=Array.isArray(t)?t:[]
4953
- if(0===o.length)return h({success:!0}),{content:[{type:"text",text:'No test processes registered for this project. The user sees the Tests gate greyed as "nothing registered" and decides whether to set one up; it is not yours to raise. Verify your work with fast `run` checks in a box, and say in your completion summary if the absence mattered. `tests` operation "setup" opens only from a request that carries a gate criterion (kind "gate": a check the request itself asks to run on every merge).'}]}
4954
- const s=r(o)
4955
- return h({success:!0}),{content:[{type:"text",text:`## Test Processes (${o.length})\n\n${s}`}]}}if("run"===e.operation){let r,l=[]
4956
- try{const e=await a.proxyGet(`/api/projects/${n.projectId}/test-processes`),t=e?.data||e||[]
4957
- l=Array.isArray(t)?t:[]}catch(e){c.warn("tests run: existence check failed; proceeding optimistically",{error:(0,o.getErrorMessage)(e)})}if(0===l.length)return h({success:!1,error:"no_process"}),{content:[{type:"text",text:'No test process registered for this project. Run `tests` with `operation: "setup"` first to bootstrap one.'}],isError:!0}
4970
+ if(!c||!await(0,u.userSaidOnRequest)(r,t.projectId,"",c,{anywhere:!0})){if(c&&t.currentSessionId)try{await(r.getSessionMessageClient?.()?.createReport({fromSessionId:t.currentSessionId,status:"success",summary:`"${a.name}" was not switched ${n?"on":"off"}: the words given as yours ("${c.length>160?`${c.slice(0,157)}...`:c}") are not in anything you wrote here, so nothing changed. If you want it ${n?"on":"off"}, tell the Alchemist.`,extraContent:{reportKind:"outcome"}}))}catch{}return{content:[{type:"text",text:`Not switched ${n?"on":"off"}: that is the user's call. `+(c?"The words in userSaid are not in any message the user sent in this project; quote them exactly as they wrote them.":`Pass their words asking for it in userSaid, quoted exactly. If they have not asked, ask them, saying what ${n?"it will check again":"stops being checked"}.`)}],isError:!0}}return await r.proxyPatch(`/api/projects/${t.projectId}/test-processes/${a.id}`,{isActive:n,userSaid:c}),{content:[{type:"text",text:n?`"${a.name}" is on again: every change it covers must pass it before it merges.`:`"${a.name}" is off: changes now merge without it running. The user was told in Steer what no longer gets checked. Say it in your reply in one sentence too.`}]}}(e,o,c)
4971
+ return p({success:!t.isError}),t}if("list"===e.operation){const e=await c.proxyGet(`/api/projects/${o.projectId}/test-processes${await r(o,c,l)}`),t=e?.data||e||[],s=Array.isArray(t)?t:[]
4972
+ if(0===s.length)return p({success:!0}),{content:[{type:"text",text:'No test processes registered for this project. The user sees the Tests gate greyed as "nothing registered" and decides whether to set one up; it is not yours to raise. Verify your work with fast `run` checks in a box, and say in your completion summary if the absence mattered. `tests` operation "setup" opens only from a request that carries a gate criterion (kind "gate": a check the request itself asks to run on every merge).'}]}
4973
+ const i=n(s)
4974
+ return p({success:!0}),{content:[{type:"text",text:`## Test Processes (${s.length})\n\n${i}`}]}}if("run"===e.operation){let r,n=[]
4975
+ try{const e=await c.proxyGet(`/api/projects/${o.projectId}/test-processes`),t=e?.data||e||[]
4976
+ n=Array.isArray(t)?t:[]}catch(e){l.warn("tests run: existence check failed; proceeding optimistically",{error:(0,s.getErrorMessage)(e)})}if(0===n.length)return p({success:!1,error:"no_process"}),{content:[{type:"text",text:'No test process registered for this project. Run `tests` with `operation: "setup"` first to bootstrap one.'}],isError:!0}
4958
4977
  const d=e.process
4959
- if(d){const e=d.toLowerCase(),t=l.find(t=>t.id===d||"string"==typeof t.name&&t.name.toLowerCase()===e)
4960
- if(!t){const e=l.map(e=>`- ${e.name} (${e.id})`).join("\n")
4961
- return h({success:!1,error:"process_not_found"}),{content:[{type:"text",text:`No test process matched "${d}". Available:\n${e}`}],isError:!0}}r=[t.id]}const p=u?.sessionId,{resolveRequestIdOrError:f}=await Promise.resolve().then(()=>t(36651)),m=await f(a,c,p,"tests run requires an associated request: your session is not currently linked to one. Open or create a request, then try again.")
4962
- if(!m.ok)return h({success:!1,error:"no_request"}),m.errorResult
4978
+ if(d){const e=d.toLowerCase(),t=n.find(t=>t.id===d||"string"==typeof t.name&&t.name.toLowerCase()===e)
4979
+ if(!t){const e=n.map(e=>`- ${e.name} (${e.id})`).join("\n")
4980
+ return p({success:!1,error:"process_not_found"}),{content:[{type:"text",text:`No test process matched "${d}". Available:\n${e}`}],isError:!0}}r=[t.id]}const u=h?.sessionId,{resolveRequestIdOrError:f}=await Promise.resolve().then(()=>t(36651)),m=await f(c,l,u,"tests run requires an associated request: your session is not currently linked to one. Open or create a request, then try again.")
4981
+ if(!m.ok)return p({success:!1,error:"no_request"}),m.errorResult
4963
4982
  const g=m.requestId,y=e.name?[e.name]:void 0
4964
- try{const e=await fetch(`${(0,s.getActionServerBaseUrl)()}/api/run-tests-now`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:g,parentSessionId:p,testProcessIds:r,commandNames:y}),signal:AbortSignal.timeout(9e4)})
4983
+ try{const e=await fetch(`${(0,i.getActionServerBaseUrl)()}/api/run-tests-now`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:g,parentSessionId:u,testProcessIds:r,commandNames:y}),signal:AbortSignal.timeout(9e4)})
4965
4984
  if(!e.ok){const t=await e.text().catch(()=>"")
4966
- return h({success:!1,error:"run_failed"}),{content:[{type:"text",text:`tests run failed: action server returned ${e.status}: ${t.slice(0,300)}`}],isError:!0}}const t=await e.json()
4967
- if(!t.success||!t.data)return h({success:!1,error:"run_failed"}),{content:[{type:"text",text:`tests run failed: ${t.error||"unknown error"}`}],isError:!0}
4985
+ return p({success:!1,error:"run_failed"}),{content:[{type:"text",text:`tests run failed: action server returned ${e.status}: ${t.slice(0,300)}`}],isError:!0}}const t=await e.json()
4986
+ if(!t.success||!t.data)return p({success:!1,error:"run_failed"}),{content:[{type:"text",text:`tests run failed: ${t.error||"unknown error"}`}],isError:!0}
4968
4987
  const n=t.data.spawnedSessionIds?.[0],o=y?` (filtered to: ${y.join(", ")})`:""
4969
- return h({success:!0}),{content:[{type:"text",text:`Test run started${o}.\nSpawned ${t.data.agentsSpawned} runner(s) for ${t.data.processCount} process(es). Test runs: ${t.data.testRunIds.join(", ")}.\n\nThe auto-tester is executing the registered commands. You will receive a notification on your next turn when results are reported: continue with other work in the meantime. This voluntary run doesn't gate anything by itself; if you feel uncertain about the change, wait for the results before completing.`}],...(0,i.alchemyMeta)({kind:"spawn-subagent",spawnedSessionId:n,agentType:"auto-tester",requestId:g,description:y?`Test run: ${y.join(", ")}`:"Test run"})}}catch(e){const t=(0,o.getErrorMessage)(e)
4970
- return/abort|timeout/i.test(t)?(h({success:!0}),{content:[{type:"text",text:"The test run was handed to the action server, but its answer did not come back within 90 seconds. It may still be running: its result arrives as a report on a later turn. Do not treat this as a failed run."}]}):(h({success:!1,error:"fetch_error"}),{content:[{type:"text",text:`tests run failed: could not reach action server: ${t}`}],isError:!0})}}if("setup"===e.operation){let r
4971
- try{const e=await a.proxyGet(`/api/projects/${n.projectId}/test-processes`),t=e?.data||e||[],o=Array.isArray(t)?t:[]
4972
- if(o.length>0){const e=o.map(e=>`- ${e.name}${e.scope?` (scope: ${e.scope})`:""}: ${e.config?.commands?.length||0} command(s), ${e.isActive?"active":"inactive"}`).join("\n")
4973
- r=`${o.length} test process(es) already registered for this project:\n${e}\n\nPick a distinct name AND a non-overlapping scope for the new process. Confirm with the user what they want this new process to cover before registering.`}}catch(e){c.warn("tests setup: existing-processes lookup failed; proceeding without hint",{error:(0,o.getErrorMessage)(e)})}const{sessionIdentity:l}=await Promise.resolve().then(()=>t(6688)),d=u?.sessionId,p=d?await l.getSessionRequestId(a,c,d):void 0
4974
- if(p)try{const e=await a.proxyGet(`/api/projects/${n.projectId}/requests/${encodeURIComponent(p)}`),t=e?.data??e
4975
- if(!(Array.isArray(t?.acceptanceCriteria)?t.acceptanceCriteria:[]).some(e=>"gate"===e?.kind))return h({success:!1,error:"no_gate_criterion"}),{content:[{type:"text",text:`tests setup is not open from ${p}: none of its acceptance criteria is a gate criterion (kind "gate", a check the request asks to run on every merge). Whether the project gets a test process is asked of the user once per project, not by workers. If you believe this request does ask for a check, say so in a question to the user; if they agree they can edit the criterion's kind on the request card. Meanwhile verify your work with fast \`run\` checks in a box.`}],isError:!0}}catch(e){c.warn("tests setup: request lookup failed; proceeding",{requestId:p,error:(0,o.getErrorMessage)(e)})}if(!(p||"string"==typeof e.ask&&e.ask.trim()))return h({success:!1,error:"no_ask"}),{content:[{type:"text",text:"tests setup needs `ask`: what the user asked the check to run, in their words. The setup architect registers exactly that; without it, it can only guess from the repository."}],isError:!0}
4976
- try{const t=await fetch(`${(0,s.getActionServerBaseUrl)()}/api/setup-tests`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:p,parentSessionId:d,context:r,..."string"==typeof e.ask&&e.ask.trim()?{ask:e.ask.trim()}:{}}),signal:AbortSignal.timeout(15e3)})
4988
+ return p({success:!0}),{content:[{type:"text",text:`Test run started${o}.\nSpawned ${t.data.agentsSpawned} runner(s) for ${t.data.processCount} process(es). Test runs: ${t.data.testRunIds.join(", ")}.\n\nThe auto-tester is executing the registered commands. You will receive a notification on your next turn when results are reported: continue with other work in the meantime. This voluntary run doesn't gate anything by itself; if you feel uncertain about the change, wait for the results before completing.`}],...(0,a.alchemyMeta)({kind:"spawn-subagent",spawnedSessionId:n,agentType:"auto-tester",requestId:g,description:y?`Test run: ${y.join(", ")}`:"Test run"})}}catch(e){const t=(0,s.getErrorMessage)(e)
4989
+ return/abort|timeout/i.test(t)?(p({success:!0}),{content:[{type:"text",text:"The test run was handed to the action server, but its answer did not come back within 90 seconds. It may still be running: its result arrives as a report on a later turn. Do not treat this as a failed run."}]}):(p({success:!1,error:"fetch_error"}),{content:[{type:"text",text:`tests run failed: could not reach action server: ${t}`}],isError:!0})}}if("setup"===e.operation){let r
4990
+ try{const e=await c.proxyGet(`/api/projects/${o.projectId}/test-processes`),t=e?.data||e||[],n=Array.isArray(t)?t:[]
4991
+ if(n.length>0){const e=n.map(e=>`- ${e.name}${e.scope?` (scope: ${e.scope})`:""}: ${e.config?.commands?.length||0} command(s), ${e.isActive?"active":"inactive"}`).join("\n")
4992
+ r=`${n.length} test process(es) already registered for this project:\n${e}\n\nPick a distinct name AND a non-overlapping scope for the new process. Confirm with the user what they want this new process to cover before registering.`}}catch(e){l.warn("tests setup: existing-processes lookup failed; proceeding without hint",{error:(0,s.getErrorMessage)(e)})}const{sessionIdentity:n}=await Promise.resolve().then(()=>t(6688)),d=h?.sessionId,u=d?await n.getSessionRequestId(c,l,d):void 0
4993
+ if(u)try{const e=await c.proxyGet(`/api/projects/${o.projectId}/requests/${encodeURIComponent(u)}`),t=e?.data??e
4994
+ if(!(Array.isArray(t?.acceptanceCriteria)?t.acceptanceCriteria:[]).some(e=>"gate"===e?.kind))return p({success:!1,error:"no_gate_criterion"}),{content:[{type:"text",text:`tests setup is not open from ${u}: none of its acceptance criteria is a gate criterion (kind "gate", a check the request asks to run on every merge). Whether the project gets a test process is asked of the user once per project, not by workers. If you believe this request does ask for a check, say so in a question to the user; if they agree they can edit the criterion's kind on the request card. Meanwhile verify your work with fast \`run\` checks in a box.`}],isError:!0}}catch(e){l.warn("tests setup: request lookup failed; proceeding",{requestId:u,error:(0,s.getErrorMessage)(e)})}if(!(u||"string"==typeof e.ask&&e.ask.trim()))return p({success:!1,error:"no_ask"}),{content:[{type:"text",text:"tests setup needs `ask`: what the user asked the check to run, in their words. The setup architect registers exactly that; without it, it can only guess from the repository."}],isError:!0}
4995
+ try{const t=await fetch(`${(0,i.getActionServerBaseUrl)()}/api/setup-tests`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:u,parentSessionId:d,context:r,..."string"==typeof e.ask&&e.ask.trim()?{ask:e.ask.trim()}:{}}),signal:AbortSignal.timeout(15e3)})
4977
4996
  if(!t.ok){const e=await t.text().catch(()=>"")
4978
4997
  if(409===t.status){let t=e
4979
- try{t=JSON.parse(e)?.error??e}catch{}return h({success:!1,error:"setup_owned_elsewhere"}),{content:[{type:"text",text:`tests setup did not start: ${t}`}],isError:!0}}return h({success:!1,error:"spawn_failed"}),{content:[{type:"text",text:`tests setup failed: action server returned ${t.status}: ${e.slice(0,300)}`}],isError:!0}}const n=await t.json()
4980
- return n.success&&n.data?(h({success:!0}),{content:[{type:"text",text:`Test setup session started.\nWorktree: ${n.data.worktreePath} (branch: ${n.data.branch})\n\nThe setup-architect agent is now interviewing the user. You will receive a notification on your next turn when configuration completes: continue with other work in the meantime.`}],...(0,i.alchemyMeta)({kind:"spawn-subagent",spawnedSessionId:n.data.sessionId,agentType:"setup-architect",requestId:p??void 0,description:"Test setup"})}):(h({success:!1,error:"spawn_failed"}),{content:[{type:"text",text:`tests setup failed: ${n.error||"unknown error"}`}],isError:!0})}catch(e){return h({success:!1,error:"fetch_error"}),{content:[{type:"text",text:`tests setup failed: could not reach action server: ${(0,o.getErrorMessage)(e)}`}],isError:!0}}}return h({success:!1,error:"unknown_operation"}),{content:[{type:"text",text:`Unknown operation: ${e.operation}`}],isError:!0}}catch(e){return h({success:!1,error:"api_error"}),{content:[{type:"text",text:`tests failed: ${(0,o.getErrorMessage)(e)}`}],isError:!0}}}
4981
- const o=t(58824),s=t(79414),i=t(82272),a=t(31375),c=t(56844),l=t(52232),d=t(29729),u=["package-lock.json","npm-shrinkwrap.json","yarn.lock","pnpm-lock.yaml","bun.lock","bun.lockb","uv.lock","poetry.lock","Pipfile.lock","requirements.txt","Cargo.lock","go.sum","Gemfile.lock","composer.lock"],h={npm:["ci","install","i"],pnpm:["install","i"],bun:["install","i"],yarn:["","install"],uv:["sync"],pip:["install"],pip3:["install"],poetry:["install"],pipenv:["install","sync"],cargo:["fetch"],bundle:["install"],composer:["install"]}},56844(e,exports,t){function r(e,t){const r=String(t||"").trim().replace(/^v/i,"").match(/^(\d+)(?:\.(\d+))?/)
4998
+ try{t=JSON.parse(e)?.error??e}catch{}return p({success:!1,error:"setup_owned_elsewhere"}),{content:[{type:"text",text:`tests setup did not start: ${t}`}],isError:!0}}return p({success:!1,error:"spawn_failed"}),{content:[{type:"text",text:`tests setup failed: action server returned ${t.status}: ${e.slice(0,300)}`}],isError:!0}}const n=await t.json()
4999
+ return n.success&&n.data?(p({success:!0}),{content:[{type:"text",text:`Test setup session started.\nWorktree: ${n.data.worktreePath} (branch: ${n.data.branch})\n\nThe setup-architect agent is now interviewing the user. You will receive a notification on your next turn when configuration completes: continue with other work in the meantime.`}],...(0,a.alchemyMeta)({kind:"spawn-subagent",spawnedSessionId:n.data.sessionId,agentType:"setup-architect",requestId:u??void 0,description:"Test setup"})}):(p({success:!1,error:"spawn_failed"}),{content:[{type:"text",text:`tests setup failed: ${n.error||"unknown error"}`}],isError:!0})}catch(e){return p({success:!1,error:"fetch_error"}),{content:[{type:"text",text:`tests setup failed: could not reach action server: ${(0,s.getErrorMessage)(e)}`}],isError:!0}}}return p({success:!1,error:"unknown_operation"}),{content:[{type:"text",text:`Unknown operation: ${e.operation}`}],isError:!0}}catch(e){return p({success:!1,error:"api_error"}),{content:[{type:"text",text:`tests failed: ${(0,s.getErrorMessage)(e)}`}],isError:!0}}}
5000
+ const s=t(58824),i=t(79414),a=t(82272),c=t(31375),l=t(56844),d=t(52232),u=t(29729),h=t(36651),p=["package-lock.json","npm-shrinkwrap.json","yarn.lock","pnpm-lock.yaml","bun.lock","bun.lockb","uv.lock","poetry.lock","Pipfile.lock","requirements.txt","Cargo.lock","go.sum","Gemfile.lock","composer.lock"],f={npm:["ci","install","i"],pnpm:["install","i"],bun:["install","i"],yarn:["","install"],uv:["sync"],pip:["install"],pip3:["install"],poetry:["install"],pipenv:["install","sync"],cargo:["fetch"],bundle:["install"],composer:["install"]}},56844(e,exports,t){function r(e,t){const r=String(t||"").trim().replace(/^v/i,"").match(/^(\d+)(?:\.(\d+))?/)
4982
5001
  return r?"node"===e?r[1]:void 0!==r[2]?`${r[1]}.${r[2]}`:null:null}function n(e,t){const n=String(t||"").split("||"),s=[]
4983
5002
  for(const t of n){const n=t.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)
4984
5003
  let i=null
@@ -5195,26 +5214,28 @@ exports.GQ=["coder","writer","work"],exports.DY=Array.from(new Set([...Object.va
5195
5214
  var o=Object.getOwnPropertyDescriptor(t,r)
5196
5215
  o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),n=this&&this.__exportStar||function(e,exports){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||r(exports,e,t)}
5197
5216
  Object.defineProperty(exports,"__esModule",{value:!0}),n(t(70441),exports),n(t(70270),exports)},70270(e,exports){Object.defineProperty(exports,"__esModule",{value:!0})},26540(e,exports){var t
5198
- Object.defineProperty(exports,"__esModule",{value:!0}),exports.LogLevel=void 0,function(e){e.ERROR="error",e.WARN="warn",e.INFO="info",e.DEBUG="debug"}(t||(exports.LogLevel=t={}))},76183(e,exports,t){Object.defineProperty(exports,"__esModule",{value:!0}),exports.DocumentOperationsSchema=exports.SearchDocumentsSchema=exports.CreateDocumentSchema=exports.ReplaceLinesSchema=exports.InsertLinesSchema=exports.PlannerOpsSchema=exports.ResearchFanoutSchema=exports.SubagentOperationsSchema=exports.TaskInspectSchema=exports.CompleteTaskSchema=exports.GetTaskInformationSchema=exports.GetRequestInformationSchema=exports.ListRequestsSchema=exports.ListTasksSchema=exports.SearchSchema=exports.QueryHistorySchema=exports.RequestDiffSchema=exports.MergePreviewSchema=exports.FileRecoverSchema=exports.FileHistorySchema=exports.DeleteFilesSchema=exports.DeleteFileSchema=exports.ReplaceInFilesSchema=exports.ReplaceStringsSchema=exports.ReplaceStringSchema=exports.MoveFilesSchema=exports.CreateDirectorySchema=exports.GetFileInfoSchema=exports.ListDirectorySchema=exports.ReadFilesSchema=exports.ViewAssetSchema=exports.WriteFileSchema=exports.UpdateTaskStatusSchema=exports.CreateTaskSchema=exports.CreateRequestSchema=exports.CompleteRequestSchema=exports.skipTestsSchema=exports.skipTestsReasonSchema=exports.ExecutedTestSchema=exports.TestVerificationSchema=exports.TestDefinitionSchema=exports.AcceptanceCriterionSchema=exports.RecordTypeEnum=exports.RequestStatusEnum=exports.TaskStatusEnum=exports.RequestStatusFilterEnum=exports.SettableRequestTypeEnum=exports.RequestTypeEnum=exports.TestCoverageTypeEnum=exports.CompletionStatusEnum=void 0,exports.EnvironmentSetupSchema=exports.EnvironmentVerifySchema=exports.EnvironmentDeleteSchema=exports.EnvironmentUpdateSchema=exports.EnvironmentCreateSchema=exports.EnvironmentVerifyStackSchema=exports.EnvironmentStatusSchema=exports.EnvironmentTeardownSchema=exports.EnvironmentProvisionSchema=exports.EnvironmentGetSchema=exports.AskUserVisualSchema=exports.RequestVisualFeedbackSchema=exports.FetchAssetSchema=exports.PreviewSiteSchema=exports.CaptureSiteSchema=exports.DriveSiteSchema=exports.ReadSiteSchema=exports.ExperimentListSchema=exports.ExperimentStopSchema=exports.ExperimentStartSchema=exports.ResultInspectSchema=exports.ResultsSchema=exports.EnvironmentListSchema=exports.TestingProcessDeleteSchema=exports.TestingProcessCreateSchema=exports.TestingProcessGetSchema=exports.TestingProcessListSchema=exports.MetaOperationsSchema=exports.MetaAgentListSchema=exports.MetaWorkflowRemoveRecipeSchema=exports.MetaWorkflowAddRecipeSchema=exports.MetaHookCreateSchema=exports.MetaHookListSchema=exports.MetaRecipeRemoveHookSchema=exports.MetaRecipeAddHookSchema=exports.MetaRecipeCreateSchema=exports.MetaRecipeGetSchema=exports.MetaRecipeListSchema=exports.MetaWorkflowUpdateSchema=exports.MetaWorkflowCreateSchema=exports.MetaWorkflowGetSchema=exports.MetaWorkflowListSchema=exports.QuickReplaceSchema=exports.QuickWriteSchema=exports.RequestOperationsSchema=exports.ManageFilesSchema=exports.ModifyFileSchema=exports.RevertRequestSchema=exports.PlanWriteSchema=exports.PlanReadSchema=void 0,exports.AnswerQuestionSchema=exports.McpConnectionsSchema=exports.DirectiveOperationsSchema=exports.CommitToViewedSessionSchema=exports.SessionMessageOperationsSchema=exports.OpeningBriefSectionSchema=exports.ReportTestResultsSchema=exports.CommandsSchema=exports.RunSchema=exports.ExecuteTestCommandSchema=exports.TestsSchema=exports.TestingProcessUpdateSchema=void 0
5199
- const r=t(11569),n=t(8955),o=t(94466),s=(e,t,n={})=>r.z.string().refine(t=>!(!n.allowEmpty||""!==t)||!!t&&e.some(e=>e.test(t)),{message:t}),i=s([o.TASK_REF_PATTERN,o.TASK_REF_SHORT_PATTERN],"Task ID must be req######+#NN (e.g. req000005#03) or a short form like #01, 01, or 1 (resolved against the active request)."),a=s([/^req\d{6}$/],"Request ID must match format: req###### (e.g. req000001)"),c=s([/^doc_[0-9A-Z]{26}$/i,/^(doc|plan|quest|jour)\d{6}$/],"Document ID must match format: doc_[26 alphanumeric] (ULID) or doc######/plan######/quest######/jour###### (local ID)",{allowEmpty:!0}),l=e=>e.path&&e.documentId?{...e,documentId:void 0}:e,d=e=>Boolean(e.path)||Boolean(e.documentId)
5200
- exports.CompletionStatusEnum=r.z.enum(["complete","incomplete","partial"]),exports.TestCoverageTypeEnum=r.z.enum(["unit","e2e","integration","manual"]),exports.RequestTypeEnum=r.z.enum(["code","quick-edit","drive","writing","engineering","setup"]),exports.SettableRequestTypeEnum=r.z.enum(["code","drive","writing","engineering"]),exports.RequestStatusFilterEnum=r.z.enum(["draft","open","in_progress","ready_for_review","ready_for_merge","resolving_conflicts","conflicted","completed","canceled","reverted","in_flight"]).describe("A status, or in_flight: every request under way."),exports.TaskStatusEnum=r.z.enum(["pending","in_progress","ready_for_review","completed","canceled","reverted"]),exports.RequestStatusEnum=r.z.enum(["open","in_progress","ready_for_review","ready_for_merge","completed","canceled","reverted","conflicted"]),exports.RecordTypeEnum=r.z.enum(["write","modify","blocker","resolution","discovery","test","delete"]),exports.AcceptanceCriterionSchema=r.z.object({description:r.z.string(),createdAt:r.z.string().optional(),updatedAt:r.z.string().optional()}),exports.TestDefinitionSchema=r.z.object({id:r.z.string(),description:r.z.string(),status:exports.CompletionStatusEnum,coverageType:exports.TestCoverageTypeEnum,accepts:r.z.array(r.z.string())}),exports.TestVerificationSchema=r.z.object({criteria:r.z.array(r.z.string()),tests:r.z.array(r.z.string()),coverageType:exports.TestCoverageTypeEnum,coverageRatio:r.z.number(),createdAt:r.z.string().optional(),updatedAt:r.z.string().optional()}),exports.ExecutedTestSchema=r.z.object({id:r.z.string(),testId:r.z.string(),status:exports.CompletionStatusEnum,results:r.z.string(),coverage:r.z.array(r.z.string()),executedAt:r.z.string()}),exports.skipTestsReasonSchema=r.z.string().min(20).optional().describe("Opt out of all tests (reason of 20+ characters). Refused under the strict test gate and when any test command is required. For some commands, use skipTests."),exports.skipTestsSchema=r.z.array(r.z.object({commandName:r.z.string().min(1).describe("A registered test command's name."),reason:r.z.string().min(20).describe("Why it is irrelevant to the change (20+ characters).")})).optional().describe("Skip test commands by name; not with skipTestsReason. Refused under the strict test gate and for required commands."),exports.CompleteRequestSchema=r.z.object({status:exports.RequestStatusEnum,acceptanceCriteria:r.z.array(exports.AcceptanceCriterionSchema),testVerification:exports.TestVerificationSchema.optional(),completionSummary:r.z.string().optional()}),exports.CreateRequestSchema=r.z.object({title:r.z.string(),process:r.z.string().optional().describe('The workflow process this request follows, by name (e.g. "CFD case"): it sets the kind and adds the process\'s rules as criteria. Name one when the request clearly is that kind of work; with none, the reply lists those that fit. Unknown names are refused with the list.'),userSaid:r.z.string().min(8).max(600).optional().describe("The user's words asking for this request, copied exactly in their language: the phrase that asks, not the whole message (matched as an exact excerpt). Pass it whenever the request comes from what the user wrote; with several messages at once, the request is filed under the one it quotes. Required for a 'gate' criterion, whose words must ask for the check to keep running."),type:exports.SettableRequestTypeEnum.describe("'code': builds or fixes behaviour (a branch, a worker, the workflow's gates, a merge). 'writing': prose that lives in the repo (docs, page copy), handled the same way. 'drive': a verification errand: the driver exercises the product through its user doors against the criteria as claims; no branch, no merge, and an UNMET claim waits for the user's sign-off. 'engineering': a model, simulation or analysis whose numbers are the product, reviewed on its idealisation and evidence and validated against something independent; prefer it over 'code' when the deliverable is a result and its justification."),description:r.z.string().optional().describe('What to build or find out and why, for whoever picks it up; the record, not a reply to the user, so rules about how you talk to them do not apply. The user reads it on the request page: call them "you", never "the user"; name agents by their job (the worker, the Alchemist).'),quotesMessage:r.z.boolean().optional().describe("true when the user's message is the specification (a brief, a pasted spec, text for the product): it is copied into the description word for word under 'Your words:', and your description is only what you add. Do not write their message out yourself. With several messages, userSaid picks which."),acceptanceCriteria:r.z.array(r.z.union([r.z.string(),r.z.object({description:r.z.string().min(1),beforeMerge:r.z.boolean().optional().describe("[user-input] criteria only: true when the user asked to check it themselves before it merges. The merge then waits for them at every Autonomy level; otherwise Self-driving treats no answer as not checked by them."),command:r.z.string().min(1).max(500).optional().describe("The command that decides this criterion, if one does (e.g. `.venv/bin/python -m pytest tests`), as it runs in the project's box. The worker may add checks, not replace it. Keep it out of the text."),kind:r.z.enum(["objective","subjective","gate"]).describe("objective: provable by running something (strings, files, exit codes, return values), even when the project has no tests yet. subjective: needs judgment (looks, reads, compares). gate: a check that runs on every merge from now on, met only by a test process registered for this request; its gate run is the verdict.")})])).optional().describe('Verifiable done-conditions: a string, or { description, kind } to say how it is proven. Split a mixed claim into one of each kind. A criterion says what must be true of the result, never that a check was run or its output recorded ("prints the tracked-file count", not "was run and its output recorded"). Put what must come from the user in its own criterion marked [user-input]; the card at the end of the work asks them for it. Criteria show on the user\'s cards, so address them as "you": "[user-input] You have tried it and say it works".'),draft:r.z.boolean().optional().describe("A draft: on the timeline, no branch, nothing runs until the user starts it (a title alone is fine). How a worker hands over work nobody asked for (with follows: your request)."),delegate:r.z.boolean().optional(),follows:r.z.string({required_error:"Required. Every request either follows earlier work or starts fresh: pass the origin request id (req######) or the word 'new'."}).refine(e=>"new"===e||/^(round:)?req\d{6}$/.test(e),{message:"Pass a request id like req000031, 'round:req000031' for another round of work that has landed, or 'new' for genuinely new work."}).describe("What this grows out of. 'round:req######': another pass at what that merged request built (bigger, another colour, the wording back); shown with it as one item and built by its builder. 'req######': a follow-up, a fix for its fallout or a continuation, only when the user pointed at it (anchored the message to it, named it, said 'that change') or you are working it; the request you are on is usually the origin. 'new': fresh work, including a new feature on an existing app and anything the user asks for on its own, even if it touches an earlier request's work (name that one in the description). The project's founding request is not an origin for later work. Only this field links requests."),planDocumentId:r.z.string().optional().describe("The plan document that decomposes this work (plan######); not the schedule that dispatched you (that is scheduleDocumentId)."),scheduleDocumentId:r.z.string().optional().describe("The schedule document that dispatched this request; only when a schedule told you to create it, with the id it gave."),questDocumentId:r.z.string().optional(),waitsOn:r.z.array(r.z.string().regex(/^req\d{6}$/)).max(5).optional().describe("Requests this one waits for: registered now, started once all have landed. A canceled one never lands; the wait holds until moved or cleared. Declare it here, not afterwards: work is dispatched at registration. When this grows out of a request that has not landed, choose this or startsNow."),startsNow:r.z.boolean().optional().describe("The other answer to waitsOn: true starts this now, alongside the unlanded request. The user's words decide (at once: start now; one after the other: wait). If they said nothing about order, wait when both change the same code."),asked:r.z.array(r.z.string().regex(/^Q-[A-Z0-9]+-\d+$/)).max(5).optional().describe("Your open questions to the user (Q-codes) that decide something here: the worker does not ask them again and gets the answer too. Pass them whenever the request builds on an answer you are waiting for."),userChoices:r.z.array(r.z.string().regex(/^Q-[A-Za-z0-9]+-\d+$/)).max(10).optional().describe("Cards the user answered that this request builds on (e.g. Q-ABCD1234-001); their picks count as sources in review, so carry the picked words into the description. A card still waiting for the user may be named (file on its default); it counts once answered. A card closed by an agent, a default or a withdrawal is refused."),replaces:r.z.string().regex(/^req\d{6}$/).optional().describe("The canceled request this one refiles. What waited on it waits on this one instead. Only a canceled request can be replaced."),areas:r.z.array(r.z.string()).max(3).optional().describe("Work-area labels, 1-3, required unless draft: lowercase kebab paths (e.g. 'graphics/opengl/shader-cache'). Pick from request_operations list-areas; add a new name only when nothing fits, nested under an existing parent. New names are registered automatically.")}),exports.CreateTaskSchema=r.z.object({requestId:a,title:r.z.string(),description:r.z.string()}),exports.UpdateTaskStatusSchema=r.z.object({taskId:i,status:exports.TaskStatusEnum,note:r.z.string()}),exports.WriteFileSchema=r.z.object({path:r.z.string().optional(),documentId:c.optional(),content:r.z.union([r.z.string(),r.z.array(r.z.string())]).optional(),fromResult:r.z.string().optional().describe('Instead of content: a recorded result (its address, or a unique prefix) whose bytes become this file, unchanged. For a file made somewhere you cannot write the worktree from, e.g. a .docx made in a sealed box and recorded with results({ operation: "record", box }). Files only (with path), up to 20 MB; bulk stays in the store (results pin).'),format:r.z.enum(["text","json"]).optional(),append:r.z.boolean().optional(),comment:r.z.string()}).transform(l).refine(d,{message:"path or documentId required"}).refine(e=>void 0!==e.content!==Boolean(e.fromResult),{message:"pass content or fromResult (exactly one)"}),exports.ViewAssetSchema=r.z.object({filename:r.z.string().optional().describe("An image in .alchemy_lab/assets/, as an asset:<filename> ref names it."),path:r.z.string().optional().describe("An image, PDF or office file (Word, Excel, PowerPoint, OpenDocument, .doc/.xls/.ppt/.rtf) in the working tree."),result:r.z.string().optional().describe("A recorded result: its address or a unique prefix."),pages:r.z.string().optional().describe('e.g. "3", "12-18" or "1,4,7-9"; at most 20 per view, required for documents over 20 pages.'),revision:r.z.string().optional().describe('With path: the file as committed at this commit, branch or tag; "base" is the version before this branch changed it.')}),exports.ReadFilesSchema=r.z.object({paths:r.z.array(r.z.object({path:r.z.string().optional(),documentId:c.optional(),lines:r.z.string().optional(),symbol:r.z.string().max(200).optional()}).transform(l).refine(d,{message:"path or documentId required"})),encoding:r.z.enum(["utf8","utf-8","ascii","binary"]).optional()}),exports.ListDirectorySchema=r.z.object({path:r.z.string(),levels:r.z.number().min(1).max(4).optional(),sortBy:r.z.enum(["name","modified","size","type"]).optional()}),exports.GetFileInfoSchema=r.z.object({path:r.z.string()}),exports.CreateDirectorySchema=r.z.object({path:r.z.string(),comment:r.z.string().optional()}),exports.MoveFilesSchema=r.z.object({operations:r.z.array(r.z.object({source:r.z.string(),destination:r.z.string()})),comment:r.z.string()}),exports.ReplaceStringSchema=r.z.object({path:r.z.string(),replacements:r.z.array(r.z.object({old_str:r.z.string(),new_str:r.z.string()})),mode:r.z.enum(["unique","all"]).optional(),comment:r.z.string()}),exports.ReplaceStringsSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:c.optional(),replacements:r.z.array(r.z.object({old_str:r.z.string(),new_str:r.z.string()})),mode:r.z.enum(["unique","all"]).optional()}).transform(l).refine(d,{message:"path or documentId required"})),comment:r.z.string()}),exports.ReplaceInFilesSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:c.optional(),replacements:r.z.array(r.z.object({old:r.z.string().min(1,"old string cannot be empty"),new:r.z.string(),match_mode:r.z.enum(["unique","all"]).optional()})).min(1,"At least one replacement required"),fuzzy_match:r.z.boolean().optional()}).transform(l).refine(d,{message:"path or documentId required"})).min(1,"At least one operation required"),fuzzy_match:r.z.boolean().optional().default(!0),comment:r.z.string()}),exports.DeleteFileSchema=r.z.object({path:r.z.string(),comment:r.z.string()}),exports.DeleteFilesSchema=r.z.object({paths:r.z.array(r.z.string()).optional(),operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:c.optional()}).transform(l).refine(d,{message:"path or documentId required"})).optional(),comment:r.z.string()}).refine(e=>e.paths&&!e.operations||!e.paths&&e.operations,{message:"paths or operations required"}).refine(e=>e.paths?.length||e.operations?.length,{message:"path/operation required"}),exports.FileHistorySchema=r.z.object({path:r.z.string(),limit:r.z.number().min(1).max(100).default(10),showDiff:r.z.boolean().default(!1),showTraceability:r.z.boolean().default(!0),branch:r.z.string().optional(),commit:r.z.string().optional(),since:r.z.string().optional()}),exports.FileRecoverSchema=r.z.object({path:r.z.string(),commitHash:r.z.string(),createBackup:r.z.boolean().default(!0)}),exports.MergePreviewSchema=r.z.object({requestId:a,format:r.z.enum(["summary","unified"]).default("summary").describe("summary = per-file counts; unified = the diff the merge would add to your branch"),path:r.z.string().optional().describe('Optional git pathspec to scope the preview (e.g. "src/hud.css", "src/", "**/*.ts")')}),exports.RequestDiffSchema=r.z.object({requestId:a,format:r.z.enum(["summary","unified"]).default("summary"),path:r.z.string().optional()}),exports.QueryHistorySchema=r.z.object({queryType:r.z.enum(["file-history","task-file-history","request-file-history","recover","blame"],{errorMap:()=>({message:"Invalid queryType. Valid options: file-history, task-file-history, request-file-history, recover, blame"})}),fileHistory:r.z.object({path:r.z.string(),limit:r.z.number().min(1).max(100).default(10),showDiff:r.z.boolean().default(!1),showTraceability:r.z.boolean().default(!0),branch:r.z.string().optional(),commit:r.z.string().optional(),since:r.z.string().optional()}).optional(),taskHistory:r.z.object({taskId:i,showDiff:r.z.boolean().optional()}).optional(),requestHistory:r.z.object({requestId:a,detailLevel:r.z.enum(["summary","detailed"]).default("summary"),taskId:i.optional(),showDiff:r.z.boolean().optional(),fileFilter:r.z.string().optional()}).optional(),recover:r.z.object({path:r.z.string(),commitHash:r.z.string().optional(),createBackup:r.z.boolean().default(!0)}).optional(),blame:r.z.object({path:r.z.string(),lines:r.z.string().optional(),branch:r.z.string().optional()}).optional()}).refine(e=>"file-history"===e.queryType?e.fileHistory&&!e.requestHistory&&!e.recover:"task-file-history"===e.queryType?e.taskHistory&&!e.fileHistory&&!e.requestHistory&&!e.recover:"request-file-history"===e.queryType?e.requestHistory&&!e.fileHistory&&!e.recover:"recover"===e.queryType?e.recover&&!e.fileHistory&&!e.requestHistory&&!e.blame:"blame"===e.queryType&&e.blame&&!e.fileHistory&&!e.requestHistory&&!e.recover,{message:"Invalid query data"}),exports.SearchSchema=r.z.object({needle:r.z.string().optional(),directory:r.z.string().optional(),directories:r.z.array(r.z.string()).max(8).optional(),options:r.z.object({caseSensitive:r.z.boolean().optional(),fileExtension:r.z.string().optional(),maxResults:r.z.number().optional(),useRegex:r.z.boolean().optional(),searchIn:r.z.enum(["content","filename","both"]).default("content").optional(),contextLines:r.z.number().min(0).optional(),levels:r.z.number().min(1).max(4).optional(),sortBy:r.z.enum(["name","modified","size","type"]).optional()}).optional()}),exports.ListTasksSchema=r.z.object({requestId:a,filters:r.z.object({status:r.z.enum(["pending","in_progress","ready_for_review","completed","canceled","reverted"]).optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).optional()}),exports.ListRequestsSchema=r.z.object({filters:r.z.object({type:exports.RequestTypeEnum.optional(),status:exports.RequestStatusFilterEnum.optional(),planDocumentId:r.z.string().optional(),scheduleDocumentId:r.z.string().optional().describe("Requests a schedule fired: that schedule document."),questDocumentId:r.z.string().optional().describe("Legacy name of scheduleDocumentId."),dateFrom:r.z.string().optional().describe("Only requests with activity from this date on (YYYY-MM-DD means that whole day in the user's clock, or an ISO timestamp)."),dateTo:r.z.string().optional().describe("Only requests with activity up to this date (YYYY-MM-DD includes the whole day)."),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).optional()}),exports.GetRequestInformationSchema=r.z.object({requestId:a}),exports.GetTaskInformationSchema=r.z.object({taskId:i}),exports.CompleteTaskSchema=r.z.object({taskId:i,summary:r.z.string()}),exports.TaskInspectSchema=r.z.object({operation:r.z.enum(["get-info","list"]),taskId:i.optional(),requestId:a.optional(),status:r.z.enum(["pending","in_progress","ready_for_review","completed","canceled","reverted"]).optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).superRefine((e,t)=>{"get-info"!==e.operation||e.taskId||t.addIssue({code:"custom",message:'taskId is required for get-info. Example: { "operation": "get-info", "taskId": "req000001#01" }'}),"list"!==e.operation||e.requestId||t.addIssue({code:"custom",message:'requestId is required for list. Example: { "operation": "list", "requestId": "req000001" }'})})
5201
- const u=r.z.string().min(1).describe("OpenCode session ID")
5202
- exports.SubagentOperationsSchema=r.z.object({sessionId:u.optional(),operation:r.z.enum(["spawn","continue","check-status","abort","read-messages","list-sessions"]),prompt:r.z.string().min(1).describe("Instructions for the subagent (required for spawn and continue)").optional(),agent:r.z.string().default("work").refine(e=>(0,n.isValidAgent)(e),{message:"Invalid agent. Check tool description for available agents."}).describe("The subagent type to spawn (see tool description for available agents)").optional(),description:r.z.string().max(60).describe("Brief label for the UI (max 60 chars, spawn only)").optional(),requestId:r.z.string().describe("Request ID: associates work (spawn) or filters results (list-sessions)").optional(),allowParallel:r.z.boolean().describe("Allow spawning even if request already has active workers (spawn only)").optional(),useExistingSession:r.z.string().describe("Existing session ID to send prompt to instead of creating new session (spawn only)").optional(),limit:r.z.number().min(1).max(100).describe("Max items to return (read-messages: max 50, list-sessions: max 100)").optional(),compact:r.z.boolean().describe("read-messages: return a one-line index of EACH message with tool-call markers (the subagent`s trajectory at a glance: which tools ran, in what order, which failed), instead of full text. Use to see what a subagent actually DID, then `select` one for detail.").optional(),select:r.z.number().min(1).describe("read-messages: return ONLY this message number (from the compact list) in full structured detail: each tool call as {tool, input, status, output}, plus its text. The objective record of one step.").optional(),activeOnly:r.z.boolean().describe("Only show sessions that are currently active/busy (list-sessions only)").optional(),minTokens:r.z.number().min(0).describe("Only show sessions with at least this many tokens (list-sessions only)").optional(),maxTokens:r.z.number().min(0).describe("Only show sessions with at most this many tokens (list-sessions only)").optional(),maxAgeHours:r.z.number().min(0).describe("Only show sessions newer than X hours (list-sessions only)").optional()}).refine(e=>"spawn"===e.operation?!!e.prompt:"continue"===e.operation?!!e.prompt&&!!e.sessionId:"check-status"===e.operation||"abort"===e.operation||"read-messages"===e.operation?!!e.sessionId:"list-sessions"===e.operation,{message:"spawn requires prompt; continue requires prompt+sessionId; check-status/abort/read-messages require sessionId"}),exports.ResearchFanoutSchema=r.z.object({goal:r.z.string().min(1).optional().describe("What to research; passed to every angle. Required to START a run."),angles:r.z.array(r.z.string()).optional().describe("Research angles to fan out over. Omit to use the default set (data-model, call-sites, prior-art/history, external/web, test-surface)."),planId:r.z.string().optional().describe("Plan document to reference the research report from when the run completes."),checkRunId:r.z.string().optional().describe("Pass a runId from a previous start to CHECK that run live progress instead of starting a new one.")}).refine(e=>!(!e.goal||!e.goal.trim())||!!e.checkRunId,{message:"Provide goal to start a run, or checkRunId to check one."}),exports.PlannerOpsSchema=r.z.object({operation:r.z.enum(["request","check-status","list","end"]),sessionId:u.optional(),prompt:r.z.string().min(1).describe("What to plan: feature description, architecture question, etc. (required for request)").optional(),description:r.z.string().max(60).describe("Brief label for the UI (max 60 chars, request only)").optional(),userRequested:r.z.boolean().describe("Set true ONLY when the user explicitly asked for this plan in their own words: their message IS the decision, so the planner starts immediately instead of asking them to choose a planning approach (request only)").optional(),documentId:r.z.string().describe("Plan an EXISTING document instead of creating a new one: the planner binds to this document, reads it first, and evolves it in place with plan_write (request only)").optional(),activeOnly:r.z.boolean().describe("Only show active/busy planning sessions (list only)").optional(),limit:r.z.number().min(1).max(100).describe("Max sessions to return (list only)").optional()}).refine(e=>"request"===e.operation?!!e.prompt:"check-status"===e.operation?!!e.sessionId:"list"===e.operation||"end"===e.operation&&(!!e.sessionId||!!e.documentId),{message:"request requires prompt; check-status requires sessionId; end requires sessionId or documentId"}),exports.InsertLinesSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:c.optional(),insertions:r.z.array(r.z.object({type:r.z.enum(["before","after","between"]),line:r.z.number().optional(),afterLine:r.z.number().optional(),beforeLine:r.z.number().optional(),content:r.z.union([r.z.string(),r.z.array(r.z.string())])}).refine(e=>"between"===e.type?void 0!==e.afterLine&&void 0!==e.beforeLine&&void 0===e.line:void 0!==e.line&&void 0===e.afterLine&&void 0===e.beforeLine,{message:"Invalid line parameters"}))}).transform(l).refine(d,{message:"path or documentId required"})),comment:r.z.string()}),exports.ReplaceLinesSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:c.optional(),replacements:r.z.array(r.z.object({lines:r.z.string(),content:r.z.union([r.z.string(),r.z.array(r.z.string())])}))}).transform(l).refine(d,{message:"path or documentId required"})),comment:r.z.string()}),exports.CreateDocumentSchema=r.z.object({requestId:a.optional(),filename:r.z.string().refine(e=>/\.(md|html?)$/i.test(e),{message:"Filename must end in .md (prose) or .html (a rendered page)"}),content:r.z.string(),comment:r.z.string(),scheduleIntervalSeconds:r.z.number().int().min(300).describe("Fire interval in seconds (min 300). Setting this makes the document a SCHEDULE: the runner periodically asks the alchemist to read it and create one linked request. 86400 = daily. Prefer scheduleAtTimes when the goal wants a time of day.").optional(),scheduleAtTimes:r.z.string().describe("Local time(s) of day to fire, e.g. '09:00' or '09:00,17:00'. Setting this makes the document a SCHEDULE that runs at that clock time instead of on an interval, and it starts at the next such time (never the moment it is created).").optional(),scheduleOnDays:r.z.string().describe("Which days scheduleAtTimes applies to: 'weekdays', 'weekends', or names like 'mon,thu'. Omit for every day.").optional(),schedulePrompt:r.z.string().describe('What each firing should do -- the instruction the alchemist receives per tick (e.g. "validate quotes.ndjson and file a short report; flag the user only on real breakage").').optional(),scheduleMaxPerDay:r.z.number().int().min(1).describe("Cap on firings per day (structural guard). Default 1 for daily-style schedules.").optional(),scheduleMaxInFlight:r.z.number().int().min(1).describe("Cap on live linked requests before firings pause (structural guard). Default 1.").optional()}),exports.SearchDocumentsSchema=r.z.object({query:r.z.string(),requestId:a.optional(),includeArchived:r.z.boolean().default(!1),maxResults:r.z.number().min(1).max(100).default(20),dateFrom:r.z.string().optional(),dateTo:r.z.string().optional(),searchIn:r.z.enum(["content","filename","both"]).default("both")}),exports.DocumentOperationsSchema=r.z.object({operation:r.z.enum(["create","update","search","create-snapshot","get-history","get-version","restore-version","archive","unarchive","list-annotations","create-annotation","reply-to-annotation","resolve-annotation","create-artifact-annotation","propose-standard"]),standardRules:r.z.array(r.z.object({text:r.z.string().min(1).max(600).describe("One statement of the standard as agents should read it, in its own words where they are clear"),section:r.z.string().min(1).max(120).describe("The heading of the section it comes from"),checked:r.z.boolean().describe("true when a reviewer can judge it from the delivered work: its files, results and the worker's account (checked in review); false for practice agents are told, and for what only the final reply to the user shows (written after the review)"),kinds:r.z.array(r.z.enum(["code","engineering","writing","drive"])).max(4).optional().describe("The kinds of work it governs; left out, all")})).min(1).max(12).optional().describe("propose-standard: at most 12 per call; call again for the rest"),documentId:c.optional(),requestId:a.optional(),filename:r.z.string().optional(),content:r.z.string().optional(),comment:r.z.string().optional(),scheduleIntervalSeconds:r.z.number().int().min(300).optional(),scheduleAtTimes:r.z.string().optional(),scheduleOnDays:r.z.string().optional(),schedulePrompt:r.z.string().optional(),scheduleMaxPerDay:r.z.number().int().min(1).optional(),scheduleMaxInFlight:r.z.number().int().min(1).optional(),query:r.z.string().optional(),includeArchived:r.z.boolean().default(!1),maxResults:r.z.number().min(1).max(100).default(20),dateFrom:r.z.string().optional(),dateTo:r.z.string().optional(),searchIn:r.z.enum(["content","filename","both"]).default("both"),replacements:r.z.array(r.z.object({old_str:r.z.string().describe("Exact text to find in the document"),new_str:r.z.string().describe("Replacement text")})).optional(),mode:r.z.enum(["unique","all"]).optional(),versionLabel:r.z.string().optional(),changeSummary:r.z.string().optional(),versionNumber:r.z.number().int().min(1).optional(),selectedText:r.z.string().optional(),prefixContext:r.z.string().optional(),suffixContext:r.z.string().optional(),lineHint:r.z.number().int().optional(),body:r.z.string().optional(),annotationId:r.z.string().optional(),ref:r.z.string().optional().describe('Artifact reference, e.g. "file:src/main.cpp"'),file:r.z.string().optional().describe("Repo-relative file path the comment is pinned to"),line:r.z.union([r.z.number().int(),r.z.string()]).optional().describe("1-based line number the comment is pinned to")}).superRefine((e,t)=>{const r=e.operation
5217
+ Object.defineProperty(exports,"__esModule",{value:!0}),exports.LogLevel=void 0,function(e){e.ERROR="error",e.WARN="warn",e.INFO="info",e.DEBUG="debug"}(t||(exports.LogLevel=t={}))},76183(e,exports,t){Object.defineProperty(exports,"__esModule",{value:!0}),exports.SearchDocumentsSchema=exports.CreateDocumentSchema=exports.ReplaceLinesSchema=exports.InsertLinesSchema=exports.PlannerOpsSchema=exports.ResearchFanoutSchema=exports.SubagentOperationsSchema=exports.TaskInspectSchema=exports.CompleteTaskSchema=exports.GetTaskInformationSchema=exports.GetRequestInformationSchema=exports.ListRequestsSchema=exports.ListTasksSchema=exports.SearchSchema=exports.QueryHistorySchema=exports.RequestDiffSchema=exports.MergePreviewSchema=exports.FileRecoverSchema=exports.FileHistorySchema=exports.DeleteFilesSchema=exports.DeleteFileSchema=exports.ReplaceInFilesSchema=exports.ReplaceStringsSchema=exports.ReplaceStringSchema=exports.MoveFilesSchema=exports.CreateDirectorySchema=exports.GetFileInfoSchema=exports.ListDirectorySchema=exports.ReadFilesSchema=exports.ViewAssetSchema=exports.WriteFileSchema=exports.UpdateTaskStatusSchema=exports.CreateTaskSchema=exports.CreateRequestSchema=exports.CompleteRequestSchema=exports.BaselineSchema=exports.skipTestsSchema=exports.skipTestsReasonSchema=exports.ExecutedTestSchema=exports.TestVerificationSchema=exports.TestDefinitionSchema=exports.AcceptanceCriterionSchema=exports.RecordTypeEnum=exports.RequestStatusEnum=exports.TaskStatusEnum=exports.RequestStatusFilterEnum=exports.SettableRequestTypeEnum=exports.RequestTypeEnum=exports.TestCoverageTypeEnum=exports.CompletionStatusEnum=void 0,exports.EnvironmentVerifySchema=exports.EnvironmentDeleteSchema=exports.EnvironmentUpdateSchema=exports.EnvironmentCreateSchema=exports.EnvironmentVerifyStackSchema=exports.EnvironmentStatusSchema=exports.EnvironmentTeardownSchema=exports.EnvironmentProvisionSchema=exports.EnvironmentGetSchema=exports.AskUserVisualSchema=exports.RequestVisualFeedbackSchema=exports.FetchAssetSchema=exports.PreviewSiteSchema=exports.CaptureSiteSchema=exports.DriveSiteSchema=exports.ReadSiteSchema=exports.ExperimentListSchema=exports.ExperimentStopSchema=exports.ExperimentStartSchema=exports.ResultInspectSchema=exports.ResultsSchema=exports.EnvironmentListSchema=exports.TestingProcessDeleteSchema=exports.TestingProcessCreateSchema=exports.TestingProcessGetSchema=exports.TestingProcessListSchema=exports.MetaOperationsSchema=exports.MetaAgentListSchema=exports.MetaWorkflowRemoveRecipeSchema=exports.MetaWorkflowAddRecipeSchema=exports.MetaHookCreateSchema=exports.MetaHookListSchema=exports.MetaRecipeRemoveHookSchema=exports.MetaRecipeAddHookSchema=exports.MetaRecipeCreateSchema=exports.MetaRecipeGetSchema=exports.MetaRecipeListSchema=exports.MetaWorkflowUpdateSchema=exports.MetaWorkflowCreateSchema=exports.MetaWorkflowGetSchema=exports.MetaWorkflowListSchema=exports.QuickReplaceSchema=exports.QuickWriteSchema=exports.RequestOperationsSchema=exports.ManageFilesSchema=exports.ModifyFileSchema=exports.RevertRequestSchema=exports.PlanWriteSchema=exports.PlanReadSchema=exports.DocumentOperationsSchema=void 0,exports.AnswerQuestionSchema=exports.McpConnectionsSchema=exports.DirectiveOperationsSchema=exports.CommitToViewedSessionSchema=exports.SessionMessageOperationsSchema=exports.OpeningBriefSectionSchema=exports.ReportTestResultsSchema=exports.CommandsSchema=exports.RunSchema=exports.ExecuteTestCommandSchema=exports.TestsSchema=exports.TestingProcessUpdateSchema=exports.EnvironmentSetupSchema=void 0
5218
+ const r=t(11569),n=t(8955),o=t(94466),s=e=>"string"!=typeof e||e.trim()?e:void 0,i=(e,t,n={})=>r.z.string().refine(t=>!(!n.allowEmpty||""!==t)||!!t&&e.some(e=>e.test(t)),{message:t}),a=i([o.TASK_REF_PATTERN,o.TASK_REF_SHORT_PATTERN],"Task ID must be req######+#NN (e.g. req000005#03) or a short form like #01, 01, or 1 (resolved against the active request)."),c=i([/^req\d{6}$/],"Request ID must match format: req###### (e.g. req000001)"),l=i([/^doc_[0-9A-Z]{26}$/i,/^(doc|plan|quest|jour)\d{6}$/],"Document ID must match format: doc_[26 alphanumeric] (ULID) or doc######/plan######/quest######/jour###### (local ID)",{allowEmpty:!0}),d=e=>e.path&&e.documentId?{...e,documentId:void 0}:e,u=e=>Boolean(e.path)||Boolean(e.documentId)
5219
+ exports.CompletionStatusEnum=r.z.enum(["complete","incomplete","partial"]),exports.TestCoverageTypeEnum=r.z.enum(["unit","e2e","integration","manual"]),exports.RequestTypeEnum=r.z.enum(["code","quick-edit","drive","writing","engineering","setup"]),exports.SettableRequestTypeEnum=r.z.enum(["code","drive","writing","engineering"]),exports.RequestStatusFilterEnum=r.z.enum(["draft","open","in_progress","ready_for_review","ready_for_merge","resolving_conflicts","conflicted","completed","canceled","reverted","in_flight"]).describe("A status, or in_flight: every request under way."),exports.TaskStatusEnum=r.z.enum(["pending","in_progress","ready_for_review","completed","canceled","reverted"]),exports.RequestStatusEnum=r.z.enum(["open","in_progress","ready_for_review","ready_for_merge","completed","canceled","reverted","conflicted"]),exports.RecordTypeEnum=r.z.enum(["write","modify","blocker","resolution","discovery","test","delete"]),exports.AcceptanceCriterionSchema=r.z.object({description:r.z.string(),createdAt:r.z.string().optional(),updatedAt:r.z.string().optional()}),exports.TestDefinitionSchema=r.z.object({id:r.z.string(),description:r.z.string(),status:exports.CompletionStatusEnum,coverageType:exports.TestCoverageTypeEnum,accepts:r.z.array(r.z.string())}),exports.TestVerificationSchema=r.z.object({criteria:r.z.array(r.z.string()),tests:r.z.array(r.z.string()),coverageType:exports.TestCoverageTypeEnum,coverageRatio:r.z.number(),createdAt:r.z.string().optional(),updatedAt:r.z.string().optional()}),exports.ExecutedTestSchema=r.z.object({id:r.z.string(),testId:r.z.string(),status:exports.CompletionStatusEnum,results:r.z.string(),coverage:r.z.array(r.z.string()),executedAt:r.z.string()}),exports.skipTestsReasonSchema=r.z.string().min(20).optional().describe("Opt out of all tests (reason of 20+ characters). Refused under the strict test gate and when any test command is required. For some commands, use skipTests."),exports.skipTestsSchema=r.z.array(r.z.object({commandName:r.z.string().min(1).describe("A registered test command's name."),reason:r.z.string().min(20).describe("Why it is irrelevant to the change (20+ characters).")})).optional().describe("Skip test commands by name; not with skipTestsReason. Refused under the strict test gate and for required commands."),exports.BaselineSchema=r.z.object({metric:r.z.string().regex(/^[A-Za-z_][A-Za-z0-9_.-]{0,59}$/).describe('"time" for the command\'s own running time in seconds, or the name of a number the command prints ("items_per_s: 812", "passed=41", JSON {"size_kb": 88}).'),better:r.z.enum(["lower","higher"]).describe("Which way is better: lower for a time or a size, higher for a throughput or a test count."),tolerancePct:r.z.number().min(0).max(1e3).optional().describe("How much worse, in percent of the value before the change, still counts as no worse. Default 10; the user's number when they gave one."),atLeast:r.z.number().min(0).optional().describe("And worse by at least this much in the metric's unit before it counts (default 0.1 for time, else 0)."),repeats:r.z.number().int().min(1).max(9).optional().describe("Runs on each side, default 3; 1 for a number that never varies (a count, a size).")}).describe("Only when the user asks that something measured must not get worse (a benchmark time, a test count, a size). Needs `command`, kind objective. The criterion then holds while the command's number on this work is no worse than before it, measured side by side in the project's box; a regression waits for the user's sign-off."),exports.CompleteRequestSchema=r.z.object({status:exports.RequestStatusEnum,acceptanceCriteria:r.z.array(exports.AcceptanceCriterionSchema),testVerification:exports.TestVerificationSchema.optional(),completionSummary:r.z.string().optional()}),exports.CreateRequestSchema=r.z.object({title:r.z.string(),process:r.z.string().optional().describe('The workflow process this request follows, by name (e.g. "CFD case"): it sets the kind and adds the process\'s rules as criteria. Name one when the request clearly is that kind of work; with none, the reply lists those that fit. Unknown names are refused with the list.'),userSaid:r.z.string().min(8).max(600).optional().describe("The user's words asking for this request, copied exactly in their language: the phrase that asks, not the whole message (matched as an exact excerpt). Pass it whenever the request comes from what the user wrote; with several messages at once, the request is filed under the one it quotes. Required for a 'gate' criterion, whose words must ask for the check to keep running."),type:exports.SettableRequestTypeEnum.describe("'code': builds or fixes behaviour (a branch, a worker, the workflow's gates, a merge). 'writing': prose that lives in the repo (docs, page copy), handled the same way. 'drive': a verification errand: the driver exercises the product through its user doors against the criteria as claims; no branch, no merge, and an UNMET claim waits for the user's sign-off. 'engineering': a model, simulation or analysis whose numbers are the product, reviewed on its assumptions and the evidence for each number; prefer it over 'code' when the deliverable is a result and its justification."),description:r.z.string().optional().describe('What to build or find out and why, for whoever picks it up; the record, not a reply to the user, so rules about how you talk to them do not apply. The user reads it on the request page: call them "you", never "the user"; name agents by their job (the worker, the Alchemist).'),quotesMessage:r.z.boolean().optional().describe("true when the user's message is the specification (a brief, a pasted spec, text for the product): it is copied into the description word for word under 'Your words:', and your description is only what you add. Do not write their message out yourself. With several messages, userSaid picks which."),acceptanceCriteria:r.z.array(r.z.union([r.z.string(),r.z.object({description:r.z.string().min(1),beforeMerge:r.z.boolean().optional().describe("[user-input] criteria only: true when the user asked to check it themselves before it merges. The merge then waits for them at every Autonomy level; otherwise Self-driving treats no answer as not checked by them."),command:r.z.string().min(1).max(500).optional().describe("The command that decides this criterion, if one does (e.g. `.venv/bin/python -m pytest tests`), as it runs in the project's box. The worker may add checks, not replace it. Keep it out of the text."),kind:r.z.enum(["objective","subjective","gate"]).describe("objective: provable by running something (strings, files, exit codes, return values), even when the project has no tests yet. subjective: needs judgment (looks, reads, compares). gate: a check that runs on every merge from now on, met only by a test process registered for this request; its gate run is the verdict."),baseline:exports.BaselineSchema.optional()})])).optional().describe('Verifiable done-conditions: a string, or { description, kind } to say how it is proven. Split a mixed claim into one of each kind. A criterion says what must be true of the result, never that a check was run or its output recorded ("prints the tracked-file count", not "was run and its output recorded"). Put what must come from the user in its own criterion marked [user-input]; the card at the end of the work asks them for it. Criteria show on the user\'s cards, so address them as "you": "[user-input] You have tried it and say it works".'),draft:r.z.boolean().optional().describe("A draft: on the timeline, no branch, nothing runs until the user starts it (a title alone is fine). How a worker hands over work nobody asked for (with follows: your request)."),delegate:r.z.boolean().optional(),follows:r.z.string({required_error:"Required. Every request either follows earlier work or starts fresh: pass the origin request id (req######) or the word 'new'."}).refine(e=>"new"===e||/^(round:)?req\d{6}$/.test(e),{message:"Pass a request id like req000031, 'round:req000031' for another round of work that has landed, or 'new' for genuinely new work."}).describe("What this grows out of. 'round:req######': another pass at what that merged request built (bigger, another colour, the wording back); shown with it as one item and built by its builder. 'req######': a follow-up, a fix for its fallout or a continuation, only when the user pointed at it (anchored the message to it, named it, said 'that change') or you are working it; the request you are on is usually the origin. 'new': fresh work, including a new feature on an existing app and anything the user asks for on its own, even if it touches an earlier request's work (name that one in the description). The project's founding request is not an origin for later work. Only this field links requests."),planDocumentId:r.z.string().optional().describe("The plan document that decomposes this work (plan######); not the schedule that dispatched you (that is scheduleDocumentId)."),scheduleDocumentId:r.z.string().optional().describe("The schedule document that dispatched this request; only when a schedule told you to create it, with the id it gave."),questDocumentId:r.z.string().optional(),waitsOn:r.z.array(r.z.string().regex(/^req\d{6}$/)).max(5).optional().describe("Requests this one waits for: registered now, started once all have landed. A canceled one never lands; the wait holds until moved or cleared. Declare it here, not afterwards: work is dispatched at registration. When this grows out of a request that has not landed, choose this or startsNow."),waitReason:r.z.string().optional().describe('With waitsOn (required there): what this request needs from the one it waits for, as the user reads it ("builds on the settings page req000012 adds"). When it needs nothing from it, it does not wait.'),startsNow:r.z.boolean().optional().describe("The other answer to waitsOn: true starts this now, alongside the unlanded request. The user's words decide (at once: start now; one after the other: wait). If they said nothing about order, wait when both change the same code."),asked:r.z.array(r.z.string().regex(/^Q-[A-Z0-9]+-\d+$/)).max(5).optional().describe("Your open questions to the user (Q-codes) that decide something here: the worker does not ask them again and gets the answer too. Pass them whenever the request builds on an answer you are waiting for."),userChoices:r.z.array(r.z.string().regex(/^Q-[A-Za-z0-9]+-\d+$/)).max(10).optional().describe("Cards the user answered that this request builds on (e.g. Q-ABCD1234-001); their picks count as sources in review, so carry the picked words into the description. A card still waiting for the user may be named (file on its default); it counts once answered. A card closed by an agent, a default or a withdrawal is refused."),replaces:r.z.string().regex(/^req\d{6}$/).optional().describe("The canceled request this one refiles. What waited on it waits on this one instead. Only a canceled request can be replaced."),areas:r.z.array(r.z.string()).max(3).optional().describe("Work-area labels, 1-3, required unless draft: lowercase kebab paths (e.g. 'graphics/opengl/shader-cache'). Pick from request_operations list-areas; add a new name only when nothing fits, nested under an existing parent. New names are registered automatically.")}),exports.CreateTaskSchema=r.z.object({requestId:c,title:r.z.string(),description:r.z.string()}),exports.UpdateTaskStatusSchema=r.z.object({taskId:a,status:exports.TaskStatusEnum,note:r.z.string()}),exports.WriteFileSchema=r.z.object({path:r.z.string().optional(),documentId:l.optional(),content:r.z.union([r.z.string(),r.z.array(r.z.string())]).optional(),fromResult:r.z.string().optional().describe('Instead of content: a recorded result (its address, or a unique prefix) whose bytes become this file, unchanged. For a file made somewhere you cannot write the worktree from, e.g. a .docx made in a sealed box and recorded with results({ operation: "record", box }). Files only (with path), up to 20 MB; bulk stays in the store (results pin).'),format:r.z.enum(["text","json"]).optional(),append:r.z.boolean().optional(),comment:r.z.string()}).transform(d).refine(u,{message:"path or documentId required"}).refine(e=>void 0!==e.content!==Boolean(e.fromResult),{message:"pass content or fromResult (exactly one)"}),exports.ViewAssetSchema=r.z.object({filename:r.z.string().optional().describe("An image in .alchemy_lab/assets/, as an asset:<filename> ref names it."),path:r.z.string().optional().describe("An image, PDF or office file (Word, Excel, PowerPoint, OpenDocument, .doc/.xls/.ppt/.rtf) in the working tree."),result:r.z.string().optional().describe("A recorded result: its address or a unique prefix."),pages:r.z.string().optional().describe('e.g. "3", "12-18" or "1,4,7-9"; at most 20 per view, required for documents over 20 pages.'),revision:r.z.string().optional().describe('With path: the file as committed at this commit, branch or tag; "base" is the version before this branch changed it.')}),exports.ReadFilesSchema=r.z.object({paths:r.z.array(r.z.object({path:r.z.string().optional(),documentId:l.optional(),lines:r.z.string().optional(),symbol:r.z.string().max(200).optional()}).transform(d).refine(u,{message:"path or documentId required"})),encoding:r.z.enum(["utf8","utf-8","ascii","binary"]).optional()}),exports.ListDirectorySchema=r.z.object({path:r.z.string(),levels:r.z.number().min(1).max(4).optional(),sortBy:r.z.enum(["name","modified","size","type"]).optional()}),exports.GetFileInfoSchema=r.z.object({path:r.z.string()}),exports.CreateDirectorySchema=r.z.object({path:r.z.string(),comment:r.z.string().optional()}),exports.MoveFilesSchema=r.z.object({operations:r.z.array(r.z.object({source:r.z.string(),destination:r.z.string()})),comment:r.z.string()}),exports.ReplaceStringSchema=r.z.object({path:r.z.string(),replacements:r.z.array(r.z.object({old_str:r.z.string(),new_str:r.z.string()})),mode:r.z.enum(["unique","all"]).optional(),comment:r.z.string()}),exports.ReplaceStringsSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:l.optional(),replacements:r.z.array(r.z.object({old_str:r.z.string(),new_str:r.z.string()})),mode:r.z.enum(["unique","all"]).optional()}).transform(d).refine(u,{message:"path or documentId required"})),comment:r.z.string()}),exports.ReplaceInFilesSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:l.optional(),replacements:r.z.array(r.z.object({old:r.z.string().min(1,"old string cannot be empty"),new:r.z.string(),match_mode:r.z.enum(["unique","all"]).optional()})).min(1,"At least one replacement required"),fuzzy_match:r.z.boolean().optional()}).transform(d).refine(u,{message:"path or documentId required"})).min(1,"At least one operation required"),fuzzy_match:r.z.boolean().optional().default(!0),comment:r.z.string()}),exports.DeleteFileSchema=r.z.object({path:r.z.string(),comment:r.z.string()}),exports.DeleteFilesSchema=r.z.object({paths:r.z.array(r.z.string()).optional(),operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:l.optional()}).transform(d).refine(u,{message:"path or documentId required"})).optional(),comment:r.z.string()}).refine(e=>e.paths&&!e.operations||!e.paths&&e.operations,{message:"paths or operations required"}).refine(e=>e.paths?.length||e.operations?.length,{message:"path/operation required"}),exports.FileHistorySchema=r.z.object({path:r.z.string(),limit:r.z.number().min(1).max(100).default(10),showDiff:r.z.boolean().default(!1),showTraceability:r.z.boolean().default(!0),branch:r.z.string().optional(),commit:r.z.string().optional(),since:r.z.string().optional()}),exports.FileRecoverSchema=r.z.object({path:r.z.string(),commitHash:r.z.string(),createBackup:r.z.boolean().default(!0)}),exports.MergePreviewSchema=r.z.object({requestId:c,format:r.z.enum(["summary","unified"]).default("summary").describe("summary = per-file counts; unified = the diff the merge would add to your branch"),path:r.z.string().optional().describe('Optional git pathspec to scope the preview (e.g. "src/hud.css", "src/", "**/*.ts")')}),exports.RequestDiffSchema=r.z.object({requestId:c,format:r.z.enum(["summary","unified"]).default("summary"),path:r.z.string().optional()}),exports.QueryHistorySchema=r.z.object({queryType:r.z.enum(["file-history","task-file-history","request-file-history","recover","blame"],{errorMap:()=>({message:"Invalid queryType. Valid options: file-history, task-file-history, request-file-history, recover, blame"})}),fileHistory:r.z.object({path:r.z.string(),limit:r.z.number().min(1).max(100).default(10),showDiff:r.z.boolean().default(!1),showTraceability:r.z.boolean().default(!0),branch:r.z.string().optional(),commit:r.z.string().optional(),since:r.z.string().optional()}).optional(),taskHistory:r.z.object({taskId:a,showDiff:r.z.boolean().optional()}).optional(),requestHistory:r.z.object({requestId:c,detailLevel:r.z.enum(["summary","detailed"]).default("summary"),taskId:a.optional(),showDiff:r.z.boolean().optional(),fileFilter:r.z.string().optional()}).optional(),recover:r.z.object({path:r.z.string(),commitHash:r.z.string().optional(),createBackup:r.z.boolean().default(!0)}).optional(),blame:r.z.object({path:r.z.string(),lines:r.z.string().optional(),branch:r.z.string().optional()}).optional()}).refine(e=>"file-history"===e.queryType?e.fileHistory&&!e.requestHistory&&!e.recover:"task-file-history"===e.queryType?e.taskHistory&&!e.fileHistory&&!e.requestHistory&&!e.recover:"request-file-history"===e.queryType?e.requestHistory&&!e.fileHistory&&!e.recover:"recover"===e.queryType?e.recover&&!e.fileHistory&&!e.requestHistory&&!e.blame:"blame"===e.queryType&&e.blame&&!e.fileHistory&&!e.requestHistory&&!e.recover,{message:"Invalid query data"}),exports.SearchSchema=r.z.object({needle:r.z.string().optional(),directory:r.z.string().optional(),directories:r.z.array(r.z.string()).max(8).optional(),options:r.z.object({caseSensitive:r.z.boolean().optional(),fileExtension:r.z.string().optional(),maxResults:r.z.number().optional(),useRegex:r.z.boolean().optional(),searchIn:r.z.enum(["content","filename","both"]).default("content").optional(),contextLines:r.z.number().min(0).optional(),levels:r.z.number().min(1).max(4).optional(),sortBy:r.z.enum(["name","modified","size","type"]).optional()}).optional()}),exports.ListTasksSchema=r.z.object({requestId:c,filters:r.z.object({status:r.z.enum(["pending","in_progress","ready_for_review","completed","canceled","reverted"]).optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).optional()}),exports.ListRequestsSchema=r.z.object({filters:r.z.object({type:exports.RequestTypeEnum.optional(),status:exports.RequestStatusFilterEnum.optional(),planDocumentId:r.z.string().optional(),scheduleDocumentId:r.z.string().optional().describe("Requests a schedule fired: that schedule document."),questDocumentId:r.z.string().optional().describe("Legacy name of scheduleDocumentId."),dateFrom:r.z.string().optional().describe("Only requests with activity from this date on (YYYY-MM-DD means that whole day in the user's clock, or an ISO timestamp)."),dateTo:r.z.string().optional().describe("Only requests with activity up to this date (YYYY-MM-DD includes the whole day)."),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).optional()}),exports.GetRequestInformationSchema=r.z.object({requestId:c}),exports.GetTaskInformationSchema=r.z.object({taskId:a}),exports.CompleteTaskSchema=r.z.object({taskId:a,summary:r.z.string()}),exports.TaskInspectSchema=r.z.object({operation:r.z.enum(["get-info","list"]),taskId:a.optional(),requestId:c.optional(),status:r.z.enum(["pending","in_progress","ready_for_review","completed","canceled","reverted"]).optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).superRefine((e,t)=>{"get-info"!==e.operation||e.taskId||t.addIssue({code:"custom",message:'taskId is required for get-info. Example: { "operation": "get-info", "taskId": "req000001#01" }'}),"list"!==e.operation||e.requestId||t.addIssue({code:"custom",message:'requestId is required for list. Example: { "operation": "list", "requestId": "req000001" }'})})
5220
+ const h=r.z.string().min(1).describe("OpenCode session ID")
5221
+ exports.SubagentOperationsSchema=r.z.object({sessionId:h.optional(),operation:r.z.enum(["spawn","continue","check-status","abort","read-messages","list-sessions"]),prompt:r.z.string().min(1).describe("Instructions for the subagent (required for spawn and continue)").optional(),agent:r.z.string().default("work").refine(e=>(0,n.isValidAgent)(e),{message:"Invalid agent. Check tool description for available agents."}).describe("The subagent type to spawn (see tool description for available agents)").optional(),description:r.z.string().max(60).describe("Brief label for the UI (max 60 chars, spawn only)").optional(),requestId:r.z.string().describe("Request ID: associates work (spawn) or filters results (list-sessions)").optional(),allowParallel:r.z.boolean().describe("Allow spawning even if request already has active workers (spawn only)").optional(),useExistingSession:r.z.string().describe("Existing session ID to send prompt to instead of creating new session (spawn only)").optional(),limit:r.z.number().min(1).max(100).describe("Max items to return (read-messages: max 50, list-sessions: max 100)").optional(),compact:r.z.boolean().describe("read-messages: return a one-line index of EACH message with tool-call markers (the subagent`s trajectory at a glance: which tools ran, in what order, which failed), instead of full text. Use to see what a subagent actually DID, then `select` one for detail.").optional(),select:r.z.number().min(1).describe("read-messages: return ONLY this message number (from the compact list) in full structured detail: each tool call as {tool, input, status, output}, plus its text. The objective record of one step.").optional(),activeOnly:r.z.boolean().describe("Only show sessions that are currently active/busy (list-sessions only)").optional(),minTokens:r.z.number().min(0).describe("Only show sessions with at least this many tokens (list-sessions only)").optional(),maxTokens:r.z.number().min(0).describe("Only show sessions with at most this many tokens (list-sessions only)").optional(),maxAgeHours:r.z.number().min(0).describe("Only show sessions newer than X hours (list-sessions only)").optional()}).refine(e=>"spawn"===e.operation?!!e.prompt:"continue"===e.operation?!!e.prompt&&!!e.sessionId:"check-status"===e.operation||"abort"===e.operation||"read-messages"===e.operation?!!e.sessionId:"list-sessions"===e.operation,{message:"spawn requires prompt; continue requires prompt+sessionId; check-status/abort/read-messages require sessionId"}),exports.ResearchFanoutSchema=r.z.object({goal:r.z.string().min(1).optional().describe("What to research; passed to every angle. Required to START a run."),angles:r.z.array(r.z.string()).optional().describe("Research angles to fan out over. Omit to use the default set (data-model, call-sites, prior-art/history, external/web, test-surface)."),planId:r.z.string().optional().describe("Plan document to reference the research report from when the run completes."),checkRunId:r.z.string().optional().describe("Pass a runId from a previous start to CHECK that run live progress instead of starting a new one.")}).refine(e=>!(!e.goal||!e.goal.trim())||!!e.checkRunId,{message:"Provide goal to start a run, or checkRunId to check one."}),exports.PlannerOpsSchema=r.z.object({operation:r.z.enum(["request","check-status","list","end"]),sessionId:h.optional(),prompt:r.z.string().min(1).describe("What to plan: feature description, architecture question, etc. (required for request)").optional(),description:r.z.string().max(60).describe("Brief label for the UI (max 60 chars, request only)").optional(),userRequested:r.z.boolean().describe("Set true ONLY when the user explicitly asked for this plan in their own words: their message IS the decision, so the planner starts immediately instead of asking them to choose a planning approach (request only)").optional(),documentId:r.z.string().describe("Plan an EXISTING document instead of creating a new one: the planner binds to this document, reads it first, and evolves it in place with plan_write (request only)").optional(),activeOnly:r.z.boolean().describe("Only show active/busy planning sessions (list only)").optional(),limit:r.z.number().min(1).max(100).describe("Max sessions to return (list only)").optional()}).refine(e=>"request"===e.operation?!!e.prompt:"check-status"===e.operation?!!e.sessionId:"list"===e.operation||"end"===e.operation&&(!!e.sessionId||!!e.documentId),{message:"request requires prompt; check-status requires sessionId; end requires sessionId or documentId"}),exports.InsertLinesSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:l.optional(),insertions:r.z.array(r.z.object({type:r.z.enum(["before","after","between"]),line:r.z.number().optional(),afterLine:r.z.number().optional(),beforeLine:r.z.number().optional(),content:r.z.union([r.z.string(),r.z.array(r.z.string())])}).refine(e=>"between"===e.type?void 0!==e.afterLine&&void 0!==e.beforeLine&&void 0===e.line:void 0!==e.line&&void 0===e.afterLine&&void 0===e.beforeLine,{message:"Invalid line parameters"}))}).transform(d).refine(u,{message:"path or documentId required"})),comment:r.z.string()}),exports.ReplaceLinesSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:l.optional(),replacements:r.z.array(r.z.object({lines:r.z.string(),content:r.z.union([r.z.string(),r.z.array(r.z.string())])}))}).transform(d).refine(u,{message:"path or documentId required"})),comment:r.z.string()}),exports.CreateDocumentSchema=r.z.object({requestId:c.optional(),filename:r.z.string().refine(e=>/\.(md|html?)$/i.test(e),{message:"Filename must end in .md (prose) or .html (a rendered page)"}),content:r.z.string(),comment:r.z.string(),scheduleIntervalSeconds:r.z.number().int().min(300).describe("Fire interval in seconds (min 300). Setting this makes the document a SCHEDULE: the runner periodically asks the alchemist to read it and create one linked request. 86400 = daily. Prefer scheduleAtTimes when the goal wants a time of day.").optional(),scheduleAtTimes:r.z.string().describe("Local time(s) of day to fire, e.g. '09:00' or '09:00,17:00'. Setting this makes the document a SCHEDULE that runs at that clock time instead of on an interval, and it starts at the next such time (never the moment it is created).").optional(),scheduleOnDays:r.z.string().describe("Which days scheduleAtTimes applies to: 'weekdays', 'weekends', or names like 'mon,thu'. Omit for every day.").optional(),schedulePrompt:r.z.string().describe('What each firing should do -- the instruction the alchemist receives per tick (e.g. "validate quotes.ndjson and file a short report; flag the user only on real breakage").').optional(),scheduleMaxPerDay:r.z.number().int().min(1).describe("Cap on firings per day (structural guard). Default 1 for daily-style schedules.").optional(),scheduleMaxInFlight:r.z.number().int().min(1).describe("Cap on live linked requests before firings pause (structural guard). Default 1.").optional()}),exports.SearchDocumentsSchema=r.z.object({query:r.z.string(),requestId:c.optional(),includeArchived:r.z.boolean().default(!1),maxResults:r.z.number().min(1).max(100).default(20),dateFrom:r.z.string().optional(),dateTo:r.z.string().optional(),searchIn:r.z.enum(["content","filename","both"]).default("both")}),exports.DocumentOperationsSchema=r.z.object({operation:r.z.enum(["create","update","search","create-snapshot","get-history","get-version","restore-version","archive","unarchive","list-annotations","create-annotation","reply-to-annotation","resolve-annotation","create-artifact-annotation","propose-standard"]),standardRules:r.z.array(r.z.object({text:r.z.string().min(1).max(600).describe("One statement of the standard as agents should read it, in its own words where they are clear"),section:r.z.string().min(1).max(120).describe("The heading of the section it comes from"),checked:r.z.boolean().describe("true when a reviewer can judge it from the delivered work: its files, results and the worker's account (checked in review); false for practice agents are told, and for what only the final reply to the user shows (written after the review)"),kinds:r.z.array(r.z.enum(["code","engineering","writing","drive"])).max(4).optional().describe("The kinds of work it governs; left out, all")})).min(1).max(12).optional().describe("propose-standard: at most 12 per call; call again for the rest"),documentId:l.optional(),requestId:c.optional(),filename:r.z.string().optional(),content:r.z.string().optional(),comment:r.z.string().optional(),scheduleIntervalSeconds:r.z.number().int().min(300).optional(),scheduleAtTimes:r.z.string().optional(),scheduleOnDays:r.z.string().optional(),schedulePrompt:r.z.string().optional(),scheduleMaxPerDay:r.z.number().int().min(1).optional(),scheduleMaxInFlight:r.z.number().int().min(1).optional(),query:r.z.string().optional(),includeArchived:r.z.boolean().default(!1),maxResults:r.z.number().min(1).max(100).default(20),dateFrom:r.z.string().optional(),dateTo:r.z.string().optional(),searchIn:r.z.enum(["content","filename","both"]).default("both"),replacements:r.z.array(r.z.object({old_str:r.z.string().describe("Exact text to find in the document"),new_str:r.z.string().describe("Replacement text")})).optional(),mode:r.z.enum(["unique","all"]).optional(),versionLabel:r.z.string().optional(),changeSummary:r.z.string().optional(),versionNumber:r.z.number().int().min(1).optional(),selectedText:r.z.string().optional(),prefixContext:r.z.string().optional(),suffixContext:r.z.string().optional(),lineHint:r.z.number().int().optional(),body:r.z.string().optional(),annotationId:r.z.string().optional(),ref:r.z.string().optional().describe('Artifact reference, e.g. "file:src/main.cpp"'),file:r.z.string().optional().describe("Repo-relative file path the comment is pinned to"),line:r.z.union([r.z.number().int(),r.z.string()]).optional().describe("1-based line number the comment is pinned to")}).superRefine((e,t)=>{const r=e.operation
5203
5222
  "propose-standard"!==r||e.standardRules&&e.standardRules.length||t.addIssue({code:"custom",message:"standardRules is required for propose-standard: [{ text, section, checked, kinds? }]"}),["create-snapshot","get-history","get-version","restore-version","list-annotations","create-annotation","propose-standard"].includes(r)&&!e.documentId&&t.addIssue({code:"custom",message:`documentId is required for '${r}'. Example: { "operation": "${r}", "documentId": "doc000001" }`}),"create"===r&&(e.filename?/\.(md|html?)$/i.test(e.filename)||t.addIssue({code:"custom",message:"Filename must end in .md (prose) or .html (a rendered page)"}):t.addIssue({code:"custom",message:"filename is required for create (must end in .md or .html)"}),e.content||t.addIssue({code:"custom",message:"content is required for create"})),"search"!==r||e.query||t.addIssue({code:"custom",message:'query is required for search. Example: { "operation": "search", "query": "search term" }'}),"get-version"!==r&&"restore-version"!==r||e.versionNumber||t.addIssue({code:"custom",message:`versionNumber is required for '${r}'`}),"create-annotation"===r&&(e.selectedText||t.addIssue({code:"custom",message:"selectedText is required for create-annotation"}),e.body||t.addIssue({code:"custom",message:"body is required for create-annotation"})),"reply-to-annotation"===r&&(e.annotationId||t.addIssue({code:"custom",message:"annotationId is required for reply-to-annotation"}),e.body||t.addIssue({code:"custom",message:"body is required for reply-to-annotation"})),"resolve-annotation"!==r||e.annotationId||t.addIssue({code:"custom",message:"annotationId is required for resolve-annotation"}),"create-artifact-annotation"===r&&(e.ref||t.addIssue({code:"custom",message:'ref is required for create-artifact-annotation. Example: { "operation": "create-artifact-annotation", "ref": "file:src/main.cpp", "line": 42, "body": "..." }'}),e.body||t.addIssue({code:"custom",message:"body is required for create-artifact-annotation"}))})
5204
- const h=c
5205
- exports.PlanReadSchema=r.z.object({operation:r.z.enum(["get","get-active","list","get-history","get-requests"]),planId:h.optional(),searchQuery:r.z.string().optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["createdAt","updatedAt","filename"]).default("updatedAt"),sortDirection:r.z.enum(["ASC","DESC"]).default("DESC")}).superRefine((e,t)=>{["get","get-history","get-requests"].includes(e.operation)&&!e.planId&&t.addIssue({code:"custom",message:`planId is required for '${e.operation}'. Example: { "operation": "${e.operation}", "planId": "plan000001" }`})}),exports.PlanWriteSchema=r.z.object({operation:r.z.enum(["create","update","append","replace","create-snapshot","restore"]),planId:h.optional(),kind:r.z.enum(["plan"]).default("plan").describe("Document kind to create. Plans only."),content:r.z.string().optional(),name:r.z.string().optional().describe("Plan name (used in filename for create; optional new name for update)."),old:r.z.string().optional().describe("Text to find in the plan (for replace)"),new:r.z.string().optional().describe("Replacement text (for replace)"),versionLabel:r.z.string().optional(),changeSummary:r.z.string().optional(),versionNumber:r.z.number().int().min(1).optional()}).superRefine((e,t)=>{const r=e.operation
5206
- "create"===r?(e.name||t.addIssue({code:"custom",message:"name is required for 'create'. Letters, numbers, hyphens, underscores only."}),void 0===e.content&&t.addIssue({code:"custom",message:"content is required for 'create' (use empty string for an empty body)."})):e.planId||t.addIssue({code:"custom",message:`planId is required for '${r}'.`}),"append"!==r||e.content||t.addIssue({code:"custom",message:'content is required for \'append\'. Example: { "operation": "append", "planId": "plan000001", "content": "..." }'}),"update"===r&&(void 0!==e.content||e.name||t.addIssue({code:"custom",message:"update requires 'content' and/or 'name'."})),"replace"===r&&(e.old||t.addIssue({code:"custom",message:'old is required for replace. Example: { "operation": "replace", "planId": "plan000001", "old": "find this", "new": "replace with" }'}),void 0===e.new&&t.addIssue({code:"custom",message:"new is required for replace"})),"restore"!==r||e.versionNumber||t.addIssue({code:"custom",message:'versionNumber is required for restore. Example: { "operation": "restore", "planId": "plan000001", "versionNumber": 1 }'})}),exports.RevertRequestSchema=r.z.object({requestId:a,reason:r.z.string(),confirmDestructive:r.z.boolean().optional()}),exports.ModifyFileSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:c.optional(),operationType:r.z.enum(["replace-string","insert-lines","replace-lines","delete-string","delete-lines"]),replaceString:r.z.object({replacements:r.z.array(r.z.object({old_str:r.z.string(),new_str:r.z.string()})),mode:r.z.enum(["unique","all"]).optional()}).optional(),insertLines:r.z.object({insertions:r.z.array(r.z.object({type:r.z.enum(["before","after","between"]),line:r.z.number().optional(),afterLine:r.z.number().optional(),beforeLine:r.z.number().optional(),content:r.z.union([r.z.string(),r.z.array(r.z.string())])}).refine(e=>"between"===e.type?void 0!==e.afterLine&&void 0!==e.beforeLine&&void 0===e.line:void 0!==e.line&&void 0===e.afterLine&&void 0===e.beforeLine,{message:"Invalid line parameters"}))}).optional(),replaceLines:r.z.object({replacements:r.z.array(r.z.object({lines:r.z.string(),content:r.z.union([r.z.string(),r.z.array(r.z.string())])}))}).optional(),deleteString:r.z.object({patterns:r.z.array(r.z.string()),mode:r.z.enum(["all","unique"]).optional()}).optional(),deleteLines:r.z.object({lines:r.z.string()}).optional()}).transform(l).refine(d,{message:"path or documentId required"}).refine(e=>"replace-string"===e.operationType?e.replaceString&&!e.insertLines&&!e.replaceLines&&!e.deleteString&&!e.deleteLines:"insert-lines"===e.operationType?e.insertLines&&!e.replaceString&&!e.replaceLines&&!e.deleteString&&!e.deleteLines:"replace-lines"===e.operationType?e.replaceLines&&!e.replaceString&&!e.insertLines&&!e.deleteString&&!e.deleteLines:"delete-string"===e.operationType?e.deleteString&&!e.replaceString&&!e.insertLines&&!e.replaceLines&&!e.deleteLines:"delete-lines"===e.operationType&&e.deleteLines&&!e.replaceString&&!e.insertLines&&!e.replaceLines&&!e.deleteString,{message:"Invalid operation data"})),comment:r.z.string()}),exports.ManageFilesSchema=r.z.object({operations:r.z.array(r.z.object({operationType:r.z.enum(["create-directory","move-files","delete-files","get-file-info"]),createDirectory:r.z.object({path:r.z.string()}).optional(),moveFiles:r.z.object({moves:r.z.array(r.z.object({source:r.z.string(),destination:r.z.string()}))}).optional(),deleteFiles:r.z.object({targets:r.z.array(r.z.object({path:r.z.string().optional(),documentId:c.optional()}).transform(l).refine(d,{message:"path or documentId required"}))}).optional(),getFileInfo:r.z.object({path:r.z.string()}).optional()}).refine(e=>"create-directory"===e.operationType?e.createDirectory&&!e.moveFiles&&!e.deleteFiles&&!e.getFileInfo:"move-files"===e.operationType?e.moveFiles&&!e.createDirectory&&!e.deleteFiles&&!e.getFileInfo:"delete-files"===e.operationType?e.deleteFiles&&!e.createDirectory&&!e.moveFiles&&!e.getFileInfo:"get-file-info"===e.operationType&&e.getFileInfo&&!e.createDirectory&&!e.moveFiles&&!e.deleteFiles,{message:"Invalid operation data"})),comment:r.z.string()}),exports.RequestOperationsSchema=r.z.object({requestId:a.optional(),operation:r.z.enum(["update","activate","complete","merge","revert","reopen","get-info","list","search","cancel","delete-empty","list-areas","update-areas","wait-on","clear-wait","premise-block","dispute-criterion","asked-no-change","hand-over"]),criterion:r.z.string().optional().describe("dispute-criterion: the key (e.g. 1a) of a criterion marked FROM THE PROCESS (or FROM THE WORKFLOW) that does not fit. You cannot drop, reword or waive it: the user waives it for this request or keeps it, and you are told; until then it binds. Put why in reason, plainly: the user reads it."),reason:r.z.string().optional().describe('cancel: why, to the user ("you"), in their language; name the replacing request if any. Also for revert, reopen and wait-on. premise-block (required): what the request builds on that does not exist in the project (a feature, file or surface); the user reads it. Not for what the request itself adds, nor for unclear wording: ask a question.'),userSaid:r.z.string().min(8).max(600).optional().describe("The user's words asking for this, quoted exactly and checked. Required for activate, for cancel when the work is finished and waiting on the user, and for reopen when a question to the user is pending on the request. asked-no-change: their message."),waitsOn:r.z.string().optional(),update:r.z.preprocess(e=>"string"==typeof e?(()=>{try{return JSON.parse(e)}catch{return e}})():e,r.z.object({userSaid:r.z.string().min(8).max(600).optional().describe('The user\'s words asking for this change to the request, quoted exactly (e.g. "skip the HTML counter"). Without them a worker may not narrow or reword its own request.'),removesCriteria:r.z.boolean().optional().describe("acceptanceCriteria replaces the whole list: send every criterion you keep. Set true only to delete those missing; otherwise a list that drops criteria is refused."),arcName:r.z.string().min(2).max(120).optional().describe('The thread\'s name (the requests grown from one ask, read as one story): two to five plain words for the whole thread ("Weekly menu app"). Set it once; a name the user chose is never overwritten.'),title:r.z.string().optional(),description:r.z.string().optional(),process:r.z.string().nullable().optional().describe("A workflow process by name (sets the kind and its rules' criteria), or null to take it off. Only on a draft; after that only the user may change it."),type:exports.SettableRequestTypeEnum.optional(),acceptanceCriteria:r.z.array(r.z.union([r.z.string(),r.z.object({description:r.z.string().min(1),beforeMerge:r.z.boolean().optional(),command:r.z.string().min(1).max(500).optional(),kind:r.z.enum(["objective","subjective","gate"]),key:r.z.string().optional().describe("The key of a criterion you reword or retype (e.g. '2u'), so it keeps its verdicts and verify commands. Omit for a new one."),carries:r.z.string().regex(/^promise:req\d+:\S+$/,"carries is a promise id: promise:<request>:<criterion id>, as the promise card and your rework task name it").optional().describe("Only to change the check of another request's promise (its id, \"promise:req000012:crt_x\", from your rework task or the promise card): state the promise's words; its command is the new check, used once this request merges. The only way to change a promise's check.")})])).optional().describe("Replaces the whole list; same item shape and rules as create_request's acceptanceCriteria.")})).optional(),areas:r.z.array(r.z.string()).max(3).optional().describe("update-areas: up to 3 labels replacing the current ones, lowercase kebab paths (e.g. 'graphics/opengl'); [] clears. New names are registered automatically."),complete:r.z.preprocess(e=>"string"==typeof e?(()=>{try{return JSON.parse(e)}catch{return e}})():e,r.z.object({summary:r.z.string().describe("The line the user reads when the request lands: if the request asked a question, the first sentence answers it; then what changed. Never say tested or verified when that step failed. It replaces any earlier summary, so after a rework it covers the whole request."),replacesSummary:r.z.boolean().optional().describe("Required on a re-completion: confirms the summary covers everything the request delivers, fixes included. Without it the re-completion is refused and shows the earlier summary."),worthKnowing:r.z.array(r.z.string().min(10)).max(5).optional().describe("What the user would regret not knowing, one per entry: a discovery, a caveat, a side effect, a follow-up worth doing; always one when what was asked was already true or turned out different than the request implied. Not the summary again. Each lands alone in the stream: name the subject first. Omit when there is nothing."),guidance:r.z.array(r.z.object({body:r.z.string().min(10).max(800).describe('One fact or rule for the next agent, not addressed to the user, e.g. "calc.py is generated from ops.json: edit ops.json and regenerate."'),files:r.z.array(r.z.string().min(1)).min(1).max(8).describe("Repo-relative files or folders (globs work) it is pinned to."),evidence:r.z.string().min(1).max(1500).describe("What shows it: the command, what it printed, the file.")})).max(2).optional().describe("A trap the next agent touching these files would hit too, proposed as guidance pinned to them for the user to adopt. Not taste, not specific to this request, not already in guidance. Usually none."),skipTestsReason:exports.skipTestsReasonSchema,skipTests:exports.skipTestsSchema,criteriaComments:r.z.array(r.z.object({key:r.z.string().min(1),comment:r.z.string().min(1),verify:r.z.array(r.z.string().min(1)).max(4).optional().describe('Commands that prove this criterion in the sealed acceptance box (a grep, a targeted test, a screenshot into .visual-check/); the acceptance judge rules on their output. They run in a clean checkout of your commit with dependencies installed but nothing built, so a check that needs a build runs it in the same command ("npm run build && grep -q X dist/app.js"). No git, no network, no branching on whether a tool exists. A proof you already saw pass on this commit is reused if written exactly as you ran it.')})).optional().describe('One entry per acceptance criterion, keyed as your pickup lists it (e.g. "1a"): what you did and how you saw it hold. A request with criteria completes with an entry for each.'),afterRun:r.z.boolean().optional().describe("Complete while your final check runs: call `run` with the check first, then this complete in the SAME response. The completion waits for that run and is made only if it passed; otherwise you get the failure."),couldNotCheck:r.z.array(r.z.string().min(1)).max(20).optional().describe('Drive requests only: keys of claims you could not check (e.g. ["3c"]), reason in each criteriaComments entry. They read as unchecked; the only way to complete a drive without stamping a claim. Stamp what you checked with record_criteria_verification.')})).optional(),merge:r.z.preprocess(e=>"string"==typeof e?(()=>{try{return JSON.parse(e)}catch{return e}})():e,r.z.object({verifications:r.z.array(r.z.object({key:r.z.string().min(2).max(4),evidence:r.z.string().min(1)})).min(1)})).optional(),revert:r.z.object({reason:r.z.string(),confirmDestructive:r.z.boolean().optional()}).optional(),list:r.z.object({filters:r.z.object({type:exports.RequestTypeEnum.optional(),status:exports.RequestStatusFilterEnum.optional(),planDocumentId:r.z.string().optional().describe("Requests linked to this plan."),scheduleDocumentId:r.z.string().optional().describe("Requests a schedule fired: that schedule document."),questDocumentId:r.z.string().optional(),dateFrom:r.z.string().optional(),dateTo:r.z.string().optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).optional()}).optional(),search:r.z.object({query:r.z.string().min(1),searchIn:r.z.enum(["title","description","criteria","all"]).default("all"),filters:r.z.object({type:exports.RequestTypeEnum.optional(),status:exports.RequestStatusFilterEnum.optional(),planDocumentId:r.z.string().optional().describe("Requests linked to this plan."),scheduleDocumentId:r.z.string().optional().describe("Requests a schedule fired: that schedule document."),questDocumentId:r.z.string().optional(),dateFrom:r.z.string().optional(),dateTo:r.z.string().optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0)}).optional()}).optional()}).superRefine((e,t)=>{e.requestId
5223
+ const p=l
5224
+ exports.PlanReadSchema=r.z.object({operation:r.z.enum(["get","get-active","list","get-history","get-requests"]),planId:p.optional(),searchQuery:r.z.string().optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["createdAt","updatedAt","filename"]).default("updatedAt"),sortDirection:r.z.enum(["ASC","DESC"]).default("DESC")}).superRefine((e,t)=>{["get","get-history","get-requests"].includes(e.operation)&&!e.planId&&t.addIssue({code:"custom",message:`planId is required for '${e.operation}'. Example: { "operation": "${e.operation}", "planId": "plan000001" }`})}),exports.PlanWriteSchema=r.z.object({operation:r.z.enum(["create","update","append","replace","create-snapshot","restore"]),planId:p.optional(),kind:r.z.enum(["plan"]).default("plan").describe("Document kind to create. Plans only."),content:r.z.string().optional(),name:r.z.string().optional().describe("Plan name (used in filename for create; optional new name for update)."),old:r.z.string().optional().describe("Text to find in the plan (for replace)"),new:r.z.string().optional().describe("Replacement text (for replace)"),versionLabel:r.z.string().optional(),changeSummary:r.z.string().optional(),versionNumber:r.z.number().int().min(1).optional()}).superRefine((e,t)=>{const r=e.operation
5225
+ "create"===r?(e.name||t.addIssue({code:"custom",message:"name is required for 'create'. Letters, numbers, hyphens, underscores only."}),void 0===e.content&&t.addIssue({code:"custom",message:"content is required for 'create' (use empty string for an empty body)."})):e.planId||t.addIssue({code:"custom",message:`planId is required for '${r}'.`}),"append"!==r||e.content||t.addIssue({code:"custom",message:'content is required for \'append\'. Example: { "operation": "append", "planId": "plan000001", "content": "..." }'}),"update"===r&&(void 0!==e.content||e.name||t.addIssue({code:"custom",message:"update requires 'content' and/or 'name'."})),"replace"===r&&(e.old||t.addIssue({code:"custom",message:'old is required for replace. Example: { "operation": "replace", "planId": "plan000001", "old": "find this", "new": "replace with" }'}),void 0===e.new&&t.addIssue({code:"custom",message:"new is required for replace"})),"restore"!==r||e.versionNumber||t.addIssue({code:"custom",message:'versionNumber is required for restore. Example: { "operation": "restore", "planId": "plan000001", "versionNumber": 1 }'})}),exports.RevertRequestSchema=r.z.object({requestId:c,reason:r.z.string(),confirmDestructive:r.z.boolean().optional()}),exports.ModifyFileSchema=r.z.object({operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:l.optional(),operationType:r.z.enum(["replace-string","insert-lines","replace-lines","delete-string","delete-lines"]),replaceString:r.z.object({replacements:r.z.array(r.z.object({old_str:r.z.string(),new_str:r.z.string()})),mode:r.z.enum(["unique","all"]).optional()}).optional(),insertLines:r.z.object({insertions:r.z.array(r.z.object({type:r.z.enum(["before","after","between"]),line:r.z.number().optional(),afterLine:r.z.number().optional(),beforeLine:r.z.number().optional(),content:r.z.union([r.z.string(),r.z.array(r.z.string())])}).refine(e=>"between"===e.type?void 0!==e.afterLine&&void 0!==e.beforeLine&&void 0===e.line:void 0!==e.line&&void 0===e.afterLine&&void 0===e.beforeLine,{message:"Invalid line parameters"}))}).optional(),replaceLines:r.z.object({replacements:r.z.array(r.z.object({lines:r.z.string(),content:r.z.union([r.z.string(),r.z.array(r.z.string())])}))}).optional(),deleteString:r.z.object({patterns:r.z.array(r.z.string()),mode:r.z.enum(["all","unique"]).optional()}).optional(),deleteLines:r.z.object({lines:r.z.string()}).optional()}).transform(d).refine(u,{message:"path or documentId required"}).refine(e=>"replace-string"===e.operationType?e.replaceString&&!e.insertLines&&!e.replaceLines&&!e.deleteString&&!e.deleteLines:"insert-lines"===e.operationType?e.insertLines&&!e.replaceString&&!e.replaceLines&&!e.deleteString&&!e.deleteLines:"replace-lines"===e.operationType?e.replaceLines&&!e.replaceString&&!e.insertLines&&!e.deleteString&&!e.deleteLines:"delete-string"===e.operationType?e.deleteString&&!e.replaceString&&!e.insertLines&&!e.replaceLines&&!e.deleteLines:"delete-lines"===e.operationType&&e.deleteLines&&!e.replaceString&&!e.insertLines&&!e.replaceLines&&!e.deleteString,{message:"Invalid operation data"})),comment:r.z.string()}),exports.ManageFilesSchema=r.z.object({operations:r.z.array(r.z.object({operationType:r.z.enum(["create-directory","move-files","delete-files","get-file-info"]),createDirectory:r.z.object({path:r.z.string()}).optional(),moveFiles:r.z.object({moves:r.z.array(r.z.object({source:r.z.string(),destination:r.z.string()}))}).optional(),deleteFiles:r.z.object({targets:r.z.array(r.z.object({path:r.z.string().optional(),documentId:l.optional()}).transform(d).refine(u,{message:"path or documentId required"}))}).optional(),getFileInfo:r.z.object({path:r.z.string()}).optional()}).refine(e=>"create-directory"===e.operationType?e.createDirectory&&!e.moveFiles&&!e.deleteFiles&&!e.getFileInfo:"move-files"===e.operationType?e.moveFiles&&!e.createDirectory&&!e.deleteFiles&&!e.getFileInfo:"delete-files"===e.operationType?e.deleteFiles&&!e.createDirectory&&!e.moveFiles&&!e.getFileInfo:"get-file-info"===e.operationType&&e.getFileInfo&&!e.createDirectory&&!e.moveFiles&&!e.deleteFiles,{message:"Invalid operation data"})),comment:r.z.string()}),exports.RequestOperationsSchema=r.z.object({requestId:c.optional(),operation:r.z.enum(["update","activate","complete","merge","revert","reopen","get-info","list","search","status","cancel","delete-empty","list-areas","update-areas","wait-on","clear-wait","premise-block","dispute-criterion","asked-no-change","hand-over"]),planId:r.z.string().max(64).optional().describe("status: the plan to report on (plan000005). Omit it and requestId for all live work."),criterion:r.z.string().optional().describe("dispute-criterion: the key (e.g. 1a) of a criterion marked FROM THE PROCESS (or FROM THE WORKFLOW) that does not fit. You cannot drop, reword or waive it: the user waives it for this request or keeps it, and you are told; until then it binds. Put why in reason, plainly: the user reads it."),reason:r.z.string().optional().describe('cancel: why, to the user ("you"), in their language; name the replacing request if any. Also for revert, reopen and wait-on. premise-block (required): what the request builds on that does not exist in the project (a feature, file or surface); the user reads it. Not for what the request itself adds, nor for unclear wording: ask a question.'),userSaid:r.z.string().min(8).max(600).optional().describe("The user's words asking for this, quoted exactly and checked. Required for activate, for cancel when the work is finished and waiting on the user, and for reopen when a question to the user is pending on the request. asked-no-change: their message."),waitsOn:r.z.string().optional(),update:r.z.preprocess(e=>"string"==typeof e?(()=>{try{return JSON.parse(e)}catch{return e}})():e,r.z.object({userSaid:r.z.string().min(8).max(600).optional().describe('The user\'s words asking for this change to the request, quoted exactly (e.g. "skip the HTML counter"). Without them a worker may not narrow or reword its own request.'),removesCriteria:r.z.boolean().optional().describe("acceptanceCriteria replaces the whole list: send every criterion you keep. Set true only to delete those missing; otherwise a list that drops criteria is refused."),arcName:r.z.string().min(2).max(120).optional().describe('The thread\'s name (the requests grown from one ask, read as one story): two to five plain words for the whole thread ("Weekly menu app"). Set it once; a name the user chose is never overwritten.'),title:r.z.string().optional(),description:r.z.string().optional(),process:r.z.string().nullable().optional().describe("A workflow process by name (sets the kind and its rules' criteria), or null to take it off. Only on a draft; after that only the user may change it."),type:exports.SettableRequestTypeEnum.optional(),acceptanceCriteria:r.z.array(r.z.union([r.z.string(),r.z.object({description:r.z.string().min(1),beforeMerge:r.z.boolean().optional(),command:r.z.string().min(1).max(500).optional(),kind:r.z.enum(["objective","subjective","gate"]),baseline:exports.BaselineSchema.optional(),key:r.z.string().optional().describe("The key of a criterion you reword or retype (e.g. '2u'), so it keeps its verdicts and verify commands. Omit for a new one."),carries:r.z.string().regex(/^promise:req\d+:\S+$/,"carries is a promise id: promise:<request>:<criterion id>, as the promise card and your rework task name it").optional().describe("Only to change the check of another request's promise (its id, \"promise:req000012:crt_x\", from your rework task or the promise card): state the promise's words; its command is the new check, used once this request merges. The only way to change a promise's check.")})])).optional().describe("Replaces the whole list; same item shape and rules as create_request's acceptanceCriteria.")})).optional(),areas:r.z.array(r.z.string()).max(3).optional().describe("update-areas: up to 3 labels replacing the current ones, lowercase kebab paths (e.g. 'graphics/opengl'); [] clears. New names are registered automatically."),complete:r.z.preprocess(e=>"string"==typeof e?(()=>{try{return JSON.parse(e)}catch{return e}})():e,r.z.object({summary:r.z.string().describe("The line the user reads when the request lands: if the request asked a question, the first sentence answers it; then what changed. Never say tested or verified when that step failed. It replaces any earlier summary, so after a rework it covers the whole request."),replacesSummary:r.z.boolean().optional().describe("Required on a re-completion: confirms the summary covers everything the request delivers, fixes included. Without it the re-completion is refused and shows the earlier summary."),notChecked:r.z.preprocess(s,r.z.string().min(3).max(160).optional()).describe('What you did not check that the user could assume you did, in a few plain words ("the page on a phone", "a real email arriving"). The card leads with it, beside what the record shows nothing checked. Omit when there is nothing.'),worthKnowing:r.z.array(r.z.string().min(10)).max(5).optional().describe("What the user would regret not knowing, one per entry: a discovery, a caveat, a side effect, a follow-up worth doing; always one when what was asked was already true or turned out different than the request implied. Not the summary again. Each lands alone in the stream: name the subject first. Omit when there is nothing."),guidance:r.z.array(r.z.object({body:r.z.string().min(10).max(800).describe('One fact or rule for the next agent, not addressed to the user, e.g. "calc.py is generated from ops.json: edit ops.json and regenerate."'),files:r.z.array(r.z.string().min(1)).min(1).max(8).optional().describe("Repo-relative files or folders (globs work) it is pinned to. Without them (only with userSaid) it is for the whole project."),evidence:r.z.string().min(1).max(1500).optional().describe("What shows it: the command, what it printed, the file. Not needed with userSaid."),userSaid:r.z.string().min(8).max(600).optional().describe("A correction the user gave you on this request that should hold for later work: their words, copied exactly; the card quotes them.")}).refine(e=>!!e.userSaid||!!e.files?.length&&!!e.evidence,{message:"a trap needs files and evidence; a correction of the user's needs userSaid"})).max(2).optional().describe("A trap the next agent touching these files would hit too, or a correction the user gave you, proposed as guidance for the user to adopt. Not taste, not specific to this request, not already in guidance. Usually none."),skipTestsReason:exports.skipTestsReasonSchema,skipTests:exports.skipTestsSchema,criteriaComments:r.z.array(r.z.object({key:r.z.string().min(1),comment:r.z.string().min(1),verify:r.z.array(r.z.string().min(1)).max(4).optional().describe('Commands that prove this criterion in the sealed acceptance box (a grep, a targeted test, a screenshot into .visual-check/); the acceptance judge rules on their output. They run in a clean checkout of your commit with dependencies installed but nothing built, so a check that needs a build runs it in the same command ("npm run build && grep -q X dist/app.js"). No git, no network, no branching on whether a tool exists. A proof you already saw pass on this commit is reused if written exactly as you ran it.')})).optional().describe('One entry per acceptance criterion, keyed as your pickup lists it (e.g. "1a"): what you did and how you saw it hold. A request with criteria completes with an entry for each.'),afterRun:r.z.boolean().optional().describe("Complete while your final check runs: call `run` with the check first, then this complete in the SAME response. The completion waits for that run and is made only if it passed; otherwise you get the failure."),couldNotCheck:r.z.array(r.z.string().min(1)).max(20).optional().describe('Drive requests only: keys of claims you could not check (e.g. ["3c"]), reason in each criteriaComments entry. They read as unchecked; the only way to complete a drive without stamping a claim. Stamp what you checked with record_criteria_verification.')})).optional(),merge:r.z.preprocess(e=>"string"==typeof e?(()=>{try{return JSON.parse(e)}catch{return e}})():e,r.z.object({verifications:r.z.array(r.z.object({key:r.z.string().min(2).max(4),evidence:r.z.string().min(1)})).min(1)})).optional(),revert:r.z.object({reason:r.z.string(),confirmDestructive:r.z.boolean().optional()}).optional(),list:r.z.object({filters:r.z.object({type:exports.RequestTypeEnum.optional(),status:exports.RequestStatusFilterEnum.optional(),planDocumentId:r.z.string().optional().describe("Requests linked to this plan."),scheduleDocumentId:r.z.string().optional().describe("Requests a schedule fired: that schedule document."),questDocumentId:r.z.string().optional(),dateFrom:r.z.string().optional(),dateTo:r.z.string().optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0),sortBy:r.z.enum(["created","updated"]).default("updated"),sortDirection:r.z.enum(["asc","desc"]).default("desc")}).optional()}).optional(),search:r.z.object({query:r.z.string().min(1),searchIn:r.z.enum(["title","description","criteria","all"]).default("all"),filters:r.z.object({type:exports.RequestTypeEnum.optional(),status:exports.RequestStatusFilterEnum.optional(),planDocumentId:r.z.string().optional().describe("Requests linked to this plan."),scheduleDocumentId:r.z.string().optional().describe("Requests a schedule fired: that schedule document."),questDocumentId:r.z.string().optional(),dateFrom:r.z.string().optional(),dateTo:r.z.string().optional(),limit:r.z.number().min(1).max(100).default(20),offset:r.z.number().min(0).default(0)}).optional()}).optional()}).superRefine((e,t)=>{e.requestId
5207
5226
  const r=e.operation,n={complete:{field:"complete",hint:'Provide: { complete: { summary: "..." } }'},merge:{field:"merge",hint:'Provide: { merge: { verifications: [{key: "1a", evidence: "..."}] } }'},revert:{field:"revert",hint:'Provide: { revert: { reason: "..." } }'},search:{field:"search",hint:'Provide: { search: { query: "..." } }'}}[r]
5208
5227
  n&&!e[n.field]&&t.addIssue({code:"custom",message:`'${r}' operation requires '${n.field}' data. ${n.hint}`})})
5209
- const p=r.z.string({required_error:"Required. A quick edit either touches up an earlier request's result or stands on its own: pass that request id (req######) or the word 'new'."}).refine(e=>"new"===e||/^req\d{6}$/.test(e),{message:"Pass a request id like req000031, or 'new'."}).describe("The request whose result this edit adjusts, when it is one: the user pointed at it (anchored the message to it, named it, or said 'that change', 'also', 'one more thing on that' right after it landed) and the edit changes what that request built. It joins that request's thread. Pass 'new' for an edit that stands on its own, even when it touches a file an earlier request changed. The same rule as create_request's follows.")
5210
- exports.QuickWriteSchema=r.z.object({title:r.z.string().min(1,"Title is required"),description:r.z.string().min(1,"Description is required"),follows:p,path:r.z.string().optional(),documentId:c.optional(),content:r.z.union([r.z.string(),r.z.array(r.z.string())]),format:r.z.enum(["text","json"]).optional(),append:r.z.boolean().optional()}).transform(l).refine(d,{message:"path or documentId required"}),exports.QuickReplaceSchema=r.z.object({title:r.z.string().min(1,"Title is required"),description:r.z.string().min(1,"Description is required"),follows:p,operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:c.optional(),replacements:r.z.array(r.z.object({old:r.z.string().min(1),new:r.z.string(),match_mode:r.z.enum(["unique","all"]).optional()})).min(1),fuzzy_match:r.z.boolean().optional()}).transform(l).refine(d,{message:"path or documentId required"})).min(1),fuzzy_match:r.z.boolean().optional(),comment:r.z.string().min(1,"Comment describing the change is required")}),exports.MetaWorkflowListSchema=r.z.object({}),exports.MetaWorkflowGetSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to retrieve")}),exports.MetaWorkflowCreateSchema=r.z.object({name:r.z.string().min(1).describe("Unique name for the workflow"),shortName:r.z.string().min(1).max(10).describe("Short display name (required, max 10 chars)"),description:r.z.string().optional().describe("Description of what the workflow does"),testGate:r.z.enum(["off","auto","ask","strict"]).optional().describe("Test gate: off (no test gate; completions merge without running tests), auto (tests run automatically; the agent may opt out with a reason), ask (the user picks auto/interactive/skip at each completion), strict (tests always run; agent opt-outs are rejected and any failed command blocks)"),reviewGate:r.z.enum(["off","criteria","full"]).optional().describe('Review gate, as the workflow page names it: off; criteria ("Criteria only": one reviewer checks each acceptance criterion and nothing else); full ("Full review": adds reviewers that read the work for quality, reuse and efficiency)'),signoffGate:r.z.enum(["off","agent","you"]).optional().describe('Sign-off gate, as the workflow page names it: off; agent ("Delivery review": an agent asks whether the delivery is what was asked for, then merges or brings it to the user); you ("You sign off": the user approves before merge)'),approvalMode:r.z.enum(["none","require-approval","agent-check"]).optional().describe("Pre-work approval: none (default), require-approval (the user approves each request), or agent-check (an independent intake reviewer rules on agent-created requests before work starts)"),interactionPosture:r.z.enum(["autonomous","balanced","collaborative"]).optional().describe("Interaction posture (question-gate dial): autonomous (defaulted questions are self-answered -- proceed + FYI report), balanced (default; questions post normally, non-blocking when defaulted), collaborative (always ask the human)")}),exports.MetaWorkflowUpdateSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to update"),name:r.z.string().min(1).optional().describe("New name"),shortName:r.z.string().max(10).optional().describe("New short name (max 10 chars)"),description:r.z.string().optional().describe("New description"),testGate:r.z.enum(["off","auto","ask","strict"]).optional().describe("Test gate: off (no test gate), auto (tests run automatically; agent may opt out with a reason), ask (the user picks auto/interactive/skip at each completion), strict (tests always run; agent opt-outs rejected, any failed command blocks)"),reviewGate:r.z.enum(["off","criteria","full"]).optional().describe('Review gate, as the workflow page names it: off; criteria ("Criteria only": one reviewer checks each acceptance criterion and nothing else); full ("Full review": adds reviewers that read the work for quality, reuse and efficiency)'),signoffGate:r.z.enum(["off","agent","you"]).optional().describe('Sign-off gate, as the workflow page names it: off; agent ("Delivery review": an agent asks whether the delivery is what was asked for, then merges or brings it to the user); you ("You sign off": the user approves before merge)'),approvalMode:r.z.enum(["none","require-approval","agent-check"]).optional().describe("Pre-work approval: none (default), require-approval (the user approves each request), or agent-check (an independent intake reviewer rules on agent-created requests before work starts)"),interactionPosture:r.z.enum(["autonomous","balanced","collaborative"]).optional().describe("Interaction posture (question-gate dial): autonomous (defaulted questions are self-answered -- proceed + FYI report), balanced (default; questions post normally, non-blocking when defaulted), collaborative (always ask the human)")}),exports.MetaRecipeListSchema=r.z.object({}),exports.MetaRecipeGetSchema=r.z.object({recipeId:r.z.string().describe("Recipe ID to retrieve")}),exports.MetaRecipeCreateSchema=r.z.object({name:r.z.string().min(1).describe("Unique name for the recipe"),description:r.z.string().optional().describe("Description of what the recipe does"),documentation:r.z.string().optional().describe("Detailed documentation")}),exports.MetaRecipeAddHookSchema=r.z.object({recipeId:r.z.string().describe("Recipe ID to add the hook to"),hookId:r.z.string().describe("Hook template ID to add"),position:r.z.number().int().min(0).optional().describe("Position in the recipe (0-based, appended if omitted)")}),exports.MetaRecipeRemoveHookSchema=r.z.object({recipeId:r.z.string().describe("Recipe ID to remove the hook from"),hookId:r.z.string().describe("Hook template ID to remove")}),exports.MetaHookListSchema=r.z.object({}),exports.MetaHookCreateSchema=r.z.object({name:r.z.string().min(1).describe("Unique name for the hook"),description:r.z.string().optional().describe("Description of what the hook does"),eventType:r.z.string().describe("Event type that triggers this hook (e.g., session_idle, request_completed, custom:plan_ready)"),category:r.z.enum(["alchemy","session","message","editing","reading","file_management","documents","history","tool"]).default("session").describe("Hook category"),agent:r.z.string().describe("Agent template to execute when hook fires"),promptTemplate:r.z.string().describe("Prompt template with {{variable}} substitution"),condition:r.z.record(r.z.any()).optional().describe("Condition object for filtering when hook fires"),timing:r.z.enum(["before","after"]).default("after").describe("When to fire relative to the event"),action:r.z.enum(["spawn_agent","inject_prompt"]).optional().describe("What the hook does: spawn_agent (default) starts a new session of `agent` with the prompt; inject_prompt sends the prompt into an existing session"),target:r.z.enum(["independent_session","child_session","same_session","parent_session","ancestor_chain"]).optional().describe("Where the prompt goes. With spawn_agent: independent_session (default, no parent) or child_session (under the session that fired the event). With inject_prompt: same_session (default, the session that fired the event), parent_session, or ancestor_chain"),maxIterations:r.z.number().int().min(1).optional().describe("Maximum times the hook fires for one session, counted from its firing record. Set it on every session_idle hook that sends into the same session. A session a hook started never triggers that hook again, whatever this says"),emitEvent:r.z.string().optional().describe("Custom event to emit on completion"),emitEventOnCondition:r.z.union([r.z.object({condition:r.z.object({field:r.z.string(),operator:r.z.enum(["contains","not_contains","equals","not_equals","matches","not_matches"]),value:r.z.string()}),event:r.z.string()}),r.z.array(r.z.object({condition:r.z.object({field:r.z.string(),operator:r.z.enum(["contains","not_contains","equals","not_equals","matches","not_matches"]),value:r.z.string()}),event:r.z.string()}))]).optional().describe("Conditional event emission based on output")}),exports.MetaWorkflowAddRecipeSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to add the recipe to"),recipeId:r.z.string().describe("Recipe ID to add"),position:r.z.number().int().min(0).optional().describe("Position in the workflow (0-based, appended if omitted)")}),exports.MetaWorkflowRemoveRecipeSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to remove the recipe from"),recipeId:r.z.string().describe("Recipe ID to remove")}),exports.MetaAgentListSchema=r.z.object({}),exports.MetaOperationsSchema=r.z.object({operation:r.z.enum(["workflow-list","workflow-get","workflow-create","workflow-update","recipe-list","recipe-get","recipe-create","recipe-add-hook","recipe-remove-hook","hook-list","hook-create","workflow-add-recipe","workflow-remove-recipe","agent-list"]).describe("Which meta operation to perform; the other params apply per operation (see tool description)"),...exports.MetaWorkflowGetSchema.partial().shape,...exports.MetaWorkflowCreateSchema.partial().shape,...exports.MetaWorkflowUpdateSchema.partial().shape,...exports.MetaRecipeGetSchema.partial().shape,...exports.MetaRecipeCreateSchema.partial().shape,...exports.MetaRecipeAddHookSchema.partial().shape,...exports.MetaRecipeRemoveHookSchema.partial().shape,...exports.MetaHookCreateSchema.partial().shape,...exports.MetaWorkflowAddRecipeSchema.partial().shape,...exports.MetaWorkflowRemoveRecipeSchema.partial().shape}),exports.TestingProcessListSchema=r.z.object({}),exports.TestingProcessGetSchema=r.z.object({processId:r.z.string().describe("Test process ID to retrieve")})
5211
- const f=r.z.object({name:r.z.string().min(1).describe('Command name (e.g., "Build", "Unit Tests")'),command:r.z.string().min(1).describe('Shell command to run (e.g., "npm test")'),required:r.z.boolean().default(!0).describe("If true, failure blocks the request (default: true)"),timeout:r.z.number().int().min(10).max(3600).default(300).describe("Max execution time in seconds (default: 300)")})
5212
- exports.TestingProcessCreateSchema=r.z.object({name:r.z.string().min(1).describe("Name for the test process"),environmentId:r.z.string().optional().describe("ID of the environment (confined runtime) this process runs in. Get it from environment_list or environment_setup."),description:r.z.string().optional().describe("Description of what this process verifies"),scope:r.z.string().optional().describe('LABEL ONLY -- a monorepo path prefix recorded for display (e.g. "packages/api/"). It does NOT affect when the process runs; use pathGlobs for that.'),pathGlobs:r.z.array(r.z.string()).optional().describe('Which changes this process runs on: glob patterns matched against the changed files (e.g. ["sites/**"], ["src/**", "*.md"]). THIS is what limits when the process runs. Omit it and the process runs on EVERY change, which is the right choice only for a check that is cheap and universal.'),areas:r.z.array(r.z.string()).optional().describe('Work-area labels this process covers (e.g. ["graphics/opengl"]). An alternative to pathGlobs for work that is not file-shaped; a process applies if EITHER dimension matches.'),setup:r.z.array(r.z.string()).optional().describe('Commands to prepare the environment (e.g., ["ln -s ../../node_modules node_modules"])'),commands:r.z.array(f).min(1).describe("Test commands to execute in order"),verifyAcceptanceCriteria:r.z.boolean().optional().describe("When true, auto-tester verifies request acceptance criteria after running commands"),fingerprint:r.z.array(r.z.string()).optional().describe('Files whose content invalidates setup. Setup commands re-run only when these files change between runs (e.g. ["package-lock.json"], ["Cargo.lock"], ["uv.lock", "poetry.lock"]). Polyglot repos list multiple. Omit / empty list = always re-run setup (existing behavior).'),poolSize:r.z.number().int().min(1).max(8).optional().describe("Number of warm test worktrees in the pool. Default 2. Set to 1 for languages with very large build artifacts (Rust target/, C++ build/). Higher values allow more parallel test runs at the cost of disk."),runtimeKept:r.z.string().optional().describe('Only when the user chose to run the check on a runtime other than the lowest one the project declares: that runtime and version, e.g. "python 3.12". Without it, a check whose environment runs another version than the declared minimum is not registered.')}),exports.TestingProcessDeleteSchema=r.z.object({processId:r.z.string().describe("Test process ID to delete")}),exports.EnvironmentListSchema=r.z.object({}),exports.ResultsSchema=r.z.object({operation:r.z.enum(["record","fetch","pin","list","read"]),path:r.z.string().optional().describe("record: the file, inside the project (not /tmp); your worktree first, then the main project. Bulk that must not reach a commit can be written by a command under `.alchemy_lab/scratch/` (gitignored)."),name:r.z.string().optional().describe("record: the name a person uses for it (defaults to the filename). list: show every version recorded under this name, newest first."),summary:r.z.record(r.z.any()).optional().describe('record (required): the small facts a reader wants instead of the bytes, e.g. {maxStress: 412, unit: "MPa", converged: true}.'),box:r.z.string().optional().describe("An experiment handle (exp_...). fetch: put the bytes inside that sealed box under its /scratch (a box cannot see the host scratch; omit for host work, which is faster). record: the result lives inside that box and is streamed out and stored in one step (a box cannot write your worktree)."),mediaType:r.z.string().optional().describe("record: MIME type, when you know it."),inputs:r.z.array(r.z.string()).optional().describe("record: addresses of the results this one was made from (provenance)."),note:r.z.string().optional().describe("record: one line on how it was produced."),address:r.z.string().optional().describe("pin / read / fetch: the full 64-character address the record returned (a unique prefix works too)."),at:r.z.string().optional().describe("pin: the pointer path in your worktree (.result.json is added). fetch: where the bytes land, under `.alchemy_lab/scratch/` on the host or the box's `/scratch`. Defaults to results/<name>."),comment:r.z.string().optional().describe("pin: the commit comment for the pointer file."),offset:r.z.number().optional().describe("read: line to start at (default 0)."),limit:r.z.number().optional().describe("read: how many lines (default 200). list: how many results (default 25)."),find:r.z.string().optional().describe("read: return only lines containing this text, instead of a range.")}),exports.ResultInspectSchema=r.z.object({operation:r.z.enum(["list","read"]),name:r.z.string().optional().describe("list: show every version recorded under this name, newest first."),address:r.z.string().optional().describe("read: the full 64-character address of the result."),offset:r.z.number().optional().describe("read: line to start at (default 0)."),limit:r.z.number().optional().describe("read: how many lines (default 200). list: how many results (default 25)."),find:r.z.string().optional().describe("read: return only lines containing this text, instead of a range.")}),exports.ExperimentStartSchema=r.z.object({env:r.z.string().optional().describe("Environment by name (from environment_list), one whose image has the toolchain you need."),environmentId:r.z.string().optional().describe("Environment by id (alternative to `env`). The primary env is used if neither is given."),size:r.z.enum(["light","standard","heavy"]).optional().describe("light: 2 cores (lint, a typecheck, one test file). standard (default): a share of the free cores (a suite, a build). heavy: every free core but 2, only for work that uses them all (a CFD solve, meshing, a large parallel build). A size you do not hold opens another box."),confirmWorkspace:r.z.boolean().optional().describe('Required for env "workspace" (the live host): the task genuinely needs the real machine. Building or trying out the app does not.')}),exports.ExperimentStopSchema=r.z.object({handle:r.z.string().describe("The experiment handle to tear down.")}),exports.ExperimentListSchema=r.z.object({}),exports.ReadSiteSchema=r.z.object({url:r.z.string()}),exports.DriveSiteSchema=r.z.object({url:r.z.string().describe("The running product, e.g. the environment's published URL or http://localhost:5173."),steps:r.z.array(r.z.object({action:r.z.enum(["click","clickat","type","press","move","scroll","wait","media"]).describe('click (selector) \xb7 clickat (x,y) \xb7 type (selector + text) \xb7 press (key) \xb7 move (x,y) \xb7 scroll (dy) \xb7 wait (ms, max 5000) \xb7 media ("print" shows the printout, "screen" switches back)'),selector:r.z.string().optional().describe('Playwright selector, e.g. "text=Build" or "#start".'),text:r.z.string().optional(),key:r.z.string().optional().describe('e.g. "Enter"'),x:r.z.number().optional(),y:r.z.number().optional(),dy:r.z.number().optional(),ms:r.z.number().optional(),media:r.z.enum(["print","screen"]).optional()})).min(1).max(20),shots:r.z.enum(["each","final"]).optional().describe('"each" screenshots every step; default the final state only.'),session:r.z.string().optional().describe("Keeps the page open: the next call with this name continues where this one stopped. Idle sessions close after 10 minutes."),close:r.z.boolean().optional().describe("Close the named session after this call."),width:r.z.number().optional().describe("Viewport width for a new session (default 1280; 390 is a phone).")}),exports.CaptureSiteSchema=r.z.object({url:r.z.string(),fullPage:r.z.boolean().optional().describe("The whole scrollable page instead of the viewport."),width:r.z.number().optional().describe("Viewport width (default 1280; 390 is a phone).")}),exports.PreviewSiteSchema=r.z.object({dir:r.z.string().describe('Repo-relative, e.g. "dist" or "." for the top of the repository.'),requestId:r.z.string().regex(/^req\d{6}$/).optional().describe("Serve from this unmerged request's working copy instead of main."),name:r.z.string().optional().describe("Preview handle (default: a slug of dir); reusing one replaces that preview."),label:r.z.string().optional()}),exports.FetchAssetSchema=r.z.object({url:r.z.string().describe("The http(s) URL of the image or font to download."),destPath:r.z.string().describe('Where to write it, repo-relative (e.g. "sites/acme/assets/hero.jpg"). Must stay inside the working tree; parent directories are created.')}),exports.RequestVisualFeedbackSchema=r.z.object({box:r.z.string().optional().describe("The experiment handle (from experiment_start, on a screenshot-capable env) to render in / read from. The box must stay held until this returns."),route:r.z.string().optional().describe('With `box`: the route I render + screenshot FOR YOU (e.g. "/" or "/settings"). I serve `serveDir` and screenshot it -- you do NOT hand-roll serve/screenshot. This is the easiest path.'),script:r.z.string().optional().describe('With `box`, for FULL control: a Playwright snippet (the body of `async (page, baseUrl) => { ... }`). I serve the app, launch headless Chromium, and run your script -- navigate (page.goto(baseUrl + "/x")), click, fill, scroll, waitForSelector, etc. -- then screenshot the final page state. Reliable: you write only the interaction, no serve/launch/flags. Use this to reach a state that needs interaction (open a menu, log in, submit a form).'),fullPage:r.z.boolean().optional().describe("Capture the entire scrollable page instead of just the viewport."),serveDir:r.z.string().optional().describe("With `box`+`route`: the static dir to serve (default /work). For a built app, build first via run(), then point this at the build output (e.g. /work/dist)."),path:r.z.string().optional().describe("Alternative to route: a screenshot you ALREADY wrote inside the box (e.g. /tmp/shot.png); I read it out."),assetFilename:r.z.string().optional().describe("Alternative to box: the filename of an already-uploaded screenshot asset to annotate."),prompt:r.z.string().optional().describe("What you want the human to look at or mark up (shown with the request)."),timeoutMs:r.z.number().optional().describe("How long to wait for the human, in ms (default ~10 min).")}),exports.AskUserVisualSchema=r.z.object({question:r.z.string().describe('The question for the USER about the marked region (e.g. "Should this button use the primary color?").'),imagePath:r.z.string().optional().describe("Repo-relative path to an image you already produced (png/jpg/gif/webp), e.g. a screenshot you wrote. Provide this OR previewName."),previewName:r.z.string().optional().describe("Name of a registered live preview (a `live:` ref); I freeze it into a snapshot image for you. Provide this OR imagePath."),box:r.z.string().optional().describe('The region the question is about: "x,y,w,h" in normalized 0..1 image coordinates, origin top-left (e.g. "0.62,0.08,0.3,0.12"). Omit to ask about the whole image.'),options:r.z.array(r.z.string()).optional().describe("Optional answer choices (labels). Omit for a free-text answer."),context:r.z.string().optional().describe("Extra context shown with the question in the inbox (why you are asking, what you will do with the answer)."),priority:r.z.enum(["low","normal","high"]).optional().describe('Question priority; "high" always reaches the user regardless of autonomy dial.')}),exports.EnvironmentGetSchema=r.z.object({environmentId:r.z.string().describe("Environment ID to retrieve")}),exports.EnvironmentProvisionSchema=r.z.object({environmentId:r.z.string(),why:r.z.string().optional().describe("Why provision now (shown on the approval).")}),exports.EnvironmentTeardownSchema=r.z.object({environmentId:r.z.string()}),exports.EnvironmentStatusSchema=r.z.object({environmentId:r.z.string()}),exports.EnvironmentVerifyStackSchema=r.z.object({environmentId:r.z.string()})
5213
- const m=r.z.object({image:r.z.string().optional().describe("Container image carrying the project toolchain/deps, e.g. node:20-alpine, python:3.12-slim, golang:1.22, ruby:3.3"),install:r.z.string().optional().describe("Deps install command -- Node-only sugar that populates a /work/node_modules cache volume, run with registry egress before the confined gate, e.g. npm ci. Non-Node runtimes use `artifacts` instead (a cache volume + prepare command: .venv/uv sync, cargo, go, vendor/bundle). Omit if the project has no deps."),composeFile:r.z.string().optional().describe("Path to the project docker-compose file for its services. Omit if no services."),shellInit:r.z.string().optional().describe("Shell preamble run before EVERY command in the box, e.g. '. /usr/lib/openfoam/openfoam2312/etc/bashrc'. REQUIRED for a toolchain that publishes itself through a script rather than the image PATH (OpenFOAM etc/bashrc, oneAPI setvars.sh, conda activate, ROS setup.bash): `docker exec` runs no ENTRYPOINT and reads no login profile, so without this every command gets a bare PATH. Put the preamble HERE, never inside the smoke command -- a smoke command carrying its own preamble proves the preamble and not the environment, and the next agent gets nothing."),connEnv:r.z.record(r.z.string()).optional().describe("Connection env injected into the gate (e.g. DATABASE_URL) using SERVICE NAMES + internal ports, never localhost/host ports."),seed:r.z.array(r.z.string()).optional().describe("Optional commands run after services are up (e.g. migrations)."),artifacts:r.z.array(r.z.object({path:r.z.string().describe("Mount target for the writable, populated volume: relative to /work (e.g. node_modules, .venv, vendor/bundle) or absolute (e.g. /cache/cargo)."),prepare:r.z.string().optional().describe("Command that populates it -- the one phase with registry egress (e.g. npm ci, uv sync, cargo fetch). Omit for a writable empty volume."),manifests:r.z.array(r.z.string()).optional().describe("Lockfiles (relative to /work) whose content hash keys the cache; list them so the volume is reused across runs and only rebuilt when deps change (e.g. uv.lock, Cargo.lock). Omit => rebuilt every run."),env:r.z.record(r.z.string()).optional().describe('Env applied during prepare AND every run, e.g. { CARGO_HOME: "/cache/cargo" } for caches outside /work.')})).optional().describe("Per-runtime build/dependency artifacts: writable volumes populated by a prepare command, generalizing `install` beyond node_modules. Use for Python (.venv), Rust (target + $CARGO_HOME), Go, Ruby (vendor/bundle), etc. `install` is sugar for a single node_modules artifact; for any non-Node runtime use artifacts (install would write to node_modules, the wrong place)."),confinement:r.z.enum(["confined","egress-allowlist","privileged","unsafe","host","pure-host"]).optional().describe("Confinement level. Default 'confined' (fully sealed Docker; add egressAllowlist hosts to open exactly those -- stored as 'egress-allowlist'). privileged/unsafe relax the container. 'host' runs on the host machine (no Docker) inside an OS sandbox (Seatbelt/bubblewrap) for toolchains Docker can't run. 'pure-host' is the built-in workspace env (the live worktree) -- do not create new envs with it. Merge gating is independent (the Sign-off setting)."),commandGate:r.z.array(r.z.enum(["policy","agent","human"])).optional().describe("Gates an experiment command passes before it runs, in escalation order policy -> agent -> human. Empty = run freely; escalating past the last gate blocks (fail closed). policy = deterministic allowlist/deny-floor; agent = isolated LLM judge (allow or escalate only); human = ask. Registered commands are pre-approved. Defaults by level ([] for confined/egress-allowlist, ['human'] for privileged/unsafe)."),worktreeTarget:r.z.enum(["ephemeral","live"]).optional().describe("Worktree the env runs against: 'ephemeral' (a disposable copy at HEAD, default) or 'live' (the project's live working dir, read-write). The built-in workspace env is 'live'."),egressAllowlist:r.z.array(r.z.string()).optional().describe("Hosts the box may reach at the 'egress-allowlist' level (exact name or subdomain, e.g. registry.npmjs.org). Ignored at other levels."),addCaps:r.z.array(r.z.string()).optional().describe("Linux capabilities to add at the 'privileged' level (on top of cap-drop ALL), e.g. SYS_PTRACE for debuggers, IPC_LOCK for memlock. Ignored at other levels."),sysctls:r.z.record(r.z.string()).optional().describe("Namespaced sysctls to set at the 'privileged' level, e.g. net.ipv4.ip_local_port_range. Host-wide sysctls (vm.max_map_count) are NOT settable per-container."),runAsRoot:r.z.boolean().optional().describe("Run the box as root (privileged / unsafe levels). Needed for some caps + the docker socket."),dockerSocket:r.z.boolean().optional().describe("Mount the host docker socket for testcontainers-style tests. WARNING: full host control over the docker daemon. Only honored at the 'unsafe' level."),persistentVolumes:r.z.array(r.z.object({name:r.z.string(),target:r.z.string(),service:r.z.string().optional()})).optional().describe("Data volumes that survive between runs (keyed to this environment; off by default since experiments are ephemeral). Set service to mount into a compose service (e.g. a DB data dir), or omit it to mount into the box (e.g. a SQLite dir)."),resources:r.z.object({memory:r.z.string().optional().describe("Memory cap, e.g. '4g' (default 2g)."),cpus:r.z.number().optional().describe("A fixed CPU count. Usually leave it unset and set size instead."),size:r.z.enum(["light","standard","heavy"]).optional().describe("What this environment's boxes and checks are for, which sets their cores from what is free: light (2 cores: lint, small checks), standard (the default: a share of the free cores, for test suites and builds), heavy (every free core but 2: CFD or FEM solves, meshing, large parallel builds). An agent can ask for another size per box."),pidsLimit:r.z.number().optional().describe("Max processes (default 512)."),scratchMb:r.z.number().optional().describe("Size in MB of an in-memory /scratch, used only when the image cannot take the disk-backed one (default 512). /scratch is normally on disk and needs no size."),shmMb:r.z.number().optional().describe("/dev/shm size in MB -- bump for headless browsers (Chrome crashes on the 64m default).")}).optional().describe("Per-environment resource caps that override the confined defaults.")}),g=function e(t){const n={...t._def,description:void 0}
5228
+ const f=r.z.string({required_error:"Required. A quick edit either touches up an earlier request's result or stands on its own: pass that request id (req######) or the word 'new'."}).refine(e=>"new"===e||/^req\d{6}$/.test(e),{message:"Pass a request id like req000031, or 'new'."}).describe("The request whose result this edit adjusts, when it is one: the user pointed at it (anchored the message to it, named it, or said 'that change', 'also', 'one more thing on that' right after it landed) and the edit changes what that request built. It joins that request's thread. Pass 'new' for an edit that stands on its own, even when it touches a file an earlier request changed. The same rule as create_request's follows.")
5229
+ exports.QuickWriteSchema=r.z.object({title:r.z.string().min(1,"Title is required"),description:r.z.string().min(1,"Description is required"),follows:f,path:r.z.string().optional(),documentId:l.optional(),content:r.z.union([r.z.string(),r.z.array(r.z.string())]),format:r.z.enum(["text","json"]).optional(),append:r.z.boolean().optional()}).transform(d).refine(u,{message:"path or documentId required"}),exports.QuickReplaceSchema=r.z.object({title:r.z.string().min(1,"Title is required"),description:r.z.string().min(1,"Description is required"),follows:f,operations:r.z.array(r.z.object({path:r.z.string().optional(),documentId:l.optional(),replacements:r.z.array(r.z.object({old:r.z.string().min(1),new:r.z.string(),match_mode:r.z.enum(["unique","all"]).optional()})).min(1),fuzzy_match:r.z.boolean().optional()}).transform(d).refine(u,{message:"path or documentId required"})).min(1),fuzzy_match:r.z.boolean().optional(),comment:r.z.string().min(1,"Comment describing the change is required")}),exports.MetaWorkflowListSchema=r.z.object({}),exports.MetaWorkflowGetSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to retrieve")}),exports.MetaWorkflowCreateSchema=r.z.object({name:r.z.string().min(1).describe("Unique name for the workflow"),shortName:r.z.string().min(1).max(10).describe("Short display name (required, max 10 chars)"),description:r.z.string().optional().describe("Description of what the workflow does"),testGate:r.z.enum(["off","auto","ask","strict"]).optional().describe("Test gate: off (no test gate; completions merge without running tests), auto (tests run automatically; the agent may opt out with a reason), ask (the user picks auto/interactive/skip at each completion), strict (tests always run; agent opt-outs are rejected and any failed command blocks)"),reviewGate:r.z.enum(["off","criteria","full"]).optional().describe('Review gate, as the workflow page names it: off; criteria ("Criteria only": one reviewer checks each acceptance criterion and nothing else); full ("Full review": adds reviewers that read the work for quality, reuse and efficiency)'),signoffGate:r.z.enum(["off","agent","you"]).optional().describe('Sign-off gate, as the workflow page names it: off; agent ("Delivery review": an agent asks whether the delivery is what was asked for, then merges or brings it to the user); you ("You sign off": the user approves before merge)'),approvalMode:r.z.enum(["none","require-approval","agent-check"]).optional().describe("Pre-work approval: none (default), require-approval (the user approves each request), or agent-check (an independent intake reviewer rules on agent-created requests before work starts)"),interactionPosture:r.z.enum(["autonomous","balanced","collaborative"]).optional().describe("Interaction posture (question-gate dial): autonomous (defaulted questions are self-answered -- proceed + FYI report), balanced (default; questions post normally, non-blocking when defaulted), collaborative (always ask the human)")}),exports.MetaWorkflowUpdateSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to update"),name:r.z.string().min(1).optional().describe("New name"),shortName:r.z.string().max(10).optional().describe("New short name (max 10 chars)"),description:r.z.string().optional().describe("New description"),testGate:r.z.enum(["off","auto","ask","strict"]).optional().describe("Test gate: off (no test gate), auto (tests run automatically; agent may opt out with a reason), ask (the user picks auto/interactive/skip at each completion), strict (tests always run; agent opt-outs rejected, any failed command blocks)"),reviewGate:r.z.enum(["off","criteria","full"]).optional().describe('Review gate, as the workflow page names it: off; criteria ("Criteria only": one reviewer checks each acceptance criterion and nothing else); full ("Full review": adds reviewers that read the work for quality, reuse and efficiency)'),signoffGate:r.z.enum(["off","agent","you"]).optional().describe('Sign-off gate, as the workflow page names it: off; agent ("Delivery review": an agent asks whether the delivery is what was asked for, then merges or brings it to the user); you ("You sign off": the user approves before merge)'),approvalMode:r.z.enum(["none","require-approval","agent-check"]).optional().describe("Pre-work approval: none (default), require-approval (the user approves each request), or agent-check (an independent intake reviewer rules on agent-created requests before work starts)"),interactionPosture:r.z.enum(["autonomous","balanced","collaborative"]).optional().describe("Interaction posture (question-gate dial): autonomous (defaulted questions are self-answered -- proceed + FYI report), balanced (default; questions post normally, non-blocking when defaulted), collaborative (always ask the human)")}),exports.MetaRecipeListSchema=r.z.object({}),exports.MetaRecipeGetSchema=r.z.object({recipeId:r.z.string().describe("Recipe ID to retrieve")}),exports.MetaRecipeCreateSchema=r.z.object({name:r.z.string().min(1).describe("Unique name for the recipe"),description:r.z.string().optional().describe("Description of what the recipe does"),documentation:r.z.string().optional().describe("Detailed documentation")}),exports.MetaRecipeAddHookSchema=r.z.object({recipeId:r.z.string().describe("Recipe ID to add the hook to"),hookId:r.z.string().describe("Hook template ID to add"),position:r.z.number().int().min(0).optional().describe("Position in the recipe (0-based, appended if omitted)")}),exports.MetaRecipeRemoveHookSchema=r.z.object({recipeId:r.z.string().describe("Recipe ID to remove the hook from"),hookId:r.z.string().describe("Hook template ID to remove")}),exports.MetaHookListSchema=r.z.object({}),exports.MetaHookCreateSchema=r.z.object({name:r.z.string().min(1).describe("Unique name for the hook"),description:r.z.string().optional().describe("Description of what the hook does"),eventType:r.z.string().describe("Event type that triggers this hook (e.g., session_idle, request_completed, custom:plan_ready)"),category:r.z.enum(["alchemy","session","message","editing","reading","file_management","documents","history","tool"]).default("session").describe("Hook category"),agent:r.z.string().describe("Agent template to execute when hook fires"),promptTemplate:r.z.string().describe("Prompt template with {{variable}} substitution"),condition:r.z.record(r.z.any()).optional().describe("Condition object for filtering when hook fires"),timing:r.z.enum(["before","after"]).default("after").describe("When to fire relative to the event"),action:r.z.enum(["spawn_agent","inject_prompt"]).optional().describe("What the hook does: spawn_agent (default) starts a new session of `agent` with the prompt; inject_prompt sends the prompt into an existing session"),target:r.z.enum(["independent_session","child_session","same_session","parent_session","ancestor_chain"]).optional().describe("Where the prompt goes. With spawn_agent: independent_session (default, no parent) or child_session (under the session that fired the event). With inject_prompt: same_session (default, the session that fired the event), parent_session, or ancestor_chain"),maxIterations:r.z.number().int().min(1).optional().describe("Maximum times the hook fires for one session, counted from its firing record. Set it on every session_idle hook that sends into the same session. A session a hook started never triggers that hook again, whatever this says"),emitEvent:r.z.string().optional().describe("Custom event to emit on completion"),emitEventOnCondition:r.z.union([r.z.object({condition:r.z.object({field:r.z.string(),operator:r.z.enum(["contains","not_contains","equals","not_equals","matches","not_matches"]),value:r.z.string()}),event:r.z.string()}),r.z.array(r.z.object({condition:r.z.object({field:r.z.string(),operator:r.z.enum(["contains","not_contains","equals","not_equals","matches","not_matches"]),value:r.z.string()}),event:r.z.string()}))]).optional().describe("Conditional event emission based on output")}),exports.MetaWorkflowAddRecipeSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to add the recipe to"),recipeId:r.z.string().describe("Recipe ID to add"),position:r.z.number().int().min(0).optional().describe("Position in the workflow (0-based, appended if omitted)")}),exports.MetaWorkflowRemoveRecipeSchema=r.z.object({workflowId:r.z.string().describe("Workflow ID to remove the recipe from"),recipeId:r.z.string().describe("Recipe ID to remove")}),exports.MetaAgentListSchema=r.z.object({}),exports.MetaOperationsSchema=r.z.object({operation:r.z.enum(["workflow-list","workflow-get","workflow-create","workflow-update","recipe-list","recipe-get","recipe-create","recipe-add-hook","recipe-remove-hook","hook-list","hook-create","workflow-add-recipe","workflow-remove-recipe","agent-list"]).describe("Which meta operation to perform; the other params apply per operation (see tool description)"),...exports.MetaWorkflowGetSchema.partial().shape,...exports.MetaWorkflowCreateSchema.partial().shape,...exports.MetaWorkflowUpdateSchema.partial().shape,...exports.MetaRecipeGetSchema.partial().shape,...exports.MetaRecipeCreateSchema.partial().shape,...exports.MetaRecipeAddHookSchema.partial().shape,...exports.MetaRecipeRemoveHookSchema.partial().shape,...exports.MetaHookCreateSchema.partial().shape,...exports.MetaWorkflowAddRecipeSchema.partial().shape,...exports.MetaWorkflowRemoveRecipeSchema.partial().shape}),exports.TestingProcessListSchema=r.z.object({}),exports.TestingProcessGetSchema=r.z.object({processId:r.z.string().describe("Test process ID to retrieve")})
5230
+ const m=r.z.object({name:r.z.string().min(1).describe('Command name (e.g., "Build", "Unit Tests")'),command:r.z.string().min(1).describe('Shell command to run (e.g., "npm test")'),required:r.z.boolean().default(!0).describe("If true, failure blocks the request (default: true)"),timeout:r.z.number().int().min(10).max(3600).default(300).describe("Max execution time in seconds (default: 300)")})
5231
+ exports.TestingProcessCreateSchema=r.z.object({name:r.z.string().min(1).describe("Name for the test process"),environmentId:r.z.string().optional().describe("ID of the environment (confined runtime) this process runs in. Get it from environment_list or environment_setup."),description:r.z.string().optional().describe("Description of what this process verifies"),scope:r.z.string().optional().describe('LABEL ONLY -- a monorepo path prefix recorded for display (e.g. "packages/api/"). It does NOT affect when the process runs; use pathGlobs for that.'),pathGlobs:r.z.array(r.z.string()).optional().describe('Which changes this process runs on: glob patterns matched against the changed files (e.g. ["sites/**"], ["src/**", "*.md"]). THIS is what limits when the process runs. Omit it and the process runs on EVERY change, which is the right choice only for a check that is cheap and universal.'),areas:r.z.array(r.z.string()).optional().describe('Work-area labels this process covers (e.g. ["graphics/opengl"]). An alternative to pathGlobs for work that is not file-shaped; a process applies if EITHER dimension matches.'),setup:r.z.array(r.z.string()).optional().describe('Commands to prepare the environment (e.g., ["ln -s ../../node_modules node_modules"])'),commands:r.z.array(m).min(1).describe("Test commands to execute in order"),verifyAcceptanceCriteria:r.z.boolean().optional().describe("When true, auto-tester verifies request acceptance criteria after running commands"),fingerprint:r.z.array(r.z.string()).optional().describe('Files whose content invalidates setup. Setup commands re-run only when these files change between runs (e.g. ["package-lock.json"], ["Cargo.lock"], ["uv.lock", "poetry.lock"]). Polyglot repos list multiple. Omit / empty list = always re-run setup (existing behavior).'),poolSize:r.z.number().int().min(1).max(8).optional().describe("Number of warm test worktrees in the pool. Default 2. Set to 1 for languages with very large build artifacts (Rust target/, C++ build/). Higher values allow more parallel test runs at the cost of disk."),runtimeKept:r.z.string().optional().describe('Only when the user chose to run the check on a runtime other than the lowest one the project declares: that runtime and version, e.g. "python 3.12". Without it, a check whose environment runs another version than the declared minimum is not registered.'),leavesOut:r.z.array(r.z.object({what:r.z.string().describe('The left-out part in plain words, e.g. "the Valkey backend tests"'),paths:r.z.array(r.z.string()).min(1).describe('Globs for the files only that part covers: its test files and the code only they exercise, e.g. ["tests/ut/backends/test_valkey.py", "aiocache/backends/valkey.py"]')})).optional().describe('What this check deliberately does not run and no other check runs (the suites the card lists as "not run on every change"), each with the files only that part covers. A change to those files is reported to the user as not checked by this check.')}),exports.TestingProcessDeleteSchema=r.z.object({processId:r.z.string().describe("Test process ID to delete")}),exports.EnvironmentListSchema=r.z.object({}),exports.ResultsSchema=r.z.object({operation:r.z.enum(["record","fetch","pin","list","read"]),path:r.z.string().optional().describe("record: the file, inside the project (not /tmp); your worktree first, then the main project. Bulk that must not reach a commit can be written by a command under `.alchemy_lab/scratch/` (gitignored)."),name:r.z.string().optional().describe("record: the name a person uses for it (defaults to the filename). list: show every version recorded under this name, newest first."),summary:r.z.record(r.z.any()).optional().describe('record (required): the small facts a reader wants instead of the bytes, e.g. {maxStress: 412, unit: "MPa", converged: true}.'),box:r.z.string().optional().describe("An experiment handle (exp_...). fetch: put the bytes inside that sealed box under its /scratch (a box cannot see the host scratch; omit for host work, which is faster). record: the result lives inside that box and is streamed out and stored in one step (a box cannot write your worktree)."),mediaType:r.z.string().optional().describe("record: MIME type, when you know it."),inputs:r.z.array(r.z.string()).optional().describe("record: addresses of the results this one was made from (provenance)."),note:r.z.string().optional().describe("record: one line on how it was produced."),address:r.z.string().optional().describe("pin / read / fetch: the full 64-character address the record returned (a unique prefix works too)."),at:r.z.string().optional().describe("pin: the pointer path in your worktree (.result.json is added). fetch: where the bytes land, under `.alchemy_lab/scratch/` on the host or the box's `/scratch`. Defaults to results/<name>."),comment:r.z.string().optional().describe("pin: the commit comment for the pointer file."),offset:r.z.number().optional().describe("read: line to start at (default 0)."),limit:r.z.number().optional().describe("read: how many lines (default 200). list: how many results (default 25)."),find:r.z.string().optional().describe("read: return only lines containing this text, instead of a range.")}),exports.ResultInspectSchema=r.z.object({operation:r.z.enum(["list","read"]),name:r.z.string().optional().describe("list: show every version recorded under this name, newest first."),address:r.z.string().optional().describe("read: the full 64-character address of the result."),offset:r.z.number().optional().describe("read: line to start at (default 0)."),limit:r.z.number().optional().describe("read: how many lines (default 200). list: how many results (default 25)."),find:r.z.string().optional().describe("read: return only lines containing this text, instead of a range.")}),exports.ExperimentStartSchema=r.z.object({env:r.z.string().optional().describe("Environment by name (from environment_list), one whose image has the toolchain you need."),environmentId:r.z.string().optional().describe("Environment by id (alternative to `env`). The primary env is used if neither is given."),size:r.z.enum(["light","standard","heavy"]).optional().describe("light: 2 cores (lint, a typecheck, one test file). standard (default): a share of the free cores (a suite, a build). heavy: every free core but 2, only for work that uses them all (a CFD solve, meshing, a large parallel build). A size you do not hold opens another box."),confirmWorkspace:r.z.boolean().optional().describe('Required for env "workspace" (the live host): the task genuinely needs the real machine. Building or trying out the app does not.')}),exports.ExperimentStopSchema=r.z.object({handle:r.z.string().describe("The experiment handle to tear down.")}),exports.ExperimentListSchema=r.z.object({}),exports.ReadSiteSchema=r.z.object({url:r.z.string()}),exports.DriveSiteSchema=r.z.object({url:r.z.string().describe("The running product, e.g. the environment's published URL or http://localhost:5173."),steps:r.z.array(r.z.object({action:r.z.enum(["click","clickat","type","press","move","scroll","wait","media"]).describe('click (selector) \xb7 clickat (x,y) \xb7 type (selector + text) \xb7 press (key) \xb7 move (x,y) \xb7 scroll (dy) \xb7 wait (ms, max 5000) \xb7 media ("print" shows the printout, "screen" switches back)'),selector:r.z.string().optional().describe('Playwright selector, e.g. "text=Build" or "#start".'),text:r.z.string().optional(),key:r.z.string().optional().describe('e.g. "Enter"'),x:r.z.number().optional(),y:r.z.number().optional(),dy:r.z.number().optional(),ms:r.z.number().optional(),media:r.z.enum(["print","screen"]).optional()})).min(1).max(20),shots:r.z.enum(["each","final"]).optional().describe('"each" screenshots every step; default the final state only.'),session:r.z.string().optional().describe("Keeps the page open: the next call with this name continues where this one stopped. Idle sessions close after 10 minutes."),close:r.z.boolean().optional().describe("Close the named session after this call."),width:r.z.number().optional().describe("Viewport width for a new session (default 1280; 390 is a phone).")}),exports.CaptureSiteSchema=r.z.object({url:r.z.string(),fullPage:r.z.boolean().optional().describe("The whole scrollable page instead of the viewport."),width:r.z.number().optional().describe("Viewport width (default 1280; 390 is a phone).")}),exports.PreviewSiteSchema=r.z.object({dir:r.z.string().describe('Repo-relative, e.g. "dist" or "." for the top of the repository.'),requestId:r.z.string().regex(/^req\d{6}$/).optional().describe("Serve from this unmerged request's working copy instead of main."),name:r.z.string().optional().describe("Preview handle (default: a slug of dir); reusing one replaces that preview."),label:r.z.string().optional()}),exports.FetchAssetSchema=r.z.object({url:r.z.string().describe("The http(s) URL of the image or font to download."),destPath:r.z.string().describe('Where to write it, repo-relative (e.g. "sites/acme/assets/hero.jpg"). Must stay inside the working tree; parent directories are created.')}),exports.RequestVisualFeedbackSchema=r.z.object({box:r.z.string().optional().describe("The experiment handle (from experiment_start, on a screenshot-capable env) to render in / read from. The box must stay held until this returns."),route:r.z.string().optional().describe('With `box`: the route I render + screenshot FOR YOU (e.g. "/" or "/settings"). I serve `serveDir` and screenshot it -- you do NOT hand-roll serve/screenshot. This is the easiest path.'),script:r.z.string().optional().describe('With `box`, for FULL control: a Playwright snippet (the body of `async (page, baseUrl) => { ... }`). I serve the app, launch headless Chromium, and run your script -- navigate (page.goto(baseUrl + "/x")), click, fill, scroll, waitForSelector, etc. -- then screenshot the final page state. Reliable: you write only the interaction, no serve/launch/flags. Use this to reach a state that needs interaction (open a menu, log in, submit a form).'),fullPage:r.z.boolean().optional().describe("Capture the entire scrollable page instead of just the viewport."),serveDir:r.z.string().optional().describe("With `box`+`route`: the static dir to serve (default /work). For a built app, build first via run(), then point this at the build output (e.g. /work/dist)."),path:r.z.string().optional().describe("Alternative to route: a screenshot you ALREADY wrote inside the box (e.g. /tmp/shot.png); I read it out."),assetFilename:r.z.string().optional().describe("Alternative to box: the filename of an already-uploaded screenshot asset to annotate."),prompt:r.z.string().optional().describe("What you want the human to look at or mark up (shown with the request)."),timeoutMs:r.z.number().optional().describe("How long to wait for the human, in ms (default ~10 min).")}),exports.AskUserVisualSchema=r.z.object({question:r.z.string().describe('The question for the USER about the marked region (e.g. "Should this button use the primary color?").'),imagePath:r.z.string().optional().describe("Repo-relative path to an image you already produced (png/jpg/gif/webp), e.g. a screenshot you wrote. Provide this OR previewName."),previewName:r.z.string().optional().describe("Name of a registered live preview (a `live:` ref); I freeze it into a snapshot image for you. Provide this OR imagePath."),box:r.z.string().optional().describe('The region the question is about: "x,y,w,h" in normalized 0..1 image coordinates, origin top-left (e.g. "0.62,0.08,0.3,0.12"). Omit to ask about the whole image.'),options:r.z.array(r.z.string()).optional().describe("Optional answer choices (labels). Omit for a free-text answer."),context:r.z.string().optional().describe("Extra context shown with the question in the inbox (why you are asking, what you will do with the answer)."),priority:r.z.enum(["low","normal","high"]).optional().describe('Question priority; "high" always reaches the user regardless of autonomy dial.')}),exports.EnvironmentGetSchema=r.z.object({environmentId:r.z.string().describe("Environment ID to retrieve")}),exports.EnvironmentProvisionSchema=r.z.object({environmentId:r.z.string(),why:r.z.string().optional().describe("Why provision now (shown on the approval).")}),exports.EnvironmentTeardownSchema=r.z.object({environmentId:r.z.string()}),exports.EnvironmentStatusSchema=r.z.object({environmentId:r.z.string()}),exports.EnvironmentVerifyStackSchema=r.z.object({environmentId:r.z.string()})
5232
+ const g=r.z.object({image:r.z.string().optional().describe("Container image carrying the project toolchain/deps, e.g. node:20-alpine, python:3.12-slim, golang:1.22, ruby:3.3"),install:r.z.string().optional().describe("Deps install command -- Node-only sugar that populates a /work/node_modules cache volume, run with registry egress before the confined gate, e.g. npm ci. Non-Node runtimes use `artifacts` instead (a cache volume + prepare command: .venv/uv sync, cargo, go, vendor/bundle). Omit if the project has no deps."),composeFile:r.z.string().optional().describe("Path to the project docker-compose file for its services. Omit if no services."),shellInit:r.z.string().optional().describe("Shell preamble run before EVERY command in the box, e.g. '. /usr/lib/openfoam/openfoam2312/etc/bashrc'. REQUIRED for a toolchain that publishes itself through a script rather than the image PATH (OpenFOAM etc/bashrc, oneAPI setvars.sh, conda activate, ROS setup.bash): `docker exec` runs no ENTRYPOINT and reads no login profile, so without this every command gets a bare PATH. Put the preamble HERE, never inside the smoke command -- a smoke command carrying its own preamble proves the preamble and not the environment, and the next agent gets nothing."),connEnv:r.z.record(r.z.string()).optional().describe("Connection env injected into the gate (e.g. DATABASE_URL) using SERVICE NAMES + internal ports, never localhost/host ports."),seed:r.z.array(r.z.string()).optional().describe("Optional commands run after services are up (e.g. migrations)."),artifacts:r.z.array(r.z.object({path:r.z.string().describe("Mount target for the writable, populated volume: relative to /work (e.g. node_modules, .venv, vendor/bundle) or absolute (e.g. /cache/cargo)."),prepare:r.z.string().optional().describe("Command that populates it -- the one phase with registry egress (e.g. npm ci, uv sync, cargo fetch). Omit for a writable empty volume."),manifests:r.z.array(r.z.string()).optional().describe("Lockfiles (relative to /work) whose content hash keys the cache; list them so the volume is reused across runs and only rebuilt when deps change (e.g. uv.lock, Cargo.lock). Omit => rebuilt every run."),env:r.z.record(r.z.string()).optional().describe('Env applied during prepare AND every run, e.g. { CARGO_HOME: "/cache/cargo" } for caches outside /work.')})).optional().describe("Per-runtime build/dependency artifacts: writable volumes populated by a prepare command, generalizing `install` beyond node_modules. Use for Python (.venv), Rust (target + $CARGO_HOME), Go, Ruby (vendor/bundle), etc. `install` is sugar for a single node_modules artifact; for any non-Node runtime use artifacts (install would write to node_modules, the wrong place)."),confinement:r.z.enum(["confined","egress-allowlist","privileged","unsafe","host","pure-host"]).optional().describe("Confinement level. Default 'confined' (fully sealed Docker; add egressAllowlist hosts to open exactly those -- stored as 'egress-allowlist'). privileged/unsafe relax the container. 'host' runs on the host machine (no Docker) inside an OS sandbox (Seatbelt/bubblewrap) for toolchains Docker can't run. 'pure-host' is the built-in workspace env (the live worktree) -- do not create new envs with it. Merge gating is independent (the Sign-off setting)."),commandGate:r.z.array(r.z.enum(["policy","agent","human"])).optional().describe("Gates an experiment command passes before it runs, in escalation order policy -> agent -> human. Empty = run freely; escalating past the last gate blocks (fail closed). policy = deterministic allowlist/deny-floor; agent = isolated LLM judge (allow or escalate only); human = ask. Registered commands are pre-approved. Defaults by level ([] for confined/egress-allowlist, ['human'] for privileged/unsafe)."),worktreeTarget:r.z.enum(["ephemeral","live"]).optional().describe("Worktree the env runs against: 'ephemeral' (a disposable copy at HEAD, default) or 'live' (the project's live working dir, read-write). The built-in workspace env is 'live'."),egressAllowlist:r.z.array(r.z.string()).optional().describe("Hosts the box may reach at the 'egress-allowlist' level (exact name or subdomain, e.g. registry.npmjs.org). Ignored at other levels."),addCaps:r.z.array(r.z.string()).optional().describe("Linux capabilities to add at the 'privileged' level (on top of cap-drop ALL), e.g. SYS_PTRACE for debuggers, IPC_LOCK for memlock. Ignored at other levels."),sysctls:r.z.record(r.z.string()).optional().describe("Namespaced sysctls to set at the 'privileged' level, e.g. net.ipv4.ip_local_port_range. Host-wide sysctls (vm.max_map_count) are NOT settable per-container."),runAsRoot:r.z.boolean().optional().describe("Run the box as root (privileged / unsafe levels). Needed for some caps + the docker socket."),dockerSocket:r.z.boolean().optional().describe("Mount the host docker socket for testcontainers-style tests. WARNING: full host control over the docker daemon. Only honored at the 'unsafe' level."),persistentVolumes:r.z.array(r.z.object({name:r.z.string(),target:r.z.string(),service:r.z.string().optional()})).optional().describe("Data volumes that survive between runs (keyed to this environment; off by default since experiments are ephemeral). Set service to mount into a compose service (e.g. a DB data dir), or omit it to mount into the box (e.g. a SQLite dir)."),resources:r.z.object({memory:r.z.string().optional().describe("Memory cap, e.g. '4g' (default 2g)."),cpus:r.z.number().optional().describe("A fixed CPU count. Usually leave it unset and set size instead."),size:r.z.enum(["light","standard","heavy"]).optional().describe("What this environment's boxes and checks are for, which sets their cores from what is free: light (2 cores: lint, small checks), standard (the default: a share of the free cores, for test suites and builds), heavy (every free core but 2: CFD or FEM solves, meshing, large parallel builds). An agent can ask for another size per box."),pidsLimit:r.z.number().optional().describe("Max processes (default 512)."),scratchMb:r.z.number().optional().describe("Size in MB of an in-memory /scratch, used only when the image cannot take the disk-backed one (default 512). /scratch is normally on disk and needs no size."),shmMb:r.z.number().optional().describe("/dev/shm size in MB -- bump for headless browsers (Chrome crashes on the 64m default).")}).optional().describe("Per-environment resource caps that override the confined defaults.")}),y=function e(t){const n={...t._def,description:void 0}
5214
5233
  if(t instanceof r.z.ZodObject){const r=Object.fromEntries(Object.entries(t.shape).map(([t,r])=>[t,e(r)]))
5215
5234
  n.shape=()=>r}else t instanceof r.z.ZodOptional||t instanceof r.z.ZodNullable||t instanceof r.z.ZodDefault?n.innerType=e(n.innerType):t instanceof r.z.ZodArray?n.type=e(n.type):t instanceof r.z.ZodRecord&&(n.valueType=e(n.valueType))
5216
- return new t.constructor(n)}(m),y='Start from a built-in preset; anything in config overrides it. "office": python-docx, openpyxl, python-pptx, pandoc, LibreOffice and segno/zbarimg (QR codes) in a sealed box, with `render-pdf FILE` to turn Word, Excel, PowerPoint, Markdown or HTML into PDF. Its image is built locally on first use (a few minutes). Pass the same preset (and config) to environment_verify and environment_create.',w="Save without a passing environment_verify, only for a config that cannot be verified from here (it needs credentials, external services or hardware the confined verifier lacks). Requires skipVerifyReason; the skip is logged."
5217
- exports.EnvironmentCreateSchema=r.z.object({name:r.z.string().min(1).describe("Name for the environment, e.g. node + postgres"),description:r.z.string().optional().describe("What this environment provides"),scope:r.z.string().optional().describe("Subproject path prefix for monorepos (e.g. packages/api/). Omit for the whole repo."),preset:r.z.enum(["office"]).optional().describe(y),config:g.optional().describe("The exact config (after the preset) that passed environment_verify in this session, unless skipVerify; its fields are described on environment_verify. Optional with a preset."),isPrimary:r.z.boolean().optional().describe("Make this the project primary environment (default for new test processes). The first environment is primary automatically."),skipVerify:r.z.boolean().optional().describe(w),skipVerifyReason:r.z.string().optional().describe("Why this config cannot be verified (required with skipVerify: true; recorded in the log).")}),exports.EnvironmentUpdateSchema=r.z.object({environmentId:r.z.string(),name:r.z.string().min(1).optional(),description:r.z.string().optional(),scope:r.z.string().optional(),config:g.optional().describe("Replaces the config wholesale: the exact config that passed environment_verify in this session, unless skipVerify (fields described on environment_verify). Metadata-only updates need no verify."),isPrimary:r.z.boolean().optional().describe("Make this the project primary environment"),skipVerify:r.z.boolean().optional().describe(w),skipVerifyReason:r.z.string().optional().describe("Why this config cannot be verified (required with skipVerify: true; recorded in the log).")}),exports.EnvironmentDeleteSchema=r.z.object({environmentId:r.z.string().describe("Environment ID to delete")}),exports.EnvironmentVerifySchema=r.z.object({preset:r.z.enum(["office"]).optional().describe(y),config:m.optional().describe("The proposed environment config to verify (image, install, services, connection). Optional with a preset."),smoke:r.z.string().optional().describe("Optional smoke command run confined after the environment is up (default: true). Use a connection probe to confirm services are reachable.")}),exports.EnvironmentSetupSchema=r.z.object({name:r.z.string().max(60).optional().describe("A few words the user reads as the setup request's title (e.g. 'Node 20 for syntax checks')."),context:r.z.string().optional().describe("What you need and why, for the setup-architect (e.g. 'Node 20 to run node --check on standalone .js files; no deps').")}),exports.TestingProcessUpdateSchema=r.z.object({processId:r.z.string(),environmentId:r.z.string().optional(),name:r.z.string().min(1).optional(),description:r.z.string().optional(),scope:r.z.string().optional().describe("A display label only; pathGlobs decides when the process runs."),pathGlobs:r.z.array(r.z.string()).optional().describe('Globs matched against changed files (e.g. ["src/**", "*.md"]): the changes this process runs on. Replaces the list; [] means every change.'),areas:r.z.array(r.z.string()).optional().describe("Work-area labels this process covers; it applies when pathGlobs or areas match."),isActive:r.z.boolean().optional(),setup:r.z.array(r.z.string()).optional().describe("Replaces the setup commands."),commands:r.z.array(f).optional().describe("Replaces the test commands."),verifyAcceptanceCriteria:r.z.boolean().optional().describe("The auto-tester also verifies the request's acceptance criteria."),fingerprint:r.z.array(r.z.string()).optional().describe("Files whose content invalidates setup."),poolSize:r.z.number().int().min(1).max(8).optional().describe("Warm test worktrees in the pool."),runtimeKept:r.z.string().optional().describe('With environmentId: only when the user chose a runtime other than the lowest one the project declares, e.g. "python 3.12".')}),exports.TestsSchema=r.z.object({operation:r.z.enum(["list","setup","run","switch-off","switch-on"]),process:r.z.string().optional().describe("run, switch-off, switch-on: one test process by name or id (run: omit for all active ones)."),userSaid:r.z.string().max(600).optional().describe("switch-off / switch-on: the user's words asking for it, copied exactly."),name:r.z.string().optional().describe("run: one test command by name; omit for all required commands."),ask:r.z.string().max(1500).optional().describe("setup, required outside a request: what the user asked the check to run, in their words; the setup architect registers exactly that.")}),exports.ExecuteTestCommandSchema=r.z.object({processId:r.z.string().describe("Test process ID containing the command"),commandName:r.z.string().describe('Name of the test command to run, or "setup" to run all setup commands in sequence')}),exports.RunSchema=r.z.object({command:r.z.string().optional().describe("A shell command, run in the box (pass box or env)."),name:r.z.string().optional().describe("A saved command by name, instead of command."),box:r.z.string().optional().describe("An experiment handle from experiment_start."),env:r.z.string().optional().describe("Instead of box: an environment by name; its box is started (or your open one reused) and the result gives the handle."),size:r.z.enum(["light","standard","heavy"]).optional().describe("With env: the box size (see experiment_start)."),args:r.z.string().optional(),grep:r.z.string().optional().describe("Filter output through grep -i with this pattern."),timeout:r.z.number().optional().describe("Seconds."),why:r.z.string().optional().describe("One short sentence, shown on the approval card when the command needs the user's approval."),cwd:r.z.string().optional().describe('A subdirectory for an ad-hoc command (e.g. "apps/web"); a command starting with `cd` is refused in favour of this.')}),exports.CommandsSchema=r.z.object({operation:r.z.enum(["run","list","remove","register","setup"]).default("run").describe('list, register, remove or setup ("run" is the run tool\'s job). register suggests commands; prefer one general project-wide check over per-file variants.'),name:r.z.string().optional().describe("remove: the command name."),args:r.z.string().optional(),grep:r.z.string().optional(),command:r.z.string().optional(),timeout:r.z.number().optional(),cwd:r.z.string().optional(),context:r.z.string().optional().describe("setup: what you think the user needs, a hint for the architect."),commands:r.z.array(r.z.object({name:r.z.string().min(1).describe('e.g. "test:web"'),command:r.z.string().min(1),description:r.z.string().min(1).describe("What this command verifies."),cwd:r.z.string().optional().describe("Relative to the project root (monorepo subdirs); omit for the root."),timeout:r.z.number().optional().describe("Seconds (default 60).")})).optional().describe("register: the commands to suggest.")}),exports.ReportTestResultsSchema=r.z.object({status:r.z.enum(["passed","failed","error"]).describe("Overall result"),testRunId:r.z.string().optional().describe("The test run this verdict belongs to (given in your instructions). Strongly preferred: without it the latest run is guessed, which misattributes results when several testers run concurrently."),results:r.z.object({commands:r.z.array(r.z.object({name:r.z.string().describe("Command name"),status:r.z.enum(["passed","failed","skipped","error"]).describe("Command result"),output:r.z.string().optional().describe("Relevant output snippet"),diagnosis:r.z.string().optional().describe("Why it failed, if applicable")})).describe("Per-command results"),summary:r.z.string().describe("Brief overall summary"),acceptanceCriteria:r.z.array(r.z.object({criterion:r.z.string().describe("The acceptance criterion text"),status:r.z.enum(["verified","unverified","unclear"]),evidence:r.z.string().describe("How verified, or why not")})).optional().describe("AC verification results, if applicable"),faultClass:r.z.enum(["fail_code","fail_evidence","fail_environment","fail_process"]).optional().describe("On a FAILED verdict, WHY it failed so the gate routes to the right actor: 'fail_code' (the change is wrong), 'fail_evidence' (the run did not prove a criterion the coder could have proven: attach/adjust verify commands), or 'fail_environment' (a required tool/runtime is MISSING from the confined box, e.g. 'node: not found': the coder cannot fix this; the environment must be extended). Use 'fail_environment' ONLY when the evidence shows a command/runtime absent from the box, never for a genuine defect or a fixable evidence gap. 'fail_process' is for a test process whose OWN command names a file the repository does not have (a deleted script): nobody's code is wrong and extending the box cannot help; the process itself must be fixed or turned off."),missingCapabilities:r.z.array(r.z.string()).optional().describe("With faultClass 'fail_environment', the binaries/runtimes the box lacks (e.g. ['node']) so the environment can be extended to provide them.")}).describe("Structured test results")}).superRefine((e,t)=>{"fail_environment"!==e.results?.faultClass||e.results.missingCapabilities&&e.results.missingCapabilities.length>0||t.addIssue({code:r.z.ZodIssueCode.custom,path:["results","missingCapabilities"],message:"faultClass 'fail_environment' requires results.missingCapabilities: name the absent binaries/runtimes (the deterministic capability probe in your evidence lists them, e.g. ABSENT from the box: node). Without the names, the environment cannot be extended and the request strands."})}),exports.OpeningBriefSectionSchema=r.z.object({id:r.z.string().min(1).describe('Stable id, unique within the brief (e.g. "date-format"). "testing-mode" is reserved for the server.'),question:r.z.string().min(1).describe("The choice, as one plain question the user can answer without your session."),context:r.z.string().min(1).describe("What the choice shapes, the consequence of each option, and why your default is recommended, citing the request and its sources as they state them; where they answer the choice, recommend their answer."),options:r.z.array(r.z.object({id:r.z.string().min(1),label:r.z.string().min(1),description:r.z.string().optional().describe("What it means and its tradeoff, in 1-2 plain sentences.")})).min(2).describe("At least two genuine alternatives."),default:r.z.string().min(1).describe("The option id you are proceeding on now."),criteria:r.z.array(r.z.string().min(1)).optional().describe('Keys of the criteria whose wording this choice decides (e.g. ["2b"]), worded for your default. If the user picks another answer, each is marked for rewording and is not proven until reworded.')}).superRefine((e,t)=>{e.options.some(t=>t.id===e.default)||t.addIssue({code:r.z.ZodIssueCode.custom,path:["default"],message:`default '${e.default}' names no option in this section (option ids: ${e.options.map(e=>e.id).join(", ")})`}),"testing-mode"===e.id&&t.addIssue({code:r.z.ZodIssueCode.custom,path:["id"],message:"section id 'testing-mode' is reserved: the server composes the testing section when the project's gate needs it -- remove it from your sections"})}),exports.SessionMessageOperationsSchema=r.z.object({operation:r.z.enum(["send","note","reply","list","get","offer-handoff","record-decision","brief","withdraw"]),milestone:r.z.boolean().optional().describe("note: a real boundary (it works, the approach changed, the goal is met), a few per request at most; one quiet line in the user's stream."),withdrawReason:r.z.string().optional().describe("withdraw: why the answer is no longer needed."),type:r.z.enum(["question","report"]).optional().describe("Required for send."),toSessionId:r.z.string().optional().describe('Target session id, or "parent". Omit to ask the user (a broadcast).'),questionType:r.z.enum(["free-form","alternatives"]).optional().describe("Required for a question."),questionContent:r.z.object({question:r.z.string().min(1),context:r.z.preprocess(e=>null!==e&&"object"==typeof e?JSON.stringify(e):e,r.z.string().optional()).optional().describe("What the user needs to answer without your session: what you found, why it matters, the consequence of each answer, why you recommend what you do. No paths or identifiers; output you ask them to judge goes in a fenced code block, as printed."),options:r.z.array(r.z.object({id:r.z.string(),label:r.z.string(),description:r.z.string().optional().describe("What it means and its tradeoff, in 1-2 plain sentences. Fill it on every option."),recommended:r.z.boolean().optional().describe("Your advice, highlighted on the card; not what happens if nobody answers (that is defaultOption). Not on a question that names criteria. Never an option that makes up what the user has not given (estimated numbers, sample values, invented names): where it is missing, the way forward leaves it visibly empty or marked unknown."),effect:r.z.enum(["choose","send-back","not-yet"]).optional().describe('"choose" (default): records the pick for you. "send-back": asks for a change to the work; on a request waiting for the user\'s sign-off the pick itself sends it back to you (do not call reopen). "not-yet": only with [user-input] criteria; they stay owed.')})).optional().describe("Each a genuine alternative, complete in one tap (one needing a second answer is two options). Recommended option first. When the way the user asked cannot work, include one that reaches their goal another way."),allowMultiple:r.z.boolean().optional(),fields:r.z.array(r.z.object({id:r.z.string().min(1),label:r.z.string().min(1),placeholder:r.z.string().optional()})).min(1).optional().describe('free-form: one labelled input per value (a name, an email); the answer arrives as "Label: value" lines. Never ask for passwords or keys: answers are on the record.'),defaultOption:r.z.string().optional().describe("What happens if nobody answers before it expires (the option id, or the text for free-form); the asker then resumes. It happens without the user, so it must be safe: when options differ in risk (values silently changed, data loss, made-up data, anything hard to undo), the default is the safe one even if you recommend another, and the context says so."),onExpiry:r.z.enum(["assume-default","escalate"]).optional().describe('"assume-default" (default with a defaultOption): resolve to it and resume the asker. "escalate": leave it pending for the user (on Self-driving only priority "high" reaches them).'),steer:r.z.enum(["what","how"]).optional().describe('Tag every question: "what" shapes the work product (spec, wording, UX, scope); "how" steers the process (testing, sequencing, completion). Most "how" choices are yours to make, not to ask.')}).optional().describe("Required for a question."),priority:r.z.enum(["low","normal","high"]).optional().describe('"high": blocked with real stakes; reaches the user at once, past the question gate. "low" with a defaultOption: under \'balanced\', batched to the next checkpoint (request review or plan handoff) without holding; you proceed on your default.'),expiresInHours:r.z.number().optional(),userSaid:r.z.string().min(8).max(600).optional().describe('question: when the user asked you to ask them (a card, options, "ask me first"), their words copied exactly. Checked against what they wrote; the question then reaches them whatever the Autonomy setting.'),replaces:r.z.array(r.z.string().regex(/^Q-[A-Za-z0-9]+-\d+$/)).max(10).optional().describe("question: codes of your open questions on the same request that this one supersedes; they close when it posts. With a question already open on the request, pass this or keepsOpen."),keepsOpen:r.z.boolean().optional().describe("question: true when this asks something different from your open questions on the request, so they stay open."),forceAsk:r.z.boolean().optional().describe("question: re-ask something the decision record already answers, only because circumstances changed; say what changed in questionContent.context."),status:r.z.enum(["success","partial","failure","blocked"]).optional().describe("Required for a report."),blockedOn:r.z.string().optional().describe('Required with status "blocked" on a request you own: "decision" (a question to your parent, escalating to the user) or a request id like "req000123" (declares a wait; you are told when it settles).'),criteria:r.z.array(r.z.string().min(1)).max(10).optional().describe('question: keys of the [user-input] criteria you ask for (e.g. ["1a"]); only such a question counts as asking them. It goes to the user with no default and no recommended option, and the answer is their proof unless the picked option is "not-yet". With a "not-yet" option you build with a placeholder meanwhile (Self-driving answers "not yet" at once); without one you wait for the answer at every Autonomy level. The user\'s check of finished work is asked on the card at the end, not here.'),attention:r.z.enum(["fyi","glance","act"]).optional().describe("'fyi' (logged, no badge), 'glance' (look soon), 'act' (the user must act). Default from status: failure/blocked act, partial glance, success fyi. It does not decide who is woken."),reportKind:r.z.enum(["milestone","reply"]).optional().describe("'milestone': narration at a boundary. 'reply': a reply to the user's inbox message."),summary:r.z.string().optional().describe("Required for a report. Outcome first, paths and identifiers in details. It shows alone in the stream, often hours later: name the subject first, never open with Also or Then. Reports to agents can be technical."),details:r.z.string().optional().describe("With blockedOn \"decision\" these become the question's context, and the user's card if your parent cannot decide: plain words, no tool names or call syntax; explain a refusal you got instead of pasting it."),ruleVerdicts:r.z.array(r.z.object({rule:r.z.string().min(1).max(80).describe("The rule id as your spawn prompt lists it, without brackets."),verdict:r.z.enum(["held","broken","not_applicable"]),note:r.z.string().max(300).optional().describe("broken: what breaks it and where (file:line). Omit otherwise.")})).max(40).optional().describe('report, Rules reviewer only: a verdict on every rule you were given. Only "broken" is a finding.'),finish:r.z.boolean().optional().describe("Release your request associations after the report."),silent:r.z.boolean().optional().describe("Record the report for the coordinator to drain without waking it (fan-out research workers)."),relatesTo:r.z.string().regex(/^[IQ]-[A-Za-z0-9]+-\d+$/,"relatesTo must be an instruction code (I-...) or question code (Q-...)").optional().describe("An instruction code (I-...) this relates to; for record-decision, a question code (Q-...) it resolves or supersedes."),decision:r.z.string().optional().describe("record-decision (required): the one-line call, recorded as the answer."),why:r.z.string().optional().describe("record-decision: the reasoning."),context:r.z.string().optional().describe("record-decision: what the choice was about, recorded as the question (defaults to decision)."),requestId:r.z.string().optional().describe('The request this is about (e.g. "req000007"), so it shows on that request. note: defaults to your session\'s request. report and record-decision: pass it when about one request, or it is filed only at the project. brief: required.'),area:r.z.string().optional().describe('record-decision: a work area (e.g. "graphics/opengl") when the call is about that area. Ignored if requestId is set.'),sections:r.z.array(exports.OpeningBriefSectionSchema).min(1).optional().describe("brief (required): your real design choices, each with at least two options, a default and context."),messageCode:r.z.string().optional().describe("Required for reply, get and withdraw."),sectionAnswers:r.z.record(r.z.string(),r.z.string().nullable()).optional().describe("reply to an opening brief: { sectionId: optionId } for sections the user answered, changed or confirmed, with quote (their words); null when a section no longer applies; 'your-words' when no option says what they asked. Sections not named stay open. A changed choice acts on the work as it is now (finished work goes back to rework)."),quote:r.z.string().optional().describe("reply to a question: the user's words this answer records, copied exactly; it is then recorded as decided with the user, and refused if they never wrote them. Omit for your own decision. Options that are the user's own statement (\"I checked, it works\") only the user can pick."),text:r.z.string().optional().describe("reply: the answer to a free-form question. note (required): the note."),selectedOptions:r.z.array(r.z.string()).optional().describe("reply: the picked option ids."),notes:r.z.string().optional(),escalate:r.z.boolean().optional().describe("reply to a question asked of you that needs the user: a copy reaches the user with your recommendation (in notes); the asker gets their answer directly. Not for broadcasts."),list:r.z.object({sessionId:r.z.string().optional().describe("Defaults to your session."),messageType:r.z.enum(["question","report","instruction","all"]).default("all"),direction:r.z.enum(["incoming","outgoing","all"]).default("all"),status:r.z.enum(["pending","answered","expired","success","partial","failure","blocked","all"]).default("all"),readStatus:r.z.enum(["unread","read","acknowledged","all"]).default("all"),requestId:r.z.string().optional().describe("Only messages about this request. Listing another session's inbox defaults to the request you are on."),limit:r.z.number().min(1).max(100).default(50),offset:r.z.number().min(0).default(0)}).optional(),offerHandoff:r.z.object({summary:r.z.string().describe('One sentence: what the plan builds. The card is already titled "Plan ready"; do not start with that.'),requestIds:r.z.array(r.z.string()).describe("Request ids created from the plan.")}).optional()}).refine(e=>"send"===e.operation?!!e.type:"note"===e.operation?"string"==typeof e.text&&e.text.trim().length>0:"reply"===e.operation?!!e.messageCode:"list"===e.operation||("get"===e.operation?!!e.messageCode:"offer-handoff"===e.operation||("record-decision"===e.operation?!!e.decision:"brief"===e.operation?!!e.requestId&&Array.isArray(e.sections)&&e.sections.length>0:"withdraw"===e.operation&&!!e.messageCode)),{message:"Invalid operation data: send requires type, note requires text, reply requires messageCode, get requires messageCode, record-decision requires decision, brief requires requestId and a non-empty sections array, withdraw requires messageCode"}),exports.CommitToViewedSessionSchema=r.z.object({message:r.z.coerce.string().min(1).describe("The cleaned-up user message to post to the viewed session. Fix obvious dictation errors, add punctuation, but preserve the user's intent exactly.")}),exports.DirectiveOperationsSchema=r.z.object({operation:r.z.enum(["set","list","search-decisions"]).describe("set = propose standing guidance in the user's words (they adopt it); list = list the project's guidance; search-decisions = free-text search the project's decision + annotation record (ask-the-history)"),targetType:r.z.enum(["project","area","request"]).optional().describe('set: what the guidance is addressed to. "project" = the whole project; "area" = a work-area name (targetId); "request" = a specific request (targetId = its local id).'),targetId:r.z.string().optional().describe('set: the area name (for targetType "area") or request local id (for targetType "request"). Omit for project-wide guidance.'),body:r.z.string().max(2e3).optional().describe("set: the standing guidance itself: a preference that shapes future work in scope (required for set). Max 2000 chars."),note:r.z.string().optional().describe("set: optional short note about why this guidance exists."),userSaid:r.z.string().optional().describe("set (required): the user's own words stating this guidance, copied exactly from their message. The card quotes them; guidance the user did not state is proposed with guidance_propose instead."),revises:r.z.string().max(160).optional().describe('set: when the user\'s words change guidance that stands ("onion skins are fine now" against "no onions"), its key as list shows it (pr:...). Adopting then rewords that item in place; without it a second item is added beside the old one.'),status:r.z.string().optional().describe("list: optional status filter (active | dormant | archived)."),query:r.z.string().max(200).optional().describe("search-decisions: the search text, matched against recorded decisions (question + answer) and annotations (comment body + quoted text). Required for search-decisions."),limit:r.z.number().int().min(1).max(50).optional().describe("search-decisions: max matches per record type (default 10).")}),exports.McpConnectionsSchema=r.z.object({operation:r.z.enum(["list","propose"]).describe("list = the connections this project has; propose = register one, switched off, for the user to switch on."),name:r.z.string().optional().describe("propose: the connection name, lower case letters, digits and dashes. It becomes the tool prefix (name_tool)."),transport:r.z.enum(["repo","boxed","remote"]).optional().describe("propose: repo = a server in THIS repository, built from its Dockerfile and run in a confined box (the repository is mounted read-only at /work, /scratch is writable memory, the image ENTRYPOINT is what runs, rebuilt when its files change on main); boxed = a published npm package at an exact version, installed once and run in a box; remote = a hosted server reached by url."),dockerfile:r.z.string().optional().describe("propose repo: path of the Dockerfile inside the repository, e.g. mcp/server.Dockerfile."),context:r.z.string().optional().describe("propose repo: the docker build context directory inside the repository (default: the repository root)."),package:r.z.string().optional().describe("propose boxed: npm package with an exact version, e.g. @scope/server@1.2.3."),bin:r.z.string().optional().describe("propose boxed: the bin to run, the name under node_modules/.bin."),url:r.z.string().optional().describe("propose remote: the http(s) url."),environment:r.z.record(r.z.string()).optional().describe("propose: plain KEY=value configuration (headers for remote). Never put a secret here; name it in secretKeys instead."),secretKeys:r.z.array(r.z.string()).optional().describe("propose: names of environment variables (or headers) whose VALUES are secret. The user sets the values on the machine that runs the work; they never reach the database.")}),exports.AnswerQuestionSchema=r.z.object({messageCode:r.z.string().min(1).describe("The code in square brackets from <waiting_on_you>, e.g. Q-51209THD-005."),optionId:r.z.string().optional().describe("The id of the option the user picked, when the question has options."),text:r.z.string().optional().describe("The user's answer in their own words, cleaned up, when the question has no options or they said something the options do not cover.")})},19567(e,exports,t){exports.Server=exports.SSEServerTransport=exports.StdioServerTransport=void 0
5235
+ return new t.constructor(n)}(g),w='Start from a built-in preset; anything in config overrides it. "office": python-docx, openpyxl, python-pptx, pandoc, LibreOffice and segno/zbarimg (QR codes) in a sealed box, with `render-pdf FILE` to turn Word, Excel, PowerPoint, Markdown or HTML into PDF. Its image is built locally on first use (a few minutes). Pass the same preset (and config) to environment_verify and environment_create.',b="Save without a passing environment_verify, only for a config that cannot be verified from here (it needs credentials, external services or hardware the confined verifier lacks). Requires skipVerifyReason; the skip is logged."
5236
+ exports.EnvironmentCreateSchema=r.z.object({name:r.z.string().min(1).describe("Name for the environment, e.g. node + postgres"),description:r.z.string().optional().describe("What this environment provides"),scope:r.z.string().optional().describe("Subproject path prefix for monorepos (e.g. packages/api/). Omit for the whole repo."),preset:r.z.enum(["office"]).optional().describe(w),config:y.optional().describe("The exact config (after the preset) that passed environment_verify in this session, unless skipVerify; its fields are described on environment_verify. Optional with a preset."),isPrimary:r.z.boolean().optional().describe("Make this the project primary environment (default for new test processes). The first environment is primary automatically."),skipVerify:r.z.boolean().optional().describe(b),skipVerifyReason:r.z.string().optional().describe("Why this config cannot be verified (required with skipVerify: true; recorded in the log).")}),exports.EnvironmentUpdateSchema=r.z.object({environmentId:r.z.string(),name:r.z.string().min(1).optional(),description:r.z.string().optional(),scope:r.z.string().optional(),config:y.optional().describe("Replaces the config wholesale: the exact config that passed environment_verify in this session, unless skipVerify (fields described on environment_verify). Metadata-only updates need no verify."),isPrimary:r.z.boolean().optional().describe("Make this the project primary environment"),skipVerify:r.z.boolean().optional().describe(b),skipVerifyReason:r.z.string().optional().describe("Why this config cannot be verified (required with skipVerify: true; recorded in the log).")}),exports.EnvironmentDeleteSchema=r.z.object({environmentId:r.z.string().describe("Environment ID to delete")}),exports.EnvironmentVerifySchema=r.z.object({preset:r.z.enum(["office"]).optional().describe(w),config:g.optional().describe("The proposed environment config to verify (image, install, services, connection). Optional with a preset."),smoke:r.z.string().optional().describe("Optional smoke command run confined after the environment is up (default: true). Use a connection probe to confirm services are reachable.")}),exports.EnvironmentSetupSchema=r.z.object({name:r.z.string().max(60).optional().describe("A few words the user reads as the setup request's title (e.g. 'Node 20 for syntax checks')."),context:r.z.string().optional().describe("What you need and why, for the setup-architect (e.g. 'Node 20 to run node --check on standalone .js files; no deps').")}),exports.TestingProcessUpdateSchema=r.z.object({processId:r.z.string(),environmentId:r.z.string().optional(),name:r.z.string().min(1).optional(),description:r.z.string().optional(),scope:r.z.string().optional().describe("A display label only; pathGlobs decides when the process runs."),pathGlobs:r.z.array(r.z.string()).optional().describe('Globs matched against changed files (e.g. ["src/**", "*.md"]): the changes this process runs on. Replaces the list; [] means every change.'),areas:r.z.array(r.z.string()).optional().describe("Work-area labels this process covers; it applies when pathGlobs or areas match."),isActive:r.z.boolean().optional(),setup:r.z.array(r.z.string()).optional().describe("Replaces the setup commands."),commands:r.z.array(m).optional().describe("Replaces the test commands."),verifyAcceptanceCriteria:r.z.boolean().optional().describe("The auto-tester also verifies the request's acceptance criteria."),fingerprint:r.z.array(r.z.string()).optional().describe("Files whose content invalidates setup."),leavesOut:r.z.array(r.z.object({what:r.z.string().describe('The left-out part in plain words, e.g. "the Valkey backend tests"'),paths:r.z.array(r.z.string()).min(1).describe('Globs for the files only that part covers: its test files and the code only they exercise, e.g. ["tests/ut/backends/test_valkey.py", "aiocache/backends/valkey.py"]')})).optional().describe("Replaces what this check deliberately does not run, with the files only that part covers; [] clears it."),poolSize:r.z.number().int().min(1).max(8).optional().describe("Warm test worktrees in the pool."),runtimeKept:r.z.string().optional().describe('With environmentId: only when the user chose a runtime other than the lowest one the project declares, e.g. "python 3.12".')}),exports.TestsSchema=r.z.object({operation:r.z.enum(["list","setup","run","switch-off","switch-on"]),process:r.z.string().optional().describe("run, switch-off, switch-on: one test process by name or id (run: omit for all active ones)."),userSaid:r.z.string().max(600).optional().describe("switch-off / switch-on: the user's words asking for it, copied exactly."),name:r.z.string().optional().describe("run: one test command by name; omit for all required commands."),ask:r.z.string().max(1500).optional().describe("setup, required outside a request: what the user asked the check to run, in their words; the setup architect registers exactly that.")}),exports.ExecuteTestCommandSchema=r.z.object({processId:r.z.string().describe("Test process ID containing the command"),commandName:r.z.string().describe('Name of the test command to run, or "setup" to run all setup commands in sequence')}),exports.RunSchema=r.z.object({command:r.z.string().optional().describe("A shell command, run in the box (pass box or env)."),name:r.z.string().optional().describe("A saved command by name, instead of command."),box:r.z.string().optional().describe("An experiment handle from experiment_start."),env:r.z.string().optional().describe("Instead of box: an environment by name; its box is started (or your open one reused) and the result gives the handle."),size:r.z.enum(["light","standard","heavy"]).optional().describe("With env: the box size (see experiment_start)."),args:r.z.string().optional(),grep:r.z.string().optional().describe("Filter output through grep -i with this pattern."),timeout:r.z.number().optional().describe("Seconds."),why:r.z.string().optional().describe("One short sentence, shown on the approval card when the command needs the user's approval."),cwd:r.z.string().optional().describe('A subdirectory for an ad-hoc command (e.g. "apps/web"); a command starting with `cd` is refused in favour of this.')}),exports.CommandsSchema=r.z.object({operation:r.z.enum(["run","list","remove","register","setup"]).default("run").describe('list, register, remove or setup ("run" is the run tool\'s job). register suggests commands; prefer one general project-wide check over per-file variants.'),name:r.z.string().optional().describe("remove: the command name."),args:r.z.string().optional(),grep:r.z.string().optional(),command:r.z.string().optional(),timeout:r.z.number().optional(),cwd:r.z.string().optional(),context:r.z.string().optional().describe("setup: what you think the user needs, a hint for the architect."),commands:r.z.array(r.z.object({name:r.z.string().min(1).describe('e.g. "test:web"'),command:r.z.string().min(1),description:r.z.string().min(1).describe("What this command verifies."),cwd:r.z.string().optional().describe("Relative to the project root (monorepo subdirs); omit for the root."),timeout:r.z.number().optional().describe("Seconds (default 60).")})).optional().describe("register: the commands to suggest.")}),exports.ReportTestResultsSchema=r.z.object({status:r.z.enum(["passed","failed","error"]).describe("Overall result"),testRunId:r.z.string().optional().describe("The test run this verdict belongs to (given in your instructions). Strongly preferred: without it the latest run is guessed, which misattributes results when several testers run concurrently."),results:r.z.object({commands:r.z.array(r.z.object({name:r.z.string().describe("Command name"),status:r.z.enum(["passed","failed","skipped","error"]).describe("Command result"),output:r.z.string().optional().describe("Relevant output snippet"),diagnosis:r.z.string().optional().describe("Why it failed, if applicable")})).describe("Per-command results"),summary:r.z.string().describe("Brief overall summary"),acceptanceCriteria:r.z.array(r.z.object({criterion:r.z.string().describe("The acceptance criterion text"),status:r.z.enum(["verified","unverified","unclear"]),evidence:r.z.string().describe("How verified, or why not")})).optional().describe("AC verification results, if applicable"),faultClass:r.z.enum(["fail_code","fail_evidence","fail_environment","fail_process"]).optional().describe("On a FAILED verdict, WHY it failed so the gate routes to the right actor: 'fail_code' (the change is wrong), 'fail_evidence' (the run did not prove a criterion the coder could have proven: attach/adjust verify commands), or 'fail_environment' (a required tool/runtime is MISSING from the confined box, e.g. 'node: not found': the coder cannot fix this; the environment must be extended). Use 'fail_environment' ONLY when the evidence shows a command/runtime absent from the box, never for a genuine defect or a fixable evidence gap. 'fail_process' is for a test process whose OWN command names a file the repository does not have (a deleted script): nobody's code is wrong and extending the box cannot help; the process itself must be fixed or turned off."),missingCapabilities:r.z.array(r.z.string()).optional().describe("With faultClass 'fail_environment', the binaries/runtimes the box lacks (e.g. ['node']) so the environment can be extended to provide them.")}).describe("Structured test results")}).superRefine((e,t)=>{"fail_environment"!==e.results?.faultClass||e.results.missingCapabilities&&e.results.missingCapabilities.length>0||t.addIssue({code:r.z.ZodIssueCode.custom,path:["results","missingCapabilities"],message:"faultClass 'fail_environment' requires results.missingCapabilities: name the absent binaries/runtimes (the deterministic capability probe in your evidence lists them, e.g. ABSENT from the box: node). Without the names, the environment cannot be extended and the request strands."})})
5237
+ const v=r.z.string().min(1,"every option needs its consequence (description)").max(200,"an option's description is its consequence in one line: 200 characters at most").describe("Its consequence in one line: what picking it gets and what it costs."),k=r.z.string().min(1).max(120,"because is one clause: 120 characters at most")
5238
+ exports.OpeningBriefSectionSchema=r.z.object({id:r.z.string().min(1).describe('Stable id, unique within the brief (e.g. "date-format"). "testing-mode" is reserved for the server.'),question:r.z.string().min(1).describe("The choice, as one plain question the user can answer without your session."),context:r.z.string().min(1).describe("What the choice shapes, citing the request and its sources as they state them; where they answer the choice, recommend their answer."),options:r.z.array(r.z.object({id:r.z.string().min(1),label:r.z.string().min(1),description:v})).min(2).describe("At least two genuine alternatives."),default:r.z.string().min(1).describe("The option id you are proceeding on now: the card marks it recommended."),because:k.describe('Why your default, in one clause ("it matches the example in your notes").'),criteria:r.z.array(r.z.string().min(1)).optional().describe('Keys of the criteria whose wording this choice decides (e.g. ["2b"]), worded for your default. If the user picks another answer, each is marked for rewording and is not proven until reworded.')}).superRefine((e,t)=>{e.options.some(t=>t.id===e.default)||t.addIssue({code:r.z.ZodIssueCode.custom,path:["default"],message:`default '${e.default}' names no option in this section (option ids: ${e.options.map(e=>e.id).join(", ")})`}),"testing-mode"===e.id&&t.addIssue({code:r.z.ZodIssueCode.custom,path:["id"],message:"section id 'testing-mode' is reserved: the server composes the testing section when the project's gate needs it -- remove it from your sections"})}),exports.SessionMessageOperationsSchema=r.z.object({operation:r.z.enum(["send","note","reply","list","get","offer-handoff","record-decision","brief","withdraw"]),milestone:r.z.boolean().optional().describe("note: a real boundary (it works, the approach changed, the goal is met), a few per request at most; one quiet line in the user's stream."),withdrawReason:r.z.string().optional().describe("withdraw: why the answer is no longer needed."),type:r.z.enum(["question","report"]).optional().describe("Required for send."),toSessionId:r.z.string().optional().describe('Target session id, or "parent". Omit to ask the user (a broadcast).'),questionType:r.z.enum(["free-form","alternatives"]).optional().describe("Required for a question."),questionContent:r.z.object({question:r.z.string().min(1),context:r.z.preprocess(e=>null!==e&&"object"==typeof e?JSON.stringify(e):e,r.z.string().optional()).optional().describe("What the user needs to answer without your session: what you found and why it matters. No paths or identifiers; output you ask them to judge goes in a fenced code block, as printed."),options:r.z.array(r.z.object({id:r.z.string(),label:r.z.string(),description:v,recommended:r.z.boolean().optional().describe("Your advice, highlighted on the card; not what happens if nobody answers (that is defaultOption). Not on a question that names criteria. Never an option that makes up what the user has not given (estimated numbers, sample values, invented names): where it is missing, the way forward leaves it visibly empty or marked unknown."),because:r.z.preprocess(s,k.optional()).describe("With recommended (required there): why, in one clause."),effect:r.z.enum(["choose","send-back","not-yet"]).optional().describe('"choose" (default): records the pick for you. "send-back": asks for a change to the work; on a request waiting for the user\'s sign-off the pick itself sends it back to you (do not call reopen). "not-yet": only with [user-input] criteria; they stay owed.')})).optional().describe("Each a genuine alternative, complete in one tap (one needing a second answer is two options). Recommended option first. When the way the user asked cannot work, include one that reaches their goal another way."),allowMultiple:r.z.boolean().optional(),fields:r.z.array(r.z.object({id:r.z.string().min(1),label:r.z.string().min(1),placeholder:r.z.string().optional()})).min(1).optional().describe('free-form: one labelled input per value (a name, an email); the answer arrives as "Label: value" lines. Never ask for passwords or keys: answers are on the record.'),defaultOption:r.z.string().optional().describe("What happens if nobody answers before it expires (the option id, or the text for free-form); the asker then resumes. It happens without the user, so it must be safe: when options differ in risk (values silently changed, data loss, made-up data, anything hard to undo), the default is the safe one even if you recommend another, and the context says so."),onExpiry:r.z.enum(["assume-default","escalate"]).optional().describe('"assume-default" (default with a defaultOption): resolve to it and resume the asker. "escalate": leave it pending for the user (on Self-driving only priority "high" reaches them).'),steer:r.z.enum(["what","how"]).optional().describe('Tag every question: "what" shapes the work product (spec, wording, UX, scope); "how" steers the process (testing, sequencing, completion). Most "how" choices are yours to make, not to ask.'),changeableLater:r.z.boolean().optional().describe("true when the answer can be changed later without losing anything (nothing sent, deleted or published on it); the card then says so.")}).superRefine((e,t)=>{(e.options??[]).forEach((e,n)=>{!0!==e.recommended||e.because||t.addIssue({code:r.z.ZodIssueCode.custom,path:["options",n,"because"],message:`option '${e.id}' is recommended: say why in one clause (because)`})})}).optional().describe("Required for a question."),priority:r.z.enum(["low","normal","high"]).optional().describe('"high": blocked with real stakes; reaches the user at once, past the question gate. "low" with a defaultOption: under \'balanced\', batched to the next checkpoint (request review or plan handoff) without holding; you proceed on your default.'),expiresInHours:r.z.number().optional(),userSaid:r.z.string().min(8).max(600).optional().describe('question: when the user asked you to ask them (a card, options, "ask me first"), their words copied exactly. Checked against what they wrote; the question then reaches them whatever the Autonomy setting.'),replaces:r.z.array(r.z.string().regex(/^Q-[A-Za-z0-9]+-\d+$/)).max(10).optional().describe("question: codes of your open questions on the same request that this one supersedes; they close when it posts. With a question already open on the request, pass this or keepsOpen."),keepsOpen:r.z.boolean().optional().describe("question: true when this asks something different from your open questions on the request, so they stay open."),forceAsk:r.z.boolean().optional().describe("question: re-ask something the decision record already answers, only because circumstances changed; say what changed in questionContent.context."),status:r.z.enum(["success","partial","failure","blocked"]).optional().describe("Required for a report."),blockedOn:r.z.string().optional().describe('Required with status "blocked" on a request you own: "decision" (a question to your parent, escalating to the user) or a request id like "req000123" (declares a wait; you are told when it settles).'),criteria:r.z.array(r.z.string().min(1)).max(10).optional().describe('question: keys of the [user-input] criteria you ask for (e.g. ["1a"]); only such a question counts as asking them. It goes to the user with no default and no recommended option, and the answer is their proof unless the picked option is "not-yet". With a "not-yet" option you build with a placeholder meanwhile (Self-driving answers "not yet" at once); without one you wait for the answer at every Autonomy level. The user\'s check of finished work is asked on the card at the end, not here.'),attention:r.z.enum(["fyi","glance","act"]).optional().describe("'fyi' (logged, no badge), 'glance' (look soon), 'act' (the user must act). Default from status: failure/blocked act, partial glance, success fyi. It does not decide who is woken."),reportKind:r.z.enum(["milestone","reply"]).optional().describe("'milestone': narration at a boundary. 'reply': a reply to the user's inbox message."),summary:r.z.string().optional().describe("Required for a report. Outcome first, paths and identifiers in details. It shows alone in the stream, often hours later: name the subject first, never open with Also or Then. Reports to agents can be technical."),details:r.z.string().optional().describe("With blockedOn \"decision\" these become the question's context, and the user's card if your parent cannot decide: plain words, no tool names or call syntax; explain a refusal you got instead of pasting it."),ruleVerdicts:r.z.array(r.z.object({rule:r.z.string().min(1).max(80).describe("The rule id as your spawn prompt lists it, without brackets."),verdict:r.z.enum(["held","broken","not_applicable"]),note:r.z.string().max(300).optional().describe("broken: what breaks it and where (file:line). Omit otherwise.")})).max(40).optional().describe('report, Rules reviewer only: a verdict on every rule you were given. Only "broken" is a finding.'),finish:r.z.boolean().optional().describe("Release your request associations after the report."),silent:r.z.boolean().optional().describe("Record the report for the coordinator to drain without waking it (fan-out research workers)."),relatesTo:r.z.string().regex(/^[IQ]-[A-Za-z0-9]+-\d+$/,"relatesTo must be an instruction code (I-...) or question code (Q-...)").optional().describe("An instruction code (I-...) this relates to; for record-decision, a question code (Q-...) it resolves or supersedes."),decision:r.z.string().optional().describe("record-decision (required): the one-line call, recorded as the answer."),why:r.z.string().optional().describe("record-decision: the reasoning."),context:r.z.string().optional().describe("record-decision: what the choice was about, recorded as the question (defaults to decision)."),requestId:r.z.string().optional().describe('The request this is about (e.g. "req000007"), so it shows on that request. note: defaults to your session\'s request. report and record-decision: pass it when about one request, or it is filed only at the project. brief: required.'),area:r.z.string().optional().describe('record-decision: a work area (e.g. "graphics/opengl") when the call is about that area. Ignored if requestId is set.'),sections:r.z.array(exports.OpeningBriefSectionSchema).min(1).optional().describe("brief (required): your real design choices, each with at least two options, a default and context."),messageCode:r.z.string().optional().describe("Required for reply, get and withdraw."),spendCeiling:r.z.number().positive().max(1e5).optional().describe("reply 'build' on a Plan ready card: the spend limit the user named, in dollars at list price, with their words in quote. The plan pauses and asks when its spend passes it."),sectionAnswers:r.z.record(r.z.string(),r.z.string().nullable()).optional().describe("reply to an opening brief: { sectionId: optionId } for sections the user answered, changed or confirmed, with quote (their words); null when a section no longer applies; 'your-words' when no option says what they asked. Sections not named stay open. A changed choice acts on the work as it is now (finished work goes back to rework)."),quote:r.z.string().optional().describe("reply to a question: the user's words this answer records, copied exactly; it is then recorded as decided with the user, and refused if they never wrote them. Omit for your own decision. Options that are the user's own statement (\"I checked, it works\") only the user can pick."),text:r.z.string().optional().describe("reply: the answer to a free-form question. note (required): the note."),selectedOptions:r.z.array(r.z.string()).optional().describe("reply: the picked option ids."),notes:r.z.string().optional(),escalate:r.z.boolean().optional().describe("reply to a question asked of you that needs the user: a copy reaches the user with your recommendation (in notes); the asker gets their answer directly. A question with no options needs them: give the ways forward in questionContent.options. Not for broadcasts."),list:r.z.object({sessionId:r.z.string().optional().describe("Defaults to your session."),messageType:r.z.enum(["question","report","instruction","all"]).default("all"),direction:r.z.enum(["incoming","outgoing","all"]).default("all"),status:r.z.enum(["pending","answered","expired","success","partial","failure","blocked","all"]).default("all"),readStatus:r.z.enum(["unread","read","acknowledged","all"]).default("all"),requestId:r.z.string().optional().describe("Only messages about this request. Listing another session's inbox defaults to the request you are on."),limit:r.z.number().min(1).max(100).default(50),offset:r.z.number().min(0).default(0)}).optional(),offerHandoff:r.z.object({summary:r.z.string().describe('One sentence: what the plan builds. The card is already titled "Plan ready"; do not start with that.'),requestIds:r.z.array(r.z.string()).describe("Request ids created from the plan.")}).optional()}).refine(e=>"send"===e.operation?!!e.type:"note"===e.operation?"string"==typeof e.text&&e.text.trim().length>0:"reply"===e.operation?!!e.messageCode:"list"===e.operation||("get"===e.operation?!!e.messageCode:"offer-handoff"===e.operation||("record-decision"===e.operation?!!e.decision:"brief"===e.operation?!!e.requestId&&Array.isArray(e.sections)&&e.sections.length>0:"withdraw"===e.operation&&!!e.messageCode)),{message:"Invalid operation data: send requires type, note requires text, reply requires messageCode, get requires messageCode, record-decision requires decision, brief requires requestId and a non-empty sections array, withdraw requires messageCode"}),exports.CommitToViewedSessionSchema=r.z.object({message:r.z.coerce.string().min(1).describe("The cleaned-up user message to post to the viewed session. Fix obvious dictation errors, add punctuation, but preserve the user's intent exactly.")}),exports.DirectiveOperationsSchema=r.z.object({operation:r.z.enum(["set","list","search-decisions"]).describe("set = propose standing guidance in the user's words (they adopt it); list = list the project's guidance; search-decisions = free-text search the project's decision + annotation record (ask-the-history)"),targetType:r.z.enum(["project","area","request","you"]).optional().describe('set: what the guidance is addressed to. "you" = how the user works, in every project they have; "project" = the whole project; "area" = a work-area name (targetId); "request" = a specific request (targetId = its local id).'),targetId:r.z.string().optional().describe('set: the area name (for targetType "area") or request local id (for targetType "request"). Omit for project-wide guidance.'),body:r.z.string().max(2e3).optional().describe("set: the standing guidance itself: a preference that shapes future work in scope (required for set). Max 2000 chars."),note:r.z.string().optional().describe("set: optional short note about why this guidance exists."),userSaid:r.z.string().optional().describe("set (required): the user's own words stating this guidance, copied exactly from their message. The card quotes them; guidance the user did not state is proposed with guidance_propose instead."),revises:r.z.string().max(160).optional().describe('set: when the user\'s words change guidance that stands ("onion skins are fine now" against "no onions"), its key as list shows it (pr:...). Adopting then rewords that item in place; without it a second item is added beside the old one.'),status:r.z.string().optional().describe("list: optional status filter (active | dormant | archived)."),query:r.z.string().max(200).optional().describe("search-decisions: the search text, matched against recorded decisions (question + answer) and annotations (comment body + quoted text). Required for search-decisions."),limit:r.z.number().int().min(1).max(50).optional().describe("search-decisions: max matches per record type (default 10).")}),exports.McpConnectionsSchema=r.z.object({operation:r.z.enum(["list","propose"]).describe("list = the connections this project has; propose = register one, switched off, for the user to switch on."),name:r.z.string().optional().describe("propose: the connection name, lower case letters, digits and dashes. It becomes the tool prefix (name_tool)."),transport:r.z.enum(["repo","boxed","remote"]).optional().describe("propose: repo = a server in THIS repository, built from its Dockerfile and run in a confined box (the repository is mounted read-only at /work, /scratch is writable memory, the image ENTRYPOINT is what runs, rebuilt when its files change on main); boxed = a published npm package at an exact version, installed once and run in a box; remote = a hosted server reached by url."),dockerfile:r.z.string().optional().describe("propose repo: path of the Dockerfile inside the repository, e.g. mcp/server.Dockerfile."),context:r.z.string().optional().describe("propose repo: the docker build context directory inside the repository (default: the repository root)."),package:r.z.string().optional().describe("propose boxed: npm package with an exact version, e.g. @scope/server@1.2.3."),bin:r.z.string().optional().describe("propose boxed: the bin to run, the name under node_modules/.bin."),url:r.z.string().optional().describe("propose remote: the http(s) url."),environment:r.z.record(r.z.string()).optional().describe("propose: plain KEY=value configuration (headers for remote). Never put a secret here; name it in secretKeys instead."),secretKeys:r.z.array(r.z.string()).optional().describe("propose: names of environment variables (or headers) whose VALUES are secret. The user sets the values on the machine that runs the work; they never reach the database.")}),exports.AnswerQuestionSchema=r.z.object({messageCode:r.z.string().min(1).describe("The code in square brackets from <waiting_on_you>, e.g. Q-51209THD-005."),optionId:r.z.string().optional().describe("The id of the option the user picked, when the question has options."),text:r.z.string().optional().describe("The user's answer in their own words, cleaned up, when the question has no options or they said something the options do not cover.")})},19567(e,exports,t){exports.Server=exports.SSEServerTransport=exports.StdioServerTransport=void 0
5218
5239
  const r=t(66865)
5219
5240
  Object.defineProperty(exports,"Server",{enumerable:!0,get:function(){return r.Server}})
5220
5241
  const n=t(25802)
@@ -5655,7 +5676,7 @@ let a=n
5655
5676
  if(!this.isOffline())try{a=await this.projectClient.ensureProjectExists(n),a!==n&&this.logger.info("Project ID changed during verification",{requestedId:n,actualId:a}),this.logger.debug("Project verified on remote server",{projectId:a})}catch(e){this.logger.warn(`Failed to verify project ${n} on remote server`,{error:(0,i.getErrorMessage)(e)})}let c=[]
5656
5677
  Array.isArray(e.acceptanceCriteria)&&(c=r(e.acceptanceCriteria))
5657
5678
  const l={title:e.title,description:e.description,type:e.type,acceptanceCriteria:c,projectId:a}
5658
- if("status"in e&&e.status?l.status=e.status:l.status="open",Array.isArray(e.areas)&&e.areas.length>0&&(l.areas=e.areas),e.roundOf&&(l.roundOf=e.roundOf),e.originRequestId&&(l.originRequestId=e.originRequestId),Array.isArray(e.waitsOn)&&e.waitsOn.length>0&&(l.waitsOn=e.waitsOn),"string"==typeof e.process&&e.process.trim()&&(l.process=e.process.trim()),!0===e.startsNow&&(l.startsNow=!0),"string"==typeof e.replaces&&e.replaces.trim()&&(l.replaces=e.replaces.trim()),Array.isArray(e.asked)&&e.asked.length>0&&(l.asked=e.asked),Array.isArray(e.userChoices)&&e.userChoices.length>0&&(l.userChoices=e.userChoices),void 0!==e.exchangeKey&&(l.exchangeKey=e.exchangeKey),e.planDocumentId&&(l.planDocumentId=e.planDocumentId),e.scheduleDocumentId&&(l.scheduleDocumentId=e.scheduleDocumentId),"metadata"in e&&e.metadata?l.metadata=e.metadata:l.metadata={},e.cliOrigin&&(l.cliOrigin=e.cliOrigin),e.creatorSessionId&&(l.creatorSessionId=e.creatorSessionId),this.logger.info("Creating request",{title:e.title,type:e.type,projectId:a,criteriaCount:c.length}),this.authToken){const e={Authorization:`Bearer ${this.authToken}`}
5679
+ if("status"in e&&e.status?l.status=e.status:l.status="open",Array.isArray(e.areas)&&e.areas.length>0&&(l.areas=e.areas),e.roundOf&&(l.roundOf=e.roundOf),e.originRequestId&&(l.originRequestId=e.originRequestId),Array.isArray(e.waitsOn)&&e.waitsOn.length>0&&(l.waitsOn=e.waitsOn,"string"==typeof e.waitReason&&(l.waitReason=e.waitReason)),"string"==typeof e.process&&e.process.trim()&&(l.process=e.process.trim()),!0===e.startsNow&&(l.startsNow=!0),"string"==typeof e.replaces&&e.replaces.trim()&&(l.replaces=e.replaces.trim()),Array.isArray(e.asked)&&e.asked.length>0&&(l.asked=e.asked),Array.isArray(e.userChoices)&&e.userChoices.length>0&&(l.userChoices=e.userChoices),void 0!==e.exchangeKey&&(l.exchangeKey=e.exchangeKey),e.planDocumentId&&(l.planDocumentId=e.planDocumentId),e.scheduleDocumentId&&(l.scheduleDocumentId=e.scheduleDocumentId),"metadata"in e&&e.metadata?l.metadata=e.metadata:l.metadata={},e.cliOrigin&&(l.cliOrigin=e.cliOrigin),e.creatorSessionId&&(l.creatorSessionId=e.creatorSessionId),this.logger.info("Creating request",{title:e.title,type:e.type,projectId:a,criteriaCount:c.length}),this.authToken){const e={Authorization:`Bearer ${this.authToken}`}
5659
5680
  this.logger.debug("Auth header prepared for request creation",{tokenLength:this.authToken.length,tokenPrefix:this.authToken.substring(0,10)+"...",tokenSuffix:"..."+this.authToken.substring(this.authToken.length-10)})
5660
5681
  const r=await this.requestWithRetry("POST",`/api/projects/${a}/requests`,l,e),n=(0,s.safeGetResponseData)(r,{})
5661
5682
  if(!n||!n.id)throw this.logger.error("Received empty response data when creating request"),new Error("Failed to create request: Empty response data")
@@ -6112,7 +6133,10 @@ return`Not ${t}: ${1===e.length?"this criterion is":"these criteria are"} kind "
6112
6133
  for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t)|0
6113
6134
  return`${t+1}${String.fromCharCode(97+Math.abs(r)%26)}`}function r(e){return!(!e||e.standing&&e.waived)&&/\[(human|user)-input\]/i.test(String(e.description??""))}function n(e){const t=e?.proof??{},n=t.latest??{}
6114
6135
  if(r(e)){const t=n.you?.verdict
6115
- return"met"===t?"PROVEN:the user checked it":"unmet"===t?"FAILED:the user checked it and it does not work":"not-checked"===t?"NOT-CHECKED:accepted without the user under Self-driving":"dropped"===t?"DROPPED:the user dropped this check; it is not required":"withdrawn"===t?"THE-USER'S:they said it works on an earlier version and the work changed since, so the card at the end asks them again; do not judge it":"settles-unchecked"===e?.yourCheck?.atTheEnd?"THE-USER'S:their own check; if they do not answer, it settles at the end as not checked by them (Self-driving), never proof; do not judge it":"THE-USER'S:their own check, asked on the card at the end, and nothing merges past it; do not judge it"}return!0===e?.proven?"reviewer"===t.by?"PROVEN:review":"you"===t.by?"PROVEN:user-hand-check":"driver"===t.by?"PROVEN:drive":"PROVEN:test":"not-checked"===n.driver?.verdict?"NOT-CHECKED:drive":"answer"===t.reword?.from?`REWORD:${String(t.reword.note??"the answer it was written for changed").slice(0,300)}; reword it with request_operations update, its key and userSaid "${t.reword.ref}"`:t.notARealTest?"NOT-A-REAL-TEST":t.checkFails?"met"===n.reviewer?.verdict?"FAILED:test (review met, check fails)":"FAILED:test":t.disputed?`DISPUTED:its check passes, but the reviewer says it does not hold${t.disputed.note?` ("${String(t.disputed.note).slice(0,200)}")`:""}; strengthen the check so it tests what the criterion says, or fix the code`:"could-not-run"===n.instrument?.verdict?"COULD-NOT-RUN:test (its check could not run here; it says nothing either way)":"unmet"===n.reviewer?.verdict?"UNMET:review":!0===n.reviewer?.reword?"REWORD:a reviewer found its words no longer fit what was asked; reword it with the user's words, or ask them":"withdrawn"===n.reviewer?.verdict?"RE-REVIEW:its review was withdrawn (the work changed after it, or a new pass is due)":e?.coder?"ATTESTED":"UNPROVEN"}function o(e){const r=new Map
6136
+ return"met"===t?"PROVEN:the user checked it":"unmet"===t?"FAILED:the user checked it and it does not work":"not-checked"===t?"NOT-CHECKED:accepted without the user under Self-driving":"dropped"===t?"DROPPED:the user dropped this check; it is not required":"withdrawn"===t?"THE-USER'S:they said it works on an earlier version and the work changed since, so the card at the end asks them again; do not judge it":"settles-unchecked"===e?.yourCheck?.atTheEnd?"THE-USER'S:their own check; if they do not answer, it settles at the end as not checked by them (Self-driving), never proof; do not judge it":"THE-USER'S:their own check, asked on the card at the end, and nothing merges past it; do not judge it"}if(e?.baseline&&"object"==typeof e.baseline){const t=[...Array.isArray(e.ledger)?e.ledger:[]].reverse().find(e=>"verify"===e?.source&&"string"==typeof e?.instrument&&e.instrument.startsWith("baseline")),r="decided by its measurement only, never by a review or anyone's own timing"
6137
+ if(!t)return`NOT-MEASURED-YET:it is measured after the work is completed, on the work and on the version it started from; ${r}`
6138
+ const n=String(t.note??"").replace(/\s+/g," ").trim().slice(0,300)
6139
+ return`${"met"===t.verdict?"MEASURED-MET":"unmet"===t.verdict?"MEASURED-WORSE":"MEASURED"}:${n||"measured"}; ${r}`}return!0===e?.proven?"reviewer"===t.by?"PROVEN:review":"you"===t.by?"PROVEN:user-hand-check":"driver"===t.by?"PROVEN:drive":"PROVEN:test":"not-checked"===n.driver?.verdict?"NOT-CHECKED:drive":"answer"===t.reword?.from?`REWORD:${String(t.reword.note??"the answer it was written for changed").slice(0,300)}; reword it with request_operations update, its key and userSaid "${t.reword.ref}"`:t.notARealTest?"NOT-A-REAL-TEST":t.checkFails?"met"===n.reviewer?.verdict?"FAILED:test (review met, check fails)":"FAILED:test":t.disputed?`DISPUTED:its check passes, but the reviewer says it does not hold${t.disputed.note?` ("${String(t.disputed.note).slice(0,200)}")`:""}; strengthen the check so it tests what the criterion says, or fix the code`:"could-not-run"===n.instrument?.verdict?"COULD-NOT-RUN:test (its check could not run here; it says nothing either way)":"unmet"===n.reviewer?.verdict?"UNMET:review":!0===n.reviewer?.reword?"REWORD:a reviewer found its words no longer fit what was asked; reword it with the user's words, or ask them":"withdrawn"===n.reviewer?.verdict?"RE-REVIEW:its review was withdrawn (the work changed after it, or a new pass is due)":e?.coder?"ATTESTED":"UNPROVEN"}function o(e){const r=new Map
6116
6140
  for(let n=0;n<e.length;n++){const o=t(e[n].id,n)
6117
6141
  r.set(o,e[n])}return r}function s(e){if(0===e.length)return"No acceptance criteria defined."
6118
6142
  const t=o(e),r=[]
@@ -7039,7 +7063,19 @@ continue}if(t.startsWith("+++ ")){o=t.slice(4).replace(/^b\//,"")
7039
7063
  continue}if(t.startsWith("--- "))continue
7040
7064
  const e=/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(t)
7041
7065
  e?(c(),s=Number(e[1])):t.startsWith("-")?(a.length&&c(),i.push(t.slice(1))):t.startsWith("+")?(a.push({text:t.slice(1),line:s}),s++):(c(),t.startsWith(" ")&&s++)}return c(),n},exports.q=150
7042
- const t=e=>e.length>160?`${e.slice(0,160)}...`:e},13922(e,exports,t){async function r(e){const t=`requests/${e.requestId}`
7066
+ const t=e=>e.length>160?`${e.slice(0,160)}...`:e},82865(e,exports,t){function r(e,t){return new Promise(r=>{(0,o.execFile)("git",t,{cwd:e,maxBuffer:8388608},(e,t)=>{const n=e&&"number"==typeof e.code?e.code:e?1:0
7067
+ r({code:n,stdout:String(t??"")})})})}function n(e){const t=e.trim(),r=/^Merge (?:branch '|)requests\/(req\d{6})(?:'|)(?:-(.*))?$/.exec(t)
7068
+ return r?{requestId:r[1],title:(r[2]??"").trim()}:{requestId:null,title:t}}exports.landedOnTopOf=async function(e,t,o){if(!s.test(t))return[]
7069
+ const[,i,a]=(await r(e,["rev-list","--parents","-n","1",t])).stdout.trim().split(/\s+/)
7070
+ if(!(i&&a&&s.test(i)&&s.test(a)))return[]
7071
+ const c=(await r(e,["rev-list","--first-parent",a,`^${i}`])).stdout.trim().split("\n").filter(Boolean)
7072
+ if(0===c.length)return[]
7073
+ const l=(await r(e,["rev-parse","--verify","--quiet",`${c[c.length-1]}^1`])).stdout.trim()
7074
+ if(!s.test(l))return[]
7075
+ const d=await r(e,["log","--first-parent","--format=%s","-n","50",i,`^${l}`]),u=[]
7076
+ for(const e of d.stdout.split("\n").map(e=>e.trim()).filter(Boolean)){const t=n(e).requestId
7077
+ t&&t!==o&&!u.includes(t)&&u.push(t)}return u}
7078
+ const o=t(35317),s=(t(29418),t(82860),/^[0-9a-f]{40}$/)},13922(e,exports,t){async function r(e){const t=`requests/${e.requestId}`
7043
7079
  try{if(0===await function(e,t,r){return new Promise(o=>{(0,n.execFile)("git",["rev-list","--count",`${t}..${r}`],{cwd:e},(e,t)=>{o(e?0:Number(String(t).trim())||0)})})}(e.projectPath,t,e.defaultBranch))return null
7044
7080
  const r=await(0,o.reconcileBranchWithMain)({projectPath:e.projectPath,requestId:e.requestId,branchName:t,defaultBranch:e.defaultBranch})
7045
7081
  return e.logger.info("held landing: main brought into the branch",{requestId:e.requestId,outcome:r.outcome}),"clean"===r.outcome?await function(e,t){return new Promise(r=>{(0,n.execFile)("git",["rev-parse","--verify","--quiet",t],{cwd:e},(e,t)=>{const n=String(t??"").trim()
@@ -7119,15 +7155,15 @@ return await c.raw(["commit","--no-edit","-m",`Merge ${s} into ${o} (additive co
7119
7155
  const{note:l}=await(0,m.holdBackStagedCredentials)(a)
7120
7156
  return await c.raw(["commit","--no-edit","-m",`Merge ${s} into ${o} (${g.MARKER_MERGE_SUBJECT})${l?`\n\n${l}`:""}`]),{outcome:"conflicts-committed",conflictedFiles:t,landed:d}}catch(e){try{await c.merge(["--abort"])}catch{}return{outcome:"error",conflictedFiles:[],landed:d,error:String(e)}}}},exports.buildResolveInstruction=function(e){const{requestId:t,branchName:r,defaultBranch:n,landed:o,conflictedFiles:s,retryVia:i}=e,a=e.cause??{kind:"signoff"},c="sibling-merged"===a.kind?`${a.mergedRequestId} just merged into ${n}, and ${t} conflicts with it.`:"reached-signoff"===a.kind?`${t} reached sign-off, but ${n} moved since you branched.`:`The user signed off ${t}, but ${n} moved since you branched.`,l="complete"===i?"Resolve every marker block with your file tools so BOTH sides' intent holds (your change AND what landed above; intent, not text: when both sides carry the same function or declaration, keep ONE merged copy, never both), remove all markers, verify with the project's build/tests, then run request_operations complete again so the user can sign off a clean merge. That summary replaces your earlier one: describe everything the request delivers, not the conflict resolution, and pass replacesSummary: true.":`Resolve every marker block with your file tools so BOTH sides' intent holds (your change AND what landed above; intent, not text: when both sides carry the same function or declaration, keep ONE merged copy, never both), remove all markers, verify with the project's build/tests, then run the merge operation again \u2014 with ${n} already merged into your branch it will be conflict-free.`
7121
7157
  return["complete"===i?`[merge-conflict] ${c} The system merged ${n} into ${r} and COMMITTED the conflicted state: the files below contain <<<<<<< / ======= / >>>>>>> markers as plain content.`:`Merging ${r} into ${n} hit conflicts \u2014 ${n} moved since you branched. The system merged ${n} into your branch and COMMITTED the conflicted state: the files below contain <<<<<<< / ======= / >>>>>>> markers as plain content.`,o.length>0?`\nWhat landed on ${n} since you branched (honor THEIR intent, not just their text):\n${o.map(e=>`- ${e}`).join("\n")}\n`:"",`Conflicted files: ${s.join(", ")||"(see markers)"}`,l].filter(Boolean).join("\n")},exports.nearDuplicateInsertion=s,exports.resolveAdditiveConflicts=i
7122
- const u=t(75453),h=t(83807),p=d(t(16928)),f=d(t(79896)),m=t(96511),g=t(82860),y=t(66485)},87192(e,exports,t){function r(e,t,r={}){return new Promise(n=>{(0,h.execFile)(r.gitBinary||"git",t,{cwd:e,env:{...process.env,...r.env||{}},maxBuffer:16777216},(e,t,r)=>{n({code:e?"number"==typeof e.code?e.code:1:0,stdout:String(t??""),stderr:String(r??"")})})})}async function n(e,t,n){const o=await r(e,["rev-parse","--verify","--quiet",t],{gitBinary:n})
7123
- return 0===o.code?o.stdout.trim():null}function o(e){return`refs/alchemy/merge-candidates/${e.replace(/[^a-zA-Z0-9_-]/g,"_")}`}async function s(e,t,r){return n(e,o(t),r)}async function i(e,t,r){return n(e,`${t}^{tree}`,r)}var a,c=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r)
7158
+ const u=t(75453),h=t(83807),p=d(t(16928)),f=d(t(79896)),m=t(96511),g=t(82860),y=t(66485)},87192(e,exports,t){function r(e,t,r={}){return new Promise(n=>{(0,p.execFile)(r.gitBinary||"git",t,{cwd:e,env:{...process.env,...r.env||{}},maxBuffer:16777216},(e,t,r)=>{n({code:e?"number"==typeof e.code?e.code:1:0,stdout:String(t??""),stderr:String(r??"")})})})}async function n(e,t,n){const o=await r(e,["rev-parse","--verify","--quiet",t],{gitBinary:n})
7159
+ return 0===o.code?o.stdout.trim():null}function o(e){return`refs/alchemy/merge-candidates/${e.replace(/[^a-zA-Z0-9_-]/g,"_")}`}async function s(e,t,r){return n(e,o(t),r)}async function i(e,t,r){return n(e,`${t}^{tree}`,r)}function a(e){return!(!e||"failed"!==e.status&&"error"!==e.status)&&"fail_main"===(e.faultClass??e.results?.faultClass)}var c,l=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r)
7124
7160
  var o=Object.getOwnPropertyDescriptor(t,r)
7125
- o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),l=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),d=this&&this.__importStar||(a=function(e){return a=Object.getOwnPropertyNames||function(e){var t=[]
7161
+ o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),d=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),u=this&&this.__importStar||(c=function(e){return c=Object.getOwnPropertyNames||function(e){var t=[]
7126
7162
  for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r)
7127
- return t},a(e)},function(e){if(e&&e.__esModule)return e
7163
+ return t},c(e)},function(e){if(e&&e.__esModule)return e
7128
7164
  var t={}
7129
- if(null!=e)for(var r=a(e),n=0;n<r.length;n++)"default"!==r[n]&&c(t,e,r[n])
7130
- return l(t,e),t})
7165
+ if(null!=e)for(var r=c(e),n=0;n<r.length;n++)"default"!==r[n]&&l(t,e,r[n])
7166
+ return d(t,e),t})
7131
7167
  Object.defineProperty(exports,"__esModule",{value:!0}),exports.dirtyTrackedFiles=async function(e,t){const n=await r(e,["status","--porcelain","--untracked-files=no"],{gitBinary:t})
7132
7168
  return 0!==n.code?[]:n.stdout.split("\n").map(e=>e.trimEnd()).filter(Boolean).map(e=>e.slice(3).trim()).filter(Boolean)},exports.assessMergeFreshness=async function(e,t,o,s){const i=await n(e,t,s),a=await n(e,o,s)
7133
7169
  if(!i)throw new Error(`assessMergeFreshness: cannot resolve ${t}`)
@@ -7138,30 +7174,30 @@ const l=c.stdout.trim()
7138
7174
  return{fresh:l===i,mainHead:i,branchTip:a,mergeBase:l}},exports.mergeCandidateRef=o,exports.readMergeCandidateRef=s,exports.clearMergeCandidate=async function(e,t,n){await r(e,["update-ref","-d",o(t)],{gitBinary:n})},exports.buildProspectiveMergeCommit=async function(e,t){const{defaultBranch:i,branchName:a,requestId:c,requestTitle:l,gitBinary:d}=t
7139
7175
  try{const t=await n(e,i,d),u=await n(e,a,d)
7140
7176
  if(!t||!u)return{ok:!1,reason:"error",error:`cannot resolve ${t?a:i}`}
7141
- const h=l?`Merge ${a}-${l}`:`Merge ${a}`,m=await async function(e,t,n){const o=await r(e,["log","-1","--format=%cI",t],{gitBinary:n}),s=0===o.code&&o.stdout.trim()?o.stdout.trim():"2000-01-01T00:00:00+00:00"
7142
- return{GIT_AUTHOR_NAME:g,GIT_AUTHOR_EMAIL:y,GIT_COMMITTER_NAME:g,GIT_COMMITTER_EMAIL:y,GIT_AUTHOR_DATE:s,GIT_COMMITTER_DATE:s}}(e,u,d)
7143
- let w=null
7177
+ const h=l?`Merge ${a}-${l}`:`Merge ${a}`,p=await async function(e,t,n){const o=await r(e,["log","-1","--format=%cI",t],{gitBinary:n}),s=0===o.code&&o.stdout.trim()?o.stdout.trim():"2000-01-01T00:00:00+00:00"
7178
+ return{GIT_AUTHOR_NAME:y,GIT_AUTHOR_EMAIL:w,GIT_COMMITTER_NAME:y,GIT_COMMITTER_EMAIL:w,GIT_AUTHOR_DATE:s,GIT_COMMITTER_DATE:s}}(e,u,d)
7179
+ let g=null
7144
7180
  const b=await r(e,["merge-tree","--write-tree",t,u],{gitBinary:d})
7145
- if(0!==b.code)return 1===b.code&&b.stdout.trim()?{ok:!1,reason:"conflicts",conflictSummary:b.stdout.split("\n").filter(e=>/CONFLICT|conflict/.test(e)).slice(0,10).join("\n")||"content conflicts detected by merge-tree"}:/unknown option|usage: git merge-tree/i.test(b.stderr)?await async function(e,t){const{mainHead:i,branchTip:a,message:c,env:l,requestId:d,gitBinary:u}=t,h=p.join(e,f.ALCHEMY_DIR_NAME,"merge-candidates",`wt-${process.pid}-${Date.now()}`),m=await r(e,["worktree","add","--detach",h,i],{gitBinary:u})
7146
- if(0!==m.code)return{ok:!1,reason:"error",error:`temp worktree add failed: ${m.stderr.trim().slice(0,400)}`}
7181
+ if(0!==b.code)return 1===b.code&&b.stdout.trim()?{ok:!1,reason:"conflicts",conflictSummary:b.stdout.split("\n").filter(e=>/CONFLICT|conflict/.test(e)).slice(0,10).join("\n")||"content conflicts detected by merge-tree"}:/unknown option|usage: git merge-tree/i.test(b.stderr)?await async function(e,t){const{mainHead:i,branchTip:a,message:c,env:l,requestId:d,gitBinary:u}=t,h=f.join(e,m.ALCHEMY_DIR_NAME,"merge-candidates",`wt-${process.pid}-${Date.now()}`),p=await r(e,["worktree","add","--detach",h,i],{gitBinary:u})
7182
+ if(0!==p.code)return{ok:!1,reason:"error",error:`temp worktree add failed: ${p.stderr.trim().slice(0,400)}`}
7147
7183
  try{const t=await r(h,["merge","--no-ff","-m",c,a],{env:l,gitBinary:u})
7148
7184
  if(0!==t.code){const e=await r(h,["diff","--name-only","--diff-filter=U"],{gitBinary:u})
7149
7185
  return await r(h,["merge","--abort"],{gitBinary:u}),{ok:!1,reason:"conflicts",conflictSummary:e.stdout.trim()||t.stdout.trim().slice(0,400)}}const p=await n(h,"HEAD",u)
7150
7186
  if(!p)return{ok:!1,reason:"error",error:"temp worktree merge produced no HEAD"}
7151
7187
  const f=await n(h,"HEAD^{tree}",u),m=await s(e,d,u)
7152
- return await r(e,["update-ref",o(d),p],{gitBinary:u}),{ok:!0,mergeCommitSha:p,treeSha:f||"",mainHead:i,branchTip:a,adopted:m===p}}finally{await r(e,["worktree","remove","--force",h],{gitBinary:u})}}(e,{mainHead:t,branchTip:u,message:h,env:m,requestId:c,gitBinary:d}):{ok:!1,reason:"error",error:`merge-tree failed (${b.code}): ${(b.stderr||b.stdout).trim().slice(0,400)}`}
7153
- if(w=b.stdout.trim().split("\n")[0]?.trim()||null,!w)return{ok:!1,reason:"error",error:"merge-tree returned no tree oid"}
7154
- const v=await r(e,["commit-tree",w,"-p",t,"-p",u,"-m",h],{env:m,gitBinary:d})
7188
+ return await r(e,["update-ref",o(d),p],{gitBinary:u}),{ok:!0,mergeCommitSha:p,treeSha:f||"",mainHead:i,branchTip:a,adopted:m===p}}finally{await r(e,["worktree","remove","--force",h],{gitBinary:u})}}(e,{mainHead:t,branchTip:u,message:h,env:p,requestId:c,gitBinary:d}):{ok:!1,reason:"error",error:`merge-tree failed (${b.code}): ${(b.stderr||b.stdout).trim().slice(0,400)}`}
7189
+ if(g=b.stdout.trim().split("\n")[0]?.trim()||null,!g)return{ok:!1,reason:"error",error:"merge-tree returned no tree oid"}
7190
+ const v=await r(e,["commit-tree",g,"-p",t,"-p",u,"-m",h],{env:p,gitBinary:d})
7155
7191
  if(0!==v.code)return{ok:!1,reason:"error",error:`commit-tree failed: ${v.stderr.trim().slice(0,400)}`}
7156
7192
  const k=v.stdout.trim(),I=await s(e,c,d),$=await r(e,["update-ref",o(c),k],{gitBinary:d})
7157
- return 0!==$.code?{ok:!1,reason:"error",error:`update-ref failed: ${$.stderr.trim().slice(0,400)}`}:{ok:!0,mergeCommitSha:k,treeSha:w,mainHead:t,branchTip:u,adopted:I===k}}catch(e){return{ok:!1,reason:"error",error:String(e?.message??e)}}},exports.landCertifiedMerge=async function(e,t){const{defaultBranch:r,mergeCommitSha:o,gitBinary:s}=t,i=await n(e,`${o}^1`,s),a=await n(e,r,s)
7193
+ return 0!==$.code?{ok:!1,reason:"error",error:`update-ref failed: ${$.stderr.trim().slice(0,400)}`}:{ok:!0,mergeCommitSha:k,treeSha:g,mainHead:t,branchTip:u,adopted:I===k}}catch(e){return{ok:!1,reason:"error",error:String(e?.message??e)}}},exports.landCertifiedMerge=async function(e,t){const{defaultBranch:r,mergeCommitSha:o,gitBinary:s}=t,i=await n(e,`${o}^1`,s),a=await n(e,r,s)
7158
7194
  if(!i||!a)return{landed:!1,reason:"cannot resolve candidate parent or default branch head"}
7159
7195
  if(i!==a)return{landed:!1,reason:`default branch moved since certification (${a.slice(0,8)} != candidate base ${i.slice(0,8)})`,refusal:"moved"}
7160
- const c=await(0,m.landOnDefaultBranch)(e,{defaultBranch:r,commitSha:o,expectedHead:a,gitBinary:s})
7196
+ const c=await(0,g.landOnDefaultBranch)(e,{defaultBranch:r,commitSha:o,expectedHead:a,gitBinary:s})
7161
7197
  return c.landed?{landed:!0,mergeCommitSha:o}:{landed:!1,reason:c.message,refusal:c.reason,files:c.files}},exports.deriveMergeChangedPaths=async function(e,t,n,o){const s=await r(e,["diff","--name-only",`${t}..${n}`],{gitBinary:o})
7162
7198
  return 0!==s.code?null:s.stdout.split("\n").map(e=>e.trim()).filter(Boolean)},exports.resolveTreeSha=i,exports.filterRunsCertifyingTree=async function(e,t,r,n){const o=new Map,s=[]
7163
7199
  for(const a of t){const t=a.commitSha
7164
- t&&(o.has(t)||o.set(t,await i(e,t,n)),o.get(t)===r&&s.push(a))}return s},exports.envMissingCapabilities=function(e){const t=new Set
7200
+ t&&(o.has(t)||o.set(t,await i(e,t,n)),o.get(t)===r&&s.push(a))}return s},exports.failsOnlyOnMain=a,exports.envMissingCapabilities=function(e){const t=new Set
7165
7201
  for(const r of e){const e=r.faultClass??r.results?.faultClass
7166
7202
  if(("failed"===r.status||"error"===r.status)&&"fail_environment"===e){const e=r.results?.missingCapabilities
7167
7203
  if(Array.isArray(e))for(const r of e)"string"==typeof r&&t.add(r)}}return[...t]},exports.scopeSkippedProcessIds=function(e){const t=new Map,r=e=>{const t=e.createdAt?new Date(e.createdAt).getTime():NaN
@@ -7180,16 +7216,16 @@ return n},exports.evaluateRunsAtHead=function(e,t,r){if(0===t.length)return"cert
7180
7216
  if(0===e.length)return"none"
7181
7217
  const n=e=>{const t=e.createdAt?new Date(e.createdAt).getTime():NaN
7182
7218
  return Number.isFinite(t)?t:0},o=e=>{const t=r?.get(e.testProcessId??"")
7183
- return!(!t||t===u.EMPTY_FINGERPRINT||!0===e.results?.scopeVerifyOnly||"passed"!==e.status&&"string"!=typeof e.executedFingerprint||e.executedFingerprint===t)}
7184
- let s=!1,i=!1,a=!1,c=!1
7185
- for(const r of t){const t=e.filter(e=>e.testProcessId===r).sort((e,t)=>n(e)-n(t)),l=t[t.length-1]
7186
- if(!l){a=!0
7187
- continue}if("skipped"===l.status&&!0===l.results?.scopeSkipped)continue
7188
- if(("passed"===l.status||"failed"===l.status||"error"===l.status||"skipped"===l.status)&&o(l)){a=!0
7189
- continue}if("passed"===l.status)continue
7190
- const d=l.faultClass??l.results?.faultClass
7191
- "failed"!==l.status&&"error"!==l.status||"fail_environment"!==d?"failed"!==l.status&&"error"!==l.status&&"skipped"!==l.status?i=!0:s=!0:c=!0}return s?"failed":i?"pending":c?"env":a?"none":"certified"}
7192
- const u=t(74146),h=t(35317),p=d(t(16928)),f=t(14139),m=t(75453),g="AlchemyLab Merge Queue",y="merge-queue@alchemylab.local"},56509(e,exports,t){function r(e){return p.join(e,f.ALCHEMY_DIR_NAME,"merge-lease.json")}function n(e){try{const t=u.readFileSync(r(e),"utf8"),n=JSON.parse(t)
7219
+ return!(!t||t===h.EMPTY_FINGERPRINT||!0===e.results?.scopeVerifyOnly||"passed"!==e.status&&"string"!=typeof e.executedFingerprint||e.executedFingerprint===t)}
7220
+ let s=!1,i=!1,c=!1,l=!1
7221
+ for(const r of t){const t=e.filter(e=>e.testProcessId===r).sort((e,t)=>n(e)-n(t)),d=t[t.length-1]
7222
+ if(!d){c=!0
7223
+ continue}if("skipped"===d.status&&!0===d.results?.scopeSkipped)continue
7224
+ if(("passed"===d.status||"failed"===d.status||"error"===d.status||"skipped"===d.status)&&o(d)){c=!0
7225
+ continue}if("passed"===d.status||a(d))continue
7226
+ const u=d.faultClass??d.results?.faultClass
7227
+ "failed"!==d.status&&"error"!==d.status||"fail_environment"!==u?"failed"!==d.status&&"error"!==d.status&&"skipped"!==d.status?i=!0:s=!0:l=!0}return s?"failed":i?"pending":l?"env":c?"none":"certified"}
7228
+ const h=t(74146),p=t(35317),f=u(t(16928)),m=t(14139),g=t(75453),y="AlchemyLab Merge Queue",w="merge-queue@alchemylab.local"},56509(e,exports,t){function r(e){return p.join(e,f.ALCHEMY_DIR_NAME,"merge-lease.json")}function n(e){try{const t=u.readFileSync(r(e),"utf8"),n=JSON.parse(t)
7193
7229
  return n&&"string"==typeof n.requestId?n:null}catch{return null}}function o(e,t=Date.now()){const r=Date.parse(e.expiresAt)
7194
7230
  return!!(Number.isFinite(r)&&t>r)||"merging"===e.phase&&e.holder?.hostname===h.hostname()&&"number"==typeof e.holder?.pid&&!function(e){try{return process.kill(e,0),!0}catch(e){return"EPERM"===e?.code}}(e.holder.pid)}function s(e,t,r,n){const o=new Date
7195
7231
  return{requestId:e,holder:{pid:process.pid,hostname:h.hostname(),source:t},phase:n?.phase??"merging",acquiredAt:n?.acquiredAt??o.toISOString(),renewedAt:o.toISOString(),ttlMs:r,expiresAt:new Date(o.getTime()+r).toISOString(),...n?.catchup?{catchup:n.catchup}:{}}}function i(e,t){const n=r(e)
@@ -7219,40 +7255,46 @@ if(o&&o.requestId!==t)return!1
7219
7255
  try{return u.unlinkSync(s),!0}catch{return!1}}
7220
7256
  const u=d(t(79896)),h=d(t(70857)),p=d(t(16928)),f=t(14139)
7221
7257
  exports.MERGE_LEASE_DEFAULT_TTL_MS=6e5,exports.MERGE_LEASE_CATCHUP_TTL_MS=36e5,exports.MERGE_LEASE_LAND_GRACE_TTL_MS=9e5
7222
- const m=e=>new Promise(t=>setTimeout(t,e))},14128(e,exports,t){async function r(e,t){let r,s
7223
- try{[r,s]=await Promise.all([e.fetchRequestRuns(),e.fetchActiveProcesses()])}catch(t){return e.logger.warn("merge-queue: could not read runs/processes for certification; treating as not yet dispatched",{requestId:e.requestId,error:String(t?.message??t)}),{state:"none",missingCapabilities:[],failedChecks:[]}}const a=await(0,i.filterRunsCertifyingTree)(e.projectPath,r||[],t,e.gitBinary),c=(s||[]).filter(e=>e&&"string"==typeof e.id),l=(0,i.evaluateRunsAtHead)(a,c.map(e=>e.id),(0,o.requiredFingerprints)(c,e.criteria,(0,i.scopeSkippedProcessIds)(a),(0,i.verifyOnlyProcessIds)(a)))
7224
- return{state:l,missingCapabilities:"env"===l?(0,i.envMissingCapabilities)(a):[],failedChecks:"failed"===l?n(a,c):[]}}function n(e,t){const r=e=>{const t=e.createdAt?new Date(e.createdAt).getTime():NaN
7225
- return Number.isFinite(t)?t:0},n=[]
7226
- for(const o of t){const t=e.filter(e=>e.testProcessId===o.id).sort((e,t)=>r(e)-r(t)).pop()
7227
- !t||"failed"!==t.status&&"error"!==t.status||"fail_environment"!==(t.faultClass??t.results?.faultClass)&&n.push(String(o.name??"").trim()||"a check")}return n}exports.runMergeQueueGate=async function(e){const{projectPath:t,requestId:n,branchName:o,defaultBranch:a,requestTitle:c,source:l,gitBinary:d,logger:u}=e,h=await(0,s.acquireMergeLease)(t,n,{source:l,waitMs:15e3})
7228
- if(!h.acquired)return{action:"wait-slot",holder:h.holder}
7229
- try{const l=await(0,i.assessMergeFreshness)(t,a,o,d),h=l.fresh
7230
- let p,f
7231
- if(h){const e=await(0,i.resolveTreeSha)(t,l.branchTip,d)
7232
- if(!e)return{action:"error",message:`cannot resolve the tree of ${o}'s tip`}
7233
- p=l.branchTip,f=e,(0,i.clearMergeCandidate)(t,n,d).catch(()=>{})}else{const e=await(0,i.buildProspectiveMergeCommit)(t,{defaultBranch:a,branchName:o,requestId:n,requestTitle:c,gitBinary:d})
7258
+ const m=e=>new Promise(t=>setTimeout(t,e))},14128(e,exports,t){async function r(e,t){let r,n
7259
+ try{[r,n]=await Promise.all([e.fetchRequestRuns(),e.fetchActiveProcesses()])}catch(t){return e.logger.warn("merge-queue: could not read runs/processes for certification; treating as not yet dispatched",{requestId:e.requestId,error:String(t?.message??t)}),{state:"none",missingCapabilities:[],failedChecks:[],failedProcessIds:[],runs:[]}}const i=await(0,a.filterRunsCertifyingTree)(e.projectPath,r||[],t,e.gitBinary),c=(n||[]).filter(e=>e&&"string"==typeof e.id),l=(0,a.evaluateRunsAtHead)(i,c.map(e=>e.id),(0,s.requiredFingerprints)(c,e.criteria,(0,a.scopeSkippedProcessIds)(i),(0,a.verifyOnlyProcessIds)(i))),d="failed"===l?function(e,t){const r=[]
7260
+ for(const n of t){const t=o(e.filter(e=>e.testProcessId===n.id))
7261
+ if(!t||"failed"!==t.status&&"error"!==t.status)continue
7262
+ const s=t.faultClass??t.results?.faultClass
7263
+ "fail_environment"!==s&&"fail_main"!==s&&r.push(n)}return r}(i,c):[]
7264
+ return{state:l,missingCapabilities:"env"===l?(0,a.envMissingCapabilities)(i):[],failedChecks:d.map(e=>String(e.name??"").trim()||"a check"),failedProcessIds:d.map(e=>e.id),runs:r||[]}}async function n(e,t,r,n,s){let i=!1
7265
+ if(!n&&t.failedProcessIds.length>0){const r=await(0,a.resolveTreeSha)(e.projectPath,s,e.gitBinary).catch(()=>null)
7266
+ if(r){const n=await(0,a.filterRunsCertifyingTree)(e.projectPath,t.runs,r,e.gitBinary)
7267
+ i=t.failedProcessIds.every(e=>"passed"===o(n.filter(t=>t.testProcessId===e))?.status)}}return{action:"catchup-failed",mergeCommitSha:r,failedChecks:t.failedChecks,mainMergedIn:!n,passedOnWork:i}}function o(e){const t=e=>{const t=e.createdAt?new Date(e.createdAt).getTime():NaN
7268
+ return Number.isFinite(t)?t:0}
7269
+ return[...e].sort((e,r)=>t(e)-t(r)).pop()}exports.runMergeQueueGate=async function(e){const{projectPath:t,requestId:o,branchName:s,defaultBranch:c,requestTitle:l,source:d,gitBinary:u,logger:h}=e,p=await(0,i.acquireMergeLease)(t,o,{source:d,waitMs:e.leaseWaitMs??15e3})
7270
+ if(!p.acquired)return{action:"wait-slot",holder:p.holder}
7271
+ try{const d=await(0,a.assessMergeFreshness)(t,c,s,u),p=d.fresh
7272
+ let f,m
7273
+ if(p){const e=await(0,a.resolveTreeSha)(t,d.branchTip,u)
7274
+ if(!e)return{action:"error",message:`cannot resolve the tree of ${s}'s tip`}
7275
+ f=d.branchTip,m=e,(0,a.clearMergeCandidate)(t,o,u).catch(()=>{})}else{const e=await(0,a.buildProspectiveMergeCommit)(t,{defaultBranch:c,branchName:s,requestId:o,requestTitle:l,gitBinary:u})
7234
7276
  if(!e.ok)return"conflicts"===e.reason?{action:"conflicts",summary:e.conflictSummary}:{action:"error",message:e.error}
7235
- if(p=e.mergeCommitSha,f=e.treeSha||await(0,i.resolveTreeSha)(t,e.mergeCommitSha,d)||"",!f)return{action:"error",message:"cannot resolve the candidate merge tree"}}const m=async t=>await async function(e,t){if(!e.evaluateMainChange)return null
7277
+ if(f=e.mergeCommitSha,m=e.treeSha||await(0,a.resolveTreeSha)(t,e.mergeCommitSha,u)||"",!m)return{action:"error",message:"cannot resolve the candidate merge tree"}}const g=async t=>await async function(e,t){if(!e.evaluateMainChange)return null
7236
7278
  try{const r=await e.evaluateMainChange({landingSha:t})
7237
- return r?.hold?r.sentBack||!r.touched?(e.logger.info("merge held: main's newer work broke a criterion check on the landing tree; back to its worker",{requestId:e.requestId}),{action:"sent-back",summary:r.summary}):(e.logger.info("merge held: a review of main's change goes first",{requestId:e.requestId}),{action:"review-held",summary:r.summary,touched:r.touched}):null}catch(t){return e.logger.warn("main-change evaluation failed; merge continues (it is an observer, not a lock)",{requestId:e.requestId,error:t instanceof Error?t.message:String(t)}),null}}(e,p)??await async function(e,t,r){if(!e.evaluatePromises)return null
7279
+ return r?.hold?r.sentBack||!r.touched?(e.logger.info("merge held: main's newer work broke a criterion check on the landing tree; back to its worker",{requestId:e.requestId}),{action:"sent-back",summary:r.summary}):(e.logger.info("merge held: a review of main's change goes first",{requestId:e.requestId}),{action:"review-held",summary:r.summary,touched:r.touched}):null}catch(t){return e.logger.warn("main-change evaluation failed; merge continues (it is an observer, not a lock)",{requestId:e.requestId,error:t instanceof Error?t.message:String(t)}),null}}(e,f)??await async function(e,t,r){if(!e.evaluatePromises)return null
7238
7280
  try{const n=await e.evaluatePromises({baseSha:t,headSha:r})
7239
- return n?.hold?(e.logger.info("merge held: an earlier promise's check fails on the tree it would land",{requestId:e.requestId,breaks:n.breaks}),{action:"promises-held",summary:n.summary,breaks:n.breaks}):null}catch(t){return e.logger.warn("promise evaluation failed; merge continues (it is an observer, not a lock)",{requestId:e.requestId,error:t instanceof Error?t.message:String(t)}),null}}(e,l.mainHead,p)??t
7240
- if(e.testGateOff)return m(h?{action:"proceed"}:{action:"land",certifiedCommitSha:p})
7241
- const g=await r(e,f),{state:y,missingCapabilities:w}=g
7242
- if("env"===y&&e.acceptEnvironmentGap)return m(h?{action:"proceed"}:{action:"land",certifiedCommitSha:p})
7243
- if("env"===y)return{action:"env-gap",mergeCommitSha:p,missingCapabilities:w}
7244
- if("certified"===y)return m(h?{action:"proceed"}:{action:"land",certifiedCommitSha:p})
7245
- if("failed"===y&&e.acceptFailingTests)return e.logger.warn("merge-queue: landing a request whose tests are RED because the user waived the gate",{requestId:n,mergeCommitSha:p}),m(h?{action:"proceed"}:{action:"land",certifiedCommitSha:p})
7246
- if("failed"===y)return await(0,i.clearMergeCandidate)(t,n,d).catch(()=>{}),{action:"catchup-failed",mergeCommitSha:p,failedChecks:g.failedChecks}
7247
- if("pending"===y)return(0,s.renewMergeLease)(t,n,{ttlMs:s.MERGE_LEASE_CATCHUP_TTL_MS,phase:"catchup"}),{action:"catchup-running",mergeCommitSha:p,baseSha:l.mainHead,branchTip:l.branchTip,dispatched:!1}
7248
- u.info("merge-queue: no green runs at the landing tree -- dispatching a catch-up at the certifying commit",{requestId:n,certifying:h?"branch-tip":"candidate",certifyingSha:p.slice(0,8),landingTree:f.slice(0,8),mainHead:l.mainHead.slice(0,8),mergeBase:l.mergeBase.slice(0,8)})
7249
- const b=e=>({mergeCommitSha:p,baseSha:l.mainHead,branchTipSha:l.branchTip,landingTreeSha:f,certifying:h?"branch-tip":"candidate",testRunIds:e,dispatchedAt:(new Date).toISOString()})
7250
- let v
7251
- try{v=await e.dispatchCatchUp({mergeCommitSha:p,baseSha:l.mainHead})}catch(e){return u.warn("merge-queue: catch-up dispatch outcome unknown; holding the ticket for adoption on retry",{requestId:n,error:String(e?.message??e)}),(0,s.renewMergeLease)(t,n,{ttlMs:s.MERGE_LEASE_CATCHUP_TTL_MS,phase:"catchup",catchup:b([])}),{action:"catchup-running",mergeCommitSha:p,baseSha:l.mainHead,branchTip:l.branchTip,dispatched:!0}}if(!v.success)return await(0,i.clearMergeCandidate)(t,n,d).catch(()=>{}),{action:"error",message:`catch-up test dispatch failed: ${v.error||"unknown error"}`}
7252
- if("green"===v.settled)return m(h?{action:"proceed"}:{action:"land",certifiedCommitSha:p})
7253
- if("failed"===v.settled){const t=await r(e,f)
7254
- return"env"===t.state&&e.acceptEnvironmentGap?m(h?{action:"proceed"}:{action:"land",certifiedCommitSha:p}):"env"===t.state?{action:"env-gap",mergeCommitSha:p,missingCapabilities:t.missingCapabilities}:e.acceptFailingTests?(e.logger.warn("merge-queue: landing a request whose catch-up run is RED because the user waived the gate",{requestId:n,mergeCommitSha:p}),m(h?{action:"proceed"}:{action:"land",certifiedCommitSha:p})):{action:"catchup-failed",mergeCommitSha:p,failedChecks:t.failedChecks}}return(0,s.renewMergeLease)(t,n,{ttlMs:s.MERGE_LEASE_CATCHUP_TTL_MS,phase:"catchup",catchup:b(v.testRunIds??[])}),{action:"catchup-running",mergeCommitSha:p,baseSha:l.mainHead,branchTip:l.branchTip,dispatched:!0}}catch(e){return{action:"error",message:String(e?.message??e)}}}
7255
- const o=t(74146),s=t(56509),i=t(87192)},41152(e,exports){function t(e=!0){return new r(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createMetricsCollector=t,exports.createNullMetricsCollector=function(){return t(!1)}
7281
+ return n?.hold?(e.logger.info("merge held: an earlier promise's check fails on the tree it would land",{requestId:e.requestId,breaks:n.breaks}),{action:"promises-held",summary:n.summary,breaks:n.breaks}):null}catch(t){return e.logger.warn("promise evaluation failed; merge continues (it is an observer, not a lock)",{requestId:e.requestId,error:t instanceof Error?t.message:String(t)}),null}}(e,d.mainHead,f)??t
7282
+ if(e.testGateOff)return g(p?{action:"proceed"}:{action:"land",certifiedCommitSha:f})
7283
+ const y=await r(e,m),{state:w,missingCapabilities:b}=y
7284
+ if("env"===w&&e.acceptEnvironmentGap)return g(p?{action:"proceed"}:{action:"land",certifiedCommitSha:f})
7285
+ if("env"===w)return{action:"env-gap",mergeCommitSha:f,missingCapabilities:b}
7286
+ if("certified"===w)return g(p?{action:"proceed"}:{action:"land",certifiedCommitSha:f})
7287
+ if("failed"===w&&e.acceptFailingTests)return e.logger.warn("merge-queue: landing a request whose tests are RED because the user waived the gate",{requestId:o,mergeCommitSha:f}),g(p?{action:"proceed"}:{action:"land",certifiedCommitSha:f})
7288
+ if("failed"===w)return await(0,a.clearMergeCandidate)(t,o,u).catch(()=>{}),n(e,y,f,p,d.branchTip)
7289
+ if("pending"===w)return(0,i.renewMergeLease)(t,o,{ttlMs:i.MERGE_LEASE_CATCHUP_TTL_MS,phase:"catchup"}),{action:"catchup-running",mergeCommitSha:f,baseSha:d.mainHead,branchTip:d.branchTip,dispatched:!1}
7290
+ h.info("merge-queue: no green runs at the landing tree -- dispatching a catch-up at the certifying commit",{requestId:o,certifying:p?"branch-tip":"candidate",certifyingSha:f.slice(0,8),landingTree:m.slice(0,8),mainHead:d.mainHead.slice(0,8),mergeBase:d.mergeBase.slice(0,8)})
7291
+ const v=e=>({mergeCommitSha:f,baseSha:d.mainHead,branchTipSha:d.branchTip,landingTreeSha:m,certifying:p?"branch-tip":"candidate",testRunIds:e,dispatchedAt:(new Date).toISOString()})
7292
+ let k
7293
+ try{k=await e.dispatchCatchUp({mergeCommitSha:f,baseSha:d.mainHead})}catch(e){return h.warn("merge-queue: catch-up dispatch outcome unknown; holding the ticket for adoption on retry",{requestId:o,error:String(e?.message??e)}),(0,i.renewMergeLease)(t,o,{ttlMs:i.MERGE_LEASE_CATCHUP_TTL_MS,phase:"catchup",catchup:v([])}),{action:"catchup-running",mergeCommitSha:f,baseSha:d.mainHead,branchTip:d.branchTip,dispatched:!0}}if(!k.success)return await(0,a.clearMergeCandidate)(t,o,u).catch(()=>{}),{action:"error",message:`catch-up test dispatch failed: ${k.error||"unknown error"}`}
7294
+ if("green"===k.settled)return g(p?{action:"proceed"}:{action:"land",certifiedCommitSha:f})
7295
+ if("failed"===k.settled){const t=await r(e,m)
7296
+ return"env"===t.state&&e.acceptEnvironmentGap?g(p?{action:"proceed"}:{action:"land",certifiedCommitSha:f}):"env"===t.state?{action:"env-gap",mergeCommitSha:f,missingCapabilities:t.missingCapabilities}:e.acceptFailingTests?(e.logger.warn("merge-queue: landing a request whose catch-up run is RED because the user waived the gate",{requestId:o,mergeCommitSha:f}),g(p?{action:"proceed"}:{action:"land",certifiedCommitSha:f})):n(e,t,f,p,d.branchTip)}return(0,i.renewMergeLease)(t,o,{ttlMs:i.MERGE_LEASE_CATCHUP_TTL_MS,phase:"catchup",catchup:v(k.testRunIds??[])}),{action:"catchup-running",mergeCommitSha:f,baseSha:d.mainHead,branchTip:d.branchTip,dispatched:!0}}catch(e){return{action:"error",message:String(e?.message??e)}}}
7297
+ const s=t(74146),i=t(56509),a=t(87192)},41152(e,exports){function t(e=!0){return new r(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createMetricsCollector=t,exports.createNullMetricsCollector=function(){return t(!1)}
7256
7298
  class r{constructor(e=!0){this.enabled=e,this.counters=new Map,this.gauges=new Map,this.histograms=new Map}getKey(e,t){const r=Object.entries(t).map(([e,t])=>`${e}="${String(t)}"`).join(",")
7257
7299
  return r?`${e}{${r}}`:e}incrementCounter(e,t=1,r={}){if(!this.enabled)return
7258
7300
  const n=this.getKey(e,r),o=this.counters.get(n)||0
@@ -7739,7 +7781,7 @@ for(;n<r.length&&(i.has(r[n])||/^[A-Za-z_][A-Za-z0-9_]*=/.test(r[n]));)n++
7739
7781
  if(n>0&&"command"===r[n-1]&&r[n]?.startsWith("-"))continue
7740
7782
  const o=(r[n]??"").replace(/^["']|["']$/g,""),a=s[o]??s[o.split("/").pop()??""]
7741
7783
  a&&t.add(a)}return[...t].sort()}function n(e){const t=e
7742
- return t?.standing&&t?.waived?[]:Array.isArray(t?.verify)?t.verify.filter(e=>"string"==typeof e&&e.trim().length>0&&null===(0,o.toolFallbackProblem)(e)):[]}exports.proofCommandsOf=n,exports.routingCandidates=function(e,t,r){const n=e.filter(e=>!t?.has(e.id))
7784
+ return t?.standing&&t?.waived||t?.baseline&&"object"==typeof t.baseline?[]:Array.isArray(t?.verify)?t.verify.filter(e=>"string"==typeof e&&e.trim().length>0&&null===(0,o.toolFallbackProblem)(e)):[]}exports.proofCommandsOf=n,exports.routingCandidates=function(e,t,r){const n=e.filter(e=>!t?.has(e.id))
7743
7785
  return[...n.filter(e=>!r?.has(e.id)),...n.filter(e=>!!r?.has(e.id))]},exports.proofCommandsFor=function(e,t,o){const s=Array.isArray(t)?t:[]
7744
7786
  return function(e,t){const o=Array.isArray(e)?e:[],s=t.find(e=>"experiment"===e.kind),i=t.filter(e=>"experiment"!==e.kind),a=new Map(i.map(e=>[e.id,r((e.config?.commands??[]).map(e=>e?.command))])),c=[]
7745
7787
  return o.forEach((e,t)=>{const o=n(e)
@@ -8037,7 +8079,7 @@ try{const t=(0,l.simpleGit)(r)
8037
8079
  if(await t.checkIsRepo()){const n=(await t.status()).current||"unknown",o=await a.default.stat(r),s={requestId:e,branchName:n,worktreePath:r,created:o.birthtime||o.ctime,lastAccessed:new Date,status:"active"}
8038
8080
  this.activeWorktrees.set(e,s),this.logger.debug("Registered existing worktree",{requestId:e,branchName:n,worktreePath:r})}else this.logger.warn("Found invalid worktree directory",{requestId:e,path:r})}catch(t){this.logger.warn("Error scanning worktree directory",{requestId:e,path:r,error:(0,h.getErrorMessage)(t)})}}this.logger.info("Worktree scan completed",{totalWorktrees:this.activeWorktrees.size})}catch(e){throw this.logger.error("Failed to scan existing worktrees",{error:(0,h.getErrorMessage)(e)}),e}}}},27634(e,exports,t){exports.WorktreeManager=void 0
8039
8081
  var r=t(21502)
8040
- Object.defineProperty(exports,"WorktreeManager",{enumerable:!0,get:function(){return r.WorktreeManager}})},66865(module){module.exports=require("@modelcontextprotocol/sdk/server/index.js")},62422(module){module.exports=require("@modelcontextprotocol/sdk/server/sse.js")},25802(module){module.exports=require("@modelcontextprotocol/sdk/server/stdio.js")},49150(module){module.exports=require("@modelcontextprotocol/sdk/types.js")},98577(module){module.exports=require("cors")},66261(module){module.exports=require("events")},7252(module){module.exports=require("express")},88194(module){module.exports=require("jszip")},47373(module){module.exports=require("micromatch")},10980(module){module.exports=require("pdf-lib")},83807(module){module.exports=require("simple-git")},36666(module){module.exports=require("ts-node/register/transpile-only")},9956(module){module.exports=require("undici")},88891(module){module.exports=require("unpdf")},55124(module){module.exports=require("winston")},11569(module){module.exports=require("zod")},25106(module){module.exports=require("zod-to-json-schema")},35317(module){module.exports=require("child_process")},76982(module){module.exports=require("crypto")},79896(module){module.exports=require("fs")},91943(module){module.exports=require("fs/promises")},69278(module){module.exports=require("net")},73024(module){module.exports=require("node:fs")},76760(module){module.exports=require("node:path")},70857(module){module.exports=require("os")},16928(module){module.exports=require("path")},23785(module){module.exports=require("readline")},49786(module){module.exports=require("stream/promises")},39023(module){module.exports=require("util")},43106(module){module.exports=require("zlib")}}
8082
+ Object.defineProperty(exports,"WorktreeManager",{enumerable:!0,get:function(){return r.WorktreeManager}})},66865(module){module.exports=require("@modelcontextprotocol/sdk/server/index.js")},62422(module){module.exports=require("@modelcontextprotocol/sdk/server/sse.js")},25802(module){module.exports=require("@modelcontextprotocol/sdk/server/stdio.js")},49150(module){module.exports=require("@modelcontextprotocol/sdk/types.js")},98577(module){module.exports=require("cors")},66261(module){module.exports=require("events")},7252(module){module.exports=require("express")},88194(module){module.exports=require("jszip")},47373(module){module.exports=require("micromatch")},10980(module){module.exports=require("pdf-lib")},83807(module){module.exports=require("simple-git")},36666(module){module.exports=require("ts-node/register/transpile-only")},9956(module){module.exports=require("undici")},88891(module){module.exports=require("unpdf")},55124(module){module.exports=require("winston")},11569(module){module.exports=require("zod")},25106(module){module.exports=require("zod-to-json-schema")},35317(module){module.exports=require("child_process")},76982(module){module.exports=require("crypto")},79896(module){module.exports=require("fs")},91943(module){module.exports=require("fs/promises")},69278(module){module.exports=require("net")},31421(module){module.exports=require("node:child_process")},73024(module){module.exports=require("node:fs")},76760(module){module.exports=require("node:path")},70857(module){module.exports=require("os")},16928(module){module.exports=require("path")},23785(module){module.exports=require("readline")},49786(module){module.exports=require("stream/promises")},39023(module){module.exports=require("util")},43106(module){module.exports=require("zlib")}}
8041
8083
  const r={}
8042
8084
  e.m=t,(()=>{const t=Object.getPrototypeOf
8043
8085
  let r