@nylorun/core 0.20.0-beta → 0.22.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 +98 -0
- package/README.md +2 -2
- package/dist/compatibility.d.ts +88 -13
- package/dist/compatibility.js +88 -13
- package/dist/contracts.d.ts +1328 -110
- package/dist/contracts.js +563 -163
- package/dist/define.d.ts +15 -13
- package/dist/define.js +11 -8
- package/dist/definition/approval.js +12 -14
- package/dist/definition/assemble.d.ts +6 -10
- package/dist/definition/assemble.js +48 -105
- package/dist/definition/bind-agent.d.ts +3 -4
- package/dist/definition/bind-agent.js +12 -30
- package/dist/definition/binding.d.ts +2 -2
- package/dist/definition/bound.d.ts +10 -10
- package/dist/definition/builder.d.ts +16 -20
- package/dist/definition/builder.js +29 -81
- package/dist/definition/code-tools.d.ts +3 -3
- package/dist/definition/code-tools.js +6 -21
- package/dist/definition/declaration.d.ts +4 -7
- package/dist/definition/declaration.js +29 -99
- package/dist/definition/{tools-capability.d.ts → deferred-tools.d.ts} +3 -13
- package/dist/definition/{tools-capability.js → deferred-tools.js} +2 -18
- package/dist/definition/delegate.d.ts +2 -4
- package/dist/definition/delegate.js +8 -10
- package/dist/definition/from.d.ts +7 -4
- package/dist/definition/from.js +72 -117
- package/dist/definition/helpers.d.ts +0 -7
- package/dist/definition/helpers.js +0 -5
- package/dist/definition/http-tool.d.ts +49 -5
- package/dist/definition/http-tool.js +167 -5
- package/dist/definition/implementations.d.ts +6 -8
- package/dist/definition/manifest.d.ts +11 -5
- package/dist/definition/manifest.js +26 -26
- package/dist/definition/mcp.d.ts +1 -52
- package/dist/definition/mcp.js +0 -52
- package/dist/definition/media-reference.d.ts +23 -0
- package/dist/definition/media-reference.js +26 -0
- package/dist/definition/removed.d.ts +3 -10
- package/dist/definition/removed.js +10 -17
- package/dist/definition/runtime-manifest.d.ts +30 -0
- package/dist/definition/runtime-manifest.js +132 -0
- package/dist/definition/sandbox-tools.d.ts +1 -1
- package/dist/definition/sandbox-tools.js +1 -1
- package/dist/definition/skill-tools.d.ts +13 -7
- package/dist/definition/skill-tools.js +23 -10
- package/dist/definition/trace.d.ts +18 -0
- package/dist/definition/trace.js +42 -0
- package/dist/definition/variant.d.ts +5 -4
- package/dist/definition/variant.js +18 -51
- package/dist/definition/workflow/runnable.js +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/harness-api/entries.d.ts +1 -0
- package/dist/harness-api/entries.js +1 -0
- package/dist/harness-api/gates.d.ts +1 -6
- package/dist/harness-api/gates.js +1 -3
- package/dist/harness-api/harness-api.schema.json +11 -92
- package/dist/harness-api/index.d.ts +2 -2
- package/dist/harness-api/index.js +2 -2
- package/dist/harness-api/mcp.d.ts +0 -4
- package/dist/harness-api/mcp.js +0 -2
- package/dist/harness-api/messages.d.ts +1 -3
- package/dist/harness-api/messages.js +1 -3
- package/dist/harness-api/schema.d.ts +5 -17
- package/dist/harness-api/schema.js +9 -6
- package/dist/index.d.ts +1 -1
- package/dist/manifest-schemas.d.ts +6 -0
- package/dist/manifest-schemas.js +46 -0
- package/dist/schemas/agent-manifest.schema.json +905 -0
- package/dist/schemas/environment-manifest.schema.json +349 -0
- package/dist/types/agent.d.ts +1 -1
- package/dist/types/manifest.d.ts +47 -24
- package/dist/types/model.d.ts +2 -2
- package/dist/types/observe.d.ts +5 -18
- package/dist/types/part.d.ts +25 -0
- package/dist/types/tool.d.ts +1 -1
- package/dist/types/transcript.d.ts +5 -0
- package/dist/utils/definition-files.d.ts +11 -6
- package/dist/utils/definition-files.js +19 -9
- package/dist/utils/runtime-tools.d.ts +19 -0
- package/dist/utils/runtime-tools.js +30 -0
- package/dist/utils/sandbox.d.ts +1 -1
- package/dist/utils/sandbox.js +1 -1
- package/package.json +9 -3
- package/dist/definition/capability.d.ts +0 -43
- package/dist/definition/capability.js +0 -82
- package/dist/definition/sandbox-capability.d.ts +0 -44
- package/dist/definition/sandbox-capability.js +0 -139
- package/dist/types/middleware.d.ts +0 -94
- /package/dist/types/{middleware.js → part.js} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Stores a sandbox file, or inline text, as a file artifact of the session (F8.1). */
|
|
2
|
+
export declare const SAVE_ARTIFACT_TOOL = "save_artifact";
|
|
3
|
+
/** Reads an artifact of the session in pages (R2b C11). */
|
|
4
|
+
export declare const READ_ARTIFACT_TOOL = "read_artifact";
|
|
5
|
+
/** Loads a skill's `SKILL.md`. */
|
|
6
|
+
export declare const LOAD_SKILL_TOOL = "load_skill";
|
|
7
|
+
/** Reads one resource file of a skill. */
|
|
8
|
+
export declare const READ_SKILL_RESOURCE_TOOL = "read_skill_resource";
|
|
9
|
+
/** Finds deferred tools by a query (BM25 over their names and descriptions). */
|
|
10
|
+
export declare const TOOL_SEARCH_TOOL = "tool_search";
|
|
11
|
+
/** Runs a deferred tool by name, as a call of that tool. */
|
|
12
|
+
export declare const TOOL_CALL_TOOL = "tool_call";
|
|
13
|
+
/**
|
|
14
|
+
* The tools the Runtime serves: the sandbox tools, the artifact tools, the skill tools and the
|
|
15
|
+
* deferred-tool pair. An agent's own tool may not take one of these names, so a tool's name alone
|
|
16
|
+
* says whose it is.
|
|
17
|
+
*/
|
|
18
|
+
export declare const RUNTIME_TOOL_NAMES: ReadonlySet<string>;
|
|
19
|
+
export declare function isRuntimeToolName(name: string): boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SANDBOX_TOOL_NAMES } from "./sandbox.js";
|
|
2
|
+
/** Stores a sandbox file, or inline text, as a file artifact of the session (F8.1). */
|
|
3
|
+
export const SAVE_ARTIFACT_TOOL = "save_artifact";
|
|
4
|
+
/** Reads an artifact of the session in pages (R2b C11). */
|
|
5
|
+
export const READ_ARTIFACT_TOOL = "read_artifact";
|
|
6
|
+
/** Loads a skill's `SKILL.md`. */
|
|
7
|
+
export const LOAD_SKILL_TOOL = "load_skill";
|
|
8
|
+
/** Reads one resource file of a skill. */
|
|
9
|
+
export const READ_SKILL_RESOURCE_TOOL = "read_skill_resource";
|
|
10
|
+
/** Finds deferred tools by a query (BM25 over their names and descriptions). */
|
|
11
|
+
export const TOOL_SEARCH_TOOL = "tool_search";
|
|
12
|
+
/** Runs a deferred tool by name, as a call of that tool. */
|
|
13
|
+
export const TOOL_CALL_TOOL = "tool_call";
|
|
14
|
+
/**
|
|
15
|
+
* The tools the Runtime serves: the sandbox tools, the artifact tools, the skill tools and the
|
|
16
|
+
* deferred-tool pair. An agent's own tool may not take one of these names, so a tool's name alone
|
|
17
|
+
* says whose it is.
|
|
18
|
+
*/
|
|
19
|
+
export const RUNTIME_TOOL_NAMES = new Set([
|
|
20
|
+
...SANDBOX_TOOL_NAMES,
|
|
21
|
+
SAVE_ARTIFACT_TOOL,
|
|
22
|
+
READ_ARTIFACT_TOOL,
|
|
23
|
+
LOAD_SKILL_TOOL,
|
|
24
|
+
READ_SKILL_RESOURCE_TOOL,
|
|
25
|
+
TOOL_SEARCH_TOOL,
|
|
26
|
+
TOOL_CALL_TOOL,
|
|
27
|
+
]);
|
|
28
|
+
export function isRuntimeToolName(name) {
|
|
29
|
+
return RUNTIME_TOOL_NAMES.has(name);
|
|
30
|
+
}
|
package/dist/utils/sandbox.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Portable sandbox constants and parsers shared by the SDK, wire schema and Runtime. */
|
|
2
|
-
/**
|
|
2
|
+
/** The sandbox tools the Runtime adds to a session with a sandbox, and runs. */
|
|
3
3
|
export declare const SANDBOX_TOOL_NAMES: readonly ["bash", "read", "write", "edit", "grep", "glob"];
|
|
4
4
|
export type SandboxToolName = (typeof SANDBOX_TOOL_NAMES)[number];
|
|
5
5
|
export declare const SANDBOX_WORKSPACE = "/workspace";
|
package/dist/utils/sandbox.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Portable sandbox constants and parsers shared by the SDK, wire schema and Runtime. */
|
|
2
|
-
/**
|
|
2
|
+
/** The sandbox tools the Runtime adds to a session with a sandbox, and runs. */
|
|
3
3
|
export const SANDBOX_TOOL_NAMES = Object.freeze([
|
|
4
4
|
"bash",
|
|
5
5
|
"read",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0-beta",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Shared agent definitions and wire contracts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"node": "^22.14.0 || ^24.0.0 || >=26.0.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "npm run clean && node ../scripts/check-typescript-version.mjs && tsc -p tsconfig.json && node scripts/harness-api-schema.mjs",
|
|
26
|
+
"build": "npm run clean && node ../scripts/check-typescript-version.mjs && tsc -p tsconfig.json && node scripts/harness-api-schema.mjs && node scripts/manifest-schemas.mjs",
|
|
27
27
|
"clean": "node -e \"import('node:fs').then(({rmSync})=>rmSync('dist',{recursive:true,force:true}))\"",
|
|
28
28
|
"check": "npm run build && npm test && node scripts/check-package.mjs",
|
|
29
29
|
"test": "vitest run --passWithNoTests",
|
|
@@ -66,7 +66,13 @@
|
|
|
66
66
|
"types": "./dist/harness-api/index.d.ts",
|
|
67
67
|
"import": "./dist/harness-api/index.js"
|
|
68
68
|
},
|
|
69
|
-
"./harness-api/schema.json": "./dist/harness-api/harness-api.schema.json"
|
|
69
|
+
"./harness-api/schema.json": "./dist/harness-api/harness-api.schema.json",
|
|
70
|
+
"./manifest-schemas": {
|
|
71
|
+
"types": "./dist/manifest-schemas.d.ts",
|
|
72
|
+
"import": "./dist/manifest-schemas.js"
|
|
73
|
+
},
|
|
74
|
+
"./schemas/agent-manifest.json": "./dist/schemas/agent-manifest.schema.json",
|
|
75
|
+
"./schemas/environment-manifest.json": "./dist/schemas/environment-manifest.schema.json"
|
|
70
76
|
},
|
|
71
77
|
"peerDependencies": {
|
|
72
78
|
"zod": "^4.6.5"
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { StepMiddleware, CapabilityDeclaration } from "../types/middleware.js";
|
|
2
|
-
import type { ToolDefinition } from "../types/tool.js";
|
|
3
|
-
import type { AgentTool } from "../types/agent.js";
|
|
4
|
-
import type { ModelDirective } from "../types/model.js";
|
|
5
|
-
export interface CapabilityIdentity {
|
|
6
|
-
readonly id: string;
|
|
7
|
-
readonly name?: string;
|
|
8
|
-
readonly description?: string;
|
|
9
|
-
}
|
|
10
|
-
/** The options form of `capability()`. Deprecated: use the builder methods. */
|
|
11
|
-
export interface CapabilityOptions<Info = unknown> extends CapabilityIdentity {
|
|
12
|
-
readonly tools?: readonly (ToolDefinition<any, Info, any> | AgentTool)[];
|
|
13
|
-
readonly instructions?: string | readonly string[];
|
|
14
|
-
/** @deprecated Runs in the local engine only. */
|
|
15
|
-
readonly middleware?: StepMiddleware<Info>;
|
|
16
|
-
/** @deprecated Model resolution is Runtime-owned; not projected into the manifest. */
|
|
17
|
-
readonly model?: ModelDirective;
|
|
18
|
-
}
|
|
19
|
-
type Parts<Info> = {
|
|
20
|
-
readonly instructions?: readonly string[];
|
|
21
|
-
readonly tools?: readonly (ToolDefinition<any, Info, any> | AgentTool)[];
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* A reusable bundle of instructions and tools, attached with `.capability()`.
|
|
25
|
-
* It has the same methods as a ReAct agent.
|
|
26
|
-
*/
|
|
27
|
-
export declare class CapabilityBuilder<Info = unknown> {
|
|
28
|
-
#private;
|
|
29
|
-
constructor(identity: CapabilityIdentity, parts?: Parts<Info>);
|
|
30
|
-
get id(): string;
|
|
31
|
-
instructions(...text: readonly string[]): CapabilityBuilder<Info>;
|
|
32
|
-
tools(...tools: readonly ToolDefinition<any, Info, any>[]): CapabilityBuilder<Info>;
|
|
33
|
-
subagents(...agents: readonly AgentTool[]): CapabilityBuilder<Info>;
|
|
34
|
-
/** @internal The declaration `.capability()` attaches. */
|
|
35
|
-
toDeclaration(): CapabilityDeclaration<Info>;
|
|
36
|
-
private with;
|
|
37
|
-
}
|
|
38
|
-
export declare function isCapabilityBuilder(value: unknown): value is CapabilityBuilder<any>;
|
|
39
|
-
/** Compose a reusable capability bundle: `capability({ id }).instructions(…).tools(…)`. */
|
|
40
|
-
export declare function capability<Info = unknown>(identity: CapabilityIdentity): CapabilityBuilder<Info>;
|
|
41
|
-
/** @deprecated Use `capability({ id }).instructions(…).tools(…)`. */
|
|
42
|
-
export declare function capability<Info = unknown>(declaration: CapabilityOptions<Info>): CapabilityDeclaration<Info>;
|
|
43
|
-
export {};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { HarnessError } from "../errors.js";
|
|
2
|
-
import { delegateTool, isAgentItem } from "./delegate.js";
|
|
3
|
-
import { deprecate } from "../utils/deprecate.js";
|
|
4
|
-
const CAPABILITY = Symbol.for("nylorun.capability");
|
|
5
|
-
/**
|
|
6
|
-
* A reusable bundle of instructions and tools, attached with `.capability()`.
|
|
7
|
-
* It has the same methods as a ReAct agent.
|
|
8
|
-
*/
|
|
9
|
-
export class CapabilityBuilder {
|
|
10
|
-
#identity;
|
|
11
|
-
#parts;
|
|
12
|
-
constructor(identity, parts = {}) {
|
|
13
|
-
if (!identity || typeof identity.id !== "string" || identity.id.length === 0)
|
|
14
|
-
throw new HarnessError("configuration.invalid", "capability() requires a non-empty id");
|
|
15
|
-
this.#identity = Object.freeze({ ...identity });
|
|
16
|
-
this.#parts = Object.freeze({ ...parts });
|
|
17
|
-
Object.defineProperty(this, CAPABILITY, { value: true });
|
|
18
|
-
}
|
|
19
|
-
get id() {
|
|
20
|
-
return this.#identity.id;
|
|
21
|
-
}
|
|
22
|
-
instructions(...text) {
|
|
23
|
-
return this.with({ instructions: [...(this.#parts.instructions ?? []), ...text] });
|
|
24
|
-
}
|
|
25
|
-
tools(...tools) {
|
|
26
|
-
return this.with({ tools: [...(this.#parts.tools ?? []), ...tools] });
|
|
27
|
-
}
|
|
28
|
-
subagents(...agents) {
|
|
29
|
-
for (const agent of agents)
|
|
30
|
-
if (!isAgentItem(agent))
|
|
31
|
-
throw new HarnessError("configuration.invalid", ".subagents() takes agents; tools belong in .tools()");
|
|
32
|
-
return this.with({ tools: [...(this.#parts.tools ?? []), ...agents] });
|
|
33
|
-
}
|
|
34
|
-
/** @internal The declaration `.capability()` attaches. */
|
|
35
|
-
toDeclaration() {
|
|
36
|
-
return declarationOf({ ...this.#identity, ...this.#parts });
|
|
37
|
-
}
|
|
38
|
-
with(parts) {
|
|
39
|
-
return new CapabilityBuilder(this.#identity, { ...this.#parts, ...parts });
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export function isCapabilityBuilder(value) {
|
|
43
|
-
return !!value && typeof value === "object" && value[CAPABILITY] === true;
|
|
44
|
-
}
|
|
45
|
-
const LEGACY_FIELDS = ["tools", "instructions", "middleware", "model"];
|
|
46
|
-
export function capability(declaration) {
|
|
47
|
-
const legacy = LEGACY_FIELDS.some((key) => declaration[key] !== undefined);
|
|
48
|
-
if (!legacy)
|
|
49
|
-
return new CapabilityBuilder({
|
|
50
|
-
id: declaration.id,
|
|
51
|
-
...(declaration.name === undefined ? {} : { name: declaration.name }),
|
|
52
|
-
...(declaration.description === undefined ? {} : { description: declaration.description }),
|
|
53
|
-
});
|
|
54
|
-
deprecate("NYLORUN_DEP_CAPABILITY_OPTIONS", "capability({ tools, instructions }) is deprecated. Use capability({ id }).instructions(…).tools(…).");
|
|
55
|
-
return declarationOf(declaration);
|
|
56
|
-
}
|
|
57
|
-
function declarationOf(declaration) {
|
|
58
|
-
const instructions = declaration.instructions === undefined
|
|
59
|
-
? undefined
|
|
60
|
-
: typeof declaration.instructions === "string"
|
|
61
|
-
? [declaration.instructions]
|
|
62
|
-
: declaration.instructions;
|
|
63
|
-
return {
|
|
64
|
-
id: declaration.id,
|
|
65
|
-
...(declaration.name === undefined ? {} : { name: declaration.name }),
|
|
66
|
-
...(declaration.description === undefined
|
|
67
|
-
? {}
|
|
68
|
-
: { description: declaration.description }),
|
|
69
|
-
...(declaration.tools === undefined
|
|
70
|
-
? {}
|
|
71
|
-
: {
|
|
72
|
-
tools: declaration.tools.map((item) => isAgentItem(item)
|
|
73
|
-
? delegateTool(item)
|
|
74
|
-
: item),
|
|
75
|
-
}),
|
|
76
|
-
...(instructions === undefined ? {} : { instructions }),
|
|
77
|
-
...(declaration.middleware === undefined
|
|
78
|
-
? {}
|
|
79
|
-
: { middleware: declaration.middleware }),
|
|
80
|
-
...(declaration.model === undefined ? {} : { model: declaration.model }),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { CapabilityManifest, SandboxManifest } from "../types/manifest.js";
|
|
2
|
-
/** Id of the capability the Runtime adds to a session whose sandbox was chosen at open. */
|
|
3
|
-
export declare const SANDBOX_CAPABILITY_ID = "nylorun.sandbox";
|
|
4
|
-
/**
|
|
5
|
-
* Id of the capability that gives our engine `save_artifact` (protocol 6): the Runtime adds it
|
|
6
|
-
* beside the sandbox capability, so `nylorun.artifacts/save_artifact` is the built-in tool
|
|
7
|
-
* `nylorun.save_artifact`.
|
|
8
|
-
*/
|
|
9
|
-
export declare const ARTIFACTS_CAPABILITY_ID = "nylorun.artifacts";
|
|
10
|
-
export declare const SAVE_ARTIFACT_TOOL = "save_artifact";
|
|
11
|
-
/**
|
|
12
|
-
* The tool that reads an artifact of the session in pages (R2b C11, Q24): how the model reads a
|
|
13
|
-
* tool result the Runtime stored because it was too large to show. With or without a sandbox.
|
|
14
|
-
*/
|
|
15
|
-
export declare const READ_ARTIFACT_TOOL = "read_artifact";
|
|
16
|
-
/** The most `read_artifact` returns per call (R2b C11): 32 KiB, the inline cap of a tool result. */
|
|
17
|
-
export declare const READ_ARTIFACT_MAX_BYTES: number;
|
|
18
|
-
/** What the `nylorun.artifacts` capability gives a session. */
|
|
19
|
-
export interface ArtifactsCapabilityOptions {
|
|
20
|
-
/** `save_artifact`, which comes with a sandbox. Default true. */
|
|
21
|
-
readonly save?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* `read_artifact` (R2b C11), for an agent whose MCP or HTTP tool results the Runtime may store
|
|
24
|
-
* as artifacts. Default false.
|
|
25
|
-
*/
|
|
26
|
-
readonly read?: boolean;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* The capability manifest that gives a session `save_artifact`, which stores a sandbox file, or
|
|
30
|
-
* inline text, as a file artifact of the session, and `read_artifact`, which reads one in pages.
|
|
31
|
-
* Its schemas are part of the hashed manifest; change them deliberately.
|
|
32
|
-
*/
|
|
33
|
-
export declare function artifactsCapabilityManifest(options?: ArtifactsCapabilityOptions): CapabilityManifest;
|
|
34
|
-
/**
|
|
35
|
-
* The capability manifest that gives a session its sandbox: the six built-in tools, the sandbox
|
|
36
|
-
* instructions and the resolved spec. The Runtime adds it to a session's pinned manifest. Its
|
|
37
|
-
* tools are projected the way the builder projects any tool.
|
|
38
|
-
*/
|
|
39
|
-
export declare function sandboxCapabilityManifest(spec: SandboxManifest, options?: {
|
|
40
|
-
/** The workspace path the backend uses, named in the tools' text. Default `/workspace`. */
|
|
41
|
-
readonly workspace?: string;
|
|
42
|
-
/** The agent's skills, whose files the sandbox holds under `/skills/<name>/`. */
|
|
43
|
-
readonly skills?: readonly string[];
|
|
44
|
-
}): CapabilityManifest;
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { SANDBOX_INSTRUCTIONS, createSandboxTools } from "./sandbox-tools.js";
|
|
3
|
-
import { tool } from "./helpers.js";
|
|
4
|
-
import { ToolError } from "./tool-error.js";
|
|
5
|
-
import { SANDBOX_WORKSPACE } from "../utils/sandbox.js";
|
|
6
|
-
import { SKILLS_MOUNT } from "../utils/definition-files.js";
|
|
7
|
-
import { normalizedSchemasFor } from "./schema.js";
|
|
8
|
-
import { copyJsonObject } from "../utils/immutable.js";
|
|
9
|
-
/** Id of the capability the Runtime adds to a session whose sandbox was chosen at open. */
|
|
10
|
-
export const SANDBOX_CAPABILITY_ID = "nylorun.sandbox";
|
|
11
|
-
/**
|
|
12
|
-
* Id of the capability that gives our engine `save_artifact` (protocol 6): the Runtime adds it
|
|
13
|
-
* beside the sandbox capability, so `nylorun.artifacts/save_artifact` is the built-in tool
|
|
14
|
-
* `nylorun.save_artifact`.
|
|
15
|
-
*/
|
|
16
|
-
export const ARTIFACTS_CAPABILITY_ID = "nylorun.artifacts";
|
|
17
|
-
export const SAVE_ARTIFACT_TOOL = "save_artifact";
|
|
18
|
-
/**
|
|
19
|
-
* The tool that reads an artifact of the session in pages (R2b C11, Q24): how the model reads a
|
|
20
|
-
* tool result the Runtime stored because it was too large to show. With or without a sandbox.
|
|
21
|
-
*/
|
|
22
|
-
export const READ_ARTIFACT_TOOL = "read_artifact";
|
|
23
|
-
/** The most `read_artifact` returns per call (R2b C11): 32 KiB, the inline cap of a tool result. */
|
|
24
|
-
export const READ_ARTIFACT_MAX_BYTES = 32 * 1024;
|
|
25
|
-
const ARTIFACTS_INSTRUCTIONS = "Use save_artifact to hand the user a file you made: a path in the sandbox, or text you pass as content. " +
|
|
26
|
-
"The user sees it as an artifact of this session and can download it; reply with its name, not its bytes. " +
|
|
27
|
-
"Files you write under /workspace/outputs reach the user too: when your turn ends, they become the session's outputs folder.";
|
|
28
|
-
const READ_ARTIFACT_INSTRUCTIONS = "A tool result too large to show is saved as an artifact of this session: the result says truncated: true, with its artifactId, its size in bytes and a preview of its start and end. " +
|
|
29
|
-
"Images and other files a tool returns are saved as artifacts too. Use read_artifact to read more of one, a page at a time, only when the preview is not enough.";
|
|
30
|
-
async function artifactsRuntimeOnly() {
|
|
31
|
-
throw new ToolError("artifacts.runtime-only", "The artifact tools run in the Nylorun Runtime. Connect the agent to a Runtime to use them.");
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* The capability manifest that gives a session `save_artifact`, which stores a sandbox file, or
|
|
35
|
-
* inline text, as a file artifact of the session, and `read_artifact`, which reads one in pages.
|
|
36
|
-
* Its schemas are part of the hashed manifest; change them deliberately.
|
|
37
|
-
*/
|
|
38
|
-
export function artifactsCapabilityManifest(options = {}) {
|
|
39
|
-
const save = options.save ?? true;
|
|
40
|
-
const read = options.read ?? false;
|
|
41
|
-
const tools = [...(save ? [saveArtifactTool()] : []), ...(read ? [readArtifactTool()] : [])];
|
|
42
|
-
return {
|
|
43
|
-
id: ARTIFACTS_CAPABILITY_ID,
|
|
44
|
-
type: "agent",
|
|
45
|
-
instructions: [
|
|
46
|
-
...(save ? [ARTIFACTS_INSTRUCTIONS] : []),
|
|
47
|
-
...(read ? [READ_ARTIFACT_INSTRUCTIONS] : []),
|
|
48
|
-
],
|
|
49
|
-
tools: tools.map((item) => {
|
|
50
|
-
const schemas = normalizedSchemasFor(item);
|
|
51
|
-
return {
|
|
52
|
-
name: item.name,
|
|
53
|
-
...(item.description === undefined ? {} : { description: item.description }),
|
|
54
|
-
inputSchema: schemas.inputSchema.jsonSchema,
|
|
55
|
-
};
|
|
56
|
-
}),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function readArtifactTool() {
|
|
60
|
-
return tool({
|
|
61
|
-
name: READ_ARTIFACT_TOOL,
|
|
62
|
-
description: `Read a text artifact of this session, such as a tool result marked truncated: up to ${READ_ARTIFACT_MAX_BYTES} bytes from offset. ` +
|
|
63
|
-
"Returns content, and nextOffset while more remains: pass it as offset to read on. An image is shown to you when you can see images.",
|
|
64
|
-
inputSchema: z.object({
|
|
65
|
-
artifactId: z.string().min(1).describe("The artifact to read, e.g. a truncated result's artifactId."),
|
|
66
|
-
offset: z.number().int().min(0).optional().describe("The byte to start at. Default 0."),
|
|
67
|
-
length: z
|
|
68
|
-
.number()
|
|
69
|
-
.int()
|
|
70
|
-
.min(1)
|
|
71
|
-
.max(READ_ARTIFACT_MAX_BYTES)
|
|
72
|
-
.optional()
|
|
73
|
-
.describe(`How many bytes to read. Default and most: ${READ_ARTIFACT_MAX_BYTES}.`),
|
|
74
|
-
}),
|
|
75
|
-
effects: "read",
|
|
76
|
-
execute: artifactsRuntimeOnly,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
function saveArtifactTool() {
|
|
80
|
-
return tool({
|
|
81
|
-
name: SAVE_ARTIFACT_TOOL,
|
|
82
|
-
description: `Save a file as an artifact of this session, for the user to download. Give path (a file in the sandbox; relative paths resolve under ${SANDBOX_WORKSPACE}) or content (text), not both. ` +
|
|
83
|
-
"Returns the artifact's id and version. Pass artifactId to save a new version of an artifact you saved before.",
|
|
84
|
-
inputSchema: z.object({
|
|
85
|
-
path: z.string().min(1).optional().describe("A file in the sandbox."),
|
|
86
|
-
content: z.string().optional().describe("Text to save instead of a file."),
|
|
87
|
-
name: z
|
|
88
|
-
.string()
|
|
89
|
-
.min(1)
|
|
90
|
-
.max(255)
|
|
91
|
-
.optional()
|
|
92
|
-
.describe("The artifact's name. Default: the file's name."),
|
|
93
|
-
contentType: z
|
|
94
|
-
.string()
|
|
95
|
-
.min(1)
|
|
96
|
-
.optional()
|
|
97
|
-
.describe("The media type, e.g. image/png. Default: from the name's extension."),
|
|
98
|
-
artifactId: z.string().min(1).optional().describe("Save a new version of this artifact."),
|
|
99
|
-
}),
|
|
100
|
-
effects: "write",
|
|
101
|
-
execute: artifactsRuntimeOnly,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* The capability manifest that gives a session its sandbox: the six built-in tools, the sandbox
|
|
106
|
-
* instructions and the resolved spec. The Runtime adds it to a session's pinned manifest. Its
|
|
107
|
-
* tools are projected the way the builder projects any tool.
|
|
108
|
-
*/
|
|
109
|
-
export function sandboxCapabilityManifest(spec, options = {}) {
|
|
110
|
-
const workspace = options.workspace ?? SANDBOX_WORKSPACE;
|
|
111
|
-
const text = (value) => value.replaceAll(SANDBOX_WORKSPACE, workspace);
|
|
112
|
-
const tools = createSandboxTools().map((tool) => {
|
|
113
|
-
const schemas = normalizedSchemasFor(tool);
|
|
114
|
-
return {
|
|
115
|
-
name: tool.name,
|
|
116
|
-
...(tool.description === undefined ? {} : { description: text(tool.description) }),
|
|
117
|
-
inputSchema: schemas.inputSchema.jsonSchema,
|
|
118
|
-
...(schemas.outputSchema === undefined
|
|
119
|
-
? {}
|
|
120
|
-
: { outputSchema: schemas.outputSchema.jsonSchema }),
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
return {
|
|
124
|
-
id: SANDBOX_CAPABILITY_ID,
|
|
125
|
-
type: "agent",
|
|
126
|
-
instructions: [
|
|
127
|
-
text(SANDBOX_INSTRUCTIONS),
|
|
128
|
-
...(options.skills?.length
|
|
129
|
-
? [
|
|
130
|
-
`Each skill's files are in the sandbox, read-only, under ${SKILLS_MOUNT}/<name>/ (${options.skills
|
|
131
|
-
.map((name) => `${SKILLS_MOUNT}/${name}/`)
|
|
132
|
-
.join(", ")}): read them there and run their scripts with bash.`,
|
|
133
|
-
]
|
|
134
|
-
: []),
|
|
135
|
-
],
|
|
136
|
-
tools,
|
|
137
|
-
sandbox: copyJsonObject(spec, "sandbox"),
|
|
138
|
-
};
|
|
139
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { ContextMutationOptions, ModelCandidate, ModelDirective, ModelToolCall, ModelConfigurationMutationOptions } from "./model.js";
|
|
2
|
-
import type { InputEvent, TranscriptEntry } from "./transcript.js";
|
|
3
|
-
import type { AgentTool } from "./agent.js";
|
|
4
|
-
import type { McpServerManifest, SkillManifest } from "./manifest.js";
|
|
5
|
-
/**
|
|
6
|
-
* The bytes of one skill file the manifest names (`SkillManifest.files`), held on the developer
|
|
7
|
-
* binding: the client uploads the files the Runtime lacks before it registers the agent. Not a
|
|
8
|
-
* manifest field.
|
|
9
|
-
*/
|
|
10
|
-
export interface SkillFileSource {
|
|
11
|
-
readonly size: number;
|
|
12
|
-
read(): Promise<Uint8Array>;
|
|
13
|
-
}
|
|
14
|
-
import type { ContextItem, JsonObject, Tripwire } from "./shared.js";
|
|
15
|
-
import type { Interaction, ToolDefinition, ToolResult } from "./tool.js";
|
|
16
|
-
interface StepRequestBase {
|
|
17
|
-
/** Opaque identity of the execution that owns this Step. */
|
|
18
|
-
readonly executionId: string;
|
|
19
|
-
/** Opaque identity of the Turn that owns this Step. */
|
|
20
|
-
readonly turnId: string;
|
|
21
|
-
/** Opaque identity of this Model Step. */
|
|
22
|
-
readonly stepId: string;
|
|
23
|
-
readonly turnNumber: number;
|
|
24
|
-
readonly stepNumber: number;
|
|
25
|
-
readonly arrivals: readonly InputEvent[];
|
|
26
|
-
readonly toolResults: readonly ToolResult[];
|
|
27
|
-
readonly transcript: readonly TranscriptEntry[];
|
|
28
|
-
readonly context: {
|
|
29
|
-
set(slot: string, items: readonly ContextItem[], options?: ContextMutationOptions): void;
|
|
30
|
-
};
|
|
31
|
-
readonly configuration: {
|
|
32
|
-
readonly instructions: {
|
|
33
|
-
set(slot: string, items: readonly string[], options?: ModelConfigurationMutationOptions): void;
|
|
34
|
-
};
|
|
35
|
-
readonly tools: {
|
|
36
|
-
set(slot: string, tools: readonly ToolDefinition[], options?: ModelConfigurationMutationOptions): void;
|
|
37
|
-
};
|
|
38
|
-
readonly model: {
|
|
39
|
-
select(directive: ModelDirective, options?: Omit<ModelConfigurationMutationOptions, "order">): void;
|
|
40
|
-
replace(directive: ModelDirective, options?: Omit<ModelConfigurationMutationOptions, "order">): void;
|
|
41
|
-
clear(options?: Omit<ModelConfigurationMutationOptions, "order">): void;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
tripwire(error: Tripwire): StepResponse;
|
|
45
|
-
}
|
|
46
|
-
export type StepRequest<Info = unknown> = StepRequestBase & {
|
|
47
|
-
readonly info?: Info;
|
|
48
|
-
};
|
|
49
|
-
export interface StepResponse {
|
|
50
|
-
candidate(): Readonly<ModelCandidate> | undefined;
|
|
51
|
-
toolCalls(): readonly ModelToolCall[];
|
|
52
|
-
replace(candidate: ModelCandidate): void;
|
|
53
|
-
deny(callId: string, reason: string): void;
|
|
54
|
-
requireInteraction(callId: string, interaction: Interaction): void;
|
|
55
|
-
tripwire(error: Tripwire): StepResponse;
|
|
56
|
-
}
|
|
57
|
-
export type StepMiddleware<Info = unknown> = (request: StepRequest<Info>, next: () => Promise<StepResponse>) => Promise<StepResponse>;
|
|
58
|
-
export type CapabilityItems<Item> = readonly Item[] | Readonly<{
|
|
59
|
-
readonly slot: string;
|
|
60
|
-
readonly items: readonly Item[];
|
|
61
|
-
}>;
|
|
62
|
-
export interface CapabilityDeclaration<Info = unknown> {
|
|
63
|
-
readonly id: string;
|
|
64
|
-
readonly type?: "agent" | "agent-plugin";
|
|
65
|
-
readonly name?: string;
|
|
66
|
-
readonly description?: string;
|
|
67
|
-
readonly metadata?: JsonObject;
|
|
68
|
-
readonly tools?: CapabilityItems<ToolDefinition<any, Info, any>>;
|
|
69
|
-
readonly instructions?: CapabilityItems<string>;
|
|
70
|
-
readonly skills?: Readonly<Record<string, SkillManifest>>;
|
|
71
|
-
/** Each skill file's bytes, by `sha256:<hex>`, for the client to upload. Not projected into the manifest. */
|
|
72
|
-
readonly skillFiles?: Readonly<Record<string, SkillFileSource>>;
|
|
73
|
-
readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated Model resolution is Runtime-owned. Not projected into the harness manifest.
|
|
76
|
-
* Kept for local middleware composition through 1.0.
|
|
77
|
-
*/
|
|
78
|
-
readonly model?: ModelDirective;
|
|
79
|
-
/** @deprecated Runs in the local engine only. Kept through 1.0. */
|
|
80
|
-
readonly middleware?: StepMiddleware<Info>;
|
|
81
|
-
}
|
|
82
|
-
/** What `.use()` accepts: a capability whose `tools` may also hold agents used as tools. */
|
|
83
|
-
export type CapabilityInput<Info = unknown> = Omit<CapabilityDeclaration<Info>, "tools"> & {
|
|
84
|
-
readonly tools?: CapabilityItems<ToolDefinition<any, Info, any> | AgentTool>;
|
|
85
|
-
};
|
|
86
|
-
export interface MiddlewareContributions {
|
|
87
|
-
readonly instructions?: readonly string[];
|
|
88
|
-
readonly tools?: readonly {
|
|
89
|
-
readonly name: string;
|
|
90
|
-
readonly description?: string;
|
|
91
|
-
}[];
|
|
92
|
-
readonly model?: Pick<ModelDirective, "id" | "controls">;
|
|
93
|
-
}
|
|
94
|
-
export {};
|
|
File without changes
|