agl 43.3.1 → 43.3.2

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/changelog.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 2026-11-12 - 43.3.2
4
+
5
+ ### Fixes
6
+
7
+ - The Flex child no longer waits for a project's whole history before AGL can reconcile the project's session identities (AGL-1713): after `project.register`, the controller asked for the project's sessions with `session.list`, which FlexHarness answered only once it had loaded and repaired every session of the project. A project with a long history took longer than the request's 35-second control budget, the cancelled request could not settle within the two-second grace while the load held the child, so the controller stopped the child, and every new child met the same load. Flex IPC protocol 40 replaces `session.list` with `session.identities`, which answers every session's id, generation and parent in one reply from the project's metadata (FlexHarness `listSessionIdentities`), before the full load settles; a project with more than 2,048 sessions is refused, never cut. The Flex child also writes one line to the controller log for each load of a project's sessions, `Flex project load: {…}`, with the project, the outcome (`loaded`, `failed` or `aborted`), the number of sessions, the snapshots and bytes the store read for it and the time spent parsing them, and FlexHarness's store-read, agent-session, repair and total times.
8
+
9
+ ### Maintenance
10
+
11
+ - Release tooling: pnpm 12.18.0 (from 12.17.0); @git.zone/tsrepo 2.1.0 and @types/node 26.6.6 are current.
12
+
3
13
  ## 2026-11-12 - 43.3.1
4
14
 
5
15
  ### Fixes
@@ -49569,7 +49569,7 @@ description:
49569
49569
  `},"renderProjectsSettings");var{html:TB}=le,nxr={claude:{name:"Claude Code",mark:"claude"},codex:{name:"Codex",mark:"codex"},opencode:{name:"OpenCode",mark:"opencode"},flex:{name:"Flex",mark:"flex"}},cvs=n(i=>{let e=i?Date.parse(i):Number.NaN;return Number.isFinite(e)?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},"clock"),axr=n(i=>{let e=i.files.filter(s=>s.kind!=="unchanged").length,t=n(s=>`${s} ${s===1?"file differs":"files differ"}`,"files");switch(i.state){case"in_sync":return{pill:"In sync",tone:"success",review:!1,text:i.targetId==="flex"?"The next Flex run picks up the latest projection.":"Its files match the latest projection."};case"changes_pending":return{pill:"Changes pending",tone:"warning",review:!0,text:e?`${t(e)} from the latest projection.`:"The latest projection is not applied yet."};case"drifted":return{pill:"Edited outside AGL",tone:"warning",review:!0,text:i.externallyEditedFiles?.length?`${i.externallyEditedFiles.join(", ")} ${i.externallyEditedFiles.length===1?"was":"were"} edited outside AGL.`:"Its files were edited outside AGL."};case"blocked":return{pill:"Blocked",tone:"error",review:!0,text:i.diagnostics.find(s=>s.severity==="error")?.message??"The latest projection cannot be applied to it as it is."};case"applying":return{pill:"Applying",tone:"primary",review:!1,text:"An apply is under way."};case"unbound":return{pill:"Not connected",tone:"default",review:!0,text:"AGL does not write its home yet; connect it in the configuration."}}},"configurationHarnessView"),dvs=n((i,e)=>{let s=(i.state==="read"?i.configuration:null)?.projection,r=[{rows:[{key:"open",icon:"lucide:Files",label:"One master configuration for every harness",description:"Instructions, drivers, inference, skills, agents, commands, MCP servers and command policy. Flex projects it onto each harness; you review and apply each one's changes.",control:TB`<dees-button class="settingsConfigurationOpen" data-action="openConfiguration" size="sm" type="accent"
49570
49570
  text="Open configuration" @clicked=${()=>e.open()}></dees-button>`}]},{header:"Harnesses",headerSuffix:TB`<span>${s?cvs(s.createdAt)?`Projected ${cvs(s.createdAt)}`:"Projected":i.state==="read"?"Not projected yet":""}</span>`,footer:"Read when this section opens. Routing through the AGL proxy is set under Inference in the configuration; from a terminal, agl config does the same.",rows:i.state==="read"?i.configuration.harnesses.map(a=>{let o=axr(a),l=nxr[a.targetId];return{key:`harness-${a.targetId}`,leading:TB`<mp-harness-mark .harness=${l.mark}></mp-harness-mark>`,label:l.name,description:o.text,accessory:TB`<dees-badge data-harness-state=${a.state} .type=${o.tone} .text=${o.pill}></dees-badge>`,...o.review?{control:TB`<dees-button class="settingsConfigurationReview" data-harness=${a.targetId}
49571
49571
  size="sm" type="ghost" text="Review" @clicked=${()=>e.review(a.targetId)}></dees-button>`}:{}}}):[{key:"harnesses",label:i.state==="failed"?"The harnesses could not be read":"Reading the harnesses\u2026",...i.state==="failed"?{description:i.message,control:TB`<dees-button class="settingsConfigurationReread" size="sm" type="ghost" text="Read again"
