@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
@@ -368,7 +368,7 @@ let OwnedItems = class OwnedItems {
368
368
  /**
369
369
  * The owner leaves its item, in the caller's transaction (P3-19, P3-20; pre-flight F14, F15).
370
370
  * Another live org uses it ({@link orgsUsing}) -> `transferred`: the item and its components
371
- * become platform-owned, a pending version is cleared, `shown_to_others` is turned off when the
371
+ * become platform-owned, `shown_to_others` is turned off when the
372
372
  * owner had not made it shareable (no exposure the owner switched off), the former owner leaves
373
373
  * the list and its switches (an `all` scope, the item's or a component's own, is narrowed to
374
374
  * `named` = the orgs using it, ruling P3-39; an `optional` item stays `optional`, ruling P3-40:
@@ -377,11 +377,9 @@ let OwnedItems = class OwnedItems {
377
377
  * directly rather than through the guarded scope writer (ruling P3-27); platform notice
378
378
  * `ownership_transferred`, audit `catalog.ownership_transferred`, the scope sync owed with it
379
379
  * (it uninstalls the former owner's install). Otherwise -> `removed`: the soft delete of
380
- * `catalog.remove` ({@link CatalogService.removeIn}, which owes the cleanup job
381
- * `owned-plugin-cleanup-<itemId>` that takes its extension out); an owner delete
380
+ * `catalog.remove` ({@link CatalogService.removeIn}); an owner delete
382
381
  * (`owner_deleted`) also uninstalls it in the owner org through the normal uninstall, keeping the
383
- * connectors it created as the org's own (ruling P3-41). A first upload still waiting is never
384
- * transferred. A gone or platform item -> 404.
382
+ * connectors it created as the org's own (ruling P3-41). A gone or platform item -> 404.
385
383
  */
386
384
  async transferOrRemove(ref, reason, actor, opts = {}) {
387
385
  if (ref.kind !== "plugin")
@@ -389,7 +387,7 @@ let OwnedItems = class OwnedItems {
389
387
  const t = this.db;
390
388
  const item = await t
391
389
  .selectFrom("catalog_items")
392
- .select(["id", "name", "owner_org_id", "shareable", "scope", "awaiting_confirmation"])
390
+ .select(["id", "name", "owner_org_id", "shareable", "scope"])
393
391
  .where("id", "=", ref.id)
394
392
  .where("deleted_at", "is", null)
395
393
  .forUpdate()
@@ -397,11 +395,9 @@ let OwnedItems = class OwnedItems {
397
395
  if (!item || item.owner_org_id === null)
398
396
  throw notFound();
399
397
  const owner = item.owner_org_id;
400
- const others = item.awaiting_confirmation ? [] : await orgsUsing(t, ref, { except: owner });
398
+ const others = await orgsUsing(t, ref, { except: owner });
401
399
  if (others.length === 0) {
402
400
  await this.catalog.removeIn(actor, item.id, { ...opts, reason });
403
- // removeIn owes the cleanup job of a confirmed plugin (a first upload still waiting has
404
- // nothing installed: its name claim is released there)
405
401
  if (reason === "owner_deleted")
406
402
  await this.uninstallInOwner(owner, actor, item.id, opts);
407
403
  return "removed";
@@ -424,9 +420,6 @@ let OwnedItems = class OwnedItems {
424
420
  .updateTable("catalog_items")
425
421
  .set({
426
422
  owner_org_id: null,
427
- pending_version: null,
428
- pending_by: null,
429
- pending_at: null,
430
423
  ...(!item.shareable && { shown_to_others: false }),
431
424
  ...(item.scope === "all" && { scope: "named" }),
432
425
  updated_at: now,
@@ -538,12 +531,9 @@ let OwnedItems = class OwnedItems {
538
531
  * An org is deleted (P3-20), in `OrgsService.softDeleteIn`'s transaction (PG writes only; the
539
532
  * org row is already marked deleted, so it counts as no user): the org's live plugins and the
540
533
  * platform skills and agent templates it promoted (ruling P3-3) are locked `FOR UPDATE`, then
541
- * each goes through {@link transferOrRemove} with reason `org_deleted`. A first upload still
542
- * waiting is removed and its extension name released here (nothing is installed under it,
543
- * pre-flight F10); a pending new version of a transferred plugin is cleared; a removed plugin's
544
- * extension is taken out by the cleanup job the deletion owes. The org's unpromoted rows (its own
545
- * skills, copies, installs) are left: they go with the org as before. Must not inject
546
- * `OrgsService` (it calls this).
534
+ * each goes through {@link transferOrRemove} with reason `org_deleted`. Unpromoted rows
535
+ * (the org’s own skills, copies and installs) are left for org deletion.
536
+ * `OrgsService` calls this method, so do not inject it here.
547
537
  */
548
538
  async onOrgDeleted(orgId, actor, opts = {}) {
549
539
  const t = this.db;
@@ -732,7 +722,7 @@ let OwnedItems = class OwnedItems {
732
722
  }
733
723
  async computeDelete(orgId, item) {
734
724
  const ref = { kind: "plugin", id: item.id };
735
- const orgs = item.awaiting_confirmation ? [] : await orgsUsing(this.db, ref, { except: orgId });
725
+ const orgs = await orgsUsing(this.db, ref, { except: orgId });
736
726
  const agents = new Map();
737
727
  for (const kind of COMPONENT_KINDS) {
738
728
  const ids = (await loadComponents(this.db, kind, { itemId: item.id })).map((c) => c.id);
@@ -754,7 +744,7 @@ let OwnedItems = class OwnedItems {
754
744
  throw notFound();
755
745
  let q = this.db
756
746
  .selectFrom("catalog_items")
757
- .select(["id", "name", "owner_org_id", "shareable", "scope", "awaiting_confirmation"])
747
+ .select(["id", "name", "owner_org_id", "shareable", "scope"])
758
748
  .where("id", "=", itemId)
759
749
  .where("deleted_at", "is", null);
760
750
  if (forUpdate)
@@ -58,44 +58,18 @@ export interface UsableFacts {
58
58
  builtin: boolean;
59
59
  disabled: boolean;
60
60
  deleted_at: Date | null;
61
- awaiting_confirmation: boolean;
62
61
  owner_org_id: string | null;
63
62
  shareable: boolean;
64
63
  }
65
64
  /**
66
- * Whether an item can serve anything at all (ruling P3-9, F12): confirmed (not a first upload
67
- * still waiting for the super admin), not disabled and not deleted. The one predicate for the
65
+ * Whether an item can serve anything at all: enabled and live. The predicate for the
68
66
  * dependency check of org uploads (P3-13), the scope sync, org switches and installs.
69
67
  */
70
- export declare function isUsable(item: Pick<UsableFacts, "disabled" | "deleted_at" | "awaiting_confirmation">): boolean;
68
+ export declare function isUsable(item: Pick<UsableFacts, "disabled" | "deleted_at">): boolean;
71
69
  /**
72
- * 409 `catalog.item_pending`: the item, or the version asked for, waits for the super admin's
73
- * confirmation in 待确认 (ruling P3-9): no scope edit, switch, install or generic update.
74
- */
75
- export declare function itemPendingError(name: string, version?: string): ApiError;
76
- /**
77
- * 409 `catalog.item_removed`: the item was removed while a super admin confirmation of its upload
78
- * was running (ruling P3-21).
70
+ * 409 `catalog.item_removed`: the item was removed before its extension could be installed.
79
71
  */
80
72
  export declare function itemRemovedError(name: string): ApiError;
81
- /** 409 `catalog.item_pending` while the item's first version waits for the super admin (P3-9). */
82
- export declare function assertNotAwaiting(item: {
83
- awaiting_confirmation: boolean;
84
- name: string;
85
- }): void;
86
- /**
87
- * The digest a super admin confirms an org upload's pending version with (rulings P3-10, P3-11):
88
- * the extension's permission review digest bound to the exact package, so a pending version
89
- * replaced by another upload is stale even when both ask for the same permissions.
90
- */
91
- export declare function pendingDigest(sha256: string, reviewHash: string): string;
92
- /**
93
- * Releases the extension name an org upload claimed (pre-flight F10), in the caller's
94
- * transaction, when nothing is installed under it: a rejected or withdrawn upload, a pending first
95
- * version replaced by one without an extension, a deleted org's pending upload. An installed
96
- * extension keeps its claim (its removal is the cleanup job's).
97
- */
98
- export declare function releaseExtensionClaim(db: KernelSchemaDb, name: string, packageName: string | null): Promise<void>;
99
73
  /**
100
74
  * Whether `orgId` can use the item (P3-13): {@link isUsable}, and its owner, or listed by a `named`
101
75
  * scope (an org already associated keeps it), or offered to every org (`all` / `optional`, builtin)
@@ -3,7 +3,6 @@
3
3
  // (`owner_org_id` null) or by one org; an org-owned one reaches other orgs only while its owner
4
4
  // makes it shareable. Every writer that shows an item to another org or associates one checks the
5
5
  // gate on the row it writes, read `FOR UPDATE` in its transaction.
6
- import { createHash } from "node:crypto";
7
6
  import { sql } from "kysely";
8
7
  import { ApiError } from "../errors.js";
9
8
  import { componentOn, listedIn, loadComponents, loadScopeState, pluginFactsOf, switchOf, } from "./component-state.js";
@@ -50,66 +49,17 @@ export function assertShareableTarget(row, from, target) {
50
49
  assertShareable(row);
51
50
  }
52
51
  /**
53
- * Whether an item can serve anything at all (ruling P3-9, F12): confirmed (not a first upload
54
- * still waiting for the super admin), not disabled and not deleted. The one predicate for the
52
+ * Whether an item can serve anything at all: enabled and live. The predicate for the
55
53
  * dependency check of org uploads (P3-13), the scope sync, org switches and installs.
56
54
  */
57
55
  export function isUsable(item) {
58
- return !item.awaiting_confirmation && !item.disabled && item.deleted_at === null;
56
+ return !item.disabled && item.deleted_at === null;
59
57
  }
60
58
  /**
61
- * 409 `catalog.item_pending`: the item, or the version asked for, waits for the super admin's
62
- * confirmation in 待确认 (ruling P3-9): no scope edit, switch, install or generic update.
63
- */
64
- export function itemPendingError(name, version) {
65
- return new ApiError("catalog.item_pending", version === undefined
66
- ? `${name} waits for a super admin to confirm its extension; confirm or reject it in 待确认 first`
67
- : `Version ${version} of ${name} waits for a super admin to confirm its extension; confirm it in 待确认`);
68
- }
69
- /**
70
- * 409 `catalog.item_removed`: the item was removed while a super admin confirmation of its upload
71
- * was running (ruling P3-21).
59
+ * 409 `catalog.item_removed`: the item was removed before its extension could be installed.
72
60
  */
73
61
  export function itemRemovedError(name) {
74
- return new ApiError("catalog.item_removed", `${name} was removed while its confirmation was running; nothing of it stays installed`);
75
- }
76
- /** 409 `catalog.item_pending` while the item's first version waits for the super admin (P3-9). */
77
- export function assertNotAwaiting(item) {
78
- if (item.awaiting_confirmation)
79
- throw itemPendingError(item.name);
80
- }
81
- /**
82
- * The digest a super admin confirms an org upload's pending version with (rulings P3-10, P3-11):
83
- * the extension's permission review digest bound to the exact package, so a pending version
84
- * replaced by another upload is stale even when both ask for the same permissions.
85
- */
86
- export function pendingDigest(sha256, reviewHash) {
87
- return createHash("sha256")
88
- .update(JSON.stringify({ sha256, reviewHash }))
89
- .digest("hex")
90
- .slice(0, 32);
91
- }
92
- /**
93
- * Releases the extension name an org upload claimed (pre-flight F10), in the caller's
94
- * transaction, when nothing is installed under it: a rejected or withdrawn upload, a pending first
95
- * version replaced by one without an extension, a deleted org's pending upload. An installed
96
- * extension keeps its claim (its removal is the cleanup job's).
97
- */
98
- export async function releaseExtensionClaim(db, name, packageName) {
99
- if (packageName === null)
100
- return;
101
- const installed = await db
102
- .selectFrom("extension_installs")
103
- .select("name")
104
- .where("name", "=", name)
105
- .executeTakeFirst();
106
- if (installed !== undefined)
107
- return;
108
- await db
109
- .deleteFrom("extension_name_owners")
110
- .where("name", "=", name)
111
- .where("package_name", "=", packageName)
112
- .execute();
62
+ return new ApiError("catalog.item_removed", `${name} was removed before its extension could be installed`);
113
63
  }
114
64
  /**
115
65
  * Whether `orgId` can use the item (P3-13): {@link isUsable}, and its owner, or listed by a `named`
@@ -169,8 +169,7 @@ export interface UploadActor {
169
169
  }
170
170
  /**
171
171
  * Writes the platform rows of a catalog version's components, in the transaction of the import
172
- * confirm that makes an item's first usable version, of the super admin's confirmation of an org
173
- * upload's first version, and of the platform plugin update to a new version.
172
+ * that creates an item and of a plugin update to a new version.
174
173
  */
175
174
  export declare class PlatformComponents {
176
175
  private readonly kdb;
@@ -184,14 +183,10 @@ export declare class PlatformComponents {
184
183
  /** CLI only (see `PluginImport.useCliStorage`): files go to the object store the CLI set up. */
185
184
  useCliStorage(storage: PrefixedStorage): void;
186
185
  /**
187
- * The first phase of a sync inside a caller's transaction (the platform plugin update, the super
188
- * admin's confirmation of an org upload's first version: `confirming`, the item still awaiting
189
- * it): plans the version's components and copies their files, outside any transaction (no
190
- * storage call holds a row lock). {@link applySyncIn} writes the rows.
186
+ * Plans the version's components and copies files before taking a row lock.
187
+ * {@link applySyncIn} writes the rows in the caller's transaction.
191
188
  */
192
- prepareSync(itemId: string, version: string, opts?: {
193
- confirming?: boolean;
194
- }): Promise<PreparedSync>;
189
+ prepareSync(itemId: string, version: string): Promise<PreparedSync>;
195
190
  /**
196
191
  * {@link prepareSync} for an import whose transaction writes the catalog version (the item may
197
192
  * not exist yet): plans from the staged content and copies the files, before that transaction.
@@ -247,8 +242,7 @@ export declare class PlatformComponents {
247
242
  */
248
243
  private markSynced;
249
244
  /**
250
- * The stored catalog version `version` of live item `itemId`. An org upload still waiting for the
251
- * super admin has no platform components (P3-9) unless this is its `confirming`.
245
+ * Reads the stored version of a live catalog item.
252
246
  */
253
247
  private source;
254
248
  /** Reads the version's components and the live platform rows; keeps only what changed. */
@@ -29,7 +29,6 @@ import { canonicalJson } from "../tools/canonical-json.js";
29
29
  import { readCatalogAgentTemplates, readCatalogFiles, readCatalogTemplates, readCatalogThemes, skillFilesDigest, skillOf, themeAssetsDigest, } from "./catalog-content.js";
30
30
  import { putCatalogFiles } from "./catalog-items.js";
31
31
  import { CatalogItemLock } from "./locks.js";
32
- import { assertNotAwaiting } from "./ownership.js";
33
32
  import { relinkDeletedItemConnectors } from "./plugin-connectors.js";
34
33
  /** The prefix (in `deployment/`) of a platform skill version's files. */
35
34
  export const platformSkillPrefix = (id, version) => `platform/skills/${id}/${version}/`;
@@ -60,8 +59,7 @@ export class PlanStale extends Error {
60
59
  }
61
60
  /**
62
61
  * Writes the platform rows of a catalog version's components, in the transaction of the import
63
- * confirm that makes an item's first usable version, of the super admin's confirmation of an org
64
- * upload's first version, and of the platform plugin update to a new version.
62
+ * that creates an item and of a plugin update to a new version.
65
63
  */
66
64
  let PlatformComponents = class PlatformComponents {
67
65
  kdb;
@@ -92,13 +90,11 @@ let PlatformComponents = class PlatformComponents {
92
90
  // files (keyed by content, {@link contentPrefix}) before the caller's transaction, and
93
91
  // {@link applySyncIn} writes the rows and `platform_synced_version` in it.
94
92
  /**
95
- * The first phase of a sync inside a caller's transaction (the platform plugin update, the super
96
- * admin's confirmation of an org upload's first version: `confirming`, the item still awaiting
97
- * it): plans the version's components and copies their files, outside any transaction (no
98
- * storage call holds a row lock). {@link applySyncIn} writes the rows.
93
+ * Plans the version's components and copies files before taking a row lock.
94
+ * {@link applySyncIn} writes the rows in the caller's transaction.
99
95
  */
100
- async prepareSync(itemId, version, opts = {}) {
101
- const plan = await this.planFrom(await this.source(itemId, version, opts.confirming === true));
96
+ async prepareSync(itemId, version) {
97
+ const plan = await this.planFrom(await this.source(itemId, version));
102
98
  await this.writeFiles(plan);
103
99
  return { plan };
104
100
  }
@@ -397,18 +393,15 @@ let PlatformComponents = class PlatformComponents {
397
393
  .execute();
398
394
  }
399
395
  /**
400
- * The stored catalog version `version` of live item `itemId`. An org upload still waiting for the
401
- * super admin has no platform components (P3-9) unless this is its `confirming`.
396
+ * Reads the stored version of a live catalog item.
402
397
  */
403
- async source(itemId, version, confirming) {
398
+ async source(itemId, version) {
404
399
  const item = await this.db
405
400
  .selectFrom("catalog_items")
406
- .select(["name", "awaiting_confirmation"])
401
+ .select("name")
407
402
  .where("id", "=", itemId)
408
403
  .where("deleted_at", "is", null)
409
404
  .executeTakeFirst();
410
- if (item !== undefined && !confirming)
411
- assertNotAwaiting(item);
412
405
  const row = item
413
406
  ? await this.db
414
407
  .selectFrom("catalog_item_versions")
@@ -1,5 +1,4 @@
1
1
  import { type AgentTemplate, type AgentTemplateTier, type LocalizedName, type PluginManifest, type ThemeScheme } from "@capybara-hq/plugin-sdk";
2
- import { ClientBuilds } from "../client/client-builds.service.js";
3
2
  import { ApiError } from "../errors.js";
4
3
  import { ExtensionAdminOps } from "../extensions/admin-ops.js";
5
4
  import { ExtensionAdmin } from "../extensions/admin-view.js";
@@ -330,17 +329,6 @@ export interface PluginConfirmResult {
330
329
  created: boolean;
331
330
  /** null when there is nothing to deploy (no extension, or keep). */
332
331
  deploy: ExtensionDeployResult | null;
333
- /**
334
- * An org upload with an extension: the version waits for the super admin's confirmation
335
- * (ruling P3-10); nothing was approved, installed or synced.
336
- */
337
- pending: boolean;
338
- /**
339
- * The confirm made the item's first usable version: it created the item, or it replaced an org
340
- * upload's first version that was still waiting for the super admin with a version without an
341
- * extension (applied at once, plan Task 6).
342
- */
343
- firstVersion: boolean;
344
332
  /**
345
333
  * A confirm with `deploy: false` that approved the extension's permissions (its snapshot
346
334
  * written): what {@link PluginImport.restoreApproval} needs to put the previous approval back
@@ -389,11 +377,8 @@ export interface StagedTarget {
389
377
  /** The review's own hash (an org's review of an update shows a combined one, P3-12). */
390
378
  reviewHash: string;
391
379
  /** The review has an extension. */
392
- extension: boolean;
393
380
  /** The live item exists already (a new version), owned by the staging's org. */
394
381
  existing: boolean;
395
- /** That item's first version still waits for the super admin (P3-9). */
396
- awaiting: boolean;
397
382
  /** The version is imported already (pre-flight F4). */
398
383
  retry: boolean;
399
384
  /** The target as the platform updater reads it (the staged manifest and files). */
@@ -437,8 +422,6 @@ export declare class PluginImport {
437
422
  readonly txHost: TransactionHost;
438
423
  /** The platform rows of a new item's components, written in the confirm's transaction. */
439
424
  private readonly platform;
440
- /** The client build of a dropped org upload's package is deleted with it. */
441
- private readonly clientBuilds;
442
425
  /** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
443
426
  private readonly outbox;
444
427
  /** Where plugin files go (the kernel's object storage; the CLI's own, see {@link useCliStorage}). */
@@ -460,8 +443,6 @@ export declare class PluginImport {
460
443
  registry: ExtensionRegistry, log: KernelLogger, txHost: TransactionHost,
461
444
  /** The platform rows of a new item's components, written in the confirm's transaction. */
462
445
  platform: PlatformComponents,
463
- /** The client build of a dropped org upload's package is deleted with it. */
464
- clientBuilds: ClientBuilds,
465
446
  /** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
466
447
  outbox: Pick<OutboxService, "add">);
467
448
  /** The kernel-schema handle of the current context (the transaction, else the pool). */
@@ -580,9 +561,7 @@ export declare class PluginImport {
580
561
  * An org upload (`opts.owner`, spec §14): only that org's staging; the actor re-checked as its
581
562
  * admin; `scope` / `orgs` are not taken: a new item is owned by the org, scope `named: [owner]`,
582
563
  * not shown to other orgs, `shareable` as given (default false). Custom deny, the name owner and
583
- * the dependencies are checked again under the item name's lock. A package with an extension
584
- * is stored and its extension name claimed, nothing approved or installed: the version waits
585
- * for the super admin (`pending`, ruling P3-10; see {@link commit}).
564
+ * the dependencies are checked again under the item name's lock.
586
565
  */
587
566
  confirm(actor: string | null, stagingId: string, input: {
588
567
  reviewHash: string;
@@ -619,7 +598,7 @@ export declare class PluginImport {
619
598
  /**
620
599
  * The platform components of the staged version when its confirm will most likely make it the
621
600
  * item's first usable version ({@link commit} decides under its locks): no live item of the name
622
- * yet, or an org upload replacing its own first upload still awaiting confirmation. Planned from
601
+ * yet. Planned from
623
602
  * the staged content and their files copied, outside any transaction; otherwise undefined.
624
603
  */
625
604
  private prepareFirstVersion;
@@ -628,17 +607,7 @@ export declare class PluginImport {
628
607
  * its install lock (stale -> `plugin.review_stale`), its snapshot approved, and the catalog
629
608
  * version written under the item name's lock.
630
609
  *
631
- * An org upload with an extension (ruling P3-10) approves nothing: under the install lock it
632
- * claims the extension name for its package (another package's -> 409
633
- * `extension.name_conflict` naming its owner, before anything is written), and the version
634
- * written becomes the item's pending one (`pending_version` / `_by` / `_at`; a first version
635
- * also `awaiting_confirmation`). A later upload replaces the pending version (P3-11). An org
636
- * upload without an extension for an item whose first version still waits (plan Task 6) replaces
637
- * that upload and applies at once: the item stops waiting and the claim is released (nothing
638
- * was installed under it).
639
- *
640
- * The item's first usable version (a new item not waiting, or an awaiting first upload replaced)
641
- * writes the platform rows of its skills, agent templates, connector templates and themes
610
+ * The first version writes the platform rows of its skills, agent templates, connector templates and themes
642
611
  * (plugin scope phase 2) from `prepared` (their files copied before the transaction, keyed by
643
612
  * content): a failure rolls the whole confirm back, and a retry copies nothing again. A plan made
644
613
  * for another item or version, or a component changed since it -> `plugin.review_stale`. A new
@@ -688,14 +657,6 @@ export declare class PluginImport {
688
657
  * replica has it or it is gone.
689
658
  */
690
659
  private cleanupOne;
691
- /**
692
- * An expired org staging's extension package (an org upload stores it at prepare, P3-10): removed
693
- * with the staging unless something else uses it — an install (running or migrated), a catalog
694
- * version, another staging — or it was stored by anyone else (the package row's source must be
695
- * this staging's own `catalog` ref). A platform staging keeps its package, as before. Its object
696
- * is deleted after the commit.
697
- */
698
- private dropOrgPackage;
699
660
  /** npm / marketplace imports: the package must be the one that was asked for. */
700
661
  private checkExpected;
701
662
  /** A config-declared extension's name cannot be taken by an imported plugin. */