@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
@@ -0,0 +1,178 @@
1
+ import type { EventFilter } from "@capybara-hq/plugin-sdk";
2
+ import type { ModelRef } from "../agents/definition.js";
3
+ /**
4
+ * Automations (spec 2026-11-11-scheduled-tasks-design.md §4): the shapes the kernel reads and
5
+ * writes. The rows live in `capybara.automations`, `automation_runs` and
6
+ * `automation_grants` (migration 0113).
7
+ */
8
+ /**
9
+ * When an automation fires: a 5-field cron, or once at a local date-time, both in an IANA zone
10
+ * (§5); or on an extension's trigger events (collaboration spec §4.1): events of `types` from the
11
+ * extension `source` whose facts match `filter`. An event automation has no next run time.
12
+ */
13
+ export type AutomationTrigger = {
14
+ kind: "cron";
15
+ expr: string;
16
+ timeZone: string;
17
+ } | {
18
+ kind: "once";
19
+ at: string;
20
+ timeZone: string;
21
+ } | {
22
+ kind: "event";
23
+ source: string;
24
+ types: string[];
25
+ filter: EventFilter;
26
+ };
27
+ /** The time triggers: the ones with a next run time. */
28
+ export type AutomationTimeTrigger = Exclude<AutomationTrigger, {
29
+ kind: "event";
30
+ }>;
31
+ /**
32
+ * Where a run posts: a new conversation, one existing conversation, an IM chat (§3), or one
33
+ * conversation per event subject (collaboration spec §4.5).
34
+ */
35
+ export type AutomationMode = "new" | "conversation" | "chat" | "subject";
36
+ /** Who made an automation: its owner, or the kernel from an acceptance rule (collaboration §4.4). */
37
+ export type AutomationOrigin = "person" | "acceptance";
38
+ /** Whom an automation acts as (`automations.principal`); today always the member `account_id`. */
39
+ export type AutomationPrincipal = {
40
+ kind: "member";
41
+ accountId: string;
42
+ };
43
+ /** What a question asked in an unattended run does (collaboration spec §4.7). */
44
+ export type AutomationUnattendedAsk = "fail" | "wait";
45
+ /** The IM chat a `chat`-mode task posts into. */
46
+ export interface AutomationChat {
47
+ connectionId: string;
48
+ chatId: string;
49
+ chatType: "dm" | "group";
50
+ }
51
+ export type AutomationStatus = "active" | "paused" | "ended";
52
+ export type AutomationPauseReason = "creator" | "admin" | "failures" | "creator_inactive" | "agent_gone" | "target_gone" | "conversation_gone" | "org_disabled" | "expired"
53
+ /** The stored trigger cannot be evaluated (the scanner stops selecting the task). */
54
+ | "invalid_schedule";
55
+ export type TaskRunStatus = "pending" | "running" | "completed" | "failed" | "skipped";
56
+ export type TaskRunSkipReason = "missed" | "overlap" | "rate_limited" | "queue_paused" | "removed" | "device_offline" | "creator_inactive" | "agent_gone" | "target_gone" | "conversation_gone" | "org_disabled"
57
+ /** The channel's extension is disabled in the org: the task stays active. */
58
+ | "plugin_disabled"
59
+ /** A group chat on a channel without threads (a group run needs its own thread). */
60
+ | "unsupported_target"
61
+ /** The task was deleted after the run was recorded. */
62
+ | "task_deleted"
63
+ /** The task was paused after the scan recorded the tick (a "run now" still runs). */
64
+ | "task_paused"
65
+ /** An event run: the subject's run rate limit was reached (collaboration spec §4.7). */
66
+ | "subject_rate";
67
+ /** A task as the kernel reads it: the columns of `capybara.automations`, camel-cased. */
68
+ export interface Automation {
69
+ id: string;
70
+ orgId: string;
71
+ /** The creator: every run acts as this account. */
72
+ accountId: string;
73
+ agentId: string;
74
+ name: string;
75
+ prompt: string;
76
+ trigger: AutomationTrigger;
77
+ mode: AutomationMode;
78
+ /** The target conversation (`conversation` mode only). */
79
+ conversationId: string | null;
80
+ /** The target chat (`chat` mode only). */
81
+ chat: AutomationChat | null;
82
+ /** Null = the agent's default model. */
83
+ model: ModelRef | null;
84
+ /** Null = the agent's default effort. */
85
+ effort: string | null;
86
+ /** Null = the default pick for new conversations. */
87
+ deviceId: string | null;
88
+ /** What a question in an unattended run does; null = the org's default. */
89
+ unattendedAsk: AutomationUnattendedAsk | null;
90
+ status: AutomationStatus;
91
+ pauseReason: AutomationPauseReason | null;
92
+ /** The account that paused the task (creator or admin); null when not paused by a person. */
93
+ pausedBy: string | null;
94
+ /** The next fire time, jitter included; null when the task is not active. */
95
+ nextRunAt: Date | null;
96
+ jitterSeconds: number;
97
+ expiresAt: Date | null;
98
+ consecutiveFailures: number;
99
+ createdAt: Date;
100
+ updatedAt: Date;
101
+ }
102
+ /** One tick of a task (or a trial run): the columns of `capybara.automation_runs`. */
103
+ export interface TaskRun {
104
+ id: string;
105
+ taskId: string;
106
+ orgId: string;
107
+ /**
108
+ * The tick, before jitter (for a trial run: when it was requested); null for an event run
109
+ * (collaboration spec §4.1).
110
+ */
111
+ scheduledFor: Date | null;
112
+ /**
113
+ * What the run is unique by outside trials: the tick as `Date.toISOString()` for a time run, the
114
+ * event id for an event run (`UNIQUE (automation_id, trigger_key) WHERE NOT trial`).
115
+ */
116
+ triggerKey: string;
117
+ firedAt: Date | null;
118
+ trial: boolean;
119
+ /** A person's "run now" (trial or not), outside the schedule. */
120
+ manual: boolean;
121
+ conversationId: string | null;
122
+ runId: string | null;
123
+ status: TaskRunStatus;
124
+ skipReason: TaskRunSkipReason | null;
125
+ error: string | null;
126
+ /** Tool keys refused for lack of a grant (§7). */
127
+ missingGrants: string[];
128
+ }
129
+ /** A run with a tick: every time run (event runs have none). */
130
+ export type TimedTaskRun = TaskRun & {
131
+ scheduledFor: Date;
132
+ };
133
+ /**
134
+ * The marker a task's message carries (`conversation_queue.schedule`, then `user_message`): not
135
+ * model-visible as such; `taskName` and `localTime` feed the English header the model sees.
136
+ */
137
+ export interface ScheduleMarker {
138
+ taskId: string;
139
+ taskRunId: string;
140
+ /** ISO timestamp of the tick. */
141
+ scheduledFor: string;
142
+ trial: boolean;
143
+ taskName: string;
144
+ /** The tick in the task's zone, as the header shows it. */
145
+ localTime: string;
146
+ }
147
+ /**
148
+ * The marker an event automation's message carries (`conversation_queue.automation_event`, then
149
+ * `user_message.automationEvent`, collaboration spec §4.6): the automation and run, and the
150
+ * events the message reports, in order (coalesced events share one message): at most the first 5
151
+ * and the latest 15 of the run's events, `omittedEvents` counting the ones left out between them.
152
+ */
153
+ export interface AutomationEventMarker {
154
+ automationId: string;
155
+ automationRunId: string;
156
+ automationName: string;
157
+ /** The extension that emitted the events (the automation's trigger source). */
158
+ source: string;
159
+ events: Array<{
160
+ id: string;
161
+ type: string;
162
+ subject: {
163
+ kind: string;
164
+ id: string;
165
+ title: string;
166
+ url?: string | undefined;
167
+ };
168
+ summary: string;
169
+ }>;
170
+ /** How many of the run's events the marker leaves out (absent: none). */
171
+ omittedEvents?: number | undefined;
172
+ }
173
+ /** A remembered "always allow" of a task (same meaning as `conversation_tool_grants`). */
174
+ export interface AutomationGrant {
175
+ toolKey: string;
176
+ specHash: string;
177
+ connectorId: string | null;
178
+ }
@@ -1,8 +1,8 @@
1
1
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
2
2
  import type { KernelConfigService } from "../infra/config/kernel-config.service.js";
