@nylorun/core 0.34.0-beta → 0.35.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/dist/contracts.js CHANGED
@@ -260,6 +260,10 @@ 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()
@@ -742,6 +746,21 @@ export const EnvironmentLimitsSchema = z
742
746
  })
743
747
  .strict()
744
748
  .optional(),
749
+ /**
750
+ * Its triggers (D83), within the Tenant's Runtime limits `triggersPerAgent`,
751
+ * `triggerMinIntervalMs` and `triggerRunsPerHour`: lowering one deletes nothing.
752
+ */
753
+ triggers: z
754
+ .object({
755
+ /** The most triggers its agents may make with the `triggers` tool; at most `triggersPerAgent`. */
756
+ count: z.number().int().positive().optional(),
757
+ /** The shortest gap between two runs of a schedule its agents make; at least `triggerMinIntervalMs`. */
758
+ minIntervalMs: z.number().int().positive().optional(),
759
+ /** The most runs its triggers start or queue in any hour; at most `triggerRunsPerHour`. */
760
+ runsPerHour: z.number().int().positive().optional(),
761
+ })
762
+ .strict()
763
+ .optional(),
745
764
  })
746
765
  .strict();
747
766
  /**
@@ -1137,6 +1156,10 @@ export const AGENT_EVENT_TYPES = [
1137
1156
  "agent.trigger_paused",
1138
1157
  "agent.trigger_resumed",
1139
1158
  "agent.trigger_secret_rotated",
1159
+ // Triggers an agent made with the triggers tool (D83), and one deleted by an agent or a person.
1160
+ "agent.trigger_created",
1161
+ "agent.trigger_updated",
1162
+ "agent.trigger_deleted",
1140
1163
  // Memory (track T5, D72): a turn changed the Agent's memories.
1141
1164
  "agent.memory_updated",
1142
1165
  ];
@@ -1231,6 +1254,35 @@ export const AGENT_EVENT_PAYLOADS = {
1231
1254
  "agent.trigger_resumed": z.object({ triggerId: z.string() }).passthrough(),
1232
1255
  /** A webhook trigger's signing secret was made or replaced; the one before stopped working. */
1233
1256
  "agent.trigger_secret_rotated": z.object({ triggerId: z.string() }).passthrough(),
1257
+ /**
1258
+ * An agent made a trigger with the `triggers` tool (D83), or replaced one with the same id
1259
+ * (`agent.trigger_updated`): the session whose agent made it (`sessionId`), the session it runs
1260
+ * in (`session`), its title and its next run.
1261
+ */
1262
+ "agent.trigger_created": z
1263
+ .object({
1264
+ triggerId: z.string(),
1265
+ kind: z.enum(["schedule", "at"]),
1266
+ sessionId: z.string(),
1267
+ session: z.string(),
1268
+ title: z.string().optional(),
1269
+ nextRunAt: z.string().nullable(),
1270
+ })
1271
+ .passthrough(),
1272
+ "agent.trigger_updated": z
1273
+ .object({
1274
+ triggerId: z.string(),
1275
+ kind: z.enum(["schedule", "at"]),
1276
+ sessionId: z.string(),
1277
+ session: z.string(),
1278
+ title: z.string().optional(),
1279
+ nextRunAt: z.string().nullable(),
1280
+ })
1281
+ .passthrough(),
1282
+ /** A trigger an agent made was deleted: by an agent of `sessionId`, or over the API (`principal`). */
1283
+ "agent.trigger_deleted": z
1284
+ .object({ triggerId: z.string(), sessionId: z.string().optional(), principal: z.string().optional() })
1285
+ .passthrough(),
1234
1286
  /** A turn changed the Agent's memories (`memory.updated` in its session): which, and how. */
1235
1287
  "agent.memory_updated": MemoryUpdatedPayloadSchema.extend({ sessionId: z.string(), turnId: z.string() }),
1236
1288
  };
@@ -1868,12 +1920,27 @@ export function triggerKindOf(trigger) {
1868
1920
  * `manual`, or `new` for one an upgrade added), `completed` is an `at` that ran.
1869
1921
  */
1870
1922
  export const TRIGGER_STATUSES = ["active", "paused", "completed"];
