gestalt-mobile 0.49.7 → 0.49.8
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 +3 -3
- package/dist/client/assets/{index-BxgQCQyH.js → index-CxuAg7aj.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/server/composition.contracts.js +234 -17
- package/dist/server/server/composition.js +16 -39
- package/dist/server/server/features/autopilot/application/policy.js +14 -0
- package/dist/server/server/features/autopilot/application/service.js +42 -1
- package/dist/server/server/features/control-plane-trace/export-trace.js +1 -0
- package/dist/server/server/features/self-debug/create-session.js +5 -9
- package/dist/server/server/features/sessions/start-session/use-case.js +27 -24
- package/dist/server/server/platform/persistence/migrate.js +1 -0
- package/dist/server/server/platform/persistence/retention.js +4 -3
- package/dist/server/server/platform/persistence/sqlite-event-journal.js +14 -4
- package/dist/server/shared/contracts/autopilot-audit.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -496,11 +496,11 @@ app-server afterwards, and always removes its temporary state. It reports
|
|
|
496
496
|
|
|
497
497
|
## Control-plane traces
|
|
498
498
|
|
|
499
|
-
When an existing Chat is selected, the header menu offers **DEBUG**. Its confirmation shows the source session's live identifiers and installed component versions. Confirming captures a redacted JSON trace immediately
|
|
499
|
+
When an existing Chat is selected, the header menu offers **DEBUG**. Its confirmation shows the source session's live identifiers and installed component versions. Confirming captures a redacted JSON trace immediately. Debug creation does not start, steer, resume, or replace the source runtime.
|
|
500
500
|
|
|
501
|
-
Self DEBUG starts an independent root thread in `~/.gestalt/self-debug`,
|
|
501
|
+
Self DEBUG starts an independent root thread in `~/.gestalt/self-debug`, inheriting the source root's model, reasoning setting, launcher profile, and exact saved skill selection, including disabled skills. It requires the source settings to be available rather than substituting executor defaults. The workspace reuses existing clones of `dyne/gestalt`, `dyne/gestalt-mobile`, and `dyne/gestalt-agents`, or clones missing repositories. Existing clones are never reset or updated automatically.
|
|
502
502
|
|
|
503
|
-
The Sessions tab retains a **Self DEBUG** section with source identifiers, versions, and a JSON preview link. The diagnostic agent is instructed to ask for missing reproduction details, investigate and test a fix, then request confirmation before opening a pull request or issue through authorized GitHub access. Trace exports
|
|
503
|
+
The Sessions tab retains a **Self DEBUG** section with source identifiers, versions, and a JSON preview link. The diagnostic agent is instructed to ask for missing reproduction details, investigate and test a fix, then request confirmation before opening a pull request or issue through authorized GitHub access. The relay journal retains a rolling 48 hours by default, pruning older session events as new events arrive. Event bursts do not shorten that window. Trace exports include at most the latest 5,000 structural control-plane events and omit free-form conversation and sensitive payload fields; older events within the retention window remain available in the journal.
|
|
504
504
|
|
|
505
505
|
Export the durable Org Plan, Autopilot, and agent-projection timeline for one relay session without starting the server:
|
|
506
506
|
|
|
@@ -15,7 +15,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
15
15
|
`);i&&t.push({kind:`text`,parts:wc(i)})};for(let e=0;e<n.length;e+=1){let a=xc(n[e]??``);if(a){i(e),t.push({kind:`heading`,level:a.level,parts:wc(a.text)}),r=e+1;continue}if(e===n.length-1)continue;let o=Sc(n[e]??``),s=Sc(n[e+1]??``);if(!o||!s||o.length!==s.length||!s.every(Cc))continue;i(e),e+=2;let c=[];for(;e<n.length;){let t=Sc(n[e]??``);if(!t||t.length!==o.length)break;c.push(t),e+=1}t.push({kind:`table`,headers:o.map(wc),rows:c.map(e=>e.map(wc))}),r=e,--e}return i(n.length),t.length?t:[{kind:`text`,parts:wc(e)}]}function xc(e){let t=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*#*[ \t]*$/.exec(e);return t?{level:t[1].length,text:t[2]??``}:null}function Sc(e){let t=e.trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(Boolean)?n:null}function Cc(e){return/^:?-{3,}:?$/.test(e)}function wc(e){let t=[],n=/\[([^\]]+)\]\((https?:\/\/[^\s)]+|codex:\/\/[^\s)]+|file:\/\/[^\s)]+|\/[^\s)]+|\.{1,2}\/[^\s)]+|[^\s:()]+\.[a-zA-Z\d]+(?::\d+(?::\d+)?)?(?:#L\d+(?:C\d+)?)?|<(?:https?:\/\/|codex:\/\/|file:\/\/|\/|\.{1,2}\/)[^>\n]+>)\)|`([^`]+)`|\*\*([^*\n]+)\*\*/g,r=0;for(let i of e.matchAll(n)){let n=e.slice(r,i.index);n&&t.push({kind:`text`,text:n}),t.push(i[3]?{kind:`code`,text:i[3]}:i[4]?{kind:`strong`,parts:wc(i[4])}:{kind:`link`,text:i[1]??``,href:(i[2]??``).replace(/^<|>$/g,``)}),r=(i.index??0)+i[0].length}let i=e.slice(r);return i&&t.push({kind:`text`,text:i}),t}function Tc(e){let t=/(?::(\d+)(?::\d+)?|#L(\d+)(?:C\d+)?)$/.exec(e);if(!t)return{path:e};let n=Number(t[1]??t[2]);return{path:e.slice(0,t.index),...Number.isSafeInteger(n)&&n>0?{line:n}:{}}}function Ec(e,t=!0){let n;try{n=t?decodeURIComponent(e):e}catch{return null}if(n.startsWith(`file://`))try{let e=new URL(n);if(e.hostname&&e.hostname!==`localhost`)return null;n=decodeURIComponent(e.pathname+e.hash)}catch{return null}let r=Tc(n);return n=r.path,/^[a-z][a-z\d+.-]*:/i.test(n)||n.startsWith(`//`)||/[\u0000-\u001f\\]/.test(n)||!n||n.startsWith(`#`)||n.includes(`?`)||n.includes(`#`)||!n.startsWith(`/`)&&!n.startsWith(`./`)&&!n.startsWith(`../`)&&!/\.[a-z\d]+$/i.test(n)?null:r}function Dc(e,t=!0){return Ec(e,t)?.path??null}var Oc=/^(.*\.org)(?::\d+(?::\d+)?)?(?:#L\d+(?:C\d+)?)?$/;function kc(e){try{return decodeURIComponent(e)}catch{return null}}function Ac(e){if(!e.startsWith(`/`)||e.includes(`\0`))return null;let t=[];for(let n of e.split(`/`))if(!(!n||n===`.`)){if(n===`..`){if(t.length===0)return null;t.pop();continue}t.push(n)}return t}function jc(e,t){let n=kc(e),r=kc(t),i=n?Oc.exec(n):null;if(!i||!r)return null;let a=Ac(i[1]??``),o=Ac(r);if(!a||!o||a.length<=o.length||o.some((e,t)=>a[t]!==e))return null;let s=a.slice(o.length).join(`/`);return s.endsWith(`.org`)&&s!==`.org`?s:null}function Mc(e){let t=kc(e);if(!t)return!1;let n=Oc.exec(t);return!!(n&&Ac(n[1]??``))}async function Nc(e,t=globalThis.navigator?.clipboard,n=Fc){if(!t)return Pc(e,n);try{return await t.writeText(e),!0}catch{return Pc(e,n)}}function Pc(e,t){try{return t(e)}catch{return!1}}function Fc(e){if(typeof document>`u`||!document.body)return!1;let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.cssText=`position:fixed;opacity:0`,document.body.append(t),t.select();let n=document.execCommand(`copy`);return t.remove(),n}var Ic=q(`<a class="svelte-1im954t"> </a>`),Lc=q(`<a target="_blank" rel="noreferrer" class="svelte-1im954t"> </a>`),Rc=q(`<code class="svelte-1im954t"> </code>`),zc=q(`<strong class="svelte-1im954t"><!></strong>`),Bc=q(`<time class="svelte-1im954t"> </time>`),Vc=q(`<span class="touch-unknown svelte-1im954t">time unknown</span>`),Hc=q(`<li class="svelte-1im954t"><code class="file-path svelte-1im954t"> </code> <span class="file-counts svelte-1im954t" aria-label="Line changes"><span class="additions svelte-1im954t"> </span> <span class="deletions svelte-1im954t"> </span></span> <!></li>`),Uc=q(`<details class="file-changes svelte-1im954t"><summary class="svelte-1im954t"> <span class="additions svelte-1im954t"> </span> <span class="deletions svelte-1im954t"> </span></summary> <section aria-label="Files changed"><ul class="svelte-1im954t"></ul></section></details>`),Wc=q(`<div class="code-block svelte-1im954t"><button class="code-copy svelte-1im954t" type="button" title="Copy code"><svg aria-hidden="true" viewBox="0 0 24 24" class="svelte-1im954t"><rect x="9" y="9" width="10" height="10" rx="2"></rect><path d="M15 9V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2"></path></svg></button> <pre class="svelte-1im954t"><code class="svelte-1im954t"> </code></pre></div>`),Gc=q(`<th scope="col" class="svelte-1im954t"><!></th>`),Kc=q(`<td class="svelte-1im954t"><!></td>`),qc=q(`<tr></tr>`),Jc=q(`<div class="table-scroll svelte-1im954t"><table class="svelte-1im954t"><thead><tr></tr></thead><tbody></tbody></table></div>`),Yc=q(`<h1 class="svelte-1im954t"><!></h1>`),Xc=q(`<h2 class="svelte-1im954t"><!></h2>`),Zc=q(`<h3 class="svelte-1im954t"><!></h3>`),Qc=q(`<h4 class="svelte-1im954t"><!></h4>`),$c=q(`<h5 class="svelte-1im954t"><!></h5>`),el=q(`<h6 class="svelte-1im954t"><!></h6>`),tl=q(`<div class="svelte-1im954t"><!></div>`),nl=q(`<li class="audit-incomplete svelte-1im954t" role="status">Earlier Autopilot audit entries are not shown; this timeline contains the retained recent
|
|
16
16
|
audit.</li>`),rl=q(`<li class="svelte-1im954t"><time class="svelte-1im954t"> </time></li>`),il=q(`<details><summary class="svelte-1im954t"> </summary> <ul></ul></details>`),al=q(`<aside class="autopilot-audit svelte-1im954t" aria-label="Autopilot audit entry"><strong>Autopilot</strong> <!> <!></aside>`),ol=q(`<time class="svelte-1im954t"> <!></time>`),sl=q(`<div class="entry-heading svelte-1im954t"><strong>working</strong></div> <!> <!>`,1),cl=q(`<section><!></section>`),ll=q(`<div class="entry-heading svelte-1im954t"><strong>prompt</strong> <!></div> <div class="entry-content svelte-1im954t"><!></div> <!> <!>`,1),ul=q(`<div class="commentary-content live-commentary svelte-1im954t"><!></div>`),dl=q(`<!> <!>`,1),fl=q(`<button class="commentary-toggle svelte-1im954t" type="button"><span aria-hidden="true"> </span> commentary</button>`),pl=q(`<div class="answer-history svelte-1im954t"><!></div>`),ml=q(`<div class="commentary-content svelte-1im954t"><!></div>`),hl=q(`<section class="answer-turn svelte-1im954t"><div class="entry-heading svelte-1im954t"><strong> </strong> <!></div> <!> <!> <div class="entry-content svelte-1im954t"><!></div> <!></section>`),gl=q(`<div class="entry-content svelte-1im954t"><!></div>`),_l=q(`<details><summary>commentary</summary> <!></details> <!>`,1),vl=q(`<section><div class="entry-heading svelte-1im954t"><strong> </strong> <!></div> <!> <!></section>`),yl=q(`<li><!></li>`),bl=q(`<li class="interaction-only svelte-1im954t"><!></li>`),xl=q(`<li class="progress-item svelte-1im954t"><section><!></section></li>`),Sl=q(`<ol aria-label="Chat messages" class="svelte-1im954t"><!> <!> <!> <!></ol> <!>`,1);function Cl(e,t){$e(t,!0);let n=(e,r=b)=>{var i=Kr();Z(H(i),17,r,ei,(e,r)=>{var i=Kr(),a=H(i),o=e=>{var n=Kr(),i=H(n),a=e=>{var t=Ic(),n=V(t,!0);P(t),W(()=>{Q(t,`href`,G(r).href),Y(n,G(r).text)}),K(`click`,t,e=>fe(e,G(r).href)),J(e,t)},o=L(()=>t.onopenorg&&Mc(G(r).href)),s=e=>{var n=Ic(),i=V(n,!0);P(n),W(()=>{Q(n,`href`,G(r).href),Y(i,G(r).text)}),K(`click`,n,e=>{e.preventDefault();let n=Ec(G(r).href);n.line?t.onopenfile?.(n.path,n.line):t.onopenfile?.(n.path)}),J(e,n)},c=L(()=>t.onopenfile&&Dc(G(r).href)),l=e=>{var t=Lc(),n=V(t,!0);P(t),W(()=>{Q(t,`href`,G(r).href),Y(n,G(r).text)}),J(e,t)};X(i,e=>{G(o)?e(a):G(c)?e(s,1):e(l,-1)}),J(e,n)},s=e=>{var t=Rc(),n=V(t,!0);P(t),W(()=>Y(n,G(r).text)),J(e,t)},c=e=>{var t=zc(),i=V(t);n(i,()=>G(r).parts),P(t),J(e,t)},l=e=>{var t=Gr();W(()=>Y(t,G(r).text)),J(e,t)};X(a,e=>{G(r).kind===`link`?e(o):G(r).kind===`code`?e(s,1):G(r).kind===`strong`?e(c,2):e(l,-1)}),J(e,i)}),J(e,i)},r=(e,t=b)=>{let n=L(()=>xs(t())),r=L(()=>Ss(G(n)));var i=Kr(),a=H(i),o=e=>{var t=Uc(),i=V(t),a=V(i),o=U(a),s=V(o);P(o);var c=U(o,2),l=V(c);P(c),P(i);var u=U(i,2),d=V(u);Z(d,21,()=>G(n),e=>e.path,(e,t)=>{var n=Hc(),r=V(n),i=V(r,!0);P(r);var a=U(r,2),o=V(a),s=V(o);P(o);var c=U(o,2),l=V(c);P(c),P(a);var u=U(a,2),d=e=>{var n=Bc(),r=V(n,!0);P(n),W((e,t)=>{Q(n,`datetime`,e),Y(r,t)},[()=>new Date(G(t).touchedAt).toISOString(),()=>Ts(G(t).touchedAt,G(w))]),J(e,n)},f=e=>{J(e,Vc())};X(u,e=>{G(t).touchedAt===void 0?e(f,-1):e(d)}),P(n),W(()=>{Y(i,G(t).path),Y(s,`+${G(t).additions??`?`??``}`),Y(l,`−${G(t).deletions??`?`??``}`)}),J(e,n)}),P(d),P(u),P(t),W(()=>{Y(a,`${G(r).files??``}
|
|
17
17
|
${G(r).files===1?`file`:`files`} changed · `),Y(s,`+${G(r).additions??`?`??``}`),Y(l,`−${G(r).deletions??`?`??``}`)}),J(e,t)};X(a,e=>{G(n).length&&e(o)}),J(e,i)},i=(e,t=b)=>{var r=Kr();Z(H(r),17,()=>yc(t()),ei,(e,t)=>{var r=Kr(),i=H(r),a=e=>{var n=Wc(),r=V(n),i=U(r,2),a=V(i),o=V(a,!0);P(a),P(i),P(n),W(e=>{Q(r,`aria-label`,e),Y(o,G(t).text)},[()=>pe(G(t).text)]),K(`click`,r,()=>void me(G(t).text)),J(e,n)},o=e=>{var r=Jc(),i=V(r),a=V(i),o=V(a);Z(o,21,()=>G(t).headers,ei,(e,t)=>{var r=Gc(),i=V(r);n(i,()=>G(t)),P(r),J(e,r)}),P(o),P(a);var s=U(a);Z(s,21,()=>G(t).rows,ei,(e,t)=>{var r=qc();Z(r,21,()=>G(t),ei,(e,t)=>{var r=Kc(),i=V(r);n(i,()=>G(t)),P(r),J(e,r)}),P(r),J(e,r)}),P(s),P(i),P(r),J(e,r)},s=e=>{var r=Kr(),i=H(r),a=e=>{var r=Yc(),i=V(r);n(i,()=>G(t).parts),P(r),J(e,r)},o=e=>{var r=Xc(),i=V(r);n(i,()=>G(t).parts),P(r),J(e,r)},s=e=>{var r=Zc(),i=V(r);n(i,()=>G(t).parts),P(r),J(e,r)},c=e=>{var r=Qc(),i=V(r);n(i,()=>G(t).parts),P(r),J(e,r)},l=e=>{var r=$c(),i=V(r);n(i,()=>G(t).parts),P(r),J(e,r)},u=e=>{var r=el(),i=V(r);n(i,()=>G(t).parts),P(r),J(e,r)};X(i,e=>{G(t).level===1?e(a):G(t).level===2?e(o,1):G(t).level===3?e(s,2):G(t).level===4?e(c,3):G(t).level===5?e(l,4):e(u,-1)}),J(e,r)},c=e=>{var r=tl(),i=V(r);n(i,()=>G(t).parts),P(r),J(e,r)};X(i,e=>{G(t).kind===`code`?e(a):G(t).kind===`table`?e(o,1):G(t).kind===`heading`?e(s,2):e(c,-1)}),J(e,r)}),J(e,r)},a=$(t,`activeTurnId`,3,null),o=$(t,`autopilotAuditTruncated`,3,!1),s=$(t,`interactions`,19,()=>[]),c=$(t,`attention`,3,null),l=$(t,`attentionPending`,3,!1),u=$(t,`onattentionresolve`,3,()=>{}),d=$(t,`answers`,19,()=>({})),f=$(t,`submittedAnswers`,19,()=>({})),p=$(t,`clipboard`,19,()=>globalThis.navigator?.clipboard),m=$(t,`onanswer`,3,()=>{}),h=$(t,`onquiz`,3,()=>{}),g=$(t,`onpermission`,3,()=>{}),_=$(t,`ondecision`,3,()=>{}),v=$(t,`onretry`,3,()=>{}),y=$(t,`oncopyresult`,3,()=>{}),x=L(()=>{let e=vc(t.messages);if(!c()||e.some(e=>e.kind===`audit`&&e.attention?.requestId===c().requestId))return e;let n=hs(c().attention);if(!n)return e;let r=c().requestedAt?Date.parse(c().requestedAt):void 0,i=r!==void 0&&Number.isFinite(r)?r:void 0,a=i===void 0?-1:e.findIndex(e=>e.occurredAt!==void 0&&e.occurredAt>i);return e.splice(a<0?e.length:a,0,{id:`attention:${c().requestId}`,kind:`audit`,text:`Needs attention`,attention:{...c(),attention:n},occurredAt:i,count:1,timestamps:i===void 0?[]:[i]}),e});function S(e){let n=e.requestedAt?Date.parse(e.requestedAt):NaN,r=t.messages.filter(t=>t.role===`assistant`&&t.turnId===e.turnId),i=r.findLast(e=>e.phase===`final_answer`&&e.occurredAt!==void 0&&e.occurredAt>=n),a=r.findLast(e=>e.phase===`commentary`&&e.occurredAt!==void 0&&e.occurredAt<=n),o=c()?.requestId===e.requestId&&c().supervisorReport?c().supervisorReport:mo(i?.text??a?.text);return{...e,...o?{supervisorReport:o}:{}}}let C=on({}),w=z(on(Date.now()));Gi(()=>{let e=globalThis.setInterval(()=>B(w,Date.now(),!0),1e3);return()=>globalThis.clearInterval(e)});let T=L(()=>G(x).filter(e=>e.kind===`user`)),E=L(()=>G(x).filter(e=>e.kind===`assistant`)),D=L(()=>G(E).at(-1)?.id),ee=L(()=>s().filter(e=>!e.turnId||!G(T).some(t=>t.turnId===e.turnId)));function te(e){let t=G(T).findLast(t=>t.turnId&&t.turnId===e.turnId);if(t)return t.id;let n=e.occurredAt;if(n!==void 0){let e=G(T).findLast(e=>e.occurredAt!==void 0&&e.occurredAt<=n);if(e)return e.id}return G(T).at(-1)?.id??null}function ne(e){return e.kind===`user`?s().filter(t=>te(t)===e.id):[]}function re(e){if(e.turnId){let t=G(E).findLast(t=>t.turnId===e.turnId);if(t)return t.id}return e.occurredAt===void 0?G(D)??null:G(E).find(t=>t.answer!==null&&t.occurredAt!==void 0&&t.occurredAt>=e.occurredAt)?.id??null}function ie(e){return e.kind===`assistant`?t.activities.filter(t=>re(t)===e.id):[]}function ae(e){if(re(e))return null;if(e.turnId){let t=G(T).findLast(t=>t.turnId===e.turnId);if(t)return t.id}return e.occurredAt===void 0?null:G(T).findLast(t=>t.occurredAt!==void 0&&t.occurredAt<=e.occurredAt)?.id??null}function oe(e){return e.kind===`user`?t.activities.filter(t=>ae(t)===e.id):[]}function se(){return t.activities.filter(e=>!re(e)&&!ae(e))}let ce=L(se);function le(e){return e.filter(e=>!e.label.toLowerCase().replaceAll(` `,``).startsWith(`filechange`))}function ue(e){return!!(e.kind===`assistant`&&a()&&(e.turnId===a()||!e.turnId&&e.id===G(D)))}function de(e){return!!(e.kind===`user`&&a()&&(e.turnId===a()||!e.turnId))}function O(e,t){return Cs(G(x)[e-1]?.occurredAt,t)}function fe(e,n){!t.onopenorg||!Mc(n)||(e.preventDefault(),t.onopenorg(n))}function pe(e){return`Copy code block: ${(e.trim().split(`
|
|
18
|
-
`)[0]?.trim()||`empty block`).slice(0,48)}`}async function me(e){y()(await Nc(e,p()))}var he=Sl(),ge=H(he),_e=V(ge),ve=e=>{J(e,nl())};X(_e,e=>{o()&&e(ve)});var k=U(_e,2);Z(k,19,()=>G(x),e=>e.id,(e,t,n)=>{var a=yl(),o=V(a),s=e=>{var n=Kr(),r=H(n),i=e=>{{let n=L(()=>S(G(t).attention)),r=L(()=>c()?.requestId!==G(t).attention.requestId),i=L(()=>`chat-attention-${G(t).attention.requestId}`);ds(e,{get attention(){return G(n)},get historical(){return G(r)},get pending(){return l()},get controlId(){return G(i)},get onresolve(){return u()}})}},a=e=>{var n=al(),r=U(V(n)),i=U(r),a=e=>{var n=Bc(),r=V(n,!0);P(n),W((e,t)=>{Q(n,`datetime`,e),Y(r,t)},[()=>new Date(G(t).occurredAt).toISOString(),()=>ws(G(t).occurredAt)]),J(e,n)};X(i,e=>{G(t).occurredAt&&e(a)});var o=U(i,2),s=e=>{var n=il(),r=V(n),i=V(r);P(r);var a=U(r,2);Z(a,21,()=>G(t).timestamps,e=>`${G(t).id}:${e}`,(e,t)=>{var n=rl(),r=V(n),i=V(r,!0);P(r),P(n),W((e,t)=>{Q(r,`datetime`,e),Y(i,t)},[()=>new Date(G(t)).toISOString(),()=>ws(G(t))]),J(e,n)}),P(a),P(n),W(()=>Y(i,`Show ${G(t).count??``} timestamps`)),J(e,n)};X(o,e=>{G(t).count>1&&e(s)}),P(n),W(()=>Y(r,` ${G(t).text??``}${G(t).count>1?` · ${G(t).count} times`:``} `)),J(e,n)};X(r,e=>{G(t).attention?e(i):e(a,-1)}),J(e,n)},p=e=>{let a=L(()=>oe(G(t)));var o=ll(),s=H(o),c=U(V(s),2),l=e=>{var r=ol(),i=V(r),a=U(i),o=e=>{var r=Gr();W(e=>Y(r,`· ${e??``}`),[()=>O(G(n),G(t).occurredAt)]),J(e,r)},s=L(()=>O(G(n),G(t).occurredAt));X(a,e=>{G(s)&&e(o)}),P(r),W((e,t)=>{Q(r,`datetime`,e),Y(i,`${t??``} `)},[()=>new Date(G(t).occurredAt).toISOString(),()=>ws(G(t).occurredAt)]),J(e,r)};X(c,e=>{G(t).occurredAt&&e(l)}),P(s);var u=U(s,2),p=V(u);i(p,()=>G(t).text),P(u);var y=U(u,2);{let e=L(()=>ne(G(t)));_c(y,{get interactions(){return G(e)},get answers(){return d()},get submittedAnswers(){return f()},get onanswer(){return m()},get onquiz(){return h()},get onpermission(){return g()},get ondecision(){return _()},get onretry(){return v()}})}var b=U(y,2),x=e=>{var n=cl(),i=V(n),o=e=>{var t=sl(),n=U(H(t),2);{let e=L(()=>le(G(a)));Ka(n,{get activities(){return G(e)},variant:`live`})}var i=U(n,2);r(i,()=>G(a)),J(e,t)},s=L(()=>de(G(t))),c=e=>{Is(e,{get activities(){return G(a)},get now(){return G(w)}})};X(i,e=>{G(s)?e(o):e(c,-1)}),P(n),W(e=>Si(n,1,e,`svelte-1im954t`),[()=>gi(de(G(t))?`progress-turn`:`orphan-activity-turn`)]),J(e,n)};X(b,e=>{G(a).length&&e(x)}),J(e,o)},y=e=>{let r=L(()=>ie(G(t)));var a=hl(),o=V(a),s=V(o),c=V(s,!0);P(s);var l=U(s,2),u=e=>{var r=ol(),i=V(r),a=U(i),o=e=>{var r=Gr();W(e=>Y(r,`· ${e??``}`),[()=>O(G(n),G(t).occurredAt)]),J(e,r)},s=L(()=>O(G(n),G(t).occurredAt));X(a,e=>{G(s)&&e(o)}),P(r),W((e,t)=>{Q(r,`datetime`,e),Y(i,`${t??``} `)},[()=>new Date(G(t).occurredAt).toISOString(),()=>ws(G(t).occurredAt)]),J(e,r)};X(l,e=>{G(t).occurredAt&&e(u)}),P(o);var d=U(o,2),f=e=>{var n=dl(),a=H(n),o=e=>{var n=ul(),r=V(n);i(r,()=>G(t).commentary),P(n),J(e,n)};X(a,e=>{G(t).commentary&&e(o)});var s=U(a,2);{let e=L(()=>le(G(r)));Ka(s,{get activities(){return G(e)},variant:`live`})}J(e,n)},p=L(()=>ue(G(t))),m=e=>{var n=pl(),r=V(n),i=e=>{var n=fl(),r=V(n),i=V(r,!0);P(r),Ue(),P(n),W(e=>{Q(n,`aria-expanded`,e),Q(n,`aria-controls`,`commentary-${G(t).id}`),Y(i,C[G(t).id]?`⌄`:`›`)},[()=>!!C[G(t).id]]),K(`click`,n,()=>C[G(t).id]=!C[G(t).id]),J(e,n)};X(r,e=>{G(t).commentary&&e(i)}),P(n),J(e,n)},h=L(()=>G(t).commentary||le(G(r)).length);X(d,e=>{G(p)?e(f):G(h)&&e(m,1)});var g=U(d,2),_=e=>{var n=ml(),r=V(n);i(r,()=>G(t).commentary),P(n),W(()=>Q(n,`id`,`commentary-${G(t).id}`)),J(e,n)},v=L(()=>!ue(G(t))&&G(t).commentary&&C[G(t).id]);X(g,e=>{G(v)&&e(_)});var y=U(g,2),b=V(y);i(b,()=>G(t).answer),P(y),Is(U(y,2),{get activities(){return G(r)},get now(){return G(w)}}),P(a),W(e=>Y(c,e),[()=>ue(G(t))?`working`:`answer`]),J(e,a)},b=e=>{let a=L(()=>ie(G(t)));var o=vl(),s=V(o),c=V(s),l=V(c,!0);P(c);var u=U(c,2),d=e=>{var r=ol(),i=V(r),a=U(i),o=e=>{var r=Gr();W(e=>Y(r,`· ${e??``}`),[()=>O(G(n),G(t).occurredAt)]),J(e,r)},s=L(()=>O(G(n),G(t).occurredAt));X(a,e=>{G(s)&&e(o)}),P(r),W((e,t)=>{Q(r,`datetime`,e),Y(i,`${t??``} `)},[()=>new Date(G(t).occurredAt).toISOString(),()=>ws(G(t).occurredAt)]),J(e,r)};X(u,e=>{G(t).occurredAt&&e(d)}),P(s);var f=U(s,2),p=e=>{var n=dl(),r=H(n),o=e=>{var n=gl(),r=V(n);i(r,()=>G(t).commentary),P(n),J(e,n)};X(r,e=>{G(t).commentary&&e(o)});var s=U(r,2);{let e=L(()=>le(G(a)));Ka(s,{get activities(){return G(e)},variant:`live`})}J(e,n)},m=L(()=>ue(G(t))),h=e=>{var n=_l(),r=H(n),o=U(V(r),2);i(o,()=>G(t).commentary),P(r),Is(U(r,2),{get activities(){return G(a)},get now(){return G(w)}}),J(e,n)};X(f,e=>{G(m)?e(p):e(h,-1)});var g=U(f,2),_=e=>{r(e,()=>G(a))},v=L(()=>ue(G(t)));X(g,e=>{G(v)&&e(_)}),P(o),W((e,t)=>{Si(o,1,e,`svelte-1im954t`),Y(l,t)},[()=>gi(ue(G(t))?`progress-turn`:`commentary-turn`),()=>ue(G(t))?`working`:`commentary`]),J(e,o)};X(o,e=>{G(t).kind===`audit`?e(s):G(t).kind===`user`?e(p,1):G(t).answer===null?G(t).commentary!==null&&e(b,3):e(y,2)}),P(a),W(()=>Si(a,1,gi(G(t).kind===`user`?`prompt-turn`:G(t).kind===`audit`?`audit-item`:`answer-item`),`svelte-1im954t`)),J(e,a)});var A=U(k,2),ye=e=>{var t=bl();_c(V(t),{get interactions(){return G(ee)},get answers(){return d()},get submittedAnswers(){return f()},get onanswer(){return m()},get onquiz(){return h()},get onpermission(){return g()},get ondecision(){return _()},get onretry(){return v()}}),P(t),J(e,t)};X(A,e=>{G(T).length===0&&G(ee).length&&e(ye)});var be=U(A,2),xe=e=>{var t=xl(),n=V(t),i=V(n),o=e=>{var t=sl(),n=U(H(t),2);{let e=L(()=>le(G(ce)));Ka(n,{get activities(){return G(e)},variant:`live`})}var i=U(n,2);r(i,()=>G(ce)),J(e,t)},s=e=>{Is(e,{get activities(){return G(ce)},get now(){return G(w)}})};X(i,e=>{a()?e(o):e(s,-1)}),P(n),P(t),W(()=>Si(n,1,gi(a()?`progress-turn`:`orphan-activity-turn`),`svelte-1im954t`)),J(e,t)};X(be,e=>{G(ce).length&&e(xe)}),P(ge),ui(U(ge,2),()=>t.footer??b),J(e,he),et()}Rr([`click`]);var wl=q(`<p class="svelte-10cj0sh"> </p> <button type="button" class="svelte-10cj0sh">Review Autopilot blocker</button>`,1),Tl=q(`<div class="svelte-10cj0sh"><span> </span> <button type="button" class="svelte-10cj0sh"> </button></div>`),El=q(`<aside class="pending-requests svelte-10cj0sh" aria-label="Pending chat requests" role="status"><strong> </strong> <!> <!></aside>`);function Dl(e,t){$e(t,!0);let n=$(t,`activeTurnId`,3,null),r=L(()=>t.interactions.filter(e=>e.state!==`resolved`&&e.kind!==`orgPlanAttention`&&e.kind!==`orgPlanCheckpoint`&&e.kind!==`autopilotWaitLease`)),i={quiz:`Quiz answer`,userInput:`Answer`,commandApproval:`Command approval`,fileChangeApproval:`File approval`,permissionsApproval:`Permission approval`};function a(e){let t=document.getElementById(e);t?.scrollIntoView({block:`start`});let n=document.querySelector(`.pending-requests`);if(t&&n){let e=t.getBoundingClientRect().top,r=n.getBoundingClientRect().bottom;e<r&&window.scrollBy({top:e-r-8})}t?.focus({preventScroll:!0})}var o=Kr(),s=H(o),c=e=>{var o=El(),s=V(o),c=V(s,!0);P(s);var l=U(s,2),u=e=>{var n=wl(),r=H(n),i=V(r,!0);P(r);var o=U(r,2);W(()=>Y(i,t.attention.supervisorReport||t.attention.attention.summary)),K(`click`,o,()=>a(`chat-attention-${t.attention.requestId}`)),J(e,n)};X(l,e=>{t.attention&&e(u)}),Z(U(l,2),17,()=>G(r),e=>e.key,(e,t)=>{let r=L(()=>G(t).kind===`quiz`&&G(t).turnId&&G(t).turnId!==n());var o=Tl(),s=V(o),c=V(s,!0);P(s);var l=U(s,2),u=V(l);P(l),P(o),W(e=>{Y(c,G(r)?`Earlier quiz remains unanswered. Autopilot can continue.`:`${i[G(t).kind]??`Response`} needed to continue.`),Y(u,`Review ${e??``}`)},[()=>i[G(t).kind]?.toLowerCase()??`request`]),K(`click`,l,()=>a(`chat-request-${G(t).requestId}`)),J(e,o)}),P(o),W(()=>Y(c,t.attention?`Autopilot needs your attention`:`Requests awaiting your response`)),J(e,o)};X(s,e=>{(t.attention||G(r).length)&&e(c)}),J(e,o),et()}Rr([`click`]);var Ol=[150,300,600];function kl(e){return new Promise(t=>setTimeout(t,e))}function Al(e){return e.status===502||e.status===503||e.status===504}async function jl(e=fetch){for(let t=0;t<=Ol.length;t+=1){let n;try{n=await e(`/api/bootstrap`)}catch(e){if(e instanceof Error&&e.name===`AbortError`)throw e;if(t===Ol.length)throw Error(`BOOTSTRAP_FAILED`);await kl(Ol[t]);continue}if(n.ok)return n.json();if(!Al(n)||t===Ol.length)throw Error(`BOOTSTRAP_FAILED`);await kl(Ol[t])}throw Error(`BOOTSTRAP_FAILED`)}var Ml=`gestalt-mobile`,Nl=2,Pl=[`settings`,`drafts`,`cursors`,`messages`];function Fl(e){return new Promise((t,n)=>{let r=e.open(Ml,Nl);r.onupgradeneeded=()=>{for(let e of Pl)r.result.objectStoreNames.contains(e)||r.result.createObjectStore(e)},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)})}function Il(e,t,n){return zl(e.transaction(t,`readonly`).objectStore(t).get(n))}function Ll(e,t,n,r){return zl(e.transaction(t,`readwrite`).objectStore(t).put(r,n))}function Rl(e,t,n){return zl(e.transaction(t,`readwrite`).objectStore(t).delete(n))}function zl(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}var Bl=`chat-projections`,Vl=e=>({version:1,cursor:e.cursor,lifecycle:e.lifecycle,activeTurnId:e.activeTurnId,messages:e.messages.filter(e=>e.role===`user`).slice(-200),activities:[],prompts:e.prompts.slice(-200),interactions:e.interactions.map(({requestId:e,key:t,kind:n,turnId:r,state:i,operationId:a,attemptedOutcome:o})=>({requestId:e,key:t,kind:n,...r?{turnId:r}:{},state:i,...a?{operationId:a}:{},...i===`resolved`&&(o===`approved`||o===`denied`||o===`answered`||o===`dismissed`)?{attemptedOutcome:o}:{},...typeof o==`object`&&o&&(o.decision===`accept`||o.decision===`decline`)?{attemptedOutcome:{decision:o.decision}}:{}})).slice(-200),buffered:[]});function Hl(e=globalThis.indexedDB){if(!e)return{read:async()=>null,write:async()=>{}};let t=Fl(e);return{read:async e=>{try{return await Il(await t,Bl,e)}catch{return null}},write:async(e,n)=>{try{await Ll(await t,Bl,e,Vl(n))}catch{}}}}var Ul=`chat-session`;function Wl(e){return new URLSearchParams(e).get(`chat-session`)?.trim()||null}function Gl(e,t){let n=new URL(e);return n.search=``,n.hash=``,n.searchParams.set(Ul,t),n.toString()}function Kl(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return`gestalt-chat-${(t>>>0).toString(36)}`}function ql(e){let t=Yl(e,`requestId`),n=hs(Yl(e,`payload`));if(typeof t!=`string`||t.length>256||!n)return;let r=Yl(e,`turnId`),i=Yl(e,`requestedAt`);return{requestId:t,turnId:typeof r==`string`?r:null,requestedAt:typeof i==`string`?i:null,attention:n}}function Jl(e,t){if(e===`autopilot.turn-started`)return`Continued execution automatically`;if(e===`autopilot.final-rejected`)return`Kept incomplete supervised work active`;if(e===`autopilot.executor-resumed`)return`Resumed the assigned executor`;if(e===`autopilot.process-monitoring`)return`Monitoring executor background work`;if(e===`autopilot.process-result-consumed`)return`Consumed background work result`;if(e===`autopilot.process-terminated`)return Yl(t,`reason`)===`resourceBudget`?`Stopped background work at its resource limit`:`Stopped executor background work`;if(e===`autopilot.turn-failed`)return Yl(t,`code`)===`START_UNAVAILABLE`?`Automatic continuation could not start: session runtime unavailable`:`Automatic continuation failed`;if(e===`org-plan.attention-required`)return`Needs attention`;if(e===`org-plan.attention-resolved`)return Yl(t,`outcome`)===`failed`?`Attention resolution failed`:`Attention resolved`;if(e!==`autopilot.updated`)return null;let n=Yl(t,`state`),r=Yl(t,`reason`);return n===`completed`?`Completed the supervised plan`:n===`monitoring`&&r===`reconcileFailed`?`Automatic continuation waiting for recovery: agent status unavailable`:n===`attentionRequired`&&r===`noPlanProgress`?`Automatic continuation stopped: no agent progress`:n===`attentionRequired`&&r===`reconcileFailed`?`Automatic continuation stopped: agent status unavailable`:n===`attentionRequired`&&r===`actionRateExceeded`?`Automatic continuation stopped: too many automatic actions`:null}function Yl(e,t){return e&&typeof e==`object`?e[t]:void 0}function Xl(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0?[{path:t.path,additions:t.additions,deletions:t.deletions}]:[]}):[]}function Zl(e){if(typeof e.id!=`string`)return null;let t={...typeof e.turnId==`string`?{turnId:e.turnId}:{},...typeof e.actorTurnId==`string`?{actorTurnId:e.actorTurnId}:{},...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{}};if(e.kind===`reasoning`&&Array.isArray(e.summary)){let n=e.summary.filter(e=>typeof e==`string`).join(`
|
|
18
|
+
`)[0]?.trim()||`empty block`).slice(0,48)}`}async function me(e){y()(await Nc(e,p()))}var he=Sl(),ge=H(he),_e=V(ge),ve=e=>{J(e,nl())};X(_e,e=>{o()&&e(ve)});var k=U(_e,2);Z(k,19,()=>G(x),e=>e.id,(e,t,n)=>{var a=yl(),o=V(a),s=e=>{var n=Kr(),r=H(n),i=e=>{{let n=L(()=>S(G(t).attention)),r=L(()=>c()?.requestId!==G(t).attention.requestId),i=L(()=>`chat-attention-${G(t).attention.requestId}`);ds(e,{get attention(){return G(n)},get historical(){return G(r)},get pending(){return l()},get controlId(){return G(i)},get onresolve(){return u()}})}},a=e=>{var n=al(),r=U(V(n)),i=U(r),a=e=>{var n=Bc(),r=V(n,!0);P(n),W((e,t)=>{Q(n,`datetime`,e),Y(r,t)},[()=>new Date(G(t).occurredAt).toISOString(),()=>ws(G(t).occurredAt)]),J(e,n)};X(i,e=>{G(t).occurredAt&&e(a)});var o=U(i,2),s=e=>{var n=il(),r=V(n),i=V(r);P(r);var a=U(r,2);Z(a,21,()=>G(t).timestamps,e=>`${G(t).id}:${e}`,(e,t)=>{var n=rl(),r=V(n),i=V(r,!0);P(r),P(n),W((e,t)=>{Q(r,`datetime`,e),Y(i,t)},[()=>new Date(G(t)).toISOString(),()=>ws(G(t))]),J(e,n)}),P(a),P(n),W(()=>Y(i,`Show ${G(t).count??``} timestamps`)),J(e,n)};X(o,e=>{G(t).count>1&&e(s)}),P(n),W(()=>Y(r,` ${G(t).text??``}${G(t).count>1?` · ${G(t).count} times`:``} `)),J(e,n)};X(r,e=>{G(t).attention?e(i):e(a,-1)}),J(e,n)},p=e=>{let a=L(()=>oe(G(t)));var o=ll(),s=H(o),c=U(V(s),2),l=e=>{var r=ol(),i=V(r),a=U(i),o=e=>{var r=Gr();W(e=>Y(r,`· ${e??``}`),[()=>O(G(n),G(t).occurredAt)]),J(e,r)},s=L(()=>O(G(n),G(t).occurredAt));X(a,e=>{G(s)&&e(o)}),P(r),W((e,t)=>{Q(r,`datetime`,e),Y(i,`${t??``} `)},[()=>new Date(G(t).occurredAt).toISOString(),()=>ws(G(t).occurredAt)]),J(e,r)};X(c,e=>{G(t).occurredAt&&e(l)}),P(s);var u=U(s,2),p=V(u);i(p,()=>G(t).text),P(u);var y=U(u,2);{let e=L(()=>ne(G(t)));_c(y,{get interactions(){return G(e)},get answers(){return d()},get submittedAnswers(){return f()},get onanswer(){return m()},get onquiz(){return h()},get onpermission(){return g()},get ondecision(){return _()},get onretry(){return v()}})}var b=U(y,2),x=e=>{var n=cl(),i=V(n),o=e=>{var t=sl(),n=U(H(t),2);{let e=L(()=>le(G(a)));Ka(n,{get activities(){return G(e)},variant:`live`})}var i=U(n,2);r(i,()=>G(a)),J(e,t)},s=L(()=>de(G(t))),c=e=>{Is(e,{get activities(){return G(a)},get now(){return G(w)}})};X(i,e=>{G(s)?e(o):e(c,-1)}),P(n),W(e=>Si(n,1,e,`svelte-1im954t`),[()=>gi(de(G(t))?`progress-turn`:`orphan-activity-turn`)]),J(e,n)};X(b,e=>{G(a).length&&e(x)}),J(e,o)},y=e=>{let r=L(()=>ie(G(t)));var a=hl(),o=V(a),s=V(o),c=V(s,!0);P(s);var l=U(s,2),u=e=>{var r=ol(),i=V(r),a=U(i),o=e=>{var r=Gr();W(e=>Y(r,`· ${e??``}`),[()=>O(G(n),G(t).occurredAt)]),J(e,r)},s=L(()=>O(G(n),G(t).occurredAt));X(a,e=>{G(s)&&e(o)}),P(r),W((e,t)=>{Q(r,`datetime`,e),Y(i,`${t??``} `)},[()=>new Date(G(t).occurredAt).toISOString(),()=>ws(G(t).occurredAt)]),J(e,r)};X(l,e=>{G(t).occurredAt&&e(u)}),P(o);var d=U(o,2),f=e=>{var n=dl(),a=H(n),o=e=>{var n=ul(),r=V(n);i(r,()=>G(t).commentary),P(n),J(e,n)};X(a,e=>{G(t).commentary&&e(o)});var s=U(a,2);{let e=L(()=>le(G(r)));Ka(s,{get activities(){return G(e)},variant:`live`})}J(e,n)},p=L(()=>ue(G(t))),m=e=>{var n=pl(),r=V(n),i=e=>{var n=fl(),r=V(n),i=V(r,!0);P(r),Ue(),P(n),W(e=>{Q(n,`aria-expanded`,e),Q(n,`aria-controls`,`commentary-${G(t).id}`),Y(i,C[G(t).id]?`⌄`:`›`)},[()=>!!C[G(t).id]]),K(`click`,n,()=>C[G(t).id]=!C[G(t).id]),J(e,n)};X(r,e=>{G(t).commentary&&e(i)}),P(n),J(e,n)},h=L(()=>G(t).commentary||le(G(r)).length);X(d,e=>{G(p)?e(f):G(h)&&e(m,1)});var g=U(d,2),_=e=>{var n=ml(),r=V(n);i(r,()=>G(t).commentary),P(n),W(()=>Q(n,`id`,`commentary-${G(t).id}`)),J(e,n)},v=L(()=>!ue(G(t))&&G(t).commentary&&C[G(t).id]);X(g,e=>{G(v)&&e(_)});var y=U(g,2),b=V(y);i(b,()=>G(t).answer),P(y),Is(U(y,2),{get activities(){return G(r)},get now(){return G(w)}}),P(a),W(e=>Y(c,e),[()=>ue(G(t))?`working`:`answer`]),J(e,a)},b=e=>{let a=L(()=>ie(G(t)));var o=vl(),s=V(o),c=V(s),l=V(c,!0);P(c);var u=U(c,2),d=e=>{var r=ol(),i=V(r),a=U(i),o=e=>{var r=Gr();W(e=>Y(r,`· ${e??``}`),[()=>O(G(n),G(t).occurredAt)]),J(e,r)},s=L(()=>O(G(n),G(t).occurredAt));X(a,e=>{G(s)&&e(o)}),P(r),W((e,t)=>{Q(r,`datetime`,e),Y(i,`${t??``} `)},[()=>new Date(G(t).occurredAt).toISOString(),()=>ws(G(t).occurredAt)]),J(e,r)};X(u,e=>{G(t).occurredAt&&e(d)}),P(s);var f=U(s,2),p=e=>{var n=dl(),r=H(n),o=e=>{var n=gl(),r=V(n);i(r,()=>G(t).commentary),P(n),J(e,n)};X(r,e=>{G(t).commentary&&e(o)});var s=U(r,2);{let e=L(()=>le(G(a)));Ka(s,{get activities(){return G(e)},variant:`live`})}J(e,n)},m=L(()=>ue(G(t))),h=e=>{var n=_l(),r=H(n),o=U(V(r),2);i(o,()=>G(t).commentary),P(r),Is(U(r,2),{get activities(){return G(a)},get now(){return G(w)}}),J(e,n)};X(f,e=>{G(m)?e(p):e(h,-1)});var g=U(f,2),_=e=>{r(e,()=>G(a))},v=L(()=>ue(G(t)));X(g,e=>{G(v)&&e(_)}),P(o),W((e,t)=>{Si(o,1,e,`svelte-1im954t`),Y(l,t)},[()=>gi(ue(G(t))?`progress-turn`:`commentary-turn`),()=>ue(G(t))?`working`:`commentary`]),J(e,o)};X(o,e=>{G(t).kind===`audit`?e(s):G(t).kind===`user`?e(p,1):G(t).answer===null?G(t).commentary!==null&&e(b,3):e(y,2)}),P(a),W(()=>Si(a,1,gi(G(t).kind===`user`?`prompt-turn`:G(t).kind===`audit`?`audit-item`:`answer-item`),`svelte-1im954t`)),J(e,a)});var A=U(k,2),ye=e=>{var t=bl();_c(V(t),{get interactions(){return G(ee)},get answers(){return d()},get submittedAnswers(){return f()},get onanswer(){return m()},get onquiz(){return h()},get onpermission(){return g()},get ondecision(){return _()},get onretry(){return v()}}),P(t),J(e,t)};X(A,e=>{G(T).length===0&&G(ee).length&&e(ye)});var be=U(A,2),xe=e=>{var t=xl(),n=V(t),i=V(n),o=e=>{var t=sl(),n=U(H(t),2);{let e=L(()=>le(G(ce)));Ka(n,{get activities(){return G(e)},variant:`live`})}var i=U(n,2);r(i,()=>G(ce)),J(e,t)},s=e=>{Is(e,{get activities(){return G(ce)},get now(){return G(w)}})};X(i,e=>{a()?e(o):e(s,-1)}),P(n),P(t),W(()=>Si(n,1,gi(a()?`progress-turn`:`orphan-activity-turn`),`svelte-1im954t`)),J(e,t)};X(be,e=>{G(ce).length&&e(xe)}),P(ge),ui(U(ge,2),()=>t.footer??b),J(e,he),et()}Rr([`click`]);var wl=q(`<p class="svelte-10cj0sh"> </p> <button type="button" class="svelte-10cj0sh">Review Autopilot blocker</button>`,1),Tl=q(`<div class="svelte-10cj0sh"><span> </span> <button type="button" class="svelte-10cj0sh"> </button></div>`),El=q(`<aside class="pending-requests svelte-10cj0sh" aria-label="Pending chat requests" role="status"><strong> </strong> <!> <!></aside>`);function Dl(e,t){$e(t,!0);let n=$(t,`activeTurnId`,3,null),r=L(()=>t.interactions.filter(e=>e.state!==`resolved`&&e.kind!==`orgPlanAttention`&&e.kind!==`orgPlanCheckpoint`&&e.kind!==`autopilotWaitLease`)),i={quiz:`Quiz answer`,userInput:`Answer`,commandApproval:`Command approval`,fileChangeApproval:`File approval`,permissionsApproval:`Permission approval`};function a(e){let t=document.getElementById(e);t?.scrollIntoView({block:`start`});let n=document.querySelector(`.pending-requests`);if(t&&n){let e=t.getBoundingClientRect().top,r=n.getBoundingClientRect().bottom;e<r&&window.scrollBy({top:e-r-8})}t?.focus({preventScroll:!0})}var o=Kr(),s=H(o),c=e=>{var o=El(),s=V(o),c=V(s,!0);P(s);var l=U(s,2),u=e=>{var n=wl(),r=H(n),i=V(r,!0);P(r);var o=U(r,2);W(()=>Y(i,t.attention.supervisorReport||t.attention.attention.summary)),K(`click`,o,()=>a(`chat-attention-${t.attention.requestId}`)),J(e,n)};X(l,e=>{t.attention&&e(u)}),Z(U(l,2),17,()=>G(r),e=>e.key,(e,t)=>{let r=L(()=>G(t).kind===`quiz`&&G(t).turnId&&G(t).turnId!==n());var o=Tl(),s=V(o),c=V(s,!0);P(s);var l=U(s,2),u=V(l);P(l),P(o),W(e=>{Y(c,G(r)?`Earlier quiz remains unanswered. Autopilot can continue.`:`${i[G(t).kind]??`Response`} needed to continue.`),Y(u,`Review ${e??``}`)},[()=>i[G(t).kind]?.toLowerCase()??`request`]),K(`click`,l,()=>a(`chat-request-${G(t).requestId}`)),J(e,o)}),P(o),W(()=>Y(c,t.attention?`Autopilot needs your attention`:`Requests awaiting your response`)),J(e,o)};X(s,e=>{(t.attention||G(r).length)&&e(c)}),J(e,o),et()}Rr([`click`]);var Ol=[150,300,600];function kl(e){return new Promise(t=>setTimeout(t,e))}function Al(e){return e.status===502||e.status===503||e.status===504}async function jl(e=fetch){for(let t=0;t<=Ol.length;t+=1){let n;try{n=await e(`/api/bootstrap`)}catch(e){if(e instanceof Error&&e.name===`AbortError`)throw e;if(t===Ol.length)throw Error(`BOOTSTRAP_FAILED`);await kl(Ol[t]);continue}if(n.ok)return n.json();if(!Al(n)||t===Ol.length)throw Error(`BOOTSTRAP_FAILED`);await kl(Ol[t])}throw Error(`BOOTSTRAP_FAILED`)}var Ml=`gestalt-mobile`,Nl=2,Pl=[`settings`,`drafts`,`cursors`,`messages`];function Fl(e){return new Promise((t,n)=>{let r=e.open(Ml,Nl);r.onupgradeneeded=()=>{for(let e of Pl)r.result.objectStoreNames.contains(e)||r.result.createObjectStore(e)},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)})}function Il(e,t,n){return zl(e.transaction(t,`readonly`).objectStore(t).get(n))}function Ll(e,t,n,r){return zl(e.transaction(t,`readwrite`).objectStore(t).put(r,n))}function Rl(e,t,n){return zl(e.transaction(t,`readwrite`).objectStore(t).delete(n))}function zl(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}var Bl=`chat-projections`,Vl=e=>({version:1,cursor:e.cursor,lifecycle:e.lifecycle,activeTurnId:e.activeTurnId,messages:e.messages.filter(e=>e.role===`user`).slice(-200),activities:[],prompts:e.prompts.slice(-200),interactions:e.interactions.map(({requestId:e,key:t,kind:n,turnId:r,state:i,operationId:a,attemptedOutcome:o})=>({requestId:e,key:t,kind:n,...r?{turnId:r}:{},state:i,...a?{operationId:a}:{},...i===`resolved`&&(o===`approved`||o===`denied`||o===`answered`||o===`dismissed`)?{attemptedOutcome:o}:{},...typeof o==`object`&&o&&(o.decision===`accept`||o.decision===`decline`)?{attemptedOutcome:{decision:o.decision}}:{}})).slice(-200),buffered:[]});function Hl(e=globalThis.indexedDB){if(!e)return{read:async()=>null,write:async()=>{}};let t=Fl(e);return{read:async e=>{try{return await Il(await t,Bl,e)}catch{return null}},write:async(e,n)=>{try{await Ll(await t,Bl,e,Vl(n))}catch{}}}}var Ul=`chat-session`;function Wl(e){return new URLSearchParams(e).get(`chat-session`)?.trim()||null}function Gl(e,t){let n=new URL(e);return n.search=``,n.hash=``,n.searchParams.set(Ul,t),n.toString()}function Kl(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return`gestalt-chat-${(t>>>0).toString(36)}`}function ql(e){let t=Yl(e,`requestId`),n=hs(Yl(e,`payload`));if(typeof t!=`string`||t.length>256||!n)return;let r=Yl(e,`turnId`),i=Yl(e,`requestedAt`);return{requestId:t,turnId:typeof r==`string`?r:null,requestedAt:typeof i==`string`?i:null,attention:n}}function Jl(e,t){if(e===`autopilot.turn-started`)return`Continued execution automatically`;if(e===`autopilot.final-rejected`)return`Kept incomplete supervised work active`;if(e===`autopilot.executor-resumed`)return`Resumed the assigned executor`;if(e===`autopilot.process-monitoring`)return`Monitoring executor background work`;if(e===`autopilot.process-result-consumed`)return`Consumed background work result`;if(e===`autopilot.process-terminated`)return Yl(t,`reason`)===`resourceBudget`?`Stopped background work at its resource limit`:`Stopped executor background work`;if(e===`autopilot.turn-failed`)return Yl(t,`code`)===`START_UNAVAILABLE`?`Automatic continuation could not start: session runtime unavailable`:`Automatic continuation failed`;if(e===`org-plan.attention-required`)return`Needs attention`;if(e===`org-plan.attention-resolved`)return Yl(t,`outcome`)===`failed`?`Attention resolution failed`:`Attention resolved`;if(e!==`autopilot.updated`)return null;let n=Yl(t,`state`),r=Yl(t,`reason`);return n===`completed`?`Completed the supervised plan`:n===`attentionRequired`&&r===`noPlanProgress`?`Automatic continuation stopped: no agent progress`:n===`attentionRequired`&&r===`reconcileFailed`?`Automatic continuation stopped: agent status unavailable`:n===`attentionRequired`&&r===`actionRateExceeded`?`Automatic continuation stopped: too many automatic actions`:null}function Yl(e,t){return e&&typeof e==`object`?e[t]:void 0}function Xl(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0?[{path:t.path,additions:t.additions,deletions:t.deletions}]:[]}):[]}function Zl(e){if(typeof e.id!=`string`)return null;let t={...typeof e.turnId==`string`?{turnId:e.turnId}:{},...typeof e.actorTurnId==`string`?{actorTurnId:e.actorTurnId}:{},...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{}};if(e.kind===`reasoning`&&Array.isArray(e.summary)){let n=e.summary.filter(e=>typeof e==`string`).join(`
|
|
19
19
|
`);return n?{id:e.id,label:`Reasoning summary`,detail:n,...t}:null}if(e.kind===`plan`&&typeof e.text==`string`)return{id:e.id,label:`Plan`,detail:e.text,...t};if(e.kind===`command`&&typeof e.command==`string`)return{id:e.id,label:`Command · ${String(e.status??`unknown`)}`,detail:e.command,...t};if(e.kind===`fileChange`&&Array.isArray(e.paths)){let n=Xl(e.changes);return{id:e.id,label:`File change · ${String(e.status??`unknown`)}`,detail:e.paths.join(`
|
|
20
20
|
`),...n.length?{changes:n}:{},...t}}return e.kind===`tool`&&typeof e.name==`string`?{id:e.id,label:`Tool · ${String(e.status??`unknown`)}`,detail:e.name,...t}:null}var Ql=()=>({sessionId:null,cursor:0,snapshotting:!1,lifecycle:`finished`,activeTurnId:null,messages:[],activities:[],prompts:[],interactions:[],autopilotAuditTruncated:!1,buffered:new Map}),$l=(e=null)=>({...Ql(),sessionId:e});function eu(e){return e.kind===`autopilot`?{id:`item:${e.id}`,role:`audit`,text:`Continued execution automatically`,...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{},...typeof e.controlId==`string`?{controlId:e.controlId}:{},complete:!0}:e.kind!==`user`&&e.kind!==`agent`||typeof e.text!=`string`?null:{id:`item:${e.id}`,role:e.kind===`user`?`user`:`assistant`,text:e.text,...e.phase===`commentary`||e.phase===`final_answer`?{phase:e.phase}:{},...typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)?{occurredAt:e.occurredAt}:{},...typeof e.turnId==`string`?{turnId:e.turnId}:{},complete:!0}}function tu(e){return{id:e.id,role:`audit`,text:e.label,occurredAt:e.occurredAt,...e.controlId?{controlId:e.controlId}:{},...e.attention?{attention:e.attention}:{},complete:!0}}function nu(e){let t=ru(e.occurredAt),n=Jl(e.type,e.payload),r=e.payload&&typeof e.payload==`object`&&typeof e.payload.controlId==`string`?e.payload.controlId:void 0;return n&&t!==void 0?tu({id:`audit:${e.sequence}`,label:n,occurredAt:t,...r?{controlId:r}:{},...e.type===`org-plan.attention-required`&&ql(e.payload)?{attention:ql(e.payload)}:{}}):null}function ru(e){if(typeof e!=`string`)return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function iu(e){let t=ru(e.requestedAt);return{requestId:e.requestId,key:`interaction:${e.requestId}`,kind:e.kind,turnId:e.turnId,payload:`payload`in e?e.payload:null,state:e.resolvedAt?e.outcome===`failed`?`failed`:`resolved`:`pending`,...e.resolvedAt?{attemptedOutcome:e.outcome}:{},...t===void 0?{}:{occurredAt:t}}}function au(e,t){return t===`approved`||t===`denied`||t===`answered`||t===`dismissed`||t===`failed`?t:e?.kind===`quiz`||e?.kind===`userInput`?`answered`:typeof t==`object`&&t&&t.decision===`decline`?`denied`:e?`approved`:void 0}function ou(e,t){return e?t===`finished`||t===`interrupted`?t:`working`:t===`working`||t===`starting`||t===`recoverable`?`finished`:t}function su(e){return[...new Map(e.map(e=>[e.key??e.id??``,e])).values()]}function cu(e,t){return e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?{...t,...t.occurredAt===void 0&&e.occurredAt!==void 0?{occurredAt:e.occurredAt}:{}}:e):[...e,t]}function lu(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=new Map(n.map((e,t)=>[e.id,t])),a=new Set(t.filter(e=>e.state!==`canonical`).map(e=>e.operationId)),o=new Set,s=e.flatMap(e=>{let i=eu(e);if(!i)return[];if(e.kind===`user`){let n=t.find(t=>typeof e.operationId==`string`&&e.operationId===t.operationId||typeof e.turnId==`string`&&e.turnId===t.turnId),s=!n&&t.filter(t=>t.state!==`canonical`&&t.text===e.text).length===1?t.find(t=>t.state!==`canonical`&&t.text===e.text):void 0,c=n??s;if(c){a.delete(c.operationId);let e=r.get(c.key),t={...i,id:c.key,turnId:c.turnId??i.turnId,...i.occurredAt===void 0&&e?.occurredAt!==void 0?{occurredAt:e.occurredAt}:{}};return o.add(t.id),[e&&e.text===t.text&&e.turnId===t.turnId&&e.complete===t.complete&&e.occurredAt===t.occurredAt?e:t]}}if(e.kind===`agent`&&typeof e.turnId==`string`){let t=r.get(`assistant:${e.id}`)??n.find(t=>t.role===`assistant`&&t.turnId===e.turnId&&t.text===i.text&&(t.phase===i.phase||!t.complete));if(t){o.add(t.id);let e={...i,id:t.id,turnId:i.turnId??t.turnId,...i.occurredAt===void 0&&t.occurredAt!==void 0?{occurredAt:t.occurredAt}:{}};return[t.text===e.text&&t.phase===e.phase&&t.occurredAt===e.occurredAt?t:e]}}return o.add(i.id),[i]}),c=t.filter(e=>a.has(e.operationId)).map(e=>r.get(e.key)??{id:e.key,role:`user`,text:e.text,complete:e.state===`failed`,...e.turnId?{turnId:e.turnId}:{}}),l=n.filter(e=>e.role===`assistant`&&e.id.startsWith(`assistant:`)&&!o.has(e.id)),u=su([...c,...l]),d=new Map(s.map((e,t)=>[e.id,t])),f=new Map;for(let e of u){let t=null;if(e.turnId){for(let n=s.length-1;n>=0;--n)if(s[n]?.turnId===e.turnId){t=n;break}}if(t===null){let r=i.get(e.id);if(r!==void 0){for(let e=r-1;e>=0;--e){let r=d.get(n[e].id);if(r!==void 0){t=r;break}}if(t===null)for(let e=r+1;e<n.length;e+=1){let r=d.get(n[e].id);if(r!==void 0){t=r-1;break}}}}let r=t??s.length-1;f.set(r,[...f.get(r)??[],e])}return su([...f.get(-1)??[],...s.flatMap((e,t)=>[e,...f.get(t)??[]])])}function uu(e,t){if(!t||typeof t!=`object`)return $l(e);let n=t;if(!Number.isInteger(n.cursor)||n.cursor<0||!Array.isArray(n.messages)||!Array.isArray(n.prompts)||!Array.isArray(n.interactions))return $l(e);let r=[`submitting`,`accepted`,`failed`,`canonical`],i=[`pending`,`submitting`,`resolved`,`failed`],a=[`starting`,`working`,`finished`,`interrupted`,`recoverable`];return{...$l(e),sessionId:e,cursor:n.cursor,lifecycle:a.includes(n.lifecycle)?n.lifecycle:`finished`,activeTurnId:typeof n.activeTurnId==`string`||n.activeTurnId===null?n.activeTurnId:null,snapshotting:!1,buffered:new Map,messages:n.messages.filter(e=>!!(e&&typeof e.id==`string`&&(e.role===`user`||e.role===`assistant`||e.role===`audit`)&&typeof e.text==`string`&&(e.attention===void 0||ql({...e.attention,payload:e.attention.attention}))&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200),activities:Array.isArray(n.activities)?n.activities.filter(e=>!!(e&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.detail==`string`&&(e.changes===void 0||Array.isArray(e.changes)&&e.changes.every(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0}))&&(e.turnId===void 0||typeof e.turnId==`string`))).slice(-200):[],prompts:n.prompts.filter(e=>!!(e&&typeof e.operationId==`string`&&typeof e.key==`string`&&typeof e.text==`string`&&r.includes(e.state)&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200),interactions:n.interactions.filter(e=>!!(e&&typeof e.requestId==`string`&&typeof e.key==`string`&&typeof e.kind==`string`&&(e.turnId===void 0||e.turnId===null||typeof e.turnId==`string`)&&i.includes(e.state)&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)))).slice(-200)}}function du(e,t){if(!Number.isInteger(t.baseSequence)||t.baseSequence<0)return e;if(t.baseSequence<e.cursor)return Cu({...e,snapshotting:!1});let n=t.items.filter(e=>e.kind===`user`),r=e.prompts.map(t=>{let r=n.some(e=>typeof e.turnId==`string`&&e.turnId===t.turnId||typeof e.operationId==`string`&&e.operationId===t.operationId),i=n.filter(e=>e.text===t.text),a=!t.turnId&&i.length===1&&e.prompts.filter(e=>e.state!==`canonical`&&e.text===t.text).length===1;return r||a?{...t,state:`canonical`}:t}),i=t.interactions.map(iu),a=new Map(e.interactions.map(e=>[e.requestId,e])),o=su(i.map(e=>{let t=a.get(e.requestId);return t?.state===`resolved`?t:{...e,...e.occurredAt===void 0&&t?.occurredAt!==void 0?{occurredAt:t.occurredAt}:{}}})),s=su(t.items.flatMap(e=>{let t=Zl(e);return t?[{...t,key:`activity:${t.id}`}]:[]}).concat((t.activities??[]).map(e=>({...e,key:`activity:${e.id}`})))).map(e=>({id:e.id,label:e.label,detail:e.detail,...e.turnId?{turnId:e.turnId}:{},...e.actorTurnId?{actorTurnId:e.actorTurnId}:{},...e.occurredAt===void 0?{}:{occurredAt:e.occurredAt},...e.changes?{changes:e.changes}:{}})).reduce(cu,[...e.activities]),c=new Map(t.turns.map(e=>[e.id,e])),l=t.items.map(e=>{if(typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt))return e;let t=typeof e.turnId==`string`?c.get(e.turnId):void 0,n=e.kind===`agent`?t?.completedAt??t?.startedAt:t?.startedAt??t?.completedAt;return typeof n==`number`&&Number.isFinite(n)?{...e,occurredAt:n}:e}),u=(t.autopilotAudit??[]).filter(e=>typeof e?.id==`string`&&typeof e.label==`string`&&typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)),d={...e,cursor:Math.max(e.cursor,t.baseSequence),snapshotting:!1,activeTurnId:t.activeTurnId,lifecycle:ou(t.activeTurnId,e.cursor===0&&e.lifecycle===`finished`?`working`:e.lifecycle),prompts:r,messages:su(lu(l,r,e.messages).concat(u.map(tu))).sort((e,t)=>(e.occurredAt??2**53-1)-(t.occurredAt??2**53-1)),activities:s,interactions:o,autopilotAuditTruncated:t.autopilotAuditTruncated===!0,buffered:new Map([...e.buffered].filter(([e])=>e>t.baseSequence))};return Cu({...d,messages:fu(d.messages)})}function fu(e){let t=new Set;return e.filter(e=>e.role!==`audit`||!e.controlId?!0:t.has(e.controlId)?!1:(t.add(e.controlId),!0))}function pu(e){return{...e,snapshotting:!0}}function mu(e,t,n,r){if(!n.trim()||e.prompts.some(e=>e.operationId===t))return e;let i={operationId:t,key:`prompt:${t}`,text:n,state:`submitting`,turnId:null,...typeof r==`number`&&Number.isFinite(r)?{occurredAt:r}:{}};return{...e,lifecycle:`starting`,prompts:[...e.prompts,i],messages:[...e.messages,{id:i.key,role:`user`,text:n,...i.occurredAt===void 0?{}:{occurredAt:i.occurredAt},complete:!1}]}}function hu(e,t,n,r){let i=mu(e,t,n,r);return i===e?e:{...i,lifecycle:`working`}}function gu(e,t,n){return{...e,activeTurnId:n??e.activeTurnId,lifecycle:n?`working`:e.lifecycle,prompts:e.prompts.map(e=>e.operationId===t?{...e,state:`accepted`,turnId:n}:e),messages:e.messages.map(e=>e.id===`prompt:${t}`?{...e,complete:!0,...n?{turnId:n}:{}}:e)}}function _u(e,t){return{...e,lifecycle:`recoverable`,prompts:e.prompts.map(e=>e.operationId===t?{...e,state:`failed`}:e),messages:e.messages.map(e=>e.id===`prompt:${t}`?{...e,complete:!0}:e)}}function vu(e,t,n){return{...e,interactions:e.interactions.map(e=>e.requestId===t&&(e.state===`pending`||e.state===`failed`)?{...e,state:`submitting`,...n?{operationId:n}:{}}:e)}}function yu(e,t,n){return{...e,interactions:e.interactions.map(e=>e.requestId===t&&e.state!==`resolved`?{...e,state:`failed`,attemptedOutcome:n}:e)}}function bu(e,t,n){return{...e,interactions:e.interactions.map(e=>e.requestId===t?{...e,state:`resolved`,...au(e,n)?{attemptedOutcome:au(e,n)}:{}}:e)}}function xu(e,t){if(!Number.isInteger(t.sequence)||t.sequence<=e.cursor)return e;if(e.snapshotting||t.sequence>e.cursor+1){let n=new Map(e.buffered);return n.set(t.sequence,t),{...e,snapshotting:!0,buffered:n}}let n={...e,cursor:t.sequence},r=t.payload,i=ru(t.occurredAt);if(t.type===`agentMessageDelta`&&typeof r?.text==`string`){let e=typeof r.turnId==`string`?r.turnId:n.activeTurnId??void 0,t=`assistant:${typeof r.itemId==`string`?r.itemId:e??`live`}`,a=n.messages.find(e=>e.id===t);n={...n,lifecycle:n.activeTurnId?`working`:n.lifecycle,messages:a?n.messages.map(e=>e.id===t?{...e,text:e.text+r.text,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:{},complete:r.phase===`final_answer`||e.complete,...e.occurredAt===void 0&&i!==void 0?{occurredAt:i}:{}}:e):[...n.messages,{id:t,role:`assistant`,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:{},text:r.text,...e?{turnId:e}:{},...i===void 0?{}:{occurredAt:i},complete:r.phase===`final_answer`}]}}else if((t.type===`agentMessageStarted`||t.type===`agentMessageCompleted`)&&typeof r.text==`string`){let e=`assistant:${typeof r.itemId==`string`?r.itemId:n.activeTurnId??`live`}`,a=n.messages.find(t=>t.id===e),o=t.type===`agentMessageCompleted`,s={id:e,role:`assistant`,text:o&&r.text?r.text:a?.text??r.text,complete:o,...r.phase===`commentary`||r.phase===`final_answer`?{phase:r.phase}:a?.phase?{phase:a.phase}:{},...typeof r.turnId==`string`?{turnId:r.turnId}:a?.turnId?{turnId:a.turnId}:n.activeTurnId?{turnId:n.activeTurnId}:{},...a?.occurredAt===void 0?i===void 0?{}:{occurredAt:i}:{occurredAt:a.occurredAt}};n={...n,lifecycle:n.activeTurnId?`working`:n.lifecycle,messages:a?n.messages.map(t=>t.id===e?s:t):[...n.messages,s]}}else if(t.type===`turnCompleted`||t.type===`turnInterrupted`)n={...n,activeTurnId:null,lifecycle:t.type===`turnCompleted`||n.lifecycle===`finished`?`finished`:`interrupted`,messages:n.messages.map(e=>e.role===`assistant`?{...e,complete:!0}:e)};else if(t.type===`interaction.requested`&&typeof r?.requestId==`string`&&typeof r.kind==`string`){let e=n.interactions.find(e=>e.requestId===r.requestId);if(!e||e.state===`resolved`){let t={requestId:r.requestId,key:`interaction:${r.requestId}`,kind:r.kind,turnId:typeof r.turnId==`string`?r.turnId:n.activeTurnId,payload:r.payload,state:`pending`,...i===void 0?{}:{occurredAt:i}};n={...n,interactions:e?n.interactions.map(e=>e.requestId===r.requestId?t:e):[...n.interactions,t]}}}else if(t.type===`interaction.resolved`&&typeof r?.requestId==`string`)n=bu(n,r.requestId,r.outcome);else if(t.type===`activity.updated`&&typeof r?.id==`string`&&typeof r.label==`string`&&typeof r.detail==`string`){let e=Su(r.changes);n={...n,activities:cu(n.activities,{id:r.id,label:r.label,detail:r.detail,...i===void 0?{}:{occurredAt:i},...e.length?{changes:e}:{},...typeof r.turnId==`string`?{turnId:r.turnId}:n.activeTurnId?{turnId:n.activeTurnId}:{},...typeof r.actorTurnId==`string`?{actorTurnId:r.actorTurnId}:{}})}}else if(t.type===`session.updated`&&r?.activeTurnId!==void 0){let e=typeof r.activeTurnId==`string`?r.activeTurnId:null;n={...n,activeTurnId:e,lifecycle:e?`working`:ou(e,n.lifecycle)}}let a=nu(t);return a&&!n.messages.some(e=>e.id===a.id)&&(n={...n,messages:fu([...n.messages,a])}),n}function Su(e){return!Array.isArray(e)||e.length>1e3?[]:e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return typeof t.path==`string`&&Number.isInteger(t.additions)&&t.additions>=0&&Number.isInteger(t.deletions)&&t.deletions>=0?[{path:t.path,additions:t.additions,deletions:t.deletions}]:[]})}function Cu(e){let t=new Map(e.buffered),n={...e,snapshotting:!1,buffered:t};for(;;){let e=t.get(n.cursor+1);if(!e)return{...n,buffered:t,snapshotting:t.size>0};t.delete(e.sequence),n=xu({...n,buffered:t},e),t=new Map(n.buffered)}}function wu(e){return e.sessionId?e.snapshotting||e.lifecycle===`recoverable`?`Connection interrupted. Reconnecting…`:e.lifecycle===`starting`?`Starting Codex turn…`:e.lifecycle===`working`?`Codex is working…`:e.lifecycle===`interrupted`?`Codex turn interrupted.`:`Ready.`:`Choose a workspace and start a session.`}var Tu={read:async()=>null,write:async()=>{}},Eu=[250,750,1500],Du=e=>!!e&&typeof e==`object`,Ou=e=>Du(e)&&typeof e.path==`string`&&Number.isInteger(e.additions)&&e.additions>=0&&Number.isInteger(e.deletions)&&e.deletions>=0,ku=e=>Du(e)&&typeof e.id==`string`&&typeof e.kind==`string`,Au=e=>Du(e)&&typeof e.id==`string`&&Array.isArray(e.items)&&e.items.every(ku)&&(e.startedAt===null||typeof e.startedAt==`number`)&&(e.completedAt===null||typeof e.completedAt==`number`),ju=e=>!Du(e)||typeof e.requestId!=`string`||typeof e.kind!=`string`||!(e.turnId===null||typeof e.turnId==`string`)||!(e.requestedAt===null||typeof e.requestedAt==`string`)?!1:e.resolvedAt===null?Object.hasOwn(e,`payload`):typeof e.resolvedAt==`string`&&(e.outcome===`approved`||e.outcome===`denied`||e.outcome===`answered`||e.outcome===`dismissed`||e.outcome===`failed`)&&!Object.hasOwn(e,`payload`),Mu=e=>Du(e)&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)&&(e.controlId===void 0||typeof e.controlId==`string`)&&(e.attention===void 0||Du(e.attention)&&!!ql({...e.attention,payload:e.attention.attention})),Nu=e=>Du(e)&&typeof e.id==`string`&&typeof e.label==`string`&&typeof e.detail==`string`&&(e.changes===void 0||Array.isArray(e.changes)&&e.changes.every(Ou))&&(e.turnId===void 0||typeof e.turnId==`string`)&&(e.occurredAt===void 0||typeof e.occurredAt==`number`&&Number.isFinite(e.occurredAt)),Pu=e=>!Du(e)||!Number.isInteger(e.baseSequence)||e.baseSequence<0||!(e.activeTurnId===null||typeof e.activeTurnId==`string`)||!Array.isArray(e.items)||!Array.isArray(e.turns)||!Array.isArray(e.interactions)||!e.items.every(ku)||!e.turns.every(Au)||!e.interactions.every(ju)||e.activities!==void 0&&(!Array.isArray(e.activities)||!e.activities.every(Nu))||e.autopilotAudit!==void 0&&(!Array.isArray(e.autopilotAudit)||!e.autopilotAudit.every(Mu))||e.autopilotAuditTruncated!==void 0&&typeof e.autopilotAuditTruncated!=`boolean`||e.currentSequence!==void 0&&(!Number.isInteger(e.currentSequence)||e.currentSequence<0)?null:e,Fu=class{#e=$l();#t=null;#n=0;#r=-1;#i=null;#a=null;#o=null;#s=0;#c=!1;#l=!1;#u=new Set;#d=null;#f=0;#p=!1;#m=new Set;#h=new Set;#g;constructor(e){this.#g={...e,websocket:e.websocket??(e=>new WebSocket(e)),cache:e.cache??Tu,location:e.location??location,document:e.document??document,window:e.window??window,setTimeout:e.setTimeout??((e,t)=>setTimeout(e,t)),clearTimeout:e.clearTimeout??(e=>clearTimeout(e)),createKey:e.createKey??po,now:e.now??Date.now},this.#g.document.addEventListener(`visibilitychange`,this.#_),this.#g.window.addEventListener(`focus`,this.#_)}get view(){return Object.freeze({...this.#e,status:wu(this.#e),starting:this.#e.lifecycle===`starting`,newEmpty:this.#l&&!Iu(this.#e)})}canSubmit(e){return this.#t?e===`send`?!this.#e.activeTurnId:!!(this.#e.activeTurnId&&(e!==`queue`||this.#g.relay.queueTurnInput)):!1}select(e,t={}){if(this.#p||this.#t===e)return;this.#j(),this.#t=e,e&&t.history===`empty`&&this.#u.add(e),this.#l=e!==null&&this.#u.has(e);let n=++this.#n;this.#e=$l(e),this.#E(),e&&this.#v(e,n)}async send(e,t=this.#g.createKey()){let n=this.#t,r=this.#n,i=`${n}:${r}:${t}`;if(!(!n||!e.trim()||this.#e.activeTurnId||this.#m.has(i))){this.#m.add(i),this.#T(mu(this.#e,t,e.trim(),this.#g.now()));try{let i=await this.#g.relay.startTurn(n,e.trim(),t);this.#O(n,r)&&(this.#D(n),this.#T(gu(this.#e,t,i.activeTurnId??null))),this.#g.onSendAccepted?.(n,t)}catch(e){this.#O(n,r)&&(this.#T(_u(this.#e,t)),this.#g.onSendError?.(e,t))}finally{this.#m.delete(i)}}}async retryPrompt(e){let t=this.#e.prompts.find(t=>t.operationId===e);t?.state===`failed`&&await this.send(t.text,e)}async queue(e,t=this.#g.createKey()){let n=this.#t,r=this.#e.activeTurnId,i=this.#g.relay.queueTurnInput,a=this.#n,o=`${n}:${a}:${t}`;if(!(!n||!r||!i||!e.trim()||this.#m.has(o))){this.#m.add(o),this.#T(hu(this.#e,t,e.trim(),this.#g.now()));try{let o=await i(n,r,e.trim(),t);this.#O(n,a)&&this.#T(gu(this.#e,t,o.activeTurnId)),this.#g.onSendAccepted?.(n,t)}catch(e){this.#O(n,a)&&(this.#T(_u(this.#e,t)),this.#g.onSendError?.(e,t))}finally{this.#m.delete(o)}}}async interruptAndSend(e,t=this.#g.createKey()){let n=this.#t,r=this.#e.activeTurnId,i=this.#n,a=`${n}:${i}:${t}`;if(!(!n||!r||!e.trim()||this.#m.has(a))){this.#m.add(a),this.#T(mu(this.#e,t,e.trim(),this.#g.now()));try{await this.#g.relay.interruptTurn(n,r).catch(()=>void 0);let a=await this.#k(n,i,e.trim(),t);this.#O(n,i)&&this.#T(gu(this.#e,t,a.activeTurnId??null)),this.#g.onSendAccepted?.(n,t)}catch(e){this.#O(n,i)&&(this.#T(_u(this.#e,t)),this.#g.onSendError?.(e,t))}finally{this.#m.delete(a)}}}async interrupt(){let e=this.#t,t=this.#e.activeTurnId;if(!(!e||!t))try{await this.#g.relay.interruptTurn(e,t)}catch{}}async respond(e,t,n=this.#g.createKey()){let r=this.#t,i=this.#n,a=this.#e.interactions.find(t=>t.requestId===e),o=a?.operationId??n,s=`${r}:${i}:${o}`;if(!(!r||!a||a.state===`resolved`||a.state===`submitting`||this.#h.has(s))){this.#h.add(s),this.#T(vu(this.#e,e,o));try{let n=await this.#g.relay.respondInteraction(r,e,t,o),a=n&&(n.outcome===`approved`||n.outcome===`denied`||n.outcome===`answered`||n.outcome===`dismissed`||n.outcome===`failed`)?n.outcome:t;this.#O(r,i)&&this.#T(bu(this.#e,e,a))}catch{this.#O(r,i)&&this.#T(yu(this.#e,e,t))}finally{this.#h.delete(s)}}}async retryInteraction(e,t){let n=this.#e.interactions.find(t=>t.requestId===e);if(n?.state!==`failed`||!n.operationId)return;let r=t??n.attemptedOutcome,i=r===`approved`?{decision:`accept`}:r===`denied`?{decision:`decline`}:r;i!==void 0&&await this.respond(e,i,n.operationId)}refresh(){this.#t&&!this.#l&&this.#S(this.#t,this.#n)}dispose(){this.#p||(this.#p=!0,this.#j(),this.#g.document.removeEventListener(`visibilitychange`,this.#_),this.#g.window.removeEventListener(`focus`,this.#_))}#_=()=>{this.#g.document.visibilityState===`visible`&&this.refresh()};async#v(e,t){let n=this.#l;if(n||this.#S(e,t),this.#y(e,t),n)return;let r=await this.#g.cache.read(e).catch(()=>null);!this.#O(e,t)||this.#r===t||!r||(this.#e=uu(e,r),this.#E())}#y(e,t){if(!this.#O(e,t)||this.#i)return;let n=this.#g.location.protocol===`https:`?`wss:`:`ws:`,r;try{r=this.#g.websocket(`${n}//${this.#g.location.host}/api/sessions/${encodeURIComponent(e)}/events?after=${this.#e.cursor}`)}catch{this.#e={...this.#e,lifecycle:`recoverable`},this.#E(),this.#d=this.#g.setTimeout(()=>this.#y(e,t),Math.min(1e3*2**this.#f++,1e4));return}this.#i=r,r.onopen=()=>{this.#O(e,t)&&this.#i===r&&(this.#f=0,this.#l||this.#S(e,t))},r.onmessage=n=>this.#b(e,t,String(n.data)),r.onclose=()=>{!this.#O(e,t)||this.#i!==r||(this.#i=null,this.#d=this.#g.setTimeout(()=>this.#y(e,t),Math.min(1e3*2**this.#f++,1e4)))}}#b(e,t,n){if(!this.#O(e,t))return;let r;try{r=JSON.parse(n)}catch{return}if(r.type===`relay.resyncRequired`){this.#S(e,t);return}if(r.type!==`relay.event`||!r.event||typeof r.event!=`object`)return;let i=r.event;if(!Number.isInteger(i.sequence)||typeof i.type!=`string`||!this.#x(i))return;([`agentMessageDelta`,`agentMessageStarted`,`agentMessageCompleted`,`activity.updated`,`interaction.requested`,`interaction.resolved`,`turnCompleted`,`turnInterrupted`].includes(i.type)||i.type===`session.updated`&&typeof i.payload.activeTurnId==`string`)&&this.#D(e);let a=xu(this.#e,i);this.#T(a),this.#g.onRelayEvent?.(i),(i.type===`session.updated`||i.type===`plan.updated`||i.type===`plan.closed`||i.type===`agent.activity.updated`||i.type===`session.status.updated`||i.type===`autopilot.updated`||i.type===`org-plan.attention-required`||i.type===`org-plan.attention-resolved`)&&this.#g.onSessionEvent?.(i),a.snapshotting&&this.#S(e,t)}#x(e){let t=e.payload;if(!t||typeof t!=`object`)return e.type===`turnCompleted`||e.type===`turnInterrupted`||e.type===`plan.closed`;let n=t;return e.type===`agentMessageDelta`||e.type===`agentMessageStarted`||e.type===`agentMessageCompleted`?typeof n.text==`string`:e.type===`interaction.requested`?typeof n.requestId==`string`&&typeof n.kind==`string`:e.type===`interaction.resolved`?typeof n.requestId==`string`:e.type===`session.updated`?n.activeTurnId===null||typeof n.activeTurnId==`string`:e.type===`activity.updated`?typeof n.id==`string`&&typeof n.label==`string`&&typeof n.detail==`string`:e.type===`agent.activity.updated`?typeof n.sessionId==`string`&&!!n.root&&Array.isArray(n.subagents):e.type===`session.status.updated`?typeof n.state==`string`&&typeof n.reason==`string`:e.type===`autopilot.updated`||e.type===`org-plan.attention-required`||e.type===`org-plan.attention-resolved`||[`autopilot.continuation-scheduled`,`autopilot.control-issued`,`autopilot.turn-started`,`autopilot.turn-failed`].includes(e.type)?!0:e.type===`plan.updated`||e.type===`plan.closed`}#S(e,t){if(this.#a?.id===e&&this.#a.generation===t)return this.#a.promise;if(!this.#O(e,t))return Promise.resolve();let n=this.#e.snapshotting&&this.#e.buffered.size>0;this.#e=pu(this.#e),this.#E();let r=this.#g.relay.getHistory(e).then(r=>{let i=Pu(r);if(this.#O(e,t)){if(!i){this.#T({...this.#e,snapshotting:!1,lifecycle:`recoverable`});return}this.#s=0,this.#c=!1,this.#o&&this.#g.clearTimeout(this.#o),this.#o=null,this.#r=t,this.#T(du(this.#e,i));for(let t of i.items)t.kind===`user`&&typeof t.operationId==`string`&&this.#g.onHistoryPromptAccepted?.(e,t.operationId);n&&this.#w(e,t)}}).catch(n=>{if(this.#O(e,t)){this.#T({...this.#e,snapshotting:!1,lifecycle:`recoverable`});let r=Eu[this.#s++];r===void 0?!this.#l&&!this.#c&&(this.#c=!0,this.#g.onHistoryError?.(n)):this.#C(e,t,r)}}).finally(()=>{this.#a?.promise===r&&(this.#a=null,this.#O(e,t)&&this.#e.snapshotting&&this.#S(e,t))});return this.#a={id:e,generation:t,promise:r},r}#C(e,t,n){this.#o&&this.#g.clearTimeout(this.#o);let r=this.#g.setTimeout(()=>{this.#o===r&&(this.#o=null,this.#O(e,t)&&this.#S(e,t))},n);this.#o=r}#w(e,t){let n=this.#i;this.#i=null,n?.close(),this.#d&&this.#g.clearTimeout(this.#d),this.#d=null,this.#y(e,t)}#T(e){this.#t&&Iu(e)&&this.#D(this.#t),this.#e=e,this.#E(),this.#t&&this.#g.cache.write(this.#t,this.#e).catch(()=>{})}#E(){this.#g.publish(this.view)}#D(e){this.#u.delete(e),this.#t===e&&(this.#l=!1)}#O(e,t){return!this.#p&&this.#t===e&&this.#n===t}async#k(e,t,n,r){let i;for(let a of[0,50,150,300]){if(!this.#O(e,t))throw Error(`SESSION_CHANGED`);a&&await this.#A(a);try{return await this.#g.relay.startTurn(e,n,r)}catch(e){if(!Lu(e,`SESSION_TURN_ACTIVE`))throw e;i=e}}throw i}#A(e){return new Promise(t=>this.#g.setTimeout(t,e))}#j(){this.#d&&this.#g.clearTimeout(this.#d),this.#d=null,this.#o&&this.#g.clearTimeout(this.#o),this.#o=null,this.#s=0,this.#c=!1,this.#l=!1;let e=this.#i;this.#i=null,e?.close()}};function Iu(e){return!!(e.activeTurnId||e.messages.length||e.activities.length||e.prompts.length||e.interactions.length)}function Lu(e,t){return Du(e)&&e.code===t}var Ru=class{#e=!0;#t=null;#n;constructor(e){this.#n=e}get following(){return this.#e}observeTail(e){this.#e=e}reset(){this.cancel(),this.#e=!0}request(e){e!==`content`&&(this.#e=!0),!(e===`content`&&!this.#e)&&this.#t===null&&(this.#t=this.#n.requestFrame(()=>{this.#t=null,this.#n.scrollTail(e===`initial`||this.#n.reducedMotion()?`auto`:`smooth`)}))}cancel(){this.#t!==null&&this.#n.cancelFrame(this.#t),this.#t=null}},zu=class{afterCommit;request;#e=0;constructor(e,t){this.afterCommit=e,this.request=t}schedule(e){let t=this.#e;this.afterCommit(()=>{t===this.#e&&this.request(e)})}invalidate(){this.#e+=1}};function Bu(e){if(!e||typeof e!=`object`)return!1;let t=e;return(t.state===`working`||t.state===`idle`)&&[`needsYou`,`complete`,`rootTurn`,`agent`,`process`,`autopilot`,`incompleteWithoutContinuation`,`stopped`,`disconnected`,`unknown`].includes(t.reason)&&[`fresh`,`stale`,`reconciling`].includes(t.confidence)&&typeof t.observedAt==`string`&&!Number.isNaN(Date.parse(t.observedAt))&&typeof t.nextExpectedAction==`string`&&t.nextExpectedAction.length>0&&t.nextExpectedAction.length<=240}var Vu={FILE_PREVIEW_NOT_FOUND:`This file or folder no longer exists. Check the path and try again.`,FILE_PREVIEW_UNREADABLE:`This path could not be read. It must be inside the workspace and accessible without symbolic links.`,FILE_PREVIEW_UNSUPPORTED:`Preview supports UTF-8 text files and folders. This item cannot be displayed.`,FILE_PREVIEW_TOO_LARGE:`This file exceeds the 1 MiB preview limit. Open it locally to view its contents.`,INVALID_FILE_PREVIEW:`This file reference is invalid. Check its path and try again.`,RELAY_UNAVAILABLE:`The relay is unavailable. Check the connection and try again.`,SESSION_HISTORY_UNAVAILABLE:`Session history is unavailable. Check the relay connection and try opening the session again.`,SESSION_HISTORY_READ_FAILED:`Session history could not be read. The conversation remains saved; try again shortly.`,SESSION_WRITER_BUSY:`This thread is active in another Codex client. Release it there, then retry sending here.`,SESSION_WORKSPACE_UNAVAILABLE:`This session workspace is unavailable. Your message remains in the conversation for copying; restore workspace access before sending again.`,SESSION_RUNTIME_DEPENDENCY_FAILED:`A required Codex runtime dependency is unavailable. Check Codex, then retry.`,CODEX_PROTOCOL_INCOMPATIBLE:`The installed Codex runtime is incompatible with this relay. Update Codex before retrying.`,SESSION_ROLLOUT_MISSING:`This stored thread is no longer available.`,SESSION_RUNTIME_UNAVAILABLE:`The Codex runtime is unavailable. Retry shortly.`,SESSION_START_FAILED:`The session could not be started. Try again.`,ORG_EXECUTOR_PROFILE_UNAVAILABLE:`The Org-plan executor profile could not be read. Restore the installed Gestalt agent profile and try again.`,ORG_EXECUTOR_PROFILE_INVALID:`The Org-plan executor profile has invalid model settings. Repair the installed profile and try again.`,SESSION_CLOSE_FAILED:`The session could not be closed. Try again.`,SESSION_COPY_FAILED:`The CLI resume command could not be copied. Check clipboard access and try again.`,SESSION_DEFAULTS_READ_FAILED:`Saved session defaults could not be loaded. Using built-in defaults; check the configuration file and reload.`,SESSION_DEFAULTS_SAVE_FAILED:`Session defaults could not be saved. Try again.`,SESSION_MODELS_READ_FAILED:`Models could not be loaded for this provider. Select another provider and try again.`,SESSION_REFRESH_FAILED:`Sessions could not be refreshed. Try again.`,MESSAGE_SEND_FAILED:`The message was not sent. Your draft is preserved.`,GIT_SUMMARY_FAILED:`Repository status could not be loaded. Select it again to retry.`,GIT_PULL_FAILED:`The branch could not be refreshed. Resolve any Git conflicts and try again.`,GIT_CHECKOUT_FAILED:`The branch could not be selected. Refresh Git status and try again.`,GIT_PUSH_FAILED:`The push failed. Refresh Git status and resolve remote divergence first.`,GIT_CLONE_FAILED:`Clone failed.`,WORKSPACE_FILES_READ_FAILED:`Files could not be read. Try again.`,QUIT_FAILED:`Gestalt Mobile could not quit cleanly. Try again or stop it from the terminal.`,UPGRADE_FAILED:`Gestalt could not complete the upgrade and reconnect. Check update-restart.log and reload when Mobile is ready.`,UPGRADE_UNAVAILABLE:`Start Mobile with gestalt mobile to enable upgrades.`,DEBUG_CONTEXT_FAILED:`Session diagnostics could not be read. Reopen DEBUG to try again.`,DEBUG_START_FAILED:`Self DEBUG could not start. Check Sessions for a saved debug session before trying again.`,DEBUG_TRACE_FAILED:`The diagnostic trace could not be opened. Check that the saved JSON file is still available.`,DEBUG_CONFIRMATION_EXPIRED:`The debug confirmation expired. Reopen DEBUG to confirm current session details.`,DEBUG_SOURCE_CHANGED:`The source session changed. Reopen DEBUG to confirm current session details.`};function Hu(e,t){let n=e instanceof Error?e.message:``,r=typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e.code:``,i=Object.hasOwn(Vu,r)?r:Object.hasOwn(Vu,n)?n:t,a=typeof e==`object`&&e&&`retryable`in e?e.retryable===!0:!0;return{code:i,message:Vu[i],retryable:a}}var Uu=q(`<small class="svelte-1izxxv2"> </small>`),Wu=q(`<li class="svelte-1izxxv2"><div class="notification-meta svelte-1izxxv2"><strong class="svelte-1izxxv2"> </strong> <time class="svelte-1izxxv2"> </time></div> <p class="svelte-1izxxv2"> </p> <!></li>`),Gu=q(`<ol aria-label="Recent notifications" class="svelte-1izxxv2"></ol>`),Ku=q(`<p class="empty svelte-1izxxv2" role="status">No recent notifications.</p>`),qu=q(`<main class="notification-history svelte-1izxxv2" aria-labelledby="notification-history-title"><header class="svelte-1izxxv2"><button type="button" class="svelte-1izxxv2">Back</button> <div><h1 id="notification-history-title" tabindex="-1" class="svelte-1izxxv2">Recent notifications</h1> <p class="svelte-1izxxv2">The latest notifications saved in this browser.</p></div></header> <!></main>`);function Ju(e,t){$e(t,!0);let n=z([]),r=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});Gi(()=>t.queue.subscribeHistory(e=>B(n,e)));function i(e){Tr().then(()=>e.focus())}var a=qu(),o=V(a),s=V(o),c=U(s,2);pi(V(c),()=>i),Ue(2),P(c),P(o);var l=U(o,2),u=e=>{var t=Gu();Z(t,21,()=>G(n),e=>e.id,(e,t)=>{var n=Wu(),i=V(n),a=V(i),o=V(a,!0);P(a);var s=U(a,2),c=V(s,!0);P(s),P(i);var l=U(i,2),u=V(l,!0);P(l);var d=U(l,2),f=e=>{var n=Uu(),r=V(n);P(n),W(()=>Y(r,`Repeated ${G(t).occurrences??``} times.`)),J(e,n)};X(d,e=>{G(t).occurrences>1&&e(f)}),P(n),W((e,r)=>{Q(n,`data-kind`,G(t).kind),Y(o,G(t).kind),Q(s,`datetime`,e),Y(c,r),Y(u,G(t).message)},[()=>new Date(G(t).updatedAt).toISOString(),()=>r.format(G(t).updatedAt)]),J(e,n)}),P(t),J(e,t)},d=e=>{J(e,Ku())};X(l,e=>{G(n).length?e(u):e(d,-1)}),P(a),K(`click`,s,function(...e){t.onclose?.apply(this,e)}),J(e,a),et()}Rr([`click`]);var Yu={error:null,success:5e3,warning:1e4,info:7e3},Xu=`gestalt-mobile.notification-history`;function Zu(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function Qu(e,t){try{let n=JSON.parse(e?.getItem(`gestalt-mobile.notification-history`)??`[]`);return Array.isArray(n)?n.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&[`error`,`success`,`warning`,`info`].includes(String(e.kind))&&typeof e.message==`string`&&typeof e.occurrences==`number`&&typeof e.createdAt==`number`&&typeof e.updatedAt==`number`).slice(-t):[]}catch{return[]}}function $u(e={}){let t=e.now??Date.now,n=e.setTimer??setTimeout,r=e.clearTimer??clearTimeout,i=new Set,a=new Set,o=new Map,s=[],c=e.historyLimit??50,l=Qu(e.historyStorage,c),u=0,d=()=>s.map(e=>({...e})),f=()=>[...l].reverse().map(e=>({...e})),p=()=>i.forEach(e=>e(d())),m=()=>{try{e.historyStorage?.setItem(Xu,JSON.stringify(l))}catch{}},h=()=>{m(),a.forEach(e=>e(f()))},g=e=>{let t=o.get(e);t?.handle&&r(t.handle),t&&(t.handle=null)},_=e=>{s.some(t=>t.id===e)&&(g(e),o.delete(e),s=s.filter(t=>t.id!==e),p())},v=e=>{let r=o.get(e);!r||r.pauseReasons.size>0||(r.startedAt=t(),r.handle=n(()=>_(e),r.remaining))};return{enqueue(e){if(e.code){let n=s.find(t=>t.kind===e.kind&&t.code===e.code);if(n)return s=s.map(e=>e.id===n.id?{...e,occurrences:e.occurrences+1}:e),l=l.map(e=>e.id===n.id?{...e,occurrences:e.occurrences+1,updatedAt:t()}:e),p(),h(),n.id}let n=t(),r=`toast-${n}-${++u}`,i={...e,id:r,occurrences:1};s=[...s,i],l=[...l,{...i,createdAt:n,updatedAt:n}].slice(-c);let a=Yu[e.kind];return a!==null&&(o.set(r,{handle:null,remaining:a,startedAt:t(),pauseReasons:new Set}),v(r)),p(),h(),r},dismiss:_,pause(e,n){let r=o.get(e);!r||r.pauseReasons.has(n)||(r.pauseReasons.add(n),r.handle&&(r.remaining=Math.max(0,r.remaining-(t()-r.startedAt)),g(e)))},resume(e,t){let n=o.get(e);!n||!n.pauseReasons.delete(t)||n.pauseReasons.size>0||v(e)},snapshot:d,historySnapshot:f,subscribe(e){return i.add(e),e(d()),()=>i.delete(e)},subscribeHistory(e){return a.add(e),e(f()),()=>a.delete(e)}}}function ed(e){if(e.type!==`activity.updated`||!e.payload||typeof e.payload!=`object`)return null;let t=e.payload;return t.id!==`gestalt-serena-availability`||t.label!==`Serena unavailable`?null:{kind:`warning`,code:`SERENA_UNAVAILABLE`,message:`Serena is unavailable in this session. Use native code tools. Connection availability will be checked when the runtime resumes.`}}var td=q(`<small class="svelte-1a0rutm"> </small>`),nd=q(`<section aria-atomic="true"><span class="toast-symbol svelte-1a0rutm" aria-hidden="true"> </span> <span class="toast-copy svelte-1a0rutm"><strong class="svelte-1a0rutm"> </strong> <span> </span> <!></span> <button type="button" class="svelte-1a0rutm"><span aria-hidden="true">×</span></button></section>`),rd=q(`<div class="toast-viewport svelte-1a0rutm" aria-label="Notifications"></div>`);function id(e,t){$e(t,!0);let n=z([]),r=L(()=>G(n).slice(-3));Gi(()=>t.queue.subscribe(e=>B(n,e)));var i=rd();Z(i,21,()=>G(r),e=>e.id,(e,n)=>{var r=nd();let i;var a=V(r),o=V(a,!0);P(a);var s=U(a,2),c=V(s),l=V(c,!0);P(c);var u=U(c,2),d=V(u,!0);P(u);var f=U(u,2),p=e=>{var t=td(),r=V(t);P(t),W(()=>Y(r,`Repeated ${G(n).occurrences??``} times.`)),J(e,t)};X(f,e=>{G(n).occurrences>1&&e(p)}),P(s);var m=U(s,2);P(r),W(()=>{i=Si(r,1,`toast svelte-1a0rutm`,null,i,{error:G(n).kind===`error`,success:G(n).kind===`success`,warning:G(n).kind===`warning`}),Q(r,`role`,G(n).kind===`error`?`alert`:`status`),Q(r,`aria-live`,G(n).kind===`error`?`assertive`:`polite`),Y(o,G(n).kind===`error`||G(n).kind===`warning`?`!`:G(n).kind===`success`?`✓`:`i`),Y(l,G(n).kind===`error`?`Error`:G(n).kind===`success`?`Success`:G(n).kind===`warning`?`Warning`:`Info`),Y(d,G(n).message),Q(m,`aria-label`,`Dismiss ${G(n).kind} notification`)}),Lr(`pointerenter`,r,()=>t.queue.pause(G(n).id,`hover`)),Lr(`pointerleave`,r,()=>t.queue.resume(G(n).id,`hover`)),K(`focusin`,r,()=>t.queue.pause(G(n).id,`focus`)),K(`focusout`,r,()=>t.queue.resume(G(n).id,`focus`)),K(`click`,m,()=>t.queue.dismiss(G(n).id)),J(e,r)}),P(i),J(e,i),et()}Rr([`focusin`,`focusout`,`click`]);var ad=q(`<main class="evidence-page svelte-1j55xyh"><h1 class="svelte-1j55xyh">Git repository</h1> <p>Choose a destination and clone a repository.</p> <div class="evidence-composer svelte-1j55xyh"><label for="evidence-prompt">Prompt</label> <textarea id="evidence-prompt" class="evidence-prompt svelte-1j55xyh" rows="1">Review repository status</textarea></div></main> <nav class="evidence-nav svelte-1j55xyh" aria-label="Primary evidence navigation"><button type="button" class="svelte-1j55xyh">Sessions</button> <button type="button" aria-pressed="true" class="svelte-1j55xyh">Git</button> <button type="button" class="svelte-1j55xyh">Chat</button></nav> <!>`,1);function od(e,t){$e(t,!0);let n=$u();Gi(()=>{t.variant===`stacked`&&n.enqueue({kind:`success`,message:`Cloned.`}),n.enqueue({kind:`error`,code:`GIT_CLONE_FAILED`,message:`Clone failed.`})});var r=ad();id(U(H(r),4),{get queue(){return n}}),J(e,r),et()}var sd={sessionBase:()=>!0,gitRepositoryTarget:e=>e.isGitRepository,cloneDestination:e=>!e.isGitRepository};function cd(e){let t=new Set,n=(e,r)=>{!e.isGitRepository&&r<=2&&t.add(e.id),e.children.forEach(e=>n(e,r+1))};return e.forEach(e=>n(e,1)),t}function ld(e,t){let n=new Set(e);return t.isGitRepository||(n.has(t.id)?n.delete(t.id):n.add(t.id)),n}function ud(e,t){let n=[],r=(e,i,a)=>{n.push({node:e,level:i,parentId:a}),!e.isGitRepository&&t.has(e.id)&&e.children.forEach(t=>r(t,i+1,e.id))};return e.forEach(e=>r(e,1,null)),n}function dd(e,t){let n=(e,r)=>{if(e.id===t)return r;for(let t of e.children){let i=n(t,[...r,e.id]);if(i)return i}return null};for(let t of e){let e=n(t,[]);if(e)return e}return[]}function fd(e,t){for(let n of e){if(n.id===t)return n;let e=fd(n.children,t);if(e)return e}}function pd(e,t,n,r){if(e){let i=fd(n,e);if(i&&r(i))return i.id;let a=dd(t,e);for(let e of a.toReversed()){let t=fd(n,e);if(t&&r(t))return t.id}}return md(n).find(r)?.id??null}function md(e){let t=[],n=e=>{t.push(e),e.children.forEach(n)};return e.forEach(n),t}var hd=q(`<button class="disclosure svelte-6z3q4v" type="button" tabindex="-1"><span aria-hidden="true"> </span></button>`),gd=q(`<span class="disclosure-spacer svelte-6z3q4v" aria-hidden="true"></span>`),_d=q(`<span class="repository-badge svelte-6z3q4v">Git</span>`),vd=q(`<div class="tree-row svelte-6z3q4v"><!> <button type="button" role="treeitem"><span class="selection-mark svelte-6z3q4v" aria-hidden="true"> </span> <span class="node-copy svelte-6z3q4v"><span class="node-name svelte-6z3q4v"> </span> <span class="node-path svelte-6z3q4v"> </span></span> <!></button></div>`),yd=q(`<div class="filesystem-tree svelte-6z3q4v" role="tree"></div>`);function bd(e,t){$e(t,!0);let n=$(t,`isSelectable`,3,()=>!0),r=z(null),i=on({}),a=L(()=>ud(t.roots,t.expandedIds)),o=L(()=>G(r)&&G(a).some(({node:e})=>e.id===G(r))?G(r):t.selectedId&&G(a).some(({node:e})=>e.id===t.selectedId)?t.selectedId:G(a)[0]?.node.id??null);function s(e){return!e.isGitRepository&&e.children.length>0}function c(e){return e===`.`?`~/`:`~/${e}`}function l(e){B(r,e,!0),i[e]?.focus()}function u(e,t){let n=Math.max(0,Math.min(G(a).length-1,t)),r=G(a)[n];r&&n!==e&&l(r.node.id)}function d(e){n()(e)&&t.onselect(e)}function f(e){s(e)&&t.onexpandedchange(ld(t.expandedIds,e))}function p(e,n,r){let{node:i,parentId:o}=n;switch(e.key){case`ArrowUp`:e.preventDefault(),u(r,r-1);break;case`ArrowDown`:e.preventDefault(),u(r,r+1);break;case`ArrowRight`:if(!s(i))return;e.preventDefault(),t.expandedIds.has(i.id)?G(a)[r+1]?.parentId===i.id&&u(r,r+1):f(i);break;case`ArrowLeft`:if(!t.expandedIds.has(i.id)&&!o)return;e.preventDefault(),s(i)&&t.expandedIds.has(i.id)?f(i):o&&l(o);break;case`Home`:e.preventDefault(),u(r,0);break;case`End`:e.preventDefault(),u(r,G(a).length-1);break;case`Enter`:case` `:e.preventDefault(),d(i);break}}var m=yd();Z(m,23,()=>G(a),e=>e.node.id,(e,a,l)=>{let u=L(()=>G(a).node),m=L(()=>s(G(u)));var h=vd();let g;var _=V(h),v=e=>{var n=hd(),r=V(n),i=V(r,!0);P(r),P(n),W((e,t)=>{Q(n,`aria-label`,e),Y(i,t)},[()=>`${t.expandedIds.has(G(u).id)?`Collapse`:`Expand`} ${G(u).name}`,()=>t.expandedIds.has(G(u).id)?`−`:`+`]),K(`click`,n,()=>f(G(u))),J(e,n)},y=e=>{J(e,gd())};X(_,e=>{G(m)?e(v):e(y,-1)});var b=U(_,2);let x;var S=V(b),C=V(S,!0);P(S);var w=U(S,2),T=V(w),E=V(T,!0);P(T);var D=U(T,2),ee=V(D,!0);P(D),P(w);var te=U(w,2),ne=e=>{J(e,_d())};X(te,e=>{G(u).isGitRepository&&e(ne)}),P(b),Ui(b,(e,t)=>i[t.id]=e,e=>i?.[e.id],()=>[G(u)]),P(h),W((e,n,r,i,s)=>{g=wi(h,``,g,e),x=Si(b,1,`tree-item svelte-6z3q4v`,null,x,{selected:t.selectedId===G(u).id,repository:G(u).isGitRepository}),Q(b,`aria-level`,G(a).level),Q(b,`aria-expanded`,n),Q(b,`aria-selected`,t.selectedId===G(u).id),Q(b,`aria-disabled`,r),Q(b,`tabindex`,G(o)===G(u).id?0:-1),Q(b,`title`,i),Y(C,t.selectedId===G(u).id?`✓`:``),Y(E,G(u).name),Y(ee,s)},[()=>({"--tree-level":Math.min(G(a).level-1,6)}),()=>G(m)?t.expandedIds.has(G(u).id):void 0,()=>!n()(G(u)),()=>c(G(u).relativePath),()=>c(G(u).relativePath)]),Lr(`focus`,b,()=>B(r,G(u).id,!0)),K(`keydown`,b,e=>p(e,G(a),G(l))),K(`click`,b,()=>d(G(u))),J(e,h)}),P(m),W(()=>Q(m,`aria-label`,t.label)),J(e,m),et()}Rr([`click`,`keydown`]);var xd=q(`<section class="evidence-shell svelte-1d6w4ti" aria-labelledby="evidence-title"><p class="eyebrow svelte-1d6w4ti"> </p> <h1 id="evidence-title" class="svelte-1d6w4ti"> </h1> <p class="instructions svelte-1d6w4ti"> </p> <!></section>`);function Sd(e,t){$e(t,!0);let n=(e,t)=>({id:e,name:t,relativePath:e,isGitRepository:!0,children:[]}),r=[{id:`.`,name:`development-workspace-with-a-long-name`,relativePath:`.`,isGitRepository:!1,children:[{id:`dyne`,name:`dyne`,relativePath:`dyne`,isGitRepository:!1,children:[{id:`dyne/mobile-applications`,name:`mobile-applications-and-experiments`,relativePath:`dyne/mobile-applications`,isGitRepository:!1,children:[n(`dyne/mobile-applications/gestalt-mobile`,`gestalt-mobile-with-an-extraordinarily-long-repository-name`)]},n(`dyne/zenroom`,`zenroom`),n(`dyne/zenflows`,`zenflows`),n(`dyne/did`,`did-toolkit`),n(`dyne/api`,`api-gateway`),n(`dyne/docs`,`documentation-portal`)]},{id:`personal`,name:`personal-projects`,relativePath:`personal`,isGitRepository:!1,children:[]}]}],i=z(on(new Set([`.`,`dyne`,`dyne/mobile-applications`]))),a=z(null),o=L(()=>t.context===`sessions`?`dyne/mobile-applications`:`dyne/mobile-applications/gestalt-mobile`),s=L(()=>G(a)??G(o));var c=xd(),l=V(c),u=V(l,!0);P(l);var d=U(l,2),f=V(d,!0);P(d);var p=U(d,2),m=V(p,!0);P(p);var h=U(p,2);{let e=L(()=>t.context===`sessions`?`Session base`:`Git repository`),n=L(()=>t.context===`sessions`?sd.sessionBase:sd.gitRepositoryTarget);bd(h,{get roots(){return r},get expandedIds(){return G(i)},get selectedId(){return G(s)},get label(){return G(e)},get isSelectable(){return G(n)},onexpandedchange:e=>B(i,e,!0),onselect:e=>B(a,e.id,!0)})}P(c),W(()=>{Y(u,t.context===`sessions`?`Sessions`:`Git`),Y(f,t.context===`sessions`?`Session base`:`Git repository`),Y(m,t.context===`sessions`?`Select the folder Codex should use as its working directory.`:`Select a repository for Git actions.`)}),J(e,c),et()}function Cd(e){return e.branch===null?{enabled:!1,reason:`Select a local branch to push.`}:e.upstream?(e.behind??0)>0?{enabled:!1,reason:`Pull upstream changes before pushing.`}:e.ahead<1?{enabled:!1,reason:`There are no commits to push.`}:{enabled:!0,reason:null}:e.branch?e.originUrl?{enabled:!0,reason:null}:{enabled:!1,reason:`No origin remote is configured.`}:{enabled:!1,reason:`Select a local branch to push.`}}function wd(e,t=Date.now()){if(!e)return`Not fetched yet`;let n=Math.max(0,t-new Date(e).getTime()),r=Math.floor(n/6e4);if(r<1)return`Fetched just now`;if(r<60)return`Fetched ${r}m ago`;let i=Math.floor(r/60);return i<24?`Fetched ${i}h ago`:`Fetched ${Math.floor(i/24)}d ago`}function Td(e,t=Date.now()){let n=Date.parse(e);if(!Number.isFinite(n))return`unknown time`;let r=Math.round((n-t)/1e3),i=[[`year`,31536e3],[`month`,2592e3],[`week`,604800],[`day`,86400],[`hour`,3600],[`minute`,60],[`second`,1]],[a,o]=i.find(([,e])=>Math.abs(r)>=e)??i.at(-1);return new Intl.RelativeTimeFormat(void 0,{numeric:`auto`}).format(Math.round(r/o),a)}var Ed=q(`<p class="clone-status svelte-pudr3t" role="status"> </p>`),Dd=q(`<option> </option>`),Od=q(`<p class="svelte-pudr3t"> </p>`),kd=q(`<p id="git-push-help" class="action-help svelte-pudr3t"> </p>`),Ad=q(`<section aria-label="Confirm push"><p> </p> <button type="button"> </button> <button type="button">Cancel</button></section>`),jd=q(`<li class="commit-entry svelte-pudr3t"><div class="commit-subject svelte-pudr3t"><code class="svelte-pudr3t"> </code><span> </span></div> <div class="commit-meta svelte-pudr3t"><span> </span><time class="svelte-pudr3t"> </time></div></li>`),Md=q(`<section class="commit-history svelte-pudr3t" aria-labelledby="recent-commits-title"><h3 id="recent-commits-title" class="svelte-pudr3t">Recent commits</h3> <ol class="commit-list svelte-pudr3t" aria-label="Recent commits"></ol></section>`),Nd=q(`<div class="git-overview svelte-pudr3t"><div class="git-status svelte-pudr3t"><label for="git-branch">Branch</label> <select id="git-branch"></select> <p class="svelte-pudr3t"> </p> <!> <p class="svelte-pudr3t"><time> </time></p> <p class="svelte-pudr3t"> </p></div> <div class="git-actions svelte-pudr3t"><button type="button" class="svelte-pudr3t"><span aria-hidden="true">↑</span> Push</button> <button type="button" class="svelte-pudr3t"><span aria-hidden="true">↓</span> </button> <!></div></div> <!> <!>`,1),Pd=q(`<p>This workspace is not a Git repository.</p>`),Fd=q(`<p role="status">Loading repository status…</p>`),Id=q(`<p><strong> </strong> is available as a Clone destination. Select a Git repository
|
|
21
21
|
to inspect branches and enable repository actions.</p> <div class="git-actions svelte-pudr3t" aria-label="Repository actions unavailable"><button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↑</span> Push</button> <button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↓</span> Pull</button></div>`,1),Ld=q(`<p>Select a folder above to choose a Clone destination or inspect a Git repository.</p> <div class="git-actions svelte-pudr3t" aria-label="Repository actions unavailable"><button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↑</span> Push</button> <button type="button" disabled="" class="svelte-pudr3t"><span aria-hidden="true">↓</span> Pull</button></div>`,1),Rd=q(`<p role="alert"> </p>`),zd=q(`<section class="git-view svelte-pudr3t" aria-labelledby="git-title"><h2 id="git-title" class="visually-hidden">Git</h2> <section class="git-tree svelte-pudr3t" aria-labelledby="git-tree-title"><div class="section-heading svelte-pudr3t"><h3 id="git-tree-title" class="svelte-pudr3t">Repository and clone destination</h3> <p class="svelte-pudr3t">Select any folder. Git repositories enable repository actions; other folders are clone
|
package/dist/client/index.html
CHANGED
|
@@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
16
16
|
<link rel="icon" href="/icons/gestalt-mobile-192.png" />
|
|
17
17
|
<link rel="apple-touch-icon" href="/icons/gestalt-mobile-180.png" />
|
|
18
18
|
<title>Gestalt Mobile</title>
|
|
19
|
-
<script type="module" crossorigin src="/assets/index-
|
|
19
|
+
<script type="module" crossorigin src="/assets/index-CxuAg7aj.js"></script>
|
|
20
20
|
<link rel="stylesheet" crossorigin href="/assets/index-DEzZEQhF.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|
|
@@ -2388,9 +2388,10 @@ describe('production composition', () => {
|
|
|
2388
2388
|
await fixture.app.close();
|
|
2389
2389
|
});
|
|
2390
2390
|
it.each([
|
|
2391
|
-
['transport-lost', new Error('CODEX_CONNECTION_LOST')],
|
|
2392
|
-
['ambiguous RPC failure', new CodexJsonRpcError(-32603, 'internal error')],
|
|
2393
|
-
|
|
2391
|
+
['transport-lost', new Error('CODEX_CONNECTION_LOST'), false],
|
|
2392
|
+
['ambiguous RPC failure', new CodexJsonRpcError(-32603, 'internal error'), false],
|
|
2393
|
+
['manual Off after RPC failure', new CodexJsonRpcError(-32603, 'internal error'), true],
|
|
2394
|
+
])('production recovers through the root after %s without replaying or replacing the executor', async (_scenario, failure, disableBeforeRecovery) => {
|
|
2394
2395
|
const timers = [];
|
|
2395
2396
|
const fixture = await createProductionAutopilotFixture({
|
|
2396
2397
|
autopilotActivity: (sessionId) => {
|
|
@@ -2449,16 +2450,27 @@ describe('production composition', () => {
|
|
|
2449
2450
|
await vi.waitFor(() => expect(fixture.handles
|
|
2450
2451
|
.flatMap((candidate) => candidate.requests)
|
|
2451
2452
|
.filter((request) => request.method === 'turn/start')).toHaveLength(1));
|
|
2452
|
-
// Drive the bounded reinspection once: the durable issued command blocks replay.
|
|
2453
|
-
const refresh = timers.find((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2454
|
-
refresh.fired = true;
|
|
2455
|
-
refresh.callback();
|
|
2456
|
-
await Promise.resolve();
|
|
2457
|
-
await Promise.resolve();
|
|
2458
2453
|
const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
|
|
2454
|
+
const operationQuery = database.prepare("SELECT payload_json FROM session_events WHERE session_id = ? AND type = 'autopilot.operation-failed' ORDER BY sequence LIMIT 1");
|
|
2455
|
+
for (let attempt = 0; attempt < 8 && !operationQuery.get(fixture.sessionId); attempt++) {
|
|
2456
|
+
const pending = timers.find((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2457
|
+
expect(pending).toBeDefined();
|
|
2458
|
+
pending.fired = true;
|
|
2459
|
+
pending.callback();
|
|
2460
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2461
|
+
}
|
|
2462
|
+
await vi.waitFor(() => expect(operationQuery.get(fixture.sessionId)).toBeDefined());
|
|
2463
|
+
const operation = operationQuery.get(fixture.sessionId);
|
|
2459
2464
|
const lifecycle = database
|
|
2460
2465
|
.prepare('SELECT lifecycle_json FROM autopilot_sessions WHERE session_id = ?')
|
|
2461
2466
|
.get(fixture.sessionId);
|
|
2467
|
+
if (failure instanceof CodexJsonRpcError)
|
|
2468
|
+
expect(JSON.parse(operation.payload_json)).toMatchObject({
|
|
2469
|
+
kind: 'executorResume',
|
|
2470
|
+
rpcCode: -32603,
|
|
2471
|
+
});
|
|
2472
|
+
else
|
|
2473
|
+
expect(JSON.parse(operation.payload_json)).not.toHaveProperty('rpcCode');
|
|
2462
2474
|
const replacements = database
|
|
2463
2475
|
.prepare("SELECT count(*) AS count FROM session_events WHERE session_id = ? AND type = 'autopilot.executor-replacement-scheduled'")
|
|
2464
2476
|
.get(fixture.sessionId);
|
|
@@ -2469,9 +2481,36 @@ describe('production composition', () => {
|
|
|
2469
2481
|
},
|
|
2470
2482
|
});
|
|
2471
2483
|
expect(replacements.count).toBe(0);
|
|
2472
|
-
|
|
2484
|
+
const starts = () => fixture.handles
|
|
2473
2485
|
.flatMap((candidate) => candidate.requests)
|
|
2474
|
-
.filter((request) => request.method === 'turn/start')
|
|
2486
|
+
.filter((request) => request.method === 'turn/start');
|
|
2487
|
+
const rootStarts = () => starts().filter((request) => request.params.threadId !== 'child-1');
|
|
2488
|
+
if (disableBeforeRecovery) {
|
|
2489
|
+
const pending = timers.filter((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2490
|
+
await fixture.app.inject({
|
|
2491
|
+
method: 'PUT',
|
|
2492
|
+
url: `/api/sessions/${fixture.sessionId}/autopilot`,
|
|
2493
|
+
payload: { enabled: false },
|
|
2494
|
+
});
|
|
2495
|
+
for (const timer of pending)
|
|
2496
|
+
timer.callback();
|
|
2497
|
+
}
|
|
2498
|
+
else {
|
|
2499
|
+
for (let attempt = 0; attempt < 8 && rootStarts().length === 0; attempt++) {
|
|
2500
|
+
const timer = timers.find((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2501
|
+
expect(timer).toBeDefined();
|
|
2502
|
+
timer.fired = true;
|
|
2503
|
+
timer.callback();
|
|
2504
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2505
|
+
}
|
|
2506
|
+
await vi.waitFor(() => expect(rootStarts()).toHaveLength(1));
|
|
2507
|
+
expect(rootStarts()[0].params.input[0].text).toContain('unconfirmed outcome');
|
|
2508
|
+
}
|
|
2509
|
+
for (const timer of timers.filter((candidate) => candidate.fired))
|
|
2510
|
+
timer.callback();
|
|
2511
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2512
|
+
expect(starts().filter((request) => request.params.threadId === 'child-1')).toHaveLength(1);
|
|
2513
|
+
expect(rootStarts()).toHaveLength(disableBeforeRecovery ? 0 : 1);
|
|
2475
2514
|
await fixture.app.close();
|
|
2476
2515
|
});
|
|
2477
2516
|
it.each([
|
|
@@ -2642,6 +2681,155 @@ describe('production composition', () => {
|
|
|
2642
2681
|
await Promise.resolve();
|
|
2643
2682
|
expect(starts()).toHaveLength(1);
|
|
2644
2683
|
});
|
|
2684
|
+
it.each([false, true])('continues past a disconnected auxiliary helper after L2 completion, reported=%s', async (reported) => {
|
|
2685
|
+
const handles = [];
|
|
2686
|
+
const launch = liveAppServer(handles);
|
|
2687
|
+
const timers = [];
|
|
2688
|
+
const fixture = await createProductionAutopilotFixture({
|
|
2689
|
+
activitySchedule: () => () => { },
|
|
2690
|
+
autopilotSchedule: (callback) => {
|
|
2691
|
+
const timer = { callback, cancelled: false, fired: false };
|
|
2692
|
+
timers.push(timer);
|
|
2693
|
+
return () => {
|
|
2694
|
+
timer.cancelled = true;
|
|
2695
|
+
};
|
|
2696
|
+
},
|
|
2697
|
+
launchAppServer: () => {
|
|
2698
|
+
const server = launch();
|
|
2699
|
+
handles.at(-1).respond = (method) => {
|
|
2700
|
+
if (method === 'thread/list')
|
|
2701
|
+
return {
|
|
2702
|
+
data: [
|
|
2703
|
+
{
|
|
2704
|
+
id: 'old-helper',
|
|
2705
|
+
status: { type: 'notLoaded' },
|
|
2706
|
+
source: {
|
|
2707
|
+
subAgent: { thread_spawn: { agent_path: '/root/editorial_review' } },
|
|
2708
|
+
},
|
|
2709
|
+
},
|
|
2710
|
+
{
|
|
2711
|
+
id: 'previous-executor',
|
|
2712
|
+
status: { type: 'idle' },
|
|
2713
|
+
source: { subAgent: { thread_spawn: { agent_path: '/root/l1' } } },
|
|
2714
|
+
},
|
|
2715
|
+
{
|
|
2716
|
+
id: 'executor',
|
|
2717
|
+
status: { type: 'idle' },
|
|
2718
|
+
source: { subAgent: { thread_spawn: { agent_path: '/root/l2' } } },
|
|
2719
|
+
},
|
|
2720
|
+
],
|
|
2721
|
+
};
|
|
2722
|
+
if (method === 'thread/backgroundTerminals/list')
|
|
2723
|
+
return { terminals: [] };
|
|
2724
|
+
return undefined;
|
|
2725
|
+
};
|
|
2726
|
+
return server;
|
|
2727
|
+
},
|
|
2728
|
+
});
|
|
2729
|
+
onTestFinished(() => fixture.app.close());
|
|
2730
|
+
await fixture.app.inject({
|
|
2731
|
+
method: 'PUT',
|
|
2732
|
+
url: `/api/sessions/${fixture.sessionId}/autopilot`,
|
|
2733
|
+
payload: { enabled: false },
|
|
2734
|
+
});
|
|
2735
|
+
await writeFile(join(fixture.workspacePath, 'autopilot.org'), acceptedL1WithNextTodoPlanText()
|
|
2736
|
+
.replace('* TODO [#B] Next parent', '* WIP [#B] Next parent')
|
|
2737
|
+
.replace('** TODO [#B] Next child', '** DONE [#B] Next child') +
|
|
2738
|
+
`
|
|
2739
|
+
** TODO [#B] Next child two
|
|
2740
|
+
:PROPERTIES:
|
|
2741
|
+
:ID: next-child-two
|
|
2742
|
+
:END:
|
|
2743
|
+
- Why :: Continue the same L1 after its first report.
|
|
2744
|
+
- Change :: Resume the canonical executor.
|
|
2745
|
+
- Tests :: Verify one fenced continuation.
|
|
2746
|
+
- Done when :: The next L2 starts.
|
|
2747
|
+
`);
|
|
2748
|
+
await expect
|
|
2749
|
+
.poll(async () => (await fixture.app.inject(`/api/sessions/${fixture.sessionId}/plan`)).json()
|
|
2750
|
+
.currentStepId)
|
|
2751
|
+
.toBe('next-parent');
|
|
2752
|
+
await fixture.app.inject({
|
|
2753
|
+
method: 'POST',
|
|
2754
|
+
url: `/api/sessions/${fixture.sessionId}/activity/refresh`,
|
|
2755
|
+
});
|
|
2756
|
+
expect((await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json()).toMatchObject({
|
|
2757
|
+
agentActivity: {
|
|
2758
|
+
confidence: 'fresh',
|
|
2759
|
+
aggregateSubagents: 'idle',
|
|
2760
|
+
subagents: expect.arrayContaining([
|
|
2761
|
+
expect.objectContaining({ id: 'old-helper', state: 'disconnected' }),
|
|
2762
|
+
expect.objectContaining({ id: 'previous-executor', state: 'idle' }),
|
|
2763
|
+
expect.objectContaining({ id: 'executor', state: 'idle' }),
|
|
2764
|
+
]),
|
|
2765
|
+
},
|
|
2766
|
+
});
|
|
2767
|
+
if (reported) {
|
|
2768
|
+
const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
|
|
2769
|
+
try {
|
|
2770
|
+
const row = database
|
|
2771
|
+
.prepare('SELECT lifecycle_json FROM autopilot_sessions WHERE session_id = ?')
|
|
2772
|
+
.get(fixture.sessionId);
|
|
2773
|
+
const lifecycle = JSON.parse(row.lifecycle_json);
|
|
2774
|
+
lifecycle.checkpoints = {
|
|
2775
|
+
protocolVersion: 1,
|
|
2776
|
+
planIdentity: createHash('sha256')
|
|
2777
|
+
.update(join(fixture.workspacePath, 'autopilot.org'))
|
|
2778
|
+
.digest('hex'),
|
|
2779
|
+
reportedL1Ids: ['parent'],
|
|
2780
|
+
reportedL2Ids: [
|
|
2781
|
+
JSON.stringify(['parent', 'child']),
|
|
2782
|
+
JSON.stringify(['next-parent', 'next-child']),
|
|
2783
|
+
],
|
|
2784
|
+
acceptedKeys: [],
|
|
2785
|
+
pendingTurnId: null,
|
|
2786
|
+
terminalReviewAccepted: false,
|
|
2787
|
+
};
|
|
2788
|
+
database
|
|
2789
|
+
.prepare('UPDATE autopilot_sessions SET lifecycle_json = ? WHERE session_id = ?')
|
|
2790
|
+
.run(JSON.stringify(lifecycle), fixture.sessionId);
|
|
2791
|
+
}
|
|
2792
|
+
finally {
|
|
2793
|
+
database.close();
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
await fixture.app.inject({
|
|
2797
|
+
method: 'PUT',
|
|
2798
|
+
url: `/api/sessions/${fixture.sessionId}/autopilot`,
|
|
2799
|
+
payload: { enabled: true },
|
|
2800
|
+
});
|
|
2801
|
+
const starts = () => handles
|
|
2802
|
+
.flatMap((handle) => handle.requests)
|
|
2803
|
+
.filter((request) => request.method === 'turn/start');
|
|
2804
|
+
for (let attempt = 0; attempt < 8 && starts().length === 0; attempt += 1) {
|
|
2805
|
+
const timer = timers.find((candidate) => !candidate.cancelled && !candidate.fired);
|
|
2806
|
+
expect(timer).toBeDefined();
|
|
2807
|
+
timer.fired = true;
|
|
2808
|
+
timer.callback();
|
|
2809
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2810
|
+
}
|
|
2811
|
+
await vi.waitFor(() => expect(starts()).toHaveLength(1));
|
|
2812
|
+
const rootThreadId = (await fixture.app.inject(`/api/sessions/${fixture.sessionId}`)).json()
|
|
2813
|
+
.threadId;
|
|
2814
|
+
expect(starts()[0].params).toMatchObject({
|
|
2815
|
+
threadId: reported ? 'executor' : rootThreadId,
|
|
2816
|
+
});
|
|
2817
|
+
// Replayed timers cannot duplicate the root report or the later
|
|
2818
|
+
// continuation of the same canonical executor.
|
|
2819
|
+
for (const timer of timers.filter((candidate) => candidate.fired))
|
|
2820
|
+
timer.callback();
|
|
2821
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2822
|
+
expect(starts()).toHaveLength(1);
|
|
2823
|
+
const database = new DatabaseSync(join(fixture.dataDir, 'relay.sqlite'));
|
|
2824
|
+
try {
|
|
2825
|
+
expect(database
|
|
2826
|
+
.prepare('SELECT count(*) AS count FROM session_events WHERE session_id = ? AND type = ?')
|
|
2827
|
+
.get(fixture.sessionId, reported ? 'autopilot.executor-resumed' : 'autopilot.control-issued')).toMatchObject({ count: 1 });
|
|
2828
|
+
}
|
|
2829
|
+
finally {
|
|
2830
|
+
database.close();
|
|
2831
|
+
}
|
|
2832
|
+
});
|
|
2645
2833
|
it('refreshes unchanged idle evidence so a stale handoff can continue', async () => {
|
|
2646
2834
|
const timers = [];
|
|
2647
2835
|
const fixture = await createProductionAutopilotFixture({
|
|
@@ -4106,7 +4294,7 @@ describe('production composition', () => {
|
|
|
4106
4294
|
});
|
|
4107
4295
|
});
|
|
4108
4296
|
describeCompositionConcern('sessions', () => {
|
|
4109
|
-
it('starts Self DEBUG
|
|
4297
|
+
it('starts Self DEBUG with the source root model and exact skill profile instead of executor defaults', async () => {
|
|
4110
4298
|
const root = await mkdtemp(join(tmpdir(), 'gestalt-debug-root-'));
|
|
4111
4299
|
const dataDir = await mkdtemp(join(tmpdir(), 'gestalt-debug-state-'));
|
|
4112
4300
|
const homeDirectory = await mkdtemp(join(tmpdir(), 'gestalt-debug-home-'));
|
|
@@ -4144,7 +4332,9 @@ describe('production composition', () => {
|
|
|
4144
4332
|
startAppServers: true,
|
|
4145
4333
|
launchAppServer: liveAppServer(handles),
|
|
4146
4334
|
componentVersions: [{ id: 'codex', label: 'Codex', version: '0.144.3' }],
|
|
4147
|
-
sessionModelCatalog: {
|
|
4335
|
+
sessionModelCatalog: {
|
|
4336
|
+
list: async () => ['gpt-5.6-terra', 'configured-debug-model', 'source-root-model'],
|
|
4337
|
+
},
|
|
4148
4338
|
profiles: {
|
|
4149
4339
|
list: async () => [],
|
|
4150
4340
|
require: async () => ({ name: 'default', state: 'ok', status: 'ready' }),
|
|
@@ -4152,7 +4342,22 @@ describe('production composition', () => {
|
|
|
4152
4342
|
});
|
|
4153
4343
|
onTestFinished(() => app.close());
|
|
4154
4344
|
const sourceId = await createComposedSession(app);
|
|
4155
|
-
|
|
4345
|
+
const inheritedSkills = {
|
|
4346
|
+
selectedProfileName: 'js-devel',
|
|
4347
|
+
skills: [
|
|
4348
|
+
{ name: 'disabled', path: '/skills/disabled/SKILL.md', enabled: false },
|
|
4349
|
+
{ name: 'selected', path: '/skills/selected/SKILL.md', enabled: true },
|
|
4350
|
+
],
|
|
4351
|
+
};
|
|
4352
|
+
const database = new DatabaseSync(join(dataDir, 'relay.sqlite'));
|
|
4353
|
+
database
|
|
4354
|
+
.prepare('UPDATE relay_sessions SET model = ?, profile = ?, model_settings_json = ?, effective_skill_selection_json = ? WHERE id = ?')
|
|
4355
|
+
.run('source-root-model', 'supervisor', JSON.stringify({
|
|
4356
|
+
reasoningEffort: 'medium',
|
|
4357
|
+
executorModel: 'configured-debug-model',
|
|
4358
|
+
executorReasoningEffort: 'high',
|
|
4359
|
+
}), JSON.stringify(inheritedSkills), sourceId);
|
|
4360
|
+
database.close();
|
|
4156
4361
|
const confirmation = (await app.inject(`/api/sessions/${sourceId}/debug`)).json();
|
|
4157
4362
|
expect(confirmation.context.mobileSession).toBe(sourceId);
|
|
4158
4363
|
const response = await app.inject({
|
|
@@ -4164,15 +4369,27 @@ describe('production composition', () => {
|
|
|
4164
4369
|
const debug = response.json();
|
|
4165
4370
|
expect(debug.id).not.toBe(sourceId);
|
|
4166
4371
|
expect(debug.workspacePath).toBe(debugRoot);
|
|
4167
|
-
expect(debug.model).toBe('
|
|
4372
|
+
expect(debug.model).toBe('source-root-model');
|
|
4373
|
+
expect(debug.profile).toBe('supervisor');
|
|
4374
|
+
expect(debug.effectiveSkillSelection).toEqual(inheritedSkills);
|
|
4375
|
+
expect(debug.selfDebug.agent.name).toBe('root');
|
|
4168
4376
|
expect(debug.threadId).not.toBe(confirmation.context.codexThread);
|
|
4377
|
+
expect((await app.inject(`/api/sessions/${sourceId}`)).json()).toMatchObject({
|
|
4378
|
+
state: 'ready',
|
|
4379
|
+
activeTurnId: null,
|
|
4380
|
+
});
|
|
4381
|
+
expect(handles
|
|
4382
|
+
.flatMap((handle) => handle.requests)
|
|
4383
|
+
.filter((request) => request.method === 'turn/start' &&
|
|
4384
|
+
request.params.threadId ===
|
|
4385
|
+
confirmation.context.codexThread)).toHaveLength(0);
|
|
4169
4386
|
const request = handles
|
|
4170
4387
|
.flatMap((handle) => handle.requests)
|
|
4171
4388
|
.find((request) => request.method === 'turn/start' &&
|
|
4172
4389
|
request.params.threadId === debug.threadId);
|
|
4173
4390
|
expect(request?.params).toMatchObject({
|
|
4174
|
-
model: '
|
|
4175
|
-
effort: '
|
|
4391
|
+
model: 'source-root-model',
|
|
4392
|
+
effort: 'medium',
|
|
4176
4393
|
input: [{ type: 'text', text: expect.stringContaining('User detected an error') }],
|
|
4177
4394
|
});
|
|
4178
4395
|
expect((await app.inject('/api/sessions'))
|
|
@@ -305,7 +305,13 @@ export async function composeRelayApp(options) {
|
|
|
305
305
|
const continuationPrompt = launchIdentity
|
|
306
306
|
? autopilotExecutorLaunchPrompt(launchIdentity)
|
|
307
307
|
: AUTOPILOT_CONTINUATION_PROMPT;
|
|
308
|
-
const
|
|
308
|
+
const recovery = autopilotStore.find(sessionId);
|
|
309
|
+
const executorRecovery = recovery?.supervision?.outcome === 'probeRequired' &&
|
|
310
|
+
recovery.executor?.commands?.some((command) => command.status === 'issued' && !command.processAction);
|
|
311
|
+
const recoveryInstruction = executorRecovery
|
|
312
|
+
? ' The previous executor resume has an unconfirmed outcome. Inspect the existing canonical executor and its latest turn before continuing. Preserve its physical identity; do not replay an active turn or replace the executor merely because the resume reply failed. Resolve this probe with verified actionable work, a valid wait lease, or genuine structured attention.'
|
|
313
|
+
: '';
|
|
314
|
+
const started = await runtime.startTurn(writer.session, continuationPrompt + recoveryInstruction, controlId, new Date().toISOString());
|
|
309
315
|
if (!started.activeTurnId)
|
|
310
316
|
throw new Error('AUTOPILOT_START_UNAVAILABLE');
|
|
311
317
|
sessions.save(started);
|
|
@@ -1333,18 +1339,13 @@ export async function composeRelayApp(options) {
|
|
|
1333
1339
|
create: (context) => createSelfDebugSession(context, {
|
|
1334
1340
|
createId: randomUUID,
|
|
1335
1341
|
now: () => new Date().toISOString(),
|
|
1336
|
-
settings: async () => {
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
const defaults = await sessionDefaults.read();
|
|
1342
|
+
settings: async (source) => {
|
|
1343
|
+
if (!source.model || !source.effectiveSkillSelection)
|
|
1344
|
+
throw new Error('DEBUG_SOURCE_SETTINGS_UNAVAILABLE');
|
|
1340
1345
|
return {
|
|
1341
|
-
|
|
1342
|
-
model: source
|
|
1343
|
-
|
|
1344
|
-
installed.model,
|
|
1345
|
-
reasoningEffort: source?.modelSettings?.executorReasoningEffort ??
|
|
1346
|
-
defaults?.executorReasoningEffort ??
|
|
1347
|
-
installed.reasoningEffort,
|
|
1346
|
+
name: 'root',
|
|
1347
|
+
model: source.model,
|
|
1348
|
+
reasoningEffort: source.modelSettings?.reasoningEffort,
|
|
1348
1349
|
};
|
|
1349
1350
|
},
|
|
1350
1351
|
capture: async (id, capturedContext, agent) => {
|
|
@@ -1354,38 +1355,13 @@ export async function composeRelayApp(options) {
|
|
|
1354
1355
|
absoluteTracePath: join(captured.root, captured.debug.tracePath),
|
|
1355
1356
|
};
|
|
1356
1357
|
},
|
|
1357
|
-
|
|
1358
|
-
const source = sessions.find(context.mobileSession);
|
|
1359
|
-
if (source && source.threadId === (context.sourceThread ?? context.codexThread))
|
|
1360
|
-
await debugWorkspace.askSource(id, source, debug, async (prompt) => {
|
|
1361
|
-
const sourceRuntime = ownerRuntime(source);
|
|
1362
|
-
// Never resume or replace the source writer merely to ask for diagnostics.
|
|
1363
|
-
if (!sourceRuntime?.ownsWriter(source.id))
|
|
1364
|
-
throw new Error('DEBUG_SOURCE_UNAVAILABLE');
|
|
1365
|
-
if (source.state === 'turnActive' && source.activeTurnId)
|
|
1366
|
-
await sourceRuntime.queueTurnInput(source, source.activeTurnId, prompt, `self-debug-${id}`);
|
|
1367
|
-
else if (source.state === 'ready') {
|
|
1368
|
-
const started = await sourceRuntime.startTurn(source, prompt, `self-debug-${id}`, new Date().toISOString());
|
|
1369
|
-
saveSession(started);
|
|
1370
|
-
activity.observe({
|
|
1371
|
-
sessionId: source.id,
|
|
1372
|
-
occurredAt: started.updatedAt,
|
|
1373
|
-
kind: 'turnStarted',
|
|
1374
|
-
threadId: started.threadId,
|
|
1375
|
-
turnId: started.activeTurnId,
|
|
1376
|
-
});
|
|
1377
|
-
}
|
|
1378
|
-
else
|
|
1379
|
-
throw new Error('DEBUG_SOURCE_UNAVAILABLE');
|
|
1380
|
-
});
|
|
1381
|
-
},
|
|
1382
|
-
createSession: async (id, root, agent) => {
|
|
1358
|
+
createSession: async (id, root, agent, source) => {
|
|
1383
1359
|
await debugWorkspace.prepare();
|
|
1384
1360
|
const debugCatalog = new FilesystemWorkspaceCatalog(root);
|
|
1385
1361
|
const [workspace] = await debugCatalog.list();
|
|
1386
1362
|
return startSession({
|
|
1387
1363
|
workspaceId: workspace.id,
|
|
1388
|
-
profile:
|
|
1364
|
+
profile: source.profile,
|
|
1389
1365
|
provider: 'codex',
|
|
1390
1366
|
model: agent.model,
|
|
1391
1367
|
reasoningEffort: agent.reasoningEffort,
|
|
@@ -1399,6 +1375,7 @@ export async function composeRelayApp(options) {
|
|
|
1399
1375
|
profiles: options.profiles,
|
|
1400
1376
|
skillProfiles,
|
|
1401
1377
|
skillCatalog,
|
|
1378
|
+
inheritedSkillSelection: source.effectiveSkillSelection,
|
|
1402
1379
|
sessionModels,
|
|
1403
1380
|
});
|
|
1404
1381
|
},
|
|
@@ -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 { parseOrgPlanAgentIdentity } from '../../../../shared/org-plan-position.js';
|
|
6
7
|
export const AUTOPILOT_PROMPT_VERSION = 'v13';
|
|
7
8
|
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.';
|
|
8
9
|
export const AUTOPILOT_EXECUTOR_CONTINUATION_PROMPT = 'Continue the same assigned Org L1 from its durable state. A prior turn ending did not complete the objective. Consume any supplied process result and take the next legal L2 action. Whenever an L2 reaches DONE, return its concise structured evidence and end the executor turn so the root can publish that mandatory answer boundary. Also report at the L1 review boundary or through structured attention.';
|
|
@@ -61,6 +62,19 @@ function classifySupervisedActivity(activity, plan) {
|
|
|
61
62
|
return classifyAgentActivity(activity);
|
|
62
63
|
const position = index + 1;
|
|
63
64
|
const retained = activity.subagents.filter((child) => {
|
|
65
|
+
// An authoritative roster retains unloaded auxiliary threads after their
|
|
66
|
+
// work ends. They have no canonical assignment to resume, and rereading
|
|
67
|
+
// that same terminal status cannot advance the current Org milestone.
|
|
68
|
+
// Keep unknown identities and any outstanding process/result in the gate.
|
|
69
|
+
const retiredAuxiliary = child.state === 'disconnected' &&
|
|
70
|
+
child.reason === 'processExited' &&
|
|
71
|
+
child.taskPath &&
|
|
72
|
+
!child.canonicalPosition &&
|
|
73
|
+
!child.canonicalTaskName &&
|
|
74
|
+
!parseOrgPlanAgentIdentity(child.taskPath) &&
|
|
75
|
+
!child.ownedProcesses?.some((process) => process.state !== 'result-consumed' && process.state !== 'terminated-for-budget');
|
|
76
|
+
if (retiredAuxiliary)
|
|
77
|
+
return false;
|
|
64
78
|
const match = /^L([1-9]\d*)$/.exec(child.canonicalPosition ?? '');
|
|
65
79
|
if (!match)
|
|
66
80
|
return true;
|
|
@@ -2627,6 +2627,7 @@ export class AutopilotCoordinator {
|
|
|
2627
2627
|
*/
|
|
2628
2628
|
containOperationFailure(sessionId, error, operation = 'queuedOperation') {
|
|
2629
2629
|
const code = operationFailureCode(error);
|
|
2630
|
+
const rpcCode = operationRpcCode(error);
|
|
2630
2631
|
try {
|
|
2631
2632
|
this.deps.diagnostic?.(sessionId, `operationFailed:${code}`);
|
|
2632
2633
|
}
|
|
@@ -2659,12 +2660,27 @@ export class AutopilotCoordinator {
|
|
|
2659
2660
|
if (!current?.requestedEnabled)
|
|
2660
2661
|
return;
|
|
2661
2662
|
const now = this.deps.now();
|
|
2663
|
+
const protocol = current.supervision ?? startSupervisionProtocol(this.progressKey(sessionId));
|
|
2664
|
+
const requireRootRecovery = operation === 'executorResume' &&
|
|
2665
|
+
!['attentionRequired', 'safetyPaused'].includes(protocol.outcome);
|
|
2662
2666
|
const recovery = {
|
|
2663
2667
|
...current,
|
|
2664
2668
|
state: 'monitoring',
|
|
2665
2669
|
generation: current.generation + 1,
|
|
2666
2670
|
nextEvaluationAt: null,
|
|
2667
2671
|
stopReason: 'reconcileFailed',
|
|
2672
|
+
...(requireRootRecovery
|
|
2673
|
+
? {
|
|
2674
|
+
supervision: {
|
|
2675
|
+
...protocol,
|
|
2676
|
+
outcome: 'probeRequired',
|
|
2677
|
+
probeKey: this.progressKey(sessionId),
|
|
2678
|
+
waitLease: null,
|
|
2679
|
+
retryKey: null,
|
|
2680
|
+
safetyPauseReason: null,
|
|
2681
|
+
},
|
|
2682
|
+
}
|
|
2683
|
+
: {}),
|
|
2668
2684
|
updatedAt: now,
|
|
2669
2685
|
};
|
|
2670
2686
|
try {
|
|
@@ -2674,7 +2690,12 @@ export class AutopilotCoordinator {
|
|
|
2674
2690
|
{
|
|
2675
2691
|
sessionId,
|
|
2676
2692
|
type: 'autopilot.operation-failed',
|
|
2677
|
-
payload: {
|
|
2693
|
+
payload: {
|
|
2694
|
+
code,
|
|
2695
|
+
kind: operation,
|
|
2696
|
+
reason: operationErrorKind(error),
|
|
2697
|
+
...(rpcCode !== undefined ? { rpcCode } : {}),
|
|
2698
|
+
},
|
|
2678
2699
|
occurredAt: now,
|
|
2679
2700
|
},
|
|
2680
2701
|
],
|
|
@@ -2699,6 +2720,17 @@ export class AutopilotCoordinator {
|
|
|
2699
2720
|
return;
|
|
2700
2721
|
}
|
|
2701
2722
|
try {
|
|
2723
|
+
if (requireRootRecovery) {
|
|
2724
|
+
// The issued executor command must stay fenced: a lost reply may hide
|
|
2725
|
+
// accepted work. Reinspection alone cannot resolve that uncertainty.
|
|
2726
|
+
// Give the root one diagnostic continuation through the normal gates
|
|
2727
|
+
// instead of mechanically retrying the same executor indefinitely.
|
|
2728
|
+
this.cancelWaitTimer(sessionId);
|
|
2729
|
+
this.parkedSubscriptions.delete(sessionId);
|
|
2730
|
+
this.evaluate(sessionId);
|
|
2731
|
+
if (this.timers.has(sessionId))
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2702
2734
|
this.armExecutorRefresh(sessionId, this.deps.policy.executorContinuationMaxMs);
|
|
2703
2735
|
}
|
|
2704
2736
|
catch {
|
|
@@ -2760,6 +2792,15 @@ function operationFailureCode(error) {
|
|
|
2760
2792
|
return 'OPERATION';
|
|
2761
2793
|
}
|
|
2762
2794
|
/** Fixed protocol categories only; exception prose and arbitrary codes stay private. */
|
|
2795
|
+
function operationRpcCode(error) {
|
|
2796
|
+
if (error &&
|
|
2797
|
+
typeof error === 'object' &&
|
|
2798
|
+
'code' in error &&
|
|
2799
|
+
typeof error.code === 'number' &&
|
|
2800
|
+
Number.isSafeInteger(error.code))
|
|
2801
|
+
return error.code;
|
|
2802
|
+
return undefined;
|
|
2803
|
+
}
|
|
2763
2804
|
function operationErrorKind(error) {
|
|
2764
2805
|
if (error &&
|
|
2765
2806
|
typeof error === 'object' &&
|
|
@@ -7,16 +7,12 @@ import { selfDebugPrompt, } from '../../../shared/contracts/self-debug.js';
|
|
|
7
7
|
import { RelaySession } from '../sessions/model/relay-session.js';
|
|
8
8
|
export async function createSelfDebugSession(context, deps) {
|
|
9
9
|
const id = deps.createId();
|
|
10
|
-
const
|
|
10
|
+
const source = deps.find(context.mobileSession);
|
|
11
|
+
if (!source || source.threadId !== (context.sourceThread ?? context.codexThread))
|
|
12
|
+
throw new Error('DEBUG_SOURCE_UNAVAILABLE');
|
|
13
|
+
const agent = await deps.settings(source);
|
|
11
14
|
const captured = await deps.capture(id, context, agent);
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
await deps.askSource(id, context, captured.debug);
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
/* Captured evidence remains sufficient to begin. */
|
|
18
|
-
}
|
|
19
|
-
let session = await deps.createSession(id, captured.root, agent);
|
|
15
|
+
let session = await deps.createSession(id, captured.root, agent, source);
|
|
20
16
|
session = { ...session, selfDebug: captured.debug };
|
|
21
17
|
deps.save(session);
|
|
22
18
|
try {
|
|
@@ -3,7 +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 { RelaySession } from '../model/relay-session.js';
|
|
6
|
+
import { RelaySession, } from '../model/relay-session.js';
|
|
7
7
|
import { DEFAULT_SESSION_MODEL } from '../application/start-settings.js';
|
|
8
8
|
import { reconcileSkillSelectionSnapshot, } from '../../skills/model/skill-profile.js';
|
|
9
9
|
import { SkillProfileError } from '../../skills/model/errors.js';
|
|
@@ -31,29 +31,32 @@ export async function startSession(input, deps) {
|
|
|
31
31
|
else {
|
|
32
32
|
model ??= DEFAULT_SESSION_MODEL;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
...
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
34
|
+
let effectiveSkillSelection = deps.inheritedSkillSelection;
|
|
35
|
+
if (!effectiveSkillSelection) {
|
|
36
|
+
const selectedProfile = input.skillProfile
|
|
37
|
+
? await deps.skillProfiles.readGlobalProfile(input.skillProfile)
|
|
38
|
+
: deps.defaultSkillProfile;
|
|
39
|
+
if (input.skillProfile && !selectedProfile)
|
|
40
|
+
throw new SkillProfileError('UNKNOWN_SKILL_PROFILE', 'The selected skill profile does not exist.');
|
|
41
|
+
const [projectProfile, catalog] = await Promise.all([
|
|
42
|
+
deps.skillProfiles.readWorkspaceDefault(workspace.realPath),
|
|
43
|
+
deps.skillCatalog(input.provider, input.profile).list(workspace.realPath),
|
|
44
|
+
]);
|
|
45
|
+
const sourceProfile = selectedProfile ?? projectProfile;
|
|
46
|
+
const reconciledSkills = reconcileSkillSelectionSnapshot(catalog.skills, sourceProfile?.skills);
|
|
47
|
+
effectiveSkillSelection = {
|
|
48
|
+
...(selectedProfile ? { selectedProfileName: selectedProfile.name } : {}),
|
|
49
|
+
skills: [
|
|
50
|
+
...reconciledSkills.skills.map((skill) => ({
|
|
51
|
+
name: skill.name,
|
|
52
|
+
path: skill.path,
|
|
53
|
+
enabled: skill.enabled,
|
|
54
|
+
})),
|
|
55
|
+
...reconciledSkills.missing,
|
|
56
|
+
],
|
|
57
|
+
...(reconciledSkills.warnings.length > 0 ? { warnings: reconciledSkills.warnings } : {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
57
60
|
const branch = await deps.gitBranch?.(workspace.realPath);
|
|
58
61
|
const session = RelaySession.create({
|
|
59
62
|
id: deps.createId(),
|
|
@@ -28,6 +28,7 @@ function migrateWorkspaceGitDefaults(database) {
|
|
|
28
28
|
}
|
|
29
29
|
export function migrate(database) {
|
|
30
30
|
database.exec(schema);
|
|
31
|
+
database.exec('CREATE INDEX IF NOT EXISTS session_events_retention ON session_events(session_id, julianday(occurred_at))');
|
|
31
32
|
database.exec('CREATE TABLE IF NOT EXISTS autopilot_state_quarantine (id INTEGER PRIMARY KEY AUTOINCREMENT, session_id TEXT NOT NULL REFERENCES relay_sessions(id) ON DELETE CASCADE, record_json TEXT NOT NULL, created_at TEXT NOT NULL)');
|
|
32
33
|
database.exec("CREATE INDEX IF NOT EXISTS session_events_autopilot_audit_tail_v3 ON session_events(session_id, type, sequence DESC) WHERE type IN ('autopilot.continuation-scheduled','autopilot.control-issued','autopilot.turn-started','autopilot.turn-failed','autopilot.progress-reset','autopilot.final-rejected','autopilot.executor-resumed','autopilot.process-monitoring','autopilot.process-result-consumed','autopilot.process-terminated','autopilot.updated','org-plan.attention-required','org-plan.attention-resolved')");
|
|
33
34
|
const columns = database.prepare('PRAGMA table_info(relay_sessions)').all();
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
-
export const
|
|
7
|
-
export function
|
|
8
|
-
|
|
6
|
+
export const eventRetentionMs = 48 * 60 * 60 * 1000;
|
|
7
|
+
export function eventRetentionCutoff(occurredAt) {
|
|
8
|
+
const timestamp = Date.parse(occurredAt);
|
|
9
|
+
return Number.isFinite(timestamp) ? new Date(timestamp - eventRetentionMs).toISOString() : null;
|
|
9
10
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { boundedAttentionReport } from '../../../shared/contracts/attention-report.js';
|
|
7
|
+
import { eventRetentionCutoff } from './retention.js';
|
|
7
8
|
export const autopilotAuditEventTypes = [
|
|
8
9
|
'autopilot.turn-started',
|
|
9
10
|
'autopilot.turn-failed',
|
|
@@ -34,7 +35,7 @@ const renderableAutopilotAuditWhere = `
|
|
|
34
35
|
export class SqliteEventJournal {
|
|
35
36
|
db;
|
|
36
37
|
retain;
|
|
37
|
-
constructor(db, retain
|
|
38
|
+
constructor(db, retain) {
|
|
38
39
|
this.db = db;
|
|
39
40
|
this.retain = retain;
|
|
40
41
|
}
|
|
@@ -67,9 +68,18 @@ export class SqliteEventJournal {
|
|
|
67
68
|
this.db
|
|
68
69
|
.prepare('UPDATE relay_sessions SET next_sequence = next_sequence + 1 WHERE id = ?')
|
|
69
70
|
.run(sessionId);
|
|
70
|
-
this.
|
|
71
|
-
.
|
|
72
|
-
|
|
71
|
+
if (this.retain !== undefined) {
|
|
72
|
+
this.db
|
|
73
|
+
.prepare('DELETE FROM session_events WHERE session_id = ? AND sequence NOT IN (SELECT sequence FROM session_events WHERE session_id = ? ORDER BY sequence DESC LIMIT ?)')
|
|
74
|
+
.run(sessionId, sessionId, this.retain);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const cutoff = eventRetentionCutoff(occurredAt);
|
|
78
|
+
if (cutoff)
|
|
79
|
+
this.db
|
|
80
|
+
.prepare('DELETE FROM session_events WHERE session_id = ? AND julianday(occurred_at) < julianday(?)')
|
|
81
|
+
.run(sessionId, cutoff);
|
|
82
|
+
}
|
|
73
83
|
const event = { sessionId, sequence: row.sequence, type, occurredAt, payload };
|
|
74
84
|
this.db.exec('COMMIT');
|
|
75
85
|
return event;
|
|
@@ -53,8 +53,8 @@ export function autopilotAuditLabel(type, payload) {
|
|
|
53
53
|
const reason = property(payload, 'reason');
|
|
54
54
|
if (state === 'completed')
|
|
55
55
|
return 'Completed the supervised plan';
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// Recovery health updates belong to the status and notification pipeline.
|
|
57
|
+
// They may repeat on every reconciliation and are not dialogue milestones.
|
|
58
58
|
if (state === 'attentionRequired' && reason === 'noPlanProgress')
|
|
59
59
|
return 'Automatic continuation stopped: no agent progress';
|
|
60
60
|
if (state === 'attentionRequired' && reason === 'reconcileFailed')
|