@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
@@ -11,5 +11,5 @@ export const PLATFORM_METHOD = [
11
11
  "4. An operation you may not call is not a dead end: its reason says who can (an org admin, the super admin) and whether a request operation exists; offer that.",
12
12
  "5. Errors say what to do next; follow them.",
13
13
  '6. When unsure how the platform works, use action "read" for the docs before acting.',
14
- 'Find an operation with "browse" (a domain) or "search", then "describe" it before you "call" it; never guess parameters.',
14
+ 'Find an operation with "browse" (a domain) or "search": each lists its input keys in "params" ("?" marks an optional key, an id key takes the id field of the matching list or get result). "describe" gives the types, bounds and an example; describe before a call whose params you are unsure of, and never guess a key that params does not list.',
15
15
  ].join("\n");
@@ -1,5 +1,6 @@
1
1
  import type { z } from "zod";
2
2
  import type { OrgAction } from "../orgs/roles.js";
3
+ import type { ErrorRole } from "./errors.js";
3
4
  /**
4
5
  * How an operation is confirmed (spec §6.2): `read` runs; `personal` asks each time and may be
5
6
  * remembered; `org` / `platform` ask each time and are never remembered.
@@ -19,8 +20,56 @@ export interface OperationContext {
19
20
  agentId: string;
20
21
  conversationId: string;
21
22
  runId: string | null;
23
+ /**
24
+ * The tool call being run (absent at confirmation time): what a result shown only on the web is
25
+ * keyed by, e.g. the generated password of `accounts.create`, read by the person who approved
26
+ * that call.
27
+ */
28
+ callId?: string;
22
29
  signal: AbortSignal;
30
+ /**
31
+ * The actor's role for next steps, from the facts the tool read for this call (spec §14.5
32
+ * item 7). Absent where no tool call is behind the context (a test running `op.run`): read it
33
+ * then with `roleFor` in ./ops/unavailable.ts.
34
+ */
35
+ errorRole?: ErrorRole;
23
36
  }
37
+ /**
38
+ * The next step after an error: one text, or one per role where the step differs (spec §14.5
39
+ * item 7). Only the super admin gets the `superAdmin` text (the admin console path); see
40
+ * `nextStepFor` in ./errors.ts for the fallbacks.
41
+ */
42
+ export type OperationErrorNext = string | {
43
+ readonly superAdmin?: string;
44
+ readonly orgAdmin?: string;
45
+ readonly member?: string;
46
+ };
47
+ /** A notable error code of an operation and what to do next (model-visible English). */
48
+ export interface OperationError {
49
+ code: string;
50
+ next: OperationErrorNext;
51
+ }
52
+ /**
53
+ * What {@link PlatformOperation.precheck} found: nothing known against the write, or why it fails.
54
+ * `next` replaces the operation's `errors[]` entry for the code when the step depends on the target
55
+ * (e.g. the admin console path naming the extension).
56
+ *
57
+ * Some codes exist only in the tool, never answered by a route: `marketplace.already_added` (the
58
+ * `marketplaces.add` duplicate check is tool policy; the web accepts a duplicate source),
59
+ * `plugin.needs_input` (input only a person enters on the web), `agent.visibility_web_only`,
60
+ * `catalog.org_owned` (`plugins.set-shown` leaves an org's own plugin to that org), and
61
+ * `account.self` / `account.no_change` (disabling your own account, a status that is set already).
62
+ */
63
+ export type PrecheckResult = {
64
+ ok: true;
65
+ } | {
66
+ ok: false;
67
+ code: string;
68
+ message: string;
69
+ next?: OperationErrorNext;
70
+ };
71
+ /** How long a precheck may take before the tool skips it (spec §14.2 item 2). */
72
+ export declare const PRECHECK_TIMEOUT_MS = 2000;
24
73
  /** One operation of the `Platform` tool (spec §7), defined next to its domain. */
