agl 43.1.0 → 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 (123) hide show
  1. package/changelog.md +12 -0
  2. package/dist_serve/bundle.js +5329 -5116
  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_ts/00_commitinfo_data.js +1 -1
  7. package/dist_ts/aglapi/aglapisurface.document.js +325 -1
  8. package/dist_ts/aglapi/interfaces.d.ts +3 -0
  9. package/dist_ts/aglapi/interfaces.js +2 -1
  10. package/dist_ts/classes.authmodels.js +17 -4
  11. package/dist_ts/classes.authstore.js +16 -2
  12. package/dist_ts/classes.cli.d.ts +4 -2
  13. package/dist_ts/classes.cli.js +6 -3
  14. package/dist_ts/classes.controller.d.ts +10 -0
  15. package/dist_ts/classes.controller.js +119 -4
  16. package/dist_ts/classes.controllermanagement.d.ts +14 -4
  17. package/dist_ts/classes.controllermanagement.js +20 -2
  18. package/dist_ts/classes.gatewayclient.d.ts +115 -0
  19. package/dist_ts/classes.gatewayclient.js +336 -0
  20. package/dist_ts/classes.gatewayclientstore.d.ts +97 -0
  21. package/dist_ts/classes.gatewayclientstore.js +261 -0
  22. package/dist_ts/classes.inferencerouter.d.ts +9 -0
  23. package/dist_ts/classes.inferencerouter.js +11 -1
  24. package/dist_ts/classes.inferenceservice.d.ts +9 -0
  25. package/dist_ts/classes.inferenceservice.js +27 -1
  26. package/dist_ts/classes.mcpclient.d.ts +4 -1
  27. package/dist_ts/classes.mcpclient.js +19 -1
  28. package/dist_ts/classes.mcpcontrollerhost.d.ts +3 -1
  29. package/dist_ts/classes.mcpcontrollerhost.js +9 -1
  30. package/dist_ts/classes.mcptools.d.ts +3 -3
  31. package/dist_ts/classes.mcptools.js +26 -1
  32. package/dist_ts/classes.mcpvalidation.js +7 -1
  33. package/dist_ts/classes.proxycontrol.d.ts +11 -0
  34. package/dist_ts/classes.proxycontrol.js +7 -1
  35. package/dist_ts/classes.proxycontrolclient.d.ts +17 -0
  36. package/dist_ts/classes.proxycontrolclient.js +35 -1
  37. package/dist_ts/classes.proxydaemon.js +8 -1
  38. package/dist_ts/classes.proxymonitor.d.ts +7 -0
  39. package/dist_ts/classes.proxymonitor.js +13 -1
  40. package/dist_ts/classes.trustedproxysecrets.d.ts +2 -0
  41. package/dist_ts/classes.trustedproxysecrets.js +5 -1
  42. package/dist_ts/functions.controllermanagementsurface.d.ts +4 -0
  43. package/dist_ts/functions.controllermanagementsurface.js +15 -1
  44. package/dist_ts/functions.gatewaycli.d.ts +24 -0
  45. package/dist_ts/functions.gatewaycli.js +395 -0
  46. package/dist_ts/functions.gatewayroute.d.ts +135 -0
  47. package/dist_ts/functions.gatewayroute.js +366 -0
  48. package/dist_ts/functions.inferencecli.js +30 -1
  49. package/dist_ts/functions.inferencecliarguments.d.ts +8 -2
  50. package/dist_ts/functions.inferencecliarguments.js +31 -3
  51. package/dist_ts/functions.proxycapacity.d.ts +50 -0
  52. package/dist_ts/functions.proxycapacity.js +142 -0
  53. package/dist_ts/functions.proxycapacitycli.d.ts +30 -0
  54. package/dist_ts/functions.proxycapacitycli.js +65 -0
  55. package/dist_ts/functions.remotecli.d.ts +30 -3
  56. package/dist_ts/functions.remotecli.js +44 -18
  57. package/dist_ts/interfaces.auth.d.ts +25 -4
  58. package/dist_ts/interfaces.auth.js +7 -1
  59. package/dist_ts/plugins.d.ts +2 -0
  60. package/dist_ts/plugins.js +4 -1
  61. package/dist_ts_authswitch/authority-placement.js +3 -17
  62. package/dist_ts_authswitch/authority-usagelimit.d.ts +29 -0
  63. package/dist_ts_authswitch/authority-usagelimit.js +66 -2
  64. package/dist_ts_authswitch/authority-usagewindows.d.ts +6 -0
  65. package/dist_ts_authswitch/authority-usagewindows.js +15 -1
  66. package/dist_ts_interfaces/gateway.d.ts +151 -0
  67. package/dist_ts_interfaces/gateway.js +66 -0
  68. package/dist_ts_interfaces/index.d.ts +2 -0
  69. package/dist_ts_interfaces/index.js +3 -1
  70. package/dist_ts_interfaces/management.d.ts +4 -4
  71. package/dist_ts_interfaces/management.js +3 -2
  72. package/dist_ts_interfaces/mcprequests.d.ts +14 -2
  73. package/dist_ts_interfaces/mcprequests.js +2 -1
  74. package/dist_ts_interfaces/proxycapacity.d.ts +99 -0
  75. package/dist_ts_interfaces/proxycapacity.js +74 -0
  76. package/package.json +4 -3
  77. package/readme.md +79 -5
  78. package/ts/00_commitinfo_data.ts +1 -1
  79. package/ts/aglapi/aglapisurface.document.ts +324 -0
  80. package/ts/aglapi/interfaces.ts +1 -0
  81. package/ts/classes.authmodels.ts +22 -3
  82. package/ts/classes.authstore.ts +15 -1
  83. package/ts/classes.cli.ts +7 -3
  84. package/ts/classes.controller.ts +134 -3
  85. package/ts/classes.controllermanagement.ts +40 -7
  86. package/ts/classes.gatewayclient.ts +401 -0
  87. package/ts/classes.gatewayclientstore.ts +272 -0
  88. package/ts/classes.inferencerouter.ts +12 -0
  89. package/ts/classes.inferenceservice.ts +27 -0
  90. package/ts/classes.mcpclient.ts +18 -0
  91. package/ts/classes.mcpcontrollerhost.ts +13 -0
  92. package/ts/classes.mcptools.ts +30 -2
  93. package/ts/classes.mcpvalidation.ts +5 -0
  94. package/ts/classes.proxycontrol.ts +16 -0
  95. package/ts/classes.proxycontrolclient.ts +30 -0
  96. package/ts/classes.proxydaemon.ts +8 -0
  97. package/ts/classes.proxymonitor.ts +12 -0
  98. package/ts/classes.trustedproxysecrets.ts +5 -0
  99. package/ts/functions.controllermanagementsurface.ts +15 -0
  100. package/ts/functions.gatewaycli.ts +436 -0
  101. package/ts/functions.gatewayroute.ts +429 -0
  102. package/ts/functions.inferencecli.ts +24 -0
  103. package/ts/functions.inferencecliarguments.ts +30 -4
  104. package/ts/functions.proxycapacity.ts +191 -0
  105. package/ts/functions.proxycapacitycli.ts +104 -0
  106. package/ts/functions.remotecli.ts +56 -20
  107. package/ts/interfaces.auth.ts +28 -4
  108. package/ts/plugins.ts +5 -0
  109. package/ts_authswitch/authority-placement.ts +2 -15
  110. package/ts_authswitch/authority-usagelimit.ts +84 -1
  111. package/ts_authswitch/authority-usagewindows.ts +13 -0
  112. package/ts_interfaces/gateway.ts +242 -0
  113. package/ts_interfaces/index.ts +2 -0
  114. package/ts_interfaces/management.ts +6 -4
  115. package/ts_interfaces/mcprequests.ts +18 -0
  116. package/ts_interfaces/proxycapacity.ts +162 -0
  117. package/ts_web/00_commitinfo_data.ts +1 -1
  118. package/ts_web/classes.browserpresentation.ts +13 -5
  119. package/ts_web/elements.accounts.ts +40 -113
  120. package/ts_web/elements.configurationpane.ts +24 -37
  121. package/ts_web/elements.devices.ts +4 -17
  122. package/ts_web/elements.flexlimitstrip.ts +21 -70
  123. package/ts_web/elements.harnesscontrollerapp.ts +91 -185
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agl",
3
- "version": "43.1.0",
3
+ "version": "43.2.0",
4
4
  "controllerUpgradeManagementVersion": 2,
