@nylorun/core 0.20.0-beta → 0.22.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 (90) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +2 -2
  3. package/dist/compatibility.d.ts +88 -13
  4. package/dist/compatibility.js +88 -13
  5. package/dist/contracts.d.ts +1328 -110
  6. package/dist/contracts.js +563 -163
  7. package/dist/define.d.ts +15 -13
  8. package/dist/define.js +11 -8
  9. package/dist/definition/approval.js +12 -14
  10. package/dist/definition/assemble.d.ts +6 -10
  11. package/dist/definition/assemble.js +48 -105
  12. package/dist/definition/bind-agent.d.ts +3 -4
  13. package/dist/definition/bind-agent.js +12 -30
  14. package/dist/definition/binding.d.ts +2 -2
  15. package/dist/definition/bound.d.ts +10 -10
  16. package/dist/definition/builder.d.ts +16 -20
  17. package/dist/definition/builder.js +29 -81
  18. package/dist/definition/code-tools.d.ts +3 -3
  19. package/dist/definition/code-tools.js +6 -21
  20. package/dist/definition/declaration.d.ts +4 -7
  21. package/dist/definition/declaration.js +29 -99
  22. package/dist/definition/{tools-capability.d.ts → deferred-tools.d.ts} +3 -13
  23. package/dist/definition/{tools-capability.js → deferred-tools.js} +2 -18
  24. package/dist/definition/delegate.d.ts +2 -4
  25. package/dist/definition/delegate.js +8 -10
  26. package/dist/definition/from.d.ts +7 -4
  27. package/dist/definition/from.js +72 -117
  28. package/dist/definition/helpers.d.ts +0 -7
  29. package/dist/definition/helpers.js +0 -5
  30. package/dist/definition/http-tool.d.ts +49 -5
  31. package/dist/definition/http-tool.js +167 -5
  32. package/dist/definition/implementations.d.ts +6 -8
  33. package/dist/definition/manifest.d.ts +11 -5
  34. package/dist/definition/manifest.js +26 -26
  35. package/dist/definition/mcp.d.ts +1 -52
  36. package/dist/definition/mcp.js +0 -52
  37. package/dist/definition/media-reference.d.ts +23 -0
  38. package/dist/definition/media-reference.js +26 -0
  39. package/dist/definition/removed.d.ts +3 -10
  40. package/dist/definition/removed.js +10 -17
  41. package/dist/definition/runtime-manifest.d.ts +30 -0
  42. package/dist/definition/runtime-manifest.js +132 -0
  43. package/dist/definition/sandbox-tools.d.ts +1 -1
  44. package/dist/definition/sandbox-tools.js +1 -1
  45. package/dist/definition/skill-tools.d.ts +13 -7
  46. package/dist/definition/skill-tools.js +23 -10
  47. package/dist/definition/trace.d.ts +18 -0
  48. package/dist/definition/trace.js +42 -0
  49. package/dist/definition/variant.d.ts +5 -4
  50. package/dist/definition/variant.js +18 -51
  51. package/dist/definition/workflow/runnable.js +1 -1
  52. package/dist/errors.d.ts +1 -1
  53. package/dist/harness-api/entries.d.ts +1 -0
  54. package/dist/harness-api/entries.js +1 -0
  55. package/dist/harness-api/gates.d.ts +1 -6
  56. package/dist/harness-api/gates.js +1 -3
  57. package/dist/harness-api/harness-api.schema.json +11 -92
  58. package/dist/harness-api/index.d.ts +2 -2
  59. package/dist/harness-api/index.js +2 -2
  60. package/dist/harness-api/mcp.d.ts +0 -4
  61. package/dist/harness-api/mcp.js +0 -2
  62. package/dist/harness-api/messages.d.ts +1 -3
  63. package/dist/harness-api/messages.js +1 -3
  64. package/dist/harness-api/schema.d.ts +5 -17
  65. package/dist/harness-api/schema.js +9 -6
  66. package/dist/index.d.ts +1 -1
  67. package/dist/manifest-schemas.d.ts +6 -0
  68. package/dist/manifest-schemas.js +46 -0
  69. package/dist/schemas/agent-manifest.schema.json +905 -0
  70. package/dist/schemas/environment-manifest.schema.json +349 -0
  71. package/dist/types/agent.d.ts +1 -1
  72. package/dist/types/manifest.d.ts +47 -24
  73. package/dist/types/model.d.ts +2 -2
  74. package/dist/types/observe.d.ts +5 -18
  75. package/dist/types/part.d.ts +25 -0
  76. package/dist/types/tool.d.ts +1 -1
  77. package/dist/types/transcript.d.ts +5 -0
  78. package/dist/utils/definition-files.d.ts +11 -6
  79. package/dist/utils/definition-files.js +19 -9
  80. package/dist/utils/runtime-tools.d.ts +19 -0
  81. package/dist/utils/runtime-tools.js +30 -0
  82. package/dist/utils/sandbox.d.ts +1 -1
  83. package/dist/utils/sandbox.js +1 -1
  84. package/package.json +9 -3
  85. package/dist/definition/capability.d.ts +0 -43
  86. package/dist/definition/capability.js +0 -82
  87. package/dist/definition/sandbox-capability.d.ts +0 -44
  88. package/dist/definition/sandbox-capability.js +0 -139
  89. package/dist/types/middleware.d.ts +0 -94
  90. /package/dist/types/{middleware.js → part.js} +0 -0
