@nylorun/core 0.20.0-beta → 0.21.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 +76 -0
- package/README.md +2 -2
- package/dist/compatibility.d.ts +84 -10
- package/dist/compatibility.js +84 -10
- package/dist/contracts.d.ts +1328 -110
- package/dist/contracts.js +544 -157
- package/dist/define.d.ts +14 -12
- package/dist/define.js +10 -7
- package/dist/definition/approval.js +12 -14
- package/dist/definition/assemble.d.ts +6 -10
- package/dist/definition/assemble.js +48 -105
- package/dist/definition/bind-agent.d.ts +3 -4
- package/dist/definition/bind-agent.js +12 -30
- package/dist/definition/binding.d.ts +2 -2
- package/dist/definition/bound.d.ts +10 -10
- package/dist/definition/builder.d.ts +16 -20
- package/dist/definition/builder.js +29 -81
- package/dist/definition/code-tools.d.ts +3 -3
- package/dist/definition/code-tools.js +6 -21
- package/dist/definition/declaration.d.ts +4 -7
- package/dist/definition/declaration.js +29 -99
- package/dist/definition/{tools-capability.d.ts → deferred-tools.d.ts} +3 -13
- package/dist/definition/{tools-capability.js → deferred-tools.js} +2 -18
- package/dist/definition/delegate.d.ts +2 -4
- package/dist/definition/delegate.js +8 -10
- package/dist/definition/from.d.ts +7 -4
- package/dist/definition/from.js +72 -117
- package/dist/definition/helpers.d.ts +0 -7
- package/dist/definition/helpers.js +0 -5
- package/dist/definition/implementations.d.ts +6 -8
- package/dist/definition/manifest.d.ts +11 -5
- package/dist/definition/manifest.js +26 -26
- package/dist/definition/mcp.d.ts +1 -52
- package/dist/definition/mcp.js +0 -52
- package/dist/definition/media-reference.d.ts +23 -0
- package/dist/definition/media-reference.js +26 -0
- package/dist/definition/removed.d.ts +3 -10
- package/dist/definition/removed.js +10 -17
- package/dist/definition/runtime-manifest.d.ts +30 -0
- package/dist/definition/runtime-manifest.js +132 -0
- package/dist/definition/sandbox-tools.d.ts +1 -1
- package/dist/definition/sandbox-tools.js +1 -1
- package/dist/definition/skill-tools.d.ts +13 -7
- package/dist/definition/skill-tools.js +23 -10
- package/dist/definition/trace.d.ts +18 -0
- package/dist/definition/trace.js +42 -0
- package/dist/definition/variant.d.ts +5 -4
- package/dist/definition/variant.js +18 -51
- package/dist/definition/workflow/runnable.js +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/harness-api/entries.d.ts +1 -0
- package/dist/harness-api/entries.js +1 -0
- package/dist/harness-api/gates.d.ts +1 -6
- package/dist/harness-api/gates.js +1 -3
- package/dist/harness-api/harness-api.schema.json +11 -92
- package/dist/harness-api/index.d.ts +2 -2
- package/dist/harness-api/index.js +2 -2
- package/dist/harness-api/mcp.d.ts +0 -4
- package/dist/harness-api/mcp.js +0 -2
- package/dist/harness-api/messages.d.ts +1 -3
- package/dist/harness-api/messages.js +1 -3
- package/dist/harness-api/schema.d.ts +5 -17
- package/dist/harness-api/schema.js +9 -6
- package/dist/index.d.ts +1 -1
- package/dist/manifest-schemas.d.ts +6 -0
- package/dist/manifest-schemas.js +34 -0
- package/dist/schemas/agent-manifest.schema.json +897 -0
- package/dist/schemas/environment-manifest.schema.json +329 -0
- package/dist/types/agent.d.ts +1 -1
- package/dist/types/manifest.d.ts +33 -19
- package/dist/types/model.d.ts +2 -2
- package/dist/types/observe.d.ts +5 -18
- package/dist/types/part.d.ts +25 -0
- package/dist/types/tool.d.ts +1 -1
- package/dist/types/transcript.d.ts +5 -0
- package/dist/utils/definition-files.d.ts +11 -6
- package/dist/utils/definition-files.js +19 -9
- package/dist/utils/runtime-tools.d.ts +19 -0
- package/dist/utils/runtime-tools.js +30 -0
- package/dist/utils/sandbox.d.ts +1 -1
- package/dist/utils/sandbox.js +1 -1
- package/package.json +9 -3
- package/dist/definition/capability.d.ts +0 -43
- package/dist/definition/capability.js +0 -82
- package/dist/definition/sandbox-capability.d.ts +0 -44
- package/dist/definition/sandbox-capability.js +0 -139
- package/dist/types/middleware.d.ts +0 -94
- /package/dist/types/{middleware.js → part.js} +0 -0
package/dist/contracts.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/** Public wire contracts only. Never import checkpoint or engine modules here. */
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, isSandboxHostPattern, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
|
|
4
|
-
import {
|
|
4
|
+
import { REMOVED_MANIFEST_FIELDS, manifestVersionIssue, workflowVersionIssue, } from "./definition/removed.js";
|
|
5
|
+
import { RUNTIME_TOOL_NAMES } from "./utils/runtime-tools.js";
|
|
5
6
|
import { DELEGATE_INPUT_SCHEMA, DELEGATE_NAME_PATTERN } from "./definition/delegate.js";
|
|
6
|
-
import {
|
|
7
|
+
import { stdioMcpRefusal } from "./definition/mcp.js";
|
|
7
8
|
import { APPROVAL_MODES, HTTP_TOOL_MAX_TIMEOUT_MS, HTTP_TOOL_METHODS, httpUrlIssue, } from "./definition/http-tool.js";
|
|
8
9
|
import { canonical } from "./utils/canonical.js";
|
|
9
10
|
import { DEFAULT_HARNESS, HARNESS_ID_PATTERN, isHarnessId } from "./utils/harness-id.js";
|
|
10
11
|
export { DEFAULT_HARNESS, HARNESS_ID_PATTERN, isHarnessId };
|
|
11
|
-
import { DEFINITION_FILE_MAX_BYTES, skillFilesIssue } from "./utils/definition-files.js";
|
|
12
|
+
import { DEFINITION_FILE_MAX_BYTES, isDefinitionFileHash, skillFilesIssue } from "./utils/definition-files.js";
|
|
12
13
|
export { PROTOCOL_VERSION, ERROR_CODES } from "./compatibility.js";
|
|
13
14
|
export { DEFINITION_FILE_MAX_BYTES, SKILL_FILES_MAX, definitionFilesOf, isDefinitionFileHash, } from "./utils/definition-files.js";
|
|
14
15
|
import { ERROR_CODES, isArtifactId } from "./compatibility.js";
|
|
@@ -39,7 +40,12 @@ const jsonValue = z
|
|
|
39
40
|
const modelFacingName = (what) => z.string().regex(DELEGATE_NAME_PATTERN, {
|
|
40
41
|
error: (issue) => `${what} name '${String(issue.input)}' may use only letters, digits, _ and -, up to 64 characters, so that every model provider accepts it`,
|
|
41
42
|
});
|
|
42
|
-
/**
|
|
43
|
+
/** Which Agent Plugin brought a skill or an MCP server. */
|
|
44
|
+
const pluginLabelSchema = z
|
|
45
|
+
.object({ name: z.string().min(1), version: z.string().min(1).optional() })
|
|
46
|
+
.strict()
|
|
47
|
+
.meta({ id: "PluginLabel" });
|
|
48
|
+
/** One tool's settings on an MCP server (R2b C9). */
|
|
43
49
|
const mcpToolSettingsSchema = z
|
|
44
50
|
.object({
|
|
45
51
|
enabled: z.boolean().optional(),
|
|
@@ -48,10 +54,11 @@ const mcpToolSettingsSchema = z
|
|
|
48
54
|
})
|
|
49
55
|
.strict()
|
|
50
56
|
.meta({ id: "McpToolSettings" });
|
|
51
|
-
/**
|
|
57
|
+
/** Per-tool settings keyed by the server's tool names, `"*"` for the rest (R2b C9, C10). */
|
|
52
58
|
const mcpServerSettings = {
|
|
53
59
|
deferred: z.boolean().optional(),
|
|
54
60
|
tools: z.record(z.string().min(1), mcpToolSettingsSchema).optional(),
|
|
61
|
+
plugin: pluginLabelSchema.optional(),
|
|
55
62
|
};
|
|
56
63
|
const mcpServerSchema = z.discriminatedUnion("type", [
|
|
57
64
|
z
|
|
@@ -91,6 +98,7 @@ const skillManifestSchema = z
|
|
|
91
98
|
name: z.string().min(1),
|
|
92
99
|
description: z.string().min(1),
|
|
93
100
|
files: z.record(z.string(), z.string()),
|
|
101
|
+
plugin: pluginLabelSchema.optional(),
|
|
94
102
|
})
|
|
95
103
|
.strict()
|
|
96
104
|
.superRefine((skill, ctx) => {
|
|
@@ -181,17 +189,36 @@ const toolManifestSchema = z
|
|
|
181
189
|
message: `Tool '${tool.name}' takes approval only as an HTTP tool`,
|
|
182
190
|
});
|
|
183
191
|
});
|
|
184
|
-
/** A manifest
|
|
192
|
+
/** A manifest naming a removed field is refused with what replaces it. */
|
|
185
193
|
const removedFieldError = (removedFields) => (issue) => {
|
|
186
194
|
if (issue.code !== "unrecognized_keys")
|
|
187
195
|
return undefined;
|
|
188
196
|
const removed = issue.keys?.find((key) => removedFields[key] !== undefined);
|
|
189
197
|
return removed === undefined ? undefined : removedFields[removed];
|
|
190
198
|
};
|
|
199
|
+
/** What the Runtime adds to a session's agent; only the Runtime writes it. */
|
|
200
|
+
const runtimeManifestSchema = z
|
|
201
|
+
.object({
|
|
202
|
+
sandbox: sandboxManifestSchema.optional(),
|
|
203
|
+
tools: z.array(toolManifestSchema).optional(),
|
|
204
|
+
instructions: z.array(z.string()).optional(),
|
|
205
|
+
})
|
|
206
|
+
.strict();
|
|
207
|
+
/**
|
|
208
|
+
* What an agent needs of the Environment its session opens on (protocol 14, D65), checked when a
|
|
209
|
+
* session opens (`409 environment_unsuitable`). `sandbox`: `any` needs kind `virtual` or `pod`,
|
|
210
|
+
* `pod` needs kind `pod`, `none` needs nothing. `secrets`: names its skills' scripts read, which
|
|
211
|
+
* the Environment's vault must hold. The agent names no Environment: the app still maps.
|
|
212
|
+
*/
|
|
213
|
+
const agentRequirementsSchema = z
|
|
214
|
+
.object({
|
|
215
|
+
sandbox: z.enum(["none", "any", "pod"]).optional(),
|
|
216
|
+
secrets: z.array(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/, "A secret name in requires is an environment variable name")).max(64).optional(),
|
|
217
|
+
})
|
|
218
|
+
.strict();
|
|
191
219
|
const agentManifestSchema = z
|
|
192
220
|
.strictObject({
|
|
193
|
-
|
|
194
|
-
manifestSchemaVersion: z.union([z.literal(5), z.literal(6)], {
|
|
221
|
+
manifestSchemaVersion: z.literal(7, {
|
|
195
222
|
error: (issue) => manifestVersionIssue(issue.input),
|
|
196
223
|
}),
|
|
197
224
|
id: z.string().min(1),
|
|
@@ -199,19 +226,12 @@ const agentManifestSchema = z
|
|
|
199
226
|
description: z.string().optional(),
|
|
200
227
|
metadata: definitionJson.optional(),
|
|
201
228
|
outputSchema: definitionJson.optional(),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
instructions: z.array(z.string()).optional(),
|
|
209
|
-
skills: z.record(z.string(), skillManifestSchema).optional(),
|
|
210
|
-
tools: z.array(toolManifestSchema).optional(),
|
|
211
|
-
mcpServers: z.record(z.string(), mcpServerSchema).optional(),
|
|
212
|
-
sandbox: sandboxManifestSchema.optional(),
|
|
213
|
-
}, { error: removedFieldError(REMOVED_CAPABILITY_FIELDS) })),
|
|
214
|
-
runtime: z.object({}).strict().optional(),
|
|
229
|
+
instructions: z.array(z.string()).optional(),
|
|
230
|
+
tools: z.array(toolManifestSchema).optional(),
|
|
231
|
+
skills: z.record(z.string(), skillManifestSchema).optional(),
|
|
232
|
+
mcpServers: z.record(z.string(), mcpServerSchema).optional(),
|
|
233
|
+
requires: agentRequirementsSchema.optional(),
|
|
234
|
+
runtime: runtimeManifestSchema.optional(),
|
|
215
235
|
// Reserved for Functions, which are deferred: developer code the Runtime will run from
|
|
216
236
|
// uploaded definition files (a `functions/` folder). Any value is refused below.
|
|
217
237
|
functions: z.unknown().optional().meta({ description: "Reserved: Functions are not available yet" }),
|
|
@@ -220,124 +240,85 @@ const agentManifestSchema = z
|
|
|
220
240
|
if (manifest.functions !== undefined)
|
|
221
241
|
ctx.addIssue({ code: "custom", path: ["functions"], message: "Functions are not available yet" });
|
|
222
242
|
delegationIssues(manifest, (message) => ctx.addIssue({ code: "custom", message }));
|
|
223
|
-
const ids = new Set();
|
|
224
243
|
const names = new Set();
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
let sandboxes = 0;
|
|
228
|
-
for (const capability of manifest.capabilities) {
|
|
229
|
-
if (capability.sandbox) {
|
|
230
|
-
sandboxes += 1;
|
|
231
|
-
if (sandboxes > 1)
|
|
232
|
-
ctx.addIssue({
|
|
233
|
-
code: "custom",
|
|
234
|
-
message: "At most one capability may declare a sandbox",
|
|
235
|
-
});
|
|
236
|
-
const declared = new Set((capability.tools ?? []).map((tool) => tool.name));
|
|
237
|
-
for (const name of SANDBOX_TOOL_NAMES)
|
|
238
|
-
if (!declared.has(name))
|
|
239
|
-
ctx.addIssue({
|
|
240
|
-
code: "custom",
|
|
241
|
-
message: `Sandbox capability '${capability.id}' must declare the built-in '${name}' tool`,
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
if (ids.has(capability.id))
|
|
245
|
-
ctx.addIssue({ code: "custom", message: "Duplicate capability id" });
|
|
246
|
-
ids.add(capability.id);
|
|
247
|
-
for (const tool of capability.tools ?? []) {
|
|
248
|
-
if (names.has(tool.name))
|
|
249
|
-
ctx.addIssue({
|
|
250
|
-
code: "custom",
|
|
251
|
-
message: "Tool names must be unique",
|
|
252
|
-
});
|
|
253
|
-
names.add(tool.name);
|
|
254
|
-
}
|
|
255
|
-
if (capability.skills && Object.keys(capability.skills).length === 0)
|
|
244
|
+
for (const tool of manifest.tools ?? []) {
|
|
245
|
+
if (RUNTIME_TOOL_NAMES.has(tool.name))
|
|
256
246
|
ctx.addIssue({
|
|
257
247
|
code: "custom",
|
|
258
|
-
message:
|
|
248
|
+
message: `Tool '${tool.name}' takes the name of a tool the Runtime serves; rename it`,
|
|
259
249
|
});
|
|
260
|
-
|
|
261
|
-
if (key !== skill.name)
|
|
262
|
-
ctx.addIssue({
|
|
263
|
-
code: "custom",
|
|
264
|
-
message: `skills key '${key}' must equal the skill name`,
|
|
265
|
-
});
|
|
266
|
-
if (skills.has(skill.name))
|
|
267
|
-
ctx.addIssue({
|
|
268
|
-
code: "custom",
|
|
269
|
-
message: `Duplicate skill '${skill.name}'`,
|
|
270
|
-
});
|
|
271
|
-
skills.add(skill.name);
|
|
272
|
-
}
|
|
273
|
-
if (capability.mcpServers && Object.keys(capability.mcpServers).length === 0)
|
|
250
|
+
if (tool.name.includes("__"))
|
|
274
251
|
ctx.addIssue({
|
|
275
252
|
code: "custom",
|
|
276
|
-
message:
|
|
253
|
+
message: `Tool '${tool.name}' must not contain '__', which names an MCP server's tools`,
|
|
277
254
|
});
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
255
|
+
}
|
|
256
|
+
for (const tool of [...(manifest.tools ?? []), ...(manifest.runtime?.tools ?? [])]) {
|
|
257
|
+
if (names.has(tool.name))
|
|
258
|
+
ctx.addIssue({ code: "custom", message: "Tool names must be unique" });
|
|
259
|
+
names.add(tool.name);
|
|
260
|
+
}
|
|
261
|
+
for (const tool of manifest.runtime?.tools ?? [])
|
|
262
|
+
if (!RUNTIME_TOOL_NAMES.has(tool.name))
|
|
263
|
+
ctx.addIssue({
|
|
264
|
+
code: "custom",
|
|
265
|
+
message: `runtime.tools holds only the tools the Runtime serves, not '${tool.name}'`,
|
|
266
|
+
});
|
|
267
|
+
if (manifest.runtime?.sandbox !== undefined) {
|
|
268
|
+
const pinned = new Set((manifest.runtime.tools ?? []).map((tool) => tool.name));
|
|
269
|
+
for (const name of SANDBOX_TOOL_NAMES)
|
|
270
|
+
if (!pinned.has(name))
|
|
285
271
|
ctx.addIssue({
|
|
286
272
|
code: "custom",
|
|
287
|
-
message: `
|
|
273
|
+
message: `runtime.sandbox comes with the sandbox tools; runtime.tools has no '${name}'`,
|
|
288
274
|
});
|
|
289
|
-
servers.add(server.name);
|
|
290
|
-
if (manifest.manifestSchemaVersion === 5 && usesMcpToolSettings(server))
|
|
291
|
-
ctx.addIssue({ code: "custom", message: mcpToolSettingsVersionIssue(server.name) });
|
|
292
|
-
}
|
|
293
275
|
}
|
|
276
|
+
if (manifest.skills && Object.keys(manifest.skills).length === 0)
|
|
277
|
+
ctx.addIssue({ code: "custom", message: "skills must be omitted when the agent has no skills" });
|
|
278
|
+
for (const [key, skill] of Object.entries(manifest.skills ?? {}))
|
|
279
|
+
if (key !== skill.name)
|
|
280
|
+
ctx.addIssue({ code: "custom", message: `skills key '${key}' must equal the skill name` });
|
|
281
|
+
if (manifest.mcpServers && Object.keys(manifest.mcpServers).length === 0)
|
|
282
|
+
ctx.addIssue({ code: "custom", message: "mcpServers must be omitted when the agent has no servers" });
|
|
283
|
+
for (const [key, server] of Object.entries(manifest.mcpServers ?? {}))
|
|
284
|
+
if (key !== server.name)
|
|
285
|
+
ctx.addIssue({ code: "custom", message: `mcpServers key '${key}' must equal the server name` });
|
|
294
286
|
});
|
|
295
287
|
/**
|
|
296
|
-
* An agent's manifest (manifest
|
|
297
|
-
*
|
|
288
|
+
* An agent's manifest (manifest v7). Its output is checked against `AgentManifest` here and below
|
|
289
|
+
* (`ManifestDrift`): the hand-written type keeps its read-only fields and its docs.
|
|
298
290
|
*/
|
|
299
291
|
export const AgentManifestSchema = agentManifestSchema;
|
|
300
292
|
/** Agents used as tools: one level deep, `{ task }` input, one shared sandbox spec. */
|
|
301
293
|
function delegationIssues(manifest, issue) {
|
|
302
294
|
const sandboxes = new Set();
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
sandboxes.add(canonical(capability.sandbox));
|
|
295
|
+
const addSandbox = (agent) => {
|
|
296
|
+
if (agent.runtime?.sandbox)
|
|
297
|
+
sandboxes.add(canonical(agent.runtime.sandbox));
|
|
307
298
|
};
|
|
308
|
-
|
|
309
|
-
for (const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
if (tool.name !== child.id)
|
|
329
|
-
issue(`Tool '${tool.name}' must be named after the agent it runs ('${child.id}')`);
|
|
330
|
-
if (!child.description?.trim() || tool.description !== child.description)
|
|
331
|
-
issue(`Agent tool '${tool.name}' must carry the agent's non-empty description`);
|
|
332
|
-
if (canonical(tool.inputSchema) !== canonical(DELEGATE_INPUT_SCHEMA))
|
|
333
|
-
issue(`Agent tool '${tool.name}' must take the standard { task } input`);
|
|
334
|
-
if (tool.outputSchema !== undefined)
|
|
335
|
-
issue(`Agent tool '${tool.name}' must not declare outputSchema; the agent's outputSchema applies`);
|
|
336
|
-
for (const inner of child.capabilities)
|
|
337
|
-
if (inner.tools?.some((item) => item.agent !== undefined))
|
|
338
|
-
issue(`'${child.id}' delegates to another agent; nested delegation is not supported yet`);
|
|
339
|
-
addSandboxes(child);
|
|
299
|
+
addSandbox(manifest);
|
|
300
|
+
for (const tool of manifest.tools ?? []) {
|
|
301
|
+
const child = tool.agent;
|
|
302
|
+
if (!child)
|
|
303
|
+
continue;
|
|
304
|
+
if (tool.name !== child.id)
|
|
305
|
+
issue(`Tool '${tool.name}' must be named after the agent it runs ('${child.id}')`);
|
|
306
|
+
if (!child.description?.trim() || tool.description !== child.description)
|
|
307
|
+
issue(`Agent tool '${tool.name}' must carry the agent's non-empty description`);
|
|
308
|
+
if (canonical(tool.inputSchema) !== canonical(DELEGATE_INPUT_SCHEMA))
|
|
309
|
+
issue(`Agent tool '${tool.name}' must take the standard { task } input`);
|
|
310
|
+
if (tool.outputSchema !== undefined)
|
|
311
|
+
issue(`Agent tool '${tool.name}' must not declare outputSchema; the agent's outputSchema applies`);
|
|
312
|
+
if ("kind" in child) {
|
|
313
|
+
// A flow agent runs in its own linked session; its leaves may delegate in turn.
|
|
314
|
+
if (child.sandbox !== undefined && Object.keys(child.sandbox).length > 0)
|
|
315
|
+
sandboxes.add(canonical(child.sandbox));
|
|
316
|
+
continue;
|
|
340
317
|
}
|
|
318
|
+
if (child.tools?.some((item) => item.agent !== undefined))
|
|
319
|
+
issue(`'${child.id}' delegates to another agent; nested delegation is not supported yet`);
|
|
320
|
+
addSandbox(child);
|
|
321
|
+
}
|
|
341
322
|
if (sandboxes.size > 1)
|
|
342
323
|
issue("An agent and the agents it uses as tools must declare identical sandboxes");
|
|
343
324
|
}
|
|
@@ -634,25 +615,92 @@ export const EnvironmentSetupCommandSchema = z
|
|
|
634
615
|
* is made or reset, before the setup commands. A file artifact is written at `path`; a folder
|
|
635
616
|
* artifact is unpacked under it.
|
|
636
617
|
*/
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
618
|
+
/** The most files one `files` entry by hash names (Q6). */
|
|
619
|
+
export const ENVIRONMENT_FILES_MAX = 1000;
|
|
620
|
+
/** A file's path inside a `files` entry by hash: relative, `/`-separated, without `.` or `..`. */
|
|
621
|
+
const relativeFilePath = z
|
|
622
|
+
.string()
|
|
623
|
+
.min(1)
|
|
624
|
+
.max(1024)
|
|
625
|
+
.refine((value) => !value.startsWith("/") && !value.includes("\0") && value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== ".."), { message: "a file's path is relative, without empty, . or .. segments" });
|
|
626
|
+
/**
|
|
627
|
+
* One input file entry (pods only): an artifact version copied to `path` (a file artifact, or a
|
|
628
|
+
* folder's files under it), or (Q6) files by content hash, each `sha256:<hex>` of a definition
|
|
629
|
+
* file the Tenant holds (`PUT /v1/files/sha256:<hex>`, at most 10 MiB each), copied under `path`
|
|
630
|
+
* at its relative path. A manifest by hash moves to another Tenant with its files.
|
|
631
|
+
*/
|
|
632
|
+
export const EnvironmentFileSchema = z.union([
|
|
633
|
+
z
|
|
634
|
+
.object({
|
|
635
|
+
artifactId: z.string().refine(isArtifactId, { message: "artifactId must be an artifact id" }),
|
|
636
|
+
version: z.number().int().positive(),
|
|
637
|
+
path: absoluteWorkspacePath("path"),
|
|
638
|
+
})
|
|
639
|
+
.strict(),
|
|
640
|
+
z
|
|
641
|
+
.object({
|
|
642
|
+
path: absoluteWorkspacePath("path"),
|
|
643
|
+
files: z
|
|
644
|
+
.record(relativeFilePath, z.string().refine(isDefinitionFileHash, { message: "each file is sha256:<64 lowercase hex>" }))
|
|
645
|
+
.refine((files) => Object.keys(files).length >= 1 && Object.keys(files).length <= ENVIRONMENT_FILES_MAX, {
|
|
646
|
+
message: `files names 1 to ${ENVIRONMENT_FILES_MAX} files`,
|
|
647
|
+
}),
|
|
648
|
+
})
|
|
649
|
+
.strict(),
|
|
650
|
+
]);
|
|
651
|
+
/**
|
|
652
|
+
* An environment manifest's name (protocol 14, D63): 1–64 letters, digits, `.`, `_` and `-`,
|
|
653
|
+
* starting with a letter or digit, such as `analyst-box`.
|
|
654
|
+
*/
|
|
655
|
+
const ENVIRONMENT_MANIFEST_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
656
|
+
export function isEnvironmentManifestName(value) {
|
|
657
|
+
return typeof value === "string" && ENVIRONMENT_MANIFEST_NAME_PATTERN.test(value);
|
|
658
|
+
}
|
|
659
|
+
export const EnvironmentManifestNameSchema = z
|
|
660
|
+
.string()
|
|
661
|
+
.refine(isEnvironmentManifestName, {
|
|
662
|
+
message: "An environment manifest's name is 1-64 letters, digits, '.', '_' and '-', starting with a letter or digit",
|
|
642
663
|
})
|
|
643
|
-
.
|
|
664
|
+
.meta({ description: "An environment manifest's name, such as `analyst-box`" });
|
|
665
|
+
/**
|
|
666
|
+
* Which manifest an Environment is made from: `name` (its latest version when the Environment is
|
|
667
|
+
* created) or `name@n` (version `n`). Either way the Environment keeps that version for life.
|
|
668
|
+
*/
|
|
669
|
+
export function parseEnvironmentManifestRef(ref) {
|
|
670
|
+
const at = ref.lastIndexOf("@");
|
|
671
|
+
const name = at < 0 ? ref : ref.slice(0, at);
|
|
672
|
+
if (!isEnvironmentManifestName(name))
|
|
673
|
+
return undefined;
|
|
674
|
+
if (at < 0)
|
|
675
|
+
return { name };
|
|
676
|
+
const version = ref.slice(at + 1);
|
|
677
|
+
return /^[1-9][0-9]{0,8}$/.test(version) ? { name, version: Number(version) } : undefined;
|
|
678
|
+
}
|
|
679
|
+
export const EnvironmentManifestRefSchema = z
|
|
680
|
+
.string()
|
|
681
|
+
.refine((value) => parseEnvironmentManifestRef(value) !== undefined, {
|
|
682
|
+
message: "manifest is an environment manifest's name, or name@version such as analyst-box@3",
|
|
683
|
+
})
|
|
684
|
+
.meta({ description: "`name` (the latest version when the Environment is created) or `name@n`" });
|
|
644
685
|
/**
|
|
645
686
|
* `PUT /v1/environments/{environmentId}`: creates the Environment and its vault, or finds the
|
|
646
|
-
* one with this id, so "get or create" is one call.
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
*
|
|
687
|
+
* one with this id, so "get or create" is one call. An Environment is made from one version of an
|
|
688
|
+
* environment manifest (`manifest`) or from the inline manifest these fields make, and never
|
|
689
|
+
* changes what it runs after that (protocol 14, D63): on an existing one, `labels` replace its
|
|
690
|
+
* labels and `ownerUserId` sets or clears its owner guard, a field that matches what it runs is
|
|
691
|
+
* accepted, and anything else is `409 environment_immutable`, naming the fork that makes a new
|
|
692
|
+
* Environment instead.
|
|
651
693
|
*/
|
|
652
694
|
export const PutEnvironmentRequestSchema = z
|
|
653
695
|
.object({
|
|
654
696
|
requestId: RequestIdSchema.optional(),
|
|
655
|
-
/**
|
|
697
|
+
/**
|
|
698
|
+
* The environment manifest to make the Environment from (Host feature
|
|
699
|
+
* `environment-manifests`): `name` or `name@n`. With it, none of the inline fields below is
|
|
700
|
+
* sent; `labels`, `ownerUserId` and `from` still are.
|
|
701
|
+
*/
|
|
702
|
+
manifest: EnvironmentManifestRefSchema.optional(),
|
|
703
|
+
/** Default `virtual`. `pod` needs sandbox pods (`nylorun local sandbox enable`). Fixed. */
|
|
656
704
|
kind: z.enum(ENVIRONMENT_KINDS).optional(),
|
|
657
705
|
labels: EnvironmentLabelsSchema.optional(),
|
|
658
706
|
/** Pods only: the workload image (default the Tenant's, else `python:3.13-slim`). */
|
|
@@ -691,6 +739,12 @@ export const PutEnvironmentRequestSchema = z
|
|
|
691
739
|
setup: z.array(EnvironmentSetupCommandSchema).max(ENVIRONMENT_SETUP_MAX).optional(),
|
|
692
740
|
/** Pods only: artifact versions copied in when the disk is made or reset, before `setup`. */
|
|
693
741
|
files: z.array(EnvironmentFileSchema).max(ENVIRONMENT_SETUP_MAX).optional(),
|
|
742
|
+
/**
|
|
743
|
+
* The secrets an Environment of this kind needs, by name (D64): each slot's type, binding,
|
|
744
|
+
* whether it is required and a description, never a value. With slots declared, a secret
|
|
745
|
+
* write sends only the value and a name not declared is `409 secret_not_in_manifest`.
|
|
746
|
+
*/
|
|
747
|
+
secrets: z.lazy(() => EnvironmentSecretSlotsSchema).optional(),
|
|
694
748
|
/**
|
|
695
749
|
* Only when the `PUT` creates the Environment (Host feature `environment-disk-versions`): its
|
|
696
750
|
* disk starts from this version of another Environment's disk. Its vault starts empty.
|
|
@@ -704,7 +758,10 @@ export const PutEnvironmentRequestSchema = z
|
|
|
704
758
|
.optional(),
|
|
705
759
|
})
|
|
706
760
|
.strict();
|
|
707
|
-
/**
|
|
761
|
+
/**
|
|
762
|
+
* What an Environment runs (its inline manifest, called the recipe before protocol 14), resolved
|
|
763
|
+
* against the Tenant's limits when it was made. It never changes after that.
|
|
764
|
+
*/
|
|
708
765
|
export const EnvironmentRecipeSchema = z
|
|
709
766
|
.object({
|
|
710
767
|
image: z.string().optional(),
|
|
@@ -715,6 +772,7 @@ export const EnvironmentRecipeSchema = z
|
|
|
715
772
|
lifecycle: EnvironmentLifecycleSchema,
|
|
716
773
|
setup: z.array(EnvironmentSetupCommandSchema).optional(),
|
|
717
774
|
files: z.array(EnvironmentFileSchema).optional(),
|
|
775
|
+
secrets: z.lazy(() => EnvironmentSecretSlotsSchema).optional(),
|
|
718
776
|
})
|
|
719
777
|
.strict();
|
|
720
778
|
/** A session that names an Environment, as the Environment's view lists it. */
|
|
@@ -741,6 +799,11 @@ export const EnvironmentPodViewSchema = z
|
|
|
741
799
|
hostEpoch: z.number().int().nonnegative(),
|
|
742
800
|
/** Why it failed, or was lost. */
|
|
743
801
|
reason: z.string().optional(),
|
|
802
|
+
/**
|
|
803
|
+
* The workload image by digest (`repo@sha256:…`), pinned the first time a pod was ready
|
|
804
|
+
* (Q14): every later pod runs it. Absent before then, or for an image with no repository.
|
|
805
|
+
*/
|
|
806
|
+
imageDigest: z.string().optional(),
|
|
744
807
|
})
|
|
745
808
|
.strict();
|
|
746
809
|
/**
|
|
@@ -755,11 +818,38 @@ export const EnvironmentViewSchema = z
|
|
|
755
818
|
id: z.string(),
|
|
756
819
|
kind: z.enum(ENVIRONMENT_KINDS),
|
|
757
820
|
labels: z.record(z.string(), z.string()),
|
|
758
|
-
/**
|
|
759
|
-
|
|
760
|
-
|
|
821
|
+
/**
|
|
822
|
+
* What it runs, fixed when it was made (protocol 14): its manifest's fields, or the inline
|
|
823
|
+
* ones, resolved against the Tenant's limits.
|
|
824
|
+
*/
|
|
825
|
+
manifest: EnvironmentRecipeSchema,
|
|
826
|
+
/** The environment manifest it was made from and its version, when it was made from one. */
|
|
827
|
+
manifestName: z.string().optional(),
|
|
828
|
+
manifestVersion: z.number().int().positive().optional(),
|
|
829
|
+
/** The hash of what it runs (`manifest`). */
|
|
830
|
+
manifestHash: z.string().optional(),
|
|
831
|
+
/**
|
|
832
|
+
* The Environment it was forked from (`POST .../fork`, Q15), and the disk version it started
|
|
833
|
+
* from (`null` for an empty disk).
|
|
834
|
+
*/
|
|
835
|
+
forkedFrom: z
|
|
836
|
+
.object({ environment: z.string(), disk: z.number().int().positive().nullable() })
|
|
837
|
+
.strict()
|
|
838
|
+
.optional(),
|
|
839
|
+
/** Each secret slot its manifest declares, and whether its vault holds a value for it. */
|
|
840
|
+
slots: z
|
|
841
|
+
.array(z
|
|
842
|
+
.object({
|
|
843
|
+
name: z.string(),
|
|
844
|
+
type: z.string(),
|
|
845
|
+
required: z.boolean(),
|
|
846
|
+
set: z.boolean(),
|
|
847
|
+
})
|
|
848
|
+
.strict())
|
|
849
|
+
.optional(),
|
|
850
|
+
/** Always 1 since protocol 14: an Environment never changes what it runs. */
|
|
761
851
|
version: z.number().int().positive(),
|
|
762
|
-
/**
|
|
852
|
+
/** Always `version`. */
|
|
763
853
|
appliedVersion: z.number().int().positive(),
|
|
764
854
|
/** The owner guard, or `null`. */
|
|
765
855
|
ownerUserId: z.string().nullable(),
|
|
@@ -853,11 +943,16 @@ export const ListEnvironmentsResponseSchema = z
|
|
|
853
943
|
export const DeleteEnvironmentResponseSchema = z
|
|
854
944
|
.object({ id: z.string(), deleted: z.boolean() })
|
|
855
945
|
.strict();
|
|
946
|
+
/** A turn that was running on an Environment when one of its connections opened (D67). */
|
|
947
|
+
export const EgressRunningTurnSchema = z
|
|
948
|
+
.object({ sessionId: z.string(), turnId: z.string() })
|
|
949
|
+
.strict();
|
|
856
950
|
/**
|
|
857
951
|
* One connection a pod Environment opened through egress-gate (track R7, Q6): written when it
|
|
858
|
-
* closes, or at once when the gate refused it
|
|
859
|
-
*
|
|
860
|
-
* Environment's
|
|
952
|
+
* closes, or at once when the gate refused it, to the Environment's own stream as
|
|
953
|
+
* `environment.egress` (D67). The connection is the Environment's: its egress token names the pod,
|
|
954
|
+
* and the Environment's sessions run turns in parallel (D66). `runningTurns` lists the turns
|
|
955
|
+
* active on it as the connection opened, at most 16, as context and never as the owner.
|
|
861
956
|
*
|
|
862
957
|
* `startedAt` is the gate's clock at CONNECT and `durationMs` runs from there to the close, so
|
|
863
958
|
* the span is the gate's own measurement. `bytesUp` is what the sandbox sent, `bytesDown` what it
|
|
@@ -883,6 +978,7 @@ export const EgressConnectionPayloadSchema = z
|
|
|
883
978
|
bytesDown: z.number().int().nonnegative(),
|
|
884
979
|
durationMs: z.number().nonnegative(),
|
|
885
980
|
startedAt: z.string(),
|
|
981
|
+
runningTurns: z.array(EgressRunningTurnSchema).max(16),
|
|
886
982
|
})
|
|
887
983
|
.passthrough();
|
|
888
984
|
/** The schema id of an Environment's lifecycle events (its stream in the record). */
|
|
@@ -899,13 +995,25 @@ export const ENVIRONMENT_EVENT_TYPES = [
|
|
|
899
995
|
"environment.lost",
|
|
900
996
|
"environment.reset",
|
|
901
997
|
"environment.failed",
|
|
902
|
-
//
|
|
998
|
+
// Forked into a new Environment (Q15).
|
|
999
|
+
"environment.forked",
|
|
1000
|
+
// egress-gate: every connection the Environment opens (R7, D67).
|
|
903
1001
|
"environment.egress",
|
|
904
1002
|
];
|
|
905
1003
|
/** The payload of each Environment lifecycle event. */
|
|
906
1004
|
export const ENVIRONMENT_EVENT_PAYLOADS = {
|
|
907
1005
|
"environment.created": z
|
|
908
|
-
.object({
|
|
1006
|
+
.object({
|
|
1007
|
+
kind: z.enum(ENVIRONMENT_KINDS),
|
|
1008
|
+
labels: z.record(z.string(), z.string()),
|
|
1009
|
+
/** The environment manifest and version it was made from (protocol 14, D63). */
|
|
1010
|
+
manifest: z.object({ name: z.string(), version: z.number().int().positive() }).strict().optional(),
|
|
1011
|
+
/** The Environment it was forked from, and the disk version it started from (Q15). */
|
|
1012
|
+
forkedFrom: z
|
|
1013
|
+
.object({ environment: z.string(), disk: z.number().int().positive().nullable() })
|
|
1014
|
+
.strict()
|
|
1015
|
+
.optional(),
|
|
1016
|
+
})
|
|
909
1017
|
.passthrough(),
|
|
910
1018
|
"environment.attached": z.object({ sessionId: z.string() }).passthrough(),
|
|
911
1019
|
"environment.detached": z
|
|
@@ -927,7 +1035,16 @@ export const ENVIRONMENT_EVENT_PAYLOADS = {
|
|
|
927
1035
|
"environment.reset": z.object({ volumeGeneration: z.number().int() }).passthrough(),
|
|
928
1036
|
/** The pod did not become ready. */
|
|
929
1037
|
"environment.failed": z.object({ reason: z.string() }).passthrough(),
|
|
930
|
-
/**
|
|
1038
|
+
/** Forked into Environment `to`: its disk started from version `disk`, `secrets` were copied. */
|
|
1039
|
+
"environment.forked": z
|
|
1040
|
+
.object({
|
|
1041
|
+
to: z.string(),
|
|
1042
|
+
disk: z.number().int().positive().nullable(),
|
|
1043
|
+
manifest: z.object({ name: z.string(), version: z.number().int().positive() }).strict().optional(),
|
|
1044
|
+
secrets: z.number().int().nonnegative(),
|
|
1045
|
+
})
|
|
1046
|
+
.passthrough(),
|
|
1047
|
+
/** A connection through egress-gate, with the turns running as it opened (D67). */
|
|
931
1048
|
"environment.egress": EgressConnectionPayloadSchema,
|
|
932
1049
|
};
|
|
933
1050
|
/** One lifecycle event on an Environment's stream, numbered from 0. */
|
|
@@ -1200,6 +1317,20 @@ export const PutEnvironmentSecretRequestSchema = z.discriminatedUnion("type", [
|
|
|
1200
1317
|
})
|
|
1201
1318
|
.strict(),
|
|
1202
1319
|
]);
|
|
1320
|
+
/**
|
|
1321
|
+
* A secret write on an Environment whose manifest declares the secret's slot (D64): only the
|
|
1322
|
+
* value, `value` (or `headers` for a `headers` slot). Its type and binding come from the slot.
|
|
1323
|
+
*/
|
|
1324
|
+
export const PutEnvironmentSecretValueRequestSchema = z
|
|
1325
|
+
.object({
|
|
1326
|
+
requestId: RequestIdSchema.optional(),
|
|
1327
|
+
value: z.string().min(1).max(8192).optional(),
|
|
1328
|
+
headers: CredentialHeadersSchema.optional(),
|
|
1329
|
+
})
|
|
1330
|
+
.strict()
|
|
1331
|
+
.refine((body) => (body.value === undefined) !== (body.headers === undefined), {
|
|
1332
|
+
message: "Send value, or headers for a headers secret",
|
|
1333
|
+
});
|
|
1203
1334
|
/** Whether `name` may name a secret of `type` (`PUT .../secrets/{name}`); a message when not. */
|
|
1204
1335
|
export function environmentSecretNameError(type, name) {
|
|
1205
1336
|
if (type === "environment_secret" || type === "environment_variable") {
|
|
@@ -1213,16 +1344,221 @@ export function environmentSecretNameError(type, name) {
|
|
|
1213
1344
|
? undefined
|
|
1214
1345
|
: "A credential name is 1-64 letters, digits, '.', '_' and '-'";
|
|
1215
1346
|
}
|
|
1347
|
+
// --- Environment manifests (protocol 14, D63 to D65) -----------------------------------------
|
|
1348
|
+
const slotBase = {
|
|
1349
|
+
/** Whether a session whose agent needs it may open without it. Default false. */
|
|
1350
|
+
required: z.boolean().optional(),
|
|
1351
|
+
description: z.string().max(500).optional(),
|
|
1352
|
+
};
|
|
1353
|
+
/**
|
|
1354
|
+
* One secret an Environment of a kind needs (D64): its type and binding, never its value. The
|
|
1355
|
+
* value is written into each Environment's vault (`PUT /v1/environments/{id}/secrets/{name}`
|
|
1356
|
+
* with `{ value }`, or `{ headers }` for `headers`), and the binding comes from here.
|
|
1357
|
+
*/
|
|
1358
|
+
export const EnvironmentSecretSlotSchema = z.discriminatedUnion("type", [
|
|
1359
|
+
z
|
|
1360
|
+
.object({
|
|
1361
|
+
type: z.literal("environment_secret"),
|
|
1362
|
+
allowedHosts: AllowedHostsSchema,
|
|
1363
|
+
inject: EnvironmentSecretInjectSchema.optional(),
|
|
1364
|
+
...slotBase,
|
|
1365
|
+
})
|
|
1366
|
+
.strict(),
|
|
1367
|
+
z.object({ type: z.literal("environment_variable"), ...slotBase }).strict(),
|
|
1368
|
+
z.object({ type: z.literal("bearer"), url: z.string().min(1), ...credentialRouting, ...slotBase }).strict(),
|
|
1369
|
+
z.object({ type: z.literal("headers"), url: z.string().min(1), ...credentialRouting, ...slotBase }).strict(),
|
|
1370
|
+
]);
|
|
1371
|
+
/** The most secret slots one manifest declares. */
|
|
1372
|
+
export const ENVIRONMENT_SECRET_SLOTS_MAX = 64;
|
|
1373
|
+
export const EnvironmentSecretSlotsSchema = z
|
|
1374
|
+
.record(z.string(), EnvironmentSecretSlotSchema)
|
|
1375
|
+
.superRefine((slots, ctx) => {
|
|
1376
|
+
const names = Object.keys(slots);
|
|
1377
|
+
if (names.length > ENVIRONMENT_SECRET_SLOTS_MAX)
|
|
1378
|
+
ctx.addIssue({ code: "custom", message: `At most ${ENVIRONMENT_SECRET_SLOTS_MAX} secrets` });
|
|
1379
|
+
for (const name of names) {
|
|
1380
|
+
const error = environmentSecretNameError(slots[name].type, name);
|
|
1381
|
+
if (error)
|
|
1382
|
+
ctx.addIssue({ code: "custom", path: [name], message: error });
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
/** The schema version of an environment manifest; the Runtime refuses one it does not know. */
|
|
1386
|
+
export const ENVIRONMENT_MANIFEST_SCHEMA_VERSION = 1;
|
|
1387
|
+
const environmentFields = PutEnvironmentRequestSchema.shape;
|
|
1388
|
+
/**
|
|
1389
|
+
* An environment manifest (protocol 14, D63): a named, versioned definition of a kind of
|
|
1390
|
+
* Environment, saved like an agent (`PUT /v1/environment-manifests/{name}`). It holds what every
|
|
1391
|
+
* Environment made from it shares; an Environment's id, labels, owner guard, disk and secret
|
|
1392
|
+
* values are its own. Written as a JSON file with `$schema`, which clients drop before saving.
|
|
1393
|
+
*/
|
|
1394
|
+
export const EnvironmentManifestSchema = z
|
|
1395
|
+
.object({
|
|
1396
|
+
manifestSchemaVersion: z.literal(ENVIRONMENT_MANIFEST_SCHEMA_VERSION, {
|
|
1397
|
+
error: (issue) => `manifestSchemaVersion ${JSON.stringify(issue.input)} is not one this Runtime reads: use ${ENVIRONMENT_MANIFEST_SCHEMA_VERSION}`,
|
|
1398
|
+
}),
|
|
1399
|
+
name: EnvironmentManifestNameSchema,
|
|
1400
|
+
description: z.string().max(1024).optional(),
|
|
1401
|
+
kind: environmentFields.kind,
|
|
1402
|
+
image: environmentFields.image,
|
|
1403
|
+
resources: environmentFields.resources,
|
|
1404
|
+
storage: environmentFields.storage,
|
|
1405
|
+
network: environmentFields.network,
|
|
1406
|
+
harness: environmentFields.harness,
|
|
1407
|
+
lifecycle: environmentFields.lifecycle,
|
|
1408
|
+
setup: environmentFields.setup,
|
|
1409
|
+
files: environmentFields.files,
|
|
1410
|
+
secrets: EnvironmentSecretSlotsSchema.optional(),
|
|
1411
|
+
})
|
|
1412
|
+
.strict();
|
|
1413
|
+
/** `PUT /v1/environment-manifests/{name}`: the manifest, whose `name` is the path's. */
|
|
1414
|
+
export const PutEnvironmentManifestRequestSchema = EnvironmentManifestSchema.extend({
|
|
1415
|
+
requestId: RequestIdSchema.optional(),
|
|
1416
|
+
}).strict();
|
|
1417
|
+
/** Who saved a version: the subject a request acted for, else `application`. */
|
|
1418
|
+
export const EnvironmentManifestSavedBySchema = z.object({ actor: z.string() }).strict();
|
|
1419
|
+
/** One version of an environment manifest. */
|
|
1420
|
+
export const EnvironmentManifestViewSchema = z
|
|
1421
|
+
.object({
|
|
1422
|
+
name: z.string(),
|
|
1423
|
+
version: z.number().int().positive(),
|
|
1424
|
+
/** The hash of `manifest`: equal manifests have equal hashes. */
|
|
1425
|
+
hash: z.string(),
|
|
1426
|
+
manifest: EnvironmentManifestSchema,
|
|
1427
|
+
savedBy: EnvironmentManifestSavedBySchema,
|
|
1428
|
+
createdAt: z.string(),
|
|
1429
|
+
/** How many Environments were made from this version. */
|
|
1430
|
+
environments: z.number().int().nonnegative(),
|
|
1431
|
+
})
|
|
1432
|
+
.strict();
|
|
1433
|
+
/** `GET /v1/environment-manifests`: each manifest's latest version, by name. */
|
|
1434
|
+
export const ListEnvironmentManifestsResponseSchema = z
|
|
1435
|
+
.object({ manifests: z.array(EnvironmentManifestViewSchema) })
|
|
1436
|
+
.strict();
|
|
1437
|
+
/** `GET /v1/environment-manifests/{name}/versions`: every version, newest first. */
|
|
1438
|
+
export const EnvironmentManifestVersionsSchema = z
|
|
1439
|
+
.object({
|
|
1440
|
+
name: z.string(),
|
|
1441
|
+
latest: z.number().int().positive(),
|
|
1442
|
+
versions: z.array(z
|
|
1443
|
+
.object({
|
|
1444
|
+
version: z.number().int().positive(),
|
|
1445
|
+
hash: z.string(),
|
|
1446
|
+
savedBy: EnvironmentManifestSavedBySchema,
|
|
1447
|
+
createdAt: z.string(),
|
|
1448
|
+
environments: z.number().int().nonnegative(),
|
|
1449
|
+
})
|
|
1450
|
+
.strict()),
|
|
1451
|
+
})
|
|
1452
|
+
.strict();
|
|
1453
|
+
/** Something a save would do that the saver should know: never a refusal. */
|
|
1454
|
+
export const EnvironmentManifestWarningSchema = z
|
|
1455
|
+
.object({ code: z.string(), message: z.string() })
|
|
1456
|
+
.strict();
|
|
1457
|
+
/**
|
|
1458
|
+
* `PUT /v1/environment-manifests/{name}?dryRun=true`: what saving it would do, with nothing
|
|
1459
|
+
* saved. `errors` lists every reason the Runtime would refuse it (the Tenant's limits, for one);
|
|
1460
|
+
* a save with errors is `400`. `behind` counts the Environments made from an older version than
|
|
1461
|
+
* the one it would save. No Environment changes when a version is saved (D63).
|
|
1462
|
+
*/
|
|
1463
|
+
export const EnvironmentManifestPlanSchema = z
|
|
1464
|
+
.object({
|
|
1465
|
+
name: z.string(),
|
|
1466
|
+
/** The latest version now, or `null` for a new manifest. */
|
|
1467
|
+
from: z.number().int().positive().nullable(),
|
|
1468
|
+
/** The version a save would answer: `from` when nothing changed. */
|
|
1469
|
+
to: z.number().int().positive(),
|
|
1470
|
+
unchanged: z.boolean(),
|
|
1471
|
+
changes: z.array(z.object({ path: z.string(), from: z.unknown().optional(), to: z.unknown().optional() }).strict()),
|
|
1472
|
+
warnings: z.array(EnvironmentManifestWarningSchema),
|
|
1473
|
+
errors: z.array(z.string()),
|
|
1474
|
+
behind: z.number().int().nonnegative(),
|
|
1475
|
+
})
|
|
1476
|
+
.strict();
|
|
1477
|
+
/** `PUT /v1/environment-manifests/{name}`: the version saved (or the latest, unchanged). */
|
|
1478
|
+
export const SaveEnvironmentManifestResponseSchema = z
|
|
1479
|
+
.object({
|
|
1480
|
+
manifest: EnvironmentManifestViewSchema,
|
|
1481
|
+
unchanged: z.boolean(),
|
|
1482
|
+
warnings: z.array(EnvironmentManifestWarningSchema),
|
|
1483
|
+
})
|
|
1484
|
+
.strict();
|
|
1485
|
+
export const DeleteEnvironmentManifestResponseSchema = z
|
|
1486
|
+
.object({ name: z.string(), deleted: z.boolean() })
|
|
1487
|
+
.strict();
|
|
1488
|
+
/**
|
|
1489
|
+
* `POST /v1/environments/{id}/fork` (Q15): how an Environment gets a new manifest version. The
|
|
1490
|
+
* fork is a new Environment, made from the version, its disk started from a version of the
|
|
1491
|
+
* source's disk and its secrets copied inside the Runtime. The source keeps what it runs, its
|
|
1492
|
+
* disk and its sessions.
|
|
1493
|
+
*/
|
|
1494
|
+
export const ForkEnvironmentRequestSchema = z
|
|
1495
|
+
.object({
|
|
1496
|
+
requestId: RequestIdSchema.optional(),
|
|
1497
|
+
/** The new Environment's id. */
|
|
1498
|
+
id: EnvironmentIdSchema,
|
|
1499
|
+
/** `name` or `name@n`; default the source's manifest at its latest version. */
|
|
1500
|
+
manifest: EnvironmentManifestRefSchema.optional(),
|
|
1501
|
+
/** Where its disk starts: `latest` (a snapshot taken first; the default), a version, or `empty`. */
|
|
1502
|
+
disk: z.union([z.literal("latest"), z.literal("empty"), z.number().int().positive()]).optional(),
|
|
1503
|
+
/** `copy` (the default): the source's secrets the new manifest declares (all, without slots). */
|
|
1504
|
+
secrets: z.enum(["copy", "none"]).optional(),
|
|
1505
|
+
labels: EnvironmentLabelsSchema.optional(),
|
|
1506
|
+
ownerUserId: z.string().min(1).nullable().optional(),
|
|
1507
|
+
/** Answer the plan and make nothing. */
|
|
1508
|
+
dryRun: z.boolean().optional(),
|
|
1509
|
+
})
|
|
1510
|
+
.strict();
|
|
1511
|
+
/** What a fork does (or, with `dryRun`, would do). */
|
|
1512
|
+
export const EnvironmentForkPlanSchema = z
|
|
1513
|
+
.object({
|
|
1514
|
+
source: z.string(),
|
|
1515
|
+
id: z.string(),
|
|
1516
|
+
kind: z.enum(ENVIRONMENT_KINDS),
|
|
1517
|
+
/** The manifest version it is made from, or `null` for the source's inline fields. */
|
|
1518
|
+
manifest: z.object({ name: z.string(), version: z.number().int().positive() }).strict().nullable(),
|
|
1519
|
+
/** The disk version it starts from: `latest` in a dry run (the snapshot is taken at the fork); `null` for an empty disk. */
|
|
1520
|
+
disk: z.union([z.number().int().positive(), z.literal("latest")]).nullable(),
|
|
1521
|
+
/** Whether the new manifest's setup runs on the copied disk: it differs from what the source runs. */
|
|
1522
|
+
setup: z.boolean(),
|
|
1523
|
+
secrets: z
|
|
1524
|
+
.object({
|
|
1525
|
+
/** Copied, by name. */
|
|
1526
|
+
copied: z.array(z.string()),
|
|
1527
|
+
/** The source's secrets the new manifest does not declare: left behind. */
|
|
1528
|
+
dropped: z.array(z.string()),
|
|
1529
|
+
/** Required slots of the new manifest no copied secret fills. */
|
|
1530
|
+
missing: z.array(z.string()),
|
|
1531
|
+
})
|
|
1532
|
+
.strict(),
|
|
1533
|
+
/** How what it runs differs from what the source runs. */
|
|
1534
|
+
changes: z.array(z.object({ path: z.string(), from: z.unknown().optional(), to: z.unknown().optional() }).strict()),
|
|
1535
|
+
/** The source's sessions: they stay on it. */
|
|
1536
|
+
sessions: z.number().int().nonnegative(),
|
|
1537
|
+
})
|
|
1538
|
+
.strict();
|
|
1539
|
+
/** `POST /v1/environments/{id}/fork`: the new Environment and the plan it ran, or with `dryRun` the plan only. */
|
|
1540
|
+
export const ForkEnvironmentResponseSchema = z.union([
|
|
1541
|
+
z.object({ dryRun: z.literal(true), plan: EnvironmentForkPlanSchema }).strict(),
|
|
1542
|
+
z.object({ environment: EnvironmentViewSchema, plan: EnvironmentForkPlanSchema }).strict(),
|
|
1543
|
+
]);
|
|
1544
|
+
/**
|
|
1545
|
+
* What a model may read (protocol 12): `text` always; `image`, `pdf`, `office` (Word, Excel,
|
|
1546
|
+
* PowerPoint), `audio` and `video` when its catalog entry or the operator says so. In this order.
|
|
1547
|
+
*/
|
|
1548
|
+
export const MODEL_INPUTS = ["text", "image", "pdf", "office", "audio", "video"];
|
|
1549
|
+
export const ModelInputSchema = z.enum(MODEL_INPUTS);
|
|
1216
1550
|
/**
|
|
1217
1551
|
* What the Runtime cannot learn from a custom OpenAI-compatible endpoint (Model Calls §7):
|
|
1218
|
-
* its context window and output limit, whether it reasons,
|
|
1219
|
-
* (`thinkingFormat`, `thinkingTokenBudgetField`,
|
|
1552
|
+
* its context window and output limit, whether it reasons, what it reads (`inputs`; default text
|
|
1553
|
+
* only) and pi-ai `compat` settings (`thinkingFormat`, `thinkingTokenBudgetField`,
|
|
1554
|
+
* `chatTemplateKwargs`, …).
|
|
1220
1555
|
*/
|
|
1221
1556
|
export const CustomModelSettingsSchema = z
|
|
1222
1557
|
.object({
|
|
1223
1558
|
contextWindow: z.number().int().min(1024).optional(),
|
|
1224
1559
|
maxTokens: z.number().int().min(1).optional(),
|
|
1225
1560
|
reasoning: z.boolean().optional(),
|
|
1561
|
+
inputs: z.array(ModelInputSchema).optional(),
|
|
1226
1562
|
compat: z.record(z.string(), z.unknown()).optional(),
|
|
1227
1563
|
})
|
|
1228
1564
|
.strict();
|
|
@@ -1757,7 +2093,12 @@ export const ContextCompactedPayloadSchema = z
|
|
|
1757
2093
|
/** How a tool call ended (R5.1): the tool answered, the Runtime ended it, or a cancel did. */
|
|
1758
2094
|
export const TOOL_CALL_STATUSES = ["completed", "failed", "cancelled"];
|
|
1759
2095
|
/** Where a tool call ran (R5.1): a remote MCP server, an HTTP tool, the sandbox, or core. */
|
|
1760
|
-
|
|
2096
|
+
/**
|
|
2097
|
+
* Where a tool call runs: an MCP server, an HTTP tool's URL, the session's sandbox, the Runtime
|
|
2098
|
+
* itself (`platform`: the artifact, skill and deferred-tool tools), or the harness that runs the
|
|
2099
|
+
* turn (`harness`: a tool it declared in `hello.features.tools`).
|
|
2100
|
+
*/
|
|
2101
|
+
export const TOOL_CALL_KINDS = ["mcp", "http", "sandbox", "platform", "harness"];
|
|
1761
2102
|
/**
|
|
1762
2103
|
* What the Tenant's tool policy did with a tool call (R5 step 2), when it did more than allow
|
|
1763
2104
|
* it: `deny` refused it unsent; `ask` held it for a person, who approved it (`approvedBy`, when
|
|
@@ -1783,12 +2124,18 @@ export const ToolCompletedPayloadSchema = z
|
|
|
1783
2124
|
...toolIds,
|
|
1784
2125
|
/** The tool call's effect id (R7.1). */
|
|
1785
2126
|
effectId: z.string().min(1).optional(),
|
|
1786
|
-
capabilityId: z.string().min(1),
|
|
1787
2127
|
toolName: z.string().min(1),
|
|
1788
2128
|
status: z.enum(TOOL_CALL_STATUSES).optional(),
|
|
1789
2129
|
kind: z.enum(TOOL_CALL_KINDS).optional(),
|
|
1790
|
-
/** The MCP server, or the HTTP tool's
|
|
2130
|
+
/** The MCP server, or the HTTP tool's URL host. */
|
|
1791
2131
|
server: z.string().min(1).optional(),
|
|
2132
|
+
/**
|
|
2133
|
+
* The skill the call ran: `load_skill` and `read_skill_resource` name it, and a sandbox tool
|
|
2134
|
+
* whose input names its folder, `/skills/<name>@<hash>/`, ran its files.
|
|
2135
|
+
*/
|
|
2136
|
+
skill: z.string().min(1).optional(),
|
|
2137
|
+
/** The Agent Plugin that brought the call's MCP server or skill. */
|
|
2138
|
+
plugin: pluginLabelSchema.optional(),
|
|
1792
2139
|
/** How many times the call was sent: 0 when the Runtime refused it, above 1 after a crash re-sent it. */
|
|
1793
2140
|
attempts: z.number().int().nonnegative().optional(),
|
|
1794
2141
|
/** From the first send to the outcome; absent when the call never ran. */
|
|
@@ -2118,8 +2465,9 @@ export const McpServerOutcomeSchema = z
|
|
|
2118
2465
|
.object({
|
|
2119
2466
|
/** The agent used as a tool that declares the server; absent for the session's root agent. */
|
|
2120
2467
|
agentId: z.string().optional(),
|
|
2121
|
-
capabilityId: z.string(),
|
|
2122
2468
|
serverName: z.string(),
|
|
2469
|
+
/** The Agent Plugin that brought the server. */
|
|
2470
|
+
plugin: pluginLabelSchema.optional(),
|
|
2123
2471
|
/** `refused`: the vault has no usable credential for it; `failed`: it could not be reached or listed. */
|
|
2124
2472
|
outcome: z.enum(["connected", "refused", "failed"]),
|
|
2125
2473
|
message: z.string(),
|
|
@@ -2186,7 +2534,6 @@ export const EVENT_CATALOG = {
|
|
|
2186
2534
|
"environment.state": { payload: EnvironmentStatePayloadSchema, source: "loop", version: 1 },
|
|
2187
2535
|
"environment.exec": { payload: EnvironmentExecPayloadSchema, source: "loop", version: 1 },
|
|
2188
2536
|
"environment.attached": { payload: EnvironmentAttachedPayloadSchema, source: "api", version: 1 },
|
|
2189
|
-
"egress.connection": { payload: EgressConnectionPayloadSchema, source: "egress-gate", version: 1 },
|
|
2190
2537
|
"node.started": { payload: NodeStartedPayloadSchema, source: "loop", version: 1 },
|
|
2191
2538
|
"node.completed": { payload: NodeCompletedPayloadSchema, source: "loop", version: 1 },
|
|
2192
2539
|
"node.agent": { payload: NodeAgentPayloadSchema, source: "loop", version: 1 },
|
|
@@ -2760,6 +3107,8 @@ export const PutAgentResponseSchema = z
|
|
|
2760
3107
|
agentId: z.string(),
|
|
2761
3108
|
manifestHash: z.string(),
|
|
2762
3109
|
implementationVersion: z.string(),
|
|
3110
|
+
/** True for `?dryRun=true` (protocol 14): every check ran, and nothing was saved. */
|
|
3111
|
+
dryRun: z.boolean().optional(),
|
|
2763
3112
|
})
|
|
2764
3113
|
.strict();
|
|
2765
3114
|
export const SESSION_STATUSES = [
|
|
@@ -2794,8 +3143,8 @@ export const SessionViewSchema = z
|
|
|
2794
3143
|
manifestHash: z.string(),
|
|
2795
3144
|
/**
|
|
2796
3145
|
* The hash of the definition the session was opened from (R2b C11). `manifestHash` differs
|
|
2797
|
-
* from it when the Runtime pinned its
|
|
2798
|
-
* tools and
|
|
3146
|
+
* from it when the Runtime pinned its `runtime` block on the definition: a sandbox's tools,
|
|
3147
|
+
* the artifact tools and the skill tools. Compare this one with the registered
|
|
2799
3148
|
* definition's hash. Absent for a session opened before this release.
|
|
2800
3149
|
*/
|
|
2801
3150
|
definitionHash: z.string().optional(),
|
|
@@ -2816,8 +3165,9 @@ export const SessionViewSchema = z
|
|
|
2816
3165
|
*/
|
|
2817
3166
|
harness: z.string(),
|
|
2818
3167
|
/**
|
|
2819
|
-
* Why the session takes no new turn, when it is closed: `
|
|
2820
|
-
* before protocol 11 (a new turn is
|
|
3168
|
+
* Why the session takes no new turn, when it is closed: `protocol_13` for a session opened
|
|
3169
|
+
* before protocol 13, `protocol_11` for one opened before protocol 11 (a new turn is
|
|
3170
|
+
* `409 session_closed`; its history stays readable).
|
|
2821
3171
|
*/
|
|
2822
3172
|
closedReason: z.string().optional(),
|
|
2823
3173
|
mcpSnapshot: z.record(z.string(), z.unknown()).nullable(),
|
|
@@ -2843,14 +3193,25 @@ export const SandboxToolOutcomeSchema = z.discriminatedUnion("kind", [
|
|
|
2843
3193
|
.strict(),
|
|
2844
3194
|
]);
|
|
2845
3195
|
export const ResetTenantResponseSchema = z.object({ ok: z.literal(true) }).strict();
|
|
2846
|
-
/**
|
|
3196
|
+
/**
|
|
3197
|
+
* `GET /v1/tenant/models`: public provider and model names, no credentials. Each model says what
|
|
3198
|
+
* it reads (`inputs`: its catalog's list and the operator's additions) and what the operator may
|
|
3199
|
+
* add (`addableInputs`, protocol 12).
|
|
3200
|
+
*/
|
|
2847
3201
|
export const HostModelCatalogSchema = z
|
|
2848
3202
|
.object({
|
|
2849
3203
|
providers: z.array(z
|
|
2850
3204
|
.object({
|
|
2851
3205
|
id: z.string(),
|
|
2852
3206
|
name: z.string(),
|
|
2853
|
-
models: z.array(z
|
|
3207
|
+
models: z.array(z
|
|
3208
|
+
.object({
|
|
3209
|
+
id: z.string(),
|
|
3210
|
+
name: z.string(),
|
|
3211
|
+
inputs: z.array(ModelInputSchema),
|
|
3212
|
+
addableInputs: z.array(ModelInputSchema),
|
|
3213
|
+
})
|
|
3214
|
+
.strict()),
|
|
2854
3215
|
})
|
|
2855
3216
|
.strict()),
|
|
2856
3217
|
})
|
|
@@ -2863,10 +3224,33 @@ export const HostModelProviderInfoSchema = z
|
|
|
2863
3224
|
authType: z.enum(["api_key", "oauth"]),
|
|
2864
3225
|
baseUrl: z.string().optional(),
|
|
2865
3226
|
settings: CustomModelSettingsSchema.optional(),
|
|
3227
|
+
/** What the provider's selected model reads (protocol 12); absent for a model unknown here. */
|
|
3228
|
+
inputs: z.array(ModelInputSchema).optional(),
|
|
2866
3229
|
lastUpdated: z.string(),
|
|
2867
3230
|
active: z.boolean(),
|
|
2868
3231
|
})
|
|
2869
3232
|
.strict();
|
|
3233
|
+
/**
|
|
3234
|
+
* `PUT /v1/tenant/models/inputs`: the inputs one catalog model reads (protocol 12), replacing
|
|
3235
|
+
* what the operator added before. Its catalog's own inputs always stay; an empty list removes
|
|
3236
|
+
* the additions. A custom endpoint sets `settings.inputs` on `PUT /v1/tenant/model` instead.
|
|
3237
|
+
*/
|
|
3238
|
+
export const PutModelInputsRequestSchema = z
|
|
3239
|
+
.object({
|
|
3240
|
+
requestId: RequestIdSchema.optional(),
|
|
3241
|
+
provider: z.string().min(1),
|
|
3242
|
+
model: z.string().min(1),
|
|
3243
|
+
inputs: z.array(ModelInputSchema),
|
|
3244
|
+
})
|
|
3245
|
+
.strict();
|
|
3246
|
+
/** What one catalog model reads now: its catalog's inputs and the operator's additions. */
|
|
3247
|
+
export const ModelInputsViewSchema = z
|
|
3248
|
+
.object({
|
|
3249
|
+
provider: z.string(),
|
|
3250
|
+
model: z.string(),
|
|
3251
|
+
inputs: z.array(ModelInputSchema),
|
|
3252
|
+
})
|
|
3253
|
+
.strict();
|
|
2870
3254
|
export const ListProvidersResponseSchema = z
|
|
2871
3255
|
.object({ providers: z.array(HostModelProviderInfoSchema) })
|
|
2872
3256
|
.strict();
|
|
@@ -2915,7 +3299,7 @@ export const TenantSandboxViewSchema = z
|
|
|
2915
3299
|
defaultImage: z.string(),
|
|
2916
3300
|
config: EffectiveSandboxConfigSchema,
|
|
2917
3301
|
/**
|
|
2918
|
-
* The Tenant's cluster for pod sandboxes (`nylorun sandbox enable`), as the sandboxes
|
|
3302
|
+
* The Tenant's cluster for pod sandboxes (`nylorun local sandbox enable`), as the sandboxes
|
|
2919
3303
|
* service reports it; null without one, or when the service does not answer.
|
|
2920
3304
|
*/
|
|
2921
3305
|
cluster: z
|
|
@@ -3492,10 +3876,13 @@ export const ToolCallSchema = z
|
|
|
3492
3876
|
effectId: z.string(),
|
|
3493
3877
|
turnId: z.string(),
|
|
3494
3878
|
callId: z.string().nullable(),
|
|
3495
|
-
capabilityId: z.string().nullable(),
|
|
3496
3879
|
toolName: z.string().nullable(),
|
|
3497
3880
|
kind: z.enum(TOOL_CALL_KINDS).nullable(),
|
|
3498
3881
|
server: z.string().nullable(),
|
|
3882
|
+
/** The skill the call ran (see `tool.completed`). */
|
|
3883
|
+
skill: z.string().nullable(),
|
|
3884
|
+
/** The Agent Plugin that brought its MCP server or skill. */
|
|
3885
|
+
plugin: pluginLabelSchema.nullable(),
|
|
3499
3886
|
/** `held`: the Tool Gate holds it for a person's approval (R5 step 2). */
|
|
3500
3887
|
status: z.enum(["invoking", "held", ...TOOL_CALL_STATUSES, "uncertain"]),
|
|
3501
3888
|
attempts: z.number().int().nonnegative(),
|