5
5
  "controllerManagementProtocolVersion": 1,
6
6
  "controllerGatewaySourcesVersion": 1,
@@ -24,13 +24,13 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@anthropic-ai/claude-agent-sdk": "0.3.288",
27
- "@api.global/typedrequest": "9.2.0",
27
+ "@api.global/typedrequest": "9.2.1",
28
28
  "@api.global/typedrequest-interfaces": "7.1.0",
29
29
  "@api.global/typedserver": "^16.0.0",
30
30
  "@api.global/typedsocket": "^10.0.1",
31
31
  "@apiclient.xyz/docker": "^12.0.0",
32
32
  "@aws-sdk/client-s3": "^3.1136.0",
33
- "@design.estate/dees-catalog": "24.2.0",
33
+ "@design.estate/dees-catalog": "24.6.0",
34
34
  "@design.estate/dees-comms": "^2.1.0",
35
35
  "@design.estate/dees-element": "4.0.2",
36
36
  "@jitl/quickjs-ng-wasmfile-release-sync": "0.32.0",
@@ -55,6 +55,7 @@
55
55
  "@push.rocks/smartshell": "4.2.0",
56
56
  "@push.rocks/smartstring": "4.3.0",
57
57
  "@push.rocks/smartsystem": "3.1.1",
58
+ "@serve.zone/interfaces": "32.75.0",
58
59
  "@simplewebauthn/browser": "13.3.0",
59
60
  "@simplewebauthn/server": "13.3.2",
60
61
  "@xterm/addon-fit": "0.11.0",
package/readme.md CHANGED
@@ -334,6 +334,7 @@ agl proxy service install [--port 4100]
334
334
  agl proxy service enable
335
335
  agl proxy service start
336
336
  agl proxy status [--json]
337
+ agl proxy capacity --provider anthropic --wait --max-seconds 3600 # wait until the Claude pool has room for new work
337
338
  agl proxy credential opencode --delivery file # the proxy keeps it in <AGL home>/proxy/credentials/opencode
338
339
  agl proxy credential mytool --write ~/.config/mytool/agl-proxy.key
339
340
  agl proxy credential codex --rotate
@@ -403,6 +404,52 @@ session of a client that names no credential goes to (`nextPlacement`), the late
403
404
  sessions placed or moved with why (`recentPlacements`), the count of usage reports handed to the account service and
404
405
  of hand-overs that failed, and exits non-zero while the proxy is down.
405
406
 
