agl 43.0.5 → 43.2.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 (216) hide show
  1. package/changelog.md +30 -0
  2. package/dist_serve/bundle.js +5996 -5280
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_serve/bundle.js.third-party-notices.json +30 -30
  5. package/dist_serve/bundle.js.third-party-notices.txt +30 -30
  6. package/dist_serve/third-party-notices.md +1 -1
  7. package/dist_ts/00_commitinfo_data.js +1 -1
  8. package/dist_ts/aglapi/aglapisurface.document.js +805 -10
  9. package/dist_ts/aglapi/interfaces.d.ts +13 -0
  10. package/dist_ts/aglapi/interfaces.js +4 -1
  11. package/dist_ts/classes.authmodels.js +17 -4
  12. package/dist_ts/classes.authstore.js +16 -2
  13. package/dist_ts/classes.claudeharness.d.ts +14 -5
  14. package/dist_ts/classes.claudeharness.js +62 -2
  15. package/dist_ts/classes.cli.d.ts +4 -2
  16. package/dist_ts/classes.cli.js +6 -3
  17. package/dist_ts/classes.codexclientadapter.d.ts +7 -5
  18. package/dist_ts/classes.codexclientadapter.js +38 -3
  19. package/dist_ts/classes.controller.d.ts +19 -2
  20. package/dist_ts/classes.controller.js +234 -27
  21. package/dist_ts/classes.controllermanagement.d.ts +14 -4
  22. package/dist_ts/classes.controllermanagement.js +20 -2
  23. package/dist_ts/classes.gatewayclient.d.ts +115 -0
  24. package/dist_ts/classes.gatewayclient.js +336 -0
  25. package/dist_ts/classes.gatewayclientstore.d.ts +97 -0
  26. package/dist_ts/classes.gatewayclientstore.js +261 -0
  27. package/dist_ts/classes.inferencegateway.d.ts +8 -5
  28. package/dist_ts/classes.inferencegateway.js +62 -19
  29. package/dist_ts/classes.inferencerouter.d.ts +9 -0
  30. package/dist_ts/classes.inferencerouter.js +11 -1
  31. package/dist_ts/classes.inferenceservice.d.ts +9 -0
  32. package/dist_ts/classes.inferenceservice.js +27 -1
  33. package/dist_ts/classes.inferencespend.d.ts +9 -3
  34. package/dist_ts/classes.inferencespend.js +44 -16
  35. package/dist_ts/classes.mcpclient.d.ts +9 -4
  36. package/dist_ts/classes.mcpclient.js +24 -2
  37. package/dist_ts/classes.mcpcontrollerhost.d.ts +3 -1
  38. package/dist_ts/classes.mcpcontrollerhost.js +13 -1
  39. package/dist_ts/classes.mcptools.d.ts +3 -3
  40. package/dist_ts/classes.mcptools.js +42 -4
  41. package/dist_ts/classes.mcpvalidation.js +7 -1
  42. package/dist_ts/classes.opencodeclient.js +3 -1
  43. package/dist_ts/classes.proxycontrol.d.ts +33 -11
  44. package/dist_ts/classes.proxycontrol.js +12 -3
  45. package/dist_ts/classes.proxycontrolclient.d.ts +23 -5
  46. package/dist_ts/classes.proxycontrolclient.js +42 -6
  47. package/dist_ts/classes.proxydaemon.d.ts +8 -6
  48. package/dist_ts/classes.proxydaemon.js +42 -21
  49. package/dist_ts/classes.proxyleaseholder.d.ts +12 -4
  50. package/dist_ts/classes.proxyleaseholder.js +39 -9
  51. package/dist_ts/classes.proxymonitor.d.ts +7 -0
  52. package/dist_ts/classes.proxymonitor.js +13 -1
  53. package/dist_ts/classes.proxystore.d.ts +4 -3
  54. package/dist_ts/classes.proxystore.js +17 -7
  55. package/dist_ts/classes.sessionfeed.d.ts +1 -1
  56. package/dist_ts/classes.trustedproxysecrets.d.ts +2 -0
  57. package/dist_ts/classes.trustedproxysecrets.js +5 -1
  58. package/dist_ts/classes.validation.d.ts +7 -0
  59. package/dist_ts/classes.validation.js +49 -2
  60. package/dist_ts/driver/functions.drivertools.js +2 -2
  61. package/dist_ts/fleet/classes.codexworkers.d.ts +4 -11
  62. package/dist_ts/fleet/classes.codexworkers.js +6 -3
  63. package/dist_ts/fleet/classes.workers.d.ts +25 -13
  64. package/dist_ts/fleet/classes.workers.js +105 -9
  65. package/dist_ts/fleet/functions.workervalidation.d.ts +26 -1
  66. package/dist_ts/fleet/functions.workervalidation.js +40 -11
  67. package/dist_ts/fleet/interfaces.workers.d.ts +17 -11
  68. package/dist_ts/fleet/interfaces.workers.js +10 -1
  69. package/dist_ts/functions.confinedrelay.d.ts +21 -0
  70. package/dist_ts/functions.confinedrelay.js +65 -0
  71. package/dist_ts/functions.controllermanagementsurface.d.ts +4 -0
  72. package/dist_ts/functions.controllermanagementsurface.js +15 -1
  73. package/dist_ts/functions.deviceapi.d.ts +4 -2
  74. package/dist_ts/functions.deviceapi.js +20 -2
  75. package/dist_ts/functions.elicitation.d.ts +49 -0
  76. package/dist_ts/functions.elicitation.js +418 -0
  77. package/dist_ts/functions.gatewaycli.d.ts +24 -0
  78. package/dist_ts/functions.gatewaycli.js +395 -0
  79. package/dist_ts/functions.gatewayroute.d.ts +135 -0
  80. package/dist_ts/functions.gatewayroute.js +366 -0
  81. package/dist_ts/functions.inferencecli.d.ts +3 -3
  82. package/dist_ts/functions.inferencecli.js +62 -10
  83. package/dist_ts/functions.inferencecliarguments.d.ts +9 -2
  84. package/dist_ts/functions.inferencecliarguments.js +59 -10
  85. package/dist_ts/functions.inferencelaunch.d.ts +35 -7
  86. package/dist_ts/functions.inferencelaunch.js +143 -16
  87. package/dist_ts/functions.mcpfleetworkertools.d.ts +63 -70
  88. package/dist_ts/functions.mcpfleetworkertools.js +32 -4
  89. package/dist_ts/functions.proxycapacity.d.ts +50 -0
  90. package/dist_ts/functions.proxycapacity.js +142 -0
  91. package/dist_ts/functions.proxycapacitycli.d.ts +30 -0
  92. package/dist_ts/functions.proxycapacitycli.js +65 -0
  93. package/dist_ts/functions.proxycontract.d.ts +21 -4
  94. package/dist_ts/functions.proxycontract.js +12 -5
  95. package/dist_ts/functions.proxyharnessconfig.d.ts +7 -0
  96. package/dist_ts/functions.proxyharnessconfig.js +11 -1
  97. package/dist_ts/functions.remotecli.d.ts +30 -3
  98. package/dist_ts/functions.remotecli.js +44 -18
  99. package/dist_ts/interfaces.auth.d.ts +25 -4
  100. package/dist_ts/interfaces.auth.js +8 -1
  101. package/dist_ts/plugins.d.ts +2 -0
  102. package/dist_ts/plugins.js +4 -1
  103. package/dist_ts_authswitch/authority-placement.js +3 -17
  104. package/dist_ts_authswitch/authority-usagelimit.d.ts +29 -0
  105. package/dist_ts_authswitch/authority-usagelimit.js +66 -2
  106. package/dist_ts_authswitch/authority-usagewindows.d.ts +6 -0
  107. package/dist_ts_authswitch/authority-usagewindows.js +15 -1
  108. package/dist_ts_interfaces/devices.d.ts +133 -3
  109. package/dist_ts_interfaces/devices.js +3 -2
  110. package/dist_ts_interfaces/elicitations.d.ts +125 -0
  111. package/dist_ts_interfaces/elicitations.js +7 -0
  112. package/dist_ts_interfaces/fleetworkers.d.ts +119 -5
  113. package/dist_ts_interfaces/fleetworkers.js +14 -2
  114. package/dist_ts_interfaces/gateway.d.ts +151 -0
  115. package/dist_ts_interfaces/gateway.js +66 -0
  116. package/dist_ts_interfaces/index.d.ts +3 -0
  117. package/dist_ts_interfaces/index.js +4 -1
  118. package/dist_ts_interfaces/interfaces.d.ts +3 -1
  119. package/dist_ts_interfaces/interfaces.js +2 -2
  120. package/dist_ts_interfaces/management.d.ts +4 -4
  121. package/dist_ts_interfaces/management.js +3 -2
  122. package/dist_ts_interfaces/mcprequests.d.ts +18 -2
  123. package/dist_ts_interfaces/mcprequests.js +3 -1
  124. package/dist_ts_interfaces/nativesessions.d.ts +14 -0
  125. package/dist_ts_interfaces/proxycapacity.d.ts +99 -0
  126. package/dist_ts_interfaces/proxycapacity.js +74 -0
  127. package/dist_ts_interfaces/requests.d.ts +3 -3
  128. package/dist_ts_interfaces/requests.fleetworkers.js +2 -2
  129. package/dist_ts_interfaces/requests.js +1 -1
  130. package/dist_ts_interfaces/requests.promptreply.d.ts +18 -0
  131. package/dist_ts_interfaces/sessionfeed.d.ts +3 -2
  132. package/dist_ts_interfaces/sessionfeed.js +1 -1
  133. package/package.json +5 -4
  134. package/readme.md +267 -26
  135. package/third-party-notices.md +1 -1
  136. package/ts/00_commitinfo_data.ts +1 -1
  137. package/ts/aglapi/aglapisurface.document.ts +804 -9
  138. package/ts/aglapi/interfaces.ts +3 -0
  139. package/ts/classes.authmodels.ts +22 -3
  140. package/ts/classes.authstore.ts +15 -1
  141. package/ts/classes.claudeharness.ts +80 -9
  142. package/ts/classes.cli.ts +7 -3
  143. package/ts/classes.codexclientadapter.ts +41 -5
  144. package/ts/classes.controller.ts +276 -32
  145. package/ts/classes.controllermanagement.ts +40 -7
  146. package/ts/classes.gatewayclient.ts +401 -0
  147. package/ts/classes.gatewayclientstore.ts +272 -0
  148. package/ts/classes.inferencegateway.ts +69 -23
  149. package/ts/classes.inferencerouter.ts +12 -0
  150. package/ts/classes.inferenceservice.ts +27 -0
  151. package/ts/classes.inferencespend.ts +46 -13
  152. package/ts/classes.mcpclient.ts +26 -4
  153. package/ts/classes.mcpcontrollerhost.ts +17 -0
  154. package/ts/classes.mcptools.ts +47 -5
  155. package/ts/classes.mcpvalidation.ts +5 -0
  156. package/ts/classes.opencodeclient.ts +2 -0
  157. package/ts/classes.proxycontrol.ts +43 -13
  158. package/ts/classes.proxycontrolclient.ts +39 -6
  159. package/ts/classes.proxydaemon.ts +57 -27
  160. package/ts/classes.proxyleaseholder.ts +43 -11
  161. package/ts/classes.proxymonitor.ts +12 -0
  162. package/ts/classes.proxystore.ts +21 -8
  163. package/ts/classes.sessionfeed.ts +1 -1
  164. package/ts/classes.trustedproxysecrets.ts +5 -0
  165. package/ts/classes.validation.ts +52 -0
  166. package/ts/driver/functions.drivertools.ts +1 -1
  167. package/ts/fleet/classes.codexworkers.ts +8 -6
  168. package/ts/fleet/classes.workers.ts +101 -17
  169. package/ts/fleet/functions.workervalidation.ts +35 -9
  170. package/ts/fleet/interfaces.workers.ts +11 -4
  171. package/ts/functions.confinedrelay.ts +65 -0
  172. package/ts/functions.controllermanagementsurface.ts +15 -0
  173. package/ts/functions.deviceapi.ts +24 -1
  174. package/ts/functions.elicitation.ts +443 -0
  175. package/ts/functions.gatewaycli.ts +436 -0
  176. package/ts/functions.gatewayroute.ts +429 -0
  177. package/ts/functions.inferencecli.ts +62 -13
  178. package/ts/functions.inferencecliarguments.ts +56 -9
  179. package/ts/functions.inferencelaunch.ts +143 -16
  180. package/ts/functions.mcpfleetworkertools.ts +34 -4
  181. package/ts/functions.proxycapacity.ts +191 -0
  182. package/ts/functions.proxycapacitycli.ts +104 -0
  183. package/ts/functions.proxycontract.ts +17 -4
  184. package/ts/functions.proxyharnessconfig.ts +11 -0
  185. package/ts/functions.remotecli.ts +56 -20
  186. package/ts/interfaces.auth.ts +29 -4
  187. package/ts/plugins.ts +5 -0
  188. package/ts_authswitch/authority-placement.ts +2 -15
  189. package/ts_authswitch/authority-usagelimit.ts +84 -1
  190. package/ts_authswitch/authority-usagewindows.ts +13 -0
  191. package/ts_interfaces/devices.schema.json +476 -2
  192. package/ts_interfaces/devices.ts +146 -2
  193. package/ts_interfaces/elicitations.ts +148 -0
  194. package/ts_interfaces/fleetworkers.ts +96 -4
  195. package/ts_interfaces/gateway.ts +242 -0
  196. package/ts_interfaces/index.ts +3 -0
  197. package/ts_interfaces/interfaces.ts +3 -1
  198. package/ts_interfaces/management.ts +6 -4
  199. package/ts_interfaces/mcprequests.ts +19 -0
  200. package/ts_interfaces/nativesessions.ts +16 -0
  201. package/ts_interfaces/proxycapacity.ts +162 -0
  202. package/ts_interfaces/requests.fleetworkers.ts +1 -1
  203. package/ts_interfaces/requests.promptreply.ts +22 -0
  204. package/ts_interfaces/requests.ts +4 -0
  205. package/ts_interfaces/sessionfeed.ts +3 -2
  206. package/ts_web/00_commitinfo_data.ts +1 -1
  207. package/ts_web/classes.browserpresentation.ts +13 -5
  208. package/ts_web/classes.elicitationcards.ts +106 -0
  209. package/ts_web/classes.nativesessionstate.ts +38 -1
  210. package/ts_web/elements.accounts.ts +40 -113
  211. package/ts_web/elements.configurationpane.ts +24 -37
  212. package/ts_web/elements.devices.ts +4 -17
  213. package/ts_web/elements.fleetworker.ts +27 -2
  214. package/ts_web/elements.flexlimitstrip.ts +21 -70
  215. package/ts_web/elements.harnesscontrollerapp.ts +159 -186
  216. package/ts_web/functions.sessionchat.ts +5 -0
