@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
@@ -9,6 +9,7 @@ import { OrgLock } from "../orgs/org-lock.js";
9
9
  import { EffectiveConfigs } from "./effective-config.js";
10
10
  import { ExtensionHost } from "./host.js";
11
11
  import { ExtensionInstalls } from "./installs.js";
12
+ import { PluginInstallLock } from "./locks.js";
12
13
  import { type DeploymentExtensionStatus, type PermissionGroup } from "./permission-view.js";
13
14
  import { ExtensionAvailability, type ExtensionUnavailableReason } from "./unavailable.js";
14
15
  /**
@@ -55,15 +56,8 @@ export interface OrgExtensionView {
55
56
  } | null;
56
57
  /** The org admin can switch it: never for a required one or a builtin plugin's. */
57
58
  switchable: boolean;
58
- /**
59
- * Whether the plugin that brings the extension is installed in the org: `installed` /
60
- * `not_installed` for an extension with a plugin path (one catalog plugin, not builtin, not
61
- * required), null without one (required, config-declared, several sources, builtin). The org's
62
- * Extensions and Models pages list an extension unless it is `not_installed` and off
63
- * ({@link listedInOrg}); its switch starts or stops the extension only, and switching on needs
64
- * the plugin installed (`extension.plugin_not_installed`; extension switch spec 2026-12-02).
65
- */
66
- pluginInstall: "installed" | "not_installed" | null;
59
+ /** Effective intent of the plugin whose switch this extension follows, or null without one. */
60
+ pluginUsable: boolean | null;
67
61
  /**
68
62
  * The two-level deployment config (spec A §5.3, §5.4): `following` the platform, a `copy` of the
69
63
  * overridable fields, or `none` (the extension has no overridable field, or is unavailable).
@@ -75,13 +69,8 @@ export interface OrgExtensionView {
75
69
  */
76
70
  needsConfig: boolean;
77
71
  }
78
- /**
79
- * Whether the org's lists of its extensions (the Extensions page, the Models page's model services,
80
- * `extensions.list`) show the extension: everything except one whose plugin is not installed in
81
- * the org and that is off (the Plugins page installs it; one left on shows, so it can be stopped).
82
- * The web applies the same rule (`apps/web/src/lib/extensions.ts`).
83
- */
84
- export declare function listedInOrg(view: Pick<OrgExtensionView, "pluginInstall" | "enabled">): boolean;
72
+ /** The management list shows extensions whose bundle is usable or that are independently enabled. */
73
+ export declare function listedInOrg(view: Pick<OrgExtensionView, "pluginUsable" | "enabled">): boolean;
85
74
  /** The extension points an extension provides, from its permission list's `provides` group. */
86
75
  export declare function providesOf(view: Pick<OrgExtensionView, "permissions">): string[];
87
76
  /** The input of `put`: enablement only. */
@@ -118,12 +107,13 @@ export interface OrgExtensionPutOptions {
118
107
  auditDetail?: Record<string, unknown>;
119
108
  }
120
109
  /**
121
- * Org-level extension enablement (`capybara.extension_org_configs.enabled`) and the org's view of
110
+ * Org-level extension intent and the org's view of
122
111
  * each extension. OrgOverrides manages the org's copy of overridable deployment fields.
123
112
  * EffectiveConfigs validates the config used for org-bound calls. Each replica reads enablement
124
113
  * from PostgreSQL.
125
114
  */