407
+ #### Pool capacity
408
+
409
+ `agl proxy capacity` answers whether a pool has room for new work, as one answer from the proxy, judged on the same
410
+ readings as `agl proxy status` -- for a script that starts confined runs (`agl proxy confined run`) only while a pool can
411
+ take them. The MCP tool `proxy_capacity` (`agl mcp`) gives the same answer to every caller, through the controller; it
412
+ never waits.
413
+
414
+ ```sh
415
+ agl proxy capacity [--provider anthropic|openai] [--min-headroom 15] [--json]
416
+ agl proxy capacity --provider openai --min-headroom 40 --wait [--max-seconds 1800]
417
+ ```
418
+
419
+ - **Members.** A pool counts its subscription sign-ins that have not lapsed and whose held reading states a counted plan,
420
+ however old the reading; API keys never count:
421
+
422
+ | Pool | Counts |
423
+ | --- | --- |
424
+ | `anthropic` (Claude accounts) | plan `max` only (both Max tiers: Anthropic names them `claude_max`) |
425
+ | `openai` (ChatGPT accounts) | every plan but `free` |
426
+
427
+ - **Headroom.** A member that takes work now adds its headroom: how far its fullest counted window is below its maximum
428
+ usage (100 when unset), the same `headroom` `agl proxy status` shows. A member that takes no work now -- cooling down
429
+ after a provider 429, at its limit or reserve, refused by its provider, or unavailable (a stale reading, a sign-in or
430
+ payment problem) -- adds 0. The pool's `room` is the members' headroom summed.
431
+ - **Binding window and growth.** Each member names the window its headroom is bound by (`binding`) and when that headroom
432
+ next grows (`growsAt`, to `growsTo`): the binding window's reset -- a five-hour window that binds grows long before a
433
+ weekly window that does not -- or the moment the member takes work again (its 429 rest's end, its provider's retry time,
434
+ the reset of the windows its limit is held by). `null` when nothing can grow it or the moment is unknown (a stale
435
+ reading names `recheckAt`, when the account service reads it next; a sign-in or payment problem names none).
436
+ - **Verdict.** `open` when `room` reaches the minimum (`--min-headroom`, any whole percent, 15 unless given) and no provider
437
+ 429 hit a member within five minutes; the proxy keeps that record in memory from its start (`observedSince`), so for
438
+ its first five minutes it cannot say none came. Otherwise `wait` with a `reason` -- `room` (too little), `provider-429`
439
+ (`last429At` within five minutes) or `quiet-unobserved` (the proxy started less than five minutes ago) -- and `until`
440
+ with `seconds`: the first moment the members' readings foresee enough room once the pool is quiet. Usage spent meanwhile
441
+ is not foreseen, so that moment is the earliest the room can be there; with no such moment foreseen (a minimum beyond
442
+ every member's whole headroom, a pool without members), `until` and `seconds` are `null`.
443
+
444
+ The text names each member by the first 12 characters of its account id, never its label or email; `--json` and the MCP
445
+ tool answer `{ at, observedSince, pools: [{ provider, minHeadroom, room, members: [{ accountId, plan, state, headroom,
446
+ binding: { name, durationSeconds, usedPercent, estimated, resetAt }, growsAt, growsTo, recheckAt }], last429At, verdict }]
447
+ }`. It exits 0 when every pool it reports is open, 2 when one waits, and 1 when the proxy is down, runs an older AGL (it
448
+ names the release and the restart onto the installed one, as `agl proxy status` does) or cannot reach its account
449
+ service. `--wait` (with `--provider`) asks again after the pool's `seconds`, at most a minute apart, until the pool is
450
+ open (0) or `--max-seconds` ran out (2), and prints the last answer; without `--max-seconds` it waits as long as it
451
+ takes.
452
+
406
453
  #### Usage reads
407
454
 
408
455
  The accounts service reads each account's usage from the provider once every 10 minutes and no more often, on its
@@ -1063,12 +1110,12 @@ Each card is one of three kinds, named by its `mode`, and carries the server's n
1063
1110
 
1064
1111
  ## MCP Server
1065
1112
 
1066
- The installed `agl` command includes a unified stdio MCP server that combines 96 tools on one connection:
1113
+ The installed `agl` command includes a unified stdio MCP server that combines 97 tools on one connection:
1067
1114
 
1068
1115
  - Nine CrossHarness tools for explicit OpenCode and Codex harness-server connections.
1069
1116
  - Six system inspection and reclaim-planning tools.
1070
1117
  - Thirteen durable `tstask` tools.
1071
- - Sixty-eight AGL controller tools for projects, task discovery, control and messaging, models, scratchpads, resource lifecycle and attachment, managed jobs, driver fleet operations, the shared project ticket board, and challenge-only worker enrollment.
1118
+ - Sixty-nine AGL controller tools for projects, task discovery, control and messaging, models, scratchpads, resource lifecycle and attachment, managed jobs, driver fleet operations, the shared project ticket board, the inference proxy's pool capacity, and challenge-only worker enrollment.
1072
1119
 
1073
1120
  Configure an MCP host to execute:
1074
1121
 
@@ -1076,7 +1123,7 @@ Configure an MCP host to execute:
1076
1123
  agl mcp --port 4097
1077
1124
  ```
1078
1125
 
1079
- `--port` takes precedence over `AGL_CONTROLLER_PORT`; otherwise the controller port defaults to `4097`. `agl mcp` starts and exposes all 96 tools without a running AGL controller. Only the AGL controller tools require a ready controller on the configured port; the CrossHarness, system, and durable-task tools remain available independently. `agl mcp` requires Linux x64 with Node.js `>=24.12.0 <27`.
1126
+ `--port` takes precedence over `AGL_CONTROLLER_PORT`; otherwise the controller port defaults to `4097`. `agl mcp` starts and exposes all 97 tools without a running AGL controller. Only the AGL controller tools require a ready controller on the configured port; the CrossHarness, system, and durable-task tools remain available independently. `agl mcp` requires Linux x64 with Node.js `>=24.12.0 <27`.
1080
1127
 
1081
1128
  On supported systems, a ready controller publishes a process- and generation-fenced private loopback endpoint under `$AGL_HOME/runtime/mcp`. The descriptor and bearer token remain owner-only runtime state. They are discovered and verified automatically; do not copy them into MCP configuration. The endpoint accepts only the explicitly registered, bounded AGL methods and is removed before controller shutdown proceeds.
1082
1129
 
@@ -1098,7 +1145,7 @@ A caller is one of three subjects:
1098
1145
  - **Runtime** — a shared harness server. OpenCode runs one server per controller and addresses MCP servers per directory rather than per task, so an OpenCode-launched caller is identified as that runtime, not as one chat: it may act for its own tasks in the project named in each request. This is deliberately coarser than a terminal subject, and narrowing it requires per-task MCP servers upstream in OpenCode.
1099
1146
  - **Task** — a chat AGL manages as a task, acting only for that task in that task's project. The subject exists in the model and is enforced everywhere, but **no task credential is issued yet**: AGL cannot stamp a per-task credential into a harness that shares one server across tasks. Until OpenCode can carry a task id into the MCP server it launches, OpenCode chats act through the runtime subject.
1100
1147
 
1101
- Reading is open to every caller that holds the descriptor token, identified or not: `controller_status`, `projects_list`, `sessions_list`, `context_resolve`, `models_list`, `session_read` and `session_scratchpad_read` behave exactly as before. That keeps the cross-harness workflow intact, where a chat running outside any AGL terminal — and therefore without an AGL identity — inspects AGL-managed tasks. `resources_list` shows the unattached project resources to such a caller.
1148
+ Reading is open to every caller that holds the descriptor token, identified or not: `controller_status`, `projects_list`, `sessions_list`, `context_resolve`, `models_list`, `session_read` and `session_scratchpad_read` behave exactly as before, and `proxy_capacity` answers the inference proxy's pool capacity (see [Pool capacity](#pool-capacity)), naming accounts by id alone. That keeps the cross-harness workflow intact, where a chat running outside any AGL terminal — and therefore without an AGL identity — inspects AGL-managed tasks. `resources_list` shows the unattached project resources to such a caller.
1102
1149
 
1103
1150
  Writing is not open. Task mutations (`session_send`, `session_scratchpad_update`, `session_model_set`, `session_rename`, `session_archive`, `session_stop`) require the calling chat to be the task itself, or its shared harness runtime; a terminal caller owns no task and an unidentified host owns nothing. Resource mutations, `project_add`, `session_create` and `browser_action` require an AGL identity as well, and so does every job tool: jobs belong to a project, and any identified caller of that project may inspect, wait for or stop them. Every caller must still run as the controller's local OS user; a remote MCP process cannot access this local endpoint without a separate authenticated transport.
1104
1151
 
@@ -3283,6 +3330,7 @@ agl feed list [--state failed] [--json] | acknowledge <row-id> --updated-at <ms>
3283
3330
  agl foreground [options]
3284
3331
  agl temp-password [--port 4097] [--ttl-hours 24]
3285
3332
  agl remote set|unset|secret import [--port 4097] [options]
3333
+ agl remote gateway enrol|status|sync|remove [--port 4097] [options]
3286
3334
  agl help
3287
3335
  agl --version
3288
3336
  ```
@@ -3553,7 +3601,7 @@ agl start --port 4097 # prints the setup code for https://agl.example.com
3553
3601
  - A passkey belongs to its RP ID. When the origin or RP ID changes, the passkey is removed and every temporary password revoked, so nothing that signed in to the old origin signs in to the new one. The next `agl start` prints a fresh setup code to its terminal, never to a log: enroll the passkey at the new origin with it. Running `remote set` again with only other gateway sources keeps the passkey.
3554
3602
  - `--gateway-source` names an address the proxy's connections arrive from (IPv4 or IPv6, repeatable, at most 16). Without one only a reverse proxy on this host reaches the controller.
3555
3603
  - A paired device signs the public origin (see Paired Devices), so a changed origin removes every paired device as well; `remote set` says how many. Changing only the gateway sources or the RP ID keeps them.
3556
- - `agl remote unset --port 4097` moves the port back to `http://localhost:4097` (RP ID `localhost`): it removes the passkey and every paired device, revokes every temporary password and forgets the trusted-proxy secret. The next start prints a setup code.
3604
+ - `agl remote unset --port 4097` moves the port back to `http://localhost:4097` (RP ID `localhost`): it removes the passkey and every paired device, revokes every temporary password and forgets the trusted-proxy secret. The next start prints a setup code. It is refused while the controller is enrolled with a gateway (see [AGL's own route on a dcrouter gateway](#agls-own-route-on-a-dcrouter-gateway)): `agl remote gateway remove` comes first. A `remote set` to another hostname is refused while enrolled as well.
3557
3605
  - Both refuse while anything listens on the port, take start admission (no upgrade runs meanwhile), run as the local OS user (the trust `agl temp-password` has) and are audited as `remote.set` or `remote.unset`, attempted and then succeeded or failed, with the OS user and process and the public origin and RP ID the move goes from and to (never a secret).
3558
3606
  - A start never moves a port: one that asks for another `--public-origin`, `--rp-id` or TLS mode is refused and names `agl remote set`. A new port can still start behind a reverse proxy on this host directly: `agl start --public-origin https://agl.example.com --rp-id agl.example.com --behind-tls-proxy`.
3559
3607
 
@@ -3610,6 +3658,32 @@ sudo ufw status verbose # the allow is listed before the deny, and no broader
3610
3658
 
3611
3659
  The gateway source is the address the proxy's connections arrive from on this host. A router that translates addresses between the proxy and this host puts its own address there, and every host behind it then passes the source check: route without translation, or put the proxy on this host's network.
3612
3660
 
3661
+ ### AGL's own route on a dcrouter gateway
3662
+
3663
+ A controller behind a [dcrouter](https://code.foss.global/serve.zone/dcrouter) gateway keeps its own route there, as Onebox and Cloudly keep theirs: it is a gateway client of type `custom` and writes one route for the hostname of its public origin. The route ends TLS at the gateway with the gateway's own certificate, forwards to the controller with the trusted-proxy secret, passes WebSockets, is reachable from private networks only (source profile `LOCAL NETWORK`, directly at the hub and over its VPN, never through RemoteIngress) and gets the gateway's own DNS record, unproxied. Every field is sent on every sync: the gateway fills an omitted one from what it stored or a default.
3664
+
3665
+ Enrol the stopped controller once, with a short-lived gateway admin token (dcrouter Ops UI → API Tokens, scope `tokens:manage`) in a file:
3666
+
3667
+ ```sh
3668
+ agl stop --port 4097
3669
+ agl remote set --port 4097 --public-origin https://agl.example.com --gateway-source 192.0.2.10
3670
+ agl remote gateway enrol --port 4097 \
3671
+ --gateway-url https://gateway.example.com:3000 \
3672
+ --target-host 192.0.2.66 < ~/gateway-admin-token
3673
+ rm ~/gateway-admin-token # and revoke the token in the Ops UI
3674
+ agl start --port 4097
3675
+ ```
3676
+
3677
+ - `enrol` reads the admin token from a pipe or file, never from a terminal, and uses it once to provision the gateway client `agl-<installation>-<port>` (derived from the controller database and the port, so every controller has its own and keeps it) with exactly this route's hostname and target and the capabilities `readRoutes`, `syncRoutes` and `syncDnsRecords`. The gateway issues a credential for that client, which AGL seals with the TPM and stores before it asks the gateway to confirm it; the gateway then revokes the client's older credentials. The admin token is never stored, logged or printed. `--gateway-url` is the gateway's API base URL (requests go to `<url>/typedrequest`): `https`, plain `http` only for a gateway on loopback (`127.0.0.0/8`, `::1`, `localhost`), since every request carries a credential, and no option skips certificate verification; a stored URL is held to the same rule at every sync and `remove` (problem `gateway_url_insecure`). A gateway that answers with a redirect is not followed: the request fails (`unreachable`), so the configured URL is the only one that ever sees a token. `--target-host` is the address the gateway reaches this host by (a loopback address for a gateway on this host; any other needs a `--gateway-source`); both are kept for the next `enrol`.
3678
+ - A confirmation whose answer is lost is asked for again at once; if the gateway still does not answer, `enrol` fails and the next `agl remote gateway enrol --port 4097` finishes it with the stored credential, without a token. Run `enrol` with a new admin token to renew the credential, for example after an admin changed the client's policy. Enrolling with another gateway, or for another hostname a leftover move left behind, first deletes the route of the earlier one.
3679
+ - The running controller syncs the route in the background once it is ready; its start never waits for the gateway. A sync checks the credential, deletes the client's routes for anything the controller no longer serves (an earlier hostname, which only a leftover leaves: an interrupted change or a move an earlier release made after a rollback; the sync then fails with `origin_changed` until `enrol`), writes the route with the trusted-proxy secret as a request header the gateway sets (`requestHeaders`, sent only to a gateway that announces `routes.requestHeaders`, dcrouter 34.5.0 or later; an earlier gateway would refuse the whole route), and reads it back: the route must name the secret header and, when the gateway names the route's source profile, be bound to `LOCAL NETWORK`. A gateway before dcrouter 34.5.0 names no profile, and the status then says the profile is unverified. A failure a later sync can fix (the gateway does not answer, its DNS provider is unavailable) is retried after 30 s, doubling up to 15 min, jittered; a written route is synced again after six hours. A gateway without `routes.requestHeaders` (one before dcrouter 34.5.0, or one downgraded) is waited for (`waiting`, "gateway lacks routes.requestHeaders: waiting"): no route is written, the controller asks again after 30 s doubling up to 15 min, then at every six-hour sync and every `sync`, and writes the route with the header as soon as the gateway announces it. Every sync sends the header, also to a route the gateway already holds, so a route whose stored header a gateway dropped gets it back at the next sync. A failure only the operator can fix stops the syncs until the next start or `sync`: a revoked or stale credential (enrol again), a refused route or one read back without the secret header or bound to another profile, and the DNS outcomes `record-conflict`, `zone-unmanaged` and `target-invalid`. `manual-satisfied` (records the gateway does not own already serve the route) counts as synced and shows as not owned.
3680
+ - `agl remote gateway status [--json]` shows the enrolment, the last sync, the problem and the next sync, from the running controller or, while it is stopped, from its database; `agl status --json` carries the same as `gateway`. Neither the browser nor a paired device sees it.
3681
+ - `agl remote gateway sync [--rotate]` asks the running controller to sync now, over its loopback management endpoint and only for a process of the controller's own OS user, which the controller proves from the kernel. `--rotate` first rotates the trusted-proxy secret: the previous one stays valid until a sync wrote the new one to the route and read it back, and is refused from then on. Nothing rotates the secret on its own.
3682
+ - `agl remote gateway remove` deletes the route and its DNS record on the gateway and forgets the credential (a gateway client cannot revoke its own; an admin deletes the client under Access → Gateway Clients, which revokes it). `agl remote unset` is refused while the controller is enrolled, and so is an `agl remote set` to another hostname (one that keeps the hostname, with another RP ID or gateway sources, is not): run `agl remote gateway remove`, then `agl remote set`, then `agl remote gateway enrol`. When the gateway cannot be reached or refuses the credential, `agl remote gateway remove --abandon` forgets the enrolment without it and prints the route key (`custom:<client>:controller-<port>:<hostname>`) and the client it left for an admin to delete.
3683
+ - `enrol`, `remove` and `--abandon` run against a stopped controller under start admission, like `remote set`; all of them and `sync` are audited as `remote.gateway.enrol`, `remote.gateway.remove`, `remote.gateway.abandon` and `remote.gateway.sync`, with the OS user and process and the route they acted on (never a credential).
3684
+
3685
+ The gateway client keeps its record in `agl_controller_gateway_clients`. An earlier release starts with it in place and leaves it alone, and 41.1.0 and later read the `remote.gateway.*` audit events as types they do not know.
3686
+
3613
3687
  ## Paired Devices
3614
3688
 
3615
3689
  A phone or a desktop app pairs with a controller and then reaches it as a device: it lists the session feed, reads a session's transcript, sends a message to a session and answers its permissions, questions and MCP elicitations. A device reaches nothing else: no terminals, settings, accounts, tickets, browsers or files. It connects through the controller's public HTTPS origin (Remote Browser Access), so a controller in local mode pairs no device.
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '43.1.0',
6
+ version: '43.2.0',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }
@@ -478,6 +478,20 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
478
478
  },
479
479
  "declaration": "/**\n * Lists the projects registered with the running AGL controller.\n */\nfunction agl_mcp_projects_list(params?: Record<string, never>): Promise<{ projects: IControllerProject[] }>;"
480
480
  },
481
+ {
482
+ "method": "agl.mcp.proxy.capacity",
483
+ "path": "agl.agl_mcp_proxy_capacity",
484
+ "summary": "A pool's room for new work in AGL's inference proxy, or both pools' when `provider` is absent: each counted account by …",
485
+ "description": "A pool's room for new work in AGL's inference proxy, or both pools' when `provider` is absent: each counted account by\nits id with its plan, state, headroom, binding window and when its headroom next grows, the newest provider 429 on\nthe pool, and an `open` or `wait` verdict against `minHeadroom` (15 unless given). The controller asks the proxy; the\nanswer names no account by label or email.",
486
+ "omitted": [],
487
+ "inputSchema": {
488
+ "$ref": "#/$defs/IProxyCapacityRequest"
489
+ },
490
+ "outputSchema": {
491
+ "$ref": "#/$defs/IProxyCapacityAnswer"
492
+ },
493
+ "declaration": "/**\n * A pool's room for new work in AGL's inference proxy, or both pools' when `provider` is absent: each counted account by\n * its id with its plan, state, headroom, binding window and when its headroom next grows, the newest provider 429 on\n * the pool, and an `open` or `wait` verdict against `minHeadroom` (15 unless given). The controller asks the proxy; the\n * answer names no account by label or email.\n */\nfunction agl_mcp_proxy_capacity(params?: IProxyCapacityRequest): Promise<IProxyCapacityAnswer>;"
494
+ },
481
495
  {
482
496
  "method": "agl.mcp.resource.attach",
483
497
  "path": "agl.agl_mcp_resource_attach",
@@ -4767,6 +4781,204 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
4767
4781
  },
4768
4782
  "declaration": "/**\n * A view of one project's working tree for the human: files, an editor and changes on disk. It owns\n * no process; the controller serves the tree on request, confined to the project directory.\n */\ninterface IControllerWorkspaceResource extends IControllerResourceBase {\n kind: 'workspace';\n /** Project-relative directory the workspace's tree starts at; the empty string is the project. */\n baseDir: string;\n /** Advanced by every base-directory switch; a switch names the revision it was based on. */\n baseRevision: number;\n}"
4769
4783
  },
