@capybara-hq/kernel 0.1.0-rc.35 → 0.1.0-rc.37

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 (311) hide show
  1. package/bootstrap.json +5 -5
  2. package/dist/admin/admin.module.d.ts +3 -3
  3. package/dist/admin/admin.module.js +6 -6
  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/outbox-dead.controller.d.ts +4 -6
  11. package/dist/admin/outbox-dead.controller.js +9 -6
  12. package/dist/admin/outbox-dead.schemas.d.ts +16 -0
  13. package/dist/admin/outbox-dead.schemas.js +25 -1
  14. package/dist/admin/outbox-dead.service.d.ts +16 -7
  15. package/dist/admin/outbox-dead.service.js +34 -10
  16. package/dist/admin/overview.service.d.ts +3 -3
  17. package/dist/admin/overview.service.js +0 -1
  18. package/dist/agents/agent-lookup.js +2 -10
  19. package/dist/agents/agents.module.js +3 -0
  20. package/dist/agents/agents.service.js +9 -20
  21. package/dist/agents/definition.d.ts +3 -51
  22. package/dist/agents/definition.js +4 -254
  23. package/dist/agents/org-templates.js +2 -6
  24. package/dist/agents/readiness.controller.d.ts +8 -19
  25. package/dist/agents/readiness.controller.js +11 -25
  26. package/dist/agents/readiness.service.d.ts +42 -0
  27. package/dist/agents/readiness.service.js +78 -0
  28. package/dist/agents/templates.d.ts +0 -6
  29. package/dist/agents/templates.js +8 -34
  30. package/dist/background/store.d.ts +2 -0
  31. package/dist/background/store.js +3 -1
  32. package/dist/background/wake-rules.js +2 -1
  33. package/dist/catalog/admin-catalog.controller.d.ts +1 -2
  34. package/dist/catalog/admin-catalog.controller.js +1 -2
  35. package/dist/catalog/appearance.service.js +1 -3
  36. package/dist/catalog/catalog-content.d.ts +1 -1
  37. package/dist/catalog/catalog-content.js +1 -4
  38. package/dist/catalog/catalog-items.js +3 -3
  39. package/dist/catalog/catalog-scope.service.d.ts +10 -28
  40. package/dist/catalog/catalog-scope.service.js +22 -73
  41. package/dist/catalog/cli.d.ts +0 -11
  42. package/dist/catalog/cli.js +0 -20
  43. package/dist/catalog/component-scope.service.js +0 -2
  44. package/dist/catalog/component-state.js +2 -2
  45. package/dist/catalog/install-status.d.ts +6 -0
  46. package/dist/catalog/install-status.js +6 -0
  47. package/dist/catalog/job-ids.d.ts +0 -4
  48. package/dist/catalog/job-ids.js +0 -4
  49. package/dist/catalog/marketplaces.service.d.ts +1 -1
  50. package/dist/catalog/org-catalog.service.d.ts +2 -0
  51. package/dist/catalog/org-catalog.service.js +8 -3
  52. package/dist/catalog/org-extension-switch.d.ts +7 -2
  53. package/dist/catalog/org-extension-switch.js +56 -9
  54. package/dist/catalog/org-plugin-uploads.d.ts +6 -15
  55. package/dist/catalog/org-plugin-uploads.js +9 -27
  56. package/dist/catalog/owned-items.js +1 -3
  57. package/dist/catalog/platform-import-update.js +1 -1
  58. package/dist/catalog/plugin-import.d.ts +15 -13
  59. package/dist/catalog/plugin-import.js +21 -30
  60. package/dist/catalog/plugin-install.d.ts +3 -43
  61. package/dist/catalog/plugin-install.js +8 -150
  62. package/dist/catalog/plugin-package.d.ts +5 -10
  63. package/dist/catalog/plugin-package.js +12 -33
  64. package/dist/catalog/plugin-upgrade.js +5 -4
  65. package/dist/catalog/scope-jobs.d.ts +34 -34
  66. package/dist/catalog/scope-jobs.js +50 -37
  67. package/dist/catalog/scope-orgs.d.ts +1 -1
  68. package/dist/catalog/scope-orgs.js +1 -2
  69. package/dist/catalog/scope-sync-workers.d.ts +4 -3
  70. package/dist/catalog/scope-sync-workers.js +18 -6
  71. package/dist/catalog/scope-sync.d.ts +56 -59
  72. package/dist/catalog/scope-sync.js +96 -166
  73. package/dist/catalog/unshare.d.ts +3 -4
  74. package/dist/catalog/unshare.js +5 -8
  75. package/dist/channels/job-ids.d.ts +2 -6
  76. package/dist/channels/job-ids.js +2 -6
  77. package/dist/channels/outbound.d.ts +1 -1
  78. package/dist/channels/outbound.js +1 -1
  79. package/dist/channels/supervisor.d.ts +2 -3
  80. package/dist/channels/supervisor.js +2 -3
  81. package/dist/client/client-access.service.js +1 -1
  82. package/dist/config/env.js +19 -1
  83. package/dist/config/load.d.ts +0 -6
  84. package/dist/config/load.js +8 -27
  85. package/dist/config/schema.d.ts +53 -47
  86. package/dist/config/schema.js +190 -40
  87. package/dist/conversations/attachments.service.d.ts +10 -3
  88. package/dist/conversations/attachments.service.js +49 -16
  89. package/dist/conversations/conversations.controller.d.ts +0 -39
  90. package/dist/conversations/conversations.controller.js +0 -39
  91. package/dist/conversations/events.d.ts +71 -46
  92. package/dist/conversations/events.js +124 -112
  93. package/dist/conversations/media-types.d.ts +25 -0
  94. package/dist/conversations/media-types.js +38 -0
  95. package/dist/conversations/queue.d.ts +3 -1
  96. package/dist/conversations/queue.service.js +9 -2
  97. package/dist/conversations/titles.js +6 -0
  98. package/dist/ctx/create-ctx.js +1 -2
  99. package/dist/ctx/secrets.d.ts +24 -7
  100. package/dist/ctx/secrets.js +97 -30
  101. package/dist/db/kernel-schema.d.ts +17 -6
  102. package/dist/errors.d.ts +5 -2
  103. package/dist/errors.js +5 -2
  104. package/dist/evals/reconstruct.d.ts +4 -17
  105. package/dist/evals/reconstruct.js +13 -53
  106. package/dist/evals/recorded-tools.d.ts +0 -27
  107. package/dist/evals/recorded-tools.js +2 -92
  108. package/dist/evals/run-replay.d.ts +1 -6
  109. package/dist/evals/run-replay.js +10 -17
  110. package/dist/evals/sets.service.d.ts +17 -5
  111. package/dist/evals/sets.service.js +33 -12
  112. package/dist/evals/snapshot.d.ts +1 -2
  113. package/dist/evals/snapshot.js +4 -17
  114. package/dist/extensions/admin-ops.d.ts +6 -1
  115. package/dist/extensions/admin-ops.js +17 -4
  116. package/dist/extensions/admin-view.d.ts +7 -4
  117. package/dist/extensions/admin-view.js +27 -21
  118. package/dist/extensions/bootstrap.js +0 -1
  119. package/dist/extensions/cli.js +0 -1
  120. package/dist/extensions/host.d.ts +2 -3
  121. package/dist/extensions/host.js +1 -5
  122. package/dist/extensions/installs.d.ts +1 -3
  123. package/dist/extensions/instance.d.ts +0 -2
  124. package/dist/extensions/instance.js +0 -3
  125. package/dist/extensions/org-config.d.ts +4 -4
  126. package/dist/extensions/org-config.js +13 -22
  127. package/dist/extensions/package.d.ts +6 -6
  128. package/dist/extensions/package.js +3 -7
  129. package/dist/extensions/permission-view.d.ts +2 -4
  130. package/dist/extensions/plugin-items.d.ts +21 -1
  131. package/dist/extensions/plugin-items.js +28 -0
  132. package/dist/extensions/sync.js +5 -10
  133. package/dist/extensions/unavailable.js +0 -1
  134. package/dist/http/api.module.js +2 -1
  135. package/dist/identity/audit.d.ts +0 -12
  136. package/dist/identity/audit.js +0 -27
  137. package/dist/identity/auth.controller.js +5 -9
  138. package/dist/identity/cookies.d.ts +4 -9
  139. package/dist/identity/cookies.js +8 -32
  140. package/dist/identity/initial-passwords.d.ts +1 -1
  141. package/dist/identity/initial-passwords.js +1 -2
  142. package/dist/identity/sessions.d.ts +0 -6
  143. package/dist/identity/sessions.js +0 -18
  144. package/dist/inbox/platform-inbox.service.d.ts +33 -1
  145. package/dist/inbox/platform-inbox.service.js +56 -6
  146. package/dist/index.d.ts +4 -2
  147. package/dist/index.js +4 -2
  148. package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
  149. package/dist/infra/cli/master-key-rewrap.js +24 -0
  150. package/dist/infra/config/kernel-config.service.js +0 -17
  151. package/dist/infra/health/health.controller.js +8 -0
  152. package/dist/infra/health/process-fault.d.ts +16 -0
  153. package/dist/infra/health/process-fault.js +49 -0
  154. package/dist/infra/lifecycle/process-guards.d.ts +8 -2
  155. package/dist/infra/lifecycle/process-guards.js +12 -3
  156. package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
  157. package/dist/infra/lifecycle/shutdown-signals.js +28 -13
  158. package/dist/infra/outbox/outbox.service.d.ts +12 -9
  159. package/dist/infra/outbox/outbox.service.js +22 -26
  160. package/dist/infra/outbox/registry.d.ts +15 -7
  161. package/dist/infra/outbox/registry.js +39 -23
  162. package/dist/lifecycle/kernel-lifecycle.js +1 -7
  163. package/dist/models/enablement.d.ts +5 -6
  164. package/dist/models/enablement.js +7 -14
  165. package/dist/orgs/orgs.module.d.ts +2 -2
  166. package/dist/orgs/orgs.module.js +2 -2
  167. package/dist/orgs/settings.controller.d.ts +3 -2
  168. package/dist/orgs/settings.service.d.ts +59 -14
  169. package/dist/orgs/settings.service.js +102 -20
  170. package/dist/overrides.d.ts +3 -7
  171. package/dist/overrides.js +2 -4
  172. package/dist/packages/tgz.d.ts +0 -2
  173. package/dist/packages/tgz.js +0 -2
  174. package/dist/platform/exclusions.js +0 -5
  175. package/dist/platform/operation.js +1 -1
  176. package/dist/platform/ops/admin.ops.d.ts +2 -2
  177. package/dist/platform/ops/admin.ops.js +9 -6
  178. package/dist/platform/ops/agents.ops.d.ts +3 -3
  179. package/dist/platform/ops/agents.ops.js +7 -10
  180. package/dist/platform/ops/connectors.ops.js +46 -1
  181. package/dist/platform/ops/evals.ops.js +1 -64
  182. package/dist/platform/ops/extensions-admin.ops.js +1 -1
  183. package/dist/platform/ops/inbox.ops.js +16 -3
  184. package/dist/platform/ops/org-plugins.ops.js +1 -1
  185. package/dist/platform/ops/orgs.ops.d.ts +5 -3
  186. package/dist/platform/ops/orgs.ops.js +19 -4
  187. package/dist/platform/ops/outbox.ops.js +5 -5
  188. package/dist/roles/worker-role.d.ts +2 -3
  189. package/dist/roles/worker-role.js +3 -13
  190. package/dist/runtime/context/build.d.ts +56 -18
  191. package/dist/runtime/context/build.js +143 -50
  192. package/dist/runtime/context/compaction.d.ts +1 -3
  193. package/dist/runtime/context/compaction.js +42 -8
  194. package/dist/runtime/context/run-context.js +1 -2
  195. package/dist/runtime/context/skills.d.ts +27 -56
  196. package/dist/runtime/context/skills.js +42 -114
  197. package/dist/runtime/context/tool-changes.d.ts +3 -3
  198. package/dist/runtime/context/tool-changes.js +6 -16
  199. package/dist/runtime/hook-calls.d.ts +6 -6
  200. package/dist/runtime/hook-calls.js +7 -7
  201. package/dist/runtime/langgraph-loop.js +1 -0
  202. package/dist/runtime/maintenance.d.ts +3 -11
  203. package/dist/runtime/maintenance.js +5 -20
  204. package/dist/runtime/model-call.d.ts +5 -0
  205. package/dist/runtime/model-call.js +48 -36
  206. package/dist/runtime/providers.d.ts +33 -35
  207. package/dist/runtime/providers.js +64 -109
  208. package/dist/runtime/run-context.service.js +7 -22
  209. package/dist/runtime/run-deletion.d.ts +6 -0
  210. package/dist/runtime/run-deletion.js +39 -16
  211. package/dist/runtime/run-execution.js +4 -3
  212. package/dist/runtime/run-finish.js +2 -1
  213. package/dist/runtime/run-liveness.d.ts +11 -0
  214. package/dist/runtime/run-liveness.js +19 -0
  215. package/dist/runtime/run-orphan-check.job.js +2 -1
  216. package/dist/runtime/run-queue.js +8 -16
  217. package/dist/runtime/run-worker.d.ts +2 -2
  218. package/dist/runtime/run-worker.js +8 -6
  219. package/dist/runtime/subagents/definition.d.ts +16 -20
  220. package/dist/runtime/subagents/definition.js +27 -27
  221. package/dist/runtime/subagents/dispatch.d.ts +6 -2
  222. package/dist/runtime/subagents/dispatch.js +17 -3
  223. package/dist/runtime/subagents/org-agents.js +1 -2
  224. package/dist/runtime/subagents/preamble.d.ts +3 -2
  225. package/dist/runtime/subagents/preamble.js +3 -2
  226. package/dist/runtime/subagents/render.d.ts +1 -2
  227. package/dist/runtime/subagents/render.js +1 -2
  228. package/dist/runtime/subagents/skill-fork.d.ts +2 -4
  229. package/dist/runtime/subagents/template-skills.d.ts +47 -0
  230. package/dist/runtime/subagents/template-skills.js +76 -0
  231. package/dist/schedules/effective-settings.d.ts +9 -3
  232. package/dist/schedules/effective-settings.js +5 -4
  233. package/dist/schedules/fire.js +11 -0
  234. package/dist/schedules/scheduled-tasks.service.js +5 -0
  235. package/dist/schedules/unattended.d.ts +2 -0
  236. package/dist/schedules/unattended.js +6 -1
  237. package/dist/skills/agent-skills.service.js +1 -2
  238. package/dist/skills/catalog.d.ts +1 -3
  239. package/dist/skills/catalog.js +1 -3
  240. package/dist/skills/conversation-catalog.d.ts +1 -2
  241. package/dist/skills/conversation-catalog.js +1 -2
  242. package/dist/skills/usable.js +2 -3
  243. package/dist/storage/storage.service.js +9 -1
  244. package/dist/tools/approvals.service.js +2 -4
  245. package/dist/tools/builtin-names.d.ts +2 -9
  246. package/dist/tools/builtin-names.js +4 -13
  247. package/dist/tools/builtins/sandbox/bash.js +3 -3
  248. package/dist/tools/builtins/sandbox/common.d.ts +7 -13
  249. package/dist/tools/builtins/sandbox/common.js +8 -115
  250. package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
  251. package/dist/tools/builtins/sandbox/fetch-attachment.js +119 -0
  252. package/dist/tools/builtins/sandbox/glob.js +1 -3
  253. package/dist/tools/builtins/sandbox/grep.js +3 -5
  254. package/dist/tools/builtins/sandbox/index.d.ts +8 -5
  255. package/dist/tools/builtins/sandbox/index.js +10 -5
  256. package/dist/tools/builtins/sandbox/read.js +3 -2
  257. package/dist/tools/builtins/tool-search.d.ts +4 -7
  258. package/dist/tools/builtins/tool-search.js +6 -10
  259. package/dist/tools/connector-account-policies.d.ts +30 -3
  260. package/dist/tools/connector-account-policies.js +54 -7
  261. package/dist/tools/connectors.controller.d.ts +24 -11
  262. package/dist/tools/connectors.controller.js +35 -6
  263. package/dist/tools/connectors.schemas.d.ts +14 -1
  264. package/dist/tools/connectors.schemas.js +14 -2
  265. package/dist/tools/connectors.service.d.ts +22 -0
  266. package/dist/tools/connectors.service.js +56 -0
  267. package/dist/tools/drift.d.ts +1 -1
  268. package/dist/tools/drift.js +1 -1
  269. package/dist/tools/git-push-policy.d.ts +4 -1
  270. package/dist/tools/git-push-policy.js +3 -1
  271. package/dist/tools/info.d.ts +1 -7
  272. package/dist/tools/info.js +5 -18
  273. package/dist/tools/job-ids.d.ts +0 -4
  274. package/dist/tools/job-ids.js +1 -6
  275. package/dist/tools/pipeline.d.ts +4 -10
  276. package/dist/tools/pipeline.js +16 -62
  277. package/dist/tools/policy.d.ts +6 -2
  278. package/dist/tools/policy.js +14 -12
  279. package/dist/tools/registry.js +1 -5
  280. package/dist/ui/views.d.ts +5 -5
  281. package/dist/ui/views.js +10 -16
  282. package/package.json +3 -3
  283. package/src/migrations/0137_audit_org_idx.sql +5 -0
  284. package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
  285. package/src/migrations/0139_retire_legacy_forms.sql +183 -0
  286. package/src/migrations/0140_retire_history_forms.sql +148 -0
  287. package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
  288. package/src/migrations/0142_backfill_event_fields.sql +74 -0
  289. package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
  290. package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
  291. package/dist/admin/platform-audit.service.d.ts +0 -41
  292. package/dist/conversations/job-ids.d.ts +0 -6
  293. package/dist/conversations/job-ids.js +0 -6
  294. package/dist/extensions/job-ids.d.ts +0 -6
  295. package/dist/extensions/job-ids.js +0 -6
  296. package/dist/infra/queue/retired-schedulers.d.ts +0 -7
  297. package/dist/infra/queue/retired-schedulers.js +0 -9
  298. package/dist/orgs/job-ids.d.ts +0 -8
  299. package/dist/orgs/job-ids.js +0 -8
  300. package/dist/runtime/context/legacy-text.d.ts +0 -22
  301. package/dist/runtime/context/legacy-text.js +0 -37
  302. package/dist/runtime/job-ids.d.ts +0 -10
  303. package/dist/runtime/job-ids.js +0 -10
  304. package/dist/runtime/retired-schedulers.d.ts +0 -7
  305. package/dist/runtime/retired-schedulers.js +0 -31
  306. package/dist/storage/job-ids.d.ts +0 -6
  307. package/dist/storage/job-ids.js +0 -6
  308. package/dist/tools/legacy-data.d.ts +0 -34
  309. package/dist/tools/legacy-data.js +0 -76
  310. package/dist/tools/legacy-keys.d.ts +0 -51
  311. package/dist/tools/legacy-keys.js +0 -114
