agl 40.5.0 → 40.6.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 (95) hide show
  1. package/changelog.md +16 -0
  2. package/dist_serve/bundle.js +598 -598
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_ts/00_commitinfo_data.js +1 -1
  5. package/dist_ts/aglapi/aglapisurface.document.js +2 -2
  6. package/dist_ts/classes.aglhome.d.ts +5 -0
  7. package/dist_ts/classes.aglhome.js +2 -1
  8. package/dist_ts/classes.authstore.js +5 -1
  9. package/dist_ts/classes.controller.js +11 -2
  10. package/dist_ts/classes.inferencegateway.d.ts +35 -1
  11. package/dist_ts/classes.inferencegateway.js +86 -26
  12. package/dist_ts/classes.inferenceservice.d.ts +4 -2
  13. package/dist_ts/classes.inferenceservice.js +5 -4
  14. package/dist_ts/classes.proxycontrol.d.ts +58 -4
  15. package/dist_ts/classes.proxycontrol.js +23 -44
  16. package/dist_ts/classes.proxycontrolclient.d.ts +15 -5
  17. package/dist_ts/classes.proxycontrolclient.js +67 -17
  18. package/dist_ts/classes.proxydaemon.d.ts +22 -3
  19. package/dist_ts/classes.proxydaemon.js +73 -12
  20. package/dist_ts/classes.proxyleaseholder.d.ts +43 -14
  21. package/dist_ts/classes.proxyleaseholder.js +66 -22
  22. package/dist_ts/classes.proxystore.d.ts +9 -0
  23. package/dist_ts/classes.proxystore.js +15 -7
  24. package/dist_ts/classes.workercallerbindings.d.ts +66 -0
  25. package/dist_ts/classes.workercallerbindings.js +211 -0
  26. package/dist_ts/classes.workercallers.d.ts +63 -2
  27. package/dist_ts/classes.workercallers.js +430 -65
  28. package/dist_ts/fleet/classes.workerlaunches.d.ts +12 -5
  29. package/dist_ts/fleet/classes.workerlaunches.js +25 -19
  30. package/dist_ts/fleet/classes.workers.d.ts +17 -0
  31. package/dist_ts/fleet/classes.workers.js +74 -1
  32. package/dist_ts/functions.inferencecli.d.ts +3 -2
  33. package/dist_ts/functions.inferencecli.js +67 -5
  34. package/dist_ts/functions.inferencecliarguments.d.ts +6 -2
  35. package/dist_ts/functions.inferencecliarguments.js +29 -2
  36. package/dist_ts/functions.inferencelaunch.d.ts +24 -0
  37. package/dist_ts/functions.inferencelaunch.js +42 -2
  38. package/dist_ts/functions.proxycontract.d.ts +11 -0
  39. package/dist_ts/functions.proxycontract.js +12 -1
  40. package/dist_ts/functions.proxysocket.d.ts +6 -0
  41. package/dist_ts/functions.proxysocket.js +46 -0
  42. package/dist_ts/functions.workerprocessproof.d.ts +6 -0
  43. package/dist_ts/functions.workerprocessproof.js +28 -4
  44. package/dist_ts_authswitch/authority-contract.d.ts +30 -5
  45. package/dist_ts_authswitch/authority-contract.js +7 -1
  46. package/dist_ts_authswitch/classes.authoritycli.js +6 -2
  47. package/dist_ts_authswitch/classes.authorityclient.js +15 -5
  48. package/dist_ts_authswitch/classes.claudenative.d.ts +7 -1
  49. package/dist_ts_authswitch/classes.claudenative.js +21 -6
  50. package/dist_ts_authswitch/classes.claudesignin.d.ts +14 -2
  51. package/dist_ts_authswitch/classes.claudesignin.js +68 -22
  52. package/dist_ts_authswitch/classes.codexmanaged.d.ts +8 -0
  53. package/dist_ts_authswitch/classes.codexmanaged.js +33 -18
  54. package/dist_ts_authswitch/classes.harnessprocesses.d.ts +8 -0
  55. package/dist_ts_authswitch/classes.harnessprocesses.js +41 -9
  56. package/dist_ts_interfaces/interfaces.d.ts +1 -1
  57. package/dist_ts_interfaces/interfaces.js +1 -1
  58. package/dist_ts_interfaces/workercallers.d.ts +43 -4
  59. package/package.json +1 -1
  60. package/readme.md +103 -14
  61. package/ts/00_commitinfo_data.ts +1 -1
  62. package/ts/aglapi/aglapisurface.document.ts +2 -2
  63. package/ts/classes.aglhome.ts +6 -0
  64. package/ts/classes.authstore.ts +4 -0
  65. package/ts/classes.controller.ts +10 -1
  66. package/ts/classes.inferencegateway.ts +104 -23
  67. package/ts/classes.inferenceservice.ts +6 -3
  68. package/ts/classes.proxycontrol.ts +76 -39
  69. package/ts/classes.proxycontrolclient.ts +72 -20
  70. package/ts/classes.proxydaemon.ts +85 -15
  71. package/ts/classes.proxyleaseholder.ts +84 -28
  72. package/ts/classes.proxystore.ts +16 -5
  73. package/ts/classes.workercallerbindings.ts +147 -0
  74. package/ts/classes.workercallers.ts +410 -59
  75. package/ts/fleet/classes.workerlaunches.ts +23 -15
  76. package/ts/fleet/classes.workers.ts +51 -1
  77. package/ts/functions.inferencecli.ts +61 -7
  78. package/ts/functions.inferencecliarguments.ts +32 -1
  79. package/ts/functions.inferencelaunch.ts +49 -2
  80. package/ts/functions.proxycontract.ts +12 -0
  81. package/ts/functions.proxysocket.ts +39 -0
  82. package/ts/functions.workerprocessproof.ts +27 -4
  83. package/ts_authswitch/authority-contract.ts +34 -5
  84. package/ts_authswitch/classes.authoritycli.ts +5 -1
  85. package/ts_authswitch/classes.authorityclient.ts +25 -9
  86. package/ts_authswitch/classes.claudenative.ts +23 -7
  87. package/ts_authswitch/classes.claudesignin.ts +70 -23
  88. package/ts_authswitch/classes.codexmanaged.ts +30 -16
  89. package/ts_authswitch/classes.harnessprocesses.ts +39 -8
  90. package/ts_authswitch/native-contracts.md +1 -1
  91. package/ts_interfaces/interfaces.ts +1 -1
  92. package/ts_interfaces/workercallers.ts +32 -4
  93. package/ts_web/00_commitinfo_data.ts +1 -1
  94. package/ts_web/accounts.plugins.ts +5 -1
  95. package/ts_web/classes.accountsreadmodel.ts +4 -1