4784
+ {
4785
+ "name": "IProxyCapacityAnswer",
4786
+ "schema": {
4787
+ "type": "object",
4788
+ "properties": {
4789
+ "at": {
4790
+ "type": "string",
4791
+ "description": "When the proxy judged it, by its own clock."
4792
+ },
4793
+ "observedSince": {
4794
+ "type": "string",
4795
+ "description": "Since when the proxy observes its pools' provider 429s: its start."
4796
+ },
4797
+ "pools": {
4798
+ "type": "array",
4799
+ "items": {
4800
+ "$ref": "#/$defs/IProxyCapacityPool"
4801
+ }
4802
+ }
4803
+ },
4804
+ "required": [
4805
+ "at",
4806
+ "observedSince",
4807
+ "pools"
4808
+ ],
4809
+ "additionalProperties": false
4810
+ },
4811
+ "declaration": "interface IProxyCapacityAnswer {\n /** When the proxy judged it, by its own clock. */\n at: string;\n /** Since when the proxy observes its pools' provider 429s: its start. */\n observedSince: string;\n pools: IProxyCapacityPool[];\n}"
4812
+ },
4813
+ {
4814
+ "name": "IProxyCapacityMember",
4815
+ "schema": {
4816
+ "type": "object",
4817
+ "properties": {
4818
+ "accountId": {
4819
+ "type": "string",
4820
+ "description": "The account's id (64 hex characters)."
4821
+ },
4822
+ "plan": {
4823
+ "type": "string",
4824
+ "description": "Its plan as its held reading states it, one the pool counts."
4825
+ },
4826
+ "state": {
4827
+ "$ref": "#/$defs/TProxyCapacityMemberState"
4828
+ },
4829
+ "headroom": {
4830
+ "type": "number",
4831
+ "description": "The headroom it adds to the room now: its headroom below its threshold while it takes new work, else 0."
4832
+ },
4833
+ "binding": {
4834
+ "anyOf": [
4835
+ {
4836
+ "$ref": "#/$defs/IProxyCapacityWindow"
4837
+ },
4838
+ {
4839
+ "type": "null"
4840
+ }
4841
+ ],
4842
+ "description": "The window its headroom is bound by; `null` without a usable reading with a counted window."
4843
+ },
4844
+ "growsAt": {
4845
+ "type": [
4846
+ "string",
4847
+ "null"
4848
+ ],
4849
+ "description": "When the headroom it adds next grows, from its reading alone: the binding window's reset, or the moment it takes work again (a provider 429's rest, a provider refusal, its windows' resets); `null` when it cannot grow or that moment is unknown (a stale reading, a sign-in or payment problem)."
4850
+ },
4851
+ "growsTo": {
4852
+ "type": [
4853
+ "number",
4854
+ "null"
4855
+ ],
4856
+ "description": "The headroom it adds from `growsAt` on, at most; `null` with it."
4857
+ },
4858
+ "recheckAt": {
4859
+ "type": [
4860
+ "string",
4861
+ "null"
4862
+ ],
4863
+ "description": "When the account service reads an account it cannot judge now again, when it says; `null` otherwise."
4864
+ }
4865
+ },
4866
+ "required": [
4867
+ "accountId",
4868
+ "plan",
4869
+ "state",
4870
+ "headroom",
4871
+ "binding",
4872
+ "growsAt",
4873
+ "growsTo",
4874
+ "recheckAt"
4875
+ ],
4876
+ "additionalProperties": false,
4877
+ "description": "An account the pool counts: a subscription sign-in of a counted plan that has not lapsed."
4878
+ },
4879
+ "declaration": "/** An account the pool counts: a subscription sign-in of a counted plan that has not lapsed. */\ninterface IProxyCapacityMember {\n /** The account's id (64 hex characters). */\n accountId: string;\n /** Its plan as its held reading states it, one the pool counts. */\n plan: string;\n state: TProxyCapacityMemberState;\n /** The headroom it adds to the room now: its headroom below its threshold while it takes new work, else 0. */\n headroom: number;\n /** The window its headroom is bound by; `null` without a usable reading with a counted window. */\n binding: IProxyCapacityWindow | null;\n /**\n * When the headroom it adds next grows, from its reading alone: the binding window's reset, or the moment it takes\n * work again (a provider 429's rest, a provider refusal, its windows' resets); `null` when it cannot grow or that\n * moment is unknown (a stale reading, a sign-in or payment problem).\n */\n growsAt: string | null;\n /** The headroom it adds from `growsAt` on, at most; `null` with it. */\n growsTo: number | null;\n /** When the account service reads an account it cannot judge now again, when it says; `null` otherwise. */\n recheckAt: string | null;\n}"
4880
+ },
4881
+ {
4882
+ "name": "IProxyCapacityPool",
4883
+ "schema": {
4884
+ "type": "object",
4885
+ "properties": {
4886
+ "provider": {
4887
+ "$ref": "#/$defs/TProxyCapacityProvider"
4888
+ },
4889
+ "minHeadroom": {
4890
+ "type": "number"
4891
+ },
4892
+ "room": {
4893
+ "type": "number",
4894
+ "description": "The members' headroom summed, in percent."
4895
+ },
4896
+ "members": {
4897
+ "type": "array",
4898
+ "items": {
4899
+ "$ref": "#/$defs/IProxyCapacityMember"
4900
+ }
4901
+ },
4902
+ "last429At": {
4903
+ "type": [
4904
+ "string",
4905
+ "null"
4906
+ ],
4907
+ "description": "The newest provider 429 on a member the proxy saw since `observedSince`, or `null`."
4908
+ },
4909
+ "verdict": {
4910
+ "$ref": "#/$defs/TProxyCapacityVerdict"
4911
+ }
4912
+ },
4913
+ "required": [
4914
+ "provider",
4915
+ "minHeadroom",
4916
+ "room",
4917
+ "members",
4918
+ "last429At",
4919
+ "verdict"
4920
+ ],
4921
+ "additionalProperties": false
4922
+ },
4923
+ "declaration": "interface IProxyCapacityPool {\n provider: TProxyCapacityProvider;\n minHeadroom: number;\n /** The members' headroom summed, in percent. */\n room: number;\n members: IProxyCapacityMember[];\n /** The newest provider 429 on a member the proxy saw since `observedSince`, or `null`. */\n last429At: string | null;\n verdict: TProxyCapacityVerdict;\n}"
4924
+ },
4925
+ {
4926
+ "name": "IProxyCapacityRequest",
4927
+ "schema": {
4928
+ "type": "object",
4929
+ "properties": {
4930
+ "provider": {
4931
+ "$ref": "#/$defs/TProxyCapacityProvider"
4932
+ },
4933
+ "minHeadroom": {
4934
+ "type": "number"
4935
+ }
4936
+ },
4937
+ "additionalProperties": false,
4938
+ "description": "What is asked: one pool, or both when `provider` is absent, against `minHeadroom` (a non-negative integer)."
4939
+ },
4940
+ "declaration": "/** What is asked: one pool, or both when `provider` is absent, against `minHeadroom` (a non-negative integer). */\ninterface IProxyCapacityRequest {\n provider?: TProxyCapacityProvider;\n minHeadroom?: number;\n}"
4941
+ },
4942
+ {
4943
+ "name": "IProxyCapacityWindow",
4944
+ "schema": {
4945
+ "type": "object",
4946
+ "properties": {
4947
+ "name": {
4948
+ "type": "string",
4949
+ "description": "The provider's name for the window, or its length (`5h`, `7d`) for one without a name."
4950
+ },
4951
+ "durationSeconds": {
4952
+ "type": "number"
4953
+ },
4954
+ "usedPercent": {
4955
+ "type": "number",
4956
+ "description": "The percent its limit decides by: the account service's estimate between reads where it has one."
4957
+ },
4958
+ "estimated": {
4959
+ "type": "boolean",
4960
+ "description": "Whether `usedPercent` is that estimate."
4961
+ },
4962
+ "resetAt": {
4963
+ "type": [
4964
+ "string",
4965
+ "null"
4966
+ ],
4967
+ "description": "When its current period ends, as the reading states it; `null` when it states none."
4968
+ }
4969
+ },
4970
+ "required": [
4971
+ "name",
4972
+ "durationSeconds",
4973
+ "usedPercent",
4974
+ "estimated",
4975
+ "resetAt"
4976
+ ],
4977
+ "additionalProperties": false,
4978
+ "description": "A member's window, as its reading states it."
4979
+ },
4980
+ "declaration": "/** A member's window, as its reading states it. */\ninterface IProxyCapacityWindow {\n /** The provider's name for the window, or its length (`5h`, `7d`) for one without a name. */\n name: string;\n durationSeconds: number;\n /** The percent its limit decides by: the account service's estimate between reads where it has one. */\n usedPercent: number;\n /** Whether `usedPercent` is that estimate. */\n estimated: boolean;\n /** When its current period ends, as the reading states it; `null` when it states none. */\n resetAt: string | null;\n}"
4981
+ },
4770
4982
  {
4771
4983
  "name": "IReq_ControllerModelList",
4772
4984
  "declaration": "interface IReq_ControllerModelList extends implementsTR<\n ITypedRequest,\n IReq_ControllerModelList\n> {\n method: 'controller.model.list';\n request: { projectId?: string; sessionId?: TControllerSessionId };\n response: {\n models: TControllerModelOption[];\n /**\n * Per harness, the model a new conversation runs on when none is chosen: what the controller\n * sends for it. A harness without one is absent; it then runs its own default unnamed.\n */\n defaults: IControllerDefaultModel[];\n /**\n * The usable Flex accounts in the order AGL's account placement takes a new conversation now:\n * a model chosen without an account runs on the first of them that offers it.\n */\n flexAccountPlacement: string[];\n codexContext?: IControllerCodexContext;\n };\n}"
@@ -6494,6 +6706,118 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
6494
6706
  },
