runcastle 1.5.5 → 1.5.6

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.
@@ -69,7 +69,7 @@ Error generating stack: `+e.message+`
69
69
 
70
70
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Di,s=!fi.jitless,c=s&&Oi.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Qo([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ts(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Ui(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>qi(e,r,pi())))}),t)}var ns=U(`$ZodUnion`,(e,t)=>{po.init(e,t),xi(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),xi(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),xi(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),xi(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>vi(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>ts(t,r,e,i)):ts(o,r,e,i)}}),rs=U(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ns.init(e,t);let n=e._zod.parse;xi(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=gi(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Di(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),is=U(`$ZodIntersection`,(e,t)=>{po.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>os(e,t,n)):os(e,i,a)}});function as(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ki(e)&&ki(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=as(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=as(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function os(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Ui(e))return e;let o=as(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ss=U(`$ZodTuple`,(e,t)=>{po.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=cs(n,`optin`),c=cs(n,`optout`);if(!t.rest){if(a.length<s)return r.issues.push({code:`too_small`,minimum:s,inclusive:!0,input:a,inst:e,origin:`array`}),r;a.length>n.length&&r.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:a,inst:e,origin:`array`})}let l=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:a[e],issues:[]},i);t instanceof Promise?o.push(t.then(t=>{l[e]=t})):l[e]=t}if(t.rest){let e=n.length-1,s=a.slice(n.length);for(let n of s){e++;let a=t.rest._zod.run({value:n,issues:[]},i);a instanceof Promise?o.push(a.then(t=>ls(t,r,e))):ls(a,r,e)}}return o.length?Promise.all(o).then(()=>us(l,r,n,a,c)):us(l,r,n,a,c)}});function cs(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function ls(e,t,n){e.issues.length&&t.issues.push(...Gi(n,e.issues)),t.value[n]=e.value}function us(e,t,n,r,i){for(let a=0;a<n.length;a++){let n=e[a],o=a<r.length;if(n.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...Gi(a,n.issues))}t.value[a]=n.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}var ds=U(`$ZodRecord`,(e,t)=>{po.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ki(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>qi(e,r,pi())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Gi(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Gi(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Ha.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>qi(e,r,pi())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Gi(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Gi(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),fs=U(`$ZodEnum`,(e,t)=>{po.init(e,t);let n=mi(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ji.has(typeof e)).map(e=>typeof e==`string`?Mi(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),ps=U(`$ZodLiteral`,(e,t)=>{if(po.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Mi(e):e?Mi(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ms=U(`$ZodTransform`,(e,t)=>{po.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new di(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new ui;return n.value=i,n.fallback=!0,n}});function hs(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var gs=U(`$ZodOptional`,(e,t)=>{po.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,xi(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),xi(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${vi(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>hs(e,r)):hs(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),_s=U(`$ZodExactOptional`,(e,t)=>{gs.init(e,t),xi(e._zod,`values`,()=>t.innerType._zod.values),xi(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),vs=U(`$ZodNullable`,(e,t)=>{po.init(e,t),xi(e._zod,`optin`,()=>t.innerType._zod.optin),xi(e._zod,`optout`,()=>t.innerType._zod.optout),xi(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${vi(e.source)}|null)$`):void 0}),xi(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ys=U(`$ZodDefault`,(e,t)=>{po.init(e,t),e._zod.optin=`optional`,xi(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>bs(e,t)):bs(r,t)}});function bs(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var xs=U(`$ZodPrefault`,(e,t)=>{po.init(e,t),e._zod.optin=`optional`,xi(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ss=U(`$ZodNonOptional`,(e,t)=>{po.init(e,t),xi(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Cs(t,e)):Cs(i,e)}});function Cs(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var ws=U(`$ZodCatch`,(e,t)=>{po.init(e,t),e._zod.optin=`optional`,xi(e._zod,`optout`,()=>t.innerType._zod.optout),xi(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>qi(e,n,pi()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>qi(e,n,pi()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Ts=U(`$ZodPipe`,(e,t)=>{po.init(e,t),xi(e._zod,`values`,()=>t.in._zod.values),xi(e._zod,`optin`,()=>t.in._zod.optin),xi(e._zod,`optout`,()=>t.out._zod.optout),xi(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Es(e,t.in,n)):Es(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Es(e,t.out,n)):Es(r,t.out,n)}});function Es(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Ds=U(`$ZodPreprocess`,(e,t)=>{Ts.init(e,t)}),Os=U(`$ZodReadonly`,(e,t)=>{po.init(e,t),xi(e._zod,`propValues`,()=>t.innerType._zod.propValues),xi(e._zod,`values`,()=>t.innerType._zod.values),xi(e._zod,`optin`,()=>t.innerType?._zod?.optin),xi(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ks):ks(r)}});function ks(e){return e.value=Object.freeze(e.value),e}var As=U(`$ZodCustom`,(e,t)=>{qa.init(e,t),po.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>js(t,n,r,e));js(i,n,r,e)}});function js(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Yi(e))}}var Ms,Ns=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ps(){return new Ns}(Ms=globalThis).__zod_globalRegistry??(Ms.__zod_globalRegistry=Ps());var Fs=globalThis.__zod_globalRegistry;function Is(e,t){return new e({type:`string`,...W(t)})}function Ls(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...W(t)})}function Rs(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...W(t)})}function zs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...W(t)})}function Bs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...W(t)})}function Vs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...W(t)})}function Hs(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...W(t)})}function Us(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...W(t)})}function Ws(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...W(t)})}function Gs(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...W(t)})}function Ks(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...W(t)})}function qs(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...W(t)})}function Js(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...W(t)})}function Ys(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...W(t)})}function Xs(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...W(t)})}function Zs(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...W(t)})}function Qs(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...W(t)})}function $s(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...W(t)})}function ec(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...W(t)})}function tc(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...W(t)})}function nc(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...W(t)})}function rc(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...W(t)})}function ic(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...W(t)})}function ac(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...W(t)})}function oc(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...W(t)})}function sc(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...W(t)})}function cc(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...W(t)})}function lc(e,t){return new e({type:`number`,checks:[],...W(t)})}function uc(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...W(t)})}function dc(e,t){return new e({type:`boolean`,...W(t)})}function fc(e,t){return new e({type:`null`,...W(t)})}function pc(e){return new e({type:`unknown`})}function mc(e,t){return new e({type:`never`,...W(t)})}function hc(e,t){return new Ya({check:`less_than`,...W(t),value:e,inclusive:!1})}function gc(e,t){return new Ya({check:`less_than`,...W(t),value:e,inclusive:!0})}function _c(e,t){return new Xa({check:`greater_than`,...W(t),value:e,inclusive:!1})}function vc(e,t){return new Xa({check:`greater_than`,...W(t),value:e,inclusive:!0})}function yc(e,t){return new Za({check:`multiple_of`,...W(t),value:e})}function bc(e,t){return new $a({check:`max_length`,...W(t),maximum:e})}function xc(e,t){return new eo({check:`min_length`,...W(t),minimum:e})}function Sc(e,t){return new to({check:`length_equals`,...W(t),length:e})}function Cc(e,t){return new ro({check:`string_format`,format:`regex`,...W(t),pattern:e})}function wc(e){return new io({check:`string_format`,format:`lowercase`,...W(e)})}function Tc(e){return new ao({check:`string_format`,format:`uppercase`,...W(e)})}function Ec(e,t){return new oo({check:`string_format`,format:`includes`,...W(t),includes:e})}function Dc(e,t){return new so({check:`string_format`,format:`starts_with`,...W(t),prefix:e})}function Oc(e,t){return new co({check:`string_format`,format:`ends_with`,...W(t),suffix:e})}function kc(e){return new lo({check:`overwrite`,tx:e})}function Ac(e){return kc(t=>t.normalize(e))}function jc(){return kc(e=>e.trim())}function Mc(){return kc(e=>e.toLowerCase())}function Nc(){return kc(e=>e.toUpperCase())}function Pc(){return kc(e=>Ti(e))}function Fc(e,t,n){return new e({type:`array`,element:t,...W(n)})}function Ic(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...W(n)})}function Lc(e,t){let n=Rc(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Yi(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Yi(r))}},e(t.value,t)),t);return n}function Rc(e,t){let n=new qa({check:`custom`,...W(t)});return n._zod.check=e,n}function zc(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Fs,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Bc(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Bc(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Uc(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Vc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
71
71
 
72
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Hc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Gc(t,`input`,e.processors),output:Gc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Uc(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Uc(r.element,n);if(r.type===`set`)return Uc(r.valueType,n);if(r.type===`lazy`)return Uc(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Uc(r.innerType,n);if(r.type===`intersection`)return Uc(r.left,n)||Uc(r.right,n);if(r.type===`record`||r.type===`map`)return Uc(r.keyType,n)||Uc(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Uc(r.in,n)||Uc(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Uc(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Uc(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Uc(e,n))return!0;return!!(r.rest&&Uc(r.rest,n))}return!1}var Wc=(e,t={})=>n=>{let r=zc({...n,processors:t});return Bc(e,r),Vc(r,e),Hc(r,e)},Gc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=zc({...i??{},target:a,io:t,processors:n});return Bc(e,o),Vc(o,e),Hc(o,e)},Kc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},qc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Kc[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Jc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Yc=(e,t,n,r)=>{n.type=`boolean`},Xc=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Zc=(e,t,n,r)=>{n.not={}},Qc=(e,t,n,r)=>{let i=e._zod.def,a=mi(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},$c=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},el=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},tl=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},nl=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Bc(a.element,t,{...r,path:[...r.path,`items`]})},rl=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Bc(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Bc(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},il=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Bc(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},al=(e,t,n,r)=>{let i=e._zod.def,a=Bc(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Bc(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ol=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Bc(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Bc(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},sl=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Bc(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Bc(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Bc(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},cl=(e,t,n,r)=>{let i=e._zod.def,a=Bc(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ll=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ul=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},dl=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},fl=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},pl=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Bc(o,t,r);let s=t.seen.get(e);s.ref=o},ml=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},hl=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gl=U(`ZodISODateTime`,(e,t)=>{Do.init(e,t),Hl.init(e,t)});function _l(e){return ac(gl,e)}var vl=U(`ZodISODate`,(e,t)=>{Oo.init(e,t),Hl.init(e,t)});function yl(e){return oc(vl,e)}var bl=U(`ZodISOTime`,(e,t)=>{ko.init(e,t),Hl.init(e,t)});function xl(e){return sc(bl,e)}var Sl=U(`ZodISODuration`,(e,t)=>{Ao.init(e,t),Hl.init(e,t)});function Cl(e){return cc(Sl,e)}var wl=U(`ZodError`,(e,t)=>{Zi.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ea(e,t)},flatten:{value:t=>$i(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,hi,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,hi,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Tl=ta(wl),El=na(wl),Dl=ra(wl),Ol=aa(wl),kl=sa(wl),Al=ca(wl),jl=la(wl),Ml=ua(wl),Nl=da(wl),Pl=fa(wl),Fl=pa(wl),Il=ma(wl),Ll=new WeakMap;function Rl(e,t,n){let r=Object.getPrototypeOf(e),i=Ll.get(r);if(i||(i=new Set,Ll.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var zl=U(`ZodType`,(e,t)=>(po.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Gc(e,`input`),output:Gc(e,`output`)}}),e.toJSONSchema=Wc(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Tl(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Dl(e,t,n),e.parseAsync=async(t,n)=>El(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ol(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>kl(e,t,n),e.decode=(t,n)=>Al(e,t,n),e.encodeAsync=async(t,n)=>jl(e,t,n),e.decodeAsync=async(t,n)=>Ml(e,t,n),e.safeEncode=(t,n)=>Nl(e,t,n),e.safeDecode=(t,n)=>Pl(e,t,n),e.safeEncodeAsync=async(t,n)=>Fl(e,t,n),e.safeDecodeAsync=async(t,n)=>Il(e,t,n),Rl(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Ci(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Ni(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(od(e,t))},superRefine(e,t){return this.check(sd(e,t))},overwrite(e){return this.check(kc(e))},optional(){return Vu(this)},exactOptional(){return Uu(this)},nullable(){return Gu(this)},nullish(){return Vu(Gu(this))},nonoptional(e){return Zu(this,e)},array(){return bu(this)},or(e){return wu([this,e])},and(e){return Ou(this,e)},transform(e){return td(this,zu(e))},default(e){return qu(this,e)},prefault(e){return Yu(this,e)},catch(e){return $u(this,e)},pipe(e){return td(this,e)},readonly(){return id(this)},describe(e){let t=this.clone();return Fs.add(t,{description:e}),t},meta(...e){if(e.length===0)return Fs.get(this);let t=this.clone();return Fs.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Fs.get(e)?.description},configurable:!0}),e)),Bl=U(`_ZodString`,(e,t)=>{mo.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qc(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Rl(e,`_ZodString`,{regex(...e){return this.check(Cc(...e))},includes(...e){return this.check(Ec(...e))},startsWith(...e){return this.check(Dc(...e))},endsWith(...e){return this.check(Oc(...e))},min(...e){return this.check(xc(...e))},max(...e){return this.check(bc(...e))},length(...e){return this.check(Sc(...e))},nonempty(...e){return this.check(xc(1,...e))},lowercase(e){return this.check(wc(e))},uppercase(e){return this.check(Tc(e))},trim(){return this.check(jc())},normalize(...e){return this.check(Ac(...e))},toLowerCase(){return this.check(Mc())},toUpperCase(){return this.check(Nc())},slugify(){return this.check(Pc())}})}),Vl=U(`ZodString`,(e,t)=>{mo.init(e,t),Bl.init(e,t),e.email=t=>e.check(Ls(Ul,t)),e.url=t=>e.check(Us(Kl,t)),e.jwt=t=>e.check(ic(su,t)),e.emoji=t=>e.check(Ws(ql,t)),e.guid=t=>e.check(Rs(Wl,t)),e.uuid=t=>e.check(zs(Gl,t)),e.uuidv4=t=>e.check(Bs(Gl,t)),e.uuidv6=t=>e.check(Vs(Gl,t)),e.uuidv7=t=>e.check(Hs(Gl,t)),e.nanoid=t=>e.check(Gs(Jl,t)),e.guid=t=>e.check(Rs(Wl,t)),e.cuid=t=>e.check(Ks(Yl,t)),e.cuid2=t=>e.check(qs(Xl,t)),e.ulid=t=>e.check(Js(Zl,t)),e.base64=t=>e.check(tc(iu,t)),e.base64url=t=>e.check(nc(au,t)),e.xid=t=>e.check(Ys(Ql,t)),e.ksuid=t=>e.check(Xs($l,t)),e.ipv4=t=>e.check(Zs(eu,t)),e.ipv6=t=>e.check(Qs(tu,t)),e.cidrv4=t=>e.check($s(nu,t)),e.cidrv6=t=>e.check(ec(ru,t)),e.e164=t=>e.check(rc(ou,t)),e.datetime=t=>e.check(_l(t)),e.date=t=>e.check(yl(t)),e.time=t=>e.check(xl(t)),e.duration=t=>e.check(Cl(t))});function G(e){return Is(Vl,e)}var Hl=U(`ZodStringFormat`,(e,t)=>{ho.init(e,t),Bl.init(e,t)}),Ul=U(`ZodEmail`,(e,t)=>{vo.init(e,t),Hl.init(e,t)}),Wl=U(`ZodGUID`,(e,t)=>{go.init(e,t),Hl.init(e,t)}),Gl=U(`ZodUUID`,(e,t)=>{_o.init(e,t),Hl.init(e,t)}),Kl=U(`ZodURL`,(e,t)=>{yo.init(e,t),Hl.init(e,t)}),ql=U(`ZodEmoji`,(e,t)=>{bo.init(e,t),Hl.init(e,t)}),Jl=U(`ZodNanoID`,(e,t)=>{xo.init(e,t),Hl.init(e,t)}),Yl=U(`ZodCUID`,(e,t)=>{So.init(e,t),Hl.init(e,t)}),Xl=U(`ZodCUID2`,(e,t)=>{Co.init(e,t),Hl.init(e,t)}),Zl=U(`ZodULID`,(e,t)=>{wo.init(e,t),Hl.init(e,t)}),Ql=U(`ZodXID`,(e,t)=>{To.init(e,t),Hl.init(e,t)}),$l=U(`ZodKSUID`,(e,t)=>{Eo.init(e,t),Hl.init(e,t)}),eu=U(`ZodIPv4`,(e,t)=>{jo.init(e,t),Hl.init(e,t)}),tu=U(`ZodIPv6`,(e,t)=>{Mo.init(e,t),Hl.init(e,t)}),nu=U(`ZodCIDRv4`,(e,t)=>{No.init(e,t),Hl.init(e,t)}),ru=U(`ZodCIDRv6`,(e,t)=>{Po.init(e,t),Hl.init(e,t)}),iu=U(`ZodBase64`,(e,t)=>{Io.init(e,t),Hl.init(e,t)}),au=U(`ZodBase64URL`,(e,t)=>{Ro.init(e,t),Hl.init(e,t)}),ou=U(`ZodE164`,(e,t)=>{zo.init(e,t),Hl.init(e,t)}),su=U(`ZodJWT`,(e,t)=>{Vo.init(e,t),Hl.init(e,t)}),cu=U(`ZodNumber`,(e,t)=>{Ho.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jc(e,t,n,r),Rl(e,`ZodNumber`,{gt(e,t){return this.check(_c(e,t))},gte(e,t){return this.check(vc(e,t))},min(e,t){return this.check(vc(e,t))},lt(e,t){return this.check(hc(e,t))},lte(e,t){return this.check(gc(e,t))},max(e,t){return this.check(gc(e,t))},int(e){return this.check(uu(e))},safe(e){return this.check(uu(e))},positive(e){return this.check(_c(0,e))},nonnegative(e){return this.check(vc(0,e))},negative(e){return this.check(hc(0,e))},nonpositive(e){return this.check(gc(0,e))},multipleOf(e,t){return this.check(yc(e,t))},step(e,t){return this.check(yc(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function K(e){return lc(cu,e)}var lu=U(`ZodNumberFormat`,(e,t)=>{Uo.init(e,t),cu.init(e,t)});function uu(e){return uc(lu,e)}var du=U(`ZodBoolean`,(e,t)=>{Wo.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yc(e,t,n,r)});function fu(e){return dc(du,e)}var pu=U(`ZodNull`,(e,t)=>{Go.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xc(e,t,n,r)});function mu(e){return fc(pu,e)}var hu=U(`ZodUnknown`,(e,t)=>{Ko.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function gu(){return pc(hu)}var _u=U(`ZodNever`,(e,t)=>{qo.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zc(e,t,n,r)});function vu(e){return mc(_u,e)}var yu=U(`ZodArray`,(e,t)=>{Yo.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nl(e,t,n,r),e.element=t.element,Rl(e,`ZodArray`,{min(e,t){return this.check(xc(e,t))},nonempty(e){return this.check(xc(1,e))},max(e,t){return this.check(bc(e,t))},length(e,t){return this.check(Sc(e,t))},unwrap(){return this.element}})});function bu(e,t){return Fc(yu,e,t)}var xu=U(`ZodObject`,(e,t)=>{es.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rl(e,t,n,r),xi(e,`shape`,()=>t.shape),Rl(e,`ZodObject`,{keyof(){return Fu(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:gu()})},loose(){return this.clone({...this._zod.def,catchall:gu()})},strict(){return this.clone({...this._zod.def,catchall:vu()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Ri(this,e)},safeExtend(e){return zi(this,e)},merge(e){return Bi(this,e)},pick(e){return Ii(this,e)},omit(e){return Li(this,e)},partial(...e){return Vi(Bu,this,e[0])},required(...e){return Hi(Xu,this,e[0])}})});function Su(e,t){return new xu({type:`object`,shape:e??{},...W(t)})}var Cu=U(`ZodUnion`,(e,t)=>{ns.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r),e.options=t.options});function wu(e,t){return new Cu({type:`union`,options:e,...W(t)})}var Tu=U(`ZodDiscriminatedUnion`,(e,t)=>{Cu.init(e,t),rs.init(e,t)});function Eu(e,t,n){return new Tu({type:`union`,options:t,discriminator:e,...W(n)})}var Du=U(`ZodIntersection`,(e,t)=>{is.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r)});function Ou(e,t){return new Du({type:`intersection`,left:e,right:t})}var ku=U(`ZodTuple`,(e,t)=>{ss.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function Au(e,t,n){let r=t instanceof po;return new ku({type:`tuple`,items:e,rest:r?t:null,...W(r?n:t)})}var ju=U(`ZodRecord`,(e,t)=>{ds.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Mu(e,t,n){return!t||!t._zod?new ju({type:`record`,keyType:G(),valueType:e,...W(t)}):new ju({type:`record`,keyType:e,valueType:t,...W(n)})}function Nu(e,t,n){let r=Ni(e);return r._zod.values=void 0,new ju({type:`record`,keyType:r,valueType:t,...W(n)})}var Pu=U(`ZodEnum`,(e,t)=>{fs.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qc(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Pu({...t,checks:[],...W(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Pu({...t,checks:[],...W(r),entries:i})}});function Fu(e,t){return new Pu({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...W(t)})}var Iu=U(`ZodLiteral`,(e,t)=>{ps.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Lu(e,t){return new Iu({type:`literal`,values:Array.isArray(e)?e:[e],...W(t)})}var Ru=U(`ZodTransform`,(e,t)=>{ms.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tl(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new di(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Yi(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Yi(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function zu(e){return new Ru({type:`transform`,transform:e})}var Bu=U(`ZodOptional`,(e,t)=>{gs.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vu(e){return new Bu({type:`optional`,innerType:e})}var Hu=U(`ZodExactOptional`,(e,t)=>{_s.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uu(e){return new Hu({type:`optional`,innerType:e})}var Wu=U(`ZodNullable`,(e,t)=>{vs.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gu(e){return new Wu({type:`nullable`,innerType:e})}var Ku=U(`ZodDefault`,(e,t)=>{ys.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ul(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qu(e,t){return new Ku({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ai(t)}})}var Ju=U(`ZodPrefault`,(e,t)=>{xs.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yu(e,t){return new Ju({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ai(t)}})}var Xu=U(`ZodNonOptional`,(e,t)=>{Ss.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zu(e,t){return new Xu({type:`nonoptional`,innerType:e,...W(t)})}var Qu=U(`ZodCatch`,(e,t)=>{ws.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $u(e,t){return new Qu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ed=U(`ZodPipe`,(e,t)=>{Ts.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),e.in=t.in,e.out=t.out});function td(e,t){return new ed({type:`pipe`,in:e,out:t})}var nd=U(`ZodPreprocess`,(e,t)=>{ed.init(e,t),Ds.init(e,t)}),rd=U(`ZodReadonly`,(e,t)=>{Os.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ml(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function id(e){return new rd({type:`readonly`,innerType:e})}var ad=U(`ZodCustom`,(e,t)=>{As.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>el(e,t,n,r)});function od(e,t={}){return Ic(ad,e,t)}function sd(e,t){return Lc(e,t)}function cd(e,t){return new nd({type:`pipe`,in:zu(e),out:t})}var ld=[`chat`,`implement`,`review`,`prepare`,`project`,`smoke`],ud=Fu(ld),dd=[`claude-code`,`codex`],fd=Fu(dd),pd=`claude-code`,md=Su({id:G().min(1),runtime:fd,note:G().optional()}),hd={"claude-code":{flagship:`claude-opus-5`,smoke:`claude-haiku-4-5`},codex:{flagship:`gpt-5.6-sol`,smoke:`gpt-5.6-luna`}},gd=[{id:`claude-opus-5`,runtime:`claude-code`},{id:`claude-opus-5[1m]`,runtime:`claude-code`},{id:`claude-sonnet-5`,runtime:`claude-code`},{id:`claude-sonnet-5[1m]`,runtime:`claude-code`},{id:`claude-fable-5`,runtime:`claude-code`},{id:`claude-fable-5[1m]`,runtime:`claude-code`},{id:`claude-opus-4-8`,runtime:`claude-code`},{id:`claude-haiku-4-5`,runtime:`claude-code`},{id:`gpt-5.6-sol`,runtime:`codex`},{id:`gpt-5.6-terra`,runtime:`codex`},{id:`gpt-5.6-luna`,runtime:`codex`}],_d=hd[pd].smoke,vd=[`waypoint`,`converge`,`research`];cd(e=>{if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e},n=typeof t.stepModels==`object`&&t.stepModels!==null&&!Array.isArray(t.stepModels)?{...t.stepModels}:void 0;if(n){for(let e of vd)delete n[e];t.stepModels=n}let r=t.smokeModel;return typeof r==`string`&&r.length>0&&n?.smoke===void 0&&(t.stepModels={...n,smoke:r}),delete t.smokeModel,t},Su({serverPort:K().default(4512),model:G().default(hd[pd].flagship),stepModels:Nu(ud,G()).default({smoke:_d}),models:bu(md).default([]),sandbox:Fu([`docker`,`podman`,`noSandbox`]).default(`docker`),sessionMcp:Fu([`inherit`,`runcastleOnly`]).default(`inherit`),sandboxImage:G().optional(),burnConcurrency:K().int().min(1).max(8).default(3),burnCpus:K().positive().max(256).optional(),burnGuard:fu().default(!0),burnMaxIterations:K().int().min(1).max(10).default(3),burnAttempts:K().int().min(1).max(5).default(3),burnConflictAttempts:K().int().min(0).max(3).default(2),setupCommand:G().optional(),verifyCommands:G().optional(),knownFailures:G().optional(),burnWorkspace:Fu([`auto`,`mounted`,`isolated`]).default(`auto`),burnCache:Fu([`volume`,`off`]).default(`volume`)}));function yd(e,t){let n=new Map(t.map(e=>[e.id,e])),r=e.map(e=>n.get(e.id)??e),i=new Set(e.map(e=>e.id));return[...r,...t.filter(e=>!i.has(e.id))]}function bd(e){return yd(yd(gd,e.discovered??[]),e.models??[])}function xd(e){return dd.flatMap(t=>e.sources[t].models.map(({id:e})=>({id:e,runtime:t})))}function Sd(e,t){return bd(t).find(t=>t.id===e)??{id:e,runtime:`claude-code`}}var Cd=Fu([`passed`,`failed`,`couldnt_run`]),wd=Su({command:G(),outcome:Cd,exitCode:K().nullable(),reason:G().optional(),log:G()}),Td=Eu(`status`,[Su({status:Lu(`none_configured`)}),Su({status:Lu(`couldnt_run`),commit:G(),reason:G(),log:G().nullable()}),Su({status:Lu(`ran`),commit:G(),commands:bu(wd)})]),Ed=Fu([`pending`,`burning`,`done`,`failed`,`cancelled`]),Dd=Fu([`chat`,`prepare`,`project`,`drive-fix`,`scenario`,`side`]),Od=Fu([`resolve-conflict`,`start-lap`,`self-plan`,`relay`,`lead-wake`,`scenario-setup`]);function kd(e){return e.kind!==`chat`||e.purpose===`lead-wake`?!1:!!e.headless||e.purpose===`self-plan`}var Ad=Su({mergeFrom:G(),mergeInto:G()}),jd=Fu([`running`,`succeeded`,`failed`,`cancelled`]),Md=Fu([`draft`,`active`,`shipped`,`archived`]),Nd=Fu([`launching`,`live`,`ended`]),Pd=Fu([`implementation`,`review`]),Fd=Fu([`defect`,`observation`]),Id=Fu([`high`,`medium`,`low`]),Ld=Fu([`open`,`fixing`,`fixed`,`failed`,`dismissed`]),Rd=Fu([`over-cap`,`fix-failed`,`verification`]),zd=Fu([`fix-ticket`,`session`]);Su({kind:Fd,severity:Id,title:G().min(1),location:G().min(1),citation:G().min(1),detail:G().min(1),reproStep:G().optional()}).superRefine((e,t)=>{e.kind===`defect`&&!e.reproStep?.trim()&&t.addIssue({code:`custom`,path:[`reproStep`],message:`defects require a repro step`})}).safeExtend({id:G(),featureId:G(),reviewTicketId:G(),reproStep:G(),status:Ld,openReason:Rd.nullable(),failureReason:G().nullable(),fixTicketId:G().nullable(),resolvedBy:zd.nullable(),resolutionNote:G().nullable(),createdAt:K()}),Su({title:G(),goal:G(),context:G(),acceptanceCriteria:bu(G()),seams:bu(G()),blockedBy:bu(K()),kind:Pd.default(`implementation`),passKind:Fu([`review`,`verification`]).default(`review`),model:G().optional(),originFindingId:G().optional()}).extend({id:G(),featureId:G(),seq:K(),status:Ed,commits:bu(G()),reviewedCommit:G().nullable().default(null),reviewMode:Fu([`drive`,`gates`]).nullable().optional(),reviewVerdict:Fu([`verified`,`unverified`]).nullable().optional(),reviewVerdictReason:G().nullable().optional(),reviewGateRun:Td.nullable().optional(),completedAt:K().nullable().default(null),error:G().optional(),attemptBranch:G().optional(),conflictFiles:bu(G()).optional(),digest:G().optional()});var Bd=Fu([`open`,`done`,`promoted`,`carried`]),Vd=Fu([`human`,`agent`]);Su({id:G(),featureId:G(),text:G(),status:Bd,author:Vd.default(`human`),ticketId:G().optional(),reviewTicketId:G().optional(),videoTimestamp:K().optional(),screenshotUrl:G().optional(),sentAt:K().optional(),createdAt:K(),updatedAt:K()});var Hd=Fu([`open`,`triaged`]);Su({id:G(),projectId:G(),text:G(),status:Hd,outcome:G().optional(),featureId:G().optional(),screenshotUrl:G().optional(),driveBranch:G().optional(),driveCommit:G().optional(),createdAt:K(),updatedAt:K()});var Ud=[`setupCommand`,`verifyCommands`,`knownFailures`,`devCommand`,`driveSetupCommand`,`driveStopCommand`,`dbResetCommand`,`driveInstructions`];Fu(Ud);var Wd=Fu([...Ud,`sandboxImage`]),Gd=[`devCommand`,`driveSetupCommand`,`driveStopCommand`],Kd=Fu([`prep`,`human`,`session`,`build`]),qd=`runcastle:`;G().min(1,`a project needs a name`).max(80,`a project name can be at most 80 characters`),Su({id:G(),name:G(),repoPath:G(),sessionBranch:G().optional(),devCommand:G().optional(),model:G().optional(),sandboxImage:G().optional(),setupCommand:G().optional(),verifyCommands:G().optional(),knownFailures:G().optional(),dbResetCommand:G().optional(),driveSetupCommand:G().optional(),driveStopCommand:G().optional(),driveInstructions:G().optional(),scenarioRunner:G().optional(),docsCommitPrefix:G().optional(),closedAt:K().optional()}),Su({key:Wd,source:Kd,evidence:G().optional(),establishedAt:K(),establishedSha:G().optional(),staleCommits:K().optional(),verifiedAt:K().optional(),verifiedSha:G().optional()}),Su({id:G(),projectId:G(),slug:G(),title:G(),oneLiner:G(),brief:G().optional(),branch:G(),baseBranch:G().optional(),status:Md,createdAt:K(),upNext:fu().default(!1),stoppedAt:K().nullable().default(null),waitingReason:G().nullable().default(null),lastHumanMessageAt:K().nullable().default(null),lastDispatchAt:K().nullable().default(null)}),Su({id:G(),featureId:G(),runId:G().nullable(),scenario:G(),createdAt:K()});var Jd=Su({ok:fu(),failed:bu(G())});Su({round:K(),runId:G(),status:jd,ticketSeqs:bu(K()),landed:bu(K()),failed:bu(K()),gates:Jd.nullable(),startedAt:K(),finishedAt:K().nullable()}),Su({id:G(),featureId:G().optional(),projectId:G().optional(),kind:Dd,purpose:Od.optional(),purposeData:Ad.optional(),ccSessionId:G().optional(),transcriptPath:G().optional(),status:Nd,awaitingInput:fu(),headless:fu().optional(),worktreePath:G(),model:G().optional(),runtime:fd.optional(),title:G().nullable().optional(),transcriptMissing:fu().optional(),createdAt:K().optional(),endedAt:K().optional(),openedBeside:G().optional()}),Su({id:G(),featureId:G(),workflow:G(),status:jd,startedAt:K(),endedAt:K().optional(),summary:G().optional(),digest:G().optional(),gates:Td.optional()});var Yd=Fu([`env`,`project`,`file`,`default`]),Xd=Fu([`global`,`project`]),Zd=Su({key:G(),value:gu(),source:Yd,editable:fu(),restartRequired:fu(),scope:Xd}),Qd=Su({id:G().min(1),runtime:fd,displayName:G().optional(),description:G().optional(),retirement:Su({at:G(),replacement:G()}).optional()}),$d=Su({sources:Mu(fd,Su({status:Fu([`never`,`ok`,`failed`]),lastSuccessAt:K().optional(),lastAttemptAt:K().optional(),error:G().optional(),models:bu(Qd),newIds:bu(G()),knownIds:bu(G()).default([])}))}),ef=()=>({status:`never`,models:[],newIds:[],knownIds:[]}),tf={sources:{"claude-code":ef(),codex:ef()}};Su({projectId:G().optional(),fields:bu(Zd),discovery:$d}),Su({projectId:G().optional(),key:G(),value:wu([G(),K(),fu(),bu(md),mu()])}),Su({id:K(),projectId:G(),featureId:G().optional(),runId:G().optional(),ticketId:G().optional(),ts:K(),type:G(),message:G(),data:gu().optional()});var nf=Su({sessionId:G().optional(),exitCode:K().nullable(),tail:G(),messages:K()});Fu([`idle`,`starting`,`serving`,`bare-checkout`,`setup-failed`,`review-agent-driving`]),Su({file:G(),group:G().optional(),name:G(),own:fu(),hasCall:fu()});var rf=Su({method:G().min(1),url:G(),headers:bu(Au([G(),G()])),body:G().optional()}),af=Su({reason:Fu([`exit`,`no-entry-url`,`timeout`,`no-runner`]),exitCode:K().nullable().optional(),outputTail:G()});Su({file:G(),name:G(),status:Fu([`running`,`landed`,`failed`]),output:G().optional(),entryUrl:G().optional(),landingId:G().optional(),failure:af.optional(),token:G().optional(),run:G().optional(),call:rf.optional(),callError:G().optional()});function of(e){let t=null;for(let n of e)if(n.type===`merge.conflict`){let e=n.data??{};t={base:typeof e.base==`string`?e.base:``,files:Array.isArray(e.files)?e.files.filter(e=>typeof e==`string`):[],at:n.ts}}else[`burn.started`,`merge.resolved`,`feature.shipped`].includes(n.type)&&(t=null);return t}var sf=`/api/reviews`,cf=`/:featureId`;function lf(e){return`${sf}${cf.replace(`:featureId`,encodeURIComponent(e))}`}var uf=`/note/:noteId/screenshot`;`${uf}`;function df(e,t){return`${sf}${e.replace(`:noteId`,encodeURIComponent(t))}`}function ff(e){return df(uf,e)}var pf=`/project-note/:noteId/screenshot`;`${pf}`;function mf(e){return df(pf,e)}function hf(e){if(!Number.isFinite(e)||e<0)return`--:--`;let t=Math.floor(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=n>0?String(r).padStart(2,`0`):String(r);return`${n>0?`${n}:`:``}${a}:${String(i).padStart(2,`0`)}`}function gf(e,t){if(e.status!==`draft`)return null;let n=t.filter(e=>!e.satisfied);return e.upNext?n.length>0&&n.every(e=>e.status!==`archived`)?`upNext`:`stuck`:n.length>0?`blocked`:t.length>0?`readyToStart`:`backlog`}function _f(e){let t=e.find(e=>!e.satisfied&&e.status===`archived`);return t?`${t.slug} was archived — remove it or move this to the backlog`:`nothing left to wait on — start it or move it to the backlog`}function vf(e){return e.filter(e=>!e.satisfied&&e.status===`draft`&&!e.upNext)}function yf(e){return e.status===`shipped`}function bf(e){return e.filter(e=>e.kind!==`review`)}function xf(e){let t=bf(e),n=t.filter(e=>e.status===`cancelled`).length;return{landed:t.filter(e=>e.status===`done`).length,total:t.length-n,waived:n}}var Sf=Symbol.for(`drizzle:entityKind`);function Cf(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,Sf))throw Error(`Class "${t.name??`<unknown>`}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)for(;n;){if(Sf in n&&n[Sf]===t[Sf])return!0;n=Object.getPrototypeOf(n)}return!1}var wf=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[Sf]=`Column`;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}},Tf=class{static[Sf]=`ColumnBuilder`;config;constructor(e,t,n){this.config={name:e,keyAsName:e===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){this.config.name===``&&(this.config.name=e)}},Ef=Symbol.for(`drizzle:Name`),Df=Symbol.for(`drizzle:isPgEnum`);function Of(e){return!!e&&typeof e==`function`&&Df in e&&e[Df]===!0}var kf=class{static[Sf]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},Af={startActiveSpan(e,t){return t()}},jf=Symbol.for(`drizzle:ViewBaseConfig`),Mf=Symbol.for(`drizzle:Schema`),Nf=Symbol.for(`drizzle:Columns`),Pf=Symbol.for(`drizzle:ExtraConfigColumns`),Ff=Symbol.for(`drizzle:OriginalName`),If=Symbol.for(`drizzle:BaseName`),Lf=Symbol.for(`drizzle:IsAlias`),Rf=Symbol.for(`drizzle:ExtraConfigBuilder`),zf=Symbol.for(`drizzle:IsDrizzleTable`),Bf=class{static[Sf]=`Table`;static Symbol={Name:Ef,Schema:Mf,OriginalName:Ff,Columns:Nf,ExtraConfigColumns:Pf,BaseName:If,IsAlias:Lf,ExtraConfigBuilder:Rf};[Ef];[Ff];[Mf];[Nf];[Pf];[If];[Lf]=!1;[zf]=!0;[Rf]=void 0;constructor(e,t,n){this[Ef]=this[Ff]=e,this[Mf]=t,this[If]=n}};function Vf(e){return e!=null&&typeof e.getSQL==`function`}function Hf(e){let t={sql:``,params:[]};for(let n of e)t.sql+=n.sql,t.params.push(...n.params),n.typings?.length&&(t.typings||=[],t.typings.push(...n.typings));return t}var Uf=class{static[Sf]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Wf([this])}},Wf=class e{constructor(e){this.queryChunks=e;for(let t of e)if(Cf(t,Bf)){let e=t[Bf.Symbol.Schema];this.usedTables.push(e===void 0?t[Bf.Symbol.Name]:e+`.`+t[Bf.Symbol.Name])}}static[Sf]=`SQL`;decoder=Kf;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return Af.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{casing:i,escapeName:a,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:l}=r;return Hf(t.map(t=>{if(Cf(t,Uf))return{sql:t.value.join(``),params:[]};if(Cf(t,Gf))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new Uf(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new Uf(`, `));return e.push(new Uf(`)`)),this.buildQueryFromSourceParams(e,r)}if(Cf(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:c||t.shouldInlineParams});if(Cf(t,Bf)){let e=t[Bf.Symbol.Schema],n=t[Bf.Symbol.Name];return{sql:e===void 0||t[Lf]?a(n):a(e)+`.`+a(n),params:[]}}if(Cf(t,wf)){let e=i.getColumnCasing(t);if(n.invokeSource===`indexes`)return{sql:a(e),params:[]};let r=t.table[Bf.Symbol.Schema];return{sql:t.table[Lf]||r===void 0?a(t.table[Bf.Symbol.Name])+`.`+a(e):a(r)+`.`+a(t.table[Bf.Symbol.Name])+`.`+a(e),params:[]}}if(Cf(t,Qf)){let e=t[jf].schema,n=t[jf].name;return{sql:e===void 0||t[jf].isAlias?a(n):a(e)+`.`+a(n),params:[]}}if(Cf(t,Jf)){if(Cf(t.value,Xf))return{sql:o(l.value++,t),params:[t],typings:[`none`]};let n=t.value===null?null:t.encoder.mapToDriverValue(t.value);if(Cf(n,e))return this.buildQueryFromSourceParams([n],r);if(c)return{sql:this.mapInlineParam(n,r),params:[]};let i=[`none`];return s&&(i=[s(t.encoder)]),{sql:o(l.value++,n),params:[n],typings:i}}return Cf(t,Xf)?{sql:o(l.value++,t),params:[t],typings:[`none`]}:Cf(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:a(t.fieldAlias),params:[]}:Cf(t,kf)?t._.isWith?{sql:a(t._.alias),params:[]}:this.buildQueryFromSourceParams([new Uf(`(`),t._.sql,new Uf(`) `),new Gf(t._.alias)],r):Of(t)?t.schema?{sql:a(t.schema)+`.`+a(t.enumName),params:[]}:{sql:a(t.enumName),params:[]}:Vf(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new Uf(`(`),t.getSQL(),new Uf(`)`)],r):c?{sql:this.mapInlineParam(t,r),params:[]}:{sql:o(l.value++,t),params:[t],typings:[`none`]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`)return e.toString();if(typeof e==`string`)return t(e);if(typeof e==`object`){let n=e.toString();return t(n===`[object Object]`?JSON.stringify(e):n)}throw Error(`Unexpected param value: `+e)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(e){return this.decoder=typeof e==`function`?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}},Gf=class{constructor(e){this.value=e}static[Sf]=`Name`;brand;getSQL(){return new Wf([this])}},Kf={mapFromDriverValue:e=>e},qf={mapToDriverValue:e=>e};({...Kf,...qf});var Jf=class{constructor(e,t=qf){this.value=e,this.encoder=t}static[Sf]=`Param`;brand;getSQL(){return new Wf([this])}};function Yf(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new Uf(e[0]));for(let[r,i]of t.entries())n.push(i,new Uf(e[r+1]));return new Wf(n)}(e=>{function t(){return new Wf([])}e.empty=t;function n(e){return new Wf(e)}e.fromList=n;function r(e){return new Wf([new Uf(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new Wf(n)}e.join=i;function a(e){return new Gf(e)}e.identifier=a;function o(e){return new Xf(e)}e.placeholder=o;function s(e,t){return new Jf(e,t)}e.param=s})(Yf||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[Sf]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Wf||={});var Xf=class{constructor(e){this.name=e}static[Sf]=`Placeholder`;getSQL(){return new Wf([this])}},Zf=Symbol.for(`drizzle:IsDrizzleView`),Qf=class{static[Sf]=`View`;[jf];[Zf]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[jf]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new Wf([this])}};wf.prototype.getSQL=function(){return new Wf([this])},Bf.prototype.getSQL=function(){return new Wf([this])},kf.prototype.getSQL=function(){return new Wf([this])};function $f(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var ep=typeof TextDecoder>`u`?null:new TextDecoder,tp=class{static[Sf]=`SQLiteForeignKeyBuilder`;reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new np(e,this)}},np=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[Sf]=`SQLiteForeignKey`;reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[Ef],...r,n[0].table[Ef],...i];return e??`${a.join(`_`)}_fk`}};function rp(e,t){return`${e[Ef]}_${t.join(`_`)}_unique`}var ip=class extends Tf{static[Sf]=`SQLiteColumnBuilder`;foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:`always`,mode:t?.mode??`virtual`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((n,r)=>{let i=new tp(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)})(n,r))}},ap=class extends wf{constructor(e,t){t.uniqueName||=rp(e,[t.name]),super(e,t),this.table=e}static[Sf]=`SQLiteColumn`},op=class extends ip{static[Sf]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteBigInt`)}build(e){return new sp(e,this.config)}},sp=class extends ap{static[Sf]=`SQLiteBigInt`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString(`utf8`))}return BigInt(ep.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},cp=class extends ip{static[Sf]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`json`,`SQLiteBlobJson`)}build(e){return new lp(e,this.config)}},lp=class extends ap{static[Sf]=`SQLiteBlobJson`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString(`utf8`))}return JSON.parse(ep.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},up=class extends ip{static[Sf]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`buffer`,`SQLiteBlobBuffer`)}build(e){return new dp(e,this.config)}},dp=class extends ap{static[Sf]=`SQLiteBlobBuffer`;mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return`blob`}};function fp(e,t){let{name:n,config:r}=$f(e,t);return r?.mode===`json`?new cp(n):r?.mode===`bigint`?new op(n):new up(n)}var pp=class extends ip{static[Sf]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new mp(e,this.config)}},mp=class extends ap{static[Sf]=`SQLiteCustomColumn`;sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==`function`?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==`function`?this.mapTo(e):e}};function hp(e){return(t,n)=>{let{name:r,config:i}=$f(t,n);return new pp(r,i,e)}}var gp=class extends ip{static[Sf]=`SQLiteBaseIntegerBuilder`;constructor(e,t,n){super(e,t,n),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}},_p=class extends ap{static[Sf]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},vp=class extends gp{static[Sf]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number`,`SQLiteInteger`)}build(e){return new yp(e,this.config)}},yp=class extends _p{static[Sf]=`SQLiteInteger`},bp=class extends gp{static[Sf]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(Yf`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new xp(e,this.config)}},xp=class extends _p{static[Sf]=`SQLiteTimestamp`;mode=this.config.mode;mapFromDriverValue(e){return this.config.mode===`timestamp`?new Date(e*1e3):new Date(e)}mapToDriverValue(e){let t=e.getTime();return this.config.mode===`timestamp`?Math.floor(t/1e3):t}},Sp=class extends gp{static[Sf]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new Cp(e,this.config)}},Cp=class extends _p{static[Sf]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return+!!e}};function wp(e,t){let{name:n,config:r}=$f(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new bp(n,r.mode):r?.mode===`boolean`?new Sp(n,r.mode):new vp(n)}var Tp=class extends ip{static[Sf]=`SQLiteNumericBuilder`;constructor(e){super(e,`string`,`SQLiteNumeric`)}build(e){return new Ep(e,this.config)}},Ep=class extends ap{static[Sf]=`SQLiteNumeric`;mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return`numeric`}},Dp=class extends ip{static[Sf]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new Op(e,this.config)}},Op=class extends ap{static[Sf]=`SQLiteNumericNumber`;mapFromDriverValue(e){return typeof e==`number`?e:Number(e)}mapToDriverValue=String;getSQLType(){return`numeric`}},kp=class extends ip{static[Sf]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteNumericBigInt`)}build(e){return new Ap(e,this.config)}},Ap=class extends ap{static[Sf]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function jp(e,t){let{name:n,config:r}=$f(e,t),i=r?.mode;return i===`number`?new Dp(n):i===`bigint`?new kp(n):new Tp(n)}var Mp=class extends ip{static[Sf]=`SQLiteRealBuilder`;constructor(e){super(e,`number`,`SQLiteReal`)}build(e){return new Np(e,this.config)}},Np=class extends ap{static[Sf]=`SQLiteReal`;getSQLType(){return`real`}};function Pp(e){return new Mp(e??``)}var Fp=class extends ip{static[Sf]=`SQLiteTextBuilder`;constructor(e,t){super(e,`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Ip(e,this.config)}},Ip=class extends ap{static[Sf]=`SQLiteText`;enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},Lp=class extends ip{static[Sf]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`json`,`SQLiteTextJson`)}build(e){return new Rp(e,this.config)}},Rp=class extends ap{static[Sf]=`SQLiteTextJson`;getSQLType(){return`text`}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};function q(e,t={}){let{name:n,config:r}=$f(e,t);return r.mode===`json`?new Lp(n):new Fp(n,r)}function zp(){return{blob:fp,customType:hp,integer:wp,numeric:jp,real:Pp,text:q}}var Bp=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),Vp=class extends Bf{static[Sf]=`SQLiteTable`;static Symbol=Object.assign({},Bf.Symbol,{InlineForeignKeys:Bp});[Bf.Symbol.Columns];[Bp]=[];[Bf.Symbol.ExtraConfigBuilder]=void 0};function Hp(e,t,n,r,i=e){let a=new Vp(e,r,i),o=typeof t==`function`?t(zp()):t,s=Object.fromEntries(Object.entries(o).map(([e,t])=>{let n=t;n.setName(e);let r=n.build(a);return a[Bp].push(...n.buildForeignKeys(r,a)),[e,r]})),c=Object.assign(a,s);return c[Bf.Symbol.Columns]=s,c[Bf.Symbol.ExtraConfigColumns]=s,n&&(c[Vp.Symbol.ExtraConfigBuilder]=n),c}var Up=(e,t,n)=>Hp(e,t,n),Wp=class{constructor(e,t){this.name=e,this.unique=t}static[Sf]=`SQLiteIndexBuilderOn`;on(...e){return new Gp(this.name,e,this.unique)}},Gp=class{static[Sf]=`SQLiteIndexBuilder`;config;constructor(e,t,n){this.config={name:e,columns:t,unique:n,where:void 0}}where(e){return this.config.where=e,this}build(e){return new Kp(this.config,e)}},Kp=class{static[Sf]=`SQLiteIndex`;config;constructor(e,t){this.config={...e,table:t}}};function qp(e){return new Wp(e,!1)}function Jp(...e){return e[0].columns?new Yp(e[0].columns,e[0].name):new Yp(e)}var Yp=class{static[Sf]=`SQLitePrimaryKeyBuilder`;columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new Xp(e,this.columns,this.name)}},Xp=class{constructor(e,t,n){this.table=e,this.columns=t,this.name=n}static[Sf]=`SQLitePrimaryKey`;columns;name;getName(){return this.name??`${this.table[Vp.Symbol.Name]}_${this.columns.map(e=>e.name).join(`_`)}_pk`}};Up(`projects`,{id:q(`id`).primaryKey(),name:q(`name`).notNull(),repoPath:q(`repo_path`).notNull(),sessionBranch:q(`session_branch`),devCommand:q(`dev_command`),model:q(`model`),sandbox:q(`sandbox`),sandboxImage:q(`sandbox_image`),closedAt:wp(`closed_at`),setupCommand:q(`setup_command`),verifyCommands:q(`verify_commands`),knownFailures:q(`known_failures`),dbResetCommand:q(`db_reset_command`),driveInstructions:q(`drive_instructions`),driveSetupCommand:q(`drive_setup_command`),driveStopCommand:q(`drive_stop_command`),scenarioRunner:q(`scenario_runner`),docsCommitPrefix:q(`docs_commit_prefix`)}),Up(`project_findings`,{projectId:q(`project_id`).notNull(),key:q(`key`).notNull(),source:q(`source`).notNull().$type(),evidence:q(`evidence`),establishedAt:wp(`established_at`).notNull(),establishedSha:q(`established_sha`),verifiedAt:wp(`verified_at`),verifiedSha:q(`verified_sha`)},e=>[Jp({columns:[e.projectId,e.key]})]);var Zp=Up(`features`,{id:q(`id`).primaryKey(),projectId:q(`project_id`).notNull(),slug:q(`slug`).notNull(),title:q(`title`).notNull(),oneLiner:q(`one_liner`).notNull(),brief:q(`brief`),branch:q(`branch`).notNull(),baseBranch:q(`base_branch`),status:q(`status`).notNull().$type(),createdAt:wp(`created_at`).notNull(),upNext:wp(`up_next`,{mode:`boolean`}).notNull().default(!1),stoppedAt:wp(`stopped_at`),waitingReason:q(`waiting_reason`),lastHumanMessageAt:wp(`last_human_message_at`),lastDispatchAt:wp(`last_dispatch_at`)});Up(`ready_declarations`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),runId:q(`run_id`),scenario:q(`scenario`).notNull(),createdAt:wp(`created_at`).notNull()}),Up(`feature_dependencies`,{dependentId:q(`dependent_id`).notNull().references(()=>Zp.id,{onDelete:`cascade`}),dependencyId:q(`dependency_id`).notNull().references(()=>Zp.id,{onDelete:`cascade`}),createdAt:wp(`created_at`).notNull()},e=>[Jp({columns:[e.dependentId,e.dependencyId]})]),Up(`sessions`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`),projectId:q(`project_id`),kind:q(`kind`).notNull().$type(),purpose:q(`purpose`).$type(),purposeData:q(`purpose_data`,{mode:`json`}).$type(),ccSessionId:q(`cc_session_id`),transcriptPath:q(`transcript_path`),status:q(`status`).notNull().$type(),awaitingInput:wp(`awaiting_input`,{mode:`boolean`}).notNull().default(!1),headless:wp(`headless`,{mode:`boolean`}).notNull().default(!1),worktreePath:q(`worktree_path`).notNull(),model:q(`model`),runtime:q(`runtime`).$type(),title:q(`title`),createdAt:wp(`created_at`),endedAt:wp(`ended_at`),tokens:wp(`tokens`),tokenBreakdown:q(`token_breakdown`,{mode:`json`}).$type(),openedBeside:q(`opened_beside`)}),Up(`tickets`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:wp(`seq`).notNull(),title:q(`title`).notNull(),goal:q(`goal`).notNull(),context:q(`context`).notNull(),acceptanceCriteria:q(`acceptance_criteria`,{mode:`json`}).notNull().$type(),seams:q(`seams`,{mode:`json`}).notNull().$type(),blockedBy:q(`blocked_by`,{mode:`json`}).notNull().$type(),kind:q(`kind`).notNull().$type().default(`implementation`),passKind:q(`pass_kind`).notNull().$type().default(`review`),reviewedCommit:q(`reviewed_commit`),reviewMode:q(`review_mode`).$type(),reviewVerdict:q(`review_verdict`).$type(),reviewVerdictReason:q(`review_verdict_reason`),reviewGateRun:q(`review_gate_run`,{mode:`json`}).$type(),completedAt:wp(`completed_at`),model:q(`model`),status:q(`status`).notNull().$type(),commits:q(`commits`,{mode:`json`}).notNull().$type(),error:q(`error`),attemptBranch:q(`attempt_branch`),conflictFiles:q(`conflict_files`,{mode:`json`}).$type(),digest:q(`digest`),originFindingId:q(`origin_finding_id`),tokens:wp(`tokens`),tokenBreakdown:q(`token_breakdown`,{mode:`json`}).$type()}),Up(`review_findings`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),reviewTicketId:q(`review_ticket_id`).notNull(),kind:q(`kind`).notNull().$type(),severity:q(`severity`).notNull().$type(),title:q(`title`).notNull(),location:q(`location`).notNull(),citation:q(`citation`).notNull(),detail:q(`detail`).notNull(),reproStep:q(`repro_step`).notNull(),status:q(`status`).notNull().$type(),openReason:q(`open_reason`).$type(),failureReason:q(`failure_reason`),fixTicketId:q(`fix_ticket_id`),resolvedBy:q(`resolved_by`).$type(),resolutionNote:q(`resolution_note`),createdAt:wp(`created_at`).notNull()}),Up(`test_notes`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),text:q(`text`).notNull(),status:q(`status`).notNull().$type(),author:q(`author`).notNull().$type().default(`human`),ticketId:q(`ticket_id`),reviewTicketId:q(`review_ticket_id`),videoTimestamp:Pp(`video_timestamp`),sentAt:wp(`sent_at`),createdAt:wp(`created_at`).notNull(),updatedAt:wp(`updated_at`).notNull()}),Up(`project_notes`,{id:q(`id`).primaryKey(),projectId:q(`project_id`).notNull(),text:q(`text`).notNull(),status:q(`status`).notNull().$type(),outcome:q(`outcome`),featureId:q(`feature_id`),driveBranch:q(`drive_branch`),driveCommit:q(`drive_commit`),createdAt:wp(`created_at`).notNull(),updatedAt:wp(`updated_at`).notNull()}),Up(`runs`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),workflow:q(`workflow`).notNull(),status:q(`status`).notNull().$type(),startedAt:wp(`started_at`).notNull(),endedAt:wp(`ended_at`),summary:q(`summary`),digest:q(`digest`),gates:q(`gates`,{mode:`json`}).$type()}),Up(`events`,{id:wp(`id`).primaryKey({autoIncrement:!0}),projectId:q(`project_id`).notNull(),featureId:q(`feature_id`),runId:q(`run_id`),ticketId:q(`ticket_id`),ts:wp(`ts`).notNull(),type:q(`type`).notNull(),message:q(`message`).notNull(),data:q(`data`,{mode:`json`})},e=>[qp(`events_project_id_id_idx`).on(e.projectId,e.id),qp(`events_feature_id_id_idx`).on(e.featureId,e.id)]);var Qp={setupCommand:`Setup`,verifyCommands:`Verify`,knownFailures:`Known failing tests`,devCommand:`Dev server`,dbResetCommand:`Reset dev database`,driveSetupCommand:`Before a test drive`,driveStopCommand:`After a test drive`,driveInstructions:`How to drive this app`,sandboxImage:`Sandbox image`},$p=new Set([`devCommand`,`dbResetCommand`,`driveSetupCommand`,`driveStopCommand`]);function em(e,t=Date.now()){let n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return`just now`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<36?`${i}h ago`:`${Math.round(i/24)}d ago`}function tm(e){return Gd.includes(e)}function nm(e){return`${rm(e)}${eee(e)}`}function eee(e){return tm(e.key)?e.verifiedAt===void 0?` Unverified — never proven by a dry run.`:` Verified ${em(e.verifiedAt)} by a dry run.`:``}function rm(e){if(e.source===`human`)return`You set this ${em(e.establishedAt)}.`;let t=e.source===`build`?`Built by runcastle from the repo Dockerfile`:e.source===`session`?`Established in a conversation on this machine`:$p.has(e.key)?`Proposed by preparation from config (not executed)`:`Established by preparation`,n=em(e.establishedAt);return e.staleCommits===void 0?`${t} ${n}${e.establishedSha?` — age against main unknown`:``}.`:e.staleCommits===0?`${t} ${n} — main has not moved since.`:`${t} ${n} — main has moved ${e.staleCommits} commit${e.staleCommits===1?``:`s`} since.`}function im(e){return e.source!==`human`&&(e.staleCommits??0)>=100}function am(e){return e.source===`human`?{label:`Yours`,title:`You set this by hand — preparation will never overwrite it`}:e.source===`build`?{label:`Built`,title:`Built by runcastle from this repo's own Dockerfile`}:e.source===`session`?{label:`Verified`,title:`Established in a conversation on your own machine`}:$p.has(e.key)?{label:`Proposed`,title:`Read from config by an older automatic run, not executed`}:{label:`Measured`,title:`Measured by an older automatic run, in a sandbox`}}var om={serverPort:`RUNCASTLE_SERVER_PORT`,model:`RUNCASTLE_MODEL`,sandbox:`RUNCASTLE_SANDBOX`,sandboxImage:`RUNCASTLE_SANDBOX_IMAGE`,sessionMcp:`RUNCASTLE_SESSION_MCP`,burnConcurrency:`RUNCASTLE_BURN_CONCURRENCY`,burnMaxIterations:`RUNCASTLE_BURN_MAX_ITERATIONS`,burnAttempts:`RUNCASTLE_BURN_ATTEMPTS`,burnConflictAttempts:`RUNCASTLE_BURN_CONFLICT_ATTEMPTS`,burnCpus:`RUNCASTLE_BURN_CPUS`,setupCommand:`RUNCASTLE_SETUP_COMMAND`,verifyCommands:`RUNCASTLE_VERIFY_COMMANDS`,knownFailures:`RUNCASTLE_KNOWN_FAILURES`},sm={"claude-code":`Claude Code`,codex:`Codex`},tee={general:[`server`,`sessions`],models:[`default`],burns:[`width`],project:[`model`,`commands`,`chat`]};function cm(e){let t=e?.fields.find(e=>e.key===`models`)?.value;return Array.isArray(t)?t.flatMap(e=>{let t=md.safeParse(e);return t.success?[t.data]:[]}):[]}function lm(e){return bd({discovered:xd(e?.discovery??tf),models:cm(e)})}function um(e){return dd.map(t=>({runtime:t,label:sm[t],entries:e.filter(e=>e.runtime===t)})).filter(e=>e.entries.length>0)}function dm(e,t,n){let r=e.trim();if(r===``)return{error:`Enter a model id.`};if(!dd.includes(t))return{error:`Choose which runtime this model runs on.`};let i=n.trim();return{entry:{id:r,runtime:t,...i?{note:i}:{}}}}var fm=`stepModels.`;function pm(e){return e.startsWith(fm)}function mm(e){return e.slice(11)}var hm=[{step:`chat`,label:`Chat`,group:`sessions`,description:`The feature conversation`},{step:`project`,label:`Project chat`,group:`sessions`,description:`The project-level conversation`},{step:`implement`,label:`Implement`,group:`unattended`,description:`Works a ticket in the sandbox`},{step:`review`,label:`Review`,group:`unattended`,description:`Reads the finished branch`},{step:`prepare`,label:`Prepare`,group:`unattended`,description:`Measures setup, verify and baseline`},{step:`smoke`,label:`Smoke`,group:`unattended`,description:`Cheap scripted end-to-end check`}],nee=Object.fromEntries(hm.map(e=>[e.step,e.label]));function gm(e){return`${fm}${e}`}ld.map(gm);var _m=`Applies inside the app under test only — it changes no review rule and permits no edit to the repo under review.`,vm={serverPort:{label:`Server port`,tooltip:`The port the runcastle server listens on. Changing it takes effect at the next server restart.`,control:`number`,page:`general`,group:`server`},model:{label:`Default model`,tooltip:`Runs every step that has no model of its own below — and every project that has not set one.`,control:`select`,page:`models`,group:`default`},sandbox:{label:`Sandbox`,tooltip:`Where launched sessions and workers run. A Docker container isolates them from this machine; “no sandbox” runs them directly on it.`,control:`select`,page:`general`,group:`sessions`,options:[`docker`,`noSandbox`],optionLabels:{docker:`Docker container (isolated)`,noSandbox:`No sandbox — run directly on this machine`}},sandboxImage:{label:`Sandbox image`,tooltip:`The Docker image sessions and workers are sandboxed in. Leave blank to use sandcastle:runcastle, the image “Build image” on the Workers page produces.`,control:`text`,page:`general`,group:`sessions`,placeholder:`sandcastle:runcastle`},sessionMcp:{label:`MCP servers in sessions`,tooltip:`Inherit mine — sessions see your own MCP servers (user, project and plugin) alongside runcastle’s. runcastle only — sessions see runcastle’s server and nothing else; use it for a reproducible tool surface or to keep a heavy personal MCP set out of the context window.`,control:`select`,page:`general`,group:`sessions`,options:[`inherit`,`runcastleOnly`],optionLabels:{inherit:`Inherit mine — my servers alongside runcastle’s`,runcastleOnly:`runcastle only — nothing else`}},burnConcurrency:{label:`Concurrency`,tooltip:`Tickets a round works in parallel (1–8). Each is a full worker with its own container, sizing its install and test workers from the whole core count — lower it if suites die under load.`,control:`number`,page:`burns`,group:`width`,unit:`tickets at once`},burnMaxIterations:{label:`Iterations per attempt`,tooltip:`Turns one healthy worker may take before it is stopped (1–10). A ticket that finishes early stops the loop itself.`,control:`number`,page:`burns`,group:`width`,shortHelp:`Distinct from attempts: an attempt restarts an agent that crashed.`,unit:`turns`},burnAttempts:{label:`Attempts per ticket`,tooltip:`Fresh agent attempts per ticket per run (1–5). A transient crash — API drop, network, rate limit — retries with committed work preserved; auth errors and conflicts never retry.`,control:`number`,page:`burns`,group:`width`,unit:`attempts`},burnConflictAttempts:{label:`Conflict resolver passes`,tooltip:`Agent passes spent resolving a ticket’s landing conflict before asking you (0–3). 0 sends every conflict straight to you.`,control:`number`,page:`burns`,group:`width`,unit:`passes before asking you`},burnCpus:{label:`CPU limit per worker`,tooltip:`CPU ceiling per worker container (--cpus). Blank leaves it unconstrained. Roughly cores ÷ concurrency keeps parallel tickets from oversubscribing the machine.`,control:`number`,page:`burns`,group:`width`,placeholder:`unlimited`,unit:`cores · e.g. 4 on a 12-thread box at width 3`},setupCommand:{label:`Setup`,tooltip:`Takes a clean checkout to a buildable state inside the worker sandbox — dependency install plus any codegen. Blank auto-detects from the lockfile.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. pnpm install --frozen-lockfile && pnpm prisma:generate`},verifyCommands:{label:`Verify`,tooltip:`The exact typecheck / test / lint commands, one per line. Every worker is told to run them, and runcastle runs them itself at the end of every round and hands the results to the agent.`,control:`textarea`,page:`project`,group:`commands`,placeholder:`one per line, e.g.
72
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Hc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Gc(t,`input`,e.processors),output:Gc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Uc(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Uc(r.element,n);if(r.type===`set`)return Uc(r.valueType,n);if(r.type===`lazy`)return Uc(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Uc(r.innerType,n);if(r.type===`intersection`)return Uc(r.left,n)||Uc(r.right,n);if(r.type===`record`||r.type===`map`)return Uc(r.keyType,n)||Uc(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Uc(r.in,n)||Uc(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Uc(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Uc(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Uc(e,n))return!0;return!!(r.rest&&Uc(r.rest,n))}return!1}var Wc=(e,t={})=>n=>{let r=zc({...n,processors:t});return Bc(e,r),Vc(r,e),Hc(r,e)},Gc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=zc({...i??{},target:a,io:t,processors:n});return Bc(e,o),Vc(o,e),Hc(o,e)},Kc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},qc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Kc[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Jc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Yc=(e,t,n,r)=>{n.type=`boolean`},Xc=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Zc=(e,t,n,r)=>{n.not={}},Qc=(e,t,n,r)=>{let i=e._zod.def,a=mi(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},$c=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},el=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},tl=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},nl=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Bc(a.element,t,{...r,path:[...r.path,`items`]})},rl=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Bc(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Bc(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},il=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Bc(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},al=(e,t,n,r)=>{let i=e._zod.def,a=Bc(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Bc(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ol=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>Bc(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?Bc(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},sl=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Bc(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Bc(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Bc(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},cl=(e,t,n,r)=>{let i=e._zod.def,a=Bc(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ll=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ul=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},dl=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},fl=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},pl=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Bc(o,t,r);let s=t.seen.get(e);s.ref=o},ml=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},hl=(e,t,n,r)=>{let i=e._zod.def;Bc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gl=U(`ZodISODateTime`,(e,t)=>{Do.init(e,t),Hl.init(e,t)});function _l(e){return ac(gl,e)}var vl=U(`ZodISODate`,(e,t)=>{Oo.init(e,t),Hl.init(e,t)});function yl(e){return oc(vl,e)}var bl=U(`ZodISOTime`,(e,t)=>{ko.init(e,t),Hl.init(e,t)});function xl(e){return sc(bl,e)}var Sl=U(`ZodISODuration`,(e,t)=>{Ao.init(e,t),Hl.init(e,t)});function Cl(e){return cc(Sl,e)}var wl=U(`ZodError`,(e,t)=>{Zi.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>ea(e,t)},flatten:{value:t=>$i(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,hi,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,hi,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Tl=ta(wl),El=na(wl),Dl=ra(wl),Ol=aa(wl),kl=sa(wl),Al=ca(wl),jl=la(wl),Ml=ua(wl),Nl=da(wl),Pl=fa(wl),Fl=pa(wl),Il=ma(wl),Ll=new WeakMap;function Rl(e,t,n){let r=Object.getPrototypeOf(e),i=Ll.get(r);if(i||(i=new Set,Ll.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var zl=U(`ZodType`,(e,t)=>(po.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Gc(e,`input`),output:Gc(e,`output`)}}),e.toJSONSchema=Wc(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Tl(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Dl(e,t,n),e.parseAsync=async(t,n)=>El(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ol(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>kl(e,t,n),e.decode=(t,n)=>Al(e,t,n),e.encodeAsync=async(t,n)=>jl(e,t,n),e.decodeAsync=async(t,n)=>Ml(e,t,n),e.safeEncode=(t,n)=>Nl(e,t,n),e.safeDecode=(t,n)=>Pl(e,t,n),e.safeEncodeAsync=async(t,n)=>Fl(e,t,n),e.safeDecodeAsync=async(t,n)=>Il(e,t,n),Rl(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Ci(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Ni(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(od(e,t))},superRefine(e,t){return this.check(sd(e,t))},overwrite(e){return this.check(kc(e))},optional(){return Vu(this)},exactOptional(){return Uu(this)},nullable(){return Gu(this)},nullish(){return Vu(Gu(this))},nonoptional(e){return Zu(this,e)},array(){return bu(this)},or(e){return wu([this,e])},and(e){return Ou(this,e)},transform(e){return td(this,zu(e))},default(e){return qu(this,e)},prefault(e){return Yu(this,e)},catch(e){return $u(this,e)},pipe(e){return td(this,e)},readonly(){return id(this)},describe(e){let t=this.clone();return Fs.add(t,{description:e}),t},meta(...e){if(e.length===0)return Fs.get(this);let t=this.clone();return Fs.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Fs.get(e)?.description},configurable:!0}),e)),Bl=U(`_ZodString`,(e,t)=>{mo.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qc(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Rl(e,`_ZodString`,{regex(...e){return this.check(Cc(...e))},includes(...e){return this.check(Ec(...e))},startsWith(...e){return this.check(Dc(...e))},endsWith(...e){return this.check(Oc(...e))},min(...e){return this.check(xc(...e))},max(...e){return this.check(bc(...e))},length(...e){return this.check(Sc(...e))},nonempty(...e){return this.check(xc(1,...e))},lowercase(e){return this.check(wc(e))},uppercase(e){return this.check(Tc(e))},trim(){return this.check(jc())},normalize(...e){return this.check(Ac(...e))},toLowerCase(){return this.check(Mc())},toUpperCase(){return this.check(Nc())},slugify(){return this.check(Pc())}})}),Vl=U(`ZodString`,(e,t)=>{mo.init(e,t),Bl.init(e,t),e.email=t=>e.check(Ls(Ul,t)),e.url=t=>e.check(Us(Kl,t)),e.jwt=t=>e.check(ic(su,t)),e.emoji=t=>e.check(Ws(ql,t)),e.guid=t=>e.check(Rs(Wl,t)),e.uuid=t=>e.check(zs(Gl,t)),e.uuidv4=t=>e.check(Bs(Gl,t)),e.uuidv6=t=>e.check(Vs(Gl,t)),e.uuidv7=t=>e.check(Hs(Gl,t)),e.nanoid=t=>e.check(Gs(Jl,t)),e.guid=t=>e.check(Rs(Wl,t)),e.cuid=t=>e.check(Ks(Yl,t)),e.cuid2=t=>e.check(qs(Xl,t)),e.ulid=t=>e.check(Js(Zl,t)),e.base64=t=>e.check(tc(iu,t)),e.base64url=t=>e.check(nc(au,t)),e.xid=t=>e.check(Ys(Ql,t)),e.ksuid=t=>e.check(Xs($l,t)),e.ipv4=t=>e.check(Zs(eu,t)),e.ipv6=t=>e.check(Qs(tu,t)),e.cidrv4=t=>e.check($s(nu,t)),e.cidrv6=t=>e.check(ec(ru,t)),e.e164=t=>e.check(rc(ou,t)),e.datetime=t=>e.check(_l(t)),e.date=t=>e.check(yl(t)),e.time=t=>e.check(xl(t)),e.duration=t=>e.check(Cl(t))});function G(e){return Is(Vl,e)}var Hl=U(`ZodStringFormat`,(e,t)=>{ho.init(e,t),Bl.init(e,t)}),Ul=U(`ZodEmail`,(e,t)=>{vo.init(e,t),Hl.init(e,t)}),Wl=U(`ZodGUID`,(e,t)=>{go.init(e,t),Hl.init(e,t)}),Gl=U(`ZodUUID`,(e,t)=>{_o.init(e,t),Hl.init(e,t)}),Kl=U(`ZodURL`,(e,t)=>{yo.init(e,t),Hl.init(e,t)}),ql=U(`ZodEmoji`,(e,t)=>{bo.init(e,t),Hl.init(e,t)}),Jl=U(`ZodNanoID`,(e,t)=>{xo.init(e,t),Hl.init(e,t)}),Yl=U(`ZodCUID`,(e,t)=>{So.init(e,t),Hl.init(e,t)}),Xl=U(`ZodCUID2`,(e,t)=>{Co.init(e,t),Hl.init(e,t)}),Zl=U(`ZodULID`,(e,t)=>{wo.init(e,t),Hl.init(e,t)}),Ql=U(`ZodXID`,(e,t)=>{To.init(e,t),Hl.init(e,t)}),$l=U(`ZodKSUID`,(e,t)=>{Eo.init(e,t),Hl.init(e,t)}),eu=U(`ZodIPv4`,(e,t)=>{jo.init(e,t),Hl.init(e,t)}),tu=U(`ZodIPv6`,(e,t)=>{Mo.init(e,t),Hl.init(e,t)}),nu=U(`ZodCIDRv4`,(e,t)=>{No.init(e,t),Hl.init(e,t)}),ru=U(`ZodCIDRv6`,(e,t)=>{Po.init(e,t),Hl.init(e,t)}),iu=U(`ZodBase64`,(e,t)=>{Io.init(e,t),Hl.init(e,t)}),au=U(`ZodBase64URL`,(e,t)=>{Ro.init(e,t),Hl.init(e,t)}),ou=U(`ZodE164`,(e,t)=>{zo.init(e,t),Hl.init(e,t)}),su=U(`ZodJWT`,(e,t)=>{Vo.init(e,t),Hl.init(e,t)}),cu=U(`ZodNumber`,(e,t)=>{Ho.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jc(e,t,n,r),Rl(e,`ZodNumber`,{gt(e,t){return this.check(_c(e,t))},gte(e,t){return this.check(vc(e,t))},min(e,t){return this.check(vc(e,t))},lt(e,t){return this.check(hc(e,t))},lte(e,t){return this.check(gc(e,t))},max(e,t){return this.check(gc(e,t))},int(e){return this.check(uu(e))},safe(e){return this.check(uu(e))},positive(e){return this.check(_c(0,e))},nonnegative(e){return this.check(vc(0,e))},negative(e){return this.check(hc(0,e))},nonpositive(e){return this.check(gc(0,e))},multipleOf(e,t){return this.check(yc(e,t))},step(e,t){return this.check(yc(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function K(e){return lc(cu,e)}var lu=U(`ZodNumberFormat`,(e,t)=>{Uo.init(e,t),cu.init(e,t)});function uu(e){return uc(lu,e)}var du=U(`ZodBoolean`,(e,t)=>{Wo.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yc(e,t,n,r)});function fu(e){return dc(du,e)}var pu=U(`ZodNull`,(e,t)=>{Go.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xc(e,t,n,r)});function mu(e){return fc(pu,e)}var hu=U(`ZodUnknown`,(e,t)=>{Ko.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function gu(){return pc(hu)}var _u=U(`ZodNever`,(e,t)=>{qo.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zc(e,t,n,r)});function vu(e){return mc(_u,e)}var yu=U(`ZodArray`,(e,t)=>{Yo.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nl(e,t,n,r),e.element=t.element,Rl(e,`ZodArray`,{min(e,t){return this.check(xc(e,t))},nonempty(e){return this.check(xc(1,e))},max(e,t){return this.check(bc(e,t))},length(e,t){return this.check(Sc(e,t))},unwrap(){return this.element}})});function bu(e,t){return Fc(yu,e,t)}var xu=U(`ZodObject`,(e,t)=>{es.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rl(e,t,n,r),xi(e,`shape`,()=>t.shape),Rl(e,`ZodObject`,{keyof(){return Fu(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:gu()})},loose(){return this.clone({...this._zod.def,catchall:gu()})},strict(){return this.clone({...this._zod.def,catchall:vu()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Ri(this,e)},safeExtend(e){return zi(this,e)},merge(e){return Bi(this,e)},pick(e){return Ii(this,e)},omit(e){return Li(this,e)},partial(...e){return Vi(Bu,this,e[0])},required(...e){return Hi(Xu,this,e[0])}})});function Su(e,t){return new xu({type:`object`,shape:e??{},...W(t)})}var Cu=U(`ZodUnion`,(e,t)=>{ns.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r),e.options=t.options});function wu(e,t){return new Cu({type:`union`,options:e,...W(t)})}var Tu=U(`ZodDiscriminatedUnion`,(e,t)=>{Cu.init(e,t),rs.init(e,t)});function Eu(e,t,n){return new Tu({type:`union`,options:t,discriminator:e,...W(n)})}var Du=U(`ZodIntersection`,(e,t)=>{is.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r)});function Ou(e,t){return new Du({type:`intersection`,left:e,right:t})}var ku=U(`ZodTuple`,(e,t)=>{ss.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function Au(e,t,n){let r=t instanceof po;return new ku({type:`tuple`,items:e,rest:r?t:null,...W(r?n:t)})}var ju=U(`ZodRecord`,(e,t)=>{ds.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Mu(e,t,n){return!t||!t._zod?new ju({type:`record`,keyType:G(),valueType:e,...W(t)}):new ju({type:`record`,keyType:e,valueType:t,...W(n)})}function Nu(e,t,n){let r=Ni(e);return r._zod.values=void 0,new ju({type:`record`,keyType:r,valueType:t,...W(n)})}var Pu=U(`ZodEnum`,(e,t)=>{fs.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qc(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Pu({...t,checks:[],...W(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Pu({...t,checks:[],...W(r),entries:i})}});function Fu(e,t){return new Pu({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...W(t)})}var Iu=U(`ZodLiteral`,(e,t)=>{ps.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Lu(e,t){return new Iu({type:`literal`,values:Array.isArray(e)?e:[e],...W(t)})}var Ru=U(`ZodTransform`,(e,t)=>{ms.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tl(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new di(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Yi(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Yi(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function zu(e){return new Ru({type:`transform`,transform:e})}var Bu=U(`ZodOptional`,(e,t)=>{gs.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vu(e){return new Bu({type:`optional`,innerType:e})}var Hu=U(`ZodExactOptional`,(e,t)=>{_s.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Uu(e){return new Hu({type:`optional`,innerType:e})}var Wu=U(`ZodNullable`,(e,t)=>{vs.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gu(e){return new Wu({type:`nullable`,innerType:e})}var Ku=U(`ZodDefault`,(e,t)=>{ys.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ul(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qu(e,t){return new Ku({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ai(t)}})}var Ju=U(`ZodPrefault`,(e,t)=>{xs.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yu(e,t){return new Ju({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ai(t)}})}var Xu=U(`ZodNonOptional`,(e,t)=>{Ss.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zu(e,t){return new Xu({type:`nonoptional`,innerType:e,...W(t)})}var Qu=U(`ZodCatch`,(e,t)=>{ws.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $u(e,t){return new Qu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ed=U(`ZodPipe`,(e,t)=>{Ts.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pl(e,t,n,r),e.in=t.in,e.out=t.out});function td(e,t){return new ed({type:`pipe`,in:e,out:t})}var nd=U(`ZodPreprocess`,(e,t)=>{ed.init(e,t),Ds.init(e,t)}),rd=U(`ZodReadonly`,(e,t)=>{Os.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ml(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function id(e){return new rd({type:`readonly`,innerType:e})}var ad=U(`ZodCustom`,(e,t)=>{As.init(e,t),zl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>el(e,t,n,r)});function od(e,t={}){return Ic(ad,e,t)}function sd(e,t){return Lc(e,t)}function cd(e,t){return new nd({type:`pipe`,in:zu(e),out:t})}var ld=[`chat`,`implement`,`review`,`prepare`,`project`,`smoke`],ud=Fu(ld),dd=[`claude-code`,`codex`],fd=Fu(dd),pd=`claude-code`,md=Su({id:G().min(1),runtime:fd,note:G().optional()}),hd={"claude-code":{flagship:`claude-opus-5`,smoke:`claude-haiku-4-5`},codex:{flagship:`gpt-5.6-sol`,smoke:`gpt-5.6-luna`}},gd=[{id:`claude-opus-5`,runtime:`claude-code`},{id:`claude-opus-5[1m]`,runtime:`claude-code`},{id:`claude-sonnet-5`,runtime:`claude-code`},{id:`claude-sonnet-5[1m]`,runtime:`claude-code`},{id:`claude-fable-5`,runtime:`claude-code`},{id:`claude-fable-5[1m]`,runtime:`claude-code`},{id:`claude-opus-4-8`,runtime:`claude-code`},{id:`claude-haiku-4-5`,runtime:`claude-code`},{id:`gpt-5.6-sol`,runtime:`codex`},{id:`gpt-5.6-terra`,runtime:`codex`},{id:`gpt-5.6-luna`,runtime:`codex`}],_d=hd[pd].smoke,vd=[`waypoint`,`converge`,`research`];cd(e=>{if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e},n=typeof t.stepModels==`object`&&t.stepModels!==null&&!Array.isArray(t.stepModels)?{...t.stepModels}:void 0;if(n){for(let e of vd)delete n[e];t.stepModels=n}let r=t.smokeModel;return typeof r==`string`&&r.length>0&&n?.smoke===void 0&&(t.stepModels={...n,smoke:r}),delete t.smokeModel,t},Su({serverPort:K().default(4512),model:G().default(hd[pd].flagship),stepModels:Nu(ud,G()).default({smoke:_d}),models:bu(md).default([]),sandbox:Fu([`docker`,`podman`,`noSandbox`]).default(`docker`),sessionMcp:Fu([`inherit`,`runcastleOnly`]).default(`inherit`),sandboxImage:G().optional(),burnConcurrency:K().int().min(1).max(8).default(3),burnCpus:K().positive().max(256).optional(),burnGuard:fu().default(!0),burnMaxIterations:K().int().min(1).max(10).default(3),burnAttempts:K().int().min(1).max(5).default(3),burnConflictAttempts:K().int().min(0).max(3).default(2),setupCommand:G().optional(),verifyCommands:G().optional(),knownFailures:G().optional(),burnWorkspace:Fu([`auto`,`mounted`,`isolated`]).default(`auto`),burnCache:Fu([`volume`,`off`]).default(`volume`)}));function yd(e,t){let n=new Map(t.map(e=>[e.id,e])),r=e.map(e=>n.get(e.id)??e),i=new Set(e.map(e=>e.id));return[...r,...t.filter(e=>!i.has(e.id))]}function bd(e){return yd(yd(gd,e.discovered??[]),e.models??[])}function xd(e){return dd.flatMap(t=>e.sources[t].models.map(({id:e})=>({id:e,runtime:t})))}function Sd(e,t){return bd(t).find(t=>t.id===e)??{id:e,runtime:`claude-code`}}var Cd=Fu([`passed`,`failed`,`couldnt_run`]),wd=Su({command:G(),outcome:Cd,exitCode:K().nullable(),reason:G().optional(),log:G()}),Td=Eu(`status`,[Su({status:Lu(`none_configured`)}),Su({status:Lu(`couldnt_run`),commit:G(),reason:G(),log:G().nullable()}),Su({status:Lu(`ran`),commit:G(),commands:bu(wd),reusedFrom:Su({kind:Fu([`round`,`review`]),id:G()}).optional()})]),Ed=Fu([`pending`,`burning`,`done`,`failed`,`cancelled`]),Dd=Fu([`chat`,`prepare`,`project`,`drive-fix`,`scenario`,`side`]),Od=Fu([`resolve-conflict`,`start-lap`,`self-plan`,`relay`,`lead-wake`,`scenario-setup`]);function kd(e){return e.kind!==`chat`||e.purpose===`lead-wake`?!1:!!e.headless||e.purpose===`self-plan`}var Ad=Su({mergeFrom:G(),mergeInto:G()}),jd=Fu([`running`,`succeeded`,`failed`,`cancelled`]),Md=Fu([`draft`,`active`,`shipped`,`archived`]),Nd=Fu([`launching`,`live`,`ended`]),Pd=Fu([`implementation`,`review`]),Fd=Fu([`defect`,`observation`]),Id=Fu([`high`,`medium`,`low`]),Ld=Fu([`open`,`fixing`,`fixed`,`failed`,`dismissed`]),Rd=Fu([`over-cap`,`fix-failed`,`verification`]),zd=Fu([`fix-ticket`,`session`]);Su({kind:Fd,severity:Id,title:G().min(1),location:G().min(1),citation:G().min(1),detail:G().min(1),reproStep:G().optional()}).superRefine((e,t)=>{e.kind===`defect`&&!e.reproStep?.trim()&&t.addIssue({code:`custom`,path:[`reproStep`],message:`defects require a repro step`})}).safeExtend({id:G(),featureId:G(),reviewTicketId:G(),reproStep:G(),status:Ld,openReason:Rd.nullable(),failureReason:G().nullable(),fixTicketId:G().nullable(),resolvedBy:zd.nullable(),resolutionNote:G().nullable(),createdAt:K()}),Su({title:G(),goal:G(),context:G(),acceptanceCriteria:bu(G()),seams:bu(G()),blockedBy:bu(K()),kind:Pd.default(`implementation`),passKind:Fu([`review`,`verification`]).default(`review`),model:G().optional(),originFindingId:G().optional()}).extend({id:G(),featureId:G(),seq:K(),status:Ed,commits:bu(G()),reviewedCommit:G().nullable().default(null),reviewMode:Fu([`drive`,`gates`]).nullable().optional(),reviewVerdict:Fu([`verified`,`unverified`]).nullable().optional(),reviewVerdictReason:G().nullable().optional(),reviewGateRun:Td.nullable().optional(),completedAt:K().nullable().default(null),error:G().optional(),attemptBranch:G().optional(),conflictFiles:bu(G()).optional(),digest:G().optional()});var Bd=Fu([`open`,`done`,`promoted`,`carried`]),Vd=Fu([`human`,`agent`]);Su({id:G(),featureId:G(),text:G(),status:Bd,author:Vd.default(`human`),ticketId:G().optional(),reviewTicketId:G().optional(),videoTimestamp:K().optional(),screenshotUrl:G().optional(),sentAt:K().optional(),createdAt:K(),updatedAt:K()});var Hd=Fu([`open`,`triaged`]);Su({id:G(),projectId:G(),text:G(),status:Hd,outcome:G().optional(),featureId:G().optional(),screenshotUrl:G().optional(),driveBranch:G().optional(),driveCommit:G().optional(),createdAt:K(),updatedAt:K()});var Ud=[`setupCommand`,`verifyCommands`,`knownFailures`,`devCommand`,`driveSetupCommand`,`driveStopCommand`,`dbResetCommand`,`driveInstructions`];Fu(Ud);var Wd=Fu([...Ud,`sandboxImage`]),Gd=[`devCommand`,`driveSetupCommand`,`driveStopCommand`],Kd=Fu([`prep`,`human`,`session`,`build`]),qd=`runcastle:`;G().min(1,`a project needs a name`).max(80,`a project name can be at most 80 characters`),Su({id:G(),name:G(),repoPath:G(),sessionBranch:G().optional(),devCommand:G().optional(),model:G().optional(),sandboxImage:G().optional(),setupCommand:G().optional(),verifyCommands:G().optional(),knownFailures:G().optional(),dbResetCommand:G().optional(),driveSetupCommand:G().optional(),driveStopCommand:G().optional(),driveInstructions:G().optional(),scenarioRunner:G().optional(),docsCommitPrefix:G().optional(),closedAt:K().optional()}),Su({key:Wd,source:Kd,evidence:G().optional(),establishedAt:K(),establishedSha:G().optional(),staleCommits:K().optional(),verifiedAt:K().optional(),verifiedSha:G().optional()}),Su({id:G(),projectId:G(),slug:G(),title:G(),oneLiner:G(),brief:G().optional(),branch:G(),baseBranch:G().optional(),status:Md,createdAt:K(),upNext:fu().default(!1),stoppedAt:K().nullable().default(null),waitingReason:G().nullable().default(null),lastHumanMessageAt:K().nullable().default(null),lastDispatchAt:K().nullable().default(null)}),Su({id:G(),featureId:G(),runId:G().nullable(),scenario:G(),createdAt:K()});var Jd=Su({ok:fu(),failed:bu(G())});Su({round:K(),runId:G(),status:jd,ticketSeqs:bu(K()),landed:bu(K()),failed:bu(K()),gates:Jd.nullable(),startedAt:K(),finishedAt:K().nullable()}),Su({id:G(),featureId:G().optional(),projectId:G().optional(),kind:Dd,purpose:Od.optional(),purposeData:Ad.optional(),ccSessionId:G().optional(),transcriptPath:G().optional(),status:Nd,awaitingInput:fu(),headless:fu().optional(),worktreePath:G(),model:G().optional(),runtime:fd.optional(),title:G().nullable().optional(),transcriptMissing:fu().optional(),createdAt:K().optional(),endedAt:K().optional(),openedBeside:G().optional()}),Su({id:G(),featureId:G(),workflow:G(),status:jd,startedAt:K(),endedAt:K().optional(),summary:G().optional(),digest:G().optional(),gates:Td.optional()});var Yd=Fu([`env`,`project`,`file`,`default`]),Xd=Fu([`global`,`project`]),Zd=Su({key:G(),value:gu(),source:Yd,editable:fu(),restartRequired:fu(),scope:Xd}),Qd=Su({id:G().min(1),runtime:fd,displayName:G().optional(),description:G().optional(),retirement:Su({at:G(),replacement:G()}).optional()}),$d=Su({sources:Mu(fd,Su({status:Fu([`never`,`ok`,`failed`]),lastSuccessAt:K().optional(),lastAttemptAt:K().optional(),error:G().optional(),models:bu(Qd),newIds:bu(G()),knownIds:bu(G()).default([])}))}),ef=()=>({status:`never`,models:[],newIds:[],knownIds:[]}),tf={sources:{"claude-code":ef(),codex:ef()}};Su({projectId:G().optional(),fields:bu(Zd),discovery:$d}),Su({projectId:G().optional(),key:G(),value:wu([G(),K(),fu(),bu(md),mu()])}),Su({id:K(),projectId:G(),featureId:G().optional(),runId:G().optional(),ticketId:G().optional(),ts:K(),type:G(),message:G(),data:gu().optional()});var nf=Su({sessionId:G().optional(),exitCode:K().nullable(),tail:G(),messages:K()});Fu([`idle`,`starting`,`serving`,`bare-checkout`,`setup-failed`,`review-agent-driving`]),Su({file:G(),group:G().optional(),name:G(),own:fu(),hasCall:fu()});var rf=Su({method:G().min(1),url:G(),headers:bu(Au([G(),G()])),body:G().optional()}),af=Su({reason:Fu([`exit`,`no-entry-url`,`timeout`,`no-runner`]),exitCode:K().nullable().optional(),outputTail:G()});Su({file:G(),name:G(),status:Fu([`running`,`landed`,`failed`]),output:G().optional(),entryUrl:G().optional(),landingId:G().optional(),failure:af.optional(),token:G().optional(),run:G().optional(),call:rf.optional(),callError:G().optional()});function of(e){let t=null;for(let n of e)if(n.type===`merge.conflict`){let e=n.data??{};t={base:typeof e.base==`string`?e.base:``,files:Array.isArray(e.files)?e.files.filter(e=>typeof e==`string`):[],at:n.ts}}else[`burn.started`,`merge.resolved`,`feature.shipped`].includes(n.type)&&(t=null);return t}var sf=`/api/reviews`,cf=`/:featureId`;function lf(e){return`${sf}${cf.replace(`:featureId`,encodeURIComponent(e))}`}var uf=`/note/:noteId/screenshot`;`${uf}`;function df(e,t){return`${sf}${e.replace(`:noteId`,encodeURIComponent(t))}`}function ff(e){return df(uf,e)}var pf=`/project-note/:noteId/screenshot`;`${pf}`;function mf(e){return df(pf,e)}function hf(e){if(!Number.isFinite(e)||e<0)return`--:--`;let t=Math.floor(e),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=n>0?String(r).padStart(2,`0`):String(r);return`${n>0?`${n}:`:``}${a}:${String(i).padStart(2,`0`)}`}function gf(e,t){if(e.status!==`draft`)return null;let n=t.filter(e=>!e.satisfied);return e.upNext?n.length>0&&n.every(e=>e.status!==`archived`)?`upNext`:`stuck`:n.length>0?`blocked`:t.length>0?`readyToStart`:`backlog`}function _f(e){let t=e.find(e=>!e.satisfied&&e.status===`archived`);return t?`${t.slug} was archived — remove it or move this to the backlog`:`nothing left to wait on — start it or move it to the backlog`}function vf(e){return e.filter(e=>!e.satisfied&&e.status===`draft`&&!e.upNext)}function yf(e){return e.status===`shipped`}function bf(e){return e.filter(e=>e.kind!==`review`)}function xf(e){let t=bf(e),n=t.filter(e=>e.status===`cancelled`).length;return{landed:t.filter(e=>e.status===`done`).length,total:t.length-n,waived:n}}var Sf=Symbol.for(`drizzle:entityKind`);function Cf(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,Sf))throw Error(`Class "${t.name??`<unknown>`}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)for(;n;){if(Sf in n&&n[Sf]===t[Sf])return!0;n=Object.getPrototypeOf(n)}return!1}var wf=class{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[Sf]=`Column`;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}},Tf=class{static[Sf]=`ColumnBuilder`;config;constructor(e,t,n){this.config={name:e,keyAsName:e===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){this.config.name===``&&(this.config.name=e)}},Ef=Symbol.for(`drizzle:Name`),Df=Symbol.for(`drizzle:isPgEnum`);function Of(e){return!!e&&typeof e==`function`&&Df in e&&e[Df]===!0}var kf=class{static[Sf]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},Af={startActiveSpan(e,t){return t()}},jf=Symbol.for(`drizzle:ViewBaseConfig`),Mf=Symbol.for(`drizzle:Schema`),Nf=Symbol.for(`drizzle:Columns`),Pf=Symbol.for(`drizzle:ExtraConfigColumns`),Ff=Symbol.for(`drizzle:OriginalName`),If=Symbol.for(`drizzle:BaseName`),Lf=Symbol.for(`drizzle:IsAlias`),Rf=Symbol.for(`drizzle:ExtraConfigBuilder`),zf=Symbol.for(`drizzle:IsDrizzleTable`),Bf=class{static[Sf]=`Table`;static Symbol={Name:Ef,Schema:Mf,OriginalName:Ff,Columns:Nf,ExtraConfigColumns:Pf,BaseName:If,IsAlias:Lf,ExtraConfigBuilder:Rf};[Ef];[Ff];[Mf];[Nf];[Pf];[If];[Lf]=!1;[zf]=!0;[Rf]=void 0;constructor(e,t,n){this[Ef]=this[Ff]=e,this[Mf]=t,this[If]=n}};function Vf(e){return e!=null&&typeof e.getSQL==`function`}function Hf(e){let t={sql:``,params:[]};for(let n of e)t.sql+=n.sql,t.params.push(...n.params),n.typings?.length&&(t.typings||=[],t.typings.push(...n.typings));return t}var Uf=class{static[Sf]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new Wf([this])}},Wf=class e{constructor(e){this.queryChunks=e;for(let t of e)if(Cf(t,Bf)){let e=t[Bf.Symbol.Schema];this.usedTables.push(e===void 0?t[Bf.Symbol.Name]:e+`.`+t[Bf.Symbol.Name])}}static[Sf]=`SQL`;decoder=Kf;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return Af.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{casing:i,escapeName:a,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:l}=r;return Hf(t.map(t=>{if(Cf(t,Uf))return{sql:t.value.join(``),params:[]};if(Cf(t,Gf))return{sql:a(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new Uf(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new Uf(`, `));return e.push(new Uf(`)`)),this.buildQueryFromSourceParams(e,r)}if(Cf(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:c||t.shouldInlineParams});if(Cf(t,Bf)){let e=t[Bf.Symbol.Schema],n=t[Bf.Symbol.Name];return{sql:e===void 0||t[Lf]?a(n):a(e)+`.`+a(n),params:[]}}if(Cf(t,wf)){let e=i.getColumnCasing(t);if(n.invokeSource===`indexes`)return{sql:a(e),params:[]};let r=t.table[Bf.Symbol.Schema];return{sql:t.table[Lf]||r===void 0?a(t.table[Bf.Symbol.Name])+`.`+a(e):a(r)+`.`+a(t.table[Bf.Symbol.Name])+`.`+a(e),params:[]}}if(Cf(t,Qf)){let e=t[jf].schema,n=t[jf].name;return{sql:e===void 0||t[jf].isAlias?a(n):a(e)+`.`+a(n),params:[]}}if(Cf(t,Jf)){if(Cf(t.value,Xf))return{sql:o(l.value++,t),params:[t],typings:[`none`]};let n=t.value===null?null:t.encoder.mapToDriverValue(t.value);if(Cf(n,e))return this.buildQueryFromSourceParams([n],r);if(c)return{sql:this.mapInlineParam(n,r),params:[]};let i=[`none`];return s&&(i=[s(t.encoder)]),{sql:o(l.value++,n),params:[n],typings:i}}return Cf(t,Xf)?{sql:o(l.value++,t),params:[t],typings:[`none`]}:Cf(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:a(t.fieldAlias),params:[]}:Cf(t,kf)?t._.isWith?{sql:a(t._.alias),params:[]}:this.buildQueryFromSourceParams([new Uf(`(`),t._.sql,new Uf(`) `),new Gf(t._.alias)],r):Of(t)?t.schema?{sql:a(t.schema)+`.`+a(t.enumName),params:[]}:{sql:a(t.enumName),params:[]}:Vf(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new Uf(`(`),t.getSQL(),new Uf(`)`)],r):c?{sql:this.mapInlineParam(t,r),params:[]}:{sql:o(l.value++,t),params:[t],typings:[`none`]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`)return e.toString();if(typeof e==`string`)return t(e);if(typeof e==`object`){let n=e.toString();return t(n===`[object Object]`?JSON.stringify(e):n)}throw Error(`Unexpected param value: `+e)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(e){return this.decoder=typeof e==`function`?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}},Gf=class{constructor(e){this.value=e}static[Sf]=`Name`;brand;getSQL(){return new Wf([this])}},Kf={mapFromDriverValue:e=>e},qf={mapToDriverValue:e=>e};({...Kf,...qf});var Jf=class{constructor(e,t=qf){this.value=e,this.encoder=t}static[Sf]=`Param`;brand;getSQL(){return new Wf([this])}};function Yf(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new Uf(e[0]));for(let[r,i]of t.entries())n.push(i,new Uf(e[r+1]));return new Wf(n)}(e=>{function t(){return new Wf([])}e.empty=t;function n(e){return new Wf(e)}e.fromList=n;function r(e){return new Wf([new Uf(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new Wf(n)}e.join=i;function a(e){return new Gf(e)}e.identifier=a;function o(e){return new Xf(e)}e.placeholder=o;function s(e,t){return new Jf(e,t)}e.param=s})(Yf||={}),(e=>{class t{constructor(e,t){this.sql=e,this.fieldAlias=t}static[Sf]=`SQL.Aliased`;isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(Wf||={});var Xf=class{constructor(e){this.name=e}static[Sf]=`Placeholder`;getSQL(){return new Wf([this])}},Zf=Symbol.for(`drizzle:IsDrizzleView`),Qf=class{static[Sf]=`View`;[jf];[Zf]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[jf]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new Wf([this])}};wf.prototype.getSQL=function(){return new Wf([this])},Bf.prototype.getSQL=function(){return new Wf([this])},kf.prototype.getSQL=function(){return new Wf([this])};function $f(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var ep=typeof TextDecoder>`u`?null:new TextDecoder,tp=class{static[Sf]=`SQLiteForeignKeyBuilder`;reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new np(e,this)}},np=class{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[Sf]=`SQLiteForeignKey`;reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[Ef],...r,n[0].table[Ef],...i];return e??`${a.join(`_`)}_fk`}};function rp(e,t){return`${e[Ef]}_${t.join(`_`)}_unique`}var ip=class extends Tf{static[Sf]=`SQLiteColumnBuilder`;foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:`always`,mode:t?.mode??`virtual`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((n,r)=>{let i=new tp(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)})(n,r))}},ap=class extends wf{constructor(e,t){t.uniqueName||=rp(e,[t.name]),super(e,t),this.table=e}static[Sf]=`SQLiteColumn`},op=class extends ip{static[Sf]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteBigInt`)}build(e){return new sp(e,this.config)}},sp=class extends ap{static[Sf]=`SQLiteBigInt`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString(`utf8`))}return BigInt(ep.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}},cp=class extends ip{static[Sf]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`json`,`SQLiteBlobJson`)}build(e){return new lp(e,this.config)}},lp=class extends ap{static[Sf]=`SQLiteBlobJson`;getSQLType(){return`blob`}mapFromDriverValue(e){if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString(`utf8`))}return JSON.parse(ep.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}},up=class extends ip{static[Sf]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`buffer`,`SQLiteBlobBuffer`)}build(e){return new dp(e,this.config)}},dp=class extends ap{static[Sf]=`SQLiteBlobBuffer`;mapFromDriverValue(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}getSQLType(){return`blob`}};function fp(e,t){let{name:n,config:r}=$f(e,t);return r?.mode===`json`?new cp(n):r?.mode===`bigint`?new op(n):new up(n)}var pp=class extends ip{static[Sf]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new mp(e,this.config)}},mp=class extends ap{static[Sf]=`SQLiteCustomColumn`;sqlName;mapTo;mapFrom;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==`function`?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==`function`?this.mapTo(e):e}};function hp(e){return(t,n)=>{let{name:r,config:i}=$f(t,n);return new pp(r,i,e)}}var gp=class extends ip{static[Sf]=`SQLiteBaseIntegerBuilder`;constructor(e,t,n){super(e,t,n),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}},_p=class extends ap{static[Sf]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},vp=class extends gp{static[Sf]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number`,`SQLiteInteger`)}build(e){return new yp(e,this.config)}},yp=class extends _p{static[Sf]=`SQLiteInteger`},bp=class extends gp{static[Sf]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(Yf`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new xp(e,this.config)}},xp=class extends _p{static[Sf]=`SQLiteTimestamp`;mode=this.config.mode;mapFromDriverValue(e){return this.config.mode===`timestamp`?new Date(e*1e3):new Date(e)}mapToDriverValue(e){let t=e.getTime();return this.config.mode===`timestamp`?Math.floor(t/1e3):t}},Sp=class extends gp{static[Sf]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new Cp(e,this.config)}},Cp=class extends _p{static[Sf]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return+!!e}};function wp(e,t){let{name:n,config:r}=$f(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new bp(n,r.mode):r?.mode===`boolean`?new Sp(n,r.mode):new vp(n)}var Tp=class extends ip{static[Sf]=`SQLiteNumericBuilder`;constructor(e){super(e,`string`,`SQLiteNumeric`)}build(e){return new Ep(e,this.config)}},Ep=class extends ap{static[Sf]=`SQLiteNumeric`;mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return`numeric`}},Dp=class extends ip{static[Sf]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new Op(e,this.config)}},Op=class extends ap{static[Sf]=`SQLiteNumericNumber`;mapFromDriverValue(e){return typeof e==`number`?e:Number(e)}mapToDriverValue=String;getSQLType(){return`numeric`}},kp=class extends ip{static[Sf]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint`,`SQLiteNumericBigInt`)}build(e){return new Ap(e,this.config)}},Ap=class extends ap{static[Sf]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function jp(e,t){let{name:n,config:r}=$f(e,t),i=r?.mode;return i===`number`?new Dp(n):i===`bigint`?new kp(n):new Tp(n)}var Mp=class extends ip{static[Sf]=`SQLiteRealBuilder`;constructor(e){super(e,`number`,`SQLiteReal`)}build(e){return new Np(e,this.config)}},Np=class extends ap{static[Sf]=`SQLiteReal`;getSQLType(){return`real`}};function Pp(e){return new Mp(e??``)}var Fp=class extends ip{static[Sf]=`SQLiteTextBuilder`;constructor(e,t){super(e,`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Ip(e,this.config)}},Ip=class extends ap{static[Sf]=`SQLiteText`;enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},Lp=class extends ip{static[Sf]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`json`,`SQLiteTextJson`)}build(e){return new Rp(e,this.config)}},Rp=class extends ap{static[Sf]=`SQLiteTextJson`;getSQLType(){return`text`}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}};function q(e,t={}){let{name:n,config:r}=$f(e,t);return r.mode===`json`?new Lp(n):new Fp(n,r)}function zp(){return{blob:fp,customType:hp,integer:wp,numeric:jp,real:Pp,text:q}}var Bp=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),Vp=class extends Bf{static[Sf]=`SQLiteTable`;static Symbol=Object.assign({},Bf.Symbol,{InlineForeignKeys:Bp});[Bf.Symbol.Columns];[Bp]=[];[Bf.Symbol.ExtraConfigBuilder]=void 0};function Hp(e,t,n,r,i=e){let a=new Vp(e,r,i),o=typeof t==`function`?t(zp()):t,s=Object.fromEntries(Object.entries(o).map(([e,t])=>{let n=t;n.setName(e);let r=n.build(a);return a[Bp].push(...n.buildForeignKeys(r,a)),[e,r]})),c=Object.assign(a,s);return c[Bf.Symbol.Columns]=s,c[Bf.Symbol.ExtraConfigColumns]=s,n&&(c[Vp.Symbol.ExtraConfigBuilder]=n),c}var Up=(e,t,n)=>Hp(e,t,n),Wp=class{constructor(e,t){this.name=e,this.unique=t}static[Sf]=`SQLiteIndexBuilderOn`;on(...e){return new Gp(this.name,e,this.unique)}},Gp=class{static[Sf]=`SQLiteIndexBuilder`;config;constructor(e,t,n){this.config={name:e,columns:t,unique:n,where:void 0}}where(e){return this.config.where=e,this}build(e){return new Kp(this.config,e)}},Kp=class{static[Sf]=`SQLiteIndex`;config;constructor(e,t){this.config={...e,table:t}}};function qp(e){return new Wp(e,!1)}function Jp(...e){return e[0].columns?new Yp(e[0].columns,e[0].name):new Yp(e)}var Yp=class{static[Sf]=`SQLitePrimaryKeyBuilder`;columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new Xp(e,this.columns,this.name)}},Xp=class{constructor(e,t,n){this.table=e,this.columns=t,this.name=n}static[Sf]=`SQLitePrimaryKey`;columns;name;getName(){return this.name??`${this.table[Vp.Symbol.Name]}_${this.columns.map(e=>e.name).join(`_`)}_pk`}};Up(`projects`,{id:q(`id`).primaryKey(),name:q(`name`).notNull(),repoPath:q(`repo_path`).notNull(),sessionBranch:q(`session_branch`),devCommand:q(`dev_command`),model:q(`model`),sandbox:q(`sandbox`),sandboxImage:q(`sandbox_image`),closedAt:wp(`closed_at`),setupCommand:q(`setup_command`),verifyCommands:q(`verify_commands`),knownFailures:q(`known_failures`),dbResetCommand:q(`db_reset_command`),driveInstructions:q(`drive_instructions`),driveSetupCommand:q(`drive_setup_command`),driveStopCommand:q(`drive_stop_command`),scenarioRunner:q(`scenario_runner`),docsCommitPrefix:q(`docs_commit_prefix`)}),Up(`project_findings`,{projectId:q(`project_id`).notNull(),key:q(`key`).notNull(),source:q(`source`).notNull().$type(),evidence:q(`evidence`),establishedAt:wp(`established_at`).notNull(),establishedSha:q(`established_sha`),verifiedAt:wp(`verified_at`),verifiedSha:q(`verified_sha`)},e=>[Jp({columns:[e.projectId,e.key]})]);var Zp=Up(`features`,{id:q(`id`).primaryKey(),projectId:q(`project_id`).notNull(),slug:q(`slug`).notNull(),title:q(`title`).notNull(),oneLiner:q(`one_liner`).notNull(),brief:q(`brief`),branch:q(`branch`).notNull(),baseBranch:q(`base_branch`),status:q(`status`).notNull().$type(),createdAt:wp(`created_at`).notNull(),upNext:wp(`up_next`,{mode:`boolean`}).notNull().default(!1),stoppedAt:wp(`stopped_at`),waitingReason:q(`waiting_reason`),lastHumanMessageAt:wp(`last_human_message_at`),lastDispatchAt:wp(`last_dispatch_at`)});Up(`ready_declarations`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),runId:q(`run_id`),scenario:q(`scenario`).notNull(),createdAt:wp(`created_at`).notNull()}),Up(`feature_dependencies`,{dependentId:q(`dependent_id`).notNull().references(()=>Zp.id,{onDelete:`cascade`}),dependencyId:q(`dependency_id`).notNull().references(()=>Zp.id,{onDelete:`cascade`}),createdAt:wp(`created_at`).notNull()},e=>[Jp({columns:[e.dependentId,e.dependencyId]})]),Up(`sessions`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`),projectId:q(`project_id`),kind:q(`kind`).notNull().$type(),purpose:q(`purpose`).$type(),purposeData:q(`purpose_data`,{mode:`json`}).$type(),ccSessionId:q(`cc_session_id`),transcriptPath:q(`transcript_path`),status:q(`status`).notNull().$type(),awaitingInput:wp(`awaiting_input`,{mode:`boolean`}).notNull().default(!1),headless:wp(`headless`,{mode:`boolean`}).notNull().default(!1),worktreePath:q(`worktree_path`).notNull(),model:q(`model`),runtime:q(`runtime`).$type(),title:q(`title`),createdAt:wp(`created_at`),endedAt:wp(`ended_at`),tokens:wp(`tokens`),tokenBreakdown:q(`token_breakdown`,{mode:`json`}).$type(),openedBeside:q(`opened_beside`)}),Up(`tickets`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),seq:wp(`seq`).notNull(),title:q(`title`).notNull(),goal:q(`goal`).notNull(),context:q(`context`).notNull(),acceptanceCriteria:q(`acceptance_criteria`,{mode:`json`}).notNull().$type(),seams:q(`seams`,{mode:`json`}).notNull().$type(),blockedBy:q(`blocked_by`,{mode:`json`}).notNull().$type(),kind:q(`kind`).notNull().$type().default(`implementation`),passKind:q(`pass_kind`).notNull().$type().default(`review`),reviewedCommit:q(`reviewed_commit`),reviewMode:q(`review_mode`).$type(),reviewVerdict:q(`review_verdict`).$type(),reviewVerdictReason:q(`review_verdict_reason`),reviewGateRun:q(`review_gate_run`,{mode:`json`}).$type(),completedAt:wp(`completed_at`),model:q(`model`),status:q(`status`).notNull().$type(),commits:q(`commits`,{mode:`json`}).notNull().$type(),error:q(`error`),attemptBranch:q(`attempt_branch`),conflictFiles:q(`conflict_files`,{mode:`json`}).$type(),digest:q(`digest`),originFindingId:q(`origin_finding_id`),tokens:wp(`tokens`),tokenBreakdown:q(`token_breakdown`,{mode:`json`}).$type()}),Up(`review_findings`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),reviewTicketId:q(`review_ticket_id`).notNull(),kind:q(`kind`).notNull().$type(),severity:q(`severity`).notNull().$type(),title:q(`title`).notNull(),location:q(`location`).notNull(),citation:q(`citation`).notNull(),detail:q(`detail`).notNull(),reproStep:q(`repro_step`).notNull(),status:q(`status`).notNull().$type(),openReason:q(`open_reason`).$type(),failureReason:q(`failure_reason`),fixTicketId:q(`fix_ticket_id`),resolvedBy:q(`resolved_by`).$type(),resolutionNote:q(`resolution_note`),createdAt:wp(`created_at`).notNull()}),Up(`test_notes`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),text:q(`text`).notNull(),status:q(`status`).notNull().$type(),author:q(`author`).notNull().$type().default(`human`),ticketId:q(`ticket_id`),reviewTicketId:q(`review_ticket_id`),videoTimestamp:Pp(`video_timestamp`),sentAt:wp(`sent_at`),createdAt:wp(`created_at`).notNull(),updatedAt:wp(`updated_at`).notNull()}),Up(`project_notes`,{id:q(`id`).primaryKey(),projectId:q(`project_id`).notNull(),text:q(`text`).notNull(),status:q(`status`).notNull().$type(),outcome:q(`outcome`),featureId:q(`feature_id`),driveBranch:q(`drive_branch`),driveCommit:q(`drive_commit`),createdAt:wp(`created_at`).notNull(),updatedAt:wp(`updated_at`).notNull()}),Up(`runs`,{id:q(`id`).primaryKey(),featureId:q(`feature_id`).notNull(),workflow:q(`workflow`).notNull(),status:q(`status`).notNull().$type(),startedAt:wp(`started_at`).notNull(),endedAt:wp(`ended_at`),summary:q(`summary`),digest:q(`digest`),gates:q(`gates`,{mode:`json`}).$type()}),Up(`events`,{id:wp(`id`).primaryKey({autoIncrement:!0}),projectId:q(`project_id`).notNull(),featureId:q(`feature_id`),runId:q(`run_id`),ticketId:q(`ticket_id`),ts:wp(`ts`).notNull(),type:q(`type`).notNull(),message:q(`message`).notNull(),data:q(`data`,{mode:`json`})},e=>[qp(`events_project_id_id_idx`).on(e.projectId,e.id),qp(`events_feature_id_id_idx`).on(e.featureId,e.id)]);var Qp={setupCommand:`Setup`,verifyCommands:`Verify`,knownFailures:`Known failing tests`,devCommand:`Dev server`,dbResetCommand:`Reset dev database`,driveSetupCommand:`Before a test drive`,driveStopCommand:`After a test drive`,driveInstructions:`How to drive this app`,sandboxImage:`Sandbox image`},$p=new Set([`devCommand`,`dbResetCommand`,`driveSetupCommand`,`driveStopCommand`]);function em(e,t=Date.now()){let n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return`just now`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<36?`${i}h ago`:`${Math.round(i/24)}d ago`}function tm(e){return Gd.includes(e)}function nm(e){return`${rm(e)}${eee(e)}`}function eee(e){return tm(e.key)?e.verifiedAt===void 0?` Unverified — never proven by a dry run.`:` Verified ${em(e.verifiedAt)} by a dry run.`:``}function rm(e){if(e.source===`human`)return`You set this ${em(e.establishedAt)}.`;let t=e.source===`build`?`Built by runcastle from the repo Dockerfile`:e.source===`session`?`Established in a conversation on this machine`:$p.has(e.key)?`Proposed by preparation from config (not executed)`:`Established by preparation`,n=em(e.establishedAt);return e.staleCommits===void 0?`${t} ${n}${e.establishedSha?` — age against main unknown`:``}.`:e.staleCommits===0?`${t} ${n} — main has not moved since.`:`${t} ${n} — main has moved ${e.staleCommits} commit${e.staleCommits===1?``:`s`} since.`}function im(e){return e.source!==`human`&&(e.staleCommits??0)>=100}function am(e){return e.source===`human`?{label:`Yours`,title:`You set this by hand — preparation will never overwrite it`}:e.source===`build`?{label:`Built`,title:`Built by runcastle from this repo's own Dockerfile`}:e.source===`session`?{label:`Verified`,title:`Established in a conversation on your own machine`}:$p.has(e.key)?{label:`Proposed`,title:`Read from config by an older automatic run, not executed`}:{label:`Measured`,title:`Measured by an older automatic run, in a sandbox`}}var om={serverPort:`RUNCASTLE_SERVER_PORT`,model:`RUNCASTLE_MODEL`,sandbox:`RUNCASTLE_SANDBOX`,sandboxImage:`RUNCASTLE_SANDBOX_IMAGE`,sessionMcp:`RUNCASTLE_SESSION_MCP`,burnConcurrency:`RUNCASTLE_BURN_CONCURRENCY`,burnMaxIterations:`RUNCASTLE_BURN_MAX_ITERATIONS`,burnAttempts:`RUNCASTLE_BURN_ATTEMPTS`,burnConflictAttempts:`RUNCASTLE_BURN_CONFLICT_ATTEMPTS`,burnCpus:`RUNCASTLE_BURN_CPUS`,setupCommand:`RUNCASTLE_SETUP_COMMAND`,verifyCommands:`RUNCASTLE_VERIFY_COMMANDS`,knownFailures:`RUNCASTLE_KNOWN_FAILURES`},sm={"claude-code":`Claude Code`,codex:`Codex`},tee={general:[`server`,`sessions`],models:[`default`],burns:[`width`],project:[`model`,`commands`,`chat`]};function cm(e){let t=e?.fields.find(e=>e.key===`models`)?.value;return Array.isArray(t)?t.flatMap(e=>{let t=md.safeParse(e);return t.success?[t.data]:[]}):[]}function lm(e){return bd({discovered:xd(e?.discovery??tf),models:cm(e)})}function um(e){return dd.map(t=>({runtime:t,label:sm[t],entries:e.filter(e=>e.runtime===t)})).filter(e=>e.entries.length>0)}function dm(e,t,n){let r=e.trim();if(r===``)return{error:`Enter a model id.`};if(!dd.includes(t))return{error:`Choose which runtime this model runs on.`};let i=n.trim();return{entry:{id:r,runtime:t,...i?{note:i}:{}}}}var fm=`stepModels.`;function pm(e){return e.startsWith(fm)}function mm(e){return e.slice(11)}var hm=[{step:`chat`,label:`Chat`,group:`sessions`,description:`The feature conversation`},{step:`project`,label:`Project chat`,group:`sessions`,description:`The project-level conversation`},{step:`implement`,label:`Implement`,group:`unattended`,description:`Works a ticket in the sandbox`},{step:`review`,label:`Review`,group:`unattended`,description:`Reads the finished branch`},{step:`prepare`,label:`Prepare`,group:`unattended`,description:`Measures setup, verify and baseline`},{step:`smoke`,label:`Smoke`,group:`unattended`,description:`Cheap scripted end-to-end check`}],nee=Object.fromEntries(hm.map(e=>[e.step,e.label]));function gm(e){return`${fm}${e}`}ld.map(gm);var _m=`Applies inside the app under test only — it changes no review rule and permits no edit to the repo under review.`,vm={serverPort:{label:`Server port`,tooltip:`The port the runcastle server listens on. Changing it takes effect at the next server restart.`,control:`number`,page:`general`,group:`server`},model:{label:`Default model`,tooltip:`Runs every step that has no model of its own below — and every project that has not set one.`,control:`select`,page:`models`,group:`default`},sandbox:{label:`Sandbox`,tooltip:`Where launched sessions and workers run. A Docker container isolates them from this machine; “no sandbox” runs them directly on it.`,control:`select`,page:`general`,group:`sessions`,options:[`docker`,`noSandbox`],optionLabels:{docker:`Docker container (isolated)`,noSandbox:`No sandbox — run directly on this machine`}},sandboxImage:{label:`Sandbox image`,tooltip:`The Docker image sessions and workers are sandboxed in. Leave blank to use sandcastle:runcastle, the image “Build image” on the Workers page produces.`,control:`text`,page:`general`,group:`sessions`,placeholder:`sandcastle:runcastle`},sessionMcp:{label:`MCP servers in sessions`,tooltip:`Inherit mine — sessions see your own MCP servers (user, project and plugin) alongside runcastle’s. runcastle only — sessions see runcastle’s server and nothing else; use it for a reproducible tool surface or to keep a heavy personal MCP set out of the context window.`,control:`select`,page:`general`,group:`sessions`,options:[`inherit`,`runcastleOnly`],optionLabels:{inherit:`Inherit mine — my servers alongside runcastle’s`,runcastleOnly:`runcastle only — nothing else`}},burnConcurrency:{label:`Concurrency`,tooltip:`Tickets a round works in parallel (1–8). Each is a full worker with its own container, sizing its install and test workers from the whole core count — lower it if suites die under load.`,control:`number`,page:`burns`,group:`width`,unit:`tickets at once`},burnMaxIterations:{label:`Iterations per attempt`,tooltip:`Turns one healthy worker may take before it is stopped (1–10). A ticket that finishes early stops the loop itself.`,control:`number`,page:`burns`,group:`width`,shortHelp:`Distinct from attempts: an attempt restarts an agent that crashed.`,unit:`turns`},burnAttempts:{label:`Attempts per ticket`,tooltip:`Fresh agent attempts per ticket per run (1–5). A transient crash — API drop, network, rate limit — retries with committed work preserved; auth errors and conflicts never retry.`,control:`number`,page:`burns`,group:`width`,unit:`attempts`},burnConflictAttempts:{label:`Conflict resolver passes`,tooltip:`Agent passes spent resolving a ticket’s landing conflict before asking you (0–3). 0 sends every conflict straight to you.`,control:`number`,page:`burns`,group:`width`,unit:`passes before asking you`},burnCpus:{label:`CPU limit per worker`,tooltip:`CPU ceiling per worker container (--cpus). Blank leaves it unconstrained. Roughly cores ÷ concurrency keeps parallel tickets from oversubscribing the machine.`,control:`number`,page:`burns`,group:`width`,placeholder:`unlimited`,unit:`cores · e.g. 4 on a 12-thread box at width 3`},setupCommand:{label:`Setup`,tooltip:`Takes a clean checkout to a buildable state inside the worker sandbox — dependency install plus any codegen. Blank auto-detects from the lockfile.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. pnpm install --frozen-lockfile && pnpm prisma:generate`},verifyCommands:{label:`Verify`,tooltip:`The exact typecheck / test / lint commands, one per line. Every worker is told to run them, and runcastle runs them itself at the end of every round and hands the results to the agent.`,control:`textarea`,page:`project`,group:`commands`,placeholder:`one per line, e.g.
73
73
  pnpm --filter @acme/web test`},knownFailures:{label:`Known failing tests`,tooltip:`Tests already red on main — a count plus suite names is enough. Saves every worker a full pre-work run to establish its own baseline.`,control:`textarea`,page:`project`,group:`commands`,placeholder:`e.g. 2 failing: dev-pane.test.ts (Windows only)`},devCommand:{label:`Dev server`,tooltip:`Starts this project’s dev server for a test drive. The URL it prints becomes the “Open app” link.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. pnpm dev`},driveSetupCommand:{label:`Before a test drive`,tooltip:`Runs on your machine before the dev server starts a test drive — bring up services, apply schema. A failure is reported, never fatal.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. docker compose up -d && pnpm db:migrate`},driveStopCommand:{label:`After a test drive`,tooltip:`Runs when a test drive stops, while the feature branch is still checked out — stop services, drop the branch database.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. docker compose down`},scenarioRunner:{label:`Scenario runner`,tooltip:`Runs one drive scenario. {file} is the scenario’s path under .runcastle/scenarios/.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. bun {file}`},dbResetCommand:{label:`Reset dev database`,tooltip:`Rebuilds the dev database from the migrations in the working tree. Offered — never run automatically — after a test drive whose branch carried migrations this one does not have.`,control:`text`,page:`project`,group:`commands`,placeholder:`e.g. pnpm db:reset`},driveInstructions:{label:`How to drive this app`,tooltip:`How to exercise this app once it is up: the sample project or scratch data a driver should use and may change, how to reach the states worth reviewing, and what to leave alone. Written by preparation, edited here, and injected verbatim into every drive-mode review and verification prompt.`,control:`textarea`,page:`project`,group:`commands`,shortHelp:_m,placeholder:`e.g. drive the sample project at ./examples/demo — change anything inside it freely`},docsCommitPrefix:{label:`Docs commit prefix`,tooltip:`Prefix for checkpoint commits runcastle creates from feature docs. Use a form accepted by this repository’s commit message policy.`,control:`text`,page:`project`,group:`chat`,placeholder:qd},sessionBranch:{label:`Commits land on`,tooltip:`The branch the project chat’s commits (charter, ADRs) land on when its terminal closes. Blank uses the repo’s detected main line; a pick takes effect at the next chat you open.`,control:`text`,page:`project`,group:`chat`,placeholder:`main (detected)`}},ym=Object.keys(vm),bm={model:{label:`Model`,tooltip:`A model set here runs every step of this project — it beats the global default and the per-step models.`,page:`project`,group:`model`},sandbox:{page:`project`,group:`model`},sandboxImage:{tooltip:`The Docker image THIS project’s sessions and workers are sandboxed in — where a repo needs a toolchain the stock image has none of. Blank inherits the machine-wide image.`,page:`project`,group:`model`}},xm=new Set([`model`,`sandbox`,`sandboxImage`,`setupCommand`,`verifyCommands`,`knownFailures`]);function Sm(e,t=`global`){if(pm(e)){let t=mm(e),n=nee[t]??t;return{label:n,tooltip:`Model for the ${n} step.`,control:`select`,page:`models`,group:`default`}}let n=vm[e]??{label:e,tooltip:``,control:`text`,page:`general`,group:`server`};return t===`project`?{...n,...bm[e]}:n}function Cm(e){return e==null?``:String(e)}function wm(e,t){let n=t.trim();if(e===`textarea`&&n===``)return{value:null};if(e!==`number`)return{value:n};if(n===``)return{value:null};let r=Number(n);return Number.isFinite(r)?{value:r}:{error:`Enter a number, or leave it blank to unset it.`}}function Tm(e){return e===`model`||pm(e)}function Em(e,t){if(t.unit!==void 0)return e.key!==`burnConcurrency`||e.source!=="default"?t.unit:`${t.unit} · default on this machine: ${Cm(e.value)}`}function Dm(e){if(e.scope!==`project`)return e.key===`burnConcurrency`&&e.source==="default"&&Cm(e.value)||void 0;if(xm.has(e.key)&&!(e.source!==`file`&&e.source!=="default"))return Cm(e.value)||void 0}var Om=new Set([`sandboxImage`]);function km(e){return e.scope===`global`&&e.source===`file`&&Om.has(e.key)}function Am(e){if(e.source===`env`)return`env`;if(!(e.scope!==`project`||!xm.has(e.key)))return e.source===`project`?`project`:`global`}function jm(e){let t=[e.source===`human`?`You`:e.source===`session`?`Set in a session`:e.source===`build`?`Built by runcastle`:`Prepared`,em(e.establishedAt)];e.source!==`human`&&e.staleCommits&&t.push(`main +${e.staleCommits}`);let n=tm(e.key)?e.verifiedAt===void 0?`unverified`:`verified by a dry run ${em(e.verifiedAt)}`:null;return n&&t.push(n),{text:t.join(` · `),tone:im(e)?`warn`:n===`unverified`?`muted`:`ok`,...e.evidence?{evidence:e.evidence}:{}}}function Mm(e,t,n=gd){let r=Sm(e.key,e.scope),i=Tm(e.key),a=!e.editable,o=e.source===`project`,s=null;e.source===`env`?s=`Set by ${om[e.key]??`the environment`}`:t&&o?s=nm(t):e.scope===`project`&&(s=o?`Overridden for this project`:`Inherited from global`);let c=Em(e,r),l=Dm(e),u=Am(e);return{key:e.key,label:r.label,...r.tag?{tag:r.tag}:{},tooltip:r.tooltip,...r.shortHelp?{shortHelp:r.shortHelp}:{},placeholder:r.placeholder??``,...c?{unit:c}:{},page:r.page,group:r.group,value:Cm(e.value),control:r.control,options:i?n.map(e=>e.id):r.options??[],modelGroups:i?um(n):[],optionLabels:r.optionLabels??{},readOnly:a,restartRequired:e.restartRequired,overridden:o,source:e.source,note:s,...l?{ghostValue:l}:{},...u?{sourceChip:u}:{},clearable:km(e),...t?{provenanceChip:jm(t)}:{},...t?.evidence?{evidence:t.evidence}:{},stale:t?im(t):!1,allowCustom:i}}function Nm(e){return!pm(e)&&e!==`models`}function Pm(e,t,n=[]){let r=new Map(n.map(e=>[e.key,e])),i=lm(e),a=tee[t];return e.fields.filter(e=>Nm(e.key)?t===`project`?e.scope===`project`:e.scope!==`project`&&Sm(e.key).page===t:!1).map(e=>Mm(e,r.get(e.key),i)).sort((e,t)=>a.indexOf(e.group)-a.indexOf(t.group)||ym.indexOf(e.key)-ym.indexOf(t.key))}function Fm(e,t){let n=t=>e?.fields.find(e=>e.key===t),r=n(`model`),i=n(`${fm}${t}`),a=(r?.source===`project`?r:void 0)??(i?.source===`file`?i:void 0)??r;return typeof a?.value==`string`?a.value:void 0}function Im(e){return Cm(e.fields.find(e=>e.key===`model`)?.value)}function Lm(e,t){let n=e.fields.find(e=>e.key===`${fm}${t}`);return n?.source===`file`&&typeof n.value==`string`&&n.value!==``?n.value:null}var Rm={"claude-code":`Claude`,codex:`Codex`};function zm(e){return e.discovery??tf}function Bm(e){let t=dd.filter(t=>e[t].status===`ok`);return t.length===0?null:t.length===1?t[0]:pd}function Vm(e){let t=Im(e),n=new Map(ld.map(n=>[n,Lm(e,n)??t])),r=new Set(gd.map(e=>e.id)),{sources:i}=zm(e),a=new Map(dd.flatMap(e=>i[e].models.map(t=>[t.id,{model:t,runtime:e}]))),o=lm(e),s=new Set(o.map(e=>e.id)),c=Bm(i),l=new Set([t,...n.values()].filter(e=>e!==``&&!s.has(e)));return[...o,...[...l].map(e=>({id:e,runtime:c??`claude-code`}))].map(e=>{let o=e.note??``,s=ld.filter(t=>n.get(t)===e.id),c=e.id===t,u=a.get(e.id),d=!r.has(e.id)&&!u&&!l.has(e.id),f=c||s.length>0||o!==``;return{id:e.id,runtime:e.runtime,displayName:u?.model.displayName??null,note:o,usedFor:s,isDefault:c,custom:d,discovered:u!==void 0,isNew:u!==void 0&&i[u.runtime].newIds.includes(e.id),noLongerOffered:f&&!u&&(r.has(e.id)||l.has(e.id)||i[e.runtime].knownIds.includes(e.id))&&i[e.runtime].status===`ok`?e.runtime:null,retirement:u?.model.retirement??null}})}function Hm(e){return e.filter(e=>e.isDefault||e.usedFor.length>0||e.note!==``||e.custom||e.isNew)}function Um(e){return e.length-Hm(e).length}function Wm(e,t=Date.now()){let{sources:n}=zm(e);return dd.map(e=>{let r=n[e],i=Rm[e],a=r.lastSuccessAt;if(r.status===`never`)return{runtime:e,text:`${i}: not run yet`,failed:!1};if(r.status===`failed`){let n=a===void 0?``:` (last good ${em(a,t)})`;return{runtime:e,text:`${i}: failed — ${r.error??`unknown error`}${n}`,failed:!0}}let o=r.models.length,s=a===void 0?``:` · ${em(a,t)}`;return{runtime:e,text:`${i}: ${o} ${o===1?`model`:`models`}${s}`,failed:!1}})}function Gm(e){let t={discovered:xd(zm(e)),models:cm(e)},n=Im(e);return hm.map(r=>{let i=Lm(e,r.step),a=i??n;return{...r,value:i,effectiveModel:a,effectiveRuntime:Sd(a,t).runtime}})}function Km(e){let t=e?.fields.find(e=>e.key===`model`);return t?.source===`project`&&Cm(t.value)||null}function qm(e){return[e.label,e.key,e.tooltip]}function Jm(e,t){let n=Pm(e,t).map(e=>({id:e.key,page:t,terms:qm(e)}));return t===`models`?[...n,...Vm(e).map(e=>({id:e.id,page:t,terms:[e.id,e.note,sm[e.runtime]]})),...Gm(e).map(e=>({id:gm(e.step),page:t,terms:[e.label,e.description,e.step]}))]:n}function Ym(e,t){let n={general:0,models:0,burns:0,project:0},r=e.trim().toLowerCase();if(r===``)return{counts:n,matches:new Set(t.map(e=>e.id))};let i=new Set;for(let e of t)e.terms.some(e=>e.toLowerCase().includes(r))&&(i.add(e.id),n[e.page]+=1);return{counts:n,matches:i}}function Xm(e){return Zm.test(e)?{page:`burns`,field:`sandcastle-image`}:null}var Zm=/Settings\s*→\s*(?:Workers|AFK burns|Burns)/i;function Qm(e){let t=Zm.exec(e),n=Xm(e);return!t||!n?null:{before:e.slice(0,t.index),phrase:t[0],after:e.slice(t.index+t[0].length),location:n}}var $m=[{key:`identity`,label:`Git identity`},{key:`runtimes`,label:`Coding agents`},{key:`afk`,label:`AFK burns`},{key:`project`,label:`First project`}];function eh(e){return e?.status===`ok`?`runtimes`:`identity`}function th(e){return $m[$m.findIndex(t=>t.key===e)+1]?.key}function nh(e,t){if(e!==eh(t))return $m[$m.findIndex(t=>t.key===e)-1]?.key}var rh={"claude-code":{kind:`claude-login`,command:`claude auth login`},codex:{kind:`codex-login`,command:`codex login`}};function ih(e){return dd.map(t=>{let n=n=>e.find(e=>e.runtime===t&&e.check===n),r=n(`binary`),i=r?.status===`ok`,a=n(`auth`)?.status===`ok`,o=t===`codex`?a:n(`afk-key`)?.status===`ok`;return{runtime:t,label:sm[t],installed:i,authed:a,afkReady:o,talkReady:i&&(a||o),detail:r?.detail??`not checked`,...i||!r?.fix?{}:{installFix:r.fix}}})}function ah(e){return e.filter(e=>e.talkReady).map(e=>e.runtime)}function oh(e){return e.find(e=>e.id===`git-identity`)?.status===`ok`&&ah(ih(e)).length>0}function sh(e){return e?.status===`ok`?`detected from git config: ${e.detail}`:void 0}function ch(e,t){let n=$m.findIndex(t=>t.key===e),r=sh(t);return $m.map((e,t)=>e.key===`identity`&&t<n&&r?{...e,state:`passed`,detected:r}:{...e,state:t<n?`done`:t===n?`current`:`todo`})}var lh=`review-artifacts`;function uh(e,t=!0){return ct({enabled:t,queryKey:[lh,e],queryFn:async()=>{let t=await fetch(lf(e));if(!t.ok)throw Error(`review artifacts: ${t.status}`);return await t.json()}})}function dh(e){if(!e)return null;for(let t of Array.from(e.files))if(t.type.startsWith(`image/`))return t;for(let t of Array.from(e.items)){if(t.kind!==`file`||!t.type.startsWith(`image/`))continue;let e=t.getAsFile();if(e)return e}return null}async function fh(e){if(e.type===`image/png`)return e;let t=await createImageBitmap(e),n=document.createElement(`canvas`);n.width=t.width,n.height=t.height;let r=n.getContext(`2d`);if(!r)throw Error(`this browser offered no 2d canvas to convert the image with`);return r.drawImage(t,0,0),t.close(),await new Promise((e,t)=>{n.toBlob(n=>{n?e(n):t(Error(`the browser produced no PNG from that image`))},`image/png`)})}async function ph(e,t){let n=await fetch(ff(e),{method:`POST`,headers:{"content-type":`image/png`},body:t});if(!n.ok)throw Error(`screenshot upload: ${n.status}`)}var mh=`connecting`,hh=new Set;function gh(e){if(e!==mh){mh=e;for(let e of hh)e()}}function ree(e){return hh.add(e),()=>hh.delete(e)}function _h(){return(0,z.useSyncExternalStore)(ree,()=>mh)}var iee=3e4,vh=1500;function yh(e=vh){return bh(_h(),e)}function bh(e,t=vh){return e===`live`?iee:t}var xh=5e3,Sh=1e4;function Ch(e){let t=null,n=null,r=Date.now(),i=!1,a=!1,o=!1,s=()=>{if(a){o=!0;return}let t=e.resyncAll();if(!t)return;a=!0;let n,r=new Promise(e=>{n=setTimeout(e,Sh)});Promise.race([t.catch(()=>{}),r]).then(()=>{clearTimeout(n),a=!1,o&&!i&&(o=!1,s())})},c=()=>{n?.(),n=null,t?.close(),t=null},l=()=>{if(i)return;c(),gh(`connecting`),r=Date.now();let a=new EventSource(`/api/stream`);t=a;let o=()=>{r=Date.now(),gh(`live`),s(),e.resyncTranscript()},l=t=>{r=Date.now(),gh(`live`);let n;try{n=JSON.parse(t.data)}catch{s();return}n.kind===`transcript`?e.resyncTranscript():s()},u=()=>{r=Date.now()},d=()=>{gh(a.readyState===EventSource.CLOSED?`offline`:`connecting`)};a.addEventListener(`ready`,o),a.addEventListener(`live`,l),a.addEventListener(`ping`,u),a.addEventListener(`error`,d),n=()=>{a.removeEventListener(`ready`,o),a.removeEventListener(`live`,l),a.removeEventListener(`ping`,u),a.removeEventListener(`error`,d)}},u=()=>{i||Date.now()-r<=35e3||l()},d=setInterval(u,xh),f=()=>{document.visibilityState===`visible`&&u()};return window.addEventListener(`focus`,u),window.addEventListener(`online`,u),document.addEventListener(`visibilitychange`,f),l(),()=>{i=!0,clearInterval(d),window.removeEventListener(`focus`,u),window.removeEventListener(`online`,u),document.removeEventListener(`visibilitychange`,f),c(),gh(`connecting`)}}function wh(){let e=H.useUtils(),t=Ge(),n=_h(),r=(0,z.useRef)(e);return r.current=e,(0,z.useEffect)(()=>Ch({resyncAll:()=>{let e=r.current,n=[];return n.push(e.events.invalidate()),n.push(e.feature.list.invalidate()),n.push(e.feature.get.invalidate()),n.push(e.feature.driveInfo.invalidate()),n.push(e.feature.rounds.invalidate()),n.push(e.feature.readyDeclarations.invalidate()),n.push(e.feature.sessions.invalidate()),n.push(e.feature.driveScenarios.invalidate()),n.push(e.notes.invalidate()),n.push(e.projectNotes.invalidate()),n.push(e.findings.invalidate()),n.push(e.project.prep.invalidate()),n.push(e.run.get.invalidate()),n.push(e.run.listByFeature.invalidate()),n.push(e.project.list.invalidate()),n.push(e.docs.invalidate()),n.push(e.settings.get.invalidate()),n.push(e.setup.imageBuildTarget.invalidate()),n.push(e.project.sessionBranch.invalidate()),n.push(e.feature.commitCount.invalidate()),n.push(e.feature.mergeDelta.invalidate()),n.push(e.project.prepSession.invalidate()),n.push(e.project.projectSession.invalidate()),n.push(e.project.conversations.invalidate()),n.push(e.design.status.invalidate()),n.push(t.invalidateQueries({queryKey:[lh]})),Promise.allSettled(n)},resyncTranscript:()=>{r.current.run.agentTranscript.invalidate()}}),[]),n}function Th(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Eh(e){return new Date(e).toLocaleString()}var Dh=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})/g;function Oh(e,t=Eh){return e.replace(Dh,e=>{let n=Date.parse(e);return Number.isNaN(n)?e:t(n)})}function kh(e){return e.slice(0,7)}var Ah=[`B`,`kB`,`MB`,`GB`,`TB`];function jh(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=Math.min(Math.floor(Math.log10(e)/3),Ah.length-1),n=e/1e3**t;return`${n.toFixed(+(t>0&&n<10))} ${Ah[t]}`}function Mh(e,t=Date.now()){let n=Math.max(0,Math.floor((t-e)/1e3));if(n<5)return`now`;if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Nh(e,t=Date.now()){let n=Mh(e,t);return n===`now`?`just now`:`${n} ago`}function Ph(e,t){let n=Math.max(0,Math.floor((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60;return r>0?`${r}h ${String(i).padStart(2,`0`)}m`:i>0?`${i}m ${String(a).padStart(2,`0`)}s`:`${a}s`}function Fh(e){return e.filter(e=>!e.satisfied)}function Ih(e){return e.satisfied?`merged`:e.status===`archived`?`archived`:e.status===`draft`?`draft`:`in progress`}function Lh(e){return Fh(e).map(e=>`${e.slug} (${Ih(e)})`).join(`, `)}function Rh(e){let t=Fh(e).map(e=>e.slug),n=t.length===1?`starts by itself when ${t[0]} ships`:`starts by itself when these ship: ${t.join(`, `)}`,r=vf(e).map(e=>e.slug);return r.length>0?`${n} — won't start until you start ${r.join(`, `)}`:n}function zh(e){let t=Fh(e);return t.length===0?null:`Waits on ${t.map(e=>e.status===`archived`?`${e.slug} (archived — remove it to start)`:`${e.slug} (${Ih(e)})`).join(`, `)}`}function Bh(e,t,n){let r=new Set(n.map(e=>e.featureId));return e.filter(e=>e.projectId===t.projectId&&e.id!==t.id&&!r.has(e.id)&&!yf(e))}var Vh=e=>gf(e,e.dependsOn);function Hh(e){return!!e.liveSession&&!e.liveSession.awaitingInput}function Uh(e){return e.status===`draft`?Vh(e)===`stuck`?{kind:`stuck`,label:e.upNextProblem??_f(e.dependsOn)}:null:e.status===`shipped`||e.status===`archived`||e.activeRun||e.liveSession&&!e.liveSession.awaitingInput?null:e.waitingReason?{kind:`waiting`,label:e.waitingReason}:e.liveSession?.awaitingInput?{kind:`input`,label:`the chat is waiting on you`}:null}function Wh(e){let{total:t,done:n,cancelled:r}=e.ticketCounts,i=t-r;return i>0?n/i:0}function Gh(e){return e.status===`draft`?`draft`:e.status===`shipped`?`shipped`:`active`}function Kh(e,t=Date.now()){let n=Uh(e);if(n)return{kind:`needsMe`,text:`Needs you`,title:n.label,needs:n.kind};if(e.activeRun)return{kind:`working`,text:`Working`,title:`agent working`};if(Hh(e))return{kind:`working`,text:`Working`,title:`the agent is working in the session`};if(e.status===`shipped`)return{kind:`shipped`,text:``,title:`shipped`};let r=Vh(e);if(r){let t=Fh(e.dependsOn),n=e=>t.length===1?`${e} ${t[0].slug}`:`${e} ${t.length}`;return r===`upNext`?{kind:`draft`,text:n(`After`),title:Rh(e.dependsOn)}:r===`blocked`?{kind:`draft`,text:n(`Blocked by`),title:`blocked by ${Lh(e.dependsOn)}`}:r===`readyToStart`?{kind:`draft`,text:`Ready to start`,title:`everything it waited on shipped — click Start to cut its branch`}:{kind:`draft`,text:`In the backlog`,title:`parked — click Start to cut its branch`}}let i=Mh(e.lastActivityAt,t);return{kind:`age`,text:i,title:`last activity ${i===`now`?`just now`:`${i} ago`}`}}function qh(e){let{total:t,done:n,cancelled:r}=e.ticketCounts,i=t-r;return i>0?`${n}/${i}`:null}function Jh(e,t){return[...e].map((e,t)=>({f:e,i:t})).sort((e,n)=>t(e.f)-t(n.f)||e.i-n.i).map(e=>e.f)}var Yh={readyToStart:0,backlog:1,blocked:2},Xh=e=>{let t=Vh(e);return(t&&Yh[t])??0};function Zh(e){if(e.length!==0)return[...e].sort((e,t)=>t.startedAt-e.startedAt)[0]}function Qh(e){if(e.status===`archived`)return`archived`;if(e.status===`shipped`)return`shipped`;let t=Vh(e);return t===`upNext`?`upNext`:t===`stuck`?`needsYou`:t?`drafts`:e.activeRun?`agentWorking`:Uh(e)?`needsYou`:Hh(e)?`agentWorking`:`inProgress`}function $h(e,t={}){let n={needsYou:[],agentWorking:[],inProgress:[],upNext:[],drafts:[],shipped:[],archived:[]};for(let t of e)n[Qh(t)].push(t);n.drafts=Jh(n.drafts,Xh);let r=[{key:`needsYou`,label:`Needs you`},{key:`agentWorking`,label:`Agent working`},{key:`inProgress`,label:`In progress`},{key:`upNext`,label:`Up next`},{key:`drafts`,label:`Backlog`},{key:`shipped`,label:`Shipped`}];return t.showArchived&&r.push({key:`archived`,label:`Archived`}),r.map(({key:e,label:t})=>({key:e,label:t,features:n[e]})).filter(e=>e.features.length>0)}function eg(e,t={}){let n=$h(e,t);return{inbox:n.find(e=>e.key===`needsYou`)?.features??[],lanes:n.filter(e=>e.key!==`needsYou`)}}var tg=[`needsYou`,`agentWorking`,`inProgress`];function ng(e){for(let t of tg){let n=e.find(e=>Qh(e)===t);if(n)return n}return null}function rg(e){return e.length===0?{view:`open`,projectId:null}:e.length===1?{view:`project`,projectId:e[0].id}:{view:`home`,projectId:null}}function ig(e,t,n){return n?t?.view===`project`&&e.some(e=>e.id===t.projectId)?{view:`project`,projectId:t.projectId}:t?.view===`home`&&e.length>0?{view:`home`,projectId:null}:rg(e):{view:`setup`,projectId:null}}function ag(e,t,n,r){let i=t&&t.kind!==`home`?t.projectId:null;return r&&i&&e.some(e=>e.id===i)?{view:`project`,projectId:i}:ig(e,n,r)}function og(e,t){return(e.view===`project`?!t.some(t=>t.id===e.projectId):e.view===`home`&&t.length===0)?rg(t):null}function sg(e){return Uh(e)!==null}function cg(e){let t=e.filter(e=>e.activeRun).length,n=e.filter(sg).length,r=e.filter(e=>e.status===`shipped`).length,i=e.length;return{total:i,needsYou:n,activeRuns:t,shipped:r,health:i===0?`empty`:n>0?`attention`:t>0?`working`:`steady`}}function lg(e){let t=ug(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n<0?t:t.slice(n+1)}function ug(e){return e.replace(/[\\/]+$/,``)}var dg=/does not exist|cannot read/i;function fg(e,t){let n=e?.trim()||void 0;return!n||!t||!dg.test(t)?{dir:n,keepTyped:!1}:{dir:pg(n),keepTyped:!0}}function pg(e){let t=ug(e),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));if(n<=0)return;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}\\`:/^[\\/]+$/.test(r)?void 0:r}var mg=[{match:/path does not exist: (.*)$/i,message:`Path does not exist`,hint:`Check the path, or pick a folder from the rail.`},{match:/cannot read (?:path|directory): (.*?)(?: \(.*\))?$/i,message:`Cannot read that folder`,hint:`It may need permissions this machine does not have.`},{match:/path is not absolute: (.*)$/i,message:`Enter an absolute path`,hint:`A path from the root of the machine runcastle runs on.`}];function hg(e){for(let t of mg){let n=t.match.exec(e);if(n)return{message:t.message,hint:t.hint,path:n[1].trim()||null}}return{message:e,hint:null,path:null}}function gg(e,t){let n=t.trim()||null;if(/not a git repository/i.test(e))return{message:`Not a git repository`,hint:`runcastle tracks work as branches, so it needs a git repository. Initialize one here, or pick a folder that already is one.`,path:n,offer:`init-repo`};let r=/does not exist/i.test(e);return r||/cannot read/i.test(e)?{message:r?`Path does not exist`:`Cannot read that path`,hint:`Check the path, or use Browse… to find the folder.`,path:n}:{message:e,hint:null,path:null}}var _g=[`plan`,`work`,`review`,`details`,`design`,`drive`];function vg(e){return _g.includes(e)}var yg={body:`work`,preview:`plan`};function bg(e){return vg(e)?e:yg[e]??null}var xg={testDrive:`drive`},Sg=[`decisions.md`,`spec.md`];function Cg(e){return!!e.preview||e.docs.some(e=>Sg.some(t=>e.relPath.endsWith(t)))}function wg(e){return e.some(e=>e.kind===`review`&&e.status!==`pending`&&e.status!==`cancelled`)}function Tg(e){if(e.isDraft)return[];let t={plan:e.hasPlan,work:e.hasTickets,review:e.hasReview||e.shipped,details:!0,design:e.designRunning,drive:e.driveActive};return _g.filter(e=>t[e])}function Eg({driveActive:e,hasNotes:t}){return[...e?[`drive`]:[],...t?[`details`]:[]]}function Dg(e){return e===`details`?`Notes`:kg[e]}function Og(e,t){if(e.type!==`panel.show`||e.featureId!==t)return null;let n=e.data??{},r=typeof n.view==`string`?bg(n.view):null;return r?{view:r,...typeof n.path==`string`?{path:n.path}:{},...typeof n.width==`number`&&Number.isInteger(n.width)&&n.width>0?{width:n.width}:{}}:null}var kg={plan:`Plan`,work:`Work`,review:`Review`,design:`Design`,drive:`Drive`,details:`Details`},Ag=.5,jg={view:null,share:Ag,collapsed:!1};function Mg(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):Ag}function Ng(e,t){switch(t.type){case`open`:{let n=Pg(e,t.view,t.origin,t.path);if(t.view!==`design`)return n;let{width:r,...i}=n;return t.width===void 0?i:{...i,width:t.width}}case`follow`:return Pg(e,xg[t.click],`runcastle`);case`switch`:return Pg(e,t.view,`human`);case`close`:{let{path:t,width:n,origin:r,...i}=e,a=e.view??e.last;return{...i,view:null,collapsed:!1,...a?{last:a}:{}}}case`setWidth`:return{...e,share:Mg(t.share)};case`toggleFull`:return{...e,share:e.share>=1?Ag:1,collapsed:!1};case`collapse`:return e.view?{...e,collapsed:!0}:e;case`expand`:return{...e,collapsed:!1};case`toggle`:{if(e.view)return Ng(e,{type:`close`});let n=e.last&&t.views.includes(e.last)?e.last:t.views[0];return n?Pg(e,n,`human`):e}}}function Pg(e,t,n,r){return{...e,view:t,last:t,origin:n,collapsed:!1,...t===`design`&&r!==void 0?{path:r}:{}}}function aee(e){return e===`chat`||e!==`work`&&vg(e)}function Fg(e){return e===null?null:e===`tickets`||e===`overview`?`work`:e===`chat`?e:bg(e)}function oee(e){return e.view??`work`}function Ig(e){return e.kind===`home`?null:e.projectId}function Lg(e){if(e.kind===`home`)return`/`;let t=`/p/${encodeURIComponent(e.projectId)}`;switch(e.kind){case`project`:return t;case`chat`:return`${t}/chat`;case`prepare`:return`${t}/prepare`;case`feature`:{let n=`${t}/f/${encodeURIComponent(e.featureSlug)}`;return e.view?`${n}/${e.view}`:n}}}function see(e){try{return e.split(`/`).filter(e=>e.length>0).map(decodeURIComponent)}catch{return null}}function Rg(e){let t=see(e);if(!t)return null;if(t.length===0)return{kind:`home`};if(t[0]!==`p`)return null;let n=t[1];if(!n)return null;if(t.length===2)return{kind:`project`,projectId:n};if(t.length===3&&t[2]===`chat`)return{kind:`chat`,projectId:n};if(t.length===3&&t[2]===`prepare`)return{kind:`prepare`,projectId:n};if(t.length===4&&t[2]===`f`&&t[3])return{kind:`feature`,projectId:n,featureSlug:t[3]};let r=t[4];if(t.length===5&&t[2]===`f`&&t[3]&&r&&aee(r))return{kind:`feature`,projectId:n,featureSlug:t[3],view:r};let i=t[3],a=t.length===5&&t[2]===`f`&&i&&r?Fg(r):null;return i&&a===`work`?{kind:`feature`,projectId:n,featureSlug:i}:i&&a===`plan`?{kind:`feature`,projectId:n,featureSlug:i,view:a}:null}function zg(e,t){return!e||e.kind===`home`||e.kind===`project`?null:e.projectId===t?e:null}function Bg(e){let{projectId:t,featureView:n=`work`}=e;if(e.preparing)return{kind:`prepare`,projectId:t};if(e.projectSelected)return{kind:`chat`,projectId:t};if(e.featureSlug){let r={kind:`feature`,projectId:t,featureSlug:e.featureSlug};return n===`work`?r:{...r,view:n}}return{kind:`project`,projectId:t}}function Vg(){return typeof window>`u`?`/`:window.location.pathname}function Hg(e){typeof window>`u`||Vg()===e||window.history.pushState(null,``,e)}function Ug(e){typeof window>`u`||Vg()===e||window.history.replaceState(null,``,e)}function Wg(e,t){let n=e?Lg(e):null,r=(0,z.useRef)(!1);(0,z.useEffect)(()=>{if(n===null){r.current=!1;return}Vg()!==n&&(r.current?window.history.pushState(null,``,n):window.history.replaceState(null,``,n)),r.current=!0},[n]);let i=(0,z.useRef)(t);(0,z.useEffect)(()=>{i.current=t}),(0,z.useEffect)(()=>{let e=()=>i.current(Rg(Vg()));return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[])}var Gg=`runcastle.project.v1`;function Kg(){let e;try{e=localStorage.getItem(Gg)}catch{return null}if(!e)return null;try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;let n=t;return n.view===`home`?{view:`home`}:n.view===`project`&&typeof n.projectId==`string`?{view:`project`,projectId:n.projectId}:null}catch{return null}}function qg(e){try{localStorage.setItem(Gg,JSON.stringify(e))}catch{}}function Jg(){let e=H.project.list.useQuery(void 0,{refetchInterval:yh(5e3)}),t=e.data,n=H.setup.doctor.useQuery(void 0,{refetchOnWindowFocus:!1,retry:!1,retryOnMount:!1}),[r]=(0,z.useState)(Kg),[i]=(0,z.useState)(()=>Rg(Vg())),[a,o]=(0,z.useState)(null),s=(0,z.useRef)(null),c=!n.data||oh(n.data.results);!s.current&&t&&!n.isLoading&&(s.current=ag(t,i,r,c));let l=a??s.current,u=l?.view??`home`,d=l?.projectId??null,f=(0,z.useRef)(!1);(0,z.useEffect)(()=>{if(!t||!l)return;let e=og(l,t);e&&(f.current=!1,o(e))},[t,l]),(0,z.useEffect)(()=>{f.current||!l||(f.current=!0,l.view===`project`&&l.projectId?Ig(Rg(Vg())??{kind:`home`})!==l.projectId&&Ug(Lg({kind:`project`,projectId:l.projectId})):Ug(`/`))},[l]),(0,z.useEffect)(()=>{let e=()=>{let e=Ig(Rg(Vg())??{kind:`home`});o(e?{view:`project`,projectId:e}:{view:`home`,projectId:null})};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let p=(0,z.useCallback)(()=>{o({view:`home`,projectId:null}),qg({view:`home`}),Hg(`/`)},[]),m=(0,z.useCallback)(e=>{o({view:`project`,projectId:e}),qg({view:`project`,projectId:e}),Hg(Lg({kind:`project`,projectId:e}))},[]),h=(0,z.useCallback)(()=>o({view:`open`,projectId:d}),[d]),g=(0,z.useCallback)(()=>{u===`open`&&o(d?{view:`project`,projectId:d}:{view:`home`,projectId:null})},[u,d]),_=t?.find(e=>e.id===d),v=n.refetch,y=(0,z.useCallback)(()=>{v()},[v]);return{projects:t,loading:e.isLoading||n.isLoading,doctorError:n.error?.message??null,recheckDoctor:y,view:u,currentProjectId:d,currentProject:_,goHome:p,enterProject:m,showOpen:h,cancelOpen:g}}var Yg=`runcastle.selected.v1`,Xg=`runcastle.preparing.v1`,Zg=`runcastle.guidance`,Qg=`runcastle.feature.tab`;function $g(e){return`${Yg}:${e}`}function e_(e){return`${Xg}:${e}`}function t_(e){return`${Qg}:${e}`}function n_({stored:e,isDraft:t}){return t?`work`:Fg(e)??`chat`}function r_(e,t){return n_({stored:i_(t_(e)),isDraft:t?.status===`draft`})}function i_(e){try{return localStorage.getItem(e)}catch{return null}}function a_(e,t){try{localStorage.setItem(e,t)}catch{}}function o_(e){try{localStorage.removeItem(e)}catch{}}function s_(e){let t=$g(e),n=e_(e),[r,i]=(0,z.useState)(()=>i_(t)),[a,o]=(0,z.useState)(()=>{let e=i_(t);return e&&Fg(i_(t_(e)))||`chat`}),[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(()=>i_(n)===`1`),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(!1),[h,g]=(0,z.useState)(null),[_,v]=(0,z.useState)(()=>i_(Zg)!==`0`);(0,z.useEffect)(()=>{r?a_(t,r):o_(t)},[r,t]),(0,z.useEffect)(()=>{a_(n,l?`1`:`0`)},[l,n]),(0,z.useEffect)(()=>{a_(Zg,_?`1`:`0`)},[_]);let y=(0,z.useCallback)((e,t=`chat`)=>{i(e),o(t),e&&a_(t_(e),t),c(!1),u(!1),f(!1),m(!1)},[]),b=(0,z.useCallback)(()=>{f(!0),c(!1),u(!1),m(!1)},[]),x=(0,z.useCallback)(e=>{o(e),r&&a_(t_(r),e)},[r]),S=(0,z.useCallback)(()=>{c(!0),u(!1),f(!1),m(!1)},[]),C=(0,z.useCallback)(()=>{u(!0),c(!1),f(!1),m(!1)},[]),w=(0,z.useCallback)((e={page:`general`})=>{g(e),m(!1)},[]),T=(0,z.useCallback)(()=>g(null),[]);return{selectedFeatureId:r,projectSelected:d,featureView:a,creating:s,preparing:l,cmdkOpen:p,settings:h,guidance:_,select:y,selectView:x,selectProject:b,startDraft:S,startPreparation:C,cancelCreate:(0,z.useCallback)(()=>c(!1),[]),closePreparation:(0,z.useCallback)(()=>u(!1),[]),setCmdk:m,openSettings:w,closeSettings:T,toggleGuidance:(0,z.useCallback)(()=>v(e=>!e),[])}}function c_(e){return e.branches.includes(e.current)?e.current:e.branches.includes(e.detected)?e.detected:``}function l_(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)}function u_(e,t){let n=l_(e);if(n===``)return null;let r=t.find(e=>e.slug===n);if(!r)return null;let i=r.status===`shipped`?`was already shipped`:`already exists`;return`“${r.title}” ${i} on feature/${r.slug}. Creating this makes a second feature and a second branch.`}function d_(e){return e.split(/\r?\n/).filter(e=>e.startsWith(`## `)).length}function f_(e,t,n){return`Proceed with your task: RESOLVE A MERGE CONFLICT. Merging ${e} into ${t} conflicts on: ${n.length?n.join(`, `):`(run git status to see the conflicts)`}. Your working directory IS the talk worktree, already checked out on ${t}. Run \`git merge ${e}\`, then resolve every conflict using this feature’s spec.md and decisions.md for intent. ${p_} Then commit the merge. Do NOT push. When the merge commit is in, tell me to click “Merge & ship” again for a clean retry — ${m_}`}var p_="Verify without dependencies — package installs are blocked in this worktree: run `git diff --check` and grep for leftover `<<<<<<<` / `>>>>>>>` markers, re-read each resolved hunk against both sides, and confirm every import and symbol the merged code uses exists on the merged side.",m_=`and that I can test-drive the branch first (it runs in the main checkout, with dependencies) for a real run.`;function h_(e){let t=e.files.length?e.files.join(`, `):`(run git status after the merge to see them)`;return`Proceed with your task: RESOLVE A MERGE CONFLICT. Ticket #${e.seq} (“${e.title}”) is fully implemented on branch ${e.branch}, but landing it on ${e.featureBranch} conflicts on: ${t}. Your working directory IS the talk worktree, already checked out on ${e.featureBranch}. Run \`git merge ${e.branch}\`, read both sides before resolving (the ticket's work on one side, the sibling tickets that landed first on the other), and resolve by intent using this feature's spec.md and decisions.md — keep BOTH sides working. ${p_} Then commit the merge. Do NOT push. When the merge commit is in, retry the ticket with dispatch_round({ seqs: [${e.seq}] }) so runcastle records it as landed, then tell me it is in — ${m_}`}var g_=[`burn.started`,`merge.resolved`,`feature.shipped`];function __(e){let t=!1,n=!1;for(let r of e)r.type===`merge.conflict`?(t=!0,n=!1):r.type===`merge.resolved`?n=t:g_.includes(r.type)&&(t=!1,n=!1);return n}function v_(e){let t=e.data?.sessionId;return typeof t==`string`?t:void 0}function y_(e,t){let n=new Set(t.filter(e=>e.purpose===`resolve-conflict`).map(e=>e.id)),r=!1;for(let t of e)if(t.type===`merge.conflict`||g_.includes(t.type))r=!1;else if(t.type===`session.ended`||t.type===`session.reconciled`){let e=v_(t);e&&n.has(e)&&(r=!0)}return r}function b_(e){return[...e].reverse().find(e=>e.type===`testdrive.started`)?.ts??null}function x_(e,t){return e===null?{value:`Not run`,tone:`idle`}:t.some(t=>t.kind!==`review`&&t.status===`done`&&(t.completedAt??0)>e)?{value:`Taken`,sub:`not since`,tone:`warn`}:{value:`Taken`,tone:`ok`}}function S_(e){if(typeof e!=`object`||!e)return;let t=e.wallMs;return typeof t==`number`&&Number.isFinite(t)&&t>=0?t:void 0}function C_(e){let t=new Map,n=new Map;for(let r of e){if(!r.ticketId)continue;if(r.type===`ticket.timing`){let e=S_(r.data);e!==void 0&&n.set(r.ticketId,e)}let e=t.get(r.ticketId);e?(e.min=Math.min(e.min,r.ts),e.max=Math.max(e.max,r.ts)):t.set(r.ticketId,{min:r.ts,max:r.ts})}let r=new Map(n);for(let[e,n]of t)!r.has(e)&&n.max>n.min&&r.set(e,n.max-n.min);return r}function w_(e,t,n=Date.now()){if(e.status!==`launching`)return!1;let r=t.find(t=>t.type===`session.launching`&&t.data?.sessionId===e.id);return!!r&&n-r.ts>3e4}function T_(e,t){let n=!1;for(let r of e)r.data?.sessionId===t&&(r.type===`session.not_ready`?n=!0:(r.type===`session.started`||r.type===`session.ended`)&&(n=!1));return n}function E_(e){return e.status===`launching`||e.status===`live`}function D_(e){return e.status===`launching`?`launching…`:`live`}function O_(e){return e.find(e=>E_(e)&&e.kind!==`scenario`&&e.kind!==`side`)}var k_={label:`Chat`,kind:`chat`},A_={label:`Plan it yourself`,kind:`selfPlan`},j_={loading:`Loading the branch list…`,unpicked:`pick a branch first`},M_={label:`Move to backlog`,kind:`moveToBacklog`};function N_(e){return!!e&&e.includes(`merged into different branches`)}function P_(e){let t=e.map(e=>e.slug);return t.length<2?t[0]??``:`${t.slice(0,-1).join(`, `)} and ${t.at(-1)}`}function F_(e){return`${P_(e)} ${e.length===1?`ships`:`ship`}`}function I_({full:e,ctx:t}){let n=zh(e.dependsOn)??(t.draftBaseMissing?j_[t.draftBaseMissing]:null),r=n?{disabled:n}:{},i={label:`Start`,kind:`startDraft`,...r},a={...A_,...r},o=Fh(e.dependsOn);switch(gf(e.feature,e.dependsOn)){case`blocked`:{let e=`Start when ready: starts by itself when ${F_(o)}; it can't be undone.`;return{kick:`NEXT STEP`,title:`Start this feature`,desc:`In the backlog. You can make it start by itself instead, as soon as what it waits on ships.`,primary:i,secondary:[a,{label:`Start when ready`,kind:`markUpNext`,hint:e}],busy:!1,note:e}}case`upNext`:{let t=vf(e.dependsOn);return{kick:`UP NEXT`,...t.length>0?{title:`Won't start until you start ${P_(t)}`,desc:`${P_(t)} ${t.length===1?`is`:`are`} in the backlog, so nothing will move ${t.length===1?`it`:`them`}. It starts by itself once ${o.length===1?`${P_(o)} has shipped`:`${P_(o)} have all shipped`}.`}:{title:`Starts by itself when ${F_(o)}`,desc:`Its branch will be cut from the branch ${o.length===1?`${P_(o)} merges`:`they merge`} into. Nothing launches and no tokens are spent.`},secondary:[M_],busy:!1}}case`stuck`:return{alert:!0,kick:`NEXT STEP`,title:`Didn't start by itself`,desc:L_(e.upNextProblem??_f(e.dependsOn),e.dependsOn),primary:i,secondary:[a,M_],busy:!1};default:return{kick:`NEXT STEP`,title:`Start this feature`,desc:`In the backlog — Start cuts its branch, writes the brief, and opens the grill with you. Plan it yourself makes the plan without you.`,primary:i,secondary:[a],busy:!1}}}function L_(e,t){let n=e.replace(/^(?:didn't|couldn't) start by itself:\s*/i,``);return t.some(e=>n.startsWith(`${e.slug} `))?n:n.charAt(0).toUpperCase()+n.slice(1)}function R_(e){let t=[...e.filter(e=>e.kind===`chat`)].reverse();return t.find(e=>e.status!==`ended`)??t[0]}function z_(e){return e.kind===`chat`&&e.purpose===`self-plan`}function B_(e){return!!e.headless||z_(e)}function V_(e){return e.flatMap(e=>{if(e.type!==`session.run_ended`)return[];let t=e.data;return t?.complete===!1&&typeof t.sessionId==`string`?[t.sessionId]:[]})}function H_(e){return e.kind===`chat`?`Feature chat`:K_(e)}function U_(e){let t=e.filter(e=>e.kind===`chat`);return t.some(e=>e.status!==`ended`||!!e.ccSessionId||e.transcriptMissing)?t:[]}function W_(e){let t=[...e].reverse().find(e=>e.type===`feature.shipped`);return t?t.ts:null}function G_(e){let t=O_(e);return!t||B_(t)?null:{sessionId:t.id,text:`${K_(t)} live`}}function K_(e){switch(e.kind){case`chat`:return`Agent`;case`drive-fix`:return`Drive fix`;case`prepare`:return`Preparation`;case`project`:return`Project`;case`scenario`:return`Scenario`;case`side`:return`Side session`}}function q_(e){let{live:t,full:n,ctx:r}=e;if(t&&kd(t))return{...J_[t.purpose===`relay`||t.purpose===`start-lap`?t.purpose:`self-plan`],primary:{label:`Stop`,kind:`stopHeadlessRun`},secondary:[],busy:!0};let{sessions:i}=n;if(t)return null;let a=i.filter(e=>e.kind===`chat`).at(-1);return!a||a.status!==`ended`||a.purpose!==`relay`&&a.purpose!==`start-lap`||!B_(a)||!r.unfinishedRuns?.includes(a.id)?null:{kick:`STOPPED`,title:Y_[a.purpose],desc:`Chat picks up what it had done.`,primary:{label:`Resume session`,kind:`chat`},secondary:[{label:`Merge & ship`,kind:`merge`}],busy:!1}}var J_={"self-plan":{kick:`PLANNING ITSELF`,title:`Planning itself`,desc:`No terminal to watch; the plan appears below as it is written.`},relay:{kick:`WORKING`,title:`Working on a change the orchestrator sent back`,desc:`No terminal to watch; the docs and tickets update as it works.`},"start-lap":{kick:`PLANNING ITSELF`,title:`Planning more work itself`,desc:`No terminal to watch; the new tickets appear below as they are written.`}},Y_={relay:`The orchestrator’s change stopped before it was finished`,"start-lap":`Planning stopped before its tickets were ready`},X_={kick:`NEXT STEP`,secondary:[],busy:!1};function Z_(e,t){let{feature:n,sessions:r}=e,i={full:e,ctx:t,live:O_(r)};return n.status===`draft`?I_(i):n.status===`archived`?{kick:`ARCHIVED`,title:`Feature archived`,desc:`This feature is archived and out of the pipeline. Unarchive it to pick the work back up.`,primary:{label:`Unarchive`,kind:`unarchive`},secondary:[],busy:!1}:q_(i)??X_}var Q_=[`planning`,`building`,`review`,`shipped`],$_={planning:`Shape the feature, write its spec, and emit tickets`,building:`Agents implement each ticket in a sandbox`,review:`Test-drive the branch, plan more work, or merge`,shipped:`Merged to main`};function ev(e){return e?.devUrl?e.devReady?{url:e.devUrl,state:`ready`}:{url:e.devUrl,state:e.devReadyTimedOut?`timedOut`:`starting`}:null}function tv(e){return e.state===`timedOut`?`${e.url} — not answering`:`starting… ${e.url}`}function nv(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function rv(e,t={}){let n=e?.hookFailure;return n?{command:n.command,outcome:n.timedOut?`timed out`:`exited ${n.exitCode??`without a code`}`,output:n.output,canFix:!t.sessionLive}:null}var iv=[`ticket.retry`,`burn.started`,`feature.shipped`];function av(e,t=[],n){let r=null;for(let t of e)if(t.type===`reviewdrive.denied`){let e=t.data??{};r={eventId:t.id,dirtyFiles:Array.isArray(e.dirtyFiles)?e.dirtyFiles.filter(e=>typeof e==`string`):[],message:t.message,at:t.ts}}else iv.includes(t.type)&&(r=null);return!r||r.eventId===n||r.at<Math.max(...t.map(e=>e.startedAt),-1/0)?null:r}var ov=e=>({showDevChip:e,showBranch:e,showOutput:e}),sv={idle:{barTitle:`Review the build`,barDesc:`Open the app when you are ready to test it.`,primary:`start`,stageKind:`player`,footer:ov(!1)},starting:{barTitle:`Starting the test drive`,barDesc:`Preparing the branch and development server.`,primary:`stop`,stageKind:`starting`,footer:ov(!0)},serving:{barTitle:`Test-driving the branch — merge when it looks right`,barDesc:`The development server is ready.`,primary:`stop`,stageKind:`panel`,footer:ov(!0)},"bare-checkout":{barTitle:`Branch checked out for inspection`,barDesc:`Branch checked out — nothing started. This project has no dev command · Set one in Settings`,primary:`stop`,stageKind:`bare`,footer:ov(!0)},"setup-failed":{barTitle:`Drive setup failed — fix it or stop the drive`,barDesc:`The project setup command did not complete.`,primary:`fixDrive`,stageKind:`failed`,footer:ov(!0)},"review-agent-driving":{barTitle:`Review agent driving`,barDesc:`review agent driving — notes land below as it finds things`,primary:`stop`,stageKind:`agent`,footer:ov(!0)}};function cv(e,t={}){return sv[e]}function lv(e){let t=new Map;for(let n of e){if(n.type!==`ticket.gate_unrunnable`||typeof n.data!=`object`||n.data===null)continue;let{command:e,error:r}=n.data;typeof e!=`string`||typeof r!=`string`||e.trim()&&r.trim()&&!t.has(e.trim())&&t.set(e.trim(),{command:e.trim(),error:r.trim()})}return[...t.values()]}var uv=e=>e.error?.toLowerCase().startsWith(`stopped`)||e.orphaned||e.error?.toLowerCase().includes(`orphaned`),dv=(e=``)=>/\b(?:git|docker|podman|mount|sandbox)\b/i.test(e);function fv(e){return e.status===`cancelled`?`waived`:e.status===`failed`?uv(e)?`stopped`:e.hadOutput===!1&&dv(e.error??``)?`launch-failed`:`failed`:e.status===`done`?`done`:e.status===`burning`||e.status===`running`?`burning`:`pending`}function pv(e){if(![`failed`,`launch-failed`].includes(fv(e)))return null;let t=e.error?.trim()||`The ticket did not complete.`,n=/agent made no commits/i.test(t)?`The burner verifies commits landed on the ticket branch — none did`:fv(e)===`launch-failed`?`The agent sandbox never started.`:t,r=/windows|path too long|long path/i.test(t)?`A long Windows path may have prevented the sandbox mount.`:void 0;return{text:n,...r?{hint:r}:{}}}function mv(e){return{done:e.filter(e=>fv(e)===`done`).length,failed:e.filter(e=>[`failed`,`launch-failed`].includes(fv(e))).length,stopped:e.filter(e=>fv(e)===`stopped`).length,waived:e.filter(e=>fv(e)===`waived`).length}}function hv(e,t={},n){if(n!==void 0)return`Retrying #${n}`;let r=e.some(e=>e.kind===`review`&&e.reviewVerdict===`unverified`);if(t.status===`succeeded`&&r)return`Succeeded-unverified · nothing verified`;let i=e.filter(e=>e.kind!==`review`&&!e.reviewFix).length,a=e.filter(e=>e.reviewFix).length;if(t.status===`succeeded`&&e.length>0&&mv(e).done===e.length)return`All ${e.length} ticket${e.length===1?``:`s`} landed`;let o=mv(e.filter(e=>e.kind!==`review`)),s=[`${t.status&&t.status!==`running`?`Ran`:`Running`} ${i} ticket${i===1?``:`s`}`];return a&&s.push(`+${a} fixes from review`),o.done&&s.push(`${o.done} done`),o.failed&&s.push(`${o.failed} failed`),o.stopped&&s.push(`${o.stopped} stopped`),o.waived&&s.push(`${o.waived} waived`),s.join(` · `)}var gv=/<promise>\s*COMPLETE\s*<\/promise>/i,_v=new RegExp(gv,`gi`);function vv(e){return e.replace(_v,``).replace(/\n{3,}/g,`
74
74
 
75
75
  `).trim()}function yv(e){return gv.test(e)}function bv(e){return e.replace(/^.*?(?:\/|\\)repo(?:\/|\\)/,``)}var xv=/[^\s"'`,)]*[/\\]repo[/\\][^\s"'`,)]*/g;function Sv(e){return e.replace(xv,bv)}function Cv(e){let t=[];for(let n of e){if(n.kind===`tool`){t.push({kind:`tool`,name:n.name??`tool`,args:wv(n.text)});continue}let e=t[t.length-1];e&&e.kind===`text`?e.text+=n.text:t.push({kind:`text`,text:n.text})}let n=!1;return{blocks:t.map(e=>e.kind===`text`?(yv(e.text)&&(n=!0),{...e,text:vv(e.text)}):e).filter(e=>e.kind!==`text`||e.text.length>0),completed:n}}function wv(e){let t=Sv(e.replace(/\s+/g,` `).trim());return t.length>300?`${t.slice(0,300)}…`:t}function Tv(e){let t=[...e].sort((e,t)=>e.seq-t.seq),n=t.filter(e=>e.kind===`review`&&e.passKind!==`verification`).at(-1),r=t.filter(e=>e.kind===`review`&&e.passKind===`verification`),i=n?t.filter(e=>e.originFindingId&&e.seq>n.seq):[],a=new Set([...r,...i]),o=t.filter(e=>!a.has(e)),s=i.length||o.filter(e=>e.kind!==`review`).length,c=[];return o.length>0&&c.push({kind:`plain`,rows:o}),i.length>0&&c.push({kind:`review-fixes`,title:`Review fixes`,rows:i}),r.length>0&&c.push({kind:`verification`,title:`Verifying ${s} fixes — recording a fresh walkthrough`,rows:r}),c}function Ev(e){let t=new Map;for(let n of e){if(!n.ticketId)continue;let e=t.get(n.ticketId),r=n.type===`burn.text`||n.type===`burn.tool`;e?r&&(e.hadOutput=!0):t.set(n.ticketId,{hadOutput:r,startedAt:n.ts})}return t}function Dv(e,t){if(e.length<2)return;let n=e.filter(e=>[`pending`,`burning`].includes(fv(e)));if(n.length===1)return t.some(e=>e.type===`ticket.retry`&&e.ticketId===n[0].id)?n[0].seq:void 0}function Ov(e){let t={label:e.command,state:e.outcome};if(e.outcome===`passed`)return t;let n=e.outcome===`failed`?e.exitCode===null?void 0:`exit ${e.exitCode}`:e.reason?.trim()||void 0;return{...t,...n?{detail:n}:{},outputUrl:e.outputUrl}}function kv(e){switch(e.status){case`none_configured`:return{summary:`No checks configured for this project`,short:`no checks configured`,commit:null,tone:`idle`,lines:[]};case`couldnt_run`:return{summary:`Checks couldn't run: ${e.reason}`,short:`checks couldn't run`,commit:e.commit?kh(e.commit):null,tone:`warn`,lines:[],...e.outputUrl?{outputUrl:e.outputUrl}:{}};case`ran`:{let t=e.commands.map(Ov),n=t.filter(e=>e.state===`passed`).length,r=kh(e.commit);return{summary:`${n} of ${t.length} checks passed`,short:`checks ${n}/${t.length} passed @${r}`,commit:r,tone:t.some(e=>e.state===`failed`)?`danger`:t.some(e=>e.state===`couldnt_run`)?`warn`:t.length>0?`ok`:`idle`,lines:t}}}}function Av(e){let t=e.map(e=>Qp[e]??e);return`${t.length===1?t[0]:`${t.slice(0,-1).join(`, `)} and ${t[t.length-1]}`} ${t.length===1?`was`:`were`} never proven by a dry run — run preparation to verify.`}function jv(e){return[...e].sort((e,t)=>(e.completedAt??-1/0)-(t.completedAt??-1/0)||e.seq-t.seq).at(-1)}function Mv(e,t){return jv(e.filter(e=>{if(e.completedAt!==null)return!0;let n=t.find(t=>t.id===e.ticketId)?.status;return n===`done`||n===`failed`}))??null}function Nv(e,t,n){if(n?.state===`running`)return{tone:`verifying`,text:`Verification running — evidence below predates it`};if(n?.state===`failed`){let e=n.reason?.trim();return{tone:`failed`,text:`verification could not run${e?`: ${e}`:``}`}}return e?t.landedSince===0?{tone:`fresh`,text:`Reviewed ✓ · this build`}:{tone:`stale`,text:`Reviewed earlier · ${t.landedSince} tickets landed since — evidence may be outdated`}:{tone:`none`,text:`no review yet`}}function Pv(e){let t=e.filter(e=>e.kind===`review`&&e.passKind===`verification`).at(-1);if(t){if(t.status===`failed`)return{state:`failed`,...t.error?{reason:t.error}:{}};if(!(t.status===`done`||t.status===`cancelled`))return{state:`running`}}}function Fv(e){let t={key:`review`,label:`Review`},n=e.verification;if(n?.state===`running`)return{...t,value:`Verification running`,sub:`the evidence below predates it`,tone:`warn`};if(n?.state===`failed`){let e=n.reason?.trim();return{...t,value:`Verification could not run`,...e?{sub:e}:{},tone:`warn`}}if(!e.artifact)return{...t,value:`Not reviewed yet`,tone:e.building?`idle`:`warn`};let r=e.artifact.gateRun,i=e=>r?`${e} · ${kv(r).short}`:e,a=e.outcome??{kind:`none`};if(a.kind===`unverified`)return{...t,value:`Unverified`,sub:i(`nothing verified`),tone:`warn`};if(a.kind===`could-not-run`)return{...t,value:`Could not run`,sub:i(`nothing verified`),tone:`warn`};let o=a.kind===`verified`?`Verified`:`Reviewed`;if(e.landedSince===0){let e=a.kind===`verified`&&a.mode?`${a.mode} mode · `:``;return{...t,value:o,sub:i(`${e}this build`),tone:`ok`}}return{...t,value:`${o} earlier`,sub:i(`${e.landedSince} landed since`),tone:`warn`}}function Iv(e){let t=Fv(e),n=Lv(e.tickets),r=e.shipped||e.runState===void 0?[]:[zv(e.runState,e.building?.elapsed)];return e.building?[...r,n,t]:[t,n,...Rv(e),...r]}function Lv(e){let t=xf(e),n=bf(e),r=n.filter(e=>e.status===`failed`).length,i=n.filter(e=>e.status===`burning`).length,a=[...r>0?[`${r} failed`]:[],...i>0?[`${i} running`]:[],...t.waived>0?[`${t.waived} waived`]:[]];return{key:`tickets`,label:`Tickets`,value:`${t.landed} of ${t.total} landed`,...a.length>0?{sub:a.join(` · `)}:{},tone:r>0?`danger`:t.waived>0?`warn`:`idle`}}function Rv(e){if(e.driving)return[{key:`drive`,label:`Test drive`,value:`Running`,tone:`ok`}];if(e.drivenAt===void 0)return[];let t=e.unverifiedKeys??[],n=x_(e.drivenAt,e.tickets),r=e.drivenAt===null&&e.noWalkthrough?`the review reported without driving`:void 0,i=t.length>0?`${t.length} check${t.length===1?``:`s`} unverified in drive`:void 0,a=[n.sub,r,i].filter(Boolean).join(` · `);return[{key:`drive`,label:`Test drive`,value:n.value,...a?{sub:a}:{},...i?{detail:Av([...t])}:{},tone:i?`warn`:n.tone}]}function zv(e,t){return{key:`run`,label:`Round`,value:e===`no run recorded`?`None recorded`:e.charAt(0).toUpperCase()+e.slice(1),...t?{sub:t}:{},tone:e===`succeeded`?`ok`:e===`failed`?`danger`:e===`no run recorded`?`idle`:`warn`}}function Bv(e){if(e.openReason===`over-cap`)return`over the auto-fix cap`;if(e.openReason===`fix-failed`){let t=e.failureReason?.trim();return t?`fix failed: ${t}`:`fix failed`}return e.openReason===`verification`?`found by the verification pass — not auto-fixed`:null}function Vv(e){let t=e.resolutionNote?.trim()||void 0;return e.status===`fixed`?e.resolvedBy===`session`?{text:`closed by a session as addressed — no fix ticket verified it`,evidence:`attested`,...t?{note:t}:{}}:e.resolvedBy===`fix-ticket`?{text:`fixed by its fix ticket`,evidence:`verified`}:null:null}function Hv(e){let[t]=(e??``).trim().split(`
package/web/index.html CHANGED
@@ -18,7 +18,7 @@
18
18
  document.documentElement.dataset.theme = t
19
19
  })()
20
20
  </script>
21
- <script type="module" crossorigin src="/assets/index-CPgKzYyE.js"></script>
21
+ <script type="module" crossorigin src="/assets/index-DJf8BQof.js"></script>
22
22
  <link rel="stylesheet" crossorigin href="/assets/index-B1MyomR6.css">
23
23
  </head>
24
24
  <body>