@capybara-hq/kernel 0.1.0-rc.21 → 0.1.0-rc.22

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 (242) hide show
  1. package/dist/agents/admin-agents.d.ts +16 -3
  2. package/dist/agents/admin-agents.js +65 -7
  3. package/dist/agents/agents.schemas.d.ts +24 -6
  4. package/dist/agents/agents.service.d.ts +4 -3
  5. package/dist/agents/agents.service.js +39 -26
  6. package/dist/agents/definition.d.ts +44 -6
  7. package/dist/agents/definition.js +86 -18
  8. package/dist/agents/from-template.d.ts +6 -3
  9. package/dist/agents/from-template.js +57 -44
  10. package/dist/agents/org-templates.js +97 -41
  11. package/dist/agents/templates.d.ts +6 -0
  12. package/dist/agents/templates.js +15 -1
  13. package/dist/catalog/admin-catalog.controller.d.ts +2 -4
  14. package/dist/catalog/admin-catalog.controller.js +2 -6
  15. package/dist/catalog/catalog.module.js +3 -0
  16. package/dist/catalog/claude/report.d.ts +9 -2
  17. package/dist/catalog/claude/report.js +1 -0
  18. package/dist/catalog/claude/translate.js +1 -1
  19. package/dist/catalog/component-promotion.js +1 -2
  20. package/dist/catalog/component-state.d.ts +13 -1
  21. package/dist/catalog/component-state.js +14 -5
  22. package/dist/catalog/marketplaces.service.d.ts +1 -1
  23. package/dist/catalog/marketplaces.service.js +2 -1
  24. package/dist/catalog/org-catalog.controller.d.ts +13 -3
  25. package/dist/catalog/org-catalog.controller.js +26 -4
  26. package/dist/catalog/org-catalog.schemas.d.ts +13 -0
  27. package/dist/catalog/org-catalog.schemas.js +34 -0
  28. package/dist/catalog/org-plugin-uploads.controller.js +0 -1
  29. package/dist/catalog/org-plugin-uploads.d.ts +0 -1
  30. package/dist/catalog/org-plugin-uploads.js +0 -3
  31. package/dist/catalog/org-plugin-uploads.schemas.d.ts +0 -1
  32. package/dist/catalog/org-plugin-uploads.schemas.js +0 -2
  33. package/dist/catalog/platform-components.d.ts +0 -1
  34. package/dist/catalog/platform-components.js +3 -8
  35. package/dist/catalog/plugin-import.d.ts +0 -8
  36. package/dist/catalog/plugin-import.js +4 -35
  37. package/dist/catalog/plugin-install.d.ts +2 -2
  38. package/dist/catalog/plugin-install.js +2 -2
  39. package/dist/catalog/plugin-package.d.ts +7 -0
  40. package/dist/catalog/plugin-package.js +27 -1
  41. package/dist/catalog/plugin-upgrade.d.ts +5 -6
  42. package/dist/catalog/plugin-upgrade.js +5 -23
  43. package/dist/catalog/requests.service.d.ts +66 -10
  44. package/dist/catalog/requests.service.js +196 -15
  45. package/dist/channels/actions.d.ts +2 -0
  46. package/dist/channels/actions.js +19 -4
  47. package/dist/channels/cards.d.ts +16 -2
  48. package/dist/channels/cards.js +40 -7
  49. package/dist/channels/channels.module.js +3 -0
  50. package/dist/channels/outbound.d.ts +22 -1
  51. package/dist/channels/outbound.js +116 -7
  52. package/dist/channels/phrases.d.ts +25 -0
  53. package/dist/channels/phrases.js +19 -0
  54. package/dist/channels/threads.d.ts +12 -0
  55. package/dist/channels/threads.js +34 -0
  56. package/dist/config/schema.d.ts +23 -1
  57. package/dist/config/schema.js +105 -5
  58. package/dist/conversations/conversations.service.d.ts +42 -9
  59. package/dist/conversations/conversations.service.js +57 -25
  60. package/dist/conversations/events.d.ts +106 -11
  61. package/dist/conversations/events.js +121 -18
  62. package/dist/conversations/message-context.d.ts +6 -3
  63. package/dist/conversations/message-context.js +14 -10
  64. package/dist/conversations/queue.d.ts +15 -2
  65. package/dist/conversations/queue.js +22 -3
  66. package/dist/conversations/queue.service.d.ts +12 -6
  67. package/dist/conversations/queue.service.js +36 -13
  68. package/dist/db/kernel-schema.d.ts +105 -3
  69. package/dist/devices/conversation-devices.d.ts +8 -1
  70. package/dist/devices/conversation-devices.js +8 -0
  71. package/dist/devices/devices.controller.d.ts +21 -4
  72. package/dist/devices/devices.controller.js +46 -8
  73. package/dist/devices/devices.schemas.d.ts +9 -1
  74. package/dist/devices/devices.schemas.js +11 -3
  75. package/dist/devices/devices.service.d.ts +176 -4
  76. package/dist/devices/devices.service.js +341 -6
  77. package/dist/devices/dto.d.ts +56 -3
  78. package/dist/devices/dto.js +51 -1
  79. package/dist/devices/public-suffix.d.ts +6 -0
  80. package/dist/devices/public-suffix.js +79 -0
  81. package/dist/errors.d.ts +46 -5
  82. package/dist/errors.js +46 -5
  83. package/dist/evals/reconstruct.d.ts +18 -13
  84. package/dist/evals/reconstruct.js +50 -36
  85. package/dist/evals/recorded-tools.d.ts +7 -7
  86. package/dist/evals/recorded-tools.js +4 -3
  87. package/dist/evals/trajectory.d.ts +6 -1
  88. package/dist/evals/trajectory.js +7 -0
  89. package/dist/extensions/package.js +2 -2
  90. package/dist/http/api.module.js +5 -0
  91. package/dist/inbox/inbox.module.js +2 -1
  92. package/dist/inbox/inbox.service.d.ts +19 -4
  93. package/dist/inbox/inbox.service.js +14 -3
  94. package/dist/infra/config/kernel-config.service.js +11 -0
  95. package/dist/infra/events/kernel-events.d.ts +2 -1
  96. package/dist/local-devices/device-policy.service.d.ts +65 -0
  97. package/dist/local-devices/device-policy.service.js +217 -0
  98. package/dist/local-devices/local-device-gateway.js +4 -1
  99. package/dist/local-devices/local-device-provider.d.ts +40 -3
  100. package/dist/local-devices/local-device-provider.js +109 -7
  101. package/dist/local-devices/local-devices.module.d.ts +2 -1
  102. package/dist/local-devices/local-devices.module.js +19 -3
  103. package/dist/local-devices/machines.d.ts +14 -3
  104. package/dist/local-devices/machines.js +41 -3
  105. package/dist/local-devices/network-grants.d.ts +104 -0
  106. package/dist/local-devices/network-grants.js +288 -0
  107. package/dist/local-devices/policy-summary.d.ts +20 -0
  108. package/dist/local-devices/policy-summary.js +63 -0
  109. package/dist/orgs/orgs.module.js +4 -10
  110. package/dist/orgs/roles.d.ts +1 -1
  111. package/dist/orgs/roles.js +4 -0
  112. package/dist/orgs/settings.controller.js +2 -1
  113. package/dist/orgs/settings.service.d.ts +164 -12
  114. package/dist/orgs/settings.service.js +212 -24
  115. package/dist/platform/exclusions.js +11 -1
  116. package/dist/platform/operation.js +4 -0
  117. package/dist/platform/ops/admin-items.ops.js +1 -1
  118. package/dist/platform/ops/agent-skills.ops.js +2 -2
  119. package/dist/platform/ops/agent-templates.ops.js +2 -2
  120. package/dist/platform/ops/agents.ops.js +11 -15
  121. package/dist/platform/ops/devices.ops.js +3 -1
  122. package/dist/platform/ops/inbox.ops.js +19 -0
  123. package/dist/platform/ops/org-settings.ops.js +14 -5
  124. package/dist/platform/ops/platform.ops.d.ts +9 -1
  125. package/dist/platform/ops/platform.ops.js +34 -12
  126. package/dist/platform/ops/requests.ops.js +3 -2
  127. package/dist/platform/ops/schedules.ops.d.ts +21 -0
  128. package/dist/platform/ops/schedules.ops.js +470 -0
  129. package/dist/platform/ops/skills.ops.js +3 -3
  130. package/dist/platform/platform-ops.module.d.ts +2 -1
  131. package/dist/platform/platform-ops.module.js +5 -0
  132. package/dist/platform/route-schemas.js +3 -0
  133. package/dist/roles/worker.module.js +3 -0
  134. package/dist/runtime/context/build.js +13 -4
  135. package/dist/runtime/context/compaction.js +6 -3
  136. package/dist/runtime/context/device-paths.d.ts +43 -21
  137. package/dist/runtime/context/device-paths.js +104 -21
  138. package/dist/runtime/context/run-context.d.ts +9 -0
  139. package/dist/runtime/context/run-context.js +8 -0
  140. package/dist/runtime/context/skills.d.ts +14 -1
  141. package/dist/runtime/context/skills.js +36 -5
  142. package/dist/runtime/maintenance.d.ts +4 -2
  143. package/dist/runtime/maintenance.js +16 -5
  144. package/dist/runtime/run-finish.d.ts +6 -1
  145. package/dist/runtime/run-finish.js +16 -2
  146. package/dist/runtime/run-queue.js +21 -2
  147. package/dist/runtime/run-worker.js +14 -33
  148. package/dist/runtime/runtime.module.js +3 -0
  149. package/dist/runtime/subagents/definition.d.ts +32 -14
  150. package/dist/runtime/subagents/definition.js +106 -109
  151. package/dist/runtime/subagents/dispatch.js +4 -3
  152. package/dist/runtime/subagents/preamble.d.ts +2 -1
  153. package/dist/runtime/subagents/preamble.js +2 -1
  154. package/dist/runtime/waits.js +14 -4
  155. package/dist/sandbox/sandbox.service.d.ts +120 -10
  156. package/dist/sandbox/sandbox.service.js +335 -28
  157. package/dist/sandbox/tiers.d.ts +86 -0
  158. package/dist/sandbox/tiers.js +96 -0
  159. package/dist/schedules/effective-settings.d.ts +16 -0
  160. package/dist/schedules/effective-settings.js +17 -0
  161. package/dist/schedules/errors.d.ts +8 -0
  162. package/dist/schedules/errors.js +8 -0
  163. package/dist/schedules/fire.d.ts +118 -0
  164. package/dist/schedules/fire.js +625 -0
  165. package/dist/schedules/grant-rules.d.ts +94 -0
  166. package/dist/schedules/grant-rules.js +126 -0
  167. package/dist/schedules/job-ids.d.ts +32 -0
  168. package/dist/schedules/job-ids.js +27 -0
  169. package/dist/schedules/pause.d.ts +9 -0
  170. package/dist/schedules/pause.js +33 -0
  171. package/dist/schedules/run-tracker.d.ts +81 -0
  172. package/dist/schedules/run-tracker.js +333 -0
  173. package/dist/schedules/scan.job.d.ts +64 -0
  174. package/dist/schedules/scan.job.js +303 -0
  175. package/dist/schedules/schedule-math.d.ts +31 -0
  176. package/dist/schedules/schedule-math.js +223 -0
  177. package/dist/schedules/scheduled-tasks.service.d.ts +351 -0
  178. package/dist/schedules/scheduled-tasks.service.js +1193 -0
  179. package/dist/schedules/schedules.controller.d.ts +68 -0
  180. package/dist/schedules/schedules.controller.js +242 -0
  181. package/dist/schedules/schedules.module.d.ts +16 -0
  182. package/dist/schedules/schedules.module.js +65 -0
  183. package/dist/schedules/schedules.schemas.d.ts +316 -0
  184. package/dist/schedules/schedules.schemas.js +186 -0
  185. package/dist/schedules/store.d.ts +81 -0
  186. package/dist/schedules/store.js +390 -0
  187. package/dist/schedules/store.module.d.ts +6 -0
  188. package/dist/schedules/store.module.js +21 -0
  189. package/dist/schedules/types.d.ts +108 -0
  190. package/dist/schedules/types.js +1 -0
  191. package/dist/schedules/unattended.d.ts +117 -0
  192. package/dist/schedules/unattended.js +228 -0
  193. package/dist/setup/oauth-token-probe.js +8 -4
  194. package/dist/skills/agent-skills.service.d.ts +4 -8
  195. package/dist/skills/agent-skills.service.js +18 -53
  196. package/dist/skills/catalog.d.ts +65 -62
  197. package/dist/skills/catalog.js +109 -206
  198. package/dist/skills/conversation-catalog.d.ts +3 -3
  199. package/dist/skills/conversation-catalog.js +5 -12
  200. package/dist/skills/invoke.d.ts +2 -2
  201. package/dist/skills/skills.controller.d.ts +3 -1
  202. package/dist/skills/skills.service.d.ts +38 -37
  203. package/dist/skills/skills.service.js +168 -107
  204. package/dist/skills/usable.d.ts +57 -8
  205. package/dist/skills/usable.js +172 -38
  206. package/dist/tools/approvals.controller.d.ts +4 -2
  207. package/dist/tools/approvals.controller.js +17 -2
  208. package/dist/tools/approvals.schemas.d.ts +1 -0
  209. package/dist/tools/approvals.schemas.js +3 -1
  210. package/dist/tools/approvals.service.d.ts +182 -7
  211. package/dist/tools/approvals.service.js +597 -13
  212. package/dist/tools/builtin-names.d.ts +25 -4
  213. package/dist/tools/builtin-names.js +45 -4
  214. package/dist/tools/builtins/builtin-tools.d.ts +8 -0
  215. package/dist/tools/builtins/builtin-tools.js +23 -2
  216. package/dist/tools/builtins/sandbox/bash.js +16 -7
  217. package/dist/tools/builtins/sandbox/common.d.ts +1 -1
  218. package/dist/tools/builtins/sandbox/common.js +33 -10
  219. package/dist/tools/builtins/sandbox/edit.js +7 -3
  220. package/dist/tools/builtins/sandbox/file-state.d.ts +31 -1
  221. package/dist/tools/builtins/sandbox/file-state.js +33 -3
  222. package/dist/tools/builtins/sandbox/write.js +8 -4
  223. package/dist/tools/builtins/schedules.d.ts +107 -0
  224. package/dist/tools/builtins/schedules.js +789 -0
  225. package/dist/tools/elicitation.d.ts +2 -0
  226. package/dist/tools/elicitation.js +1 -1
  227. package/dist/tools/fixed-ask.d.ts +7 -0
  228. package/dist/tools/fixed-ask.js +9 -0
  229. package/dist/tools/network-asks.d.ts +109 -0
  230. package/dist/tools/network-asks.js +221 -0
  231. package/dist/tools/pipeline.d.ts +53 -6
  232. package/dist/tools/pipeline.js +202 -13
  233. package/dist/tools/policy.d.ts +21 -8
  234. package/dist/tools/policy.js +63 -9
  235. package/dist/tools/registry.d.ts +10 -1
  236. package/dist/tools/tools.module.js +12 -0
  237. package/package.json +2 -2
  238. package/src/migrations/0113_scheduled_tasks.sql +108 -0
  239. package/src/migrations/0114_network_asks.sql +23 -0
  240. package/src/migrations/0115_network_requests.sql +28 -0
  241. package/src/migrations/0116_skills_default_on.sql +37 -0
  242. package/src/migrations/0117_sandbox_tiers.sql +11 -0
