@nylorun/core 0.2.0-beta → 0.3.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @nylorun/core
2
2
 
3
+ ## 0.3.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - b8d822a: Studio Model Settings lists multiple vault-stored providers, adds credentials through a sheet, and switches the active provider/model via Runtime host vault APIs.
8
+ - b8d822a: Let a running Runtime learn its executors instead of receiving them all at startup.
9
+ `PUT /v1/executors` registers or rotates scoped executor credentials with the application
10
+ credential, `DELETE /v1/executors/:agentId` removes one, and `GET /v1/executors` lists them
11
+ without disclosing secrets. Registrations persist in SQLite with the token hashed at rest and
12
+ are restored on the next start; scopes supplied through `NYLORUN_EXECUTORS_JSON` still apply
13
+ to that process, take precedence for their agent, and are never written to the database. An
14
+ unchanged registration is idempotent and keeps open streams, while a rotation ends the
15
+ replaced token's work stream and stops it authorizing. Unauthenticated `/health` now also
16
+ reports the Runtime version, a non-reversible scope digest of the database path, and the
17
+ process id; all three are optional in the contract so an older host still parses. Token
18
+ hashing is adequate only because these credentials are high-entropy values minted by the
19
+ host; it is not a password derivation.
20
+ - b8d822a: Add `sandbox()`: one `.use(sandbox())` gives an agent Runtime-executed `bash`, `read`, `write`, `edit`, `grep` and `glob` tools on an isolated machine with a persistent `/workspace`. The Runtime selects a microsandbox microVM where available, otherwise an in-process virtual shell, enforces deny-by-default egress presets, owns sandbox lifecycle, and reports its choice through `GET /v1/host/sandbox`, the `nylorun dev` banner and `nylorun doctor sandbox`.
21
+ - b8d822a: Breaking beta: replace `beforeModelCall` / `afterModelCall` with scoped hooks. Register `before("turn" | "step", fn)` and `after("step" | "turn", fn)` on the agent, or `before: { turn, step }` / `after: { step, turn }` on a capability. `before("turn")` runs once per turn and its `Patch` applies to every model call in the turn; the new `after("turn")` returns a `TurnDecision` for the final answer. `after` hooks take one argument and receive `attempt`, and `retry` now retries instead of failing the run. The manifest moves to `manifestSchemaVersion: 4` with `capabilities[].hooks`, and `BeforeModelCallFn`, `AfterModelCallFn` and the `beforeModelCall` / `afterModelCall` action kinds are removed. Every capability registered at a hook point now runs in one `hook` executor action, an expired hook claim is offered again instead of becoming uncertain, and the durable engine version is `hosted-2`. Hook toggles now hide a capability's tools, or one tool of a multi-tool capability, instead of having no effect or failing. Studio lists each capability's hooks with how often they run and labels hook actions. See MIGRATION.md.
22
+
3
23
  ## 0.2.0-beta
4
24
 
5
25
  ### Minor Changes
@@ -81,6 +81,50 @@ export declare const RotateCredentialRequestSchema: z.ZodObject<{
81
81
  }, z.core.$strict>], "type">;
82
82
  }, z.core.$strict>;
83
83
  export type RotateCredentialRequest = z.infer<typeof RotateCredentialRequestSchema>;
