agl 43.1.0 → 43.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/changelog.md +32 -0
  2. package/dist_serve/bundle.js +5950 -5530
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_serve/bundle.js.third-party-notices.json +31 -31
  5. package/dist_serve/bundle.js.third-party-notices.txt +31 -31
  6. package/dist_ts/00_commitinfo_data.js +1 -1
  7. package/dist_ts/aglapi/aglapisurface.document.js +521 -17
  8. package/dist_ts/aglapi/interfaces.d.ts +3 -0
  9. package/dist_ts/aglapi/interfaces.js +2 -1
  10. package/dist_ts/classes.accountsactions.d.ts +3 -1
  11. package/dist_ts/classes.accountsactions.js +21 -3
  12. package/dist_ts/classes.authmodels.js +17 -4
  13. package/dist_ts/classes.authstore.js +16 -2
  14. package/dist_ts/classes.claudeharness.d.ts +16 -0
  15. package/dist_ts/classes.claudeharness.js +24 -2
  16. package/dist_ts/classes.cli.d.ts +4 -2
  17. package/dist_ts/classes.cli.js +6 -3
  18. package/dist_ts/classes.codexclientadapter.d.ts +11 -0
  19. package/dist_ts/classes.codexclientadapter.js +14 -2
  20. package/dist_ts/classes.controller.d.ts +175 -11
  21. package/dist_ts/classes.controller.js +1213 -173
  22. package/dist_ts/classes.controllerdevices.d.ts +2 -0
  23. package/dist_ts/classes.controllerdevices.js +6 -1
  24. package/dist_ts/classes.controllermanagement.d.ts +14 -4
  25. package/dist_ts/classes.controllermanagement.js +20 -2
  26. package/dist_ts/classes.gatewayclient.d.ts +115 -0
  27. package/dist_ts/classes.gatewayclient.js +336 -0
  28. package/dist_ts/classes.gatewayclientstore.d.ts +97 -0
  29. package/dist_ts/classes.gatewayclientstore.js +261 -0
  30. package/dist_ts/classes.inbox.d.ts +72 -0
  31. package/dist_ts/classes.inbox.js +231 -0
  32. package/dist_ts/classes.inferencerouter.d.ts +19 -0
  33. package/dist_ts/classes.inferencerouter.js +15 -3
  34. package/dist_ts/classes.inferenceservice.d.ts +9 -0
  35. package/dist_ts/classes.inferenceservice.js +28 -2
  36. package/dist_ts/classes.mcpclient.d.ts +4 -1
  37. package/dist_ts/classes.mcpclient.js +42 -6
  38. package/dist_ts/classes.mcpcontrollerhost.d.ts +3 -1
  39. package/dist_ts/classes.mcpcontrollerhost.js +11 -1
  40. package/dist_ts/classes.mcptools.d.ts +3 -3
  41. package/dist_ts/classes.mcptools.js +38 -8
  42. package/dist_ts/classes.mcpvalidation.d.ts +5 -0
  43. package/dist_ts/classes.mcpvalidation.js +38 -2
  44. package/dist_ts/classes.nativesessions.d.ts +17 -4
  45. package/dist_ts/classes.nativesessions.js +41 -9
  46. package/dist_ts/classes.opencodeclient.d.ts +23 -2
  47. package/dist_ts/classes.opencodeclient.js +47 -3
  48. package/dist_ts/classes.proxycontrol.d.ts +11 -0
  49. package/dist_ts/classes.proxycontrol.js +7 -1
  50. package/dist_ts/classes.proxycontrolclient.d.ts +17 -0
  51. package/dist_ts/classes.proxycontrolclient.js +35 -1
  52. package/dist_ts/classes.proxydaemon.js +8 -1
  53. package/dist_ts/classes.proxymonitor.d.ts +7 -0
  54. package/dist_ts/classes.proxymonitor.js +13 -1
  55. package/dist_ts/classes.publishedset.d.ts +38 -0
  56. package/dist_ts/classes.publishedset.js +50 -0
  57. package/dist_ts/classes.sessionfeed.d.ts +3 -3
  58. package/dist_ts/classes.sessionfeed.js +18 -26
  59. package/dist_ts/classes.systemmetricssampler.d.ts +6 -0
  60. package/dist_ts/classes.systemmetricssampler.js +15 -3
  61. package/dist_ts/classes.ticketstore.d.ts +50 -3
  62. package/dist_ts/classes.ticketstore.js +45 -8
  63. package/dist_ts/classes.trustedproxysecrets.d.ts +2 -0
  64. package/dist_ts/classes.trustedproxysecrets.js +5 -1
  65. package/dist_ts/driver/classes.directreports.d.ts +14 -4
  66. package/dist_ts/driver/classes.directreports.js +25 -6
  67. package/dist_ts/driver/classes.driverservice.d.ts +44 -3
  68. package/dist_ts/driver/classes.driverservice.js +50 -16
  69. package/dist_ts/fleet/classes.claudeworkers.d.ts +21 -5
  70. package/dist_ts/fleet/classes.claudeworkers.js +142 -46
  71. package/dist_ts/fleet/classes.codexworkers.d.ts +16 -4
  72. package/dist_ts/fleet/classes.codexworkers.js +22 -5
  73. package/dist_ts/fleet/classes.workercommand.d.ts +6 -1
  74. package/dist_ts/fleet/classes.workercommand.js +15 -4
  75. package/dist_ts/fleet/classes.workers.d.ts +5 -1
  76. package/dist_ts/fleet/classes.workers.js +8 -2
  77. package/dist_ts/fleet/functions.unbounddrivers.js +2 -2
  78. package/dist_ts/fleet/functions.workervalidation.js +2 -2
  79. package/dist_ts/fleet/interfaces.workers.d.ts +21 -3
  80. package/dist_ts/fleet/interfaces.workers.js +1 -1
  81. package/dist_ts/functions.agentmessage.d.ts +3 -0
  82. package/dist_ts/functions.agentmessage.js +4 -1
  83. package/dist_ts/functions.controllermanagementsurface.d.ts +4 -0
  84. package/dist_ts/functions.controllermanagementsurface.js +15 -1
  85. package/dist_ts/functions.deviceapi.d.ts +151 -4
  86. package/dist_ts/functions.deviceapi.js +893 -38
  87. package/dist_ts/functions.fleetworkercli.d.ts +1 -1
  88. package/dist_ts/functions.fleetworkercli.js +11 -8
  89. package/dist_ts/functions.gatewaycli.d.ts +24 -0
  90. package/dist_ts/functions.gatewaycli.js +395 -0
  91. package/dist_ts/functions.gatewayroute.d.ts +135 -0
  92. package/dist_ts/functions.gatewayroute.js +366 -0
  93. package/dist_ts/functions.inferencecli.js +32 -1
  94. package/dist_ts/functions.inferencecliarguments.d.ts +8 -2
  95. package/dist_ts/functions.inferencecliarguments.js +31 -3
  96. package/dist_ts/functions.mcpfleetworkertools.js +2 -2
  97. package/dist_ts/functions.proxycapacity.d.ts +50 -0
  98. package/dist_ts/functions.proxycapacity.js +142 -0
  99. package/dist_ts/functions.proxycapacitycli.d.ts +30 -0
  100. package/dist_ts/functions.proxycapacitycli.js +65 -0
  101. package/dist_ts/functions.remotecli.d.ts +30 -3
  102. package/dist_ts/functions.remotecli.js +44 -18
  103. package/dist_ts/functions.ticketvalidation.js +11 -2
  104. package/dist_ts/interfaces.auth.d.ts +25 -4
  105. package/dist_ts/interfaces.auth.js +15 -1
  106. package/dist_ts/plugins.d.ts +5 -1
  107. package/dist_ts/plugins.js +10 -2
  108. package/dist_ts_authswitch/authority-contract.d.ts +25 -0
  109. package/dist_ts_authswitch/authority-contract.js +1 -1
  110. package/dist_ts_authswitch/authority-overview.d.ts +8 -0
  111. package/dist_ts_authswitch/authority-overview.js +17 -6
  112. package/dist_ts_authswitch/authority-placement.d.ts +20 -16
  113. package/dist_ts_authswitch/authority-placement.js +19 -26
  114. package/dist_ts_authswitch/authority-renewal.d.ts +34 -0
  115. package/dist_ts_authswitch/authority-renewal.js +56 -0
  116. package/dist_ts_authswitch/authority-usagelimit.d.ts +29 -0
  117. package/dist_ts_authswitch/authority-usagelimit.js +66 -2
  118. package/dist_ts_authswitch/authority-usagewindows.d.ts +6 -0
  119. package/dist_ts_authswitch/authority-usagewindows.js +15 -1
  120. package/dist_ts_authswitch/classes.authoritybroker.d.ts +8 -0
  121. package/dist_ts_authswitch/classes.authoritybroker.js +35 -2
  122. package/dist_ts_authswitch/classes.authoritycli.d.ts +1 -0
  123. package/dist_ts_authswitch/classes.authoritycli.js +44 -3
  124. package/dist_ts_authswitch/classes.authorityclient.d.ts +6 -1
  125. package/dist_ts_authswitch/classes.authorityclient.js +12 -4
  126. package/dist_ts_authswitch/classes.authoritydaemon.js +8 -1
  127. package/dist_ts_authswitch/classes.authoritydatabase.js +6 -2
  128. package/dist_ts_authswitch/classes.authoritymodels.d.ts +7 -0
  129. package/dist_ts_authswitch/classes.authoritymodels.js +21 -5
  130. package/dist_ts_interfaces/devices.d.ts +1012 -5
  131. package/dist_ts_interfaces/devices.js +68 -2
  132. package/dist_ts_interfaces/fleetworkers.d.ts +5 -3
  133. package/dist_ts_interfaces/gateway.d.ts +151 -0
  134. package/dist_ts_interfaces/gateway.js +66 -0
  135. package/dist_ts_interfaces/inbox.d.ts +234 -0
  136. package/dist_ts_interfaces/inbox.js +101 -0
  137. package/dist_ts_interfaces/index.d.ts +3 -0
  138. package/dist_ts_interfaces/index.js +4 -1
  139. package/dist_ts_interfaces/interfaces.d.ts +10 -3
  140. package/dist_ts_interfaces/interfaces.js +4 -2
  141. package/dist_ts_interfaces/management.d.ts +4 -4
  142. package/dist_ts_interfaces/management.js +3 -2
  143. package/dist_ts_interfaces/mcprequests.d.ts +48 -6
  144. package/dist_ts_interfaces/mcprequests.js +12 -1
  145. package/dist_ts_interfaces/mcpworkspacerequests.d.ts +4 -1
  146. package/dist_ts_interfaces/mcpworkspacerequests.js +1 -1
  147. package/dist_ts_interfaces/nativesessions.d.ts +16 -3
  148. package/dist_ts_interfaces/plugins.d.ts +2 -1
  149. package/dist_ts_interfaces/plugins.js +4 -2
  150. package/dist_ts_interfaces/proxycapacity.d.ts +99 -0
  151. package/dist_ts_interfaces/proxycapacity.js +74 -0
  152. package/dist_ts_interfaces/requests.accounts.d.ts +21 -0
  153. package/dist_ts_interfaces/requests.accounts.js +3 -1
  154. package/dist_ts_interfaces/requests.d.ts +3 -2
  155. package/dist_ts_interfaces/requests.js +1 -1
  156. package/docs/authswitch.md +20 -1
  157. package/package.json +6 -5
  158. package/readme.md +191 -31
  159. package/ts/00_commitinfo_data.ts +1 -1
  160. package/ts/aglapi/aglapisurface.document.ts +520 -16
  161. package/ts/aglapi/interfaces.ts +1 -0
  162. package/ts/classes.accountsactions.ts +30 -3
  163. package/ts/classes.authmodels.ts +22 -3
  164. package/ts/classes.authstore.ts +15 -1
  165. package/ts/classes.claudeharness.ts +27 -1
  166. package/ts/classes.cli.ts +7 -3
  167. package/ts/classes.codexclientadapter.ts +14 -1
  168. package/ts/classes.controller.ts +1428 -249
  169. package/ts/classes.controllerdevices.ts +6 -0
  170. package/ts/classes.controllermanagement.ts +40 -7
  171. package/ts/classes.gatewayclient.ts +401 -0
  172. package/ts/classes.gatewayclientstore.ts +272 -0
  173. package/ts/classes.inbox.ts +239 -0
  174. package/ts/classes.inferencerouter.ts +27 -2
  175. package/ts/classes.inferenceservice.ts +28 -1
  176. package/ts/classes.mcpclient.ts +42 -3
  177. package/ts/classes.mcpcontrollerhost.ts +15 -0
  178. package/ts/classes.mcptools.ts +42 -9
  179. package/ts/classes.mcpvalidation.ts +32 -1
  180. package/ts/classes.nativesessions.ts +50 -12
  181. package/ts/classes.opencodeclient.ts +55 -4
  182. package/ts/classes.proxycontrol.ts +16 -0
  183. package/ts/classes.proxycontrolclient.ts +30 -0
  184. package/ts/classes.proxydaemon.ts +8 -0
  185. package/ts/classes.proxymonitor.ts +12 -0
  186. package/ts/classes.publishedset.ts +56 -0
  187. package/ts/classes.sessionfeed.ts +17 -20
  188. package/ts/classes.systemmetricssampler.ts +13 -2
  189. package/ts/classes.ticketstore.ts +73 -12
  190. package/ts/classes.trustedproxysecrets.ts +5 -0
  191. package/ts/driver/classes.directreports.ts +25 -6
  192. package/ts/driver/classes.driverservice.ts +75 -14
  193. package/ts/fleet/classes.claudeworkers.ts +112 -39
  194. package/ts/fleet/classes.codexworkers.ts +21 -6
  195. package/ts/fleet/classes.workercommand.ts +14 -4
  196. package/ts/fleet/classes.workers.ts +9 -2
  197. package/ts/fleet/functions.unbounddrivers.ts +1 -1
  198. package/ts/fleet/functions.workervalidation.ts +1 -1
  199. package/ts/fleet/interfaces.workers.ts +20 -5
  200. package/ts/functions.agentmessage.ts +3 -0
  201. package/ts/functions.controllermanagementsurface.ts +15 -0
  202. package/ts/functions.deviceapi.ts +1071 -34
  203. package/ts/functions.fleetworkercli.ts +10 -7
  204. package/ts/functions.gatewaycli.ts +436 -0
  205. package/ts/functions.gatewayroute.ts +429 -0
  206. package/ts/functions.inferencecli.ts +26 -0
  207. package/ts/functions.inferencecliarguments.ts +30 -4
  208. package/ts/functions.mcpfleetworkertools.ts +1 -1
  209. package/ts/functions.proxycapacity.ts +191 -0
  210. package/ts/functions.proxycapacitycli.ts +104 -0
  211. package/ts/functions.remotecli.ts +56 -20
  212. package/ts/functions.ticketvalidation.ts +11 -1
  213. package/ts/interfaces.auth.ts +36 -4
  214. package/ts/plugins.ts +12 -0
  215. package/ts_authswitch/authority-contract.ts +20 -0
  216. package/ts_authswitch/authority-overview.ts +28 -6
  217. package/ts_authswitch/authority-placement.ts +27 -32
  218. package/ts_authswitch/authority-renewal.ts +64 -0
  219. package/ts_authswitch/authority-usagelimit.ts +84 -1
  220. package/ts_authswitch/authority-usagewindows.ts +13 -0
  221. package/ts_authswitch/classes.authoritybroker.ts +34 -1
  222. package/ts_authswitch/classes.authoritycli.ts +49 -2
  223. package/ts_authswitch/classes.authorityclient.ts +14 -4
  224. package/ts_authswitch/classes.authoritydaemon.ts +9 -1
  225. package/ts_authswitch/classes.authoritydatabase.ts +5 -1
  226. package/ts_authswitch/classes.authoritymodels.ts +23 -3
  227. package/ts_authswitch/native-contracts.md +21 -0
  228. package/ts_authswitch/readme.md +1 -1
  229. package/ts_interfaces/devices.schema.json +3573 -603
  230. package/ts_interfaces/devices.ts +1093 -4
  231. package/ts_interfaces/fleetworkers.ts +5 -3
  232. package/ts_interfaces/gateway.ts +242 -0
  233. package/ts_interfaces/inbox.ts +287 -0
  234. package/ts_interfaces/index.ts +3 -0
  235. package/ts_interfaces/interfaces.ts +9 -2
  236. package/ts_interfaces/management.ts +6 -4
  237. package/ts_interfaces/mcprequests.ts +61 -4
  238. package/ts_interfaces/mcpworkspacerequests.ts +4 -2
  239. package/ts_interfaces/nativesessions.ts +17 -3
  240. package/ts_interfaces/plugins.ts +3 -1
  241. package/ts_interfaces/proxycapacity.ts +162 -0
  242. package/ts_interfaces/requests.accounts.ts +20 -0
  243. package/ts_interfaces/requests.ts +4 -0
  244. package/ts_web/00_commitinfo_data.ts +1 -1
  245. package/ts_web/accounts.plugins.ts +4 -2
  246. package/ts_web/classes.accountsreadmodel.ts +33 -0
  247. package/ts_web/classes.browserpresentation.ts +19 -6
  248. package/ts_web/classes.inboxfeed.ts +329 -0
  249. package/ts_web/classes.nativesessionstate.ts +9 -23
  250. package/ts_web/elements.accounts.ts +121 -113
  251. package/ts_web/elements.configurationpane.ts +24 -37
  252. package/ts_web/elements.deployments.ts +66 -2
  253. package/ts_web/elements.devices.ts +4 -17
  254. package/ts_web/elements.flexlimitstrip.ts +21 -70
  255. package/ts_web/elements.harnesscontrollerapp.ts +198 -222
  256. package/ts_web/elements.inbox.ts +808 -0
  257. package/ts_web/functions.inbox.ts +95 -0
  258. package/ts_web/functions.sessioncards.ts +40 -0
  259. package/ts_web/plugins.ts +2 -0
