@nylorun/agents 0.23.0-beta → 0.24.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -6,22 +6,24 @@ export { Agent, AgentBuilder } from "./builder.js";
6
6
  export { AgentBuildError, AgentLifecycleError, VerdictSchema, isVerdict, WorkflowBuildError, isBuiltWorkflow, flow, tool, http, defineSchema, ToolError, } from "@nylorun/core/define";
7
7
  export type { FlowAgentBuilder, Flow, Named, LoopOptions, StageOptions, HttpTarget, } from "@nylorun/core/define";
8
8
  export type { AgentOptions, AgentManifest, BuiltAgent, BuiltWorkflow, Verdict, WorkflowBinding, WorkflowManifest, ToolDefinition, ToolExecutionContext, ToolOutcome, JsonValue, JsonObject, } from "@nylorun/core/define";
9
- export type { SessionPage, SessionListItem, SessionManifestView, HistoryPage, SessionUsageTotals, ModelCall, ModelCallsPage, EnvironmentPage, ToolCall, ToolCallsPage, LiveEvent, SessionEvent, SessionEventOf, EventType, SessionCommand, SubjectScope, EnvironmentView, EnvironmentEvent, EnvironmentEventType, EgressRunningTurn, EnvironmentKind, EnvironmentRecipe, EnvironmentSecretView, EnvironmentSnapshot, EnvironmentRestore, EnvironmentVersions, RestoreEnvironmentRequest, EnvironmentForkPlan, ForkEnvironmentRequest, ForkEnvironmentResponse, EnvironmentManifest, EnvironmentManifestPlan, EnvironmentManifestView, EnvironmentManifestVersions, SaveEnvironmentManifestResponse, MessagePart, ArtifactView, ArtifactKind, ArtifactListItem, ArtifactPage, ArtifactVersionView, ArtifactLink, UploadArtifactResponse, DefinitionFileView, ArtifactTree, ArtifactDiff, FolderEntry, } from "@nylorun/core/contracts";
10
- export { ENVIRONMENT_EVENT_TYPES, RUNTIME_LIMIT_DEFAULTS, SUBJECT_SCOPES } from "@nylorun/core/contracts";
9
+ export type { SessionPage, SessionListItem, SessionManifestView, HistoryPage, SessionUsageTotals, ModelCall, ModelCallsPage, AgentPage, ToolCall, ToolCallsPage, LiveEvent, SessionEvent, SessionEventOf, EventType, SessionCommand, SubjectScope, AgentView, AgentState, AgentAttention, AgentEvent, AgentEventType, EgressRunningTurn, EnvironmentKind, EnvironmentRecipe, EnvironmentSecretSlot, AgentSecretView, AgentSnapshot, AgentRestore, AgentDiskVersions, RestoreAgentRequest, AgentForkPlan, AgentMovePlan, RestartAgentRequest, ForkAgentRequest, ForkAgentResponse, DeleteAgentResponse, PutAgentRequest, PutAgentSecretRequest, AgentManifestV8, AgentManifestFile, HarnessManifestFile, RuntimeManifestFile, RuntimeSection, AgentManifestChange, AgentManifestWarning, AgentManifestPlan, AgentManifestView, AgentManifestVersions, SaveAgentManifestResponse, DeleteAgentManifestResponse, MessagePart, ArtifactView, ArtifactKind, ArtifactListItem, ArtifactPage, ArtifactVersionView, ArtifactLink, UploadArtifactResponse, DefinitionFileView, ArtifactTree, ArtifactDiff, FolderEntry, } from "@nylorun/core/contracts";
10
+ export { AGENT_EVENT_TYPES, AGENT_STATES, COMPUTE_STATES, RUNTIME_LIMIT_DEFAULTS, SUBJECT_SCOPES, } from "@nylorun/core/contracts";
11
+ export type { AgentHarnessSection, HarnessSection, HarnessSkill, HarnessMcpServer, WorkflowHarnessSection, } from "@nylorun/core";
11
12
  export { AgentsClient, SessionClient, createClient } from "./client.js";
12
13
  export { ArtifactsClient } from "./artifacts.js";
13
14
  export { FilesClient, definitionFileHash } from "./files.js";
14
15
  export type { ArtifactBody, ArtifactPageOptions, ArtifactLinkWithUrl, UploadArtifactOptions, } from "./artifacts.js";
15
- export type { ActAsOptions, AgentSource, SessionView, CommandOptions, CreateSessionOptions, SessionSandbox, ForSessionOptions, EnvironmentFileBytes, EnvironmentInput, EnvironmentManifestInput, EnvironmentSecretInput, SessionEnvironmentHandle, } from "./client.js";
16
- export { EnvironmentManifestsClient, EnvironmentsClient, EnvironmentSecretsClient, environmentFiles, environmentManifest, } from "./client.js";
16
+ export type { ActAsOptions, AgentSource, SessionView, CommandOptions, CreateSessionOptions, SessionSandbox, AgentFilter, AgentInput, AgentSecretInput, RuntimeFileBytes, AgentManifestDocument, AgentManifestFromAgent, AgentManifestInput, AgentManifestSaveOptions, ComposedManifest, DefinitionFiles, } from "./client.js";
17
+ export { AgentInstancesClient, AgentManifestsClient, AgentMemoriesClient, AgentSecretsClient, ManifestGapsError, agentManifest, requirementGaps, runtimeFiles, } from "./client.js";
18
+ export { composeManifest, manifestFolders, ComposeError, AGENT_MANIFEST_FILE } from "./compose.js";
17
19
  export { AccessClient } from "./access.js";
