@capybara-hq/kernel 0.1.0-rc.4 → 0.1.0-rc.5

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 (507) hide show
  1. package/bootstrap.json +61 -5
  2. package/dist/admin/admin.controller.d.ts +39 -13
  3. package/dist/admin/admin.controller.js +33 -17
  4. package/dist/admin/extensions.controller.d.ts +16 -2
  5. package/dist/admin/extensions.controller.js +26 -6
  6. package/dist/admin/setup-lock.d.ts +1 -1
  7. package/dist/admin/setup-lock.js +1 -1
  8. package/dist/admin/setup.controller.d.ts +1 -1
  9. package/dist/admin/setup.controller.js +1 -1
  10. package/dist/admin/setup.service.d.ts +4 -4
  11. package/dist/admin/setup.service.js +8 -8
  12. package/dist/agents/agent-lookup.d.ts +16 -0
  13. package/dist/agents/agent-lookup.js +11 -0
  14. package/dist/agents/agents.controller.d.ts +76 -1
  15. package/dist/agents/agents.controller.js +90 -11
  16. package/dist/agents/agents.module.d.ts +4 -1
  17. package/dist/agents/agents.module.js +32 -6
  18. package/dist/agents/agents.service.d.ts +51 -22
  19. package/dist/agents/agents.service.js +172 -70
  20. package/dist/agents/definition.d.ts +49 -0
  21. package/dist/agents/definition.js +45 -0
  22. package/dist/agents/from-template.d.ts +106 -0
  23. package/dist/agents/from-template.js +649 -0
  24. package/dist/agents/from-template.service.d.ts +60 -0
  25. package/dist/agents/from-template.service.js +161 -0
  26. package/dist/agents/org-templates.d.ts +176 -0
  27. package/dist/agents/org-templates.js +827 -0
  28. package/dist/agents/pending-connector-requests.d.ts +77 -0
  29. package/dist/agents/pending-connector-requests.js +215 -0
  30. package/dist/agents/pending-connectors.controller.d.ts +39 -0
  31. package/dist/agents/pending-connectors.controller.js +91 -0
  32. package/dist/agents/pending-connectors.service.d.ts +62 -0
  33. package/dist/agents/pending-connectors.service.js +282 -0
  34. package/dist/agents/templates.controller.d.ts +86 -5
  35. package/dist/agents/templates.controller.js +171 -7
  36. package/dist/agents/templates.d.ts +127 -23
  37. package/dist/agents/templates.js +475 -52
  38. package/dist/background/background.module.js +8 -1
  39. package/dist/background/finish.d.ts +3 -2
  40. package/dist/background/launch-lock.d.ts +4 -3
  41. package/dist/background/launch-lock.js +4 -3
  42. package/dist/background/poll.job.d.ts +9 -6
  43. package/dist/background/poll.job.js +30 -22
  44. package/dist/background/session.d.ts +13 -2
  45. package/dist/background/session.js +13 -0
  46. package/dist/background/stop.d.ts +12 -6
  47. package/dist/background/stop.js +57 -39
  48. package/dist/background/store.d.ts +18 -6
  49. package/dist/background/store.js +12 -6
  50. package/dist/background/tasks.service.d.ts +15 -5
  51. package/dist/background/tasks.service.js +42 -17
  52. package/dist/background/wake-rules.d.ts +27 -18
  53. package/dist/background/wake-rules.js +52 -22
  54. package/dist/background/wake.d.ts +13 -11
  55. package/dist/background/wake.js +20 -14
  56. package/dist/catalog/admin-catalog.controller.d.ts +129 -30
  57. package/dist/catalog/admin-catalog.controller.js +213 -42
  58. package/dist/catalog/catalog-content.d.ts +58 -32
  59. package/dist/catalog/catalog-content.js +34 -8
  60. package/dist/catalog/catalog-import.module.d.ts +7 -0
  61. package/dist/catalog/catalog-import.module.js +60 -0
  62. package/dist/catalog/catalog-items.d.ts +111 -7
  63. package/dist/catalog/catalog-items.js +279 -13
  64. package/dist/catalog/catalog-scope.service.d.ts +260 -0
  65. package/dist/catalog/catalog-scope.service.js +1116 -0
  66. package/dist/catalog/catalog.module.d.ts +7 -9
  67. package/dist/catalog/catalog.module.js +41 -31
  68. package/dist/catalog/catalog.service.d.ts +101 -29
  69. package/dist/catalog/catalog.service.js +104 -106
  70. package/dist/catalog/cli.d.ts +11 -1
  71. package/dist/catalog/cli.js +26 -1
  72. package/dist/catalog/component-promotion.d.ts +96 -0
  73. package/dist/catalog/component-promotion.js +395 -0
  74. package/dist/catalog/component-scope.controller.d.ts +152 -0
  75. package/dist/catalog/component-scope.controller.js +287 -0
  76. package/dist/catalog/component-scope.service.d.ts +303 -0
  77. package/dist/catalog/component-scope.service.js +936 -0
  78. package/dist/catalog/component-state.d.ts +174 -0
  79. package/dist/catalog/component-state.js +437 -0
  80. package/dist/catalog/job-ids.d.ts +30 -0
  81. package/dist/catalog/job-ids.js +25 -0
  82. package/dist/catalog/marketplace-fetch.d.ts +1 -1
  83. package/dist/catalog/marketplaces.controller.d.ts +22 -5
  84. package/dist/catalog/marketplaces.controller.js +56 -7
  85. package/dist/catalog/marketplaces.service.d.ts +54 -14
  86. package/dist/catalog/marketplaces.service.js +71 -22
  87. package/dist/catalog/org-catalog.controller.d.ts +125 -34
  88. package/dist/catalog/org-catalog.controller.js +181 -65
  89. package/dist/catalog/org-catalog.service.d.ts +65 -33
  90. package/dist/catalog/org-catalog.service.js +324 -157
  91. package/dist/catalog/org-extension-switch.d.ts +41 -0
  92. package/dist/catalog/org-extension-switch.js +115 -0
  93. package/dist/catalog/org-extension.controller.d.ts +119 -0
  94. package/dist/catalog/org-extension.controller.js +266 -0
  95. package/dist/catalog/org-plugin-uploads.controller.d.ts +98 -0
  96. package/dist/catalog/org-plugin-uploads.controller.js +213 -0
  97. package/dist/catalog/org-plugin-uploads.d.ts +63 -0
  98. package/dist/catalog/org-plugin-uploads.js +116 -0
  99. package/dist/catalog/owned-items.d.ts +184 -0
  100. package/dist/catalog/owned-items.js +789 -0
  101. package/dist/catalog/owned-plugin-cleanup.d.ts +56 -0
  102. package/dist/catalog/owned-plugin-cleanup.js +194 -0
  103. package/dist/catalog/ownership.d.ts +172 -0
  104. package/dist/catalog/ownership.js +326 -0
  105. package/dist/catalog/platform-components.d.ts +221 -0
  106. package/dist/catalog/platform-components.js +761 -0
  107. package/dist/catalog/platform-migration.d.ts +115 -0
  108. package/dist/catalog/platform-migration.js +582 -0
  109. package/dist/catalog/plugin-import.d.ts +178 -34
  110. package/dist/catalog/plugin-import.js +622 -82
  111. package/dist/catalog/plugin-install.d.ts +185 -41
  112. package/dist/catalog/plugin-install.js +758 -126
  113. package/dist/catalog/plugin-upgrade.d.ts +260 -225
  114. package/dist/catalog/plugin-upgrade.js +1147 -1136
  115. package/dist/catalog/request-rules.d.ts +65 -0
  116. package/dist/catalog/request-rules.js +217 -0
  117. package/dist/catalog/requests.service.d.ts +193 -118
  118. package/dist/catalog/requests.service.js +526 -343
  119. package/dist/catalog/reserved-names.d.ts +8 -0
  120. package/dist/catalog/reserved-names.js +42 -0
  121. package/dist/catalog/scope-orgs.d.ts +21 -0
  122. package/dist/catalog/scope-orgs.js +67 -0
  123. package/dist/catalog/scope-state.d.ts +35 -0
  124. package/dist/catalog/scope-state.js +87 -0
  125. package/dist/catalog/scope-sync-workers.d.ts +7 -0
  126. package/dist/catalog/scope-sync-workers.js +29 -0
  127. package/dist/catalog/scope-sync.d.ts +176 -0
  128. package/dist/catalog/scope-sync.js +576 -0
  129. package/dist/catalog/scope.d.ts +42 -0
  130. package/dist/catalog/scope.js +42 -0
  131. package/dist/catalog/unshare.d.ts +22 -0
  132. package/dist/catalog/unshare.js +118 -0
  133. package/dist/channels/actions.js +1 -0
  134. package/dist/channels/cards.js +20 -2
  135. package/dist/channels/channels.module.js +2 -0
  136. package/dist/channels/inbound.d.ts +9 -1
  137. package/dist/channels/inbound.js +67 -5
  138. package/dist/channels/phrases.d.ts +35 -0
  139. package/dist/channels/phrases.js +29 -0
  140. package/dist/config/docs.js +3 -1
  141. package/dist/config/schema.d.ts +6 -2
  142. package/dist/config/schema.js +46 -22
  143. package/dist/conversations/access.d.ts +6 -4
  144. package/dist/conversations/access.js +27 -5
  145. package/dist/conversations/agent-tree.d.ts +46 -0
  146. package/dist/conversations/agent-tree.js +92 -0
  147. package/dist/conversations/conversations.controller.d.ts +43 -18
  148. package/dist/conversations/conversations.controller.js +79 -38
  149. package/dist/conversations/conversations.module.d.ts +1 -1
  150. package/dist/conversations/conversations.module.js +7 -7
  151. package/dist/conversations/conversations.service.d.ts +69 -12
  152. package/dist/conversations/conversations.service.js +106 -27
  153. package/dist/conversations/environment-status.d.ts +24 -0
  154. package/dist/conversations/environment-status.js +71 -0
  155. package/dist/conversations/event-log.d.ts +20 -5
  156. package/dist/conversations/event-log.js +60 -0
  157. package/dist/conversations/events.d.ts +84 -2
  158. package/dist/conversations/events.js +91 -17
  159. package/dist/conversations/queue.service.d.ts +1 -1
  160. package/dist/conversations/queue.service.js +5 -0
  161. package/dist/conversations/titles.d.ts +5 -3
  162. package/dist/conversations/titles.js +21 -8
  163. package/dist/conversations/tree.d.ts +17 -0
  164. package/dist/conversations/tree.js +42 -0
  165. package/dist/ctx/create-ctx.d.ts +5 -0
  166. package/dist/ctx/create-ctx.js +15 -5
  167. package/dist/db/kernel-schema.d.ts +362 -18
  168. package/dist/environments/access.d.ts +41 -0
  169. package/dist/environments/access.js +77 -0
  170. package/dist/environments/conversation-environments.d.ts +61 -0
  171. package/dist/environments/conversation-environments.js +170 -0
  172. package/dist/environments/dto.d.ts +25 -0
  173. package/dist/environments/dto.js +12 -0
  174. package/dist/environments/environments.controller.d.ts +33 -0
  175. package/dist/environments/environments.controller.js +110 -0
  176. package/dist/environments/environments.module.d.ts +8 -0
  177. package/dist/environments/environments.module.js +27 -0
  178. package/dist/environments/environments.service.d.ts +153 -0
  179. package/dist/environments/environments.service.js +541 -0
  180. package/dist/environments/legacy-cleanup.job.d.ts +34 -0
  181. package/dist/environments/legacy-cleanup.job.js +141 -0
  182. package/dist/errors.d.ts +82 -2
  183. package/dist/errors.js +82 -2
  184. package/dist/evals/reconstruct.d.ts +18 -9
  185. package/dist/evals/reconstruct.js +26 -7
  186. package/dist/evals/run-replay.d.ts +4 -2
  187. package/dist/evals/run-replay.js +16 -4
  188. package/dist/evals/step-replay.d.ts +2 -5
  189. package/dist/evals/step-replay.js +1 -1
  190. package/dist/evals/trajectory.service.d.ts +8 -3
  191. package/dist/evals/trajectory.service.js +26 -14
  192. package/dist/evals/worker.d.ts +5 -5
  193. package/dist/evals/worker.js +9 -3
  194. package/dist/extensions/admin-ops.d.ts +36 -10
  195. package/dist/extensions/admin-ops.js +65 -42
  196. package/dist/extensions/admin-view.d.ts +37 -10
  197. package/dist/extensions/admin-view.js +103 -20
  198. package/dist/extensions/bootstrap.d.ts +17 -4
  199. package/dist/extensions/bootstrap.js +70 -9
  200. package/dist/extensions/cli.d.ts +12 -0
  201. package/dist/extensions/cli.js +11 -2
  202. package/dist/extensions/deployment-config.d.ts +28 -5
  203. package/dist/extensions/deployment-config.js +48 -7
  204. package/dist/extensions/effective-config.d.ts +127 -0
  205. package/dist/extensions/effective-config.js +368 -0
  206. package/dist/extensions/extensions.module.js +8 -2
  207. package/dist/extensions/hooks.d.ts +37 -4
  208. package/dist/extensions/hooks.js +82 -16
  209. package/dist/extensions/host.d.ts +19 -1
  210. package/dist/extensions/host.js +30 -7
  211. package/dist/extensions/installs.d.ts +20 -8
  212. package/dist/extensions/installs.js +37 -15
  213. package/dist/extensions/org-config.d.ts +75 -6
  214. package/dist/extensions/org-config.js +184 -32
  215. package/dist/extensions/org-levels.d.ts +37 -0
  216. package/dist/extensions/org-levels.js +71 -0
  217. package/dist/extensions/org-overrides.d.ts +151 -0
  218. package/dist/extensions/org-overrides.js +524 -0
  219. package/dist/extensions/permission-view.d.ts +16 -4
  220. package/dist/extensions/permission-view.js +4 -4
  221. package/dist/extensions/plugin-items.d.ts +21 -0
  222. package/dist/extensions/plugin-items.js +42 -0
  223. package/dist/extensions/point-defaults.d.ts +12 -5
  224. package/dist/extensions/point-defaults.js +37 -9
  225. package/dist/extensions/resolve.d.ts +5 -1
  226. package/dist/extensions/resolve.js +15 -2
  227. package/dist/files/previewers.d.ts +8 -1
  228. package/dist/files/previewers.js +35 -6
  229. package/dist/http/api.module.js +23 -3
  230. package/dist/http/app.d.ts +11 -2
  231. package/dist/http/app.js +31 -5
  232. package/dist/identity/accounts.d.ts +29 -29
  233. package/dist/identity/accounts.js +47 -47
  234. package/dist/identity/audit.d.ts +2 -1
  235. package/dist/identity/auth.guard.d.ts +13 -5
  236. package/dist/identity/auth.guard.js +26 -9
  237. package/dist/identity/identity.module.d.ts +1 -1
  238. package/dist/identity/identity.module.js +4 -4
  239. package/dist/identity/me.controller.js +1 -1
  240. package/dist/identity/principal.d.ts +3 -3
  241. package/dist/identity/principal.js +3 -3
  242. package/dist/identity/settings.d.ts +22 -11
  243. package/dist/identity/settings.js +53 -18
  244. package/dist/identity/{enterprise-admin.d.ts → super-admin.d.ts} +5 -5
  245. package/dist/identity/{enterprise-admin.js → super-admin.js} +24 -24
  246. package/dist/inbox/inbox.module.d.ts +4 -1
  247. package/dist/inbox/inbox.module.js +7 -3
  248. package/dist/inbox/inbox.service.d.ts +62 -3
  249. package/dist/inbox/inbox.service.js +74 -4
  250. package/dist/inbox/org-notices.d.ts +63 -0
  251. package/dist/inbox/org-notices.js +91 -0
  252. package/dist/inbox/platform-inbox.controller.d.ts +23 -0
  253. package/dist/inbox/platform-inbox.controller.js +58 -0
  254. package/dist/inbox/platform-inbox.service.d.ts +151 -0
  255. package/dist/inbox/platform-inbox.service.js +263 -0
  256. package/dist/inbox/platform-notices.d.ts +19 -0
  257. package/dist/inbox/platform-notices.js +9 -0
  258. package/dist/index.d.ts +1 -1
  259. package/dist/index.js +1 -1
  260. package/dist/infra/cli/kernel-cli.module.js +9 -1
  261. package/dist/infra/config/kernel-config.service.js +21 -1
  262. package/dist/infra/database/xact-lock.d.ts +1 -1
  263. package/dist/infra/database/xact-lock.js +1 -1
  264. package/dist/infra/events/kernel-events.d.ts +11 -2
  265. package/dist/infra/queue/add-job-once.d.ts +14 -0
  266. package/dist/infra/queue/add-job-once.js +16 -0
  267. package/dist/kernel.module.js +6 -0
  268. package/dist/lifecycle/kernel-lifecycle.d.ts +1 -1
  269. package/dist/lifecycle/kernel-lifecycle.js +4 -4
  270. package/dist/models/prices.d.ts +5 -5
  271. package/dist/models/prices.js +4 -4
  272. package/dist/models/purposes.controller.d.ts +6 -4
  273. package/dist/models/purposes.controller.js +13 -7
  274. package/dist/models/purposes.d.ts +20 -9
  275. package/dist/models/purposes.js +17 -8
  276. package/dist/orgs/directory-sync.d.ts +14 -5
  277. package/dist/orgs/directory-sync.js +41 -17
  278. package/dist/orgs/offboarding.d.ts +9 -7
  279. package/dist/orgs/offboarding.js +28 -17
  280. package/dist/orgs/org-lock.d.ts +5 -0
  281. package/dist/orgs/org-lock.js +13 -0
  282. package/dist/orgs/org.guard.d.ts +10 -0
  283. package/dist/orgs/org.guard.js +43 -32
  284. package/dist/orgs/orgs.module.js +3 -0
  285. package/dist/orgs/orgs.service.d.ts +20 -7
  286. package/dist/orgs/orgs.service.js +32 -12
  287. package/dist/orgs/roles.d.ts +1 -1
  288. package/dist/orgs/roles.js +5 -1
  289. package/dist/orgs/settings.controller.d.ts +1 -1
  290. package/dist/orgs/settings.service.d.ts +15 -3
  291. package/dist/orgs/settings.service.js +6 -2
  292. package/dist/overrides.d.ts +3 -0
  293. package/dist/overrides.js +2 -0
  294. package/dist/platform/actor.d.ts +48 -0
  295. package/dist/platform/actor.js +100 -0
  296. package/dist/platform/agent-docs.d.ts +18 -0
  297. package/dist/platform/agent-docs.js +59 -0
  298. package/dist/platform/availability.d.ts +14 -0
  299. package/dist/platform/availability.js +43 -0
  300. package/dist/platform/errors.d.ts +11 -0
  301. package/dist/platform/errors.js +26 -0
  302. package/dist/platform/exclusions.d.ts +12 -0
  303. package/dist/platform/exclusions.js +1387 -0
  304. package/dist/platform/method.d.ts +6 -0
  305. package/dist/platform/method.js +15 -0
  306. package/dist/platform/operation.d.ts +92 -0
  307. package/dist/platform/operation.js +35 -0
  308. package/dist/platform/ops/agent-templates.ops.d.ts +14 -0
  309. package/dist/platform/ops/agent-templates.ops.js +92 -0
  310. package/dist/platform/ops/agents.ops.d.ts +19 -0
  311. package/dist/platform/ops/agents.ops.js +294 -0
  312. package/dist/platform/ops/connectors.ops.d.ts +15 -0
  313. package/dist/platform/ops/connectors.ops.js +126 -0
  314. package/dist/platform/ops/errors.d.ts +11 -0
  315. package/dist/platform/ops/errors.js +22 -0
  316. package/dist/platform/ops/extensions.ops.d.ts +19 -0
  317. package/dist/platform/ops/extensions.ops.js +116 -0
  318. package/dist/platform/ops/marketplaces.ops.d.ts +16 -0
  319. package/dist/platform/ops/marketplaces.ops.js +157 -0
  320. package/dist/platform/ops/paging.d.ts +14 -0
  321. package/dist/platform/ops/paging.js +20 -0
  322. package/dist/platform/ops/platform.ops.d.ts +23 -0
  323. package/dist/platform/ops/platform.ops.js +158 -0
  324. package/dist/platform/ops/plugins.ops.d.ts +33 -0
  325. package/dist/platform/ops/plugins.ops.js +377 -0
  326. package/dist/platform/ops/requests.ops.d.ts +14 -0
  327. package/dist/platform/ops/requests.ops.js +153 -0
  328. package/dist/platform/ops/role.d.ts +4 -0
  329. package/dist/platform/ops/role.js +10 -0
  330. package/dist/platform/ops/skills.ops.d.ts +13 -0
  331. package/dist/platform/ops/skills.ops.js +98 -0
  332. package/dist/platform/ops/summary.d.ts +10 -0
  333. package/dist/platform/ops/summary.js +18 -0
  334. package/dist/platform/platform-ops.module.d.ts +7 -0
  335. package/dist/platform/platform-ops.module.js +55 -0
  336. package/dist/platform/platform.module.d.ts +8 -0
  337. package/dist/platform/platform.module.js +25 -0
  338. package/dist/platform/redact-orgs.d.ts +7 -0
  339. package/dist/platform/redact-orgs.js +52 -0
  340. package/dist/platform/registry.d.ts +30 -0
  341. package/dist/platform/registry.js +111 -0
  342. package/dist/roles/worker-role.d.ts +6 -4
  343. package/dist/roles/worker-role.js +14 -7
  344. package/dist/roles/worker.module.d.ts +1 -1
  345. package/dist/roles/worker.module.js +9 -1
  346. package/dist/runtime/context/build.d.ts +6 -4
  347. package/dist/runtime/context/build.js +26 -7
  348. package/dist/runtime/context/claude-tools.d.ts +2 -1
  349. package/dist/runtime/context/claude-tools.js +5 -4
  350. package/dist/runtime/context/compaction.js +9 -0
  351. package/dist/runtime/context/reminders.d.ts +2 -0
  352. package/dist/runtime/context/reminders.js +2 -0
  353. package/dist/runtime/context/skills.js +9 -2
  354. package/dist/runtime/context/tool-changes.d.ts +27 -0
  355. package/dist/runtime/context/tool-changes.js +60 -0
  356. package/dist/runtime/hook-calls.js +2 -0
  357. package/dist/runtime/langgraph-loop.d.ts +3 -1
  358. package/dist/runtime/langgraph-loop.js +35 -17
  359. package/dist/runtime/loop.d.ts +32 -4
  360. package/dist/runtime/maintenance.d.ts +7 -4
  361. package/dist/runtime/maintenance.js +23 -8
  362. package/dist/runtime/model-call.d.ts +30 -8
  363. package/dist/runtime/model-call.js +69 -19
  364. package/dist/runtime/run-control.d.ts +11 -1
  365. package/dist/runtime/run-control.js +12 -0
  366. package/dist/runtime/run-drafts.d.ts +85 -0
  367. package/dist/runtime/run-drafts.js +230 -0
  368. package/dist/runtime/run-jobs.d.ts +3 -5
  369. package/dist/runtime/run-jobs.js +3 -7
  370. package/dist/runtime/run-queue.d.ts +37 -3
  371. package/dist/runtime/run-queue.js +188 -11
  372. package/dist/runtime/run-worker.d.ts +11 -5
  373. package/dist/runtime/run-worker.js +54 -31
  374. package/dist/runtime/runtime.module.js +3 -0
  375. package/dist/runtime/step-log.d.ts +9 -4
  376. package/dist/runtime/step-log.js +8 -5
  377. package/dist/runtime/stream.controller.d.ts +23 -1
  378. package/dist/runtime/stream.controller.js +60 -3
  379. package/dist/runtime/stream.d.ts +4 -1
  380. package/dist/runtime/stream.js +27 -3
  381. package/dist/runtime/subagents/child.d.ts +55 -7
  382. package/dist/runtime/subagents/child.js +105 -7
  383. package/dist/runtime/subagents/definition.d.ts +12 -3
  384. package/dist/runtime/subagents/definition.js +43 -29
  385. package/dist/runtime/subagents/deliveries.d.ts +71 -0
  386. package/dist/runtime/subagents/deliveries.js +228 -0
  387. package/dist/runtime/subagents/dispatch.d.ts +115 -26
  388. package/dist/runtime/subagents/dispatch.js +212 -141
  389. package/dist/runtime/subagents/limits.d.ts +24 -5
  390. package/dist/runtime/subagents/limits.js +40 -6
  391. package/dist/runtime/subagents/messages.d.ts +95 -0
  392. package/dist/runtime/subagents/messages.js +328 -0
  393. package/dist/runtime/subagents/preamble.d.ts +4 -4
  394. package/dist/runtime/subagents/preamble.js +9 -7
  395. package/dist/runtime/subagents/progress.d.ts +8 -6
  396. package/dist/runtime/subagents/progress.js +11 -6
  397. package/dist/runtime/subagents/render.d.ts +30 -0
  398. package/dist/runtime/subagents/render.js +53 -0
  399. package/dist/runtime/subagents/roster.d.ts +24 -7
  400. package/dist/runtime/subagents/roster.js +47 -11
  401. package/dist/runtime/subagents/skill-fork.d.ts +3 -2
  402. package/dist/runtime/subagents/skill-fork.js +8 -4
  403. package/dist/runtime/subagents/status.d.ts +14 -0
  404. package/dist/runtime/subagents/status.js +23 -0
  405. package/dist/runtime/subagents/subagents.service.d.ts +7 -4
  406. package/dist/runtime/subagents/subagents.service.js +11 -6
  407. package/dist/runtime/usage-report.js +17 -12
  408. package/dist/runtime/waits.d.ts +140 -37
  409. package/dist/runtime/waits.js +394 -106
  410. package/dist/sandbox/jobs.d.ts +40 -13
  411. package/dist/sandbox/jobs.js +57 -20
  412. package/dist/sandbox/leases.d.ts +37 -54
  413. package/dist/sandbox/leases.js +71 -115
  414. package/dist/sandbox/providers.d.ts +2 -2
  415. package/dist/sandbox/providers.js +1 -1
  416. package/dist/sandbox/sandbox.module.d.ts +3 -2
  417. package/dist/sandbox/sandbox.module.js +4 -3
  418. package/dist/sandbox/sandbox.service.d.ts +229 -134
  419. package/dist/sandbox/sandbox.service.js +630 -409
  420. package/dist/skills/catalog.d.ts +3 -2
  421. package/dist/skills/catalog.js +21 -43
  422. package/dist/skills/changes.controller.d.ts +7 -0
  423. package/dist/skills/changes.controller.js +19 -1
  424. package/dist/skills/invoke.js +8 -3
  425. package/dist/skills/package.d.ts +20 -1
  426. package/dist/skills/package.js +28 -1
  427. package/dist/skills/skills.controller.d.ts +39 -4
  428. package/dist/skills/skills.controller.js +88 -10
  429. package/dist/skills/skills.module.js +10 -1
  430. package/dist/skills/skills.service.d.ts +106 -26
  431. package/dist/skills/skills.service.js +421 -75
  432. package/dist/skills/usable.d.ts +81 -0
  433. package/dist/skills/usable.js +379 -0
  434. package/dist/tools/approvals.service.d.ts +20 -2
  435. package/dist/tools/approvals.service.js +23 -4
  436. package/dist/tools/builtin-names.d.ts +21 -5
  437. package/dist/tools/builtin-names.js +30 -5
  438. package/dist/tools/builtins/agent.d.ts +23 -21
  439. package/dist/tools/builtins/agent.js +62 -55
  440. package/dist/tools/builtins/builtin-tools.d.ts +6 -2
  441. package/dist/tools/builtins/builtin-tools.js +37 -12
  442. package/dist/tools/builtins/handback.d.ts +28 -0
  443. package/dist/tools/builtins/handback.js +53 -0
  444. package/dist/tools/builtins/platform.d.ts +34 -0
  445. package/dist/tools/builtins/platform.js +362 -0
  446. package/dist/tools/builtins/sandbox/bash.js +13 -3
  447. package/dist/tools/builtins/sandbox/common.d.ts +43 -24
  448. package/dist/tools/builtins/sandbox/common.js +80 -45
  449. package/dist/tools/builtins/sandbox/edit.js +2 -2
  450. package/dist/tools/builtins/sandbox/glob.js +2 -2
  451. package/dist/tools/builtins/sandbox/grep.js +2 -4
  452. package/dist/tools/builtins/sandbox/index.d.ts +1 -1
  453. package/dist/tools/builtins/sandbox/index.js +1 -1
  454. package/dist/tools/builtins/sandbox/read.js +1 -1
  455. package/dist/tools/builtins/sandbox/task-output.d.ts +14 -3
  456. package/dist/tools/builtins/sandbox/task-output.js +30 -5
  457. package/dist/tools/builtins/sandbox/task-stop.js +2 -1
  458. package/dist/tools/builtins/sandbox/write.js +2 -2
  459. package/dist/tools/builtins/send-message.d.ts +56 -0
  460. package/dist/tools/builtins/send-message.js +100 -0
  461. package/dist/tools/builtins/skill-load.d.ts +22 -14
  462. package/dist/tools/builtins/skill-load.js +86 -57
  463. package/dist/tools/builtins/skill-write.js +1 -1
  464. package/dist/tools/builtins/web/extract.js +5 -1
  465. package/dist/tools/builtins/web/fetch.js +1 -0
  466. package/dist/tools/builtins/web/search.js +1 -0
  467. package/dist/tools/connectors.controller.d.ts +10 -0
  468. package/dist/tools/connectors.controller.js +12 -0
  469. package/dist/tools/connectors.service.d.ts +46 -5
  470. package/dist/tools/connectors.service.js +94 -15
  471. package/dist/tools/extension-tools.controller.d.ts +14 -0
  472. package/dist/tools/extension-tools.controller.js +37 -0
  473. package/dist/tools/info.d.ts +42 -1
  474. package/dist/tools/info.js +64 -1
  475. package/dist/tools/org-tool-switches.d.ts +74 -0
  476. package/dist/tools/org-tool-switches.js +184 -0
  477. package/dist/tools/pipeline.d.ts +46 -40
  478. package/dist/tools/pipeline.js +187 -364
  479. package/dist/tools/policy.d.ts +1 -1
  480. package/dist/tools/policy.js +36 -16
  481. package/dist/tools/registry.d.ts +98 -5
  482. package/dist/tools/registry.js +87 -9
  483. package/dist/tools/tools.module.js +12 -2
  484. package/dist/ui/views.d.ts +2 -1
  485. package/dist/ui/views.js +17 -3
  486. package/package.json +3 -3
  487. package/src/migrations/0074_subagent_tree.sql +50 -0
  488. package/src/migrations/0075_plugin_scope.sql +61 -0
  489. package/src/migrations/0076_skills_created_by_nullable.sql +6 -0
  490. package/src/migrations/0077_scope_requests.sql +52 -0
  491. package/src/migrations/0078_scope_grant_switches.sql +18 -0
  492. package/src/migrations/0079_scope_live_install_switches.sql +19 -0
  493. package/src/migrations/0080_rename_enterprise_admin.sql +18 -0
  494. package/src/migrations/0081_platform_components.sql +129 -0
  495. package/src/migrations/0082_platform_migration.sql +33 -0
  496. package/src/migrations/0083_plugin_scope_sync_failures.sql +15 -0
  497. package/src/migrations/0084_org_owned_items.sql +85 -0
  498. package/src/migrations/0085_agent_templates_phase4.sql +45 -0
  499. package/src/migrations/0086_org_layering.sql +30 -0
  500. package/src/migrations/0087_approval_summary.sql +6 -0
  501. package/src/migrations/0088_environments.sql +80 -0
  502. package/dist/catalog/upgrade-targets.d.ts +0 -56
  503. package/dist/catalog/upgrade-targets.js +0 -90
  504. package/dist/conversations/sandbox-status.d.ts +0 -24
  505. package/dist/conversations/sandbox-status.js +0 -52
  506. package/dist/extensions/org-config.controller.d.ts +0 -32
  507. package/dist/extensions/org-config.controller.js +0 -70