@@ -6,6 +6,7 @@ import { controllerMcpFleetMethods, type TControllerMcpFleetTypedRequest } from
6
6
  import { controllerMcpSessionFeedMethods, type TControllerMcpSessionFeedTypedRequest } from './sessionfeed.js';
7
7
  import { controllerMcpDeployMethods, type TControllerMcpDeployTypedRequest } from './deployments.js';
8
8
  import * as plugins from './plugins.js';
9
+ import type { IProxyCapacityAnswer, IProxyCapacityRequest } from './proxycapacity.js';
9
10
  import type { IReq_ControllerMcpWorkerEnroll, IWorkerCallerSubject } from './workercallers.js';
10
11
  import type { IReq_ControllerSettingsGet, IReq_ControllerSettingsUpdate } from './requests.js';
11
12
  import type {
@@ -16,7 +17,9 @@ import type {
16
17
  TConfigurationNativeTargetId,
17
18
  TConfigurationTargetId,
18
19
  } from './configuration.js';
20
+ import type { IControllerNativeSession, TControllerNativeJobDelivery } from './nativesessions.js';
19
21
  import type {
22
+ IControllerMessagePage,
20
23
  IControllerProject,
21
24
  IControllerSession,
22
25
  IControllerSessionDetail,
@@ -44,6 +47,7 @@ export const controllerMcpMethods = [
44
47
  'agl.mcp.session.scratchpad.read',
45
48
  'agl.mcp.session.scratchpad.update',
46
49
  'agl.mcp.session.message',
50
+ 'agl.mcp.proxy.capacity',
47
51
  ...controllerMcpWorkspaceMethods,
48
52
  ...controllerMcpJobMethods,
49
53
  'agl.mcp.controller.settings.get',
@@ -299,6 +303,21 @@ export interface IReq_ControllerMcpStatus extends plugins.typedrequestInterfaces
299
303
  response: IControllerMcpStatusResponse;
300
304
  }
301
305
 
306
+ /**
307
+ * A pool's room for new work in AGL's inference proxy, or both pools' when `provider` is absent: each counted account by
308
+ * its id with its plan, state, headroom, binding window and when its headroom next grows, the newest provider 429 on
309
+ * the pool, and an `open` or `wait` verdict against `minHeadroom` (15 unless given). The controller asks the proxy; the
310
+ * answer names no account by label or email.
311
+ */
312
+ export interface IReq_ControllerMcpProxyCapacity extends plugins.typedrequestInterfaces.implementsTR<
313
+ plugins.typedrequestInterfaces.ITypedRequest,
314
+ IReq_ControllerMcpProxyCapacity
315
+ > {
316
+ method: 'agl.mcp.proxy.capacity';
317
+ request: IProxyCapacityRequest;
318
+ response: IProxyCapacityAnswer;
319
+ }
320
+
302
321
  /** Lists the projects registered with the running AGL controller. */
303
322
  export interface IReq_ControllerMcpProjectsList extends plugins.typedrequestInterfaces.implementsTR<
304
323
  plugins.typedrequestInterfaces.ITypedRequest,
@@ -309,9 +328,16 @@ export interface IReq_ControllerMcpProjectsList extends plugins.typedrequestInte
309
328
  response: { projects: IControllerProject[] };
310
329
  }
311
330
 
331
+ /** The most settled Claude Code sessions `agl.mcp.sessions.list` lists in `nativeSessions`; running ones are all listed. */
332
+ export const controllerMcpNativeSessionSettledLimit = 50;
333
+
312
334
  /**
313
- * Discovers a project's OpenCode, Flex and Codex tasks from its folder and configured connections,
314
- * tasks created outside AGL included.
335
+ * Discovers a project's OpenCode, Flex and Codex tasks and AGL's own Claude Code conversations from its folder and
336
+ * configured connections, tasks created outside AGL included (`sessions`), and, apart from them, the Claude Code
337
+ * sessions of the host's own Claude Code home whose directory is the project folder itself (`nativeSessions`): running
338
+ * ones first, all of them, then at most `controllerMcpNativeSessionSettledLimit` settled ones, newest first
339
+ * (`nativeSessionsTruncated` when more may exist). `nativeSessionsError` names why the Claude Code inventory could not
340
+ * be read; `nativeSessions` is then empty.
315
341
  */
316
342
  export interface IReq_ControllerMcpSessionsList extends plugins.typedrequestInterfaces.implementsTR<
317
343
  plugins.typedrequestInterfaces.ITypedRequest,
@@ -319,9 +345,34 @@ export interface IReq_ControllerMcpSessionsList extends plugins.typedrequestInte
319
345
  > {
320
346
  method: 'agl.mcp.sessions.list';
321
347
  request: { projectId: string };
322
- response: { sessions: IControllerSession[] };
348
+ response: {
349
+ sessions: IControllerSession[];
350
+ nativeSessions: IControllerNativeSession[];
351
+ nativeSessionsTruncated?: true;
352
+ nativeSessionsError?: string;
353
+ };
323
354
  }
324
355
 
356
+ /**
357
+ * A Claude Code session outside AGL as `agl.mcp.session.read` answers it: the session with why it takes no message
358
+ * (`readOnly`) or how it takes one (`jobDelivery`), its newest transcript page and its scratchpad.
359
+ */
360
+ export interface IControllerMcpNativeSessionDetail {
361
+ kind: 'native';
362
+ session: IControllerNativeSession;
363
+ messagePage: IControllerMessagePage;
364
+ scratchpad: IControllerSessionScratchpad;
365
+ }
366
+
367
+ /**
368
+ * How an agent message to a Claude Code background job was delivered, in `session_message`'s delivery terms: a wake
369
+ * starts the job's next turn, an inbox message waits in its queue until the job reads it.
370
+ */
371
+ export const controllerMcpNativeDeliveries: Readonly<Record<TControllerNativeJobDelivery, TControllerPromptDelivery>> = {
372
+ wake: 'next-turn',
373
+ inbox: 'queue',
374
+ };
375
+
325
376
  /**
326
377
  * Reads the bounded current detail of one task: its newest messages, pending prompts, permissions,
327
378
  * questions, todos, scratchpad, model and, for Codex, the running turn. Read it again to follow the
@@ -336,7 +387,7 @@ export interface IReq_ControllerMcpSessionRead extends plugins.typedrequestInter
336
387
  projectId: string;
337
388
  sessionId: IControllerRuntimeId;
338
389
  };
339
- response: TControllerMcpSessionDetail;
390
+ response: TControllerMcpSessionDetail | IControllerMcpNativeSessionDetail;
340
391
  }
341
392
 
342
393
  export interface IReq_ControllerMcpSessionSend extends plugins.typedrequestInterfaces.implementsTR<
@@ -393,6 +444,11 @@ export interface IReq_ControllerMcpSessionMessage extends plugins.typedrequestIn
393
444
  delivery: TControllerPromptDelivery;
394
445
  /** The Codex or Claude Code turn a steer went into. */
395
446
  turnId?: string;
447
+ /**
448
+ * For a Claude Code background job outside AGL: how it took the message; `delivery` is then
449
+ * `controllerMcpNativeDeliveries[native]`.
450
+ */
451
+ native?: TControllerNativeJobDelivery;
396
452
  };