@@ -1,14 +1,14 @@
1
1
  import { flexMessageDeliveryProof, type TFlexDeliveryEvidence, type TFlexDeliveryProof } from './functions.flexdeliveryproof.js';
2
2
  import { FleetWorkers, fleetNativeSessionNames } from './fleet/classes.workers.js';
3
3
  import { FleetTicketEffects } from './fleet/classes.ticketeffects.js';
4
- import { FleetDispatchError } from './fleet/interfaces.workers.js';
4
+ import { FleetDispatchError, FleetWorkerError } from './fleet/interfaces.workers.js';
5
5
  import type { TFleetWorkerAction, TFleetWorkerRequest } from '../ts_interfaces/fleetworkers.js';
6
6
  import { ControllerBrowserOperationAuthority } from './classes.browseroperationauthority.js';
7
7
  import { ControllerWorkerCallers, type IWorkerCodexCallerOrigin } from './classes.workercallers.js';
8
8
  import { WorkerCallerBindingStore } from './classes.workercallerbindings.js';
9
9
  import { FleetWorkerLaunches } from './fleet/classes.workerlaunches.js';
10
10
  import { workerCallerEnrollmentToolName } from './classes.mcpworkercaller.js';
11
- import { readWorkerProcessSnapshot, readWorkerUnixSocketOwner, workerSnapshotsEqual, isWorkerCallerProofRefusal, type IWorkerCallerConnection } from './functions.workerprocessproof.js';
11
+ import { proveConnectionProcessAncestry, readWorkerProcessSnapshot, readWorkerUnixSocketOwner, workerSnapshotsEqual, isWorkerCallerProofRefusal, type IWorkerCallerConnection } from './functions.workerprocessproof.js';
12
12
  import { proveCliCallerClaudeSession } from './functions.cliticketsession.js';