@@ -0,0 +1,263 @@
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 { sql } from "kysely";
12
+ import { CatalogService } from "../catalog/catalog.service.js";
13
+ import { CatalogRequestsService } from "../catalog/requests.service.js";
14
+ import { ApiError } from "../errors.js";
15
+ import { KernelDb } from "../infra/database/kernel-db.js";
16
+ /** The most items one platform inbox read returns. */
17
+ export const PLATFORM_INBOX_MAX_ITEMS = 100;
18
+ /** The most open scope sync failures one read takes. */
19
+ export const SCOPE_SYNC_FAILURES_LIST_MAX = 200;
20
+ /**
21
+ * A platform components migration run unfinished this long after its start is stuck (its worker
22
+ * stopped mid-run; a run takes seconds, and the next one starts at the next worker start or day).
23
+ */
24
+ export const MIGRATION_RUN_STUCK_MS = 60 * 60_000;
25
+ /** Plugin install statuses of a plugin that is on in the org. */
26
+ const LIVE_INSTALL = ["installing", "installed", "upgrading"];
27
+ /**
28
+ * The super admin's inbox (plugin scope spec §5.1 rule 5, §13.5): what waits on the platform,
29
+ * gathered from the sources the admin pages read (the 待确认 tab's requests and permission
30
+ * confirmations), plus the scope sync's open failures and the platform components migration's
31
+ * latest run. Stateless, read live from PG.
32
+ */
33
+ let PlatformInboxService = class PlatformInboxService {
34
+ requests;
35
+ catalog;
36
+ kdb;
37
+ constructor(requests, catalog, kdb) {
38
+ this.requests = requests;
39
+ this.catalog = catalog;
40
+ this.kdb = kdb;
41
+ }
42
+ async list() {
43
+ const [requests, requestCount, pending, failures, failureCount, run, notices, noticeCount] = await Promise.all([
44
+ this.requests.listDeployment(),
45
+ this.requests.countPendingDeployment(),
46
+ this.catalog.list({ pending: true }),
47
+ this.scopeSyncFailures(),
48
+ this.countScopeSyncFailures(),
49
+ this.migrationRun(),
50
+ this.notices(),
51
+ this.countNotices(),
52
+ ]);
53
+ const all = [
54
+ ...requests.map((r) => ({
55
+ type: "catalog_request",
56
+ id: r.id,
57
+ createdAt: r.createdAt,
58
+ request: r,
59
+ })),
60
+ ...pending.map((i) => ({
61
+ type: i.owner.kind === "org" ? "org_upload_pending" : "permission_confirmation",
62
+ id: i.id,
63
+ createdAt: i.updatedAt,
64
+ item: i,
65
+ })),
66
+ ...failures.map((f) => ({
67
+ type: "scope_sync_failed",
68
+ id: `${f.item.id}/${f.org.id}`,
69
+ createdAt: f.failedAt,
70
+ failure: f,
71
+ })),
72
+ ...notices.map((n) => ({
73
+ type: "ownership_transferred",
74
+ id: n.id,
75
+ createdAt: n.createdAt,
76
+ notice: n,
77
+ })),
78
+ ...(run === null
79
+ ? []
80
+ : [
81
+ {
82
+ type: "platform_migration",
83
+ id: run.id,
84
+ createdAt: run.finishedAt ?? run.startedAt,
85
+ run,
86
+ },
87
+ ]),
88
+ ];
89
+ // newest first; equal times by id (a stable order)
90
+ all.sort((a, b) => a.createdAt !== b.createdAt
91
+ ? a.createdAt < b.createdAt
92
+ ? 1
93
+ : -1
94
+ : a.id < b.id
95
+ ? -1
96
+ : a.id > b.id
97
+ ? 1
98
+ : 0);
99
+ const total = requestCount + pending.length + failureCount + (run === null ? 0 : 1) + noticeCount;
100
+ const items = all.slice(0, PLATFORM_INBOX_MAX_ITEMS);
101
+ return { items, truncated: total > items.length, total };
102
+ }
103
+ /**
104
+ * How many items wait (the sidebar's count): the same sources, counted where they can be (the
105
+ * requests and the failures; the permission confirmations are the catalog's pending list).
106
+ */
107
+ async count() {
108
+ const [requests, pending, failures, run, notices] = await Promise.all([
109
+ this.requests.countPendingDeployment(),
110
+ this.catalog.list({ pending: true }),
111
+ this.countScopeSyncFailures(),
112
+ this.migrationRun(),
113
+ this.countNotices(),
114
+ ]);
115
+ return requests + pending.length + failures + (run === null ? 0 : 1) + notices;
116
+ }
117
+ async countNotices() {
118
+ const r = await this.kdb.db
119
+ .selectFrom("platform_notices")
120
+ .select(sql `count(*)`.as("n"))
121
+ .where("dismissed_at", "is", null)
122
+ .executeTakeFirstOrThrow();
123
+ return Number(r.n);
124
+ }
125
+ /** The open platform notices, newest first, at most {@link PLATFORM_INBOX_MAX_ITEMS}. */
126
+ async notices() {
127
+ const rows = await this.kdb.db
128
+ .selectFrom("platform_notices")
129
+ .select(["id", "kind", "detail", "created_at"])
130
+ .where("dismissed_at", "is", null)
131
+ .orderBy("created_at", "desc")
132
+ .orderBy("id")
133
+ .limit(PLATFORM_INBOX_MAX_ITEMS)
134
+ .execute();
135
+ return rows.map((r) => ({
136
+ id: r.id,
137
+ kind: r.kind,
138
+ createdAt: r.created_at.toISOString(),
139
+ detail: r.detail,
140
+ }));
141
+ }
142
+ /**
143
+ * A super admin dismisses a platform notice (for every super admin). Dismissing one already
144
+ * dismissed is fine; no notice with that id -> `inbox.notice_not_found`.
145
+ */
146
+ async dismissNotice(accountId, id) {
147
+ if (!UUID_RE.test(id))
148
+ throw new ApiError("inbox.notice_not_found", "Notice not found");
149
+ const r = await this.kdb.db
150
+ .updateTable("platform_notices")
151
+ .set({ dismissed_at: sql `now()`, dismissed_by: accountId })
152
+ .where("id", "=", id)
153
+ .where("dismissed_at", "is", null)
154
+ .executeTakeFirst();
155
+ if (r.numUpdatedRows > 0n)
156
+ return;
157
+ const exists = await this.kdb.db
158
+ .selectFrom("platform_notices")
159
+ .select("id")
160
+ .where("id", "=", id)
161
+ .executeTakeFirst();
162
+ if (!exists)
163
+ throw new ApiError("inbox.notice_not_found", "Notice not found");
164
+ }
165
+ /**
166
+ * The open failures still worth a look, joined to their item and org: of a live item and org,
167
+ * and the pair still differs in the failed direction (a person may have converged it meanwhile):
168
+ * an install failure while the org has no live install of the item; an uninstall or dependencies
169
+ * failure while it has one.
170
+ */
171
+ failureRows() {
172
+ return this.kdb.db
173
+ .selectFrom("plugin_scope_sync_failures as f")
174
+ .innerJoin("catalog_items as i", "i.id", "f.item_id")
175
+ .innerJoin("orgs as o", "o.id", "f.org_id")
176
+ .where("i.deleted_at", "is", null)
177
+ .where("o.deleted_at", "is", null)
178
+ .where((eb) => {
179
+ const live = eb.exists(eb
180
+ .selectFrom("plugin_installs as p")
181
+ .select("p.id")
182
+ .whereRef("p.org_id", "=", "f.org_id")
183
+ .whereRef("p.item_id", "=", "f.item_id")
184
+ .where("p.status", "in", [...LIVE_INSTALL]));
185
+ return eb.or([
186
+ eb.and([eb("f.op", "=", "install"), eb.not(live)]),
187
+ eb.and([eb("f.op", "in", ["uninstall", "dependencies"]), live]),
188
+ ]);
189
+ });
190
+ }
191
+ async countScopeSyncFailures() {
192
+ const r = await this.failureRows()
193
+ .select(sql `count(*)`.as("n"))
194
+ .executeTakeFirstOrThrow();
195
+ return Number(r.n);
196
+ }
197
+ /** The open scope sync failures ({@link failureRows}), newest first. */
198
+ async scopeSyncFailures() {
199
+ const rows = await this.failureRows()
200
+ .select([
201
+ "f.item_id",
202
+ "i.name as item_name",
203
+ "i.display_name",
204
+ "f.org_id",
205
+ "o.name as org_name",
206
+ "f.op",
207
+ "f.code",
208
+ "f.message",
209
+ "f.failed_at",
210
+ ])
211
+ .orderBy("f.failed_at", "desc")
212
+ .orderBy("f.item_id")
213
+ .orderBy("f.org_id")
214
+ .limit(SCOPE_SYNC_FAILURES_LIST_MAX)
215
+ .execute();
216
+ return rows.map((r) => ({
217
+ item: { id: r.item_id, name: r.item_name, displayName: r.display_name },
218
+ org: { id: r.org_id, name: r.org_name },
219
+ op: r.op,
220
+ code: r.code,
221
+ message: r.message,
222
+ failedAt: r.failed_at.toISOString(),
223
+ }));
224
+ }
225
+ /**
226
+ * The latest migration run when it needs a look (see {@link MigrationRunView}); null when it
227
+ * finished without failed items, is still running, or there was none. An earlier run's failure
228
+ * is not shown: each run tries every unwritten item again.
229
+ */
230
+ async migrationRun() {
231
+ const run = await this.kdb.db
232
+ .selectFrom("platform_migration_runs")
233
+ .select(["id", "started_at", "finished_at", "stats"])
234
+ .orderBy("started_at", "desc")
235
+ .orderBy("id", "desc")
236
+ .limit(1)
237
+ .executeTakeFirst();
238
+ if (run === undefined)
239
+ return null;
240
+ const failed = run.stats.itemsFailed;
241
+ const itemsFailed = Array.isArray(failed)
242
+ ? failed.filter((x) => typeof x === "string")
243
+ : [];
244
+ const stuck = run.finished_at === null && run.started_at.getTime() < Date.now() - MIGRATION_RUN_STUCK_MS;
245
+ if (!stuck && (run.finished_at === null || itemsFailed.length === 0))
246
+ return null;
247
+ return {
248
+ id: run.id,
249
+ startedAt: run.started_at.toISOString(),
250
+ finishedAt: run.finished_at?.toISOString() ?? null,
251
+ stuck,
252
+ itemsFailed,
253
+ };
254
+ }
255
+ };
256
+ PlatformInboxService = __decorate([
257
+ Injectable(),
258
+ __param(0, Inject(CatalogRequestsService)),
259
+ __param(1, Inject(CatalogService)),
260
+ __param(2, Inject(KernelDb))
261
+ ], PlatformInboxService);
262
+ export { PlatformInboxService };
263
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -0,0 +1,19 @@
1
+ import type { OwnedRef } from "../catalog/ownership.js";
2
+ import type { KernelSchemaDb } from "../db/kernel-schema.js";
3
+ export type PlatformNoticeKind = "ownership_transferred";
4
+ /** The `detail` of each platform notice kind. */
5
+ export interface PlatformNoticeDetails {
6
+ /** A deleted org's (or owner's) shared item now belongs to the platform. */
7
+ ownership_transferred: {
8
+ ref: OwnedRef;
9
+ name: string;
10
+ fromOrg: {
11
+ id: string;
12
+ name: string;
13
+ };
14
+ reason: "owner_deleted" | "org_deleted";
15
+ /** How many other orgs use it. */
16
+ usedBy: number;
17
+ };
18
+ }
19
+ export declare function addPlatformNotice<K extends PlatformNoticeKind>(db: KernelSchemaDb, kind: K, detail: PlatformNoticeDetails[K]): Promise<void>;
@@ -0,0 +1,9 @@
1
+ // Platform notices (`platform_notices`, plugin scope phase 3, ruling P3-22): what the super admins
2
+ // are told, until any one of them dismisses it. Written in the caller's transaction.
3
+ import { randomUUID } from "node:crypto";
4
+ export async function addPlatformNotice(db, kind, detail) {
5
+ await db
6
+ .insertInto("platform_notices")
7
+ .values({ id: randomUUID(), kind, detail: JSON.stringify(detail) })
8
+ .execute();
9
+ }
package/dist/index.d.ts CHANGED
@@ -71,4 +71,4 @@ export { SANDBOX_DESTROY_JOB, SANDBOX_SUSPEND_JOB, } from "./sandbox/jobs.js";
71
71
  export { SANDBOX_LOCK_TTL_MS, SandboxService, type SandboxUseInfo, } from "./sandbox/sandbox.service.js";