6495
6707
  "declaration": "/** Why Paint is unavailable for an incarnation or for the runtime. */\ntype TPaintUnavailableReason = 'not-selected' | 'sandbox' | 'sandbox-helper' | 'artifact-download' | 'artifact-integrity' | 'capture';"
6496
6708
  },
6709
+ {
6710
+ "name": "TProxyCapacityMemberState",
6711
+ "schema": {
6712
+ "type": "string",
6713
+ "enum": [
6714
+ "available",
6715
+ "reserved",
6716
+ "exhausted",
6717
+ "cooling",
6718
+ "unavailable"
6719
+ ],
6720
+ "description": "Whether a member takes new work now, as `agl proxy status` judges it, or why not."
6721
+ },
6722
+ "declaration": "/** Whether a member takes new work now, as `agl proxy status` judges it, or why not. */\ntype TProxyCapacityMemberState = 'available' | 'reserved' | 'exhausted' | 'cooling' | 'unavailable';"
6723
+ },
6724
+ {
6725
+ "name": "TProxyCapacityProvider",
6726
+ "schema": {
6727
+ "type": "string",
6728
+ "enum": [
6729
+ "anthropic",
6730
+ "openai"
6731
+ ],
6732
+ "description": "A pool: Claude accounts (`anthropic`) or ChatGPT accounts (`openai`)."
6733
+ },
6734
+ "declaration": "/** A pool: Claude accounts (`anthropic`) or ChatGPT accounts (`openai`). */\ntype TProxyCapacityProvider = 'anthropic' | 'openai';"
6735
+ },
6736
+ {
6737
+ "name": "TProxyCapacityVerdict",
6738
+ "schema": {
6739
+ "anyOf": [
6740
+ {
6741
+ "type": "object",
6742
+ "properties": {
6743
+ "state": {
6744
+ "type": "string",
6745
+ "const": "open"
6746
+ }
6747
+ },
6748
+ "required": [
6749
+ "state"
6750
+ ],
6751
+ "additionalProperties": false
6752
+ },
6753
+ {
6754
+ "type": "object",
6755
+ "properties": {
6756
+ "state": {
6757
+ "type": "string",
6758
+ "const": "wait"
6759
+ },
6760
+ "reason": {
6761
+ "$ref": "#/$defs/TProxyCapacityWaitReason"
6762
+ },
6763
+ "until": {
6764
+ "type": "string"
6765
+ },
6766
+ "seconds": {
6767
+ "type": "number"
6768
+ }
6769
+ },
6770
+ "required": [
6771
+ "state",
6772
+ "reason",
6773
+ "until",
6774
+ "seconds"
6775
+ ],
6776
+ "additionalProperties": false
6777
+ },
6778
+ {
6779
+ "type": "object",
6780
+ "properties": {
6781
+ "state": {
6782
+ "type": "string",
6783
+ "const": "wait"
6784
+ },
6785
+ "reason": {
6786
+ "$ref": "#/$defs/TProxyCapacityWaitReason"
6787
+ },
6788
+ "until": {
6789
+ "type": "null"
6790
+ },
6791
+ "seconds": {
6792
+ "type": "null"
6793
+ }
6794
+ },
6795
+ "required": [
6796
+ "state",
6797
+ "reason",
6798
+ "until",
6799
+ "seconds"
6800
+ ],
6801
+ "additionalProperties": false
6802
+ }
6803
+ ],
6804
+ "description": "`open`: the pool takes new work now. `wait`: not before `until`, `seconds` from the answer's `at`; both `null` when the members' readings foresee no moment the room reaches the minimum."
6805
+ },
6806
+ "declaration": "/**\n * `open`: the pool takes new work now. `wait`: not before `until`, `seconds` from the answer's `at`; both `null` when\n * the members' readings foresee no moment the room reaches the minimum.\n */\ntype TProxyCapacityVerdict =\n | { state: 'open' }\n | { state: 'wait'; reason: TProxyCapacityWaitReason; until: string; seconds: number }\n | { state: 'wait'; reason: TProxyCapacityWaitReason; until: null; seconds: null };"
6807
+ },
6808
+ {
6809
+ "name": "TProxyCapacityWaitReason",
6810
+ "schema": {
6811
+ "type": "string",
6812
+ "enum": [
6813
+ "room",
6814
+ "provider-429",
6815
+ "quiet-unobserved"
6816
+ ],
6817
+ "description": "Why a pool waits: too little room, a provider 429 within the quiet period, or a proxy that has not observed it long enough."
6818
+ },
6819
+ "declaration": "/** Why a pool waits: too little room, a provider 429 within the quiet period, or a proxy that has not observed it long enough. */\ntype TProxyCapacityWaitReason = 'room' | 'provider-429' | 'quiet-unobserved';"
6820
+ },
6497
6821
  {
6498
6822
  "name": "TTicketAutoLabel",
6499
6823
  "schema": {
@@ -59,6 +59,7 @@ const tickets: readonly TAglApiRole[] = ['session'];
59
59
  */
60
60
  export const aglApiMethods = {
61
61
  'agl.mcp.controller.status': { use: 'read' },
62
+ 'agl.mcp.proxy.capacity': { use: 'observe' },
62
63
  'agl.mcp.projects.list': { use: 'read' },
63
64
  'agl.mcp.sessions.list': { use: 'read' },
64
65
  'agl.mcp.session.read': { use: 'observe' },
@@ -9,6 +9,7 @@ import {
9
9
  controllerAuditEventTypes,
10
10
  type IControllerAuditEvent,
11
11
  type IControllerAuditRemoteEndpoint,
12
+ type IControllerAuditGateway,
12
13
  type IControllerAuditRemoteMove,
13
14
  type IControllerAuthDocument,
14
15
  type IControllerTempPasswordDocument,
@@ -396,13 +397,31 @@ const isAuditRemoteMove = (valueArg: unknown): valueArg is IControllerAuditRemot
396
397
  && isAuditRemoteEndpoint(valueArg.previous)
397
398
  && isAuditRemoteEndpoint(valueArg.target);
398
399
 
400
+ const isAuditGatewayText = (valueArg: unknown, maximumArg: number): valueArg is string => (
401
+ isNonEmptyString(valueArg) && valueArg.length <= maximumArg && !/[\0\r\n]/u.test(valueArg)
402
+ );
403
+
404
+ const isAuditGateway = (typeArg: string, valueArg: unknown): valueArg is IControllerAuditGateway => isPlainObject(valueArg)
405
+ && hasExactKeys(valueArg, ['gatewayUrl', 'gatewayClientId', 'appId', 'hostname', 'targetHost', 'targetPort', 'routeKey'],
406
+ typeArg === 'remote.gateway.sync' ? ['rotate'] : [])
407
+ && isAuditGatewayText(valueArg.gatewayUrl, 2048)
408
+ && isAuditGatewayText(valueArg.gatewayClientId, 128)
409
+ && isAuditGatewayText(valueArg.appId, 128)
410
+ && isAuditGatewayText(valueArg.hostname, 253)
411
+ && isAuditGatewayText(valueArg.targetHost, 253)
412
+ && isValidPort(valueArg.targetPort)
413
+ && isAuditGatewayText(valueArg.routeKey, 1024)
414
+ && (valueArg.rotate === undefined || typeof valueArg.rotate === 'boolean');
415
+
399
416
  /**
400
417
  * `details` on a type this release knows: only `remote.set` and `remote.unset` record a `remoteMove`, and only a move
401
- * from one canonical origin and RP ID to another.
418
+ * from one canonical origin and RP ID to another; only `remote.gateway.*` records a `gateway`.
402
419
  */
403
420
  const hasKnownAuditDetails = (typeArg: string, detailsArg: Record<string, unknown>): boolean =>
404
- !Object.hasOwn(detailsArg, 'remoteMove')
405
- || ((typeArg === 'remote.set' || typeArg === 'remote.unset') && isAuditRemoteMove(detailsArg.remoteMove));
421
+ (!Object.hasOwn(detailsArg, 'remoteMove')
422
+ || ((typeArg === 'remote.set' || typeArg === 'remote.unset') && isAuditRemoteMove(detailsArg.remoteMove)))
423
+ && (!Object.hasOwn(detailsArg, 'gateway')
424
+ || (typeArg.startsWith('remote.gateway.') && isAuditGateway(typeArg, detailsArg.gateway)));
406
425
 
407
426
  /**
408
427
  * A stored audit event. The log is shared with later releases, so a type this release does not know (a later
@@ -11,6 +11,7 @@ import { ControllerCodexOriginMigrationModel } from '../ts_migration/v29_codexor
11
11
  import { ControllerCodexConnectionStore } from './classes.codexconnectionstore.js';
12
12
  import { ControllerTrustedProxySecretModel } from './classes.trustedproxysecrets.js';
13
13
  import { ControllerDeviceModel, deleteControllerDevices } from './classes.controllerdevices.js';
14
+ import { ControllerGatewayClientModel } from './classes.gatewayclientstore.js';
14
15
  import { ControllerClaudeSessionStore } from './classes.claudesessionstore.js';
15
16
  import { ControllerClaudeSessionModel } from './classes.claudesessionmodels.js';
16
17
  import { ControllerPendingPromptStore } from './classes.pendingpromptstore.js';
@@ -807,6 +808,7 @@ const setAuthStoreModelManager = (
807
808
  plugins.nosqldb.setDefaultManagerForDoc(managerArg, ControllerTrackedConversationModel);
808
809
  plugins.nosqldb.setDefaultManagerForDoc(managerArg, ControllerTrustedProxySecretModel);
809
810
  plugins.nosqldb.setDefaultManagerForDoc(managerArg, ControllerDeviceModel);
811
+ plugins.nosqldb.setDefaultManagerForDoc(managerArg, ControllerGatewayClientModel);
810
812
  plugins.nosqldb.setDefaultManagerForDoc(
811
813
  managerArg,
812
814
  ControllerLegacyManagedSessionMigrationModel,
@@ -1097,6 +1099,7 @@ export class SmartDataAuthStore implements IAuthStore, IAuthStoreSessionIdentity
1097
1099
  await ControllerTrackedConversationModel.init();
1098
1100
  await ControllerTrustedProxySecretModel.init();
1099
1101
  await ControllerDeviceModel.init();
1102
+ await ControllerGatewayClientModel.init();
1100
1103
  // `moveRuntimeConfig` changes the configuration and deletes the paired devices in one transaction.
1101
1104
  await ControllerAuthModel.exact.prepare();
1102
1105
  await ControllerDeviceModel.exact.prepare();
@@ -1932,7 +1935,7 @@ export class SmartDataAuthStore implements IAuthStore, IAuthStoreSessionIdentity
1932
1935
  ...(eventArg.senderLabel === undefined ? {} : { senderLabel: eventArg.senderLabel }),
1933
1936
  ...(eventArg.localCli === undefined ? {} : { localCli: { ...eventArg.localCli } }),
1934
1937
  ...(eventArg.details === undefined ? {} : {
1935
- details: {
1938
+ details: 'remoteMove' in eventArg.details ? {
1936
1939
  remoteMove: {
1937
1940
  previous: {
1938
1941
  publicOrigin: eventArg.details.remoteMove.previous.publicOrigin,
@@ -1943,6 +1946,17 @@ export class SmartDataAuthStore implements IAuthStore, IAuthStoreSessionIdentity
1943
1946
  rpId: eventArg.details.remoteMove.target.rpId,
1944
1947
  },
1945
1948
  },
1949
+ } : {
1950
+ gateway: {
1951
+ gatewayUrl: eventArg.details.gateway.gatewayUrl,
1952
+ gatewayClientId: eventArg.details.gateway.gatewayClientId,
1953
+ appId: eventArg.details.gateway.appId,
1954
+ hostname: eventArg.details.gateway.hostname,
1955
+ targetHost: eventArg.details.gateway.targetHost,
1956
+ targetPort: eventArg.details.gateway.targetPort,
1957
+ routeKey: eventArg.details.gateway.routeKey,
1958
+ ...(eventArg.details.gateway.rotate === undefined ? {} : { rotate: eventArg.details.gateway.rotate }),
1959
+ },
1946
1960
  },
1947
1961
  }),
1948
1962
  };