@capybara-hq/kernel 0.1.0-rc.36 → 0.1.0-rc.38

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 (351) hide show
  1. package/bootstrap.json +5 -5
  2. package/dist/admin/admin.module.d.ts +3 -2
  3. package/dist/admin/admin.module.js +9 -5
  4. package/dist/admin/audit-log.service.d.ts +51 -0
  5. package/dist/admin/{platform-audit.service.js → audit-log.service.js} +20 -12
  6. package/dist/admin/audit.controller.d.ts +18 -6
  7. package/dist/admin/audit.controller.js +36 -6
  8. package/dist/admin/audit.schemas.d.ts +9 -1
  9. package/dist/admin/audit.schemas.js +22 -2
  10. package/dist/admin/org-network.controller.d.ts +30 -0
  11. package/dist/admin/org-network.controller.js +77 -0
  12. package/dist/admin/org-network.schemas.d.ts +16 -0
  13. package/dist/admin/org-network.schemas.js +27 -0
  14. package/dist/admin/org-network.service.d.ts +41 -0
  15. package/dist/admin/org-network.service.js +101 -0
  16. package/dist/admin/outbox-dead.controller.d.ts +4 -6
  17. package/dist/admin/outbox-dead.controller.js +9 -6
  18. package/dist/admin/outbox-dead.schemas.d.ts +16 -0
  19. package/dist/admin/outbox-dead.schemas.js +25 -1
  20. package/dist/admin/outbox-dead.service.d.ts +16 -7
  21. package/dist/admin/outbox-dead.service.js +34 -10
  22. package/dist/admin/overview.service.d.ts +3 -3
  23. package/dist/admin/overview.service.js +0 -1
  24. package/dist/agents/agent-lookup.js +2 -10
  25. package/dist/agents/agents.service.js +9 -20
  26. package/dist/agents/definition.d.ts +3 -51
  27. package/dist/agents/definition.js +4 -254
  28. package/dist/agents/org-templates.js +2 -6
  29. package/dist/agents/readiness.controller.d.ts +4 -12
  30. package/dist/agents/readiness.controller.js +4 -12
  31. package/dist/agents/readiness.service.d.ts +23 -11
  32. package/dist/agents/readiness.service.js +31 -14
  33. package/dist/agents/templates.d.ts +0 -6
  34. package/dist/agents/templates.js +8 -34
  35. package/dist/background/store.d.ts +2 -0
  36. package/dist/background/store.js +3 -1
  37. package/dist/background/wake-rules.js +2 -1
  38. package/dist/catalog/admin-catalog.controller.d.ts +1 -2
  39. package/dist/catalog/admin-catalog.controller.js +1 -2
  40. package/dist/catalog/appearance.service.js +1 -3
  41. package/dist/catalog/catalog-content.d.ts +1 -1
  42. package/dist/catalog/catalog-content.js +1 -4
  43. package/dist/catalog/catalog-items.js +3 -3
  44. package/dist/catalog/catalog-scope.service.d.ts +10 -28
  45. package/dist/catalog/catalog-scope.service.js +22 -73
  46. package/dist/catalog/cli.d.ts +0 -11
  47. package/dist/catalog/cli.js +0 -20
  48. package/dist/catalog/component-scope.service.js +0 -2
  49. package/dist/catalog/component-state.js +2 -2
  50. package/dist/catalog/install-status.d.ts +6 -0
  51. package/dist/catalog/install-status.js +6 -0
  52. package/dist/catalog/job-ids.d.ts +0 -4
  53. package/dist/catalog/job-ids.js +0 -4
  54. package/dist/catalog/marketplaces.service.d.ts +1 -1
  55. package/dist/catalog/org-catalog.service.d.ts +2 -0
  56. package/dist/catalog/org-catalog.service.js +8 -3
  57. package/dist/catalog/org-extension-switch.d.ts +7 -2
  58. package/dist/catalog/org-extension-switch.js +56 -9
  59. package/dist/catalog/org-plugin-uploads.d.ts +6 -15
  60. package/dist/catalog/org-plugin-uploads.js +9 -27
  61. package/dist/catalog/owned-items.js +1 -3
  62. package/dist/catalog/platform-import-update.js +1 -1
  63. package/dist/catalog/plugin-import.d.ts +15 -13
  64. package/dist/catalog/plugin-import.js +21 -30
  65. package/dist/catalog/plugin-install.d.ts +3 -43
  66. package/dist/catalog/plugin-install.js +8 -150
  67. package/dist/catalog/plugin-package.d.ts +5 -10
  68. package/dist/catalog/plugin-package.js +12 -33
  69. package/dist/catalog/plugin-upgrade.js +5 -4
  70. package/dist/catalog/scope-jobs.d.ts +34 -34
  71. package/dist/catalog/scope-jobs.js +50 -37
  72. package/dist/catalog/scope-orgs.d.ts +1 -1
  73. package/dist/catalog/scope-orgs.js +1 -2
  74. package/dist/catalog/scope-sync-workers.d.ts +4 -3
  75. package/dist/catalog/scope-sync-workers.js +18 -6
  76. package/dist/catalog/scope-sync.d.ts +56 -59
  77. package/dist/catalog/scope-sync.js +96 -166
  78. package/dist/catalog/unshare.d.ts +3 -4
  79. package/dist/catalog/unshare.js +5 -8
  80. package/dist/channels/job-ids.d.ts +2 -6
  81. package/dist/channels/job-ids.js +2 -6
  82. package/dist/channels/outbound.d.ts +1 -1
  83. package/dist/channels/outbound.js +1 -1
  84. package/dist/channels/supervisor.d.ts +2 -3
  85. package/dist/channels/supervisor.js +2 -3
  86. package/dist/client/client-access.service.js +1 -1
  87. package/dist/config/env.js +19 -1
  88. package/dist/config/load.d.ts +0 -6
  89. package/dist/config/load.js +8 -27
  90. package/dist/config/schema.d.ts +54 -47
  91. package/dist/config/schema.js +198 -42
  92. package/dist/conversations/attachments.service.d.ts +10 -3
  93. package/dist/conversations/attachments.service.js +49 -16
  94. package/dist/conversations/conversations.controller.d.ts +0 -39
  95. package/dist/conversations/conversations.controller.js +0 -39
  96. package/dist/conversations/event-log.js +4 -1
  97. package/dist/conversations/events.d.ts +71 -46
  98. package/dist/conversations/events.js +124 -112
  99. package/dist/conversations/media-types.d.ts +25 -0
  100. package/dist/conversations/media-types.js +38 -0
  101. package/dist/conversations/queue.d.ts +3 -1
  102. package/dist/conversations/queue.service.js +9 -2
  103. package/dist/conversations/titles.js +6 -0
  104. package/dist/ctx/create-ctx.d.ts +8 -1
  105. package/dist/ctx/create-ctx.js +13 -3
  106. package/dist/ctx/net.d.ts +50 -0
  107. package/dist/ctx/net.js +67 -0
  108. package/dist/ctx/secrets.d.ts +24 -7
  109. package/dist/ctx/secrets.js +97 -30
  110. package/dist/db/kernel-schema.d.ts +27 -6
  111. package/dist/devices/devices.service.js +2 -1
  112. package/dist/errors.d.ts +10 -2
  113. package/dist/errors.js +10 -2
  114. package/dist/evals/reconstruct.d.ts +4 -17
  115. package/dist/evals/reconstruct.js +13 -53
  116. package/dist/evals/recorded-tools.d.ts +0 -27
  117. package/dist/evals/recorded-tools.js +2 -92
  118. package/dist/evals/run-replay.d.ts +1 -6
  119. package/dist/evals/run-replay.js +10 -17
  120. package/dist/evals/sets.service.d.ts +17 -5
  121. package/dist/evals/sets.service.js +33 -12
  122. package/dist/evals/snapshot.d.ts +1 -2
  123. package/dist/evals/snapshot.js +4 -17
  124. package/dist/extensions/admin-ops.d.ts +6 -1
  125. package/dist/extensions/admin-ops.js +17 -4
  126. package/dist/extensions/admin-view.d.ts +7 -4
  127. package/dist/extensions/admin-view.js +27 -21
  128. package/dist/extensions/bootstrap.js +0 -1
  129. package/dist/extensions/cli.js +0 -1
  130. package/dist/extensions/extensions.module.js +3 -0
  131. package/dist/extensions/host.d.ts +9 -4
  132. package/dist/extensions/host.js +14 -8
  133. package/dist/extensions/installs.d.ts +1 -3
  134. package/dist/extensions/instance.d.ts +0 -2
  135. package/dist/extensions/instance.js +0 -3
  136. package/dist/extensions/org-config.d.ts +4 -4
  137. package/dist/extensions/org-config.js +13 -22
  138. package/dist/extensions/package.d.ts +6 -6
  139. package/dist/extensions/package.js +3 -7
  140. package/dist/extensions/permission-view.d.ts +2 -4
  141. package/dist/extensions/plugin-items.d.ts +21 -1
  142. package/dist/extensions/plugin-items.js +28 -0
  143. package/dist/extensions/sync.js +5 -10
  144. package/dist/extensions/unavailable.js +0 -1
  145. package/dist/http/api.module.js +4 -1
  146. package/dist/identity/audit.d.ts +0 -12
  147. package/dist/identity/audit.js +0 -27
  148. package/dist/identity/auth.controller.js +5 -9
  149. package/dist/identity/cookies.d.ts +4 -9
  150. package/dist/identity/cookies.js +8 -32
  151. package/dist/identity/initial-passwords.d.ts +1 -1
  152. package/dist/identity/initial-passwords.js +1 -2
  153. package/dist/identity/sessions.d.ts +0 -6
  154. package/dist/identity/sessions.js +0 -18
  155. package/dist/inbox/platform-inbox.service.d.ts +33 -1
  156. package/dist/inbox/platform-inbox.service.js +56 -6
  157. package/dist/index.d.ts +4 -2
  158. package/dist/index.js +4 -2
  159. package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
  160. package/dist/infra/cli/master-key-rewrap.js +24 -0
  161. package/dist/infra/config/kernel-config.service.js +0 -17
  162. package/dist/infra/database/transaction-host.d.ts +32 -1
  163. package/dist/infra/database/transaction-host.js +30 -4
  164. package/dist/infra/database/xact-lock.d.ts +16 -0
  165. package/dist/infra/database/xact-lock.js +28 -1
  166. package/dist/infra/health/health.controller.js +8 -0
  167. package/dist/infra/health/process-fault.d.ts +16 -0
  168. package/dist/infra/health/process-fault.js +49 -0
  169. package/dist/infra/lifecycle/process-guards.d.ts +8 -2
  170. package/dist/infra/lifecycle/process-guards.js +12 -3
  171. package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
  172. package/dist/infra/lifecycle/shutdown-signals.js +28 -13
  173. package/dist/infra/outbox/outbox.service.d.ts +12 -9
  174. package/dist/infra/outbox/outbox.service.js +22 -26
  175. package/dist/infra/outbox/registry.d.ts +15 -7
  176. package/dist/infra/outbox/registry.js +39 -23
  177. package/dist/lifecycle/kernel-lifecycle.js +1 -7
  178. package/dist/models/enablement.d.ts +5 -6
  179. package/dist/models/enablement.js +7 -14
  180. package/dist/net/public-address.d.ts +21 -1
  181. package/dist/net/public-address.js +56 -10
  182. package/dist/net/safe-fetch.d.ts +4 -1
  183. package/dist/net/safe-fetch.js +15 -4
  184. package/dist/orgs/directory-sync.js +2 -0
  185. package/dist/orgs/members.service.js +5 -0
  186. package/dist/orgs/network-allowances.service.d.ts +79 -0
  187. package/dist/orgs/network-allowances.service.js +371 -0
  188. package/dist/orgs/offboarding.d.ts +3 -1
  189. package/dist/orgs/offboarding.js +9 -2
  190. package/dist/orgs/org-lock.d.ts +28 -2
  191. package/dist/orgs/org-lock.js +59 -4
  192. package/dist/orgs/orgs.controller.d.ts +11 -2
  193. package/dist/orgs/orgs.controller.js +19 -3
  194. package/dist/orgs/orgs.module.d.ts +3 -2
  195. package/dist/orgs/orgs.module.js +6 -2
  196. package/dist/orgs/orgs.schemas.d.ts +12 -0
  197. package/dist/orgs/orgs.schemas.js +5 -0
  198. package/dist/orgs/orgs.service.js +6 -1
  199. package/dist/orgs/settings.controller.d.ts +3 -2
  200. package/dist/orgs/settings.service.d.ts +59 -14
  201. package/dist/orgs/settings.service.js +102 -20
  202. package/dist/overrides.d.ts +7 -7
  203. package/dist/overrides.js +4 -4
  204. package/dist/packages/tgz.d.ts +0 -2
  205. package/dist/packages/tgz.js +0 -2
  206. package/dist/platform/exclusions.js +0 -5
  207. package/dist/platform/operation.js +1 -1
  208. package/dist/platform/ops/admin.ops.d.ts +2 -2
  209. package/dist/platform/ops/admin.ops.js +9 -6
  210. package/dist/platform/ops/agents.ops.js +1 -1
  211. package/dist/platform/ops/connectors.ops.js +46 -1
  212. package/dist/platform/ops/evals.ops.js +1 -64
  213. package/dist/platform/ops/extensions-admin.ops.js +1 -1
  214. package/dist/platform/ops/inbox.ops.js +16 -3
  215. package/dist/platform/ops/org-plugins.ops.js +1 -1
  216. package/dist/platform/ops/orgs.ops.d.ts +11 -3
  217. package/dist/platform/ops/orgs.ops.js +139 -5
  218. package/dist/platform/ops/outbox.ops.js +5 -5
  219. package/dist/platform/route-schemas.js +3 -0
  220. package/dist/roles/worker-role.d.ts +2 -3
  221. package/dist/roles/worker-role.js +3 -13
  222. package/dist/runtime/checkpointer.d.ts +3 -0
  223. package/dist/runtime/checkpointer.js +7 -4
  224. package/dist/runtime/context/build.d.ts +56 -18
  225. package/dist/runtime/context/build.js +143 -50
  226. package/dist/runtime/context/compaction.d.ts +1 -3
  227. package/dist/runtime/context/compaction.js +42 -8
  228. package/dist/runtime/context/run-context.js +1 -2
  229. package/dist/runtime/context/skills.d.ts +27 -56
  230. package/dist/runtime/context/skills.js +42 -114
  231. package/dist/runtime/context/tool-changes.d.ts +3 -3
  232. package/dist/runtime/context/tool-changes.js +6 -16
  233. package/dist/runtime/hook-calls.d.ts +6 -6
  234. package/dist/runtime/hook-calls.js +7 -7
  235. package/dist/runtime/langgraph-loop.js +9 -3
  236. package/dist/runtime/maintenance.d.ts +3 -11
  237. package/dist/runtime/maintenance.js +5 -20
  238. package/dist/runtime/model-call.d.ts +5 -0
  239. package/dist/runtime/model-call.js +48 -36
  240. package/dist/runtime/providers.d.ts +33 -35
  241. package/dist/runtime/providers.js +64 -109
  242. package/dist/runtime/run-context.service.js +7 -22
  243. package/dist/runtime/run-deletion.d.ts +6 -0
  244. package/dist/runtime/run-deletion.js +39 -16
  245. package/dist/runtime/run-execution.d.ts +56 -3
  246. package/dist/runtime/run-execution.js +81 -11
  247. package/dist/runtime/run-finish.js +2 -1
  248. package/dist/runtime/run-liveness.d.ts +11 -0
  249. package/dist/runtime/run-liveness.js +19 -0
  250. package/dist/runtime/run-orphan-check.job.js +2 -1
  251. package/dist/runtime/run-queue.js +8 -16
  252. package/dist/runtime/run-worker.d.ts +2 -2
  253. package/dist/runtime/run-worker.js +8 -6
  254. package/dist/runtime/step-log.d.ts +5 -0
  255. package/dist/runtime/step-log.js +9 -4
  256. package/dist/runtime/subagents/definition.d.ts +16 -20
  257. package/dist/runtime/subagents/definition.js +27 -27
  258. package/dist/runtime/subagents/dispatch.d.ts +6 -2
  259. package/dist/runtime/subagents/dispatch.js +17 -3
  260. package/dist/runtime/subagents/org-agents.js +1 -2
  261. package/dist/runtime/subagents/preamble.d.ts +3 -2
  262. package/dist/runtime/subagents/preamble.js +3 -2
  263. package/dist/runtime/subagents/render.d.ts +1 -2
  264. package/dist/runtime/subagents/render.js +1 -2
  265. package/dist/runtime/subagents/skill-fork.d.ts +2 -4
  266. package/dist/runtime/subagents/template-skills.d.ts +47 -0
  267. package/dist/runtime/subagents/template-skills.js +76 -0
  268. package/dist/runtime/waits.js +3 -1
  269. package/dist/schedules/effective-settings.d.ts +9 -3
  270. package/dist/schedules/effective-settings.js +5 -4
  271. package/dist/schedules/fire.js +11 -0
  272. package/dist/schedules/scheduled-tasks.service.js +5 -0
  273. package/dist/schedules/unattended.d.ts +2 -0
  274. package/dist/schedules/unattended.js +6 -1
  275. package/dist/skills/agent-skills.service.js +1 -2
  276. package/dist/skills/catalog.d.ts +1 -3
  277. package/dist/skills/catalog.js +1 -3
  278. package/dist/skills/conversation-catalog.d.ts +1 -2
  279. package/dist/skills/conversation-catalog.js +1 -2
  280. package/dist/skills/usable.js +2 -3
  281. package/dist/storage/storage.service.js +9 -1
  282. package/dist/tools/approvals.service.js +2 -4
  283. package/dist/tools/builtin-names.d.ts +2 -9
  284. package/dist/tools/builtin-names.js +4 -13
  285. package/dist/tools/builtins/sandbox/bash.js +3 -3
  286. package/dist/tools/builtins/sandbox/common.d.ts +7 -13
  287. package/dist/tools/builtins/sandbox/common.js +8 -115
  288. package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
  289. package/dist/tools/builtins/sandbox/fetch-attachment.js +119 -0
  290. package/dist/tools/builtins/sandbox/glob.js +1 -3
  291. package/dist/tools/builtins/sandbox/grep.js +3 -5
  292. package/dist/tools/builtins/sandbox/index.d.ts +8 -5
  293. package/dist/tools/builtins/sandbox/index.js +10 -5
  294. package/dist/tools/builtins/sandbox/read.js +3 -2
  295. package/dist/tools/builtins/tool-search.d.ts +4 -7
  296. package/dist/tools/builtins/tool-search.js +6 -10
  297. package/dist/tools/connector-account-policies.d.ts +30 -3
  298. package/dist/tools/connector-account-policies.js +54 -7
  299. package/dist/tools/connector-content.js +1 -0
  300. package/dist/tools/connectors.controller.d.ts +24 -11
  301. package/dist/tools/connectors.controller.js +35 -6
  302. package/dist/tools/connectors.schemas.d.ts +14 -1
  303. package/dist/tools/connectors.schemas.js +14 -2
  304. package/dist/tools/connectors.service.d.ts +22 -0
  305. package/dist/tools/connectors.service.js +65 -6
  306. package/dist/tools/drift.d.ts +6 -2
  307. package/dist/tools/drift.js +10 -5
  308. package/dist/tools/git-push-policy.d.ts +4 -1
  309. package/dist/tools/git-push-policy.js +3 -1
  310. package/dist/tools/info.d.ts +1 -7
  311. package/dist/tools/info.js +5 -18
  312. package/dist/tools/job-ids.d.ts +0 -4
  313. package/dist/tools/job-ids.js +1 -6
  314. package/dist/tools/pipeline.d.ts +4 -10
  315. package/dist/tools/pipeline.js +17 -62
  316. package/dist/tools/policy.d.ts +6 -2
  317. package/dist/tools/policy.js +14 -12
  318. package/dist/tools/registry.js +1 -5
  319. package/dist/ui/views.d.ts +5 -5
  320. package/dist/ui/views.js +10 -16
  321. package/package.json +3 -3
  322. package/src/migrations/0137_audit_org_idx.sql +5 -0
  323. package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
  324. package/src/migrations/0139_retire_legacy_forms.sql +183 -0
  325. package/src/migrations/0140_retire_history_forms.sql +148 -0
  326. package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
  327. package/src/migrations/0142_backfill_event_fields.sql +74 -0
  328. package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
  329. package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
  330. package/src/migrations/0145_org_network_allowances.sql +12 -0
  331. package/dist/admin/platform-audit.service.d.ts +0 -41
  332. package/dist/conversations/job-ids.d.ts +0 -6
  333. package/dist/conversations/job-ids.js +0 -6
  334. package/dist/extensions/job-ids.d.ts +0 -6
  335. package/dist/extensions/job-ids.js +0 -6
  336. package/dist/infra/queue/retired-schedulers.d.ts +0 -7
  337. package/dist/infra/queue/retired-schedulers.js +0 -9
  338. package/dist/orgs/job-ids.d.ts +0 -8
  339. package/dist/orgs/job-ids.js +0 -8
  340. package/dist/runtime/context/legacy-text.d.ts +0 -22
  341. package/dist/runtime/context/legacy-text.js +0 -37
  342. package/dist/runtime/job-ids.d.ts +0 -10
  343. package/dist/runtime/job-ids.js +0 -10
  344. package/dist/runtime/retired-schedulers.d.ts +0 -7
  345. package/dist/runtime/retired-schedulers.js +0 -31
  346. package/dist/storage/job-ids.d.ts +0 -6
  347. package/dist/storage/job-ids.js +0 -6
  348. package/dist/tools/legacy-data.d.ts +0 -34
  349. package/dist/tools/legacy-data.js +0 -76
  350. package/dist/tools/legacy-keys.d.ts +0 -51
  351. package/dist/tools/legacy-keys.js +0 -114
