gestalt-mobile 0.49.8 → 0.50.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/README.md CHANGED
@@ -545,6 +545,15 @@ across three jobs instead of nine. These are measured runner durations, not a
545
545
  guarantee about elapsed time or GitHub's runner allocation queue. The full Vitest
546
546
  job took 77 seconds and remains in the default gate.
547
547
 
548
+ The Vitest CI job also checks out the compatible Agents helper at the immutable
549
+ revision recorded in `scripts/test-org-plan-integration.mjs` and runs
550
+ `npm run test:org-plan-integration -- <agents-checkout>`. To repeat locally, use a
551
+ separate `dyne/gestalt-agents` checkout at that exact revision and pass its path.
552
+ The command rejects a missing helper or mismatched revision and proves the
553
+ accepted dependency → one root continuation → same-owner resume using the real
554
+ helper on a disposable plan. Ordinary unit tests require no network or Agents
555
+ checkout; their coordinator case supplies equivalent projection data.
556
+
548
557
  Local aggregate commands remain unchanged: `npm test` runs every Vitest test and
549
558
  `npm run test:e2e` runs every browser test except the isolated real-auth journey.
550
559
 
@@ -22,7 +22,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
22
22
  destinations.</p></div> <!> <button id="browse-files" type="button" class="svelte-pudr3t">Browse files</button></section> <form class="clone-form svelte-pudr3t"><div class="clone-controls svelte-pudr3t"><div class="clone-field svelte-pudr3t"><label for="git-clone-address" class="svelte-pudr3t">Git address</label> <input id="git-clone-address" name="address" autocomplete="url" inputmode="url" enterkeyhint="done" aria-describedby="clone-help"/></div> <button type="submit" class="svelte-pudr3t"> </button></div> <p id="clone-help" class="svelte-pudr3t"> </p> <!></form> <section class="repository-details svelte-pudr3t" aria-labelledby="repository-details-title"><h3 id="repository-details-title" class="svelte-pudr3t">Repository details</h3> <!> <!></section></section>`);function Bd(e,t){$e(t,!0);let n=$(t,`pushing`,3,!1),r=z(``),i=L(()=>t.selectedWorkspace&&!t.selectedWorkspace.isGitRepository?t.selectedWorkspace:null),a=L(()=>!!t.selectedWorkspace?.isGitRepository),o=L(()=>G(a)?t.summary?.originUrl??``:G(r)),s=L(()=>t.summary?Cd(t.summary):{enabled:!1,reason:null});function c(e){e.preventDefault(),!(!G(i)||!G(r).trim()||t.cloning)&&t.onclone(G(r).trim())}var l=zd(),u=U(V(l),2),d=U(V(u),2);{let e=L(()=>t.selectedWorkspace?.id??null);bd(d,{get roots(){return t.workspaceTree},get expandedIds(){return t.expandedIds},get selectedId(){return G(e)},label:`Git repository and clone destination`,get onexpandedchange(){return t.onexpandedchange},get onselect(){return t.onselect}})}var f=U(d,2);P(u);var p=U(u,2),m=V(p),h=V(m),g=U(V(h),2);Ni(g),P(h);var _=U(h,2),v=V(_,!0);P(_),P(m);var y=U(m,2),b=V(y,!0);P(y);var x=U(y,2),S=e=>{var n=Ed(),r=V(n,!0);P(n),W(()=>Y(r,t.cloneStatus)),J(e,n)};X(x,e=>{t.cloneStatus&&e(S)}),P(p);var C=U(p,2),w=U(V(C),2),T=e=>{var r=Kr(),i=H(r),a=e=>{var r=Kr(),i=H(r),a=e=>{var r=Nd(),i=H(r),a=V(i),o=U(V(a),2);Z(o,20,()=>t.summary.branches??[],e=>e,(e,t)=>{var n=Dd(),r=V(n,!0);P(n);var i={};W(()=>{Y(r,t),i!==(i=t)&&(n.value=(n.__value=t)??``)}),J(e,n)}),P(o);var c;Ei(o);var l=U(o,2),u=V(l);P(l);var d=U(l,2),f=e=>{var n=Od(),r=V(n);P(n),W(()=>Y(r,`Ahead ${t.summary.ahead??``}; behind ${t.summary.behind??``}.`)),J(e,n)};X(d,e=>{t.summary.upstream&&e(f)});var p=U(d,2),m=V(p),h=V(m,!0);P(m),P(p);var g=U(p,2),_=V(g);P(g),P(a);var v=U(a,2),y=V(v),b=U(y,2),x=U(V(b));P(b);var S=U(b,2),C=e=>{var t=kd(),n=V(t,!0);P(t),W(()=>Y(n,G(s).reason)),J(e,t)};X(S,e=>{!G(s).enabled&&G(s).reason&&e(C)}),P(v),P(i);var w=U(i,2),T=e=>{var r=Ad(),i=V(r),a=V(i,!0);P(i);var o=U(i,2),s=V(o,!0);P(o);var c=U(o,2);P(r),W(()=>{Y(a,t.summary.upstream?`Push ${t.summary.branch??`HEAD`} to ${t.summary.upstream}?`:`Publish ${t.summary.branch} to origin and set its upstream?`),o.disabled=n(),Y(s,n()?`Pushing…`:`Confirm push`),c.disabled=n()}),K(`click`,o,function(...e){t.onpush?.apply(this,e)}),K(`click`,c,function(...e){t.oncancelpush?.apply(this,e)}),J(e,r)};X(w,e=>{t.confirmingPush&&e(T)});var E=U(w,2),D=e=>{var n=Md(),r=U(V(n),2);Z(r,21,()=>t.summary.commits,e=>e.hash,(e,t)=>{var n=jd(),r=V(n),i=V(r),a=V(i,!0);P(i);var o=U(i),s=V(o,!0);P(o),P(r);var c=U(r,2),l=V(c),u=V(l,!0);P(l);var d=U(l),f=V(d,!0);P(d),P(c),P(n),W(e=>{Q(i,`title`,G(t).hash),Y(a,G(t).shortHash),Y(s,G(t).subject),Y(u,G(t).author),Q(d,`datetime`,G(t).authoredAt),Q(d,`title`,G(t).authoredAt),Y(f,e)},[()=>Td(G(t).authoredAt)]),J(e,n)}),P(r),P(n),J(e,n)};X(E,e=>{t.summary.commits.length&&e(D)}),W(e=>{o.disabled=t.refreshing||t.checkingOut||!t.summary.branches?.length,c!==(c=t.summary.branch??``)&&(o.value=(o.__value=t.summary.branch??``)??``,Ti(o,t.summary.branch??``)),Y(u,`Upstream: ${t.summary.upstream??`not configured`??``}`),Q(m,`datetime`,t.summary.fetchedAt??void 0),Y(h,e),Y(_,`Changes: ${t.summary.dirty.staged??``} staged, ${t.summary.dirty.unstaged??``} unstaged, ${t.summary.dirty.untracked??``} untracked.`),y.disabled=t.refreshing||t.checkingOut||n()||!G(s).enabled,Q(y,`aria-describedby`,G(s).enabled?void 0:`git-push-help`),b.disabled=t.refreshing||t.checkingOut||n()||!t.summary.upstream,Y(x,` ${t.refreshing?`Pulling…`:`Pull`}`)},[()=>wd(t.summary.fetchedAt)]),K(`change`,o,e=>t.oncheckout(e.currentTarget.value)),K(`click`,y,function(...e){t.onopenpushconfirmation?.apply(this,e)}),K(`click`,b,function(...e){t.onpull?.apply(this,e)}),J(e,r)},o=e=>{J(e,Pd())};X(i,e=>{t.summary.available?e(a):e(o,-1)}),J(e,r)},o=e=>{J(e,Fd())};X(i,e=>{t.summary?e(a):t.error||e(o,1)}),J(e,r)},E=e=>{var n=Id(),r=H(n),i=V(r),a=V(i,!0);P(i),Ue(),P(r),Ue(2),W(()=>Y(a,t.selectedWorkspace.name)),J(e,n)},D=e=>{var t=Ld();Ue(2),J(e,t)};X(w,e=>{t.selectedWorkspace?.isGitRepository?e(T):t.selectedWorkspace?e(E,1):e(D,-1)});var ee=U(w,2),te=e=>{var n=Rd(),r=V(n,!0);P(n),W(()=>Y(r,t.error)),J(e,n)};X(ee,e=>{t.error&&e(te)}),P(C),P(l),W(e=>{f.disabled=!t.selectedWorkspace,Pi(g,G(o)),g.readOnly=G(a),g.required=!G(a),Q(g,`placeholder`,G(a)?`No origin remote`:`https://example.com/owner/repository.git`),_.disabled=e,Y(v,t.cloning?`Cloning…`:`Clone`),Y(b,G(a)?t.summary?.originUrl?`Origin remote. Select a folder to clone another repository.`:`No origin remote is configured for this repository.`:t.selectedWorkspace?`Clone into ${t.selectedWorkspace.name}.`:`Select a folder to clone a repository.`)},[()=>t.cloning||!G(i)||!G(r).trim()]),K(`click`,f,e=>t.onbrowsefiles(e.currentTarget)),Lr(`submit`,p,c),K(`input`,g,e=>B(r,e.currentTarget.value,!0)),J(e,l),et()}Rr([`click`,`input`,`change`]);var Vd=class{transport;isRepository;onChange;errorMessage;#e={workspaceId:null,summary:null,loading:!1,refreshing:!1,checkingOut:!1,error:null};#t=0;#n=null;#r=!1;constructor(e,t,n,r){this.transport=e,this.isRepository=t,this.onChange=n,this.errorMessage=r}get state(){return this.#e}select(e){this.#a();let t=e,n=!!(t&&this.isRepository(t));this.#s({workspaceId:t,summary:null,loading:n,refreshing:!1,checkingOut:!1,error:null}),n&&this.refresh()}async refresh(){let e=this.#e.workspaceId;if(!e||!this.isRepository(e))return;let t=this.#i(),n=this.#t;this.#s({...this.#e,loading:!0,error:null});try{let r=await this.transport.getSummary(e,t.signal);this.#o(n,e,t)&&this.#s({...this.#e,summary:r,loading:!1})}catch(r){this.#o(n,e,t)&&!t.signal.aborted&&this.#s({...this.#e,summary:null,loading:!1,error:this.errorMessage(r,`GIT_SUMMARY_FAILED`)})}}async pull(e){let t=this.#e.workspaceId;if(!t||this.#e.refreshing)return;let n=this.#i(),r=this.#t;this.#s({...this.#e,refreshing:!0,error:null});try{await this.transport.pull(t,e,n.signal),this.#o(r,t,n)&&(this.#s({...this.#e,refreshing:!1}),await this.refresh())}catch(e){this.#o(r,t,n)&&!n.signal.aborted&&this.#s({...this.#e,refreshing:!1,error:this.errorMessage(e,`GIT_PULL_FAILED`)})}}async checkout(e){let t=this.#e.workspaceId;if(!t||this.#e.checkingOut||e===this.#e.summary?.branch)return;let n=this.#i(),r=this.#t;this.#s({...this.#e,checkingOut:!0,error:null});try{await this.transport.checkout(t,e,n.signal),this.#o(r,t,n)&&(this.#s({...this.#e,checkingOut:!1}),await this.refresh())}catch(e){this.#o(r,t,n)&&!n.signal.aborted&&this.#s({...this.#e,checkingOut:!1,error:this.errorMessage(e,`GIT_CHECKOUT_FAILED`)})}}dispose(){this.#r=!0,this.#a()}#i(){return this.#a(),this.#n=new AbortController,++this.#t,this.#n}#a(){this.#n?.abort(),this.#n=null,++this.#t}#o(e,t,n){return!this.#r&&e===this.#t&&this.#e.workspaceId===t&&this.#n===n}#s(e){this.#r||(this.#e=e,this.onChange(e))}};function Hd(e,t,n,r,i){let a=new Set(Ud(e).filter(e=>e.isGitRepository).map(e=>e.id)),o=fd(t,n),s=o?Ud(o.children).filter(e=>e.isGitRepository&&!a.has(e.id)):[],c=Wd(r),l=s.find(e=>e.name===c)??(s.length===1?s[0]:void 0),u=l?.id??o?.id??null,d=new Set(i);return u&&dd(t,u).forEach(e=>d.add(e)),!l&&o&&d.add(o.id),{selectedId:u,expandedIds:d}}function Ud(e){let t=[],n=e=>{t.push(e),e.children.forEach(n)};return e.forEach(n),t}function Wd(e){return(e.trim().replace(/[?#].*$/,``).replace(/\/+$/,``).split(/[/:]/).at(-1)??``).replace(/\.git$/i,``)}function Gd(e){if(typeof e!=`object`||!e)return null;let t=e.permissions;if(typeof t!=`object`||!t)return null;let n=t;return{permissions:{...n.network===null||n.network===void 0?{}:{network:n.network},...n.fileSystem===null||n.fileSystem===void 0?{}:{fileSystem:n.fileSystem}},scope:`turn`}}function Kd(e){return{answers:Object.fromEntries(e.filter(e=>e.answer.trim()).map(e=>[e.id,{answers:[e.answer]}]))}}function qd(e){return[`Submitted quiz answers:`,...e.map(e=>`- ${e.header} — ${e.question}\n ${e.answer.trim().replaceAll(`
23
23
  `,`
