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

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 (230) hide show
  1. package/bootstrap.json +3 -3
  2. package/dist/background/finish.d.ts +5 -1
  3. package/dist/background/finish.js +29 -18
  4. package/dist/background/launch.d.ts +0 -5
  5. package/dist/background/launch.js +1 -6
  6. package/dist/background/managed.js +1 -4
  7. package/dist/background/poll.job.d.ts +3 -25
  8. package/dist/background/poll.job.js +20 -112
  9. package/dist/background/render.d.ts +2 -8
  10. package/dist/background/render.js +3 -17
  11. package/dist/background/stop.d.ts +15 -16
  12. package/dist/background/stop.js +39 -76
  13. package/dist/background/store.d.ts +17 -45
  14. package/dist/background/store.js +60 -94
  15. package/dist/background/tasks.service.d.ts +2 -5
  16. package/dist/background/tasks.service.js +9 -20
  17. package/dist/background/wake.js +3 -2
  18. package/dist/catalog/admin-catalog.controller.d.ts +2 -18
  19. package/dist/catalog/admin-catalog.controller.js +2 -28
  20. package/dist/catalog/catalog-content.d.ts +1 -5
  21. package/dist/catalog/catalog-items.d.ts +2 -6
  22. package/dist/catalog/catalog-items.js +5 -26
  23. package/dist/catalog/catalog-scope.service.d.ts +1 -121
  24. package/dist/catalog/catalog-scope.service.js +12 -552
  25. package/dist/catalog/catalog.service.d.ts +4 -15
  26. package/dist/catalog/catalog.service.js +7 -35
  27. package/dist/catalog/job-ids.d.ts +0 -18
  28. package/dist/catalog/job-ids.js +0 -20
  29. package/dist/catalog/marketplaces.service.d.ts +1 -1
  30. package/dist/catalog/org-catalog.service.js +6 -20
  31. package/dist/catalog/org-plugin-uploads.controller.d.ts +4 -19
  32. package/dist/catalog/org-plugin-uploads.controller.js +6 -34
  33. package/dist/catalog/org-plugin-uploads.d.ts +3 -10
  34. package/dist/catalog/org-plugin-uploads.js +4 -18
  35. package/dist/catalog/org-plugin-uploads.schemas.js +0 -1
  36. package/dist/catalog/owned-items.d.ts +6 -11
  37. package/dist/catalog/owned-items.js +10 -20
  38. package/dist/catalog/ownership.d.ts +3 -29
  39. package/dist/catalog/ownership.js +4 -54
  40. package/dist/catalog/platform-components.d.ts +5 -11
  41. package/dist/catalog/platform-components.js +8 -15
  42. package/dist/catalog/plugin-import.d.ts +3 -42
  43. package/dist/catalog/plugin-import.js +26 -195
  44. package/dist/catalog/plugin-install.js +1 -6
  45. package/dist/catalog/plugin-package.d.ts +1 -0
  46. package/dist/catalog/plugin-package.js +5 -0
  47. package/dist/catalog/plugin-upgrade.d.ts +3 -26
  48. package/dist/catalog/plugin-upgrade.js +20 -103
  49. package/dist/catalog/request-rules.js +4 -6
  50. package/dist/catalog/scope-sync.js +2 -4
  51. package/dist/catalog/scope.d.ts +2 -5
  52. package/dist/channels/jobs.d.ts +3 -3
  53. package/dist/channels/jobs.js +4 -3
  54. package/dist/channels/outbound.d.ts +1 -0
  55. package/dist/channels/outbound.js +32 -8
  56. package/dist/config/load.d.ts +0 -25
  57. package/dist/config/load.js +0 -57
  58. package/dist/config/schema.js +2 -3
  59. package/dist/conversations/attachments.service.js +3 -5
  60. package/dist/conversations/conversations.service.d.ts +3 -3
  61. package/dist/conversations/conversations.service.js +3 -3
  62. package/dist/conversations/job-org.d.ts +3 -0
  63. package/dist/conversations/job-org.js +11 -0
  64. package/dist/conversations/prompt-suggestions.d.ts +2 -7
  65. package/dist/conversations/prompt-suggestions.js +29 -27
  66. package/dist/conversations/titles.d.ts +3 -4
  67. package/dist/conversations/titles.js +19 -30
  68. package/dist/db/kernel-schema.d.ts +6 -16
  69. package/dist/db/pool.js +7 -2
  70. package/dist/devices/devices.controller.d.ts +0 -5
  71. package/dist/devices/devices.controller.js +2 -20
  72. package/dist/devices/devices.service.d.ts +1 -17
  73. package/dist/devices/devices.service.js +0 -22
  74. package/dist/errors.d.ts +1 -5
  75. package/dist/errors.js +1 -5
  76. package/dist/evals/judge.d.ts +3 -0
  77. package/dist/evals/judge.js +1 -1
  78. package/dist/evals/run-replay.d.ts +1 -1
  79. package/dist/evals/run-replay.js +26 -29
  80. package/dist/evals/step-replay.d.ts +3 -1
  81. package/dist/evals/step-replay.js +10 -1
  82. package/dist/evals/worker.d.ts +3 -1
  83. package/dist/evals/worker.js +53 -21
  84. package/dist/extensions/deployment-config-store.js +18 -14
  85. package/dist/extensions/effective-config.d.ts +1 -5
  86. package/dist/extensions/effective-config.js +1 -5
  87. package/dist/extensions/hooks.d.ts +3 -1
  88. package/dist/extensions/hooks.js +7 -2
  89. package/dist/extensions/installs.d.ts +2 -14
  90. package/dist/extensions/installs.js +10 -32
  91. package/dist/extensions/org-config.d.ts +3 -4
  92. package/dist/extensions/org-config.js +3 -4
  93. package/dist/extensions/plugin-guides.d.ts +0 -1
  94. package/dist/extensions/plugin-guides.js +0 -1
  95. package/dist/extensions/plugin-icons.d.ts +0 -1
  96. package/dist/extensions/plugin-icons.js +0 -3
  97. package/dist/files/blob-sweep.job.d.ts +2 -11
  98. package/dist/files/blob-sweep.job.js +7 -21
  99. package/dist/files/hash-job.d.ts +5 -15
  100. package/dist/files/hash-job.js +14 -33
  101. package/dist/files/library-jobs.module.d.ts +1 -6
  102. package/dist/files/library-jobs.module.js +3 -9
  103. package/dist/identity/api-tokens.js +54 -40
  104. package/dist/identity/auth.guard.js +2 -2
  105. package/dist/identity/sessions.js +7 -3
  106. package/dist/identity/settings.js +5 -21
  107. package/dist/inbox/inbox.service.d.ts +2 -3
  108. package/dist/inbox/org-notices.d.ts +0 -14
  109. package/dist/inbox/platform-inbox.service.d.ts +1 -8
  110. package/dist/inbox/platform-inbox.service.js +2 -6
  111. package/dist/inbox/platform-notices.d.ts +3 -3
  112. package/dist/index.d.ts +0 -4
  113. package/dist/index.js +0 -3
  114. package/dist/infra/database/database.module.js +2 -1
  115. package/dist/infra/database/org-scope.d.ts +5 -3
  116. package/dist/infra/database/org-scope.js +7 -1
  117. package/dist/infra/database/scoped-dialect.d.ts +3 -1
  118. package/dist/infra/database/scoped-dialect.js +17 -5
  119. package/dist/infra/events/kernel-events.d.ts +2 -0
  120. package/dist/infra/outbox/outbox.service.d.ts +2 -0
  121. package/dist/infra/outbox/outbox.service.js +10 -0
  122. package/dist/infra/outbox/registry.d.ts +0 -41
  123. package/dist/infra/outbox/registry.js +0 -37
  124. package/dist/models/embeddings.d.ts +0 -5
  125. package/dist/models/embeddings.js +28 -35
  126. package/dist/models/images.d.ts +3 -8
  127. package/dist/models/images.js +19 -37
  128. package/dist/models/purposes.d.ts +7 -2
  129. package/dist/models/purposes.js +16 -3
  130. package/dist/orgs/device-network-setting.d.ts +0 -44
  131. package/dist/orgs/device-network-setting.js +0 -83
  132. package/dist/orgs/invitations.service.js +34 -30
  133. package/dist/orgs/offboarding.d.ts +2 -2
  134. package/dist/orgs/offboarding.js +2 -2
  135. package/dist/orgs/orgs.service.d.ts +1 -1
  136. package/dist/orgs/orgs.service.js +19 -15
  137. package/dist/orgs/settings.service.d.ts +19 -14
  138. package/dist/orgs/settings.service.js +12 -37
  139. package/dist/platform/exclusions.js +0 -11
  140. package/dist/platform/ops/catalog-admin.ops.js +0 -8
  141. package/dist/platform/ops/devices.ops.js +0 -28
  142. package/dist/platform/ops/extensions-admin.ops.js +3 -3
  143. package/dist/platform/ops/inbox.ops.js +5 -22
  144. package/dist/platform/ops/org-plugins.ops.d.ts +1 -3
  145. package/dist/platform/ops/org-plugins.ops.js +11 -67
  146. package/dist/roles/worker.module.js +0 -9
  147. package/dist/runtime/hook-calls.d.ts +13 -6
  148. package/dist/runtime/hook-calls.js +26 -4
  149. package/dist/runtime/maintenance.d.ts +3 -12
  150. package/dist/runtime/maintenance.js +25 -55
  151. package/dist/runtime/model-call.d.ts +4 -2
  152. package/dist/runtime/model-call.js +59 -58
  153. package/dist/runtime/providers.d.ts +27 -1
  154. package/dist/runtime/providers.js +57 -0
  155. package/dist/runtime/run-jobs.d.ts +1 -1
  156. package/dist/runtime/run-processors.d.ts +3 -9
  157. package/dist/runtime/run-worker.d.ts +2 -0
  158. package/dist/runtime/run-worker.js +23 -8
  159. package/dist/runtime/subagents/deliveries.js +6 -1
  160. package/dist/runtime/subagents/dispatch.d.ts +3 -3
  161. package/dist/runtime/write-base.service.d.ts +2 -3
  162. package/dist/runtime/write-base.service.js +3 -5
  163. package/dist/sandbox/device-sandbox-settings.d.ts +38 -92
  164. package/dist/sandbox/device-sandbox-settings.js +19 -325
  165. package/dist/sandbox/jobs.d.ts +3 -14
  166. package/dist/sandbox/jobs.js +2 -20
  167. package/dist/sandbox/modes.d.ts +5 -45
  168. package/dist/sandbox/modes.js +3 -60
  169. package/dist/sandbox/operation-authority.js +0 -11
  170. package/dist/sandbox/operation-intents.d.ts +32 -9
  171. package/dist/sandbox/operation-intents.js +241 -32
  172. package/dist/sandbox/operation-intents.module.js +2 -1
  173. package/dist/sandbox/operation-reconcile.job.d.ts +9 -11
  174. package/dist/sandbox/operation-reconcile.job.js +119 -33
  175. package/dist/sandbox/operation-revoke.d.ts +20 -0
  176. package/dist/sandbox/operation-revoke.js +3 -0
  177. package/dist/sandbox/permission-ceiling-writes.d.ts +1 -2
  178. package/dist/sandbox/permission-ceiling-writes.js +3 -6
  179. package/dist/sandbox/permission-config-publication.d.ts +1 -28
  180. package/dist/sandbox/permission-config-publication.js +14 -211
  181. package/dist/sandbox/permission-facts.d.ts +4 -15
  182. package/dist/sandbox/permission-facts.js +7 -29
  183. package/dist/sandbox/permission-instance-writes.d.ts +1 -4
  184. package/dist/sandbox/permission-instance-writes.js +1 -55
  185. package/dist/sandbox/providers.d.ts +1 -6
  186. package/dist/sandbox/providers.js +1 -15
  187. package/dist/sandbox/review/classifier.js +12 -13
  188. package/dist/sandbox/sandbox.module.js +3 -6
  189. package/dist/sandbox/sandbox.service.d.ts +17 -123
  190. package/dist/sandbox/sandbox.service.js +239 -998
  191. package/dist/shares/liveness.d.ts +1 -2
  192. package/dist/shares/liveness.js +1 -2
  193. package/dist/shares/shares.module.d.ts +1 -2
  194. package/dist/shares/shares.module.js +2 -5
  195. package/dist/shares/shares.service.js +1 -2
  196. package/dist/tools/builtins/image/generate.js +7 -15
  197. package/dist/tools/builtins/sandbox/common.d.ts +0 -2
  198. package/dist/tools/builtins/sandbox/common.js +1 -27
  199. package/dist/tools/builtins/sandbox/task-list.js +10 -10
  200. package/dist/tools/builtins/sandbox/task-output.d.ts +3 -10
  201. package/dist/tools/builtins/sandbox/task-output.js +13 -83
  202. package/dist/tools/builtins/sandbox/task-stop.js +18 -22
  203. package/dist/tools/builtins/vision/read-image.js +9 -10
  204. package/dist/tools/builtins/web/extract.js +9 -10
  205. package/package.json +3 -3
  206. package/src/migrations/0206_retire_org_extension_uploads.sql +125 -0
  207. package/src/migrations/0207_confirm_device_instance_destruction.sql +25 -0
  208. package/src/migrations/0208_convert_stored_permission_settings.sql +189 -0
  209. package/dist/background/retire-legacy-tasks.job.d.ts +0 -57
  210. package/dist/background/retire-legacy-tasks.job.js +0 -149
  211. package/dist/catalog/owned-plugin-cleanup.d.ts +0 -47
  212. package/dist/catalog/owned-plugin-cleanup.js +0 -140
  213. package/dist/config/permission-migration.d.ts +0 -34
  214. package/dist/config/permission-migration.js +0 -115
  215. package/dist/devices/legacy-cleanup.job.d.ts +0 -34
  216. package/dist/devices/legacy-cleanup.job.js +0 -147
  217. package/dist/files/library-backfill.d.ts +0 -63
  218. package/dist/files/library-backfill.js +0 -143
  219. package/dist/infra/cli/permission-cutover.d.ts +0 -59
  220. package/dist/infra/cli/permission-cutover.js +0 -107
  221. package/dist/sandbox/cloud-permission-snapshot.d.ts +0 -159
  222. package/dist/sandbox/cloud-permission-snapshot.js +0 -430
  223. package/dist/sandbox/cloud-permission-snapshot.module.d.ts +0 -8
  224. package/dist/sandbox/cloud-permission-snapshot.module.js +0 -34
  225. package/dist/sandbox/legacy-retirement.d.ts +0 -284
  226. package/dist/sandbox/legacy-retirement.js +0 -1165
  227. package/dist/sandbox/legacy-retirement.module.d.ts +0 -8
  228. package/dist/sandbox/legacy-retirement.module.js +0 -25
  229. package/dist/shares/share-objects.d.ts +0 -47
  230. package/dist/shares/share-objects.js +0 -93