@@ -1,5 +1,9 @@
1
1
  import { type ContentBlock, type MediaSource } from "@capybara-hq/plugin-sdk";
2
2
  import { z } from "zod";
3
+ /** The most hosts one network ask (and one `network_blocked` event) lists. */
4
+ export declare const NETWORK_ASK_MAX_HOSTS = 20;
5
+ /** The longest host name a network ask or `network_blocked` event carries. */
6
+ export declare const NETWORK_HOST_MAX_CHARS = 255;
3
7
  /** The longest deny reason (characters): the decision route's limit and `approval_decided.reason`'s. */
4
8
  export declare const APPROVAL_DENY_REASON_MAX_CHARS = 500;
5
9
  /** 一条 `media_excluded` 事件最多的附件数。 */
@@ -87,9 +91,12 @@ export type LogContentBlock = Exclude<ContentBlock, MediaBlock> | (MediaBlock ex
87
91
  /**
88
92
  * Structured view of a builtin tool's result (UI refresh B, spec §5.5 / §5.9): display only, like
89
93
  * `display`. `command`: `Bash` (the model's `description`, the exit code, null when the
90
- * command was stopped, and whether it timed out; the web shows "Failed" for a non-zero exit even
91
- * though `isError` stays false); `edit`: `Edit` / `Write` (a capped line diff);
92
- * `read`: `Read` (the line range shown).
94
+ * command was stopped, and whether it timed out; a non-zero exit is information, not a failure:
95
+ * the web shows "Failed" only for a timeout or a stopped command, as `isError` does);
96
+ * `edit`: `Edit` / `Write` (a capped line diff); `read`: `Read` (the line range shown);
97
+ * `guard`: `Edit` / `Write` refused by the read-before-write check (`not_read`: the file was never
98
+ * read in the conversation, `modified`: it changed since). The result stays `isError: true` for
99
+ * the model; the web shows the refusal as a neutral outcome, not a failure.
93
100
  */
94
101
  export declare const ToolViewSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
95
102
  kind: z.ZodLiteral<"command">;
@@ -130,6 +137,12 @@ export declare const ToolViewSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
130
137
  size: z.ZodNumber;
131
138
  sha256: z.ZodString;
132
139
  }, z.core.$strip>>;
