@nylorun/agents 0.7.0-beta → 0.9.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.
@@ -1,2 +1,2 @@
1
- export { mcp, McpError } from "./mcp.js";
2
- export type { McpCapability, McpOptions } from "./mcp.js";
1
+ export { mcp, McpError, normalizeMcpServers } from "@nylorun/core/define";
2
+ export type { McpCapability, McpOptions, McpServerSpec } from "@nylorun/core/define";
package/dist/mcp/index.js CHANGED
@@ -1 +1 @@
1
- export { mcp, McpError } from "./mcp.js";
1
+ export { mcp, McpError, normalizeMcpServers } from "@nylorun/core/define";
@@ -1,4 +1,4 @@
1
- export { sandbox, SandboxError } from "./sandbox.js";
2
- export type { SandboxCapability, SandboxCapabilityOptions, SandboxOptions, } from "./sandbox.js";
1
+ export { sandbox, SandboxError } from "@nylorun/core/define";
2
+ export type { SandboxCapability, SandboxCapabilityOptions, SandboxOptions, } from "@nylorun/core/define";
3
3
  export { createActionSandbox, definitionDeclaresSandbox, isActionSandboxTool, } from "./client.js";
4
4
  export type { ActionSandbox, ActionSandboxToolResult, CreateActionSandboxOptions, } from "./client.js";
@@ -1,2 +1,2 @@
1
- export { sandbox, SandboxError } from "./sandbox.js";
1
+ export { sandbox, SandboxError } from "@nylorun/core/define";
2
2
  export { createActionSandbox, definitionDeclaresSandbox, isActionSandboxTool, } from "./client.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/agents",
3
- "version": "0.7.0-beta",
3
+ "version": "0.9.0-beta",
4
4
  "description": "Nylorun agent definitions, session client and connected executor",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -27,6 +27,10 @@
27
27
  "./executor": {
28
28
  "types": "./dist/executor.d.ts",
29
29
  "import": "./dist/executor.js"
30
+ },
31
+ "./ag-ui": {
32
+ "types": "./dist/ag-ui/index.d.ts",
33
+ "import": "./dist/ag-ui/index.js"
30
34
  }
31
35
  },
32
36
  "scripts": {
@@ -35,7 +39,8 @@
35
39
  "test": "vitest run --passWithNoTests"
36
40
  },
37
41
  "dependencies": {
38
- "@nylorun/core": "0.6.0-beta",
42
+ "@ag-ui/core": "~1.0.0",
43
+ "@nylorun/core": "0.8.0-beta",
39
44
  "gray-matter": "^4.0.3"
40
45
  },
41
46
  "peerDependencies": {
@@ -51,7 +56,7 @@
51
56
  },
52
57
  "repository": {
53
58
  "type": "git",
54
- "url": "git+https://github.com/nylorun/harness.git",
59
+ "url": "git+https://github.com/nylorun/agents.git",
55
60
  "directory": "agents"
56
61
  },
