@nylorun/runtime 0.23.0-beta → 0.25.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 +252 -0
- package/README.md +87 -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/card.d.ts +11 -1
- package/dist/api/a2a/card.js +26 -2
- package/dist/api/a2a/endpoint.js +9 -3
- package/dist/api/a2a/protocol.d.ts +25 -2
- package/dist/api/a2a/protocol.js +20 -3
- package/dist/api/a2a/routes.d.ts +6 -1
- package/dist/api/a2a/routes.js +67 -9
- package/dist/api/a2a/tasks.js +2 -1
- package/dist/api/ag-ui/endpoint.js +8 -3
- package/dist/api/ag-ui/history.d.ts +6 -1
- package/dist/api/ag-ui/history.js +39 -3
- package/dist/api/ag-ui/routes.d.ts +4 -1
- package/dist/api/ag-ui/routes.js +63 -20
- package/dist/api/ag-ui/translate.js +3 -2
- package/dist/api/components.d.ts +5327 -1091
- package/dist/api/components.js +40 -16
- package/dist/api/gate/keys.d.ts +2 -1
- package/dist/api/gate/keys.js +14 -1
- package/dist/api/gate/routes.d.ts +6 -0
- package/dist/api/gate/routes.js +52 -3
- package/dist/api/http/app.js +17 -6
- package/dist/api/http/body.d.ts +3 -3
- package/dist/api/http/body.js +7 -7
- 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/environment-manifests.d.ts +9 -0
- package/dist/api/http/routes/environment-manifests.js +118 -0
- package/dist/api/http/routes/environments.d.ts +11 -0
- package/dist/api/http/routes/environments.js +332 -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 +94 -9
- package/dist/api/http/routes/reads.js +54 -5
- package/dist/api/http/routes/sessions.js +24 -9
- package/dist/api/http/routes/tenant.js +65 -15
- package/dist/api/inbound-files.d.ts +65 -0
- package/dist/api/inbound-files.js +115 -0
- package/dist/api/openapi.js +48 -28
- package/dist/artifacts/disk.d.ts +59 -0
- package/dist/artifacts/disk.js +569 -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/media-types.d.ts +15 -0
- package/dist/artifacts/media-types.js +56 -4
- package/dist/artifacts/parts.d.ts +12 -3
- package/dist/artifacts/parts.js +15 -4
- package/dist/artifacts/service.d.ts +2 -1
- package/dist/artifacts/service.js +6 -1
- package/dist/artifacts/workspace.d.ts +5 -5
- package/dist/artifacts/workspace.js +7 -19
- package/dist/core/flow-host.d.ts +3 -4
- package/dist/core/flow-host.js +5 -2
- 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 +11 -44
- package/dist/core/turn-manifest.d.ts +3 -2
- package/dist/core/turn-manifest.js +29 -5
- 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 +22 -1
- package/dist/gates/egress.js +116 -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 +9 -6
- package/dist/gates/http-tool.js +11 -17
- 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 +51 -0
- package/dist/gates/mcp-handler.d.ts +4 -0
- package/dist/gates/mcp-handler.js +7 -4
- 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 +132 -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 +11 -69
- package/dist/gates/tool-contract.js +1 -85
- package/dist/gates/tool-gate.d.ts +1 -1
- package/dist/harness/calls.d.ts +14 -7
- package/dist/harness/calls.js +30 -24
- package/dist/harness/executors.js +12 -9
- package/dist/harness/main.js +24 -5
- package/dist/harness/pod.d.ts +39 -0
- package/dist/harness/pod.js +46 -0
- package/dist/harness/service.d.ts +0 -1
- package/dist/harness/service.js +17 -9
- package/dist/harness/setup.d.ts +29 -0
- package/dist/harness/setup.js +174 -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 +180 -50
- package/dist/harness-api/redact.d.ts +3 -0
- package/dist/harness-api/redact.js +45 -0
- package/dist/harness-api/server.d.ts +35 -4
- package/dist/harness-api/server.js +130 -17
- 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 +105 -0
- package/dist/harness-api/tool-journal.js +132 -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 +12 -7
- package/dist/harness-api/workspace.js +47 -25
- 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 +62 -2
- package/dist/keys/client.js +4 -1
- package/dist/keys/keys.d.ts +13 -6
- package/dist/keys/keys.js +9 -8
- package/dist/management-openapi.json +1264 -2171
- package/dist/mcp/connect.d.ts +26 -22
- package/dist/mcp/connect.js +30 -34
- package/dist/mcp/pool.d.ts +3 -6
- package/dist/mcp/pool.js +14 -28
- package/dist/mcp/preview.d.ts +3 -3
- package/dist/mcp/preview.js +10 -21
- package/dist/mcp/snapshot.d.ts +16 -24
- package/dist/mcp/snapshot.js +33 -45
- package/dist/model/capabilities.d.ts +26 -0
- package/dist/model/capabilities.js +44 -0
- package/dist/model/catalog.d.ts +34 -3
- package/dist/model/catalog.js +38 -2
- package/dist/model/models.d.ts +2 -0
- package/dist/model/models.js +1 -1
- package/dist/model/native-blocks.d.ts +35 -0
- package/dist/model/native-blocks.js +170 -0
- package/dist/model/pi-model.js +114 -94
- package/dist/openapi.json +12822 -3943
- 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 +46 -15
- package/dist/sandbox/manager.d.ts +47 -21
- package/dist/sandbox/manager.js +162 -107
- package/dist/sandbox/placement.d.ts +14 -13
- package/dist/sandbox/placement.js +31 -14
- package/dist/sandbox/pods/client.d.ts +9 -2
- package/dist/sandbox/pods/lifecycle.d.ts +36 -27
- package/dist/sandbox/pods/lifecycle.js +29 -26
- package/dist/sandbox/pods/reconcile.js +18 -12
- package/dist/sandbox/pods/spec.d.ts +15 -13
- package/dist/sandbox/pods/spec.js +17 -20
- package/dist/sandbox/records.d.ts +2 -2
- package/dist/sandbox/records.js +3 -3
- package/dist/sandbox/resolve.d.ts +37 -27
- package/dist/sandbox/resolve.js +73 -41
- package/dist/sandbox/runtime-tools.d.ts +9 -0
- package/dist/sandbox/runtime-tools.js +16 -0
- package/dist/sandbox/session-sandbox.d.ts +4 -6
- package/dist/sandbox/session-sandbox.js +47 -94
- package/dist/sandbox/setup.d.ts +64 -0
- package/dist/sandbox/setup.js +160 -0
- package/dist/sandbox/share.d.ts +21 -26
- package/dist/sandbox/share.js +36 -63
- package/dist/sandbox/skills.d.ts +8 -6
- package/dist/sandbox/skills.js +24 -23
- 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/0024_flat_manifest.sql +7 -0
- package/dist/store/postgres/drizzle/0025_environment_manifests.sql +14 -0
- package/dist/store/postgres/drizzle/0026_environment_forks.sql +1 -0
- package/dist/store/postgres/drizzle/0027_environment_image_digest.sql +1 -0
- package/dist/store/postgres/drizzle/meta/_journal.json +56 -0
- package/dist/store/postgres/reads.js +123 -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 +1126 -736
- package/dist/store/postgres/schema.js +136 -73
- package/dist/store/postgres/store.js +195 -67
- package/dist/store/types.d.ts +165 -50
- package/dist/tenant/advance.d.ts +7 -6
- package/dist/tenant/advance.js +118 -42
- package/dist/tenant/artifact-tool.d.ts +1 -1
- package/dist/tenant/artifact-tool.js +46 -26
- package/dist/tenant/commands.d.ts +15 -2
- package/dist/tenant/commands.js +115 -14
- package/dist/tenant/context.d.ts +56 -24
- package/dist/tenant/context.js +4 -15
- package/dist/tenant/effects.d.ts +1 -1
- package/dist/tenant/effects.js +44 -29
- package/dist/tenant/environment-manifests.d.ts +57 -0
- package/dist/tenant/environment-manifests.js +200 -0
- package/dist/tenant/environments.d.ts +174 -0
- package/dist/tenant/environments.js +1044 -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/model-setting.d.ts +14 -0
- package/dist/tenant/model-setting.js +51 -0
- 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 +18 -14
- package/dist/tenant/sessions.js +99 -143
- package/dist/tenant/signing-keys.d.ts +5 -1
- package/dist/tenant/skill-tool.d.ts +3 -3
- package/dist/tenant/skill-tool.js +6 -11
- package/dist/tenant/status.js +3 -3
- package/dist/tenant/sweep.js +13 -7
- package/dist/tenant/tool-results.js +1 -1
- package/dist/tenant/tool-search.d.ts +7 -11
- package/dist/tenant/tool-search.js +8 -5
- package/dist/tenant/transcript.d.ts +245 -36
- package/dist/tenant/transcript.js +64 -12
- 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 +41 -0
- package/dist/traces/ids.js +81 -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 +289 -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 +62 -0
- package/dist/vault/error.d.ts +11 -1
- package/dist/vault/error.js +5 -1
- package/dist/vault/host-model.d.ts +4 -1
- package/dist/vault/host-model.js +10 -2
- package/dist/vault/service.d.ts +92 -48
- package/dist/vault/service.js +462 -376
- 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/sandbox/capability.d.ts +0 -3
- package/dist/sandbox/capability.js +0 -10
- 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, EnvironmentManifest, 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,81 @@ 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
|
+
/**
|
|
152
|
+
* The disk version the next volume starts from (R2d step 3). `setup` (a fork onto other setup,
|
|
153
|
+
* Q17): the setup runs once the version is written (`written`), and the seed stays until it is done.
|
|
154
|
+
*/
|
|
155
|
+
diskSeed?: DiskSeed;
|
|
156
|
+
/** The environment manifest it was made from and its version (D63); absent for an inline one. */
|
|
157
|
+
manifestName?: string;
|
|
158
|
+
manifestVersion?: number;
|
|
159
|
+
/** The hash of what it runs (`recipe`), recorded at creation (protocol 14). */
|
|
160
|
+
manifestHash?: string;
|
|
161
|
+
/** The Environment it was forked from and the disk version it started from (Q15). */
|
|
162
|
+
forkedFrom?: {
|
|
163
|
+
environment: string;
|
|
164
|
+
disk: number | null;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/** A pending seed of an Environment's disk (`disk_seed`). */
|
|
168
|
+
export interface DiskSeed {
|
|
169
|
+
artifactId: string;
|
|
170
|
+
version: number;
|
|
171
|
+
/** Run the setup on the seeded disk (a fork onto other setup, Q17). */
|
|
172
|
+
setup?: true;
|
|
173
|
+
/** The version is written; with `setup`, the seed waits for the setup to be done. */
|
|
174
|
+
written?: true;
|
|
175
|
+
}
|
|
176
|
+
/** One version of an environment manifest (`environment_manifests`, D63). */
|
|
177
|
+
export interface EnvironmentManifestRow {
|
|
178
|
+
name: string;
|
|
179
|
+
version: number;
|
|
180
|
+
body: EnvironmentManifest;
|
|
181
|
+
hash: string;
|
|
182
|
+
savedBy: {
|
|
183
|
+
actor: string;
|
|
184
|
+
};
|
|
185
|
+
createdAt: string;
|
|
186
|
+
}
|
|
187
|
+
/** A disk lease (R2d step 3): what holds the disk, since when, and until when unless renewed. */
|
|
188
|
+
export interface DiskOperation {
|
|
189
|
+
kind: "snapshot" | "restore" | "seed";
|
|
190
|
+
version?: number;
|
|
191
|
+
/** ISO times. */
|
|
192
|
+
startedAt: string;
|
|
193
|
+
until: string;
|
|
140
194
|
}
|
|
141
195
|
/**
|
|
142
|
-
* A pod
|
|
196
|
+
* A pod Environment's lifecycle columns (`environments`, F7.2, D34): what the Runtime wants
|
|
143
197
|
* (`desired`), what it last saw (`observed`), and the fences of its incarnations.
|
|
144
198
|
*/
|
|
145
199
|
export interface SandboxPodState {
|
|
146
200
|
/** The agent-sandbox Sandbox's name (`podName`), of generation `volumeGen`. */
|
|
147
201
|
k8sName: string;
|
|
148
202
|
volumeGen: number;
|
|
149
|
-
desired:
|
|
150
|
-
observed:
|
|
203
|
+
desired: PodDesired;
|
|
204
|
+
observed: PodObserved;
|
|
151
205
|
/** The UID of the pod that last joined. */
|
|
152
206
|
podUid?: string;
|
|
153
207
|
/** Bumped by every join, relaunch, loss and reset; host and egress tokens carry it. */
|
|
@@ -158,13 +212,17 @@ export interface SandboxPodState {
|
|
|
158
212
|
rev: number;
|
|
159
213
|
/** ISO times. */
|
|
160
214
|
lastActiveAt?: string;
|
|
161
|
-
expiresAt?: string;
|
|
162
215
|
startedAt?: string;
|
|
163
216
|
reason?: string;
|
|
164
217
|
/** An earlier incarnation's Sandbox still to delete (after a reset or a loss). */
|
|
165
218
|
retiring?: string;
|
|
166
219
|
/** The id the engine keeps on the volume, from the first join. */
|
|
167
220
|
volumeId?: string;
|
|
221
|
+
/**
|
|
222
|
+
* The workload image by digest (`repo@sha256:…`), recorded the first time a pod of the
|
|
223
|
+
* Environment is ready (Q14): every later pod, after a stop, a relaunch or a reset, runs it.
|
|
224
|
+
*/
|
|
225
|
+
imageDigest?: string;
|
|
168
226
|
}
|
|
169
227
|
/** A change to a pod's columns: `null` clears an optional one. */
|
|
170
228
|
export type SandboxPodPatch = {
|
|
@@ -233,7 +291,7 @@ export interface StoreCounts {
|
|
|
233
291
|
sandboxes: number;
|
|
234
292
|
definitions: number;
|
|
235
293
|
}
|
|
236
|
-
export type ResetScope = "sessions" | "
|
|
294
|
+
export type ResetScope = "sessions" | "environments" | "all";
|
|
237
295
|
/** Result of `takeOwnership`. */
|
|
238
296
|
export type TakeOwnership = {
|
|
239
297
|
status: "owned";
|
|
@@ -406,7 +464,9 @@ export interface Tx {
|
|
|
406
464
|
* commit listeners. Rejects when the session does not exist. The returned
|
|
407
465
|
* cursor is final.
|
|
408
466
|
*/
|
|
409
|
-
event<T extends EventType>(sessionId: string, turnId: string | null, type: T, payload: EventPayload<T
|
|
467
|
+
event<T extends EventType>(sessionId: string, turnId: string | null, type: T, payload: EventPayload<T>,
|
|
468
|
+
/** Who wrote it (R4.9): absent, core, observed. */
|
|
469
|
+
writer?: EventWriter): Promise<SessionEventOf<T>>;
|
|
410
470
|
/**
|
|
411
471
|
* Asks for an advance of `sessionId` once this transaction commits. The request is a row
|
|
412
472
|
* of the wake outbox written in this transaction, so it commits, or rolls back, with what
|
|
@@ -483,37 +543,65 @@ export interface Tx {
|
|
|
483
543
|
}): Promise<StoredSession<T>[]>;
|
|
484
544
|
listDefinitions<T extends DefinitionDoc = DefinitionDoc>(): Promise<T[]>;
|
|
485
545
|
listSandboxes<T extends SandboxDoc = SandboxDoc>(): Promise<T[]>;
|
|
486
|
-
/**
|
|
487
|
-
|
|
546
|
+
/** Environment `id`; with `lock`, its row is locked until the transaction ends. */
|
|
547
|
+
environment(id: string, options?: {
|
|
488
548
|
lock?: boolean;
|
|
489
|
-
}): Promise<
|
|
490
|
-
/**
|
|
491
|
-
* Creates the
|
|
492
|
-
*
|
|
493
|
-
*/
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
549
|
+
}): Promise<Environment | undefined>;
|
|
550
|
+
/**
|
|
551
|
+
* Creates the Environment unless one with its id exists, while the Tenant holds fewer than
|
|
552
|
+
* `limit`: `exists` and `limit` write nothing. Serialized with every other create.
|
|
553
|
+
*/
|
|
554
|
+
createEnvironment(row: Environment, limit: number): Promise<"created" | "exists" | "limit">;
|
|
555
|
+
/**
|
|
556
|
+
* Changes an Environment's columns other than its pod's (the caller holds the row's lock):
|
|
557
|
+
* labels, recipe and version, the applied recipe and its version, the owner guard (`null`
|
|
558
|
+
* clears it), and when it was last used.
|
|
559
|
+
*/
|
|
560
|
+
updateEnvironment(id: string, patch: {
|
|
561
|
+
labels?: Record<string, string>;
|
|
562
|
+
recipe?: EnvironmentRecipe;
|
|
563
|
+
version?: number;
|
|
564
|
+
applied?: EnvironmentRecipe;
|
|
565
|
+
appliedVersion?: number;
|
|
566
|
+
ownerUserId?: string | null;
|
|
567
|
+
lastUsedAt?: string;
|
|
568
|
+
diskOp?: DiskOperation | null;
|
|
569
|
+
diskSeed?: DiskSeed | null;
|
|
570
|
+
}, updatedAt: string): Promise<void>;
|
|
571
|
+
/** Changes a pod Environment's lifecycle columns (the caller holds the row's lock). */
|
|
572
|
+
updateEnvironmentPod(id: string, patch: SandboxPodPatch, updatedAt: string): Promise<void>;
|
|
573
|
+
/** Deletes the Environment; its vault and credentials go with it (foreign key). */
|
|
574
|
+
deleteEnvironment(id: string): Promise<void>;
|
|
575
|
+
/** Environments by id, those with every label in `labels` when it is given. */
|
|
576
|
+
listEnvironments(filter?: {
|
|
503
577
|
labels?: Record<string, string>;
|
|
504
|
-
}): Promise<
|
|
505
|
-
/** Sessions
|
|
506
|
-
|
|
578
|
+
}): Promise<Environment[]>;
|
|
579
|
+
/** Sessions that name Environment `environmentId` (`Session.environmentId`), by id. */
|
|
580
|
+
sessionsOnEnvironment<T extends SessionDoc = SessionDoc>(environmentId: string): Promise<StoredSession<T>[]>;
|
|
507
581
|
/**
|
|
508
|
-
* Appends an event to the
|
|
509
|
-
* holds the
|
|
582
|
+
* Appends an event to the Environment's lifecycle stream through the record module. The
|
|
583
|
+
* caller holds the Environment row's lock (or created the row in this transaction).
|
|
510
584
|
*/
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
585
|
+
environmentEvent<T extends EnvironmentEventType>(environmentId: string, type: T, payload: EnvironmentEventPayload<T>): Promise<EnvironmentEvent>;
|
|
586
|
+
/**
|
|
587
|
+
* The Environment's stream, from `fromSeq` on, at most `limit` events: only `types` when given,
|
|
588
|
+
* and only events recorded at or after `since` and before `until` (ISO times) when given.
|
|
589
|
+
*/
|
|
590
|
+
environmentEvents(environmentId: string, options?: EnvironmentEventsQuery): Promise<EnvironmentEvent[]>;
|
|
591
|
+
/** Holds manifest `name`'s save lock until the transaction ends, so saves of one name are serial. */
|
|
592
|
+
lockEnvironmentManifest(name: string): Promise<void>;
|
|
593
|
+
/** Version `version` of manifest `name`, or its latest when `version` is omitted. */
|
|
594
|
+
environmentManifest(name: string, version?: number): Promise<EnvironmentManifestRow | undefined>;
|
|
595
|
+
/** Writes a new version (the caller holds the name's lock and chose the next number). */
|
|
596
|
+
insertEnvironmentManifest(row: EnvironmentManifestRow): Promise<void>;
|
|
597
|
+
/** Each manifest's latest version, by name. */
|
|
598
|
+
listEnvironmentManifests(): Promise<EnvironmentManifestRow[]>;
|
|
599
|
+
/** Every version of manifest `name`, newest first. */
|
|
600
|
+
environmentManifestVersions(name: string): Promise<EnvironmentManifestRow[]>;
|
|
601
|
+
/** Deletes every version of manifest `name`; how many there were. */
|
|
602
|
+
deleteEnvironmentManifest(name: string): Promise<number>;
|
|
603
|
+
/** How many Environments were made from each version of manifest `name` (deleting ones too). */
|
|
604
|
+
environmentsOfManifest(name: string): Promise<Map<number, number>>;
|
|
517
605
|
/** `invoking` effects of one session; takeover turns them `uncertain`. */
|
|
518
606
|
invokingEffects<T extends EffectDoc = EffectDoc>(sessionId: string): Promise<T[]>;
|
|
519
607
|
effectsForSession<T extends EffectDoc = EffectDoc>(sessionId: string, filter?: SessionEffectFilter): Promise<T[]>;
|
|
@@ -549,20 +637,20 @@ export interface Tx {
|
|
|
549
637
|
putPrincipal(id: string, tokenHash: string, createdAt: string, role?: KeyRole): Promise<PrincipalRow>;
|
|
550
638
|
/** Deletes principal `id`; false when there was none. */
|
|
551
639
|
deletePrincipal(id: string): Promise<boolean>;
|
|
552
|
-
/** Rejects on a duplicate id, or a second
|
|
640
|
+
/** Rejects on a duplicate id, or a second vault for one Environment. */
|
|
553
641
|
insertVault(row: VaultRow): Promise<void>;
|
|
554
642
|
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[]>;
|
|
643
|
+
/** The vault of Environment `environmentId` (D56). */
|
|
644
|
+
vaultOfEnvironment(environmentId: string): Promise<VaultRow | undefined>;
|
|
559
645
|
updateVaultMetadata(id: string, metadataJson: string | null): Promise<void>;
|
|
560
646
|
/** Deletes the vault and its credentials. */
|
|
561
647
|
deleteVault(id: string): Promise<void>;
|
|
562
648
|
/** Rejects on a duplicate id or an unknown vault. */
|
|
563
649
|
insertCredential(row: VaultCredentialRow): Promise<void>;
|
|
564
|
-
/** Looks a credential up by id alone
|
|
650
|
+
/** Looks a credential up by id alone; callers compare `vaultId`. */
|
|
565
651
|
getCredential(id: string): Promise<VaultCredentialRow | undefined>;
|
|
652
|
+
/** The credential named `name` in vault `vaultId` (names are unique per vault). */
|
|
653
|
+
credentialByName(vaultId: string, name: string): Promise<VaultCredentialRow | undefined>;
|
|
566
654
|
/** Credentials of one vault, ordered by `createdAt`, then id. */
|
|
567
655
|
credentialsForVault(vaultId: string, filter?: {
|
|
568
656
|
type?: VaultCredentialRow["type"];
|
|
@@ -600,6 +688,11 @@ export interface Tx {
|
|
|
600
688
|
countSigningKeys(): Promise<number>;
|
|
601
689
|
/** Appends a row, setting `duplicate` when one with the same `effectKey` exists; returns it. */
|
|
602
690
|
recordModelUsage(row: ModelUsageWrite): Promise<ModelUsageRow>;
|
|
691
|
+
/**
|
|
692
|
+
* The first row the gate recorded for the model call `effectKey` (R7.1), never a `duplicate`;
|
|
693
|
+
* undefined when no gate metered it.
|
|
694
|
+
*/
|
|
695
|
+
modelUsageOf(effectKey: string): Promise<ModelUsageRow | undefined>;
|
|
603
696
|
modelUsageTotals(query: ModelUsageQuery): Promise<ModelUsageTotals>;
|
|
604
697
|
/** Every budget, ordered by scope, then scope id. */
|
|
605
698
|
listModelBudgets(): Promise<ModelBudgetRow[]>;
|
|
@@ -608,6 +701,11 @@ export interface Tx {
|
|
|
608
701
|
toolCrossing(key: string): Promise<ToolCrossingRow | undefined>;
|
|
609
702
|
/** Inserts the running call's row; false when a row with `key` already exists. */
|
|
610
703
|
startToolCrossing(row: Pick<ToolCrossingRow, "key" | "hash" | "startedAt">): Promise<boolean>;
|
|
704
|
+
/**
|
|
705
|
+
* Starts a lost call's row again (R5.3): `startedAt` moves on, on a row with no answer and
|
|
706
|
+
* `hash`. False when the row is gone, settled, or another request's.
|
|
707
|
+
*/
|
|
708
|
+
restartToolCrossing(row: Pick<ToolCrossingRow, "key" | "hash" | "startedAt">): Promise<boolean>;
|
|
611
709
|
/** Records the call's answer. */
|
|
612
710
|
settleToolCrossing(key: string, answer: unknown, settledAt: string): Promise<void>;
|
|
613
711
|
/** Deletes rows that settled before `before`; returns how many. */
|
|
@@ -616,6 +714,10 @@ export interface Tx {
|
|
|
616
714
|
artifact(id: string, options?: {
|
|
617
715
|
lock?: boolean;
|
|
618
716
|
}): Promise<ArtifactRow | undefined>;
|
|
717
|
+
/** The folder artifact that holds Environment `environmentId`'s disk versions (R2d step 3). */
|
|
718
|
+
diskArtifact(environmentId: string, options?: {
|
|
719
|
+
lock?: boolean;
|
|
720
|
+
}): Promise<ArtifactRow | undefined>;
|
|
619
721
|
/** Artifacts by creation time, then id: those of one session when `sessionId` is given. */
|
|
620
722
|
listArtifacts(filter?: {
|
|
621
723
|
sessionId?: string;
|
|
@@ -632,6 +734,11 @@ export interface Tx {
|
|
|
632
734
|
artifactVersions(artifactId: string): Promise<ArtifactVersionRow[]>;
|
|
633
735
|
/** Deletes the artifact and its versions; returns the versions' blob keys (empty when none). */
|
|
634
736
|
deleteArtifact(id: string): Promise<string[]>;
|
|
737
|
+
/**
|
|
738
|
+
* Deletes one version of a locked artifact (its content rows go with it) and returns its blob
|
|
739
|
+
* key; the latest version becomes the newest one left. The artifact itself stays, even empty.
|
|
740
|
+
*/
|
|
741
|
+
deleteArtifactVersion(artifactId: string, version: number): Promise<string | undefined>;
|
|
635
742
|
/**
|
|
636
743
|
* Serializes the Tenant's artifact writes: held until the transaction ends. Take it before
|
|
637
744
|
* reading the total a new version must fit under.
|
|
@@ -677,11 +784,19 @@ export interface Tx {
|
|
|
677
784
|
* Tenant's record rows and log heads. The Tenant moves to the next basin
|
|
678
785
|
* generation and the current one is retired, so session ids it frees start again in an
|
|
679
786
|
* empty basin;
|
|
680
|
-
* - `
|
|
787
|
+
* - `environments`: sandbox records, Environments with their vaults, and their lifecycle
|
|
788
|
+
* streams;
|
|
681
789
|
* - `all`: both, plus definitions (and which definition files they use),
|
|
682
|
-
* user vaults with their credentials,
|
|
683
790
|
* the model usage ledger, the model budgets and Tenant-wide artifacts. The host vault, principals, signing keys,
|
|
684
791
|
* settings, audit and vault idempotency rows stay.
|
|
685
792
|
*/
|
|
686
793
|
reset(scope: ResetScope): Promise<void>;
|
|
687
794
|
}
|
|
795
|
+
/** Which of an Environment's events to read (`Tx.environmentEvents`). */
|
|
796
|
+
export interface EnvironmentEventsQuery {
|
|
797
|
+
readonly fromSeq?: number;
|
|
798
|
+
readonly limit?: number;
|
|
799
|
+
readonly types?: readonly string[];
|
|
800
|
+
readonly since?: string;
|
|
801
|
+
readonly until?: string;
|
|
802
|
+
}
|
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[]>;
|