1871
- /** `GET /v1/agents/{id}/triggers`: one trigger, from its manifest entry and the Agent's state. */
1923
+ /**
1924
+ * Where a trigger's definition comes from (D83): `manifest` (the version's `runtime.triggers`),
1925
+ * `agent` (made by an agent of the Agent's sessions with the `triggers` tool, kept by the Agent)
1926
+ * or `wake` (a session's booked wake, never listed).
1927
+ */
1928
+ export const TRIGGER_ORIGINS = ["manifest", "agent", "wake"];
1929
+ /**
1930
+ * `GET /v1/agents/{id}/triggers`: one trigger, from its manifest entry (or, for one an agent made,
1931
+ * its own definition) and the Agent's state.
1932
+ */
1872
1933
  export const TriggerViewSchema = z
1873
1934
  .object({
1874
1935
  id: z.string(),
1875
1936
  kind: z.enum(TRIGGER_KINDS),
1937
+ origin: z.enum(TRIGGER_ORIGINS),
1938
+ /** The title an agent gave a trigger it made; null for a manifest's. */
1939
+ title: z.string().nullable(),
1940
+ /** The session whose agent made it; null for a manifest's. */
1941
+ createdSessionId: z.string().nullable(),
1876
1942
  status: z.enum(TRIGGER_STATUSES),
1943
+ /** `manual`, `new` for one an upgrade added, `undeclared` for an agent's while the version lacks `engine.triggers`. */
1877
1944
  pausedReason: z.string().nullable(),
1878
1945
  schedule: z.string().optional(),
1879
1946
  timezone: z.string().optional(),
@@ -1890,9 +1957,66 @@ export const TriggerViewSchema = z
1890
1957
  webhookUrl: z.string().optional(),
1891
1958
  /** Whether a webhook trigger has a signing secret (`POST .../secret` makes one). */
1892
1959
  secretSet: z.boolean().optional(),
1960
+ /** What each run sends as its message: the definition's prompt. */
1961
+ prompt: z.string().optional(),
1893
1962
  })
1894
1963
  .strict();
1895
1964
  export const TriggerListSchema = z.object({ triggers: z.array(TriggerViewSchema) }).strict();
