@nylorun/core 0.34.0-beta → 0.36.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/compatibility.d.ts +9 -1
  3. package/dist/compatibility.js +8 -0
  4. package/dist/contracts.d.ts +352 -6
  5. package/dist/contracts.js +180 -6
  6. package/dist/definition/variant.js +8 -1
  7. package/dist/engine/blocks.d.ts +2 -0
  8. package/dist/engine/blocks.js +7 -0
  9. package/dist/engine/explain.d.ts +1 -1
  10. package/dist/engine/explain.js +27 -5
  11. package/dist/engine/index.d.ts +1 -0
  12. package/dist/engine/index.js +1 -0
  13. package/dist/engine/names.d.ts +1 -1
  14. package/dist/engine/names.js +1 -0
  15. package/dist/engine/preview.d.ts +6 -0
  16. package/dist/engine/preview.js +3 -1
  17. package/dist/engine/projection.d.ts +10 -6
  18. package/dist/engine/projection.js +110 -6
  19. package/dist/engine/tools.d.ts +32 -0
  20. package/dist/engine/tools.js +85 -1
  21. package/dist/folder/compile.d.ts +3 -3
  22. package/dist/folder/compile.js +82 -12
  23. package/dist/folder/engine.d.ts +14 -2
  24. package/dist/folder/engine.js +17 -3
  25. package/dist/folder/index.d.ts +2 -0
  26. package/dist/folder/index.js +2 -0
  27. package/dist/folder/migrate-v3.d.ts +20 -0
  28. package/dist/folder/migrate-v3.js +124 -0
  29. package/dist/folder/nested.js +5 -0
  30. package/dist/folder/schemas.js +19 -6
  31. package/dist/folder/v3.d.ts +66 -0
  32. package/dist/folder/v3.js +139 -0
  33. package/dist/harness-api/harness-api.schema.json +19 -4
  34. package/dist/harness-api/json-schema.js +3 -2
  35. package/dist/harness-api/schema.d.ts +6 -0
  36. package/dist/harness-api/schema.js +9 -2
  37. package/dist/manifest-schemas.js +6 -4
  38. package/dist/plugins/bundle.generated.d.ts +120 -0
  39. package/dist/plugins/bundle.generated.js +143 -0
  40. package/dist/plugins/index.d.ts +65 -0
  41. package/dist/plugins/index.js +62 -0
  42. package/dist/schemas/agent-folder/agent-md.schema.json +26 -4
  43. package/dist/schemas/agent-folder/runtime.schema.json +22 -1
  44. package/dist/schemas/agent-manifest.schema.json +72 -1
  45. package/dist/schemas/harness-manifest.schema.json +51 -1
  46. package/dist/schemas/runtime-manifest.schema.json +22 -1
  47. package/dist/types/manifest.d.ts +14 -0
  48. package/package.json +1 -1
package/dist/contracts.js CHANGED
@@ -260,11 +260,24 @@ export const HarnessEngineSchema = z
260
260
  .boolean()
261
261
  .optional()
262
262
  .meta({ description: "Defer MCP tools behind tool_search when their schemas pass the threshold" }),
263
+ triggers: z
264
+ .boolean()
265
+ .optional()
266
+ .meta({ description: "The triggers tool and its text: the root agent sets up its own triggers; never a subagent's" }),
263
267
  instructions: z
264
268
  .partialRecord(z.enum(ENGINE_BLOCK_NAMES), z.string().min(1))
265
269
  .optional()
266
270
  .meta({ description: "A block's wording replaced, by block name" }),
267
271
  blocks: z.array(engineBlockRefSchema).optional().meta({ description: "The engine text blocks the agent gets, with their hashes" }),
272
+ plugins: z
273
+ .array(z.strictObject({
274
+ name: z.enum(["nylorun-memory", "nylorun-triggers", "nylorun-plan", "nylorun-interactions", "nylorun-artifacts", "nylorun-sandbox"]),
275
+ tools: z.array(z.string().min(1)),
276
+ sha256: z.string().regex(/^sha256:[0-9a-f]{64}$/),
277
+ hosts: z.array(z.string().min(1)).optional(),
278
+ }))
279
+ .optional()
280
+ .meta({ description: "The Runtime's plugins the agent declares (agent-folder/3, ADR-106): each with the tools left on and the hash of its files" }),
268
281
  })
269
282
  .meta({ id: "HarnessEngine" });
270
283
  const harnessEngineField = HarnessEngineSchema.optional();
@@ -742,6 +755,21 @@ export const EnvironmentLimitsSchema = z
742
755
  })
743
756
  .strict()
744
757
  .optional(),
