@capybara-hq/kernel 0.1.0-rc.121 → 0.1.0-rc.122

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 (229) hide show
  1. package/dist/background/finish.d.ts +5 -1
  2. package/dist/background/finish.js +29 -18
  3. package/dist/background/launch.d.ts +0 -5
  4. package/dist/background/launch.js +1 -6
  5. package/dist/background/managed.js +1 -4
  6. package/dist/background/poll.job.d.ts +3 -25
  7. package/dist/background/poll.job.js +20 -112
  8. package/dist/background/render.d.ts +2 -8
  9. package/dist/background/render.js +3 -17
  10. package/dist/background/stop.d.ts +15 -16
  11. package/dist/background/stop.js +39 -76
  12. package/dist/background/store.d.ts +17 -45
  13. package/dist/background/store.js +60 -94
  14. package/dist/background/tasks.service.d.ts +2 -5
  15. package/dist/background/tasks.service.js +9 -20
  16. package/dist/background/wake.js +3 -2
  17. package/dist/catalog/admin-catalog.controller.d.ts +2 -18
  18. package/dist/catalog/admin-catalog.controller.js +2 -28
  19. package/dist/catalog/catalog-content.d.ts +1 -5
  20. package/dist/catalog/catalog-items.d.ts +2 -6
  21. package/dist/catalog/catalog-items.js +5 -26
  22. package/dist/catalog/catalog-scope.service.d.ts +1 -121
  23. package/dist/catalog/catalog-scope.service.js +12 -552
  24. package/dist/catalog/catalog.service.d.ts +4 -15
  25. package/dist/catalog/catalog.service.js +7 -35
  26. package/dist/catalog/job-ids.d.ts +0 -18
  27. package/dist/catalog/job-ids.js +0 -20
  28. package/dist/catalog/marketplaces.service.d.ts +1 -1
  29. package/dist/catalog/org-catalog.service.js +6 -20
  30. package/dist/catalog/org-plugin-uploads.controller.d.ts +4 -19
  31. package/dist/catalog/org-plugin-uploads.controller.js +6 -34
  32. package/dist/catalog/org-plugin-uploads.d.ts +3 -10
  33. package/dist/catalog/org-plugin-uploads.js +4 -18
  34. package/dist/catalog/org-plugin-uploads.schemas.js +0 -1
  35. package/dist/catalog/owned-items.d.ts +6 -11
  36. package/dist/catalog/owned-items.js +10 -20
  37. package/dist/catalog/ownership.d.ts +3 -29
  38. package/dist/catalog/ownership.js +4 -54
  39. package/dist/catalog/platform-components.d.ts +5 -11
  40. package/dist/catalog/platform-components.js +8 -15
  41. package/dist/catalog/plugin-import.d.ts +3 -42
  42. package/dist/catalog/plugin-import.js +26 -195
  43. package/dist/catalog/plugin-install.js +1 -6
  44. package/dist/catalog/plugin-package.d.ts +1 -0
  45. package/dist/catalog/plugin-package.js +5 -0
  46. package/dist/catalog/plugin-upgrade.d.ts +3 -26
  47. package/dist/catalog/plugin-upgrade.js +20 -103
  48. package/dist/catalog/request-rules.js +4 -6
  49. package/dist/catalog/scope-sync.js +2 -4
  50. package/dist/catalog/scope.d.ts +2 -5
  51. package/dist/channels/jobs.d.ts +3 -3
  52. package/dist/channels/jobs.js +4 -3
  53. package/dist/channels/outbound.d.ts +1 -0
  54. package/dist/channels/outbound.js +32 -8
  55. package/dist/config/load.d.ts +0 -25
  56. package/dist/config/load.js +0 -57
  57. package/dist/config/schema.js +2 -3
  58. package/dist/conversations/attachments.service.js +3 -5
  59. package/dist/conversations/conversations.service.d.ts +3 -3
  60. package/dist/conversations/conversations.service.js +3 -3
  61. package/dist/conversations/job-org.d.ts +3 -0
  62. package/dist/conversations/job-org.js +11 -0
  63. package/dist/conversations/prompt-suggestions.d.ts +2 -7
  64. package/dist/conversations/prompt-suggestions.js +29 -27
  65. package/dist/conversations/titles.d.ts +3 -4
  66. package/dist/conversations/titles.js +19 -30
  67. package/dist/db/kernel-schema.d.ts +6 -16
  68. package/dist/db/pool.js +7 -2
  69. package/dist/devices/devices.controller.d.ts +0 -5
  70. package/dist/devices/devices.controller.js +2 -20
  71. package/dist/devices/devices.service.d.ts +1 -17
  72. package/dist/devices/devices.service.js +0 -22
  73. package/dist/errors.d.ts +1 -5
  74. package/dist/errors.js +1 -5
  75. package/dist/evals/judge.d.ts +3 -0
  76. package/dist/evals/judge.js +1 -1
  77. package/dist/evals/run-replay.d.ts +1 -1
  78. package/dist/evals/run-replay.js +26 -29
  79. package/dist/evals/step-replay.d.ts +3 -1
  80. package/dist/evals/step-replay.js +10 -1
  81. package/dist/evals/worker.d.ts +3 -1
  82. package/dist/evals/worker.js +53 -21
  83. package/dist/extensions/deployment-config-store.js +18 -14
  84. package/dist/extensions/effective-config.d.ts +1 -5
  85. package/dist/extensions/effective-config.js +1 -5
  86. package/dist/extensions/hooks.d.ts +3 -1
  87. package/dist/extensions/hooks.js +7 -2
  88. package/dist/extensions/installs.d.ts +2 -14
  89. package/dist/extensions/installs.js +10 -32
  90. package/dist/extensions/org-config.d.ts +3 -4
  91. package/dist/extensions/org-config.js +3 -4
  92. package/dist/extensions/plugin-guides.d.ts +0 -1
  93. package/dist/extensions/plugin-guides.js +0 -1
  94. package/dist/extensions/plugin-icons.d.ts +0 -1
  95. package/dist/extensions/plugin-icons.js +0 -3
  96. package/dist/files/blob-sweep.job.d.ts +2 -11
  97. package/dist/files/blob-sweep.job.js +7 -21
  98. package/dist/files/hash-job.d.ts +5 -15
  99. package/dist/files/hash-job.js +14 -33
  100. package/dist/files/library-jobs.module.d.ts +1 -6
  101. package/dist/files/library-jobs.module.js +3 -9
  102. package/dist/identity/api-tokens.js +54 -40
  103. package/dist/identity/auth.guard.js +2 -2
  104. package/dist/identity/sessions.js +7 -3
  105. package/dist/identity/settings.js +5 -21
  106. package/dist/inbox/inbox.service.d.ts +2 -3
  107. package/dist/inbox/org-notices.d.ts +0 -14
  108. package/dist/inbox/platform-inbox.service.d.ts +1 -8
  109. package/dist/inbox/platform-inbox.service.js +2 -6
  110. package/dist/inbox/platform-notices.d.ts +3 -3
  111. package/dist/index.d.ts +0 -4
  112. package/dist/index.js +0 -3
  113. package/dist/infra/database/database.module.js +2 -1
  114. package/dist/infra/database/org-scope.d.ts +5 -3
  115. package/dist/infra/database/org-scope.js +7 -1
  116. package/dist/infra/database/scoped-dialect.d.ts +3 -1
  117. package/dist/infra/database/scoped-dialect.js +17 -5
  118. package/dist/infra/events/kernel-events.d.ts +2 -0
  119. package/dist/infra/outbox/outbox.service.d.ts +2 -0
  120. package/dist/infra/outbox/outbox.service.js +10 -0
  121. package/dist/infra/outbox/registry.d.ts +0 -41
  122. package/dist/infra/outbox/registry.js +0 -37
  123. package/dist/models/embeddings.d.ts +0 -5
  124. package/dist/models/embeddings.js +28 -35
  125. package/dist/models/images.d.ts +3 -8
  126. package/dist/models/images.js +19 -37
  127. package/dist/models/purposes.d.ts +7 -2
  128. package/dist/models/purposes.js +16 -3
  129. package/dist/orgs/device-network-setting.d.ts +0 -44
  130. package/dist/orgs/device-network-setting.js +0 -83
  131. package/dist/orgs/invitations.service.js +34 -30
  132. package/dist/orgs/offboarding.d.ts +2 -2
  133. package/dist/orgs/offboarding.js +2 -2
  134. package/dist/orgs/orgs.service.d.ts +1 -1
  135. package/dist/orgs/orgs.service.js +19 -15
  136. package/dist/orgs/settings.service.d.ts +19 -14
  137. package/dist/orgs/settings.service.js +12 -37
  138. package/dist/platform/exclusions.js +0 -11
  139. package/dist/platform/ops/catalog-admin.ops.js +0 -8
  140. package/dist/platform/ops/devices.ops.js +0 -28
  141. package/dist/platform/ops/extensions-admin.ops.js +3 -3
  142. package/dist/platform/ops/inbox.ops.js +5 -22
  143. package/dist/platform/ops/org-plugins.ops.d.ts +1 -3
  144. package/dist/platform/ops/org-plugins.ops.js +11 -67
  145. package/dist/roles/worker.module.js +0 -9
  146. package/dist/runtime/hook-calls.d.ts +13 -6
  147. package/dist/runtime/hook-calls.js +26 -4
  148. package/dist/runtime/maintenance.d.ts +3 -12
  149. package/dist/runtime/maintenance.js +25 -55
  150. package/dist/runtime/model-call.d.ts +4 -2
  151. package/dist/runtime/model-call.js +59 -58
  152. package/dist/runtime/providers.d.ts +27 -1
  153. package/dist/runtime/providers.js +57 -0
  154. package/dist/runtime/run-jobs.d.ts +1 -1
  155. package/dist/runtime/run-processors.d.ts +3 -9
  156. package/dist/runtime/run-worker.d.ts +2 -0
  157. package/dist/runtime/run-worker.js +23 -8
  158. package/dist/runtime/subagents/deliveries.js +6 -1
  159. package/dist/runtime/subagents/dispatch.d.ts +3 -3
  160. package/dist/runtime/write-base.service.d.ts +2 -3
  161. package/dist/runtime/write-base.service.js +3 -5
  162. package/dist/sandbox/device-sandbox-settings.d.ts +38 -92
  163. package/dist/sandbox/device-sandbox-settings.js +19 -325
  164. package/dist/sandbox/jobs.d.ts +3 -14
  165. package/dist/sandbox/jobs.js +2 -20
  166. package/dist/sandbox/modes.d.ts +5 -45
  167. package/dist/sandbox/modes.js +3 -60
  168. package/dist/sandbox/operation-authority.js +0 -11
  169. package/dist/sandbox/operation-intents.d.ts +32 -9
  170. package/dist/sandbox/operation-intents.js +241 -32
  171. package/dist/sandbox/operation-intents.module.js +2 -1
  172. package/dist/sandbox/operation-reconcile.job.d.ts +9 -11
  173. package/dist/sandbox/operation-reconcile.job.js +119 -33
  174. package/dist/sandbox/operation-revoke.d.ts +20 -0
  175. package/dist/sandbox/operation-revoke.js +3 -0
  176. package/dist/sandbox/permission-ceiling-writes.d.ts +1 -2
  177. package/dist/sandbox/permission-ceiling-writes.js +3 -6
  178. package/dist/sandbox/permission-config-publication.d.ts +1 -28
  179. package/dist/sandbox/permission-config-publication.js +14 -211
  180. package/dist/sandbox/permission-facts.d.ts +4 -15
  181. package/dist/sandbox/permission-facts.js +7 -29
  182. package/dist/sandbox/permission-instance-writes.d.ts +1 -4
  183. package/dist/sandbox/permission-instance-writes.js +1 -55
  184. package/dist/sandbox/providers.d.ts +1 -6
  185. package/dist/sandbox/providers.js +1 -15
  186. package/dist/sandbox/review/classifier.js +12 -13
  187. package/dist/sandbox/sandbox.module.js +3 -6
  188. package/dist/sandbox/sandbox.service.d.ts +17 -123
  189. package/dist/sandbox/sandbox.service.js +239 -998
  190. package/dist/shares/liveness.d.ts +1 -2
  191. package/dist/shares/liveness.js +1 -2
  192. package/dist/shares/shares.module.d.ts +1 -2
  193. package/dist/shares/shares.module.js +2 -5
  194. package/dist/shares/shares.service.js +1 -2
  195. package/dist/tools/builtins/image/generate.js +7 -15
  196. package/dist/tools/builtins/sandbox/common.d.ts +0 -2
  197. package/dist/tools/builtins/sandbox/common.js +1 -27
  198. package/dist/tools/builtins/sandbox/task-list.js +10 -10
  199. package/dist/tools/builtins/sandbox/task-output.d.ts +3 -10
  200. package/dist/tools/builtins/sandbox/task-output.js +13 -83
  201. package/dist/tools/builtins/sandbox/task-stop.js +18 -22
  202. package/dist/tools/builtins/vision/read-image.js +9 -10
  203. package/dist/tools/builtins/web/extract.js +9 -10
  204. package/package.json +3 -3
  205. package/src/migrations/0206_retire_org_extension_uploads.sql +125 -0
  206. package/src/migrations/0207_confirm_device_instance_destruction.sql +25 -0
  207. package/src/migrations/0208_convert_stored_permission_settings.sql +189 -0
  208. package/dist/background/retire-legacy-tasks.job.d.ts +0 -57
  209. package/dist/background/retire-legacy-tasks.job.js +0 -149
  210. package/dist/catalog/owned-plugin-cleanup.d.ts +0 -47
  211. package/dist/catalog/owned-plugin-cleanup.js +0 -140
  212. package/dist/config/permission-migration.d.ts +0 -34
  213. package/dist/config/permission-migration.js +0 -115
  214. package/dist/devices/legacy-cleanup.job.d.ts +0 -34
  215. package/dist/devices/legacy-cleanup.job.js +0 -147
  216. package/dist/files/library-backfill.d.ts +0 -63
  217. package/dist/files/library-backfill.js +0 -143
  218. package/dist/infra/cli/permission-cutover.d.ts +0 -59
  219. package/dist/infra/cli/permission-cutover.js +0 -107
  220. package/dist/sandbox/cloud-permission-snapshot.d.ts +0 -159
  221. package/dist/sandbox/cloud-permission-snapshot.js +0 -430
  222. package/dist/sandbox/cloud-permission-snapshot.module.d.ts +0 -8
  223. package/dist/sandbox/cloud-permission-snapshot.module.js +0 -34
  224. package/dist/sandbox/legacy-retirement.d.ts +0 -284
  225. package/dist/sandbox/legacy-retirement.js +0 -1165
  226. package/dist/sandbox/legacy-retirement.module.d.ts +0 -8
  227. package/dist/sandbox/legacy-retirement.module.js +0 -25
  228. package/dist/shares/share-objects.d.ts +0 -47
  229. package/dist/shares/share-objects.js +0 -93