1965
+ /** `in` of the `triggers` tool (D83): a delay in minutes, hours or days, such as `30m`, `2h`, `1d`. */
1966
+ export const TRIGGER_DELAY_PATTERN = /^[1-9][0-9]*(m|h|d)$/;
1967
+ /** The longest title an agent gives a trigger it makes. */
1968
+ export const TRIGGER_TITLE_MAX = 80;
1969
+ /** Where an agent-made trigger runs: the calling session (`this`), or a session of its own (`own`). */
1970
+ export const TRIGGER_TOOL_SESSIONS = ["this", "own"];
1971
+ const triggerCreateSchema = z
1972
+ .strictObject({
1973
+ command: z.literal("create"),
1974
+ id: TriggerIdSchema,
1975
+ title: z.string().min(1).max(TRIGGER_TITLE_MAX).optional(),
1976
+ schedule: TriggerSchema.shape.schedule,
1977
+ timezone: z.string().min(1).optional(),
1978
+ at: TriggerSchema.shape.at,
1979
+ in: z.string().regex(TRIGGER_DELAY_PATTERN, { message: "in is a delay such as 30m, 2h or 1d" }).optional(),
1980
+ session: z.enum(TRIGGER_TOOL_SESSIONS),
1981
+ prompt: z.string().min(1),
1982
+ })
1983
+ .superRefine((input, ctx) => {
1984
+ if ([input.schedule, input.at, input.in].filter((value) => value !== undefined).length !== 1)
1985
+ ctx.addIssue({ code: "custom", message: "Give exactly one of schedule, at or in" });
1986
+ if (input.timezone !== undefined && input.schedule === undefined)
1987
+ ctx.addIssue({ code: "custom", path: ["timezone"], message: "timezone goes with schedule" });
1988
+ });
1989
+ /**
1990
+ * A call of the `triggers` tool (D83), which the Runtime serves for an agent whose version
1991
+ * declares `engine.triggers`: `list` the triggers the calling session made; `create` one (or
1992
+ * replace the session's own with the same `id`) with exactly one of `schedule` (with `timezone`),
1993
+ * `at` or `in`, the `session` it runs in and its `prompt`; `delete` one by `id`.
1994
+ */
1995
+ export const TriggerToolInputSchema = z.discriminatedUnion("command", [
1996
+ z.strictObject({ command: z.literal("list") }),
1997
+ triggerCreateSchema,
1998
+ z.strictObject({ command: z.literal("delete"), id: TriggerIdSchema }),
1999
+ ]);
2000
+ /** One trigger as the `triggers` tool lists it. */
2001
+ export const TriggerToolItemSchema = z
2002
+ .strictObject({
2003
+ id: z.string(),
2004
+ title: z.string().nullable(),
2005
+ status: z.enum(TRIGGER_STATUSES),
2006
+ schedule: z.string().optional(),
2007
+ timezone: z.string().optional(),
2008
+ at: z.string().optional(),
2009
+ /** The session it runs in: the calling session's id, or its own (`<session>_t_<id>`). */
2010
+ session: z.string(),
2011
+ nextRunAt: z.string().nullable(),
2012
+ prompt: z.string(),
2013
+ });
2014
+ /** What a `triggers` call answers: the trigger made, the list, or the one deleted. */
2015
+ export const TriggerToolOutputSchema = z.union([
2016
+ z.strictObject({ id: z.string(), status: z.enum(TRIGGER_STATUSES), nextRunAt: z.string().nullable(), session: z.string() }),
2017
+ z.strictObject({ triggers: z.array(TriggerToolItemSchema) }),
2018
+ z.strictObject({ id: z.string(), deleted: z.literal(true) }),
2019
+ ]);
1896
2020
  /**
1897
2021
  * What a run came to: `started` a turn, `queued` a message behind a running turn,
1898
2022
  * `skipped` (nothing started: `overlap`, `rate_limited`, `paused`) or `failed` (`queue_full`,
@@ -1917,6 +2041,33 @@ export const TriggerRunSchema = z
1917
2041
  queuedMessageId: z.string().nullable(),
1918
2042
  })
1919
2043
  .strict();
2044
+ /**
2045
+ * One run on the Tenant's runs stream (D83, `GET /v1/runs/stream`): a run of any Agent's
2046
+ * triggers, as `TriggerRunSchema` has it, with its Agent and its trigger's origin and title. A
2047
+ * run may arrive twice (after a crash between append and mark); a reader drops a `runId` it has
2048
+ * seen.
2049
+ */
2050
+ export const TenantRunSchema = z
2051
+ .object({
2052
+ runId: z.string(),
2053
+ agentId: z.string(),
2054
+ triggerId: z.string(),
2055
+ kind: z.enum(TRIGGER_KINDS),
2056
+ status: z.enum(TRIGGER_RUN_STATUSES),
2057
+ reason: z.string().nullable(),
2058
+ sessionId: z.string().nullable(),
2059
+ turnId: z.string().nullable(),
2060
+ queuedMessageId: z.string().nullable(),
2061
+ dueAt: z.string(),
2062
+ firedAt: z.string(),
2063
+ late: z.boolean(),
2064
+ origin: z.enum(TRIGGER_ORIGINS),
2065
+ /** The title an agent gave the trigger; null for a manifest's or a wake. */
2066
+ title: z.string().nullable(),
2067
+ })
2068
+ .strict();
2069
+ /** One event of `GET /v1/runs/stream` (`event: run`): the run, and the cursor to resume after it. */
2070
+ export const TenantRunEventSchema = z.object({ cursor: z.string(), run: TenantRunSchema }).strict();
1920
2071
  /** `GET /v1/agents/{id}/runs`: runs, newest first. */
1921
2072
  export const TriggerRunPageSchema = z
1922
2073
  .object({ runs: z.array(TriggerRunSchema), nextCursor: z.string().nullable() })
@@ -4539,10 +4690,12 @@ export const ToolInputConditionSchema = z
4539
4690
  });