24
24
  `)}`)].join(`
25
- `)}function Jd(e=fetch){async function t(e){let t=await e.json().catch(()=>null),n=typeof t?.code==`string`&&/^[A-Z0-9_]+$/.test(t.code)?t.code:void 0,r=n?.startsWith(`AUTOPILOT_`)&&e.status===409?`Relay request failed (${e.status}).`:typeof t?.detail==`string`&&t.detail.length<=600?t.detail:typeof t?.title==`string`?t.title:`Relay request failed (${e.status}).`;return Object.assign(Error(r),{...n?{code:n}:{},...typeof t?.replaceAllowed==`boolean`?{replaceAllowed:t.replaceAllowed}:{},status:e.status})}async function n(n,r,i={},a){let o=await e(n,{method:`POST`,headers:{"content-type":`application/json`,...i},body:JSON.stringify(r),signal:a});if(!o.ok)throw await t(o);return o.json()}async function r(n,r,i={}){let a=await e(n,{method:`PUT`,headers:{"content-type":`application/json`,...i},body:JSON.stringify(r)});if(!a.ok)throw await t(a);return a.json()}async function i(n,r,i,a){let o=await e(n,{method:`PUT`,headers:{"content-type":`application/octet-stream`,"idempotency-key":i},body:r,signal:a});if(!o.ok)throw await t(o);return o.json()}async function a(n,r,i){let a=await e(n,{method:`DELETE`,headers:{"content-type":`application/json`,"idempotency-key":i},body:JSON.stringify(r)});if(!a.ok)throw await t(a);return a.json()}async function o(n){let r=await e(n,{method:`DELETE`});if(!r.ok)throw await t(r)}async function s(n,r){let i=await e(n,r?{signal:r}:void 0);if(!i.ok)throw await t(i);return i.json()}async function c(n,r){let i=await e(n,{signal:r});if(i.status===204)return null;if(!i.ok)throw await t(i);return i.json()}return{debugConfirmation:e=>s(`/api/sessions/${encodeURIComponent(e)}/debug`),startSelfDebug:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/debug`,{confirmationId:t}),readDebugTrace:(e,t)=>s(`/api/sessions/${encodeURIComponent(e)}/debug/trace`,t),quit:()=>n(`/api/maintenance/quit`,{}),upgrade:()=>n(`/api/maintenance/upgrade`,{}),upgradeStatus:e=>s(`/api/maintenance/upgrade`,e),listSessions:e=>s(`/api/sessions`,e),checkWorkspaceFileReferences:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/references`,{paths:t},{},r),getSessionFilePreview:(e,t,n)=>s(`/api/sessions/${encodeURIComponent(e)}/files/preview?${new URLSearchParams({path:t})}`,n),getWorkspaceFilePreview:(e,t,n)=>s(`/api/workspaces/${encodeURIComponent(e)}/files/preview?${new URLSearchParams({path:t})}`,n),listWorkspaceDirectory:(e,t={},n)=>{let r=new URLSearchParams;t.directory!==void 0&&r.set(`directory`,t.directory),t.cursor!==void 0&&r.set(`cursor`,t.cursor),t.limit!==void 0&&r.set(`limit`,String(t.limit));let i=r.size===0?``:`?${r}`;return s(`/api/workspaces/${encodeURIComponent(e)}/files${i}`,n)},copyWorkspaceEntry:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/copy`,t,{"idempotency-key":r}),moveWorkspaceEntry:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/move`,t,{"idempotency-key":r}),uploadWorkspaceFile:(e,t,n,r)=>{let a=new URLSearchParams({directory:t.directory,filename:t.filename,conflict:t.conflict});return i(`/api/workspaces/${encodeURIComponent(e)}/files/upload?${a}`,t.file,n,r)},deleteWorkspaceEntry:(e,t,n)=>a(`/api/workspaces/${encodeURIComponent(e)}/files`,{path:t,recursive:!0},n),getSession:e=>s(`/api/sessions/${encodeURIComponent(e)}`),refreshActivity:e=>n(`/api/sessions/${encodeURIComponent(e)}/activity/refresh`,{}),setAutopilot:(e,t,n)=>r(`/api/sessions/${encodeURIComponent(e)}/autopilot`,{enabled:t},n?{"idempotency-key":n}:{}),resolveAttention:(e,t,r)=>n(`/api/sessions/${encodeURIComponent(e)}/attention/${encodeURIComponent(t)}/resolve`,r),listRecentSessions:()=>s(`/api/sessions/recent-threads`),openRecentSession:(e,t,r=`codex`)=>n(`/api/sessions/recent-threads/open`,{threadId:e,cwd:t,provider:r}),listSessionModels:e=>n(`/api/session-models/${encodeURIComponent(e)}`,{}),startSession:(e,t={},r)=>n(`/api/sessions`,{workspaceId:e,profile:`default`,provider:`codex`,...t},r?{"idempotency-key":r}:{}),startTurn:(e,t,r)=>n(`/api/sessions/${encodeURIComponent(e)}/turns`,{text:t},r?{"idempotency-key":r}:{}),selectModel:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/model`,{model:t}),interruptTurn:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/turns/${encodeURIComponent(t)}/interrupt`,{}),queueTurnInput:(e,t,r,i)=>n(`/api/sessions/${encodeURIComponent(e)}/turns/${encodeURIComponent(t)}/queue`,{text:r},i?{"idempotency-key":i}:{}),restoreSession:e=>n(`/api/sessions/${encodeURIComponent(e)}/restore`,{}),releaseSession:e=>n(`/api/sessions/${encodeURIComponent(e)}/release`,{}),forgetSession:n=>e(`/api/sessions/${encodeURIComponent(n)}`,{method:`DELETE`}).then(async e=>{if(!e.ok)throw await t(e)}),getHistory:e=>s(`/api/sessions/${encodeURIComponent(e)}/history`),getPlan:(e,t)=>c(`/api/sessions/${encodeURIComponent(e)}/plan`,t),closePlan:e=>o(`/api/sessions/${encodeURIComponent(e)}/plan`),listWorkspacePlans:(e,t)=>s(`/api/workspaces/${encodeURIComponent(e)}/plans`,t),archiveWorkspacePlan:(e,t)=>n(`/api/workspaces/${encodeURIComponent(e)}/plans/${encodeURIComponent(t)}/archive`,{}),getWorkspacePlan:(e,t,n)=>s(`/api/workspaces/${encodeURIComponent(e)}/plans/${encodeURIComponent(t)}`,n),openSessionPlan:(e,t)=>r(`/api/sessions/${encodeURIComponent(e)}/plan`,{planName:t}),getGitSummary:(e,t)=>s(`/api/git/repositories/${encodeURIComponent(e)}`,t),cloneGitRepository:(e,t)=>n(`/api/git/clone`,{workspaceId:e,address:t}),refreshGit:(e,t)=>n(`/api/git/repositories/${encodeURIComponent(e)}/refresh`,{},t?{"idempotency-key":t}:{}),pullGit:(e,t,r)=>n(`/api/git/repositories/${encodeURIComponent(e)}/pull`,{},t?{"idempotency-key":t}:{},r),checkoutGitBranch:(e,t,r)=>n(`/api/git/repositories/${encodeURIComponent(e)}/checkout`,{branch:t},{},r),pushGit:(e,t)=>n(`/api/git/repositories/${encodeURIComponent(e)}/push`,{},t?{"idempotency-key":t}:{}),listAvailableSkills:(e,t,n=!1,r)=>s(`/api/skills?${new URLSearchParams({workspaceId:e,profile:t,...n?{refresh:`true`}:{}}).toString()}`,r),listSkillProfiles:e=>s(`/api/skill-profiles`,e),replaceSkillProfile:(e,t)=>r(`/api/skill-profiles/${encodeURIComponent(e)}`,t),deleteSkillProfile:e=>o(`/api/skill-profiles/${encodeURIComponent(e)}`),respondInteraction:(e,t,r,i)=>n(`/api/sessions/${encodeURIComponent(e)}/interactions/${encodeURIComponent(t)}`,r,i?{"idempotency-key":i}:{})}}var Yd=[`authoring-start`,`work-start`,`checkpoint`,`update`,`supervision-start`,`resync`];function Xd(e){return typeof e==`string`&&(Yd.includes(e)||/^review:[A-Za-z0-9._-]{1,128}:REVIEWED$/.test(e)||/^l2:[A-Za-z0-9._-]{1,128}:(WIP|DONE)$/.test(e))}function Zd(e){if(!e||typeof e!=`object`)return!1;let t=e;return Qd(t.plan)&&(t.reason===null||Xd(t.reason))}function Qd(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.title==`string`&&Array.isArray(t.steps)&&typeof t.totalSteps==`number`&&typeof t.doneSteps==`number`&&typeof t.allDone==`boolean`&&typeof t.currentStepId==`string`}function $d(e){return e instanceof Error?e.message:`Could not load the plan.`}function ef(e){return{...e,...e.skills?{skills:[...e.skills]}:{},description:{...e.description},children:e.children.map(ef)}}function tf(e){return{...e,steps:e.steps.map(ef)}}function nf(e,t){return e.kind===`unavailable`&&e.sessionId===t}function rf(e,t){let n=null,r={kind:`unavailable`,sessionId:null},i=0,a=0,o=null,s=0,c=e=>{++a,r=e,t(e)},l=(t,r)=>{o?.abort(),o=new AbortController;let a=++i,l=s;r||c({kind:`loading`,sessionId:t}),e.getPlan(t,o.signal).then(e=>{a!==i||n!==t||s===l&&c(e?{kind:`ready`,sessionId:t,plan:tf(e)}:{kind:`unavailable`,sessionId:t})}).catch(e=>{o?.signal.aborted||a!==i||n!==t||c({kind:`error`,sessionId:t,error:$d(e),...r?{plan:r}:{}})})};return{select(e){if(o?.abort(),n=e,s=0,!e){++i,c({kind:`unavailable`,sessionId:null});return}l(e,void 0)},refresh(e){if(n!==e)return;let t=r.kind===`ready`||r.kind===`closing`||r.kind===`error`?r.plan:void 0;l(e,t)},applyEvent(e,t){if(!(n!==e||t.sequence<=s)){if(t.type===`plan.updated`&&(Qd(t.payload)||Zd(t.payload))){let n=Zd(t.payload)?t.payload.plan:t.payload;s=t.sequence,c({kind:`ready`,sessionId:e,plan:tf(n)})}t.type===`plan.closed`&&(s=t.sequence,c({kind:`unavailable`,sessionId:e}))}},async close(){if(r.kind!==`ready`&&r.kind!==`error`||!r.plan?.allDone)return null;let{sessionId:t,plan:i}=r;c({kind:`closing`,sessionId:t,plan:i});let o=a;try{return await e.closePlan(t),n===t?a===o?(c({kind:`unavailable`,sessionId:t}),`chat`):nf(r,t)?`chat`:null:null}catch(e){return n===t?a===o?(c({kind:`error`,sessionId:t,plan:i,error:$d(e)}),null):nf(r,t)?`chat`:null:null}},dispose(){o?.abort(),o=null,n=null,++i,c({kind:`unavailable`,sessionId:null})}}}function af(e){if(!e)return null;let t=of(e.steps,e.currentStepId)?.measurement?.weeklyRemainingCurrent;return typeof t==`number`&&Number.isFinite(t)&&t>=0&&t<=100?Math.round(t):null}function of(e,t){for(let n of e){if(n.id===t)return n;let e=of(n.children,t);if(e)return e}}function sf(e){let t=new Set,n=e=>{for(let n of e.matchAll(/=([^=\n]+)=/g)){let e=n[1].trim();e&&t.add(e)}};if(e?.kind===`org-source`)n(e.source);else if(e&&`plan`in e&&e.plan){let t=[...e.plan.steps];for(;t.length;){let e=t.pop();Object.values(e.description).forEach(e=>{e&&n(e)}),t.push(...e.children)}}return[...t]}var cf=q(`<a class="svelte-nywawl"><code class="svelte-nywawl"> </code></a>`),lf=q(`<code class="svelte-nywawl"> </code>`),uf=q(`<span class="notes svelte-nywawl"></span>`);function df(e,t){$e(t,!0);let n=$(t,`verifiedReferences`,19,()=>new Set),r=L(()=>t.text.split(/(=[^=\n]+=)/g));var i=uf();Z(i,21,()=>G(r),ei,(e,r)=>{var i=Kr(),a=H(i),o=e=>{var i=Kr(),a=H(i),o=e=>{var n=cf(),i=V(n),a=V(i,!0);P(i),P(n),W((e,t)=>{Q(n,`href`,e),Y(a,t)},[()=>`#file-preview=${encodeURIComponent(G(r).slice(1,-1).trim())}`,()=>G(r).slice(1,-1)]),K(`click`,n,e=>{e.preventDefault(),t.onreference?.(G(r).slice(1,-1).trim())}),J(e,n)},s=L(()=>t.onreference&&n().has(G(r).slice(1,-1).trim())),c=e=>{var t=lf(),n=V(t,!0);P(t),W(e=>Y(n,e),[()=>G(r).slice(1,-1)]),J(e,t)};X(a,e=>{G(s)?e(o):e(c,-1)}),J(e,i)},s=L(()=>G(r).startsWith(`=`)&&G(r).endsWith(`=`)&&G(r).length>2),c=e=>{var t=Gr();W(()=>Y(t,G(r))),J(e,t)};X(a,e=>{G(s)?e(o):e(c,-1)}),J(e,i)}),P(i),J(e,i),et()}Rr([`click`]);function ff(e,t){return t===void 0?`L${e}`:`L${e}.${t}`}function pf(e){let t=e.steps.filter(e=>e.reviewStatus===`REVIEWED`).length,n=e.steps.length,r=mf(e),i=e.steps.find(e=>e.state===`DONE`&&e.reviewStatus===`UNREVIEWED`);return i?{phase:`awaiting review`,label:`Awaiting ${ff(e.steps.indexOf(i)+1)} review`,current:r,reviewedL1s:t,totalL1s:n}:n>0&&t===n?{phase:`terminal review`,label:`Terminal review`,current:r,reviewedL1s:t,totalL1s:n}:t>0&&!r?{phase:`milestone reported`,label:`Preparing milestone summary`,current:r,reviewedL1s:t,totalL1s:n}:r?{phase:`implementing`,label:`Implementing ${r.position} ${r.title}`,current:r,reviewedL1s:t,totalL1s:n}:{phase:e.allDone?`terminal review`:`implementing`,label:e.allDone?`Terminal review`:`Implementing`,current:r,reviewedL1s:t,totalL1s:n}}function mf(e){for(let[t,n]of e.steps.entries()){if(n.id===e.currentStepId)return{id:n.id,position:ff(t+1),title:n.title,state:n.state};let r=n.children.findIndex(t=>t.id===e.currentStepId);if(r>=0){let e=n.children[r];return{id:e.id,position:ff(t+1,r+1),title:e.title,state:e.state}}}}var hf=q(`<span class="wip-effort svelte-hmxg46"> </span>`),gf=q(`<li class="svelte-hmxg46"><span class="wip-position svelte-hmxg46" aria-hidden="true"> </span> <span class="wip-title svelte-hmxg46"> </span> <!></li>`),_f=q(`<ol class="wip-steps svelte-hmxg46" aria-label="Work in progress plan steps"></ol>`),vf=q(`<li class="svelte-hmxg46"><span aria-hidden="true" class="position svelte-hmxg46"> </span> <span aria-hidden="true" class="state"> </span></li>`),yf=q(`<ol class="step-markers svelte-hmxg46" aria-label="Plan step progress"></ol>`),bf=q(`<div><div class="progress-heading svelte-hmxg46"><span> </span> <span> </span></div> <progress class="svelte-hmxg46"> </progress> <span class="review-status"> </span> <!></div>`);function xf(e,t){$e(t,!0);let n=$(t,`compact`,3,!1),r=$(t,`label`,3,`Plan progress`),i=L(()=>t.plan.steps.flatMap((e,t)=>[{id:e.id,position:ff(t+1),state:e.state,level:e.level,title:e.title,...e.description.effort?{effort:e.description.effort}:{}},...e.children.map((e,n)=>({id:e.id,position:ff(t+1,n+1),state:e.state,level:e.level,title:e.title}))])),a=L(()=>G(i).filter(e=>e.state===`WIP`)),o=L(()=>pf(t.plan)),s=L(()=>Math.max(t.plan.totalSteps,1));var c=bf(),l=V(c),u=V(l),d=V(u);P(u);var f=U(u,2),p=V(f);P(f),P(l);var m=U(l,2),h=V(m);P(m);var g=U(m,2),_=V(g,!0);P(g);var v=U(g,2),y=e=>{var n=_f();Z(n,21,()=>G(a),e=>e.id,(e,n)=>{var r=gf(),i=V(r),a=V(i);P(i);var o=U(i,2),s=V(o,!0);P(o);var c=U(o,2),l=e=>{var t=hf(),r=V(t);P(t),W(()=>Y(r,`Effort: ${G(n).effort??``}`)),J(e,t)};X(c,e=>{G(n).level===1&&G(n).effort&&e(l)}),P(r),W(()=>{Q(r,`aria-current`,G(n).id===t.plan.currentStepId?`step`:void 0),Q(r,`aria-label`,`${G(n).position}: ${G(n).title}, WIP${G(n).level===1&&G(n).effort?`, effort ${G(n).effort}`:``}`),Y(a,`${G(n).position??``} · WIP`),Y(s,G(n).title)}),J(e,r)}),P(n),J(e,n)},b=e=>{var n=yf();Z(n,21,()=>G(i),e=>e.id,(e,n)=>{var r=vf(),i=V(r),a=V(i,!0);P(i);var o=U(i,2),s=V(o,!0);P(o),P(r),W(()=>{Q(r,`data-state`,G(n).state),Q(r,`aria-current`,G(n).id===t.plan.currentStepId?`step`:void 0),Q(r,`aria-label`,`${G(n).position}: ${G(n).state}`),Y(a,G(n).position),Y(s,G(n).state)}),J(e,r)}),P(n),J(e,n)};X(v,e=>{n()&&G(a).length?e(y):!n()&&G(i).length&&e(b,1)}),P(c),W(()=>{Si(c,1,gi([`plan-progress`,{compact:n()}]),`svelte-hmxg46`),Y(d,`${t.plan.doneSteps??``} / ${t.plan.totalSteps??``} work items done`),Y(p,`· ${G(o).reviewedL1s??``} / ${G(o).totalL1s??``} reviewed`),Q(m,`aria-label`,r()),Pi(m,t.plan.doneSteps),Q(m,`max`,G(s)),Y(h,`${t.plan.doneSteps??``} of ${t.plan.totalSteps??``} work items done`),Q(g,`data-phase`,G(o).phase),Y(_,G(o).label)}),J(e,c),et()}var Sf=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg">Loading plan…</p></section>`),Cf=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg">No retained plan for this session.</p></section>`),wf=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg"> </p></section>`),Tf=q(`<p class="svelte-3rmyvg"> </p>`),Ef=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Subtitle</dt> <dd class="svelte-3rmyvg"> </dd></div>`),Df=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Date</dt> <dd class="svelte-3rmyvg"> </dd></div>`),Of=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Keywords</dt> <dd class="svelte-3rmyvg"> </dd></div>`),kf=q(`<dl class="metadata svelte-3rmyvg"><!> <!> <!></dl>`),Af=q(`<p class="svelte-3rmyvg">No plan steps have been retained yet.</p>`),jf=q(`<p class="svelte-3rmyvg"><strong class="svelte-3rmyvg"> </strong> <!></p>`),Mf=q(`<p class="svelte-3rmyvg"><strong class="svelte-3rmyvg">Skills:</strong> </p>`),Nf=q(`<li class="svelte-3rmyvg"><details class="svelte-3rmyvg"><summary class="svelte-3rmyvg"><strong class="svelte-3rmyvg"><span class="position svelte-3rmyvg"> </span> </strong> <span class="svelte-3rmyvg"> </span> <span class="svelte-3rmyvg"> </span></summary> <!> <!></details></li>`),Pf=q(`<ol class="svelte-3rmyvg"></ol>`),Ff=q(`<li class="svelte-3rmyvg"><details class="svelte-3rmyvg"><summary class="svelte-3rmyvg"><strong class="svelte-3rmyvg"><span class="position svelte-3rmyvg"> </span> </strong> <span class="svelte-3rmyvg"> </span> <span class="svelte-3rmyvg"> </span> <span class="measurement svelte-3rmyvg"> </span></summary> <!> <!> <!></details></li>`),If=q(`<ol class="plan-steps svelte-3rmyvg"></ol>`),Lf=q(`<section class="plan svelte-3rmyvg" aria-labelledby="plan-title"><header class="svelte-3rmyvg"><div class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg"> </h2></div> <button class="close svelte-3rmyvg" aria-label="Close plan and return to list">×</button></header> <!> <p class="svelte-3rmyvg"> </p> <!> <!> <!></section>`),Rf=q(`<p class="visually-hidden svelte-3rmyvg" aria-live="polite" aria-atomic="true"> </p> <!>`,1);function zf(e,t){$e(t,!0);let n={effort:`Effort`,goal:`Goal`,notes:`Notes`,why:`Why`,change:`Change`,tests:`Tests`,doneWhen:`Done when`},r=$(t,`verifiedReferences`,19,()=>new Set),i=z(on(new Set)),a=on({}),o=null,s=0,c=L(()=>t.state.kind===`ready`||t.state.kind===`closing`||t.state.kind===`error`?t.state.plan:void 0),l=L(()=>G(c)?m(G(c).steps,G(c).currentStepId):void 0),u=L(()=>G(c)?h(G(c).steps,G(c).currentStepId):void 0),d=L(()=>G(c)?pf(G(c)):void 0),f=L(()=>G(c)?g(G(c).steps,G(c).currentStepId):new Set),p=L(()=>t.state.kind===`loading`?`Loading plan.`:t.state.kind===`unavailable`?`No retained plan for this session.`:t.state.kind===`error`&&!G(c)?t.state.error:t.state.kind===`closing`?`Closing completed plan.`:G(c)?G(l)?`${G(d)?.label??`Current step: ${G(u)} ${G(l).title}`}. ${G(c).doneSteps} of ${G(c).totalSteps} work items done.${t.state.kind===`error`?` ${t.state.error}`:``}`:`${G(d)?.label??`Plan progress`}. ${G(c).doneSteps} of ${G(c).totalSteps} work items done.${t.state.kind===`error`?` ${t.state.error}`:``}`:``);Mn(()=>{let e=G(c)?.currentStepId||null;if(!e||o===e)return;let t=o===null;o=e;let n=++s;t||Tr().then(()=>{n!==s||G(c)?.currentStepId!==e||a[e]?.scrollIntoView({behavior:`auto`,block:`nearest`,inline:`nearest`})})});function m(e,t){for(let n of e){if(n.id===t)return n;let e=m(n.children,t);if(e)return e}}function h(e,t){for(let[n,r]of e.entries()){if(r.id===t)return ff(n+1);let e=r.children.findIndex(e=>e.id===t);if(e>=0)return ff(n+1,e+1)}}function g(e,t,n=[]){for(let r of e){if(r.id===t)return new Set([...n,r.id]);let e=g(r.children,t,[...n,r.id]);if(e.size)return e}return new Set}function _(e){return G(i).has(e)||G(f).has(e)}function v(e,t){B(i,t?new Set([...G(i),e]):new Set([...G(i)].filter(t=>t!==e)),!0)}function y(e){return e.description.goal??e.description.why??e.title}function b(e){let t=e.measurement;if(!t)return`Measurements unavailable`;let n=[];return t.elapsedSeconds!==void 0&&n.push(`${Math.floor(t.elapsedSeconds/60)}m ${t.elapsedSeconds%60}s elapsed`),t.weeklyPercentUsed!==void 0&&n.push(`${t.weeklyPercentUsed}% observed account-wide usage`),t.tokensUsed!==void 0&&n.push(`${t.tokensUsed.toLocaleString()} tokens used`),n.join(` · `)||`Measurements unavailable`}function x(e){return Object.keys(n).flatMap(t=>{let r=e.description[t];return r?[[n[t],r]]:[]})}var S=Rf(),w=H(S),T=V(w,!0);P(w);var E=U(w,2),D=e=>{J(e,Sf())},ee=e=>{J(e,Cf())},te=e=>{var n=wf(),r=U(V(n),2),i=V(r,!0);P(r),P(n),W(()=>Y(i,t.state.error)),J(e,n)},ne=e=>{var n=Lf(),i=V(n),o=V(i),s=V(o),f=V(s,!0);P(s),P(o);var p=U(o,2);P(i);var m=U(i,2);xf(m,{get plan(){return G(c)}});var h=U(m,2),g=V(h);P(h);var S=U(h,2),w=e=>{var n=Tf(),r=V(n,!0);P(n),W(()=>Y(r,t.state.error)),J(e,n)};X(S,e=>{t.state.kind===`error`&&e(w)});var T=U(S,2),E=e=>{var t=kf(),n=V(t),r=e=>{var t=Ef(),n=U(V(t),2),r=V(n,!0);P(n),P(t),W(()=>Y(r,G(c).subtitle)),J(e,t)};X(n,e=>{G(c).subtitle&&e(r)});var i=U(n,2),a=e=>{var t=Df(),n=U(V(t),2),r=V(n,!0);P(n),P(t),W(()=>Y(r,G(c).date)),J(e,t)};X(i,e=>{G(c).date&&e(a)});var o=U(i,2),s=e=>{var t=Of(),n=U(V(t),2),r=V(n,!0);P(n),P(t),W(()=>Y(r,G(c).keywords)),J(e,t)};X(o,e=>{G(c).keywords&&e(s)}),P(t),J(e,t)};X(T,e=>{(G(c).subtitle||G(c).date||G(c).keywords)&&e(E)});var D=U(T,2),ee=e=>{J(e,Af())},te=e=>{var n=If();Z(n,23,()=>G(c).steps,e=>e.id,(e,n,i)=>{var o=Ff(),s=V(o),c=V(s),l=V(c),u=V(l),d=V(u,!0);P(u);var f=U(u);P(l);var p=U(l,2),m=V(p);P(p);var h=U(p,2),g=V(h,!0);P(h);var S=U(h,2),w=V(S,!0);P(S),P(c);var T=U(c,2);Z(T,17,()=>x(G(n)),([e,t])=>e,(e,n)=>{var i=L(()=>C(G(n),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=jf(),c=V(s),l=V(c);P(c),df(U(c,2),{get text(){return o()},get onreference(){return t.onreference},get verifiedReferences(){return r()}}),P(s),W(()=>Y(l,`${a()??``}:`)),J(e,s)});var E=U(T,2),D=e=>{var t=Mf(),r=U(V(t));P(t),W(e=>Y(r,` ${e??``}`),[()=>G(n).skills.join(`, `)]),J(e,t)};X(E,e=>{G(n).skills?.length&&e(D)});var ee=U(E,2),te=e=>{var o=Pf();Z(o,23,()=>G(n).children,e=>e.id,(e,n,o)=>{var s=Nf(),c=V(s),l=V(c),u=V(l),d=V(u),f=V(d,!0);P(d);var p=U(d);P(u);var m=U(u,2),h=V(m);P(m);var g=U(m,2),b=V(g,!0);P(g),P(l);var S=U(l,2);Z(S,17,()=>x(G(n)),([e,t])=>e,(e,n)=>{var i=L(()=>C(G(n),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=jf(),c=V(s),l=V(c);P(c),df(U(c,2),{get text(){return o()},get onreference(){return t.onreference},get verifiedReferences(){return r()}}),P(s),W(()=>Y(l,`${a()??``}:`)),J(e,s)});var w=U(S,2),T=e=>{var t=Mf(),r=U(V(t));P(t),W(e=>Y(r,` ${e??``}`),[()=>G(n).skills.join(`, `)]),J(e,t)};X(w,e=>{G(n).skills?.length&&e(T)}),P(c),Ui(c,(e,t)=>a[t.id]=e,e=>a?.[e.id],()=>[G(n)]),P(s),W((e,t,r)=>{Q(c,`data-step-id`,G(n).id),c.open=e,Y(f,t),Y(p,` ${G(n).title??``}`),Y(h,`${G(n).state??``} · Priority ${G(n).priority??``}${G(n).reviewStatus?` · ${G(n).reviewStatus}`:``}`),Y(b,r)},[()=>_(G(n).id),()=>ff(G(i)+1,G(o)+1),()=>y(G(n))]),Lr(`toggle`,c,e=>v(G(n).id,e.currentTarget.open)),J(e,s)}),P(o),J(e,o)};X(ee,e=>{G(n).children.length&&e(te)}),P(s),Ui(s,(e,t)=>a[t.id]=e,e=>a?.[e.id],()=>[G(n)]),P(o),W((e,t,r,i)=>{Q(s,`data-step-id`,G(n).id),s.open=e,Y(d,t),Y(f,` ${G(n).title??``}`),Y(m,`${G(n).state??``} · Priority ${G(n).priority??``}${G(n).reviewStatus?` · ${G(n).reviewStatus}`:``}`),Y(g,r),Y(w,i)},[()=>_(G(n).id),()=>ff(G(i)+1),()=>y(G(n)),()=>b(G(n))]),Lr(`toggle`,s,e=>v(G(n).id,e.currentTarget.open)),J(e,o)}),P(n),J(e,n)};X(D,e=>{G(c).steps.length===0?e(ee):e(te,-1)}),P(n),W(()=>{Y(f,G(c).title),Y(g,`${G(d)?.label??``}. Current: ${G(l)?`${G(u)} ${G(l).title} (${G(l).state})`:`No current step`}`)}),K(`click`,p,function(...e){t.onclose?.apply(this,e)}),J(e,n)};X(E,e=>{t.state.kind===`loading`?e(D):t.state.kind===`unavailable`?e(ee,1):t.state.kind===`error`&&!G(c)?e(te,2):G(c)&&e(ne,3)}),W(()=>Y(T,G(p))),J(e,S),et()}Rr([`click`]);var Bf=/^(\*+)\s+(?:(TODO|WIP|DONE)\s+)?(?:\[#([ABC])\]\s+)?(.+)$/,Vf=/^#\+([A-Z][A-Z0-9_-]*):\s*(.*)$/i,Hf=/^:([A-Z][A-Z0-9_]*):\s*(.*)$/,Uf=/^-\s+([^:]+?)\s+::\s*(.*)$/;function Wf(e){let t=[],n=[],r=[],i=e.replace(/\r\n?/g,`
25
+ `)}function Jd(e=fetch){async function t(e){let t=await e.json().catch(()=>null),n=typeof t?.code==`string`&&/^[A-Z0-9_]+$/.test(t.code)?t.code:void 0,r=n?.startsWith(`AUTOPILOT_`)&&e.status===409?`Relay request failed (${e.status}).`:typeof t?.detail==`string`&&t.detail.length<=600?t.detail:typeof t?.title==`string`?t.title:`Relay request failed (${e.status}).`;return Object.assign(Error(r),{...n?{code:n}:{},...typeof t?.replaceAllowed==`boolean`?{replaceAllowed:t.replaceAllowed}:{},status:e.status})}async function n(n,r,i={},a){let o=await e(n,{method:`POST`,headers:{"content-type":`application/json`,...i},body:JSON.stringify(r),signal:a});if(!o.ok)throw await t(o);return o.json()}async function r(n,r,i={}){let a=await e(n,{method:`PUT`,headers:{"content-type":`application/json`,...i},body:JSON.stringify(r)});if(!a.ok)throw await t(a);return a.json()}async function i(n,r,i,a){let o=await e(n,{method:`PUT`,headers:{"content-type":`application/octet-stream`,"idempotency-key":i},body:r,signal:a});if(!o.ok)throw await t(o);return o.json()}async function a(n,r,i){let a=await e(n,{method:`DELETE`,headers:{"content-type":`application/json`,"idempotency-key":i},body:JSON.stringify(r)});if(!a.ok)throw await t(a);return a.json()}async function o(n){let r=await e(n,{method:`DELETE`});if(!r.ok)throw await t(r)}async function s(n,r){let i=await e(n,r?{signal:r}:void 0);if(!i.ok)throw await t(i);return i.json()}async function c(n,r){let i=await e(n,{signal:r});if(i.status===204)return null;if(!i.ok)throw await t(i);return i.json()}return{debugConfirmation:e=>s(`/api/sessions/${encodeURIComponent(e)}/debug`),startSelfDebug:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/debug`,{confirmationId:t}),readDebugTrace:(e,t)=>s(`/api/sessions/${encodeURIComponent(e)}/debug/trace`,t),quit:()=>n(`/api/maintenance/quit`,{}),upgrade:()=>n(`/api/maintenance/upgrade`,{}),upgradeStatus:e=>s(`/api/maintenance/upgrade`,e),listSessions:e=>s(`/api/sessions`,e),checkWorkspaceFileReferences:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/references`,{paths:t},{},r),getSessionFilePreview:(e,t,n)=>s(`/api/sessions/${encodeURIComponent(e)}/files/preview?${new URLSearchParams({path:t})}`,n),getWorkspaceFilePreview:(e,t,n)=>s(`/api/workspaces/${encodeURIComponent(e)}/files/preview?${new URLSearchParams({path:t})}`,n),listWorkspaceDirectory:(e,t={},n)=>{let r=new URLSearchParams;t.directory!==void 0&&r.set(`directory`,t.directory),t.cursor!==void 0&&r.set(`cursor`,t.cursor),t.limit!==void 0&&r.set(`limit`,String(t.limit));let i=r.size===0?``:`?${r}`;return s(`/api/workspaces/${encodeURIComponent(e)}/files${i}`,n)},copyWorkspaceEntry:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/copy`,t,{"idempotency-key":r}),moveWorkspaceEntry:(e,t,r)=>n(`/api/workspaces/${encodeURIComponent(e)}/files/move`,t,{"idempotency-key":r}),uploadWorkspaceFile:(e,t,n,r)=>{let a=new URLSearchParams({directory:t.directory,filename:t.filename,conflict:t.conflict});return i(`/api/workspaces/${encodeURIComponent(e)}/files/upload?${a}`,t.file,n,r)},deleteWorkspaceEntry:(e,t,n)=>a(`/api/workspaces/${encodeURIComponent(e)}/files`,{path:t,recursive:!0},n),getSession:e=>s(`/api/sessions/${encodeURIComponent(e)}`),refreshActivity:e=>n(`/api/sessions/${encodeURIComponent(e)}/activity/refresh`,{}),setAutopilot:(e,t,n)=>r(`/api/sessions/${encodeURIComponent(e)}/autopilot`,{enabled:t},n?{"idempotency-key":n}:{}),resolveAttention:(e,t,r)=>n(`/api/sessions/${encodeURIComponent(e)}/attention/${encodeURIComponent(t)}/resolve`,r),listRecentSessions:()=>s(`/api/sessions/recent-threads`),openRecentSession:(e,t,r=`codex`)=>n(`/api/sessions/recent-threads/open`,{threadId:e,cwd:t,provider:r}),listSessionModels:e=>n(`/api/session-models/${encodeURIComponent(e)}`,{}),startSession:(e,t={},r)=>n(`/api/sessions`,{workspaceId:e,profile:`default`,provider:`codex`,...t},r?{"idempotency-key":r}:{}),startTurn:(e,t,r)=>n(`/api/sessions/${encodeURIComponent(e)}/turns`,{text:t},r?{"idempotency-key":r}:{}),selectModel:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/model`,{model:t}),interruptTurn:(e,t)=>n(`/api/sessions/${encodeURIComponent(e)}/turns/${encodeURIComponent(t)}/interrupt`,{}),queueTurnInput:(e,t,r,i)=>n(`/api/sessions/${encodeURIComponent(e)}/turns/${encodeURIComponent(t)}/queue`,{text:r},i?{"idempotency-key":i}:{}),restoreSession:e=>n(`/api/sessions/${encodeURIComponent(e)}/restore`,{}),releaseSession:e=>n(`/api/sessions/${encodeURIComponent(e)}/release`,{}),forgetSession:n=>e(`/api/sessions/${encodeURIComponent(n)}`,{method:`DELETE`}).then(async e=>{if(!e.ok)throw await t(e)}),getHistory:e=>s(`/api/sessions/${encodeURIComponent(e)}/history`),getPlan:(e,t)=>c(`/api/sessions/${encodeURIComponent(e)}/plan`,t),closePlan:e=>o(`/api/sessions/${encodeURIComponent(e)}/plan`),listWorkspacePlans:(e,t)=>s(`/api/workspaces/${encodeURIComponent(e)}/plans`,t),archiveWorkspacePlan:(e,t)=>n(`/api/workspaces/${encodeURIComponent(e)}/plans/${encodeURIComponent(t)}/archive`,{}),getWorkspacePlan:(e,t,n)=>s(`/api/workspaces/${encodeURIComponent(e)}/plans/${encodeURIComponent(t)}`,n),openSessionPlan:(e,t)=>r(`/api/sessions/${encodeURIComponent(e)}/plan`,{planName:t}),getGitSummary:(e,t)=>s(`/api/git/repositories/${encodeURIComponent(e)}`,t),cloneGitRepository:(e,t)=>n(`/api/git/clone`,{workspaceId:e,address:t}),refreshGit:(e,t)=>n(`/api/git/repositories/${encodeURIComponent(e)}/refresh`,{},t?{"idempotency-key":t}:{}),pullGit:(e,t,r)=>n(`/api/git/repositories/${encodeURIComponent(e)}/pull`,{},t?{"idempotency-key":t}:{},r),checkoutGitBranch:(e,t,r)=>n(`/api/git/repositories/${encodeURIComponent(e)}/checkout`,{branch:t},{},r),pushGit:(e,t)=>n(`/api/git/repositories/${encodeURIComponent(e)}/push`,{},t?{"idempotency-key":t}:{}),listAvailableSkills:(e,t,n=!1,r)=>s(`/api/skills?${new URLSearchParams({workspaceId:e,profile:t,...n?{refresh:`true`}:{}}).toString()}`,r),listSkillProfiles:e=>s(`/api/skill-profiles`,e),replaceSkillProfile:(e,t)=>r(`/api/skill-profiles/${encodeURIComponent(e)}`,t),deleteSkillProfile:e=>o(`/api/skill-profiles/${encodeURIComponent(e)}`),respondInteraction:(e,t,r,i)=>n(`/api/sessions/${encodeURIComponent(e)}/interactions/${encodeURIComponent(t)}`,r,i?{"idempotency-key":i}:{})}}var Yd=[`authoring-start`,`work-start`,`checkpoint`,`update`,`supervision-start`,`resync`];function Xd(e){return typeof e==`string`&&(Yd.includes(e)||/^review:[A-Za-z0-9._-]{1,128}:REVIEWED$/.test(e)||/^l2:[A-Za-z0-9._-]{1,128}:(WIP|DONE)$/.test(e))}function Zd(e){if(!e||typeof e!=`object`)return!1;let t=e;return Qd(t.plan)&&(t.reason===null||Xd(t.reason))}function Qd(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.title==`string`&&Array.isArray(t.steps)&&typeof t.totalSteps==`number`&&typeof t.doneSteps==`number`&&typeof t.allDone==`boolean`&&typeof t.currentStepId==`string`}function $d(e){return e instanceof Error?e.message:`Could not load the plan.`}function ef(e){return{...e,...e.skills?{skills:[...e.skills]}:{},description:{...e.description},children:e.children.map(ef)}}function tf(e){return{...e,steps:e.steps.map(ef)}}function nf(e,t){return e.kind===`unavailable`&&e.sessionId===t}function rf(e,t){let n=null,r={kind:`unavailable`,sessionId:null},i=0,a=0,o=null,s=0,c=e=>{++a,r=e,t(e)},l=(t,r)=>{o?.abort(),o=new AbortController;let a=++i,l=s;r||c({kind:`loading`,sessionId:t}),e.getPlan(t,o.signal).then(e=>{a!==i||n!==t||s===l&&c(e?{kind:`ready`,sessionId:t,plan:tf(e)}:{kind:`unavailable`,sessionId:t})}).catch(e=>{o?.signal.aborted||a!==i||n!==t||c({kind:`error`,sessionId:t,error:$d(e),...r?{plan:r}:{}})})};return{select(e){if(o?.abort(),n=e,s=0,!e){++i,c({kind:`unavailable`,sessionId:null});return}l(e,void 0)},refresh(e){if(n!==e)return;let t=r.kind===`ready`||r.kind===`closing`||r.kind===`error`?r.plan:void 0;l(e,t)},applyEvent(e,t){if(!(n!==e||t.sequence<=s)){if(t.type===`plan.updated`&&(Qd(t.payload)||Zd(t.payload))){let n=Zd(t.payload)?t.payload.plan:t.payload;s=t.sequence,c({kind:`ready`,sessionId:e,plan:tf(n)})}t.type===`plan.closed`&&(s=t.sequence,c({kind:`unavailable`,sessionId:e}))}},async close(){if(r.kind!==`ready`&&r.kind!==`error`||!r.plan?.allDone)return null;let{sessionId:t,plan:i}=r;c({kind:`closing`,sessionId:t,plan:i});let o=a;try{return await e.closePlan(t),n===t?a===o?(c({kind:`unavailable`,sessionId:t}),`chat`):nf(r,t)?`chat`:null:null}catch(e){return n===t?a===o?(c({kind:`error`,sessionId:t,plan:i,error:$d(e)}),null):nf(r,t)?`chat`:null:null}},dispose(){o?.abort(),o=null,n=null,++i,c({kind:`unavailable`,sessionId:null})}}}function af(e){if(!e)return null;let t=of(e.steps,e.currentStepId)?.measurement?.weeklyRemainingCurrent;return typeof t==`number`&&Number.isFinite(t)&&t>=0&&t<=100?Math.round(t):null}function of(e,t){for(let n of e){if(n.id===t)return n;let e=of(n.children,t);if(e)return e}}function sf(e){let t=new Set,n=e=>{for(let n of e.matchAll(/=([^=\n]+)=/g)){let e=n[1].trim();e&&t.add(e)}};if(e?.kind===`org-source`)n(e.source);else if(e&&`plan`in e&&e.plan){let t=[...e.plan.steps];for(;t.length;){let e=t.pop();Object.values(e.description).forEach(e=>{e&&n(e)}),t.push(...e.children)}}return[...t]}var cf=q(`<a class="svelte-nywawl"><code class="svelte-nywawl"> </code></a>`),lf=q(`<code class="svelte-nywawl"> </code>`),uf=q(`<span class="notes svelte-nywawl"></span>`);function df(e,t){$e(t,!0);let n=$(t,`verifiedReferences`,19,()=>new Set),r=L(()=>t.text.split(/(=[^=\n]+=)/g));var i=uf();Z(i,21,()=>G(r),ei,(e,r)=>{var i=Kr(),a=H(i),o=e=>{var i=Kr(),a=H(i),o=e=>{var n=cf(),i=V(n),a=V(i,!0);P(i),P(n),W((e,t)=>{Q(n,`href`,e),Y(a,t)},[()=>`#file-preview=${encodeURIComponent(G(r).slice(1,-1).trim())}`,()=>G(r).slice(1,-1)]),K(`click`,n,e=>{e.preventDefault(),t.onreference?.(G(r).slice(1,-1).trim())}),J(e,n)},s=L(()=>t.onreference&&n().has(G(r).slice(1,-1).trim())),c=e=>{var t=lf(),n=V(t,!0);P(t),W(e=>Y(n,e),[()=>G(r).slice(1,-1)]),J(e,t)};X(a,e=>{G(s)?e(o):e(c,-1)}),J(e,i)},s=L(()=>G(r).startsWith(`=`)&&G(r).endsWith(`=`)&&G(r).length>2),c=e=>{var t=Gr();W(()=>Y(t,G(r))),J(e,t)};X(a,e=>{G(s)?e(o):e(c,-1)}),J(e,i)}),P(i),J(e,i),et()}Rr([`click`]);function ff(e,t){return t===void 0?`L${e}`:`L${e}.${t}`}function pf(e){let t=e.steps.filter(e=>e.reviewStatus===`REVIEWED`).length,n=e.steps.length,r=mf(e),i=e.steps.find(e=>e.state===`DONE`&&e.reviewStatus===`UNREVIEWED`);return i?{phase:`awaiting review`,label:`Awaiting ${ff(e.steps.indexOf(i)+1)} review`,current:r,reviewedL1s:t,totalL1s:n}:n>0&&t===n?{phase:`terminal review`,label:`Terminal review`,current:r,reviewedL1s:t,totalL1s:n}:t>0&&!r?{phase:`milestone reported`,label:`Preparing milestone summary`,current:r,reviewedL1s:t,totalL1s:n}:r?.state===`SUSPENDED`?{phase:`suspended`,label:`Resume ${r.position} after dependency review`,current:r,reviewedL1s:t,totalL1s:n}:r?{phase:`implementing`,label:`Implementing ${r.position} ${r.title}`,current:r,reviewedL1s:t,totalL1s:n}:{phase:e.allDone?`terminal review`:`implementing`,label:e.allDone?`Terminal review`:`Implementing`,current:r,reviewedL1s:t,totalL1s:n}}function mf(e){for(let[t,n]of e.steps.entries()){if(n.id===e.currentStepId)return{id:n.id,position:ff(t+1),title:n.title,state:n.state};let r=n.children.findIndex(t=>t.id===e.currentStepId);if(r>=0){let e=n.children[r];return{id:e.id,position:ff(t+1,r+1),title:e.title,state:e.state}}}}var hf=q(`<span class="wip-effort svelte-hmxg46"> </span>`),gf=q(`<li class="svelte-hmxg46"><span class="wip-position svelte-hmxg46" aria-hidden="true"> </span> <span class="wip-title svelte-hmxg46"> </span> <!></li>`),_f=q(`<ol class="wip-steps svelte-hmxg46" aria-label="Work in progress plan steps"></ol>`),vf=q(`<li class="svelte-hmxg46"><span aria-hidden="true" class="position svelte-hmxg46"> </span> <span aria-hidden="true" class="state"> </span></li>`),yf=q(`<ol class="step-markers svelte-hmxg46" aria-label="Plan step progress"></ol>`),bf=q(`<div><div class="progress-heading svelte-hmxg46"><span> </span> <span> </span></div> <progress class="svelte-hmxg46"> </progress> <span class="review-status"> </span> <!></div>`);function xf(e,t){$e(t,!0);let n=$(t,`compact`,3,!1),r=$(t,`label`,3,`Plan progress`),i=L(()=>t.plan.steps.flatMap((e,t)=>[{id:e.id,position:ff(t+1),state:e.state,level:e.level,title:e.title,...e.description.effort?{effort:e.description.effort}:{}},...e.children.map((e,n)=>({id:e.id,position:ff(t+1,n+1),state:e.state,level:e.level,title:e.title}))])),a=L(()=>G(i).filter(e=>e.state===`WIP`)),o=L(()=>pf(t.plan)),s=L(()=>Math.max(t.plan.totalSteps,1));var c=bf(),l=V(c),u=V(l),d=V(u);P(u);var f=U(u,2),p=V(f);P(f),P(l);var m=U(l,2),h=V(m);P(m);var g=U(m,2),_=V(g,!0);P(g);var v=U(g,2),y=e=>{var n=_f();Z(n,21,()=>G(a),e=>e.id,(e,n)=>{var r=gf(),i=V(r),a=V(i);P(i);var o=U(i,2),s=V(o,!0);P(o);var c=U(o,2),l=e=>{var t=hf(),r=V(t);P(t),W(()=>Y(r,`Effort: ${G(n).effort??``}`)),J(e,t)};X(c,e=>{G(n).level===1&&G(n).effort&&e(l)}),P(r),W(()=>{Q(r,`aria-current`,G(n).id===t.plan.currentStepId?`step`:void 0),Q(r,`aria-label`,`${G(n).position}: ${G(n).title}, WIP${G(n).level===1&&G(n).effort?`, effort ${G(n).effort}`:``}`),Y(a,`${G(n).position??``} · WIP`),Y(s,G(n).title)}),J(e,r)}),P(n),J(e,n)},b=e=>{var n=yf();Z(n,21,()=>G(i),e=>e.id,(e,n)=>{var r=vf(),i=V(r),a=V(i,!0);P(i);var o=U(i,2),s=V(o,!0);P(o),P(r),W(()=>{Q(r,`data-state`,G(n).state),Q(r,`aria-current`,G(n).id===t.plan.currentStepId?`step`:void 0),Q(r,`aria-label`,`${G(n).position}: ${G(n).state}`),Y(a,G(n).position),Y(s,G(n).state)}),J(e,r)}),P(n),J(e,n)};X(v,e=>{n()&&G(a).length?e(y):!n()&&G(i).length&&e(b,1)}),P(c),W(()=>{Si(c,1,gi([`plan-progress`,{compact:n()}]),`svelte-hmxg46`),Y(d,`${t.plan.doneSteps??``} / ${t.plan.totalSteps??``} work items done`),Y(p,`· ${G(o).reviewedL1s??``} / ${G(o).totalL1s??``} reviewed`),Q(m,`aria-label`,r()),Pi(m,t.plan.doneSteps),Q(m,`max`,G(s)),Y(h,`${t.plan.doneSteps??``} of ${t.plan.totalSteps??``} work items done`),Q(g,`data-phase`,G(o).phase),Y(_,G(o).label)}),J(e,c),et()}var Sf=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg">Loading plan…</p></section>`),Cf=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg">No retained plan for this session.</p></section>`),wf=q(`<section aria-labelledby="plan-title" class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg">Plan</h2> <p class="svelte-3rmyvg"> </p></section>`),Tf=q(`<p class="svelte-3rmyvg"> </p>`),Ef=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Subtitle</dt> <dd class="svelte-3rmyvg"> </dd></div>`),Df=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Date</dt> <dd class="svelte-3rmyvg"> </dd></div>`),Of=q(`<div class="svelte-3rmyvg"><dt class="svelte-3rmyvg">Keywords</dt> <dd class="svelte-3rmyvg"> </dd></div>`),kf=q(`<dl class="metadata svelte-3rmyvg"><!> <!> <!></dl>`),Af=q(`<p class="svelte-3rmyvg">No plan steps have been retained yet.</p>`),jf=q(`<p class="svelte-3rmyvg"><strong class="svelte-3rmyvg"> </strong> <!></p>`),Mf=q(`<p class="svelte-3rmyvg"><strong class="svelte-3rmyvg">Skills:</strong> </p>`),Nf=q(`<li class="svelte-3rmyvg"><details class="svelte-3rmyvg"><summary class="svelte-3rmyvg"><strong class="svelte-3rmyvg"><span class="position svelte-3rmyvg"> </span> </strong> <span class="svelte-3rmyvg"> </span> <span class="svelte-3rmyvg"> </span></summary> <!> <!></details></li>`),Pf=q(`<ol class="svelte-3rmyvg"></ol>`),Ff=q(`<li class="svelte-3rmyvg"><details class="svelte-3rmyvg"><summary class="svelte-3rmyvg"><strong class="svelte-3rmyvg"><span class="position svelte-3rmyvg"> </span> </strong> <span class="svelte-3rmyvg"> </span> <span class="svelte-3rmyvg"> </span> <span class="measurement svelte-3rmyvg"> </span></summary> <!> <!> <!></details></li>`),If=q(`<ol class="plan-steps svelte-3rmyvg"></ol>`),Lf=q(`<section class="plan svelte-3rmyvg" aria-labelledby="plan-title"><header class="svelte-3rmyvg"><div class="svelte-3rmyvg"><h2 id="plan-title" class="svelte-3rmyvg"> </h2></div> <button class="close svelte-3rmyvg" aria-label="Close plan and return to list">×</button></header> <!> <p class="svelte-3rmyvg"> </p> <!> <!> <!></section>`),Rf=q(`<p class="visually-hidden svelte-3rmyvg" aria-live="polite" aria-atomic="true"> </p> <!>`,1);function zf(e,t){$e(t,!0);let n={effort:`Effort`,goal:`Goal`,notes:`Notes`,why:`Why`,change:`Change`,tests:`Tests`,doneWhen:`Done when`},r=$(t,`verifiedReferences`,19,()=>new Set),i=z(on(new Set)),a=on({}),o=null,s=0,c=L(()=>t.state.kind===`ready`||t.state.kind===`closing`||t.state.kind===`error`?t.state.plan:void 0),l=L(()=>G(c)?m(G(c).steps,G(c).currentStepId):void 0),u=L(()=>G(c)?h(G(c).steps,G(c).currentStepId):void 0),d=L(()=>G(c)?pf(G(c)):void 0),f=L(()=>G(c)?g(G(c).steps,G(c).currentStepId):new Set),p=L(()=>t.state.kind===`loading`?`Loading plan.`:t.state.kind===`unavailable`?`No retained plan for this session.`:t.state.kind===`error`&&!G(c)?t.state.error:t.state.kind===`closing`?`Closing completed plan.`:G(c)?G(l)?`${G(d)?.label??`Current step: ${G(u)} ${G(l).title}`}. ${G(c).doneSteps} of ${G(c).totalSteps} work items done.${t.state.kind===`error`?` ${t.state.error}`:``}`:`${G(d)?.label??`Plan progress`}. ${G(c).doneSteps} of ${G(c).totalSteps} work items done.${t.state.kind===`error`?` ${t.state.error}`:``}`:``);Mn(()=>{let e=G(c)?.currentStepId||null;if(!e||o===e)return;let t=o===null;o=e;let n=++s;t||Tr().then(()=>{n!==s||G(c)?.currentStepId!==e||a[e]?.scrollIntoView({behavior:`auto`,block:`nearest`,inline:`nearest`})})});function m(e,t){for(let n of e){if(n.id===t)return n;let e=m(n.children,t);if(e)return e}}function h(e,t){for(let[n,r]of e.entries()){if(r.id===t)return ff(n+1);let e=r.children.findIndex(e=>e.id===t);if(e>=0)return ff(n+1,e+1)}}function g(e,t,n=[]){for(let r of e){if(r.id===t)return new Set([...n,r.id]);let e=g(r.children,t,[...n,r.id]);if(e.size)return e}return new Set}function _(e){return G(i).has(e)||G(f).has(e)}function v(e,t){B(i,t?new Set([...G(i),e]):new Set([...G(i)].filter(t=>t!==e)),!0)}function y(e){return e.description.goal??e.description.why??e.title}function b(e){let t=e.measurement;if(!t)return`Measurements unavailable`;let n=[];return t.elapsedSeconds!==void 0&&n.push(`${Math.floor(t.elapsedSeconds/60)}m ${t.elapsedSeconds%60}s elapsed`),t.weeklyPercentUsed!==void 0&&n.push(`${t.weeklyPercentUsed}% observed account-wide usage`),t.tokensUsed!==void 0&&n.push(`${t.tokensUsed.toLocaleString()} tokens used`),n.join(` · `)||`Measurements unavailable`}function x(e){return Object.keys(n).flatMap(t=>{let r=e.description[t];return r?[[n[t],r]]:[]})}var S=Rf(),w=H(S),T=V(w,!0);P(w);var E=U(w,2),D=e=>{J(e,Sf())},ee=e=>{J(e,Cf())},te=e=>{var n=wf(),r=U(V(n),2),i=V(r,!0);P(r),P(n),W(()=>Y(i,t.state.error)),J(e,n)},ne=e=>{var n=Lf(),i=V(n),o=V(i),s=V(o),f=V(s,!0);P(s),P(o);var p=U(o,2);P(i);var m=U(i,2);xf(m,{get plan(){return G(c)}});var h=U(m,2),g=V(h);P(h);var S=U(h,2),w=e=>{var n=Tf(),r=V(n,!0);P(n),W(()=>Y(r,t.state.error)),J(e,n)};X(S,e=>{t.state.kind===`error`&&e(w)});var T=U(S,2),E=e=>{var t=kf(),n=V(t),r=e=>{var t=Ef(),n=U(V(t),2),r=V(n,!0);P(n),P(t),W(()=>Y(r,G(c).subtitle)),J(e,t)};X(n,e=>{G(c).subtitle&&e(r)});var i=U(n,2),a=e=>{var t=Df(),n=U(V(t),2),r=V(n,!0);P(n),P(t),W(()=>Y(r,G(c).date)),J(e,t)};X(i,e=>{G(c).date&&e(a)});var o=U(i,2),s=e=>{var t=Of(),n=U(V(t),2),r=V(n,!0);P(n),P(t),W(()=>Y(r,G(c).keywords)),J(e,t)};X(o,e=>{G(c).keywords&&e(s)}),P(t),J(e,t)};X(T,e=>{(G(c).subtitle||G(c).date||G(c).keywords)&&e(E)});var D=U(T,2),ee=e=>{J(e,Af())},te=e=>{var n=If();Z(n,23,()=>G(c).steps,e=>e.id,(e,n,i)=>{var o=Ff(),s=V(o),c=V(s),l=V(c),u=V(l),d=V(u,!0);P(u);var f=U(u);P(l);var p=U(l,2),m=V(p);P(p);var h=U(p,2),g=V(h,!0);P(h);var S=U(h,2),w=V(S,!0);P(S),P(c);var T=U(c,2);Z(T,17,()=>x(G(n)),([e,t])=>e,(e,n)=>{var i=L(()=>C(G(n),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=jf(),c=V(s),l=V(c);P(c),df(U(c,2),{get text(){return o()},get onreference(){return t.onreference},get verifiedReferences(){return r()}}),P(s),W(()=>Y(l,`${a()??``}:`)),J(e,s)});var E=U(T,2),D=e=>{var t=Mf(),r=U(V(t));P(t),W(e=>Y(r,` ${e??``}`),[()=>G(n).skills.join(`, `)]),J(e,t)};X(E,e=>{G(n).skills?.length&&e(D)});var ee=U(E,2),te=e=>{var o=Pf();Z(o,23,()=>G(n).children,e=>e.id,(e,n,o)=>{var s=Nf(),c=V(s),l=V(c),u=V(l),d=V(u),f=V(d,!0);P(d);var p=U(d);P(u);var m=U(u,2),h=V(m);P(m);var g=U(m,2),b=V(g,!0);P(g),P(l);var S=U(l,2);Z(S,17,()=>x(G(n)),([e,t])=>e,(e,n)=>{var i=L(()=>C(G(n),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=jf(),c=V(s),l=V(c);P(c),df(U(c,2),{get text(){return o()},get onreference(){return t.onreference},get verifiedReferences(){return r()}}),P(s),W(()=>Y(l,`${a()??``}:`)),J(e,s)});var w=U(S,2),T=e=>{var t=Mf(),r=U(V(t));P(t),W(e=>Y(r,` ${e??``}`),[()=>G(n).skills.join(`, `)]),J(e,t)};X(w,e=>{G(n).skills?.length&&e(T)}),P(c),Ui(c,(e,t)=>a[t.id]=e,e=>a?.[e.id],()=>[G(n)]),P(s),W((e,t,r)=>{Q(c,`data-step-id`,G(n).id),c.open=e,Y(f,t),Y(p,` ${G(n).title??``}`),Y(h,`${G(n).state??``} · Priority ${G(n).priority??``}${G(n).reviewStatus?` · ${G(n).reviewStatus}`:``}`),Y(b,r)},[()=>_(G(n).id),()=>ff(G(i)+1,G(o)+1),()=>y(G(n))]),Lr(`toggle`,c,e=>v(G(n).id,e.currentTarget.open)),J(e,s)}),P(o),J(e,o)};X(ee,e=>{G(n).children.length&&e(te)}),P(s),Ui(s,(e,t)=>a[t.id]=e,e=>a?.[e.id],()=>[G(n)]),P(o),W((e,t,r,i)=>{Q(s,`data-step-id`,G(n).id),s.open=e,Y(d,t),Y(f,` ${G(n).title??``}`),Y(m,`${G(n).state??``} · Priority ${G(n).priority??``}${G(n).reviewStatus?` · ${G(n).reviewStatus}`:``}`),Y(g,r),Y(w,i)},[()=>_(G(n).id),()=>ff(G(i)+1),()=>y(G(n)),()=>b(G(n))]),Lr(`toggle`,s,e=>v(G(n).id,e.currentTarget.open)),J(e,o)}),P(n),J(e,n)};X(D,e=>{G(c).steps.length===0?e(ee):e(te,-1)}),P(n),W(()=>{Y(f,G(c).title),Y(g,`${G(d)?.label??``}. Current: ${G(l)?`${G(u)} ${G(l).title} (${G(l).state})`:`No current step`}`)}),K(`click`,p,function(...e){t.onclose?.apply(this,e)}),J(e,n)};X(E,e=>{t.state.kind===`loading`?e(D):t.state.kind===`unavailable`?e(ee,1):t.state.kind===`error`&&!G(c)?e(te,2):G(c)&&e(ne,3)}),W(()=>Y(T,G(p))),J(e,S),et()}Rr([`click`]);var Bf=/^(\*+)\s+(?:(TODO|WIP|DONE|SUSPENDED)\s+)?(?:\[#([ABC])\]\s+)?(.+)$/,Vf=/^#\+([A-Z][A-Z0-9_-]*):\s*(.*)$/i,Hf=/^:([A-Z][A-Z0-9_]*):\s*(.*)$/,Uf=/^-\s+([^:]+?)\s+::\s*(.*)$/;function Wf(e){let t=[],n=[],r=[],i=e.replace(/\r\n?/g,`
26
26
  `).split(`
