@nylorun/core 0.19.0-beta → 0.20.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/dist/compatibility.d.ts +74 -32
  3. package/dist/compatibility.js +80 -33
  4. package/dist/contracts.d.ts +1496 -495
  5. package/dist/contracts.js +889 -374
  6. package/dist/define.d.ts +1 -0
  7. package/dist/define.js +1 -0
  8. package/dist/definition/approval.d.ts +16 -0
  9. package/dist/definition/approval.js +35 -0
  10. package/dist/definition/code-tools.d.ts +1 -1
  11. package/dist/definition/code-tools.js +1 -1
  12. package/dist/definition/flow/compile.js +0 -2
  13. package/dist/definition/http-tool.d.ts +7 -4
  14. package/dist/definition/http-tool.js +6 -10
  15. package/dist/definition/manifest.js +1 -0
  16. package/dist/definition/mcp.d.ts +4 -4
  17. package/dist/definition/mcp.js +15 -12
  18. package/dist/definition/removed.js +1 -1
  19. package/dist/definition/variant.d.ts +1 -1
  20. package/dist/definition/variant.js +6 -5
  21. package/dist/harness-api/entries.d.ts +241 -0
  22. package/dist/harness-api/entries.js +117 -0
  23. package/dist/harness-api/gates.d.ts +172 -0
  24. package/dist/harness-api/gates.js +119 -0
  25. package/dist/harness-api/harness-api.schema.json +5056 -0
  26. package/dist/harness-api/index.d.ts +19 -3
  27. package/dist/harness-api/index.js +16 -3
  28. package/dist/harness-api/json-schema.d.ts +12 -0
  29. package/dist/harness-api/json-schema.js +61 -0
  30. package/dist/harness-api/mcp.d.ts +61 -0
  31. package/dist/harness-api/mcp.js +41 -0
  32. package/dist/harness-api/messages.d.ts +12 -4
  33. package/dist/harness-api/messages.js +6 -2
  34. package/dist/harness-api/schema.d.ts +353 -31
  35. package/dist/harness-api/schema.js +138 -20
  36. package/dist/harness-api/transport.d.ts +55 -0
  37. package/dist/harness-api/transport.js +61 -0
  38. package/dist/types/manifest.d.ts +15 -9
  39. package/dist/types/observe.d.ts +3 -2
  40. package/dist/utils/harness-id.d.ts +9 -0
  41. package/dist/utils/harness-id.js +11 -0
  42. package/package.json +5 -4
