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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/agents/agents.schemas.d.ts +9 -9
  2. package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
  3. package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
  4. package/dist/automations/automations.module.d.ts +16 -0
  5. package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
  6. package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
  7. package/dist/automations/automations.schemas.js +253 -0
  8. package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
  9. package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
  10. package/dist/{schedules → automations}/calendar.d.ts +8 -8
  11. package/dist/{schedules → automations}/calendar.js +2 -2
  12. package/dist/automations/effective-settings.d.ts +28 -0
  13. package/dist/automations/effective-settings.js +25 -0
  14. package/dist/automations/errors.d.ts +19 -0
  15. package/dist/automations/errors.js +19 -0
  16. package/dist/automations/events/coalesce.d.ts +28 -0
  17. package/dist/automations/events/coalesce.js +131 -0
  18. package/dist/automations/events/deadline.d.ts +10 -0
  19. package/dist/automations/events/deadline.js +24 -0
  20. package/dist/automations/events/dispatcher.d.ts +74 -0
  21. package/dist/automations/events/dispatcher.js +353 -0
  22. package/dist/automations/events/events.module.d.ts +7 -0
  23. package/dist/automations/events/events.module.js +26 -0
  24. package/dist/automations/events/guards.d.ts +32 -0
  25. package/dist/automations/events/guards.js +87 -0
  26. package/dist/automations/events/sweep.job.d.ts +49 -0
  27. package/dist/automations/events/sweep.job.js +202 -0
  28. package/dist/automations/events/token.d.ts +5 -0
  29. package/dist/automations/events/token.js +5 -0
  30. package/dist/automations/events/trigger-events.service.d.ts +47 -0
  31. package/dist/automations/events/trigger-events.service.js +254 -0
  32. package/dist/{schedules → automations}/fire.d.ts +57 -17
  33. package/dist/{schedules → automations}/fire.js +311 -79
  34. package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
  35. package/dist/{schedules → automations}/grant-rules.js +5 -5
  36. package/dist/automations/job-ids.d.ts +113 -0
  37. package/dist/automations/job-ids.js +117 -0
  38. package/dist/{schedules → automations}/pause.d.ts +3 -3
  39. package/dist/{schedules → automations}/pause.js +3 -3
  40. package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
  41. package/dist/{schedules → automations}/run-tracker.js +68 -56
  42. package/dist/{schedules → automations}/scan.job.d.ts +12 -8
  43. package/dist/{schedules → automations}/scan.job.js +39 -23
  44. package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
  45. package/dist/{schedules → automations}/schedule-math.js +17 -7
  46. package/dist/{schedules → automations}/store.d.ts +57 -27
  47. package/dist/{schedules → automations}/store.js +102 -52
  48. package/dist/automations/store.module.d.ts +6 -0
  49. package/dist/{schedules → automations}/store.module.js +9 -9
  50. package/dist/automations/types.d.ts +178 -0
  51. package/dist/{schedules → automations}/unattended.d.ts +22 -11
  52. package/dist/{schedules → automations}/unattended.js +53 -30
  53. package/dist/catalog/marketplaces.service.d.ts +1 -1
  54. package/dist/channels/channels.module.js +3 -3
  55. package/dist/channels/outbound.d.ts +5 -5
  56. package/dist/channels/outbound.js +17 -17
  57. package/dist/channels/threads.d.ts +1 -1
  58. package/dist/channels/threads.js +1 -1
  59. package/dist/config/schema.d.ts +5 -1
  60. package/dist/config/schema.js +44 -6
  61. package/dist/conversations/approval-profile.d.ts +2 -2
  62. package/dist/conversations/approval-profile.js +3 -3
  63. package/dist/conversations/conversations.controller.d.ts +7 -1
  64. package/dist/conversations/conversations.controller.js +26 -10
  65. package/dist/conversations/conversations.service.d.ts +101 -25
  66. package/dist/conversations/conversations.service.js +132 -32
  67. package/dist/conversations/events.d.ts +46 -0
  68. package/dist/conversations/events.js +54 -3
  69. package/dist/conversations/message-context.d.ts +2 -2
  70. package/dist/conversations/message-context.js +1 -1
  71. package/dist/conversations/permission-profile-store.d.ts +2 -1
  72. package/dist/conversations/permission-profiles.controller.d.ts +3 -0
  73. package/dist/conversations/permission-profiles.service.js +1 -1
  74. package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
  75. package/dist/conversations/prompt-suggestion-request.js +2 -1
  76. package/dist/conversations/queue.d.ts +7 -4
  77. package/dist/conversations/queue.js +6 -2
  78. package/dist/conversations/queue.service.d.ts +5 -5
  79. package/dist/conversations/queue.service.js +20 -14
  80. package/dist/ctx/create-ctx.d.ts +20 -1
  81. package/dist/ctx/create-ctx.js +59 -2
  82. package/dist/db/kernel-schema.d.ts +104 -25
  83. package/dist/devices/device-project-files.service.d.ts +88 -0
  84. package/dist/devices/device-project-files.service.js +249 -0
  85. package/dist/devices/device-projects.service.d.ts +40 -0
  86. package/dist/devices/device-projects.service.js +16 -13
  87. package/dist/devices/devices.controller.d.ts +9 -3
  88. package/dist/devices/devices.controller.js +27 -5
  89. package/dist/devices/devices.module.js +9 -1
  90. package/dist/devices/devices.schemas.js +6 -1
  91. package/dist/devices/dto.d.ts +15 -0
  92. package/dist/devices/dto.js +11 -0
  93. package/dist/devices/project-paths.d.ts +29 -0
  94. package/dist/devices/project-paths.js +66 -0
  95. package/dist/devices/project-rules.d.ts +5 -1
  96. package/dist/devices/project-rules.js +5 -1
  97. package/dist/errors.d.ts +34 -13
  98. package/dist/errors.js +34 -13
  99. package/dist/evals/reconstruct.d.ts +10 -1
  100. package/dist/evals/reconstruct.js +7 -0
  101. package/dist/extensions/host.d.ts +6 -1
  102. package/dist/extensions/host.js +10 -0
  103. package/dist/extensions/permission-set.d.ts +17 -1
  104. package/dist/extensions/permission-set.js +13 -1
  105. package/dist/extensions/permission-view.d.ts +1 -1
  106. package/dist/extensions/permission-view.js +4 -1
  107. package/dist/git/gateway.js +2 -2
  108. package/dist/http/api.module.js +5 -5
  109. package/dist/http/request-signal.d.ts +8 -0
  110. package/dist/http/request-signal.js +14 -0
  111. package/dist/inbox/inbox.module.js +2 -2
  112. package/dist/inbox/inbox.service.d.ts +8 -8
  113. package/dist/inbox/inbox.service.js +7 -7
  114. package/dist/infra/config/kernel-config.service.js +10 -5
  115. package/dist/infra/outbox/registry.d.ts +29 -2
  116. package/dist/infra/outbox/registry.js +30 -7
  117. package/dist/kernel.module.js +3 -0
  118. package/dist/orgs/roles.d.ts +1 -1
  119. package/dist/orgs/roles.js +3 -3
  120. package/dist/orgs/settings.controller.d.ts +1 -1
  121. package/dist/orgs/settings.service.d.ts +27 -11
  122. package/dist/orgs/settings.service.js +42 -24
  123. package/dist/platform/operation.js +2 -2
  124. package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
  125. package/dist/platform/ops/automations.ops.js +560 -0
  126. package/dist/platform/ops/devices.ops.d.ts +3 -1
  127. package/dist/platform/ops/devices.ops.js +77 -3
  128. package/dist/platform/ops/inbox.ops.js +4 -4
  129. package/dist/platform/ops/orgs.ops.js +1 -1
  130. package/dist/platform/ops/platform.ops.js +4 -4
  131. package/dist/platform/platform-ops.module.d.ts +2 -2
  132. package/dist/platform/platform-ops.module.js +5 -5
  133. package/dist/platform/route-schemas.js +3 -3
  134. package/dist/push/jobs.d.ts +3 -3
  135. package/dist/push/jobs.js +2 -2
  136. package/dist/push/preferences.service.js +1 -1
  137. package/dist/push/push-owed.d.ts +3 -3
  138. package/dist/push/push-owed.js +6 -6
  139. package/dist/push/push.schemas.d.ts +4 -4
  140. package/dist/push/push.schemas.js +3 -3
  141. package/dist/push/recipients.d.ts +4 -4
  142. package/dist/push/recipients.js +23 -23
  143. package/dist/push/texts.d.ts +3 -3
  144. package/dist/push/texts.js +2 -2
  145. package/dist/push/triggers.d.ts +1 -1
  146. package/dist/roles/worker.module.js +3 -3
  147. package/dist/runtime/context/build.d.ts +6 -0
  148. package/dist/runtime/context/build.js +14 -3
  149. package/dist/runtime/context/compaction.js +15 -5
  150. package/dist/runtime/context/run-context.d.ts +38 -0
  151. package/dist/runtime/context/run-context.js +54 -0
  152. package/dist/runtime/maintenance.d.ts +8 -4
  153. package/dist/runtime/maintenance.js +37 -16
  154. package/dist/runtime/run-finish.d.ts +4 -4
  155. package/dist/runtime/run-finish.js +3 -3
  156. package/dist/runtime/run-queue.js +12 -7
  157. package/dist/runtime/run-worker.js +7 -1
  158. package/dist/runtime/runtime.module.js +3 -3
  159. package/dist/runtime/subagents/dispatch.js +11 -3
  160. package/dist/sandbox/browse-roots.d.ts +8 -0
  161. package/dist/sandbox/browse-roots.js +22 -0
  162. package/dist/sandbox/network-grants.d.ts +4 -4
  163. package/dist/sandbox/network-grants.js +7 -7
  164. package/dist/sandbox/operation-authority.d.ts +10 -3
  165. package/dist/sandbox/operation-authority.js +20 -10
  166. package/dist/sandbox/operation-intents.d.ts +3 -1
  167. package/dist/sandbox/operation-intents.js +11 -4
  168. package/dist/sandbox/permission-call-grants.js +2 -2
  169. package/dist/sandbox/permission-facts.js +1 -1
  170. package/dist/sandbox/review/classifier.d.ts +2 -2
  171. package/dist/sandbox/review/classifier.js +22 -11
  172. package/dist/sandbox/review/permission-candidate.d.ts +1 -1
  173. package/dist/sandbox/review/permission-candidate.js +1 -1
  174. package/dist/sandbox/sandbox.service.d.ts +15 -5
  175. package/dist/sandbox/sandbox.service.js +14 -8
  176. package/dist/storage/purge.d.ts +1 -1
  177. package/dist/storage/purge.js +2 -2
  178. package/dist/tools/approvals.service.d.ts +6 -6
  179. package/dist/tools/approvals.service.js +19 -19
  180. package/dist/tools/builtin-names.d.ts +12 -12
  181. package/dist/tools/builtin-names.js +29 -29
  182. package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
  183. package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
  184. package/dist/tools/builtins/builtin-tools.d.ts +8 -8
  185. package/dist/tools/builtins/builtin-tools.js +16 -16
  186. package/dist/tools/call-scope.d.ts +1 -1
  187. package/dist/tools/git-asks.js +1 -1
  188. package/dist/tools/git-push-policy.d.ts +3 -3
  189. package/dist/tools/git-push-policy.js +6 -6
  190. package/dist/tools/network-asks.d.ts +3 -3
  191. package/dist/tools/network-asks.js +3 -3
  192. package/dist/tools/pipeline.d.ts +4 -4
  193. package/dist/tools/pipeline.js +2 -2
  194. package/dist/tools/policy.d.ts +3 -3
  195. package/dist/tools/policy.js +3 -3
  196. package/dist/tools/tools.module.js +9 -9
  197. package/package.json +3 -3
  198. package/src/migrations/0188_automations_rename.sql +309 -0
  199. package/src/migrations/0189_event_automations.sql +136 -0
  200. package/dist/platform/ops/schedules.ops.js +0 -509
  201. package/dist/schedules/effective-settings.d.ts +0 -22
  202. package/dist/schedules/effective-settings.js +0 -18
  203. package/dist/schedules/errors.d.ts +0 -8
  204. package/dist/schedules/errors.js +0 -8
  205. package/dist/schedules/job-ids.d.ts +0 -81
  206. package/dist/schedules/job-ids.js +0 -95
  207. package/dist/schedules/schedules.module.d.ts +0 -16
  208. package/dist/schedules/schedules.schemas.js +0 -213
  209. package/dist/schedules/store.module.d.ts +0 -6
  210. package/dist/schedules/types.d.ts +0 -110
  211. /package/dist/{schedules → automations}/types.js +0 -0
