agl 43.3.0 → 43.3.1

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.
Files changed (71) hide show
  1. package/changelog.md +9 -0
  2. package/dist_serve/bundle.js +2 -2
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_ts/00_commitinfo_data.js +1 -1
  5. package/dist_ts/classes.authstore.d.ts +7 -0
  6. package/dist_ts/classes.authstore.js +9 -1
  7. package/dist_ts/classes.claudeharness.d.ts +13 -2
  8. package/dist_ts/classes.claudeharness.js +12 -5
  9. package/dist_ts/classes.controller.d.ts +27 -6
  10. package/dist_ts/classes.controller.js +136 -39
  11. package/dist_ts/classes.mcpcontrollerhost.js +4 -1
  12. package/dist_ts/classes.mcptools.js +6 -1
  13. package/dist_ts/classes.nativesessions.d.ts +12 -0
  14. package/dist_ts/classes.nativesessions.js +1 -1
  15. package/dist_ts/classes.workercallers.js +4 -2
  16. package/dist_ts/driver/classes.directreports.js +19 -19
  17. package/dist_ts/driver/classes.directreportstore.d.ts +8 -1
  18. package/dist_ts/driver/classes.directreportstore.js +20 -10
  19. package/dist_ts/fleet/classes.workers.d.ts +16 -0
  20. package/dist_ts/fleet/classes.workers.js +73 -39
  21. package/dist_ts/fleet/classes.workerstore.js +14 -8
  22. package/dist_ts/fleet/functions.workervalidation.js +10 -3
  23. package/dist_ts/fleet/interfaces.workers.d.ts +6 -2
  24. package/dist_ts/fleet/interfaces.workers.js +8 -4
  25. package/dist_ts/functions.deviceapi.d.ts +50 -3
  26. package/dist_ts/functions.deviceapi.js +174 -7
  27. package/dist_ts/functions.exactpersistence.d.ts +3 -0
  28. package/dist_ts/functions.exactpersistence.js +4 -0
  29. package/dist_ts/functions.mcpfleetworkertools.js +2 -2
  30. package/dist_ts/functions.ticketactor.d.ts +17 -1
  31. package/dist_ts/functions.ticketactor.js +55 -15
  32. package/dist_ts_interfaces/devices.d.ts +17 -4
  33. package/dist_ts_interfaces/devices.js +1 -1
  34. package/dist_ts_interfaces/fleetworkers.d.ts +32 -7
  35. package/dist_ts_interfaces/fleetworkers.js +19 -8
  36. package/dist_ts_interfaces/workercallers.d.ts +2 -0
  37. package/dist_ts_migration/classes.documentmigrationrunner.d.ts +14 -0
  38. package/dist_ts_migration/classes.documentmigrationrunner.js +20 -1
  39. package/dist_ts_migration/index.d.ts +1 -0
  40. package/dist_ts_migration/index.js +2 -1
  41. package/dist_ts_migration/v43_ticketactornames.d.ts +32 -0
  42. package/dist_ts_migration/v43_ticketactornames.js +236 -0
  43. package/package.json +1 -1
  44. package/readme.md +34 -3
  45. package/ts/00_commitinfo_data.ts +1 -1
  46. package/ts/classes.authstore.ts +10 -0
  47. package/ts/classes.claudeharness.ts +18 -4
  48. package/ts/classes.controller.ts +142 -40
  49. package/ts/classes.mcpcontrollerhost.ts +3 -0
  50. package/ts/classes.mcptools.ts +5 -0
  51. package/ts/classes.nativesessions.ts +13 -0
  52. package/ts/classes.workercallers.ts +3 -1
  53. package/ts/driver/classes.directreports.ts +18 -18
  54. package/ts/driver/classes.directreportstore.ts +20 -9
  55. package/ts/fleet/classes.workers.ts +66 -39
  56. package/ts/fleet/classes.workerstore.ts +11 -7
  57. package/ts/fleet/functions.workervalidation.ts +7 -2
  58. package/ts/fleet/interfaces.workers.ts +6 -2
  59. package/ts/functions.deviceapi.ts +227 -6
  60. package/ts/functions.exactpersistence.ts +5 -0
  61. package/ts/functions.mcpfleetworkertools.ts +1 -1
  62. package/ts/functions.ticketactor.ts +58 -14
  63. package/ts_interfaces/devices.schema.json +5 -2
  64. package/ts_interfaces/devices.ts +20 -4
  65. package/ts_interfaces/fleetworkers.ts +33 -7
  66. package/ts_interfaces/workercallers.ts +2 -0
  67. package/ts_migration/classes.documentmigrationrunner.ts +21 -0
  68. package/ts_migration/index.ts +1 -0
  69. package/ts_migration/v43_ticketactornames.ts +225 -0
  70. package/ts_web/00_commitinfo_data.ts +1 -1
  71. package/ts_web/elements.fleetworker.ts +4 -2