3
3
  /**
4
- * The scheduled task run a kernel run serves (scheduled tasks spec §4, §7), or null for an attended
5
- * run: `runs.scheduled_task_run_id`, set on the run a task's message triggered and inherited by the
4
+ * The automation run a kernel run serves (scheduled tasks spec §4, §7), or null for an attended
5
+ * run: `runs.automation_run_id`, set on the run a task's message triggered and inherited by the
6
6
  * runs descending from it without a person (sub-agent runs, wake runs). A run whose task run row is
7
7
  * gone is treated as attended.
8
8
  */
@@ -11,16 +11,25 @@ export declare function unattendedTaskRunOf(db: KernelSchemaDb, runId: string):
11
11
  taskId: string;
12
12
  trial: boolean;
13
13
  } | null>;
14
+ /** What a new run takes from its boundary event ({@link automationRunAt}). */
15
+ export interface AutomationLineage {
16
+ /** `runs.automation_run_id`: the automation run it serves (unattended); null = attended. */
17
+ automationRunId: string | null;
18
+ /** `runs.trigger_event_id`: the trigger event it started from (collaboration spec §4.7). */
19
+ triggerEventId: string | null;
20
+ }
14
21
  /**
15
- * The `scheduled_task_run_id` a new run whose boundary (`runs.trigger_seq`) is event `seq` of
16
- * `conversationId` gets (scheduled tasks spec §4), read in the caller's transaction:
17
- * - a `user_message`: its schedule marker's task run; a sub-agent's task or `SendMessage` message
18
- * (`dispatch`): what its parent run has; a person's message: null;
22
+ * The `automation_run_id` and `trigger_event_id` a new run whose boundary (`runs.trigger_seq`) is
23
+ * event `seq` of `conversationId` gets (scheduled tasks spec §4, collaboration spec §4.7), read in
24
+ * the caller's transaction:
25
+ * - a `user_message`: its schedule marker's task run (no event), or its event marker's run and
26
+ * last event (the most recent cause); a sub-agent's task or `SendMessage` message (`dispatch`):
27
+ * what its parent run has; a person's message: neither;
19
28
  * - a `background_task_finished`: what the run that launched the task has;
20
29
  * - a `subagent_delivery`: what the child run that delivered it has (it inherited from its parent);
21
- * - anything else, or no such event: null.
30
+ * - anything else, or no such event: neither.
22
31
  */
