@nylorun/core 0.23.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.
- package/CHANGELOG.md +24 -0
- package/dist/compatibility.d.ts +96 -39
- package/dist/compatibility.js +97 -40
- package/dist/contracts.d.ts +2316 -842
- package/dist/contracts.js +1010 -407
- package/dist/define.d.ts +1 -0
- package/dist/define.js +1 -0
- package/dist/definition/removed.d.ts +7 -0
- package/dist/definition/removed.js +21 -1
- package/dist/definition/sections.d.ts +63 -0
- package/dist/definition/sections.js +204 -0
- package/dist/harness-api/harness-api.schema.json +182 -6
- package/dist/harness-api/index.d.ts +3 -3
- package/dist/harness-api/index.js +3 -3
- package/dist/harness-api/json-schema.js +2 -2
- package/dist/harness-api/messages.d.ts +5 -3
- package/dist/harness-api/messages.js +1 -1
- package/dist/harness-api/schema.d.ts +76 -7
- package/dist/harness-api/schema.js +52 -8
- package/dist/manifest-schemas.d.ts +9 -5
- package/dist/manifest-schemas.js +23 -27
- package/dist/schemas/agent-manifest.schema.json +1534 -250
- package/dist/schemas/harness-manifest.schema.json +1273 -0
- package/dist/schemas/{environment-manifest.schema.json → runtime-manifest.schema.json} +109 -68
- package/dist/types/manifest.d.ts +69 -1
- package/dist/types/manifest.js +4 -0
- package/dist/types/model.d.ts +5 -0
- package/dist/utils/memory.d.ts +64 -0
- package/dist/utils/memory.js +139 -0
- package/dist/utils/runtime-limits.d.ts +53 -2
- package/dist/utils/runtime-limits.js +104 -1
- package/package.json +6 -5
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://docs.nylorun.com/schemas/
|
|
4
|
-
"title": "Nylorun
|
|
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
8
|
"type": "string"
|
|
21
9
|
},
|
|
22
10
|
"kind": {
|
|
@@ -60,10 +48,6 @@
|
|
|
60
48
|
},
|
|
61
49
|
"additionalProperties": false
|
|
62
50
|
},
|
|
63
|
-
"harness": {
|
|
64
|
-
"type": "string",
|
|
65
|
-
"pattern": "^[a-z][a-z0-9-]{1,62}$"
|
|
66
|
-
},
|
|
67
51
|
"lifecycle": {
|
|
68
52
|
"type": "object",
|
|
69
53
|
"properties": {
|
|
@@ -105,63 +89,65 @@
|
|
|
105
89
|
"items": {
|
|
106
90
|
"anyOf": [
|
|
107
91
|
{
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
"type": "object",
|
|
133
|
-
"properties": {
|
|
134
|
-
"path": {
|
|
135
|
-
"type": "string",
|
|
136
|
-
"minLength": 1,
|
|
137
|
-
"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
|
|
138
116
|
},
|
|
139
|
-
|
|
117
|
+
{
|
|
140
118
|
"type": "object",
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
|
|
144
|
-
|
|
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
|
+
}
|
|
145
136
|
},
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
|
|
137
|
+
"required": [
|
|
138
|
+
"path",
|
|
139
|
+
"files"
|
|
140
|
+
],
|
|
141
|
+
"additionalProperties": false
|
|
149
142
|
}
|
|
150
|
-
|
|
151
|
-
"required": [
|
|
152
|
-
"path",
|
|
153
|
-
"files"
|
|
154
|
-
],
|
|
155
|
-
"additionalProperties": false
|
|
143
|
+
]
|
|
156
144
|
},
|
|
157
145
|
{
|
|
158
146
|
"type": "object",
|
|
159
|
-
"description": "For the CLI only: a folder, relative to this file, that `nylorun environments manifests save` uploads by hash and saves as { path, files }",
|
|
160
147
|
"properties": {
|
|
161
148
|
"path": {
|
|
162
149
|
"type": "string",
|
|
163
|
-
"minLength": 1
|
|
164
|
-
"maxLength": 1024
|
|
150
|
+
"minLength": 1
|
|
165
151
|
},
|
|
166
152
|
"from": {
|
|
167
153
|
"type": "string",
|
|
@@ -379,11 +365,66 @@
|
|
|
379
365
|
}
|
|
380
366
|
]
|
|
381
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"
|
|
382
384
|
}
|
|
383
385
|
},
|
|
384
386
|
"required": [
|
|
385
|
-
"
|
|
386
|
-
"name"
|
|
387
|
+
"kind"
|
|
387
388
|
],
|
|
388
|
-
"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
|
+
}
|
|
389
430
|
}
|
package/dist/types/manifest.d.ts
CHANGED
|
@@ -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.
|
|
@@ -161,4 +161,72 @@ export interface AgentRequirements {
|
|
|
161
161
|
/** Secret names (environment variables) its skills' scripts read, which the vault must hold. */
|
|
162
162
|
readonly secrets?: readonly string[];
|
|
163
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;
|
|
164
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
|
+
*/
|
package/dist/types/manifest.js
CHANGED
package/dist/types/model.d.ts
CHANGED
|
@@ -132,6 +132,11 @@ export interface ModelRequest {
|
|
|
132
132
|
/** Canonical, immutable Harness-owned model configuration for this call. */
|
|
133
133
|
readonly configuration: ModelConfigurationSnapshot;
|
|
134
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[];
|
|
135
140
|
readonly context: ContextSnapshot;
|
|
136
141
|
readonly transcript: readonly TranscriptEntry[];
|
|
137
142
|
readonly arrivals: readonly InputEvent[];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent memory (track T5, D72): what a memory's path may be, and what its index line shows.
|
|
3
|
+
* The Runtime and the engine's `memory` tool share these rules, so a path the tool accepts is one
|
|
4
|
+
* the Runtime stores.
|
|
5
|
+
*
|
|
6
|
+
* A memory is a Markdown file under `/memories`: its path is `/memories/` and one or more
|
|
7
|
+
* `/`-separated segments, ends in `.md`, has no `.` or `..` segment, no empty segment, no
|
|
8
|
+
* backslash or control character, and is at most `MEMORY_PATH_MAX` characters. Folders are only
|
|
9
|
+
* the prefixes of memory paths; no row holds one.
|
|
10
|
+
*/
|
|
11
|
+
/** Where an Agent's memories live, in the tool and in every path the Runtime stores. */
|
|
12
|
+
export declare const MEMORY_ROOT = "/memories";
|
|
13
|
+
/** The longest memory path, `/memories/` included. */
|
|
14
|
+
export declare const MEMORY_PATH_MAX = 512;
|
|
15
|
+
/** The longest `harness.memory.instructions`. */
|
|
16
|
+
export declare const MEMORY_INSTRUCTIONS_MAX = 4096;
|
|
17
|
+
/** The longest description an index line shows. */
|
|
18
|
+
export declare const MEMORY_DESCRIPTION_MAX = 200;
|
|
19
|
+
/** What `harness.memory.access` may be: reads and writes, or reads only. */
|
|
20
|
+
export declare const MEMORY_ACCESS: readonly ["read_write", "read_only"];
|
|
21
|
+
export type MemoryAccess = (typeof MEMORY_ACCESS)[number];
|
|
22
|
+
/** What changed a memory, as a version records it. */
|
|
23
|
+
export declare const MEMORY_OPERATIONS: readonly ["create", "str_replace", "insert", "delete", "rename"];
|
|
24
|
+
export type MemoryOperation = (typeof MEMORY_OPERATIONS)[number];
|
|
25
|
+
/**
|
|
26
|
+
* Normalises a path the model or an API caller sent: a trailing `/` is dropped, and a path
|
|
27
|
+
* without the leading `/` of `/memories` gets it. Answers the path, or why it is refused.
|
|
28
|
+
* `kind: "file"` requires a memory's path (ending in `.md`); `kind: "any"` also takes a folder,
|
|
29
|
+
* `/memories` itself included.
|
|
30
|
+
*/
|
|
31
|
+
export declare function memoryPathOf(raw: string, kind: "file" | "any"): {
|
|
32
|
+
path: string;
|
|
33
|
+
} | {
|
|
34
|
+
error: string;
|
|
35
|
+
};
|
|
36
|
+
/** Whether `path` is `folder` or inside it (`folder` a normalised memory path). */
|
|
37
|
+
export declare function memoryPathWithin(path: string, folder: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* What a memory's index line shows: the `description` of its YAML frontmatter, when it has one,
|
|
40
|
+
* cut to `MEMORY_DESCRIPTION_MAX` characters; otherwise `null`. Frontmatter is optional and the
|
|
41
|
+
* Runtime never writes into a memory.
|
|
42
|
+
*/
|
|
43
|
+
export declare function memoryDescriptionOf(content: string): string | null;
|
|
44
|
+
/** The `memory` tool's commands, Anthropic's memory tool's. */
|
|
45
|
+
export declare const MEMORY_COMMANDS: readonly ["view", "create", "str_replace", "insert", "delete", "rename"];
|
|
46
|
+
export type MemoryCommandName = (typeof MEMORY_COMMANDS)[number];
|
|
47
|
+
/**
|
|
48
|
+
* Checks a `memory` call's input against its command's parameters, which a JSON schema cannot
|
|
49
|
+
* tie to the command: answers the command, or the error text the model reads
|
|
50
|
+
* (`Error: create requires file_text.`). Our engine checks before it sends a call, and the
|
|
51
|
+
* Runtime checks again for every harness.
|
|
52
|
+
*/
|
|
53
|
+
export declare function checkMemoryCall(input: unknown): {
|
|
54
|
+
command: MemoryCommandName;
|
|
55
|
+
args: Record<string, unknown>;
|
|
56
|
+
} | {
|
|
57
|
+
error: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The `memory` call a tool name stands for when a model names the command in it (E-P1):
|
|
61
|
+
* `memory.create` and `memory/create` are `memory` with `command: "create"`. Answers the command,
|
|
62
|
+
* or `undefined` for any other name.
|
|
63
|
+
*/
|
|
64
|
+
export declare function memoryAliasOf(name: string): MemoryCommandName | undefined;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent memory (track T5, D72): what a memory's path may be, and what its index line shows.
|
|
3
|
+
* The Runtime and the engine's `memory` tool share these rules, so a path the tool accepts is one
|
|
4
|
+
* the Runtime stores.
|
|
5
|
+
*
|
|
6
|
+
* A memory is a Markdown file under `/memories`: its path is `/memories/` and one or more
|
|
7
|
+
* `/`-separated segments, ends in `.md`, has no `.` or `..` segment, no empty segment, no
|
|
8
|
+
* backslash or control character, and is at most `MEMORY_PATH_MAX` characters. Folders are only
|
|
9
|
+
* the prefixes of memory paths; no row holds one.
|
|
10
|
+
*/
|
|
11
|
+
/** Where an Agent's memories live, in the tool and in every path the Runtime stores. */
|
|
12
|
+
export const MEMORY_ROOT = "/memories";
|
|
13
|
+
/** The longest memory path, `/memories/` included. */
|
|
14
|
+
export const MEMORY_PATH_MAX = 512;
|
|
15
|
+
/** The longest `harness.memory.instructions`. */
|
|
16
|
+
export const MEMORY_INSTRUCTIONS_MAX = 4096;
|
|
17
|
+
/** The longest description an index line shows. */
|
|
18
|
+
export const MEMORY_DESCRIPTION_MAX = 200;
|
|
19
|
+
/** What `harness.memory.access` may be: reads and writes, or reads only. */
|
|
20
|
+
export const MEMORY_ACCESS = ["read_write", "read_only"];
|
|
21
|
+
/** What changed a memory, as a version records it. */
|
|
22
|
+
export const MEMORY_OPERATIONS = ["create", "str_replace", "insert", "delete", "rename"];
|
|
23
|
+
// Control characters (C0, DEL, C1) and the backslash; a path holds neither.
|
|
24
|
+
const FORBIDDEN = /[\u0000-\u001f\u007f-\u009f\\]/;
|
|
25
|
+
/**
|
|
26
|
+
* Normalises a path the model or an API caller sent: a trailing `/` is dropped, and a path
|
|
27
|
+
* without the leading `/` of `/memories` gets it. Answers the path, or why it is refused.
|
|
28
|
+
* `kind: "file"` requires a memory's path (ending in `.md`); `kind: "any"` also takes a folder,
|
|
29
|
+
* `/memories` itself included.
|
|
30
|
+
*/
|
|
31
|
+
export function memoryPathOf(raw, kind) {
|
|
32
|
+
let path = raw.trim();
|
|
33
|
+
if (path.startsWith("memories/") || path === "memories")
|
|
34
|
+
path = `/${path}`;
|
|
35
|
+
if (path.length > 1 && path.endsWith("/"))
|
|
36
|
+
path = path.slice(0, -1);
|
|
37
|
+
if (path !== MEMORY_ROOT && !path.startsWith(`${MEMORY_ROOT}/`))
|
|
38
|
+
return { error: `${raw} is not under ${MEMORY_ROOT}: memory paths start with ${MEMORY_ROOT}/` };
|
|
39
|
+
if (path.length > MEMORY_PATH_MAX)
|
|
40
|
+
return { error: `A memory path is at most ${MEMORY_PATH_MAX} characters` };
|
|
41
|
+
if (FORBIDDEN.test(path))
|
|
42
|
+
return { error: "A memory path has no backslash or control character" };
|
|
43
|
+
const segments = path.slice(MEMORY_ROOT.length + 1).split("/");
|
|
44
|
+
if (path !== MEMORY_ROOT && segments.some((segment) => segment === "" || segment === "." || segment === ".."))
|
|
45
|
+
return { error: `${raw} has an empty, "." or ".." segment` };
|
|
46
|
+
if (kind === "file") {
|
|
47
|
+
if (path === MEMORY_ROOT)
|
|
48
|
+
return { error: `${MEMORY_ROOT} is the memory folder, not a memory` };
|
|
49
|
+
if (!path.endsWith(".md") || path.endsWith("/.md"))
|
|
50
|
+
return { error: `${path} must end in .md: memories are Markdown files` };
|
|
51
|
+
}
|
|
52
|
+
return { path };
|
|
53
|
+
}
|
|
54
|
+
/** Whether `path` is `folder` or inside it (`folder` a normalised memory path). */
|
|
55
|
+
export function memoryPathWithin(path, folder) {
|
|
56
|
+
return folder === MEMORY_ROOT ? path.startsWith(`${MEMORY_ROOT}/`) : path === folder || path.startsWith(`${folder}/`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* What a memory's index line shows: the `description` of its YAML frontmatter, when it has one,
|
|
60
|
+
* cut to `MEMORY_DESCRIPTION_MAX` characters; otherwise `null`. Frontmatter is optional and the
|
|
61
|
+
* Runtime never writes into a memory.
|
|
62
|
+
*/
|
|
63
|
+
export function memoryDescriptionOf(content) {
|
|
64
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(content);
|
|
65
|
+
if (!match)
|
|
66
|
+
return null;
|
|
67
|
+
const line = /^description:[ \t]*(.*)$/m.exec(match[1]);
|
|
68
|
+
if (!line)
|
|
69
|
+
return null;
|
|
70
|
+
let value = line[1].trim();
|
|
71
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'")))
|
|
72
|
+
value = value.slice(1, -1).trim();
|
|
73
|
+
if (value === "")
|
|
74
|
+
return null;
|
|
75
|
+
return value.length > MEMORY_DESCRIPTION_MAX ? `${value.slice(0, MEMORY_DESCRIPTION_MAX - 1)}…` : value;
|
|
76
|
+
}
|
|
77
|
+
/** The `memory` tool's commands, Anthropic's memory tool's. */
|
|
78
|
+
export const MEMORY_COMMANDS = ["view", "create", "str_replace", "insert", "delete", "rename"];
|
|
79
|
+
/** Each command's parameters: name → whether it is required, and its kind. */
|
|
80
|
+
const MEMORY_PARAMETERS = {
|
|
81
|
+
view: { path: { required: true, kind: "string" }, view_range: { required: false, kind: "range" } },
|
|
82
|
+
create: { path: { required: true, kind: "string" }, file_text: { required: true, kind: "string" } },
|
|
83
|
+
str_replace: {
|
|
84
|
+
path: { required: true, kind: "string" },
|
|
85
|
+
old_str: { required: true, kind: "string" },
|
|
86
|
+
new_str: { required: false, kind: "string" },
|
|
87
|
+
},
|
|
88
|
+
insert: {
|
|
89
|
+
path: { required: true, kind: "string" },
|
|
90
|
+
insert_line: { required: true, kind: "integer" },
|
|
91
|
+
insert_text: { required: true, kind: "string" },
|
|
92
|
+
},
|
|
93
|
+
delete: { path: { required: true, kind: "string" } },
|
|
94
|
+
rename: { old_path: { required: true, kind: "string" }, new_path: { required: true, kind: "string" } },
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Checks a `memory` call's input against its command's parameters, which a JSON schema cannot
|
|
98
|
+
* tie to the command: answers the command, or the error text the model reads
|
|
99
|
+
* (`Error: create requires file_text.`). Our engine checks before it sends a call, and the
|
|
100
|
+
* Runtime checks again for every harness.
|
|
101
|
+
*/
|
|
102
|
+
export function checkMemoryCall(input) {
|
|
103
|
+
const error = (message) => ({ error: `Error: ${message}` });
|
|
104
|
+
if (input === null || typeof input !== "object" || Array.isArray(input))
|
|
105
|
+
return error("the input is an object with a command.");
|
|
106
|
+
const args = input;
|
|
107
|
+
const command = args.command;
|
|
108
|
+
if (typeof command !== "string" || !MEMORY_COMMANDS.includes(command))
|
|
109
|
+
return error(`command must be one of ${MEMORY_COMMANDS.join(", ")}; got ${JSON.stringify(command ?? null)}.`);
|
|
110
|
+
const parameters = MEMORY_PARAMETERS[command];
|
|
111
|
+
const missing = Object.entries(parameters)
|
|
112
|
+
.filter(([name, spec]) => spec.required && (args[name] === undefined || args[name] === null))
|
|
113
|
+
.map(([name]) => name);
|
|
114
|
+
if (missing.length > 0)
|
|
115
|
+
return error(`${command} requires ${missing.join(" and ")}.`);
|
|
116
|
+
for (const [name, spec] of Object.entries(parameters)) {
|
|
117
|
+
const value = args[name];
|
|
118
|
+
if (value === undefined || value === null)
|
|
119
|
+
continue;
|
|
120
|
+
if (spec.kind === "string" && typeof value !== "string")
|
|
121
|
+
return error(`${name} must be a string.`);
|
|
122
|
+
if (spec.kind === "integer" && !(Number.isInteger(value) || (typeof value === "string" && /^-?\d+$/.test(value))))
|
|
123
|
+
return error(`${name} must be an integer.`);
|
|
124
|
+
if (spec.kind === "range" &&
|
|
125
|
+
!(Array.isArray(value) && value.length === 2 && value.every((item) => Number.isInteger(Number(item)))))
|
|
126
|
+
return error(`${name} must be [start_line, end_line].`);
|
|
127
|
+
}
|
|
128
|
+
return { command: command, args };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The `memory` call a tool name stands for when a model names the command in it (E-P1):
|
|
132
|
+
* `memory.create` and `memory/create` are `memory` with `command: "create"`. Answers the command,
|
|
133
|
+
* or `undefined` for any other name.
|
|
134
|
+
*/
|
|
135
|
+
export function memoryAliasOf(name) {
|
|
136
|
+
const match = /^memory[./]([a-z_]+)$/.exec(name);
|
|
137
|
+
const command = match?.[1];
|
|
138
|
+
return command && MEMORY_COMMANDS.includes(command) ? command : undefined;
|
|
139
|
+
}
|
|
@@ -107,6 +107,32 @@ export declare const LINUX_ARG_MAX_BYTES: number;
|
|
|
107
107
|
* longest `reason` or `matches` expression.
|
|
108
108
|
* - `modelBudgets`: the most model budgets the Tenant sets.
|
|
109
109
|
*
|
|
110
|
+
* Triggers (track T4, D74; checked when a manifest is saved, and when a trigger fires):
|
|
111
|
+
* - `triggersPerAgent`: the most triggers one agent manifest declares.
|
|
112
|
+
* - `triggerMinIntervalMs`: the shortest gap between two runs of one schedule (cron is minute
|
|
113
|
+
* grained, so at least a minute), checked over its next fires at save.
|
|
114
|
+
* - `triggerRunsPerHour`: the most runs one Agent's triggers start or queue in any hour; later
|
|
115
|
+
* ones are skipped (`rate_limited`). The guard against an Agent triggering itself.
|
|
116
|
+
* - `triggerJitterPercent`, `triggerJitterMaxMs`: how far each schedule's fixed offset may move
|
|
117
|
+
* its runs, as a part of its interval and at most.
|
|
118
|
+
* - `triggerPromptChars`: the longest prompt one trigger holds.
|
|
119
|
+
* - `triggerRunRetentionMs`: how long runs are kept; they dedupe repeated fires, so at least a day.
|
|
120
|
+
* - `wakeMaxAheadMs`: how far ahead `schedule_wake` may book a session's next turn (D77); at least
|
|
121
|
+
* `triggerMinIntervalMs` ahead too. A long wait is armed in steps, so it has no timer ceiling.
|
|
122
|
+
* - `wakeNoteChars`: the longest note a booked wake carries to its turn.
|
|
123
|
+
* - `webhookBodyBytes`: the largest delivery a webhook endpoint reads, before it verifies it
|
|
124
|
+
* (`413` past it); the payload goes into the turn's message, one record entry.
|
|
125
|
+
*
|
|
126
|
+
* Memory (track T5, D72; checked on every write):
|
|
127
|
+
* - `memoryBytes`: the largest memory, in UTF-8 bytes.
|
|
128
|
+
* - `memoriesPerAgent`: the most memories one Agent holds.
|
|
129
|
+
* - `memoryIndexLines`, `memoryIndexBytes`: the most lines and UTF-8 bytes of the index a session
|
|
130
|
+
* pins at its start (`turn.start.memory.index`); the newest memories come first.
|
|
131
|
+
*
|
|
132
|
+
* Sessions:
|
|
133
|
+
* - `sessionQueuedMessages`: the most messages one session's queue holds while its turn runs or
|
|
134
|
+
* waits (protocol 17); one more is `429 queue_full`.
|
|
135
|
+
*
|
|
110
136
|
* Flows (`workflows.md` §13):
|
|
111
137
|
* - `flowConcurrency`: the most effects one flow turn runs at once; the rest wait their turn.
|
|
112
138
|
* - `flowMapItems`: the most items one map stage may fan out to (`map.too-many-items` past it).
|
|
@@ -165,6 +191,21 @@ export declare const RuntimeLimitsSchema: z.ZodObject<{
|
|
|
165
191
|
toolRuleFieldChars: z.ZodNumber;
|
|
166
192
|
toolRuleTextChars: z.ZodNumber;
|
|
167
193
|
modelBudgets: z.ZodNumber;
|
|
194
|
+
triggersPerAgent: z.ZodNumber;
|
|
195
|
+
triggerMinIntervalMs: z.ZodNumber;
|
|
196
|
+
triggerRunsPerHour: z.ZodNumber;
|
|
197
|
+
triggerJitterPercent: z.ZodNumber;
|
|
198
|
+
triggerJitterMaxMs: z.ZodNumber;
|
|
199
|
+
triggerPromptChars: z.ZodNumber;
|
|
200
|
+
triggerRunRetentionMs: z.ZodNumber;
|
|
201
|
+
webhookBodyBytes: z.ZodNumber;
|
|
202
|
+
wakeMaxAheadMs: z.ZodNumber;
|
|
203
|
+
wakeNoteChars: z.ZodNumber;
|
|
204
|
+
memoryBytes: z.ZodNumber;
|
|
205
|
+
memoriesPerAgent: z.ZodNumber;
|
|
206
|
+
memoryIndexLines: z.ZodNumber;
|
|
207
|
+
memoryIndexBytes: z.ZodNumber;
|
|
208
|
+
sessionQueuedMessages: z.ZodNumber;
|
|
168
209
|
flowConcurrency: z.ZodNumber;
|
|
169
210
|
flowMapItems: z.ZodNumber;
|
|
170
211
|
flowLoopIterations: z.ZodNumber;
|
|
@@ -189,7 +230,7 @@ export type HarnessLimit = keyof HarnessLimits;
|
|
|
189
230
|
/** The part of `limits` a harness is sent. */
|
|
190
231
|
export declare function harnessLimitsOf(limits: RuntimeLimits): HarnessLimits;
|
|
191
232
|
/** What a limit counts. */
|
|
192
|
-
export type RuntimeLimitUnit = "bytes" | "entries" | "characters" | "milliseconds" | "attempts" | "retries" | "effects" | "iterations";
|
|
233
|
+
export type RuntimeLimitUnit = "percent" | "runs" | "bytes" | "entries" | "characters" | "milliseconds" | "attempts" | "retries" | "effects" | "iterations";
|
|
193
234
|
interface Ceiling {
|
|
194
235
|
readonly value: number;
|
|
195
236
|
readonly unit: RuntimeLimitUnit;
|
|
@@ -213,7 +254,17 @@ export declare const RUNTIME_LIMIT_DEFAULTS: RuntimeLimits;
|
|
|
213
254
|
export declare const HARNESS_LIMIT_DEFAULTS: HarnessLimits;
|
|
214
255
|
/** The limits in force: `set`, with the default for each it leaves out. */
|
|
215
256
|
export declare function runtimeLimitsOf(set: Partial<RuntimeLimits> | undefined): RuntimeLimits;
|
|
216
|
-
/**
|
|
257
|
+
/**
|
|
258
|
+
* Limits with a floor, which no setting may go under, and why: a schedule's cron is minute
|
|
259
|
+
* grained, and runs dedupe repeated fires for as long as the execution's own dedupe lasts (a day).
|
|
260
|
+
*/
|
|
261
|
+
export declare const RUNTIME_LIMIT_FLOORS: {
|
|
262
|
+
readonly [K in RuntimeLimit]?: {
|
|
263
|
+
readonly value: number;
|
|
264
|
+
readonly why: string;
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
/** Why `set` cannot be put: each limit above its ceiling or under its floor, naming why. */
|
|
217
268
|
export declare function runtimeLimitIssues(set: Partial<RuntimeLimits> | undefined): string[];
|
|
218
269
|
/**
|
|
219
270
|
* The message of a write refused for passing limit `name`: what was sent, the limit, and where an
|