@nylorun/runtime 0.13.0-beta → 0.15.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +434 -0
- package/README.md +137 -41
- package/dist/adapters/execution/restate.d.ts +7 -2
- package/dist/adapters/execution/restate.js +40 -10
- package/dist/adapters/replication/pgoutput.d.ts +21 -0
- package/dist/adapters/replication/pgoutput.js +170 -0
- package/dist/adapters/streams/s2.js +37 -20
- package/dist/admin-openapi.json +570 -0
- package/dist/api/a2a/card.d.ts +15 -0
- package/dist/api/a2a/card.js +24 -0
- package/dist/api/a2a/endpoint.d.ts +8 -0
- package/dist/api/a2a/endpoint.js +81 -0
- package/dist/api/a2a/protocol.d.ts +144 -0
- package/dist/api/a2a/protocol.js +188 -0
- package/dist/api/a2a/routes.d.ts +19 -0
- package/dist/api/a2a/routes.js +289 -0
- package/dist/api/a2a/tasks.d.ts +50 -0
- package/dist/api/a2a/tasks.js +186 -0
- package/dist/api/ag-ui/endpoint.d.ts +8 -0
- package/dist/api/ag-ui/endpoint.js +126 -0
- package/dist/api/ag-ui/history.d.ts +7 -0
- package/dist/api/ag-ui/history.js +60 -0
- package/dist/api/ag-ui/routes.d.ts +32 -0
- package/dist/api/ag-ui/routes.js +305 -0
- package/dist/api/ag-ui/session-id.d.ts +1 -0
- package/dist/api/ag-ui/session-id.js +12 -0
- package/dist/api/ag-ui/sse.d.ts +9 -0
- package/dist/api/ag-ui/sse.js +7 -0
- package/dist/api/ag-ui/translate.d.ts +38 -0
- package/dist/api/ag-ui/translate.js +222 -0
- package/dist/api/components.d.ts +8065 -0
- package/dist/api/components.js +82 -0
- package/dist/api/gate/keys.d.ts +14 -0
- package/dist/api/gate/keys.js +59 -0
- package/dist/api/gate/routes.d.ts +34 -0
- package/dist/api/gate/routes.js +235 -0
- package/dist/api/http/app.d.ts +18 -0
- package/dist/api/http/app.js +58 -0
- package/dist/api/http/body.d.ts +4 -0
- package/dist/api/http/body.js +37 -0
- package/dist/api/http/define.d.ts +39 -0
- package/dist/api/http/define.js +122 -0
- package/dist/api/http/respond.d.ts +9 -0
- package/dist/api/http/respond.js +44 -0
- package/dist/api/http/routes/access.d.ts +24 -0
- package/dist/api/http/routes/access.js +266 -0
- package/dist/api/http/routes/actions.d.ts +8 -0
- package/dist/api/http/routes/actions.js +76 -0
- package/dist/api/http/routes/endpoints.d.ts +7 -0
- package/dist/api/http/routes/endpoints.js +100 -0
- package/dist/api/http/routes/sessions.d.ts +3 -0
- package/dist/api/http/routes/sessions.js +205 -0
- package/dist/api/http/routes/tenant.d.ts +11 -0
- package/dist/api/http/routes/tenant.js +244 -0
- package/dist/api/http/routes/vaults.d.ts +8 -0
- package/dist/api/http/routes/vaults.js +167 -0
- package/dist/api/openapi.d.ts +19 -0
- package/dist/api/openapi.js +137 -0
- package/dist/api/route.d.ts +12 -0
- package/dist/api/route.js +4 -0
- package/dist/core/bearer.d.ts +8 -0
- package/dist/core/bearer.js +11 -0
- package/dist/core/flow-host.d.ts +7 -15
- package/dist/core/flow-host.js +16 -41
- package/dist/core/sandbox-routes.d.ts +12 -7
- package/dist/core/sandbox-routes.js +24 -25
- package/dist/execution/memory.d.ts +8 -5
- package/dist/execution/memory.js +33 -13
- package/dist/execution/types.d.ts +38 -6
- package/dist/execution/types.js +12 -3
- package/dist/gates/contract.d.ts +51 -0
- package/dist/gates/contract.js +37 -0
- package/dist/gates/handler.d.ts +21 -0
- package/dist/gates/handler.js +55 -0
- package/dist/gates/http-client.d.ts +12 -0
- package/dist/gates/http-client.js +160 -0
- package/dist/gates/in-process.d.ts +32 -0
- package/dist/gates/in-process.js +42 -0
- package/dist/gates/inflight.d.ts +39 -0
- package/dist/gates/inflight.js +70 -0
- package/dist/gates/mcp-handler.d.ts +35 -0
- package/dist/gates/mcp-handler.js +142 -0
- package/dist/gates/meter.d.ts +24 -0
- package/dist/gates/meter.js +165 -0
- package/dist/gates/model-gate.d.ts +45 -0
- package/dist/gates/model-gate.js +1 -0
- package/dist/gates/tenant-vaults.d.ts +64 -0
- package/dist/gates/tenant-vaults.js +94 -0
- package/dist/gates/tool-calls.d.ts +51 -0
- package/dist/gates/tool-calls.js +64 -0
- package/dist/gates/tool-client.d.ts +12 -0
- package/dist/gates/tool-client.js +201 -0
- package/dist/gates/tool-contract.d.ts +116 -0
- package/dist/gates/tool-contract.js +64 -0
- package/dist/gates/tool-gate.d.ts +45 -0
- package/dist/gates/tool-gate.js +10 -0
- package/dist/host/admin-api.d.ts +23 -0
- package/dist/host/admin-api.js +74 -0
- package/dist/host/app.d.ts +34 -0
- package/dist/host/app.js +181 -0
- package/dist/host/config-for.d.ts +3 -1
- package/dist/host/config-for.js +3 -2
- package/dist/host/config.d.ts +11 -0
- package/dist/host/cors.d.ts +27 -0
- package/dist/host/cors.js +64 -0
- package/dist/host/create-host.d.ts +36 -8
- package/dist/host/create-host.js +161 -330
- package/dist/host/execution.d.ts +20 -18
- package/dist/host/execution.js +2 -2
- package/dist/host/gates.d.ts +58 -0
- package/dist/host/gates.js +127 -0
- package/dist/host/http.d.ts +20 -4
- package/dist/host/http.js +81 -23
- package/dist/host/index.d.ts +1 -1
- package/dist/host/main.js +189 -58
- package/dist/host/stack-config.d.ts +91 -19
- package/dist/host/stack-config.js +246 -17
- package/dist/infra/database.d.ts +2 -2
- package/dist/infra/execution.d.ts +5 -5
- package/dist/infra/execution.js +8 -6
- package/dist/infra/index.d.ts +1 -1
- package/dist/infra/workers.d.ts +17 -17
- package/dist/infra/workers.js +9 -9
- package/dist/keys/client.d.ts +9 -0
- package/dist/keys/client.js +70 -0
- package/dist/keys/contract.d.ts +24 -0
- package/dist/keys/contract.js +12 -0
- package/dist/keys/keys.d.ts +41 -0
- package/dist/keys/keys.js +50 -0
- package/dist/mcp/connect.d.ts +43 -3
- package/dist/mcp/connect.js +12 -5
- package/dist/mcp/pool.d.ts +39 -3
- package/dist/mcp/pool.js +74 -11
- package/dist/model/catalog.d.ts +2 -10
- package/dist/model/classify.d.ts +13 -0
- package/dist/model/classify.js +61 -0
- package/dist/model/models.d.ts +10 -1
- package/dist/model/models.js +14 -6
- package/dist/model/pi-model.d.ts +17 -2
- package/dist/model/pi-model.js +366 -222
- package/dist/openapi.json +25889 -0
- package/dist/record/append.d.ts +51 -0
- package/dist/record/append.js +20 -0
- package/dist/record/envelope.d.ts +19 -0
- package/dist/record/envelope.js +49 -0
- package/dist/record/index.d.ts +11 -0
- package/dist/record/index.js +11 -0
- package/dist/sandbox/manager.d.ts +13 -1
- package/dist/sandbox/manager.js +8 -11
- package/dist/sandbox/resolve.d.ts +33 -0
- package/dist/sandbox/resolve.js +81 -0
- package/dist/sandbox/session-sandbox.d.ts +11 -0
- package/dist/sandbox/session-sandbox.js +51 -0
- package/dist/sandbox/share.d.ts +14 -2
- package/dist/sandbox/share.js +33 -3
- package/dist/sandbox/tenant-config.d.ts +37 -0
- package/dist/sandbox/tenant-config.js +51 -0
- package/dist/sandbox/tools.d.ts +7 -9
- package/dist/sandbox/tools.js +11 -3
- package/dist/sandbox/types.d.ts +8 -2
- package/dist/store/postgres/connect.d.ts +25 -9
- package/dist/store/postgres/connect.js +27 -10
- package/dist/store/postgres/db.d.ts +16 -0
- package/dist/store/postgres/db.js +28 -0
- package/dist/store/postgres/drizzle/0000_foundation.sql +22 -0
- package/dist/store/postgres/drizzle/0001_baseline.sql +255 -0
- package/dist/store/postgres/drizzle/0002_stream_relay.sql +4 -0
- package/dist/store/postgres/drizzle/0003_tool_crossings.sql +9 -0
- package/dist/store/postgres/drizzle/meta/_journal.json +34 -0
- package/dist/store/postgres/migrate.d.ts +68 -0
- package/dist/store/postgres/migrate.js +183 -0
- package/dist/store/postgres/record-writer.d.ts +4 -0
- package/dist/store/postgres/record-writer.js +34 -0
- package/dist/store/postgres/record.d.ts +5 -0
- package/dist/store/postgres/record.js +60 -0
- package/dist/store/postgres/schema.d.ts +3096 -0
- package/dist/store/postgres/schema.js +363 -0
- package/dist/store/postgres/store.d.ts +2 -4
- package/dist/store/postgres/store.js +590 -434
- package/dist/store/postgres/tenant.d.ts +56 -0
- package/dist/store/postgres/tenant.js +154 -0
- package/dist/store/types.d.ts +183 -132
- package/dist/store/types.js +0 -1
- package/dist/streams/basin.d.ts +18 -1
- package/dist/streams/basin.js +34 -2
- package/dist/streams/control.d.ts +18 -0
- package/dist/streams/control.js +33 -0
- package/dist/streams/memory.d.ts +3 -1
- package/dist/streams/memory.js +14 -8
- package/dist/streams/relay/core.d.ts +35 -0
- package/dist/streams/relay/core.js +366 -0
- package/dist/streams/relay/types.d.ts +78 -0
- package/dist/streams/relay/types.js +8 -0
- package/dist/streams/types.d.ts +71 -36
- package/dist/streams/types.js +18 -53
- package/dist/tenant/access-policy.d.ts +30 -0
- package/dist/tenant/access-policy.js +52 -0
- package/dist/tenant/actions.d.ts +10 -149
- package/dist/tenant/actions.js +5 -167
- package/dist/tenant/advance.d.ts +7 -2
- package/dist/tenant/advance.js +125 -14
- package/dist/tenant/auth.d.ts +19 -17
- package/dist/tenant/auth.js +90 -93
- package/dist/tenant/browser.d.ts +15 -0
- package/dist/tenant/browser.js +39 -0
- package/dist/tenant/cause.d.ts +25 -0
- package/dist/tenant/cause.js +45 -0
- package/dist/tenant/commands.d.ts +18 -2
- package/dist/tenant/commands.js +111 -115
- package/dist/tenant/context.d.ts +101 -21
- package/dist/tenant/context.js +14 -10
- package/dist/tenant/delivery-token.d.ts +41 -0
- package/dist/tenant/delivery-token.js +104 -0
- package/dist/tenant/delivery.d.ts +62 -0
- package/dist/tenant/delivery.js +481 -0
- package/dist/tenant/effects.d.ts +20 -1
- package/dist/tenant/effects.js +159 -42
- package/dist/tenant/endpoints.d.ts +67 -0
- package/dist/tenant/endpoints.js +90 -0
- package/dist/tenant/ephemeral.d.ts +22 -7
- package/dist/tenant/ephemeral.js +83 -125
- package/dist/tenant/history.d.ts +64 -0
- package/dist/tenant/history.js +120 -0
- package/dist/tenant/http.d.ts +8 -9
- package/dist/tenant/http.js +13 -27
- package/dist/tenant/jwt.d.ts +16 -0
- package/dist/tenant/jwt.js +50 -0
- package/dist/tenant/model-setting.d.ts +2 -2
- package/dist/tenant/module.d.ts +17 -28
- package/dist/tenant/module.js +133 -279
- package/dist/tenant/outbound.d.ts +44 -0
- package/dist/tenant/outbound.js +127 -0
- package/dist/tenant/paths.d.ts +11 -16
- package/dist/tenant/paths.js +24 -68
- package/dist/tenant/pool.d.ts +1 -3
- package/dist/tenant/pool.js +1 -19
- package/dist/tenant/principals.d.ts +23 -11
- package/dist/tenant/principals.js +61 -49
- package/dist/tenant/reset.d.ts +0 -4
- package/dist/tenant/reset.js +0 -5
- package/dist/tenant/runtime.d.ts +28 -20
- package/dist/tenant/runtime.js +95 -64
- package/dist/tenant/scheduler.d.ts +10 -3
- package/dist/tenant/scheduler.js +9 -5
- package/dist/tenant/session-streams.d.ts +127 -0
- package/dist/tenant/session-streams.js +404 -0
- package/dist/tenant/sessions.d.ts +28 -4
- package/dist/tenant/sessions.js +118 -24
- package/dist/tenant/signing-keys.d.ts +55 -0
- package/dist/tenant/signing-keys.js +172 -0
- package/dist/tenant/slim.d.ts +8 -0
- package/dist/tenant/slim.js +21 -0
- package/dist/tenant/status.d.ts +3 -3
- package/dist/tenant/status.js +20 -13
- package/dist/tenant/store-pg.d.ts +9 -6
- package/dist/tenant/store-pg.js +60 -125
- package/dist/tenant/streams.d.ts +62 -85
- package/dist/tenant/streams.js +143 -226
- package/dist/tenant/subject-limits.d.ts +16 -0
- package/dist/tenant/subject-limits.js +45 -0
- package/dist/tenant/sweep.d.ts +1 -10
- package/dist/tenant/sweep.js +29 -69
- package/dist/tenant/tokens.d.ts +14 -0
- package/dist/tenant/tokens.js +180 -0
- package/dist/tenant/transcript.d.ts +48 -5
- package/dist/tenant/transcript.js +58 -1
- package/dist/tenant/types.d.ts +69 -98
- package/dist/tenant/types.js +4 -15
- package/dist/tenant/worker.d.ts +3 -1
- package/dist/tenant/worker.js +13 -7
- package/dist/vault/host-model.d.ts +31 -0
- package/dist/vault/host-model.js +57 -0
- package/dist/vault/service.d.ts +44 -17
- package/dist/vault/service.js +126 -121
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +25 -9
- package/dist/core/executors.d.ts +0 -44
- package/dist/core/executors.js +0 -95
- package/dist/store/memory.d.ts +0 -57
- package/dist/store/memory.js +0 -645
- package/dist/store/postgres/migrations/001_initial.d.ts +0 -27
- package/dist/store/postgres/migrations/001_initial.js +0 -196
- package/dist/store/postgres/migrations/002_session_owner.d.ts +0 -6
- package/dist/store/postgres/migrations/002_session_owner.js +0 -13
- package/dist/store/postgres/migrations/index.d.ts +0 -49
- package/dist/store/postgres/migrations/index.js +0 -76
- package/dist/store/postgres/names.d.ts +0 -11
- package/dist/store/postgres/names.js +0 -42
- package/dist/store/postgres/tenants.d.ts +0 -90
- package/dist/store/postgres/tenants.js +0 -214
- package/dist/streams/relay.d.ts +0 -37
- package/dist/streams/relay.js +0 -254
- package/dist/tenant/envelope.d.ts +0 -7
- package/dist/tenant/envelope.js +0 -22
- package/dist/tenant/live.d.ts +0 -92
- package/dist/tenant/live.js +0 -290
- package/dist/tenant/quarantine-error.d.ts +0 -6
- package/dist/tenant/quarantine-error.js +0 -9
- package/dist/tenant/quarantine.d.ts +0 -27
- package/dist/tenant/quarantine.js +0 -72
- package/dist/tenant/routes-tenant.d.ts +0 -12
- package/dist/tenant/routes-tenant.js +0 -137
- package/dist/tenant/routes.d.ts +0 -9
- package/dist/tenant/routes.js +0 -151
- package/dist/tenant/store-memory.d.ts +0 -16
- package/dist/tenant/store-memory.js +0 -111
- /package/dist/{store → record}/cursor.d.ts +0 -0
- /package/dist/{store → record}/cursor.js +0 -0
package/dist/tenant/streams.d.ts
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Durable Streams seam of an open Tenant (Durable Streams §7–§9), wired by one
|
|
3
|
+
* `wireStreams(ctx, …)` call in the composition root:
|
|
4
|
+
*
|
|
5
|
+
* - **Record.** Every event is written to the record in its transaction (`Tx.event`). The
|
|
6
|
+
* stream relay (`streams/relay/`) feeds the Tenant's basin from it. On a Host with S2, one
|
|
7
|
+
* process-wide relay reads the record over logical replication (`host/main.ts`);
|
|
8
|
+
* otherwise (tests, a Host without S2) this module runs a relay of the Tenant's own commits,
|
|
9
|
+
* which reconciles the record with the streams when it starts.
|
|
10
|
+
* - **Basin generations.** The Tenant's session streams live in its current basin generation
|
|
11
|
+
* (`streams/basin.ts`). A reset moves it to the next one (`tenantReset`): the old basin gets
|
|
12
|
+
* a `sessions.reset` signal, every process moves its readers, and the old basin is deleted
|
|
13
|
+
* after a grace period (again when the Tenant opens, until it is gone).
|
|
14
|
+
* - **Basin.** The current basin is created when the Tenant opens. A missing basin (S2 down
|
|
15
|
+
* then, or deleted since) is repaired on first use: a failed `ensureTenant` retries in the background with backoff,
|
|
16
|
+
* and `streamsStatus` reports the basin's state.
|
|
17
|
+
* - **Readers.** History and session SSE read the session's stream
|
|
18
|
+
* (`tenant/session-streams.ts`). This module runs one `tenant/control` reader per Tenant per
|
|
19
|
+
* process, on the current basin, which calls `ctx.abortLocal` for each `session.cancel`,
|
|
20
|
+
* checks the session streams for each `sessions.reset`, and ends a subject's streams for
|
|
21
|
+
* each `subject.revoked`.
|
|
22
|
+
*
|
|
23
|
+
* The caller passes the streams: the Host's S2 streams, or `MemoryStreams` for tests and a
|
|
24
|
+
* local development Host (not durable).
|
|
25
|
+
*/
|
|
1
26
|
import type { SessionStore } from "../store/types.js";
|
|
2
|
-
import { type
|
|
27
|
+
import { type StreamRelay, type StreamRelayStatus } from "../streams/relay/core.js";
|
|
3
28
|
import { type DurableStreams } from "../streams/types.js";
|
|
4
29
|
import type { TenantContext } from "./context.js";
|
|
5
30
|
export interface WireStreamsOptions {
|
|
@@ -8,10 +33,15 @@ export interface WireStreamsOptions {
|
|
|
8
33
|
streams: DurableStreams;
|
|
9
34
|
/** Close `streams` with the wiring (streams created for this Tenant alone). */
|
|
10
35
|
ownsStreams?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The Host runs the stream relay for the Tenant (logical replication). Otherwise the
|
|
38
|
+
* Tenant relays its own commits.
|
|
39
|
+
*/
|
|
40
|
+
hostRelay?: boolean;
|
|
41
|
+
/** How long a retired basin is kept for readers still on it. Default 60 s. */
|
|
42
|
+
retireGraceMs?: number;
|
|
13
43
|
}
|
|
14
|
-
/** The state of the Tenant's basin as this process last saw it. */
|
|
44
|
+
/** The state of the Tenant's current basin as this process last saw it. */
|
|
15
45
|
export interface BasinStatus {
|
|
16
46
|
/** `ensureTenant` succeeded and no append has failed since. */
|
|
17
47
|
ready: boolean;
|
|
@@ -20,107 +50,54 @@ export interface BasinStatus {
|
|
|
20
50
|
/** The last failure's message, cleared once the basin is ready. */
|
|
21
51
|
lastError: string | null;
|
|
22
52
|
}
|
|
23
|
-
/**
|
|
24
|
-
export interface CollectResult {
|
|
25
|
-
/** Abandoned session streams deleted. */
|
|
26
|
-
deleted: number;
|
|
27
|
-
/** Session streams of existing sessions, kept. */
|
|
28
|
-
kept: number;
|
|
29
|
-
/** Deletions that failed; the collection stays pending. */
|
|
30
|
-
failed: number;
|
|
31
|
-
}
|
|
32
|
-
/** The handles `wireStreams` returns (also kept on `ctx.live.wiring`). */
|
|
53
|
+
/** The handles `wireStreams` returns (also kept on `ctx.sessionStreams.wiring`). */
|
|
33
54
|
export interface StreamsWiring {
|
|
34
55
|
readonly streams: DurableStreams;
|
|
35
|
-
|
|
36
|
-
|
|
56
|
+
/** The Tenant's own relay; undefined when the Host relays. */
|
|
57
|
+
readonly relay: StreamRelay | undefined;
|
|
58
|
+
/** The current basin's state (`streamsStatus`). */
|
|
37
59
|
basin(): BasinStatus;
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*/
|
|
44
|
-
collect(): Promise<CollectResult | undefined>;
|
|
45
|
-
/** Stops the readers, waits for in-flight relays, and closes what `wireStreams` created. */
|
|
60
|
+
/** Moves this process's readers and control reader to basin generation `generation`. */
|
|
61
|
+
moveTo(generation: number): void;
|
|
62
|
+
/** Deletes the basins of retired generations after the grace period. */
|
|
63
|
+
retire(generations: readonly number[]): void;
|
|
64
|
+
/** Stops the readers and the relay, and closes what `wireStreams` created. */
|
|
46
65
|
close(): Promise<void>;
|
|
47
66
|
}
|
|
48
|
-
/** The Tenant setting that holds a pending collection's token ("" when none is pending). */
|
|
49
|
-
export declare const COLLECT_SETTING = "streams.collect";
|
|
50
67
|
/**
|
|
51
|
-
* Wires the Tenant to Durable Streams:
|
|
52
|
-
*
|
|
53
|
-
*
|
|
68
|
+
* Wires the Tenant to Durable Streams: reads its basin generation, checks the basin, starts
|
|
69
|
+
* the Tenant's relay (unless the Host relays), the control reader and the retired basins'
|
|
70
|
+
* deletion, and records the handles on `ctx.sessionStreams.wiring`. Call it once, after
|
|
71
|
+
* `ctx` is built and before the Tenant serves requests.
|
|
54
72
|
*/
|
|
55
73
|
export declare function wireStreams(ctx: TenantContext, options: WireStreamsOptions): Promise<StreamsWiring>;
|
|
56
|
-
/** The Tenant sweep's outbox recovery: appends leftover rows, at most `limit`. */
|
|
57
|
-
export declare function drainOutbox(ctx: TenantContext, limit?: number): Promise<number>;
|
|
58
|
-
/**
|
|
59
|
-
* Appends `session.cancel` for `sessionId` to `tenant/control`, so the process running its
|
|
60
|
-
* advance aborts it. Call it from `t.afterCommit` after a cancel commits. A lost signal costs
|
|
61
|
-
* latency only (the advance checks the Session Store before every effect), so failures are
|
|
62
|
-
* logged, never thrown.
|
|
63
|
-
*/
|
|
64
|
-
export declare function signalSessionCancel(ctx: TenantContext, sessionId: string): void;
|
|
65
74
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
75
|
+
* Appends `session.cancel` for `sessionId` and its cancelled turn to `tenant/control`, so the
|
|
76
|
+
* process running that turn's advance aborts it. Call it from `t.afterCommit` after a cancel
|
|
77
|
+
* commits. A lost signal costs latency only (the advance checks the Session Store before every
|
|
78
|
+
* effect), so failures are logged, never thrown.
|
|
68
79
|
*/
|
|
69
|
-
export declare function
|
|
80
|
+
export declare function signalSessionCancel(ctx: TenantContext, sessionId: string, turnId: string | null): void;
|
|
70
81
|
/**
|
|
71
|
-
* After a reset deleted sessions
|
|
72
|
-
*
|
|
73
|
-
*
|
|
82
|
+
* After a reset deleted the Tenant's sessions and moved it to a new basin generation: tells
|
|
83
|
+
* every process with the Tenant open (`sessions.reset` on the old basin's control stream),
|
|
84
|
+
* moves this process's readers, and deletes the old basin after the grace period. Failures
|
|
85
|
+
* are logged; the periodic check and the next open finish the job.
|
|
74
86
|
*/
|
|
75
|
-
export declare function
|
|
76
|
-
/**
|
|
77
|
-
* Deletes the Tenant's session streams that no session uses any more: streams of deleted
|
|
78
|
-
* sessions and of earlier incarnations. Runs only while a collection is pending
|
|
79
|
-
* (`requestStreamCollection`), and clears it once every deletion succeeded, unless another
|
|
80
|
-
* reset requested a new one meanwhile.
|
|
81
|
-
*
|
|
82
|
-
* Streams are listed before their sessions are read, so a session created meanwhile keeps
|
|
83
|
-
* its stream: its row committed before the relay created the stream.
|
|
84
|
-
*/
|
|
85
|
-
export declare function collectSessionStreams(ctx: TenantContext, streams: DurableStreams): Promise<CollectResult | undefined>;
|
|
87
|
+
export declare function tenantReset(ctx: TenantContext): Promise<void>;
|
|
86
88
|
/** Tenant status of the streams seam (for `GET /v1/tenant` and the Admin API). */
|
|
87
89
|
export interface StreamsStatus {
|
|
88
90
|
/** The streams' service answered a probe (`probeStreams`) within the timeout. */
|
|
89
91
|
reachable: boolean;
|
|
90
92
|
basin: BasinStatus;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
oldestAgeMs: number | null;
|
|
96
|
-
};
|
|
97
|
-
/** How far the relay is behind: the oldest unrelayed event's age, 0 when none is waiting. */
|
|
98
|
-
relayLagMs: number;
|
|
99
|
-
/** Abandoned session streams are waiting to be deleted. */
|
|
100
|
-
collectionPending: boolean;
|
|
93
|
+
/** The basin generation session streams are in. */
|
|
94
|
+
generation: number;
|
|
95
|
+
/** The Tenant's own relay; null when the Host's relay serves it. */
|
|
96
|
+
relay: StreamRelayStatus | null;
|
|
101
97
|
}
|
|
102
|
-
/**
|
|
103
|
-
* The streams seam's status for an open Tenant: S2 reachability, the basin, outbox depth and
|
|
104
|
-
* relay lag. Reads the Session Store and probes the streams (at most `probeTimeoutMs`).
|
|
105
|
-
*/
|
|
98
|
+
/** The streams seam's status for an open Tenant: S2 reachability, the basin and the relay. */
|
|
106
99
|
export declare function streamsStatus(ctx: TenantContext, options?: {
|
|
107
100
|
probeTimeoutMs?: number;
|
|
108
|
-
now?: () => number;
|
|
109
101
|
}): Promise<StreamsStatus>;
|
|
110
|
-
/**
|
|
111
|
-
* Creates a new Tenant's basin. Call it when the Tenant is created, after its schema commits;
|
|
112
|
-
* retries transient failures, then throws. A failure need not fail the creation: opening the
|
|
113
|
-
* Tenant repairs a missing basin.
|
|
114
|
-
*/
|
|
115
|
-
export declare function createTenantStreams(streams: DurableStreams, tenantId: string, options?: {
|
|
116
|
-
attempts?: number;
|
|
117
|
-
}): Promise<void>;
|
|
118
|
-
/**
|
|
119
|
-
* Deletes a Tenant's basin and every stream in it. Call it when the Tenant is deleted (never
|
|
120
|
-
* on reset). Idempotent; retries transient failures, then throws.
|
|
121
|
-
*/
|
|
122
|
-
export declare function deleteTenantStreams(streams: DurableStreams, tenantId: string, options?: {
|
|
123
|
-
attempts?: number;
|
|
124
|
-
}): Promise<void>;
|
|
125
102
|
/** Close: stops the readers and relay; the observers were ended by `endAllStreams`. */
|
|
126
103
|
export declare function closeStreams(ctx: TenantContext): Promise<void>;
|