758
+ /**
759
+ * Its triggers (D83), within the Tenant's Runtime limits `triggersPerAgent`,
760
+ * `triggerMinIntervalMs` and `triggerRunsPerHour`: lowering one deletes nothing.
761
+ */
762
+ triggers: z
763
+ .object({
764
+ /** The most triggers its agents may make with the `triggers` tool; at most `triggersPerAgent`. */
765
+ count: z.number().int().positive().optional(),
766
+ /** The shortest gap between two runs of a schedule its agents make; at least `triggerMinIntervalMs`. */
767
+ minIntervalMs: z.number().int().positive().optional(),
768
+ /** The most runs its triggers start or queue in any hour; at most `triggerRunsPerHour`. */
769
+ runsPerHour: z.number().int().positive().optional(),
770
+ })
771
+ .strict()
772
+ .optional(),
745
773
  })
746
774
  .strict();
747
775
  /**
@@ -1137,6 +1165,10 @@ export const AGENT_EVENT_TYPES = [
1137
1165
  "agent.trigger_paused",
1138
1166
  "agent.trigger_resumed",
1139
1167
  "agent.trigger_secret_rotated",
1168
+ // Triggers an agent made with the triggers tool (D83), and one deleted by an agent or a person.
1169
+ "agent.trigger_created",
1170
+ "agent.trigger_updated",
1171
+ "agent.trigger_deleted",
1140
1172
  // Memory (track T5, D72): a turn changed the Agent's memories.
1141
1173
  "agent.memory_updated",
1142
1174
  ];
@@ -1231,6 +1263,35 @@ export const AGENT_EVENT_PAYLOADS = {
1231
1263
  "agent.trigger_resumed": z.object({ triggerId: z.string() }).passthrough(),
1232
1264
  /** A webhook trigger's signing secret was made or replaced; the one before stopped working. */
1233
1265
  "agent.trigger_secret_rotated": z.object({ triggerId: z.string() }).passthrough(),
1266
+ /**
1267
+ * An agent made a trigger with the `triggers` tool (D83), or replaced one with the same id
1268
+ * (`agent.trigger_updated`): the session whose agent made it (`sessionId`), the session it runs
1269
+ * in (`session`), its title and its next run.
1270
+ */
1271
+ "agent.trigger_created": z
1272
+ .object({
1273
+ triggerId: z.string(),
1274
+ kind: z.enum(["schedule", "at"]),
1275
+ sessionId: z.string(),
1276
+ session: z.string(),
1277
+ title: z.string().optional(),
1278
+ nextRunAt: z.string().nullable(),
1279
+ })
1280
+ .passthrough(),
1281
+ "agent.trigger_updated": z
1282
+ .object({
1283
+ triggerId: z.string(),
1284
+ kind: z.enum(["schedule", "at"]),
1285
+ sessionId: z.string(),
1286
+ session: z.string(),
1287
+ title: z.string().optional(),
1288
+ nextRunAt: z.string().nullable(),
1289
+ })
1290
+ .passthrough(),
1291
+ /** A trigger an agent made was deleted: by an agent of `sessionId`, or over the API (`principal`). */
1292
+ "agent.trigger_deleted": z
1293
+ .object({ triggerId: z.string(), sessionId: z.string().optional(), principal: z.string().optional() })
1294
+ .passthrough(),
1234
1295
  /** A turn changed the Agent's memories (`memory.updated` in its session): which, and how. */
1235
1296
  "agent.memory_updated": MemoryUpdatedPayloadSchema.extend({ sessionId: z.string(), turnId: z.string() }),
1236
1297
  };
@@ -1868,12 +1929,27 @@ export function triggerKindOf(trigger) {
1868
1929
  * `manual`, or `new` for one an upgrade added), `completed` is an `at` that ran.
1869
1930
  */
1870
1931
  export const TRIGGER_STATUSES = ["active", "paused", "completed"];
1871
- /** `GET /v1/agents/{id}/triggers`: one trigger, from its manifest entry and the Agent's state. */
1932
+ /**
1933
+ * Where a trigger's definition comes from (D83): `manifest` (the version's `runtime.triggers`),
1934
+ * `agent` (made by an agent of the Agent's sessions with the `triggers` tool, kept by the Agent)
1935
+ * or `wake` (a session's booked wake, never listed).
1936
+ */
1937
+ export const TRIGGER_ORIGINS = ["manifest", "agent", "wake"];
1938
+ /**
1939
+ * `GET /v1/agents/{id}/triggers`: one trigger, from its manifest entry (or, for one an agent made,
1940
+ * its own definition) and the Agent's state.
1941
+ */
1872
1942
  export const TriggerViewSchema = z
