@nylorun/core 0.21.0-beta → 0.23.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 (74) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +1 -1
  3. package/dist/compatibility.d.ts +37 -20
  4. package/dist/compatibility.js +38 -21
  5. package/dist/contracts.d.ts +531 -88
  6. package/dist/contracts.js +315 -204
  7. package/dist/define.d.ts +8 -12
  8. package/dist/define.js +7 -11
  9. package/dist/definition/assemble.d.ts +1 -3
  10. package/dist/definition/assemble.js +4 -8
  11. package/dist/definition/bound.d.ts +1 -1
  12. package/dist/definition/delegate.d.ts +5 -0
  13. package/dist/definition/delegate.js +6 -1
  14. package/dist/definition/from.d.ts +4 -2
  15. package/dist/definition/from.js +11 -29
  16. package/dist/definition/http-tool.d.ts +54 -8
  17. package/dist/definition/http-tool.js +175 -10
  18. package/dist/definition/manifest.d.ts +7 -6
  19. package/dist/definition/manifest.js +7 -6
  20. package/dist/definition/mcp.d.ts +1 -1
  21. package/dist/definition/media-reference.d.ts +2 -11
  22. package/dist/definition/media-reference.js +0 -12
  23. package/dist/definition/model-failure.js +1 -0
  24. package/dist/definition/removed.js +1 -0
  25. package/dist/definition/trace.d.ts +0 -7
  26. package/dist/definition/trace.js +0 -34
  27. package/dist/definition/variant.d.ts +1 -1
  28. package/dist/definition/variant.js +1 -3
  29. package/dist/harness-api/artifacts.d.ts +84 -0
  30. package/dist/harness-api/artifacts.js +128 -0
  31. package/dist/harness-api/gates.d.ts +0 -4
  32. package/dist/harness-api/gates.js +0 -4
  33. package/dist/harness-api/harness-api.schema.json +2422 -924
  34. package/dist/harness-api/index.d.ts +9 -6
  35. package/dist/harness-api/index.js +9 -6
  36. package/dist/harness-api/json-schema.js +5 -2
  37. package/dist/harness-api/mcp.d.ts +77 -30
  38. package/dist/harness-api/mcp.js +42 -25
  39. package/dist/harness-api/messages.d.ts +45 -17
  40. package/dist/harness-api/messages.js +20 -5
  41. package/dist/harness-api/schema.d.ts +538 -198
  42. package/dist/harness-api/schema.js +298 -59
  43. package/dist/harness-api/transcript.d.ts +8 -10
  44. package/dist/harness-api/transcript.js +27 -11
  45. package/dist/harness-api/transport.d.ts +7 -1
  46. package/dist/harness-api/transport.js +10 -7
  47. package/dist/manifest-schemas.js +14 -2
  48. package/dist/schemas/agent-manifest.schema.json +14 -147
  49. package/dist/schemas/environment-manifest.schema.json +76 -16
  50. package/dist/types/manifest.d.ts +17 -18
  51. package/dist/types/model.d.ts +10 -5
  52. package/dist/utils/definition-files.d.ts +20 -6
  53. package/dist/utils/definition-files.js +31 -17
  54. package/dist/utils/file-systems.d.ts +20 -0
  55. package/dist/utils/file-systems.js +20 -0
  56. package/dist/utils/harness-id.d.ts +4 -1
  57. package/dist/utils/harness-id.js +4 -1
  58. package/dist/utils/media-types.d.ts +30 -0
  59. package/dist/utils/media-types.js +128 -0
  60. package/dist/utils/runtime-limits.d.ts +229 -0
  61. package/dist/utils/runtime-limits.js +482 -0
  62. package/dist/utils/runtime-tools.d.ts +8 -16
  63. package/dist/utils/runtime-tools.js +8 -27
  64. package/dist/utils/sandbox.d.ts +4 -1
  65. package/dist/utils/sandbox.js +4 -1
  66. package/package.json +1 -1
  67. package/dist/definition/deferred-tools.d.ts +0 -27
  68. package/dist/definition/deferred-tools.js +0 -82
  69. package/dist/definition/runtime-manifest.d.ts +0 -30
  70. package/dist/definition/runtime-manifest.js +0 -132
  71. package/dist/definition/sandbox-tools.d.ts +0 -5
  72. package/dist/definition/sandbox-tools.js +0 -109
  73. package/dist/definition/skill-tools.d.ts +0 -23
  74. package/dist/definition/skill-tools.js +0 -76