72
72
  export { MAX_STORAGE_KEY_BYTES, StorageKeyError, } from "./storage/prefix.js";
73
73
  export { PrefixedStorage, StorageService, type StorageSource, } from "./storage/storage.service.js";
74
- export { SANDBOX_RECREATED_NOTICE, SANDBOX_STARTED_NOTICE, } from "./tools/builtins/sandbox/common.js";
74
+ export { SANDBOX_RESTARTED_NOTICE, SANDBOX_STARTED_NOTICE, } from "./tools/builtins/sandbox/common.js";
package/dist/index.js CHANGED
@@ -67,4 +67,4 @@ export { SANDBOX_DESTROY_JOB, SANDBOX_SUSPEND_JOB, } from "./sandbox/jobs.js";
67
67
  export { SANDBOX_LOCK_TTL_MS, SandboxService, } from "./sandbox/sandbox.service.js";
68
68
  export { MAX_STORAGE_KEY_BYTES, StorageKeyError, } from "./storage/prefix.js";
69
69
  export { PrefixedStorage, StorageService, } from "./storage/storage.service.js";
70
- export { SANDBOX_RECREATED_NOTICE, SANDBOX_STARTED_NOTICE, } from "./tools/builtins/sandbox/common.js";
70
+ export { SANDBOX_RESTARTED_NOTICE, SANDBOX_STARTED_NOTICE, } from "./tools/builtins/sandbox/common.js";
@@ -13,6 +13,7 @@ import { NestFactory } from "@nestjs/core";
13
13
  import { Redis } from "ioredis";