126
115
  export declare class OrgExtensionConfigs {
116
+ private readonly installLock;
127
117
  private readonly kdb;
128
118
  readonly txHost: TransactionHost;
129
119
  private readonly host;
@@ -139,7 +129,7 @@ export declare class OrgExtensionConfigs {
139
129
  private readonly availability;
140
130
  /** Owes the org's template connector ensure when an extension is switched on (ruling R27). */
141
131
  private readonly outbox;
142
- constructor(kdb: KernelDb, txHost: TransactionHost, host: ExtensionHost,
132
+ constructor(installLock: PluginInstallLock, kdb: KernelDb, txHost: TransactionHost, host: ExtensionHost,
143
133
  /** The org row lock (orgs/org-lock.ts): joins the transaction. */
144
134
  orgLock: OrgLock,
145
135
  /** Install records (any desired state): the ones not loaded are listed unavailable (T14). */
@@ -181,9 +171,9 @@ export declare class OrgExtensionConfigs {
181
171
  * How an `enabled` write of this extension in the org is handled, read before the write (the
182
172
  * Platform tool's precheck; {@link put} repeats every rule under the org row lock): `direct`, a
183
173
  * write of the extension's own switch (a required bootstrap plugin keeps `extension.required`;
184
- * the plugin stays installed either way, extension switch spec 2026-12-02 §3.1), `locked` (a live
174
+ * the bundle keeps its intent either way, extension switch spec 2026-12-02 §3.1), `locked` (a live
185
175
  * item is builtin and the write switches off: `plugin.scope_locked`), or `not_installed` (switching
186
- * on an extension whose plugin is not installed in the org: `extension.plugin_not_installed`).
176
+ * on an extension whose plugin is off in the org: `extension.plugin_not_installed`).
187
177
  */
188
178
  switchPlan(orgId: string, plugin: string, enabled: boolean): Promise<{
189
179
  kind: "direct";
@@ -199,7 +189,7 @@ export declare class OrgExtensionConfigs {
199
189
  * - Extension not loaded -> `extension.not_found`; `enabled: false` for a required bootstrap
200
190
  * plugin -> `extension.required` (it stays enabled in every org).
201
191
  * - Switches the extension only, never its plugin (extension switch spec 2026-12-02 §3.1): with a
202
- * plugin path ({@link pluginPathItem}) switching on needs the plugin installed in the org
192
+ * plugin path ({@link pluginPathItem}) switching on needs the plugin usable in the org
203
193
  * (`extension.plugin_not_installed`; the install itself passes `viaItem`), and switching off an
204
194
  * extension that is off already while its plugin is not installed writes nothing.
205
195
  * - Enabling never checks a config: an extension whose effective config is not valid for the org
@@ -216,8 +206,7 @@ export declare class OrgExtensionConfigs {
216
206
  */
217
207
  private assertSwitchRules;
218
208
  /**
219
- * Whether `plugin` is enabled in the org: an always-on extension (a required bootstrap plugin, or
220
- * its plugin is builtin: `enabled.ts`) is enabled without a row; no row otherwise -> undefined.
209
+ * The extension's committed intent in the org; absent when it is off and has no explicit switch.
221
210
  * Inside a caller's transaction it reads in that transaction (it sees the caller's uncommitted
222
211
  * writes). The extension's config for the org is its effective config ({@link EffectiveConfigs}).
223
212
  */
@@ -230,8 +219,9 @@ export declare class OrgExtensionConfigs {
230
219
  */
231
220
  enabledDependents(orgId: string, plugin: string): Promise<string[]>;
232
221
  /**
233
- * 在调用方事务里停用(应用安装的回滚与卸载用;调用方已锁组织行并复核角色):不检查依赖方,配置保留,
234
- * 审计 `org.plugin_config.updated`(带 reason)。提交后调用方须再调 {@link afterDisable}。
222
+ * Stops the extension during bundle rollback or uninstall under the caller's org lock and
223
+ * authorization. It keeps configuration, skips dependent checks and audits the reason.
224
+ * The caller invokes {@link afterDisable} after commit.
235
225
  */
236
226
  disableIn(orgId: string, plugin: string, actorAccountId: string | null, reason: string): Promise<boolean>;
237
227
  /** {@link disableIn} 的事务提交之后:通知停用(断开该插件的渠道连接等)。 */
@@ -252,12 +242,12 @@ export declare class OrgExtensionConfigs {
252
242
  }
253
243
  /**
254
244
  * Whether the org may see `plugin` (a required bootstrap plugin always; else under its catalog
255
- * items' scope; the list also hides one off here whose item is disabled, {@link offeredToOrg}).
245
+ * items' visibility).
256
246
  * `db` may be a transaction.
257
247
  */
258
248
  export declare function extensionVisibleTo(db: KernelSchemaDb, orgId: string, plugin: string): Promise<boolean>;
259
249
  /**
260
- * `extension.plugin_not_installed`: switching on an extension whose plugin is not installed in the
250
+ * `extension.plugin_not_installed`: switching on an extension whose plugin is off in the
261
251
  * org. Names the plugin (details `[{ itemId, plugin }]`). `db` may be a transaction.
262
252
  */
263
253
  export declare function pluginNotInstalledError(db: KernelSchemaDb, extension: string, itemId: string): Promise<ApiError>;
@@ -9,7 +9,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { EXTENSION_POINTS, parseExtensionPoint, } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
+ import { orgUsable } from "../catalog/org-intent.js";
12
13
  import { assertItemInstallable, assertPluginSourcesInstallable, disabledPluginItems, pluginItemDisabled, } from "../catalog/request-rules.js";
14
+ import { itemsSeenBy, pluginUsable } from "../catalog/scope-state.js";
15
+ import { writeComponentSwitch } from "../catalog/scope-writer.js";
13
16
  import { oweTemplateConnectors } from "../catalog/template-connector-jobs.js";
14
17
  import { oweHostServicesStop } from "../device-access/host-service-stop.js";
15
18
  import { revokeSiteGrantsOfExtension } from "../device-access/site-grants.js";
@@ -23,21 +26,17 @@ import { KernelEvents } from "../infra/events/kernel-events.js";
23
26
  import { OutboxService } from "../infra/outbox/outbox.service.js";
24
27
  import { OrgLock } from "../orgs/org-lock.js";
25
28
  import { EffectiveConfigs } from "./effective-config.js";
26
- import { alwaysOnExtensions, enabledExtensionsQuery, requiredExtensions } from "./enabled.js";
29
+ import { alwaysOnExtensions, enabledExtensionsQuery, extensionSwitch, isExtensionEnabled, requiredExtensions, } from "./enabled.js";
27
30
  import { ExtensionHost } from "./host.js";
28
31
  import { ExtensionInstalls } from "./installs.js";
32
+ import { PluginInstallLock } from "./locks.js";
29
33
  import { fieldLevels } from "./org-levels.js";
30
34
  import { permissionGroups, } from "./permission-view.js";
31
- import { itemLocked, itemsVisible, liveInstalledItems, offeredToOrg, pluginInstallOf, pluginItemsOf, pluginPathItem, scopeListedFor, } from "./plugin-items.js";
35
+ import { itemLocked, pluginItemsOf, pluginPathItem, } from "./plugin-items.js";
32
36
  import { ExtensionAvailability } from "./unavailable.js";
33
- /**
34
- * Whether the org's lists of its extensions (the Extensions page, the Models page's model services,
35
- * `extensions.list`) show the extension: everything except one whose plugin is not installed in
36
- * the org and that is off (the Plugins page installs it; one left on shows, so it can be stopped).
37
- * The web applies the same rule (`apps/web/src/lib/extensions.ts`).
38
- */
37
+ /** The management list shows extensions whose bundle is usable or that are independently enabled. */
39
38
  export function listedInOrg(view) {
40
- return view.pluginInstall !== "not_installed" || view.enabled;
39
+ return view.pluginUsable !== false || view.enabled;
41
40
  }
42
41
  /** The extension points an extension provides, from its permission list's `provides` group. */
43
42
  export function providesOf(view) {
@@ -48,23 +47,24 @@ export function providesOf(view) {
48
47
  * With several source items, a builtin one locks the extension on (scope `all`); an `all` one does
49
48
  * not (layering spec §4).
50
49
  */
51
- function scopeFields(items, required) {
52
- const primary = items?.[0];
50
+ function scopeFields(items, required, seen) {
51
+ const primary = items?.find((item) => seen === undefined || seen.has(item.id));
52
+ const locked = required || items?.some(itemLocked) === true;
53
53
  if (!primary)
54
- return { catalogItem: null, switchable: !required };
55
- const locked = required || items.some(itemLocked);
54
+ return { catalogItem: null, switchable: !locked };
56
55
  return {
57
56
  catalogItem: { itemId: primary.id, scope: locked ? "all" : primary.scope },
58
57
  switchable: !locked,
59
58
  };
60
59
  }
61
60
  /**
62
- * Org-level extension enablement (`capybara.extension_org_configs.enabled`) and the org's view of
61
+ * Org-level extension intent and the org's view of
63
62
  * each extension. OrgOverrides manages the org's copy of overridable deployment fields.
64
63
  * EffectiveConfigs validates the config used for org-bound calls. Each replica reads enablement
65
64
  * from PostgreSQL.
66
65
  */
67
66
  let OrgExtensionConfigs = class OrgExtensionConfigs {
67
+ installLock;
68
68
  kdb;
69
69
  txHost;
70
70
  host;
@@ -74,7 +74,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
74
74
  effective;
75
75
  availability;
76
76
  outbox;
77
- constructor(kdb, txHost, host,
77
+ constructor(installLock, kdb, txHost, host,
78
78
  /** The org row lock (orgs/org-lock.ts): joins the transaction. */
79
79
  orgLock,
80
80
  /** Install records (any desired state): the ones not loaded are listed unavailable (T14). */
@@ -87,6 +87,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
87
87
  availability,
88
88
  /** Owes the org's template connector ensure when an extension is switched on (ruling R27). */
89
89
  outbox) {
90
+ this.installLock = installLock;
90
91
  this.kdb = kdb;
91
92
  this.txHost = txHost;
92
93
  this.host = host;
@@ -158,33 +159,40 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
158
159
  */
159
160
  async listSnapshot(orgId, installed) {
160
161
  const t = this.db;
161
- const rows = await t
162
- .selectFrom("extension_org_configs")
163
- .select(["plugin", "enabled"])
164
- .where("org_id", "=", orgId)
165
- .execute();
166
- // Required bootstrap plugins and builtin plugins' extensions are listed enabled (no org
167
- // config row needed, spec §7; enabled.ts)
162
+ const enabled = new Set((await enabledExtensionsQuery(t, orgId).execute()).map((row) => row.plugin));
168
163
  const required = await requiredExtensions(t);
169
- const on = await alwaysOnExtensions(t);
170
164
  const loaded = this.host.manifests();
171
165
  const items = await pluginItemsOf(t, [
172
166
  ...loaded.map((m) => m.name),
173
167
  ...installed.map((i) => i.name),
174
168
  ]);
175
- // An extension the org is not offered (a `named` plugin without it, or one off here whose
176
- // item the super admin disabled) is absent: the rule readiness shares
177
- const listed = await scopeListedFor(t, orgId);
178
- const live = await liveInstalledItems(t, orgId);
179
- const seen = (name) => offeredToOrg({
180
- required: required.has(name),
181
- enabled: on.has(name) || (rows.find((r) => r.plugin === name)?.enabled ?? false),
182
- items: items.get(name),
183
- listed,
184
- });
169
+ const itemIds = [
170
+ ...new Set([...items.values()].flatMap((sources) => sources.map((source) => source.id))),
171
+ ];
172
+ const shown = await itemsSeenBy(t, orgId, itemIds, "offered");
173
+ const usable = new Set(itemIds.length === 0
174
+ ? []
175
+ : (await t
176
+ .selectFrom("catalog_items")
177
+ .select("id")
178
+ .where("id", "in", itemIds)
179
+ .where(({ ref }) => orgUsable(t, orgId, ref("id")))
180
+ .execute()).map((item) => item.id));
181
+ const followsBundle = (name) => {
182
+ const path = pluginPathItem(items.get(name), required.has(name));
183
+ return path === null ? null : usable.has(path);
184
+ };
185
+ const seen = (name) => {
186
+ if (required.has(name))
187
+ return true;
188
+ const sources = items.get(name);
189
+ return (sources === undefined ||
190
+ (sources.some((source) => shown.has(source.id)) &&
191
+ (enabled.has(name) || sources.every((source) => !source.disabled))));
192
+ };
185
193
  const views = loaded
186
194
  .filter((m) => seen(m.name))
187
- .map((m) => this.view(m, rows.find((r) => r.plugin === m.name), required.has(m.name), items.get(m.name), on.has(m.name), live));
195
+ .map((m) => this.view(m, enabled.has(m.name), required.has(m.name), items.get(m.name), followsBundle(m.name), shown));
188
196
  const names = new Set(loaded.map((m) => m.name));
189
197
  const unavailable = installed
190
198
  .filter((i) => !names.has(i.name) && seen(i.name))
@@ -192,7 +200,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
192
200
  .map((i) => ({
193
201
  plugin: i.name,
194
202
  version: i.version,
195
- enabled: on.has(i.name) || (rows.find((r) => r.plugin === i.name)?.enabled ?? false),
203
+ enabled: enabled.has(i.name),
196
204
  configurable: false,
197
205
  permissions: [],
198
206
  available: false,
@@ -200,8 +208,8 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
200
208
  status: "converging",
201
209
  reason: "loading",
202
210
  required: required.has(i.name),
203
- ...scopeFields(items.get(i.name), required.has(i.name)),
204
- pluginInstall: pluginInstallOf(items.get(i.name), required.has(i.name), live),
211
+ ...scopeFields(items.get(i.name), required.has(i.name), shown),
212
+ pluginUsable: followsBundle(i.name),
205
213
  overrideState: "none",
206
214
  needsConfig: false,
207
215
  }));
@@ -211,9 +219,9 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
211
219
  * How an `enabled` write of this extension in the org is handled, read before the write (the
212
220
  * Platform tool's precheck; {@link put} repeats every rule under the org row lock): `direct`, a
213
221
  * write of the extension's own switch (a required bootstrap plugin keeps `extension.required`;
214
- * the plugin stays installed either way, extension switch spec 2026-12-02 §3.1), `locked` (a live
222
+ * the bundle keeps its intent either way, extension switch spec 2026-12-02 §3.1), `locked` (a live
215
223
  * item is builtin and the write switches off: `plugin.scope_locked`), or `not_installed` (switching
216
- * on an extension whose plugin is not installed in the org: `extension.plugin_not_installed`).
224
+ * on an extension whose plugin is off in the org: `extension.plugin_not_installed`).
217
225
  */
218
226
  async switchPlan(orgId, plugin, enabled) {
219
227
  const t = this.db;
@@ -228,7 +236,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
228
236
  const itemId = pluginPathItem(items, required);
229
237
  if (!enabled || itemId === null)
230
238
  return { kind: "direct" };
231
- return (await liveInstalledItems(t, orgId)).has(itemId)
239
+ return (await pluginUsable(t, orgId, itemId))
232
240
  ? { kind: "direct" }
233
241
  : { kind: "not_installed", itemId };
234
242
  }
@@ -238,7 +246,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
238
246
  * - Extension not loaded -> `extension.not_found`; `enabled: false` for a required bootstrap
239
247
  * plugin -> `extension.required` (it stays enabled in every org).
240
248
  * - Switches the extension only, never its plugin (extension switch spec 2026-12-02 §3.1): with a
241
- * plugin path ({@link pluginPathItem}) switching on needs the plugin installed in the org
249
+ * plugin path ({@link pluginPathItem}) switching on needs the plugin usable in the org
242
250
  * (`extension.plugin_not_installed`; the install itself passes `viaItem`), and switching off an
243
251
  * extension that is off already while its plugin is not installed writes nothing.
244
252
  * - Enabling never checks a config: an extension whose effective config is not valid for the org
@@ -254,46 +262,44 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
254
262
  async write(orgId, plugin, manifest, input, actorAccountId, actorTokenId, opts) {
255
263
  const t = this.db;
256
264
  await this.orgLock.lockFor(orgId, actorAccountId, "org.extensions.manage");
257
- const row = await t
258
- .selectFrom("extension_org_configs")
259
- .select(["enabled"])
260
- .where("plugin", "=", plugin)
261
- .where("org_id", "=", orgId)
262
- .executeTakeFirst();
265
+ if (opts.viaItem === undefined)
266
+ await this.installLock.shared(plugin);
267
+ const row = await extensionSwitch(t, orgId, plugin).executeTakeFirst();
263
268
  const required = (await requiredExtensions(t)).has(plugin);
264
- // Always on (required, or its plugin is builtin): enabled in every org (enabled.ts)
265
- const on = required || (await alwaysOnExtensions(t)).has(plugin);
269
+ const locked = required || (await alwaysOnExtensions(t)).has(plugin);
266
270
  const item = (await pluginItemsOf(t, [plugin])).get(plugin);
271
+ const before = await isExtensionEnabled(t, orgId, plugin);
267
272
  if (required && input.enabled === false)
268
273
  throw requiredError(plugin);
269
- if (on && input.enabled === false)
274
+ if (locked && input.enabled === false)
270
275
  throw scopeLockedError();
271
- // The org's live installs matter only to an extension with a plugin path
272
276
  const pathItem = pluginPathItem(item, required);
273
- const live = pathItem === null ? new Set() : await liveInstalledItems(t, orgId);
274
- if (opts.ifDisabled && (row?.enabled === true || on)) {
275
- opts.ifDisabled.skipped = true;
276
- return this.view(manifest, row, required, item, on, live);
277
+ const bundleUsable = pathItem === null ? null : await pluginUsable(t, orgId, pathItem);
278
+ const snapshot = () => this.view(manifest, before, required, item, bundleUsable);
279
+ if (opts.viaItem !== undefined) {
280
+ // A bundle applies effects. The org's extension choice belongs to its own switch.
281
+ if (locked || pathItem !== opts.viaItem || row?.enabled === false) {
282
+ if (opts.ifDisabled)
283
+ opts.ifDisabled.skipped = true;
284
+ return snapshot();
285
+ }
286
+ await this.assertSwitchRules(t, orgId, manifest, input, before, locked, opts);
287
+ await oweTemplateConnectors(this.outbox, t, orgId);
288
+ return snapshot();
277
289
  }
278
- // Not the install itself (`viaItem`): a plugin path needs the plugin installed here
279
- if (opts.viaItem === undefined && !on && pathItem !== null && !live.has(pathItem)) {
290
+ if (input.enabled === true && !before && (item ?? []).some((source) => source.disabled)) {
291
+ throw pluginItemDisabled([plugin]);
292
+ }
293
+ if (!locked && pathItem !== null && !before && bundleUsable === false) {
280
294
  if (input.enabled === true)
281
295
  throw await pluginNotInstalledError(t, plugin, pathItem);
282
- if (row?.enabled !== true)
283
- return this.view(manifest, row, required, item, on, live);
296
+ return snapshot();
284
297
  }
285
- // An always-on extension is enabled whatever the row said (it may predate `required` / builtin)
286
- const enabled = on || (input.enabled ?? row?.enabled ?? false);
287
- await this.assertSwitchRules(t, orgId, manifest, input, row, on, opts);
288
- await t
289
- .insertInto("extension_org_configs")
290
- .values({ plugin, org_id: orgId, enabled, updated_by: actorAccountId })
291
- .onConflict((oc) => oc.columns(["plugin", "org_id"]).doUpdateSet({
292
- enabled,
293
- updated_by: actorAccountId,
294
- updated_at: new Date(),
295
- }))
296
- .execute();
298
+ if (input.enabled === undefined || locked)
299
+ return snapshot();
300
+ await this.assertSwitchRules(t, orgId, manifest, input, before, locked, opts);
301
+ await writeComponentSwitch(t, { kind: "extension", id: plugin }, orgId, input.enabled, actorAccountId);
302
+ const enabled = await isExtensionEnabled(t, orgId, plugin);
297
303
  if (!enabled) {
298
304
  await revokeSiteGrantsOfExtension(t, { orgId, extensionName: plugin });
299
305
  // its host services on the org's machines stop (local agents spec, call 5)
@@ -302,7 +308,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
302
308
  // Switched on: it may provide the connector kind of a template whose plugin is installed in
303
309
  // the org without its connector; a worker creates the connectors it never had, once the
304
310
  // extension is loaded there (ruling R27)
305
- if (input.enabled === true && row?.enabled !== true) {
311
+ if (enabled && !before) {
306
312
  await oweTemplateConnectors(this.outbox, t, orgId);
307
313
  }
308
314
  await audit(t, {
@@ -317,7 +323,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
317
323
  ...opts.auditDetail,
318
324
  },
319
325
  });
320
- const view = this.view(manifest, { enabled }, required, item, on, live);
326
+ const view = this.view(manifest, enabled, required, item, bundleUsable);
321
327
  // Only once the root transaction committed (an outer caller's too): a rolled-back write
322
328
  // disconnects nothing
323
329
  afterCommit(async () => {
@@ -330,14 +336,14 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
330
336
  * re-checks the item policy and grants (C22; one already enabled is unaffected), enabling needs
331
337
  * the dependencies enabled, disabling (without `force`) no enabled dependents.
332
338
  */
333
- async assertSwitchRules(t, orgId, manifest, input, row, alwaysOn, opts) {
339
+ async assertSwitchRules(t, orgId, manifest, input, enabledBefore, alwaysOn, opts) {
334
340
  const plugin = manifest.name;
335
- if (input.enabled === true && row?.enabled !== true && !alwaysOn) {
336
- // 插件自己的条目 disabled 是总开关,任何途径都不能新启用(裁决 M-5)
341
+ if (input.enabled === true && !enabledBefore && !alwaysOn) {
342
+ // Deployment disable prevents every new enable (ruling M-5).
337
343
  const killed = await disabledPluginItems(t, [plugin]);
338
344
  if (killed.length > 0)
339
345
  throw pluginItemDisabled(killed);
340
- // 经某个条目安装:只看该条目(应用里的插件按应用条目,C22);直接启用:全部来源里最严格的生效
346
+ // Bundle installs use that source's policy. Direct enables enforce every source's policy.
341
347
  if (opts.viaItem !== undefined) {
342
348
  await assertItemInstallable(t, orgId, opts.viaItem, opts.approvedBy ?? opts.viaItem);
343
349
  }
@@ -351,24 +357,18 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
351
357
  }
352
358
  }
353
359
  /**
354
- * Whether `plugin` is enabled in the org: an always-on extension (a required bootstrap plugin, or
355
- * its plugin is builtin: `enabled.ts`) is enabled without a row; no row otherwise -> undefined.
360
+ * The extension's committed intent in the org; absent when it is off and has no explicit switch.
356
361
  * Inside a caller's transaction it reads in that transaction (it sees the caller's uncommitted
357
362
  * writes). The extension's config for the org is its effective config ({@link EffectiveConfigs}).
358
363
  */
359
364
  async get(orgId, plugin) {
360
365
  this.manifest(plugin);
361
366
  const t = this.db;
362
- const row = await t
363
- .selectFrom("extension_org_configs")
364
- .select(["enabled"])
365
- .where("plugin", "=", plugin)
366
- .where("org_id", "=", orgId)
367
- .executeTakeFirst();
368
- const on = (await alwaysOnExtensions(t)).has(plugin);
369
- if (!row && !on)
370
- return undefined;
371
- return { enabled: on || row?.enabled === true };
367
+ const enabled = await isExtensionEnabled(t, orgId, plugin);
368
+ if (enabled)
369
+ return { enabled };
370
+ const row = await extensionSwitch(t, orgId, plugin).executeTakeFirst();
371
+ return row === undefined ? undefined : { enabled };
372
372
  }
373
373
  /**
374
374
  * 该组织里已启用、且所 requires 的按组织启用的能力只剩这个插件提供的插件(停用它会让它们失去依赖)。
@@ -399,23 +399,16 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
399
399
  return [...out].sort();
400
400
  }
401
401
  /**
402
- * 在调用方事务里停用(应用安装的回滚与卸载用;调用方已锁组织行并复核角色):不检查依赖方,配置保留,
403
- * 审计 `org.plugin_config.updated`(带 reason)。提交后调用方须再调 {@link afterDisable}。
402
+ * Stops the extension during bundle rollback or uninstall under the caller's org lock and
403
+ * authorization. It keeps configuration, skips dependent checks and audits the reason.
404
+ * The caller invokes {@link afterDisable} after commit.
404
405
  */
405
406
  async disableIn(orgId, plugin, actorAccountId, reason) {
406
407
  const t = this.db;
407
- // An always-on extension (required, or its plugin is builtin) stays enabled in every org
408
- if ((await alwaysOnExtensions(t)).has(plugin))
408
+ if (await isExtensionEnabled(t, orgId, plugin))
409
409
  return false;
410
- const r = await t
411
- .updateTable("extension_org_configs")
412
- .set({ enabled: false, updated_by: actorAccountId, updated_at: new Date() })
413
- .where("plugin", "=", plugin)
414
- .where("org_id", "=", orgId)
415
- .where("enabled", "=", true)
416
- .returning("plugin")
417
- .executeTakeFirst();
418
- if (!r)
410
+ const row = await extensionSwitch(t, orgId, plugin).executeTakeFirst();
411
+ if (row?.enabled === false)
419
412
  return false;
420
413
  await revokeSiteGrantsOfExtension(t, { orgId, extensionName: plugin });
421
414
  await oweHostServicesStop(t, this.outbox, { orgId, extension: plugin });
@@ -497,23 +490,19 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
497
490
  throw new ApiError("extension.not_found", `Extension ${plugin} is not installed`);
498
491
  return set;
499
492
  }
500
- view(m, row, required, items,
501
- /** Always on in every org (enabled.ts): required, or its plugin is builtin. */
502
- alwaysOn,
503
- /** The items with a live install in the org ({@link liveInstalledItems}). */
504
- liveItems) {
493
+ view(m, enabled, required, items, bundleUsable, seen) {
505
494
  const configurable = [...fieldLevels(m.config?.deployment).values()].includes("override");
506
495
  return {
507
496
  plugin: m.name,
508
497
  version: m.version,
509
- enabled: alwaysOn || (row?.enabled ?? false),
498
+ enabled,
510
499
  configurable,
511
500
  permissions: permissionGroups(this.permissionsOf(m.name)),
512
501
  available: true,
513
502
  status: "enabled",
514
503
  required,
515
- ...scopeFields(items, required),
516
- pluginInstall: pluginInstallOf(items, required, liveItems),
504
+ ...scopeFields(items, required, seen),
505
+ pluginUsable: bundleUsable,
517
506
  // filled in by `withLayers` (the copy rows and the effective config)
518
507
  overrideState: configurable ? "following" : "none",
519
508
  needsConfig: false,
@@ -538,20 +527,21 @@ __decorate([
538
527
  ], OrgExtensionConfigs.prototype, "disableIn", null);
539
528
  OrgExtensionConfigs = __decorate([
540
529
  Injectable(),
541
- __param(0, Inject(KernelDb)),
542
- __param(1, Inject(TransactionHost)),
543
- __param(2, Inject(ExtensionHost)),
544
- __param(3, Inject(OrgLock)),
545
- __param(4, Inject(ExtensionInstalls)),
546
- __param(5, Inject(KernelEvents)),
547
- __param(6, Inject(EffectiveConfigs)),
548
- __param(7, Inject(ExtensionAvailability)),
549
- __param(8, Inject(OutboxService))
530
+ __param(0, Inject(PluginInstallLock)),
531
+ __param(1, Inject(KernelDb)),
532
+ __param(2, Inject(TransactionHost)),
533
+ __param(3, Inject(ExtensionHost)),
534
+ __param(4, Inject(OrgLock)),
535
+ __param(5, Inject(ExtensionInstalls)),
536
+ __param(6, Inject(KernelEvents)),
537
+ __param(7, Inject(EffectiveConfigs)),
538
+ __param(8, Inject(ExtensionAvailability)),
539
+ __param(9, Inject(OutboxService))
550
540
  ], OrgExtensionConfigs);
551
541
  export { OrgExtensionConfigs };
552
542
  /**
553
543
  * Whether the org may see `plugin` (a required bootstrap plugin always; else under its catalog
554
- * items' scope; the list also hides one off here whose item is disabled, {@link offeredToOrg}).
544
+ * items' visibility).
555
545
  * `db` may be a transaction.
556
546
  */
557
547
  export async function extensionVisibleTo(db, orgId, plugin) {
@@ -560,17 +550,12 @@ export async function extensionVisibleTo(db, orgId, plugin) {
560
550
  const items = (await pluginItemsOf(db, [plugin])).get(plugin);
561
551
  if (!items)
562
552
  return true;
563
- const listed = new Set((await db
564
- .selectFrom("catalog_item_scope_orgs")
565
- .select("item_id")
566
- .where("org_id", "=", orgId)
567
- .where("item_id", "in", items.map((i) => i.id))
568
- .execute()).map((r) => r.item_id));
569
- return itemsVisible(items, listed);
553
+ const visible = await itemsSeenBy(db, orgId, items.map((item) => item.id), "offered");
554
+ return visible.size > 0;
570
555
  }
571
556
  const scopeLockedError = () => new ApiError("plugin.scope_locked", "This plugin is built in: it is on for every organization and cannot be switched off here");
572
557
  /**
573
- * `extension.plugin_not_installed`: switching on an extension whose plugin is not installed in the
558
+ * `extension.plugin_not_installed`: switching on an extension whose plugin is off in the
574
559
  * org. Names the plugin (details `[{ itemId, plugin }]`). `db` may be a transaction.
575
560
  */
576
561
  export async function pluginNotInstalledError(db, extension, itemId) {
@@ -580,6 +565,6 @@ export async function pluginNotInstalledError(db, extension, itemId) {
580
565
  .where("id", "=", itemId)
581
566
  .executeTakeFirst();
582
567
  const name = item?.name ?? extension;
583
- return new ApiError("extension.plugin_not_installed", `Extension ${extension} comes with the plugin ${name}, which is not installed in this organization: enable the plugin ${name} on the Plugins page first`, [{ itemId, plugin: name }]);
568
+ return new ApiError("extension.plugin_not_installed", `Extension ${extension} comes with the plugin ${name}, which is off in this organization. Turn on ${name} on the Plugins page first`, [{ itemId, plugin: name }]);
584
569
  }
585
570
  const requiredError = (plugin) => new ApiError("extension.required", `Extension ${plugin} is required by this deployment (a bootstrap plugin): it is enabled in every organization and cannot be disabled`);
@@ -149,7 +149,7 @@ export interface AdminExtensionView {
149
149
  /** The scope of the catalog plugin the extension ships in (builtin: `all`); null without one. */
150
150
  scope: PluginScope | null;
151
151
  /** Orgs where the extension is enabled (a required plugin: every org). */
152
- enabledOrgs: number;
152
+ enabledOrgs?: number;
153
153
  /** Shipped with the deployment (a builtin plugin or a required bootstrap plugin). */
154
154
  builtin: boolean;
155
155
  /** Where the install record came from (`bootstrap` for the bootstrap step); null for config-declared. */
@@ -296,3 +296,8 @@ export interface PackageWarning {
296
296
  /** 语句(压成一行,字符串字面量已抹掉)。 */
297
297
  statement: string;
298
298
  }
299
+ export interface ExtensionOrgCounts {
300
+ name: string;
301
+ enabledOrgs: number;
302
+ orgsNeedingConfig?: number;
303
+ }
@@ -108,9 +108,10 @@ type VersionFile = {
108
108
  sha256: string;
109
109
  };
110
110
  /** The live items (with their latest version) by name or id. */
111
- declare function latestItems(db: KernelDb, by: "name" | "id", keys: string[]): Promise<{
112
- builtin: boolean;
113
- disabled: boolean;
111
+ declare function latestItems(db: KernelDb, by: "name" | "id", keys: string[], org?: {
112
+ orgId: string;
113
+ role: OrgRole;
114
+ }): Promise<{
114
115
  files: {
115
116
  path: string;
116
117
  size: number;
@@ -120,10 +121,6 @@ declare function latestItems(db: KernelDb, by: "name" | "id", keys: string[]): P
120
121
  latest_version: string;
121
122
  manifest: unknown;
122
123
  name: string;
123
- owner_org_id: string | null;
124
- scope: "all" | "named" | "optional";
125
- shareable: boolean;
126
- shown_to_others: boolean;
127
124
  }[]>;
128
125
  /** A live item with its latest version, as {@link PluginGuides} reads it. */
129
126
  export type ItemRow = Awaited<ReturnType<typeof latestItems>>[number];
@@ -137,7 +134,7 @@ export declare const templateGuideOf: (manifest: unknown, templateId: string) =>
137
134
  * catalog item (the item of the same name, its latest version), renders a guide document for a
138
135
  * place, audience, mode and target with the place's safe variables (`guide-places.ts`; never a
139
136
  * secret), and computes the drift hashes targets record to tell when an upgrade changed their
140
- * setup. Org reads follow the catalog icon's visibility ({@link orgVisibleItems}), the platform
137
+ * setup. Org reads follow the catalog icon's visibility ({@link orgSees}), the platform
141
138
  * preview any live item. Stateless: everything comes from PG (version rows, target rows, the
142
139
  * documents in `catalog_files`).
143
140
  */
@@ -147,8 +144,6 @@ export declare class PluginGuides {
147
144
  private readonly log;
148
145
  constructor(db: KernelDb, config: Pick<KernelConfigService, "get">, log: Pick<KernelLogger, "warn">);
149
146
  private latest;
150
- /** The rows the org's catalog shows ({@link orgVisibleItems}); all of them without an org. */
151
- private visibleTo;
152
147
  /** The English documents of guides, by `<itemId>/<guideId>` (one PG read); absent when not stored. */
153
148
  private englishSources;
154
149
  /** The admin drift hash of a guide for a mode. */