@@ -4,7 +4,9 @@
4
4
  * from its `$schema` and a client in another language validates what core enforces. The build
5
5
  * writes them to `dist/schemas/` (`@nylorun/core/schemas/agent-manifest.json` and
6
6
  * `@nylorun/core/schemas/environment-manifest.json`). Both allow a top-level `$schema`, which
7
- * the CLI and SDK drop before they save: the Runtime's own schemas stay strict.
7
+ * the CLI and SDK drop before they save: the Runtime's own schemas stay strict. The environment
8
+ * manifest's `files` also allow the CLI's `{ path, from }`, a folder beside the file that
9
+ * `nylorun environments manifests save` hashes into `{ path, files }`: the Runtime never sees it.
8
10
  */
9
11
  import { z } from "zod";
10
12
  import { AgentManifestSchema, ENVIRONMENT_MANIFEST_SCHEMA_VERSION, EnvironmentManifestSchema, } from "./contracts.js";
@@ -26,7 +28,17 @@ function document(schema, id, title) {
26
28
  }
27
29
  /** The environment manifest's JSON Schema document (draft 2020-12). */
28
30
  export function environmentManifestJsonSchema() {
29
- return document(EnvironmentManifestSchema, `environment-manifest/v${ENVIRONMENT_MANIFEST_SCHEMA_VERSION}`, `Nylorun environment manifest ${ENVIRONMENT_MANIFEST_SCHEMA_VERSION}`);
31
+ const schema = document(EnvironmentManifestSchema, `environment-manifest/v${ENVIRONMENT_MANIFEST_SCHEMA_VERSION}`, `Nylorun environment manifest ${ENVIRONMENT_MANIFEST_SCHEMA_VERSION}`);
32
+ const shapes = schema.properties.files.items.anyOf;
33
+ const tree = shapes.find((shape) => "files" in shape.properties);
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;
30
42
  }
31
43
  /** The agent manifest's JSON Schema document (draft 2020-12). */
32
44
  export function agentManifestJsonSchema() {
@@ -81,9 +81,11 @@
81
81
  "method": {
82
82
  "type": "string",
83
83
  "enum": [
84
+ "GET",
84
85
  "POST",
85
86
  "PUT",
86
- "PATCH"
87
+ "PATCH",
88
+ "DELETE"
87
89
  ]
88
90
  },
89
91
  "credential": {
@@ -93,7 +95,7 @@
93
95
  "timeoutMs": {
94
96
  "type": "integer",
95
97
  "exclusiveMinimum": 0,
96
- "maximum": 300000
98
+ "maximum": 2147483647
97
99
  }
98
100
  },
99
101
  "required": [
@@ -291,149 +293,10 @@
291
293
  ]
292
294
  },