140
+ }, z.core.$strip>, z.ZodObject<{
141
+ kind: z.ZodLiteral<"guard">;
142
+ reason: z.ZodEnum<{
143
+ modified: "modified";
144
+ not_read: "not_read";
145
+ }>;
133
146
  }, z.core.$strip>], "kind">;
134
147
  export type ToolView = z.infer<typeof ToolViewSchema>;
135
148
  /**
@@ -158,6 +171,15 @@ export declare const MessageSenderSchema: z.ZodObject<{
158
171
  }>>;
159
172
  anonymous: z.ZodOptional<z.ZodLiteral<true>>;
160
173
  }, z.core.$strip>;
174
+ /** `user_message.schedule` (scheduled tasks spec §6): the `ScheduleMarker` shape. */
175
+ export declare const ScheduleMarkerSchema: z.ZodObject<{
176
+ taskId: z.ZodString;
177
+ taskRunId: z.ZodString;
178
+ scheduledFor: z.ZodString;
179
+ trial: z.ZodBoolean;
180
+ taskName: z.ZodString;
181
+ localTime: z.ZodString;
182
+ }, z.core.$strip>;
161
183
  /** `run_context` (run context spec §3.1): every field optional, a later event holds changes only. */
162
184
  export declare const RunContextSchema: z.ZodObject<{
163
185
  agent: z.ZodOptional<z.ZodObject<{
@@ -280,6 +302,14 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
280
302
  }>;
281
303
  agentType: z.ZodOptional<z.ZodString>;
282
304
  }, z.core.$strip>>;
