@aeolus-fleet/core 0.39.1 → 0.41.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/README.md +7 -7
- package/dist/adapters/cli/fleet-init.d.ts +1 -1
- package/dist/adapters/cli/fleet-init.js +5 -3
- package/dist/adapters/cli/fleet-init.js.map +1 -1
- package/dist/adapters/cli/io.d.ts +5 -2
- package/dist/adapters/cli/io.js.map +1 -1
- package/dist/adapters/crypto/account-token-signatures.js +1 -1
- package/dist/adapters/crypto/account-token-signatures.js.map +1 -1
- package/dist/adapters/prisma/client.d.ts +8 -2
- package/dist/adapters/prisma/client.js +3 -3
- package/dist/adapters/prisma/client.js.map +1 -1
- package/dist/adapters/prisma/content-type-sql.d.ts +11 -0
- package/dist/adapters/prisma/content-type-sql.js +41 -0
- package/dist/adapters/prisma/content-type-sql.js.map +1 -0
- package/dist/adapters/prisma/delivery-notices.d.ts +2 -2
- package/dist/adapters/prisma/delivery-notices.js +2 -2
- package/dist/adapters/prisma/exchange-rollups.d.ts +3 -1
- package/dist/adapters/prisma/exchange-rollups.js +15 -9
- package/dist/adapters/prisma/exchange-rollups.js.map +1 -1
- package/dist/adapters/prisma/fill-message-question-ids.d.ts +7 -0
- package/dist/adapters/prisma/fill-message-question-ids.js +12 -0
- package/dist/adapters/prisma/fill-message-question-ids.js.map +1 -0
- package/dist/adapters/prisma/fleet-counter.js +1 -1
- package/dist/adapters/prisma/fleet-counter.js.map +1 -1
- package/dist/adapters/prisma/fleet-event-wakeups.d.ts +1 -7
- package/dist/adapters/prisma/fleet-event-wakeups.js +0 -19
- package/dist/adapters/prisma/fleet-event-wakeups.js.map +1 -1
- package/dist/adapters/prisma/fleet-removal.d.ts +17 -0
- package/dist/adapters/prisma/fleet-removal.js +109 -0
- package/dist/adapters/prisma/fleet-removal.js.map +1 -0
- package/dist/adapters/prisma/generated/browser.d.ts +6 -0
- package/dist/adapters/prisma/generated/client.d.ts +6 -0
- package/dist/adapters/prisma/generated/commonInputTypes.d.ts +0 -30
- package/dist/adapters/prisma/generated/enums.d.ts +1 -6
- package/dist/adapters/prisma/generated/enums.js +2 -6
- package/dist/adapters/prisma/generated/enums.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/class.d.ts +11 -0
- package/dist/adapters/prisma/generated/internal/class.js +4 -4
- package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +89 -10
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +13 -2
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +13 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +13 -2
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
- package/dist/adapters/prisma/generated/models/Exchange.d.ts +60 -1
- package/dist/adapters/prisma/generated/models/Fleet.d.ts +700 -1
- package/dist/adapters/prisma/generated/models/Message.d.ts +174 -1
- package/dist/adapters/prisma/generated/models/MessageMetadataBackfill.d.ts +1132 -0
- package/dist/adapters/prisma/generated/models/MessageMetadataBackfill.js +2 -0
- package/dist/adapters/prisma/generated/models/MessageMetadataBackfill.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Operator.d.ts +1 -40
- package/dist/adapters/prisma/generated/models.d.ts +1 -0
- package/dist/adapters/prisma/health-bootstrap-index.d.ts +2 -0
- package/dist/adapters/prisma/health-bootstrap-index.js +15 -0
- package/dist/adapters/prisma/health-bootstrap-index.js.map +1 -0
- package/dist/adapters/prisma/health-snapshots.js +6 -3
- package/dist/adapters/prisma/health-snapshots.js.map +1 -1
- package/dist/adapters/prisma/history.d.ts +3 -1
- package/dist/adapters/prisma/history.js +22 -4
- package/dist/adapters/prisma/history.js.map +1 -1
- package/dist/adapters/prisma/identity.js +6 -9
- package/dist/adapters/prisma/identity.js.map +1 -1
- package/dist/adapters/prisma/index-after-start.d.ts +16 -0
- package/dist/adapters/prisma/index-after-start.js +78 -0
- package/dist/adapters/prisma/index-after-start.js.map +1 -0
- package/dist/adapters/prisma/installation.js +3 -3
- package/dist/adapters/prisma/installation.js.map +1 -1
- package/dist/adapters/prisma/message-metadata-fill.d.ts +40 -0
- package/dist/adapters/prisma/message-metadata-fill.js +122 -0
- package/dist/adapters/prisma/message-metadata-fill.js.map +1 -0
- package/dist/adapters/prisma/messaging.d.ts +17 -1
- package/dist/adapters/prisma/messaging.js +60 -2
- package/dist/adapters/prisma/messaging.js.map +1 -1
- package/dist/adapters/prisma/page-with-messages.js +2 -0
- package/dist/adapters/prisma/page-with-messages.js.map +1 -1
- package/dist/adapters/prisma/receiver-wakeups.d.ts +11 -17
- package/dist/adapters/prisma/receiver-wakeups.js +0 -60
- package/dist/adapters/prisma/receiver-wakeups.js.map +1 -1
- package/dist/adapters/prisma/registry.js +19 -54
- package/dist/adapters/prisma/registry.js.map +1 -1
- package/dist/adapters/prisma/rows.js +3 -3
- package/dist/adapters/prisma/rows.js.map +1 -1
- package/dist/adapters/prisma/sealings.js +23 -7
- package/dist/adapters/prisma/sealings.js.map +1 -1
- package/dist/adapters/prisma/unit-of-work.d.ts +4 -2
- package/dist/adapters/prisma/unit-of-work.js +4 -0
- package/dist/adapters/prisma/unit-of-work.js.map +1 -1
- package/dist/adapters/prisma/unseen-plain-messages.d.ts +3 -0
- package/dist/adapters/prisma/unseen-plain-messages.js +20 -0
- package/dist/adapters/prisma/unseen-plain-messages.js.map +1 -0
- package/dist/adapters/telemetry/calls.d.ts +0 -8
- package/dist/adapters/telemetry/calls.js +3 -39
- package/dist/adapters/telemetry/calls.js.map +1 -1
- package/dist/adapters/trpc/console.d.ts +5 -10
- package/dist/adapters/trpc/console.js +2 -10
- package/dist/adapters/trpc/console.js.map +1 -1
- package/dist/adapters/trpc/context.d.ts +0 -2
- package/dist/adapters/trpc/fleet.d.ts +12 -13
- package/dist/adapters/trpc/fleet.js +6 -5
- package/dist/adapters/trpc/fleet.js.map +1 -1
- package/dist/adapters/trpc/installation.d.ts +12 -0
- package/dist/adapters/trpc/router.d.ts +36 -28
- package/dist/adapters/trpc/ship-protocol.js +1 -1
- package/dist/adapters/trpc/ship-protocol.js.map +1 -1
- package/dist/adapters/trpc/ship.d.ts +15 -15
- package/dist/adapters/trpc/ship.js +15 -16
- package/dist/adapters/trpc/ship.js.map +1 -1
- package/dist/adapters/trpc/trpc.js +0 -2
- package/dist/adapters/trpc/trpc.js.map +1 -1
- package/dist/app.d.ts +5 -3
- package/dist/app.js +79 -14
- package/dist/app.js.map +1 -1
- package/dist/domain/identity/authenticate-installation.d.ts +1 -1
- package/dist/domain/identity/authenticate-installation.js +2 -2
- package/dist/domain/identity/authenticate-installation.js.map +1 -1
- package/dist/domain/identity/notice.js +1 -0
- package/dist/domain/identity/notice.js.map +1 -1
- package/dist/domain/identity/operator-account.d.ts +1 -3
- package/dist/domain/identity/operator-account.js.map +1 -1
- package/dist/domain/identity/ports.d.ts +1 -6
- package/dist/domain/identity/read-account.d.ts +2 -3
- package/dist/domain/identity/read-account.js +1 -2
- package/dist/domain/identity/read-account.js.map +1 -1
- package/dist/domain/messaging/check-inbox.d.ts +6 -23
- package/dist/domain/messaging/check-inbox.js +14 -59
- package/dist/domain/messaging/check-inbox.js.map +1 -1
- package/dist/domain/messaging/exchange.d.ts +3 -1
- package/dist/domain/messaging/exchange.js +10 -6
- package/dist/domain/messaging/exchange.js.map +1 -1
- package/dist/domain/messaging/fill-message-metadata.d.ts +29 -0
- package/dist/domain/messaging/fill-message-metadata.js +54 -0
- package/dist/domain/messaging/fill-message-metadata.js.map +1 -0
- package/dist/domain/messaging/message.d.ts +5 -1
- package/dist/domain/messaging/message.js +9 -3
- package/dist/domain/messaging/message.js.map +1 -1
- package/dist/domain/messaging/ports.d.ts +63 -18
- package/dist/domain/messaging/public.d.ts +1 -0
- package/dist/domain/messaging/public.js +1 -0
- package/dist/domain/messaging/public.js.map +1 -1
- package/dist/domain/messaging/push-receive-deliveries.d.ts +4 -6
- package/dist/domain/messaging/push-receive-deliveries.js +5 -7
- package/dist/domain/messaging/push-receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/read-exchanges.d.ts +1 -0
- package/dist/domain/messaging/read-exchanges.js +2 -1
- package/dist/domain/messaging/read-exchanges.js.map +1 -1
- package/dist/domain/messaging/receive-deliveries.d.ts +4 -34
- package/dist/domain/messaging/receive-deliveries.js +4 -46
- package/dist/domain/messaging/receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/receive-reply.d.ts +5 -8
- package/dist/domain/messaging/receive-reply.js +10 -9
- package/dist/domain/messaging/receive-reply.js.map +1 -1
- package/dist/domain/messaging/retired-asker.d.ts +33 -0
- package/dist/domain/messaging/retired-asker.js +81 -0
- package/dist/domain/messaging/retired-asker.js.map +1 -0
- package/dist/domain/messaging/turn-on-sealing.js +1 -1
- package/dist/domain/messaging/turn-on-sealing.js.map +1 -1
- package/dist/domain/registry/check-reach.d.ts +1 -1
- package/dist/domain/registry/check-reach.js +2 -2
- package/dist/domain/registry/check-reach.js.map +1 -1
- package/dist/domain/registry/delete-fleet.d.ts +5 -3
- package/dist/domain/registry/delete-fleet.js +6 -4
- package/dist/domain/registry/delete-fleet.js.map +1 -1
- package/dist/domain/registry/expectations.js +1 -0
- package/dist/domain/registry/expectations.js.map +1 -1
- package/dist/domain/registry/found-fleet.js +1 -1
- package/dist/domain/registry/found-fleet.js.map +1 -1
- package/dist/domain/registry/network-settings.d.ts +5 -2
- package/dist/domain/registry/network-settings.js +2 -2
- package/dist/domain/registry/network-settings.js.map +1 -1
- package/dist/domain/registry/ports.d.ts +25 -8
- package/dist/domain/registry/public.d.ts +1 -1
- package/dist/domain/registry/read-reach.js +1 -1
- package/dist/domain/registry/read-reach.js.map +1 -1
- package/dist/domain/registry/remove-deleted-fleets.d.ts +30 -0
- package/dist/domain/registry/remove-deleted-fleets.js +54 -0
- package/dist/domain/registry/remove-deleted-fleets.js.map +1 -0
- package/dist/domain/registry/retire-ship.d.ts +6 -2
- package/dist/domain/registry/retire-ship.js +9 -1
- package/dist/domain/registry/retire-ship.js.map +1 -1
- package/dist/domain/registry/ship-order.js +1 -1
- package/dist/domain/registry/ship-order.js.map +1 -1
- package/dist/domain/registry/verified-facts.js +1 -0
- package/dist/domain/registry/verified-facts.js.map +1 -1
- package/dist/domain/shared/caller.js +1 -0
- package/dist/domain/shared/caller.js.map +1 -1
- package/dist/domain/shared/errors.d.ts +1 -1
- package/dist/domain/shared/errors.js.map +1 -1
- package/dist/domain/shared/events.d.ts +0 -13
- package/dist/domain/shared/follow-fleet.d.ts +9 -15
- package/dist/domain/shared/follow-fleet.js +16 -55
- package/dist/domain/shared/follow-fleet.js.map +1 -1
- package/dist/domain/shared/health-snapshot.js +7 -2
- package/dist/domain/shared/health-snapshot.js.map +1 -1
- package/dist/domain/shared/read-fleet-limits.d.ts +2 -2
- package/dist/domain/shared/read-fleet-limits.js +1 -1
- package/dist/domain/shared/read-sent-message.d.ts +7 -4
- package/dist/domain/shared/read-sent-message.js +6 -15
- package/dist/domain/shared/read-sent-message.js.map +1 -1
- package/dist/maintenance-pass.d.ts +1 -1
- package/dist/maintenance-pass.js +4 -1
- package/dist/maintenance-pass.js.map +1 -1
- package/dist/start.d.ts +1 -1
- package/dist/start.js +1 -1
- package/dist/testing/container-sweeper.d.ts +67 -0
- package/dist/testing/container-sweeper.js +147 -14
- package/dist/testing/container-sweeper.js.map +1 -1
- package/dist/testing/postgres-container.js +2 -2
- package/dist/testing/postgres-container.js.map +1 -1
- package/dist/testing/postgres-global-setup.d.ts +1 -1
- package/dist/testing/postgres-global-setup.js +3 -2
- package/dist/testing/postgres-global-setup.js.map +1 -1
- package/dist/wiring.d.ts +7 -12
- package/dist/wiring.js +6 -18
- package/dist/wiring.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/prisma/migrations/20261115090000_messages_asked_answered_question_id/migration.sql +20 -0
- package/src/adapters/prisma/migrations/20261115100000_unseen_plain_messages/migration.sql +3 -0
- package/src/adapters/prisma/migrations/20261115110000_theme_per_browser/migration.sql +4 -0
- package/src/adapters/prisma/migrations/20261115120000_fleet_deleted_at/migration.sql +2 -0
- package/src/adapters/prisma/migrations/20261115180000_trierarch_kind/migration.sql +2 -0
- package/src/adapters/prisma/migrations/20261115180100_trierarch_kind_backfill/migration.sql +38 -0
- package/src/adapters/prisma/schema.prisma +28 -14
- package/dist/domain/identity/set-theme.d.ts +0 -21
- package/dist/domain/identity/set-theme.js +0 -19
- package/dist/domain/identity/set-theme.js.map +0 -1
- package/dist/domain/messaging/inbox-wait.d.ts +0 -8
- package/dist/domain/messaging/inbox-wait.js +0 -19
- package/dist/domain/messaging/inbox-wait.js.map +0 -1
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Environment variables, validated at startup (see `.env.example`):
|
|
|
47
47
|
| `KMS_ENDPOINT` | AWS's own | Another KMS endpoint, such as LocalStack's `http://localhost:4566`; needs `KMS_REGION` |
|
|
48
48
|
| `CONSOLE_ORIGIN` | `PUBLIC_URL`'s origin | The console's origin, such as `https://console.fleet.example.com`: the only origin a state-changing console call (sign-in, sign-out, a change made with the session cookie) is taken from, and the one origin allowed to call with credentials from another host (CORS). The default fits web and server behind one host. In development the console runs on `http://localhost:3000` (see `.env.example`) |
|
|
49
49
|
|
|
50
|
-
The browser calls the server's `/trpc` itself, at the address the web app runs with (`AEOLUS_SERVER_URL`, see the web README), so the console may run on another host: set `COOKIE_DOMAIN` and `CONSOLE_ORIGIN` for it. Another service the operator uses beside the console (served by its own server, under the configured cookie domain) checks a console session with `GET /trpc/console.session`, forwarding the browser's `Cookie` header: it answers `{ "fleetId": "flt_...", "expiresAt": "...", "kind": "operator" | "viewer", "scopes": [...] }`, or `UNAUTHORIZED` without a signed-in session; a viewer's scopes are `fleet:read` only, so serve it reads only. Only the cookie counts, never a crew token, and the call moves the session's expiry like any console call. A client that is no browser follows the fleet with `fleet.follow` (`fleet:read`; also `/api/v1/fleet/follow` and the MCP tool `fleet_follow`): `{ "afterSeq": n, "max": 1 to 100
|
|
50
|
+
The browser calls the server's `/trpc` itself, at the address the web app runs with (`AEOLUS_SERVER_URL`, see the web README), so the console may run on another host: set `COOKIE_DOMAIN` and `CONSOLE_ORIGIN` for it. Another service the operator uses beside the console (served by its own server, under the configured cookie domain) checks a console session with `GET /trpc/console.session`, forwarding the browser's `Cookie` header: it answers `{ "fleetId": "flt_...", "expiresAt": "...", "kind": "operator" | "viewer", "scopes": [...] }`, or `UNAUTHORIZED` without a signed-in session; a viewer's scopes are `fleet:read` only, so serve it reads only. Only the cookie counts, never a crew token, and the call moves the session's expiry like any console call. A client that is no browser follows the fleet with `fleet.follow` (`fleet:read`; also `/api/v1/fleet/follow` and the MCP tool `fleet_follow`): `{ "afterSeq": n, "max": 1 to 100 }`, both optional (`waitSeconds` is refused), answers `{ "events": [...], "lastSeq": n }`, the events after `afterSeq` oldest first, in the live stream's shape (never their details). Passing the answered `lastSeq` as the next `afterSeq` misses nothing across reconnects; without `afterSeq` it answers no events and the current `lastSeq` It answers at once. The console follows the fleet live through the `fleet.events` subscription, over a WebSocket opened on the same `/trpc` path, so a proxy in front must pass the upgrade on (Caddy does by itself). The upgrade carries the session cookie and is refused from any origin but `CONSOLE_ORIGIN`, as a state-changing call is. The ship page reads `fleet.ship`, `fleet.shipTimeline`, `fleet.shipMessages` (`{ "shipId": "shp_..." }`) and `fleet.message` (`{ "messageId": "msg_..." }`), each with `fleet:read`, which includes message payloads; a ship or message of another fleet is `NOT_FOUND`. A timeline and a message list hold the newest 200. A console call refused because the operator signed in somewhere else carries `refusal: "SIGNED_IN_ELSEWHERE"` in its error data, and a rate-limited sign-in carries `retryAt`, when the client may try again.
|
|
51
51
|
|
|
52
52
|
## Telemetry
|
|
53
53
|
|
|
@@ -66,7 +66,7 @@ The server and the console send traces and metrics over OpenTelemetry (OTLP), sw
|
|
|
66
66
|
Every other `OTEL_*` setting the OpenTelemetry Node SDK reads works as its specification says. What is sent:
|
|
67
67
|
|
|
68
68
|
- Every HTTP request is a point in the histogram `http.server.request.duration` (seconds) with `http.request.method`, `http.route` (the route template, such as `/trpc/:path`) and `http.response.status_code`; a 5xx adds `error.type`. A tRPC batch is one request for several procedures, so each procedure is measured on its own as well.
|
|
69
|
-
- Every tRPC, REST and MCP call is a server span named by its procedure (`system.ping`, `ship.receive`), and a point in the histogram `rpc.server.call.duration` (seconds) with `rpc.system` (`trpc`), `rpc.method` and `rpc.response.status_code` (`OK` or the refusal code), so p95, p99 and the error rate are read per procedure; a server failure adds `error.type`.
|
|
69
|
+
- Every tRPC, REST and MCP call is a server span named by its procedure (`system.ping`, `ship.receive`), and a point in the histogram `rpc.server.call.duration` (seconds) with `rpc.system` (`trpc`), `rpc.method` and `rpc.response.status_code` (`OK` or the refusal code), so p95, p99 and the error rate are read per procedure; a server failure adds `error.type`. No call waits for a message (decision 0072), so each duration is the call's work. Subscriptions are not measured.
|
|
70
70
|
- Every database query is traced under the call that made it (Prisma's instrumentation, with its SQL), and each Prisma operation is a point in `db.client.operation.duration` (seconds) with `db.operation.name`, such as `Ship.findMany` or `$queryRaw`.
|
|
71
71
|
- The console sends Next.js's own spans and a point in `http.server.request.duration` for every request, and each console read as a span and a point in `rpc.server.call.duration`, named `reads.<read>`.
|
|
72
72
|
|
|
@@ -93,7 +93,7 @@ Run on the server, against the configured database, once it is migrated:
|
|
|
93
93
|
|
|
94
94
|
| Command | Does |
|
|
95
95
|
| --- | --- |
|
|
96
|
-
| `aeolus-core fleet:init --name "<fleet name>"` | Creates the fleet, its operator ship `argo` and argo's own sign-in, with no email and no password, asking nothing. Prints a console link (`CONSOLE_ORIGIN/sign-in/ticket?ticket=...`) that signs in as argo: one use, valid 15 minutes. Refuses when a fleet already exists |
|
|
96
|
+
| `aeolus-core fleet:init --name "<fleet name>"` | Creates the fleet, its operator ship `argo` and argo's own sign-in, with no email and no password, asking nothing. Prints a console link (`CONSOLE_ORIGIN/sign-in/ticket?ticket=...`) that signs in as argo: one use, valid 15 minutes. Refuses when a fleet already exists, with exit code 3 (0 done, 1 any other failure, 2 wrong usage), so a script can tell "already set up" from an error |
|
|
97
97
|
| `aeolus-core sign-in` | Prints a fresh sign-in link as `fleet:init` does, for another browser or once the first one expired. Signing in with it ends any other sign-in as argo |
|
|
98
98
|
| `aeolus-core operator:reset-password` | Asks for a new operator password (twice, not shown, at least 12 characters) and sets it. The old one stops working and every console session ends. Refused while argo has no password yet (sign in with a link and set one in Settings), and for an operator a hosting installation created, who signs in only through the hosting service |
|
|
99
99
|
| `aeolus-core fleet:restored` | Run once after `pg_restore` and before `start`. It first applies the migrations a backup made by an older core lacks, as `start` does. Then, in every fleet, each in one transaction, it ends every open lease but argo's (`LeaseRevoked`, reason `restored`): their deliveries in flight go back to pending, and a session still holding a crew token from before the restore is answered `LEASE_ENDED`. It changes nothing else. Refused while a core process is connected to the database |
|
|
@@ -131,9 +131,9 @@ A session crews an agent ship with `ship.register`: the ship id and secret from
|
|
|
131
131
|
|
|
132
132
|
`ship.send` sends a message from the calling ship (a crew token, or the console session as `argo`); it needs the `messages:send` scope. It takes a selector (`{ "kind": "ship", "shipId": "shp_..." }`, `{ "kind": "ship", "name": "scout" }` or `{ "kind": "type", "type": "reviewer" }`), a payload (text of at most 256 KB in UTF-8, never parsed), optionally its content type (any well-formed media type, such as `text/plain` or `application/json; charset=utf-8`, passed on untouched; `text/plain` when left out), the model the sending session runs now (`model`, its exact id, such as `claude-opus-5-5`; every ship states it on every send, so a send without it is refused (`BAD_REQUEST`), and only `argo` states none; code that runs no model, such as a script or a service, states its package or name and the version it runs, as squadrons states `@aeolus-fleet/squadrons@<version>`), the sender's own idempotency key (1 to 256 characters) and, for a reply, `inReplyTo` (a message id of the fleet). A name is resolved to the ship's id when the message is sent; a retired or unknown ship, or a type without an active ship, is refused. It answers `{ "messageId": "msg_..." }` only once the message and its delivery are stored. A repeat of the key with the same request (selector as sent, payload, content type, `inReplyTo`; no content type is the same as `text/plain`) answers with the original id; the same key with another request is refused (`CONFLICT`). When the send commits, Postgres `NOTIFY` announces the delivery on the channel `aeolus_delivery_pending`.
|
|
133
133
|
|
|
134
|
-
`ship.receive` and `ship.ack` take the crew token only (the console session is refused) and need the `messages:receive` scope. `ship.receive` takes `{ "max": 1 to 10 }`, one when left out, and answers `{ "deliveries": [...] }`: the crew's own unacknowledged deliveries in flight first, then the oldest pending ones for its ship or its type. Each comes with its message and its sender (`deliveryId`, `messageId`, `senderShipId`, `senderName`, `senderType`, `recipient`, `payload`, `contentType`, `inReplyTo`, `sentAt`, `attempts`; the sender's name and type as they are at the receive, so a renamed sender goes by its new name) and is handed at once: in flight with the crew until acknowledged or the lease ends. The crew's next receive hands it again, counted as another attempt, so a lost reply loses nothing. The fifth attempt of a delivery never acknowledged is refused: it becomes undeliverable instead and is handed to no one. With nothing there, a receive
|
|
134
|
+
`ship.receive` and `ship.ack` take the crew token only (the console session is refused) and need the `messages:receive` scope. `ship.receive` takes `{ "max": 1 to 10 }`, one when left out, and answers `{ "deliveries": [...] }`: the crew's own unacknowledged deliveries in flight first, then the oldest pending ones for its ship or its type. Each comes with its message and its sender (`deliveryId`, `messageId`, `senderShipId`, `senderName`, `senderType`, `recipient`, `payload`, `contentType`, `inReplyTo`, `sentAt`, `attempts`; the sender's name and type as they are at the receive, so a renamed sender goes by its new name) and is handed at once: in flight with the crew until acknowledged or the lease ends. The crew's next receive hands it again, counted as another attempt, so a lost reply loses nothing. The fifth attempt of a delivery never acknowledged is refused: it becomes undeliverable instead and is handed to no one. With nothing there, a receive answers with no deliveries at once: no call waits (decision 0072); the wake stream tells a crew when to look. `ship.pushReceive` (decision 0040), for a pushed ship's trierarch or plugin watcher, takes the same input as `ship.receive` and answers the same deliveries, each with `state` (`received` or `handed`) and `handOverNumber`: a pending one becomes received, in flight with the crew, with no attempt counted; the crew's own received and handed ones come first again, unchanged. From the lease's first push receive until it ends, `ship.receive` answers no deliveries. `ship.handed` takes `{ "deliveryId": "dlv_...", "handOverNumber": n }` and answers `{ "state": "handed" | "acknowledged" | "undeliverable" }`: a number higher than the last counts one attempt, the same or a lower one changes nothing, and the fifth attempt is undeliverable; with `"isOnceMore": true` it hands an acknowledged delivery once more after its turn died, counting no attempt, only once. `ship.handled` and `ship.notHandled` take `{ "deliveryId": "dlv_..." }` and answer `{}`: the turn that took an acknowledged delivery ended by itself, or the turn it was handed once more to died too; again is OK, and a delivery not acknowledged, or not handed once more for `notHandled`, is refused (`CONFLICT`). `ship.ack` takes `{ "deliveryId": "dlv_..." }` and answers `{}`: only the ship holding the delivery in flight, received or handed, acknowledges it, and acknowledging it again is OK. `ship.pong` takes the crew token and the same scope, takes `{ "deliveryId": "dlv_..." }` of a ping the ship holds in flight and answers `{}`: it acknowledges the ping, with `answer: pong` in `DeliveryAcknowledged`, and marks the lease last seen, in one transaction; again is OK and changes nothing, and a delivery that is not a ping is refused (`CONFLICT`). `ship.report` takes the crew token and no scope: `{ "state": "working" | "blocked" | "idle", "note"?: "..." }` (one line, at most 200 characters, trimmed), answers `{}`. The report is kept with the crew's lease, so the ship's next crew starts with none, and `fleet.list` and `fleet.ship` show it (`report: { state, note, reportedAt }` or null); `ShipReported` is written only when the state or the note changes, so reporting the same again is a check-in. `ship.turn` takes the crew token and no scope: `{ "turn": "idle" | "busy", "at": "<ISO 8601>" }`, answers `{}`; the lease keeps the turn at that time with `TurnReported`, and the same turn again or a report older than the one held changes nothing. `ship.inbox` takes the crew token and the same scope, takes no input (`waitSeconds` and `knownWaiting` are refused) and answers `{ "waiting": n, "forced": n }` at once: how many deliveries the crew's next receive would hand it, its own in flight included. It claims nothing. A mutation only so REST takes its body; it changes nothing.
|
|
135
135
|
|
|
136
|
-
A lease ends cleanly in two ways. The operator releases a crewed ship with `fleet.release` (`{ "shipId": "shp_..." }`, scope `fleet:manage`); `argo` is never released, and a ship awaiting crew gets a new starting prompt instead (`CONFLICT`). A crew ends its own lease with `ship.deregister`, which takes the crew token only and no scope. Both work in one transaction: the secret is invalidated, the lease and its crew token end, and the deliveries the lease held in flight return to pending, to the ship's inbox or its type's queue, their attempts kept, each announced on `aeolus_delivery_pending` as a send is, so
|
|
136
|
+
A lease ends cleanly in two ways. The operator releases a crewed ship with `fleet.release` (`{ "shipId": "shp_..." }`, scope `fleet:manage`); `argo` is never released, and a ship awaiting crew gets a new starting prompt instead (`CONFLICT`). A crew ends its own lease with `ship.deregister`, which takes the crew token only and no scope. Both work in one transaction: the secret is invalidated, the lease and its crew token end, and the deliveries the lease held in flight return to pending, to the ship's inbox or its type's queue, their attempts kept, each announced on `aeolus_delivery_pending` as a send is, so another ship of the type, woken on its wake stream, takes a returned type delivery at its next look. Both answer `{}`. The old crew token then fails on every call, refused as `LEASE_ENDED` with `This ship was released; this session no longer crews it.` (the `UNAUTHORIZED` code at `/trpc`, which knows only tRPC's codes), and the old secret fails on `register`; the next crew needs a new starting prompt. A receive of that crew still waiting hands out nothing: it answers empty at the end of its wait, or `LEASE_ENDED` if a delivery wakes it first.
|
|
137
137
|
|
|
138
138
|
`fleet.ping` (`{ "shipId": "shp_..." }`, `fleet:manage`) sends a crewed ship a ping: a message from argo with the content type `application/vnd.aeolus.ping` and the payload `Ping from argo: answer with pong(deliveryId).`, delivered like any other. It answers `{ "messageId": "msg_...", "sentAt": "...", "isNew": true }`. Pings never stack: while the ship's last ping is pending or in flight, it answers with that one (`isNew: false`) and stores nothing. It refuses argo (`FORBIDDEN`), a retired ship and a ship awaiting crew (`CONFLICT`). `ship.send` refuses the ping content type for every caller (`FORBIDDEN`): only `fleet.ping` sends a ping.
|
|
139
139
|
|
|
@@ -150,7 +150,7 @@ A ship reaches the same calls without installing anything, as REST under `/api/v
|
|
|
150
150
|
- **REST**: one route per ship procedure and fleet action (`src/adapters/rest/README.md`), with the crew token as `Authorization: Bearer`. A refusal answers with its code's HTTP status and `{ "code": "CONFLICT", "message": "..." }`. The OpenAPI 3.1 spec is at `/api/v1/openapi.json`, and as a readable page at `/api/v1/docs`.
|
|
151
151
|
- **MCP**: a remote MCP server over streamable HTTP, one tool per call. The connection carries no ship, so many conversations can share it (ADR 0015): every tool but `register` takes the crew token as its `crewToken` argument. A refusal is a tool error reading `CODE: message`. To add it to Claude Code, for every session on the machine: `claude mcp add --transport http --scope user aeolus <PUBLIC_URL>/mcp`. A chat app (Claude chat, ChatGPT) connects `<PUBLIC_URL>/mcp` as a remote MCP server or connector, without auth.
|
|
152
152
|
|
|
153
|
-
The server listens on `aeolus_delivery_pending` over a connection of its own (named `aeolus-delivery-listener` in Postgres), which needs a direct database connection, not a transaction pooler. After a lost connection it listens again, with a delay that doubles up to 30 seconds, and every
|
|
153
|
+
The server listens on `aeolus_delivery_pending` over a connection of its own (named `aeolus-delivery-listener` in Postgres), which needs a direct database connection, not a transaction pooler. After a lost connection it listens again, with a delay that doubles up to 30 seconds, and every open wake stream is woken (`reconnect`) so its crew looks again, since notices sent meanwhile are gone.
|
|
154
154
|
|
|
155
155
|
No text input to any procedure may hold the character U+0000, which Postgres cannot store: it is refused as `BAD_REQUEST`, naming the field. A refusal answers its own code and message. A server failure answers only `Internal error` and the request's id (`data.requestId`); the server log holds the whole error, stack included, under the same id (`reqId`). No answer ever carries a stack trace.
|
|
156
156
|
|
|
@@ -158,7 +158,7 @@ A database error is logged by its codes only, under `database`: Prisma's code, P
|
|
|
158
158
|
|
|
159
159
|
A request Fastify refuses before any procedure runs answers in the same `{ "code", "message" }` shape: a body that is not JSON `400 BAD_REQUEST`, a body over 1 MiB `413 PAYLOAD_TOO_LARGE`, a body of another content type `415 UNSUPPORTED_MEDIA_TYPE`, and a path or method nothing serves `404 NOT_FOUND`.
|
|
160
160
|
|
|
161
|
-
The operator's account: `console.account` answers `kind: "operator"` with the signed-in operator's email
|
|
161
|
+
The operator's account: `console.account` answers `kind: "operator"` with the signed-in operator's email and this console session (`{ "device": "Mac · Chrome", "since": "..." }`; the device is worded from the sign-in's User-Agent and is also argo's lease location), or `kind: "viewer"` with the session alone for a viewer session (decision 0022). It answers only a console session (`FORBIDDEN` otherwise). The theme is the browser's, kept by the console in a cookie (docs/design/header-across-apps.md); core stores none.
|
|
162
162
|
|
|
163
163
|
Last seen: every call a crew token or the console session authenticates marks its lease seen (`leases.last_seen_at`), in the statement that looks the caller up. `fleet.list` and `fleet.ship` answer `lastSeenAt` for a crewed ship (its claim until it calls again), for the viewer ship the last use of its most recent viewer session, and null otherwise. Observation only (ADR 0016): no heartbeat, nothing ends a lease because a ship went quiet. With the Aeolus Fleet plugin, the watcher's inbox check keeps it fresh about every 25 s.
|
|
164
164
|
|
|
@@ -6,7 +6,7 @@ import { type CommandIo, type ExitCode } from './io.js';
|
|
|
6
6
|
* `fleet:init --name <name>`: creates the fleet, its operator ship argo and
|
|
7
7
|
* argo's own sign-in, asking nothing, and prints a one-use console link that
|
|
8
8
|
* signs in as argo (accounts design, A1). An email and password come later,
|
|
9
|
-
* from Settings. Refuses when a fleet already exists; the use case checks
|
|
9
|
+
* from Settings. Refuses with exit code 3 when a fleet already exists; the use case checks
|
|
10
10
|
* again under its lock, for two runs at once.
|
|
11
11
|
*/
|
|
12
12
|
export declare function fleetInit(args: string[], deps: {
|
|
@@ -2,12 +2,14 @@ import { parseArgs } from 'node:util';
|
|
|
2
2
|
import { nulRefusal } from './io.js';
|
|
3
3
|
import { SIGN_IN_LINK_NOTE, signInLinkOf } from './sign-in-link.js';
|
|
4
4
|
const NOTHING_CREATED = 'Nothing was created.';
|
|
5
|
+
/** Exit code when the fleet already exists, so a start script can tell "already set up" from a failure. */
|
|
6
|
+
const FLEET_EXISTS_EXIT_CODE = 3;
|
|
5
7
|
const USAGE = 'Usage: aeolus-core fleet:init --name "<fleet name>"';
|
|
6
8
|
/**
|
|
7
9
|
* `fleet:init --name <name>`: creates the fleet, its operator ship argo and
|
|
8
10
|
* argo's own sign-in, asking nothing, and prints a one-use console link that
|
|
9
11
|
* signs in as argo (accounts design, A1). An email and password come later,
|
|
10
|
-
* from Settings. Refuses when a fleet already exists; the use case checks
|
|
12
|
+
* from Settings. Refuses with exit code 3 when a fleet already exists; the use case checks
|
|
11
13
|
* again under its lock, for two runs at once.
|
|
12
14
|
*/
|
|
13
15
|
export async function fleetInit(args, deps) {
|
|
@@ -31,12 +33,12 @@ export async function fleetInit(args, deps) {
|
|
|
31
33
|
}
|
|
32
34
|
if ((await deps.listFleets()).length > 0) {
|
|
33
35
|
io.err(`A fleet already exists: a fleet is initialised only once. ${NOTHING_CREATED}`);
|
|
34
|
-
return
|
|
36
|
+
return FLEET_EXISTS_EXIT_CODE;
|
|
35
37
|
}
|
|
36
38
|
const initialised = await deps.initialiseFleet({ name });
|
|
37
39
|
if (!initialised.isOk) {
|
|
38
40
|
io.err(initialised.error.message);
|
|
39
|
-
return 1;
|
|
41
|
+
return initialised.error.kind === 'FLEET_ALREADY_EXISTS' ? FLEET_EXISTS_EXIT_CODE : 1;
|
|
40
42
|
}
|
|
41
43
|
const { fleetId, operatorShipId, operatorId } = initialised.value;
|
|
42
44
|
const created = [`Fleet initialised: ${fleetId}`, `Operator ship argo: ${operatorShipId}`, `Operator account: ${operatorId}`];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fleet-init.js","sourceRoot":"","sources":["../../../src/adapters/cli/fleet-init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAKtC,OAAO,EAAE,UAAU,EAAiC,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEpE,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAE/C,MAAM,KAAK,GAAG,qDAAqD,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,IAAc,EACd,IAA0I;IAE1I,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IAEpB,IAAI,IAAwB,CAAC;IAC7B,IAAI,CAAC;QACH,CAAC,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,E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ined>;
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Exit codes: 0 done, 1 refused by the domain or the installation, 2 wrong usage,
|
|
15
|
+
* 3 `fleet:init` found the fleet already there (a script tells "already set up" from a failure).
|
|
16
|
+
*/
|
|
17
|
+
export type ExitCode = 0 | 1 | 2 | 3;
|
|
15
18
|
export type NewPassword = {
|
|
16
19
|
kind: 'given';
|
|
17
20
|
password: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"io.js","sourceRoot":"","sources":["../../../src/adapters/cli/io.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["../../../src/adapters/cli/io.ts"],"names":[],"mappings":"AAmBA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EAAa,EAAE,QAAgB;IAClE,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,uBAAuB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACrD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAClF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,KAAgD,EAAE,OAAe;IAC1F,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClE,OAAO,OAAO,IAAI,OAAO,OAAO,CAAC,IAAI,4CAA4C,OAAO,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -51,7 +51,7 @@ export function createAccountTokenSignatures(deps) {
|
|
|
51
51
|
if (!header.success) {
|
|
52
52
|
return undefined;
|
|
53
53
|
}
|
|
54
|
-
if (fetchedAt === undefined || deps.now().getTime() - fetchedAt >= KEYS_FRESH_FOR_MS) {
|
|
54
|
+
if (fetching || fetchedAt === undefined || deps.now().getTime() - fetchedAt >= KEYS_FRESH_FOR_MS) {
|
|
55
55
|
await refresh();
|
|
56
56
|
}
|
|
57
57
|
const key = keys.get(header.data.kid);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-token-signatures.js","sourceRoot":"","sources":["../../../src/adapters/crypto/account-token-signatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAkB,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC,qDAAqD;AACrD,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAEnC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAG9H,8FAA8F;AAC9F,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GA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|
|
@@ -2,6 +2,12 @@ import { PrismaClient, type Prisma } from './generated/client.js';
|
|
|
2
2
|
export type { PrismaClient } from './generated/client.js';
|
|
3
3
|
/** The client itself, or the client of one interactive transaction. Repositories take either. */
|
|
4
4
|
export type Db = PrismaClient | Prisma.TransactionClient;
|
|
5
|
+
/**
|
|
6
|
+
* How long a call waits for a connection from the pool, in a transaction or
|
|
7
|
+
* outside one (such as the crew-token lookup), before it is refused as busy
|
|
8
|
+
* (fleet-busy.ts). The pool keeps pg's default size.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CONNECTION_WAIT_MS = 10000;
|
|
5
11
|
/**
|
|
6
12
|
* How long a bulk operation's transaction may run instead: one whose work
|
|
7
13
|
* grows with the fleet's history, such as a fleet delete, so it legitimately
|
|
@@ -12,10 +18,10 @@ export declare const BULK_TRANSACTION_TIME_MS = 30000;
|
|
|
12
18
|
export declare function createPrismaClient(databaseUrl: string): PrismaClient;
|
|
13
19
|
/**
|
|
14
20
|
* A client as createPrismaClient makes, that also hands each statement it
|
|
15
|
-
* runs to `onStatement`: for a scale test that counts the statements a read
|
|
21
|
+
* runs and its parameters to `onStatement`: for a scale test that counts the statements a read
|
|
16
22
|
* runs, which a time would not show without flaking.
|
|
17
23
|
*/
|
|
18
|
-
export declare function createPrismaClientTellingStatements(databaseUrl: string, onStatement: (statement: string) => void): PrismaClient;
|
|
24
|
+
export declare function createPrismaClientTellingStatements(databaseUrl: string, onStatement: (statement: string, params: string) => void): PrismaClient;
|
|
19
25
|
/** Throws when the database cannot answer a trivial query. */
|
|
20
26
|
export declare function checkDatabase(prisma: PrismaClient): Promise<void>;
|
|
21
27
|
/** The latest migration applied to the database, by name; null before the first. */
|
|
@@ -5,7 +5,7 @@ import { PrismaClient } from './generated/client.js';
|
|
|
5
5
|
* outside one (such as the crew-token lookup), before it is refused as busy
|
|
6
6
|
* (fleet-busy.ts). The pool keeps pg's default size.
|
|
7
7
|
*/
|
|
8
|
-
const CONNECTION_WAIT_MS = 10_000;
|
|
8
|
+
export const CONNECTION_WAIT_MS = 10_000;
|
|
9
9
|
/**
|
|
10
10
|
* How long a call's transaction may run before Prisma rolls it back; the
|
|
11
11
|
* call is then refused as busy too (fleet-busy.ts).
|
|
@@ -26,7 +26,7 @@ export function createPrismaClient(databaseUrl) {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* A client as createPrismaClient makes, that also hands each statement it
|
|
29
|
-
* runs to `onStatement`: for a scale test that counts the statements a read
|
|
29
|
+
* runs and its parameters to `onStatement`: for a scale test that counts the statements a read
|
|
30
30
|
* runs, which a time would not show without flaking.
|
|
31
31
|
*/
|
|
32
32
|
export function createPrismaClientTellingStatements(databaseUrl, onStatement) {
|
|
@@ -36,7 +36,7 @@ export function createPrismaClientTellingStatements(databaseUrl, onStatement) {
|
|
|
36
36
|
log: [{ emit: 'event', level: 'query' }],
|
|
37
37
|
});
|
|
38
38
|
client.$on('query', (event) => {
|
|
39
|
-
onStatement(event.query);
|
|
39
|
+
onStatement(event.query, event.params);
|
|
40
40
|
});
|
|
41
41
|
return client;
|
|
42
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/adapters/prisma/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAe,MAAM,uBAAuB,CAAC;AAOlE;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/adapters/prisma/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAe,MAAM,uBAAuB,CAAC;AAOlE;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC;;;GAGG;AACH,MAAM,mBAAmB,GA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YAIpD,CAAC;IACX,OAAO,GAAG,EAAE,cAAc,IAAI,IAAI,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Prisma } from './generated/client.js';
|
|
2
|
+
/** Whether the content type is a question's or a replacement's. */
|
|
3
|
+
export declare function askingContentTypeText(column: string): string;
|
|
4
|
+
export declare function isAskingContentType(column: string): Prisma.Sql;
|
|
5
|
+
export declare function isAnswerContentType(column: string): Prisma.Sql;
|
|
6
|
+
/** Whether the content type is none of the conventions'. */
|
|
7
|
+
export declare function isNoConventionContentType(column: string): Prisma.Sql;
|
|
8
|
+
/** The uuid a question's or a replacement's plain payload names as its own. */
|
|
9
|
+
export declare function askedQuestionIdIn(payload: string): Prisma.Sql;
|
|
10
|
+
/** The uuid an answer's plain payload names. */
|
|
11
|
+
export declare function answeredQuestionIdIn(payload: string): Prisma.Sql;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SQL that tells content types apart and reads a question's uuid from a
|
|
3
|
+
* plain payload, built from the content types common owns. The types go in
|
|
4
|
+
* as literals, not parameters, so a partial index's predicate built here
|
|
5
|
+
* matches the query built here under a generic plan too. Columns are internal
|
|
6
|
+
* SQL names, never request input.
|
|
7
|
+
*/
|
|
8
|
+
import { ANSWER_CONTENT_TYPE, CONVENTION_CONTENT_TYPES, QUESTION_CONTENT_TYPE, REPLACEMENT_CONTENT_TYPE } from '@aeolus-fleet/common';
|
|
9
|
+
import { Prisma } from './generated/client.js';
|
|
10
|
+
/** The content types whose payload names its own question uuid: a question and a replacement's new question. */
|
|
11
|
+
const ASKING_CONTENT_TYPES = [QUESTION_CONTENT_TYPE, REPLACEMENT_CONTENT_TYPE];
|
|
12
|
+
function literalOf(value) {
|
|
13
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
14
|
+
}
|
|
15
|
+
/** A content type's essence in SQL, as essenceOf in common takes it. */
|
|
16
|
+
function essenceOf(column) {
|
|
17
|
+
return `lower(btrim(split_part(${column}, ';', 1)))`;
|
|
18
|
+
}
|
|
19
|
+
/** Whether the content type is a question's or a replacement's. */
|
|
20
|
+
export function askingContentTypeText(column) {
|
|
21
|
+
return `${essenceOf(column)} IN (${ASKING_CONTENT_TYPES.map(literalOf).join(', ')})`;
|
|
22
|
+
}
|
|
23
|
+
export function isAskingContentType(column) {
|
|
24
|
+
return Prisma.raw(askingContentTypeText(column));
|
|
25
|
+
}
|
|
26
|
+
export function isAnswerContentType(column) {
|
|
27
|
+
return Prisma.raw(`${essenceOf(column)} = ${literalOf(ANSWER_CONTENT_TYPE)}`);
|
|
28
|
+
}
|
|
29
|
+
/** Whether the content type is none of the conventions'. */
|
|
30
|
+
export function isNoConventionContentType(column) {
|
|
31
|
+
return Prisma.raw(`${essenceOf(column)} NOT IN (${CONVENTION_CONTENT_TYPES.map(literalOf).join(', ')})`);
|
|
32
|
+
}
|
|
33
|
+
/** The uuid a question's or a replacement's plain payload names as its own. */
|
|
34
|
+
export function askedQuestionIdIn(payload) {
|
|
35
|
+
return Prisma.raw(`substring(${payload} from '"id"\\s*:\\s*"([^"]*)"')`);
|
|
36
|
+
}
|
|
37
|
+
/** The uuid an answer's plain payload names. */
|
|
38
|
+
export function answeredQuestionIdIn(payload) {
|
|
39
|
+
return Prisma.raw(`substring(${payload} from '"questionId"\\s*:\\s*"([^"]*)"')`);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=content-type-sql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-type-sql.js","sourceRoot":"","sources":["../../../src/adapters/prisma/content-type-sql.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEtI,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,gHAAgH;AAChH,MAAM,oBAAoB,GAAsB,CAAC,qBAA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@@ -15,13 +15,13 @@ export interface DeliveryListener {
|
|
|
15
15
|
/**
|
|
16
16
|
* Listens for pending deliveries on a connection of its own: LISTEN needs one
|
|
17
17
|
* that no pool hands to another query, and it must be direct, not through a
|
|
18
|
-
* transaction pooler.
|
|
18
|
+
* transaction pooler. Wake streams and live subscriptions are woken
|
|
19
19
|
* through it. Returns at once.
|
|
20
20
|
*
|
|
21
21
|
* It never throws: a failed connect or a lost connection goes to `onError`,
|
|
22
22
|
* and it tries again after a delay that doubles with each failure, up to 30
|
|
23
23
|
* seconds. Notices sent while it did not listen are gone, so `onListening`
|
|
24
|
-
* runs each time it starts listening, for
|
|
24
|
+
* runs each time it starts listening, for every wake stream's crew to look again.
|
|
25
25
|
*/
|
|
26
26
|
export declare function listenForPendingDeliveries(options: {
|
|
27
27
|
databaseUrl: string;
|
|
@@ -29,13 +29,13 @@ const RECONNECT_DELAY_MAX_MS = 30_000;
|
|
|
29
29
|
/**
|
|
30
30
|
* Listens for pending deliveries on a connection of its own: LISTEN needs one
|
|
31
31
|
* that no pool hands to another query, and it must be direct, not through a
|
|
32
|
-
* transaction pooler.
|
|
32
|
+
* transaction pooler. Wake streams and live subscriptions are woken
|
|
33
33
|
* through it. Returns at once.
|
|
34
34
|
*
|
|
35
35
|
* It never throws: a failed connect or a lost connection goes to `onError`,
|
|
36
36
|
* and it tries again after a delay that doubles with each failure, up to 30
|
|
37
37
|
* seconds. Notices sent while it did not listen are gone, so `onListening`
|
|
38
|
-
* runs each time it starts listening, for
|
|
38
|
+
* runs each time it starts listening, for every wake stream's crew to look again.
|
|
39
39
|
*/
|
|
40
40
|
export function listenForPendingDeliveries(options) {
|
|
41
41
|
const firstDelayMs = options.reconnectDelayMs ?? RECONNECT_DELAY_MS;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* The rollup of the list of exchanges on Postgres (docs/design/exchange-read,
|
|
3
3
|
* E4, E5): one row per person ship and each ship it exchanged with, holding
|
|
4
4
|
* the newest message between them and how many of the other ship's
|
|
5
|
-
* deliveries to it are still open
|
|
5
|
+
* deliveries to it are still open, separately counting plain messages as
|
|
6
|
+
* ackUpTo does. A unit of work collects what each
|
|
6
7
|
* delivery it makes or changes adds (exchange.ts says what), and writes the
|
|
7
8
|
* sums as its last statement before commit, in ship id order: a row's lock
|
|
8
9
|
* is then held only until commit, two label sends to the same person ships
|
|
@@ -26,6 +27,7 @@ export declare const changedDeliveryRowSchema: z.ZodObject<{
|
|
|
26
27
|
message_id: z.ZodType<`msg_${string}`, unknown, z.core.$ZodTypeInternals<`msg_${string}`, unknown>>;
|
|
27
28
|
sender_ship_id: z.ZodType<`shp_${string}`, unknown, z.core.$ZodTypeInternals<`shp_${string}`, unknown>>;
|
|
28
29
|
is_in_exchange: z.ZodBoolean;
|
|
30
|
+
content_type: z.ZodString;
|
|
29
31
|
before_state: z.ZodEnum<{
|
|
30
32
|
pending: "pending";
|
|
31
33
|
received: "received";
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* The rollup of the list of exchanges on Postgres (docs/design/exchange-read,
|
|
3
3
|
* E4, E5): one row per person ship and each ship it exchanged with, holding
|
|
4
4
|
* the newest message between them and how many of the other ship's
|
|
5
|
-
* deliveries to it are still open
|
|
5
|
+
* deliveries to it are still open, separately counting plain messages as
|
|
6
|
+
* ackUpTo does. A unit of work collects what each
|
|
6
7
|
* delivery it makes or changes adds (exchange.ts says what), and writes the
|
|
7
8
|
* sums as its last statement before commit, in ship id order: a row's lock
|
|
8
9
|
* is then held only until commit, two label sends to the same person ships
|
|
@@ -15,6 +16,7 @@ import { z } from 'zod';
|
|
|
15
16
|
import { exchangeCountsOf } from '../../domain/messaging/exchange.js';
|
|
16
17
|
import { pageOf } from '../../domain/shared/page.js';
|
|
17
18
|
import { Prisma } from './generated/client.js';
|
|
19
|
+
import { unseenPlainMessagesStatement } from './unseen-plain-messages.js';
|
|
18
20
|
import { pageWithMessages } from './page-with-messages.js';
|
|
19
21
|
/**
|
|
20
22
|
* A delivery row a statement changed, as it returns it for the rollup: its
|
|
@@ -26,6 +28,7 @@ export const changedDeliveryRowSchema = z.object({
|
|
|
26
28
|
message_id: idSchema('message'),
|
|
27
29
|
sender_ship_id: idSchema('ship'),
|
|
28
30
|
is_in_exchange: z.boolean(),
|
|
31
|
+
content_type: z.string(),
|
|
29
32
|
before_state: deliveryStateSchema,
|
|
30
33
|
before_reached_ship_id: idSchema('ship').nullable(),
|
|
31
34
|
after_state: deliveryStateSchema,
|
|
@@ -37,7 +40,7 @@ export function addChangedDelivery(rollups, row) {
|
|
|
37
40
|
if (!changed.is_in_exchange) {
|
|
38
41
|
return;
|
|
39
42
|
}
|
|
40
|
-
const side = { messageId: changed.message_id, senderShipId: changed.sender_ship_id };
|
|
43
|
+
const side = { messageId: changed.message_id, contentType: changed.content_type, senderShipId: changed.sender_ship_id };
|
|
41
44
|
rollups.add(changed.fleet_id, {
|
|
42
45
|
before: { ...side, reachedShipId: changed.before_reached_ship_id, state: changed.before_state },
|
|
43
46
|
after: { ...side, reachedShipId: changed.after_reached_ship_id, state: changed.after_state },
|
|
@@ -56,6 +59,7 @@ export function createPrismaExchangeRollups(db) {
|
|
|
56
59
|
otherShipId: count.otherShipId,
|
|
57
60
|
newestMessageId: sum && sum.newestMessageId > count.newestMessageId ? sum.newestMessageId : count.newestMessageId,
|
|
58
61
|
unacknowledged: (sum?.unacknowledged ?? 0) + count.unacknowledged,
|
|
62
|
+
unseenPlainMessages: (sum?.unseenPlainMessages ?? 0) + count.unseenPlainMessages,
|
|
59
63
|
});
|
|
60
64
|
}
|
|
61
65
|
},
|
|
@@ -66,17 +70,18 @@ export function createPrismaExchangeRollups(db) {
|
|
|
66
70
|
const rows = [...sums.entries()].toSorted(([first], [second]) => first.localeCompare(second)).map(([, sum]) => sum);
|
|
67
71
|
sums.clear();
|
|
68
72
|
await db.$executeRaw `
|
|
69
|
-
INSERT INTO exchanges (fleet_id, ship_id, other_ship_id, newest_message_id, unacknowledged)
|
|
70
|
-
SELECT sum.fleet_id, sum.ship_id, sum.other_ship_id, sum.newest_message_id, sum.unacknowledged
|
|
73
|
+
INSERT INTO exchanges (fleet_id, ship_id, other_ship_id, newest_message_id, unacknowledged, unseen_plain_messages)
|
|
74
|
+
SELECT sum.fleet_id, sum.ship_id, sum.other_ship_id, sum.newest_message_id, sum.unacknowledged, sum.unseen_plain_messages
|
|
71
75
|
FROM unnest(
|
|
72
76
|
${rows.map((row) => row.fleetId)}::text[], ${rows.map((row) => row.shipId)}::text[], ${rows.map((row) => row.otherShipId)}::text[],
|
|
73
|
-
${rows.map((row) => row.newestMessageId)}::text[], ${rows.map((row) => row.unacknowledged)}::int[]
|
|
74
|
-
) WITH ORDINALITY AS sum(fleet_id, ship_id, other_ship_id, newest_message_id, unacknowledged, place)
|
|
77
|
+
${rows.map((row) => row.newestMessageId)}::text[], ${rows.map((row) => row.unacknowledged)}::int[], ${rows.map((row) => row.unseenPlainMessages)}::int[]
|
|
78
|
+
) WITH ORDINALITY AS sum(fleet_id, ship_id, other_ship_id, newest_message_id, unacknowledged, unseen_plain_messages, place)
|
|
75
79
|
JOIN ships s ON s.fleet_id = sum.fleet_id AND s.id = sum.ship_id AND s.kind = 'person'
|
|
76
80
|
ORDER BY sum.place
|
|
77
81
|
ON CONFLICT (fleet_id, ship_id, other_ship_id) DO UPDATE
|
|
78
82
|
SET newest_message_id = GREATEST(exchanges.newest_message_id, EXCLUDED.newest_message_id),
|
|
79
|
-
unacknowledged = exchanges.unacknowledged + EXCLUDED.unacknowledged
|
|
83
|
+
unacknowledged = exchanges.unacknowledged + EXCLUDED.unacknowledged,
|
|
84
|
+
unseen_plain_messages = exchanges.unseen_plain_messages + EXCLUDED.unseen_plain_messages`;
|
|
80
85
|
},
|
|
81
86
|
};
|
|
82
87
|
}
|
|
@@ -87,12 +92,13 @@ const listedRow = z.object({
|
|
|
87
92
|
kind: shipKindSchema,
|
|
88
93
|
newest_message_id: idSchema('message'),
|
|
89
94
|
unacknowledged: z.int(),
|
|
95
|
+
unseen_plain_messages: z.int(),
|
|
90
96
|
});
|
|
91
97
|
/** A page of a ship's rows, newest first, with the other ship of each. */
|
|
92
98
|
export function exchangeListStatement({ fleetId, shipId, cursor, limit }) {
|
|
93
99
|
const after = cursor === undefined ? Prisma.empty : Prisma.sql `AND e.newest_message_id < ${cursor}`;
|
|
94
100
|
return Prisma.sql `
|
|
95
|
-
SELECT e.fleet_id, e.other_ship_id, s.name, s.type, s.kind::text AS kind, e.newest_message_id, e.unacknowledged
|
|
101
|
+
SELECT e.fleet_id, e.other_ship_id, s.name, s.type, s.kind::text AS kind, e.newest_message_id, e.unacknowledged, COALESCE(e.unseen_plain_messages, ${unseenPlainMessagesStatement(Prisma.sql `e`)}) AS unseen_plain_messages
|
|
96
102
|
FROM exchanges e
|
|
97
103
|
JOIN ships s ON s.fleet_id = e.fleet_id AND s.id = e.other_ship_id
|
|
98
104
|
WHERE e.fleet_id = ${fleetId} AND e.ship_id = ${shipId} AND s.retired_at IS NULL ${after}
|
|
@@ -110,7 +116,7 @@ export function createPrismaExchangeList(db) {
|
|
|
110
116
|
});
|
|
111
117
|
const listed = rows.map(({ row, message: newestMessage }) => {
|
|
112
118
|
const other = listedRow.parse(row);
|
|
113
|
-
return { otherShip: { id: other.other_ship_id, name: other.name, type: other.type, kind: other.kind }, newestMessage, unacknowledged: other.unacknowledged };
|
|
119
|
+
return { otherShip: { id: other.other_ship_id, name: other.name, type: other.type, kind: other.kind }, newestMessage, unacknowledged: other.unacknowledged, unseenPlainMessages: other.unseen_plain_messages };
|
|
114
120
|
});
|
|
115
121
|
return pageOf(listed, { limit, cursorOf: (row) => row.newestMessage.id });
|
|
116
122
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange-rollups.js","sourceRoot":"","sources":["../../../src/adapters/prisma/exchange-rollups.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"exchange-rollups.js","sourceRoot":"","sources":["../../../src/adapters/prisma/exchange-rollups.ts"],"names":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AC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACnC,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,aAAa,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,mBAAmB,EAAE,KAAK,CAAC,qBAAqB,EAAE,CAAC;YACjN,CAAC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5E,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Fills the question uuids of a bounded set of plain payloads, also before sealing removes them. */
|
|
2
|
+
import type { FleetId, MessageId } from '@aeolus-fleet/common';
|
|
3
|
+
import { Prisma } from './generated/client.js';
|
|
4
|
+
export declare function fillMessageQuestionIdsStatement({ fleetId, ids }: {
|
|
5
|
+
fleetId: FleetId;
|
|
6
|
+
ids: readonly MessageId[];
|
|
7
|
+
}): Prisma.Sql;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { answeredQuestionIdIn, askedQuestionIdIn, isAnswerContentType, isAskingContentType } from './content-type-sql.js';
|
|
2
|
+
import { Prisma } from './generated/client.js';
|
|
3
|
+
export function fillMessageQuestionIdsStatement({ fleetId, ids }) {
|
|
4
|
+
return Prisma.sql `
|
|
5
|
+
UPDATE messages SET
|
|
6
|
+
asked_question_id = COALESCE(asked_question_id, CASE WHEN ${isAskingContentType('content_type')} THEN ${askedQuestionIdIn('payload')} END),
|
|
7
|
+
answered_question_id = COALESCE(answered_question_id, CASE WHEN ${isAnswerContentType('content_type')} THEN ${answeredQuestionIdIn('payload')} END)
|
|
8
|
+
WHERE fleet_id = ${fleetId} AND id = ANY(${ids}::text[]) AND payload IS NOT NULL
|
|
9
|
+
AND ((asked_question_id IS NULL AND ${isAskingContentType('content_type')})
|
|
10
|
+
OR (answered_question_id IS NULL AND ${isAnswerContentType('content_type')}))`;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=fill-message-question-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill-message-question-ids.js","sourceRoot":"","sources":["../../../src/adapters/prisma/fill-message-question-ids.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC1H,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,MAAM,UAAU,+BAA+B,CAAC,EAAE,OAAO,EAAE,GAAG,EAAmD;IAC/G,OAAO,MAAM,CAAC,GAAG,CAAA;;kEAE+C,mBAAmB,CAAC,cAAc,CAAC,SAAS,iBAAiB,CAAC,SAAS,CAAC;wEAClE,mBAAmB,CAAC,cAAc,CAAC,SAAS,oBAAoB,CAAC,SAAS,CAAC;uBAC5H,OAAO,iBAAiB,GAAG;4CACN,mBAAmB,CAAC,cAAc,CAAC;+CAChC,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC;AACvF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fleet-counter.js","sourceRoot":"","sources":["../../../src/adapters/prisma/fleet-counter.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,wBAAwB,CAAC,MAAoB;IAC3D,OAAO;QACL,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE;
|
|
1
|
+
{"version":3,"file":"fleet-counter.js","sourceRoot":"","sources":["../../../src/adapters/prisma/fleet-counter.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,wBAAwB,CAAC,MAAoB;IAC3D,OAAO;QACL,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* lost while the listener reconnects costs nothing once `wakeAll` runs.
|
|
7
7
|
*/
|
|
8
8
|
import type { FleetId } from '@aeolus-fleet/common';
|
|
9
|
-
import type { FleetEventNotice
|
|
9
|
+
import type { FleetEventNotice } from '../../domain/shared/events.js';
|
|
10
10
|
export interface FleetEventWatch {
|
|
11
11
|
/**
|
|
12
12
|
* Settles once the fleet has news: at once when a notice came since the last
|
|
@@ -25,9 +25,3 @@ export interface FleetEventWakeupHub {
|
|
|
25
25
|
endAll(): void;
|
|
26
26
|
}
|
|
27
27
|
export declare function createFleetEventWakeups(): FleetEventWakeupHub;
|
|
28
|
-
/**
|
|
29
|
-
* The hub as the core's port for a waiting follow: each wait ends when the
|
|
30
|
-
* fleet has news, or once its time has passed, or when the server stops,
|
|
31
|
-
* which reads as the time having passed.
|
|
32
|
-
*/
|
|
33
|
-
export declare function fleetEventWakeupsOf(hub: Pick<FleetEventWakeupHub, 'watch'>): FleetEventWakeups;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { measureWait } from '../telemetry/calls.js';
|
|
2
1
|
export function createFleetEventWakeups() {
|
|
3
2
|
const watchers = new Map();
|
|
4
3
|
let isEnded = false;
|
|
@@ -66,22 +65,4 @@ export function createFleetEventWakeups() {
|
|
|
66
65
|
},
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
|
-
/**
|
|
70
|
-
* The hub as the core's port for a waiting follow: each wait ends when the
|
|
71
|
-
* fleet has news, or once its time has passed, or when the server stops,
|
|
72
|
-
* which reads as the time having passed.
|
|
73
|
-
*/
|
|
74
|
-
export function fleetEventWakeupsOf(hub) {
|
|
75
|
-
return {
|
|
76
|
-
watch: (fleetId) => {
|
|
77
|
-
const watch = hub.watch(fleetId);
|
|
78
|
-
return {
|
|
79
|
-
next: async (waitMs) => ((await measureWait(() => watch.next(AbortSignal.timeout(waitMs)))) ? 'woken' : 'timedOut'),
|
|
80
|
-
stop: () => {
|
|
81
|
-
watch.stop();
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
68
|
//# sourceMappingURL=fleet-event-wakeups.js.map
|