@capybara-hq/kernel 0.1.0-rc.104 → 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 (250) 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 +103 -25
  66. package/dist/conversations/conversations.service.js +138 -33
  67. package/dist/conversations/events.d.ts +48 -1
  68. package/dist/conversations/events.js +61 -9
  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 +47 -13
  98. package/dist/errors.js +47 -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/handoff/app-schemes.d.ts +28 -0
  109. package/dist/handoff/app-schemes.js +41 -0
  110. package/dist/handoff/handoff-paths.d.ts +26 -0
  111. package/dist/handoff/handoff-paths.js +25 -0
  112. package/dist/handoff/handoff-tickets.d.ts +28 -0
  113. package/dist/handoff/handoff-tickets.js +111 -0
  114. package/dist/handoff/handoff.controller.d.ts +24 -0
  115. package/dist/handoff/handoff.controller.js +74 -0
  116. package/dist/handoff/handoff.module.d.ts +7 -0
  117. package/dist/handoff/handoff.module.js +26 -0
  118. package/dist/handoff/handoff.schemas.d.ts +13 -0
  119. package/dist/handoff/handoff.schemas.js +3 -0
  120. package/dist/handoff/handoff.service.d.ts +49 -0
  121. package/dist/handoff/handoff.service.js +96 -0
  122. package/dist/http/api.module.js +13 -5
  123. package/dist/http/meta.controller.d.ts +1 -0
  124. package/dist/http/meta.controller.js +7 -0
  125. package/dist/http/request-signal.d.ts +8 -0
  126. package/dist/http/request-signal.js +14 -0
  127. package/dist/identity/sso.controller.d.ts +30 -6
  128. package/dist/identity/sso.controller.js +51 -17
  129. package/dist/identity/sso.d.ts +10 -2
  130. package/dist/identity/sso.js +15 -3
  131. package/dist/inbox/inbox.module.js +2 -2
  132. package/dist/inbox/inbox.service.d.ts +8 -8
  133. package/dist/inbox/inbox.service.js +7 -7
  134. package/dist/infra/config/kernel-config.service.js +10 -5
  135. package/dist/infra/outbox/registry.d.ts +29 -2
  136. package/dist/infra/outbox/registry.js +30 -7
  137. package/dist/kernel.module.js +3 -0
  138. package/dist/orgs/roles.d.ts +1 -1
  139. package/dist/orgs/roles.js +3 -3
  140. package/dist/orgs/settings.controller.d.ts +1 -1
  141. package/dist/orgs/settings.service.d.ts +27 -11
  142. package/dist/orgs/settings.service.js +42 -24
  143. package/dist/overrides.d.ts +4 -4
  144. package/dist/overrides.js +1 -1
  145. package/dist/platform/exclusions.js +5 -0
  146. package/dist/platform/operation.js +2 -2
  147. package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
  148. package/dist/platform/ops/automations.ops.js +560 -0
  149. package/dist/platform/ops/connectors.ops.js +4 -2
  150. package/dist/platform/ops/devices.ops.d.ts +3 -1
  151. package/dist/platform/ops/devices.ops.js +77 -3
  152. package/dist/platform/ops/inbox.ops.js +4 -4
  153. package/dist/platform/ops/orgs.ops.js +1 -1
  154. package/dist/platform/ops/platform.ops.js +4 -4
  155. package/dist/platform/platform-ops.module.d.ts +2 -2
  156. package/dist/platform/platform-ops.module.js +5 -5
  157. package/dist/platform/route-schemas.js +3 -3
  158. package/dist/push/jobs.d.ts +3 -3
  159. package/dist/push/jobs.js +2 -2
  160. package/dist/push/preferences.service.js +1 -1
  161. package/dist/push/push-owed.d.ts +3 -3
  162. package/dist/push/push-owed.js +6 -6
  163. package/dist/push/push.schemas.d.ts +4 -4
  164. package/dist/push/push.schemas.js +3 -3
  165. package/dist/push/recipients.d.ts +4 -4
  166. package/dist/push/recipients.js +23 -23
  167. package/dist/push/texts.d.ts +3 -3
  168. package/dist/push/texts.js +2 -2
  169. package/dist/push/triggers.d.ts +1 -1
  170. package/dist/roles/worker.module.js +3 -3
  171. package/dist/runtime/compaction.service.d.ts +3 -1
  172. package/dist/runtime/compaction.service.js +3 -1
  173. package/dist/runtime/context/build.d.ts +6 -0
  174. package/dist/runtime/context/build.js +14 -3
  175. package/dist/runtime/context/compaction.d.ts +27 -1
  176. package/dist/runtime/context/compaction.js +102 -37
  177. package/dist/runtime/context/run-context.d.ts +38 -0
  178. package/dist/runtime/context/run-context.js +54 -0
  179. package/dist/runtime/maintenance.d.ts +8 -4
  180. package/dist/runtime/maintenance.js +37 -16
  181. package/dist/runtime/model-call.d.ts +6 -4
  182. package/dist/runtime/model-call.js +17 -7
  183. package/dist/runtime/project/knowledge.service.d.ts +16 -7
  184. package/dist/runtime/project/knowledge.service.js +31 -13
  185. package/dist/runtime/run-finish.d.ts +4 -4
  186. package/dist/runtime/run-finish.js +3 -3
  187. package/dist/runtime/run-queue.js +12 -7
  188. package/dist/runtime/run-worker.js +7 -1
  189. package/dist/runtime/runtime.module.js +3 -3
  190. package/dist/runtime/subagents/dispatch.js +11 -3
  191. package/dist/sandbox/browse-roots.d.ts +8 -0
  192. package/dist/sandbox/browse-roots.js +22 -0
  193. package/dist/sandbox/network-grants.d.ts +4 -4
  194. package/dist/sandbox/network-grants.js +7 -7
  195. package/dist/sandbox/operation-authority.d.ts +10 -3
  196. package/dist/sandbox/operation-authority.js +20 -10
  197. package/dist/sandbox/operation-intents.d.ts +3 -1
  198. package/dist/sandbox/operation-intents.js +11 -4
  199. package/dist/sandbox/permission-call-grants.js +2 -2
  200. package/dist/sandbox/permission-facts.js +1 -1
  201. package/dist/sandbox/review/classifier.d.ts +2 -2
  202. package/dist/sandbox/review/classifier.js +22 -11
  203. package/dist/sandbox/review/permission-candidate.d.ts +1 -1
  204. package/dist/sandbox/review/permission-candidate.js +1 -1
  205. package/dist/sandbox/sandbox.service.d.ts +15 -5
  206. package/dist/sandbox/sandbox.service.js +14 -8
  207. package/dist/storage/purge.d.ts +1 -1
  208. package/dist/storage/purge.js +2 -2
  209. package/dist/tools/approvals.service.d.ts +6 -6
  210. package/dist/tools/approvals.service.js +19 -19
  211. package/dist/tools/builtin-names.d.ts +12 -12
  212. package/dist/tools/builtin-names.js +29 -29
  213. package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
  214. package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
  215. package/dist/tools/builtins/builtin-tools.d.ts +8 -8
  216. package/dist/tools/builtins/builtin-tools.js +16 -16
  217. package/dist/tools/call-scope.d.ts +1 -1
  218. package/dist/tools/connectors.service.d.ts +4 -13
  219. package/dist/tools/connectors.service.js +12 -21
  220. package/dist/tools/git-asks.js +1 -1
  221. package/dist/tools/git-push-policy.d.ts +3 -3
  222. package/dist/tools/git-push-policy.js +6 -6
  223. package/dist/tools/network-asks.d.ts +3 -3
  224. package/dist/tools/network-asks.js +3 -3
  225. package/dist/tools/oauth/flow.d.ts +16 -2
  226. package/dist/tools/oauth/flow.js +23 -4
  227. package/dist/tools/oauth/oauth.controller.d.ts +19 -7
  228. package/dist/tools/oauth/oauth.controller.js +42 -12
  229. package/dist/tools/oauth/oauth.schemas.d.ts +14 -1
  230. package/dist/tools/oauth/oauth.schemas.js +4 -1
  231. package/dist/tools/pipeline.d.ts +4 -4
  232. package/dist/tools/pipeline.js +2 -2
  233. package/dist/tools/policy.d.ts +3 -3
  234. package/dist/tools/policy.js +3 -3
  235. package/dist/tools/tools.module.js +9 -9
  236. package/package.json +3 -3
  237. package/src/migrations/0188_automations_rename.sql +309 -0
  238. package/src/migrations/0189_event_automations.sql +136 -0
  239. package/dist/platform/ops/schedules.ops.js +0 -509
  240. package/dist/schedules/effective-settings.d.ts +0 -22
  241. package/dist/schedules/effective-settings.js +0 -18
  242. package/dist/schedules/errors.d.ts +0 -8
  243. package/dist/schedules/errors.js +0 -8
  244. package/dist/schedules/job-ids.d.ts +0 -81
  245. package/dist/schedules/job-ids.js +0 -95
  246. package/dist/schedules/schedules.module.d.ts +0 -16
  247. package/dist/schedules/schedules.schemas.js +0 -213
  248. package/dist/schedules/store.module.d.ts +0 -6
  249. package/dist/schedules/types.d.ts +0 -110
  250. /package/dist/{schedules → automations}/types.js +0 -0
