@nylorun/core 0.22.0-beta → 0.24.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 (82) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/README.md +1 -1
  3. package/dist/compatibility.d.ts +120 -47
  4. package/dist/compatibility.js +122 -49
  5. package/dist/contracts.d.ts +2824 -907
  6. package/dist/contracts.js +1286 -585
  7. package/dist/define.d.ts +9 -12
  8. package/dist/define.js +8 -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 +5 -3
  17. package/dist/definition/http-tool.js +8 -5
  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.d.ts +7 -0
  25. package/dist/definition/removed.js +21 -0
  26. package/dist/definition/sections.d.ts +63 -0
  27. package/dist/definition/sections.js +204 -0
  28. package/dist/definition/trace.d.ts +0 -7
  29. package/dist/definition/trace.js +0 -34
  30. package/dist/definition/variant.d.ts +1 -1
  31. package/dist/definition/variant.js +1 -3
  32. package/dist/harness-api/artifacts.d.ts +84 -0
  33. package/dist/harness-api/artifacts.js +128 -0
  34. package/dist/harness-api/gates.d.ts +0 -4
  35. package/dist/harness-api/gates.js +0 -4
  36. package/dist/harness-api/harness-api.schema.json +2798 -1124
  37. package/dist/harness-api/index.d.ts +9 -6
  38. package/dist/harness-api/index.js +9 -6
  39. package/dist/harness-api/json-schema.js +5 -2
  40. package/dist/harness-api/mcp.d.ts +77 -30
  41. package/dist/harness-api/mcp.js +42 -25
  42. package/dist/harness-api/messages.d.ts +47 -17
  43. package/dist/harness-api/messages.js +20 -5
  44. package/dist/harness-api/schema.d.ts +609 -200
  45. package/dist/harness-api/schema.js +345 -62
  46. package/dist/harness-api/transcript.d.ts +8 -10
  47. package/dist/harness-api/transcript.js +27 -11
  48. package/dist/harness-api/transport.d.ts +7 -1
  49. package/dist/harness-api/transport.js +10 -7
  50. package/dist/manifest-schemas.d.ts +9 -5
  51. package/dist/manifest-schemas.js +23 -27
  52. package/dist/schemas/agent-manifest.schema.json +1508 -365
  53. package/dist/schemas/harness-manifest.schema.json +1273 -0
  54. package/dist/schemas/{environment-manifest.schema.json → runtime-manifest.schema.json} +165 -84
  55. package/dist/types/manifest.d.ts +72 -14
  56. package/dist/types/manifest.js +4 -0
  57. package/dist/types/model.d.ts +15 -5
  58. package/dist/utils/definition-files.d.ts +20 -6
  59. package/dist/utils/definition-files.js +31 -17
  60. package/dist/utils/file-systems.d.ts +20 -0
  61. package/dist/utils/file-systems.js +20 -0
  62. package/dist/utils/harness-id.d.ts +4 -1
  63. package/dist/utils/harness-id.js +4 -1
  64. package/dist/utils/media-types.d.ts +30 -0
  65. package/dist/utils/media-types.js +128 -0
  66. package/dist/utils/memory.d.ts +64 -0
  67. package/dist/utils/memory.js +139 -0
  68. package/dist/utils/runtime-limits.d.ts +280 -0
  69. package/dist/utils/runtime-limits.js +585 -0
  70. package/dist/utils/runtime-tools.d.ts +8 -16
  71. package/dist/utils/runtime-tools.js +8 -27
  72. package/dist/utils/sandbox.d.ts +4 -1
  73. package/dist/utils/sandbox.js +4 -1
  74. package/package.json +6 -5
  75. package/dist/definition/deferred-tools.d.ts +0 -27
  76. package/dist/definition/deferred-tools.js +0 -82
  77. package/dist/definition/runtime-manifest.d.ts +0 -30
  78. package/dist/definition/runtime-manifest.js +0 -132
  79. package/dist/definition/sandbox-tools.d.ts +0 -5
  80. package/dist/definition/sandbox-tools.js +0 -109
  81. package/dist/definition/skill-tools.d.ts +0 -23
  82. package/dist/definition/skill-tools.js +0 -76
@@ -1,24 +1,11 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://docs.nylorun.com/schemas/environment-manifest/v1.json",
4
- "title": "Nylorun environment manifest 1",
3
+ "$id": "https://docs.nylorun.com/schemas/runtime-manifest/v1.json",
4
+ "title": "Nylorun runtime manifest 1",
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "$schema": {
8
- "type": "string",
9
- "description": "This document's JSON Schema, for editors; clients drop it before saving"
10
- },
11
- "manifestSchemaVersion": {
12
- "type": "number",
13
- "const": 1
14
- },
15
- "name": {
16
- "type": "string",
17
- "description": "An environment manifest's name, such as `analyst-box`"
18
- },
19
- "description": {
20
- "type": "string",
21
- "maxLength": 1024
8
+ "type": "string"
22
9
  },