13
13
  import type { IFleetWorkerCallerHooks, TFleetWorkerCallerLaunch } from '../ts_interfaces/workercallers.js';
14
14
  import { awaitWithAbortSignal } from './functions.abort.js';
@@ -52,7 +52,7 @@ import { AccountsActions } from './classes.accountsactions.js';
52
52
  import { AglProxyMonitor } from './classes.proxymonitor.js';
53
53
  import type { TAglProxyLeaseCatalog } from './classes.proxycontrol.js';
54
54
  import { AglProxyLeaseHolder } from './classes.proxyleaseholder.js';
55
- import { AglProxyRefusedError } from './classes.proxycontrolclient.js';
55
+ import { AglProxyOutdatedError, AglProxyRefusedError, AglProxyUnavailableError } from './classes.proxycontrolclient.js';
56
56
  import { inferenceHarnessLaunch } from './functions.inferencelaunch.js';
57
57
  import type { IControllerTerminalAgentInferenceSession } from './classes.terminalmanager.js';
58
58
  import type { TConfigurationHostClaudeLogin } from './configuration/classes.inferencereview.js';
@@ -98,12 +98,14 @@ import {
98
98
  assertDeviceRevokeRequest,
99
99
  assertDevicePermissionReplyRequest,
100
100
  assertDeviceQuestionReplyRequest,
101
+ assertDeviceElicitationReplyRequest,
101
102
  assertDeviceSessionReadRequest,
102
103
  assertDeviceSessionSendRequest,
103
104
  deviceEvent,
104
105
  deviceMessages,
105
106
  devicePermissions,
106
107
  deviceQuestions,
108
+ deviceElicitations,
107
109
  deviceRelayedEventTypes,
108
110
  deviceSessionRow,
109
111
  deviceSessionRows,
@@ -138,6 +140,7 @@ import {
138
140
  controllerMaximumMessageBundles,
139
141
  controllerMaximumTranscriptBytes,
140
142
  controllerLiveToolExecutionIsCovered,
143
+ controllerAttentionPending,
141
144
  controllerProtocolVersion,
142
145
  controllerUpgradeManagementVersion,
143
146
  controllerManagementProtocolVersion,
@@ -179,6 +182,7 @@ import {
179
182
  type IControllerProject,
180
183
  type IControllerProviderConnection,
181
184
  type IControllerQuestion,
185
+ type IControllerAttention,
182
186
  type IControllerRuntimeId,
183
187
  type IControllerSession,
184
188
  type IControllerSessionGroup,
@@ -217,6 +221,7 @@ import {
217
221
  type IReq_ControllerProviderModelRefreshGet,
218
222
  type IReq_ControllerPermissionReply,
219
223
  type IReq_ControllerQuestionReply,
224
+ type IReq_ControllerElicitationReply,
220
225
  type IReq_ControllerSessionRename,
221
226
  type IReq_ControllerSessionArchive,
222
227
  type IReq_ControllerSessionYolo,
@@ -332,6 +337,9 @@ import {
332
337
  type IReq_ControllerSetupBegin,
333
338
  type IReq_ControllerSetupFinish,
334
339
  type IReq_ControllerStatus,
340
+ type IReq_ControllerManagementStatus,
341
+ type IReq_ControllerGatewaySync,
342
+ type IControllerGatewayStatus,
335
343
  type IReq_ControllerUpgradeLaunch,
336
344
  type IReq_ControllerUpgradePrepareBegin,
337
345
  type IReq_ControllerUpgradeFinalize,
@@ -362,6 +370,7 @@ import {
362
370
  type IReq_DevicePair,
363
371
  type IReq_DevicePermissionReply,
364
372
  type IReq_DeviceQuestionReply,
373
+ type IReq_DeviceElicitationReply,
365
374
  type IReq_DeviceSessionRead,
366
375
  type IReq_DeviceSessionSend,
367
376
  type IReq_DeviceSessionsList,
@@ -388,6 +397,11 @@ import {
388
397
  import { controllerListenerOptions } from './functions.controlleradmission.js';
389
398
  import { ControllerTrustedProxySecrets } from './classes.trustedproxysecrets.js';
390
399
  import { TpmSecretCodec } from './classes.tpmsecretcodec.js';
400
+ import { ControllerGatewayClient } from './classes.gatewayclient.js';
401
+ import { ControllerGatewayClientStore } from './classes.gatewayclientstore.js';
402
+ import { gatewayRouteKey } from './functions.gatewayroute.js';
403
+ import { readManagementPeerConnection } from './functions.controllermanagementsurface.js';
404
+ import { assertConfigurationLocalCliActor } from './functions.configurationactor.js';
391
405
  import { resolveAGLHomePaths } from './classes.aglhome.js';
392
406
  import { selectControllerBrowserPaint } from './functions.browserpaintartifact.js';
393
407
  import { ControllerBrowserViewerAssets } from './functions.browserpaintassets.js';
@@ -520,6 +534,7 @@ import type {
520
534
  IReq_ControllerNativeSessionIntelligenceAsk,
521
535
  IReq_ControllerNativeSessionPermissionReply,
522
536
  IReq_ControllerNativeSessionQuestionReply,
537
+ IReq_ControllerNativeSessionElicitationReply,
523
538
  IReq_ControllerNativeSessionRead,
524
539
  IReq_ControllerNativeSessionScratchpadSave,
525
540
  IReq_ControllerNativeSessionSend,
@@ -630,6 +645,7 @@ import {
630
645
  assertProviderModelRefreshGetRequest,
631
646
  assertPermissionReplyRequest,
632
647
  assertQuestionReplyRequest,
648
+ assertElicitationReplyRequest,
633
649
  assertSessionRenameRequest,
634
650
  assertSessionArchiveRequest,
635
651
  assertSessionYoloRequest,
@@ -715,6 +731,7 @@ import {
715
731
  assertNativeSessionIntelligenceAskRequest,
716
732
  assertNativeSessionPermissionReplyRequest,
717
733
  assertNativeSessionQuestionReplyRequest,
734
+ assertNativeSessionElicitationReplyRequest,
718
735
  assertStandardProjectDirectories,
719
736
  assertSessionMessagesPageRequest,
720
737
  assertSessionMessageGetRequest,
@@ -821,7 +838,8 @@ import {
821
838
  } from './constants.upgradeenvironment.js';
822
839
  import { ControllerAgentMessageLimiter } from './classes.agentmessagelimiter.js';
823
840
  import { agentMessageSubjects, formatAgentMessage, formatOwnerFleetMessage } from './functions.agentmessage.js';
824
- import { FleetNativeTurnError } from './fleet/interfaces.workers.js';
841
+ import { FleetNativeTurnError, type TFleetNativeReply } from './fleet/interfaces.workers.js';
842
+ import { ControllerElicitationReplyError } from './functions.elicitation.js';
825
843
  import {
826
844
  isModelChoiceOffered,
827
845
  resolveFlexDefaultModel,
@@ -2416,6 +2434,16 @@ const assertNativeSessionWritable = (resolvedArg: IResolvedNativeSession): void
2416
2434
  const { readOnly } = resolvedArg.session;
2417
2435
  if (readOnly) throw new plugins.typedrequest.TypedResponseError(readOnly.message, { code: 'session_read_only' });
2418
2436
  };
2437
+ /**
2438
+ * A harness's refusal of an elicitation reply -- the answer does not fit the request, or the request is gone -- as the
2439
+ * typed refusal it is; its text never carries what the owner entered. Every other error passes as it is.
2440
+ */
2441
+ const elicitationRefusal = (errorArg: unknown): unknown => (
2442
+ errorArg instanceof ControllerElicitationReplyError
2443
+ ? new plugins.typedrequest.TypedResponseError(errorArg.message, { code: errorArg.code })
2444
+ : errorArg
2445
+ );
2446
+
2419
2447
  const validateRequest = <T>(validatorArg: () => T): T => {
2420
2448
  try {
2421
2449
  return validatorArg();
@@ -3432,6 +3460,8 @@ export class OpenCodeController {
3432
3460
  private passkeyManager?: PasskeyManager;
3433
3461
  /** TLS-proxy mode only: the secret admission accepts from the reverse proxy, and its rotation. */
3434
3462
  private trustedProxySecrets?: ControllerTrustedProxySecrets;
3463
+ /** The controller's own route on its gateway (`agl remote gateway`), synced in the background once it is ready. */
3464
+ private gatewayClient?: ControllerGatewayClient;
3435
3465
  private openCodeSupervisor?: OpenCodeSupervisor;
3436
3466
  private openCodeClient?: OpenCodeClientAdapter;
3437
3467
  private flexSupervisor?: FlexSupervisor;
@@ -5911,7 +5941,7 @@ export class OpenCodeController {
5911
5941
  if (!managed) throw new plugins.typedrequest.TypedResponseError('The Codex conversation is not managed by AGL.', { code: 'session_not_found' });
5912
5942
  const canonical = client.register(projectIdArg, directoryArg, session);
5913
5943
  this.setManagedSessionAuthority(projectIdArg, session.id, 'managed', managed.identity.sessionIdentityId);
5914
- return { ...canonical, ...(client.attention(nativeIdArg).permissions.length || client.attention(nativeIdArg).questions.length ? { attention: true } : {}) };
5944
+ return { ...canonical, ...(controllerAttentionPending(client.attention(nativeIdArg)) ? { attention: true } : {}) };
5915
5945
  }
5916
5946
 
5917
5947
  private async listManagedCodexSessions(projectIdArg: string, directoryArg: string, signalArg: AbortSignal,
@@ -6001,7 +6031,7 @@ export class OpenCodeController {
6001
6031
  await client.refreshActivity(session.id.nativeId, signalArg).catch(() => undefined);
6002
6032
  }
6003
6033
  return { ...canonical, codexActivity: client.activitySummary(session.id.nativeId),
6004
- ...(attention.permissions.length || attention.questions.length ? { attention: true } : {}) };
6034
+ ...(controllerAttentionPending(attention) ? { attention: true } : {}) };
6005
6035
  } catch (error) {
6006
6036
  if (!(error instanceof ControllerSessionIdentityError)) throw error;
6007
6037
  this.withholdRefusedListedSession(projectIdArg, session.id, error);
@@ -6028,7 +6058,7 @@ export class OpenCodeController {
6028
6058
  await client.refreshActivity(session.id.nativeId, signalArg).catch(() => undefined);
6029
6059
  }
6030
6060
  result.push({ connection: 'connected', session: { ...canonical, codexActivity: client.activitySummary(session.id.nativeId),
6031
- ...(attention.permissions.length || attention.questions.length ? { attention: true } : {}) } });
6061
+ ...(controllerAttentionPending(attention) ? { attention: true } : {}) } });
6032
6062
  }
6033
6063
  return result;
6034
6064
  }
@@ -9778,7 +9808,12 @@ export class OpenCodeController {
9778
9808
  const caller = this.mcpCaller();
9779
9809
  const reportsTo = ['start', 'adopt', 'refresh', 'move'].includes(action) && caller.subject.kind !== 'anonymous'
9780
9810
  ? await this.requireDirectReports().reportOf(owner.resourceId, ticketActorFromCaller(caller).sessionId) : undefined;
9781
- return this.requireFleetWorkers().execute(action, input as TFleetWorkerRequest<typeof action>, master.fleet ?? {}, owner.resourceId, operationSignal, actor, reportsTo);
9811
+ try {
9812
+ return await this.requireFleetWorkers().execute(action, input as TFleetWorkerRequest<typeof action>, master.fleet ?? {}, owner.resourceId, operationSignal, actor, reportsTo);
9813
+ } catch (errorArg) {
9814
+ if (errorArg instanceof FleetWorkerError) throw new plugins.typedrequest.TypedResponseError(errorArg.message, { code: errorArg.code });
9815
+ throw errorArg;
9816
+ }
9782
9817
  }),
9783
9818
  sessionFeed: {
9784
9819
  list: (request, signal) => run(signal, async () => {
@@ -9842,6 +9877,21 @@ export class OpenCodeController {
9842
9877
  throw errorArg;
9843
9878
  }
9844
9879
  }),
9880
+ // A read for every caller (AGL-1097): the answer names accounts by id alone.
9881
+ proxyCapacity: (requestArg, signalArg) => run(signalArg, async (operationSignalArg) => {
9882
+ const monitor = this.proxyMonitor;
9883
+ if (!monitor) throw new plugins.typedrequest.TypedResponseError('The AGL proxy is not running.', { code: 'proxy_unavailable' });
9884
+ try {
9885
+ return await monitor.capacity(requestArg, operationSignalArg);
9886
+ } catch (errorArg) {
9887
+ const code = errorArg instanceof AglProxyUnavailableError ? 'proxy_unavailable'
9888
+ : errorArg instanceof AglProxyOutdatedError ? 'proxy_outdated'
9889
+ : errorArg instanceof AglProxyRefusedError && errorArg.code === 'authority_unavailable' ? 'proxy_accounts_unavailable'
9890
+ : undefined;
9891
+ if (code && errorArg instanceof Error) throw new plugins.typedrequest.TypedResponseError(errorArg.message, { code });
9892
+ throw errorArg;
9893
+ }
9894
+ }),
9845
9895
  status: async (principalArg, signalArg) => run(signalArg, async () => ({
9846
9896
  status: this.statusForPrincipal(principalArg),
9847
9897
  controllerPort: controllerPortArg,
@@ -10214,6 +10264,19 @@ export class OpenCodeController {
10214
10264
  this.assertStartActive();
10215
10265
  }
10216
10266
  const trustedProxySecrets = this.trustedProxySecrets;
10267
+ // Its enrolment is read now; its first sync runs once the controller is ready, never holding up the start.
10268
+ const gatewayClient = new ControllerGatewayClient({
10269
+ store: new ControllerGatewayClientStore({
10270
+ controllerId: authDocument.id,
10271
+ issuerId: issuerIdentity.issuerId,
10272
+ codec: this.options.trustedProxySecretCodec ?? new TpmSecretCodec(),
10273
+ }),
10274
+ runtimeConfig: () => this.requireRuntimeConfig(),
10275
+ secrets: () => this.trustedProxySecrets,
10276
+ });
10277
+ this.gatewayClient = gatewayClient;
10278
+ await gatewayClient.load();
10279
+ this.assertStartActive();
10217
10280
  const publicHostname = new URL(runtimeConfig.publicOrigin).hostname;
10218
10281
  const hostnames = [...new Set([publicHostname, 'localhost', '127.0.0.1'])];
10219
10282
  const serveDirectory = plugins.path.resolve(
@@ -10772,6 +10835,7 @@ export class OpenCodeController {
10772
10835
  startupOpenCodeExitSignal,
10773
10836
  );
10774
10837
  this.lifecycleState = 'ready';
10838
+ this.gatewayClient?.start();
10775
10839
  this.requireFleetWorkers();
10776
10840
  // New Claude Code releases an earlier run recorded but did not announce are announced now, once.
10777
10841
  const harnessReleases = this.harnessReleases;
@@ -13156,6 +13220,7 @@ export class OpenCodeController {
13156
13220
  await stopPart(async () => { await this.fleetService?.close(); this.fleetService = undefined; });
13157
13221
  await stopPart(async () => { await this.boardPump?.close(); this.boardPump = undefined; });
13158
13222
  await stopPart(async () => { await this.deployMonitor?.close(); this.deployMonitor = undefined; });
13223
+ await stopPart(async () => { await this.gatewayClient?.close(); this.gatewayClient = undefined; });
13159
13224
  await stopPart(async () => { await this.ticketNotifier?.close(); this.ticketNotifier = undefined; });
13160
13225
  await stopPart(async () => { await this.sessionFeed?.close(); this.sessionFeed = undefined; });
13161
13226
  await stopPart(async () => { await this.usageFeed?.stop(); this.usageFeed = undefined; });
@@ -13878,6 +13943,7 @@ export class OpenCodeController {
13878
13943
  before: page.nextCursor ?? null,
13879
13944
  permissions: devicePermissions(detail.permissions),
13880
13945
  questions: deviceQuestions(detail.questions),
13946
+ elicitations: deviceElicitations(detail.elicitations),
13881
13947
  };
13882
13948
  }
13883
13949
  // As for a conversation, `limit` sizes older pages only; the newest page is the controller's own bound.
@@ -13891,6 +13957,7 @@ export class OpenCodeController {
13891
13957
  before: native.messagePage.nextCursor ?? null,
13892
13958
  permissions: devicePermissions(native.permissions),
13893
13959
  questions: deviceQuestions(native.questions),
13960
+ elicitations: deviceElicitations(native.elicitations),
13894
13961
  };
13895
13962
  }, toolsArg?.abortSignal);
13896
13963
  });
@@ -13963,6 +14030,30 @@ export class OpenCodeController {
13963
14030
  }, signalArg);
13964
14031
  }, toolsArg?.abortSignal);
13965
14032
  });
14033
+
14034
+ routerArg.addHandler<IReq_DeviceElicitationReply>('device.elicitation.reply', async (requestArg, toolsArg) => {
14035
+ const request = validateRequest(() => assertDeviceElicitationReplyRequest(requestArg));
14036
+ const { peer, deviceId } = this.requestDevice(toolsArg?.localData);
14037
+ return this.runDeviceOperation(peer, deviceId, async (signalArg) => {
14038
+ const auditPeerId = deviceAuditPeerId(deviceId);
14039
+ const { open } = await this.deviceSessionTarget(request.sessionId);
14040
+ if (open.kind === 'conversation') {
14041
+ return this.replyElicitationForPrincipal('device', auditPeerId, validateRequest(() => assertElicitationReplyRequest({
14042
+ projectId: open.projectId,
14043
+ sessionId: open.sessionId,
14044
+ requestId: { harnessId: open.sessionId.harnessId, nativeId: request.elicitationId },
14045
+ reply: request.reply,
14046
+ })), signalArg);
14047
+ }
14048
+ const ref = nativeSessionRefOfFeed(open);
14049
+ const native = validateRequest(() => assertNativeSessionElicitationReplyRequest({
14050
+ session: ref, requestId: { harnessId: ref.harness, nativeId: request.elicitationId }, reply: request.reply,
14051
+ }));
14052
+ return this.replyNativeSessionForPrincipal('device', auditPeerId, {
14053
+ session: native.session, requestId: native.requestId, elicitation: native.reply,
14054
+ }, signalArg);
14055
+ }, toolsArg?.abortSignal);
14056
+ });
13966
14057
  }
13967
14058
 
13968
14059
  /**
@@ -14042,13 +14133,104 @@ export class OpenCodeController {
14042
14133
  */
14043
14134
  private createManagementRouter(): plugins.typedrequest.TypedRouter {
14044
14135
  const router = new plugins.typedrequest.TypedRouter();
14045
- router.addTypedHandler(this.createStatusHandler());
14136
+ router.addTypedHandler(this.createManagementStatusHandler());
14046
14137
  router.addTypedHandler(this.createUpgradeLaunchHandler());
14047
14138
  router.addTypedHandler(this.createUpgradePrepareBeginHandler());
14048
14139
  router.addTypedHandler(this.createUpgradeFinalizeHandler());
14140
+ router.addTypedHandler(this.createGatewaySyncHandler());
14049
14141
  return router;
14050
14142
  }
14051
14143
 
14144
+ /** The browser's status and, on the management endpoint only, the gateway client's (AGL-828). */
14145
+ private createManagementStatusHandler(): plugins.typedrequest.TypedHandler<IReq_ControllerManagementStatus> {
14146
+ return new plugins.typedrequest.TypedHandler<IReq_ControllerManagementStatus>(
14147
+ 'controller.status',
14148
+ async (requestArg) => {
14149
+ validateRequest(() => assertEmptyRequest(requestArg));
14150
+ return { ...this.statusForPrincipal('browser'), gateway: this.gatewayClient?.status() ?? { state: 'not_enrolled' } };
14151
+ },
14152
+ );
14153
+ }
14154
+
14155
+ /**
14156
+ * `agl remote gateway sync [--rotate]`: only a process of the controller's own OS user that holds the request's
14157
+ * loopback connection (the `localCli` it names, proved from the kernel) syncs the route now, rotating the
14158
+ * trusted-proxy secret first when asked; audited as `remote.gateway.sync`.
14159
+ */
14160
+ private createGatewaySyncHandler(): plugins.typedrequest.TypedHandler<IReq_ControllerGatewaySync> {
14161
+ return new plugins.typedrequest.TypedHandler<IReq_ControllerGatewaySync>(
14162
+ 'controller.gateway.sync',
14163
+ async (requestArg, toolsArg) => {
14164
+ const peer = peerFromLocalData(toolsArg?.localData);
14165
+ this.recordUnauthenticatedPreflightOperation(peer.id);
14166
+ const invalid = () => new plugins.typedrequest.TypedResponseError(
14167
+ 'The gateway sync request is invalid.',
14168
+ { code: 'invalid_request' },
14169
+ );
14170
+ if (
14171
+ !requestArg
14172
+ || typeof requestArg !== 'object'
14173
+ || Array.isArray(requestArg)
14174
+ || Object.keys(requestArg).length !== 2
14175
+ || typeof requestArg.rotate !== 'boolean'
14176
+ ) throw invalid();
14177
+ try {
14178
+ assertConfigurationLocalCliActor(requestArg.localCli);
14179
+ } catch {
14180
+ throw invalid();
14181
+ }
14182
+ const localCli = requestArg.localCli;
14183
+ try {
14184
+ const [caller] = await proveConnectionProcessAncestry(readManagementPeerConnection(toolsArg?.localData), localCli.pid, 1);
14185
+ if (!caller || caller.parentPid !== localCli.parentPid) throw new Error('The caller is not the process it names.');
14186
+ } catch (errorArg) {
14187
+ if (!(errorArg instanceof Error)) throw errorArg;
14188
+ throw new plugins.typedrequest.TypedResponseError(
14189
+ 'Only a process of the controller\'s own OS user that holds its connection syncs the gateway route.',
14190
+ { code: 'unauthorized' },
14191
+ );
14192
+ }
14193
+ const gatewayClient = this.gatewayClient;
14194
+ const authStore = this.requireAuthStore();
14195
+ if (!gatewayClient || this.lifecycleState !== 'ready') {
14196
+ throw new plugins.typedrequest.TypedResponseError('The controller is not ready.', { code: 'not_ready' });
14197
+ }
14198
+ const before = gatewayClient.status();
14199
+ const enrolment = before.enrolment;
14200
+ if (!enrolment) {
14201
+ throw new plugins.typedrequest.TypedResponseError(
14202
+ `controller:${this.requireRuntimeConfig().controllerPort} is not enrolled with a gateway: run \`agl remote gateway enrol\` first.`,
14203
+ { code: 'not_enrolled' },
14204
+ );
14205
+ }
14206
+ const details = { gateway: {
14207
+ gatewayUrl: enrolment.gatewayUrl,
14208
+ gatewayClientId: enrolment.gatewayClientId,
14209
+ appId: enrolment.appId,
14210
+ hostname: enrolment.hostname,
14211
+ targetHost: enrolment.target.host,
14212
+ targetPort: enrolment.target.port,
14213
+ routeKey: gatewayRouteKey({ gatewayClientId: enrolment.gatewayClientId, appId: enrolment.appId, hostname: enrolment.hostname }),
14214
+ rotate: requestArg.rotate,
14215
+ } };
14216
+ const audit = { type: 'remote.gateway.sync' as const, peerId: peer.id, localCli, details };
14217
+ await authStore.recordAuditEvent({ ...audit, outcome: 'attempted' });
14218
+ let gateway: IControllerGatewayStatus;
14219
+ try {
14220
+ gateway = await gatewayClient.sync({ rotate: requestArg.rotate });
14221
+ } catch (errorArg) {
14222
+ await authStore.recordAuditEvent({ ...audit, outcome: 'failed' });
14223
+ throw new plugins.typedrequest.TypedResponseError(
14224
+ errorArg instanceof Error ? errorArg.message : 'The gateway sync failed.',
14225
+ { code: 'gateway_sync_failed' },
14226
+ );
14227
+ }
14228
+ await authStore.recordAuditEvent({ ...audit, outcome: gateway.state === 'synced' ? 'succeeded' : 'failed' });
14229
+ return { gateway };
14230
+ },
14231
+ );
14232
+ }
14233
+
14052
14234
  private createStatusHandler(): plugins.typedrequest.TypedHandler<IReq_ControllerStatus> {
14053
14235
  return new plugins.typedrequest.TypedHandler<IReq_ControllerStatus>(
14054
14236
  'controller.status',
@@ -16735,6 +16917,48 @@ export class OpenCodeController {
16735
16917
  ));
16736
16918
  },
16737
16919
  );
16920
+
16921
+ protectedRouterArg.addHandler<IReq_ControllerElicitationReply>(
16922
+ 'controller.elicitation.reply',
16923
+ async (requestArg, toolsArg) => {
16924
+ const peer = peerFromLocalData(toolsArg?.localData);
16925
+ const request = validateRequest(() => assertElicitationReplyRequest(requestArg));
16926
+ return this.runOperation(peer, async (signalArg) => this.replyElicitationForPrincipal(
16927
+ 'browser', peer.id, request, signalArg,
16928
+ ));
16929
+ },
16930
+ );
16931
+ }
16932
+
16933
+ /**
16934
+ * Answers an MCP elicitation of a Claude Code or Codex conversation, for the owner's browser and a paired device
16935
+ * alike. The harness checks the reply against the pending request before it sends anything; elicitations are never
16936
+ * answered automatically, auto-accept included.
16937
+ */
16938
+ private async replyElicitationForPrincipal(
16939
+ principalArg: TControllerOperationPrincipal,
16940
+ peerIdArg: string,
16941
+ requestArg: IReq_ControllerElicitationReply['request'],
16942
+ signalArg: AbortSignal,
16943
+ ): Promise<IReq_ControllerElicitationReply['response']> {
16944
+ const { projectId, sessionId, requestId, reply } = requestArg;
16945
+ return this.runAudited(
16946
+ { type: 'elicitation.reply', peerId: this.auditPeerId(principalArg, peerIdArg), sessionId, requestId },
16947
+ async () => {
16948
+ await this.resolveProject(projectId);
16949
+ await this.assertSessionExists(projectId, sessionId, signalArg);
16950
+ return this.withHarnessSubmissionAdmission(projectId, sessionId, signalArg, async () => {
16951
+ signalArg.throwIfAborted();
16952
+ try {
16953
+ if (sessionId.harnessId === 'codex') this.requireCodexClient(sessionId.nativeId).replyElicitation(sessionId.nativeId, requestId.nativeId, reply);
16954
+ else this.requireClaudeHarness().replyElicitation(sessionId.nativeId, requestId.nativeId, reply);
16955
+ } catch (errorArg) {
16956
+ throw elicitationRefusal(errorArg);
16957
+ }
16958
+ return { success: true };
16959
+ });
16960
+ },
16961
+ );
16738
16962
  }