@@ -3,7 +3,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
3
3
  import { TransactionHost } from "../infra/database/transaction-host.js";
4
4
  import { KernelEvents } from "../infra/events/kernel-events.js";
5
5
  import { OutboxService } from "../infra/outbox/outbox.service.js";
6
- import { type BackgroundTaskRow, BackgroundTaskStore } from "./store.js";
6
+ import { type BackgroundTaskRow, BackgroundTaskStore, type CancelRequester } from "./store.js";
7
7
  /** Where a task ends (as {@link BackgroundTaskStore.finish} takes it). */
8
8
  export type BackgroundFinish = Parameters<BackgroundTaskStore["finish"]>[1];
9
9
  /**
@@ -12,6 +12,10 @@ export type BackgroundFinish = Parameters<BackgroundTaskStore["finish"]>[1];
12
12
  * stopped background sub-agent).
13
13
  */
14
14
  export type BackgroundStoppedBy = "person" | "deletion" | "subagent_end";
15
+ /** The finish options of a stop asked for by `by`: who stopped it decides whether it may wake. */
16
+ export declare function stoppedByOpts(by: CancelRequester | null): {
17
+ stoppedBy?: BackgroundStoppedBy;
18
+ };
15
19
  /** The idempotency key of a task's `background_task_finished` event. */
