@capybara-hq/kernel 0.1.0-rc.105 → 0.1.0-rc.106

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 (211) hide show
  1. package/dist/agents/agents.schemas.d.ts +9 -9
  2. package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
  3. package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
  4. package/dist/automations/automations.module.d.ts +16 -0
  5. package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
  6. package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
  7. package/dist/automations/automations.schemas.js +253 -0
  8. package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
  9. package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
  10. package/dist/{schedules → automations}/calendar.d.ts +8 -8
  11. package/dist/{schedules → automations}/calendar.js +2 -2
  12. package/dist/automations/effective-settings.d.ts +28 -0
  13. package/dist/automations/effective-settings.js +25 -0
  14. package/dist/automations/errors.d.ts +19 -0
  15. package/dist/automations/errors.js +19 -0
  16. package/dist/automations/events/coalesce.d.ts +28 -0
  17. package/dist/automations/events/coalesce.js +131 -0
  18. package/dist/automations/events/deadline.d.ts +10 -0
  19. package/dist/automations/events/deadline.js +24 -0
  20. package/dist/automations/events/dispatcher.d.ts +74 -0
  21. package/dist/automations/events/dispatcher.js +353 -0
  22. package/dist/automations/events/events.module.d.ts +7 -0
  23. package/dist/automations/events/events.module.js +26 -0
  24. package/dist/automations/events/guards.d.ts +32 -0
  25. package/dist/automations/events/guards.js +87 -0
  26. package/dist/automations/events/sweep.job.d.ts +49 -0
  27. package/dist/automations/events/sweep.job.js +202 -0
  28. package/dist/automations/events/token.d.ts +5 -0
  29. package/dist/automations/events/token.js +5 -0
  30. package/dist/automations/events/trigger-events.service.d.ts +47 -0
  31. package/dist/automations/events/trigger-events.service.js +254 -0
  32. package/dist/{schedules → automations}/fire.d.ts +57 -17
  33. package/dist/{schedules → automations}/fire.js +311 -79
  34. package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
  35. package/dist/{schedules → automations}/grant-rules.js +5 -5
  36. package/dist/automations/job-ids.d.ts +113 -0
  37. package/dist/automations/job-ids.js +117 -0
  38. package/dist/{schedules → automations}/pause.d.ts +3 -3
  39. package/dist/{schedules → automations}/pause.js +3 -3
  40. package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
  41. package/dist/{schedules → automations}/run-tracker.js +68 -56
  42. package/dist/{schedules → automations}/scan.job.d.ts +12 -8
  43. package/dist/{schedules → automations}/scan.job.js +39 -23
  44. package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
  45. package/dist/{schedules → automations}/schedule-math.js +17 -7
  46. package/dist/{schedules → automations}/store.d.ts +57 -27
  47. package/dist/{schedules → automations}/store.js +102 -52
  48. package/dist/automations/store.module.d.ts +6 -0
  49. package/dist/{schedules → automations}/store.module.js +9 -9
  50. package/dist/automations/types.d.ts +178 -0
  51. package/dist/{schedules → automations}/unattended.d.ts +22 -11
  52. package/dist/{schedules → automations}/unattended.js +53 -30
  53. package/dist/catalog/marketplaces.service.d.ts +1 -1
  54. package/dist/channels/channels.module.js +3 -3
  55. package/dist/channels/outbound.d.ts +5 -5
  56. package/dist/channels/outbound.js +17 -17
  57. package/dist/channels/threads.d.ts +1 -1
  58. package/dist/channels/threads.js +1 -1
  59. package/dist/config/schema.d.ts +5 -1
  60. package/dist/config/schema.js +44 -6
  61. package/dist/conversations/approval-profile.d.ts +2 -2
  62. package/dist/conversations/approval-profile.js +3 -3
  63. package/dist/conversations/conversations.controller.d.ts +7 -1
  64. package/dist/conversations/conversations.controller.js +26 -10
  65. package/dist/conversations/conversations.service.d.ts +101 -25
  66. package/dist/conversations/conversations.service.js +132 -32
  67. package/dist/conversations/events.d.ts +46 -0
  68. package/dist/conversations/events.js +54 -3
  69. package/dist/conversations/message-context.d.ts +2 -2
  70. package/dist/conversations/message-context.js +1 -1
  71. package/dist/conversations/permission-profile-store.d.ts +2 -1
  72. package/dist/conversations/permission-profiles.controller.d.ts +3 -0
  73. package/dist/conversations/permission-profiles.service.js +1 -1
  74. package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
  75. package/dist/conversations/prompt-suggestion-request.js +2 -1
  76. package/dist/conversations/queue.d.ts +7 -4
  77. package/dist/conversations/queue.js +6 -2
  78. package/dist/conversations/queue.service.d.ts +5 -5
  79. package/dist/conversations/queue.service.js +20 -14
  80. package/dist/ctx/create-ctx.d.ts +20 -1
  81. package/dist/ctx/create-ctx.js +59 -2
  82. package/dist/db/kernel-schema.d.ts +104 -25
  83. package/dist/devices/device-project-files.service.d.ts +88 -0
  84. package/dist/devices/device-project-files.service.js +249 -0
  85. package/dist/devices/device-projects.service.d.ts +40 -0
  86. package/dist/devices/device-projects.service.js +16 -13
  87. package/dist/devices/devices.controller.d.ts +9 -3
  88. package/dist/devices/devices.controller.js +27 -5
  89. package/dist/devices/devices.module.js +9 -1
  90. package/dist/devices/devices.schemas.js +6 -1
  91. package/dist/devices/dto.d.ts +15 -0
  92. package/dist/devices/dto.js +11 -0
  93. package/dist/devices/project-paths.d.ts +29 -0
  94. package/dist/devices/project-paths.js +66 -0
  95. package/dist/devices/project-rules.d.ts +5 -1
  96. package/dist/devices/project-rules.js +5 -1
  97. package/dist/errors.d.ts +34 -13
  98. package/dist/errors.js +34 -13
  99. package/dist/evals/reconstruct.d.ts +10 -1
  100. package/dist/evals/reconstruct.js +7 -0
  101. package/dist/extensions/host.d.ts +6 -1
  102. package/dist/extensions/host.js +10 -0
  103. package/dist/extensions/permission-set.d.ts +17 -1
  104. package/dist/extensions/permission-set.js +13 -1
  105. package/dist/extensions/permission-view.d.ts +1 -1
  106. package/dist/extensions/permission-view.js +4 -1
  107. package/dist/git/gateway.js +2 -2
  108. package/dist/http/api.module.js +5 -5
  109. package/dist/http/request-signal.d.ts +8 -0
  110. package/dist/http/request-signal.js +14 -0
  111. package/dist/inbox/inbox.module.js +2 -2
  112. package/dist/inbox/inbox.service.d.ts +8 -8
  113. package/dist/inbox/inbox.service.js +7 -7
  114. package/dist/infra/config/kernel-config.service.js +10 -5
  115. package/dist/infra/outbox/registry.d.ts +29 -2
  116. package/dist/infra/outbox/registry.js +30 -7
  117. package/dist/kernel.module.js +3 -0
  118. package/dist/orgs/roles.d.ts +1 -1
  119. package/dist/orgs/roles.js +3 -3
  120. package/dist/orgs/settings.controller.d.ts +1 -1
  121. package/dist/orgs/settings.service.d.ts +27 -11
  122. package/dist/orgs/settings.service.js +42 -24
  123. package/dist/platform/operation.js +2 -2
  124. package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
  125. package/dist/platform/ops/automations.ops.js +560 -0
  126. package/dist/platform/ops/devices.ops.d.ts +3 -1
  127. package/dist/platform/ops/devices.ops.js +77 -3
  128. package/dist/platform/ops/inbox.ops.js +4 -4
  129. package/dist/platform/ops/orgs.ops.js +1 -1
  130. package/dist/platform/ops/platform.ops.js +4 -4
  131. package/dist/platform/platform-ops.module.d.ts +2 -2
  132. package/dist/platform/platform-ops.module.js +5 -5
  133. package/dist/platform/route-schemas.js +3 -3
  134. package/dist/push/jobs.d.ts +3 -3
  135. package/dist/push/jobs.js +2 -2
  136. package/dist/push/preferences.service.js +1 -1
  137. package/dist/push/push-owed.d.ts +3 -3
  138. package/dist/push/push-owed.js +6 -6
  139. package/dist/push/push.schemas.d.ts +4 -4
  140. package/dist/push/push.schemas.js +3 -3
  141. package/dist/push/recipients.d.ts +4 -4
  142. package/dist/push/recipients.js +23 -23
  143. package/dist/push/texts.d.ts +3 -3
  144. package/dist/push/texts.js +2 -2
  145. package/dist/push/triggers.d.ts +1 -1
  146. package/dist/roles/worker.module.js +3 -3
  147. package/dist/runtime/context/build.d.ts +6 -0
  148. package/dist/runtime/context/build.js +14 -3
  149. package/dist/runtime/context/compaction.js +15 -5
  150. package/dist/runtime/context/run-context.d.ts +38 -0
  151. package/dist/runtime/context/run-context.js +54 -0
  152. package/dist/runtime/maintenance.d.ts +8 -4
  153. package/dist/runtime/maintenance.js +37 -16
  154. package/dist/runtime/run-finish.d.ts +4 -4
  155. package/dist/runtime/run-finish.js +3 -3
  156. package/dist/runtime/run-queue.js +12 -7
  157. package/dist/runtime/run-worker.js +7 -1
  158. package/dist/runtime/runtime.module.js +3 -3
  159. package/dist/runtime/subagents/dispatch.js +11 -3
  160. package/dist/sandbox/browse-roots.d.ts +8 -0
  161. package/dist/sandbox/browse-roots.js +22 -0
  162. package/dist/sandbox/network-grants.d.ts +4 -4
  163. package/dist/sandbox/network-grants.js +7 -7
  164. package/dist/sandbox/operation-authority.d.ts +10 -3
  165. package/dist/sandbox/operation-authority.js +20 -10
  166. package/dist/sandbox/operation-intents.d.ts +3 -1
  167. package/dist/sandbox/operation-intents.js +11 -4
  168. package/dist/sandbox/permission-call-grants.js +2 -2
  169. package/dist/sandbox/permission-facts.js +1 -1
  170. package/dist/sandbox/review/classifier.d.ts +2 -2
  171. package/dist/sandbox/review/classifier.js +22 -11
  172. package/dist/sandbox/review/permission-candidate.d.ts +1 -1
  173. package/dist/sandbox/review/permission-candidate.js +1 -1
  174. package/dist/sandbox/sandbox.service.d.ts +15 -5
  175. package/dist/sandbox/sandbox.service.js +14 -8
  176. package/dist/storage/purge.d.ts +1 -1
  177. package/dist/storage/purge.js +2 -2
  178. package/dist/tools/approvals.service.d.ts +6 -6
  179. package/dist/tools/approvals.service.js +19 -19
  180. package/dist/tools/builtin-names.d.ts +12 -12
  181. package/dist/tools/builtin-names.js +29 -29
  182. package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
  183. package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
  184. package/dist/tools/builtins/builtin-tools.d.ts +8 -8
  185. package/dist/tools/builtins/builtin-tools.js +16 -16
  186. package/dist/tools/call-scope.d.ts +1 -1
  187. package/dist/tools/git-asks.js +1 -1
  188. package/dist/tools/git-push-policy.d.ts +3 -3
  189. package/dist/tools/git-push-policy.js +6 -6
  190. package/dist/tools/network-asks.d.ts +3 -3
  191. package/dist/tools/network-asks.js +3 -3
  192. package/dist/tools/pipeline.d.ts +4 -4
  193. package/dist/tools/pipeline.js +2 -2
  194. package/dist/tools/policy.d.ts +3 -3
  195. package/dist/tools/policy.js +3 -3
  196. package/dist/tools/tools.module.js +9 -9
  197. package/package.json +3 -3
  198. package/src/migrations/0188_automations_rename.sql +309 -0
  199. package/src/migrations/0189_event_automations.sql +136 -0
  200. package/dist/platform/ops/schedules.ops.js +0 -509
  201. package/dist/schedules/effective-settings.d.ts +0 -22
  202. package/dist/schedules/effective-settings.js +0 -18
  203. package/dist/schedules/errors.d.ts +0 -8
  204. package/dist/schedules/errors.js +0 -8
  205. package/dist/schedules/job-ids.d.ts +0 -81
  206. package/dist/schedules/job-ids.js +0 -95
  207. package/dist/schedules/schedules.module.d.ts +0 -16
  208. package/dist/schedules/schedules.schemas.js +0 -213
  209. package/dist/schedules/store.module.d.ts +0 -6
  210. package/dist/schedules/types.d.ts +0 -110
  211. /package/dist/{schedules → automations}/types.js +0 -0
