@nylorun/agents 0.19.1-beta → 0.21.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 +179 -0
- package/README.md +191 -106
- package/dist/ag-ui/handler.d.ts +4 -4
- package/dist/artifacts.d.ts +14 -1
- package/dist/artifacts.js +28 -0
- package/dist/builder.d.ts +2 -3
- package/dist/builder.js +5 -5
- package/dist/environments.d.ts +387 -0
- package/dist/environments.js +299 -0
- package/dist/http.js +2 -2
- package/dist/index.d.ts +11 -13
- package/dist/index.js +5 -6
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +1 -1
- package/dist/plugins/load.d.ts +1 -0
- package/dist/plugins/load.js +1 -0
- package/dist/plugins/plugin.d.ts +9 -5
- package/dist/plugins/plugin.js +19 -21
- package/dist/reads.d.ts +1 -1
- package/dist/session-client.d.ts +108 -21
- package/dist/session-client.js +43 -30
- package/dist/skills/index.d.ts +1 -3
- package/dist/skills/index.js +1 -2
- package/dist/skills/skills.d.ts +11 -11
- package/dist/skills/skills.js +17 -23
- package/package.json +4 -4
- package/dist/sandboxes.d.ts +0 -106
- package/dist/sandboxes.js +0 -109
- package/dist/skills/catalog.d.ts +0 -5
- package/dist/skills/catalog.js +0 -14
package/dist/session-client.d.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* which resolves the connection from the environment or the Project link.
|
|
4
4
|
*/
|
|
5
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
|
|
6
|
+
import { type SessionItemsResponse, type SessionSummary, type ListAgentsResponse, type ListPublicAgentsResponse, type SubjectScope, type MessagePart, type SessionCommand } from "@nylorun/core/contracts";
|
|
7
7
|
import { SessionsReadClient } from "./reads.js";
|
|
8
8
|
import { AccessClient } from "./access.js";
|
|
9
|
-
import {
|
|
9
|
+
import { EnvironmentsClient } from "./environments.js";
|
|
10
10
|
import { ArtifactsClient } from "./artifacts.js";
|
|
11
11
|
import { FilesClient } from "./files.js";
|
|
12
12
|
import { Transport, type Destination } from "./http.js";
|
|
@@ -20,8 +20,6 @@ export interface AgentSource {
|
|
|
20
20
|
build?(): BuiltAgent | BuiltWorkflow;
|
|
21
21
|
getBinding?: BuiltAgent["getBinding"] | BuiltWorkflow["getBinding"];
|
|
22
22
|
}
|
|
23
|
-
/** Closures stay on the live binding. The published manifest cannot name them. */
|
|
24
|
-
export declare function assertNoMiddlewareClosures(agent: AgentSource): void;
|
|
25
23
|
export interface SessionView {
|
|
26
24
|
id: string;
|
|
27
25
|
agentId: string;
|
|
@@ -38,16 +36,12 @@ export interface CreateSessionOptions {
|
|
|
38
36
|
ownerUserId: string;
|
|
39
37
|
info?: Record<string, unknown>;
|
|
40
38
|
requestId?: string;
|
|
41
|
-
vaultIds?: readonly string[];
|
|
42
|
-
credentialSelections?: readonly CredentialSelection[];
|
|
43
39
|
/**
|
|
44
|
-
* The
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* shares another session's and is deprecated: use `client.sandboxes.forSession()` or
|
|
48
|
-
* `ensure()` and `{ id }`. Fixed once the session exists.
|
|
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.
|
|
49
43
|
*/
|
|
50
|
-
|
|
44
|
+
environment?: string;
|
|
51
45
|
}
|
|
52
46
|
export interface ActAsOptions {
|
|
53
47
|
/** What the subject may do; the Runtime grants nothing else. Default `["sessions:own"]`. */
|
|
@@ -61,17 +55,18 @@ export declare class AgentsClient {
|
|
|
61
55
|
/**
|
|
62
56
|
* A client that acts for `subject`: every call sends `Nylorun-Subject` and
|
|
63
57
|
* `Nylorun-Scopes`, and the Runtime limits it to the scopes and to the subject's own sessions
|
|
64
|
-
*
|
|
58
|
+
* (Host feature `subject-headers`). For app servers, which authenticate the person
|
|
65
59
|
* themselves and hold the key; nothing is minted, cached or refreshed.
|
|
66
60
|
*/
|
|
67
61
|
as(subject: string, options?: ActAsOptions): AgentsClient;
|
|
68
62
|
/** The public keys that verify the tokens the Tenant signs. */
|
|
69
63
|
get access(): AccessClient;
|
|
70
64
|
/**
|
|
71
|
-
*
|
|
72
|
-
* label, `delete` one, or give a session its own with
|
|
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`.
|
|
73
68
|
*/
|
|
74
|
-
get
|
|
69
|
+
get environments(): EnvironmentsClient;
|
|
75
70
|
/** File artifacts: upload, list, download with Range, capability links (protocol 6). */
|
|
76
71
|
get artifacts(): ArtifactsClient;
|
|
77
72
|
/** Definition files: the skill files a definition names, by content hash. */
|
|
@@ -98,12 +93,14 @@ export declare class AgentsClient {
|
|
|
98
93
|
* Registers the agent's definition (`PUT /v1/agents/{id}`), first uploading the skill files
|
|
99
94
|
* it names that the Runtime does not hold. A definition with a tool that runs your code
|
|
100
95
|
* (`tool({ run })`, a flow's tool stage) is refused before anything is sent: the Runtime runs
|
|
101
|
-
*
|
|
102
|
-
* `NYLORUN_IMPLEMENTATION_VERSION`, else `dev`.
|
|
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.
|
|
103
99
|
*/
|
|
104
100
|
saveAgent(agent: AgentSource | BuiltWorkflow, options?: {
|
|
105
101
|
implementationVersion?: string;
|
|
106
102
|
requestId?: string;
|
|
103
|
+
dryRun?: boolean;
|
|
107
104
|
}): Promise<unknown>;
|
|
108
105
|
createSession(options: CreateSessionOptions): Promise<SessionClient>;
|
|
109
106
|
session(sessionId: string): SessionClient;
|
|
@@ -206,6 +203,7 @@ export declare class SessionClient {
|
|
|
206
203
|
}): Promise<{
|
|
207
204
|
calls: {
|
|
208
205
|
id: string;
|
|
206
|
+
effectId: string;
|
|
209
207
|
sessionId: string;
|
|
210
208
|
turnId: string;
|
|
211
209
|
agentId: string;
|
|
@@ -229,6 +227,91 @@ export declare class SessionClient {
|
|
|
229
227
|
nextCursor: string | null;
|
|
230
228
|
asOf: string;
|
|
231
229
|
}>;
|
|
230
|
+
/**
|
|
231
|
+
* The session's tool calls (R5, Host feature `tool-calls`), in the order they were first sent:
|
|
232
|
+
* each one's tool, input, status and sends. `attempts` above 1: a crash re-sent it.
|
|
233
|
+
*/
|
|
234
|
+
toolCalls(options?: {
|
|
235
|
+
turnId?: string;
|
|
236
|
+
limit?: number;
|
|
237
|
+
cursor?: string;
|
|
238
|
+
signal?: AbortSignal;
|
|
239
|
+
}): Promise<{
|
|
240
|
+
calls: {
|
|
241
|
+
effectId: string;
|
|
242
|
+
turnId: string;
|
|
243
|
+
callId: string | null;
|
|
244
|
+
toolName: string | null;
|
|
245
|
+
kind: "harness" | "http" | "mcp" | "platform" | "sandbox" | null;
|
|
246
|
+
server: string | null;
|
|
247
|
+
skill: string | null;
|
|
248
|
+
plugin: {
|
|
249
|
+
name: string;
|
|
250
|
+
version?: string | undefined;
|
|
251
|
+
} | null;
|
|
252
|
+
status: "cancelled" | "completed" | "failed" | "held" | "invoking" | "uncertain";
|
|
253
|
+
attempts: number;
|
|
254
|
+
input: unknown;
|
|
255
|
+
error: {
|
|
256
|
+
code: string;
|
|
257
|
+
message: string;
|
|
258
|
+
} | null;
|
|
259
|
+
startedAt: string | null;
|
|
260
|
+
settledAt: string | null;
|
|
261
|
+
durationMs: number | null;
|
|
262
|
+
}[];
|
|
263
|
+
nextCursor: string | null;
|
|
264
|
+
asOf: string;
|
|
265
|
+
}>;
|
|
266
|
+
/**
|
|
267
|
+
* A turn's trace (R7, Host feature `traces`): its spans as OTLP/HTTP JSON (`resourceSpans`), as
|
|
268
|
+
* the Runtime posts them to an OTLP collector. Post it to a collector's `/v1/traces` to backfill
|
|
269
|
+
* one, or read it without one.
|
|
270
|
+
*/
|
|
271
|
+
trace(turnId: string, options?: {
|
|
272
|
+
signal?: AbortSignal;
|
|
273
|
+
}): Promise<{
|
|
274
|
+
[x: string]: unknown;
|
|
275
|
+
resourceSpans: {
|
|
276
|
+
[x: string]: unknown;
|
|
277
|
+
resource: {
|
|
278
|
+
[x: string]: unknown;
|
|
279
|
+
attributes: {
|
|
280
|
+
[x: string]: unknown;
|
|
281
|
+
key: string;
|
|
282
|
+
value: Record<string, unknown>;
|
|
283
|
+
}[];
|
|
284
|
+
};
|
|
285
|
+
scopeSpans: {
|
|
286
|
+
[x: string]: unknown;
|
|
287
|
+
scope: {
|
|
288
|
+
[x: string]: unknown;
|
|
289
|
+
name: string;
|
|
290
|
+
version?: string | undefined;
|
|
291
|
+
};
|
|
292
|
+
spans: {
|
|
293
|
+
[x: string]: unknown;
|
|
294
|
+
traceId: string;
|
|
295
|
+
spanId: string;
|
|
296
|
+
parentSpanId?: string | undefined;
|
|
297
|
+
name: string;
|
|
298
|
+
kind: number;
|
|
299
|
+
startTimeUnixNano: string;
|
|
300
|
+
endTimeUnixNano: string;
|
|
301
|
+
attributes: {
|
|
302
|
+
[x: string]: unknown;
|
|
303
|
+
key: string;
|
|
304
|
+
value: Record<string, unknown>;
|
|
305
|
+
}[];
|
|
306
|
+
status: {
|
|
307
|
+
[x: string]: unknown;
|
|
308
|
+
code: number;
|
|
309
|
+
message?: string | undefined;
|
|
310
|
+
};
|
|
311
|
+
}[];
|
|
312
|
+
}[];
|
|
313
|
+
}[];
|
|
314
|
+
}>;
|
|
232
315
|
/** `agent` narrows to one agent used as a tool: its delegationId or its path. */
|
|
233
316
|
history(options: {
|
|
234
317
|
cursor?: string;
|
|
@@ -261,10 +344,14 @@ export declare class SessionClient {
|
|
|
261
344
|
time: string;
|
|
262
345
|
schemaVersion: number;
|
|
263
346
|
source: {
|
|
264
|
-
kind: "api" | "controller" | "edge" | "egress-gate" | "evidence" | "harness" | "human" | "init" | "loop" | "model-gate" | "operator" | "sandboxes" | "supervisor" | "tool-gate";
|
|
347
|
+
kind: "api" | "client" | "controller" | "core" | "edge" | "egress-gate" | "evidence" | "harness" | "human" | "init" | "loop" | "model-gate" | "operator" | "sandboxes" | "supervisor" | "tool-gate";
|
|
265
348
|
id: string;
|
|
266
349
|
};
|
|
267
350
|
evidence: "asserted" | "attested" | "claimed" | "measured" | "observed";
|
|
351
|
+
principal?: {
|
|
352
|
+
kind: "application" | "core" | "flow-host" | "subject";
|
|
353
|
+
id: string;
|
|
354
|
+
} | undefined;
|
|
268
355
|
trace?: {
|
|
269
356
|
traceId: string;
|
|
270
357
|
spanId: string;
|
|
@@ -286,5 +373,5 @@ export { RuntimeError, IncompatibleRuntimeError } from "./http.js";
|
|
|
286
373
|
export type { Destination, IncompatibleReason } from "./http.js";
|
|
287
374
|
export type { LiveEvent } from "@nylorun/core/contracts";
|
|
288
375
|
export { AccessClient } from "./access.js";
|
|
289
|
-
export {
|
|
290
|
-
export type { ForSessionOptions,
|
|
376
|
+
export { EnvironmentManifestsClient, EnvironmentSecretsClient, EnvironmentsClient, environmentFiles, environmentManifest, } from "./environments.js";
|
|
377
|
+
export type { EnvironmentFileBytes, EnvironmentInput, EnvironmentManifestInput, EnvironmentSecretInput, ForSessionOptions, SessionEnvironmentHandle, } from "./environments.js";
|
package/dist/session-client.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { SANDBOX_TOOL_NAMES, codeToolRefusal, delegateOf, isBuiltWorkflow, isSandboxToolName, } from "@nylorun/core/define";
|
|
1
|
+
import { SANDBOX_TOOL_NAMES, approvalRefusal, codeToolRefusal, delegateOf, isBuiltWorkflow, isSandboxToolName, } from "@nylorun/core/define";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { SCOPES_HEADER, SUBJECT_HEADER } from "@nylorun/core/compatibility";
|
|
4
|
-
import { SessionManifestViewSchema, SessionUsageTotalsSchema, ModelCallsPageSchema, parseSessionEvent, parseSubjectHeaders, } from "@nylorun/core/contracts";
|
|
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 {
|
|
7
|
+
import { EnvironmentsClient } from "./environments.js";
|
|
8
8
|
import { ArtifactsClient } from "./artifacts.js";
|
|
9
9
|
import { FilesClient } from "./files.js";
|
|
10
10
|
import { Transport, env, id, segment } from "./http.js";
|
|
@@ -30,7 +30,6 @@ function linkedSessionId(event) {
|
|
|
30
30
|
? sessionId
|
|
31
31
|
: undefined;
|
|
32
32
|
}
|
|
33
|
-
const middlewareClosure = "Hosted definitions support declarative capabilities, not middleware closures";
|
|
34
33
|
/** The agent's declarations, then those of each agent it uses as a tool. */
|
|
35
34
|
function declarationsOf(agent) {
|
|
36
35
|
if (isBuiltWorkflow(agent) || agent.manifest.kind === "workflow")
|
|
@@ -39,15 +38,15 @@ function declarationsOf(agent) {
|
|
|
39
38
|
if (isBuiltWorkflow(built))
|
|
40
39
|
return [];
|
|
41
40
|
const binding = built.getBinding?.();
|
|
42
|
-
if (!binding || !("
|
|
41
|
+
if (!binding || !("parts" in binding))
|
|
43
42
|
return [];
|
|
44
|
-
const found = [...(binding.
|
|
43
|
+
const found = [...(binding.parts ?? [])];
|
|
45
44
|
for (const tool of binding.tools ?? []) {
|
|
46
45
|
const delegate = delegateOf(tool);
|
|
47
|
-
found.push(...(delegate?.agent?.getBinding().
|
|
46
|
+
found.push(...(delegate?.agent?.getBinding().parts ?? []));
|
|
48
47
|
// A flow agent used as a tool: its agents' declarations.
|
|
49
48
|
for (const leaf of Object.values(delegate?.workflow?.getBinding().agents ?? {}))
|
|
50
|
-
found.push(...(leaf.
|
|
49
|
+
found.push(...(leaf.parts ?? []));
|
|
51
50
|
}
|
|
52
51
|
return found;
|
|
53
52
|
}
|
|
@@ -58,11 +57,6 @@ function skillFilesOf(agent, into = new Map()) {
|
|
|
58
57
|
into.set(sha256, source);
|
|
59
58
|
return into;
|
|
60
59
|
}
|
|
61
|
-
/** Closures stay on the live binding. The published manifest cannot name them. */
|
|
62
|
-
export function assertNoMiddlewareClosures(agent) {
|
|
63
|
-
if (declarationsOf(agent).some((item) => item.hasMiddleware))
|
|
64
|
-
throw new Error(middlewareClosure);
|
|
65
|
-
}
|
|
66
60
|
export class AgentsClient {
|
|
67
61
|
transport;
|
|
68
62
|
/** The subject this client acts for (`as`), or `undefined` for the principal itself. */
|
|
@@ -74,7 +68,7 @@ export class AgentsClient {
|
|
|
74
68
|
/**
|
|
75
69
|
* A client that acts for `subject`: every call sends `Nylorun-Subject` and
|
|
76
70
|
* `Nylorun-Scopes`, and the Runtime limits it to the scopes and to the subject's own sessions
|
|
77
|
-
*
|
|
71
|
+
* (Host feature `subject-headers`). For app servers, which authenticate the person
|
|
78
72
|
* themselves and hold the key; nothing is minted, cached or refreshed.
|
|
79
73
|
*/
|
|
80
74
|
as(subject, options = {}) {
|
|
@@ -98,11 +92,12 @@ export class AgentsClient {
|
|
|
98
92
|
return new AccessClient(this.transport);
|
|
99
93
|
}
|
|
100
94
|
/**
|
|
101
|
-
*
|
|
102
|
-
* label, `delete` one, or give a session its own with
|
|
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`.
|
|
103
98
|
*/
|
|
104
|
-
get
|
|
105
|
-
return new
|
|
99
|
+
get environments() {
|
|
100
|
+
return new EnvironmentsClient(this.transport, (options) => this.createSession(options));
|
|
106
101
|
}
|
|
107
102
|
/** File artifacts: upload, list, download with Range, capability links (protocol 6). */
|
|
108
103
|
get artifacts() {
|
|
@@ -132,8 +127,9 @@ export class AgentsClient {
|
|
|
132
127
|
* Registers the agent's definition (`PUT /v1/agents/{id}`), first uploading the skill files
|
|
133
128
|
* it names that the Runtime does not hold. A definition with a tool that runs your code
|
|
134
129
|
* (`tool({ run })`, a flow's tool stage) is refused before anything is sent: the Runtime runs
|
|
135
|
-
*
|
|
136
|
-
* `NYLORUN_IMPLEMENTATION_VERSION`, else `dev`.
|
|
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.
|
|
137
133
|
*/
|
|
138
134
|
async saveAgent(agent, options = {}) {
|
|
139
135
|
const files = new Map();
|
|
@@ -141,19 +137,18 @@ export class AgentsClient {
|
|
|
141
137
|
// A flow agent embeds its agents: one document, carrying their files.
|
|
142
138
|
for (const binding of Object.values(agent.getBinding().agents)) {
|
|
143
139
|
const leaf = { id: binding.manifest.id, manifest: binding.manifest, getBinding: () => binding };
|
|
144
|
-
assertNoMiddlewareClosures(leaf);
|
|
145
140
|
skillFilesOf(leaf, files);
|
|
146
141
|
}
|
|
147
142
|
}
|
|
148
143
|
else {
|
|
149
|
-
assertNoMiddlewareClosures(agent);
|
|
150
144
|
skillFilesOf(agent, files);
|
|
151
145
|
}
|
|
152
|
-
const refusal = codeToolRefusal(agent.manifest)
|
|
146
|
+
const refusal = codeToolRefusal(agent.manifest) ??
|
|
147
|
+
approvalRefusal(agent.manifest);
|
|
153
148
|
if (refusal)
|
|
154
149
|
throw new Error(refusal);
|
|
155
150
|
await this.files.ensure(files);
|
|
156
|
-
return this.transport.json(`/v1/agents/${segment(agent.id)}`, "PUT", {
|
|
151
|
+
return this.transport.json(`/v1/agents/${segment(agent.id)}${options.dryRun ? "?dryRun=true" : ""}`, "PUT", {
|
|
157
152
|
requestId: options.requestId ?? id(),
|
|
158
153
|
manifest: agent.manifest,
|
|
159
154
|
implementationVersion: options.implementationVersion ?? env("NYLORUN_IMPLEMENTATION_VERSION") ?? "dev",
|
|
@@ -166,11 +161,7 @@ export class AgentsClient {
|
|
|
166
161
|
agentId: options.agentId,
|
|
167
162
|
ownerUserId: options.ownerUserId,
|
|
168
163
|
...(options.info ? { info: options.info } : {}),
|
|
169
|
-
...(options.
|
|
170
|
-
...(options.credentialSelections
|
|
171
|
-
? { credentialSelections: options.credentialSelections }
|
|
172
|
-
: {}),
|
|
173
|
-
...(options.sandbox === undefined ? {} : { sandbox: options.sandbox }),
|
|
164
|
+
...(options.environment === undefined ? {} : { environment: options.environment }),
|
|
174
165
|
});
|
|
175
166
|
return this.session(sessionId);
|
|
176
167
|
}
|
|
@@ -274,6 +265,28 @@ export class SessionClient {
|
|
|
274
265
|
query.set("cursor", options.cursor);
|
|
275
266
|
return ModelCallsPageSchema.parse(await this.transport.json(`${this.path}/calls/model?${query}`, "GET", undefined, options.signal));
|
|
276
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* The session's tool calls (R5, Host feature `tool-calls`), in the order they were first sent:
|
|
270
|
+
* each one's tool, input, status and sends. `attempts` above 1: a crash re-sent it.
|
|
271
|
+
*/
|
|
272
|
+
async toolCalls(options = {}) {
|
|
273
|
+
await this.transport.requireFeature("tool-calls", options.signal);
|
|
274
|
+
const query = new URLSearchParams({ limit: String(options.limit ?? 50) });
|
|
275
|
+
if (options.turnId !== undefined)
|
|
276
|
+
query.set("turnId", options.turnId);
|
|
277
|
+
if (options.cursor !== undefined)
|
|
278
|
+
query.set("cursor", options.cursor);
|
|
279
|
+
return ToolCallsPageSchema.parse(await this.transport.json(`${this.path}/calls/tool?${query}`, "GET", undefined, options.signal));
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* A turn's trace (R7, Host feature `traces`): its spans as OTLP/HTTP JSON (`resourceSpans`), as
|
|
283
|
+
* the Runtime posts them to an OTLP collector. Post it to a collector's `/v1/traces` to backfill
|
|
284
|
+
* one, or read it without one.
|
|
285
|
+
*/
|
|
286
|
+
async trace(turnId, options = {}) {
|
|
287
|
+
await this.transport.requireFeature("traces", options.signal);
|
|
288
|
+
return TurnTraceSchema.parse(await this.transport.json(`${this.path}/turns/${encodeURIComponent(turnId)}/trace`, "GET", undefined, options.signal));
|
|
289
|
+
}
|
|
277
290
|
async history(options = {}) {
|
|
278
291
|
const query = new URLSearchParams();
|
|
279
292
|
if (options.cursor)
|
|
@@ -372,4 +385,4 @@ export class SessionClient {
|
|
|
372
385
|
}
|
|
373
386
|
export { RuntimeError, IncompatibleRuntimeError } from "./http.js";
|
|
374
387
|
export { AccessClient } from "./access.js";
|
|
375
|
-
export {
|
|
388
|
+
export { EnvironmentManifestsClient, EnvironmentSecretsClient, EnvironmentsClient, environmentFiles, environmentManifest, } from "./environments.js";
|
package/dist/skills/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export { skills } from "./skills.js";
|
|
2
|
-
export type { SkillsCapability, SkillsOptions } from "./skills.js";
|
|
3
1
|
export { loadSkillsFromDirectory, resolveSkillsRoot, parseSkill, SkillsError, } from "./load.js";
|
|
4
2
|
export type { LoadedSkill, SkillDiagnostic } from "./load.js";
|
|
5
|
-
export { formatSkillCatalog, SKILLS_USAGE } from "
|
|
3
|
+
export { formatSkillCatalog, SKILLS_USAGE } from "@nylorun/core/define";
|
package/dist/skills/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { skills } from "./skills.js";
|
|
2
1
|
export { loadSkillsFromDirectory, resolveSkillsRoot, parseSkill, SkillsError, } from "./load.js";
|
|
3
|
-
export { formatSkillCatalog, SKILLS_USAGE } from "
|
|
2
|
+
export { formatSkillCatalog, SKILLS_USAGE } from "@nylorun/core/define";
|
package/dist/skills/skills.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PartDeclaration, PluginLabel } from "@nylorun/core/define";
|
|
2
2
|
import { type LoadedSkill, type SkillDiagnostic } from "./load.js";
|
|
3
|
-
export interface
|
|
4
|
-
/** Capability id. Defaults to the catalog directory basename. */
|
|
5
|
-
readonly id?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface SkillsCapability extends CapabilityDeclaration {
|
|
3
|
+
export interface SkillsPart extends PartDeclaration {
|
|
8
4
|
readonly diagnostics: readonly SkillDiagnostic[];
|
|
9
5
|
/** Absolute catalog directory that was loaded. */
|
|
10
6
|
readonly root: string;
|
|
11
7
|
}
|
|
12
8
|
/**
|
|
13
|
-
* Load an agentskills.io catalog folder
|
|
9
|
+
* Load an agentskills.io catalog folder as one part of an agent, for `.skills()`.
|
|
14
10
|
*
|
|
15
11
|
* Expected layout:
|
|
16
12
|
* ```
|
|
@@ -23,8 +19,12 @@ export interface SkillsCapability extends CapabilityDeclaration {
|
|
|
23
19
|
*
|
|
24
20
|
* Sets `skills`: each skill's name, description and files (every file of its folder, binary
|
|
25
21
|
* included, by content hash). The client uploads the files the Runtime lacks when it registers
|
|
26
|
-
* the agent
|
|
22
|
+
* the agent; the Runtime adds the skill catalog and serves `load_skill` / `read_skill_resource`
|
|
23
|
+
* from them.
|
|
24
|
+
*/
|
|
25
|
+
export declare function skills(directory: string): SkillsPart;
|
|
26
|
+
/**
|
|
27
|
+
* The manifest's skills and the bytes behind their files. A plugin's skills carry its label, so
|
|
28
|
+
* a tool call can be traced to the plugin that brought the skill.
|
|
27
29
|
*/
|
|
28
|
-
export declare function
|
|
29
|
-
/** The manifest's skills and the bytes behind their files, for a capability declaration. */
|
|
30
|
-
export declare function skillsDeclaration(listed: readonly LoadedSkill[]): Required<Pick<CapabilityDeclaration, "skills" | "skillFiles">>;
|
|
30
|
+
export declare function skillsDeclaration(listed: readonly LoadedSkill[], plugin?: PluginLabel): Required<Pick<PartDeclaration, "skills" | "skillFiles">>;
|
package/dist/skills/skills.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { basename } from "node:path";
|
|
2
|
-
import { formatSkillCatalog, SKILLS_USAGE } from "./catalog.js";
|
|
3
2
|
import { loadSkillsFromDirectory, resolveSkillsRoot, } from "./load.js";
|
|
4
3
|
/**
|
|
5
|
-
* Load an agentskills.io catalog folder
|
|
4
|
+
* Load an agentskills.io catalog folder as one part of an agent, for `.skills()`.
|
|
6
5
|
*
|
|
7
6
|
* Expected layout:
|
|
8
7
|
* ```
|
|
@@ -15,39 +14,34 @@ import { loadSkillsFromDirectory, resolveSkillsRoot, } from "./load.js";
|
|
|
15
14
|
*
|
|
16
15
|
* Sets `skills`: each skill's name, description and files (every file of its folder, binary
|
|
17
16
|
* included, by content hash). The client uploads the files the Runtime lacks when it registers
|
|
18
|
-
* the agent
|
|
17
|
+
* the agent; the Runtime adds the skill catalog and serves `load_skill` / `read_skill_resource`
|
|
18
|
+
* from them.
|
|
19
19
|
*/
|
|
20
|
-
export function skills(directory
|
|
20
|
+
export function skills(directory) {
|
|
21
21
|
const root = resolveSkillsRoot(directory);
|
|
22
22
|
const diagnostics = [];
|
|
23
23
|
const loaded = loadSkillsFromDirectory(root, diagnostics);
|
|
24
24
|
const listed = Object.values(loaded);
|
|
25
|
-
const id =
|
|
25
|
+
const id = `skills:${basename(root)}`;
|
|
26
26
|
if (listed.length === 0) {
|
|
27
27
|
return { id, root, diagnostics };
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
id,
|
|
32
|
-
root,
|
|
33
|
-
instructions: [
|
|
34
|
-
SKILLS_USAGE,
|
|
35
|
-
formatSkillCatalog(listed.map((skill) => ({
|
|
36
|
-
name: skill.name,
|
|
37
|
-
description: skill.description,
|
|
38
|
-
}))),
|
|
39
|
-
],
|
|
40
|
-
skills: skillManifest,
|
|
41
|
-
skillFiles,
|
|
42
|
-
diagnostics,
|
|
43
|
-
};
|
|
29
|
+
return { id, root, ...skillsDeclaration(listed), diagnostics };
|
|
44
30
|
}
|
|
45
|
-
/**
|
|
46
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The manifest's skills and the bytes behind their files. A plugin's skills carry its label, so
|
|
33
|
+
* a tool call can be traced to the plugin that brought the skill.
|
|
34
|
+
*/
|
|
35
|
+
export function skillsDeclaration(listed, plugin) {
|
|
47
36
|
return {
|
|
48
37
|
skills: Object.fromEntries(listed.map((skill) => [
|
|
49
38
|
skill.name,
|
|
50
|
-
{
|
|
39
|
+
{
|
|
40
|
+
name: skill.name,
|
|
41
|
+
description: skill.description,
|
|
42
|
+
files: skill.files,
|
|
43
|
+
...(plugin === undefined ? {} : { plugin }),
|
|
44
|
+
},
|
|
51
45
|
])),
|
|
52
46
|
skillFiles: Object.assign({}, ...listed.map((skill) => skill.sources)),
|
|
53
47
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0-beta",
|
|
4
4
|
"description": "Nylorun agent definitions and session client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"test": "vitest run --passWithNoTests"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@nylorun/core": "0.
|
|
46
|
+
"@nylorun/core": "0.21.0-beta",
|
|
47
47
|
"gray-matter": "^4.0.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"zod": "^4.6.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/node": "^
|
|
53
|
+
"@types/node": "^26.6.4",
|
|
54
54
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
55
55
|
"vitest": "^5.0.2"
|
|
56
56
|
},
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"repository": {
|
|
61
61
|
"type": "git",
|
|
62
62
|
"url": "git+https://github.com/nylorun/agents.git",
|
|
63
|
-
"directory": "agents"
|
|
63
|
+
"directory": "sdks/agents"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public",
|
package/dist/sandboxes.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sandboxes as a resource (Host feature `sandboxes`): `client.sandboxes`. A sandbox has its own
|
|
3
|
-
* id and outlives the sessions attached to it; whether it serves one session, one person or a
|
|
4
|
-
* project is the app's choice, made here:
|
|
5
|
-
*
|
|
6
|
-
* - `sandboxes.forSession(...)`: one sandbox for one session. It creates the sandbox, opens the
|
|
7
|
-
* session attached to it, and `release()` deletes the sandbox when the session is done. It
|
|
8
|
-
* replaces sharing through another session (`sandbox: { session }`, `sandboxOwnerId`).
|
|
9
|
-
* - `sandboxes.ensure(id, spec)`: one sandbox per person or per project, by a deterministic id
|
|
10
|
-
* (`user-42`, `team-a/proj-42`); get-or-create in one call. Attach sessions to it with
|
|
11
|
-
* `createSession({ sandbox: { id } })`.
|
|
12
|
-
*
|
|
13
|
-
* Ids may hold `/`; they are sent percent-encoded as one path segment.
|
|
14
|
-
*/
|
|
15
|
-
import { type DeleteSandboxResponse, type PutSandboxRequest, type SandboxEvent, type SandboxView } from "@nylorun/core/contracts";
|
|
16
|
-
import { type Transport } from "./http.js";
|
|
17
|
-
import type { CreateSessionOptions, SessionClient } from "./session-client.js";
|
|
18
|
-
/** What a sandbox is made of: fixed once it exists, except its labels. */
|
|
19
|
-
export type SandboxSpec = Omit<PutSandboxRequest, "requestId">;
|
|
20
|
-
/** A session opened on a sandbox of its own (`sandboxes.forSession`). */
|
|
21
|
-
export interface SessionSandboxHandle {
|
|
22
|
-
readonly session: SessionClient;
|
|
23
|
-
readonly sandbox: SandboxView;
|
|
24
|
-
/** Deletes the sandbox and its files; call it when the session is done. */
|
|
25
|
-
release(options?: {
|
|
26
|
-
signal?: AbortSignal;
|
|
27
|
-
}): Promise<DeleteSandboxResponse>;
|
|
28
|
-
}
|
|
29
|
-
export interface ForSessionOptions {
|
|
30
|
-
/** The session to open, as `createSession` takes it, without `sandbox`. */
|
|
31
|
-
readonly session: Omit<CreateSessionOptions, "sandbox">;
|
|
32
|
-
/** The sandbox's spec and labels. Default: a virtual sandbox within the Tenant's defaults. */
|
|
33
|
-
readonly spec?: SandboxSpec;
|
|
34
|
-
/** The sandbox's id. Default: `sessions/<session id>`. */
|
|
35
|
-
readonly sandboxId?: string;
|
|
36
|
-
readonly signal?: AbortSignal;
|
|
37
|
-
}
|
|
38
|
-
export declare class SandboxesClient {
|
|
39
|
-
private readonly transport;
|
|
40
|
-
/** `AgentsClient.createSession`, bound. */
|
|
41
|
-
private readonly createSession;
|
|
42
|
-
constructor(transport: Transport,
|
|
43
|
-
/** `AgentsClient.createSession`, bound. */
|
|
44
|
-
createSession: (options: CreateSessionOptions) => Promise<SessionClient>);
|
|
45
|
-
private path;
|
|
46
|
-
/**
|
|
47
|
-
* Creates the sandbox, or finds the one with this id (`PUT /v1/sandboxes/{id}`). Its spec is
|
|
48
|
-
* fixed once it exists: a different one is a 409. Labels, when given, replace its labels.
|
|
49
|
-
*/
|
|
50
|
-
ensure(sandboxId: string, spec?: SandboxSpec, options?: {
|
|
51
|
-
signal?: AbortSignal;
|
|
52
|
-
}): Promise<SandboxView>;
|
|
53
|
-
get(sandboxId: string, options?: {
|
|
54
|
-
signal?: AbortSignal;
|
|
55
|
-
}): Promise<SandboxView>;
|
|
56
|
-
/** The sandboxes with every label in `labels` that this client reaches. */
|
|
57
|
-
list(options?: {
|
|
58
|
-
labels?: Readonly<Record<string, string>>;
|
|
59
|
-
signal?: AbortSignal;
|
|
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
|
-
}>;
|
|
90
|
-
/** Deletes the sandbox and its files; `deleted` is false when there was none. */
|
|
91
|
-
delete(sandboxId: string, options?: {
|
|
92
|
-
signal?: AbortSignal;
|
|
93
|
-
}): Promise<DeleteSandboxResponse>;
|
|
94
|
-
/** The sandbox's lifecycle events, from `from` on. */
|
|
95
|
-
events(sandboxId: string, options?: {
|
|
96
|
-
from?: number;
|
|
97
|
-
signal?: AbortSignal;
|
|
98
|
-
}): Promise<SandboxEvent[]>;
|
|
99
|
-
/**
|
|
100
|
-
* One sandbox for one session: creates the sandbox (`sessions/<session id>` unless
|
|
101
|
-
* `sandboxId` names another), opens the session attached to it, and returns both with
|
|
102
|
-
* `release()`, which deletes the sandbox. If the session cannot be opened, the sandbox is
|
|
103
|
-
* deleted again.
|
|
104
|
-
*/
|
|
105
|
-
forSession(options: ForSessionOptions): Promise<SessionSandboxHandle>;
|
|
106
|
-
}
|