@@ -1,7 +1,10 @@
1
+ import { type EventFilter, type LocalizedName, type TriggerEventDeclaration } from "@capybara-hq/plugin-sdk";
1
2
  import { AgentLookup } from "../agents/agent-lookup.js";
2
3
  import type { ModelRef } from "../agents/definition.js";
3
4
  import { ConversationAccess } from "../conversations/access.js";
4
5
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
6
+ import { ExtensionDisplayNames } from "../extensions/display-name.js";
7
+ import { ExtensionPointDefaults } from "../extensions/point-defaults.js";
5
8
  import { ExtensionRegistry } from "../extensions/registry.js";
6
9
  import { type PersonRef } from "../identity/account-avatar.js";
7
10
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
@@ -15,26 +18,40 @@ import { SandboxService } from "../sandbox/sandbox.service.js";
15
18
  import { ToolRegistry } from "../tools/registry.js";
16
19
  import { type CalendarAnswer, type CalendarLimits } from "./calendar.js";
17
20
  import { type GrantContext, type GrantRefusalCode, grantRefusal, grantRefusalOf, networkGrantRefusal } from "./grant-rules.js";
18
- import { ScheduledTaskStore } from "./store.js";
19
- import type { ScheduleChat, ScheduledTask, ScheduledTaskGrant, ScheduleMode, SchedulePauseReason, TaskRun } from "./types.js";
21
+ import { AutomationStore } from "./store.js";
22
+ import type { Automation, AutomationChat, AutomationGrant, AutomationMode, AutomationPauseReason, AutomationUnattendedAsk, TaskRun } from "./types.js";
20
23
  export { type GrantContext, type GrantRefusalCode, grantRefusal, grantRefusalOf, networkGrantRefusal, };
