@nylorun/core 0.39.0-beta → 0.41.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,31 @@
1
1
  # @nylorun/core
2
2
 
3
+ ## 0.41.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - fe118db: The Tenant's sandbox settings round-trip, and `engine.images` comes back (#588).
8
+
9
+ - **Breaking (`@nylorun/runtime`, `@nylorun/core`, `@nylorun/admin`): `config` is the settings as stored.** `GET` and `PUT /v1/tenant/sandbox` (`admin.settings.sandbox`) answer `config` as the Tenant set it, with no defaults, in exactly the shape `PUT` takes (`limits.resources.memory: "8GiB"`), so `put(get().config)` changes nothing and saves no default as a setting. The settings in force, every default filled in and sizes in MiB (`memoryMiB`), are `effective`, which is what `config` was. Before, `PUT` refused what `GET` answered (`unrecognized_keys "memoryMiB"`). Read the settings in force from `effective` (`view.effective.limits.resources.memoryMiB`), and build a `PUT` body from `view.config`. `TenantSandboxViewSchema` has `config: TenantEnvironmentsConfigSchema` and `effective: EffectiveSandboxConfigSchema`.
10
+ - **`engine.images` is answered.** A `PUT` with `engine.images` was stored and used, but left out of its answer and of the next `GET`. Both now carry it, in `config` as set and in `effective` (`[]` when unset).
11
+ - `@nylorun/studio`: Edit compute settings puts the stored settings with only the fields it changed, so it no longer erases `engine.images` set through the API, keeps `placement`, and saves no default as a setting; clearing idle, stop grace or most Agents puts back the default. The Compute tab lists the engine images.
12
+ - `nylorun`: `nylorun tenant settings sandbox put` takes what `get` printed and puts back its `config`. `nylorun doctor sandbox` reads the limits in force from `effective`, or from `config` on an older Runtime.
13
+
14
+ ### Patch Changes
15
+
16
+ - fe118db: A message's `removeTools` turns a Runtime plugin's tool off by its own name too: `memory` now does what `nylorun__memory` does, so the name events and `check --explain` showed no longer leaves the tool on without a word (#589). `nylorun check --explain` lists a plugin's tools by the names the model reads (`nylorun__memory`, `nylorun__update_plan`), the ones `removeTools` and tool policy take, and its memory note says the index is pinned again at a turn after a write from elsewhere (#590, #591).
17
+
18
+ ## 0.40.0-beta
19
+
20
+ ### Minor Changes
21
+
22
+ - b6a7c1d: An agent sees the images and PDFs it makes in its sandbox (ADR-139). `read` of a file the turn's model reads as media, known by its extension (an image, a PDF, an Office document, audio or video), comes back as the file itself, shown to the model in the turn's files, instead of numbered lines of decoded bytes. Our engine runs it in the harness: it reads the bytes, checks they start as the type says, and stores them as an artifact for the model only. A model that can't read the kind is told so before anything is read or stored (`sandbox.unreadable`), and a file that isn't what its name says fails `sandbox.binary_file`.
23
+
24
+ - **Model-only artifacts.** `artifact.write` `begin` takes `audience: "model"` (Harness API 5, schema revision 5, `harness-api/v5.5.json`; only our own engine sends it). Such an artifact is readable by id and carries `audience: "model"` in its view and its `artifact.created` event, but is never listed (`GET /v1/artifacts`, a session's artifacts, pages) and is no A2A task file. Runtime store migration 0046 (`artifacts.audience`, nullable) runs at start.
25
+ - **Binary files.** The sandbox's `read` of any other binary file fails `sandbox.binary_file`, in words, instead of answering decoded bytes as text.
26
+ - **A cap per call.** A model call carries at most the 6 newest files from tool results as media; older ones in the same turn go as a note naming them, which `read_artifact` brings back. A person's own files are never capped.
27
+ - `read`'s description says what it now does, so the prompt prefix of every agent with a sandbox changes once: its first call after the upgrade misses the prompt cache.
28
+
3
29
  ## 0.39.0-beta
4
30
 
5
31
  ### Minor Changes
@@ -12,7 +12,7 @@ export type { WorkflowManifest } from "./types/workflow.js";
12
12
  export { PROTOCOL_VERSION, ERROR_CODES } from "./compatibility.js";
13
13
  export { SKILL_TOTAL_BYTES_DEFAULT, definitionFilesOf, isDefinitionFileHash, skillsOf, } from "./utils/definition-files.js";
14
14
  export { HARNESS_LIMIT_DEFAULTS, HarnessLimitsSchema, JS_STRING_MAX_LENGTH, RECORD_ENVELOPE_RESERVE_BYTES, RUNTIME_LIMIT_CEILINGS, RUNTIME_LIMIT_DEFAULTS, RuntimeLimitsSchema, S2_RECORD_MAX_BYTES, TIMER_MAX_MS, harnessLimitsOf, inlineBodyBytes, limitExceededMessage, runtimeLimitIssues, runtimeLimitsOf, type HarnessLimit, type HarnessLimits, type RuntimeLimit, type RuntimeLimits, } from "./utils/runtime-limits.js";
15
- export { DEFAULT_CONTENT_TYPE, MODEL_IMAGE_TYPES, contentTypeFor, essence, extensionFor, inputLabel, isModelImage, isOffice, isText, modelInputOf, normalizeContentType, } from "./utils/media-types.js";
15
+ export { DEFAULT_CONTENT_TYPE, MODEL_IMAGE_TYPES, contentTypeFor, essence, extensionFor, inputLabel, isModelImage, isOffice, isText, matchesSignature, modelInputOf, normalizeContentType, } from "./utils/media-types.js";
16
16
  export type { ErrorCode } from "./compatibility.js";
17
17
  export declare const RequestIdSchema: z.ZodString;
18
18
  /** At most 256 characters: an identifier's grammar is the protocol's (it crosses the Runtime API, the Harness API and tokens, and means the same in every installation), so its length is a constant of protocol 15, not a setting. */
@@ -4215,8 +4215,8 @@ export type MessageDelivery = z.infer<typeof MessageDeliverySchema>;
4215
4215
  * A message's `removeTools` (Host feature `remove-tools`): the tools its turn may not use, by
4216
4216
  * name. In the root agent and each agent it uses as a tool, a name removes the declared tool of
4217
4217
  * that name (an agent used as a tool included), `<server>__<tool>` disables an MCP server's tool
4218
- * (the server's name and the tool's own name on it), and `<server>` every tool of that server.
4219
- * Applied to the version the turn runs, after a turn's first segment re-pins the session to its
4218
+ * (the server's name and the tool's own name on it), `<server>` every tool of that server, and a
4219
+ * Runtime plugin's tool is named `nylorun__<tool>` or by its own name (`memory`). Applied to the version the turn runs, after a turn's first segment re-pins the session to its
4220
4220
  * Agent's version; names that version does not have are ignored. Any caller may send it: it
4221
4221
  * only narrows.
4222
4222
  */
@@ -5505,6 +5505,14 @@ export declare const ArtifactSourceSchema: z.ZodEnum<{
5505
5505
  upload: "upload";
5506
5506
  }>;
5507
5507
  export type ArtifactSource = z.infer<typeof ArtifactSourceSchema>;
5508
+ /**
5509
+ * Who an artifact is for (ADR-139): `model` for a file our engine stored only so its model could
5510
+ * see it (a sandbox image or PDF it read). Such an artifact stays in the session, readable by id,
5511
+ * but is no output: no A2A task file, no AG-UI history entry, not in a session's artifact list.
5512
+ * Absent for everything else.
5513
+ */
5514
+ export declare const ArtifactAudienceSchema: z.ZodLiteral<"model">;
5515
+ export type ArtifactAudience = z.infer<typeof ArtifactAudienceSchema>;
5508
5516
  /**
5509
5517
  * What an artifact holds: one file, or a folder, whose versions are manifests of paths to
5510
5518
  * content-addressed files.
@@ -5536,6 +5544,7 @@ export declare const ArtifactVersionPayloadSchema: z.ZodObject<{
5536
5544
  snapshot: "snapshot";
5537
5545
  upload: "upload";
5538
5546
  }>;
5547
+ audience: z.ZodOptional<z.ZodLiteral<"model">>;
5539
5548
  callId: z.ZodOptional<z.ZodString>;
5540
5549
  fileCount: z.ZodOptional<z.ZodNumber>;
5541
5550
  claimed: z.ZodOptional<z.ZodBoolean>;
@@ -6398,6 +6407,7 @@ export declare const EVENT_CATALOG: {
6398
6407
  snapshot: "snapshot";
6399
6408
  upload: "upload";
6400
6409
  }>;
6410
+ audience: z.ZodOptional<z.ZodLiteral<"model">>;
6401
6411
  callId: z.ZodOptional<z.ZodString>;
6402
6412
  fileCount: z.ZodOptional<z.ZodNumber>;
6403
6413
  claimed: z.ZodOptional<z.ZodBoolean>;
@@ -6423,6 +6433,7 @@ export declare const EVENT_CATALOG: {
6423
6433
  snapshot: "snapshot";
6424
6434
  upload: "upload";
6425
6435
  }>;
6436
+ audience: z.ZodOptional<z.ZodLiteral<"model">>;
6426
6437
  callId: z.ZodOptional<z.ZodString>;
6427
6438
  fileCount: z.ZodOptional<z.ZodNumber>;
6428
6439
  claimed: z.ZodOptional<z.ZodBoolean>;
@@ -7617,7 +7628,10 @@ export declare const ListProvidersResponseSchema: z.ZodObject<{
7617
7628
  }, z.core.$strict>>;
7618
7629
  }, z.core.$strict>;
7619
7630
  export type ListProvidersResponse = z.infer<typeof ListProvidersResponseSchema>;
7620
- /** A Tenant's Environment settings with every default applied (sizes in MiB). */
7631
+ /**
7632
+ * A Tenant's Environment settings with every default applied (sizes in MiB): the configuration in
7633
+ * force. `GET /v1/tenant/sandbox` answers it as `effective`, beside `config`, the settings as set.
7634
+ */
7621
7635
  export declare const EffectiveSandboxConfigSchema: z.ZodObject<{
7622
7636
  limits: z.ZodObject<{
7623
7637
  network: z.ZodArray<z.ZodString>;
@@ -7641,9 +7655,15 @@ export declare const EffectiveSandboxConfigSchema: z.ZodObject<{
7641
7655
  sandbox: "sandbox";
7642
7656
  }>>;
7643
7657
  }, z.core.$strict>>>;
7658
+ engine: z.ZodOptional<z.ZodObject<{
7659
+ images: z.ZodArray<z.ZodString>;
7660
+ }, z.core.$strict>>;
7644
7661
  }, z.core.$strict>;
7645
7662
  export type EffectiveSandboxConfig = z.infer<typeof EffectiveSandboxConfigSchema>;
7646
- /** `GET` and `PUT /v1/tenant/sandbox`: the backend chosen, and the configuration in force. */
7663
+ /**
7664
+ * `GET` and `PUT /v1/tenant/sandbox`: the backend chosen, the Tenant's settings as it set them
7665
+ * (`config`) and the configuration in force (`effective`).
7666
+ */
7647
7667
  export declare const TenantSandboxViewSchema: z.ZodObject<{
7648
7668
  preference: z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodEnum<{
7649
7669
  local: "local";
@@ -7673,6 +7693,33 @@ export declare const TenantSandboxViewSchema: z.ZodObject<{
7673
7693
  }, z.core.$strict>>;
7674
7694
  defaultImage: z.ZodString;
7675
7695
  config: z.ZodObject<{
7696
+ limits: z.ZodOptional<z.ZodObject<{
7697
+ network: z.ZodOptional<z.ZodArray<z.ZodString>>;
7698
+ resources: z.ZodOptional<z.ZodObject<{
7699
+ cpus: z.ZodOptional<z.ZodNumber>;
7700
+ memory: z.ZodOptional<z.ZodString>;
7701
+ }, z.core.$strict>>;
7702
+ defaultResources: z.ZodOptional<z.ZodObject<{
7703
+ cpus: z.ZodOptional<z.ZodNumber>;
7704
+ memory: z.ZodOptional<z.ZodString>;
7705
+ }, z.core.$strict>>;
7706
+ idle: z.ZodOptional<z.ZodString>;
7707
+ environments: z.ZodOptional<z.ZodNumber>;
7708
+ }, z.core.$strict>>;
7709
+ lifecycle: z.ZodOptional<z.ZodObject<{
7710
+ stopGrace: z.ZodOptional<z.ZodString>;
7711
+ }, z.core.$strict>>;
7712
+ engine: z.ZodOptional<z.ZodObject<{
7713
+ images: z.ZodOptional<z.ZodArray<z.ZodString>>;
7714
+ }, z.core.$strict>>;
7715
+ placement: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
7716
+ hosts: z.ZodArray<z.ZodEnum<{
7717
+ "harness-container": "harness-container";
7718
+ sandbox: "sandbox";
7719
+ }>>;
7720
+ }, z.core.$strict>>>;
7721
+ }, z.core.$strict>;
7722
+ effective: z.ZodObject<{
7676
7723
  limits: z.ZodObject<{
7677
7724
  network: z.ZodArray<z.ZodString>;
7678
7725
  resources: z.ZodObject<{
@@ -7695,6 +7742,9 @@ export declare const TenantSandboxViewSchema: z.ZodObject<{
7695
7742
  sandbox: "sandbox";
7696
7743
  }>>;
7697
7744
  }, z.core.$strict>>>;
7745
+ engine: z.ZodOptional<z.ZodObject<{
7746
+ images: z.ZodArray<z.ZodString>;
7747
+ }, z.core.$strict>>;
7698
7748
  }, z.core.$strict>;
7699
7749
  cluster: z.ZodOptional<z.ZodNullable<z.ZodObject<{
7700
7750
  namespace: z.ZodString;
@@ -8184,6 +8234,7 @@ export declare const ArtifactViewSchema: z.ZodObject<{
8184
8234
  agentId: z.ZodOptional<z.ZodString>;
8185
8235
  latestVersion: z.ZodNumber;
8186
8236
  labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8237
+ audience: z.ZodOptional<z.ZodLiteral<"model">>;
8187
8238
  createdAt: z.ZodString;
8188
8239
  updatedAt: z.ZodString;
8189
8240
  versions: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -8214,6 +8265,7 @@ export declare const ListArtifactsResponseSchema: z.ZodObject<{
8214
8265
  agentId: z.ZodOptional<z.ZodString>;
8215
8266
  latestVersion: z.ZodNumber;
8216
8267
  labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8268
+ audience: z.ZodOptional<z.ZodLiteral<"model">>;
8217
8269
  createdAt: z.ZodString;
8218
8270
  updatedAt: z.ZodString;
8219
8271
  versions: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -8245,6 +8297,7 @@ export declare const ArtifactListItemSchema: z.ZodObject<{
8245
8297
  agentId: z.ZodOptional<z.ZodString>;
8246
8298
  latestVersion: z.ZodNumber;
8247
8299
  labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8300
+ audience: z.ZodOptional<z.ZodLiteral<"model">>;
8248
8301
  createdAt: z.ZodString;
8249
8302
  updatedAt: z.ZodString;
8250
8303
  }, z.core.$strict>;
@@ -8262,6 +8315,7 @@ export declare const ArtifactPageSchema: z.ZodObject<{
8262
8315
  agentId: z.ZodOptional<z.ZodString>;
8263
8316
  latestVersion: z.ZodNumber;
8264
8317
  labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8318
+ audience: z.ZodOptional<z.ZodLiteral<"model">>;
8265
8319
  createdAt: z.ZodString;
8266
8320
  updatedAt: z.ZodString;
8267
8321
  }, z.core.$strict>>;
@@ -8282,6 +8336,7 @@ export declare const UploadArtifactResponseSchema: z.ZodObject<{
8282
8336
  agentId: z.ZodOptional<z.ZodString>;
8283
8337
  latestVersion: z.ZodNumber;
8284
8338
  labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
8339
+ audience: z.ZodOptional<z.ZodLiteral<"model">>;
8285
8340
  createdAt: z.ZodString;
8286
8341
  updatedAt: z.ZodString;
8287
8342
  versions: z.ZodOptional<z.ZodArray<z.ZodObject<{
package/dist/contracts.js CHANGED
@@ -18,7 +18,7 @@ export { PROTOCOL_VERSION, ERROR_CODES } from "./compatibility.js";
18
18
  export { SKILL_TOTAL_BYTES_DEFAULT, definitionFilesOf, isDefinitionFileHash, skillsOf, } from "./utils/definition-files.js";
19
19
  export { HARNESS_LIMIT_DEFAULTS, HarnessLimitsSchema, JS_STRING_MAX_LENGTH, RECORD_ENVELOPE_RESERVE_BYTES, RUNTIME_LIMIT_CEILINGS, RUNTIME_LIMIT_DEFAULTS, RuntimeLimitsSchema, S2_RECORD_MAX_BYTES, TIMER_MAX_MS, harnessLimitsOf, inlineBodyBytes, limitExceededMessage, runtimeLimitIssues, runtimeLimitsOf, } from "./utils/runtime-limits.js";
20
20
  import { RuntimeLimitsSchema, TIMER_MAX_MS } from "./utils/runtime-limits.js";
21
- export { DEFAULT_CONTENT_TYPE, MODEL_IMAGE_TYPES, contentTypeFor, essence, extensionFor, inputLabel, isModelImage, isOffice, isText, modelInputOf, normalizeContentType, } from "./utils/media-types.js";
21
+ export { DEFAULT_CONTENT_TYPE, MODEL_IMAGE_TYPES, contentTypeFor, essence, extensionFor, inputLabel, isModelImage, isOffice, isText, matchesSignature, modelInputOf, normalizeContentType, } from "./utils/media-types.js";
22
22
  import { ERROR_CODES, isArtifactId } from "./compatibility.js";
23
23
  export const RequestIdSchema = z.string().min(1);
24
24
  /** At most 256 characters: an identifier's grammar is the protocol's (it crosses the Runtime API, the Harness API and tokens, and means the same in every installation), so its length is a constant of protocol 15, not a setting. */
@@ -2898,8 +2898,8 @@ export const MessageDeliverySchema = z.enum(["queue", "reject", "steer"]);
2898
2898
  * A message's `removeTools` (Host feature `remove-tools`): the tools its turn may not use, by
2899
2899
  * name. In the root agent and each agent it uses as a tool, a name removes the declared tool of
2900
2900
  * that name (an agent used as a tool included), `<server>__<tool>` disables an MCP server's tool
2901
- * (the server's name and the tool's own name on it), and `<server>` every tool of that server.
2902
- * Applied to the version the turn runs, after a turn's first segment re-pins the session to its
2901
+ * (the server's name and the tool's own name on it), `<server>` every tool of that server, and a
2902
+ * Runtime plugin's tool is named `nylorun__<tool>` or by its own name (`memory`). Applied to the version the turn runs, after a turn's first segment re-pins the session to its
2903
2903
  * Agent's version; names that version does not have are ignored. Any caller may send it: it
2904
2904
  * only narrows.
2905
2905
  */
@@ -3641,6 +3641,13 @@ export const TranscriptUpdatedPayloadSchema = z
3641
3641
  * before protocol 15 name (`export`).
3642
3642
  */
3643
3643
  export const ArtifactSourceSchema = z.enum(["upload", "engine", "export", "snapshot"]);
3644
+ /**
3645
+ * Who an artifact is for (ADR-139): `model` for a file our engine stored only so its model could
3646
+ * see it (a sandbox image or PDF it read). Such an artifact stays in the session, readable by id,
3647
+ * but is no output: no A2A task file, no AG-UI history entry, not in a session's artifact list.
3648
+ * Absent for everything else.
3649
+ */
3650
+ export const ArtifactAudienceSchema = z.literal("model");
3644
3651
  /**
3645
3652
  * What an artifact holds: one file, or a folder, whose versions are manifests of paths to
3646
3653
  * content-addressed files.
@@ -3661,6 +3668,8 @@ export const ArtifactVersionPayloadSchema = z
3661
3668
  size: z.number().int().nonnegative(),
3662
3669
  sha256: z.string(),
3663
3670
  source: ArtifactSourceSchema,
3671
+ /** `model`: stored only for the model to see (ADR-139); absent for an output. */
3672
+ audience: ArtifactAudienceSchema.optional(),
3664
3673
  /** The tool call that saved it (`save_artifact`), when our engine did. */
3665
3674
  callId: z.string().optional(),
3666
3675
  /** A folder's number of files. */
@@ -4579,7 +4588,10 @@ export const ListProvidersResponseSchema = z
4579
4588
  const SandboxResourcesLimitSchema = z
4580
4589
  .object({ cpus: z.number(), memoryMiB: z.number() })
4581
4590
  .strict();
4582
- /** A Tenant's Environment settings with every default applied (sizes in MiB). */
4591
+ /**
4592
+ * A Tenant's Environment settings with every default applied (sizes in MiB): the configuration in
4593
+ * force. `GET /v1/tenant/sandbox` answers it as `effective`, beside `config`, the settings as set.
4594
+ */
4583
4595
  export const EffectiveSandboxConfigSchema = z
4584
4596
  .object({
4585
4597
  limits: z
@@ -4598,11 +4610,16 @@ export const EffectiveSandboxConfigSchema = z
4598
4610
  placement: z
4599
4611
  .record(z.string(), z.object({ hosts: z.array(z.enum(PLACEMENT_HOSTS)) }).strict())
4600
4612
  .optional(),
4613
+ /** Pods: the image repositories that carry this Runtime's engine (ADR-99); none by default. */
4614
+ engine: z.object({ images: z.array(z.string()) }).strict().optional(),
4601
4615
  })
4602
4616
  .strict();
4603
4617
  const SandboxBackendNameSchema = z.enum(["virtual", "local"]);
4604
4618
  const SandboxIsolationSchema = z.enum(["process", "container"]);
4605
- /** `GET` and `PUT /v1/tenant/sandbox`: the backend chosen, and the configuration in force. */
4619
+ /**
4620
+ * `GET` and `PUT /v1/tenant/sandbox`: the backend chosen, the Tenant's settings as it set them
4621
+ * (`config`) and the configuration in force (`effective`).
4622
+ */
4606
4623
  export const TenantSandboxViewSchema = z
4607
4624
  .object({
4608
4625
  preference: z.union([z.literal("auto"), SandboxBackendNameSchema]),
@@ -4619,7 +4636,14 @@ export const TenantSandboxViewSchema = z
4619
4636
  })
4620
4637
  .strict()),
4621
4638
  defaultImage: z.string(),
4622
- config: EffectiveSandboxConfigSchema,
4639
+ /**
4640
+ * The Tenant's settings as stored (Tenant setting `environments.config`): only what it set,
4641
+ * with no defaults, in exactly the shape `PUT /v1/tenant/sandbox` takes. Put it back, changed,
4642
+ * to change one setting and keep the others. `{}` when the Tenant set nothing.
4643
+ */
4644
+ config: TenantEnvironmentsConfigSchema,
4645
+ /** The configuration in force: `config` with every default filled in, sizes in MiB. */
4646
+ effective: EffectiveSandboxConfigSchema,
4623
4647
  /**
4624
4648
  * The Tenant's cluster for pod sandboxes (`nylorun local sandbox enable`), as the sandboxes
4625
4649
  * service reports it; null without one, or when the service does not answer.
@@ -5021,6 +5045,11 @@ export const ArtifactViewSchema = z
5021
5045
  agentId: z.string().optional(),
5022
5046
  latestVersion: z.number().int().positive(),
5023
5047
  labels: z.record(z.string(), z.string()).optional(),
5048
+ /**
5049
+ * `model`: our engine stored it only so its model could see it (ADR-139). Readable by id;
5050
+ * never in a list of artifacts. Absent for every other artifact.
5051
+ */
5052
+ audience: ArtifactAudienceSchema.optional(),
5024
5053
  createdAt: z.string(),
5025
5054
  updatedAt: z.string(),
5026
5055
  /** Every version, oldest first (`GET /v1/artifacts/{id}` only). */
@@ -16,7 +16,9 @@ export declare function isVariantOf(candidate: AgentManifest, pinned: AgentManif
16
16
  * - the tool of that name: an agent used as a tool, an HTTP tool, any declared tool;
17
17
  * - `<server>__<tool>`, an MCP server's tool by the server's name and the tool's own name on it:
18
18
  * disabled in the server's `tools` settings (`{enabled: false}`);
19
- * - `<server>`, an MCP server's name: every tool of it disabled (`"*"` and each entry).
19
+ * - `<server>`, an MCP server's name: every tool of it disabled (`"*"` and each entry);
20
+ * - a Runtime plugin's tool, by the name the model reads (`nylorun__memory`) or its own name
21
+ * (`memory`): turned off in the declared plugin (ADR-106).
20
22
  *
21
23
  * A name that matches nothing is ignored: the version the turn runs may not have it. Returns
22
24
  * `manifest` itself when nothing matched.
@@ -1,4 +1,4 @@
1
- import { runtimeToolOf } from "../plugins/index.js";
1
+ import { pluginOfTool, runtimeToolOf } from "../plugins/index.js";
2
2
  import { canonical } from "../utils/canonical.js";
3
3
  function same(a, b) {
4
4
  return canonical(a) === canonical(b);
@@ -108,7 +108,9 @@ export function isVariantOf(candidate, pinned) {
108
108
  * - the tool of that name: an agent used as a tool, an HTTP tool, any declared tool;
109
109
  * - `<server>__<tool>`, an MCP server's tool by the server's name and the tool's own name on it:
110
110
  * disabled in the server's `tools` settings (`{enabled: false}`);
111
- * - `<server>`, an MCP server's name: every tool of it disabled (`"*"` and each entry).
111
+ * - `<server>`, an MCP server's name: every tool of it disabled (`"*"` and each entry);
112
+ * - a Runtime plugin's tool, by the name the model reads (`nylorun__memory`) or its own name
113
+ * (`memory`): turned off in the declared plugin (ADR-106).
112
114
  *
113
115
  * A name that matches nothing is ignored: the version the turn runs may not have it. Returns
114
116
  * `manifest` itself when nothing matched.
@@ -122,8 +124,9 @@ export function withoutTools(manifest, names) {
122
124
  }
123
125
  function narrowAgent(agent, removed, root) {
124
126
  const { tools: _tools, mcpServers: _servers, engine: _engine, ...rest } = agent;
125
- // A Runtime plugin's tool by the name the model reads (ADR-106): `nylorun__ask` turns `ask` off.
126
- const offPlugin = new Set([...removed].flatMap((name) => runtimeToolOf(name) ?? []));
127
+ // A Runtime plugin's tool by the name the model reads (ADR-106): `nylorun__ask` turns `ask` off,
128
+ // and so does its own name `ask`, the one events and `check --explain` show.
129
+ const offPlugin = new Set([...removed].flatMap((name) => runtimeToolOf(name) ?? (pluginOfTool(name) === undefined ? [] : [name])));
127
130
  const engine = agent.engine?.plugins !== undefined && offPlugin.size > 0
128
131
  ? { ...agent.engine, plugins: agent.engine.plugins.map((plugin) => ({ ...plugin, tools: plugin.tools.filter((tool) => !offPlugin.has(tool)) })) }
129
132
  : agent.engine;
@@ -80,10 +80,12 @@ function explainOne(id, preview, facts) {
80
80
  }
81
81
  };
82
82
  const blocks = new Set(preview.blocks.map((block) => block.name));
83
- // A Runtime plugin's tool by its own name: nylorun__memory is memory (ADR-106).
84
- const tools = new Set(preview.engineTools.map((name) => runtimeToolOf(name) ?? name));
83
+ // A Runtime plugin's tool matches by its own name (nylorun__memory is memory, ADR-106), and is
84
+ // shown by the name the model reads, the one `removeTools` and tool policy take.
85
+ const modelNames = new Map(preview.engineTools.map((name) => [runtimeToolOf(name) ?? name, name]));
86
+ const tools = new Set(modelNames.keys());
85
87
  const features = ENGINE_FEATURES.map((feature) => {
86
- const added = TOOLS[feature].filter((name) => tools.has(name));
88
+ const added = TOOLS[feature].filter((name) => tools.has(name)).map((name) => modelNames.get(name) ?? name);
87
89
  const text = BLOCKS[feature].filter((name) => blocks.has(name)).map((name) => `${name}@${ENGINE_BLOCK_VERSIONS[name]}`);
88
90
  let on = added.length > 0 || text.length > 0;
89
91
  let note;
@@ -95,7 +97,7 @@ function explainOne(id, preview, facts) {
95
97
  note = !facts.root
96
98
  ? "view only: the root agent's memory"
97
99
  : facts.pinned
98
- ? "the memory index is pinned at the head of each session"
100
+ ? "the memory index is pinned at the head of each session, and again at a turn after a write from elsewhere"
99
101
  : "no memory index is pinned (memory.index: false)";
100
102
  if (feature === "toolSearch") {
101
103
  on = preview.features.toolSearch;
@@ -67,8 +67,10 @@ export function sandboxTools(limits, workspace, names = SANDBOX_TOOL_NAMES) {
67
67
  },
68
68
  {
69
69
  name: "read",
70
- description: `Read a text file from the sandbox. ${relative} Returns numbered lines. ` +
71
- "Use offset and limit to page through large files.",
70
+ description: `Read a file from the sandbox. ${relative} A text file returns numbered lines: use offset ` +
71
+ "and limit to page through a large one. An image, a PDF or another file your model reads, " +
72
+ "known by its extension, comes back as the file itself, shown to you and not to the user. " +
73
+ "Other binary files can't be read.",
72
74
  inputSchema: object({
73
75
  path: pathField,
74
76
  offset: {
@@ -44,6 +44,8 @@ export interface ArtifactWriteOptions {
44
44
  readonly effectId?: string;
45
45
  /** The body's size when known: core refuses one past its limits before a byte is sent. */
46
46
  readonly size?: number;
47
+ /** `model`: a new artifact stored only for the model to see, never an output (ADR-139). */
48
+ readonly audience?: "model";
47
49
  /** The most bytes one chunk carries: the run's `turn.start.limits.chunkBytes`. */
48
50
  readonly chunkBytes: number;
49
51
  readonly signal?: AbortSignal;
@@ -69,6 +69,7 @@ function beginOf(options) {
69
69
  ...(options.contentType === undefined ? {} : { contentType: options.contentType }),
70
70
  ...(options.effectId === undefined ? {} : { effectId: options.effectId }),
71
71
  ...(options.size === undefined ? {} : { size: options.size }),
72
+ ...(options.audience === undefined ? {} : { audience: options.audience }),
72
73
  };
73
74
  }
74
75
  function opened(channel, options, begun) {
@@ -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.4.json",
3
+ "$id": "https://docs.nylorun.com/schemas/harness-api/v5.5.json",
4
4
  "title": "Nylorun Harness API 5",
5
5
  "$defs": {
6
6
  "ArtifactMeta": {
@@ -4774,6 +4774,10 @@
4774
4774
  },
4775
4775
  "base64": {
4776
4776
  "type": "string"
4777
+ },
4778
+ "audience": {
4779
+ "type": "string",
4780
+ "const": "model"
4777
4781
  }
4778
4782
  },
4779
4783
  "required": [
@@ -57,9 +57,10 @@ export function harnessApiSchemas() {
57
57
  * pinned). Revision 3: `turn.start.agent.triggers` and the `runtime` operation `triggers` (D83),
58
58
  * which a v5 harness that offers no `triggers` tool never sees. Revision 4: the effect kind `inputs`
59
59
  (D85): the messages steered into the running turn, which core answers at once and a v5 harness
60
- that never asks for it never sees.
60
+ that never asks for it never sees. Revision 5: `artifact.write` `begin` may carry
61
+ `audience: "model"` (ADR-139), which core accepts and only our own engine sends.
61
62
  */
62
- const SCHEMA_REVISION = 4;
63
+ const SCHEMA_REVISION = 5;
63
64
  /** The JSON Schema document of the Harness API (draft 2020-12). */
64
65
  export function harnessApiJsonSchema() {
65
66
  const $defs = {};
@@ -1075,6 +1075,7 @@ export declare const harnessRequests: {
1075
1075
  size: z.ZodOptional<z.ZodNumber>;
1076
1076
  effectId: z.ZodOptional<z.ZodString>;
1077
1077
  base64: z.ZodOptional<z.ZodString>;
1078
+ audience: z.ZodOptional<z.ZodLiteral<"model">>;
1078
1079
  }, z.core.$strict>, z.ZodObject<{
1079
1080
  runId: z.ZodString;
1080
1081
  op: z.ZodLiteral<"begin">;
@@ -7,7 +7,7 @@
7
7
  import { z } from "zod";
8
8
  import { ABORT_REASONS, HARNESS_API_VERSION, HARNESS_CLAIMS, HARNESS_ERROR_CODES, } from "./messages.js";
9
9
  import { HarnessApiError } from "./errors.js";
10
- import { ARTIFACT_NAME_MAX, ENVIRONMENT_KINDS, EffectOutcomeSchema, ModelInputSchema } from "../contracts.js";
10
+ import { ARTIFACT_NAME_MAX, ArtifactAudienceSchema, ENVIRONMENT_KINDS, EffectOutcomeSchema, ModelInputSchema, } from "../contracts.js";
11
11
  import { HarnessLimitsSchema, RUNTIME_LIMIT_CEILINGS } from "../utils/runtime-limits.js";
12
12
  import { SANDBOX_TOOL_NAMES } from "../utils/sandbox.js";
13
13
  import { McpFactsSchema, McpSnapshotSchema } from "./mcp.js";
@@ -641,6 +641,11 @@ export const harnessRequests = {
641
641
  size: z.number().int().nonnegative().optional(),
642
642
  effectId: id.optional(),
643
643
  base64: z.string().optional(),
644
+ /**
645
+ * `model` (ADR-139, revision 5): a file stored only for the model to see, never an
646
+ * output. Only our own engine sends it; core accepts it within v5.
647
+ */
648
+ audience: ArtifactAudienceSchema.optional(),
644
649
  })
645
650
  .strict(),
646
651
  runId
@@ -24,6 +24,12 @@ export declare function isText(contentType: string): boolean;
24
24
  export declare function extensionFor(contentType: string): string | undefined;
25
25
  /** Word, Excel and PowerPoint documents, old and Open XML. */
26
26
  export declare function isOffice(contentType: string): boolean;
27
+ /**
28
+ * Whether `bytes` start as a file of `contentType` does: true or false for a type with a known
29
+ * signature (PNG, JPEG, GIF, WebP, PDF, Office), undefined for one without. A sandbox file is typed
30
+ * by its extension; this keeps a `.png` that isn't a PNG from reaching a model as an image.
31
+ */
32
+ export declare function matchesSignature(contentType: string, bytes: Uint8Array): boolean | undefined;
27
33
  /** The model input a file of `contentType` is, or undefined for a type no model reads. */
28
34
  export declare function modelInputOf(contentType: string): ModelInput | undefined;
29
35
  /** An input, in a sentence: "PDFs", "Office documents"; "files of this type" for none. */
@@ -97,6 +97,34 @@ export function isOffice(contentType) {
97
97
  type === "application/vnd.ms-powerpoint" ||
98
98
  type.startsWith("application/vnd.openxmlformats-officedocument."));
99
99
  }
100
+ const ascii = (text) => [...text].map((char) => char.charCodeAt(0));
101
+ /** The first bytes a file of each type starts with, where the type has one. */
102
+ const SIGNATURES = {
103
+ "image/png": [[0x89, ...ascii("PNG\r\n"), 0x1a, 0x0a]],
104
+ "image/jpeg": [[0xff, 0xd8, 0xff]],
105
+ "image/gif": [ascii("GIF87a"), ascii("GIF89a")],
106
+ // RIFF, four bytes of size, then WEBP.
107
+ "image/webp": [[...ascii("RIFF"), undefined, undefined, undefined, undefined, ...ascii("WEBP")]],
108
+ "application/pdf": [ascii("%PDF-")],
109
+ // Old Office files are OLE compound documents; Open XML ones are zip archives.
110
+ "application/msword": [[0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1]],
111
+ "application/vnd.ms-excel": [[0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1]],
112
+ "application/vnd.ms-powerpoint": [[0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1]],
113
+ };
114
+ const ZIP = [0x50, 0x4b, 0x03, 0x04];
115
+ /**
116
+ * Whether `bytes` start as a file of `contentType` does: true or false for a type with a known
117
+ * signature (PNG, JPEG, GIF, WebP, PDF, Office), undefined for one without. A sandbox file is typed
118
+ * by its extension; this keeps a `.png` that isn't a PNG from reaching a model as an image.
119
+ */
120
+ export function matchesSignature(contentType, bytes) {
121
+ const type = essence(contentType);
122
+ const signatures = SIGNATURES[type] ?? (type.startsWith("application/vnd.openxmlformats-officedocument.") ? [ZIP] : undefined);
123
+ if (signatures === undefined)
124
+ return undefined;
125
+ return signatures.some((signature) => bytes.byteLength >= signature.length &&
126
+ signature.every((byte, index) => byte === undefined || bytes[index] === byte));
127
+ }
100
128
  /** The model input a file of `contentType` is, or undefined for a type no model reads. */
101
129
  export function modelInputOf(contentType) {
102
130
  const type = essence(contentType);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/core",
3
- "version": "0.39.0-beta",
3
+ "version": "0.41.0-beta",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Shared agent definitions and wire contracts",