14
14
  import { createBus } from "../../ctx/bus.js";
15
15
  import { KERNEL_APP_OPTIONS } from "../../lifecycle/tokens.js";
16
+ import { CacheModule } from "../cache/cache.module.js";
16
17
  import { ConfigModule } from "../config/config.module.js";
17
18
  import { KernelConfigService } from "../config/kernel-config.service.js";
18
19
  import { DatabaseModule } from "../database/database.module.js";
@@ -20,6 +21,7 @@ import { KernelEventsModule } from "../events/kernel-events.js";
20
21
  import { GracefulShutdownModule } from "../lifecycle/graceful-shutdown.module.js";
21
22
  import { LockModule } from "../lock/lock.module.js";
22
23
  import { LoggingModule } from "../logging/logging.module.js";
24
+ import { QueueModule } from "../queue/queue.module.js";
23
25
  import { KERNEL_BUS, KERNEL_LOGGER, REDIS, REDIS_SUBSCRIBER } from "../tokens.js";
24
26
  /** How long the CLI's Redis connection may take before a command fails (a publish only warns). */
25
27
  const CLI_REDIS_CONNECT_TIMEOUT_MS = 3_000;
@@ -108,7 +110,13 @@ let KernelCliModule = KernelCliModule_1 = class KernelCliModule {
108
110
  ConfigModule.forRoot(config, opts.env !== undefined ? { env: opts.env } : {}),
109
111
  GracefulShutdownModule,
110
112
  DatabaseModule.forRoot(),
111
- ...(opts.redis === false ? [] : [CliRedisModule, LockModule]),
113
+ // QueueModule's root gives the queues a command's modules register (the catalog's scope
114
+ // sync and maintenance queues) the configured Redis; without it BullMQ would connect to
115
+ // its default 127.0.0.1:6379
116
+ // CacheModule: `@Cacheable` providers of the domain modules (EffectiveConfigs) need it
117
+ ...(opts.redis === false
118
+ ? []
119
+ : [CliRedisModule, LockModule, CacheModule, QueueModule.forRoot()]),
112
120
  KernelEventsModule,
113
121
  ...opts.modules,
114
122
  ],