18
20
  export { resolveConnection, ConnectionError } from "./connection.js";
19
21
  export type { ResolvedConnection } from "./connection.js";
20
22
  export { RuntimeError, IncompatibleRuntimeError } from "./http.js";
21
23
  export type { Destination, IncompatibleReason, TokenSource } from "./http.js";
22
- export { loadPlugin, PluginError } from "./plugins/load.js";
24
+ export { loadMcpServers, loadPlugin, PluginError } from "./plugins/load.js";
23
25
  export type { LoadedPlugin, PluginDiagnostic } from "./plugins/load.js";
24
- export { loadSkillsFromDirectory, resolveSkillsRoot, parseSkill, SkillsError, } from "./skills/index.js";
26
+ export { hashFolder, loadSkillsFromDirectory, resolveSkillsRoot, parseSkill, SkillsError, } from "./skills/index.js";
25
27
  export type { SkillDiagnostic } from "./skills/index.js";
26
28
  export { McpError } from "./mcp/index.js";
27
29
  export type { McpServerSpec } from "./mcp/index.js";
package/dist/index.js CHANGED
@@ -4,14 +4,15 @@ export { hashManifest, PROTOCOL_VERSION, PROTOCOL_FEATURES, HOST_PROTOCOL, DEFIN
4
4
  export { checkHealth, describeIncompatibility, parseProtocolRange, } from "@nylorun/core/transport";
5
5
  export { Agent, AgentBuilder } from "./builder.js";
6
6
  export { AgentBuildError, AgentLifecycleError, VerdictSchema, isVerdict, WorkflowBuildError, isBuiltWorkflow, flow, tool, http, defineSchema, ToolError, } from "@nylorun/core/define";
7
- export { ENVIRONMENT_EVENT_TYPES, RUNTIME_LIMIT_DEFAULTS, SUBJECT_SCOPES } from "@nylorun/core/contracts";
7
+ export { AGENT_EVENT_TYPES, AGENT_STATES, COMPUTE_STATES, RUNTIME_LIMIT_DEFAULTS, SUBJECT_SCOPES, } from "@nylorun/core/contracts";
8
8
  export { AgentsClient, SessionClient, createClient } from "./client.js";
9
9
  export { ArtifactsClient } from "./artifacts.js";
10
10
  export { FilesClient, definitionFileHash } from "./files.js";
11
- export { EnvironmentManifestsClient, EnvironmentsClient, EnvironmentSecretsClient, environmentFiles, environmentManifest, } from "./client.js";
11
+ export { AgentInstancesClient, AgentManifestsClient, AgentMemoriesClient, AgentSecretsClient, ManifestGapsError, agentManifest, requirementGaps, runtimeFiles, } from "./client.js";
12
+ export { composeManifest, manifestFolders, ComposeError, AGENT_MANIFEST_FILE } from "./compose.js";
12
13
  export { AccessClient } from "./access.js";
13
14
  export { resolveConnection, ConnectionError } from "./connection.js";
14
15
  export { RuntimeError, IncompatibleRuntimeError } from "./http.js";
15
- export { loadPlugin, PluginError } from "./plugins/load.js";
16
- export { loadSkillsFromDirectory, resolveSkillsRoot, parseSkill, SkillsError, } from "./skills/index.js";
16
+ export { loadMcpServers, loadPlugin, PluginError } from "./plugins/load.js";
17
+ export { hashFolder, loadSkillsFromDirectory, resolveSkillsRoot, parseSkill, SkillsError, } from "./skills/index.js";
17
18
  export { McpError } from "./mcp/index.js";
@@ -23,3 +23,13 @@ export interface LoadedPlugin {
23
23
  readonly diagnostics: readonly PluginDiagnostic[];
24
24
  }
25
25
  export declare function loadPlugin(directory: string): LoadedPlugin;
26
+ /**
27
+ * The remote MCP servers of an `mcp.json` in the Agent Plugins format (`$schema` and
28
+ * `mcpServers`), as a manifest declares them: a plugin's, or the one a `harness.manifest.json`
29
+ * names. A file that cannot be read is a `<prefix>.mcp-invalid` diagnostic and no servers; an
30
+ * invalid server is skipped with a diagnostic; a stdio server throws.
31
+ */
32
+ export declare function loadMcpServers(location: string, diagnostics: PluginDiagnostic[], options?: {
33
+ readonly boundary?: string;
34
+ readonly codePrefix?: string;
35
+ }): Readonly<Record<string, McpServerManifest>>;
@@ -1,5 +1,5 @@
1
1
  import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
2
- import { isAbsolute, join, relative, resolve, sep } from "node:path";
2
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
3
3
  import { stdioMcpRefusal } from "@nylorun/core/define";
4
4
  import { HEADER_NAME_PATTERN, LOOPBACK_HOSTS, McpServerManifestSchema, } from "@nylorun/core/contracts";
5
5
  import { loadSkillsFromDirectory } from "../skills/load.js";
@@ -137,12 +137,23 @@ function loadMcp(root, diagnostics) {
137
137
  const location = join(root, "mcp.json");
138
138
  if (!existsSync(location))
139
139
  return {};
140
- const real = realInside(root, location);
140
+ return loadMcpServers(location, diagnostics, { boundary: root });
141
+ }
142
+ /**
143
+ * The remote MCP servers of an `mcp.json` in the Agent Plugins format (`$schema` and
144
+ * `mcpServers`), as a manifest declares them: a plugin's, or the one a `harness.manifest.json`
145
+ * names. A file that cannot be read is a `<prefix>.mcp-invalid` diagnostic and no servers; an
146
+ * invalid server is skipped with a diagnostic; a stdio server throws.
147
+ */
148
+ export function loadMcpServers(location, diagnostics, options = {}) {
149
+ const prefix = options.codePrefix ?? "plugin";
150
+ const boundary = options.boundary ?? dirname(resolve(location));
151
+ const real = realInside(boundary, location);
141
152
  if (!real || !statSync(real).isFile()) {
142
153
  diagnostics.push({
143
154
  severity: "warning",
144
- code: "plugin.mcp-invalid",
145
- message: "mcp.json is not a file inside the package",
155
+ code: `${prefix}.mcp-invalid`,
156
+ message: `${basename(location)} is not a file inside the package`,
146
157
  path: location,
147
158
  });
148
159
  return {};
@@ -154,8 +165,8 @@ function loadMcp(root, diagnostics) {
154
165
  catch {
155
166
  diagnostics.push({
156
167
  severity: "warning",
157
- code: "plugin.mcp-invalid",
158
- message: "mcp.json is not valid JSON",
168
+ code: `${prefix}.mcp-invalid`,
169
+ message: `${basename(location)} is not valid JSON`,
159
170
  path: location,
160
171
  });
161
172
  return {};
@@ -163,8 +174,8 @@ function loadMcp(root, diagnostics) {
163
174
  if (!isRecord(parsed) || Object.keys(parsed).some((key) => key !== "$schema" && key !== "mcpServers")) {
164
175
  diagnostics.push({
165
176
  severity: "warning",
166
- code: "plugin.mcp-invalid",
167
- message: "mcp.json must contain only $schema and mcpServers",
177
+ code: `${prefix}.mcp-invalid`,
178
+ message: `${basename(location)} must contain only $schema and mcpServers`,
168
179
  path: location,
169
180
  });
170
181
  return {};
@@ -172,8 +183,8 @@ function loadMcp(root, diagnostics) {
172
183
  if (parsed.$schema !== MCP_SCHEMA) {
173
184
  diagnostics.push({
174
185
  severity: "warning",
175
- code: "plugin.mcp-invalid",
176
- message: "mcp.json $schema does not match the plugin schema version",
186
+ code: `${prefix}.mcp-invalid`,
187
+ message: `${basename(location)} $schema does not match the plugin schema version`,
177
188
  path: location,
178
189
  });
179
190
  return {};
@@ -181,8 +192,8 @@ function loadMcp(root, diagnostics) {
181
192
  if (!isRecord(parsed.mcpServers)) {
182
193
  diagnostics.push({
183
194
  severity: "warning",
184
- code: "plugin.mcp-invalid",
185
- message: "mcp.json mcpServers must be an object",
195
+ code: `${prefix}.mcp-invalid`,
196
+ message: `${basename(location)} mcpServers must be an object`,
186
197
  path: location,
187
198
  });
188
199
  return {};
@@ -190,12 +201,12 @@ function loadMcp(root, diagnostics) {
190
201
  const servers = {};
191
202
  for (const [name, value] of Object.entries(parsed.mcpServers)) {
192
203
  if (isRecord(value) && value.type === "stdio")
193
- throw new PluginError("plugin.mcp-stdio", stdioMcpRefusal(name), diagnostics);
204
+ throw new PluginError(`${prefix}.mcp-stdio`, stdioMcpRefusal(name), diagnostics);
194
205
  const server = validateServer(name, value);
195
206
  if (typeof server === "string") {
196
207
  diagnostics.push({
197
208
  severity: "warning",
198
- code: "plugin.mcp-server-skipped",
209
+ code: `${prefix}.mcp-server-skipped`,
199
210
  message: `Skipped invalid MCP server '${name}': ${server}`,
200
211
  path: location,
201
212
  });
@@ -5,7 +5,7 @@ export interface PluginPart extends PartDeclaration {
5
5
  }
6
6
  /**
7
7
  * Read an Agent Plugin package as one part of an agent, for `.plugin()`. Each part it skips
8
- * (an invalid MCP server or skill) is a process warning, so building or registering the agent
8
+ * (an invalid MCP server or skill) is a process warning, so building or saving its manifest
9
9
  * says why the agent has less than the package declares. A stdio MCP server throws: Nylorun
10
10
  * accepts remote servers only.
11
11
  */
@@ -2,7 +2,7 @@ import { skillsDeclaration } from "../skills/skills.js";
2
2
  import { loadPlugin, } from "./load.js";
3
3
  /**
4
4
  * Read an Agent Plugin package as one part of an agent, for `.plugin()`. Each part it skips
5
- * (an invalid MCP server or skill) is a process warning, so building or registering the agent
5
+ * (an invalid MCP server or skill) is a process warning, so building or saving its manifest
6
6
  * says why the agent has less than the package declares. A stdio MCP server throws: Nylorun
7
7
  * accepts remote servers only.
8
8
  */
package/dist/reads.d.ts CHANGED
@@ -2,9 +2,11 @@
2
2
  import { type SessionListItem, type SessionPage } from "@nylorun/core/contracts";
3
3
  import type { Transport } from "./http.js";
4
4
  export type SessionPageOptions = {
5
+ /** The Agent the sessions run on. */
5
6
  agentId?: string;
7
+ /** The agent manifest's name their Agents were made from. */
8
+ manifest?: string;
6
9
  status?: SessionListItem["status"];
7
- environmentId?: string;
8
10
  ownerUserId?: string;
9
11
  limit?: number;
10
12
  cursor?: string;
@@ -2,11 +2,12 @@
2
2
  * The Runtime API client classes, with no Node-only imports. `client.ts` adds `createClient`,
3
3
  * which resolves the connection from the environment or the Project link.
4
4
  */
5
- import type { AgentManifest, BuiltAgent, BuiltWorkflow, JsonValue, SandboxToolName, WorkflowManifest } from "@nylorun/core/define";
6
- import { type SessionItemsResponse, type SessionSummary, type ListAgentsResponse, type ListPublicAgentsResponse, type SubjectScope, type MessagePart, type SessionCommand } from "@nylorun/core/contracts";
5
+ import type { JsonValue, SandboxToolName } from "@nylorun/core/define";
6
+ import { type SessionItemsResponse, type SessionSummary, type SubjectScope, type MessageDelivery, type MessagePart, type SessionCommand } from "@nylorun/core/contracts";
7
7
  import { SessionsReadClient } from "./reads.js";
8
8
  import { AccessClient } from "./access.js";
9
- import { EnvironmentsClient } from "./environments.js";
9
+ import { AgentInstancesClient } from "./agents.js";
10
+ import { AgentManifestsClient } from "./agent-manifests.js";
10
11
  import { ArtifactsClient } from "./artifacts.js";
11
12
  import { FilesClient } from "./files.js";
12
13
  import { Transport, type Destination } from "./http.js";
@@ -14,12 +15,6 @@ import { Transport, type Destination } from "./http.js";
14
15
  export type SessionSandbox = {
15
16
  readonly [K in SandboxToolName]: (args: Record<string, unknown>) => Promise<unknown>;
16
17
  };
17
- export interface AgentSource {
18
- readonly id: string;
19
- readonly manifest: AgentManifest | WorkflowManifest;
20
- build?(): BuiltAgent | BuiltWorkflow;
21
- getBinding?: BuiltAgent["getBinding"] | BuiltWorkflow["getBinding"];
22
- }
23
18
  export interface SessionView {
24
19
  id: string;
25
20
  agentId: string;
@@ -31,17 +26,16 @@ export interface SessionView {
31
26
  }
32
27
  /** `AgentsClient.createSession`'s options. */
33
28
  export interface CreateSessionOptions {
29
+ /** The session's id, which the app chooses (D71). Default: a new UUID. */
34
30
  id?: string;
35
- agentId: string;
31
+ /**
32
+ * The Agent the session runs on (`client.agents`): its manifest version, its sandbox and its
33
+ * vault's credentials. Fixed once the session exists.
34
+ */
35
+ agent: string;
36
36
  ownerUserId: string;
37
37
  info?: Record<string, unknown>;
38
38
  requestId?: string;
39
- /**
40
- * The Environment the session runs in (`client.environments`): its sandbox, and its vault's
41
- * credentials for the session's shell, MCP servers and HTTP tools. Omit for no sandbox and no
42
- * credentials. Fixed once the session exists.
43
- */
44
- environment?: string;
45
39
  }
46
40
  export interface ActAsOptions {
47
41
  /** What the subject may do; the Runtime grants nothing else. Default `["sessions:own"]`. */
@@ -62,11 +56,16 @@ export declare class AgentsClient {
62
56
  /** The public keys that verify the tokens the Tenant signs. */
63
57
  get access(): AccessClient;
64
58
  /**
65
- * Environments (protocol 11): `put` one by id (create, find or change), write its `secrets`,
66
- * `list` them by label, `stop`, `reset` or `delete` one, or give a session its own with
67
- * `forSession`.
59
+ * Agent manifests (protocol 16): `save` a manifest's next version (a v8 document, what
60
+ * `composeManifest` read, or a built agent with its runtime section), `plan` a save, read
61
+ * their versions.
68
62
  */
69
- get environments(): EnvironmentsClient;
63
+ get agentManifests(): AgentManifestsClient;
64
+ /**
65
+ * Agents (protocol 16): `put` one by id from a saved manifest (create or find), write its
66
+ * `secrets`, `list` them, `stop`, `reset`, `fork` or `delete` one. Sessions run on them.
67
+ */
68
+ get agents(): AgentInstancesClient;
70
69
  /** File artifacts: upload, list, download with Range, capability links (protocol 6). */
71
70
  get artifacts(): ArtifactsClient;
72
71
  /** Definition files: the skill files a definition names, by content hash. */
@@ -76,32 +75,12 @@ export declare class AgentsClient {
76
75
  signal?: AbortSignal;
77
76
  }): Promise<readonly string[]>;
78
77
  get sessions(): SessionsReadClient;
79
- listAgents(options?: {
80
- signal?: AbortSignal;
81
- }): Promise<ListAgentsResponse | {
82
- agents: (ListPublicAgentsResponse["agents"][number] & {
83
- manifest?: never;
84
- })[];
85
- }>;
86
78
  listSessions(options?: {
87
79
  agentId?: string;
88
80
  signal?: AbortSignal;
89
81
  }): Promise<{
90
82
  sessions: SessionSummary[];
91
83
  }>;
92
- /**
93
- * Registers the agent's definition (`PUT /v1/agents/{id}`), first uploading the skill files
94
- * it names that the Runtime does not hold. A definition with a tool that runs your code
95
- * (`tool({ run })`, a flow's tool stage) is refused before anything is sent: the Runtime runs
96
- * agents from their manifests alone. `implementationVersion` defaults to
97
- * `NYLORUN_IMPLEMENTATION_VERSION`, else `dev`. `dryRun` (protocol 14) runs every check and
98
- * saves nothing; the skill files are still uploaded, since they are stored by content.
99
- */
100
- saveAgent(agent: AgentSource | BuiltWorkflow, options?: {
101
- implementationVersion?: string;
102
- requestId?: string;
103
- dryRun?: boolean;
104
- }): Promise<unknown>;
105
84
  createSession(options: CreateSessionOptions): Promise<SessionClient>;
106
85
  session(sessionId: string): SessionClient;
107
86
  }
@@ -110,6 +89,14 @@ export type CommandOptions = {
110
89
  requestId?: string;
111
90
  signal?: AbortSignal;
112
91
  };
92
+ /**
93
+ * A message's options. `delivery` says what a message to a busy session does (protocol 17):
94
+ * `queue` (the default) waits for the running turn to end, `reject` is refused with
95
+ * `409 session_busy`.
96
+ */
97
+ export type MessageOptions = CommandOptions & {
98
+ delivery?: MessageDelivery;
99
+ };
113
100
  export declare class SessionClient {
114
101
  private readonly transport;
115
102
  readonly id: string;
@@ -119,44 +106,75 @@ export declare class SessionClient {
119
106
  inspect(signal?: AbortSignal): Promise<SessionView>;
120
107
  /** Pending waits / interactions from the session inspect view. */
121
108
  pending(signal?: AbortSignal): Promise<{}>;
109
+ /** A message answers `queued` when it waits for the running turn (protocol 17). */
122
110
  command(command: SessionCommand, signal?: AbortSignal): Promise<{
123
111
  status: "accepted";
124
112
  turnId: string | null;
125
113
  cursor: string | null;
126
114
  requestId: string;
115
+ } | {
116
+ status: "queued";
117
+ queuedMessageId: string;
118
+ position: number;
119
+ cursor: string | null;
120
+ requestId: string;
127
121
  }>;
128
122
  /**
129
123
  * Start a turn. Strings become `message.content`; any other JSON value becomes
130
124
  * `message.data` (workflows.md §5).
131
125
  */
132
- input(value: string | JsonValue, options: CommandOptions): Promise<{
126
+ input(value: string | JsonValue, options: MessageOptions): Promise<{
133
127
  status: "accepted";
134
128
  turnId: string | null;
135
129
  cursor: string | null;
136
130
  requestId: string;
131
+ } | {
132
+ status: "queued";
133
+ queuedMessageId: string;
134
+ position: number;
135
+ cursor: string | null;
136
+ requestId: string;
137
137
  }>;
138
138
  /**
139
139
  * Start a turn with text and file parts (protocol 6): a file part names an artifact (upload
140
140
  * it with `client.artifacts.upload`), at a version or its latest, and the model reads it, an
141
141
  * image as an image and a text file as text.
142
142
  */
143
- inputParts(parts: readonly MessagePart[], options: CommandOptions): Promise<{
143
+ inputParts(parts: readonly MessagePart[], options: MessageOptions): Promise<{
144
144
  status: "accepted";
145
145
  turnId: string | null;
146
146
  cursor: string | null;
147
147
  requestId: string;
148
+ } | {
149
+ status: "queued";
150
+ queuedMessageId: string;
151
+ position: number;
152
+ cursor: string | null;
153
+ requestId: string;
148
154
  }>;
149
155
  approve(interactionId: string, approved: boolean, options: CommandOptions): Promise<{
150
156
  status: "accepted";
151
157
  turnId: string | null;
152
158
  cursor: string | null;
153
159
  requestId: string;
160
+ } | {
161
+ status: "queued";
162
+ queuedMessageId: string;
163
+ position: number;
164
+ cursor: string | null;
165
+ requestId: string;
154
166
  }>;
155
167
  respond(interactionId: string, value: JsonValue, options: CommandOptions): Promise<{
156
168
  status: "accepted";
157
169
  turnId: string | null;
158
170
  cursor: string | null;
159
171
  requestId: string;
172
+ } | {
173
+ status: "queued";
174
+ queuedMessageId: string;
175
+ position: number;
176
+ cursor: string | null;
177
+ requestId: string;
160
178
  }>;
161
179
  cancel(options: CommandOptions & {
162
180
  reason?: string;
@@ -165,14 +183,23 @@ export declare class SessionClient {
165
183
  turnId: string | null;
166
184
  cursor: string | null;
167
185
  requestId: string;
186
+ } | {
187
+ status: "queued";
188
+ queuedMessageId: string;
189
+ position: number;
190
+ cursor: string | null;
191
+ requestId: string;
168
192
  }>;
169
193
  manifest(options?: {
170
194
  signal?: AbortSignal;
171
195
  }): Promise<{
172
196
  sessionId: string;
173
197
  agentId: string;
198
+ definition: {
199
+ name: string;
200
+ version: number;
201
+ } | null;
174
202
  manifestHash: string;
175
- implementationVersion: string;
176
203
  manifest: Record<string, unknown>;
177
204
  }>;
178
205
  usage(options?: {
@@ -206,7 +233,7 @@ export declare class SessionClient {
206
233
  effectId: string;
207
234
  sessionId: string;
208
235
  turnId: string;
209
- agentId: string;
236
+ manifestName: string;
210
237
  provider: string | null;
211
238
  model: string | null;
212
239
  at: string;
@@ -242,7 +269,7 @@ export declare class SessionClient {
242
269
  turnId: string;
243
270
  callId: string | null;
244
271
  toolName: string | null;
245
- kind: "harness" | "http" | "mcp" | "sandbox" | null;
272
+ kind: "harness" | "http" | "mcp" | "runtime" | "sandbox" | null;
246
273
  server: string | null;
247
274
  tool: string | null;
248
275
  skill: string | null;
@@ -350,7 +377,7 @@ export declare class SessionClient {
350
377
  };
351
378
  evidence: "asserted" | "attested" | "claimed" | "measured" | "observed";
352
379
  principal?: {
353
- kind: "application" | "core" | "flow-host" | "subject";
380
+ kind: "application" | "core" | "flow-host" | "subject" | "trigger";
354
381
  id: string;
355
382
  } | undefined;
356
383
  trace?: {
@@ -374,5 +401,7 @@ export { RuntimeError, IncompatibleRuntimeError } from "./http.js";
374
401
  export type { Destination, IncompatibleReason } from "./http.js";
375
402
  export type { LiveEvent } from "@nylorun/core/contracts";
376
403
  export { AccessClient } from "./access.js";
377
- export { EnvironmentManifestsClient, EnvironmentSecretsClient, EnvironmentsClient, environmentFiles, environmentManifest, } from "./environments.js";
378
- export type { EnvironmentFileBytes, EnvironmentInput, EnvironmentManifestInput, EnvironmentSecretInput, ForSessionOptions, SessionEnvironmentHandle, } from "./environments.js";
404
+ export { AgentInstancesClient, AgentMemoriesClient, AgentSecretsClient, runtimeFiles } from "./agents.js";
405
+ export type { AgentFilter, AgentInput, AgentSecretInput, RuntimeFileBytes } from "./agents.js";
406
+ export { AgentManifestsClient, ManifestGapsError, agentManifest, requirementGaps } from "./agent-manifests.js";
407
+ export type { AgentManifestDocument, AgentManifestFromAgent, AgentManifestInput, AgentManifestSaveOptions, AgentSource, ComposedManifest, DefinitionFiles, } from "./agent-manifests.js";
@@ -1,13 +1,14 @@
1
- import { SANDBOX_TOOL_NAMES, approvalRefusal, codeToolRefusal, delegateOf, isBuiltWorkflow, isSandboxToolName, } from "@nylorun/core/define";
1
+ import { SANDBOX_TOOL_NAMES, isSandboxToolName } from "@nylorun/core/define";
2
2
  import { z } from "zod";
3
3
  import { SCOPES_HEADER, SUBJECT_HEADER } from "@nylorun/core/compatibility";
4
4
  import { SessionManifestViewSchema, SessionUsageTotalsSchema, ModelCallsPageSchema, ToolCallsPageSchema, TurnTraceSchema, parseSessionEvent, parseSubjectHeaders, } from "@nylorun/core/contracts";
5
5
  import { SessionsReadClient } from "./reads.js";
6
6
  import { AccessClient } from "./access.js";
7
- import { EnvironmentsClient } from "./environments.js";
7
+ import { AgentInstancesClient } from "./agents.js";
8
+ import { AgentManifestsClient } from "./agent-manifests.js";
8
9
  import { ArtifactsClient } from "./artifacts.js";
9
10
  import { FilesClient } from "./files.js";
10
- import { Transport, env, id, segment } from "./http.js";
11
+ import { Transport, id, segment } from "./http.js";
11
12
  import { observeSSE } from "./sse.js";
12
13
  function sessionSandboxOf(transport, sessionId) {
13
14
  const call = (tool, args) => transport.json(`/v1/sessions/${segment(sessionId)}/sandbox/${segment(tool)}`, "POST", args);
@@ -30,33 +31,6 @@ function linkedSessionId(event) {
30
31
  ? sessionId
31
32
  : undefined;
32
33
  }
33
- /** The agent's declarations, then those of each agent it uses as a tool. */
34
- function declarationsOf(agent) {
35
- if (isBuiltWorkflow(agent) || agent.manifest.kind === "workflow")
36
- return [];
37
- const built = agent.build?.() ?? agent;
38
- if (isBuiltWorkflow(built))
39
- return [];
40
- const binding = built.getBinding?.();
41
- if (!binding || !("parts" in binding))
42
- return [];
43
- const found = [...(binding.parts ?? [])];
44
- for (const tool of binding.tools ?? []) {
45
- const delegate = delegateOf(tool);
46
- found.push(...(delegate?.agent?.getBinding().parts ?? []));
47
- // A flow agent used as a tool: its agents' declarations.
48
- for (const leaf of Object.values(delegate?.workflow?.getBinding().agents ?? {}))
49
- found.push(...(leaf.parts ?? []));
50
- }
51
- return found;
52
- }
53
- /** The bytes of every skill file the agent's definition names, by `sha256:<hex>`. */
54
- function skillFilesOf(agent, into = new Map()) {
55
- for (const item of declarationsOf(agent))
56
- for (const [sha256, source] of Object.entries(item.skillFiles ?? {}))
57
- into.set(sha256, source);
58
- return into;
59
- }
60
34
  export class AgentsClient {
61
35
  transport;
62
36
  /** The subject this client acts for (`as`), or `undefined` for the principal itself. */
@@ -92,12 +66,19 @@ export class AgentsClient {
92
66
  return new AccessClient(this.transport);
93
67
  }
94
68
  /**
95
- * Environments (protocol 11): `put` one by id (create, find or change), write its `secrets`,
96
- * `list` them by label, `stop`, `reset` or `delete` one, or give a session its own with
97
- * `forSession`.
69
+ * Agent manifests (protocol 16): `save` a manifest's next version (a v8 document, what
70
+ * `composeManifest` read, or a built agent with its runtime section), `plan` a save, read
71
+ * their versions.
98
72
  */
99
- get environments() {
100
- return new EnvironmentsClient(this.transport, (options) => this.createSession(options));
73
+ get agentManifests() {
74
+ return new AgentManifestsClient(this.transport);
75
+ }
76
+ /**
77
+ * Agents (protocol 16): `put` one by id from a saved manifest (create or find), write its
78
+ * `secrets`, `list` them, `stop`, `reset`, `fork` or `delete` one. Sessions run on them.
79
+ */
80
+ get agents() {
81
+ return new AgentInstancesClient(this.transport);
101
82
  }
102
83
  /** File artifacts: upload, list, download with Range, capability links (protocol 6). */
103
84
  get artifacts() {
@@ -114,54 +95,19 @@ export class AgentsClient {
114
95
  get sessions() {
115
96
  return new SessionsReadClient(this.transport);
116
97
  }
117
- listAgents(options = {}) {
118
- return this.transport.json("/v1/agents", "GET", undefined, options.signal);
119
- }
120
98
  listSessions(options = {}) {
121
99
  const query = options.agentId
122
100
  ? `?agentId=${encodeURIComponent(options.agentId)}`
123
101
  : "";
124
102
  return this.transport.json(`/v1/sessions${query}`, "GET", undefined, options.signal);
125
103
  }
126
- /**
127
- * Registers the agent's definition (`PUT /v1/agents/{id}`), first uploading the skill files
128
- * it names that the Runtime does not hold. A definition with a tool that runs your code
129
- * (`tool({ run })`, a flow's tool stage) is refused before anything is sent: the Runtime runs
130
- * agents from their manifests alone. `implementationVersion` defaults to
131
- * `NYLORUN_IMPLEMENTATION_VERSION`, else `dev`. `dryRun` (protocol 14) runs every check and
132
- * saves nothing; the skill files are still uploaded, since they are stored by content.
133
- */
134
- async saveAgent(agent, options = {}) {
135
- const files = new Map();
136
- if (isBuiltWorkflow(agent)) {
137
- // A flow agent embeds its agents: one document, carrying their files.
138
- for (const binding of Object.values(agent.getBinding().agents)) {
139
- const leaf = { id: binding.manifest.id, manifest: binding.manifest, getBinding: () => binding };
140
- skillFilesOf(leaf, files);
141
- }
142
- }
143
- else {
144
- skillFilesOf(agent, files);
145
- }
146
- const refusal = codeToolRefusal(agent.manifest) ??
147
- approvalRefusal(agent.manifest);
148
- if (refusal)
149
- throw new Error(refusal);
150
- await this.files.ensure(files);
151
- return this.transport.json(`/v1/agents/${segment(agent.id)}${options.dryRun ? "?dryRun=true" : ""}`, "PUT", {
152
- requestId: options.requestId ?? id(),
153
- manifest: agent.manifest,
154
- implementationVersion: options.implementationVersion ?? env("NYLORUN_IMPLEMENTATION_VERSION") ?? "dev",
155
- });
156
- }
157
104
  async createSession(options) {
158
105
  const sessionId = options.id ?? id();
159
106
  await this.transport.json(`/v1/sessions/${segment(sessionId)}`, "PUT", {
160
107
  requestId: options.requestId ?? id(),
161
- agentId: options.agentId,
108
+ agent: options.agent,
162
109
  ownerUserId: options.ownerUserId,
163
110
  ...(options.info ? { info: options.info } : {}),
164
- ...(options.environment === undefined ? {} : { environment: options.environment }),
165
111
  });
166
112
  return this.session(sessionId);
167
113
  }
@@ -189,6 +135,7 @@ export class SessionClient {
189
135
  const view = await this.inspect(signal);
190
136
  return view.waits ?? [];
191
137
  }
138
+ /** A message answers `queued` when it waits for the running turn (protocol 17). */
192
139
  command(command, signal) {
193
140
  return this.transport.json(`${this.path}/commands`, "POST", command, signal);
194
141
  }
@@ -201,6 +148,7 @@ export class SessionClient {
201
148
  type: "message",
202
149
  requestId: options.requestId ?? id(),
203
150
  idempotencyKey: options.idempotencyKey,
151
+ ...(options.delivery ? { delivery: options.delivery } : {}),
204
152
  };
205
153
  return this.command(typeof value === "string"
206
154
  ? { ...base, content: value }
@@ -217,6 +165,7 @@ export class SessionClient {
217
165
  requestId: options.requestId ?? id(),
218
166
  idempotencyKey: options.idempotencyKey,
219
167
  parts: [...parts],
168
+ ...(options.delivery ? { delivery: options.delivery } : {}),
220
169
  }, options.signal);
221
170
  }
222
171
  approve(interactionId, approved, options) {
@@ -385,4 +334,5 @@ export class SessionClient {
385
334
  }
386
335
  export { RuntimeError, IncompatibleRuntimeError } from "./http.js";
387
336
  export { AccessClient } from "./access.js";
388
- export { EnvironmentManifestsClient, EnvironmentSecretsClient, EnvironmentsClient, environmentFiles, environmentManifest, } from "./environments.js";
337
+ export { AgentInstancesClient, AgentMemoriesClient, AgentSecretsClient, runtimeFiles } from "./agents.js";
338
+ export { AgentManifestsClient, ManifestGapsError, agentManifest, requirementGaps } from "./agent-manifests.js";
@@ -1,2 +1,2 @@
1
- export { loadSkillsFromDirectory, resolveSkillsRoot, parseSkill, SkillsError, } from "./load.js";
1
+ export { hashFolder, loadSkillsFromDirectory, resolveSkillsRoot, parseSkill, SkillsError, } from "./load.js";
2
2
  export type { LoadedSkill, SkillDiagnostic } from "./load.js";
@@ -1 +1 @@
1
- export { loadSkillsFromDirectory, resolveSkillsRoot, parseSkill, SkillsError, } from "./load.js";
1
+ export { hashFolder, loadSkillsFromDirectory, resolveSkillsRoot, parseSkill, SkillsError, } from "./load.js";
@@ -37,3 +37,13 @@ export declare function parseSkill(text: string, directoryName: string): {
37
37
  description: string;
38
38
  instructions: string;
39
39
  } | undefined;
40
+ /**
41
+ * Every file of `directory` (a runtime section's `files` entry with `from`), hashed as a skill's
42
+ * folder is: each by its `/`-separated path, with where to read its bytes. Version control, OS
43
+ * and `.env` files are left out; a symbolic link outside `boundary` (default the folder) is
44
+ * skipped with a diagnostic.
45
+ */
46
+ export declare function hashFolder(directory: string, diagnostics: SkillDiagnostic[], options?: {
47
+ readonly boundary?: string;
48
+ readonly codePrefix?: string;
49
+ }): Pick<LoadedSkill, "files" | "sources">;