16739
16963
 
16740
16964
  /**
@@ -17920,6 +18144,17 @@ export class OpenCodeController {
17920
18144
  ), toolsArg?.abortSignal);
17921
18145
  },
17922
18146
  );
18147
+
18148
+ protectedRouterArg.addHandler<IReq_ControllerNativeSessionElicitationReply>(
18149
+ 'controller.nativesession.elicitation.reply',
18150
+ async (requestArg, toolsArg) => {
18151
+ const peer = peerFromLocalData(toolsArg?.localData);
18152
+ const request = validateRequest(() => assertNativeSessionElicitationReplyRequest(requestArg));
18153
+ return this.runOperation(peer, (signalArg) => this.replyNativeSessionForPrincipal(
18154
+ 'browser', peer.id, { session: request.session, requestId: request.requestId, elicitation: request.reply }, signalArg,
18155
+ ), toolsArg?.abortSignal);
18156
+ },
18157
+ );
17923
18158
  }
17924
18159
 
17925
18160
  /**
@@ -17961,28 +18196,27 @@ export class OpenCodeController {
17961
18196
  }
17962
18197
 
17963
18198
  /**
17964
- * Answers a permission (`permission`) or a question (`answers`, `null` rejects it) of AGL's own turn in a native
17965
- * session, for the owner's browser and a paired device alike. The request must still be pending.
18199
+ * Answers a permission (`permission`), a question (`answers`, `null` rejects it) or an MCP elicitation
18200
+ * (`elicitation`) of AGL's own turn in a native session, for the owner's browser and a paired device alike. The
18201
+ * request must still be pending.
17966
18202
  */
