@capybara-hq/kernel 0.1.0-rc.136 → 0.1.0-rc.138

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 (203) hide show
  1. package/dist/admin/audit-log.service.d.ts +96 -12
  2. package/dist/admin/audit-log.service.js +508 -44
  3. package/dist/admin/audit-targets.d.ts +17 -0
  4. package/dist/admin/audit-targets.js +84 -0
  5. package/dist/admin/audit.controller.d.ts +12 -9
  6. package/dist/admin/audit.controller.js +29 -8
  7. package/dist/admin/audit.schemas.d.ts +20 -4
  8. package/dist/admin/audit.schemas.js +42 -17
  9. package/dist/admin/extensions.controller.d.ts +5 -2
  10. package/dist/admin/extensions.controller.js +10 -1
  11. package/dist/admin/extensions.schemas.d.ts +4 -0
  12. package/dist/admin/extensions.schemas.js +9 -0
  13. package/dist/admin/health.service.d.ts +1 -1
  14. package/dist/admin/health.service.js +3 -3
  15. package/dist/agents/templates.js +3 -10
  16. package/dist/app.d.ts +3 -1
  17. package/dist/app.js +1 -0
  18. package/dist/automations/automations.service.js +4 -5
  19. package/dist/catalog/catalog-content.d.ts +6 -8
  20. package/dist/catalog/catalog-content.js +17 -22
  21. package/dist/catalog/catalog-items.d.ts +5 -10
  22. package/dist/catalog/catalog-items.js +27 -51
  23. package/dist/catalog/catalog-scope.service.d.ts +4 -2
  24. package/dist/catalog/catalog-scope.service.js +109 -145
  25. package/dist/catalog/catalog.module.js +7 -4
  26. package/dist/catalog/catalog.service.d.ts +10 -4
  27. package/dist/catalog/catalog.service.js +52 -10
  28. package/dist/catalog/cli.js +17 -0
  29. package/dist/catalog/component-promotion.js +8 -4
  30. package/dist/catalog/component-scope.service.d.ts +3 -1
  31. package/dist/catalog/component-scope.service.js +101 -140
  32. package/dist/catalog/component-state.d.ts +10 -8
  33. package/dist/catalog/component-state.js +42 -30
  34. package/dist/catalog/dependency-edges.d.ts +25 -0
  35. package/dist/catalog/dependency-edges.js +125 -0
  36. package/dist/catalog/effect-work.d.ts +27 -0
  37. package/dist/catalog/effect-work.js +151 -0
  38. package/dist/catalog/jobs.d.ts +4 -1
  39. package/dist/catalog/jobs.js +14 -4
  40. package/dist/catalog/org-catalog.service.d.ts +5 -1
  41. package/dist/catalog/org-catalog.service.js +101 -106
  42. package/dist/catalog/org-intent.d.ts +45 -0
  43. package/dist/catalog/org-intent.js +205 -0
  44. package/dist/catalog/owned-items.d.ts +6 -2
  45. package/dist/catalog/owned-items.js +27 -32
  46. package/dist/catalog/ownership.d.ts +2 -3
  47. package/dist/catalog/ownership.js +10 -28
  48. package/dist/catalog/platform-components.d.ts +3 -1
  49. package/dist/catalog/platform-components.js +9 -1
  50. package/dist/catalog/plugin-import.d.ts +4 -2
  51. package/dist/catalog/plugin-import.js +22 -21
  52. package/dist/catalog/plugin-install.d.ts +19 -54
  53. package/dist/catalog/plugin-install.js +221 -271
  54. package/dist/catalog/plugin-upgrade.d.ts +10 -5
  55. package/dist/catalog/plugin-upgrade.js +80 -67
  56. package/dist/catalog/request-rules.js +20 -8
  57. package/dist/catalog/scope-orgs.js +2 -7
  58. package/dist/catalog/scope-state.d.ts +6 -6
  59. package/dist/catalog/scope-state.js +24 -43
  60. package/dist/catalog/scope-sync-workers.d.ts +7 -11
  61. package/dist/catalog/scope-sync-workers.js +10 -26
  62. package/dist/catalog/scope-sync.d.ts +19 -116
  63. package/dist/catalog/scope-sync.js +228 -275
  64. package/dist/catalog/scope-writer.d.ts +87 -0
  65. package/dist/catalog/scope-writer.js +239 -0
  66. package/dist/catalog/template-connector-ensure.js +1 -1
  67. package/dist/catalog/unshare.js +9 -43
  68. package/dist/channels/connections.service.js +6 -6
  69. package/dist/channels/supervisor.js +3 -7
  70. package/dist/client/client-access.service.js +2 -12
  71. package/dist/config/schema.d.ts +6 -0
  72. package/dist/config/schema.js +32 -1
  73. package/dist/ctx/create-ctx.d.ts +2 -2
  74. package/dist/ctx/create-ctx.js +2 -60
  75. package/dist/ctx/guard-db.d.ts +6 -0
  76. package/dist/ctx/guard-db.js +55 -0
  77. package/dist/db/extension-handoff-schema.d.ts +1 -1
  78. package/dist/db/extension-handoff-schema.js +48 -10
  79. package/dist/db/extension-schema-transfer.js +5 -2
  80. package/dist/db/kernel-schema.d.ts +32 -6
  81. package/dist/device-access/host-services.d.ts +2 -2
  82. package/dist/device-access/host-services.js +5 -6
  83. package/dist/erasure/org-catalog.js +2 -2
  84. package/dist/erasure/org-rules.js +7 -0
  85. package/dist/extensions/admin-ops.d.ts +10 -6
  86. package/dist/extensions/admin-ops.js +53 -9
  87. package/dist/extensions/admin-view.d.ts +4 -1
  88. package/dist/extensions/admin-view.js +27 -14
  89. package/dist/extensions/bootstrap.d.ts +1 -1
  90. package/dist/extensions/bootstrap.js +6 -4
  91. package/dist/extensions/cli.js +1 -0
  92. package/dist/extensions/effective-config.js +1 -4
  93. package/dist/extensions/enabled.d.ts +183 -29
  94. package/dist/extensions/enabled.js +148 -62
  95. package/dist/extensions/host.d.ts +65 -45
  96. package/dist/extensions/host.js +446 -128
  97. package/dist/extensions/installs.d.ts +9 -0
  98. package/dist/extensions/installs.js +23 -0
  99. package/dist/extensions/isolated/admission.d.ts +10 -0
  100. package/dist/extensions/isolated/admission.js +206 -0
  101. package/dist/extensions/isolated/authorization.d.ts +45 -0
  102. package/dist/extensions/isolated/authorization.js +191 -0
  103. package/dist/extensions/isolated/broker.d.ts +15 -0
  104. package/dist/extensions/isolated/broker.js +471 -0
  105. package/dist/extensions/isolated/child-protocol.d.ts +84 -0
  106. package/dist/extensions/isolated/child-protocol.js +21 -0
  107. package/dist/extensions/isolated/child-registration.d.ts +22 -0
  108. package/dist/extensions/isolated/child-registration.js +152 -0
  109. package/dist/extensions/isolated/child-session.d.ts +6 -0
  110. package/dist/extensions/isolated/child-session.js +343 -0
  111. package/dist/extensions/isolated/child-streams.d.ts +4 -0
  112. package/dist/extensions/isolated/child-streams.js +142 -0
  113. package/dist/extensions/isolated/child.d.ts +1 -0
  114. package/dist/extensions/isolated/child.js +10 -0
  115. package/dist/extensions/isolated/configured-package.d.ts +15 -0
  116. package/dist/extensions/isolated/configured-package.js +73 -0
  117. package/dist/extensions/isolated/engine-binds.d.ts +9 -0
  118. package/dist/extensions/isolated/engine-binds.js +82 -0
  119. package/dist/extensions/isolated/engine-policy.d.ts +85 -0
  120. package/dist/extensions/isolated/engine-policy.js +75 -0
  121. package/dist/extensions/isolated/engine-proxy-main.d.ts +1 -0
  122. package/dist/extensions/isolated/engine-proxy-main.js +20 -0
  123. package/dist/extensions/isolated/engine-proxy.d.ts +7 -0
  124. package/dist/extensions/isolated/engine-proxy.js +408 -0
  125. package/dist/extensions/isolated/engine-vaults.d.ts +12 -0
  126. package/dist/extensions/isolated/engine-vaults.js +93 -0
  127. package/dist/extensions/isolated/lanes.d.ts +108 -0
  128. package/dist/extensions/isolated/lanes.js +726 -0
  129. package/dist/extensions/isolated/postgres-gate.d.ts +15 -0
  130. package/dist/extensions/isolated/postgres-gate.js +255 -0
  131. package/dist/extensions/isolated/revision.d.ts +32 -0
  132. package/dist/extensions/isolated/revision.js +359 -0
  133. package/dist/extensions/isolated/rpc-frame.d.ts +50 -0
  134. package/dist/extensions/isolated/rpc-frame.js +193 -0
  135. package/dist/extensions/isolated/rpc.d.ts +66 -0
  136. package/dist/extensions/isolated/rpc.js +314 -0
  137. package/dist/extensions/isolated/sandbox.d.ts +39 -0
  138. package/dist/extensions/isolated/sandbox.js +356 -0
  139. package/dist/extensions/isolated/tier.d.ts +6 -0
  140. package/dist/extensions/isolated/tier.js +45 -0
  141. package/dist/extensions/ledger.d.ts +1 -1
  142. package/dist/extensions/lifecycle-topics.d.ts +2 -0
  143. package/dist/extensions/lifecycle-topics.js +2 -0
  144. package/dist/extensions/lifecycle.d.ts +3 -1
  145. package/dist/extensions/lifecycle.js +53 -5
  146. package/dist/extensions/locks.d.ts +2 -0
  147. package/dist/extensions/locks.js +7 -0
  148. package/dist/extensions/org-config.d.ts +17 -27
  149. package/dist/extensions/org-config.js +114 -129
  150. package/dist/extensions/permission-view.d.ts +6 -1
  151. package/dist/extensions/plugin-guides.d.ts +5 -10
  152. package/dist/extensions/plugin-guides.js +18 -37
  153. package/dist/extensions/plugin-icons.d.ts +3 -21
  154. package/dist/extensions/plugin-icons.js +9 -44
  155. package/dist/extensions/plugin-items.d.ts +10 -30
  156. package/dist/extensions/plugin-items.js +32 -73
  157. package/dist/extensions/source-intent.d.ts +14 -0
  158. package/dist/extensions/source-intent.js +77 -0
  159. package/dist/inbox/platform-inbox.service.js +16 -27
  160. package/dist/index.d.ts +2 -1
  161. package/dist/index.js +2 -1
  162. package/dist/infra/database/database.module.js +6 -1
  163. package/dist/infra/database/kernel-db.d.ts +3 -1
  164. package/dist/infra/database/kernel-db.js +4 -0
  165. package/dist/infra/events/kernel-events.d.ts +4 -0
  166. package/dist/infra/outbox/registry.d.ts +3 -36
  167. package/dist/infra/outbox/registry.js +4 -49
  168. package/dist/infra/paging/paged-read.d.ts +56 -0
  169. package/dist/infra/paging/paged-read.js +78 -0
  170. package/dist/infra/queue/queue-names.d.ts +1 -1
  171. package/dist/infra/queue/queue-names.js +1 -1
  172. package/dist/kernel.d.ts +3 -2
  173. package/dist/kernel.js +21 -2
  174. package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
  175. package/dist/lifecycle/kernel-lifecycle.js +22 -12
  176. package/dist/lifecycle/tokens.d.ts +8 -0
  177. package/dist/lifecycle/tokens.js +2 -0
  178. package/dist/orgs/directory-sync.js +1 -4
  179. package/dist/orgs/org-lock.d.ts +3 -1
  180. package/dist/orgs/org-lock.js +3 -1
  181. package/dist/orgs/orgs.service.d.ts +3 -1
  182. package/dist/orgs/orgs.service.js +15 -8
  183. package/dist/overrides.d.ts +0 -3
  184. package/dist/overrides.js +0 -2
  185. package/dist/platform/ops/admin.ops.js +14 -3
  186. package/dist/platform/ops/extensions-admin.ops.js +20 -3
  187. package/dist/platform/ops/org-plugins.ops.js +5 -2
  188. package/dist/platform/ops/orgs.ops.js +13 -3
  189. package/dist/platform/ops/plugins.ops.js +11 -10
  190. package/dist/setup/setup-checks.service.js +3 -2
  191. package/dist/skills/usable.js +41 -30
  192. package/dist/themes/theme-state.js +3 -3
  193. package/dist/tools/registry.d.ts +2 -2
  194. package/dist/tools/registry.js +7 -3
  195. package/package.json +2 -2
  196. package/src/migrations/0228_extension_org_switches.sql +56 -0
  197. package/src/migrations/0229_catalog_dependency_edges.sql +17 -0
  198. package/src/migrations/0230_audit_filter_idx.sql +18 -0
  199. package/src/migrations/0231_plugin_effect_work.sql +171 -0
  200. package/dist/catalog/install-status.d.ts +0 -6
  201. package/dist/catalog/install-status.js +0 -6
  202. package/dist/catalog/scope-jobs.d.ts +0 -59
  203. package/dist/catalog/scope-jobs.js +0 -78
