@nylorun/core 0.23.0-beta → 0.25.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 +37 -0
- package/dist/compatibility.d.ts +127 -59
- package/dist/compatibility.js +128 -60
- package/dist/contracts.d.ts +2413 -893
- package/dist/contracts.js +1144 -491
- package/dist/define.d.ts +1 -0
- package/dist/define.js +1 -0
- package/dist/definition/approval.d.ts +1 -1
- package/dist/definition/bound.d.ts +2 -0
- package/dist/definition/builder.d.ts +2 -2
- package/dist/definition/builder.js +1 -1
- package/dist/definition/code-tools.d.ts +1 -1
- package/dist/definition/declaration.js +3 -0
- package/dist/definition/delegate.d.ts +1 -1
- package/dist/definition/delegate.js +1 -1
- package/dist/definition/from.d.ts +2 -2
- package/dist/definition/from.js +1 -1
- package/dist/definition/http-tool.d.ts +3 -3
- package/dist/definition/mcp.d.ts +4 -4
- package/dist/definition/mcp.js +3 -3
- package/dist/definition/removed.d.ts +7 -0
- package/dist/definition/removed.js +21 -1
- package/dist/definition/sections.d.ts +64 -0
- package/dist/definition/sections.js +227 -0
- package/dist/definition/variant.d.ts +1 -1
- package/dist/definition/variant.js +4 -4
- package/dist/harness-api/entries.d.ts +1 -1
- package/dist/harness-api/entries.js +1 -1
- package/dist/harness-api/gates.d.ts +1 -1
- package/dist/harness-api/gates.js +1 -1
- package/dist/harness-api/harness-api.schema.json +182 -6
- package/dist/harness-api/index.d.ts +3 -3
- package/dist/harness-api/index.js +3 -3
- package/dist/harness-api/json-schema.d.ts +1 -1
- package/dist/harness-api/json-schema.js +3 -3
- package/dist/harness-api/mcp.js +1 -1
- package/dist/harness-api/messages.d.ts +10 -8
- package/dist/harness-api/messages.js +1 -1
- package/dist/harness-api/schema.d.ts +82 -13
- package/dist/harness-api/schema.js +63 -19
- package/dist/harness-api/transcript.d.ts +1 -1
- package/dist/harness-api/transport.d.ts +1 -1
- package/dist/harness-api/transport.js +1 -1
- package/dist/manifest-schemas.d.ts +9 -5
- package/dist/manifest-schemas.js +24 -27
- package/dist/schemas/agent-manifest.schema.json +1534 -250
- package/dist/schemas/harness-manifest.schema.json +1273 -0
- package/dist/schemas/{environment-manifest.schema.json → runtime-manifest.schema.json} +109 -68
- package/dist/types/manifest.d.ts +87 -15
- package/dist/types/manifest.js +4 -0
- package/dist/types/model.d.ts +5 -0
- package/dist/types/observe.d.ts +1 -1
- package/dist/types/part.d.ts +5 -0
- package/dist/types/tool.d.ts +4 -4
- package/dist/utils/definition-files.d.ts +3 -2
- package/dist/utils/definition-files.js +4 -3
- package/dist/utils/file-systems.d.ts +1 -1
- package/dist/utils/file-systems.js +1 -1
- package/dist/utils/harness-id.d.ts +1 -1
- package/dist/utils/harness-id.js +1 -1
- package/dist/utils/memory.d.ts +64 -0
- package/dist/utils/memory.js +139 -0
- package/dist/utils/runtime-limits.d.ts +55 -4
- package/dist/utils/runtime-limits.js +106 -3
- package/dist/utils/runtime-tools.d.ts +3 -3
- package/dist/utils/runtime-tools.js +3 -3
- package/package.json +6 -5
|
@@ -81,6 +81,13 @@ export const EffectTargetSchema = z.discriminatedUnion("kind", [
|
|
|
81
81
|
z.object({ kind: z.literal("http"), tool: z.string().min(1) }).strict(),
|
|
82
82
|
z.object({ kind: z.literal("sandbox") }).strict(),
|
|
83
83
|
z.object({ kind: z.literal("harness") }).strict(),
|
|
84
|
+
/**
|
|
85
|
+
* An operation the Runtime itself serves, in the transaction that journals the call, keyed by
|
|
86
|
+
* the effect id: `schedule_wake` books the session's next turn; `memory` is a
|
|
87
|
+
* call of the `memory` tool, with Anthropic's memory tool parameters as its input,
|
|
88
|
+
* on the Agent's memories. Answered at once; the harness never executes it.
|
|
89
|
+
*/
|
|
90
|
+
z.object({ kind: z.literal("runtime"), operation: z.enum(["schedule_wake", "memory"]) }).strict(),
|
|
84
91
|
]);
|
|
85
92
|
/**
|
|
86
93
|
* One effect the engine asks for: a `HostEffect`, by structure. Model intents carry no `input`.
|
|
@@ -181,7 +188,7 @@ export const WorkspaceCallSchema = z
|
|
|
181
188
|
})
|
|
182
189
|
.strict();
|
|
183
190
|
/**
|
|
184
|
-
* One operation on the disk of a workspace
|
|
191
|
+
* One operation on the disk of a workspace: `list` its entries (files with mode and
|
|
185
192
|
* modification time, links, empty directories; paths relative to the volume, `workspace/…` and
|
|
186
193
|
* in a pod `harness/…`), `read` a range of one file (answered `{kind: "read", base64, eof}`),
|
|
187
194
|
* `clear` it (the engine's own files stay), or `put` entries back in order. A `workspace.read`
|
|
@@ -220,7 +227,7 @@ export const DiskOpSchema = z.union([
|
|
|
220
227
|
export const WorkspaceDiskCallSchema = z
|
|
221
228
|
.object({ session: WorkspaceSessionSchema, spec: z.unknown(), disk: DiskOpSchema })
|
|
222
229
|
.strict();
|
|
223
|
-
/** The lease on one run. `token` is the run token
|
|
230
|
+
/** The lease on one run. `token` is the run token when the gates require one. */
|
|
224
231
|
export const RunGrantSchema = z
|
|
225
232
|
.object({
|
|
226
233
|
runId: id,
|
|
@@ -247,7 +254,7 @@ export const RunRoutingSchema = z
|
|
|
247
254
|
environmentId: id.optional(),
|
|
248
255
|
spec: z.unknown().optional(),
|
|
249
256
|
/**
|
|
250
|
-
* Variables every sandbox command gets
|
|
257
|
+
* Variables every sandbox command gets: each `environment_secret` name set to
|
|
251
258
|
* the sentinel `nylorun_managed`, and each `environment_variable`'s value. Never a secret.
|
|
252
259
|
*/
|
|
253
260
|
environment: z.record(z.string(), z.string()).optional(),
|
|
@@ -257,10 +264,12 @@ export const RunRoutingSchema = z
|
|
|
257
264
|
})
|
|
258
265
|
.strict();
|
|
259
266
|
/**
|
|
260
|
-
* The fields of `TurnStart.checkpoint` a harness reads
|
|
267
|
+
* The fields of `TurnStart.checkpoint` a harness reads; the rest are our engine's. An
|
|
261
268
|
* agent turn's `input` is the turn's message: a string, `{text, metadata?}`, `{content,
|
|
262
|
-
* metadata?}` with user content parts, `{kind: "
|
|
263
|
-
*
|
|
269
|
+
* metadata?}` with user content parts, `{kind: "messages", messages}` for messages that waited in
|
|
270
|
+
* the session's queue (protocol 17: each one of the shapes before, each its own user message, in
|
|
271
|
+
* order), `{kind: "continue"}` for the next segment of a yielded turn, or an approval or response
|
|
272
|
+
* event. Effect ids are prefixed `<turnId>:<segment>:`
|
|
264
273
|
* (`effectIdOf`), and every intent carries `manifestHash`. `state` is the harness's own, as its
|
|
265
274
|
* last output left it: core stores it unread (at most `limits.harnessStateBytes` for a harness
|
|
266
275
|
* other than ours) and folds the transcript every segment, whatever the state holds. A model
|
|
@@ -300,16 +309,38 @@ export const ModelDescriptorSchema = z
|
|
|
300
309
|
})
|
|
301
310
|
.strict();
|
|
302
311
|
/**
|
|
303
|
-
* The
|
|
312
|
+
* The Agent a turn runs on (Harness API 5, protocol 16): its id and kind and, when it has a
|
|
304
313
|
* sandbox, the workspace its commands start in. A harness writes the model's instructions and
|
|
305
314
|
* defines its sandbox tools from it; the sandbox's spec is the routing's (`routing.sandbox.spec`).
|
|
315
|
+
* The Agent's runtime section never reaches the harness.
|
|
306
316
|
*/
|
|
307
|
-
export const
|
|
317
|
+
export const TurnAgentSchema = z
|
|
308
318
|
.object({
|
|
309
319
|
id,
|
|
310
320
|
kind: z.enum(ENVIRONMENT_KINDS),
|
|
311
321
|
/** Present when the session has a sandbox. */
|
|
312
322
|
sandbox: z.object({ workspace: z.string().regex(/^\//) }).strict().optional(),
|
|
323
|
+
/**
|
|
324
|
+
* The version the session runs sets `runtime.selfWake`: our engine offers
|
|
325
|
+
* `schedule_wake`, a `runtime` effect.
|
|
326
|
+
*/
|
|
327
|
+
selfWake: z.boolean().optional(),
|
|
328
|
+
})
|
|
329
|
+
.strict();
|
|
330
|
+
/**
|
|
331
|
+
* The Agent's memory as a turn starts, present when the version its session runs
|
|
332
|
+
* sets `harness.memory`: its access in every turn, the agent's own `instructions`, and the index a
|
|
333
|
+
* harness pins in the session (one line per memory, newest first, with its description, within
|
|
334
|
+
* the Runtime limits `memoryIndexLines` and `memoryIndexBytes`; `truncated` when some were left
|
|
335
|
+
* out). A harness offers the `memory` tool (a `runtime` effect, operation `memory`), view only for
|
|
336
|
+
* `read_only` and for its sub-agents.
|
|
337
|
+
*/
|
|
338
|
+
export const TurnMemorySchema = z
|
|
339
|
+
.object({
|
|
340
|
+
access: z.enum(["read_write", "read_only"]),
|
|
341
|
+
instructions: z.string().optional(),
|
|
342
|
+
index: z.string(),
|
|
343
|
+
truncated: z.boolean(),
|
|
313
344
|
})
|
|
314
345
|
.strict();
|
|
315
346
|
/** What a run starts from: `turn.start` (message, continue, resume) or `approval.answer`. */
|
|
@@ -317,8 +348,21 @@ export const TurnStartSchema = z
|
|
|
317
348
|
.object({
|
|
318
349
|
type: z.enum(["turn.start", "approval.answer"]),
|
|
319
350
|
engine: z.enum(["agent", "flow"]),
|
|
320
|
-
/**
|
|
351
|
+
/**
|
|
352
|
+
* The turn's loop manifest: the harness section of the agent manifest version its session
|
|
353
|
+
* pinned, with the manifest's name as its `id` (agent manifest v7's shape), or the workflow
|
|
354
|
+
* manifest (flow). A flow's leaf session gets its embedded agent's.
|
|
355
|
+
*/
|
|
321
356
|
manifest: document,
|
|
357
|
+
/** The agent manifest version the session pinned (protocol 16), for the harness's records. */
|
|
358
|
+
definition: z.object({ name: z.string(), version: z.number().int().positive() }).strict().optional(),
|
|
359
|
+
/**
|
|
360
|
+
* The harness section's `loop` (protocol 16): the harness's own settings, which the Runtime
|
|
361
|
+
* passes on without reading. Ours reads none yet.
|
|
362
|
+
*/
|
|
363
|
+
loop: document.optional(),
|
|
364
|
+
/** The Agent's memory, when the version its session runs sets `harness.memory`. Absent for a flow. */
|
|
365
|
+
memory: TurnMemorySchema.optional(),
|
|
322
366
|
/** The segment's checkpoint; an agent's state has no transcript (`transcript.cursor`). */
|
|
323
367
|
checkpoint: document,
|
|
324
368
|
/**
|
|
@@ -338,14 +382,14 @@ export const TurnStartSchema = z
|
|
|
338
382
|
flowLimits: z.unknown().optional(),
|
|
339
383
|
/**
|
|
340
384
|
* Informational: the Tenant answers model calls with the fixture model. The Model Gate
|
|
341
|
-
* answers them itself
|
|
385
|
+
* answers them itself, so a harness calls the gate as for any model.
|
|
342
386
|
*/
|
|
343
387
|
fixtureModel: z.boolean(),
|
|
344
388
|
})
|
|
345
389
|
.strict(),
|
|
346
390
|
routing: RunRoutingSchema,
|
|
347
391
|
/**
|
|
348
|
-
* The turn's trace context
|
|
392
|
+
* The turn's trace context, when the Runtime traces: a harness may send it as
|
|
349
393
|
* `traceparent` on its gate calls and as `TRACEPARENT` to the processes it starts, so its own
|
|
350
394
|
* spans join the turn's trace. The Runtime never ingests a harness's spans.
|
|
351
395
|
*/
|
|
@@ -364,10 +408,10 @@ export const TurnStartSchema = z
|
|
|
364
408
|
*/
|
|
365
409
|
model: ModelDescriptorSchema.optional(),
|
|
366
410
|
/**
|
|
367
|
-
* The
|
|
368
|
-
* and defines the sandbox tools from. Absent
|
|
411
|
+
* The Agent the session runs on (Harness API 5; `environment` before): what our engine writes
|
|
412
|
+
* the sandbox notes and defines the sandbox tools from. Absent for a flow.
|
|
369
413
|
*/
|
|
370
|
-
|
|
414
|
+
agent: TurnAgentSchema.optional(),
|
|
371
415
|
})
|
|
372
416
|
.strict();
|
|
373
417
|
/**
|
|
@@ -405,7 +449,7 @@ export const IntentAnswerSchema = z.union([
|
|
|
405
449
|
status: z.literal("execute"),
|
|
406
450
|
rejoin: z.literal(true).optional(),
|
|
407
451
|
/**
|
|
408
|
-
* The call's span context
|
|
452
|
+
* The call's span context, for a tool call: a harness hands it on as `TRACEPARENT`
|
|
409
453
|
* to the command it runs, so the command's own spans join the call's.
|
|
410
454
|
*/
|
|
411
455
|
traceparent: TraceContextSchema.shape.traceparent.optional(),
|
|
@@ -422,7 +466,7 @@ const outcomeObject = z.record(z.string(), z.unknown());
|
|
|
422
466
|
/** Requests a harness sends to core, with their answers. */
|
|
423
467
|
export const harnessRequests = {
|
|
424
468
|
/**
|
|
425
|
-
* `features.workspace` declares that the harness serves the Tenant's workspaces
|
|
469
|
+
* `features.workspace` declares that the harness serves the Tenant's workspaces:
|
|
426
470
|
* core then sends it the `workspace.*` requests. The answer names the Tenant (its workspace
|
|
427
471
|
* keys are scoped by it) and the sandbox backend preference the harness selects with.
|
|
428
472
|
*/
|
|
@@ -493,7 +537,7 @@ export const harnessRequests = {
|
|
|
493
537
|
result: z.object({ mcp: McpFactsSchema.optional() }).strict(),
|
|
494
538
|
},
|
|
495
539
|
/**
|
|
496
|
-
* A definition file's bytes, base64
|
|
540
|
+
* A definition file's bytes, base64: one the run's definition names, for the
|
|
497
541
|
* skills its sandbox mounts. With `offset` and `length` (at most `turn.start.limits.chunkBytes`,
|
|
498
542
|
* its default without `length`; more is `limit_exceeded`), only those bytes: fewer than
|
|
499
543
|
* `length`, none past the end, once the file ends. Without them the whole file, which must then
|
|
@@ -634,7 +678,7 @@ export const harnessRequests = {
|
|
|
634
678
|
z
|
|
635
679
|
.object({
|
|
636
680
|
status: z.literal("refused"),
|
|
637
|
-
/** The total a folder version would pass: the Tenant's, or the session's
|
|
681
|
+
/** The total a folder version would pass: the Tenant's, or the session's Agent's. */
|
|
638
682
|
reason: z.enum(["tenant_total", "environment_total"]),
|
|
639
683
|
message: z.string(),
|
|
640
684
|
limit: z.number().int().nonnegative(),
|
|
@@ -651,7 +695,7 @@ export const harnessRequests = {
|
|
|
651
695
|
checkpoint: { params: TurnOutputSchema, result: settled },
|
|
652
696
|
};
|
|
653
697
|
/**
|
|
654
|
-
* Requests core sends to a harness that declared `workspace
|
|
698
|
+
* Requests core sends to a harness that declared `workspace`, with their answers. A
|
|
655
699
|
* sandbox tool's answer is its `SandboxToolOutcome`; the harness claims its `environment.*` events
|
|
656
700
|
* while the request is in flight.
|
|
657
701
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Transcript edits
|
|
2
|
+
* Transcript edits: a segment's transcript changes are recorded as
|
|
3
3
|
* `transcript.updated` events, each an edit of the transcript before it. Shared by core, which
|
|
4
4
|
* records and folds them, and a harness, which computes them and keeps its cache with them.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* How a harness reaches core
|
|
2
|
+
* How a harness reaches core. Three version numbers apply, and each moves on its own:
|
|
3
3
|
*
|
|
4
4
|
* - the transport: path `/nylorun/harness/v1` and header `Nylorun-Harness-Api: 1`, for the
|
|
5
5
|
* WebSocket and its frames (`FrameSchema`), one JSON text message per frame;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* How a harness reaches core
|
|
2
|
+
* How a harness reaches core. Three version numbers apply, and each moves on its own:
|
|
3
3
|
*
|
|
4
4
|
* - the transport: path `/nylorun/harness/v1` and header `Nylorun-Harness-Api: 1`, for the
|
|
5
5
|
* WebSocket and its frames (`FrameSchema`), one JSON text message per frame;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Agent manifest v8's JSON Schema document (protocol 16): the authoring form, whose `harness`
|
|
3
|
+
* and `runtime` may each be a path to an authoring file, as `agent.manifest.json` is written.
|
|
4
|
+
* What the API receives has both sections written out (`AgentManifestV8Schema`).
|
|
5
|
+
*/
|
|
6
6
|
export declare function agentManifestJsonSchema(): Record<string, unknown>;
|
|
7
|
+
/** `harness.manifest.json`'s JSON Schema document: the harness section as an authoring file. */
|
|
8
|
+
export declare function harnessManifestJsonSchema(): Record<string, unknown>;
|
|
9
|
+
/** `runtime.manifest.json`'s JSON Schema document: the runtime section as an authoring file. */
|
|
10
|
+
export declare function runtimeManifestJsonSchema(): Record<string, unknown>;
|
package/dist/manifest-schemas.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* generated from the zod schemas the Runtime
|
|
4
|
-
* from its `$schema` and a client in another language validates what core
|
|
5
|
-
* writes them to `dist/schemas
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
2
|
+
* Agent manifest v8 and its two authoring files as JSON Schema documents (protocol 16),
|
|
3
|
+
* generated from the zod schemas the Runtime and the composer validate with, so an editor checks
|
|
4
|
+
* a manifest file from its `$schema` and a client in another language validates what core
|
|
5
|
+
* enforces. The build writes them to `dist/schemas/`: `@nylorun/core/schemas/agent-manifest.json`
|
|
6
|
+
* (`agent.manifest.json`, whose sections may be paths), `harness-manifest.json` and
|
|
7
|
+
* `runtime-manifest.json`. Each allows a top-level `$schema`, which the composer drops before it
|
|
8
|
+
* saves: the Runtime's own schemas stay strict. A runtime file's `files` also allow `{ path,
|
|
9
|
+
* from }`, a folder beside the file the composer hashes into `{ path, files }`. A published `$id`
|
|
10
|
+
* keeps its content but for descriptions: a change takes a new version (`published-schemas.test.ts`).
|
|
10
11
|
*/
|
|
11
12
|
import { z } from "zod";
|
|
12
|
-
import {
|
|
13
|
-
/** The agent manifest version these documents describe. */
|
|
14
|
-
export const AGENT_MANIFEST_SCHEMA_VERSION = 7;
|
|
13
|
+
import { AGENT_MANIFEST_V8_SCHEMA_VERSION, AgentManifestFileSchema, HARNESS_MANIFEST_FILE_SCHEMA_VERSION, HarnessManifestFileSchema, RUNTIME_MANIFEST_FILE_SCHEMA_VERSION, RuntimeManifestFileSchema, } from "./contracts.js";
|
|
15
14
|
function document(schema, id, title) {
|
|
16
15
|
const { $schema: _, ...definition } = z.toJSONSchema(schema, { io: "input", unrepresentable: "any" });
|
|
17
16
|
const properties = (definition.properties ?? {});
|
|
@@ -26,21 +25,19 @@ function document(schema, id, title) {
|
|
|
26
25
|
},
|
|
27
26
|
};
|
|
28
27
|
}
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
shapes.push({
|
|
35
|
-
type: "object",
|
|
36
|
-
description: "For the CLI only: a folder, relative to this file, that `nylorun environments manifests save` uploads by hash and saves as { path, files }",
|
|
37
|
-
properties: { path: tree?.properties.path, from: { type: "string", minLength: 1 } },
|
|
38
|
-
required: ["path", "from"],
|
|
39
|
-
additionalProperties: false,
|
|
40
|
-
});
|
|
41
|
-
return schema;
|
|
42
|
-
}
|
|
43
|
-
/** The agent manifest's JSON Schema document (draft 2020-12). */
|
|
28
|
+
/**
|
|
29
|
+
* Agent manifest v8's JSON Schema document (protocol 16): the authoring form, whose `harness`
|
|
30
|
+
* and `runtime` may each be a path to an authoring file, as `agent.manifest.json` is written.
|
|
31
|
+
* What the API receives has both sections written out (`AgentManifestV8Schema`).
|
|
32
|
+
*/
|
|
44
33
|
export function agentManifestJsonSchema() {
|
|
45
|
-
return document(
|
|
34
|
+
return document(AgentManifestFileSchema, `agent-manifest/v${AGENT_MANIFEST_V8_SCHEMA_VERSION}`, `Nylorun agent manifest ${AGENT_MANIFEST_V8_SCHEMA_VERSION}`);
|
|
35
|
+
}
|
|
36
|
+
/** `harness.manifest.json`'s JSON Schema document: the harness section as an authoring file. */
|
|
37
|
+
export function harnessManifestJsonSchema() {
|
|
38
|
+
return document(HarnessManifestFileSchema, `harness-manifest/v${HARNESS_MANIFEST_FILE_SCHEMA_VERSION}`, `Nylorun harness manifest ${HARNESS_MANIFEST_FILE_SCHEMA_VERSION}`);
|
|
39
|
+
}
|
|
40
|
+
/** `runtime.manifest.json`'s JSON Schema document: the runtime section as an authoring file. */
|
|
41
|
+
export function runtimeManifestJsonSchema() {
|
|
42
|
+
return document(RuntimeManifestFileSchema, `runtime-manifest/v${RUNTIME_MANIFEST_FILE_SCHEMA_VERSION}`, `Nylorun runtime manifest ${RUNTIME_MANIFEST_FILE_SCHEMA_VERSION}`);
|
|
46
43
|
}
|