agl 41.2.0 → 42.0.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.
- package/changelog.md +35 -0
- package/dist_serve/bundle.js +1996 -1999
- package/dist_serve/bundle.js.map +2 -2
- package/dist_serve/bundle.js.third-party-notices.json +3 -68
- package/dist_serve/bundle.js.third-party-notices.txt +4 -137
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/aglapi/aglapisurface.document.js +4 -4
- package/dist_ts/classes.authmodels.d.ts +2 -8
- package/dist_ts/classes.authmodels.js +60 -23
- package/dist_ts/classes.authstore.d.ts +22 -0
- package/dist_ts/classes.authstore.js +152 -23
- package/dist_ts/classes.cli.d.ts +3 -6
- package/dist_ts/classes.cli.js +38 -51
- package/dist_ts/classes.config.d.ts +17 -3
- package/dist_ts/classes.config.js +55 -18
- package/dist_ts/classes.controller.d.ts +12 -12
- package/dist_ts/classes.controller.js +46 -117
- package/dist_ts/classes.controllermanagement.d.ts +42 -9
- package/dist_ts/classes.controllermanagement.js +72 -23
- package/dist_ts/classes.controllerservice.d.ts +3 -31
- package/dist_ts/classes.controllerservice.js +3 -47
- package/dist_ts/classes.mcpcontrollerhost.js +9 -3
- package/dist_ts/classes.processinspection.d.ts +8 -1
- package/dist_ts/classes.processinspection.js +92 -2
- package/dist_ts/classes.proxycontrol.js +6 -1
- package/dist_ts/classes.proxydaemon.d.ts +2 -2
- package/dist_ts/classes.proxydaemon.js +1 -1
- package/dist_ts/classes.proxystore.d.ts +2 -11
- package/dist_ts/classes.proxystore.js +3 -25
- package/dist_ts/classes.tpmsecretcodec.d.ts +13 -0
- package/dist_ts/classes.tpmsecretcodec.js +28 -0
- package/dist_ts/classes.trustedproxysecrets.d.ts +91 -0
- package/dist_ts/classes.trustedproxysecrets.js +338 -0
- package/dist_ts/classes.upgradecoordinator.d.ts +14 -1
- package/dist_ts/classes.upgradecoordinator.js +21 -3
- package/dist_ts/classes.upgradetransaction.d.ts +32 -0
- package/dist_ts/classes.upgradetransaction.js +101 -4
- package/dist_ts/functions.controlleradmission.d.ts +67 -0
- package/dist_ts/functions.controlleradmission.js +127 -0
- package/dist_ts/functions.remotecli.d.ts +27 -0
- package/dist_ts/functions.remotecli.js +236 -0
- package/dist_ts/functions.retiredenvironment.d.ts +11 -2
- package/dist_ts/functions.retiredenvironment.js +22 -5
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +2 -1
- package/dist_ts/interfaces.auth.d.ts +29 -4
- package/dist_ts/interfaces.auth.js +5 -1
- package/dist_ts/interfaces.config.d.ts +14 -0
- package/dist_ts/interfaces.config.js +9 -2
- package/dist_ts/interfaces.lifecycle.d.ts +3 -0
- package/dist_ts_authswitch/classes.authoritydaemon.js +6 -1
- package/dist_ts_interfaces/interfaces.d.ts +2 -2
- package/dist_ts_interfaces/interfaces.js +1 -1
- package/dist_ts_interfaces/management.d.ts +2 -2
- package/dist_ts_interfaces/management.js +2 -2
- package/dist_ts_interfaces/requests.d.ts +1 -2
- package/dist_ts_interfaces/requests.js +1 -1
- package/dist_ts_interfaces/requests.upgrade.d.ts +0 -12
- package/package.json +12 -11
- package/readme.md +84 -24
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/aglapi/aglapisurface.document.ts +3 -3
- package/ts/classes.authmodels.ts +68 -25
- package/ts/classes.authstore.ts +151 -24
- package/ts/classes.cli.ts +38 -61
- package/ts/classes.config.ts +70 -21
- package/ts/classes.controller.ts +50 -163
- package/ts/classes.controllermanagement.ts +123 -49
- package/ts/classes.controllerservice.ts +3 -56
- package/ts/classes.mcpcontrollerhost.ts +10 -5
- package/ts/classes.processinspection.ts +84 -3
- package/ts/classes.proxycontrol.ts +2 -0
- package/ts/classes.proxydaemon.ts +3 -2
- package/ts/classes.proxystore.ts +4 -25
- package/ts/classes.tpmsecretcodec.ts +26 -0
- package/ts/classes.trustedproxysecrets.ts +317 -0
- package/ts/classes.upgradecoordinator.ts +33 -3
- package/ts/classes.upgradetransaction.ts +130 -1
- package/ts/functions.controlleradmission.ts +168 -0
- package/ts/functions.remotecli.ts +264 -0
- package/ts/functions.retiredenvironment.ts +25 -3
- package/ts/index.ts +1 -0
- package/ts/interfaces.auth.ts +36 -3
- package/ts/interfaces.config.ts +15 -0
- package/ts/interfaces.lifecycle.ts +3 -0
- package/ts_authswitch/classes.authoritydaemon.ts +2 -0
- package/ts_interfaces/interfaces.ts +2 -2
- package/ts_interfaces/management.ts +2 -2
- package/ts_interfaces/requests.ts +0 -10
- package/ts_interfaces/requests.upgrade.ts +0 -16
- package/ts_web/00_commitinfo_data.ts +1 -1
|
@@ -11,18 +11,6 @@ export interface IReq_ControllerUpgradeLaunch extends plugins.typedrequestInterf
|
|
|
11
11
|
logFilePath: string;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
export interface IReq_ControllerUpgradePrepare extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_ControllerUpgradePrepare> {
|
|
15
|
-
method: 'controller.upgrade.prepare';
|
|
16
|
-
request: {
|
|
17
|
-
token: string;
|
|
18
|
-
targetVersion: string;
|
|
19
|
-
gracePeriodMs: number;
|
|
20
|
-
};
|
|
21
|
-
response: {
|
|
22
|
-
prepared: true;
|
|
23
|
-
sessionCount: number;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
14
|
export interface IReq_ControllerUpgradePrepareBegin extends plugins.typedrequestInterfaces.implementsTR<plugins.typedrequestInterfaces.ITypedRequest, IReq_ControllerUpgradePrepareBegin> {
|
|
27
15
|
method: 'controller.upgrade.prepare.begin';
|
|
28
16
|
request: {
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agl",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "42.0.0",
|
|
4
4
|
"controllerUpgradeManagementVersion": 2,
|
|
5
5
|
"controllerManagementProtocolVersion": 1,
|
|
6
|
+
"controllerGatewaySourcesVersion": 1,
|
|
6
7
|
"private": false,
|
|
7
8
|
"description": "Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions",
|
|
8
9
|
"main": "dist_ts/index.js",
|
|
@@ -19,25 +20,25 @@
|
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"@anthropic-ai/claude-agent-sdk": "0.3.288",
|
|
22
|
-
"@api.global/typedrequest": "
|
|
23
|
+
"@api.global/typedrequest": "9.2.0",
|
|
23
24
|
"@api.global/typedrequest-interfaces": "7.1.0",
|
|
24
|
-
"@api.global/typedserver": "
|
|
25
|
-
"@api.global/typedsocket": "
|
|
26
|
-
"@apiclient.xyz/docker": "
|
|
25
|
+
"@api.global/typedserver": "^16.0.0",
|
|
26
|
+
"@api.global/typedsocket": "^10.0.1",
|
|
27
|
+
"@apiclient.xyz/docker": "^12.0.0",
|
|
27
28
|
"@aws-sdk/client-s3": "^3.1136.0",
|
|
28
29
|
"@design.estate/dees-catalog": "^23.4.0",
|
|
29
30
|
"@design.estate/dees-comms": "^2.1.0",
|
|
30
31
|
"@design.estate/dees-element": "4.0.2",
|
|
31
32
|
"@jitl/quickjs-ng-wasmfile-release-sync": "0.32.0",
|
|
32
|
-
"@lossless.org/client": "
|
|
33
|
+
"@lossless.org/client": "^2.5.0",
|
|
33
34
|
"@lossless.org/nosqldb": "10.8.0",
|
|
34
35
|
"@lossless.org/objectstorage": "10.7.1",
|
|
35
36
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
36
37
|
"@modelprofile.com/catalog": "^1.1.0",
|
|
37
|
-
"@modelprofile.com/flexharness": "17.0.
|
|
38
|
-
"@modelprofile.com/flexharness-agent": "17.0.
|
|
39
|
-
"@modelprofile.com/flexharness-models": "17.0.
|
|
40
|
-
"@modelprofile.com/flexharness-providers": "17.0.
|
|
38
|
+
"@modelprofile.com/flexharness": "17.0.1",
|
|
39
|
+
"@modelprofile.com/flexharness-agent": "17.0.1",
|
|
40
|
+
"@modelprofile.com/flexharness-models": "17.0.1",
|
|
41
|
+
"@modelprofile.com/flexharness-providers": "17.0.1",
|
|
41
42
|
"@modelprofile.com/mcp-crossharness": "5.9.0",
|
|
42
43
|
"@modelprofile.com/mcp-system": "3.1.0",
|
|
43
44
|
"@opencode-ai/sdk": "1.18.15",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"@push.rocks/smartdaemon": "2.21.0",
|
|
47
48
|
"@push.rocks/smartfs": "1.9.0",
|
|
48
49
|
"@push.rocks/smartsecret": "1.9.1",
|
|
49
|
-
"@push.rocks/smartserve": "
|
|
50
|
+
"@push.rocks/smartserve": "^10.0.1",
|
|
50
51
|
"@push.rocks/smartshell": "4.2.0",
|
|
51
52
|
"@push.rocks/smartstring": "4.3.0",
|
|
52
53
|
"@push.rocks/smartsystem": "3.1.1",
|
package/readme.md
CHANGED
|
@@ -2795,7 +2795,7 @@ The tabs of one browser share the sign-in without sharing its resume token, whic
|
|
|
2795
2795
|
- **Signing in.** When one tab signs in, a tab waiting at the sign-in screen asks for a handoff. One signed-in tab answers: it asks the controller for a single-use resume token of its sign-in (`controller.auth.handoff`), and the waiting tab redeems it through `controller.auth.resume`. The token must be redeemed within 30 seconds and carries the same sign-in and expiry. A tab opened later beside a signed-in tab joins the same way. When the answering tab cannot get a token, it says so and the waiting tab stays at the sign-in screen right away; when no tab answers within 5 seconds, the waiting tab stays there too.
|
|
2796
2796
|
- **Signing out.** **Sign out** in the header (`controller.auth.signout`) revokes every resume token of the sign-in and closes every connection of it with code 4401. The other tabs show that the browser signed out, and they do not rejoin until someone signs in again.
|
|
2797
2797
|
- **Layout.** Each tab follows the sidebar width and whether the browser sidebar is shown; the theme already follows through local storage.
|
|
2798
|
-
- **Upgrades.** When the controller is upgraded, one tab reloads into the new bundle and reports the outcome. The others follow it and do not race it to the reload.
|
|
2798
|
+
- **Upgrades.** When the controller is upgraded, one tab reloads into the new bundle and reports the outcome. The others follow it and do not race it to the reload. A tab whose release speaks another TypedSocket wire major than the upgraded controller (a tab of AGL 41, wire 8, after the upgrade to 42, wire 9) cannot reconnect to read the new version: it shows "This page does not match the running controller … Reload the page" until you reload it.
|
|
2799
2799
|
|
|
2800
2800
|
The project and session in view, the conversation sidebar, and the upgrade-reload fence stay with each tab.
|
|
2801
2801
|
|
|
@@ -2816,6 +2816,7 @@ agl ticket list|get|create|update|move|comment|link|assign [options] [--json]
|
|
|
2816
2816
|
agl feed list [--state failed] [--json] | acknowledge <row-id> --updated-at <ms> [--json]
|
|
2817
2817
|
agl foreground [options]
|
|
2818
2818
|
agl temp-password [--port 4097] [--ttl-hours 24]
|
|
2819
|
+
agl remote set|unset|secret import [--port 4097] [options]
|
|
2819
2820
|
agl help
|
|
2820
2821
|
agl --version
|
|
2821
2822
|
```
|
|
@@ -2835,7 +2836,7 @@ Important startup options:
|
|
|
2835
2836
|
|
|
2836
2837
|
`settings` prints the browser capture backend and the standard project directories; `--json` includes the complete public settings, including a selected Session Intelligence model and Claude terminal routing. A plain read never updates settings. `--add-standard-dir` and `--remove-standard-dir` edit that list, which is the same list **Settings -> Projects** edits in the browser. Directories must be absolute and must exist on the controller's disk.
|
|
2837
2838
|
|
|
2838
|
-
Runtime configuration is durable and immutable per controller port. Later management commands must use the same `--port`. The `--directory` option is transient and can register another project during a later stopped start.
|
|
2839
|
+
Runtime configuration is durable and immutable per controller port. Later management commands must use the same `--port`. A start never changes the public origin, RP ID or TLS mode of an initialized port and refuses to; only `agl remote set` and `agl remote unset` move a stopped controller's port (see [Remote Browser Access](#remote-browser-access)). The `--directory` option is transient and can register another project during a later stopped start.
|
|
2839
2840
|
|
|
2840
2841
|
`feed` reads the sidebar's session feed and acknowledges failed rows as the local owner, as **Acknowledge and remove** does:
|
|
2841
2842
|
|
|
@@ -2849,7 +2850,7 @@ agl feed acknowledge codex:01a1504e-1f31-7123-a67a-3d4bd59be124 --updated-at 176
|
|
|
2849
2850
|
|
|
2850
2851
|
`stop` verifies the exact package CLI, process, process group, command, port, and process-start fingerprint before signaling anything. AGL never kills processes by name.
|
|
2851
2852
|
|
|
2852
|
-
`restart` stops the controller and starts it again on the same port. It takes no startup options: the controller comes back with the runtime configuration stored for its port (public origin, RP ID, projects root, OpenCode port and TLS mode), and with the environment of the shell that runs `restart` when it runs detached (the unit's own when it runs as `agl-controller.service`). It checks that the start would succeed before it stops anything: the start must be admitted, and a
|
|
2853
|
+
`restart` stops the controller and starts it again on the same port. It takes no startup options: the controller comes back with the runtime configuration stored for its port (public origin, RP ID, projects root, OpenCode port and TLS mode), and with the environment of the shell that runs `restart` when it runs detached (the unit's own when it runs as `agl-controller.service`). It checks that the start would succeed before it stops anything: the start must be admitted, and a start the installed `agl-controller.service` would refuse is refused before anything stops. A controller behind a TLS reverse proxy restarts like any other: its trusted-proxy secret is in its database. Sessions are not paused or continued; `upgrade` is the command that carries them across a restart.
|
|
2853
2854
|
|
|
2854
2855
|
### Running AGL as a systemd user unit
|
|
2855
2856
|
|
|
@@ -2862,7 +2863,7 @@ agl restart --port 4097 # move a running detached controller into the
|
|
|
2862
2863
|
|
|
2863
2864
|
`service install` takes the persistent startup options (`--opencode-port`, `--projects-root`, `--public-origin`, `--rp-id`) and writes them into the unit's command line: the pnpm-global `agl` shim, verified to run this release, with `__serve --service --port <port>`. Because pnpm rewrites the shim for every release it installs, the unit runs whichever AGL is installed and survives upgrades. The unit runs from the home directory, after `authswitch-authority.service`, and is wanted by `default.target`, so the user manager starts AGL at login, or at boot when lingering is enabled for the user (`loginctl enable-linger`). Running it again with the same settings changes nothing, even while the unit runs. A changed definition is written only while the unit is stopped, so changing the settings is `agl stop`, then `agl service install` with the new settings, then `agl start`. It needs a systemd user manager of version 254 or later.
|
|
2864
2865
|
|
|
2865
|
-
The unit runs
|
|
2866
|
+
The unit runs a controller behind a TLS reverse proxy as well as one on localhost: the trusted-proxy secret is generated and sealed in the controller's database, so the unit carries none (see [Remote Browser Access](#remote-browser-access)).
|
|
2866
2867
|
|
|
2867
2868
|
From then on, `start`, `stop`, `restart` and `upgrade` drive the unit for the AGL home and port it was installed for:
|
|
2868
2869
|
|
|
@@ -2872,7 +2873,7 @@ From then on, `start`, `stop`, `restart` and `upgrade` drive the unit for the AG
|
|
|
2872
2873
|
|
|
2873
2874
|
`agl status` shows `agl-controller.service` in place of `detached` for a controller the unit runs. `agl service status [--json]` reports the unit's state, its port and AGL home, and its unit and log files. `agl service uninstall` disables the unit, stops the controller it runs, waits for the unit to stop and removes exactly the definition AGL installed; it refuses while processes it started, such as jobs, still run in the unit's control group. Start AGL detached again with `agl start`.
|
|
2874
2875
|
|
|
2875
|
-
The unit carries `PATH` and `AGL_HOME`, and, when set, `AGL_DB_DIR`, `AGL_MONGO_DB`, `AGL_MONGO_URL`, `AGL_CODEX_EXECUTABLE`, `AGL_CLAUDE_EXECUTABLE`, `CODEX_HOME`, `CLAUDE_CONFIG_DIR`, `XDG_CONFIG_HOME`, `XDG_DATA_HOME`, `XDG_STATE_HOME`, `XDG_CACHE_HOME`, `NODE_EXTRA_CA_CERTS`, `SSL_CERT_FILE`, `SSL_CERT_DIR`, `TZ`, `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY`; nothing else from the installing shell reaches it. The unit file is readable by every local user, so it never holds a secret: `service install` refuses while `
|
|
2876
|
+
The unit carries `PATH` and `AGL_HOME`, and, when set, `AGL_DB_DIR`, `AGL_MONGO_DB`, `AGL_MONGO_URL`, `AGL_CODEX_EXECUTABLE`, `AGL_CLAUDE_EXECUTABLE`, `CODEX_HOME`, `CLAUDE_CONFIG_DIR`, `XDG_CONFIG_HOME`, `XDG_DATA_HOME`, `XDG_STATE_HOME`, `XDG_CACHE_HOME`, `NODE_EXTRA_CA_CERTS`, `SSL_CERT_FILE`, `SSL_CERT_DIR`, `TZ`, `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY`; nothing else from the installing shell reaches it. The unit file is readable by every local user, so it never holds a secret: `service install` refuses while `AGL_MONGO_URL`, `HTTP_PROXY` or `HTTPS_PROXY` carries credentials, and while `AGL_FORWARD_ENV` names variables the fixed set would drop. Such a controller keeps running detached.
|
|
2876
2877
|
|
|
2877
2878
|
The unit appends the controller's errors to the same `$AGL_HOME/logs/controller-<port>.log` a detached controller writes; standard output is discarded, as it is for a detached controller.
|
|
2878
2879
|
|
|
@@ -2918,7 +2919,9 @@ The upgrade worker:
|
|
|
2918
2919
|
- Restarts `agl-proxy.service` onto the new release once the target controller is up, when the unit is installed and running and runs the pnpm-global `agl` shim, and waits until the proxy answers as the new release and its credential launcher, run with an empty environment as a harness runs it, runs the new release too. A unit that is not installed or not running is left alone. A restart that fails does not fail the upgrade: it is logged as a warning and appended to the completion message (`message` in `--json` output).
|
|
2919
2920
|
- Moves the accounts service onto the authswitch the new AGL brings, with authswitch's own `authority service stop`, `install` and `start`: the service is stopped before the package changes and started again, on the new release, when it ran before. A release that declares no `authswitch` command is refused before anything is stopped. A host without the service's unit keeps it that way, and the service's store is never touched. Stopping the service also stops the managed Codex runtimes it runs; they start again when next asked for. The log names what was stopped and started; a failed upgrade restores the previous AGL first, then the running service, and each step is recorded in the upgrade transaction, so recovering a lost worker finishes or undoes it.
|
|
2920
2921
|
- Preserves its transaction across worker or controller failure.
|
|
2921
|
-
- Reads the controller's status, prepares it and finalizes it through the controller's loopback management endpoint (an HTTP `POST` of one TypedRequest to `/management/typedrequest` on the controller's port, addressed to `127.0.0.1:<port>`), never through the browser's WebSocket, so the worker of one release finalizes the controller of the next whatever transport that release's browser speaks. `agl status` and `agl upgrade` read their own release's controller the same way. The endpoint is used only for a controller that declares it: before the controller runs, by `controllerManagementProtocolVersion` in the `package.json` of the installed release that starts it, and once it runs, by `managementProtocolVersion` in its status. A controller that declares neither, as every release before the endpoint,
|
|
2922
|
+
- Reads the controller's status, prepares it and finalizes it through the controller's loopback management endpoint (an HTTP `POST` of one TypedRequest to `/management/typedrequest` on the controller's port, addressed to `127.0.0.1:<port>`), never through the browser's WebSocket, so the worker of one release finalizes the controller of the next whatever transport that release's browser speaks. `agl status` and `agl upgrade` read their own release's controller the same way. The endpoint is used only for a controller that declares it: before the controller runs, by `controllerManagementProtocolVersion` in the `package.json` of the installed release that starts it, and once it runs, by `managementProtocolVersion` in its status. A controller that declares neither, as every release before the endpoint, is refused by name and never reached over its controller socket, which since 42 serves only the browser's status read. Nothing is tried over one transport and then the other.
|
|
2923
|
+
|
|
2924
|
+
**AGL 41.0.x or older must upgrade to 41.1.x before 42.** AGL 42 manages a controller only through the loopback management endpoint, which 41.1.0 added, and its controller no longer speaks TypedSocket 8, the only way an upgrade worker of 41.0.x or older reaches the controller it starts. Run `agl upgrade` while 41.1.x is the latest release, then upgrade again. Once 42 is the latest release, upgrade a 41.0.x or older controller while it is stopped: `agl stop --port 4097` with its own release, then `agl upgrade --port 4097` and `agl start --port 4097`. AGL 42 refuses to manage an older controller: `agl status`, `stop`, `start`, `restart`, `upgrade` and `service install` say "AGL 41.0.x or older must upgrade to 41.1.x before 42" instead of reporting no controller, and name the release (`agl@41.0.3`) when its package or an upgrade transaction names it, or else call it a controller older than 41.1.0 on its port. They say so only when the process listening on the port runs an installed AGL package's controller (on Linux and macOS); any other program on the port is reported as a busy port. A recovery that restores such a release leaves it installed and its controller stopped, with the upgrade transaction open; the next `agl upgrade --port 4097`, now of that release, starts it and finishes the recovery.
|
|
2922
2925
|
|
|
2923
2926
|
The cohort is every conversation with an AGL prompt that is queued or still running when the upgrade starts. AGL seals prompt admission, so no new message is accepted and no queue starts a turn, and stops each of them, as **Stop** does:
|
|
2924
2927
|
|
|
@@ -2940,15 +2943,17 @@ Upgrade coordination lives under `$AGL_HOME/upgrade`. Private logs live under `$
|
|
|
2940
2943
|
|
|
2941
2944
|
A failure reference from the Errors dialog appears in those logs on the line the controller wrote when the failure happened, together with the operation and the cause. The journal the dialog reads it from is in memory only, so it is gone after a controller restart while the log line remains.
|
|
2942
2945
|
|
|
2943
|
-
### Rolling back
|
|
2946
|
+
### Rolling back to 41.x
|
|
2947
|
+
|
|
2948
|
+
41.1.0 and the later 41.x releases are the ones this release rolls back to. This release keeps a port's trusted-proxy secret sealed in the controller's database and never exports it, and `agl remote set` can store gateway sources, which 41.x cannot enforce. To roll back a port that this release serves behind a TLS reverse proxy:
|
|
2944
2949
|
|
|
2945
|
-
|
|
2950
|
+
1. Stop the controller and run `agl remote unset --port <port>`. It moves the port back to `http://localhost:<port>` and removes its passkey, so the next start prints a setup code. A 41.x controller refuses to start on a configuration with gateway sources, and its refusal names this command.
|
|
2951
|
+
2. Roll back and start the controller. Roll back only while no upgrade is open: 41.x refuses an upgrade transaction this release created.
|
|
2952
|
+
3. To serve 41.x behind the proxy again, generate a new secret and set it both on the proxy route (`X-Harness-Controller-Proxy-Secret`) and in `AGL_TRUSTED_PROXY_SECRET`, as 41.x's readme describes. 41.x fixes a port's public origin and TLS mode on its first start, so that is a port that has not been started yet.
|
|
2946
2953
|
|
|
2947
|
-
|
|
2948
|
-
2. Roll back and start the controller.
|
|
2949
|
-
3. To serve 41.1.x behind the proxy again, generate a new secret and set it both on the proxy route (`X-Harness-Controller-Proxy-Secret`) and in `AGL_TRUSTED_PROXY_SECRET`, as in [Remote Browser Access](#remote-browser-access). 41.1.x fixes a port's public origin and TLS mode on its first start, so that is a port that has not been started yet.
|
|
2954
|
+
A recovery of AGL 42 that would roll a stalled upgrade back to a release older than 42 first checks the port's stored configuration: while it names gateway sources (`agl remote set --gateway-source`), which such a release refuses to start on and has no command to remove, it restores nothing and asks you to run `agl remote unset --port 4097` with 42, still installed, and then `agl upgrade --port 4097` again. Whether the release it would put back supports gateway sources is what that release's package declares (`controllerGatewaySourcesVersion`), as the upgrade recorded it when it started.
|
|
2950
2955
|
|
|
2951
|
-
|
|
2956
|
+
The audit events of types 41.x does not know (`remote.*`) stay in the audit log and are pruned with the others.
|
|
2952
2957
|
|
|
2953
2958
|
### Migrating From `hcon`
|
|
2954
2959
|
|
|
@@ -3055,31 +3060,86 @@ A controller that runs as `agl-controller.service` has the unit's environment in
|
|
|
3055
3060
|
|
|
3056
3061
|
## Remote Browser Access
|
|
3057
3062
|
|
|
3058
|
-
Remote WebAuthn requires HTTPS
|
|
3063
|
+
Remote WebAuthn requires HTTPS, so a browser on another machine reaches AGL through a trusted TLS reverse proxy: the proxy terminates TLS for a public origin and forwards plain HTTP to the controller's port, and the controller runs in TLS-proxy mode (`tlsMode: proxy` in `agl status --json`). A browser at `http://localhost:<port>` is refused from then on: one origin per port.
|
|
3064
|
+
|
|
3065
|
+
### Moving a port behind the proxy
|
|
3066
|
+
|
|
3067
|
+
Only a stopped controller's port moves, with `agl remote set`:
|
|
3059
3068
|
|
|
3060
3069
|
```sh
|
|
3061
|
-
|
|
3070
|
+
agl stop --port 4097
|
|
3071
|
+
agl remote set --port 4097 \
|
|
3072
|
+
--public-origin https://agl.example.com \
|
|
3073
|
+
--rp-id agl.example.com \
|
|
3074
|
+
--gateway-source 192.0.2.10
|
|
3075
|
+
agl start --port 4097 # prints the setup code for https://agl.example.com
|
|
3076
|
+
```
|
|
3077
|
+
|
|
3078
|
+
- The controller keeps its id (`controller:4097`) and all of its data: projects, conversations, tickets, settings and the audit trail. Only the public origin, the WebAuthn RP ID (the origin's hostname when `--rp-id` is omitted; IP addresses and public suffixes are refused) and the gateway sources change.
|
|
3079
|
+
- 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.
|
|
3080
|
+
- `--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.
|
|
3081
|
+
- `agl remote unset --port 4097` moves the port back to `http://localhost:4097` (RP ID `localhost`): it removes the passkey, revokes every temporary password and forgets the trusted-proxy secret. The next start prints a setup code.
|
|
3082
|
+
- 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).
|
|
3083
|
+
- 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`.
|
|
3084
|
+
|
|
3085
|
+
### The trusted-proxy secret
|
|
3062
3086
|
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3087
|
+
The controller trusts the proxy by the secret it sends as `X-Harness-Controller-Proxy-Secret`. AGL generates it, 32 random bytes, at the first start in TLS-proxy mode, seals it with the TPM (`systemd-creds`, as the inference proxy seals its credentials) and keeps only the sealed form in its database. It is never read from the environment, written to a file or the unit, or logged. TLS-proxy mode therefore needs a TPM2 the user can use, as `agl proxy` does.
|
|
3088
|
+
|
|
3089
|
+
A rotation keeps the previous secret valid until the proxy is confirmed to send the new one, and refuses it from then on. For a reverse proxy AGL does not configure itself, choose the secret and import it into the stopped controller:
|
|
3090
|
+
|
|
3091
|
+
```sh
|
|
3092
|
+
node -e "console.log(require('node:crypto').randomBytes(32).toString('base64url'))" > ~/agl-proxy-secret
|
|
3093
|
+
chmod 600 ~/agl-proxy-secret
|
|
3094
|
+
agl stop --port 4097
|
|
3095
|
+
agl remote secret import --port 4097 < ~/agl-proxy-secret
|
|
3096
|
+
agl start --port 4097
|
|
3067
3097
|
```
|
|
3068
3098
|
|
|
3069
|
-
|
|
3099
|
+
`secret import` reads a 32-byte base64url secret (43 characters) from a pipe or file, never from a terminal, replaces the secret and any rotation in progress, prints only its generation and is audited as `remote.secret.import`. A controller on localhost takes no secret.
|
|
3100
|
+
|
|
3101
|
+
`AGL_TRUSTED_PROXY_SECRET` is not read any more: `start`, `restart`, `foreground`, `upgrade`, `temp-password` and `service` refuse to run while it is set, naming the import. Move the secret it holds into the database and unset it:
|
|
3070
3102
|
|
|
3071
|
-
|
|
3072
|
-
|
|
3103
|
+
```sh
|
|
3104
|
+
agl stop --port 4097
|
|
3105
|
+
printf '%s' "$AGL_TRUSTED_PROXY_SECRET" | agl remote secret import --port 4097
|
|
3106
|
+
unset AGL_TRUSTED_PROXY_SECRET
|
|
3107
|
+
agl start --port 4097
|
|
3108
|
+
```
|
|
3109
|
+
|
|
3110
|
+
### What the proxy must do
|
|
3111
|
+
|
|
3112
|
+
- Inject the secret as `X-Harness-Controller-Proxy-Secret`, replacing any copy the client sent: a request with two copies is refused.
|
|
3073
3113
|
- Set `X-Forwarded-Proto: https` on WebSocket upgrades.
|
|
3074
3114
|
- Preserve the exact public Host and Origin.
|
|
3075
3115
|
- Forward WebSocket upgrades.
|
|
3076
|
-
- Restrict direct access to the backend listener.
|
|
3077
3116
|
|
|
3078
|
-
|
|
3117
|
+
### Admission
|
|
3118
|
+
|
|
3119
|
+
The controller has one listener. It binds loopback in local mode and in TLS-proxy mode without a gateway source, and every interface once a gateway source is configured (IPv6 too when one is an IPv6 address). Every HTTP request and WebSocket upgrade on it, static assets included, is admitted alike:
|
|
3120
|
+
|
|
3121
|
+
- From loopback, as before: the CLI, `agl mcp` and the upgrade worker connect without an `Origin`. A browser's upgrade carries the public origin as `Origin`, and in TLS-proxy mode `X-Forwarded-Proto: https` and the secret, since a reverse proxy on this host forwards from loopback.
|
|
3122
|
+
- From any other address, only a configured gateway source that sends the secret. Its upgrades also carry the public origin as `Origin` and `X-Forwarded-Proto: https`: an upgrade without an `Origin` is admitted only from loopback, so a native client sends the public origin too. Its GET and HEAD requests may come without an `Origin`, as a browser's page loads do; every other method needs the public origin as `Origin`, and no request may carry another.
|
|
3123
|
+
|
|
3124
|
+
A refused request is answered 403.
|
|
3125
|
+
|
|
3126
|
+
### Backend isolation
|
|
3127
|
+
|
|
3128
|
+
Admission is the second line. The host firewall must let only the gateway reach the controller's port; with ufw:
|
|
3129
|
+
|
|
3130
|
+
```sh
|
|
3131
|
+
sudo ufw allow proto tcp from 192.0.2.10 to any port 4097 comment 'AGL through its gateway'
|
|
3132
|
+
sudo ufw deny proto tcp to any port 4097 comment 'AGL only through its gateway'
|
|
3133
|
+
sudo ufw status verbose # the allow is listed before the deny, and no broader rule allows the port
|
|
3134
|
+
```
|
|
3135
|
+
|
|
3136
|
+
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.
|
|
3079
3137
|
|
|
3080
3138
|
## Security Boundaries
|
|
3081
3139
|
|
|
3082
|
-
- Local mode binds the controller to loopback only.
|
|
3140
|
+
- Local mode binds the controller to loopback only, and so does TLS-proxy mode without a gateway source. With one, a request from off loopback needs a configured gateway source address and the trusted-proxy secret, and only loopback connects without an `Origin`.
|
|
3141
|
+
- The trusted-proxy secret is generated and TPM2-sealed in the controller's database; it is never read from the environment, written to a file or logged.
|
|
3142
|
+
- Only `agl remote`, run by the local OS user against a stopped controller, changes a port's public origin, RP ID, TLS mode or gateway sources, and a changed origin or RP ID removes the passkey.
|
|
3083
3143
|
- The private OpenCode server always remains on loopback and uses a generated per-process password.
|
|
3084
3144
|
- Application RPC starts only after the exact TypedSocket package-major handshake.
|
|
3085
3145
|
- The management endpoint (`/management/typedrequest`, used by the CLI and the upgrade worker) answers only an HTTP `POST` of `application/json` from a loopback peer (`127.0.0.1` or `::1`), addressed to `127.0.0.1:<port>`, with no `Origin` and no forwarding header (`Forwarded`, `X-Forwarded-*`, `X-Real-IP`, `X-Harness-Controller-Proxy-Secret`), so a browser or a request a proxy forwards is refused, also in proxy mode. It serves only the status read and the upgrade methods; each upgrade method authorises itself against the upgrade token and its one-time grant, as it does over the socket, and every upgrade request counts against the controller's global unauthenticated preflight limit.
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -3765,14 +3765,14 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
|
|
|
3765
3765
|
},
|
|
3766
3766
|
"protocolVersion": {
|
|
3767
3767
|
"type": "number",
|
|
3768
|
-
"const":
|
|
3768
|
+
"const": 48
|
|
3769
3769
|
},
|
|
3770
3770
|
"upgradeManagementVersion": {
|
|
3771
3771
|
"type": "number"
|
|
3772
3772
|
},
|
|
3773
3773
|
"managementProtocolVersion": {
|
|
3774
3774
|
"type": "number",
|
|
3775
|
-
"description": "The protocol of the controller's loopback management endpoint (`controllerManagementProtocolVersion`); absent from a controller older than the endpoint, which
|
|
3775
|
+
"description": "The protocol of the controller's loopback management endpoint (`controllerManagementProtocolVersion`); absent from a controller older than the endpoint, which this release refuses to manage."
|
|
3776
3776
|
},
|
|
3777
3777
|
"controllerPid": {
|
|
3778
3778
|
"type": "number"
|
|
@@ -3891,7 +3891,7 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
|
|
|
3891
3891
|
],
|
|
3892
3892
|
"additionalProperties": false
|
|
3893
3893
|
},
|
|
3894
|
-
"declaration": "interface IControllerStatus {\n packageName: string;\n packageVersion: string;\n protocolVersion:
|
|
3894
|
+
"declaration": "interface IControllerStatus {\n packageName: string;\n packageVersion: string;\n protocolVersion: 48;\n upgradeManagementVersion: number;\n /**\n * The protocol of the controller's loopback management endpoint (`controllerManagementProtocolVersion`); absent\n * from a controller older than the endpoint, which this release refuses to manage.\n */\n managementProtocolVersion?: 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}"
|
|
3895
3895
|
},
|
|
3896
3896
|
{
|
|
3897
3897
|
"name": "IControllerTerminalResource",
|
package/ts/classes.authmodels.ts
CHANGED
|
@@ -4,9 +4,12 @@ import { assertControllerFlexCleanupCohort } from './classes.managedsessionmodel
|
|
|
4
4
|
import { isControllerTerminalAgentSessionId } from './functions.terminalagents.js';
|
|
5
5
|
import { resourceKindAcceptsTerminalSubject } from './functions.resourceattachments.js';
|
|
6
6
|
import { isAgentMessageSubject } from './functions.agentmessage.js';
|
|
7
|
+
import { canonicalGatewaySources } from './functions.controlleradmission.js';
|
|
7
8
|
import {
|
|
8
9
|
controllerAuditEventTypes,
|
|
9
10
|
type IControllerAuditEvent,
|
|
11
|
+
type IControllerAuditRemoteEndpoint,
|
|
12
|
+
type IControllerAuditRemoteMove,
|
|
10
13
|
type IControllerAuthDocument,
|
|
11
14
|
type IControllerTempPasswordDocument,
|
|
12
15
|
type ISetupAuthorityState,
|
|
@@ -97,8 +100,9 @@ const isBoundedPlainJson = (valueArg: unknown, depthArg: number): boolean => {
|
|
|
97
100
|
};
|
|
98
101
|
|
|
99
102
|
/**
|
|
100
|
-
* An audit event's `details`:
|
|
101
|
-
*
|
|
103
|
+
* An audit event's `details`: what a type records beyond the envelope (this release's `remoteMove` on `remote.set`
|
|
104
|
+
* and `remote.unset`, a later release's own keys on its types). Bounded plain JSON: an object at most eight levels
|
|
105
|
+
* deep and 4 KiB serialized.
|
|
102
106
|
*/
|
|
103
107
|
const isAuditDetails = (valueArg: unknown): valueArg is Record<string, unknown> =>
|
|
104
108
|
isPlainObject(valueArg)
|
|
@@ -155,6 +159,17 @@ const isValidDate = (valueArg: unknown): valueArg is Date =>
|
|
|
155
159
|
const isValidPort = (valueArg: unknown): valueArg is number =>
|
|
156
160
|
Number.isSafeInteger(valueArg) && (valueArg as number) >= 1 && (valueArg as number) <= 65535;
|
|
157
161
|
|
|
162
|
+
/** Stored only in TLS-proxy mode and only while it names an address, canonical and sorted. */
|
|
163
|
+
const isStoredGatewaySources = (valueArg: unknown, tlsModeArg: unknown): boolean => {
|
|
164
|
+
if (tlsModeArg !== 'proxy' || !Array.isArray(valueArg) || valueArg.length === 0
|
|
165
|
+
|| !valueArg.every((entryArg) => typeof entryArg === 'string')) return false;
|
|
166
|
+
try {
|
|
167
|
+
return canonicalGatewaySources(valueArg).join(',') === valueArg.join(',');
|
|
168
|
+
} catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
158
173
|
const isRuntimeConfig = (valueArg: unknown): valueArg is IControllerRuntimeConfig => {
|
|
159
174
|
if (!isPlainObject(valueArg)) return false;
|
|
160
175
|
if (
|
|
@@ -165,7 +180,8 @@ const isRuntimeConfig = (valueArg: unknown): valueArg is IControllerRuntimeConfi
|
|
|
165
180
|
'projectsRoot',
|
|
166
181
|
'opencodePort',
|
|
167
182
|
'tlsMode',
|
|
168
|
-
])
|
|
183
|
+
], ['gatewaySources'])
|
|
184
|
+
|| (Object.hasOwn(valueArg, 'gatewaySources') && !isStoredGatewaySources(valueArg.gatewaySources, valueArg.tlsMode))
|
|
169
185
|
|| !isNonEmptyString(valueArg.projectsRoot)
|
|
170
186
|
|| !plugins.path.isAbsolute(valueArg.projectsRoot)
|
|
171
187
|
|| plugins.path.normalize(valueArg.projectsRoot) !== valueArg.projectsRoot
|
|
@@ -241,29 +257,10 @@ const isStoredCredential = (valueArg: unknown): valueArg is IStoredPasskeyCreden
|
|
|
241
257
|
&& isBase64Url(valueArg.counterUpdateId, 32);
|
|
242
258
|
};
|
|
243
259
|
|
|
244
|
-
/**
|
|
245
|
-
* The stored runtime configuration names `gatewaySources`, which only a later release writes (`agl remote set` with
|
|
246
|
-
* gateway sources). This release cannot enforce them, so it refuses the document; the message names the one remedy.
|
|
247
|
-
*/
|
|
248
|
-
export class ControllerRuntimeConfigFromLaterReleaseError extends Error {
|
|
249
|
-
constructor(controllerPortArg: unknown) {
|
|
250
|
-
const port = isValidPort(controllerPortArg) ? String(controllerPortArg) : '<port>';
|
|
251
|
-
super(
|
|
252
|
-
`The stored runtime configuration of controller:${port} names gatewaySources, which a later AGL release set `
|
|
253
|
-
+ 'and this release cannot enforce, so it does not start. Run '
|
|
254
|
-
+ `\`agl remote unset --port ${port}\` on the later release before rolling back.`,
|
|
255
|
-
);
|
|
256
|
-
this.name = 'ControllerRuntimeConfigFromLaterReleaseError';
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
260
|
export const assertControllerAuthDocument = (
|
|
261
261
|
valueArg: unknown,
|
|
262
262
|
): asserts valueArg is IControllerAuthDocument => {
|
|
263
263
|
if (!isPlainObject(valueArg)) throw new Error('Invalid controller authentication document.');
|
|
264
|
-
if (isPlainObject(valueArg.config) && Object.hasOwn(valueArg.config, 'gatewaySources')) {
|
|
265
|
-
throw new ControllerRuntimeConfigFromLaterReleaseError(valueArg.config.controllerPort);
|
|
266
|
-
}
|
|
267
264
|
if (
|
|
268
265
|
!hasExactKeys(valueArg, [
|
|
269
266
|
'id',
|
|
@@ -369,12 +366,51 @@ export const assertWebAuthnCeremonyDocument = (
|
|
|
369
366
|
}
|
|
370
367
|
};
|
|
371
368
|
|
|
369
|
+
/** A canonical origin with the RP ID it is valid for, as `isRuntimeConfig` holds them; never anything else. */
|
|
370
|
+
const isAuditRemoteEndpoint = (valueArg: unknown): valueArg is IControllerAuditRemoteEndpoint => {
|
|
371
|
+
if (
|
|
372
|
+
!isPlainObject(valueArg)
|
|
373
|
+
|| !hasExactKeys(valueArg, ['publicOrigin', 'rpId'])
|
|
374
|
+
|| !isNonEmptyString(valueArg.publicOrigin)
|
|
375
|
+
|| valueArg.publicOrigin.length > 512
|
|
376
|
+
|| !isNonEmptyString(valueArg.rpId)
|
|
377
|
+
|| valueArg.rpId.length > 253
|
|
378
|
+
|| valueArg.rpId !== valueArg.rpId.toLowerCase()
|
|
379
|
+
|| /[/:\s]/.test(valueArg.rpId)
|
|
380
|
+
) {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
try {
|
|
384
|
+
const origin = new URL(valueArg.publicOrigin);
|
|
385
|
+
const hostname = origin.hostname.toLowerCase().replace(/\.$/, '');
|
|
386
|
+
return origin.origin === valueArg.publicOrigin
|
|
387
|
+
&& (origin.protocol === 'http:' || origin.protocol === 'https:')
|
|
388
|
+
&& (hostname === valueArg.rpId || hostname.endsWith(`.${valueArg.rpId}`));
|
|
389
|
+
} catch {
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
const isAuditRemoteMove = (valueArg: unknown): valueArg is IControllerAuditRemoteMove => isPlainObject(valueArg)
|
|
395
|
+
&& hasExactKeys(valueArg, ['previous', 'target'])
|
|
396
|
+
&& isAuditRemoteEndpoint(valueArg.previous)
|
|
397
|
+
&& isAuditRemoteEndpoint(valueArg.target);
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* `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.
|
|
402
|
+
*/
|
|
403
|
+
const hasKnownAuditDetails = (typeArg: string, detailsArg: Record<string, unknown>): boolean =>
|
|
404
|
+
!Object.hasOwn(detailsArg, 'remoteMove')
|
|
405
|
+
|| ((typeArg === 'remote.set' || typeArg === 'remote.unset') && isAuditRemoteMove(detailsArg.remoteMove));
|
|
406
|
+
|
|
372
407
|
/**
|
|
373
408
|
* A stored audit event. The log is shared with later releases, so a type this release does not know (a later
|
|
374
409
|
* release's, read back after a rollback) is accepted when it is spelled as an audit type: its envelope is checked as
|
|
375
410
|
* strictly as a known type's, and only the rules that tie a field to particular types (`senderLabel` to
|
|
376
411
|
* `session.message`, `localCli` to `configuration.*`) are left to the release that knows the type. A known type keeps
|
|
377
|
-
* every check. `details` is bounded plain JSON on any type
|
|
412
|
+
* every check. `details` is bounded plain JSON on any type; on a known type its `remoteMove` is checked strictly
|
|
413
|
+
* (`hasKnownAuditDetails`).
|
|
378
414
|
*/
|
|
379
415
|
export const assertControllerAuditEventDocument = (
|
|
380
416
|
valueArg: unknown,
|
|
@@ -405,12 +441,19 @@ export const assertControllerAuditEventDocument = (
|
|
|
405
441
|
Object.hasOwn(valueArg, 'senderLabel')
|
|
406
442
|
&& ((known && type !== 'session.message') || !isControllerAgentMessageSender(valueArg.senderLabel))
|
|
407
443
|
)
|
|
408
|
-
|| (
|
|
444
|
+
|| (
|
|
445
|
+
Object.hasOwn(valueArg, 'details')
|
|
446
|
+
&& (!isAuditDetails(valueArg.details) || (known && !hasKnownAuditDetails(type, valueArg.details)))
|
|
447
|
+
)
|
|
409
448
|
) {
|
|
410
449
|
throw new Error('Invalid controller audit event.');
|
|
411
450
|
}
|
|
412
451
|
if (Object.hasOwn(valueArg, 'localCli')) {
|
|
413
|
-
|
|
452
|
+
// Local configuration and the offline `agl remote` commands are the actions a local OS user takes; a type this
|
|
453
|
+
// release does not know leaves that rule to the release that knows it.
|
|
454
|
+
if (known && !type.startsWith('configuration.') && !type.startsWith('remote.')) {
|
|
455
|
+
throw new Error('Invalid local configuration audit event.');
|
|
456
|
+
}
|
|
414
457
|
assertConfigurationLocalCliActor(valueArg.localCli);
|
|
415
458
|
}
|
|
416
459
|
for (const optionalKey of [
|