1873
1943
  .object({
1874
1944
  id: z.string(),
1875
1945
  kind: z.enum(TRIGGER_KINDS),
1946
+ origin: z.enum(TRIGGER_ORIGINS),
1947
+ /** The title an agent gave a trigger it made; null for a manifest's. */
1948
+ title: z.string().nullable(),
1949
+ /** The session whose agent made it; null for a manifest's. */
1950
+ createdSessionId: z.string().nullable(),
1876
1951
  status: z.enum(TRIGGER_STATUSES),
1952
+ /** `manual`, `new` for one an upgrade added, `undeclared` for an agent's while the version lacks `engine.triggers`. */
1877
1953
  pausedReason: z.string().nullable(),
1878
1954
  schedule: z.string().optional(),
1879
1955
  timezone: z.string().optional(),
@@ -1890,9 +1966,73 @@ export const TriggerViewSchema = z
1890
1966
  webhookUrl: z.string().optional(),
1891
1967
  /** Whether a webhook trigger has a signing secret (`POST .../secret` makes one). */
1892
1968
  secretSet: z.boolean().optional(),
1969
+ /** What each run sends as its message: the definition's prompt. */
1970
+ prompt: z.string().optional(),
1893
1971
  })
1894
1972
  .strict();
1895
1973
  export const TriggerListSchema = z.object({ triggers: z.array(TriggerViewSchema) }).strict();
1974
+ /** `in` of the `triggers` tool (D83): a delay in minutes, hours or days, such as `30m`, `2h`, `1d`. */
1975
+ export const TRIGGER_DELAY_PATTERN = /^[1-9][0-9]*(m|h|d)$/;
1976
+ /** The longest title an agent gives a trigger it makes. */
1977
+ export const TRIGGER_TITLE_MAX = 80;
1978
+ /** Where an agent-made trigger runs: the calling session (`this`), or a session of its own (`own`). */
1979
+ export const TRIGGER_TOOL_SESSIONS = ["this", "own"];
1980
+ const triggerCreateSchema = z
1981
+ .strictObject({
1982
+ command: z.literal("create"),
1983
+ id: TriggerIdSchema,
1984
+ title: z.string().min(1).max(TRIGGER_TITLE_MAX).optional(),
1985
+ schedule: TriggerSchema.shape.schedule,
1986
+ timezone: z.string().min(1).optional(),
1987
+ at: TriggerSchema.shape.at,
1988
+ in: z.string().regex(TRIGGER_DELAY_PATTERN, { message: "in is a delay such as 30m, 2h or 1d" }).optional(),
1989
+ session: z.enum(TRIGGER_TOOL_SESSIONS),
1990
+ prompt: z.string().min(1),
1991
+ })
1992
+ .superRefine((input, ctx) => {
1993
+ if ([input.schedule, input.at, input.in].filter((value) => value !== undefined).length !== 1)
1994
+ ctx.addIssue({ code: "custom", message: "Give exactly one of schedule, at or in" });
1995
+ if (input.timezone !== undefined && input.schedule === undefined)
1996
+ ctx.addIssue({ code: "custom", path: ["timezone"], message: "timezone goes with schedule" });
1997
+ });
1998
+ /**
1999
+ * A call of the `triggers` tool (D83), which the Runtime serves for an agent whose version
2000
+ * declares `engine.triggers`: `list` the triggers the calling session made; `create` one (or
2001
+ * replace the session's own with the same `id`) with exactly one of `schedule` (with `timezone`),
2002
+ * `at` or `in`, the `session` it runs in and its `prompt`; `delete` one by `id`.
2003
+ */
2004
+ export const TriggerToolInputSchema = z.discriminatedUnion("command", [
2005
+ z.strictObject({ command: z.literal("list") }),
2006
+ triggerCreateSchema,
2007
+ z.strictObject({ command: z.literal("delete"), id: TriggerIdSchema }),
2008
+ ]);
2009
+ /** One trigger as the `triggers` tool lists it. */
2010
+ export const TriggerToolItemSchema = z
2011
+ .strictObject({
2012
+ id: z.string(),
2013
+ title: z.string().nullable(),
2014
+ status: z.enum(TRIGGER_STATUSES),
2015
+ schedule: z.string().optional(),
2016
+ timezone: z.string().optional(),
2017
+ at: z.string().optional(),
2018
+ /** The session it runs in: the calling session's id, or its own (`<session>_t_<id>`). */
2019
+ session: z.string(),
2020
+ nextRunAt: z.string().nullable(),
2021
+ prompt: z.string(),
2022
+ });
2023
+ /** What a `triggers` call answers: the trigger made, the list, or the one deleted. */
2024
+ export const TriggerToolOutputSchema = z.union([
2025
+ z.strictObject({
2026
+ id: z.string(),
2027
+ status: z.enum(TRIGGER_STATUSES),
2028
+ nextRunAt: z.string().nullable(),
2029
+ session: z.string(),
2030
+ /** The Runtime's clock when it answered, so the model knows the time (ADR-106). */
2031
+ now: z.string().optional(),
2032
+ }),
2033
+ z.strictObject({ triggers: z.array(TriggerToolItemSchema), now: z.string().optional() }),
2034
+ z.strictObject({ id: z.string(), deleted: z.literal(true) }),
2035
+ ]);
1896
2036
  /**
1897
2037
  * What a run came to: `started` a turn, `queued` a message behind a running turn,
1898
2038
  * `skipped` (nothing started: `overlap`, `rate_limited`, `paused`) or `failed` (`queue_full`,
@@ -1917,6 +2057,33 @@ export const TriggerRunSchema = z
1917
2057
  queuedMessageId: z.string().nullable(),
1918
2058
  })
1919
2059
  .strict();
2060
+ /**
2061
+ * One run on the Tenant's runs stream (D83, `GET /v1/runs/stream`): a run of any Agent's
2062
+ * triggers, as `TriggerRunSchema` has it, with its Agent and its trigger's origin and title. A
2063
+ * run may arrive twice (after a crash between append and mark); a reader drops a `runId` it has
2064
+ * seen.
2065
+ */
2066
+ export const TenantRunSchema = z
2067
+ .object({
2068
+ runId: z.string(),
2069
+ agentId: z.string(),
2070
+ triggerId: z.string(),
2071
+ kind: z.enum(TRIGGER_KINDS),
2072
+ status: z.enum(TRIGGER_RUN_STATUSES),
2073
+ reason: z.string().nullable(),
2074
+ sessionId: z.string().nullable(),
2075
+ turnId: z.string().nullable(),
2076
+ queuedMessageId: z.string().nullable(),
2077
+ dueAt: z.string(),
2078
+ firedAt: z.string(),
2079
+ late: z.boolean(),
2080
+ origin: z.enum(TRIGGER_ORIGINS),
2081
+ /** The title an agent gave the trigger; null for a manifest's or a wake. */
2082
+ title: z.string().nullable(),
2083
+ })
2084
+ .strict();
2085
+ /** One event of `GET /v1/runs/stream` (`event: run`): the run, and the cursor to resume after it. */
2086
+ export const TenantRunEventSchema = z.object({ cursor: z.string(), run: TenantRunSchema }).strict();
1920
2087
  /** `GET /v1/agents/{id}/runs`: runs, newest first. */