4540
4691
  /**
4541
4692
  * 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
4693
+ * of every harness, and to the operations the Runtime serves itself (`kind: "runtime"`, D83). A
4694
+ * rule matches a call when every selector it sets matches: `tool` (the tool's identity: an MCP
4695
+ * tool's own name on its server, an HTTP tool's declared name, or a runtime operation:
4696
+ * `triggers`, `memory`, `schedule_wake`; never the name a harness gave the model; `*` for any run
4697
+ * of characters), `server` (an MCP server's name), `kind` (a runtime operation matches only a rule
4698
+ * that names `kind: "runtime"`), `agent` (the agent that calls it: the agent manifest's name, or the id of an agent used
4546
4699
  * as a tool or of a flow's agent; never an Agent's id; the session's root agent's name matches its
4547
4700
  * subagents' calls too, those of the agents it uses as tools) and `when` (fields of the input, by
4548
4701
  * dotted path). The strictest matching rule decides: `deny` refuses the call before it is sent,
@@ -4565,7 +4718,10 @@ export const ToolRuleSchema = z
4565
4718
  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
4719
  }),
4567
4720
  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(),
4721
+ kind: z
4722
+ .enum(["mcp", "http", "runtime"])
4723
+ .optional()
4724
+ .meta({ description: "mcp, http, or runtime: an operation the Runtime serves itself (triggers, memory, schedule_wake), which only a rule naming it matches" }),
4569
4725
  agent: z
4570
4726
  .string()
4571
4727
  .min(1)
@@ -4582,6 +4738,8 @@ export const ToolRuleSchema = z
4582
4738
  })
4583
4739
  .strict()
4584
4740
  .superRefine((rule, ctx) => {
4741
+ if (rule.kind === "runtime" && rule.server !== undefined)
4742
+ ctx.addIssue({ code: "custom", path: ["server"], message: "A runtime operation has no server: leave server out of a rule of kind runtime" });
4585
4743
  if (rule.tool !== undefined && rule.tool.includes("__"))
4586
4744
  ctx.addIssue({
4587
4745
  code: "custom",
@@ -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,7 @@
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, } from "./tools.js";
5
5
  import { READ_ARTIFACT_TOOL, SAVE_ARTIFACT_TOOL } from "../utils/runtime-tools.js";
6
6
  import { loopManifestOf } from "../definition/sections.js";
7
7
  /** The engine features, in the order the harness adds them. */
