@capybara-hq/kernel 0.1.0-rc.6 → 0.1.0-rc.7

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 (331) hide show
  1. package/bootstrap.json +27 -3
  2. package/dist/admin/admin.controller.d.ts +8 -72
  3. package/dist/admin/admin.controller.js +21 -46
  4. package/dist/admin/admin.schemas.d.ts +57 -0
  5. package/dist/admin/admin.schemas.js +50 -0
  6. package/dist/admin/extensions.controller.d.ts +10 -0
  7. package/dist/admin/extensions.controller.js +18 -0
  8. package/dist/admin/extensions.schemas.d.ts +7 -0
  9. package/dist/admin/extensions.schemas.js +10 -0
  10. package/dist/admin/limit-defaults.d.ts +20 -0
  11. package/dist/admin/limit-defaults.js +10 -0
  12. package/dist/agents/agent-profile.service.d.ts +7 -5
  13. package/dist/agents/agent-profile.service.js +14 -9
  14. package/dist/agents/agents.controller.d.ts +7 -287
  15. package/dist/agents/agents.controller.js +7 -67
  16. package/dist/agents/agents.schemas.d.ts +389 -0
  17. package/dist/agents/agents.schemas.js +126 -0
  18. package/dist/agents/agents.service.d.ts +13 -5
  19. package/dist/agents/agents.service.js +67 -13
  20. package/dist/agents/definition.d.ts +47 -19
  21. package/dist/agents/definition.js +119 -38
  22. package/dist/agents/from-template.d.ts +2 -2
  23. package/dist/agents/from-template.js +76 -45
  24. package/dist/agents/from-template.service.d.ts +12 -0
  25. package/dist/agents/from-template.service.js +20 -3
  26. package/dist/agents/models.controller.d.ts +1 -2
  27. package/dist/agents/models.controller.js +1 -1
  28. package/dist/agents/org-templates.d.ts +13 -3
  29. package/dist/agents/org-templates.js +69 -28
  30. package/dist/agents/pending-connector-requests.d.ts +2 -0
  31. package/dist/agents/pending-connector-requests.js +1 -1
  32. package/dist/agents/pending-connectors.controller.d.ts +1 -1
  33. package/dist/agents/pending-connectors.controller.js +2 -2
  34. package/dist/agents/pending-connectors.service.d.ts +2 -2
  35. package/dist/agents/pending-connectors.service.js +19 -19
  36. package/dist/agents/profile.d.ts +18 -0
  37. package/dist/agents/profile.js +5 -1
  38. package/dist/agents/templates.controller.d.ts +8 -17
  39. package/dist/agents/templates.controller.js +13 -31
  40. package/dist/agents/templates.schemas.d.ts +20 -0
  41. package/dist/agents/templates.schemas.js +45 -0
  42. package/dist/background/background.controller.js +3 -2
  43. package/dist/background/background.schemas.d.ts +10 -0
  44. package/dist/background/background.schemas.js +16 -0
  45. package/dist/background/tasks.service.d.ts +1 -1
  46. package/dist/background/tasks.service.js +7 -2
  47. package/dist/catalog/admin-catalog.controller.d.ts +4 -57
  48. package/dist/catalog/admin-catalog.controller.js +8 -45
  49. package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
  50. package/dist/catalog/admin-catalog.schemas.js +92 -0
  51. package/dist/catalog/catalog-content.d.ts +12 -2
  52. package/dist/catalog/catalog-scope.service.js +8 -2
  53. package/dist/catalog/catalog.service.d.ts +2 -0
  54. package/dist/catalog/catalog.service.js +3 -0
  55. package/dist/catalog/component-scope.controller.d.ts +3 -65
  56. package/dist/catalog/component-scope.controller.js +3 -56
  57. package/dist/catalog/component-scope.schemas.d.ts +114 -0
  58. package/dist/catalog/component-scope.schemas.js +97 -0
  59. package/dist/catalog/component-scope.service.d.ts +28 -4
  60. package/dist/catalog/component-scope.service.js +55 -3
  61. package/dist/catalog/component-state.d.ts +9 -2
  62. package/dist/catalog/component-state.js +22 -13
  63. package/dist/catalog/marketplaces.controller.d.ts +5 -35
  64. package/dist/catalog/marketplaces.controller.js +6 -34
  65. package/dist/catalog/marketplaces.schemas.d.ts +48 -0
  66. package/dist/catalog/marketplaces.schemas.js +53 -0
  67. package/dist/catalog/marketplaces.service.d.ts +15 -1
  68. package/dist/catalog/marketplaces.service.js +22 -1
  69. package/dist/catalog/org-catalog.controller.d.ts +6 -62
  70. package/dist/catalog/org-catalog.controller.js +12 -66
  71. package/dist/catalog/org-catalog.schemas.d.ts +79 -0
  72. package/dist/catalog/org-catalog.schemas.js +82 -0
  73. package/dist/catalog/org-catalog.service.d.ts +9 -2
  74. package/dist/catalog/org-catalog.service.js +38 -5
  75. package/dist/catalog/org-extension.controller.d.ts +1 -12
  76. package/dist/catalog/org-extension.controller.js +1 -10
  77. package/dist/catalog/org-extension.schemas.d.ts +15 -0
  78. package/dist/catalog/org-extension.schemas.js +22 -0
  79. package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
  80. package/dist/catalog/org-plugin-uploads.controller.js +15 -28
  81. package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
  82. package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
  83. package/dist/catalog/owned-items.d.ts +6 -2
  84. package/dist/catalog/owned-items.js +16 -4
  85. package/dist/catalog/platform-components.d.ts +2 -0
  86. package/dist/catalog/platform-components.js +2 -0
  87. package/dist/catalog/plugin-import.js +1 -0
  88. package/dist/catalog/plugin-install.js +1 -1
  89. package/dist/catalog/requests.service.d.ts +2 -1
  90. package/dist/catalog/requests.service.js +6 -2
  91. package/dist/channels/channels.schemas.d.ts +33 -0
  92. package/dist/channels/channels.schemas.js +34 -0
  93. package/dist/channels/connections.controller.d.ts +2 -29
  94. package/dist/channels/connections.controller.js +1 -23
  95. package/dist/channels/connections.service.d.ts +8 -2
  96. package/dist/channels/connections.service.js +23 -5
  97. package/dist/channels/inbound.js +4 -0
  98. package/dist/conversations/conversations.controller.d.ts +16 -37
  99. package/dist/conversations/conversations.controller.js +16 -56
  100. package/dist/conversations/conversations.schemas.d.ts +52 -0
  101. package/dist/conversations/conversations.schemas.js +79 -0
  102. package/dist/conversations/conversations.service.d.ts +9 -1
  103. package/dist/conversations/conversations.service.js +23 -18
  104. package/dist/conversations/events.d.ts +80 -6
  105. package/dist/conversations/events.js +60 -5
  106. package/dist/conversations/message-context.d.ts +28 -0
  107. package/dist/conversations/message-context.js +56 -0
  108. package/dist/conversations/queue.d.ts +2 -1
  109. package/dist/conversations/queue.js +11 -2
  110. package/dist/db/kernel-schema.d.ts +20 -0
  111. package/dist/environments/environments.schemas.d.ts +3 -0
  112. package/dist/environments/environments.schemas.js +14 -0
  113. package/dist/environments/environments.service.d.ts +16 -4
  114. package/dist/environments/environments.service.js +58 -13
  115. package/dist/errors.d.ts +3 -0
  116. package/dist/errors.js +3 -0
  117. package/dist/evals/evals.schemas.d.ts +110 -0
  118. package/dist/evals/evals.schemas.js +107 -0
  119. package/dist/evals/reconstruct.js +18 -11
  120. package/dist/evals/recorded-tools.d.ts +2 -1
  121. package/dist/evals/recorded-tools.js +11 -3
  122. package/dist/evals/run-replay.d.ts +8 -1
  123. package/dist/evals/run-replay.js +13 -0
  124. package/dist/evals/runs.controller.d.ts +2 -57
  125. package/dist/evals/runs.controller.js +1 -42
  126. package/dist/evals/runs.service.d.ts +6 -6
  127. package/dist/evals/runs.service.js +32 -18
  128. package/dist/evals/sets.controller.d.ts +2 -28
  129. package/dist/evals/sets.controller.js +1 -31
  130. package/dist/evals/sets.service.d.ts +7 -7
  131. package/dist/evals/sets.service.js +23 -17
  132. package/dist/evals/snapshot.d.ts +3 -2
  133. package/dist/evals/snapshot.js +17 -4
  134. package/dist/extensions/admin-ops.d.ts +5 -3
  135. package/dist/extensions/admin-ops.js +17 -12
  136. package/dist/extensions/deployment-config.d.ts +16 -1
  137. package/dist/extensions/deployment-config.js +83 -0
  138. package/dist/extensions/extensions.module.js +3 -0
  139. package/dist/extensions/host.d.ts +33 -2
  140. package/dist/extensions/host.js +107 -1
  141. package/dist/extensions/installs.d.ts +5 -0
  142. package/dist/extensions/installs.js +12 -0
  143. package/dist/extensions/org-config.d.ts +17 -2
  144. package/dist/extensions/org-config.js +23 -4
  145. package/dist/extensions/point-defaults.controller.d.ts +2 -8
  146. package/dist/extensions/point-defaults.controller.js +1 -3
  147. package/dist/extensions/point-defaults.d.ts +3 -1
  148. package/dist/extensions/point-defaults.js +4 -2
  149. package/dist/extensions/point-defaults.schemas.d.ts +9 -0
  150. package/dist/extensions/point-defaults.schemas.js +14 -0
  151. package/dist/extensions/unavailable.d.ts +49 -0
  152. package/dist/extensions/unavailable.js +113 -0
  153. package/dist/files/previewers.controller.js +2 -3
  154. package/dist/files/previewers.d.ts +1 -1
  155. package/dist/files/previewers.js +4 -4
  156. package/dist/files/previewers.schemas.d.ts +10 -0
  157. package/dist/files/previewers.schemas.js +9 -0
  158. package/dist/http/api.module.js +2 -0
  159. package/dist/identity/accounts.d.ts +43 -4
  160. package/dist/identity/accounts.js +74 -6
  161. package/dist/identity/auth.guard.js +10 -1
  162. package/dist/identity/cookies.d.ts +6 -0
  163. package/dist/identity/cookies.js +14 -0
  164. package/dist/identity/identity.module.js +3 -0
  165. package/dist/identity/initial-passwords.controller.d.ts +22 -0
  166. package/dist/identity/initial-passwords.controller.js +49 -0
  167. package/dist/identity/initial-passwords.d.ts +61 -0
  168. package/dist/identity/initial-passwords.job.d.ts +16 -0
  169. package/dist/identity/initial-passwords.job.js +46 -0
  170. package/dist/identity/initial-passwords.js +159 -0
  171. package/dist/identity/me.controller.d.ts +14 -0
  172. package/dist/identity/me.controller.js +39 -1
  173. package/dist/identity/principal.d.ts +8 -0
  174. package/dist/identity/principal.js +8 -0
  175. package/dist/identity/settings.d.ts +3 -1
  176. package/dist/identity/settings.js +6 -4
  177. package/dist/inbox/inbox.schemas.d.ts +8 -0
  178. package/dist/inbox/inbox.schemas.js +11 -0
  179. package/dist/inbox/platform-inbox.controller.d.ts +1 -1
  180. package/dist/inbox/platform-inbox.controller.js +2 -2
  181. package/dist/index.d.ts +4 -0
  182. package/dist/index.js +6 -0
  183. package/dist/lifecycle/kernel-lifecycle.js +4 -0
  184. package/dist/models/enablement.d.ts +2 -0
  185. package/dist/models/enablement.js +1 -0
  186. package/dist/models/org-models.schemas.d.ts +8 -0
  187. package/dist/models/org-models.schemas.js +22 -0
  188. package/dist/models/prices.d.ts +3 -1
  189. package/dist/models/prices.js +7 -5
  190. package/dist/models/purposes.d.ts +12 -2
  191. package/dist/models/purposes.js +22 -8
  192. package/dist/orgs/orgs.controller.d.ts +2 -5
  193. package/dist/orgs/orgs.controller.js +3 -6
  194. package/dist/orgs/orgs.schemas.d.ts +8 -0
  195. package/dist/orgs/orgs.schemas.js +16 -0
  196. package/dist/orgs/orgs.service.d.ts +3 -1
  197. package/dist/orgs/orgs.service.js +6 -4
  198. package/dist/orgs/settings.service.d.ts +9 -1
  199. package/dist/orgs/settings.service.js +20 -5
  200. package/dist/overrides.d.ts +4 -0
  201. package/dist/overrides.js +2 -0
  202. package/dist/platform/errors.d.ts +21 -4
  203. package/dist/platform/errors.js +45 -6
  204. package/dist/platform/exclusions.d.ts +2 -3
  205. package/dist/platform/exclusions.js +68 -849
  206. package/dist/platform/method.js +1 -1
  207. package/dist/platform/operation.d.ts +82 -5
  208. package/dist/platform/operation.js +62 -7
  209. package/dist/platform/ops/accounts.ops.d.ts +32 -0
  210. package/dist/platform/ops/accounts.ops.js +291 -0
  211. package/dist/platform/ops/admin.ops.d.ts +36 -0
  212. package/dist/platform/ops/admin.ops.js +389 -0
  213. package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
  214. package/dist/platform/ops/agent-skills.ops.js +226 -0
  215. package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
  216. package/dist/platform/ops/agent-templates.ops.js +194 -14
  217. package/dist/platform/ops/agents.ops.d.ts +19 -1
  218. package/dist/platform/ops/agents.ops.js +481 -58
  219. package/dist/platform/ops/approvals.ops.d.ts +30 -0
  220. package/dist/platform/ops/approvals.ops.js +116 -0
  221. package/dist/platform/ops/background.ops.d.ts +14 -0
  222. package/dist/platform/ops/background.ops.js +134 -0
  223. package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
  224. package/dist/platform/ops/catalog-admin.ops.js +587 -0
  225. package/dist/platform/ops/channels.ops.d.ts +16 -0
  226. package/dist/platform/ops/channels.ops.js +195 -0
  227. package/dist/platform/ops/components.ops.d.ts +46 -0
  228. package/dist/platform/ops/components.ops.js +853 -0
  229. package/dist/platform/ops/connectors.ops.d.ts +4 -2
  230. package/dist/platform/ops/connectors.ops.js +68 -6
  231. package/dist/platform/ops/conversations.ops.d.ts +30 -0
  232. package/dist/platform/ops/conversations.ops.js +470 -0
  233. package/dist/platform/ops/environments.ops.d.ts +26 -0
  234. package/dist/platform/ops/environments.ops.js +289 -0
  235. package/dist/platform/ops/errors.d.ts +10 -5
  236. package/dist/platform/ops/errors.js +19 -11
  237. package/dist/platform/ops/evals.ops.d.ts +28 -0
  238. package/dist/platform/ops/evals.ops.js +783 -0
  239. package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
  240. package/dist/platform/ops/extensions-admin.ops.js +344 -0
  241. package/dist/platform/ops/extensions.ops.d.ts +7 -1
  242. package/dist/platform/ops/extensions.ops.js +248 -17
  243. package/dist/platform/ops/inbox.ops.d.ts +25 -0
  244. package/dist/platform/ops/inbox.ops.js +378 -0
  245. package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
  246. package/dist/platform/ops/marketplaces.ops.js +326 -17
  247. package/dist/platform/ops/models.ops.d.ts +25 -0
  248. package/dist/platform/ops/models.ops.js +232 -0
  249. package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
  250. package/dist/platform/ops/org-plugins.ops.js +329 -0
  251. package/dist/platform/ops/org-settings.ops.d.ts +16 -0
  252. package/dist/platform/ops/org-settings.ops.js +102 -0
  253. package/dist/platform/ops/orgs.ops.d.ts +28 -0
  254. package/dist/platform/ops/orgs.ops.js +295 -0
  255. package/dist/platform/ops/other-orgs.d.ts +20 -0
  256. package/dist/platform/ops/other-orgs.js +72 -0
  257. package/dist/platform/ops/platform.ops.d.ts +4 -4
  258. package/dist/platform/ops/platform.ops.js +23 -24
  259. package/dist/platform/ops/plugins.ops.d.ts +10 -8
  260. package/dist/platform/ops/plugins.ops.js +176 -77
  261. package/dist/platform/ops/previewers.ops.d.ts +14 -0
  262. package/dist/platform/ops/previewers.ops.js +109 -0
  263. package/dist/platform/ops/requests.ops.js +57 -19
  264. package/dist/platform/ops/skills.ops.d.ts +5 -1
  265. package/dist/platform/ops/skills.ops.js +129 -11
  266. package/dist/platform/ops/unavailable.d.ts +23 -0
  267. package/dist/platform/ops/unavailable.js +111 -0
  268. package/dist/platform/parity.d.ts +33 -0
  269. package/dist/platform/parity.js +272 -0
  270. package/dist/platform/platform-ops.module.d.ts +32 -0
  271. package/dist/platform/platform-ops.module.js +78 -11
  272. package/dist/platform/route-schemas.d.ts +18 -0
  273. package/dist/platform/route-schemas.js +60 -0
  274. package/dist/roles/worker.module.js +2 -0
  275. package/dist/runtime/context/build.d.ts +2 -0
  276. package/dist/runtime/context/build.js +28 -2
  277. package/dist/runtime/context/compaction.js +10 -1
  278. package/dist/runtime/context/run-context.d.ts +65 -0
  279. package/dist/runtime/context/run-context.js +215 -0
  280. package/dist/runtime/model-call.js +2 -1
  281. package/dist/runtime/providers.js +8 -1
  282. package/dist/runtime/run-context.service.d.ts +65 -0
  283. package/dist/runtime/run-context.service.js +220 -0
  284. package/dist/runtime/run-worker.d.ts +5 -0
  285. package/dist/runtime/run-worker.js +31 -6
  286. package/dist/runtime/runtime.module.js +2 -0
  287. package/dist/runtime/subagents/definition.d.ts +15 -15
  288. package/dist/runtime/subagents/definition.js +46 -115
  289. package/dist/skills/changes.controller.js +2 -1
  290. package/dist/skills/changes.service.d.ts +1 -1
  291. package/dist/skills/changes.service.js +4 -4
  292. package/dist/skills/invocable.controller.d.ts +1 -1
  293. package/dist/skills/invocable.controller.js +2 -2
  294. package/dist/skills/invoke.d.ts +2 -2
  295. package/dist/skills/invoke.js +8 -1
  296. package/dist/skills/skills.controller.d.ts +4 -13
  297. package/dist/skills/skills.controller.js +8 -24
  298. package/dist/skills/skills.schemas.d.ts +48 -0
  299. package/dist/skills/skills.schemas.js +61 -0
  300. package/dist/skills/skills.service.d.ts +11 -1
  301. package/dist/skills/skills.service.js +37 -14
  302. package/dist/time-zone.d.ts +5 -0
  303. package/dist/time-zone.js +19 -0
  304. package/dist/tools/approvals.controller.js +2 -3
  305. package/dist/tools/approvals.schemas.d.ts +21 -0
  306. package/dist/tools/approvals.schemas.js +15 -0
  307. package/dist/tools/builtin-names.d.ts +10 -8
  308. package/dist/tools/builtin-names.js +16 -11
  309. package/dist/tools/builtins/builtin-tools.d.ts +3 -1
  310. package/dist/tools/builtins/builtin-tools.js +15 -3
  311. package/dist/tools/builtins/current-time.d.ts +26 -0
  312. package/dist/tools/builtins/current-time.js +99 -0
  313. package/dist/tools/builtins/platform.d.ts +19 -2
  314. package/dist/tools/builtins/platform.js +105 -16
  315. package/dist/tools/connectors.controller.d.ts +1 -2
  316. package/dist/tools/connectors.controller.js +1 -4
  317. package/dist/tools/connectors.schemas.d.ts +12 -0
  318. package/dist/tools/connectors.schemas.js +19 -0
  319. package/dist/tools/connectors.service.d.ts +5 -2
  320. package/dist/tools/connectors.service.js +7 -5
  321. package/dist/tools/org-tool-switches.d.ts +16 -2
  322. package/dist/tools/org-tool-switches.js +26 -9
  323. package/dist/tools/pipeline.js +3 -1
  324. package/dist/tools/registry.d.ts +48 -51
  325. package/dist/tools/registry.js +222 -233
  326. package/package.json +3 -3
  327. package/src/migrations/0090_initial_passwords.sql +27 -0
  328. package/src/migrations/0091_account_time_zone.sql +4 -0
  329. package/src/migrations/0092_tools_default_on.sql +27 -0
  330. package/dist/platform/redact-orgs.d.ts +0 -7
  331. package/dist/platform/redact-orgs.js +0 -52