57
62
  "publishConfig": {
package/dist/mcp/mcp.d.ts DELETED
@@ -1,30 +0,0 @@
1
- import type { CapabilityDeclaration, McpServerManifest } from "@nylorun/core/define";
2
- export interface McpOptions {
3
- /** Capability id. Defaults to `"mcp"`. */
4
- readonly id?: string;
5
- }
6
- export interface McpCapability extends CapabilityDeclaration {
7
- readonly mcpServers: Readonly<Record<string, McpServerManifest>>;
8
- }
9
- export declare class McpError extends Error {
10
- readonly code: string;
11
- constructor(code: string, message: string);
12
- }
13
- /**
14
- * Declare MCP servers as one capability for `Agent.use`.
15
- *
16
- * The map shape matches agent-plugins `mcpServers` and manifest v3: each key
17
- * must equal that server's `name`. Supported transports are `stdio`,
18
- * `streamable-http`, and `sse` (see https://agent-plugins.org/plugin-authors/mcp-servers).
19
- *
20
- * ```ts
21
- * Agent({...}).use(mcp({
22
- * github: {
23
- * name: "github",
24
- * type: "streamable-http",
25
- * url: "https://mcp.example.com/github",
26
- * },
27
- * }))
28
- * ```
29
- */
30
- export declare function mcp(servers: Readonly<Record<string, McpServerManifest>>, options?: McpOptions): McpCapability;
package/dist/mcp/mcp.js DELETED
@@ -1,80 +0,0 @@
1
- export class McpError extends Error {
2
- code;
3
- constructor(code, message) {
4
- super(message);
5
- this.name = "McpError";
6
- this.code = code;
7
- }
8
- }
9
- /**
10
- * Declare MCP servers as one capability for `Agent.use`.
11
- *
12
- * The map shape matches agent-plugins `mcpServers` and manifest v3: each key
13
- * must equal that server's `name`. Supported transports are `stdio`,
14
- * `streamable-http`, and `sse` (see https://agent-plugins.org/plugin-authors/mcp-servers).
15
- *
16
- * ```ts
17
- * Agent({...}).use(mcp({
18
- * github: {
19
- * name: "github",
20
- * type: "streamable-http",
21
- * url: "https://mcp.example.com/github",
22
- * },
23
- * }))
24
- * ```
25
- */
26
- export function mcp(servers, options = {}) {
27
- const id = options.id ?? "mcp";
28
- if (!isRecord(servers)) {
29
- throw new McpError("mcp.invalid", "mcp() expects a non-empty map of MCP servers");
30
- }
31
- const entries = Object.entries(servers);
32
- if (entries.length === 0) {
33
- throw new McpError("mcp.empty", "mcp() requires at least one MCP server");
34
- }
35
- const mcpServers = {};
36
- for (const [key, server] of entries) {
37
- if (!isMcpServer(server)) {
38
- throw new McpError("mcp.invalid-server", `MCP server '${key}' is not a valid stdio, streamable-http, or sse declaration`);
39
- }
40
- if (server.name !== key) {
41
- throw new McpError("mcp.name-mismatch", `MCP server key '${key}' must equal the server name '${server.name}'`);
42
- }
43
- mcpServers[key] = freezeServer(server);
44
- }
45
- return { id, mcpServers: Object.freeze(mcpServers) };
46
- }
47
- function freezeServer(server) {
48
- if (server.type === "stdio") {
49
- return Object.freeze({
50
- name: server.name,
51
- type: "stdio",
52
- command: server.command,
53
- ...(server.args === undefined ? {} : { args: Object.freeze([...server.args]) }),
54
- ...(server.env === undefined
55
- ? {}
56
- : { env: Object.freeze({ ...server.env }) }),
57
- ...(server.cwd === undefined ? {} : { cwd: server.cwd }),
58
- });
59
- }
60
- return Object.freeze({
61
- name: server.name,
62
- type: server.type,
63
- url: server.url,
64
- ...(server.headers === undefined
65
- ? {}
66
- : { headers: Object.freeze({ ...server.headers }) }),
67
- });
68
- }
69
- function isMcpServer(value) {
70
- if (!isRecord(value) || typeof value.name !== "string" || !value.name)
71
- return false;
72
- if (value.type === "stdio")
73
- return typeof value.command === "string" && value.command.length > 0;
74
- if (value.type === "streamable-http" || value.type === "sse")
75
- return typeof value.url === "string" && value.url.length > 0;
76
- return false;
77
- }
78
- function isRecord(value) {
79
- return !!value && typeof value === "object" && !Array.isArray(value);
80
- }
@@ -1,27 +0,0 @@
1
- import type { CapabilityDeclaration, SandboxManifest, ToolDefinition } from "@nylorun/core/define";
2
- /** What computer the agent needs. The Runtime decides where it runs. */
3
- export type SandboxOptions = SandboxManifest;
4
- export interface SandboxCapabilityOptions {
5
- /** Capability id. Defaults to `"sandbox"`. */
6
- readonly id?: string;
7
- }
8
- export interface SandboxCapability extends CapabilityDeclaration {
9
- readonly sandbox: SandboxManifest;
10
- readonly tools: readonly ToolDefinition[];
11
- }
12
- export declare class SandboxError extends Error {
13
- readonly code: string;
14
- constructor(code: string, message: string);
15
- }
16
- /**
17
- * Give the agent an isolated Linux machine with a persistent `/workspace`.
18
- *
19
- * Adds the built-in `bash`, `read`, `write`, `edit`, `grep` and `glob` tools. They run in the
20
- * Nylorun Runtime, which picks the backend. Agent code declares requirements only.
21
- *
22
- * ```ts
23
- * Agent({ id: "analyst", instructions: "..." }).use(sandbox())
24
- * Agent({ ... }).use(sandbox({ image: "node:24", network: { allow: ["api.github.com"] } }))
25
- * ```
26
- */
27
- export declare function sandbox(options?: SandboxOptions, capability?: SandboxCapabilityOptions): SandboxCapability;
@@ -1,92 +0,0 @@
1
- import { SANDBOX_DEFERRED_FIELDS, SANDBOX_FIELDS, SANDBOX_INSTRUCTIONS, SANDBOX_NETWORK_PRESETS, createSandboxTools, isSandboxHostPattern, parseSandboxDuration, parseSandboxSize, } from "@nylorun/core/define";
2
- export class SandboxError extends Error {
3
- code;
4
- constructor(code, message) {
5
- super(message);
6
- this.name = "SandboxError";
7
- this.code = code;
8
- }
9
- }
10
- /**
11
- * Give the agent an isolated Linux machine with a persistent `/workspace`.
12
- *
13
- * Adds the built-in `bash`, `read`, `write`, `edit`, `grep` and `glob` tools. They run in the
14
- * Nylorun Runtime, which picks the backend. Agent code declares requirements only.
15
- *
16
- * ```ts
17
- * Agent({ id: "analyst", instructions: "..." }).use(sandbox())
18
- * Agent({ ... }).use(sandbox({ image: "node:24", network: { allow: ["api.github.com"] } }))
19
- * ```
20
- */
21
- export function sandbox(options = {}, capability = {}) {
22
- const id = capability.id ?? "sandbox";
23
- if (!isRecord(options))
24
- throw new SandboxError("sandbox.invalid", "sandbox() expects an options object");
25
- for (const key of Object.keys(options)) {
26
- if (SANDBOX_DEFERRED_FIELDS.includes(key))
27
- throw new SandboxError("sandbox.unsupported", `sandbox({ ${key} }) is not supported in this version. ` +
28
- `Supported options: ${SANDBOX_FIELDS.join(", ")}. See docs/design/sandboxes.md for what is planned.`);
29
- if (!SANDBOX_FIELDS.includes(key))
30
- throw new SandboxError("sandbox.unknown-option", `Unknown sandbox option '${key}'. Supported options: ${SANDBOX_FIELDS.join(", ")}`);
31
- }
32
- return Object.freeze({
33
- id,
34
- instructions: Object.freeze([SANDBOX_INSTRUCTIONS]),
35
- tools: createSandboxTools(),
36
- sandbox: freezeOptions(options),
37
- });
38
- }
39
- function freezeOptions(options) {
40
- const result = {};
41
- if (options.image !== undefined) {
42
- if (typeof options.image !== "string" || options.image.trim().length === 0)
43
- throw new SandboxError("sandbox.invalid-image", "sandbox({ image }) must be a non-empty OCI image reference");
44
- result.image = options.image;
45
- }
46
- if (options.network !== undefined) {
47
- if (!isRecord(options.network))
48
- throw new SandboxError("sandbox.invalid-network", "sandbox({ network }) must be an object");
49
- for (const key of Object.keys(options.network))
50
- if (key !== "preset" && key !== "allow")
51
- throw new SandboxError("sandbox.invalid-network", `Unknown network option '${key}'. Use preset and allow.`);
52
- const { preset, allow } = options.network;
53
- if (preset !== undefined && !SANDBOX_NETWORK_PRESETS.includes(preset))
54
- throw new SandboxError("sandbox.invalid-network", `network.preset must be one of ${SANDBOX_NETWORK_PRESETS.join(", ")}`);
55
- if (allow !== undefined) {
56
- if (!Array.isArray(allow))
57
- throw new SandboxError("sandbox.invalid-network", "network.allow must be an array of host names");
58
- for (const host of allow)
59
- if (typeof host !== "string" || !isSandboxHostPattern(host))
60
- throw new SandboxError("sandbox.invalid-network", `network.allow entry '${String(host)}' must be a host name such as api.github.com or *.example.com (no scheme, port or path)`);
61
- }
62
- result.network = Object.freeze({
63
- ...(preset === undefined ? {} : { preset: preset }),
64
- ...(allow === undefined ? {} : { allow: Object.freeze([...allow]) }),
65
- });
66
- }
67
- if (options.resources !== undefined) {
68
- if (!isRecord(options.resources))
69
- throw new SandboxError("sandbox.invalid-resources", "sandbox({ resources }) must be an object");
70
- for (const key of Object.keys(options.resources))
71
- if (key !== "cpus" && key !== "memory")
72
- throw new SandboxError("sandbox.invalid-resources", `resources.${key} is not supported in this version. Use cpus and memory.`);
73
- const { cpus, memory } = options.resources;
74
- if (cpus !== undefined && (!Number.isInteger(cpus) || cpus < 1 || cpus > 64))
75
- throw new SandboxError("sandbox.invalid-resources", "resources.cpus must be an integer from 1 to 64");
76
- if (memory !== undefined && (typeof memory !== "string" || parseSandboxSize(memory) === undefined))
77
- throw new SandboxError("sandbox.invalid-resources", "resources.memory must be a size such as 512MiB or 2GiB");
78
- result.resources = Object.freeze({
79
- ...(cpus === undefined ? {} : { cpus }),
80
- ...(memory === undefined ? {} : { memory }),
81
- });
82
- }
83
- if (options.idle !== undefined) {
84
- if (typeof options.idle !== "string" || parseSandboxDuration(options.idle) === undefined)
85
- throw new SandboxError("sandbox.invalid-idle", "sandbox({ idle }) must be a duration such as 30s, 15m or 1h");
86
- result.idle = options.idle;
87
- }
88
- return Object.freeze(result);
89
- }
90
- function isRecord(value) {
91
- return !!value && typeof value === "object" && !Array.isArray(value);
92
- }