305
+ schedule: z.ZodOptional<z.ZodObject<{
306
+ taskId: z.ZodString;
307
+ taskRunId: z.ZodString;
308
+ scheduledFor: z.ZodString;
309
+ trial: z.ZodBoolean;
310
+ taskName: z.ZodString;
311
+ localTime: z.ZodString;
312
+ }, z.core.$strip>>;
283
313
  dispatch: z.ZodOptional<z.ZodObject<{
284
314
  parentConversationId: z.ZodString;
285
315
  parentRunId: z.ZodString;
@@ -301,6 +331,14 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
301
331
  connectorId: z.ZodString;
302
332
  tools: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodString>]>;
303
333
  }, z.core.$strict>], "kind">>>;
334
+ disabledSkills: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
335
+ kind: z.ZodLiteral<"plugin">;
336
+ plugin: z.ZodString;
337
+ skills: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodString>]>;
338
+ }, z.core.$strict>, z.ZodObject<{
339
+ kind: z.ZodLiteral<"skill">;
340
+ skillId: z.ZodString;
341
+ }, z.core.$strict>], "kind">>>;
304
342
  skills: z.ZodOptional<z.ZodObject<{
305
343
  orgSkills: z.ZodArray<z.ZodString>;
306
344
  pinned: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -340,6 +378,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
340
378
  trigger: z.ZodOptional<z.ZodEnum<{
341
379
  background_task: "background_task";
342
380
  message: "message";
381
+ schedule: "schedule";
343
382
  subagent: "subagent";
344
383
  }>>;
345
384
  triggerSeq: z.ZodOptional<z.ZodNumber>;
@@ -523,6 +562,27 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
523
562
  skills: z.ZodString;
524
563
  tmp: z.ZodString;
525
564
  }, z.core.$strip>;
565
+ tier: z.ZodOptional<z.ZodEnum<{
566
+ dev: "dev";
567
+ open: "open";
568
+ strict: "strict";
569
+ }>>;
570
+ isolation: z.ZodOptional<z.ZodEnum<{
571
+ none: "none";
572
+ sandbox: "sandbox";
573
+ }>>;
574
+ network: z.ZodOptional<z.ZodLiteral<"none">>;
575
+ localhost: z.ZodOptional<z.ZodEnum<{
576
+ off: "off";
577
+ "off-proxy-detected": "off-proxy-detected";
578
+ on: "on";
579
+ }>>;
580
+ unixSockets: z.ZodOptional<z.ZodEnum<{
581
+ "all-masked": "all-masked";
582
+ off: "off";
583
+ roots: "roots";
584
+ }>>;
585
+ unattended: z.ZodOptional<z.ZodLiteral<true>>;
526
586
  }, z.core.$strip>;
527
587
  }, z.core.$strip>, z.ZodObject<{
528
588
  type: z.ZodLiteral<"tool_call_started">;
@@ -588,6 +648,12 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
588
648
  size: z.ZodNumber;
589
649
  sha256: z.ZodString;
590
650
  }, z.core.$strip>>;
651
+ }, z.core.$strip>, z.ZodObject<{
652
+ kind: z.ZodLiteral<"guard">;
653
+ reason: z.ZodEnum<{
654
+ modified: "modified";
655
+ not_read: "not_read";
656
+ }>;
591
657
  }, z.core.$strip>], "kind">>;
592
658
  card: z.ZodOptional<z.ZodObject<{
593
659
  plugin: z.ZodString;
@@ -626,6 +692,9 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
626
692
  org: "org";
627
693
  role: "role";
628
694
  }>>;
695
+ network: z.ZodOptional<z.ZodObject<{
696
+ hosts: z.ZodArray<z.ZodString>;
697
+ }, z.core.$strip>>;
629
698
  }, z.core.$strip>;
630
699
  }, z.core.$strip>, z.ZodObject<{
631
700
  type: z.ZodLiteral<"approval_decided">;
@@ -637,6 +706,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
637
706
  cancelled: "cancelled";
638
707
  denied: "denied";
639
708
  expired: "expired";
709
+ skipped: "skipped";
640
710
  }>;
641
711
  scope: z.ZodOptional<z.ZodEnum<{
642
712
  always: "always";
@@ -720,6 +790,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
720
790
  version: z.ZodNumber;
721
791
  source: z.ZodString;
722
792
  plugin: z.ZodOptional<z.ZodString>;
793
+ nameOnly: z.ZodOptional<z.ZodLiteral<true>>;
723
794
  }, z.core.$strip>>;
724
795
  pinned: z.ZodOptional<z.ZodArray<z.ZodObject<{
725
796
  id: z.ZodString;
@@ -748,6 +819,22 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
748
819
  attempt: z.ZodOptional<z.ZodNumber>;
749
820
  callId: z.ZodOptional<z.ZodString>;
750
821
  }, z.core.$strip>;
822
+ }, z.core.$strip>, z.ZodObject<{
823
+ type: z.ZodLiteral<"network_blocked">;
824
+ payload: z.ZodObject<{
825
+ step: z.ZodNumber;
826
+ callId: z.ZodString;
827
+ hosts: z.ZodArray<z.ZodObject<{
828
+ host: z.ZodString;
829
+ port: z.ZodNumber;
830
+ layer: z.ZodEnum<{
831
+ address: "address";
832
+ device: "device";
833
+ org: "org";
834
+ unknown: "unknown";
835
+ }>;
836
+ }, z.core.$strip>>;
837
+ }, z.core.$strip>;
751
838
  }, z.core.$strip>, z.ZodObject<{
752
839
  type: z.ZodLiteral<"subagent_started">;
753
840
  payload: z.ZodObject<{
@@ -776,6 +863,14 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
776
863
  }, z.core.$strip>>;
777
864
  }, z.core.$strip>;
778
865
  definition: z.ZodObject<{
866
+ skills: z.ZodOptional<z.ZodObject<{
867
+ writePolicy: z.ZodOptional<z.ZodEnum<{
868
+ allow: "allow";
869
+ ask: "ask";
870
+ }>>;
871
+ orgSkills: z.ZodOptional<z.ZodArray<z.ZodString>>;
872
+ pinned: z.ZodOptional<z.ZodArray<z.ZodString>>;
873
+ }, z.core.$strict>>;
779
874
  name: z.ZodString;
780
875
  description: z.ZodOptional<z.ZodString>;
781
876
  avatarUrl: z.ZodDefault<z.ZodNullable<z.ZodURL>>;
@@ -815,14 +910,14 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
815
910
  ask: "ask";
816
911
  deny: "deny";
817
912
  }>>>;
