@nylorun/core 0.23.0-beta → 0.25.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/dist/compatibility.d.ts +127 -59
- package/dist/compatibility.js +128 -60
- package/dist/contracts.d.ts +2413 -893
- package/dist/contracts.js +1144 -491
- package/dist/define.d.ts +1 -0
- package/dist/define.js +1 -0
- package/dist/definition/approval.d.ts +1 -1
- package/dist/definition/bound.d.ts +2 -0
- package/dist/definition/builder.d.ts +2 -2
- package/dist/definition/builder.js +1 -1
- package/dist/definition/code-tools.d.ts +1 -1
- package/dist/definition/declaration.js +3 -0
- package/dist/definition/delegate.d.ts +1 -1
- package/dist/definition/delegate.js +1 -1
- package/dist/definition/from.d.ts +2 -2
- package/dist/definition/from.js +1 -1
- package/dist/definition/http-tool.d.ts +3 -3
- package/dist/definition/mcp.d.ts +4 -4
- package/dist/definition/mcp.js +3 -3
- package/dist/definition/removed.d.ts +7 -0
- package/dist/definition/removed.js +21 -1
- package/dist/definition/sections.d.ts +64 -0
- package/dist/definition/sections.js +227 -0
- package/dist/definition/variant.d.ts +1 -1
- package/dist/definition/variant.js +4 -4
- package/dist/harness-api/entries.d.ts +1 -1
- package/dist/harness-api/entries.js +1 -1
- package/dist/harness-api/gates.d.ts +1 -1
- package/dist/harness-api/gates.js +1 -1
- package/dist/harness-api/harness-api.schema.json +182 -6
- package/dist/harness-api/index.d.ts +3 -3
- package/dist/harness-api/index.js +3 -3
- package/dist/harness-api/json-schema.d.ts +1 -1
- package/dist/harness-api/json-schema.js +3 -3
- package/dist/harness-api/mcp.js +1 -1
- package/dist/harness-api/messages.d.ts +10 -8
- package/dist/harness-api/messages.js +1 -1
- package/dist/harness-api/schema.d.ts +82 -13
- package/dist/harness-api/schema.js +63 -19
- package/dist/harness-api/transcript.d.ts +1 -1
- package/dist/harness-api/transport.d.ts +1 -1
- package/dist/harness-api/transport.js +1 -1
- package/dist/manifest-schemas.d.ts +9 -5
- package/dist/manifest-schemas.js +24 -27
- package/dist/schemas/agent-manifest.schema.json +1534 -250
- package/dist/schemas/harness-manifest.schema.json +1273 -0
- package/dist/schemas/{environment-manifest.schema.json → runtime-manifest.schema.json} +109 -68
- package/dist/types/manifest.d.ts +87 -15
- package/dist/types/manifest.js +4 -0
- package/dist/types/model.d.ts +5 -0
- package/dist/types/observe.d.ts +1 -1
- package/dist/types/part.d.ts +5 -0
- package/dist/types/tool.d.ts +4 -4
- package/dist/utils/definition-files.d.ts +3 -2
- package/dist/utils/definition-files.js +4 -3
- package/dist/utils/file-systems.d.ts +1 -1
- package/dist/utils/file-systems.js +1 -1
- package/dist/utils/harness-id.d.ts +1 -1
- package/dist/utils/harness-id.js +1 -1
- package/dist/utils/memory.d.ts +64 -0
- package/dist/utils/memory.js +139 -0
- package/dist/utils/runtime-limits.d.ts +55 -4
- package/dist/utils/runtime-limits.js +106 -3
- package/dist/utils/runtime-tools.d.ts +3 -3
- package/dist/utils/runtime-tools.js +3 -3
- package/package.json +6 -5
package/dist/contracts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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, isSandboxHostPattern, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
|
|
4
|
-
import { REMOVED_MANIFEST_FIELDS, manifestVersionIssue, workflowVersionIssue, } from "./definition/removed.js";
|
|
4
|
+
import { REMOVED_MANIFEST_FIELDS, REMOVED_RUNTIME_SECTION_FIELDS, agentManifestVersionIssue, manifestVersionIssue, workflowVersionIssue, } from "./definition/removed.js";
|
|
5
5
|
import { DELEGATE_INPUT_SCHEMA, DELEGATE_NAME_PATTERN } from "./definition/delegate.js";
|
|
6
6
|
import { stdioMcpRefusal } from "./definition/mcp.js";
|
|
7
7
|
import { APPROVAL_MODES, HTTP_TOOL_METHODS, httpInputIssue, httpUrlIssue, httpUrlTemplateIssue, httpVerifierIssue, } from "./definition/http-tool.js";
|
|
@@ -11,6 +11,8 @@ export { FILE_NAME_MAX, FILE_PATH_MAX } from "./utils/file-systems.js";
|
|
|
11
11
|
import { DEFAULT_HARNESS, HARNESS_ID_PATTERN, isHarnessId } from "./utils/harness-id.js";
|
|
12
12
|
export { DEFAULT_HARNESS, HARNESS_ID_PATTERN, isHarnessId };
|
|
13
13
|
import { isDefinitionFileHash, skillFilesIssue } from "./utils/definition-files.js";
|
|
14
|
+
import { MEMORY_ACCESS, MEMORY_INSTRUCTIONS_MAX, MEMORY_OPERATIONS } from "./utils/memory.js";
|
|
15
|
+
export { MEMORY_ACCESS, MEMORY_COMMANDS, MEMORY_DESCRIPTION_MAX, MEMORY_INSTRUCTIONS_MAX, MEMORY_OPERATIONS, MEMORY_PATH_MAX, MEMORY_ROOT, checkMemoryCall, memoryAliasOf, memoryDescriptionOf, memoryPathOf, memoryPathWithin, } from "./utils/memory.js";
|
|
14
16
|
export { PROTOCOL_VERSION, ERROR_CODES } from "./compatibility.js";
|
|
15
17
|
export { SKILL_TOTAL_BYTES_DEFAULT, definitionFilesOf, isDefinitionFileHash, skillsOf, } from "./utils/definition-files.js";
|
|
16
18
|
export { HARNESS_LIMIT_DEFAULTS, HarnessLimitsSchema, JS_STRING_MAX_LENGTH, RECORD_ENVELOPE_RESERVE_BYTES, RUNTIME_LIMIT_CEILINGS, RUNTIME_LIMIT_DEFAULTS, RuntimeLimitsSchema, S2_RECORD_MAX_BYTES, TIMER_MAX_MS, harnessLimitsOf, inlineBodyBytes, limitExceededMessage, runtimeLimitIssues, runtimeLimitsOf, } from "./utils/runtime-limits.js";
|
|
@@ -39,7 +41,7 @@ const jsonValue = z
|
|
|
39
41
|
]))
|
|
40
42
|
.meta({ id: "JsonValue" });
|
|
41
43
|
/**
|
|
42
|
-
* A name the model sees in a tool name
|
|
44
|
+
* A name the model sees in a tool name: a declared tool's, or an MCP server's, which
|
|
43
45
|
* prefixes its tools' names. Letters, digits, `_` and `-`, up to 64: what every provider accepts.
|
|
44
46
|
*/
|
|
45
47
|
const modelFacingName = (what) => z.string().regex(DELEGATE_NAME_PATTERN, {
|
|
@@ -50,7 +52,7 @@ const pluginLabelSchema = z
|
|
|
50
52
|
.object({ name: z.string().min(1), version: z.string().min(1).optional() })
|
|
51
53
|
.strict()
|
|
52
54
|
.meta({ id: "PluginLabel" });
|
|
53
|
-
/** One tool's settings on an MCP server
|
|
55
|
+
/** One tool's settings on an MCP server. */
|
|
54
56
|
const mcpToolSettingsSchema = z
|
|
55
57
|
.object({
|
|
56
58
|
enabled: z.boolean().optional(),
|
|
@@ -59,7 +61,7 @@ const mcpToolSettingsSchema = z
|
|
|
59
61
|
})
|
|
60
62
|
.strict()
|
|
61
63
|
.meta({ id: "McpToolSettings" });
|
|
62
|
-
/** Per-tool settings keyed by the server's tool names, `"*"` for the rest
|
|
64
|
+
/** Per-tool settings keyed by the server's tool names, `"*"` for the rest. */
|
|
63
65
|
const mcpServerSettings = {
|
|
64
66
|
deferred: z.boolean().optional(),
|
|
65
67
|
tools: z.record(z.string().min(1), mcpToolSettingsSchema).optional(),
|
|
@@ -206,13 +208,13 @@ const removedFieldError = (removedFields) => (issue) => {
|
|
|
206
208
|
return removed === undefined ? undefined : removedFields[removed];
|
|
207
209
|
};
|
|
208
210
|
/**
|
|
209
|
-
* An environment variable name a shell secret or plain variable may take
|
|
211
|
+
* An environment variable name a shell secret or plain variable may take: a POSIX
|
|
210
212
|
* name, of any length (POSIX and Linux set none; a request's body bounds it). Names the sandbox
|
|
211
213
|
* needs for itself (the proxy, the trust store, `PATH`, `HOME`) and `NYLORUN_*` are reserved.
|
|
212
214
|
*/
|
|
213
215
|
export const ENVIRONMENT_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
214
216
|
/**
|
|
215
|
-
* What an agent needs of the Environment its session opens on (protocol 14
|
|
217
|
+
* What an agent needs of the Environment its session opens on (protocol 14), checked when a
|
|
216
218
|
* session opens (`409 environment_unsuitable`). `sandbox`: `any` needs kind `virtual` or `pod`,
|
|
217
219
|
* `pod` needs kind `pod`, `none` needs nothing. `secrets`: names its skills' scripts read, which
|
|
218
220
|
* the Environment's vault must hold. The agent names no Environment: the app still maps.
|
|
@@ -457,19 +459,15 @@ function referencedAgents(node) {
|
|
|
457
459
|
}
|
|
458
460
|
/** Workflow definition document. `kind: "workflow"`; a missing `kind` is never a workflow. */
|
|
459
461
|
export const WorkflowManifestSchema = workflowManifestSchema;
|
|
460
|
-
/**
|
|
462
|
+
/**
|
|
463
|
+
* A loop manifest: what the engine runs (agent manifest v7's shape, or workflow manifest v3's),
|
|
464
|
+
* as the Runtime makes it from an agent manifest v8's harness section (`loopManifestOf`) and a
|
|
465
|
+
* session pins it.
|
|
466
|
+
*/
|
|
461
467
|
export const DefinitionDocumentSchema = z.union([
|
|
462
468
|
AgentManifestSchema,
|
|
463
469
|
WorkflowManifestSchema,
|
|
464
470
|
]);
|
|
465
|
-
export const PutAgentRequestSchema = z
|
|
466
|
-
.object({
|
|
467
|
-
requestId: RequestIdSchema,
|
|
468
|
-
/** Agent or workflow document. Registry `kind` is carried on the document. */
|
|
469
|
-
manifest: DefinitionDocumentSchema,
|
|
470
|
-
implementationVersion: z.string().min(1),
|
|
471
|
-
})
|
|
472
|
-
.strict();
|
|
473
471
|
const hostPatternSchema = z.string().refine(isSandboxHostPattern, {
|
|
474
472
|
message: "network.allowedHosts entries must be host names such as api.github.com or *.example.com",
|
|
475
473
|
});
|
|
@@ -490,34 +488,35 @@ const resourcesSchema = z
|
|
|
490
488
|
.strict();
|
|
491
489
|
// --- Environments (protocol 11, R2d, blueprint D55 and D56) --------------------------------
|
|
492
490
|
/**
|
|
493
|
-
* An Environment id: 1–200 characters, one or more
|
|
494
|
-
* `.`, `_` and `-`, each starting with a letter or
|
|
495
|
-
* hierarchical so a grant can name a family of
|
|
491
|
+
* An Agent id (protocol 16; an Environment id before): 1–200 characters, one or more
|
|
492
|
+
* `/`-separated segments of letters, digits, `.`, `_` and `-`, each starting with a letter or
|
|
493
|
+
* digit (`triage`, `users/alice/triage`). Ids are hierarchical so a grant can name a family of
|
|
494
|
+
* them (`users/alice/*`).
|
|
496
495
|
*/
|
|
497
|
-
const
|
|
496
|
+
const AGENT_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*(?:\/[A-Za-z0-9][A-Za-z0-9._-]*)*$/;
|
|
498
497
|
/**
|
|
499
|
-
* An identifier's grammar is the protocol's
|
|
500
|
-
* and means the same in every installation, so its length is a constant of protocol
|
|
498
|
+
* An identifier's grammar is the protocol's: it crosses the Runtime API, tokens and grants
|
|
499
|
+
* and means the same in every installation, so its length is a constant of the protocol, not a
|
|
501
500
|
* setting.
|
|
502
501
|
*/
|
|
503
|
-
export const
|
|
504
|
-
export function
|
|
505
|
-
return
|
|
506
|
-
value.length <= ENVIRONMENT_ID_MAX_LENGTH &&
|
|
507
|
-
ENVIRONMENT_ID_PATTERN.test(value));
|
|
502
|
+
export const AGENT_ID_MAX_LENGTH = 200;
|
|
503
|
+
export function isAgentId(value) {
|
|
504
|
+
return typeof value === "string" && value.length <= AGENT_ID_MAX_LENGTH && AGENT_ID_PATTERN.test(value);
|
|
508
505
|
}
|
|
509
|
-
/** An
|
|
510
|
-
export function
|
|
506
|
+
/** An Agent grant: an exact Agent id, or a prefix ending in `/*` (`team-a/*`). */
|
|
507
|
+
export function isAgentGrant(value) {
|
|
511
508
|
if (typeof value !== "string")
|
|
512
509
|
return false;
|
|
513
|
-
return value.endsWith("/*") ?
|
|
510
|
+
return value === "*" || (value.endsWith("/*") ? isAgentId(value.slice(0, -2)) : isAgentId(value));
|
|
514
511
|
}
|
|
515
512
|
/**
|
|
516
|
-
* Whether `grants` (a token caller's
|
|
517
|
-
*
|
|
513
|
+
* Whether `grants` (a token caller's Agent grants) reach Agent `id`: `*`, an exact entry, or a
|
|
514
|
+
* prefix entry `p/*` for any id below `p/`. No grants reach no Agent.
|
|
518
515
|
*/
|
|
519
|
-
export function
|
|
516
|
+
export function agentGranted(grants, id) {
|
|
520
517
|
for (const grant of grants ?? []) {
|
|
518
|
+
if (grant === "*")
|
|
519
|
+
return true;
|
|
521
520
|
if (grant.endsWith("/*")) {
|
|
522
521
|
if (id.startsWith(grant.slice(0, -1)))
|
|
523
522
|
return true;
|
|
@@ -527,14 +526,14 @@ export function environmentGranted(grants, id) {
|
|
|
527
526
|
}
|
|
528
527
|
return false;
|
|
529
528
|
}
|
|
530
|
-
export const
|
|
529
|
+
export const AgentIdSchema = z
|
|
531
530
|
.string()
|
|
532
|
-
.refine(
|
|
533
|
-
message: "An
|
|
531
|
+
.refine(isAgentId, {
|
|
532
|
+
message: "An Agent id is up to 200 characters: /-separated segments of letters, digits, '.', '_' and '-'",
|
|
534
533
|
})
|
|
535
|
-
.meta({ description: "An
|
|
536
|
-
export const
|
|
537
|
-
message: "An
|
|
534
|
+
.meta({ description: "An Agent id, such as `triage` or `users/alice/triage`" });
|
|
535
|
+
export const AgentGrantSchema = z.string().refine(isAgentGrant, {
|
|
536
|
+
message: "An Agent grant is *, an Agent id, or a prefix ending in /* such as team-a/*",
|
|
538
537
|
});
|
|
539
538
|
/**
|
|
540
539
|
* `virtual`: a just-bash workspace in the harness container, no cluster (a local convenience).
|
|
@@ -554,7 +553,7 @@ export const EnvironmentLabelsSchema = z.record(z.string().regex(LABEL_KEY_PATTE
|
|
|
554
553
|
}), z.string().regex(LABEL_VALUE_PATTERN, {
|
|
555
554
|
message: "Label values are printable ASCII characters",
|
|
556
555
|
}));
|
|
557
|
-
/** A harness id
|
|
556
|
+
/** A harness id: what a harness names itself in `hello`. */
|
|
558
557
|
export const HarnessIdSchema = z.string().regex(HARNESS_ID_PATTERN, {
|
|
559
558
|
message: "harness must be a harness id: lowercase letters, digits and dashes, starting with a letter",
|
|
560
559
|
});
|
|
@@ -609,7 +608,7 @@ const relativeFilePath = z
|
|
|
609
608
|
.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" });
|
|
610
609
|
/**
|
|
611
610
|
* One input file entry (pods only): an artifact version copied to `path` (a file artifact, or a
|
|
612
|
-
* folder's files under it), or
|
|
611
|
+
* folder's files under it), or files by content hash, each `sha256:<hex>` of a definition
|
|
613
612
|
* file the Tenant holds (`PUT /v1/files/sha256:<hex>`, at most 2 GiB each), copied under `path`
|
|
614
613
|
* at its relative path. A manifest by hash moves to another Tenant with its files.
|
|
615
614
|
*/
|
|
@@ -632,42 +631,40 @@ export const EnvironmentFileSchema = z.union([
|
|
|
632
631
|
.strict(),
|
|
633
632
|
]);
|
|
634
633
|
/**
|
|
635
|
-
* An
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
* and means the same in every installation, so its length is a constant of protocol 15, not a
|
|
639
|
-
* setting.
|
|
634
|
+
* An agent manifest's name (protocol 16): 1–64 letters, digits, `.`, `_` and `-`, starting with a
|
|
635
|
+
* letter or digit, such as `triage`; a version is at most 9 digits. Manifest names and Agent ids
|
|
636
|
+
* are separate namespaces.
|
|
640
637
|
*/
|
|
641
|
-
const
|
|
642
|
-
export function
|
|
643
|
-
return typeof value === "string" &&
|
|
638
|
+
const AGENT_MANIFEST_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
639
|
+
export function isAgentManifestName(value) {
|
|
640
|
+
return typeof value === "string" && AGENT_MANIFEST_NAME_PATTERN.test(value);
|
|
644
641
|
}
|
|
645
|
-
export const
|
|
642
|
+
export const AgentManifestNameSchema = z
|
|
646
643
|
.string()
|
|
647
|
-
.refine(
|
|
648
|
-
message: "An
|
|
644
|
+
.refine(isAgentManifestName, {
|
|
645
|
+
message: "An agent manifest's name is 1-64 letters, digits, '.', '_' and '-', starting with a letter or digit",
|
|
649
646
|
})
|
|
650
|
-
.meta({ description: "An
|
|
647
|
+
.meta({ description: "An agent manifest's name, such as `triage`" });
|
|
651
648
|
/**
|
|
652
|
-
* Which manifest an
|
|
653
|
-
* created) or `name@n` (version `n`).
|
|
649
|
+
* Which agent manifest an Agent is made from: `name` (tracking: the latest version when the Agent
|
|
650
|
+
* is created, and each version saved later) or `name@n` (pinned to version `n`).
|
|
654
651
|
*/
|
|
655
|
-
export function
|
|
652
|
+
export function parseAgentManifestRef(ref) {
|
|
656
653
|
const at = ref.lastIndexOf("@");
|
|
657
654
|
const name = at < 0 ? ref : ref.slice(0, at);
|
|
658
|
-
if (!
|
|
655
|
+
if (!isAgentManifestName(name))
|
|
659
656
|
return undefined;
|
|
660
657
|
if (at < 0)
|
|
661
658
|
return { name };
|
|
662
659
|
const version = ref.slice(at + 1);
|
|
663
660
|
return /^[1-9][0-9]{0,8}$/.test(version) ? { name, version: Number(version) } : undefined;
|
|
664
661
|
}
|
|
665
|
-
export const
|
|
662
|
+
export const AgentManifestRefSchema = z
|
|
666
663
|
.string()
|
|
667
|
-
.refine((value) =>
|
|
668
|
-
message: "manifest is an
|
|
664
|
+
.refine((value) => parseAgentManifestRef(value) !== undefined, {
|
|
665
|
+
message: "manifest is an agent manifest's name, or name@version such as triage@3",
|
|
669
666
|
})
|
|
670
|
-
.meta({ description: "`name` (
|
|
667
|
+
.meta({ description: "`name` (tracking) or `name@n` (pinned)" });
|
|
671
668
|
/**
|
|
672
669
|
* What an Environment's artifacts, its sessions' skills and its disk versions may hold: part of
|
|
673
670
|
* its manifest, fixed for its life. Each limit left out is the Tenant's (`/v1/tenant/artifacts`,
|
|
@@ -705,26 +702,12 @@ export const EnvironmentLimitsSchema = z
|
|
|
705
702
|
})
|
|
706
703
|
.strict();
|
|
707
704
|
/**
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
* environment manifest (`manifest`) or from the inline manifest these fields make, and never
|
|
711
|
-
* changes what it runs after that (protocol 14, D63): on an existing one, `labels` replace its
|
|
712
|
-
* labels and `ownerUserId` sets or clears its owner guard, a field that matches what it runs is
|
|
713
|
-
* accepted, and anything else is `409 environment_immutable`, naming the fork that makes a new
|
|
714
|
-
* Environment instead.
|
|
705
|
+
* The fields of a runtime section (agent manifest v8, protocol 16): what the Runtime provides
|
|
706
|
+
* around an Agent's loop. Environment manifest v1's fields, which they were until protocol 16.
|
|
715
707
|
*/
|
|
716
|
-
|
|
717
|
-
.
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* The environment manifest to make the Environment from (Host feature
|
|
721
|
-
* `environment-manifests`): `name` or `name@n`. With it, none of the inline fields below is
|
|
722
|
-
* sent; `labels`, `ownerUserId` and `from` still are.
|
|
723
|
-
*/
|
|
724
|
-
manifest: EnvironmentManifestRefSchema.optional(),
|
|
725
|
-
/** Default `virtual`. `pod` needs sandbox pods (`nylorun local sandbox enable`). Fixed. */
|
|
726
|
-
kind: z.enum(ENVIRONMENT_KINDS).optional(),
|
|
727
|
-
labels: EnvironmentLabelsSchema.optional(),
|
|
708
|
+
const runtimeFields = {
|
|
709
|
+
/** `virtual`, `pod` (needs sandbox pods, `nylorun local sandbox enable`) or `none`. Fixed. */
|
|
710
|
+
kind: z.enum(ENVIRONMENT_KINDS),
|
|
728
711
|
/** Pods only: the workload image (default the Tenant's, else `python:3.13-slim`). */
|
|
729
712
|
image: z.string().min(1).optional(),
|
|
730
713
|
resources: resourcesSchema.optional(),
|
|
@@ -740,47 +723,45 @@ export const PutEnvironmentRequestSchema = z
|
|
|
740
723
|
.object({ allowedHosts: z.array(hostPatternSchema).optional() })
|
|
741
724
|
.strict()
|
|
742
725
|
.optional(),
|
|
743
|
-
/**
|
|
744
|
-
* The harness that runs the Environment's sessions (track R4): `nylorun` (ours, the default)
|
|
745
|
-
* or the id of a custom harness. A pod Environment whose harness is not ours runs its
|
|
746
|
-
* `image` as the harness: the image's own entrypoint, with nothing copied in. It is fixed
|
|
747
|
-
* for the Environment's life (protocol 14): to run another harness, fork onto a manifest
|
|
748
|
-
* version that names it. Each session pins the harness when it opens; a session whose
|
|
749
|
-
* Environment id was deleted and made again with another harness fails its next turn with
|
|
750
|
-
* `harness_mismatch`.
|
|
751
|
-
*/
|
|
752
|
-
harness: HarnessIdSchema.optional(),
|
|
753
|
-
/**
|
|
754
|
-
* The owner guard: when set, only sessions of this owner may name the Environment (checked
|
|
755
|
-
* when a session opens and at every turn start). `null` clears it.
|
|
756
|
-
*/
|
|
757
|
-
ownerUserId: z.string().min(1).nullable().optional(),
|
|
758
726
|
lifecycle: EnvironmentLifecycleSchema.optional(),
|
|
759
|
-
/**
|
|
760
|
-
* Pods only (Host feature `environment-setup`): commands run when the disk is made or reset,
|
|
761
|
-
* before any turn. A change applies at the next reset.
|
|
762
|
-
*/
|
|
727
|
+
/** Pods only: commands run when the disk is made or reset, before any turn. */
|
|
763
728
|
setup: z.array(EnvironmentSetupCommandSchema).optional(),
|
|
764
|
-
/** Pods only: artifact versions copied in when the disk is made or reset, before `setup`. */
|
|
729
|
+
/** Pods only: artifact versions or files by hash copied in when the disk is made or reset, before `setup`. */
|
|
765
730
|
files: z.array(EnvironmentFileSchema).optional(),
|
|
766
|
-
/**
|
|
767
|
-
* What its artifacts and its sessions' skills may hold, at most the Tenant's limits; a limit
|
|
768
|
-
* left out is the Tenant's. Fixed.
|
|
769
|
-
*/
|
|
731
|
+
/** What its artifacts and its sessions' skills may hold, at most the Tenant's limits. Fixed. */
|
|
770
732
|
limits: EnvironmentLimitsSchema.optional(),
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* `PUT /v1/agents/{agentId}` (protocol 16): creates the Agent, its vault and its compute from a
|
|
736
|
+
* saved agent manifest, or finds the one with this id, so "get or create" is one call. An Agent is
|
|
737
|
+
* the live instance of one version of an agent manifest: `manifest: "name"` records that it
|
|
738
|
+
* tracks the manifest (its latest version, and every version saved later) and `"name@n"` that it
|
|
739
|
+
* is pinned to one; the version it runs is `resolvedVersion`. On an existing Agent, `labels`
|
|
740
|
+
* replace its labels, `owner` sets or clears its owner guard, and `manifest` moves it:
|
|
741
|
+
* to another version of its manifest, tracking or pinned. A move changes no data: its id,
|
|
742
|
+
* disk, vault and sessions stay. A harness-only change applies at once; a runtime change of a pod
|
|
743
|
+
* waits for its next start; one that adds a required secret waits for its value. Its manifest's
|
|
744
|
+
* name, kind, harness and storage are fixed (`409 agent_fixed_field`); fork it to change them.
|
|
745
|
+
* `?dryRun=true` answers the move's plan (`AgentMovePlan`) and changes nothing.
|
|
746
|
+
*/
|
|
747
|
+
export const PutAgentRequestSchema = z
|
|
748
|
+
.object({
|
|
749
|
+
requestId: RequestIdSchema.optional(),
|
|
750
|
+
/** The agent manifest it is made from: `name` (tracking) or `name@n` (pinned). */
|
|
751
|
+
manifest: AgentManifestRefSchema,
|
|
771
752
|
/**
|
|
772
|
-
* The
|
|
773
|
-
*
|
|
774
|
-
* write sends only the value and a name not declared is `409 secret_not_in_manifest`.
|
|
753
|
+
* The owner guard: when set, only sessions of this owner may run on the Agent (checked when
|
|
754
|
+
* a session opens and at every turn start). `null` clears it.
|
|
775
755
|
*/
|
|
776
|
-
|
|
756
|
+
owner: z.string().min(1).nullable().optional(),
|
|
757
|
+
labels: EnvironmentLabelsSchema.optional(),
|
|
777
758
|
/**
|
|
778
|
-
* Only when the `PUT` creates the
|
|
779
|
-
*
|
|
759
|
+
* Only when the `PUT` creates the Agent (Host feature `environment-disk-versions`): its disk
|
|
760
|
+
* starts from this version of another Agent's disk. Its vault starts empty.
|
|
780
761
|
*/
|
|
781
762
|
from: z
|
|
782
763
|
.object({
|
|
783
|
-
|
|
764
|
+
agent: AgentIdSchema,
|
|
784
765
|
version: z.union([z.number().int().positive(), z.literal("latest")]),
|
|
785
766
|
})
|
|
786
767
|
.strict()
|
|
@@ -788,8 +769,10 @@ export const PutEnvironmentRequestSchema = z
|
|
|
788
769
|
})
|
|
789
770
|
.strict();
|
|
790
771
|
/**
|
|
791
|
-
* What an
|
|
792
|
-
* against the Tenant's limits when
|
|
772
|
+
* What an Agent's environment runs: the runtime section of the manifest version it runs, resolved
|
|
773
|
+
* against the Tenant's limits when the Agent was made or moved to that version, with the harness
|
|
774
|
+
* that runs its loop. A move to another version changes it; its kind, harness and storage never
|
|
775
|
+
* change.
|
|
793
776
|
*/
|
|
794
777
|
export const EnvironmentRecipeSchema = z
|
|
795
778
|
.object({
|
|
@@ -806,9 +789,14 @@ export const EnvironmentRecipeSchema = z
|
|
|
806
789
|
secrets: z.lazy(() => EnvironmentSecretSlotsSchema).optional(),
|
|
807
790
|
})
|
|
808
791
|
.strict();
|
|
809
|
-
/** A session
|
|
810
|
-
export const
|
|
811
|
-
.object({
|
|
792
|
+
/** A session on an Agent, as the Agent's view lists it: none is special. */
|
|
793
|
+
export const AgentSessionSchema = z
|
|
794
|
+
.object({
|
|
795
|
+
id: z.string(),
|
|
796
|
+
ownerUserId: z.string(),
|
|
797
|
+
status: z.string(),
|
|
798
|
+
activeTurnId: z.string().nullable(),
|
|
799
|
+
})
|
|
812
800
|
.strict();
|
|
813
801
|
/** What the Runtime wants of a pod (`desired`) and what it last saw (`observed`). */
|
|
814
802
|
export const POD_DESIRED = ["running", "suspended", "deleted"];
|
|
@@ -820,7 +808,7 @@ export const POD_OBSERVED = [
|
|
|
820
808
|
"failed",
|
|
821
809
|
"deleting",
|
|
822
810
|
];
|
|
823
|
-
export const
|
|
811
|
+
export const AgentPodViewSchema = z
|
|
824
812
|
.object({
|
|
825
813
|
desired: z.enum(POD_DESIRED),
|
|
826
814
|
observed: z.enum(POD_OBSERVED),
|
|
@@ -831,34 +819,98 @@ export const EnvironmentPodViewSchema = z
|
|
|
831
819
|
/** Why it failed, or was lost. */
|
|
832
820
|
reason: z.string().optional(),
|
|
833
821
|
/**
|
|
834
|
-
* The workload image by digest (`repo@sha256:…`), pinned the first time a pod was ready
|
|
835
|
-
*
|
|
822
|
+
* The workload image by digest (`repo@sha256:…`), pinned the first time a pod was ready:
|
|
823
|
+
* every later pod runs it. Absent before then, or for an image with no repository.
|
|
836
824
|
*/
|
|
837
825
|
imageDigest: z.string().optional(),
|
|
838
826
|
})
|
|
839
827
|
.strict();
|
|
840
828
|
/**
|
|
841
|
-
* The compute states an
|
|
842
|
-
* one, then `creating`, `running` or `stopped`. An open set: clients must
|
|
843
|
-
*
|
|
829
|
+
* The compute states an Agent's environment reports (`compute.state`): `ready` until a tool
|
|
830
|
+
* first runs in a virtual one, then `creating`, `running` or `stopped`. An open set: clients must
|
|
831
|
+
* accept values they do not know.
|
|
844
832
|
*/
|
|
845
|
-
export const
|
|
846
|
-
/**
|
|
847
|
-
|
|
833
|
+
export const COMPUTE_STATES = ["ready", "creating", "running", "stopped"];
|
|
834
|
+
/**
|
|
835
|
+
* An Agent's state (protocol 16), derived when it is read, the first that holds:
|
|
836
|
+
*
|
|
837
|
+
* - `paused`: its desired state is `off` (nothing in protocol 16 sets it).
|
|
838
|
+
* - `failing`: its compute failed or was lost, or a session's latest finished turn failed.
|
|
839
|
+
* - `input_required`: a session waits on a person (an approval or interaction, or an uncertain
|
|
840
|
+
* effect), even while another works.
|
|
841
|
+
* - `working`: a turn runs.
|
|
842
|
+
* - `sleeping`: nothing to do.
|
|
843
|
+
*
|
|
844
|
+
* An open set: clients must accept values they do not know.
|
|
845
|
+
*/
|
|
846
|
+
export const AGENT_STATES = ["paused", "failing", "input_required", "working", "sleeping"];
|
|
847
|
+
/** What made an Agent's state, or another state that also holds (`attention`). */
|
|
848
|
+
export const AgentAttentionSchema = z
|
|
849
|
+
.object({
|
|
850
|
+
state: z.enum(AGENT_STATES),
|
|
851
|
+
/** The session behind it; absent for the Agent's compute. */
|
|
852
|
+
sessionId: z.string().optional(),
|
|
853
|
+
/** Why, for a person: the session's status, or the compute's failure. */
|
|
854
|
+
reason: z.string(),
|
|
855
|
+
})
|
|
856
|
+
.strict();
|
|
857
|
+
/** `PUT` and `GET /v1/agents/{agentId}`. */
|
|
858
|
+
export const AgentViewSchema = z
|
|
848
859
|
.object({
|
|
849
860
|
id: z.string(),
|
|
850
|
-
|
|
851
|
-
|
|
861
|
+
/** How it names its manifest: `name` (tracking) or `name@n` (pinned). */
|
|
862
|
+
manifest: z.string(),
|
|
863
|
+
/** The version of the manifest it runs: each turn takes it when the turn starts. */
|
|
864
|
+
resolvedVersion: z.number().int().positive(),
|
|
865
|
+
/** The hash of that version. */
|
|
866
|
+
manifestHash: z.string(),
|
|
867
|
+
/** Whether `manifest` tracks the manifest's latest version or pins one. */
|
|
868
|
+
tracking: z.enum(["tracking", "pinned"]),
|
|
852
869
|
/**
|
|
853
|
-
*
|
|
854
|
-
*
|
|
870
|
+
* The version it moves to while it is outdated, else `null`. It waits for a value of
|
|
871
|
+
* each required secret the version adds (`waitingFor: "secrets"`) or for its pod's next start
|
|
872
|
+
* (`"start"`); turns run `resolvedVersion` meanwhile.
|
|
855
873
|
*/
|
|
856
|
-
|
|
857
|
-
/**
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
874
|
+
targetVersion: z.number().int().positive().nullable(),
|
|
875
|
+
/** What the move to `targetVersion` waits for, else `null`. */
|
|
876
|
+
waitingFor: z.enum(["secrets", "start"]).nullable(),
|
|
877
|
+
/**
|
|
878
|
+
* A version that failed to start: the Agent went back to the one it ran, and a tracking Agent
|
|
879
|
+
* does not move to it again on its own. `null` once a start on a new version succeeds.
|
|
880
|
+
*/
|
|
881
|
+
failedVersion: z.number().int().positive().nullable(),
|
|
882
|
+
/**
|
|
883
|
+
* While its pod starts on a new version: the version it ran before, which a failed start
|
|
884
|
+
* goes back to, and since when it starts. `null` otherwise.
|
|
885
|
+
*/
|
|
886
|
+
startCheck: z
|
|
887
|
+
.object({ from: z.number().int().positive(), startedAt: z.string() })
|
|
888
|
+
.strict()
|
|
889
|
+
.nullable(),
|
|
890
|
+
kind: z.enum(ENVIRONMENT_KINDS),
|
|
891
|
+
/** The harness that runs its loop: its manifest's `harness.id`, else `nylorun`. */
|
|
892
|
+
harness: z.string(),
|
|
893
|
+
/** The owner guard, or `null`. */
|
|
894
|
+
owner: z.string().nullable(),
|
|
895
|
+
labels: z.record(z.string(), z.string()),
|
|
896
|
+
/** See `AGENT_STATES`: an open set. */
|
|
897
|
+
state: z.string().meta({ description: "working, sleeping, input_required, failing or paused; an open set" }),
|
|
898
|
+
/** Every state that holds, with the session behind each: what made `state` first. */
|
|
899
|
+
attention: z.array(AgentAttentionSchema),
|
|
900
|
+
/** `on`, or `off` once paused. */
|
|
901
|
+
desired: z.enum(["on", "off"]),
|
|
902
|
+
/** When its next trigger fires: the earliest next run of its active triggers, or `null`. */
|
|
903
|
+
nextWakeAt: z.string().nullable(),
|
|
904
|
+
compute: z
|
|
905
|
+
.object({
|
|
906
|
+
/** See `COMPUTE_STATES`: an open set. */
|
|
907
|
+
state: z.string().meta({ description: "ready, creating, running or stopped; an open set" }),
|
|
908
|
+
/** Kind `pod`: what the Runtime wants of the pod and what it last saw. */
|
|
909
|
+
pod: AgentPodViewSchema.optional(),
|
|
910
|
+
})
|
|
911
|
+
.strict(),
|
|
912
|
+
/** What its environment runs: the runtime section of `resolvedVersion`, resolved. */
|
|
913
|
+
runtime: EnvironmentRecipeSchema,
|
|
862
914
|
/** The limits in force now: its manifest's, else the Tenant's, never above the Tenant's. */
|
|
863
915
|
limits: z
|
|
864
916
|
.object({
|
|
@@ -867,37 +919,17 @@ export const EnvironmentViewSchema = z
|
|
|
867
919
|
disk: z.object({ versionBytes: z.number().int(), versionEntries: z.number().int() }).strict(),
|
|
868
920
|
})
|
|
869
921
|
.strict(),
|
|
870
|
-
/**
|
|
871
|
-
|
|
872
|
-
* from (`null` for an empty disk).
|
|
873
|
-
*/
|
|
874
|
-
forkedFrom: z
|
|
875
|
-
.object({ environment: z.string(), disk: z.number().int().positive().nullable() })
|
|
876
|
-
.strict()
|
|
877
|
-
.optional(),
|
|
922
|
+
/** Its sessions (acting for a subject, only the subject's own). */
|
|
923
|
+
sessions: z.array(AgentSessionSchema),
|
|
878
924
|
/** Each secret slot its manifest declares, and whether its vault holds a value for it. */
|
|
879
|
-
slots: z
|
|
880
|
-
.array(z
|
|
925
|
+
slots: z.array(z
|
|
881
926
|
.object({
|
|
882
927
|
name: z.string(),
|
|
883
928
|
type: z.string(),
|
|
884
929
|
required: z.boolean(),
|
|
885
930
|
set: z.boolean(),
|
|
886
931
|
})
|
|
887
|
-
.strict())
|
|
888
|
-
.optional(),
|
|
889
|
-
/** Always 1 since protocol 14: an Environment never changes what it runs. */
|
|
890
|
-
version: z.number().int().positive(),
|
|
891
|
-
/** Always `version`. */
|
|
892
|
-
appliedVersion: z.number().int().positive(),
|
|
893
|
-
/** The owner guard, or `null`. */
|
|
894
|
-
ownerUserId: z.string().nullable(),
|
|
895
|
-
/** See `ENVIRONMENT_STATES`: an open set. */
|
|
896
|
-
state: z.string().meta({ description: "ready, creating, running or stopped; an open set" }),
|
|
897
|
-
/** Kind `pod`: what the Runtime wants of the pod and what it last saw. */
|
|
898
|
-
pod: EnvironmentPodViewSchema.optional(),
|
|
899
|
-
/** When it was last used: a turn, a recipe change, a secret write, a stop or a reset. */
|
|
900
|
-
lastUsedAt: z.string(),
|
|
932
|
+
.strict()),
|
|
901
933
|
/**
|
|
902
934
|
* Its disk versions (Host feature `environment-disk-versions`): the latest, and the copy
|
|
903
935
|
* that holds the disk now, if one does. Absent for kind `none`.
|
|
@@ -912,20 +944,25 @@ export const EnvironmentViewSchema = z
|
|
|
912
944
|
startedAt: z.string(),
|
|
913
945
|
})
|
|
914
946
|
.strict()
|
|
915
|
-
.
|
|
947
|
+
.nullable(),
|
|
916
948
|
})
|
|
917
949
|
.strict()
|
|
918
950
|
.optional(),
|
|
919
|
-
/**
|
|
920
|
-
|
|
951
|
+
/** The Agent it was forked from (`POST .../fork`), and the disk version it started from. */
|
|
952
|
+
forkedFrom: z
|
|
953
|
+
.object({ agent: z.string(), disk: z.number().int().positive().nullable() })
|
|
954
|
+
.strict()
|
|
955
|
+
.nullable(),
|
|
956
|
+
/** When it was last used: a turn, a secret write, a stop or a reset. */
|
|
957
|
+
lastUsedAt: z.string(),
|
|
921
958
|
createdAt: z.string(),
|
|
922
959
|
updatedAt: z.string(),
|
|
923
960
|
})
|
|
924
961
|
.strict();
|
|
925
|
-
/** `POST /v1/
|
|
926
|
-
export const
|
|
962
|
+
/** `POST /v1/agents/{id}/snapshot`: a new version of the Agent's disk. */
|
|
963
|
+
export const AgentSnapshotSchema = z
|
|
927
964
|
.object({
|
|
928
|
-
|
|
965
|
+
agentId: z.string(),
|
|
929
966
|
artifactId: z.string(),
|
|
930
967
|
version: z.number().int().positive(),
|
|
931
968
|
format: z.string(),
|
|
@@ -941,29 +978,29 @@ export const EnvironmentSnapshotSchema = z
|
|
|
941
978
|
createdAt: z.string(),
|
|
942
979
|
})
|
|
943
980
|
.strict();
|
|
944
|
-
/** `POST /v1/
|
|
945
|
-
export const
|
|
981
|
+
/** `POST /v1/agents/{id}/restore`: which version of its disk to put back. */
|
|
982
|
+
export const RestoreAgentRequestSchema = z
|
|
946
983
|
.object({
|
|
947
984
|
requestId: RequestIdSchema.optional(),
|
|
948
985
|
version: z.union([z.number().int().positive(), z.literal("latest")]),
|
|
949
986
|
})
|
|
950
987
|
.strict();
|
|
951
|
-
export const
|
|
988
|
+
export const AgentRestoreSchema = z
|
|
952
989
|
.object({
|
|
953
|
-
|
|
990
|
+
agentId: z.string(),
|
|
954
991
|
restored: z.number().int().positive(),
|
|
955
992
|
/**
|
|
956
|
-
* `done` once the version is back (a virtual
|
|
957
|
-
*
|
|
993
|
+
* `done` once the version is back (a virtual Agent); `pending` while a pod's new volume is
|
|
994
|
+
* seeded (`disk.operation` in the view until it ends; turns wait for it).
|
|
958
995
|
*/
|
|
959
996
|
status: z.enum(["done", "pending"]),
|
|
960
997
|
volumeGeneration: z.number().int().nonnegative().optional(),
|
|
961
998
|
})
|
|
962
999
|
.strict();
|
|
963
|
-
/** `GET /v1/
|
|
964
|
-
export const
|
|
1000
|
+
/** `GET /v1/agents/{id}/versions`: its disk versions, newest first. */
|
|
1001
|
+
export const AgentDiskVersionsSchema = z
|
|
965
1002
|
.object({
|
|
966
|
-
|
|
1003
|
+
agentId: z.string(),
|
|
967
1004
|
/** The folder artifact that holds them (read trees, files and diffs through `/v1/artifacts`). */
|
|
968
1005
|
artifactId: z.string().nullable(),
|
|
969
1006
|
latest: z.number().int().positive().nullable(),
|
|
@@ -976,32 +1013,29 @@ export const EnvironmentVersionsSchema = z
|
|
|
976
1013
|
.strict()),
|
|
977
1014
|
})
|
|
978
1015
|
.strict();
|
|
979
|
-
export const
|
|
980
|
-
.object({ environments: z.array(EnvironmentViewSchema) })
|
|
981
|
-
.strict();
|
|
982
|
-
export const DeleteEnvironmentResponseSchema = z
|
|
1016
|
+
export const DeleteAgentResponseSchema = z
|
|
983
1017
|
.object({ id: z.string(), deleted: z.boolean() })
|
|
984
1018
|
.strict();
|
|
985
|
-
/** A turn that was running on an
|
|
1019
|
+
/** A turn that was running on an Agent when one of its connections opened. */
|
|
986
1020
|
export const EgressRunningTurnSchema = z
|
|
987
1021
|
.object({ sessionId: z.string(), turnId: z.string() })
|
|
988
1022
|
.strict();
|
|
989
1023
|
/**
|
|
990
|
-
* One connection a pod
|
|
991
|
-
*
|
|
992
|
-
*
|
|
993
|
-
*
|
|
994
|
-
*
|
|
1024
|
+
* One connection a pod Agent opened through egress-gate: written when it closes,
|
|
1025
|
+
* or at once when the gate refused it, to the Agent's own stream as `agent.egress`. The
|
|
1026
|
+
* connection is the Agent's: its egress token names the pod, and the Agent's sessions run turns
|
|
1027
|
+
* in parallel. `runningTurns` lists the turns active on it as the connection opened, at
|
|
1028
|
+
* most 16, as context and never as the owner.
|
|
995
1029
|
*
|
|
996
1030
|
* `startedAt` is the gate's clock at CONNECT and `durationMs` runs from there to the close, so
|
|
997
1031
|
* the span is the gate's own measurement. `bytesUp` is what the sandbox sent, `bytesDown` what it
|
|
998
|
-
* got. `mode: "credential"` is a host an `environment_secret` is bound to
|
|
1032
|
+
* got. `mode: "credential"` is a host an `environment_secret` is bound to: the gate read
|
|
999
1033
|
* each request (`requests`) and set a credential on it (`credentialIds`, ids only). It never
|
|
1000
1034
|
* carries a header value, a URL path or a body.
|
|
1001
1035
|
*/
|
|
1002
1036
|
export const EgressConnectionPayloadSchema = z
|
|
1003
1037
|
.object({
|
|
1004
|
-
|
|
1038
|
+
agentId: z.string(),
|
|
1005
1039
|
host: z.string(),
|
|
1006
1040
|
port: z.number().int(),
|
|
1007
1041
|
outcome: z.enum(["allowed", "refused"]),
|
|
@@ -1020,103 +1054,175 @@ export const EgressConnectionPayloadSchema = z
|
|
|
1020
1054
|
runningTurns: z.array(EgressRunningTurnSchema).max(16),
|
|
1021
1055
|
})
|
|
1022
1056
|
.passthrough();
|
|
1023
|
-
/** The schema id of an
|
|
1024
|
-
export const
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1057
|
+
/** The schema id of an Agent's lifecycle events (its stream in the record). */
|
|
1058
|
+
export const AGENT_EVENT_SCHEMA = "nylorun.agent-event/1";
|
|
1059
|
+
/**
|
|
1060
|
+
* `memory.updated`: the session's agent changed the Agent's memory with its
|
|
1061
|
+
* `memory` tool: each memory the call changed, what changed it and its version after. The Agent's
|
|
1062
|
+
* stream carries the same as `agent.memory_updated`, with the session.
|
|
1063
|
+
*/
|
|
1064
|
+
export const MemoryUpdatedPayloadSchema = z
|
|
1065
|
+
.object({
|
|
1066
|
+
effectId: z.string(),
|
|
1067
|
+
changes: z
|
|
1068
|
+
.array(z.object({ path: z.string(), operation: z.enum(MEMORY_OPERATIONS), version: z.number().int().positive() }).strict())
|
|
1069
|
+
.min(1),
|
|
1070
|
+
})
|
|
1071
|
+
.passthrough();
|
|
1072
|
+
export const AGENT_EVENT_TYPES = [
|
|
1073
|
+
"agent.created",
|
|
1074
|
+
"agent.attached",
|
|
1075
|
+
"agent.detached",
|
|
1076
|
+
"agent.deleted",
|
|
1030
1077
|
// Kind `pod` (Host feature `sandbox-pods`).
|
|
1031
|
-
"
|
|
1032
|
-
"
|
|
1033
|
-
"
|
|
1034
|
-
"
|
|
1035
|
-
"
|
|
1036
|
-
"
|
|
1037
|
-
// Forked into a new
|
|
1038
|
-
"
|
|
1039
|
-
//
|
|
1040
|
-
"
|
|
1078
|
+
"agent.running",
|
|
1079
|
+
"agent.suspended",
|
|
1080
|
+
"agent.relaunched",
|
|
1081
|
+
"agent.lost",
|
|
1082
|
+
"agent.reset",
|
|
1083
|
+
"agent.failed",
|
|
1084
|
+
// Forked into a new Agent (Q15).
|
|
1085
|
+
"agent.forked",
|
|
1086
|
+
// Moved to another version of its manifest (track T3, D73).
|
|
1087
|
+
"agent.outdated",
|
|
1088
|
+
"agent.version_changed",
|
|
1089
|
+
"agent.start_failed",
|
|
1090
|
+
// egress-gate: every connection the Agent opens (R7, D67).
|
|
1091
|
+
"agent.egress",
|
|
1092
|
+
// Triggers (track T4, D74): each run, and a trigger paused or resumed.
|
|
1093
|
+
"agent.run",
|
|
1094
|
+
"agent.trigger_paused",
|
|
1095
|
+
"agent.trigger_resumed",
|
|
1096
|
+
"agent.trigger_secret_rotated",
|
|
1097
|
+
// Memory (track T5, D72): a turn changed the Agent's memories.
|
|
1098
|
+
"agent.memory_updated",
|
|
1041
1099
|
];
|
|
1042
|
-
/** The payload of each
|
|
1043
|
-
export const
|
|
1044
|
-
"
|
|
1100
|
+
/** The payload of each Agent lifecycle event. */
|
|
1101
|
+
export const AGENT_EVENT_PAYLOADS = {
|
|
1102
|
+
"agent.created": z
|
|
1045
1103
|
.object({
|
|
1046
1104
|
kind: z.enum(ENVIRONMENT_KINDS),
|
|
1047
1105
|
labels: z.record(z.string(), z.string()),
|
|
1048
|
-
/** The
|
|
1049
|
-
manifest: z
|
|
1050
|
-
|
|
1106
|
+
/** The agent manifest and version it was made from, and how it refers to it. */
|
|
1107
|
+
manifest: z
|
|
1108
|
+
.object({ name: z.string(), version: z.number().int().positive(), tracking: z.enum(["tracking", "pinned"]) })
|
|
1109
|
+
.strict(),
|
|
1110
|
+
/** The Agent it was forked from, and the disk version it started from. */
|
|
1051
1111
|
forkedFrom: z
|
|
1052
|
-
.object({
|
|
1112
|
+
.object({ agent: z.string(), disk: z.number().int().positive().nullable() })
|
|
1053
1113
|
.strict()
|
|
1054
1114
|
.optional(),
|
|
1055
1115
|
})
|
|
1056
1116
|
.passthrough(),
|
|
1057
|
-
"
|
|
1058
|
-
"
|
|
1117
|
+
"agent.attached": z.object({ sessionId: z.string() }).passthrough(),
|
|
1118
|
+
"agent.detached": z
|
|
1059
1119
|
.object({ sessionId: z.string(), reason: z.enum(["reset"]) })
|
|
1060
1120
|
.passthrough(),
|
|
1061
1121
|
/** Deleted by a `DELETE`, or by the sweep once `lifecycle.deleteAfter` passed (`reason`). */
|
|
1062
|
-
"
|
|
1122
|
+
"agent.deleted": z
|
|
1063
1123
|
.object({ reason: z.enum(["delete", "deleteAfter"]).optional() })
|
|
1064
1124
|
.passthrough(),
|
|
1065
|
-
/** A pod joined and serves the
|
|
1066
|
-
"
|
|
1125
|
+
/** A pod joined and serves the Agent. */
|
|
1126
|
+
"agent.running": z.object({ hostEpoch: z.number().int() }).passthrough(),
|
|
1067
1127
|
/** Stopped (`POST .../stop`, or idle): the volume is kept; the next turn starts it again. */
|
|
1068
|
-
"
|
|
1128
|
+
"agent.suspended": z.object({ reason: z.enum(["stop", "idle", "restart"]) }).passthrough(),
|
|
1069
1129
|
/** Its pod was replaced (same volume): the old pod's host token no longer works. */
|
|
1070
|
-
"
|
|
1130
|
+
"agent.relaunched": z.object({ hostEpoch: z.number().int() }).passthrough(),
|
|
1071
1131
|
/** Its volume or node is gone: turns are refused until a reset. */
|
|
1072
|
-
"
|
|
1132
|
+
"agent.lost": z.object({ reason: z.string() }).passthrough(),
|
|
1073
1133
|
/** Reset: a new pod on a new, empty volume. */
|
|
1074
|
-
"
|
|
1134
|
+
"agent.reset": z.object({ volumeGeneration: z.number().int() }).passthrough(),
|
|
1075
1135
|
/** The pod did not become ready. */
|
|
1076
|
-
"
|
|
1077
|
-
/** Forked into
|
|
1078
|
-
"
|
|
1136
|
+
"agent.failed": z.object({ reason: z.string() }).passthrough(),
|
|
1137
|
+
/** Forked into Agent `to`: its disk started from version `disk`, `secrets` were copied. */
|
|
1138
|
+
"agent.forked": z
|
|
1079
1139
|
.object({
|
|
1080
1140
|
to: z.string(),
|
|
1081
1141
|
disk: z.number().int().positive().nullable(),
|
|
1082
|
-
manifest: z.object({ name: z.string(), version: z.number().int().positive() }).strict()
|
|
1142
|
+
manifest: z.object({ name: z.string(), version: z.number().int().positive() }).strict(),
|
|
1083
1143
|
secrets: z.number().int().nonnegative(),
|
|
1084
1144
|
})
|
|
1085
1145
|
.passthrough(),
|
|
1086
|
-
/**
|
|
1087
|
-
|
|
1146
|
+
/**
|
|
1147
|
+
* Asked to move to version `to` of its manifest, which waits: for a value of each
|
|
1148
|
+
* required secret it adds (`secrets`), or for its pod's next start (`start`).
|
|
1149
|
+
*/
|
|
1150
|
+
"agent.outdated": z
|
|
1151
|
+
.object({
|
|
1152
|
+
from: z.number().int().positive(),
|
|
1153
|
+
to: z.number().int().positive(),
|
|
1154
|
+
waitingFor: z.enum(["secrets", "start"]),
|
|
1155
|
+
})
|
|
1156
|
+
.passthrough(),
|
|
1157
|
+
/** Runs version `to` of its manifest now: turns that start from here run it. */
|
|
1158
|
+
"agent.version_changed": z
|
|
1159
|
+
.object({ from: z.number().int().positive(), to: z.number().int().positive() })
|
|
1160
|
+
.passthrough(),
|
|
1161
|
+
/**
|
|
1162
|
+
* Its pod did not start on version `to` (its setup failed, the pod failed, or it took longer
|
|
1163
|
+
* than the Host allows): it went back to version `from`, with its disk as it was.
|
|
1164
|
+
*/
|
|
1165
|
+
"agent.start_failed": z
|
|
1166
|
+
.object({
|
|
1167
|
+
from: z.number().int().positive(),
|
|
1168
|
+
to: z.number().int().positive(),
|
|
1169
|
+
reason: z.string(),
|
|
1170
|
+
reverted: z.boolean(),
|
|
1171
|
+
})
|
|
1172
|
+
.passthrough(),
|
|
1173
|
+
/** A connection through egress-gate, with the turns running as it opened. */
|
|
1174
|
+
"agent.egress": EgressConnectionPayloadSchema,
|
|
1175
|
+
/** A trigger fired, or was run by hand: the run and what came of it (`TriggerRunSchema`). */
|
|
1176
|
+
"agent.run": z
|
|
1177
|
+
.object({
|
|
1178
|
+
runId: z.string(),
|
|
1179
|
+
triggerId: z.string(),
|
|
1180
|
+
dueAt: z.string(),
|
|
1181
|
+
late: z.boolean(),
|
|
1182
|
+
status: z.string(),
|
|
1183
|
+
reason: z.string().optional(),
|
|
1184
|
+
sessionId: z.string().optional(),
|
|
1185
|
+
})
|
|
1186
|
+
.passthrough(),
|
|
1187
|
+
"agent.trigger_paused": z.object({ triggerId: z.string(), reason: z.string() }).passthrough(),
|
|
1188
|
+
"agent.trigger_resumed": z.object({ triggerId: z.string() }).passthrough(),
|
|
1189
|
+
/** A webhook trigger's signing secret was made or replaced; the one before stopped working. */
|
|
1190
|
+
"agent.trigger_secret_rotated": z.object({ triggerId: z.string() }).passthrough(),
|
|
1191
|
+
/** A turn changed the Agent's memories (`memory.updated` in its session): which, and how. */
|
|
1192
|
+
"agent.memory_updated": MemoryUpdatedPayloadSchema.extend({ sessionId: z.string(), turnId: z.string() }),
|
|
1088
1193
|
};
|
|
1089
|
-
/** One lifecycle event on an
|
|
1090
|
-
export const
|
|
1194
|
+
/** One lifecycle event on an Agent's stream, numbered from 0. */
|
|
1195
|
+
export const AgentEventSchema = z
|
|
1091
1196
|
.object({
|
|
1092
|
-
schema: z.literal(
|
|
1197
|
+
schema: z.literal(AGENT_EVENT_SCHEMA),
|
|
1093
1198
|
eventId: z.string(),
|
|
1094
1199
|
tenantId: z.string(),
|
|
1095
|
-
|
|
1200
|
+
agentId: z.string(),
|
|
1096
1201
|
seq: z.number().int().nonnegative(),
|
|
1097
1202
|
time: z.string(),
|
|
1098
|
-
type: z.enum(
|
|
1203
|
+
type: z.enum(AGENT_EVENT_TYPES),
|
|
1099
1204
|
payload: z.record(z.string(), z.unknown()),
|
|
1100
1205
|
})
|
|
1101
1206
|
.strict();
|
|
1102
|
-
export const
|
|
1103
|
-
.object({ events: z.array(
|
|
1207
|
+
export const ListAgentEventsResponseSchema = z
|
|
1208
|
+
.object({ events: z.array(AgentEventSchema) })
|
|
1104
1209
|
.strict();
|
|
1210
|
+
/**
|
|
1211
|
+
* `PUT /v1/sessions/{id}` (protocol 16): the session's Agent, owner and info. The session runs on
|
|
1212
|
+
* the Agent for its life (its sandbox, its vault's credentials) and pins the manifest version the
|
|
1213
|
+
* Agent runs when it opens. No session is special: an app that keeps one conversation
|
|
1214
|
+
* going reuses its id.
|
|
1215
|
+
*/
|
|
1105
1216
|
export const PutSessionRequestSchema = z
|
|
1106
1217
|
.object({
|
|
1107
1218
|
requestId: RequestIdSchema,
|
|
1108
|
-
|
|
1219
|
+
/** The Agent the session runs on. Fixed once the session exists. */
|
|
1220
|
+
agent: AgentIdSchema,
|
|
1109
1221
|
ownerUserId: z.string().min(1),
|
|
1110
1222
|
info: jsonObject.optional(),
|
|
1111
|
-
/**
|
|
1112
|
-
* The Environment the session runs in: its sandbox, and its vault's credentials for the
|
|
1113
|
-
* session's shell, MCP servers and HTTP tools. Omitted: no sandbox and no credentials.
|
|
1114
|
-
* Fixed once the session exists.
|
|
1115
|
-
*/
|
|
1116
|
-
environment: EnvironmentIdSchema.optional(),
|
|
1117
1223
|
})
|
|
1118
1224
|
.strict();
|
|
1119
|
-
/** The hosts a harness can run on
|
|
1225
|
+
/** The hosts a harness can run on. */
|
|
1120
1226
|
export const PLACEMENT_HOSTS = ["harness-container", "sandbox"];
|
|
1121
1227
|
/**
|
|
1122
1228
|
* A Tenant's Environment settings (Tenant setting `environments.config`): the limits every
|
|
@@ -1148,7 +1254,7 @@ export const TenantEnvironmentsConfigSchema = z
|
|
|
1148
1254
|
.strict()
|
|
1149
1255
|
.optional(),
|
|
1150
1256
|
/**
|
|
1151
|
-
* Where each harness may run
|
|
1257
|
+
* Where each harness may run, by harness id (`nylorun`, or `*` for the rest):
|
|
1152
1258
|
* `harness-container` (the Runtime's harness) and `sandbox` (the engine in a pod).
|
|
1153
1259
|
* Default `{ "*": { hosts: ["harness-container", "sandbox"] } }`. Checked when a session
|
|
1154
1260
|
* opens; a host left out is refused (`placement_refused`). `"*": { hosts: [] }` refuses every
|
|
@@ -1177,7 +1283,7 @@ const CredentialHeaderValueSchema = z
|
|
|
1177
1283
|
.string()
|
|
1178
1284
|
.min(1)
|
|
1179
1285
|
.refine((value) => !/[\r\n\0]/.test(value), "A header value has no CR, LF or NUL");
|
|
1180
|
-
/** A `headers` credential's map
|
|
1286
|
+
/** A `headers` credential's map: one or more headers sent on every request. */
|
|
1181
1287
|
const CredentialHeadersSchema = z
|
|
1182
1288
|
.record(CredentialHeaderNameSchema, CredentialHeaderValueSchema)
|
|
1183
1289
|
.refine((value) => Object.keys(value).length > 0, "At least one header is required")
|
|
@@ -1185,7 +1291,7 @@ const CredentialHeadersSchema = z
|
|
|
1185
1291
|
/** A loopback host as a URL's `hostname` names it: plain `http` reaches only these. */
|
|
1186
1292
|
export const LOOPBACK_HOSTS = /^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\])$/i;
|
|
1187
1293
|
/**
|
|
1188
|
-
* `via
|
|
1294
|
+
* `via`: where this installation reaches the credential's server, such as a
|
|
1189
1295
|
* gateway's endpoint for it. An absolute `https` URL (`http` only to a loopback host), with no
|
|
1190
1296
|
* userinfo, query string or fragment. Credentials are still matched by the URL the manifest
|
|
1191
1297
|
* names; `via` changes only where the request goes.
|
|
@@ -1209,7 +1315,7 @@ export const CredentialViaSchema = z.string().superRefine((value, ctx) => {
|
|
|
1209
1315
|
ctx.addIssue({ code: "custom", message: "via may not carry a fragment" });
|
|
1210
1316
|
});
|
|
1211
1317
|
/**
|
|
1212
|
-
* The identity header
|
|
1318
|
+
* The identity header: each request carries the session owner's subject in
|
|
1213
1319
|
* `header`, for a gateway that keeps each person's accounts. A session with no person as its
|
|
1214
1320
|
* owner (the reserved `installation`) sends none.
|
|
1215
1321
|
*/
|
|
@@ -1251,13 +1357,13 @@ const EnvironmentNameSchema = z
|
|
|
1251
1357
|
.regex(ENVIRONMENT_NAME_PATTERN, "An environment variable name is a letter or _ followed by letters, digits or _")
|
|
1252
1358
|
.refine((name) => !isReservedEnvironmentName(name), "That environment variable name is reserved");
|
|
1253
1359
|
/**
|
|
1254
|
-
* The value a sandbox sees for every `environment_secret
|
|
1360
|
+
* The value a sandbox sees for every `environment_secret`: never the secret. Word
|
|
1255
1361
|
* characters only, so CLIs that check a token's format before sending it (the Vercel CLI
|
|
1256
1362
|
* refuses anything matching `\W`) still send the request egress-gate sets the header on.
|
|
1257
1363
|
*/
|
|
1258
1364
|
export const ENVIRONMENT_SECRET_SENTINEL = "nylorun_managed";
|
|
1259
1365
|
/**
|
|
1260
|
-
* How egress-gate writes an `environment_secret` into a request
|
|
1366
|
+
* How egress-gate writes an `environment_secret` into a request: one header, set on
|
|
1261
1367
|
* every request to a bound host. `format` is text with `{value}` once, optionally inside a
|
|
1262
1368
|
* `{base64:…}` group, for example `Bearer {value}` (the default),
|
|
1263
1369
|
* `Basic {base64:x-access-token:{value}}` or `{value}`.
|
|
@@ -1304,13 +1410,13 @@ const EnvironmentValueSchema = z
|
|
|
1304
1410
|
.refine((value) => !/[\r\n\0]/.test(value), "A value has no CR, LF or NUL");
|
|
1305
1411
|
/**
|
|
1306
1412
|
* The name of a credential for a tool (`bearer` or `headers`): a label of 1–64 characters.
|
|
1307
|
-
* An identifier's grammar is the protocol's
|
|
1413
|
+
* An identifier's grammar is the protocol's: it crosses the Runtime API, tokens and grants
|
|
1308
1414
|
* and means the same in every installation, so its length is a constant of protocol 15, not a
|
|
1309
1415
|
* setting.
|
|
1310
1416
|
*/
|
|
1311
1417
|
export const TOOL_SECRET_NAME_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
|
|
1312
1418
|
/**
|
|
1313
|
-
* `PUT /v1/
|
|
1419
|
+
* `PUT /v1/agents/{agentId}/secrets/{name}`: creates or replaces one credential
|
|
1314
1420
|
* in the Environment's vault. For `environment_secret` and `environment_variable` the name is
|
|
1315
1421
|
* the variable's name (a POSIX name, not reserved); for `bearer` and `headers` it is a label.
|
|
1316
1422
|
* The same name and type keeps the credential and re-seals its value and binding; another type
|
|
@@ -1318,7 +1424,7 @@ export const TOOL_SECRET_NAME_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
|
|
|
1318
1424
|
* credentials bound to one host, or two `bearer`/`headers` credentials for one URL, are
|
|
1319
1425
|
* `409 credential_conflict`.
|
|
1320
1426
|
*/
|
|
1321
|
-
export const
|
|
1427
|
+
export const PutAgentSecretRequestSchema = z.discriminatedUnion("type", [
|
|
1322
1428
|
z
|
|
1323
1429
|
.object({
|
|
1324
1430
|
requestId: RequestIdSchema.optional(),
|
|
@@ -1355,10 +1461,10 @@ export const PutEnvironmentSecretRequestSchema = z.discriminatedUnion("type", [
|
|
|
1355
1461
|
.strict(),
|
|
1356
1462
|
]);
|
|
1357
1463
|
/**
|
|
1358
|
-
* A secret write on an Environment whose manifest declares the secret's slot
|
|
1464
|
+
* A secret write on an Environment whose manifest declares the secret's slot: only the
|
|
1359
1465
|
* value, `value` (or `headers` for a `headers` slot). Its type and binding come from the slot.
|
|
1360
1466
|
*/
|
|
1361
|
-
export const
|
|
1467
|
+
export const PutAgentSecretValueRequestSchema = z
|
|
1362
1468
|
.object({
|
|
1363
1469
|
requestId: RequestIdSchema.optional(),
|
|
1364
1470
|
value: z.string().min(1).optional(),
|
|
@@ -1389,8 +1495,8 @@ const slotBase = {
|
|
|
1389
1495
|
description: z.string().optional(),
|
|
1390
1496
|
};
|
|
1391
1497
|
/**
|
|
1392
|
-
* One secret an Environment of a kind needs
|
|
1393
|
-
* value is written into each Environment's vault (`PUT /v1/
|
|
1498
|
+
* One secret an Environment of a kind needs: its type and binding, never its value. The
|
|
1499
|
+
* value is written into each Environment's vault (`PUT /v1/agents/{id}/secrets/{name}`
|
|
1394
1500
|
* with `{ value }`, or `{ headers }` for `headers`), and the binding comes from here.
|
|
1395
1501
|
*/
|
|
1396
1502
|
export const EnvironmentSecretSlotSchema = z.discriminatedUnion("type", [
|
|
@@ -1416,62 +1522,462 @@ export const EnvironmentSecretSlotsSchema = z
|
|
|
1416
1522
|
ctx.addIssue({ code: "custom", path: [name], message: error });
|
|
1417
1523
|
}
|
|
1418
1524
|
});
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
const
|
|
1525
|
+
// --- Agent manifest v8 (protocol 16, track T2) ----------------------------------------------
|
|
1526
|
+
/** The schema version of an agent manifest the Runtime saves at `/v1/agent-manifests/{name}`. */
|
|
1527
|
+
export const AGENT_MANIFEST_V8_SCHEMA_VERSION = 8;
|
|
1528
|
+
/** A skill of the harness section: v7's, and the secret slots its scripts read. */
|
|
1529
|
+
const harnessSkillSchema = z
|
|
1530
|
+
.object({
|
|
1531
|
+
name: z.string().min(1),
|
|
1532
|
+
description: z.string().min(1),
|
|
1533
|
+
files: z.record(z.string(), z.string()),
|
|
1534
|
+
plugin: pluginLabelSchema.optional(),
|
|
1535
|
+
secrets: z
|
|
1536
|
+
.array(z.string().regex(ENVIRONMENT_NAME_PATTERN, "A skill's secrets are environment variable names"))
|
|
1537
|
+
.optional(),
|
|
1538
|
+
})
|
|
1539
|
+
.strict()
|
|
1540
|
+
.superRefine((skill, ctx) => {
|
|
1541
|
+
const issue = skillFilesIssue(skill.files);
|
|
1542
|
+
if (issue)
|
|
1543
|
+
ctx.addIssue({ code: "custom", path: ["files"], message: `Skill '${skill.name}' ${issue}` });
|
|
1544
|
+
});
|
|
1545
|
+
const harnessMcpServerFields = {
|
|
1546
|
+
name: modelFacingName("MCP server"),
|
|
1547
|
+
url: z.string().min(1),
|
|
1548
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
1549
|
+
/** A `runtime.secrets` slot of type `bearer` or `headers` bound to `url`. */
|
|
1550
|
+
credential: z.string().min(1).optional(),
|
|
1551
|
+
...mcpServerSettings,
|
|
1552
|
+
};
|
|
1553
|
+
const harnessMcpServerSchema = z.discriminatedUnion("type", [
|
|
1554
|
+
z.object({ type: z.literal("streamable-http"), ...harnessMcpServerFields }).strict(),
|
|
1555
|
+
z.object({ type: z.literal("sse"), ...harnessMcpServerFields }).strict(),
|
|
1556
|
+
], { error: (issue) => stdioIssue(issue.input) });
|
|
1557
|
+
const harnessIdField = HarnessIdSchema.optional().meta({
|
|
1558
|
+
description: "The harness that runs the loop: `nylorun` (ours, the default) or a custom harness's id",
|
|
1559
|
+
});
|
|
1560
|
+
const harnessLoopField = definitionJson
|
|
1561
|
+
.optional()
|
|
1562
|
+
.meta({ description: "The harness's own settings, passed to it in turn.start; the Runtime never reads them" });
|
|
1422
1563
|
/**
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
1425
|
-
* Environment made from it shares; an Environment's id, labels, owner guard, disk and secret
|
|
1426
|
-
* values are its own. Written as a JSON file with `$schema`, which clients drop before saving.
|
|
1564
|
+
* `harness.memory`: turns the Agent's memory on. Its `access` holds in every turn,
|
|
1565
|
+
* whoever starts it; `instructions` follow the engine's own memory rules.
|
|
1427
1566
|
*/
|
|
1428
|
-
|
|
1567
|
+
const harnessMemoryField = z
|
|
1568
|
+
.strictObject({
|
|
1569
|
+
access: z.enum(MEMORY_ACCESS).optional().meta({ description: "`read_write` (the default) or `read_only`" }),
|
|
1570
|
+
instructions: z
|
|
1571
|
+
.string()
|
|
1572
|
+
.max(MEMORY_INSTRUCTIONS_MAX)
|
|
1573
|
+
.optional()
|
|
1574
|
+
.meta({ description: "What this agent should remember, after the engine's own memory rules" }),
|
|
1575
|
+
})
|
|
1576
|
+
.optional()
|
|
1577
|
+
.meta({ description: "The Agent's memory: Markdown files under /memories it keeps across sessions" });
|
|
1578
|
+
/** Fields the harness section refuses with where they went. */
|
|
1579
|
+
const REMOVED_HARNESS_FIELDS = Object.freeze({
|
|
1580
|
+
requires: "harness.requires left the API in agent manifest v8: the Runtime checks the harness against the runtime section when the manifest is saved. Keep requires in harness.manifest.json, where the CLI checks it",
|
|
1581
|
+
manifestSchemaVersion: "manifestSchemaVersion belongs at the top of the agent manifest, not in harness",
|
|
1582
|
+
name: "name belongs at the top of the agent manifest, not in harness",
|
|
1583
|
+
description: "description belongs at the top of the agent manifest, not in harness",
|
|
1584
|
+
metadata: "metadata belongs at the top of the agent manifest, not in harness",
|
|
1585
|
+
approval: "Tool approvals are the Tenant's tool policy (PUT /v1/tenant/tool-policy)",
|
|
1586
|
+
});
|
|
1587
|
+
const agentHarnessObject = z
|
|
1588
|
+
.strictObject({
|
|
1589
|
+
id: harnessIdField,
|
|
1590
|
+
instructions: z.array(z.string()).optional(),
|
|
1591
|
+
tools: z.array(toolManifestSchema).optional(),
|
|
1592
|
+
skills: z.record(z.string(), harnessSkillSchema).optional(),
|
|
1593
|
+
mcpServers: z.record(z.string(), harnessMcpServerSchema).optional(),
|
|
1594
|
+
plugins: z.array(pluginLabelSchema).optional(),
|
|
1595
|
+
outputSchema: definitionJson.optional(),
|
|
1596
|
+
loop: harnessLoopField,
|
|
1597
|
+
memory: harnessMemoryField,
|
|
1598
|
+
functions: z.unknown().optional().meta({ description: "Reserved: Functions are not available yet" }),
|
|
1599
|
+
}, { error: removedFieldError(REMOVED_HARNESS_FIELDS) })
|
|
1600
|
+
.superRefine((harness, ctx) => {
|
|
1601
|
+
if (harness.functions !== undefined)
|
|
1602
|
+
ctx.addIssue({ code: "custom", path: ["functions"], message: "Functions are not available yet" });
|
|
1603
|
+
delegationIssues({ tools: harness.tools }, (message) => ctx.addIssue({ code: "custom", message }));
|
|
1604
|
+
const names = new Set();
|
|
1605
|
+
for (const tool of harness.tools ?? []) {
|
|
1606
|
+
if (tool.name.includes("__"))
|
|
1607
|
+
ctx.addIssue({
|
|
1608
|
+
code: "custom",
|
|
1609
|
+
message: `Tool '${tool.name}' must not contain '__', which names an MCP server's tools`,
|
|
1610
|
+
});
|
|
1611
|
+
if (names.has(tool.name))
|
|
1612
|
+
ctx.addIssue({ code: "custom", message: "Tool names must be unique" });
|
|
1613
|
+
names.add(tool.name);
|
|
1614
|
+
}
|
|
1615
|
+
if (harness.skills && Object.keys(harness.skills).length === 0)
|
|
1616
|
+
ctx.addIssue({ code: "custom", message: "harness.skills must be omitted when the agent has no skills" });
|
|
1617
|
+
for (const [key, skill] of Object.entries(harness.skills ?? {}))
|
|
1618
|
+
if (key !== skill.name)
|
|
1619
|
+
ctx.addIssue({ code: "custom", message: `harness.skills key '${key}' must equal the skill name` });
|
|
1620
|
+
if (harness.mcpServers && Object.keys(harness.mcpServers).length === 0)
|
|
1621
|
+
ctx.addIssue({ code: "custom", message: "harness.mcpServers must be omitted when the agent has no servers" });
|
|
1622
|
+
for (const [key, server] of Object.entries(harness.mcpServers ?? {}))
|
|
1623
|
+
if (key !== server.name)
|
|
1624
|
+
ctx.addIssue({ code: "custom", message: `harness.mcpServers key '${key}' must equal the server name` });
|
|
1625
|
+
});
|
|
1626
|
+
const workflowHarnessObject = z
|
|
1429
1627
|
.object({
|
|
1430
|
-
|
|
1431
|
-
|
|
1628
|
+
kind: z.literal("workflow"),
|
|
1629
|
+
id: harnessIdField,
|
|
1630
|
+
inputSchema: definitionJson.optional(),
|
|
1631
|
+
outputSchema: definitionJson.optional(),
|
|
1632
|
+
root: workflowNodeSchema,
|
|
1633
|
+
agents: z.record(z.string().min(1), z.union([workflowManifestSchema, AgentManifestSchema])),
|
|
1634
|
+
plugins: z.array(pluginLabelSchema).optional(),
|
|
1635
|
+
loop: harnessLoopField,
|
|
1636
|
+
})
|
|
1637
|
+
.strict()
|
|
1638
|
+
.superRefine((flow, ctx) => {
|
|
1639
|
+
if (flow.id !== undefined && flow.id !== DEFAULT_HARNESS)
|
|
1640
|
+
ctx.addIssue({ code: "custom", path: ["id"], message: `A flow runs in our harness: harness.id must be ${DEFAULT_HARNESS} or left out` });
|
|
1641
|
+
for (const agentId of referencedAgents(flow.root))
|
|
1642
|
+
if (!(agentId in flow.agents))
|
|
1643
|
+
ctx.addIssue({
|
|
1644
|
+
code: "custom",
|
|
1645
|
+
path: ["agents"],
|
|
1646
|
+
message: `Agent '${agentId}' is used in the flow but not embedded in agents`,
|
|
1647
|
+
});
|
|
1648
|
+
for (const [key, agent] of Object.entries(flow.agents))
|
|
1649
|
+
if (agent.id !== key)
|
|
1650
|
+
ctx.addIssue({ code: "custom", path: ["agents", key], message: `Embedded agent '${agent.id}' must be keyed by its id` });
|
|
1651
|
+
});
|
|
1652
|
+
/** What runs inside the loop of an agent: the `harness` section of agent manifest v8. */
|
|
1653
|
+
export const AgentHarnessSectionSchema = agentHarnessObject.meta({
|
|
1654
|
+
id: "AgentHarnessSection",
|
|
1655
|
+
});
|
|
1656
|
+
/** A flow's `harness` section (`kind: "workflow"`). */
|
|
1657
|
+
export const WorkflowHarnessSectionSchema = workflowHarnessObject.meta({
|
|
1658
|
+
id: "WorkflowHarnessSection",
|
|
1659
|
+
});
|
|
1660
|
+
/** The `harness` section: an agent's loop, or a flow (`kind: "workflow"`). */
|
|
1661
|
+
export const HarnessSectionSchema = z.union([WorkflowHarnessSectionSchema, AgentHarnessSectionSchema]);
|
|
1662
|
+
/**
|
|
1663
|
+
* A trigger's id in `runtime.triggers`: 1–64 letters, digits, `.`, `_` and `-`,
|
|
1664
|
+
* starting with a letter or digit. The map key; it names the trigger in routes and runs.
|
|
1665
|
+
*/
|
|
1666
|
+
export const TriggerIdSchema = z
|
|
1667
|
+
.string()
|
|
1668
|
+
.regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/, {
|
|
1669
|
+
message: "A trigger id is 1-64 letters, digits, '.', '_' and '-', starting with a letter or digit",
|
|
1670
|
+
})
|
|
1671
|
+
.meta({ description: "A trigger's id, such as `hourly-check`" });
|
|
1672
|
+
/** The signature schemes a webhook trigger verifies: Standard Webhooks only. */
|
|
1673
|
+
export const WEBHOOK_SCHEMES = ["standard-webhooks"];
|
|
1674
|
+
/**
|
|
1675
|
+
* One trigger of an agent manifest's `runtime.triggers`: exactly one of
|
|
1676
|
+
* `schedule` (five-field cron, minute granularity, in `timezone`, an IANA name, default UTC), `at`
|
|
1677
|
+
* (one run at an RFC 3339 time with an offset) or `webhook` (a webhook endpoint verified with the
|
|
1678
|
+
* named scheme), plus the `session` each run goes to and the author's `prompt`.
|
|
1679
|
+
*
|
|
1680
|
+
* `session` is a session id of the Agent, opened on the trigger's first run if it does not
|
|
1681
|
+
* exist, or `"new"` for a new session per run (`run-<runId>`). The Runtime keeps no main session.
|
|
1682
|
+
* The cron's smallest gap, the `at` time, the prompt's length and how many triggers a
|
|
1683
|
+
* manifest holds are checked against the Tenant's Runtime limits when it is saved.
|
|
1684
|
+
*/
|
|
1685
|
+
export const TriggerSchema = z
|
|
1686
|
+
.strictObject({
|
|
1687
|
+
schedule: z
|
|
1688
|
+
.string()
|
|
1689
|
+
.regex(/^\S+(\s+\S+){4}$/, { message: "schedule is five cron fields: minute hour day-of-month month day-of-week" })
|
|
1690
|
+
.optional(),
|
|
1691
|
+
timezone: z.string().min(1).optional(),
|
|
1692
|
+
at: z.iso.datetime({ offset: true, message: "at is an RFC 3339 time with an offset, such as 2026-11-01T09:00:00+05:30" }).optional(),
|
|
1693
|
+
webhook: z.enum(WEBHOOK_SCHEMES).optional(),
|
|
1694
|
+
session: z.string().min(1).max(200),
|
|
1695
|
+
prompt: z.string().min(1),
|
|
1696
|
+
})
|
|
1697
|
+
.superRefine((trigger, ctx) => {
|
|
1698
|
+
const kinds = [trigger.schedule, trigger.at, trigger.webhook].filter((value) => value !== undefined);
|
|
1699
|
+
if (kinds.length !== 1)
|
|
1700
|
+
ctx.addIssue({ code: "custom", message: "A trigger has exactly one of schedule, at or webhook" });
|
|
1701
|
+
if (trigger.timezone !== undefined && trigger.schedule === undefined)
|
|
1702
|
+
ctx.addIssue({ code: "custom", path: ["timezone"], message: "timezone goes with schedule" });
|
|
1703
|
+
})
|
|
1704
|
+
.meta({ id: "Trigger" });
|
|
1705
|
+
/** What a trigger is: the field it has, or `wake` for a session's own booking. */
|
|
1706
|
+
export const TRIGGER_KINDS = ["schedule", "at", "webhook", "wake"];
|
|
1707
|
+
/** A trigger's kind, from its manifest entry. */
|
|
1708
|
+
export function triggerKindOf(trigger) {
|
|
1709
|
+
return trigger.schedule !== undefined ? "schedule" : trigger.at !== undefined ? "at" : "webhook";
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* A trigger's status on an Agent: `active` fires, `paused` does not (`pausedReason`
|
|
1713
|
+
* `manual`, or `new` for one an upgrade added), `completed` is an `at` that ran.
|
|
1714
|
+
*/
|
|
1715
|
+
export const TRIGGER_STATUSES = ["active", "paused", "completed"];
|
|
1716
|
+
/** `GET /v1/agents/{id}/triggers`: one trigger, from its manifest entry and the Agent's state. */
|
|
1717
|
+
export const TriggerViewSchema = z
|
|
1718
|
+
.object({
|
|
1719
|
+
id: z.string(),
|
|
1720
|
+
kind: z.enum(TRIGGER_KINDS),
|
|
1721
|
+
status: z.enum(TRIGGER_STATUSES),
|
|
1722
|
+
pausedReason: z.string().nullable(),
|
|
1723
|
+
schedule: z.string().optional(),
|
|
1724
|
+
timezone: z.string().optional(),
|
|
1725
|
+
at: z.string().optional(),
|
|
1726
|
+
/** The session each run goes to: a session id, or `new`. */
|
|
1727
|
+
session: z.string(),
|
|
1728
|
+
/** When it fires next, or `null` while paused or completed. */
|
|
1729
|
+
nextRunAt: z.string().nullable(),
|
|
1730
|
+
lastRunAt: z.string().nullable(),
|
|
1731
|
+
/**
|
|
1732
|
+
* A webhook trigger's endpoint: `POST` Standard Webhooks deliveries to it. The origin is
|
|
1733
|
+
* the one this read reached.
|
|
1734
|
+
*/
|
|
1735
|
+
webhookUrl: z.string().optional(),
|
|
1736
|
+
/** Whether a webhook trigger has a signing secret (`POST .../secret` makes one). */
|
|
1737
|
+
secretSet: z.boolean().optional(),
|
|
1738
|
+
})
|
|
1739
|
+
.strict();
|
|
1740
|
+
export const TriggerListSchema = z.object({ triggers: z.array(TriggerViewSchema) }).strict();
|
|
1741
|
+
/**
|
|
1742
|
+
* What a run came to: `started` a turn, `queued` a message behind a running turn,
|
|
1743
|
+
* `skipped` (nothing started: `overlap`, `rate_limited`, `paused`) or `failed` (`queue_full`,
|
|
1744
|
+
* `session_conflict`, `agent_unavailable`).
|
|
1745
|
+
*/
|
|
1746
|
+
export const TRIGGER_RUN_STATUSES = ["started", "queued", "skipped", "failed"];
|
|
1747
|
+
/** One run: a trigger fired, or was run by hand. */
|
|
1748
|
+
export const TriggerRunSchema = z
|
|
1749
|
+
.object({
|
|
1750
|
+
id: z.string(),
|
|
1751
|
+
triggerId: z.string(),
|
|
1752
|
+
kind: z.enum(TRIGGER_KINDS),
|
|
1753
|
+
/** When it was due; for a run by hand or a webhook, when it arrived. */
|
|
1754
|
+
dueAt: z.string(),
|
|
1755
|
+
firedAt: z.string(),
|
|
1756
|
+
/** Fired more than the Host's `triggers.lateGraceMs` after it was due (after downtime). */
|
|
1757
|
+
late: z.boolean(),
|
|
1758
|
+
status: z.enum(TRIGGER_RUN_STATUSES),
|
|
1759
|
+
reason: z.string().nullable(),
|
|
1760
|
+
sessionId: z.string().nullable(),
|
|
1761
|
+
turnId: z.string().nullable(),
|
|
1762
|
+
queuedMessageId: z.string().nullable(),
|
|
1763
|
+
})
|
|
1764
|
+
.strict();
|
|
1765
|
+
/** `GET /v1/agents/{id}/runs`: runs, newest first. */
|
|
1766
|
+
export const TriggerRunPageSchema = z
|
|
1767
|
+
.object({ runs: z.array(TriggerRunSchema), nextCursor: z.string().nullable() })
|
|
1768
|
+
.strict();
|
|
1769
|
+
/**
|
|
1770
|
+
* `POST /v1/agents/{id}/triggers/{triggerId}/secret`: a webhook trigger's new signing secret,
|
|
1771
|
+
* in the Standard Webhooks format (`whsec_` and 32 random bytes in base64), shown this once. It
|
|
1772
|
+
* replaces the one before at once.
|
|
1773
|
+
*/
|
|
1774
|
+
export const WebhookSecretResponseSchema = z
|
|
1775
|
+
.object({ triggerId: z.string(), webhookUrl: z.string(), secret: z.string() })
|
|
1776
|
+
.strict();
|
|
1777
|
+
/** `POST /v1/webhooks/{endpointId}`: the run a delivery made, or the run a repeated delivery made. */
|
|
1778
|
+
export const WebhookAcceptedResponseSchema = z
|
|
1779
|
+
.object({ runId: z.string(), status: z.enum(TRIGGER_RUN_STATUSES), reason: z.string().nullable() })
|
|
1780
|
+
.strict();
|
|
1781
|
+
/** `POST /v1/agents/{id}/triggers/{triggerId}/run`: the run it made. */
|
|
1782
|
+
export const RunTriggerResponseSchema = z.object({ run: TriggerRunSchema }).strict();
|
|
1783
|
+
/**
|
|
1784
|
+
* One of an Agent's memories, as `GET /v1/agents/{id}/memories` lists it: its
|
|
1785
|
+
* path under `/memories`, size, content hash (the precondition a `PUT` may send), the
|
|
1786
|
+
* `description` of its frontmatter when it has one, and its version, which every change bumps.
|
|
1787
|
+
*/
|
|
1788
|
+
export const MemorySummarySchema = z
|
|
1789
|
+
.object({
|
|
1790
|
+
path: z.string(),
|
|
1791
|
+
bytes: z.number().int().nonnegative(),
|
|
1792
|
+
contentSha256: z.string(),
|
|
1793
|
+
description: z.string().nullable(),
|
|
1794
|
+
version: z.number().int().positive(),
|
|
1795
|
+
updatedAt: z.string(),
|
|
1796
|
+
})
|
|
1797
|
+
.strict();
|
|
1798
|
+
/** `GET /v1/agents/{id}/memories`: memories by path. */
|
|
1799
|
+
export const MemoryListSchema = z
|
|
1800
|
+
.object({ memories: z.array(MemorySummarySchema), nextCursor: z.string().nullable() })
|
|
1801
|
+
.strict();
|
|
1802
|
+
/** `GET /v1/agents/{id}/memories/{path}`: one memory with its content. */
|
|
1803
|
+
export const MemorySchema = MemorySummarySchema.extend({ content: z.string() }).strict();
|
|
1804
|
+
/**
|
|
1805
|
+
* `PUT /v1/agents/{id}/memories/{path}`: the memory's whole content, creating it or replacing it.
|
|
1806
|
+
* With `contentSha256`, the write applies only while the memory's content still has that hash
|
|
1807
|
+
* (`409 memory_conflict` with the current text otherwise); an empty string requires that no
|
|
1808
|
+
* memory has the path.
|
|
1809
|
+
*/
|
|
1810
|
+
export const PutMemoryRequestSchema = z
|
|
1811
|
+
.object({
|
|
1812
|
+
content: z.string(),
|
|
1813
|
+
contentSha256: z.string().optional(),
|
|
1814
|
+
})
|
|
1815
|
+
.strict();
|
|
1816
|
+
/**
|
|
1817
|
+
* One change to a memory: what changed it (`create`, `str_replace`, `insert`, `delete`,
|
|
1818
|
+
* `rename`), the content it left (`null` for a delete), and who made it: `agent:<manifest>@<n>`
|
|
1819
|
+
* for a turn, with its session, turn and trigger run, or the principal of an API call. A rename's
|
|
1820
|
+
* version is on the new path and names the old one in `fromPath`.
|
|
1821
|
+
*/
|
|
1822
|
+
export const MemoryVersionSchema = z
|
|
1823
|
+
.object({
|
|
1824
|
+
id: z.string(),
|
|
1825
|
+
path: z.string(),
|
|
1826
|
+
fromPath: z.string().nullable(),
|
|
1827
|
+
operation: z.enum(MEMORY_OPERATIONS),
|
|
1828
|
+
bytes: z.number().int().nonnegative().nullable(),
|
|
1829
|
+
contentSha256: z.string().nullable(),
|
|
1830
|
+
actor: z.string(),
|
|
1831
|
+
sessionId: z.string().nullable(),
|
|
1832
|
+
turnId: z.string().nullable(),
|
|
1833
|
+
triggerRunId: z.string().nullable(),
|
|
1834
|
+
createdAt: z.string(),
|
|
1835
|
+
})
|
|
1836
|
+
.strict();
|
|
1837
|
+
/** `GET /v1/agents/{id}/memory_versions/{versionId}`: one version with the content it left. */
|
|
1838
|
+
export const MemoryVersionDetailSchema = MemoryVersionSchema.extend({ content: z.string().nullable() })
|
|
1839
|
+
.strict();
|
|
1840
|
+
/** `GET /v1/agents/{id}/memory_versions`: versions, newest first. */
|
|
1841
|
+
export const MemoryVersionPageSchema = z
|
|
1842
|
+
.object({ versions: z.array(MemoryVersionSchema), nextCursor: z.string().nullable() })
|
|
1843
|
+
.strict();
|
|
1844
|
+
/**
|
|
1845
|
+
* What the Runtime provides around the loop: the `runtime` section of agent manifest v8, with
|
|
1846
|
+
* environment manifest v1's fields but its identity and its `harness` (now `harness.id`).
|
|
1847
|
+
* `triggers` start the Agent's turns with no client connected; `selfWake` offers
|
|
1848
|
+
* the agent `schedule_wake`, which books its session's next turn.
|
|
1849
|
+
*/
|
|
1850
|
+
const runtimeSectionObject = z
|
|
1851
|
+
.strictObject({
|
|
1852
|
+
kind: z.enum(ENVIRONMENT_KINDS, {
|
|
1853
|
+
error: () => `runtime.kind is required: ${ENVIRONMENT_KINDS.join(", ")}`,
|
|
1854
|
+
}),
|
|
1855
|
+
image: runtimeFields.image,
|
|
1856
|
+
resources: runtimeFields.resources,
|
|
1857
|
+
storage: runtimeFields.storage,
|
|
1858
|
+
network: runtimeFields.network,
|
|
1859
|
+
lifecycle: runtimeFields.lifecycle,
|
|
1860
|
+
setup: runtimeFields.setup,
|
|
1861
|
+
files: runtimeFields.files,
|
|
1862
|
+
limits: runtimeFields.limits,
|
|
1863
|
+
secrets: EnvironmentSecretSlotsSchema.optional(),
|
|
1864
|
+
triggers: z
|
|
1865
|
+
.record(TriggerIdSchema, TriggerSchema)
|
|
1866
|
+
.optional()
|
|
1867
|
+
.meta({ description: "What starts the Agent's turns with no client connected, by trigger id" }),
|
|
1868
|
+
selfWake: z
|
|
1869
|
+
.boolean()
|
|
1870
|
+
.optional()
|
|
1871
|
+
.meta({ description: "Offer the agent schedule_wake: it books its session's next turn itself" }),
|
|
1872
|
+
}, { error: removedFieldError(REMOVED_RUNTIME_SECTION_FIELDS) })
|
|
1873
|
+
.meta({ id: "RuntimeSection" });
|
|
1874
|
+
export const RuntimeSectionSchema = runtimeSectionObject;
|
|
1875
|
+
/**
|
|
1876
|
+
* Agent manifest v8 (protocol 16): one versioned document with what runs inside the
|
|
1877
|
+
* agent loop (`harness`) and what the Runtime provides around it (`runtime`), saved at
|
|
1878
|
+
* `PUT /v1/agent-manifests/{name}`. Without `runtime`, an Agent made from it is kind `none`.
|
|
1879
|
+
* The Runtime also checks the two sections against each other when it is saved (`sectionGaps`).
|
|
1880
|
+
*/
|
|
1881
|
+
export const AgentManifestV8Schema = z
|
|
1882
|
+
.object({
|
|
1883
|
+
manifestSchemaVersion: z.literal(AGENT_MANIFEST_V8_SCHEMA_VERSION, {
|
|
1884
|
+
error: (issue) => agentManifestVersionIssue(issue.input),
|
|
1432
1885
|
}),
|
|
1433
|
-
name:
|
|
1886
|
+
name: AgentManifestNameSchema,
|
|
1434
1887
|
/** At most the Tenant's Runtime limit `manifestDescriptionChars`, checked when it is saved. */
|
|
1435
1888
|
description: z.string().optional(),
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1889
|
+
metadata: definitionJson.optional(),
|
|
1890
|
+
harness: HarnessSectionSchema,
|
|
1891
|
+
runtime: RuntimeSectionSchema.optional(),
|
|
1892
|
+
})
|
|
1893
|
+
.strict()
|
|
1894
|
+
.meta({ id: "AgentManifestV8" });
|
|
1895
|
+
/**
|
|
1896
|
+
* `harness.manifest.json`, an authoring file `nylorun apply` and the SDK's `composeManifest`
|
|
1897
|
+
* read: the harness section, whose `skills`, `mcpServers` and `plugins` may be paths relative to
|
|
1898
|
+
* the file, with a `credentials` map from MCP server or HTTP tool names to `runtime.secrets`
|
|
1899
|
+
* slots, and `requires`, a portable contract the composer checks against the runtime section.
|
|
1900
|
+
* The API never sees it.
|
|
1901
|
+
*/
|
|
1902
|
+
export const HARNESS_MANIFEST_FILE_SCHEMA_VERSION = 1;
|
|
1903
|
+
const pathField = (what) => z.string().min(1).meta({ description: `A path to ${what}, relative to this file` });
|
|
1904
|
+
export const HarnessManifestFileSchema = z
|
|
1905
|
+
.object({
|
|
1906
|
+
$schema: z.string().optional(),
|
|
1907
|
+
id: harnessIdField,
|
|
1908
|
+
instructions: z.array(z.string()).optional(),
|
|
1909
|
+
tools: z.array(toolManifestSchema).optional(),
|
|
1910
|
+
skills: z
|
|
1911
|
+
.union([pathField("a folder of skill folders"), z.record(z.string(), harnessSkillSchema)])
|
|
1912
|
+
.optional(),
|
|
1913
|
+
mcpServers: z
|
|
1914
|
+
.union([pathField("an mcp.json file"), z.record(z.string(), harnessMcpServerSchema)])
|
|
1915
|
+
.optional(),
|
|
1916
|
+
plugins: z.array(z.union([pathField("an Agent Plugin folder"), pluginLabelSchema])).optional(),
|
|
1917
|
+
outputSchema: definitionJson.optional(),
|
|
1918
|
+
loop: harnessLoopField,
|
|
1919
|
+
memory: harnessMemoryField,
|
|
1920
|
+
/** MCP server or HTTP tool name → the `runtime.secrets` slot it authenticates with. */
|
|
1921
|
+
credentials: z.record(z.string().min(1), z.string().min(1)).optional(),
|
|
1922
|
+
/** What this harness needs of any runtime it is combined with; checked by the composer only. */
|
|
1923
|
+
requires: agentRequirementsSchema.optional(),
|
|
1924
|
+
})
|
|
1925
|
+
.strict();
|
|
1926
|
+
/** `runtime.manifest.json`: the runtime section as a file, often shared by many agents. */
|
|
1927
|
+
export const RUNTIME_MANIFEST_FILE_SCHEMA_VERSION = 1;
|
|
1928
|
+
export const RuntimeManifestFileSchema = runtimeSectionObject.extend({
|
|
1929
|
+
$schema: z.string().optional(),
|
|
1930
|
+
/** Also `{ path, from }`: a folder beside the file that the composer uploads by hash as `{ path, files }`. */
|
|
1931
|
+
files: z
|
|
1932
|
+
.array(z.union([
|
|
1933
|
+
EnvironmentFileSchema,
|
|
1934
|
+
z.object({ path: z.string().min(1), from: z.string().min(1) }).strict(),
|
|
1935
|
+
]))
|
|
1936
|
+
.optional(),
|
|
1937
|
+
});
|
|
1938
|
+
/**
|
|
1939
|
+
* `agent.manifest.json`: an agent manifest v8 whose `harness` and `runtime` may each be a path to
|
|
1940
|
+
* an authoring file (or inline). The composer resolves both and sends one document.
|
|
1941
|
+
*/
|
|
1942
|
+
export const AgentManifestFileSchema = z
|
|
1943
|
+
.object({
|
|
1944
|
+
$schema: z.string().optional(),
|
|
1945
|
+
manifestSchemaVersion: z.literal(AGENT_MANIFEST_V8_SCHEMA_VERSION, {
|
|
1946
|
+
error: (issue) => agentManifestVersionIssue(issue.input),
|
|
1947
|
+
}),
|
|
1948
|
+
name: AgentManifestNameSchema,
|
|
1949
|
+
description: z.string().optional(),
|
|
1950
|
+
metadata: definitionJson.optional(),
|
|
1951
|
+
harness: z.union([pathField("a harness.manifest.json file"), HarnessManifestFileSchema, WorkflowHarnessSectionSchema]),
|
|
1952
|
+
runtime: z.union([pathField("a runtime.manifest.json file"), RuntimeManifestFileSchema]).optional(),
|
|
1447
1953
|
})
|
|
1448
1954
|
.strict();
|
|
1449
|
-
/** `PUT /v1/
|
|
1450
|
-
export const
|
|
1955
|
+
/** `PUT /v1/agent-manifests/{name}`: the manifest, whose `name` is the path's. */
|
|
1956
|
+
export const PutAgentManifestRequestSchema = AgentManifestV8Schema.extend({
|
|
1451
1957
|
requestId: RequestIdSchema.optional(),
|
|
1452
1958
|
}).strict();
|
|
1453
1959
|
/** Who saved a version: the subject a request acted for, else `application`. */
|
|
1454
|
-
export const
|
|
1455
|
-
/** One version of an
|
|
1456
|
-
export const
|
|
1960
|
+
export const AgentManifestSavedBySchema = z.object({ actor: z.string() }).strict();
|
|
1961
|
+
/** One version of an agent manifest. */
|
|
1962
|
+
export const AgentManifestViewSchema = z
|
|
1457
1963
|
.object({
|
|
1458
1964
|
name: z.string(),
|
|
1459
1965
|
version: z.number().int().positive(),
|
|
1460
1966
|
/** The hash of `manifest`: equal manifests have equal hashes. */
|
|
1461
1967
|
hash: z.string(),
|
|
1462
|
-
manifest:
|
|
1463
|
-
savedBy:
|
|
1968
|
+
manifest: AgentManifestV8Schema,
|
|
1969
|
+
savedBy: AgentManifestSavedBySchema,
|
|
1464
1970
|
createdAt: z.string(),
|
|
1465
|
-
/** How many
|
|
1466
|
-
|
|
1971
|
+
/** How many Agents were made from this version. */
|
|
1972
|
+
agents: z.number().int().nonnegative(),
|
|
1467
1973
|
})
|
|
1468
1974
|
.strict();
|
|
1469
|
-
/** `GET /v1/
|
|
1470
|
-
export const
|
|
1471
|
-
.object({ manifests: z.array(
|
|
1975
|
+
/** `GET /v1/agent-manifests`: each manifest's latest version, by name. */
|
|
1976
|
+
export const ListAgentManifestsResponseSchema = z
|
|
1977
|
+
.object({ manifests: z.array(AgentManifestViewSchema) })
|
|
1472
1978
|
.strict();
|
|
1473
|
-
/** `GET /v1/
|
|
1474
|
-
export const
|
|
1979
|
+
/** `GET /v1/agent-manifests/{name}/versions`: every version, newest first. */
|
|
1980
|
+
export const AgentManifestVersionsSchema = z
|
|
1475
1981
|
.object({
|
|
1476
1982
|
name: z.string(),
|
|
1477
1983
|
latest: z.number().int().positive(),
|
|
@@ -1479,24 +1985,36 @@ export const EnvironmentManifestVersionsSchema = z
|
|
|
1479
1985
|
.object({
|
|
1480
1986
|
version: z.number().int().positive(),
|
|
1481
1987
|
hash: z.string(),
|
|
1482
|
-
savedBy:
|
|
1988
|
+
savedBy: AgentManifestSavedBySchema,
|
|
1483
1989
|
createdAt: z.string(),
|
|
1484
|
-
|
|
1990
|
+
agents: z.number().int().nonnegative(),
|
|
1485
1991
|
})
|
|
1486
1992
|
.strict()),
|
|
1487
1993
|
})
|
|
1488
1994
|
.strict();
|
|
1489
1995
|
/** Something a save would do that the saver should know: never a refusal. */
|
|
1490
|
-
export const
|
|
1996
|
+
export const AgentManifestWarningSchema = z
|
|
1491
1997
|
.object({ code: z.string(), message: z.string() })
|
|
1492
1998
|
.strict();
|
|
1999
|
+
/** One field a save changes, by its section and its path in it. */
|
|
2000
|
+
export const AgentManifestChangeSchema = z
|
|
2001
|
+
.object({
|
|
2002
|
+
/** `harness`, `runtime`, or `manifest` for the top-level fields. */
|
|
2003
|
+
section: z.enum(["manifest", "harness", "runtime"]),
|
|
2004
|
+
path: z.string(),
|
|
2005
|
+
op: z.enum(["add", "remove", "replace"]),
|
|
2006
|
+
from: z.unknown().optional(),
|
|
2007
|
+
to: z.unknown().optional(),
|
|
2008
|
+
})
|
|
2009
|
+
.strict();
|
|
1493
2010
|
/**
|
|
1494
|
-
* `PUT /v1/
|
|
1495
|
-
*
|
|
1496
|
-
* a save with errors is
|
|
1497
|
-
* the
|
|
2011
|
+
* `PUT /v1/agent-manifests/{name}?dryRun=true`: what saving it would do, with nothing saved.
|
|
2012
|
+
* `errors` lists every reason the Runtime would refuse it: the gaps between its sections, the
|
|
2013
|
+
* Tenant's limits, its files; a save with errors is refused. A save moves every Agent that tracks
|
|
2014
|
+
* the manifest: `moves` counts them by when the new version applies. `behind` counts
|
|
2015
|
+
* the Agents that stay on an older version: pinned ones, and tracking ones it cannot move.
|
|
1498
2016
|
*/
|
|
1499
|
-
export const
|
|
2017
|
+
export const AgentManifestPlanSchema = z
|
|
1500
2018
|
.object({
|
|
1501
2019
|
name: z.string(),
|
|
1502
2020
|
/** The latest version now, or `null` for a new manifest. */
|
|
@@ -1504,54 +2022,62 @@ export const EnvironmentManifestPlanSchema = z
|
|
|
1504
2022
|
/** The version a save would answer: `from` when nothing changed. */
|
|
1505
2023
|
to: z.number().int().positive(),
|
|
1506
2024
|
unchanged: z.boolean(),
|
|
1507
|
-
changes: z.array(
|
|
1508
|
-
warnings: z.array(
|
|
2025
|
+
changes: z.array(AgentManifestChangeSchema),
|
|
2026
|
+
warnings: z.array(AgentManifestWarningSchema),
|
|
1509
2027
|
errors: z.array(z.string()),
|
|
1510
2028
|
behind: z.number().int().nonnegative(),
|
|
2029
|
+
/** The tracking Agents a save moves: at once, at their pod's next start, once their secrets are set. */
|
|
2030
|
+
moves: z
|
|
2031
|
+
.object({
|
|
2032
|
+
now: z.number().int().nonnegative(),
|
|
2033
|
+
nextStart: z.number().int().nonnegative(),
|
|
2034
|
+
secrets: z.number().int().nonnegative(),
|
|
2035
|
+
})
|
|
2036
|
+
.strict(),
|
|
1511
2037
|
})
|
|
1512
2038
|
.strict();
|
|
1513
|
-
/** `PUT /v1/
|
|
1514
|
-
export const
|
|
2039
|
+
/** `PUT /v1/agent-manifests/{name}`: the version saved (or the latest, unchanged). */
|
|
2040
|
+
export const SaveAgentManifestResponseSchema = z
|
|
1515
2041
|
.object({
|
|
1516
|
-
manifest:
|
|
2042
|
+
manifest: AgentManifestViewSchema,
|
|
1517
2043
|
unchanged: z.boolean(),
|
|
1518
|
-
warnings: z.array(
|
|
2044
|
+
warnings: z.array(AgentManifestWarningSchema),
|
|
1519
2045
|
})
|
|
1520
2046
|
.strict();
|
|
1521
|
-
export const
|
|
2047
|
+
export const DeleteAgentManifestResponseSchema = z
|
|
1522
2048
|
.object({ name: z.string(), deleted: z.boolean() })
|
|
1523
2049
|
.strict();
|
|
1524
2050
|
/**
|
|
1525
|
-
* `POST /v1/
|
|
1526
|
-
*
|
|
1527
|
-
*
|
|
1528
|
-
* disk and its sessions.
|
|
2051
|
+
* `POST /v1/agents/{id}/fork`: copies an Agent, with its disk and vault, into a new one,
|
|
2052
|
+
* made from `manifest` (default the source's manifest at its latest version): how an Agent
|
|
2053
|
+
* changes what is fixed for its life (its kind, harness, storage or manifest). The source keeps
|
|
2054
|
+
* what it runs, its disk and its sessions.
|
|
1529
2055
|
*/
|
|
1530
|
-
export const
|
|
2056
|
+
export const ForkAgentRequestSchema = z
|
|
1531
2057
|
.object({
|
|
1532
2058
|
requestId: RequestIdSchema.optional(),
|
|
1533
|
-
/** The new
|
|
1534
|
-
id:
|
|
1535
|
-
/** `name` or `name@n`; default the source's manifest
|
|
1536
|
-
manifest:
|
|
2059
|
+
/** The new Agent's id. */
|
|
2060
|
+
id: AgentIdSchema,
|
|
2061
|
+
/** `name` or `name@n`; default the source's manifest name (tracking). */
|
|
2062
|
+
manifest: AgentManifestRefSchema.optional(),
|
|
1537
2063
|
/** Where its disk starts: `latest` (a snapshot taken first; the default), a version, or `empty`. */
|
|
1538
2064
|
disk: z.union([z.literal("latest"), z.literal("empty"), z.number().int().positive()]).optional(),
|
|
1539
|
-
/** `copy` (the default): the source's secrets the new manifest declares
|
|
2065
|
+
/** `copy` (the default): the source's secrets the new manifest declares. */
|
|
1540
2066
|
secrets: z.enum(["copy", "none"]).optional(),
|
|
1541
2067
|
labels: EnvironmentLabelsSchema.optional(),
|
|
1542
|
-
|
|
2068
|
+
owner: z.string().min(1).nullable().optional(),
|
|
1543
2069
|
/** Answer the plan and make nothing. */
|
|
1544
2070
|
dryRun: z.boolean().optional(),
|
|
1545
2071
|
})
|
|
1546
2072
|
.strict();
|
|
1547
2073
|
/** What a fork does (or, with `dryRun`, would do). */
|
|
1548
|
-
export const
|
|
2074
|
+
export const AgentForkPlanSchema = z
|
|
1549
2075
|
.object({
|
|
1550
2076
|
source: z.string(),
|
|
1551
2077
|
id: z.string(),
|
|
1552
2078
|
kind: z.enum(ENVIRONMENT_KINDS),
|
|
1553
|
-
/** The manifest version it is made from
|
|
1554
|
-
manifest: z.object({ name: z.string(), version: z.number().int().positive() }).strict()
|
|
2079
|
+
/** The manifest version it is made from. */
|
|
2080
|
+
manifest: z.object({ name: z.string(), version: z.number().int().positive() }).strict(),
|
|
1555
2081
|
/** The disk version it starts from: `latest` in a dry run (the snapshot is taken at the fork); `null` for an empty disk. */
|
|
1556
2082
|
disk: z.union([z.number().int().positive(), z.literal("latest")]).nullable(),
|
|
1557
2083
|
/** Whether the new manifest's setup runs on the copied disk: it differs from what the source runs. */
|
|
@@ -1570,13 +2096,63 @@ export const EnvironmentForkPlanSchema = z
|
|
|
1570
2096
|
changes: z.array(z.object({ path: z.string(), from: z.unknown().optional(), to: z.unknown().optional() }).strict()),
|
|
1571
2097
|
/** The source's sessions: they stay on it. */
|
|
1572
2098
|
sessions: z.number().int().nonnegative(),
|
|
2099
|
+
/** The source's memories: copied as they are now, each at version 1, with no history. */
|
|
2100
|
+
memories: z.number().int().nonnegative(),
|
|
1573
2101
|
})
|
|
1574
2102
|
.strict();
|
|
1575
|
-
/** `POST /v1/
|
|
1576
|
-
export const
|
|
1577
|
-
z.object({ dryRun: z.literal(true), plan:
|
|
1578
|
-
z.object({
|
|
2103
|
+
/** `POST /v1/agents/{id}/fork`: the new Agent and the plan it ran, or with `dryRun` the plan only. */
|
|
2104
|
+
export const ForkAgentResponseSchema = z.union([
|
|
2105
|
+
z.object({ dryRun: z.literal(true), plan: AgentForkPlanSchema }).strict(),
|
|
2106
|
+
z.object({ agent: AgentViewSchema, plan: AgentForkPlanSchema }).strict(),
|
|
1579
2107
|
]);
|
|
2108
|
+
/**
|
|
2109
|
+
* `PUT /v1/agents/{id}?dryRun=true` on an existing Agent: what moving it to the
|
|
2110
|
+
* version `manifest` names would do, with nothing changed. `applies`: `none` (it runs that
|
|
2111
|
+
* version), `now` (turns that start from here run it), `next_start` (a runtime change: its pod's
|
|
2112
|
+
* next start applies it), `secrets` (it waits for a value of each of `missingSecrets`), or
|
|
2113
|
+
* `refused` (`refusals` names each fixed field it would change: `409 agent_fixed_field`).
|
|
2114
|
+
*/
|
|
2115
|
+
export const AgentMovePlanSchema = z
|
|
2116
|
+
.object({
|
|
2117
|
+
agent: z.string(),
|
|
2118
|
+
manifest: z.string(),
|
|
2119
|
+
/** The version it runs now, and the one it would run. */
|
|
2120
|
+
from: z.number().int().positive(),
|
|
2121
|
+
to: z.number().int().positive(),
|
|
2122
|
+
/** How it names its manifest after the move. */
|
|
2123
|
+
tracking: z.enum(["tracking", "pinned"]),
|
|
2124
|
+
applies: z.enum(["none", "now", "next_start", "secrets", "refused"]),
|
|
2125
|
+
/** How the version differs from the one it runs, by section. */
|
|
2126
|
+
changes: z.array(z
|
|
2127
|
+
.object({
|
|
2128
|
+
section: z.enum(["manifest", "harness", "runtime"]),
|
|
2129
|
+
path: z.string(),
|
|
2130
|
+
op: z.enum(["add", "remove", "replace"]),
|
|
2131
|
+
from: z.unknown().optional(),
|
|
2132
|
+
to: z.unknown().optional(),
|
|
2133
|
+
})
|
|
2134
|
+
.strict()),
|
|
2135
|
+
/** Required secrets of the version with no value the version can use. */
|
|
2136
|
+
missingSecrets: z.array(z.string()),
|
|
2137
|
+
/** Its secrets the version does not declare: kept, and unused while it runs the version. */
|
|
2138
|
+
dormantSecrets: z.array(z.string()),
|
|
2139
|
+
/** What is fixed for its life that the version would change: kind, harness, storage. */
|
|
2140
|
+
refusals: z.array(z.object({ field: z.string(), from: z.unknown().optional(), to: z.unknown().optional() }).strict()),
|
|
2141
|
+
/** Its sessions: each takes the version at its next turn once it applies. */
|
|
2142
|
+
sessions: z.number().int().nonnegative(),
|
|
2143
|
+
})
|
|
2144
|
+
.strict();
|
|
2145
|
+
/**
|
|
2146
|
+
* `POST /v1/agents/{id}/restart`: applies a pending version now. A running pod stops,
|
|
2147
|
+
* so the next turn starts it on the version (a stopped one starts at once); `retry` first moves
|
|
2148
|
+
* it to the version that failed to start (`failedVersion`) again.
|
|
2149
|
+
*/
|
|
2150
|
+
export const RestartAgentRequestSchema = z
|
|
2151
|
+
.object({ requestId: RequestIdSchema.optional(), retry: z.boolean().optional() })
|
|
2152
|
+
.strict();
|
|
2153
|
+
export const PutAgentDryRunResponseSchema = z
|
|
2154
|
+
.object({ dryRun: z.literal(true), plan: AgentMovePlanSchema })
|
|
2155
|
+
.strict();
|
|
1580
2156
|
/**
|
|
1581
2157
|
* What a model may read (protocol 12): `text` always; `image`, `pdf`, `office` (Word, Excel,
|
|
1582
2158
|
* PowerPoint), `audio` and `video` when its catalog entry or the operator says so. In this order.
|
|
@@ -1648,7 +2224,7 @@ export const ENVIRONMENT_SECRET_TYPES = [
|
|
|
1648
2224
|
* One credential of an Environment's vault, never its value: what it is bound to (the server
|
|
1649
2225
|
* `url` for `bearer` and `headers`; the hosts and header for `environment_secret`).
|
|
1650
2226
|
*/
|
|
1651
|
-
export const
|
|
2227
|
+
export const AgentSecretViewSchema = z
|
|
1652
2228
|
.object({
|
|
1653
2229
|
name: z.string(),
|
|
1654
2230
|
type: z.enum(ENVIRONMENT_SECRET_TYPES),
|
|
@@ -1667,14 +2243,14 @@ export const EnvironmentSecretViewSchema = z
|
|
|
1667
2243
|
rotatedAt: z.string().optional(),
|
|
1668
2244
|
})
|
|
1669
2245
|
.strict();
|
|
1670
|
-
export const
|
|
1671
|
-
.object({ secrets: z.array(
|
|
2246
|
+
export const ListAgentSecretsResponseSchema = z
|
|
2247
|
+
.object({ secrets: z.array(AgentSecretViewSchema) })
|
|
1672
2248
|
.strict();
|
|
1673
2249
|
/** The MCP transports a preview speaks: a manifest's remote server types. */
|
|
1674
2250
|
export const MCP_PREVIEW_TYPES = ["streamable-http", "sse"];
|
|
1675
2251
|
/**
|
|
1676
|
-
* `POST /v1/tenant/mcp/preview
|
|
1677
|
-
* names it. The Runtime connects with the credential for `url` in the vault of `
|
|
2252
|
+
* `POST /v1/tenant/mcp/preview`: what a remote MCP server offers, before an agent
|
|
2253
|
+
* names it. The Runtime connects with the credential for `url` in the vault of Agent `agentId`
|
|
1678
2254
|
* (none without one), lists the tools and closes the connection; it never calls a tool.
|
|
1679
2255
|
*/
|
|
1680
2256
|
export const McpPreviewRequestSchema = z
|
|
@@ -1703,7 +2279,7 @@ export const McpPreviewRequestSchema = z
|
|
|
1703
2279
|
*/
|
|
1704
2280
|
name: modelFacingName("MCP server").optional(),
|
|
1705
2281
|
/** The Environment whose vault's credential for `url` to send. Default: none is sent. */
|
|
1706
|
-
|
|
2282
|
+
agentId: AgentIdSchema.optional(),
|
|
1707
2283
|
})
|
|
1708
2284
|
.strict();
|
|
1709
2285
|
/** One tool a preview found. */
|
|
@@ -1712,7 +2288,7 @@ export const McpPreviewToolSchema = z
|
|
|
1712
2288
|
/** The server's own name for the tool. */
|
|
1713
2289
|
serverToolName: z.string(),
|
|
1714
2290
|
/**
|
|
1715
|
-
* What the model would call it as Nylorun's engine names MCP tools
|
|
2291
|
+
* What the model would call it as Nylorun's engine names MCP tools; absent when the
|
|
1716
2292
|
* engine leaves the tool out (its input schema is not one it can use). A harness of your own
|
|
1717
2293
|
* names tools itself.
|
|
1718
2294
|
*/
|
|
@@ -1725,7 +2301,7 @@ export const McpPreviewToolSchema = z
|
|
|
1725
2301
|
})
|
|
1726
2302
|
.strict();
|
|
1727
2303
|
/**
|
|
1728
|
-
* A preview
|
|
2304
|
+
* A preview. A server that answered `401` is `authRequired`, with its RFC 9728
|
|
1729
2305
|
* protected-resource metadata when it publishes any: it needs a person's sign-in or a key the
|
|
1730
2306
|
* Environment's vault does not hold, so reach it with a key or through a gateway (`via`).
|
|
1731
2307
|
*/
|
|
@@ -1742,7 +2318,7 @@ export const McpPreviewSchema = z
|
|
|
1742
2318
|
/** The server's instructions from `initialize`. */
|
|
1743
2319
|
instructions: z.string().optional(),
|
|
1744
2320
|
tools: z.array(McpPreviewToolSchema),
|
|
1745
|
-
/** Tools Nylorun's engine names otherwise than `server__tool
|
|
2321
|
+
/** Tools Nylorun's engine names otherwise than `server__tool`. */
|
|
1746
2322
|
renamed: z.array(z.object({ serverToolName: z.string(), name: z.string() }).strict()),
|
|
1747
2323
|
authRequired: z
|
|
1748
2324
|
.object({
|
|
@@ -1756,24 +2332,22 @@ export const McpPreviewSchema = z
|
|
|
1756
2332
|
})
|
|
1757
2333
|
.strict();
|
|
1758
2334
|
/**
|
|
1759
|
-
* `POST /v1/tenant/credential-coverage`: which credential each of
|
|
1760
|
-
*
|
|
1761
|
-
* session's tool calls decide it (by URL). It reads no secret and calls no
|
|
2335
|
+
* `POST /v1/tenant/credential-coverage`: which credential each of an Agent's remote MCP servers
|
|
2336
|
+
* and HTTP tools (those of the manifest version it runs) would get in its sessions, decided as the
|
|
2337
|
+
* session's tool calls decide it (by URL) from the Agent's vault. It reads no secret and calls no
|
|
2338
|
+
* server.
|
|
1762
2339
|
*/
|
|
1763
2340
|
export const CredentialCoverageRequestSchema = z
|
|
1764
2341
|
.object({
|
|
1765
2342
|
requestId: RequestIdSchema.optional(),
|
|
1766
|
-
|
|
1767
|
-
agentId: z.string().min(1),
|
|
1768
|
-
/** The Environment the session would name. Default: none (every entry is `missing`). */
|
|
1769
|
-
environmentId: EnvironmentIdSchema.optional(),
|
|
2343
|
+
agentId: AgentIdSchema,
|
|
1770
2344
|
})
|
|
1771
2345
|
.strict();
|
|
1772
2346
|
/** A credential coverage names: where it is, never its value. */
|
|
1773
2347
|
export const CoverageCredentialSchema = z
|
|
1774
2348
|
.object({
|
|
1775
|
-
|
|
1776
|
-
/** The secret's name in the
|
|
2349
|
+
agentId: z.string(),
|
|
2350
|
+
/** The secret's name in the Agent's vault. */
|
|
1777
2351
|
name: z.string(),
|
|
1778
2352
|
/** Where the credential sends the requests instead of the URL (a gateway). */
|
|
1779
2353
|
via: z.string().optional(),
|
|
@@ -1812,7 +2386,6 @@ export const CredentialCoverageEntrySchema = z
|
|
|
1812
2386
|
export const CredentialCoverageSchema = z
|
|
1813
2387
|
.object({
|
|
1814
2388
|
agentId: z.string(),
|
|
1815
|
-
environmentId: z.string().nullable(),
|
|
1816
2389
|
/** True when every entry is `covered`. */
|
|
1817
2390
|
complete: z.boolean(),
|
|
1818
2391
|
/** One per declared MCP server and HTTP tool credential: the agent's, then its agents'. */
|
|
@@ -1823,11 +2396,18 @@ const commandBase = {
|
|
|
1823
2396
|
requestId: RequestIdSchema,
|
|
1824
2397
|
idempotencyKey: IdempotencyKeySchema,
|
|
1825
2398
|
};
|
|
2399
|
+
/**
|
|
2400
|
+
* What a message to a busy session does (protocol 17): `queue` waits for the running turn to
|
|
2401
|
+
* end and starts the next one; `reject` is refused with `409 session_busy`. A protocol 17 client's
|
|
2402
|
+
* default is `queue`, a protocol 16 client's `reject`.
|
|
2403
|
+
*/
|
|
2404
|
+
export const MessageDeliverySchema = z.enum(["queue", "reject"]);
|
|
1826
2405
|
const messageBase = {
|
|
1827
2406
|
...commandBase,
|
|
1828
2407
|
type: z.literal("message"),
|
|
1829
2408
|
/** Optional turn manifest (Loop patch); validated as a variant of the pinned agent. */
|
|
1830
2409
|
manifest: AgentManifestSchema.optional(),
|
|
2410
|
+
delivery: MessageDeliverySchema.optional(),
|
|
1831
2411
|
};
|
|
1832
2412
|
/**
|
|
1833
2413
|
* One part of a user message (protocol 6): text, or a file by artifact id. A file part without
|
|
@@ -1906,11 +2486,11 @@ export const SessionEventBodySchema = SessionCommandSchema;
|
|
|
1906
2486
|
/** The envelope every session event carries (`nylorun.event/2`, Durable Streams §9.5). */
|
|
1907
2487
|
export const EVENT_SCHEMA = "nylorun.event/2";
|
|
1908
2488
|
/**
|
|
1909
|
-
* Who wrote an event
|
|
2489
|
+
* Who wrote an event: the writer says so, not the event's type. `client` is a
|
|
1910
2490
|
* command over the Runtime API (its `principal` says who sent it), `core` is core's own logic
|
|
1911
2491
|
* (settle, sweeps, the flow host, exports, the tools core serves), `harness` is what a harness
|
|
1912
2492
|
* reported (`source.id` is its harness id, `runId` its run), and the gates are themselves.
|
|
1913
|
-
* `loop` and `api` are what events
|
|
2493
|
+
* `loop` and `api` are what older events say.
|
|
1914
2494
|
*/
|
|
1915
2495
|
export const EventSourceKindSchema = z.enum([
|
|
1916
2496
|
"client",
|
|
@@ -1943,10 +2523,11 @@ export const EvidenceClassSchema = z.enum([
|
|
|
1943
2523
|
"claimed",
|
|
1944
2524
|
"asserted",
|
|
1945
2525
|
]);
|
|
1946
|
-
/** A command's sender
|
|
2526
|
+
/** A command's sender: from the request's credential, never from its body. */
|
|
1947
2527
|
export const EventPrincipalSchema = z
|
|
1948
2528
|
.object({
|
|
1949
|
-
|
|
2529
|
+
/** `trigger`: core, for an Agent's trigger; its id is the trigger's. */
|
|
2530
|
+
kind: z.enum(["application", "subject", "flow-host", "core", "trigger"]),
|
|
1950
2531
|
id: z.string(),
|
|
1951
2532
|
})
|
|
1952
2533
|
.strict();
|
|
@@ -1976,7 +2557,7 @@ const eventEnvelope = {
|
|
|
1976
2557
|
schemaVersion: z.number().int().positive(),
|
|
1977
2558
|
source: z.object({ kind: EventSourceKindSchema, id: z.string() }),
|
|
1978
2559
|
evidence: EvidenceClassSchema,
|
|
1979
|
-
/** Who sent a command (`command.*`, a cancel's `turn.cancelled`), from its credential
|
|
2560
|
+
/** Who sent a command (`command.*`, a cancel's `turn.cancelled`), from its credential. */
|
|
1980
2561
|
principal: EventPrincipalSchema.optional(),
|
|
1981
2562
|
trace: z
|
|
1982
2563
|
.object({
|
|
@@ -2003,6 +2584,19 @@ export const AcceptedResponseSchema = z.object({
|
|
|
2003
2584
|
cursor: z.string().nullable(),
|
|
2004
2585
|
requestId: z.string(),
|
|
2005
2586
|
});
|
|
2587
|
+
/**
|
|
2588
|
+
* A message the session queued because a turn runs or waits (protocol 17): it starts the next
|
|
2589
|
+
* turn when this one ends. `position` counts from 1, the first to go.
|
|
2590
|
+
*/
|
|
2591
|
+
export const QueuedResponseSchema = z.object({
|
|
2592
|
+
status: z.literal("queued"),
|
|
2593
|
+
queuedMessageId: z.string(),
|
|
2594
|
+
position: z.number().int().positive(),
|
|
2595
|
+
cursor: z.string().nullable(),
|
|
2596
|
+
requestId: z.string(),
|
|
2597
|
+
});
|
|
2598
|
+
/** What a session command answers: accepted, or, for a message, queued. */
|
|
2599
|
+
export const CommandResponseSchema = z.union([AcceptedResponseSchema, QueuedResponseSchema]);
|
|
2006
2600
|
export const RejectedResponseSchema = z.object({
|
|
2007
2601
|
status: z.literal("rejected"),
|
|
2008
2602
|
code: z.enum(ERROR_CODES),
|
|
@@ -2033,7 +2627,7 @@ const toolIds = {
|
|
|
2033
2627
|
invocationId: z.string().min(1),
|
|
2034
2628
|
};
|
|
2035
2629
|
/**
|
|
2036
|
-
* When a gate served a call
|
|
2630
|
+
* When a gate served a call: its own start and end, as it measured them. Absent when no
|
|
2037
2631
|
* gate measured the call (a fixture model, a sandbox or core-served tool, a call refused before
|
|
2038
2632
|
* it was sent).
|
|
2039
2633
|
*/
|
|
@@ -2041,7 +2635,7 @@ export const GateTimesSchema = z
|
|
|
2041
2635
|
.object({ startedAt: z.string(), endedAt: z.string() })
|
|
2042
2636
|
.passthrough();
|
|
2043
2637
|
/**
|
|
2044
|
-
* What the Model Gate's meter recorded for a model call
|
|
2638
|
+
* What the Model Gate's meter recorded for a model call, from the usage ledger: the
|
|
2045
2639
|
* tokens and cost the Runtime counts, beside the `usage` the harness reported. `cachedTokens`
|
|
2046
2640
|
* and `costUsd` are absent when zero.
|
|
2047
2641
|
*/
|
|
@@ -2055,7 +2649,7 @@ export const MeteredUsageSchema = z
|
|
|
2055
2649
|
})
|
|
2056
2650
|
.passthrough();
|
|
2057
2651
|
/**
|
|
2058
|
-
* The timing of a model call's outcome
|
|
2652
|
+
* The timing of a model call's outcome, on `message.assistant`, `model.failed` and
|
|
2059
2653
|
* `context.compacted`. `durationMs` is the journal's window, from the intent to the outcome;
|
|
2060
2654
|
* `gate`, `firstTokenMs` and `meteredUsage` are the meter's, absent when no gate metered the
|
|
2061
2655
|
* call.
|
|
@@ -2097,7 +2691,7 @@ export const AssistantMessagePayloadSchema = z
|
|
|
2097
2691
|
...eventAgent,
|
|
2098
2692
|
})
|
|
2099
2693
|
.passthrough();
|
|
2100
|
-
/** True when a `message.assistant` said nothing: no text and no tool calls
|
|
2694
|
+
/** True when a `message.assistant` said nothing: no text and no tool calls. */
|
|
2101
2695
|
export function isEmptyAssistantMessage(payload) {
|
|
2102
2696
|
return ((typeof payload.text !== "string" || payload.text === "") &&
|
|
2103
2697
|
(payload.toolCalls?.length ?? 0) === 0);
|
|
@@ -2132,16 +2726,17 @@ export const ContextCompactedPayloadSchema = z
|
|
|
2132
2726
|
...eventAgent,
|
|
2133
2727
|
})
|
|
2134
2728
|
.passthrough();
|
|
2135
|
-
/** How a tool call ended
|
|
2729
|
+
/** How a tool call ended: the tool answered, the Runtime ended it, or a cancel did. */
|
|
2136
2730
|
export const TOOL_CALL_STATUSES = ["completed", "failed", "cancelled"];
|
|
2137
2731
|
/**
|
|
2138
|
-
* Where a tool call ran
|
|
2139
|
-
* tool's URL, the session's sandbox,
|
|
2140
|
-
* in its own process, such as our engine's skill, artifact and `tool_search` tools)
|
|
2732
|
+
* Where a tool call ran, its effect's target kind (protocol 15): an MCP server, an HTTP
|
|
2733
|
+
* tool's URL, the session's sandbox, the harness that runs the turn (`harness`: a tool it runs
|
|
2734
|
+
* in its own process, such as our engine's skill, artifact and `tool_search` tools), or the
|
|
2735
|
+
* Runtime itself (`runtime`: `schedule_wake`).
|
|
2141
2736
|
*/
|
|
2142
|
-
export const TOOL_CALL_KINDS = ["mcp", "http", "sandbox", "harness"];
|
|
2737
|
+
export const TOOL_CALL_KINDS = ["mcp", "http", "sandbox", "harness", "runtime"];
|
|
2143
2738
|
/**
|
|
2144
|
-
* What the Tenant's tool policy did with a tool call
|
|
2739
|
+
* What the Tenant's tool policy did with a tool call, when it did more than allow
|
|
2145
2740
|
* it: `deny` refused it unsent; `ask` held it for a person, who approved it (`approvedBy`, when
|
|
2146
2741
|
* known) or denied it.
|
|
2147
2742
|
*/
|
|
@@ -2153,7 +2748,7 @@ export const ToolPolicyFactSchema = z
|
|
|
2153
2748
|
})
|
|
2154
2749
|
.passthrough();
|
|
2155
2750
|
/**
|
|
2156
|
-
* `tool.completed`: how one tool call ended, written once per call
|
|
2751
|
+
* `tool.completed`: how one tool call ended, written once per call. `status`
|
|
2157
2752
|
* `completed`: the tool answered, with its output or the tool error it reported (`error`).
|
|
2158
2753
|
* `failed`: the Runtime ended the call (`tool.disabled`, `tool.unavailable`, `tool.denied`, or
|
|
2159
2754
|
* `tool.interrupted` for a call a crash interrupted, which may have run). `cancelled`: the turn
|
|
@@ -2163,7 +2758,7 @@ export const ToolPolicyFactSchema = z
|
|
|
2163
2758
|
export const ToolCompletedPayloadSchema = z
|
|
2164
2759
|
.object({
|
|
2165
2760
|
...toolIds,
|
|
2166
|
-
/** The tool call's effect id
|
|
2761
|
+
/** The tool call's effect id. */
|
|
2167
2762
|
effectId: z.string().min(1).optional(),
|
|
2168
2763
|
/** The name the model called the tool by, as its harness named it: for display. */
|
|
2169
2764
|
toolName: z.string().min(1),
|
|
@@ -2188,7 +2783,7 @@ export const ToolCompletedPayloadSchema = z
|
|
|
2188
2783
|
/** From the first send to the outcome; absent when the call never ran. */
|
|
2189
2784
|
durationMs: z.number().int().nonnegative().optional(),
|
|
2190
2785
|
/**
|
|
2191
|
-
* The Tool Gate's own start and end of the call's last send
|
|
2786
|
+
* The Tool Gate's own start and end of the call's last send: an MCP or HTTP tool
|
|
2192
2787
|
* through the gateway. Absent for a sandbox or core-served tool.
|
|
2193
2788
|
*/
|
|
2194
2789
|
gate: GateTimesSchema.optional(),
|
|
@@ -2199,18 +2794,18 @@ export const ToolCompletedPayloadSchema = z
|
|
|
2199
2794
|
code: z.string(),
|
|
2200
2795
|
message: z.string(),
|
|
2201
2796
|
/**
|
|
2202
|
-
* With `credential_rejected
|
|
2797
|
+
* With `credential_rejected`: the MCP server, or the HTTP tool's `credential`,
|
|
2203
2798
|
* whose server answered `401`.
|
|
2204
2799
|
*/
|
|
2205
2800
|
server: z.string().optional(),
|
|
2206
|
-
/** An MCP tool error
|
|
2801
|
+
/** An MCP tool error: true when calling again may work, as for `mcp.unreachable`. */
|
|
2207
2802
|
retryable: z.boolean().optional(),
|
|
2208
2803
|
})
|
|
2209
2804
|
.passthrough()
|
|
2210
2805
|
.optional(),
|
|
2211
2806
|
/**
|
|
2212
|
-
* How many credential values the Runtime replaced with `[redacted]` in `output` or `error
|
|
2213
|
-
*
|
|
2807
|
+
* How many credential values the Runtime replaced with `[redacted]` in `output` or `error`:
|
|
2808
|
+
* the server echoed what it was sent. Absent when none.
|
|
2214
2809
|
*/
|
|
2215
2810
|
redacted: z.number().int().positive().optional(),
|
|
2216
2811
|
...eventAgent,
|
|
@@ -2220,7 +2815,7 @@ export const EffectUncertainPayloadSchema = z
|
|
|
2220
2815
|
.object({ effectId: z.string().min(1), message: z.string().optional() })
|
|
2221
2816
|
.passthrough();
|
|
2222
2817
|
/**
|
|
2223
|
-
* How a turn that ended went
|
|
2818
|
+
* How a turn that ended went, on `turn.completed`, `turn.failed` and `turn.cancelled`:
|
|
2224
2819
|
* `durationMs` from the turn's start to its end, waits for a person included, so the turn's span
|
|
2225
2820
|
* holds every crossing in it; `pausedMs`, how much of that it waited paused; `totals` from the
|
|
2226
2821
|
* usage ledger (`steps`: the model calls the gate metered). Absent on a turn
|
|
@@ -2229,8 +2824,10 @@ export const EffectUncertainPayloadSchema = z
|
|
|
2229
2824
|
const turnEndFacts = {
|
|
2230
2825
|
durationMs: z.number().int().nonnegative().optional(),
|
|
2231
2826
|
pausedMs: z.number().int().nonnegative().optional(),
|
|
2232
|
-
/** The session's
|
|
2827
|
+
/** The session's Agent. */
|
|
2233
2828
|
agentId: z.string().optional(),
|
|
2829
|
+
/** The agent manifest version the session runs (protocol 16): the agent the turn's span names. */
|
|
2830
|
+
manifest: z.object({ name: z.string(), version: z.number().int() }).passthrough().optional(),
|
|
2234
2831
|
totals: z
|
|
2235
2832
|
.object({
|
|
2236
2833
|
steps: z.number().int().nonnegative(),
|
|
@@ -2272,6 +2869,26 @@ export const TurnFailedPayloadSchema = z
|
|
|
2272
2869
|
export const TurnCancelledPayloadSchema = z
|
|
2273
2870
|
.object({ reason: z.string().optional(), ...turnEndFacts })
|
|
2274
2871
|
.passthrough();
|
|
2872
|
+
/**
|
|
2873
|
+
* `message.queued` (protocol 17): a message arrived while the session's turn ran or waited, and
|
|
2874
|
+
* waits in its queue. `position` counts from 1; the message's `command.message` is written when
|
|
2875
|
+
* a turn takes it.
|
|
2876
|
+
*/
|
|
2877
|
+
export const MessageQueuedPayloadSchema = z
|
|
2878
|
+
.object({ queuedMessageId: z.string(), position: z.number().int().positive(), requestId: z.string() })
|
|
2879
|
+
.passthrough();
|
|
2880
|
+
/**
|
|
2881
|
+
* `wake.booked`: the session's agent booked its next turn with `schedule_wake`,
|
|
2882
|
+
* at `at`, replacing any booking before. `wake.cancelled`: it cancelled its booking.
|
|
2883
|
+
*/
|
|
2884
|
+
export const WakeBookedPayloadSchema = z
|
|
2885
|
+
.object({ at: z.string(), note: z.string(), effectId: z.string(), replaced: z.boolean() })
|
|
2886
|
+
.passthrough();
|
|
2887
|
+
export const WakeCancelledPayloadSchema = z.object({ effectId: z.string() }).passthrough();
|
|
2888
|
+
/** `queue.taken` (protocol 17): the turn that started with the queued messages, in order. */
|
|
2889
|
+
export const QueueTakenPayloadSchema = z
|
|
2890
|
+
.object({ turnId: z.string(), queuedMessageIds: z.array(z.string()).min(1) })
|
|
2891
|
+
.passthrough();
|
|
2275
2892
|
/** Lifecycle of an agent used as a tool. `agent.delegationId` is the parent call's invocation. */
|
|
2276
2893
|
export const DelegationPayloadSchema = z
|
|
2277
2894
|
.object({
|
|
@@ -2304,8 +2921,19 @@ export const CommandMessagePayloadSchema = z
|
|
|
2304
2921
|
parts: z.array(MessagePartSchema).optional(),
|
|
2305
2922
|
/** The turn manifest the message carried, if any. */
|
|
2306
2923
|
manifest: z.unknown().optional(),
|
|
2924
|
+
delivery: MessageDeliverySchema.optional(),
|
|
2925
|
+
/** Set when the message waited in the session's queue (protocol 17): its id there. */
|
|
2926
|
+
queuedMessageId: z.string().optional(),
|
|
2927
|
+
/**
|
|
2928
|
+
* What sent it, when not a client: a trigger's run (`trigger`, with the trigger
|
|
2929
|
+
* and run ids), or the session's own booked wake (`self`).
|
|
2930
|
+
*/
|
|
2931
|
+
cause: z
|
|
2932
|
+
.object({ kind: z.enum(["trigger", "self"]), triggerId: z.string(), runId: z.string() })
|
|
2933
|
+
.strict()
|
|
2934
|
+
.optional(),
|
|
2307
2935
|
/**
|
|
2308
|
-
* The W3C trace context the message was sent with
|
|
2936
|
+
* The W3C trace context the message was sent with: the turn's trace is the caller's,
|
|
2309
2937
|
* and its root span the child of the caller's span.
|
|
2310
2938
|
*/
|
|
2311
2939
|
trace: z
|
|
@@ -2347,11 +2975,11 @@ export const EnvironmentStatePayloadSchema = z
|
|
|
2347
2975
|
})
|
|
2348
2976
|
.passthrough();
|
|
2349
2977
|
/**
|
|
2350
|
-
* `
|
|
2351
|
-
*
|
|
2978
|
+
* `agent.attached`: the session was opened on its Agent (protocol 16; `environment.attached`
|
|
2979
|
+
* before). The Agent's own stream records the same attachment.
|
|
2352
2980
|
*/
|
|
2353
|
-
export const
|
|
2354
|
-
.object({
|
|
2981
|
+
export const AgentAttachedPayloadSchema = z
|
|
2982
|
+
.object({ agentId: z.string() })
|
|
2355
2983
|
.passthrough();
|
|
2356
2984
|
/** `environment.exec`: one sandbox tool call finished. */
|
|
2357
2985
|
export const EnvironmentExecPayloadSchema = z
|
|
@@ -2374,7 +3002,7 @@ export const NodeStartedPayloadSchema = z
|
|
|
2374
3002
|
.passthrough();
|
|
2375
3003
|
/**
|
|
2376
3004
|
* `node.completed`: a flow's HTTP stage or HTTP verifier ended, or a tool stage the Runtime
|
|
2377
|
-
* refused to run
|
|
3005
|
+
* refused to run, named as its `node.started` names it. `status` reads as
|
|
2378
3006
|
* `tool.completed`'s: `completed` when the stage's server answered (an error answer included),
|
|
2379
3007
|
* `failed` when the Runtime ended it, `cancelled` when a cancel did. `gate` is the Tool Gate's
|
|
2380
3008
|
* own start and end of its last send.
|
|
@@ -2422,7 +3050,7 @@ export const LoopVerifiedPayloadSchema = z
|
|
|
2422
3050
|
})
|
|
2423
3051
|
.passthrough();
|
|
2424
3052
|
/**
|
|
2425
|
-
* `transcript.updated` (internal
|
|
3053
|
+
* `transcript.updated` (internal): the own loop's model-facing transcript after a
|
|
2426
3054
|
* settled segment, as an edit of the previous one: keep its first `keep` entries, then append
|
|
2427
3055
|
* `entries`; the result has `length` entries. `keep` is 0 for a snapshot (after compaction, or
|
|
2428
3056
|
* for a session written before transcripts were recorded). Large edits are split into
|
|
@@ -2444,7 +3072,7 @@ export const TranscriptUpdatedPayloadSchema = z
|
|
|
2444
3072
|
*/
|
|
2445
3073
|
export const ArtifactSourceSchema = z.enum(["upload", "engine", "export", "snapshot"]);
|
|
2446
3074
|
/**
|
|
2447
|
-
* What an artifact holds: one file, or a folder
|
|
3075
|
+
* What an artifact holds: one file, or a folder, whose versions are manifests of paths to
|
|
2448
3076
|
* content-addressed files.
|
|
2449
3077
|
*/
|
|
2450
3078
|
export const ArtifactKindSchema = z.enum(["file", "folder"]);
|
|
@@ -2487,7 +3115,7 @@ export const ArtifactExportSkipReasonSchema = z.enum([
|
|
|
2487
3115
|
"file_too_large",
|
|
2488
3116
|
"too_large",
|
|
2489
3117
|
"tenant_total",
|
|
2490
|
-
/** Past the session's
|
|
3118
|
+
/** Past the session's Agent's own total (its manifest's `runtime.limits.artifacts.totalBytes`). */
|
|
2491
3119
|
"environment_total",
|
|
2492
3120
|
]);
|
|
2493
3121
|
/**
|
|
@@ -2527,10 +3155,10 @@ export const McpServerOutcomeSchema = z
|
|
|
2527
3155
|
message: z.string(),
|
|
2528
3156
|
/** The tools it added to the session that its `tools` settings leave enabled; 0 unless connected. */
|
|
2529
3157
|
tools: z.number().int().nonnegative(),
|
|
2530
|
-
/** Listed tools the server's `tools` settings disable
|
|
3158
|
+
/** Listed tools the server's `tools` settings disable; absent when none. */
|
|
2531
3159
|
disabled: z.number().int().positive().optional(),
|
|
2532
3160
|
/**
|
|
2533
|
-
* Keys of the server's `tools` settings that name no tool it listed
|
|
3161
|
+
* Keys of the server's `tools` settings that name no tool it listed: a diagnostic,
|
|
2534
3162
|
* since servers change their lists.
|
|
2535
3163
|
*/
|
|
2536
3164
|
unknownTools: z.array(z.string()).optional(),
|
|
@@ -2564,6 +3192,11 @@ export const EVENT_CATALOG = {
|
|
|
2564
3192
|
"turn.paused": { payload: TurnPausedPayloadSchema, source: "loop", version: 1 },
|
|
2565
3193
|
"turn.failed": { payload: TurnFailedPayloadSchema, source: "loop", version: 1 },
|
|
2566
3194
|
"turn.cancelled": { payload: TurnCancelledPayloadSchema, source: "api", version: 1 },
|
|
3195
|
+
"message.queued": { payload: MessageQueuedPayloadSchema, source: "api", version: 1 },
|
|
3196
|
+
"queue.taken": { payload: QueueTakenPayloadSchema, source: "api", version: 1 },
|
|
3197
|
+
"wake.booked": { payload: WakeBookedPayloadSchema, source: "api", version: 1 },
|
|
3198
|
+
"wake.cancelled": { payload: WakeCancelledPayloadSchema, source: "api", version: 1 },
|
|
3199
|
+
"memory.updated": { payload: MemoryUpdatedPayloadSchema, source: "api", version: 1 },
|
|
2567
3200
|
"message.assistant": { payload: AssistantMessagePayloadSchema, source: "loop", version: 1 },
|
|
2568
3201
|
"model.failed": { payload: ModelFailedPayloadSchema, source: "loop", version: 1 },
|
|
2569
3202
|
"context.compacted": { payload: ContextCompactedPayloadSchema, source: "loop", version: 1 },
|
|
@@ -2574,7 +3207,7 @@ export const EVENT_CATALOG = {
|
|
|
2574
3207
|
"mcp.discovered": { payload: McpDiscoveredPayloadSchema, source: "loop", version: 1 },
|
|
2575
3208
|
"environment.state": { payload: EnvironmentStatePayloadSchema, source: "loop", version: 1 },
|
|
2576
3209
|
"environment.exec": { payload: EnvironmentExecPayloadSchema, source: "loop", version: 1 },
|
|
2577
|
-
"
|
|
3210
|
+
"agent.attached": { payload: AgentAttachedPayloadSchema, source: "api", version: 1 },
|
|
2578
3211
|
"node.started": { payload: NodeStartedPayloadSchema, source: "loop", version: 1 },
|
|
2579
3212
|
"node.completed": { payload: NodeCompletedPayloadSchema, source: "loop", version: 1 },
|
|
2580
3213
|
"node.agent": { payload: NodeAgentPayloadSchema, source: "loop", version: 1 },
|
|
@@ -2741,7 +3374,7 @@ export const StreamRelayStatusSchema = z
|
|
|
2741
3374
|
})
|
|
2742
3375
|
.strict();
|
|
2743
3376
|
/**
|
|
2744
|
-
* The Tenant's harnesses
|
|
3377
|
+
* The Tenant's harnesses: `in-process` runs one in core's process; `remote` waits for
|
|
2745
3378
|
* harnesses on the Harness API listener. `workspace` says one that serves the Tenant's
|
|
2746
3379
|
* workspaces is connected.
|
|
2747
3380
|
*/
|
|
@@ -2834,7 +3467,7 @@ export const TenantStatusSchema = z
|
|
|
2834
3467
|
})
|
|
2835
3468
|
.strict(),
|
|
2836
3469
|
model: HostModelViewSchema,
|
|
2837
|
-
/** The
|
|
3470
|
+
/** The Tenant's Agents, by id. */
|
|
2838
3471
|
agents: z.array(z.object({ agentId: z.string() }).strict()),
|
|
2839
3472
|
counts: z
|
|
2840
3473
|
.object({
|
|
@@ -2849,7 +3482,7 @@ export const TenantStatusSchema = z
|
|
|
2849
3482
|
retained: z.number().int().nonnegative(),
|
|
2850
3483
|
})
|
|
2851
3484
|
.strict(),
|
|
2852
|
-
/** The Tenant's harnesses
|
|
3485
|
+
/** The Tenant's harnesses. */
|
|
2853
3486
|
harness: HarnessStatusSchema.optional(),
|
|
2854
3487
|
/**
|
|
2855
3488
|
* Durable Session Execution invocations of this Tenant that need an operator: paused
|
|
@@ -2930,22 +3563,22 @@ export const SeedTenantConfigResponseSchema = z
|
|
|
2930
3563
|
export const ResetTenantRequestSchema = z
|
|
2931
3564
|
.object({
|
|
2932
3565
|
requestId: RequestIdSchema,
|
|
2933
|
-
scope: z.enum(["sessions", "
|
|
3566
|
+
scope: z.enum(["sessions", "agents", "all"]),
|
|
2934
3567
|
activeWork: z.enum(["drain", "cancel"]),
|
|
2935
3568
|
})
|
|
2936
3569
|
.strict();
|
|
2937
3570
|
/**
|
|
2938
3571
|
* Acting for a subject (Host feature `subject-headers`): what an application principal may
|
|
2939
3572
|
* narrow a request to. `sessions:own` reaches only the subject's own sessions; the others reach
|
|
2940
|
-
* Tenant-wide resources. `
|
|
2941
|
-
*
|
|
2942
|
-
* grants name.
|
|
3573
|
+
* Tenant-wide resources. `agents:write` creates, changes and deletes Agents and writes their
|
|
3574
|
+
* secrets (protocol 16; `environments:write` before); a token caller's reach only the ids its
|
|
3575
|
+
* Agent grants name. `agent-manifests:write` saves and deletes agent manifests.
|
|
2943
3576
|
*/
|
|
2944
3577
|
export const SUBJECT_SCOPES = [
|
|
2945
3578
|
"agents:read",
|
|
2946
3579
|
"agents:write",
|
|
2947
3580
|
"sessions:own",
|
|
2948
|
-
"
|
|
3581
|
+
"agent-manifests:write",
|
|
2949
3582
|
];
|
|
2950
3583
|
/**
|
|
2951
3584
|
* Retired scopes: `Nylorun-Scopes` may still name them (older clients do), and they grant
|
|
@@ -2955,14 +3588,14 @@ export const SUBJECT_SCOPES = [
|
|
|
2955
3588
|
const RETIRED_SUBJECT_SCOPES = ["vaults:own", "tenant:settings"];
|
|
2956
3589
|
/**
|
|
2957
3590
|
* 1–200 visible ASCII characters; spaces only inside.
|
|
2958
|
-
* An identifier's grammar is the protocol's
|
|
3591
|
+
* An identifier's grammar is the protocol's: it crosses the Runtime API, tokens and grants
|
|
2959
3592
|
* and means the same in every installation, so its length is a constant of protocol 15, not a
|
|
2960
3593
|
* setting.
|
|
2961
3594
|
*/
|
|
2962
3595
|
const SUBJECT_PATTERN = /^[\x21-\x7e](?:[\x20-\x7e]{0,198}[\x21-\x7e])?$/;
|
|
2963
3596
|
/**
|
|
2964
3597
|
* The owner of a session opened for no person: an MCP server's or HTTP tool's identity header
|
|
2965
|
-
*
|
|
3598
|
+
* names nobody for it. A reserved subject.
|
|
2966
3599
|
*/
|
|
2967
3600
|
export const INSTALLATION_OWNER = "installation";
|
|
2968
3601
|
/** Owner ids the Runtime uses itself: `host` (the model vault's) and `installation`. */
|
|
@@ -2992,10 +3625,10 @@ export function parseSubjectHeaders(subject, scopes) {
|
|
|
2992
3625
|
message: "Nylorun-Scopes is required with Nylorun-Subject",
|
|
2993
3626
|
};
|
|
2994
3627
|
const names = named.filter((name) => !RETIRED_SUBJECT_SCOPES.includes(name));
|
|
2995
|
-
if (names.includes("sandboxes:write"))
|
|
3628
|
+
if (names.includes("sandboxes:write") || names.includes("environments:write"))
|
|
2996
3629
|
return {
|
|
2997
3630
|
ok: false,
|
|
2998
|
-
message: "
|
|
3631
|
+
message: "environments:write was renamed agents:write in protocol 16 (sandboxes:write before protocol 11)",
|
|
2999
3632
|
};
|
|
3000
3633
|
const unknown = names.filter((name) => !SUBJECT_SCOPES.includes(name));
|
|
3001
3634
|
if (unknown.length > 0)
|
|
@@ -3008,12 +3641,13 @@ export function parseSubjectHeaders(subject, scopes) {
|
|
|
3008
3641
|
}
|
|
3009
3642
|
// --- token callers (Host feature `trusted-issuers`) ------------------------------------------
|
|
3010
3643
|
/**
|
|
3011
|
-
* Scopes a token caller (a trusted issuer's token) may carry: never `
|
|
3644
|
+
* Scopes a token caller (a trusted issuer's token) may carry: never `agent-manifests:write`.
|
|
3645
|
+
* `agents:write` reaches only the Agents its grants name.
|
|
3012
3646
|
*/
|
|
3013
3647
|
export const TOKEN_SCOPES = [
|
|
3014
3648
|
"agents:read",
|
|
3015
3649
|
"sessions:own",
|
|
3016
|
-
"
|
|
3650
|
+
"agents:write",
|
|
3017
3651
|
];
|
|
3018
3652
|
/**
|
|
3019
3653
|
* The `iss` of every token a Tenant's Runtime signs itself: capability links, run, host and
|
|
@@ -3022,6 +3656,7 @@ export const TOKEN_SCOPES = [
|
|
|
3022
3656
|
export function tenantTokenIssuer(tenantId) {
|
|
3023
3657
|
return `urn:nylorun:tenant:${tenantId}`;
|
|
3024
3658
|
}
|
|
3659
|
+
/** The Agents a caller reaches: `*` for every one, or Agent grants (ids and `p/*` prefixes). */
|
|
3025
3660
|
const AgentAllowlistSchema = z.union([
|
|
3026
3661
|
z.literal("*"),
|
|
3027
3662
|
z.array(z.string().min(1)),
|
|
@@ -3078,9 +3713,8 @@ export const CALLER_SCOPES = [...SUBJECT_SCOPES, "studio"];
|
|
|
3078
3713
|
* `issuer:<name>` (a token from the identity file's issuer `name`).
|
|
3079
3714
|
* - `subject` is the person the request acts for; absent for an application key alone.
|
|
3080
3715
|
* - `scopes`: what the caller holds. An application key alone holds every subject scope.
|
|
3081
|
-
* - `agents`: the
|
|
3082
|
-
*
|
|
3083
|
-
* an application key, alone or acting for a subject, which no grant limits.
|
|
3716
|
+
* - `agents`: the Agents it may reach: `*` for all, else a token caller's Agent grants (ids
|
|
3717
|
+
* and `p/*` prefixes; empty reaches none).
|
|
3084
3718
|
*/
|
|
3085
3719
|
export const MeResponseSchema = z
|
|
3086
3720
|
.object({
|
|
@@ -3090,12 +3724,6 @@ export const MeResponseSchema = z
|
|
|
3090
3724
|
.meta({ description: "The person the request acts for; absent for an application key alone" }),
|
|
3091
3725
|
scopes: z.array(z.enum(CALLER_SCOPES)),
|
|
3092
3726
|
agents: AgentAllowlistSchema,
|
|
3093
|
-
environments: z
|
|
3094
|
-
.array(z.string())
|
|
3095
|
-
.optional()
|
|
3096
|
-
.meta({
|
|
3097
|
-
description: "A token caller's Environment grants (empty reaches none); absent when no grant limits the caller",
|
|
3098
|
-
}),
|
|
3099
3727
|
via: z.string().meta({
|
|
3100
3728
|
description: "How the caller authenticated: `application:<principalId>`, `management:<principalId>`, `subject` or `issuer:<name>`",
|
|
3101
3729
|
}),
|
|
@@ -3118,37 +3746,9 @@ export function isSerializedOrigin(value) {
|
|
|
3118
3746
|
}
|
|
3119
3747
|
// Successful answers of the Runtime and Management APIs that had no schema of their own. With the
|
|
3120
3748
|
// request schemas above they describe every body the Runtime sends (its OpenAPI document).
|
|
3121
|
-
/** `GET /v1/agents
|
|
3122
|
-
export const AgentDefinitionViewSchema = z
|
|
3123
|
-
.object({
|
|
3124
|
-
agentId: z.string(),
|
|
3125
|
-
manifest: z.record(z.string(), z.unknown()),
|
|
3126
|
-
manifestHash: z.string(),
|
|
3127
|
-
implementationVersion: z.string(),
|
|
3128
|
-
})
|
|
3129
|
-
.strict();
|
|
3749
|
+
/** `GET /v1/agents`: the Agents the caller reaches. */
|
|
3130
3750
|
export const ListAgentsResponseSchema = z
|
|
3131
|
-
.object({ agents: z.array(
|
|
3132
|
-
.strict();
|
|
3133
|
-
/** `GET /v1/agents` with a token caller's credential: the allowed agents' names only. */
|
|
3134
|
-
export const PublicAgentSchema = z
|
|
3135
|
-
.object({
|
|
3136
|
-
agentId: z.string(),
|
|
3137
|
-
name: z.string().optional(),
|
|
3138
|
-
description: z.string().optional(),
|
|
3139
|
-
})
|
|
3140
|
-
.strict();
|
|
3141
|
-
export const ListPublicAgentsResponseSchema = z
|
|
3142
|
-
.object({ agents: z.array(PublicAgentSchema) })
|
|
3143
|
-
.strict();
|
|
3144
|
-
export const PutAgentResponseSchema = z
|
|
3145
|
-
.object({
|
|
3146
|
-
agentId: z.string(),
|
|
3147
|
-
manifestHash: z.string(),
|
|
3148
|
-
implementationVersion: z.string(),
|
|
3149
|
-
/** True for `?dryRun=true` (protocol 14): every check ran, and nothing was saved. */
|
|
3150
|
-
dryRun: z.boolean().optional(),
|
|
3151
|
-
})
|
|
3751
|
+
.object({ agents: z.array(AgentViewSchema) })
|
|
3152
3752
|
.strict();
|
|
3153
3753
|
export const SESSION_STATUSES = [
|
|
3154
3754
|
"idle",
|
|
@@ -3164,6 +3764,7 @@ export const SESSION_STATUSES = [
|
|
|
3164
3764
|
export const SessionSummarySchema = z
|
|
3165
3765
|
.object({
|
|
3166
3766
|
id: z.string(),
|
|
3767
|
+
/** The Agent the session runs on. */
|
|
3167
3768
|
agentId: z.string(),
|
|
3168
3769
|
ownerUserId: z.string(),
|
|
3169
3770
|
status: z.enum(SESSION_STATUSES),
|
|
@@ -3177,33 +3778,28 @@ export const ListSessionsResponseSchema = z
|
|
|
3177
3778
|
export const SessionViewSchema = z
|
|
3178
3779
|
.object({
|
|
3179
3780
|
id: z.string(),
|
|
3781
|
+
/** The Agent the session runs on (protocol 16). */
|
|
3180
3782
|
agentId: z.string(),
|
|
3181
3783
|
ownerUserId: z.string(),
|
|
3182
|
-
manifestHash: z.string(),
|
|
3183
3784
|
/**
|
|
3184
|
-
* The
|
|
3185
|
-
*
|
|
3186
|
-
* session opened before R2b C11.
|
|
3785
|
+
* The agent manifest version the session pinned when it opened: the one its Agent runs.
|
|
3786
|
+
* Absent for a session closed by protocol 16, opened from a definition.
|
|
3187
3787
|
*/
|
|
3188
|
-
|
|
3189
|
-
|
|
3788
|
+
manifest: z.object({ name: z.string(), version: z.number().int().positive() }).strict().nullable(),
|
|
3789
|
+
/** The hash of the loop manifest the session pinned. */
|
|
3790
|
+
manifestHash: z.string(),
|
|
3190
3791
|
status: z.enum(SESSION_STATUSES),
|
|
3191
3792
|
activeTurnId: z.string().nullable(),
|
|
3793
|
+
/** Messages waiting in the session's queue for the next turn (protocol 17). */
|
|
3794
|
+
queuedMessages: z.number().int().nonnegative(),
|
|
3192
3795
|
/**
|
|
3193
|
-
* The
|
|
3194
|
-
*
|
|
3195
|
-
*/
|
|
3196
|
-
environment: z
|
|
3197
|
-
.object({ id: z.string(), version: z.number().int().positive() })
|
|
3198
|
-
.strict()
|
|
3199
|
-
.nullable(),
|
|
3200
|
-
/**
|
|
3201
|
-
* The harness that runs the session's turns, pinned when it opened (track R4): its
|
|
3202
|
-
* Environment's harness, else `nylorun`.
|
|
3796
|
+
* The harness that runs the session's turns, pinned when it opened: its
|
|
3797
|
+
* manifest's `harness.id`, else `nylorun`.
|
|
3203
3798
|
*/
|
|
3204
3799
|
harness: z.string(),
|
|
3205
3800
|
/**
|
|
3206
|
-
* Why the session takes no new turn, when it is closed: `
|
|
3801
|
+
* Why the session takes no new turn, when it is closed: `protocol_16` for a session opened
|
|
3802
|
+
* before protocol 16 (from a definition), `protocol_13` for a session opened
|
|
3207
3803
|
* before protocol 13, `protocol_11` for one opened before protocol 11 (a new turn is
|
|
3208
3804
|
* `409 session_closed`; its history stays readable).
|
|
3209
3805
|
*/
|
|
@@ -3310,7 +3906,7 @@ export const EffectiveSandboxConfigSchema = z
|
|
|
3310
3906
|
.strict(),
|
|
3311
3907
|
/** Pods (Host feature `sandbox-pods`): the pod's stop grace. */
|
|
3312
3908
|
lifecycle: z.object({ stopGrace: z.string() }).strict().optional(),
|
|
3313
|
-
/** Where each harness may run
|
|
3909
|
+
/** Where each harness may run. */
|
|
3314
3910
|
placement: z
|
|
3315
3911
|
.record(z.string(), z.object({ hosts: z.array(z.enum(PLACEMENT_HOSTS)) }).strict())
|
|
3316
3912
|
.optional(),
|
|
@@ -3352,13 +3948,16 @@ export const TenantSandboxViewSchema = z
|
|
|
3352
3948
|
.optional(),
|
|
3353
3949
|
})
|
|
3354
3950
|
.strict();
|
|
3355
|
-
/**
|
|
3356
|
-
|
|
3951
|
+
/**
|
|
3952
|
+
* What a usage total or a budget covers: the whole Tenant, the Agents made from one agent manifest
|
|
3953
|
+
* (`manifest`, by its name; scope `agent` keyed a definition id before protocol 16), or one turn.
|
|
3954
|
+
*/
|
|
3955
|
+
export const ModelUsageScopeSchema = z.enum(["tenant", "manifest", "turn"]);
|
|
3357
3956
|
/** `GET /v1/tenant/usage`: which rows of the model usage ledger to total. */
|
|
3358
3957
|
export const ModelUsageQuerySchema = z
|
|
3359
3958
|
.object({
|
|
3360
3959
|
scope: ModelUsageScopeSchema.default("tenant"),
|
|
3361
|
-
/** The
|
|
3960
|
+
/** The manifest's name or the turn id; required for those scopes. */
|
|
3362
3961
|
id: z.string().min(1).optional(),
|
|
3363
3962
|
/** The current UTC day or month, or every row. */
|
|
3364
3963
|
period: z.enum(["day", "month", "total"]).default("total"),
|
|
@@ -3385,11 +3984,14 @@ export const ModelUsageTotalsSchema = z
|
|
|
3385
3984
|
*/
|
|
3386
3985
|
export const ModelBudgetSchema = z
|
|
3387
3986
|
.object({
|
|
3388
|
-
/**
|
|
3987
|
+
/**
|
|
3988
|
+
* `turn` caps every turn; `manifest` the sessions of every Agent made from one agent
|
|
3989
|
+
* manifest; `tenant` all of them.
|
|
3990
|
+
*/
|
|
3389
3991
|
scope: ModelUsageScopeSchema,
|
|
3390
|
-
/** The agent's
|
|
3992
|
+
/** The agent manifest's name; `manifest` only. */
|
|
3391
3993
|
id: z.string().min(1).optional(),
|
|
3392
|
-
/** The UTC period spend counts over; `
|
|
3994
|
+
/** The UTC period spend counts over; `manifest` and `tenant` only. */
|
|
3393
3995
|
period: z.enum(["day", "month"]).optional(),
|
|
3394
3996
|
/** pi-ai's catalog price; custom endpoints count as $0, so cap them in tokens. */
|
|
3395
3997
|
limitUsd: z.number().positive().optional(),
|
|
@@ -3399,10 +4001,10 @@ export const ModelBudgetSchema = z
|
|
|
3399
4001
|
.superRefine((budget, ctx) => {
|
|
3400
4002
|
if (budget.limitUsd === undefined && budget.limitTokens === undefined)
|
|
3401
4003
|
ctx.addIssue({ code: "custom", message: "A budget needs limitUsd, limitTokens or both" });
|
|
3402
|
-
if ((budget.scope === "
|
|
3403
|
-
ctx.addIssue({ code: "custom", message: "
|
|
4004
|
+
if ((budget.scope === "manifest") !== (budget.id !== undefined))
|
|
4005
|
+
ctx.addIssue({ code: "custom", message: "A manifest budget names the agent manifest in id; other scopes take no id" });
|
|
3404
4006
|
if ((budget.scope === "turn") === (budget.period !== undefined))
|
|
3405
|
-
ctx.addIssue({ code: "custom", message: "A turn budget takes no period;
|
|
4007
|
+
ctx.addIssue({ code: "custom", message: "A turn budget takes no period; manifest and Tenant budgets need one" });
|
|
3406
4008
|
});
|
|
3407
4009
|
/** `PUT /v1/tenant/budgets`: replaces every budget. An empty list removes them all. */
|
|
3408
4010
|
export const PutModelBudgetsRequestSchema = z
|
|
@@ -3422,7 +4024,7 @@ export const PutModelBudgetsRequestSchema = z
|
|
|
3422
4024
|
}
|
|
3423
4025
|
});
|
|
3424
4026
|
export const ModelBudgetsSchema = z.object({ budgets: z.array(ModelBudgetSchema) }).strict();
|
|
3425
|
-
/** What a tool policy rule does to a call it matches
|
|
4027
|
+
/** What a tool policy rule does to a call it matches. */
|
|
3426
4028
|
export const TOOL_POLICY_EFFECTS = ["allow", "ask", "deny"];
|
|
3427
4029
|
/** A test of one field of a tool call's input; every test it sets must hold. */
|
|
3428
4030
|
export const ToolInputConditionSchema = z
|
|
@@ -3452,12 +4054,13 @@ export const ToolInputConditionSchema = z
|
|
|
3452
4054
|
}
|
|
3453
4055
|
});
|
|
3454
4056
|
/**
|
|
3455
|
-
* One rule of the Tenant's tool policy
|
|
3456
|
-
*
|
|
3457
|
-
*
|
|
3458
|
-
*
|
|
3459
|
-
*
|
|
3460
|
-
*
|
|
4057
|
+
* One rule of the Tenant's tool policy, applied at the Tool Gate to every MCP and HTTP tool call
|
|
4058
|
+
* of every harness. A rule matches a call when every selector it sets matches: `tool` (the tool's
|
|
4059
|
+
* identity: an MCP tool's own name on its server, or an HTTP tool's declared name; never the name
|
|
4060
|
+
* a harness gave the model; `*` for any run of characters), `server` (an MCP server's name),
|
|
4061
|
+
* `kind`, `agent` (the agent that calls it: the agent manifest's name, or the id of an agent used
|
|
4062
|
+
* as a tool or of a flow's agent; never an Agent's id) and `when` (fields of the input, by dotted
|
|
4063
|
+
* path). The strictest matching rule decides: `deny` refuses the call before it is sent,
|
|
3461
4064
|
* `ask` holds it until a person approves it on the session (`approve`), `allow` runs it. A call no
|
|
3462
4065
|
* rule matches runs. Sandbox tools never cross the gate; their network side is egress policy.
|
|
3463
4066
|
*
|
|
@@ -3469,11 +4072,26 @@ export const ToolRuleSchema = z
|
|
|
3469
4072
|
effect: z.enum(TOOL_POLICY_EFFECTS),
|
|
3470
4073
|
// The selectors, and `when`'s paths, are at most the Tenant's Runtime limit
|
|
3471
4074
|
// `toolRuleFieldChars` long; `reason` at most `toolRuleTextChars` (checked when put).
|
|
3472
|
-
tool: z
|
|
3473
|
-
|
|
4075
|
+
tool: z
|
|
4076
|
+
.string()
|
|
4077
|
+
.min(1)
|
|
4078
|
+
.optional()
|
|
4079
|
+
.meta({
|
|
4080
|
+
description: "The tool's identity: an MCP tool's own name on its `server`, or an HTTP tool's declared name, never the name the model calls it by. `*` matches any run of characters; a name with `__` in it is refused",
|
|
4081
|
+
}),
|
|
4082
|
+
server: z.string().min(1).optional().meta({ description: "An MCP server's name; `*` matches any run of characters" }),
|
|
3474
4083
|
kind: z.enum(["mcp", "http"]).optional(),
|
|
3475
|
-
agent: z
|
|
3476
|
-
|
|
4084
|
+
agent: z
|
|
4085
|
+
.string()
|
|
4086
|
+
.min(1)
|
|
4087
|
+
.optional()
|
|
4088
|
+
.meta({
|
|
4089
|
+
description: "The agent that calls the tool: the agent manifest's name, or the id of an agent used as a tool or of a flow's agent, never an Agent's id. `*` matches any run of characters",
|
|
4090
|
+
}),
|
|
4091
|
+
when: z
|
|
4092
|
+
.record(z.string().min(1), ToolInputConditionSchema)
|
|
4093
|
+
.optional()
|
|
4094
|
+
.meta({ description: "Fields of the call's input by dotted path, each tested by every test its condition sets" }),
|
|
3477
4095
|
/** Why the rule exists: shown with a held or denied call. */
|
|
3478
4096
|
reason: z.string().min(1).optional(),
|
|
3479
4097
|
})
|
|
@@ -3513,13 +4131,12 @@ export const StreamClosedFrameSchema = z
|
|
|
3513
4131
|
*/
|
|
3514
4132
|
export const AgUiRunErrorCodeSchema = z.enum([
|
|
3515
4133
|
...ERROR_CODES,
|
|
3516
|
-
"session_busy",
|
|
3517
4134
|
"runtime_error",
|
|
3518
4135
|
]);
|
|
3519
4136
|
// --- Studio embedding (Studio design §8) ---------------------------------------------------
|
|
3520
4137
|
/**
|
|
3521
4138
|
* A Tenant id as Studio's routes accept it.
|
|
3522
|
-
* An identifier's grammar is the protocol's
|
|
4139
|
+
* An identifier's grammar is the protocol's: it crosses the Runtime API, tokens and grants
|
|
3523
4140
|
* and means the same in every installation, so its length is a constant of protocol 15, not a
|
|
3524
4141
|
* setting.
|
|
3525
4142
|
*/
|
|
@@ -3658,7 +4275,7 @@ export const ARTIFACT_TOTAL_BYTES_DEFAULT = 10 * 1024 * 1024 * 1024;
|
|
|
3658
4275
|
/**
|
|
3659
4276
|
* The longest artifact name, in characters: the longest file name a workspace's file system takes
|
|
3660
4277
|
* (`NAME_MAX`), since a name becomes one when the artifact is copied into a sandbox or downloaded.
|
|
3661
|
-
* A standard's constant, not a limit
|
|
4278
|
+
* A standard's constant, not a limit.
|
|
3662
4279
|
*/
|
|
3663
4280
|
export const ARTIFACT_NAME_MAX = FILE_NAME_MAX;
|
|
3664
4281
|
/**
|
|
@@ -3687,7 +4304,7 @@ export const ArtifactVersionViewSchema = z
|
|
|
3687
4304
|
.strict();
|
|
3688
4305
|
/**
|
|
3689
4306
|
* An artifact: an id, a name and numbered versions, its bytes in the Object store. A file's
|
|
3690
|
-
* version is its bytes; a folder's
|
|
4307
|
+
* version is its bytes; a folder's is a manifest of paths to content-addressed files.
|
|
3691
4308
|
*/
|
|
3692
4309
|
export const ArtifactViewSchema = z
|
|
3693
4310
|
.object({
|
|
@@ -3698,10 +4315,10 @@ export const ArtifactViewSchema = z
|
|
|
3698
4315
|
/** The session it belongs to; absent for a Tenant-wide artifact an application made. */
|
|
3699
4316
|
sessionId: z.string().optional(),
|
|
3700
4317
|
/**
|
|
3701
|
-
* The
|
|
3702
|
-
*
|
|
4318
|
+
* The Agent whose disk versions it holds; absent otherwise. Such an artifact
|
|
4319
|
+
* changes only through `/v1/agents/{id}/snapshot` and its versions routes.
|
|
3703
4320
|
*/
|
|
3704
|
-
|
|
4321
|
+
agentId: z.string().optional(),
|
|
3705
4322
|
latestVersion: z.number().int().positive(),
|
|
3706
4323
|
labels: z.record(z.string(), z.string()).optional(),
|
|
3707
4324
|
createdAt: z.string(),
|
|
@@ -3723,7 +4340,7 @@ export const UploadArtifactResponseSchema = z
|
|
|
3723
4340
|
.object({ artifact: ArtifactViewSchema, version: ArtifactVersionViewSchema })
|
|
3724
4341
|
.strict();
|
|
3725
4342
|
/**
|
|
3726
|
-
* `PUT /v1/files/sha256:{hex}`: a definition file the Runtime holds
|
|
4343
|
+
* `PUT /v1/files/sha256:{hex}`: a definition file the Runtime holds, named by the
|
|
3727
4344
|
* SHA-256 of its bytes. `201` stored it, `200` already had it.
|
|
3728
4345
|
*/
|
|
3729
4346
|
export const DefinitionFileViewSchema = z
|
|
@@ -3768,7 +4385,7 @@ export const FOLDER_CONTENT_TYPE = "application/vnd.nylorun.folder+json";
|
|
|
3768
4385
|
/** The manifest format a folder version is stored as. */
|
|
3769
4386
|
export const FOLDER_MANIFEST_FORMAT = "nylorun.folder.v1";
|
|
3770
4387
|
/**
|
|
3771
|
-
* The manifest format of an Environment's disk versions
|
|
4388
|
+
* The manifest format of an Environment's disk versions: v1's entries, plus file
|
|
3772
4389
|
* modes and modification times, symbolic links and empty directories. Readers accept both.
|
|
3773
4390
|
*/
|
|
3774
4391
|
export const FOLDER_MANIFEST_FORMAT_V2 = "nylorun.folder.v2";
|
|
@@ -3798,7 +4415,7 @@ export const FolderEntrySchema = z
|
|
|
3798
4415
|
.strict();
|
|
3799
4416
|
/**
|
|
3800
4417
|
* A folder version as stored: the files, sorted by path, each naming its content-addressed
|
|
3801
|
-
* bytes by SHA-256. The one manifest format for folders, reused by
|
|
4418
|
+
* bytes by SHA-256. The one manifest format for folders, reused by disk snapshots.
|
|
3802
4419
|
*/
|
|
3803
4420
|
export const FolderManifestSchema = z
|
|
3804
4421
|
.object({
|
|
@@ -3881,7 +4498,7 @@ export const TenantSkillsViewSchema = z
|
|
|
3881
4498
|
.object({ limits: z.object({ totalBytes: z.number().int() }).strict() })
|
|
3882
4499
|
.strict();
|
|
3883
4500
|
/**
|
|
3884
|
-
* A Tenant's Runtime limits
|
|
4501
|
+
* A Tenant's Runtime limits, stored as Tenant setting `limits.config`: what
|
|
3885
4502
|
* one record entry, model call, model file, tool answer, harness state and Harness API chunk may
|
|
3886
4503
|
* hold. Each limit left out is its default (`RUNTIME_LIMIT_DEFAULTS`); none may pass its ceiling
|
|
3887
4504
|
* (`RUNTIME_LIMIT_CEILINGS`, a `400` naming it).
|
|
@@ -3898,7 +4515,6 @@ export const TenantLimitsViewSchema = z.object({ limits: RuntimeLimitsSchema }).
|
|
|
3898
4515
|
/** Opt-in session reads (Host feature `session-reads`). */
|
|
3899
4516
|
export const SessionListItemSchema = SessionSummarySchema.extend({
|
|
3900
4517
|
lastTurnId: z.string().nullable(),
|
|
3901
|
-
environmentId: z.string().nullable(),
|
|
3902
4518
|
createdAt: z.string().nullable(),
|
|
3903
4519
|
lastEventAt: z.string().nullable(),
|
|
3904
4520
|
}).strict();
|
|
@@ -3908,9 +4524,12 @@ export const SessionPageSchema = z
|
|
|
3908
4524
|
export const SessionManifestViewSchema = z
|
|
3909
4525
|
.object({
|
|
3910
4526
|
sessionId: z.string(),
|
|
4527
|
+
/** The Agent the session runs on. */
|
|
3911
4528
|
agentId: z.string(),
|
|
4529
|
+
/** The agent manifest version it pinned; `null` for a session closed by protocol 16. */
|
|
4530
|
+
definition: z.object({ name: z.string(), version: z.number().int().positive() }).strict().nullable(),
|
|
3912
4531
|
manifestHash: z.string(),
|
|
3913
|
-
|
|
4532
|
+
/** The loop manifest it pinned: that version's harness section, as the harness runs it. */
|
|
3914
4533
|
manifest: z.record(z.string(), z.unknown()),
|
|
3915
4534
|
})
|
|
3916
4535
|
.strict();
|
|
@@ -3924,6 +4543,18 @@ const usageNumbers = {
|
|
|
3924
4543
|
reasoningTokens: z.number().int().nonnegative(),
|
|
3925
4544
|
costUsd: z.number().nonnegative(),
|
|
3926
4545
|
};
|
|
4546
|
+
/**
|
|
4547
|
+
* A cost by the token kind it paid for, at the prices in force when the call was made:
|
|
4548
|
+
* uncached input, input read from the provider's cache, input written to it, and output.
|
|
4549
|
+
*/
|
|
4550
|
+
export const CostSplitSchema = z
|
|
4551
|
+
.object({
|
|
4552
|
+
input: z.number().nonnegative(),
|
|
4553
|
+
cacheRead: z.number().nonnegative(),
|
|
4554
|
+
cacheWrite: z.number().nonnegative(),
|
|
4555
|
+
output: z.number().nonnegative(),
|
|
4556
|
+
})
|
|
4557
|
+
.strict();
|
|
3927
4558
|
export const SessionUsageTotalsSchema = z
|
|
3928
4559
|
.object({
|
|
3929
4560
|
sessionId: z.string(),
|
|
@@ -3935,22 +4566,42 @@ export const SessionUsageTotalsSchema = z
|
|
|
3935
4566
|
unpricedCalls: z.number().int().nonnegative(),
|
|
3936
4567
|
unreportedCalls: z.number().int().nonnegative(),
|
|
3937
4568
|
unknownQualityCalls: z.number().int().nonnegative(),
|
|
4569
|
+
/**
|
|
4570
|
+
* `costUsd` by token kind, summed over the `splitCalls` calls that kept their split. A call
|
|
4571
|
+
* recorded before the split was kept counts in `costUsd` only. Protocol 18, like
|
|
4572
|
+
* `modelTimeMs` and `timedCalls`: an older client's read leaves all four out.
|
|
4573
|
+
*/
|
|
4574
|
+
costSplit: CostSplitSchema,
|
|
4575
|
+
splitCalls: z.number().int().nonnegative(),
|
|
4576
|
+
/**
|
|
4577
|
+
* The calls' durations added up, from when the gate sent each call to when its answer was
|
|
4578
|
+
* complete, over the `timedCalls` calls the gate timed. Calls that overlap each count in full.
|
|
4579
|
+
*/
|
|
4580
|
+
modelTimeMs: z.number().int().nonnegative(),
|
|
4581
|
+
timedCalls: z.number().int().nonnegative(),
|
|
3938
4582
|
})
|
|
3939
4583
|
.strict();
|
|
3940
4584
|
export const ModelCallSchema = z
|
|
3941
4585
|
.object({
|
|
3942
4586
|
id: z.string(),
|
|
3943
4587
|
/**
|
|
3944
|
-
* The model effect the call served: the effect id its harness sent as `Idempotency-Key
|
|
3945
|
-
*
|
|
4588
|
+
* The model effect the call served: the effect id its harness sent as `Idempotency-Key`,
|
|
4589
|
+
* so a call is joined to the journal.
|
|
3946
4590
|
*/
|
|
3947
4591
|
effectId: z.string(),
|
|
3948
4592
|
sessionId: z.string(),
|
|
3949
4593
|
turnId: z.string(),
|
|
3950
|
-
agentId
|
|
4594
|
+
/** The agent manifest the calling agent came from (protocol 16; `agentId` before). */
|
|
4595
|
+
manifestName: z.string(),
|
|
3951
4596
|
provider: z.string().nullable(),
|
|
3952
4597
|
model: z.string().nullable(),
|
|
3953
4598
|
at: z.string(),
|
|
4599
|
+
/**
|
|
4600
|
+
* When the gate sent the call, and when its answer was complete; null when untimed. Protocol
|
|
4601
|
+
* 18, like `usage.costSplit`: an older client's read leaves them out.
|
|
4602
|
+
*/
|
|
4603
|
+
startedAt: z.string().nullable(),
|
|
4604
|
+
endedAt: z.string().nullable(),
|
|
3954
4605
|
outcome: z.enum(["completed", "failed"]),
|
|
3955
4606
|
usage: z
|
|
3956
4607
|
.object({
|
|
@@ -3958,6 +4609,8 @@ export const ModelCallSchema = z
|
|
|
3958
4609
|
duplicate: z.boolean(),
|
|
3959
4610
|
tokensReported: z.boolean().nullable(),
|
|
3960
4611
|
costKnown: z.boolean().nullable(),
|
|
4612
|
+
/** `costUsd` by token kind; null for a call recorded before the split was kept. */
|
|
4613
|
+
costSplit: CostSplitSchema.nullable(),
|
|
3961
4614
|
})
|
|
3962
4615
|
.strict()
|
|
3963
4616
|
.nullable(),
|
|
@@ -3975,9 +4628,9 @@ export const ModelCallExportPageSchema = z
|
|
|
3975
4628
|
})
|
|
3976
4629
|
.strict();
|
|
3977
4630
|
/**
|
|
3978
|
-
* One tool call of a session
|
|
4631
|
+
* One tool call of a session, read from the effect journal: what ran, with what input,
|
|
3979
4632
|
* how many sends, and how it ended. `invoking` while it runs. `uncertain` only for a call
|
|
3980
|
-
* recorded
|
|
4633
|
+
* recorded by an older Runtime. The output is in the session's log (`tool.completed`).
|
|
3981
4634
|
*/
|
|
3982
4635
|
export const ToolCallSchema = z
|
|
3983
4636
|
.object({
|
|
@@ -3994,7 +4647,7 @@ export const ToolCallSchema = z
|
|
|
3994
4647
|
skill: z.string().nullable(),
|
|
3995
4648
|
/** The Agent Plugin that brought its MCP server or skill. */
|
|
3996
4649
|
plugin: pluginLabelSchema.nullable(),
|
|
3997
|
-
/** `held`: the Tool Gate holds it for a person's approval
|
|
4650
|
+
/** `held`: the Tool Gate holds it for a person's approval. */
|
|
3998
4651
|
status: z.enum(["invoking", "held", ...TOOL_CALL_STATUSES, "uncertain"]),
|
|
3999
4652
|
attempts: z.number().int().nonnegative(),
|
|
4000
4653
|
input: z.unknown(),
|
|
@@ -4007,12 +4660,12 @@ export const ToolCallSchema = z
|
|
|
4007
4660
|
export const ToolCallsPageSchema = z
|
|
4008
4661
|
.object({ calls: z.array(ToolCallSchema), nextCursor: z.string().nullable(), asOf: z.string() })
|
|
4009
4662
|
.strict();
|
|
4010
|
-
/** One OTLP attribute
|
|
4663
|
+
/** One OTLP attribute: a key and an `AnyValue` (`stringValue`, `intValue`, …). */
|
|
4011
4664
|
export const OtlpKeyValueSchema = z
|
|
4012
4665
|
.object({ key: z.string(), value: z.record(z.string(), z.unknown()) })
|
|
4013
4666
|
.passthrough();
|
|
4014
4667
|
/**
|
|
4015
|
-
* One span as OTLP/HTTP JSON encodes it
|
|
4668
|
+
* One span as OTLP/HTTP JSON encodes it: hex ids, times in nanoseconds as decimal strings,
|
|
4016
4669
|
* `kind` (1 internal, 3 client) and `status.code` (0 unset, 1 ok, 2 error) as numbers.
|
|
4017
4670
|
*/
|
|
4018
4671
|
export const OtlpSpanSchema = z
|
|
@@ -4029,7 +4682,7 @@ export const OtlpSpanSchema = z
|
|
|
4029
4682
|
})
|
|
4030
4683
|
.passthrough();
|
|
4031
4684
|
/**
|
|
4032
|
-
* A turn's trace (
|
|
4685
|
+
* A turn's trace (feature `traces`): the OTLP `ExportTraceServiceRequest` JSON the Runtime
|
|
4033
4686
|
* posts to a collector, built from the turn's log rows. One resource, one scope.
|
|
4034
4687
|
*/
|
|
4035
4688
|
export const TurnTraceSchema = z
|
|
@@ -4047,6 +4700,6 @@ export const TurnTraceSchema = z
|
|
|
4047
4700
|
.passthrough()),
|
|
4048
4701
|
})
|
|
4049
4702
|
.passthrough();
|
|
4050
|
-
export const
|
|
4051
|
-
.object({
|
|
4703
|
+
export const AgentPageSchema = z
|
|
4704
|
+
.object({ agents: z.array(AgentViewSchema), nextCursor: z.string().nullable() })
|
|
4052
4705
|
.strict();
|