397
453
  }
398
454
 
@@ -441,6 +497,7 @@ export type TControllerMcpTypedRequest =
441
497
  | TControllerMcpWorkspaceTypedRequest
442
498
  | TControllerMcpJobTypedRequest
443
499
  | IReq_ControllerMcpStatus
500
+ | IReq_ControllerMcpProxyCapacity
444
501
  | IReq_ControllerMcpProjectsList
445
502
  | IReq_ControllerMcpSessionsList
446
503
  | IReq_ControllerMcpSessionRead
@@ -1,5 +1,6 @@
1
1
  import * as plugins from './plugins.js';
2
2
  import type * as requests from './requests.js';
3
+ import type { IControllerNativeSession } from './nativesessions.js';
3
4
  import type {
4
5
  IControllerProject, IControllerSession, TControllerResourceKind, TControllerSessionId, TControllerTerminalAgentKind,
5
6
  } from './interfaces.js';
@@ -240,14 +241,15 @@ export interface IReq_ControllerMcpWorkspaceReveal extends plugins.typedrequestI
240
241
 
241
242
  /**
242
243
  * Resolves an absolute project directory and, optionally, one of its existing native tasks to AGL's
243
- * project and qualified session. It does not take over a running task.
244
+ * project and qualified session. It does not take over a running task. A Claude Code session outside
245
+ * AGL (`sessions_list`'s `nativeSessions`) answers as `nativeSession` and is recorded nowhere.
244
246
  */