16
20
  export declare const finishedEventKey: (taskId: string) => string;
17
21
  /**
@@ -17,9 +17,19 @@ import { KernelEvents } from "../infra/events/kernel-events.js";
17
17
  import { OutboxService } from "../infra/outbox/outbox.service.js";
18
18
  import { oweEnsureRun } from "../runtime/run-jobs.js";
19
19
  import { OPERATION_REVOKE } from "../sandbox/operation-intents.js";
20
- import { taskOutputFile } from "./launch.js";
21
20
  import { LAST_LINES_MAX_CHARS } from "./session.js";
22
- import { BackgroundTaskStore, isManagedTask } from "./store.js";
21
+ import { BackgroundTaskStore } from "./store.js";
22
+ /** The finish options of a stop asked for by `by`: who stopped it decides whether it may wake. */
23
+ export function stoppedByOpts(by) {
24
+ const stoppedBy = by === "person"
25
+ ? "person"
26
+ : by === "conversation_deleted"
27
+ ? "deletion"
28
+ : by === "subagent_end"
29
+ ? "subagent_end"
30
+ : undefined;
31
+ return stoppedBy === undefined ? {} : { stoppedBy };
32
+ }
23
33
  /** The idempotency key of a task's `background_task_finished` event. */
24
34
  export const finishedEventKey = (taskId) => `background_task_finished:${taskId}`;
25
35
  /**
@@ -65,12 +75,8 @@ let BackgroundTaskFinisher = class BackgroundTaskFinisher {
65
75
  * intent row is locked before the task row, the order every authority writer takes.
66
76
  */
