@nylorun/runtime 0.27.0-beta → 0.29.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 +67 -0
- package/README.md +1 -1
- package/dist/api/a2a/card.d.ts +4 -3
- package/dist/api/a2a/card.js +3 -3
- package/dist/api/a2a/routes.js +18 -7
- package/dist/api/ag-ui/routes.js +4 -7
- package/dist/api/components.d.ts +5854 -2718
- package/dist/api/components.js +39 -30
- package/dist/api/http/app.js +9 -4
- package/dist/api/http/body.d.ts +2 -0
- package/dist/api/http/body.js +20 -0
- package/dist/api/http/define.d.ts +4 -0
- package/dist/api/http/define.js +20 -9
- package/dist/api/http/routes/agent-manifests.d.ts +10 -0
- package/dist/api/http/routes/agent-manifests.js +135 -0
- package/dist/api/http/routes/agents.d.ts +11 -0
- package/dist/api/http/routes/agents.js +418 -0
- package/dist/api/http/routes/artifacts.js +2 -2
- package/dist/api/http/routes/coverage.d.ts +4 -4
- package/dist/api/http/routes/coverage.js +12 -6
- package/dist/api/http/routes/files.js +1 -1
- package/dist/api/http/routes/mcp.js +2 -2
- package/dist/api/http/routes/me.d.ts +1 -1
- package/dist/api/http/routes/me.js +1 -2
- package/dist/api/http/routes/memories.d.ts +9 -0
- package/dist/api/http/routes/memories.js +152 -0
- package/dist/api/http/routes/reads.d.ts +1 -137
- package/dist/api/http/routes/reads.js +31 -12
- package/dist/api/http/routes/sessions.js +21 -50
- package/dist/api/http/routes/tenant.js +13 -10
- package/dist/api/http/routes/triggers.d.ts +10 -0
- package/dist/api/http/routes/triggers.js +183 -0
- package/dist/api/openapi.js +69 -47
- package/dist/artifacts/disk.d.ts +10 -10
- package/dist/artifacts/disk.js +27 -27
- package/dist/artifacts/quota.d.ts +1 -1
- package/dist/artifacts/quota.js +2 -2
- package/dist/artifacts/service.js +2 -2
- package/dist/core/flow-host.d.ts +0 -1
- package/dist/gates/egress-credentials.js +1 -1
- package/dist/gates/egress.d.ts +5 -5
- package/dist/gates/egress.js +6 -6
- package/dist/gates/http-tool.js +2 -2
- package/dist/gates/meter.js +22 -5
- package/dist/gates/policy.d.ts +8 -3
- package/dist/gates/policy.js +7 -2
- package/dist/gates/tenant-vaults.d.ts +1 -1
- package/dist/harness/pod.d.ts +2 -0
- package/dist/harness/setup.js +17 -6
- package/dist/harness-api/record.js +11 -0
- package/dist/harness-api/server.js +4 -0
- package/dist/harness-api/start.d.ts +11 -7
- package/dist/harness-api/start.js +49 -5
- package/dist/harness-api/workspace.js +2 -2
- package/dist/host/config-for.d.ts +2 -0
- package/dist/host/config-for.js +1 -0
- package/dist/host/http.d.ts +2 -2
- package/dist/host/http.js +5 -2
- package/dist/host/main.js +1 -0
- package/dist/keys/keys.d.ts +15 -4
- package/dist/keys/keys.js +16 -0
- package/dist/keys/webhooks.d.ts +25 -0
- package/dist/keys/webhooks.js +62 -0
- package/dist/management-openapi.json +313 -133
- package/dist/mcp/connect.d.ts +2 -2
- package/dist/mcp/connect.js +3 -3
- package/dist/mcp/preview.js +7 -7
- package/dist/memory/service.d.ts +97 -0
- package/dist/memory/service.js +335 -0
- package/dist/memory/tool.d.ts +36 -0
- package/dist/memory/tool.js +84 -0
- package/dist/model/pi-model.js +7 -0
- package/dist/openapi.json +13120 -9034
- package/dist/reads/types.d.ts +3 -3
- package/dist/record/agent.d.ts +27 -0
- package/dist/record/agent.js +46 -0
- package/dist/record/index.d.ts +1 -1
- package/dist/record/index.js +1 -1
- package/dist/sandbox/join.js +5 -5
- package/dist/sandbox/placement.d.ts +1 -1
- package/dist/sandbox/placement.js +3 -3
- package/dist/sandbox/pods/lifecycle.d.ts +6 -6
- package/dist/sandbox/pods/lifecycle.js +6 -6
- package/dist/sandbox/pods/reconcile.js +10 -2
- package/dist/sandbox/resolve.d.ts +3 -3
- package/dist/sandbox/resolve.js +7 -7
- package/dist/sandbox/setup.d.ts +3 -1
- package/dist/sandbox/setup.js +14 -4
- package/dist/store/postgres/drizzle/0032_agents.sql +54 -0
- package/dist/store/postgres/drizzle/0033_agent_versions.sql +7 -0
- package/dist/store/postgres/drizzle/0034_protocol_17_session_queue.sql +13 -0
- package/dist/store/postgres/drizzle/0035_t4_triggers.sql +41 -0
- package/dist/store/postgres/drizzle/0036_t5_memories.sql +30 -0
- package/dist/store/postgres/drizzle/0037_model_usage_cost_split.sql +4 -0
- package/dist/store/postgres/drizzle/meta/_journal.json +42 -0
- package/dist/store/postgres/reads.js +44 -87
- package/dist/store/postgres/record-writer.d.ts +4 -4
- package/dist/store/postgres/record-writer.js +9 -9
- package/dist/store/postgres/schema.d.ts +1408 -123
- package/dist/store/postgres/schema.js +194 -38
- package/dist/store/postgres/store.js +329 -79
- package/dist/store/postgres/tenant.js +1 -2
- package/dist/store/types.d.ts +155 -50
- package/dist/store/types.js +0 -1
- package/dist/tenant/advance.js +20 -8
- package/dist/tenant/agent-manifests.d.ts +72 -0
- package/dist/tenant/agent-manifests.js +359 -0
- package/dist/tenant/agent-versions.d.ts +126 -0
- package/dist/tenant/agent-versions.js +389 -0
- package/dist/tenant/agents.d.ts +230 -0
- package/dist/tenant/{environments.js → agents.js} +464 -320
- package/dist/tenant/auth.d.ts +1 -1
- package/dist/tenant/auth.js +3 -3
- package/dist/tenant/commands.d.ts +63 -2
- package/dist/tenant/commands.js +240 -83
- package/dist/tenant/context.d.ts +46 -19
- package/dist/tenant/context.js +6 -2
- package/dist/tenant/effects.js +7 -16
- package/dist/tenant/identity-file.d.ts +6 -6
- package/dist/tenant/identity-file.js +12 -10
- package/dist/tenant/issuers.js +3 -3
- package/dist/tenant/limits.d.ts +0 -3
- package/dist/tenant/limits.js +0 -3
- package/dist/tenant/memories.d.ts +38 -0
- package/dist/tenant/memories.js +119 -0
- package/dist/tenant/reset.js +2 -2
- package/dist/tenant/run-grants.d.ts +6 -0
- package/dist/tenant/run-grants.js +4 -0
- package/dist/tenant/runtime.d.ts +1 -1
- package/dist/tenant/runtime.js +8 -0
- package/dist/tenant/sessions.d.ts +28 -45
- package/dist/tenant/sessions.js +85 -208
- package/dist/tenant/status.js +6 -7
- package/dist/tenant/sweep.js +12 -3
- package/dist/tenant/transcript.d.ts +16 -16
- package/dist/tenant/triggers.d.ts +143 -0
- package/dist/tenant/triggers.js +715 -0
- package/dist/tenant/turn-timing.d.ts +11 -1
- package/dist/tenant/turn-timing.js +3 -1
- package/dist/tenant/types.d.ts +5 -0
- package/dist/tenant/worker.d.ts +2 -0
- package/dist/tenant/worker.js +5 -0
- package/dist/traces/map.d.ts +1 -1
- package/dist/traces/map.js +7 -1
- package/dist/tuning.d.ts +7 -0
- package/dist/tuning.js +19 -0
- package/dist/vault/service.d.ts +13 -8
- package/dist/vault/service.js +61 -17
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -12
- package/dist/api/http/routes/environment-manifests.d.ts +0 -9
- package/dist/api/http/routes/environment-manifests.js +0 -118
- package/dist/api/http/routes/environments.d.ts +0 -11
- package/dist/api/http/routes/environments.js +0 -332
- package/dist/record/environment.d.ts +0 -27
- package/dist/record/environment.js +0 -46
- package/dist/tenant/environment-manifests.d.ts +0 -57
- package/dist/tenant/environment-manifests.js +0 -208
- package/dist/tenant/environments.d.ts +0 -172
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment manifests (protocol 14, D63): `/v1/environment-manifests/{name}`, named and
|
|
3
|
-
* versioned definitions of a kind of Environment, saved like agents.
|
|
4
|
-
*
|
|
5
|
-
* - **Versions.** A save whose manifest hashes the same as the latest answers it unchanged;
|
|
6
|
-
* any other writes the next version. A version is never changed or deleted alone.
|
|
7
|
-
* - **No Environment changes.** Saving a version reaches no Environment: an Environment is made
|
|
8
|
-
* from one version and keeps it for life (`putEnvironment`). The plan counts those behind.
|
|
9
|
-
* - **Plan and drift.** `?dryRun=true` answers what a save would do and saves nothing: the
|
|
10
|
-
* changes from the latest, every reason the Runtime would refuse it (the Tenant's limits,
|
|
11
|
-
* missing artifacts), warnings, and how many Environments stay on older versions.
|
|
12
|
-
* `If-Match: <version>` refuses (`412 manifest_changed`) a save whose latest version moved
|
|
13
|
-
* since the client read it; `0` asks for a manifest that does not exist yet.
|
|
14
|
-
* - **Every client is equal** (Q12): a version records who saved it (`savedBy`), and nothing is
|
|
15
|
-
* read-only by where it was saved from.
|
|
16
|
-
*/
|
|
17
|
-
import {} from "@nylorun/core/contracts";
|
|
18
|
-
import { hashManifest } from "@nylorun/core/compatibility";
|
|
19
|
-
import { canonical } from "../store/canonical.js";
|
|
20
|
-
import { resolveRecipe } from "../sandbox/resolve.js";
|
|
21
|
-
import { limitIssues, manifestShapeIssues, readTenantLimits } from "./limits.js";
|
|
22
|
-
import { readRuntimeLimits } from "./runtime-limits.js";
|
|
23
|
-
import { effectiveSandboxConfig, readSandboxConfig } from "../sandbox/tenant-config.js";
|
|
24
|
-
import { actorOf, fileErrors } from "./environments.js";
|
|
25
|
-
import { fail } from "./http.js";
|
|
26
|
-
/** What an environment manifest asks of an Environment's recipe. */
|
|
27
|
-
export function manifestRecipeRequest(manifest) {
|
|
28
|
-
return {
|
|
29
|
-
...(manifest.image === undefined ? {} : { image: manifest.image }),
|
|
30
|
-
...(manifest.resources === undefined ? {} : { resources: manifest.resources }),
|
|
31
|
-
...(manifest.storage === undefined ? {} : { storage: manifest.storage }),
|
|
32
|
-
...(manifest.network === undefined ? {} : { network: manifest.network }),
|
|
33
|
-
...(manifest.harness === undefined ? {} : { harness: manifest.harness }),
|
|
34
|
-
...(manifest.lifecycle === undefined ? {} : { lifecycle: manifest.lifecycle }),
|
|
35
|
-
...(manifest.setup === undefined ? {} : { setup: manifest.setup }),
|
|
36
|
-
...(manifest.files === undefined ? {} : { files: manifest.files }),
|
|
37
|
-
...(manifest.limits === undefined ? {} : { limits: manifest.limits }),
|
|
38
|
-
...(manifest.secrets === undefined ? {} : { secrets: manifest.secrets }),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/** The hash a manifest's version records: equal manifests hash the same. */
|
|
42
|
-
export function environmentManifestHash(manifest) {
|
|
43
|
-
return hashManifest(manifest);
|
|
44
|
-
}
|
|
45
|
-
const notFound = (name, version) => fail(404, version === undefined ? `No environment manifest is named ${name}.` : `Environment manifest ${name} has no version ${version}.`, {
|
|
46
|
-
code: "manifest_not_found",
|
|
47
|
-
});
|
|
48
|
-
function viewOf(row, counts) {
|
|
49
|
-
return {
|
|
50
|
-
name: row.name,
|
|
51
|
-
version: row.version,
|
|
52
|
-
hash: row.hash,
|
|
53
|
-
manifest: row.body,
|
|
54
|
-
savedBy: row.savedBy,
|
|
55
|
-
createdAt: row.createdAt,
|
|
56
|
-
environments: counts.get(row.version) ?? 0,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/** Each field that differs between `before` and `after`, by path; arrays compare whole. */
|
|
60
|
-
export function manifestChanges(before, after, path = "") {
|
|
61
|
-
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
62
|
-
if (object(before) && object(after)) {
|
|
63
|
-
const keys = [...new Set([...Object.keys(before), ...Object.keys(after)])].sort();
|
|
64
|
-
return keys.flatMap((key) => manifestChanges(before[key], after[key], path ? `${path}.${key}` : key));
|
|
65
|
-
}
|
|
66
|
-
if (canonical(before) === canonical(after))
|
|
67
|
-
return [];
|
|
68
|
-
return [
|
|
69
|
-
{
|
|
70
|
-
path,
|
|
71
|
-
...(before === undefined ? {} : { from: before }),
|
|
72
|
-
...(after === undefined ? {} : { to: after }),
|
|
73
|
-
},
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
/** What a save of `manifest` should tell its saver, though it would be saved. */
|
|
77
|
-
function warningsOf(ctx, manifest) {
|
|
78
|
-
const warnings = [];
|
|
79
|
-
if (manifest.image !== undefined && !manifest.image.includes("@sha256:"))
|
|
80
|
-
warnings.push({
|
|
81
|
-
code: "image_tag",
|
|
82
|
-
message: `image ${manifest.image} is a tag, not a digest: each Environment pins what its first pod pulls, so two Tenants may run different bytes.`,
|
|
83
|
-
});
|
|
84
|
-
if (manifest.kind === "pod" && !ctx.pods)
|
|
85
|
-
warnings.push({
|
|
86
|
-
code: "pods_unavailable",
|
|
87
|
-
message: "kind pod needs sandbox pods, which this Tenant does not have: an Environment made from it is refused until `nylorun local sandbox enable`.",
|
|
88
|
-
});
|
|
89
|
-
return warnings;
|
|
90
|
-
}
|
|
91
|
-
/** Every reason the Runtime would refuse `manifest` now: the Tenant's limits and its files. */
|
|
92
|
-
async function errorsOf(t, manifest) {
|
|
93
|
-
const config = effectiveSandboxConfig(await readSandboxConfig(t));
|
|
94
|
-
const resolved = resolveRecipe(manifest.kind ?? "virtual", manifestRecipeRequest(manifest), config);
|
|
95
|
-
return [
|
|
96
|
-
...(resolved.kind === "error" ? resolved.errors : []),
|
|
97
|
-
...limitIssues(manifest.limits, await readTenantLimits(t)),
|
|
98
|
-
...manifestShapeIssues(manifest, await readRuntimeLimits(t)),
|
|
99
|
-
...(await fileErrors(t, manifest.files)),
|
|
100
|
-
];
|
|
101
|
-
}
|
|
102
|
-
export async function saveEnvironmentManifest(ctx, name, body, scope, options = {}) {
|
|
103
|
-
const { requestId: _, ...manifest } = body;
|
|
104
|
-
if (manifest.name !== name)
|
|
105
|
-
fail(400, `The manifest is named ${manifest.name}, and the path names ${name}: they must match.`);
|
|
106
|
-
const hash = environmentManifestHash(manifest);
|
|
107
|
-
const warnings = warningsOf(ctx, manifest);
|
|
108
|
-
return ctx.store.tx(async (t) => {
|
|
109
|
-
await t.lockEnvironmentManifest(name);
|
|
110
|
-
const latest = await t.environmentManifest(name);
|
|
111
|
-
if (options.ifMatch !== undefined && (latest?.version ?? 0) !== options.ifMatch)
|
|
112
|
-
fail(412, latest === undefined
|
|
113
|
-
? `Environment manifest ${name} does not exist, and If-Match named version ${options.ifMatch}.`
|
|
114
|
-
: `Environment manifest ${name} is at version ${latest.version}, not ${options.ifMatch}: someone saved it since you read it. Read it again, or save without If-Match to replace it.`, { code: "manifest_changed", details: { latest: latest?.version ?? 0 } });
|
|
115
|
-
const unchanged = latest?.hash === hash;
|
|
116
|
-
const to = unchanged ? latest.version : (latest?.version ?? 0) + 1;
|
|
117
|
-
const counts = await t.environmentsOfManifest(name);
|
|
118
|
-
const errors = await errorsOf(t, manifest);
|
|
119
|
-
if (options.dryRun) {
|
|
120
|
-
let behind = 0;
|
|
121
|
-
for (const [version, n] of counts)
|
|
122
|
-
if (version < to)
|
|
123
|
-
behind += n;
|
|
124
|
-
return {
|
|
125
|
-
name,
|
|
126
|
-
from: latest?.version ?? null,
|
|
127
|
-
to,
|
|
128
|
-
unchanged,
|
|
129
|
-
changes: unchanged ? [] : manifestChanges(latest?.body ?? {}, manifest),
|
|
130
|
-
warnings,
|
|
131
|
-
errors,
|
|
132
|
-
behind,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
if (errors.length > 0)
|
|
136
|
-
fail(400, errors.join(" "));
|
|
137
|
-
if (unchanged)
|
|
138
|
-
return { manifest: viewOf(latest, counts), unchanged: true, warnings };
|
|
139
|
-
const row = {
|
|
140
|
-
name,
|
|
141
|
-
version: to,
|
|
142
|
-
body: manifest,
|
|
143
|
-
hash,
|
|
144
|
-
savedBy: { actor: actorOf(scope) },
|
|
145
|
-
createdAt: new Date().toISOString(),
|
|
146
|
-
};
|
|
147
|
-
await t.insertEnvironmentManifest(row);
|
|
148
|
-
// Its files by hash (Q6), recorded as a definition's are, for the sweep that deletes unused ones.
|
|
149
|
-
const shas = [...new Set((manifest.files ?? []).flatMap((file) => ("files" in file ? Object.values(file.files) : [])))];
|
|
150
|
-
if (shas.length > 0)
|
|
151
|
-
await t.insertDefinitionFileUses(`environment-manifest:${name}`, hash, shas);
|
|
152
|
-
return { manifest: viewOf(row, counts), unchanged: false, warnings };
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
/** `GET /v1/environment-manifests/{name}` (the latest) and `.../versions/{n}`. */
|
|
156
|
-
export async function getEnvironmentManifest(ctx, name, version) {
|
|
157
|
-
return ctx.store.tx(async (t) => {
|
|
158
|
-
const row = (await t.environmentManifest(name, version)) ?? notFound(name, version);
|
|
159
|
-
return viewOf(row, await t.environmentsOfManifest(name));
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
/** `GET /v1/environment-manifests`: each manifest's latest version. */
|
|
163
|
-
export async function listEnvironmentManifests(ctx) {
|
|
164
|
-
return ctx.store.tx(async (t) => {
|
|
165
|
-
const manifests = [];
|
|
166
|
-
for (const row of await t.listEnvironmentManifests())
|
|
167
|
-
manifests.push(viewOf(row, await t.environmentsOfManifest(row.name)));
|
|
168
|
-
return { manifests };
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/** `GET /v1/environment-manifests/{name}/versions`: every version, newest first. */
|
|
172
|
-
export async function environmentManifestVersions(ctx, name) {
|
|
173
|
-
return ctx.store.tx(async (t) => {
|
|
174
|
-
const rows = await t.environmentManifestVersions(name);
|
|
175
|
-
if (rows.length === 0)
|
|
176
|
-
notFound(name);
|
|
177
|
-
const counts = await t.environmentsOfManifest(name);
|
|
178
|
-
return {
|
|
179
|
-
name,
|
|
180
|
-
latest: rows[0].version,
|
|
181
|
-
versions: rows.map((row) => ({
|
|
182
|
-
version: row.version,
|
|
183
|
-
hash: row.hash,
|
|
184
|
-
savedBy: row.savedBy,
|
|
185
|
-
createdAt: row.createdAt,
|
|
186
|
-
environments: counts.get(row.version) ?? 0,
|
|
187
|
-
})),
|
|
188
|
-
};
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* `DELETE /v1/environment-manifests/{name}`: deletes every version, refused while any Environment
|
|
193
|
-
* was made from one (`409 manifest_in_use`): the Environment names the version it runs.
|
|
194
|
-
*/
|
|
195
|
-
export async function deleteEnvironmentManifest(ctx, name) {
|
|
196
|
-
return ctx.store.tx(async (t) => {
|
|
197
|
-
await t.lockEnvironmentManifest(name);
|
|
198
|
-
let made = 0;
|
|
199
|
-
for (const n of (await t.environmentsOfManifest(name)).values())
|
|
200
|
-
made += n;
|
|
201
|
-
if (made > 0)
|
|
202
|
-
fail(409, `${made} Environment(s) were made from environment manifest ${name}: delete them first, or keep the manifest.`, {
|
|
203
|
-
code: "manifest_in_use",
|
|
204
|
-
details: { environments: made },
|
|
205
|
-
});
|
|
206
|
-
return { name, deleted: (await t.deleteEnvironmentManifest(name)) > 0 };
|
|
207
|
-
});
|
|
208
|
-
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { type EnvironmentRecipe, type EnvironmentView, type ForkEnvironmentRequest, type ForkEnvironmentResponse, type PutEnvironmentRequest, type PutEnvironmentSecretRequest } from "@nylorun/core/contracts";
|
|
2
|
-
import type { Environment, EnvironmentEventsQuery, Tx } from "../store/types.js";
|
|
3
|
-
import type { SandboxRouteDeps } from "../core/sandbox-routes.js";
|
|
4
|
-
import { type AuthScope, type Session, type TenantContext } from "./context.js";
|
|
5
|
-
import type { SealedSecretCopies } from "../vault/service.js";
|
|
6
|
-
/** The Environment grants that limit `scope`, or undefined when it reaches every Environment. */
|
|
7
|
-
export declare function environmentGrantsOf(scope: AuthScope): readonly string[] | undefined;
|
|
8
|
-
/** Who the vault's audit rows name for a request: the subject, else the application. */
|
|
9
|
-
export declare function actorOf(scope: AuthScope): string;
|
|
10
|
-
/** Refuses (the 404 of a missing one) Environment `id` when the caller's grants miss it. */
|
|
11
|
-
export declare function assertReaches(scope: AuthScope, id: string): void;
|
|
12
|
-
/** An Environment, unless it is gone or being deleted. */
|
|
13
|
-
export declare function liveEnvironment(t: Tx, id: string, options?: {
|
|
14
|
-
lock?: boolean;
|
|
15
|
-
}): Promise<Environment | undefined>;
|
|
16
|
-
/**
|
|
17
|
-
* Why input files cannot be used: each that is not a version of a Tenant-wide artifact (a
|
|
18
|
-
* session's artifacts go with the session). Pins nothing else: the version is the one named.
|
|
19
|
-
*/
|
|
20
|
-
export declare function fileErrors(t: Tx, files: EnvironmentRecipe["files"]): Promise<string[]>;
|
|
21
|
-
/**
|
|
22
|
-
* `PUT /v1/environments/{id}`: creates the Environment and its vault (within the Tenant's limit
|
|
23
|
-
* on their number) from an environment manifest's version or from the inline fields, or finds
|
|
24
|
-
* the one with this id, so "get or create" is one call. An existing one never changes what it
|
|
25
|
-
* runs (D63): its labels and owner guard may change, fields that match are accepted, and any
|
|
26
|
-
* other difference is `409 environment_immutable`. Every `PUT` counts as the Environment's use.
|
|
27
|
-
*/
|
|
28
|
-
export declare function putEnvironment(ctx: TenantContext, id: string, body: PutEnvironmentRequest, scope: AuthScope, options?: {
|
|
29
|
-
fork?: Fork;
|
|
30
|
-
}): Promise<EnvironmentView>;
|
|
31
|
-
/**
|
|
32
|
-
* The secret write `raw` asks of Environment `id` (D64). When what it runs declares secret
|
|
33
|
-
* slots, the name must be one (`409 secret_not_in_manifest`), and the body is `{ value }` (or
|
|
34
|
-
* `{ headers }` for a `headers` slot) with the binding from the slot; a full typed body is
|
|
35
|
-
* accepted only when its binding is the slot's. Without slots, today's typed body.
|
|
36
|
-
*/
|
|
37
|
-
export declare function secretRequestFor(ctx: TenantContext, id: string, name: string, raw: unknown): Promise<PutEnvironmentSecretRequest>;
|
|
38
|
-
/** What a create does for a fork (`POST .../fork`); `copied` is filled in by the create. */
|
|
39
|
-
interface Fork {
|
|
40
|
-
source: string;
|
|
41
|
-
setup: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* The source's secrets sealed by keys for the new vault `vaultId` (F4.2), before the create's
|
|
44
|
-
* transaction, which inserts them; absent with `secrets: none`.
|
|
45
|
-
*/
|
|
46
|
-
sealed?: {
|
|
47
|
-
vaultId: string;
|
|
48
|
-
copies: SealedSecretCopies;
|
|
49
|
-
};
|
|
50
|
-
copied?: {
|
|
51
|
-
copied: string[];
|
|
52
|
-
dropped: string[];
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* `POST /v1/environments/{id}/fork` (Q15): how an Environment gets a new manifest version. A new
|
|
57
|
-
* Environment `body.id` is made from the manifest version (default the source's manifest at its
|
|
58
|
-
* latest), its disk started from a version of the source's (`latest` takes a snapshot first,
|
|
59
|
-
* refused during a turn), and its secrets copied inside the Runtime. A fork onto other setup
|
|
60
|
-
* runs that setup on the copied disk before its first turn (Q17). The source keeps what it runs,
|
|
61
|
-
* its disk and its sessions. With `dryRun`, the plan only.
|
|
62
|
-
*/
|
|
63
|
-
export declare function forkEnvironment(ctx: TenantContext, sourceId: string, body: ForkEnvironmentRequest, scope: AuthScope): Promise<ForkEnvironmentResponse>;
|
|
64
|
-
/** `GET /v1/environments/{id}`. */
|
|
65
|
-
export declare function getEnvironment(ctx: TenantContext, id: string, scope: AuthScope): Promise<EnvironmentView>;
|
|
66
|
-
/** `GET /v1/environments?label=k=v`: every Environment with all the labels, that the caller reaches. */
|
|
67
|
-
export declare function listEnvironments(ctx: TenantContext, labels: Record<string, string>, scope: AuthScope): Promise<{
|
|
68
|
-
environments: EnvironmentView[];
|
|
69
|
-
}>;
|
|
70
|
-
/**
|
|
71
|
-
* Asks pod Environment `id` to run when it is stopped or failed (a disk copy needs its engine),
|
|
72
|
-
* with its recipe applied, as a turn start would.
|
|
73
|
-
*/
|
|
74
|
-
export declare function wakePod(ctx: TenantContext, id: string): Promise<void>;
|
|
75
|
-
/** Whether a disk lease (R2d step 3) holds `environment` now. */
|
|
76
|
-
export declare function diskHeld(environment: Environment, now?: number): boolean;
|
|
77
|
-
/** Refused while a snapshot or restore copies the disk (a pending seed does not count). */
|
|
78
|
-
export declare function refuseDiskCopy(environment: Environment): void;
|
|
79
|
-
/**
|
|
80
|
-
* `DELETE /v1/environments/{id}`: deletes the Environment, its vault and its workspace. Refused
|
|
81
|
-
* while a session that names it has an active turn. Sessions keep its id: their next turn is
|
|
82
|
-
* refused (`environment_unavailable`) unless an Environment with this id exists again.
|
|
83
|
-
*/
|
|
84
|
-
export declare function deleteEnvironment(ctx: TenantContext, id: string, scope: AuthScope): Promise<{
|
|
85
|
-
id: string;
|
|
86
|
-
deleted: boolean;
|
|
87
|
-
}>;
|
|
88
|
-
/**
|
|
89
|
-
* Deletes every Environment unused for its `lifecycle.deleteAfter` (Q13): no turn, recipe
|
|
90
|
-
* change, secret write, stop or reset since. One with a turn running waits for the next sweep.
|
|
91
|
-
* Run by the Tenant sweep.
|
|
92
|
-
*/
|
|
93
|
-
export declare function sweepUnusedEnvironments(ctx: TenantContext, now?: number): Promise<void>;
|
|
94
|
-
/**
|
|
95
|
-
* `POST /v1/environments/{id}/stop`: suspends a pod Environment. Its volume is kept, and the next
|
|
96
|
-
* turn of a session that names it starts it again. Refused during a turn.
|
|
97
|
-
*/
|
|
98
|
-
export declare function stopEnvironment(ctx: TenantContext, id: string, scope: AuthScope): Promise<EnvironmentView>;
|
|
99
|
-
/**
|
|
100
|
-
* `POST /v1/environments/{id}/reset`: a new pod on a new, empty volume (the next volume
|
|
101
|
-
* generation), with a new join token and the recipe applied; the old Sandbox and volume are
|
|
102
|
-
* deleted. Leaves `lost` and `failed`. Refused during a turn, and while an earlier reset's
|
|
103
|
-
* Sandbox is still being deleted.
|
|
104
|
-
*/
|
|
105
|
-
export declare function resetEnvironment(ctx: TenantContext, id: string, scope: AuthScope): Promise<EnvironmentView>;
|
|
106
|
-
/**
|
|
107
|
-
* Gives pod Environment `environment` (locked) a new pod on a new, empty volume, the next volume
|
|
108
|
-
* generation, with its recipe applied: the old Sandbox and volume are retired. With `seed`, the
|
|
109
|
-
* new volume starts from that disk version before any turn (R2d step 3): a restore, or the
|
|
110
|
-
* recovery of a lost volume.
|
|
111
|
-
*/
|
|
112
|
-
export declare function newVolume(ctx: TenantContext, t: Tx, environment: Environment, options?: {
|
|
113
|
-
seed?: {
|
|
114
|
-
artifactId: string;
|
|
115
|
-
version: number;
|
|
116
|
-
};
|
|
117
|
-
reason?: "restore" | "lost";
|
|
118
|
-
}): Promise<number>;
|
|
119
|
-
/** `GET /v1/environments/{id}/events`: the Environment's lifecycle stream. */
|
|
120
|
-
export declare function environmentEventsOf(ctx: TenantContext, id: string, scope: AuthScope, query?: EnvironmentEventsQuery): Promise<{
|
|
121
|
-
events: {
|
|
122
|
-
schema: "nylorun.environment-event/1";
|
|
123
|
-
eventId: string;
|
|
124
|
-
tenantId: string;
|
|
125
|
-
environmentId: string;
|
|
126
|
-
seq: number;
|
|
127
|
-
time: string;
|
|
128
|
-
type: "environment.attached" | "environment.created" | "environment.deleted" | "environment.detached" | "environment.egress" | "environment.failed" | "environment.forked" | "environment.lost" | "environment.relaunched" | "environment.reset" | "environment.running" | "environment.suspended";
|
|
129
|
-
payload: Record<string, unknown>;
|
|
130
|
-
}[];
|
|
131
|
-
}>;
|
|
132
|
-
/**
|
|
133
|
-
* Opens a new session on Environment `id` (`PutSessionRequest.environment`): it must exist, be
|
|
134
|
-
* reachable with `grants` and pass its owner guard. Runs in the session's transaction, after
|
|
135
|
-
* its session row lock; holds the Environment's row lock.
|
|
136
|
-
*/
|
|
137
|
-
export declare function openEnvironment(t: Tx, id: string, options: {
|
|
138
|
-
grants?: readonly string[];
|
|
139
|
-
ownerUserId: string;
|
|
140
|
-
opaque: boolean;
|
|
141
|
-
}): Promise<Environment>;
|
|
142
|
-
/** Records the attachment on the session's log and on the Environment's stream. */
|
|
143
|
-
export declare function recordAttachment(t: Tx, sessionId: string, environmentId: string): Promise<void>;
|
|
144
|
-
/**
|
|
145
|
-
* Checks a turn start on a session that names an Environment, in the command's transaction
|
|
146
|
-
* after the session row lock: the Environment still exists, a token caller's grants reach it,
|
|
147
|
-
* its owner guard admits the session's owner, and no disk copy holds it. Other sessions' turns
|
|
148
|
-
* do not stop it (D66). Holds the Environment row's lock until the transaction ends, so a turn
|
|
149
|
-
* start and disk work on one Environment are decided one after the other.
|
|
150
|
-
*
|
|
151
|
-
* A pod Environment must also be usable: not lost (`environment_lost`), on a Runtime with
|
|
152
|
-
* sandbox pods (`environment_unavailable`). A stopped or failed pod is asked to run again, with
|
|
153
|
-
* its recipe applied, after the commit.
|
|
154
|
-
*/
|
|
155
|
-
export declare function checkEnvironmentTurn(t: Tx, session: Session, scope: AuthScope, ctx?: TenantContext): Promise<void>;
|
|
156
|
-
/** A sessions reset detaches every session from its Environment: each one's stream says so. */
|
|
157
|
-
export declare function detachAllSessions(t: Tx): Promise<void>;
|
|
158
|
-
/**
|
|
159
|
-
* Marks the end of a turn's segment on Environment `id`: it was used now (`deleteAfter` counts
|
|
160
|
-
* from here), and for a running pod idle counts from now and the idle timer is armed (D34).
|
|
161
|
-
* Best effort.
|
|
162
|
-
*/
|
|
163
|
-
export declare function touchEnvironment(ctx: TenantContext, id: string): Promise<void>;
|
|
164
|
-
/**
|
|
165
|
-
* Re-arms the idle timer of every running pod after the Tenant's settings change, so a shorter
|
|
166
|
-
* `limits.idle` applies to pods already idle (D36: the settings are read whenever a timer is
|
|
167
|
-
* set). Best effort.
|
|
168
|
-
*/
|
|
169
|
-
export declare function rearmPodTimers(ctx: TenantContext): Promise<void>;
|
|
170
|
-
/** Session lookups for the sandbox route handlers (`core/sandbox-routes.ts`). */
|
|
171
|
-
export declare function sandboxRouteDeps(ctx: TenantContext): SandboxRouteDeps;
|
|
172
|
-
export {};
|