@@ -4,14 +4,16 @@ import { OrgCatalogService } from "../../catalog/org-catalog.service.js";
4
4
  import { PluginInstaller } from "../../catalog/plugin-install.js";
5
5
  import { PlatformPluginUpdater } from "../../catalog/plugin-upgrade.js";
6
6
  import { OrgExtensionConfigs } from "../../extensions/org-config.js";
7
+ import { ExtensionAvailability } from "../../extensions/unavailable.js";
7
8
  import { KernelDb } from "../../infra/database/kernel-db.js";
8
9
  import { PlatformOperations } from "../registry.js";
9
- export declare const OTHER_ORG = "This plugin belongs to another org; use the admin console.";
10
+ export { OTHER_ORG } from "./other-orgs.js";
10
11
  export declare const NEEDS_INPUT = "This plugin needs configuration a person must enter; ask them to enable it on the \u63D2\u4EF6 page.";
11
12
  /**
12
13
  * Plugin operations of the `Platform` tool (spec §7): the org's view (list, get, switch on or off)
13
14
  * and the super admin's platform view (list, get, update with its preview). Every platform result
14
- * goes through {@link redactOrgs}: other orgs only as counts (spec §6.1).
15
+ * shows the admin console's data in full for platform items and the org's own (spec §14.5 item 1);
16
+ * plugins other orgs own are only counted, and reading or updating one is refused.
15
17
  */
