@capybara-hq/kernel 0.1.0-rc.5 → 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 (362) hide show
  1. package/bootstrap.json +27 -3
  2. package/dist/admin/admin.controller.d.ts +21 -74
  3. package/dist/admin/admin.controller.js +50 -50
  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 +16 -6
  19. package/dist/agents/agents.service.js +75 -19
  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 +23 -6
  26. package/dist/agents/models.controller.d.ts +33 -5
  27. package/dist/agents/models.controller.js +50 -6
  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/readiness.controller.d.ts +5 -5
  39. package/dist/agents/readiness.controller.js +6 -6
  40. package/dist/agents/templates.controller.d.ts +8 -17
  41. package/dist/agents/templates.controller.js +13 -31
  42. package/dist/agents/templates.schemas.d.ts +20 -0
  43. package/dist/agents/templates.schemas.js +45 -0
  44. package/dist/background/background.controller.js +3 -2
  45. package/dist/background/background.schemas.d.ts +10 -0
  46. package/dist/background/background.schemas.js +16 -0
  47. package/dist/background/tasks.service.d.ts +1 -1
  48. package/dist/background/tasks.service.js +7 -2
  49. package/dist/catalog/admin-catalog.controller.d.ts +4 -57
  50. package/dist/catalog/admin-catalog.controller.js +8 -45
  51. package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
  52. package/dist/catalog/admin-catalog.schemas.js +92 -0
  53. package/dist/catalog/catalog-content.d.ts +12 -2
  54. package/dist/catalog/catalog-scope.service.js +8 -2
  55. package/dist/catalog/catalog.service.d.ts +2 -0
  56. package/dist/catalog/catalog.service.js +3 -0
  57. package/dist/catalog/component-scope.controller.d.ts +3 -65
  58. package/dist/catalog/component-scope.controller.js +3 -56
  59. package/dist/catalog/component-scope.schemas.d.ts +114 -0
  60. package/dist/catalog/component-scope.schemas.js +97 -0
  61. package/dist/catalog/component-scope.service.d.ts +28 -4
  62. package/dist/catalog/component-scope.service.js +55 -3
  63. package/dist/catalog/component-state.d.ts +9 -2
  64. package/dist/catalog/component-state.js +22 -13
  65. package/dist/catalog/marketplaces.controller.d.ts +5 -35
  66. package/dist/catalog/marketplaces.controller.js +6 -34
  67. package/dist/catalog/marketplaces.schemas.d.ts +48 -0
  68. package/dist/catalog/marketplaces.schemas.js +53 -0
  69. package/dist/catalog/marketplaces.service.d.ts +15 -1
  70. package/dist/catalog/marketplaces.service.js +22 -1
  71. package/dist/catalog/org-catalog.controller.d.ts +6 -62
  72. package/dist/catalog/org-catalog.controller.js +12 -66
  73. package/dist/catalog/org-catalog.schemas.d.ts +79 -0
  74. package/dist/catalog/org-catalog.schemas.js +82 -0
  75. package/dist/catalog/org-catalog.service.d.ts +9 -2
  76. package/dist/catalog/org-catalog.service.js +38 -5
  77. package/dist/catalog/org-extension.controller.d.ts +1 -12
  78. package/dist/catalog/org-extension.controller.js +1 -10
  79. package/dist/catalog/org-extension.schemas.d.ts +15 -0
  80. package/dist/catalog/org-extension.schemas.js +22 -0
  81. package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
  82. package/dist/catalog/org-plugin-uploads.controller.js +15 -28
  83. package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
  84. package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
  85. package/dist/catalog/owned-items.d.ts +6 -2
  86. package/dist/catalog/owned-items.js +16 -4
  87. package/dist/catalog/platform-components.d.ts +2 -0
  88. package/dist/catalog/platform-components.js +2 -0
  89. package/dist/catalog/plugin-import.js +1 -0
  90. package/dist/catalog/plugin-install.js +1 -1
  91. package/dist/catalog/requests.service.d.ts +2 -1
  92. package/dist/catalog/requests.service.js +6 -2
  93. package/dist/channels/channels.schemas.d.ts +33 -0
  94. package/dist/channels/channels.schemas.js +34 -0
  95. package/dist/channels/connections.controller.d.ts +2 -29
  96. package/dist/channels/connections.controller.js +1 -23
  97. package/dist/channels/connections.service.d.ts +8 -2
  98. package/dist/channels/connections.service.js +23 -5
  99. package/dist/channels/inbound.js +4 -0
  100. package/dist/config/schema.d.ts +4 -0
  101. package/dist/config/schema.js +24 -0
  102. package/dist/conversations/conversations.controller.d.ts +16 -37
  103. package/dist/conversations/conversations.controller.js +16 -56
  104. package/dist/conversations/conversations.schemas.d.ts +52 -0
  105. package/dist/conversations/conversations.schemas.js +79 -0
  106. package/dist/conversations/conversations.service.d.ts +13 -4
  107. package/dist/conversations/conversations.service.js +32 -26
  108. package/dist/conversations/events.d.ts +80 -6
  109. package/dist/conversations/events.js +60 -5
  110. package/dist/conversations/message-context.d.ts +28 -0
  111. package/dist/conversations/message-context.js +56 -0
  112. package/dist/conversations/queue.d.ts +2 -1
  113. package/dist/conversations/queue.js +11 -2
  114. package/dist/ctx/create-ctx.d.ts +15 -1
  115. package/dist/ctx/create-ctx.js +23 -2
  116. package/dist/db/kernel-schema.d.ts +44 -0
  117. package/dist/environments/environments.schemas.d.ts +3 -0
  118. package/dist/environments/environments.schemas.js +14 -0
  119. package/dist/environments/environments.service.d.ts +16 -4
  120. package/dist/environments/environments.service.js +58 -13
  121. package/dist/errors.d.ts +6 -0
  122. package/dist/errors.js +6 -0
  123. package/dist/evals/evals.schemas.d.ts +110 -0
  124. package/dist/evals/evals.schemas.js +107 -0
  125. package/dist/evals/reconstruct.js +18 -11
  126. package/dist/evals/recorded-tools.d.ts +2 -1
  127. package/dist/evals/recorded-tools.js +11 -3
  128. package/dist/evals/run-replay.d.ts +8 -1
  129. package/dist/evals/run-replay.js +17 -2
  130. package/dist/evals/runs.controller.d.ts +2 -57
  131. package/dist/evals/runs.controller.js +1 -42
  132. package/dist/evals/runs.service.d.ts +8 -7
  133. package/dist/evals/runs.service.js +45 -30
  134. package/dist/evals/sets.controller.d.ts +2 -28
  135. package/dist/evals/sets.controller.js +1 -31
  136. package/dist/evals/sets.service.d.ts +7 -7
  137. package/dist/evals/sets.service.js +23 -17
  138. package/dist/evals/snapshot.d.ts +3 -2
  139. package/dist/evals/snapshot.js +17 -4
  140. package/dist/evals/step-replay.d.ts +2 -1
  141. package/dist/evals/step-replay.js +3 -2
  142. package/dist/extensions/admin-ops.d.ts +5 -3
  143. package/dist/extensions/admin-ops.js +17 -12
  144. package/dist/extensions/config-hash.d.ts +10 -0
  145. package/dist/extensions/config-hash.js +38 -0
  146. package/dist/extensions/deployment-config.d.ts +16 -1
  147. package/dist/extensions/deployment-config.js +83 -0
  148. package/dist/extensions/extensions.module.js +9 -12
  149. package/dist/extensions/host.d.ts +39 -12
  150. package/dist/extensions/host.js +129 -51
  151. package/dist/extensions/installs.d.ts +5 -0
  152. package/dist/extensions/installs.js +12 -0
  153. package/dist/extensions/org-config.d.ts +17 -2
  154. package/dist/extensions/org-config.js +23 -4
  155. package/dist/extensions/point-defaults.controller.d.ts +2 -8
  156. package/dist/extensions/point-defaults.controller.js +1 -3
  157. package/dist/extensions/point-defaults.d.ts +3 -1
  158. package/dist/extensions/point-defaults.js +4 -2
  159. package/dist/extensions/point-defaults.schemas.d.ts +9 -0
  160. package/dist/extensions/point-defaults.schemas.js +14 -0
  161. package/dist/extensions/state.module.d.ts +9 -0
  162. package/dist/extensions/state.module.js +38 -0
  163. package/dist/extensions/unavailable.d.ts +49 -0
  164. package/dist/extensions/unavailable.js +113 -0
  165. package/dist/files/previewers.controller.js +2 -3
  166. package/dist/files/previewers.d.ts +1 -1
  167. package/dist/files/previewers.js +4 -4
  168. package/dist/files/previewers.schemas.d.ts +10 -0
  169. package/dist/files/previewers.schemas.js +9 -0
  170. package/dist/http/api.module.js +4 -0
  171. package/dist/http/plugin-dispatch.d.ts +4 -1
  172. package/dist/http/plugin-dispatch.js +14 -2
  173. package/dist/identity/accounts.d.ts +43 -4
  174. package/dist/identity/accounts.js +74 -6
  175. package/dist/identity/auth.guard.js +10 -1
  176. package/dist/identity/cookies.d.ts +6 -0
  177. package/dist/identity/cookies.js +14 -0
  178. package/dist/identity/identity.module.js +3 -0
  179. package/dist/identity/initial-passwords.controller.d.ts +22 -0
  180. package/dist/identity/initial-passwords.controller.js +49 -0
  181. package/dist/identity/initial-passwords.d.ts +61 -0
  182. package/dist/identity/initial-passwords.job.d.ts +16 -0
  183. package/dist/identity/initial-passwords.job.js +46 -0
  184. package/dist/identity/initial-passwords.js +159 -0
  185. package/dist/identity/me.controller.d.ts +14 -0
  186. package/dist/identity/me.controller.js +39 -1
  187. package/dist/identity/principal.d.ts +8 -0
  188. package/dist/identity/principal.js +8 -0
  189. package/dist/identity/settings.d.ts +3 -1
  190. package/dist/identity/settings.js +6 -4
  191. package/dist/inbox/inbox.schemas.d.ts +8 -0
  192. package/dist/inbox/inbox.schemas.js +11 -0
  193. package/dist/inbox/platform-inbox.controller.d.ts +1 -1
  194. package/dist/inbox/platform-inbox.controller.js +2 -2
  195. package/dist/index.d.ts +4 -0
  196. package/dist/index.js +6 -0
  197. package/dist/infra/config/kernel-config.service.js +3 -0
  198. package/dist/infra/events/kernel-events.d.ts +8 -0
  199. package/dist/lifecycle/kernel-lifecycle.js +4 -0
  200. package/dist/models/embeddings.d.ts +82 -0
  201. package/dist/models/embeddings.js +326 -0
  202. package/dist/models/enablement.controller.d.ts +40 -0
  203. package/dist/models/enablement.controller.js +74 -0
  204. package/dist/models/enablement.d.ts +101 -0
  205. package/dist/models/enablement.js +264 -0
  206. package/dist/models/models.module.d.ts +5 -1
  207. package/dist/models/models.module.js +16 -4
  208. package/dist/models/org-models.schemas.d.ts +8 -0
  209. package/dist/models/org-models.schemas.js +22 -0
  210. package/dist/models/prices.d.ts +3 -1
  211. package/dist/models/prices.js +7 -5
  212. package/dist/models/purposes.d.ts +30 -6
  213. package/dist/models/purposes.js +68 -17
  214. package/dist/orgs/orgs.controller.d.ts +2 -5
  215. package/dist/orgs/orgs.controller.js +3 -6
  216. package/dist/orgs/orgs.schemas.d.ts +8 -0
  217. package/dist/orgs/orgs.schemas.js +16 -0
  218. package/dist/orgs/orgs.service.d.ts +3 -1
  219. package/dist/orgs/orgs.service.js +6 -4
  220. package/dist/orgs/settings.service.d.ts +9 -1
  221. package/dist/orgs/settings.service.js +20 -5
  222. package/dist/overrides.d.ts +4 -0
  223. package/dist/overrides.js +2 -0
  224. package/dist/platform/errors.d.ts +21 -4
  225. package/dist/platform/errors.js +45 -6
  226. package/dist/platform/exclusions.d.ts +2 -3
  227. package/dist/platform/exclusions.js +68 -831
  228. package/dist/platform/method.js +1 -1
  229. package/dist/platform/operation.d.ts +82 -5
  230. package/dist/platform/operation.js +62 -7
  231. package/dist/platform/ops/accounts.ops.d.ts +32 -0
  232. package/dist/platform/ops/accounts.ops.js +291 -0
  233. package/dist/platform/ops/admin.ops.d.ts +36 -0
  234. package/dist/platform/ops/admin.ops.js +389 -0
  235. package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
  236. package/dist/platform/ops/agent-skills.ops.js +226 -0
  237. package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
  238. package/dist/platform/ops/agent-templates.ops.js +194 -14
  239. package/dist/platform/ops/agents.ops.d.ts +19 -1
  240. package/dist/platform/ops/agents.ops.js +481 -58
  241. package/dist/platform/ops/approvals.ops.d.ts +30 -0
  242. package/dist/platform/ops/approvals.ops.js +116 -0
  243. package/dist/platform/ops/background.ops.d.ts +14 -0
  244. package/dist/platform/ops/background.ops.js +134 -0
  245. package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
  246. package/dist/platform/ops/catalog-admin.ops.js +587 -0
  247. package/dist/platform/ops/channels.ops.d.ts +16 -0
  248. package/dist/platform/ops/channels.ops.js +195 -0
  249. package/dist/platform/ops/components.ops.d.ts +46 -0
  250. package/dist/platform/ops/components.ops.js +853 -0
  251. package/dist/platform/ops/connectors.ops.d.ts +4 -2
  252. package/dist/platform/ops/connectors.ops.js +68 -6
  253. package/dist/platform/ops/conversations.ops.d.ts +30 -0
  254. package/dist/platform/ops/conversations.ops.js +470 -0
  255. package/dist/platform/ops/environments.ops.d.ts +26 -0
  256. package/dist/platform/ops/environments.ops.js +289 -0
  257. package/dist/platform/ops/errors.d.ts +10 -5
  258. package/dist/platform/ops/errors.js +19 -11
  259. package/dist/platform/ops/evals.ops.d.ts +28 -0
  260. package/dist/platform/ops/evals.ops.js +783 -0
  261. package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
  262. package/dist/platform/ops/extensions-admin.ops.js +344 -0
  263. package/dist/platform/ops/extensions.ops.d.ts +7 -1
  264. package/dist/platform/ops/extensions.ops.js +248 -17
  265. package/dist/platform/ops/inbox.ops.d.ts +25 -0
  266. package/dist/platform/ops/inbox.ops.js +378 -0
  267. package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
  268. package/dist/platform/ops/marketplaces.ops.js +326 -17
  269. package/dist/platform/ops/models.ops.d.ts +25 -0
  270. package/dist/platform/ops/models.ops.js +232 -0
  271. package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
  272. package/dist/platform/ops/org-plugins.ops.js +329 -0
  273. package/dist/platform/ops/org-settings.ops.d.ts +16 -0
  274. package/dist/platform/ops/org-settings.ops.js +102 -0
  275. package/dist/platform/ops/orgs.ops.d.ts +28 -0
  276. package/dist/platform/ops/orgs.ops.js +295 -0
  277. package/dist/platform/ops/other-orgs.d.ts +20 -0
  278. package/dist/platform/ops/other-orgs.js +72 -0
  279. package/dist/platform/ops/platform.ops.d.ts +4 -4
  280. package/dist/platform/ops/platform.ops.js +23 -24
  281. package/dist/platform/ops/plugins.ops.d.ts +10 -8
  282. package/dist/platform/ops/plugins.ops.js +176 -77
  283. package/dist/platform/ops/previewers.ops.d.ts +14 -0
  284. package/dist/platform/ops/previewers.ops.js +109 -0
  285. package/dist/platform/ops/requests.ops.js +57 -19
  286. package/dist/platform/ops/skills.ops.d.ts +5 -1
  287. package/dist/platform/ops/skills.ops.js +129 -11
  288. package/dist/platform/ops/unavailable.d.ts +23 -0
  289. package/dist/platform/ops/unavailable.js +111 -0
  290. package/dist/platform/parity.d.ts +33 -0
  291. package/dist/platform/parity.js +272 -0
  292. package/dist/platform/platform-ops.module.d.ts +32 -0
  293. package/dist/platform/platform-ops.module.js +78 -11
  294. package/dist/platform/route-schemas.d.ts +18 -0
  295. package/dist/platform/route-schemas.js +60 -0
  296. package/dist/roles/worker.module.js +2 -0
  297. package/dist/runtime/context/build.d.ts +2 -0
  298. package/dist/runtime/context/build.js +28 -2
  299. package/dist/runtime/context/compaction.js +10 -1
  300. package/dist/runtime/context/run-context.d.ts +65 -0
  301. package/dist/runtime/context/run-context.js +215 -0
  302. package/dist/runtime/hook-calls.d.ts +8 -1
  303. package/dist/runtime/hook-calls.js +40 -9
  304. package/dist/runtime/model-call.d.ts +8 -3
  305. package/dist/runtime/model-call.js +30 -6
  306. package/dist/runtime/providers.d.ts +146 -32
  307. package/dist/runtime/providers.js +328 -67
  308. package/dist/runtime/run-context.service.d.ts +65 -0
  309. package/dist/runtime/run-context.service.js +220 -0
  310. package/dist/runtime/run-worker.d.ts +6 -1
  311. package/dist/runtime/run-worker.js +35 -10
  312. package/dist/runtime/runtime.module.js +2 -0
  313. package/dist/runtime/subagents/definition.d.ts +15 -15
  314. package/dist/runtime/subagents/definition.js +49 -118
  315. package/dist/runtime/usage-report-jobs.d.ts +88 -0
  316. package/dist/runtime/usage-report-jobs.js +158 -0
  317. package/dist/runtime/usage-report.d.ts +33 -38
  318. package/dist/runtime/usage-report.js +152 -84
  319. package/dist/skills/changes.controller.js +2 -1
  320. package/dist/skills/changes.service.d.ts +1 -1
  321. package/dist/skills/changes.service.js +4 -4
  322. package/dist/skills/invocable.controller.d.ts +1 -1
  323. package/dist/skills/invocable.controller.js +2 -2
  324. package/dist/skills/invoke.d.ts +2 -2
  325. package/dist/skills/invoke.js +8 -1
  326. package/dist/skills/skills.controller.d.ts +4 -13
  327. package/dist/skills/skills.controller.js +8 -24
  328. package/dist/skills/skills.schemas.d.ts +48 -0
  329. package/dist/skills/skills.schemas.js +61 -0
  330. package/dist/skills/skills.service.d.ts +11 -1
  331. package/dist/skills/skills.service.js +37 -14
  332. package/dist/time-zone.d.ts +5 -0
  333. package/dist/time-zone.js +19 -0
  334. package/dist/tools/approvals.controller.js +2 -3
  335. package/dist/tools/approvals.schemas.d.ts +21 -0
  336. package/dist/tools/approvals.schemas.js +15 -0
  337. package/dist/tools/builtin-names.d.ts +10 -8
  338. package/dist/tools/builtin-names.js +16 -11
  339. package/dist/tools/builtins/builtin-tools.d.ts +3 -1
  340. package/dist/tools/builtins/builtin-tools.js +15 -3
  341. package/dist/tools/builtins/current-time.d.ts +26 -0
  342. package/dist/tools/builtins/current-time.js +99 -0
  343. package/dist/tools/builtins/platform.d.ts +19 -2
  344. package/dist/tools/builtins/platform.js +105 -16
  345. package/dist/tools/connectors.controller.d.ts +1 -2
  346. package/dist/tools/connectors.controller.js +1 -4
  347. package/dist/tools/connectors.schemas.d.ts +12 -0
  348. package/dist/tools/connectors.schemas.js +19 -0
  349. package/dist/tools/connectors.service.d.ts +5 -2
  350. package/dist/tools/connectors.service.js +7 -5
  351. package/dist/tools/org-tool-switches.d.ts +16 -2
  352. package/dist/tools/org-tool-switches.js +26 -9
  353. package/dist/tools/pipeline.js +9 -1
  354. package/dist/tools/registry.d.ts +48 -51
  355. package/dist/tools/registry.js +222 -233
  356. package/package.json +3 -3
  357. package/src/migrations/0089_model_kinds_usage.sql +38 -0
  358. package/src/migrations/0090_initial_passwords.sql +27 -0
  359. package/src/migrations/0091_account_time_zone.sql +4 -0
  360. package/src/migrations/0092_tools_default_on.sql +27 -0
  361. package/dist/platform/redact-orgs.d.ts +0 -7
  362. package/dist/platform/redact-orgs.js +0 -52