@@ -12,6 +12,7 @@ export const ENGINE_FEATURES = [
12
12
  "outputs",
13
13
  "artifacts.read",
14
14
  "selfWake",
15
+ "triggers",
15
16
  "memory",
16
17
  "plan",
17
18
  "connections",
@@ -24,6 +25,7 @@ const TOOLS = {
24
25
  outputs: [],
25
26
  "artifacts.read": [READ_ARTIFACT_TOOL],
26
27
  selfWake: [SCHEDULE_WAKE_TOOL],
28
+ triggers: [TRIGGERS_TOOL],
27
29
  memory: [MEMORY_TOOL],
28
30
  plan: [UPDATE_PLAN_TOOL],
29
31
  connections: [REQUEST_CONNECTION_TOOL],
@@ -36,6 +38,7 @@ const BLOCKS = {
36
38
  outputs: ["outputs"],
37
39
  "artifacts.read": ["artifacts_read"],
38
40
  selfWake: ["wake"],
41
+ triggers: ["triggers"],
39
42
  memory: ["memory"],
40
43
  plan: ["plan"],
41
44
  connections: ["connection"],
@@ -55,6 +58,8 @@ function explainOne(id, preview, facts) {
55
58
  return "loop.connections";
56
59
  case "selfWake":
57
60
  return "runtime.selfWake";
61
+ case "triggers":
62
+ return "engine.triggers";
58
63
  default:
59
64
  return declared ? `engine.${feature}` : "by default";
60
65
  }
@@ -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,6 +43,11 @@ 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;
@@ -63,6 +63,7 @@ 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;
66
67
  const limits = { ...DEFAULT_ENGINE_TOOL_LIMITS, ...options.limits };
67
68
  const memoryOf = (agent) => memory && {
68
69
  access: memory.access ?? "read_write",
@@ -70,7 +71,7 @@ export function previewTurn(manifest, options = {}) {
70
71
  root: agent.id === loop.id,
71
72
  index: memory.index !== false,
72
73
  };
73
- const projection = (agent) => engineProjection(agent, runsOn, limits, memoryOf(agent), plan && agent.id === loop.id, connections && agent.id === loop.id);
74
+ const projection = (agent) => engineProjection(agent, runsOn, limits, memoryOf(agent), plan && agent.id === loop.id, connections && agent.id === loop.id, triggers && agent.id === loop.id);
74
75
  const mcp = mcpToolSet(options.mcpFacts, loop, {
75
76
  config: mcpToolConfigOf(options.mcpTools),
76
77
  ...(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,9 @@ 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): EngineProjection;
@@ -1,6 +1,6 @@
1
- import { ARTIFACTS_READ_TEXT, ARTIFACTS_SAVE_TEXT, CONNECTION_TEXT, ENGINE_BLOCK_VERSIONS, MEMORY_DATA_RULE, MEMORY_READ_ONLY_DATA_RULE, OUTPUTS_AFTER_SAVE_TEXT, OUTPUTS_TEXT, PLAN_TEXT, SKILLS_USAGE, WAKE_TEXT, formatSkillCatalog, memoryRules, sandboxNote, skillFolderNote, } from "./blocks.js";
1
+ import { ARTIFACTS_READ_TEXT, ARTIFACTS_SAVE_TEXT, CONNECTION_TEXT, ENGINE_BLOCK_VERSIONS, MEMORY_DATA_RULE, MEMORY_READ_ONLY_DATA_RULE, OUTPUTS_AFTER_SAVE_TEXT, OUTPUTS_TEXT, PLAN_TEXT, SKILLS_USAGE, TRIGGERS_TEXT, WAKE_TEXT, formatSkillCatalog, memoryRules, sandboxNote, skillFolderNote, } from "./blocks.js";
2
2
  import { engineFeaturesOf } from "./features.js";
3
- import { DEFAULT_SANDBOX_TOOL_LIMITS, REQUEST_CONNECTION_TOOL, UPDATE_PLAN_TOOL, artifactTools, connectionToolOf, memoryToolOf, planToolOf, sandboxTools, skillTools, wakeToolOf, } from "./tools.js";
3
+ import { DEFAULT_SANDBOX_TOOL_LIMITS, REQUEST_CONNECTION_TOOL, TRIGGERS_TOOL, UPDATE_PLAN_TOOL, artifactTools, connectionToolOf, memoryToolOf, planToolOf, sandboxTools, skillTools, triggersToolOf, wakeToolOf, } from "./tools.js";
4
4
  /** The default of the harness's `artifactPageBytes` setting: one `read_artifact` page. */
5
5
  export const DEFAULT_ARTIFACT_PAGE_BYTES = 32 * 1024;
6
6
  /** The most bytes of one skill file the skill tools read into the model's context by default. */
@@ -16,10 +16,12 @@ export const DEFAULT_ENGINE_TOOL_LIMITS = Object.freeze({
16
16
  * with its memory (`turn.start.memory`). `memory.root` is false for an agent used as a tool,
17
17
  * which may only view memory. `plan` offers `update_plan`: true for the session's root agent when
18
18
  * the version sets `harness.loop.plan`; `connections` offers `request_connection` alike
19
- * (`harness.loop.connections`). An agent whose own tools name one of them keeps its own. What the
20
- * agent declares (`agent.engine`) decides the rest; a block it replaces is in its words.
19
+ * (`harness.loop.connections`). An agent whose own tools name one of them keeps its own.
20
+ * `triggers` offers the `triggers` tool and its text (D83): true for the session's root agent when
21
+ * the version declares `harness.engine.triggers` (`turn.start.agent.triggers`). What the agent
22
+ * declares (`agent.engine`) decides the rest; a block it replaces is in its words.
21
23
  */
22
- export function engineProjection(agent, runsOn, options, memory, plan = false, connections = false) {
24
+ export function engineProjection(agent, runsOn, options, memory, plan = false, connections = false, triggers = false) {
23
25
  const skills = Object.values(agent.skills ?? {});
24
26
  const workspace = runsOn?.sandbox?.workspace;
25
27
  const features = engineFeaturesOf(agent.engine, { computer: workspace !== undefined });
@@ -61,6 +63,13 @@ export function engineProjection(agent, runsOn, options, memory, plan = false, c
61
63
  use("wake");
62
64
  instructions.push(text("wake", WAKE_TEXT));
63
65
  }
66
+ // The triggers the agent sets up itself (D83): the root agent's, when the version declares them.
67
+ const own = (name) => (agent.tools ?? []).some((tool) => tool.name === name);
68
+ const triggering = triggers && !own(TRIGGERS_TOOL);
69
+ if (triggering) {
70
+ use("triggers");
71
+ instructions.push(text("triggers", TRIGGERS_TEXT));
72
+ }
64
73
  // The Agent's memory (track T5, D72).
65
74
  const writes = memory !== undefined && memory.root && memory.access === "read_write";
66
75
  if (memory) {
@@ -71,7 +80,6 @@ export function engineProjection(agent, runsOn, options, memory, plan = false, c
71
80
  instructions.push([rules, ...(memory.instructions ? [`Memory instructions for this agent:\n${memory.instructions}`] : [])].join("\n\n"));
72
81
  }
73
82
  // The agent's plan (A2A profile v2, `progress/v1`).
74
- const own = (name) => (agent.tools ?? []).some((tool) => tool.name === name);
75
83
  const planning = plan && !own(UPDATE_PLAN_TOOL);
76
84
  if (planning) {
77
85
  use("plan");
@@ -89,6 +97,7 @@ export function engineProjection(agent, runsOn, options, memory, plan = false, c
89
97
  ...skillTools(skills),
90
98
  ...artifactTools({ read: features.artifactsRead, save: features.artifactsSave, sandboxed }, { pageBytes: options.artifactPageBytes }),
91
99
  ...(wake ? [wakeToolOf()] : []),
100
+ ...(triggering ? [triggersToolOf()] : []),
92
101
  ...(memory ? [memoryToolOf(writes)] : []),
93
102
  ...(planning ? [planToolOf()] : []),
94
103
  ...(connecting ? [connectionToolOf()] : []),
@@ -81,6 +81,16 @@ export declare function memoryToolOf(writes: boolean): EngineTool;
81
81
  export declare const SCHEDULE_WAKE_TOOL = "schedule_wake";
82
82
  /** `schedule_wake` (track T4): a `runtime` effect. */
83
83
  export declare function wakeToolOf(): EngineTool;
84
+ /** The triggers tool's name (D83). */
85
+ export declare const TRIGGERS_TOOL = "triggers";
86
+ /** What serves a `triggers` call: the Runtime, in the call's own transaction. */
87
+ export declare const RUNTIME_TRIGGERS: EffectTarget;
88
+ /**
89
+ * `triggers` (D83): list, create and delete the triggers the calling session made, for an agent
90
+ * whose version declares `engine.triggers`; the root agent's only. A `runtime` effect, operation
91
+ * `triggers`; its input is `TriggerToolInputSchema`'s.
92
+ */
93
+ export declare function triggersToolOf(): EngineTool;
84
94
  /** The plan tool's name. */
85
95
  export declare const UPDATE_PLAN_TOOL = "update_plan";
86
96
  /** `update_plan` (A2A profile v2, `progress/v1`): runs in the harness. */
@@ -6,7 +6,7 @@
6
6
  * deliberately.
7
7
  */
8
8
  import { z } from "zod";
9
- import { ARTIFACT_NAME_MAX, PLAN_LIMITS, PLAN_STEP_STATES } from "../contracts.js";
9
+ import { ARTIFACT_NAME_MAX, PLAN_LIMITS, PLAN_STEP_STATES, TRIGGER_DELAY_PATTERN, TRIGGER_TITLE_MAX } from "../contracts.js";
10
10
  import { MEMORY_ROOT } from "../utils/memory.js";
11
11
  import { SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE } from "../utils/sandbox.js";
12
12
  import { SKILL_ENTRY } from "../utils/definition-files.js";
@@ -330,6 +330,54 @@ export function wakeToolOf() {
330
330
  target: RUNTIME_WAKE,
331
331
  };
332
332
  }
333
+ // --- triggers --------------------------------------------------------------------------------
334
+ /** The triggers tool's name (D83). */
335
+ export const TRIGGERS_TOOL = "triggers";
336
+ /** What serves a `triggers` call: the Runtime, in the call's own transaction. */
337
+ export const RUNTIME_TRIGGERS = Object.freeze({ kind: "runtime", operation: "triggers" });
338
+ /**
339
+ * `triggers` (D83): list, create and delete the triggers the calling session made, for an agent
340
+ * whose version declares `engine.triggers`; the root agent's only. A `runtime` effect, operation
341
+ * `triggers`; its input is `TriggerToolInputSchema`'s.
342
+ */
343
+ export function triggersToolOf() {
344
+ return {
345
+ name: TRIGGERS_TOOL,
346
+ description: [
347
+ "Set up work that runs later, when nobody may be here to ask: a trigger runs its prompt as your message, on a schedule, at a time or after a delay.",
348
+ "Commands:",
349
+ "- list: the triggers this session made, each with its id, title, status, when and next run.",
350
+ "- create: make a trigger, or replace the one this session made with the same id. Params: id, title (optional, a few words), exactly one of schedule (five cron fields: minute hour day-of-month month day-of-week, with an optional IANA timezone, default UTC), at (an RFC 3339 time with an offset) or in (a delay: 30m, 2h, 1d), session (this: run here, as a follow-up; own: run in a session of its own, kept across runs), and prompt (what to do then, in your own words).",
351
+ "- delete: remove a trigger this session made. Params: id.",
352
+ "Returns the trigger's id, status, next run and the session it runs in.",
353
+ ].join("\n"),
354
+ inputSchema: {
355
+ type: "object",
356
+ properties: {
357
+ command: { type: "string", enum: ["list", "create", "delete"], description: "The operation to perform." },
358
+ id: {
359
+ type: "string",
360
+ pattern: "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",
361
+ description: "create and delete: the trigger's id, such as daily-standup: 1-64 letters, digits, '.', '_' and '-'.",
362
+ },
363
+ title: { type: "string", minLength: 1, maxLength: TRIGGER_TITLE_MAX, description: "create only: a few words that name it." },
364
+ schedule: { type: "string", description: "create only: five cron fields, such as 0 9 * * 1-5 (weekdays at nine)." },
365
+ timezone: { type: "string", description: "create only, with schedule: an IANA time zone, such as Europe/Berlin; default UTC." },
366
+ at: { type: "string", description: "create only: one run at an RFC 3339 time with an offset, such as 2026-11-01T09:00:00+05:30." },
367
+ in: { type: "string", pattern: TRIGGER_DELAY_PATTERN.source, description: "create only: one run after a delay: 30m, 2h, 1d." },
368
+ session: {
369
+ type: "string",
370
+ enum: ["this", "own"],
371
+ description: "create only: this runs it in this session; own runs it in a session of its own, kept across its runs.",
372
+ },
373
+ prompt: { type: "string", minLength: 1, description: "create only: what to do then, in your own words: your message when it runs." },
374
+ },
375
+ required: ["command"],
376
+ additionalProperties: false,
377
+ },
378
+ target: RUNTIME_TRIGGERS,
379
+ };
380
+ }
333
381
  // --- update_plan -----------------------------------------------------------------------------
334
382
  /** The plan tool's name. */
335
383
  export const UPDATE_PLAN_TOOL = "update_plan";
@@ -72,7 +72,7 @@ export interface CompiledAgentFolder {
72
72
  */
73
73
  export declare const FOLDER_SCHEMAS = "https://docs.nylorun.com/schemas/agent-folder/v1/";
74
74
  export declare const SCHEMA_URLS: {
75
- readonly runtime: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/runtime.1.json", "https://docs.nylorun.com/schemas/agent-folder/v1/runtime.json", "https://docs.nylorun.com/schemas/runtime-manifest/v1.1.json", "https://docs.nylorun.com/schemas/runtime-manifest/v1.json"];
75
+ readonly runtime: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/runtime.2.json", "https://docs.nylorun.com/schemas/agent-folder/v1/runtime.1.json", "https://docs.nylorun.com/schemas/agent-folder/v1/runtime.json", "https://docs.nylorun.com/schemas/runtime-manifest/v1.2.json", "https://docs.nylorun.com/schemas/runtime-manifest/v1.1.json", "https://docs.nylorun.com/schemas/runtime-manifest/v1.json"];
76
76
  readonly tool: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/tool.json"];
77
77
  readonly mcp: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/mcp.json", "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json"];
78
78
  readonly flow: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/flow.json"];
@@ -42,8 +42,10 @@ const AGENT_PLUGINS_MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.sc
42
42
  export const FOLDER_SCHEMAS = "https://docs.nylorun.com/schemas/agent-folder/v1/";
43
43
  export const SCHEMA_URLS = {
44
44
  runtime: [
45
+ `${FOLDER_SCHEMAS}runtime.2.json`,
45
46
  `${FOLDER_SCHEMAS}runtime.1.json`,
46
47
  `${FOLDER_SCHEMAS}runtime.json`,
48
+ "https://docs.nylorun.com/schemas/runtime-manifest/v1.2.json",
47
49
  "https://docs.nylorun.com/schemas/runtime-manifest/v1.1.json",
48
50
  "https://docs.nylorun.com/schemas/runtime-manifest/v1.json",
49
51
  ],
@@ -1037,6 +1039,7 @@ export function compileAgentFolder(input, scope) {
1037
1039
  : {}),
1038
1040
  plan: role === "root" && loop.plan === true,
1039
1041
  connections: role === "root" && loop.connections === true,
1042
+ triggers: role === "root" && declared.engine.triggers === true,
1040
1043
  });
1041
1044
  for (const name of unusedInstructions(declared.engine, names))
1042
1045
  warn("engine_text_unused", `engine.instructions.${name} replaces the wording of the ${name} block, and the agent does not get that block, so the text is never read`, AGENT_FILE, ["engine", "instructions", name], { key: true });
@@ -2,7 +2,7 @@ import { type EngineBlockName } from "../engine/names.js";
2
2
  import type { HarnessEngine, SkillManifest, ToolManifest } from "../types/manifest.js";
3
3
  import type { ReportOptions } from "./context.js";
4
4
  /** The keys of `AGENT.md`'s `engine:` block. */
5
- export declare const ENGINE_KEYS: readonly ["sandbox", "artifacts", "outputs", "toolSearch", "instructions"];
5
+ export declare const ENGINE_KEYS: readonly ["sandbox", "artifacts", "outputs", "toolSearch", "triggers", "instructions"];
6
6
  /** Where a folder keeps the files that replace a block's wording. */
7
7
  export declare const ENGINE_TEXT_DIR = "engine";
8
8
  /** A folder's format: 1 (`agent-folder/1`, the default) or 2 (`agent-folder/2`); undefined when it is neither. */
@@ -39,7 +39,8 @@ export declare function engineDeclarations(value: unknown, options: {
39
39
  /**
40
40
  * The text blocks an agent gets, from what it declares and what the folder says of its session:
41
41
  * whether its runtime has a computer and sets `selfWake`, its skills, memory and loop settings,
42
- * and whether its MCP tools may be deferred. The harness's own projection decides them
42
+ * whether it is the root agent declaring `engine.triggers`, and whether its MCP tools may be
43
+ * deferred. The harness's own projection decides them
43
44
  * (`engineProjection`), so the list is what a session's system text holds.
44
45
  */
45
46
  export declare function engineBlocksOf(agent: {
@@ -62,6 +63,8 @@ export declare function engineBlocksOf(agent: {
62
63
  };
63
64
  readonly plan: boolean;
64
65
  readonly connections: boolean;
66
+ /** The root agent declares `engine.triggers` (D83). */
67
+ readonly triggers?: boolean;
65
68
  }): EngineBlockName[];
66
69
  /** `harness.engine` as the compiled manifest holds it: the declarations, then the blocks. */
67
70
  export declare function compiledEngine(engine: HarnessEngine, blocks: readonly EngineBlockName[], sources: Partial<Record<EngineBlockName, string>>): HarnessEngine;