245
247
  export interface IReq_ControllerMcpContextResolve extends plugins.typedrequestInterfaces.implementsTR<
246
248
  plugins.typedrequestInterfaces.ITypedRequest, IReq_ControllerMcpContextResolve
247
249
  > {
248
250
  method: 'agl.mcp.context.resolve';
249
251
  request: { directory: string; sessionId?: TControllerSessionId };
250
- response: { project: IControllerProject; session?: IControllerSession };
252
+ response: { project: IControllerProject; session?: IControllerSession; nativeSession?: IControllerNativeSession };
251
253
  }
252
254
 
253
255
  export const controllerMcpWorkspaceMethods = [
@@ -26,9 +26,20 @@ export interface IControllerNativeSessionRef {
26
26
  profileId?: string;
27
27
  }
28
28
 
29
+ /**
30
+ * How a message reaches a Claude Code background job (`claude --bg`) that AGL does not run: `wake` continues a settled
31
+ * (done, blocked or stopped) job through Claude Code's own `claude --bg --resume`, `inbox` puts it into a running job's
32
+ * inbox through Claude Code's own SendMessage, accepted and queued there, not yet read.
33
+ */
34
+ export type TControllerNativeJobDelivery = 'wake' | 'inbox';
35
+
29
36
  /**
30
37
  * Why AGL does not write to a native session:
31
38
  * `running`: another process runs it, and AGL never becomes its second writer;
39
+ * `unaddressable`: a running background job takes a message only by a session name no other running session shares, and
40
+ * it has none or shares it;
41
+ * `notBackgroundJob`: an agent reaches only a background job (MCP `session_message`); the owner's own native session view
42
+ * resumes another settled session;
32
43
  * `profileHome`: it lives in a fleet profile's Claude Code home, which AGL's own Claude Code does not resume;
33
44
  * `directoryMissing`: its directory is gone, so nothing resumes it;
34
45
  * `projectConversation`: an AGL project conversation records it, and that project sends to it;
@@ -37,7 +48,7 @@ export interface IControllerNativeSessionRef {
37
48
  * `jobHeld`: AGL's own Claude Code still holds a background job's conversation, so Claude Code would wake a copy.
38
49
  */
39
50
  export type TControllerNativeSessionReadOnlyReason =
40
- 'running' | 'profileHome' | 'directoryMissing' | 'projectConversation' | 'fleetWorker' | 'jobFailed' | 'jobHeld';
51
+ 'running' | 'unaddressable' | 'notBackgroundJob' | 'profileHome' | 'directoryMissing' | 'projectConversation' | 'fleetWorker' | 'jobFailed' | 'jobHeld';
41
52
 
42
53
  export interface IControllerNativeSession extends IControllerNativeSessionRef {
43
54
  cwd: string;
@@ -51,6 +62,8 @@ export interface IControllerNativeSession extends IControllerNativeSessionRef {
51
62
  effort?: string;
52
63
  /** Present while AGL does not write to the session; `message` is the reason the owner sees. */
53
64
  readOnly?: { reason: TControllerNativeSessionReadOnlyReason; message: string };
65
+ /** How a message reaches the session, present exactly while it is a Claude Code background job that takes one. */
66
+ jobDelivery?: TControllerNativeJobDelivery;
54
67
  }
55
68
 
56
69
  /** A native session, its newest transcript page and its session state. */
@@ -90,8 +103,9 @@ export interface IReq_ControllerNativeSessionAuxiliaryGet extends plugins.typedr
90
103
 
91
104
  /**
92
105
  * Sends the owner's message to a native session that AGL may write to: a settled Claude Code session of the host's
93
- * own home, resumed in its own directory, or a Codex thread through the shared app-server that owns it. Attachments
94
- * follow the conversation send's contract and limits.
106
+ * own home, resumed in its own directory, a Claude Code background job (`jobDelivery`), or a Codex thread through the
107
+ * shared app-server that owns it. A job's inbox takes the text as the owner's agent message. Attachments follow the
108
+ * conversation send's contract and limits.
95
109
  */
96
110
  export interface IReq_ControllerNativeSessionSend extends plugins.typedrequestInterfaces.implementsTR<
97
111
  plugins.typedrequestInterfaces.ITypedRequest,
@@ -8,6 +8,8 @@ import type * as browserRuntime from '@push.rocks/smartbrowser/runtime';
8
8
  import * as authswitchAuthority from '../ts_authswitch/authority-contract.js';
9
9
  // An API key's monthly spend: the spend limit rule and dollar amounts, a leaf that imports nothing.
10
10
  import * as authswitchSpend from '../ts_authswitch/authority-spend.js';
11
+ // A Claude sign-in's monthly renewal: the anchor rule and the next renewal, a leaf that imports nothing.
12
+ import * as authswitchRenewal from '../ts_authswitch/authority-renewal.js';
11
13
  import type {
12
14
  AuthenticationResponseJSON,
13
15
  PublicKeyCredentialCreationOptionsJSON,
@@ -17,7 +19,7 @@ import type {
17
19
 
18
20
  export { typedrequestInterfaces };
19
21
  export type { browserRuntime };
20
- export { authswitchAuthority, authswitchSpend };
22
+ export { authswitchAuthority, authswitchRenewal, authswitchSpend };
21
23
 
22
24
  export type {
23
25
  AuthenticationResponseJSON,
@@ -0,0 +1,162 @@
1
+ /**
2
+ * A pool's room for new work in AGL's inference proxy (AGL-1097): `agl proxy capacity`, the proxy's
3
+ * `agl.proxy.capacity` and the MCP tool `proxy_capacity` answer it alike. A leaf: it imports nothing.
4
+ *
5
+ * The answer carries no identity: an account is named by its account id alone, never by its label or email.
6
+ */
7
+
8
+ /** A pool: Claude accounts (`anthropic`) or ChatGPT accounts (`openai`). */
9
+ export type TProxyCapacityProvider = 'anthropic' | 'openai';
10
+ export const proxyCapacityProviders: readonly TProxyCapacityProvider[] = ['anthropic', 'openai'];
11
+
12
+ /** The room a pool needs, in headroom percent summed over its members, when a request names none. */
13
+ export const proxyCapacityDefaultMinimumHeadroom = 15;
14
+
15
+ /**
16
+ * How long a pool waits after the newest provider 429 on one of its members, and how long a proxy must have observed its
17
+ * pools before the absence of a 429 counts: five minutes.
18
+ */
19
+ export const proxyCapacityQuietMs = 300_000;
20
+
21
+ /** What is asked: one pool, or both when `provider` is absent, against `minHeadroom` (a non-negative integer). */
22
+ export interface IProxyCapacityRequest {
23
+ provider?: TProxyCapacityProvider;
24
+ minHeadroom?: number;
25
+ }
26
+
27
+ /** A member's window, as its reading states it. */
28
+ export interface IProxyCapacityWindow {
29
+ /** The provider's name for the window, or its length (`5h`, `7d`) for one without a name. */
30
+ name: string;
31
+ durationSeconds: number;
32
+ /** The percent its limit decides by: the account service's estimate between reads where it has one. */
33
+ usedPercent: number;
34
+ /** Whether `usedPercent` is that estimate. */
35
+ estimated: boolean;
36
+ /** When its current period ends, as the reading states it; `null` when it states none. */
37
+ resetAt: string | null;
38
+ }
39
+
40
+ /** Whether a member takes new work now, as `agl proxy status` judges it, or why not. */
41
+ export type TProxyCapacityMemberState = 'available' | 'reserved' | 'exhausted' | 'cooling' | 'unavailable';
42
+ export const proxyCapacityMemberStates: readonly TProxyCapacityMemberState[] = ['available', 'reserved', 'exhausted',
43
+ 'cooling', 'unavailable'];
44
+
45
+ /** An account the pool counts: a subscription sign-in of a counted plan that has not lapsed. */
46
+ export interface IProxyCapacityMember {
47
+ /** The account's id (64 hex characters). */
48
+ accountId: string;
49
+ /** Its plan as its held reading states it, one the pool counts. */
50
+ plan: string;
51
+ state: TProxyCapacityMemberState;
52
+ /** The headroom it adds to the room now: its headroom below its threshold while it takes new work, else 0. */
53
+ headroom: number;
54
+ /** The window its headroom is bound by; `null` without a usable reading with a counted window. */
55
+ binding: IProxyCapacityWindow | null;
56
+ /**
57
+ * When the headroom it adds next grows, from its reading alone: the binding window's reset, or the moment it takes
58
+ * work again (a provider 429's rest, a provider refusal, its windows' resets); `null` when it cannot grow or that
59
+ * moment is unknown (a stale reading, a sign-in or payment problem).
60
+ */
61
+ growsAt: string | null;
62
+ /** The headroom it adds from `growsAt` on, at most; `null` with it. */
63
+ growsTo: number | null;
64
+ /** When the account service reads an account it cannot judge now again, when it says; `null` otherwise. */
65
+ recheckAt: string | null;
66
+ }
67
+
68
+ /** Why a pool waits: too little room, a provider 429 within the quiet period, or a proxy that has not observed it long enough. */
69
+ export type TProxyCapacityWaitReason = 'room' | 'provider-429' | 'quiet-unobserved';
70
+ export const proxyCapacityWaitReasons: readonly TProxyCapacityWaitReason[] = ['room', 'provider-429', 'quiet-unobserved'];
71
+
72
+ /**
73
+ * `open`: the pool takes new work now. `wait`: not before `until`, `seconds` from the answer's `at`; both `null` when
74
+ * the members' readings foresee no moment the room reaches the minimum.
75
+ */
76
+ export type TProxyCapacityVerdict =
77
+ | { state: 'open' }
78
+ | { state: 'wait'; reason: TProxyCapacityWaitReason; until: string; seconds: number }
79
+ | { state: 'wait'; reason: TProxyCapacityWaitReason; until: null; seconds: null };
80
+
81
+ export interface IProxyCapacityPool {
82
+ provider: TProxyCapacityProvider;
83
+ minHeadroom: number;
84
+ /** The members' headroom summed, in percent. */
85
+ room: number;
86
+ members: IProxyCapacityMember[];
87
+ /** The newest provider 429 on a member the proxy saw since `observedSince`, or `null`. */
88
+ last429At: string | null;
89
+ verdict: TProxyCapacityVerdict;
90
+ }
91
+
92
+ export interface IProxyCapacityAnswer {
93
+ /** When the proxy judged it, by its own clock. */
94
+ at: string;
95
+ /** Since when the proxy observes its pools' provider 429s: its start. */
96
+ observedSince: string;
97
+ pools: IProxyCapacityPool[];
98
+ }
99
+
100
+ /** At most this many members a pool lists (the proxy routes a pool of at most 64 accounts per request). */
101
+ const maximumMembers = 256;
102
+
103
+ const isRecord = (valueArg: unknown): valueArg is Record<string, unknown> =>
104
+ typeof valueArg === 'object' && valueArg !== null && !Array.isArray(valueArg);
105
+ const hasExactKeys = (valueArg: Record<string, unknown>, requiredArg: readonly string[],
106
+ optionalArg: readonly string[] = []): boolean => requiredArg.every((keyArg) => Object.hasOwn(valueArg, keyArg))
107
+ && Object.keys(valueArg).every((keyArg) => requiredArg.includes(keyArg) || optionalArg.includes(keyArg));
108
+ const isTime = (valueArg: unknown): valueArg is string => typeof valueArg === 'string' && valueArg.length <= 32
109
+ && Number.isFinite(Date.parse(valueArg));
110
+ const isTimeOrNull = (valueArg: unknown): boolean => valueArg === null || isTime(valueArg);
111
+ const isPercent = (valueArg: unknown): valueArg is number => typeof valueArg === 'number' && Number.isFinite(valueArg);
112
+ const isMinimum = (valueArg: unknown): valueArg is number => typeof valueArg === 'number' && Number.isSafeInteger(valueArg)
113
+ && valueArg >= 0;
114
+
115
+ /** Whether a value is a capacity request as `IProxyCapacityRequest` states it, and nothing else. */
116
+ export const isProxyCapacityRequest = (valueArg: unknown): valueArg is IProxyCapacityRequest => isRecord(valueArg)
117
+ && hasExactKeys(valueArg, [], ['provider', 'minHeadroom'])
118
+ && (valueArg.provider === undefined || proxyCapacityProviders.includes(valueArg.provider as TProxyCapacityProvider))
119
+ && (valueArg.minHeadroom === undefined || isMinimum(valueArg.minHeadroom));
120
+
121
+ const isWindow = (valueArg: unknown): boolean => isRecord(valueArg)
122
+ && hasExactKeys(valueArg, ['name', 'durationSeconds', 'usedPercent', 'estimated', 'resetAt'])
123
+ && typeof valueArg.name === 'string' && valueArg.name.length <= 128
124
+ && isPercent(valueArg.durationSeconds) && isPercent(valueArg.usedPercent) && typeof valueArg.estimated === 'boolean'
125
+ && isTimeOrNull(valueArg.resetAt);
126
+
127
+ const isMember = (valueArg: unknown): boolean => isRecord(valueArg)
128
+ && hasExactKeys(valueArg, ['accountId', 'plan', 'state', 'headroom', 'binding', 'growsAt', 'growsTo', 'recheckAt'])
129
+ && typeof valueArg.accountId === 'string' && /^[a-f0-9]{64}$/.test(valueArg.accountId)
130
+ && typeof valueArg.plan === 'string' && valueArg.plan.length > 0 && valueArg.plan.length <= 128
131
+ && proxyCapacityMemberStates.includes(valueArg.state as TProxyCapacityMemberState)
132
+ && isPercent(valueArg.headroom) && valueArg.headroom >= 0
133
+ && (valueArg.binding === null || isWindow(valueArg.binding))
134
+ && isTimeOrNull(valueArg.growsAt) && (valueArg.growsAt === null) === (valueArg.growsTo === null)
135
+ && (valueArg.growsTo === null || isPercent(valueArg.growsTo))
136
+ && isTimeOrNull(valueArg.recheckAt);
137
+
138
+ const isVerdict = (valueArg: unknown): boolean => {
139
+ if (!isRecord(valueArg)) return false;
140
+ if (valueArg.state === 'open') return hasExactKeys(valueArg, ['state']);
141
+ return valueArg.state === 'wait' && hasExactKeys(valueArg, ['state', 'reason', 'until', 'seconds'])
142
+ && proxyCapacityWaitReasons.includes(valueArg.reason as TProxyCapacityWaitReason)
143
+ && (valueArg.until === null
144
+ ? valueArg.seconds === null
145
+ : isTime(valueArg.until) && typeof valueArg.seconds === 'number' && Number.isSafeInteger(valueArg.seconds)
146
+ && valueArg.seconds >= 0);
147
+ };
148
+
149
+ const isPool = (valueArg: unknown): boolean => isRecord(valueArg)
150
+ && hasExactKeys(valueArg, ['provider', 'minHeadroom', 'room', 'members', 'last429At', 'verdict'])
151
+ && proxyCapacityProviders.includes(valueArg.provider as TProxyCapacityProvider)
152
+ && isMinimum(valueArg.minHeadroom) && isPercent(valueArg.room) && valueArg.room >= 0
153
+ && Array.isArray(valueArg.members) && valueArg.members.length <= maximumMembers && valueArg.members.every(isMember)
154
+ && isTimeOrNull(valueArg.last429At) && isVerdict(valueArg.verdict);
155
+
156
+ /** Whether a value is a capacity answer as `IProxyCapacityAnswer` states it, and nothing else. */
157
+ export const isProxyCapacityAnswer = (valueArg: unknown): valueArg is IProxyCapacityAnswer => isRecord(valueArg)
158
+ && hasExactKeys(valueArg, ['at', 'observedSince', 'pools'])
159
+ && isTime(valueArg.at) && isTime(valueArg.observedSince)
160
+ && Array.isArray(valueArg.pools) && valueArg.pools.length >= 1 && valueArg.pools.length <= proxyCapacityProviders.length
161
+ && valueArg.pools.every(isPool)
162
+ && new Set(valueArg.pools.map((poolArg) => (poolArg as IProxyCapacityPool).provider)).size === valueArg.pools.length;
@@ -201,6 +201,9 @@ export const isControllerSpendLimitMicroUsd = plugins.authswitchSpend.isAuthSwit
201
201
  /** The range of a spend limit, in micro-dollars. */
202
202
  export const controllerSpendLimitRange = plugins.authswitchSpend.authSwitchSpendLimitRange;
203
203
 
204
+ /** The renewal anchor rule of the accounts service (`IReq_ControllerAccountsRenewal`); a past date and time is valid. */
205
+ export const isControllerRenewsAt = plugins.authswitchRenewal.isAuthSwitchRenewsAt;
206
+
204
207
  /** The longest API key the accounts service holds, in characters; a longer value is refused before it is sent. */
205
208
  export const controllerApiKeyMaxLength = 512;
206
209
 
@@ -251,6 +254,23 @@ export interface IReq_ControllerAccountsClaudeCode extends plugins.typedrequestI
251
254
  response: { answer: TControllerAccountsAnswer<TControllerAccount> };
252
255
  }
253
256
 
257
+ /**
258
+ * Sets the anchor of a Claude sign-in's monthly renewal (AGL-1644), or clears it with `null`: any date and time the
259
+ * subscription renewed or renews, a past one too, by the accounts service's rule (`isControllerRenewsAt`). AGL's
260
+ * inference proxy then spends first the usage a window would still hold at the next renewal. `expectedRevision` is
261
+ * the revision the view showed, so a change of an account that changed meanwhile is refused as `account_changed`, and a
262
+ * value that breaks the rule, or an account other than a Claude sign-in, as `invalid_input`, both by the service. The
263
+ * answer arrives only once the projection shows the result.
264
+ */
265
+ export interface IReq_ControllerAccountsRenewal extends plugins.typedrequestInterfaces.implementsTR<
266
+ plugins.typedrequestInterfaces.ITypedRequest,
267
+ IReq_ControllerAccountsRenewal
268
+ > {
269
+ method: 'controller.accounts.renewal';
270
+ request: { accountId: string; expectedRevision: number; renewsAt: string | null };
271
+ response: { answer: TControllerAccountsAnswer<TControllerAccount> };
272
+ }
273
+
254
274
  /** Duration validation shared with the authority; no implicit duration is supplied. */
255
275
  export const isControllerReserveLiftHours = plugins.authswitchAuthority.isAuthSwitchReserveLiftHours;
256
276
 
@@ -32,6 +32,7 @@ import type {
32
32
  IReq_ControllerAccountsApiKeyAdd,
33
33
  IReq_ControllerAccountsSpendLimit,
34
34
  IReq_ControllerAccountsClaudeCode,
35
+ IReq_ControllerAccountsRenewal,
35
36
  IReq_ControllerAccountsSnapshot,
36
37
  IReq_ControllerAccountsUsageGet,
37
38
  IReq_ControllerAccountsUsageRecheck,
@@ -59,6 +60,7 @@ import type {
59
60
  } from './requests.fleetworkers.js';
60
61
  import type { IReq_ControllerDirectReportAdopt, IReq_ControllerDirectReportAppoint, IReq_ControllerDirectReportPreflight, IReq_ControllerDirectReportList, IReq_ControllerDirectReportMessage, IReq_ControllerDirectReportRead } from './requests.directreports.js';
61
62
  import type { IReq_ControllerSessionFeedAcknowledge, IReq_ControllerSessionFeedList } from './sessionfeed.js';
63
+ import type { IReq_ControllerInboxList } from './inbox.js';
62
64
  import type { TControllerDeployTypedRequest } from './deployments.js';
63
65
  import type {
64
66
  IReq_ControllerNativeSessionAuxiliaryGet,
@@ -410,6 +412,7 @@ export type TControllerRequest =
410
412
  | IReq_ControllerAccountsApiKeyAdd
411
413
  | IReq_ControllerAccountsSpendLimit
412
414
  | IReq_ControllerAccountsClaudeCode
415
+ | IReq_ControllerAccountsRenewal
413
416
  | IReq_ControllerAccountsRemove
414
417
  | IReq_ControllerAccountsAdd
415
418
  | IReq_ControllerAccountsReauth
@@ -435,6 +438,7 @@ export type TControllerRequest =
435
438
  | IReq_ControllerDevicesPairingBegin
436
439
  | IReq_ControllerDevicesPairingCancel
437
440
  | IReq_ControllerDevicesRevoke
441
+ | IReq_ControllerInboxList
438
442
  | import('./requests.tickets.js').TControllerTicketTypedRequest
439
443
  | IReq_ControllerEvent
440
444
  | IReq_ControllerSessionChildEvent;
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '43.1.0',
6
+ version: '43.3.0',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }
@@ -13,9 +13,11 @@ import * as authswitchUsageLimit from '../ts_authswitch/authority-usagelimit.js'
13
13
  import * as authswitchSubscription from '../ts_authswitch/authority-subscription.js';
14
14
  // An API key's month: the spend limit rule and dollar amounts, as the command line states them; it imports nothing.
15
15
  import * as authswitchSpend from '../ts_authswitch/authority-spend.js';
16
+ // A Claude sign-in's monthly renewal: its next one, rolled forward as placement rolls it; it imports nothing.
17
+ import * as authswitchRenewal from '../ts_authswitch/authority-renewal.js';
16
18
  // The service's contract, which the controller's interfaces load already: the processes holding a Claude sign-in, in
17
19
  // the words the command line uses.
18
20
  import * as authswitchAuthority from '../ts_authswitch/authority-contract.js';
19
21
 
20
- export { authswitchAuthority, authswitchPreuseText, authswitchSpend, authswitchSubscription, authswitchUsageLimit,
21
- authswitchUsageWindows };
22
+ export { authswitchAuthority, authswitchPreuseText, authswitchRenewal, authswitchSpend, authswitchSubscription,
23
+ authswitchUsageLimit, authswitchUsageWindows };
@@ -147,6 +147,8 @@ export type TAccountActionId =
147
147
  | 'spendLimit'
148
148
  | 'clearSpendLimit'
149
149
  | 'claudeCode'
150
+ | 'renewal'
151
+ | 'clearRenewal'
150
152
  | 'addApiKey'
151
153
  | 'remove'
152
154
  | 'usage'
@@ -356,6 +358,11 @@ export interface IAccountRow {
356
358
  spendLimitMicroUsd: number | null;
357
359
  /** Whether the account may serve Claude Code (AGL-1146); always `true` for a sign-in. */
358
360
  claudeCode: boolean;
361
+ /**
362
+ * The anchor of a Claude sign-in's monthly renewal as its owner set it (ISO 8601 UTC, AGL-1644), or `null` without
363
+ * one and for every other account.
364
+ */
365
+ renewsAt: string | null;
359
366
  /** What a removal does that the owner must know, said with the removal; empty for a sign-in. */
360
367
  removeNote: string;
361
368
  label: string;
@@ -1353,6 +1360,27 @@ const identityText = (emailArg: string | null | undefined, planArg: string | nul
1353
1360
  `${emailArg || 'No email reported'} · ${planArg ? `${planArg} plan` : 'plan not reported'}`
1354
1361
  );
1355
1362
 
1363
+ /**
1364
+ * What the Details say of a Claude sign-in's renewal: the next one, rolled forward from the anchor its owner set as
1365
+ * placement rolls it, or that none is set. AGL derives no renewal from what Claude states.
1366
+ */
1367
+ export const renewalFact = (renewsAtArg: string | null, nowArg: number): string => {
1368
+ const renewal = plugins.authswitchRenewal.authSwitchRenewal(renewsAtArg, nowArg);
1369
+ return renewal === null ? 'Not set'
1370
+ : `${plugins.authswitchPreuseText.localDateTime(renewal.at)}, monthly (set by you)`;
1371
+ };
1372
+
1373
+ /**
1374
+ * Why a renewal draft cannot be saved yet, or `''` when it can: a date and time the service's own rule reads, other
1375
+ * than the renewal the account has. A past one is valid: the next renewal is a whole number of months after it.
1376
+ */
1377
+ export const renewalReason = (draftArg: string, currentArg: string | null): string => {
1378
+ const draft = draftArg.trim();
1379
+ if (draft.length === 0) return 'Enter a date and time.';
1380
+ if (!interfaces.isControllerRenewsAt(draft)) return 'Enter a date and time, year first, such as 2026-11-20 09:30.';
1381
+ return currentArg !== null && Date.parse(draft) === Date.parse(currentArg) ? 'The renewal is unchanged.' : '';
1382
+ };
1383
+
1356
1384
  /** What the Details say of an account's usage threshold. */
1357
1385
  const maxUsageFact = (maxUsagePercentArg: number | null): string => maxUsagePercentArg === null
1358
1386
  ? 'Not set'
@@ -1530,6 +1558,7 @@ const serviceRow = (
1530
1558
  const payment = accountArg.removed || usageRead?.state !== 'read' ? null
1531
1559
  : paymentView(accountArg, usageRead.usage, contextArg.now);
1532
1560
  const apiKey = isApiKeyAccount(accountArg);
1561
+ const claudeSignIn = !apiKey && accountArg.providerId === 'anthropic';
1533
1562
  const provider = keyProvider(accountArg.providerId);
1534
1563
  const identity = apiKey ? keyIdentityText(accountArg) : identityText(accountArg.email, accountArg.plan);
1535
1564
  const liftedUntil = !accountArg.removed && accountArg.maxUsagePercent !== null
@@ -1545,6 +1574,7 @@ const serviceRow = (
1545
1574
  apiKey,
1546
1575
  spendLimitMicroUsd: apiKey ? accountArg.spendLimitMicroUsd : null,
1547
1576
  claudeCode: accountArg.claudeCode,
1577
+ renewsAt: claudeSignIn ? accountArg.renewsAt : null,
1548
1578
  removeNote: apiKey
1549
1579
  ? `AGL stops using the key. It stays valid at ${provider.name} until you revoke it in ${provider.console}.`
1550
1580
  : '',
@@ -1599,6 +1629,8 @@ const serviceRow = (
1599
1629
  : [serviceSlot('maxUsage', 'Max usage', 'lucide:SlidersHorizontal', contextArg.service, removed)]),
1600
1630
  ...(!apiKey && accountArg.maxUsagePercent !== null && accountArg.maxUsagePercent < 100
1601
1631
  ? [serviceSlot('liftReserve', 'Lift reserve', 'lucide:Clock', contextArg.service, removed)] : []),
1632
+ // A renewal is a Claude subscription's: neither a key nor a ChatGPT account has one to set.
1633
+ ...(claudeSignIn ? [serviceSlot('renewal', 'Renewal', 'lucide:CalendarClock', contextArg.service, removed)] : []),
1602
1634
  serviceSlot('remove', 'Remove', 'lucide:Trash2', contextArg.service, removed),
1603
1635
  ...(usageLogin ? [serviceSlot('usage', 'Show latest usage', 'lucide:Gauge', contextArg.service)] : []),
1604
1636
  ...(usageLogin && payment ? [serviceSlot('recheck', 'Re-check', 'lucide:RotateCcw', contextArg.service)] : []),
@@ -1616,6 +1648,7 @@ const serviceRow = (
1616
1648
  apiKey ? { label: 'Monthly spend limit', value: spendLimitText(accountArg.spendLimitMicroUsd) }
1617
1649
  : { label: 'Max usage', value: maxUsageFact(accountArg.maxUsagePercent) },
1618
1650
  ...(apiKey ? [{ label: 'Claude Code', value: claudeCodeText(accountArg.claudeCode) }] : []),
1651
+ ...(claudeSignIn ? [{ label: 'Renews', value: renewalFact(accountArg.renewsAt, contextArg.now) }] : []),
1619
1652
  { label: 'Account reference', value: accountArg.id },
1620
1653
  ],
1621
1654
  accountId: accountArg.id,
@@ -11,6 +11,8 @@ type TPaintOpen = interfaces.IReq_ControllerBrowserPaintOpen['response'];
11
11
 
12
12
  /** Original-video route requests kept while a Paint stream is still opening; it binds at most four. */
13
13
  const maximumPendingVideoRoutes = 4;
14
+ /** The operation a failed original-video route of the run on screen reports. */
15
+ const pageVideoOperation = 'Show the page\'s video in Paint';
14
16
 
15
17
  /** The controller requests this presentation issues, with the socket client's fire options. */
16
18
  export interface IBrowserPresentationSocket {
@@ -214,7 +216,7 @@ export class ControllerBrowserPresentation {
214
216
  const paint = this.paint;
215
217
  if (paint && paint.response.paintId === eventArg.paintId) {
216
218
  void this.openVideoRoute(paint, eventArg.routeId).catch((errorArg) => {
217
- if (this.paint === paint) this.options.onError('Show the browser view\'s video', errorArg);
219
+ if (this.isCurrentPaint(paint)) this.options.onError(pageVideoOperation, errorArg);
218
220
  });
219
221
  return;
220
222
  }
@@ -330,7 +332,7 @@ export class ControllerBrowserPresentation {
330
332
  for (const pending of this.pendingVideoRoutes.splice(0)) {
331
333
  if (pending.paintId === opened.paintId) {
332
334
  void this.openVideoRoute(paint, pending.routeId).catch((errorArg) => {
333
- if (this.paint === paint) this.options.onError('Show the browser view\'s video', errorArg);
335
+ if (this.isCurrentPaint(paint)) this.options.onError(pageVideoOperation, errorArg);
334
336
  });
335
337
  }
336
338
  }
@@ -384,7 +386,15 @@ export class ControllerBrowserPresentation {
384
386
  if (failure !== undefined) this.fallBackToVideo({ kind: 'viewer-cannot-render', failure });
385
387
  }
386
388
 
389
+ /** Whether `paintArg` is the run this view presents: a stopping, replaced or closed run is not. */
390
+ private isCurrentPaint(paintArg: IPaintRun): boolean {
391
+ return this.paint === paintArg && !this.closed;
392
+ }
393
+
387
394
  private async stopPaint(paintArg: IPaintRun): Promise<void> {
395
+ // The run stops being current before its abort listeners run: they fire synchronously, and
396
+ // what they end belongs to the stopping run, never to the view.
397
+ if (this.paint === paintArg) this.paint = undefined;
388
398
  paintArg.abortController.abort(new Error('The Paint stream closed.'));
389
399
  paintArg.removeSessionEnd();
390
400
  this.closeVideoRoutes(paintArg);
@@ -392,7 +402,6 @@ export class ControllerBrowserPresentation {
392
402
  // Closes the controller's Paint stream exactly once and stops the renderer.
393
403
  await paintArg.presenter.close();
394
404
  } finally {
395
- if (this.paint === paintArg) this.paint = undefined;
396
405
  this.clearRenderer(paintArg.renderer);
397
406
  }
398
407
  }
@@ -427,10 +436,14 @@ export class ControllerBrowserPresentation {
427
436
  // The host ended the route on purpose (a source rebind or a closed subscription): the worker
428
437
  // keeps running and the next route mounts on it.
429
438
  onEnded: () => { paintArg.routes.delete(mount); },
430
- // A broken route closes only its own decoders; the renderer keeps running.
431
- onFailure: (errorArg) => {
439
+ // A broken route closes only its own decoders; the renderer keeps running. A route of a
440
+ // stopping, replaced or closed run is not this view's fault. Every reason of the run on
441
+ // screen is reported: SmartBrowser never reports this view's own close of a route (its
442
+ // abort signal or `close()`), so `fenced` is the host's revocation or a pair broken
443
+ // underneath it, `protocol` a broken route and `worker` a failed worker request.
444
+ onFailure: (errorArg: plugins.PaintVideoRouteError) => {
432
445
  paintArg.routes.delete(mount);
433
- this.options.onError('Show the browser view\'s video', errorArg);
446
+ if (this.isCurrentPaint(paintArg)) this.options.onError(pageVideoOperation, errorArg);
434
447
  },
435
448
  });
436
449
  paintArg.routes.add(mount);