23
- export declare function scheduledTaskRunAt(t: KernelSchemaDb, conversationId: string, seq: number | string): Promise<string | null>;
32
+ export declare function automationRunAt(t: KernelSchemaDb, conversationId: string, seq: number | string): Promise<AutomationLineage>;
24
33
  /** The tool result of an ask outside the task's grants in an unattended run, `fail` mode (§7). */
25
34
  export declare const UNATTENDED_ASK_ERROR: (tool: string) => string;
26
35
  /**
@@ -48,7 +57,7 @@ export declare const connectionGrantKey: (connectorSlug: string) => string;
48
57
  /** The `missing_grants` entry of a refused network host (network ask-to-allow spec §8.1, §8.3). */
49
58
  export declare const networkGrantKey: (host: string) => string;
50
59
  /**
51
- * What the tool policy knows of the scheduled task run a kernel run serves (`PolicyContext`): the
60
+ * What the tool policy knows of the automation run a kernel run serves (`PolicyContext`): the
52
61
  * task (its grants), the task run (its `missing_grants`), whether it is a trial run (attended), and
53
62
  * the org's `unattendedAsk` and `forbiddenTools`, read live.
54
63
  */
@@ -66,13 +75,15 @@ export declare const unattendedRules: (u: UnattendedRun | null | undefined) => u
66
75
  /** In `fail` mode, an unattended run never waits for a person (§7). */
67
76
  export declare const unattendedFails: (u: UnattendedRun | null | undefined) => boolean;
68
77
  /**
69
- * The scheduled task context of a run's tool calls (`PolicyContext.unattended`), or null when the
78
+ * The automation context of a run's tool calls (`PolicyContext.unattended`), or null when the
70
79
  * run is attended: it serves no task run, or a person's message joined it ({@link personJoined}).
71
80
  * A trial run is returned with `trial: true` (attended; its approvals become task grants).
81
+ * `unattendedAsk` is the automation's own `unattended_ask` when set (collaboration spec §4.4),
82
+ * else the org's default.
72
83
  */
73
84
  export declare function unattendedRunOf(db: KernelSchemaDb, config: Pick<KernelConfigService, "get">, orgId: string, runId: string): Promise<UnattendedRun | null>;
74
85
  /**
75
- * The scheduled task whose grants a run's actions use (spec §7; network ask-to-allow spec §8.1),
86
+ * The automation whose grants a run's actions use (spec §7; network ask-to-allow spec §8.1),
76
87
  * or null: the run serves a task run that is no trial run and no person joined
77
88
  * ({@link personJoined}): the same rule as {@link unattendedRules} on {@link unattendedRunOf},
78
89
  * without the org's settings. `accountId`: the task's creator; `orgId`: the task's org.
@@ -1,30 +1,33 @@
1
1
  import { sql } from "kysely";
2
- import { readScheduleSettings } from "./effective-settings.js";
2
+ import { readAutomationSettings } from "./effective-settings.js";
3
3
  /**
4
- * The scheduled task run a kernel run serves (scheduled tasks spec §4, §7), or null for an attended
5
- * run: `runs.scheduled_task_run_id`, set on the run a task's message triggered and inherited by the
4
+ * The automation run a kernel run serves (scheduled tasks spec §4, §7), or null for an attended
5
+ * run: `runs.automation_run_id`, set on the run a task's message triggered and inherited by the
6
6
  * runs descending from it without a person (sub-agent runs, wake runs). A run whose task run row is
7
7
  * gone is treated as attended.
8
8
  */