293
295
  "secrets": {
294
- "maxItems": 64,
295
296
  "type": "array",
296
297
  "items": {
297
298
  "type": "string",
298
- "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,127}$"
299
- }
300
- }
301
- },
302
- "additionalProperties": false
303
- },
304
- "runtime": {
305
- "type": "object",
306
- "properties": {
307
- "sandbox": {
308
- "type": "object",
309
- "properties": {
310
- "image": {
311
- "type": "string",
312
- "minLength": 1
313
- },
314
- "network": {
315
- "type": "object",
316
- "properties": {
317
- "preset": {
318
- "type": "string",
319
- "enum": [
320
- "none",
321
- "dev",
322
- "open"
323
- ]
324
- },
325
- "allow": {
326
- "type": "array",
327
- "items": {
328
- "type": "string"
329
- }
330
- }
331
- },
332
- "additionalProperties": false
333
- },
334
- "resources": {
335
- "type": "object",
336
- "properties": {
337
- "cpus": {
338
- "type": "integer",
339
- "minimum": 1,
340
- "maximum": 64
341
- },
342
- "memory": {
343
- "type": "string"
344
- }
345
- },
346
- "additionalProperties": false
347
- },
348
- "idle": {
349
- "type": "string"
350
- }
351
- },
352
- "additionalProperties": false
353
- },
354
- "tools": {
355
- "type": "array",
356
- "items": {
357
- "type": "object",
358
- "properties": {
359
- "name": {
360
- "type": "string",
361
- "pattern": "^[A-Za-z0-9_-]{1,64}$"
362
- },
363
- "description": {
364
- "type": "string"
365
- },
366
- "inputSchema": {
367
- "type": "object",
368
- "propertyNames": {
369
- "type": "string"
370
- },
371
- "additionalProperties": {}
372
- },
373
- "outputSchema": {
374
- "type": "object",
375
- "propertyNames": {
376
- "type": "string"
377
- },
378
- "additionalProperties": {}
379
- },
380
- "agent": {
381
- "$ref": "#/$defs/ToolAgentManifest"
382
- },
383
- "http": {
384
- "type": "object",
385
- "properties": {
386
- "url": {
387
- "type": "string"
388
- },
389
- "method": {
390
- "type": "string",
391
- "enum": [
392
- "POST",
393
- "PUT",
394
- "PATCH"
395
- ]
396
- },
397
- "credential": {
398
- "type": "string",
399
- "minLength": 1
400
- },
401
- "timeoutMs": {
402
- "type": "integer",
403
- "exclusiveMinimum": 0,
404
- "maximum": 300000
405
- }
406
- },
407
- "required": [
408
- "url"
409
- ],
410
- "additionalProperties": false
411
- },
412
- "approval": {
413
- "type": "string",
414
- "enum": [
415
- "never",
416
- "always"
417
- ]
418
- },
419
- "fn": {
420
- "description": "Reserved for a later kind of tool; refused for now."
421
- },
422
- "command": {
423
- "description": "Reserved for a later kind of tool; refused for now."
424
- }
425
- },
426
- "required": [
427
- "name",
428
- "inputSchema"
429
- ],
430
- "additionalProperties": false
431
- }
432
- },
433
- "instructions": {
434
- "type": "array",
435
- "items": {
436
- "type": "string"
299
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
437
300
  }
438
301
  }
439
302
  },
@@ -535,7 +398,7 @@
535
398
  "cpus": {
536
399
  "type": "integer",
537
400
  "minimum": 1,
538
- "maximum": 64
401
+ "maximum": 9007199254740991
539
402
  },
540
403
  "memory": {
541
404
  "type": "string"
@@ -634,9 +497,11 @@
634
497
  "method": {
635
498
  "type": "string",
636
499
  "enum": [
500
+ "GET",
637
501
  "POST",
638
502
  "PUT",
639
- "PATCH"
503
+ "PATCH",
504
+ "DELETE"
640
505
  ]
641
506
  },
642
507
  "credential": {
@@ -646,7 +511,7 @@
646
511
  "timeoutMs": {
647
512
  "type": "integer",
648
513
  "exclusiveMinimum": 0,
649
- "maximum": 300000
514
+ "maximum": 2147483647
650
515
  }
651
516
  },
652
517
  "required": [
@@ -824,9 +689,11 @@
824
689
  "method": {
825
690
  "type": "string",
826
691
  "enum": [
692
+ "GET",
827
693
  "POST",
828
694
  "PUT",
829
- "PATCH"
695
+ "PATCH",
696
+ "DELETE"
830
697
  ]
831
698
  },
832
699
  "credential": {
@@ -836,7 +703,7 @@
836
703
  "timeoutMs": {
837
704
  "type": "integer",
838
705
  "exclusiveMinimum": 0,
839
- "maximum": 300000
706
+ "maximum": 2147483647
840
707
  }
841
708
  },
842
709
  "required": [
@@ -17,8 +17,7 @@
17
17
  "description": "An environment manifest's name, such as `analyst-box`"
18
18
  },
19
19
  "description": {
20
- "type": "string",
21
- "maxLength": 1024
20
+ "type": "string"
22
21
  },
23
22
  "kind": {
24
23
  "type": "string",
@@ -38,7 +37,7 @@
38
37
  "cpus": {
39
38
  "type": "integer",
40
39
  "minimum": 1,
41
- "maximum": 64
40
+ "maximum": 9007199254740991
42
41
  },
43
42
  "memory": {
44
43
  "type": "string"
@@ -78,15 +77,13 @@
78
77
  "additionalProperties": false
79
78
  },
80
79
  "setup": {
81
- "maxItems": 16,
82
80
  "type": "array",
83
81
  "items": {
84
82
  "type": "object",
85
83
  "properties": {
86
84
  "command": {
87
85
  "type": "string",
88
- "minLength": 1,
89
- "maxLength": 4096
86
+ "minLength": 1
90
87
  },
91
88
  "cwd": {
92
89
  "type": "string",
@@ -104,7 +101,6 @@
104
101
  }
105
102
  },
106
103
  "files": {
107
- "maxItems": 16,
108
104
  "type": "array",
109
105
  "items": {
110
106
  "anyOf": [
@@ -157,10 +153,79 @@
157
153
  "files"
158
154
  ],
159
155
  "additionalProperties": false
156
+ },
157
+ {
158
+ "type": "object",
159
+ "description": "For the CLI only: a folder, relative to this file, that `nylorun environments manifests save` uploads by hash and saves as { path, files }",
160
+ "properties": {
161
+ "path": {
162
+ "type": "string",
163
+ "minLength": 1,
164
+ "maxLength": 1024
165
+ },
166
+ "from": {
167
+ "type": "string",
168
+ "minLength": 1
169
+ }
170
+ },
171
+ "required": [
172
+ "path",
173
+ "from"
174
+ ],
175
+ "additionalProperties": false
160
176
  }
161
177
  ]
162
178
  }
163
179
  },
180
+ "limits": {
181
+ "type": "object",
182
+ "properties": {
183
+ "artifacts": {
184
+ "type": "object",
185
+ "properties": {
186
+ "fileBytes": {
187
+ "type": "integer",
188
+ "exclusiveMinimum": 0,
189
+ "maximum": 9007199254740991
190
+ },
191
+ "totalBytes": {
192
+ "type": "integer",
193
+ "exclusiveMinimum": 0,
194
+ "maximum": 9007199254740991
195
+ }
196
+ },
197
+ "additionalProperties": false
198
+ },
199
+ "skills": {
200
+ "type": "object",
201
+ "properties": {
202
+ "totalBytes": {
203
+ "type": "integer",
204
+ "exclusiveMinimum": 0,
205
+ "maximum": 9007199254740991
206
+ }
207
+ },
208
+ "additionalProperties": false
209
+ },
210
+ "disk": {
211
+ "type": "object",
212
+ "properties": {
213
+ "versionBytes": {
214
+ "type": "integer",
215
+ "exclusiveMinimum": 0,
216
+ "maximum": 9007199254740991
217
+ },
218
+ "versionEntries": {
219
+ "type": "integer",
220
+ "exclusiveMinimum": 0,
221
+ "maximum": 9007199254740991
222
+ }
223
+ },
224
+ "additionalProperties": false
225
+ }
226
+ },
227
+ "additionalProperties": false
228
+ },
164
229
  "secrets": {
165
230
  "type": "object",
166
231
  "propertyNames": {
@@ -177,7 +242,6 @@
177
242
  },
178
243
  "allowedHosts": {
179
244
  "minItems": 1,
180
- "maxItems": 32,
181
245
  "type": "array",
182
246
  "items": {
183
247
  "type": "string"
@@ -205,8 +269,7 @@
205
269
  "type": "boolean"
206
270
  },
207
271
  "description": {
208
- "type": "string",
209
- "maxLength": 500
272
+ "type": "string"
210
273
  }
211
274
  },
212
275
  "required": [
@@ -226,8 +289,7 @@
226
289
  "type": "boolean"
227
290
  },
228
291
  "description": {
229
- "type": "string",
230
- "maxLength": 500
292
+ "type": "string"
231
293
  }
232
294
  },
233
295
  "required": [
@@ -266,8 +328,7 @@
266
328
  "type": "boolean"
267
329
  },
268
330
  "description": {
269
- "type": "string",
270
- "maxLength": 500
331
+ "type": "string"
271
332
  }
272
333
  },
273
334
  "required": [
@@ -307,8 +368,7 @@
307
368
  "type": "boolean"
308
369
  },
309
370
  "description": {
310
- "type": "string",
311
- "maxLength": 500
371
+ "type": "string"
312
372
  }
313
373
  },
314
374
  "required": [
@@ -15,14 +15,23 @@ export interface PluginLabel {
15
15
  * Tool Gate holds such a call). New definitions use the Tenant's tool policy instead.
16
16
  */
17
17
  export type ApprovalMode = "never" | "always";
18
- /** The methods an HTTP tool may use: each sends the tool input as a JSON body. */
19
- export type HttpToolMethod = "POST" | "PUT" | "PATCH";
20
18
  /**
21
- * A tool the Runtime runs as one HTTP request through its Tool Gate: the input as a JSON body,
22
- * the answer as the output. A sibling of `agent`; `fn` and `command` are reserved for later kinds.
19
+ * The methods an HTTP tool may use. `POST`, `PUT` and `PATCH` send the tool input as a JSON body;
20
+ * `GET` and `DELETE` send no body and put it in the query string.
21
+ */
22
+ export type HttpToolMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
23
+ /**
24
+ * A tool the Runtime runs as one HTTP request through its Tool Gate: the input's path parameters
25
+ * in the URL, the rest as a JSON body (or, for `GET` and `DELETE`, as the query string), the
26
+ * answer as the output. A sibling of `agent`; `fn` and `command` are reserved for later kinds.
23
27
  */
24
28
  export interface HttpToolTarget {
25
- /** Absolute `http` or `https` URL. */
29
+ /**
30
+ * Absolute `http` or `https` URL. Its path may name input fields as `{field}`, such as
31
+ * `https://api.example.com/orders/{orderId}`: each is a required field of the input schema,
32
+ * sent percent-encoded in its place and not again in the query string or body. A query string
33
+ * in the URL is kept, and the input's fields are added after it.
34
+ */
26
35
  readonly url: string;
27
36
  /** Default `POST`. */
28
37
  readonly method?: HttpToolMethod;
@@ -79,8 +88,9 @@ export interface McpToolSettings {
79
88
  readonly approval?: ApprovalMode;
80
89
  /**
81
90
  * `true`: the tool leaves the model's tool list; the model finds it with `tool_search` and runs
82
- * it with `tool_call` (R2b C10). Default: the server's `deferred`, else deferred when the
83
- * agent's MCP tools would take more than a tenth of the model's context window.
91
+ * it with `tool_call` (R2b C10). A hint the harness reads (`turn.start.mcp`): Nylorun's engine
92
+ * follows it, and without one defers when the agent's MCP tools would take more than a tenth of
93
+ * the model's context window.
84
94
  */
85
95
  readonly deferred?: boolean;
86
96
  }
@@ -130,16 +140,6 @@ export interface SandboxManifest {
130
140
  /** Stop compute after this long without use, e.g. "15m". Files persist. */
131
141
  readonly idle?: string;
132
142
  }
133
- /**
134
- * What the Runtime adds to a session's agent when it pins it: the session's sandbox, the tools the
135
- * Runtime serves (the sandbox tools, the artifact tools, the skill tools) and the text that goes
136
- * with them. Only the Runtime writes it; a definition or a turn variant that sets it is refused.
137
- */
138
- export interface RuntimeManifest {
139
- readonly sandbox?: SandboxManifest;
140
- readonly tools?: readonly ToolManifest[];
141
- readonly instructions?: readonly string[];
142
- }
143
143
  export interface AgentManifest {
144
144
  readonly manifestSchemaVersion: ManifestSchemaVersion;
145
145
  readonly id: string;
@@ -153,7 +153,6 @@ export interface AgentManifest {
153
153
  readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
154
154
  /** What the agent needs of its session's Environment, checked when a session opens (D65). */
155
155
  readonly requires?: AgentRequirements;
156
- readonly runtime?: RuntimeManifest;
157
156
  }
158
157
  /** What an agent needs of the Environment its session opens on (protocol 14, D65). */
159
158
  export interface AgentRequirements {
@@ -50,6 +50,11 @@ export interface ModelCandidate {
50
50
  }
51
51
  /** Why a model call failed in a known way (Model Calls §6.1). */
52
52
  export type ModelFailureCode = "context_overflow" | "rate_limited" | "overloaded" | "timeout" | "transient" | "content_policy" | "auth" | "invalid_request" | "invalid_output"
53
+ /**
54
+ * The call holds a part the model or its provider API cannot take (protocol 15): a file kind
55
+ * the model does not read, or a text file sent as a media part. Nothing was sent; never retried.
56
+ */
57
+ | "unsupported_input"
53
58
  /** A model budget's cap is reached (`PUT /v1/tenant/budgets`); never retried. */
54
59
  | "budget_exhausted";
55
60
  /**
@@ -191,21 +196,21 @@ export interface ModelCall {
191
196
  readonly model?: ModelDirective;
192
197
  readonly prompt: readonly PromptItem[];
193
198
  readonly tools: readonly ModelCallTool[];
194
- /** Optional portable contract for this turn's terminal JSON result. */
195
- readonly outputSchema?: JsonObject;
196
199
  readonly executionId: string;
197
200
  }
198
201
  export interface ModelAdapterContext {
199
202
  readonly request: ModelRequest;
200
203
  readonly invocationId: string;
201
204
  readonly signal: AbortSignal;
202
- /** Set when the engine calls the model to summarize history (Model Calls §8). */
205
+ /**
206
+ * Set when the engine calls the model to summarize history (Model Calls §8). Engine-internal:
207
+ * the call's effect says `purpose: "summary"`, and the compaction's facts go with its
208
+ * transcript edit.
209
+ */
203
210
  readonly compaction?: {
204
211
  readonly trigger: "threshold" | "overflow";
205
212
  readonly tokensBefore: number;
206
213
  readonly keptTokens: number;
207
- /** An intermediate call of a chunked summary; only the last one completes the compaction. */
208
- readonly partial?: boolean;
209
214
  };
210
215
  /** Publishes one JSON-safe provider request derived from the canonical ModelCall. */
211
216
  reportPreparedCall(prepared: ModelPreparedCall): void;
@@ -1,13 +1,19 @@
1
- /** The largest definition file the Runtime stores. */
2
- export declare const DEFINITION_FILE_MAX_BYTES: number;
3
- /** The most files one skill may have. */
4
- export declare const SKILL_FILES_MAX = 500;
5
- /** The longest path of a file in a skill's folder. */
6
- export declare const SKILL_FILE_PATH_MAX = 512;
1
+ /**
2
+ * The most bytes one skill's files may hold together when the Tenant sets no limit of its own
3
+ * (2 GiB, Tenant setting `skills.config`); an Environment's manifest may set a lower one. No file
4
+ * and no count of files has a limit of its own.
5
+ */
6
+ export declare const SKILL_TOTAL_BYTES_DEFAULT: number;
7
7
  /** The file every skill has: its frontmatter and instructions. */
8
8
  export declare const SKILL_ENTRY = "SKILL.md";
9
9
  /** Where a session's sandbox holds each skill's files, read-only: `/skills/<name>@<hash>/`. */
10
10
  export declare const SKILLS_MOUNT = "/skills";
11
+ /**
12
+ * The longest path of a file in a skill's folder: what the longest path a workspace's file
13
+ * system takes (`FILE_PATH_MAX`) leaves under the skill's mount folder, `/skills/<name>@<12 hex>/`
14
+ * with a name as long as a file name may be.
15
+ */
16
+ export declare const SKILL_FILE_PATH_MAX: number;
11
17
  /**
12
18
  * The folder of a sandbox that holds one version of a skill, read-only (D66):
13
19
  * `/skills/<name>@<12 hex>`, the hex from the SHA-256 of its canonical file map. A version keeps
@@ -29,6 +35,14 @@ export declare function skillFilesIssue(files: unknown): string | undefined;
29
35
  * agents it uses as tools, and those of a flow's agents, as `sha256:<hex>`.
30
36
  */
31
37
  export declare function definitionFilesOf(document: unknown, into?: Set<string>): Set<string>;
38
+ /**
39
+ * Every skill a definition document carries, as written: its agents' skills, those of the agents
40
+ * it uses as tools, and those of a flow's agents. A skill two agents carry comes once for each.
41
+ */
42
+ export declare function skillsOf(document: unknown): Generator<{
43
+ readonly name?: unknown;
44
+ readonly files?: Readonly<Record<string, unknown>>;
45
+ }>;
32
46
  /**
33
47
  * A `SKILL.md`'s instructions: the text after its YAML frontmatter (`---` lines), without the
34
48
  * blank line that follows it. Text without frontmatter is returned whole.
@@ -6,16 +6,23 @@
6
6
  import { sha256 } from "@noble/hashes/sha2.js";
7
7
  import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
8
8
  import { canonical } from "./canonical.js";
9
- /** The largest definition file the Runtime stores. */
10
- export const DEFINITION_FILE_MAX_BYTES = 10 * 1024 * 1024;
11
- /** The most files one skill may have. */
12
- export const SKILL_FILES_MAX = 500;
13
- /** The longest path of a file in a skill's folder. */
14
- export const SKILL_FILE_PATH_MAX = 512;
9
+ import { FILE_NAME_MAX, FILE_PATH_MAX } from "./file-systems.js";
10
+ /**
11
+ * The most bytes one skill's files may hold together when the Tenant sets no limit of its own
12
+ * (2 GiB, Tenant setting `skills.config`); an Environment's manifest may set a lower one. No file
13
+ * and no count of files has a limit of its own.
14
+ */
15
+ export const SKILL_TOTAL_BYTES_DEFAULT = 2 * 1024 * 1024 * 1024;
15
16
  /** The file every skill has: its frontmatter and instructions. */
16
17
  export const SKILL_ENTRY = "SKILL.md";
17
18
  /** Where a session's sandbox holds each skill's files, read-only: `/skills/<name>@<hash>/`. */
18
19
  export const SKILLS_MOUNT = "/skills";
20
+ /**
21
+ * The longest path of a file in a skill's folder: what the longest path a workspace's file
22
+ * system takes (`FILE_PATH_MAX`) leaves under the skill's mount folder, `/skills/<name>@<12 hex>/`
23
+ * with a name as long as a file name may be.
24
+ */
25
+ export const SKILL_FILE_PATH_MAX = FILE_PATH_MAX - `${SKILLS_MOUNT}/${"n".repeat(FILE_NAME_MAX)}@${"0".repeat(12)}/`.length;
19
26
  /**
20
27
  * The folder of a sandbox that holds one version of a skill, read-only (D66):
21
28
  * `/skills/<name>@<12 hex>`, the hex from the SHA-256 of its canonical file map. A version keeps
@@ -50,14 +57,12 @@ export function skillFilesIssue(files) {
50
57
  if (!files || typeof files !== "object" || Array.isArray(files))
51
58
  return `files must map each path in the skill's folder to sha256:<hex>`;
52
59
  const entries = Object.entries(files);
53
- if (entries.length > SKILL_FILES_MAX)
54
- return `has ${entries.length} files; a skill may have at most ${SKILL_FILES_MAX}`;
55
60
  if (!(SKILL_ENTRY in files))
56
61
  return `files must include ${SKILL_ENTRY}`;
57
62
  for (const [path, hash] of entries) {
58
63
  const issue = skillFilePathIssue(path);
59
64
  if (issue)
60
- return `file path ${JSON.stringify(path.slice(0, 80))} ${issue}`;
65
+ return `file path ${JSON.stringify(path.slice(0, FILE_PATH_MAX))} ${issue}`;
61
66
  if (!isDefinitionFileHash(hash))
62
67
  return `file ${JSON.stringify(path)} must name its content as sha256:<64 lowercase hex>`;
63
68
  }
@@ -68,21 +73,30 @@ export function skillFilesIssue(files) {
68
73
  * agents it uses as tools, and those of a flow's agents, as `sha256:<hex>`.
69
74
  */
70
75
  export function definitionFilesOf(document, into = new Set()) {
76
+ for (const skill of skillsOf(document))
77
+ for (const hash of Object.values(skill.files ?? {}))
78
+ if (isDefinitionFileHash(hash))
79
+ into.add(hash);
80
+ return into;
81
+ }
82
+ /**
83
+ * Every skill a definition document carries, as written: its agents' skills, those of the agents
84
+ * it uses as tools, and those of a flow's agents. A skill two agents carry comes once for each.
85
+ */
86
+ export function* skillsOf(document) {
71
87
  if (!document || typeof document !== "object")
72
- return into;
88
+ return;
73
89
  const value = document;
74
90
  if (value.kind === "workflow") {
75
91
  for (const agent of Object.values(value.agents ?? {}))
76
- definitionFilesOf(agent, into);
77
- return into;
92
+ yield* skillsOf(agent);
93
+ return;
78
94
  }
79
95
  for (const skill of Object.values(value.skills ?? {}))
80
- for (const hash of Object.values(skill?.files ?? {}))
81
- if (isDefinitionFileHash(hash))
82
- into.add(hash);
96
+ if (skill)
97
+ yield skill;
83
98
  for (const tool of value.tools ?? [])
84
- definitionFilesOf(tool.agent, into);
85
- return into;
99
+ yield* skillsOf(tool.agent);
86
100
  }
87
101
  /**
88
102
  * A `SKILL.md`'s instructions: the text after its YAML frontmatter (`---` lines), without the
@@ -0,0 +1,20 @@
1
+ /**
2
+ * What the file systems a workspace lives on take (B15: constants fixed by a standard, not
3
+ * limits): artifact names and folder paths are written as file names and paths there, when an
4
+ * artifact is copied into a sandbox, a folder unpacked, a skill mounted or a file downloaded.
5
+ */
6
+ /**
7
+ * The longest file name: `NAME_MAX`, 255 on ext4, XFS, APFS and NTFS (POSIX `<limits.h>`).
8
+ */
9
+ export declare const FILE_NAME_MAX = 255;
10
+ /**
11
+ * The longest path: `PATH_MAX` of macOS (1024, `<sys/syslimits.h>`), where a local Runtime's
12
+ * virtual workspace lives, and the smallest of the systems a workspace lives on (Linux's is
13
+ * 4096).
14
+ */
15
+ export declare const FILE_PATH_MAX = 1024;
16
+ /**
17
+ * The longest target a symbolic link of a folder artifact may name: Linux's `PATH_MAX` (4096,
18
+ * `<linux/limits.h>`), the most `symlink(2)` stores, since a sandbox's disk is a Linux file system.
19
+ */
20
+ export declare const LINK_TARGET_MAX = 4096;