23
10
  "kind": {
24
11
  "type": "string",
@@ -38,7 +25,7 @@
38
25
  "cpus": {
39
26
  "type": "integer",
40
27
  "minimum": 1,
41
- "maximum": 64
28
+ "maximum": 9007199254740991
42
29
  },
43
30
  "memory": {
44
31
  "type": "string"
@@ -61,10 +48,6 @@
61
48
  },
62
49
  "additionalProperties": false
63
50
  },
64
- "harness": {
65
- "type": "string",
66
- "pattern": "^[a-z][a-z0-9-]{1,62}$"
67
- },
68
51
  "lifecycle": {
69
52
  "type": "object",
70
53
  "properties": {
@@ -78,15 +61,13 @@
78
61
  "additionalProperties": false
79
62
  },
80
63
  "setup": {
81
- "maxItems": 16,
82
64
  "type": "array",
83
65
  "items": {
84
66
  "type": "object",
85
67
  "properties": {
86
68
  "command": {
87
69
  "type": "string",
88
- "minLength": 1,
89
- "maxLength": 4096
70
+ "minLength": 1
90
71
  },
91
72
  "cwd": {
92
73
  "type": "string",
@@ -104,68 +85,69 @@
104
85
  }
105
86
  },
106
87
  "files": {
107
- "maxItems": 16,
108
88
  "type": "array",
109
89
  "items": {
110
90
  "anyOf": [
111
91
  {
112
- "type": "object",
113
- "properties": {
114
- "artifactId": {
115
- "type": "string"
116
- },
117
- "version": {
118
- "type": "integer",
119
- "exclusiveMinimum": 0,
120
- "maximum": 9007199254740991
121
- },
122
- "path": {
123
- "type": "string",
124
- "minLength": 1,
125
- "maxLength": 1024
126
- }
127
- },
128
- "required": [
129
- "artifactId",
130
- "version",
131
- "path"
132
- ],
133
- "additionalProperties": false
134
- },
135
- {
136
- "type": "object",
137
- "properties": {
138
- "path": {
139
- "type": "string",
140
- "minLength": 1,
141
- "maxLength": 1024
92
+ "anyOf": [
93
+ {
94
+ "type": "object",
95
+ "properties": {
96
+ "artifactId": {
97
+ "type": "string"
98
+ },
99
+ "version": {
100
+ "type": "integer",
101
+ "exclusiveMinimum": 0,
102
+ "maximum": 9007199254740991
103
+ },
104
+ "path": {
105
+ "type": "string",
106
+ "minLength": 1,
107
+ "maxLength": 1024
108
+ }
109
+ },
110
+ "required": [
111
+ "artifactId",
112
+ "version",
113
+ "path"
114
+ ],
115
+ "additionalProperties": false
142
116
  },
143
- "files": {
117
+ {
144
118
  "type": "object",
145
- "propertyNames": {
146
- "type": "string",
147
- "minLength": 1,
148
- "maxLength": 1024
119
+ "properties": {
120
+ "path": {
121
+ "type": "string",
122
+ "minLength": 1,
123
+ "maxLength": 1024
124
+ },
125
+ "files": {
126
+ "type": "object",
127
+ "propertyNames": {
128
+ "type": "string",
129
+ "minLength": 1,
130
+ "maxLength": 1024
131
+ },
132
+ "additionalProperties": {
133
+ "type": "string"
134
+ }
135
+ }
149
136
  },
150
- "additionalProperties": {
151
- "type": "string"
152
- }
137
+ "required": [
138
+ "path",
139
+ "files"
140
+ ],
141
+ "additionalProperties": false
153
142
  }
154
- },
155
- "required": [
156
- "path",
157
- "files"
158
- ],
159
- "additionalProperties": false
143
+ ]
160
144
  },
161
145
  {
162
146
  "type": "object",
163
- "description": "For the CLI only: a folder, relative to this file, that `nylorun environments manifests save` uploads by hash and saves as { path, files }",
164
147
  "properties": {
165
148
  "path": {
166
149
  "type": "string",
167
- "minLength": 1,
168
- "maxLength": 1024
150
+ "minLength": 1
169
151
  },
170
152
  "from": {
171
153
  "type": "string",
@@ -181,6 +163,55 @@
181
163
  ]
182
164
  }
183
165
  },
166
+ "limits": {
167
+ "type": "object",
168
+ "properties": {
169
+ "artifacts": {
170
+ "type": "object",
171
+ "properties": {
172
+ "fileBytes": {
173
+ "type": "integer",
174
+ "exclusiveMinimum": 0,
175
+ "maximum": 9007199254740991
176
+ },
177
+ "totalBytes": {
178
+ "type": "integer",
179
+ "exclusiveMinimum": 0,
180
+ "maximum": 9007199254740991
181
+ }
182
+ },
183
+ "additionalProperties": false
184
+ },
185
+ "skills": {
186
+ "type": "object",
187
+ "properties": {
188
+ "totalBytes": {
189
+ "type": "integer",
190
+ "exclusiveMinimum": 0,
191
+ "maximum": 9007199254740991
192
+ }
193
+ },
194
+ "additionalProperties": false
195
+ },
196
+ "disk": {
197
+ "type": "object",
198
+ "properties": {
199
+ "versionBytes": {
200
+ "type": "integer",
201
+ "exclusiveMinimum": 0,
202
+ "maximum": 9007199254740991
203
+ },
204
+ "versionEntries": {
205
+ "type": "integer",
206
+ "exclusiveMinimum": 0,
207
+ "maximum": 9007199254740991
208
+ }
209
+ },
210
+ "additionalProperties": false
211
+ }
212
+ },
213
+ "additionalProperties": false
214
+ },
184
215
  "secrets": {
185
216
  "type": "object",
186
217
  "propertyNames": {
@@ -197,7 +228,6 @@
197
228
  },
198
229
  "allowedHosts": {
199
230
  "minItems": 1,
200
- "maxItems": 32,
201
231
  "type": "array",
202
232
  "items": {
203
233
  "type": "string"
@@ -225,8 +255,7 @@
225
255
  "type": "boolean"
226
256
  },
227
257
  "description": {
228
- "type": "string",
229
- "maxLength": 500
258
+ "type": "string"
230
259
  }
231
260
  },
232
261
  "required": [
@@ -246,8 +275,7 @@
246
275
  "type": "boolean"
247
276
  },
248
277
  "description": {
249
- "type": "string",
250
- "maxLength": 500
278
+ "type": "string"
251
279
  }
252
280
  },
253
281
  "required": [
@@ -286,8 +314,7 @@
286
314
  "type": "boolean"
287
315
  },
288
316
  "description": {
289
- "type": "string",
290
- "maxLength": 500
317
+ "type": "string"
291
318
  }
292
319
  },
293
320
  "required": [
@@ -327,8 +354,7 @@
327
354
  "type": "boolean"
328
355
  },
329
356
  "description": {
330
- "type": "string",
331
- "maxLength": 500
357
+ "type": "string"
332
358
  }
333
359
  },
334
360
  "required": [
@@ -339,11 +365,66 @@
339
365
  }
340
366
  ]
341
367
  }
368
+ },
369
+ "triggers": {
370
+ "description": "What starts the Agent's turns with no client connected, by trigger id (D74)",
371
+ "type": "object",
372
+ "propertyNames": {
373
+ "type": "string",
374
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",
375
+ "description": "A trigger's id, such as `hourly-check`"
376
+ },
377
+ "additionalProperties": {
378
+ "$ref": "#/$defs/Trigger"
379
+ }
380
+ },
381
+ "selfWake": {
382
+ "description": "Offer the agent schedule_wake: it books its session's next turn itself (D77)",
383
+ "type": "boolean"
342
384
  }
343
385
  },
344
386
  "required": [
345
- "manifestSchemaVersion",
346
- "name"
387
+ "kind"
347
388
  ],
348
- "additionalProperties": false
389
+ "additionalProperties": false,
390
+ "$defs": {
391
+ "Trigger": {
392
+ "type": "object",
393
+ "properties": {
394
+ "schedule": {
395
+ "type": "string",
396
+ "pattern": "^\\S+(\\s+\\S+){4}$"
397
+ },
398
+ "timezone": {
399
+ "type": "string",
400
+ "minLength": 1
401
+ },
402
+ "at": {
403
+ "type": "string",
404
+ "format": "date-time",
405
+ "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
406
+ },
407
+ "webhook": {
408
+ "type": "string",
409
+ "enum": [
410
+ "standard-webhooks"
411
+ ]
412
+ },
413
+ "session": {
414
+ "type": "string",
415
+ "minLength": 1,
416
+ "maxLength": 200
417
+ },
418
+ "prompt": {
419
+ "type": "string",
420
+ "minLength": 1
421
+ }
422
+ },
423
+ "required": [
424
+ "session",
425
+ "prompt"
426
+ ],
427
+ "additionalProperties": false
428
+ }
429
+ }
349
430
  }
@@ -1,5 +1,5 @@
1
1
  import type { JsonObject } from "./shared.js";
2
- import type { WorkflowManifest } from "./workflow.js";
2
+ import type { WorkflowManifest, WorkflowNode } from "./workflow.js";
3
3
  /**
4
4
  * Published manifest schema version (no top-level model — Runtime-owned). Version 7 is flat: the
5
5
  * agent's instructions, tools, skills and MCP servers sit at the top level, with no capabilities.
@@ -88,8 +88,9 @@ export interface McpToolSettings {
88
88
  readonly approval?: ApprovalMode;
89
89
  /**
90
90
  * `true`: the tool leaves the model's tool list; the model finds it with `tool_search` and runs
91
- * it with `tool_call` (R2b C10). Default: the server's `deferred`, else deferred when the
92
- * 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.
93
94
  */
94
95
  readonly deferred?: boolean;
95
96
  }
@@ -139,16 +140,6 @@ export interface SandboxManifest {
139
140
  /** Stop compute after this long without use, e.g. "15m". Files persist. */
140
141
  readonly idle?: string;
141
142
  }
142
- /**
143
- * What the Runtime adds to a session's agent when it pins it: the session's sandbox, the tools the
144
- * Runtime serves (the sandbox tools, the artifact tools, the skill tools) and the text that goes
145
- * with them. Only the Runtime writes it; a definition or a turn variant that sets it is refused.
146
- */
147
- export interface RuntimeManifest {
148
- readonly sandbox?: SandboxManifest;
149
- readonly tools?: readonly ToolManifest[];
150
- readonly instructions?: readonly string[];
151
- }
152
143
  export interface AgentManifest {
153
144
  readonly manifestSchemaVersion: ManifestSchemaVersion;
154
145
  readonly id: string;
@@ -162,7 +153,6 @@ export interface AgentManifest {
162
153
  readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
163
154
  /** What the agent needs of its session's Environment, checked when a session opens (D65). */
164
155
  readonly requires?: AgentRequirements;
165
- readonly runtime?: RuntimeManifest;
166
156
  }
167
157
  /** What an agent needs of the Environment its session opens on (protocol 14, D65). */
168
158
  export interface AgentRequirements {
@@ -171,4 +161,72 @@ export interface AgentRequirements {
171
161
  /** Secret names (environment variables) its skills' scripts read, which the vault must hold. */
172
162
  readonly secrets?: readonly string[];
173
163
  }
164
+ /**
165
+ * Agent manifest v8 (protocol 16, track T2): one versioned document saved at
166
+ * `/v1/agent-manifests/{name}`, with what runs inside the agent loop (`harness`) and what the
167
+ * Runtime provides around it (`runtime`). An Agent is made from one version of it.
168
+ */
169
+ export type AgentManifestV8SchemaVersion = 8;
170
+ /** A skill as an agent manifest v8 declares it: a v7 skill, and the secret slots its scripts read. */
171
+ export interface HarnessSkill extends SkillManifest {
172
+ /**
173
+ * The `runtime.secrets` slots its scripts read, each of type `environment_secret` or
174
+ * `environment_variable`: checked when the manifest is saved. Replaces `requires.secrets`.
175
+ */
176
+ readonly secrets?: readonly string[];
177
+ }
178
+ /** A remote MCP server as an agent manifest v8 declares it: no `approval`, which v8 refuses. */
179
+ export type HarnessMcpServer = (McpServerManifest extends infer Server ? Server extends unknown ? Omit<Server, "approval"> : never : never) & {
180
+ /**
181
+ * The `runtime.secrets` slot of type `bearer` or `headers` bound to this server's URL: checked
182
+ * when the manifest is saved. A server that names none keeps matching the vault by its URL.
183
+ */
184
+ readonly credential?: string;
185
+ };
186
+ /** What runs inside the loop of an agent: the `harness` section of an agent manifest v8. */
187
+ export interface AgentHarnessSection {
188
+ /** The harness that runs the loop: `nylorun` (ours, the default) or a custom harness's id. */
189
+ readonly id?: string;
190
+ readonly instructions?: readonly string[];
191
+ /** An HTTP tool's `credential` names a `runtime.secrets` slot, checked at save. */
192
+ readonly tools?: readonly ToolManifest[];
193
+ readonly skills?: Readonly<Record<string, HarnessSkill>>;
194
+ readonly mcpServers?: Readonly<Record<string, HarnessMcpServer>>;
195
+ /** The Agent Plugins folded into it when it was composed, so a version records what built it. */
196
+ readonly plugins?: readonly PluginLabel[];
197
+ readonly outputSchema?: JsonObject;
198
+ /** The harness's own settings: passed to it in `turn.start`, never read by the Runtime. */
199
+ readonly loop?: JsonObject;
200
+ /** Turns on the Agent's memory (track T5, D72): Markdown files it keeps across sessions. */
201
+ readonly memory?: AgentMemorySettings;
202
+ }
203
+ /**
204
+ * `harness.memory` (track T5, D72): the Agent's memory, the same in every turn whoever starts it.
205
+ * `access` is `read_write` (the default) or `read_only`; `instructions` tell the model what this
206
+ * agent should remember, after the engine's own memory rules.
207
+ */
208
+ export interface AgentMemorySettings {
209
+ readonly access?: "read_write" | "read_only";
210
+ readonly instructions?: string;
211
+ }
212
+ /**
213
+ * A flow's `harness` section: workflow manifest v3's flow without its identity, which the
214
+ * manifest holds, or its sandbox, which the `runtime` section provides.
215
+ */
216
+ export interface WorkflowHarnessSection {
217
+ readonly kind: "workflow";
218
+ /** Flows run in our harness: `nylorun` when set. */
219
+ readonly id?: string;
220
+ readonly inputSchema?: JsonObject;
221
+ readonly outputSchema?: JsonObject;
222
+ readonly root: WorkflowNode;
223
+ readonly agents: Readonly<Record<string, AgentManifest | WorkflowManifest>>;
224
+ readonly plugins?: readonly PluginLabel[];
225
+ readonly loop?: JsonObject;
226
+ }
227
+ export type HarnessSection = AgentHarnessSection | WorkflowHarnessSection;
174
228
  export {};
229
+ /**
230
+ * The rest of agent manifest v8 (`AgentManifestV8`, `RuntimeSection`) is the zod schemas' output
231
+ * in `contracts.ts`: the runtime section reuses environment manifest v1's field schemas.
232
+ */
@@ -1 +1,5 @@
1
1
  export {};
2
+ /**
3
+ * The rest of agent manifest v8 (`AgentManifestV8`, `RuntimeSection`) is the zod schemas' output
4
+ * in `contracts.ts`: the runtime section reuses environment manifest v1's field schemas.
5
+ */
@@ -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
  /**
@@ -127,6 +132,11 @@ export interface ModelRequest {
127
132
  /** Canonical, immutable Harness-owned model configuration for this call. */
128
133
  readonly configuration: ModelConfigurationSnapshot;
129
134
  readonly instructions: readonly string[];
135
+ /**
136
+ * Text the engine keeps at the head of the conversation, after the instructions, as user-role
137
+ * context: the Agent's memory index (track T5). The same for every call until it is re-pinned.
138
+ */
139
+ readonly pinned?: readonly string[];
130
140
  readonly context: ContextSnapshot;
131
141
  readonly transcript: readonly TranscriptEntry[];
132
142
  readonly arrivals: readonly InputEvent[];
@@ -191,21 +201,21 @@ export interface ModelCall {
191
201
  readonly model?: ModelDirective;
192
202
  readonly prompt: readonly PromptItem[];
193
203
  readonly tools: readonly ModelCallTool[];
194
- /** Optional portable contract for this turn's terminal JSON result. */
195
- readonly outputSchema?: JsonObject;
196
204
  readonly executionId: string;
197
205
  }
198
206
  export interface ModelAdapterContext {
199
207
  readonly request: ModelRequest;
200
208
  readonly invocationId: string;
201
209
  readonly signal: AbortSignal;
202
- /** Set when the engine calls the model to summarize history (Model Calls §8). */
210
+ /**
211
+ * Set when the engine calls the model to summarize history (Model Calls §8). Engine-internal:
212
+ * the call's effect says `purpose: "summary"`, and the compaction's facts go with its
213
+ * transcript edit.
214
+ */
203
215
  readonly compaction?: {
204
216
  readonly trigger: "threshold" | "overflow";
205
217
  readonly tokensBefore: number;
206
218
  readonly keptTokens: number;
207
- /** An intermediate call of a chunked summary; only the last one completes the compaction. */
208
- readonly partial?: boolean;
209
219
  };
210
220
  /** Publishes one JSON-safe provider request derived from the canonical ModelCall. */
211
221
  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;