9
9
  export async function unattendedTaskRunOf(db, runId) {
10
10
  const row = await db
11
11
  .selectFrom("runs as r")
12
- .innerJoin("scheduled_task_runs as tr", "tr.id", "r.scheduled_task_run_id")
13
- .select(["tr.id", "tr.task_id", "tr.trial"])
12
+ .innerJoin("automation_runs as tr", "tr.id", "r.automation_run_id")
13
+ .select(["tr.id", "tr.automation_id", "tr.trial"])
14
14
  .where("r.id", "=", runId)
15
15
  .executeTakeFirst();
16
- return row ? { taskRunId: row.id, taskId: row.task_id, trial: row.trial } : null;
16
+ return row ? { taskRunId: row.id, taskId: row.automation_id, trial: row.trial } : null;
17
17
  }
18
+ const NO_LINEAGE = { automationRunId: null, triggerEventId: null };
18
19
  /**
19
- * The `scheduled_task_run_id` a new run whose boundary (`runs.trigger_seq`) is event `seq` of
20
- * `conversationId` gets (scheduled tasks spec §4), read in the caller's transaction:
21
- * - a `user_message`: its schedule marker's task run; a sub-agent's task or `SendMessage` message
22
- * (`dispatch`): what its parent run has; a person's message: null;
20
+ * The `automation_run_id` and `trigger_event_id` a new run whose boundary (`runs.trigger_seq`) is
21
+ * event `seq` of `conversationId` gets (scheduled tasks spec §4, collaboration spec §4.7), read in
22
+ * the caller's transaction:
23
+ * - a `user_message`: its schedule marker's task run (no event), or its event marker's run and
24
+ * last event (the most recent cause); a sub-agent's task or `SendMessage` message (`dispatch`):
25
+ * what its parent run has; a person's message: neither;
23
26
  * - a `background_task_finished`: what the run that launched the task has;
24
27
  * - a `subagent_delivery`: what the child run that delivered it has (it inherited from its parent);
25
- * - anything else, or no such event: null.
28
+ * - anything else, or no such event: neither.
26
29
  */
