@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
@@ -0,0 +1,195 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { Inject, Injectable } from "@nestjs/common";
11
+ import { z } from "zod";
12
+ import { ChannelPatchSchema, ChannelPathParams } from "../../channels/channels.schemas.js";
13
+ import { ChannelConnections, } from "../../channels/connections.service.js";
14
+ import { defineOperation } from "../operation.js";
15
+ import { PlatformOperations } from "../registry.js";
16
+ import { precheckBy, viaAgent } from "./errors.js";
17
+ import { Cursor, pageOf, startOf } from "./paging.js";
18
+ import { named, orElse } from "./summary.js";
19
+ const PAGE = 50;
20
+ /**
21
+ * A connection as the tool shows it: the settings an admin sees on the channels page. The
22
+ * non-secret config and whether each secret is set, never a secret value (the service view holds
23
+ * none), plus the webhook callback URL (an address, not a secret).
24
+ */
25
+ const detail = (c) => ({
26
+ id: c.id,
27
+ name: c.name,
28
+ plugin: c.plugin,
29
+ agentId: c.agentId,
30
+ status: c.status,
31
+ unboundPolicy: c.unboundPolicy,
32
+ inboundMode: c.inboundMode,
33
+ webhookSupported: c.webhookSupported,
34
+ webhookUrl: c.webhookUrl,
35
+ lastError: c.lastError,
36
+ config: c.config,
37
+ secrets: c.secrets,
38
+ createdAt: c.createdAt,
39
+ updatedAt: c.updatedAt,
40
+ });
41
+ /**
42
+ * Channel connection operations of the `Platform` tool (spec §14): read a connection and change
43
+ * its binding (which agent answers, what happens to unbound people, on / off, inbound mode),
44
+ * or remove it. Creating a connection and changing its credentials or config stay on the web:
45
+ * they carry app secrets a person types (spec §6.4).
46
+ */
47
+ let ChannelsOperations = class ChannelsOperations {
48
+ registry;
49
+ channels;
50
+ constructor(registry, channels) {
51
+ this.registry = registry;
52
+ this.channels = channels;
53
+ }
54
+ async nameOf(orgId, id) {
55
+ return orElse(async () => named((await this.channels.get(orgId, id)).name), id);
56
+ }
57
+ onModuleInit() {
58
+ this.registry.register([
59
+ defineOperation({
60
+ id: "channels.list",
61
+ description: "List the org's channel connections (IM bots), one compact row each: id, name, state (active or disabled), the last error, and the plugin, the agent that answers and the policy for unbound people. Never returns credentials. Pages by 50: pass the returned next as params.cursor. One connection's settings come from channels.get.",
62
+ input: z.object({ cursor: Cursor.optional() }).strict(),
63
+ example: {},
64
+ authz: { orgAction: "channels.manage" },
65
+ mirrors: ["GET /api/v1/orgs/:orgId/channels"],
66
+ extras: ["cursor"],
67
+ confirm: "read",
68
+ run: async (input, ctx) => pageOf((await this.channels.list(ctx.orgId)).map((c) => ({
69
+ id: c.id,
70
+ name: c.name,
71
+ state: c.status,
72
+ ...(c.lastError !== null && { reason: c.lastError }),
73
+ plugin: c.plugin,
74
+ agentId: c.agentId,
75
+ unboundPolicy: c.unboundPolicy,
76
+ })), startOf(input.cursor), PAGE),
77
+ }),
78
+ defineOperation({
79
+ id: "channels.get",
80
+ description: "Read one channel connection: the agent that answers, the policy for unbound people, state, inbound mode, the last error, its non-secret config and which secrets are set. Credential values are never returned.",
81
+ input: ChannelPathParams.strict(),
82
+ example: { connectionId: "00000000-0000-4000-8000-000000000000" },
83
+ authz: { orgAction: "channels.manage" },
84
+ mirrors: ["GET /api/v1/orgs/:orgId/channels/:connectionId"],
85
+ confirm: "read",
86
+ errors: [
87
+ {
88
+ code: "channel.not_found",
89
+ next: "Look the connection up with channels.list and pass its id.",
90
+ },
91
+ ],
92
+ run: async (input, ctx) => ({
93
+ channel: detail(await this.channels.get(ctx.orgId, input.connectionId)),
94
+ }),
95
+ }),
96
+ defineOperation({
97
+ id: "channels.update",
98
+ description: "Change a channel connection's binding (org admins): its name, the agent that answers (agentId), what happens to people not yet bound to an account (unboundPolicy: bind or anonymous), active or disabled, and the inbound mode. Give only what changes. Credentials and config are changed on the web.",
99
+ input: ChannelPatchSchema.omit({ config: true })
100
+ .extend(ChannelPathParams.shape)
101
+ .strict()
102
+ .refine((i) => i.name !== undefined ||
103
+ i.agentId !== undefined ||
104
+ i.unboundPolicy !== undefined ||
105
+ i.status !== undefined ||
106
+ i.inboundMode !== undefined, { message: "give name, agentId, unboundPolicy, status or inboundMode" }),
107
+ example: { connectionId: "00000000-0000-4000-8000-000000000000", status: "disabled" },
108
+ authz: { orgAction: "channels.manage" },
109
+ mirrors: ["PATCH /api/v1/orgs/:orgId/channels/:connectionId"],
110
+ // the route's config carries app secrets: a person changes it on the web
111
+ omits: ["config"],
112
+ extras: [],
113
+ confirm: "org",
114
+ errors: [
115
+ {
116
+ code: "channel.not_found",
117
+ next: "Look the connection up with channels.list and pass its id.",
118
+ },
119
+ {
120
+ code: "agent.not_found",
121
+ next: "Pick the agent with agents.list and pass its id as agentId.",
122
+ },
123
+ {
124
+ code: "channel.webhook_unavailable",
125
+ next: "The plugin or the deployment cannot receive webhooks; keep inboundMode long_connection, or ask the super admin to set channels.webhookBaseUrl.",
126
+ },
127
+ ],
128
+ precheck: (i, ctx) => {
129
+ const { connectionId, ...patch } = i;
130
+ return precheckBy(() => this.channels.checkUpdate(ctx.orgId, connectionId, patch));
131
+ },
132
+ summary: async (i, ctx) => {
133
+ const name = await this.nameOf(ctx.orgId, i.connectionId);
134
+ const parts = [
135
+ i.name !== undefined && `name → "${named(i.name)}"`,
136
+ i.agentId !== undefined && `agent → ${named(i.agentId)}`,
137
+ i.unboundPolicy !== undefined && `unbound people: ${i.unboundPolicy}`,
138
+ i.status !== undefined && `status → ${i.status}`,
139
+ i.inboundMode !== undefined && `inbound mode → ${i.inboundMode}`,
140
+ ].filter((p) => typeof p === "string");
141
+ return {
142
+ zh: `修改渠道连接「${name}」:${parts.join(",")}`,
143
+ en: `Update channel connection "${name}": ${parts.join(", ")}`,
144
+ };
145
+ },
146
+ run: async (input, ctx) => {
147
+ const { connectionId, ...patch } = input;
148
+ const r = await this.channels.update(ctx.orgId, connectionId, patch, ctx.actorAccountId, undefined, viaAgent("channels.update", ctx));
149
+ const webhook = input.inboundMode === "webhook";
150
+ return {
151
+ channel: detail(r.channel),
152
+ ...(webhook && {
153
+ note: r.channel.webhookUrl !== null
154
+ ? `Register the callback URL ${r.channel.webhookUrl} in the IM platform's app settings (channels.get shows it again).`
155
+ : "The callback URL is not available yet: the super admin has to set channels.webhookBaseUrl; the channels page on the web then shows it.",
156
+ }),
157
+ };
158
+ },
159
+ }),
160
+ defineOperation({
161
+ id: "channels.delete",
162
+ description: "Remove a channel connection (org admins): its credentials are deleted and the bot stops answering; people have to set it up again on the web to bring it back.",
163
+ input: ChannelPathParams.strict(),
164
+ example: { connectionId: "00000000-0000-4000-8000-000000000000" },
165
+ authz: { orgAction: "channels.manage" },
166
+ mirrors: ["DELETE /api/v1/orgs/:orgId/channels/:connectionId"],
167
+ confirm: "org",
168
+ errors: [
169
+ {
170
+ code: "channel.not_found",
171
+ next: "Look the connection up with channels.list and pass its id.",
172
+ },
173
+ ],
174
+ precheck: (i, ctx) => precheckBy(() => this.channels.get(ctx.orgId, i.connectionId)),
175
+ summary: async (i, ctx) => {
176
+ const name = await this.nameOf(ctx.orgId, i.connectionId);
177
+ return {
178
+ zh: `删除渠道连接「${name}」(凭据一并删除,机器人停止应答)`,
179
+ en: `Delete channel connection "${name}" (its credentials are deleted and the bot stops answering)`,
180
+ };
181
+ },
182
+ run: async (input, ctx) => {
183
+ await this.channels.remove(ctx.orgId, input.connectionId, ctx.actorAccountId, undefined, viaAgent("channels.delete", ctx));
184
+ return { deleted: input.connectionId };
185
+ },
186
+ }),
187
+ ]);
188
+ }
189
+ };
190
+ ChannelsOperations = __decorate([
191
+ Injectable(),
192
+ __param(0, Inject(PlatformOperations)),
193
+ __param(1, Inject(ChannelConnections))
194
+ ], ChannelsOperations);
195
+ export { ChannelsOperations };
@@ -0,0 +1,46 @@
1
+ import { type OnModuleInit } from "@nestjs/common";
2
+ import { ComponentScopeService } from "../../catalog/component-scope.service.js";
3
+ import { PlatformComponents } from "../../catalog/platform-components.js";
4
+ import { KernelDb } from "../../infra/database/kernel-db.js";
5
+ import { PlatformOperations } from "../registry.js";
6
+ /**
7
+ * The org's switches of platform components (spec §7, rule 5): for each kind (skill, agent
8
+ * template, connector template) the platform components offered to the org, the read-only preview
9
+ * of switching one off, and the switch itself; plus the super admin's read-only component list and
10
+ * version history, and the admin console's component writes (scope, disable, visibility, template
11
+ * versions; class `platform`). The operations
12
+ * of the three kinds are written out (the `platform-op-*` checks read literals); their logic is
13
+ * shared below.
14
+ */
15
+ export declare class ComponentsOperations implements OnModuleInit {
16
+ private readonly registry;
17
+ private readonly components;
18
+ private readonly platformComponents;
19
+ private readonly kdb;
20
+ constructor(registry: PlatformOperations, components: ComponentScopeService, platformComponents: PlatformComponents, kdb: KernelDb);
21
+ /** A component as a write returns it, with its orgs named (see {@link brief}). */
22
+ private withOrgNames;
23
+ /** Refuses a super-admin operation on a component another org owns (spec section 6.1). */
24
+ private assertNotOtherOrgs;
25
+ private adminName;
26
+ /**
27
+ * Runs a governance write; a name clash the service reports (it names the clashing items, which
28
+ * may be another org's own) is rethrown with {@link clashText} of the current preview, so a race
29
+ * past the precheck never puts another org's private item in the log.
30
+ */
31
+ private withoutItemNames;
32
+ /**
33
+ * What a scope change or disable would touch, as the admin console shows it (orgs named, spec
34
+ * §14.5 item 1); each org's agents and the clashing items are counted (they are that org's own).
35
+ */
36
+ private previewBrief;
37
+ /** The precheck of a scope change or disable: another org's component, a stale hash, a name clash. */
38
+ private precheckTarget;
39
+ private available;
40
+ private nameOf;
41
+ private disablePreview;
42
+ private precheckSwitch;
43
+ private switchSummary;
44
+ private switchRun;
45
+ onModuleInit(): void;
46
+ }