@@ -11,6 +11,7 @@ import { SDK_VERSION } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
13
  import semver from "semver";
14
+ import { oweDeployedExtensionSync } from "../catalog/scope-jobs.js";
14
15
  import { pluginSchemaName } from "../ctx/create-ctx.js";
15
16
  import { ApiError } from "../errors.js";
16
17
  import { audit } from "../identity/audit.js";
@@ -20,6 +21,7 @@ import { afterCommit } from "../infra/database/after-commit.js";
20
21
  import { KernelDb } from "../infra/database/kernel-db.js";
21
22
  import { TransactionHost } from "../infra/database/transaction-host.js";
22
23
  import { Transactional } from "../infra/database/transactional.decorator.js";
24
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
23
25
  import { KERNEL_BUS, KERNEL_LOGGER } from "../infra/tokens.js";
24
26
  import { OrgLock } from "../orgs/org-lock.js";
25
27
  import { ExtensionAdmin } from "./admin-view.js";
@@ -44,6 +46,7 @@ let ExtensionAdminOps = class ExtensionAdminOps {
44
46
  lifecycle;
45
47
  log;
46
48
  singleProvider;
49
+ outbox;
47
50
  constructor(kdb, txHost,
48
51
  /** The super admin lock (identity/super-admin.ts): joins the transaction. */
49
52
  adminLock,
@@ -68,7 +71,9 @@ let ExtensionAdminOps = class ExtensionAdminOps {
68
71
  */
69
72
  lifecycle, log,
70
73
  /** One enabled provider per single-provider extension point (checked in the enable). */
71
- singleProvider) {
74
+ singleProvider,
75
+ /** The plugin scope sync a deploy owes (`oweDeployedExtensionSync`). */
76
+ outbox) {
72
77
  this.kdb = kdb;
73
78
  this.txHost = txHost;
74
79
  this.adminLock = adminLock;
@@ -82,6 +87,7 @@ let ExtensionAdminOps = class ExtensionAdminOps {
82
87
  this.lifecycle = lifecycle;
83
88
  this.log = log;
84
89
  this.singleProvider = singleProvider;
90
+ this.outbox = outbox;
85
91
  }
86
92
  get db() {
87
93
  return this.kdb.db;
@@ -136,8 +142,7 @@ let ExtensionAdminOps = class ExtensionAdminOps {
136
142
  throw new ApiError("extension.name_mismatch", `Package ${sha256} contains extension ${pkg.name}, not ${name}`);
137
143
  }
138
144
  // The downgrade check needs the target package's migration files: read and parse the package
139
- // outside the transaction (inside it only _migrations is compared). A stored package in the
140
- // pre-0.1.0 format -> extension.legacy_format.
145
+ // outside the transaction (inside it only _migrations is compared).
141
146
  const target = await readExtensionPackage(await this.blobs.get(sha256), {
142
147
  maxBytes: this.config.get().packages.maxBytes,
143
148
  hostSdkVersion: SDK_VERSION,
@@ -282,6 +287,9 @@ let ExtensionAdminOps = class ExtensionAdminOps {
282
287
  afterCommit(() => this.notify(name));
283
288
  if (leftDisabled !== undefined)
284
289
  return { changed: true, state: "disabled", leftDisabled };
290
+ // A new version of an enabled extension is a deploy: it owes its plugin's scope sync
291
+ if (row?.desired_state === "enabled")
292
+ await oweDeployedExtensionSync(this.outbox, db, name);
285
293
  return { changed: true, state: row?.desired_state ?? "disabled" };
286
294
  }
287
295
  /**
@@ -393,6 +401,10 @@ let ExtensionAdminOps = class ExtensionAdminOps {
393
401
  .execute();
394
402
  await this.audit(actor, actorTokenId, state === "enabled" ? "extension.enabled" : "extension.disabled", name, row.version, row.sha256, { ...ownerDetail(owner), ...auditDetail });
395
403
  afterCommit(() => this.notify(name));
404
+ // The enable is the deploy: it owes its plugin's scope sync, which installs it where its scope
405
+ // wants it on (a replica that has not loaded it yet retries)
406
+ if (state === "enabled")
407
+ await oweDeployedExtensionSync(this.outbox, db, name);
396
408
  return { row, changed: true };
397
409
  }
398
410
  /**
@@ -503,7 +515,8 @@ ExtensionAdminOps = __decorate([
503
515
  __param(9, Inject(KERNEL_BUS)),
504
516
  __param(10, Inject(ExtensionLifecycle)),
505
517
  __param(11, Inject(KERNEL_LOGGER)),
506
- __param(12, Inject(SingleProviderGuard))
518
+ __param(12, Inject(SingleProviderGuard)),
519
+ __param(13, Inject(OutboxService))
507
520
  ], ExtensionAdminOps);
508
521
  export { ExtensionAdminOps };
509
522
  /**
@@ -2,6 +2,7 @@ import { SuperAdminLock } from "../identity/super-admin.js";
2
2
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
3
3
  import { KernelDb } from "../infra/database/kernel-db.js";
4
4
  import { TransactionHost } from "../infra/database/transaction-host.js";
5
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
5
6
  import type { KernelLogger } from "../log.js";
6
7
  import { ExtensionApprovals } from "./approvals.js";
7
8
  import { ExtensionBlobs } from "./blobs.js";
@@ -55,6 +56,8 @@ export declare class ExtensionAdmin {
55
56
  private readonly singleProvider;
56
57
  /** The plugins' icons (admin catalog routes). */
57
58
  private readonly icons;
59
+ /** The plugin scope sync an approval of an enabled extension owes. */
60
+ private readonly outbox;
58
61
  private readonly packageSets;
59
62
  constructor(kdb: KernelDb, txHost: TransactionHost,
60
63
  /** The super admin lock (identity/super-admin.ts): joins the transaction. */
@@ -70,7 +73,9 @@ export declare class ExtensionAdmin {
70
73
  /** Which enabled extension keeps a disabled one from being enabled (`enableBlocked`). */
71
74
  singleProvider: SingleProviderGuard,
72
75
  /** The plugins' icons (admin catalog routes). */
73
- icons: PluginIcons);
76
+ icons: PluginIcons,
77
+ /** The plugin scope sync an approval of an enabled extension owes. */
78
+ outbox: Pick<OutboxService, "add">);
74
79
  private get db();
75
80
  /**
76
81
  * Every extension (config-declared, then install records, each by name). With `names`, only
@@ -82,9 +87,7 @@ export declare class ExtensionAdmin {
82
87
  * A single extension; unknown -> `extension.not_found`; package unreadable ->
83
88
  * `extension.package_unavailable`. With `allowUnreadable` an unreadable package returns the same
84
89
  * degraded item as {@link list} (status failed, with `error`): used after a write has committed, so
85
- * an operation that took effect is not reported as failed. A package in the pre-0.1.0 format is
86
- * a state, not an error: it always returns the item with status `legacy_format` (so the admin can
87
- * see it and uninstall it).
90
+ * an operation that took effect is not reported as failed.
88
91
  */
89
92
  get(name: string, opts?: {
90
93
  allowUnreadable?: boolean;
@@ -10,12 +10,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { SDK_VERSION } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
+ import { oweDeployedExtensionSync } from "../catalog/scope-jobs.js";
13
14
  import { ApiError } from "../errors.js";
14
15
  import { SuperAdminLock } from "../identity/super-admin.js";
15
16
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
16
17
  import { KernelDb } from "../infra/database/kernel-db.js";
17
18
  import { TransactionHost } from "../infra/database/transaction-host.js";
18
19
  import { Transactional } from "../infra/database/transactional.decorator.js";
20
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
19
21
  import { KERNEL_BUS, KERNEL_LOGGER } from "../infra/tokens.js";
20
22
  import { ExtensionApprovals, snapshotCovers, writeSnapshot, } from "./approvals.js";
21
23
  import { ExtensionBlobs } from "./blobs.js";
@@ -46,12 +48,10 @@ const EMPTY_SET = buildPermissionSet({
46
48
  tables: [],
47
49
  });
48
50
  /**
49
- * The package cannot be read -> `extension.package_unavailable`, or is in the pre-0.1.0 format ->
50
- * `extension.legacy_format` (details and approval cannot be based on an unreadable package).
51
+ * The package cannot be read -> `extension.package_unavailable` (details and approval cannot be
52
+ * based on an unreadable package).
51
53
  */
52
54
  function assertReadable(s) {
53
- if (s.legacy)
54
- throw new ApiError("extension.legacy_format", s.broken);
55
55
  if (s.broken !== undefined) {
56
56
  throw new ApiError("extension.package_unavailable", `The package of extension ${s.name} cannot be read: ${s.broken}`);
57
57
  }
@@ -78,6 +78,7 @@ let ExtensionAdmin = class ExtensionAdmin {
78
78
  effectiveConfigs;
79
79
  singleProvider;
80
80
  icons;
81
+ outbox;
81
82
  packageSets = new Map();
82
83
  constructor(kdb, txHost,
83
84
  /** The super admin lock (identity/super-admin.ts): joins the transaction. */
@@ -93,7 +94,9 @@ let ExtensionAdmin = class ExtensionAdmin {
93
94
  /** Which enabled extension keeps a disabled one from being enabled (`enableBlocked`). */
94
95
  singleProvider,
95
96
  /** The plugins' icons (admin catalog routes). */
96
- icons) {
97
+ icons,
98
+ /** The plugin scope sync an approval of an enabled extension owes. */
99
+ outbox) {
97
100
  this.kdb = kdb;
98
101
  this.txHost = txHost;
99
102
  this.adminLock = adminLock;
@@ -111,6 +114,7 @@ let ExtensionAdmin = class ExtensionAdmin {
111
114
  this.effectiveConfigs = effectiveConfigs;
112
115
  this.singleProvider = singleProvider;
113
116
  this.icons = icons;
117
+ this.outbox = outbox;
114
118
  }
115
119
  get db() {
116
120
  return this.kdb.db;
@@ -128,15 +132,13 @@ let ExtensionAdmin = class ExtensionAdmin {
128
132
  * A single extension; unknown -> `extension.not_found`; package unreadable ->
129
133
  * `extension.package_unavailable`. With `allowUnreadable` an unreadable package returns the same
130
134
  * degraded item as {@link list} (status failed, with `error`): used after a write has committed, so
131
- * an operation that took effect is not reported as failed. A package in the pre-0.1.0 format is
132
- * a state, not an error: it always returns the item with status `legacy_format` (so the admin can
133
- * see it and uninstall it).
135
+ * an operation that took effect is not reported as failed.
134
136
  */
135
137
  async get(name, opts = {}) {
136
138
  const s = (await this.subjects(name))[0];
137
139
  if (!s)
138
140
  throw new ApiError("extension.not_found", `Extension ${name} is not known to this deployment`);
139
- if (!opts.allowUnreadable && !s.legacy)
141
+ if (!opts.allowUnreadable)
140
142
  assertReadable(s);
141
143
  return (await this.views([s]))[0];
142
144
  }
@@ -200,16 +202,19 @@ let ExtensionAdmin = class ExtensionAdmin {
200
202
  const db = this.db;
201
203
  await this.adminLock.lockAndAuthorize(actor);
202
204
  await this.approveLock.lock(name);
205
+ // The install may have moved to another package since the review (an upgrade): re-checked
206
+ // under its row lock
207
+ let enabled = s.install === null;
203
208
  if (s.install !== null) {
204
- // 审阅之后安装记录可能已换包(T14 升级):锁行复核
205
209
  const row = await db
206
210
  .selectFrom("extension_installs")
207
- .select("sha256")
211
+ .select(["sha256", "desired_state"])
208
212
  .where("name", "=", name)
209
213
  .forUpdate()
210
214
  .executeTakeFirst();
211
215
  if (row?.sha256 !== s.install.sha256)
212
216
  throw stale();
217
+ enabled = row.desired_state === "enabled";
213
218
  }
214
219
  const snapRow = await db
215
220
  .selectFrom("extension_permission_snapshots")
@@ -233,6 +238,10 @@ let ExtensionAdmin = class ExtensionAdmin {
233
238
  ...(actorTokenId !== undefined && { actorTokenId }),
234
239
  audit: { added, removed, sha256: s.install?.sha256 ?? null },
235
240
  });
241
+ // Approving an enabled (or config-declared) extension lets replicas load it: a deploy, which
242
+ // owes its plugin's scope sync
243
+ if (enabled)
244
+ await oweDeployedExtensionSync(this.outbox, db, name);
236
245
  }
237
246
  /** 配置声明 → 安装记录(与配置声明重名的安装记录不生效,不单列)。`only` 给出时只取这一个。 */
238
247
  async subjects(only, names) {
@@ -261,16 +270,13 @@ let ExtensionAdmin = class ExtensionAdmin {
261
270
  }
262
271
  catch (err) {
263
272
  // One unreadable package (bytes missing / corrupt, over the current limit) does not break
264
- // the list: it becomes a failed item; a pre-0.1.0 package becomes a legacy_format item.
265
- const legacy = err instanceof ExtensionPackageError && err.code === "extension.legacy_format";
266
- const detail = legacy
267
- ? err.message
268
- : `package ${r.name} ${r.version} (${r.sha256}) cannot be read: ${err instanceof Error ? err.message : String(err)}`;
269
- // A pre-0.1.0 package is an expected state (repack needed), logged without a stack trace.
273
+ // the list: it becomes a failed item. An invalid package is an expected state (repack
274
+ // needed), logged without a stack trace.
275
+ const detail = `package ${r.name} ${r.version} (${r.sha256}) cannot be read: ${err instanceof Error ? err.message : String(err)}`;
270
276
  this.log.warn("plugin package unreadable for the admin view", {
271
277
  plugin: r.name,
272
278
  sha256: r.sha256,
273
- ...(legacy ? { reason: detail } : { err }),
279
+ ...(err instanceof ExtensionPackageError ? { reason: detail } : { err }),
274
280
  });
275
281
  out.push({
276
282
  name: r.name,
@@ -281,7 +287,6 @@ let ExtensionAdmin = class ExtensionAdmin {
281
287
  configurable: false,
282
288
  configValid: null,
283
289
  broken: detail,
284
- ...(legacy && { legacy }),
285
290
  warnings: [],
286
291
  });
287
292
  continue;
@@ -426,7 +431,7 @@ let ExtensionAdmin = class ExtensionAdmin {
426
431
  version: s.version,
427
432
  source: s.source,
428
433
  sha256: target,
429
- status: s.legacy ? "legacy_format" : "failed",
434
+ status: "failed",
430
435
  desired: install && {
431
436
  version: install.version,
432
437
  sha256: install.sha256,
@@ -598,7 +603,8 @@ ExtensionAdmin = __decorate([
598
603
  __param(13, Inject(ExtensionDeploymentConfigService)),
599
604
  __param(14, Inject(EffectiveConfigs)),
600
605
  __param(15, Inject(SingleProviderGuard)),
601
- __param(16, Inject(PluginIcons))
606
+ __param(16, Inject(PluginIcons)),
607
+ __param(17, Inject(OutboxService))
602
608
  ], ExtensionAdmin);
603
609
  export { ExtensionAdmin };
604
610
  const replicaView = (r) => ({
@@ -573,7 +573,6 @@ let BootstrapService = class BootstrapService {
573
573
  builtin: true,
574
574
  scope: "all",
575
575
  disabled: false,
576
- scope_version: sql `scope_version + 1`,
577
576
  ...touch,
578
577
  })
579
578
  .where("name", "=", name)
@@ -95,7 +95,6 @@ export async function openExtensionCli(config, log, opts = {}) {
95
95
  remember: (sha256, bytes) => blobs.remember(sha256, bytes),
96
96
  readPackage: (sha256) => blobs.get(sha256),
97
97
  async packageSet(sha256) {
98
- // a stored package in the pre-0.1.0 format -> extension.legacy_format
99
98
  const pkg = await readExtensionPackage(await blobs.get(sha256), {
100
99
  maxBytes: config.packages.maxBytes,
101
100
  hostSdkVersion: SDK_VERSION,
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Module } from "@nestjs/common";
8
8
  import { SuperAdminLockModule } from "../identity/super-admin.js";
9
9
  import { ModelsModule } from "../models/models.module.js";
10
+ import { OrgNetworkAllowancesModule } from "../orgs/network-allowances.service.js";
10
11
  import { OrgLockModule } from "../orgs/org-lock.js";
11
12
  import { StorageModule } from "../storage/storage.module.js";
12
13
  import { EmbedTokensModule } from "../ui/embed-token.js";
@@ -51,6 +52,8 @@ ExtensionsModule = __decorate([
51
52
  ModelsModule,
52
53
  // the lifecycle clears the `usage.report` subscriber cache on PLUGINS_CHANGED
53
54
  UsageSubscribersModule,
55
+ // ctx.net reads each org's allowed internal endpoints per call
56
+ OrgNetworkAllowancesModule,
54
57
  ],
55
58
  providers: [
56
59
  PluginInstallLock,
@@ -4,6 +4,7 @@ import type { core } from "zod";
4
4
  import type { KernelAppOptions } from "../app.js";
5
5
  import type { BusSubscriber } from "../ctx/bus.js";
6
6
  import { type Route } from "../ctx/create-ctx.js";
7
+ import { type ExtensionNetSeams } from "../ctx/net.js";
7
8
  import type { Keyring } from "../ctx/secrets.js";
8
9
  import type { PluginRouteTable } from "../http/plugin-dispatch.js";
9
10
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
@@ -11,6 +12,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
11
12
  import { LockService } from "../infra/lock/lock.service.js";
12
13
  import type { KernelLogger } from "../log.js";
13
14
  import { ModelEmbeddings } from "../models/embeddings.js";
15
+ import { OrgNetworkAllowances } from "../orgs/network-allowances.service.js";
14
16
  import { EmbedTokens } from "../ui/embed-token.js";
15
17
  import type { UiActionHandler, UiRender } from "../ui/registry.js";
16
18
  import { ExtensionApprovals, type PendingExtension } from "./approvals.js";
@@ -32,7 +34,7 @@ export { deploymentConfigHash };
32
34
  export interface LoadedUiContribution {
33
35
  plugin: string;
34
36
  contribution: UiContribution;
35
- /** The catalog slot the contribution resolved to (from `slot`, or the deprecated `place`). */
37
+ /** The catalog slot the contribution resolved to (from `slot`). */
36
38
  slot: UiSlotSpec;
37
39
  /** For a slot with anchors: the anchor it goes after (see `resolveUiSlots`). */
38
40
  after?: string;
@@ -264,7 +266,11 @@ export declare class ExtensionHost {
264
266
  */
265
267
  effective: Pick<EffectiveConfigs, "get">,
266
268
  /** `ctx.models`: the embeddings broker (spec B §5.4). */
267
- models: Pick<ModelEmbeddings, "embed" | "describe">);
269
+ models: Pick<ModelEmbeddings, "embed" | "describe">,
270
+ /** `ctx.net`: the internal endpoints each org's extension requests may reach (read per call). */
271
+ allowances: OrgNetworkAllowances,
272
+ /** Tests only: `ctx.net`'s DNS and dispatcher seams (`EXTENSION_NET_SEAMS`). */
273
+ netSeams?: ExtensionNetSeams);
268
274
  /** The startup config's `extensionConfig` (file / Nacos merged with env). */
269
275
  private get extensionConfig();
270
276
  /** `extensionPermissions.autoApprove` (development and trials only; see `planApprovals`). */
@@ -371,8 +377,7 @@ export declare class ExtensionHost {
371
377
  * `permissionSetOfPackage` at review; the migrations directory comes only from
372
378
  * `extension.migrations`). Does not import the module: that happens after the permission gate
373
379
  * ({@link importInstalled}). A failure is recorded as failed (`sync_failed` / `sha_mismatch`, the
374
- * detail is the error message only, e.g. the legacy-format message for a pre-0.1.0 package) and
375
- * returns undefined. The result for a package never changes, so successes are cached by sha (a
380
+ * detail is the error message only) and returns undefined. The result for a package never changes, so successes are cached by sha (a
376
381
  * reconcile cycle does not unpack again).
377
382
  */
378
383
  private prepare;
@@ -12,9 +12,10 @@ import { createRequire } from "node:module";
12
12
  import { dirname, isAbsolute, join, resolve as resolvePath } from "node:path";
13
13
  import { fileURLToPath, pathToFileURL } from "node:url";
14
14
  import { EXTENSION_POINT_CARDINALITY, parseExtensionPoint, SDK_VERSION, } from "@capybara-hq/plugin-sdk";
15
- import { Inject, Injectable } from "@nestjs/common";
15
+ import { Inject, Injectable, Optional } from "@nestjs/common";
16
16
  import { changedPaths, configFields, secretValues, unreachableSecrets } from "../config/fields.js";
17
17
  import { pluginSchemaName, queryEnabledPlugins, } from "../ctx/create-ctx.js";
18
+ import { EXTENSION_NET_SEAMS } from "../ctx/net.js";
18
19
  import { kernelDb } from "../db/kernel-schema.js";
19
20
  import { migrate } from "../db/migrator.js";
20
21
  import { createDb } from "../db/pool.js";
@@ -25,6 +26,7 @@ import { LockService } from "../infra/lock/lock.service.js";
25
26
  import { KERNEL_LOGGER, KEYRING, REDIS, REDIS_SUBSCRIBER } from "../infra/tokens.js";
26
27
  import { KERNEL_APP_OPTIONS } from "../lifecycle/tokens.js";
27
28
  import { ModelEmbeddings } from "../models/embeddings.js";
29
+ import { OrgNetworkAllowances } from "../orgs/network-allowances.service.js";
28
30
  import { packagePath } from "../packages/tgz.js";
29
31
  import { EmbedTokens } from "../ui/embed-token.js";
30
32
  import { ExtensionApprovals, planApprovals, readSnapshots, withPreApproved, } from "./approvals.js";
@@ -411,7 +413,11 @@ let ExtensionHost = class ExtensionHost {
411
413
  */
412
414
  effective,
413
415
  /** `ctx.models`: the embeddings broker (spec B §5.4). */
414
- models) {
416
+ models,
417
+ /** `ctx.net`: the internal endpoints each org's extension requests may reach (read per call). */
418
+ allowances,
419
+ /** Tests only: `ctx.net`'s DNS and dispatcher seams (`EXTENSION_NET_SEAMS`). */
420
+ netSeams) {
415
421
  this.registry = registry;
416
422
  this.installs = installs;
417
423
  this.approvals = approvals;
@@ -442,6 +448,7 @@ let ExtensionHost = class ExtensionHost {
442
448
  models,
443
449
  // ctx.models.embed fires model.request through the same registry (spec B §5.4)
444
450
  hooks: this.hooks,
451
+ net: { config, allowances, ...(netSeams !== undefined && { seams: netSeams }) },
445
452
  locks,
446
453
  runWorkers: c.roles.includes("worker"),
447
454
  log,
@@ -950,8 +957,7 @@ let ExtensionHost = class ExtensionHost {
950
957
  * `permissionSetOfPackage` at review; the migrations directory comes only from
951
958
  * `extension.migrations`). Does not import the module: that happens after the permission gate
952
959
  * ({@link importInstalled}). A failure is recorded as failed (`sync_failed` / `sha_mismatch`, the
953
- * detail is the error message only, e.g. the legacy-format message for a pre-0.1.0 package) and
954
- * returns undefined. The result for a package never changes, so successes are cached by sha (a
960
+ * detail is the error message only) and returns undefined. The result for a package never changes, so successes are cached by sha (a
955
961
  * reconcile cycle does not unpack again).
956
962
  */
957
963
  async prepare(loader, d) {
@@ -1762,9 +1768,6 @@ let ExtensionHost = class ExtensionHost {
1762
1768
  if (inst.uiUnknownAnchors.length > 0) {
1763
1769
  this.log.warn("plugin ui anchors unknown", { ...at, anchors: inst.uiUnknownAnchors });
1764
1770
  }
1765
- if (inst.uiDeprecatedPlace.length > 0) {
1766
- this.log.info("plugin ui uses the deprecated place", { ...at, ids: inst.uiDeprecatedPlace });
1767
- }
1768
1771
  return inst;
1769
1772
  }
1770
1773
  /** 取能力实现:单选能力无需 providerName,多选能力必须指定。 */
@@ -2390,6 +2393,9 @@ ExtensionHost = __decorate([
2390
2393
  __param(11, Inject(KERNEL_LOGGER)),
2391
2394
  __param(12, Inject(KERNEL_APP_OPTIONS)),
2392
2395
  __param(13, Inject(EffectiveConfigs)),
2393
- __param(14, Inject(ModelEmbeddings))
2396
+ __param(14, Inject(ModelEmbeddings)),
2397
+ __param(15, Inject(OrgNetworkAllowances)),
2398
+ __param(16, Optional()),
2399
+ __param(16, Inject(EXTENSION_NET_SEAMS))
2394
2400
  ], ExtensionHost);
2395
2401
  export { ExtensionHost };
@@ -60,9 +60,7 @@ export interface DesiredExtension {
60
60
  */
61
61
  blobStore?: "object" | "pg";
62
62
  /**
63
- * The reviewed extension section of the plugin (the migrations path is taken only from here). A
64
- * row stored before 0.1.0 holds the old `capybara` section instead; its package is in the old
65
- * format and fails to sync with `extension.legacy_format`.
63
+ * The reviewed extension section of the plugin (the migrations path is taken only from here).
66
64
  */
67
65
  section: PluginExtensionSection;
68
66
  }
@@ -53,8 +53,6 @@ export declare class ExtensionInstance {
53
53
  id: string;
54
54
  after: string;
55
55
  }[];
56
- /** Ids of contributions that still name the deprecated `place`. */
57
- readonly uiDeprecatedPlace: string[];
58
56
  private hash;
59
57
  private readonly live;
60
58
  readonly entryUrl: string;
@@ -66,8 +66,6 @@ export class ExtensionInstance {
66
66
  uiDropped;
67
67
  /** `after` values that are not anchors of their slot (the contribution keeps the default position). */
68
68
  uiUnknownAnchors;
69
- /** Ids of contributions that still name the deprecated `place`. */
70
- uiDeprecatedPlace;
71
69
  hash;
72
70
  live;
73
71
  entryUrl;
@@ -89,7 +87,6 @@ export class ExtensionInstance {
89
87
  this.ui = ui.resolved;
90
88
  this.uiDropped = ui.dropped;
91
89
  this.uiUnknownAnchors = ui.unknownAnchors;
92
- this.uiDeprecatedPlace = ui.deprecatedPlace;
93
90
  this.hash = init.configHash;
94
91
  this.live = init.config;
95
92
  this.entryUrl = init.entryUrl;
@@ -1,4 +1,4 @@
1
- import { type PluginScope } from "../catalog/scope.js";
1
+ import type { PluginScope } from "../catalog/scope.js";
2
2
  import { type Keyring } from "../ctx/secrets.js";
3
3
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
4
4
  import { KernelDb } from "../infra/database/kernel-db.js";
@@ -266,8 +266,8 @@ export declare class OrgExtensionConfigs {
266
266
  private setSecretKeys;
267
267
  }
268
268
  /**
269
- * Whether the org sees `plugin` in its extension list (a required bootstrap plugin always; else
270
- * under its catalog items' scope, as {@link OrgExtensionConfigs.list} filters). `db` may be a
271
- * transaction.
269
+ * Whether the org may see `plugin` (a required bootstrap plugin always; else under its catalog
270
+ * items' scope; the list also hides one off here whose item is disabled, {@link offeredToOrg}).
271
+ * `db` may be a transaction.
272
272
  */
273
273
  export declare function extensionVisibleTo(db: KernelSchemaDb, orgId: string, plugin: string): Promise<boolean>;
@@ -10,7 +10,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { EXTENSION_POINTS, parseExtensionPoint, } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { assertItemInstallable, assertPluginSourcesInstallable, disabledPluginItems, pluginItemDisabled, } from "../catalog/request-rules.js";
13
- import { visibleTo } from "../catalog/scope.js";
14
13
  import { changedPaths, configFields, getPath, secretValues } from "../config/fields.js";
15
14
  import { createSecrets } from "../ctx/secrets.js";
16
15
  import { ApiError } from "../errors.js";
@@ -30,7 +29,7 @@ import { ExtensionHost } from "./host.js";
30
29
  import { ExtensionInstalls } from "./installs.js";
31
30
  import { fieldLevels } from "./org-levels.js";
32
31
  import { permissionGroups, } from "./permission-view.js";
33
- import { itemLocked, pluginItemsOf } from "./plugin-items.js";
32
+ import { itemLocked, itemsVisible, offeredToOrg, pluginItemsOf, scopeListedFor, } from "./plugin-items.js";
34
33
  import { ExtensionAvailability } from "./unavailable.js";
35
34
  export { toIssues };
36
35
  /** 内核自己的 secrets 命名空间(plugin-sdk 把 `kernel` 列为保留插件名,插件不会与之相撞)。 */
@@ -224,13 +223,15 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
224
223
  ...loaded.map((m) => m.name),
225
224
  ...installed.map((i) => i.name),
226
225
  ]);
227
- // An extension whose plugin the org is not offered (a `named` plugin without it) is absent
228
- const listed = new Set((await t
229
- .selectFrom("catalog_item_scope_orgs")
230
- .select("item_id")
231
- .where("org_id", "=", orgId)
232
- .execute()).map((r) => r.item_id));
233
- const seen = (name) => required.has(name) || itemsVisible(items.get(name), listed);
226
+ // An extension the org is not offered (a `named` plugin without it, or one off here whose
227
+ // item the super admin disabled) is absent: the rule readiness shares
228
+ const listed = await scopeListedFor(t, orgId);
229
+ const seen = (name) => offeredToOrg({
230
+ required: required.has(name),
231
+ enabled: rows.find((r) => r.plugin === name)?.enabled ?? false,
232
+ items: items.get(name),
233
+ listed,
234
+ });
234
235
  const views = loaded
235
236
  .filter((m) => seen(m.name))
236
237
  .map((m) => this.view(m, rows.find((r) => r.plugin === m.name), setKeys, required.has(m.name), items.get(m.name)));
@@ -722,19 +723,9 @@ OrgExtensionConfigs = __decorate([
722
723
  ], OrgExtensionConfigs);
723
724
  export { OrgExtensionConfigs };
724
725
  /**
725
- * Whether an org may see an extension with these live catalog items (`listed`: the items whose
726
- * `named` list has the org): one visible item is enough; without an item (config-declared, or its
727
- * items deleted) it is visible. A builtin item counts as `all`.
728
- */
729
- function itemsVisible(items, listed) {
730
- if (!items)
731
- return true;
732
- return items.some((i) => visibleTo({ scope: i.builtin ? "all" : i.scope }, listed.has(i.id)));
733
- }
734
- /**
735
- * Whether the org sees `plugin` in its extension list (a required bootstrap plugin always; else
736
- * under its catalog items' scope, as {@link OrgExtensionConfigs.list} filters). `db` may be a
737
- * transaction.
726
+ * Whether the org may see `plugin` (a required bootstrap plugin always; else under its catalog
727
+ * items' scope; the list also hides one off here whose item is disabled, {@link offeredToOrg}).
728
+ * `db` may be a transaction.
738
729
  */
739
730
  export async function extensionVisibleTo(db, orgId, plugin) {
740
731
  if ((await requiredExtensions(db)).has(plugin))
@@ -29,11 +29,11 @@ export { HOST_ZOD_VERSION };
29
29
  /** Unpack limits: `maxBytes` is `packages.maxBytes`; the rest default to {@link EXTENSION_PACKAGE_LIMITS}. */
30
30
  export type ExtensionPackageLimits = PackageTgzLimits;
31
31
  /**
32
- * Codes of {@link ExtensionPackageError}: an invalid package, a tgz in the pre-0.1.0 format, a
33
- * plugin without an extension (nothing to install on the deployment), or client code the
34
- * extension manifest does not declare.
32
+ * Codes of {@link ExtensionPackageError}: an invalid package, a plugin without an
33
+ * extension (nothing to install on the deployment), or client code the extension manifest does not
34
+ * declare.
35
35
  */
36
- export type ExtensionPackageErrorCode = "extension.package_invalid" | "extension.legacy_format" | "extension.no_extension" | "client.undeclared";
36
+ export type ExtensionPackageErrorCode = "extension.package_invalid" | "extension.no_extension" | "client.undeclared";
37
37
  /** The extension package is invalid; `issues` lists the problems (English, shown to the admin). */
38
38
  export declare class ExtensionPackageError extends Error {
39
39
  readonly code: ExtensionPackageErrorCode;
@@ -80,8 +80,8 @@ export interface ReadExtensionPackageOptions extends ExtensionPackageLimits {
80
80
  * (`readPluginPackage`) with an `extension` section, whose entry's module graph passes the import
81
81
  * rules (file header) and whose `extension.migrations` SQL is collected. Invalid ->
82
82
  * {@link ExtensionPackageError} (listing every problem it can find; problems while unpacking stop
83
- * at the first): `extension.legacy_format` for the pre-0.1.0 format, `extension.no_extension` for a
84
- * plugin without an extension, otherwise `extension.package_invalid`.
83
+ * at the first): `extension.no_extension` for a plugin without an extension, otherwise
84
+ * `extension.package_invalid`.
85
85
  */
86
86
  export declare function readExtensionPackage(bytes: Uint8Array, opts: ReadExtensionPackageOptions): Promise<ExtensionPackage>;
87
87
  /**
@@ -111,18 +111,14 @@ function checkModuleGraph(entry, byPath) {
111
111
  return issues;
112
112
  }
113
113
  /** Maps an error of `readPluginPackage` to the extension package error. */
114
- const fromPluginPackageError = (e) => new ExtensionPackageError(e.issues, e.code === "catalog.legacy_format"
115
- ? "extension.legacy_format"
116
- : e.code === "client.undeclared"
117
- ? "client.undeclared"
118
- : "extension.package_invalid");
114
+ const fromPluginPackageError = (e) => new ExtensionPackageError(e.issues, e.code === "client.undeclared" ? "client.undeclared" : "extension.package_invalid");
119
115
  /**
120
116
  * Reads and validates an extension package without running any code from it: a plugin tgz
121
117
  * (`readPluginPackage`) with an `extension` section, whose entry's module graph passes the import
122
118
  * rules (file header) and whose `extension.migrations` SQL is collected. Invalid ->
123
119
  * {@link ExtensionPackageError} (listing every problem it can find; problems while unpacking stop
124
- * at the first): `extension.legacy_format` for the pre-0.1.0 format, `extension.no_extension` for a
125
- * plugin without an extension, otherwise `extension.package_invalid`.
120
+ * at the first): `extension.no_extension` for a plugin without an extension, otherwise
121
+ * `extension.package_invalid`.
126
122
  */
127
123
  export async function readExtensionPackage(bytes, opts) {
128
124
  let plugin;
@@ -64,9 +64,7 @@ export declare function permissionGroups(set: PermissionSet): PermissionGroup[];
64
64
  * `conflict`: it provides a single-provider extension point another loaded extension provides (same
65
65
  * rank as `dependency`); it loads once that one is disabled.
66
66
  */
67
- export type DeploymentExtensionStatus = "enabled" | "disabled" | "pending_approval" | "pending_config" | "pending_migration" | "converging" | "failed" | "dependency" | "conflict"
68
- /** The stored package is in the pre-0.1.0 format: reinstall it from a repacked tgz. */
69
- | "legacy_format";
67
+ export type DeploymentExtensionStatus = "enabled" | "disabled" | "pending_approval" | "pending_config" | "pending_migration" | "converging" | "failed" | "dependency" | "conflict";
70
68
  /**
71
69
  * 需要超级管理员处理的状态(后台概览「需要处理的插件」):待批准、待配置、失败、依赖缺失,以及副本不一致
72
70
  * (`converging` 收敛中、`pending_migration` 待迁移)。
@@ -219,7 +217,7 @@ export interface AdminExtensionView {
219
217
  };
220
218
  /**
221
219
  * Why the install record's package cannot be read (bytes missing or corrupt, over the current
222
- * size limit; status failed), or the legacy-format message (status `legacy_format`); permissions
220
+ * size limit; status failed); permissions
223
221
  * are then empty.
224
222
  */
225
223
  error?: string;