@@ -4,6 +4,8 @@ export declare const workerCallerLaunchGenerationEnvironmentVariable = "AGL_MCP_
4
4
  export interface IFleetWorkerCallerLaunchBase {
5
5
  launchId: string;
6
6
  projectId: string;
7
+ /** The fleet worker the launch identifies, `${projectId}:${name}`: a worker holds one current launch. */
8
+ workerId: string;
7
9
  }
8
10
  /**
9
11
  * The Codex app-server connection that created the worker's thread: a controller connection profile, or the fleet's
@@ -28,12 +30,18 @@ export interface IFleetClaudeProcess {
28
30
  pid: number;
29
31
  startTicks: string;
30
32
  }
31
- export type TFleetWorkerCallerBinding = IFleetWorkerCallerLaunchBase & {
33
+ export type TFleetWorkerCallerBinding = Omit<IFleetWorkerCallerLaunchBase, 'workerId'> & {
32
34
  nativeSessionId: string;
33
35
  expectedBindingRevision: number;
34
- } & ({
36
+ } & (
37
+ /**
38
+ * A Claude launch binds to its background job and to the job's current process; a job whose process already exited
39
+ * binds without one, and the next process of the same job proves itself when its bridge enrolls.
40
+ */
41
+ {
35
42
  harnessId: 'claude';
36
- claudeProcess: IFleetClaudeProcess;
43
+ claudeJobId: string;
44
+ claudeProcess?: IFleetClaudeProcess;
37
45
  } | {
38
46
  harnessId: 'codex';
39
47
  });
@@ -58,11 +66,42 @@ export interface IFleetWorkerCallerHooks {
58
66
  ticketSessionId: string;
59
67
  }>;
60
68
  getWorkerCallerStatus(launchId: string): IWorkerCallerReadiness;