17967
18203
  private async replyNativeSessionForPrincipal(
17968
18204
  principalArg: TControllerOperationPrincipal,
17969
18205
  peerIdArg: string,
17970
- requestArg: { session: IControllerNativeSessionRef; requestId: IControllerRuntimeId }
17971
- & ({ permission: TControllerPermissionReply } | { answers: string[][] | null }),
18206
+ requestArg: { session: IControllerNativeSessionRef; requestId: IControllerRuntimeId } & TFleetNativeReply,
17972
18207
  signalArg: AbortSignal,
17973
18208
  ): Promise<{ success: boolean }> {
17974
18209
  const { session: ref, requestId } = requestArg;
17975
- const kind = 'permission' in requestArg ? 'permission' : 'question';
18210
+ const [kind, reply]: ['permission' | 'question' | 'elicitation', TFleetNativeReply] = 'permission' in requestArg
18211
+ ? ['permission', { permission: requestArg.permission }]
18212
+ : 'elicitation' in requestArg
18213
+ ? ['elicitation', { elicitation: requestArg.elicitation }]
18214
+ : ['question', { answers: requestArg.answers }];
17976
18215
  return this.runAudited(
17977
18216
  { type: `${kind}.reply`, peerId: this.auditPeerId(principalArg, peerIdArg), sessionId: nativeSessionRuntimeId(ref), requestId },
17978
18217
  () => this.serveNativeSession(signalArg, async () => {
17979
18218
  const resolved = await this.nativeSessions.resolve(ref);
17980
- await this.replyNativeSessionRequest(
17981
- resolved,
17982
- requestId.nativeId,
17983
- 'permission' in requestArg ? { permission: requestArg.permission } : { answers: requestArg.answers },
17984
- kind,
17985
- );
18219
+ await this.replyNativeSessionRequest(resolved, requestId.nativeId, reply, kind);
17986
18220
  return { success: true };
17987
18221
  }),
17988
18222
  );
@@ -17991,33 +18225,39 @@ export class OpenCodeController {
17991
18225
  /** The requests of AGL's own turns in a native session that wait for an answer. */
17992
18226
  private async nativeSessionAttention(
17993
18227
  resolvedArg: IResolvedNativeSession,
17994
- ): Promise<{ permissions: IControllerPermission[]; questions: IControllerQuestion[] }> {
18228
+ ): Promise<IControllerAttention> {
17995
18229
  const { session, native } = resolvedArg;
17996
18230
  if (session.harness === 'codex') return await this.requireFleetWorkers().nativeAttention('codex', native);
17997
18231
  const harness = this.claudeHarness;
17998
18232
  return harness && !harness.closed && harness.isRegistered(native.nativeId)
17999
18233
  ? harness.attention(native.nativeId)
18000
- : { permissions: [], questions: [] };
18234
+ : { permissions: [], questions: [], elicitations: [] };
18001
18235
  }
18002
18236
 
18003
18237
  private async replyNativeSessionRequest(
18004
18238
  resolvedArg: IResolvedNativeSession,
18005
18239
  requestIdArg: string,
18006
- replyArg: { permission: TControllerPermissionReply } | { answers: string[][] | null },
18007
- kindArg: 'permission' | 'question',
18240
+ replyArg: TFleetNativeReply,
18241
+ kindArg: 'permission' | 'question' | 'elicitation',
18008
18242
  ): Promise<void> {
18009
18243
  const { session, native } = resolvedArg;
18010
18244
  const attention = await this.nativeSessionAttention(resolvedArg);
18011
- if (!(kindArg === 'permission' ? attention.permissions : attention.questions).some((request) => request.id.nativeId === requestIdArg)) {
18012
- throw new plugins.typedrequest.TypedResponseError(`The ${kindArg} request is no longer pending.`, { code: 'not_found' });
18245
+ const pending = kindArg === 'permission' ? attention.permissions : kindArg === 'question' ? attention.questions : attention.elicitations;
18246
+ if (!pending.some((request) => request.id.nativeId === requestIdArg)) {
18247
+ throw new plugins.typedrequest.TypedResponseError(`The ${kindArg === 'elicitation' ? 'MCP' : kindArg} request is no longer pending.`, { code: 'not_found' });
18013
18248
  }
18014
- if (session.harness === 'codex') {
18015
- await this.requireFleetWorkers().nativeReply('codex', native, requestIdArg, replyArg);
18016
- return;
18249
+ try {
18250
+ if (session.harness === 'codex') {
18251
+ await this.requireFleetWorkers().nativeReply('codex', native, requestIdArg, replyArg);
18252
+ return;
18253
+ }
18254
+ const harness = this.requireClaudeHarness();
18255
+ if ('permission' in replyArg) harness.replyPermission(native.nativeId, requestIdArg, replyArg.permission);
18256
+ else if ('elicitation' in replyArg) harness.replyElicitation(native.nativeId, requestIdArg, replyArg.elicitation);
18257
+ else harness.replyQuestion(native.nativeId, requestIdArg, replyArg.answers);
18258
+ } catch (errorArg) {
18259
+ throw elicitationRefusal(errorArg);
18017
18260
  }
18018
- const harness = this.requireClaudeHarness();
18019
- if ('permission' in replyArg) harness.replyPermission(native.nativeId, requestIdArg, replyArg.permission);
18020
- else harness.replyQuestion(native.nativeId, requestIdArg, replyArg.answers);
18021
18261
  }
18022
18262
 
18023
18263
  /** Native session failures are bounded messages; the session view and the fleet's receipt show them as they are. */
@@ -18524,6 +18764,7 @@ export class OpenCodeController {
18524
18764
  : `${errorArg.message} The current revision is ${errorArg.currentRevision}.`);
18525
18765
  }
18526
18766
  if (errorArg instanceof DriverError) return refuse(errorArg.code, errorArg.message);
18767
+ if (errorArg instanceof FleetWorkerError) return refuse(errorArg.code, errorArg.message);
18527
18768
  if (
18528
18769
  (errorArg instanceof AuthError && errorArg.code === 'concurrent_change')
18529
18770
  || (
@@ -24635,6 +24876,7 @@ export class OpenCodeController {
24635
24876
  messagePage: IControllerMessagePage;
24636
24877
  permissions: IControllerPermission[];
24637
24878
  questions: IControllerQuestion[];
24879
+ elicitations: IControllerAttention['elicitations'];
24638
24880
  todos: IControllerTodo[];
24639
24881
  contextCompaction?: IControllerSessionDetail['contextCompaction'];
24640
24882
  model?: string;
@@ -24715,6 +24957,8 @@ export class OpenCodeController {
24715
24957
  }),
24716
24958
  permissions,
24717
24959
  questions: [],
24960
+ // Flex hands AGL no MCP elicitations.
24961
+ elicitations: [],
24718
24962
  todos,
24719
24963
  ...(model === undefined ? {} : { model }),
24720
24964
  ...(effort === undefined ? {} : { effort }),
@@ -6,8 +6,13 @@ import {
6
6
  controllerPackageName,
7
7
  controllerProtocolVersion,
8
8
  controllerServiceUnitName,
9
+ readControllerGatewayStatus,
10
+ type IConfigurationLocalCliActor,
11
+ type IControllerGatewayStatus,
12
+ type IControllerManagementStatus,
9
13
  type IControllerStatus,
10
- type IReq_ControllerStatus,
14
+ type IReq_ControllerGatewaySync,
15
+ type IReq_ControllerManagementStatus,
11
16
  type IReq_ControllerUpgradeLaunch,
12
17
  type IReq_ControllerUpgradePrepareBegin,
13
18
  type IReq_ControllerUpgradeFinalize,
@@ -238,7 +243,7 @@ export const assertControllerStatus = (
238
243
  statusArg: unknown,
239
244
  expectationArg: IControllerStatusExpectation,
240
245
  knownProtocolVersionArg: number = controllerProtocolVersion,
241
- ): IControllerStatus => {
246
+ ): IControllerManagementStatus => {
242
247
  if (typeof statusArg !== 'object' || statusArg === null) {
243
248
  throw new Error(`The service on the management port is not an ${currentRuntimeName} endpoint.`);
244
249
  }
@@ -276,10 +281,13 @@ export const assertControllerStatus = (
276
281
  throw new Error('The service on the management port has an incompatible controller identity.');
277
282
  }
278
283
  // A section a newer controller reports in a form this release cannot read is left out.
279
- const readableStatus: Partial<IControllerStatus> = { ...status, harnesses };
284
+ const readableStatus: Partial<IControllerManagementStatus> = { ...status, harnesses };
280
285
  if (!isControllerUpgradeStatus(status.upgrade, exactShape)) delete readableStatus.upgrade;
281
286
  if (!isControllerProxyStatus(status.proxy, exactShape)) delete readableStatus.proxy;
282
- return readableStatus as IControllerStatus;
287
+ // The gateway section only the management endpoint reports (AGL-828); a controller before it reports none.
288
+ const gateway = (statusArg as Partial<IControllerManagementStatus>).gateway;
289
+ if (gateway === undefined || !readControllerGatewayStatus(gateway)) delete readableStatus.gateway;
290
+ return readableStatus as IControllerManagementStatus;
283
291
  };
284
292
 
285
293
  /** A management request the controller answered with an error, or whose answer this build cannot read. */
@@ -532,9 +540,9 @@ export const queryControllerStatus = async (
532
540
  portArg: number,
533
541
  queryArg: IControllerStatusQuery,
534
542
  timeoutMsArg = 2_500,
535
- ): Promise<IControllerStatus> => {
543
+ ): Promise<IControllerManagementStatus> => {
536
544
  const status = assertControllerStatus(
537
- await requestManagedController<IReq_ControllerStatus>(
545
+ await requestManagedController<IReq_ControllerManagementStatus>(
538
546
  portArg,
539
547
  queryArg,
540
548
  'controller.status',
@@ -561,7 +569,7 @@ export const isUnmanagedControllerError = (errorArg: unknown): errorArg is Contr
561
569
  export const tryQueryControllerStatus = async (
562
570
  portArg: number,
563
571
  queryArg: IControllerStatusQuery,
564
- ): Promise<IControllerStatus | undefined> => {
572
+ ): Promise<IControllerManagementStatus | undefined> => {
565
573
  try {
566
574
  return await queryControllerStatus(portArg, queryArg);
567
575
  } catch (errorArg) {
@@ -570,6 +578,31 @@ export const tryQueryControllerStatus = async (
570
578
  }
571
579
  };
572
580
 
581
+ /**
582
+ * Syncs the gateway route of the controller `controllerArg` names now, rotating its trusted-proxy secret first when
583
+ * `rotateArg` is set (`agl remote gateway sync`). `localCliArg` is this process: the controller proves that it holds
584
+ * the request's loopback connection and runs as the controller's user before it acts, and audits it as the actor.
585
+ * The sync talks to the gateway, so it may take as long as the gateway's DNS reconciliation.
586
+ */
587
+ export const requestControllerGatewaySync = async (
588
+ portArg: number,
589
+ controllerArg: IControllerManagementTarget,
590
+ optionsArg: { rotate: boolean; localCli: IConfigurationLocalCliActor },
591
+ timeoutMsArg = 180_000,
592
+ ): Promise<IControllerGatewayStatus> => {
593
+ const response = await requestManagedController<IReq_ControllerGatewaySync>(
594
+ portArg,
595
+ controllerArg,
596
+ 'controller.gateway.sync',
597
+ { rotate: optionsArg.rotate, localCli: optionsArg.localCli },
598
+ { timeoutMs: timeoutMsArg },
599
+ );
600
+ const gateway = isPlainRecord(response) && Object.keys(response).length === 1
601
+ ? readControllerGatewayStatus(response.gateway) : undefined;
602
+ if (!gateway) throw new Error('The controller returned an invalid gateway sync response.');
603
+ return gateway;
604
+ };
605
+
573
606
  export const isLoopbackPortListening = async (
574
607
  portArg: number,
575
608
  timeoutMsArg = 500,