@nylorun/runtime 0.15.2-beta → 0.17.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 +134 -0
- package/README.md +68 -29
- package/dist/adapters/execution/restate.d.ts +9 -1
- package/dist/adapters/execution/restate.js +64 -5
- package/dist/adapters/sandbox/local.d.ts +10 -0
- package/dist/adapters/sandbox/local.js +195 -0
- package/dist/adapters/sandbox/virtual.js +36 -1
- package/dist/admin-openapi.json +341 -7
- package/dist/api/a2a/tasks.js +6 -1
- package/dist/api/ag-ui/endpoint.js +1 -2
- package/dist/api/ag-ui/history.js +6 -1
- package/dist/api/ag-ui/routes.d.ts +1 -1
- package/dist/api/ag-ui/routes.js +15 -13
- package/dist/api/components.d.ts +2667 -711
- package/dist/api/components.js +24 -11
- package/dist/api/gate/keys.d.ts +4 -3
- package/dist/api/gate/routes.d.ts +19 -3
- package/dist/api/gate/routes.js +162 -53
- package/dist/api/http/app.js +6 -0
- package/dist/api/http/define.d.ts +19 -12
- package/dist/api/http/define.js +13 -27
- package/dist/api/http/routes/access.d.ts +3 -19
- package/dist/api/http/routes/access.js +12 -172
- package/dist/api/http/routes/actions.js +0 -1
- package/dist/api/http/routes/artifacts.d.ts +11 -0
- package/dist/api/http/routes/artifacts.js +516 -0
- package/dist/api/http/routes/me.d.ts +13 -0
- package/dist/api/http/routes/me.js +45 -0
- package/dist/api/http/routes/sandboxes.d.ts +9 -0
- package/dist/api/http/routes/sandboxes.js +150 -0
- package/dist/api/http/routes/sessions.js +9 -13
- package/dist/api/http/routes/tenant.js +36 -2
- package/dist/api/http/routes/vaults.d.ts +12 -3
- package/dist/api/http/routes/vaults.js +122 -54
- package/dist/api/openapi.js +4 -10
- package/dist/artifacts/config.d.ts +23 -0
- package/dist/artifacts/config.js +27 -0
- package/dist/artifacts/export.d.ts +8 -0
- package/dist/artifacts/export.js +205 -0
- package/dist/artifacts/files.d.ts +36 -0
- package/dist/artifacts/files.js +45 -0
- package/dist/artifacts/folders.d.ts +60 -0
- package/dist/artifacts/folders.js +209 -0
- package/dist/artifacts/links.d.ts +28 -0
- package/dist/artifacts/links.js +92 -0
- package/dist/artifacts/media-types.d.ts +13 -0
- package/dist/artifacts/media-types.js +80 -0
- package/dist/artifacts/parts.d.ts +34 -0
- package/dist/artifacts/parts.js +38 -0
- package/dist/artifacts/service.d.ts +74 -0
- package/dist/artifacts/service.js +301 -0
- package/dist/artifacts/workspace.d.ts +60 -0
- package/dist/artifacts/workspace.js +57 -0
- package/dist/artifacts/zip.d.ts +10 -0
- package/dist/artifacts/zip.js +126 -0
- package/dist/blob/fs.d.ts +13 -0
- package/dist/blob/fs.js +194 -0
- package/dist/blob/index.d.ts +9 -0
- package/dist/blob/index.js +9 -0
- package/dist/blob/s3.d.ts +42 -0
- package/dist/blob/s3.js +366 -0
- package/dist/blob/types.d.ts +108 -0
- package/dist/blob/types.js +85 -0
- package/dist/core/sandbox-routes.d.ts +2 -2
- package/dist/core/sandbox-routes.js +4 -3
- package/dist/execution/memory.d.ts +11 -1
- package/dist/execution/memory.js +77 -3
- package/dist/execution/types.d.ts +54 -1
- package/dist/execution/types.js +31 -0
- package/dist/gates/contract.d.ts +14 -13
- package/dist/gates/contract.js +13 -12
- package/dist/gates/egress.d.ts +72 -0
- package/dist/gates/egress.js +319 -0
- package/dist/gates/handler.d.ts +3 -0
- package/dist/gates/handler.js +3 -2
- package/dist/gates/http-client.d.ts +3 -2
- package/dist/gates/http-client.js +17 -6
- package/dist/gates/in-process.d.ts +13 -1
- package/dist/gates/in-process.js +11 -0
- package/dist/gates/inflight.d.ts +23 -4
- package/dist/gates/inflight.js +18 -4
- package/dist/gates/mcp-handler.js +5 -1
- package/dist/gates/model-gate.d.ts +6 -2
- package/dist/gates/tenant-vaults.d.ts +18 -9
- package/dist/gates/tenant-vaults.js +17 -12
- package/dist/gates/tool-calls.d.ts +9 -5
- package/dist/gates/tool-calls.js +6 -6
- package/dist/gates/tool-client.d.ts +9 -2
- package/dist/gates/tool-client.js +56 -22
- package/dist/gates/tool-contract.d.ts +12 -7
- package/dist/gates/tool-contract.js +10 -4
- package/dist/gates/tool-gate.d.ts +1 -0
- package/dist/harness/calls.d.ts +52 -0
- package/dist/harness/calls.js +113 -0
- package/dist/harness/executors.d.ts +22 -0
- package/dist/harness/executors.js +96 -0
- package/dist/harness/main.d.ts +6 -0
- package/dist/harness/main.js +103 -0
- package/dist/harness/pod.d.ts +21 -0
- package/dist/harness/pod.js +119 -0
- package/dist/harness/run-tokens.d.ts +18 -0
- package/dist/harness/run-tokens.js +15 -0
- package/dist/harness/service.d.ts +46 -0
- package/dist/harness/service.js +179 -0
- package/dist/harness/ws-client.d.ts +43 -0
- package/dist/harness/ws-client.js +122 -0
- package/dist/harness/ws-port.d.ts +22 -0
- package/dist/harness/ws-port.js +78 -0
- package/dist/harness-api/in-process.d.ts +24 -0
- package/dist/harness-api/in-process.js +119 -0
- package/dist/harness-api/record.d.ts +44 -0
- package/dist/harness-api/record.js +250 -0
- package/dist/harness-api/renew.d.ts +37 -0
- package/dist/harness-api/renew.js +77 -0
- package/dist/harness-api/server.d.ts +104 -0
- package/dist/harness-api/server.js +408 -0
- package/dist/harness-api/start.d.ts +36 -0
- package/dist/harness-api/start.js +118 -0
- package/dist/harness-api/workspace.d.ts +53 -0
- package/dist/harness-api/workspace.js +201 -0
- package/dist/harness-api/ws-server.d.ts +34 -0
- package/dist/harness-api/ws-server.js +227 -0
- package/dist/host/admin-api.d.ts +12 -5
- package/dist/host/admin-api.js +72 -6
- package/dist/host/app.d.ts +0 -1
- package/dist/host/app.js +35 -24
- package/dist/host/config-for.d.ts +4 -0
- package/dist/host/config-for.js +2 -0
- package/dist/host/config.d.ts +0 -6
- package/dist/host/create-host.d.ts +3 -10
- package/dist/host/create-host.js +4 -1
- package/dist/host/gates.d.ts +27 -2
- package/dist/host/gates.js +52 -2
- package/dist/host/http.d.ts +4 -1
- package/dist/host/http.js +6 -1
- package/dist/host/main.js +167 -37
- package/dist/host/stack-config.d.ts +112 -9
- package/dist/host/stack-config.js +222 -20
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/keys/client.js +9 -1
- package/dist/keys/keys.d.ts +12 -2
- package/dist/keys/keys.js +8 -0
- package/dist/mcp/connect.js +2 -1
- package/dist/mcp/pool.d.ts +1 -0
- package/dist/mcp/pool.js +1 -0
- package/dist/mcp/snapshot.d.ts +8 -1
- package/dist/mcp/snapshot.js +28 -0
- package/dist/media.d.ts +5 -24
- package/dist/media.js +5 -0
- package/dist/model/pi-model.d.ts +6 -2
- package/dist/model/pi-model.js +39 -22
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +1 -1
- package/dist/openapi.json +14084 -9426
- package/dist/record/index.d.ts +1 -0
- package/dist/record/index.js +1 -0
- package/dist/record/sandbox.d.ts +25 -0
- package/dist/record/sandbox.js +43 -0
- package/dist/sandbox/capability.d.ts +3 -0
- package/dist/sandbox/capability.js +10 -0
- package/dist/sandbox/egress-token.d.ts +26 -0
- package/dist/sandbox/egress-token.js +8 -0
- package/dist/sandbox/join.d.ts +37 -0
- package/dist/sandbox/join.js +165 -0
- package/dist/sandbox/manager.d.ts +99 -34
- package/dist/sandbox/manager.js +216 -84
- package/dist/sandbox/placement.d.ts +27 -0
- package/dist/sandbox/placement.js +44 -0
- package/dist/sandbox/pods/client.d.ts +90 -0
- package/dist/sandbox/pods/client.js +79 -0
- package/dist/sandbox/pods/lifecycle.d.ts +91 -0
- package/dist/sandbox/pods/lifecycle.js +178 -0
- package/dist/sandbox/pods/name.d.ts +1 -0
- package/dist/sandbox/pods/name.js +28 -0
- package/dist/sandbox/pods/network-gate.d.ts +25 -0
- package/dist/sandbox/pods/network-gate.js +71 -0
- package/dist/sandbox/pods/reconcile.d.ts +11 -0
- package/dist/sandbox/pods/reconcile.js +152 -0
- package/dist/sandbox/pods/spec.d.ts +45 -0
- package/dist/sandbox/pods/spec.js +62 -0
- package/dist/sandbox/records.d.ts +29 -0
- package/dist/sandbox/records.js +79 -0
- package/dist/sandbox/resolve.d.ts +5 -0
- package/dist/sandbox/resolve.js +3 -2
- package/dist/sandbox/session-sandbox.js +7 -5
- package/dist/sandbox/share.d.ts +11 -0
- package/dist/sandbox/share.js +10 -0
- package/dist/sandbox/tenant-config.d.ts +16 -1
- package/dist/sandbox/tenant-config.js +9 -0
- package/dist/sandbox/types.d.ts +29 -1
- package/dist/sandbox/types.js +13 -1
- package/dist/store/postgres/drizzle/0004_sandbox_resources.sql +20 -0
- package/dist/store/postgres/drizzle/0005_artifacts.sql +27 -0
- package/dist/store/postgres/drizzle/0006_folder_artifacts.sql +12 -0
- package/dist/store/postgres/drizzle/0007_sandbox_pods.sql +14 -0
- package/dist/store/postgres/drizzle/0008_installation_vaults.sql +2 -0
- package/dist/store/postgres/drizzle/0009_oauth_pending.sql +19 -0
- package/dist/store/postgres/drizzle/0010_oss_auth_removals.sql +3 -0
- package/dist/store/postgres/drizzle/meta/_journal.json +49 -0
- package/dist/store/postgres/record-writer.d.ts +6 -1
- package/dist/store/postgres/record-writer.js +20 -2
- package/dist/store/postgres/schema.d.ts +1168 -250
- package/dist/store/postgres/schema.js +174 -28
- package/dist/store/postgres/store.js +339 -103
- package/dist/store/postgres/tenant.d.ts +1 -1
- package/dist/store/postgres/tenant.js +2 -2
- package/dist/store/types.d.ts +163 -32
- package/dist/streams/control.d.ts +2 -5
- package/dist/streams/control.js +5 -8
- package/dist/streams/types.d.ts +8 -8
- package/dist/streams/types.js +1 -1
- package/dist/tenant/advance.js +218 -160
- package/dist/tenant/artifact-tool.d.ts +5 -0
- package/dist/tenant/artifact-tool.js +119 -0
- package/dist/tenant/auth.d.ts +13 -9
- package/dist/tenant/auth.js +25 -32
- package/dist/tenant/commands.js +31 -10
- package/dist/tenant/context.d.ts +83 -26
- package/dist/tenant/delivery-token.js +4 -4
- package/dist/tenant/effects.d.ts +24 -14
- package/dist/tenant/effects.js +10 -398
- package/dist/tenant/ephemeral.d.ts +14 -2
- package/dist/tenant/ephemeral.js +8 -1
- package/dist/tenant/history.d.ts +13 -23
- package/dist/tenant/history.js +14 -62
- package/dist/tenant/host-token.d.ts +92 -0
- package/dist/tenant/host-token.js +179 -0
- package/dist/tenant/identity-file.d.ts +75 -0
- package/dist/tenant/identity-file.js +202 -0
- package/dist/tenant/issuers.d.ts +48 -0
- package/dist/tenant/issuers.js +311 -0
- package/dist/tenant/jwt.js +3 -3
- package/dist/tenant/module.js +1 -0
- package/dist/tenant/operator-keys.d.ts +18 -0
- package/dist/tenant/operator-keys.js +55 -0
- package/dist/tenant/outbound.d.ts +30 -0
- package/dist/tenant/outbound.js +142 -10
- package/dist/tenant/paths.d.ts +2 -1
- package/dist/tenant/paths.js +3 -1
- package/dist/tenant/principals.d.ts +2 -11
- package/dist/tenant/principals.js +10 -30
- package/dist/tenant/reset.d.ts +5 -2
- package/dist/tenant/reset.js +22 -2
- package/dist/tenant/run-grants.d.ts +49 -0
- package/dist/tenant/run-grants.js +62 -0
- package/dist/tenant/run-token.d.ts +70 -0
- package/dist/tenant/run-token.js +138 -0
- package/dist/tenant/runtime.d.ts +42 -0
- package/dist/tenant/runtime.js +134 -33
- package/dist/tenant/sandboxes.d.ts +119 -0
- package/dist/tenant/sandboxes.js +551 -0
- package/dist/tenant/session-streams.d.ts +6 -10
- package/dist/tenant/session-streams.js +9 -27
- package/dist/tenant/session.d.ts +2 -13
- package/dist/tenant/session.js +4 -28
- package/dist/tenant/sessions.d.ts +6 -1
- package/dist/tenant/sessions.js +29 -2
- package/dist/tenant/signing-keys.d.ts +2 -1
- package/dist/tenant/signing-keys.js +2 -2
- package/dist/tenant/status.d.ts +8 -3
- package/dist/tenant/status.js +5 -0
- package/dist/tenant/streams.d.ts +8 -2
- package/dist/tenant/streams.js +25 -6
- package/dist/tenant/sweep.js +37 -4
- package/dist/tenant/types.d.ts +39 -1
- package/dist/tenant/worker.d.ts +11 -5
- package/dist/tenant/worker.js +12 -6
- package/dist/vault/crypto.d.ts +7 -0
- package/dist/vault/crypto.js +16 -0
- package/dist/vault/oauth.d.ts +55 -0
- package/dist/vault/oauth.js +186 -0
- package/dist/vault/service.d.ts +54 -7
- package/dist/vault/service.js +261 -17
- package/dist/vault/sources.d.ts +54 -0
- package/dist/vault/sources.js +185 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +14 -10
- package/dist/adapters/media.d.ts +0 -24
- package/dist/adapters/media.js +0 -111
- package/dist/host/cors.d.ts +0 -27
- package/dist/host/cors.js +0 -64
- package/dist/tenant/access-policy.d.ts +0 -30
- package/dist/tenant/access-policy.js +0 -52
- package/dist/tenant/browser.d.ts +0 -15
- package/dist/tenant/browser.js +0 -39
- package/dist/tenant/subject-limits.d.ts +0 -16
- package/dist/tenant/subject-limits.js +0 -45
- package/dist/tenant/tokens.d.ts +0 -14
- package/dist/tenant/tokens.js +0 -180
package/dist/store/types.d.ts
CHANGED
|
@@ -55,9 +55,10 @@
|
|
|
55
55
|
* them there (`tenant/session-streams.ts`).
|
|
56
56
|
*/
|
|
57
57
|
import type { RecordReader } from "../streams/relay/types.js";
|
|
58
|
-
import type { Action, EventPayload, EventType, LiveEvent, SessionEventOf } from "@nylorun/core/contracts";
|
|
58
|
+
import type { Action, EventPayload, EventType, LiveEvent, SandboxEvent, SandboxEventPayload, SandboxEventType, SandboxKind, SandboxPodDesired, SandboxPodObserved, SessionEventOf } from "@nylorun/core/contracts";
|
|
59
|
+
import type { SandboxManifest } from "@nylorun/core/define";
|
|
59
60
|
import type { HostEffect } from "@nylorun/harness/run";
|
|
60
|
-
import type { ModelBudgetRow, ModelUsageRow, PrincipalRow, ToolCrossingRow,
|
|
61
|
+
import type { ArtifactRow, ArtifactVersionRow, ModelBudgetRow, ModelUsageRow, PrincipalRow, ToolCrossingRow, SigningKeyRow, VaultAuditRow, VaultCredentialRow, VaultIdempotencyRow, VaultRow, OAuthPendingRow } from "./postgres/schema.js";
|
|
61
62
|
/** Tables holding JSON documents keyed by `id`. */
|
|
62
63
|
export type DocTable = "definitions" | "sessions" | "commands" | "effects" | "actions" | "sandboxes" | "links";
|
|
63
64
|
export declare const DOC_TABLES: readonly DocTable[];
|
|
@@ -80,6 +81,12 @@ export interface SessionOwnership {
|
|
|
80
81
|
/** ISO time the owner's lease ends, or null without an owner. */
|
|
81
82
|
ownerExpiresAt: string | null;
|
|
82
83
|
}
|
|
84
|
+
/** A session's lease epoch, status and active turn: what a run token must still match. */
|
|
85
|
+
export interface SessionRunState {
|
|
86
|
+
readonly epoch: number;
|
|
87
|
+
readonly status: string;
|
|
88
|
+
readonly activeTurnId: string | null;
|
|
89
|
+
}
|
|
83
90
|
/**
|
|
84
91
|
* The fields of a session document that the store indexes. The
|
|
85
92
|
* Runtime's own session type extends this; everything else in the body is
|
|
@@ -115,6 +122,50 @@ export interface DefinitionDoc {
|
|
|
115
122
|
export interface SandboxDoc {
|
|
116
123
|
key: string;
|
|
117
124
|
}
|
|
125
|
+
/** A sandbox resource (`sandbox_resources`): what `PUT /v1/sandboxes/{id}` created. */
|
|
126
|
+
export interface SandboxResource {
|
|
127
|
+
id: string;
|
|
128
|
+
kind: SandboxKind;
|
|
129
|
+
/** The spec resolved against the Tenant's limits when the sandbox was created. */
|
|
130
|
+
spec: SandboxManifest;
|
|
131
|
+
labels: Record<string, string>;
|
|
132
|
+
createdAt: string;
|
|
133
|
+
updatedAt: string;
|
|
134
|
+
/** Kind `pod`: the pod's lifecycle (F7.2). Absent for a virtual sandbox. */
|
|
135
|
+
pod?: SandboxPodState;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* A pod sandbox's lifecycle columns (`sandbox_resources`, F7.2, D34): what the Runtime wants
|
|
139
|
+
* (`desired`), what it last saw (`observed`), and the fences of its incarnations.
|
|
140
|
+
*/
|
|
141
|
+
export interface SandboxPodState {
|
|
142
|
+
/** The agent-sandbox Sandbox's name (`podName`), of generation `volumeGen`. */
|
|
143
|
+
k8sName: string;
|
|
144
|
+
volumeGen: number;
|
|
145
|
+
desired: SandboxPodDesired;
|
|
146
|
+
observed: SandboxPodObserved;
|
|
147
|
+
/** The UID of the pod that last joined. */
|
|
148
|
+
podUid?: string;
|
|
149
|
+
/** Bumped by every join, relaunch, loss and reset; host and egress tokens carry it. */
|
|
150
|
+
hostEpoch: number;
|
|
151
|
+
/** sha256 hex of the incarnation's join token. */
|
|
152
|
+
joinTokenHash?: string;
|
|
153
|
+
/** Bumped by every change asked of the pod (the sandboxes service's `opId`). */
|
|
154
|
+
rev: number;
|
|
155
|
+
/** ISO times. */
|
|
156
|
+
lastActiveAt?: string;
|
|
157
|
+
expiresAt?: string;
|
|
158
|
+
startedAt?: string;
|
|
159
|
+
reason?: string;
|
|
160
|
+
/** An earlier incarnation's Sandbox still to delete (after a reset or a loss). */
|
|
161
|
+
retiring?: string;
|
|
162
|
+
/** The id the engine keeps on the volume, from the first join. */
|
|
163
|
+
volumeId?: string;
|
|
164
|
+
}
|
|
165
|
+
/** A change to a pod's columns: `null` clears an optional one. */
|
|
166
|
+
export type SandboxPodPatch = {
|
|
167
|
+
[K in keyof SandboxPodState]?: undefined extends SandboxPodState[K] ? SandboxPodState[K] | null : SandboxPodState[K];
|
|
168
|
+
};
|
|
118
169
|
/** A session as read from the store: its document plus the store-managed ownership fields. */
|
|
119
170
|
export type StoredSession<T extends SessionDoc = SessionDoc> = T & SessionOwnership;
|
|
120
171
|
/** A link row together with the agent session it names. */
|
|
@@ -191,10 +242,9 @@ export type EndpointHealthUpdate =
|
|
|
191
242
|
* The rows of the typed tables, inferred from the tables Drizzle defines
|
|
192
243
|
* (`store/postgres/schema.ts`): a principal, a vault and its credentials (secrets sealed in
|
|
193
244
|
* `bytea` columns, never inside a JSON body), the vault's audit and idempotency records, the
|
|
194
|
-
* Tenant's signing keys, a
|
|
195
|
-
* ledger and a model budget.
|
|
245
|
+
* Tenant's signing keys, a model call in the usage ledger and a model budget.
|
|
196
246
|
*/
|
|
197
|
-
export type { ModelBudgetRow, ModelUsageRow, ToolCrossingRow, PrincipalRow,
|
|
247
|
+
export type { ArtifactRow, ArtifactVersionRow, ModelBudgetRow, ModelUsageRow, ToolCrossingRow, PrincipalRow, SigningKeyRow, VaultAuditRow, VaultCredentialRow, VaultIdempotencyRow, VaultRow, OAuthPendingRow, };
|
|
198
248
|
/** Which rows of the usage ledger a total covers. */
|
|
199
249
|
export interface ModelUsageQuery {
|
|
200
250
|
scope: "tenant" | "agent" | "turn";
|
|
@@ -340,6 +390,11 @@ export interface Tx {
|
|
|
340
390
|
* advance calls this first; see `ownedTx` in `store/ownership.ts`.
|
|
341
391
|
*/
|
|
342
392
|
assertEpoch<T extends SessionDoc = SessionDoc>(sessionId: string, epoch: number): Promise<StoredSession<T>>;
|
|
393
|
+
/**
|
|
394
|
+
* What a run token's live check reads of a session (F5 gate trust): its lease epoch, status
|
|
395
|
+
* and active turn, without the body. Undefined when the session is gone. Does not lock.
|
|
396
|
+
*/
|
|
397
|
+
runState(sessionId: string): Promise<SessionRunState | undefined>;
|
|
343
398
|
sessionsWithStatus<T extends SessionDoc = SessionDoc>(statuses: readonly (SessionStatus | (string & {}))[]): Promise<StoredSession<T>[]>;
|
|
344
399
|
/**
|
|
345
400
|
* Sessions `running` or `runnable` with no owner or an owner whose lease
|
|
@@ -353,6 +408,37 @@ export interface Tx {
|
|
|
353
408
|
}): Promise<StoredSession<T>[]>;
|
|
354
409
|
listDefinitions<T extends DefinitionDoc = DefinitionDoc>(): Promise<T[]>;
|
|
355
410
|
listSandboxes<T extends SandboxDoc = SandboxDoc>(): Promise<T[]>;
|
|
411
|
+
/** The sandbox resource `id`; with `lock`, its row is locked until the transaction ends. */
|
|
412
|
+
sandboxResource(id: string, options?: {
|
|
413
|
+
lock?: boolean;
|
|
414
|
+
}): Promise<SandboxResource | undefined>;
|
|
415
|
+
/**
|
|
416
|
+
* Creates the sandbox resource unless one with its id exists, while the Tenant holds fewer
|
|
417
|
+
* than `limit`: `exists` and `limit` write nothing. Serialized with every other create.
|
|
418
|
+
*/
|
|
419
|
+
createSandboxResource(row: SandboxResource, limit: number): Promise<"created" | "exists" | "limit">;
|
|
420
|
+
updateSandboxLabels(id: string, labels: Record<string, string>, updatedAt: string): Promise<void>;
|
|
421
|
+
/** Replaces a sandbox's spec (a pod's new `lifecycle.ttl`; the caller holds the row's lock). */
|
|
422
|
+
updateSandboxSpec(id: string, spec: SandboxManifest, updatedAt: string): Promise<void>;
|
|
423
|
+
/** Changes a pod sandbox's lifecycle columns (the caller holds the row's lock). */
|
|
424
|
+
updateSandboxPod(id: string, patch: SandboxPodPatch, updatedAt: string): Promise<void>;
|
|
425
|
+
deleteSandboxResource(id: string): Promise<void>;
|
|
426
|
+
/** Sandbox resources by id, those with every label in `labels` when it is given. */
|
|
427
|
+
listSandboxResources(filter?: {
|
|
428
|
+
labels?: Record<string, string>;
|
|
429
|
+
}): Promise<SandboxResource[]>;
|
|
430
|
+
/** Sessions attached to sandbox resource `sandboxId` (`Session.sandboxId`), by id. */
|
|
431
|
+
sessionsOnSandbox<T extends SessionDoc = SessionDoc>(sandboxId: string): Promise<StoredSession<T>[]>;
|
|
432
|
+
/**
|
|
433
|
+
* Appends an event to the sandbox's lifecycle stream through the record module. The caller
|
|
434
|
+
* holds the sandbox row's lock (or created the row in this transaction).
|
|
435
|
+
*/
|
|
436
|
+
sandboxEvent<T extends SandboxEventType>(sandboxId: string, type: T, payload: SandboxEventPayload<T>): Promise<SandboxEvent>;
|
|
437
|
+
/** The sandbox's lifecycle stream, from `fromSeq` on, at most `limit` events. */
|
|
438
|
+
sandboxEvents(sandboxId: string, options?: {
|
|
439
|
+
fromSeq?: number;
|
|
440
|
+
limit?: number;
|
|
441
|
+
}): Promise<SandboxEvent[]>;
|
|
356
442
|
/** One agent's `pending` actions, delivered when its endpoint is registered. */
|
|
357
443
|
pendingActions(agentId: string): Promise<ActionDoc[]>;
|
|
358
444
|
/** How many of one agent's actions are `delivering` (Action endpoints). */
|
|
@@ -393,11 +479,23 @@ export interface Tx {
|
|
|
393
479
|
principalByTokenHash(tokenHash: string): Promise<PrincipalRow | undefined>;
|
|
394
480
|
principalById(id: string): Promise<PrincipalRow | undefined>;
|
|
395
481
|
applicationTokenHashes(): Promise<string[]>;
|
|
482
|
+
/** Every principal, ordered by id. */
|
|
483
|
+
listPrincipals(): Promise<PrincipalRow[]>;
|
|
484
|
+
/**
|
|
485
|
+
* Creates application principal `id` with `tokenHash`, or gives an existing one this hash
|
|
486
|
+
* (and `createdAt`): its previous key stops authenticating. Rejects when another principal
|
|
487
|
+
* holds the hash.
|
|
488
|
+
*/
|
|
489
|
+
putPrincipal(id: string, tokenHash: string, createdAt: string): Promise<PrincipalRow>;
|
|
490
|
+
/** Deletes principal `id`; false when there was none. */
|
|
491
|
+
deletePrincipal(id: string): Promise<boolean>;
|
|
396
492
|
/** Rejects on a duplicate id, or a second `host` vault. */
|
|
397
493
|
insertVault(row: VaultRow): Promise<void>;
|
|
398
494
|
getVault(id: string): Promise<VaultRow | undefined>;
|
|
399
495
|
/** User vaults of one owner, ordered by `createdAt`, then id. */
|
|
400
496
|
vaultsByOwner(ownerUserId: string): Promise<VaultRow[]>;
|
|
497
|
+
/** Installation vaults (any session may attach them), ordered by `createdAt`, then id. */
|
|
498
|
+
installationVaults(): Promise<VaultRow[]>;
|
|
401
499
|
updateVaultMetadata(id: string, metadataJson: string | null): Promise<void>;
|
|
402
500
|
/** Deletes the vault and its credentials. */
|
|
403
501
|
deleteVault(id: string): Promise<void>;
|
|
@@ -423,6 +521,12 @@ export interface Tx {
|
|
|
423
521
|
getVaultIdempotency(id: string): Promise<VaultIdempotencyRow | undefined>;
|
|
424
522
|
/** Rejects when the id exists. */
|
|
425
523
|
insertVaultIdempotency(row: VaultIdempotencyRow): Promise<void>;
|
|
524
|
+
/** An MCP OAuth connect's start (F9 C2). Rejects on a duplicate state or an unknown vault. */
|
|
525
|
+
insertOAuthPending(row: OAuthPendingRow): Promise<void>;
|
|
526
|
+
/** Deletes and returns the pending connect of `stateHash`, expired or not: each is used once. */
|
|
527
|
+
takeOAuthPending(stateHash: string): Promise<OAuthPendingRow | undefined>;
|
|
528
|
+
/** Deletes the pending connects that expired before `now` (ISO); returns how many. */
|
|
529
|
+
deleteExpiredOAuthPending(now: string): Promise<number>;
|
|
426
530
|
/**
|
|
427
531
|
* Serializes signing key changes: held until the transaction ends. Take it before reading
|
|
428
532
|
* the keys a change depends on, so concurrent first uses or rotations do not collide.
|
|
@@ -440,28 +544,6 @@ export interface Tx {
|
|
|
440
544
|
*/
|
|
441
545
|
setSigningKeyState(id: string, from: SigningKeyRow["state"], to: SigningKeyRow["state"], at: string): Promise<boolean>;
|
|
442
546
|
countSigningKeys(): Promise<number>;
|
|
443
|
-
/** The subject's revocation epoch; 0 when it was never revoked. */
|
|
444
|
-
subjectEpoch(subject: string): Promise<number>;
|
|
445
|
-
/** The epochs of several subjects; subjects never revoked are absent. */
|
|
446
|
-
subjectEpochs(subjects: readonly string[]): Promise<Map<string, number>>;
|
|
447
|
-
/** Adds one to the subject's epoch and returns the new value. */
|
|
448
|
-
bumpSubjectEpoch(subject: string, at: string): Promise<number>;
|
|
449
|
-
/**
|
|
450
|
-
* The subject's turn bucket, created from `initial` when missing, locked until the
|
|
451
|
-
* transaction ends so concurrent commands of one subject serialize.
|
|
452
|
-
*/
|
|
453
|
-
lockSubjectUsage(initial: SubjectUsageRow): Promise<SubjectUsageRow>;
|
|
454
|
-
putSubjectUsage(row: SubjectUsageRow): Promise<void>;
|
|
455
|
-
/** How many sessions of `ownerUserId` are in one of `statuses`. */
|
|
456
|
-
countOwnerSessions(ownerUserId: string, statuses: readonly string[]): Promise<number>;
|
|
457
|
-
/** Rejects on a duplicate id, key or name. */
|
|
458
|
-
insertPublishableKey(row: PublishableKeyRow): Promise<void>;
|
|
459
|
-
publishableKeyByKey(key: string): Promise<PublishableKeyRow | undefined>;
|
|
460
|
-
publishableKey(id: string): Promise<PublishableKeyRow | undefined>;
|
|
461
|
-
/** All keys, revoked ones included, ordered by `createdAt`, then id. */
|
|
462
|
-
publishableKeys(): Promise<PublishableKeyRow[]>;
|
|
463
|
-
/** Returns false when the key does not exist. */
|
|
464
|
-
updatePublishableKey(id: string, patch: Partial<Pick<PublishableKeyRow, "originsJson" | "revokedAt">>): Promise<boolean>;
|
|
465
547
|
/** Appends a row, setting `duplicate` when one with the same `effectKey` exists; returns it. */
|
|
466
548
|
recordModelUsage(row: Omit<ModelUsageRow, "duplicate">): Promise<ModelUsageRow>;
|
|
467
549
|
modelUsageTotals(query: ModelUsageQuery): Promise<ModelUsageTotals>;
|
|
@@ -476,18 +558,67 @@ export interface Tx {
|
|
|
476
558
|
settleToolCrossing(key: string, answer: unknown, settledAt: string): Promise<void>;
|
|
477
559
|
/** Deletes rows that settled before `before`; returns how many. */
|
|
478
560
|
pruneToolCrossings(before: string): Promise<number>;
|
|
561
|
+
/** The artifact `id`; with `lock`, its row is locked until the transaction ends. */
|
|
562
|
+
artifact(id: string, options?: {
|
|
563
|
+
lock?: boolean;
|
|
564
|
+
}): Promise<ArtifactRow | undefined>;
|
|
565
|
+
/** Artifacts by creation time, then id: those of one session when `sessionId` is given. */
|
|
566
|
+
listArtifacts(filter?: {
|
|
567
|
+
sessionId?: string;
|
|
568
|
+
}): Promise<ArtifactRow[]>;
|
|
569
|
+
/** Writes a new artifact with its first version. Rejects on a duplicate id. */
|
|
570
|
+
insertArtifact(row: ArtifactRow, version: ArtifactVersionRow): Promise<void>;
|
|
571
|
+
/**
|
|
572
|
+
* Adds the next version of a locked artifact and makes it the latest (its content type and
|
|
573
|
+
* `updatedAt` follow the version).
|
|
574
|
+
*/
|
|
575
|
+
insertArtifactVersion(version: ArtifactVersionRow): Promise<void>;
|
|
576
|
+
/** One version, or every version oldest first. */
|
|
577
|
+
artifactVersion(artifactId: string, version: number): Promise<ArtifactVersionRow | undefined>;
|
|
578
|
+
artifactVersions(artifactId: string): Promise<ArtifactVersionRow[]>;
|
|
579
|
+
/** Deletes the artifact and its versions; returns the versions' blob keys (empty when none). */
|
|
580
|
+
deleteArtifact(id: string): Promise<string[]>;
|
|
581
|
+
/**
|
|
582
|
+
* Serializes the Tenant's artifact writes: held until the transaction ends. Take it before
|
|
583
|
+
* reading the total a new version must fit under.
|
|
584
|
+
*/
|
|
585
|
+
lockArtifactQuota(): Promise<void>;
|
|
586
|
+
/**
|
|
587
|
+
* The bytes the artifacts store: every file version, plus each distinct content-addressed file
|
|
588
|
+
* of the folders once (F8.2).
|
|
589
|
+
*/
|
|
590
|
+
artifactBytes(): Promise<number>;
|
|
591
|
+
/**
|
|
592
|
+
* The blob keys of every artifact version (a folder's: its manifests): of session artifacts
|
|
593
|
+
* only, or of all of them.
|
|
594
|
+
*/
|
|
595
|
+
artifactBlobKeys(scope: "sessions" | "all"): Promise<string[]>;
|
|
596
|
+
/** Records the distinct content-addressed files a folder version references (F8.2). */
|
|
597
|
+
insertArtifactContent(artifactId: string, version: number, files: readonly {
|
|
598
|
+
sha256: string;
|
|
599
|
+
size: number;
|
|
600
|
+
}[]): Promise<void>;
|
|
601
|
+
/** Those of `shas` some committed folder version references. */
|
|
602
|
+
referencedArtifactContent(shas: readonly string[]): Promise<Set<string>>;
|
|
603
|
+
/**
|
|
604
|
+
* The distinct content-addressed files folder versions reference: of one artifact, of session
|
|
605
|
+
* artifacts only, or of all of them.
|
|
606
|
+
*/
|
|
607
|
+
artifactContentShas(scope: "sessions" | "all" | {
|
|
608
|
+
artifactId: string;
|
|
609
|
+
}): Promise<string[]>;
|
|
479
610
|
getSetting(key: string): Promise<string | undefined>;
|
|
480
611
|
putSetting(key: string, value: string): Promise<void>;
|
|
481
612
|
/**
|
|
482
613
|
* Deletes Tenant state by scope, in this transaction:
|
|
483
|
-
* - `sessions`: sessions, commands, effects, actions, links,
|
|
484
|
-
*
|
|
614
|
+
* - `sessions`: sessions, commands, effects, actions, links, the artifacts of sessions (their blobs are the caller's to delete) and the
|
|
615
|
+
* Tenant's record rows and log heads. The Tenant moves to the next basin
|
|
485
616
|
* generation and the current one is retired, so session ids it frees start again in an
|
|
486
617
|
* empty basin;
|
|
487
|
-
* - `sandboxes`: sandbox records;
|
|
618
|
+
* - `sandboxes`: sandbox records, sandbox resources and their lifecycle streams;
|
|
488
619
|
* - `all`: both, plus definitions, Action endpoints, user vaults with their credentials,
|
|
489
|
-
* the model usage ledger
|
|
490
|
-
*
|
|
620
|
+
* the model usage ledger, the model budgets and Tenant-wide artifacts. The host vault, principals, signing keys,
|
|
621
|
+
* settings, audit and vault idempotency rows stay.
|
|
491
622
|
*/
|
|
492
623
|
reset(scope: ResetScope): Promise<void>;
|
|
493
624
|
}
|
|
@@ -6,13 +6,10 @@
|
|
|
6
6
|
import { type DurableStreams } from "./types.js";
|
|
7
7
|
/** Appends a `session.cancel` signal: the process running the session's advance aborts it. */
|
|
8
8
|
export declare function signalCancel(streams: DurableStreams, basin: string, sessionId: string, turnId?: string): Promise<void>;
|
|
9
|
+
/** Appends an `action.resolved` signal: a run held for the Action goes on with its outcome. */
|
|
10
|
+
export declare function signalActionResolved(streams: DurableStreams, basin: string, sessionId: string, actionId: string): Promise<void>;
|
|
9
11
|
/**
|
|
10
12
|
* Appends a `sessions.reset` signal to the old generation's basin: every process with the
|
|
11
13
|
* Tenant open moves its readers to `generation` and ends the streams of deleted sessions.
|
|
12
14
|
*/
|
|
13
15
|
export declare function signalSessionsReset(streams: DurableStreams, basin: string, generation: number): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Appends a `subject.revoked` signal: every process with the Tenant open ends the subject's
|
|
16
|
-
* streams opened with a token older than `epoch`.
|
|
17
|
-
*/
|
|
18
|
-
export declare function signalSubjectRevoked(streams: DurableStreams, basin: string, subject: string, epoch: number): Promise<void>;
|
package/dist/streams/control.js
CHANGED
|
@@ -15,6 +15,11 @@ export async function signalCancel(streams, basin, sessionId, turnId) {
|
|
|
15
15
|
};
|
|
16
16
|
await streams.append(basin, CONTROL_STREAM, [signal]);
|
|
17
17
|
}
|
|
18
|
+
/** Appends an `action.resolved` signal: a run held for the Action goes on with its outcome. */
|
|
19
|
+
export async function signalActionResolved(streams, basin, sessionId, actionId) {
|
|
20
|
+
const signal = { type: "action.resolved", sessionId, actionId };
|
|
21
|
+
await streams.append(basin, CONTROL_STREAM, [signal]);
|
|
22
|
+
}
|
|
18
23
|
/**
|
|
19
24
|
* Appends a `sessions.reset` signal to the old generation's basin: every process with the
|
|
20
25
|
* Tenant open moves its readers to `generation` and ends the streams of deleted sessions.
|
|
@@ -23,11 +28,3 @@ export async function signalSessionsReset(streams, basin, generation) {
|
|
|
23
28
|
const signal = { type: "sessions.reset", generation };
|
|
24
29
|
await streams.append(basin, CONTROL_STREAM, [signal]);
|
|
25
30
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Appends a `subject.revoked` signal: every process with the Tenant open ends the subject's
|
|
28
|
-
* streams opened with a token older than `epoch`.
|
|
29
|
-
*/
|
|
30
|
-
export async function signalSubjectRevoked(streams, basin, subject, epoch) {
|
|
31
|
-
const signal = { type: "subject.revoked", subject, epoch };
|
|
32
|
-
await streams.append(basin, CONTROL_STREAM, [signal]);
|
|
33
|
-
}
|
package/dist/streams/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* | Stream | Contents | Written by | Read by |
|
|
8
8
|
* | --- | --- | --- | --- |
|
|
9
9
|
* | `sessions/<sessionId>` | every event of the session, in sequence | the stream relay, from the record | history and session SSE |
|
|
10
|
-
* | `tenant/control` | `session.cancel`, `sessions.reset` and `
|
|
10
|
+
* | `tenant/control` | `session.cancel`, `sessions.reset` and `action.resolved` signals | API nodes | every process with the Tenant open |
|
|
11
11
|
*
|
|
12
12
|
* **Basin generations.** A session id is unique within its Tenant's basin generation. A
|
|
13
13
|
* Tenant reset, the only path that frees ids, moves the Tenant to the next generation, so
|
|
@@ -139,12 +139,12 @@ export interface SessionsResetSignal {
|
|
|
139
139
|
generation?: number;
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
142
|
+
* An Action of `sessionId` has its outcome (F6.2): the process whose harness holds the
|
|
143
|
+
* session's run while the Action is pending passes it on (`effect.resolved`).
|
|
144
144
|
*/
|
|
145
|
-
export interface
|
|
146
|
-
type: "
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
export interface ActionResolvedSignal {
|
|
146
|
+
type: "action.resolved";
|
|
147
|
+
sessionId: string;
|
|
148
|
+
actionId: string;
|
|
149
149
|
}
|
|
150
|
-
export type ControlSignal = SessionCancelSignal | SessionsResetSignal |
|
|
150
|
+
export type ControlSignal = SessionCancelSignal | SessionsResetSignal | ActionResolvedSignal;
|
package/dist/streams/types.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* | Stream | Contents | Written by | Read by |
|
|
8
8
|
* | --- | --- | --- | --- |
|
|
9
9
|
* | `sessions/<sessionId>` | every event of the session, in sequence | the stream relay, from the record | history and session SSE |
|
|
10
|
-
* | `tenant/control` | `session.cancel`, `sessions.reset` and `
|
|
10
|
+
* | `tenant/control` | `session.cancel`, `sessions.reset` and `action.resolved` signals | API nodes | every process with the Tenant open |
|
|
11
11
|
*
|
|
12
12
|
* **Basin generations.** A session id is unique within its Tenant's basin generation. A
|
|
13
13
|
* Tenant reset, the only path that frees ids, moves the Tenant to the next generation, so
|