@aeolus-fleet/core 0.40.0 → 0.42.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 +5 -5
- package/dist/adapters/crypto/account-token-signatures.js +1 -1
- package/dist/adapters/crypto/account-token-signatures.js.map +1 -1
- package/dist/adapters/http/plugin-calls.d.ts +14 -0
- package/dist/adapters/http/plugin-calls.js +46 -0
- package/dist/adapters/http/plugin-calls.js.map +1 -0
- package/dist/adapters/http/plugin-targets.d.ts +8 -0
- package/dist/adapters/http/plugin-targets.js +27 -0
- package/dist/adapters/http/plugin-targets.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/event-log.d.ts +2 -1
- package/dist/adapters/prisma/event-log.js +7 -2
- package/dist/adapters/prisma/event-log.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-journeys.d.ts +49 -0
- package/dist/adapters/prisma/fleet-journeys.js +112 -0
- package/dist/adapters/prisma/fleet-journeys.js.map +1 -0
- package/dist/adapters/prisma/generated/browser.d.ts +17 -1
- package/dist/adapters/prisma/generated/client.d.ts +19 -3
- package/dist/adapters/prisma/generated/client.js +2 -2
- package/dist/adapters/prisma/generated/commonInputTypes.d.ts +236 -214
- package/dist/adapters/prisma/generated/enums.d.ts +1 -0
- package/dist/adapters/prisma/generated/enums.js +2 -1
- package/dist/adapters/prisma/generated/enums.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/class.d.ts +40 -7
- 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 +266 -16
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +26 -4
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +30 -5
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +26 -4
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
- package/dist/adapters/prisma/generated/models/Delivery.d.ts +146 -9
- package/dist/adapters/prisma/generated/models/Fleet.d.ts +513 -29
- package/dist/adapters/prisma/generated/models/FleetJourney.d.ts +1212 -0
- package/dist/adapters/prisma/generated/models/FleetJourney.js +2 -0
- package/dist/adapters/prisma/generated/models/FleetJourney.js.map +1 -0
- package/dist/adapters/prisma/generated/models/InstallationJourneyChange.d.ts +982 -0
- package/dist/adapters/prisma/generated/models/InstallationJourneyChange.js +2 -0
- package/dist/adapters/prisma/generated/models/InstallationJourneyChange.js.map +1 -0
- package/dist/adapters/prisma/generated/models/InstallationJourneyClock.d.ts +964 -0
- package/dist/adapters/prisma/generated/models/InstallationJourneyClock.js +2 -0
- package/dist/adapters/prisma/generated/models/InstallationJourneyClock.js.map +1 -0
- package/dist/adapters/prisma/generated/models.d.ts +3 -0
- package/dist/adapters/prisma/installation.js +10 -3
- package/dist/adapters/prisma/installation.js.map +1 -1
- package/dist/adapters/prisma/journey-source-facts.d.ts +7 -0
- package/dist/adapters/prisma/journey-source-facts.js +76 -0
- package/dist/adapters/prisma/journey-source-facts.js.map +1 -0
- 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 +5 -3
- package/dist/adapters/prisma/registry.js.map +1 -1
- package/dist/adapters/prisma/unit-of-work.d.ts +7 -4
- package/dist/adapters/prisma/unit-of-work.js +13 -10
- package/dist/adapters/prisma/unit-of-work.js.map +1 -1
- 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 -1
- package/dist/adapters/trpc/context.d.ts +4 -0
- package/dist/adapters/trpc/fleet.d.ts +41 -33
- package/dist/adapters/trpc/fleet.js +20 -5
- package/dist/adapters/trpc/fleet.js.map +1 -1
- package/dist/adapters/trpc/installation.d.ts +132 -0
- package/dist/adapters/trpc/installation.js +34 -1
- package/dist/adapters/trpc/installation.js.map +1 -1
- package/dist/adapters/trpc/router.d.ts +185 -46
- package/dist/adapters/trpc/ship-contract.js +1 -0
- package/dist/adapters/trpc/ship-contract.js.map +1 -1
- 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 +16 -20
- package/dist/adapters/trpc/ship.js +11 -14
- package/dist/adapters/trpc/ship.js.map +1 -1
- package/dist/adapters/trpc/trpc.d.ts +9 -0
- package/dist/adapters/trpc/trpc.js +13 -3
- package/dist/adapters/trpc/trpc.js.map +1 -1
- package/dist/app.d.ts +3 -3
- package/dist/app.js +10 -12
- package/dist/app.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.js +11 -0
- package/dist/config.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/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/journey-message.d.ts +18 -0
- package/dist/domain/messaging/journey-message.js +10 -0
- package/dist/domain/messaging/journey-message.js.map +1 -0
- package/dist/domain/messaging/message.d.ts +1 -1
- package/dist/domain/messaging/message.js +2 -2
- package/dist/domain/messaging/message.js.map +1 -1
- package/dist/domain/messaging/ports.d.ts +1 -16
- 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/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/registry/call-plugin.d.ts +26 -0
- package/dist/domain/registry/call-plugin.js +46 -0
- package/dist/domain/registry/call-plugin.js.map +1 -0
- 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/expectations.js +1 -0
- package/dist/domain/registry/expectations.js.map +1 -1
- package/dist/domain/registry/installation-fleet.d.ts +2 -1
- package/dist/domain/registry/installation-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/plugin-calls.d.ts +11 -0
- package/dist/domain/registry/plugin-calls.js +2 -0
- package/dist/domain/registry/plugin-calls.js.map +1 -0
- package/dist/domain/registry/ports.d.ts +4 -3
- package/dist/domain/registry/read-installation-journeys.d.ts +90 -0
- package/dist/domain/registry/read-installation-journeys.js +20 -0
- package/dist/domain/registry/read-installation-journeys.js.map +1 -0
- package/dist/domain/registry/read-reach.js +1 -1
- package/dist/domain/registry/read-reach.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.d.ts +4 -0
- package/dist/domain/shared/caller.js +5 -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/expire-journey-activity.d.ts +18 -0
- package/dist/domain/shared/expire-journey-activity.js +17 -0
- package/dist/domain/shared/expire-journey-activity.js.map +1 -0
- package/dist/domain/shared/fleet-journey.d.ts +35 -0
- package/dist/domain/shared/fleet-journey.js +83 -0
- package/dist/domain/shared/fleet-journey.js.map +1 -0
- 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/read-fleet-limits.d.ts +2 -2
- package/dist/domain/shared/read-fleet-limits.js +1 -1
- package/dist/domain/shared/record-fleet-journey.d.ts +17 -0
- package/dist/domain/shared/record-fleet-journey.js +8 -0
- package/dist/domain/shared/record-fleet-journey.js.map +1 -0
- package/dist/maintenance-pass.d.ts +1 -1
- package/dist/maintenance-pass.js +1 -0
- package/dist/maintenance-pass.js.map +1 -1
- package/dist/start.d.ts +1 -1
- package/dist/start.js +2 -1
- package/dist/start.js.map +1 -1
- package/dist/testing/container-sweeper.d.ts +47 -0
- package/dist/testing/container-sweeper.js +101 -1
- 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 +12 -10
- package/dist/wiring.js +19 -18
- package/dist/wiring.js.map +1 -1
- package/package.json +2 -2
- 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/migrations/20261117010000_fleet_journeys/migration.sql +37 -0
- package/src/adapters/prisma/schema.prisma +55 -19
- 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
|
|
|
@@ -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
|
|
|
@@ -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,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GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;YACjC,IAAI,CAAC;gBACH,IAAI,GAAG,UAAU,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;YAC9C,CAAC;YAAC,MAAM,CAAC;gBACP,0FAA0F;YAC5F,CAAC;oBAAS,CAAC;gBACT,QAAQ,GAAG,SAAS,CAAC;YACvB,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACtB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,MAAM,CAAC,aAAa,GAAG,EAAE,EAAE,aAAa,GAAG,EAAE,EAAE,gBAAgB,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;YAC9E,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;YAC9D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,IAAI,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,IAAI,iBAAiB,EAAE,CAAC;
|
|
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,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AG,MAAM,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC7D,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,GAAG,CAAC,iBAAiB,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACpF,KAAK,OAAO;YACV,OAAO,GAAG,CAAC,iBAAiB,KAAK,IAAI,IAAI,GAAG,CAAC,oBAAoB,EAAE,UAAU,KAAK,YAAY,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,SAAS,CAAC,CAAC;IAC7K,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PluginCalls } from '../../domain/registry/plugin-calls.js';
|
|
2
|
+
import type { PluginTarget } from './plugin-targets.js';
|
|
3
|
+
export interface PluginDispatchLog {
|
|
4
|
+
requestId: string;
|
|
5
|
+
pluginShipId: string;
|
|
6
|
+
procedure: string;
|
|
7
|
+
durationMs: number;
|
|
8
|
+
outcome: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createHttpPluginCalls(options: {
|
|
11
|
+
targets: readonly PluginTarget[];
|
|
12
|
+
now: () => Date;
|
|
13
|
+
log?: (facts: PluginDispatchLog) => void;
|
|
14
|
+
}): PluginCalls;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** One synchronous server-authenticated dispatch. Never follow redirects or retry a plugin operation. */
|
|
2
|
+
import { pluginCallAnswerSchema } from '@aeolus-fleet/common';
|
|
3
|
+
import { err } from '../../domain/shared/result.js';
|
|
4
|
+
function refused(code, message) {
|
|
5
|
+
return err({ kind: 'PLUGIN_REFUSED', code, message });
|
|
6
|
+
}
|
|
7
|
+
export function createHttpPluginCalls(options) {
|
|
8
|
+
const dispatch = async (context) => {
|
|
9
|
+
const target = options.targets.find((candidate) => candidate.fleetId === context.fleetId && candidate.pluginShipId === context.pluginShipId);
|
|
10
|
+
if (!target)
|
|
11
|
+
return refused('NOT_FOUND', 'Plugin endpoint is not configured; no operation started');
|
|
12
|
+
const remaining = Date.parse(context.expiresAt) - options.now().getTime();
|
|
13
|
+
if (remaining <= 0)
|
|
14
|
+
return refused('TIMEOUT', 'Plugin dispatch expired; no operation started');
|
|
15
|
+
const unknown = `Plugin outcome unknown; read current state before retrying (request ${context.requestId})`;
|
|
16
|
+
try {
|
|
17
|
+
const response = await fetch(target.url, { method: 'POST', redirect: 'manual', headers: { 'content-type': 'application/json', 'aeolus-plugin-secret': target.secret }, body: JSON.stringify(context), signal: AbortSignal.timeout(remaining) });
|
|
18
|
+
if (response.status >= 300 && response.status < 400)
|
|
19
|
+
return refused('BAD_GATEWAY', unknown);
|
|
20
|
+
const body = await response.json();
|
|
21
|
+
const answer = pluginCallAnswerSchema.safeParse(body);
|
|
22
|
+
if (!answer.success)
|
|
23
|
+
return refused('BAD_GATEWAY', unknown);
|
|
24
|
+
if ('error' in answer.data) {
|
|
25
|
+
const { code } = answer.data.error.data;
|
|
26
|
+
return refused(code, code === 'BAD_GATEWAY' || code === 'TIMEOUT' || code === 'INTERNAL_SERVER_ERROR' ? unknown : `Plugin operation refused: ${code} (request ${context.requestId})`);
|
|
27
|
+
}
|
|
28
|
+
if (!response.ok)
|
|
29
|
+
return refused('BAD_GATEWAY', unknown);
|
|
30
|
+
return { isOk: true, value: answer.data.result.data };
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (error instanceof Error && 'cause' in error && error.cause instanceof Error && 'code' in error.cause && error.cause.code === 'ECONNREFUSED') {
|
|
34
|
+
return refused('BAD_GATEWAY', `Plugin unavailable; no operation started (request ${context.requestId})`);
|
|
35
|
+
}
|
|
36
|
+
return refused(error instanceof Error && (error.name === 'TimeoutError' || error.name === 'AbortError') ? 'TIMEOUT' : 'BAD_GATEWAY', unknown);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return { dispatch: async (context) => {
|
|
40
|
+
const startedAt = performance.now();
|
|
41
|
+
const answer = await dispatch(context);
|
|
42
|
+
options.log?.({ requestId: context.requestId, pluginShipId: context.pluginShipId, procedure: context.procedure, durationMs: performance.now() - startedAt, outcome: answer.isOk ? 'OK' : answer.error.code });
|
|
43
|
+
return answer;
|
|
44
|
+
} };
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=plugin-calls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-calls.js","sourceRoot":"","sources":["../../../src/adapters/http/plugin-calls.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,OAAO,EAAE,sBAAsB,EAAkD,MAAM,sBAAsB,CAAC;AAG9G,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAGpD,SAAS,OAAO,CAAC,IAAuB,EAAE,OAAe;IACvD,OAAO,GAAG,CAAoB,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAC3E,CAAC;AAUD,MAAM,UAAU,qBAAqB,CAAC,OAAwG;IAC5I,MAAM,QAAQ,GAA4B,KAAK,EAAE,OAA0B,EAAE,EAAE;QAC7E,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;QAC7I,IAAI,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,WAAW,EAAE,yDAAyD,CAAC,CAAC;QACpG,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,S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,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YAC9M,OAAO,MAAM,CAAC;QAChB,CAAC,EAAE,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const pluginTargetsSchema: z.ZodArray<z.ZodObject<{
|
|
3
|
+
fleetId: z.ZodType<`flt_${string}`, unknown, z.core.$ZodTypeInternals<`flt_${string}`, unknown>>;
|
|
4
|
+
pluginShipId: z.ZodType<`shp_${string}`, unknown, z.core.$ZodTypeInternals<`shp_${string}`, unknown>>;
|
|
5
|
+
url: z.ZodString;
|
|
6
|
+
secret: z.ZodString;
|
|
7
|
+
}, z.core.$strict>>;
|
|
8
|
+
export type PluginTarget = z.infer<typeof pluginTargetsSchema>[number];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Deployment settings only: endpoints and shared secrets never live in a fleet or actor input. */
|
|
2
|
+
import { idSchema } from '@aeolus-fleet/common';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
/** Plain HTTP is restricted to literal loopback/private addresses, so DNS cannot turn it public. */
|
|
5
|
+
function isAllowedEndpoint(value) {
|
|
6
|
+
const url = URL.parse(value);
|
|
7
|
+
if (url?.username !== '' || url.password !== '' || url.hash !== '' || url.search !== '')
|
|
8
|
+
return false;
|
|
9
|
+
if (url.protocol === 'https:')
|
|
10
|
+
return true;
|
|
11
|
+
if (url.protocol !== 'http:')
|
|
12
|
+
return false;
|
|
13
|
+
const host = url.hostname;
|
|
14
|
+
if (host === '[::1]' || host === 'localhost')
|
|
15
|
+
return true;
|
|
16
|
+
const octets = host.split('.').map(Number);
|
|
17
|
+
if (octets.length !== 4 || octets.some((part) => !Number.isInteger(part) || part < 0 || part > 255))
|
|
18
|
+
return false;
|
|
19
|
+
const [first, second = 0] = octets;
|
|
20
|
+
return first === 127 || first === 10 || (first === 172 && second >= 16 && second <= 31) || (first === 192 && second === 168);
|
|
21
|
+
}
|
|
22
|
+
export const pluginTargetsSchema = z.array(z.strictObject({
|
|
23
|
+
fleetId: idSchema('fleet'), pluginShipId: idSchema('ship'),
|
|
24
|
+
url: z.string().refine(isAllowedEndpoint, 'must be HTTPS or HTTP on a private literal address'),
|
|
25
|
+
secret: z.string().min(32),
|
|
26
|
+
})).refine((targets) => new Set(targets.map((target) => `${target.fleetId}:${target.pluginShipId}`)).size === targets.length, 'duplicate plugin target');
|
|
27
|
+
//# sourceMappingURL=plugin-targets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-targets.js","sourceRoot":"","sources":["../../../src/adapters/http/plugin-targets.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,oGAAoG;AACpG,SAAS,iBAAiB,CAAC,KAAa;IACtC,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,GAAG,EAAE,QAAQ,KAAK,EAAE,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IACtG,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC1B,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAClH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACnC,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,EAAE,IAAI,CAAC,KAAK,KAAK,GAAG,IAAI,MAAM,IAAI,EAAE,IAAI,MAAM,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC;AAC/H,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC;IACxD,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC;IAC1D,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,iBAAiB,EAAE,oDAAoD,CAAC;IAC/F,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;CAC3B,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC"}
|
|
@@ -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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Clock } from '../../domain/shared/clock.js';
|
|
1
2
|
import type { EventLog, FleetEventFeed } from '../../domain/shared/events.js';
|
|
2
3
|
import type { Db } from './client.js';
|
|
3
4
|
/** The one channel every committed event is announced on, with its fleet and the last number. */
|
|
@@ -6,6 +7,6 @@ export interface BufferedEventLog extends EventLog {
|
|
|
6
7
|
/** Numbers and writes the held events and announces them. The unit of work's last step before commit. */
|
|
7
8
|
flush(): Promise<void>;
|
|
8
9
|
}
|
|
9
|
-
export declare function createPrismaEventLog(db: Db): BufferedEventLog;
|
|
10
|
+
export declare function createPrismaEventLog(db: Db, clock?: Clock): BufferedEventLog;
|
|
10
11
|
/** Reads committed events by number. Each read is one statement, outside a unit of work. */
|
|
11
12
|
export declare function createPrismaFleetEventFeed(db: Db): FleetEventFeed;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { projectJourneyEvents } from './fleet-journeys.js';
|
|
1
2
|
import { toLastEventSeq, toSequencedEvent } from './rows.js';
|
|
2
3
|
/** The one channel every committed event is announced on, with its fleet and the last number. */
|
|
3
4
|
export const FLEET_EVENT_CHANNEL = 'aeolus_event';
|
|
4
|
-
export function createPrismaEventLog(db) {
|
|
5
|
+
export function createPrismaEventLog(db, clock = { now: () => new Date() }) {
|
|
5
6
|
const held = [];
|
|
6
7
|
return {
|
|
7
8
|
append: (event) => {
|
|
@@ -10,8 +11,11 @@ export function createPrismaEventLog(db) {
|
|
|
10
11
|
},
|
|
11
12
|
flush: async () => {
|
|
12
13
|
const fleets = [...new Set(held.map((event) => event.fleetId))].toSorted();
|
|
14
|
+
if (fleets.length > 1) {
|
|
15
|
+
await db.$queryRaw `SELECT id FROM fleets WHERE id = ANY(${fleets}::text[]) ORDER BY id FOR UPDATE`;
|
|
16
|
+
}
|
|
13
17
|
for (const fleetId of fleets) {
|
|
14
|
-
await writeNumbered(db, { fleetId, events: held.filter((event) => event.fleetId === fleetId) });
|
|
18
|
+
await writeNumbered(db, { fleetId, events: held.filter((event) => event.fleetId === fleetId), computedAt: clock.now().toISOString() });
|
|
15
19
|
}
|
|
16
20
|
held.length = 0;
|
|
17
21
|
},
|
|
@@ -39,6 +43,7 @@ async function writeNumbered(db, of) {
|
|
|
39
43
|
seq: BigInt(firstSeq + index),
|
|
40
44
|
})),
|
|
41
45
|
});
|
|
46
|
+
await projectJourneyEvents(db, { fleetId, events, lastSeq, computedAt: of.computedAt });
|
|
42
47
|
await db.$executeRaw `SELECT pg_notify(${FLEET_EVENT_CHANNEL}, ${JSON.stringify({ fleetId, seq: lastSeq })})`;
|
|
43
48
|
}
|
|
44
49
|
/** Reads committed events by number. Each read is one statement, outside a unit of work. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-log.js","sourceRoot":"","sources":["../../../src/adapters/prisma/event-log.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-log.js","sourceRoot":"","sources":["../../../src/adapters/prisma/event-log.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7D,iGAAiG;AACjG,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAOlD,MAAM,UAAU,oBAAoB,CAAC,EAAM,EAAE,QAAe,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE;IACnF,MAAM,IAAI,GAAiB,EAAE,CAAC;IAE9B,OAAO;QACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACjB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QACD,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC3E,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtB,MAAM,EAAE,CAAC,SAAS,CAAA,wCAAwC,MAAM,kCAAkC,CAAC;YACrG,CAAC;YACD,KAAK,MAAM,OAAO,IAAI,MAAM,EAAE,CAA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K,MAAM;YACT,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,CAAC,iBAAiB,IAAI,IAAI,EAAE,CAAC;QACvK,KAAK,SAAS;YACZ,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC,SAAS,EAAE,kBAAkB,EAAE,KAAK,CAAC,aAAa,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC;QAC9J,KAAK,cAAc,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC;IACtI,CAAC;AACH,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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fleet-event-wakeups.js","sourceRoot":"","sources":["../../../src/adapters/prisma/fleet-event-wakeups.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fleet-event-wakeups.js","sourceRoot":"","sources":["../../../src/adapters/prisma/fleet-event-wakeups.ts"],"names":[],"mappings":"AAoCA,MAAM,UAAU,uBAAuB;IACrC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAClD,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,MAAM,IAAI,GAAG,CAAC,OAAgB,EAAE,EAAE;QAChC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,MAAM,CAAC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
+
import type { JourneyActivityExpiry } from '../../domain/shared/expire-journey-activity.js';
|
|
3
|
+
import type { JourneyRecords } from '../../domain/shared/record-fleet-journey.js';
|
|
4
|
+
import type { FleetEvent } from '../../domain/shared/events.js';
|
|
5
|
+
import type { InstallationJourneyReads, JourneyPagePosition } from '../../domain/registry/read-installation-journeys.js';
|
|
6
|
+
import type { Db } from './client.js';
|
|
7
|
+
import { Prisma } from './generated/client.js';
|
|
8
|
+
export declare function createPrismaJourneyRecords(db: Db): JourneyRecords;
|
|
9
|
+
/** Called after the source fleet row is locked, before commit. No background consumer can lose evidence to pruning. */
|
|
10
|
+
export declare function projectJourneyEvents(db: Db, input: {
|
|
11
|
+
fleetId: FleetId;
|
|
12
|
+
events: readonly FleetEvent[];
|
|
13
|
+
lastSeq: number;
|
|
14
|
+
computedAt: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
export declare function deleteFleetJourney(db: Db, fleetId: FleetId): Promise<void>;
|
|
17
|
+
/** Keyset reads are bounded before any projection JSON is loaded. */
|
|
18
|
+
export declare function journeyPageStatement(position?: JourneyPagePosition): Prisma.Sql;
|
|
19
|
+
export declare function journeyChangesStatement(after: bigint): Prisma.Sql;
|
|
20
|
+
export declare function createPrismaInstallationJourneyReads(db: Db): InstallationJourneyReads;
|
|
21
|
+
/** Kept outside the legacy unbounded list: only one fleet and the new bounded resources carry journeys. */
|
|
22
|
+
export declare function readFleetJourney(db: Db, input: {
|
|
23
|
+
fleetId: FleetId;
|
|
24
|
+
now: Date;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
milestones: {
|
|
27
|
+
key: "fleet-ready" | "first-ship-crewed" | "two-ships-crewed" | "first-message" | "first-value" | "repeat-value";
|
|
28
|
+
label: string;
|
|
29
|
+
definitionVersion: string;
|
|
30
|
+
occurredAt: string | null;
|
|
31
|
+
computedAt: string;
|
|
32
|
+
coverageFrom: string;
|
|
33
|
+
state: "unknown" | "reached" | "not-yet";
|
|
34
|
+
}[];
|
|
35
|
+
firstValueDefinition: {
|
|
36
|
+
label: "First value";
|
|
37
|
+
version: "round-trip-v1";
|
|
38
|
+
definition: string;
|
|
39
|
+
};
|
|
40
|
+
computedAt: string;
|
|
41
|
+
coverageFrom: string;
|
|
42
|
+
processedThrough: number;
|
|
43
|
+
activityDates: string[];
|
|
44
|
+
activityDatesLast7Days: string[];
|
|
45
|
+
activityDatesLast28Days: string[];
|
|
46
|
+
latestQualifyingActivityAt: string | null;
|
|
47
|
+
} | undefined>;
|
|
48
|
+
/** Expiry reads only due compact projections, with concurrent maintenance workers skipping held rows. */
|
|
49
|
+
export declare function createPrismaJourneyActivityExpiry(db: Db): JourneyActivityExpiry;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** Durable compact projections and a commit-ordered installation change cursor. */
|
|
2
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
+
import { fleetJourneySummarySchema, idSchema } from '@aeolus-fleet/common';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { JOURNEY_ACTIVITY_DAYS, newFleetJourney, fleetJourneySummary, projectFleetJourney } from '../../domain/shared/fleet-journey.js';
|
|
6
|
+
import { Prisma } from './generated/client.js';
|
|
7
|
+
import { journeySourceFacts } from './journey-source-facts.js';
|
|
8
|
+
const privateJourney = fleetJourneySummarySchema.omit({ activityDatesLast7Days: true, activityDatesLast28Days: true }).extend({ crewedShipIds: z.array(idSchema('ship')).max(2) });
|
|
9
|
+
const projectionRow = z.object({ fleetId: idSchema('fleet'), createdAt: z.date(), coverageFrom: z.date(), processedThrough: z.bigint(), data: z.unknown() });
|
|
10
|
+
function journeyOf(row) {
|
|
11
|
+
return row.data === null
|
|
12
|
+
? { ...newFleetJourney({ createdAt: row.createdAt.toISOString(), coverageFrom: row.coverageFrom.toISOString(), computedAt: row.coverageFrom.toISOString() }), processedThrough: Number(row.processedThrough) }
|
|
13
|
+
: privateJourney.parse(row.data);
|
|
14
|
+
}
|
|
15
|
+
export function createPrismaJourneyRecords(db) {
|
|
16
|
+
return {
|
|
17
|
+
read: async (fleetId) => {
|
|
18
|
+
const [row] = z.array(projectionRow).parse(await db.$queryRaw `SELECT fleet_id AS "fleetId", created_at AS "createdAt", coverage_from AS "coverageFrom", processed_through AS "processedThrough", data FROM fleet_journeys WHERE fleet_id = ${fleetId}`);
|
|
19
|
+
return row ? journeyOf(row) : undefined;
|
|
20
|
+
},
|
|
21
|
+
save: async (fleetId, journey) => {
|
|
22
|
+
const firstDate = journey.activityDates[0];
|
|
23
|
+
const expiresAt = firstDate ? new Date(Date.parse(`${firstDate}T00:00:00.000Z`) + JOURNEY_ACTIVITY_DAYS * 86_400_000) : null;
|
|
24
|
+
await db.$executeRaw `UPDATE fleet_journeys SET data = ${JSON.stringify(journey)}::jsonb, processed_through = ${journey.processedThrough}, activity_expires_at = ${expiresAt} WHERE fleet_id = ${fleetId}`;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Called after the source fleet row is locked, before commit. No background consumer can lose evidence to pruning. */
|
|
29
|
+
export async function projectJourneyEvents(db, input) {
|
|
30
|
+
const { fleetId, events, lastSeq } = input;
|
|
31
|
+
const created = events.find((event) => event.type === 'FleetInitialised');
|
|
32
|
+
if (created) {
|
|
33
|
+
await db.$executeRaw `INSERT INTO fleet_journeys(fleet_id, created_at, coverage_from) VALUES (${fleetId}, ${created.occurredAt}, ${created.occurredAt}) ON CONFLICT DO NOTHING`;
|
|
34
|
+
}
|
|
35
|
+
if (!events.some((event) => ['FleetInitialised', 'ShipClaimed', 'MessageAccepted', 'DeliveryReceived', 'DeliveryHanded'].includes(event.type))) {
|
|
36
|
+
await db.$executeRaw `UPDATE fleet_journeys SET processed_through = ${lastSeq},
|
|
37
|
+
data = data || jsonb_build_object('processedThrough', ${lastSeq}::bigint, 'computedAt', ${input.computedAt}::text)
|
|
38
|
+
WHERE fleet_id = ${fleetId}`;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const [row] = z.array(projectionRow).parse(await db.$queryRaw `SELECT fleet_id AS "fleetId", created_at AS "createdAt", coverage_from AS "coverageFrom", processed_through AS "processedThrough", data FROM fleet_journeys WHERE fleet_id = ${fleetId}`);
|
|
42
|
+
if (!row)
|
|
43
|
+
return;
|
|
44
|
+
const state = journeyOf(row);
|
|
45
|
+
const facts = await journeySourceFacts(db, events);
|
|
46
|
+
const journey = projectFleetJourney(state, { facts, computedAt: input.computedAt, processedThrough: lastSeq });
|
|
47
|
+
await createPrismaJourneyRecords(db).save(fleetId, journey);
|
|
48
|
+
// Watermarks stay fleet-local. The installation cursor only advertises changed facts.
|
|
49
|
+
if (created || !isDeepStrictEqual(journeyFacts(state), journeyFacts(journey))) {
|
|
50
|
+
await recordJourneyChange(db, { fleetId, isDeleted: false });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function journeyFacts(journey) {
|
|
54
|
+
return { milestones: journey.milestones, crewedShipIds: journey.crewedShipIds,
|
|
55
|
+
activityDates: journey.activityDates, latestQualifyingActivityAt: journey.latestQualifyingActivityAt };
|
|
56
|
+
}
|
|
57
|
+
/** The single installation clock is locked last. Lower cursors always commit before higher ones. */
|
|
58
|
+
async function recordJourneyChange(db, input) {
|
|
59
|
+
const [clock] = z.array(z.object({ seq: z.bigint() })).parse(await db.$queryRaw `UPDATE installation_journey_clock SET seq = seq + 1 WHERE id = 1 RETURNING seq`);
|
|
60
|
+
if (!clock)
|
|
61
|
+
throw new Error('The installation journey clock is missing');
|
|
62
|
+
await db.$executeRaw `INSERT INTO installation_journey_changes(resource_id, seq, is_deleted) VALUES (${input.fleetId}, ${clock.seq}, ${input.isDeleted})
|
|
63
|
+
ON CONFLICT (resource_id) DO UPDATE SET seq = EXCLUDED.seq, is_deleted = EXCLUDED.is_deleted`;
|
|
64
|
+
}
|
|
65
|
+
export async function deleteFleetJourney(db, fleetId) {
|
|
66
|
+
await db.$executeRaw `DELETE FROM fleet_journeys WHERE fleet_id = ${fleetId}`;
|
|
67
|
+
await recordJourneyChange(db, { fleetId, isDeleted: true });
|
|
68
|
+
}
|
|
69
|
+
/** Keyset reads are bounded before any projection JSON is loaded. */
|
|
70
|
+
export function journeyPageStatement(position) {
|
|
71
|
+
const after = position ? Prisma.sql `WHERE (created_at, fleet_id) > (${position.createdAt}, ${position.fleetId})` : Prisma.empty;
|
|
72
|
+
return Prisma.sql `SELECT fleet_id AS "fleetId", created_at AS "createdAt", coverage_from AS "coverageFrom", processed_through AS "processedThrough", data
|
|
73
|
+
FROM fleet_journeys ${after} ORDER BY created_at, fleet_id LIMIT 21`;
|
|
74
|
+
}
|
|
75
|
+
export function journeyChangesStatement(after) {
|
|
76
|
+
return Prisma.sql `SELECT c.resource_id AS "fleetId", c.seq, c.is_deleted AS "isDeleted", j.created_at AS "createdAt", j.coverage_from AS "coverageFrom", j.processed_through AS "processedThrough", j.data
|
|
77
|
+
FROM installation_journey_changes c LEFT JOIN fleet_journeys j ON j.fleet_id = c.resource_id
|
|
78
|
+
WHERE c.seq > ${after} ORDER BY c.seq LIMIT 21`;
|
|
79
|
+
}
|
|
80
|
+
export function createPrismaInstallationJourneyReads(db) {
|
|
81
|
+
return {
|
|
82
|
+
find: async (fleetId) => createPrismaJourneyRecords(db).read(fleetId),
|
|
83
|
+
page: async (position) => z.array(projectionRow).parse(await db.$queryRaw(journeyPageStatement(position))).map((row) => ({ fleetId: row.fleetId, createdAt: row.createdAt, journey: journeyOf(row) })),
|
|
84
|
+
changes: async (after) => {
|
|
85
|
+
const rows = z.array(z.object({ fleetId: idSchema('fleet'), seq: z.bigint(), isDeleted: z.boolean(), createdAt: z.date().nullable(), coverageFrom: z.date().nullable(), processedThrough: z.bigint().nullable(), data: z.unknown() })).parse(await db.$queryRaw(journeyChangesStatement(after)));
|
|
86
|
+
return rows.map((row) => ({ fleetId: row.fleetId, seq: row.seq, isDeleted: row.isDeleted,
|
|
87
|
+
journey: row.isDeleted || row.createdAt === null || row.coverageFrom === null || row.processedThrough === null ? null
|
|
88
|
+
: journeyOf({ ...row, createdAt: row.createdAt, coverageFrom: row.coverageFrom, processedThrough: row.processedThrough }),
|
|
89
|
+
}));
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Kept outside the legacy unbounded list: only one fleet and the new bounded resources carry journeys. */
|
|
94
|
+
export async function readFleetJourney(db, input) {
|
|
95
|
+
const state = await createPrismaJourneyRecords(db).read(input.fleetId);
|
|
96
|
+
return state ? fleetJourneySummary(state, input.now) : undefined;
|
|
97
|
+
}
|
|
98
|
+
/** Expiry reads only due compact projections, with concurrent maintenance workers skipping held rows. */
|
|
99
|
+
export function createPrismaJourneyActivityExpiry(db) {
|
|
100
|
+
return {
|
|
101
|
+
expired: async (now, limit) => {
|
|
102
|
+
const rows = z.array(projectionRow).parse(await db.$queryRaw `SELECT fleet_id AS "fleetId", created_at AS "createdAt", coverage_from AS "coverageFrom", processed_through AS "processedThrough", data
|
|
103
|
+
FROM fleet_journeys WHERE activity_expires_at <= ${now} ORDER BY activity_expires_at, fleet_id LIMIT ${limit} FOR UPDATE SKIP LOCKED`);
|
|
104
|
+
return rows.map((row) => ({ fleetId: row.fleetId, journey: journeyOf(row) }));
|
|
105
|
+
},
|
|
106
|
+
save: async (fleetId, journey) => {
|
|
107
|
+
await createPrismaJourneyRecords(db).save(fleetId, journey);
|
|
108
|
+
await recordJourneyChange(db, { fleetId, isDeleted: false });
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=fleet-journeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleet-journeys.js","sourceRoot":"","sources":["../../../src/adapters/prisma/fleet-journeys.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAgB,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,C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C,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;YAC/B,MAAM,0BAA0B,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC5D,MAAM,mBAAmB,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -3,8 +3,24 @@ export { Prisma };
|
|
|
3
3
|
export * as $Enums from './enums.js';
|
|
4
4
|
export * from './enums.js';
|
|
5
5
|
/**
|
|
6
|
-
* Model
|
|
6
|
+
* Model FleetJourney
|
|
7
7
|
* The tenant: one operator's ships, messages and history. Ids start with flt_.
|
|
8
|
+
* A bounded operational projection, retained independently of message history.
|
|
9
|
+
*/
|
|
10
|
+
export type FleetJourney = Prisma.FleetJourneyModel;
|
|
11
|
+
/**
|
|
12
|
+
* Model InstallationJourneyClock
|
|
13
|
+
* Installation-owned commit cursor and deletion references for reconciliation.
|
|
14
|
+
*/
|
|
15
|
+
export type InstallationJourneyClock = Prisma.InstallationJourneyClockModel;
|
|
16
|
+
/**
|
|
17
|
+
* Model InstallationJourneyChange
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export type InstallationJourneyChange = Prisma.InstallationJourneyChangeModel;
|
|
21
|
+
/**
|
|
22
|
+
* Model Fleet
|
|
23
|
+
*
|
|
8
24
|
*/
|
|
9
25
|
export type Fleet = Prisma.FleetModel;
|
|
10
26
|
/**
|