@@ -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,
@@ -32,7 +32,7 @@ export { deploymentConfigHash };
32
32
  export interface LoadedUiContribution {
33
33
  plugin: string;
34
34
  contribution: UiContribution;
35
- /** The catalog slot the contribution resolved to (from `slot`, or the deprecated `place`). */
35
+ /** The catalog slot the contribution resolved to (from `slot`). */
36
36
  slot: UiSlotSpec;
37
37
  /** For a slot with anchors: the anchor it goes after (see `resolveUiSlots`). */
38
38
  after?: string;
@@ -371,8 +371,7 @@ export declare class ExtensionHost {
371
371
  * `permissionSetOfPackage` at review; the migrations directory comes only from
372
372
  * `extension.migrations`). Does not import the module: that happens after the permission gate
373
373
  * ({@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
374
+ * detail is the error message only) and returns undefined. The result for a package never changes, so successes are cached by sha (a
376
375
  * reconcile cycle does not unpack again).
377
376
  */
378
377
  private prepare;
@@ -950,8 +950,7 @@ let ExtensionHost = class ExtensionHost {
950
950
  * `permissionSetOfPackage` at review; the migrations directory comes only from
951
951
  * `extension.migrations`). Does not import the module: that happens after the permission gate
952
952
  * ({@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
953
+ * detail is the error message only) and returns undefined. The result for a package never changes, so successes are cached by sha (a
955
954
  * reconcile cycle does not unpack again).
956
955
  */
957
956
  async prepare(loader, d) {
@@ -1762,9 +1761,6 @@ let ExtensionHost = class ExtensionHost {
1762
1761
  if (inst.uiUnknownAnchors.length > 0) {
1763
1762
  this.log.warn("plugin ui anchors unknown", { ...at, anchors: inst.uiUnknownAnchors });
1764
1763
  }
1765
- if (inst.uiDeprecatedPlace.length > 0) {
1766
- this.log.info("plugin ui uses the deprecated place", { ...at, ids: inst.uiDeprecatedPlace });
1767
- }
1768
1764
  return inst;
1769
1765
  }
1770
1766
  /** 取能力实现:单选能力无需 providerName,多选能力必须指定。 */
@@ -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;
@@ -1,4 +1,4 @@
1
- import type { PluginScope } from "../catalog/scope.js";
1
+ import { type PluginScope } from "../catalog/scope.js";
2
2
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
3
3
  /** The catalog item (the plugin) an extension ships in. */
4
4
  export interface ExtensionPluginItem {
@@ -19,3 +19,23 @@ export declare function pluginItemsOf(db: KernelSchemaDb, names: readonly string
19
19
  * one, layering spec §4): its switch cannot go off.
20
20
  */
21
21
  export declare const itemLocked: (i: ExtensionPluginItem) => boolean;
22
+ /**
23
+ * Whether an org may see an extension with these live catalog items (`listed`: the items whose
24
+ * `named` list has the org): one visible item is enough; without an item (config-declared, or its
25
+ * items deleted) it is visible. A builtin item counts as `all`.
26
+ */
27
+ export declare function itemsVisible(items: readonly ExtensionPluginItem[] | undefined, listed: ReadonlySet<string>): boolean;
28
+ /**
29
+ * Whether the org's extension list shows an extension (`OrgExtensionConfigs.list`, which the org
30
+ * readiness reads for the model providers an org admin can fix): a required bootstrap plugin
31
+ * always; else under its catalog items' scope, and, while it is off in the org, only when none of
32
+ * its items is disabled (nothing can newly enable it then, Ruling M-5; one already on stays).
33
+ */
34
+ export declare const offeredToOrg: (e: {
35
+ required: boolean;
36
+ enabled: boolean;
37
+ items: readonly ExtensionPluginItem[] | undefined;
38
+ listed: ReadonlySet<string>;
39
+ }) => boolean;
40
+ /** The ids of the catalog items whose `named` list has `orgId`. `db` may be a transaction. */
41
+ export declare function scopeListedFor(db: KernelSchemaDb, orgId: string): Promise<Set<string>>;
@@ -1,3 +1,4 @@
1
+ import { visibleTo } from "../catalog/scope.js";
1
2
  /**
2
3
  * The live catalog items of each extension in `names`, the one recorded on its install
3
4
  * (`extension_installs.catalog_item_id`) first, then its other `extension_catalog_sources` by id.
@@ -40,3 +41,30 @@ export async function pluginItemsOf(db, names) {
40
41
  * one, layering spec §4): its switch cannot go off.
41
42
  */
42
43
  export const itemLocked = (i) => i.builtin;
44
+ /**
45
+ * Whether an org may see an extension with these live catalog items (`listed`: the items whose
46
+ * `named` list has the org): one visible item is enough; without an item (config-declared, or its
47
+ * items deleted) it is visible. A builtin item counts as `all`.
48
+ */
49
+ export function itemsVisible(items, listed) {
50
+ if (!items)
51
+ return true;
52
+ return items.some((i) => visibleTo({ scope: i.builtin ? "all" : i.scope }, listed.has(i.id)));
53
+ }
54
+ /**
55
+ * Whether the org's extension list shows an extension (`OrgExtensionConfigs.list`, which the org
56
+ * readiness reads for the model providers an org admin can fix): a required bootstrap plugin
57
+ * always; else under its catalog items' scope, and, while it is off in the org, only when none of
58
+ * its items is disabled (nothing can newly enable it then, Ruling M-5; one already on stays).
59
+ */
60
+ export const offeredToOrg = (e) => e.required ||
61
+ (itemsVisible(e.items, e.listed) && (e.enabled || !(e.items ?? []).some((i) => i.disabled)));
62
+ /** The ids of the catalog items whose `named` list has `orgId`. `db` may be a transaction. */
63
+ export async function scopeListedFor(db, orgId) {
64
+ const rows = await db
65
+ .selectFrom("catalog_item_scope_orgs")
66
+ .select("item_id")
67
+ .where("org_id", "=", orgId)
68
+ .execute();
69
+ return new Set(rows.map((r) => r.item_id));
70
+ }
@@ -4,8 +4,8 @@ import { mkdir, readdir, readFile, rename, rm, stat, symlink, writeFile } from "
4
4
  import { dirname, join, relative, resolve as resolvePath, sep } from "node:path";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import { HOST_PROVIDED_PACKAGES, isSafePackagePath, PLUGIN_MANIFEST_FILE, } from "@capybara-hq/plugin-sdk";
7
- import { LEGACY_FORMAT_MESSAGE, packagePath } from "../packages/tgz.js";
8
- import { ExtensionPackageError, extractExtensionPackage, } from "./package.js";
7
+ import { packagePath } from "../packages/tgz.js";
8
+ import { extractExtensionPackage } from "./package.js";
9
9
  /**
10
10
  * 把内容寻址的插件包同步到本副本的本地目录(C13):`<dir>/<name>/<sha256 前 16 位>/`。
11
11
  *
@@ -165,9 +165,8 @@ export async function syncPackage(dir, name, sha, blobs, limits) {
165
165
  }
166
166
  /**
167
167
  * The extension entry (relative to the package root) from the unpacked package's
168
- * `.capybara-plugin/plugin.json`. A package in the pre-0.1.0 format (no plugin.json, a `capybara`
169
- * section or `app.yaml`) -> {@link ExtensionPackageError} `extension.legacy_format` (the host
170
- * records it as the replica's failure instead of loading).
168
+ * `.capybara-plugin/plugin.json`. A package without plugin.json fails with an ordinary
169
+ * error (the host records it as the replica's failure instead of loading).
171
170
  */
172
171
  async function extensionEntryOf(root, name) {
173
172
  const read = async (path) => {
@@ -182,11 +181,7 @@ async function extensionEntryOf(root, name) {
182
181
  };
183
182
  const manifest = (await read(PLUGIN_MANIFEST_FILE));
184
183
  if (manifest === undefined) {
185
- const pkg = (await read("package.json"));
186
- if (pkg?.capybara !== undefined || existsSync(join(root, "app.yaml"))) {
187
- throw new ExtensionPackageError([`Package of extension ${name} ${LEGACY_FORMAT_MESSAGE}`], "extension.legacy_format");
188
- }
189
- throw new Error(`package ${name}: ${PLUGIN_MANIFEST_FILE} is missing`);
184
+ throw new Error(`package ${name}: ${PLUGIN_MANIFEST_FILE} is missing; a plugin package carries its manifest at that path (build it with \`capybara-plugin pack\`)`);
190
185
  }
191
186
  const entry = manifest.extension?.entry;
192
187
  if (typeof entry !== "string" || !isSafePackagePath(packagePath(entry))) {
@@ -28,7 +28,6 @@ export function unavailableReason(status) {
28
28
  case "conflict":
29
29
  return "conflict";
30
30
  case "failed":
31
- case "legacy_format":
32
31
  return "failed";
33
32
  case "disabled":
34
33
  return "deployment_disabled";
@@ -10,7 +10,7 @@ import { AdminController } from "../admin/admin.controller.js";
10
10
  import { AdminModule } from "../admin/admin.module.js";
11
11
  import { AdminAgentsController } from "../admin/admin-agents.controller.js";
12
12
  import { AdminConnectorsController } from "../admin/admin-connectors.controller.js";
13
- import { AdminAuditController } from "../admin/audit.controller.js";
13
+ import { AdminAuditController, OrgAuditController } from "../admin/audit.controller.js";
14
14
  import { AdminExtensionsController } from "../admin/extensions.controller.js";
15
15
  import { OutboxDeadController } from "../admin/outbox-dead.controller.js";
16
16
  import { AdminOverviewController } from "../admin/overview.controller.js";
@@ -108,6 +108,7 @@ const CONTROLLERS = [
108
108
  AdminAgentsController,
109
109
  AdminConnectorsController,
110
110
  AdminAuditController,
111
+ OrgAuditController,
111
112
  AdminOverviewController,
112
113
  OutboxDeadController,
113
114
  AdminExtensionsController,
@@ -13,15 +13,3 @@ export declare function audit(db: KernelSchemaDb, e: {
13
13
  target?: string;
14
14
  detail?: Record<string, unknown>;
15
15
  }): Promise<void>;
16
- /**
17
- * Connector audit actions written before the D17 rename (old rows are not rewritten, C27) -> the
18
- * renamed action. Only these are listed, nothing is inferred from the `app.*` prefix: after D17
19
- * "app" meant app bundles (`app.installed` etc., `plugin.org_installed` since phase 0a), which are
20
- * unrelated to connectors (F-X).
21
- */
22
- export declare const LEGACY_AUDIT_ACTIONS: Readonly<Record<string, string>>;
23
- /**
24
- * 按 action 查询审计时与之同义的全部 action(含自身):`connector.created` ↔ `app.created` 等,
25
- * 只按 {@link LEGACY_AUDIT_ACTIONS} 显式映射;其余 action 只有自身。
26
- */
27
- export declare function auditActionAliases(action: string): string[];
@@ -16,30 +16,3 @@ export async function audit(db, e) {
16
16
  })
17
17
  .execute();
18
18
  }
19
- /**
20
- * Connector audit actions written before the D17 rename (old rows are not rewritten, C27) -> the
21
- * renamed action. Only these are listed, nothing is inferred from the `app.*` prefix: after D17
22
- * "app" meant app bundles (`app.installed` etc., `plugin.org_installed` since phase 0a), which are
23
- * unrelated to connectors (F-X).
24
- */
25
- export const LEGACY_AUDIT_ACTIONS = Object.freeze({
26
- "app.created": "connector.created",
27
- "app.updated": "connector.updated",
28
- "app.deleted": "connector.deleted",
29
- "app.tools_refreshed": "connector.tools_refreshed",
30
- "app.tools_drifted": "connector.tools_drifted",
31
- "app.tool_reviewed": "connector.tool_reviewed",
32
- "app.credential.set": "connector.credential.set",
33
- "app.credential.cleared": "connector.credential.cleared",
34
- });
35
- /**
36
- * 按 action 查询审计时与之同义的全部 action(含自身):`connector.created` ↔ `app.created` 等,
37
- * 只按 {@link LEGACY_AUDIT_ACTIONS} 显式映射;其余 action 只有自身。
38
- */
39
- export function auditActionAliases(action) {
40
- const current = LEGACY_AUDIT_ACTIONS[action] ?? action;
41
- const legacy = Object.entries(LEGACY_AUDIT_ACTIONS)
42
- .filter(([, to]) => to === current)
43
- .map(([from]) => from);
44
- return [current, ...legacy];
45
- }
@@ -15,7 +15,7 @@ import { CredentialThrottler } from "../infra/throttler/credential-throttler.js"
15
15
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
16
16
  import { ZBody } from "../infra/validation/zod-params.js";
17
17
  import { AccountsService } from "./accounts.js";
18
- import { ACCESS_COOKIE, clearSessionCookies, refreshCookieValues, setSessionCookies, } from "./cookies.js";
18
+ import { ACCESS_COOKIE, clearSessionCookies, REFRESH_COOKIE, setSessionCookies, } from "./cookies.js";
19
19
  import { Public } from "./principal.js";
20
20
  import { SessionService } from "./sessions.js";
21
21
  const LoginBodySchema = z.object({ login: z.string().max(256), password: z.string() });
@@ -74,13 +74,9 @@ let AuthController = class AuthController {
74
74
  */
75
75
  async refresh(req, reply) {
76
76
  try {
77
- // the header may carry several cap_rt (legacy Path and Path=/): the current one of a live session wins
78
- const candidates = refreshCookieValues(req.headers.cookie);
79
- if (candidates.length === 0) {
77
+ const rt = req.cookies[REFRESH_COOKIE];
78
+ if (!rt)
80
79
  throw new ApiError("auth.refresh_invalid", "Refresh token is missing");
81
- }
82
- // none is current: the last one (the Path=/ cookie) goes through the usual replay handling
83
- const rt = (await this.sessions.pickCurrentRefresh(candidates)) ?? candidates.at(-1);
84
80
  const session = await this.sessions.refresh(rt, clientMeta(req));
85
81
  const account = await this.accounts.get(session.accountId);
86
82
  if (!account)
@@ -98,13 +94,13 @@ let AuthController = class AuthController {
98
94
  async logout(req, reply) {
99
95
  clearSessionCookies(reply);
100
96
  const at = req.cookies[ACCESS_COOKIE];
101
- const rts = refreshCookieValues(req.headers.cookie);
97
+ const rt = req.cookies[REFRESH_COOKIE];
102
98
  if (at) {
103
99
  const sid = await this.sessions.sessionIdFromAccess(at);
104
100
  if (sid !== undefined)
105
101
  await this.sessions.revoke(sid);
106
102
  }
107
- for (const rt of rts)
103
+ if (rt)
108
104
  await this.sessions.revokeByRefresh(rt);
109
105
  }
110
106
  };