@@ -282,7 +282,13 @@ export async function commitDispatchIn(d, a, plan, child) {
282
282
  .executeTakeFirst();
283
283
  const parent = await t
284
284
  .selectFrom("runs")
285
- .select(["status", "subagent_tokens_used", "budget_run_id", "scheduled_task_run_id"])
285
+ .select([
286
+ "status",
287
+ "subagent_tokens_used",
288
+ "budget_run_id",
289
+ "automation_run_id",
290
+ "trigger_event_id",
291
+ ])
286
292
  .where("id", "=", ctx.runId)
287
293
  .forUpdate()
288
294
  .executeTakeFirst();
@@ -377,8 +383,10 @@ export async function commitDispatchIn(d, a, plan, child) {
377
383
  trigger_account_id: ctx.accountId,
378
384
  trigger_seq: task.seq,
379
385
  budget_run_id: budgetRunId,
380
- // an unattended parent's sub-agents are unattended too (scheduled tasks spec §4)
381
- scheduled_task_run_id: parent.scheduled_task_run_id,
386
+ // an unattended parent's sub-agents are unattended too (scheduled tasks spec §4), and an
387
+ // event a sub-agent causes counts its chain from the parent's event (collaboration §4.7)
388
+ automation_run_id: parent.automation_run_id,
389
+ trigger_event_id: parent.trigger_event_id,
382
390
  })