818
- skills: z.ZodOptional<z.ZodObject<{
819
- orgSkills: z.ZodDefault<z.ZodArray<z.ZodString>>;
820
- writePolicy: z.ZodOptional<z.ZodEnum<{
821
- allow: "allow";
822
- ask: "ask";
823
- }>>;
824
- pinned: z.ZodOptional<z.ZodArray<z.ZodString>>;
825
- }, z.core.$strict>>;
913
+ disabledSkills: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
914
+ kind: z.ZodLiteral<"plugin">;
915
+ plugin: z.ZodString;
916
+ skills: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodString>]>;
917
+ }, z.core.$strict>, z.ZodObject<{
918
+ kind: z.ZodLiteral<"skill">;
919
+ skillId: z.ZodString;
920
+ }, z.core.$strict>], "kind">>>;
826
921
  subagents: z.ZodOptional<z.ZodObject<{
827
922
  general: z.ZodOptional<z.ZodBoolean>;
828
923
  templates: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1,6 +1,6 @@
1
1
  import { DOCUMENT_MEDIA_TYPES, hasControlChars, IMAGE_MEDIA_TYPES, isAttachmentId, isSkillName, MEDIA_NAME_MAX_CHARS, } from "@capybara-hq/plugin-sdk";
2
2
  import { z } from "zod";
3
- import { AgentDefinitionSchema, DisabledToolRef, ModelRef } from "../agents/definition.js";
3
+ import { AgentDefinitionSchema, DisabledSkillRef, DisabledToolRef, ModelRef, } from "../agents/definition.js";
4
4
  import { ORG_ROLES } from "../orgs/roles.js";
5
5
  import { TOOL_VIEW_DIFF_MAX_LINES, TOOL_VIEW_LINE_MAX_CHARS, TOOL_VIEW_PATH_MAX_CHARS, } from "../tools/view.js";
6
6
  /** 供应商私有数据(`ProviderOpaque`):原样保存、只回放给同一供应商。 */
@@ -27,6 +27,10 @@ const ApproverFields = {
27
27
  requestedFor: z.string().nullable().optional(),
28
28
  approverRole: z.enum(ORG_ROLES).nullable().optional(),
29
29
  };
30
+ /** The most hosts one network ask (and one `network_blocked` event) lists. */
31
+ export const NETWORK_ASK_MAX_HOSTS = 20;
32
+ /** The longest host name a network ask or `network_blocked` event carries. */
33
+ export const NETWORK_HOST_MAX_CHARS = 255;
30
34
  /** The longest deny reason (characters): the decision route's limit and `approval_decided.reason`'s. */
31
35
  export const APPROVAL_DENY_REASON_MAX_CHARS = 500;
32
36
  /** 一条 `media_excluded` 事件最多的附件数。 */
@@ -98,9 +102,12 @@ const FileStateViewSchema = z.object({
98
102
  /**
99
103
  * Structured view of a builtin tool's result (UI refresh B, spec §5.5 / §5.9): display only, like
100
104
  * `display`. `command`: `Bash` (the model's `description`, the exit code, null when the
101
- * command was stopped, and whether it timed out; the web shows "Failed" for a non-zero exit even
102
- * though `isError` stays false); `edit`: `Edit` / `Write` (a capped line diff);
103
- * `read`: `Read` (the line range shown).
105
+ * command was stopped, and whether it timed out; a non-zero exit is information, not a failure:
106
+ * the web shows "Failed" only for a timeout or a stopped command, as `isError` does);
107
+ * `edit`: `Edit` / `Write` (a capped line diff); `read`: `Read` (the line range shown);
108
+ * `guard`: `Edit` / `Write` refused by the read-before-write check (`not_read`: the file was never
109
+ * read in the conversation, `modified`: it changed since). The result stays `isError: true` for
110
+ * the model; the web shows the refusal as a neutral outcome, not a failure.
104
111
  */
105
112
  export const ToolViewSchema = z.discriminatedUnion("kind", [
106
113
  z.object({
@@ -137,6 +144,10 @@ export const ToolViewSchema = z.discriminatedUnion("kind", [
137
144
  toLine: count.optional(),
138
145
  file: FileStateViewSchema.optional(),
139
146
  }),
147
+ z.object({
148
+ kind: z.literal("guard"),
149
+ reason: z.enum(["not_read", "modified"]),
150
+ }),
140
151
  ]);
141
152
  const ModelUsageShape = {
142
153
  inputTokens: count,
@@ -186,6 +197,15 @@ export const MessageSenderSchema = z.object({
186
197
  /** An IM sender served as the org's anonymous guest; `name` is the IM profile name. */
187
198
  anonymous: z.literal(true).optional(),
188
199
  });
200
+ /** `user_message.schedule` (scheduled tasks spec §6): the `ScheduleMarker` shape. */
201
+ export const ScheduleMarkerSchema = z.object({
202
+ taskId: z.string(),
203
+ taskRunId: z.string(),
204
+ scheduledFor: z.string(),
205
+ trial: z.boolean(),
206
+ taskName: z.string(),
207
+ localTime: z.string(),
208
+ });
189
209
  /** `run_context` (run context spec §3.1): every field optional, a later event holds changes only. */
190
210
  export const RunContextSchema = z.object({
191
211
  /** The agent itself: its name and its versioned description collapsed to one line. */
@@ -208,6 +228,21 @@ export const RunContextSchema = z.object({
208
228
  .optional(),
209
229
  });
210
230
  const ev = (type, payload) => z.object({ type: z.literal(type), payload });
231
+ /**
232
+ * An agent definition frozen into a log (`subagent_started`): the current schema, with the
233
+ * selected and pinned skills of older logs still accepted (skills default-on spec §4: history
234
+ * keeps the old fields; new definitions never carry them).
235
+ */
236
+ const LoggedAgentDefinition = AgentDefinitionSchema.extend({
237
+ skills: z
238
+ .object({
239
+ writePolicy: z.enum(["allow", "ask"]).optional(),
240
+ orgSkills: z.array(z.string()).optional(),
241
+ pinned: z.array(z.string()).optional(),
242
+ })
243
+ .strict()
244
+ .optional(),
245
+ });
211
246
  /**
212
247
  * 会话事件(`type` + `payload`)的判别联合。事件日志只追加,写入前用它校验 payload;
213
248
  * 读出时按写入时的形状原样返回。
@@ -263,6 +298,14 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
263
298
  agentType: z.string().optional(),
264
299
  })
265
300
  .optional(),
301
+ /**
302
+ * A scheduled task's message (scheduled tasks spec §6, §12): which task and tick posted it.
303
+ * Not model-visible as such: request building renders only `taskName` and `localTime`, fixed
304
+ * here at write time, as the header `[Scheduled task "<name>", run for <local time>]`
305
+ * (`scheduleHeader`). The run this message triggers is unattended
306
+ * (`runs.scheduled_task_run_id`).
307
+ */
308
+ schedule: ScheduleMarkerSchema.optional(),
266
309
  /**
267
310
  * Set on a sub-agent's task message (phase C, spec §6.3): which parent call dispatched it.
268
311
  * Not model-visible; the web renders the message as the task block.
@@ -279,8 +322,9 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
279
322
  kind: z.enum(["task", "message"]).optional(),
280
323
  /**
281
324
  * A follow-up (`resume`, final review I1): the frozen and the current version's
282
- * turned-off tools together, and the frozen org skills intersected with the current
283
- * ones (`narrowFollowUp`); the child's run uses these instead of the frozen ones.
325
+ * turned-off tools and skills together (`narrowFollowUp`; older logs: the frozen org
326
+ * skills intersected with the current ones); the child's run uses these instead of the
327
+ * frozen ones.
284
328
  * Absent on a first dispatch and in older logs; logs from before tools were on by
285
329
  * default carry an enabled `tools` list instead of `disabledTools` (read as no tool
286
330
  * narrowing).
@@ -288,6 +332,11 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
288
332
  narrowed: z
289
333
  .object({
290
334
  disabledTools: z.array(DisabledToolRef).optional(),
335
+ /**
336
+ * Skills default-on (spec §6.1): the frozen and the current version's turned-off
337
+ * skills together. Logs from before carry `skills` (`orgSkills` / `pinned`) instead.
338
+ */
339
+ disabledSkills: z.array(DisabledSkillRef).optional(),
291
340
  skills: z
292
341
  .object({ orgSkills: z.array(z.string()), pinned: z.array(z.string()).optional() })
293
342
  .optional(),
@@ -320,9 +369,9 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
320
369
  * What started the run (display only): absent or `message` = a person's message (or a
321
370
  * sub-agent's task), `background_task` = a finished background task woke the conversation
322
371
  * (spec 2026-11-05-background-bash-design §3), `subagent` = a sub-agent's delivery woke it
323
- * (agent map spec §5.3).
372
+ * (agent map spec §5.3), `schedule` = a scheduled task's message (scheduled tasks spec §6).
324
373
  */
325
- trigger: z.enum(["message", "background_task", "subagent"]).optional(),
374
+ trigger: z.enum(["message", "background_task", "subagent", "schedule"]).optional(),
326
375
  /**
327
376
  * A wake run's boundary: the seq of the finish or delivery that woke it (full-run replay
328
377
  * seeds from it).
@@ -444,11 +493,12 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
444
493
  */
445
494
  ev("tools_changed", z.object({ step: count, added: z.array(z.string()), removed: z.array(z.string()) })),
446
495
  /**
447
- * The directories of the instance a sandbox tool call entered, when they differ from the
448
- * defaults (environments spec §13.1: a connected machine's real paths). Written once per
449
- * conversation and roots, before that call's result. **Model-visible**: rendered at its position
450
- * as a system message (`devicePathsText`); a summary covering it is followed by the latest
451
- * one again.
496
+ * The directories of the instance a sandbox tool call entered and the device's sandbox level
497
+ * (environments spec §13.1; sandbox dev tiers spec §11.5: `tier`, `isolation`, and when they
498
+ * apply `network: "none"`, a local device's `localhost` / `unixSockets` and `unattended`; all
499
+ * absent on events recorded before tiers). Written on a conversation's first sandbox call and whenever
500
+ * they change, before that call's result. **Model-visible**: rendered at its position as a
501
+ * system message (`devicePathsText`); a summary covering it is followed by the latest one again.
452
502
  */
453
503
  ev("device_paths", z.object({
454
504
  roots: z.object({
@@ -456,6 +506,12 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
456
506
  skills: z.string().min(1).max(4096),
457
507
  tmp: z.string().min(1).max(4096),
458
508
  }),
509
+ tier: z.enum(["strict", "dev", "open"]).optional(),
510
+ isolation: z.enum(["sandbox", "none"]).optional(),
511
+ network: z.literal("none").optional(),
512
+ localhost: z.enum(["on", "off-proxy-detected", "off"]).optional(),
513
+ unixSockets: z.enum(["roots", "all-masked", "off"]).optional(),
514
+ unattended: z.literal(true).optional(),
459
515
  })),
460
516
  /** 工具调用开始执行之前写入(续跑时「有开始无结果」的调用记为结果未知,不再执行)。 */
461
517
  ev("tool_call_started", z.object({ step: count, callId: z.string(), toolKey: z.string(), specHash: z.string() })),
@@ -513,13 +569,28 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
513
569
  expiresAt: z.string(),
514
570
  /** Which rule asked (UI refresh B; display only, absent in older logs). */
515
571
  policy: z.enum(["agent", "connector", "default", "role", "org", "fixed"]).optional(),
572
+ /**
573
+ * A network ask (network ask-to-allow spec §6.1): the hosts the device owner is asked to
574
+ * allow. Display only, never model-visible: the model sees the call's `tool_result` only.
575
+ */
576
+ network: z
577
+ .object({
578
+ hosts: z
579
+ .array(z.string().min(1).max(NETWORK_HOST_MAX_CHARS))
580
+ .min(1)
581
+ .max(NETWORK_ASK_MAX_HOSTS),
582
+ })
583
+ .optional(),
516
584
  ...ApproverFields,
517
585
  })),
518
- /** 审批已处理(批准 / 拒绝 / 超时 / 取消);`scope` 只在批准时出现,`byAccountId` 为处理人(超时 / 取消为 null)。 */
586
+ /**
587
+ * 审批已处理(批准 / 拒绝 / 超时 / 取消,或 `skipped`:网络询问被运行发起人的消息跳过,`byAccountId`
588
+ * 为消息作者);`scope` 只在批准时出现,`byAccountId` 为处理人(超时 / 取消为 null)。
589
+ */
519
590
  ev("approval_decided", z.object({
520
591
  approvalId: z.string(),
521
592
  callId: z.string(),
522
- decision: z.enum(["approved", "denied", "expired", "cancelled"]),
593
+ decision: z.enum(["approved", "denied", "expired", "cancelled", "skipped"]),
523
594
  scope: z.enum(["once", "session", "always"]).optional(),
524
595
  byAccountId: z.string().nullable(),
525
596
  /**
@@ -599,6 +670,12 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
599
670
  * resolves `<plugin>:<name>` with it; it is not model-visible otherwise.
600
671
  */
601
672
  plugin: z.string().min(1).max(64).optional(),
673
+ /**
674
+ * Listed by name only, past the catalog budget (`skills.catalogBudgetChars`, skills
675
+ * default-on spec §7): decided when the snapshot is written, so a later budget never
676
+ * changes an old request. Absent in every snapshot before phase 2 (= described).
677
+ */
678
+ nameOnly: z.literal(true).optional(),
602
679
  }))
603
680
  .max(SKILLS_CATALOG_MAX),
604
681
  /**
@@ -638,6 +715,24 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
638
715
  attempt: count.optional(),
639
716
  callId: z.string().optional(),
640
717
  })),
718
+ /**
719
+ * The network refusals a command reported (network ask-to-allow spec §6.5), whether or not they
720
+ * raised an ask: the web draws the facts and the org-layer request under the command's row. Not
721
+ * model-visible: request building skips it; the model sees only the call's `tool_result` (the
722
+ * device's trailer and the kernel's note).
723
+ */
724
+ ev("network_blocked", z.object({
725
+ step: count,
726
+ callId: z.string(),
727
+ hosts: z
728
+ .array(z.object({
729
+ host: z.string().min(1).max(NETWORK_HOST_MAX_CHARS),
730
+ port: z.number().int().min(1).max(65535),
731
+ layer: z.enum(["device", "org", "address", "unknown"]),
732
+ }))
733
+ .min(1)
734
+ .max(NETWORK_ASK_MAX_HOSTS),
735
+ })),
641
736
  /**
642
737
  * The first event of a sub-agent's (child) conversation (phase C, spec §6.3), written once in the
643
738
  * dispatch transaction. Request building for a `subagent` conversation takes the definition and
@@ -671,9 +766,15 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
671
766
  .object({ id: z.string(), version: z.number().int(), name: z.string() })
672
767
  .optional(),
673
768
  }),
674
- /** The effective (narrowed) definition, frozen at dispatch. */
675
- definition: AgentDefinitionSchema,
676
- /** `SUBAGENT_PREAMBLE` at dispatch time. */
769
+ /**
770
+ * The effective (narrowed) definition, frozen at dispatch. Logs from before skills were on
771
+ * by default also carry `skills.orgSkills` / `skills.pinned` (skills default-on spec §4).
772
+ */
773
+ definition: LoggedAgentDefinition,
774
+ /**
775
+ * `SUBAGENT_PREAMBLE` at dispatch time; since skills were on by default, followed by the line
776
+ * naming a template's skills the child loads first (skills default-on spec §6.1).
777
+ */
677
778
  preamble: z.string(),
678
779
  maxSteps: z.number().int().positive(),
679
780
  warnings: z.array(z.string()).optional(),
@@ -849,6 +950,8 @@ void _effort;
849
950
  const _usage = true;
850
951
  const _toolResult = true;
851
952
  void _toolResult;
953
+ const _schedule = true;
954
+ void _schedule;
852
955
  void _blocks;
853
956
  void _logIsBlock;
854
957
  void _stop;
@@ -59,9 +59,10 @@ 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`: what the IM platform gave for the sender (`im`, when valid), else the account's
63
- * setting, else the browser's (when valid), else the org default, else UTC. The anonymous guest
64
- * account has no setting of its own, so it gets the IM value or the org default.
62
+ * - `timeZone`: the override (`timeZoneOverride`, when valid: a scheduled task's zone, scheduled
63
+ * tasks spec §6), else what the IM platform gave for the sender (`im`, when valid), else the
64
+ * account's setting, else the browser's (when valid), else the org default, else UTC. The
65
+ * anonymous guest account has no setting of its own, so it gets the IM value or the org default.
65
66
  * - `locale`: the IM platform's value, else the browser's UI language, else the UI language of the
66
67
  * person's most recent web message in the org ({@link latestWebLocale}; not for the shared
67
68
  * anonymous guest account), else the org's `locale`.
@@ -76,4 +77,6 @@ export declare function readMessageContext(t: KernelSchemaDb, input: {
76
77
  browser?: BrowserContext | undefined;
77
78
  /** An IM message: what the platform gave for the sender (maintainer decision 2026-11-08). */
78
79
  im?: ImSenderContext | undefined;
80
+ /** A zone that beats every other source (a scheduled task's zone); internal callers only. */
81
+ timeZoneOverride?: string | undefined;
79
82
  }): Promise<MessageContext>;
@@ -84,9 +84,10 @@ 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`: what the IM platform gave for the sender (`im`, when valid), else the account's
88
- * setting, else the browser's (when valid), else the org default, else UTC. The anonymous guest
89
- * account has no setting of its own, so it gets the IM value or the org default.
87
+ * - `timeZone`: the override (`timeZoneOverride`, when valid: a scheduled task's zone, scheduled
88
+ * tasks spec §6), else what the IM platform gave for the sender (`im`, when valid), else the
89
+ * account's setting, else the browser's (when valid), else the org default, else UTC. The
90
+ * anonymous guest account has no setting of its own, so it gets the IM value or the org default.
90
91
  * - `locale`: the IM platform's value, else the browser's UI language, else the UI language of the
91
92
  * person's most recent web message in the org ({@link latestWebLocale}; not for the shared
92
93
  * anonymous guest account), else the org's `locale`.
@@ -124,13 +125,16 @@ export async function readMessageContext(t, input) {
124
125
  const im = input.im?.timeZone;
125
126
  const own = row?.time_zone ?? null;
126
127
  const browser = input.browser?.timeZone;
127
- const timeZone = im !== undefined && isTimeZone(im)
128
- ? im
129
- : own !== null && isTimeZone(own)
130
- ? own
131
- : browser !== undefined && isTimeZone(browser)
132
- ? browser
133
- : (org.timeZone ?? "UTC");
128
+ const override = input.timeZoneOverride;
129
+ const timeZone = override !== undefined && isTimeZone(override)
130
+ ? override
131
+ : im !== undefined && isTimeZone(im)
132
+ ? im
133
+ : own !== null && isTimeZone(own)
134
+ ? own
135
+ : browser !== undefined && isTimeZone(browser)
136
+ ? browser
137
+ : (org.timeZone ?? "UTC");
134
138
  const locale = input.im?.locale ??
135
139
  input.browser?.locale ??
136
140
  (row !== undefined && !anonymous
@@ -1,6 +1,7 @@
1
1
  import { type ModelRef } from "../agents/definition.js";
2
2
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
3
3
  import { ApiError } from "../errors.js";
4
+ import type { ScheduleMarker } from "../schedules/types.js";
4
5
  import { type InvocationRecord, type RenderedInvocation } from "../skills/invoke.js";
5
6
  import type { AttachmentRef } from "./conversations.service.js";
6
7
  import { type AppendEvent, type EventLog } from "./event-log.js";
@@ -28,6 +29,14 @@ export interface QueuedSkill {
28
29
  invokedAs: string;
29
30
  record: InvocationRecord;
30
31
  }
32
+ /**
33
+ * A scheduled task's queued message (scheduled tasks spec §6), stored in
34
+ * `conversation_queue.schedule`: the marker the `user_message` carries and the task's zone, which
35
+ * becomes the message's `timeZone` (the top-priority override of `readMessageContext`).
36
+ */
37
+ export type QueuedSchedule = ScheduleMarker & {
38
+ timeZone?: string;
39
+ };
31
40
  /** The caller's transaction handle (the module helpers below run inside it). */
32
41
  type KernelTrx = KernelSchemaDb;
33
42
  /** A queued message as the API returns it. */
@@ -92,9 +101,10 @@ export interface QueueRow {
92
101
  model: unknown;
93
102
  effort: string | null;
94
103
  skill: unknown;
104
+ schedule: unknown;
95
105
  created_at: Date;
96
106
  }
97
- export declare const COLUMNS: readonly ["id", "conversation_id", "account_id", "position", "text", "content", "attachments", "files", "client_message_id", "model", "effort", "skill", "created_at"];
107
+ export declare const COLUMNS: readonly ["id", "conversation_id", "account_id", "position", "text", "content", "attachments", "files", "client_message_id", "model", "effort", "skill", "schedule", "created_at"];
98
108
  /**
99
109
  * Queued text as the event log will store it: NUL becomes U+FFFD (PG rejects NUL in text and
100
110
  * jsonb), the mapping `payloadJson` applies to a direct send (final review m1).
@@ -113,7 +123,10 @@ export declare function storedSkill(invokedAs: string, invoked: RenderedInvocati
113
123
  skill: string;
114
124
  first: LogContentBlock;
115
125
  };
116
- /** The `user_message` a queued item becomes, as `postUserMessage` would have written it. */
126
+ /**
127
+ * The `user_message` a queued item becomes, as `postUserMessage` would have written it; a scheduled
128
+ * task's item carries its marker (without the stored zone, which is in `context`).
129
+ */
117
130
  export declare function queuedUserMessage(r: QueueRow, context?: MessageContext): AppendEvent;
118
131
  /**
119
132
  * Appends a queued item inside `t` (the caller holds the conversation row lock): its pick, re-planned
@@ -28,6 +28,7 @@ export const COLUMNS = [
28
28
  "model",
29
29
  "effort",
30
30
  "skill",
31
+ "schedule",
31
32
  "created_at",
32
33
  ];
33
34
  /**
@@ -77,10 +78,14 @@ export function storedSkill(invokedAs, invoked) {
77
78
  const skill = { invokedAs, record: invoked.skill };
78
79
  return { skill: payloadJson(skill), first: { type: "text", text: invoked.text } };
79
80
  }
80
- /** The `user_message` a queued item becomes, as `postUserMessage` would have written it. */
81
+ /**
82
+ * The `user_message` a queued item becomes, as `postUserMessage` would have written it; a scheduled
83
+ * task's item carries its marker (without the stored zone, which is in `context`).
84
+ */
81
85
  export function queuedUserMessage(r, context = {}) {
82
86
  const attachments = r.attachments;
83
87
  const skill = r.skill;
88
+ const marker = queuedMarker(r);
84
89
  return {
85
90
  type: "user_message",
86
91
  idemKey: userMessageIdemKey(r.client_message_id),
@@ -95,9 +100,18 @@ export function queuedUserMessage(r, context = {}) {
95
100
  ...context,
96
101
  clientMessageId: r.client_message_id,
97
102
  ...(skill !== null && { skill: skill.record }),
103
+ ...(marker !== undefined && { schedule: marker }),
98
104
  },
99
105
  };
100
106
  }
107
+ /** A queued item's schedule marker as the log stores it (the six marker fields), or undefined. */
108
+ function queuedMarker(r) {
109
+ const s = r.schedule;
110
+ if (s === null || s === undefined)
111
+ return undefined;
112
+ const { taskId, taskRunId, scheduledFor, trial, taskName, localTime } = s;
113
+ return { taskId, taskRunId, scheduledFor, trial, taskName, localTime };
114
+ }
101
115
  /**
102
116
  * Appends a queued item inside `t` (the caller holds the conversation row lock): its pick, re-planned
103
117
  * against the selection in effect now, becomes a `model_switched` before the `user_message`, as a
@@ -122,13 +136,18 @@ export async function appendQueuedIn(t, eventLog, conversationId, r) {
122
136
  payload: { ...next, byAccountId: r.account_id, reason: "user" },
123
137
  });
124
138
  }
125
- // run context spec §3.4: no browser values were stored with a leftover row
139
+ // run context spec §3.4: no browser values were stored with a leftover row; a scheduled task's
140
+ // item stored its task's zone, which wins (scheduled tasks spec §6)
126
141
  const org = await t
127
142
  .selectFrom("conversations")
128
143
  .select("org_id")
129
144
  .where("id", "=", conversationId)
130
145
  .executeTakeFirstOrThrow();
131
- const context = await readMessageContext(t, { orgId: org.org_id, accountId: r.account_id });
146
+ const context = await readMessageContext(t, {
147
+ orgId: org.org_id,
148
+ accountId: r.account_id,
149
+ timeZoneOverride: r.schedule?.timeZone,
150
+ });
132
151
  events.push(queuedUserMessage(r, context));
133
152
  const written = await eventLog.appendIn(conversationId, events);
134
153
  if (next !== null) {