@@ -13,11 +13,11 @@ import { KernelDb } from "../infra/database/kernel-db.js";
13
13
  import { asPlatform } from "../infra/database/org-scope.js";
14
14
  import { TransactionHost } from "../infra/database/transaction-host.js";
15
15
  import { Transactional } from "../infra/database/transactional.decorator.js";
16
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
17
+ import { OPERATION_REVOKE } from "../sandbox/operation-revoke.js";
16
18
  import { BackgroundLaunchLock } from "./launch-lock.js";
17
19
  /** The status of a task that is still live; the one filter every "running tasks" read shares. */
18
20
  export const RUNNING_TASK_STATUS = "running";
19
- /** Whether `task` is a managed (exact-ref) task rather than a legacy SID one. */
20
- export const isManagedTask = (task) => task.launchState !== "legacy";
21
21
  const toRow = (r) => ({
22
22
  id: r.id,
23
23
  orgId: r.org_id,
@@ -29,7 +29,6 @@ const toRow = (r) => ({
29
29
  triggerAccountId: r.trigger_account_id,
30
30
  description: r.description,
31
31
  command: r.command,
32
- sid: r.sid,
33
32
  outputPath: r.output_path,
34
33
  status: r.status,
35
34
  lostReason: r.lost_reason,
@@ -38,7 +37,6 @@ const toRow = (r) => ({
38
37
  finishedAt: r.finished_at === null ? null : new Date(r.finished_at),
39
38
  deadlineAt: new Date(r.deadline_at),
40
39
  sandboxCreatedAt: r.sandbox_created_at === null ? null : new Date(r.sandbox_created_at),
41
- killPending: r.kill_pending,
42
40
  readOffset: Number(r.read_offset),
43
41
  stoppingAt: r.stopping_at === null ? null : new Date(r.stopping_at),
44
42
  launchState: r.launch_state,
@@ -68,18 +66,18 @@ const unclaimed = sql `(stopping_at IS NULL OR stopping_at < now() - ${STOP_CLAI
68
66
  *
69
67
  * A launch reserves its managed row ({@link BackgroundTaskStore.reserveManaged}: `running`,
70
68
  * `pending`) before the start is dispatched; the operation facade then moves its durable launch
71
- * state. No launch writes a legacy (SID) row any more: those left from before are only finished
72
- * here and retired by `RetireLegacyTasksJob`; a legacy reservation that never started is failed
73
- * by the poller ({@link BackgroundTaskStore.failAbandonedLaunches}).
69
+ * state. The poller fails abandoned pending reservations.
74
70
  */
75
71
  let BackgroundTaskStore = class BackgroundTaskStore {
76
72
  db;
77
73
  txHost;
78
74
  launchLock;
79
- constructor(db, txHost, launchLock) {
75
+ outbox;
76
+ constructor(db, txHost, launchLock, outbox) {
80
77
  this.db = db;
81
78
  this.txHost = txHost;
82
79
  this.launchLock = launchLock;
80
+ this.outbox = outbox;
83
81
  }
84
82
  /**
85
83
  * Reserves a managed launch (permission runtime cutover phase 8.2) under the root conversation's
@@ -97,7 +95,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
97
95
  .selectAll()
98
96
  .where("run_id", "=", row.runId)
99
97
  .where("call_id", "=", row.callId)
100
- .where("launch_state", "<>", "legacy")
98
+ .where("operation_id", "is not", null)
101
99
  .executeTakeFirst();
102
100
  if (previous)
103
101
  return { kind: "existing", row: toRow(previous) };
@@ -116,7 +114,6 @@ let BackgroundTaskStore = class BackgroundTaskStore {
116
114
  trigger_account_id: row.triggerAccountId,
117
115
  description: row.description,
118
116
  command: row.command,
119
- sid: null,
120
117
  output_path: row.outputPath,
121
118
  started_at: row.startedAt,
122
119
  deadline_at: row.deadlineAt,
@@ -187,7 +184,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
187
184
  }
188
185
  /**
189
186
  * Finishes as `failed` (`lost_reason` `launch_abandoned`) every reservation that started before
190
- * `before`, never dispatched (a managed `pending` row, or a legacy row that never got its sid)
187
+ * `before`, never dispatched (still pending)
191
188
  * and is not claimed by a live stop: the launch that reserved it died (a crashed replica). A
192
189
  * stop's claim older than {@link STOP_CLAIM_TTL_MS} does not hold it: a stop only claims a
193
190
  * reservation and leaves the rest to the launch, so a dead launch would keep it (and its slot of
@@ -209,12 +206,11 @@ let BackgroundTaskStore = class BackgroundTaskStore {
209
206
  stopping_at: null,
210
207
  // a managed reservation that never dispatched settles; dispatch is conditional on
211
208
  // `pending`, so a launch racing this update either wins or is refused before effects
212
- launch_state: sql `CASE WHEN launch_state = 'pending' THEN 'terminal' ELSE launch_state END`,
209
+ launch_state: "terminal",
213
210
  })
214
211
  .where("status", "=", "running")
215
- .where("sid", "is", null)
216
212
  // never a dispatched, acknowledged or cancel-pending managed task
217
- .where("launch_state", "in", ["legacy", "pending"])
213
+ .where("launch_state", "=", "pending")
218
214
  .where(unclaimed)
219
215
  .where("started_at", "<", before)
220
216
  .returning(["id", "conversation_id", "sandbox_conversation_id"])
@@ -226,37 +222,8 @@ let BackgroundTaskStore = class BackgroundTaskStore {
226
222
  }));
227
223
  });
228
224
  }
229
- /**
230
- * Inserts a legacy row: no launch writes one any more; only rows from before (and tests of their
231
- * retirement) exist. `legacyDispatch` (0157) defaults to `unknown`: a row is "never dispatched"
232
- * only when its reservation says so.
233
- */
234
- async insert(row, legacyDispatch = "unknown") {
235
- await this.db
236
- .insertInto("background_tasks")
237
- .values({
238
- legacy_dispatch: legacyDispatch,
239
- id: row.id,
240
- org_id: row.orgId,
241
- conversation_id: row.conversationId,
242
- sandbox_conversation_id: row.sandboxConversationId,
243
- device_id: row.deviceId,
244
- run_id: row.runId,
245
- call_id: row.callId,
246
- trigger_account_id: row.triggerAccountId,
247
- description: row.description,
248
- command: row.command,
249
- sid: row.sid,
250
- output_path: row.outputPath,
251
- started_at: row.startedAt,
252
- deadline_at: row.deadlineAt,
253
- sandbox_created_at: row.sandboxCreatedAt,
254
- })
255
- .execute();
256
- }
257
225
  /** The managed task launched by start operation `operationId`, if its row still exists. */
258
- // org-filter: by start operation id read from a kernel-written row (operation intent or
259
- // retirement marker), not caller input
226
+ // org-filter: by start operation id read from the kernel-written operation intent
260
227
  async byOperation(operationId) {
261
228
  const r = await this.db
262
229
  .selectFrom("background_tasks")
@@ -285,6 +252,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
285
252
  async get(id) {
286
253
  const r = await this.db
287
254
  .selectFrom("background_tasks")
255
+ .where("operation_id", "is not", null)
288
256
  .selectAll()
289
257
  .where("id", "=", id)
290
258
  .executeTakeFirst();
@@ -296,6 +264,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
296
264
  async runningIn(sandboxConversationId) {
297
265
  const rows = await this.db
298
266
  .selectFrom("background_tasks")
267
+ .where("operation_id", "is not", null)
299
268
  .selectAll()
300
269
  .where("sandbox_conversation_id", "=", sandboxConversationId)
301
270
  .where("status", "=", RUNNING_TASK_STATUS)
@@ -304,29 +273,6 @@ let BackgroundTaskStore = class BackgroundTaskStore {
304
273
  .execute();
305
274
  return rows.map(toRow);
306
275
  }
307
- /**
308
- * Every running legacy task that started in an instance and no live stop claimed, across
309
- * sandboxes, oldest first: what the poller finishes once its instance is gone (never by an
310
- * exec). A legacy reservation that never started is failed as abandoned, a claimed task is left
311
- * to its stop.
312
- */
313
- // org-filter: deployment-wide background-task poller sweep across all orgs; each row is
314
- // handled in its own org
315
- async runningLegacy() {
316
- return asPlatform("deployment-wide background-task poller sweep across all orgs", async () => {
317
- const rows = await this.db
318
- .selectFrom("background_tasks")
319
- .selectAll()
320
- .where("status", "=", "running")
321
- .where("launch_state", "=", "legacy")
322
- .where("sandbox_created_at", "is not", null)
323
- .where(unclaimed)
324
- .orderBy("started_at", "asc")
325
- .orderBy("id", "asc")
326
- .execute();
327
- return rows.map(toRow);
328
- });
329
- }
330
276
  /**
331
277
  * Every running acknowledged managed task with no live stop claim, oldest first: what the
332
278
  * poller checks by exact status.
@@ -364,6 +310,11 @@ let BackgroundTaskStore = class BackgroundTaskStore {
364
310
  .where("background_tasks.status", "=", "running")
365
311
  .where("background_tasks.launch_state", "=", "cancel-pending")
366
312
  .where("background_tasks.execution_ref", "is not", null)
313
+ .where(({ not, exists, selectFrom }) => not(exists(selectFrom("sandbox_operation_intents as i")
314
+ .select("i.operation_id")
315
+ .whereRef("i.org_id", "=", "background_tasks.org_id")
316
+ .whereRef("i.operation_id", "=", "background_tasks.operation_id")
317
+ .where("i.revoke_attempt", ">", 0))))
367
318
  .where(sql `(background_tasks.stopping_at IS NULL OR background_tasks.stopping_at < now() - ${STOP_CLAIM_TTL_MS}::integer * interval '1 millisecond')`)
368
319
  .where(sql `NOT (device_instances.status IS NOT DISTINCT FROM 'suspended' AND floor(extract(epoch from device_instances.created_at) * 1000)::bigint::text = background_tasks.instance_generation)`)
369
320
  .orderBy(sql `background_tasks.cancel_attempted_at ASC NULLS FIRST`)
@@ -411,7 +362,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
411
362
  })
412
363
  .where("id", "=", id)
413
364
  .where("status", "=", "running")
414
- .where("launch_state", "<>", "legacy")
365
+ .where("operation_id", "is not", null)
415
366
  .execute();
416
367
  }
417
368
  /**
@@ -424,7 +375,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
424
375
  // org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
425
376
  // TasksService.owned: org and conversation scope) or pass the id of a row they already read
426
377
  async oweCancel(id, by) {
427
- await this.db
378
+ const task = await this.db
428
379
  .updateTable("background_tasks")
429
380
  .set({
430
381
  cancel_requested_by: sql `COALESCE(cancel_requested_by, ${by}::text)`,
@@ -433,8 +384,29 @@ let BackgroundTaskStore = class BackgroundTaskStore {
433
384
  })
434
385
  .where("id", "=", id)
435
386
  .where("status", "=", "running")
436
- .where("launch_state", "<>", "legacy")
437
- .execute();
387
+ .where("operation_id", "is not", null)
388
+ .returning(["org_id", "operation_id"])
389
+ .executeTakeFirst();
390
+ if (!task?.operation_id)
391
+ return;
392
+ // The caller may disappear before its first attempt returns. The worker adopts the stop
393
+ // only if the exact task still owes it; a verified finish makes this delayed job a no-op.
394
+ const running = await this.db
395
+ .selectFrom("sandbox_operation_intents")
396
+ .select("operation_id")
397
+ .where("operation_id", "=", task.operation_id)
398
+ .where("org_id", "=", task.org_id)
399
+ .where("state", "=", "background-running")
400
+ .executeTakeFirst();
401
+ if (running)
402
+ await this.outbox.add({
403
+ queue: "cap-kernel-maintenance",
404
+ name: OPERATION_REVOKE,
405
+ jobId: `${OPERATION_REVOKE}-${task.operation_id}-stop`,
406
+ orgId: task.org_id,
407
+ data: { orgId: task.org_id, operationId: task.operation_id, attempt: 0 },
408
+ runAt: new Date(Date.now() + 30_000),
409
+ });
438
410
  }
439
411
  /** The running tasks one conversation owns (not those of its sub-agents), oldest first. */
440
412
  // org-filter: by conversation id the caller already resolved in its org (the tool call's
@@ -442,6 +414,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
442
414
  async runningOwnedBy(conversationId) {
443
415
  const rows = await this.db
444
416
  .selectFrom("background_tasks")
417
+ .where("operation_id", "is not", null)
445
418
  .selectAll()
446
419
  .where("conversation_id", "=", conversationId)
447
420
  .where("status", "=", "running")
@@ -460,6 +433,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
460
433
  const [rows, count] = await Promise.all([
461
434
  this.db
462
435
  .selectFrom("background_tasks")
436
+ .where("operation_id", "is not", null)
463
437
  .selectAll()
464
438
  .where("conversation_id", "=", conversationId)
465
439
  .where("status", "<>", "running")
@@ -469,6 +443,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
469
443
  .execute(),
470
444
  this.db
471
445
  .selectFrom("background_tasks")
446
+ .where("operation_id", "is not", null)
472
447
  .select((eb) => eb.fn.countAll().as("n"))
473
448
  .where("conversation_id", "=", conversationId)
474
449
  .where("status", "<>", "running")
@@ -482,6 +457,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
482
457
  async countRunning(sandboxConversationId) {
483
458
  const r = await this.db
484
459
  .selectFrom("background_tasks")
460
+ .where("operation_id", "is not", null)
485
461
  .select((eb) => eb.fn.countAll().as("n"))
486
462
  .where("sandbox_conversation_id", "=", sandboxConversationId)
487
463
  .where("status", "=", "running")
@@ -496,6 +472,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
496
472
  return [];
497
473
  const rows = await this.db
498
474
  .selectFrom("background_tasks")
475
+ .where("operation_id", "is not", null)
499
476
  .selectAll()
500
477
  .where("conversation_id", "in", conversationIds)
501
478
  .orderBy("started_at", "desc")
@@ -504,11 +481,11 @@ let BackgroundTaskStore = class BackgroundTaskStore {
504
481
  return rows.map(toRow);
505
482
  }
506
483
  /**
507
- * Conditional `running` to a final status; false when the row was no longer running (another
484
+ * Conditional `running` to a final status; no row when the task was no longer running (another
508
485
  * path finished it first), or, with `opts.unclaimed` (the poller), when a live stop claimed it.
509
- * The caller's transaction also appends the finished event.
486
+ * The returned requester is the one recorded when the conditional update won.
510
487
  */
511
- async finish(id, to, opts = {}) {
488
+ async finish(id, to, opts) {
512
489
  // org-filter: by task id: callers check ownership first (ownedTask: the calling
513
490
  // conversation; TasksService.owned: org and conversation scope) or pass the id of a row
514
491
  // they already read
@@ -520,19 +497,15 @@ let BackgroundTaskStore = class BackgroundTaskStore {
520
497
  exit_code: to.exitCode ?? null,
521
498
  lost_reason: to.lostReason ?? null,
522
499
  stopping_at: null,
523
- ...(to.killPending !== undefined && { kill_pending: to.killPending }),
524
500
  // a managed task's settlement: `terminal` only on verified evidence; an uncertain end
525
501
  // (lost) keeps its owed cancellation record
526
- ...(opts.managed !== undefined && {
527
- launch_state: sql `CASE WHEN launch_state = 'legacy' THEN 'legacy' ELSE ${opts.managed} END`,
528
- }),
502
+ launch_state: opts.launchState,
529
503
  })
530
504
  .where("id", "=", id)
531
505
  .where("status", "=", "running");
532
506
  if (opts.unclaimed)
533
507
  q = q.where(unclaimed);
534
- const r = await q.executeTakeFirst();
535
- return Number(r.numUpdatedRows) > 0;
508
+ return q.returning("cancel_requested_by").executeTakeFirst();
536
509
  }
537
510
  /** Moves the read offset forward only (a concurrent reader never moves it back). */
538
511
  // org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
@@ -545,20 +518,9 @@ let BackgroundTaskStore = class BackgroundTaskStore {
545
518
  .where(sql `read_offset < ${to}`)
546
519
  .execute();
547
520
  }
548
- // org-filter: by task id: callers check ownership first (ownedTask: the calling conversation;
549
- // TasksService.owned: org and conversation scope) or pass the id of a row they already read
550
- async clearKill(ids) {
551
- if (ids.length === 0)
552
- return;
553
- await this.db
554
- .updateTable("background_tasks")
555
- .set({ kill_pending: false })
556
- .where("id", "in", ids)
557
- .execute();
558
- }
559
521
  /**
560
522
  * Deletes finished tasks that ended before `before`; a running one is never deleted, nor a
561
- * managed record whose launch or cancellation is still uncertain (only `legacy` and settled
523
+ * managed record whose launch or cancellation is still uncertain (only settled
562
524
  * `terminal` rows go).
563
525
  */
564
526
  // org-filter: deployment-wide retention sweep across all orgs (finished rows past their age)
@@ -567,7 +529,7 @@ let BackgroundTaskStore = class BackgroundTaskStore {
567
529
  const r = await this.db
568
530
  .deleteFrom("background_tasks")
569
531
  .where("status", "<>", "running")
570
- .where("launch_state", "in", ["legacy", "terminal"])
532
+ .where("launch_state", "=", "terminal")
571
533
  .where("finished_at", "<", before)
572
534
  .executeTakeFirst();
573
535
  return Number(r.numDeletedRows);
@@ -577,6 +539,9 @@ let BackgroundTaskStore = class BackgroundTaskStore {
577
539
  __decorate([
578
540
  Transactional()
579
541
  ], BackgroundTaskStore.prototype, "reserveManaged", null);
542
+ __decorate([
543
+ Transactional()
544
+ ], BackgroundTaskStore.prototype, "oweCancel", null);
580
545
  __decorate([
581
546
  Transactional({ propagation: "mandatory" })
582
547
  ], BackgroundTaskStore.prototype, "finish", null);
@@ -584,6 +549,7 @@ BackgroundTaskStore = __decorate([
584
549
  Injectable(),
585
550
  __param(0, Inject(KernelDb)),
586
551
  __param(1, Inject(TransactionHost)),
587
- __param(2, Inject(BackgroundLaunchLock))
552
+ __param(2, Inject(BackgroundLaunchLock)),
553
+ __param(3, Inject(OutboxService))
588
554
  ], BackgroundTaskStore);
589
555
  export { BackgroundTaskStore };
@@ -53,8 +53,7 @@ export interface BackgroundTaskView {
53
53
  * `suspended` (the instance is suspended; reading never resumes it), `rebuilt` (the instance the
54
54
  * task ran in is gone, and its files with it), `output_missing` (the instance runs but the output
55
55
  * is gone), `no_access` (the conversation's owner may no longer use the device), `unavailable`
56
- * (the device's provider is not loaded), `read_failed` (the exact read failed, or the task is a
57
- * finished legacy one, whose output is never read live).
56
+ * (the device's provider is not loaded), `read_failed` (the exact read failed).
58
57
  */
59
58
  export type OutputUnavailableReason = "starting" | "not_started" | "device_offline" | "suspended" | "rebuilt" | "output_missing" | "no_access" | "unavailable" | "read_failed";
60
59
  /** Why the live read failed, and the provider of the device the task ran on (null: none known). */
@@ -102,7 +101,7 @@ export declare class BackgroundTasks {
102
101
  * A person's stop. Returns the row after the stop: `running` with `stopping` true when another
103
102
  * stop already claimed the task (or the task is a reservation still launching, which its launch
104
103
  * then kills), or when the device has not applied it yet (`stopWaiting`, the stop owed and
105
- * delivered by the poller); a legacy task's retirement refusal throws. Writes the `background_task.stopped` audit event.
104
+ * delivered by the poller). Writes the `background_task.stopped` audit event.
106
105
  */
107
106
  stop(orgId: string, conversationId: string, accountId: string, taskId: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<BackgroundTaskView>;
108
107
  /**
@@ -119,8 +118,6 @@ export declare class BackgroundTasks {
119
118
  output(orgId: string, conversationId: string, accountId: string, taskId: string, tail: number): Promise<BackgroundTaskOutput>;
120
119
  /** The provider of the device the task ran on (`devices.provider`); null when none is known. */
121
120
  private providerOf;
122
- /** Reads the output from the task's running instance, or says why it cannot. */
123
- private readLive;
124
121
  /**
125
122
  * A managed task's live suffix (permission runtime cutover phase 8.3): by its exact ref on its
126
123
  * exact instance only (never resumed, no exec, no path), the metadata total N first, then every
@@ -19,14 +19,14 @@ import { loadPeople } from "../identity/account-avatar.js";
19
19
  import { audit } from "../identity/audit.js";
20
20
  import { KernelDb } from "../infra/database/kernel-db.js";
21
21
  import { rootConversationOf } from "../runtime/subagents/child.js";
22
- import { retirementPending, SandboxService } from "../sandbox/sandbox.service.js";
22
+ import { SandboxService } from "../sandbox/sandbox.service.js";
23
23
  import { UUID_RE } from "../ui/registry.js";
24
24
  import { finishedEventKey } from "./finish.js";
25
25
  import { TASK_ID_RE } from "./launch.js";
26
26
  import { ManagedInstanceMismatchError, ManagedRefError, onManagedInstance, readerOf, } from "./managed.js";
27
27
  import { assembleOutputSuffix, ManagedOutputCapacityError, ManagedOutputUnavailableError, } from "./managed-output.js";
28
28
  import { BackgroundTaskStopper } from "./stop.js";
29
- import { BackgroundTaskStore, isManagedTask, STOP_CLAIM_TTL_MS, } from "./store.js";
29
+ import { BackgroundTaskStore, STOP_CLAIM_TTL_MS, } from "./store.js";
30
30
  /** The most bytes of output one read returns. */
31
31
  export const OUTPUT_TAIL_MAX_BYTES = 65_536;
32
32
  /** The time limit of reading an output (the exact reads and the wait for the sandbox's lease). */
@@ -121,12 +121,10 @@ let BackgroundTasks = class BackgroundTasks {
121
121
  * A person's stop. Returns the row after the stop: `running` with `stopping` true when another
122
122
  * stop already claimed the task (or the task is a reservation still launching, which its launch
123
123
  * then kills), or when the device has not applied it yet (`stopWaiting`, the stop owed and
124
- * delivered by the poller); a legacy task's retirement refusal throws. Writes the `background_task.stopped` audit event.
124
+ * delivered by the poller). Writes the `background_task.stopped` audit event.
125
125
  */
126
126
  async stop(orgId, conversationId, accountId, taskId, actorTokenId, auditDetail) {
127
127
  const task = await this.owned(orgId, conversationId, accountId, taskId);
128
- // the stopper refuses a running legacy task's stop with the retirement refusal while its
129
- // instance runs (it is never signalled)
130
128
  const after = await this.stopper.stop(task, "person");
131
129
  await audit(this.db.db, {
132
130
  actorAccountId: accountId,
@@ -166,7 +164,7 @@ let BackgroundTasks = class BackgroundTasks {
166
164
  */
167
165
  async output(orgId, conversationId, accountId, taskId, tail) {
168
166
  const task = await this.owned(orgId, conversationId, accountId, taskId);
169
- const read = await this.readLive(orgId, task, tail);
167
+ const read = await this.readManaged(orgId, task, tail);
170
168
  if (read.kind === "ok")
171
169
  return { ...read.value, source: "live" };
172
170
  const unavailable = {
@@ -193,19 +191,6 @@ let BackgroundTasks = class BackgroundTasks {
193
191
  .executeTakeFirst();
194
192
  return row?.provider ?? null;
195
193
  }
196
- /** Reads the output from the task's running instance, or says why it cannot. */
197
- async readLive(orgId, task, tail) {
198
- if (isManagedTask(task))
199
- return this.readManaged(orgId, task, tail);
200
- // a legacy task's output is never read by an exec: a running one is the retirement gate's
201
- // (its actionable refusal), a finished one answers with its finish summary
202
- if (task.status === "running")
203
- throw retirementPending();
204
- return {
205
- kind: "unavailable",
206
- reason: task.sandboxCreatedAt === null ? "not_started" : "read_failed",
207
- };
208
- }
209
194
  /**
210
195
  * A managed task's live suffix (permission runtime cutover phase 8.3): by its exact ref on its
211
196
  * exact instance only (never resumed, no exec, no path), the metadata total N first, then every
@@ -216,7 +201,11 @@ let BackgroundTasks = class BackgroundTasks {
216
201
  if (task.executionRef === null || task.deviceId === null) {
217
202
  return {
218
203
  kind: "unavailable",
219
- reason: task.status === "running" ? "starting" : "not_started",
204
+ reason: task.status === "running"
205
+ ? "starting"
206
+ : task.lostReason === "stop_unconfirmed" || task.lostReason === "stop_confirmed"
207
+ ? "read_failed"
208
+ : "not_started",
220
209
  };
221
210
  }
222
211
  if (!(await this.sandbox.availableFor(task.deviceId, orgId))) {
@@ -8,6 +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 { Inject, Injectable } from "@nestjs/common";
11
+ import { withOrgScope } from "../infra/database/org-scope.js";
11
12
  import { KernelEvents } from "../infra/events/kernel-events.js";
12
13
  import { KERNEL_LOGGER } from "../infra/tokens.js";
13
14
  import { RunQueue } from "../runtime/run-queue.js";
@@ -32,8 +33,8 @@ let BackgroundWake = class BackgroundWake {
32
33
  this.runs = runs;
33
34
  this.log = log;
34
35
  this.unsubscribe = [
35
- events.on("background_task.finished", ({ conversationId }) => this.onFinished(conversationId)),
36
- events.on("subagent.delivered", ({ conversationId }) => this.onFinished(conversationId)),
36
+ events.on("background_task.finished", ({ orgId, conversationId }) => withOrgScope(orgId, () => this.onFinished(conversationId))),
37
+ events.on("subagent.delivered", ({ orgId, conversationId }) => withOrgScope(orgId, () => this.onFinished(conversationId))),
37
38
  ];
38
39
  }
39
40
  /**
@@ -26,10 +26,6 @@ declare const ConfirmBody: z.ZodObject<{
26
26
  declare const ConfirmPermissionsBody: z.ZodObject<{
27
27
  permissionsHash: z.ZodString;
28
28
  }, z.core.$strict>;
29
- /** The reason shown to the owner org in its `upload_rejected` notice (optional). */
30
- declare const RejectBody: z.ZodObject<{
31
- reason: z.ZodOptional<z.ZodString>;
32
- }, z.core.$strict>;
33
29
  /**
34
30
  * The platform catalog (`/api/v1/admin/catalog/*`, super admins): plugin import (upload / npm
35
31
  * prepare, then confirm, which installs the plugin's extension), the item list and detail, scope and
@@ -205,19 +201,9 @@ export declare class AdminCatalogController {
205
201
  * Confirms the item's extension permissions (the admin's 待确认; body `{ permissionsHash }` from
206
202
  * the item view): approves the current permission set (snapshot source `web`) and installs and
207
203
  * enables an extension that was never deployed. A changed set -> 409 `extension.approval_stale`;
208
- * nothing to confirm -> 409 `extension.not_pending`. Returns the item. An org's upload
209
- * (`owner.kind` org, ruling P3-10): the digest of its pending version's package; a first version
210
- * is installed, approved, enabled and synced, a new version applied by the platform update
211
- * (the item removed meanwhile -> 409 `catalog.item_removed`, P3-21).
204
+ * nothing to confirm returns 409 `extension.not_pending`. Returns the updated item.
212
205
  */
213
206
  confirmPermissions(principal: Principal, id: string, body: z.infer<typeof ConfirmPermissionsBody>): Promise<CatalogItemView>;
214
- /**
215
- * Rejects an org upload's pending version (ruling P3-10; body `{ reason? }`, told to the owner
216
- * org in `upload_rejected`): a first version is removed (its name free again), a new version's
217
- * pending state cleared. Nothing pending, or a platform item (pre-flight F11) -> 409
218
- * `extension.not_pending`. 204.
219
- */
220
- reject(principal: Principal, id: string, body: z.infer<typeof RejectBody>): Promise<void>;
221
207
  /**
222
208
  * Whether orgs outside a `named` item's list see it as requestable (spec §5.1 rule 1). Hiding it
223
209
  * keeps pending requests as they are; new requests from unlisted orgs are then 404. Never makes
@@ -239,9 +225,7 @@ export declare class AdminCatalogController {
239
225
  * Updates the platform plugin, confirmed with the preview's `diffHash` (recomputed under the item
240
226
  * lock; a difference -> 409 `plugin.upgrade_stale`; another update running -> 409
241
227
  * `plugin.install_in_progress`). A failure undoes everything -> 502 `plugin.upgrade_failed`.
242
- * Audits `plugin.platform_updated`. A version an org upload waits with (or an item whose first
243
- * version waits) -> 409 `catalog.item_pending`: confirm it in 待确认 (pre-flight F8); the
244
- * preview answers the same.
228
+ * Audits `plugin.platform_updated`. The preview and update require an applied org version.
245
229
  */
246
230
  update(principal: Principal, id: string, body: z.infer<typeof CatalogUpdateBody>): Promise<PlatformUpdateResult>;
247
231
  /** 删除条目(软删除,已安装的组件不受影响)。 */
@@ -35,8 +35,6 @@ const ConfirmBody = z
35
35
  })
36
36
  .strict();
37
37
  const ConfirmPermissionsBody = z.object({ permissionsHash: Hash }).strict();
38
- /** The reason shown to the owner org in its `upload_rejected` notice (optional). */
39
- const RejectBody = z.object({ reason: z.string().trim().min(1).max(1000).optional() }).strict();
40
38
  const actorOpts = (actor) => {
41
39
  const tokenId = patTokenId(actor);
42
40
  return tokenId !== undefined ? { actorTokenId: tokenId } : {};
@@ -59,8 +57,6 @@ class CatalogConfirmPermissionsBody extends createZodDto(ConfirmPermissionsBody,
59
57
  }
60
58
  class CatalogShownBody extends createZodDto(ShownBody, "CatalogShownBody") {
61
59
  }
62
- class CatalogRejectBody extends createZodDto(RejectBody, "CatalogRejectBody") {
63
- }
64
60
  class CatalogDisabledBody extends createZodDto(DisabledBody, "CatalogDisabledBody") {
65
61
  }
66
62
  class CatalogUpdatePreviewBodyDto extends createZodDto(CatalogUpdatePreviewBody, "CatalogUpdatePreviewBody") {
@@ -314,25 +310,12 @@ let AdminCatalogController = class AdminCatalogController {
314
310
  * Confirms the item's extension permissions (the admin's 待确认; body `{ permissionsHash }` from
315
311
  * the item view): approves the current permission set (snapshot source `web`) and installs and
316
312
  * enables an extension that was never deployed. A changed set -> 409 `extension.approval_stale`;
317
- * nothing to confirm -> 409 `extension.not_pending`. Returns the item. An org's upload
318
- * (`owner.kind` org, ruling P3-10): the digest of its pending version's package; a first version
319
- * is installed, approved, enabled and synced, a new version applied by the platform update
320
- * (the item removed meanwhile -> 409 `catalog.item_removed`, P3-21).
313
+ * nothing to confirm returns 409 `extension.not_pending`. Returns the updated item.
321
314
  */
322
315
  confirmPermissions(principal, id, body) {
323
316
  const actor = requireUser(principal);
324
317
  return this.scope.confirmPermissions(actor.account.id, id, body.permissionsHash, actorOpts(actor));
325
318
  }
326
- /**
327
- * Rejects an org upload's pending version (ruling P3-10; body `{ reason? }`, told to the owner
328
- * org in `upload_rejected`): a first version is removed (its name free again), a new version's
329
- * pending state cleared. Nothing pending, or a platform item (pre-flight F11) -> 409
330
- * `extension.not_pending`. 204.
331
- */
332
- async reject(principal, id, body) {
333
- const actor = requireUser(principal);
334
- await this.scope.reject(actor.account.id, id, body.reason ?? null, actorOpts(actor));
335
- }
336
319
  /**
337
320
  * Whether orgs outside a `named` item's list see it as requestable (spec §5.1 rule 1). Hiding it
338
321
  * keeps pending requests as they are; new requests from unlisted orgs are then 404. Never makes
@@ -359,9 +342,7 @@ let AdminCatalogController = class AdminCatalogController {
359
342
  * Updates the platform plugin, confirmed with the preview's `diffHash` (recomputed under the item
360
343
  * lock; a difference -> 409 `plugin.upgrade_stale`; another update running -> 409
361
344
  * `plugin.install_in_progress`). A failure undoes everything -> 502 `plugin.upgrade_failed`.
362
- * Audits `plugin.platform_updated`. A version an org upload waits with (or an item whose first
363
- * version waits) -> 409 `catalog.item_pending`: confirm it in 待确认 (pre-flight F8); the
364
- * preview answers the same.
345
+ * Audits `plugin.platform_updated`. The preview and update require an applied org version.
365
346
  */
366
347
  update(principal, id, body) {
367
348
  const actor = requireUser(principal);
@@ -469,13 +450,6 @@ __decorate([
469
450
  __param(1, Param("id")),
470
451
  __param(2, ZBody(CatalogConfirmPermissionsBody))
471
452
  ], AdminCatalogController.prototype, "confirmPermissions", null);
472
- __decorate([
473
- Post("items/:id/reject"),
474
- HttpCode(204),
475
- __param(0, CurrentPrincipal()),
476
- __param(1, Param("id")),
477
- __param(2, ZBody(CatalogRejectBody))
478
- ], AdminCatalogController.prototype, "reject", null);
479
453
  __decorate([
480
454
  Put("items/:id/shown"),
481
455
  __param(0, CurrentPrincipal()),
@@ -14,11 +14,7 @@ import type { OrgPluginState, PluginScope } from "./scope.js";
14
14
  /** A catalog item from an organization's view (`GET /orgs/:orgId/catalog`). */
15
15
  /** Why an org's plugin is `unavailable` ({@link OrgCatalogItem.reason}). */
16
16
  export type PluginUnavailableReason = "plugin_disabled" | ExtensionUnavailableReason;
17
- export interface OrgCatalogItem extends Omit<CatalogItemView, "installs" | "marketplaceId" | "latestMarketplaceVersion" | "newerInMarketplace" | "scopeOrgs" | "enabledOrgs" | "offCount" | "pending" | "shownToOthers" | "awaitingConfirmation" | "pendingVersion"> {
18
- /** The owner org only (absent for other orgs): its upload waits for the super admin (P3-9). */
19
- awaitingConfirmation?: boolean;
20
- /** The owner org only (absent for other orgs): the version waiting for that confirmation. */
21
- pendingVersion?: string | null;
17
+ export interface OrgCatalogItem extends Omit<CatalogItemView, "installs" | "marketplaceId" | "latestMarketplaceVersion" | "newerInMarketplace" | "scopeOrgs" | "enabledOrgs" | "offCount" | "pending" | "shownToOthers"> {
22
18
  scope: PluginScope;
23
19
  /** Shipped with the deployment (a required bootstrap plugin): on in every org, never switchable. */
24
20
  builtin: boolean;
@@ -167,17 +167,16 @@ export declare function writeCatalogVersion(db: KernelSchemaDb, w: CatalogVersio
167
167
  created: boolean;
168
168
  }>;
169
169
  /**
170
- * Records that `version` of the item was applied or confirmed (ruling P3-52), in the caller's
170
+ * Records that `version` of the item was applied (ruling P3-52), in the caller's
171
171
  * transaction: from then on it may serve other orgs and the generic update. Idempotent.
172
172
  */
173
173
  export declare function markVersionApplied(db: KernelSchemaDb, itemId: string, version: string): Promise<void>;
174
174
  /**
175
175
  * Whether a version may serve other orgs, dependency resolution and the generic update (ruling
176
- * P3-52): applied or confirmed, and never rejected, whoever owns the item now.
176
+ * P3-52): applied, whoever owns the item now.
177
177
  */
178
178
  export declare function versionUsable(v: {
179
179
  applied_at: Date | null;
180
- rejected_at: Date | null;
181
180
  }): boolean;
182
181
  /**
183
182
  * An extension name belongs to the npm package that first installed it (`extension_name_owners`,
@@ -254,7 +253,6 @@ export declare function itemConfirmations(admin: ExtensionAdmin, items: {
254
253
  builtin: boolean;
255
254
  latest_version: string;
256
255
  owner_org_id: string | null;
257
- pending_version: string | null;
258
256
  }[], versions: ReadonlyMap<string, {
259
257
  version: string;
260
258
  extension_sha256: string | null;
@@ -286,8 +284,6 @@ export declare function itemView(i: {
286
284
  marketplace_id?: string | null;
287
285
  updated_at: Date;
288
286
  shareable: boolean;
289
- awaiting_confirmation: boolean;
290
- pending_version: string | null;
291
287
  }, versions: {
292
288
  version: string;
293
289
  source: string;