package/changelog.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 2026-11-12 - 43.3.1
4
+
5
+ ### Fixes
6
+
7
+ - Refuse every device request with a code of the device contract (AGL-1670): `TDeviceRefusalCode` promised a closed set, but `device.session.read`/`.send`, `device.driver.read`/`.send` and the other device methods passed on the browser's codes from the shared functions and the controller's error translation (`flex_not_ready`, `flex_operation_failed`, `flex_projection_*`, `harness_unavailable`, `native_session_failed`, `concurrent_change`, `outcome_unknown`, `controller_operation_failed` and more). The device scopes of `createRouter` now translate every failure in one place (`asDeviceResponseError`, through `deviceContractError`), mapping each controller code through one compiler-checked table (`deviceControllerRefusals`) and answering any code it does not know as a fault. Device protocol 1.3 adds three codes: `outcome_unknown` (the request may have happened; a client never resends it on its own and reads again to learn the outcome), `concurrent_change` (another change to the same session or record won; nothing was done; read again, then decide) and `controller_failed` (a fault, with the failure journal's `reference` in `error.data`, instead of the browser's `controller_operation_failed`). A ticket change or answer whose commit outcome is unknown is `outcome_unknown`, and so is a native send or answer, or a direct report message, that may have reached the session, instead of `native_session_failed` or `direct_report_failed`: every native session failure now says whether anything went out (`outcome: 'refused'` or `'unknown'`), a failure that does not is taken as unknown, and Claude Code's refusal of a native send while the conversation still works (`refusal: 'busy'`) is `concurrent_change`, while too many conversations work (`'capacity'`) `operation_limit`. A state of the controller (Flex starting, a harness not running) is `controller_unavailable`, and a model or stopped message the owner must resolve in the browser `session_read_only`. `controller_failed` always reads "The controller operation failed.", and a refusal whose controller message may carry a raw cause (a native session failure, a harness diagnostic, a configuration refusal) reaches a device with its device code's own sentence; the cause stays in the controller log and the failure journal.
8
+ - A direct report's failure no longer shows a dependency's own text (AGL-1670 follow-up), in the browser's Driver view as on a device: `direct_report_failed` keeps the message only of a refusal whose class AGL writes the text of (`DirectReportError`, the direct reports' and their store's own refusals, now typed, `FleetWorkerError` and `FleetNativeTurnError`), and every other error, such as a spawn error, a socket path or a failed relaunch's harness error, is the controller's one generic failure, `controller_operation_failed` "The controller operation failed." with the failure journal's `reference` (before: `direct_report_failed` with the raw text), under which the journal keeps the cause; a device receives it as `direct_report_failed` "The controller operation failed. (ref …)" for a message and as `controller_failed` for the list. The fleet's own refusals are typed at their source, so the Driver view keeps their text: admission ("The fleet is closing…", job capacity), the dispatch fences ("Worker is archived.", an unresolved dispatch, another ticket), the relaunch and adopt preconditions and the worker registry's own refusals (an unknown worker `worker_not_found`, a concurrent change, a taken name) are `FleetWorkerError`s with five new codes in `fleetWorkerErrorCodes` (`fleet_unavailable`, `worker_fenced`, `worker_archived`, `ticket_mismatch`, `worker_conflict`; MCP `FLEET_UNAVAILABLE` and the others), and a failed fleet job records the code beside its `error` as `errorCode` exactly when the fleet refused it itself. A message to a fleet worker report whose steer job failed shows the job's error only with `errorCode`; any other job error, a harness's own text that may have come after the message went out, reads "The controller operation failed. (ref …)" in the Driver view and on a device alike, and a relaunch whose job failed so is the generic failure above; `job.error` stays as it was for MCP, the driver tools and the CLI. A report not recorded after its relaunch names the worker to appoint without the store's error, which the journal keeps. A device's report message refused with a code whose message may carry a raw cause (a harness diagnostic, a native session failure) reads "The direct report did not take the message." with the reference. `expectedTurnId` on a message to a fleet worker report is now refused as `invalid_request`.
9
+ - A direct report's steer that failed after its dispatch is of unknown outcome, never a message the report did not take (AGL-1691): a device read `direct_report_failed` for every failed fleet steer job, so a 1.3 client could send again a message that may have been delivered. A failed fleet worker job now carries `errorOutcome`, `refused` only where nothing can have reached a native session (a refusal before the job's first dispatch, or a dispatch that proved it sent nothing) and `unknown` for every other failure; `device.directreport.message` answers `outcome_unknown` for it, which a client never resends on its own, and the Driver view shows the steer's outcome as unknown and keeps the draft. MCP `fleet_worker_job_wait` and the driver tools return the job with the field.
10
+ - Tickets name the sessions acting on them by their role instead of a raw session id (AGL-1686): an MCP caller's ticket writes name the owner's active direct report its session is, else its fleet worker's name, else its harness's label (`Claude Code session`, `Codex session`, `OpenCode session`, `Flex session`), and the shared OpenCode runtime `OpenCode` instead of `runtime`; ids and session ids stay as they were, so assignment, Mine and every match are unchanged. Migration `v43_ticketactornames` renames the old records once, at the first start: every person and actor a ticket, its comments, its questions and its activity hold (the snapshots in its history and each comment's copy included) whose name is its session id takes its harness's label, and a `runtime` worker actor without a session becomes `OpenCode`. Only those names change, so 41.1.0 still reads the store; a renamed ticket's revision moves, with no history entry, notice or board pump action.
11
+
3
12
  ## 2026-11-11 - 43.3.0
4
13
 
5
14
  ### Features
@@ -49277,7 +49277,7 @@ description:
49277
49277
  @harness-menu-action=${e.menuAction}
49278
49278
  @harness-worker-open=${e.workerOpen}
49279
49279
  >${i.strips??""}</dees-harness-chat>
49280
- `},"renderSessionChat"),rKt=n(i=>typeof i=="string"&&i.trim().length>0,"isNonEmptyString"),W2=n(i=>{if(!Array.isArray(i))return;let e=[];for(let t of i){if(!t||typeof t!="object"||Array.isArray(t))return;let s=t;if(!rKt(s.id)||!rKt(s.name)||!rKt(s.mediaType)||!Number.isSafeInteger(s.size)||(s.size??-1)<0||!["image","text","binary"].includes(s.kind??"")||typeof s.dataBase64!="string")return;e.push({id:s.id,name:s.name,mediaType:s.mediaType,size:s.size,kind:s.kind,dataBase64:s.dataBase64})}return e},"toControllerDraftAttachments"),VUe=n(i=>{if(i!==void 0)return{label:i==="accountSettings"?"Open Accounts":"Open Session Intelligence settings"}},"sessionIntelligenceAvailabilityAction");var F0r=3e3,nKt=50,tgs=200,igs=n(i=>JSON.stringify([i.harness,i.nativeId,i.profileId??null]),"refKey"),B0r=n((i,e)=>Gke(i.id.nativeId,i.questions.length,e),"questionCardIdOf"),H8=class{constructor(e,t){this.host=e;this.options=t;this.limit=t.initialLimit}host;options;static{n(this,"NativeSessionState")}response;readError="";auxiliary;limit;loadingEarlier=!1;sender;ref;scratchpadSaving=!1;scratchpadError="";asking=!1;intelligenceError="";intelligenceAction;permissionCards=[];questionCards=[];elicitations=new V2(e=>e.nativeId);elicitationCards=[];answeredPermissions=new Map;answeredQuestions=new Map;questionBatches=new Map;generation=0;reading;rereadRequested=!1;readAbort;pollTimer;get session(){return this.response?.session}show(e,t){let s=this.ref!==void 0&&t!==void 0&&igs(this.ref)===igs(t);this.sender=e,!(s&&this.response)&&(s||this.leave(),this.ref=t,t&&e&&(this.refresh(),this.loadAuxiliary()))}leave(){this.generation+=1,this.readAbort?.abort(),this.readAbort=void 0,this.reading=void 0,this.rereadRequested=!1,this.clearPoll(),this.ref=void 0,this.response=void 0,this.readError="",this.auxiliary=void 0,this.limit=this.options.initialLimit,this.loadingEarlier=!1,this.scratchpadSaving=!1,this.scratchpadError="",this.asking=!1,this.intelligenceError="",this.intelligenceAction=void 0,this.answeredPermissions.clear(),this.answeredQuestions.clear(),this.questionBatches.clear(),this.permissionCards=[],this.questionCards=[],this.elicitations.clear(),this.elicitationCards=[]}refresh(){let e=this.generation;if(this.reading?.generation===e)return this.rereadRequested=!0,this.reading.promise;let t=this.read(e).finally(()=>{if(this.reading?.promise===t){if(this.reading=void 0,!this.rereadRequested)return this.schedulePoll();this.rereadRequested=!1,this.refresh()}});return this.reading={generation:e,promise:t},t}async loadAuxiliary(){let{ref:e,sender:t,generation:s}=this;if(!(!e||!t))try{let r=await t.fire("controller.nativesession.auxiliary.get",{session:e});if(s!==this.generation)return;this.auxiliary=r,this.intelligenceAction=VUe(r.sessionIntelligenceAvailabilityStatus==="unavailable"?r.sessionIntelligenceRemedy:void 0),this.host.requestUpdate()}catch(r){if(s!==this.generation)return;this.intelligenceError=vd(r),this.host.requestUpdate()}}async loadEarlier(){if(this.loadingEarlier||!this.hasEarlier())return;let e=this.generation;this.loadingEarlier=!0,this.limit=Math.min(tgs,this.limit+nKt),this.host.requestUpdate();try{await this.refresh()}finally{e===this.generation&&(this.loadingEarlier=!1,this.host.requestUpdate())}}hasEarlier(){return this.response?.messagePage.nextCursor!==void 0&&this.limit<tgs}chatView(){let e=this.response,t=this.auxiliary,s=e?.intelligenceExchanges??[],r=[...s].reverse().find(a=>a.scratchpadConflict===!0);return{scratchpad:e?.scratchpad,scratchpadBusy:this.scratchpadSaving,scratchpadError:this.scratchpadError,...t?{sessionMetrics:t.sessionMetrics}:{},sessionIntelligenceEnabled:t?.sessionIntelligenceEnabled??!1,intelligenceAvailabilityStatus:t?.sessionIntelligenceAvailabilityStatus??"unavailable",intelligenceUnavailableReason:t?.sessionIntelligenceUnavailableReason??"Session Intelligence is still loading.",intelligenceAvailabilityAction:this.intelligenceAction,intelligenceExchanges:s,intelligenceBusy:this.asking||s.some(a=>a.status==="running"),intelligenceError:this.intelligenceError||(r?"The answer completed, but its scratchpad update was not applied because a newer revision exists.":""),permissions:this.permissionCards,questions:this.questionCards,elicitations:this.elicitationCards}}handlers={scratchpadSave:n(e=>{let t=e.detail;typeof t?.text!="string"||!Number.isSafeInteger(t.expectedRevision)||t.expectedRevision<0||this.saveScratchpad(t.text,t.expectedRevision)},"scratchpadSave"),intelligenceAsk:n(e=>{let t=e.detail?.question?.trim();t&&this.ask(t)},"intelligenceAsk"),intelligenceAvailabilityAction:n(()=>{let e=this.auxiliary?.sessionIntelligenceAvailabilityStatus==="unavailable"?this.auxiliary.sessionIntelligenceRemedy:void 0;e!==void 0&&this.host.dispatchEvent(new CustomEvent("agl-session-intelligence-remedy",{detail:{remedy:e},bubbles:!0,composed:!0}))},"intelligenceAvailabilityAction"),permissionResponse:n(e=>{let t=e.detail,s=this.response?.permissions.find(r=>r.id.nativeId===t?.requestId);s&&(this.answeredPermissions.set(t.requestId,{...t.request,response:t.response,respondedAt:Date.now()}),this.rebuildCards(),this.reply(()=>this.sender.fire("controller.nativesession.permission.reply",{session:this.ref,requestId:s.id,reply:t.response==="reject"?"reject":"once"})))},"permissionResponse"),questionResponse:n(e=>{let t=e.detail,s=Array.isArray(t?.answers)?t.answers.filter(r=>typeof r=="string"&&r.trim().length>0):[];if(s.length!==0)for(let r of this.response?.questions??[]){let a=r.questions.findIndex((c,d)=>B0r(r,d)===t.requestId);if(a<0)continue;this.answeredQuestions.set(t.requestId,{...t.request,response:s,respondedAt:Date.now()}),this.rebuildCards();let o=this.questionBatches.get(r.id.nativeId)??new Map;if(o.set(a,s),this.questionBatches.set(r.id.nativeId,o),o.size<r.questions.length)return;this.questionBatches.delete(r.id.nativeId);let l=r.questions.map((c,d)=>o.get(d)??[]);this.reply(()=>this.sender.fire("controller.nativesession.question.reply",{session:this.ref,requestId:r.id,answers:l}));return}},"questionResponse"),elicitationResponse:n(e=>{let t=e.detail?.requestId;if(typeof t!="string")return;let s=this.elicitations.request(t),r=z8(e.detail);s&&r&&this.answerElicitation(t,s.id,r)},"elicitationResponse")};async read(e){let{ref:t,sender:s}=this;if(!t||!s||!this.host.isConnected)return;this.clearPoll();let r=new AbortController;this.readAbort=r;try{let a=await s.fire("controller.nativesession.read",{session:t,limit:this.limit},{abortSignal:r.signal});if(e!==this.generation)return;this.response=a,this.readError="",this.rebuildCards()}catch(a){if(e!==this.generation)return;this.readError=vd(a),this.host.requestUpdate()}finally{this.readAbort===r&&(this.readAbort=void 0)}}async saveScratchpad(e,t){let{ref:s,sender:r,generation:a}=this;if(!(!s||!r||this.scratchpadSaving)){this.scratchpadSaving=!0,this.scratchpadError="",this.host.requestUpdate();try{let{scratchpad:o}=await r.fire("controller.nativesession.scratchpad.save",{session:s,text:e,expectedRevision:t});if(a!==this.generation||!this.response)return;this.response={...this.response,scratchpad:o}}catch(o){if(a!==this.generation)return;this.scratchpadError=vd(o),this.refresh()}finally{a===this.generation&&(this.scratchpadSaving=!1,this.host.requestUpdate())}}}async ask(e){let{ref:t,sender:s,generation:r,auxiliary:a,response:o}=this;if(!(!t||!s||!o||this.asking||a?.sessionIntelligenceEnabled!==!0||a.sessionIntelligenceAvailabilityStatus!=="available"||o.intelligenceExchanges.some(l=>l.status==="running"))){this.asking=!0,this.intelligenceError="",this.host.requestUpdate();try{let{exchange:l}=await s.fire("controller.nativesession.intelligence.ask",{session:t,question:e});if(r!==this.generation||!this.response)return;let c=this.response.intelligenceExchanges;this.response={...this.response,intelligenceExchanges:c.some(d=>d.id===l.id)?c.map(d=>d.id===l.id&&d.status==="running"?l:d):[...c,l]}}catch(l){if(r!==this.generation)return;this.intelligenceError=vd(l)}finally{r===this.generation&&(this.asking=!1,this.host.requestUpdate(),this.refresh())}}}async reply(e){let t=this.generation;try{await e()}catch(s){if(t!==this.generation)return;this.readError=vd(s)}t===this.generation&&this.refresh()}async answerElicitation(e,t,s){let{ref:r,sender:a,generation:o}=this;if(!(!r||!a)){try{await a.fire("controller.nativesession.elicitation.reply",{session:r,requestId:t,reply:s})}catch(l){if(o!==this.generation)return;this.elicitations.refuse(e,vd(l)),this.rebuildCards()}o===this.generation&&this.refresh()}}rebuildCards(){let e=this.response,t=new Set(e?.permissions.map(a=>a.id.nativeId));for(let a of this.answeredPermissions.keys())t.has(a)||this.answeredPermissions.delete(a);this.permissionCards=(e?.permissions??[]).map(a=>this.answeredPermissions.get(a.id.nativeId)??q8(a,a.id.nativeId));let s=[],r=new Set;for(let a of e?.questions??[])for(let o of xB(a,a.id.nativeId))r.add(o.id),s.push(this.answeredQuestions.get(o.id)??o);for(let a of this.answeredQuestions.keys())r.has(a)||this.answeredQuestions.delete(a);this.questionCards=s,this.elicitationCards=this.elicitations.cards(e?.elicitations??[]),this.host.requestUpdate()}schedulePoll(){this.clearPoll();let e=this.response;!(e!==void 0&&(e.intelligenceExchanges.some(s=>s.status==="running")||this.options.pollWhileBusy&&e.session.status==="busy"))||!this.host.isConnected||document.visibilityState!=="visible"||(this.pollTimer=setTimeout(()=>{this.pollTimer=void 0,this.refresh()},F0r))}clearPoll(){this.pollTimer&&clearTimeout(this.pollTimer),this.pollTimer=void 0}};var sgs,rgs,ngs,ags,ogs,lgs,cgs,dgs,ugs,hgs,pgs,Ea,aKt,oKt,lKt,cKt,dKt,uKt,hKt,pKt,fKt,{html:kB,css:z0r}=le,mKt=3e3,V8=12e4,rS={claude:"Claude Code",codex:"Codex"},GUe=n(i=>JSON.stringify([i.harnessId,i.nativeId]),"uiKey"),q0r=n(i=>{let{id:e,reasoning:t,toolCall:s,...r}=i,a=s?(({id:o,childSessionId:l,...c})=>({...c,id:GUe(o)}))(s):void 0;return{...r,id:GUe(e),markdown:i.role==="assistant",...t?{reasoning:t.map(o=>({...o,id:GUe(o.id)}))}:{},...a?{toolCall:a}:{}}},"harnessMessage"),jke=n((i,e)=>{let t=new Map(e?.bundles.map(a=>[a.key,a])),s=i.map(a=>{let o=`${GUe(a.sourceMessageId)}\0${a.structuralDigest}`;return t.get(o)??{key:o,messages:a.messages.map(q0r)}}),r=e!==void 0&&s.length===e.bundles.length&&s.every((a,o)=>a===e.bundles[o]);return{bundles:s,messages:r?e.messages:s.flatMap(a=>a.messages)}},"transcript"),U0r=n((i,e)=>({view:{worker:i.worker,...i.status?{status:i.status}:{},...i.outcome?{outcome:i.outcome}:{},...i.nativeWait?{nativeWait:i.nativeWait}:{}},earlier:i.earlier,...jke(i.bundles,e)}),"workerPage"),vd=n(i=>i instanceof Error&&i.message?i.message:"The request failed.","errorText"),H0r={approval:"Approve in",user_input:"Reply in",native_prompt:"Answer in",unrecognized:"Waiting in"},V0r={usage_limit:"usage limit reached",usage_reserve:"usage reserve reached",rate_limit:"rate limit reached"},G0r=n(i=>i?.state==="failed"?{type:"error",message:`The last turn failed${i.limit?`: ${V0r[i.limit]}`:""}.`}:void 0,"fleetWorkerOutcomeStatus"),CB=[],Kke=["steer"];pgs=[le.customElement("agl-fleet-worker")];var jp=class jp extends(hgs=le.DeesElement,ugs=[le.property({attribute:!1})],dgs=[le.property()],cgs=[le.property()],lgs=[le.state()],ogs=[le.state()],ags=[le.state()],ngs=[le.state()],rgs=[le.state()],sgs=[le.state()],hgs){constructor(){super(...arguments);it(this,aKt,ge(Ea,8,this)),ge(Ea,11,this);it(this,oKt,ge(Ea,12,this,"")),ge(Ea,15,this);it(this,lKt,ge(Ea,16,this,"")),ge(Ea,19,this);it(this,cKt,ge(Ea,20,this)),ge(Ea,23,this);it(this,dKt,ge(Ea,24,this,"")),ge(Ea,27,this);it(this,uKt,ge(Ea,28,this,!1)),ge(Ea,31,this);it(this,hKt,ge(Ea,32,this,"")),ge(Ea,35,this);it(this,pKt,ge(Ea,36,this,"")),ge(Ea,39,this);it(this,fKt,ge(Ea,40,this,CB)),ge(Ea,43,this);Ae(this,"session",new H8(this,{initialLimit:1,pollWhileBusy:!1}));Ae(this,"generation",0);Ae(this,"reading");Ae(this,"rereadRequested",!1);Ae(this,"readAbort");Ae(this,"readTimer");Ae(this,"handleVisibilityChange",n(()=>{document.visibilityState==="visible"?this.refresh():this.clearReadTimer()},"handleVisibilityChange"));Ae(this,"handleInput",n(t=>{typeof t.detail?.value=="string"&&(this.draft=t.detail.value)},"handleInput"));Ae(this,"handleAttachmentsChange",n(t=>{Array.isArray(t.detail?.attachments)&&(this.attachments=t.detail.attachments)},"handleAttachmentsChange"));Ae(this,"handleSend",n(async t=>{let{name:s,report:r,sender:a}=this,o=t.detail?.text??"";if(!s||!a||this.steering||!o.trim())return;let l=W2(t.detail.attachments??[]);if(!l){this.steerError="An attachment could not be read; remove it and attach it again.";return}let c=this.generation;this.steering=!0,this.steerError="";try{let d=l.length>0?{attachments:l}:{},u=r?await a.fire("controller.directreport.message",{name:r,text:o,...d},{timeoutMs:V8}):await a.fire("controller.fleet.worker.steer",{name:s,text:o,...d},{timeoutMs:V8});if(c!==this.generation)return;let h="job"in u?u.job:void 0;!h||h.state==="succeeded"?(this.draft="",this.attachments=CB):this.steerError=h.error??"The fleet did not deliver the message."}catch(d){if(c!==this.generation)return;this.steerError=d instanceof Yi.TypedResponseError?vd(d):`The steer's outcome is unknown (${vd(d)}). Check the transcript before sending it again.`}finally{c===this.generation&&(this.steering=!1,this.refresh())}},"handleSend"))}refresh(){let t=this.generation;if(this.reading?.generation===t)return this.rereadRequested=!0,this.reading.promise;let s=this.read(t).finally(()=>{if(this.reading?.promise===s){if(this.reading=void 0,!this.rereadRequested)return this.scheduleRead();this.rereadRequested=!1,this.refresh()}});return this.reading={generation:t,promise:s},s}async connectedCallback(){let t=this.hasUpdated;await super.connectedCallback(),document.addEventListener("visibilitychange",this.handleVisibilityChange),t&&this.refresh()}async disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.leaveWorker(),await super.disconnectedCallback()}willUpdate(t){t.has("name")&&(this.leaveWorker(),this.page=void 0,this.readError="",this.steering=!1,this.steerError="",this.draft="",this.attachments=CB)}updated(t){(t.has("name")||t.has("sender")&&!this.page)&&this.refresh()}render(){let t=this.page?.view,s=t?.worker,r=t?.status==="busy",a=!this.report&&s!==void 0&&s.ticketKey===void 0,o=this.readError?{type:"error",message:this.readError}:this.steering?{type:"busy",message:"Steering the worker\u2026"}:r?{type:"busy",message:"Working"}:G0r(t?.outcome)??{type:"idle"};return kB`
49280
+ `},"renderSessionChat"),rKt=n(i=>typeof i=="string"&&i.trim().length>0,"isNonEmptyString"),W2=n(i=>{if(!Array.isArray(i))return;let e=[];for(let t of i){if(!t||typeof t!="object"||Array.isArray(t))return;let s=t;if(!rKt(s.id)||!rKt(s.name)||!rKt(s.mediaType)||!Number.isSafeInteger(s.size)||(s.size??-1)<0||!["image","text","binary"].includes(s.kind??"")||typeof s.dataBase64!="string")return;e.push({id:s.id,name:s.name,mediaType:s.mediaType,size:s.size,kind:s.kind,dataBase64:s.dataBase64})}return e},"toControllerDraftAttachments"),VUe=n(i=>{if(i!==void 0)return{label:i==="accountSettings"?"Open Accounts":"Open Session Intelligence settings"}},"sessionIntelligenceAvailabilityAction");var F0r=3e3,nKt=50,tgs=200,igs=n(i=>JSON.stringify([i.harness,i.nativeId,i.profileId??null]),"refKey"),B0r=n((i,e)=>Gke(i.id.nativeId,i.questions.length,e),"questionCardIdOf"),H8=class{constructor(e,t){this.host=e;this.options=t;this.limit=t.initialLimit}host;options;static{n(this,"NativeSessionState")}response;readError="";auxiliary;limit;loadingEarlier=!1;sender;ref;scratchpadSaving=!1;scratchpadError="";asking=!1;intelligenceError="";intelligenceAction;permissionCards=[];questionCards=[];elicitations=new V2(e=>e.nativeId);elicitationCards=[];answeredPermissions=new Map;answeredQuestions=new Map;questionBatches=new Map;generation=0;reading;rereadRequested=!1;readAbort;pollTimer;get session(){return this.response?.session}show(e,t){let s=this.ref!==void 0&&t!==void 0&&igs(this.ref)===igs(t);this.sender=e,!(s&&this.response)&&(s||this.leave(),this.ref=t,t&&e&&(this.refresh(),this.loadAuxiliary()))}leave(){this.generation+=1,this.readAbort?.abort(),this.readAbort=void 0,this.reading=void 0,this.rereadRequested=!1,this.clearPoll(),this.ref=void 0,this.response=void 0,this.readError="",this.auxiliary=void 0,this.limit=this.options.initialLimit,this.loadingEarlier=!1,this.scratchpadSaving=!1,this.scratchpadError="",this.asking=!1,this.intelligenceError="",this.intelligenceAction=void 0,this.answeredPermissions.clear(),this.answeredQuestions.clear(),this.questionBatches.clear(),this.permissionCards=[],this.questionCards=[],this.elicitations.clear(),this.elicitationCards=[]}refresh(){let e=this.generation;if(this.reading?.generation===e)return this.rereadRequested=!0,this.reading.promise;let t=this.read(e).finally(()=>{if(this.reading?.promise===t){if(this.reading=void 0,!this.rereadRequested)return this.schedulePoll();this.rereadRequested=!1,this.refresh()}});return this.reading={generation:e,promise:t},t}async loadAuxiliary(){let{ref:e,sender:t,generation:s}=this;if(!(!e||!t))try{let r=await t.fire("controller.nativesession.auxiliary.get",{session:e});if(s!==this.generation)return;this.auxiliary=r,this.intelligenceAction=VUe(r.sessionIntelligenceAvailabilityStatus==="unavailable"?r.sessionIntelligenceRemedy:void 0),this.host.requestUpdate()}catch(r){if(s!==this.generation)return;this.intelligenceError=vd(r),this.host.requestUpdate()}}async loadEarlier(){if(this.loadingEarlier||!this.hasEarlier())return;let e=this.generation;this.loadingEarlier=!0,this.limit=Math.min(tgs,this.limit+nKt),this.host.requestUpdate();try{await this.refresh()}finally{e===this.generation&&(this.loadingEarlier=!1,this.host.requestUpdate())}}hasEarlier(){return this.response?.messagePage.nextCursor!==void 0&&this.limit<tgs}chatView(){let e=this.response,t=this.auxiliary,s=e?.intelligenceExchanges??[],r=[...s].reverse().find(a=>a.scratchpadConflict===!0);return{scratchpad:e?.scratchpad,scratchpadBusy:this.scratchpadSaving,scratchpadError:this.scratchpadError,...t?{sessionMetrics:t.sessionMetrics}:{},sessionIntelligenceEnabled:t?.sessionIntelligenceEnabled??!1,intelligenceAvailabilityStatus:t?.sessionIntelligenceAvailabilityStatus??"unavailable",intelligenceUnavailableReason:t?.sessionIntelligenceUnavailableReason??"Session Intelligence is still loading.",intelligenceAvailabilityAction:this.intelligenceAction,intelligenceExchanges:s,intelligenceBusy:this.asking||s.some(a=>a.status==="running"),intelligenceError:this.intelligenceError||(r?"The answer completed, but its scratchpad update was not applied because a newer revision exists.":""),permissions:this.permissionCards,questions:this.questionCards,elicitations:this.elicitationCards}}handlers={scratchpadSave:n(e=>{let t=e.detail;typeof t?.text!="string"||!Number.isSafeInteger(t.expectedRevision)||t.expectedRevision<0||this.saveScratchpad(t.text,t.expectedRevision)},"scratchpadSave"),intelligenceAsk:n(e=>{let t=e.detail?.question?.trim();t&&this.ask(t)},"intelligenceAsk"),intelligenceAvailabilityAction:n(()=>{let e=this.auxiliary?.sessionIntelligenceAvailabilityStatus==="unavailable"?this.auxiliary.sessionIntelligenceRemedy:void 0;e!==void 0&&this.host.dispatchEvent(new CustomEvent("agl-session-intelligence-remedy",{detail:{remedy:e},bubbles:!0,composed:!0}))},"intelligenceAvailabilityAction"),permissionResponse:n(e=>{let t=e.detail,s=this.response?.permissions.find(r=>r.id.nativeId===t?.requestId);s&&(this.answeredPermissions.set(t.requestId,{...t.request,response:t.response,respondedAt:Date.now()}),this.rebuildCards(),this.reply(()=>this.sender.fire("controller.nativesession.permission.reply",{session:this.ref,requestId:s.id,reply:t.response==="reject"?"reject":"once"})))},"permissionResponse"),questionResponse:n(e=>{let t=e.detail,s=Array.isArray(t?.answers)?t.answers.filter(r=>typeof r=="string"&&r.trim().length>0):[];if(s.length!==0)for(let r of this.response?.questions??[]){let a=r.questions.findIndex((c,d)=>B0r(r,d)===t.requestId);if(a<0)continue;this.answeredQuestions.set(t.requestId,{...t.request,response:s,respondedAt:Date.now()}),this.rebuildCards();let o=this.questionBatches.get(r.id.nativeId)??new Map;if(o.set(a,s),this.questionBatches.set(r.id.nativeId,o),o.size<r.questions.length)return;this.questionBatches.delete(r.id.nativeId);let l=r.questions.map((c,d)=>o.get(d)??[]);this.reply(()=>this.sender.fire("controller.nativesession.question.reply",{session:this.ref,requestId:r.id,answers:l}));return}},"questionResponse"),elicitationResponse:n(e=>{let t=e.detail?.requestId;if(typeof t!="string")return;let s=this.elicitations.request(t),r=z8(e.detail);s&&r&&this.answerElicitation(t,s.id,r)},"elicitationResponse")};async read(e){let{ref:t,sender:s}=this;if(!t||!s||!this.host.isConnected)return;this.clearPoll();let r=new AbortController;this.readAbort=r;try{let a=await s.fire("controller.nativesession.read",{session:t,limit:this.limit},{abortSignal:r.signal});if(e!==this.generation)return;this.response=a,this.readError="",this.rebuildCards()}catch(a){if(e!==this.generation)return;this.readError=vd(a),this.host.requestUpdate()}finally{this.readAbort===r&&(this.readAbort=void 0)}}async saveScratchpad(e,t){let{ref:s,sender:r,generation:a}=this;if(!(!s||!r||this.scratchpadSaving)){this.scratchpadSaving=!0,this.scratchpadError="",this.host.requestUpdate();try{let{scratchpad:o}=await r.fire("controller.nativesession.scratchpad.save",{session:s,text:e,expectedRevision:t});if(a!==this.generation||!this.response)return;this.response={...this.response,scratchpad:o}}catch(o){if(a!==this.generation)return;this.scratchpadError=vd(o),this.refresh()}finally{a===this.generation&&(this.scratchpadSaving=!1,this.host.requestUpdate())}}}async ask(e){let{ref:t,sender:s,generation:r,auxiliary:a,response:o}=this;if(!(!t||!s||!o||this.asking||a?.sessionIntelligenceEnabled!==!0||a.sessionIntelligenceAvailabilityStatus!=="available"||o.intelligenceExchanges.some(l=>l.status==="running"))){this.asking=!0,this.intelligenceError="",this.host.requestUpdate();try{let{exchange:l}=await s.fire("controller.nativesession.intelligence.ask",{session:t,question:e});if(r!==this.generation||!this.response)return;let c=this.response.intelligenceExchanges;this.response={...this.response,intelligenceExchanges:c.some(d=>d.id===l.id)?c.map(d=>d.id===l.id&&d.status==="running"?l:d):[...c,l]}}catch(l){if(r!==this.generation)return;this.intelligenceError=vd(l)}finally{r===this.generation&&(this.asking=!1,this.host.requestUpdate(),this.refresh())}}}async reply(e){let t=this.generation;try{await e()}catch(s){if(t!==this.generation)return;this.readError=vd(s)}t===this.generation&&this.refresh()}async answerElicitation(e,t,s){let{ref:r,sender:a,generation:o}=this;if(!(!r||!a)){try{await a.fire("controller.nativesession.elicitation.reply",{session:r,requestId:t,reply:s})}catch(l){if(o!==this.generation)return;this.elicitations.refuse(e,vd(l)),this.rebuildCards()}o===this.generation&&this.refresh()}}rebuildCards(){let e=this.response,t=new Set(e?.permissions.map(a=>a.id.nativeId));for(let a of this.answeredPermissions.keys())t.has(a)||this.answeredPermissions.delete(a);this.permissionCards=(e?.permissions??[]).map(a=>this.answeredPermissions.get(a.id.nativeId)??q8(a,a.id.nativeId));let s=[],r=new Set;for(let a of e?.questions??[])for(let o of xB(a,a.id.nativeId))r.add(o.id),s.push(this.answeredQuestions.get(o.id)??o);for(let a of this.answeredQuestions.keys())r.has(a)||this.answeredQuestions.delete(a);this.questionCards=s,this.elicitationCards=this.elicitations.cards(e?.elicitations??[]),this.host.requestUpdate()}schedulePoll(){this.clearPoll();let e=this.response;!(e!==void 0&&(e.intelligenceExchanges.some(s=>s.status==="running")||this.options.pollWhileBusy&&e.session.status==="busy"))||!this.host.isConnected||document.visibilityState!=="visible"||(this.pollTimer=setTimeout(()=>{this.pollTimer=void 0,this.refresh()},F0r))}clearPoll(){this.pollTimer&&clearTimeout(this.pollTimer),this.pollTimer=void 0}};var sgs,rgs,ngs,ags,ogs,lgs,cgs,dgs,ugs,hgs,pgs,Ea,aKt,oKt,lKt,cKt,dKt,uKt,hKt,pKt,fKt,{html:kB,css:z0r}=le,mKt=3e3,V8=12e4,rS={claude:"Claude Code",codex:"Codex"},GUe=n(i=>JSON.stringify([i.harnessId,i.nativeId]),"uiKey"),q0r=n(i=>{let{id:e,reasoning:t,toolCall:s,...r}=i,a=s?(({id:o,childSessionId:l,...c})=>({...c,id:GUe(o)}))(s):void 0;return{...r,id:GUe(e),markdown:i.role==="assistant",...t?{reasoning:t.map(o=>({...o,id:GUe(o.id)}))}:{},...a?{toolCall:a}:{}}},"harnessMessage"),jke=n((i,e)=>{let t=new Map(e?.bundles.map(a=>[a.key,a])),s=i.map(a=>{let o=`${GUe(a.sourceMessageId)}\0${a.structuralDigest}`;return t.get(o)??{key:o,messages:a.messages.map(q0r)}}),r=e!==void 0&&s.length===e.bundles.length&&s.every((a,o)=>a===e.bundles[o]);return{bundles:s,messages:r?e.messages:s.flatMap(a=>a.messages)}},"transcript"),U0r=n((i,e)=>({view:{worker:i.worker,...i.status?{status:i.status}:{},...i.outcome?{outcome:i.outcome}:{},...i.nativeWait?{nativeWait:i.nativeWait}:{}},earlier:i.earlier,...jke(i.bundles,e)}),"workerPage"),vd=n(i=>i instanceof Error&&i.message?i.message:"The request failed.","errorText"),H0r={approval:"Approve in",user_input:"Reply in",native_prompt:"Answer in",unrecognized:"Waiting in"},V0r={usage_limit:"usage limit reached",usage_reserve:"usage reserve reached",rate_limit:"rate limit reached"},G0r=n(i=>i?.state==="failed"?{type:"error",message:`The last turn failed${i.limit?`: ${V0r[i.limit]}`:""}.`}:void 0,"fleetWorkerOutcomeStatus"),CB=[],Kke=["steer"];pgs=[le.customElement("agl-fleet-worker")];var jp=class jp extends(hgs=le.DeesElement,ugs=[le.property({attribute:!1})],dgs=[le.property()],cgs=[le.property()],lgs=[le.state()],ogs=[le.state()],ags=[le.state()],ngs=[le.state()],rgs=[le.state()],sgs=[le.state()],hgs){constructor(){super(...arguments);it(this,aKt,ge(Ea,8,this)),ge(Ea,11,this);it(this,oKt,ge(Ea,12,this,"")),ge(Ea,15,this);it(this,lKt,ge(Ea,16,this,"")),ge(Ea,19,this);it(this,cKt,ge(Ea,20,this)),ge(Ea,23,this);it(this,dKt,ge(Ea,24,this,"")),ge(Ea,27,this);it(this,uKt,ge(Ea,28,this,!1)),ge(Ea,31,this);it(this,hKt,ge(Ea,32,this,"")),ge(Ea,35,this);it(this,pKt,ge(Ea,36,this,"")),ge(Ea,39,this);it(this,fKt,ge(Ea,40,this,CB)),ge(Ea,43,this);Ae(this,"session",new H8(this,{initialLimit:1,pollWhileBusy:!1}));Ae(this,"generation",0);Ae(this,"reading");Ae(this,"rereadRequested",!1);Ae(this,"readAbort");Ae(this,"readTimer");Ae(this,"handleVisibilityChange",n(()=>{document.visibilityState==="visible"?this.refresh():this.clearReadTimer()},"handleVisibilityChange"));Ae(this,"handleInput",n(t=>{typeof t.detail?.value=="string"&&(this.draft=t.detail.value)},"handleInput"));Ae(this,"handleAttachmentsChange",n(t=>{Array.isArray(t.detail?.attachments)&&(this.attachments=t.detail.attachments)},"handleAttachmentsChange"));Ae(this,"handleSend",n(async t=>{let{name:s,report:r,sender:a}=this,o=t.detail?.text??"";if(!s||!a||this.steering||!o.trim())return;let l=W2(t.detail.attachments??[]);if(!l){this.steerError="An attachment could not be read; remove it and attach it again.";return}let c=this.generation;this.steering=!0,this.steerError="";try{let d=l.length>0?{attachments:l}:{},u=r?await a.fire("controller.directreport.message",{name:r,text:o,...d},{timeoutMs:V8}):await a.fire("controller.fleet.worker.steer",{name:s,text:o,...d},{timeoutMs:V8});if(c!==this.generation)return;let h="job"in u?u.job:void 0;!h||h.state==="succeeded"?(this.draft="",this.attachments=CB):h.errorOutcome==="refused"?this.steerError=h.error??"The fleet did not deliver the message.":this.steerError=`The steer's outcome is unknown (${h.error??"the fleet job failed"}). Check the transcript before sending it again.`}catch(d){if(c!==this.generation)return;this.steerError=d instanceof Yi.TypedResponseError?vd(d):`The steer's outcome is unknown (${vd(d)}). Check the transcript before sending it again.`}finally{c===this.generation&&(this.steering=!1,this.refresh())}},"handleSend"))}refresh(){let t=this.generation;if(this.reading?.generation===t)return this.rereadRequested=!0,this.reading.promise;let s=this.read(t).finally(()=>{if(this.reading?.promise===s){if(this.reading=void 0,!this.rereadRequested)return this.scheduleRead();this.rereadRequested=!1,this.refresh()}});return this.reading={generation:t,promise:s},s}async connectedCallback(){let t=this.hasUpdated;await super.connectedCallback(),document.addEventListener("visibilitychange",this.handleVisibilityChange),t&&this.refresh()}async disconnectedCallback(){document.removeEventListener("visibilitychange",this.handleVisibilityChange),this.leaveWorker(),await super.disconnectedCallback()}willUpdate(t){t.has("name")&&(this.leaveWorker(),this.page=void 0,this.readError="",this.steering=!1,this.steerError="",this.draft="",this.attachments=CB)}updated(t){(t.has("name")||t.has("sender")&&!this.page)&&this.refresh()}render(){let t=this.page?.view,s=t?.worker,r=t?.status==="busy",a=!this.report&&s!==void 0&&s.ticketKey===void 0,o=this.readError?{type:"error",message:this.readError}:this.steering?{type:"busy",message:"Steering the worker\u2026"}:r?{type:"busy",message:"Working"}:G0r(t?.outcome)??{type:"idle"};return kB`
49281
49281
  <div class="chatStack">
49282
49282
  ${this.page?.earlier?kB`<div class="notice" role="note">Showing the newest turns; earlier ones stay in the worker's own transcript.</div>`:""}
49283
49283
  ${a?kB`<div class="notice warning" role="note">Only its driver steers this worker: it is bound to no ticket.</div>`:""}
@@ -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.0",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.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(`
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
- size: 34808144 bytes
4
- sha256: 7da47530d315987c9b46ddf2704a34b60adcaff8c348ab9d76f5ef5e2125f11a
3
+ size: 34810131 bytes
4
+ sha256: e90a3a790fd059292783c1a2c5760d09d82dcc055bcbfe607cde1e83b1d34eb4
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '43.3.0',
6
+ version: '43.3.1',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxLQUFLO0lBQ1gsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLG1FQUFtRTtDQUNqRixDQUFBIn0=
@@ -109,6 +109,13 @@ export declare class SmartDataAuthStore implements IAuthStore, IAuthStoreSession
109
109
  migrateTicketOwnerPrincipal(): Promise<void>;
110
110
  /** AGL-916: tickets released by hand without a release link move to the closed column; answers the keys it moved. */
111
111
  migrateTicketClosedColumn(): Promise<string[]>;
112
+ /** AGL-1686: once, ticket people and actors named by their session id are named by their role; answers the keys it moved. */
113
+ migrateTicketActorNames(): Promise<string[]>;
114
+ /** The ticket migrations of a controller start, in the runner's order; answers what v41 moved and v43 renamed. */
115
+ migrateTicketsAtStart(): Promise<{
116
+ closed: string[];
117
+ renamed: string[];
118
+ }>;
112
119
  /**
113
120
  * AGL-909: once, links and release plans name each repository `resolveArg` resolves as `org/name`; answers the keys it
114
121
  * changed. With no repository discovered (`discoveredArg` 0) it waits for a later start.