67
77
  async finish(task, to, lastLines, reported, opts = {}) {
68
- const managed = isManagedTask(task)
69
- ? to.status === "lost" || opts.keepOwed
70
- ? "cancel-pending"
71
- : "terminal"
72
- : undefined;
73
- if (managed !== undefined && task.operationId !== null)
78
+ const launchState = to.status === "lost" || opts.keepOwed ? "cancel-pending" : "terminal";
79
+ if (task.operationId !== null)
74
80
  await this.db
75
81
  .selectFrom("sandbox_operation_intents")
76
82
  .select("operation_id")
@@ -78,12 +84,14 @@ let BackgroundTaskFinisher = class BackgroundTaskFinisher {
78
84
  .where("org_id", "=", task.orgId)
79
85
  .forUpdate()
80
86
  .executeTakeFirst();
81
- if (!(await this.store.finish(task.id, to, {
87
+ const finished = await this.store.finish(task.id, to, {
82
88
  ...(opts.unclaimed !== undefined && { unclaimed: opts.unclaimed }),
83
- ...(managed !== undefined && { managed }),
84
- })))
89
+ launchState,
90
+ });
91
+ if (!finished)
85
92
  return false;
86
- if (managed === "terminal" && task.operationId !== null)
93
+ const stoppedBy = stoppedByOpts(finished.cancel_requested_by).stoppedBy ?? opts.stoppedBy;
94
+ if (launchState === "terminal" && task.operationId !== null)
87
95
  await this.db
88
96
  .updateTable("sandbox_operation_intents")
89
97
  .set({ state: "completed", updated_at: new Date() })
@@ -93,8 +101,8 @@ let BackgroundTaskFinisher = class BackgroundTaskFinisher {
93
101
  .execute();
94
102
  // A lost end (supervision lost, instance gone or replaced) is no proof the process is gone:
95
103
  // its running authority is retired and the exact cancellation is owed to the revoke worker,
96
- // which acknowledges it only on a verified stop (an unresolvable one waits for retirement).
97
- if (managed === "cancel-pending" && task.operationId !== null) {
104
+ // which acknowledges it only on an exact stop, exit or confirmed incarnation destruction.
105
+ if (launchState === "cancel-pending" && task.operationId !== null) {
98
106
  const retired = await this.db
99
107
  .updateTable("sandbox_operation_intents")
100
108
  .set({ state: "revoked", outcome_unknown: true, updated_at: new Date() })
@@ -125,16 +133,16 @@ let BackgroundTaskFinisher = class BackgroundTaskFinisher {
125
133
  lastLines: lastLines.length > LAST_LINES_MAX_CHARS
126
134
  ? lastLines.slice(-LAST_LINES_MAX_CHARS)
127
135
  : lastLines,
128
- outputPath: taskOutputFile(task.outputPath),
136
+ outputPath: task.outputPath,
129
137
  reported,
130
138
  ...(to.lostReason !== undefined && { lostReason: to.lostReason }),
131
- ...(opts.stoppedBy !== undefined && { stoppedBy: opts.stoppedBy }),
139
+ ...(stoppedBy !== undefined && { stoppedBy }),
132
140
  },
133
141
  },
134
142
  ]);
135
143
  // a finish that may wake the conversation owes the ensure-run backstop with its event: the
136
144
  // wake after the commit (`BackgroundWake`) may never happen (transactional outbox spec §6)
137
- if (event && !reported && opts.stoppedBy === undefined) {
145
+ if (event && !reported && stoppedBy === undefined) {
138
146
  await oweEnsureRun(this.outbox, task.conversationId, event.seq, task.orgId);
139
147
  }
140
148
  const conversations = [...new Set([task.conversationId, task.sandboxConversationId])];
@@ -143,7 +151,10 @@ let BackgroundTaskFinisher = class BackgroundTaskFinisher {
143
151
  await this.eventLog.notify(task.conversationId, event.seq);
144
152
  for (const c of conversations)
145
153
  await this.eventLog.publishChanged(c, "background");
146
- await this.events.emit("background_task.finished", { conversationId: task.conversationId });
154
+ await this.events.emit("background_task.finished", {
155
+ orgId: task.orgId,
156
+ conversationId: task.conversationId,
157
+ });
147
158
  });
148
159
  return true;
149
160
  }
@@ -17,11 +17,6 @@ export declare const backgroundMaxSeconds: (cfg: Pick<KernelConfig, "sandbox">)
17
17
  export declare const TASKS_DIR = ".capybara/tasks";
18
18
  /** A task's output file, relative to the workspace root (`output_path` while reserved). */
19
19
  export declare const taskOutputPath: (id: string) => string;
20
- /**
21
- * The absolute output file of a task from its `output_path`: a managed task's is always absolute;
22
- * a legacy row reserved but never started kept a relative one, read under the default workspace.
23
- */
24
- export declare const taskOutputFile: (outputPath: string) => string;
25
20
  /** A new task id: `bt_` plus 6 lowercase base32 characters. */
26
21
  export declare function newTaskId(): string;
27
22
  /** A task id ({@link newTaskId}). */
@@ -1,5 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
- import { DEFAULT_SANDBOX_ROOTS, SandboxScopeDeniedError, } from "@capybara-hq/plugin-sdk";
2
+ import { SandboxScopeDeniedError } from "@capybara-hq/plugin-sdk";
3
3
  /**
4
4
  * Launching a background Bash task (spec 2026-11-05-background-bash-design §4.2, permission
5
5
  * runtime cutover phase 8.2): the task id, the managed artifact placement and the model-visible
@@ -17,11 +17,6 @@ export const backgroundMaxSeconds = (cfg) => Math.min(cfg.sandbox.background.max
17
17
  export const TASKS_DIR = ".capybara/tasks";
18
18
  /** A task's output file, relative to the workspace root (`output_path` while reserved). */
19
19
  export const taskOutputPath = (id) => `${TASKS_DIR}/${id}.out`;
20
- /**
21
- * The absolute output file of a task from its `output_path`: a managed task's is always absolute;
22
- * a legacy row reserved but never started kept a relative one, read under the default workspace.
23
- */
24
- export const taskOutputFile = (outputPath) => outputPath.startsWith("/") ? outputPath : `${DEFAULT_SANDBOX_ROOTS.workspace}/${outputPath}`;
25
20
  const BASE32 = "abcdefghijklmnopqrstuvwxyz234567";
26
21
  /** A new task id: `bt_` plus 6 lowercase base32 characters. */
27
22
  export function newTaskId() {
@@ -60,9 +60,7 @@ export function exactRefOf(task) {
60
60
  */
61
61
  export async function onManagedInstance(ifRunning, task, fn, signal) {
62
62
  const { ref, deviceId, generation } = exactRefOf(task);
63
- return ifRunning(deviceId,
64
- // an exact-ref drain: allowed on an incarnation under a retirement obligation (8.5)
65
- { createdAt: new Date(generation), exactRef: true }, async (p, h, sig) => {
63
+ return ifRunning(deviceId, { createdAt: new Date(generation) }, async (p, h, sig) => {
66
64
  if (h.id !== ref.instanceId)
67
65
  throw new ManagedInstanceMismatchError();
68
66
  const bg = p.background;
@@ -75,7 +73,6 @@ export async function onManagedInstance(ifRunning, task, fn, signal) {
75
73
  export const SUPERVISION_LOST = {
76
74
  status: "lost",
77
75
  lostReason: "supervision_lost",
78
- killPending: false,
79
76
  };
80
77
  function exitedEnd(exitCode, timedOut) {
81
78
  if (timedOut)
@@ -1,4 +1,3 @@
1
- import type { Redis } from "ioredis";
2
1
  import type { KernelConfig } from "../config/schema.js";
3
2
  import { EventLog } from "../conversations/event-log.js";
4
3
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
@@ -15,8 +14,7 @@ export declare const BACKGROUND_PRUNE_JOB = "background-task-prune";
15
14
  /** The most owed managed cancellations one poll applies (each a lease and up to a 5 s grace). */
16
15
  export declare const MANAGED_STOPS_PER_TICK = 8;
17
16
  /**
18
- * A reservation that never dispatched (a managed `pending` row, or a legacy row without an
19
- * instance) older than this has lost its launch. The slowest legitimate launch
17
+ * A pending reservation that never dispatched older than this has lost its launch. The slowest legitimate launch
20
18
  * is the pipeline's own limit for a background `Bash` call ({@link LAUNCH_EXEC_TIMEOUT_MS} plus
21
19
  * {@link sandboxBaseTimeoutMs}: the tool timeout, `sandbox.lockWaitSeconds` and the setup margin),
22
20
  * so twice that (never under 2 minutes) leaves a wide margin: only a launching process that died
@@ -30,9 +28,7 @@ export declare const launchAbandonedAfterMs: (cfg: KernelConfig) => number;
30
28
  * exact ref on its exact instance (through `SandboxService.ifRunning`, which never creates or
31
29
  * resumes an instance); ended tasks finish through {@link BackgroundTaskFinisher}. Each poll
32
30
  * takes and releases a lease, so `last_used_at` stays fresh and an instance with running tasks
33
- * is never idle-suspended. A running legacy (SID) task is never polled by any exec: while its
34
- * instance runs it is left to the retirement gate (`RetireLegacyTasksJob`); once that instance
35
- * is gone or replaced it finishes `lost` without any exec or signal;
31
+ * is never idle-suspended;
36
32
  * - `background-task-prune` (daily): deletes finished tasks older than `tools.outputRetentionDays`.
37
33
  */
38
34
  export declare class BackgroundTaskPollJob {
@@ -44,11 +40,7 @@ export declare class BackgroundTaskPollJob {
44
40
  readonly lockService: LockService;
45
41
  readonly log: KernelLogger;
46
42
  private readonly stopper;
47
- /** The marker that logs a left-alone legacy instance once across the replicas. */
48
- private readonly redis?;
49
- constructor(store: Pick<BackgroundTaskStore, "runningLegacy" | "runningManaged" | "owedCancels" | "pruneFinished" | "failAbandonedLaunches">, finisher: BackgroundTaskFinisher, eventLog: Pick<EventLog, "publishChanged">, sandbox: Pick<SandboxService, "availableFor" | "providerLoaded" | "ifRunning">, config: KernelConfigService, lockService: LockService, log: KernelLogger, stopper: Pick<BackgroundTaskStopper, "stop">,
50
- /** The marker that logs a left-alone legacy instance once across the replicas. */
51
- redis?: Pick<Redis, "set"> | undefined);
43
+ constructor(store: Pick<BackgroundTaskStore, "runningManaged" | "owedCancels" | "pruneFinished" | "failAbandonedLaunches">, finisher: BackgroundTaskFinisher, eventLog: Pick<EventLog, "publishChanged">, sandbox: Pick<SandboxService, "availableFor" | "providerLoaded" | "ifRunning">, config: KernelConfigService, lockService: LockService, log: KernelLogger, stopper: Pick<BackgroundTaskStopper, "stop">);
52
44
  poll(signal?: AbortSignal): Promise<void>;
53
45
  /**
54
46
  * One poll of every running task (the body of {@link poll}); returns how many tasks finished.
@@ -78,19 +70,5 @@ export declare class BackgroundTaskPollJob {
78
70
  private applyOwedStops;
79
71
  /** The exact statuses of one instance's acknowledged managed tasks; returns how many finished. */
80
72
  private pollManagedInstance;
81
- /**
82
- * The legacy tasks of one device instance, without any exec or signal; returns how many
83
- * finished. A running instance is the retirement gate's: its tasks stay as they are until it
84
- * destroys or quarantines that incarnation (said once per instance, not a warning every tick).
85
- * An instance that is not running finishes them `lost` (a suspended one may keep their processes:
86
- * `kill_pending`, settled by the retirement), a replaced one `sandbox_recreated`.
87
- */
88
- private pollLegacy;
89
- /**
90
- * Logs at `info`, once per legacy instance across the replicas (a Redis marker; every time
91
- * without one), that its tasks are left to the retirement gate. A Redis failure logs anyway.
92
- */
93
- private noteRetirementOnce;
94
- /** Deletes the finished tasks older than `tools.outputRetentionDays` (their rows only). */
95
73
  prune(): Promise<void>;
96
74
  }
@@ -7,14 +7,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
- import { Inject, Injectable, Optional } from "@nestjs/common";
10
+ import { Inject, Injectable } from "@nestjs/common";
11
11
  import { EventLog } from "../conversations/event-log.js";
12
12
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
13
+ import { withOrgScope } from "../infra/database/org-scope.js";
13
14
  import { LockService } from "../infra/lock/lock.service.js";
14
15
  import { LockedCron } from "../infra/schedule/locked-cron.decorator.js";
15
16
  import { LockedInterval } from "../infra/schedule/locked-interval.js";
16
- import { KERNEL_LOGGER, REDIS } from "../infra/tokens.js";
17
- import { RetirementPendingError, SandboxService, } from "../sandbox/sandbox.service.js";
17
+ import { KERNEL_LOGGER } from "../infra/tokens.js";
18
+ import { SandboxService } from "../sandbox/sandbox.service.js";
18
19
  import { sandboxBaseTimeoutMs } from "../tools/builtins/sandbox/common.js";
19
20
  import { BackgroundTaskFinisher } from "./finish.js";
20
21
  import { LAUNCH_EXEC_TIMEOUT_MS } from "./launch.js";
@@ -30,8 +31,7 @@ export const MANAGED_STOPS_PER_TICK = 8;
30
31
  /** The least age at which a reservation counts as abandoned, whatever the config. */
31
32
  const LAUNCH_ABANDONED_FLOOR_MS = 120_000;
32
33
  /**
33
- * A reservation that never dispatched (a managed `pending` row, or a legacy row without an
34
- * instance) older than this has lost its launch. The slowest legitimate launch
34
+ * A pending reservation that never dispatched older than this has lost its launch. The slowest legitimate launch
35
35
  * is the pipeline's own limit for a background `Bash` call ({@link LAUNCH_EXEC_TIMEOUT_MS} plus
36
36
  * {@link sandboxBaseTimeoutMs}: the tool timeout, `sandbox.lockWaitSeconds` and the setup margin),
37
37
  * so twice that (never under 2 minutes) leaves a wide margin: only a launching process that died
@@ -45,9 +45,7 @@ export const launchAbandonedAfterMs = (cfg) => Math.max(LAUNCH_ABANDONED_FLOOR_M
45
45
  * exact ref on its exact instance (through `SandboxService.ifRunning`, which never creates or
46
46
  * resumes an instance); ended tasks finish through {@link BackgroundTaskFinisher}. Each poll
47
47
  * takes and releases a lease, so `last_used_at` stays fresh and an instance with running tasks
48
- * is never idle-suspended. A running legacy (SID) task is never polled by any exec: while its
49
- * instance runs it is left to the retirement gate (`RetireLegacyTasksJob`); once that instance
50
- * is gone or replaced it finishes `lost` without any exec or signal;
48
+ * is never idle-suspended;
51
49
  * - `background-task-prune` (daily): deletes finished tasks older than `tools.outputRetentionDays`.
52
50
  */
53
51
  let BackgroundTaskPollJob = class BackgroundTaskPollJob {
@@ -59,10 +57,7 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
59
57
  lockService;
60
58
  log;
61
59
  stopper;
62
- redis;
63
- constructor(store, finisher, eventLog, sandbox, config, lockService, log, stopper,
64
- /** The marker that logs a left-alone legacy instance once across the replicas. */
65
- redis) {
60
+ constructor(store, finisher, eventLog, sandbox, config, lockService, log, stopper) {
66
61
  this.store = store;
67
62
  this.finisher = finisher;
68
63
  this.eventLog = eventLog;
@@ -71,7 +66,6 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
71
66
  this.lockService = lockService;
72
67
  this.log = log;
73
68
  this.stopper = stopper;
74
- this.redis = redis;
75
69
  }
76
70
  async poll(signal) {
77
71
  await this.pollOnce(signal);
@@ -93,38 +87,7 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
93
87
  for (const c of conversations)
94
88
  await this.eventLog.publishChanged(c, "background");
95
89
  }
96
- const groups = new Map();
97
- for (const t of await this.store.runningLegacy()) {
98
- if (t.sandboxCreatedAt === null)
99
- continue;
100
- // one look per instance: the tasks of every conversation sharing the device
101
- const key = `${t.deviceId} ${t.sandboxCreatedAt.getTime()}`;
102
- groups.set(key, [...(groups.get(key) ?? []), t]);
103
- }
104
- let finished = 0;
105
- for (const tasks of groups.values()) {
106
- if (signal.aborted)
107
- break;
108
- try {
109
- // the device's provider does not serve its org now (off in the org or not loaded): its
110
- // tasks stay as they are until it does. A task without a device
111
- // needs no provider: pollLegacy finishes it as gone.
112
- const first = tasks[0];
113
- if (first?.deviceId && !(await this.sandbox.availableFor(first.deviceId, first.orgId))) {
114
- continue;
115
- }
116
- finished += await this.pollLegacy(tasks, signal);
117
- }
118
- catch (err) {
119
- if (signal.aborted)
120
- break;
121
- this.log.warn("cannot check legacy background tasks; retrying next tick", {
122
- deviceId: tasks[0]?.deviceId,
123
- err,
124
- });
125
- }
126
- }
127
- finished += await this.pollManaged(signal);
90
+ const finished = await this.pollManaged(signal);
128
91
  if (finished > 0)
129
92
  this.log.info("background tasks finished", { count: finished });
130
93
  return finished;
@@ -154,7 +117,7 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
154
117
  cancels.push(t);
155
118
  continue;
156
119
  }
157
- const key = `${t.deviceId} ${t.instanceGeneration}`;
120
+ const key = `${t.orgId} ${t.deviceId} ${t.instanceGeneration}`;
158
121
  groups.set(key, [...(groups.get(key) ?? []), t]);
159
122
  }
160
123
  let n = 0;
@@ -163,9 +126,11 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
163
126
  break;
164
127
  const [first] = tasks;
165
128
  try {
166
- if (!(await this.sandbox.availableFor(first.deviceId, first.orgId)))
167
- continue;
168
- n += await this.pollManagedInstance(tasks, signal);
129
+ n += await withOrgScope(first.orgId, async () => {
130
+ if (!(await this.sandbox.availableFor(first.deviceId, first.orgId)))
131
+ return 0;
132
+ return this.pollManagedInstance(tasks, signal);
133
+ });
169
134
  }
170
135
  catch (err) {
171
136
  if (signal.aborted)
@@ -195,7 +160,8 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
195
160
  break;
196
161
  try {
197
162
  // revocation delivery needs the provider loaded only (not on in the org)
198
- if (!(await this.sandbox.providerLoaded(t.deviceId)))
163
+ const loaded = await withOrgScope(t.orgId, () => this.sandbox.providerLoaded(t.deviceId));
164
+ if (!loaded)
199
165
  continue;
200
166
  }
201
167
  catch (err) {
@@ -206,7 +172,7 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
206
172
  continue;
207
173
  }
208
174
  turns++;
209
- const key = t.deviceId;
175
+ const key = `${t.orgId} ${t.deviceId}`;
210
176
  byDevice.set(key, [...(byDevice.get(key) ?? []), t]);
211
177
  }
212
178
  const finished = await Promise.all([...byDevice.values()].map(async (tasks) => {
@@ -215,7 +181,7 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
215
181
  if (signal.aborted)
216
182
  break;
217
183
  try {
218
- const after = await this.stopper.stop(t, "revoked", signal);
184
+ const after = await withOrgScope(t.orgId, () => this.stopper.stop(t, "revoked", signal));
219
185
  if (after.status !== "running")
220
186
  n++;
221
187
  else if (after.cancelFailure === "unreachable")
@@ -264,7 +230,7 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
264
230
  const end = r.kind === "ran"
265
231
  ? r.value.get(t.id)
266
232
  : r.kind === "not_running"
267
- ? { to: notRunningAs(r.status, false), lastLines: "" }
233
+ ? { to: notRunningAs(r.status), lastLines: "" }
268
234
  : { to: RECREATED, lastLines: "" };
269
235
  // a stop that claimed the task after the read above finishes it itself
270
236
  if (end && (await this.finisher.finish(t, end.to, end.lastLines, false, { unclaimed: true })))
@@ -272,62 +238,6 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
272
238
  }
273
239
  return n;
274
240
  }
275
- /**
276
- * The legacy tasks of one device instance, without any exec or signal; returns how many
277
- * finished. A running instance is the retirement gate's: its tasks stay as they are until it
278
- * destroys or quarantines that incarnation (said once per instance, not a warning every tick).
279
- * An instance that is not running finishes them `lost` (a suspended one may keep their processes:
280
- * `kill_pending`, settled by the retirement), a replaced one `sandbox_recreated`.
281
- */
282
- async pollLegacy(tasks, signal) {
283
- const [first] = tasks;
284
- // a task from before devices has no instance any more
285
- let r;
286
- try {
287
- r =
288
- first.deviceId === null
289
- ? { kind: "not_running", status: "gone" }
290
- : await this.sandbox.ifRunning(first.deviceId, { createdAt: first.sandboxCreatedAt }, async () => "running", signal);
291
- }
292
- catch (err) {
293
- // the lifecycle gate refuses the instance itself: the same retirement owns it
294
- if (!(err instanceof RetirementPendingError))
295
- throw err;
296
- r = { kind: "ran", value: "running" };
297
- }
298
- if (r.kind === "ran") {
299
- await this.noteRetirementOnce(first);
300
- return 0;
301
- }
302
- let n = 0;
303
- for (const t of tasks) {
304
- const to = r.kind === "not_running" ? notRunningAs(r.status, r.status === "suspended") : RECREATED;
305
- // a stop that claimed the task after the read above finishes it itself
306
- if (await this.finisher.finish(t, to, "", false, { unclaimed: true }))
307
- n++;
308
- }
309
- return n;
310
- }
311
- /**
312
- * Logs at `info`, once per legacy instance across the replicas (a Redis marker; every time
313
- * without one), that its tasks are left to the retirement gate. A Redis failure logs anyway.
314
- */
315
- async noteRetirementOnce(first) {
316
- const instance = `${first.deviceId}:${first.sandboxCreatedAt?.getTime() ?? 0}`;
317
- // a log marker, not a lock: the previous value says whether this instance was logged (two
318
- // replicas racing may both log, which is harmless)
319
- const firstTime = this.redis === undefined ||
320
- (await this.redis
321
- .set(`capk:bg-legacy-retirement-noted:${instance}`, "1", "EX", 86_400, "GET")
322
- .then((prev) => prev === null)
323
- .catch(() => true));
324
- if (firstTime)
325
- this.log.info("legacy background tasks left to the retirement gate; not polled", {
326
- deviceId: first.deviceId,
327
- instanceGeneration: first.sandboxCreatedAt?.getTime(),
328
- });
329
- }
330
- /** Deletes the finished tasks older than `tools.outputRetentionDays` (their rows only). */
331
241
  async prune() {
332
242
  const days = this.config.get().tools.outputRetentionDays;
333
243
  const n = await this.store.pruneFinished(new Date(Date.now() - days * 86_400_000));
@@ -350,8 +260,6 @@ BackgroundTaskPollJob = __decorate([
350
260
  __param(4, Inject(KernelConfigService)),
351
261
  __param(5, Inject(LockService)),
352
262
  __param(6, Inject(KERNEL_LOGGER)),
353
- __param(7, Inject(BackgroundTaskStopper)),
354
- __param(8, Optional()),
355
- __param(8, Inject(REDIS))
263
+ __param(7, Inject(BackgroundTaskStopper))
356
264
  ], BackgroundTaskPollJob);
357
265
  export { BackgroundTaskPollJob };
@@ -3,15 +3,9 @@ import type { EventPayload } from "../conversations/events.js";
3
3
  export declare function formatElapsed(ms: number): string;
4
4
  /** Why a task was lost, as the model reads it (an unknown reason as is). */
5
5
  export declare const lostReasonText: (reason: string) => string;
6
- /**
7
- * A task's lost or failure reason as the model reads it (`TaskOutput`, `TaskList`): kernel text
8
- * only. A managed task's reasons are the kernel's own; a legacy row's unknown reason is the old
9
- * launcher's raw text and is replaced.
10
- */
11
- export declare function taskReasonText(task: {
6
+ export declare const taskReasonText: (task: {
12
7
  lostReason: string | null;
13
- launchState: string;
14
- }): string;
8
+ }) => string;
15
9
  type Finished = EventPayload<"background_task_finished">;
16
10
  /**
17
11
  * The model-visible text of a `background_task_finished` event, rendered as a system message (spec
@@ -14,29 +14,15 @@ const LOST_REASONS = {
14
14
  sandbox_recreated: "the sandbox was recreated",
15
15
  process_gone: "its processes ended without an exit code",
16
16
  launch_abandoned: "its launch was interrupted",
17
+ stop_confirmed: "the device later confirmed the command ended; its original exit status is unavailable",
18
+ stop_unconfirmed: "its final state is unknown. Ask the device owner to check whether the command is still running on the device",
17
19
  supervision_lost: "its supervision was lost",
18
20
  launch_unknown: "whether its launch started could not be confirmed; any process it started is being stopped",
19
21
  launch_revoked: "its launch was revoked before its start was confirmed; any process it started is being stopped",
20
22
  };
21
23
  /** Why a task was lost, as the model reads it (an unknown reason as is). */
22
24
  export const lostReasonText = (reason) => LOST_REASONS[reason] ?? reason;
23
- /**
24
- * Why a legacy (SID) launch failed is recorded in the old launcher's raw words (a provider's
25
- * stderr): never shown, the model gets this instead.
26
- */
27
- const LEGACY_LAUNCH_FAILED = "its launch failed under an earlier version of the device runtime; call Bash with run_in_background again to start it";
28
- /**
29
- * A task's lost or failure reason as the model reads it (`TaskOutput`, `TaskList`): kernel text
30
- * only. A managed task's reasons are the kernel's own; a legacy row's unknown reason is the old
31
- * launcher's raw text and is replaced.
32
- */
33
- export function taskReasonText(task) {
34
- const reason = task.lostReason ?? "";
35
- const known = lostReasonText(reason);
36
- if (known !== reason || task.launchState !== "legacy")
37
- return known;
38
- return LEGACY_LAUNCH_FAILED;
39
- }
25
+ export const taskReasonText = (task) => lostReasonText(task.lostReason ?? "");
40
26
  const statusWord = (status) => status === "timed_out" ? "timed out" : status;
41
27
  /**
42
28
  * The model-visible text of a `background_task_finished` event, rendered as a system message (spec
@@ -1,5 +1,6 @@
1
1
  import { KernelDb } from "../infra/database/kernel-db.js";
2
2
  import type { KernelLogger } from "../log.js";
3
+ import type { ResumeStopProof } from "../sandbox/operation-revoke.js";
3
4
  import { SandboxService } from "../sandbox/sandbox.service.js";
4
5
  import { type BackgroundFinish, BackgroundTaskFinisher } from "./finish.js";
5
6
  import { type BackgroundTaskRow, BackgroundTaskStore, type CancelFailure } from "./store.js";
@@ -36,16 +37,13 @@ export declare const BACKGROUND_STOP_ATTEMPT_MS: unique symbol;
36
37
  */
37
38
  export type StopReason = "tool" | "person" | "subagent_end" | "conversation_deleted" | "revoked";
38
39
  /** How a task whose sandbox is not running ends (`ifRunning`'s `not_running` status). */
39
- export declare function notRunningAs(status: string, killPending: boolean): BackgroundFinish;
40
+ export declare function notRunningAs(status: string): BackgroundFinish;
40
41
  /** A task found in another sandbox instance (a rebuild): its processes are gone with the old one. */
41
42
  export declare const RECREATED: BackgroundFinish;
42
43
  /**
43
44
  * Stops background tasks (spec 2026-11-05-background-bash-design §2.3, §4.3, permission runtime
44
45
  * cutover phase 8.3): a managed task by its exact ref on its exact instance only, through
45
- * `SandboxService.ifRunning` (it never creates or resumes a sandbox). A legacy (SID) task is never
46
- * signalled: while its instance runs it belongs to the retirement gate (`RetireLegacyTasksJob`),
47
- * and its stop is refused with that gate's actionable refusal; once its instance is gone or
48
- * replaced it finishes `lost` without any exec or signal.
46
+ * `SandboxService.ifRunning` (it never creates or resumes a sandbox).
49
47
  */
50
48
  export declare class BackgroundTaskStopper {
51
49
  private readonly store;
@@ -62,10 +60,9 @@ export declare class BackgroundTaskStopper {
62
60
  * The stop first claims the task (`stopping_at`), so the poller leaves it alone while the stop
63
61
  * takes effect and the stop's finish is its only one. A stop that loses the claim to another
64
62
  * live stop still records its asker on a managed task, so the later finish keeps their wake
65
- * rule. A legacy reservation that never started (no instance) is only claimed: the poller fails
66
- * it as abandoned. A managed task's stop is owed before the device is asked and never throws for
63
+ * rule. A managed task's stop is owed before the device is asked and never throws for
67
64
  * the device: one that cannot settle within its attempt stays owed (`cancel-pending`, why in
68
- * `cancelFailure`) for the poller. A legacy task's retirement refusal, a malformed ref and a
65
+ * `cancelFailure`) for the poller. A malformed ref and a
69
66
  * failed write give the claim up and throw, the task staying `running`. `how.reported`: the
70
67
  * caller's own result tells the model this finish (a managed task's cancellation settled from a
71
68
  * TaskOutput read).
@@ -98,14 +95,16 @@ export declare class BackgroundTaskStopper {
98
95
  * record that never gets one.
99
96
  */
100
97
  settleRevokedUnconfirmed(task: BackgroundTaskRow): Promise<void>;
98
+ /** Destruction proves the execution ended, but gives no exit status or output. */
99
+ settleDestroyed(task: BackgroundTaskRow): Promise<void>;
100
+ /** The provider already established the exact end under the pre-resume lease. */
101
+ settleResumeExit(task: BackgroundTaskRow, result: Extract<ResumeStopProof, {
102
+ ref: object;
103
+ }>["result"]): Promise<void>;
104
+ /** Called inside the exhausted operation's dead-letter transaction, under its row lock. */
105
+ settleStopUnconfirmed(task: BackgroundTaskRow): Promise<void>;
106
+ private finishRevoked;
101
107
  private stopManaged;
102
- /**
103
- * A legacy task's own instance, never signalled: a running one refuses with the retirement
104
- * gate's refusal before any provider call (the gate retires it and its processes whole); one
105
- * that is not running or was replaced is reported, so the task finishes without any exec or
106
- * signal. A task from before devices has none.
107
- */
108
- private legacyInstance;
109
108
  /**
110
109
  * After a sub-agent run ended (spec §4.3): stops the running tasks of `conversationId` when it
111
110
  * is a sub-agent's conversation; any other conversation is left alone. With `runId`, only the
@@ -123,7 +122,7 @@ export declare class BackgroundTaskStopper {
123
122
  /**
124
123
  * Stops `tasks` side by side. A stop that fails while the sandbox runs leaves its task running
125
124
  * (logged): a managed task stays owed to the poller and ends at its own deadline at the latest;
126
- * a legacy task stays with the retirement gate until its instance is destroyed or quarantined
125
+ * a managed cancellation stays owed until its exact execution ends
127
126
  * (no deadline ends it in the kernel's view).
128
127
  */
129
128
  private stopAll;