61
- revokeWorkerCaller(request: {
69
+ /**
70
+ * Revokes one launch, or the current launch of a worker, also one the controller kept from before a restart. Every
71
+ * reason but `generation_change` revokes it for good: its kept binding is deleted with it.
72
+ */
73
+ revokeWorkerCaller(request: ({
62
74
  launchId: string;
75
+ } | {
76
+ workerId: string;
77
+ }) & {
63
78
  reason: 'failure' | 'stop' | 'replacement' | 'generation_change' | 'cancelled';
64
79
  }): Promise<void>;
65
80
  }
81
+ /** The background job a Claude worker's launch is bound to, as the controller asks the fleet about it. */
82
+ export interface IWorkerClaudeJobRequest {
83
+ workerId: string;
84
+ projectId: string;
85
+ nativeSessionId: string;
86
+ jobId: string;
87
+ }
88
+ /**
89
+ * What a fresh Claude inventory shows of that job: `running` in one process, `settled` without a process, `ended` for
90
+ * this worker (the worker is gone or archived, continues in another session, or the session continues as another job),
91
+ * or `unproven` when the registry or the inventory could not be read or did not list the session once.
92
+ */
93
+ export type TWorkerClaudeJobObservation = {
94
+ state: 'running';
95
+ process: IFleetClaudeProcess;
96
+ } | {
97
+ state: 'settled';
98
+ } | {
99
+ state: 'ended';
100
+ reason: string;
101
+ } | {
102
+ state: 'unproven';
103
+ reason: string;
104
+ };
66
105
  export interface IWorkerCallerSubject {
67
106
  kind: 'worker_launch';
68
107
  launchId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agl",
3
- "version": "40.5.0",
3
+ "version": "40.6.0",
4
4
  "controllerUpgradeManagementVersion": 2,
5
5
  "private": false,
6
6
  "description": "Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions",
package/readme.md CHANGED
@@ -194,7 +194,7 @@ Codex renews the login of the account it runs on, and a login has one renewer, s
194
194
 
195
195
  **New Claude terminals** above the list says what new Claude terminals of AGL run on, and switches it: Claude Code's own configuration (which AGL Configuration's **Inference** section can route through the proxy's Claude accounts), or ChatGPT models through the AGL proxy, which routes them across its ChatGPT accounts and moves a conversation to another account when one runs out (the `claudeTerminals` controller setting, `controller.settings.update { claudeTerminals: 'claude_code' | 'chatgpt' }`). Terminals already created keep what they were created with. No account row chooses Claude Code any more. See [Claude chats on ChatGPT models](#claude-chats-on-chatgpt-models).
196
196
 
197
- **Add Claude account** starts a Claude sign-in in the accounts service: it makes a private Claude Code home for it and names the command that signs Claude Code in there. The sign-in waits above the list with that command, **Open in a terminal**, which closes Settings and runs the command in a new terminal of the project in view, and **Cancel sign-in**. Once Claude Code signed in, the service takes the login over -- it is the login's only renewer from then on -- and the new account appears in the list; the screen says how the sign-in ended. **Add Codex's current sign-in** adds the account Codex on this host is already signed in to, once (the `codex_native` source of the service's import inventory): the service manages Codex's sign-in from then on and can switch it, and Codex keeps renewing its own login. The service restarts Codex's app-server to prove the sign-in. It is offered until the service manages Codex's sign-in on this host.
197
+ **Add Claude account** starts a Claude sign-in in the accounts service: it makes a private Claude Code home for it and names the command that signs Claude Code in there. The sign-in waits above the list with that command, **Open in a terminal**, which closes Settings and runs the command in a new terminal of the project in view, and **Cancel sign-in**. Once Claude Code signed in, the service takes the login over -- it is the login's only renewer from then on -- and the new account appears in the list; the screen says how the sign-in ended. The service takes the login only while no Claude Code process may still write to the sign-in home: one running on it, or one it could not inspect that started after the sign-in did (a process that started earlier cannot name the home; one whose working directory was deleted is still matched by the home and credential store it names by absolute path). Until then the sign-in says that Claude Code signed in and names those processes by pid; one still held after fifteen minutes ends without adding the login and names them again. **Add Codex's current sign-in** adds the account Codex on this host is already signed in to, once (the `codex_native` source of the service's import inventory): the service manages Codex's sign-in from then on and can switch it, and Codex keeps renewing its own login. The service restarts Codex's app-server to prove the sign-in. It is offered until the service manages Codex's sign-in on this host.
198
198
 
199
199
  **Claude Code on this host**, below **New Claude terminals**, says what Claude Code's own home on this host holds (`controller.accounts.claude.host.get`, the service's `claude.host` read) and offers the one action it calls for, each confirmed with what it does first. Claude Code is not switched between accounts: once AGL Configuration routes it through the AGL proxy, its own sign-in is handed to AGL with **Hand to AGL** (`controller.accounts.claude.release { operationId, accountId, loginId, endNativeSessions }`, naming the account and sign-in the read named) -- the sign-in an earlier AGL adopted moves into the service's custody, and a sign-in of an account the service already renews is signed out of Claude Code's files, which keep everything else. Before Claude Code is routed the hand-over waits and **Open Inference settings** opens AGL Configuration on its Inference section. A Claude Code process that started before the routing may still use the sign-in: the screen names it by pid and start, and **Hand to AGL and end their sign-in** hands it over anyway, after saying those processes fail at their next request until restarted. A Claude Code process on a release whose credential handling AGL has not verified (2.1.280 to 2.1.282, 2.1.288, the one AGL's own Claude chats run through the Agent SDK, and 2.1.306 are; a newer release, a remote agent's build such as `2.1.295-8b2928c330c4` or another Agent SDK's build is not yet) blocks the hand-over, also when its sign-in would be ended: the screen names each such process by pid, start and release, to be closed or restarted on a verified release first. A process counts as running on the home when its credential store is there, also when `CLAUDE_SECURESTORAGE_CONFIG_DIR` puts it there from another configuration directory; one configured on the home whose store is elsewhere blocks the hand-over too. A sign-in an earlier AGL adopted that can no longer be handed over -- the service holds it after a hand-over or switch it could not settle, or Claude Code's files now hold another account, none, or no readable one -- is **Repair**ed instead (`controller.accounts.claude.repair { operationId }`): the service forgets it, leaves Claude Code's files as they are, and the adopted account needs a new sign-in unless a renewal the held hand-over kept is confirmed by the provider. The browser names each hand-over and repair by an operation id of its own, so one whose answer is lost is read again by it: a hand-over with `controller.accounts.claude.release.get`, a repair by sending it again with the same id, which the service answers with the repair it committed; both are recorded in AGL's audit trail (`accounts.claude.release`, `accounts.claude.repair`). While Claude Code renews an adopted sign-in in its routed home, its usage is not read, and its row says so.
200
200
 
@@ -328,6 +328,8 @@ agl proxy run codex --model <catalog-model> -- exec 'Explain this repository'
328
328
  agl proxy run claude -- # Claude Code on Claude accounts
329
329
  agl proxy run claude --provider openai --model <catalog-model> --
330
330
  agl proxy run opencode --model <catalog-model> -- run 'Explain this repository'
331
+ agl proxy confined run -- docker run --rm --user "$(id -u):$(id -g)" -i <image> claude -p # Claude Code in a container
332
+ agl proxy confined end <run id>
331
333
  ```
332
334
 
333
335
  Every client -- `codex`, `claude`, `opencode`, or a name of your own -- has one credential. The proxy keeps it
@@ -434,7 +436,8 @@ pool and keeps its credential. `agl proxy run claude` uses Claude accounts unles
434
436
  ChatGPT models behind Claude Code; `run codex` and `run opencode` use ChatGPT accounts.
435
437
 
436
438
  The listener binds only `127.0.0.1` and requires the exact host and port, no browser Origin, and
437
- `Authorization: Bearer <credential>` (or `x-api-key`).
439
+ `Authorization: Bearer <credential>` (or `x-api-key`). Claude Code in a container reaches the proxy through a second
440
+ listener, a Unix socket that serves confined runs alone (see [Confined containers](#confined-containers)).
438
441
 
439
442
  - A ChatGPT pool serves `/openai/v1/responses` and `/openai/v1/models` (the pooled Codex catalog in Codex's
440
443
  own shape when Codex names its `client_version`), and `/anthropic/v1/messages` and `/anthropic/v1/models`
@@ -701,6 +704,65 @@ proxy's binding with it, and the sessions it served move at their next request.
701
704
  pool, 16 requests in flight per session, 256 per client credential, 512 in all, 32 MiB per request and 8 MiB
702
705
  per inspected response event (or non-streaming JSON response).
703
706
 
707
+ #### Confined containers
708
+
709
+ `agl proxy confined run` runs Claude Code in a Docker container that reaches AGL through one route only: the proxy's
710
+ confined listener, a Unix socket alone in a directory of its own (`agl-proxy-confined/proxy.sock` beside the proxy's
711
+ control socket; `agl proxy status` names it). The listener serves the Claude pool's three endpoints Claude Code uses --
712
+ `GET /anthropic/v1/models`, `POST /anthropic/v1/messages` and `POST /anthropic/v1/messages/count_tokens` -- exactly as
713
+ the loopback listener serves a Claude client, and refuses every other path, method and pool with 404 before anything is
714
+ read or routed; nothing else of AGL is reachable through it. It accepts confined runs' credentials alone: a request
715
+ without a credential, with one the proxy does not know, or with a credential of the loopback listener (any client's or
716
+ lease's) is refused with 401, and a confined run's credential is refused on the loopback listener alike.
717
+
718
+ ```sh
719
+ agl proxy confined run -- docker run --rm --user "$(id -u):$(id -g)" -i <image> \
720
+ claude -p --model claude-opus-5-5 --output-format json < prompt.txt
721
+ agl proxy status # names the confined listener and lists the runs by id
722
+ agl proxy confined end <run id> # ends a run's credential at once
723
+ ```
724
+
725
+ Before the container starts, the command asks the proxy for the run's credential: one for this run alone, a lease of
726
+ the Claude pool (the Claude accounts first, then the Anthropic API keys) whose sessions are those of the client
727
+ `confined`, so its requests are placed, moved and counted (token usage under `confined`) like any other Claude
728
+ client's. Right after `docker run` it adds the listener's directory as a read-only mount at `/run/agl-proxy` and what
729
+ Claude Code inside needs to reach it, each variable passed by name so the credential appears on no command line:
730
+
731
+ - `ANTHROPIC_UNIX_SOCKET=/run/agl-proxy/proxy.sock`: Claude Code sends its API requests through the socket, as plain
732
+ HTTP, so no relay runs in the container (Claude Code's own setting, which `claude ssh` uses; verified with Claude Code
733
+ 2.1.288, the release of AGL's Agent SDK);
734
+ - `ANTHROPIC_BASE_URL=http://localhost/anthropic`: the path Claude Code puts on its requests; the host is not used;
735
+ - `ANTHROPIC_AUTH_TOKEN`: the run's credential;
736
+ - `CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1` and `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`, as `agl proxy run
737
+ claude` sets them.
738
+
739
+ It prints the run's id on standard error (`AGL proxy confined run <id>: …`), passes its standard input and output
740
+ through, and exits with the container's status. The container never receives an account token, the control socket or
741
+ any other part of the AGL home: the mount holds the socket alone, and the variables that would give Claude Code another
742
+ login or route (`CLAUDE_CODE_OAUTH_TOKEN`, `ANTHROPIC_API_KEY`, …) are removed from the environment `docker` runs with,
743
+ so a `-e NAME` of one of them passes nothing. What the launcher names itself after `docker run` is its own: it must not
744
+ set the variables above. The command takes `docker run` and `docker container run` only, with the image and its
745
+ command after the options.
746
+
747
+ The socket and its directory are the proxy user's alone (0600 and 0700), so the container's processes connect as that
748
+ user: `--user` with its uid and gid under a Docker daemon that runs as root, or the container's own root under rootless
749
+ Docker, which maps it to that user; another uid, or a container whose user namespace maps it elsewhere, cannot connect.
750
+ Root in a container of a rootful daemon connects as well while it keeps Docker's default capabilities, since
751
+ `CAP_DAC_OVERRIDE` passes the socket's mode (with `--cap-drop ALL` it is refused): the mode keeps the host's other users
752
+ out, and only the containers a run started have the mount at all. The directory, not the socket file, is mounted, so a
753
+ proxy restart, which replaces the socket, does not cut the container off.
754
+
755
+ The credential lives as long as the command. When the container exits the command ends it, and the proxy refuses it
756
+ from then on and forgets it. Like a lease it survives a restart of the proxy, which keeps only its SHA-256 digest and
757
+ serves it again at once while the command takes it back. `agl proxy confined end <run id>` ends it at once: requests in
758
+ flight end, the next one is refused, and the command stops the container (`docker run` passes its SIGTERM on) and exits
759
+ with the reason; it does the same when the proxy does not hand the credential back after a restart.
760
+
761
+ Downgrade: an earlier proxy refuses to start while its store keeps a confined run's credential, which its check of the
762
+ kept leases does not know. Let every confined run end before downgrading; if an earlier proxy's start already failed,
763
+ start this release once with no confined run going and wait out the 60-second reclaim window, which ends the kept
764
+ credential, then downgrade.
765
+
704
766
  ## Native Codex Harness
705
767
 
706
768
  Choose **New → Chat session** and pick the Codex harness to use Codex inside AGL. Native threads support text and reasoning streaming, tool activity, the Codex model and reasoning-effort catalog, command and file approvals, ordinary user-input questions, interruption, history pagination, rename, archive, and deletion. AGL Ask/Yolo controls apply to the exact pending native approval request; approvals never outlive its server request.
@@ -1737,11 +1799,12 @@ superseded origins refuse preparation.
1737
1799
  - Revoke on failure, stop, replacement, cancellation or controller-generation change.
1738
1800
  Revocation fences new admissions immediately, removes credentials, and waits for already
1739
1801
  admitted ticket requests. Native-ID uniqueness and binding revision checks fence races.
1740
- Controller restart invalidates every old handle; existing native workers remain
1741
- unidentified until fleet performs an authorized controlled resume/relaunch with a fresh
1742
- overlay. Hooks do not automatically terminate or adopt outside sessions. Revoked launch IDs
1743
- stay recorded so they are never prepared again; the oldest give way once 65,536 launches
1744
- are recorded.
1802
+ Controller restart invalidates every credential. A Claude launch's binding to its job
1803
+ outlives it (below); a Codex launch does not, and its worker is bound again at its next
1804
+ steer. Every reason but a controller-generation change revokes a launch for good and
1805
+ deletes its kept binding. Hooks do not automatically terminate or adopt outside sessions.
1806
+ Revoked launch IDs stay recorded so they are never prepared again; the oldest give way
1807
+ once 65,536 launches are recorded.
1745
1808
 
1746
1809
  Fleet workers use these hooks themselves, so a worker's MCP ticket writes are admitted as
1747
1810
  that worker, not as the driver or anonymously:
@@ -1753,16 +1816,40 @@ that worker, not as the driver or anonymously:
1753
1816
  the worker id), passed as `--mcp-config <file> -- <prompt>`. Claude Code saves that path and reads it
1754
1817
  again at every wake, so the fleet rewrites it before each one; the launch ID and
1755
1818
  generation reach only the `agl` MCP server's environment, never the Claude process's.
1756
- Once the agents listing shows the job's process, the fleet binds the launch to it. A start,
1757
- wake or relaunch that fails at any step revokes its launch. Stop revokes the launch and archive removes the overlay. A start fails closed before Claude
1758
- runs when the Configuration master has no `agl` MCP server.
1819
+ Once the agents listing shows the job's process, the fleet binds the launch to the job and
1820
+ that process; a job that already settled after a quick turn is bound without a process. A
1821
+ start, wake or relaunch that fails at any step revokes its launch. Stop revokes the launch
1822
+ and archive also removes the overlay. A start fails closed before Claude runs when the
1823
+ Configuration master has no `agl` MCP server.
1759
1824
  - Fleet Codex workers prepare the launch on the fleet's own connection before
1760
1825
  `thread/start` and bind it before the first `turn/start`. Before steering a thread whose
1761
1826
  launch is unbound, from an earlier connection or from before a controller restart, the
1762
1827
  fleet loads the thread and binds a fresh launch; a refusal fails the steer undispatched.
1763
- - Launches live in memory. After a controller restart a Claude worker stays unidentified
1764
- until its next fleet start, steer or resume, and a Codex worker is bound again at its next
1765
- steer.
1828
+ - A Claude launch belongs to its background job, not to one process. Claude Code retires an
1829
+ idle job's process and starts a new one for the same job when someone writes to it in
1830
+ Claude Code; that process reads the same overlay. The controller keeps each Claude
1831
+ launch's binding in its store (`agl_worker_caller_bindings`, one record per worker:
1832
+ digests of the launch ID and generation, the job and session IDs, the binding revision, the
1833
+ proved process's PID, start and snapshot digest, and the approved bridge command; never a
1834
+ credential). When a bridge enrolls under another process than the bound one, or after a
1835
+ controller restart, the fleet reads a fresh Claude inventory (one read at a time) and the
1836
+ launch is bound to the bridge's process only when the inventory lists the worker's session,
1837
+ once, as the same background job in exactly that process, the process runs the approved
1838
+ Claude Code executable, and the bridge is its direct child running the recorded command
1839
+ over its own connection. A launch a restarted controller restores is proved the same way
1840
+ before its first write, also when its process still runs. Every other process stays
1841
+ unverified, and a refused bridge is not proved again at every call: for the life of that
1842
+ process image, or for five seconds when the job showed no process yet, the inventory could
1843
+ not be read, or the inventory still named another process for the job (Claude Code may just
1844
+ have replaced it).
1845
+ When the inventory shows the worker's session as another job, or the fleet no longer binds
1846
+ the worker to it (archived, moved to another session), the launch is revoked for good.
1847
+ An upgrade moves every bridge in place onto the new build (`process.execve`: the same PID and
1848
+ start, a new image from the new install's path), and the image it became is proved afresh:
1849
+ its command is the one recorded with the launch or the one the restarted controller resolves
1850
+ itself from its configured `agl` MCP entry, never one the bridge names, and a new command is
1851
+ kept with the binding's next revision. Each reason an enrollment stays unverified is written once to the controller log,
1852
+ naming the worker and its session, never the launch ID or a credential.
1766
1853
 
1767
1854
  The bridge exchanges credentials only through the private controller endpoint after Linux
1768
1855
  direct-loopback socket-inode ownership, approved executable/argv and current native
@@ -2860,6 +2947,8 @@ Backend isolation is mandatory. Proxy mode binds the controller to all interface
2860
2947
  - Permission auto-accept is an explicit server policy, never an assumption based on an open browser.
2861
2948
  - Questions are never auto-answered.
2862
2949
  - Unknown, malformed, concurrent, or unverifiable lifecycle state fails closed.
2950
+ - The inference proxy's confined listener is a Unix socket of the proxy's user alone; it accepts only confined runs'
2951
+ credentials and serves them only the Claude pool's three Claude Code endpoints.
2863
2952
 
2864
2953
  The global **auto-accept permissions (yolo)** setting replies once to pending permissions across registered projects and writes those replies to the audit log. Each conversation also has a run-local Ask/Yolo switch. For an active managed OpenCode root, that switch covers its currently active direct children under the same exact family authority. For an active managed Flex root, it covers admitted descendants through their exact active parent-run authority chain; a relationship alone grants nothing. Terminal children are never auto-accepted. Disabling either policy seals new automatic replies and drains already admitted replies before returning. Neither mode creates persistent broad provider grants.
2865
2954
 
@@ -2910,7 +2999,7 @@ A run that fails keeps its evidence before its root goes: when a test of the fil
2910
2999
  The suite guards, end to end: opening every harness's conversation across page reloads without a harness child being replaced, recovering the Flex child after `SIGKILL` within 15 seconds, rejoining the shared Codex daemon on its own after that daemon restarts (the conversation opens and answers again within one rejoin backoff step, without **Reconnect**), starting the controller again (as the same and as the next build) with a browser resource attached to a Codex, Flex and OpenCode chat, listing a project's resources right after a browser is attached to each new chat and after a restart, the Flex model list carrying the account's current catalog, a Flex conversation answering, and opening and answering again after a restart, in a project whose id begins with `-` or `_` (the file creates projects until one does), and an `agl mcp` bridge answering tool calls from the same process after the controller moves to the next build. It is the test step of `gitzone release` (`release.preflight` in `.smartconfig.json`) and takes about eight minutes.
2911
3000
 
2912
3001
 
2913
- Host prerequisites: Linux, Chrome (`google-chrome`, `chromium` or `chromium-browser`), `openssl`, `ss` (iproute2, to name the process behind a refused connection) and `codex` 0.156.0 or newer on `PATH`. Set `AGL_E2E_PACKAGE_ROOT` to another installed and built checkout, for example an earlier release, to run a scenario against it and prove it fails there:
3002
+ Host prerequisites: Linux, Chrome (`google-chrome`, `chromium` or `chromium-browser`), `openssl`, `ss` (iproute2, to name the process behind a refused connection) and `codex` 0.156.0 or newer on `PATH`. `e2e.proxyconfined` also runs a Docker container (a daemon this user may use and the `ubuntu:24.04` image already on the host, which the case never pulls) and skips with the missing prerequisite named without them. Set `AGL_E2E_PACKAGE_ROOT` to another installed and built checkout, for example an earlier release, to run a scenario against it and prove it fails there:
2914
3003
 
2915
3004
  ```sh
2916
3005
  AGL_E2E_PACKAGE_ROOT=/path/to/agl-32.15.1 pnpm exec tsrepo test test/e2e/e2e.conversations.node.ts --verbose --timeout 900
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '40.5.0',
6
+ version: '40.6.0',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }
@@ -3783,7 +3783,7 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
3783
3783
  },
3784
3784
  "protocolVersion": {
3785
3785
  "type": "number",
3786
- "const": 44
3786
+ "const": 45
3787
3787
  },
3788
3788
  "upgradeManagementVersion": {
3789
3789
  "type": "number"
@@ -3905,7 +3905,7 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
3905
3905
  ],
3906
3906
  "additionalProperties": false
3907
3907
  },
3908
- "declaration": "interface IControllerStatus {\n packageName: string;\n packageVersion: string;\n protocolVersion: 44;\n upgradeManagementVersion: number;\n controllerPid: number;\n processGroupId: number;\n processFingerprint: string;\n processMode: TControllerProcessMode;\n lifecycleState: TControllerLifecycleState;\n startedAt: number;\n setupRequired: boolean;\n /** Present when the controller runs as the systemd user unit (`agl service install`); absent for a detached or foreground one. */\n serviceUnit?: \"agl-controller.service\";\n /** The TLS mode of the runtime configuration the controller runs with; absent until it is resolved. */\n tlsMode?: TControllerTlsMode;\n upgrade?: IControllerUpgradeStatus;\n /** AGL's inference proxy, by state only; details need a signed-in owner (`controller.proxy.status.get`). */\n proxy?: { state: TControllerProxyState };\n harnesses: Array<{\n harnessId: TControllerSessionHarnessId;\n pid?: number;\n state: TControllerHarnessLifecycleState;\n healthy: boolean;\n version?: string;\n supportsLocalAttachments?: boolean;\n connectionMode?: 'local' | 'shared' | 'remote';\n diagnostic?: IControllerCodexDiagnostic;\n /** Codex only: automatic reconnection of this entry's profile to the local shared app-server. */\n rejoin?: IControllerCodexRejoinStatus;\n /**\n * Codex only, on the controller status: every connected or required profile. The entry's\n * `healthy` is then true only when each of them is, apart from a profile on an account Codex\n * cannot run on now, listed `stopped` with an `account_unavailable` diagnostic that says why;\n * its other members describe the default profile.\n */\n profiles?: IControllerCodexProfileStatus[];\n }>;\n}"
3908
+ "declaration": "interface IControllerStatus {\n packageName: string;\n packageVersion: string;\n protocolVersion: 45;\n upgradeManagementVersion: number;\n controllerPid: number;\n processGroupId: number;\n processFingerprint: string;\n processMode: TControllerProcessMode;\n lifecycleState: TControllerLifecycleState;\n startedAt: number;\n setupRequired: boolean;\n /** Present when the controller runs as the systemd user unit (`agl service install`); absent for a detached or foreground one. */\n serviceUnit?: \"agl-controller.service\";\n /** The TLS mode of the runtime configuration the controller runs with; absent until it is resolved. */\n tlsMode?: TControllerTlsMode;\n upgrade?: IControllerUpgradeStatus;\n /** AGL's inference proxy, by state only; details need a signed-in owner (`controller.proxy.status.get`). */\n proxy?: { state: TControllerProxyState };\n harnesses: Array<{\n harnessId: TControllerSessionHarnessId;\n pid?: number;\n state: TControllerHarnessLifecycleState;\n healthy: boolean;\n version?: string;\n supportsLocalAttachments?: boolean;\n connectionMode?: 'local' | 'shared' | 'remote';\n diagnostic?: IControllerCodexDiagnostic;\n /** Codex only: automatic reconnection of this entry's profile to the local shared app-server. */\n rejoin?: IControllerCodexRejoinStatus;\n /**\n * Codex only, on the controller status: every connected or required profile. The entry's\n * `healthy` is then true only when each of them is, apart from a profile on an account Codex\n * cannot run on now, listed `stopped` with an `account_unavailable` diagnostic that says why;\n * its other members describe the default profile.\n */\n profiles?: IControllerCodexProfileStatus[];\n }>;\n}"
3909
3909
  },
3910
3910
  {
3911
3911
  "name": "IControllerTerminalResource",
@@ -64,6 +64,11 @@ export interface IAGLHomePaths {
64
64
  proxy: string;
65
65
  /** The running proxy's private control socket. */
66
66
  proxySocket: string;
67
+ /**
68
+ * The proxy's confined listener: a Unix socket alone in a private directory of its own, which a confined run mounts
69
+ * into its container, so the container sees nothing else of AGL. Only confined credentials are accepted on it.
70
+ */
71
+ proxyConfinedSocket: string;
67
72
  /** The credentials the proxy keeps in files, one per client with delivery `file` (OpenCode's `{file:...}`). */
68
73
  proxyCredentials: string;
69
74
  /** The credential command a harness routed through the proxy runs; the proxy writes it whenever it starts. */
@@ -211,6 +216,7 @@ export const resolveAGLHomePaths = (
211
216
  claudeOnChatGpt: path.join(root, 'claude-gateway'),
212
217
  proxy: path.join(root, 'proxy'),
213
218
  proxySocket: path.join(sockets, 'agl-proxy.sock'),
219
+ proxyConfinedSocket: path.join(sockets, 'agl-proxy-confined', 'proxy.sock'),
214
220
  proxyCredentials: path.join(root, 'proxy', 'credentials'),
215
221
  proxyCredentialHelper: path.join(root, 'proxy', 'credential-helper'),
216
222
  migration: path.join(root, 'migration'),
@@ -3,6 +3,7 @@ import { DriverModel } from './driver/classes.driverstore.js';
3
3
  import { DirectReportModel } from './driver/classes.directreportstore.js';
4
4
  import { SessionFeedAcknowledgementModel } from './classes.sessionfeedacknowledgements.js';
5
5
  import { HarnessReleaseModel } from './classes.harnessreleases.js';
6
+ import { WorkerCallerBindingModel } from './classes.workercallerbindings.js';
6
7
  import { FleetTicketEffectModel } from './fleet/classes.ticketeffects.js';
7
8
  import { ControllerCodexOriginMigrationModel } from '../ts_migration/v29_codexorigins.js';
8
9
  import { ControllerCodexConnectionStore } from './classes.codexconnectionstore.js';
@@ -781,6 +782,7 @@ const setAuthStoreModelManager = (
781
782
  plugins.nosqldb.setDefaultManagerForDoc(managerArg, SessionFeedAcknowledgementModel);
782
783
  plugins.nosqldb.setDefaultManagerForDoc(managerArg, FleetTicketEffectModel);
783
784
  plugins.nosqldb.setDefaultManagerForDoc(managerArg, HarnessReleaseModel);
785
+ plugins.nosqldb.setDefaultManagerForDoc(managerArg, WorkerCallerBindingModel);
784
786
  plugins.nosqldb.setDefaultManagerForDoc(managerArg, TicketModel);
785
787
  plugins.nosqldb.setDefaultManagerForDoc(managerArg, TicketBoardModel);
786
788
  plugins.nosqldb.setDefaultManagerForDoc(managerArg, TicketCommentModel);
@@ -1054,6 +1056,8 @@ export class SmartDataAuthStore implements IAuthStore, IAuthStoreSessionIdentity
1054
1056
  await FleetTicketEffectModel.exact.prepare();
1055
1057
  await HarnessReleaseModel.init();
1056
1058
  await HarnessReleaseModel.exact.prepare();
1059
+ await WorkerCallerBindingModel.init();
1060
+ await WorkerCallerBindingModel.exact.prepare();
1057
1061
  await TicketModel.init();
1058
1062
  await TicketBoardModel.init();
1059
1063
  await TicketCommentModel.init();
@@ -5,6 +5,7 @@ import { FleetDispatchError } 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
+ import { WorkerCallerBindingStore } from './classes.workercallerbindings.js';
8
9
  import { FleetWorkerLaunches } from './fleet/classes.workerlaunches.js';
9
10
  import { workerCallerEnrollmentToolName } from './classes.mcpworkercaller.js';
10
11
  import { readWorkerProcessSnapshot, readWorkerUnixSocketOwner, workerSnapshotsEqual, isWorkerCallerProofRefusal, type IWorkerCallerConnection } from './functions.workerprocessproof.js';
@@ -10555,7 +10556,12 @@ export class OpenCodeController {
10555
10556
  readMaster: async () => {
10556
10557
  const resource = await configurationAuthority.getResource();
10557
10558
  return (await configurationAuthority.getMaster({ resourceId: resource.resourceId })).master;
10558
- }, captureCodexOrigin: launch => this.captureWorkerCodexOrigin(launch) });
10559
+ }, captureCodexOrigin: launch => this.captureWorkerCodexOrigin(launch),
10560
+ // Claude launches keep their bindings, so a fleet worker's bridge proves itself again after this restart and
10561
+ // after Claude Code continued its job in another process; the fleet reads the job's inventory for that proof.
10562
+ bindings: new WorkerCallerBindingStore(),
10563
+ observeClaudeJob: async (request) => this.fleetWorkers
10564
+ ? await this.fleetWorkers.observeCallerJob(request) : { state: 'unproven', reason: 'the fleet is not running yet' } });
10559
10565
  this.workerCallers = workerCallers;
10560
10566
  const mcpControllerHost = new ControllerMcpHost({
10561
10567
  controllerPort: runtimeConfig.controllerPort,
@@ -12955,6 +12961,9 @@ export class OpenCodeController {
12955
12961
  }
12956
12962
  };
12957
12963
 
12964
+ // Fleet jobs prepare, bind and revoke worker launches through the caller hooks: admit none and let the running
12965
+ // ones settle before the hooks go, so a stop or archive meets the fleet's own refusal, never missing hooks.
12966
+ await stopPart(async () => { await this.fleetWorkers?.closeAdmission(); });
12958
12967
  await stopPart(async () => {
12959
12968
  await this.workerCallers?.close();
12960
12969
  this.workerCallers = undefined;