@nylorun/core 0.47.0-beta → 0.49.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 +16 -0
- package/dist/compatibility.d.ts +8 -0
- package/dist/compatibility.js +8 -0
- package/dist/contracts.d.ts +59 -0
- package/dist/contracts.js +25 -0
- package/dist/folder/compile.js +41 -3
- package/dist/folder/migrate-v3.js +10 -1
- package/dist/folder/v3.d.ts +6 -1
- package/dist/folder/v3.js +17 -2
- package/dist/harness-api/harness-api.schema.json +44 -1
- package/dist/harness-api/json-schema.js +4 -2
- package/dist/harness-api/schema.d.ts +18 -0
- package/dist/harness-api/schema.js +16 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.49.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d688ce5: An Agent sets when its sessions compact (ADR-157): `harness.loop.compaction` (`loop.compaction` in `AGENT.md`) takes `threshold` and `keepTokens`, positive whole numbers of tokens, and `roles.<role>` over them for sessions opened with that role. Our harness compacts before a model call whose estimate passes the lower of `threshold` and the model's window minus the reply reserve, and keeps `keepTokens` word for word; unset, sessions compact as before. A value that is not a positive integer is ignored with an `engine.diagnostic` (`compaction_setting_ignored`), and the folder compiler refuses it. `turn.start` names the session's role (`role`) to our harness.
|
|
8
|
+
|
|
9
|
+
An `agent-folder/3` folder may now set `loop` for the harness's own settings, such as `compaction`; only `loop.plan`, `loop.connections` and `loop.ask`, which its plugins declare, are refused. `nylorun migrate folder --to 3` keeps those settings.
|
|
10
|
+
|
|
11
|
+
- d688ce5: A message's context (ADR-157, Host feature `message-context`): a message takes `context`, up to 16 items `{ type?, value }` and 16 KiB in all, facts for its own turn only. The Runtime keeps them on `command.message` and passes them to the turn as its input's `metadata.context`; our harness renders the turn's latest ones in the `<runtime-context>` block after the history on every model call of that turn, and later turns leave them out. A workflow session refuses them. `session.input(value, { context })` and `session.inputParts(parts, { context })` send them, and refuse before sending when the Runtime lacks the feature.
|
|
12
|
+
|
|
13
|
+
## 0.48.0-beta
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 536ff54: A harness reaches a computer's new volume after a restore (ADR-149): a computer restored through `POST /v1/agents/{id}/restore`, reset, or given a new volume by its lifecycle gets a new sandbox name (`…-g0` → `…-g1`), but a harness that had opened it kept sending its sessions' `bash`, `read` and `write` to the last computer until the ticket expired, and a gateway or router that still served it ran them on the old volume. Before each request to a computer the harness now asks core where it is (`computer.current`, Harness API 5.7, `harness-api/v5.7.json`: a store read that never wakes it) and opens it again with `computer.open` when the URL moved. Core's own uses checked this already. A harness on a core older than 5.7 keeps its access until the ticket is renewed, as before.
|
|
18
|
+
|
|
3
19
|
## 0.47.0-beta
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -251,6 +251,14 @@ export declare const OPTIONAL_HOST_FEATURES: readonly ["tenant-fixture-model", "
|
|
|
251
251
|
* always sends it still moves to new versions.
|
|
252
252
|
*/
|
|
253
253
|
"remove-tools",
|
|
254
|
+
/**
|
|
255
|
+
* A message's `context` (ADR-157): up to 16 items `{type?, value}` for its own turn. Our engine puts
|
|
256
|
+
* them in the `<runtime-context>` block of every model call of that turn, after the history, and
|
|
257
|
+
* later turns leave them out; `command.message` keeps them. Our harness also reads
|
|
258
|
+
* `harness.loop.compaction` (`threshold`, `keepTokens`, per role), with the session's role in
|
|
259
|
+
* `turn.start`.
|
|
260
|
+
*/
|
|
261
|
+
"message-context",
|
|
254
262
|
/**
|
|
255
263
|
* The triggers capability (D83): an agent whose version declares `harness.engine.triggers` sets
|
|
256
264
|
* up its own triggers with the `triggers` tool, kept by the Agent (`origin: agent` in
|
package/dist/compatibility.js
CHANGED
|
@@ -273,6 +273,14 @@ export const OPTIONAL_HOST_FEATURES = [
|
|
|
273
273
|
* always sends it still moves to new versions.
|
|
274
274
|
*/
|
|
275
275
|
"remove-tools",
|
|
276
|
+
/**
|
|
277
|
+
* A message's `context` (ADR-157): up to 16 items `{type?, value}` for its own turn. Our engine puts
|
|
278
|
+
* them in the `<runtime-context>` block of every model call of that turn, after the history, and
|
|
279
|
+
* later turns leave them out; `command.message` keeps them. Our harness also reads
|
|
280
|
+
* `harness.loop.compaction` (`threshold`, `keepTokens`, per role), with the session's role in
|
|
281
|
+
* `turn.start`.
|
|
282
|
+
*/
|
|
283
|
+
"message-context",
|
|
276
284
|
/**
|
|
277
285
|
* The triggers capability (D83): an agent whose version declares `harness.engine.triggers` sets
|
|
278
286
|
* up its own triggers with the `triggers` tool, kept by the Agent (`origin: agent` in
|
package/dist/contracts.d.ts
CHANGED
|
@@ -4322,6 +4322,21 @@ export type MessageDelivery = z.infer<typeof MessageDeliverySchema>;
|
|
|
4322
4322
|
* only narrows.
|
|
4323
4323
|
*/
|
|
4324
4324
|
export declare const RemoveToolsSchema: z.ZodArray<z.ZodString>;
|
|
4325
|
+
/** The most context items one message carries (ADR-157). */
|
|
4326
|
+
export declare const MESSAGE_CONTEXT_MAX_ITEMS = 16;
|
|
4327
|
+
/** The most bytes a message's context items take, as JSON (ADR-157). */
|
|
4328
|
+
export declare const MESSAGE_CONTEXT_MAX_BYTES: number;
|
|
4329
|
+
/**
|
|
4330
|
+
* A message's `context` (Host feature `message-context`, ADR-157): facts for its own turn only,
|
|
4331
|
+
* such as the time or who the agent is today. Our engine puts them in the `<runtime-context>` block
|
|
4332
|
+
* of every model call of that turn, after the history; later turns leave them out. The
|
|
4333
|
+
* `command.message` event keeps them.
|
|
4334
|
+
*/
|
|
4335
|
+
export declare const MessageContextSchema: z.ZodArray<z.ZodObject<{
|
|
4336
|
+
type: z.ZodOptional<z.ZodString>;
|
|
4337
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4338
|
+
}, z.core.$strict>>;
|
|
4339
|
+
export type MessageContextItem = z.infer<typeof MessageContextSchema>[number];
|
|
4325
4340
|
/**
|
|
4326
4341
|
* One part of a user message (protocol 6): text, or a file by artifact id. A file part without
|
|
4327
4342
|
* `version` means the artifact's latest version when the message is accepted; the Runtime pins
|
|
@@ -4351,6 +4366,10 @@ export declare const MessageEventBodySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
4351
4366
|
reject: "reject";
|
|
4352
4367
|
steer: "steer";
|
|
4353
4368
|
}>>;
|
|
4369
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4370
|
+
type: z.ZodOptional<z.ZodString>;
|
|
4371
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4372
|
+
}, z.core.$strict>>>;
|
|
4354
4373
|
content: z.ZodString;
|
|
4355
4374
|
}, z.core.$strict>, z.ZodObject<{
|
|
4356
4375
|
requestId: z.ZodString;
|
|
@@ -4363,6 +4382,10 @@ export declare const MessageEventBodySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
4363
4382
|
reject: "reject";
|
|
4364
4383
|
steer: "steer";
|
|
4365
4384
|
}>>;
|
|
4385
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4386
|
+
type: z.ZodOptional<z.ZodString>;
|
|
4387
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4388
|
+
}, z.core.$strict>>>;
|
|
4366
4389
|
data: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4367
4390
|
}, z.core.$strict>, z.ZodObject<{
|
|
4368
4391
|
requestId: z.ZodString;
|
|
@@ -4375,6 +4398,10 @@ export declare const MessageEventBodySchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
4375
4398
|
reject: "reject";
|
|
4376
4399
|
steer: "steer";
|
|
4377
4400
|
}>>;
|
|
4401
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4402
|
+
type: z.ZodOptional<z.ZodString>;
|
|
4403
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4404
|
+
}, z.core.$strict>>>;
|
|
4378
4405
|
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4379
4406
|
type: z.ZodLiteral<"text">;
|
|
4380
4407
|
text: z.ZodString;
|
|
@@ -4401,6 +4428,10 @@ export declare const SessionCommandSchema: z.ZodUnion<readonly [z.ZodUnion<reado
|
|
|
4401
4428
|
reject: "reject";
|
|
4402
4429
|
steer: "steer";
|
|
4403
4430
|
}>>;
|
|
4431
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4432
|
+
type: z.ZodOptional<z.ZodString>;
|
|
4433
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4434
|
+
}, z.core.$strict>>>;
|
|
4404
4435
|
content: z.ZodString;
|
|
4405
4436
|
}, z.core.$strict>, z.ZodObject<{
|
|
4406
4437
|
requestId: z.ZodString;
|
|
@@ -4413,6 +4444,10 @@ export declare const SessionCommandSchema: z.ZodUnion<readonly [z.ZodUnion<reado
|
|
|
4413
4444
|
reject: "reject";
|
|
4414
4445
|
steer: "steer";
|
|
4415
4446
|
}>>;
|
|
4447
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4448
|
+
type: z.ZodOptional<z.ZodString>;
|
|
4449
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4450
|
+
}, z.core.$strict>>>;
|
|
4416
4451
|
data: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4417
4452
|
}, z.core.$strict>, z.ZodObject<{
|
|
4418
4453
|
requestId: z.ZodString;
|
|
@@ -4425,6 +4460,10 @@ export declare const SessionCommandSchema: z.ZodUnion<readonly [z.ZodUnion<reado
|
|
|
4425
4460
|
reject: "reject";
|
|
4426
4461
|
steer: "steer";
|
|
4427
4462
|
}>>;
|
|
4463
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4464
|
+
type: z.ZodOptional<z.ZodString>;
|
|
4465
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4466
|
+
}, z.core.$strict>>>;
|
|
4428
4467
|
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4429
4468
|
type: z.ZodLiteral<"text">;
|
|
4430
4469
|
text: z.ZodString;
|
|
@@ -4462,6 +4501,10 @@ export declare const SessionEventBodySchema: z.ZodUnion<readonly [z.ZodUnion<rea
|
|
|
4462
4501
|
reject: "reject";
|
|
4463
4502
|
steer: "steer";
|
|
4464
4503
|
}>>;
|
|
4504
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4505
|
+
type: z.ZodOptional<z.ZodString>;
|
|
4506
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4507
|
+
}, z.core.$strict>>>;
|
|
4465
4508
|
content: z.ZodString;
|
|
4466
4509
|
}, z.core.$strict>, z.ZodObject<{
|
|
4467
4510
|
requestId: z.ZodString;
|
|
@@ -4474,6 +4517,10 @@ export declare const SessionEventBodySchema: z.ZodUnion<readonly [z.ZodUnion<rea
|
|
|
4474
4517
|
reject: "reject";
|
|
4475
4518
|
steer: "steer";
|
|
4476
4519
|
}>>;
|
|
4520
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4521
|
+
type: z.ZodOptional<z.ZodString>;
|
|
4522
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4523
|
+
}, z.core.$strict>>>;
|
|
4477
4524
|
data: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4478
4525
|
}, z.core.$strict>, z.ZodObject<{
|
|
4479
4526
|
requestId: z.ZodString;
|
|
@@ -4486,6 +4533,10 @@ export declare const SessionEventBodySchema: z.ZodUnion<readonly [z.ZodUnion<rea
|
|
|
4486
4533
|
reject: "reject";
|
|
4487
4534
|
steer: "steer";
|
|
4488
4535
|
}>>;
|
|
4536
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
4537
|
+
type: z.ZodOptional<z.ZodString>;
|
|
4538
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
4539
|
+
}, z.core.$strict>>>;
|
|
4489
4540
|
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4490
4541
|
type: z.ZodLiteral<"text">;
|
|
4491
4542
|
text: z.ZodString;
|
|
@@ -5508,6 +5559,10 @@ export declare const CommandMessagePayloadSchema: z.ZodObject<{
|
|
|
5508
5559
|
}, z.core.$strict>], "type">>>;
|
|
5509
5560
|
manifest: z.ZodOptional<z.ZodUnknown>;
|
|
5510
5561
|
removeTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5562
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
5563
|
+
type: z.ZodOptional<z.ZodString>;
|
|
5564
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
5565
|
+
}, z.core.$strict>>>;
|
|
5511
5566
|
delivery: z.ZodOptional<z.ZodEnum<{
|
|
5512
5567
|
queue: "queue";
|
|
5513
5568
|
reject: "reject";
|
|
@@ -5946,6 +6001,10 @@ export declare const EVENT_CATALOG: {
|
|
|
5946
6001
|
}, z.core.$strict>], "type">>>;
|
|
5947
6002
|
manifest: z.ZodOptional<z.ZodUnknown>;
|
|
5948
6003
|
removeTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6004
|
+
context: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
6005
|
+
type: z.ZodOptional<z.ZodString>;
|
|
6006
|
+
value: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
6007
|
+
}, z.core.$strict>>>;
|
|
5949
6008
|
delivery: z.ZodOptional<z.ZodEnum<{
|
|
5950
6009
|
queue: "queue";
|
|
5951
6010
|
reject: "reject";
|
package/dist/contracts.js
CHANGED
|
@@ -2973,6 +2973,28 @@ export const MessageDeliverySchema = z.enum(["queue", "reject", "steer"]);
|
|
|
2973
2973
|
* only narrows.
|
|
2974
2974
|
*/
|
|
2975
2975
|
export const RemoveToolsSchema = z.array(z.string().min(1).max(256)).max(256);
|
|
2976
|
+
/** The most context items one message carries (ADR-157). */
|
|
2977
|
+
export const MESSAGE_CONTEXT_MAX_ITEMS = 16;
|
|
2978
|
+
/** The most bytes a message's context items take, as JSON (ADR-157). */
|
|
2979
|
+
export const MESSAGE_CONTEXT_MAX_BYTES = 16 * 1024;
|
|
2980
|
+
/**
|
|
2981
|
+
* A message's `context` (Host feature `message-context`, ADR-157): facts for its own turn only,
|
|
2982
|
+
* such as the time or who the agent is today. Our engine puts them in the `<runtime-context>` block
|
|
2983
|
+
* of every model call of that turn, after the history; later turns leave them out. The
|
|
2984
|
+
* `command.message` event keeps them.
|
|
2985
|
+
*/
|
|
2986
|
+
export const MessageContextSchema = z
|
|
2987
|
+
.array(z
|
|
2988
|
+
.object({
|
|
2989
|
+
type: z.string().min(1).max(64).optional(),
|
|
2990
|
+
value: jsonValue,
|
|
2991
|
+
})
|
|
2992
|
+
.strict())
|
|
2993
|
+
.min(1)
|
|
2994
|
+
.max(MESSAGE_CONTEXT_MAX_ITEMS)
|
|
2995
|
+
.refine((items) => new TextEncoder().encode(JSON.stringify(items)).length <= MESSAGE_CONTEXT_MAX_BYTES, {
|
|
2996
|
+
message: `A message's context takes at most ${MESSAGE_CONTEXT_MAX_BYTES} bytes as JSON`,
|
|
2997
|
+
});
|
|
2976
2998
|
const messageBase = {
|
|
2977
2999
|
...commandBase,
|
|
2978
3000
|
type: z.literal("message"),
|
|
@@ -2985,6 +3007,7 @@ const messageBase = {
|
|
|
2985
3007
|
manifest: AgentManifestSchema.optional(),
|
|
2986
3008
|
removeTools: RemoveToolsSchema.optional(),
|
|
2987
3009
|
delivery: MessageDeliverySchema.optional(),
|
|
3010
|
+
context: MessageContextSchema.optional(),
|
|
2988
3011
|
};
|
|
2989
3012
|
/**
|
|
2990
3013
|
* One part of a user message (protocol 6): text, or a file by artifact id. A file part without
|
|
@@ -3577,6 +3600,8 @@ export const CommandMessagePayloadSchema = z
|
|
|
3577
3600
|
manifest: z.unknown().optional(),
|
|
3578
3601
|
/** The tools the message's turn may not use (Host feature `remove-tools`). */
|
|
3579
3602
|
removeTools: z.array(z.string()).optional(),
|
|
3603
|
+
/** The context items the message carried for its turn (ADR-157, Host feature `message-context`). */
|
|
3604
|
+
context: z.array(z.object({ type: z.string().optional(), value: jsonValue }).strict()).optional(),
|
|
3580
3605
|
delivery: MessageDeliverySchema.optional(),
|
|
3581
3606
|
/** Set when the message waited in the session's queue (protocol 17): its id there. */
|
|
3582
3607
|
queuedMessageId: z.string().optional(),
|
package/dist/folder/compile.js
CHANGED
|
@@ -66,10 +66,14 @@ export const SERVER_SETTING_KEYS = ["deferred", "tools"];
|
|
|
66
66
|
export const PLUGIN_SERVER_SETTING_KEYS = [...SERVER_SETTING_KEYS, "credential"];
|
|
67
67
|
export const TOOL_KEYS = ["description", "inputSchema", "outputSchema", "http"];
|
|
68
68
|
/**
|
|
69
|
-
* The loop settings our harness reads from `loop`: `plan` (`true` offers the agent `update_plan`)
|
|
70
|
-
*
|
|
69
|
+
* The loop settings our harness reads from `loop`: `plan` (`true` offers the agent `update_plan`),
|
|
70
|
+
* `connections` (`true` offers it `request_connection`), `ask`, and `compaction` (ADR-157: when
|
|
71
|
+
* the agent's sessions compact, `threshold` and `keepTokens`, and `roles.<role>` over them). A
|
|
72
|
+
* custom harness reads its own.
|
|
71
73
|
*/
|
|
72
|
-
const NYLORUN_LOOP_KEYS = ["plan", "connections", "ask"];
|
|
74
|
+
const NYLORUN_LOOP_KEYS = ["plan", "connections", "ask", "compaction"];
|
|
75
|
+
/** What `loop.compaction` and each of its `roles` set: positive whole numbers of tokens. */
|
|
76
|
+
const COMPACTION_KEYS = ["threshold", "keepTokens"];
|
|
73
77
|
const LOOP_TOOLS = { plan: "update_plan", connections: "request_connection", ask: "ask" };
|
|
74
78
|
/** The runtime fields only a sandbox has, and the ones only a pod has. */
|
|
75
79
|
const SANDBOX_FIELDS = ["image", "resources", "storage", "network", "setup", "files"];
|
|
@@ -554,6 +558,8 @@ export function compileAgentFolder(input, scope) {
|
|
|
554
558
|
if (typeof front.loop[key] !== "boolean")
|
|
555
559
|
error("value_invalid", `loop.${key} is true or false: true offers the agent ${LOOP_TOOLS[key]}`, AGENT_FILE, ["loop", key]);
|
|
556
560
|
}
|
|
561
|
+
else if (key === "compaction")
|
|
562
|
+
checkCompaction(front.loop.compaction, error);
|
|
557
563
|
else if (!NYLORUN_LOOP_KEYS.includes(key)) {
|
|
558
564
|
const close = suggestion(key, NYLORUN_LOOP_KEYS);
|
|
559
565
|
warn("loop_key", `Unknown loop setting '${key}'.${close ? ` Did you mean '${close}'?` : ""} loop holds the harness's own settings, and the ${DEFAULT_HARNESS} harness reads ${NYLORUN_LOOP_KEYS.length === 0 ? "none yet" : NYLORUN_LOOP_KEYS.join(", ")}, so it is ignored`, AGENT_FILE, ["loop", key], { key: true });
|
|
@@ -1493,3 +1499,35 @@ function trimBlankLines(text) {
|
|
|
1493
1499
|
lines.pop();
|
|
1494
1500
|
return lines.join("\n");
|
|
1495
1501
|
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Checks `loop.compaction` (ADR-157): a map of `threshold` and `keepTokens`, positive whole numbers
|
|
1504
|
+
* of tokens, and `roles`, a map from a role's name to the same two. The harness also ignores a
|
|
1505
|
+
* value it cannot use, so a folder that passes here never changes how its sessions compact by
|
|
1506
|
+
* accident.
|
|
1507
|
+
*/
|
|
1508
|
+
function checkCompaction(value, error) {
|
|
1509
|
+
const at = (...path) => ["loop", "compaction", ...path];
|
|
1510
|
+
const settings = (from, path, roles) => {
|
|
1511
|
+
if (!isObject(from)) {
|
|
1512
|
+
error("value_invalid", `${path.join(".")} is a map of ${COMPACTION_KEYS.join(" and ")}${roles ? ", and roles" : ""}`, AGENT_FILE, path);
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
for (const [key, setting] of Object.entries(from)) {
|
|
1516
|
+
if (roles && key === "roles")
|
|
1517
|
+
continue;
|
|
1518
|
+
if (!COMPACTION_KEYS.includes(key))
|
|
1519
|
+
error("unknown_key", `Unknown compaction setting '${key}': ${path.join(".")} takes ${COMPACTION_KEYS.join(", ")}${roles ? " and roles" : ""}`, AGENT_FILE, [...path, key]);
|
|
1520
|
+
else if (typeof setting !== "number" || !Number.isInteger(setting) || setting <= 0)
|
|
1521
|
+
error("value_invalid", `${path.join(".")}.${key} is a positive whole number of tokens`, AGENT_FILE, [...path, key]);
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
settings(value, at(), true);
|
|
1525
|
+
if (!isObject(value) || value.roles === undefined)
|
|
1526
|
+
return;
|
|
1527
|
+
if (!isObject(value.roles)) {
|
|
1528
|
+
error("value_invalid", "loop.compaction.roles is a map from a role's name to its threshold and keepTokens", AGENT_FILE, at("roles"));
|
|
1529
|
+
return;
|
|
1530
|
+
}
|
|
1531
|
+
for (const [role, entry] of Object.entries(value.roles))
|
|
1532
|
+
settings(entry, at("roles", role), false);
|
|
1533
|
+
}
|
|
@@ -75,7 +75,16 @@ export function folderV3Edit(input) {
|
|
|
75
75
|
}
|
|
76
76
|
// The frontmatter, edited in place: comments and the other keys stay as they are.
|
|
77
77
|
doc.delete("memory");
|
|
78
|
-
|
|
78
|
+
// loop keeps the harness's own settings (compaction, ADR-157); its plan, connections and ask are plugins now.
|
|
79
|
+
const loopNode = doc.get("loop", true);
|
|
80
|
+
if (isMap(loopNode)) {
|
|
81
|
+
for (const key of ["plan", "connections", "ask"])
|
|
82
|
+
loopNode.delete(key);
|
|
83
|
+
if (loopNode.items.length === 0)
|
|
84
|
+
doc.delete("loop");
|
|
85
|
+
}
|
|
86
|
+
else
|
|
87
|
+
doc.delete("loop");
|
|
79
88
|
const engineNode = doc.get("engine", true);
|
|
80
89
|
if (isMap(engineNode)) {
|
|
81
90
|
for (const key of ["sandbox", "artifacts", "triggers", "instructions"])
|
package/dist/folder/v3.d.ts
CHANGED
|
@@ -23,7 +23,12 @@ import type { ReportOptions } from "./context.js";
|
|
|
23
23
|
/** The format name a v3 folder writes. */
|
|
24
24
|
export declare const AGENT_FOLDER_V3 = "agent-folder/3";
|
|
25
25
|
/** The keys of `AGENT.md` a v3 folder declares as plugins instead. */
|
|
26
|
-
export declare const V3_REFUSED_KEYS: readonly ["memory"
|
|
26
|
+
export declare const V3_REFUSED_KEYS: readonly ["memory"];
|
|
27
|
+
/**
|
|
28
|
+
* The `loop` keys a v3 folder declares as plugins instead. `loop` itself stays the harness's own
|
|
29
|
+
* settings, such as `compaction` (ADR-157).
|
|
30
|
+
*/
|
|
31
|
+
export declare const V3_REFUSED_LOOP_KEYS: readonly ["plan", "connections", "ask"];
|
|
27
32
|
/** The keys of `engine:` a v3 folder declares as plugins instead. */
|
|
28
33
|
export declare const V3_REFUSED_ENGINE_KEYS: readonly ["sandbox", "artifacts", "triggers", "instructions"];
|
|
29
34
|
/** Whether `value` names the v3 format: `agent-folder/3` or `3`. */
|
package/dist/folder/v3.js
CHANGED
|
@@ -23,7 +23,12 @@ import { suggestion } from "./suggest.js";
|
|
|
23
23
|
/** The format name a v3 folder writes. */
|
|
24
24
|
export const AGENT_FOLDER_V3 = "agent-folder/3";
|
|
25
25
|
/** The keys of `AGENT.md` a v3 folder declares as plugins instead. */
|
|
26
|
-
export const V3_REFUSED_KEYS = ["memory"
|
|
26
|
+
export const V3_REFUSED_KEYS = ["memory"];
|
|
27
|
+
/**
|
|
28
|
+
* The `loop` keys a v3 folder declares as plugins instead. `loop` itself stays the harness's own
|
|
29
|
+
* settings, such as `compaction` (ADR-157).
|
|
30
|
+
*/
|
|
31
|
+
export const V3_REFUSED_LOOP_KEYS = ["plan", "connections", "ask"];
|
|
27
32
|
/** The keys of `engine:` a v3 folder declares as plugins instead. */
|
|
28
33
|
export const V3_REFUSED_ENGINE_KEYS = ["sandbox", "artifacts", "triggers", "instructions"];
|
|
29
34
|
const MIGRATE = "run nylorun migrate folder <dir> --to 3, which writes the plugins that keep what the agent gets today";
|
|
@@ -47,6 +52,12 @@ export function v3Declarations(front, options) {
|
|
|
47
52
|
for (const key of V3_REFUSED_KEYS)
|
|
48
53
|
if (front[key] !== undefined)
|
|
49
54
|
fail("v3_refused", `${key} is a key of agent-folder/2: an agent-folder/3 folder declares the Runtime's features as plugins. Fix: ${MIGRATE}`, [key], { key: true });
|
|
55
|
+
if (front.loop !== undefined && !isObject(front.loop))
|
|
56
|
+
fail("value_invalid", "loop is a map", ["loop"]);
|
|
57
|
+
if (isObject(front.loop))
|
|
58
|
+
for (const key of V3_REFUSED_LOOP_KEYS)
|
|
59
|
+
if (front.loop[key] !== undefined)
|
|
60
|
+
fail("v3_refused", `loop.${key} is a key of agent-folder/2: an agent-folder/3 folder declares the Runtime's features as plugins. Fix: ${MIGRATE}`, ["loop", key], { key: true });
|
|
50
61
|
if (isObject(front.engine))
|
|
51
62
|
for (const key of V3_REFUSED_ENGINE_KEYS)
|
|
52
63
|
if (front.engine[key] !== undefined)
|
|
@@ -110,7 +121,11 @@ export function v3Declarations(front, options) {
|
|
|
110
121
|
return { name, tools: within ? tools.filter((tool) => within.tools.includes(tool)) : tools };
|
|
111
122
|
});
|
|
112
123
|
const on = (tool) => plugins.some((plugin) => plugin.tools.includes(tool));
|
|
113
|
-
|
|
124
|
+
// The harness's own settings the folder sets (compaction), then those the plugins stand for.
|
|
125
|
+
const loop = {
|
|
126
|
+
...(isObject(front.loop) ? front.loop : {}),
|
|
127
|
+
...Object.fromEntries([["plan", "update_plan"], ["connections", "request_connection"], ["ask", "ask"]].flatMap(([key, tool]) => (role === "root" && on(tool) ? [[key, true]] : []))),
|
|
128
|
+
};
|
|
114
129
|
const engine = {
|
|
115
130
|
...(isObject(front.engine) ? front.engine : {}),
|
|
116
131
|
sandbox: SANDBOX_TOOL_NAMES.filter((tool) => on(tool)),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://docs.nylorun.com/schemas/harness-api/v5.
|
|
3
|
+
"$id": "https://docs.nylorun.com/schemas/harness-api/v5.8.json",
|
|
4
4
|
"title": "Nylorun Harness API 5",
|
|
5
5
|
"$defs": {
|
|
6
6
|
"ArtifactMeta": {
|
|
@@ -1187,6 +1187,11 @@
|
|
|
1187
1187
|
},
|
|
1188
1188
|
"additionalProperties": {}
|
|
1189
1189
|
},
|
|
1190
|
+
"role": {
|
|
1191
|
+
"type": "string",
|
|
1192
|
+
"minLength": 1,
|
|
1193
|
+
"maxLength": 64
|
|
1194
|
+
},
|
|
1190
1195
|
"memory": {
|
|
1191
1196
|
"type": "object",
|
|
1192
1197
|
"properties": {
|
|
@@ -3393,6 +3398,11 @@
|
|
|
3393
3398
|
},
|
|
3394
3399
|
"additionalProperties": {}
|
|
3395
3400
|
},
|
|
3401
|
+
"role": {
|
|
3402
|
+
"type": "string",
|
|
3403
|
+
"minLength": 1,
|
|
3404
|
+
"maxLength": 64
|
|
3405
|
+
},
|
|
3396
3406
|
"memory": {
|
|
3397
3407
|
"type": "object",
|
|
3398
3408
|
"properties": {
|
|
@@ -4676,6 +4686,39 @@
|
|
|
4676
4686
|
],
|
|
4677
4687
|
"additionalProperties": false
|
|
4678
4688
|
},
|
|
4689
|
+
"computer.current.params": {
|
|
4690
|
+
"type": "object",
|
|
4691
|
+
"properties": {
|
|
4692
|
+
"runId": {
|
|
4693
|
+
"type": "string",
|
|
4694
|
+
"minLength": 1,
|
|
4695
|
+
"maxLength": 512
|
|
4696
|
+
},
|
|
4697
|
+
"environmentId": {
|
|
4698
|
+
"type": "string",
|
|
4699
|
+
"minLength": 1,
|
|
4700
|
+
"maxLength": 512
|
|
4701
|
+
}
|
|
4702
|
+
},
|
|
4703
|
+
"required": [
|
|
4704
|
+
"runId",
|
|
4705
|
+
"environmentId"
|
|
4706
|
+
],
|
|
4707
|
+
"additionalProperties": false
|
|
4708
|
+
},
|
|
4709
|
+
"computer.current.result": {
|
|
4710
|
+
"type": "object",
|
|
4711
|
+
"properties": {
|
|
4712
|
+
"url": {
|
|
4713
|
+
"type": "string",
|
|
4714
|
+
"format": "uri"
|
|
4715
|
+
}
|
|
4716
|
+
},
|
|
4717
|
+
"required": [
|
|
4718
|
+
"url"
|
|
4719
|
+
],
|
|
4720
|
+
"additionalProperties": false
|
|
4721
|
+
},
|
|
4679
4722
|
"artifact.read.params": {
|
|
4680
4723
|
"type": "object",
|
|
4681
4724
|
"properties": {
|
|
@@ -60,9 +60,11 @@ export function harnessApiSchemas() {
|
|
|
60
60
|
that never asks for it never sees. Revision 5: `artifact.write` `begin` may carry
|
|
61
61
|
`audience: "model"` (ADR-139), which core accepts and only our own engine sends. Revision 6:
|
|
62
62
|
`routing.sandbox.computer` and the request `computer.open` (ADR-149), which a v5 harness never
|
|
63
|
-
sees unless the Tenant's pod Agents are computers.
|
|
63
|
+
sees unless the Tenant's pod Agents are computers. Revision 7: the request `computer.current`,
|
|
64
|
+
which only a harness that drives computers sends. Revision 8: `turn.start.role` (ADR-157), the
|
|
65
|
+
session's role, which the Runtime sends only to our own harness.
|
|
64
66
|
*/
|
|
65
|
-
const SCHEMA_REVISION =
|
|
67
|
+
const SCHEMA_REVISION = 8;
|
|
66
68
|
/** The JSON Schema document of the Harness API (draft 2020-12). */
|
|
67
69
|
export function harnessApiJsonSchema() {
|
|
68
70
|
const $defs = {};
|
|
@@ -453,6 +453,7 @@ export declare const TurnStartSchema: z.ZodObject<{
|
|
|
453
453
|
version: z.ZodNumber;
|
|
454
454
|
}, z.core.$strict>>;
|
|
455
455
|
loop: z.ZodOptional<z.ZodType<object, unknown, z.core.$ZodTypeInternals<object, unknown>>>;
|
|
456
|
+
role: z.ZodOptional<z.ZodString>;
|
|
456
457
|
memory: z.ZodOptional<z.ZodObject<{
|
|
457
458
|
access: z.ZodEnum<{
|
|
458
459
|
read_only: "read_only";
|
|
@@ -697,6 +698,7 @@ export declare const harnessRequests: {
|
|
|
697
698
|
version: z.ZodNumber;
|
|
698
699
|
}, z.core.$strict>>;
|
|
699
700
|
loop: z.ZodOptional<z.ZodType<object, unknown, z.core.$ZodTypeInternals<object, unknown>>>;
|
|
701
|
+
role: z.ZodOptional<z.ZodString>;
|
|
700
702
|
memory: z.ZodOptional<z.ZodObject<{
|
|
701
703
|
access: z.ZodEnum<{
|
|
702
704
|
read_only: "read_only";
|
|
@@ -1024,6 +1026,22 @@ export declare const harnessRequests: {
|
|
|
1024
1026
|
expiresAt: z.ZodNumber;
|
|
1025
1027
|
}, z.core.$strict>;
|
|
1026
1028
|
};
|
|
1029
|
+
/**
|
|
1030
|
+
* Where the computer of the run's session is now (Harness API 5.7), without waking it: the
|
|
1031
|
+
* sandbox gateway's URL for its current incarnation. A restore, a reset or a lost volume's
|
|
1032
|
+
* recovery gives the computer a new volume, and with it a new URL: a harness asks before each
|
|
1033
|
+
* request to the computer and, when the URL is not the one its `computer.open` answered, opens
|
|
1034
|
+
* it again rather than reach the last one. Refused as `computer.open` is for another computer.
|
|
1035
|
+
*/
|
|
1036
|
+
"computer.current": {
|
|
1037
|
+
params: z.ZodObject<{
|
|
1038
|
+
runId: z.ZodString;
|
|
1039
|
+
environmentId: z.ZodString;
|
|
1040
|
+
}, z.core.$strict>;
|
|
1041
|
+
result: z.ZodObject<{
|
|
1042
|
+
url: z.ZodString;
|
|
1043
|
+
}, z.core.$strict>;
|
|
1044
|
+
};
|
|
1027
1045
|
/**
|
|
1028
1046
|
* An artifact the run's session may read (the artifact seam, protocol 15): one of the session's
|
|
1029
1047
|
* own, or a Tenant-wide one its messages named; anything else is `not_found`, alike. The answer
|
|
@@ -391,6 +391,11 @@ export const TurnStartSchema = z
|
|
|
391
391
|
* "connection"`.
|
|
392
392
|
*/
|
|
393
393
|
loop: document.optional(),
|
|
394
|
+
/**
|
|
395
|
+
* The role the session was opened with (`PUT /v1/sessions/{id}` `role`, ADR-157), so a harness
|
|
396
|
+
* can use its settings for that role. Absent for a session opened without one.
|
|
397
|
+
*/
|
|
398
|
+
role: z.string().min(1).max(64).optional(),
|
|
394
399
|
/** The Agent's memory, when the version its session runs sets `harness.memory`. Absent for a flow. */
|
|
395
400
|
memory: TurnMemorySchema.optional(),
|
|
396
401
|
/** The segment's checkpoint; an agent's state has no transcript (`transcript.cursor`). */
|
|
@@ -594,6 +599,17 @@ export const harnessRequests = {
|
|
|
594
599
|
params: runId.extend({ environmentId: id }).strict(),
|
|
595
600
|
result: z.object({ url: z.string().url(), ticket: z.string().min(1), expiresAt: z.number().int() }).strict(),
|
|
596
601
|
},
|
|
602
|
+
/**
|
|
603
|
+
* Where the computer of the run's session is now (Harness API 5.7), without waking it: the
|
|
604
|
+
* sandbox gateway's URL for its current incarnation. A restore, a reset or a lost volume's
|
|
605
|
+
* recovery gives the computer a new volume, and with it a new URL: a harness asks before each
|
|
606
|
+
* request to the computer and, when the URL is not the one its `computer.open` answered, opens
|
|
607
|
+
* it again rather than reach the last one. Refused as `computer.open` is for another computer.
|
|
608
|
+
*/
|
|
609
|
+
"computer.current": {
|
|
610
|
+
params: runId.extend({ environmentId: id }).strict(),
|
|
611
|
+
result: z.object({ url: z.string().url() }).strict(),
|
|
612
|
+
},
|
|
597
613
|
/**
|
|
598
614
|
* An artifact the run's session may read (the artifact seam, protocol 15): one of the session's
|
|
599
615
|
* own, or a Tenant-wide one its messages named; anything else is `not_found`, alike. The answer
|