21
- /** When a task fires, before the zone is fixed (spec §5). */
24
+ /**
25
+ * When a task fires, before the zone is fixed (spec §5); or on events of `types` from the
26
+ * extension `source` that match `filter` (absent: every event of the types).
27
+ */
22
28
  export type TriggerInput = {
23
29
  kind: "cron";
24
30
  expr: string;
25
31
  } | {
26
32
  kind: "once";
27
33
  at: string;
34
+ } | {
35
+ kind: "event";
36
+ source: string;
37
+ types: string[];
38
+ filter?: EventFilter;
28
39
  };
29
- /** A scheduled task that needs its creator's attention (spec §8): the inbox item's payload. */
30
- export interface ScheduleAttention {
40
+ /** One trigger source that serves an org, as the automation form offers it. */
41
+ export interface EventSourceView {
42
+ source: string;
43
+ name: LocalizedName;
44
+ events: TriggerEventDeclaration[];
45
+ }
46
+ /** An automation that needs its creator's attention (spec §8): the inbox item's payload. */
47
+ export interface AutomationAttention {
31
48
  taskId: string;
32
49
  name: string;
33
50
  /**
34
51
  * `missing_grants`: the latest run was refused tools or connections the task lacks; `failed`:
35
52
  * the latest settled run of an active task failed (its start included); else the pause reason.
36
53
  */
37
- reason: SchedulePauseReason | "missing_grants" | "failed";
54
+ reason: AutomationPauseReason | "missing_grants" | "failed";
38
55
  /** The person who paused the task (`reason: "admin"` names the admin); else null. */
39
56
  pausedBy: PersonRef | null;
40
57
  /**
@@ -72,11 +89,11 @@ export interface CreateTaskInput {
72
89
  trigger: TriggerInput;
73
90
  /** Absent: the creator's effective zone (account, browser, org, UTC). */
74
91
  timeZone?: string;
75
- mode: ScheduleMode;
92
+ mode: AutomationMode;
76
93
  /** `conversation` mode only. */
77
94
  conversationId?: string;
78
95
  /** `chat` mode only. */
79
- chat?: ScheduleChat;
96
+ chat?: AutomationChat;
80
97
  /**
81
98
  * `new` mode only (a conversation or chat task runs with that conversation's selection and
82
99
  * device): the model, which must resolve for the org, and an effort it declares.
@@ -85,15 +102,17 @@ export interface CreateTaskInput {
85
102
  effort?: string;
86
103
  deviceId?: string;
87
104
  /**
88
- * When the task ends; it must lie in the future. Absent or null: for a cron task, now + the
89
- * org's `defaultExpiryDays` when set; otherwise never.
105
+ * When the task ends; it must lie in the future. Absent or null: for a cron or event task, now +
106
+ * the org's `defaultExpiryDays` when set; otherwise never.
90
107
  */
91
108
  expiresAt?: Date | null;
92
109
  grants?: GrantInput[];
110
+ /** What a question in an unattended run does; absent or null: the org's default. */
111
+ unattendedAsk?: AutomationUnattendedAsk | null;
93
112
  }
94
113
  /**
95
114
  * Fields to change; `null` clears an optional one (`expiresAt: null` is the org's default expiry
96
- * for a cron task, as on create). Grants change through their own methods.
115
+ * for a cron or event task, as on create). Grants change through their own methods.
97
116
  */
98
117
  export interface UpdateTaskInput {
99
118
  agentId?: string;
@@ -101,27 +120,28 @@ export interface UpdateTaskInput {
101
120
  prompt?: string;
102
121
  trigger?: TriggerInput;
103
122
  timeZone?: string;
104
- mode?: ScheduleMode;
123
+ mode?: AutomationMode;
105
124
  conversationId?: string | null;
106
- chat?: ScheduleChat | null;
125
+ chat?: AutomationChat | null;
107
126
  model?: ModelRef | null;
108
127
  effort?: string | null;
109
128
  deviceId?: string | null;
110
129
  expiresAt?: Date | null;
130
+ unattendedAsk?: AutomationUnattendedAsk | null;
111
131
  }
112
132
  /**
113
133
  * Where a grant write comes from: `fromSession` only for a person in a signed-in web session (not a
114
- * personal access token, the Platform tool or the schedule tools). Network domains are approved
134
+ * personal access token, the Platform tool or the automation tools). Network domains are approved
115
135
  * only there (network ask-to-allow spec §8.1): an agent must never pre-approve a domain for itself.
116
136
  */
117
137
  export interface GrantWriteSource {
118
138
  fromSession?: boolean;
119
139
  }
120
140
  /** Who acts on a task: the service reads their live role itself and decides by that one. */
121
- export interface ScheduleActor {
141
+ export interface AutomationActor {
122
142
  accountId: string;
123
143
  }
124
- /** One of the agent's tools as the task form offers it (`GET …/schedules/grantable-tools`). */
144
+ /** One of the agent's tools as the task form offers it (`GET …/automations/grantable-tools`). */
125
145
  export interface GrantableTool {
126
146
  key: string;
127
147
  /** The tool's display title, when it declares one. */
@@ -136,7 +156,7 @@ export interface GrantableTool {
136
156
  * A grant as the task page shows it: `stale` when the tool's definition changed or the tool left
137
157
  * (spec §7); null when the agent's tools cannot be read now.
138
158
  */
139
- export interface ScheduledTaskGrantView extends ScheduledTaskGrant {
159
+ export interface AutomationGrantView extends AutomationGrant {
140
160
  stale: boolean | null;
141
161
  }
142
162
  /** The latest settled (completed, failed or skipped) non-trial run of a task. */
@@ -147,11 +167,11 @@ export interface TaskLastRun {
147
167
  at: Date;
148
168
  }
149
169
  /** A task in a list, with its latest settled run. */
150
- export type ScheduledTaskListItem = ScheduledTaskView & {
170
+ export type AutomationListItem = AutomationView & {
151
171
  lastRun: TaskLastRun | null;
152
172
  };
153
173
  /** A task with its creator as a person (null when the account is gone). */
154
- export type ScheduledTaskView = ScheduledTask & {
174
+ export type AutomationView = Automation & {
155
175
  account: PersonRef | null;
156
176
  };
157
177
  /**
@@ -171,16 +191,16 @@ export interface ChatTarget {
171
191
  label: string;
172
192
  }
173
193
  /**
174
- * Scheduled tasks for people (spec §5, §7–§10): create, edit, pause, resume, delete, their runs
194
+ * Automations for people (spec §5, §7–§10): create, edit, pause, resume, delete, their runs
175
195
  * and grants. Every write runs in one transaction under the org row lock (`OrgLock`), which also
176
196
  * serializes the per-member and per-org caps, re-reads the actor's role there, and holds the task
177
197
  * row (`FOR UPDATE`) so the scanner skips it until the write commits.
178
198
  *
179
- * Roles: `schedules.use` (member) creates and edits one's own tasks; `schedules.manage` (admin)
199
+ * Roles: `automations.use` (member) creates and edits one's own tasks; `automations.manage` (admin)
180
200
  * lists, pauses, resumes and deletes any task of the org, never edits another person's (the task
181
- * runs as its creator). A task the caller may not see is `schedule.not_found`.
201
+ * runs as its creator). A task the caller may not see is `automation.not_found`.
182
202
  */
183
- export declare class ScheduledTasksService {
203
+ export declare class AutomationsService {
184
204
  private readonly db;
185
205
  readonly txHost: TransactionHost;
186
206
  private readonly config;
@@ -197,43 +217,48 @@ export declare class ScheduledTasksService {
197
217
  private readonly outbox;
198
218
  /** Network grants: the org's sandbox-mode network (network ask-to-allow spec §8.1). */
199
219
  private readonly sandbox;
200
- constructor(db: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">, store: ScheduledTaskStore, orgLock: Pick<OrgLock, "lockAndAuthorize">, agents: Pick<AgentLookup, "get">, access: Pick<ConversationAccess, "isAccessible">, tools: Pick<ToolRegistry, "forAgent">, extensions: Pick<ExtensionRegistry, "list">,
220
+ /** Event automations: the trigger sources that serve an org (`trigger-source@1`). */
221
+ private readonly points;
222
+ private readonly displayNames;
223
+ constructor(db: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">, store: AutomationStore, orgLock: Pick<OrgLock, "lockAndAuthorize">, agents: Pick<AgentLookup, "get">, access: Pick<ConversationAccess, "isAccessible">, tools: Pick<ToolRegistry, "forAgent">, extensions: Pick<ExtensionRegistry, "list">,
201
224
  /** A task's model must resolve for the org and declare its effort (as a message's switch). */
202
225
  providers: Pick<ProviderRegistry, "resolve">, log: Pick<KernelLogger, "warn">,
203
226
  /** "Run now" owes the fire job (consumed by the worker role). */
204
227
  outbox: Pick<OutboxService, "add">,
205
228
  /** Network grants: the org's sandbox-mode network (network ask-to-allow spec §8.1). */
206
- sandbox: Pick<SandboxService, "ceilingLimits" | "devicePolicy">);
207
- create(orgId: string, accountId: string, input: CreateTaskInput, browserTimeZone?: string, source?: GrantWriteSource): Promise<ScheduledTask>;
208
- /** Creator only: an org admin gets `schedule.forbidden`, anyone else `schedule.not_found`. */
209
- update(orgId: string, accountId: string, id: string, patch: UpdateTaskInput): Promise<ScheduledTask>;
210
- /** The creator, or an org admin (`schedules.manage`); a task not active is returned as is. */
211
- pause(orgId: string, actor: ScheduleActor, id: string): Promise<ScheduledTask>;
229
+ sandbox: Pick<SandboxService, "ceilingLimits" | "devicePolicy">,
230
+ /** Event automations: the trigger sources that serve an org (`trigger-source@1`). */
231
+ points: Pick<ExtensionPointDefaults, "providersFor">, displayNames: Pick<ExtensionDisplayNames, "many">);
232
+ create(orgId: string, accountId: string, input: CreateTaskInput, browserTimeZone?: string, source?: GrantWriteSource): Promise<Automation>;
233
+ /** Creator only: an org admin gets `automation.forbidden`, anyone else `automation.not_found`. */
234
+ update(orgId: string, accountId: string, id: string, patch: UpdateTaskInput): Promise<Automation>;
235
+ /** The creator, or an org admin (`automations.manage`); a task not active is returned as is. */
236
+ pause(orgId: string, actor: AutomationActor, id: string): Promise<Automation>;
212
237
  /**
213
- * The creator (`schedules.use`), or an org admin. The next run is computed from now (missed ticks
238
+ * The creator (`automations.use`), or an org admin. The next run is computed from now (missed ticks
214
239
  * are not caught up) and the failure count starts over. An ended task cannot be resumed.
215
240
  */
216
- resume(orgId: string, actor: ScheduleActor, id: string): Promise<ScheduledTask>;
241
+ resume(orgId: string, actor: AutomationActor, id: string): Promise<Automation>;
217
242
  /** The creator, or an org admin. */
218
- remove(orgId: string, actor: ScheduleActor, id: string): Promise<void>;
243
+ remove(orgId: string, actor: AutomationActor, id: string): Promise<void>;
219
244
  /** The creator, or an org admin. */
220
- get(orgId: string, actor: ScheduleActor, id: string): Promise<ScheduledTaskView>;
245
+ get(orgId: string, actor: AutomationActor, id: string): Promise<AutomationView>;
221
246
  /** Each task with its creator as a person, in one query. */
222
247
  private withAccounts;
223
248
  /** The actor's own tasks; `all` (org admins only, else `forbidden`): every task of the org. */
224
- list(orgId: string, actor: ScheduleActor, opts?: {
249
+ list(orgId: string, actor: AutomationActor, opts?: {
225
250
  all?: boolean;
226
251
  conversationId?: string;
227
- }): Promise<ScheduledTaskListItem[]>;
252
+ }): Promise<AutomationListItem[]>;
228
253
  /**
229
254
  * The calendar between two instants (calendar spec §5): the runs and planned occurrences of the
230
255
  * actor's own tasks, or with `all` (org admins only, else `forbidden`) every task of the org; with
231
- * `taskId` only that task (one the actor may see, else `schedule.not_found`), never collapsed.
256
+ * `taskId` only that task (one the actor may see, else `automation.not_found`), never collapsed.
232
257
  * Another creator's runs come without `conversationId`, `error` and `missingGrants` (§15 Q3).
233
258
  * A range longer than 43 days (2 with `taskId`), or not forward, is `validation_failed`. `now`
234
259
  * is for tests.
235
260
  */
236
- calendar(orgId: string, actor: ScheduleActor, q: {
261
+ calendar(orgId: string, actor: AutomationActor, q: {
237
262
  from: Date;
238
263
  to: Date;
239
264
  timeZone: string;
@@ -247,10 +272,29 @@ export declare class ScheduledTasksService {
247
272
  private postingInto;
248
273
  /** Each task with its latest settled non-trial run, in one query. */
249
274
  private withLastRuns;
275
+ /**
276
+ * The trigger sources that serve the org now (`trigger-source@1` providers enabled in it with a
277
+ * valid config) and the org has not switched off (`eventSourcesOff`), each with its extension's
278
+ * display name and event declarations: what the automation form builds its event picker and
279
+ * filter rows from. A source whose `events()` fails or does not answer within `tools.timeoutMs`
280
+ * is left out (logged), so one broken source does not take the others' list down.
281
+ */
282
+ eventSources(orgId: string): Promise<EventSourceView[]>;
283
+ /** A trigger source's declarations, within `tools.timeoutMs` (as the dispatcher asks it). */
284
+ private declaredEvents;
285
+ /**
286
+ * An event trigger as stored: the source must serve the org and not be switched off
287
+ * (`automation.event_source_unavailable`), every type must be declared by it and not directed
288
+ * (`automation.event_type_unknown`: a directed event wakes one agent through acceptance, never
289
+ * through an automation), and the filter must fit the selected types' facts
290
+ * (`automation.filter_invalid`). Whether an owner may see a subject is not checked here: dispatch
291
+ * enforces it through the source's `visible()` for the automation's owner.
292
+ */
293
+ private checkEventTrigger;
250
294
  /**
251
295
  * The chats the caller can point a `chat` task at (spec §8): per active connection of the org
252
296
  * whose extension is enabled in it, their DM threads (archived included) and, on a channel with
253
- * threads, the groups they have a thread in. Members up (`schedules.use`, the route's).
297
+ * threads, the groups they have a thread in. Members up (`automations.use`, the route's).
254
298
  */
255
299
  chatTargets(orgId: string, accountId: string): Promise<ChatTarget[]>;
256
300
  /**
@@ -260,24 +304,24 @@ export declare class ScheduledTasksService {
260
304
  */
261
305
  grantableTools(orgId: string, accountId: string, agentId: string): Promise<GrantableTool[]>;
262
306
  /** The task's runs, latest first (default 50, at most 200); visible as {@link get}. */
263
- runs(orgId: string, actor: ScheduleActor, id: string, limit?: number): Promise<TaskRun[]>;
307
+ runs(orgId: string, actor: AutomationActor, id: string, limit?: number): Promise<TaskRun[]>;
264
308
  /** The task's grants; visible as {@link get}. */
265
- grants(orgId: string, actor: ScheduleActor, id: string): Promise<ScheduledTaskGrantView[]>;
309
+ grants(orgId: string, actor: AutomationActor, id: string): Promise<AutomationGrantView[]>;
266
310
  /**
267
311
  * Creator only; each grant is checked as at create (spec §7); network domains only from a web
268
312
  * session (`source.fromSession`).
269
313
  */
270
- addGrants(orgId: string, accountId: string, id: string, grants: GrantInput[], source?: GrantWriteSource): Promise<ScheduledTaskGrant[]>;
314
+ addGrants(orgId: string, accountId: string, id: string, grants: GrantInput[], source?: GrantWriteSource): Promise<AutomationGrant[]>;
271
315
  /** Creator only; removing a grant the task does not have is a no-op. */
272
316
  removeGrant(orgId: string, accountId: string, id: string, toolKey: string): Promise<void>;
273
317
  /**
274
- * The creator's scheduled tasks that need attention (spec §8), derived live: a paused task whose
318
+ * The creator's automations that need attention (spec §8), derived live: a paused task whose
275
319
  * reason is not `creator` (resuming clears it), an active task whose latest settled non-trial
276
320
  * run failed (the next good run clears it), and a task whose latest settled non-trial run was
277
321
  * refused tools, connections or domains (a tool granted since drops out, a domain too while the
278
322
  * org's network allowlist admits it; the next clean run clears the rest). Newest first.
279
323
  */
280
- attentionFor(orgId: string, accountId: string): Promise<ScheduleAttention[]>;
324
+ attentionFor(orgId: string, accountId: string): Promise<AutomationAttention[]>;
281
325
  private roleOrNull;
282
326
  /**
283
327
  * The agent's tools by key (their `requiredRole` and definition hash) as the creator sees them;
@@ -290,24 +334,26 @@ export declare class ScheduledTasksService {
290
334
  * delivery path); `by` is the account that caused it, null for the kernel. A task already
291
335
  * paused or ended keeps its state and reason.
292
336
  */
293
- pauseFor(t: KernelSchemaDb, taskId: string, reason: SchedulePauseReason, by: string | null): Promise<void>;
337
+ pauseFor(t: KernelSchemaDb, taskId: string, reason: AutomationPauseReason, by: string | null): Promise<void>;
294
338
  /**
295
339
  * "Run now" (spec §6), creator only: a task run for the request time, outside the schedule (no
296
340
  * unique-key conflict with a tick, and `next_run_at` does not move), fired at once through the
297
341
  * fire job its transaction owes. `trial`: an attended trial run whose approvals become the task's
298
342
  * grants (§7). Counted in the rate limit like any run. An ended task cannot run; a paused one
299
343
  * can (only its creator gets here: the run is `manual`, which the fire's paused check lets by).
344
+ * An event automation has neither (`automation.run_now_unsupported`): its runs are made from its
345
+ * events (collaboration spec §4.1).
300
346
  */
301
347
  runNow(orgId: string, accountId: string, id: string, opts: {
302
348
  trial: boolean;
303
349
  }): Promise<TaskRun>;
304
- /** The live role of a member of the org; not a member → `schedule.not_found`. */
350
+ /** The live role of a member of the org; not a member → `automation.not_found`. */
305
351
  private liveRole;
306
- /** The actor's own task, row-locked; another's: `schedule.forbidden` for an admin, else 404. */
352
+ /** The actor's own task, row-locked; another's: `automation.forbidden` for an admin, else 404. */
307
353
  private lockOwn;
308
354
  /**
309
355
  * A task the actor may pause, resume or delete, row-locked under the org lock: their own (with
310
- * `creatorAction`), or any as an org admin (`schedules.manage`); otherwise `schedule.not_found`.
356
+ * `creatorAction`), or any as an org admin (`automations.manage`); otherwise `automation.not_found`.
311
357
  */
312
358
  private lockManaged;
313
359
  /**
@@ -323,9 +369,10 @@ export declare class ScheduledTasksService {
323
369
  /** The channel's declared features; undefined when its extension is not loaded here. */
324
370
  private channelFeatures;
325
371
  /**
326
- * A task's model, effort and device (spec §4): `new` mode only, since a conversation or chat
327
- * task runs with that conversation's selection and device (a task must not switch a person's
328
- * conversation for their later turns), so another mode refuses them (`validation_failed`).
372
+ * A task's model, effort and device (spec §4): `new` mode takes all three and `subject` mode a
373
+ * model and effort (not a device). A conversation or chat task runs with that conversation's
374
+ * selection and device (a task must not switch a person's conversation for their later turns),
375
+ * so those modes refuse them (`validation_failed`).
329
376
  * The model must resolve for the org (`agent.model_unavailable`, as a message's switch) and
330
377
  * declare the effort (`validation_failed`); the device must be one of the creator's
331
378
  * (`checkDevice`, when `deviceChanged`).
@@ -340,7 +387,7 @@ export declare class ScheduledTasksService {
340
387
  * `deviceId`, the task's device (null: none can be determined, the device rule is skipped),
341
388
  * stored with `spec_hash` `network` and no connector (plan P-D7), and only when
342
389
  * `source.fromSession` (a person on the task page; never a token, the Platform tool or the
343
- * schedule tools). Each git push key (`git:push`, `git:push:<owner>/<repo>`, the repository
390
+ * automation tools). Each git push key (`git:push`, `git:push:<owner>/<repo>`, the repository
344
391
  * lower-cased) is refused by {@link gitGrantRefusal} and stored with `spec_hash` `git` and no
345
392
  * connector, also only when `source.fromSession`. Duplicates keep the last.
346
393
  */