1921
2088
  export const TriggerRunPageSchema = z
1922
2089
  .object({ runs: z.array(TriggerRunSchema), nextCursor: z.string().nullable() })
@@ -4539,10 +4706,12 @@ export const ToolInputConditionSchema = z
4539
4706
  });
4540
4707
  /**
4541
4708
  * One rule of the Tenant's tool policy, applied at the Tool Gate to every MCP and HTTP tool call
4542
- * of every harness. A rule matches a call when every selector it sets matches: `tool` (the tool's
4543
- * identity: an MCP tool's own name on its server, or an HTTP tool's declared name; never the name
4544
- * a harness gave the model; `*` for any run of characters), `server` (an MCP server's name),
4545
- * `kind`, `agent` (the agent that calls it: the agent manifest's name, or the id of an agent used
4709
+ * of every harness, and to the operations the Runtime serves itself (`kind: "runtime"`, D83). A
4710
+ * rule matches a call when every selector it sets matches: `tool` (the tool's identity: an MCP
4711
+ * tool's own name on its server, an HTTP tool's declared name, or a runtime operation:
4712
+ * `triggers`, `memory`, `schedule_wake`; never the name a harness gave the model; `*` for any run
4713
+ * of characters), `server` (an MCP server's name), `kind` (a runtime operation matches only a rule
4714
+ * that names `kind: "runtime"`), `agent` (the agent that calls it: the agent manifest's name, or the id of an agent used
4546
4715
  * as a tool or of a flow's agent; never an Agent's id; the session's root agent's name matches its
4547
4716
  * subagents' calls too, those of the agents it uses as tools) and `when` (fields of the input, by
4548
4717
  * dotted path). The strictest matching rule decides: `deny` refuses the call before it is sent,
@@ -4565,7 +4734,10 @@ export const ToolRuleSchema = z
4565
4734
  description: "The tool's identity: an MCP tool's own name on its `server`, or an HTTP tool's declared name, never the name the model calls it by. `*` matches any run of characters; a name with `__` in it is refused",
4566
4735
  }),
4567
4736
  server: z.string().min(1).optional().meta({ description: "An MCP server's name; `*` matches any run of characters" }),
4568
- kind: z.enum(["mcp", "http"]).optional(),
4737
+ kind: z
4738
+ .enum(["mcp", "http", "runtime"])
4739
+ .optional()
4740
+ .meta({ description: "mcp, http, or runtime: an operation the Runtime serves itself (triggers, memory, schedule_wake), which only a rule naming it matches" }),
4569
4741
  agent: z
4570
4742
  .string()
4571
4743
  .min(1)
@@ -4582,6 +4754,8 @@ export const ToolRuleSchema = z
4582
4754
  })
4583
4755
  .strict()
4584
4756
  .superRefine((rule, ctx) => {
4757
+ if (rule.kind === "runtime" && rule.server !== undefined)
4758
+ ctx.addIssue({ code: "custom", path: ["server"], message: "A runtime operation has no server: leave server out of a rule of kind runtime" });
4585
4759
  if (rule.tool !== undefined && rule.tool.includes("__"))
4586
4760
  ctx.addIssue({
4587
4761
  code: "custom",
@@ -1,3 +1,4 @@
1
+ import { runtimeToolOf } from "../plugins/index.js";
1
2
  import { canonical } from "../utils/canonical.js";
2
3
  function same(a, b) {
3
4
  return canonical(a) === canonical(b);
@@ -120,7 +121,12 @@ export function withoutTools(manifest, names) {
120
121
  return same(next, manifest) ? manifest : next;
121
122
  }
122
123
  function narrowAgent(agent, removed, root) {
123
- const { tools: _tools, mcpServers: _servers, ...rest } = agent;
124
+ 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
+ const engine = agent.engine?.plugins !== undefined && offPlugin.size > 0
128
+ ? { ...agent.engine, plugins: agent.engine.plugins.map((plugin) => ({ ...plugin, tools: plugin.tools.filter((tool) => !offPlugin.has(tool)) })) }
129
+ : agent.engine;
124
130
  const tools = agent.tools
125
131
  ?.filter((tool) => !removed.has(tool.name))
126
132
  .map((tool) => {
@@ -134,6 +140,7 @@ function narrowAgent(agent, removed, root) {
134
140
  ...rest,
135
141
  ...(tools === undefined ? {} : { tools }),
136
142
  ...(servers === undefined ? {} : { mcpServers: servers }),
143
+ ...(engine === undefined ? {} : { engine }),
137
144
  };
138
145
  }
139
146
  function narrowServer(server, removed) {
@@ -31,6 +31,8 @@ export declare const OUTPUTS_TEXT = "Files you write under /workspace/outputs re
31
31
  export declare const ARTIFACTS_READ_TEXT: string;
32
32
  /** `wake`. */
