agl 43.10.2 → 43.12.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 (55) hide show
  1. package/changelog.md +22 -0
  2. package/dist_serve/bundle.js +2 -2
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_ts/00_commitinfo_data.js +1 -1
  5. package/dist_ts/classes.apnsclient.d.ts +5 -3
  6. package/dist_ts/classes.apnsclient.js +10 -5
  7. package/dist_ts/classes.controller.js +11 -4
  8. package/dist_ts/classes.controllerdevices.d.ts +4 -3
  9. package/dist_ts/classes.controllerdevices.js +3 -2
  10. package/dist_ts/classes.controllerpush.d.ts +6 -1
  11. package/dist_ts/classes.controllerpush.js +25 -2
  12. package/dist_ts/classes.fcmclient.d.ts +2 -1
  13. package/dist_ts/classes.fcmclient.js +3 -2
  14. package/dist_ts/classes.pushregistrations.d.ts +13 -3
  15. package/dist_ts/classes.pushregistrations.js +56 -27
  16. package/dist_ts/fleet/classes.deploymonitor.d.ts +7 -8
  17. package/dist_ts/fleet/classes.deploymonitor.js +16 -14
  18. package/dist_ts/fleet/classes.releasereconciler.d.ts +2 -1
  19. package/dist_ts/fleet/classes.releasereconciler.js +3 -2
  20. package/dist_ts/fleet/classes.runtime.js +9 -5
  21. package/dist_ts/fleet/classes.service.d.ts +12 -2
  22. package/dist_ts/fleet/classes.service.js +55 -17
  23. package/dist_ts/fleet/functions.discovery.d.ts +11 -2
  24. package/dist_ts/fleet/functions.discovery.js +55 -12
  25. package/dist_ts/fleet/functions.rebase.js +5 -2
  26. package/dist_ts/fleet/functions.toolchain.d.ts +20 -0
  27. package/dist_ts/fleet/functions.toolchain.js +50 -0
  28. package/dist_ts/fleet/functions.validation.d.ts +2 -0
  29. package/dist_ts/fleet/functions.validation.js +11 -3
  30. package/dist_ts/functions.mcpfleettools.js +2 -2
  31. package/dist_ts_interfaces/devices.d.ts +31 -8
  32. package/dist_ts_interfaces/devices.js +2 -2
  33. package/dist_ts_interfaces/fleet.d.ts +23 -0
  34. package/package.json +1 -1
  35. package/readme.md +26 -6
  36. package/ts/00_commitinfo_data.ts +1 -1
  37. package/ts/classes.apnsclient.ts +9 -4
  38. package/ts/classes.controller.ts +9 -3
  39. package/ts/classes.controllerdevices.ts +4 -2
  40. package/ts/classes.controllerpush.ts +31 -1
  41. package/ts/classes.fcmclient.ts +2 -1
  42. package/ts/classes.pushregistrations.ts +56 -24
  43. package/ts/fleet/classes.deploymonitor.ts +19 -16
  44. package/ts/fleet/classes.releasereconciler.ts +2 -1
  45. package/ts/fleet/classes.runtime.ts +8 -4
  46. package/ts/fleet/classes.service.ts +50 -17
  47. package/ts/fleet/functions.discovery.ts +54 -12
  48. package/ts/fleet/functions.rebase.ts +4 -1
  49. package/ts/fleet/functions.toolchain.ts +56 -0
  50. package/ts/fleet/functions.validation.ts +7 -2
  51. package/ts/functions.mcpfleettools.ts +1 -1
  52. package/ts_interfaces/devices.schema.json +25 -4
  53. package/ts_interfaces/devices.ts +32 -8
  54. package/ts_interfaces/fleet.ts +15 -0
  55. package/ts_web/00_commitinfo_data.ts +1 -1
@@ -2,7 +2,7 @@ import type { ITypedRequest, implementsTR } from '@api.global/typedrequest-inter
2
2
  /** The device protocol this controller speaks. */
3
3
  export declare const deviceProtocolVersion: {
4
4
  readonly major: 1;
5
- readonly minor: 4;
5
+ readonly minor: 5;
6
6
  };
7
7
  /** The scheme of a pairing payload: `agl-pair:?origin=<https origin>&controller=<controller id>&code=<base64url>`. */
8
8
  export declare const devicePairingScheme: 'agl-pair';
@@ -720,10 +720,17 @@ export declare const devicePushSummarySentence = "New items wait for you in the
720
720
  export declare const devicePushReportSentence = "A direct report has a new result.";
721
721
  /** The text of the owner's test notification. Since protocol 1.4. */
722
722
  export declare const devicePushTestSentence = "Push from AGL works.";
723
+ /**
724
+ * The buttons a notification offers, for an item a device answers from the notification itself. `permission`: Allow
725
+ * once (`device.permission.reply` with `reply: 'once'`), Reject (`reply: 'reject'`) and Open, which opens the item in
726
+ * the app. On iOS it is also the notification's category (`aps.category`). Since protocol 1.5.
727
+ */
728
+ export type TDevicePushActions = 'permission';
723
729
  /**
724
730
  * One Inbox item that came: an alert (iOS: thread `inbox`, interruption level `active`; Android: channel Inbox). With
725
731
  * previews off it says only the kind's fixed sentence; with previews on also where the item lives, what it asks and
726
- * its id. Tapping it opens the Inbox. Since protocol 1.4.
732
+ * its id, and for a permission the device can answer (`device.inbox.list` names its answer `session` or `child`) the
733
+ * buttons and the ids their reply names. Tapping it opens the Inbox. Since protocol 1.4.
727
734
  */