@@ -0,0 +1,349 @@
1
+ {
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",
5
+ "type": "object",
6
+ "properties": {
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
22
+ },
23
+ "kind": {
24
+ "type": "string",
25
+ "enum": [
26
+ "virtual",
27
+ "pod",
28
+ "none"
29
+ ]
30
+ },
31
+ "image": {
32
+ "type": "string",
33
+ "minLength": 1
34
+ },
35
+ "resources": {
36
+ "type": "object",
37
+ "properties": {
38
+ "cpus": {
39
+ "type": "integer",
40
+ "minimum": 1,
41
+ "maximum": 64
42
+ },
43
+ "memory": {
44
+ "type": "string"
45
+ }
46
+ },
47
+ "additionalProperties": false
48
+ },
49
+ "storage": {
50
+ "type": "string"
51
+ },
52
+ "network": {
53
+ "type": "object",
54
+ "properties": {
55
+ "allowedHosts": {
56
+ "type": "array",
57
+ "items": {
58
+ "type": "string"
59
+ }
60
+ }
61
+ },
62
+ "additionalProperties": false
63
+ },
64
+ "harness": {
65
+ "type": "string",
66
+ "pattern": "^[a-z][a-z0-9-]{1,62}$"
67
+ },
68
+ "lifecycle": {
69
+ "type": "object",
70
+ "properties": {
71
+ "idle": {
72
+ "type": "string"
73
+ },
74
+ "deleteAfter": {
75
+ "type": "string"
76
+ }
77
+ },
78
+ "additionalProperties": false
79
+ },
80
+ "setup": {
81
+ "maxItems": 16,
82
+ "type": "array",
83
+ "items": {
84
+ "type": "object",
85
+ "properties": {
86
+ "command": {
87
+ "type": "string",
88
+ "minLength": 1,
89
+ "maxLength": 4096
90
+ },
91
+ "cwd": {
92
+ "type": "string",
93
+ "minLength": 1,
94
+ "maxLength": 1024
95
+ },
96
+ "timeout": {
97
+ "type": "string"
98
+ }
99
+ },
100
+ "required": [
101
+ "command"
102
+ ],
103
+ "additionalProperties": false
104
+ }
105
+ },
106
+ "files": {
107
+ "maxItems": 16,
108
+ "type": "array",
109
+ "items": {
110
+ "anyOf": [
111
+ {
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
142
+ },
143
+ "files": {
144
+ "type": "object",
145
+ "propertyNames": {
146
+ "type": "string",
147
+ "minLength": 1,
148
+ "maxLength": 1024
149
+ },
150
+ "additionalProperties": {
151
+ "type": "string"
152
+ }
153
+ }
154
+ },
155
+ "required": [
156
+ "path",
157
+ "files"
158
+ ],
159
+ "additionalProperties": false
160
+ },
161
+ {
162
+ "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
+ "properties": {
165
+ "path": {
166
+ "type": "string",
167
+ "minLength": 1,
168
+ "maxLength": 1024
169
+ },
170
+ "from": {
171
+ "type": "string",
172
+ "minLength": 1
173
+ }
174
+ },
175
+ "required": [
176
+ "path",
177
+ "from"
178
+ ],
179
+ "additionalProperties": false
180
+ }
181
+ ]
182
+ }
183
+ },
184
+ "secrets": {
185
+ "type": "object",
186
+ "propertyNames": {
187
+ "type": "string"
188
+ },
189
+ "additionalProperties": {
190
+ "oneOf": [
191
+ {
192
+ "type": "object",
193
+ "properties": {
194
+ "type": {
195
+ "type": "string",
196
+ "const": "environment_secret"
197
+ },
198
+ "allowedHosts": {
199
+ "minItems": 1,
200
+ "maxItems": 32,
201
+ "type": "array",
202
+ "items": {
203
+ "type": "string"
204
+ }
205
+ },
206
+ "inject": {
207
+ "type": "object",
208
+ "properties": {
209
+ "header": {
210
+ "type": "string",
211
+ "pattern": "^[!#$%&'*+.^_`|~0-9A-Za-z-]+$"
212
+ },
213
+ "format": {
214
+ "type": "string",
215
+ "minLength": 1
216
+ }
217
+ },
218
+ "required": [
219
+ "header",
220
+ "format"
221
+ ],
222
+ "additionalProperties": false
223
+ },
224
+ "required": {
225
+ "type": "boolean"
226
+ },
227
+ "description": {
228
+ "type": "string",
229
+ "maxLength": 500
230
+ }
231
+ },
232
+ "required": [
233
+ "type",
234
+ "allowedHosts"
235
+ ],
236
+ "additionalProperties": false
237
+ },
238
+ {
239
+ "type": "object",
240
+ "properties": {
241
+ "type": {
242
+ "type": "string",
243
+ "const": "environment_variable"
244
+ },
245
+ "required": {
246
+ "type": "boolean"
247
+ },
248
+ "description": {
249
+ "type": "string",
250
+ "maxLength": 500
251
+ }
252
+ },
253
+ "required": [
254
+ "type"
255
+ ],
256
+ "additionalProperties": false
257
+ },
258
+ {
259
+ "type": "object",
260
+ "properties": {
261
+ "type": {
262
+ "type": "string",
263
+ "const": "bearer"
264
+ },
265
+ "url": {
266
+ "type": "string",
267
+ "minLength": 1
268
+ },
269
+ "via": {
270
+ "type": "string"
271
+ },
272
+ "identity": {
273
+ "type": "object",
274
+ "properties": {
275
+ "header": {
276
+ "type": "string",
277
+ "pattern": "^[!#$%&'*+.^_`|~0-9A-Za-z-]+$"
278
+ }
279
+ },
280
+ "required": [
281
+ "header"
282
+ ],
283
+ "additionalProperties": false
284
+ },
285
+ "required": {
286
+ "type": "boolean"
287
+ },
288
+ "description": {
289
+ "type": "string",
290
+ "maxLength": 500
291
+ }
292
+ },
293
+ "required": [
294
+ "type",
295
+ "url"
296
+ ],
297
+ "additionalProperties": false
298
+ },
299
+ {
300
+ "type": "object",
301
+ "properties": {
302
+ "type": {
303
+ "type": "string",
304
+ "const": "headers"
305
+ },
306
+ "url": {
307
+ "type": "string",
308
+ "minLength": 1
309
+ },
310
+ "via": {
311
+ "type": "string"
312
+ },
313
+ "identity": {
314
+ "type": "object",
315
+ "properties": {
316
+ "header": {
317
+ "type": "string",
318
+ "pattern": "^[!#$%&'*+.^_`|~0-9A-Za-z-]+$"
319
+ }
320
+ },
321
+ "required": [
322
+ "header"
323
+ ],
324
+ "additionalProperties": false
325
+ },
326
+ "required": {
327
+ "type": "boolean"
328
+ },
329
+ "description": {
330
+ "type": "string",
331
+ "maxLength": 500
332
+ }
333
+ },
334
+ "required": [
335
+ "type",
336
+ "url"
337
+ ],
338
+ "additionalProperties": false
339
+ }
340
+ ]
341
+ }
342
+ }
343
+ },
344
+ "required": [
345
+ "manifestSchemaVersion",
346
+ "name"
347
+ ],
348
+ "additionalProperties": false
349
+ }
@@ -1,6 +1,6 @@
1
1
  import type { AgentBinding } from "../definition/binding.js";
