@nylorun/core 0.16.0-beta → 0.18.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 +72 -0
- package/README.md +10 -0
- package/dist/compatibility.d.ts +18 -11
- package/dist/compatibility.js +18 -11
- package/dist/contracts.d.ts +176 -50
- package/dist/contracts.js +289 -85
- package/dist/define.d.ts +6 -5
- package/dist/define.js +3 -2
- package/dist/definition/assemble.d.ts +3 -1
- package/dist/definition/assemble.js +3 -0
- package/dist/definition/code-tools.d.ts +4 -4
- package/dist/definition/code-tools.js +3 -2
- package/dist/definition/from.d.ts +5 -0
- package/dist/definition/from.js +31 -188
- package/dist/definition/manifest.d.ts +3 -1
- package/dist/definition/manifest.js +4 -1
- package/dist/definition/mcp.d.ts +45 -1
- package/dist/definition/mcp.js +85 -2
- package/dist/definition/removed.d.ts +8 -3
- package/dist/definition/removed.js +13 -4
- package/dist/definition/sandbox-capability.d.ts +21 -4
- package/dist/definition/sandbox-capability.js +56 -19
- package/dist/definition/tools-capability.d.ts +37 -0
- package/dist/definition/tools-capability.js +98 -0
- package/dist/definition/variant.d.ts +2 -1
- package/dist/definition/variant.js +40 -4
- package/dist/harness-api/messages.d.ts +30 -352
- package/dist/harness-api/messages.js +2 -6
- package/dist/harness-api/schema.d.ts +701 -13
- package/dist/harness-api/schema.js +129 -53
- package/dist/harness-api/transcript.d.ts +8 -6
- package/dist/harness-api/transcript.js +4 -5
- package/dist/project.d.ts +67 -0
- package/dist/project.js +210 -0
- package/dist/transport.d.ts +52 -0
- package/dist/transport.js +73 -0
- package/dist/types/manifest.d.ts +42 -14
- package/dist/types/tool.d.ts +22 -0
- package/package.json +9 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every Runtime client does on the wire (`@nylorun/core/transport`): the headers of an
|
|
3
|
+
* authenticated request, reading a response body, and the `/health` compatibility probe. It
|
|
4
|
+
* imports nothing from Node, so browser clients use it too. `@nylorun/agents` (the Runtime
|
|
5
|
+
* API), `@nylorun/admin` (the Management API) and Studio's server build on it.
|
|
6
|
+
*/
|
|
7
|
+
import { type Compatibility, type ProtocolRange } from "./compatibility.js";
|
|
8
|
+
export type Incompatibility = Extract<Compatibility, {
|
|
9
|
+
ok: false;
|
|
10
|
+
}>;
|
|
11
|
+
/** A protocol range (`{ min, max, features }`); undefined when `value` is not one. */
|
|
12
|
+
export declare function parseProtocolRange(value: unknown): ProtocolRange | undefined;
|
|
13
|
+
/** The `protocol` a `/health` or `426` body advertises; undefined when it has none. */
|
|
14
|
+
export declare function advertisedProtocol(body: unknown): ProtocolRange | undefined;
|
|
15
|
+
/** Whether a Host advertising `host` serves this client's protocol and required features. */
|
|
16
|
+
export declare function clientCompatibility(host: ProtocolRange): Compatibility;
|
|
17
|
+
/** Why a Host does not serve this client, starting lowercase. */
|
|
18
|
+
export declare function describeIncompatibility(result: Incompatibility): string;
|
|
19
|
+
/** The headers of an authenticated request: this client's protocol and the bearer, when given. */
|
|
20
|
+
export declare function requestHeaders(bearer?: string): Record<string, string>;
|
|
21
|
+
/** A response body's text as JSON, or the text itself when it is not JSON. */
|
|
22
|
+
export declare function parseBody(text: string): unknown;
|
|
23
|
+
/** Reads `response`'s body: JSON, else its text. */
|
|
24
|
+
export declare function readBody(response: Response): Promise<unknown>;
|
|
25
|
+
/** What the Host's `/health` says about this client. */
|
|
26
|
+
export type HealthCheck =
|
|
27
|
+
/** `/health` answered an error status; `body` is what it sent. */
|
|
28
|
+
{
|
|
29
|
+
result: "failed";
|
|
30
|
+
status: number;
|
|
31
|
+
body: unknown;
|
|
32
|
+
}
|
|
33
|
+
/** `/health` advertised no protocol range: a Host older than protocol ranges. */
|
|
34
|
+
| {
|
|
35
|
+
result: "unadvertised";
|
|
36
|
+
body: unknown;
|
|
37
|
+
} | {
|
|
38
|
+
result: "incompatible";
|
|
39
|
+
protocol: ProtocolRange;
|
|
40
|
+
compatibility: Incompatibility;
|
|
41
|
+
} | {
|
|
42
|
+
result: "compatible";
|
|
43
|
+
protocol: ProtocolRange;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* `GET <url>/health` (no credential, no redirects) and whether the Host serves this client. A
|
|
47
|
+
* network failure rejects.
|
|
48
|
+
*/
|
|
49
|
+
export declare function checkHealth(url: string, options?: {
|
|
50
|
+
fetch?: typeof fetch;
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
}): Promise<HealthCheck>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every Runtime client does on the wire (`@nylorun/core/transport`): the headers of an
|
|
3
|
+
* authenticated request, reading a response body, and the `/health` compatibility probe. It
|
|
4
|
+
* imports nothing from Node, so browser clients use it too. `@nylorun/agents` (the Runtime
|
|
5
|
+
* API), `@nylorun/admin` (the Management API) and Studio's server build on it.
|
|
6
|
+
*/
|
|
7
|
+
import { PROTOCOL_FEATURES, PROTOCOL_HEADER, PROTOCOL_VERSION, checkCompatibility, } from "./compatibility.js";
|
|
8
|
+
import { ProtocolRangeSchema } from "./contracts.js";
|
|
9
|
+
// A newer Host may add fields to its range: they are ignored, not refused.
|
|
10
|
+
const ProtocolRangeReader = ProtocolRangeSchema.strip();
|
|
11
|
+
/** A protocol range (`{ min, max, features }`); undefined when `value` is not one. */
|
|
12
|
+
export function parseProtocolRange(value) {
|
|
13
|
+
const parsed = ProtocolRangeReader.safeParse(value);
|
|
14
|
+
return parsed.success ? parsed.data : undefined;
|
|
15
|
+
}
|
|
16
|
+
/** The `protocol` a `/health` or `426` body advertises; undefined when it has none. */
|
|
17
|
+
export function advertisedProtocol(body) {
|
|
18
|
+
return body && typeof body === "object" && !Array.isArray(body)
|
|
19
|
+
? parseProtocolRange(body.protocol)
|
|
20
|
+
: undefined;
|
|
21
|
+
}
|
|
22
|
+
/** Whether a Host advertising `host` serves this client's protocol and required features. */
|
|
23
|
+
export function clientCompatibility(host) {
|
|
24
|
+
return checkCompatibility({ version: PROTOCOL_VERSION, required: [...PROTOCOL_FEATURES] }, host);
|
|
25
|
+
}
|
|
26
|
+
/** Why a Host does not serve this client, starting lowercase. */
|
|
27
|
+
export function describeIncompatibility(result) {
|
|
28
|
+
return result.reason === "version"
|
|
29
|
+
? `client protocol ${result.client} is outside Host range ${result.host.min}–${result.host.max}`
|
|
30
|
+
: `Host is missing required features: ${result.missing.join(", ")}`;
|
|
31
|
+
}
|
|
32
|
+
/** The headers of an authenticated request: this client's protocol and the bearer, when given. */
|
|
33
|
+
export function requestHeaders(bearer) {
|
|
34
|
+
return {
|
|
35
|
+
[PROTOCOL_HEADER]: String(PROTOCOL_VERSION),
|
|
36
|
+
...(bearer ? { authorization: `Bearer ${bearer}` } : {}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** A response body's text as JSON, or the text itself when it is not JSON. */
|
|
40
|
+
export function parseBody(text) {
|
|
41
|
+
try {
|
|
42
|
+
return JSON.parse(text);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return text;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Reads `response`'s body: JSON, else its text. */
|
|
49
|
+
export async function readBody(response) {
|
|
50
|
+
return parseBody(await response.text());
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `GET <url>/health` (no credential, no redirects) and whether the Host serves this client. A
|
|
54
|
+
* network failure rejects.
|
|
55
|
+
*/
|
|
56
|
+
export async function checkHealth(url, options = {}) {
|
|
57
|
+
const fetcher = options.fetch ?? globalThis.fetch;
|
|
58
|
+
const response = await fetcher(`${url}/health`, {
|
|
59
|
+
method: "GET",
|
|
60
|
+
redirect: "error",
|
|
61
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
62
|
+
});
|
|
63
|
+
const body = await readBody(response);
|
|
64
|
+
if (!response.ok)
|
|
65
|
+
return { result: "failed", status: response.status, body };
|
|
66
|
+
const protocol = advertisedProtocol(body);
|
|
67
|
+
if (!protocol)
|
|
68
|
+
return { result: "unadvertised", body };
|
|
69
|
+
const compatibility = clientCompatibility(protocol);
|
|
70
|
+
return compatibility.ok
|
|
71
|
+
? { result: "compatible", protocol }
|
|
72
|
+
: { result: "incompatible", protocol, compatibility };
|
|
73
|
+
}
|
package/dist/types/manifest.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { JsonObject } from "./shared.js";
|
|
2
2
|
import type { WorkflowManifest } from "./workflow.js";
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Published manifest schema version (no top-level model — Runtime-owned). Version 6 (R2b C9) adds
|
|
5
|
+
* an MCP server's `tools` and `deferred`; a manifest that uses neither stays version 5, so its
|
|
6
|
+
* hash is unchanged, and the Runtime accepts both.
|
|
7
|
+
*/
|
|
8
|
+
export type ManifestSchemaVersion = 5 | 6;
|
|
5
9
|
/** Whether each call waits for a person's approval (`approve` on the session). Default `never`. */
|
|
6
10
|
export type ApprovalMode = "never" | "always";
|
|
7
11
|
/** The methods an HTTP tool may use: each sends the tool input as a JSON body. */
|
|
@@ -17,8 +21,10 @@ export interface HttpToolTarget {
|
|
|
17
21
|
readonly method?: HttpToolMethod;
|
|
18
22
|
/**
|
|
19
23
|
* Adds a vault credential to each request, as for a remote MCP server: a credential in the
|
|
20
|
-
* session's vaults bound to `url
|
|
21
|
-
*
|
|
24
|
+
* session's vaults bound to `url` (a `bearer` token or a `headers` map, sent to its `via` when
|
|
25
|
+
* it has one, with its identity header), chosen by the session's credential selection with
|
|
26
|
+
* this name (`credentialSelections[].serverName`) when several are. When the vaults hold none,
|
|
27
|
+
* the call fails with `http.credential` and is not sent.
|
|
22
28
|
*/
|
|
23
29
|
readonly credential?: string;
|
|
24
30
|
/** How long the service may take to answer. Default 60000, at most 300000. */
|
|
@@ -50,22 +56,43 @@ export interface SkillManifest {
|
|
|
50
56
|
*/
|
|
51
57
|
readonly files: Readonly<Record<string, string>>;
|
|
52
58
|
}
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* One tool's settings on an MCP server (manifest v6, R2b C9). Each setting resolves from the
|
|
61
|
+
* tool's own entry, then the `"*"` entry, then the server, then the default.
|
|
62
|
+
*/
|
|
63
|
+
export interface McpToolSettings {
|
|
64
|
+
/** `false`: the tool never reaches the model and cannot be called. Default `true`. */
|
|
65
|
+
readonly enabled?: boolean;
|
|
66
|
+
/** `always`: each call waits for approval. Default: the server's `approval`, else `never`. */
|
|
60
67
|
readonly approval?: ApprovalMode;
|
|
61
|
-
|
|
68
|
+
/**
|
|
69
|
+
* `true`: the tool leaves the model's tool list; the model finds it with `tool_search` and runs
|
|
70
|
+
* it with `tool_call` (R2b C10). Default: the server's `deferred`, else deferred when the
|
|
71
|
+
* agent's MCP tools would take more than a tenth of the model's context window.
|
|
72
|
+
*/
|
|
73
|
+
readonly deferred?: boolean;
|
|
74
|
+
}
|
|
75
|
+
interface McpServerFields {
|
|
62
76
|
readonly name: string;
|
|
63
|
-
readonly type: "sse";
|
|
64
77
|
readonly url: string;
|
|
65
78
|
readonly headers?: Readonly<Record<string, string>>;
|
|
66
79
|
/** Each call of every tool of the server waits for approval. */
|
|
67
80
|
readonly approval?: ApprovalMode;
|
|
68
|
-
|
|
81
|
+
/** Defers every tool of the server, or none (manifest v6, R2b C10). Default: automatic. */
|
|
82
|
+
readonly deferred?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Settings per tool (manifest v6, R2b C9), keyed by the server's own tool name (before C6
|
|
85
|
+
* renaming), with `"*"` for every tool without an entry: `{"*": {enabled: false}}` and an
|
|
86
|
+
* entry per wanted tool make an allowlist.
|
|
87
|
+
*/
|
|
88
|
+
readonly tools?: Readonly<Record<string, McpToolSettings>>;
|
|
89
|
+
}
|
|
90
|
+
/** A remote MCP server, declared by URL. Nylorun accepts no stdio servers (`stdioMcpRefusal`). */
|
|
91
|
+
export type McpServerManifest = (McpServerFields & {
|
|
92
|
+
readonly type: "streamable-http";
|
|
93
|
+
}) | (McpServerFields & {
|
|
94
|
+
readonly type: "sse";
|
|
95
|
+
});
|
|
69
96
|
/** Network egress preset for a sandbox. Private ranges and metadata endpoints are always blocked. */
|
|
70
97
|
export type SandboxNetworkPreset = "none" | "dev" | "open";
|
|
71
98
|
/**
|
|
@@ -115,3 +142,4 @@ export interface AgentManifest {
|
|
|
115
142
|
readonly capabilities: readonly CapabilityManifest[];
|
|
116
143
|
readonly runtime?: RuntimeManifest;
|
|
117
144
|
}
|
|
145
|
+
export {};
|
package/dist/types/tool.d.ts
CHANGED
|
@@ -153,9 +153,25 @@ export type ToolExecutionContext<Info = unknown> = ToolExecutionContextBase & {
|
|
|
153
153
|
readonly info?: Info;
|
|
154
154
|
};
|
|
155
155
|
export type ToolContent = JsonValue;
|
|
156
|
+
/**
|
|
157
|
+
* A file the model sees beside a tool's output (R2b C11): an image a tool returned, which the
|
|
158
|
+
* Runtime stored as an artifact. `reference` is the host's, as a message's media part carries it:
|
|
159
|
+
* the model call resolves it, and a model that reads no images gets a note instead.
|
|
160
|
+
*/
|
|
161
|
+
export type ToolResultFile = {
|
|
162
|
+
readonly mediaType: string;
|
|
163
|
+
readonly reference: JsonValue;
|
|
164
|
+
};
|
|
156
165
|
export type ToolOutcome<Output = ToolContent> = {
|
|
157
166
|
readonly kind: "completed";
|
|
158
167
|
readonly output: Output;
|
|
168
|
+
/** Files the model sees beside the output (R2b C11). */
|
|
169
|
+
readonly files?: readonly ToolResultFile[];
|
|
170
|
+
/**
|
|
171
|
+
* The output is the Runtime's preview of a larger result it stored as an artifact (R2b
|
|
172
|
+
* C11), not the tool's own, so the tool's output schema is not checked against it.
|
|
173
|
+
*/
|
|
174
|
+
readonly truncated?: boolean;
|
|
159
175
|
} | {
|
|
160
176
|
readonly kind: "denied";
|
|
161
177
|
readonly reason: string;
|
|
@@ -163,6 +179,8 @@ export type ToolOutcome<Output = ToolContent> = {
|
|
|
163
179
|
readonly kind: "failed";
|
|
164
180
|
readonly code: string;
|
|
165
181
|
readonly message: string;
|
|
182
|
+
/** True when calling again may work (an MCP server that could not be reached). */
|
|
183
|
+
readonly retryable?: boolean;
|
|
166
184
|
} | {
|
|
167
185
|
readonly kind: "interaction-required";
|
|
168
186
|
readonly interaction: Interaction;
|
|
@@ -177,6 +195,8 @@ export type ToolResult = {
|
|
|
177
195
|
readonly toolName: string;
|
|
178
196
|
readonly kind: "completed";
|
|
179
197
|
readonly output: ToolContent;
|
|
198
|
+
/** The outcome's `files`, when it has any. */
|
|
199
|
+
readonly files?: readonly ToolResultFile[];
|
|
180
200
|
} | {
|
|
181
201
|
readonly callId: string;
|
|
182
202
|
readonly toolName: string;
|
|
@@ -189,6 +209,8 @@ export type ToolResult = {
|
|
|
189
209
|
readonly code: string;
|
|
190
210
|
readonly message: string;
|
|
191
211
|
readonly details?: ToolValidationFailureDetails;
|
|
212
|
+
/** The outcome's `retryable`, when it says. */
|
|
213
|
+
readonly retryable?: boolean;
|
|
192
214
|
};
|
|
193
215
|
/** Immutable tool metadata supplied to model adapters and observers. */
|
|
194
216
|
export interface ToolDescriptor {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0-beta",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Shared agent definitions and wire contracts",
|
|
@@ -54,6 +54,14 @@
|
|
|
54
54
|
"types": "./dist/compatibility.d.ts",
|
|
55
55
|
"import": "./dist/compatibility.js"
|
|
56
56
|
},
|
|
57
|
+
"./transport": {
|
|
58
|
+
"types": "./dist/transport.d.ts",
|
|
59
|
+
"import": "./dist/transport.js"
|
|
60
|
+
},
|
|
61
|
+
"./project": {
|
|
62
|
+
"types": "./dist/project.d.ts",
|
|
63
|
+
"import": "./dist/project.js"
|
|
64
|
+
},
|
|
57
65
|
"./harness-api": {
|
|
58
66
|
"types": "./dist/harness-api/index.d.ts",
|
|
59
67
|
"import": "./dist/harness-api/index.js"
|