25
74
  export interface PlatformOperation<I = unknown> {
26
75
  /** `<domain>.<verb>`, matching {@link OPERATION_ID}; the domain is one of {@link PLATFORM_DOMAINS}. */
@@ -40,7 +89,29 @@ export interface PlatformOperation<I = unknown> {
40
89
  authzNote?: "service-enforced";
41
90
  /** The HTTP routes it corresponds to, e.g. `POST /api/v1/orgs/:orgId/skills`; [] when synthetic. */
42
91
  mirrors: readonly string[];
92
+ /**
93
+ * Fields of the mirrored route (body, query, path params but `:orgId`) the input leaves out, e.g.
94
+ * `uploadId` of `skills.create` (spec §14.5 item 3; the parity test in `tools/checks` holds it).
95
+ */
96
+ omits?: readonly string[];
97
+ /** Input fields the mirrored route lacks, e.g. `cursor` of a paged list. */
98
+ extras?: readonly string[];
99
+ /**
100
+ * Input fields compared with a route field of another name or path: `{ skillId: "id" }`, a
101
+ * flattened `{ name: "definition.name" }`. The route field counts as present.
102
+ */
103
+ renames?: Readonly<Record<string, string>>;
104
+ /**
105
+ * Input fields allowed to accept more than the route (bounds, pattern, required-ness, never the
106
+ * type), each with its reason, e.g. a confirm value that also takes `nothing-installed`.
107
+ */
108
+ loosens?: Readonly<Record<string, string>>;
43
109
  confirm: ConfirmClass;
110
+ /**
111
+ * `false`: a confirmation is never remembered, whatever the class (a destructive personal write
112
+ * such as deleting a conversation). Static; absent: remembered only for the class `personal`.
113
+ */
114
+ rememberable?: false;
44
115
  /**
45
116
  * The class of one call when it depends on the target (read at confirmation time): e.g.
46
117
  * `agents.update` is `personal` only on a private agent the actor owns and `org` otherwise, so a
@@ -50,12 +121,18 @@ export interface PlatformOperation<I = unknown> {
50
121
  confirmFor?(input: I, ctx: OperationContext): Promise<ConfirmClass>;
51
122
  /**
52
123
  * The notable error codes of the operation and what to do next (model-visible English), shown
53
- * by `describe` (spec §3).
124
+ * by `describe` (spec §3) and appended to an `ApiError` of that code (spec §14.5 item 7). `next`
125
+ * is keyed by role where the step differs (`check:platform-ops` rule `platform-op-errors`).
126
+ */
127
+ errors?: readonly OperationError[];
128
+ /**
129
+ * Preconditions read before the card (spec §14.2 item 2): a write known to fail (a taken name, a
130
+ * stale preview) is denied with this reason and the person is never asked. Reads only; runs
131
+ * again when an approved call resumes (a failure then returns the error, nothing runs). Bounded
132
+ * by the tool ({@link PRECHECK_TIMEOUT_MS}); a timeout or a throw skips it, and the write's own
133
+ * errors speak.
54
134
  */
55
- errors?: readonly {
56
- code: string;
57
- next: string;
58
- }[];
135
+ precheck?(input: I, ctx: OperationContext): Promise<PrecheckResult>;
59
136
  /**
60
137
  * The bilingual card summary of a write, rendered from the input and kernel reads (names of
61
138
  * the targets, preview counts), never from model text; required unless `confirm` is `read`.
@@ -1,3 +1,5 @@
1
+ /** How long a precheck may take before the tool skips it (spec §14.2 item 2). */
2
+ export const PRECHECK_TIMEOUT_MS = 2000;
1
3
  /** Identity helper that types an operation's handler and summary from its input schema. */
2
4
  export function defineOperation(op) {
3
5
  return op;
@@ -15,21 +17,74 @@ export const PLATFORM_DOMAINS = [
15
17
  { id: "skills", description: "The org's skill library: list, read, create, switch on or off." },
16
18
  {
17
19
  id: "agents",
18
- description: "Agents in the org: list, read, create private ones, update those you may edit.",
20
+ description: "Agents in the org: list, read, create private ones, update or delete those you may edit, their profile (avatar, quick actions), versions, pending connectors, readiness.",
19
21
  },
20
22
  {
21
23
  id: "agent-templates",
22
- description: "Agent templates: list, read, save an agent as a template.",
24
+ description: "Agent templates: list, read, save an agent as a template, update, share or delete the org's own.",
23
25
  },
24
26
  {
25
27
  id: "plugins",
26
- description: "Plugins in the org and on the platform: list, read, enable, disable, update.",
28
+ description: "Plugins in the org and on the platform: list, read, enable, disable, update, scope, import, the org's own uploads.",
27
29
  },
28
30
  {
29
31
  id: "marketplaces",
30
- description: "Marketplace sources and their entries: list, browse, add, request a plugin.",
32
+ description: "Marketplace sources and their entries: list, browse, add, edit, refresh, remove, import, request a plugin.",
33
+ },
34
+ {
35
+ id: "requests",
36
+ description: "Requests to admins: list yours, create one; org admins list the members' pending ones; the super admin lists the platform's.",
37
+ },
38
+ {
39
+ id: "connectors",
40
+ description: "Connectors and connector templates: list and read, refresh tools, delete.",
41
+ },
42
+ {
43
+ id: "extensions",
44
+ description: "Extensions in the org (state, tool switches, extension point defaults, file previewers) and, for the super admin, on the platform (state, pending permission confirmations, enable, disable, uninstall).",
45
+ },
46
+ {
47
+ id: "conversations",
48
+ description: "Your own conversations: list, read, rename, archive, delete, read their events, list and stop their background tasks.",
49
+ },
50
+ {
51
+ id: "orgs",
52
+ description: "This org (read, rename, members) and, for the super admin, every org and its limits.",
53
+ },
54
+ {
55
+ id: "accounts",
56
+ description: "Platform accounts (super admin): list, read, create, disable, enable.",
57
+ },
58
+ {
59
+ id: "admin",
60
+ description: "The admin console (super admin): dashboard totals and deployment settings.",
61
+ },
62
+ {
63
+ id: "models",
64
+ description: "The org's model per purpose, the models available and the ones it switched off; for the super admin, the platform's models: catalog and disabled list, prices, default model per purpose.",
65
+ },
66
+ {
67
+ id: "evals",
68
+ description: "Eval sets, their cases and runs, results and labels (org admins): replay a candidate model or prompt over real cases.",
69
+ },
70
+ {
71
+ id: "inbox",
72
+ description: "Your inbox (what waits for you, as summaries; dismiss notices) and, for the super admin, the platform inbox. Deciding is done on the web.",
73
+ },
74
+ {
75
+ id: "approvals",
76
+ description: "Tool call approvals you can decide: list and read them as summaries, never the call's input. Deciding is done on the web.",
77
+ },
78
+ {
79
+ id: "channels",
80
+ description: "The org's channel connections (IM bots): list, read without credentials, change the binding, remove.",
81
+ },
82
+ {
83
+ id: "org-settings",
84
+ description: "The org's settings (tool search, language, sandbox policy, the Platform tool switch): read and change.",
85
+ },
86
+ {
87
+ id: "environments",
88
+ description: "Your own cloud environments (the workspaces your conversations run in): list, read, create, rename, delete, wipe the files.",
31
89
  },
32
- { id: "requests", description: "Requests to admins: list yours, create one." },
33
- { id: "connectors", description: "Connectors and connector templates: list and read." },
34
- { id: "extensions", description: "Extensions in the org (state only) and extension points." },
35
90
  ];
@@ -0,0 +1,32 @@
1
+ import type { Logger } from "@capybara-hq/plugin-sdk";
2
+ import { type OnModuleInit } from "@nestjs/common";
3
+ import { AccountsService } from "../../identity/accounts.js";
4
+ import { InitialPasswords } from "../../identity/initial-passwords.js";
5
+ import { SessionService } from "../../identity/sessions.js";
6
+ import { OrgsService } from "../../orgs/orgs.service.js";
7
+ import { PlatformOperations } from "../registry.js";
8
+ /** What the tool result says instead of the password (model-visible English). */
9
+ export declare const INITIAL_PASSWORD_NOTE = "The kernel generated a one-time initial password. It is shown once, on the web, to the person who approved this call (the approval card in this conversation); it is not available to you, so never ask for it or make one up. If it is not read within 24 hours it is lost: disable the account and create it again. The account must change it at first sign-in.";
10
+ /**
11
+ * Account operations of the `Platform` tool (spec §14.2, admin console): the super admin lists,
12
+ * reads, creates, disables and enables accounts, only through their own private agent
13
+ * (`availability`). Creating takes no password: the kernel generates a one-time one, the account
14
+ * must change it at first sign-in, and only the approving person sees it, on the web (spec §14.5
15
+ * item 2); the result, the events, the audit and the logs never carry it. The super-admin flag
16
+ * stays a human-only change (a role change).
17
+ */
18
+ export declare class AccountsOperations implements OnModuleInit {
19
+ private readonly registry;
20
+ private readonly accounts;
21
+ private readonly passwords;
22
+ private readonly sessions;
23
+ private readonly orgs;
24
+ private readonly log;
25
+ constructor(registry: PlatformOperations, accounts: AccountsService, passwords: InitialPasswords, sessions: SessionService, orgs: OrgsService, log: Logger);
26
+ private account;
27
+ /** Refuses a status change that cannot or need not run, before the card. */
28
+ private statusPrecheck;
29
+ private setStatus;
30
+ private statusSummary;
31
+ onModuleInit(): void;
32
+ }
@@ -0,0 +1,291 @@
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 { AccountListQuery, AccountParams, CreateAccountBody } from "../../admin/admin.schemas.js";
13
+ import { ApiError } from "../../errors.js";
14
+ import { AccountsService } from "../../identity/accounts.js";
15
+ import { InitialPasswords } from "../../identity/initial-passwords.js";
16
+ import { SessionService } from "../../identity/sessions.js";
17
+ import { KERNEL_LOGGER } from "../../infra/tokens.js";
18
+ import { OrgsService } from "../../orgs/orgs.service.js";
19
+ import { defineOperation } from "../operation.js";
20
+ import { PlatformOperations } from "../registry.js";
21
+ import { precheckBy, viaAgent } from "./errors.js";
22
+ import { named } from "./summary.js";
23
+ const PAGE = 50;
24
+ const AccountId = AccountParams.shape.accountId.describe("The account id (accounts.list).");
25
+ /** What the tool result says instead of the password (model-visible English). */
26
+ export const INITIAL_PASSWORD_NOTE = "The kernel generated a one-time initial password. It is shown once, on the web, to the person who approved this call (the approval card in this conversation); it is not available to you, so never ask for it or make one up. If it is not read within 24 hours it is lost: disable the account and create it again. The account must change it at first sign-in.";
27
+ /** An account as a detail returns it (the admin console's account fields). */
28
+ const accountView = (a, login) => ({
29
+ id: a.id,
30
+ login,
31
+ displayName: a.displayName,
32
+ email: a.email,
33
+ status: a.status,
34
+ superAdmin: a.isSuperAdmin,
35
+ mustChangePassword: a.mustChangePassword,
36
+ createdAt: a.createdAt,
37
+ });
38
+ /** The account's name as a card summary quotes it: display name and login. */
39
+ const quoted = (a, login) => login ? `${named(a.displayName)} (${named(login)})` : named(a.displayName);
40
+ /**
41
+ * Account operations of the `Platform` tool (spec §14.2, admin console): the super admin lists,
42
+ * reads, creates, disables and enables accounts, only through their own private agent
43
+ * (`availability`). Creating takes no password: the kernel generates a one-time one, the account
44
+ * must change it at first sign-in, and only the approving person sees it, on the web (spec §14.5
45
+ * item 2); the result, the events, the audit and the logs never carry it. The super-admin flag
46
+ * stays a human-only change (a role change).
47
+ */
48
+ let AccountsOperations = class AccountsOperations {
49
+ registry;
50
+ accounts;
51
+ passwords;
52
+ sessions;
53
+ orgs;
54
+ log;
55
+ constructor(registry, accounts, passwords, sessions, orgs, log) {
56
+ this.registry = registry;
57
+ this.accounts = accounts;
58
+ this.passwords = passwords;
59
+ this.sessions = sessions;
60
+ this.orgs = orgs;
61
+ this.log = log;
62
+ }
63
+ async account(id) {
64
+ const a = await this.accounts.get(id);
65
+ if (!a)
66
+ throw new ApiError("account.not_found", "Account not found");
67
+ return a;
68
+ }
69
+ /** Refuses a status change that cannot or need not run, before the card. */
70
+ async statusPrecheck(accountId, status, ctx) {
71
+ const r = await precheckBy(() => this.account(accountId));
72
+ if (!r.ok)
73
+ return r;
74
+ const a = await this.account(accountId);
75
+ if (a.status === status) {
76
+ return {
77
+ ok: false,
78
+ code: "account.no_change",
79
+ message: `The account is ${status} already`,
80
+ };
81
+ }
82
+ if (status === "disabled" && accountId === ctx.actorAccountId) {
83
+ return {
84
+ ok: false,
85
+ code: "account.self",
86
+ message: "You cannot disable your own account through your agent",
87
+ };
88
+ }
89
+ if (status === "disabled" &&
90
+ a.isSuperAdmin &&
91
+ a.status === "active" &&
92
+ (await this.accounts.countSuperAdmins()) <= 1) {
93
+ return {
94
+ ok: false,
95
+ code: "account.last_super_admin",
96
+ message: "This is the last active super admin",
97
+ };
98
+ }
99
+ return { ok: true };
100
+ }
101
+ async setStatus(operation, accountId, status, ctx) {
102
+ const { account, revokedSessionIds } = await this.accounts.updateAccount(accountId, { status }, ctx.actorAccountId, undefined, { auditDetail: viaAgent(operation, ctx) });
103
+ try {
104
+ await this.sessions.markRevoked(revokedSessionIds);
105
+ }
106
+ catch (err) {
107
+ // the Redis markers are only the fast path: auth reads PG revoked_at on every request
108
+ this.log.warn("failed to write session revocation markers after account deactivation", {
109
+ accountId,
110
+ err,
111
+ });
112
+ }
113
+ const login = (await this.accounts.localLogins([account.id])).get(account.id) ?? null;
114
+ return { account: accountView(account, login) };
115
+ }
116
+ async statusSummary(accountId, zh, en) {
117
+ const a = await this.accounts.get(accountId);
118
+ if (!a)
119
+ return { zh: `${zh}账号 ${accountId}`, en: `${en} account ${accountId}` };
120
+ const login = (await this.accounts.localLogins([a.id])).get(a.id);
121
+ return { zh: `${zh}账号「${quoted(a, login)}」`, en: `${en} account "${quoted(a, login)}"` };
122
+ }
123
+ onModuleInit() {
124
+ this.registry.register([
125
+ defineOperation({
126
+ id: "accounts.list",
127
+ description: "List the platform's accounts (super admin), one compact row each: id, display name, state (active or disabled), login, email and whether it is a super admin. Ordered by id; pages by 50: pass the returned next as params.after. Details come from accounts.get.",
128
+ input: z
129
+ .object({ after: AccountListQuery.shape.after.unwrap().max(100).optional() })
130
+ .strict(),
131
+ example: {},
132
+ authz: { superAdmin: true },
133
+ mirrors: ["GET /api/v1/admin/accounts"],
134
+ // the page size is fixed at 50 (compact rows)
135
+ omits: ["limit"],
136
+ confirm: "read",
137
+ run: async (input) => {
138
+ const rows = await this.accounts.list({
139
+ limit: PAGE + 1,
140
+ ...(input.after !== undefined && { after: input.after }),
141
+ });
142
+ const page = rows.slice(0, PAGE);
143
+ const logins = await this.accounts.localLogins(page.map((a) => a.id));
144
+ return {
145
+ items: page.map((a) => ({
146
+ id: a.id,
147
+ name: a.displayName,
148
+ state: a.status,
149
+ login: logins.get(a.id) ?? null,
150
+ email: a.email,
151
+ superAdmin: a.isSuperAdmin,
152
+ })),
153
+ next: rows.length > PAGE ? (page.at(-1)?.id ?? null) : null,
154
+ };
155
+ },
156
+ }),
157
+ defineOperation({
158
+ id: "accounts.get",
159
+ description: "Read one account (super admin): login, display name, email, state, whether it is a super admin, whether it still has to change a generated initial password, when it was created, and the orgs it belongs to with its role in each.",
160
+ input: z.object({ accountId: AccountId }).strict(),
161
+ example: { accountId: "00000000-0000-4000-8000-000000000000" },
162
+ authz: { superAdmin: true },
163
+ mirrors: [],
164
+ confirm: "read",
165
+ errors: [
166
+ {
167
+ code: "account.not_found",
168
+ next: "Look the account up with accounts.list and pass its id.",
169
+ },
170
+ ],
171
+ run: async (input) => {
172
+ const a = await this.account(input.accountId);
173
+ const [logins, orgs] = await Promise.all([
174
+ this.accounts.localLogins([a.id]),
175
+ this.orgs.listForAccount(a.id),
176
+ ]);
177
+ return {
178
+ account: accountView(a, logins.get(a.id) ?? null),
179
+ orgs: orgs.map((o) => ({ id: o.id, name: o.name, slug: o.slug, role: o.role })),
180
+ };
181
+ },
182
+ }),
183
+ defineOperation({
184
+ id: "accounts.create",
185
+ description: "Create a local sign-in account (super admin): a login (3-64 characters: letters, digits, . _ @ + -), a display name and an optional email. You pass no password: the kernel generates a one-time initial password, shows it once to the person who approves this call, on the web (the approval card); it is lost if not read within 24 hours (then disable the account and create it again). The account must change it at first sign-in. The account is never a super admin; that and org memberships are set by a person on the web (add it to an org with an invitation).",
186
+ input: CreateAccountBody.pick({ login: true, displayName: true, email: true }).strict(),
187
+ example: { login: "alice", displayName: "Alice Chen", email: "alice@example.com" },
188
+ authz: { superAdmin: true },
189
+ mirrors: ["POST /api/v1/admin/accounts"],
190
+ // the password is generated by the kernel; the super-admin flag is a role change (human-only)
191
+ omits: ["password", "superAdmin"],
192
+ confirm: "platform",
193
+ errors: [
194
+ {
195
+ code: "account.login_taken",
196
+ next: "Choose another login, or use the existing account (accounts.list).",
197
+ },
198
+ {
199
+ code: "account.create_needs_approval",
200
+ next: "Call it from a conversation with your private agent, where you approve the call yourself, or create the account on the web (admin console, Accounts).",
201
+ },
202
+ {
203
+ code: "validation_failed",
204
+ next: "Fix the login, display name or email as the message says, then call again.",
205
+ },
206
+ ],
207
+ precheck: (i) => precheckBy(() => this.accounts.assertLoginFree(i.login)),
208
+ summary: (i) => ({
209
+ zh: `新建账号「${quoted(i, i.login)}」,初始密码由平台生成,批准后仅向你显示一次`,
210
+ en: `Create account "${quoted(i, i.login)}"; the platform generates the initial password and shows it once to you after approval`,
211
+ }),
212
+ run: async (input, ctx) => {
213
+ if (ctx.callId === undefined || ctx.runId === null) {
214
+ // the password reaches the approver through the approved call; without one it could
215
+ // never be shown, so nothing is created
216
+ throw new ApiError("account.create_needs_approval", "accounts.create runs only as a Platform call you approve in a conversation");
217
+ }
218
+ const account = await this.passwords.createAccount({
219
+ login: input.login,
220
+ displayName: input.displayName,
221
+ ...(input.email !== undefined && { email: input.email }),
222
+ }, ctx.actorAccountId, {
223
+ conversationId: ctx.conversationId,
224
+ runId: ctx.runId,
225
+ callId: ctx.callId,
226
+ recipientAccountId: ctx.actorAccountId,
227
+ }, viaAgent("accounts.create", ctx));
228
+ const login = (await this.accounts.localLogins([account.id])).get(account.id) ?? null;
229
+ return { account: accountView(account, login), initialPassword: INITIAL_PASSWORD_NOTE };
230
+ },
231
+ }),
232
+ defineOperation({
233
+ id: "accounts.disable",
234
+ description: "Disable an account (super admin): it can no longer sign in, and its sessions and personal access tokens are revoked at once (enabling it again does not bring them back). You cannot disable your own account or the last active super admin.",
235
+ input: z.object({ accountId: AccountId }).strict(),
236
+ example: { accountId: "00000000-0000-4000-8000-000000000000" },
237
+ authz: { superAdmin: true },
238
+ mirrors: ["PATCH /api/v1/admin/accounts/:accountId"],
239
+ // only the status, set by the operation; the display name and the super-admin flag (a role
240
+ // change, human-only) are changed on the web
241
+ omits: ["displayName", "status", "isSuperAdmin"],
242
+ confirm: "platform",
243
+ errors: [
244
+ {
245
+ code: "account.not_found",
246
+ next: "Look the account up with accounts.list and pass its id.",
247
+ },
248
+ {
249
+ code: "account.last_super_admin",
250
+ next: "Make another account a super admin on the web first (admin console, Accounts).",
251
+ },
252
+ { code: "account.self", next: "Ask another super admin to do it on the web." },
253
+ { code: "account.no_change", next: "Nothing to do: the account is disabled already." },
254
+ ],
255
+ precheck: (i, ctx) => this.statusPrecheck(i.accountId, "disabled", ctx),
256
+ summary: (i) => this.statusSummary(i.accountId, "停用", "Disable"),
257
+ run: (input, ctx) => this.setStatus("accounts.disable", input.accountId, "disabled", ctx),
258
+ }),
259
+ defineOperation({
260
+ id: "accounts.enable",
261
+ description: "Enable a disabled account again (super admin): it can sign in again with its password; its earlier sessions and tokens stay revoked.",
262
+ input: z.object({ accountId: AccountId }).strict(),
263
+ example: { accountId: "00000000-0000-4000-8000-000000000000" },
264
+ authz: { superAdmin: true },
265
+ mirrors: ["PATCH /api/v1/admin/accounts/:accountId"],
266
+ omits: ["displayName", "status", "isSuperAdmin"],
267
+ confirm: "platform",
268
+ errors: [
269
+ {
270
+ code: "account.not_found",
271
+ next: "Look the account up with accounts.list and pass its id.",
272
+ },
273
+ { code: "account.no_change", next: "Nothing to do: the account is active already." },
274
+ ],
275
+ precheck: (i, ctx) => this.statusPrecheck(i.accountId, "active", ctx),
276
+ summary: (i) => this.statusSummary(i.accountId, "启用", "Enable"),
277
+ run: (input, ctx) => this.setStatus("accounts.enable", input.accountId, "active", ctx),
278
+ }),
279
+ ]);
280
+ }
281
+ };
282
+ AccountsOperations = __decorate([
283
+ Injectable(),
284
+ __param(0, Inject(PlatformOperations)),
285
+ __param(1, Inject(AccountsService)),
286
+ __param(2, Inject(InitialPasswords)),
287
+ __param(3, Inject(SessionService)),
288
+ __param(4, Inject(OrgsService)),
289
+ __param(5, Inject(KERNEL_LOGGER))
290
+ ], AccountsOperations);
291
+ export { AccountsOperations };
@@ -0,0 +1,36 @@
1
+ import { type OnModuleInit } from "@nestjs/common";
2
+ import { CatalogRequestsService } from "../../catalog/requests.service.js";
3
+ import { ExtensionAdmin } from "../../extensions/admin-view.js";
4
+ import { ExtensionDisplayNames } from "../../extensions/display-name.js";
5
+ import { ExtensionRegistry } from "../../extensions/registry.js";
6
+ import { AccountsService } from "../../identity/accounts.js";
7
+ import { SettingsService } from "../../identity/settings.js";
8
+ import { ModelEnablement } from "../../models/enablement.js";
9
+ import { PricesService } from "../../models/prices.js";
10
+ import { ModelPurposesService } from "../../models/purposes.js";
11
+ import { OrgsService } from "../../orgs/orgs.service.js";
12
+ import { ProviderRegistry } from "../../runtime/providers.js";
13
+ import { PlatformOperations } from "../registry.js";
14
+ /**
15
+ * Admin console operations of the `Platform` tool (spec §14.2): the dashboard totals, the
16
+ * deployment settings, and the platform's models (the model catalog with the platform's disabled
17
+ * list, the price table, the default model per purpose). Super admin only, through their own
18
+ * private agent. The per-org overrides of models and purposes are the org's own pages.
19
+ */
20
+ export declare class AdminOperations implements OnModuleInit {
21
+ private readonly registry;
22
+ private readonly extensions;
23
+ private readonly orgs;
24
+ private readonly accounts;
25
+ private readonly catalogRequests;
26
+ private readonly settings;
27
+ private readonly providers;
28
+ private readonly displayNames;
29
+ private readonly extensionRegistry;
30
+ private readonly enablement;
31
+ private readonly prices;
32
+ private readonly purposes;
33
+ constructor(registry: PlatformOperations, extensions: ExtensionAdmin, orgs: OrgsService, accounts: AccountsService, catalogRequests: CatalogRequestsService, settings: SettingsService, providers: ProviderRegistry, displayNames: ExtensionDisplayNames, extensionRegistry: ExtensionRegistry, enablement: ModelEnablement, prices: PricesService, purposes: ModelPurposesService);
34
+ private assertProvider;
35
+ onModuleInit(): void;
36
+ }