@@ -20,10 +20,13 @@ import { loadTemplates, readOwnTemplate, softDeleteTemplateIn } from "../agents/
20
20
  import { ApiError } from "../errors.js";
21
21
  import { audit } from "../identity/audit.js";
22
22
  import { addPlatformNotice } from "../inbox/platform-notices.js";
23
+ import { afterCommit } from "../infra/database/after-commit.js";
23
24
  import { KernelDb } from "../infra/database/kernel-db.js";
24
25
  import { asPlatform } from "../infra/database/org-scope.js";
25
26
  import { TransactionHost } from "../infra/database/transaction-host.js";
26
27
  import { Transactional } from "../infra/database/transactional.decorator.js";
28
+ import { XactLock } from "../infra/database/xact-lock.js";
29
+ import { KernelEvents } from "../infra/events/kernel-events.js";
27
30
  import { KERNEL_LOGGER } from "../infra/tokens.js";
28
31
  import { OrgLock } from "../orgs/org-lock.js";
29
32
  import { SkillsService } from "../skills/skills.service.js";
@@ -32,9 +35,11 @@ import { CatalogService } from "./catalog.service.js";
32
35
  import { CatalogScopeService } from "./catalog-scope.service.js";
33
36
  import { notOwnedError } from "./component-promotion.js";
