@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
@@ -15,7 +15,10 @@ import { avatarView } from "../agents/avatar-view.js";
15
15
  import { unbindConversation } from "../channels/threads.js";
16
16
  import { oweConversationDeletedNotice } from "../device-access/conversation-notices.js";
17
17
  import { ConversationDevices, } from "../devices/conversation-devices.js";
18
+ import { DeviceProjectFilesService } from "../devices/device-project-files.service.js";
18
19
  import { DeviceProjectsService } from "../devices/device-projects.service.js";
20
+ import { projectFilePath } from "../devices/project-paths.js";
21
+ import { clipped } from "../devices/project-rules.js";
19
22
  import { ApiError } from "../errors.js";
20
23
  import { loadPeople } from "../identity/account-avatar.js";
21
24
  import { afterCommit } from "../infra/database/after-commit.js";
@@ -97,6 +100,14 @@ function toConversationAgent(r) {
97
100
  }
98
101
  const notFound = () => new ApiError("conversation.not_found", "Conversation not found");
99
102
  export const NO_REPLY_SKIPS = { questions: [], network: [], seqs: new Map() };
103
+ export { MAX_PROJECT_FILES } from "../devices/device-project-files.service.js";
104
+ /**
105
+ * The model-visible text of one referenced project file (composer menus §5): English, logged in
106
+ * the `user_message`, so replay rebuilds it from the log as it is.
107
+ */
108
+ export const projectFileText = (path, root) => `Referenced project file: ${path} (in the project root ${root}; read it with Read when needed).`;
109
+ /** A message's project file that cannot be referenced (422, `details: [{ path }]` or `reason`). */
110
+ const projectFileUnavailable = (message, details) => new ApiError("conversation.project_file_unavailable", message, details);
100
111
  export { userMessageIdemKey } from "./idem-keys.js";