728
735
  export interface IDevicePushInboxData {
729
736
  type: 'inbox';
@@ -743,6 +750,18 @@ export interface IDevicePushInboxData {
743
750
  title?: string;
744
751
  /** Previews on only: the item's id, as `device.inbox.list` names it. */
745
752
  itemId?: string;
753
+ /**
754
+ * Previews on only, and only for an item the device answers from the notification: the buttons it offers. Set
755
+ * together with `sessionId` and `permissionId` (and `childSessionId` for a direct child's permission), never alone.
756
+ * Since protocol 1.5.
757
+ */
758
+ actions?: TDevicePushActions;
759
+ /** With `actions`: `device.permission.reply`'s `sessionId`. Since protocol 1.5. */
760
+ sessionId?: string;
761
+ /** With `actions`, only for a direct child's permission: `device.permission.reply`'s `childSessionId`. Since protocol 1.5. */
762
+ childSessionId?: string;
763
+ /** With `actions`: `device.permission.reply`'s `permissionId`. Since protocol 1.5. */
764
+ permissionId?: string;
746
765
  }
747
766
  /**
748
767
  * More than four items came at once: one notification says so (iOS: thread `inbox`, level `active`; Android: channel
@@ -762,7 +781,7 @@ export interface IDevicePushSummaryData {
762
781
  /**
763
782
  * A direct report's new `result:` line, sent only to a registration with `reports` (iOS: thread `reports`,
764
783
  * interruption level `passive`; Android: channel Reports, low importance). It leaves the badge alone: a result waits
765
- * for nobody. Since protocol 1.4.
784
+ * for nobody. Tapping it opens the Driver tab, where the direct reports are. Since protocol 1.4.
766
785
  */
767
786
  export interface IDevicePushReportData {
768
787
  type: 'report';
@@ -801,9 +820,11 @@ export interface IDevicePushClearData {
801
820
  * What a notification from the host carries, the same for both platforms, each value a string because FCM data carries
802
821
  * only strings: FCM sends it as a data-only message's `data` (the Android app builds the notification itself), APNs as
803
822
  * the payload's `agl` object beside `aps` (an alert push for `inbox`, `summary`, `report` and `test`, a background push
804
- * for `clear`). No notification carries a session's or a ticket's id with previews off. A later minor may add keys and
805
- * types: an app ignores keys it does not know, and a notification whose `type` it does not know, except an iOS alert
806
- * push, which the system presents from `aps` without running the app. Since protocol 1.4.
823
+ * for `clear`). No notification carries a session's or a ticket's id with previews off. An inbox notification with
824
+ * `actions` names its category on iOS (`aps.category`); an app that registers no category of that name shows it without
825
+ * buttons. A later minor may add keys and types: an app ignores keys it does not know, and a notification whose `type`
826
+ * it does not know, except an iOS alert push, which the system presents from `aps` without running the app. Since
827
+ * protocol 1.4.
807
828
  */
808
829
  export type TDevicePushData = IDevicePushInboxData | IDevicePushSummaryData | IDevicePushReportData | IDevicePushTestData | IDevicePushClearData;
809
830
  /**
@@ -1494,8 +1515,10 @@ export interface IReq_DeviceHostGet extends implementsTR<ITypedRequest, IReq_Dev
1494
1515
  /**
1495
1516
  * Registers this device for notifications of what comes into the Inbox, and with `reports` of the direct reports'
1496
1517
  * results too: one registration per device, which the next one replaces, so an app registers again with its current
1497
- * token on every connect. Taken also while the host holds no credential to send with (the answer's `available` says
1498
- * so). The token stays on the host: no answer, event or log repeats it. Scope `device`. Since protocol 1.4.
1518
+ * token on every connect. A token is one device's: the registration of any other device holding the same platform's
1519
+ * token (the same app, paired before) ends with it. Taken also while the host holds no credential to send with (the
1520
+ * answer's `available` says so). The token stays on the host: no answer, event or log repeats it. Scope `device`.
1521
+ * Since protocol 1.4.
1499
1522
  */
1500
1523
  export interface IReq_DevicePushRegister extends implementsTR<ITypedRequest, IReq_DevicePushRegister> {
1501
1524
  method: 'device.push.register';
@@ -1,5 +1,5 @@
1
1
  /** The device protocol this controller speaks. */
2
- export const deviceProtocolVersion = { major: 1, minor: 4 };
2
+ export const deviceProtocolVersion = { major: 1, minor: 5 };
3
3
  /** The scheme of a pairing payload: `agl-pair:?origin=<https origin>&controller=<controller id>&code=<base64url>`. */
4
4
  export const devicePairingScheme = 'agl-pair';
5
5
  /** The first field of the message a device signs to pair. */
@@ -120,4 +120,4 @@ export const deviceMethods = [
120
120
  'device.ticket.ask',
121
121
  'device.ticket.move',
122
122
  ];
123
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGV2aWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzX2ludGVyZmFjZXMvZGV2aWNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFrQkEsa0RBQWtEO0FBQ2xELE1BQU0sQ0FBQyxNQUFNLHFCQUFxQixHQUFHLEVBQUUsS0FBSyxFQUFFLENBQUMsRUFBRSxLQUFLLEVBQUUsQ0FBQyxFQUFXLENBQUM7QUFFckUsc0hBQXNIO0FBQ3RILE1BQU0sQ0FBQyxNQUFNLG1CQUFtQixHQUFHLFVBQW1CLENBQUM7QUFDdkQsNkRBQTZEO0FBQzdELE1BQU0sQ0FBQyxNQUFNLHlCQUF5QixHQUFHLGlCQUEwQixDQUFDO0FBQ3BFLGtGQUFrRjtBQUNsRixNQUFNLENBQUMsTUFBTSxnQ0FBZ0MsR0FBRyxpQkFBMEIsQ0FBQztBQUMzRSxpRUFBaUU7QUFDakUsTUFBTSxDQUFDLE1BQU0saUJBQWlCLEdBQUcsRUFBRSxDQUFDO0FBQ3BDLHFFQUFxRTtBQUNyRSxNQUFNLENBQUMsTUFBTSx1QkFBdUIsR0FBRyxDQUFDLEdBQUcsRUFBRSxHQUFHLElBQUksQ0FBQztBQUNyRCwyRkFBMkY7QUFDM0YsTUFBTSxDQUFDLE1BQU0seUJBQXlCLEdBQUcsRUFBRSxHQUFHLElBQUksQ0FBQztBQUNuRCxvREFBb0Q7QUFDcEQsTUFBTSxDQUFDLE1BQU0sNEJBQ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tJQUN2QiwwQkFBMEI7SUFDMUIsbUJBQW1CO0lBQ25CLHNCQUFzQjtJQUN0QixtQkFBbUI7SUFDbkIsb0JBQW9CO0lBQ3BCLG9CQUFvQjtJQUNwQixvQkFBb0I7SUFDcEIsMkJBQTJCO0lBQzNCLDZCQUE2QjtJQUM3QixpQkFBaUI7SUFDakIsc0JBQXNCO0lBQ3RCLHdCQUF3QjtJQUN4QixtQkFBbUI7SUFDbkIsbUJBQW1CO0lBQ25CLHVCQUF1QjtJQUN2QixtQkFBbUI7SUFDbkIsb0JBQW9CO0NBQ1osQ0FBQyJ9
@@ -87,6 +87,8 @@ export interface IFleetConfiguration {
87
87
  export interface IFleetScope extends IFleetConfiguration {
88
88
  repositories: IFleetRepository[];
89
89
  skipped?: IFleetDiscoverySkip[];
90
+ /** The canonical checkouts discovery found that declare neither a release nor a fleet section, by real path. */
91
+ unconfigured?: string[];
90
92
  }
91
93
  export type TFleetOperation = 'land' | 'release' | 'tooling' | 'audit' | 'reconcile';
92
94
  export interface IFleetLandRequest {
@@ -220,6 +222,21 @@ export interface IFleetUnboundDriver {
220
222
  */
221
223
  nativeMessage?: string;
222
224
  }
225
+ /** A discovered repository the audit could not read; the audit goes on with the others. */
226
+ export interface IFleetUnauditedRepository {
227
+ repo: string;
228
+ path: string;
229
+ reason: string;
230
+ }
231
+ /**
232
+ * A landed ticket whose branch or commit link names a repository fleet discovery did not admit, so no release of it
233
+ * releases the ticket from there: `repo` is the name as the link holds it, `reason` why discovery did not admit it.
234
+ */
235
+ export interface IFleetLandedOutsideFleet {
236
+ ticketKey: string;
237
+ repo: string;
238
+ reason: string;
239
+ }
223
240
  export interface IFleetAuditResult {
224
241
  operation: 'audit';
225
242
  entries: IFleetAuditEntry[];
@@ -227,6 +244,12 @@ export interface IFleetAuditResult {
227
244
  /** The audited repositories with the source of each setting, and the checkouts discovery did not admit. */
228
245
  repositories?: IFleetRepository[];
229
246
  skipped?: IFleetDiscoverySkip[];
247
+ /** The repositories whose audit failed, each with its reason. */
248
+ unaudited?: IFleetUnauditedRepository[];
249
+ /** The landed tickets whose code links name a repository outside the fleet, each with why. */
250
+ landedOutsideFleet?: IFleetLandedOutsideFleet[];
251
+ /** Why the board could not be read for `landedOutsideFleet`. */
252
+ landedOutsideFleetError?: string;
230
253
  /** Claude Code background jobs that look like drivers and that no worker binds. */
231
254
  unboundDrivers?: IFleetUnboundDriver[];
232
255
  /** The Claude Code inventories the unbound driver search could not read, each with its reason. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agl",
3
- "version": "43.10.2",
3
+ "version": "43.12.0",
4
4
  "controllerUpgradeManagementVersion": 2,
5
5
  "controllerManagementProtocolVersion": 1,
6
6
  "controllerGatewaySourcesVersion": 1,
package/readme.md CHANGED
@@ -1302,8 +1302,10 @@ Fleet operations run on the controller's host. There is no central repository li
1302
1302
  discovers every canonical checkout (a directory whose `.git` is a directory, not a linked
1303
1303
  worktree) up to three levels below the controller's standard project directories, plus each
1304
1304
  registered project that is itself a canonical checkout. A checkout belongs to the fleet when
1305
- its `.smartconfig.json` declares a `@git.zone/cli` release or a fleet section; `"fleet": false`
1306
- opts it out. Each setting is read from the repository itself:
1305
+ its `.smartconfig.json` declares a `@git.zone/cli` release or a fleet section and its `main` has
1306
+ a commit; `"fleet": false` opts it out. The fleet lands and releases on `main` only: a checkout
1307
+ whose default branch is another (`master`) or whose `main` is unborn is skipped with that reason,
1308
+ never followed onto its own branch. Each setting is read from the repository itself:
1307
1309
 
1308
1310
  - `id`: the directory name, or `parent/name` while two checkouts share a name;
1309
1311
  - `remote`: `git config branch.main.remote`, else `origin`;
@@ -1331,8 +1333,19 @@ opts it out. Each setting is read from the repository itself:
1331
1333
 
1332
1334
  `agl fleet audit` lists each discovered repository with the file and key of every setting in
1333
1335
  `sources`, and each skipped checkout with its reason (opted out, an invalid section, an
1334
- unreadable file or an ambiguous id). A repository name that matches no discovered checkout
1335
- refuses with that reason. `remote` names the remote that canonical main tracks, such as
1336
+ unreadable file, an ambiguous id, no commit on `main`, or a remote or registry the fleet cannot
1337
+ use). A repository name that matches no discovered checkout refuses with that reason, in a
1338
+ fleet operation as in a release plan or an `affects` link. A repository whose audit fails is
1339
+ listed under `unaudited` with its reason and the audit goes on with the others; `entries` may
1340
+ still hold what was read of it before the failure, and with `--cleanup` `removed` holds the refs
1341
+ already deleted. `--repo` fails with it, and its error names the refs its cleanup removed before
1342
+ the failure. `landedOutsideFleet` names each landed ticket whose
1343
+ branch or commit link names a repository the fleet does not hold, with why: the reason its
1344
+ checkout was skipped, a checkout without a release or fleet section, a name several fleet
1345
+ repositories match, or no canonical checkout below the roots or among the registered projects.
1346
+ The release reconciler releases a ticket only from fleet repositories, so such a ticket stays in
1347
+ landed until its repository joins the fleet; `landedOutsideFleetError` says why the board could
1348
+ not be read. `remote` names the remote that canonical main tracks, such as
1336
1349
  `lossless`; fleet fetches, bases and pushes through it alone. List every build step CI requires
1337
1350
  in `ciBuildSteps`, including auxiliary builds. Test and guard paths support globs under `test/`;
1338
1351
  every matching file runs separately and must report a non-empty passing count. Configure a
@@ -1384,7 +1397,14 @@ lockfile conflicts, and regenerates admitted generated files. It runs production
1384
1397
  typechecks, the build, named tests and configured guards before fast-forwarding and
1385
1398
  pushing, so a test that loads the built bundle sees the branch's own build. A repository
1386
1399
  that declares a `test:before` script runs it in place of the early build, and the build
1387
- follows the tests. Named tests are resolved in the branch worktree after the rebase, so a test the
1400
+ follows the tests. Each check runs with the repository's own tooling, never a binary found on
1401
+ `PATH`: the production typecheck is its `typecheck` script, else `tsrepo build tsfolders`; the
1402
+ test typecheck its `check:test` script, else `tsrepo check 'test/**/*'`; each named test or
1403
+ guard `tsrepo test <file> --timeout 120 --logfile`; a regenerated file `tsrepo run <generator>`.
1404
+ `tsrepo` is used when the repository's `package.json` pins `@git.zone/tsrepo`; a repository
1405
+ still on the deprecated single tools runs the `tsbuild`, `tstest` or `tsrun` it pins instead. A
1406
+ pinned tool must be installed in the repository's own `node_modules/.bin`. A step with neither a
1407
+ script nor a pinned tool refuses the landing or release and names what to add. Named tests are resolved in the branch worktree after the rebase, so a test the
1388
1408
  branch adds, or one main received through another landing, can qualify it; a name that matches
1389
1409
  no file there refuses the landing before verification. The released-changelog guard compares released sections by
1390
1410
  position, so repeated headings stay distinct. Canonical main must be clean and equal to its
@@ -4003,7 +4023,7 @@ The device API is its own contract, separate from the browser's: `ts_interfaces/
4003
4023
  - `device.directreports.list` lists the active direct reports as the Driver view does, each by its name, with its session as the feed names it, status, projects, ticket, newest `result:` line, open questions and the fleet workers that report to it (name, harness, status, ticket; no directories or profiles), and whether it takes a message. `device.directreport.message` sends one the owner's message as the Driver view does: a fleet worker report is steered through its ticket and answers `fleet` once the steer succeeded (a steer the fleet refused before its dispatch is refused with `direct_report_failed` and the fleet's own text, such as "Worker is archived.", or "The controller operation failed." with the failure journal's reference where a harness's own text failed it; a steer that failed after its dispatch, or whose job does not prove it sent nothing (`errorOutcome` other than `refused`), may have delivered the message and is `outcome_unknown`, "The request may have taken effect. Read again to learn whether it did before sending it again." with the failure journal's reference, which a client never sends again on its own); a Codex thread takes it as the owner's agent message, `steer` into the turn AGL runs or `next-turn`. A turn another Codex client runs is refused with `direct_report_busy` (nothing was sent), a Claude Code session the fleet does not run with `direct_report_failed`, and messages to a report faster than its agent message rate with `rate_limited`. Messages are audited as `session.message` from `Owner` for the device.
4004
4024
  - The Host view is read-only (AGL-824): a device changes nothing on the host (no deploy or deploy probe, account, setting, upgrade or pairing). `device.host.get` answers what runs (`agl`: the AGL release, its start, its public origin, and whether a device reaches it through the gateway AGL keeps its route on, with where that route's sync stands, or through the owner's own reverse proxy; never the gateway's address, the client or the route's target), the device itself as the controller keeps it (`device`: name, model, when it paired and when it last connected; a device neither renames nor unpairs itself), the deploy targets (`deploys`: what each runs and since when, whether its probe answers, its newest release, the released versions it does not run (`undeployed`, newest first), and its planned deploys (`plans`: the ticket, the version, the owner's go and, for one queued into a maintenance window, the window's times); never a probe's address, the owner's notes on how it deploys and what a deploy interrupts, a failed probe's text, a plan's question or who deploys it, and the read runs no probe), the inference proxy's account pools (`pools`: each pool's verdict and room, and its accounts by plan and then the most used first, each only as its plan, state and the usage window it is bound by: no account id, and no order that stands in for one) and the API keys (`apiKeys`: per provider, how many keys are under their monthly spend limit, held at it, without one, or not read, judged by the rule AGL's inference proxy places by; no label, email, id or dollar amount). `deploys`, `pools` and `apiKeys` each answer `ready` or `unavailable` on their own, with the reason (`not_running`, `outdated`, or `failed` with the failure journal's `reference`), and the request still answers the others. `host.changed` (no payload) says when to read it again: the deploy targets, their planned deploys (tickets) or the accounts changed. Usage moves without an event, so a client reads it again when the Host view is opened or refreshed.
4005
4025
  - The shared board on a device is the browser's board (AGL-1637). `device.board.list` answers one column at a time, as the browser shows its cards (the tasks; an epic and a subtask open with `device.ticket.get`), in the column's order, `limit` (1 to 100, default 50) from `offset`, filtered as the browser filters: `text` (1 to 200 characters, in the key, title, description and source words), `project`, `epic` (the epic's own tasks), `assignee` (`{ kind: 'owner' }`, `{ kind: 'unassigned' }` or a session as the feed names it) and an AutoLabel (`openQuestion`, `planned`, `undeployed`). Every column's count under the same filters comes from the same read as the page, with `total`, the projects the board's tickets name, the epics a filter may choose and the board's `revision`: when a later page answers another revision, or `tickets.changed` arrives, a client reads the board again from offset 0. `device.ticket.get` answers a ticket with its description, source words, links and parent, one page of its discussion (comments and questions together in the order they were written, newest page first, at most `limit` of 1 to 50 and 256 KiB, `before` for the next older page), where it runs (`placement`, from the deploy monitor, `unavailable` on its own as a section of `device.host.get` is) and what it plans (`plans`: the release plan, the maintenance window and the deploy plan, with where the window stands and the owner's go while the monitor answers); no history of its other changes, no source attachments, no plan's question and nothing that names who deploys it. People appear by name: the owner as `kind: 'owner'`, never the owner's account, a person's id or a session the feed does not list (the driver's own session included). `device.ticket.comment` (Markdown, at most 64 KiB as the store keeps it), `device.ticket.ask` (text alone, at most 16 KiB, answered with text) and `device.ticket.move` (to the end of a column; "Move to…" stands in for the browser's drag) run the browser board's own function as the owner, audited as `ticket.comment`, `ticket.ask` and `ticket.move` for the device; `device.ticket.answer` answers a question. The controller decides every change: a refusal changes nothing and carries the ticket store's own code (`deviceTicketRefusalCodes`, such as `ticket_review_branch_required` for a move to review without a branch) and its reason. The app then keeps the owner's draft, reads the ticket again and shows the reason; it never sends a refused change again on its own. A change whose outcome AGL cannot tell is refused as `outcome_unknown` and stays fenced: the app reads the ticket again to learn whether it happened before the owner decides, and never sends it again on its own. Creating, editing and assigning tickets stay in the browser.
4006
- - Notifications (AGL-1639): `device.push.register` registers the device itself, never another, with its push service's token (`platform` `apns` with the device token as lowercase hex and its `environment`, `sandbox` or `production`, or `fcm` with the registration token) and whether it wants the direct reports' results too (`reports`). A device holds one registration, which the next one replaces, so the app registers again with its current token on every connect; the same request again changes nothing. It answers the registration as `device.host.get` shows it (`push`: `reports`, `previews`, `available`, `lastFailure`), and is taken also while the host cannot send (`available` `false`: the owner has not set the platform's credential, or Apple or Google refused it; see [Notifications](#notifications)). `device.push.unregister` ends it (`removed` says whether there was one). The token is kept only in the registration (`agl_controller_push_registrations`, one record per device, beside the device record and never in it); no answer, event, audit entry or log repeats it. Revoking the device and an origin move delete its registration with it, in the same transaction, and a start removes every registration whose device is gone.
4026
+ - Notifications (AGL-1639): `device.push.register` registers the device itself, never another, with its push service's token (`platform` `apns` with the device token as lowercase hex and its `environment`, `sandbox` or `production`, or `fcm` with the registration token) and whether it wants the direct reports' results too (`reports`). A device holds one registration, which the next one replaces, so the app registers again with its current token on every connect; the same request again changes nothing. A token is one device's: the app holds one pairing, so when a registration takes a token another device's registration holds on the same platform (the app was unpaired without revoking the device here, then paired again), that registration ends in the same transaction and nothing new is sent to it; this controller also drops what it still had queued for that device, while another controller of the same store can still deliver what it had already queued for up to an hour. The earlier device stays paired until it is revoked; the APNs environment is no part of the match. It answers the registration as `device.host.get` shows it (`push`: `reports`, `previews`, `available`, `lastFailure`), and is taken also while the host cannot send (`available` `false`: the owner has not set the platform's credential, or Apple or Google refused it; see [Notifications](#notifications)). `device.push.unregister` ends it (`removed` says whether there was one). The token is kept only in the registration (`agl_controller_push_registrations`, one record per device, beside the device record and never in it); no answer, event, audit entry or log repeats it. Revoking the device and an origin move delete its registration with it, in the same transaction, and a start removes every registration whose device is gone.
4007
4027
  - Every refusal of every device method carries one code of `TDeviceRefusalCode` as `error.data.code` and a message to show, whatever the controller refused it with (AGL-1670): the set is closed, and within a major it only grows. The pairing and the connection: `device_unknown` (forget the pairing), `device_pairing_invalid`, `device_pairing_unavailable`, `device_limit`, `device_already_paired`, `device_proof_invalid`, `device_challenge_invalid` and `device_authentication_required`. What the request names is gone: `session_not_found` (list the feed again), `driver_absent`, and the ticket store's `ticket_not_found` and `ticket_question_not_found`. Nothing was done because something else changed meanwhile, so read again, then decide: `concurrent_change` (among others an answer to a permission or question the session no longer holds, AGL-1687), `ticket_revision_conflict` and `direct_report_busy`. Refused by a rule, with the reason: `session_read_only` (including a session whose model or stopped message the owner resolves in the browser first), `invalid_request`, `direct_report_failed` and the ticket store's other codes (`deviceTicketRefusalCodes`). Limits: `rate_limited`, final as every refusal, and `operation_limit`. The controller: `controller_unavailable` (not ready: starting, stopping, or a harness or the Flex child not running) and `controller_failed` (a fault, always "The controller operation failed."; `error.data.reference` names the failure journal entry the owner's browser shows, and no message to a device carries a raw cause such as a socket path or a spawn error). `outcome_unknown` means the request may have happened: AGL dispatched it, or may have, and cannot tell whether it took effect. A client never resends it on its own; it keeps the owner's text, reads the session, the driver or the ticket again to learn the outcome, and the owner decides.
4008
4028
  - The controller pushes a device an allowlist of events in their own shape: feed changes, a session's change, its streaming text (snapshots and exact deltas), Inbox changes, the driver's changes (`driver.changed` with its status, also when its transcript or prompts changed, never its streaming text), the direct reports' changes (`directreports.changed`, with no payload, also when fleet workers or tickets changed), the host's changes (`host.changed`, with no payload, when the deploy targets or the accounts changed), the board's changes (`tickets.changed`, with no ticket key and with the board's revision when it moved, followed by `directreports.changed` and `host.changed`, since tickets hold the reports' questions and the planned deploys) and a resynchronization request. Every other event, and every event about a session the feed does not list, stays on the controller. A device that falls behind by 256 events or 4 MiB is resynchronized alone: on `sessions.changed` it lists the feed and reads the open session again, an open Driver view included (the driver's own changes may have folded into it).
4009
4029
  - Through the gateway, a device's WebSocket upgrade carries the public origin as `Origin`, like a browser's (Admission).
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '43.10.2',
6
+ version: '43.12.0',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }
@@ -54,9 +54,11 @@ const badgeOf = (valueArg: string): number | undefined => (/^\d{1,9}$/u.test(val
54
54
  /**
55
55
  * The APNs request for a notification: an alert push with `aps` (the alert, `thread-id` inbox or reports,
56
56
  * `interruption-level` active or passive, the default sound except for a report's result, the badge where the payload
57
- * carries one) for `inbox`, `summary`, `report` and `test`, a background push (`content-available`, priority 5) for `clear`, and the payload itself under `agl`. The
58
- * payload's key is `apns-collapse-id`, so a notification sent again replaces the one shown. None when the payload breaks
59
- * Apple's limits.
57
+ * carries one, and for an inbox notification with `actions` that value as `category`, the buttons the app registered
58
+ * under it) for `inbox`, `summary`, `report` and `test`, a background push (`content-available`, priority 5) for
59
+ * `clear`, and the payload itself under `agl`. No `mutable-content`: no extension changes a notification. The payload's
60
+ * key is `apns-collapse-id`, so a notification sent again replaces the one shown. None when the payload breaks Apple's
61
+ * limits.
60
62
  */
61
63
  export const apnsRequest = (topicArg: string, payloadArg: TDevicePushData, expiresAtArg: number): IApnsRequest | undefined => {
62
64
  const alert = (bodyArg: string, titleArg?: string) => (titleArg === undefined ? { body: bodyArg } : { title: titleArg, body: bodyArg });
@@ -65,7 +67,10 @@ export const apnsRequest = (topicArg: string, payloadArg: TDevicePushData, expir
65
67
  case 'inbox': {
66
68
  const badge = badgeOf(payloadArg.badge);
67
69
  if (badge === undefined) return undefined;
68
- aps = { alert: alert(payloadArg.body, payloadArg.title), badge, sound: 'default', 'thread-id': 'inbox', 'interruption-level': 'active' };
70
+ aps = {
71
+ alert: alert(payloadArg.body, payloadArg.title), badge, sound: 'default', 'thread-id': 'inbox', 'interruption-level': 'active',
72
+ ...(payloadArg.actions === undefined ? {} : { category: payloadArg.actions }),
73
+ };
69
74
  break;
70
75
  }
71
76
  case 'summary': {
@@ -11024,6 +11024,8 @@ export class OpenCodeController {
11024
11024
  targets: () => devices.pushTargets(),
11025
11025
  delivery: this.pushDelivery,
11026
11026
  previews: () => pushSettings.previews(),
11027
+ // The rows `device.inbox.list` names sessions by: a previewed permission a device answers carries its buttons.
11028
+ rowOf: (rowIdArg) => this.sessionFeed?.publishedRow(rowIdArg),
11027
11029
  // What the last clean stop announced, read (and removed) before the first change is sent; written by the stop.
11028
11030
  handover: {
11029
11031
  take: () => takePushHandover(pushControllerId),
@@ -15138,9 +15140,13 @@ export class OpenCodeController {
15138
15140
  routerArg.addHandler<IReq_DevicePushRegister>('device.push.register', async (requestArg, toolsArg) => {
15139
15141
  const request = validateRequest(() => assertDevicePushRegisterRequest(requestArg));
15140
15142
  const { peer, deviceId } = this.requestDevice(toolsArg?.localData);
15141
- return this.runDeviceOperation(peer, deviceId, async () => ({
15142
- push: deviceHostPush(await this.requireDevices().registerPush(deviceId, request), this.devicePushState(deviceId, request.platform)),
15143
- }), toolsArg?.abortSignal);
15143
+ return this.runDeviceOperation(peer, deviceId, async () => {
15144
+ const { registration, displaced } = await this.requireDevices().registerPush(deviceId, request);
15145
+ // A device whose registration held the same token is this app paired before: drop this controller's queued sends for it
15146
+ // (another controller of the store keeps what it already queued until that ages out).
15147
+ for (const displacedId of displaced) this.pushDelivery?.forget(displacedId);
15148
+ return { push: deviceHostPush(registration, this.devicePushState(deviceId, request.platform)) };
15149
+ }, toolsArg?.abortSignal);
15144
15150
  });
15145
15151
 
15146
15152
  routerArg.addHandler<IReq_DevicePushUnregister>('device.push.unregister', async (requestArg, toolsArg) => {
@@ -34,6 +34,7 @@ import {
34
34
  readPushTargets,
35
35
  sweepPushRegistrations,
36
36
  writePushRegistration,
37
+ type IControllerPushRegistrationWrite,
37
38
  type IControllerPushTarget,
38
39
  type TControllerPushRegistrationRequest,
39
40
  type TControllerPushRegistrationState,
@@ -506,9 +507,10 @@ export class ControllerDevices {
506
507
 
507
508
  /**
508
509
  * Registers a paired device for notifications, replacing its registration: it runs in the order of the device
509
- * writes, after a revocation that came first, so a revoked device is never registered.
510
+ * writes, after a revocation that came first, so a revoked device is never registered. The registration of every
511
+ * other device that held the same token goes with it (`writePushRegistration`); the answer names those devices.
510
512
  */
511
- public registerPush(deviceIdArg: string, requestArg: TControllerPushRegistrationRequest): Promise<TControllerPushRegistrationState> {
513
+ public registerPush(deviceIdArg: string, requestArg: TControllerPushRegistrationRequest): Promise<IControllerPushRegistrationWrite> {
512
514
  if (this.closed) return Promise.reject(deviceRefusal('controller_unavailable', 'The controller is stopping.'));
513
515
  return this.mutate(async () => {
514
516
  if (!this.records.has(deviceIdArg)) throw deviceRefusal('device_unknown', 'No such device is paired with this controller.');
@@ -11,12 +11,14 @@ import type { IDirectReport } from '../ts_interfaces/directreports.js';
11
11
  import {
12
12
  controllerInboxLimits,
13
13
  type IControllerInboxSnapshot,
14
+ type IControllerSessionFeedRow,
14
15
  type TControllerInboxDelta,
15
16
  type TControllerInboxItem,
16
17
  type TControllerInboxWhere,
17
18
  } from '../ts_interfaces/index.js';
18
19
  import { apnsRequest } from './classes.apnsclient.js';
19
20
  import { fcmMessage } from './classes.fcmclient.js';
21
+ import { deviceInboxItem } from './functions.deviceapi.js';
20
22
  import { inboxTitle } from './classes.inbox.js';
21
23
  import type { IPushDeliveryTarget } from './classes.pushdelivery.js';
22
24
  import { pushKeySubjects, pushNotificationKey, type IControllerPushTarget } from './classes.pushregistrations.js';
@@ -64,6 +66,11 @@ export interface IControllerPushOptions {
64
66
  delivery: IControllerPushDelivery;
65
67
  /** Whether notifications carry previews (`ControllerPushSettings.previews`). */
66
68
  previews(): boolean;
69
+ /**
70
+ * The session feed's row a device names a session by, as `device.inbox.list` reads it (`SessionFeed.publishedRow`):
71
+ * whether a previewed notification's item is one the device answers.
72
+ */
73
+ rowOf(rowIdArg: string): IControllerSessionFeedRow | undefined;
67
74
  /** Read once as the trigger starts, before any change is sent, and written once by `stop`. */
68
75
  handover: IControllerPushHandover;
69
76
  /** A failure no caller sees: a registration read that failed, a handover that was not there or not kept, a fault of the trigger. */
@@ -94,6 +101,24 @@ const pushPlace = (whereArg: TControllerInboxWhere): string => {
94
101
  }
95
102
  };
96
103
 
104
+ /** A previewed notification's buttons and the ids their reply names (protocol 1.5). */
105
+ type TPushReply = Pick<IDevicePushInboxData, 'actions' | 'sessionId' | 'childSessionId' | 'permissionId'>;
106
+
107
+ /**
108
+ * The buttons of a previewed notification and the ids `device.permission.reply` names, for a permission a device
109
+ * answers as `device.inbox.list` shows the item (`deviceInboxItem`: answer `session`, or `child` with the child's id);
110
+ * none for any other item.
111
+ */
112
+ const pushReply = (itemArg: TControllerInboxItem, rowOfArg: (rowIdArg: string) => IControllerSessionFeedRow | undefined): TPushReply => {
113
+ const item = deviceInboxItem(itemArg, rowOfArg);
114
+ if (item.kind !== 'permission' || item.permission === undefined || item.where.kind !== 'session') return {};
115
+ const { sessionId, childSessionId } = item.where;
116
+ const permissionId = item.permission.id;
117
+ if (item.answer === 'session') return { actions: 'permission', sessionId, permissionId };
118
+ if (item.answer === 'child' && childSessionId !== undefined) return { actions: 'permission', sessionId, childSessionId, permissionId };
119
+ return {};
120
+ };
121
+
97
122
  /** Whether a payload fits both push services' limits, as their senders build the request. */
98
123
  const pushPayloadFits = (payloadArg: TDevicePushData): boolean => (
99
124
  apnsRequest('com.modelprofile.harness', payloadArg, 0) !== undefined && fcmMessage('token', payloadArg, 0, 0) !== undefined
@@ -107,7 +132,7 @@ const cut = (textArg: string, charactersArg: number): string => {
107
132
 
108
133
  /**
109
134
  * A previewed notification within the push services' limits: its title and body cut shorter until it fits (Apple
110
- * repeats both in `aps`), or, for an item whose id alone leaves no room, `plainArg`.
135
+ * repeats both in `aps`), or, for an item whose ids alone leave no room, `plainArg`. Ids are never cut.
111
136
  */
112
137
  const fitted = <TPayload extends IDevicePushInboxData | IDevicePushReportData>(
113
138
  plainArg: TPayload,
@@ -322,6 +347,10 @@ export class ControllerPush {
322
347
  private sendInboxChange(changeArg: IInboxChange, targetsArg: readonly IControllerPushTarget[]): void {
323
348
  const { delivery } = this.options;
324
349
  const badge = String(changeArg.total);
350
+ // Read once per change, as `device.inbox.list` would show the items now; only previewed notifications carry it.
351
+ const replies = new Map(changeArg.previews && changeArg.added.length <= pushSummaryThreshold
352
+ ? changeArg.added.map((itemArg) => [itemArg.id, pushReply(itemArg, (rowIdArg) => this.options.rowOf(rowIdArg))] as const)
353
+ : []);
325
354
  for (const registration of targetsArg) {
326
355
  const target = deliveryTarget(registration);
327
356
  const summaryKey = pushNotificationKey(registration.salt, pushKeySubjects.summary);
@@ -343,6 +372,7 @@ export class ControllerPush {
343
372
  delivery.send(target, changeArg.previews
344
373
  ? fitted(plain, (charactersArg) => ({
345
374
  ...plain, title: cut(inboxTitle(pushPlace(item.where)), charactersArg), body: cut(item.title, charactersArg), itemId: item.id,
375
+ ...replies.get(item.id),
346
376
  }))
347
377
  : plain);
348
378
  }
@@ -36,7 +36,8 @@ const reservedDataKey = (keyArg: string): boolean => keyArg === 'from' || keyArg
36
36
 
37
37
  /**
38
38
  * The FCM v1 request body for a notification: a data-only message to the registration token (the payload's values as
39
- * they are, all strings), `android.priority` HIGH for what a person acts on (`inbox`, `summary`, `test`) and NORMAL for
39
+ * they are, all strings, an inbox notification's `actions` and reply ids too, counted toward the 4096 bytes like every
40
+ * other key; the app builds the buttons), `android.priority` HIGH for what a person acts on (`inbox`, `summary`, `test`) and NORMAL for
40
41
  * a report's result and a `clear`, and a `ttl` up to `expiresAtArg`. No collapse key: FCM keeps at most four of them per
41
42
  * device, and the app replaces a notification by its tag (the payload's key) itself. None when the payload breaks FCM's
42
43
  * limits.
@@ -106,45 +106,77 @@ export const readPushRegistration = async (deviceIdArg: string): Promise<TContro
106
106
  return stored === null ? undefined : stateOf(ControllerPushRegistrationModel.exact.toPersisted(stored));
107
107
  };
108
108
 
109
+ /** What a registration wrote: the device's registration, and the other devices whose registration held its token. */
110
+ export interface IControllerPushRegistrationWrite {
111
+ registration: TControllerPushRegistrationState;
112
+ /** The devices whose registration held the same platform and token: deleted with the write, in one transaction. */
113
+ displaced: string[];
114
+ }
115
+
109
116
  /**
110
117
  * Sets a device's registration: a new one gets a fresh salt, an existing one takes the request's platform, token and
111
- * choices and keeps its salt; the same request again writes nothing. The caller runs it after the device's record and
112
- * in the one order of the device's writes, so a revoked device is never registered again.
118
+ * choices and keeps its salt; the same request again writes nothing to it. A token is the address of one app on one
119
+ * phone, and the app holds one pairing: every other device's registration with the same platform and token is the
120
+ * same app paired before (unpaired in the app, never revoked here) and is deleted in the same transaction, so one
121
+ * token never receives a notification twice. The environment is no part of the match: an APNs token is globally unique
122
+ * and belongs to one environment. Nothing records the deletion; the token stays out of every error. The caller runs it
123
+ * after the device's record and in the one order of the device's writes, so a revoked device is never registered again.
113
124
  */
114
125
  export const writePushRegistration = async (
115
126
  deviceIdArg: string,
116
127
  requestArg: TControllerPushRegistrationRequest,
117
128
  nowArg: number,
118
- ): Promise<TControllerPushRegistrationState> => {
129
+ ): Promise<IControllerPushRegistrationWrite> => {
119
130
  const content = {
120
131
  platform: requestArg.platform,
121
132
  ...(requestArg.platform === 'apns' ? { environment: requestArg.environment } : {}),
122
133
  token: requestArg.token,
123
134
  reports: requestArg.reports,
124
135
  };
125
- const current = await ControllerPushRegistrationModel.exact.findStoredOne({ id: deviceIdArg });
126
- if (current === null) {
127
- const inserted = await ControllerPushRegistrationModel.exact.insert({
128
- id: deviceIdArg, ...content, salt: plugins.crypto.randomBytes(32).toString('base64url'), registeredAt: nowArg,
136
+ const session = ControllerPushRegistrationModel.collection.smartdataDb.createSession();
137
+ try {
138
+ const written = await session.withTransaction(async (transactionArg): Promise<IControllerPushRegistrationWrite> => {
139
+ const options = { session: transactionArg };
140
+ const displaced: string[] = [];
141
+ const holders = await ControllerPushRegistrationModel.exact.findStored({
142
+ filter: { platform: content.platform, token: content.token }, ...options,
143
+ });
144
+ for (const holder of holders) {
145
+ const { id } = ControllerPushRegistrationModel.exact.toPersisted(holder);
146
+ if (id === deviceIdArg) continue;
147
+ const result = await ControllerPushRegistrationModel.exact.delete({ current: holder }, options);
148
+ if (result.status !== 'deleted') throw new Error('A push registration holding the same token changed concurrently.');
149
+ displaced.push(id);
150
+ }
151
+ const current = await ControllerPushRegistrationModel.exact.findStoredOne({ id: deviceIdArg }, options);
152
+ if (current === null) {
153
+ const inserted = await ControllerPushRegistrationModel.exact.insert({
154
+ id: deviceIdArg, ...content, salt: plugins.crypto.randomBytes(32).toString('base64url'), registeredAt: nowArg,
155
+ }, options);
156
+ if (inserted.status !== 'inserted') throw new Error('The push registration changed concurrently and was not stored.');
157
+ return { registration: stateOf(ControllerPushRegistrationModel.exact.toPersisted(inserted.document)), displaced };
158
+ }
159
+ const stored = ControllerPushRegistrationModel.exact.toPersisted(current);
160
+ if (stored.platform === content.platform && stored.environment === content.environment && stored.token === content.token
161
+ && stored.reports === content.reports) {
162
+ return { registration: stateOf(stored), displaced };
163
+ }
164
+ const result = await ControllerPushRegistrationModel.exact.transition({ current, change: (modelArg) => {
165
+ modelArg.platform = content.platform;
166
+ if (content.environment === undefined) delete modelArg.environment;
167
+ else modelArg.environment = content.environment;
168
+ modelArg.token = content.token;
169
+ modelArg.reports = content.reports;
170
+ modelArg.registeredAt = nowArg;
171
+ } }, options);
172
+ if (result.status !== 'transitioned') throw new Error('The push registration changed concurrently and was not stored.');
173
+ return { registration: stateOf(ControllerPushRegistrationModel.exact.toPersisted(result.document)), displaced };
129
174
  });
130
- if (inserted.status !== 'inserted') throw new Error('The push registration changed concurrently and was not stored.');
131
- return stateOf(ControllerPushRegistrationModel.exact.toPersisted(inserted.document));
132
- }
133
- const stored = ControllerPushRegistrationModel.exact.toPersisted(current);
134
- if (stored.platform === content.platform && stored.environment === content.environment && stored.token === content.token
135
- && stored.reports === content.reports) {
136
- return stateOf(stored);
175
+ if (written === undefined) throw new Error('The push registration was not stored.');
176
+ return written;
177
+ } finally {
178
+ await session.close();
137
179
  }
138
- const result = await ControllerPushRegistrationModel.exact.transition({ current, change: (modelArg) => {
139
- modelArg.platform = content.platform;
140
- if (content.environment === undefined) delete modelArg.environment;
141
- else modelArg.environment = content.environment;
142
- modelArg.token = content.token;
143
- modelArg.reports = content.reports;
144
- modelArg.registeredAt = nowArg;
145
- } });
146
- if (result.status !== 'transitioned') throw new Error('The push registration changed concurrently and was not stored.');
147
- return stateOf(ControllerPushRegistrationModel.exact.toPersisted(result.document));
148
180
  };
149
181
 
150
182
  /**