34
37
  import { agentsUsing, COMPONENT_KINDS, componentOn, listedIn, loadComponents, loadScopeState, pluginFactsOf, switchOf, } from "./component-state.js";
38
+ import { EFFECT_CANDIDATES_LOCK } from "./effect-work.js";
35
39
  import { orgsUsing } from "./ownership.js";
36
40
  import { PluginInstaller } from "./plugin-install.js";
37
41
  import { ScopeStillWanted } from "./scope-state.js";
42
+ import { writeScope } from "./scope-writer.js";
38
43
  import { narrowComponentOnUnshare } from "./unshare.js";
39
44
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
40
45
  const notFound = () => new ApiError("catalog.item_not_found", "Catalog item not found");
@@ -78,11 +83,13 @@ let OwnedItems = class OwnedItems {
78
83
  skills;
79
84
  log;
80
85
  txHost;
86
+ xactLock;
87
+ events;
81
88
  constructor(kdb, orgLock, catalog, scope,
82
89
  /** The owner org's own uninstall of a removed plugin (ruling P3-41). */
83
90
  installer,
84
91
  /** The owner's org skill row, soft-deleted after its promoted platform row leaves it. */
85
- skills, log, txHost) {
92
+ skills, log, txHost, xactLock, events) {
86
93
  this.kdb = kdb;
87
94
  this.orgLock = orgLock;
88
95
  this.catalog = catalog;
@@ -91,6 +98,8 @@ let OwnedItems = class OwnedItems {
91
98
  this.skills = skills;
92
99
  this.log = log;
93
100
  this.txHost = txHost;
101
+ this.xactLock = xactLock;
102
+ this.events = events;
94
103
  }
95
104
  get db() {
96
105
  return this.kdb.db;
@@ -104,6 +113,7 @@ let OwnedItems = class OwnedItems {
104
113
  * `catalog.shareable_changed`.
105
114
  */
106
115
  async setShareable(orgId, actor, ref, shareable, opts = {}) {
116
+ await this.xactLock.lock(EFFECT_CANDIDATES_LOCK);
107
117
  if (ref.kind !== "plugin") {
108
118
  await this.setComponentShareable(orgId, actor, ref.kind, ref.id, shareable, opts);
109
119
  return;
@@ -360,6 +370,7 @@ let OwnedItems = class OwnedItems {
360
370
  * {@link transferOrRemove} with reason `owner_deleted`.
361
371
  */
362
372
  async delete(orgId, actor, itemId, previewHash, opts = {}) {
373
+ await this.xactLock.lock(EFFECT_CANDIDATES_LOCK);
363
374
  await this.orgLock.lockAndAuthorize(orgId, actor, "catalog.upload");
364
375
  const item = await this.ownedRow(orgId, itemId, true);
365
376
  if ((await this.computeDelete(orgId, item)).previewHash !== previewHash)
@@ -375,7 +386,7 @@ let OwnedItems = class OwnedItems {
375
386
  * `named` = the orgs using it, ruling P3-39; an `optional` item stays `optional`, ruling P3-40:
376
387
  * it passed the share gate already, so every org could see it, and the former owner is then an
377
388
  * ordinary org that may switch it on again), written
378
- * directly rather than through the guarded scope writer (ruling P3-27); platform notice
389
+ * using the scope writer under the ownership transaction (ruling P3-27); platform notice
379
390
  * `ownership_transferred`, audit `catalog.ownership_transferred`, the scope sync owed with it
380
391
  * (it uninstalls the former owner's install). Otherwise -> `removed`: the soft delete of
381
392
  * `catalog.remove` ({@link CatalogService.removeIn}); an owner delete
@@ -422,7 +433,6 @@ let OwnedItems = class OwnedItems {
422
433
  .set({
423
434
  owner_org_id: null,
424
435
  ...(!item.shareable && { shown_to_others: false }),
425
- ...(item.scope === "all" && { scope: "named" }),
426
436
  updated_at: now,
427
437
  })
428
438
  .where("id", "=", item.id)
@@ -430,11 +440,12 @@ let OwnedItems = class OwnedItems {
430
440
  if (item.scope === "all") {
431
441
  // org-filter: deployment-wide rewrite of the transferred item's named list.
432
442
  await asPlatform("replace the transferred plugin's named scope", async () => {
433
- await t.deleteFrom("catalog_item_scope_orgs").where("item_id", "=", item.id).execute();
434
- await t
435
- .insertInto("catalog_item_scope_orgs")
436
- .values(others.map((o) => ({ item_id: item.id, org_id: o.id })))
437
- .execute();
443
+ await writeScope(t, {
444
+ kind: "plugin",
445
+ id: item.id,
446
+ scope: "named",
447
+ orgs: others.map((o) => o.id),
448
+ });
438
449
  });
439
450
  }
440
451
  else {
@@ -470,11 +481,6 @@ let OwnedItems = class OwnedItems {
470
481
  }
471
482
  }
472
483
  for (const { c, orgs } of narrow) {
473
- await t
474
- .updateTable(TABLE_OF[c.kind])
475
- .set({ scope: "named", updated_at: now })
476
- .where("id", "=", c.id)
477
- .execute();
478
484
  await this.replaceComponentScope(c.kind, c.id, orgs);
479
485
  await audit(t, {
480
486
  actorAccountId: actor,
@@ -517,6 +523,9 @@ let OwnedItems = class OwnedItems {
517
523
  },
518
524
  });
519
525
  await this.scope.enqueueSync(item.id);
526
+ if (reason === "owner_deleted") {
527
+ afterCommit(() => this.events.emit("catalog.org-intent-changed", {}));
528
+ }
520
529
  return "transferred";
521
530
  }
522
531
  /**
@@ -609,9 +618,6 @@ let OwnedItems = class OwnedItems {
609
618
  .set({
610
619
  owner_org_id: null,
611
620
  ...(!c.shareable && { shown_to_others: false }),
612
- ...(narrowTo !== null && {
613
- scope: "named",
614
- }),
615
621
  updated_at: now,
616
622
  })
617
623
  .where("id", "=", id)
@@ -673,20 +679,7 @@ let OwnedItems = class OwnedItems {
673
679
  /** Replaces a transferred component's named list in the transfer's transaction. */
674
680
  async replaceComponentScope(kind, id, orgs) {
675
681
  // org-filter: deployment-wide rewrite of the transferred component's named list.
676
- await asPlatform("replace the transferred component's named scope", async () => {
677
- const t = this.db;
678
- await t
679
- .deleteFrom("component_scope_orgs")
680
- .where("kind", "=", kind)
681
- .where("component_id", "=", id)
682
- .execute();
683
- if (orgs.length > 0) {
684
- await t
685
- .insertInto("component_scope_orgs")
686
- .values(orgs.map((org_id) => ({ kind, component_id: id, org_id })))
687
- .execute();
688
- }
689
- });
682
+ await asPlatform("replace the transferred component's named scope", () => writeScope(this.db, { kind, id, scopeMode: "own", scope: "named", orgs }));
690
683
  }
691
684
  /**
692
685
  * The owner org's live install of a removed plugin, uninstalled in the caller's transaction
@@ -700,7 +693,7 @@ let OwnedItems = class OwnedItems {
700
693
  .select("id")
701
694
  .where("org_id", "=", owner)
702
695
  .where("item_id", "=", itemId)
703
- .where("status", "=", "installed")
696
+ .where("version", "is not", null)
704
697
  .executeTakeFirst();
705
698
  if (live === undefined)
706
699
  return;
@@ -781,6 +774,8 @@ OwnedItems = __decorate([
781
774
  __param(4, Inject(PluginInstaller)),
782
775
  __param(5, Inject(SkillsService)),
783
776
  __param(6, Inject(KERNEL_LOGGER)),
784
- __param(7, Inject(TransactionHost))
777
+ __param(7, Inject(TransactionHost)),
778
+ __param(8, Inject(XactLock)),
779
+ __param(9, Inject(KernelEvents))
785
780
  ], OwnedItems);
786
781
  export { OwnedItems };
@@ -1,6 +1,6 @@
1
1
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
2
2
  import { ApiError } from "../errors.js";
3
- import { type PluginScope } from "./scope.js";
3
+ import type { PluginScope } from "./scope.js";
4
4
  /** Who owns an item or component: the platform, or one org (by id and name, deleted orgs too). */
5
5
  export type Owner = {
6
6
  kind: "platform";
@@ -121,8 +121,7 @@ export type OwnedRef = {
121
121
  id: string;
122
122
  };
123
123
  /**
124
- * The live orgs an item is on in (ruling P3-18: listed and not switched off for `named`, switched
125
- * on for `optional`, any live org for `all`; a component by {@link componentOn}), minus
124
+ * The live orgs where the item is usable, minus
126
125
  * `except` (usually the owner), by name. One definition for the update notices and the
127
126
  * "used by another org" check of deletes. An item that is gone or disabled is on nowhere.
128
127
  */
@@ -7,7 +7,7 @@ import { sql } from "kysely";
7
7
  import { ApiError } from "../errors.js";
8
8
  import { asPlatform } from "../infra/database/org-scope.js";
9
9
  import { componentOn, listedIn, loadComponents, loadScopeState, pluginFactsOf, switchOf, } from "./component-state.js";
10
- import { wantedOn } from "./scope.js";
10
+ import { orgUsable } from "./org-intent.js";
11
11
  export const PLATFORM_OWNER = { kind: "platform" };
12
12
  /**
13
13
  * The share gate (P3-1): a platform item, or an org-owned one its owner made shareable. Closed:
@@ -217,45 +217,27 @@ export function ownerOf(ownerOrgId, owners) {
217
217
  return owners.get(ownerOrgId) ?? { kind: "org", orgId: ownerOrgId, name: ownerOrgId };
218
218
  }
219
219
  /**
220
- * The live orgs an item is on in (ruling P3-18: listed and not switched off for `named`, switched
221
- * on for `optional`, any live org for `all`; a component by {@link componentOn}), minus
220
+ * The live orgs where the item is usable, minus
222
221
  * `except` (usually the owner), by name. One definition for the update notices and the
223
222
  * "used by another org" check of deletes. An item that is gone or disabled is on nowhere.
224
223
  */
225
224
  export function orgsUsing(db, ref, opts = {}) {
226
225
  // org-filter: deployment-wide subscriber lookup, keyed by the shared item id.
227
226
  return asPlatform("find the live organizations using this shared item", async () => {
228
- const orgs = await db
227
+ let query = db
229
228
  .selectFrom("orgs")
230
229
  .select(["id", "name"])
231
230
  .where("deleted_at", "is", null)
232
231
  .orderBy("name")
233
- .orderBy("id")
234
- .execute();
235
- const others = orgs.filter((o) => o.id !== opts.except);
236
- if (others.length === 0)
237
- return [];
232
+ .orderBy("id");
233
+ if (opts.except != null)
234
+ query = query.where("id", "!=", opts.except);
238
235
  if (ref.kind === "plugin") {
239
- const item = await db
240
- .selectFrom("catalog_items")
241
- .select(["scope", "builtin", "disabled"])
242
- .where("id", "=", ref.id)
243
- .where("deleted_at", "is", null)
244
- .executeTakeFirst();
245
- if (!item)
246
- return [];
247
- const listed = new Set((await db
248
- .selectFrom("catalog_item_scope_orgs")
249
- .select("org_id")
250
- .where("item_id", "=", ref.id)
251
- .execute()).map((r) => r.org_id));
252
- const switches = new Map((await db
253
- .selectFrom("catalog_item_org_switches")
254
- .select(["org_id", "enabled"])
255
- .where("item_id", "=", ref.id)
256
- .execute()).map((r) => [r.org_id, r.enabled]));
257
- return others.filter((o) => wantedOn(item, listed.has(o.id), switches.get(o.id) ?? null));
236
+ return query.where(({ ref: column }) => orgUsable(db, column("orgs.id"), ref.id)).execute();
258
237
  }
238
+ const others = await query.execute();
239
+ if (others.length === 0)
240
+ return [];
259
241
  const kind = ref.kind;
260
242
  const [c] = await loadComponents(db, kind, { ids: [ref.id] });
261
243
  if (!c)
@@ -180,6 +180,7 @@ export declare class PlatformComponents {
180
180
  private files;
181
181
  constructor(kdb: KernelDb, storage: StorageService, itemLock: CatalogItemLock, log: KernelLogger, txHost: TransactionHost);
182
182
  private get db();
183
+ initializeDependencyEdges(): Promise<void>;
183
184
  /** CLI only (see `PluginImport.useCliStorage`): files go to the object store the CLI set up. */
184
185
  useCliStorage(storage: PrefixedStorage): void;
185
186
  /**
@@ -194,7 +195,8 @@ export declare class PlatformComponents {
194
195
  prepareImport(source: SyncSource): Promise<PreparedSync>;
195
196
  /**
196
197
  * The second phase: writes the prepared rows in the caller's transaction and records
197
- * `platform_synced_version`. A component changed since the plan -> {@link PlanStale} (the caller
198
+ * `platform_synced_version`. The caller refreshes edges after all version and component changes.
199
+ * A component changed since the plan -> {@link PlanStale} (the caller
198
200
  * prepares again).
199
201
  */
200
202
  applySyncIn(p: PreparedSync): Promise<PlatformSyncResult>;
@@ -28,6 +28,7 @@ import { StorageService } from "../storage/storage.service.js";
28
28
  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
+ import { initializeCatalogDependencyEdges } from "./dependency-edges.js";
31
32
  import { CatalogItemLock } from "./locks.js";
32
33
  import { relinkDeletedItemConnectors } from "./plugin-connectors.js";
33
34
  /** The prefix (in `deployment/`) of a platform skill version's files. */
@@ -78,6 +79,9 @@ let PlatformComponents = class PlatformComponents {
78
79
  get db() {
79
80
  return this.kdb.db;
80
81
  }
82
+ async initializeDependencyEdges() {
83
+ await initializeCatalogDependencyEdges(this.db);
84
+ }
81
85
  /** CLI only (see `PluginImport.useCliStorage`): files go to the object store the CLI set up. */
82
86
  useCliStorage(storage) {
83
87
  this.files = storage;
@@ -109,7 +113,8 @@ let PlatformComponents = class PlatformComponents {
109
113
  }
110
114
  /**
111
115
  * The second phase: writes the prepared rows in the caller's transaction and records
112
- * `platform_synced_version`. A component changed since the plan -> {@link PlanStale} (the caller
116
+ * `platform_synced_version`. The caller refreshes edges after all version and component changes.
117
+ * A component changed since the plan -> {@link PlanStale} (the caller
113
118
  * prepares again).
114
119
  */
115
120
  async applySyncIn(p) {
@@ -828,6 +833,9 @@ let PlatformComponents = class PlatformComponents {
828
833
  return out;
829
834
  }
830
835
  };
836
+ __decorate([
837
+ Transactional()
838
+ ], PlatformComponents.prototype, "initializeDependencyEdges", null);
831
839
  __decorate([
832
840
  Transactional({ propagation: "mandatory" })
833
841
  ], PlatformComponents.prototype, "applySyncIn", null);
@@ -15,6 +15,7 @@ import { SuperAdminLock } from "../identity/super-admin.js";
15
15
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
16
16
  import { KernelDb } from "../infra/database/kernel-db.js";
17
17
  import { TransactionHost } from "../infra/database/transaction-host.js";
18
+ import { XactLock } from "../infra/database/xact-lock.js";
18
19
  import { OutboxService } from "../infra/outbox/outbox.service.js";
19
20
  import type { KernelLogger } from "../log.js";
20
21
  import { OrgLock } from "../orgs/org-lock.js";
@@ -421,6 +422,7 @@ export declare class PluginImport {
421
422
  private readonly registry;
422
423
  private readonly log;
423
424
  readonly txHost: TransactionHost;
425
+ private readonly xactLock;
424
426
  /** The platform rows of a new item's components, written in the confirm's transaction. */
425
427
  private readonly platform;
426
428
  /** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
@@ -441,11 +443,11 @@ export declare class PluginImport {
441
443
  /** Reads a package from the package store (confirm recomputes the permission set). */
442
444
  blobs: ExtensionBlobs,
443
445
  /** Config-declared names, loaded connectors and extension versions (the extension registry). */
444
- registry: ExtensionRegistry, log: KernelLogger, txHost: TransactionHost,
446
+ registry: ExtensionRegistry, log: KernelLogger, txHost: TransactionHost, xactLock: XactLock,
445
447
  /** The platform rows of a new item's components, written in the confirm's transaction. */
446
448
  platform: PlatformComponents,
447
449
  /** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
448
- outbox: Pick<OutboxService, "add">);
450
+ outbox: Pick<OutboxService, "add" | "addMany">);
449
451
  /** The kernel-schema handle of the current context (the transaction, else the pool). */
450
452
  private get db();
451
453
  /**
@@ -34,6 +34,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
34
34
  import { asPlatform } from "../infra/database/org-scope.js";
35
35
  import { TransactionHost } from "../infra/database/transaction-host.js";
36
36
  import { Transactional } from "../infra/database/transactional.decorator.js";
37
+ import { XactLock } from "../infra/database/xact-lock.js";
37
38
  import { OutboxService } from "../infra/outbox/outbox.service.js";
38
39
  import { KERNEL_LOGGER } from "../infra/tokens.js";
39
40
  import { OrgLock } from "../orgs/org-lock.js";
@@ -50,6 +51,8 @@ import { CLAUDE_PLUGIN_FILE, claudeContentDigest, } from "./claude/manifest.js";
50
51
  import { CLAUDE_MCP_CONNECTOR } from "./claude/mcp.js";
51
52
  import { item as reportItem, sortItems, } from "./claude/report.js";
52
53
  import { isClaudePluginTree, translateClaudePlugin } from "./claude/translate.js";
54
+ import { refreshCatalogDependencyEdges } from "./dependency-edges.js";
55
+ import { EFFECT_CANDIDATES_LOCK, oweEffectWork } from "./effect-work.js";
53
56
  import { CatalogItemLock } from "./locks.js";
54
57
  import { requireMarketplacePublisher } from "./marketplace-fetch.js";
55
58
  import { assertNameFree, assertPackageFree, assertShareable, packageOwner, shareGate, usableBy, } from "./ownership.js";
@@ -58,8 +61,8 @@ import { assertDeclarativeUpload, PluginPackageError, readPluginFiles, readPlugi
58
61
  import { OFFICIAL_MARKETPLACE_ID, officialPublisherProofMode } from "./publisher-policy.js";
59
62
  import { hasImportRequests, importRequestOf, resolveImportRequests } from "./request-rules.js";
60
63
  import { assertNameNotReserved } from "./reserved-names.js";
61
- import { oweScopeItem } from "./scope-jobs.js";
62
64
  import { addScopeOrg } from "./scope-orgs.js";
65
+ import { writeScope } from "./scope-writer.js";
63
66
  import { templateDescriptionText } from "./template-description.js";
64
67
  import { maxSatisfying, satisfiesRange } from "./versions.js";
65
68
  /**
@@ -162,6 +165,7 @@ let PluginImport = class PluginImport {
162
165
  registry;
163
166
  log;
164
167
  txHost;
168
+ xactLock;
165
169
  platform;
166
170
  outbox;
167
171
  /** Where plugin files go (the kernel's object storage; the CLI's own, see {@link useCliStorage}). */
@@ -180,7 +184,7 @@ let PluginImport = class PluginImport {
180
184
  /** Reads a package from the package store (confirm recomputes the permission set). */
181
185
  blobs,
182
186
  /** Config-declared names, loaded connectors and extension versions (the extension registry). */
183
- registry, log, txHost,
187
+ registry, log, txHost, xactLock,
184
188
  /** The platform rows of a new item's components, written in the confirm's transaction. */
185
189
  platform,
186
190
  /** The item's scope sync, owed by the confirm's commit when it deploys no extension. */
@@ -200,6 +204,7 @@ let PluginImport = class PluginImport {
200
204
  this.registry = registry;
201
205
  this.log = log;
202
206
  this.txHost = txHost;
207
+ this.xactLock = xactLock;
203
208
  this.platform = platform;
204
209
  this.outbox = outbox;
205
210
  this.files = storage;
@@ -832,6 +837,7 @@ let PluginImport = class PluginImport {
832
837
  const reviewed = review.extension;
833
838
  const stale = () => reviewStale(review);
834
839
  const { owner } = scope;
840
+ await this.xactLock.lock(EFFECT_CANDIDATES_LOCK);
835
841
  await this.authorizeActor(actor, owner);
836
842
  const t = this.db;
837
843
  // The settings writer takes the same super-admin lock. A staged pin-only import
@@ -942,7 +948,7 @@ let PluginImport = class PluginImport {
942
948
  previous,
943
949
  };
944
950
  }
945
- const { id: itemId, created } = await writeCatalogVersion(t, {
951
+ const { id: itemId, created, selectedVersionChanged, } = await writeCatalogVersion(t, {
946
952
  // an org's version becomes its latest only when applied or confirmed (P3-34)
947
953
  ...(owner !== undefined && { keepLatest: true }),
948
954
  actor,
@@ -987,26 +993,18 @@ let PluginImport = class PluginImport {
987
993
  // A new item gets the scope chosen in the review; a new version keeps the item's scope, its
988
994
  // org list and its scope version (prepare reuses the live item's id, so the id cannot tell)
989
995
  if (created) {
990
- await t
991
- .updateTable("catalog_items")
992
- .set({
993
- scope: scope.scope,
994
- // an org upload: the org owns it, nobody else sees it until shared and shown (P3-16)
995
- ...(owner !== undefined && {
996
+ if (owner !== undefined) {
997
+ await t
998
+ .updateTable("catalog_items")
999
+ .set({
996
1000
  owner_org_id: owner.orgId,
997
1001
  shareable: scope.shareable === true,
998
1002
  shown_to_others: false,
999
- }),
1000
- })
1001
- .where("id", "=", itemId)
1002
- .execute();
1003
- if (scope.scope === "named" && scope.orgs.length > 0) {
1004
- await t
1005
- .insertInto("catalog_item_scope_orgs")
1006
- .values(scope.orgs.map((org_id) => ({ item_id: itemId, org_id })))
1007
- .onConflict((oc) => oc.doNothing())
1003
+ })
1004
+ .where("id", "=", itemId)
1008
1005
  .execute();
1009
1006
  }
1007
+ await writeScope(t, { kind: "plugin", id: itemId, scope: scope.scope, orgs: scope.orgs });
1010
1008
  }
1011
1009
  // The org requests this staging answers resolve with the confirm; on an item that existed
1012
1010
  // already (imported meanwhile) a `named` scope gains their orgs. An org-owned item held back by
@@ -1055,9 +1053,11 @@ let PluginImport = class PluginImport {
1055
1053
  .where("id", "=", itemId)
1056
1054
  .executeTakeFirstOrThrow();
1057
1055
  if (item.scope !== "optional" || owner !== undefined) {
1058
- await oweScopeItem(this.outbox, t, itemId);
1056
+ await oweEffectWork(this.outbox, t, { itemIds: [itemId] });
1059
1057
  }
1060
1058
  }
1059
+ if (selectedVersionChanged)
1060
+ await refreshCatalogDependencyEdges(t);
1061
1061
  return {
1062
1062
  itemId,
1063
1063
  created,
@@ -1645,8 +1645,9 @@ PluginImport = __decorate([
1645
1645
  __param(13, Inject(ExtensionRegistry)),
1646
1646
  __param(14, Inject(KERNEL_LOGGER)),
1647
1647
  __param(15, Inject(TransactionHost)),
1648
- __param(16, Inject(PlatformComponents)),
1649
- __param(17, Inject(OutboxService))
1648
+ __param(16, Inject(XactLock)),
1649
+ __param(17, Inject(PlatformComponents)),
1650
+ __param(18, Inject(OutboxService))
1650
1651
  ], PluginImport);
1651
1652
  export { PluginImport };
1652
1653
  /**
@@ -1,12 +1,10 @@
1
1
  import { type AgentTemplate, type ConnectorTemplateFile, type PluginManifest } from "@capybara-hq/plugin-sdk";
2
- import type { KernelSchemaDb, PluginInstallStatus, SourceFormat } from "../db/kernel-schema.js";
2
+ import type { KernelSchemaDb, PluginEffectError, PluginInstallStatus, SourceFormat } from "../db/kernel-schema.js";
3
3
  import { OrgExtensionConfigs, type OrgExtensionInput, type OrgExtensionPutOptions } from "../extensions/org-config.js";
4
4
  import { ExtensionRegistry } from "../extensions/registry.js";
5
- import { KernelConfigService } from "../infra/config/kernel-config.service.js";
6
5
  import { KernelDb } from "../infra/database/kernel-db.js";
7
6
  import { TransactionHost } from "../infra/database/transaction-host.js";
8
7
  import { OutboxService } from "../infra/outbox/outbox.service.js";
9
- import type { KernelLogger } from "../log.js";
10
8
  import { OrgLock } from "../orgs/org-lock.js";
11
9
  import type { OrgAction } from "../orgs/roles.js";
12
10
  import { type SkillConflict, SkillsService } from "../skills/skills.service.js";
@@ -16,6 +14,7 @@ import type { ConnectorDetail, CreateConnectorInput, ToolIssue } from "../tools/
16
14
  import { ConnectorsService } from "../tools/connectors.service.js";
17
15
  import { type CatalogVersionFiles, type TemplateDeps } from "./catalog-content.js";
18
16
  import { type DefinitionRefs, type TemplateSwitch } from "./component-state.js";
17
+ import { ScopeWriter } from "./scope-writer.js";
19
18
  /**
20
19
  * What an org fills in for one more connector from a connector template (C30; `POST …/
21
20
  * connector-templates/:templateId/connectors`). Installs and enables take none (plugin pages spec
@@ -78,9 +77,9 @@ export interface UninstallReport {
78
77
  * plugin's skills, connectors or agent templates.
79
78
  */
80
79
  export interface UninstallPreview {
81
- installId: string;
80
+ installId: string | null;
82
81
  name: string;
83
- version: string;
82
+ version: string | null;
84
83
  components: {
85
84
  kind: ComponentKind;
86
85
  ref: string;
@@ -103,22 +102,16 @@ export interface UninstallPreview {
103
102
  }
104
103
  /** The confirm hash of an uninstall preview: sha256 over its sorted JSON (the scheme of `diffHash`). */
105
104
  export declare function uninstallPreviewHash(p: UninstallPreview): string;
106
- /** Upserts the org's switch row of an item in the caller's transaction (the org lock is held). */
107
- export declare function upsertOrgSwitch(db: KernelSchemaDb, orgId: string, itemId: string, enabled: boolean, actor: string | null): Promise<void>;
108
105
  /** A plugin install in an org (`GET /orgs/:orgId/plugin-installs`). */
109
106
  export interface PluginInstallView {
110
107
  id: string;
111
108
  itemId: string;
112
109
  name: string;
113
- version: string;
110
+ version: string | null;
114
111
  status: PluginInstallStatus;
115
112
  installedBy: string | null;
116
113
  installedAt: string;
117
- /** The failed install's step and code, or the last failed upgrade's (the install stays installed). */
118
- error: {
119
- step: string;
120
- code: string;
121
- } | null;
114
+ error: PluginEffectError | null;
122
115
  /**
123
116
  * `dropped`: an upgrade removed it from the plugin but kept it because an agent uses it ("no
124
117
  * longer in the plugin"); uninstalling still removes it once nothing uses it.
@@ -146,7 +139,6 @@ export interface ResolvedDependency {
146
139
  version: string;
147
140
  }
148
141
  /** How deep plugin dependencies may nest (the root plugin's dependencies are level 1). */
149
- export declare const DEPENDENCY_DEPTH_LIMIT = 10;
150
142
  /** A component as an install records it (see `plugin_install_components`). */
151
143
  export interface Component {
152
144
  kind: ComponentKind;
@@ -269,10 +261,9 @@ export declare class PluginInstaller {
269
261
  private readonly registry;
270
262
  private readonly skills;
271
263
  private readonly orgConfigs;
272
- private readonly config;
264
+ private readonly scopeWriter;
273
265
  /** Org connectors: installs create, upgrade and remove them. */
274
266
  private readonly connectors;
275
- private readonly log;
276
267
  /** Owes the template connector ensure of an install's commit (`markInstalled`). */
277
268
  private readonly outbox;
278
269
  readonly txHost: TransactionHost;
@@ -280,15 +271,13 @@ export declare class PluginInstaller {
280
271
  /** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
281
272
  orgLock: OrgLock, storage: StorageService,
282
273
  /** The loaded extensions and connectors of this replica (the extension registry). */
283
- registry: ExtensionRegistry, skills: SkillsService, orgConfigs: OrgExtensionConfigs, config: KernelConfigService,
274
+ registry: ExtensionRegistry, skills: SkillsService, orgConfigs: OrgExtensionConfigs, scopeWriter: ScopeWriter,
284
275
  /** Org connectors: installs create, upgrade and remove them. */
285
- connectors: ConnectorsService, log: KernelLogger,
276
+ connectors: ConnectorsService,
286
277
  /** Owes the template connector ensure of an install's commit (`markInstalled`). */
287
278
  outbox: Pick<OutboxService, "add">, txHost: TransactionHost);
288
279
  /** The kernel-schema handle of the current context (the transaction, else the pool). */
289
280
  private get db();
290
- /** `catalog.staleInstallMinutes`: an install `installing` for longer can be cleaned up by uninstalling it. */
291
- staleInstallMinutes(): number;
292
281
  /**
293
282
  * The checks an install runs before it creates anything, without the org's input (for the org
294
283
  * catalog to run before a request is created): dependency resolution, the extensions deployed and
@@ -302,7 +291,9 @@ export declare class PluginInstaller {
302
291
  auditDetail?: AuditDetail;
303
292
  switchOn?: boolean;
304
293
  via?: "scope";
305
- }): Promise<PluginInstallView>;
294
+ }): Promise<PluginInstallView | null>;
295
+ private effectGeneration;
296
+ private recordInstallFailure;
306
297
  /**
307
298
  * Refuses a plan whose skills would overwrite a skill of other provenance (spec §9.2, Decision
308
299
  * 8) with 409 `plugin.skill_conflict`, before anything is written: for the plugin and each
@@ -396,27 +387,12 @@ export declare class PluginInstaller {
396
387
  switchOn?: boolean;
397
388
  /** Installed by the plugin scope sync (recorded in the audits). */
398
389
  via?: "scope";
399
- }): Promise<string>;
400
- /**
401
- * The install row (role and item policy re-checked under the lock; one live install per org and
402
- * item). A step of the install: committed on its own.
403
- */
404
- /**
405
- * Enables a plugin's extension for the org and records it as a component of the install, in one
406
- * transaction (`put` joins it): "enabled before" is decided under the org row lock (already
407
- * enabled: `put` writes nothing, the config is untouched, the component is recorded as not
408
- * created), and the ledger row is written before the COMMIT, so no concurrent uninstall fits
409
- * between enabling and recording. Used only by a fresh install (and a dependency the install or a
410
- * platform update adds): a platform update of an installed plugin and switching an installed
411
- * plugin on again never call it, so an extension the org switched off stays off (extension switch
412
- * spec 2026-12-02 §3.2).
413
- */
414
- enableExtension(orgId: string, name: string, input: OrgExtensionInput, actor: string | null, actorTokenId: string | undefined, opts: Pick<OrgExtensionPutOptions, "viaItem" | "approvedBy">, record: (c: Component) => Promise<void>): Promise<void>;
390
+ }): Promise<string | null>;
391
+ /** Validates extension setup and owes connector discovery in the caller's transaction. */
392
+ enableExtension(orgId: string, name: string, input: OrgExtensionInput, actor: string | null, actorTokenId: string | undefined, opts: Pick<OrgExtensionPutOptions, "viaItem" | "approvedBy">): Promise<void>;
415
393
  private createInstallRow;
416
394
  /** The install `installed` and its `plugin.org_installed` audit, under the org row lock (its own transaction). */
417
395
  private markInstalled;
418
- /** The install `failed` with `{ step, code }` and its `plugin.org_install_failed` audit (its own transaction). */
419
- private markFailed;
420
396
  /**
421
397
  * The extension to enable: the plugin's own, when it has one. Not loaded on this replica ->
422
398
  * `catalog.not_deployed`; not yet enabled in this org while its own catalog item is disabled ->
@@ -424,20 +400,6 @@ export declare class PluginInstaller {
424
400
  * unaffected.
425
401
  */
426
402
  planExtension(orgId: string, manifest: PluginManifest): Promise<string | null>;
427
- /**
428
- * Undoes the components this install created, in reverse order (the role is not re-checked: it
429
- * undoes this install's own changes); returns the ones that failed. The component rows of undone
430
- * (or already gone) components are deleted in the same transaction, so cleaning up the failed
431
- * install later only handles what failed to undo or was kept, and does not undo again an extension
432
- * an org admin re-enabled by hand or a skill version a user uploaded since.
433
- */
434
- private rollback;
435
- /**
436
- * Undoes one component of a failed install and deletes its component row, under the org row lock,
437
- * in a transaction of its own (committed when it returns); returns the extensions it disabled
438
- * (the caller notifies them).
439
- */
440
- private rollbackOne;
441
403
  /** Removes one component (one already gone is no error); returns whether anything changed. */
442
404
  removeComponent(orgId: string, actor: string | null, c: Component, reason: string): Promise<boolean>;
443
405
  /**
@@ -589,7 +551,7 @@ export declare class PluginInstaller {
589
551
  * the item whose status is one of `statuses` (`created`: the plugin made it, so an uninstall and
590
552
  * upgrades see it), in the caller's transaction. True when such an install exists.
591
553
  */
592
- recordTemplateConnectorIn(orgId: string, itemId: string, connectorId: string, templateId: string, statuses: readonly PluginInstallStatus[]): Promise<boolean>;
554
+ recordTemplateConnectorIn(orgId: string, itemId: string, connectorId: string, templateId: string): Promise<boolean>;
593
555
  /**
594
556
  * Records a connector made from a plugin's template on the org's live install of that plugin,
595
557
  * when there is one, under the org lock (so an uninstall in between is seen).
@@ -614,6 +576,9 @@ export declare class PluginInstaller {
614
576
  * update keeps copies of removed components).
615
577
  */
616
578
  previewUninstall(orgId: string, installId: string): Promise<UninstallPreview>;
579
+ /** A pure content plugin can take components away without an org install row. */
580
+ previewContentOff(orgId: string, itemId: string): Promise<UninstallPreview | null>;
581
+ private previewRemoval;
617
582
  /**
618
583
  * The connectors, skills (selected, pinned, or in an inline sub-agent template) and agent
619
584
  * templates (`subagents.templates`) referenced by the current definitions of the org's live