@@ -9,11 +9,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Inject, Injectable } from "@nestjs/common";
11
11
  import { sql } from "kysely";
12
+ import { AutomationsService, } from "../automations/automations.service.js";
12
13
  import { CATALOG_REQUESTS_LIST_MAX, CatalogRequestsService, } from "../catalog/requests.service.js";
13
14
  import { ApiError } from "../errors.js";
14
15
  import { KernelDb } from "../infra/database/kernel-db.js";
15
16
  import { roleAtLeast } from "../orgs/roles.js";
16
- import { ScheduledTasksService, } from "../schedules/scheduled-tasks.service.js";
17
17
  import { SKILL_CHANGES_LIST_MAX, SkillChangesService, } from "../skills/changes.service.js";
18
18
  import { APPROVALS_LIST_MAX, ApprovalsService, } from "../tools/approvals.service.js";
19
19
  /** The most open org notices one inbox read returns. */
@@ -26,13 +26,13 @@ let InboxService = class InboxService {
26
26
  skillChanges;
27
27
  kdb;
28
28
  catalogRequests;
29
- schedules;
30
- constructor(approvals, skillChanges, kdb, catalogRequests, schedules) {
29
+ automations;
30
+ constructor(approvals, skillChanges, kdb, catalogRequests, automations) {
31
31
  this.approvals = approvals;
32
32
  this.skillChanges = skillChanges;
33
33
  this.kdb = kdb;
34
34
  this.catalogRequests = catalogRequests;
35
- this.schedules = schedules;
35
+ this.automations = automations;
36
36
  }
37
37
  async list(orgId, accountId) {
38
38
  const [approvals, changes, requests, decided, notices, attention] = await Promise.all([
@@ -41,7 +41,7 @@ let InboxService = class InboxService {
41
41
  this.catalogRequests.listForOrgAdmin(orgId, accountId),
42
42
  this.catalogRequests.listDecidedForRequester(orgId, accountId),
43
43
  this.notices(orgId, accountId),
44
- this.schedules.attentionFor(orgId, accountId),
44
+ this.automations.attentionFor(orgId, accountId),
45
45
  ]);
46
46
  const all = [
47
47
  ...approvals.map((a) => ({
@@ -69,7 +69,7 @@ let InboxService = class InboxService {
69
69
  request: r,
70
70
  })),
71
71
  ...attention.map(({ at, ...view }) => ({
72
- type: "schedule_attention",
72
+ type: "automation_attention",
73
73
  id: `${view.taskId}:${view.reason === "missing_grants" ? "grants" : view.reason === "failed" ? "failed" : "paused"}`,
74
74
  createdAt: at.toISOString(),
75
75
  attention: view,
@@ -150,7 +150,7 @@ InboxService = __decorate([
150
150
  __param(1, Inject(SkillChangesService)),
151
151
  __param(2, Inject(KernelDb)),
152
152
  __param(3, Inject(CatalogRequestsService)),
153
- __param(4, Inject(ScheduledTasksService))
153
+ __param(4, Inject(AutomationsService))
154
154
  ], InboxService);
155
155
  export { InboxService };
156
156
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -75,11 +75,16 @@ const HOT_APPLIERS = {
75
75
  "web.fetch.timeoutMs": () => { },
76
76
  // The push fanout reads the preview setting at every fanout.
77
77
  "push.previews": () => { },
78
- // Scheduled-task settings are clamped to these bounds on every read.
79
- "schedules.minIntervalFloorMinutes": () => { },
80
- "schedules.maxTasksPerMemberCap": () => { },
81
- "schedules.maxTasksPerOrgCap": () => { },
82
- "schedules.maxRunsPerHourCap": () => { },
78
+ // Automation settings are clamped to these bounds on every read.
79
+ "automations.minIntervalFloorMinutes": () => { },
80
+ "automations.maxTasksPerMemberCap": () => { },
81
+ "automations.maxTasksPerOrgCap": () => { },
82
+ "automations.maxRunsPerHourCap": () => { },
83
+ "automations.maxEventDepthCap": () => { },
84
+ "automations.coalesceSecondsCap": () => { },
85
+ "automations.maxEventRunsPerSubjectPerHourCap": () => { },
86
+ // The trigger event sweep reads the retention at every tick.
87
+ "automations.eventRetentionDays": () => { },
83
88
  // Run start reads the skills catalog budget when it records a snapshot.
84
89
  "skills.catalogBudgetChars": () => { },
85
90
  // The attribution defaults are read live at every run start, admin settings view and org settings.
@@ -19,6 +19,33 @@ export interface OutboxJobSpec {
19
19
  * name without one does not type-check as an `OutboxJobName` (`add` does not check it at runtime).
20
20
  */
21
21
  export declare const OUTBOX_JOBS: {
22
+ readonly "trigger-dispatch": {
23
+ readonly queue: "cap-kernel-maintenance";
24
+ readonly idempotent: "Dispatches one stored event by id; the dispatcher reads the event's state and delivers each automation at most once (deliveries keyed by automation and event)";
25
+ readonly processedIn: "packages/kernel/src/runtime/maintenance.ts";
26
+ readonly opts: {
27
+ readonly attempts: 10;
28
+ readonly backoff: {
29
+ readonly type: "exponential";
30
+ readonly delay: 5000;
31
+ };
32
+ readonly removeOnComplete: true;
33
+ };
34
+ };
35
+ readonly "automation-coalesce": {
36
+ readonly queue: "cap-kernel-maintenance";
37
+ readonly idempotent: "Flushes the pair's deliveries still waiting for a run under the automation row lock; a repeat finds none and records nothing";
38
+ readonly processedIn: "packages/kernel/src/runtime/maintenance.ts";
39
+ readonly opts: {
40
+ readonly attempts: 10;
41
+ readonly backoff: {
42
+ readonly type: "exponential";
43
+ readonly delay: 5000;
44
+ };
45
+ readonly removeOnComplete: true;
46
+ readonly removeOnFail: true;
47
+ };
48
+ };
22
49
  readonly "share-object-delete": {
23
50
  readonly queue: "cap-kernel-maintenance";
24
51
  readonly idempotent: "Deletes one object key; deleting a missing object is a no-op";
@@ -326,7 +353,7 @@ export declare const OUTBOX_JOBS: {
326
353
  readonly removeOnFail: true;
327
354
  };
328
355
  };
329
- readonly "sched-fire": {
356
+ readonly "automation-fire": {
330
357
  readonly queue: "cap-kernel-maintenance";
331
358
  readonly idempotent: "a fire acts only on a pending task run, under its row lock; a retried start reuses what the first one made";
332
359
  readonly processedIn: "packages/kernel/src/runtime/maintenance.ts";
@@ -340,7 +367,7 @@ export declare const OUTBOX_JOBS: {
340
367
  readonly removeOnFail: true;
341
368
  };
342
369
  };
343
- readonly "sched-settle": {
370
+ readonly "automation-settle": {
344
371
  readonly queue: "cap-kernel-maintenance";
345
372
  readonly idempotent: "a check acts only on a task run still pending (claimed for the claimed check, unclaimed for the unfired one), under the task and run row locks, so a run claimed, started, ended or skipped since is left as it is";
346
373
  readonly processedIn: "packages/kernel/src/runtime/maintenance.ts";
@@ -21,6 +21,29 @@ const SCOPE_JOB_OPTS = {
21
21
  * name without one does not type-check as an `OutboxJobName` (`add` does not check it at runtime).
22
22
  */
23
23
  export const OUTBOX_JOBS = {
24
+ // `automations/job-ids.ts` TRIGGER_DISPATCH_JOB: owed by the transaction that stores a trigger
25
+ // event (`TriggerEventsService.emit`, collaboration spec §4.2), under `trigger-dispatch-<eventId>`
26
+ "trigger-dispatch": {
27
+ queue: "cap-kernel-maintenance",
28
+ idempotent: "Dispatches one stored event by id; the dispatcher reads the event's state and delivers each automation at most once (deliveries keyed by automation and event)",
29
+ processedIn: "packages/kernel/src/runtime/maintenance.ts",
30
+ opts: { attempts: 10, backoff: { type: "exponential", delay: 5000 }, removeOnComplete: true },
31
+ },
32
+ // `automations/job-ids.ts` AUTOMATION_COALESCE_JOB: owed by the dispatch that opens a window of
33
+ // events for one (automation, subject) pair (`TriggerDispatcher`, collaboration spec §4.7), under
34
+ // `<coalesceJobId(automation, subject)>-<first event id>`, due when the window closes
35
+ "automation-coalesce": {
36
+ queue: "cap-kernel-maintenance",
37
+ idempotent: "Flushes the pair's deliveries still waiting for a run under the automation row lock; a repeat finds none and records nothing",
38
+ processedIn: "packages/kernel/src/runtime/maintenance.ts",
39
+ // removed once done, so a later window's add is never swallowed by a kept job
40
+ opts: {
41
+ attempts: 10,
42
+ backoff: { type: "exponential", delay: 5000 },
43
+ removeOnComplete: true,
44
+ removeOnFail: true,
45
+ },
46
+ },
24
47
  // `shares/share-objects.ts` SHARE_OBJECT_DELETE_JOB: owed by a share's refresh (the previous
25
48
  // generation) and revoke (the current one), under `shareObjectDeleteJobId` (file sharing spec §2)
26
49
  "share-object-delete": {
@@ -287,9 +310,9 @@ export const OUTBOX_JOBS = {
287
310
  removeOnFail: true,
288
311
  },
289
312
  },
290
- // `schedules/job-ids.ts` SCHED_FIRE_JOB: owed by the transaction that writes a pending task run
291
- // (the scan's tick, a person's "run now"), under `schedFireJobId` (spec §8.1)
292
- "sched-fire": {
313
+ // `automations/job-ids.ts` AUTOMATION_FIRE_JOB: owed by the transaction that writes a pending task run
314
+ // (the scan's tick, a person's "run now"), under `automationFireJobId` (spec §8.1)
315
+ "automation-fire": {
293
316
  queue: "cap-kernel-maintenance",
294
317
  idempotent: "a fire acts only on a pending task run, under its row lock; a retried start reuses what the first one made",
295
318
  processedIn: "packages/kernel/src/runtime/maintenance.ts",
@@ -301,11 +324,11 @@ export const OUTBOX_JOBS = {
301
324
  removeOnFail: true,
302
325
  },
303
326
  },
304
- // `schedules/job-ids.ts` SCHED_SETTLE_JOB: the claimed check, owed by the fire job's claim (the
305
- // transaction that writes `fired_at`) with `runAt` 10 min on, under `schedSettleJobId` (a run
327
+ // `automations/job-ids.ts` AUTOMATION_SETTLE_JOB: the claimed check, owed by the fire job's claim (the
328
+ // transaction that writes `fired_at`) with `runAt` 10 min on, under `automationSettleJobId` (a run
306
329
  // still in flight owes the next check an hour on); the unfired check, owed with the task run
307
- // (scan tick, "run now") under `schedSettleUnfiredJobId` (ruling R26)
308
- "sched-settle": {
330
+ // (scan tick, "run now") under `automationSettleUnfiredJobId` (ruling R26)
331
+ "automation-settle": {
309
332
  queue: "cap-kernel-maintenance",
310
333
  idempotent: "a check acts only on a task run still pending (claimed for the claimed check, unclaimed for the unfired one), under the task and run row locks, so a run claimed, started, ended or skipped since is left as it is",
311
334
  processedIn: "packages/kernel/src/runtime/maintenance.ts",
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var KernelAppOptionsModule_1, KernelModule_1;
8
8
  import { Global, Module } from "@nestjs/common";
9
9
  import { APP_INTERCEPTOR } from "@nestjs/core";
10
+ import { TriggerEventsModule } from "./automations/events/events.module.js";
10
11
  import { CatalogModule } from "./catalog/catalog.module.js";
11
12
  import { ChannelsModule } from "./channels/channels.module.js";
12
13
  import { ClientModule } from "./client/client.module.js";
@@ -131,6 +132,8 @@ let KernelModule = KernelModule_1 = class KernelModule {
131
132
  ClientModule,
132
133
  // ctx.deviceAccess: extensions' device services (the host finds it at the time of use)
133
134
  ExtensionDeviceAccessModule,
135
+ // ctx.triggers: the events extensions emit (the host finds it at the time of use)
136
+ TriggerEventsModule,
134
137
  // the Platform tool's operation registry and actor facts
135
138
  PlatformModule,
136
139
  // its operations (skills, agents, ...), registered at start on every role
@@ -4,7 +4,7 @@ export type OrgRole = (typeof ORG_ROLES)[number];
4
4
  /** `role` 是否不低于 `min`。 */
5
5
  export declare function roleAtLeast(role: OrgRole, min: OrgRole): boolean;
6
6
  /** 组织级动作;路由用 `@OrgAction(action)` 声明所需动作。 */
7
- export type OrgAction = "org.read" | "org.update" | "org.delete" | "org.transfer" | "org.members.read" | "org.members.manage" | "org.invitations.manage" | "org.tokens.manage" | "org.extensions.read" | "org.extensions.manage" | "agents.create" | "agents.use" | "agents.manage" | "conversations.compact" | "connectors.manage" | "connectors.use" | "approvals.decide" | "channels.manage" | "skills.read" | "skills.manage" | "ui.use" | "trajectories.read" | "evals.manage" | "org.models.manage" | "catalog.read" | "catalog.request" | "catalog.decide" | "catalog.upload" | "schedules.use" | "schedules.manage";
7
+ export type OrgAction = "org.read" | "org.update" | "org.delete" | "org.transfer" | "org.members.read" | "org.members.manage" | "org.invitations.manage" | "org.tokens.manage" | "org.extensions.read" | "org.extensions.manage" | "agents.create" | "agents.use" | "agents.manage" | "conversations.compact" | "connectors.manage" | "connectors.use" | "approvals.decide" | "channels.manage" | "skills.read" | "skills.manage" | "ui.use" | "trajectories.read" | "evals.manage" | "org.models.manage" | "catalog.read" | "catalog.request" | "catalog.decide" | "catalog.upload" | "automations.use" | "automations.manage";
8
8
  /** 每个动作所需的最低角色。 */
9
9
  export declare const ACTION_MIN_ROLE: Record<OrgAction, OrgRole>;
10
10
  /** 只允许 user principal 执行的动作:服务令牌即使角色足够也拒绝(除 SERVICE_ALLOWED 外全部)。 */
@@ -49,10 +49,10 @@ export const ACTION_MIN_ROLE = {
49
49
  "catalog.decide": "admin",
50
50
  // An org admin uploads a plugin package the org owns (spec §14.1 item 1, ruling P3-7)
51
51
  "catalog.upload": "admin",
52
- // Scheduled tasks (spec 2026-11-11 §10): create, edit, pause, resume, run and delete one's own
53
- "schedules.use": "member",
52
+ // Automations (spec 2026-11-11 §10): create, edit, pause, resume, run and delete one's own
53
+ "automations.use": "member",
54
54
  // list every task of the org, pause, resume and delete any (never edit another person's)
55
- "schedules.manage": "admin",
55
+ "automations.manage": "admin",
56
56
  };
57
57
  /** 服务令牌也可执行的动作:只读的 org.read、org.members.read,以及使用 agent 的 agents.use。 */
58
58
  const SERVICE_ALLOWED = new Set([
@@ -7,7 +7,7 @@ import { type OrgEffectiveNetwork, type OrgSandboxLimits, type OrgSettingsDeploy
7
7
  * 以及只读的 `sandboxLimits`(组织实际生效的沙箱 cpu / 内存与来源,超级管理员在部署设置里覆盖,C19)。
8
8
  */
9
9
  type SettingsResponse = {
10
- /** `scheduledTasks.forbiddenToolsUnreadable: true` when the stored list cannot be read. */
10
+ /** `automations.forbiddenToolsUnreadable: true` when the stored list cannot be read. */
11
11
  settings: OrgSettingsView;
12
12
  deployment: OrgSettingsDeployment;
13
13
  /** The org's effective sandbox-mode network (org egress ceiling spec §D4). */
@@ -77,12 +77,12 @@ export type OrgThemeSetting = z.infer<typeof OrgThemeSettingSchema>;
77
77
  /** The theme setting of an org that has none: follow the platform, personal picks allowed. */
78
78
  export declare const DEFAULT_ORG_THEME: OrgThemeSetting;
79
79
  /**
80
- * Org settings of scheduled tasks (spec §9); every field reads leniently (invalid = default,
80
+ * Org settings of automations (spec §9); every field reads leniently (invalid = default,
81
81
  * except `forbiddenTools`, which keeps its valid entries). A stored `forbiddenTools` that is not a
82
82
  * list (or a group that is not an object) reads as `[]` here, for display; enforcement checks
83
83
  * {@link invalidStoredForbiddenTools} and fails unattended runs instead (never wider).
84
84
  */
85
- export declare const ScheduledTasksSettingsSchema: z.ZodObject<{
85
+ export declare const AutomationsSettingsSchema: z.ZodObject<{
86
86
  enabled: z.ZodCatch<z.ZodDefault<z.ZodBoolean>>;
87
87
  minIntervalMinutes: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
88
88
  maxTasksPerMember: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
@@ -95,14 +95,18 @@ export declare const ScheduledTasksSettingsSchema: z.ZodObject<{
95
95
  wait: "wait";
96
96
  }>>>;
97
97
  pauseAfterFailures: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
98
+ maxEventDepth: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
99
+ coalesceSeconds: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
100
+ maxEventRunsPerSubjectPerHour: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
101
+ eventSourcesOff: z.ZodCatch<z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodString>>, unknown>>;
98
102
  forbiddenTools: z.ZodCatch<z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodString>>, unknown>>;
99
103
  }, z.core.$strip>;
100
- export type ScheduledTasksSettings = z.infer<typeof ScheduledTasksSettingsSchema>;
104
+ export type AutomationsSettings = z.infer<typeof AutomationsSettingsSchema>;
101
105
  /**
102
106
  * The PATCH form: a partial merge into the group (fields left out keep their stored value; see
103
107
  * `OrgSettingsService.update`). A field given replaces that field whole, `forbiddenTools` too.
104
108
  */
105
- export declare const ScheduledTasksPatchSchema: z.ZodObject<{
109
+ export declare const AutomationsPatchSchema: z.ZodObject<{
106
110
  enabled: z.ZodOptional<z.ZodBoolean>;
107
111
  minIntervalMinutes: z.ZodOptional<z.ZodNumber>;
108
112
  maxTasksPerMember: z.ZodOptional<z.ZodNumber>;
@@ -115,6 +119,10 @@ export declare const ScheduledTasksPatchSchema: z.ZodObject<{
115
119
  wait: "wait";
116
120
  }>>;
117
121
  pauseAfterFailures: z.ZodOptional<z.ZodNumber>;
122
+ maxEventDepth: z.ZodOptional<z.ZodNumber>;
123
+ coalesceSeconds: z.ZodOptional<z.ZodNumber>;
124
+ maxEventRunsPerSubjectPerHour: z.ZodOptional<z.ZodNumber>;
125
+ eventSourcesOff: z.ZodOptional<z.ZodArray<z.ZodString>>;
118
126
  forbiddenTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
119
127
  }, z.core.$strict>;
120
128
  /**
@@ -187,7 +195,7 @@ export declare const OrgSettingsSchema: z.ZodObject<{
187
195
  enabled: z.ZodOptional<z.ZodBoolean>;
188
196
  hostSources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
189
197
  }, z.core.$strip>>>;
190
- scheduledTasks: z.ZodCatch<z.ZodPrefault<z.ZodObject<{
198
+ automations: z.ZodCatch<z.ZodPrefault<z.ZodObject<{
191
199
  enabled: z.ZodCatch<z.ZodDefault<z.ZodBoolean>>;
192
200
  minIntervalMinutes: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
193
201
  maxTasksPerMember: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
@@ -200,6 +208,10 @@ export declare const OrgSettingsSchema: z.ZodObject<{
200
208
  wait: "wait";
201
209
  }>>>;
202
210
  pauseAfterFailures: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
211
+ maxEventDepth: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
212
+ coalesceSeconds: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
213
+ maxEventRunsPerSubjectPerHour: z.ZodCatch<z.ZodDefault<z.ZodNumber>>;
214
+ eventSourcesOff: z.ZodCatch<z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodString>>, unknown>>;
203
215
  forbiddenTools: z.ZodCatch<z.ZodPreprocess<z.ZodDefault<z.ZodArray<z.ZodString>>, unknown>>;
204
216
  }, z.core.$strip>>>;
205
217
  compaction: z.ZodCatch<z.ZodOptional<z.ZodObject<{
@@ -221,12 +233,12 @@ export declare const OrgSettingsSchema: z.ZodObject<{
221
233
  export type OrgSettings = z.infer<typeof OrgSettingsSchema>;
222
234
  /**
223
235
  * The settings as the responses carry them: {@link OrgSettings} plus
224
- * `scheduledTasks.forbiddenToolsUnreadable: true` when the stored list cannot be read
236
+ * `automations.forbiddenToolsUnreadable: true` when the stored list cannot be read
225
237
  * ({@link invalidStoredForbiddenTools}; `forbiddenTools` then reads `[]`), so the settings page
226
238
  * says so and saves the list. Never stored.
227
239
  */
228
240
  export type OrgSettingsView = OrgSettings & {
229
- scheduledTasks: OrgSettings["scheduledTasks"] & {
241
+ automations: OrgSettings["automations"] & {
230
242
  forbiddenToolsUnreadable?: true;
231
243
  };
232
244
  };
@@ -280,7 +292,7 @@ export declare const OrgSettingsPatchSchema: z.ZodObject<{
280
292
  }>;
281
293
  }, z.core.$strict>>>;
282
294
  uiArrangement: z.ZodOptional<z.ZodType<Partial<Record<"agent.detail.section" | "conversation.composer.frame" | "conversation.empty" | "conversation.panel" | "conversation.properties.section" | "conversation.tool-result.card" | "file.preview" | "org.page" | "org.settings.section" | "platform.page" | "shell.brand" | "shell.overlay", import("../ui/arrangement.js").UiArrangementEntry | null>>, unknown, z.core.$ZodTypeInternals<Partial<Record<"agent.detail.section" | "conversation.composer.frame" | "conversation.empty" | "conversation.panel" | "conversation.properties.section" | "conversation.tool-result.card" | "file.preview" | "org.page" | "org.settings.section" | "platform.page" | "shell.brand" | "shell.overlay", import("../ui/arrangement.js").UiArrangementEntry | null>>, unknown>>>;
283
- scheduledTasks: z.ZodOptional<z.ZodObject<{
295
+ automations: z.ZodOptional<z.ZodObject<{
284
296
  enabled: z.ZodOptional<z.ZodBoolean>;
285
297
  minIntervalMinutes: z.ZodOptional<z.ZodNumber>;
286
298
  maxTasksPerMember: z.ZodOptional<z.ZodNumber>;
@@ -293,6 +305,10 @@ export declare const OrgSettingsPatchSchema: z.ZodObject<{
293
305
  wait: "wait";
294
306
  }>>;
295
307
  pauseAfterFailures: z.ZodOptional<z.ZodNumber>;
308
+ maxEventDepth: z.ZodOptional<z.ZodNumber>;
309
+ coalesceSeconds: z.ZodOptional<z.ZodNumber>;
310
+ maxEventRunsPerSubjectPerHour: z.ZodOptional<z.ZodNumber>;
311
+ eventSourcesOff: z.ZodOptional<z.ZodArray<z.ZodString>>;
296
312
  forbiddenTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
297
313
  }, z.core.$strict>>;
298
314
  compaction: z.ZodOptional<z.ZodNullable<z.ZodObject<{
@@ -383,16 +399,16 @@ log?: Pick<KernelLogger, "debug">): Promise<OrgSettings>;
383
399
  /** Whether a stored settings object holds a `sandboxToolPolicy` this version reads as `ask`. */
384
400
  export declare function invalidStoredSandboxToolPolicy(raw: unknown): boolean;
385
401
  /**
386
- * Whether the stored scheduled-task `forbiddenTools` cannot be read: the group or the field is
402
+ * Whether the stored automation `forbiddenTools` cannot be read: the group or the field is
387
403
  * present but not an object / a list. Unattended runs of such an org fail
388
404
  * ({@link FORBIDDEN_TOOLS_UNREADABLE_ERROR}) rather than run with nothing forbidden. Invalid
389
405
  * entries inside a list are dropped instead (the valid ones stay forbidden).
390
406
  */
391
407
  export declare function invalidStoredForbiddenTools(raw: unknown): boolean;
392
408
  /** The refusal of an unattended run of an org whose `forbiddenTools` cannot be read. */
393
- export declare const FORBIDDEN_TOOLS_UNREADABLE_ERROR = "The organization's forbidden tool list for scheduled tasks is unreadable, so this scheduled run cannot continue; an org admin must save the list again in the organization's scheduled task settings.";
409
+ export declare const FORBIDDEN_TOOLS_UNREADABLE_ERROR = "The organization's forbidden tool list for automations is unreadable, so this scheduled run cannot continue; an org admin must save the list again in the organization's automation settings.";
394
410
  /** The refusal of a new task grant while the org's `forbiddenTools` cannot be read. */
395
- export declare const FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR = "The organization's forbidden tool list for scheduled tasks is unreadable, so no tool can be approved for a task now; an org admin must save the list again in the organization's scheduled task settings.";
411
+ export declare const FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR = "The organization's forbidden tool list for automations is unreadable, so no tool can be approved for a task now; an org admin must save the list again in the organization's automation settings.";
396
412
  /**
397
413
  * Logs (through `log`, at the caller's level) the security settings a stored value reads narrower
398
414
  * than written, with the org id.
@@ -94,22 +94,36 @@ export const DEFAULT_ORG_THEME = { id: null, personal: "allowed" };
94
94
  const posInt = (max, def) => z.number().int().min(1).max(max).default(def).catch(def);
95
95
  /** A stored `forbiddenTools` entry worth keeping: a tool key of the length the PATCH accepts. */
96
96
  const isForbiddenToolEntry = (v) => typeof v === "string" && v.length >= 1 && v.length <= 200;
97
+ /** A stored `eventSourcesOff` entry worth keeping: an extension name of the length the PATCH accepts. */
98
+ const isEventSourceEntry = (v) => typeof v === "string" && v.length >= 1 && v.length <= 214;
97
99
  /**
98
- * Org settings of scheduled tasks (spec §9); every field reads leniently (invalid = default,
100
+ * Org settings of automations (spec §9); every field reads leniently (invalid = default,
99
101
  * except `forbiddenTools`, which keeps its valid entries). A stored `forbiddenTools` that is not a
100
102
  * list (or a group that is not an object) reads as `[]` here, for display; enforcement checks
101
103
  * {@link invalidStoredForbiddenTools} and fails unattended runs instead (never wider).
102
104
  */
103
- export const ScheduledTasksSettingsSchema = z.object({
105
+ export const AutomationsSettingsSchema = z.object({
104
106
  enabled: z.boolean().default(true).catch(true),
105
107
  minIntervalMinutes: posInt(1_000_000, 60),
106
108
  maxTasksPerMember: posInt(1_000_000, 20),
107
109
  maxTasksPerOrg: posInt(1_000_000, 200),
110
+ // the runs one member's automations may start per hour (collaboration spec §4.7: per person)
108
111
  maxRunsPerHour: posInt(1_000_000, 60),
109
112
  defaultExpiryDays: z.number().int().min(1).max(36_500).nullable().default(null).catch(null),
110
113
  catchUpWindowMinutes: posInt(1_000_000, 60),
111
114
  unattendedAsk: z.enum(["fail", "wait"]).default("fail").catch("fail"),
112
115
  pauseAfterFailures: posInt(1000, 5),
116
+ // event automations (collaboration spec §4.7): the chain depth past which an event is stored
117
+ // but not dispatched, the window that coalesces one subject's events into one run, and how many
118
+ // runs (up to this many, not skipped) one automation may make for one subject per hour
119
+ maxEventDepth: posInt(1000, 8),
120
+ coalesceSeconds: posInt(86_400, 30),
121
+ maxEventRunsPerSubjectPerHour: posInt(1_000_000, 12),
122
+ // the trigger sources (extension names) whose events fire no automation of the org; an invalid
123
+ // entry is dropped, the valid ones stay off
124
+ eventSourcesOff: z
125
+ .preprocess((v) => (Array.isArray(v) ? v.filter(isEventSourceEntry).slice(0, 200) : v), z.array(z.string()).max(200).default([]))
126
+ .catch([]),
113
127
  // fail-safe: an invalid entry is dropped, the valid ones stay forbidden (never reset to []);
114
128
  // past the PATCH's 500 the list is truncated
115
129
  forbiddenTools: z
@@ -120,7 +134,7 @@ export const ScheduledTasksSettingsSchema = z.object({
120
134
  * The PATCH form: a partial merge into the group (fields left out keep their stored value; see
121
135
  * `OrgSettingsService.update`). A field given replaces that field whole, `forbiddenTools` too.
122
136
  */
123
- export const ScheduledTasksPatchSchema = z
137
+ export const AutomationsPatchSchema = z
124
138
  .object({
125
139
  enabled: z.boolean(),
126
140
  minIntervalMinutes: z.number().int().min(1).max(1_000_000),
@@ -131,6 +145,10 @@ export const ScheduledTasksPatchSchema = z
131
145
  catchUpWindowMinutes: z.number().int().min(1).max(1_000_000),
132
146
  unattendedAsk: z.enum(["fail", "wait"]),
133
147
  pauseAfterFailures: z.number().int().min(1).max(1000),
148
+ maxEventDepth: z.number().int().min(1).max(1000),
149
+ coalesceSeconds: z.number().int().min(1).max(86_400),
150
+ maxEventRunsPerSubjectPerHour: z.number().int().min(1).max(1_000_000),
151
+ eventSourcesOff: z.array(z.string().min(1).max(214)).max(200),
134
152
  forbiddenTools: z.array(z.string().min(1).max(200)).max(500),
135
153
  })
136
154
  .partial()
@@ -175,8 +193,8 @@ export const OrgSettingsSchema = z.object({
175
193
  uiArrangement: UiArrangementSchema.optional().catch(undefined),
176
194
  /** The org's git gateway switch and host sources; absent = on, sources chosen by default. */
177
195
  gitGateway: GitGatewaySettingSchema.optional().catch({ ...GIT_GATEWAY_INVALID }),
178
- /** Scheduled tasks (spec §9); the platform bounds clamp it, see `effectiveScheduleSettings`. */
179
- scheduledTasks: ScheduledTasksSettingsSchema.prefault({}).catch(ScheduledTasksSettingsSchema.parse({})),
196
+ /** Automations (spec §9); the platform bounds clamp it, see `effectiveAutomationSettings`. */
197
+ automations: AutomationsSettingsSchema.prefault({}).catch(AutomationsSettingsSchema.parse({})),
180
198
  /**
181
199
  * Conversation compaction overrides (context compaction spec §4.8): every field given wins, the
182
200
  * rest follow the platform; absent (or an invalid stored value) follows the platform entirely.
@@ -197,7 +215,7 @@ export const OrgSettingsSchema = z.object({
197
215
  const viewOf = (settings, raw) => invalidStoredForbiddenTools(raw)
198
216
  ? {
199
217
  ...settings,
200
- scheduledTasks: { ...settings.scheduledTasks, forbiddenToolsUnreadable: true },
218
+ automations: { ...settings.automations, forbiddenToolsUnreadable: true },
201
219
  }
202
220
  : settings;
203
221
  /** PATCH 体:只改给出的字段;未知字段 → 400。 */
@@ -237,8 +255,8 @@ export const OrgSettingsPatchSchema = z
237
255
  * null removes a slot's entry (it follows the platform again). `platform.page` is refused.
238
256
  */
239
257
  uiArrangement: OrgUiArrangementPatchSchema.optional(),
240
- /** Fields to change in the scheduled-tasks group; the rest keep their value. */
241
- scheduledTasks: ScheduledTasksPatchSchema.optional(),
258
+ /** Fields to change in the automations group; the rest keep their value. */
259
+ automations: AutomationsPatchSchema.optional(),
242
260
  /**
243
261
  * Conversation compaction overrides (context compaction spec §4.8): a partial object merges
244
262
  * into the stored fields (absent fields keep their value); null clears the whole override
@@ -324,13 +342,13 @@ export function invalidStoredSandboxToolPolicy(raw) {
324
342
  return v !== undefined && !OrgSettingsPatchSchema.shape.sandboxToolPolicy.safeParse(v).success;
325
343
  }
326
344
  /**
327
- * Whether the stored scheduled-task `forbiddenTools` cannot be read: the group or the field is
345
+ * Whether the stored automation `forbiddenTools` cannot be read: the group or the field is
328
346
  * present but not an object / a list. Unattended runs of such an org fail
329
347
  * ({@link FORBIDDEN_TOOLS_UNREADABLE_ERROR}) rather than run with nothing forbidden. Invalid
330
348
  * entries inside a list are dropped instead (the valid ones stay forbidden).
331
349
  */
332
350
  export function invalidStoredForbiddenTools(raw) {
333
- const group = asObject(raw).scheduledTasks;
351
+ const group = asObject(raw).automations;
334
352
  if (group === undefined)
335
353
  return false;
336
354
  if (group === null || typeof group !== "object" || Array.isArray(group))
@@ -339,9 +357,9 @@ export function invalidStoredForbiddenTools(raw) {
339
357
  return v !== undefined && !Array.isArray(v);
340
358
  }
341
359
  /** The refusal of an unattended run of an org whose `forbiddenTools` cannot be read. */
342
- export const FORBIDDEN_TOOLS_UNREADABLE_ERROR = "The organization's forbidden tool list for scheduled tasks is unreadable, so this scheduled run cannot continue; an org admin must save the list again in the organization's scheduled task settings.";
360
+ export const FORBIDDEN_TOOLS_UNREADABLE_ERROR = "The organization's forbidden tool list for automations is unreadable, so this scheduled run cannot continue; an org admin must save the list again in the organization's automation settings.";
343
361
  /** The refusal of a new task grant while the org's `forbiddenTools` cannot be read. */
344
- export const FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR = "The organization's forbidden tool list for scheduled tasks is unreadable, so no tool can be approved for a task now; an org admin must save the list again in the organization's scheduled task settings.";
362
+ export const FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR = "The organization's forbidden tool list for automations is unreadable, so no tool can be approved for a task now; an org admin must save the list again in the organization's automation settings.";
345
363
  /**
346
364
  * Logs (through `log`, at the caller's level) the security settings a stored value reads narrower
347
365
  * than written, with the org id.
@@ -351,7 +369,7 @@ export function logUnreadableSecuritySettings(log, orgId, raw) {
351
369
  log("org settings: stored sandboxToolPolicy is invalid; it reads as ask", { orgId });
352
370
  }
353
371
  if (invalidStoredForbiddenTools(raw)) {
354
- log("org settings: stored scheduledTasks.forbiddenTools is unreadable; unattended runs fail until an org admin saves it again", { orgId });
372
+ log("org settings: stored automations.forbiddenTools is unreadable; unattended runs fail until an org admin saves it again", { orgId });
355
373
  }
356
374
  }
357
375
  const outsideSandboxNotAllowed = (message) => new ApiError("org.outside_sandbox_not_allowed", message);
@@ -694,13 +712,13 @@ let OrgSettingsService = class OrgSettingsService {
694
712
  const arrangementPatch = patch.uiArrangement;
695
713
  const compactionPatch = patch.compaction;
696
714
  delete changes.uiArrangement;
697
- delete changes.scheduledTasks;
715
+ delete changes.automations;
698
716
  delete changes.compaction;
699
717
  const after = { ...before, ...changes };
700
- if (patch.scheduledTasks !== undefined) {
701
- after.scheduledTasks = ScheduledTasksSettingsSchema.parse({
702
- ...before.scheduledTasks,
703
- ...Object.fromEntries(Object.entries(patch.scheduledTasks).filter(([, v]) => v !== undefined)),
718
+ if (patch.automations !== undefined) {
719
+ after.automations = AutomationsSettingsSchema.parse({
720
+ ...before.automations,
721
+ ...Object.fromEntries(Object.entries(patch.automations).filter(([, v]) => v !== undefined)),
704
722
  });
705
723
  }
706
724
  if (compactionPatch !== undefined) {
@@ -747,7 +765,7 @@ let OrgSettingsService = class OrgSettingsService {
747
765
  if (after.promptSuggestions === undefined)
748
766
  delete after.promptSuggestions;
749
767
  // saving an unreadable security setting writes it even when it equals what it read as
750
- const repairs = (invalidStoredForbiddenTools(stored) && patch.scheduledTasks?.forbiddenTools !== undefined) ||
768
+ const repairs = (invalidStoredForbiddenTools(stored) && patch.automations?.forbiddenTools !== undefined) ||
751
769
  (invalidStoredSandboxToolPolicy(stored) && patch.sandboxToolPolicy !== undefined);
752
770
  if (!repairs && sameSettings(before, after))
753
771
  return viewOf(before, stored);
@@ -758,15 +776,15 @@ let OrgSettingsService = class OrgSettingsService {
758
776
  }
759
777
  // Merge with the stored value: keep the keys this version does not know (a cleared
760
778
  // outsideSandbox / deviceNetwork is not kept; the old keys are rewritten in step)
761
- const { autoMode: _legacyAutoMode, fullAccess: _legacyFullAccess, cloudNetwork: _legacyNetwork, outsideSandbox: _oldOutside, deviceNetwork: _oldNetwork, deviceDefaultProvider: _oldDeviceProvider, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, scheduledTasks: _oldScheduled, compaction: _oldCompaction, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
779
+ const { autoMode: _legacyAutoMode, fullAccess: _legacyFullAccess, cloudNetwork: _legacyNetwork, outsideSandbox: _oldOutside, deviceNetwork: _oldNetwork, deviceDefaultProvider: _oldDeviceProvider, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, automations: _oldAutomations, compaction: _oldCompaction, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
762
780
  const written = { ...rest, ...after };
763
781
  keepOrgLegacyKeysInStep(written, stored);
764
782
  // An unreadable forbiddenTools reads as [] for display only: a write that does not replace the
765
783
  // list keeps it unreadable (never healed to "nothing forbidden"); saving the list fixes it
766
- if (invalidStoredForbiddenTools(stored) && patch.scheduledTasks?.forbiddenTools === undefined) {
767
- const group = asObject(stored.scheduledTasks);
768
- written.scheduledTasks = {
769
- ...after.scheduledTasks,
784
+ if (invalidStoredForbiddenTools(stored) && patch.automations?.forbiddenTools === undefined) {
785
+ const group = asObject(stored.automations);
786
+ written.automations = {
787
+ ...after.automations,
770
788
  forbiddenTools: group.forbiddenTools ?? null,
771
789
  };
772
790
  }
@@ -92,8 +92,8 @@ export const PLATFORM_DOMAINS = [
92
92
  description: "Your own cloud devices (the workspaces your conversations run in): list, read, create, rename, narrow the sandbox network, delete, wipe the files.",
93
93
  },
94
94
  {
95
- id: "schedules",
96
- description: "Your scheduled tasks (an agent runs a prompt on a schedule, as you, unattended): list, read, create, edit, pause, resume, delete, run now or as a trial, run history, and the tools approved for a task.",
95
+ id: "automations",
96
+ description: "Your automations (an agent runs a prompt on a schedule, as you, unattended): list, read, create, edit, pause, resume, delete, run now or as a trial, run history, and the tools approved for a task.",
97
97
  },
98
98
  {
99
99
  id: "setup",
@@ -1,18 +1,18 @@
1
1
  import { type OnModuleInit } from "@nestjs/common";
2
- import { ScheduledTasksService } from "../../schedules/scheduled-tasks.service.js";
2
+ import { AutomationsService } from "../../automations/automations.service.js";
3
3
  import { PlatformOperations } from "../registry.js";
4
4
  /**
5
- * Scheduled-task operations of the `Platform` tool (scheduled tasks spec §10): the same service
5
+ * Automation operations of the `Platform` tool (scheduled tasks spec §10): the same service
6
6
  * as the HTTP routes. Writes are `personal`. Creating or changing a task and its approved tools
7
7
  * are never remembered (`rememberable: false`): an approval, remembered or granted to a task,
8
8
  * must never let an unattended run create or widen a task. Delete, run and resume are never
9
9
  * remembered either. List, pause and delete are `org.read` like their routes: a creator demoted
10
10
  * to guest can still see and stop their own tasks (the service decides by ownership).
11
11
  */
12
- export declare class SchedulesOperations implements OnModuleInit {
12
+ export declare class AutomationsOperations implements OnModuleInit {
13
13
  private readonly registry;
14
14
  private readonly tasks;
15
- constructor(registry: PlatformOperations, tasks: ScheduledTasksService);
15
+ constructor(registry: PlatformOperations, tasks: AutomationsService);
16
16
  /** The caller as the service expects (it reads the live role itself). */
17
17
  private actor;
18
18
  /** The task's name for a card; its id when it cannot be read. */