@nylorun/agents 0.13.0-beta → 0.16.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 +139 -0
- package/README.md +220 -235
- package/dist/access.d.ts +6 -97
- package/dist/access.js +1 -103
- package/dist/ag-ui/handler.d.ts +3 -6
- package/dist/ag-ui/handler.js +2 -2
- package/dist/artifacts.d.ts +1 -1
- package/dist/files.d.ts +31 -0
- package/dist/files.js +60 -0
- package/dist/http.d.ts +6 -13
- package/dist/http.js +4 -16
- package/dist/index.d.ts +8 -16
- package/dist/index.js +4 -7
- package/dist/plugins/load.d.ts +3 -2
- package/dist/plugins/load.js +40 -100
- package/dist/plugins/plugin.d.ts +6 -1
- package/dist/plugins/plugin.js +20 -7
- package/dist/reads.d.ts +17 -0
- package/dist/reads.js +17 -0
- package/dist/sandboxes.d.ts +29 -0
- package/dist/sandboxes.js +10 -1
- package/dist/session-client.d.ts +94 -112
- package/dist/session-client.js +80 -107
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/load.d.ts +14 -3
- package/dist/skills/load.js +50 -32
- package/dist/skills/skills.d.ts +6 -4
- package/dist/skills/skills.js +17 -10
- package/dist/sse.js +1 -1
- package/dist/studio-embed.d.ts +1 -1
- package/dist/studio-embed.js +1 -1
- package/package.json +3 -7
- package/dist/action-handler.d.ts +0 -63
- package/dist/action-handler.js +0 -279
- package/dist/browser.d.ts +0 -104
- package/dist/browser.js +0 -281
- package/dist/delivery-token.d.ts +0 -62
- package/dist/delivery-token.js +0 -159
- package/dist/execute-action.d.ts +0 -16
- package/dist/execute-action.js +0 -288
- package/dist/plugins/launch.d.ts +0 -17
- package/dist/plugins/launch.js +0 -71
- package/dist/sandbox/client.d.ts +0 -63
- package/dist/sandbox/client.js +0 -29
- package/dist/sandbox/index.d.ts +0 -2
- package/dist/sandbox/index.js +0 -1
- package/dist/served-definitions.d.ts +0 -20
- package/dist/served-definitions.js +0 -100
- package/dist/token-endpoint.d.ts +0 -23
- package/dist/token-endpoint.js +0 -30
package/dist/plugins/load.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { existsSync,
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { stdioMcpRefusal } from "@nylorun/core/define";
|
|
3
4
|
import { loadSkillsFromDirectory } from "../skills/load.js";
|
|
4
|
-
import { expandPluginPlaceholders } from "./launch.js";
|
|
5
5
|
export const PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
|
|
6
6
|
export const MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json";
|
|
7
7
|
const PLUGIN_FIELDS = new Set([
|
|
@@ -17,7 +17,6 @@ const PLUGIN_FIELDS = new Set([
|
|
|
17
17
|
"extensions",
|
|
18
18
|
]);
|
|
19
19
|
const AUTHOR_FIELDS = new Set(["name", "email", "url"]);
|
|
20
|
-
const RESERVED_ENV = new Set(["PLUGIN_ROOT", "PLUGIN_DATA"]);
|
|
21
20
|
export class PluginError extends Error {
|
|
22
21
|
code;
|
|
23
22
|
diagnostics;
|
|
@@ -76,7 +75,7 @@ export function loadPlugin(directory) {
|
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
77
|
const skills = loadSkills(root, diagnostics);
|
|
79
|
-
const mcpServers = loadMcp(root,
|
|
78
|
+
const mcpServers = loadMcp(root, diagnostics);
|
|
80
79
|
return {
|
|
81
80
|
root,
|
|
82
81
|
name: parsed.name,
|
|
@@ -132,7 +131,7 @@ function loadSkills(root, diagnostics) {
|
|
|
132
131
|
codePrefix: "plugin",
|
|
133
132
|
});
|
|
134
133
|
}
|
|
135
|
-
function loadMcp(root,
|
|
134
|
+
function loadMcp(root, diagnostics) {
|
|
136
135
|
const location = join(root, "mcp.json");
|
|
137
136
|
if (!existsSync(location))
|
|
138
137
|
return {};
|
|
@@ -186,101 +185,54 @@ function loadMcp(root, pluginName, diagnostics) {
|
|
|
186
185
|
});
|
|
187
186
|
return {};
|
|
188
187
|
}
|
|
189
|
-
const pluginData = join(dirname(root), ".nylorun", "plugin-data", pluginName);
|
|
190
188
|
const servers = {};
|
|
191
189
|
for (const [name, value] of Object.entries(parsed.mcpServers)) {
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
if (isRecord(value) && value.type === "stdio")
|
|
191
|
+
throw new PluginError("plugin.mcp-stdio", stdioMcpRefusal(name), diagnostics);
|
|
192
|
+
const server = validateServer(name, value);
|
|
193
|
+
if (typeof server === "string") {
|
|
194
194
|
diagnostics.push({
|
|
195
195
|
severity: "warning",
|
|
196
196
|
code: "plugin.mcp-server-skipped",
|
|
197
|
-
message: `Skipped invalid MCP server '${name}'`,
|
|
197
|
+
message: `Skipped invalid MCP server '${name}': ${server}`,
|
|
198
198
|
path: location,
|
|
199
199
|
});
|
|
200
200
|
continue;
|
|
201
201
|
}
|
|
202
|
-
if (server.type === "stdio")
|
|
203
|
-
mkdirSync(pluginData, { recursive: true });
|
|
204
202
|
servers[name] = server;
|
|
205
203
|
}
|
|
206
204
|
return servers;
|
|
207
205
|
}
|
|
208
|
-
|
|
206
|
+
/** The server, or why it is skipped. */
|
|
207
|
+
function validateServer(name, value) {
|
|
209
208
|
if (!isRecord(value) || typeof value.type !== "string")
|
|
210
|
-
return
|
|
211
|
-
if (value.type === "stdio")
|
|
212
|
-
return validateStdio(name, value, root, pluginData);
|
|
209
|
+
return "it has no type";
|
|
213
210
|
if (value.type === "streamable-http" || value.type === "sse")
|
|
214
211
|
return validateRemote(name, value);
|
|
215
|
-
return
|
|
216
|
-
}
|
|
217
|
-
function validateStdio(name, value, root, pluginData) {
|
|
218
|
-
const allowed = new Set(["type", "command", "args", "env", "cwd"]);
|
|
219
|
-
if (Object.keys(value).some((key) => !allowed.has(key)))
|
|
220
|
-
return undefined;
|
|
221
|
-
if (typeof value.command !== "string" || !isCommandToken(value.command))
|
|
222
|
-
return undefined;
|
|
223
|
-
if (value.command.startsWith("./") && !commandStaysInside(root, value.command))
|
|
224
|
-
return undefined;
|
|
225
|
-
let args;
|
|
226
|
-
if (value.args !== undefined) {
|
|
227
|
-
if (!Array.isArray(value.args) || value.args.some((item) => typeof item !== "string"))
|
|
228
|
-
return undefined;
|
|
229
|
-
args = value.args;
|
|
230
|
-
}
|
|
231
|
-
let env;
|
|
232
|
-
if (value.env !== undefined) {
|
|
233
|
-
if (!isRecord(value.env))
|
|
234
|
-
return undefined;
|
|
235
|
-
env = {};
|
|
236
|
-
for (const [key, item] of Object.entries(value.env)) {
|
|
237
|
-
if (typeof item !== "string" || RESERVED_ENV.has(key))
|
|
238
|
-
return undefined;
|
|
239
|
-
env[key] = item;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
let cwd;
|
|
243
|
-
if (value.cwd !== undefined) {
|
|
244
|
-
if (typeof value.cwd !== "string" || !isCwdForm(value.cwd))
|
|
245
|
-
return undefined;
|
|
246
|
-
const expanded = expandPluginPlaceholders(value.cwd, root, pluginData);
|
|
247
|
-
const absolute = expanded.startsWith("/") || /^[A-Za-z]:[\\/]/.test(expanded)
|
|
248
|
-
? expanded
|
|
249
|
-
: resolve(root, expanded);
|
|
250
|
-
const boundary = value.cwd === "${PLUGIN_DATA}" || value.cwd.startsWith("${PLUGIN_DATA}/")
|
|
251
|
-
? pluginData
|
|
252
|
-
: root;
|
|
253
|
-
if (!isInside(boundary, absolute))
|
|
254
|
-
return undefined;
|
|
255
|
-
cwd = value.cwd;
|
|
256
|
-
}
|
|
257
|
-
return {
|
|
258
|
-
name,
|
|
259
|
-
type: "stdio",
|
|
260
|
-
command: value.command,
|
|
261
|
-
...(args === undefined ? {} : { args }),
|
|
262
|
-
...(env === undefined ? {} : { env }),
|
|
263
|
-
...(cwd === undefined ? {} : { cwd }),
|
|
264
|
-
};
|
|
212
|
+
return `type '${value.type}' is not streamable-http or sse`;
|
|
265
213
|
}
|
|
266
214
|
function validateRemote(name, value) {
|
|
267
215
|
const allowed = new Set(["type", "url", "headers"]);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
216
|
+
const unknown = Object.keys(value).filter((key) => !allowed.has(key));
|
|
217
|
+
if (unknown.length > 0)
|
|
218
|
+
return `${value.type} servers take only type, url and headers, not ${unknown.join(", ")}`;
|
|
219
|
+
if (typeof value.url !== "string")
|
|
220
|
+
return "url must be a string";
|
|
221
|
+
const problem = remoteUrlProblem(value.url);
|
|
222
|
+
if (problem)
|
|
223
|
+
return problem;
|
|
272
224
|
let headers;
|
|
273
225
|
if (value.headers !== undefined) {
|
|
274
226
|
if (!isRecord(value.headers))
|
|
275
|
-
return
|
|
227
|
+
return "headers must be an object";
|
|
276
228
|
const seen = new Set();
|
|
277
229
|
headers = {};
|
|
278
230
|
for (const [key, item] of Object.entries(value.headers)) {
|
|
279
231
|
if (typeof item !== "string" || !isHeaderName(key) || /[\r\n\0]/.test(item))
|
|
280
|
-
return
|
|
232
|
+
return `header '${key}' is not a valid header`;
|
|
281
233
|
const folded = key.toLowerCase();
|
|
282
234
|
if (seen.has(folded))
|
|
283
|
-
return
|
|
235
|
+
return `header '${key}' is repeated`;
|
|
284
236
|
seen.add(folded);
|
|
285
237
|
headers[key] = item;
|
|
286
238
|
}
|
|
@@ -292,41 +244,29 @@ function validateRemote(name, value) {
|
|
|
292
244
|
...(headers === undefined ? {} : { headers }),
|
|
293
245
|
};
|
|
294
246
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
function isCommandToken(command) {
|
|
302
|
-
if (!command || /\s/.test(command))
|
|
303
|
-
return false;
|
|
304
|
-
if (command.startsWith("./"))
|
|
305
|
-
return !command.split("/").includes("..");
|
|
306
|
-
return !command.includes("/") && !command.includes("\\") && !command.includes("${");
|
|
307
|
-
}
|
|
308
|
-
function isCwdForm(cwd) {
|
|
309
|
-
return (cwd.startsWith("./") ||
|
|
310
|
-
cwd === "${PLUGIN_ROOT}" ||
|
|
311
|
-
cwd.startsWith("${PLUGIN_ROOT}/") ||
|
|
312
|
-
cwd === "${PLUGIN_DATA}" ||
|
|
313
|
-
cwd.startsWith("${PLUGIN_DATA}/"));
|
|
314
|
-
}
|
|
315
|
-
function isRemoteUrl(value) {
|
|
247
|
+
/**
|
|
248
|
+
* Why `value` is not a remote server URL: https, or plain http to this machine's loopback (a
|
|
249
|
+
* local Tenant in Docker reaches it on the Docker host). No credentials or fragment.
|
|
250
|
+
*/
|
|
251
|
+
function remoteUrlProblem(value) {
|
|
316
252
|
let url;
|
|
317
253
|
try {
|
|
318
254
|
url = new URL(value);
|
|
319
255
|
}
|
|
320
256
|
catch {
|
|
321
|
-
return
|
|
257
|
+
return `url '${value}' is not a URL`;
|
|
322
258
|
}
|
|
323
|
-
if (url.username || url.password
|
|
324
|
-
return
|
|
259
|
+
if (url.username || url.password)
|
|
260
|
+
return "url must not carry credentials; use headers";
|
|
261
|
+
if (url.hash)
|
|
262
|
+
return "url must not have a fragment";
|
|
325
263
|
if (url.protocol === "https:")
|
|
326
|
-
return
|
|
264
|
+
return undefined;
|
|
327
265
|
if (url.protocol !== "http:")
|
|
328
|
-
return
|
|
329
|
-
|
|
266
|
+
return `url must be https, not ${url.protocol.slice(0, -1)}`;
|
|
267
|
+
if (isLoopback(url.hostname))
|
|
268
|
+
return undefined;
|
|
269
|
+
return `plain http is allowed only for localhost, 127.0.0.1 or [::1]; use https for ${url.hostname}`;
|
|
330
270
|
}
|
|
331
271
|
function isLoopback(hostname) {
|
|
332
272
|
const host = hostname.replace(/^\[|\]$/g, "");
|
package/dist/plugins/plugin.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { type LoadedPlugin, type PluginDiagnostic } from "./load.js";
|
|
|
3
3
|
export interface PluginCapability extends CapabilityDeclaration {
|
|
4
4
|
readonly diagnostics: readonly PluginDiagnostic[];
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Read an Agent Plugin package and return one capability for `Agent.use`. Each part it skips
|
|
8
|
+
* (an invalid MCP server or skill) is a process warning, so building or registering the agent
|
|
9
|
+
* says why the agent has less than the package declares. A stdio MCP server throws: Nylorun
|
|
10
|
+
* accepts remote servers only.
|
|
11
|
+
*/
|
|
7
12
|
export declare function plugin(directory: string): PluginCapability;
|
|
8
13
|
export declare function capabilityFromPlugin(loaded: LoadedPlugin): PluginCapability;
|
package/dist/plugins/plugin.js
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import { formatSkillCatalog, SKILLS_USAGE } from "../skills/catalog.js";
|
|
2
|
+
import { skillsDeclaration } from "../skills/skills.js";
|
|
2
3
|
import { loadPlugin, } from "./load.js";
|
|
3
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Read an Agent Plugin package and return one capability for `Agent.use`. Each part it skips
|
|
6
|
+
* (an invalid MCP server or skill) is a process warning, so building or registering the agent
|
|
7
|
+
* says why the agent has less than the package declares. A stdio MCP server throws: Nylorun
|
|
8
|
+
* accepts remote servers only.
|
|
9
|
+
*/
|
|
4
10
|
export function plugin(directory) {
|
|
5
11
|
const loaded = loadPlugin(directory);
|
|
12
|
+
warn(loaded);
|
|
6
13
|
return capabilityFromPlugin(loaded);
|
|
7
14
|
}
|
|
15
|
+
function warn(loaded) {
|
|
16
|
+
for (const diagnostic of loaded.diagnostics) {
|
|
17
|
+
if (diagnostic.severity !== "warning")
|
|
18
|
+
continue;
|
|
19
|
+
process.emitWarning(`Plugin '${loaded.name}': ${diagnostic.message}`, {
|
|
20
|
+
type: "NylorunPluginWarning",
|
|
21
|
+
code: diagnostic.code,
|
|
22
|
+
...(diagnostic.path === undefined ? {} : { detail: diagnostic.path }),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
8
26
|
export function capabilityFromPlugin(loaded) {
|
|
9
27
|
const names = Object.values(loaded.skills);
|
|
10
28
|
const instructions = names.length === 0
|
|
@@ -16,17 +34,12 @@ export function capabilityFromPlugin(loaded) {
|
|
|
16
34
|
description: skill.description,
|
|
17
35
|
}))),
|
|
18
36
|
];
|
|
19
|
-
const skills = Object.fromEntries(names.map((skill) => [
|
|
20
|
-
skill.name,
|
|
21
|
-
{ name: skill.name, description: skill.description },
|
|
22
|
-
]));
|
|
23
37
|
return {
|
|
24
38
|
id: loaded.name,
|
|
25
39
|
type: "agent-plugin",
|
|
26
|
-
pluginRoot: loaded.root,
|
|
27
40
|
...(loaded.description === undefined ? {} : { description: loaded.description }),
|
|
28
41
|
...(instructions === undefined ? {} : { instructions }),
|
|
29
|
-
...(names.length === 0 ? {} :
|
|
42
|
+
...(names.length === 0 ? {} : skillsDeclaration(names)),
|
|
30
43
|
...(Object.keys(loaded.mcpServers).length === 0
|
|
31
44
|
? {}
|
|
32
45
|
: { mcpServers: loaded.mcpServers }),
|
package/dist/reads.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Optional public reads shared by Studio, CLI and custom clients. */
|
|
2
|
+
import { type SessionListItem, type SessionPage } from "@nylorun/core/contracts";
|
|
3
|
+
import type { Transport } from "./http.js";
|
|
4
|
+
export type SessionPageOptions = {
|
|
5
|
+
agentId?: string;
|
|
6
|
+
status?: SessionListItem["status"];
|
|
7
|
+
sandboxId?: string;
|
|
8
|
+
ownerUserId?: string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
cursor?: string;
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
};
|
|
13
|
+
export declare class SessionsReadClient {
|
|
14
|
+
private readonly transport;
|
|
15
|
+
constructor(transport: Transport);
|
|
16
|
+
page(options?: SessionPageOptions): Promise<SessionPage>;
|
|
17
|
+
}
|
package/dist/reads.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Optional public reads shared by Studio, CLI and custom clients. */
|
|
2
|
+
import { SessionPageSchema, } from "@nylorun/core/contracts";
|
|
3
|
+
export class SessionsReadClient {
|
|
4
|
+
transport;
|
|
5
|
+
constructor(transport) {
|
|
6
|
+
this.transport = transport;
|
|
7
|
+
}
|
|
8
|
+
async page(options = {}) {
|
|
9
|
+
await this.transport.requireFeature("session-reads", options.signal);
|
|
10
|
+
const { signal, ...filters } = options;
|
|
11
|
+
const query = new URLSearchParams({ limit: String(options.limit ?? 50) });
|
|
12
|
+
for (const [key, value] of Object.entries(filters))
|
|
13
|
+
if (value !== undefined)
|
|
14
|
+
query.set(key, String(value));
|
|
15
|
+
return SessionPageSchema.parse(await this.transport.json(`/v1/sessions?${query}`, "GET", undefined, signal));
|
|
16
|
+
}
|
|
17
|
+
}
|
package/dist/sandboxes.d.ts
CHANGED
|
@@ -58,6 +58,35 @@ export declare class SandboxesClient {
|
|
|
58
58
|
labels?: Readonly<Record<string, string>>;
|
|
59
59
|
signal?: AbortSignal;
|
|
60
60
|
}): Promise<SandboxView[]>;
|
|
61
|
+
page(options?: {
|
|
62
|
+
labels?: Readonly<Record<string, string>>;
|
|
63
|
+
limit?: number;
|
|
64
|
+
cursor?: string;
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
sandboxes: {
|
|
68
|
+
id: string;
|
|
69
|
+
kind: "pod" | "virtual";
|
|
70
|
+
labels: Record<string, string>;
|
|
71
|
+
spec: Record<string, unknown>;
|
|
72
|
+
state: "creating" | "ready" | "running" | "stopped";
|
|
73
|
+
pod?: {
|
|
74
|
+
desired: "deleted" | "running" | "suspended";
|
|
75
|
+
observed: "creating" | "deleting" | "expired" | "failed" | "lost" | "running" | "suspended";
|
|
76
|
+
volumeGeneration: number;
|
|
77
|
+
hostEpoch: number;
|
|
78
|
+
expiresAt?: string | undefined;
|
|
79
|
+
reason?: string | undefined;
|
|
80
|
+
} | undefined;
|
|
81
|
+
sessions: {
|
|
82
|
+
id: string;
|
|
83
|
+
activeTurnId: string | null;
|
|
84
|
+
}[];
|
|
85
|
+
createdAt: string;
|
|
86
|
+
updatedAt: string;
|
|
87
|
+
}[];
|
|
88
|
+
nextCursor: string | null;
|
|
89
|
+
}>;
|
|
61
90
|
/** Deletes the sandbox and its files; `deleted` is false when there was none. */
|
|
62
91
|
delete(sandboxId: string, options?: {
|
|
63
92
|
signal?: AbortSignal;
|
package/dist/sandboxes.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Ids may hold `/`; they are sent percent-encoded as one path segment.
|
|
14
14
|
*/
|
|
15
|
-
import { isSandboxId, } from "@nylorun/core/contracts";
|
|
15
|
+
import { SandboxPageSchema, isSandboxId, } from "@nylorun/core/contracts";
|
|
16
16
|
import { id, segment } from "./http.js";
|
|
17
17
|
const FEATURE = "sandboxes";
|
|
18
18
|
export class SandboxesClient {
|
|
@@ -53,6 +53,15 @@ export class SandboxesClient {
|
|
|
53
53
|
const reply = await this.transport.json(`/v1/sandboxes${search ? `?${search}` : ""}`, "GET", undefined, options.signal);
|
|
54
54
|
return reply.sandboxes;
|
|
55
55
|
}
|
|
56
|
+
async page(options = {}) {
|
|
57
|
+
await this.transport.requireFeature("session-reads", options.signal);
|
|
58
|
+
const query = new URLSearchParams({ limit: String(options.limit ?? 50) });
|
|
59
|
+
if (options.cursor !== undefined)
|
|
60
|
+
query.set("cursor", options.cursor);
|
|
61
|
+
for (const [key, value] of Object.entries(options.labels ?? {}))
|
|
62
|
+
query.append("label", `${key}=${value}`);
|
|
63
|
+
return SandboxPageSchema.parse(await this.transport.json(`/v1/sandboxes?${query}`, "GET", undefined, options.signal));
|
|
64
|
+
}
|
|
56
65
|
/** Deletes the sandbox and its files; `deleted` is false when there was none. */
|
|
57
66
|
async delete(sandboxId, options = {}) {
|
|
58
67
|
const path = this.path(sandboxId);
|
package/dist/session-client.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Tenant API client classes, with no Node-only imports
|
|
3
|
-
*
|
|
4
|
-
* connection from the environment or the Project link.
|
|
2
|
+
* The Tenant API client classes, with no Node-only imports. `client.ts` adds `createClient`,
|
|
3
|
+
* which resolves the connection from the environment or the Project link.
|
|
5
4
|
*/
|
|
6
5
|
import type { AgentManifest, BuiltAgent, BuiltWorkflow, JsonValue, SandboxToolName, WorkflowManifest } from "@nylorun/core/define";
|
|
7
|
-
import { type
|
|
8
|
-
import {
|
|
6
|
+
import { type SessionItemsResponse, type SessionSummary, type ListAgentsResponse, type ListPublicAgentsResponse, type SubjectScope, type CredentialSelection, type MessagePart, type SandboxRequest, type SessionCommand } from "@nylorun/core/contracts";
|
|
7
|
+
import { SessionsReadClient } from "./reads.js";
|
|
8
|
+
import { AccessClient } from "./access.js";
|
|
9
9
|
import { SandboxesClient } from "./sandboxes.js";
|
|
10
10
|
import { ArtifactsClient } from "./artifacts.js";
|
|
11
|
+
import { FilesClient } from "./files.js";
|
|
11
12
|
import { Transport, type Destination } from "./http.js";
|
|
12
13
|
/** Application-principal access to a session's sandbox built-ins (workflows.md §8). */
|
|
13
14
|
export type SessionSandbox = {
|
|
@@ -64,12 +65,7 @@ export declare class AgentsClient {
|
|
|
64
65
|
* themselves and hold the key; nothing is minted, cached or refreshed.
|
|
65
66
|
*/
|
|
66
67
|
as(subject: string, options?: ActAsOptions): AgentsClient;
|
|
67
|
-
/**
|
|
68
|
-
* Mints subject tokens for signed-in people (Host feature `subject-tokens`), so their
|
|
69
|
-
* browser or app calls the Runtime directly. Application key only.
|
|
70
|
-
*/
|
|
71
|
-
get tokens(): TokensClient;
|
|
72
|
-
/** The access policy, signing keys and revocations (Host feature `subject-tokens`). */
|
|
68
|
+
/** The public keys that verify the tokens the Tenant signs. */
|
|
73
69
|
get access(): AccessClient;
|
|
74
70
|
/**
|
|
75
71
|
* Sandboxes as a resource (Host feature `sandboxes`): `ensure` one by id, `list` them by
|
|
@@ -78,90 +74,38 @@ export declare class AgentsClient {
|
|
|
78
74
|
get sandboxes(): SandboxesClient;
|
|
79
75
|
/** File artifacts: upload, list, download with Range, capability links (protocol 6). */
|
|
80
76
|
get artifacts(): ArtifactsClient;
|
|
77
|
+
/** Definition files: the skill files a definition names, by content hash. */
|
|
78
|
+
get files(): FilesClient;
|
|
81
79
|
/** The Runtime's protocol features, including optional ones such as `transcript-events`. */
|
|
82
80
|
hostFeatures(options?: {
|
|
83
81
|
signal?: AbortSignal;
|
|
84
82
|
}): Promise<readonly string[]>;
|
|
83
|
+
get sessions(): SessionsReadClient;
|
|
85
84
|
listAgents(options?: {
|
|
86
85
|
signal?: AbortSignal;
|
|
87
|
-
}): Promise<{
|
|
88
|
-
agents: {
|
|
89
|
-
manifest
|
|
90
|
-
}[];
|
|
86
|
+
}): Promise<ListAgentsResponse | {
|
|
87
|
+
agents: (ListPublicAgentsResponse["agents"][number] & {
|
|
88
|
+
manifest?: never;
|
|
89
|
+
})[];
|
|
91
90
|
}>;
|
|
92
91
|
listSessions(options?: {
|
|
93
92
|
agentId?: string;
|
|
94
93
|
signal?: AbortSignal;
|
|
95
94
|
}): Promise<{
|
|
96
|
-
sessions:
|
|
95
|
+
sessions: SessionSummary[];
|
|
97
96
|
}>;
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Registers the agent's definition (`PUT /v1/agents/{id}`), first uploading the skill files
|
|
99
|
+
* it names that the Runtime does not hold. A definition with a tool that runs your code
|
|
100
|
+
* (`tool({ run })`, a flow's tool stage) is refused before anything is sent: the Runtime runs
|
|
101
|
+
* no code of yours during a session. `implementationVersion` defaults to
|
|
102
|
+
* `NYLORUN_IMPLEMENTATION_VERSION`, else `dev`.
|
|
103
|
+
*/
|
|
104
|
+
saveAgent(agent: AgentSource | BuiltWorkflow, options?: {
|
|
105
|
+
implementationVersion?: string;
|
|
100
106
|
requestId?: string;
|
|
101
107
|
}): Promise<unknown>;
|
|
102
108
|
createSession(options: CreateSessionOptions): Promise<SessionClient>;
|
|
103
|
-
createVault(options: {
|
|
104
|
-
name: string;
|
|
105
|
-
ownerUserId: string;
|
|
106
|
-
metadata?: Record<string, string>;
|
|
107
|
-
idempotencyKey: string;
|
|
108
|
-
requestId?: string;
|
|
109
|
-
}): Promise<VaultInfo>;
|
|
110
|
-
listVaults(ownerUserId: string, signal?: AbortSignal): Promise<{
|
|
111
|
-
vaults: VaultInfo[];
|
|
112
|
-
}>;
|
|
113
|
-
getVault(vaultId: string, signal?: AbortSignal): Promise<VaultInfo>;
|
|
114
|
-
deleteVault(vaultId: string): Promise<{
|
|
115
|
-
id: string;
|
|
116
|
-
}>;
|
|
117
|
-
createCredential(vaultId: string, options: {
|
|
118
|
-
name: string;
|
|
119
|
-
idempotencyKey: string;
|
|
120
|
-
requestId?: string;
|
|
121
|
-
auth: {
|
|
122
|
-
type: "bearer";
|
|
123
|
-
url: string;
|
|
124
|
-
token: string;
|
|
125
|
-
} | {
|
|
126
|
-
type: "oauth";
|
|
127
|
-
url: string;
|
|
128
|
-
accessToken: string;
|
|
129
|
-
expiresAt?: string | null;
|
|
130
|
-
refresh?: {
|
|
131
|
-
tokenEndpoint: string;
|
|
132
|
-
clientId: string;
|
|
133
|
-
refreshToken: string;
|
|
134
|
-
tokenEndpointAuth: {
|
|
135
|
-
type: "none";
|
|
136
|
-
} | {
|
|
137
|
-
type: "client_secret_basic";
|
|
138
|
-
clientSecret: string;
|
|
139
|
-
} | {
|
|
140
|
-
type: "client_secret_post";
|
|
141
|
-
clientSecret: string;
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
}): Promise<CredentialInfo>;
|
|
146
|
-
listCredentials(vaultId: string, signal?: AbortSignal): Promise<{
|
|
147
|
-
credentials: CredentialInfo[];
|
|
148
|
-
}>;
|
|
149
|
-
getCredential(vaultId: string, credentialId: string, signal?: AbortSignal): Promise<CredentialInfo>;
|
|
150
|
-
rotateCredential(vaultId: string, credentialId: string, options: {
|
|
151
|
-
idempotencyKey: string;
|
|
152
|
-
requestId?: string;
|
|
153
|
-
auth: {
|
|
154
|
-
type: "bearer";
|
|
155
|
-
token: string;
|
|
156
|
-
} | {
|
|
157
|
-
type: "oauth";
|
|
158
|
-
accessToken: string;
|
|
159
|
-
expiresAt?: string | null;
|
|
160
|
-
};
|
|
161
|
-
}): Promise<CredentialInfo>;
|
|
162
|
-
deleteCredential(vaultId: string, credentialId: string): Promise<{
|
|
163
|
-
id: string;
|
|
164
|
-
}>;
|
|
165
109
|
session(sessionId: string): SessionClient;
|
|
166
110
|
}
|
|
167
111
|
export type CommandOptions = {
|
|
@@ -225,42 +169,80 @@ export declare class SessionClient {
|
|
|
225
169
|
cursor: string | null;
|
|
226
170
|
requestId: string;
|
|
227
171
|
}>;
|
|
228
|
-
|
|
229
|
-
|
|
172
|
+
manifest(options?: {
|
|
173
|
+
signal?: AbortSignal;
|
|
174
|
+
}): Promise<{
|
|
175
|
+
sessionId: string;
|
|
176
|
+
agentId: string;
|
|
177
|
+
manifestHash: string;
|
|
178
|
+
implementationVersion: string;
|
|
179
|
+
manifest: Record<string, unknown>;
|
|
180
|
+
}>;
|
|
181
|
+
usage(options?: {
|
|
182
|
+
turnId?: string;
|
|
183
|
+
signal?: AbortSignal;
|
|
184
|
+
}): Promise<{
|
|
185
|
+
inputTokens: number;
|
|
186
|
+
outputTokens: number;
|
|
187
|
+
totalTokens: number;
|
|
188
|
+
cachedTokens: number;
|
|
189
|
+
cacheWriteTokens: number;
|
|
190
|
+
reasoningTokens: number;
|
|
191
|
+
costUsd: number;
|
|
192
|
+
sessionId: string;
|
|
193
|
+
turnId: string | null;
|
|
194
|
+
asOf: string;
|
|
195
|
+
calls: number;
|
|
196
|
+
duplicates: number;
|
|
197
|
+
unpricedCalls: number;
|
|
198
|
+
unreportedCalls: number;
|
|
199
|
+
unknownQualityCalls: number;
|
|
200
|
+
}>;
|
|
201
|
+
modelCalls(options?: {
|
|
202
|
+
turnId?: string;
|
|
203
|
+
limit?: number;
|
|
230
204
|
cursor?: string;
|
|
231
|
-
agent?: string;
|
|
232
205
|
signal?: AbortSignal;
|
|
233
206
|
}): Promise<{
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
eventId: string;
|
|
237
|
-
tenantId: string;
|
|
207
|
+
calls: {
|
|
208
|
+
id: string;
|
|
238
209
|
sessionId: string;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
} |
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
210
|
+
turnId: string;
|
|
211
|
+
agentId: string;
|
|
212
|
+
provider: string | null;
|
|
213
|
+
model: string | null;
|
|
214
|
+
at: string;
|
|
215
|
+
outcome: "completed" | "failed";
|
|
216
|
+
usage: {
|
|
217
|
+
inputTokens: number;
|
|
218
|
+
outputTokens: number;
|
|
219
|
+
totalTokens: number;
|
|
220
|
+
cachedTokens: number;
|
|
221
|
+
cacheWriteTokens: number;
|
|
222
|
+
reasoningTokens: number;
|
|
223
|
+
costUsd: number;
|
|
224
|
+
duplicate: boolean;
|
|
225
|
+
tokensReported: boolean | null;
|
|
226
|
+
costKnown: boolean | null;
|
|
227
|
+
} | null;
|
|
228
|
+
}[];
|
|
229
|
+
nextCursor: string | null;
|
|
230
|
+
asOf: string;
|
|
231
|
+
}>;
|
|
232
|
+
/** `agent` narrows to one agent used as a tool: its delegationId or its path. */
|
|
233
|
+
history(options: {
|
|
234
|
+
cursor?: string;
|
|
235
|
+
agent?: string;
|
|
236
|
+
signal?: AbortSignal;
|
|
237
|
+
limit: number;
|
|
238
|
+
}): Promise<SessionItemsResponse & {
|
|
239
|
+
tail: boolean;
|
|
263
240
|
}>;
|
|
241
|
+
history(options?: {
|
|
242
|
+
cursor?: string;
|
|
243
|
+
agent?: string;
|
|
244
|
+
signal?: AbortSignal;
|
|
245
|
+
}): Promise<SessionItemsResponse>;
|
|
264
246
|
observe(options?: {
|
|
265
247
|
cursor?: string;
|
|
266
248
|
signal?: AbortSignal;
|
|
@@ -303,6 +285,6 @@ export declare class SessionClient {
|
|
|
303
285
|
export { RuntimeError, IncompatibleRuntimeError } from "./http.js";
|
|
304
286
|
export type { Destination, IncompatibleReason } from "./http.js";
|
|
305
287
|
export type { LiveEvent } from "@nylorun/core/contracts";
|
|
306
|
-
export { AccessClient
|
|
288
|
+
export { AccessClient } from "./access.js";
|
|
307
289
|
export { SandboxesClient } from "./sandboxes.js";
|
|
308
290
|
export type { ForSessionOptions, SandboxSpec, SessionSandboxHandle } from "./sandboxes.js";
|