@nylorun/runtime 0.23.0-beta → 0.24.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 +148 -0
- package/README.md +79 -28
- package/dist/adapters/execution/restate.js +1 -1
- package/dist/adapters/replication/pgoutput.d.ts +2 -0
- package/dist/adapters/replication/pgoutput.js +6 -3
- package/dist/adapters/sandbox/local.d.ts +9 -1
- package/dist/adapters/sandbox/local.js +16 -4
- package/dist/adapters/sandbox/virtual.js +4 -1
- package/dist/api/a2a/endpoint.js +5 -1
- package/dist/api/a2a/routes.d.ts +2 -0
- package/dist/api/a2a/routes.js +2 -2
- package/dist/api/a2a/tasks.js +2 -1
- package/dist/api/ag-ui/endpoint.js +4 -2
- package/dist/api/ag-ui/history.js +4 -1
- package/dist/api/ag-ui/routes.d.ts +4 -1
- package/dist/api/ag-ui/routes.js +11 -10
- package/dist/api/ag-ui/translate.js +3 -2
- package/dist/api/components.d.ts +4953 -1204
- package/dist/api/components.js +25 -16
- package/dist/api/gate/keys.js +7 -1
- package/dist/api/gate/routes.d.ts +6 -0
- package/dist/api/gate/routes.js +39 -3
- package/dist/api/http/app.js +4 -4
- package/dist/api/http/define.d.ts +6 -0
- package/dist/api/http/define.js +13 -1
- package/dist/api/http/respond.js +1 -1
- package/dist/api/http/routes/artifacts.js +35 -8
- package/dist/api/http/routes/coverage.d.ts +9 -0
- package/dist/api/http/routes/coverage.js +34 -0
- package/dist/api/http/routes/environments.d.ts +11 -0
- package/dist/api/http/routes/environments.js +283 -0
- package/dist/api/http/routes/mcp.d.ts +1 -1
- package/dist/api/http/routes/mcp.js +2 -2
- package/dist/api/http/routes/me.js +1 -1
- package/dist/api/http/routes/reads.d.ts +45 -9
- package/dist/api/http/routes/reads.js +54 -5
- package/dist/api/http/routes/sessions.js +11 -6
- package/dist/api/http/routes/tenant.js +32 -10
- package/dist/api/openapi.js +31 -26
- package/dist/artifacts/disk.d.ts +59 -0
- package/dist/artifacts/disk.js +563 -0
- package/dist/artifacts/export.d.ts +1 -1
- package/dist/artifacts/export.js +2 -3
- package/dist/artifacts/folders.d.ts +6 -3
- package/dist/artifacts/folders.js +17 -12
- package/dist/artifacts/service.d.ts +2 -1
- package/dist/artifacts/service.js +6 -1
- package/dist/artifacts/workspace.d.ts +1 -1
- package/dist/artifacts/workspace.js +1 -1
- package/dist/core/flow-host.d.ts +2 -3
- package/dist/core/flow-host.js +3 -0
- package/dist/core/provider.d.ts +3 -2
- package/dist/core/provider.js +5 -37
- package/dist/core/sandbox-routes.d.ts +2 -21
- package/dist/core/sandbox-routes.js +10 -43
- package/dist/execution/types.d.ts +1 -1
- package/dist/gates/contract.d.ts +3 -24
- package/dist/gates/contract.js +1 -36
- package/dist/gates/egress-credentials.d.ts +9 -0
- package/dist/gates/egress-credentials.js +11 -4
- package/dist/gates/egress.d.ts +28 -1
- package/dist/gates/egress.js +115 -10
- package/dist/gates/fixture-model.d.ts +28 -0
- package/dist/gates/fixture-model.js +92 -0
- package/dist/gates/handler.js +4 -4
- package/dist/gates/http-tool.d.ts +6 -2
- package/dist/gates/http-tool.js +3 -5
- package/dist/gates/in-process.d.ts +5 -0
- package/dist/gates/in-process.js +12 -1
- package/dist/gates/journal.d.ts +30 -0
- package/dist/gates/journal.js +52 -0
- package/dist/gates/mcp-handler.d.ts +4 -0
- package/dist/gates/mcp-handler.js +5 -1
- package/dist/gates/meter.d.ts +10 -2
- package/dist/gates/meter.js +20 -5
- package/dist/gates/policy.d.ts +49 -0
- package/dist/gates/policy.js +134 -0
- package/dist/gates/tenant-vaults.d.ts +7 -7
- package/dist/gates/tenant-vaults.js +5 -5
- package/dist/gates/tool-calls.d.ts +10 -5
- package/dist/gates/tool-calls.js +28 -10
- package/dist/gates/tool-client.d.ts +8 -0
- package/dist/gates/tool-client.js +27 -11
- package/dist/gates/tool-contract.d.ts +10 -68
- package/dist/gates/tool-contract.js +1 -85
- package/dist/gates/tool-gate.d.ts +1 -1
- package/dist/harness/calls.d.ts +12 -5
- package/dist/harness/calls.js +21 -12
- package/dist/harness/executors.js +12 -9
- package/dist/harness/main.js +18 -5
- package/dist/harness/pod.d.ts +34 -0
- package/dist/harness/pod.js +41 -0
- package/dist/harness/service.d.ts +0 -1
- package/dist/harness/service.js +13 -5
- package/dist/harness/setup.d.ts +27 -0
- package/dist/harness/setup.js +150 -0
- package/dist/harness/ws-client.js +3 -2
- package/dist/harness/ws-port.d.ts +1 -5
- package/dist/harness/ws-port.js +1 -5
- package/dist/harness-api/in-process.js +3 -3
- package/dist/harness-api/record.d.ts +15 -1
- package/dist/harness-api/record.js +174 -44
- package/dist/harness-api/redact.d.ts +3 -0
- package/dist/harness-api/redact.js +45 -0
- package/dist/harness-api/server.d.ts +8 -0
- package/dist/harness-api/server.js +93 -13
- package/dist/harness-api/start.d.ts +10 -3
- package/dist/harness-api/start.js +40 -10
- package/dist/harness-api/tool-journal.d.ts +96 -0
- package/dist/harness-api/tool-journal.js +102 -0
- package/dist/harness-api/tool-status.d.ts +13 -0
- package/dist/harness-api/tool-status.js +26 -0
- package/dist/harness-api/workspace.d.ts +6 -3
- package/dist/harness-api/workspace.js +27 -11
- package/dist/harness-api/ws-server.d.ts +11 -3
- package/dist/harness-api/ws-server.js +94 -15
- package/dist/host/gates.d.ts +2 -1
- package/dist/host/gates.js +10 -2
- package/dist/host/main.js +54 -5
- package/dist/host/operate.js +67 -5
- package/dist/host/stack-config.d.ts +64 -0
- package/dist/host/stack-config.js +61 -1
- package/dist/keys/client.js +4 -1
- package/dist/keys/keys.d.ts +5 -5
- package/dist/keys/keys.js +5 -7
- package/dist/management-openapi.json +999 -2211
- package/dist/mcp/connect.d.ts +25 -20
- package/dist/mcp/connect.js +29 -30
- package/dist/mcp/pool.d.ts +2 -2
- package/dist/mcp/pool.js +1 -1
- package/dist/mcp/preview.d.ts +3 -3
- package/dist/mcp/preview.js +10 -20
- package/dist/mcp/snapshot.d.ts +5 -11
- package/dist/mcp/snapshot.js +6 -7
- package/dist/model/pi-model.js +8 -0
- package/dist/openapi.json +6955 -2526
- package/dist/reads/types.d.ts +16 -3
- package/dist/record/append.d.ts +3 -1
- package/dist/record/append.js +1 -0
- package/dist/record/envelope.d.ts +5 -1
- package/dist/record/envelope.js +7 -3
- package/dist/record/environment.d.ts +25 -0
- package/dist/record/environment.js +44 -0
- package/dist/record/index.d.ts +1 -1
- package/dist/record/index.js +1 -1
- package/dist/sandbox/disk-fs.d.ts +95 -0
- package/dist/sandbox/disk-fs.js +206 -0
- package/dist/sandbox/join.d.ts +17 -18
- package/dist/sandbox/join.js +42 -15
- package/dist/sandbox/manager.d.ts +16 -8
- package/dist/sandbox/manager.js +33 -17
- package/dist/sandbox/placement.d.ts +13 -12
- package/dist/sandbox/placement.js +29 -12
- package/dist/sandbox/pods/client.d.ts +6 -1
- package/dist/sandbox/pods/lifecycle.d.ts +28 -27
- package/dist/sandbox/pods/lifecycle.js +14 -26
- package/dist/sandbox/pods/reconcile.js +18 -12
- package/dist/sandbox/pods/spec.d.ts +15 -13
- package/dist/sandbox/pods/spec.js +16 -20
- package/dist/sandbox/records.d.ts +2 -2
- package/dist/sandbox/records.js +3 -3
- package/dist/sandbox/resolve.d.ts +35 -27
- package/dist/sandbox/resolve.js +66 -41
- package/dist/sandbox/session-sandbox.js +1 -1
- package/dist/sandbox/setup.d.ts +61 -0
- package/dist/sandbox/setup.js +123 -0
- package/dist/sandbox/share.d.ts +11 -21
- package/dist/sandbox/share.js +12 -41
- package/dist/sandbox/tenant-config.d.ts +12 -14
- package/dist/sandbox/tenant-config.js +12 -17
- package/dist/sandbox/types.d.ts +6 -0
- package/dist/store/postgres/drizzle/0020_environments.sql +63 -0
- package/dist/store/postgres/drizzle/0021_disk_versions.sql +7 -0
- package/dist/store/postgres/drizzle/0022_model_usage_timing.sql +5 -0
- package/dist/store/postgres/drizzle/0023_artifact_pages.sql +1 -0
- package/dist/store/postgres/drizzle/meta/_journal.json +28 -0
- package/dist/store/postgres/reads.js +117 -17
- package/dist/store/postgres/record-writer.d.ts +4 -4
- package/dist/store/postgres/record-writer.js +9 -9
- package/dist/store/postgres/record.d.ts +7 -0
- package/dist/store/postgres/record.js +23 -2
- package/dist/store/postgres/schema.d.ts +934 -761
- package/dist/store/postgres/schema.js +102 -73
- package/dist/store/postgres/store.js +119 -66
- package/dist/store/types.d.ts +109 -48
- package/dist/tenant/advance.d.ts +7 -6
- package/dist/tenant/advance.js +115 -42
- package/dist/tenant/artifact-tool.js +3 -4
- package/dist/tenant/commands.d.ts +15 -2
- package/dist/tenant/commands.js +93 -12
- package/dist/tenant/context.d.ts +48 -22
- package/dist/tenant/context.js +4 -15
- package/dist/tenant/effects.d.ts +1 -1
- package/dist/tenant/effects.js +37 -20
- package/dist/tenant/environments.d.ts +167 -0
- package/dist/tenant/environments.js +823 -0
- package/dist/tenant/harness-tokens.d.ts +21 -0
- package/dist/tenant/harness-tokens.js +61 -0
- package/dist/tenant/host-token.d.ts +1 -1
- package/dist/tenant/host-token.js +2 -4
- package/dist/tenant/identity-file.d.ts +4 -4
- package/dist/tenant/identity-file.js +17 -8
- package/dist/tenant/issuers.js +3 -3
- package/dist/tenant/principals.js +1 -1
- package/dist/tenant/reset.js +3 -3
- package/dist/tenant/runtime.d.ts +6 -1
- package/dist/tenant/runtime.js +7 -1
- package/dist/tenant/session.d.ts +3 -3
- package/dist/tenant/session.js +0 -14
- package/dist/tenant/sessions.d.ts +13 -13
- package/dist/tenant/sessions.js +61 -138
- package/dist/tenant/signing-keys.d.ts +5 -1
- package/dist/tenant/status.js +3 -3
- package/dist/tenant/sweep.js +12 -6
- package/dist/tenant/transcript.d.ts +210 -20
- package/dist/tenant/transcript.js +62 -11
- package/dist/tenant/turn-timing.d.ts +43 -0
- package/dist/tenant/turn-timing.js +39 -0
- package/dist/tenant/types.d.ts +2 -0
- package/dist/traces/ids.d.ts +42 -0
- package/dist/traces/ids.js +85 -0
- package/dist/traces/key.d.ts +6 -0
- package/dist/traces/key.js +37 -0
- package/dist/traces/map.d.ts +113 -0
- package/dist/traces/map.js +317 -0
- package/dist/traces/options.d.ts +7 -0
- package/dist/traces/options.js +1 -0
- package/dist/traces/otlp.d.ts +42 -0
- package/dist/traces/otlp.js +84 -0
- package/dist/traces/projector.d.ts +58 -0
- package/dist/traces/projector.js +200 -0
- package/dist/traces/read.d.ts +23 -0
- package/dist/traces/read.js +16 -0
- package/dist/vault/coverage.d.ts +26 -0
- package/dist/vault/coverage.js +64 -0
- package/dist/vault/error.d.ts +11 -1
- package/dist/vault/error.js +5 -1
- package/dist/vault/service.d.ts +47 -48
- package/dist/vault/service.js +321 -382
- package/dist/vault/sources.d.ts +5 -16
- package/dist/vault/sources.js +6 -8
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/package.json +13 -13
- package/dist/api/http/routes/sandboxes.d.ts +0 -9
- package/dist/api/http/routes/sandboxes.js +0 -153
- package/dist/api/http/routes/vaults.d.ts +0 -10
- package/dist/api/http/routes/vaults.js +0 -139
- package/dist/record/sandbox.d.ts +0 -25
- package/dist/record/sandbox.js +0 -43
- package/dist/tenant/sandboxes.d.ts +0 -123
- package/dist/tenant/sandboxes.js +0 -566
package/dist/store/types.d.ts
CHANGED
|
@@ -63,8 +63,7 @@
|
|
|
63
63
|
import type { KeyRole } from "@nylorun/core/compatibility";
|
|
64
64
|
import type { RecordReader } from "../streams/relay/types.js";
|
|
65
65
|
import type { SandboxSignal, Wake } from "../execution/types.js";
|
|
66
|
-
import type { EventPayload, EventType, LiveEvent,
|
|
67
|
-
import type { SandboxManifest } from "@nylorun/core/define";
|
|
66
|
+
import type { EventPayload, EventType, EventWriter, LiveEvent, EnvironmentEvent, EnvironmentEventPayload, EnvironmentEventType, EnvironmentKind, EnvironmentRecipe, PodDesired, PodObserved, SessionEventOf } from "@nylorun/core/contracts";
|
|
68
67
|
import type { HostEffect } from "@nylorun/harness/run";
|
|
69
68
|
import type { ArtifactRow, ArtifactVersionRow, DefinitionFileRow, ModelBudgetRow, ModelUsageRow, ModelUsageWrite, PrincipalRow, ToolCrossingRow, SigningKeyRow, VaultAuditRow, VaultCredentialRow, VaultIdempotencyRow, VaultRow } from "./postgres/schema.js";
|
|
70
69
|
/** Tables holding JSON documents keyed by `id`. */
|
|
@@ -73,7 +72,9 @@ export declare const DOC_TABLES: readonly DocTable[];
|
|
|
73
72
|
/** Session lifecycle (architecture §10.2). */
|
|
74
73
|
export type SessionStatus = "idle" | "runnable" | "running" | "waiting" | "paused" | "uncertain" | "completed" | "failed" | "cancelled";
|
|
75
74
|
/** Effect states (§10.3), plus the flow host's `queued` and `cancelled`. */
|
|
76
|
-
export type EffectStatus = "pending" | "invoking"
|
|
75
|
+
export type EffectStatus = "pending" | "invoking"
|
|
76
|
+
/** A tool call the Tool Gate held for a person's approval (R5 step 2): nothing was sent. */
|
|
77
|
+
| "held" | "completed" | "uncertain" | "queued" | "cancelled";
|
|
77
78
|
export type EffectKind = HostEffect["kind"];
|
|
78
79
|
/**
|
|
79
80
|
* Ownership of a session by a Worker (§10.6). Read with the session; written
|
|
@@ -126,28 +127,51 @@ export interface DefinitionDoc {
|
|
|
126
127
|
export interface SandboxDoc {
|
|
127
128
|
key: string;
|
|
128
129
|
}
|
|
129
|
-
/**
|
|
130
|
-
export interface
|
|
130
|
+
/** An Environment (`environments`, D55): what `PUT /v1/environments/{id}` created. */
|
|
131
|
+
export interface Environment {
|
|
131
132
|
id: string;
|
|
132
|
-
kind:
|
|
133
|
-
/** The spec resolved against the Tenant's limits when the sandbox was created. */
|
|
134
|
-
spec: SandboxManifest;
|
|
133
|
+
kind: EnvironmentKind;
|
|
135
134
|
labels: Record<string, string>;
|
|
135
|
+
/** What the app asked for, resolved against the Tenant's limits. */
|
|
136
|
+
recipe: EnvironmentRecipe;
|
|
137
|
+
/** The recipe the current pod or workspace runs (copied from `recipe` at the next wake). */
|
|
138
|
+
applied: EnvironmentRecipe;
|
|
139
|
+
version: number;
|
|
140
|
+
appliedVersion: number;
|
|
141
|
+
/** The owner guard: only this owner's sessions may name it. */
|
|
142
|
+
ownerUserId?: string;
|
|
143
|
+
/** ISO time it was last used (`lifecycle.deleteAfter` counts from it). */
|
|
144
|
+
lastUsedAt: string;
|
|
136
145
|
createdAt: string;
|
|
137
146
|
updatedAt: string;
|
|
138
|
-
/** Kind `pod`: the pod's lifecycle (F7.2). Absent
|
|
147
|
+
/** Kind `pod`: the pod's lifecycle (F7.2). Absent otherwise. */
|
|
139
148
|
pod?: SandboxPodState;
|
|
149
|
+
/** The disk lease while a snapshot, restore or seed copies the disk (R2d step 3). */
|
|
150
|
+
diskOp?: DiskOperation;
|
|
151
|
+
/** The disk version the next volume starts from (R2d step 3). */
|
|
152
|
+
diskSeed?: {
|
|
153
|
+
artifactId: string;
|
|
154
|
+
version: number;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/** A disk lease (R2d step 3): what holds the disk, since when, and until when unless renewed. */
|
|
158
|
+
export interface DiskOperation {
|
|
159
|
+
kind: "snapshot" | "restore" | "seed";
|
|
160
|
+
version?: number;
|
|
161
|
+
/** ISO times. */
|
|
162
|
+
startedAt: string;
|
|
163
|
+
until: string;
|
|
140
164
|
}
|
|
141
165
|
/**
|
|
142
|
-
* A pod
|
|
166
|
+
* A pod Environment's lifecycle columns (`environments`, F7.2, D34): what the Runtime wants
|
|
143
167
|
* (`desired`), what it last saw (`observed`), and the fences of its incarnations.
|
|
144
168
|
*/
|
|
145
169
|
export interface SandboxPodState {
|
|
146
170
|
/** The agent-sandbox Sandbox's name (`podName`), of generation `volumeGen`. */
|
|
147
171
|
k8sName: string;
|
|
148
172
|
volumeGen: number;
|
|
149
|
-
desired:
|
|
150
|
-
observed:
|
|
173
|
+
desired: PodDesired;
|
|
174
|
+
observed: PodObserved;
|
|
151
175
|
/** The UID of the pod that last joined. */
|
|
152
176
|
podUid?: string;
|
|
153
177
|
/** Bumped by every join, relaunch, loss and reset; host and egress tokens carry it. */
|
|
@@ -158,7 +182,6 @@ export interface SandboxPodState {
|
|
|
158
182
|
rev: number;
|
|
159
183
|
/** ISO times. */
|
|
160
184
|
lastActiveAt?: string;
|
|
161
|
-
expiresAt?: string;
|
|
162
185
|
startedAt?: string;
|
|
163
186
|
reason?: string;
|
|
164
187
|
/** An earlier incarnation's Sandbox still to delete (after a reset or a loss). */
|
|
@@ -233,7 +256,7 @@ export interface StoreCounts {
|
|
|
233
256
|
sandboxes: number;
|
|
234
257
|
definitions: number;
|
|
235
258
|
}
|
|
236
|
-
export type ResetScope = "sessions" | "
|
|
259
|
+
export type ResetScope = "sessions" | "environments" | "all";
|
|
237
260
|
/** Result of `takeOwnership`. */
|
|
238
261
|
export type TakeOwnership = {
|
|
239
262
|
status: "owned";
|
|
@@ -406,7 +429,9 @@ export interface Tx {
|
|
|
406
429
|
* commit listeners. Rejects when the session does not exist. The returned
|
|
407
430
|
* cursor is final.
|
|
408
431
|
*/
|
|
409
|
-
event<T extends EventType>(sessionId: string, turnId: string | null, type: T, payload: EventPayload<T
|
|
432
|
+
event<T extends EventType>(sessionId: string, turnId: string | null, type: T, payload: EventPayload<T>,
|
|
433
|
+
/** Who wrote it (R4.9): absent, core, observed. */
|
|
434
|
+
writer?: EventWriter): Promise<SessionEventOf<T>>;
|
|
410
435
|
/**
|
|
411
436
|
* Asks for an advance of `sessionId` once this transaction commits. The request is a row
|
|
412
437
|
* of the wake outbox written in this transaction, so it commits, or rolls back, with what
|
|
@@ -483,37 +508,54 @@ export interface Tx {
|
|
|
483
508
|
}): Promise<StoredSession<T>[]>;
|
|
484
509
|
listDefinitions<T extends DefinitionDoc = DefinitionDoc>(): Promise<T[]>;
|
|
485
510
|
listSandboxes<T extends SandboxDoc = SandboxDoc>(): Promise<T[]>;
|
|
486
|
-
/**
|
|
487
|
-
|
|
511
|
+
/** Environment `id`; with `lock`, its row is locked until the transaction ends. */
|
|
512
|
+
environment(id: string, options?: {
|
|
488
513
|
lock?: boolean;
|
|
489
|
-
}): Promise<
|
|
490
|
-
/**
|
|
491
|
-
* Creates the
|
|
492
|
-
*
|
|
493
|
-
*/
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
514
|
+
}): Promise<Environment | undefined>;
|
|
515
|
+
/**
|
|
516
|
+
* Creates the Environment unless one with its id exists, while the Tenant holds fewer than
|
|
517
|
+
* `limit`: `exists` and `limit` write nothing. Serialized with every other create.
|
|
518
|
+
*/
|
|
519
|
+
createEnvironment(row: Environment, limit: number): Promise<"created" | "exists" | "limit">;
|
|
520
|
+
/**
|
|
521
|
+
* Changes an Environment's columns other than its pod's (the caller holds the row's lock):
|
|
522
|
+
* labels, recipe and version, the applied recipe and its version, the owner guard (`null`
|
|
523
|
+
* clears it), and when it was last used.
|
|
524
|
+
*/
|
|
525
|
+
updateEnvironment(id: string, patch: {
|
|
526
|
+
labels?: Record<string, string>;
|
|
527
|
+
recipe?: EnvironmentRecipe;
|
|
528
|
+
version?: number;
|
|
529
|
+
applied?: EnvironmentRecipe;
|
|
530
|
+
appliedVersion?: number;
|
|
531
|
+
ownerUserId?: string | null;
|
|
532
|
+
lastUsedAt?: string;
|
|
533
|
+
diskOp?: DiskOperation | null;
|
|
534
|
+
diskSeed?: {
|
|
535
|
+
artifactId: string;
|
|
536
|
+
version: number;
|
|
537
|
+
} | null;
|
|
538
|
+
}, updatedAt: string): Promise<void>;
|
|
539
|
+
/** Changes a pod Environment's lifecycle columns (the caller holds the row's lock). */
|
|
540
|
+
updateEnvironmentPod(id: string, patch: SandboxPodPatch, updatedAt: string): Promise<void>;
|
|
541
|
+
/** Deletes the Environment; its vault and credentials go with it (foreign key). */
|
|
542
|
+
deleteEnvironment(id: string): Promise<void>;
|
|
543
|
+
/** Environments by id, those with every label in `labels` when it is given. */
|
|
544
|
+
listEnvironments(filter?: {
|
|
503
545
|
labels?: Record<string, string>;
|
|
504
|
-
}): Promise<
|
|
505
|
-
/** Sessions
|
|
506
|
-
|
|
546
|
+
}): Promise<Environment[]>;
|
|
547
|
+
/** Sessions that name Environment `environmentId` (`Session.environmentId`), by id. */
|
|
548
|
+
sessionsOnEnvironment<T extends SessionDoc = SessionDoc>(environmentId: string): Promise<StoredSession<T>[]>;
|
|
507
549
|
/**
|
|
508
|
-
* Appends an event to the
|
|
509
|
-
* holds the
|
|
550
|
+
* Appends an event to the Environment's lifecycle stream through the record module. The
|
|
551
|
+
* caller holds the Environment row's lock (or created the row in this transaction).
|
|
510
552
|
*/
|
|
511
|
-
|
|
512
|
-
/** The
|
|
513
|
-
|
|
553
|
+
environmentEvent<T extends EnvironmentEventType>(environmentId: string, type: T, payload: EnvironmentEventPayload<T>): Promise<EnvironmentEvent>;
|
|
554
|
+
/** The Environment's lifecycle stream, from `fromSeq` on, at most `limit` events. */
|
|
555
|
+
environmentEvents(environmentId: string, options?: {
|
|
514
556
|
fromSeq?: number;
|
|
515
557
|
limit?: number;
|
|
516
|
-
}): Promise<
|
|
558
|
+
}): Promise<EnvironmentEvent[]>;
|
|
517
559
|
/** `invoking` effects of one session; takeover turns them `uncertain`. */
|
|
518
560
|
invokingEffects<T extends EffectDoc = EffectDoc>(sessionId: string): Promise<T[]>;
|
|
519
561
|
effectsForSession<T extends EffectDoc = EffectDoc>(sessionId: string, filter?: SessionEffectFilter): Promise<T[]>;
|
|
@@ -549,20 +591,20 @@ export interface Tx {
|
|
|
549
591
|
putPrincipal(id: string, tokenHash: string, createdAt: string, role?: KeyRole): Promise<PrincipalRow>;
|
|
550
592
|
/** Deletes principal `id`; false when there was none. */
|
|
551
593
|
deletePrincipal(id: string): Promise<boolean>;
|
|
552
|
-
/** Rejects on a duplicate id, or a second
|
|
594
|
+
/** Rejects on a duplicate id, or a second vault for one Environment. */
|
|
553
595
|
insertVault(row: VaultRow): Promise<void>;
|
|
554
596
|
getVault(id: string): Promise<VaultRow | undefined>;
|
|
555
|
-
/**
|
|
556
|
-
|
|
557
|
-
/** Installation vaults (any session may attach them), ordered by `createdAt`, then id. */
|
|
558
|
-
installationVaults(): Promise<VaultRow[]>;
|
|
597
|
+
/** The vault of Environment `environmentId` (D56). */
|
|
598
|
+
vaultOfEnvironment(environmentId: string): Promise<VaultRow | undefined>;
|
|
559
599
|
updateVaultMetadata(id: string, metadataJson: string | null): Promise<void>;
|
|
560
600
|
/** Deletes the vault and its credentials. */
|
|
561
601
|
deleteVault(id: string): Promise<void>;
|
|
562
602
|
/** Rejects on a duplicate id or an unknown vault. */
|
|
563
603
|
insertCredential(row: VaultCredentialRow): Promise<void>;
|
|
564
|
-
/** Looks a credential up by id alone
|
|
604
|
+
/** Looks a credential up by id alone; callers compare `vaultId`. */
|
|
565
605
|
getCredential(id: string): Promise<VaultCredentialRow | undefined>;
|
|
606
|
+
/** The credential named `name` in vault `vaultId` (names are unique per vault). */
|
|
607
|
+
credentialByName(vaultId: string, name: string): Promise<VaultCredentialRow | undefined>;
|
|
566
608
|
/** Credentials of one vault, ordered by `createdAt`, then id. */
|
|
567
609
|
credentialsForVault(vaultId: string, filter?: {
|
|
568
610
|
type?: VaultCredentialRow["type"];
|
|
@@ -600,6 +642,11 @@ export interface Tx {
|
|
|
600
642
|
countSigningKeys(): Promise<number>;
|
|
601
643
|
/** Appends a row, setting `duplicate` when one with the same `effectKey` exists; returns it. */
|
|
602
644
|
recordModelUsage(row: ModelUsageWrite): Promise<ModelUsageRow>;
|
|
645
|
+
/**
|
|
646
|
+
* The first row the gate recorded for the model call `effectKey` (R7.1), never a `duplicate`;
|
|
647
|
+
* undefined when no gate metered it.
|
|
648
|
+
*/
|
|
649
|
+
modelUsageOf(effectKey: string): Promise<ModelUsageRow | undefined>;
|
|
603
650
|
modelUsageTotals(query: ModelUsageQuery): Promise<ModelUsageTotals>;
|
|
604
651
|
/** Every budget, ordered by scope, then scope id. */
|
|
605
652
|
listModelBudgets(): Promise<ModelBudgetRow[]>;
|
|
@@ -608,6 +655,11 @@ export interface Tx {
|
|
|
608
655
|
toolCrossing(key: string): Promise<ToolCrossingRow | undefined>;
|
|
609
656
|
/** Inserts the running call's row; false when a row with `key` already exists. */
|
|
610
657
|
startToolCrossing(row: Pick<ToolCrossingRow, "key" | "hash" | "startedAt">): Promise<boolean>;
|
|
658
|
+
/**
|
|
659
|
+
* Starts a lost call's row again (R5.3): `startedAt` moves on, on a row with no answer and
|
|
660
|
+
* `hash`. False when the row is gone, settled, or another request's.
|
|
661
|
+
*/
|
|
662
|
+
restartToolCrossing(row: Pick<ToolCrossingRow, "key" | "hash" | "startedAt">): Promise<boolean>;
|
|
611
663
|
/** Records the call's answer. */
|
|
612
664
|
settleToolCrossing(key: string, answer: unknown, settledAt: string): Promise<void>;
|
|
613
665
|
/** Deletes rows that settled before `before`; returns how many. */
|
|
@@ -616,6 +668,10 @@ export interface Tx {
|
|
|
616
668
|
artifact(id: string, options?: {
|
|
617
669
|
lock?: boolean;
|
|
618
670
|
}): Promise<ArtifactRow | undefined>;
|
|
671
|
+
/** The folder artifact that holds Environment `environmentId`'s disk versions (R2d step 3). */
|
|
672
|
+
diskArtifact(environmentId: string, options?: {
|
|
673
|
+
lock?: boolean;
|
|
674
|
+
}): Promise<ArtifactRow | undefined>;
|
|
619
675
|
/** Artifacts by creation time, then id: those of one session when `sessionId` is given. */
|
|
620
676
|
listArtifacts(filter?: {
|
|
621
677
|
sessionId?: string;
|
|
@@ -632,6 +688,11 @@ export interface Tx {
|
|
|
632
688
|
artifactVersions(artifactId: string): Promise<ArtifactVersionRow[]>;
|
|
633
689
|
/** Deletes the artifact and its versions; returns the versions' blob keys (empty when none). */
|
|
634
690
|
deleteArtifact(id: string): Promise<string[]>;
|
|
691
|
+
/**
|
|
692
|
+
* Deletes one version of a locked artifact (its content rows go with it) and returns its blob
|
|
693
|
+
* key; the latest version becomes the newest one left. The artifact itself stays, even empty.
|
|
694
|
+
*/
|
|
695
|
+
deleteArtifactVersion(artifactId: string, version: number): Promise<string | undefined>;
|
|
635
696
|
/**
|
|
636
697
|
* Serializes the Tenant's artifact writes: held until the transaction ends. Take it before
|
|
637
698
|
* reading the total a new version must fit under.
|
|
@@ -677,9 +738,9 @@ export interface Tx {
|
|
|
677
738
|
* Tenant's record rows and log heads. The Tenant moves to the next basin
|
|
678
739
|
* generation and the current one is retired, so session ids it frees start again in an
|
|
679
740
|
* empty basin;
|
|
680
|
-
* - `
|
|
741
|
+
* - `environments`: sandbox records, Environments with their vaults, and their lifecycle
|
|
742
|
+
* streams;
|
|
681
743
|
* - `all`: both, plus definitions (and which definition files they use),
|
|
682
|
-
* user vaults with their credentials,
|
|
683
744
|
* the model usage ledger, the model budgets and Tenant-wide artifacts. The host vault, principals, signing keys,
|
|
684
745
|
* settings, audit and vault idempotency rows stay.
|
|
685
746
|
*/
|
package/dist/tenant/advance.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AdvanceResult } from "../execution/types.js";
|
|
2
2
|
import type { Tx } from "../store/types.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type Session, type TenantContext } from "./context.js";
|
|
4
4
|
/**
|
|
5
5
|
* Advance session `id` if it has a runnable checkpoint (`WorkerHandlers.advance`). Returns
|
|
6
6
|
* `busy` when another advance holds a live lease, `done` otherwise.
|
|
@@ -9,12 +9,13 @@ export declare function advance(ctx: TenantContext, id: string, signal: AbortSig
|
|
|
9
9
|
/**
|
|
10
10
|
* Takeover (§10.5 step 2, §11.4), inside the transaction that took ownership: the dead
|
|
11
11
|
* owner's `invoking` effects become `uncertain` and are never invoked again, except model
|
|
12
|
-
* calls when the gate recovers them (P1.2) and
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* calls when the gate recovers them (P1.2) and every tool call (R5.3): those stay `invoking`,
|
|
13
|
+
* and the replay decides. It re-sends a model call, and an MCP or HTTP tool call with the same
|
|
14
|
+
* key; a sandbox or core-served tool call fails to the model as `tool.interrupted`
|
|
15
|
+
* (`harness-api/tool-journal.ts`). When an effect marked `uncertain` belongs to the active
|
|
16
|
+
* turn, the session becomes `uncertain` too, with an `effect.uncertain` event. Mutates and
|
|
17
|
+
* writes `s`. Returns the effect ids it marked.
|
|
16
18
|
*/
|
|
17
19
|
export declare function takeOver(t: Tx, s: Session, options?: {
|
|
18
20
|
recoversModelCalls?: boolean;
|
|
19
|
-
recoversToolCalls?: boolean;
|
|
20
21
|
}): Promise<string[]>;
|