101
112
  const COLUMNS = [
102
113
  "id",
@@ -113,7 +124,8 @@ const COLUMNS = [
113
124
  "subagent_type",
114
125
  "archived_at",
115
126
  "device_id",
116
- "scheduled_task_id",
127
+ "automation_id",
128
+ "subject",
117
129
  "project_name",
118
130
  "project_path",
119
131
  ];
@@ -133,7 +145,15 @@ function toView(r) {
133
145
  subagentType: r.subagent_type,
134
146
  archivedAt: r.archived_at,
135
147
  deviceId: r.device_id,
136
- scheduledTaskId: r.scheduled_task_id,
148
+ automationId: r.automation_id,
149
+ subject: r.subject === null
150
+ ? null
151
+ : {
152
+ source: r.subject.source,
153
+ kind: r.subject.kind,
154
+ id: r.subject.id,
155
+ title: r.subject.title,
156
+ },
137
157
  project: r.project_name !== null && r.project_path !== null
138
158
  ? { name: r.project_name, path: r.project_path }
139
159
  : null,
@@ -148,6 +168,12 @@ export const CONVERSATION_TITLE_MAX_CHARS = 120;
148
168
  * paging spec §2); a longer run starts mid-run.
149
169
  */
150
170
  export const EVENTS_TURN_EXTEND = 2000;
171
+ /** `conversations.subject` as stored: the four fields, never the subject's link. */
172
+ function storedSubject(s) {
173
+ return s === undefined
174
+ ? null
175
+ : JSON.stringify({ source: s.source, kind: s.kind, id: s.id, title: s.title });
176
+ }
151
177
  /** The sums of the `usage` events matching `where` (over `conversation_events e`), one row. */
152
178
  const usageSums = (where) => sql `
153
179
  SELECT
@@ -182,6 +208,7 @@ let ConversationsService = class ConversationsService {
182
208
  deletion;
183
209
  devices;
184
210
  projects;
211
+ projectFiles;
185
212
  questions;
186
213
  approvals;
187
214
  events;
@@ -205,6 +232,8 @@ let ConversationsService = class ConversationsService {
205
232
  devices,
206
233
  /** The project of that device a new conversation is bound to (project root design §4.3). */
207
234
  projects,
235
+ /** Checks a message's referenced project files on the device (composer menus §5). */
236
+ projectFiles,
208
237
  /** A starter's message skips the run's pending questions (reply-while-question spec §8.1). */
209
238
  questions,
210
239
  /** ... and its pending network asks (network ask-to-allow spec §6.7). */
@@ -224,6 +253,7 @@ let ConversationsService = class ConversationsService {
224
253
  this.deletion = deletion;
225
254
  this.devices = devices;
226
255
  this.projects = projects;
256
+ this.projectFiles = projectFiles;
227
257
  this.questions = questions;
228
258
  this.approvals = approvals;
229
259
  this.events = events;
@@ -254,6 +284,7 @@ let ConversationsService = class ConversationsService {
254
284
  project_name: project?.name ?? null,
255
285
  project_path: project?.path ?? null,
256
286
  source: opts.source,
287
+ subject: storedSubject(opts.subject),
257
288
  })
258
289
  .returning(COLUMNS)
259
290
  .executeTakeFirstOrThrow();
@@ -267,8 +298,8 @@ let ConversationsService = class ConversationsService {
267
298
  * `agent.not_found` and nothing is written. Queues a run afterwards, like `postUserMessage`.
268
299
  * `events` are every event the create wrote, in seq order from seq 1 (a `model_switched` before
269
300
  * the message when the send switched), so a client can seed the new conversation's log whole.
270
- * `internal`: the conversation's source and, for kernel callers only, a scheduled task's marker,
271
- * which also sets `conversations.scheduled_task_id`, and its zone override. `pick.project` binds
301
+ * `internal`: the conversation's source and, for kernel callers only, an automation's marker,
302
+ * which also sets `conversations.automation_id`, and its zone override. `pick.project` binds
272
303
  * the conversation to one of its device's projects inside the write ({@link bindingFor}); a
273
304
  * retry answers with the conversation the first send created, its binding unchanged.
274
305
  */
@@ -284,7 +315,15 @@ let ConversationsService = class ConversationsService {
284
315
  return prior;
285
316
  const deviceId = await this.devices.forNew(orgId, accountId, pick);
286
317
  const next = await this.planSwitch(orgId, agent.definition, NO_SELECTION, input);
287
- const extra = await this.resolveExtra(orgId, accountId, input);
318
+ // the project its files are checked in, read before the write (the binding inside it decides)
319
+ const project = (input.projectFiles?.length ?? 0) > 0
320
+ ? await this.bindingFor(orgId, accountId, deviceId, pick.project)
321
+ : undefined;
322
+ const extra = await this.resolveExtra(orgId, accountId, input, {
323
+ deviceId,
324
+ project,
325
+ signal: internal.signal,
326
+ });
288
327
  const invoked = await this.prepareSkill(orgId, accountId, agentId, { conversationId: undefined, deviceId }, agent.definition, input);
289
328
  const id = randomUUID();
290
329
  let all;
@@ -324,6 +363,10 @@ let ConversationsService = class ConversationsService {
324
363
  if (internal.initialPermission)
325
364
  await this.permissions.lockInitial(orgId, id, conv.deviceId);
326
365
  const project = await this.bindingFor(orgId, accountId, conv.deviceId, conv.project);
366
+ // the project changed since its files were checked: the blocks would name another root
367
+ if (extra.projectRoot !== undefined && extra.projectRoot !== project?.path) {
368
+ throw new ApiError("conflict", "The project changed while the message was sent; retry");
369
+ }
327
370
  const row = await this.db
328
371
  .insertInto("conversations")
329
372
  .values({
@@ -336,8 +379,9 @@ let ConversationsService = class ConversationsService {
336
379
  project_path: project?.path ?? null,
337
380
  create_request_id: input.clientMessageId,
338
381
  create_request_hash: internal.createRequestHash ?? null,
339
- scheduled_task_id: internal.schedule?.taskId ?? null,
382
+ automation_id: internal.schedule?.taskId ?? internal.automationEvent?.automationId ?? null,
340
383
  source: internal.source,
384
+ subject: storedSubject(internal.subject),
341
385
  })
342
386
  .onConflict((oc) => oc
343
387
  .columns(["org_id", "account_id", "create_request_id"])
@@ -721,7 +765,7 @@ let ConversationsService = class ConversationsService {
721
765
  SELECT page.agent_id, page.latest_at, v.definition ->> 'name' AS agent_name,
722
766
  a.profile_avatar, a.profile_updated_at, cs.id, cs.org_id, cs.account_id, cs.title, cs.title_source, cs.selection, cs.last_seq,
723
767
  cs.created_at, cs.updated_at, cs.parent_conversation_id, cs.subagent_type,
724
- cs.archived_at, cs.device_id, cs.scheduled_task_id, cs.project_name, cs.project_path,
768
+ cs.archived_at, cs.device_id, cs.automation_id, cs.subject, cs.project_name, cs.project_path,
725
769
  cs.activity
726
770
  FROM page
727
771
  JOIN capybara.agents a ON a.id = page.agent_id
@@ -729,7 +773,7 @@ let ConversationsService = class ConversationsService {
729
773
  CROSS JOIN LATERAL (
730
774
  SELECT c.id, c.org_id, c.account_id, c.title, c.title_source, c.selection, c.last_seq,
731
775
  c.created_at, c.updated_at, c.parent_conversation_id, c.subagent_type,
732
- c.archived_at, c.device_id, c.scheduled_task_id, c.project_name, c.project_path,
776
+ c.archived_at, c.device_id, c.automation_id, c.subject, c.project_name, c.project_path,
733
777
  ${activitySql("c")} AS activity
734
778
  FROM capybara.conversations c
735
779
  WHERE c.org_id = ${orgId} AND c.account_id = ${accountId} AND c.kind = 'chat'
@@ -826,7 +870,11 @@ let ConversationsService = class ConversationsService {
826
870
  ORDER BY a.created_at, a.id) AS approval_ids,
827
871
  ARRAY(SELECT q.id FROM capybara.questions q
828
872
  WHERE q.conversation_id = c.id AND q.status = 'pending' AND q.expires_at > now()
829
- ORDER BY q.created_at, q.id) AS question_ids
873
+ ORDER BY q.created_at, q.id) AS question_ids,
874
+ ARRAY(SELECT q.id FROM capybara.questions q
875
+ WHERE q.conversation_id = c.id AND q.status = 'pending' AND q.expires_at > now()
876
+ AND (q.spec->>'watch')::boolean IS TRUE
877
+ ORDER BY q.created_at, q.id) AS watched_question_ids
830
878
  FROM page c
831
879
  CROSS JOIN LATERAL (
832
880
  SELECT sd.child_run_id FROM capybara.subagent_dispatches sd
@@ -850,6 +898,7 @@ let ConversationsService = class ConversationsService {
850
898
  usage: toUsage(r),
851
899
  pendingApprovalIds: r.approval_ids,
852
900
  pendingQuestionIds: r.question_ids,
901
+ watchedQuestionIds: r.watched_question_ids,
853
902
  }));
854
903
  const next = rows.length > opts.limit ? (subagents.at(-1)?.id ?? null) : null;
855
904
  return { subagents, next };
@@ -925,20 +974,32 @@ let ConversationsService = class ConversationsService {
925
974
  return this.eventLog.readTurnPageBefore(conversationId, beforeSeq, limit, EVENTS_TURN_EXTEND);
926
975
  }
927
976
  /**
928
- * 追加一条用户消息;带 `clientMessageId` 时重复提交返回同一事件。写入后调用 `ensureRun`:
929
- * 没有进行中的运行时投递一轮;运行中则由当前运行在步骤间隙吸收,或在它结束时再次 `ensureRun`。
930
- * A failed `ensureRun` is logged, not thrown: the message's transaction owes the ensure-run
977
+ * Appends a user message; a repeated send with the same `clientMessageId` returns the same
978
+ * event. After the write it calls `ensureRun`: with no run in progress it enqueues one; during
979
+ * a run the current run takes the message in between steps, or `ensureRun` runs again when it
980
+ * ends. A failed `ensureRun` is logged, not thrown: the message's transaction owes the ensure-run
931
981
  * backstop, which starts the run once the queue is reachable (transactional outbox spec §6).
932
982
  *
933
- * `attachments`(`@` 资源引用):内核以发送者的凭据读取资源(打码、限长),作为用户文本之后的额外文本块写入同一条
934
- * user_message,并在 `payload.attachments` 记录元数据(第 i 个附件对应 `content[i + 1]`)。读取失败整条不写。
935
- * 带 `clientMessageId` 的重复提交直接返回已写入的事件,不再读取。
983
+ * `attachments` (`@` resource references): the kernel reads each resource with the sender's
984
+ * credentials (redacted, length-capped) and writes it as an extra text block after the user's
985
+ * text in the same user_message, with its metadata in `payload.attachments` (attachment i is
986
+ * `content[i + 1]`). A failed read writes nothing. A repeated send with the same
987
+ * `clientMessageId` returns the written event without reading again.
988
+ *
989
+ * `files` (uploaded attachment ids): checked and bound to this conversation in the transaction
990
+ * that writes the event (see {@link BindFiles}) and appended last as image / document reference
991
+ * blocks (after the `@` resource blocks); any unavailable file writes nothing. The log holds
992
+ * only references, never bytes. With empty `text` (files only: the HTTP layer ensures `files`
993
+ * and no `@` resources then) no text block is written.
936
994
  *
937
- * `files`(上传的附件 id):在写事件的同一事务里校验并绑定到本会话(见 {@link BindFiles}),作为 image /
938
- * document 引用块追加在最后(`@` 资源块之后);任一附件不可用则整条不写。日志里只有引用,没有字节。
939
- * `text` 为空时(只发附件,HTTP 层保证此时有 `files` 且没有 `@` 资源)不写文本块。
995
+ * `projectFiles` (composer menus §5): checked in the conversation's stored project before the
996
+ * write ({@link resolveExtra}); one block each after the `@` resources' bodies, before the
997
+ * uploaded files' blocks, and `payload.projectFiles`. Any refusal writes nothing; a repeated
998
+ * send with the same `clientMessageId` returns the written event without checking again.
940
999
  */
941
- async postUserMessage(orgId, conversationId, accountId, input) {
1000
+ async postUserMessage(orgId, conversationId, accountId, input,
1001
+ /** The request's signal: the project file check on the device stops when the client hangs up. */
1002
+ signal) {
942
1003
  const conv = await this.writable(orgId, conversationId, accountId);
943
1004
  // A retry returns the written event before resolving today's model or resources.
944
1005
  if (input.clientMessageId !== undefined) {
@@ -952,7 +1013,7 @@ let ConversationsService = class ConversationsService {
952
1013
  const agent = needsAgent
953
1014
  ? (await this.agents.get(orgId, conv.agentId, accountId)).definition
954
1015
  : undefined;
955
- const extra = await this.resolveExtra(orgId, accountId, input);
1016
+ const extra = await this.resolveExtra(orgId, accountId, input, { ...conv, signal });
956
1017
  const invoked = agent === undefined
957
1018
  ? undefined
958
1019
  : await this.prepareSkill(orgId, accountId, conv.agentId, { conversationId, deviceId: conv.deviceId }, agent, input);
@@ -1141,7 +1202,7 @@ let ConversationsService = class ConversationsService {
1141
1202
  im: input.im,
1142
1203
  timeZoneOverride: internal.timeZoneOverride,
1143
1204
  });
1144
- events.push(this.userMessage(accountId, input, extra, blocks, invoked, context, internal.schedule));
1205
+ events.push(this.userMessage(accountId, input, extra, blocks, invoked, context, internal));
1145
1206
  const { events: written, fresh } = await this.eventLog.appendInReport(conversationId, events);
1146
1207
  const message = written.at(-1);
1147
1208
  // the run this message starts is owed with it: the direct ensureRun after the commit may never
@@ -1197,14 +1258,53 @@ let ConversationsService = class ConversationsService {
1197
1258
  return this.prepareSkill(orgId, accountId, conv.agentId, { conversationId: conv.id, deviceId: conv.deviceId }, agent.definition, input);
1198
1259
  }
1199
1260
  /**
1200
- * Reads the `@` resources with the sender's credentials (nothing when there are none). Shared
1201
- * with the queue, which reads them when a message is queued (decision 15).
1261
+ * Reads the `@` resources with the sender's credentials and checks the referenced project files
1262
+ * (nothing when there are none). Shared with the queue, which reads the resources when a
1263
+ * message is queued (decision 15; a queued message carries no project files).
1264
+ *
1265
+ * Project files (composer menus §5) are checked in `target`'s project on its device as the
1266
+ * sender (the conversation's owner, through `DeviceProjectFilesService.statAll`, outside any
1267
+ * transaction): no bound project → `conversation.project_file_unavailable` with `reason:
1268
+ * "no_project"`; a path leaving the project → `device.path_outside_project`; one that is not a
1269
+ * file there → `conversation.project_file_unavailable` with its path; the device codes pass on.
1270
+ * Each becomes a {@link projectFileText} block after the resources' bodies.
1202
1271
  */
1203
- async resolveExtra(orgId, accountId, input) {
1272
+ async resolveExtra(orgId, accountId, input, target) {
1204
1273
  const refs = input.attachments ?? [];
1274
+ const files = await this.checkProjectFiles(orgId, accountId, input.projectFiles ?? [], target);
1275
+ const resolved = refs.length === 0
1276
+ ? { blocks: [], attachments: [] }
1277
+ : await this.content.resolveAttachments(orgId, accountId, refs);
1278
+ if (files === undefined)
1279
+ return resolved;
1280
+ return {
1281
+ blocks: [
1282
+ ...resolved.blocks,
1283
+ ...files.paths.map((path) => ({
1284
+ type: "text",
1285
+ text: projectFileText(path, files.root),
1286
+ })),
1287
+ ],
1288
+ attachments: resolved.attachments,
1289
+ projectFiles: files.paths.map((path) => ({ path })),
1290
+ projectRoot: files.root,
1291
+ };
1292
+ }
1293
+ /** {@link resolveExtra}'s project file check: the normalized paths and the root, or none. */
1294
+ async checkProjectFiles(orgId, accountId, refs, target) {
1205
1295
  if (refs.length === 0)
1206
- return { blocks: [], attachments: [] };
1207
- return this.content.resolveAttachments(orgId, accountId, refs);
1296
+ return undefined;
1297
+ const project = target?.project;
1298
+ if (!project || target?.deviceId == null) {
1299
+ throw projectFileUnavailable("This conversation has no device project, so it cannot reference project files; start it in a project", [{ reason: "no_project" }]);
1300
+ }
1301
+ // normalized first (a path leaving the project is refused before the device is asked), once each
1302
+ const paths = [...new Set(refs.map((r) => projectFilePath(r.path)))];
1303
+ const { missing } = await this.projectFiles.statAll({ orgId, accountId, deviceId: target.deviceId }, project.path, paths, target.signal);
1304
+ if (missing.length > 0) {
1305
+ throw projectFileUnavailable(`${clipped(missing[0])} is not a file in the project ${project.name}; pick it again`, missing.map((path) => ({ path: clipped(path) })));
1306
+ }
1307
+ return { paths, root: project.path };
1208
1308
  }
1209
1309
  /**
1210
1310
  * Binds uploaded files inside the message's (or queue item's) transaction; none → no blocks.
@@ -1218,7 +1318,8 @@ let ConversationsService = class ConversationsService {
1218
1318
  afterCommit(() => this.eventLog.publishChanged(conversationId, "files"));
1219
1319
  return blocks;
1220
1320
  }
1221
- userMessage(accountId, input, extra, fileBlocks, invoked, context, schedule) {
1321
+ userMessage(accountId, input, extra, fileBlocks, invoked, context, markers = {}) {
1322
+ const { schedule, automationEvent } = markers;
1222
1323
  // a skill invocation's rendered text replaces the typed arguments as content[0]
1223
1324
  const text = invoked?.text ?? input.text;
1224
1325
  return {
@@ -1234,12 +1335,15 @@ let ConversationsService = class ConversationsService {
1234
1335
  ...fileBlocks,
1235
1336
  ],
1236
1337
  ...(extra.attachments.length > 0 && { attachments: extra.attachments }),
1338
+ ...(extra.projectFiles !== undefined &&
1339
+ extra.projectFiles.length > 0 && { projectFiles: extra.projectFiles }),
1237
1340
  authorAccountId: accountId,
1238
1341
  ...context,
1239
1342
  ...(input.clientMessageId !== undefined && { clientMessageId: input.clientMessageId }),
1240
1343
  ...(input.retryOf !== undefined && { retryOf: input.retryOf }),
1241
1344
  ...(invoked !== undefined && { skill: invoked.skill }),
1242
1345
  ...(schedule !== undefined && { schedule }),
1346
+ ...(automationEvent !== undefined && { automationEvent }),
1243
1347
  },
1244
1348
  };
1245
1349
  }
@@ -1419,11 +1523,12 @@ ConversationsService = __decorate([
1419
1523
  __param(10, Inject(RunDeletion)),
1420
1524
  __param(11, Inject(ConversationDevices)),
1421
1525
  __param(12, Inject(DeviceProjectsService)),
1422
- __param(13, Inject(QuestionsService)),
1423
- __param(14, Inject(ApprovalsService)),
1424
- __param(15, Inject(KernelEvents)),
1425
- __param(16, Inject(TransactionHost)),
1426
- __param(17, Inject(PermissionCeilingWrites)),
1427
- __param(18, Inject(OutboxService))
1526
+ __param(13, Inject(DeviceProjectFilesService)),
1527
+ __param(14, Inject(QuestionsService)),
1528
+ __param(15, Inject(ApprovalsService)),
1529
+ __param(16, Inject(KernelEvents)),
1530
+ __param(17, Inject(TransactionHost)),
1531
+ __param(18, Inject(PermissionCeilingWrites)),
1532
+ __param(19, Inject(OutboxService))
1428
1533
  ], ConversationsService);
1429
1534
  export { ConversationsService };
@@ -622,6 +622,29 @@ export declare const ScheduleMarkerSchema: z.ZodObject<{
622
622
  taskName: z.ZodString;
623
623
  localTime: z.ZodString;
624
624
  }, z.core.$strip>;
625
+ /**
626
+ * `user_message.automationEvent` (collaboration spec §4.6): the `AutomationEventMarker` shape, the
627
+ * events an event automation's message reports (at least one; coalesced events in order; at most
628
+ * the first 5 and the latest 15, `omittedEvents` counting the ones between, absent when none).
629
+ */
630
+ export declare const AutomationEventMarkerSchema: z.ZodObject<{
631
+ automationId: z.ZodString;
632
+ automationRunId: z.ZodString;
633
+ automationName: z.ZodString;
634
+ source: z.ZodString;
635
+ events: z.ZodArray<z.ZodObject<{
636
+ id: z.ZodString;
637
+ type: z.ZodString;
638
+ subject: z.ZodObject<{
639
+ kind: z.ZodString;
640
+ id: z.ZodString;
641
+ title: z.ZodString;
642
+ url: z.ZodOptional<z.ZodString>;
643
+ }, z.core.$strip>;
644
+ summary: z.ZodString;
645
+ }, z.core.$strip>>;
646
+ omittedEvents: z.ZodOptional<z.ZodNumber>;
647
+ }, z.core.$strip>;
625
648
  /** `run_context` (run context spec §3.1): every field optional, a later event holds changes only. */
626
649
  export declare const RunContextSchema: z.ZodObject<{
627
650
  agent: z.ZodOptional<z.ZodObject<{
@@ -935,6 +958,9 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
935
958
  uri: z.ZodString;
936
959
  name: z.ZodString;
937
960
  }, z.core.$strip>>>;
961
+ projectFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
962
+ path: z.ZodString;
963
+ }, z.core.$strip>>>;
938
964
  authorAccountId: z.ZodString;
939
965
  sender: z.ZodOptional<z.ZodObject<{
940
966
  name: z.ZodString;
@@ -978,6 +1004,24 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
978
1004
  taskName: z.ZodString;
979
1005
  localTime: z.ZodString;
980
1006
  }, z.core.$strip>>;
1007
+ automationEvent: z.ZodOptional<z.ZodObject<{
1008
+ automationId: z.ZodString;
1009
+ automationRunId: z.ZodString;
1010
+ automationName: z.ZodString;
1011
+ source: z.ZodString;
1012
+ events: z.ZodArray<z.ZodObject<{
1013
+ id: z.ZodString;
1014
+ type: z.ZodString;
1015
+ subject: z.ZodObject<{
1016
+ kind: z.ZodString;
1017
+ id: z.ZodString;
1018
+ title: z.ZodString;
1019
+ url: z.ZodOptional<z.ZodString>;
1020
+ }, z.core.$strip>;
1021
+ summary: z.ZodString;
1022
+ }, z.core.$strip>>;
1023
+ omittedEvents: z.ZodOptional<z.ZodNumber>;
1024
+ }, z.core.$strip>>;
981
1025
  dispatch: z.ZodOptional<z.ZodObject<{
982
1026
  parentConversationId: z.ZodString;
983
1027
  parentRunId: z.ZodString;
@@ -1040,6 +1084,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
1040
1084
  }, z.core.$strip>;
1041
1085
  triggerAccountId: z.ZodString;
1042
1086
  trigger: z.ZodOptional<z.ZodEnum<{
1087
+ automation_event: "automation_event";
1043
1088
  background_task: "background_task";
1044
1089
  compact: "compact";
1045
1090
  message: "message";
@@ -1069,6 +1114,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
1069
1114
  }, z.core.$strict>>;
1070
1115
  reminderSeqs: z.ZodArray<z.ZodNumber>;
1071
1116
  runOutcomeSeqs: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
1117
+ automationEventSeqs: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
1072
1118
  maxOutputTokens: z.ZodNumber;
1073
1119
  params: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
1074
1120
  droppedParams: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -2056,9 +2102,10 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
2056
2102
  type: z.ZodLiteral<"compaction_skipped">;
2057
2103
  payload: z.ZodObject<{
2058
2104
  reason: z.ZodEnum<{
2105
+ nothing_to_summarize: "nothing_to_summarize";
2059
2106
  too_few_turns: "too_few_turns";
2060
2107
  }>;
2061
- keepRecentTurns: z.ZodNumber;
2108
+ keepRecentTurns: z.ZodOptional<z.ZodNumber>;
2062
2109
  turns: z.ZodNumber;
2063
2110
  step: z.ZodNumber;
2064
2111
  }, z.core.$strip>;
@@ -709,6 +709,31 @@ export const ScheduleMarkerSchema = z.object({
709
709
  taskName: z.string(),
710
710
  localTime: z.string(),
711
711
  });
712
+ /**
713
+ * `user_message.automationEvent` (collaboration spec §4.6): the `AutomationEventMarker` shape, the
714
+ * events an event automation's message reports (at least one; coalesced events in order; at most
715
+ * the first 5 and the latest 15, `omittedEvents` counting the ones between, absent when none).
716
+ */
717
+ export const AutomationEventMarkerSchema = z.object({
718
+ automationId: z.string(),
719
+ automationRunId: z.string(),
720
+ automationName: z.string(),
721
+ source: z.string(),
722
+ events: z
723
+ .array(z.object({
724
+ id: z.string(),
725
+ type: z.string(),
726
+ subject: z.object({
727
+ kind: z.string(),
728
+ id: z.string(),
729
+ title: z.string(),
730
+ url: z.string().optional(),
731
+ }),
732
+ summary: z.string(),
733
+ }))
734
+ .min(1),
735
+ omittedEvents: z.number().int().positive().optional(),
736
+ });
712
737
  /** `run_context` (run context spec §3.1): every field optional, a later event holds changes only. */
713
738
  export const RunContextSchema = z.object({
714
739
  /** The agent itself: its name and its versioned description collapsed to one line. */
@@ -831,6 +856,13 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
831
856
  attachments: z
832
857
  .array(z.object({ appId: z.string(), appName: z.string(), uri: z.string(), name: z.string() }))
833
858
  .optional(),
859
+ /**
860
+ * The referenced project files (composer menus §5), paths relative to the conversation's
861
+ * project root: the text block of file i is `content[1 + attachments.length + i]`, before
862
+ * the uploaded files' blocks. Normalized and deduplicated, so possibly shorter than the
863
+ * body's list. Absent: none.
864
+ */
865
+ projectFiles: z.array(z.object({ path: z.string() })).optional(),
834
866
  authorAccountId: z.string(),
835
867
  /**
836
868
  * Who wrote the message, at send time (run context spec §3.2): display name and org role
@@ -889,9 +921,17 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
889
921
  * Not model-visible as such: request building renders only `taskName` and `localTime`, fixed
890
922
  * here at write time, as the header `[Scheduled task "<name>", run for <local time>]`
891
923
  * (`scheduleHeader`). The run this message triggers is unattended
892
- * (`runs.scheduled_task_run_id`).
924
+ * (`runs.automation_run_id`).
893
925
  */
894
926
  schedule: ScheduleMarkerSchema.optional(),
927
+ /**
928
+ * An event automation's message (collaboration spec §4.6): which automation and run posted
929
+ * it and the events it reports. Request building renders it, from these fields fixed at
930
+ * write time, as a block before the automation's prompt (`automationEventBlock`); the ids
931
+ * are not model-visible. The run this message triggers is unattended
932
+ * (`runs.automation_run_id`) and records its last event (`runs.trigger_event_id`).
933
+ */
934
+ automationEvent: AutomationEventMarkerSchema.optional(),
895
935
  /**
896
936
  * Set on a sub-agent's task message (phase C, spec §6.3): which parent call dispatched it.
897
937
  * Not model-visible; the web renders the message as the task block.
@@ -946,9 +986,12 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
946
986
  * (spec 2026-11-05-background-bash-design §3), `subagent` = a sub-agent's delivery woke it
947
987
  * (agent map spec §5.3), `schedule` = a scheduled task's message (scheduled tasks spec §6),
948
988
  * `compact` = a manual compaction run (context compaction spec §4.7): no message, no model
949
- * step, only the summary and its usage.
989
+ * step, only the summary and its usage, `automation_event` = an event automation's message
990
+ * (collaboration spec §4.6).
950
991
  */
951
- trigger: z.enum(["message", "background_task", "subagent", "schedule", "compact"]).optional(),
992
+ trigger: z
993
+ .enum(["message", "background_task", "subagent", "schedule", "compact", "automation_event"])
994
+ .optional(),
952
995
  /**
953
996
  * A wake run's boundary: the seq of the finish or delivery that woke it (full-run replay
954
997
  * seeds from it).
@@ -976,6 +1019,12 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
976
1019
  * renders another set (a request sent before the note existed).
977
1020
  */
978
1021
  runOutcomeSeqs: z.array(seqNo).optional(),
1022
+ /**
1023
+ * The `user_message` events whose event automation block (`automationEventBlock`) the
1024
+ * request rendered, in seq order; absent when it rendered none. Reconstruction reports
1025
+ * `automation_event_block` when the rebuild renders another set.
1026
+ */
1027
+ automationEventSeqs: z.array(seqNo).optional(),
979
1028
  /**
980
1029
  * The request's output cap: `min(model cap, maxOutputTokens knob ??
981
1030
  * runtime.maxOutputTokens)`, clamped by the hard fit guard.
@@ -1791,14 +1840,15 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
1791
1840
  })),
1792
1841
  /**
1793
1842
  * A manual compaction (a compact run, context compaction spec §4.7) found nothing to summarize:
1794
- * the kept tail (the latest `keepRecentTurns` user turns) already holds every user turn since
1795
- * the last summary (`turns`). Display only, never model-visible; written once per compact run
1796
- * (maintainer decision 2026-11-28). An automatic compaction's skip writes nothing.
1843
+ * nothing precedes the kept tail (the latest user turn, or its latest tool pairs; maintainer
1844
+ * decision 2026-11-28), reason `nothing_to_summarize`. Display only, never model-visible; written
1845
+ * once per compact run. An automatic compaction's skip writes nothing. `too_few_turns` (with
1846
+ * `keepRecentTurns`) is the reason an earlier manual plan wrote, still read.
1797
1847
  */
1798
1848
  ev("compaction_skipped", z.object({
1799
- reason: z.enum(["too_few_turns"]),
1800
- /** The effective `keepRecentTurns` setting the plan used. */
1801
- keepRecentTurns: count,
1849
+ reason: z.enum(["nothing_to_summarize", "too_few_turns"]),
1850
+ /** The effective `keepRecentTurns` an earlier manual plan used (`too_few_turns` only). */
1851
+ keepRecentTurns: count.optional(),
1802
1852
  /** The user turns since the last summary (all of them without one). */
1803
1853
  turns: count,
1804
1854
  /** The step the compaction ran in (0 for a manual compact run). */
@@ -1851,6 +1901,8 @@ const _toolResult = true;
1851
1901
  void _toolResult;
1852
1902
  const _schedule = true;
1853
1903
  void _schedule;
1904
+ const _automationEvent = true;
1905
+ void _automationEvent;
1854
1906
  void _blocks;
1855
1907
  void _logIsBlock;
1856
1908
  void _stop;
@@ -59,7 +59,7 @@ export type MessageContext = Pick<EventPayload<"user_message">, "sender" | "time
59
59
  * - `sender`: the account's display name and org role at send time; the org's anonymous guest
60
60
  * account (`org_anonymous_accounts`) is `{ name: <senderName, else "Anonymous guest">, role:
61
61
  * "guest", anonymous: true }`. Names are sanitised; an empty one leaves `sender` out.
62
- * - `timeZone`: the override (`timeZoneOverride`, when valid: a scheduled task's zone, scheduled
62
+ * - `timeZone`: the override (`timeZoneOverride`, when valid: an automation's zone, scheduled
63
63
  * tasks spec §6), else what the IM platform gave for the sender (`im`, when valid), else the
64
64
  * account's setting, else the browser's (when valid), else the org default, else UTC. The
65
65
  * anonymous guest account has no setting of its own, so it gets the IM value or the org default.
@@ -77,6 +77,6 @@ export declare function readMessageContext(t: KernelSchemaDb, input: {
77
77
  browser?: BrowserContext | undefined;
78
78
  /** An IM message: what the platform gave for the sender (maintainer decision 2026-11-08). */
79
79
  im?: ImSenderContext | undefined;
80
- /** A zone that beats every other source (a scheduled task's zone); internal callers only. */
80
+ /** A zone that beats every other source (an automation's zone); internal callers only. */
81
81
  timeZoneOverride?: string | undefined;
82
82
  }): Promise<MessageContext>;
@@ -84,7 +84,7 @@ export async function recipientLocale(t, input) {
84
84
  * - `sender`: the account's display name and org role at send time; the org's anonymous guest
85
85
  * account (`org_anonymous_accounts`) is `{ name: <senderName, else "Anonymous guest">, role:
86
86
  * "guest", anonymous: true }`. Names are sanitised; an empty one leaves `sender` out.
87
- * - `timeZone`: the override (`timeZoneOverride`, when valid: a scheduled task's zone, scheduled
87
+ * - `timeZone`: the override (`timeZoneOverride`, when valid: an automation's zone, scheduled
88
88
  * tasks spec §6), else what the IM platform gave for the sender (`im`, when valid), else the
89
89
  * account's setting, else the browser's (when valid), else the org default, else UTC. The
90
90
  * anonymous guest account has no setting of its own, so it gets the IM value or the org default.
@@ -12,6 +12,7 @@ export declare class PermissionProfileStore {
12
12
  account_id: string;
13
13
  agent_id: string;
14
14
  archived_at: Date | null;
15
+ automation_id: string | null;
15
16
  consumed_seq: string;
16
17
  create_request_hash: string | null;
17
18
  create_request_id: string | null;
@@ -31,11 +32,11 @@ export declare class PermissionProfileStore {
31
32
  project_path: string | null;
32
33
  queue_pause_reason: string | null;
33
34
  queue_paused: boolean;
34
- scheduled_task_id: string | null;
35
35
  selection: unknown;
36
36
  source: "channel_dm" | "channel_group" | "subagent" | "web";
37
37
  subagent_depth: number;
38
38
  subagent_type: string | null;
39
+ subject: import("../db/kernel-schema.js").ConversationSubject | null;
39
40
  title: string | null;
40
41
  title_attempts: number;
41
42
  title_source: import("../db/kernel-schema.js").TitleSource | null;
@@ -16,6 +16,9 @@ export declare const FirstMessageBody: z.ZodObject<{
16
16
  uri: z.ZodString;
17
17
  }, z.core.$strict>>>;
18
18
  files: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
19
+ projectFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
+ path: z.ZodString;
21
+ }, z.core.$strict>>>;
19
22
  model: z.ZodOptional<z.ZodObject<{
20
23
  provider: z.ZodString;
21
24
  model: z.ZodString;
@@ -123,7 +123,7 @@ let PermissionProfilesService = class PermissionProfilesService {
123
123
  }
124
124
  async setLocked(orgId, id, accountId, body, binding) {
125
125
  let row = await this.store.own(orgId, id, accountId);
126
- if (row.parent_conversation_id || row.kind !== "chat" || row.scheduled_task_id)
126
+ if (row.parent_conversation_id || row.kind !== "chat" || row.automation_id)
127
127
  throw new ApiError("forbidden", "Only interactive root conversations have editable permissions");
128
128
  const subject = {
129
129
  orgId,
@@ -78,7 +78,7 @@ export interface SuggestionEligibilityInput {
78
78
  }
79
79
  /**
80
80
  * Whether a finished run may get a suggestion by its outcome, conversation and trigger (spec §2):
81
- * `completed` or `max_steps`, a `chat` conversation from `web`, not a scheduled or compact run.
81
+ * `completed` or `max_steps`, a `chat` conversation from `web`, not an automation's or compact run.
82
82
  * The final reply, freshness and the switches are checked elsewhere.
83
83
  */
84
84
  export declare function suggestionEligible(i: SuggestionEligibilityInput): boolean;