2
2
  import type { AgentManifest } from "./manifest.js";
3
- /** An agent definition composed with Agent(...).use(...). Optional `.build()` is a no-op facade. */
3
+ /** An agent definition built with Agent(...). Optional `.build()` is a no-op facade. */
4
4
  export interface BuiltAgent<Info = unknown, Output = string> {
5
5
  readonly id: string;
6
6
  readonly name?: string;
@@ -1,24 +1,37 @@
1
1
  import type { JsonObject } from "./shared.js";
2
2
  import type { WorkflowManifest } from "./workflow.js";
3
3
  /**
4
- * Published manifest schema version (no top-level model — Runtime-owned). Version 6 (R2b C9) adds
5
- * an MCP server's `tools` and `deferred`; a manifest that uses neither stays version 5, so its
6
- * hash is unchanged, and the Runtime accepts both.
4
+ * Published manifest schema version (no top-level model — Runtime-owned). Version 7 is flat: the
5
+ * agent's instructions, tools, skills and MCP servers sit at the top level, with no capabilities.
7
6
  */
8
- export type ManifestSchemaVersion = 5 | 6;
7
+ export type ManifestSchemaVersion = 7;
8
+ /** Which Agent Plugin brought a skill or an MCP server: its `plugin.json` name and version. */
9
+ export interface PluginLabel {
10
+ readonly name: string;
11
+ readonly version?: string;
12
+ }
9
13
  /**
10
14
  * Whether each call waits for a person's approval, in a manifest saved before R5 step 2 (the
11
15
  * Tool Gate holds such a call). New definitions use the Tenant's tool policy instead.
12
16
  */
13
17
  export type ApprovalMode = "never" | "always";
14
- /** The methods an HTTP tool may use: each sends the tool input as a JSON body. */
15
- export type HttpToolMethod = "POST" | "PUT" | "PATCH";
16
18
  /**
17
- * A tool the Runtime runs as one HTTP request through its Tool Gate: the input as a JSON body,
18
- * 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.
19
27
  */
20
28
  export interface HttpToolTarget {
21
- /** 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
+ */
22
35
  readonly url: string;
23
36
  /** Default `POST`. */
24
37
  readonly method?: HttpToolMethod;
@@ -61,6 +74,8 @@ export interface SkillManifest {
61
74
  * the Runtime holds and serves. `SKILL.md` is required.
62
75
  */
63
76
  readonly files: Readonly<Record<string, string>>;
77
+ /** The Agent Plugin that brought the skill. Absent: the agent's own. */
78
+ readonly plugin?: PluginLabel;
64
79
  }
65
80
  /**
66
81
  * One tool's settings on an MCP server (manifest v6, R2b C9). Each setting resolves from the
@@ -92,6 +107,8 @@ interface McpServerFields {
92
107
  * entry per wanted tool make an allowlist.
93
108
  */
94
109
  readonly tools?: Readonly<Record<string, McpToolSettings>>;
110
+ /** The Agent Plugin that brought the server. Absent: the agent's own. */
111
+ readonly plugin?: PluginLabel;
95
112
  }
96
113
  /** A remote MCP server, declared by URL. Nylorun accepts no stdio servers (`stdioMcpRefusal`). */
97
114
  export type McpServerManifest = (McpServerFields & {
@@ -122,21 +139,15 @@ export interface SandboxManifest {
122
139
  /** Stop compute after this long without use, e.g. "15m". Files persist. */
123
140
  readonly idle?: string;
124
141
  }
125
- export interface CapabilityManifest {
126
- readonly id: string;
127
- readonly type: "agent" | "agent-plugin";
128
- readonly name?: string;
129
- readonly description?: string;
130
- readonly metadata?: JsonObject;
131
- readonly instructions?: readonly string[];
132
- readonly skills?: Readonly<Record<string, SkillManifest>>;
133
- readonly tools?: readonly ToolManifest[];
134
- readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
135
- /** Present when this capability gives the agent a Runtime-owned sandbox. */
136
- readonly sandbox?: SandboxManifest;
137
- }
138
- /** Reserved. Empty until later fields are defined. Omit `runtime` while it has no fields. */
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
+ */
139
147
  export interface RuntimeManifest {
148
+ readonly sandbox?: SandboxManifest;
149
+ readonly tools?: readonly ToolManifest[];
150
+ readonly instructions?: readonly string[];
140
151
  }
141
152
  export interface AgentManifest {
142
153
  readonly manifestSchemaVersion: ManifestSchemaVersion;
@@ -145,7 +156,19 @@ export interface AgentManifest {
145
156
  readonly description?: string;
146
157
  readonly metadata?: JsonObject;
147
158
  readonly outputSchema?: JsonObject;
148
- readonly capabilities: readonly CapabilityManifest[];
159
+ readonly instructions?: readonly string[];
160
+ readonly tools?: readonly ToolManifest[];
161
+ readonly skills?: Readonly<Record<string, SkillManifest>>;
162
+ readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
163
+ /** What the agent needs of its session's Environment, checked when a session opens (D65). */
164
+ readonly requires?: AgentRequirements;
149
165
  readonly runtime?: RuntimeManifest;
150
166
  }
167
+ /** What an agent needs of the Environment its session opens on (protocol 14, D65). */
168
+ export interface AgentRequirements {
169
+ /** `any`: kind `virtual` or `pod`; `pod`: kind `pod`; `none`: nothing. */
170
+ readonly sandbox?: "none" | "any" | "pod";
171
+ /** Secret names (environment variables) its skills' scripts read, which the vault must hold. */
172
+ readonly secrets?: readonly string[];
173
+ }
151
174
  export {};
@@ -78,7 +78,7 @@ export interface ModelConfigurationMutationOptions {
78
78
  readonly reason?: string;
79
79
  }
80
80
  export interface ModelConfigurationContributor {
81
- readonly middlewareId: string;
81
+ readonly partId: string;
82
82
  readonly slot: string;
83
83
  readonly order: number;
84
84
  readonly reason?: string;
@@ -109,7 +109,7 @@ export interface ContextMutationOptions {
109
109
  readonly reason?: string;
110
110
  }
111
111
  export interface ContextContributor {
112
- readonly middlewareId: string;
112
+ readonly partId: string;
113
113
  readonly slot: string;
114
114
  readonly order: number;
115
115
  readonly reason?: string;
@@ -78,7 +78,7 @@ export interface ObserveSealedCall {
78
78
  readonly args: JsonValue;
79
79
  readonly invocationId: string;
80
80
  readonly owner: {
81
- readonly middlewareId: string;
81
+ readonly partId: string;
82
82
  readonly slot: string;
83
83
  };
84
84
  readonly interaction?: RequiredInteraction;
@@ -130,19 +130,6 @@ export type ObserveEvent = {
130
130
  readonly toolResults: readonly ToolResult[];
131
131
  readonly transcript: readonly TranscriptEntry[];
132
132
  };
133
- } | {
134
- readonly type: "middleware.entered" | "middleware.completed";
135
- readonly turnId: string;
136
- readonly stepId: string;
137
- readonly inputId?: string;
138
- readonly middlewareId: string;
139
- } | {
140
- readonly type: "middleware.lease-violation";
141
- readonly turnId: string;
142
- readonly stepId: string;
143
- readonly inputId?: string;
144
- readonly middlewareId: string;
145
- readonly reason: string;
146
133
  } | {
147
134
  readonly type: "tool.sealed";
148
135
  readonly turnId: string;
@@ -161,7 +148,7 @@ export type ObserveEvent = {
161
148
  readonly toolName: string;
162
149
  readonly callId: string;
163
150
  readonly invocationId: string;
164
- readonly middlewareId: string;
151
+ readonly partId: string;
165
152
  readonly slot: string;
166
153
  readonly attributes: {
167
154
  readonly args: JsonValue;
@@ -175,7 +162,7 @@ export type ObserveEvent = {
175
162
  readonly toolName: string;
176
163
  readonly callId: string;
177
164
  readonly invocationId: string;
178
- readonly middlewareId: string;
165
+ readonly partId: string;
179
166
  readonly slot: string;
180
167
  readonly attributes: {
181
168
  readonly message: string;
@@ -190,7 +177,7 @@ export type ObserveEvent = {
190
177
  readonly toolName: string;
191
178
  readonly callId: string;
192
179
  readonly invocationId: string;
193
- readonly middlewareId: string;
180
+ readonly partId: string;
194
181
  readonly slot: string;
195
182
  readonly outcome: string;
196
183
  readonly code?: string;
@@ -204,7 +191,7 @@ export type ObserveEvent = {
204
191
  readonly toolName: string;
205
192
  readonly callId: string;
206
193
  readonly invocationId: string;
207
- readonly middlewareId: string;
194
+ readonly partId: string;
208
195
  readonly slot: string;
209
196
  readonly attributes: {
210
197
  readonly token?: JsonValue;
@@ -0,0 +1,25 @@
1
+ import type { AgentTool } from "./agent.js";
2
+ import type { McpServerManifest, SkillManifest } from "./manifest.js";
3
+ import type { ToolDefinition } from "./tool.js";
4
+ /**
5
+ * The bytes of one skill file the manifest names (`SkillManifest.files`), held on the developer
6
+ * binding: the client uploads the files the Runtime lacks before it registers the agent. Not a
7
+ * manifest field.
8
+ */
9
+ export interface SkillFileSource {
10
+ readonly size: number;
11
+ read(): Promise<Uint8Array>;
12
+ }
13
+ /**
14
+ * @internal What one builder call, skills folder or plugin adds to an agent. The manifest holds
15
+ * the agent's parts merged: a plugin's skills and servers carry its `plugin` label.
16
+ */
17
+ export interface PartDeclaration<Info = unknown> {
18
+ readonly id: string;
19
+ readonly tools?: readonly (ToolDefinition<any, Info, any> | AgentTool)[];
20
+ readonly instructions?: readonly string[];
21
+ readonly skills?: Readonly<Record<string, SkillManifest>>;
22
+ /** Each skill file's bytes, by `sha256:<hex>`, for the client to upload. Not projected into the manifest. */
23
+ readonly skillFiles?: Readonly<Record<string, SkillFileSource>>;
24
+ readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
25
+ }
@@ -83,7 +83,7 @@ export interface ToolDefinition<InputSchema extends ToolInputSchema = ToolInputS
83
83
  /** A plain return value is treated as `{ kind: "completed", output }`. Legacy tagged outcomes remain valid. */
84
84
  export type ToolRunResult<Output = ToolContent> = Output | ToolOutcome<Output>;
85
85
  export interface ToolOwner {
86
- readonly middlewareId: string;
86
+ readonly partId: string;
87
87
  readonly slot: string;
88
88
  }
89
89
  export interface Interaction {
@@ -74,5 +74,10 @@ export interface TranscriptCompactionEntry {
74
74
  readonly trigger: "threshold" | "overflow";
75
75
  readonly tokensBefore: number;
76
76
  readonly tokensAfter: number;
77
+ /**
78
+ * The reference lines of the files the summarized part named (protocol 12), carried across
79
+ * compactions so the model can still read them with `read_artifact`.
80
+ */
81
+ readonly files?: readonly string[];
77
82
  }
78
83
  export type TranscriptEntry = TranscriptInputEntry | TranscriptCandidateEntry | TranscriptToolsEntry | TranscriptFinalEntry | TranscriptCompactionEntry;
@@ -1,8 +1,3 @@
1
- /**
2
- * Definition files (track R2 M4): the files a definition names by content hash, uploaded once
3
- * with `PUT /v1/files/sha256:<hex>` and held by the Runtime. Today they are the files of a
4
- * skill's folder (`SkillManifest.files`). Shared by the SDK, the wire schema and the Runtime.
5
- */
6
1
  /** The largest definition file the Runtime stores. */
7
2
  export declare const DEFINITION_FILE_MAX_BYTES: number;
8
3
  /** The most files one skill may have. */
@@ -11,8 +6,18 @@ export declare const SKILL_FILES_MAX = 500;
11
6
  export declare const SKILL_FILE_PATH_MAX = 512;
12
7
  /** The file every skill has: its frontmatter and instructions. */
13
8
  export declare const SKILL_ENTRY = "SKILL.md";
14
- /** Where a session's sandbox holds each skill's files, read-only: `/skills/<name>/`. */
9
+ /** Where a session's sandbox holds each skill's files, read-only: `/skills/<name>@<hash>/`. */
15
10
  export declare const SKILLS_MOUNT = "/skills";
11
+ /**
12
+ * The folder of a sandbox that holds one version of a skill, read-only (D66):
13
+ * `/skills/<name>@<12 hex>`, the hex from the SHA-256 of its canonical file map. A version keeps
14
+ * its folder and is never replaced, so sessions whose agents carry different versions of a skill
15
+ * share an Environment without changing each other's files.
16
+ */
17
+ export declare function skillFolderOf(skill: {
18
+ readonly name: string;
19
+ readonly files: Readonly<Record<string, string>>;
20
+ }): string;
16
21
  /** `sha256:<hex>`, the way a manifest names a definition file. */
17
22
  export declare function isDefinitionFileHash(value: unknown): value is string;
18
23
  /** Why `path` cannot name a file in a skill's folder, or undefined when it can. */
@@ -3,6 +3,9 @@
3
3
  * with `PUT /v1/files/sha256:<hex>` and held by the Runtime. Today they are the files of a
4
4
  * skill's folder (`SkillManifest.files`). Shared by the SDK, the wire schema and the Runtime.
5
5
  */
6
+ import { sha256 } from "@noble/hashes/sha2.js";
7
+ import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
8
+ import { canonical } from "./canonical.js";
6
9
  /** The largest definition file the Runtime stores. */
7
10
  export const DEFINITION_FILE_MAX_BYTES = 10 * 1024 * 1024;
8
11
  /** The most files one skill may have. */
@@ -11,8 +14,17 @@ export const SKILL_FILES_MAX = 500;
11
14
  export const SKILL_FILE_PATH_MAX = 512;
12
15
  /** The file every skill has: its frontmatter and instructions. */
13
16
  export const SKILL_ENTRY = "SKILL.md";
14
- /** Where a session's sandbox holds each skill's files, read-only: `/skills/<name>/`. */
17
+ /** Where a session's sandbox holds each skill's files, read-only: `/skills/<name>@<hash>/`. */
15
18
  export const SKILLS_MOUNT = "/skills";
19
+ /**
20
+ * The folder of a sandbox that holds one version of a skill, read-only (D66):
21
+ * `/skills/<name>@<12 hex>`, the hex from the SHA-256 of its canonical file map. A version keeps
22
+ * its folder and is never replaced, so sessions whose agents carry different versions of a skill
23
+ * share an Environment without changing each other's files.
24
+ */
25
+ export function skillFolderOf(skill) {
26
+ return `${SKILLS_MOUNT}/${skill.name}@${bytesToHex(sha256(utf8ToBytes(canonical(skill.files)))).slice(0, 12)}`;
27
+ }
16
28
  const FILE_HASH = /^sha256:[0-9a-f]{64}$/;
17
29
  /** `sha256:<hex>`, the way a manifest names a definition file. */
18
30
  export function isDefinitionFileHash(value) {
@@ -64,14 +76,12 @@ export function definitionFilesOf(document, into = new Set()) {
64
76
  definitionFilesOf(agent, into);
65
77
  return into;
66
78
  }
67
- for (const capability of value.capabilities ?? []) {
68
- for (const skill of Object.values(capability.skills ?? {}))
69
- for (const hash of Object.values(skill?.files ?? {}))
70
- if (isDefinitionFileHash(hash))
71
- into.add(hash);
72
- for (const tool of capability.tools ?? [])
73
- definitionFilesOf(tool.agent, into);
74
- }
79
+ 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);
83
+ for (const tool of value.tools ?? [])
84
+ definitionFilesOf(tool.agent, into);
75
85
  return into;
76
86
  }
77
87
  /**