27
- export async function scheduledTaskRunAt(t, conversationId, seq) {
30
+ export async function automationRunAt(t, conversationId, seq) {
28
31
  const ev = await t
29
32
  .selectFrom("conversation_events")
30
33
  .select(["type", "payload"])
@@ -32,12 +35,21 @@ export async function scheduledTaskRunAt(t, conversationId, seq) {
32
35
  .where("seq", "=", String(seq))
33
36
  .executeTakeFirst();
34
37
  if (!ev)
35
- return null;
38
+ return NO_LINEAGE;
36
39
  const p = ev.payload;
37
40
  let runId;
38
41
  if (ev.type === "user_message") {
39
- if (typeof p.schedule?.taskRunId === "string")
40
- return p.schedule.taskRunId;
42
+ if (typeof p.schedule?.taskRunId === "string") {
43
+ return { automationRunId: p.schedule.taskRunId, triggerEventId: null };
44
+ }
45
+ const marker = p.automationEvent;
46
+ if (typeof marker?.automationRunId === "string") {
47
+ const last = marker.events?.at(-1)?.id;
48
+ return {
49
+ automationRunId: marker.automationRunId,
50
+ triggerEventId: typeof last === "string" ? last : null,
51
+ };
52
+ }
41
53
  if (typeof p.dispatch?.parentRunId === "string")
42
54
  runId = p.dispatch.parentRunId;
43
55
  }
@@ -55,13 +67,15 @@ export async function scheduledTaskRunAt(t, conversationId, seq) {
55
67
  runId = p.childRunId;
56
68
  }
57
69
  if (runId === undefined)
58
- return null;
70
+ return NO_LINEAGE;
59
71
  const run = await t
60
72
  .selectFrom("runs")
61
- .select("scheduled_task_run_id")
73
+ .select(["automation_run_id", "trigger_event_id"])
62
74
  .where("id", "=", runId)
63
75
  .executeTakeFirst();
64
- return run?.scheduled_task_run_id ?? null;
76
+ return run
77
+ ? { automationRunId: run.automation_run_id, triggerEventId: run.trigger_event_id }
78
+ : NO_LINEAGE;
65
79
  }
66
80
  /** The tool result of an ask outside the task's grants in an unattended run, `fail` mode (§7). */
67
81
  export const UNATTENDED_ASK_ERROR = (tool) => `This scheduled run cannot ask for approval; the task's owner can add ${tool} to the task's approved tools.`;
@@ -101,9 +115,9 @@ export const unattendedRules = (u) => u !== null && u !== undefined && !u.trial;
101
115
  /** In `fail` mode, an unattended run never waits for a person (§7). */
102
116
  export const unattendedFails = (u) => unattendedRules(u) && u.unattendedAsk === "fail";
103
117
  /**
104
- * Whether the task's creator joined the run (scheduled tasks rulings, Task 7 and Task 8): the run's
118
+ * Whether the task's creator joined the run (automations rulings, Task 7 and Task 8): the run's
105
119
  * conversation holds a `user_message` after the run's boundary (`trigger_seq`) that the creator
106
- * wrote (no schedule marker, no sub-agent dispatch, `authorAccountId` = the task's account) and
120
+ * wrote (no schedule or event marker, no sub-agent dispatch, `authorAccountId` = the task's account) and
107
121
  * that the run already absorbed (at or below the `absorbedUpToSeq` of its latest model call). The
108
122
  * rest of such a run is attended. Another person's message (someone replying in a group thread the
109
123
  * task posted into) does not make it attended: the task's grants are the creator's, and only the
@@ -112,14 +126,15 @@ export const unattendedFails = (u) => unattendedRules(u) && u.unattendedAsk ===
112
126
  async function personJoined(db, runId) {
113
127
  const row = await db
114
128
  .selectFrom("runs as r")
115
- .innerJoin("scheduled_task_runs as tr", "tr.id", "r.scheduled_task_run_id")
116
- .innerJoin("scheduled_tasks as st", "st.id", "tr.task_id")
129
+ .innerJoin("automation_runs as tr", "tr.id", "r.automation_run_id")
130
+ .innerJoin("automations as st", "st.id", "tr.automation_id")
117
131
  .select(sql `EXISTS (
118
132
  SELECT 1 FROM capybara.conversation_events u
119
133
  WHERE u.conversation_id = r.conversation_id
120
134
  AND u.type = 'user_message'
121
135
  AND u.seq > r.trigger_seq
122
136
  AND NOT (u.payload ? 'schedule')
137
+ AND NOT (u.payload ? 'automationEvent')
123
138
  AND NOT (u.payload ? 'dispatch')
124
139
  AND u.payload->>'authorAccountId' = st.account_id
125
140
  AND u.seq <= (
@@ -136,9 +151,11 @@ async function personJoined(db, runId) {
136
151
  return row?.joined === true;
137
152
  }
138
153
  /**
139
- * The scheduled task context of a run's tool calls (`PolicyContext.unattended`), or null when the
154
+ * The automation context of a run's tool calls (`PolicyContext.unattended`), or null when the
140
155
  * run is attended: it serves no task run, or a person's message joined it ({@link personJoined}).
141
156
  * A trial run is returned with `trial: true` (attended; its approvals become task grants).
157
+ * `unattendedAsk` is the automation's own `unattended_ask` when set (collaboration spec §4.4),
158
+ * else the org's default.
142
159
  */
143
160
  export async function unattendedRunOf(db, config, orgId, runId) {
144
161
  const run = await unattendedTaskRunOf(db, runId);
@@ -146,16 +163,22 @@ export async function unattendedRunOf(db, config, orgId, runId) {
146
163
  return null;
147
164
  if (!run.trial && (await personJoined(db, runId)))
148
165
  return null;
149
- const s = await readScheduleSettings(db, config, orgId);
166
+ const s = await readAutomationSettings(db, config, orgId);
167
+ // org-filter: the task id is read from the kernel run's own automation_run_id, never input
168
+ const own = await db
169
+ .selectFrom("automations")
170
+ .select("unattended_ask")
171
+ .where("id", "=", run.taskId)
172
+ .executeTakeFirst();
150
173
  return {
151
174
  ...run,
152
- unattendedAsk: s.unattendedAsk,
175
+ unattendedAsk: own?.unattended_ask ?? s.unattendedAsk,
153
176
  forbiddenTools: s.forbiddenTools,
154
177
  forbiddenToolsUnreadable: s.forbiddenToolsUnreadable,
155
178
  };
156
179
  }
157
180
  /**
158
- * The scheduled task whose grants a run's actions use (spec §7; network ask-to-allow spec §8.1),
181
+ * The automation whose grants a run's actions use (spec §7; network ask-to-allow spec §8.1),
159
182
  * or null: the run serves a task run that is no trial run and no person joined
160
183
  * ({@link personJoined}): the same rule as {@link unattendedRules} on {@link unattendedRunOf},
161
184
  * without the org's settings. `accountId`: the task's creator; `orgId`: the task's org.
@@ -166,9 +189,9 @@ export async function taskGrantsRunOf(db, runId) {
166
189
  return null;
167
190
  if (await personJoined(db, runId))
168
191
  return null;
169
- // org-filter: the task id is read from the kernel run's own scheduled_task_run_id, never input
192
+ // org-filter: the task id is read from the kernel run's own automation_run_id, never input
170
193
  const task = await db
171
- .selectFrom("scheduled_tasks")
194
+ .selectFrom("automations")
172
195
  .select(["id", "account_id", "org_id"])
173
196
  .where("id", "=", run.taskId)
174
197
  .where("deleted_at", "is", null)
@@ -180,10 +203,10 @@ export async function taskGrantsRunOf(db, runId) {
180
203
  * atomic update, so parallel calls of a run and of its sub-agents never lose or repeat a key.
181
204
  */
182
205
  // org-filter: callers pass the task run id of the kernel run's own unattended context
183
- // (PolicyContext.unattended, from runs.scheduled_task_run_id), never a caller-supplied id
206
+ // (PolicyContext.unattended, from runs.automation_run_id), never a caller-supplied id
184
207
  export async function appendMissingGrant(db, taskRunId, key) {
185
208
  await db
186
- .updateTable("scheduled_task_runs")
209
+ .updateTable("automation_runs")
187
210
  .set({
188
211
  missing_grants: sql `CASE WHEN missing_grants ? ${key} THEN missing_grants
189
212
  ELSE missing_grants || jsonb_build_array(${key}::text) END`,
@@ -208,7 +208,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
208
208
  /** The host versions (an entry's `minKernel` is judged against them). */
209
209
  export declare const HOST_VERSIONS: {
210
210
  readonly kernel: string;
211
- readonly sdk: "0.1.0-rc.84";
211
+ readonly sdk: "0.1.0-rc.85";
212
212
  };
213
213
  /** Whether this deployment satisfies the entry's `minKernel`. */
214
214
  export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
@@ -11,6 +11,7 @@ var ChannelWorkersModule_1;
11
11
  import { OnWorkerEvent, WorkerHost } from "@nestjs/bullmq";
12
12
  import { Inject, Injectable, Module } from "@nestjs/common";
13
13
  import { UnrecoverableError } from "bullmq";
14
+ import { AutomationsModule } from "../automations/automations.module.js";
14
15
  import { ConversationsModule } from "../conversations/conversations.module.js";
15
16
  import { EventLogModule } from "../conversations/event-log.js";
16
17
  import { DevicesModule } from "../devices/devices.module.js";
@@ -22,7 +23,6 @@ import { runJob } from "../infra/queue/run-job.js";
22
23
  import { OrgLockModule } from "../orgs/org-lock.js";
23
24
  import { OrgsModule } from "../orgs/orgs.module.js";
24
25
  import { RuntimeModule } from "../runtime/runtime.module.js";
25
- import { SchedulesModule } from "../schedules/schedules.module.js";
26
26
  import { StorageModule } from "../storage/storage.module.js";
27
27
  import { ToolsModule } from "../tools/tools.module.js";
28
28
  import { ChannelConnections } from "./connections.service.js";
@@ -53,8 +53,8 @@ ChannelsModule = __decorate([
53
53
  ToolsModule,
54
54
  ConversationsModule,
55
55
  RuntimeModule,
56
- // outbound pauses the scheduled task of a run whose chat is gone (scheduled tasks spec §8)
57
- SchedulesModule,
56
+ // outbound pauses the automation of a run whose chat is gone (scheduled tasks spec §8)
57
+ AutomationsModule,
58
58
  // outbound reads conversation files to send them into the chat (channel file delivery §4.2)
59
59
  StorageModule,
60
60
  CHANNEL_QUEUE_MODULE,
@@ -1,5 +1,6 @@
1
1
  import { type ChannelTarget, type Logger } from "@capybara-hq/plugin-sdk";
2
2
  import { type Job, type Worker } from "bullmq";
3
+ import { AutomationsService } from "../automations/automations.service.js";
3
4
  import { EventLog } from "../conversations/event-log.js";
4
5
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
5
6
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
@@ -7,7 +8,6 @@ import { KernelDb } from "../infra/database/kernel-db.js";
7
8
  import { TransactionHost } from "../infra/database/transaction-host.js";
8
9
  import { ConversationLock } from "../runtime/conversation-lock.js";
9
10
  import type { StreamBus } from "../runtime/stream.js";
10
- import { ScheduledTasksService } from "../schedules/scheduled-tasks.service.js";
11
11
  import { StorageService } from "../storage/storage.service.js";
12
12
  import { ApprovalsService } from "../tools/approvals.service.js";
13
13
  import { QuestionsService } from "../tools/questions.service.js";
@@ -106,7 +106,7 @@ export declare class ChannelOutbound {
106
106
  private readonly log;
107
107
  readonly txHost: TransactionHost;
108
108
  /** Pauses the task of a scheduled run whose chat is gone (scheduled tasks spec §8). */
109
- private readonly schedules;
109
+ private readonly automations;
110
110
  private worker;
111
111
  private closed;
112
112
  /** 停机:进行中的任务在下一个检查点交还队列(由其他副本续投)。 */
@@ -119,7 +119,7 @@ export declare class ChannelOutbound {
119
119
  /** 入站任务的处理(worker 上执行 `ChannelInbound.handle`);失败抛错由 BullMQ 重试。 */
120
120
  inbound: Pick<ChannelInbound, "handle">, jobs: Pick<ChannelJobs, "enqueue" | "resumeConnection">, config: Pick<KernelConfigService, "get">, log: Pick<Logger, "error" | "warn" | "info">, txHost: TransactionHost,
121
121
  /** Pauses the task of a scheduled run whose chat is gone (scheduled tasks spec §8). */
122
- schedules: Pick<ScheduledTasksService, "pauseFor">,
122
+ automations: Pick<AutomationsService, "pauseFor">,
123
123
  /** Conversation files sent into the chat (channel file delivery spec §4.2). */
124
124
  storage: Pick<StorageService, "kernel">);
125
125
  /**
@@ -169,9 +169,9 @@ export declare class ChannelOutbound {
169
169
  /**
170
170
  * A delivery failed for good because the chat is gone or the connection's credentials are
171
171
  * (`ChannelSendError` `target_gone` / `auth`): when the run being delivered serves a scheduled
172
- * task run (`runs.scheduled_task_run_id`), its task pauses with `target_gone` (spec §8), so later
172
+ * task run (`runs.automation_run_id`), its task pauses with `target_gone` (spec §8), so later
173
173
  * ticks do not keep running into the same chat. `runId` is the run of the event being delivered;
174
174
  * without one (a streaming draft), the conversation's latest run. A person's run pauses nothing.
175
175
  */
176
- pauseScheduledTaskIn(conversationId: string, runId: string | null): Promise<void>;
176
+ pauseAutomationIn(conversationId: string, runId: string | null): Promise<void>;
177
177
  }
@@ -12,6 +12,7 @@ import { isChannelSendError, } from "@capybara-hq/plugin-sdk";
12
12
  import { Inject, Injectable } from "@nestjs/common";
13
13
  import { DelayedError, UnrecoverableError } from "bullmq";
14
14
  import { sql } from "kysely";
15
+ import { AutomationsService } from "../automations/automations.service.js";
15
16
  import { productName } from "../config/product-name.js";
16
17
  import { conversationTopic, EventLog, } from "../conversations/event-log.js";
17
18
  import { recipientLocale } from "../conversations/message-context.js";
@@ -22,7 +23,6 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
22
23
  import { Transactional } from "../infra/database/transactional.decorator.js";
23
24
  import { KERNEL_BUS, KERNEL_LOGGER } from "../infra/tokens.js";
24
25
  import { ConversationLock, } from "../runtime/conversation-lock.js";
25
- import { ScheduledTasksService } from "../schedules/scheduled-tasks.service.js";
26
26
  import { StorageService } from "../storage/storage.service.js";
27
27
  import { ApprovalsService } from "../tools/approvals.service.js";
28
28
  import { toolInfo } from "../tools/info.js";
@@ -181,7 +181,7 @@ let ChannelOutbound = class ChannelOutbound {
181
181
  config;
182
182
  log;
183
183
  txHost;
184
- schedules;
184
+ automations;
185
185
  worker;
186
186
  closed = false;
187
187
  /** 停机:进行中的任务在下一个检查点交还队列(由其他副本续投)。 */
@@ -194,7 +194,7 @@ let ChannelOutbound = class ChannelOutbound {
194
194
  /** 入站任务的处理(worker 上执行 `ChannelInbound.handle`);失败抛错由 BullMQ 重试。 */
195
195
  inbound, jobs, config, log, txHost,
196
196
  /** Pauses the task of a scheduled run whose chat is gone (scheduled tasks spec §8). */
197
- schedules,
197
+ automations,
198
198
  /** Conversation files sent into the chat (channel file delivery spec §4.2). */
199
199
  storage) {
200
200
  this.kdb = kdb;
@@ -203,7 +203,7 @@ let ChannelOutbound = class ChannelOutbound {
203
203
  this.config = config;
204
204
  this.log = log;
205
205
  this.txHost = txHost;
206
- this.schedules = schedules;
206
+ this.automations = automations;
207
207
  this.lock = lock.scoped(DELIVER_LOCK_PREFIX);
208
208
  this.d = {
209
209
  get db() {
@@ -351,7 +351,7 @@ let ChannelOutbound = class ChannelOutbound {
351
351
  if (outcome.error)
352
352
  await this.recordError(outcome.error.connectionId, outcome.error.message);
353
353
  if (outcome.gone) {
354
- await this.pauseScheduledTaskIn(conversationId, outcome.gone.runId).catch((err) => this.log.warn("cannot pause the scheduled task of a gone chat", { conversationId, err }));
354
+ await this.pauseAutomationIn(conversationId, outcome.gone.runId).catch((err) => this.log.warn("cannot pause the automation of a gone chat", { conversationId, err }));
355
355
  }
356
356
  switch (outcome.kind) {
357
357
  case "shutdown":
@@ -497,25 +497,25 @@ let ChannelOutbound = class ChannelOutbound {
497
497
  /**
498
498
  * A delivery failed for good because the chat is gone or the connection's credentials are
499
499
  * (`ChannelSendError` `target_gone` / `auth`): when the run being delivered serves a scheduled
500
- * task run (`runs.scheduled_task_run_id`), its task pauses with `target_gone` (spec §8), so later
500
+ * task run (`runs.automation_run_id`), its task pauses with `target_gone` (spec §8), so later
501
501
  * ticks do not keep running into the same chat. `runId` is the run of the event being delivered;
502
502
  * without one (a streaming draft), the conversation's latest run. A person's run pauses nothing.
503
503
  */
504
- async pauseScheduledTaskIn(conversationId, runId) {
504
+ async pauseAutomationIn(conversationId, runId) {
505
505
  let q = this.kdb
506
506
  .selectFrom("runs as r")
507
- .innerJoin("scheduled_task_runs as tr", "tr.id", "r.scheduled_task_run_id")
508
- .select(["tr.task_id", "r.scheduled_task_run_id"])
507
+ .innerJoin("automation_runs as tr", "tr.id", "r.automation_run_id")
508
+ .select(["tr.automation_id", "r.automation_run_id"])
509
509
  .where("r.conversation_id", "=", conversationId);
510
510
  q = runId !== null ? q.where("r.id", "=", runId) : q.orderBy("r.created_at", "desc").limit(1);
511
511
  const row = await q.executeTakeFirst();
512
512
  if (!row)
513
513
  return;
514
- await this.schedules.pauseFor(this.kdb.db, row.task_id, "target_gone", null);
515
- this.log.info("scheduled task paused: its chat is gone", {
514
+ await this.automations.pauseFor(this.kdb.db, row.automation_id, "target_gone", null);
515
+ this.log.info("automation paused: its chat is gone", {
516
516
  conversationId,
517
- taskId: row.task_id,
518
- taskRunId: row.scheduled_task_run_id,
517
+ taskId: row.automation_id,
518
+ taskRunId: row.automation_run_id,
519
519
  });
520
520
  }
521
521
  };
@@ -527,7 +527,7 @@ __decorate([
527
527
  ], ChannelOutbound.prototype, "bindThreadIn", null);
528
528
  __decorate([
529
529
  Transactional()
530
- ], ChannelOutbound.prototype, "pauseScheduledTaskIn", null);
530
+ ], ChannelOutbound.prototype, "pauseAutomationIn", null);
531
531
  ChannelOutbound = __decorate([
532
532
  Injectable(),
533
533
  __param(0, Inject(KernelDb)),
@@ -543,7 +543,7 @@ ChannelOutbound = __decorate([
543
543
  __param(10, Inject(KernelConfigService)),
544
544
  __param(11, Inject(KERNEL_LOGGER)),
545
545
  __param(12, Inject(TransactionHost)),
546
- __param(13, Inject(ScheduledTasksService)),
546
+ __param(13, Inject(AutomationsService)),
547
547
  __param(14, Inject(StorageService))
548
548
  ], ChannelOutbound);
549
549
  export { ChannelOutbound };
@@ -573,7 +573,7 @@ class Delivery {
573
573
  persisted = 0;
574
574
  /** 正在投递的事件(不可重试失败按它计数)。 */
575
575
  handling;
576
- /** The run of the event being delivered (a gone chat pauses its scheduled task). */
576
+ /** The run of the event being delivered (a gone chat pauses its automation). */
577
577
  handlingRun = null;
578
578
  /**
579
579
  * A scheduled group run's thread is still to bind (`pending_thread_account_id` set): the first
@@ -730,7 +730,7 @@ class Delivery {
730
730
  if (isChannelSendError(err) && !err.retryable) {
731
731
  const message = this.redact(errMsg(err));
732
732
  // Ruling A22:机器人被移出群 / 会话不存在 → 停止本轮,不计毒事件(不是连接的问题,不记 last_error)
733
- // either also pauses the scheduled task of the run being delivered (scheduled tasks §8)
733
+ // either also pauses the automation of the run being delivered (automations §8)
734
734
  const gone = { runId: this.handlingRun };
735
735
  if (err.reason === "target_gone") {
736
736
  this.d.log.warn("channel delivery target is gone", {
@@ -49,7 +49,7 @@ export declare function findThread(db: KernelSchemaDb, k: ThreadKey): Promise<st
49
49
  export declare function insertThread(db: KernelSchemaDb, k: ThreadKey, conversationId: string): Promise<string>;
50
50
  /**
51
51
  * The live conversation of a thread, or a new one bound to it, inside the caller's transaction
52
- * (a scheduled task posting into a chat, scheduled tasks spec §6): the live thread row's
52
+ * (an automation posting into a chat, scheduled tasks spec §6): the live thread row's
53
53
  * conversation when there is one; otherwise `create()`'s conversation, bound with
54
54
  * {@link insertThread} and given the chat as its delivery target (`channel_deliveries`), as an
55
55
  * inbound message would. When a concurrent inbound bound the thread first, the empty conversation