33
33
  export declare const WAKE_TEXT = "You can book this session's next turn with schedule_wake, to check on something later or keep a routine going. Booking again replaces the booking you have.";
34
+ /** `triggers` (D83): what the `triggers` tool is for, and where a trigger's runs go. */
35
+ export declare const TRIGGERS_TEXT: string;
34
36
  /** `plan`. */
35
37
  export declare const PLAN_TEXT = "For work of several steps, keep your plan with update_plan: set it when you start, and call it again, with the whole plan, as each step starts, finishes or is blocked.";
36
38
  /** `connection`. */
@@ -27,6 +27,7 @@ export const ENGINE_BLOCK_VERSIONS = Object.freeze({
27
27
  outputs: 1,
28
28
  artifacts_read: 1,
29
29
  wake: 1,
30
+ triggers: 1,
30
31
  memory: 1,
31
32
  plan: 1,
32
33
  connection: 1,
@@ -68,6 +69,10 @@ export const ARTIFACTS_READ_TEXT = "A tool result too large to show is saved as
68
69
  'Files from earlier turns appear as lines like [Uploaded artifact "name" · <artifactId> v<version> · read_artifact to view]: call read_artifact with that artifactId and version only when you need the file again.';
69
70
  /** `wake`. */
70
71
  export const WAKE_TEXT = "You can book this session's next turn with schedule_wake, to check on something later or keep a routine going. Booking again replaces the booking you have.";
72
+ /** `triggers` (D83): what the `triggers` tool is for, and where a trigger's runs go. */
73
+ export const TRIGGERS_TEXT = "You can set up triggers with the triggers tool, so the work goes on when nobody is here: a schedule (five-field cron, in a time zone), one time (at), or a delay (in, such as 30m, 2h or 1d), each with the prompt that will be your message when it runs. " +
74
+ "session: this runs it here, as a follow-up in this conversation; session: own runs it in a session of its own, kept across its runs. " +
75
+ "Use list to read back the triggers this session made, create with an id it already has to change one, and delete to remove one. A turn a trigger started can't create triggers.";
71
76
  /** `plan`. */
72
77
  export const PLAN_TEXT = "For work of several steps, keep your plan with update_plan: set it when you start, and call it again, with the whole plan, as each step starts, finishes or is blocked.";
73
78
  /** `connection`. */
@@ -126,6 +131,8 @@ function templateOf(name) {
126
131
  return ARTIFACTS_READ_TEXT;
127
132
  case "wake":
128
133
  return WAKE_TEXT;
134
+ case "triggers":
135
+ return TRIGGERS_TEXT;
129
136
  case "memory":
130
137
  return [memoryRules(true), memoryRules(true, false), memoryRules(false)].join("\n\n");
131
138
  case "plan":
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import type { AgentManifestV8 } from "../contracts.js";
8
8
  /** The engine features, in the order the harness adds them. */
9
- export declare const ENGINE_FEATURES: readonly ["skills", "sandbox", "artifacts.save", "outputs", "artifacts.read", "selfWake", "memory", "plan", "connections", "toolSearch"];
9
+ export declare const ENGINE_FEATURES: readonly ["skills", "sandbox", "artifacts.save", "outputs", "artifacts.read", "selfWake", "triggers", "memory", "plan", "connections", "toolSearch"];
10
10
  export type EngineFeature = (typeof ENGINE_FEATURES)[number];
11
11
  /** One feature of one agent: whether it is on, what declares it, and what it adds. */
12
12
  export interface ExplainedFeature {
@@ -1,7 +1,8 @@
1
1
  import { SANDBOX_TOOL_NAMES } from "../utils/sandbox.js";
2
2
  import { ENGINE_BLOCK_VERSIONS } from "./blocks.js";
3
3
  import { previewTurn } from "./preview.js";
4
- import { LOAD_SKILL_TOOL, MEMORY_TOOL, READ_SKILL_RESOURCE_TOOL, REQUEST_CONNECTION_TOOL, SCHEDULE_WAKE_TOOL, TOOL_CALL_TOOL, TOOL_SEARCH_TOOL, UPDATE_PLAN_TOOL, } from "./tools.js";
4
+ import { LOAD_SKILL_TOOL, MEMORY_TOOL, READ_SKILL_RESOURCE_TOOL, REQUEST_CONNECTION_TOOL, SCHEDULE_WAKE_TOOL, TOOL_CALL_TOOL, TRIGGERS_TOOL, TOOL_SEARCH_TOOL, UPDATE_PLAN_TOOL, ASK_TOOL, } from "./tools.js";
5
+ import { runtimeToolOf } from "../plugins/index.js";
5
6
  import { READ_ARTIFACT_TOOL, SAVE_ARTIFACT_TOOL } from "../utils/runtime-tools.js";
6
7
  import { loopManifestOf } from "../definition/sections.js";
7
8
  /** The engine features, in the order the harness adds them. */
@@ -12,6 +13,7 @@ export const ENGINE_FEATURES = [
12
13
  "outputs",
13
14
  "artifacts.read",
14
15
  "selfWake",
16
+ "triggers",
15
17
  "memory",
16
18
  "plan",
17
19
  "connections",
@@ -24,11 +26,23 @@ const TOOLS = {
24
26
  outputs: [],
25
27
  "artifacts.read": [READ_ARTIFACT_TOOL],
26
28
  selfWake: [SCHEDULE_WAKE_TOOL],
29
+ triggers: [TRIGGERS_TOOL],
27
30
  memory: [MEMORY_TOOL],
28
31
  plan: [UPDATE_PLAN_TOOL],
29
- connections: [REQUEST_CONNECTION_TOOL],
32
+ connections: [REQUEST_CONNECTION_TOOL, ASK_TOOL],
30
33
  toolSearch: [TOOL_SEARCH_TOOL, TOOL_CALL_TOOL],
31
34
  };
35
+ /** The Runtime plugin that declares each feature in an `agent-folder/3` folder (ADR-106). */
36
+ const PLUGIN_OF = {
37
+ sandbox: "nylorun-sandbox",
38
+ "artifacts.save": "nylorun-artifacts",
39
+ "artifacts.read": "nylorun-artifacts",
40
+ selfWake: "nylorun-triggers",
41
+ triggers: "nylorun-triggers",
42
+ memory: "nylorun-memory",
43
+ plan: "nylorun-plan",
44
+ connections: "nylorun-interactions",
45
+ };
32
46
  const BLOCKS = {
33
47
  skills: ["skills", "skill_folder"],
34
48
  sandbox: ["sandbox"],
@@ -36,6 +50,7 @@ const BLOCKS = {
36
50
  outputs: ["outputs"],
37
51
  "artifacts.read": ["artifacts_read"],
38
52
  selfWake: ["wake"],
53
+ triggers: ["triggers"],
39
54
  memory: ["memory"],
40
55
  plan: ["plan"],
41
56
  connections: ["connection"],
@@ -44,6 +59,9 @@ const BLOCKS = {
44
59
  function explainOne(id, preview, facts) {
45
60
  const declared = preview.features.declared;
46
61
  const by = (feature) => {
62
+ // agent-folder/3: the plugin that brings it (ADR-106), or skills/ and the plugins' skills.
63
+ if (facts.plugins)
64
+ return PLUGIN_OF[feature] ?? (feature === "skills" ? "skills/ and the plugins' skills" : `engine.${feature}`);
47
65
  switch (feature) {
48
66
  case "skills":
49
67
  return "skills/";
@@ -55,12 +73,15 @@ function explainOne(id, preview, facts) {
55
73
  return "loop.connections";
56
74
  case "selfWake":
57
75
  return "runtime.selfWake";
76
+ case "triggers":
77
+ return "engine.triggers";
58
78
  default:
59
79
  return declared ? `engine.${feature}` : "by default";
60
80
  }
61
81
  };
62
82
  const blocks = new Set(preview.blocks.map((block) => block.name));
63
- const tools = new Set(preview.engineTools);
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));
64
85
  const features = ENGINE_FEATURES.map((feature) => {
65
86
  const added = TOOLS[feature].filter((name) => tools.has(name));
66
87
  const text = BLOCKS[feature].filter((name) => blocks.has(name)).map((name) => `${name}@${ENGINE_BLOCK_VERSIONS[name]}`);
@@ -100,9 +121,10 @@ export function explainEngine(manifest) {
100
121
  const preview = previewTurn(manifest);
101
122
  const loop = loopManifestOf(manifest);
102
123
  const mcpOf = (agent) => Object.keys(agent.mcpServers ?? {}).length > 0;
103
- const root = explainOne(manifest.name, preview, { root: true, pinned: preview.pinned.length > 0, mcp: mcpOf(loop) });
124
+ const plugins = manifest.harness.engine?.plugins !== undefined;
125
+ const root = explainOne(manifest.name, preview, { root: true, pinned: preview.pinned.length > 0, mcp: mcpOf(loop), plugins });
104
126
  const subagents = (loop.tools ?? []).flatMap((tool) => tool.agent && !("kind" in tool.agent) && preview.agents[tool.agent.id]
105
- ? [explainOne(tool.agent.id, preview.agents[tool.agent.id], { root: false, pinned: false, mcp: mcpOf(tool.agent) })]
127
+ ? [explainOne(tool.agent.id, preview.agents[tool.agent.id], { root: false, pinned: false, mcp: mcpOf(tool.agent), plugins })]
106
128
  : []);
107
129
  return [root, ...subagents];
108
130
  }
@@ -12,3 +12,4 @@ export * from "./mcp.js";
12
12
  export * from "./projection.js";
13
13
  export * from "./preview.js";
14
14
  export * from "./explain.js";
15
+ export * from "../plugins/index.js";
@@ -12,3 +12,4 @@ export * from "./mcp.js";
12
12
  export * from "./projection.js";
13
13
  export * from "./preview.js";
14
14
  export * from "./explain.js";
15
+ export * from "../plugins/index.js";
@@ -5,7 +5,7 @@
5
5
  * block's wording (`harness.engine.instructions.<block>`). Kept apart from the blocks' text so
6
6
  * the manifest schemas can name them without importing it.
7
7
  */
8
- export declare const ENGINE_BLOCK_NAMES: readonly ["skills", "sandbox", "skill_folder", "artifacts_save", "outputs", "artifacts_read", "wake", "memory", "plan", "connection", "tool_search"];
8
+ export declare const ENGINE_BLOCK_NAMES: readonly ["skills", "sandbox", "skill_folder", "artifacts_save", "outputs", "artifacts_read", "wake", "triggers", "memory", "plan", "connection", "tool_search"];
9
9
  export type EngineBlockName = (typeof ENGINE_BLOCK_NAMES)[number];
10
10
  export declare function isEngineBlockName(name: string): name is EngineBlockName;
11
11
  /** The folder format that declares every engine feature it uses. */
@@ -13,6 +13,7 @@ export const ENGINE_BLOCK_NAMES = Object.freeze([
13
13
  "outputs",
14
14
  "artifacts_read",
15
15
  "wake",
16
+ "triggers",
16
17
  "memory",
17
18
  "plan",
18
19
  "connection",
@@ -43,10 +43,16 @@ export interface PreviewTurnOptions {
43
43
  readonly model?: Pick<ModelDescriptor, "contextWindow">;
44
44
  /** The version sets `runtime.selfWake`. Default: an agent manifest v8's. */
45
45
  readonly selfWake?: boolean;
46
+ /**
47
+ * The version declares `harness.engine.triggers` (D83): the root agent gets the `triggers` tool
48
+ * and its text. Default: an agent manifest v8's.
49
+ */
50
+ readonly triggers?: boolean;
46
51
  /** The harness's loop settings (`harness.loop`): `plan`, `connections`. Default: an agent manifest v8's. */
47
52
  readonly loop?: {
48
53
  readonly plan?: boolean;
49
54
  readonly connections?: boolean;
55
+ readonly ask?: boolean;
50
56
  };
51
57
  /** The harness's configuration of our engine's tools. Default: the harness's defaults. */
52
58
  readonly limits?: Partial<EngineToolLimits>;
@@ -63,6 +63,8 @@ export function previewTurn(manifest, options = {}) {
63
63
  const settings = (harness?.loop ?? {});
64
64
  const plan = options.loop?.plan ?? settings.plan === true;
65
65
  const connections = options.loop?.connections ?? settings.connections === true;
66
+ const triggers = options.triggers ?? harness?.engine?.triggers === true;
67
+ const ask = options.loop?.ask ?? settings.ask === true;
66
68
  const limits = { ...DEFAULT_ENGINE_TOOL_LIMITS, ...options.limits };
67
69
  const memoryOf = (agent) => memory && {
68
70
  access: memory.access ?? "read_write",
@@ -70,7 +72,7 @@ export function previewTurn(manifest, options = {}) {
70
72
  root: agent.id === loop.id,
71
73
  index: memory.index !== false,
72
74
  };
73
- const projection = (agent) => engineProjection(agent, runsOn, limits, memoryOf(agent), plan && agent.id === loop.id, connections && agent.id === loop.id);
75
+ const projection = (agent) => engineProjection(agent, runsOn, limits, memoryOf(agent), plan && agent.id === loop.id, connections && agent.id === loop.id, triggers && agent.id === loop.id, ask && agent.id === loop.id);
74
76
  const mcp = mcpToolSet(options.mcpFacts, loop, {
75
77
  config: mcpToolConfigOf(options.mcpTools),
76
78
  ...(options.model ? { model: options.model } : {}),
@@ -6,10 +6,10 @@
6
6
  * One order keeps the prompt's prefix stable:
7
7
  *
8
8
  * - text: `skills` (the usage and the catalog); `sandbox`; `skill_folder`; `artifacts_save` and
9
- * `outputs`; `artifacts_read`; `wake`; `memory`, then the agent's memory instructions; `plan`;
10
- * `connection`;
9
+ * `outputs`; `artifacts_read`; `wake`; `triggers`; `memory`, then the agent's memory
10
+ * instructions; `plan`; `connection`;
11
11
  * - tools: the sandbox tools; the skill tools; `save_artifact`; `read_artifact`; `schedule_wake`;
12
- * `memory`; `update_plan`; `request_connection`.
12
+ * `triggers`; `memory`; `update_plan`; `request_connection`.
13
13
  *
14
14
  * They come after the agent's own and before the session's MCP tools (`mcpToolSet`), and are
15
15
  * not hashed.
@@ -55,7 +55,11 @@ export interface EngineProjection {
55
55
  * with its memory (`turn.start.memory`). `memory.root` is false for an agent used as a tool,
56
56
  * which may only view memory. `plan` offers `update_plan`: true for the session's root agent when
57
57
  * the version sets `harness.loop.plan`; `connections` offers `request_connection` alike
58
- * (`harness.loop.connections`). An agent whose own tools name one of them keeps its own. What the
59
- * agent declares (`agent.engine`) decides the rest; a block it replaces is in its words.
58
+ * (`harness.loop.connections`). An agent whose own tools name one of them keeps its own.
59
+ * `triggers` offers the `triggers` tool and its text (D83): true for the session's root agent when
60
+ * the version declares `harness.engine.triggers` (`turn.start.agent.triggers`). What the agent
61
+ * declares (`agent.engine`) decides the rest; a block it replaces is in its words.
60
62
  */
61
- export declare function engineProjection(agent: Pick<AgentManifest, "skills" | "tools" | "engine">, runsOn: Pick<TurnAgent, "sandbox" | "selfWake"> | undefined, options: Pick<EngineToolLimits, "artifactPageBytes" | "sandboxTools">, memory?: EngineMemory, plan?: boolean, connections?: boolean): EngineProjection;
63
+ export declare function engineProjection(agent: Pick<AgentManifest, "skills" | "tools" | "engine">, runsOn: Pick<TurnAgent, "sandbox" | "selfWake"> | undefined, options: Pick<EngineToolLimits, "artifactPageBytes" | "sandboxTools">, memory?: EngineMemory, plan?: boolean, connections?: boolean, triggers?: boolean, ask?: boolean): EngineProjection;
64
+ /** The first line of server `nylorun`'s text (ADR-106). */
65
+ export declare const RUNTIME_SERVER_HEADING = "# Server nylorun\nThe Runtime's own tools, from the plugins this agent declares. Their names begin with nylorun__.";