@nylorun/core 0.43.0-beta → 0.45.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 +22 -0
- package/dist/compatibility.d.ts +7 -0
- package/dist/compatibility.js +7 -0
- package/dist/contracts.d.ts +93 -24
- package/dist/contracts.js +67 -39
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.45.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 17951fe: A client can give one Agent a trigger over the API (D88, ADR-145; Host feature `api-triggers`). `PUT /v1/agents/{agentId}/triggers/{triggerId}` creates or replaces the Agent's trigger of a fourth origin, `api`: the body is a `Trigger` exactly as a definition's `runtime.triggers` entry holds it (one of `schedule` with `timezone`, `at` or `webhook`; `session`; `prompt`) and an optional `title`. A new one is active with its next time; a replaced one gets its next time again and keeps its status; the same body again changes nothing and records no event. An id the definition declares, or one an agent's trigger or a booked wake holds, is `409 trigger_conflict`. The checks and limits are a definition's, and `runtime.limits.triggers.count` now counts the triggers an Agent's agents made and those clients put together (`422 trigger_limit`). Upgrades and moves never touch an `api` trigger, `DELETE` removes it, and pause, resume, run and a webhook's secret work as for any trigger.
|
|
8
|
+
|
|
9
|
+
- `@nylorun/core`: `TRIGGER_ORIGINS` adds `api`; `TriggerPutSchema`; `TriggerView.principal`; `agent.trigger_created` and `agent.trigger_updated` carry `origin`, `principal`, the timing and `changed` (their `sessionId` is now optional, set for `agent` only; `kind` adds `webhook`), and `agent.trigger_deleted` carries `origin`; Host feature `api-triggers`.
|
|
10
|
+
- `@nylorun/runtime`: the route; `agent_triggers.principal` and the `api` origin (store migration 0049, run at start).
|
|
11
|
+
- `@nylorun/agents`: `agents.putTrigger(agentId, triggerId, trigger)`; `deleteTrigger` deletes `api` triggers too.
|
|
12
|
+
- `nylorun`: `nylorun agents triggers put <id> <trigger>` with `--schedule`, `--timezone`, `--at`, `--webhook`, `--session`, `--prompt` and `--title`, or a JSON file; `rm` deletes `api` triggers.
|
|
13
|
+
- `@nylorun/studio`: the Triggers tab shows where each trigger came from (the definition's version, the agent that made it, or the principal that put it), its prompt and time zone for every origin, and deletes one an agent made or a client put; Activity words trigger changes and filters them.
|
|
14
|
+
|
|
15
|
+
## 0.44.0-beta
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 874cc83: Pods on Agent Substrate (preview): suspend before drain, following Substrate's eviction contract. A worker pod that stops (a drain, a GKE node upgrade or scale-down, a WorkerPool rollout, a deleted pod) sends each of its actors SIGTERM and gives them 30 minutes to be suspended; until now the engine exited on that signal, so the actor crashed and went back to its last suspend, losing everything since.
|
|
20
|
+
|
|
21
|
+
- `@nylorun/runtime`: on Substrate (`NYLORUN_SANDBOX_SUBSTRATE=1`, which the sandboxes service's template sets), the engine logs `harness_worker_stopping` on SIGTERM and keeps running, with its runs. The sandboxes service watches worker pods (label `ate.dev/worker-pool`) and, when one turns Terminating, suspends each of the Tenant's actors on it synchronously (eight at a time, trying again for up to 29 minutes), records `drainedAt`, and resumes a sandbox whose request is `Running` on another worker. While it moves, its status reason is `Moving`, and the pod lifecycle waits instead of failing it at the ready deadline. Each drain is recorded once, as `agent.suspended` with reason `drain` (the pod row's `drained_at`, store migration 0048, nullable, run at start). Not covered: a spot reclaim or a node that dies, which still crash and revert. An actor created by an earlier release keeps its engine (#643) until it is reset.
|
|
22
|
+
- `@nylorun/core`: `agent.suspended`'s `reason` may be `drain`.
|
|
23
|
+
- `nylorun`: `local sandbox enable --backend substrate` lets the sandboxes service read pods cluster-wide (`get`, `list`, `watch`), for the worker pods it watches.
|
|
24
|
+
|
|
3
25
|
## 0.43.0-beta
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -259,6 +259,13 @@ export declare const OPTIONAL_HOST_FEATURES: readonly ["tenant-fixture-model", "
|
|
|
259
259
|
* `runtime.limits.triggers`; and `GET /v1/runs/stream`, the Tenant's runs as server-sent events.
|
|
260
260
|
*/
|
|
261
261
|
"agent-triggers",
|
|
262
|
+
/**
|
|
263
|
+
* Triggers a client puts on one Agent (D88): `PUT /v1/agents/{id}/triggers/{triggerId}` with a
|
|
264
|
+
* `Trigger` and an optional `title` creates or replaces the Agent's `api` trigger; `DELETE`
|
|
265
|
+
* removes it; the list shows `origin: api` and its `principal`; the trigger events carry `origin`,
|
|
266
|
+
* `principal` and `changed`.
|
|
267
|
+
*/
|
|
268
|
+
"api-triggers",
|
|
262
269
|
/**
|
|
263
270
|
* A message's `delivery: "steer"` (D85): to a busy agent session it waits in the session queue
|
|
264
271
|
* marked `steer`, and our engine takes it into the running turn before its next step (the
|
package/dist/compatibility.js
CHANGED
|
@@ -281,6 +281,13 @@ export const OPTIONAL_HOST_FEATURES = [
|
|
|
281
281
|
* `runtime.limits.triggers`; and `GET /v1/runs/stream`, the Tenant's runs as server-sent events.
|
|
282
282
|
*/
|
|
283
283
|
"agent-triggers",
|
|
284
|
+
/**
|
|
285
|
+
* Triggers a client puts on one Agent (D88): `PUT /v1/agents/{id}/triggers/{triggerId}` with a
|
|
286
|
+
* `Trigger` and an optional `title` creates or replaces the Agent's `api` trigger; `DELETE`
|
|
287
|
+
* removes it; the list shows `origin: api` and its `principal`; the trigger events carry `origin`,
|
|
288
|
+
* `principal` and `changed`.
|
|
289
|
+
*/
|
|
290
|
+
"api-triggers",
|
|
284
291
|
/**
|
|
285
292
|
* A message's `delivery: "steer"` (D85): to a busy agent session it waits in the session queue
|
|
286
293
|
* marked `steer`, and our engine takes it into the running turn before its next step (the
|
package/dist/contracts.d.ts
CHANGED
|
@@ -728,6 +728,28 @@ export declare const MemoryUpdatedPayloadSchema: z.ZodObject<{
|
|
|
728
728
|
}, z.core.$loose>;
|
|
729
729
|
export declare const AGENT_EVENT_TYPES: readonly ["agent.created", "agent.attached", "agent.detached", "agent.deleted", "agent.running", "agent.suspended", "agent.relaunched", "agent.lost", "agent.reset", "agent.failed", "agent.forked", "agent.outdated", "agent.version_changed", "agent.start_failed", "agent.egress", "agent.run", "agent.trigger_paused", "agent.trigger_resumed", "agent.trigger_secret_rotated", "agent.trigger_created", "agent.trigger_updated", "agent.trigger_deleted", "agent.memory_updated"];
|
|
730
730
|
export type AgentEventType = (typeof AGENT_EVENT_TYPES)[number];
|
|
731
|
+
/** `agent.trigger_created` and `agent.trigger_updated`'s payload (D83, D88). */
|
|
732
|
+
export declare const TriggerChangePayloadSchema: z.ZodObject<{
|
|
733
|
+
triggerId: z.ZodString;
|
|
734
|
+
kind: z.ZodEnum<{
|
|
735
|
+
at: "at";
|
|
736
|
+
schedule: "schedule";
|
|
737
|
+
webhook: "webhook";
|
|
738
|
+
}>;
|
|
739
|
+
origin: z.ZodOptional<z.ZodEnum<{
|
|
740
|
+
agent: "agent";
|
|
741
|
+
api: "api";
|
|
742
|
+
}>>;
|
|
743
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
744
|
+
principal: z.ZodOptional<z.ZodString>;
|
|
745
|
+
session: z.ZodString;
|
|
746
|
+
title: z.ZodOptional<z.ZodString>;
|
|
747
|
+
schedule: z.ZodOptional<z.ZodString>;
|
|
748
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
749
|
+
at: z.ZodOptional<z.ZodString>;
|
|
750
|
+
changed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
751
|
+
nextRunAt: z.ZodNullable<z.ZodString>;
|
|
752
|
+
}, z.core.$loose>;
|
|
731
753
|
/** The payload of each Agent lifecycle event. */
|
|
732
754
|
export declare const AGENT_EVENT_PAYLOADS: {
|
|
733
755
|
readonly "agent.created": z.ZodObject<{
|
|
@@ -770,9 +792,14 @@ export declare const AGENT_EVENT_PAYLOADS: {
|
|
|
770
792
|
readonly "agent.running": z.ZodObject<{
|
|
771
793
|
hostEpoch: z.ZodNumber;
|
|
772
794
|
}, z.core.$loose>;
|
|
773
|
-
/**
|
|
795
|
+
/**
|
|
796
|
+
* Stopped (`POST .../stop`, or idle): the volume is kept; the next turn starts it again.
|
|
797
|
+
* `drain` (Agent Substrate): its worker stopped, so it was suspended with everything it held
|
|
798
|
+
* and resumed on another worker; nothing was lost.
|
|
799
|
+
*/
|
|
774
800
|
readonly "agent.suspended": z.ZodObject<{
|
|
775
801
|
reason: z.ZodEnum<{
|
|
802
|
+
drain: "drain";
|
|
776
803
|
idle: "idle";
|
|
777
804
|
restart: "restart";
|
|
778
805
|
stop: "stop";
|
|
@@ -880,19 +907,31 @@ export declare const AGENT_EVENT_PAYLOADS: {
|
|
|
880
907
|
triggerId: z.ZodString;
|
|
881
908
|
}, z.core.$loose>;
|
|
882
909
|
/**
|
|
883
|
-
* An agent made a trigger with the `triggers` tool (D83), or
|
|
884
|
-
* (
|
|
885
|
-
*
|
|
910
|
+
* An agent made a trigger with the `triggers` tool (D83), or a client put one over the API
|
|
911
|
+
* (D88), or either replaced one with the same id (`agent.trigger_updated`): where it came from
|
|
912
|
+
* (`origin`), the session whose agent made it (`sessionId`, for `agent`) or who put it
|
|
913
|
+
* (`principal`, for `api`), the session it runs in (`session`), its timing, its title, its next
|
|
914
|
+
* run, and on an update the fields that changed (`changed`).
|
|
886
915
|
*/
|
|
887
916
|
readonly "agent.trigger_created": z.ZodObject<{
|
|
888
917
|
triggerId: z.ZodString;
|
|
889
918
|
kind: z.ZodEnum<{
|
|
890
919
|
at: "at";
|
|
891
920
|
schedule: "schedule";
|
|
921
|
+
webhook: "webhook";
|
|
892
922
|
}>;
|
|
893
|
-
|
|
923
|
+
origin: z.ZodOptional<z.ZodEnum<{
|
|
924
|
+
agent: "agent";
|
|
925
|
+
api: "api";
|
|
926
|
+
}>>;
|
|
927
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
928
|
+
principal: z.ZodOptional<z.ZodString>;
|
|
894
929
|
session: z.ZodString;
|
|
895
930
|
title: z.ZodOptional<z.ZodString>;
|
|
931
|
+
schedule: z.ZodOptional<z.ZodString>;
|
|
932
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
933
|
+
at: z.ZodOptional<z.ZodString>;
|
|
934
|
+
changed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
896
935
|
nextRunAt: z.ZodNullable<z.ZodString>;
|
|
897
936
|
}, z.core.$loose>;
|
|
898
937
|
readonly "agent.trigger_updated": z.ZodObject<{
|
|
@@ -900,15 +939,32 @@ export declare const AGENT_EVENT_PAYLOADS: {
|
|
|
900
939
|
kind: z.ZodEnum<{
|
|
901
940
|
at: "at";
|
|
902
941
|
schedule: "schedule";
|
|
942
|
+
webhook: "webhook";
|
|
903
943
|
}>;
|
|
904
|
-
|
|
944
|
+
origin: z.ZodOptional<z.ZodEnum<{
|
|
945
|
+
agent: "agent";
|
|
946
|
+
api: "api";
|
|
947
|
+
}>>;
|
|
948
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
949
|
+
principal: z.ZodOptional<z.ZodString>;
|
|
905
950
|
session: z.ZodString;
|
|
906
951
|
title: z.ZodOptional<z.ZodString>;
|
|
952
|
+
schedule: z.ZodOptional<z.ZodString>;
|
|
953
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
954
|
+
at: z.ZodOptional<z.ZodString>;
|
|
955
|
+
changed: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
907
956
|
nextRunAt: z.ZodNullable<z.ZodString>;
|
|
908
957
|
}, z.core.$loose>;
|
|
909
|
-
/**
|
|
958
|
+
/**
|
|
959
|
+
* A trigger an agent made or a client put was deleted: by an agent of `sessionId`, or over the
|
|
960
|
+
* API (`principal`); `origin` says which kind of trigger it was (D88).
|
|
961
|
+
*/
|
|
910
962
|
readonly "agent.trigger_deleted": z.ZodObject<{
|
|
911
963
|
triggerId: z.ZodString;
|
|
964
|
+
origin: z.ZodOptional<z.ZodEnum<{
|
|
965
|
+
agent: "agent";
|
|
966
|
+
api: "api";
|
|
967
|
+
}>>;
|
|
912
968
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
913
969
|
principal: z.ZodOptional<z.ZodString>;
|
|
914
970
|
}, z.core.$loose>;
|
|
@@ -1336,17 +1392,6 @@ export declare const HarnessSectionSchema: z.ZodUnion<readonly [z.ZodType<Workfl
|
|
|
1336
1392
|
export declare const TriggerIdSchema: z.ZodString;
|
|
1337
1393
|
/** The signature schemes a webhook trigger verifies: Standard Webhooks only. */
|
|
1338
1394
|
export declare const WEBHOOK_SCHEMES: readonly ["standard-webhooks"];
|
|
1339
|
-
/**
|
|
1340
|
-
* One trigger of an agent manifest's `runtime.triggers`: exactly one of
|
|
1341
|
-
* `schedule` (five-field cron, minute granularity, in `timezone`, an IANA name, default UTC), `at`
|
|
1342
|
-
* (one run at an RFC 3339 time with an offset) or `webhook` (a webhook endpoint verified with the
|
|
1343
|
-
* named scheme), plus the `session` each run goes to and the author's `prompt`.
|
|
1344
|
-
*
|
|
1345
|
-
* `session` is a session id of the Agent, opened on the trigger's first run if it does not
|
|
1346
|
-
* exist, or `"new"` for a new session per run (`run-<runId>`). The Runtime keeps no main session.
|
|
1347
|
-
* The cron's smallest gap, the `at` time, the prompt's length and how many triggers a
|
|
1348
|
-
* manifest holds are checked against the Tenant's Runtime limits when it is saved.
|
|
1349
|
-
*/
|
|
1350
1395
|
export declare const TriggerSchema: z.ZodObject<{
|
|
1351
1396
|
schedule: z.ZodOptional<z.ZodString>;
|
|
1352
1397
|
timezone: z.ZodOptional<z.ZodString>;
|
|
@@ -1369,11 +1414,12 @@ export declare function triggerKindOf(trigger: Trigger): Exclude<TriggerKind, "w
|
|
|
1369
1414
|
*/
|
|
1370
1415
|
export declare const TRIGGER_STATUSES: readonly ["active", "paused", "completed"];
|
|
1371
1416
|
/**
|
|
1372
|
-
* Where a trigger's definition comes from (D83): `manifest` (the version's `runtime.triggers`),
|
|
1373
|
-
* `agent` (made by an agent of the Agent's sessions with the `triggers` tool, kept by the Agent)
|
|
1374
|
-
*
|
|
1417
|
+
* Where a trigger's definition comes from (D83, D88): `manifest` (the version's `runtime.triggers`),
|
|
1418
|
+
* `agent` (made by an agent of the Agent's sessions with the `triggers` tool, kept by the Agent),
|
|
1419
|
+
* `api` (put on the Agent by a client, `PUT /v1/agents/{id}/triggers/{triggerId}`, kept by the
|
|
1420
|
+
* Agent with the principal that put it) or `wake` (a session's booked wake, never listed).
|
|
1375
1421
|
*/
|
|
1376
|
-
export declare const TRIGGER_ORIGINS: readonly ["manifest", "agent", "wake"];
|
|
1422
|
+
export declare const TRIGGER_ORIGINS: readonly ["manifest", "agent", "api", "wake"];
|
|
1377
1423
|
export type TriggerOrigin = (typeof TRIGGER_ORIGINS)[number];
|
|
1378
1424
|
/**
|
|
1379
1425
|
* `GET /v1/agents/{id}/triggers`: one trigger, from its manifest entry (or, for one an agent made,
|
|
@@ -1389,11 +1435,13 @@ export declare const TriggerViewSchema: z.ZodObject<{
|
|
|
1389
1435
|
}>;
|
|
1390
1436
|
origin: z.ZodEnum<{
|
|
1391
1437
|
agent: "agent";
|
|
1438
|
+
api: "api";
|
|
1392
1439
|
manifest: "manifest";
|
|
1393
1440
|
wake: "wake";
|
|
1394
1441
|
}>;
|
|
1395
1442
|
title: z.ZodNullable<z.ZodString>;
|
|
1396
1443
|
createdSessionId: z.ZodNullable<z.ZodString>;
|
|
1444
|
+
principal: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1397
1445
|
status: z.ZodEnum<{
|
|
1398
1446
|
active: "active";
|
|
1399
1447
|
completed: "completed";
|
|
@@ -1422,11 +1470,13 @@ export declare const TriggerListSchema: z.ZodObject<{
|
|
|
1422
1470
|
}>;
|
|
1423
1471
|
origin: z.ZodEnum<{
|
|
1424
1472
|
agent: "agent";
|
|
1473
|
+
api: "api";
|
|
1425
1474
|
manifest: "manifest";
|
|
1426
1475
|
wake: "wake";
|
|
1427
1476
|
}>;
|
|
1428
1477
|
title: z.ZodNullable<z.ZodString>;
|
|
1429
1478
|
createdSessionId: z.ZodNullable<z.ZodString>;
|
|
1479
|
+
principal: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1430
1480
|
status: z.ZodEnum<{
|
|
1431
1481
|
active: "active";
|
|
1432
1482
|
completed: "completed";
|
|
@@ -1444,10 +1494,27 @@ export declare const TriggerListSchema: z.ZodObject<{
|
|
|
1444
1494
|
prompt: z.ZodOptional<z.ZodString>;
|
|
1445
1495
|
}, z.core.$strict>>;
|
|
1446
1496
|
}, z.core.$strict>;
|
|
1497
|
+
/** The longest title an agent or a client gives a trigger it makes. */
|
|
1498
|
+
export declare const TRIGGER_TITLE_MAX = 80;
|
|
1499
|
+
/**
|
|
1500
|
+
* The body of `PUT /v1/agents/{agentId}/triggers/{triggerId}` (D88): a `Trigger`, exactly as a
|
|
1501
|
+
* definition's `runtime.triggers` entry holds it, and an optional `title`. It creates the Agent's
|
|
1502
|
+
* `api` trigger with that id, or replaces it; the same body again changes nothing.
|
|
1503
|
+
*/
|
|
1504
|
+
export declare const TriggerPutSchema: z.ZodObject<{
|
|
1505
|
+
schedule: z.ZodOptional<z.ZodString>;
|
|
1506
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
1507
|
+
at: z.ZodOptional<z.ZodISODateTime>;
|
|
1508
|
+
webhook: z.ZodOptional<z.ZodEnum<{
|
|
1509
|
+
"standard-webhooks": "standard-webhooks";
|
|
1510
|
+
}>>;
|
|
1511
|
+
session: z.ZodString;
|
|
1512
|
+
prompt: z.ZodString;
|
|
1513
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1514
|
+
}, z.core.$strict>;
|
|
1515
|
+
export type TriggerPut = z.infer<typeof TriggerPutSchema>;
|
|
1447
1516
|
/** `in` of the `triggers` tool (D83): a delay in minutes, hours or days, such as `30m`, `2h`, `1d`. */
|
|
1448
1517
|
export declare const TRIGGER_DELAY_PATTERN: RegExp;
|
|
1449
|
-
/** The longest title an agent gives a trigger it makes. */
|
|
1450
|
-
export declare const TRIGGER_TITLE_MAX = 80;
|
|
1451
1518
|
/** Where an agent-made trigger runs: the calling session (`this`), or a session of its own (`own`). */
|
|
1452
1519
|
export declare const TRIGGER_TOOL_SESSIONS: readonly ["this", "own"];
|
|
1453
1520
|
/**
|
|
@@ -1587,6 +1654,7 @@ export declare const TenantRunSchema: z.ZodObject<{
|
|
|
1587
1654
|
late: z.ZodBoolean;
|
|
1588
1655
|
origin: z.ZodEnum<{
|
|
1589
1656
|
agent: "agent";
|
|
1657
|
+
api: "api";
|
|
1590
1658
|
manifest: "manifest";
|
|
1591
1659
|
wake: "wake";
|
|
1592
1660
|
}>;
|
|
@@ -1621,6 +1689,7 @@ export declare const TenantRunEventSchema: z.ZodObject<{
|
|
|
1621
1689
|
late: z.ZodBoolean;
|
|
1622
1690
|
origin: z.ZodEnum<{
|
|
1623
1691
|
agent: "agent";
|
|
1692
|
+
api: "api";
|
|
1624
1693
|
manifest: "manifest";
|
|
1625
1694
|
wake: "wake";
|
|
1626
1695
|
}>;
|
package/dist/contracts.js
CHANGED
|
@@ -1172,6 +1172,27 @@ export const AGENT_EVENT_TYPES = [
|
|
|
1172
1172
|
// Memory (track T5, D72): a turn changed the Agent's memories.
|
|
1173
1173
|
"agent.memory_updated",
|
|
1174
1174
|
];
|
|
1175
|
+
/** `agent.trigger_created` and `agent.trigger_updated`'s payload (D83, D88). */
|
|
1176
|
+
export const TriggerChangePayloadSchema = z
|
|
1177
|
+
.object({
|
|
1178
|
+
triggerId: z.string(),
|
|
1179
|
+
kind: z.enum(["schedule", "at", "webhook"]),
|
|
1180
|
+
/** Absent on events recorded before D88, which were all `agent`. */
|
|
1181
|
+
origin: z.enum(["agent", "api"]).optional(),
|
|
1182
|
+
/** The session whose agent made it: an `agent` trigger's. */
|
|
1183
|
+
sessionId: z.string().optional(),
|
|
1184
|
+
/** Who put it: an `api` trigger's. */
|
|
1185
|
+
principal: z.string().optional(),
|
|
1186
|
+
session: z.string(),
|
|
1187
|
+
title: z.string().optional(),
|
|
1188
|
+
schedule: z.string().optional(),
|
|
1189
|
+
timezone: z.string().optional(),
|
|
1190
|
+
at: z.string().optional(),
|
|
1191
|
+
/** On `agent.trigger_updated` from D88: the definition's fields that changed. */
|
|
1192
|
+
changed: z.array(z.string()).optional(),
|
|
1193
|
+
nextRunAt: z.string().nullable(),
|
|
1194
|
+
})
|
|
1195
|
+
.passthrough();
|
|
1175
1196
|
/** The payload of each Agent lifecycle event. */
|
|
1176
1197
|
export const AGENT_EVENT_PAYLOADS = {
|
|
1177
1198
|
"agent.created": z
|
|
@@ -1199,8 +1220,12 @@ export const AGENT_EVENT_PAYLOADS = {
|
|
|
1199
1220
|
.passthrough(),
|
|
1200
1221
|
/** A pod joined and serves the Agent. */
|
|
1201
1222
|
"agent.running": z.object({ hostEpoch: z.number().int() }).passthrough(),
|
|
1202
|
-
/**
|
|
1203
|
-
|
|
1223
|
+
/**
|
|
1224
|
+
* Stopped (`POST .../stop`, or idle): the volume is kept; the next turn starts it again.
|
|
1225
|
+
* `drain` (Agent Substrate): its worker stopped, so it was suspended with everything it held
|
|
1226
|
+
* and resumed on another worker; nothing was lost.
|
|
1227
|
+
*/
|
|
1228
|
+
"agent.suspended": z.object({ reason: z.enum(["stop", "idle", "restart", "drain"]) }).passthrough(),
|
|
1204
1229
|
/** Its pod was replaced (same volume): the old pod's host token no longer works. */
|
|
1205
1230
|
"agent.relaunched": z.object({ hostEpoch: z.number().int() }).passthrough(),
|
|
1206
1231
|
/** Its volume or node is gone: turns are refused until a reset. */
|
|
@@ -1264,34 +1289,26 @@ export const AGENT_EVENT_PAYLOADS = {
|
|
|
1264
1289
|
/** A webhook trigger's signing secret was made or replaced; the one before stopped working. */
|
|
1265
1290
|
"agent.trigger_secret_rotated": z.object({ triggerId: z.string() }).passthrough(),
|
|
1266
1291
|
/**
|
|
1267
|
-
* An agent made a trigger with the `triggers` tool (D83), or
|
|
1268
|
-
* (
|
|
1269
|
-
*
|
|
1292
|
+
* An agent made a trigger with the `triggers` tool (D83), or a client put one over the API
|
|
1293
|
+
* (D88), or either replaced one with the same id (`agent.trigger_updated`): where it came from
|
|
1294
|
+
* (`origin`), the session whose agent made it (`sessionId`, for `agent`) or who put it
|
|
1295
|
+
* (`principal`, for `api`), the session it runs in (`session`), its timing, its title, its next
|
|
1296
|
+
* run, and on an update the fields that changed (`changed`).
|
|
1270
1297
|
*/
|
|
1271
|
-
"agent.trigger_created":
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
nextRunAt: z.string().nullable(),
|
|
1279
|
-
})
|
|
1280
|
-
.passthrough(),
|
|
1281
|
-
"agent.trigger_updated": z
|
|
1298
|
+
"agent.trigger_created": TriggerChangePayloadSchema,
|
|
1299
|
+
"agent.trigger_updated": TriggerChangePayloadSchema,
|
|
1300
|
+
/**
|
|
1301
|
+
* A trigger an agent made or a client put was deleted: by an agent of `sessionId`, or over the
|
|
1302
|
+
* API (`principal`); `origin` says which kind of trigger it was (D88).
|
|
1303
|
+
*/
|
|
1304
|
+
"agent.trigger_deleted": z
|
|
1282
1305
|
.object({
|
|
1283
1306
|
triggerId: z.string(),
|
|
1284
|
-
|
|
1285
|
-
sessionId: z.string(),
|
|
1286
|
-
|
|
1287
|
-
title: z.string().optional(),
|
|
1288
|
-
nextRunAt: z.string().nullable(),
|
|
1307
|
+
origin: z.enum(["agent", "api"]).optional(),
|
|
1308
|
+
sessionId: z.string().optional(),
|
|
1309
|
+
principal: z.string().optional(),
|
|
1289
1310
|
})
|
|
1290
1311
|
.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(),
|
|
1295
1312
|
/** A turn changed the Agent's memories (`memory.updated` in its session): which, and how. */
|
|
1296
1313
|
"agent.memory_updated": MemoryUpdatedPayloadSchema.extend({ sessionId: z.string(), turnId: z.string() }),
|
|
1297
1314
|
};
|
|
@@ -1898,8 +1915,7 @@ export const WEBHOOK_SCHEMES = ["standard-webhooks"];
|
|
|
1898
1915
|
* The cron's smallest gap, the `at` time, the prompt's length and how many triggers a
|
|
1899
1916
|
* manifest holds are checked against the Tenant's Runtime limits when it is saved.
|
|
1900
1917
|
*/
|
|
1901
|
-
|
|
1902
|
-
.strictObject({
|
|
1918
|
+
const TRIGGER_FIELDS = {
|
|
1903
1919
|
schedule: z
|
|
1904
1920
|
.string()
|
|
1905
1921
|
.regex(/^\S+(\s+\S+){4}$/, { message: "schedule is five cron fields: minute hour day-of-month month day-of-week" })
|
|
@@ -1909,15 +1925,16 @@ export const TriggerSchema = z
|
|
|
1909
1925
|
webhook: z.enum(WEBHOOK_SCHEMES).optional(),
|
|
1910
1926
|
session: z.string().min(1).max(200),
|
|
1911
1927
|
prompt: z.string().min(1),
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1928
|
+
};
|
|
1929
|
+
/** A trigger has exactly one of `schedule`, `at` or `webhook`, and `timezone` only with `schedule`. */
|
|
1930
|
+
function checkTriggerKind(trigger, ctx) {
|
|
1914
1931
|
const kinds = [trigger.schedule, trigger.at, trigger.webhook].filter((value) => value !== undefined);
|
|
1915
1932
|
if (kinds.length !== 1)
|
|
1916
1933
|
ctx.addIssue({ code: "custom", message: "A trigger has exactly one of schedule, at or webhook" });
|
|
1917
1934
|
if (trigger.timezone !== undefined && trigger.schedule === undefined)
|
|
1918
1935
|
ctx.addIssue({ code: "custom", path: ["timezone"], message: "timezone goes with schedule" });
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1936
|
+
}
|
|
1937
|
+
export const TriggerSchema = z.strictObject(TRIGGER_FIELDS).superRefine(checkTriggerKind).meta({ id: "Trigger" });
|
|
1921
1938
|
/** What a trigger is: the field it has, or `wake` for a session's own booking. */
|
|
1922
1939
|
export const TRIGGER_KINDS = ["schedule", "at", "webhook", "wake"];
|
|
1923
1940
|
/** A trigger's kind, from its manifest entry. */
|
|
@@ -1930,11 +1947,12 @@ export function triggerKindOf(trigger) {
|
|
|
1930
1947
|
*/
|
|
1931
1948
|
export const TRIGGER_STATUSES = ["active", "paused", "completed"];
|
|
1932
1949
|
/**
|
|
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
|
-
*
|
|
1950
|
+
* Where a trigger's definition comes from (D83, D88): `manifest` (the version's `runtime.triggers`),
|
|
1951
|
+
* `agent` (made by an agent of the Agent's sessions with the `triggers` tool, kept by the Agent),
|
|
1952
|
+
* `api` (put on the Agent by a client, `PUT /v1/agents/{id}/triggers/{triggerId}`, kept by the
|
|
1953
|
+
* Agent with the principal that put it) or `wake` (a session's booked wake, never listed).
|
|
1936
1954
|
*/
|
|
1937
|
-
export const TRIGGER_ORIGINS = ["manifest", "agent", "wake"];
|
|
1955
|
+
export const TRIGGER_ORIGINS = ["manifest", "agent", "api", "wake"];
|
|
1938
1956
|
/**
|
|
1939
1957
|
* `GET /v1/agents/{id}/triggers`: one trigger, from its manifest entry (or, for one an agent made,
|
|
1940
1958
|
* its own definition) and the Agent's state.
|
|
@@ -1944,10 +1962,12 @@ export const TriggerViewSchema = z
|
|
|
1944
1962
|
id: z.string(),
|
|
1945
1963
|
kind: z.enum(TRIGGER_KINDS),
|
|
1946
1964
|
origin: z.enum(TRIGGER_ORIGINS),
|
|
1947
|
-
/** The title an agent gave a trigger it made; null for a manifest's. */
|
|
1965
|
+
/** The title an agent or a client gave a trigger it made; null for a manifest's. */
|
|
1948
1966
|
title: z.string().nullable(),
|
|
1949
|
-
/** The session whose agent made it; null for a manifest's. */
|
|
1967
|
+
/** The session whose agent made it; null for a manifest's or an `api` trigger. */
|
|
1950
1968
|
createdSessionId: z.string().nullable(),
|
|
1969
|
+
/** Who put an `api` trigger (D88); null for every other origin. Absent from a Runtime before D88. */
|
|
1970
|
+
principal: z.string().nullable().optional(),
|
|
1951
1971
|
status: z.enum(TRIGGER_STATUSES),
|
|
1952
1972
|
/** `manual`, `new` for one an upgrade added, `undeclared` for an agent's while the version lacks `engine.triggers`. */
|
|
1953
1973
|
pausedReason: z.string().nullable(),
|
|
@@ -1971,10 +1991,18 @@ export const TriggerViewSchema = z
|
|
|
1971
1991
|
})
|
|
1972
1992
|
.strict();
|
|
1973
1993
|
export const TriggerListSchema = z.object({ triggers: z.array(TriggerViewSchema) }).strict();
|
|
1994
|
+
/** The longest title an agent or a client gives a trigger it makes. */
|
|
1995
|
+
export const TRIGGER_TITLE_MAX = 80;
|
|
1996
|
+
/**
|
|
1997
|
+
* The body of `PUT /v1/agents/{agentId}/triggers/{triggerId}` (D88): a `Trigger`, exactly as a
|
|
1998
|
+
* definition's `runtime.triggers` entry holds it, and an optional `title`. It creates the Agent's
|
|
1999
|
+
* `api` trigger with that id, or replaces it; the same body again changes nothing.
|
|
2000
|
+
*/
|
|
2001
|
+
export const TriggerPutSchema = z
|
|
2002
|
+
.strictObject({ ...TRIGGER_FIELDS, title: z.string().min(1).max(TRIGGER_TITLE_MAX).optional() })
|
|
2003
|
+
.superRefine(checkTriggerKind);
|
|
1974
2004
|
/** `in` of the `triggers` tool (D83): a delay in minutes, hours or days, such as `30m`, `2h`, `1d`. */
|
|
1975
2005
|
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
2006
|
/** Where an agent-made trigger runs: the calling session (`this`), or a session of its own (`own`). */
|
|
1979
2007
|
export const TRIGGER_TOOL_SESSIONS = ["this", "own"];
|
|
1980
2008
|
const triggerCreateSchema = z
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0-beta",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Shared agent definitions and wire contracts",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"yaml": "^2.9.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@types/node": "^26.6.
|
|
37
|
+
"@types/node": "^26.6.6",
|
|
38
38
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
39
|
-
"vitest": "^5.0
|
|
39
|
+
"vitest": "^5.1.0"
|
|
40
40
|
},
|
|
41
41
|
"exports": {
|
|
42
42
|
".": {
|