84
+ export declare const PutHostModelRequestSchema: z.ZodObject<{
85
+ requestId: z.ZodString;
86
+ idempotencyKey: z.ZodString;
87
+ provider: z.ZodString;
88
+ model: z.ZodString;
89
+ baseUrl: z.ZodOptional<z.ZodString>;
90
+ auth: z.ZodDiscriminatedUnion<[z.ZodObject<{
91
+ type: z.ZodLiteral<"api_key">;
92
+ key: z.ZodString;
93
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
94
+ }, z.core.$strict>, z.ZodObject<{
95
+ type: z.ZodLiteral<"oauth">;
96
+ refresh: z.ZodString;
97
+ access: z.ZodString;
98
+ expires: z.ZodNumber;
99
+ }, z.core.$loose>], "type">;
100
+ }, z.core.$strict>;
101
+ export type PutHostModelRequest = z.infer<typeof PutHostModelRequestSchema>;
102
+ export type HostModelView = {
103
+ readonly configured: false;
104
+ } | {
105
+ readonly configured: true;
106
+ readonly provider: string;
107
+ readonly model: string;
108
+ readonly authType: "api_key" | "oauth";
109
+ readonly baseUrl?: string;
110
+ };
111
+ export declare const SelectHostModelRequestSchema: z.ZodObject<{
112
+ requestId: z.ZodString;
113
+ idempotencyKey: z.ZodString;
114
+ provider: z.ZodString;
115
+ model: z.ZodString;
116
+ baseUrl: z.ZodOptional<z.ZodString>;
117
+ }, z.core.$strict>;
118
+ export type SelectHostModelRequest = z.infer<typeof SelectHostModelRequestSchema>;
119
+ export type HostModelProviderInfo = {
120
+ readonly id: string;
121
+ readonly name: string;
122
+ readonly model: string;
123
+ readonly authType: "api_key" | "oauth";
124
+ readonly baseUrl?: string;
125
+ readonly lastUpdated: string;
126
+ readonly active: boolean;
127
+ };
84
128
  export interface VaultInfo {
85
129
  readonly id: string;
86
130
  readonly name: string;
@@ -232,22 +276,50 @@ export declare const RejectedResponseSchema: z.ZodObject<{
232
276
  requestId: z.ZodOptional<z.ZodString>;
233
277
  }, z.core.$strip>;
234
278
  export type RejectedResponse = z.infer<typeof RejectedResponseSchema>;
235
- export declare const ActionSchema: z.ZodObject<{
279
+ /** The hook point an action runs, and the capabilities that registered it (manifest order). */
280
+ export declare const ActionHookSchema: z.ZodObject<{
281
+ at: z.ZodEnum<{
282
+ after: "after";
283
+ before: "before";
284
+ }>;
285
+ scope: z.ZodEnum<{
286
+ step: "step";
287
+ turn: "turn";
288
+ }>;
289
+ capabilityIds: z.ZodArray<z.ZodString>;
290
+ }, z.core.$strict>;
291
+ export type ActionHook = z.infer<typeof ActionHookSchema>;
292
+ export declare const ActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
236
293
  actionId: z.ZodString;
237
294
  sessionId: z.ZodString;
238
295
  turnId: z.ZodString;
239
296
  agentId: z.ZodString;
240
297
  manifestHash: z.ZodString;
241
298
  implementationVersion: z.ZodString;
242
- kind: z.ZodEnum<{
243
- afterModelCall: "afterModelCall";
244
- beforeModelCall: "beforeModelCall";
245
- tool: "tool";
299
+ input: z.ZodUnknown;
300
+ context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
301
+ status: z.ZodEnum<{
302
+ cancelled: "cancelled";
303
+ claimed: "claimed";
304
+ completed: "completed";
305
+ pending: "pending";
306
+ uncertain: "uncertain";
246
307
  }>;
308
+ generation: z.ZodNumber;
309
+ claimId: z.ZodNullable<z.ZodString>;
310
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
311
+ kind: z.ZodLiteral<"tool">;
247
312
  capabilityId: z.ZodString;
248
- toolName: z.ZodOptional<z.ZodString>;
313
+ toolName: z.ZodString;
249
314
  inputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
250
315
  outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
316
+ }, z.core.$strip>, z.ZodObject<{
317
+ actionId: z.ZodString;
318
+ sessionId: z.ZodString;
319
+ turnId: z.ZodString;
320
+ agentId: z.ZodString;
321
+ manifestHash: z.ZodString;
322
+ implementationVersion: z.ZodString;
251
323
  input: z.ZodUnknown;
252
324
  context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
253
325
  status: z.ZodEnum<{
@@ -260,7 +332,19 @@ export declare const ActionSchema: z.ZodObject<{
260
332
  generation: z.ZodNumber;
261
333
  claimId: z.ZodNullable<z.ZodString>;
262
334
  leaseExpiresAt: z.ZodNullable<z.ZodString>;
263
- }, z.core.$strip>;
335
+ kind: z.ZodLiteral<"hook">;
336
+ hook: z.ZodObject<{
337
+ at: z.ZodEnum<{
338
+ after: "after";
339
+ before: "before";
340
+ }>;
341
+ scope: z.ZodEnum<{
342
+ step: "step";
343
+ turn: "turn";
344
+ }>;
345
+ capabilityIds: z.ZodArray<z.ZodString>;
346
+ }, z.core.$strict>;
347
+ }, z.core.$strip>], "kind">;
264
348
  export type Action = z.infer<typeof ActionSchema>;
265
349
  export declare const ActionClaimRequestSchema: z.ZodObject<{
266
350
  requestId: z.ZodString;
@@ -272,22 +356,37 @@ export declare const ActionHeartbeatRequestSchema: z.ZodObject<{
272
356
  generation: z.ZodNumber;
273
357
  }, z.core.$strict>;
274
358
  export declare const ActionClaimResponseSchema: z.ZodObject<{
275
- action: z.ZodObject<{
359
+ action: z.ZodDiscriminatedUnion<[z.ZodObject<{
276
360
  actionId: z.ZodString;
277
361
  sessionId: z.ZodString;
278
362
  turnId: z.ZodString;
279
363
  agentId: z.ZodString;
280
364
  manifestHash: z.ZodString;
281
365
  implementationVersion: z.ZodString;
282
- kind: z.ZodEnum<{
283
- afterModelCall: "afterModelCall";
284
- beforeModelCall: "beforeModelCall";
285
- tool: "tool";
366
+ input: z.ZodUnknown;
367
+ context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
368
+ status: z.ZodEnum<{
369
+ cancelled: "cancelled";
370
+ claimed: "claimed";
371
+ completed: "completed";
372
+ pending: "pending";
373
+ uncertain: "uncertain";
286
374
  }>;
375
+ generation: z.ZodNumber;
376
+ claimId: z.ZodNullable<z.ZodString>;
377
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
378
+ kind: z.ZodLiteral<"tool">;
287
379
  capabilityId: z.ZodString;
288
- toolName: z.ZodOptional<z.ZodString>;
380
+ toolName: z.ZodString;
289
381
  inputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
290
382
  outputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
383
+ }, z.core.$strip>, z.ZodObject<{
384
+ actionId: z.ZodString;
385
+ sessionId: z.ZodString;
386
+ turnId: z.ZodString;
387
+ agentId: z.ZodString;
388
+ manifestHash: z.ZodString;
389
+ implementationVersion: z.ZodString;
291
390
  input: z.ZodUnknown;
292
391
  context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
293
392
  status: z.ZodEnum<{
@@ -300,7 +399,19 @@ export declare const ActionClaimResponseSchema: z.ZodObject<{
300
399
  generation: z.ZodNumber;
301
400
  claimId: z.ZodNullable<z.ZodString>;
302
401
  leaseExpiresAt: z.ZodNullable<z.ZodString>;
303
- }, z.core.$strip>;
402
+ kind: z.ZodLiteral<"hook">;
403
+ hook: z.ZodObject<{
404
+ at: z.ZodEnum<{
405
+ after: "after";
406
+ before: "before";
407
+ }>;
408
+ scope: z.ZodEnum<{
409
+ step: "step";
410
+ turn: "turn";
411
+ }>;
412
+ capabilityIds: z.ZodArray<z.ZodString>;
413
+ }, z.core.$strict>;
414
+ }, z.core.$strip>], "kind">;
304
415
  claimId: z.ZodString;
305
416
  generation: z.ZodNumber;
306
417
  leaseExpiresAt: z.ZodString;
@@ -314,9 +425,52 @@ export interface ExecutorScope {
314
425
  export declare const ExecutorNotificationSchema: z.ZodObject<{
315
426
  type: z.ZodLiteral<"work_available">;
316
427
  }, z.core.$strip>;
428
+ export declare const ExecutorRegistrationSchema: z.ZodObject<{
429
+ agentId: z.ZodString;
430
+ implementationVersion: z.ZodString;
431
+ manifestHash: z.ZodOptional<z.ZodString>;
432
+ token: z.ZodString;
433
+ }, z.core.$strict>;
434
+ export declare const RegisterExecutorsRequestSchema: z.ZodObject<{
435
+ executors: z.ZodArray<z.ZodObject<{
436
+ agentId: z.ZodString;
437
+ implementationVersion: z.ZodString;
438
+ manifestHash: z.ZodOptional<z.ZodString>;
439
+ token: z.ZodString;
440
+ }, z.core.$strict>>;
441
+ }, z.core.$strict>;
442
+ export declare const RegisterExecutorsResponseSchema: z.ZodObject<{
443
+ executors: z.ZodArray<z.ZodObject<{
444
+ agentId: z.ZodString;
445
+ implementationVersion: z.ZodString;
446
+ rotated: z.ZodBoolean;
447
+ }, z.core.$strip>>;
448
+ }, z.core.$strip>;
449
+ export declare const ExecutorSummarySchema: z.ZodObject<{
450
+ agentId: z.ZodString;
451
+ implementationVersion: z.ZodString;
452
+ manifestHash: z.ZodOptional<z.ZodString>;
453
+ connected: z.ZodBoolean;
454
+ updatedAt: z.ZodString;
455
+ }, z.core.$strip>;
456
+ export declare const ListExecutorsResponseSchema: z.ZodObject<{
457
+ executors: z.ZodArray<z.ZodObject<{
458
+ agentId: z.ZodString;
459
+ implementationVersion: z.ZodString;
460
+ manifestHash: z.ZodOptional<z.ZodString>;
461
+ connected: z.ZodBoolean;
462
+ updatedAt: z.ZodString;
463
+ }, z.core.$strip>>;
464
+ }, z.core.$strip>;
465
+ export type ExecutorRegistration = z.infer<typeof ExecutorRegistrationSchema>;
466
+ export type RegisterExecutorsResponse = z.infer<typeof RegisterExecutorsResponseSchema>;
467
+ export type ExecutorSummary = z.infer<typeof ExecutorSummarySchema>;
317
468
  export declare const HealthResponseSchema: z.ZodObject<{
318
469
  status: z.ZodLiteral<"ok">;
319
470
  service: z.ZodString;
471
+ version: z.ZodOptional<z.ZodString>;
472
+ scopeId: z.ZodOptional<z.ZodString>;
473
+ pid: z.ZodOptional<z.ZodNumber>;
320
474
  }, z.core.$strip>;
321
475
  export declare const ReadyResponseSchema: z.ZodObject<{
322
476
  status: z.ZodEnum<{
package/dist/contracts.js CHANGED
@@ -1,5 +1,7 @@
1
1
  /** Public wire contracts only. Never import checkpoint or engine modules here. */
2
2
  import { z } from "zod";
3
+ import { SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, isSandboxHostPattern, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
4
+ import { hookListIssue } from "./definition/hooks.js";
3
5
  export const PROTOCOL_VERSION = 1;
4
6
  export const RequestIdSchema = z.string().min(1);
5
7
  export const IdempotencyKeySchema = z.string().min(1).max(256);
@@ -38,6 +40,40 @@ const skillManifestSchema = z
38
40
  description: z.string().min(1),
39
41
  })
40
42
  .strict();
43
+ const sandboxManifestSchema = z
44
+ .object({
45
+ image: z.string().min(1).optional(),
46
+ network: z
47
+ .object({
48
+ preset: z.enum(SANDBOX_NETWORK_PRESETS).optional(),
49
+ allow: z
50
+ .array(z.string().refine(isSandboxHostPattern, {
51
+ message: "network.allow entries must be host names such as api.github.com or *.example.com",
52
+ }))
53
+ .optional(),
54
+ })
55
+ .strict()
56
+ .optional(),
57
+ resources: z
58
+ .object({
59
+ cpus: z.number().int().min(1).max(64).optional(),
60
+ memory: z
61
+ .string()
62
+ .refine((value) => parseSandboxSize(value) !== undefined, {
63
+ message: "resources.memory must be a size such as 512MiB or 2GiB",
64
+ })
65
+ .optional(),
66
+ })
67
+ .strict()
68
+ .optional(),
69
+ idle: z
70
+ .string()
71
+ .refine((value) => parseSandboxDuration(value) !== undefined, {
72
+ message: "idle must be a duration such as 30s, 15m or 1h",
73
+ })
74
+ .optional(),
75
+ })
76
+ .strict();
41
77
  const toolManifestSchema = z
42
78
  .object({
43
79
  name: z.string().min(1),
@@ -46,9 +82,15 @@ const toolManifestSchema = z
46
82
  outputSchema: jsonObject.optional(),
47
83
  })
48
84
  .strict();
85
+ const hookPointSchema = z
86
+ .object({
87
+ at: z.enum(["before", "after"]),
88
+ scope: z.enum(["turn", "step"]),
89
+ })
90
+ .strict();
49
91
  export const AgentManifestSchema = z
50
92
  .object({
51
- manifestSchemaVersion: z.literal(3),
93
+ manifestSchemaVersion: z.literal(4),
52
94
  id: z.string().min(1),
53
95
  name: z.string().min(1).optional(),
54
96
  description: z.string().optional(),
@@ -65,8 +107,15 @@ export const AgentManifestSchema = z
65
107
  skills: z.record(z.string(), skillManifestSchema).optional(),
66
108
  tools: z.array(toolManifestSchema).optional(),
67
109
  mcpServers: z.record(z.string(), mcpServerSchema).optional(),
68
- beforeModelCall: z.boolean().optional(),
69
- afterModelCall: z.boolean().optional(),
110
+ sandbox: sandboxManifestSchema.optional(),
111
+ hooks: z
112
+ .array(hookPointSchema)
113
+ .optional()
114
+ .superRefine((hooks, ctx) => {
115
+ const issue = hooks === undefined ? undefined : hookListIssue(hooks);
116
+ if (issue)
117
+ ctx.addIssue({ code: "custom", message: issue });
118
+ }),
70
119
  })
71
120
  .strict()),
72
121
  runtime: z.object({}).strict().optional(),
@@ -77,7 +126,23 @@ export const AgentManifestSchema = z
77
126
  const names = new Set();
78
127
  const servers = new Set();
79
128
  const skills = new Set();
129
+ let sandboxes = 0;
80
130
  for (const capability of manifest.capabilities) {
131
+ if (capability.sandbox) {
132
+ sandboxes += 1;
133
+ if (sandboxes > 1)
134
+ ctx.addIssue({
135
+ code: "custom",
136
+ message: "At most one capability may declare a sandbox",
137
+ });
138
+ const declared = new Set((capability.tools ?? []).map((tool) => tool.name));
139
+ for (const name of SANDBOX_TOOL_NAMES)
140
+ if (!declared.has(name))
141
+ ctx.addIssue({
142
+ code: "custom",
143
+ message: `Sandbox capability '${capability.id}' must declare the built-in '${name}' tool`,
144
+ });
145
+ }
81
146
  if (ids.has(capability.id))
82
147
  ctx.addIssue({ code: "custom", message: "Duplicate capability id" });
83
148
  ids.add(capability.id);
@@ -231,6 +296,39 @@ export const RotateCredentialRequestSchema = z
231
296
  ]),
232
297
  })
233
298
  .strict();
299
+ export const PutHostModelRequestSchema = z
300
+ .object({
301
+ ...vaultWriteBase,
302
+ provider: z.string().min(1),
303
+ model: z.string().min(1),
304
+ baseUrl: z.string().min(1).optional(),
305
+ auth: z.discriminatedUnion("type", [
306
+ z
307
+ .object({
308
+ type: z.literal("api_key"),
309
+ key: z.string().min(1),
310
+ env: z.record(z.string(), z.string()).optional(),
311
+ })
312
+ .strict(),
313
+ z
314
+ .object({
315
+ type: z.literal("oauth"),
316
+ refresh: z.string().min(1),
317
+ access: z.string().min(1),
318
+ expires: z.number(),
319
+ })
320
+ .passthrough(),
321
+ ]),
322
+ })
323
+ .strict();
324
+ export const SelectHostModelRequestSchema = z
325
+ .object({
326
+ ...vaultWriteBase,
327
+ provider: z.string().min(1),
328
+ model: z.string().min(1),
329
+ baseUrl: z.string().min(1).optional(),
330
+ })
331
+ .strict();
234
332
  const commandBase = {
235
333
  requestId: RequestIdSchema,
236
334
  idempotencyKey: IdempotencyKeySchema,
@@ -314,25 +412,43 @@ export const RejectedResponseSchema = z.object({
314
412
  activeTurnId: z.string().optional(),
315
413
  requestId: z.string().optional(),
316
414
  });
317
- export const ActionSchema = z.object({
415
+ const actionBase = {
318
416
  actionId: z.string(),
319
417
  sessionId: z.string(),
320
418
  turnId: z.string(),
321
419
  agentId: z.string(),
322
420
  manifestHash: z.string(),
323
421
  implementationVersion: z.string(),
324
- kind: z.enum(["tool", "beforeModelCall", "afterModelCall"]),
325
- capabilityId: z.string(),
326
- toolName: z.string().optional(),
327
- inputSchema: jsonObject.optional(),
328
- outputSchema: jsonObject.optional(),
329
422
  input: z.unknown(),
330
423
  context: jsonObject,
331
424
  status: z.enum(["pending", "claimed", "completed", "uncertain", "cancelled"]),
332
425
  generation: z.number().int().nonnegative(),
333
426
  claimId: z.string().nullable(),
334
427
  leaseExpiresAt: z.string().nullable(),
335
- });
428
+ };
429
+ /** The hook point an action runs, and the capabilities that registered it (manifest order). */
430
+ export const ActionHookSchema = z
431
+ .object({
432
+ at: z.enum(["before", "after"]),
433
+ scope: z.enum(["turn", "step"]),
434
+ capabilityIds: z.array(z.string().min(1)).min(1),
435
+ })
436
+ .strict();
437
+ export const ActionSchema = z.discriminatedUnion("kind", [
438
+ z.object({
439
+ ...actionBase,
440
+ kind: z.literal("tool"),
441
+ capabilityId: z.string(),
442
+ toolName: z.string(),
443
+ inputSchema: jsonObject.optional(),
444
+ outputSchema: jsonObject.optional(),
445
+ }),
446
+ z.object({
447
+ ...actionBase,
448
+ kind: z.literal("hook"),
449
+ hook: ActionHookSchema,
450
+ }),
451
+ ]);
336
452
  export const ActionClaimRequestSchema = z
337
453
  .object({
338
454
  requestId: RequestIdSchema,
@@ -355,9 +471,43 @@ export const ActionClaimResponseSchema = z.object({
355
471
  export const ExecutorNotificationSchema = z.object({
356
472
  type: z.literal("work_available"),
357
473
  });
474
+ export const ExecutorRegistrationSchema = z
475
+ .object({
476
+ agentId: z.string().min(1),
477
+ implementationVersion: z.string().min(1),
478
+ manifestHash: z.string().min(1).optional(),
479
+ token: z.string().min(16),
480
+ })
481
+ .strict();
482
+ export const RegisterExecutorsRequestSchema = z
483
+ .object({
484
+ executors: z.array(ExecutorRegistrationSchema).min(1).max(64),
485
+ })
486
+ .strict();
487
+ export const RegisterExecutorsResponseSchema = z.object({
488
+ executors: z.array(z.object({
489
+ agentId: z.string(),
490
+ implementationVersion: z.string(),
491
+ rotated: z.boolean(),
492
+ })),
493
+ });
494
+ export const ExecutorSummarySchema = z.object({
495
+ agentId: z.string(),
496
+ implementationVersion: z.string(),
497
+ manifestHash: z.string().optional(),
498
+ connected: z.boolean(),
499
+ updatedAt: z.string(),
500
+ });
501
+ export const ListExecutorsResponseSchema = z.object({
502
+ executors: z.array(ExecutorSummarySchema),
503
+ });
504
+ // Health fields added after the beta stay optional so a new client can parse an older Runtime.
358
505
  export const HealthResponseSchema = z.object({
359
506
  status: z.literal("ok"),
360
507
  service: z.string(),
508
+ version: z.string().optional(),
509
+ scopeId: z.string().optional(),
510
+ pid: z.number().int().positive().optional(),
361
511
  });
362
512
  export const ReadyResponseSchema = z.object({
363
513
  status: z.enum(["ready", "not_ready"]),
package/dist/define.d.ts CHANGED
@@ -7,10 +7,14 @@ export { capability, middleware, model, tool } from "./definition/helpers.js";
7
7
  export { ToolError, isToolError } from "./definition/tool-error.js";
8
8
  export { defineSchema } from "./definition/schema.js";
9
9
  export { hashManifest } from "./utils/hash.js";
10
+ export { createSandboxTools, SANDBOX_INSTRUCTIONS, } from "./definition/sandbox-tools.js";
11
+ export { SANDBOX_DEFERRED_FIELDS, SANDBOX_FIELDS, SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE, isSandboxHostPattern, isSandboxToolName, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
12
+ export type { SandboxToolName } from "./utils/sandbox.js";
10
13
  export type { Implementations } from "./definition/implementations.js";
11
- export type { AgentManifest, CapabilityManifest, McpServerManifest, RuntimeManifest, SkillManifest, ToolManifest, ManifestSchemaVersion, } from "./types/manifest.js";
14
+ export type { AgentManifest, CapabilityManifest, McpServerManifest, RuntimeManifest, SandboxManifest, SandboxNetworkPreset, SkillManifest, ToolManifest, ManifestSchemaVersion, } from "./types/manifest.js";
12
15
  export type { CapabilityDeclaration, CapabilityItems, MiddlewareContributions, SkillRecord, StepMiddleware, StepRequest, StepResponse, } from "./types/middleware.js";
13
- export type { Patch, Decision, BeforeModelCallFn, AfterModelCallFn, } from "./types/dynamics.js";
16
+ export type { Patch, Decision, TurnDecision, HookAt, HookScope, HookManifest, HookState, HookToolCall, BeforeHook, AfterHook, BeforeHooks, AfterHooks, BeforeTurnArgs, BeforeStepArgs, AfterStepArgs, AfterTurnArgs, } from "./types/dynamics.js";
17
+ export { HOOK_POINTS, hasHook, hookListIssue, hooksFrom, runHookPoint, } from "./definition/hooks.js";
14
18
  export type { ModelCandidate, ModelControls, ModelDirective, ModelEvidence, ModelFinishReason, ModelAdapter, ModelAdapterContext, ModelPreparedCall, ContextContributor, ContextMutationOptions, ContextSnapshot, ModelCall, ModelCallTool, ModelOutputBlock, PromptContentPart, PromptItem, ModelConfigurationContributor, ModelConfigurationInstruction, ModelConfigurationMutationOptions, ModelConfigurationSnapshot, ModelConfigurationTool, ModelRequest, ModelToolCall, ModelUsage, } from "./types/model.js";
15
19
  export type { BuildDiagnostic, ContextItem, DeferredOutcome, JsonObject, JsonPrimitive, JsonValue, Tripwire, } from "./types/shared.js";
16
20
  export type { ObserveEvent, ObserveModelConfigurationSnapshot, ObserveModelRequested, ObserveSealedCall, ObserveToolSnapshot, Observer, } from "./types/observe.js";
package/dist/define.js CHANGED
@@ -4,6 +4,9 @@ export { capability, middleware, model, tool } from "./definition/helpers.js";
4
4
  export { ToolError, isToolError } from "./definition/tool-error.js";
5
5
  export { defineSchema } from "./definition/schema.js";
6
6
  export { hashManifest } from "./utils/hash.js";
7
+ export { createSandboxTools, SANDBOX_INSTRUCTIONS, } from "./definition/sandbox-tools.js";
8
+ export { SANDBOX_DEFERRED_FIELDS, SANDBOX_FIELDS, SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE, isSandboxHostPattern, isSandboxToolName, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
9
+ export { HOOK_POINTS, hasHook, hookListIssue, hooksFrom, runHookPoint, } from "./definition/hooks.js";
7
10
  export { normalizeToolDefinition, normalizedSchemasFor, } from "./definition/schema.js";
8
11
  export { implementationsFor, bindingFromAgent } from "./definition/binding.js";
9
12
  export { bindTool } from "./definition/bind-tool.js";
@@ -3,7 +3,7 @@ import type { BuiltAgent } from "../types/agent.js";
3
3
  import type { AgentManifest, RuntimeManifest } from "../types/manifest.js";
4
4
  import type { BuildDiagnostic, JsonObject } from "../types/shared.js";
5
5
  import type { ToolSchemaSource } from "../types/tool.js";
6
- import type { AfterModelCallFn, BeforeModelCallFn } from "../types/dynamics.js";
6
+ import type { AfterHooks, BeforeHooks } from "../types/dynamics.js";
7
7
  import type { StepMiddleware } from "../types/middleware.js";
8
8
  type BuildResult<Agent> = {
9
9
  readonly ok: true;
@@ -14,8 +14,8 @@ type BuildResult<Agent> = {
14
14
  readonly diagnostics: readonly BuildDiagnostic[];
15
15
  };
16
16
  export interface CapabilityDynamics {
17
- readonly beforeModelCall?: BeforeModelCallFn<any>;
18
- readonly afterModelCall?: AfterModelCallFn<any>;
17
+ readonly before?: BeforeHooks<any>;
18
+ readonly after?: AfterHooks<any>;
19
19
  readonly middleware?: StepMiddleware<any>;
20
20
  }
21
21
  export declare function assembleAgent(middleware: readonly BoundMiddleware[], identity: Readonly<{
@@ -36,8 +36,7 @@ export function assembleAgent(middleware, identity, dynamics = new Map()) {
36
36
  ...(item.contributions === undefined
37
37
  ? {}
38
38
  : { contributions: item.contributions }),
39
- ...(item.beforeModelCall ? { beforeModelCall: true } : {}),
40
- ...(item.afterModelCall ? { afterModelCall: true } : {}),
39
+ ...(item.hooks === undefined ? {} : { hooks: item.hooks }),
41
40
  ...(item.manifestType === undefined
42
41
  ? {}
43
42
  : { manifestType: item.manifestType }),
@@ -45,6 +44,7 @@ export function assembleAgent(middleware, identity, dynamics = new Map()) {
45
44
  ...(item.mcpServers === undefined
46
45
  ? {}
47
46
  : { mcpServers: item.mcpServers }),
47
+ ...(item.sandbox === undefined ? {} : { sandbox: item.sandbox }),
48
48
  ...(item.skills === undefined ? {} : { skills: item.skills }),
49
49
  ...(item.skillRecords === undefined
50
50
  ? {}
@@ -58,6 +58,20 @@ export function assembleAgent(middleware, identity, dynamics = new Map()) {
58
58
  }
59
59
  const skilled = attachSkillTools(frozen);
60
60
  diagnostics.push(...skilled.diagnostics);
61
+ // The wire schema rejects tool names shared across capabilities; report them at build time
62
+ // with both owners. Duplicates within one capability keep their registration-time error.
63
+ const toolOwners = new Map();
64
+ for (const item of skilled.items)
65
+ for (const entry of item.tools ?? []) {
66
+ const owner = toolOwners.get(entry.name);
67
+ if (owner !== undefined && owner !== item.id)
68
+ diagnostics.push(diagnostic("tool.duplicate-name", `Tool '${entry.name}' is declared by capabilities '${owner}' and '${item.id}'` +
69
+ (owner === "sandbox" || item.id === "sandbox"
70
+ ? "; sandbox() provides built-in bash, read, write, edit, grep and glob tools, so rename yours"
71
+ : "")));
72
+ else
73
+ toolOwners.set(entry.name, item.id);
74
+ }
61
75
  if (diagnostics.length)
62
76
  return Object.freeze({
63
77
  ok: false,
@@ -53,8 +53,8 @@ function buildImplementations(middleware, dynamics, snapshots) {
53
53
  ...(Object.keys(tools).length
54
54
  ? { tools: Object.freeze({ ...tools }) }
55
55
  : {}),
56
- ...(dyn?.beforeModelCall ? { beforeModelCall: dyn.beforeModelCall } : {}),
57
- ...(dyn?.afterModelCall ? { afterModelCall: dyn.afterModelCall } : {}),
56
+ ...(dyn?.before ? { before: Object.freeze({ ...dyn.before }) } : {}),
57
+ ...(dyn?.after ? { after: Object.freeze({ ...dyn.after }) } : {}),
58
58
  ...(dyn?.middleware ? { middleware: dyn.middleware } : {}),
59
59
  });
60
60
  }
@@ -1,6 +1,7 @@
1
1
  import type { JsonObject } from "../types/shared.js";
2
- import type { McpServerManifest, SkillManifest } from "../types/manifest.js";
2
+ import type { McpServerManifest, SandboxManifest, SkillManifest } from "../types/manifest.js";
3
3
  import type { SkillRecord } from "../types/middleware.js";
4
+ import type { HookManifest } from "../types/dynamics.js";
4
5
  import type { MiddlewareContributions, StepMiddleware } from "../types/middleware.js";
5
6
  import type { ToolApproval, ToolDefinition, ToolEffects, ToolExecutionContext, ToolInputSchema, ToolOutputSchema, ToolOwner, ToolRunResult, ToolSchema } from "../types/tool.js";
6
7
  export interface BoundToolDefinition<Info = unknown> extends Omit<ToolDefinition<ToolInputSchema, Info, ToolOutputSchema | undefined>, "inputSchema" | "outputSchema" | "execute" | "run" | "input" | "output"> {
@@ -22,13 +23,14 @@ export interface BoundMiddleware {
22
23
  /** Execution-only tools. Advertised for this run and omitted from the manifest. */
23
24
  readonly sessionTools?: readonly ToolDefinition<any, any, any>[];
24
25
  readonly contributions?: MiddlewareContributions;
25
- readonly beforeModelCall?: boolean;
26
- readonly afterModelCall?: boolean;
26
+ /** Registered hook points, in canonical order. */
27
+ readonly hooks?: readonly HookManifest[];
27
28
  readonly manifestType?: "agent" | "agent-plugin";
28
29
  readonly metadata?: JsonObject;
29
30
  readonly skills?: Readonly<Record<string, SkillManifest>>;
30
31
  readonly skillRecords?: Readonly<Record<string, SkillRecord>>;
31
32
  readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
33
+ readonly sandbox?: SandboxManifest;
32
34
  /** Package directory for a plugin capability. Not a manifest field. */
33
35
  readonly pluginRoot?: string;
34
36
  }