49572
- @clicked=${()=>e.reread()}></dees-button>`}:{}}]}];return TB`<dees-grouped-list class="settingsConfiguration" .inset=${!1} .sections=${r}></dees-grouped-list>`},"renderConfigurationSettings");var Xke={name:"agl",version:"43.3.1",description:"Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions"};lRe();var hvs="agl",uvs={handoff:"agl.auth.handoff",bundleReload:"agl.bundle.reload"},oxr=5e3,lxr=1e3,cxr=2e4,JKt=n(i=>typeof i=="object"&&i!==null&&!Array.isArray(i),"isRecord"),eYt=n(i=>typeof i=="string"&&i.length>0&&i.length<=256,"isShortString"),JUe=class{constructor(e){this.options=e;let{comms:t}=e;this.subscriptions.push(t.subscribe("signedIn",()=>e.onSignedIn()),t.subscribe("signedOut",()=>e.onSignedOut()),t.subscribe("layout",s=>this.receiveLayout(s)),t.subscribe("bundleReloaded",s=>this.receiveBundleOutcome(s)))}options;static{n(this,"ControllerTabSync")}subscriptions=[];pendingHandoffs=new Set;pendingReloads=new Map;handoffLease;handoffHandlerRemoved=Promise.resolve();releaseReloadLease;closed=!1;setAuthenticated(e){if(this.closed)return;if(!e){this.endHandoffLease();return}if(this.handoffLease)return;let t,s=new Promise(o=>{t=o}),r={abort:new AbortController,granted:s,grant:t};this.handoffLease=r;let{locks:a}=this.options;if(!a){this.answerHandoffs(r);return}a.request(uvs.handoff,{signal:r.abort.signal},()=>new Promise(o=>{if(this.handoffLease!==r){o();return}r.release=o,this.answerHandoffs(r)})).catch(()=>{})}async announceSignedIn(){this.setAuthenticated(!0);let e=this.handoffLease;if(e){let t;await Promise.race([e.granted,new Promise(s=>{t=setTimeout(s,lxr)})]),clearTimeout(t)}await this.send("signedIn",{})}announceSignedOut(){this.send("signedOut",{})}publishLayout(e){this.send("layout",e)}async requestHandoff(e=oxr){if(this.closed)return;let t=new AbortController;this.pendingHandoffs.add(t);try{let s=await this.options.comms.createTypedRequest("handoff").fire({},{timeoutMs:e,abortSignal:t.signal});return JKt(s)&&eYt(s.resumeToken)?s.resumeToken:void 0}catch{return}finally{this.pendingHandoffs.delete(t)}}coordinateBundleReload(e,t=cxr){let{locks:s}=this.options;return this.closed||!s||this.releaseReloadLease?Promise.resolve("lead"):new Promise(r=>{s.request(uvs.bundleReload,{ifAvailable:!0},async a=>{if(a){if(r("lead"),this.closed)return;await new Promise(o=>{this.releaseReloadLease=o});return}r(await this.awaitBundleOutcome(e,t))}).catch(()=>r("lead"))})}releaseBundleReloadLead(){this.releaseReloadLease?.(),this.releaseReloadLease=void 0}announceBundleOutcome(e,t){this.send("bundleReloaded",{version:e,outcome:t})}async close(){if(!this.closed){this.closed=!0;for(let e of this.subscriptions.splice(0))e.unsubscribe();for(let e of[...this.pendingHandoffs])e.abort();for(let e of[...this.pendingReloads.values()])for(let t of[...e])t("timeout");this.endHandoffLease(),this.releaseBundleReloadLead(),await this.options.comms.close()}}endHandoffLease(){let e=this.handoffLease;this.handoffLease=void 0,e&&(e.abort.abort(),e.handler&&(this.handoffHandlerRemoved=e.handler.then(t=>t?.remove())),e.release?.())}answerHandoffs(e){e.handler=this.handoffHandlerRemoved.then(()=>this.handoffLease===e?this.options.comms.createTypedHandler("handoff",()=>this.answerHandoff(e)):void 0).catch(()=>{}),e.handler.then(()=>e.grant())}async send(e,t){if(this.closed)return!1;try{return await this.options.comms.broadcast(e,t),!0}catch{return!1}}async answerHandoff(e){let t;if(this.handoffLease===e)try{t=await this.options.mintHandoff()}catch{t=void 0}if(this.handoffLease!==e||!eYt(t))throw new _g.TypedResponseError("handoff_unavailable");return{resumeToken:t}}receiveLayout(e){if(!JKt(e))return;let t={};typeof e.sidebarWidth=="number"&&Number.isFinite(e.sidebarWidth)&&(t.sidebarWidth=e.sidebarWidth),typeof e.browserSidebarVisible=="boolean"&&(t.browserSidebarVisible=e.browserSidebarVisible),(e.browserPresentation==="default"||e.browserPresentation==="paint"||e.browserPresentation==="video")&&(t.browserPresentation=e.browserPresentation),(e.paintRendering==="gpu"||e.paintRendering==="software")&&(t.paintRendering=e.paintRendering),Object.keys(t).length>0&&this.options.onLayout(t)}awaitBundleOutcome(e,t){return this.closed?Promise.resolve("timeout"):new Promise(s=>{let r=this.pendingReloads.get(e);r||(r=new Set,this.pendingReloads.set(e,r));let a=n(l=>{clearTimeout(o),r.delete(a),r.size===0&&this.pendingReloads.get(e)===r&&this.pendingReloads.delete(e),s(l)},"finish"),o=setTimeout(()=>a("timeout"),t);r.add(a)})}receiveBundleOutcome(e){if(!JKt(e)||!eYt(e.version)||e.outcome!=="current"&&e.outcome!=="stale")return;let t=e.outcome;for(let s of[...this.pendingReloads.get(e.version)??[]])s(t)}};var pvs=n((i,e,t)=>{let{statuses:s,finished:r,errors:a,optimistic:o}=i;if(t.sessionError===!0){s.set(e,"error"),a.add(e),r.delete(e),o.delete(e);return}let l=t.sessionStatus;if(l===void 0)return;let c=s.get(e),d=c==="busy"||c==="retry"||o.has(e);s.set(e,l),l==="busy"||l==="retry"?(a.delete(e),r.delete(e),o.delete(e)):l==="idle"?(o.delete(e),d&&!a.has(e)&&r.add(e)):(a.add(e),r.delete(e),o.delete(e))},"applySessionCardEvent");var dxr=4,tYt="Show the page's video in Paint",fvs=n(async(i,e)=>{e.throwIfAborted();let t;try{return await Promise.race([i(),new Promise((s,r)=>{t=n(()=>r(e.reason),"onAbort"),e.addEventListener("abort",t,{once:!0})})])}finally{t&&e.removeEventListener("abort",t)}},"settleWithin"),uxr=n((i,e,t)=>fvs(()=>i.send(e),t),"sendWithin"),hxr=n(i=>{if(i instanceof Yi.TypedResponseError){let t=i.errorData?.code;if(t==="paint_unavailable"||t==="paint_capture_unavailable")return{kind:"paint-refused",code:t,message:i.errorText}}let e=Mke(i);return e===void 0?void 0:{kind:"viewer-cannot-render",failure:e}},"paintOpenFallback"),Zke=class{constructor(e){this.options=e;this.switcher=new fB({surface:e.surface,capture:n(()=>this.renderer instanceof py?e.canvas:this.renderer?e.video:void 0,"capture"),open:n((t,s)=>t==="paint"?this.openPaint(s):this.openVideo(s),"open"),onError:n(t=>e.onError("Show the browser view",t),"onError")})}options;static{n(this,"ControllerBrowserPresentation")}switcher;renderer;paint;paintOpening=!1;pendingVideoRoutes=[];audio;closed=!1;currentChoice;get mode(){return this.switcher.mode}get choice(){return this.currentChoice}static initialChoice(e,t,s){let r=t==="default"?"controller":"device",a=t==="default"?e:t;return a==="paint"&&s?.paint.state==="unavailable"?{requested:a,reason:{source:r,fallback:{kind:"paint-unavailable",paint:s.paint}}}:{requested:a,reason:{source:r}}}async start(e,t){await this.present(e,t)}async switchTo(e,t){await this.present({requested:e,reason:{source:"view"}},t)}async present(e,t){if(this.closed)return;this.setChoice(e);let s=e.reason.fallback?"video":e.requested;try{await this.switcher.switchTo(s,t)}catch(r){if(this.closed||t?.aborted||s!=="paint")throw r;let a=hxr(r);if(a===void 0)throw r;this.setChoice({requested:e.requested,reason:{...e.reason,fallback:a}}),await this.switcher.switchTo("video",t)}}fallBackToVideo(e){let t=this.currentChoice;this.closed||!t||(this.setChoice({requested:t.requested,reason:{...t.reason,fallback:e}}),this.switcher.switchTo("video").catch(s=>this.options.onError("Show the browser view",s)))}setChoice(e){this.currentChoice=e,this.options.onChoice(e)}async activateSound(){let e=this.renderer;if(!e)throw new Error("The browser view shows nothing yet.");await e.activateAudio()}get soundAvailable(){return this.options.presentation()?.audio.state==="available"}handlePaintTermination(e){let t=this.paint;!t||t.response.paintId!==e.paintId||t.presenter.terminateFromControl(e.source,e.termination)}handleVideoRouteRequest(e){let t=this.paint;if(t&&t.response.paintId===e.paintId){this.openVideoRoute(t,e.routeId).catch(s=>{this.isCurrentPaint(t)&&this.options.onError(tYt,s)});return}this.paintOpening&&this.pendingVideoRoutes.length<dxr&&this.pendingVideoRoutes.push({paintId:e.paintId,routeId:e.routeId})}async close(){if(this.closed)return;this.closed=!0,this.pendingVideoRoutes.length=0;let e=await Promise.allSettled([this.switcher.close()]),t=this.audio;this.audio=void 0;let s=await Promise.allSettled([t?.dispose()]),r=[...e,...s].flatMap(a=>a.status==="rejected"?[a.reason]:[]);if(r.length===1)throw r[0];if(r.length>1)throw new AggregateError(r,"Browser presentation cleanup is incomplete.")}async openVideo(e){let t=await this.audioLifecycle();e.throwIfAborted();let s=new kC({video:this.options.video,client:this.options.client,...t===void 0?{}:{audio:t},focusTarget:this.options.surface,resizeTarget:this.options.surface,onError:n(r=>this.options.onRendererError(r),"onError")});this.setRenderer(s);try{await this.options.startRenderer(s)}catch(r){throw await this.options.stopRenderer(s),this.clearRenderer(s),r}return{firstFrame:s.firstFrame,stop:n(async()=>{try{await this.options.stopRenderer(s)}finally{this.clearRenderer(s)}},"stop")}}async openPaint(e){let t=await this.options.assets(),s=await this.audioLifecycle();e.throwIfAborted();let r=new py({canvas:this.options.canvas,client:this.options.client,...s===void 0?{}:{audio:s},focusTarget:this.options.surface,resizeTarget:this.options.surface,picture:{...R8,...t.paint,...Rds(this.options.paintRendering())},originalVideo:xke,onError:n(o=>{Mke(o.cause)===void 0&&this.options.onRendererError(o)},"onError")});this.setRenderer(r),this.paintOpening=!0;let a;try{await this.options.startRenderer(r);let o=r.pictureRenderer?.videoWorkerIncarnation;if(!o)throw new Error("The Paint renderer has no worker.");a=await this.options.socket.fire("controller.browser.paint.open",{viewId:this.options.viewId,streamGeneration:this.options.streamGeneration,workerIncarnation:o},{maxRetries:0,abortSignal:e});let l=a;await fvs(()=>Promise.all([l.packets.opened,l.control.opened]),e);let c=new AbortController,d=new iB({expectedHello:l.hello,renderer:r,sendPacket:n((h,p)=>uxr(l.control,h,p),"sendPacket"),closeSource:n(()=>this.closePaintSource(l),"closeSource"),onFailure:n(h=>{Mke(h)===void 0&&this.options.onError("Run the browser Paint view",h)},"onFailure"),onTermination:n(h=>this.onPaintTermination(l.paintId,h),"onTermination"),signal:c.signal}),u={response:l,presenter:d,renderer:r,routes:new Set,abortController:c,removeSessionEnd:r.observePaintSessionEnd(h=>{this.closeVideoRoutes(u),this.onPaintSessionEnd(u,h)})};this.paint=u,this.receivePaintPackets(u);for(let h of this.pendingVideoRoutes.splice(0))h.paintId===l.paintId&&this.openVideoRoute(u,h.routeId).catch(p=>{this.isCurrentPaint(u)&&this.options.onError(tYt,p)});return{firstFrame:r.firstFrame,stop:n(()=>this.stopPaint(u),"stop")}}catch(o){throw a&&await this.closePaintSource(a).catch(()=>{}),await r.stop().catch(()=>{}),this.clearRenderer(r),o}finally{this.paintOpening=!1,this.pendingVideoRoutes.length=0}}async receivePaintPackets(e){try{for(;!e.abortController.signal.aborted;){let t=await e.response.packets.receive();if(t===void 0){await e.response.packets.accept();return}e.presenter.receivePacket(t)}}catch(t){if(this.paint!==e||e.abortController.signal.aborted)return;this.options.onError("Run the browser Paint view",t),await this.stopPaint(e).catch(()=>{})}}onPaintTermination(e,t){this.paint?.response.paintId!==e||this.closed||(t.kind==="unsupported"?this.fallBackToVideo({kind:"page-unsupported",reasonCode:t.reasonCode}):t.kind==="failure"&&this.options.onError("Run the browser Paint view",new Error(t.message)))}onPaintSessionEnd(e,t){if(this.paint!==e||this.closed||t===void 0)return;let s=Mke(t);s!==void 0&&this.fallBackToVideo({kind:"viewer-cannot-render",failure:s})}isCurrentPaint(e){return this.paint===e&&!this.closed}async stopPaint(e){this.paint===e&&(this.paint=void 0),e.abortController.abort(new Error("The Paint stream closed.")),e.removeSessionEnd(),this.closeVideoRoutes(e);try{await e.presenter.close()}finally{this.clearRenderer(e.renderer)}}async closePaintSource(e){let t=new Error("The Paint stream closed.");await Promise.allSettled([e.packets.abort(t),e.control.abort(t)]),this.options.socket.isConnected&&await this.options.socket.fire("controller.browser.paint.close",{viewId:this.options.viewId,paintId:e.paintId,streamGeneration:this.options.streamGeneration},{maxRetries:0})}async openVideoRoute(e,t){let s=e.renderer.pictureRenderer;if(!s)throw new Error("The Paint renderer has no worker.");let r=await this.options.socket.fire("controller.browser.paint.video.openRoute",{viewId:this.options.viewId,streamGeneration:this.options.streamGeneration,paintId:e.response.paintId,routeId:t},{maxRetries:0,abortSignal:e.abortController.signal}),a=new pB({..._ke,routeId:r.routeId,packets:r.packets,receipts:r.receipts,renderer:s,signal:e.abortController.signal,onEnded:n(()=>{e.routes.delete(a)},"onEnded"),onFailure:n(o=>{e.routes.delete(a),this.isCurrentPaint(e)&&this.options.onError(tYt,o)},"onFailure")});e.routes.add(a);try{await a.start()}catch(o){throw e.routes.delete(a),o}}closeVideoRoutes(e){for(let t of e.routes)t.close().catch(s=>this.options.onError("Close the browser view's video",s));e.routes.clear()}async audioLifecycle(){if(this.options.presentation()?.audio.state!=="available")return;if(this.audio)return this.audio;let e=await this.options.assets();if(this.audio)return this.audio;let t={openAudioRelay:n(s=>this.openAudioRelay(s),"openAudioRelay")};return this.audio=new oB({viewerId:this.options.viewId,client:new lB(t),assets:e.audio,sampleCreditBytes:e.audioSampleCredit.bytes,sampleCreditEvents:e.audioSampleCredit.events,clockPolicy:gke,onError:n(s=>this.options.onError("Play the browser sound",s),"onError")}),this.audio}async openAudioRelay(e){let t=await this.options.socket.fire("controller.browser.audio.open",{viewId:this.options.viewId,streamGeneration:this.options.streamGeneration},{maxRetries:0,abortSignal:e.signal}),r=await new dB({events:t.events,operations:t.operations,sampleCreditBytes:t.sampleCredit.bytes,sampleCreditEvents:t.sampleCredit.events,signal:e.signal}).openAudioRelay(e);return{sendCommand:n(a=>r.sendCommand(a),"sendCommand"),close:n(async()=>{try{await r.close()}finally{this.options.socket.isConnected&&await this.options.socket.fire("controller.browser.audio.close",{viewId:this.options.viewId,audioId:t.audioId,streamGeneration:this.options.streamGeneration},{maxRetries:0}).catch(()=>{})}},"close")}}setRenderer(e){this.renderer=e,this.options.surface.dataset.presentation=e instanceof py?"paint":"video",this.options.onRenderer(e)}clearRenderer(e){this.renderer===e&&(this.renderer=void 0,this.options.onRenderer(void 0))}};var iYt=n((i,e,t)=>`${i}:${e}\0${t}`,"projectMutationScope"),mvs=n((i,e)=>iYt("draft",i,`${e}`),"draftScopeOf"),gvs=n((i,e)=>iYt("conversation",i,e),"conversationScopeOf"),e8e=class{constructor(e){this.onChange=e}onChange;static{n(this,"ControllerMutationLocks")}held=new Map;startedCount=0;get started(){return this.startedCount}get anyHeld(){return this.held.size>0}isHeld(e){return this.held.has(e)}isProjectHeld(e){let t=["draft","conversation"].map(s=>iYt(s,e,""));return[...this.held.keys()].some(s=>t.some(r=>s.startsWith(r)))}holds(e){return[...this.held.values()].includes(e)}acquire(e){if(this.held.has(e))return;let t=Symbol(e);return this.held.set(e,t),this.startedCount+=1,this.onChange(),t}release(e){for(let[t,s]of this.held)if(s===e)return this.held.delete(t),this.onChange(),!0;return!1}releaseAll(){this.held.size!==0&&(this.held.clear(),this.onChange())}};var ONc=50,vvs=n((i,e)=>[...i,e].slice(-50),"appendErrorJournalEntry"),sYt=n(i=>Number.isFinite(i)?new Date(i).toISOString():"unknown","formatTimestamp"),pxr=n((i,e)=>{let t=[`[${e}] ${sYt(i.at)} - ${i.operation}`,`message: ${i.message}`];i.reference!==void 0&&t.push(`reference: ${i.reference}`);let s=i.detail;return s!==void 0?(t.push(`controller operation: ${s.operation}`,`controller time: ${sYt(s.at)}`,`controller cause: ${s.name}: ${s.message}`),s.stack&&t.push("controller stack:",s.stack)):i.reference!==void 0&&t.push("controller cause: unavailable"),t.join(`
49572
+ @clicked=${()=>e.reread()}></dees-button>`}:{}}]}];return TB`<dees-grouped-list class="settingsConfiguration" .inset=${!1} .sections=${r}></dees-grouped-list>`},"renderConfigurationSettings");var Xke={name:"agl",version:"43.3.2",description:"Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions"};lRe();var hvs="agl",uvs={handoff:"agl.auth.handoff",bundleReload:"agl.bundle.reload"},oxr=5e3,lxr=1e3,cxr=2e4,JKt=n(i=>typeof i=="object"&&i!==null&&!Array.isArray(i),"isRecord"),eYt=n(i=>typeof i=="string"&&i.length>0&&i.length<=256,"isShortString"),JUe=class{constructor(e){this.options=e;let{comms:t}=e;this.subscriptions.push(t.subscribe("signedIn",()=>e.onSignedIn()),t.subscribe("signedOut",()=>e.onSignedOut()),t.subscribe("layout",s=>this.receiveLayout(s)),t.subscribe("bundleReloaded",s=>this.receiveBundleOutcome(s)))}options;static{n(this,"ControllerTabSync")}subscriptions=[];pendingHandoffs=new Set;pendingReloads=new Map;handoffLease;handoffHandlerRemoved=Promise.resolve();releaseReloadLease;closed=!1;setAuthenticated(e){if(this.closed)return;if(!e){this.endHandoffLease();return}if(this.handoffLease)return;let t,s=new Promise(o=>{t=o}),r={abort:new AbortController,granted:s,grant:t};this.handoffLease=r;let{locks:a}=this.options;if(!a){this.answerHandoffs(r);return}a.request(uvs.handoff,{signal:r.abort.signal},()=>new Promise(o=>{if(this.handoffLease!==r){o();return}r.release=o,this.answerHandoffs(r)})).catch(()=>{})}async announceSignedIn(){this.setAuthenticated(!0);let e=this.handoffLease;if(e){let t;await Promise.race([e.granted,new Promise(s=>{t=setTimeout(s,lxr)})]),clearTimeout(t)}await this.send("signedIn",{})}announceSignedOut(){this.send("signedOut",{})}publishLayout(e){this.send("layout",e)}async requestHandoff(e=oxr){if(this.closed)return;let t=new AbortController;this.pendingHandoffs.add(t);try{let s=await this.options.comms.createTypedRequest("handoff").fire({},{timeoutMs:e,abortSignal:t.signal});return JKt(s)&&eYt(s.resumeToken)?s.resumeToken:void 0}catch{return}finally{this.pendingHandoffs.delete(t)}}coordinateBundleReload(e,t=cxr){let{locks:s}=this.options;return this.closed||!s||this.releaseReloadLease?Promise.resolve("lead"):new Promise(r=>{s.request(uvs.bundleReload,{ifAvailable:!0},async a=>{if(a){if(r("lead"),this.closed)return;await new Promise(o=>{this.releaseReloadLease=o});return}r(await this.awaitBundleOutcome(e,t))}).catch(()=>r("lead"))})}releaseBundleReloadLead(){this.releaseReloadLease?.(),this.releaseReloadLease=void 0}announceBundleOutcome(e,t){this.send("bundleReloaded",{version:e,outcome:t})}async close(){if(!this.closed){this.closed=!0;for(let e of this.subscriptions.splice(0))e.unsubscribe();for(let e of[...this.pendingHandoffs])e.abort();for(let e of[...this.pendingReloads.values()])for(let t of[...e])t("timeout");this.endHandoffLease(),this.releaseBundleReloadLead(),await this.options.comms.close()}}endHandoffLease(){let e=this.handoffLease;this.handoffLease=void 0,e&&(e.abort.abort(),e.handler&&(this.handoffHandlerRemoved=e.handler.then(t=>t?.remove())),e.release?.())}answerHandoffs(e){e.handler=this.handoffHandlerRemoved.then(()=>this.handoffLease===e?this.options.comms.createTypedHandler("handoff",()=>this.answerHandoff(e)):void 0).catch(()=>{}),e.handler.then(()=>e.grant())}async send(e,t){if(this.closed)return!1;try{return await this.options.comms.broadcast(e,t),!0}catch{return!1}}async answerHandoff(e){let t;if(this.handoffLease===e)try{t=await this.options.mintHandoff()}catch{t=void 0}if(this.handoffLease!==e||!eYt(t))throw new _g.TypedResponseError("handoff_unavailable");return{resumeToken:t}}receiveLayout(e){if(!JKt(e))return;let t={};typeof e.sidebarWidth=="number"&&Number.isFinite(e.sidebarWidth)&&(t.sidebarWidth=e.sidebarWidth),typeof e.browserSidebarVisible=="boolean"&&(t.browserSidebarVisible=e.browserSidebarVisible),(e.browserPresentation==="default"||e.browserPresentation==="paint"||e.browserPresentation==="video")&&(t.browserPresentation=e.browserPresentation),(e.paintRendering==="gpu"||e.paintRendering==="software")&&(t.paintRendering=e.paintRendering),Object.keys(t).length>0&&this.options.onLayout(t)}awaitBundleOutcome(e,t){return this.closed?Promise.resolve("timeout"):new Promise(s=>{let r=this.pendingReloads.get(e);r||(r=new Set,this.pendingReloads.set(e,r));let a=n(l=>{clearTimeout(o),r.delete(a),r.size===0&&this.pendingReloads.get(e)===r&&this.pendingReloads.delete(e),s(l)},"finish"),o=setTimeout(()=>a("timeout"),t);r.add(a)})}receiveBundleOutcome(e){if(!JKt(e)||!eYt(e.version)||e.outcome!=="current"&&e.outcome!=="stale")return;let t=e.outcome;for(let s of[...this.pendingReloads.get(e.version)??[]])s(t)}};var pvs=n((i,e,t)=>{let{statuses:s,finished:r,errors:a,optimistic:o}=i;if(t.sessionError===!0){s.set(e,"error"),a.add(e),r.delete(e),o.delete(e);return}let l=t.sessionStatus;if(l===void 0)return;let c=s.get(e),d=c==="busy"||c==="retry"||o.has(e);s.set(e,l),l==="busy"||l==="retry"?(a.delete(e),r.delete(e),o.delete(e)):l==="idle"?(o.delete(e),d&&!a.has(e)&&r.add(e)):(a.add(e),r.delete(e),o.delete(e))},"applySessionCardEvent");var dxr=4,tYt="Show the page's video in Paint",fvs=n(async(i,e)=>{e.throwIfAborted();let t;try{return await Promise.race([i(),new Promise((s,r)=>{t=n(()=>r(e.reason),"onAbort"),e.addEventListener("abort",t,{once:!0})})])}finally{t&&e.removeEventListener("abort",t)}},"settleWithin"),uxr=n((i,e,t)=>fvs(()=>i.send(e),t),"sendWithin"),hxr=n(i=>{if(i instanceof Yi.TypedResponseError){let t=i.errorData?.code;if(t==="paint_unavailable"||t==="paint_capture_unavailable")return{kind:"paint-refused",code:t,message:i.errorText}}let e=Mke(i);return e===void 0?void 0:{kind:"viewer-cannot-render",failure:e}},"paintOpenFallback"),Zke=class{constructor(e){this.options=e;this.switcher=new fB({surface:e.surface,capture:n(()=>this.renderer instanceof py?e.canvas:this.renderer?e.video:void 0,"capture"),open:n((t,s)=>t==="paint"?this.openPaint(s):this.openVideo(s),"open"),onError:n(t=>e.onError("Show the browser view",t),"onError")})}options;static{n(this,"ControllerBrowserPresentation")}switcher;renderer;paint;paintOpening=!1;pendingVideoRoutes=[];audio;closed=!1;currentChoice;get mode(){return this.switcher.mode}get choice(){return this.currentChoice}static initialChoice(e,t,s){let r=t==="default"?"controller":"device",a=t==="default"?e:t;return a==="paint"&&s?.paint.state==="unavailable"?{requested:a,reason:{source:r,fallback:{kind:"paint-unavailable",paint:s.paint}}}:{requested:a,reason:{source:r}}}async start(e,t){await this.present(e,t)}async switchTo(e,t){await this.present({requested:e,reason:{source:"view"}},t)}async present(e,t){if(this.closed)return;this.setChoice(e);let s=e.reason.fallback?"video":e.requested;try{await this.switcher.switchTo(s,t)}catch(r){if(this.closed||t?.aborted||s!=="paint")throw r;let a=hxr(r);if(a===void 0)throw r;this.setChoice({requested:e.requested,reason:{...e.reason,fallback:a}}),await this.switcher.switchTo("video",t)}}fallBackToVideo(e){let t=this.currentChoice;this.closed||!t||(this.setChoice({requested:t.requested,reason:{...t.reason,fallback:e}}),this.switcher.switchTo("video").catch(s=>this.options.onError("Show the browser view",s)))}setChoice(e){this.currentChoice=e,this.options.onChoice(e)}async activateSound(){let e=this.renderer;if(!e)throw new Error("The browser view shows nothing yet.");await e.activateAudio()}get soundAvailable(){return this.options.presentation()?.audio.state==="available"}handlePaintTermination(e){let t=this.paint;!t||t.response.paintId!==e.paintId||t.presenter.terminateFromControl(e.source,e.termination)}handleVideoRouteRequest(e){let t=this.paint;if(t&&t.response.paintId===e.paintId){this.openVideoRoute(t,e.routeId).catch(s=>{this.isCurrentPaint(t)&&this.options.onError(tYt,s)});return}this.paintOpening&&this.pendingVideoRoutes.length<dxr&&this.pendingVideoRoutes.push({paintId:e.paintId,routeId:e.routeId})}async close(){if(this.closed)return;this.closed=!0,this.pendingVideoRoutes.length=0;let e=await Promise.allSettled([this.switcher.close()]),t=this.audio;this.audio=void 0;let s=await Promise.allSettled([t?.dispose()]),r=[...e,...s].flatMap(a=>a.status==="rejected"?[a.reason]:[]);if(r.length===1)throw r[0];if(r.length>1)throw new AggregateError(r,"Browser presentation cleanup is incomplete.")}async openVideo(e){let t=await this.audioLifecycle();e.throwIfAborted();let s=new kC({video:this.options.video,client:this.options.client,...t===void 0?{}:{audio:t},focusTarget:this.options.surface,resizeTarget:this.options.surface,onError:n(r=>this.options.onRendererError(r),"onError")});this.setRenderer(s);try{await this.options.startRenderer(s)}catch(r){throw await this.options.stopRenderer(s),this.clearRenderer(s),r}return{firstFrame:s.firstFrame,stop:n(async()=>{try{await this.options.stopRenderer(s)}finally{this.clearRenderer(s)}},"stop")}}async openPaint(e){let t=await this.options.assets(),s=await this.audioLifecycle();e.throwIfAborted();let r=new py({canvas:this.options.canvas,client:this.options.client,...s===void 0?{}:{audio:s},focusTarget:this.options.surface,resizeTarget:this.options.surface,picture:{...R8,...t.paint,...Rds(this.options.paintRendering())},originalVideo:xke,onError:n(o=>{Mke(o.cause)===void 0&&this.options.onRendererError(o)},"onError")});this.setRenderer(r),this.paintOpening=!0;let a;try{await this.options.startRenderer(r);let o=r.pictureRenderer?.videoWorkerIncarnation;if(!o)throw new Error("The Paint renderer has no worker.");a=await this.options.socket.fire("controller.browser.paint.open",{viewId:this.options.viewId,streamGeneration:this.options.streamGeneration,workerIncarnation:o},{maxRetries:0,abortSignal:e});let l=a;await fvs(()=>Promise.all([l.packets.opened,l.control.opened]),e);let c=new AbortController,d=new iB({expectedHello:l.hello,renderer:r,sendPacket:n((h,p)=>uxr(l.control,h,p),"sendPacket"),closeSource:n(()=>this.closePaintSource(l),"closeSource"),onFailure:n(h=>{Mke(h)===void 0&&this.options.onError("Run the browser Paint view",h)},"onFailure"),onTermination:n(h=>this.onPaintTermination(l.paintId,h),"onTermination"),signal:c.signal}),u={response:l,presenter:d,renderer:r,routes:new Set,abortController:c,removeSessionEnd:r.observePaintSessionEnd(h=>{this.closeVideoRoutes(u),this.onPaintSessionEnd(u,h)})};this.paint=u,this.receivePaintPackets(u);for(let h of this.pendingVideoRoutes.splice(0))h.paintId===l.paintId&&this.openVideoRoute(u,h.routeId).catch(p=>{this.isCurrentPaint(u)&&this.options.onError(tYt,p)});return{firstFrame:r.firstFrame,stop:n(()=>this.stopPaint(u),"stop")}}catch(o){throw a&&await this.closePaintSource(a).catch(()=>{}),await r.stop().catch(()=>{}),this.clearRenderer(r),o}finally{this.paintOpening=!1,this.pendingVideoRoutes.length=0}}async receivePaintPackets(e){try{for(;!e.abortController.signal.aborted;){let t=await e.response.packets.receive();if(t===void 0){await e.response.packets.accept();return}e.presenter.receivePacket(t)}}catch(t){if(this.paint!==e||e.abortController.signal.aborted)return;this.options.onError("Run the browser Paint view",t),await this.stopPaint(e).catch(()=>{})}}onPaintTermination(e,t){this.paint?.response.paintId!==e||this.closed||(t.kind==="unsupported"?this.fallBackToVideo({kind:"page-unsupported",reasonCode:t.reasonCode}):t.kind==="failure"&&this.options.onError("Run the browser Paint view",new Error(t.message)))}onPaintSessionEnd(e,t){if(this.paint!==e||this.closed||t===void 0)return;let s=Mke(t);s!==void 0&&this.fallBackToVideo({kind:"viewer-cannot-render",failure:s})}isCurrentPaint(e){return this.paint===e&&!this.closed}async stopPaint(e){this.paint===e&&(this.paint=void 0),e.abortController.abort(new Error("The Paint stream closed.")),e.removeSessionEnd(),this.closeVideoRoutes(e);try{await e.presenter.close()}finally{this.clearRenderer(e.renderer)}}async closePaintSource(e){let t=new Error("The Paint stream closed.");await Promise.allSettled([e.packets.abort(t),e.control.abort(t)]),this.options.socket.isConnected&&await this.options.socket.fire("controller.browser.paint.close",{viewId:this.options.viewId,paintId:e.paintId,streamGeneration:this.options.streamGeneration},{maxRetries:0})}async openVideoRoute(e,t){let s=e.renderer.pictureRenderer;if(!s)throw new Error("The Paint renderer has no worker.");let r=await this.options.socket.fire("controller.browser.paint.video.openRoute",{viewId:this.options.viewId,streamGeneration:this.options.streamGeneration,paintId:e.response.paintId,routeId:t},{maxRetries:0,abortSignal:e.abortController.signal}),a=new pB({..._ke,routeId:r.routeId,packets:r.packets,receipts:r.receipts,renderer:s,signal:e.abortController.signal,onEnded:n(()=>{e.routes.delete(a)},"onEnded"),onFailure:n(o=>{e.routes.delete(a),this.isCurrentPaint(e)&&this.options.onError(tYt,o)},"onFailure")});e.routes.add(a);try{await a.start()}catch(o){throw e.routes.delete(a),o}}closeVideoRoutes(e){for(let t of e.routes)t.close().catch(s=>this.options.onError("Close the browser view's video",s));e.routes.clear()}async audioLifecycle(){if(this.options.presentation()?.audio.state!=="available")return;if(this.audio)return this.audio;let e=await this.options.assets();if(this.audio)return this.audio;let t={openAudioRelay:n(s=>this.openAudioRelay(s),"openAudioRelay")};return this.audio=new oB({viewerId:this.options.viewId,client:new lB(t),assets:e.audio,sampleCreditBytes:e.audioSampleCredit.bytes,sampleCreditEvents:e.audioSampleCredit.events,clockPolicy:gke,onError:n(s=>this.options.onError("Play the browser sound",s),"onError")}),this.audio}async openAudioRelay(e){let t=await this.options.socket.fire("controller.browser.audio.open",{viewId:this.options.viewId,streamGeneration:this.options.streamGeneration},{maxRetries:0,abortSignal:e.signal}),r=await new dB({events:t.events,operations:t.operations,sampleCreditBytes:t.sampleCredit.bytes,sampleCreditEvents:t.sampleCredit.events,signal:e.signal}).openAudioRelay(e);return{sendCommand:n(a=>r.sendCommand(a),"sendCommand"),close:n(async()=>{try{await r.close()}finally{this.options.socket.isConnected&&await this.options.socket.fire("controller.browser.audio.close",{viewId:this.options.viewId,audioId:t.audioId,streamGeneration:this.options.streamGeneration},{maxRetries:0}).catch(()=>{})}},"close")}}setRenderer(e){this.renderer=e,this.options.surface.dataset.presentation=e instanceof py?"paint":"video",this.options.onRenderer(e)}clearRenderer(e){this.renderer===e&&(this.renderer=void 0,this.options.onRenderer(void 0))}};var iYt=n((i,e,t)=>`${i}:${e}\0${t}`,"projectMutationScope"),mvs=n((i,e)=>iYt("draft",i,`${e}`),"draftScopeOf"),gvs=n((i,e)=>iYt("conversation",i,e),"conversationScopeOf"),e8e=class{constructor(e){this.onChange=e}onChange;static{n(this,"ControllerMutationLocks")}held=new Map;startedCount=0;get started(){return this.startedCount}get anyHeld(){return this.held.size>0}isHeld(e){return this.held.has(e)}isProjectHeld(e){let t=["draft","conversation"].map(s=>iYt(s,e,""));return[...this.held.keys()].some(s=>t.some(r=>s.startsWith(r)))}holds(e){return[...this.held.values()].includes(e)}acquire(e){if(this.held.has(e))return;let t=Symbol(e);return this.held.set(e,t),this.startedCount+=1,this.onChange(),t}release(e){for(let[t,s]of this.held)if(s===e)return this.held.delete(t),this.onChange(),!0;return!1}releaseAll(){this.held.size!==0&&(this.held.clear(),this.onChange())}};var ONc=50,vvs=n((i,e)=>[...i,e].slice(-50),"appendErrorJournalEntry"),sYt=n(i=>Number.isFinite(i)?new Date(i).toISOString():"unknown","formatTimestamp"),pxr=n((i,e)=>{let t=[`[${e}] ${sYt(i.at)} - ${i.operation}`,`message: ${i.message}`];i.reference!==void 0&&t.push(`reference: ${i.reference}`);let s=i.detail;return s!==void 0?(t.push(`controller operation: ${s.operation}`,`controller time: ${sYt(s.at)}`,`controller cause: ${s.name}: ${s.message}`),s.stack&&t.push("controller stack:",s.stack)):i.reference!==void 0&&t.push("controller cause: unavailable"),t.join(`
49573
49573
  `)},"formatEntry"),bvs=n(i=>{let e=["AGL error report",`agl version: ${i.version||"unknown"}`,`generated: ${sYt(i.generatedAt)}`,`entries: ${i.entries.length}`].join(`