@@ -9,6 +9,7 @@ import { ABORT_REASONS, HARNESS_API_VERSION, HARNESS_CLAIMS, HARNESS_ERROR_CODES
9
9
  import { HarnessApiError } from "./errors.js";
10
10
  import { EffectOutcomeSchema } from "../contracts.js";
11
11
  import { SANDBOX_TOOL_NAMES } from "../utils/sandbox.js";
12
+ import { McpSnapshotSchema } from "./mcp.js";
12
13
  const id = z.string().min(1).max(512);
13
14
  const runId = z.object({ runId: id });
14
15
  /** An engine document (a manifest, a checkpoint): an object here, which the engine checks. */
@@ -32,7 +33,17 @@ export const FrameSchema = z.union([
32
33
  z.object({ t: z.literal("abort"), id: z.number().int().positive() }).strict(),
33
34
  z.object({ t: z.literal("ping") }).strict(),
34
35
  ]);
35
- /** One effect the engine asks for: a `HostEffect`, by structure. Model intents carry no `input`. */
36
+ /**
37
+ * One effect the engine asks for: a `HostEffect`, by structure. Model intents carry no `input`.
38
+ * `context` carries the ids the record derives its events from: a model effect's
39
+ * `invocationId` (the step), and a tool effect's `callId` (the model's tool call id) and
40
+ * `invocationId`; without them the call is journaled but no `tool.completed` is written. A
41
+ * tool effect may name its step (`stepId`), which shares one result budget among its calls.
42
+ *
43
+ * `requestHash` (`effectRequestHash`) covers the whole request: for a model effect, the intent
44
+ * with `input` set to its `ModelCall`, though the intent is sent without it. A replay that asks
45
+ * for the same id with another hash is `effect_drift`.
46
+ */
36
47
  export const EffectIntentSchema = z
37
48
  .object({
38
49
  effectId: id,
@@ -60,7 +71,7 @@ export const WorkspaceRecordSchema = z
60
71
  .object({
61
72
  key: z.string().min(1).max(512),
62
73
  sessionId: id,
63
- sandboxId: id.optional(),
74
+ environmentId: id.optional(),
64
75
  backend: z.string(),
65
76
  image: z.string(),
66
77
  state: z.enum(["creating", "running", "stopped"]),
@@ -68,12 +79,12 @@ export const WorkspaceRecordSchema = z
68
79
  updatedAt: z.string(),
69
80
  })
70
81
  .strict();
71
- /** The session a workspace request acts for: the workspace's owner and its sandbox resource. */
82
+ /** The session a workspace request acts for, and the Environment whose workspace it is. */
72
83
  export const WorkspaceSessionSchema = z
73
84
  .object({
74
- /** The session that owns the workspace: its log records the workspace's events. */
85
+ /** The session the request acts for: its log records the workspace's events. */
75
86
  ownerId: id,
76
- sandboxId: id.optional(),
87
+ environmentId: id.optional(),
77
88
  activeTurnId: id.nullable(),
78
89
  })
79
90
  .strict();
@@ -111,6 +122,46 @@ export const WorkspaceListCallSchema = z
111
122
  list: z.object({ dir: z.string().min(1), maxEntries: z.number().int().positive() }).strict(),
112
123
  })
113
124
  .strict();
125
+ /**
126
+ * One operation on the disk of a workspace (R2d step 3): `list` its entries (files with mode and
127
+ * modification time, links, empty directories; paths relative to the volume, `workspace/…` and
128
+ * in a pod `harness/…`), `read` a range of one file (answered `{kind: "read", base64, eof}`),
129
+ * `clear` it (the engine's own files stay), or `put` entries back in order. A `workspace.read`
130
+ * carries `list` or `read`; a `workspace.write` `clear` or `put`.
131
+ */
132
+ export const DiskOpSchema = z.union([
133
+ z.object({ list: z.object({ maxEntries: z.number().int().positive() }).strict() }).strict(),
134
+ z
135
+ .object({
136
+ read: z
137
+ .object({
138
+ path: z.string().min(1),
139
+ offset: z.number().int().nonnegative(),
140
+ length: z.number().int().positive().max(16 * 1024 * 1024),
141
+ })
142
+ .strict(),
143
+ })
144
+ .strict(),
145
+ z.object({ clear: z.literal(true) }).strict(),
146
+ z
147
+ .object({
148
+ put: z.array(z
149
+ .object({
150
+ path: z.string().min(1),
151
+ type: z.enum(["file", "dir", "link"]),
152
+ mode: z.number().int().nonnegative().optional(),
153
+ mtimeMs: z.number().nonnegative().optional(),
154
+ base64: z.string().optional(),
155
+ append: z.boolean().optional(),
156
+ target: z.string().optional(),
157
+ })
158
+ .strict()),
159
+ })
160
+ .strict(),
161
+ ]);
162
+ export const WorkspaceDiskCallSchema = z
163
+ .object({ session: WorkspaceSessionSchema, spec: z.unknown(), disk: DiskOpSchema })
164
+ .strict();
114
165
  /** The lease on one run. `token` is the run token (F5) when the gates require one. */
115
166
  export const RunGrantSchema = z
116
167
  .object({
@@ -127,12 +178,13 @@ export const RunRoutingSchema = z
127
178
  .object({
128
179
  /** The session's pinned manifest: an effect's agent resolves against it. */
129
180
  rootManifest: document,
130
- mcpSnapshot: z.unknown().optional(),
131
- /** The session that owns the tree's sandbox, and the sandbox resource it is attached to. */
181
+ /** The session's MCP snapshot, once its first run recorded one (`session.mcp`). */
182
+ mcpSnapshot: McpSnapshotSchema.optional(),
183
+ /** The session's sandbox: the session, and the Environment whose sandbox it is. */
132
184
  sandbox: z
133
185
  .object({
134
186
  ownerId: id,
135
- sandboxId: id.optional(),
187
+ environmentId: id.optional(),
136
188
  spec: z.unknown().optional(),
137
189
  /**
138
190
  * Variables every sandbox command gets (R2c, D50): each `environment_secret` name set to
@@ -144,6 +196,44 @@ export const RunRoutingSchema = z
144
196
  .optional(),
145
197
  })
146
198
  .strict();
199
+ /**
200
+ * The fields of `TurnStart.checkpoint` a harness reads (R4.2); the rest are our engine's. An
201
+ * agent turn's `input` is the turn's message: a string, `{text, metadata?}`, `{content,
202
+ * metadata?}` with user content parts, `{kind: "continue"}` for the next segment of a yielded
203
+ * turn, or an approval or response event. Effect ids are prefixed `<turnId>:<segment>:`
204
+ * (`effectIdOf`), and every intent carries `manifestHash`. `state` is the harness's own, as its
205
+ * last output left it: core stores it unread (at most `MAX_HARNESS_STATE_BYTES` for a harness
206
+ * other than ours) and folds the transcript every segment, whatever the state holds. A model
207
+ * call's `executionId` is the session id.
208
+ */
209
+ export const HarnessCheckpointSchema = z.looseObject({
210
+ sessionId: id,
211
+ turnId: id,
212
+ segment: z.number().int().min(0),
213
+ manifestHash: z.string(),
214
+ input: z.unknown().optional(),
215
+ state: z.unknown().optional(),
216
+ });
217
+ /** W3C trace context: `traceparent`, and `tracestate` when the trace carries one. */
218
+ export const TraceContextSchema = z
219
+ .object({
220
+ traceparent: z.string().regex(/^[0-9a-f]{2}-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$/),
221
+ tracestate: z.string().max(512).optional(),
222
+ })
223
+ .strict();
224
+ /**
225
+ * A tool a harness runs itself (R4.2, Q3), declared in `hello`: the model may call it, and the
226
+ * harness journals each call as a `tool` effect of capability `harness` (`HARNESS_TOOLS_CAPABILITY`)
227
+ * with intent and outcome, like a sandbox tool, so the log records what really ran. It runs in
228
+ * the harness's own process or pod: the egress gate is its only control.
229
+ */
230
+ export const NativeToolSchema = z
231
+ .object({
232
+ name: z.string().regex(/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/),
233
+ description: z.string().max(4096).optional(),
234
+ inputSchema: z.record(z.string(), z.unknown()),
235
+ })
236
+ .strict();
147
237
  /** What a run starts from: `turn.start` (message, continue, resume) or `approval.answer`. */
148
238
  export const TurnStartSchema = z
149
239
  .object({
@@ -162,15 +252,31 @@ export const TurnStartSchema = z
162
252
  .object({
163
253
  yieldAfter: z.object({ steps: z.number().optional(), ms: z.number().optional() }).strict().optional(),
164
254
  flowLimits: z.unknown().optional(),
255
+ /**
256
+ * Informational: the Tenant answers model calls with the fixture model. The Model Gate
257
+ * answers them itself (R4.3), so a harness calls the gate as for any model.
258
+ */
165
259
  fixtureModel: z.boolean(),
166
260
  })
167
261
  .strict(),
168
262
  routing: RunRoutingSchema,
263
+ /**
264
+ * The turn's trace context (R4.10), when the Runtime traces: a harness may send it as
265
+ * `traceparent` on its gate calls and as `TRACEPARENT` to the processes it starts, so its own
266
+ * spans join the turn's trace. The Runtime never ingests a harness's spans.
267
+ */
268
+ trace: TraceContextSchema.optional(),
169
269
  })
170
270
  .strict();
171
271
  /**
172
- * A segment's end. `state` is the agent's engine state without its transcript; `transcript`
173
- * edits the transcript the segment started from. `thrown` reports an engine that threw.
272
+ * A segment's end. `state` is the harness's state for the next segment (our engine's has no
273
+ * transcript); `transcript` edits the transcript the segment started from. `thrown` reports an
274
+ * engine that threw. The method follows the status: `completed` is `turn.completed`, `failed`
275
+ * and `cancelled` are `turn.failed` (after a cancel, report `cancelled`), `waiting` and
276
+ * `uncertain` are `turn.waiting` (an effect is pending or uncertain), `yielded` is `checkpoint`
277
+ * (the turn goes on in a new segment), `paused` is `turn.paused` (our engine only, in v2). An
278
+ * `execute` answer with `rejoin` re-sends a call its previous owner left running at a gate,
279
+ * same key and body, to join it or collect its outcome.
174
280
  */
175
281
  export const TurnOutputSchema = z
176
282
  .object({
@@ -192,7 +298,17 @@ export const ReleaseReasonSchema = z.enum(["shutdown", "ownership.lost", "connec
192
298
  export const IntentAnswerSchema = z.union([
193
299
  z.object({ status: z.literal("completed"), outcome: EffectOutcomeSchema }).strict(),
194
300
  z.object({ status: z.enum(["pending", "uncertain"]) }).strict(),
195
- z.object({ status: z.literal("execute"), rejoin: z.literal(true).optional() }).strict(),
301
+ z
302
+ .object({
303
+ status: z.literal("execute"),
304
+ rejoin: z.literal(true).optional(),
305
+ /**
306
+ * The call's span context (R7.4), for a tool call: a harness hands it on as `TRACEPARENT`
307
+ * to the command it runs, so the command's own spans join the call's.
308
+ */
309
+ traceparent: TraceContextSchema.shape.traceparent.optional(),
310
+ })
311
+ .strict(),
196
312
  ]);
197
313
  export const OutcomeAnswerSchema = z.union([
198
314
  z.object({ status: z.literal("completed"), outcome: EffectOutcomeSchema }).strict(),
@@ -214,7 +330,9 @@ export const harnessRequests = {
214
330
  api: z.number().int(),
215
331
  name: z.string(),
216
332
  version: z.string(),
217
- capabilities: z.object({ workspace: z.unknown().optional() }).strict(),
333
+ capabilities: z
334
+ .object({ workspace: z.unknown().optional(), tools: z.array(NativeToolSchema).max(64).optional() })
335
+ .strict(),
218
336
  })
219
337
  .strict(),
220
338
  result: z
@@ -264,15 +382,15 @@ export const harnessRequests = {
264
382
  turnId: id.nullable(),
265
383
  type: z.enum(HARNESS_CLAIMS),
266
384
  payload: z.unknown(),
267
- /** With `sandbox.state`: the workspace's compute record as it is now. */
385
+ /** With `environment.state`: the workspace's compute record as it is now. */
268
386
  record: WorkspaceRecordSchema.optional(),
269
387
  })
270
388
  .strict(),
271
389
  result: empty,
272
390
  },
273
391
  "session.mcp": {
274
- params: runId.extend({ snapshot: z.unknown().optional(), diagnostics: z.array(z.unknown()) }).strict(),
275
- result: z.object({ snapshot: z.unknown(), sessionTools: z.array(z.unknown()) }).strict(),
392
+ params: runId.extend({ snapshot: McpSnapshotSchema.optional(), diagnostics: z.array(z.unknown()) }).strict(),
393
+ result: z.object({ snapshot: McpSnapshotSchema.optional(), sessionTools: z.array(z.unknown()) }).strict(),
276
394
  },
277
395
  /**
278
396
  * A definition file's bytes, base64 (track R2 M4): one the run's definition names, for the
@@ -291,16 +409,16 @@ export const harnessRequests = {
291
409
  };
292
410
  /**
293
411
  * Requests core sends to a harness that declared `workspace` (F6.2), with their answers. A
294
- * sandbox tool's answer is its `SandboxToolOutcome`; the harness claims its `sandbox.*` events
412
+ * sandbox tool's answer is its `SandboxToolOutcome`; the harness claims its `environment.*` events
295
413
  * while the request is in flight. `workspace.read` stays generic: F8.2 exports outputs
296
414
  * through it.
297
415
  */
298
416
  export const coreRequests = {
299
417
  "workspace.read": {
300
- params: z.union([WorkspaceCallSchema, WorkspaceBytesCallSchema, WorkspaceListCallSchema]),
418
+ params: z.union([WorkspaceCallSchema, WorkspaceBytesCallSchema, WorkspaceListCallSchema, WorkspaceDiskCallSchema]),
301
419
  result: outcomeObject,
302
420
  },
303
- "workspace.write": { params: WorkspaceCallSchema, result: outcomeObject },
421
+ "workspace.write": { params: z.union([WorkspaceCallSchema, WorkspaceDiskCallSchema]), result: outcomeObject },
304
422
  "workspace.exec": { params: WorkspaceCallSchema, result: outcomeObject },
305
423
  /** The harness's sandbox selection report (`GET /v1/tenant/sandbox`, Tenant status). */
306
424
  "workspace.report": { params: empty, result: outcomeObject },
@@ -309,12 +427,12 @@ export const coreRequests = {
309
427
  params: z.object({ now: z.number().optional() }).strict(),
310
428
  result: z.object({ workspaces: z.array(WorkspaceRecordSchema) }).strict(),
311
429
  },
312
- /** Deletes workspaces with their files: by key, by sandbox resource, or all of them. */
430
+ /** Deletes workspaces with their files: by key, by Environment, or all of them. */
313
431
  "workspace.remove": {
314
432
  params: z
315
433
  .object({
316
434
  keys: z.array(z.string().min(1)).optional(),
317
- sandboxIds: z.array(id).optional(),
435
+ environmentIds: z.array(id).optional(),
318
436
  all: z.literal(true).optional(),
319
437
  })
320
438
  .strict(),
@@ -0,0 +1,55 @@
1
+ /**
2
+ * How a harness reaches core (R4.5). Three version numbers apply, and each moves on its own:
3
+ *
4
+ * - the transport: path `/nylorun/harness/v1` and header `Nylorun-Harness-Api: 1`, for the
5
+ * WebSocket and its frames (`FrameSchema`), one JSON text message per frame;
6
+ * - the messages: `HARNESS_API_VERSION` (2), which a harness names in `hello.api` and core
7
+ * checks;
8
+ * - the Runtime's protocol, which the Runtime and Management APIs carry, never this one.
9
+ *
10
+ * A harness container connects with `Authorization: Bearer <harness token>`. The harness in a
11
+ * pod sandbox holds no harness token: it exchanges the join token mounted in its pod for a host
12
+ * token (`POST .../host/join`), renews it (`POST .../host/renew`, `Authorization: Bearer <host
13
+ * token>`) every few minutes, and connects with the host token as its bearer. That connection
14
+ * serves its sandbox alone. Every refused join or renewal is the same `401`.
15
+ */
16
+ import { z } from "zod";
17
+ /** The URL path of the Harness API's WebSocket, on core's harness port (4200 by default). */
18
+ export declare const HARNESS_API_PATH = "/nylorun/harness/v1";
19
+ /** The upgrade header naming the transport version, and the only value accepted. */
20
+ export declare const HARNESS_API_HEADER = "nylorun-harness-api";
21
+ export declare const HARNESS_API_TRANSPORT = "1";
22
+ /** Largest frame either end accepts. */
23
+ export declare const HARNESS_MAX_PAYLOAD: number;
24
+ /** Where a pod's harness exchanges its join token, and renews its host token. */
25
+ export declare const HOST_JOIN_PATH = "/nylorun/harness/v1/host/join";
26
+ export declare const HOST_RENEW_PATH = "/nylorun/harness/v1/host/renew";
27
+ /**
28
+ * A pod's join: its sandbox (`NYLORUN_SANDBOX_ID`), its pod's UID, the join token read from the
29
+ * mounted join file (afresh each time: a reset writes a new one), and the id the harness keeps on
30
+ * the volume (`/harness/volume-id`), so a volume recreated empty is told apart.
31
+ */
32
+ export declare const HostJoinRequestSchema: z.ZodObject<{
33
+ sandboxId: z.ZodString;
34
+ podUid: z.ZodString;
35
+ joinToken: z.ZodString;
36
+ volumeId: z.ZodOptional<z.ZodString>;
37
+ }, z.core.$strict>;
38
+ export type HostJoinRequest = z.infer<typeof HostJoinRequestSchema>;
39
+ /**
40
+ * What `host/join` and `host/renew` answer. The host token is the WebSocket bearer; the egress
41
+ * token is the password of the egress proxy every command the harness runs must use
42
+ * (`NYLORUN_EGRESS_PROXY`); `caCertificate` is the egress CA (PEM), which the harness adds to the
43
+ * trust bundle of those commands. Both tokens expire at `expiresAt`.
44
+ */
45
+ export declare const HostJoinAnswerSchema: z.ZodObject<{
46
+ hostToken: z.ZodString;
47
+ egressToken: z.ZodString;
48
+ sandboxId: z.ZodString;
49
+ epoch: z.ZodNumber;
50
+ expiresAt: z.ZodString;
51
+ caCertificate: z.ZodString;
52
+ setup: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
53
+ seeded: z.ZodOptional<z.ZodLiteral<true>>;
54
+ }, z.core.$strict>;
55
+ export type HostJoinAnswer = z.infer<typeof HostJoinAnswerSchema>;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * How a harness reaches core (R4.5). Three version numbers apply, and each moves on its own:
3
+ *
4
+ * - the transport: path `/nylorun/harness/v1` and header `Nylorun-Harness-Api: 1`, for the
5
+ * WebSocket and its frames (`FrameSchema`), one JSON text message per frame;
6
+ * - the messages: `HARNESS_API_VERSION` (2), which a harness names in `hello.api` and core
7
+ * checks;
8
+ * - the Runtime's protocol, which the Runtime and Management APIs carry, never this one.
9
+ *
10
+ * A harness container connects with `Authorization: Bearer <harness token>`. The harness in a
11
+ * pod sandbox holds no harness token: it exchanges the join token mounted in its pod for a host
12
+ * token (`POST .../host/join`), renews it (`POST .../host/renew`, `Authorization: Bearer <host
13
+ * token>`) every few minutes, and connects with the host token as its bearer. That connection
14
+ * serves its sandbox alone. Every refused join or renewal is the same `401`.
15
+ */
16
+ import { z } from "zod";
17
+ /** The URL path of the Harness API's WebSocket, on core's harness port (4200 by default). */
18
+ export const HARNESS_API_PATH = "/nylorun/harness/v1";
19
+ /** The upgrade header naming the transport version, and the only value accepted. */
20
+ export const HARNESS_API_HEADER = "nylorun-harness-api";
21
+ export const HARNESS_API_TRANSPORT = "1";
22
+ /** Largest frame either end accepts. */
23
+ export const HARNESS_MAX_PAYLOAD = 64 * 1024 * 1024;
24
+ /** Where a pod's harness exchanges its join token, and renews its host token. */
25
+ export const HOST_JOIN_PATH = `${HARNESS_API_PATH}/host/join`;
26
+ export const HOST_RENEW_PATH = `${HARNESS_API_PATH}/host/renew`;
27
+ /**
28
+ * A pod's join: its sandbox (`NYLORUN_SANDBOX_ID`), its pod's UID, the join token read from the
29
+ * mounted join file (afresh each time: a reset writes a new one), and the id the harness keeps on
30
+ * the volume (`/harness/volume-id`), so a volume recreated empty is told apart.
31
+ */
32
+ export const HostJoinRequestSchema = z.strictObject({
33
+ sandboxId: z.string().min(1),
34
+ podUid: z.string().regex(/^[A-Za-z0-9-]{1,64}$/),
35
+ joinToken: z.string().min(1).max(512),
36
+ volumeId: z
37
+ .string()
38
+ .regex(/^[A-Za-z0-9-]{1,64}$/)
39
+ .optional(),
40
+ });
41
+ /**
42
+ * What `host/join` and `host/renew` answer. The host token is the WebSocket bearer; the egress
43
+ * token is the password of the egress proxy every command the harness runs must use
44
+ * (`NYLORUN_EGRESS_PROXY`); `caCertificate` is the egress CA (PEM), which the harness adds to the
45
+ * trust bundle of those commands. Both tokens expire at `expiresAt`.
46
+ */
47
+ export const HostJoinAnswerSchema = z.strictObject({
48
+ hostToken: z.string(),
49
+ egressToken: z.string(),
50
+ sandboxId: z.string(),
51
+ epoch: z.number().int(),
52
+ expiresAt: z.string(),
53
+ caCertificate: z.string(),
54
+ /**
55
+ * Join only: what our engine copies and runs on a new disk before it takes turns (the
56
+ * Environment's `files` and `setup`). A custom harness runs them itself, or ignores them.
57
+ */
58
+ setup: z.record(z.string(), z.unknown()).optional(),
59
+ /** Join only: the new volume starts from a disk version, so there is no setup to run. */
60
+ seeded: z.literal(true).optional(),
61
+ });
@@ -6,7 +6,10 @@ import type { WorkflowManifest } from "./workflow.js";
6
6
  * hash is unchanged, and the Runtime accepts both.
7
7
  */
8
8
  export type ManifestSchemaVersion = 5 | 6;
9
- /** Whether each call waits for a person's approval (`approve` on the session). Default `never`. */
9
+ /**
10
+ * Whether each call waits for a person's approval, in a manifest saved before R5 step 2 (the
11
+ * Tool Gate holds such a call). New definitions use the Tenant's tool policy instead.
12
+ */
10
13
  export type ApprovalMode = "never" | "always";
11
14
  /** The methods an HTTP tool may use: each sends the tool input as a JSON body. */
12
15
  export type HttpToolMethod = "POST" | "PUT" | "PATCH";
@@ -20,11 +23,10 @@ export interface HttpToolTarget {
20
23
  /** Default `POST`. */
21
24
  readonly method?: HttpToolMethod;
22
25
  /**
23
- * Adds a vault credential to each request, as for a remote MCP server: a credential in the
24
- * session's vaults bound to `url` (a `bearer` token or a `headers` map, sent to its `via` when
25
- * it has one, with its identity header), chosen by the session's credential selection with
26
- * this name (`credentialSelections[].serverName`) when several are. When the vaults hold none,
27
- * the call fails with `http.credential` and is not sent.
26
+ * Adds a vault credential to each request, as for a remote MCP server: the credential in the
27
+ * vault of the session's Environment bound to `url` (a `bearer` token or a `headers` map, sent
28
+ * to its `via` when it has one, with its identity header). This name labels it in coverage.
29
+ * When the vault holds none, the call fails with `http.credential` and is not sent.
28
30
  */
29
31
  readonly credential?: string;
30
32
  /** How long the service may take to answer. Default 60000, at most 300000. */
@@ -43,7 +45,11 @@ export interface ToolManifest {
43
45
  readonly agent?: AgentManifest | WorkflowManifest;
44
46
  /** Present when the Runtime runs this tool as an HTTP request. Never with `agent`. */
45
47
  readonly http?: HttpToolTarget;
46
- /** Each call of an HTTP tool waits for approval. */
48
+ /**
49
+ * @deprecated Removed in R5 step 2: the Runtime refuses a definition that sets it, and tool
50
+ * approvals are the Tenant's tool policy (`PUT /v1/tenant/tool-policy`). Read only from
51
+ * manifests saved before, which the Tool Gate still holds for approval.
52
+ */
47
53
  readonly approval?: ApprovalMode;
48
54
  }
49
55
  export interface SkillManifest {
@@ -63,7 +69,7 @@ export interface SkillManifest {
63
69
  export interface McpToolSettings {
64
70
  /** `false`: the tool never reaches the model and cannot be called. Default `true`. */
65
71
  readonly enabled?: boolean;
66
- /** `always`: each call waits for approval. Default: the server's `approval`, else `never`. */
72
+ /** @deprecated Removed in R5 step 2, as `ToolManifest.approval`; read only from older manifests. */
67
73
  readonly approval?: ApprovalMode;
68
74
  /**
69
75
  * `true`: the tool leaves the model's tool list; the model finds it with `tool_search` and runs
@@ -76,7 +82,7 @@ interface McpServerFields {
76
82
  readonly name: string;
77
83
  readonly url: string;
78
84
  readonly headers?: Readonly<Record<string, string>>;
79
- /** Each call of every tool of the server waits for approval. */
85
+ /** @deprecated Removed in R5 step 2, as `ToolManifest.approval`; read only from older manifests. */
80
86
  readonly approval?: ApprovalMode;
81
87
  /** Defers every tool of the server, or none (manifest v6, R2b C10). Default: automatic. */
82
88
  readonly deferred?: boolean;
@@ -12,8 +12,9 @@ export interface WorkflowErrorPayload {
12
12
  * LiveEvent payloads for workflow sessions (`workflows.md` §11, `loops.md` §4.6).
13
13
  *
14
14
  * @deprecated Use the event catalog (`EVENT_CATALOG`, `SessionEventOf<"node.agent">` in
15
- * `@nylorun/core/contracts`): it types the events the Runtime writes. `node.completed`,
16
- * `node.failed`, `switch.selected`, `map.items` and `loop.waiting` are not written.
15
+ * `@nylorun/core/contracts`): it types the events the Runtime writes. `node.completed` is
16
+ * written for a flow's HTTP stages only (R7.1), with more fields; `node.failed`,
17
+ * `switch.selected`, `map.items` and `loop.waiting` are not written.
17
18
  */
18
19
  export type WorkflowLiveEventPayload = {
19
20
  readonly type: "node.started";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Harness ids (track R4): the name a harness says in `hello`, an Environment's `harness`, and the
3
+ * key of the Tenant's placement. A session runs the harness it pinned when it opened.
4
+ */
5
+ /** The harness of a session that names no other: ours (`@nylorun/harness`). */
6
+ export declare const DEFAULT_HARNESS = "nylorun";
7
+ /** Lowercase letters, digits and dashes, starting with a letter: 2 to 63 characters. */
8
+ export declare const HARNESS_ID_PATTERN: RegExp;
9
+ export declare function isHarnessId(value: unknown): value is string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Harness ids (track R4): the name a harness says in `hello`, an Environment's `harness`, and the
3
+ * key of the Tenant's placement. A session runs the harness it pinned when it opened.
4
+ */
5
+ /** The harness of a session that names no other: ours (`@nylorun/harness`). */
6
+ export const DEFAULT_HARNESS = "nylorun";
7
+ /** Lowercase letters, digits and dashes, starting with a letter: 2 to 63 characters. */
8
+ export const HARNESS_ID_PATTERN = /^[a-z][a-z0-9-]{1,62}$/;
9
+ export function isHarnessId(value) {
10
+ return typeof value === "string" && HARNESS_ID_PATTERN.test(value);
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/core",
3
- "version": "0.19.0-beta",
3
+ "version": "0.20.0-beta",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Shared agent definitions and wire contracts",
@@ -23,7 +23,7 @@
23
23
  "node": "^22.14.0 || ^24.0.0 || >=26.0.0"
24
24
  },
25
25
  "scripts": {
26
- "build": "npm run clean && node ../scripts/check-typescript-version.mjs && tsc -p tsconfig.json",
26
+ "build": "npm run clean && node ../scripts/check-typescript-version.mjs && tsc -p tsconfig.json && node scripts/harness-api-schema.mjs",
27
27
  "clean": "node -e \"import('node:fs').then(({rmSync})=>rmSync('dist',{recursive:true,force:true}))\"",
28
28
  "check": "npm run build && npm test && node scripts/check-package.mjs",
29
29
  "test": "vitest run --passWithNoTests",
@@ -33,7 +33,7 @@
33
33
  "@noble/hashes": "^2.4.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/node": "^26.5.0",
36
+ "@types/node": "^26.6.4",
37
37
  "typescript": "npm:@typescript/typescript6@^6.0.2",
38
38
  "vitest": "^5.0.2"
39
39
  },
@@ -65,7 +65,8 @@
65
65
  "./harness-api": {
66
66
  "types": "./dist/harness-api/index.d.ts",
67
67
  "import": "./dist/harness-api/index.js"
68
- }
68
+ },
69
+ "./harness-api/schema.json": "./dist/harness-api/harness-api.schema.json"
69
70
  },
70
71
  "peerDependencies": {
71
72
  "zod": "^4.6.5"