@@ -1,20 +1,12 @@
1
1
  import type { FastifyReply } from "fastify";
2
2
  import { z } from "zod";
3
3
  import { type Principal } from "../identity/principal.js";
4
+ import { CatalogItemsQuery, CatalogUpdateBody, CatalogUpdatePreviewBody, CatalogDisabledBody as DisabledBody, CatalogGitImportBody as GitBody, CatalogNpmImportBody as NpmBody, CatalogScopeBody as ScopeBody, CatalogScopePreviewBody as ScopePreviewBody, CatalogShownBody as ShownBody } from "./admin-catalog.schemas.js";
4
5
  import { type CatalogItemDetail, type CatalogItemView, CatalogService, type PermissionsMismatch } from "./catalog.service.js";
5
6
  import { CatalogScopeService, type ScopePreview } from "./catalog-scope.service.js";
6
7
  import { OrgCatalogService } from "./org-catalog.service.js";
7
8
  import { type PluginConfirmResult, PluginImport, type PluginReview } from "./plugin-import.js";
8
9
  import { PlatformPluginUpdater, type PlatformUpdatePreview, type PlatformUpdateResult } from "./plugin-upgrade.js";
9
- declare const NpmBody: z.ZodObject<{
10
- package: z.ZodString;
11
- version: z.ZodOptional<z.ZodString>;
12
- }, z.core.$strip>;
13
- declare const GitBody: z.ZodObject<{
14
- url: z.ZodString;
15
- ref: z.ZodOptional<z.ZodString>;
16
- path: z.ZodOptional<z.ZodString>;
17
- }, z.core.$strict>;
18
10
  declare const ConfirmBody: z.ZodObject<{
19
11
  reviewHash: z.ZodString;
20
12
  scope: z.ZodOptional<z.ZodEnum<{
@@ -25,44 +17,6 @@ declare const ConfirmBody: z.ZodObject<{
25
17
  orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
18
  pinnedSuggestions: z.ZodOptional<z.ZodArray<z.ZodString>>;
27
19
  }, z.core.$strict>;
28
- /** `{ scope, orgs? }` (a scope change) or `{ disabled: true }` (a disable), not both. */
29
- declare const ScopePreviewBody: z.ZodObject<{
30
- scope: z.ZodOptional<z.ZodEnum<{
31
- all: "all";
32
- named: "named";
33
- optional: "optional";
34
- }>>;
35
- orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
36
- disabled: z.ZodOptional<z.ZodLiteral<true>>;
37
- }, z.core.$strict>;
38
- declare const ScopeBody: z.ZodObject<{
39
- scope: z.ZodEnum<{
40
- all: "all";
41
- named: "named";
42
- optional: "optional";
43
- }>;
44
- orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
- scopeHash: z.ZodString;
46
- }, z.core.$strict>;
47
- declare const DisabledBody: z.ZodObject<{
48
- disabled: z.ZodBoolean;
49
- scopeHash: z.ZodOptional<z.ZodString>;
50
- }, z.core.$strict>;
51
- declare const ShownBody: z.ZodObject<{
52
- shownToOthers: z.ZodBoolean;
53
- }, z.core.$strict>;
54
- declare const ListQuery: z.ZodObject<{
55
- includeDeleted: z.ZodOptional<z.ZodEnum<{
56
- false: "false";
57
- true: "true";
58
- }>>;
59
- limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
60
- offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
61
- pending: z.ZodOptional<z.ZodEnum<{
62
- false: "false";
63
- true: "true";
64
- }>>;
65
- }, z.core.$strip>;
66
20
  declare const ConfirmPermissionsBody: z.ZodObject<{
67
21
  permissionsHash: z.ZodString;
68
22
  }, z.core.$strict>;
@@ -70,13 +24,6 @@ declare const ConfirmPermissionsBody: z.ZodObject<{
70
24
  declare const RejectBody: z.ZodObject<{
71
25
  reason: z.ZodOptional<z.ZodString>;
72
26
  }, z.core.$strict>;
73
- declare const UpdatePreviewBody: z.ZodObject<{
74
- version: z.ZodString;
75
- }, z.core.$strict>;
76
- declare const UpdateBody: z.ZodObject<{
77
- version: z.ZodString;
78
- diffHash: z.ZodString;
79
- }, z.core.$strict>;
80
27
  /**
81
28
  * The platform catalog (`/api/v1/admin/catalog/*`, super admins): plugin import (upload / npm
82
29
  * prepare, then confirm, which installs the plugin's extension), the item list and detail, scope and
@@ -157,7 +104,7 @@ export declare class AdminCatalogController {
157
104
  * The item list (`includeDeleted=true` includes deleted items). Paging: `limit` (default 200, at
158
105
  * most 1000) and `offset`; `nextOffset` is the next page's offset, null when there is none.
159
106
  */
160
- list(q: z.infer<typeof ListQuery>): Promise<{
107
+ list(q: z.infer<typeof CatalogItemsQuery>): Promise<{
161
108
  items: CatalogItemView[];
162
109
  nextOffset: number | null;
163
110
  }>;
@@ -226,7 +173,7 @@ export declare class AdminCatalogController {
226
173
  * `plugin.upgrade_target_invalid`; an added skill named like one in use where the plugin is on
227
174
  * -> 409 `plugin.skill_conflict`; disabled -> 403 `catalog.item_disabled`.
228
175
  */
229
- previewUpdate(id: string, body: z.infer<typeof UpdatePreviewBody>): Promise<PlatformUpdatePreview>;
176
+ previewUpdate(id: string, body: z.infer<typeof CatalogUpdatePreviewBody>): Promise<PlatformUpdatePreview>;
230
177
  /**
231
178
  * Updates the platform plugin, confirmed with the preview's `diffHash` (recomputed under the item
232
179
  * lock; a difference -> 409 `plugin.upgrade_stale`; another update running -> 409
@@ -235,7 +182,7 @@ export declare class AdminCatalogController {
235
182
  * version waits) -> 409 `catalog.item_pending`: confirm it in 待确认 (pre-flight F8); the
236
183
  * preview answers the same.
237
184
  */
238
- update(principal: Principal, id: string, body: z.infer<typeof UpdateBody>): Promise<PlatformUpdateResult>;
185
+ update(principal: Principal, id: string, body: z.infer<typeof CatalogUpdateBody>): Promise<PlatformUpdateResult>;
239
186
  /** 删除条目(软删除,已安装的组件不受影响)。 */
240
187
  remove(principal: Principal, id: string): Promise<void>;
241
188
  }
@@ -13,26 +13,13 @@ import { ApiError } from "../errors.js";
13
13
  import { CurrentPrincipal, patTokenId, requireUser, SuperAdmin, } from "../identity/principal.js";
14
14
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
15
15
  import { ZBody, ZQuery } from "../infra/validation/zod-params.js";
16
- import { CATALOG_LIST_MAX_LIMIT, CatalogService, } from "./catalog.service.js";
16
+ import { CatalogItemsQuery, CatalogUpdateBody, CatalogUpdatePreviewBody, CatalogDisabledBody as DisabledBody, CatalogGitImportBody as GitBody, CatalogHash as Hash, CatalogNpmImportBody as NpmBody, CatalogScopeOrgs as Orgs, CatalogScope as Scope, CatalogScopeBody as ScopeBody, CatalogScopePreviewBody as ScopePreviewBody, CatalogShownBody as ShownBody, } from "./admin-catalog.schemas.js";
17
+ import { CatalogService, } from "./catalog.service.js";
17
18
  import { CatalogScopeService } from "./catalog-scope.service.js";
18
19
  import { sendCatalogIcon } from "./org-catalog.controller.js";
19
20
  import { OrgCatalogService } from "./org-catalog.service.js";
20
21
  import { PluginImport } from "./plugin-import.js";
21
22
  import { PlatformPluginUpdater, } from "./plugin-upgrade.js";
22
- const NpmBody = z.object({
23
- package: z.string().min(1).max(214),
24
- version: z.string().min(1).max(256).optional(),
25
- });
26
- const GitBody = z
27
- .object({
28
- url: z.string().min(1).max(2000),
29
- ref: z.string().min(1).max(256).optional(),
30
- path: z.string().min(1).max(512).optional(),
31
- })
32
- .strict();
33
- const Scope = z.enum(["all", "optional", "named"]);
34
- const Orgs = z.array(z.string().min(1).max(128)).max(1000);
35
- const Hash = z.string().min(1).max(128);
36
23
  const ConfirmBody = z
37
24
  .object({
38
25
  reviewHash: Hash,
@@ -43,33 +30,9 @@ const ConfirmBody = z
43
30
  pinnedSuggestions: z.array(z.string().min(1).max(64)).max(50).optional(),
44
31
  })
45
32
  .strict();
46
- /** `{ scope, orgs? }` (a scope change) or `{ disabled: true }` (a disable), not both. */
47
- const ScopePreviewBody = z
48
- .object({ scope: Scope.optional(), orgs: Orgs.optional(), disabled: z.literal(true).optional() })
49
- .strict()
50
- .refine((b) => (b.disabled === true) !== (b.scope !== undefined), {
51
- message: "send either scope (with orgs for named) or disabled: true",
52
- })
53
- .refine((b) => b.disabled === undefined || b.orgs === undefined, {
54
- message: "orgs: only allowed with scope named",
55
- path: ["orgs"],
56
- });
57
- const ScopeBody = z.object({ scope: Scope, orgs: Orgs.optional(), scopeHash: Hash }).strict();
58
- const DisabledBody = z.object({ disabled: z.boolean(), scopeHash: Hash.optional() }).strict();
59
- const ShownBody = z.object({ shownToOthers: z.boolean() }).strict();
60
- const ListQuery = z.object({
61
- includeDeleted: z.enum(["true", "false"]).optional(),
62
- limit: z.coerce.number().int().min(1).max(CATALOG_LIST_MAX_LIMIT).optional(),
63
- offset: z.coerce.number().int().min(0).max(1_000_000).optional(),
64
- /** `true`: only the items waiting for a permission confirmation (not paged). */
65
- pending: z.enum(["true", "false"]).optional(),
66
- });
67
33
  const ConfirmPermissionsBody = z.object({ permissionsHash: Hash }).strict();
68
34
  /** The reason shown to the owner org in its `upload_rejected` notice (optional). */
69
35
  const RejectBody = z.object({ reason: z.string().trim().min(1).max(1000).optional() }).strict();
70
- const Version = z.string().min(1).max(256);
71
- const UpdatePreviewBody = z.object({ version: Version }).strict();
72
- const UpdateBody = z.object({ version: Version, diffHash: Hash }).strict();
73
36
  const actorOpts = (actor) => {
74
37
  const tokenId = patTokenId(actor);
75
38
  return tokenId !== undefined ? { actorTokenId: tokenId } : {};
@@ -78,7 +41,7 @@ class CatalogImportConfirmBody extends createZodDto(ConfirmBody, "CatalogImportC
78
41
  }
79
42
  class CatalogGitImportBody extends createZodDto(GitBody, "CatalogGitImportBody") {
80
43
  }
81
- class CatalogItemsQuery extends createZodDto(ListQuery, "CatalogItemsQuery") {
44
+ class CatalogItemsQueryDto extends createZodDto(CatalogItemsQuery, "CatalogItemsQuery") {
82
45
  }
83
46
  class CatalogNpmImportBody extends createZodDto(NpmBody, "CatalogNpmImportBody") {
84
47
  }
@@ -94,9 +57,9 @@ class CatalogRejectBody extends createZodDto(RejectBody, "CatalogRejectBody") {
94
57
  }
95
58
  class CatalogDisabledBody extends createZodDto(DisabledBody, "CatalogDisabledBody") {
96
59
  }
97
- class CatalogUpdatePreviewBody extends createZodDto(UpdatePreviewBody, "CatalogUpdatePreviewBody") {
60
+ class CatalogUpdatePreviewBodyDto extends createZodDto(CatalogUpdatePreviewBody, "CatalogUpdatePreviewBody") {
98
61
  }
99
- class CatalogUpdateBody extends createZodDto(UpdateBody, "CatalogUpdateBody") {
62
+ class CatalogUpdateBodyDto extends createZodDto(CatalogUpdateBody, "CatalogUpdateBody") {
100
63
  }
101
64
  /**
102
65
  * The platform catalog (`/api/v1/admin/catalog/*`, super admins): plugin import (upload / npm
@@ -351,7 +314,7 @@ __decorate([
351
314
  ], AdminCatalogController.prototype, "confirm", null);
352
315
  __decorate([
353
316
  Get("items"),
354
- __param(0, ZQuery(CatalogItemsQuery))
317
+ __param(0, ZQuery(CatalogItemsQueryDto))
355
318
  ], AdminCatalogController.prototype, "list", null);
356
319
  __decorate([
357
320
  Get("items/:id"),
@@ -404,13 +367,13 @@ __decorate([
404
367
  Post("items/:id/update/preview"),
405
368
  HttpCode(200),
406
369
  __param(0, Param("id")),
407
- __param(1, ZBody(CatalogUpdatePreviewBody))
370
+ __param(1, ZBody(CatalogUpdatePreviewBodyDto))
408
371
  ], AdminCatalogController.prototype, "previewUpdate", null);
409
372
  __decorate([
410
373
  Put("items/:id/update"),
411
374
  __param(0, CurrentPrincipal()),
412
375
  __param(1, Param("id")),
413
- __param(2, ZBody(CatalogUpdateBody))
376
+ __param(2, ZBody(CatalogUpdateBodyDto))
414
377
  ], AdminCatalogController.prototype, "update", null);
415
378
  __decorate([
416
379
  Delete("items/:id"),
@@ -0,0 +1,72 @@
1
+ import { z } from "zod";
2
+ import type { RouteSchemas } from "../platform/route-schemas.js";
3
+ export declare const CatalogHash: z.ZodString;
4
+ export declare const CatalogItemsQuery: z.ZodObject<{
5
+ includeDeleted: z.ZodOptional<z.ZodEnum<{
6
+ false: "false";
7
+ true: "true";
8
+ }>>;
9
+ limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
10
+ offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
11
+ pending: z.ZodOptional<z.ZodEnum<{
12
+ false: "false";
13
+ true: "true";
14
+ }>>;
15
+ }, z.core.$strip>;
16
+ export declare const CatalogUpdatePreviewBody: z.ZodObject<{
17
+ version: z.ZodString;
18
+ }, z.core.$strict>;
19
+ export declare const CatalogUpdateBody: z.ZodObject<{
20
+ version: z.ZodString;
21
+ diffHash: z.ZodString;
22
+ }, z.core.$strict>;
23
+ /** `:id` as the routes take it (`@Param`). */
24
+ export declare const CatalogIdPathParams: z.ZodObject<{
25
+ id: z.ZodString;
26
+ }, z.core.$strip>;
27
+ /** `:stagingId` of a staged import as the route takes it (`@Param`). */
28
+ export declare const CatalogStagingPathParams: z.ZodObject<{
29
+ stagingId: z.ZodString;
30
+ }, z.core.$strip>;
31
+ export declare const CatalogNpmImportBody: z.ZodObject<{
32
+ package: z.ZodString;
33
+ version: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strip>;
35
+ export declare const CatalogGitImportBody: z.ZodObject<{
36
+ url: z.ZodString;
37
+ ref: z.ZodOptional<z.ZodString>;
38
+ path: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strict>;
40
+ export declare const CatalogScope: z.ZodEnum<{
41
+ all: "all";
42
+ named: "named";
43
+ optional: "optional";
44
+ }>;
45
+ export declare const CatalogScopeOrgs: z.ZodArray<z.ZodString>;
46
+ /** `{ scope, orgs? }` (a scope change) or `{ disabled: true }` (a disable), not both. */
47
+ export declare const CatalogScopePreviewBody: z.ZodObject<{
48
+ scope: z.ZodOptional<z.ZodEnum<{
49
+ all: "all";
50
+ named: "named";
51
+ optional: "optional";
52
+ }>>;
53
+ orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
54
+ disabled: z.ZodOptional<z.ZodLiteral<true>>;
55
+ }, z.core.$strict>;
56
+ export declare const CatalogScopeBody: z.ZodObject<{
57
+ scope: z.ZodEnum<{
58
+ all: "all";
59
+ named: "named";
60
+ optional: "optional";
61
+ }>;
62
+ orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
63
+ scopeHash: z.ZodString;
64
+ }, z.core.$strict>;
65
+ export declare const CatalogDisabledBody: z.ZodObject<{
66
+ disabled: z.ZodBoolean;
67
+ scopeHash: z.ZodOptional<z.ZodString>;
68
+ }, z.core.$strict>;
69
+ export declare const CatalogShownBody: z.ZodObject<{
70
+ shownToOthers: z.ZodBoolean;
71
+ }, z.core.$strict>;
72
+ export declare const ADMIN_CATALOG_ROUTES: readonly RouteSchemas[];
@@ -0,0 +1,92 @@
1
+ import { z } from "zod";
2
+ import { CATALOG_LIST_MAX_LIMIT } from "./catalog.service.js";
3
+ export const CatalogHash = z.string().min(1).max(128);
4
+ export const CatalogItemsQuery = z.object({
5
+ includeDeleted: z.enum(["true", "false"]).optional(),
6
+ limit: z.coerce.number().int().min(1).max(CATALOG_LIST_MAX_LIMIT).optional(),
7
+ offset: z.coerce.number().int().min(0).max(1_000_000).optional(),
8
+ /** `true`: only the items waiting for a permission confirmation (not paged). */
9
+ pending: z.enum(["true", "false"]).optional(),
10
+ });
11
+ const CatalogVersion = z.string().min(1).max(256);
12
+ export const CatalogUpdatePreviewBody = z.object({ version: CatalogVersion }).strict();
13
+ export const CatalogUpdateBody = z
14
+ .object({ version: CatalogVersion, diffHash: CatalogHash })
15
+ .strict();
16
+ /** `:id` as the routes take it (`@Param`). */
17
+ export const CatalogIdPathParams = z.object({ id: z.string().min(1) });
18
+ /** `:stagingId` of a staged import as the route takes it (`@Param`). */
19
+ export const CatalogStagingPathParams = z.object({ stagingId: z.string().min(1) });
20
+ export const CatalogNpmImportBody = z.object({
21
+ package: z.string().min(1).max(214),
22
+ version: z.string().min(1).max(256).optional(),
23
+ });
24
+ export const CatalogGitImportBody = z
25
+ .object({
26
+ url: z.string().min(1).max(2000),
27
+ ref: z.string().min(1).max(256).optional(),
28
+ path: z.string().min(1).max(512).optional(),
29
+ })
30
+ .strict();
31
+ export const CatalogScope = z.enum(["all", "optional", "named"]);
32
+ export const CatalogScopeOrgs = z.array(z.string().min(1).max(128)).max(1000);
33
+ /** `{ scope, orgs? }` (a scope change) or `{ disabled: true }` (a disable), not both. */
34
+ export const CatalogScopePreviewBody = z
35
+ .object({
36
+ scope: CatalogScope.optional(),
37
+ orgs: CatalogScopeOrgs.optional(),
38
+ disabled: z.literal(true).optional(),
39
+ })
40
+ .strict()
41
+ .refine((b) => (b.disabled === true) !== (b.scope !== undefined), {
42
+ message: "send either scope (with orgs for named) or disabled: true",
43
+ })
44
+ .refine((b) => b.disabled === undefined || b.orgs === undefined, {
45
+ message: "orgs: only allowed with scope named",
46
+ path: ["orgs"],
47
+ });
48
+ export const CatalogScopeBody = z
49
+ .object({ scope: CatalogScope, orgs: CatalogScopeOrgs.optional(), scopeHash: CatalogHash })
50
+ .strict();
51
+ export const CatalogDisabledBody = z
52
+ .object({ disabled: z.boolean(), scopeHash: CatalogHash.optional() })
53
+ .strict();
54
+ export const CatalogShownBody = z.object({ shownToOthers: z.boolean() }).strict();
55
+ export const ADMIN_CATALOG_ROUTES = [
56
+ { route: "GET /api/v1/admin/catalog/items", query: CatalogItemsQuery },
57
+ { route: "GET /api/v1/admin/catalog/items/:id", params: CatalogIdPathParams },
58
+ {
59
+ route: "POST /api/v1/admin/catalog/items/:id/update/preview",
60
+ params: CatalogIdPathParams,
61
+ body: CatalogUpdatePreviewBody,
62
+ },
63
+ {
64
+ route: "PUT /api/v1/admin/catalog/items/:id/update",
65
+ params: CatalogIdPathParams,
66
+ body: CatalogUpdateBody,
67
+ },
68
+ { route: "POST /api/v1/admin/catalog/import/npm", body: CatalogNpmImportBody },
69
+ { route: "POST /api/v1/admin/catalog/import/git", body: CatalogGitImportBody },
70
+ { route: "GET /api/v1/admin/catalog/imports/:stagingId", params: CatalogStagingPathParams },
71
+ {
72
+ route: "POST /api/v1/admin/catalog/items/:id/scope/preview",
73
+ params: CatalogIdPathParams,
74
+ body: CatalogScopePreviewBody,
75
+ },
76
+ {
77
+ route: "PUT /api/v1/admin/catalog/items/:id/scope",
78
+ params: CatalogIdPathParams,
79
+ body: CatalogScopeBody,
80
+ },
81
+ {
82
+ route: "PUT /api/v1/admin/catalog/items/:id/disabled",
83
+ params: CatalogIdPathParams,
84
+ body: CatalogDisabledBody,
85
+ },
86
+ {
87
+ route: "PUT /api/v1/admin/catalog/items/:id/shown",
88
+ params: CatalogIdPathParams,
89
+ body: CatalogShownBody,
90
+ },
91
+ { route: "DELETE /api/v1/admin/catalog/items/:id", params: CatalogIdPathParams },
92
+ ];
@@ -1,6 +1,7 @@
1
1
  import { type AgentTemplate, type Connector, type ConnectorTemplateFile, type ConnectorTemplateSpec, type LocalizedName, type PluginManifest } from "@capybara-hq/plugin-sdk";
2
2
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
3
3
  import type { ExtensionRegistry } from "../extensions/registry.js";
4
+ import type { ExtensionUnavailableReason } from "../extensions/unavailable.js";
4
5
  import type { OrgLock } from "../orgs/org-lock.js";
5
6
  import { type OrgAction } from "../orgs/roles.js";
6
7
  import { checkSkillFiles, type SkillPackageFile } from "../skills/package.js";
@@ -10,6 +11,8 @@ import type { CatalogItemView } from "./catalog.service.js";
10
11
  import type { ConnectorInstallInput, PluginInstallInput, PluginInstallView } from "./plugin-install.js";
11
12
  import type { OrgPluginState, PluginScope } from "./scope.js";
12
13
  /** A catalog item from an organization's view (`GET /orgs/:orgId/catalog`). */
14
+ /** Why an org's plugin is `unavailable` ({@link OrgCatalogItem.reason}). */
15
+ export type PluginUnavailableReason = "plugin_disabled" | ExtensionUnavailableReason;
13
16
  export interface OrgCatalogItem extends Omit<CatalogItemView, "installs" | "marketplaceId" | "latestMarketplaceVersion" | "newerInMarketplace" | "scopeOrgs" | "enabledOrgs" | "offCount" | "pending" | "shownToOthers" | "awaitingConfirmation" | "pendingVersion"> {
14
17
  /** The owner org only (absent for other orgs): its upload waits for the super admin (P3-9). */
15
18
  awaitingConfirmation?: boolean;
@@ -21,10 +24,17 @@ export interface OrgCatalogItem extends Omit<CatalogItemView, "installs" | "mark
21
24
  /**
22
25
  * The effective state in this org: `on`, `off`, `needs_config` (installed with an on connector
23
26
  * template that has no connector here, ruling P2-10; or wanted but not installed, and the
24
- * install needs inputs), `unavailable` (disabled by the super admin; members don't see it)
25
- * or `not_offered` (a `named` item shown to orgs outside its list: requestable, not usable).
27
+ * install needs inputs), `unavailable` (disabled by the super admin, members don't see it; or
28
+ * not installed here and its extension cannot run on the deployment, see `reason`) or
29
+ * `not_offered` (a `named` item shown to orgs outside its list: requestable, not usable).
26
30
  */
27
31
  state: OrgPluginState;
32
+ /**
33
+ * Only when `unavailable`: why (Platform tool spec §14.2 problem 1). `plugin_disabled`: the super
34
+ * admin disabled the item; otherwise its extension's {@link ExtensionUnavailableReason}, the same
35
+ * one the org's 扩展 page shows.
36
+ */
37
+ reason?: PluginUnavailableReason;
28
38
  /** The org admin may switch it (never for `all` and builtin items). */
29
39
  switchable: boolean;
30
40
  /** The plugin's extension (or a template's connector extension) is not on the deployment. */
@@ -596,6 +596,7 @@ let CatalogScopeService = class CatalogScopeService {
596
596
  ownerOrgId: item.owner_org_id,
597
597
  removed: item.awaiting_confirmation,
598
598
  ...(how.kind === "reject" && { reason: how.reason }),
599
+ ...opts.auditDetail,
599
600
  },
600
601
  });
601
602
  }
@@ -661,7 +662,7 @@ let CatalogScopeService = class CatalogScopeService {
661
662
  ...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
662
663
  action: "catalog.shown_changed",
663
664
  target: itemId,
664
- detail: { name: item.name, from: item.shown_to_others, to: shown },
665
+ detail: { name: item.name, from: item.shown_to_others, to: shown, ...opts.auditDetail },
665
666
  });
666
667
  }
667
668
  async writeScope(actor, itemId, target, hash, opts) {
@@ -710,6 +711,7 @@ let CatalogScopeService = class CatalogScopeService {
710
711
  name: item.name,
711
712
  from: { scope: item.scope, orgs: from },
712
713
  to: { scope: t.scope, orgs: t.orgs },
714
+ ...opts.auditDetail,
713
715
  },
714
716
  });
715
717
  afterCommit(() => this.enqueue(itemId));
@@ -740,7 +742,11 @@ let CatalogScopeService = class CatalogScopeService {
740
742
  ...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
741
743
  action: "catalog.scope_changed",
742
744
  target: itemId,
743
- detail: { name: item.name, disabled: { from: item.disabled, to: disabled } },
745
+ detail: {
746
+ name: item.name,
747
+ disabled: { from: item.disabled, to: disabled },
748
+ ...opts.auditDetail,
749
+ },
744
750
  });
745
751
  afterCommit(() => this.enqueue(itemId));
746
752
  }
@@ -186,6 +186,8 @@ export interface CatalogItemDetail {
186
186
  /** Audits carry the PAT when a personal token made the call. */
187
187
  export interface ActorOpts {
188
188
  actorTokenId?: string;
189
+ /** Merged into the audit detail (a write made through the Platform tool: `via`, …). */
190
+ auditDetail?: Record<string, unknown>;
189
191
  }
190
192
  /**
191
193
  * The marketplace's permission summary differs from the keys computed from the package (a warning,
@@ -164,6 +164,7 @@ let CatalogService = class CatalogService {
164
164
  }
165
165
  const prepareOpts = {
166
166
  ...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
167
+ ...(opts.auditDetail !== undefined && { auditDetail: opts.auditDetail }),
167
168
  expect: {
168
169
  marketplace: {
169
170
  name: entry.name,
@@ -300,6 +301,7 @@ let CatalogService = class CatalogService {
300
301
  : where.detail.path.split("/").pop();
301
302
  const r = await this.pluginImport.prepareGit(actor, read.files, { kind: "git", ref: where.ref, detail: where.detail }, {
302
303
  ...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
304
+ ...(opts.auditDetail !== undefined && { auditDetail: opts.auditDetail }),
303
305
  fallback: {
304
306
  name: pluginNameFrom(segment),
305
307
  version: gitFallbackVersion(read.commit),
@@ -520,6 +522,7 @@ let CatalogService = class CatalogService {
520
522
  name: row.name,
521
523
  ...(row.owner_org_id !== null && { ownerOrgId: row.owner_org_id }),
522
524
  ...(opts.reason !== undefined && { reason: opts.reason }),
525
+ ...opts.auditDetail,
523
526
  },
524
527
  });
525
528
  return { name: row.name };
@@ -1,70 +1,9 @@
1
- import { z } from "zod";
1
+ import type { z } from "zod";
2
2
  import { type Principal } from "../identity/principal.js";
3
3
  import { type OrgContext } from "../orgs/org.guard.js";
4
+ import { ComponentParams, ComponentDisabledSchema as DisabledBody, ComponentIdSchema as IdParams, ComponentListQuery as ListQuery, OrgComponentListQuery, ComponentScopePreviewSchema as PreviewBody, ComponentScopeSchema as ScopeBody, ComponentShownSchema as ShownBody, ComponentSwitchBody as SwitchBody, ComponentTemplateVersionSchema as TemplateVersionBody } from "./component-scope.schemas.js";
4
5
  import { type ComponentScopePreview, ComponentScopeService, type ComponentVersionView, type ComponentView, type OrgComponentView, type OrgOfferedComponentView } from "./component-scope.service.js";
5
6
  import { PlatformComponents, type UploadedComponentVersion } from "./platform-components.js";
6
- declare const ComponentParams: z.ZodObject<{
7
- kind: z.ZodEnum<{
8
- agent_template: "agent_template";
9
- connector_template: "connector_template";
10
- skill: "skill";
11
- }>;
12
- id: z.ZodString;
13
- }, z.core.$strip>;
14
- declare const ListQuery: z.ZodObject<{
15
- kind: z.ZodEnum<{
16
- agent_template: "agent_template";
17
- connector_template: "connector_template";
18
- skill: "skill";
19
- }>;
20
- }, z.core.$strict>;
21
- declare const OrgListQuery: z.ZodObject<{
22
- kind: z.ZodOptional<z.ZodEnum<{
23
- agent_template: "agent_template";
24
- connector_template: "connector_template";
25
- skill: "skill";
26
- }>>;
27
- itemId: z.ZodOptional<z.ZodString>;
28
- }, z.core.$strict>;
29
- /** `{ scope, orgs? }`, `{ disabled: true }` or `{ follow: true }`: exactly one. */
30
- declare const PreviewBody: z.ZodObject<{
31
- scope: z.ZodOptional<z.ZodEnum<{
32
- all: "all";
33
- named: "named";
34
- optional: "optional";
35
- }>>;
36
- orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
37
- disabled: z.ZodOptional<z.ZodLiteral<true>>;
38
- follow: z.ZodOptional<z.ZodLiteral<true>>;
39
- }, z.core.$strict>;
40
- /** `{ scope, orgs?, scopeHash }` or `{ follow: true, scopeHash }`. */
41
- declare const ScopeBody: z.ZodObject<{
42
- scope: z.ZodOptional<z.ZodEnum<{
43
- all: "all";
44
- named: "named";
45
- optional: "optional";
46
- }>>;
47
- orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
48
- follow: z.ZodOptional<z.ZodLiteral<true>>;
49
- scopeHash: z.ZodString;
50
- }, z.core.$strict>;
51
- declare const DisabledBody: z.ZodObject<{
52
- disabled: z.ZodBoolean;
53
- scopeHash: z.ZodOptional<z.ZodString>;
54
- }, z.core.$strict>;
55
- declare const ShownBody: z.ZodObject<{
56
- shownToOthers: z.ZodBoolean;
57
- }, z.core.$strict>;
58
- declare const SwitchBody: z.ZodObject<{
59
- enabled: z.ZodBoolean;
60
- confirm: z.ZodOptional<z.ZodString>;
61
- }, z.core.$strict>;
62
- declare const IdParams: z.ZodObject<{
63
- id: z.ZodString;
64
- }, z.core.$strip>;
65
- declare const TemplateVersionBody: z.ZodObject<{
66
- content: z.ZodString;
67
- }, z.core.$strict>;
68
7
  /**
69
8
  * Platform components (`/api/v1/admin/components/*`, super admins; plugin scope phase 2, Task 6):
70
9
  * the global list of skills, agent templates and connector templates, and each one's own scope,
@@ -132,7 +71,7 @@ export declare class OrgComponentsController {
132
71
  * with its state in the org (`on`, `locked` for `all`, the org's `switch`) and whether an org
133
72
  * admin may switch it. Members read it (the workspace pages are read-only for them).
134
73
  */
135
- list(org: OrgContext, q: z.infer<typeof OrgListQuery>): Promise<{
74
+ list(org: OrgContext, q: z.infer<typeof OrgComponentListQuery>): Promise<{
136
75
  components: OrgOfferedComponentView[];
137
76
  }>;
138
77
  setSwitch(principal: Principal, org: OrgContext, p: z.infer<typeof ComponentParams>, body: z.infer<typeof SwitchBody>): Promise<{
@@ -149,4 +88,3 @@ export declare class OrgComponentsController {
149
88
  confirm: string;
150
89
  }>;
151
90
  }
152
- export {};
@@ -8,67 +8,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
10
  import { Controller, Get, HttpCode, Inject, Post, Put, Req } from "@nestjs/common";
11
- import { z } from "zod";
12
11
  import { ApiError } from "../errors.js";
13
12
  import { CurrentPrincipal, patTokenId, requireUser, SuperAdmin, } from "../identity/principal.js";
14
13
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
15
14
  import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
16
15
  import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
16
+ import { ComponentParams, ComponentDisabledSchema as DisabledBody, ComponentIdSchema as IdParams, ComponentListQuery as ListQuery, OrgComponentListQuery, ComponentScopePreviewSchema as PreviewBody, ComponentScopeSchema as ScopeBody, ComponentShownSchema as ShownBody, ComponentSwitchBody as SwitchBody, ComponentTemplateVersionSchema as TemplateVersionBody, } from "./component-scope.schemas.js";
17
17
  import { ComponentScopeService, } from "./component-scope.service.js";
18
- import { COMPONENT_KINDS } from "./component-state.js";
19
18
  import { PlatformComponents } from "./platform-components.js";
20
- const Kind = z.enum(COMPONENT_KINDS);
21
- const Scope = z.enum(["all", "optional", "named"]);
22
- const Orgs = z.array(z.string().min(1).max(128)).max(1000);
23
- const Hash = z.string().min(1).max(128);
24
- const ComponentParams = z.object({ kind: Kind, id: z.string().min(1).max(128) });
25
- const ListQuery = z.object({ kind: Kind }).strict();
26
- const OrgListQuery = z
27
- .object({ kind: Kind.optional(), itemId: z.string().uuid().optional() })
28
- .strict();
29
- /** `{ scope, orgs? }`, `{ disabled: true }` or `{ follow: true }`: exactly one. */
30
- const PreviewBody = z
31
- .object({
32
- scope: Scope.optional(),
33
- orgs: Orgs.optional(),
34
- disabled: z.literal(true).optional(),
35
- follow: z.literal(true).optional(),
36
- })
37
- .strict()
38
- .refine((b) => [b.scope !== undefined, b.disabled === true, b.follow === true].filter(Boolean).length === 1, { message: "send exactly one of scope (with orgs for named), disabled: true or follow: true" })
39
- .refine((b) => b.scope !== undefined || b.orgs === undefined, {
40
- message: "orgs: only allowed with scope named",
41
- path: ["orgs"],
42
- });
43
- /** `{ scope, orgs?, scopeHash }` or `{ follow: true, scopeHash }`. */
44
- const ScopeBody = z
45
- .object({
46
- scope: Scope.optional(),
47
- orgs: Orgs.optional(),
48
- follow: z.literal(true).optional(),
49
- scopeHash: Hash,
50
- })
51
- .strict()
52
- .refine((b) => (b.scope !== undefined) !== (b.follow === true), {
53
- message: "send either scope (with orgs for named) or follow: true",
54
- })
55
- .refine((b) => b.scope !== undefined || b.orgs === undefined, {
56
- message: "orgs: only allowed with scope named",
57
- path: ["orgs"],
58
- });
59
- const DisabledBody = z.object({ disabled: z.boolean(), scopeHash: Hash.optional() }).strict();
60
- const ShownBody = z.object({ shownToOthers: z.boolean() }).strict();
61
- const SwitchBody = z
62
- .object({
63
- enabled: z.boolean(),
64
- confirm: z
65
- .string()
66
- .regex(/^[0-9a-f]{64}$/)
67
- .optional(),
68
- })
69
- .strict();
70
- const IdParams = z.object({ id: z.string().min(1).max(128) });
71
- const TemplateVersionBody = z.object({ content: z.string().min(1).max(400_000) }).strict();
72
19
  class ComponentIdParams extends createZodDto(IdParams, "ComponentIdParams") {
73
20
  }
74
21
  class TemplateVersionDto extends createZodDto(TemplateVersionBody, "TemplateVersionBody") {
@@ -77,7 +24,7 @@ class ComponentParamsDto extends createZodDto(ComponentParams, "ComponentParams"
77
24
  }
78
25
  class ComponentListQuery extends createZodDto(ListQuery, "ComponentListQuery") {
79
26
  }
80
- class OrgComponentListQuery extends createZodDto(OrgListQuery, "OrgComponentListQuery") {
27
+ class OrgComponentListQueryDto extends createZodDto(OrgComponentListQuery, "OrgComponentListQuery") {
81
28
  }
82
29
  class ComponentScopePreviewBody extends createZodDto(PreviewBody, "ComponentScopePreviewBody") {
83
30
  }
@@ -270,7 +217,7 @@ __decorate([
270
217
  Get(),
271
218
  OrgAction("catalog.read"),
272
219
  __param(0, CurrentOrg()),
273
- __param(1, ZQuery(OrgComponentListQuery))
220
+ __param(1, ZQuery(OrgComponentListQueryDto))
274
221
  ], OrgComponentsController.prototype, "list", null);
275
222
  __decorate([
276
223
  Put(":kind/:id/switch"),