27
27
  `),a=null,o=!1,s=null,c=0,l=()=>{a&&r.push({...a,properties:[...a.properties],descriptions:[...a.descriptions],body:Gf(a.body)})};for(let e of i){let r=Bf.exec(e);if(r){l(),a={level:r[1].length,title:r[4].trim(),...r[2]?{state:r[2]}:{},...r[3]?{priority:r[3]}:{},properties:[],descriptions:[],body:[]},o=!1,s=null,c=0;continue}if(!a){let r=Vf.exec(e);r?t.push([r[1].toUpperCase(),r[2].trim()]):n.push(e);continue}if(e===`:PROPERTIES:`){o=!0;continue}if(o&&e===`:END:`){o=!1,s=null,c=0;continue}if(o){let t=Hf.exec(e);t&&a.properties.push([t[1],t[2].trim()]);continue}let i=Uf.exec(e);if(i)a.descriptions.push([i[1].trim(),i[2].trim()]),s=a.descriptions.length-1,c=0;else if(s!==null&&/^[ \t]+\S/.test(e)){let[t,n]=a.descriptions[s];a.descriptions[s]=[t,`${n}${`
28
28
  `.repeat(c+1)}${e.replace(/^(?: |\t)/,``)}`],c=0}else s!==null&&!e.trim()?c+=1:(s=null,c=0,a.body.push(e))}return l(),{metadata:t,preamble:Gf(n),sections:r}}function Gf(e){let t=[...e];for(;t[0]?.trim()===``;)t.shift();for(;t.at(-1)?.trim()===``;)t.pop();return t}var Kf=q(`<div class="svelte-h7gaqo"><dt class="svelte-h7gaqo"> </dt> <dd class="svelte-h7gaqo"><!></dd></div>`),qf=q(`<dl class="metadata svelte-h7gaqo"></dl>`),Jf=q(`<p class="svelte-h7gaqo"><!></p>`),Yf=q(`<p class="svelte-h7gaqo">This Org document has no headings.</p>`),Xf=q(`<h3 class="svelte-h7gaqo"> </h3>`),Zf=q(`<h4 class="svelte-h7gaqo"> </h4>`),Qf=q(`<span> </span>`),$f=q(`<span class="priority svelte-h7gaqo"> </span>`),ep=q(`<dl class="descriptions svelte-h7gaqo"></dl>`),tp=q(`<p><!></p>`),np=q(`<details class="properties svelte-h7gaqo"><summary class="svelte-h7gaqo">Properties</summary> <dl class="svelte-h7gaqo"></dl></details>`),rp=q(`<section class="org-section svelte-h7gaqo"><div class="section-heading svelte-h7gaqo"><!> <!> <!></div> <!> <!> <!></section>`),ip=q(`<div class="sections svelte-h7gaqo"></div>`),ap=q(`<article class="org-document svelte-h7gaqo" aria-labelledby="org-document-title"><header class="svelte-h7gaqo"><div><h2 id="org-document-title" class="svelte-h7gaqo"> </h2> <code class="svelte-h7gaqo"> </code></div> <button class="close svelte-h7gaqo" type="button" aria-label="Close plan and return to list">×</button></header> <!> <!> <!></article>`);function op(e,t){$e(t,!0);let n=$(t,`verifiedReferences`,19,()=>new Set),r=L(()=>Wf(t.preview.source)),i=L(()=>G(r).metadata.filter(([e])=>e!==`TITLE`));var a=ap(),o=V(a),s=V(o),c=V(s),l=V(c,!0);P(c);var u=U(c,2),d=V(u,!0);P(u),P(s);var f=U(s,2);P(o);var p=U(o,2),m=e=>{var r=qf();Z(r,21,()=>G(i),([e,t])=>`${e}:${t}`,(e,r)=>{var i=L(()=>C(G(r),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=Kf(),c=V(s),l=V(c,!0);P(c);var u=U(c,2),d=V(u);{let e=L(()=>o()||`—`);df(d,{get text(){return G(e)},get onreference(){return t.onreference},get verifiedReferences(){return n()}})}P(u),P(s),W(()=>Y(l,a())),J(e,s)}),P(r),J(e,r)};X(p,e=>{G(i).length&&e(m)});var h=U(p,2);Z(h,19,()=>G(r).preamble,(e,t)=>`preamble:${t}:${e}`,(e,r)=>{var i=Kr(),a=H(i),o=e=>{var i=Jf();df(V(i),{get text(){return G(r)},get onreference(){return t.onreference},get verifiedReferences(){return n()}}),P(i),J(e,i)},s=L(()=>G(r).trim());X(a,e=>{G(s)&&e(o)}),J(e,i)});var g=U(h,2),_=e=>{J(e,Yf())},v=e=>{var i=ip();Z(i,23,()=>G(r).sections,(e,t)=>`${t}:${e.level}:${e.title}`,(e,r)=>{var i=rp();let a;var o=V(i),s=V(o),c=e=>{var t=Xf(),n=V(t,!0);P(t),W(()=>Y(n,G(r).title)),J(e,t)},l=e=>{var t=Zf(),n=V(t,!0);P(t),W(()=>Y(n,G(r).title)),J(e,t)};X(s,e=>{G(r).level===1?e(c):e(l,-1)});var u=U(s,2),d=e=>{var t=Qf(),n=V(t,!0);P(t),W(e=>{Si(t,1,e,`svelte-h7gaqo`),Y(n,G(r).state)},[()=>`state state-${G(r).state.toLowerCase()}`]),J(e,t)};X(u,e=>{G(r).state&&e(d)});var f=U(u,2),p=e=>{var t=$f(),n=V(t);P(t),W(()=>Y(n,`Priority ${G(r).priority??``}`)),J(e,t)};X(f,e=>{G(r).priority&&e(p)}),P(o);var m=U(o,2),h=e=>{var i=ep();Z(i,21,()=>G(r).descriptions,([e,t])=>`${e}:${t}`,(e,r)=>{var i=L(()=>C(G(r),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=Kf(),c=V(s),l=V(c,!0);P(c);var u=U(c,2),d=V(u);{let e=L(()=>o()||`—`);df(d,{get text(){return G(e)},get onreference(){return t.onreference},get verifiedReferences(){return n()}})}P(u),P(s),W(()=>Y(l,a())),J(e,s)}),P(i),J(e,i)};X(m,e=>{G(r).descriptions.length&&e(h)});var g=U(m,2);Z(g,19,()=>G(r).body,(e,t)=>`${t}:${e}`,(e,r)=>{var i=Kr(),a=H(i),o=e=>{var i=tp();let a;df(V(i),{get text(){return G(r)},get onreference(){return t.onreference},get verifiedReferences(){return n()}}),P(i),W(e=>a=Si(i,1,`svelte-h7gaqo`,null,a,e),[()=>({"list-item":G(r).trimStart().startsWith(`- `)})]),J(e,i)},s=L(()=>G(r).trim());X(a,e=>{G(s)&&e(o)}),J(e,i)});var _=U(g,2),v=e=>{var i=np(),a=U(V(i),2);Z(a,21,()=>G(r).properties,([e,t])=>`${e}:${t}`,(e,r)=>{var i=L(()=>C(G(r),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=Kf(),c=V(s),l=V(c,!0);P(c);var u=U(c,2),d=V(u);{let e=L(()=>o()||`—`);df(d,{get text(){return G(e)},get onreference(){return t.onreference},get verifiedReferences(){return n()}})}P(u),P(s),W(()=>Y(l,a())),J(e,s)}),P(a),P(i),J(e,i)};X(_,e=>{G(r).properties.length&&e(v)}),P(i),W(e=>a=wi(i,``,a,e),[()=>({"--org-depth":Math.max(0,G(r).level-1)})]),J(e,i)}),P(i),J(e,i)};X(g,e=>{G(r).sections.length===0?e(_):e(v,-1)}),P(a),W(()=>{Y(l,t.preview.title),Y(d,t.preview.planName)}),K(`click`,f,function(...e){t.onclose?.apply(this,e)}),J(e,a),et()}Rr([`click`]);var sp=q(`<span> </span>`),cp=q(`<span class="subtitle svelte-x2ko9l"> </span>`),lp=q(`<div class="catalog-progress svelte-x2ko9l"><progress class="svelte-x2ko9l"> </progress> <span class="svelte-x2ko9l"> </span></div> <!>`,1),up=q(`<span class="subtitle svelte-x2ko9l">Org document</span>`),dp=q(`<span class="archive-tag svelte-x2ko9l">Archived</span>`),fp=q(`<li class="plan-row svelte-x2ko9l"><div class="plan-details svelte-x2ko9l"><strong> </strong> <div class="plan-path svelte-x2ko9l"><!> <span> </span></div> <!> <!></div> <div class="plan-actions svelte-x2ko9l"><!> <!></div></li>`),pp=q(`<p>Waiting for the application workspace…</p>`),mp=q(`<p>Finding Org plans…</p>`),hp=q(`<p> </p>`),gp=q(`<p>No .org files were found in .gestalt folders below the application workspace.</p>`),_p=q(`<ul aria-label="Unfinished plans" class="svelte-x2ko9l"></ul>`),vp=q(`<section class="completed svelte-x2ko9l" aria-labelledby="completed-plans-title"><h3 id="completed-plans-title" class="svelte-x2ko9l">Completed and archived</h3> <ul aria-label="Completed and archived plans" class="svelte-x2ko9l"></ul></section>`),yp=q(`<p class="scope svelte-x2ko9l">Org plans in .gestalt folders below the application workspace.</p> <!> <!>`,1),bp=q(`<section class="plans svelte-x2ko9l" aria-labelledby="plans-title"><div class="catalog-heading svelte-x2ko9l"><h2 id="plans-title" tabindex="-1" class="svelte-x2ko9l">ORG Plans</h2> <span role="status">(updating…)</span></div> <!></section>`);function xp(e,t){$e(t,!0);let n=(e,n=b)=>{let i=L(()=>n().planName.split(`/`)),a=L(()=>G(i).slice(0,-1)),s=L(()=>G(a).slice(0,2).filter((e,t)=>t===0||e!==`.gestalt`).join(`/`));var c=fp(),l=V(c),u=V(l),d=V(u,!0);P(u);var f=U(u,2),p=V(f),g=e=>{var t=sp(),n=V(t,!0);P(t),W(()=>Y(n,G(s))),J(e,t)};X(p,e=>{G(s)&&e(g)});var _=U(p,2),v=V(_,!0);P(_),P(f);var y=U(f,2),x=e=>{var t=lp(),r=H(t),i=V(r),a=V(i);P(i);var o=U(i,2),s=V(o);P(o),P(r);var c=U(r,2),l=e=>{var t=cp(),r=V(t,!0);P(t),W(()=>Y(r,n().subtitle)),J(e,t)};X(c,e=>{n().subtitle&&e(l)}),W(e=>{Q(i,`aria-label`,`Completion for ${n().title}`),Pi(i,n().doneSteps),Q(i,`max`,e),Y(a,`${n().doneSteps??``} of ${n().totalSteps??``} work items complete`),Y(s,`${n().doneSteps??``} / ${n().totalSteps??``}`)},[()=>Math.max(1,n().totalSteps)]),J(e,t)},S=e=>{J(e,up())};X(y,e=>{n().previewAvailable!==!1&&n().totalSteps!==void 0&&n().doneSteps!==void 0?e(x):e(S,-1)});var C=U(y,2),w=e=>{J(e,dp())};X(C,e=>{n().archived&&e(w)}),P(l);var T=U(l,2),E=V(T);{let e=L(()=>`${n().allDone||n().archived?`Reopen`:`Open`} ${n().title}`);Ya(E,{get label(){return G(e)},onclick:()=>m(n().planName),children:(e,t)=>{Ue();var r=Gr();W(()=>Y(r,n().allDone||n().archived?`Reopen`:`Open`)),J(e,r)},$$slots:{default:!0}})}var D=U(E,2),ee=e=>{{let i=L(()=>`Archive ${n().title}`),a=L(()=>!t.onarchive||n().archived||r().includes(n().planName));Ya(e,{get label(){return G(i)},get disabled(){return G(a)},onclick:()=>h(n().planName),children:(e,t)=>{Ue();var i=Gr();W(e=>Y(i,e),[()=>r().includes(n().planName)?`Archiving…`:`Archive`]),J(e,i)},$$slots:{default:!0}})}};X(D,e=>{!n().allDone&&!n().archived&&e(ee)}),P(T),P(c),Ui(c,e=>o[n().planName]=e,()=>o?.[n().planName]),W(e=>{Q(c,`aria-label`,`${n().title} (${n().planName})`),Y(d,n().title),Q(f,`title`,n().planName),Y(v,e)},[()=>G(i).at(-1)]),J(e,c)},r=$(t,`archivingPlans`,19,()=>[]),i=z(on(new Set));Mn(()=>{let e=sf(t.state),n=t.checkreferences,r=new AbortController;return B(i,new Set,!0),e.length&&n&&n(e,r.signal).then(e=>{r.signal.aborted||B(i,new Set(e),!0)}).catch(()=>{}),()=>r.abort()});let a=z(null),o=on({}),s=z(null),c=z(null),l=!1,u=!1,d=L(()=>t.catalog.kind===`ready`?t.catalog.entries.filter(e=>e.allDone!==!0&&!e.archived):[]),f=L(()=>t.catalog.kind===`ready`?t.catalog.entries.filter(e=>e.allDone===!0||e.archived):[]);function p(){t.onclose()}function m(e){B(c,e,!0),t.onopen(e)}function h(e){B(s,e,!0),t.onarchive?.(e)}Mn(()=>{let e=G(s);if(e&&t.catalog.kind===`ready`&&t.catalog.entries.some(t=>t.planName===e&&t.archived)&&queueMicrotask(()=>{o[e]?.querySelector(`button`)?.focus(),B(s,null)}),t.state){l=!0;return}if(l&&(l=!1,u=!0),!u)return;let n=t.catalog.kind,r=G(c);queueMicrotask(()=>{let e=r?o[r]?.querySelector(`button`):void 0;e?.isConnected?(e.focus(),u=!1):n!==`loading`&&(G(a)?.focus(),u=!1)})});var g=Kr(),_=H(g),v=e=>{op(e,{get preview(){return t.state},onclose:p,get onreference(){return t.onreference},get verifiedReferences(){return G(i)}})},y=e=>{zf(e,{get state(){return t.state},onclose:p,get onreference(){return t.onreference},get verifiedReferences(){return G(i)}})},x=e=>{var r=bp(),i=V(r),o=V(i);Ui(o,e=>B(a,e),()=>G(a));var s=U(o,2);P(i);var c=U(i,2),l=e=>{J(e,pp())},u=e=>{J(e,mp())},p=e=>{var n=hp(),r=V(n,!0);P(n),W(()=>Y(r,t.catalog.error)),J(e,n)},m=e=>{J(e,gp())},h=e=>{var t=yp(),r=U(H(t),2),i=e=>{var t=_p();Z(t,21,()=>G(d),e=>e.planName,(e,t)=>{n(e,()=>G(t))}),P(t),J(e,t)};X(r,e=>{G(d).length>0&&e(i)});var a=U(r,2),o=e=>{var t=vp(),r=U(V(t),2);Z(r,21,()=>G(f),e=>e.planName,(e,t)=>{n(e,()=>G(t))}),P(r),P(t),J(e,t)};X(a,e=>{G(f).length>0&&e(o)}),J(e,t)};X(c,e=>{t.catalog.kind===`no-workspace`?e(l):t.catalog.kind===`loading`?e(u,1):t.catalog.kind===`error`?e(p,2):t.catalog.entries.length===0?e(m,3):e(h,-1)}),P(r),W(()=>{Si(s,1,gi([`catalog-update`,{inactive:t.catalog.kind!==`ready`||!t.catalog.refreshing}]),`svelte-x2ko9l`),Q(s,`aria-hidden`,t.catalog.kind!==`ready`||!t.catalog.refreshing)}),J(e,r)};X(_,e=>{t.state?.kind===`org-source`?e(v):t.state?e(y,1):e(x,-1)}),J(e,g),et()}var Sp=`settings`,Cp=`drafts`,wp=`cursors`,Tp=`selected-session`,Ep={text:``,revision:0},Dp=e=>{if(!e||typeof e!=`object`)return!1;let t=e,n=t.pending;return typeof t.text==`string`&&Number.isSafeInteger(t.revision)&&t.revision>=0&&(n===void 0||Array.isArray(n)&&n.every(e=>!!e&&typeof e.operationId==`string`&&typeof e.text==`string`&&Number.isSafeInteger(e.revision)&&e.revision>=0&&(e.kind===`send`||e.kind===`queue`||e.kind===`interrupt-send`)))};function Op(e=globalThis.indexedDB){if(!e)return kp;let t=Fl(e),n=new Map,r=new Map,i=async(e,i)=>{let a=r.get(e);if(a&&a.revision>i.revision)return;r.set(e,i);let o=(n.get(e)??Promise.resolve()).catch(()=>void 0).then(async()=>{if(r.get(e)===i)try{await Ll(await t,Cp,e,i)}catch{}});n.set(e,o),await o};return{async readSelectedSession(){try{return await Il(await t,Sp,Tp)??null}catch{return null}},async saveSelectedSession(e){try{let n=await t;e?await Ll(n,Sp,Tp,e):await Rl(n,Sp,Tp)}catch{}},async readDraft(e){return(await this.readDraftEnvelope(e)).text},async saveDraft(e,t){let n=await this.readDraftEnvelope(e);await i(e,{text:t,revision:n.revision+1})},async readDraftEnvelope(e){try{let n=await Il(await t,Cp,e),i=Dp(n)?n:typeof n==`string`?{text:n,revision:0}:Ep,a=r.get(e);return a&&a.revision>=i.revision?a:(r.set(e,i),i)}catch{return r.get(e)??Ep}},saveDraftEnvelope:i,replaceDraftText:async(e,t,n)=>{let a=r.get(e);await i(e,{text:t,revision:n,pending:a?.pending})},addPendingDraftOperation:async(e,t)=>{let n=r.get(e)??Ep;await i(e,{...n,pending:[...(n.pending??[]).filter(e=>e.operationId!==t.operationId),t].slice(-8)})},consumeAcceptedDraft:async(e,i,a)=>{let o=n.get(e)??Promise.resolve(),s=null,c=o.catch(()=>void 0).then(async()=>{let n=r.get(e);if(!n)try{let r=await Il(await t,Cp,e);n=Dp(r)?r:typeof r==`string`?{text:r,revision:0}:Ep}catch{n=Ep}if(!(n.revision!==i||!n.pending?.some(e=>e.operationId===a))){s={text:``,revision:n.revision+1,pending:n.pending.filter(e=>e.operationId!==a)},r.set(e,s);try{await Ll(await t,Cp,e,s)}catch{r.get(e)===s&&r.set(e,n),s=null}}});return n.set(e,c),await c,s},async readCursor(e){try{let n=await Il(await t,wp,e);return typeof n==`number`&&Number.isSafeInteger(n)&&n>=0?n:0}catch{return 0}},async saveCursor(e,n){try{await Ll(await t,wp,e,n)}catch{}}}}var kp={readSelectedSession:async()=>null,saveSelectedSession:async()=>{},readDraft:async()=>``,saveDraft:async()=>{},readDraftEnvelope:async()=>Ep,saveDraftEnvelope:async()=>{},replaceDraftText:async()=>{},addPendingDraftOperation:async()=>{},consumeAcceptedDraft:async()=>null,readCursor:async()=>0,saveCursor:async()=>{}};function Ap(e,t=Date.now()){if(e===null)return`Unknown activity time`;let n=Math.max(0,t-e),r=Math.floor(n/(3600*1e3));if(r<1)return`Less than an hour ago`;if(r<24)return`${r} hour${r===1?``:`s`} ago`;let i=Math.floor(r/24);return`${i} day${i===1?``:`s`} ago`}function jp(e){return!!(e?.plan||e?.lastOrgPlan?.attached)}function Mp(e){let t=e.updatedAt?Date.parse(e.updatedAt):NaN;return{threadId:e.threadId??null,workspacePath:e.workspacePath??`Workspace unavailable`,updatedAt:Number.isFinite(t)?t:null}}function Np(e,t){if(!t?.threadId||!t.workspacePath||!t.resumeCommand||e.some(e=>e.id===t.threadId&&(e.provider??`codex`)===(t.provider??`codex`)))return e;let n=t.updatedAt?Date.parse(t.updatedAt)/1e3:NaN,r={id:t.threadId,cwd:t.workspacePath,recencyAt:Number.isFinite(n)?n:null,resumeCommand:t.resumeCommand,...t.provider===void 0?{}:{provider:t.provider},...t.model===void 0?{}:{model:t.model},...t.effectiveSkillSelection?.selectedProfileName===void 0?{}:{skillProfile:t.effectiveSkillSelection.selectedProfileName},...t.lastOrgPlan===void 0?{}:{orgPlanFilename:t.lastOrgPlan.filename}};return[...e,r].sort((e,t)=>(t.recencyAt??-1/0)-(e.recencyAt??-1/0))}function Pp(e){let t=/^\/home\/[^/]+/.exec(e)?.[0];if(!t)return e;let n=e.slice(t.length);return n?`~${n}`:`~/`}var Fp=[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`],Ip=(e,t=b)=>{var n=Bp(),r=H(n),i=e=>{J(e,Lp())},a=L(()=>jp(t()));X(r,e=>{G(a)&&e(i)});var o=U(r,2),s=e=>{var n=Rp(),r=V(n),i=V(r,!0);P(r);var a=U(r,2),o=V(a,!0);P(a),P(n),W(()=>{Y(i,t().lastOrgPlan.title),Y(o,t().lastOrgPlan.filename)}),J(e,n)};X(o,e=>{t().lastOrgPlan&&e(s)});var c=U(o,2),l=e=>{var n=zp(),r=V(n);{let e=L(()=>`Plan progress for ${t().plan.title}`);xf(r,{compact:!0,get plan(){return t().plan},get label(){return G(e)}})}P(n),J(e,n)};X(c,e=>{t().plan&&e(l)}),J(e,n)},Lp=q(`<span class="profile-badge svelte-hxb22h">Org plan attached</span>`),Rp=q(`<span class="org-plan-metadata svelte-hxb22h"><span class="org-plan-title svelte-hxb22h"> </span> <span class="org-plan-filename svelte-hxb22h"> </span></span>`),zp=q(`<div class="session-plan-progress svelte-hxb22h"><!></div>`),Bp=q(`<!> <!> <!>`,1),Vp=q(`<details class="self-debug-details svelte-hxb22h"><summary class="svelte-hxb22h">Self DEBUG</summary> <!> <button type="button" class="svelte-hxb22h">Redacted diagnostic trace (JSON)</button></details>`),Hp=q(`<!> <!>`,1),Up=q(`<details class="session-verdict svelte-hxb22h"><summary class="svelte-hxb22h"><span aria-hidden="true"></span> </summary> <p class="svelte-hxb22h"> </p></details>`),Wp=q(`<time class="svelte-hxb22h"> </time>`),Gp=q(`<div class="svelte-hxb22h"> </div>`),Kp=q(`<span class="profile-badge svelte-hxb22h"> </span>`),qp=q(`<span class="profile-badge svelte-hxb22h">Kimi</span>`),Jp=q(`<li><div class="session-actions svelte-hxb22h" aria-label="Session actions"><!> <!> <!> <!></div> <div class="session-details svelte-hxb22h"><!> <div class="session-summary svelte-hxb22h"><!> <!> <div class="workspace-path svelte-hxb22h"> </div> <!> <!> <!> <!> <!></div> <!> <!></div></li>`),Yp=q(`<section aria-labelledby="open-sessions-title" class="svelte-hxb22h"><h3 id="open-sessions-title" class="svelte-hxb22h">Open sessions</h3> <ul class="session-list svelte-hxb22h" aria-label="Open sessions"></ul></section>`),Xp=q(`<li class="managed-session svelte-hxb22h"><div class="session-actions svelte-hxb22h"><!> <!> <!></div> <div class="session-details svelte-hxb22h"><!> <!> <div class="workspace-path svelte-hxb22h"> </div> <!> <!> <!> <!> <!></div></li>`),Zp=q(`<ul class="session-list svelte-hxb22h" aria-label="Saved sessions"></ul>`),Qp=q(`<p class="svelte-hxb22h">No saved sessions yet.</p>`),$p=q(`<option class="svelte-hxb22h"> </option>`),em=q(`<option class="svelte-hxb22h">Loading models…</option>`),tm=q(`<option class="svelte-hxb22h">Choose automatically</option>`),nm=q(`<p class="skills-profile-error svelte-hxb22h" role="alert"> </p>`),rm=q(`<fieldset class="executor-settings svelte-hxb22h"><legend class="svelte-hxb22h">Org-plan executor</legend> <label for="executor-model" class="svelte-hxb22h">Executor model <select id="executor-model" class="svelte-hxb22h"></select></label> <label for="executor-thinking" class="svelte-hxb22h">Executor thinking <select id="executor-thinking" class="svelte-hxb22h"></select></label></fieldset>`),im=q(`<label for="model-thinking" class="svelte-hxb22h">Model thinking <select id="model-thinking" class="svelte-hxb22h"></select></label>`),am=q(`<label for="sandbox" class="svelte-hxb22h">Sandbox</label> <label for="approval-policy" class="svelte-hxb22h">Approval policy</label>`,1),om=q(`<select id="sandbox" class="svelte-hxb22h"><option class="svelte-hxb22h">workspace-git (Git writable)</option><option class="svelte-hxb22h">workspace-write</option><option class="svelte-hxb22h">read-only</option><option class="svelte-hxb22h">danger-full-access</option></select> <select id="approval-policy" class="svelte-hxb22h"><option class="svelte-hxb22h">Ask on all commands</option><option class="svelte-hxb22h">Ask out of workspace</option><option class="svelte-hxb22h">Never ask for approval</option></select>`,1),sm=q(`<li class="recent-session svelte-hxb22h"><div class="session-details svelte-hxb22h"><!> <div class="workspace-path svelte-hxb22h"> </div> <!> <!> <!> <!></div> <div class="session-actions svelte-hxb22h"><!> <!></div></li>`),cm=q(`<ul class="session-list recent-session-list svelte-hxb22h" aria-label="Recent sessions"></ul>`),lm=q(`<p class="svelte-hxb22h">No other recent sessions found.</p>`),um=q(`<dialog aria-labelledby="close-session-title" class="svelte-hxb22h"><h2 id="close-session-title" class="svelte-hxb22h">Close session?</h2> <p class="svelte-hxb22h">You can reopen this session from the session list.</p> <div class="dialog-actions svelte-hxb22h"><!> <!></div></dialog> <section aria-labelledby="sessions-title" class="svelte-hxb22h"><h2 id="sessions-title" class="visually-hidden svelte-hxb22h">Sessions</h2> <!> <!> <form class="svelte-hxb22h"><h3 class="new-session-title svelte-hxb22h">New session</h3> <div class="session-base svelte-hxb22h"><!></div> <div class="essential-settings svelte-hxb22h"><label for="skills-profile" class="svelte-hxb22h">Skills profile <select id="skills-profile" class="svelte-hxb22h"><option class="svelte-hxb22h">Default</option><!></select></label> <label for="model" class="svelte-hxb22h">Model <select id="model" class="svelte-hxb22h"><!><!></select></label></div> <!> <details class="advanced-settings svelte-hxb22h"><summary class="svelte-hxb22h">Advanced settings</summary> <div class="advanced-content svelte-hxb22h"><section class="session-settings svelte-hxb22h" aria-label="New session settings"><div class="advanced-model-settings svelte-hxb22h"><!> <fieldset class="supervisor-settings svelte-hxb22h"><legend class="svelte-hxb22h">Main supervisor</legend> <!> <div class="provider-control svelte-hxb22h"><label for="session-provider" class="svelte-hxb22h">Provider</label> <select id="session-provider" class="svelte-hxb22h"><option class="svelte-hxb22h">Codex</option><option class="svelte-hxb22h"> </option></select></div></fieldset></div> <div class="session-setting-labels svelte-hxb22h"><!></div> <div class="session-setting-controls svelte-hxb22h"><!></div> <div class="session-secondary-actions svelte-hxb22h"><!> <!></div></section></div></details> <div class="create-session-actions svelte-hxb22h"><!></div></form> <section aria-labelledby="recent-sessions-title" class="svelte-hxb22h"><h3 id="recent-sessions-title" class="svelte-hxb22h">Recent sessions</h3> <!></section></section>`,1);function dm(e,t){$e(t,!0);let n=(e,t=b)=>{var n=Kr(),r=H(n),i=e=>{var n=Vp(),r=U(V(n),2);Ma(r,{get context(){return t().selfDebug.context}});var i=U(r,2);P(n),K(`click`,i,e=>ee()(t(),e.currentTarget)),J(e,n)};X(r,e=>{t().selfDebug&&e(i)}),J(e,n)},r=$(t,`activitySnapshots`,19,()=>new Map),i=$(t,`autopilotSnapshots`,19,()=>new Map),a=$(t,`autopilotPending`,19,()=>new Set),o=$(t,`autopilotAttention`,19,()=>new Map),s=$(t,`models`,19,()=>[]),c=$(t,`selectedModel`,3,``),l=$(t,`reasoningEffort`,3,`medium`),u=$(t,`executorModels`,19,()=>[]),d=$(t,`executorModel`,3,`gpt-5.6-terra`),f=$(t,`executorReasoningEffort`,3,`high`),p=$(t,`onreasoningchange`,3,()=>{}),m=$(t,`onexecutormodelchange`,3,()=>{}),h=$(t,`onexecutorreasoningchange`,3,()=>{}),g=$(t,`provider`,3,`codex`),_=$(t,`kimiAvailable`,3,!1),v=$(t,`modelsLoading`,3,!1),y=$(t,`onmodelchange`,3,()=>{}),x=$(t,`onproviderchange`,3,()=>{}),S=$(t,`onautopilottoggle`,3,()=>{}),C=$(t,`onactivityopen`,3,()=>{}),w=$(t,`onautopilotresolve`,3,()=>{}),T=$(t,`savingDefaults`,3,!1),E=$(t,`advancedExpanded`,15,!1),D=$(t,`onsavedefaults`,3,()=>{}),ee=$(t,`ondebugtrace`,3,()=>{}),te=L(()=>t.sessions.filter(e=>e.state===`ready`||e.state===`turnActive`)),ne=L(()=>t.sessions.filter(e=>e.state!==`ready`&&e.state!==`turnActive`)),re=L(()=>t.recentSessions.filter(e=>!G(te).some(t=>t.threadId===e.id&&(t.provider??`codex`)===(e.provider??`codex`)))),ie=L(()=>fd(t.workspaceTree,t.workspaceId)),ae=z(null),oe=z(null);function se(e){B(oe,e,!0),G(ae)?.showModal()}var ce=um(),le=H(ce),ue=U(V(le),4),de=V(ue);Ya(de,{onclick:()=>G(ae)?.close(),children:(e,t)=>{Ue(),J(e,Gr(`Cancel`))},$$slots:{default:!0}}),Ya(U(de,2),{primary:!0,onclick:()=>{G(oe)&&t.onclose(G(oe)),G(ae)?.close()},children:(e,t)=>{Ue(),J(e,Gr(`Close session`))},$$slots:{default:!0}}),P(ue),P(le),Ui(le,e=>B(ae,e),()=>G(ae));var O=U(le,2),fe=U(V(O),2),pe=e=>{var c=Yp(),l=U(V(c),2);Z(l,21,()=>G(te),e=>e.id,(e,c)=>{let l=L(()=>Mp(G(c))),u=L(()=>Bu(G(c).sessionStatus)?G(c).sessionStatus:null);var d=Jp();let f;var p=V(d),m=V(p);{let e=L(()=>G(c).id===t.selectedSessionId?`page`:void 0);Ya(m,{compact:!0,full:!0,get current(){return G(e)},onclick:()=>t.onselectopen(G(c).id),children:(e,t)=>{Ue(),J(e,Gr(`Open`))},$$slots:{default:!0}})}var h=U(m,2),g=e=>{Ya(e,{compact:!0,full:!0,onclick:()=>t.oncopyresume(G(c).resumeCommand),children:(e,t)=>{Ue(),J(e,Gr(`Copy CLI`))},$$slots:{default:!0}})};X(h,e=>{G(c).resumeCommand&&G(c).provider!==`kimi`&&e(g)});var _=U(h,2),v=e=>{var t=Hp(),n=H(t),o=e=>{{let t=L(()=>i().get(G(c).id)??G(c).autopilot??null),n=L(()=>`session-autopilot-${G(c).id}`),r=L(()=>a().has(G(c).id));jo(e,{compact:!0,indicatorOnly:!0,get autopilot(){return G(t)},get controlId(){return G(n)},get pending(){return G(r)},ontoggle:e=>S()(G(c).id,e)})}};X(n,e=>{G(c).provider!==`kimi`&&e(o)});var l=U(n,2);{let e=L(()=>r().get(G(c).id)??G(c).agentActivity??null),t=L(()=>G(c).model??s()?.[0]);so(l,{compact:!0,get activity(){return G(e)},get rootModel(){return G(t)},get plan(){return G(c).plan},onopen:()=>C()(G(c).id)})}J(e,t)},y=L(()=>jp(G(c)));X(_,e=>{G(y)&&e(v)}),Ya(U(_,2),{compact:!0,full:!0,onclick:()=>se(G(c).id),children:(e,t)=>{Ue(),J(e,Gr(`Close`))},$$slots:{default:!0}}),P(p);var b=U(p,2),x=V(b);n(x,()=>G(c));var T=U(x,2),E=V(T),D=e=>{var t=Up(),n=V(t),r=V(n);let i;var a=U(r);P(n);var o=U(n,2),s=V(o);P(o),P(t),W(()=>{Q(t,`data-state`,G(u).state),Q(t,`aria-label`,`${G(u).state===`working`?`Working`:`Idle`}: ${G(u).reason}`),Q(n,`aria-label`,`${G(u).state===`working`?`Working`:`Idle`}: ${G(u).reason}`),i=Si(r,1,`verdict-dot svelte-hxb22h`,null,i,{live:G(u).state===`working`&&G(u).confidence===`fresh`}),Y(a,` ${G(u).state===`working`?`Working`:`Idle`}`),Y(s,`${G(u).reason??``}. ${G(u).nextExpectedAction??``}
@@ -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-CxuAg7aj.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-IkBR-U3-.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-DEzZEQhF.css">
21
21
  </head>
22
22
  <body>
@@ -3,6 +3,7 @@
3
3
  * Designed by Denis Roio <jaromil@dyne.org>
4
4
  * SPDX-License-Identifier: AGPL-3.0-or-later
5
5
  */
6
+ import { currentExecutableL1Index, } from '../../plans/domain/supervised-plan.js';
6
7
  import { parseOrgPlanAgentIdentity } from '../../../../shared/org-plan-position.js';
7
8
  export const AUTOPILOT_PROMPT_VERSION = 'v13';
8
9
  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. Spawn exactly one executor per L1 and pass the exact literal task_name l<a>: l1 for L1, l2 for L2, and so on. Never create an L2-specific task name or append a title, role, nickname, plan name, or generated label. A validated DONE L2 and an accepted L1 are mandatory answer boundaries. The corresponding gestalt_org_plan_checkpoint call must be the last tool call of that root turn: immediately emit exactly one boundary final and end the turn, without followup_task, review, executor launch, or later milestone work. An accepted L1 always ends the root turn with a chat answer: never continue into the next L1 or emit post-acceptance documentation as commentary. Roll up commentary, files, verification, and commands since the previous boundary into that one answer; all later milestone activity belongs to a new root turn. On this later Autopilot turn, resume the same executor after an L2 boundary or launch exactly one fresh canonical executor for the next L1 after an accepted-L1 boundary. Treat a status question as an interruption: answer briefly, then perform the applicable 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. When explicit human permission is required for a physical executor replacement, include executorReplacement with the exact canonicalTaskName; Mobile alone computes and persists the physical generation. Do not call attention 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. Yield only when its response contains accepted:true; accepted:false means no continuation was registered and requires same-turn supervision. 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.';
@@ -56,8 +57,9 @@ export function classifyAgentActivity(activity) {
56
57
  * topology cannot indefinitely turn a fresh read into a reconciliation loop.
57
58
  */
58
59
  function classifySupervisedActivity(activity, plan) {
59
- const selected = plan.steps.findIndex((step) => step.id === plan.currentStepId || step.state === 'WIP');
60
- const index = selected >= 0 ? selected : plan.steps.findIndex((step) => step.state !== 'DONE');
60
+ const executable = currentExecutableL1Index(plan);
61
+ // A checkpoint authorizes a supervisor turn to resume the barrier, never executor dispatch.
62
+ const index = executable >= 0 ? executable : plan.steps.findIndex((step) => step.state === 'SUSPENDED');
61
63
  if (index < 0)
62
64
  return classifyAgentActivity(activity);
63
65
  const position = index + 1;
@@ -79,6 +81,11 @@ function classifySupervisedActivity(activity, plan) {
79
81
  if (!match)
80
82
  return true;
81
83
  const historical = Number(match[1]) < position;
84
+ const suspended = plan.steps[Number(match[1]) - 1]?.state === 'SUSPENDED';
85
+ if (suspended &&
86
+ ['idle', 'blocked', 'disconnected'].includes(child.state) &&
87
+ !child.ownedProcesses?.some((process) => process.state === 'running' || process.state === 'detached-active'))
88
+ return false;
82
89
  const supervisedProcess = child.ownedProcesses?.some((process) => process.ownership === 'supervisor' &&
83
90
  (process.state === 'running' || process.state === 'detached-active'));
84
91
  return !historical || supervisedProcess;
@@ -142,6 +149,10 @@ export function decideAutopilot(input) {
142
149
  };
143
150
  return { kind: 'complete' };
144
151
  }
152
+ if (plan.steps.some((step) => step.state === 'SUSPENDED') &&
153
+ currentExecutableL1Index(plan) < 0 &&
154
+ !state.checkpoints?.rootContinuationFromTurnId)
155
+ return { kind: 'observe' };
145
156
  // Quiz, approval, and other held requests are ordinary session work. Only a
146
157
  // validated Org attention record may turn an incomplete plan into a human stop.
147
158
  if (hasPendingInteraction)
@@ -8,6 +8,7 @@ import { AutopilotStateError } from '../domain/persisted-state-error.js';
8
8
  import { canTransitionExecutorCommand, retainExecutorCommands, } from '../domain/executor-commands.js';
9
9
  import { deriveSessionStatus } from '../../sessions/session-status.js';
10
10
  import { createHash } from 'node:crypto';
11
+ import { currentExecutableL1Index, } from '../../plans/domain/supervised-plan.js';
11
12
  import { AUTOPILOT_WAIT_MAX_MS, AUTOPILOT_WAIT_MIN_MS, } from '../../../../shared/contracts/autopilot-wait-lease.js';
12
13
  import { autopilotSnapshot, disabledAutopilot, } from '../domain/autopilot-session.js';
13
14
  import { classifyExecutorOutcome, decideSupervisedLifecycle, executorIdentity, validStructuredBlock, checkpointTarget, executorAssignment, } from '../domain/supervised-lifecycle.js';
@@ -874,6 +875,24 @@ export class AutopilotCoordinator {
874
875
  return;
875
876
  }
876
877
  this.supersedeExecutorCommands(sessionId, plan.identity, plan.plan);
878
+ const retainedExecutor = this.deps.store.find(sessionId)?.executor;
879
+ const assignedStep = retainedExecutor
880
+ ? plan.plan.steps[Number(retainedExecutor.canonicalPosition.slice(1)) - 1]
881
+ : undefined;
882
+ if (retainedExecutor &&
883
+ assignedStep?.state === 'SUSPENDED' &&
884
+ retainedExecutor.l1State !== 'SUSPENDED') {
885
+ const latest = this.deps.store.find(sessionId);
886
+ this.persist({
887
+ ...latest,
888
+ executor: {
889
+ ...retainedExecutor,
890
+ l1State: 'SUSPENDED',
891
+ ...(retainedExecutor.l2State === 'WIP' ? { l2State: 'SUSPENDED' } : {}),
892
+ },
893
+ updatedAt: this.deps.now(),
894
+ });
895
+ }
877
896
  // Supersession persists independently. Re-read before reopening epochs so
878
897
  // this update cannot restore commands from the stale pre-supersession row.
879
898
  const current = this.deps.store.find(sessionId) ?? prior;
@@ -1324,7 +1343,12 @@ export class AutopilotCoordinator {
1324
1343
  executor: {
1325
1344
  ...executor,
1326
1345
  commands: executor.commands.map((command) => command.status === 'scheduled'
1327
- ? { ...command, status: 'cancelled', updatedAt: this.deps.now() }
1346
+ ? {
1347
+ ...command,
1348
+ status: 'cancelled',
1349
+ supersededBeforeIssue: true,
1350
+ updatedAt: this.deps.now(),
1351
+ }
1328
1352
  : command),
1329
1353
  },
1330
1354
  updatedAt: this.deps.now(),
@@ -1484,16 +1508,16 @@ export class AutopilotCoordinator {
1484
1508
  const epoch = epochs.get(target);
1485
1509
  return Boolean(epoch?.reopened || epoch?.completed === false);
1486
1510
  };
1487
- return plan.steps.some((l1) => l1.children.some((l2) => l2.state === 'DONE' &&
1488
- (!reportedL2.has(JSON.stringify([l1.id, l2.id])) ||
1489
- epochNeedsReport(checkpointTarget('l2', l1.id, l2.id)))) ||
1511
+ return plan.steps.some((l1) => (l1.state !== 'SUSPENDED' &&
1512
+ l1.children.some((l2) => l2.state === 'DONE' &&
1513
+ (!reportedL2.has(JSON.stringify([l1.id, l2.id])) ||
1514
+ epochNeedsReport(checkpointTarget('l2', l1.id, l2.id))))) ||
1490
1515
  (l1.state === 'DONE' &&
1491
1516
  l1.reviewStatus === 'REVIEWED' &&
1492
1517
  (!reportedL1.has(l1.id) || epochNeedsReport(checkpointTarget('l1', l1.id)))));
1493
1518
  }
1494
1519
  currentExecutor(sessionId, plan, continuationCount, persisted, activity = this.deps.activity(sessionId)) {
1495
- const stepIndex = plan.steps.findIndex((step) => step.id === plan.currentStepId || step.state === 'WIP');
1496
- const index = stepIndex >= 0 ? stepIndex : plan.steps.findIndex((step) => step.state !== 'DONE');
1520
+ const index = currentExecutableL1Index(plan);
1497
1521
  if (index < 0)
1498
1522
  return undefined;
1499
1523
  const step = plan.steps[index];
@@ -1638,6 +1662,18 @@ export class AutopilotCoordinator {
1638
1662
  return true;
1639
1663
  }
1640
1664
  executorCommand(fence, executor, generation, trigger) {
1665
+ const unissued = (executor.commands ?? [])
1666
+ .filter((command) => command.supersededBeforeIssue &&
1667
+ !command.processAction &&
1668
+ command.planIdentity === fence.planIdentity &&
1669
+ command.planFingerprint === fence.planFingerprint &&
1670
+ command.threadId === fence.executorThreadId &&
1671
+ command.taskPath === executor.taskPath &&
1672
+ command.canonicalTaskName === executor.canonicalTaskName &&
1673
+ command.generation === generation &&
1674
+ command.trigger === trigger.kind)
1675
+ .map((command) => command.commandId)
1676
+ .sort();
1641
1677
  const commandId = createHash('sha256')
1642
1678
  .update(JSON.stringify([
1643
1679
  fence.planIdentity,
@@ -1649,6 +1685,7 @@ export class AutopilotCoordinator {
1649
1685
  generation,
1650
1686
  ...(executor.resumeFailures ? [executor.resumeFailures] : []),
1651
1687
  trigger.kind,
1688
+ ...(unissued.length ? [unissued] : []),
1652
1689
  ]))
1653
1690
  .digest('hex');
1654
1691
  const now = this.deps.now();
@@ -1714,6 +1751,9 @@ export class AutopilotCoordinator {
1714
1751
  return state?.requestedEnabled &&
1715
1752
  retained &&
1716
1753
  executor &&
1754
+ (command.processAction ||
1755
+ currentExecutableL1Index(retained.plan) ===
1756
+ Number(command.canonicalPosition.slice(1)) - 1) &&
1717
1757
  executor.commands?.some((entry) => entry.commandId === command.commandId &&
1718
1758
  (['scheduled', 'issued'].includes(entry.status) ||
1719
1759
  (command.processAction && entry.status === 'failed'))) &&
@@ -1883,7 +1923,12 @@ export class AutopilotCoordinator {
1883
1923
  if (!stale || !['scheduled', 'issued'].includes(command.status))
1884
1924
  return command;
1885
1925
  changed = true;
1886
- return { ...command, status: 'superseded', updatedAt: this.deps.now() };
1926
+ return {
1927
+ ...command,
1928
+ status: 'superseded',
1929
+ ...(command.status === 'scheduled' ? { supersededBeforeIssue: true } : {}),
1930
+ updatedAt: this.deps.now(),
1931
+ };
1887
1932
  });
1888
1933
  if (!changed)
1889
1934
  return false;
@@ -1925,8 +1970,7 @@ export class AutopilotCoordinator {
1925
1970
  const plan = this.deps.plan(sessionId)?.plan;
1926
1971
  if (!plan)
1927
1972
  return undefined;
1928
- const stepIndex = plan.steps.findIndex((step) => step.id === plan.currentStepId || step.state === 'WIP');
1929
- const index = stepIndex >= 0 ? stepIndex : plan.steps.findIndex((step) => step.state !== 'DONE');
1973
+ const index = currentExecutableL1Index(plan);
1930
1974
  if (index < 0)
1931
1975
  return undefined;
1932
1976
  const canonicalTaskName = `l${index + 1}`;
@@ -1953,7 +1997,7 @@ export class AutopilotCoordinator {
1953
1997
  retained.identity !== replacement.planIdentity ||
1954
1998
  fingerprint(retained.plan) !== replacement.planFingerprint)
1955
1999
  return false;
1956
- const index = retained.plan.steps.findIndex((step) => step.id === retained.plan.currentStepId || step.state === 'WIP');
2000
+ const index = currentExecutableL1Index(retained.plan);
1957
2001
  return index >= 0 && replacement.canonicalPosition === `L${index + 1}`;
1958
2002
  }
1959
2003
  /** Converts an exhausted physical executor into one durable root-owned handoff. */
@@ -2344,8 +2388,7 @@ export class AutopilotCoordinator {
2344
2388
  authoritativeExecutorActive(next, plan, activity) {
2345
2389
  if (!plan || activity?.confidence !== 'fresh')
2346
2390
  return false;
2347
- const selected = plan.steps.findIndex((step) => step.id === plan.currentStepId || step.state === 'WIP');
2348
- const index = selected >= 0 ? selected : plan.steps.findIndex((step) => step.state !== 'DONE');
2391
+ const index = currentExecutableL1Index(plan);
2349
2392
  if (index < 0)
2350
2393
  return false;
2351
2394
  const position = `L${index + 1}`;
@@ -164,8 +164,8 @@ export function parsePersistedSupervisedLifecycle(value) {
164
164
  const canonicalTaskName = boundedText(executorValue.canonicalTaskName);
165
165
  const taskPath = boundedText(executorValue.taskPath);
166
166
  const threadId = boundedText(executorValue.threadId);
167
- const l1State = stringValue(executorValue.l1State, ['TODO', 'WIP', 'DONE']);
168
- const l2State = stringValue(executorValue.l2State, ['TODO', 'WIP', 'DONE']);
167
+ const l1State = stringValue(executorValue.l1State, ['TODO', 'WIP', 'DONE', 'SUSPENDED']);
168
+ const l2State = stringValue(executorValue.l2State, ['TODO', 'WIP', 'DONE', 'SUSPENDED']);
169
169
  const lastActivityAt = boundedText(executorValue.lastActivityAt);
170
170
  const outcome = stringValue(executorValue.outcome, [
171
171
  'objective_complete',
@@ -273,6 +273,8 @@ export function parsePersistedSupervisedLifecycle(value) {
273
273
  typeof generation === 'number' &&
274
274
  typeof attempt === 'number' &&
275
275
  trigger &&
276
+ (command.supersededBeforeIssue === undefined ||
277
+ (command.supersededBeforeIssue === true && ['cancelled', 'superseded'].includes(status))) &&
276
278
  createdAt &&
277
279
  updatedAt &&
278
280
  (command.processAction === undefined ||
@@ -289,6 +291,7 @@ export function parsePersistedSupervisedLifecycle(value) {
289
291
  threadId: commandThreadId,
290
292
  generation,
291
293
  ...(attempt ? { attempt } : {}),
294
+ ...(command.supersededBeforeIssue ? { supersededBeforeIssue: true } : {}),
292
295
  trigger,
293
296
  ...(processActionValue && processActionKind && processActionKey
294
297
  ? { processAction: { kind: processActionKind, processKey: processActionKey } }
@@ -535,6 +538,12 @@ export function decideSupervisedLifecycle(input) {
535
538
  finalAllowed: true,
536
539
  action: { kind: 'invokeAttention', ...input.attention },
537
540
  };
541
+ if (input.executor &&
542
+ (input.executor.l1State === 'SUSPENDED' ||
543
+ input.executor.l2State === 'SUSPENDED' ||
544
+ input.plan.steps[Number(input.executor.canonicalPosition.slice(1)) - 1]?.state ===
545
+ 'SUSPENDED'))
546
+ return { finalAllowed: false, action: { kind: 'continueSupervisor' } };
538
547
  const processes = input.executor?.ownedProcesses ?? [];
539
548
  const overBudget = processes.find((process) => (process.state === 'running' || process.state === 'detached-active') &&
540
549
  (process.elapsedMs > input.policy.processMaxElapsedMs ||
@@ -28,7 +28,7 @@ export function resolveOrgPlanCheckpointSignal(kind, plan, planIdentity, publica
28
28
  const allReviewed = plan.steps.filter((step) => step.state === 'DONE' && step.reviewStatus === 'REVIEWED');
29
29
  const unreportedReviewed = allReviewed.filter((step) => !completedTargets.includes(checkpointTarget('l1', step.id)));
30
30
  const reviewed = reviewedId || !unreportedReviewed.length ? allReviewed : unreportedReviewed;
31
- const allCompleted = plan.steps.flatMap((parent) => parent.reviewStatus === 'UNREVIEWED'
31
+ const allCompleted = plan.steps.flatMap((parent) => parent.state !== 'SUSPENDED' && parent.reviewStatus === 'UNREVIEWED'
32
32
  ? parent.children
33
33
  .filter((child) => child.state === 'DONE' &&
34
34
  (!completedId || child.id === completedId) &&
@@ -98,6 +98,8 @@ export function validateOrgPlanCheckpoint(input) {
98
98
  const l1 = plan.steps.find((step) => step.id === checkpoint.l1Id);
99
99
  if (!l1)
100
100
  return { valid: false, reasonCode: 'l1NotFound' };
101
+ if (l1.state === 'SUSPENDED')
102
+ return { valid: false, reasonCode: 'l1Suspended' };
101
103
  const position = `L${plan.steps.indexOf(l1) + 1}`;
102
104
  if (checkpoint.kind === 'l2Completed') {
103
105
  const l2 = l1.children.find((step) => step.id === checkpoint.l2Id);
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: AGPL-3.0-or-later
5
5
  */
6
6
  import { isAbsolute, relative, resolve } from 'node:path';
7
- const headingPattern = /^(\*{1,2}) (TODO|WIP|DONE) \[#([ABC])\] (.+)$/;
7
+ const headingPattern = /^(\*{1,2}) (TODO|WIP|DONE|SUSPENDED) \[#([ABC])\] (.+)$/;
8
8
  const propertyPattern = /^:([A-Z_]+):(?:[ \t](.*))?$/;
9
9
  const descriptionPattern = /^- ([A-Za-z][A-Za-z ]*?) ::(?:[ \t](.*))?$/;
10
10
  /**
@@ -98,6 +98,8 @@ export function parseSupervisedPlan(input) {
98
98
  return unavailable('MALFORMED_ORG');
99
99
  if (new Set(headings.map((heading) => heading.id)).size !== headings.length)
100
100
  return unavailable('DUPLICATE_ID');
101
+ if (!hasValidSuspension(headings))
102
+ return unavailable('MALFORMED_ORG');
101
103
  if (!hasValidWipPath(headings))
102
104
  return unavailable('MULTIPLE_WIP');
103
105
  const built = buildSteps(headings);
@@ -278,6 +280,43 @@ function descriptionFor(heading) {
278
280
  doneWhen: description.get('Done when'),
279
281
  };
280
282
  }
283
+ /** Match the helper's bounded suspension-v1 lifecycle dialect. */
284
+ function hasValidSuspension(headings) {
285
+ const parents = headings.filter((heading) => heading.level === 1);
286
+ const suspended = parents.filter((heading) => heading.state === 'SUSPENDED');
287
+ if (suspended.length > 1 ||
288
+ headings.filter((heading) => heading.level === 2 && heading.state === 'SUSPENDED').length > 1)
289
+ return false;
290
+ let parent;
291
+ for (const heading of headings) {
292
+ if (heading.level === 1)
293
+ parent = heading;
294
+ const dependency = heading.properties.get('SUSPENDED_FOR');
295
+ if (heading.level === 1 && heading.state === 'SUSPENDED') {
296
+ const index = parents.findIndex((candidate) => candidate.id === dependency);
297
+ if (index < 0 ||
298
+ index >= parents.indexOf(heading) ||
299
+ heading.properties.get('REVIEW_STATUS') !== 'UNREVIEWED')
300
+ return false;
301
+ }
302
+ else if (dependency !== undefined)
303
+ return false;
304
+ if (heading.level === 2) {
305
+ if (!parent)
306
+ return false;
307
+ if (heading.state === 'SUSPENDED' && parent.state !== 'SUSPENDED')
308
+ return false;
309
+ if (parent.state === 'SUSPENDED' && heading.state === 'WIP')
310
+ return false;
311
+ if (parent.state === 'DONE' && heading.state !== 'DONE')
312
+ return false;
313
+ if (parent.state === 'TODO' && heading.state !== 'TODO')
314
+ return false;
315
+ }
316
+ }
317
+ return (!suspended.length ||
318
+ !parents.some((heading) => heading.state === 'WIP' && parents.indexOf(heading) >= parents.indexOf(suspended[0])));
319
+ }
281
320
  function hasValidWipPath(headings) {
282
321
  const wipByLevel = new Map();
283
322
  for (const heading of headings) {
@@ -310,9 +349,13 @@ function findCurrentStepId(headings, allDone) {
310
349
  heading.properties.get('REVIEW_STATUS') === 'UNREVIEWED');
311
350
  if (review)
312
351
  return review.id;
313
- const todo = headings.find((heading) => heading.state === 'TODO');
352
+ const suspended = headings.find((heading) => heading.level === 1 && heading.state === 'SUSPENDED');
353
+ const todo = headings.find((heading) => heading.state === 'TODO' &&
354
+ (!suspended || headings.indexOf(heading) < headings.indexOf(suspended)));
314
355
  if (todo)
315
356
  return todo.id;
357
+ if (suspended)
358
+ return suspended.id;
316
359
  return allDone ? (headings.findLast((heading) => heading.level === 1)?.id ?? null) : null;
317
360
  }
318
361
  function freezePlan(plan) {
@@ -3,4 +3,15 @@
3
3
  * Designed by Denis Roio <jaromil@dyne.org>
4
4
  * SPDX-License-Identifier: AGPL-3.0-or-later
5
5
  */
6
- export {};
6
+ /** Suspended work is a barrier: no later implementation may be selected. */
7
+ export function currentExecutableL1Index(plan) {
8
+ const boundary = plan.steps.findIndex((step) => step.state === 'SUSPENDED');
9
+ const eligible = (index) => boundary < 0 || index < boundary;
10
+ const selected = plan.steps.findIndex((step, index) => eligible(index) &&
11
+ (step.id === plan.currentStepId ||
12
+ step.children.some((child) => child.id === plan.currentStepId) ||
13
+ step.state === 'WIP'));
14
+ if (selected >= 0)
15
+ return selected;
16
+ return plan.steps.findIndex((step, index) => eligible(index) && step.state !== 'DONE');
17
+ }
@@ -27,8 +27,9 @@ export function launchCodexAppServer(input) {
27
27
  };
28
28
  }
29
29
  /** Prevents a relay's own ambient status path from reaching discovery-only children. */
30
- export function codexChildEnvironment(environment) {
31
- const inherited = { ...process.env };
30
+ export function codexChildEnvironment(environment, launchEnvironment = process.env) {
31
+ const inherited = { ...launchEnvironment };
32
+ delete inherited.GESTALT_MOBILE_ORG_PLAN_CAPABILITIES;
32
33
  delete inherited.GESTALT_MOBILE_ORG_PLAN_STATUS_FILE;
33
34
  delete inherited.GESTALT_MOBILE_ORG_PLAN_STATUS_DIRECTORY;
34
35
  delete inherited.GESTALT_MOBILE_ORG_PLAN_MEASUREMENT_URL;
@@ -3,6 +3,7 @@
3
3
  * Designed by Denis Roio <jaromil@dyne.org>
4
4
  * SPDX-License-Identifier: AGPL-3.0-or-later
5
5
  */
6
+ import { ORG_PLAN_CAPABILITIES } from '../plans/org-plan-capabilities.js';
6
7
  import { RelaySession, } from '../../features/sessions/model/relay-session.js';
7
8
  import { randomUUID } from 'node:crypto';
8
9
  import { createPlanMeasurementSnapshot, } from '../../features/plans/application/measurement-snapshot.js';
@@ -917,7 +918,10 @@ export class CodexSessionRuntime {
917
918
  ? {
918
919
  environment: {
919
920
  ...(lease
920
- ? { GESTALT_MOBILE_ORG_PLAN_STATUS_DIRECTORY: lease.statusDirectory }
921
+ ? {
922
+ GESTALT_MOBILE_ORG_PLAN_STATUS_DIRECTORY: lease.statusDirectory,
923
+ GESTALT_MOBILE_ORG_PLAN_CAPABILITIES: ORG_PLAN_CAPABILITIES,
924
+ }
921
925
  : {}),
922
926
  ...(this.planMeasurementBaseUrl
923
927
  ? {
@@ -143,6 +143,7 @@ export class KimiWebServerManager {
143
143
  /** Prevents relay state from leaking into kimi web children, and pins KIMI_SHARE_DIR. */
144
144
  export function kimiChildEnvironment(overrides) {
145
145
  const inherited = { ...process.env };
146
+ delete inherited.GESTALT_MOBILE_ORG_PLAN_CAPABILITIES;
146
147
  delete inherited.GESTALT_MOBILE_ORG_PLAN_STATUS_FILE;
147
148
  delete inherited.GESTALT_MOBILE_ORG_PLAN_STATUS_DIRECTORY;
148
149
  delete inherited.GESTALT_MOBILE_ORG_PLAN_MEASUREMENT_URL;
@@ -0,0 +1,7 @@
1
+ /*
2
+ * Copyright (C) 2026 Dyne.org foundation
3
+ * Designed by Denis Roio <jaromil@dyne.org>
4
+ * SPDX-License-Identifier: AGPL-3.0-or-later
5
+ */
6
+ /** Compiled host assertion; never supplied by config, request or ambient env. */
7
+ export const ORG_PLAN_CAPABILITIES = 'suspension-v1';
@@ -5,11 +5,13 @@
5
5
  */
6
6
  import { execFile } from 'node:child_process';
7
7
  import { promisify } from 'node:util';
8
+ import { ORG_PLAN_CAPABILITIES } from './org-plan-capabilities.js';
8
9
  const execute = promisify(execFile);
9
10
  export const PLAN_MEASUREMENT_COMMAND_TIMEOUT_MS = 15_000;
10
11
  /** Invokes the explicitly configured Org Plan helper without a shell. */
11
12
  export async function checkpointPlanMeasurement(helperPath, planPath, stepId, snapshot) {
12
13
  await execute(helperPath, ['measure', 'checkpoint', planPath, stepId, JSON.stringify(snapshot)], {
14
+ env: { ...process.env, GESTALT_MOBILE_ORG_PLAN_CAPABILITIES: ORG_PLAN_CAPABILITIES },
13
15
  shell: false,
14
16
  timeout: PLAN_MEASUREMENT_COMMAND_TIMEOUT_MS,
15
17
  });
@@ -54,7 +54,10 @@ export class PlanMeasurementRefresh {
54
54
  return;
55
55
  this.inFlight.add(sessionId);
56
56
  try {
57
- await this.checkpoint(active.planPath, active.stepId, await this.readSnapshot(sessionId));
57
+ const snapshot = await this.readSnapshot(sessionId);
58
+ // Suspension/reselection may arrive while the provider read is in flight.
59
+ if (this.active.get(sessionId) === active)
60
+ await this.checkpoint(active.planPath, active.stepId, snapshot);
58
61
  }
59
62
  catch {
60
63
  // A transient Codex or helper failure makes this tick unavailable only.
@@ -12,6 +12,7 @@
12
12
  "canonical-agent-identity",
13
13
  "session-verdict",
14
14
  "acknowledgement-safe-composer",
15
- "org-plan-contract"
15
+ "org-plan-contract",
16
+ "suspension-v1"
16
17
  ]
17
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.49.8",
3
+ "version": "0.50.0",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",
@@ -52,6 +52,7 @@
52
52
  "test:auth:stress": "AUTH_CONTENTION_STRESS=1 vitest run --config vitest.auth-stress.config.ts --reporter=default --reporter=json --outputFile=test-results/auth-stress.json",
53
53
  "audit:prod": "npm audit --omit=dev --audit-level=high",
54
54
  "test:open-profile-smoke": "tsx scripts/open-profile-smoke.ts",
55
+ "test:org-plan-integration": "node scripts/test-org-plan-integration.mjs",
55
56
  "test:watch": "vitest",
56
57
  "test:package": "node scripts/smoke-packed-cli.mjs",
57
58
  "test:e2e": "playwright test",