gestalt-mobile 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{index-nivA6-l4.js → index-BTJImyK1.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/server/composition.js +17 -7
- package/dist/server/server/features/autopilot/application/policy.js +2 -2
- package/dist/server/server/features/autopilot/application/service.js +87 -4
- package/dist/server/server/features/autopilot/domain/autopilot-session.js +3 -0
- package/dist/server/server/features/autopilot/domain/supervision-protocol.js +54 -3
- package/dist/server/server/platform/codex/server-request.js +11 -0
- package/dist/server/shared/contracts/autopilot-wait-lease.js +27 -4
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
3
3
|
the relay restarts.</p> <div class="dialog-actions svelte-t9laac"><button type="button" class="svelte-t9laac">Cancel</button> <button type="button" class="svelte-t9laac"> </button></div></dialog>`,1);function la(e,t){Qe(t,!0);let n=$(t,`sessionPath`,3,null),r=$(t,`sessionModel`,3,null),i=$(t,`weeklyQuotaRemaining`,3,null),a=$(t,`passkeyAuthEnabled`,3,!0),o=$(t,`componentVersions`,19,()=>[]),s=$(t,`onlock`,3,()=>{}),c=$(t,`ondevices`,3,()=>{}),l=$(t,`onnotifications`,3,()=>{}),u=$(t,`onscratchpad`,3,()=>{}),d=$(t,`onupdaterestart`,3,async()=>{}),f=I(null),p=I(null),m=I(!1);function h(){G(f)?.showModal(),queueMicrotask(()=>G(p)?.focus())}async function g(){L(m,!0);try{await d()(),G(f)?.close()}catch{}finally{L(m,!1)}}var _=ca(),v=B(_),y=V(z(v),2),b=e=>{var t=ta(),i=z(t,!0),a=V(i),o=e=>{var t=ea(),n=z(t),i=z(n);M(n),M(t),H(()=>Y(i,`· ${r()??``}`)),J(e,t)};X(a,e=>{r()&&e(o)}),M(t),H(()=>{Q(t,`title`,n()),Y(i,n())}),J(e,t)};X(y,e=>{n()&&e(b)});var x=V(y,2),S=z(x),C=e=>{var t=na(),n=z(t);M(t),H(()=>Y(n,`${i()??``}% left`)),J(e,t)};X(S,e=>{i()!==null&&e(C)});var w=V(S,2),T=e=>{var n=ra();K(`click`,n,function(...e){t.ondetach?.apply(this,e)}),J(e,n)};X(w,e=>{t.ondetach&&e(T)}),Ue(2),M(x),M(v);var E=V(v,2),D=V(z(E),2),O=V(z(D),2);Z(O,21,()=>Ui,e=>e.id,(e,t)=>{var n=ia(),r=z(n,!0);M(n);var i={};H(()=>{Y(r,G(t).label),i!==(i=G(t).id)&&(n.value=(n.__value=G(t).id)??``)}),J(e,n)}),M(O);var ee;bi(O),M(D);var k=V(D,2),te=V(k,2),ne=V(te,2),re=e=>{var t=aa(),n=B(t),r=V(n,2);K(`click`,n,e=>c()(e.currentTarget)),K(`click`,r,function(...e){s()?.apply(this,e)}),J(e,t)};X(ne,e=>{a()&&e(re)});var ie=V(ne,2),ae=e=>{var t=sa(),n=V(z(t),2);Z(n,21,o,e=>e.id,(e,t)=>{var n=oa(),r=z(n),i=z(r,!0);M(r);var a=V(r,2),o=z(a,!0);M(a),M(n),H(()=>{Y(i,G(t).label),Q(a,`title`,G(t).version??`Version unavailable`),Y(o,G(t).version??`Unavailable`)}),J(e,n)}),M(n),M(t),J(e,t)};X(ie,e=>{o().length&&e(ae)});var oe=V(ie,2),se=z(oe);M(oe),M(E);var ce=V(E,2),le=V(z(ce),4),ue=z(le);Li(ue,e=>L(p,e),()=>G(p));var de=V(ue,2),fe=z(de,!0);M(de),M(le),M(ce),Li(ce,e=>L(f,e),()=>G(f)),H(()=>{ee!==(ee=t.theme)&&(O.value=(O.__value=t.theme)??``,yi(O,t.theme)),ue.disabled=G(m),de.disabled=G(m),Y(fe,G(m)?`Starting update…`:`Update and restart`)}),K(`change`,O,e=>t.onthemechange(e.currentTarget.value)),K(`click`,k,function(...e){l()?.apply(this,e)}),K(`click`,te,function(...e){u()?.apply(this,e)}),K(`click`,se,h),Nr(`cancel`,ce,e=>G(m)&&e.preventDefault()),K(`click`,ue,()=>G(f)?.close()),K(`click`,de,()=>void g()),J(e,_),$e()}Pr([`click`,`change`]);function ua(e){return e.reduce((e,t)=>{let n=da(t);return n?.kind===`Command`?(n.status===`completed`&&(e.successful+=1),n.status===`failed`&&(e.failed+=1),e):e},{successful:0,failed:0})}function da(e){if(fa(e))return null;let[t,n]=e.label.split(` · `,2);return{kind:t,...n?{status:n}:{},content:pa(t,e.detail)}}function fa(e){return e.label.startsWith(`Tool`)&&(e.detail.includes(`context_mode`)||/(^|[_:])ctx_[a-z]/i.test(e.detail))}function pa(e,t){return e===`Command`?ma(t):e===`File change`||e===`fileChange`?t.split(`
|
|
4
4
|
`).filter(Boolean).join(`, `):t}function ma(e){let t=e.match(/^\/bin\/bash -lc "([\s\S]*)"$/);return t?t[1].replace(/\\"/g,`"`).replace(/\\\\/g,`\\`):e}var ha=q(`<dl class="command-counts svelte-thyolt"><div data-command-outcome="successful" class="svelte-thyolt"><dt class="svelte-thyolt">Successful commands</dt> <dd class="svelte-thyolt"> </dd></div> <div data-command-outcome="failed" class="svelte-thyolt"><dt class="svelte-thyolt">Failed commands</dt> <dd class="svelte-thyolt"> </dd></div></dl>`),ga=q(`<li class="activity-row svelte-thyolt"><small class="activity-type svelte-thyolt"> </small> <span class="activity-content svelte-thyolt"> </span></li>`),_a=q(`<ul class="activity-list svelte-thyolt"></ul>`),va=q(`<details class="chat-activity svelte-thyolt"><summary class="svelte-thyolt">activity</summary> <!> <!></details>`),ya=q(`<section class="live-activity svelte-thyolt" aria-label="Current activity"><strong class="svelte-thyolt">activity</strong> <!> <!></section>`);function ba(e,t){Qe(t,!0);let n=e=>{var t=ha(),n=z(t),r=V(z(n),2),i=z(r,!0);M(r),M(n);var a=V(n,2),o=V(z(a),2),c=z(o,!0);M(o),M(a),M(t),H(()=>{Y(i,G(s).successful),Y(c,G(s).failed)}),J(e,t)},r=e=>{var t=Hr(),n=B(t),r=e=>{var t=_a();Z(t,21,()=>G(c),e=>e.id,(e,t)=>{var n=ga(),r=z(n),i=z(r);M(r);var a=V(r,2),o=z(a,!0);M(a),M(n),H(e=>{Q(n,`data-activity-kind`,e),Q(n,`data-activity-status`,G(t).status),Y(i,`${G(t).kind??``}${G(t).status?` · ${G(t).status}`:``}`),Y(o,G(t).content)},[()=>G(t).kind.toLowerCase().replaceAll(` `,`-`)]),J(e,n)}),M(t),J(e,t)};X(n,e=>{G(c).length&&e(r)}),J(e,t)},i=$(t,`variant`,3,`summary`),a=P(()=>t.activities.flatMap(e=>{let t=da(e);return t&&t.kind.toLowerCase().replaceAll(` `,``)!==`filechange`?[{id:e.id,...t}]:[]})),o=P(()=>G(a).some(e=>e.kind===`Command`)),s=P(()=>ua(t.activities)),c=P(()=>G(a).filter(e=>e.kind!==`Command`));var l=Hr(),u=B(l),d=e=>{var t=Hr(),a=B(t),s=e=>{var t=va(),i=V(z(t),2),a=e=>{n(e)};X(i,e=>{G(o)&&e(a)});var s=V(i,2);r(s),M(t),J(e,t)},c=e=>{var t=ya(),i=V(z(t),2),a=e=>{n(e)};X(i,e=>{G(o)&&e(a)});var s=V(i,2);r(s),M(t),J(e,t)};X(a,e=>{i()===`summary`?e(s):e(c,-1)}),J(e,t)};X(u,e=>{(G(o)||G(c).length)&&e(d)}),J(e,l),$e()}var xa=q(`<summary><!></summary>`),Sa=q(`<button><!></button>`);function Ca(e,t){let n=$(t,`element`,3,`button`),r=$(t,`type`,3,`button`),i=$(t,`disabled`,3,!1),a=$(t,`compact`,3,!1),o=$(t,`full`,3,!1),s=$(t,`primary`,3,!1),c=$(t,`accentPressed`,3,!1);var l=Hr(),u=B(l),d=e=>{var n=xa();ai(z(n),()=>t.children),M(n),H(()=>{Q(n,`id`,t.id),gi(n,1,ui([`app-control`,t.class,{compact:a(),full:o(),primary:s(),accentPressed:c()}]),`svelte-6ey372`),Q(n,`data-state`,t.state)}),J(e,n)},f=e=>{var n=Sa();ai(z(n),()=>t.children),M(n),H(()=>{Q(n,`id`,t.id),Q(n,`type`,r()),n.disabled=i(),gi(n,1,ui([`app-control`,t.class,{compact:a(),full:o(),primary:s(),accentPressed:c()}]),`svelte-6ey372`),Q(n,`aria-label`,t.label),Q(n,`aria-current`,t.current),Q(n,`aria-pressed`,t.pressed),Q(n,`aria-describedby`,t.describedby),Q(n,`aria-disabled`,t.ariaDisabled)}),K(`click`,n,function(...e){t.onclick?.apply(this,e)}),J(e,n)};X(u,e=>{n()===`summary`?e(d):e(f,-1)}),J(e,l)}Pr([`click`]);var wa=e=>({working:`working`,idle:`idle`,awaitingAgent:`waiting for child`,awaitingHuman:`needs you`,blocked:`blocked`,disconnected:`disconnected`})[e];function Ta(e,t){if(!t)return{polite:``,critical:``};let n=!e||e.root.state!==t.root.state||e.aggregateSubagents!==t.aggregateSubagents,r=t.root.state===`blocked`||t.root.state===`awaitingHuman`;return{polite:n?`l0 ${wa(t.root.state)}; subagents ${wa(t.aggregateSubagents)}.`:``,critical:r&&(!e||e.root.state!==t.root.state)?`l0 ${wa(t.root.state)}.`:``}}function Ea(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`recently`;let r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`<1m`;let i=Math.floor(r/60);if(i<60)return`${i}m`;let a=Math.floor(i/60);if(a<24)return`${a}h`;let o=Math.floor(a/24);if(o<7)return`${o}d`;let s=Math.floor(o/7);if(s<5)return`${s}w`;let c=Math.floor(o/30);return c<12?`${c}mo`:`${Math.floor(o/365)}y`}var Da=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j"> </strong> <span class="agent-metadata svelte-d9jh4j"> </span> <time class="svelte-d9jh4j"> </time></li>`),Oa=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j">l0</strong> <span class="agent-metadata svelte-d9jh4j"> </span> <span class="unavailable svelte-d9jh4j" role="status">activity unavailable</span></li>`),ka=q(`<details class="agents svelte-d9jh4j"><!> <ul class="svelte-d9jh4j"><!></ul></details>`),Aa=q(`<li class="svelte-d9jh4j"><strong class="svelte-d9jh4j"> </strong> <small class="svelte-d9jh4j"> </small></li>`),ja=q(`<div class="chips svelte-d9jh4j"><span class="chip svelte-d9jh4j"><span aria-hidden="true" class="svelte-d9jh4j">●</span> </span> <details class="children svelte-d9jh4j"><summary class="chip svelte-d9jh4j"><span aria-hidden="true" class="svelte-d9jh4j">◆</span> </summary> <ul class="svelte-d9jh4j"></ul></details> <span class="freshness svelte-d9jh4j"> </span></div>`),Ma=q(`<p class="visually-hidden svelte-d9jh4j" role="alert"> </p>`),Na=q(`<p class="visually-hidden svelte-d9jh4j" aria-live="polite" aria-atomic="true"> </p> <!>`,1),Pa=q(`<section aria-label="Agent activity"><!> <!></section>`);function Fa(e,t){Qe(t,!0);let n=$(t,`compact`,3,!1),r=$(t,`popupAlign`,3,`end`),i=$(t,`onopen`,3,()=>{}),a={working:`working`,idle:`idle`,awaitingAgent:`waiting for child`,awaitingHuman:`needs you`,blocked:`blocked`,disconnected:`disconnected`},o={working:0,awaitingAgent:1,awaitingHuman:1,blocked:1,idle:2,disconnected:3},s=I(``),c=I(``),l=null,u=I(R(Date.now())),d=P(()=>t.activity?`${t.activity.sessionId}:${t.activity.root.state}:${t.activity.aggregateSubagents}`:``),f=P(()=>t.activity?[`blocked`,`awaitingHuman`,`disconnected`].includes(t.activity.root.state)?t.activity.root.state:t.activity.aggregateSubagents:`unavailable`);function p(e){let n=/^L([1-9]\d*)$/.exec(e??``);return n?t.plan?.steps[Number(n[1])-1]?.title:void 0}function m(e){let t=p(e.canonicalPosition),n=e.canonicalTaskName??e.canonicalPosition?.toLowerCase()??e.nickname??e.role??e.id;return t?`${n} — ${t}`:n}function h(){return`l0`}function g(e){return e===void 0?`(ctx: —)`:`(ctx: ${e}%)`}function _(e){let t=/^L([1-9]\d*)(?:\.([1-9]\d*))?$/.exec(e??``);return t?Number(t[1])*1e3+Number(t[2]??0):2**53-1}function v(e,t){return _(e.canonicalPosition)-_(t.canonicalPosition)||(e.continuationGeneration??1)-(t.continuationGeneration??1)||o[e.state]-o[t.state]||m(e).localeCompare(m(t))}let y=P(()=>t.activity?[{key:`root`,name:h(),planOrder:-1,generation:0,contextUsedPercent:t.activity.root.contextUsedPercent,role:`supervisor`,...t.rootModel?{model:t.rootModel}:{},state:t.activity.root.state,lastActivityAt:t.activity.root.lastActivityAt},...t.activity.subagents.map(e=>({key:`child:${e.id}`,name:m(e),planOrder:_(e.canonicalPosition),generation:e.continuationGeneration??1,contextUsedPercent:e.contextUsedPercent,...e.role?{role:e.role}:{},...e.model?{model:e.model}:{},state:e.state,lastActivityAt:e.lastActivityAt}))].sort((e,t)=>e.planOrder-t.planOrder||e.generation-t.generation||o[e.state]-o[t.state]||e.name.localeCompare(t.name)):[]),b=P(()=>t.activity?[...t.activity.subagents].sort(v):[]);Ri(()=>{let e=window.setInterval(()=>L(u,Date.now(),!0),6e4);return()=>window.clearInterval(e)});function x(e,t){let n=Ea(t,G(u));return e===`idle`||e===`disconnected`?`${a[e]} since ${n}`:`${a[e]} · active ${n} ago`}Mn(()=>{if(!G(d))return;let e=Er(()=>t.activity),n=Er(()=>l);if(!e)return;let r=Ta(n?.sessionId===e.sessionId?n:null,e);r.polite&&L(s,r.polite,!0),r.critical?L(c,r.critical,!0):e.root.state!==`blocked`&&e.root.state!==`awaitingHuman`&&L(c,``),l=e});var S=Pa();let C;var w=z(S),T=e=>{var n=ka(),r=z(n);Ca(r,{element:`summary`,compact:!0,full:!0,get state(){return G(f)},children:(e,n)=>{Ue();var r=Vr();H(()=>Y(r,`Agents (${(t.activity?.subagents.length??0)+1})`)),J(e,r)},$$slots:{default:!0}});var a=V(r,2),o=z(a),s=e=>{var t=Hr();Z(B(t),17,()=>G(y),e=>e.key,(e,t)=>{var n=Da(),r=z(n),i=z(r,!0);M(r);var a=V(r,2),o=z(a,!0);M(a);var s=V(a,2),c=z(s,!0);M(s),M(n),H((e,n)=>{Y(i,G(t).name),Y(o,e),Q(s,`datetime`,G(t).lastActivityAt),Y(c,n)},[()=>[g(G(t).contextUsedPercent),G(t).role,G(t).model?`Model: ${G(t).model}`:`Model unavailable`].filter(Boolean).join(` · `),()=>x(G(t).state,G(t).lastActivityAt)]),J(e,n)}),J(e,t)},c=e=>{var n=Oa(),r=V(z(n),2),i=z(r,!0);M(r),Ue(2),M(n),H(e=>Y(i,e),[()=>[`(ctx: —)`,`supervisor`,t.rootModel?`Model: ${t.rootModel}`:`Model unavailable`].filter(Boolean).join(` · `)]),J(e,n)};X(o,e=>{t.activity?e(s):e(c,-1)}),M(a),M(n),Nr(`toggle`,n,e=>e.currentTarget.open&&i()()),J(e,n)},E=e=>{var n=ja(),r=z(n),i=V(z(r));M(r);var o=V(r,2),s=z(o),c=V(z(s));M(s);var l=V(s,2);Z(l,21,()=>G(b),e=>e.id,(e,t)=>{var n=Aa(),r=z(n),i=z(r,!0);M(r);var o=V(r),s=V(o),c=z(s,!0);M(s),M(n),H((e,n)=>{Y(i,e),Y(o,` · ${n??``}${G(t).role?` · ${G(t).role}`:``}${G(t).model?` · Model: ${G(t).model}`:``} —
|
|
5
5
|
${a[G(t).state]??``} `),Y(c,G(t).lastActivityAt)},[()=>m(G(t)),()=>g(G(t).contextUsedPercent)]),J(e,n)}),M(l),M(o);var u=V(o,2),d=z(u,!0);M(u),M(n),H(e=>{Q(r,`data-state`,t.activity.root.state),Y(i,` l0: ${a[t.activity.root.state]??``}
|
|
6
|
-
${e??``}`),Q(s,`data-state`,t.activity.aggregateSubagents),Y(c,` Subagents: ${a[t.activity.aggregateSubagents]??``} (${t.activity.subagents.length??``})`),Y(d,t.activity.confidence===`fresh`?`Current`:t.activity.confidence===`reconciling`?`Checking updates`:`May be stale`)},[()=>g(t.activity.root.contextUsedPercent)]),J(e,n)};X(w,e=>{n()?e(T):t.activity&&e(E,1)});var D=V(w,2),O=e=>{var t=Na(),n=B(t),r=z(n,!0);M(n);var i=V(n,2),a=e=>{var t=Ma(),n=z(t,!0);M(t),H(()=>Y(n,G(c))),J(e,t)};X(i,e=>{G(c)&&e(a)}),H(()=>Y(r,G(s))),J(e,t)};X(D,e=>{t.activity&&e(O)}),M(S),H(()=>C=gi(S,1,`agent-activity svelte-d9jh4j`,null,C,{compact:n(),"align-start":r()===`start`})),J(e,S),$e()}Xe();var Ia=q(`<main class="svelte-iw6wrs"><h1 class="svelte-iw6wrs">Activity evidence</h1> <!><!></main>`);function La(e){let t={sessionId:`evidence`,confidence:`reconciling`,aggregateSubagents:`working`,root:{state:`awaitingAgent`,observedAt:`2026-01-01T00:00:00.000Z`,lastActivityAt:`2026-01-01T00:00:00.000Z`},subagents:[{id:`α-worker`,nickname:`α worker`,role:`research`,state:`working`,observedAt:`2026-01-01T00:00:00.000Z`,lastActivityAt:`2026-01-01T00:00:00.000Z`}]},n=[`working`,`awaitingAgent`,`awaitingHuman`,`blocked`,`idle`,`disconnected`];var r=Ia(),i=V(z(r),2);Fa(i,{get activity(){return t}}),Z(V(i),1,()=>n,e=>e,(e,n)=>{{let r=Tt(()=>({...t,sessionId:G(n),confidence:G(n)===`blocked`?`stale`:`fresh`,root:{...t.root,state:G(n)},aggregateSubagents:G(n)}));Fa(e,{get activity(){return G(r)}})}}),M(r),J(e,r)}function Ra(e,t){if(!e||typeof e!=`object`)return!1;let n=e,r=new Set([`working`,`idle`,`awaitingAgent`,`awaitingHuman`,`blocked`,`disconnected`]),i=(e,t=256)=>typeof e==`string`&&e.length<=t,a=e=>Array.isArray(e)&&e.length<=64&&e.every(e=>{let t=e;return t&&typeof t==`object`&&[`running`,`detached-active`,`exited-awaiting-result`,`result-consumed`,`terminated-for-budget`].includes(t.state)&&[`executor`,`supervisor`].includes(t.ownership)&&i(t.observedAt,64)&&!Number.isNaN(Date.parse(t.observedAt))}),o=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return i(t.state,32)&&r.has(t.state)&&i(t.observedAt,64)&&i(t.lastActivityAt,64)&&!Number.isNaN(Date.parse(t.observedAt))&&!Number.isNaN(Date.parse(t.lastActivityAt))&&(t.reason===void 0||i(t.reason,64))&&(t.contextUsedPercent===void 0||Number.isInteger(t.contextUsedPercent)&&t.contextUsedPercent>=0&&t.contextUsedPercent<=100)};return i(n.sessionId)&&(!t||n.sessionId===t)&&o(n.root)&&Array.isArray(n.subagents)&&n.subagents.length<=64&&n.subagents.every(e=>o(e)&&i(e.id)&&(e.nickname===void 0||i(e.nickname))&&(e.role===void 0||i(e.role))&&(e.model===void 0||i(e.model))&&(e.canonicalTaskName===void 0||i(e.canonicalTaskName))&&(e.canonicalPosition===void 0||i(e.canonicalPosition,32))&&(e.continuationGeneration===void 0||Number.isInteger(e.continuationGeneration)&&e.continuationGeneration>0)&&(e.outcome===void 0||[`partial`,`cancelled`,`failed`].includes(e.outcome))&&(e.ownedProcesses===void 0||a(e.ownedProcesses)))&&i(n.aggregateSubagents,32)&&r.has(n.aggregateSubagents)&&(n.confidence===`fresh`||n.confidence===`stale`||n.confidence===`reconciling`)}var za=class{#e=new Map;#t=new Map;#n=new Set;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=null;#l=!1;#u;constructor(e){this.#u={...e,websocket:e.websocket??(e=>new WebSocket(e)),location:e.location??location,setTimeout:e.setTimeout??setTimeout,clearTimeout:e.clearTimeout??clearTimeout}}get(e){return e?this.#e.get(e)??null:null}bootstrap(e,t){for(let t of e)!this.#e.has(t.id)&&Ra(t.agentActivity,t.id)&&this.#p(t.id,this.#t.get(t.id)??0,t.agentActivity);this.sync(e.map(e=>e.id),t)}sync(e,t){if(!this.#l){this.#c=t,this.#n=new Set(e);for(let e of this.#n)this.#i.has(e)||this.#i.set(e,0);for(let e of[...this.#i.keys()])this.#n.has(e)||this.remove(e);for(let[e,n]of this.#r)(e===t||!this.#n.has(e))&&(n.close(),this.#r.delete(e));for(let e of this.#n)this.hydrate(e),e!==t&&!this.#r.has(e)&&this.#f(e)}}select(e){this.sync([...this.#n],e)}remove(e){this.#n.delete(e),this.#i.set(e,(this.#i.get(e)??0)+1),this.#r.get(e)?.close(),this.#r.delete(e);let t=this.#a.get(e);t&&this.#u.clearTimeout(t),this.#a.delete(e),this.#o.delete(e),this.#s.delete(e),this.#e.delete(e),this.#t.delete(e),this.#u.publish(this.#e)}observe(e,t){if(this.#l||!this.#n.has(e)||!Number.isInteger(t.sequence))return;let n=this.#t.get(e)??0;t.sequence<=n||(t.sequence>n+1&&(this.#t.set(e,t.sequence-1),this.resync(e)),this.#t.set(e,t.sequence),this.#u.onEvent?.(e,t),t.type===`agent.activity.updated`&&Ra(t.payload,e)&&this.#p(e,t.sequence,t.payload))}async hydrate(e){let t=this.#i.get(e)??0,n=this.#t.get(e)??0;try{let r=await this.#u.relay.getSession(e);if(!this.#d(e,t))return;let i=this.#t.get(e)??0,a=r.currentSequence;if(Number.isInteger(a)){if(a<i)return;this.#t.set(e,a),Ra(r.agentActivity,e)&&this.#p(e,a,r.agentActivity),this.#u.onAuthoritativeSnapshot?.(e,r)}else i===n&&Ra(r.agentActivity,e)&&(this.#p(e,i,r.agentActivity),this.#u.onAuthoritativeSnapshot?.(e,r))}catch{this.#m(e)}}async resync(e){let t=this.#o.get(e);if(t)return t;let n=this.#i.get(e)??0;this.#m(e);let r;return r=(async()=>{try{await this.#u.relay.refreshActivity(e),this.#d(e,n)&&await this.hydrate(e)}catch{}finally{this.#o.get(e)===r&&this.#o.delete(e)}})(),this.#o.set(e,r),r}dispose(){this.#l=!0;for(let e of[...this.#n])this.remove(e)}#d(e,t){return!this.#l&&this.#n.has(e)&&this.#i.get(e)===t}#f(e){let t=this.#i.get(e)??0,n=this.#u.location.protocol===`https:`?`wss:`:`ws:`,r=this.#u.websocket(`${n}//${this.#u.location.host}/api/sessions/${encodeURIComponent(e)}/events?after=${this.#t.get(e)??0}`);this.#r.set(e,r),r.onmessage=n=>{if(!(!this.#d(e,t)||this.#r.get(e)!==r))try{this.#s.delete(e);let t=JSON.parse(String(n.data));t.type===`relay.resyncRequired`?this.resync(e):t.type===`relay.event`&&t.event&&this.observe(e,t.event)}catch{}},r.onclose=()=>{if(!this.#d(e,t)||this.#c===e)return;this.#r.delete(e),this.#m(e);let n=this.#s.get(e)??0,r=(this.#u.reconnectDelaysMs??[250,1e3,5e3])[n];r!==void 0&&(this.#s.set(e,n+1),this.#a.set(e,this.#u.setTimeout(()=>{this.#a.delete(e),this.#d(e,t)&&e!==this.#c&&this.#f(e)},r)))}}#p(e,t,n){let r=this.#e.get(e);this.#t.set(e,Math.max(t,this.#t.get(e)??0)),JSON.stringify(r)!==JSON.stringify(n)&&(this.#e.set(e,n),this.#u.publish(this.#e))}#m(e){let t=this.#e.get(e);t&&t.confidence===`fresh`&&(this.#e.set(e,{...t,confidence:`stale`}),this.#u.publish(this.#e))}};function Ba(e=globalThis.crypto,t=Date.now,n=Math.random){return typeof e?.randomUUID==`function`?e.randomUUID():`k-${t().toString(36)}-${Math.floor(n()*4294967296).toString(36)}`}var Va=(e,t=600)=>typeof e==`string`&&e.length<=t,Ha=e=>Va(e,64)&&!Number.isNaN(Date.parse(e));function Ua(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.enabled==`boolean`&&typeof t.state==`string`&&[`disabled`,`monitoring`,`backoff`,`attentionRequired`,`completed`,`safetyPaused`].includes(t.state)&&!!t.retry&&typeof t.retry==`object`&&Number.isInteger(t.retry.position)&&Number.isInteger(t.retry.limit)&&Va(t.updatedAt,64)&&(t.reason===void 0||Va(t.reason,80))&&(t.nextEvaluationAt===void 0||Va(t.nextEvaluationAt,64))&&(t.health===void 0||Wa(t.health))}function Wa(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!t.wait||typeof t.wait!=`object`)return!1;let n=t.wait;return typeof t.healthy==`boolean`&&typeof t.phase==`string`&&[`off`,`rootWorking`,`continuationScheduled`,`waitingForAgentEvent`,`checkingState`,`needsYou`,`safetyPaused`,`complete`,`degraded`].includes(t.phase)&&[`active`,`probeRequired`,`parked`,`retrying`,`attentionRequired`,`safetyPaused`,`none`].includes(t.supervision)&&typeof n.present==`boolean`&&Array.isArray(n.wakeCategories)&&n.wakeCategories.length<=9&&new Set(n.wakeCategories).size===n.wakeCategories.length&&n.wakeCategories.every(e=>[`planChanged`,`reviewChanged`,`checkpointChanged`,`interactionChanged`,`executorChanged`,`processExited`,`processResultAvailable`,`processLimitBreached`,`agentActivityChanged`].includes(e))&&Ha(t.observedAt)&&Ha(t.lastTransitionAt)&&Va(t.nextExpectedAction)&&(t.degradationReason===void 0||[`missingContinuation`,`invalidWaitLease`,`controllerUnavailable`,`staleTransition`,`planMismatch`].includes(t.degradationReason))}function Ga(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.attention;if(!n||typeof n!=`object`)return!1;let r=n;return Va(t.requestId,256)&&(t.turnId===null||Va(t.turnId,256))&&(t.requestedAt===null||Va(t.requestedAt,64))&&Va(r.reason,64)&&Va(r.summary)&&Va(r.requestedAction)&&Va(r.resumeCondition,64)}function Ka(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`orgPlanAttention`&&Ga({requestId:t.requestId,turnId:t.turnId??null,requestedAt:t.requestedAt??null,attention:t.payload})}function qa(e){return{requestId:e.requestId,turnId:e.turnId,requestedAt:e.requestedAt,attention:e.payload}}var Ja=e=>{let t=e&&typeof e==`object`?e.code:void 0;return t===`AUTOPILOT_PLAN_REQUIRED`?`An incomplete supervised plan is required before Autopilot can start.`:t===`AUTOPILOT_PLAN_COMPLETE`?`This plan is complete, so Autopilot is unavailable.`:t===`AUTOPILOT_SESSION_UNAVAILABLE`?`This session is unavailable for Autopilot.`:e instanceof Error?e.message:`Could not update Autopilot.`},Ya=class{relay;publish;createKey;#e=new Map;#t=new Map;#n=new Set;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=new Map;#d=new Set;#f=!1;constructor(e,t,n=Ba){this.relay=e,this.publish=t,this.createKey=n}bootstrap(e){if(this.#f)return;let t=new Set(e.map(e=>e.id));for(let e of this.#d)t.has(e)||this.remove(e);this.#d=t;for(let t of e){this.#i.has(t.id)||this.#i.set(t.id,0),this.#a.has(t.id)||this.#a.set(t.id,0);let e=this.#u.get(t.id)??0,n=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null,r=this.#c.get(t.id);!this.#n.has(t.id)&&(r===void 0||n!==null&&n>r)&&(n!==null&&n>e||!this.#e.has(t.id)&&e===0)&&(n!==null&&(this.#u.set(t.id,n),r!==void 0&&n>r&&this.#c.delete(t.id)),this.#g(t.id,t))}this.#_()}observe(e,t){if(this.#f||!this.#d.has(e)||!Number.isInteger(t.sequence))return;let n=this.#u.get(e)??0;t.sequence<=n||(this.#u.set(e,t.sequence),this.#a.set(e,(this.#a.get(e)??0)+1),t.type===`autopilot.updated`&&this.#m(e,t.payload),t.type===`org-plan.attention-required`&&this.#h(e,t.payload),t.type===`org-plan.attention-resolved`&&(t.payload&&typeof t.payload==`object`&&t.payload.outcome,this.#t.delete(e)),this.#_())}async hydrate(e,t){let n=this.#i.get(e)??0,r=(this.#l.get(e)??0)+1;this.#l.set(e,r);let i=t??this.#u.get(e)??0,a=this.#o.get(e),o=this.#s.get(e)??0;try{let t=await this.relay.getSession(e);if(!this.#p(e,n)||this.#l.get(e)!==r||(this.#s.get(e)??0)!==o||this.#o.has(e)&&this.#o.get(e)!==a)return;let s=this.#u.get(e)??0,c=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null;c!==null&&c>s?(this.#u.set(e,c),this.#g(e,t)):c===null&&s===i&&this.#g(e,t),this.#_()}catch{}}async toggle(e,t){if(this.#f||!this.#d.has(e)||this.#n.has(e))return;let n=this.#i.get(e)??0,r=this.#a.get(e)??0;this.#o.set(e,(this.#o.get(e)??0)+1),this.#s.set(e,(this.#s.get(e)??0)+1),this.#n.add(e),this.#r.delete(e),this.#_();try{let i=await this.relay.setAutopilot(e,t,this.createKey());this.#p(e,n)&&this.#a.get(e)===r&&(this.#m(e,i.autopilot),this.#a.set(e,r+1),this.#c.set(e,this.#u.get(e)??0),Ua(i.autopilot)&&!i.autopilot.enabled&&this.#t.delete(e))}catch(t){this.#p(e,n)&&this.#a.get(e)===r&&this.#r.set(e,Ja(t))}finally{this.#p(e,n)&&(this.#n.delete(e),this.#s.set(e,(this.#s.get(e)??0)+1)),this.#_()}}async resolve(e,t,n){let r=this.#t.get(e);if(!r||this.#n.has(e)||this.#f)return;let i=n?.trim();if(i&&i.length>600){this.#r.set(e,`Guidance must be 600 characters or fewer.`),this.#_();return}let a=this.#i.get(e)??0,o=this.#a.get(e)??0;this.#s.set(e,(this.#s.get(e)??0)+1),this.#n.add(e),this.#r.delete(e),this.#_();try{await this.relay.resolveAttention(e,r.requestId,{operationKey:this.createKey(),action:t,...i?{guidance:i}:{}}),this.#p(e,a)&&this.#a.get(e)===o&&await this.hydrate(e)}catch(t){this.#p(e,a)&&this.#a.get(e)===o&&this.#r.set(e,t instanceof Error?t.message:`Could not resolve attention.`)}finally{this.#p(e,a)&&(this.#n.delete(e),this.#s.set(e,(this.#s.get(e)??0)+1)),this.#_()}}remove(e){this.#i.set(e,(this.#i.get(e)??0)+1),this.#d.delete(e),this.#e.delete(e),this.#t.delete(e),this.#n.delete(e),this.#r.delete(e),this.#u.delete(e),this.#a.delete(e),this.#o.delete(e),this.#s.delete(e),this.#c.delete(e),this.#l.delete(e),this.#_()}dispose(){this.#f=!0,this.#d.clear(),this.#e.clear(),this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#l.clear(),this.#a.clear(),this.#o.clear(),this.#s.clear(),this.#c.clear(),this.#_()}#p(e,t){return!this.#f&&this.#d.has(e)&&this.#i.get(e)===t}#m(e,t){Ua(t)&&this.#e.set(e,t)}#h(e,t){if(Ga(t))this.#t.set(e,t);else if(Ka(t))this.#t.set(e,qa(t));else if(Array.isArray(t)){let n=t.find(Ka);n?this.#t.set(e,qa(n)):this.#t.delete(e)}}applyAuthoritative(e,t){if(this.#f||!this.#d.has(e)||this.#n.has(e))return;let n=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null,r=this.#u.get(e)??0,i=this.#c.get(e);i!==void 0&&(n===null||n<=i)||n!==null&&n<r||(n!==null&&(this.#u.set(e,n),i!==void 0&&n>i&&this.#c.delete(e)),this.#g(e,t),this.#_())}#g(e,t){this.#a.set(e,(this.#a.get(e)??0)+1),this.#m(e,t.autopilot),this.#h(e,t.pendingInteractions)}#_(){this.publish({snapshots:new Map(this.#e),attention:new Map(this.#t),pending:new Set(this.#n),errors:new Map(this.#r)})}},Xa=q(`<span aria-hidden="true" class="svelte-1qf1ppf"> </span> `,1),Za=q(`<div class="control-row svelte-1qf1ppf"><span class="status svelte-1qf1ppf"><span aria-hidden="true" class="svelte-1qf1ppf"> </span> </span> <!></div>`),Qa=q(`<section aria-label="Autopilot"><p class="visually-hidden svelte-1qf1ppf" data-testid="autopilot-live-status" aria-live="polite" aria-atomic="true"> </p> <!> <p> </p></section>`);function $a(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-control`),r=$(t,`compact`,3,!1),i=$(t,`indicatorOnly`,3,!1),a=$(t,`pending`,3,!1),o=$(t,`ontoggle`,3,()=>{}),s={disabled:`Off`,monitoring:`Monitoring`,backoff:`Waiting to continue`,attentionRequired:`Paused for attention`,completed:`Complete`,safetyPaused:`Safety paused`},c={off:`Off`,rootWorking:`On · root working`,continuationScheduled:`On · continuation scheduled`,waitingForAgentEvent:`On · waiting for agent event`,checkingState:`On · checking state`,needsYou:`Paused · needs you`,safetyPaused:`Safety paused`,complete:`Complete`,degraded:`On · continuation unavailable`},l={planRequired:`An incomplete supervised plan is required before Autopilot can start.`,planComplete:`This plan is complete, so Autopilot is unavailable.`,sessionUnavailable:`This session is unavailable for Autopilot.`,attentionRequired:`Autopilot is paused because an agent is waiting for human input.`,noPlanProgress:`Autopilot paused because the plan did not make durable progress.`,reconcileFailed:`Autopilot paused because it could not safely confirm session state.`,startUnavailable:`Automatic continuation could not start because the session runtime is unavailable. Restore or reopen the session, then retry Autopilot.`,actionRateExceeded:`Autopilot paused after too many automatic actions in ten minutes. Wait for the safety window to clear, or continue manually.`,planRemoved:`The retained plan was removed.`,planReplaced:`The retained plan changed. Enable Autopilot again after reviewing it.`,sessionEnded:`This session ended.`,manualDisabled:`Autopilot is off.`,safetyPaused:`Autopilot paused after a repeated or invalid automatic continuation. Resume manually when ready.`},u=P(()=>t.autopilot?t.autopilot.health?c[t.autopilot.health.phase]:s[t.autopilot.state]:`Unavailable`),d=P(()=>t.autopilot?.state===`backoff`&&t.autopilot.retry.position>0&&t.autopilot.retry.limit>0?`Retry ${t.autopilot.retry.position} of ${t.autopilot.retry.limit}.`:null),f=P(()=>(t.autopilot?.reason?l[t.autopilot.reason]:null)??G(d)??t.autopilot?.health?.nextExpectedAction??(t.autopilot?.state===`monitoring`?`Autopilot is monitoring this supervised plan.`:t.autopilot?.state===`attentionRequired`?`Autopilot is paused because human attention is required.`:`Autopilot state is loading from the relay.`)),p=P(()=>`Autopilot status: ${G(u)}. ${G(f)}`),m=P(()=>t.autopilot?.enabled??!1);var h=Qa();let g;var _=z(h),v=z(_,!0);M(_);var y=V(_,2),b=e=>{{let t=P(()=>`${n()}-button`),r=P(()=>i()?`Autopilot: ${a()?`Updating`:G(u)}`:void 0),s=P(()=>`${n()}-help`);Ca(e,{get id(){return G(t)},compact:!0,full:!0,get pressed(){return G(m)},get accentPressed(){return i()},get label(){return G(r)},get describedby(){return G(s)},get ariaDisabled(){return a()},onclick:()=>{a()||o()(!G(m))},children:(e,t)=>{var n=Hr(),r=B(n),o=e=>{J(e,Vr(`Autopilot`))},s=e=>{var t=Xa(),n=B(t),r=z(n,!0);M(n);var i=V(n);H(()=>{Y(r,G(m)?`●`:`○`),Y(i,` Autopilot: ${(a()?`Updating…`:G(u))??``}`)}),J(e,t)};X(r,e=>{i()?e(o):e(s,-1)}),J(e,n)},$$slots:{default:!0}})}},x=e=>{var r=Za(),i=z(r),s=z(i),c=z(s,!0);M(s);var l=V(s);M(i);var d=V(i,2);{let e=P(()=>`${n()}-button`),t=P(()=>`${n()}-help`);Ca(d,{get id(){return G(e)},get pressed(){return G(m)},get describedby(){return G(t)},get ariaDisabled(){return a()},onclick:()=>{a()||o()(!G(m))},children:(e,t)=>{Ue();var n=Vr();H(()=>Y(n,a()?`Updating…`:G(m)?`Pause`:`Enable`)),J(e,n)},$$slots:{default:!0}})}M(r),H(()=>{Q(i,`data-state`,t.autopilot?.state??`unavailable`),Y(c,G(m)?`●`:`○`),Y(l,` Autopilot: ${G(u)??``}`)}),J(e,r)};X(y,e=>{r()?e(b):e(x,-1)});var S=V(y,2);let C;var w=z(S,!0);M(S),M(h),H(()=>{g=gi(h,1,`autopilot-control svelte-1qf1ppf`,null,g,{compact:r()}),Y(v,G(p)),Q(S,`id`,`${n()}-help`),C=gi(S,1,`svelte-1qf1ppf`,null,C,{"visually-hidden":r()}),Y(w,G(f))}),J(e,h),$e()}var eo=q(`<section class="attention svelte-1hnxk0w" role="alert"><h3 class="svelte-1hnxk0w">Autopilot needs your attention</h3> <dl class="svelte-1hnxk0w"><div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Reason</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">What happened</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Requested action</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Resume when</dt> <dd class="svelte-1hnxk0w"> </dd></div></dl> <label>Optional guidance for the resumed work</label> <textarea maxlength="600" class="svelte-1hnxk0w"></textarea> <p class="guidance-help svelte-1hnxk0w"> </p> <div class="actions svelte-1hnxk0w"><button type="button" class="svelte-1hnxk0w"> </button> <button type="button" class="svelte-1hnxk0w">Disable Autopilot</button></div></section>`);function to(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-attention`),r=$(t,`pending`,3,!1),i=$(t,`onresolve`,3,()=>{}),a=I(``),o=P(()=>G(a).trim().length>600?`Guidance must be 600 characters or fewer.`:``);var s=Hr(),c=B(s),l=e=>{var s=eo(),c=z(s),l=V(c,2),u=z(l),d=V(z(u),2),f=z(d,!0);M(d),M(u);var p=V(u,2),m=V(z(p),2),h=z(m,!0);M(m),M(p);var g=V(p,2),_=V(z(g),2),v=z(_,!0);M(_),M(g);var y=V(g,2),b=V(z(y),2),x=z(b,!0);M(b),M(y),M(l);var S=V(l,2),C=V(S,2);Sn(C);var w=V(C,2),T=z(w,!0);M(w);var E=V(w,2),D=z(E),O=z(D,!0);M(D);var ee=V(D,2);M(E),M(s),H((e,i)=>{Q(s,`aria-labelledby`,`${n()}-title`),Q(c,`id`,`${n()}-title`),Y(f,t.attention.attention.reason),Y(h,t.attention.attention.summary),Y(v,t.attention.attention.requestedAction),Y(x,t.attention.attention.resumeCondition),Q(S,`for`,`${n()}-guidance`),Q(C,`id`,`${n()}-guidance`),Q(C,`aria-describedby`,`${n()}-guidance-help`),Q(C,`aria-invalid`,e),Q(w,`id`,`${n()}-guidance-help`),Y(T,G(o)||`Up to 600 characters. Do not include secrets.`),D.disabled=i,Y(O,r()?`Updating…`:`Resume`),ee.disabled=r()},[()=>!!G(o),()=>r()||!!G(o)]),Ni(C,()=>G(a),e=>L(a,e)),K(`click`,D,()=>G(a).trim()?i()(`resume`,G(a)):i()(`resume`)),K(`click`,ee,()=>i()(`disableAutopilot`)),J(e,s)};X(c,e=>{t.attention&&e(l)}),J(e,s),$e()}Pr([`click`]);var no=q(`<section class="safety-stop svelte-yp6bgs" role="alert"><h3 class="svelte-yp6bgs">Autopilot safety stop</h3> <p class="svelte-yp6bgs"> </p> <p class="svelte-yp6bgs"> </p> <div class="actions svelte-yp6bgs"><button type="button" class="svelte-yp6bgs"> </button> <button type="button" class="svelte-yp6bgs">Disable Autopilot</button></div></section>`);function ro(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-safety-stop`),r=$(t,`pending`,3,!1),i=$(t,`onrecover`,3,()=>{}),a=$(t,`ondisable`,3,()=>{}),o={attentionRequired:`The coordinator stopped because it needs a human safety decision, but no actionable agent request is available.`,noPlanProgress:`The coordinator stopped because recent automatic turns made no durable plan progress.`,reconcileFailed:`The coordinator stopped because it could not safely confirm the session state.`,startUnavailable:`The coordinator stopped because the session runtime was unavailable when it tried to start an automatic turn.`,actionRateExceeded:`The coordinator stopped because it reached the automatic-action safety limit.`},s=P(()=>t.autopilot?.reason&&!t.attention?o[t.autopilot.reason]??null:null),c=P(()=>t.autopilot?.reason===`startUnavailable`?`There is no pending agent attention request to answer. Restore or reopen this session, then retry Autopilot.`:t.autopilot?.reason===`actionRateExceeded`?`There is no pending agent attention request to answer. Wait for the ten-minute safety window to clear, or continue manually.`:`There is no pending agent attention request to answer. Retry the supported Autopilot coordinator after addressing the cause, or disable it.`);var l=Hr(),u=B(l),d=e=>{var t=no(),o=z(t),l=V(o,2),u=z(l,!0);M(l);var d=V(l,2),f=z(d,!0);M(d);var p=V(d,2),m=z(p),h=z(m,!0);M(m);var g=V(m,2);M(p),M(t),H(()=>{Q(t,`aria-labelledby`,`${n()}-title`),Q(o,`id`,`${n()}-title`),Y(u,G(s)),Y(f,G(c)),m.disabled=r(),Y(h,r()?`Updating…`:`Retry Autopilot`),g.disabled=r()}),K(`click`,m,function(...e){i()?.apply(this,e)}),K(`click`,g,function(...e){a()?.apply(this,e)}),J(e,t)};X(u,e=>{t.autopilot?.state===`attentionRequired`&&G(s)&&e(d)}),J(e,l),$e()}Pr([`click`]);function io(e,t=`gestalt-mobile.autopilot-attention-toasts.v1`,n=100){let r=ao(e,t,n);return{claim(i){if(r.has(i))return!1;r=new Set([...r,i].slice(-n));try{e?.setItem(t,JSON.stringify([...r]))}catch{}return!0}}}function ao(e,t,n){try{let r=JSON.parse(e?.getItem(t)??`[]`);return new Set(Array.isArray(r)?r.filter(e=>typeof e==`string`).slice(-n):[])}catch{return new Set}}var oo=[{name:`model`,description:`Choose the model for the next turn`,argumentPicker:`models`},{name:`reasoning`,description:`Choose reasoning effort for the next turn`,argumentPicker:`reasoning`}];function so(e){let t=e.match(/^\/([^\s]*)$/);return t?t[1].toLowerCase():null}function co(e){let t=so(e);return t===null?[]:oo.filter(e=>e.name.startsWith(t))}function lo(e){let t=e.match(/^\/([^\s]+)\s*$/)?.[1]?.toLowerCase();return oo.find(e=>e.name===t)?.argumentPicker}function uo(e){return[...e].sort((e,t)=>fo(t,e)||t.localeCompare(e))}function fo(e,t){let n=e.match(/\d+(?:\.\d+)*/)?.[0].split(`.`).map(Number)??[],r=t.match(/\d+(?:\.\d+)*/)?.[0].split(`.`).map(Number)??[];for(let e=0;e<Math.max(n.length,r.length);e+=1){let t=(n[e]??0)-(r[e]??0);if(t)return t}return 0}var po=q(`Ready <span class="block-cursor svelte-1264sfg" aria-hidden="true"></span>`,1),mo=q(`<p id="writer-hint" class="writer-hint svelte-1264sfg">You can read this conversation. Sending will connect to Codex.</p>`),ho=q(`<button type="button" class="svelte-1264sfg">Retry send</button>`),go=q(`<div class="writer-feedback svelte-1264sfg" role="alert" aria-atomic="true"><p class="svelte-1264sfg"> </p> <!></div>`),_o=q(`<li><button type="button" class="svelte-1264sfg"><code class="svelte-1264sfg"> </code> <small class="svelte-1264sfg"> </small></button></li>`),vo=q(`<ul id="chat-command-completion" class="command-menu svelte-1264sfg" aria-label="Chat commands"></ul>`),yo=q(`<li class="svelte-1264sfg"><button type="button" class="svelte-1264sfg"><code class="svelte-1264sfg"> </code></button></li>`),bo=q(`<ul class="command-menu svelte-1264sfg" aria-label="Available models"></ul>`),xo=q(`<ul class="command-menu svelte-1264sfg" aria-label="Reasoning efforts"></ul>`),So=q(`<div id="prompt-action-panel" class="action-panel svelte-1264sfg" aria-label="Prompt actions"><button type="button" class="svelte-1264sfg">Queue message</button> <button type="button" class="svelte-1264sfg">Interrupt and send</button></div>`),Co=q(`<div class="prompt-action svelte-1264sfg"><button type="button" aria-label="Choose prompt action" aria-controls="prompt-action-panel" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><circle cx="6" cy="12" r="1.5" class="svelte-1264sfg"></circle><circle cx="12" cy="12" r="1.5" class="svelte-1264sfg"></circle><circle cx="18" cy="12" r="1.5" class="svelte-1264sfg"></circle></svg></button> <!></div>`),wo=q(`<button type="button" aria-label="Interrupt" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><path d="m7 7 10 10M17 7 7 17" class="svelte-1264sfg"></path></svg></button>`),To=q(`<button type="button" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><path d="M9 10 5 14l4 4M5 14h8a6 6 0 0 0 6-6V6" class="svelte-1264sfg"></path></svg></button>`),Eo=q(`<form class="svelte-1264sfg"><p role="status" aria-live="polite" aria-atomic="true" class="svelte-1264sfg"><!></p> <!> <!> <!> <!> <!> <div class="prompt-row svelte-1264sfg"><textarea id="message" aria-label="Prompt" placeholder="Prompt" rows="1" required="" class="svelte-1264sfg"></textarea> <!></div></form>`);function Do(e,t){Qe(t,!0);let n=$(t,`detached`,3,!1),r=$(t,`retryMessage`,3,null),i=$(t,`retryable`,3,!1),a=$(t,`models`,19,()=>[]),o=$(t,`onscrollbottom`,3,()=>{}),s=$(t,`onmodelselect`,3,()=>{}),c=$(t,`onqueue`,3,()=>{}),l=$(t,`oninterruptsend`,3,()=>{}),u=$(t,`onretry`,3,()=>{}),d=I(0),f=I(null),p=I(!1),m=P(()=>co(t.message)),h=P(()=>so(t.message)),g=P(()=>G(h)!==null&&G(h)!==G(f)&&G(m).length>0),_=P(()=>lo(t.message)),v=P(()=>G(_)===`models`),y=P(()=>uo(a())),b=P(()=>G(_)===`reasoning`),x=P(()=>!t.activeTurnId&&!t.starting&&!!t.message.trim()),S=P(()=>!!t.message.trim()),C=P(()=>i()&&!r());function w(e){L(p,!1),e===`queue`?c()():l()()}function T(e,n=!1){L(f,null),L(d,0),t.onchange(e),n&&o()()}function E(e=G(d)){let t=G(m)[e];t&&T(`/${t.name} `,!0)}function D(e){if(e.key===`Enter`&&e.ctrlKey&&!e.isComposing){if(t.activeTurnId&&!t.starting&&G(S)){e.preventDefault(),w(`queue`);return}if(G(x)){e.preventDefault(),t.onsend();return}}if(G(g)){if(e.key===`ArrowDown`){e.preventDefault(),L(d,(G(d)+1)%G(m).length);return}if(e.key===`ArrowUp`){e.preventDefault(),L(d,(G(d)-1+G(m).length)%G(m).length);return}if(e.key===`Escape`){e.preventDefault(),L(f,G(h),!0);return}if(e.key===`Tab`){e.preventDefault(),E();return}}}var O=Eo(),ee=z(O),k=z(ee),te=e=>{var t=po();Ue(),J(e,t)},ne=e=>{var n=Vr();H(()=>Y(n,t.status)),J(e,n)};X(k,e=>{t.status===`Ready.`?e(te):e(ne,-1)}),M(ee);var re=V(ee,2),ie=e=>{J(e,mo())};X(re,e=>{n()&&e(ie)});var ae=V(re,2),oe=e=>{var n=go(),a=z(n),o=z(a,!0);M(a);var s=V(a,2),c=e=>{var n=ho();H(()=>n.disabled=t.starting),K(`click`,n,function(...e){u()?.apply(this,e)}),J(e,n)};X(s,e=>{i()&&e(c)}),M(n),H(()=>Y(o,r())),J(e,n)};X(ae,e=>{r()&&e(oe)});var se=V(ae,2),ce=e=>{var t=vo();Z(t,23,()=>G(m),e=>e.name,(e,t,n)=>{var r=_o(),i=z(r),a=z(i),o=z(a);M(a);var s=V(a,2),c=z(s,!0);M(s),M(i),M(r),H(()=>{gi(r,1,ui(G(n)===G(d)?`command-selected`:void 0),`svelte-1264sfg`),Y(o,`/${G(t).name??``}`),Y(c,G(t).description)}),K(`click`,i,()=>E(G(n))),J(e,r)}),M(t),J(e,t)};X(se,e=>{G(g)&&e(ce)});var le=V(se,2),ue=e=>{var t=bo();Z(t,20,()=>G(y),e=>e,(e,t)=>{var n=yo(),r=z(n),i=z(r),a=z(i,!0);M(i),M(r),M(n),H(()=>Y(a,t)),K(`click`,r,()=>{s()(t),o()()}),J(e,n)}),M(t),J(e,t)};X(le,e=>{G(v)&&e(ue)});var de=V(le,2),fe=e=>{var t=xo();Z(t,20,()=>[`low`,`medium`,`high`],e=>e,(e,t)=>{var n=yo(),r=z(n),i=z(r),a=z(i,!0);M(i),M(r),M(n),H(()=>Y(a,t)),K(`click`,r,()=>T(`/reasoning ${t} `,!0)),J(e,n)}),M(t),J(e,t)};X(de,e=>{G(b)&&e(fe)});var pe=V(de,2),me=z(pe);Sn(me);var he=V(me,2),ge=e=>{var t=Co(),n=z(t),r=V(n,2),i=e=>{var t=So(),n=z(t),r=V(n,2);M(t),K(`click`,n,()=>w(`queue`)),K(`click`,r,()=>w(`interrupt-send`)),J(e,t)};X(r,e=>{G(p)&&e(i)}),M(t),H(()=>Q(n,`aria-expanded`,G(p))),K(`click`,n,()=>L(p,!G(p))),J(e,t)},_e=e=>{var n=wo();H(()=>n.disabled=t.starting),K(`click`,n,function(...e){t.oninterrupt?.apply(this,e)}),J(e,n)},ve=e=>{var n=To();H(()=>{Q(n,`aria-label`,G(C)?`Retry send`:`Send prompt`),n.disabled=!G(x)}),K(`click`,n,function(...e){(G(C)?u():t.onsend)?.apply(this,e)}),J(e,n)};X(he,e=>{t.activeTurnId&&G(S)?e(ge):t.activeTurnId?e(_e,1):e(ve,-1)}),M(pe),M(O),H(()=>{Q(O,`aria-busy`,t.starting),Q(ee,`aria-label`,t.status),Oi(me,t.message),Q(me,`aria-describedby`,n()?`writer-hint`:void 0)}),K(`input`,me,e=>T(e.currentTarget.value)),K(`keydown`,me,D),J(e,O),$e()}Pr([`click`,`input`,`keydown`]);function Oo(e){let t=new Map;for(let n of e){if(!n.label.toLowerCase().replaceAll(` `,``).startsWith(`filechange`))continue;let e=n.changes?.length?n.changes:n.detail.split(`
|
|
6
|
+
${e??``}`),Q(s,`data-state`,t.activity.aggregateSubagents),Y(c,` Subagents: ${a[t.activity.aggregateSubagents]??``} (${t.activity.subagents.length??``})`),Y(d,t.activity.confidence===`fresh`?`Current`:t.activity.confidence===`reconciling`?`Checking updates`:`May be stale`)},[()=>g(t.activity.root.contextUsedPercent)]),J(e,n)};X(w,e=>{n()?e(T):t.activity&&e(E,1)});var D=V(w,2),O=e=>{var t=Na(),n=B(t),r=z(n,!0);M(n);var i=V(n,2),a=e=>{var t=Ma(),n=z(t,!0);M(t),H(()=>Y(n,G(c))),J(e,t)};X(i,e=>{G(c)&&e(a)}),H(()=>Y(r,G(s))),J(e,t)};X(D,e=>{t.activity&&e(O)}),M(S),H(()=>C=gi(S,1,`agent-activity svelte-d9jh4j`,null,C,{compact:n(),"align-start":r()===`start`})),J(e,S),$e()}Xe();var Ia=q(`<main class="svelte-iw6wrs"><h1 class="svelte-iw6wrs">Activity evidence</h1> <!><!></main>`);function La(e){let t={sessionId:`evidence`,confidence:`reconciling`,aggregateSubagents:`working`,root:{state:`awaitingAgent`,observedAt:`2026-01-01T00:00:00.000Z`,lastActivityAt:`2026-01-01T00:00:00.000Z`},subagents:[{id:`α-worker`,nickname:`α worker`,role:`research`,state:`working`,observedAt:`2026-01-01T00:00:00.000Z`,lastActivityAt:`2026-01-01T00:00:00.000Z`}]},n=[`working`,`awaitingAgent`,`awaitingHuman`,`blocked`,`idle`,`disconnected`];var r=Ia(),i=V(z(r),2);Fa(i,{get activity(){return t}}),Z(V(i),1,()=>n,e=>e,(e,n)=>{{let r=Tt(()=>({...t,sessionId:G(n),confidence:G(n)===`blocked`?`stale`:`fresh`,root:{...t.root,state:G(n)},aggregateSubagents:G(n)}));Fa(e,{get activity(){return G(r)}})}}),M(r),J(e,r)}function Ra(e,t){if(!e||typeof e!=`object`)return!1;let n=e,r=new Set([`working`,`idle`,`awaitingAgent`,`awaitingHuman`,`blocked`,`disconnected`]),i=(e,t=256)=>typeof e==`string`&&e.length<=t,a=e=>Array.isArray(e)&&e.length<=64&&e.every(e=>{let t=e;return t&&typeof t==`object`&&[`running`,`detached-active`,`exited-awaiting-result`,`result-consumed`,`terminated-for-budget`].includes(t.state)&&[`executor`,`supervisor`].includes(t.ownership)&&i(t.observedAt,64)&&!Number.isNaN(Date.parse(t.observedAt))}),o=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return i(t.state,32)&&r.has(t.state)&&i(t.observedAt,64)&&i(t.lastActivityAt,64)&&!Number.isNaN(Date.parse(t.observedAt))&&!Number.isNaN(Date.parse(t.lastActivityAt))&&(t.reason===void 0||i(t.reason,64))&&(t.contextUsedPercent===void 0||Number.isInteger(t.contextUsedPercent)&&t.contextUsedPercent>=0&&t.contextUsedPercent<=100)};return i(n.sessionId)&&(!t||n.sessionId===t)&&o(n.root)&&Array.isArray(n.subagents)&&n.subagents.length<=64&&n.subagents.every(e=>o(e)&&i(e.id)&&(e.nickname===void 0||i(e.nickname))&&(e.role===void 0||i(e.role))&&(e.model===void 0||i(e.model))&&(e.canonicalTaskName===void 0||i(e.canonicalTaskName))&&(e.canonicalPosition===void 0||i(e.canonicalPosition,32))&&(e.continuationGeneration===void 0||Number.isInteger(e.continuationGeneration)&&e.continuationGeneration>0)&&(e.outcome===void 0||[`partial`,`cancelled`,`failed`].includes(e.outcome))&&(e.ownedProcesses===void 0||a(e.ownedProcesses)))&&i(n.aggregateSubagents,32)&&r.has(n.aggregateSubagents)&&(n.confidence===`fresh`||n.confidence===`stale`||n.confidence===`reconciling`)}var za=class{#e=new Map;#t=new Map;#n=new Set;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=null;#l=!1;#u;constructor(e){this.#u={...e,websocket:e.websocket??(e=>new WebSocket(e)),location:e.location??location,setTimeout:e.setTimeout??setTimeout,clearTimeout:e.clearTimeout??clearTimeout}}get(e){return e?this.#e.get(e)??null:null}bootstrap(e,t){for(let t of e)!this.#e.has(t.id)&&Ra(t.agentActivity,t.id)&&this.#p(t.id,this.#t.get(t.id)??0,t.agentActivity);this.sync(e.map(e=>e.id),t)}sync(e,t){if(!this.#l){this.#c=t,this.#n=new Set(e);for(let e of this.#n)this.#i.has(e)||this.#i.set(e,0);for(let e of[...this.#i.keys()])this.#n.has(e)||this.remove(e);for(let[e,n]of this.#r)(e===t||!this.#n.has(e))&&(n.close(),this.#r.delete(e));for(let e of this.#n)this.hydrate(e),e!==t&&!this.#r.has(e)&&this.#f(e)}}select(e){this.sync([...this.#n],e)}remove(e){this.#n.delete(e),this.#i.set(e,(this.#i.get(e)??0)+1),this.#r.get(e)?.close(),this.#r.delete(e);let t=this.#a.get(e);t&&this.#u.clearTimeout(t),this.#a.delete(e),this.#o.delete(e),this.#s.delete(e),this.#e.delete(e),this.#t.delete(e),this.#u.publish(this.#e)}observe(e,t){if(this.#l||!this.#n.has(e)||!Number.isInteger(t.sequence))return;let n=this.#t.get(e)??0;t.sequence<=n||(t.sequence>n+1&&(this.#t.set(e,t.sequence-1),this.resync(e)),this.#t.set(e,t.sequence),this.#u.onEvent?.(e,t),t.type===`agent.activity.updated`&&Ra(t.payload,e)&&this.#p(e,t.sequence,t.payload))}async hydrate(e){let t=this.#i.get(e)??0,n=this.#t.get(e)??0;try{let r=await this.#u.relay.getSession(e);if(!this.#d(e,t))return;let i=this.#t.get(e)??0,a=r.currentSequence;if(Number.isInteger(a)){if(a<i)return;this.#t.set(e,a),Ra(r.agentActivity,e)&&this.#p(e,a,r.agentActivity),this.#u.onAuthoritativeSnapshot?.(e,r)}else i===n&&Ra(r.agentActivity,e)&&(this.#p(e,i,r.agentActivity),this.#u.onAuthoritativeSnapshot?.(e,r))}catch{this.#m(e)}}async resync(e){let t=this.#o.get(e);if(t)return t;let n=this.#i.get(e)??0;this.#m(e);let r;return r=(async()=>{try{await this.#u.relay.refreshActivity(e),this.#d(e,n)&&await this.hydrate(e)}catch{}finally{this.#o.get(e)===r&&this.#o.delete(e)}})(),this.#o.set(e,r),r}dispose(){this.#l=!0;for(let e of[...this.#n])this.remove(e)}#d(e,t){return!this.#l&&this.#n.has(e)&&this.#i.get(e)===t}#f(e){let t=this.#i.get(e)??0,n=this.#u.location.protocol===`https:`?`wss:`:`ws:`,r=this.#u.websocket(`${n}//${this.#u.location.host}/api/sessions/${encodeURIComponent(e)}/events?after=${this.#t.get(e)??0}`);this.#r.set(e,r),r.onmessage=n=>{if(!(!this.#d(e,t)||this.#r.get(e)!==r))try{this.#s.delete(e);let t=JSON.parse(String(n.data));t.type===`relay.resyncRequired`?this.resync(e):t.type===`relay.event`&&t.event&&this.observe(e,t.event)}catch{}},r.onclose=()=>{if(!this.#d(e,t)||this.#c===e)return;this.#r.delete(e),this.#m(e);let n=this.#s.get(e)??0,r=(this.#u.reconnectDelaysMs??[250,1e3,5e3])[n];r!==void 0&&(this.#s.set(e,n+1),this.#a.set(e,this.#u.setTimeout(()=>{this.#a.delete(e),this.#d(e,t)&&e!==this.#c&&this.#f(e)},r)))}}#p(e,t,n){let r=this.#e.get(e);this.#t.set(e,Math.max(t,this.#t.get(e)??0)),JSON.stringify(r)!==JSON.stringify(n)&&(this.#e.set(e,n),this.#u.publish(this.#e))}#m(e){let t=this.#e.get(e);t&&t.confidence===`fresh`&&(this.#e.set(e,{...t,confidence:`stale`}),this.#u.publish(this.#e))}};function Ba(e=globalThis.crypto,t=Date.now,n=Math.random){return typeof e?.randomUUID==`function`?e.randomUUID():`k-${t().toString(36)}-${Math.floor(n()*4294967296).toString(36)}`}var Va=(e,t=600)=>typeof e==`string`&&e.length<=t,Ha=e=>Va(e,64)&&!Number.isNaN(Date.parse(e));function Ua(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.enabled==`boolean`&&typeof t.state==`string`&&[`disabled`,`monitoring`,`backoff`,`attentionRequired`,`completed`,`safetyPaused`].includes(t.state)&&!!t.retry&&typeof t.retry==`object`&&Number.isInteger(t.retry.position)&&Number.isInteger(t.retry.limit)&&Va(t.updatedAt,64)&&(t.reason===void 0||Va(t.reason,80))&&(t.nextEvaluationAt===void 0||Va(t.nextEvaluationAt,64))&&(t.health===void 0||Wa(t.health))}function Wa(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!t.wait||typeof t.wait!=`object`)return!1;let n=t.wait;return typeof t.healthy==`boolean`&&typeof t.phase==`string`&&[`off`,`rootWorking`,`continuationScheduled`,`waitingForAgentEvent`,`checkingState`,`needsYou`,`safetyPaused`,`complete`,`degraded`].includes(t.phase)&&[`active`,`probeRequired`,`parked`,`retrying`,`attentionRequired`,`safetyPaused`,`none`].includes(t.supervision)&&typeof n.present==`boolean`&&Array.isArray(n.wakeCategories)&&n.wakeCategories.length<=9&&new Set(n.wakeCategories).size===n.wakeCategories.length&&n.wakeCategories.every(e=>[`planChanged`,`reviewChanged`,`checkpointChanged`,`interactionChanged`,`executorChanged`,`processExited`,`processResultAvailable`,`processLimitBreached`,`agentActivityChanged`].includes(e))&&(n.resumeAt===void 0||Ha(n.resumeAt))&&Ha(t.observedAt)&&Ha(t.lastTransitionAt)&&Va(t.nextExpectedAction)&&(t.degradationReason===void 0||[`missingContinuation`,`invalidWaitLease`,`controllerUnavailable`,`staleTransition`,`planMismatch`].includes(t.degradationReason))}function Ga(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.attention;if(!n||typeof n!=`object`)return!1;let r=n;return Va(t.requestId,256)&&(t.turnId===null||Va(t.turnId,256))&&(t.requestedAt===null||Va(t.requestedAt,64))&&Va(r.reason,64)&&Va(r.summary)&&Va(r.requestedAction)&&Va(r.resumeCondition,64)}function Ka(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`orgPlanAttention`&&Ga({requestId:t.requestId,turnId:t.turnId??null,requestedAt:t.requestedAt??null,attention:t.payload})}function qa(e){return{requestId:e.requestId,turnId:e.turnId,requestedAt:e.requestedAt,attention:e.payload}}var Ja=e=>{let t=e&&typeof e==`object`?e.code:void 0;return t===`AUTOPILOT_PLAN_REQUIRED`?`An incomplete supervised plan is required before Autopilot can start.`:t===`AUTOPILOT_PLAN_COMPLETE`?`This plan is complete, so Autopilot is unavailable.`:t===`AUTOPILOT_SESSION_UNAVAILABLE`?`This session is unavailable for Autopilot.`:e instanceof Error?e.message:`Could not update Autopilot.`},Ya=class{relay;publish;createKey;#e=new Map;#t=new Map;#n=new Set;#r=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#c=new Map;#l=new Map;#u=new Map;#d=new Set;#f=!1;constructor(e,t,n=Ba){this.relay=e,this.publish=t,this.createKey=n}bootstrap(e){if(this.#f)return;let t=new Set(e.map(e=>e.id));for(let e of this.#d)t.has(e)||this.remove(e);this.#d=t;for(let t of e){this.#i.has(t.id)||this.#i.set(t.id,0),this.#a.has(t.id)||this.#a.set(t.id,0);let e=this.#u.get(t.id)??0,n=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null,r=this.#c.get(t.id);!this.#n.has(t.id)&&(r===void 0||n!==null&&n>r)&&(n!==null&&n>e||!this.#e.has(t.id)&&e===0)&&(n!==null&&(this.#u.set(t.id,n),r!==void 0&&n>r&&this.#c.delete(t.id)),this.#g(t.id,t))}this.#_()}observe(e,t){if(this.#f||!this.#d.has(e)||!Number.isInteger(t.sequence))return;let n=this.#u.get(e)??0;t.sequence<=n||(this.#u.set(e,t.sequence),this.#a.set(e,(this.#a.get(e)??0)+1),t.type===`autopilot.updated`&&this.#m(e,t.payload),t.type===`org-plan.attention-required`&&this.#h(e,t.payload),t.type===`org-plan.attention-resolved`&&(t.payload&&typeof t.payload==`object`&&t.payload.outcome,this.#t.delete(e)),this.#_())}async hydrate(e,t){let n=this.#i.get(e)??0,r=(this.#l.get(e)??0)+1;this.#l.set(e,r);let i=t??this.#u.get(e)??0,a=this.#o.get(e),o=this.#s.get(e)??0;try{let t=await this.relay.getSession(e);if(!this.#p(e,n)||this.#l.get(e)!==r||(this.#s.get(e)??0)!==o||this.#o.has(e)&&this.#o.get(e)!==a)return;let s=this.#u.get(e)??0,c=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null;c!==null&&c>s?(this.#u.set(e,c),this.#g(e,t)):c===null&&s===i&&this.#g(e,t),this.#_()}catch{}}async toggle(e,t){if(this.#f||!this.#d.has(e)||this.#n.has(e))return;let n=this.#i.get(e)??0,r=this.#a.get(e)??0;this.#o.set(e,(this.#o.get(e)??0)+1),this.#s.set(e,(this.#s.get(e)??0)+1),this.#n.add(e),this.#r.delete(e),this.#_();try{let i=await this.relay.setAutopilot(e,t,this.createKey());this.#p(e,n)&&this.#a.get(e)===r&&(this.#m(e,i.autopilot),this.#a.set(e,r+1),this.#c.set(e,this.#u.get(e)??0),Ua(i.autopilot)&&!i.autopilot.enabled&&this.#t.delete(e))}catch(t){this.#p(e,n)&&this.#a.get(e)===r&&this.#r.set(e,Ja(t))}finally{this.#p(e,n)&&(this.#n.delete(e),this.#s.set(e,(this.#s.get(e)??0)+1)),this.#_()}}async resolve(e,t,n){let r=this.#t.get(e);if(!r||this.#n.has(e)||this.#f)return;let i=n?.trim();if(i&&i.length>600){this.#r.set(e,`Guidance must be 600 characters or fewer.`),this.#_();return}let a=this.#i.get(e)??0,o=this.#a.get(e)??0;this.#s.set(e,(this.#s.get(e)??0)+1),this.#n.add(e),this.#r.delete(e),this.#_();try{await this.relay.resolveAttention(e,r.requestId,{operationKey:this.createKey(),action:t,...i?{guidance:i}:{}}),this.#p(e,a)&&this.#a.get(e)===o&&await this.hydrate(e)}catch(t){this.#p(e,a)&&this.#a.get(e)===o&&this.#r.set(e,t instanceof Error?t.message:`Could not resolve attention.`)}finally{this.#p(e,a)&&(this.#n.delete(e),this.#s.set(e,(this.#s.get(e)??0)+1)),this.#_()}}remove(e){this.#i.set(e,(this.#i.get(e)??0)+1),this.#d.delete(e),this.#e.delete(e),this.#t.delete(e),this.#n.delete(e),this.#r.delete(e),this.#u.delete(e),this.#a.delete(e),this.#o.delete(e),this.#s.delete(e),this.#c.delete(e),this.#l.delete(e),this.#_()}dispose(){this.#f=!0,this.#d.clear(),this.#e.clear(),this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#l.clear(),this.#a.clear(),this.#o.clear(),this.#s.clear(),this.#c.clear(),this.#_()}#p(e,t){return!this.#f&&this.#d.has(e)&&this.#i.get(e)===t}#m(e,t){Ua(t)&&this.#e.set(e,t)}#h(e,t){if(Ga(t))this.#t.set(e,t);else if(Ka(t))this.#t.set(e,qa(t));else if(Array.isArray(t)){let n=t.find(Ka);n?this.#t.set(e,qa(n)):this.#t.delete(e)}}applyAuthoritative(e,t){if(this.#f||!this.#d.has(e)||this.#n.has(e))return;let n=typeof t.currentSequence==`number`&&Number.isInteger(t.currentSequence)?t.currentSequence:null,r=this.#u.get(e)??0,i=this.#c.get(e);i!==void 0&&(n===null||n<=i)||n!==null&&n<r||(n!==null&&(this.#u.set(e,n),i!==void 0&&n>i&&this.#c.delete(e)),this.#g(e,t),this.#_())}#g(e,t){this.#a.set(e,(this.#a.get(e)??0)+1),this.#m(e,t.autopilot),this.#h(e,t.pendingInteractions)}#_(){this.publish({snapshots:new Map(this.#e),attention:new Map(this.#t),pending:new Set(this.#n),errors:new Map(this.#r)})}},Xa=q(`<span aria-hidden="true" class="svelte-1qf1ppf"> </span> `,1),Za=q(`<div class="control-row svelte-1qf1ppf"><span class="status svelte-1qf1ppf"><span aria-hidden="true" class="svelte-1qf1ppf"> </span> </span> <!></div>`),Qa=q(`<section aria-label="Autopilot"><p class="visually-hidden svelte-1qf1ppf" data-testid="autopilot-live-status" aria-live="polite" aria-atomic="true"> </p> <!> <p> </p></section>`);function $a(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-control`),r=$(t,`compact`,3,!1),i=$(t,`indicatorOnly`,3,!1),a=$(t,`pending`,3,!1),o=$(t,`ontoggle`,3,()=>{}),s={disabled:`Off`,monitoring:`Monitoring`,backoff:`Waiting to continue`,attentionRequired:`Paused for attention`,completed:`Complete`,safetyPaused:`Safety paused`},c={off:`Off`,rootWorking:`On · root working`,continuationScheduled:`On · continuation scheduled`,waitingForAgentEvent:`On · waiting for agent event`,checkingState:`On · checking state`,needsYou:`Paused · needs you`,safetyPaused:`Safety paused`,complete:`Complete`,degraded:`On · continuation unavailable`},l={planRequired:`An incomplete supervised plan is required before Autopilot can start.`,planComplete:`This plan is complete, so Autopilot is unavailable.`,sessionUnavailable:`This session is unavailable for Autopilot.`,attentionRequired:`Autopilot is paused because an agent is waiting for human input.`,noPlanProgress:`Autopilot paused because the plan did not make durable progress.`,reconcileFailed:`Autopilot paused because it could not safely confirm session state.`,startUnavailable:`Automatic continuation could not start because the session runtime is unavailable. Restore or reopen the session, then retry Autopilot.`,actionRateExceeded:`Autopilot paused after too many automatic actions in ten minutes. Wait for the safety window to clear, or continue manually.`,planRemoved:`The retained plan was removed.`,planReplaced:`The retained plan changed. Enable Autopilot again after reviewing it.`,sessionEnded:`This session ended.`,manualDisabled:`Autopilot is off.`,safetyPaused:`Autopilot paused after a repeated or invalid automatic continuation. Resume manually when ready.`},u=P(()=>t.autopilot?t.autopilot.health?c[t.autopilot.health.phase]:s[t.autopilot.state]:`Unavailable`),d=P(()=>t.autopilot?.state===`backoff`&&t.autopilot.retry.position>0&&t.autopilot.retry.limit>0?`Retry ${t.autopilot.retry.position} of ${t.autopilot.retry.limit}.`:null),f=P(()=>(t.autopilot?.reason?l[t.autopilot.reason]:null)??G(d)??t.autopilot?.health?.nextExpectedAction??(t.autopilot?.state===`monitoring`?`Autopilot is monitoring this supervised plan.`:t.autopilot?.state===`attentionRequired`?`Autopilot is paused because human attention is required.`:`Autopilot state is loading from the relay.`)),p=P(()=>`Autopilot status: ${G(u)}. ${G(f)}`),m=P(()=>t.autopilot?.enabled??!1);var h=Qa();let g;var _=z(h),v=z(_,!0);M(_);var y=V(_,2),b=e=>{{let t=P(()=>`${n()}-button`),r=P(()=>i()?`Autopilot: ${a()?`Updating`:G(u)}`:void 0),s=P(()=>`${n()}-help`);Ca(e,{get id(){return G(t)},compact:!0,full:!0,get pressed(){return G(m)},get accentPressed(){return i()},get label(){return G(r)},get describedby(){return G(s)},get ariaDisabled(){return a()},onclick:()=>{a()||o()(!G(m))},children:(e,t)=>{var n=Hr(),r=B(n),o=e=>{J(e,Vr(`Autopilot`))},s=e=>{var t=Xa(),n=B(t),r=z(n,!0);M(n);var i=V(n);H(()=>{Y(r,G(m)?`●`:`○`),Y(i,` Autopilot: ${(a()?`Updating…`:G(u))??``}`)}),J(e,t)};X(r,e=>{i()?e(o):e(s,-1)}),J(e,n)},$$slots:{default:!0}})}},x=e=>{var r=Za(),i=z(r),s=z(i),c=z(s,!0);M(s);var l=V(s);M(i);var d=V(i,2);{let e=P(()=>`${n()}-button`),t=P(()=>`${n()}-help`);Ca(d,{get id(){return G(e)},get pressed(){return G(m)},get describedby(){return G(t)},get ariaDisabled(){return a()},onclick:()=>{a()||o()(!G(m))},children:(e,t)=>{Ue();var n=Vr();H(()=>Y(n,a()?`Updating…`:G(m)?`Pause`:`Enable`)),J(e,n)},$$slots:{default:!0}})}M(r),H(()=>{Q(i,`data-state`,t.autopilot?.state??`unavailable`),Y(c,G(m)?`●`:`○`),Y(l,` Autopilot: ${G(u)??``}`)}),J(e,r)};X(y,e=>{r()?e(b):e(x,-1)});var S=V(y,2);let C;var w=z(S,!0);M(S),M(h),H(()=>{g=gi(h,1,`autopilot-control svelte-1qf1ppf`,null,g,{compact:r()}),Y(v,G(p)),Q(S,`id`,`${n()}-help`),C=gi(S,1,`svelte-1qf1ppf`,null,C,{"visually-hidden":r()}),Y(w,G(f))}),J(e,h),$e()}var eo=q(`<section class="attention svelte-1hnxk0w" role="alert"><h3 class="svelte-1hnxk0w">Autopilot needs your attention</h3> <dl class="svelte-1hnxk0w"><div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Reason</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">What happened</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Requested action</dt> <dd class="svelte-1hnxk0w"> </dd></div> <div class="svelte-1hnxk0w"><dt class="svelte-1hnxk0w">Resume when</dt> <dd class="svelte-1hnxk0w"> </dd></div></dl> <label>Optional guidance for the resumed work</label> <textarea maxlength="600" class="svelte-1hnxk0w"></textarea> <p class="guidance-help svelte-1hnxk0w"> </p> <div class="actions svelte-1hnxk0w"><button type="button" class="svelte-1hnxk0w"> </button> <button type="button" class="svelte-1hnxk0w">Disable Autopilot</button></div></section>`);function to(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-attention`),r=$(t,`pending`,3,!1),i=$(t,`onresolve`,3,()=>{}),a=I(``),o=P(()=>G(a).trim().length>600?`Guidance must be 600 characters or fewer.`:``);var s=Hr(),c=B(s),l=e=>{var s=eo(),c=z(s),l=V(c,2),u=z(l),d=V(z(u),2),f=z(d,!0);M(d),M(u);var p=V(u,2),m=V(z(p),2),h=z(m,!0);M(m),M(p);var g=V(p,2),_=V(z(g),2),v=z(_,!0);M(_),M(g);var y=V(g,2),b=V(z(y),2),x=z(b,!0);M(b),M(y),M(l);var S=V(l,2),C=V(S,2);Sn(C);var w=V(C,2),T=z(w,!0);M(w);var E=V(w,2),D=z(E),O=z(D,!0);M(D);var ee=V(D,2);M(E),M(s),H((e,i)=>{Q(s,`aria-labelledby`,`${n()}-title`),Q(c,`id`,`${n()}-title`),Y(f,t.attention.attention.reason),Y(h,t.attention.attention.summary),Y(v,t.attention.attention.requestedAction),Y(x,t.attention.attention.resumeCondition),Q(S,`for`,`${n()}-guidance`),Q(C,`id`,`${n()}-guidance`),Q(C,`aria-describedby`,`${n()}-guidance-help`),Q(C,`aria-invalid`,e),Q(w,`id`,`${n()}-guidance-help`),Y(T,G(o)||`Up to 600 characters. Do not include secrets.`),D.disabled=i,Y(O,r()?`Updating…`:`Resume`),ee.disabled=r()},[()=>!!G(o),()=>r()||!!G(o)]),Ni(C,()=>G(a),e=>L(a,e)),K(`click`,D,()=>G(a).trim()?i()(`resume`,G(a)):i()(`resume`)),K(`click`,ee,()=>i()(`disableAutopilot`)),J(e,s)};X(c,e=>{t.attention&&e(l)}),J(e,s),$e()}Pr([`click`]);var no=q(`<section class="safety-stop svelte-yp6bgs" role="alert"><h3 class="svelte-yp6bgs">Autopilot safety stop</h3> <p class="svelte-yp6bgs"> </p> <p class="svelte-yp6bgs"> </p> <div class="actions svelte-yp6bgs"><button type="button" class="svelte-yp6bgs"> </button> <button type="button" class="svelte-yp6bgs">Disable Autopilot</button></div></section>`);function ro(e,t){Qe(t,!0);let n=$(t,`controlId`,3,`autopilot-safety-stop`),r=$(t,`pending`,3,!1),i=$(t,`onrecover`,3,()=>{}),a=$(t,`ondisable`,3,()=>{}),o={attentionRequired:`The coordinator stopped because it needs a human safety decision, but no actionable agent request is available.`,noPlanProgress:`The coordinator stopped because recent automatic turns made no durable plan progress.`,reconcileFailed:`The coordinator stopped because it could not safely confirm the session state.`,startUnavailable:`The coordinator stopped because the session runtime was unavailable when it tried to start an automatic turn.`,actionRateExceeded:`The coordinator stopped because it reached the automatic-action safety limit.`},s=P(()=>t.autopilot?.reason&&!t.attention?o[t.autopilot.reason]??null:null),c=P(()=>t.autopilot?.reason===`startUnavailable`?`There is no pending agent attention request to answer. Restore or reopen this session, then retry Autopilot.`:t.autopilot?.reason===`actionRateExceeded`?`There is no pending agent attention request to answer. Wait for the ten-minute safety window to clear, or continue manually.`:`There is no pending agent attention request to answer. Retry the supported Autopilot coordinator after addressing the cause, or disable it.`);var l=Hr(),u=B(l),d=e=>{var t=no(),o=z(t),l=V(o,2),u=z(l,!0);M(l);var d=V(l,2),f=z(d,!0);M(d);var p=V(d,2),m=z(p),h=z(m,!0);M(m);var g=V(m,2);M(p),M(t),H(()=>{Q(t,`aria-labelledby`,`${n()}-title`),Q(o,`id`,`${n()}-title`),Y(u,G(s)),Y(f,G(c)),m.disabled=r(),Y(h,r()?`Updating…`:`Retry Autopilot`),g.disabled=r()}),K(`click`,m,function(...e){i()?.apply(this,e)}),K(`click`,g,function(...e){a()?.apply(this,e)}),J(e,t)};X(u,e=>{t.autopilot?.state===`attentionRequired`&&G(s)&&e(d)}),J(e,l),$e()}Pr([`click`]);function io(e,t=`gestalt-mobile.autopilot-attention-toasts.v1`,n=100){let r=ao(e,t,n);return{claim(i){if(r.has(i))return!1;r=new Set([...r,i].slice(-n));try{e?.setItem(t,JSON.stringify([...r]))}catch{}return!0}}}function ao(e,t,n){try{let r=JSON.parse(e?.getItem(t)??`[]`);return new Set(Array.isArray(r)?r.filter(e=>typeof e==`string`).slice(-n):[])}catch{return new Set}}var oo=[{name:`model`,description:`Choose the model for the next turn`,argumentPicker:`models`},{name:`reasoning`,description:`Choose reasoning effort for the next turn`,argumentPicker:`reasoning`}];function so(e){let t=e.match(/^\/([^\s]*)$/);return t?t[1].toLowerCase():null}function co(e){let t=so(e);return t===null?[]:oo.filter(e=>e.name.startsWith(t))}function lo(e){let t=e.match(/^\/([^\s]+)\s*$/)?.[1]?.toLowerCase();return oo.find(e=>e.name===t)?.argumentPicker}function uo(e){return[...e].sort((e,t)=>fo(t,e)||t.localeCompare(e))}function fo(e,t){let n=e.match(/\d+(?:\.\d+)*/)?.[0].split(`.`).map(Number)??[],r=t.match(/\d+(?:\.\d+)*/)?.[0].split(`.`).map(Number)??[];for(let e=0;e<Math.max(n.length,r.length);e+=1){let t=(n[e]??0)-(r[e]??0);if(t)return t}return 0}var po=q(`Ready <span class="block-cursor svelte-1264sfg" aria-hidden="true"></span>`,1),mo=q(`<p id="writer-hint" class="writer-hint svelte-1264sfg">You can read this conversation. Sending will connect to Codex.</p>`),ho=q(`<button type="button" class="svelte-1264sfg">Retry send</button>`),go=q(`<div class="writer-feedback svelte-1264sfg" role="alert" aria-atomic="true"><p class="svelte-1264sfg"> </p> <!></div>`),_o=q(`<li><button type="button" class="svelte-1264sfg"><code class="svelte-1264sfg"> </code> <small class="svelte-1264sfg"> </small></button></li>`),vo=q(`<ul id="chat-command-completion" class="command-menu svelte-1264sfg" aria-label="Chat commands"></ul>`),yo=q(`<li class="svelte-1264sfg"><button type="button" class="svelte-1264sfg"><code class="svelte-1264sfg"> </code></button></li>`),bo=q(`<ul class="command-menu svelte-1264sfg" aria-label="Available models"></ul>`),xo=q(`<ul class="command-menu svelte-1264sfg" aria-label="Reasoning efforts"></ul>`),So=q(`<div id="prompt-action-panel" class="action-panel svelte-1264sfg" aria-label="Prompt actions"><button type="button" class="svelte-1264sfg">Queue message</button> <button type="button" class="svelte-1264sfg">Interrupt and send</button></div>`),Co=q(`<div class="prompt-action svelte-1264sfg"><button type="button" aria-label="Choose prompt action" aria-controls="prompt-action-panel" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><circle cx="6" cy="12" r="1.5" class="svelte-1264sfg"></circle><circle cx="12" cy="12" r="1.5" class="svelte-1264sfg"></circle><circle cx="18" cy="12" r="1.5" class="svelte-1264sfg"></circle></svg></button> <!></div>`),wo=q(`<button type="button" aria-label="Interrupt" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><path d="m7 7 10 10M17 7 7 17" class="svelte-1264sfg"></path></svg></button>`),To=q(`<button type="button" class="svelte-1264sfg"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1264sfg"><path d="M9 10 5 14l4 4M5 14h8a6 6 0 0 0 6-6V6" class="svelte-1264sfg"></path></svg></button>`),Eo=q(`<form class="svelte-1264sfg"><p role="status" aria-live="polite" aria-atomic="true" class="svelte-1264sfg"><!></p> <!> <!> <!> <!> <!> <div class="prompt-row svelte-1264sfg"><textarea id="message" aria-label="Prompt" placeholder="Prompt" rows="1" required="" class="svelte-1264sfg"></textarea> <!></div></form>`);function Do(e,t){Qe(t,!0);let n=$(t,`detached`,3,!1),r=$(t,`retryMessage`,3,null),i=$(t,`retryable`,3,!1),a=$(t,`models`,19,()=>[]),o=$(t,`onscrollbottom`,3,()=>{}),s=$(t,`onmodelselect`,3,()=>{}),c=$(t,`onqueue`,3,()=>{}),l=$(t,`oninterruptsend`,3,()=>{}),u=$(t,`onretry`,3,()=>{}),d=I(0),f=I(null),p=I(!1),m=P(()=>co(t.message)),h=P(()=>so(t.message)),g=P(()=>G(h)!==null&&G(h)!==G(f)&&G(m).length>0),_=P(()=>lo(t.message)),v=P(()=>G(_)===`models`),y=P(()=>uo(a())),b=P(()=>G(_)===`reasoning`),x=P(()=>!t.activeTurnId&&!t.starting&&!!t.message.trim()),S=P(()=>!!t.message.trim()),C=P(()=>i()&&!r());function w(e){L(p,!1),e===`queue`?c()():l()()}function T(e,n=!1){L(f,null),L(d,0),t.onchange(e),n&&o()()}function E(e=G(d)){let t=G(m)[e];t&&T(`/${t.name} `,!0)}function D(e){if(e.key===`Enter`&&e.ctrlKey&&!e.isComposing){if(t.activeTurnId&&!t.starting&&G(S)){e.preventDefault(),w(`queue`);return}if(G(x)){e.preventDefault(),t.onsend();return}}if(G(g)){if(e.key===`ArrowDown`){e.preventDefault(),L(d,(G(d)+1)%G(m).length);return}if(e.key===`ArrowUp`){e.preventDefault(),L(d,(G(d)-1+G(m).length)%G(m).length);return}if(e.key===`Escape`){e.preventDefault(),L(f,G(h),!0);return}if(e.key===`Tab`){e.preventDefault(),E();return}}}var O=Eo(),ee=z(O),k=z(ee),te=e=>{var t=po();Ue(),J(e,t)},ne=e=>{var n=Vr();H(()=>Y(n,t.status)),J(e,n)};X(k,e=>{t.status===`Ready.`?e(te):e(ne,-1)}),M(ee);var re=V(ee,2),ie=e=>{J(e,mo())};X(re,e=>{n()&&e(ie)});var ae=V(re,2),oe=e=>{var n=go(),a=z(n),o=z(a,!0);M(a);var s=V(a,2),c=e=>{var n=ho();H(()=>n.disabled=t.starting),K(`click`,n,function(...e){u()?.apply(this,e)}),J(e,n)};X(s,e=>{i()&&e(c)}),M(n),H(()=>Y(o,r())),J(e,n)};X(ae,e=>{r()&&e(oe)});var se=V(ae,2),ce=e=>{var t=vo();Z(t,23,()=>G(m),e=>e.name,(e,t,n)=>{var r=_o(),i=z(r),a=z(i),o=z(a);M(a);var s=V(a,2),c=z(s,!0);M(s),M(i),M(r),H(()=>{gi(r,1,ui(G(n)===G(d)?`command-selected`:void 0),`svelte-1264sfg`),Y(o,`/${G(t).name??``}`),Y(c,G(t).description)}),K(`click`,i,()=>E(G(n))),J(e,r)}),M(t),J(e,t)};X(se,e=>{G(g)&&e(ce)});var le=V(se,2),ue=e=>{var t=bo();Z(t,20,()=>G(y),e=>e,(e,t)=>{var n=yo(),r=z(n),i=z(r),a=z(i,!0);M(i),M(r),M(n),H(()=>Y(a,t)),K(`click`,r,()=>{s()(t),o()()}),J(e,n)}),M(t),J(e,t)};X(le,e=>{G(v)&&e(ue)});var de=V(le,2),fe=e=>{var t=xo();Z(t,20,()=>[`low`,`medium`,`high`],e=>e,(e,t)=>{var n=yo(),r=z(n),i=z(r),a=z(i,!0);M(i),M(r),M(n),H(()=>Y(a,t)),K(`click`,r,()=>T(`/reasoning ${t} `,!0)),J(e,n)}),M(t),J(e,t)};X(de,e=>{G(b)&&e(fe)});var pe=V(de,2),me=z(pe);Sn(me);var he=V(me,2),ge=e=>{var t=Co(),n=z(t),r=V(n,2),i=e=>{var t=So(),n=z(t),r=V(n,2);M(t),K(`click`,n,()=>w(`queue`)),K(`click`,r,()=>w(`interrupt-send`)),J(e,t)};X(r,e=>{G(p)&&e(i)}),M(t),H(()=>Q(n,`aria-expanded`,G(p))),K(`click`,n,()=>L(p,!G(p))),J(e,t)},_e=e=>{var n=wo();H(()=>n.disabled=t.starting),K(`click`,n,function(...e){t.oninterrupt?.apply(this,e)}),J(e,n)},ve=e=>{var n=To();H(()=>{Q(n,`aria-label`,G(C)?`Retry send`:`Send prompt`),n.disabled=!G(x)}),K(`click`,n,function(...e){(G(C)?u():t.onsend)?.apply(this,e)}),J(e,n)};X(he,e=>{t.activeTurnId&&G(S)?e(ge):t.activeTurnId?e(_e,1):e(ve,-1)}),M(pe),M(O),H(()=>{Q(O,`aria-busy`,t.starting),Q(ee,`aria-label`,t.status),Oi(me,t.message),Q(me,`aria-describedby`,n()?`writer-hint`:void 0)}),K(`input`,me,e=>T(e.currentTarget.value)),K(`keydown`,me,D),J(e,O),$e()}Pr([`click`,`input`,`keydown`]);function Oo(e){let t=new Map;for(let n of e){if(!n.label.toLowerCase().replaceAll(` `,``).startsWith(`filechange`))continue;let e=n.changes?.length?n.changes:n.detail.split(`
|
|
7
7
|
`).filter(Boolean).map(e=>({path:e,additions:null,deletions:null}));for(let r of e){let e=t.get(r.path),i=typeof r.additions==`number`&&typeof r.deletions==`number`;t.set(r.path,{path:r.path,additions:i&&e?.additions!==null?(e?.additions??0)+r.additions:null,deletions:i&&e?.deletions!==null?(e?.deletions??0)+r.deletions:null,...n.occurredAt===void 0?e?.touchedAt===void 0?{}:{touchedAt:e.touchedAt}:{touchedAt:Math.max(e?.touchedAt??0,n.occurredAt)}})}}return[...t.values()]}function ko(e){return{files:e.length,additions:e.every(e=>e.additions!==null)?e.reduce((e,t)=>e+t.additions,0):null,deletions:e.every(e=>e.deletions!==null)?e.reduce((e,t)=>e+t.deletions,0):null}}function Ao(e,t){if(e===void 0||t===void 0||!Number.isFinite(e)||!Number.isFinite(t))return null;let n=Math.floor(Math.max(0,t-e)/6e4);if(n<1)return`moments later`;if(n<60)return`${n} minute${n===1?``:`s`} later`;let r=Math.floor(n/60);if(r<24)return`${r} hour${r===1?``:`s`} later`;let i=Math.floor(r/24);return`${i} day${i===1?``:`s`} later`}function jo(e){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`}).format(e)}function Mo(e,t){let n=Math.floor(Math.max(0,t-e)/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}var No=q(`<dl class="command-counts svelte-11ye6aj"><div class="svelte-11ye6aj"><dt class="svelte-11ye6aj">Successful commands</dt> <dd class="svelte-11ye6aj"> </dd></div> <div class="svelte-11ye6aj"><dt class="svelte-11ye6aj">Failed commands</dt> <dd class="svelte-11ye6aj"> </dd></div></dl>`),Po=q(`<li data-status="failed" class="svelte-11ye6aj"><code class="svelte-11ye6aj"> </code></li>`),Fo=q(`<section aria-label="Failed commands"><strong>Failed commands</strong> <ul class="activity-list svelte-11ye6aj"></ul></section>`),Io=q(`<li class="svelte-11ye6aj"><small class="svelte-11ye6aj"> </small> <span class="svelte-11ye6aj"> </span></li>`),Lo=q(`<ul class="activity-list svelte-11ye6aj" aria-label="Work activity"></ul>`),Ro=q(`<time class="svelte-11ye6aj"> </time>`),zo=q(`<span class="svelte-11ye6aj">time unknown</span>`),Bo=q(`<li class="svelte-11ye6aj"><code class="svelte-11ye6aj"> </code> <span class="file-counts svelte-11ye6aj" aria-label="Line changes"><span class="svelte-11ye6aj"> </span><span class="svelte-11ye6aj"> </span></span> <!></li>`),Vo=q(`<section aria-label="Files changed"><strong>Files changed</strong> <ul class="file-list svelte-11ye6aj"></ul></section>`),Ho=q(`<details class="work-details svelte-11ye6aj"><summary class="svelte-11ye6aj"> </summary> <div class="work-details-content svelte-11ye6aj"><!> <!> <!> <!></div></details>`);function Uo(e,t){Qe(t,!0);let n=$(t,`now`,19,()=>Date.now()),r=P(()=>ua(t.activities)),i=P(()=>t.activities.flatMap(e=>{let t=da(e);return t?.kind===`Command`&&t.status===`failed`?[{id:e.id,command:t.content}]:[]})),a=P(()=>Oo(t.activities)),o=P(()=>ko(G(a))),s=P(()=>t.activities.flatMap(e=>{let t=da(e);return t&&t.kind!==`Command`&&t.kind!==`File change`?[{id:e.id,...t}]:[]})),c=P(()=>t.activities.length),l=P(()=>G(a).length?`${G(o).files} ${G(o).files===1?`file`:`files`} changed · +${G(o).additions??`?`} −${G(o).deletions??`?`}`:`Work details · ${G(c)} ${G(c)===1?`activity`:`activities`}`);var u=Hr(),d=B(u),f=e=>{var t=Ho(),o=z(t),c=z(o,!0);M(o);var u=V(o,2),d=z(u),f=e=>{var t=No(),n=z(t),i=V(z(n),2),a=z(i,!0);M(i),M(n);var o=V(n,2),s=V(z(o),2),c=z(s,!0);M(s),M(o),M(t),H(()=>{Y(a,G(r).successful),Y(c,G(r).failed)}),J(e,t)};X(d,e=>{(G(r).successful||G(r).failed)&&e(f)});var p=V(d,2),m=e=>{var t=Fo(),n=V(z(t),2);Z(n,21,()=>G(i),e=>e.id,(e,t)=>{var n=Po(),r=z(n),i=z(r,!0);M(r),M(n),H(()=>Y(i,G(t).command)),J(e,n)}),M(n),M(t),J(e,t)};X(p,e=>{G(i).length&&e(m)});var h=V(p,2),g=e=>{var t=Lo();Z(t,21,()=>G(s),e=>e.id,(e,t)=>{var n=Io(),r=z(n),i=z(r);M(r);var a=V(r,2),o=z(a,!0);M(a),M(n),H(()=>{Q(n,`data-status`,G(t).status),Y(i,`${G(t).kind??``}${G(t).status?` · ${G(t).status}`:``}`),Y(o,G(t).content)}),J(e,n)}),M(t),J(e,t)};X(h,e=>{G(s).length&&e(g)});var _=V(h,2),v=e=>{var t=Vo(),r=V(z(t),2);Z(r,21,()=>G(a),e=>e.path,(e,t)=>{var r=Bo(),i=z(r),a=z(i,!0);M(i);var o=V(i,2),s=z(o),c=z(s);M(s);var l=V(s),u=z(l);M(l),M(o);var d=V(o,2),f=e=>{var r=Ro(),i=z(r,!0);M(r),H((e,t)=>{Q(r,`datetime`,e),Y(i,t)},[()=>new Date(G(t).touchedAt).toISOString(),()=>Mo(G(t).touchedAt,n())]),J(e,r)},p=e=>{J(e,zo())};X(d,e=>{G(t).touchedAt===void 0?e(p,-1):e(f)}),M(r),H(()=>{Y(a,G(t).path),Y(c,`+${G(t).additions??`?`??``}`),Y(u,`-${G(t).deletions??`?`??``}`)}),J(e,r)}),M(r),M(t),J(e,t)};X(_,e=>{G(a).length&&e(v)}),M(u),M(t),H(()=>Y(c,G(l))),J(e,t)};X(d,e=>{G(c)&&e(f)}),J(e,u),$e()}function Wo(e){if(!e||typeof e!=`object`)return null;let t=e.command;return typeof t==`string`&&t.trim()?t:null}function Go(e){if(!Ko(e))return null;let t=e.changes;if(!Array.isArray(t))return null;let n=t.map(e=>Ko(e)&&typeof e.path==`string`&&e.path.trim()?e.path:null).filter(e=>e!==null);return n.length===t.length&&n.length>0?n:null}function Ko(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var qo=q(`<div class="choice svelte-77f3gb"><input type="radio" class="svelte-77f3gb"/> <label class="svelte-77f3gb"><strong> </strong><span class="svelte-77f3gb"> </span></label></div>`),Jo=q(`<label class="custom svelte-77f3gb">Your custom answer <input required="" class="svelte-77f3gb"/></label>`),Yo=q(`<div class="choice svelte-77f3gb"><input type="radio" class="svelte-77f3gb"/> <label class="svelte-77f3gb"><strong>Custom answer</strong><span class="svelte-77f3gb">Provide your own response.</span></label></div> <!>`,1),Xo=q(`<fieldset class="svelte-77f3gb"><legend class="svelte-77f3gb"><strong> </strong><span class="svelte-77f3gb"> </span></legend> <div class="choices svelte-77f3gb"><!> <!></div></fieldset>`),Zo=q(`<form class="quiz-form svelte-77f3gb"><fieldset class="questions svelte-77f3gb"></fieldset> <button type="submit">Send answers</button></form>`);function Qo(e,t){Qe(t,!0);let n=$(t,`disabled`,3,!1),r=R({}),i=R({}),a=P(()=>t.quiz.questions.every(e=>!!t.answers[e.id]?.trim()));async function o(e){i[e]=!0,t.onanswer(e,t.answers[e]??``),await Cr(),r[e]?.focus()}var s=Zo(),c=z(s);Z(c,21,()=>t.quiz.questions,e=>e.id,(e,n)=>{let a=P(()=>`${t.requestId}-${G(n).id}-custom`),s=P(()=>G(n).choices.some(e=>e.label===t.answers[G(n).id]));var c=Xo(),l=z(c),u=z(l),d=z(u,!0);M(u);var f=V(u),p=z(f,!0);M(f),M(l);var m=V(l,2),h=z(m);Z(h,17,()=>G(n).choices,e=>`${G(n).id}-${e.label}`,(e,r)=>{let a=P(()=>`${t.requestId}-${G(n).id}-${G(r).label}`);var o=qo(),s=z(o);Di(s);var c=V(s,2),l=z(c),u=z(l,!0);M(l);var d=V(l),f=z(d,!0);M(d),M(c),M(o),H(()=>{Q(s,`id`,G(a)),Q(s,`name`,`${t.requestId}-${G(n).id}`),ki(s,t.answers[G(n).id]===G(r).label),Q(c,`for`,G(a)),Y(u,G(r).label),Y(f,G(r).description)}),K(`change`,s,()=>{i[G(n).id]=!1,t.onanswer(G(n).id,G(r).label)}),J(e,o)});var g=V(h,2),_=e=>{var c=Yo(),l=B(c),u=z(l);Di(u);var d=V(u,2);M(l);var f=V(l,2),p=e=>{var i=Jo(),o=V(z(i));Di(o),Li(o,(e,t)=>r[t.id]=e,e=>r?.[e.id],()=>[G(n)]),M(i),H(()=>{Q(i,`for`,`${G(a)}-text`),Q(o,`id`,`${G(a)}-text`),Q(o,`type`,G(n).isSecret?`password`:`text`),Oi(o,t.answers[G(n).id])}),K(`input`,o,e=>t.onanswer(G(n).id,e.currentTarget.value)),J(e,i)},m=P(()=>i[G(n).id]||!!t.answers[G(n).id]&&!G(s));X(f,e=>{G(m)&&e(p)}),H(e=>{Q(u,`id`,G(a)),Q(u,`name`,`${t.requestId}-${G(n).id}`),ki(u,e),Q(d,`for`,G(a))},[()=>i[G(n).id]||!!t.answers[G(n).id]&&!G(s)]),K(`change`,u,()=>o(G(n).id)),K(`click`,u,()=>{i[G(n).id]&&o(G(n).id)}),J(e,c)};X(g,e=>{G(n).allowCustom&&e(_)}),M(m),M(c),H(()=>{Y(d,G(n).header),Y(p,G(n).question)}),J(e,c)}),M(c);var l=V(c,2);M(s),H(()=>{c.disabled=n(),l.disabled=n()||!G(a)}),Nr(`submit`,s,e=>{e.preventDefault(),G(a)&&t.onsubmit()}),J(e,s),$e()}Pr([`change`,`click`,`input`]);function $o(e,t=2){if(!os(e)||!Array.isArray(e.questions)||e.questions.length<1||e.questions.length>8)return null;let n=e.questions.map(e=>ns(e,t));if(n.some(e=>e===null))return null;let r=n;return new Set(r.map(e=>e.id)).size===r.length?{questions:r}:null}function es(e){return!os(e)||!Array.isArray(e.questions)||e.questions.length>3?null:$o({questions:e.questions.map(e=>os(e)?{id:e.id,header:e.header,question:e.question,choices:e.options,allowCustom:e.isOther===!0,isSecret:e.isSecret===!0}:e)},1)}function ts(e){return{contentItems:[{type:`inputText`,text:JSON.stringify({answers:Object.fromEntries(e.filter(e=>e.answer.trim()).map(e=>[e.id,e.answer]))})}],success:!0}}function ns(e,t){if(!os(e)||!Array.isArray(e.choices)||e.choices.length<t||e.choices.length>5||!is(e.id)||!as(e.header,120)||!as(e.question,600)||typeof e.allowCustom!=`boolean`)return null;let n=e.choices.map(rs);return n.some(e=>e===null)?null:{id:e.id,header:e.header,question:e.question,choices:n,allowCustom:e.allowCustom,isSecret:e.isSecret===!0}}function rs(e){return!os(e)||!as(e.label,160)||!as(e.description,600)?null:{label:e.label,description:e.description}}function is(e){return typeof e==`string`&&/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(e)}function as(e,t){return typeof e==`string`&&e.trim().length>0&&e.length<=t}function os(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ss=q(`<p class="interaction-result svelte-ajsqcq" data-interaction-state="resolved" tabindex="-1"> </p>`),cs=q(`<p class="interaction-submitting svelte-ajsqcq" data-interaction-state="submitting">Submitting…</p>`),ls=q(`<p>Codex sent an invalid quiz request.</p>`),us=q(`<p>Grant the requested permissions for this turn only.</p> <button type="button">Approve</button>`,1),ds=q(`<pre class="command-approval-command svelte-ajsqcq"><code> </code></pre>`),fs=q(`<p class="command-approval-missing svelte-ajsqcq">Command details were not provided.</p>`),ps=q(`<p>Approve this command?</p> <!> <div class="approval-actions svelte-ajsqcq"><button type="button">Approve</button> <button type="button">Deny</button></div>`,1),ms=q(`<li><code> </code></li>`),hs=q(`<ul class="file-change-approval-targets svelte-ajsqcq" aria-label="Files to change"></ul>`),gs=q(`<p class="file-change-approval-missing svelte-ajsqcq">File details were not provided.</p>`),_s=q(`<p>Approve changes to these files?</p> <!> <div class="approval-actions svelte-ajsqcq"><button type="button">Approve</button> <button type="button">Deny</button></div>`,1),vs=q(`<button type="button">Approve</button><button type="button">Deny</button>`,1),ys=q(`<p class="interaction-failed svelte-ajsqcq" data-interaction-state="failed">Could not send. Try again.</p> <button type="button">Retry</button>`,1),bs=q(`<!> <!> <!>`,1),xs=q(`<li class="svelte-ajsqcq"><span class="submitted-question svelte-ajsqcq"><strong> </strong> </span> <span class="submitted-answer svelte-ajsqcq"> </span></li>`),Ss=q(`<section class="submitted-answers svelte-ajsqcq" aria-label="Submitted answers" aria-live="polite"><p class="svelte-ajsqcq"><strong>Submitted answers</strong></p> <ol class="svelte-ajsqcq"></ol> <p class="submitted-note svelte-ajsqcq">Recorded in this chat view before delivery.</p></section>`),Cs=q(`<article><p class="interaction-kind svelte-ajsqcq"> </p> <!> <!></article>`);function ws(e,t){Qe(t,!0);let n=$(t,`submittedAnswers`,19,()=>({})),r=$(t,`onretry`,3,()=>{}),i=I(null),a=R({}),o=e=>Object.fromEntries(Object.entries(t.answers).filter(([t])=>t.startsWith(`${e}:`)).map(([t,n])=>[t.slice(e.length+1),n]));function s(e,t){L(i,e.requestId,!0),t()}Mn(()=>{let e=t.interactions.find(e=>e.requestId===G(i));e?.state===`resolved`&&(Cr().then(()=>a[e.requestId]?.focus()),L(i,null))});var c=Hr();Z(B(c),17,()=>t.interactions,e=>e.key??e.requestId,(e,i)=>{let c=P(()=>G(i).state===`submitting`);var l=Cs();let u;var d=z(l),f=z(d,!0);M(d);var p=V(d,2),m=e=>{var t=ss(),n=z(t,!0);M(t),Li(t,(e,t)=>a[t.requestId]=e,e=>a?.[e.requestId],()=>[G(i)]),H(()=>Y(n,G(i).attemptedOutcome===`denied`?`Denied`:G(i).attemptedOutcome===`dismissed`?`No longer awaiting a response`:G(i).attemptedOutcome===`answered`?`Answers sent`:`Approved`)),J(e,t)},h=e=>{var n=bs(),a=B(n),l=e=>{J(e,cs())};X(a,e=>{G(c)&&e(l)});var u=V(a,2),d=e=>{let n=P(()=>G(i).kind===`quiz`?$o(G(i).payload):es(G(i).payload));var r=Hr(),a=B(r),l=e=>{{let r=P(()=>o(G(i).requestId));Qo(e,{get requestId(){return G(i).requestId},get quiz(){return G(n)},get answers(){return G(r)},get disabled(){return G(c)},onanswer:(e,n)=>t.onanswer(G(i).requestId,e,n),onsubmit:()=>s(G(i),()=>t.onquiz(G(i)))})}},u=e=>{J(e,ls())};X(a,e=>{G(n)?e(l):e(u,-1)}),J(e,r)},f=e=>{var n=us(),r=V(B(n),2);H(()=>r.disabled=G(c)),K(`click`,r,()=>s(G(i),()=>t.onpermission(G(i)))),J(e,n)},p=e=>{let n=P(()=>Wo(G(i).payload));var r=ps(),a=V(B(r),2),o=e=>{var t=ds(),r=z(t),i=z(r,!0);M(r),M(t),H(()=>Y(i,G(n))),J(e,t)},l=e=>{J(e,fs())};X(a,e=>{G(n)?e(o):e(l,-1)});var u=V(a,2),d=z(u),f=V(d,2);M(u),H(()=>{d.disabled=G(c),f.disabled=G(c)}),K(`click`,d,()=>s(G(i),()=>t.ondecision(G(i).requestId,`accept`))),K(`click`,f,()=>s(G(i),()=>t.ondecision(G(i).requestId,`decline`))),J(e,r)},m=e=>{let n=P(()=>Go(G(i).payload));var r=_s(),a=V(B(r),2),o=e=>{var t=hs();Z(t,20,()=>G(n),e=>e,(e,t)=>{var n=ms(),r=z(n),i=z(r,!0);M(r),M(n),H(()=>Y(i,t)),J(e,n)}),M(t),J(e,t)},l=e=>{J(e,gs())};X(a,e=>{G(n)?e(o):e(l,-1)});var u=V(a,2),d=z(u),f=V(d,2);M(u),H(()=>{d.disabled=G(c),f.disabled=G(c)}),K(`click`,d,()=>s(G(i),()=>t.ondecision(G(i).requestId,`accept`))),K(`click`,f,()=>s(G(i),()=>t.ondecision(G(i).requestId,`decline`))),J(e,r)},h=e=>{var n=vs(),r=B(n),a=V(r);H(()=>{r.disabled=G(c),a.disabled=G(c)}),K(`click`,r,()=>s(G(i),()=>t.ondecision(G(i).requestId,`accept`))),K(`click`,a,()=>s(G(i),()=>t.ondecision(G(i).requestId,`decline`))),J(e,n)};X(u,e=>{G(i).kind===`userInput`||G(i).kind===`quiz`?e(d):G(i).kind===`permissionsApproval`?e(f,1):G(i).kind===`commandApproval`?e(p,2):G(i).kind===`fileChangeApproval`?e(m,3):e(h,-1)});var g=V(u,2),_=e=>{var t=ys();K(`click`,V(B(t),2),()=>r()(G(i))),J(e,t)};X(g,e=>{G(i).state===`failed`&&e(_)}),J(e,n)};X(p,e=>{G(i).state===`resolved`?e(m):e(h,-1)});var g=V(p,2),_=e=>{var t=Ss(),r=V(z(t),2);Z(r,21,()=>n()[G(i).requestId],e=>e.id,(e,t)=>{var n=xs(),r=z(n),i=z(r),a=z(i,!0);M(i);var o=V(i);M(r);var s=V(r,2),c=z(s,!0);M(s),M(n),H(()=>{Y(a,G(t).header),Y(o,` — ${G(t).question??``}`),Y(c,G(t).answer)}),J(e,n)}),M(r),Ue(2),M(t),J(e,t)};X(g,e=>{n()[G(i).requestId]?.length&&e(_)}),M(l),H(()=>{u=gi(l,1,`svelte-ajsqcq`,null,u,{resolved:G(i).state===`resolved`}),Y(f,G(i).kind)}),J(e,l)}),J(e,c),$e()}Pr([`click`]);function Ts(e){let t=[],n=[],r=()=>{n.length&&(t.push({id:n.at(-1).id,kind:`assistant`,commentary:n.map(e=>e.text).join(`
|
|
8
8
|
|
|
9
9
|
`),answer:null,...n.at(-1)?.turnId?{turnId:n.at(-1).turnId}:{},...n.at(-1)?.occurredAt===void 0?{}:{occurredAt:n.at(-1).occurredAt}}),n=[])};for(let i of e){if(i.role===`audit`){r(),t.push({id:i.id,kind:`audit`,text:i.text,...i.controlId?{controlId:i.controlId}:{},...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt},count:1,timestamps:i.occurredAt===void 0?[]:[i.occurredAt]});continue}if(i.role===`user`){r(),t.push({id:i.id,kind:`user`,text:i.text,...i.turnId?{turnId:i.turnId}:{},...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt}});continue}if(i.phase===`commentary`){n.push(i);continue}t.push({id:i.id,kind:`assistant`,commentary:n.length?n.map(e=>e.text).join(`
|
package/dist/client/index.html
CHANGED
|
@@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
16
16
|
<link rel="icon" href="/icons/gestalt-mobile-192.png" />
|
|
17
17
|
<link rel="apple-touch-icon" href="/icons/gestalt-mobile-180.png" />
|
|
18
18
|
<title>Gestalt Mobile</title>
|
|
19
|
-
<script type="module" crossorigin src="/assets/index-
|
|
19
|
+
<script type="module" crossorigin src="/assets/index-BTJImyK1.js"></script>
|
|
20
20
|
<link rel="stylesheet" crossorigin href="/assets/index-CPQBJDsg.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|
|
@@ -36,7 +36,7 @@ import { RelaySession, } from './features/sessions/model/relay-session.js';
|
|
|
36
36
|
import { AgentActivityRegistry } from './features/agent-activity/registry.js';
|
|
37
37
|
import { toAgentActivityDto } from './features/agent-activity/activity-dto.js';
|
|
38
38
|
import { decodeAgentActivityFacts } from './platform/codex/activity-facts.js';
|
|
39
|
-
import { isAgentCapacityRecoveryCall, isAutopilotWaitLeaseCall, resolvedServerRequestId, toPendingInteraction, } from './platform/codex/server-request.js';
|
|
39
|
+
import { completedCommandId, isAgentCapacityRecoveryCall, isAutopilotWaitLeaseCall, resolvedServerRequestId, toPendingInteraction, } from './platform/codex/server-request.js';
|
|
40
40
|
import { parseOrgPlanCheckpoint, toOrgPlanCheckpointToolResponse, } from '../shared/contracts/org-plan-checkpoint.js';
|
|
41
41
|
import { validOrgPlanCheckpoint } from './features/org-plan-checkpoint/application/validate.js';
|
|
42
42
|
import { isValidInteractionResponse, isValidQuizInteractionResponse, } from './features/sessions/interaction/response-validator.js';
|
|
@@ -437,6 +437,9 @@ export async function composeRelayApp(options) {
|
|
|
437
437
|
? { ...origin, kind: 'root' }
|
|
438
438
|
: origin;
|
|
439
439
|
const normalized = normalizeCodexNotification(sessionId, 0, occurredAt, notification, currentSession?.workspacePath, currentSession?.activeTurnId, resolvedOrigin);
|
|
440
|
+
const rootCommandId = resolvedOrigin.kind === 'root' ? completedCommandId(notification) : null;
|
|
441
|
+
if (rootCommandId)
|
|
442
|
+
autopilot.rootProcessCompleted(sessionId, rootCommandId);
|
|
440
443
|
if (!normalized) {
|
|
441
444
|
for (const activityFact of activityFacts)
|
|
442
445
|
activity.observe(activityFact);
|
|
@@ -483,12 +486,19 @@ export async function composeRelayApp(options) {
|
|
|
483
486
|
const lease = rawInteraction.payload;
|
|
484
487
|
const rootOwned = origin.kind === 'root' && origin.physicalTurnId === session.activeTurnId;
|
|
485
488
|
const accepted = rootOwned &&
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
489
|
+
(lease.version === 2
|
|
490
|
+
? autopilot.registerProactiveWait(sessionId, {
|
|
491
|
+
id: lease.reportId,
|
|
492
|
+
leaseId: lease.leaseId,
|
|
493
|
+
wakeConditions: lease.wakeConditions,
|
|
494
|
+
maxWaitMs: lease.maxWaitMs,
|
|
495
|
+
})
|
|
496
|
+
: autopilot.reportProbe(sessionId, {
|
|
497
|
+
id: lease.reportId,
|
|
498
|
+
kind: 'wait',
|
|
499
|
+
leaseId: lease.leaseId,
|
|
500
|
+
wakeConditions: lease.wakeConditions,
|
|
501
|
+
}));
|
|
492
502
|
if (!accepted) {
|
|
493
503
|
if (rootOwned)
|
|
494
504
|
autopilot.rejectProbe(sessionId);
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
-
export const AUTOPILOT_PROMPT_VERSION = '
|
|
7
|
-
export const AUTOPILOT_CONTINUATION_PROMPT = 'Inspect the active supervised Org Plan. Refer to every L1 as L<a> and each nested L2 as L<a>.<b>, using one-based positions. For a subagent dedicated to that position, use the collaboration-safe task_name l<a> or l<a>_<b> and refer to it by its canonical L label. If the active L1 is still WIP and its executor stopped or is idle after a partial report or L2 checkpoint, call followup_task on that same executor before sending any response. Treat a status question as an interruption: answer briefly, then perform that continuation in the same turn. Before sending any blocker response or yielding because progress cannot continue safely, call gestalt_org_plan_attention for the matching decision-table blocker; never rely on blocker prose as the signal. Do not call it for routine progress or a recoverable failure. When the Autopilot probe is active, register
|
|
6
|
+
export const AUTOPILOT_PROMPT_VERSION = 'v8';
|
|
7
|
+
export const AUTOPILOT_CONTINUATION_PROMPT = 'Inspect the active supervised Org Plan. Refer to every L1 as L<a> and each nested L2 as L<a>.<b>, using one-based positions. For a subagent dedicated to that position, use the collaboration-safe task_name l<a> or l<a>_<b> and refer to it by its canonical L label. If the active L1 is still WIP and its executor stopped or is idle after a partial report or L2 checkpoint, call followup_task on that same executor before sending any response. Treat a status question as an interruption: answer briefly, then perform that continuation in the same turn. Before sending any blocker response or yielding because progress cannot continue safely, call gestalt_org_plan_attention for the matching decision-table blocker; never rely on blocker prose as the signal. Do not call it for routine progress or a recoverable failure. Before yielding for known long work, call gestalt_autopilot_wait_lease version 2 with relevant observable wake conditions and a bounded maxWaitMs; it is one episode, so reassess before registering another in a later turn. For GitHub PR CI, start an owned gh pr checks --watch process and lease processExited plus processResultAvailable while it runs. When the Autopilot probe is active, register the compatible wait lease, declare genuine attention, or immediately do actionable work; never acknowledge waiting in prose. Do not send a status-only response.';
|
|
8
8
|
export const AUTOPILOT_EXECUTOR_CONTINUATION_PROMPT = 'Continue the same assigned Org L1 from its durable state. A prior turn ending did not complete the objective. Consume any supplied process result, take the next legal L2 action, and report only at the L1 review boundary or through structured attention.';
|
|
9
9
|
/** Builds a physical launch instruction while keeping durable L1 identity canonical. */
|
|
10
10
|
export function autopilotExecutorLaunchPrompt(identity) {
|
|
@@ -5,15 +5,17 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { deriveSessionStatus } from '../../sessions/session-status.js';
|
|
7
7
|
import { createHash } from 'node:crypto';
|
|
8
|
+
import { AUTOPILOT_WAIT_MAX_MS, AUTOPILOT_WAIT_MIN_MS, } from '../../../../shared/contracts/autopilot-wait-lease.js';
|
|
8
9
|
import { autopilotSnapshot, disabledAutopilot, } from '../domain/autopilot-session.js';
|
|
9
10
|
import { classifyExecutorOutcome, decideSupervisedLifecycle, executorIdentity, validStructuredBlock, } from '../domain/supervised-lifecycle.js';
|
|
10
11
|
import { classifyAgentActivity, decideAutopilot, executionComplete, } from './policy.js';
|
|
11
|
-
import { consumeObservableWake, recordAutomaticContinuation, recoverSafetyPause, reportProbe, semanticProgressKey, startSupervisionProtocol, } from '../domain/supervision-protocol.js';
|
|
12
|
+
import { consumeObservableWake, consumeWaitDeadline, recordAutomaticContinuation, recoverSafetyPause, registerProactiveWait as registerProtocolWait, reportProbe, semanticProgressKey, startSupervisionProtocol, } from '../domain/supervision-protocol.js';
|
|
12
13
|
export class AutopilotCoordinator {
|
|
13
14
|
deps;
|
|
14
15
|
timers = new Map();
|
|
15
16
|
completionTimers = new Map();
|
|
16
17
|
executorTimers = new Map();
|
|
18
|
+
waitTimers = new Map();
|
|
17
19
|
publishedSnapshots = new Map();
|
|
18
20
|
planEventKeys = new Map();
|
|
19
21
|
activityEventKeys = new Map();
|
|
@@ -75,6 +77,8 @@ export class AutopilotCoordinator {
|
|
|
75
77
|
});
|
|
76
78
|
if (state.supervision.waitLease && validated.health.wait.wakeCategories.length > 0) {
|
|
77
79
|
this.parkedSubscriptions.set(sessionId, state.supervision.waitLease.id);
|
|
80
|
+
if (state.supervision.waitLease.resumeAt)
|
|
81
|
+
this.armWaitDeadline(sessionId, state.supervision.waitLease.id, state.supervision.waitLease.resumeAt);
|
|
78
82
|
return;
|
|
79
83
|
}
|
|
80
84
|
this.parkedSubscriptions.delete(sessionId);
|
|
@@ -113,6 +117,7 @@ export class AutopilotCoordinator {
|
|
|
113
117
|
}
|
|
114
118
|
dispose(sessionId) {
|
|
115
119
|
this.cancelTimer(sessionId);
|
|
120
|
+
this.cancelWaitTimer(sessionId);
|
|
116
121
|
this.planEventKeys.delete(sessionId);
|
|
117
122
|
this.activityEventKeys.delete(sessionId);
|
|
118
123
|
this.reconciling.delete(sessionId);
|
|
@@ -123,8 +128,9 @@ export class AutopilotCoordinator {
|
|
|
123
128
|
const state = this.deps.store.find(sessionId);
|
|
124
129
|
if (!state?.requestedEnabled)
|
|
125
130
|
return false;
|
|
126
|
-
const
|
|
127
|
-
|
|
131
|
+
const protocol = state.supervision ?? startSupervisionProtocol(this.progressKey(sessionId));
|
|
132
|
+
const nextProtocol = reportProbe(protocol, report);
|
|
133
|
+
if (nextProtocol === protocol)
|
|
128
134
|
return false;
|
|
129
135
|
if (nextProtocol.outcome === 'parked' && nextProtocol.waitLease)
|
|
130
136
|
this.parkedSubscriptions.set(sessionId, nextProtocol.waitLease.id);
|
|
@@ -147,6 +153,38 @@ export class AutopilotCoordinator {
|
|
|
147
153
|
this.cancelTimer(sessionId);
|
|
148
154
|
return true;
|
|
149
155
|
}
|
|
156
|
+
/** Parks one explicitly requested long wait without changing future pulse policy. */
|
|
157
|
+
registerProactiveWait(sessionId, report) {
|
|
158
|
+
const state = this.deps.store.find(sessionId);
|
|
159
|
+
if (!state?.requestedEnabled ||
|
|
160
|
+
!Number.isSafeInteger(report.maxWaitMs) ||
|
|
161
|
+
report.maxWaitMs < AUTOPILOT_WAIT_MIN_MS ||
|
|
162
|
+
report.maxWaitMs > AUTOPILOT_WAIT_MAX_MS)
|
|
163
|
+
return false;
|
|
164
|
+
const now = this.deps.now();
|
|
165
|
+
const resumeAt = new Date(Date.parse(now) + report.maxWaitMs).toISOString();
|
|
166
|
+
const protocol = state.supervision ?? startSupervisionProtocol(this.progressKey(sessionId));
|
|
167
|
+
const nextProtocol = registerProtocolWait(protocol, { ...report, resumeAt });
|
|
168
|
+
if (nextProtocol === protocol)
|
|
169
|
+
return false;
|
|
170
|
+
const cancelled = this.cancelScheduledControl(state, now);
|
|
171
|
+
this.timers.get(sessionId)?.();
|
|
172
|
+
this.timers.delete(sessionId);
|
|
173
|
+
this.completionTimers.get(sessionId)?.();
|
|
174
|
+
this.completionTimers.delete(sessionId);
|
|
175
|
+
this.parkedSubscriptions.set(sessionId, report.leaseId);
|
|
176
|
+
this.persist({
|
|
177
|
+
...state,
|
|
178
|
+
state: 'monitoring',
|
|
179
|
+
generation: state.generation + (cancelled ? 1 : 0),
|
|
180
|
+
nextEvaluationAt: null,
|
|
181
|
+
...(cancelled ? { lastControlId: null } : {}),
|
|
182
|
+
supervision: nextProtocol,
|
|
183
|
+
updatedAt: now,
|
|
184
|
+
}, cancelled);
|
|
185
|
+
this.armWaitDeadline(sessionId, report.leaseId, resumeAt);
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
150
188
|
/** Fails closed only for the currently active bounded probe. */
|
|
151
189
|
rejectProbe(sessionId) {
|
|
152
190
|
const state = this.deps.store.find(sessionId);
|
|
@@ -187,6 +225,7 @@ export class AutopilotCoordinator {
|
|
|
187
225
|
const nextProtocol = consumeObservableWake(state.supervision, wake);
|
|
188
226
|
if (nextProtocol === state.supervision)
|
|
189
227
|
return false;
|
|
228
|
+
this.cancelWaitTimer(sessionId);
|
|
190
229
|
this.parkedSubscriptions.delete(sessionId);
|
|
191
230
|
this.persist({ ...state, supervision: nextProtocol, updatedAt: this.deps.now() });
|
|
192
231
|
this.evaluate(sessionId);
|
|
@@ -203,6 +242,23 @@ export class AutopilotCoordinator {
|
|
|
203
242
|
progressKey: this.progressKey(sessionId),
|
|
204
243
|
});
|
|
205
244
|
}
|
|
245
|
+
/** Bridges a completed root-owned background command into its one active wait episode. */
|
|
246
|
+
rootProcessCompleted(sessionId, processId) {
|
|
247
|
+
const lease = this.deps.store.find(sessionId)?.supervision?.waitLease;
|
|
248
|
+
if (!lease || !processId || processId.length > 256)
|
|
249
|
+
return false;
|
|
250
|
+
const condition = lease.wakeConditions.includes('processResultAvailable')
|
|
251
|
+
? 'processResultAvailable'
|
|
252
|
+
: lease.wakeConditions.includes('processExited')
|
|
253
|
+
? 'processExited'
|
|
254
|
+
: null;
|
|
255
|
+
if (!condition)
|
|
256
|
+
return false;
|
|
257
|
+
const progressKey = createHash('sha256')
|
|
258
|
+
.update(`${this.progressKey(sessionId)}\0root-process\0${processId}`)
|
|
259
|
+
.digest('hex');
|
|
260
|
+
return this.observableWake(sessionId, { leaseId: lease.id, condition, progressKey });
|
|
261
|
+
}
|
|
206
262
|
enable(sessionId) {
|
|
207
263
|
const session = this.deps.session(sessionId);
|
|
208
264
|
if (!session || !session.threadId || !['ready', 'turnActive'].includes(session.state))
|
|
@@ -216,6 +272,8 @@ export class AutopilotCoordinator {
|
|
|
216
272
|
const prior = this.deps.store.find(sessionId) ?? disabledAutopilot(sessionId, now);
|
|
217
273
|
const nextFingerprint = fingerprint(currentPlan.plan);
|
|
218
274
|
const replacing = Boolean(prior.planIdentity && prior.planIdentity !== currentPlan.identity);
|
|
275
|
+
if (replacing)
|
|
276
|
+
this.cancelWaitTimer(sessionId);
|
|
219
277
|
if (prior.requestedEnabled &&
|
|
220
278
|
prior.planIdentity === currentPlan.identity &&
|
|
221
279
|
prior.state !== 'attentionRequired')
|
|
@@ -273,6 +331,7 @@ export class AutopilotCoordinator {
|
|
|
273
331
|
};
|
|
274
332
|
this.persist(next, cancelled);
|
|
275
333
|
this.cancelTimer(sessionId);
|
|
334
|
+
this.cancelWaitTimer(sessionId);
|
|
276
335
|
return this.snapshot(sessionId);
|
|
277
336
|
}
|
|
278
337
|
cancel(sessionId, reason) {
|
|
@@ -293,6 +352,7 @@ export class AutopilotCoordinator {
|
|
|
293
352
|
updatedAt: now,
|
|
294
353
|
}, cancelled);
|
|
295
354
|
this.cancelTimer(sessionId);
|
|
355
|
+
this.cancelWaitTimer(sessionId);
|
|
296
356
|
}
|
|
297
357
|
evaluate(sessionId) {
|
|
298
358
|
const prior = this.deps.store.find(sessionId);
|
|
@@ -607,8 +667,10 @@ export class AutopilotCoordinator {
|
|
|
607
667
|
return this.snapshot(sessionId);
|
|
608
668
|
const replacing = Boolean(prior.planIdentity && prior.planIdentity !== currentPlan.identity);
|
|
609
669
|
const cancelled = replacing ? this.cancelScheduledControl(prior, now) : undefined;
|
|
610
|
-
if (replacing)
|
|
670
|
+
if (replacing) {
|
|
611
671
|
this.cancelTimer(sessionId);
|
|
672
|
+
this.cancelWaitTimer(sessionId);
|
|
673
|
+
}
|
|
612
674
|
const next = {
|
|
613
675
|
...prior,
|
|
614
676
|
state: 'monitoring',
|
|
@@ -894,6 +956,27 @@ export class AutopilotCoordinator {
|
|
|
894
956
|
this.executorTimers.get(sessionId)?.();
|
|
895
957
|
this.executorTimers.delete(sessionId);
|
|
896
958
|
}
|
|
959
|
+
cancelWaitTimer(sessionId) {
|
|
960
|
+
this.waitTimers.get(sessionId)?.();
|
|
961
|
+
this.waitTimers.delete(sessionId);
|
|
962
|
+
}
|
|
963
|
+
armWaitDeadline(sessionId, leaseId, resumeAt) {
|
|
964
|
+
this.cancelWaitTimer(sessionId);
|
|
965
|
+
this.waitTimers.set(sessionId, this.deps.schedule(() => {
|
|
966
|
+
this.waitTimers.delete(sessionId);
|
|
967
|
+
const state = this.deps.store.find(sessionId);
|
|
968
|
+
if (!state?.requestedEnabled || !state.supervision)
|
|
969
|
+
return;
|
|
970
|
+
const protocol = consumeWaitDeadline(state.supervision, leaseId, this.deps.now());
|
|
971
|
+
if (protocol === state.supervision) {
|
|
972
|
+
this.armWaitDeadline(sessionId, leaseId, resumeAt);
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
this.parkedSubscriptions.delete(sessionId);
|
|
976
|
+
this.persist({ ...state, supervision: protocol, updatedAt: this.deps.now() });
|
|
977
|
+
this.evaluate(sessionId);
|
|
978
|
+
}, Math.max(0, Date.parse(resumeAt) - Date.parse(this.deps.now()))));
|
|
979
|
+
}
|
|
897
980
|
async enforceSupervisedLifecycle(sessionId, event) {
|
|
898
981
|
const controller = this.deps.executorController;
|
|
899
982
|
const retained = this.deps.plan(sessionId);
|
|
@@ -95,6 +95,9 @@ export function autopilotSnapshot(state, retryLimit, facts = {
|
|
|
95
95
|
wait: {
|
|
96
96
|
present: Boolean(state.supervision?.waitLease),
|
|
97
97
|
wakeCategories: [...waitCategories].slice(0, 9),
|
|
98
|
+
...(state.supervision?.waitLease?.resumeAt
|
|
99
|
+
? { resumeAt: state.supervision.waitLease.resumeAt }
|
|
100
|
+
: {}),
|
|
98
101
|
},
|
|
99
102
|
observedAt: facts.observedAt,
|
|
100
103
|
lastTransitionAt: state.updatedAt,
|
|
@@ -85,6 +85,29 @@ export function recordAutomaticContinuation(state, progressKey) {
|
|
|
85
85
|
return { ...state, unchangedContinuations, outcome: 'probeRequired', probeKey: progressKey };
|
|
86
86
|
return { ...state, unchangedContinuations };
|
|
87
87
|
}
|
|
88
|
+
/** Registers one explicit long-wait episode without changing future pulse policy. */
|
|
89
|
+
export function registerProactiveWait(state, report) {
|
|
90
|
+
if (state.lastReportId === report.id ||
|
|
91
|
+
state.outcome === 'parked' ||
|
|
92
|
+
state.outcome === 'attentionRequired' ||
|
|
93
|
+
state.outcome === 'safetyPaused' ||
|
|
94
|
+
!Number.isFinite(Date.parse(report.resumeAt)))
|
|
95
|
+
return state;
|
|
96
|
+
const wakeConditions = uniqueSupportedWakeConditions(report.wakeConditions);
|
|
97
|
+
if (!report.leaseId || wakeConditions.length === 0)
|
|
98
|
+
return state;
|
|
99
|
+
return {
|
|
100
|
+
...state,
|
|
101
|
+
outcome: 'parked',
|
|
102
|
+
lastReportId: report.id,
|
|
103
|
+
waitLease: {
|
|
104
|
+
id: report.leaseId,
|
|
105
|
+
probeKey: state.progressKey,
|
|
106
|
+
wakeConditions,
|
|
107
|
+
resumeAt: report.resumeAt,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
88
111
|
/** Accepts only structured, bounded probe reports. Unsupported waits fail closed. */
|
|
89
112
|
export function reportProbe(state, report) {
|
|
90
113
|
if (state.lastReportId === report.id)
|
|
@@ -117,6 +140,11 @@ export function consumeObservableWake(state, wake) {
|
|
|
117
140
|
!lease.wakeConditions.includes(wake.condition) ||
|
|
118
141
|
wake.progressKey === lease.probeKey)
|
|
119
142
|
return state;
|
|
143
|
+
if (lease.resumeAt)
|
|
144
|
+
return {
|
|
145
|
+
...startSupervisionProtocol(wake.progressKey),
|
|
146
|
+
lastReportId: state.lastReportId,
|
|
147
|
+
};
|
|
120
148
|
return {
|
|
121
149
|
...state,
|
|
122
150
|
outcome: 'retrying',
|
|
@@ -127,6 +155,20 @@ export function consumeObservableWake(state, wake) {
|
|
|
127
155
|
retryKey: wake.progressKey,
|
|
128
156
|
};
|
|
129
157
|
}
|
|
158
|
+
/** A proactive deadline consumes only its matching episode and restores normal policy. */
|
|
159
|
+
export function consumeWaitDeadline(state, leaseId, observedAt) {
|
|
160
|
+
const lease = state.waitLease;
|
|
161
|
+
if (state.outcome !== 'parked' ||
|
|
162
|
+
!lease?.resumeAt ||
|
|
163
|
+
lease.id !== leaseId ||
|
|
164
|
+
!Number.isFinite(Date.parse(observedAt)) ||
|
|
165
|
+
Date.parse(observedAt) < Date.parse(lease.resumeAt))
|
|
166
|
+
return state;
|
|
167
|
+
return {
|
|
168
|
+
...startSupervisionProtocol(state.progressKey),
|
|
169
|
+
lastReportId: state.lastReportId,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
130
172
|
/** Manual recovery is the only transition out of durable safety pause. */
|
|
131
173
|
export function recoverSafetyPause(state, progressKey) {
|
|
132
174
|
return state.outcome === 'safetyPaused' ? startSupervisionProtocol(progressKey) : state;
|
|
@@ -197,7 +239,16 @@ function parseWaitLease(value) {
|
|
|
197
239
|
!Array.isArray(candidate.wakeConditions))
|
|
198
240
|
return undefined;
|
|
199
241
|
const wakeConditions = uniqueSupportedWakeConditions(candidate.wakeConditions);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
242
|
+
if (wakeConditions.length !== candidate.wakeConditions.length)
|
|
243
|
+
return undefined;
|
|
244
|
+
const resumeAt = candidate.resumeAt;
|
|
245
|
+
if (resumeAt !== undefined &&
|
|
246
|
+
(typeof resumeAt !== 'string' || !Number.isFinite(Date.parse(resumeAt))))
|
|
247
|
+
return undefined;
|
|
248
|
+
return {
|
|
249
|
+
id: candidate.id,
|
|
250
|
+
probeKey: candidate.probeKey,
|
|
251
|
+
wakeConditions,
|
|
252
|
+
...(typeof resumeAt === 'string' ? { resumeAt } : {}),
|
|
253
|
+
};
|
|
203
254
|
}
|
|
@@ -53,6 +53,17 @@ export function resolvedServerRequestId(input) {
|
|
|
53
53
|
return null;
|
|
54
54
|
return String(requestId);
|
|
55
55
|
}
|
|
56
|
+
/** Returns only the bounded identity of a completed command item. Ownership is checked by caller. */
|
|
57
|
+
export function completedCommandId(input) {
|
|
58
|
+
if (input.method !== 'item/completed' || !isRecord(input.params))
|
|
59
|
+
return null;
|
|
60
|
+
const item = input.params.item;
|
|
61
|
+
if (!isRecord(item) || item.type !== 'commandExecution')
|
|
62
|
+
return null;
|
|
63
|
+
return typeof item.id === 'string' && item.id.length > 0 && item.id.length <= 256
|
|
64
|
+
? item.id
|
|
65
|
+
: null;
|
|
66
|
+
}
|
|
56
67
|
export function isAutopilotWaitLeaseCall(input) {
|
|
57
68
|
return (Number.isSafeInteger(input.id) &&
|
|
58
69
|
input.method === 'item/tool/call' &&
|
|
@@ -15,16 +15,18 @@ export const autopilotWaitWakeConditions = [
|
|
|
15
15
|
'processLimitBreached',
|
|
16
16
|
'agentActivityChanged',
|
|
17
17
|
];
|
|
18
|
+
export const AUTOPILOT_WAIT_MIN_MS = 60_000;
|
|
19
|
+
export const AUTOPILOT_WAIT_MAX_MS = 86_400_000;
|
|
18
20
|
export const gestaltAutopilotWaitLeaseDynamicTool = {
|
|
19
21
|
type: 'function',
|
|
20
22
|
name: GESTALT_AUTOPILOT_WAIT_LEASE_TOOL_NAME,
|
|
21
|
-
description: 'Register
|
|
23
|
+
description: 'Register one non-persistent Autopilot wait episode for the current supervised session. Version 2 may be called proactively for known long work and resumes on the first requested event or bounded maxWaitMs deadline; call it again in a later turn only if another long wait is justified. This cannot request human authority and never accepts transcript prose.',
|
|
22
24
|
inputSchema: {
|
|
23
25
|
type: 'object',
|
|
24
26
|
additionalProperties: false,
|
|
25
27
|
required: ['version', 'reportId', 'leaseId', 'wakeConditions'],
|
|
26
28
|
properties: {
|
|
27
|
-
version: {
|
|
29
|
+
version: { type: 'integer', enum: [1, 2] },
|
|
28
30
|
reportId: { type: 'string', minLength: 1, maxLength: 128 },
|
|
29
31
|
leaseId: { type: 'string', minLength: 1, maxLength: 128 },
|
|
30
32
|
wakeConditions: {
|
|
@@ -34,11 +36,20 @@ export const gestaltAutopilotWaitLeaseDynamicTool = {
|
|
|
34
36
|
uniqueItems: true,
|
|
35
37
|
items: { type: 'string', enum: autopilotWaitWakeConditions },
|
|
36
38
|
},
|
|
39
|
+
maxWaitMs: {
|
|
40
|
+
type: 'integer',
|
|
41
|
+
minimum: AUTOPILOT_WAIT_MIN_MS,
|
|
42
|
+
maximum: AUTOPILOT_WAIT_MAX_MS,
|
|
43
|
+
description: 'Version 2 safety deadline in milliseconds. An observable wake resumes earlier.',
|
|
44
|
+
},
|
|
37
45
|
},
|
|
38
46
|
},
|
|
39
47
|
};
|
|
40
48
|
export function parseAutopilotWaitLease(value) {
|
|
41
|
-
if (!record(value) ||
|
|
49
|
+
if (!record(value) || (value.version !== 1 && value.version !== 2))
|
|
50
|
+
return null;
|
|
51
|
+
const expectedKeys = value.version === 1 ? 4 : 5;
|
|
52
|
+
if (Object.keys(value).length !== expectedKeys)
|
|
42
53
|
return null;
|
|
43
54
|
if (!bounded(value.reportId) || !bounded(value.leaseId) || !Array.isArray(value.wakeConditions))
|
|
44
55
|
return null;
|
|
@@ -49,7 +60,19 @@ export function parseAutopilotWaitLease(value) {
|
|
|
49
60
|
!wakeConditions.every((condition) => typeof condition === 'string' &&
|
|
50
61
|
autopilotWaitWakeConditions.includes(condition)))
|
|
51
62
|
return null;
|
|
52
|
-
|
|
63
|
+
if (value.version === 1)
|
|
64
|
+
return { version: 1, reportId: value.reportId, leaseId: value.leaseId, wakeConditions };
|
|
65
|
+
if (!Number.isSafeInteger(value.maxWaitMs) ||
|
|
66
|
+
value.maxWaitMs < AUTOPILOT_WAIT_MIN_MS ||
|
|
67
|
+
value.maxWaitMs > AUTOPILOT_WAIT_MAX_MS)
|
|
68
|
+
return null;
|
|
69
|
+
return {
|
|
70
|
+
version: 2,
|
|
71
|
+
reportId: value.reportId,
|
|
72
|
+
leaseId: value.leaseId,
|
|
73
|
+
wakeConditions,
|
|
74
|
+
maxWaitMs: value.maxWaitMs,
|
|
75
|
+
};
|
|
53
76
|
}
|
|
54
77
|
export function autopilotWaitLeaseToolResponse() {
|
|
55
78
|
return { success: true, contentItems: [{ type: 'inputText', text: '{"accepted":true}' }] };
|