@@ -30,8 +30,11 @@ const HOT_APPLIERS = {
30
30
  "hooks.timeoutMs": () => { },
31
31
  // SandboxService reads the shared-lease cap at every acquisition.
32
32
  "sandbox.maxConcurrentCommands": () => { },
33
+ // The environments service reads the personal limit at every create.
34
+ "environments.maxPersonal": () => { },
33
35
  // Sub-agent limits are read at every dispatch, child step and tool resolution.
34
- "subagents.maxConcurrentPerRun": () => { },
36
+ "subagents.maxDepth": () => { },
37
+ "subagents.maxConcurrentPerConversation": () => { },
35
38
  "subagents.maxDispatchesPerRun": () => { },
36
39
  "subagents.maxTokensPerRun": () => { },
37
40
  // The web tools read these limits through the config service on every call.
@@ -41,6 +44,18 @@ const HOT_APPLIERS = {
41
44
  "web.fetch.cacheSeconds": () => { },
42
45
  "web.fetch.timeoutMs": () => { },
43
46
  };
47
+ /**
48
+ * Environment variables of renamed config keys, with their replacements: warned about once when
49
+ * the service starts (agent map spec §6: `subagents.maxConcurrentPerRun` became
50
+ * `subagents.maxConcurrentPerConversation`). A retired file or Nacos key cannot be told here: the
51
+ * schema strips unknown keys before the kernel receives its config.
52
+ */
53
+ const RETIRED_ENV = [
54
+ [
55
+ "CAPYBARA_SUBAGENTS__MAX_CONCURRENT_PER_RUN",
56
+ "CAPYBARA_SUBAGENTS__MAX_CONCURRENT_PER_CONVERSATION",
57
+ ],
58
+ ];
44
59
  const HOT_PATHS = configFields(KernelConfigSchema)
45
60
  .filter((f) => f.meta?.hot)
46
61
  .map((f) => f.path);
@@ -61,6 +76,11 @@ let KernelConfigService = class KernelConfigService {
61
76
  this.env = input.env ?? process.env;
62
77
  log.setLevel(input.config.log.level);
63
78
  log.addSecrets(secretValues(KernelConfigSchema, input.config));
79
+ for (const [old, now] of RETIRED_ENV) {
80
+ if (this.env[old] !== undefined) {
81
+ log.warn(`${old} is no longer read and is ignored; set ${now} instead`, { env: old });
82
+ }
83
+ }
64
84
  }
65
85
  get() {
66
86
  return this.current;
@@ -4,7 +4,7 @@ import { TransactionHost } from "./transaction-host.js";
4
4
  * Transaction-scoped advisory locks (decision R9 of the Nest kernel spec): `pg_advisory_xact_lock`
5
5
  * is transaction semantics, like `FOR UPDATE`. It is held by the caller's transaction and released
6
6
  * at its COMMIT or ROLLBACK, so it serializes writers whose invariant is checked inside that same
7
- * transaction ("never zero active enterprise admins", "set up once", "one account per external
7
+ * transaction ("never zero active super admins", "set up once", "one account per external
8
8
  * identity"). The one place that takes such a lock; `propagation: "mandatory"` makes a call outside
9
9
  * a transaction (where the lock would be released at once) throw.
10
10
  */
@@ -16,7 +16,7 @@ import { Transactional } from "./transactional.decorator.js";
16
16
  * Transaction-scoped advisory locks (decision R9 of the Nest kernel spec): `pg_advisory_xact_lock`
17
17
  * is transaction semantics, like `FOR UPDATE`. It is held by the caller's transaction and released
18
18
  * at its COMMIT or ROLLBACK, so it serializes writers whose invariant is checked inside that same
19
- * transaction ("never zero active enterprise admins", "set up once", "one account per external
19
+ * transaction ("never zero active super admins", "set up once", "one account per external
20
20
  * identity"). The one place that takes such a lock; `propagation: "mandatory"` makes a call outside
21
21
  * a transaction (where the lock would be released at once) throw.
22
22
  */
@@ -72,12 +72,21 @@ export interface KernelEventMap {
72
72
  runId: string;
73
73
  };
74
74
  /**
75
- * `ensureRun` marked an orphaned run failed (after the commit): the waits stop its active
76
- * sub-agents at once. A lost event is repaired by the wait sweep (children of finished runs).
75
+ * `ensureRun` marked an orphaned run failed (after the commit): the waits stop its active fork
76
+ * sub-agent at once (background sub-agents keep running, agent map spec §5.4). A lost event is
77
+ * repaired by the wait sweep (fork children of finished runs).
77
78
  */
78
79
  "run.orphaned": {
79
80
  runId: string;
80
81
  };
82
+ /**
83
+ * A sub-agent's `subagent_delivery` was appended to its parent conversation (after the commit;
84
+ * `SubagentDeliveries`). Waking an idle parent follows it; a lost event is re-derived by the
85
+ * next `ensureRun` (a message, the end of a run, a page opening).
86
+ */
87
+ "subagent.delivered": {
88
+ conversationId: string;
89
+ };
81
90
  /**
82
91
  * A background task of the conversation finished (after the commit of its
83
92
  * `background_task_finished` event). `BackgroundWake` asks the run queue for a wake run; a lost
@@ -0,0 +1,14 @@
1
+ import { type JobsOptions } from "bullmq";
2
+ import type { Redis } from "ioredis";
3
+ /** One job to add: its name, data and options (a deterministic `jobId` makes the add idempotent). */
4
+ export interface OneJob<T> {
5
+ name: string;
6
+ data: T;
7
+ opts: JobsOptions;
8
+ }
9
+ /**
10
+ * Adds one job to a kernel queue from a process that hosts no queue of its own (a CLI command),
11
+ * over the caller's Redis connection (left open), with BullMQ's default key prefix like the
12
+ * kernel's queues. The queue handle is closed again before returning.
13
+ */
14
+ export declare function addJobOnce<T>(connection: Redis, queue: string, job: OneJob<T>): Promise<void>;
@@ -0,0 +1,16 @@
1
+ import { Queue } from "bullmq";
2
+ /**
3
+ * Adds one job to a kernel queue from a process that hosts no queue of its own (a CLI command),
4
+ * over the caller's Redis connection (left open), with BullMQ's default key prefix like the
5
+ * kernel's queues. The queue handle is closed again before returning.
6
+ */
7
+ export async function addJobOnce(connection, queue, job) {
8
+ const q = new Queue(queue, { connection });
9
+ try {
10
+ // biome-ignore lint/suspicious/noExplicitAny: BullMQ's name and data generics do not line up here
11
+ await q.add(job.name, job.data, job.opts);
12
+ }
13
+ finally {
14
+ await q.close();
15
+ }
16
+ }
@@ -33,6 +33,8 @@ import { KernelLifecycle } from "./lifecycle/kernel-lifecycle.js";
33
33
  import { KERNEL_APP_OPTIONS } from "./lifecycle/tokens.js";
34
34
  import { createConfiguredLogger } from "./log-config.js";
35
35
  import { KERNEL_OVERRIDE_TOKENS } from "./overrides.js";
36
+ import { PlatformModule } from "./platform/platform.module.js";
37
+ import { PlatformOpsModule } from "./platform/platform-ops.module.js";
36
38
  import { GatewayModule } from "./roles/gateway.module.js";
37
39
  import { WorkerModule } from "./roles/worker.module.js";
38
40
  import { UsageReportModule } from "./runtime/usage-report.js";
@@ -108,6 +110,10 @@ let KernelModule = KernelModule_1 = class KernelModule {
108
110
  TitlesModule,
109
111
  UsageReportModule,
110
112
  ChannelsModule,
113
+ // the Platform tool's operation registry and actor facts
114
+ PlatformModule,
115
+ // its operations (skills, agents, ...), registered at start on every role
116
+ PlatformOpsModule,
111
117
  // the role modules, by `roles` (nest kernel spec §2)
112
118
  ...(config.roles.includes("api") ? [ApiModule] : []),
113
119
  ...(config.roles.includes("worker") ? [WorkerModule.forRoot(config)] : []),
@@ -123,7 +123,7 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
123
123
  * and the next start tries again while it stays incomplete.
124
124
  */
125
125
  private runBootstrap;
126
- /** 部署尚无活跃企业管理员时提示去初始化;查询失败只记日志,不影响启动。 */
126
+ /** 部署尚无活跃超级管理员时提示去初始化;查询失败只记日志,不影响启动。 */
127
127
  private warnIfSetupPending;
128
128
  beforeApplicationShutdown(): Promise<void>;
129
129
  /** Logs the end of the stop phases (Redis and the pool close right after, in the infra modules). */
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
- import { SANDBOX_EXTENSION_POINT, } from "@capybara-hq/plugin-sdk";
10
+ import { SANDBOX_EXTENSION_POINT } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable, Optional, } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
13
  import { MarketplacesService } from "../catalog/marketplaces.service.js";
@@ -237,7 +237,7 @@ let KernelLifecycle = class KernelLifecycle {
237
237
  .list("sandbox")
238
238
  .find((x) => x.capability === SANDBOX_EXTENSION_POINT);
239
239
  if (sandboxEntry !== undefined) {
240
- for (const w of sandboxConfigWarnings(cfg(), sandboxEntry.plugin, sandboxEntry.impl)) {
240
+ for (const w of sandboxConfigWarnings(cfg(), sandboxEntry.plugin)) {
241
241
  this.log[w.level](w.message);
242
242
  }
243
243
  }
@@ -318,10 +318,10 @@ let KernelLifecycle = class KernelLifecycle {
318
318
  throw e;
319
319
  }
320
320
  }
321
- /** 部署尚无活跃企业管理员时提示去初始化;查询失败只记日志,不影响启动。 */
321
+ /** 部署尚无活跃超级管理员时提示去初始化;查询失败只记日志,不影响启动。 */
322
322
  async warnIfSetupPending() {
323
323
  try {
324
- if ((await this.accounts.countEnterpriseAdmins()) === 0) {
324
+ if ((await this.accounts.countSuperAdmins()) === 0) {
325
325
  this.log.warn("deployment is not set up; open the setup wizard or run `capybara admin create`");
326
326
  }
327
327
  }
@@ -1,10 +1,10 @@
1
1
  import type { ModelUsage } from "@capybara-hq/plugin-sdk";
2
2
  import { z } from "zod";
3
- import { EnterpriseAdminLock } from "../identity/enterprise-admin.js";
3
+ import { SuperAdminLock } from "../identity/super-admin.js";
4
4
  import { KernelDb } from "../infra/database/kernel-db.js";
5
5
  import { TransactionHost } from "../infra/database/transaction-host.js";
6
6
  /**
7
- * 一个模型的价格(C2):每百万 token,币种为部署设置 `priceCurrency`。由企业管理员录入,插件不声明价格。
7
+ * 一个模型的价格(C2):每百万 token,币种为部署设置 `priceCurrency`。由超级管理员录入,插件不声明价格。
8
8
  * 缓存读 / 写价为 null 时按输入价计。
9
9
  */
10
10
  export interface ModelPrice {
@@ -40,13 +40,13 @@ export declare class PricesService {
40
40
  private readonly db;
41
41
  readonly txHost: TransactionHost;
42
42
  private readonly adminLock;
43
- constructor(db: KernelDb, txHost: TransactionHost, adminLock: EnterpriseAdminLock);
43
+ constructor(db: KernelDb, txHost: TransactionHost, adminLock: SuperAdminLock);
44
44
  /** 全部价格,按 provider、model 排序。 */
45
45
  list(): Promise<ModelPrice[]>;
46
46
  /** 价格表(按 {@link priceKey} 查)。 */
47
47
  table(): Promise<PriceTable>;
48
48
  /**
49
- * 设置或删除(`price: null`)一个模型的价格:事务内取企业管理员锁并复核发起人仍是活跃企业管理员
49
+ * 设置或删除(`price: null`)一个模型的价格:事务内取超级管理员锁并复核发起人仍是活跃超级管理员
50
50
  * (否则 `forbidden`),写审计 `model_price.updated` / `model_price.deleted`。
51
51
  */
52
52
  put(input: ModelPrice | {
@@ -54,6 +54,6 @@ export declare class PricesService {
54
54
  model: string;
55
55
  price: null;
56
56
  }, actorAccountId: string, actorTokenId?: string): Promise<void>;
57
- /** The write of {@link put}, under the enterprise admin lock. */
57
+ /** The write of {@link put}, under the super admin lock. */
58
58
  private write;
59
59
  }
@@ -11,7 +11,7 @@ import { Inject, Injectable } from "@nestjs/common";
11
11
  import { z } from "zod";
12
12
  import { ApiError } from "../errors.js";
13
13
  import { audit } from "../identity/audit.js";
14
- import { EnterpriseAdminLock } from "../identity/enterprise-admin.js";
14
+ import { SuperAdminLock } from "../identity/super-admin.js";
15
15
  import { KernelDb } from "../infra/database/kernel-db.js";
16
16
  import { TransactionHost } from "../infra/database/transaction-host.js";
17
17
  import { Transactional } from "../infra/database/transactional.decorator.js";
@@ -87,7 +87,7 @@ let PricesService = class PricesService {
87
87
  return new Map((await this.list()).map((p) => [priceKey(p.provider, p.model), p]));
88
88
  }
89
89
  /**
90
- * 设置或删除(`price: null`)一个模型的价格:事务内取企业管理员锁并复核发起人仍是活跃企业管理员
90
+ * 设置或删除(`price: null`)一个模型的价格:事务内取超级管理员锁并复核发起人仍是活跃超级管理员
91
91
  * (否则 `forbidden`),写审计 `model_price.updated` / `model_price.deleted`。
92
92
  */
93
93
  async put(input, actorAccountId, actorTokenId) {
@@ -97,7 +97,7 @@ let PricesService = class PricesService {
97
97
  }
98
98
  await this.write(check.data, actorAccountId, actorTokenId);
99
99
  }
100
- /** The write of {@link put}, under the enterprise admin lock. */
100
+ /** The write of {@link put}, under the super admin lock. */
101
101
  async write(v, actorAccountId, actorTokenId) {
102
102
  await this.adminLock.lockAndAuthorize(actorAccountId);
103
103
  const target = `${v.provider}/${v.model}`;
@@ -144,6 +144,6 @@ PricesService = __decorate([
144
144
  Injectable(),
145
145
  __param(0, Inject(KernelDb)),
146
146
  __param(1, Inject(TransactionHost)),
147
- __param(2, Inject(EnterpriseAdminLock))
147
+ __param(2, Inject(SuperAdminLock))
148
148
  ], PricesService);
149
149
  export { PricesService };
@@ -1,6 +1,7 @@
1
+ import { ExtensionDisplayNames } from "../extensions/display-name.js";
1
2
  import { type Principal } from "../identity/principal.js";
2
3
  import { type OrgContext } from "../orgs/org.guard.js";
3
- import { ModelPurposesService, type PurposePut, type PurposeTarget, type PurposeView } from "./purposes.js";
4
+ import { ModelPurposesService, type PurposeListing, type PurposePut, type PurposeTarget } from "./purposes.js";
4
5
  /** body 的目标(参数缺省为 `{}`)。 */
5
6
  export declare const purposeTargetOf: (b: PurposePut) => PurposeTarget | null;
6
7
  /**
@@ -9,11 +10,12 @@ export declare const purposeTargetOf: (b: PurposePut) => PurposeTarget | null;
9
10
  */
10
11
  export declare class ModelPurposesController {
11
12
  private readonly purposes;
12
- constructor(purposes: ModelPurposesService);
13
+ private readonly displayNames;
14
+ constructor(purposes: ModelPurposesService, displayNames: ExtensionDisplayNames);
13
15
  list(principal: Principal, org: OrgContext): Promise<{
14
- purposes: PurposeView[];
16
+ purposes: PurposeListing[];
15
17
  }>;
16
18
  put(principal: Principal, org: OrgContext, purpose: string, body: PurposePut): Promise<{
17
- purpose: PurposeView;
19
+ purpose: PurposeListing;
18
20
  }>;
19
21
  }