49574
49574
  `);if(i.entries.length===0)return`${e}
49575
49575
  `;let t=i.entries.map((s,r)=>pxr(s,r+1)).join(`
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist_serve/bundle.js.map
3
3
  size: 34810131 bytes
4
- sha256: e90a3a790fd059292783c1a2c5760d09d82dcc055bcbfe607cde1e83b1d34eb4
4
+ sha256: 898e58a3673ecc7ddf9b851242f0b4311ff9ade9ddbccff02225529b85caa03c
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '43.3.1',
6
+ version: '43.3.2',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxLQUFLO0lBQ1gsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLG1FQUFtRTtDQUNqRixDQUFBIn0=
@@ -1023,6 +1023,11 @@ export declare class OpenCodeController {
1023
1023
  private requireFlexRuntimeExitAuthority;
1024
1024
  private assertOpenCodeSessionIdentityGenerationCurrent;
1025
1025
  private assertFlexSessionIdentityGenerationCurrent;
1026
+ /**
1027
+ * A project's Flex session identities, in one answer the child reads from the project's metadata:
1028
+ * the snapshot is atomic and never waits for a load of the sessions' histories (AGL-1713). The
1029
+ * supervisor has proven the answer: bounded, strictly ordered and generation-bearing.
1030
+ */
1026
1031
  private readFlexSessionIdentitySnapshot;
1027
1032
  private captureFlexCleanupCohort;
1028
1033
  private reconcileOpenCodeSessionIdentities;
@@ -2122,10 +2127,12 @@ export declare class OpenCodeController {
2122
2127
  /**
2123
2128
  * The reversion requests that settle what a Flex session already recorded: a capture's inspection
2124
2129
  * and finalization, a pending undo or redo, a release. A project reconciling its session authority
2125
- * admits them. Its reconciliation loads the project's sessions in the child (`project.register`,
2126
- * `session.list`), and that load settles each session's pending capture and apply before it
2127
- * answers; a refused settlement fails the load and with it the reconciliation, which then never
2128
- * succeeds. The ending turn of a run closes its capture with the same requests. A new capture
2130
+ * admits them. The first full load of the project's sessions in the child (the child's recovery
2131
+ * load once it is ready, a held prompt's settlement or a managed creation's recovery during the
2132
+ * reconciliation, any session read; never `session.identities`) settles each session's pending
2133
+ * capture and apply before it answers; a refused settlement fails that load, and with it a
2134
+ * reconciliation waiting for it, which then never succeeds. The ending turn of a run closes its
2135
+ * capture with the same requests. A new capture
2129
2136
  * (`reversion.prepare`) is new work and stays refused while authority is uncertain.
2130
2137
  */
2131
2138
  private flexHostMethodSettlesRecordedReversion;