383
391
  .execute();
384
392
  await t
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The read roots of an owner browse narrowed to `narrow` (composer menus §5: a project's files are
3
+ * browsed in a scope rooted at the project path): each narrowing root that lies at or below one of
4
+ * the owner's ceiling roots, never wider than the ceiling. A narrowing root outside every ceiling
5
+ * root, or one that is not absolute and normalized, drops out. The result is deduplicated and may
6
+ * be empty (the caller refuses the browse then).
7
+ */
8
+ export declare function narrowReadRoots(ceiling: readonly string[], narrow: readonly string[]): string[];
@@ -0,0 +1,22 @@
1
+ import { posix } from "node:path";
2
+ /** `path` lies at or below `root` (both absolute and normalized). */
3
+ const within = (path, root) => path === root || root === "/" || path.startsWith(`${root}/`);
4
+ /** An absolute, normalized posix path without a trailing `/` (except `/` itself). */
5
+ const plainAbsolute = (p) => posix.isAbsolute(p) && posix.normalize(p) === p && (p === "/" || !p.endsWith("/"));
6
+ /**
7
+ * The read roots of an owner browse narrowed to `narrow` (composer menus §5: a project's files are
8
+ * browsed in a scope rooted at the project path): each narrowing root that lies at or below one of
9
+ * the owner's ceiling roots, never wider than the ceiling. A narrowing root outside every ceiling
10
+ * root, or one that is not absolute and normalized, drops out. The result is deduplicated and may
11
+ * be empty (the caller refuses the browse then).
12
+ */
13
+ export function narrowReadRoots(ceiling, narrow) {
14
+ const out = new Set();
15
+ for (const n of narrow) {
16
+ if (!plainAbsolute(n))
17
+ continue;
18
+ if (ceiling.some((c) => within(n, c)))
19
+ out.add(n);
20
+ }
21
+ return [...out];
22
+ }
@@ -14,7 +14,7 @@ export interface NetworkRunState {
14
14
  /** A network ask of the run tree is still pending (at most one at a time). */
15
15
  pending: boolean;
16
16
  /**
17
- * Hosts the scheduled task the run serves approves on this device (spec §8.1; unattended runs
17
+ * Hosts the automation the run serves approves on this device (spec §8.1; unattended runs
18
18
  * only, read only with a `deviceId`): never asked about nor recorded as missing. Absent: none.
19
19
  */
20
20
  taskGranted?: Set<string>;
@@ -26,7 +26,7 @@ export interface NetworkRunState {
26
26
  * tree is the runs of one budget window (`runs.budget_run_id` lineage): a sub-agent's run sees the
27
27
  * root's grants, another run tree never does. The hosts a decision allowed are its
28
28
  * `detail.grantedHosts`; a decision without them grants nothing. In an unattended run of a
29
- * scheduled task, the task's `network:<host>` grants (spec §8.1) join them.
29
+ * automation, the task's `network:<host>` grants (spec §8.1) join them.
30
30
  */
31
31
  export declare class NetworkGrants {
32
32
  private readonly db;
@@ -35,7 +35,7 @@ export declare class NetworkGrants {
35
35
  * Hosts allowed for this exec on `deviceId`: the run tree's once-approved network asks in
36
36
  * `orgId` about that device, while the tree's root run has not ended (a grant ends with its run;
37
37
  * a later run of the same budget window does not inherit it), with the root run as their source
38
- * and the latest decider as its account; and in an unattended run of a scheduled task, the
38
+ * and the latest decider as its account; and in an unattended run of an automation, the
39
39
  * task's network grants (spec §8.1) when the device is its creator's, with the task as their
40
40
  * source and the creator as its account. Both together are one grant: the hosts of both, the
41
41
  * task as the source. Undefined when none. The device applies them only when its owner allows
@@ -55,7 +55,7 @@ export declare class NetworkGrants {
55
55
  /** The run tree's once-approved hosts as exec grants (source: the root run). */
56
56
  private runGrants;
57
57
  /**
58
- * A scheduled task's network grants for an unattended run (spec §8.1): the task's
58
+ * An automation's network grants for an unattended run (spec §8.1): the task's
59
59
  * `network:<host>` grants when the run serves a task run that is no trial run and no person
60
60
  * joined (`taskGrantsRunOf`, inherited by its sub-agents), the task is of `orgId` (when given)
61
61
  * and `deviceId` is a live device of the task's org owned by the task's creator (a creator
@@ -10,13 +10,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { validateAllowHost } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
+ import { taskGrantsRunOf } from "../automations/unattended.js";
13
14
  import { KernelDb } from "../infra/database/kernel-db.js";
14
15
  import { budgetRunOf } from "../runtime/subagents/limits.js";
15
- import { taskGrantsRunOf } from "../schedules/unattended.js";
16
16
  import { coversHost } from "./modes.js";
17
17
  /** The most hosts one exec's grants carry (the device protocol's limit). */
18
18
  export const MAX_GRANT_HOSTS = 100;
19
- /** The key prefix of a scheduled task's network grant (`schedules/grant-rules.ts`). */
19
+ /** The key prefix of an automation's network grant (`automations/grant-rules.ts`). */
20
20
  const NETWORK_KEY_PREFIX = "network:";
21
21
  /** The statuses of a run that has not ended: its run grants still apply. */
22
22
  const LIVE_RUN = ["queued", "running", "waiting"];
@@ -54,7 +54,7 @@ function askedOf(detail) {
54
54
  * tree is the runs of one budget window (`runs.budget_run_id` lineage): a sub-agent's run sees the
55
55
  * root's grants, another run tree never does. The hosts a decision allowed are its
56
56
  * `detail.grantedHosts`; a decision without them grants nothing. In an unattended run of a
57
- * scheduled task, the task's `network:<host>` grants (spec §8.1) join them.
57
+ * automation, the task's `network:<host>` grants (spec §8.1) join them.
58
58
  */
59
59
  let NetworkGrants = class NetworkGrants {
60
60
  db;
@@ -65,7 +65,7 @@ let NetworkGrants = class NetworkGrants {
65
65
  * Hosts allowed for this exec on `deviceId`: the run tree's once-approved network asks in
66
66
  * `orgId` about that device, while the tree's root run has not ended (a grant ends with its run;
67
67
  * a later run of the same budget window does not inherit it), with the root run as their source
68
- * and the latest decider as its account; and in an unattended run of a scheduled task, the
68
+ * and the latest decider as its account; and in an unattended run of an automation, the
69
69
  * task's network grants (spec §8.1) when the device is its creator's, with the task as their
70
70
  * source and the creator as its account. Both together are one grant: the hosts of both, the
71
71
  * task as the source. Undefined when none. The device applies them only when its owner allows
@@ -165,7 +165,7 @@ let NetworkGrants = class NetworkGrants {
165
165
  return { hosts, source: { kind: "run", id: root, accountId: latest.decided_by } };
166
166
  }
167
167
  /**
168
- * A scheduled task's network grants for an unattended run (spec §8.1): the task's
168
+ * An automation's network grants for an unattended run (spec §8.1): the task's
169
169
  * `network:<host>` grants when the run serves a task run that is no trial run and no person
170
170
  * joined (`taskGrantsRunOf`, inherited by its sub-agents), the task is of `orgId` (when given)
171
171
  * and `deviceId` is a live device of the task's org owned by the task's creator (a creator
@@ -187,9 +187,9 @@ let NetworkGrants = class NetworkGrants {
187
187
  if (device === undefined)
188
188
  return undefined;
189
189
  const rows = await this.db
190
- .selectFrom("scheduled_task_grants")
190
+ .selectFrom("automation_grants")
191
191
  .select("tool_key")
192
- .where("task_id", "=", task.taskId)
192
+ .where("automation_id", "=", task.taskId)
193
193
  .where("tool_key", "like", `${NETWORK_KEY_PREFIX}%`)
194
194
  .orderBy("tool_key")
195
195
  .execute();
@@ -68,12 +68,19 @@ export declare class SandboxOperationAuthority {
68
68
  private readonly locks;
69
69
  private readonly epochs;
70
70
  constructor(callGrants: PermissionCallGrants, publication: PermissionConfigPublication, db: KernelDb, txHost: TransactionHost, profiles: PermissionProfileStore, facts: PermissionFacts, grants: NetworkGrants, locks: PermissionAuthorityLock, epochs: PermissionAuthorityEpochStore);
71
- /** Owner project browsing has no conversation, profile, or fabricated root identity. */
71
+ /**
72
+ * Owner project browsing has no conversation, profile, or fabricated root identity. `narrow`
73
+ * (absolute paths, e.g. a project root) replaces the scope's read roots with those of its paths
74
+ * that lie inside the owner's ceiling ({@link narrowReadRoots}), never wider; when none does the
75
+ * browse is refused (`device.project_outside_mode`).
76
+ */
72
77
  resolveBrowse(ctx: {
73
78
  orgId: string;
74
79
  deviceId: string;
75
80
  accountId: string;
76
- }, signal: AbortSignal): Promise<SandboxBrowseScope>;
81
+ }, signal: AbortSignal, narrow?: {
82
+ readRoots: readonly string[];
83
+ }): Promise<SandboxBrowseScope>;
77
84
  /**
78
85
  * The one actor liveness predicate of owner browsing, the recorded permission context and the
79
86
  * managed device context writer: an active account that is still a member of a live org.
@@ -115,7 +122,7 @@ export declare class SandboxOperationAuthority {
115
122
  private snapshot;
116
123
  /**
117
124
  * The actual run of an operation or context read: still this conversation's, triggered by this
118
- * actor and not ended; true when it serves a scheduled task run (an unattended child or wake
125
+ * actor and not ended; true when it serves an automation run (an unattended child or wake
119
126
  * included). Shared by admission and the recorded permission context.
120
127
  */
121
128
  private runScheduledLocked;
@@ -18,6 +18,7 @@ import { ApiError } from "../errors.js";
18
18
  import { KernelDb } from "../infra/database/kernel-db.js";
19
19
  import { TransactionHost, withTransactionFencePrelude, } from "../infra/database/transaction-host.js";
20
20
  import { Transactional } from "../infra/database/transactional.decorator.js";
21
+ import { narrowReadRoots } from "./browse-roots.js";
21
22
  import { hostGrantable } from "./device-sandbox.js";
22
23
  import { KernelReadUnsupported, kernelReadCovering, kernelReadRoute, } from "./kernel-read.js";
23
24
  import { coversHost } from "./modes.js";
@@ -144,8 +145,13 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
144
145
  this.locks = locks;
145
146
  this.epochs = epochs;
146
147
  }
147
- /** Owner project browsing has no conversation, profile, or fabricated root identity. */
148
- async resolveBrowse(ctx, signal) {
148
+ /**
149
+ * Owner project browsing has no conversation, profile, or fabricated root identity. `narrow`
150
+ * (absolute paths, e.g. a project root) replaces the scope's read roots with those of its paths
151
+ * that lie inside the owner's ceiling ({@link narrowReadRoots}), never wider; when none does the
152
+ * browse is refused (`device.project_outside_mode`).
153
+ */
154
+ async resolveBrowse(ctx, signal, narrow) {
149
155
  signal.throwIfAborted();
150
156
  await this.locks.acquire({ orgId: ctx.orgId, deviceId: ctx.deviceId }, { kind: "admit" });
151
157
  await this.publication.assertCurrent();
@@ -156,6 +162,12 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
156
162
  const scope = await this.facts.projectScope(ctx.orgId, ctx.accountId, ctx.deviceId);
157
163
  if (!scope.supported)
158
164
  throw new ApiError("device.projects_unsupported", "Current owner and organization ceilings do not permit browsing");
165
+ // the base the picker starts from: the provider's reported home, else the workspace (what
166
+ // the device answers within it is the provider's rule)
167
+ const ceiling = [scope.home ?? scope.workspace];
168
+ const readRoots = narrow === undefined ? ceiling : narrowReadRoots(ceiling, narrow.readRoots);
169
+ if (readRoots.length === 0)
170
+ throw new ApiError("device.project_outside_mode", "The project lies outside what the device lets its owner browse; remove it and add it again from a directory under the device's base");
159
171
  const operationId = randomUUID();
160
172
  const vector = await this.epochs.readLocked({ orgId: ctx.orgId, deviceId: ctx.deviceId });
161
173
  return parseSandboxBrowseScope({
@@ -164,9 +176,7 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
164
176
  accountId: ctx.accountId,
165
177
  admitBeforeMs: Date.now() + 30000,
166
178
  ceilingRevision: permissionScopeHash(vector),
167
- // the base the picker starts from: the provider's reported home, else the workspace (what
168
- // the device answers within it is the provider's rule)
169
- readRoots: [scope.home ?? scope.workspace],
179
+ readRoots,
170
180
  tag: operationId,
171
181
  });
172
182
  }
@@ -461,7 +471,7 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
461
471
  if (view.deviceId !== ctx.deviceId)
462
472
  throw new ApiError("device.not_found", "The conversation is not bound to this device");
463
473
  await this.facts.preview(ctx.orgId, ctx.actor.accountId, ctx.deviceId, root.project_name ?? undefined);
464
- let unattended = root.scheduled_task_id !== null;
474
+ let unattended = root.automation_id !== null;
465
475
  if (ctx.actor.runId)
466
476
  unattended ||= await this.runScheduledLocked(ctx.holderConversationId, ctx.actor.accountId, ctx.actor.runId);
467
477
  const base = await this.baseScopeLocked({
@@ -557,13 +567,13 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
557
567
  }
558
568
  /**
559
569
  * The actual run of an operation or context read: still this conversation's, triggered by this
560
- * actor and not ended; true when it serves a scheduled task run (an unattended child or wake
570
+ * actor and not ended; true when it serves an automation run (an unattended child or wake
561
571
  * included). Shared by admission and the recorded permission context.
562
572
  */
563
573
  async runScheduledLocked(conversationId, accountId, runId) {
564
574
  const run = await this.db
565
575
  .selectFrom("runs")
566
- .select(["conversation_id", "trigger_account_id", "scheduled_task_run_id", "status"])
576
+ .select(["conversation_id", "trigger_account_id", "automation_run_id", "status"])
567
577
  .where("id", "=", runId)
568
578
  .executeTakeFirst();
569
579
  if (!run ||
@@ -571,7 +581,7 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
571
581
  run.trigger_account_id !== accountId ||
572
582
  !["running", "queued", "waiting"].includes(run.status))
573
583
  throw new ApiError("forbidden", "The operation run is no longer authorized");
574
- return run.scheduled_task_run_id !== null;
584
+ return run.automation_run_id !== null;
575
585
  }
576
586
  /**
577
587
  * The call-independent base authority of a device for one root (B1): the device's policy and
@@ -711,7 +721,7 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
711
721
  throw new ApiError("forbidden", "This run's actor is no longer authorized");
712
722
  await this.publication.assertCurrent();
713
723
  const scheduled = (await this.runScheduledLocked(input.conversationId, input.accountId, input.runId)) ||
714
- root.scheduled_task_id !== null;
724
+ root.automation_id !== null;
715
725
  const header = {
716
726
  version: 2,
717
727
  // only a supported context carries the device sandbox block (below)
@@ -102,7 +102,9 @@ export declare class SandboxOperationIntents {
102
102
  orgId: string;
103
103
  deviceId: string;
104
104
  accountId: string;
105
- }, instance: OperationInstance, method: "stat" | "list" | "scan", input: unknown, signal: AbortSignal): Promise<OperationIntent>;
105
+ }, instance: OperationInstance, method: "stat" | "list" | "scan", input: unknown, signal: AbortSignal, narrow?: {
106
+ readRoots: readonly string[];
107
+ }): Promise<OperationIntent>;
106
108
  /**
107
109
  * The run of a kernel read (permission activation L2): the run must still be the claim's
108
110
  * execution, triggered by the actor and in the state its purpose reads in, checked in PG under
@@ -8,7 +8,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
10
  import { createHash, randomUUID } from "node:crypto";
11
- import { parseSandboxExecutionRef, parseSandboxOperationScope, SandboxOperationOutcomeUnknownError, SandboxPermissionUnsupportedError, SandboxScopeDeniedError, ToolError, } from "@capybara-hq/plugin-sdk";
11
+ import { parseSandboxBrowseScope, parseSandboxExecutionRef, parseSandboxOperationScope, SandboxOperationOutcomeUnknownError, SandboxPermissionUnsupportedError, SandboxScopeDeniedError, ToolError, } from "@capybara-hq/plugin-sdk";
12
12
  import { Inject, Injectable } from "@nestjs/common";
13
13
  import { sql } from "kysely";
14
14
  import { STOP_CLAIM_TTL_MS } from "../background/store.js";
@@ -265,8 +265,8 @@ let SandboxOperationIntents = class SandboxOperationIntents {
265
265
  return row;
266
266
  }
267
267
  /** Owner-native reads have their own admission, without a manufactured conversation or run. */
268
- async admitBrowse(ctx, instance, method, input, signal) {
269
- const scope = await this.authority.resolveBrowse(ctx, signal);
268
+ async admitBrowse(ctx, instance, method, input, signal, narrow) {
269
+ const scope = await this.authority.resolveBrowse(ctx, signal, narrow);
270
270
  const described = describeOperationPayload(input);
271
271
  const payload = payloadReference("input", described);
272
272
  const vector = await this.epochs.readLocked({ orgId: ctx.orgId, deviceId: ctx.deviceId });
@@ -466,7 +466,14 @@ let SandboxOperationIntents = class SandboxOperationIntents {
466
466
  denied("The browse admission does not match this owner");
467
467
  if (row.state !== "admitted" || row.deadline.getTime() <= Date.now())
468
468
  denied("Browse admission was revoked or expired");
469
- await this.authority.resolveBrowse(ctx, new AbortController().signal);
469
+ // checked again with the read roots it was admitted with (a project's root narrows them), so
470
+ // a ceiling that moved since then refuses the browse instead of widening or keeping it
471
+ const admitted = parseSandboxBrowseScope(row.scope);
472
+ const fresh = await this.authority.resolveBrowse(ctx, new AbortController().signal, {
473
+ readRoots: admitted.readRoots,
474
+ });
475
+ if (JSON.stringify(fresh.readRoots) !== JSON.stringify(admitted.readRoots))
476
+ denied("Authority changed before the browse was dispatched");
470
477
  await this.db
471
478
  .updateTable("sandbox_operation_intents")
472
479
  .set({ state: "dispatching", updated_at: new Date() })
@@ -83,11 +83,11 @@ let PermissionCallGrants = class PermissionCallGrants {
83
83
  });
84
84
  if (root.id !== binding.rootConversationId ||
85
85
  root.device_id !== binding.deviceId ||
86
- root.scheduled_task_id ||
86
+ root.automation_id ||
87
87
  !run ||
88
88
  run.conversation_id !== binding.conversationId ||
89
89
  run.trigger_account_id !== binding.accountId ||
90
- run.scheduled_task_run_id ||
90
+ run.automation_run_id ||
91
91
  !["running", "waiting", "queued"].includes(run.status) ||
92
92
  device?.owner_account_id !== binding.accountId ||
93
93
  view.availability.state !== "supported" ||
@@ -398,7 +398,7 @@ let PermissionFacts = class PermissionFacts {
398
398
  // a home reported after the project was added can put it above the home: the working root
399
399
  // would fall back for it, so it is not bound (the add rule, project root §4.3)
400
400
  if (aboveHome(row.path, scope.home))
401
- throw tooBroad(row.path);
401
+ throw tooBroad(row.name);
402
402
  return { name: row.name, path: row.path };
403
403
  }
404
404
  async projectMatches(deviceId, name, path) {
@@ -124,8 +124,8 @@ export declare function fitReviewText(build: (text: string, personMessages: stri
124
124
  /** How many of the root conversation's latest person messages are read before bounding the text. */
125
125
  export declare const PERSON_MESSAGES_READ = 20;
126
126
  /**
127
- * The bounded text of the root conversation's last person messages: the `user_message` text blocks
128
- * only, never an assistant message or a tool result, newest {@link PERSON_MESSAGES_READ} read and
127
+ * The bounded text of the root conversation's last person messages: each `user_message`'s own
128
+ * words ({@link textOfUserMessage}), never an assistant message or a tool result, newest {@link PERSON_MESSAGES_READ} read and
129
129
  * bounded to `budget` estimated tokens (`sandbox.review.messageTokens`). The command review and the
130
130
  * tool review read the same messages.
131
131
  */
@@ -261,24 +261,35 @@ export function fitReviewText(build, parts, system, limits, marker) {
261
261
  * ---------------------------------------------------------------------------------------------- */
262
262
  /** How many of the root conversation's latest person messages are read before bounding the text. */
263
263
  export const PERSON_MESSAGES_READ = 20;
264
- /** The text blocks of a `user_message` payload (its images, documents and attachments are skipped). */
264
+ /**
265
+ * The person's own words of a `user_message` payload: `content[0]` when it is a text block (the
266
+ * typed text, or the rendered skill of an invocation) and the kernel-written lines naming the
267
+ * referenced project files (`payload.projectFiles`, blocks `1 + attachments.length + i`: the
268
+ * person's intent, worded by the kernel). The `@` resources' bodies (`payload.attachments`,
269
+ * blocks `1 .. attachments.length`) are content read from a connector, not the person's
270
+ * instructions, so they are skipped, like images, documents and uploaded files.
271
+ */
265
272
  function textOfUserMessage(payload) {
266
- const content = payload?.content;
273
+ const p = payload;
274
+ const content = p?.content;
267
275
  if (!Array.isArray(content))
268
276
  return "";
269
- return content
270
- .flatMap((b) => {
271
- if (b === null || typeof b !== "object")
272
- return [];
273
- const block = b;
274
- return block.type === "text" && typeof block.text === "string" ? [block.text] : [];
275
- })
277
+ const textAt = (i) => {
278
+ const b = content[i];
279
+ return b !== null && typeof b === "object" && b.type === "text" && typeof b.text === "string"
280
+ ? [b.text]
281
+ : [];
282
+ };
283
+ const resources = Array.isArray(p?.attachments) ? p.attachments.length : 0;
284
+ const projectFiles = Array.isArray(p?.projectFiles) ? p.projectFiles.length : 0;
285
+ const first = 1 + resources;
286
+ return [...textAt(0), ...Array.from({ length: projectFiles }, (_, i) => textAt(first + i)).flat()]
276
287
  .join("\n")
277
288
  .trim();
278
289
  }
279
290
  /**
280
- * The bounded text of the root conversation's last person messages: the `user_message` text blocks
281
- * only, never an assistant message or a tool result, newest {@link PERSON_MESSAGES_READ} read and
291
+ * The bounded text of the root conversation's last person messages: each `user_message`'s own
292
+ * words ({@link textOfUserMessage}), never an assistant message or a tool result, newest {@link PERSON_MESSAGES_READ} read and
282
293
  * bounded to `budget` estimated tokens (`sandbox.review.messageTokens`). The command review and the
283
294
  * tool review read the same messages.
284
295
  */
@@ -34,7 +34,7 @@ export declare const isEscalatedCall: (toolKey: string, input: unknown) => boole
34
34
  /** An escalated call without a usable justification: refused before any review. */
35
35
  export declare const ESCALATION_JUSTIFICATION_MISSING_TEXT = "This Bash call asked to run outside the sandbox (sandbox: \"escalated\") without a justification, so it did not run. Retry with justification: one sentence saying why this command must run outside the sandbox, or call Bash without sandbox to run it in the sandbox.";
36
36
  /** Why an escalation cannot be reviewed: an unattended run (no one can approve it). */
37
- export declare const ESCALATION_UNATTENDED_WHY = "this is an unattended run (a scheduled task) where no one can approve running outside the sandbox";
37
+ export declare const ESCALATION_UNATTENDED_WHY = "this is an unattended run (an automation) where no one can approve running outside the sandbox";
38
38
  /**
39
39
  * Why an escalation cannot be reviewed because the device's provider does not allow running
40
40
  * outside its sandbox now, with the provider's own description of the device and how to change it
@@ -78,7 +78,7 @@ export const isEscalatedCall = (toolKey, input) => toolKey === "Bash" &&
78
78
  /** An escalated call without a usable justification: refused before any review. */
79
79
  export const ESCALATION_JUSTIFICATION_MISSING_TEXT = 'This Bash call asked to run outside the sandbox (sandbox: "escalated") without a justification, so it did not run. Retry with justification: one sentence saying why this command must run outside the sandbox, or call Bash without sandbox to run it in the sandbox.';
80
80
  /** Why an escalation cannot be reviewed: an unattended run (no one can approve it). */
81
- export const ESCALATION_UNATTENDED_WHY = "this is an unattended run (a scheduled task) where no one can approve running outside the sandbox";
81
+ export const ESCALATION_UNATTENDED_WHY = "this is an unattended run (an automation) where no one can approve running outside the sandbox";
82
82
  /**
83
83
  * The device's own words appended to a refusal that cites its report: its description (what the
84
84
  * device may do now) and its change hint (who changes that and how), each without a final period,
@@ -385,7 +385,7 @@ export declare class SandboxService {
385
385
  policy?: EffectiveDevicePolicy;
386
386
  }): Promise<DeviceLimits>;
387
387
  /**
388
- * The org's limits for a standing network grant (a scheduled task's grant, a network approval):
388
+ * The org's limits for a standing network grant (an automation's grant, a network approval):
389
389
  * {@link deviceLimits} with the org's per-call host ceiling as an allowlist (`hostGrantCeiling`
390
390
  * with no device). Where that ceiling is bounded by the kernel only (`any`, which an allowlist
391
391
  * cannot carry with its exclusions), the org's effective hosts: a standing grant never reaches
@@ -538,12 +538,18 @@ export declare class SandboxService {
538
538
  /** Trusted staging only. The callback receives no exec, browsing or lifecycle methods. */
539
539
  withPreparation<T>(ctx: SandboxUseContext, purpose: SandboxPreparationScope["purpose"], roots: readonly string[], fn: (p: SandboxPreparation, signal: AbortSignal) => Promise<T>, signal: AbortSignal): Promise<T>;
540
540
  private prepareFor;
541
- /** Owner browse scopes never manufacture a conversation or Full consent. */
541
+ /**
542
+ * Owner browse scopes never manufacture a conversation or Full consent. `narrow.readRoots`
543
+ * roots every call's scope at those paths (a project's files: its root), each inside the owner's
544
+ * ceiling and never wider; none inside it is `device.project_outside_mode`.
545
+ */
542
546
  withBrowse<T>(ctx: {
543
547
  orgId: string;
544
548
  deviceId: string;
545
549
  accountId: string;
546
- }, fn: (p: SandboxBrowse, signal: AbortSignal) => Promise<T>, signal: AbortSignal): Promise<T>;
550
+ }, fn: (p: SandboxBrowse, signal: AbortSignal) => Promise<T>, signal: AbortSignal, narrow?: {
551
+ readRoots: readonly string[];
552
+ }): Promise<T>;
547
553
  /**
548
554
  * Makes the device's instance run for its owner (permission activation L2, Hook 3), before an
549
555
  * owner browse ({@link withBrowse}) of a device that may be stopped: the owner, membership and
@@ -551,13 +557,17 @@ export declare class SandboxService {
551
557
  * use takes (the exclusive lease creates or resumes the instance through the retirement gate,
552
558
  * the B-11 reconcile marker, `maxRunningSandboxes` and fencing), and the lease
553
559
  * is left at once. No conversation holds it and nothing runs in it; what the start caused is
554
- * not marked seen, so each conversation's next use still learns of it.
560
+ * not marked seen, so each conversation's next use still learns of it. `narrow` is the browse's
561
+ * own (see {@link withBrowse}), checked before the start, so a browse the narrowed scope refuses
562
+ * (`device.project_outside_mode`) never starts the device.
555
563
  */
556
564
  ensureRunningForOwner(ctx: {
557
565
  orgId: string;
558
566
  deviceId: string;
559
567
  accountId: string;
560
- }, signal: AbortSignal): Promise<void>;
568
+ }, signal: AbortSignal, narrow?: {
569
+ readRoots: readonly string[];
570
+ }): Promise<void>;
561
571
  /**
562
572
  * Makes the device's instance run for a managed call before its permission review reads the
563
573
  * device's facts: the lifecycle `enter` the call's own use takes (the exclusive lease creates
@@ -490,7 +490,7 @@ let SandboxService = class SandboxService {
490
490
  }, override);
491
491
  }
492
492
  /**
493
- * The org's limits for a standing network grant (a scheduled task's grant, a network approval):
493
+ * The org's limits for a standing network grant (an automation's grant, a network approval):
494
494
  * {@link deviceLimits} with the org's per-call host ceiling as an allowlist (`hostGrantCeiling`
495
495
  * with no device). Where that ceiling is bounded by the kernel only (`any`, which an allowlist
496
496
  * cannot carry with its exclusions), the org's effective hosts: a standing grant never reaches
@@ -927,9 +927,13 @@ let SandboxService = class SandboxService {
927
927
  stat: async (path, signal) => (await operation()).stat(path, AbortSignal.any([sig, signal])),
928
928
  }, sig);
929
929
  }
930
- /** Owner browse scopes never manufacture a conversation or Full consent. */
931
- async withBrowse(ctx, fn, signal) {
932
- await this.authority.resolveBrowse(ctx, signal);
930
+ /**
931
+ * Owner browse scopes never manufacture a conversation or Full consent. `narrow.readRoots`
932
+ * roots every call's scope at those paths (a project's files: its root), each inside the owner's
933
+ * ceiling and never wider; none inside it is `device.project_outside_mode`.
934
+ */
935
+ async withBrowse(ctx, fn, signal, narrow) {
936
+ await this.authority.resolveBrowse(ctx, signal, narrow);
933
937
  const row = await this.readRow(ctx);
934
938
  if (!row)
935
939
  throw deviceNotRunning();
@@ -944,7 +948,7 @@ let SandboxService = class SandboxService {
944
948
  provider: entry.plugin,
945
949
  providerVersion: entry.version,
946
950
  generation: String(row.created_at.getTime()),
947
- }, method, input, combined);
951
+ }, method, input, combined, narrow);
948
952
  const admitted = await this.operationIntents.claimBrowse(ctx, intent.operation_id);
949
953
  combined.throwIfAborted();
950
954
  try {
@@ -975,10 +979,12 @@ let SandboxService = class SandboxService {
975
979
  * use takes (the exclusive lease creates or resumes the instance through the retirement gate,
976
980
  * the B-11 reconcile marker, `maxRunningSandboxes` and fencing), and the lease
977
981
  * is left at once. No conversation holds it and nothing runs in it; what the start caused is
978
- * not marked seen, so each conversation's next use still learns of it.
982
+ * not marked seen, so each conversation's next use still learns of it. `narrow` is the browse's
983
+ * own (see {@link withBrowse}), checked before the start, so a browse the narrowed scope refuses
984
+ * (`device.project_outside_mode`) never starts the device.
979
985
  */
980
- async ensureRunningForOwner(ctx, signal) {
981
- await this.authority.resolveBrowse(ctx, signal);
986
+ async ensureRunningForOwner(ctx, signal, narrow) {
987
+ await this.authority.resolveBrowse(ctx, signal, narrow);
982
988
  const p = await this.require(ctx.deviceId, ctx.orgId);
983
989
  const use = {
984
990
  orgId: ctx.orgId,
@@ -5,7 +5,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
5
5
  import { LockService } from "../infra/lock/lock.service.js";
6
6
  import type { KernelLogger } from "../log.js";
7
7
  import { type PrefixedStorage, StorageService } from "./storage.service.js";
8
- /** 定时任务:清理已删除组织的对象存储(名字不含 `:`),每小时整点。 */
8
+ /** Scheduled job: purges the object storage of deleted organizations (the name has no `:`), hourly on the hour. */
9
9
  export declare const STORAGE_PURGE_JOB = "storage-org-purge";
10
10
  /**
11
11
  * 删除「软删除超过 `afterDays` 天、尚未清理存储」的组织的全部对象(`StorageService.deleteOrg`),
@@ -15,9 +15,9 @@ import { LockService } from "../infra/lock/lock.service.js";
15
15
  import { LockedCron } from "../infra/schedule/locked-cron.decorator.js";
16
16
  import { KERNEL_LOGGER } from "../infra/tokens.js";
17
17
  import { StorageService } from "./storage.service.js";
18
- /** 定时任务:清理已删除组织的对象存储(名字不含 `:`),每小时整点。 */
18
+ /** Scheduled job: purges the object storage of deleted organizations (the name has no `:`), hourly on the hour. */
19
19
  export const STORAGE_PURGE_JOB = "storage-org-purge";
20
- /** 每次运行最多处理的组织数(成功与失败合计)。 */
20
+ /** The most organizations one run handles (successes and failures together). */
21
21
  const PURGE_BATCH = 100;
22
22
  /** 认领超过这么久仍未完成(运行中途退出)就可被重新认领。 */
23
23
  const CLAIM_STALE_MINUTES = 60;
@@ -1,4 +1,5 @@
1
1
  import { type LocalizedName, type ToolDisplay } from "@capybara-hq/plugin-sdk";
2
+ import { AutomationStore } from "../automations/store.js";
2
3
  import { EventLog } from "../conversations/event-log.js";
3
4
  import { type EventPayload, type ReviewRecord, type ToolView } from "../conversations/events.js";
4
5
  import { ConversationLeakCheck } from "../conversations/leak-check.js";
@@ -18,7 +19,6 @@ import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js
18
19
  import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
19
20
  import type { PermissionCandidate, PermissionEscalation, PermissionExpansion } from "../sandbox/permission-call-types.js";
20
21
  import { SandboxService } from "../sandbox/sandbox.service.js";
21
- import { ScheduledTaskStore } from "../schedules/store.js";
22
22
  import type { ApprovalPolicySource } from "./pipeline.js";
23
23
  import { ToolRegistry } from "./registry.js";
24
24
  export { APPROVAL_DENY_REASON_MAX_CHARS } from "../conversations/events.js";
@@ -474,7 +474,7 @@ export declare class ApprovalsService {
474
474
  private readonly eventLog;
475
475
  private readonly events;
476
476
  readonly txHost: TransactionHost;
477
- private readonly schedules;
477
+ private readonly automations;
478
478
  /** A trial approval is kept only for a tool the task may hold as a grant (its agent's tools). */
479
479
  private readonly registry;
480
480
  /** One decision of a network ask at a time, across replicas. */
@@ -491,7 +491,7 @@ export declare class ApprovalsService {
491
491
  private readonly devices;
492
492
  private readonly permissionLocks?;
493
493
  private readonly permissionGrants?;
494
- constructor(db: KernelDb, config: Pick<KernelConfigService, "get">, eventLog: Pick<EventLog, "appendIn" | "notify">, events: Pick<KernelEvents, "emit">, txHost: TransactionHost, schedules: Pick<ScheduledTaskStore, "addGrant">,
494
+ constructor(db: KernelDb, config: Pick<KernelConfigService, "get">, eventLog: Pick<EventLog, "appendIn" | "notify">, events: Pick<KernelEvents, "emit">, txHost: TransactionHost, automations: Pick<AutomationStore, "addGrant">,
495
495
  /** A trial approval is kept only for a tool the task may hold as a grant (its agent's tools). */
496
496
  registry: Pick<ToolRegistry, "forAgent">,
497
497
  /** One decision of a network ask at a time, across replicas. */
@@ -614,7 +614,7 @@ export declare class ApprovalsService {
614
614
  */
615
615
  private decideTx;
616
616
  /**
617
- * A trial run of a scheduled task (scheduled tasks spec §7): an approval its creator granted, in
617
+ * A trial run of an automation (scheduled tasks spec §7): an approval its creator granted, in
618
618
  * any scope, is also added to the task's grants with the approved definition's hash, so its
619
619
  * unattended runs do not ask again. Kept only by the rule `addGrants` applies
620
620
  * (`grantRefusalOf`, against the task agent's tools now): never a role-escalated approval
@@ -625,7 +625,7 @@ export declare class ApprovalsService {
625
625
  */
626
626
  private keepTrialGrant;
627
627
  /**
628
- * A trial run of a scheduled task (network ask-to-allow spec §8.1): the hosts its creator allowed
628
+ * A trial run of an automation (network ask-to-allow spec §8.1): the hosts its creator allowed
629
629
  * for this run (「这次允许」) on a network ask about one of their devices become the task's
630
630
  * `network:<host>` grants, each only when `networkGrantRefusal` allows it (exact host, within the
631
631
  * org's effective egress, the device takes remote grants). Never for an ask another account
@@ -639,7 +639,7 @@ export declare class ApprovalsService {
639
639
  */
640
640
  private allowRepoIn;
641
641
  /**
642
- * A trial run of a scheduled task (sandbox git credentials spec §7): a push its creator allowed
642
+ * A trial run of an automation (sandbox git credentials spec §7): a push its creator allowed
643
643
  * for this run (「这次允许」) becomes the task's `git:push:<owner>/<repo>` grant, when
644
644
  * `gitGrantRefusal` allows it (the org does not forbid it). Never for an ask another account
645
645
  * decided or one asked of someone else. In the decision's transaction.