16
18
  export declare class PluginsOperations implements OnModuleInit {
17
19
  private readonly registry;
@@ -21,13 +23,13 @@ export declare class PluginsOperations implements OnModuleInit {
21
23
  private readonly installer;
22
24
  private readonly extensions;
23
25
  private readonly kdb;
24
- constructor(registry: PlatformOperations, orgCatalog: OrgCatalogService, catalog: CatalogService, updater: PlatformPluginUpdater, installer: PluginInstaller, extensions: OrgExtensionConfigs, kdb: KernelDb);
26
+ private readonly availability;
27
+ constructor(registry: PlatformOperations, orgCatalog: OrgCatalogService, catalog: CatalogService, updater: PlatformPluginUpdater, installer: PluginInstaller, extensions: OrgExtensionConfigs, kdb: KernelDb, availability: ExtensionAvailability);
25
28
  /**
26
- * Refuses a super-admin operation on an item another org owns: its results would describe that
27
- * org's private plugin in this org's log (spec §6.1). Platform items and the org's own pass.
29
+ * Installed (or builtin) plugins whose extension stopped loading: the reason, keyed by plugin
30
+ * name. Their state stays (`on` / `needs_config`) so an org admin can still switch them off;
31
+ * the reason and next step tell why the plugin does nothing now.
28
32
  */
29
- private assertNotOtherOrgs;
30
- /** How many live catalog items other orgs own (left out of the platform list). */
31
- private otherOrgItems;
33
+ private stopped;
32
34
  onModuleInit(): void;
33
35
  }
@@ -10,37 +10,56 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { ToolError } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { z } from "zod";
13
+ import { CatalogIdPathParams, CatalogUpdateBody } from "../../catalog/admin-catalog.schemas.js";
13
14
  import { CatalogService } from "../../catalog/catalog.service.js";
15
+ import { CatalogItemPathParams } from "../../catalog/org-catalog.schemas.js";
14
16
  import { OrgCatalogService } from "../../catalog/org-catalog.service.js";
15
17
  import { PluginInstaller, uninstallPreviewHash } from "../../catalog/plugin-install.js";
16
18
  import { PlatformPluginUpdater } from "../../catalog/plugin-upgrade.js";
17
19
  import { OrgExtensionConfigs } from "../../extensions/org-config.js";
20
+ import { ExtensionAvailability } from "../../extensions/unavailable.js";
18
21
  import { KernelDb } from "../../infra/database/kernel-db.js";
19
22
  import { defineOperation } from "../operation.js";
20
- import { redactOrgs } from "../redact-orgs.js";
21
23
  import { PlatformOperations } from "../registry.js";
22
- import { asToolError, viaAgent } from "./errors.js";
24
+ import { viaAgent } from "./errors.js";
25
+ import { assertNotOtherOrgs, otherOrgItems } from "./other-orgs.js";
23
26
  import { Cursor, pageOf, startOf } from "./paging.js";
24
27
  import { localized } from "./summary.js";
25
- const Id = z.string().min(1).max(100);
26
- const Version = z.string().min(1).max(100);
27
- const Hash = z.string().min(1).max(200);
28
+ import { roleFor, unavailableFields, unavailableMessage, unavailableNext } from "./unavailable.js";
29
+ /** An org catalog item id (`:itemId` of the org routes). */
30
+ const ItemId = CatalogItemPathParams.shape.itemId.max(100);
31
+ /** A platform catalog item id (`:id` of the admin routes), named `itemId` like the org's. */
32
+ const PlatformItemId = CatalogIdPathParams.shape.id.max(100);
33
+ const Version = CatalogUpdateBody.shape.version.max(100);
34
+ /** The switch-off confirm: the uninstall preview's hash, or `nothing-installed`. */
35
+ const Confirm = z.string().min(1).max(200);
28
36
  /** Entries per page of the paged lists (the tool caps a bare list at 50). */
29
37
  const PAGE = 50;
30
38
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
31
- export const OTHER_ORG = "This plugin belongs to another org; use the admin console.";
39
+ export { OTHER_ORG } from "./other-orgs.js";
32
40
  const LOCKED = "This plugin is on for every org (or shipped with the platform) and cannot be switched off in one org.";
33
41
  /** The confirm value of switching off a plugin with nothing installed in the org. */
34
42
  const NOTHING_INSTALLED = "nothing-installed";
35
43
  export const NEEDS_INPUT = "This plugin needs configuration a person must enter; ask them to enable it on the 插件 page.";
36
- /** An org's view of a plugin, as the list shows it. */
37
- const brief = (i) => ({
44
+ /** The English name of a plugin as next steps and messages name it. */
45
+ const enName = (i) => localized(i.displayName, i.name).en;
46
+ /** The item with the reason its extension stopped loading (state unchanged), when it has one. */
47
+ const withStopped = (i, stopped) => {
48
+ const reason = i.reason ?? stopped.get(i.name);
49
+ return reason === undefined ? i : { ...i, reason };
50
+ };
51
+ /**
52
+ * An org's view of a plugin (`plugins.get`): the state, and when unavailable the reason and the
53
+ * actor's next step (spec §14.2 problem 4: one call decides it).
54
+ */
55
+ const brief = (i, role) => ({
38
56
  id: i.id,
39
57
  name: i.name,
40
58
  displayName: i.displayName,
41
59
  description: i.description,
42
60
  scope: i.scope,
43
61
  state: i.state,
62
+ ...unavailableFields(i.reason, enName(i), role),
44
63
  switchable: i.switchable,
45
64
  builtin: i.builtin,
46
65
  notDeployed: i.notDeployed,
@@ -50,6 +69,16 @@ const brief = (i) => ({
50
69
  owner: i.owner,
51
70
  request: i.request,
52
71
  });
72
+ /** A plugin as `plugins.list` shows it: a compact row; the rest comes from `plugins.get`. */
73
+ const row = (i, role) => ({
74
+ id: i.id,
75
+ name: i.name,
76
+ state: i.state,
77
+ ...unavailableFields(i.reason, enName(i), role),
78
+ displayName: i.displayName,
79
+ switchable: i.switchable,
80
+ request: i.request,
81
+ });
53
82
  const hasConfigFields = (schema) => {
54
83
  const props = schema?.properties;
55
84
  return typeof props === "object" && props !== null && Object.keys(props).length > 0;
@@ -74,7 +103,8 @@ function needsInput(item, extensions) {
74
103
  /**
75
104
  * Plugin operations of the `Platform` tool (spec §7): the org's view (list, get, switch on or off)
76
105
  * and the super admin's platform view (list, get, update with its preview). Every platform result
77
- * goes through {@link redactOrgs}: other orgs only as counts (spec §6.1).
106
+ * shows the admin console's data in full for platform items and the org's own (spec §14.5 item 1);
107
+ * plugins other orgs own are only counted, and reading or updating one is refused.
78
108
  */
79
109
  let PluginsOperations = class PluginsOperations {
80
110
  registry;
@@ -84,7 +114,8 @@ let PluginsOperations = class PluginsOperations {
84
114
  installer;
85
115
  extensions;
86
116
  kdb;
87
- constructor(registry, orgCatalog, catalog, updater, installer, extensions, kdb) {
117
+ availability;
118
+ constructor(registry, orgCatalog, catalog, updater, installer, extensions, kdb, availability) {
88
119
  this.registry = registry;
89
120
  this.orgCatalog = orgCatalog;
90
121
  this.catalog = catalog;
@@ -92,52 +123,49 @@ let PluginsOperations = class PluginsOperations {
92
123
  this.installer = installer;
93
124
  this.extensions = extensions;
94
125
  this.kdb = kdb;
126
+ this.availability = availability;
95
127
  }
96
128
  /**
97
- * Refuses a super-admin operation on an item another org owns: its results would describe that
98
- * org's private plugin in this org's log (spec §6.1). Platform items and the org's own pass.
129
+ * Installed (or builtin) plugins whose extension stopped loading: the reason, keyed by plugin
130
+ * name. Their state stays (`on` / `needs_config`) so an org admin can still switch them off;
131
+ * the reason and next step tell why the plugin does nothing now.
99
132
  */
100
- async assertNotOtherOrgs(itemId, orgId) {
101
- if (!UUID_RE.test(itemId))
102
- return;
103
- const row = await this.kdb.db
104
- .selectFrom("catalog_items")
105
- .select("owner_org_id")
106
- .where("id", "=", itemId)
107
- .executeTakeFirst();
108
- if (row?.owner_org_id != null && row.owner_org_id !== orgId)
109
- throw new ToolError(OTHER_ORG);
110
- }
111
- /** How many live catalog items other orgs own (left out of the platform list). */
112
- async otherOrgItems(orgId) {
113
- const r = await this.kdb.db
114
- .selectFrom("catalog_items")
115
- .select((eb) => eb.fn.countAll().as("n"))
116
- .where("deleted_at", "is", null)
117
- .where("owner_org_id", "is not", null)
118
- .where("owner_org_id", "!=", orgId)
119
- .executeTakeFirstOrThrow();
120
- return Number(r.n);
133
+ async stopped(items) {
134
+ const names = items
135
+ .filter((i) => i.reason === undefined &&
136
+ i.componentCounts.extension > 0 &&
137
+ (i.installed !== null || i.builtin))
138
+ // a plugin's extension carries the plugin's name
139
+ .map((i) => i.name);
140
+ const out = new Map();
141
+ for (const [name, u] of await this.availability.unavailable(names))
142
+ out.set(name, u.reason);
143
+ return out;
121
144
  }
122
145
  onModuleInit() {
123
146
  this.registry.register([
124
147
  defineOperation({
125
148
  id: "plugins.list",
126
- description: "List the plugins this org can see, with their state here (on, off, needs_config, unavailable, not_offered), whether an org admin can switch them, and the org's pending request. Pages by 50: pass the returned next as params.cursor.",
149
+ description: "List the plugins this org can see, one compact row each: the state here (on, off, needs_config, unavailable, not_offered), why an unavailable one cannot be used (reason) and your next step (next; an installed plugin whose extension stopped running keeps its state and carries them too), whether an org admin can switch it, and the org's pending request. Details come from plugins.get. Pages by 50: pass the returned next as params.cursor.",
127
150
  input: z.object({ cursor: Cursor.optional() }).strict(),
128
151
  example: {},
129
152
  authz: { orgAction: "catalog.read" },
130
153
  mirrors: ["GET /api/v1/orgs/:orgId/catalog"],
154
+ extras: ["cursor"],
131
155
  confirm: "read",
132
156
  run: async (input, ctx) => {
133
- const all = await this.orgCatalog.list(ctx.orgId, ctx.actorAccountId);
134
- return pageOf(all.map(brief), startOf(input.cursor), PAGE);
157
+ const [all, role] = await Promise.all([
158
+ this.orgCatalog.list(ctx.orgId, ctx.actorAccountId),
159
+ roleFor(this.kdb.db, ctx),
160
+ ]);
161
+ const stopped = await this.stopped(all);
162
+ return pageOf(all.map((i) => row(withStopped(i, stopped), role)), startOf(input.cursor), PAGE);
135
163
  },
136
164
  }),
137
165
  defineOperation({
138
166
  id: "plugins.get",
139
- description: "Read one plugin as this org sees it: its state, extension, connector templates (presets only, never credentials), dependencies, skills and agent templates.",
140
- input: z.object({ itemId: Id }).strict(),
167
+ description: "Read one plugin as this org sees it: its state (with the reason and your next step when it is unavailable, or installed but its extension stopped running), extension, connector templates (presets only, never credentials), dependencies, skills and agent templates.",
168
+ input: z.object({ itemId: ItemId }).strict(),
141
169
  example: { itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c" },
142
170
  authz: { orgAction: "catalog.read" },
143
171
  mirrors: ["GET /api/v1/orgs/:orgId/catalog/:itemId"],
@@ -145,15 +173,18 @@ let PluginsOperations = class PluginsOperations {
145
173
  errors: [
146
174
  { code: "catalog.item_not_found", next: "Check the plugin id with plugins.list." },
147
175
  ],
148
- run: async (input, ctx) => asToolError(async () => {
149
- const d = await this.orgCatalog.detail(ctx.orgId, ctx.actorAccountId, input.itemId);
150
- return { ...d, item: brief(d.item) };
151
- }),
176
+ run: async (input, ctx) => {
177
+ const [d, role] = await Promise.all([
178
+ this.orgCatalog.detail(ctx.orgId, ctx.actorAccountId, input.itemId),
179
+ roleFor(this.kdb.db, ctx),
180
+ ]);
181
+ return { ...d, item: brief(withStopped(d.item, await this.stopped([d.item])), role) };
182
+ },
152
183
  }),
153
184
  defineOperation({
154
185
  id: "plugins.disable-preview",
155
186
  description: "Preview switching a plugin off in this org (org admins): what it would remove and which agents use it, and the confirm value plugins.set-enabled needs to switch it off. Show the preview to the person before switching off.",
156
- input: z.object({ itemId: Id }).strict(),
187
+ input: z.object({ itemId: ItemId }).strict(),
157
188
  example: { itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c" },
158
189
  // the web previews through the switch route itself (no confirm); writes nothing here
159
190
  authz: { orgAction: "org.extensions.manage" },
@@ -162,7 +193,7 @@ let PluginsOperations = class PluginsOperations {
162
193
  errors: [
163
194
  { code: "catalog.item_not_found", next: "Check the plugin id with plugins.list." },
164
195
  ],
165
- run: async (input, ctx) => asToolError(async () => {
196
+ run: async (input, ctx) => {
166
197
  const d = await this.orgCatalog.detail(ctx.orgId, ctx.actorAccountId, input.itemId);
167
198
  if (!d.item.switchable)
168
199
  throw new ToolError(LOCKED);
@@ -176,14 +207,14 @@ let PluginsOperations = class PluginsOperations {
176
207
  }
177
208
  const preview = await this.installer.previewUninstall(ctx.orgId, live.pluginInstallId);
178
209
  return { preview, confirm: uninstallPreviewHash(preview) };
179
- }),
210
+ },
180
211
  }),
181
212
  defineOperation({
182
213
  id: "plugins.set-enabled",
183
214
  description: "Switch a plugin on or off in this org. Switching on installs it; a plugin whose enabling needs configuration a person enters (connector credentials, extension config) is refused, so point the person to the 插件 page. Switching off removes what the plugin brought and needs confirm: the value plugins.disable-preview returned with the preview the person saw.",
184
215
  input: z.discriminatedUnion("enabled", [
185
- z.object({ itemId: Id, enabled: z.literal(true) }).strict(),
186
- z.object({ itemId: Id, enabled: z.literal(false), confirm: Hash }).strict(),
216
+ z.object({ itemId: ItemId, enabled: z.literal(true) }).strict(),
217
+ z.object({ itemId: ItemId, enabled: z.literal(false), confirm: Confirm }).strict(),
187
218
  ]),
188
219
  example: { itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c", enabled: true },
189
220
  // the route needs catalog.read; setSwitch requires an org admin (any of skills.manage,
@@ -191,6 +222,11 @@ let PluginsOperations = class PluginsOperations {
191
222
  authz: { orgAction: "org.extensions.manage" },
192
223
  authzNote: "service-enforced",
193
224
  mirrors: ["PUT /api/v1/orgs/:orgId/catalog/:itemId/switch"],
225
+ // install inputs a person enters on the web (a plugin that needs them is refused)
226
+ omits: ["inputs"],
227
+ loosens: {
228
+ confirm: "also takes `nothing-installed` (plugins.disable-preview's value when nothing is installed), which the route's hash pattern rejects; the service checks confirm only when something is installed",
229
+ },
194
230
  confirm: "org",
195
231
  errors: [
196
232
  {
@@ -203,17 +239,64 @@ let PluginsOperations = class PluginsOperations {
203
239
  },
204
240
  {
205
241
  code: "plugin.disabled",
206
- next: "The super admin stopped this plugin on the platform; ask them.",
242
+ next: {
243
+ superAdmin: "The plugin is stopped on the platform: turn it back on in the admin console under Plugins, then call again.",
244
+ orgAdmin: "The super admin stopped this plugin on the platform; ask them.",
245
+ member: "The super admin stopped this plugin on the platform; tell your org admin, who can ask the super admin.",
246
+ },
247
+ },
248
+ {
249
+ code: "catalog.item_not_found",
250
+ next: "Check the plugin id with plugins.list.",
251
+ },
252
+ {
253
+ code: "plugin.needs_input",
254
+ next: "Ask the person to enable it on the 插件 page, where they enter its configuration.",
207
255
  },
208
256
  {
209
257
  code: "catalog.approval_required",
210
258
  next: "The plugin is not offered to this org: create an access request with requests.create.",
211
259
  },
260
+ {
261
+ code: "catalog.not_deployed",
262
+ next: {
263
+ superAdmin: "Open the admin console → Extensions → the plugin's extension to see why it is not running (deployment config, permission approval, disabled, or failed to load); fix it, then call again.",
264
+ orgAdmin: "Only the super admin can make the plugin's extension run; plugins.get shows the reason. There is no request operation for this (requests.create covers enabling and access only), so tell the super admin directly.",
265
+ member: "Ask an org admin: the super admin must set up the plugin's extension on the platform first.",
266
+ },
267
+ },
212
268
  {
213
269
  code: "plugin.skill_conflict",
214
270
  next: "An org skill has the name of one of the plugin's skills; the person resolves it on the web.",
215
271
  },
216
272
  ],
273
+ // what is known to fail before the card: an unknown plugin, switching off a locked one,
274
+ // switching on one whose extension cannot run (with the role's next step naming it) or
275
+ // that needs a person's input
276
+ precheck: async (i, ctx) => {
277
+ const [item] = UUID_RE.test(i.itemId)
278
+ ? await this.orgCatalog.list(ctx.orgId, ctx.actorAccountId, i.itemId)
279
+ : [];
280
+ if (item === undefined) {
281
+ return { ok: false, code: "catalog.item_not_found", message: "Catalog item not found" };
282
+ }
283
+ if (!i.enabled && !item.switchable) {
284
+ return { ok: false, code: "plugin.scope_locked", message: LOCKED };
285
+ }
286
+ if (i.enabled && item.state === "unavailable" && item.reason !== undefined) {
287
+ const name = enName(item);
288
+ return {
289
+ ok: false,
290
+ code: item.reason === "plugin_disabled" ? "plugin.disabled" : "catalog.not_deployed",
291
+ message: unavailableMessage(item.reason, name),
292
+ next: unavailableNext(item.reason, name),
293
+ };
294
+ }
295
+ if (i.enabled && needsInput(item, await this.extensions.list(ctx.orgId))) {
296
+ return { ok: false, code: "plugin.needs_input", message: NEEDS_INPUT };
297
+ }
298
+ return { ok: true };
299
+ },
217
300
  summary: async (i, ctx) => {
218
301
  const [item] = await this.orgCatalog.list(ctx.orgId, ctx.actorAccountId, i.itemId);
219
302
  if (item === undefined)
@@ -236,7 +319,7 @@ let PluginsOperations = class PluginsOperations {
236
319
  en: `Disable plugin "${n.en}" in the org: removes ${p.components.length} components; ${p.agents.length} agents use it`,
237
320
  };
238
321
  },
239
- run: async (input, ctx) => asToolError(async () => {
322
+ run: async (input, ctx) => {
240
323
  if (input.enabled) {
241
324
  const [item] = await this.orgCatalog.list(ctx.orgId, ctx.actorAccountId, input.itemId);
242
325
  if (item && needsInput(item, await this.extensions.list(ctx.orgId))) {
@@ -244,36 +327,43 @@ let PluginsOperations = class PluginsOperations {
244
327
  }
245
328
  }
246
329
  const r = await this.orgCatalog.setSwitch(ctx.orgId, ctx.actorAccountId, input.itemId, input.enabled ? { enabled: true } : { enabled: false, confirm: input.confirm }, undefined, viaAgent("plugins.set-enabled", ctx));
247
- if (r.kind === "done")
248
- return { item: brief(r.item) };
330
+ if (r.kind === "done") {
331
+ return {
332
+ item: brief(r.item, await roleFor(this.kdb.db, ctx)),
333
+ };
334
+ }
249
335
  // unreachable: confirm is required when switching off
250
336
  return { preview: r.preview, confirm: r.confirm };
251
- }),
337
+ },
252
338
  }),
253
339
  defineOperation({
254
340
  id: "plugins.platform-list",
255
- description: "List the platform's plugins and this org's own (super admin): scope, disabled, versions, pending confirmation and how many orgs use it. Plugins other orgs own are only counted (otherOrgItems); orgs are given as counts. Pages by 50: pass the returned next as params.cursor.",
341
+ description: "List the platform's plugins and this org's own (super admin): scope, disabled, versions, pending confirmation and how many orgs use it. Plugins other orgs own are only counted (otherOrgItems). Pages by 50: pass the returned next as params.cursor.",
256
342
  input: z.object({ cursor: Cursor.optional() }).strict(),
257
343
  example: {},
258
344
  authz: { superAdmin: true },
259
345
  mirrors: ["GET /api/v1/admin/catalog/items"],
346
+ // paged by cursor; deleted items and the pending filter are the admin console's
347
+ omits: ["includeDeleted", "limit", "offset", "pending"],
348
+ extras: ["cursor"],
260
349
  confirm: "read",
261
350
  run: async (input, ctx) => {
262
351
  const p = await this.catalog.page({ limit: PAGE, offset: startOf(input.cursor) });
263
- return redactOrgs({
352
+ return {
264
353
  items: p.items.filter((i) => i.owner.kind !== "org" || i.owner.orgId === ctx.orgId),
265
- otherOrgItems: await this.otherOrgItems(ctx.orgId),
354
+ otherOrgItems: await otherOrgItems(this.kdb.db, ctx.orgId),
266
355
  next: p.nextOffset === null ? null : String(p.nextOffset),
267
- });
356
+ };
268
357
  },
269
358
  }),
270
359
  defineOperation({
271
360
  id: "plugins.platform-get",
272
- description: "Read one platform catalog plugin (super admin): the item, its platform version and every version with its source. Orgs are given as counts only.",
273
- input: z.object({ itemId: Id }).strict(),
361
+ description: "Read one platform catalog plugin (super admin): the item, its platform version and every version with its source, and the orgs it is offered to. Another org's own plugin is refused.",
362
+ input: z.object({ itemId: PlatformItemId }).strict(),
274
363
  example: { itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c" },
275
364
  authz: { superAdmin: true },
276
365
  mirrors: ["GET /api/v1/admin/catalog/items/:id"],
366
+ renames: { itemId: "id" },
277
367
  confirm: "read",
278
368
  errors: [
279
369
  {
@@ -281,10 +371,10 @@ let PluginsOperations = class PluginsOperations {
281
371
  next: "Check the plugin id with plugins.platform-list.",
282
372
  },
283
373
  ],
284
- run: async (input, ctx) => asToolError(async () => {
285
- await this.assertNotOtherOrgs(input.itemId, ctx.orgId);
374
+ run: async (input, ctx) => {
375
+ await assertNotOtherOrgs(this.kdb.db, input.itemId, ctx.orgId);
286
376
  const d = await this.catalog.get(input.itemId);
287
- return redactOrgs({
377
+ return {
288
378
  item: d.item,
289
379
  versions: d.versions.map((v) => ({
290
380
  version: v.version,
@@ -294,16 +384,17 @@ let PluginsOperations = class PluginsOperations {
294
384
  importedAt: v.importedAt,
295
385
  ...(v.version === d.item.platformVersion && { manifest: v.manifest }),
296
386
  })),
297
- });
298
- }),
387
+ };
388
+ },
299
389
  }),
300
390
  defineOperation({
301
391
  id: "plugins.update-preview",
302
- description: "Preview updating a platform plugin to another imported version (super admin): every component's change, the extension step and the org connectors it touches, with the diffHash plugins.update takes. Orgs are given as counts only; the admin console shows which.",
303
- input: z.object({ itemId: Id, version: Version }).strict(),
392
+ description: "Preview updating a platform plugin to another imported version (super admin): every component's change, the extension step and the org connectors it touches, with the diffHash plugins.update takes. Another org's own plugin is refused.",
393
+ input: z.object({ itemId: PlatformItemId, version: Version }).strict(),
304
394
  example: { itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c", version: "1.2.0" },
305
395
  authz: { superAdmin: true },
306
396
  mirrors: ["POST /api/v1/admin/catalog/items/:id/update/preview"],
397
+ renames: { itemId: "id" },
307
398
  confirm: "read",
308
399
  errors: [
309
400
  {
@@ -311,15 +402,21 @@ let PluginsOperations = class PluginsOperations {
311
402
  next: "Check the plugin id and its versions with plugins.platform-get.",
312
403
  },
313
404
  ],
314
- run: async (input, ctx) => asToolError(async () => {
315
- await this.assertNotOtherOrgs(input.itemId, ctx.orgId);
316
- return redactOrgs(await this.updater.preview(input.itemId, input.version));
317
- }),
405
+ run: async (input, ctx) => {
406
+ await assertNotOtherOrgs(this.kdb.db, input.itemId, ctx.orgId);
407
+ return this.updater.preview(input.itemId, input.version);
408
+ },
318
409
  }),
319
410
  defineOperation({
320
411
  id: "plugins.update",
321
412
  description: "Update a platform plugin to the version previewed (super admin), for every org at once: pass the version and the diffHash plugins.update-preview returned. A preview that is out of date is refused; preview again.",
322
- input: z.object({ itemId: Id, version: Version, diffHash: Hash }).strict(),
413
+ input: z
414
+ .object({
415
+ itemId: PlatformItemId,
416
+ version: Version,
417
+ diffHash: CatalogUpdateBody.shape.diffHash,
418
+ })
419
+ .strict(),
323
420
  example: {
324
421
  itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c",
325
422
  version: "1.2.0",
@@ -327,6 +424,7 @@ let PluginsOperations = class PluginsOperations {
327
424
  },
328
425
  authz: { superAdmin: true },
329
426
  mirrors: ["PUT /api/v1/admin/catalog/items/:id/update"],
427
+ renames: { itemId: "id" },
330
428
  confirm: "platform",
331
429
  errors: [
332
430
  {
@@ -339,7 +437,7 @@ let PluginsOperations = class PluginsOperations {
339
437
  },
340
438
  ],
341
439
  summary: async (i, ctx) => {
342
- await this.assertNotOtherOrgs(i.itemId, ctx.orgId);
440
+ await assertNotOtherOrgs(this.kdb.db, i.itemId, ctx.orgId);
343
441
  const [{ item }, p] = await Promise.all([
344
442
  this.catalog.get(i.itemId),
345
443
  this.updater.preview(i.itemId, i.version),
@@ -349,17 +447,17 @@ let PluginsOperations = class PluginsOperations {
349
447
  const changed = count("upgrade", "downgrade");
350
448
  const added = count("added");
351
449
  const removed = count("removed");
352
- // one version for every org: the orgs it is on in, as a count (spec §6.1)
450
+ // one version for every org: how many orgs it is on in
353
451
  const orgs = item.enabledOrgs;
354
452
  return {
355
453
  zh: `把平台插件「${n.zh}」从 ${p.from ?? "无"} 更新到 ${p.to}:组件 ${changed} 个更新、${added} 个新增、${removed} 个移除,影响 ${orgs} 个组织`,
356
454
  en: `Update platform plugin "${n.en}" from ${p.from ?? "none"} to ${p.to}: components ${changed} updated, ${added} added, ${removed} removed; ${orgs} orgs affected`,
357
455
  };
358
456
  },
359
- run: async (input, ctx) => asToolError(async () => {
360
- await this.assertNotOtherOrgs(input.itemId, ctx.orgId);
361
- return redactOrgs(await this.updater.update(ctx.actorAccountId, input.itemId, { version: input.version, diffHash: input.diffHash }, { auditDetail: viaAgent("plugins.update", ctx) }));
362
- }),
457
+ run: async (input, ctx) => {
458
+ await assertNotOtherOrgs(this.kdb.db, input.itemId, ctx.orgId);
459
+ return this.updater.update(ctx.actorAccountId, input.itemId, { version: input.version, diffHash: input.diffHash }, { auditDetail: viaAgent("plugins.update", ctx) });
460
+ },
363
461
  }),
364
462
  ]);
365
463
  }
@@ -372,6 +470,7 @@ PluginsOperations = __decorate([
372
470
  __param(3, Inject(PlatformPluginUpdater)),
373
471
  __param(4, Inject(PluginInstaller)),
374
472
  __param(5, Inject(OrgExtensionConfigs)),
375
- __param(6, Inject(KernelDb))
473
+ __param(6, Inject(KernelDb)),
474
+ __param(7, Inject(ExtensionAvailability))
376
475
  ], PluginsOperations);
377
476
  export { PluginsOperations };
@@ -0,0 +1,14 @@
1
+ import { type OnModuleInit } from "@nestjs/common";
2
+ import { PreviewerRegistry } from "../../files/previewers.js";
3
+ import { PlatformOperations } from "../registry.js";
4
+ /**
5
+ * File previewer operations (the `extensions` domain): the org's order of the previewers its
6
+ * extensions provide and which are off (org admins, `org.extensions.manage`). Rendering a preview
7
+ * is the web's (`transport`).
8
+ */
9
+ export declare class PreviewersOperations implements OnModuleInit {
10
+ private readonly registry;
11
+ private readonly previewers;
12
+ constructor(registry: PlatformOperations, previewers: PreviewerRegistry);
13
+ onModuleInit(): void;
14
+ }