@nylorun/agents 0.22.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 +129 -0
- package/README.md +148 -114
- package/dist/a2a/handler.d.ts +9 -4
- package/dist/a2a/handler.js +9 -0
- package/dist/ag-ui/handler.d.ts +13 -9
- package/dist/ag-ui/handler.js +8 -5
- package/dist/agent-manifests.d.ts +127 -0
- package/dist/agent-manifests.js +208 -0
- package/dist/agents.d.ts +456 -0
- package/dist/agents.js +331 -0
- package/dist/compose.d.ts +23 -0
- package/dist/compose.js +246 -0
- package/dist/files.d.ts +3 -3
- package/dist/files.js +3 -3
- package/dist/index.d.ts +8 -6
- package/dist/index.js +5 -4
- package/dist/plugins/load.d.ts +10 -0
- package/dist/plugins/load.js +25 -14
- package/dist/plugins/plugin.d.ts +1 -1
- package/dist/plugins/plugin.js +1 -1
- package/dist/reads.d.ts +3 -1
- package/dist/session-client.d.ts +78 -48
- package/dist/session-client.js +22 -72
- package/dist/skills/index.d.ts +1 -2
- package/dist/skills/index.js +1 -2
- package/dist/skills/load.d.ts +13 -2
- package/dist/skills/load.js +59 -19
- package/dist/skills/skills.d.ts +2 -2
- package/dist/skills/skills.js +2 -2
- package/package.json +5 -5
- package/dist/environments.d.ts +0 -387
- package/dist/environments.js +0 -299
package/dist/skills/load.d.ts
CHANGED
|
@@ -24,8 +24,9 @@ export declare function resolveSkillsRoot(directory: string): string;
|
|
|
24
24
|
/**
|
|
25
25
|
* Load Agent Skills (agentskills.io) from a catalog directory.
|
|
26
26
|
* Each immediate subdirectory with a valid SKILL.md becomes one skill, with every file of its
|
|
27
|
-
* folder (text or binary) hashed. Throws `SkillsError` for a
|
|
28
|
-
*
|
|
27
|
+
* folder (text or binary) hashed. Throws `SkillsError` for a path a manifest cannot name. How
|
|
28
|
+
* much a skill may hold is the Tenant's limit (`/v1/tenant/skills`, default 2 GiB), which the
|
|
29
|
+
* Runtime checks when the files are uploaded and the agent is saved.
|
|
29
30
|
*/
|
|
30
31
|
export declare function loadSkillsFromDirectory(directory: string, diagnostics: SkillDiagnostic[], options?: {
|
|
31
32
|
readonly boundary?: string;
|
|
@@ -36,3 +37,13 @@ export declare function parseSkill(text: string, directoryName: string): {
|
|
|
36
37
|
description: string;
|
|
37
38
|
instructions: string;
|
|
38
39
|
} | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Every file of `directory` (a runtime section's `files` entry with `from`), hashed as a skill's
|
|
42
|
+
* folder is: each by its `/`-separated path, with where to read its bytes. Version control, OS
|
|
43
|
+
* and `.env` files are left out; a symbolic link outside `boundary` (default the folder) is
|
|
44
|
+
* skipped with a diagnostic.
|
|
45
|
+
*/
|
|
46
|
+
export declare function hashFolder(directory: string, diagnostics: SkillDiagnostic[], options?: {
|
|
47
|
+
readonly boundary?: string;
|
|
48
|
+
readonly codePrefix?: string;
|
|
49
|
+
}): Pick<LoadedSkill, "files" | "sources">;
|
package/dist/skills/load.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { existsSync, readdirSync, readFileSync, realpathSync, statSync, } from "node:fs";
|
|
3
|
-
import {
|
|
2
|
+
import { closeSync, existsSync, openSync, readdirSync, readFileSync, readSync, realpathSync, statSync, } from "node:fs";
|
|
3
|
+
import { open } from "node:fs/promises";
|
|
4
4
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { SKILL_ENTRY, skillFilePathIssue, } from "@nylorun/core/define";
|
|
6
6
|
import matter from "gray-matter";
|
|
7
7
|
const SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
8
8
|
/** Version control and operating system files, never part of a skill. */
|
|
@@ -33,8 +33,9 @@ export function resolveSkillsRoot(directory) {
|
|
|
33
33
|
/**
|
|
34
34
|
* Load Agent Skills (agentskills.io) from a catalog directory.
|
|
35
35
|
* Each immediate subdirectory with a valid SKILL.md becomes one skill, with every file of its
|
|
36
|
-
* folder (text or binary) hashed. Throws `SkillsError` for a
|
|
37
|
-
*
|
|
36
|
+
* folder (text or binary) hashed. Throws `SkillsError` for a path a manifest cannot name. How
|
|
37
|
+
* much a skill may hold is the Tenant's limit (`/v1/tenant/skills`, default 2 GiB), which the
|
|
38
|
+
* Runtime checks when the files are uploaded and the agent is saved.
|
|
38
39
|
*/
|
|
39
40
|
export function loadSkillsFromDirectory(directory, diagnostics, options = {}) {
|
|
40
41
|
const root = resolveSkillsRoot(directory);
|
|
@@ -92,7 +93,7 @@ export function loadSkillsFromDirectory(directory, diagnostics, options = {}) {
|
|
|
92
93
|
skills[parsed.name] = {
|
|
93
94
|
name: parsed.name,
|
|
94
95
|
description: parsed.description,
|
|
95
|
-
...readFiles(parsed.name
|
|
96
|
+
...readFiles(`skill '${parsed.name}'`, boundary, directoryReal, diagnostics, prefix),
|
|
96
97
|
};
|
|
97
98
|
}
|
|
98
99
|
return skills;
|
|
@@ -120,8 +121,18 @@ export function parseSkill(text, directoryName) {
|
|
|
120
121
|
function asTrimmedString(value) {
|
|
121
122
|
return typeof value === "string" ? value.trim() : "";
|
|
122
123
|
}
|
|
123
|
-
/**
|
|
124
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Every file of `directory` (a runtime section's `files` entry with `from`), hashed as a skill's
|
|
126
|
+
* folder is: each by its `/`-separated path, with where to read its bytes. Version control, OS
|
|
127
|
+
* and `.env` files are left out; a symbolic link outside `boundary` (default the folder) is
|
|
128
|
+
* skipped with a diagnostic.
|
|
129
|
+
*/
|
|
130
|
+
export function hashFolder(directory, diagnostics, options = {}) {
|
|
131
|
+
const root = resolveSkillsRoot(directory);
|
|
132
|
+
return readFiles(`folder ${directory}`, options.boundary ?? root, root, diagnostics, options.codePrefix ?? "files");
|
|
133
|
+
}
|
|
134
|
+
/** Every file of the folder, hashed, and where to read each one's bytes. */
|
|
135
|
+
function readFiles(label, boundary, directory, diagnostics, prefix) {
|
|
125
136
|
const files = {};
|
|
126
137
|
const sources = {};
|
|
127
138
|
const visited = new Set();
|
|
@@ -137,7 +148,7 @@ function readFiles(name, boundary, directory, diagnostics, prefix) {
|
|
|
137
148
|
diagnostics.push({
|
|
138
149
|
severity: "warning",
|
|
139
150
|
code: `${prefix}.resource-denied`,
|
|
140
|
-
message: `Denied a file of
|
|
151
|
+
message: `Denied a file of ${label} outside the package: ${entry.name}`,
|
|
141
152
|
path: full,
|
|
142
153
|
});
|
|
143
154
|
continue;
|
|
@@ -153,22 +164,51 @@ function readFiles(name, boundary, directory, diagnostics, prefix) {
|
|
|
153
164
|
continue;
|
|
154
165
|
const issue = skillFilePathIssue(path);
|
|
155
166
|
if (issue)
|
|
156
|
-
throw new SkillsError(`${prefix}.invalid-path`,
|
|
157
|
-
|
|
158
|
-
throw new SkillsError(`${prefix}.file-too-large`, `Skill '${name}' file ${path} is ${stats.size} bytes; a skill file may be at most ${DEFINITION_FILE_MAX_BYTES} (10 MiB)`);
|
|
159
|
-
const hash = `sha256:${createHash("sha256").update(readFileSync(real)).digest("hex")}`;
|
|
167
|
+
throw new SkillsError(`${prefix}.invalid-path`, `${label[0].toUpperCase()}${label.slice(1)} has a file whose path ${issue}: ${path}`);
|
|
168
|
+
const hash = hashFile(real);
|
|
160
169
|
files[path] = hash;
|
|
161
|
-
sources[hash] = {
|
|
162
|
-
size: stats.size,
|
|
163
|
-
read: async () => new Uint8Array(await readFile(real)),
|
|
164
|
-
};
|
|
165
|
-
if (Object.keys(files).length > SKILL_FILES_MAX)
|
|
166
|
-
throw new SkillsError(`${prefix}.too-many-files`, `Skill '${name}' has more than ${SKILL_FILES_MAX} files; a skill may have at most ${SKILL_FILES_MAX}`);
|
|
170
|
+
sources[hash] = { size: stats.size, read: () => readWhole(real, stats.size) };
|
|
167
171
|
}
|
|
168
172
|
};
|
|
169
173
|
walk(directory, "");
|
|
170
174
|
return { files: sorted(files), sources };
|
|
171
175
|
}
|
|
176
|
+
/** Read in chunks: neither the hash nor the read is bound by `readFile`'s 2 GiB limit. */
|
|
177
|
+
const CHUNK_BYTES = 1024 * 1024;
|
|
178
|
+
/** `sha256:<hex>` of the file at `path`, read a chunk at a time. */
|
|
179
|
+
function hashFile(path) {
|
|
180
|
+
const hash = createHash("sha256");
|
|
181
|
+
const chunk = Buffer.allocUnsafe(CHUNK_BYTES);
|
|
182
|
+
const fd = openSync(path, "r");
|
|
183
|
+
try {
|
|
184
|
+
for (let read; (read = readSync(fd, chunk, 0, CHUNK_BYTES, null)) > 0;)
|
|
185
|
+
hash.update(chunk.subarray(0, read));
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
closeSync(fd);
|
|
189
|
+
}
|
|
190
|
+
return `sha256:${hash.digest("hex")}`;
|
|
191
|
+
}
|
|
192
|
+
/** The `size` bytes of the file at `path`. */
|
|
193
|
+
async function readWhole(path, size) {
|
|
194
|
+
const bytes = new Uint8Array(size);
|
|
195
|
+
const file = await open(path, "r");
|
|
196
|
+
try {
|
|
197
|
+
let at = 0;
|
|
198
|
+
while (at < size) {
|
|
199
|
+
const { bytesRead } = await file.read(bytes, at, Math.min(CHUNK_BYTES, size - at), at);
|
|
200
|
+
if (bytesRead === 0)
|
|
201
|
+
break;
|
|
202
|
+
at += bytesRead;
|
|
203
|
+
}
|
|
204
|
+
if (at !== size)
|
|
205
|
+
throw new Error(`${path} changed while it was read: ${at} of ${size} bytes`);
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
await file.close();
|
|
209
|
+
}
|
|
210
|
+
return bytes;
|
|
211
|
+
}
|
|
172
212
|
function sorted(files) {
|
|
173
213
|
return Object.fromEntries(Object.entries(files).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
174
214
|
}
|
package/dist/skills/skills.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ export interface SkillsPart extends PartDeclaration {
|
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
20
20
|
* Sets `skills`: each skill's name, description and files (every file of its folder, binary
|
|
21
|
-
* included, by content hash). The client uploads the files the Runtime lacks when it
|
|
22
|
-
*
|
|
21
|
+
* included, by content hash). The client uploads the files the Runtime lacks when it saves the
|
|
22
|
+
* agent's manifest; the Runtime adds the skill catalog and serves `load_skill` / `read_skill_resource`
|
|
23
23
|
* from them.
|
|
24
24
|
*/
|
|
25
25
|
export declare function skills(directory: string): SkillsPart;
|
package/dist/skills/skills.js
CHANGED
|
@@ -13,8 +13,8 @@ import { loadSkillsFromDirectory, resolveSkillsRoot, } from "./load.js";
|
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
15
|
* Sets `skills`: each skill's name, description and files (every file of its folder, binary
|
|
16
|
-
* included, by content hash). The client uploads the files the Runtime lacks when it
|
|
17
|
-
*
|
|
16
|
+
* included, by content hash). The client uploads the files the Runtime lacks when it saves the
|
|
17
|
+
* agent's manifest; the Runtime adds the skill catalog and serves `load_skill` / `read_skill_resource`
|
|
18
18
|
* from them.
|
|
19
19
|
*/
|
|
20
20
|
export function skills(directory) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0-beta",
|
|
4
4
|
"description": "Nylorun agent definitions and session client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
"test": "vitest run --passWithNoTests"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@nylorun/core": "0.
|
|
46
|
+
"@nylorun/core": "0.24.0-beta",
|
|
47
47
|
"gray-matter": "^4.0.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"zod": "^4.6.
|
|
50
|
+
"zod": "^4.6.7"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/node": "^26.6.
|
|
53
|
+
"@types/node": "^26.6.5",
|
|
54
54
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
55
|
-
"vitest": "^5.0.
|
|
55
|
+
"vitest": "^5.0.4"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=24"
|
package/dist/environments.d.ts
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environments (protocol 11, D55, D56): `client.environments`. An Environment is one sandbox
|
|
3
|
-
* (kind `virtual`, `pod` or `none`) made from an environment manifest's version or from inline
|
|
4
|
-
* fields, and one vault of secrets for its shell, MCP servers and HTTP tools. It never changes
|
|
5
|
-
* what it runs after it is made (protocol 14, D63): a new version reaches an agent through a new
|
|
6
|
-
* Environment. It has its own id and outlives the sessions that name it; whether it serves one
|
|
7
|
-
* session, one person or a project is the app's choice, made here:
|
|
8
|
-
*
|
|
9
|
-
* - `environments.forSession(...)`: one Environment for one session. It creates the
|
|
10
|
-
* Environment, opens the session on it, and `release()` deletes the Environment (and its
|
|
11
|
-
* vault) when the session is done.
|
|
12
|
-
* - `environments.put(id, { manifest: "analyst-box" })` (or inline fields): one Environment per
|
|
13
|
-
* person or per project, by a deterministic id (`users/alice/web`); get-or-create in one call.
|
|
14
|
-
* Write its secrets with `environments.secrets.put(id, name, { value })` and open sessions on
|
|
15
|
-
* it with `createSession({ environment: id })`.
|
|
16
|
-
* - `environments.manifests.save(manifest)`: save an environment manifest's next version, like
|
|
17
|
-
* `saveAgent`; `plan(manifest)` answers what a save would do and saves nothing.
|
|
18
|
-
*
|
|
19
|
-
* Ids may hold `/`; they are sent percent-encoded as one path segment. Secret values are
|
|
20
|
-
* write-only: no call reads one back.
|
|
21
|
-
*
|
|
22
|
-
* Disk versions (Host feature `environment-disk-versions`): `snapshot(id)` keeps a version of
|
|
23
|
-
* the Environment's disk between turns, `restore(id, version)` puts one back, and
|
|
24
|
-
* `put(id, { from: { environment, version } })` creates a new Environment from another's version.
|
|
25
|
-
*
|
|
26
|
-
* `fork(id, { id: next })` is how an Environment gets a new manifest version (Q15): a new
|
|
27
|
-
* Environment made from it, with the source's disk and secrets; `planFork` answers what it would do.
|
|
28
|
-
*/
|
|
29
|
-
import { ENVIRONMENT_MANIFEST_SCHEMA_VERSION, type DeleteEnvironmentManifestResponse, type EnvironmentManifest, type EnvironmentManifestPlan, type EnvironmentManifestVersions, type EnvironmentForkPlan, type EnvironmentManifestView, type ForkEnvironmentRequest, type SaveEnvironmentManifestResponse, type DeleteEnvironmentResponse, type EnvironmentEvent, type EnvironmentEventType, type EnvironmentRestore, type EnvironmentSecretView, type EnvironmentSnapshot, type EnvironmentVersions, type EnvironmentView, type PutEnvironmentRequest, type PutEnvironmentSecretRequest } from "@nylorun/core/contracts";
|
|
30
|
-
import { type Transport } from "./http.js";
|
|
31
|
-
import type { CreateSessionOptions, SessionClient } from "./session-client.js";
|
|
32
|
-
/**
|
|
33
|
-
* What an Environment is made from: an environment manifest (`manifest: "name"` or `"name@n"`)
|
|
34
|
-
* or the inline fields, and its labels, owner guard and `from`.
|
|
35
|
-
*/
|
|
36
|
-
export type EnvironmentInput = Omit<PutEnvironmentRequest, "requestId">;
|
|
37
|
-
/**
|
|
38
|
-
* One secret of an Environment's vault, as written: typed, or only its value (`{ value }`, or
|
|
39
|
-
* `{ headers }` for a `headers` secret) when what the Environment runs declares its slot (D64).
|
|
40
|
-
*/
|
|
41
|
-
export type EnvironmentSecretInput = PutEnvironmentSecretRequest | {
|
|
42
|
-
readonly value: string;
|
|
43
|
-
} | {
|
|
44
|
-
readonly headers: Readonly<Record<string, string>>;
|
|
45
|
-
};
|
|
46
|
-
/** An environment manifest as authored: `manifestSchemaVersion` may be left out. */
|
|
47
|
-
export type EnvironmentManifestInput = Omit<EnvironmentManifest, "manifestSchemaVersion"> & {
|
|
48
|
-
readonly manifestSchemaVersion?: typeof ENVIRONMENT_MANIFEST_SCHEMA_VERSION;
|
|
49
|
-
/** For editors; dropped here, as the CLI drops it. */
|
|
50
|
-
readonly $schema?: string;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* An environment manifest (protocol 14, D63): checked now against the schema the Runtime
|
|
54
|
-
* enforces, with `manifestSchemaVersion` filled in and `$schema` dropped. Save it with
|
|
55
|
-
* `client.environments.manifests.save()`, or make an Environment from it inline.
|
|
56
|
-
*/
|
|
57
|
-
export declare function environmentManifest(input: EnvironmentManifestInput): EnvironmentManifest;
|
|
58
|
-
/** A session opened on an Environment of its own (`environments.forSession`). */
|
|
59
|
-
export interface SessionEnvironmentHandle {
|
|
60
|
-
readonly session: SessionClient;
|
|
61
|
-
readonly environment: EnvironmentView;
|
|
62
|
-
/** Deletes the Environment, its vault and its files; call it when the session is done. */
|
|
63
|
-
release(options?: {
|
|
64
|
-
signal?: AbortSignal;
|
|
65
|
-
}): Promise<DeleteEnvironmentResponse>;
|
|
66
|
-
}
|
|
67
|
-
export interface ForSessionOptions {
|
|
68
|
-
/** The session to open, as `createSession` takes it, without `environment`. */
|
|
69
|
-
readonly session: Omit<CreateSessionOptions, "environment">;
|
|
70
|
-
/**
|
|
71
|
-
* What the Environment is made from (a `manifest` or inline fields) and its labels. Default: a
|
|
72
|
-
* virtual one within the Tenant's defaults.
|
|
73
|
-
*/
|
|
74
|
-
readonly recipe?: EnvironmentInput;
|
|
75
|
-
/** Secrets to write before the session opens, by name. */
|
|
76
|
-
readonly secrets?: Readonly<Record<string, EnvironmentSecretInput>>;
|
|
77
|
-
/** The Environment's id. Default: `sessions/<session id>`. */
|
|
78
|
-
readonly environmentId?: string;
|
|
79
|
-
readonly signal?: AbortSignal;
|
|
80
|
-
}
|
|
81
|
-
/** An Environment's secrets: `client.environments.secrets`. */
|
|
82
|
-
export declare class EnvironmentSecretsClient {
|
|
83
|
-
private readonly transport;
|
|
84
|
-
private readonly path;
|
|
85
|
-
constructor(transport: Transport, path: (environmentId: string) => string);
|
|
86
|
-
/**
|
|
87
|
-
* Creates or replaces secret `name` (`PUT /v1/environments/{id}/secrets/{name}`): for
|
|
88
|
-
* `environment_secret` and `environment_variable` the name is the variable's. A second
|
|
89
|
-
* credential for a host or a URL is a 409 `credential_conflict`. When what the Environment
|
|
90
|
-
* runs declares the secret's slot (D64), send only `{ value }` (or `{ headers }`); a name it
|
|
91
|
-
* does not declare is `409 secret_not_in_manifest`.
|
|
92
|
-
*/
|
|
93
|
-
put(environmentId: string, name: string, secret: EnvironmentSecretInput, options?: {
|
|
94
|
-
signal?: AbortSignal;
|
|
95
|
-
}): Promise<EnvironmentSecretView>;
|
|
96
|
-
/** The secrets' names, types and bindings; never a value. */
|
|
97
|
-
list(environmentId: string, options?: {
|
|
98
|
-
signal?: AbortSignal;
|
|
99
|
-
}): Promise<EnvironmentSecretView[]>;
|
|
100
|
-
get(environmentId: string, name: string, options?: {
|
|
101
|
-
signal?: AbortSignal;
|
|
102
|
-
}): Promise<EnvironmentSecretView>;
|
|
103
|
-
delete(environmentId: string, name: string, options?: {
|
|
104
|
-
signal?: AbortSignal;
|
|
105
|
-
}): Promise<{
|
|
106
|
-
id: string;
|
|
107
|
-
}>;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Environment manifests (protocol 14, D63): `client.environments.manifests`. A save writes the
|
|
111
|
-
* manifest's next version, or answers the latest unchanged, and changes no Environment: an
|
|
112
|
-
* Environment keeps the version it was made from.
|
|
113
|
-
*/
|
|
114
|
-
/** The bytes of files by hash, by `sha256:<hex>` (`environmentFiles(...).bytes`). */
|
|
115
|
-
export type EnvironmentFileBytes = Readonly<Record<string, Uint8Array>>;
|
|
116
|
-
/**
|
|
117
|
-
* A manifest `files` entry by content hash (Q6): `contents` (each file's path under `path` and
|
|
118
|
-
* its bytes or text) hashed, as `entry` for the manifest and `bytes` for `manifests.save`'s
|
|
119
|
-
* `files`, which uploads them. Each file holds at most 10 MiB.
|
|
120
|
-
*/
|
|
121
|
-
export declare function environmentFiles(path: string, contents: Readonly<Record<string, Uint8Array | string>>): Promise<{
|
|
122
|
-
entry: {
|
|
123
|
-
path: string;
|
|
124
|
-
files: Record<string, string>;
|
|
125
|
-
};
|
|
126
|
-
bytes: Record<string, Uint8Array>;
|
|
127
|
-
}>;
|
|
128
|
-
export declare class EnvironmentManifestsClient {
|
|
129
|
-
private readonly transport;
|
|
130
|
-
constructor(transport: Transport);
|
|
131
|
-
private path;
|
|
132
|
-
private send;
|
|
133
|
-
/**
|
|
134
|
-
* Saves `manifest` (`PUT /v1/environment-manifests/{name}`). `ifMatch`: the version you read
|
|
135
|
-
* (`0` for none yet); a save over a newer one is `412 manifest_changed`. `files`: the bytes of
|
|
136
|
-
* its files by hash (`environmentFiles(...).bytes`), uploaded first when the Runtime lacks them.
|
|
137
|
-
*/
|
|
138
|
-
save(manifest: EnvironmentManifestInput, options?: {
|
|
139
|
-
ifMatch?: number;
|
|
140
|
-
files?: EnvironmentFileBytes;
|
|
141
|
-
signal?: AbortSignal;
|
|
142
|
-
}): Promise<SaveEnvironmentManifestResponse>;
|
|
143
|
-
/** What saving `manifest` would do (`?dryRun=true`): changes, errors, warnings, and the Environments behind. */
|
|
144
|
-
plan(manifest: EnvironmentManifestInput, options?: {
|
|
145
|
-
ifMatch?: number;
|
|
146
|
-
files?: EnvironmentFileBytes;
|
|
147
|
-
signal?: AbortSignal;
|
|
148
|
-
}): Promise<EnvironmentManifestPlan>;
|
|
149
|
-
/** The latest version of manifest `name`, or version `version`. */
|
|
150
|
-
get(name: string, options?: {
|
|
151
|
-
version?: number;
|
|
152
|
-
signal?: AbortSignal;
|
|
153
|
-
}): Promise<EnvironmentManifestView>;
|
|
154
|
-
/** Each manifest's latest version. */
|
|
155
|
-
list(options?: {
|
|
156
|
-
signal?: AbortSignal;
|
|
157
|
-
}): Promise<EnvironmentManifestView[]>;
|
|
158
|
-
/** Every version of manifest `name`, newest first. */
|
|
159
|
-
versions(name: string, options?: {
|
|
160
|
-
signal?: AbortSignal;
|
|
161
|
-
}): Promise<EnvironmentManifestVersions>;
|
|
162
|
-
/** Deletes every version; refused while an Environment was made from one (`409 manifest_in_use`). */
|
|
163
|
-
delete(name: string, options?: {
|
|
164
|
-
signal?: AbortSignal;
|
|
165
|
-
}): Promise<DeleteEnvironmentManifestResponse>;
|
|
166
|
-
}
|
|
167
|
-
export declare class EnvironmentsClient {
|
|
168
|
-
private readonly transport;
|
|
169
|
-
/** `AgentsClient.createSession`, bound. */
|
|
170
|
-
private readonly createSession;
|
|
171
|
-
constructor(transport: Transport,
|
|
172
|
-
/** `AgentsClient.createSession`, bound. */
|
|
173
|
-
createSession: (options: CreateSessionOptions) => Promise<SessionClient>);
|
|
174
|
-
private path;
|
|
175
|
-
/** The Environment's secrets. */
|
|
176
|
-
get secrets(): EnvironmentSecretsClient;
|
|
177
|
-
/** Environment manifests (protocol 14, D63): named, versioned definitions of a kind of Environment. */
|
|
178
|
-
get manifests(): EnvironmentManifestsClient;
|
|
179
|
-
/**
|
|
180
|
-
* Creates the Environment and its vault, or finds the one with this id
|
|
181
|
-
* (`PUT /v1/environments/{id}`), from an environment manifest (`{ manifest: "name" }` takes
|
|
182
|
-
* the latest version, `"name@n"` version n) or from inline fields. It never changes what it
|
|
183
|
-
* runs after that (protocol 14): on an existing one, labels replace and `ownerUserId` sets or
|
|
184
|
-
* clears the owner guard, fields that match are accepted, and anything else is
|
|
185
|
-
* `409 environment_immutable`.
|
|
186
|
-
*/
|
|
187
|
-
put(environmentId: string, recipe?: EnvironmentInput, options?: {
|
|
188
|
-
signal?: AbortSignal;
|
|
189
|
-
}): Promise<EnvironmentView>;
|
|
190
|
-
get(environmentId: string, options?: {
|
|
191
|
-
signal?: AbortSignal;
|
|
192
|
-
}): Promise<EnvironmentView>;
|
|
193
|
-
/** The Environments with every label in `labels` that this client reaches. */
|
|
194
|
-
list(options?: {
|
|
195
|
-
labels?: Readonly<Record<string, string>>;
|
|
196
|
-
signal?: AbortSignal;
|
|
197
|
-
}): Promise<EnvironmentView[]>;
|
|
198
|
-
page(options?: {
|
|
199
|
-
labels?: Readonly<Record<string, string>>;
|
|
200
|
-
limit?: number;
|
|
201
|
-
cursor?: string;
|
|
202
|
-
signal?: AbortSignal;
|
|
203
|
-
}): Promise<{
|
|
204
|
-
environments: {
|
|
205
|
-
id: string;
|
|
206
|
-
kind: "none" | "pod" | "virtual";
|
|
207
|
-
labels: Record<string, string>;
|
|
208
|
-
manifest: {
|
|
209
|
-
image?: string | undefined;
|
|
210
|
-
resources?: {
|
|
211
|
-
cpus: number;
|
|
212
|
-
memory: string;
|
|
213
|
-
} | undefined;
|
|
214
|
-
storage?: string | undefined;
|
|
215
|
-
network?: {
|
|
216
|
-
allowedHosts: string[];
|
|
217
|
-
} | undefined;
|
|
218
|
-
harness: string;
|
|
219
|
-
lifecycle: {
|
|
220
|
-
idle?: string | undefined;
|
|
221
|
-
deleteAfter?: string | undefined;
|
|
222
|
-
};
|
|
223
|
-
setup?: {
|
|
224
|
-
command: string;
|
|
225
|
-
cwd?: string | undefined;
|
|
226
|
-
timeout?: string | undefined;
|
|
227
|
-
}[] | undefined;
|
|
228
|
-
files?: ({
|
|
229
|
-
artifactId: string;
|
|
230
|
-
version: number;
|
|
231
|
-
path: string;
|
|
232
|
-
} | {
|
|
233
|
-
path: string;
|
|
234
|
-
files: Record<string, string>;
|
|
235
|
-
})[] | undefined;
|
|
236
|
-
secrets?: Record<string, {
|
|
237
|
-
required?: boolean | undefined;
|
|
238
|
-
description?: string | undefined;
|
|
239
|
-
type: "environment_secret";
|
|
240
|
-
allowedHosts: string[];
|
|
241
|
-
inject?: {
|
|
242
|
-
header: string;
|
|
243
|
-
format: string;
|
|
244
|
-
} | undefined;
|
|
245
|
-
} | {
|
|
246
|
-
required?: boolean | undefined;
|
|
247
|
-
description?: string | undefined;
|
|
248
|
-
type: "environment_variable";
|
|
249
|
-
} | {
|
|
250
|
-
via?: string | undefined;
|
|
251
|
-
identity?: {
|
|
252
|
-
header: string;
|
|
253
|
-
} | undefined;
|
|
254
|
-
required?: boolean | undefined;
|
|
255
|
-
description?: string | undefined;
|
|
256
|
-
type: "bearer";
|
|
257
|
-
url: string;
|
|
258
|
-
} | {
|
|
259
|
-
via?: string | undefined;
|
|
260
|
-
identity?: {
|
|
261
|
-
header: string;
|
|
262
|
-
} | undefined;
|
|
263
|
-
required?: boolean | undefined;
|
|
264
|
-
description?: string | undefined;
|
|
265
|
-
type: "headers";
|
|
266
|
-
url: string;
|
|
267
|
-
}> | undefined;
|
|
268
|
-
};
|
|
269
|
-
manifestName?: string | undefined;
|
|
270
|
-
manifestVersion?: number | undefined;
|
|
271
|
-
manifestHash?: string | undefined;
|
|
272
|
-
forkedFrom?: {
|
|
273
|
-
environment: string;
|
|
274
|
-
disk: number | null;
|
|
275
|
-
} | undefined;
|
|
276
|
-
slots?: {
|
|
277
|
-
name: string;
|
|
278
|
-
type: string;
|
|
279
|
-
required: boolean;
|
|
280
|
-
set: boolean;
|
|
281
|
-
}[] | undefined;
|
|
282
|
-
version: number;
|
|
283
|
-
appliedVersion: number;
|
|
284
|
-
ownerUserId: string | null;
|
|
285
|
-
state: string;
|
|
286
|
-
pod?: {
|
|
287
|
-
desired: "deleted" | "running" | "suspended";
|
|
288
|
-
observed: "creating" | "deleting" | "failed" | "lost" | "running" | "suspended";
|
|
289
|
-
volumeGeneration: number;
|
|
290
|
-
hostEpoch: number;
|
|
291
|
-
reason?: string | undefined;
|
|
292
|
-
imageDigest?: string | undefined;
|
|
293
|
-
} | undefined;
|
|
294
|
-
lastUsedAt: string;
|
|
295
|
-
disk?: {
|
|
296
|
-
latestVersion: number | null;
|
|
297
|
-
operation?: {
|
|
298
|
-
kind: "restore" | "seed" | "snapshot";
|
|
299
|
-
version?: number | undefined;
|
|
300
|
-
startedAt: string;
|
|
301
|
-
} | undefined;
|
|
302
|
-
} | undefined;
|
|
303
|
-
sessions: {
|
|
304
|
-
id: string;
|
|
305
|
-
activeTurnId: string | null;
|
|
306
|
-
}[];
|
|
307
|
-
createdAt: string;
|
|
308
|
-
updatedAt: string;
|
|
309
|
-
}[];
|
|
310
|
-
nextCursor: string | null;
|
|
311
|
-
}>;
|
|
312
|
-
/** Stops a pod Environment: its volume is kept, and the next turn starts it again. */
|
|
313
|
-
stop(environmentId: string, options?: {
|
|
314
|
-
signal?: AbortSignal;
|
|
315
|
-
}): Promise<EnvironmentView>;
|
|
316
|
-
/** Resets a pod Environment: a new pod on a new, empty volume, with its recipe applied. */
|
|
317
|
-
reset(environmentId: string, options?: {
|
|
318
|
-
signal?: AbortSignal;
|
|
319
|
-
}): Promise<EnvironmentView>;
|
|
320
|
-
/**
|
|
321
|
-
* Keeps a version of the Environment's disk (`POST /v1/environments/{id}/snapshot`), between
|
|
322
|
-
* turns; `unchanged` when the disk is as the latest version has it.
|
|
323
|
-
*/
|
|
324
|
-
snapshot(environmentId: string, options?: {
|
|
325
|
-
signal?: AbortSignal;
|
|
326
|
-
}): Promise<EnvironmentSnapshot>;
|
|
327
|
-
/**
|
|
328
|
-
* Puts disk version `version` back: at once for a virtual Environment (`done`), on a new volume
|
|
329
|
-
* seeded before the next turn for a pod (`pending`).
|
|
330
|
-
*/
|
|
331
|
-
restore(environmentId: string, version: number | "latest", options?: {
|
|
332
|
-
signal?: AbortSignal;
|
|
333
|
-
}): Promise<EnvironmentRestore>;
|
|
334
|
-
/**
|
|
335
|
-
* Forks the Environment into a new one, `options.id` (Q15): how an Environment gets a new
|
|
336
|
-
* manifest version, since none ever changes what it runs. It is made from `options.manifest`
|
|
337
|
-
* (default the source's manifest at its latest version), its disk starts from `options.disk`
|
|
338
|
-
* (`latest`, the default, snapshots first; a version; or `empty`) and the secrets the new
|
|
339
|
-
* manifest declares are copied (`options.secrets: "none"` copies none). The source keeps what
|
|
340
|
-
* it runs, its disk and its sessions. Answers the new Environment and the plan it ran.
|
|
341
|
-
*/
|
|
342
|
-
fork(environmentId: string, options: Omit<ForkEnvironmentRequest, "requestId" | "dryRun"> & {
|
|
343
|
-
signal?: AbortSignal;
|
|
344
|
-
}): Promise<{
|
|
345
|
-
environment: EnvironmentView;
|
|
346
|
-
plan: EnvironmentForkPlan;
|
|
347
|
-
}>;
|
|
348
|
-
/** What `fork` would do (the disk, the secrets copied and left behind, the changes), making nothing. */
|
|
349
|
-
planFork(environmentId: string, options: Omit<ForkEnvironmentRequest, "requestId" | "dryRun"> & {
|
|
350
|
-
signal?: AbortSignal;
|
|
351
|
-
}): Promise<EnvironmentForkPlan>;
|
|
352
|
-
/** The Environment's disk versions, newest first. */
|
|
353
|
-
versions(environmentId: string, options?: {
|
|
354
|
-
signal?: AbortSignal;
|
|
355
|
-
}): Promise<EnvironmentVersions>;
|
|
356
|
-
/** Deletes disk version `version`; `deleted` is false when there was none. */
|
|
357
|
-
deleteVersion(environmentId: string, version: number, options?: {
|
|
358
|
-
signal?: AbortSignal;
|
|
359
|
-
}): Promise<{
|
|
360
|
-
environmentId: string;
|
|
361
|
-
version: number;
|
|
362
|
-
deleted: boolean;
|
|
363
|
-
}>;
|
|
364
|
-
/** Deletes the Environment, its vault and its files; `deleted` is false when there was none. */
|
|
365
|
-
delete(environmentId: string, options?: {
|
|
366
|
-
signal?: AbortSignal;
|
|
367
|
-
}): Promise<DeleteEnvironmentResponse>;
|
|
368
|
-
/**
|
|
369
|
-
* The Environment's events, from `from` on: its lifecycle, and `environment.egress` for every
|
|
370
|
-
* connection its sandbox opens (with the turns that were running). `types` keeps only those
|
|
371
|
-
* types; `since` and `until` keep events recorded in that window (ISO times or `Date`s).
|
|
372
|
-
*/
|
|
373
|
-
events(environmentId: string, options?: {
|
|
374
|
-
from?: number;
|
|
375
|
-
types?: readonly EnvironmentEventType[];
|
|
376
|
-
since?: string | Date;
|
|
377
|
-
until?: string | Date;
|
|
378
|
-
signal?: AbortSignal;
|
|
379
|
-
}): Promise<EnvironmentEvent[]>;
|
|
380
|
-
/**
|
|
381
|
-
* One Environment for one session: creates the Environment (`sessions/<session id>` unless
|
|
382
|
-
* `environmentId` names another), writes `secrets`, opens the session on it, and returns both
|
|
383
|
-
* with `release()`, which deletes the Environment. If the session cannot be opened, the
|
|
384
|
-
* Environment is deleted again.
|
|
385
|
-
*/
|
|
386
|
-
forSession(options: ForSessionOptions): Promise<SessionEnvironmentHandle>;
|
|
387
|
-
}
|