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

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 (534) hide show
  1. package/bootstrap.json +61 -5
  2. package/dist/admin/admin.controller.d.ts +51 -14
  3. package/dist/admin/admin.controller.js +60 -19
  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 +54 -23
  19. package/dist/agents/agents.service.js +180 -76
  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/models.controller.d.ts +34 -5
  27. package/dist/agents/models.controller.js +50 -6
  28. package/dist/agents/org-templates.d.ts +176 -0
  29. package/dist/agents/org-templates.js +827 -0
  30. package/dist/agents/pending-connector-requests.d.ts +77 -0
  31. package/dist/agents/pending-connector-requests.js +215 -0
  32. package/dist/agents/pending-connectors.controller.d.ts +39 -0
  33. package/dist/agents/pending-connectors.controller.js +91 -0
  34. package/dist/agents/pending-connectors.service.d.ts +62 -0
  35. package/dist/agents/pending-connectors.service.js +282 -0
  36. package/dist/agents/readiness.controller.d.ts +5 -5
  37. package/dist/agents/readiness.controller.js +6 -6
  38. package/dist/agents/templates.controller.d.ts +86 -5
  39. package/dist/agents/templates.controller.js +171 -7
  40. package/dist/agents/templates.d.ts +127 -23
  41. package/dist/agents/templates.js +475 -52
  42. package/dist/background/background.module.js +8 -1
  43. package/dist/background/finish.d.ts +3 -2
  44. package/dist/background/launch-lock.d.ts +4 -3
  45. package/dist/background/launch-lock.js +4 -3
  46. package/dist/background/poll.job.d.ts +9 -6
  47. package/dist/background/poll.job.js +30 -22
  48. package/dist/background/session.d.ts +13 -2
  49. package/dist/background/session.js +13 -0
  50. package/dist/background/stop.d.ts +12 -6
  51. package/dist/background/stop.js +57 -39
  52. package/dist/background/store.d.ts +18 -6
  53. package/dist/background/store.js +12 -6
  54. package/dist/background/tasks.service.d.ts +15 -5
  55. package/dist/background/tasks.service.js +42 -17
  56. package/dist/background/wake-rules.d.ts +27 -18
  57. package/dist/background/wake-rules.js +52 -22
  58. package/dist/background/wake.d.ts +13 -11
  59. package/dist/background/wake.js +20 -14
  60. package/dist/catalog/admin-catalog.controller.d.ts +129 -30
  61. package/dist/catalog/admin-catalog.controller.js +213 -42
  62. package/dist/catalog/catalog-content.d.ts +58 -32
  63. package/dist/catalog/catalog-content.js +34 -8
  64. package/dist/catalog/catalog-import.module.d.ts +7 -0
  65. package/dist/catalog/catalog-import.module.js +60 -0
  66. package/dist/catalog/catalog-items.d.ts +111 -7
  67. package/dist/catalog/catalog-items.js +279 -13
  68. package/dist/catalog/catalog-scope.service.d.ts +260 -0
  69. package/dist/catalog/catalog-scope.service.js +1116 -0
  70. package/dist/catalog/catalog.module.d.ts +7 -9
  71. package/dist/catalog/catalog.module.js +41 -31
  72. package/dist/catalog/catalog.service.d.ts +101 -29
  73. package/dist/catalog/catalog.service.js +104 -106
  74. package/dist/catalog/cli.d.ts +11 -1
  75. package/dist/catalog/cli.js +26 -1
  76. package/dist/catalog/component-promotion.d.ts +96 -0
  77. package/dist/catalog/component-promotion.js +395 -0
  78. package/dist/catalog/component-scope.controller.d.ts +152 -0
  79. package/dist/catalog/component-scope.controller.js +287 -0
  80. package/dist/catalog/component-scope.service.d.ts +303 -0
  81. package/dist/catalog/component-scope.service.js +936 -0
  82. package/dist/catalog/component-state.d.ts +174 -0
  83. package/dist/catalog/component-state.js +437 -0
  84. package/dist/catalog/job-ids.d.ts +30 -0
  85. package/dist/catalog/job-ids.js +25 -0
  86. package/dist/catalog/marketplace-fetch.d.ts +1 -1
  87. package/dist/catalog/marketplaces.controller.d.ts +22 -5
  88. package/dist/catalog/marketplaces.controller.js +56 -7
  89. package/dist/catalog/marketplaces.service.d.ts +54 -14
  90. package/dist/catalog/marketplaces.service.js +71 -22
  91. package/dist/catalog/org-catalog.controller.d.ts +125 -34
  92. package/dist/catalog/org-catalog.controller.js +181 -65
  93. package/dist/catalog/org-catalog.service.d.ts +65 -33
  94. package/dist/catalog/org-catalog.service.js +324 -157
  95. package/dist/catalog/org-extension-switch.d.ts +41 -0
  96. package/dist/catalog/org-extension-switch.js +115 -0
  97. package/dist/catalog/org-extension.controller.d.ts +119 -0
  98. package/dist/catalog/org-extension.controller.js +266 -0
  99. package/dist/catalog/org-plugin-uploads.controller.d.ts +98 -0
  100. package/dist/catalog/org-plugin-uploads.controller.js +213 -0
  101. package/dist/catalog/org-plugin-uploads.d.ts +63 -0
  102. package/dist/catalog/org-plugin-uploads.js +116 -0
  103. package/dist/catalog/owned-items.d.ts +184 -0
  104. package/dist/catalog/owned-items.js +789 -0
  105. package/dist/catalog/owned-plugin-cleanup.d.ts +56 -0
  106. package/dist/catalog/owned-plugin-cleanup.js +194 -0
  107. package/dist/catalog/ownership.d.ts +172 -0
  108. package/dist/catalog/ownership.js +326 -0
  109. package/dist/catalog/platform-components.d.ts +221 -0
  110. package/dist/catalog/platform-components.js +761 -0
  111. package/dist/catalog/platform-migration.d.ts +115 -0
  112. package/dist/catalog/platform-migration.js +582 -0
  113. package/dist/catalog/plugin-import.d.ts +178 -34
  114. package/dist/catalog/plugin-import.js +622 -82
  115. package/dist/catalog/plugin-install.d.ts +185 -41
  116. package/dist/catalog/plugin-install.js +758 -126
  117. package/dist/catalog/plugin-upgrade.d.ts +260 -225
  118. package/dist/catalog/plugin-upgrade.js +1147 -1136
  119. package/dist/catalog/request-rules.d.ts +65 -0
  120. package/dist/catalog/request-rules.js +217 -0
  121. package/dist/catalog/requests.service.d.ts +193 -118
  122. package/dist/catalog/requests.service.js +526 -343
  123. package/dist/catalog/reserved-names.d.ts +8 -0
  124. package/dist/catalog/reserved-names.js +42 -0
  125. package/dist/catalog/scope-orgs.d.ts +21 -0
  126. package/dist/catalog/scope-orgs.js +67 -0
  127. package/dist/catalog/scope-state.d.ts +35 -0
  128. package/dist/catalog/scope-state.js +87 -0
  129. package/dist/catalog/scope-sync-workers.d.ts +7 -0
  130. package/dist/catalog/scope-sync-workers.js +29 -0
  131. package/dist/catalog/scope-sync.d.ts +176 -0
  132. package/dist/catalog/scope-sync.js +576 -0
  133. package/dist/catalog/scope.d.ts +42 -0
  134. package/dist/catalog/scope.js +42 -0
  135. package/dist/catalog/unshare.d.ts +22 -0
  136. package/dist/catalog/unshare.js +118 -0
  137. package/dist/channels/actions.js +1 -0
  138. package/dist/channels/cards.js +20 -2
  139. package/dist/channels/channels.module.js +2 -0
  140. package/dist/channels/inbound.d.ts +9 -1
  141. package/dist/channels/inbound.js +67 -5
  142. package/dist/channels/phrases.d.ts +35 -0
  143. package/dist/channels/phrases.js +29 -0
  144. package/dist/config/docs.js +3 -1
  145. package/dist/config/schema.d.ts +10 -2
  146. package/dist/config/schema.js +70 -22
  147. package/dist/conversations/access.d.ts +6 -4
  148. package/dist/conversations/access.js +27 -5
  149. package/dist/conversations/agent-tree.d.ts +46 -0
  150. package/dist/conversations/agent-tree.js +92 -0
  151. package/dist/conversations/conversations.controller.d.ts +43 -18
  152. package/dist/conversations/conversations.controller.js +79 -38
  153. package/dist/conversations/conversations.module.d.ts +1 -1
  154. package/dist/conversations/conversations.module.js +7 -7
  155. package/dist/conversations/conversations.service.d.ts +73 -15
  156. package/dist/conversations/conversations.service.js +115 -35
  157. package/dist/conversations/environment-status.d.ts +24 -0
  158. package/dist/conversations/environment-status.js +71 -0
  159. package/dist/conversations/event-log.d.ts +20 -5
  160. package/dist/conversations/event-log.js +60 -0
  161. package/dist/conversations/events.d.ts +84 -2
  162. package/dist/conversations/events.js +91 -17
  163. package/dist/conversations/queue.service.d.ts +1 -1
  164. package/dist/conversations/queue.service.js +5 -0
  165. package/dist/conversations/titles.d.ts +5 -3
  166. package/dist/conversations/titles.js +21 -8
  167. package/dist/conversations/tree.d.ts +17 -0
  168. package/dist/conversations/tree.js +42 -0
  169. package/dist/ctx/create-ctx.d.ts +20 -1
  170. package/dist/ctx/create-ctx.js +38 -7
  171. package/dist/db/kernel-schema.d.ts +386 -18
  172. package/dist/environments/access.d.ts +41 -0
  173. package/dist/environments/access.js +77 -0
  174. package/dist/environments/conversation-environments.d.ts +61 -0
  175. package/dist/environments/conversation-environments.js +170 -0
  176. package/dist/environments/dto.d.ts +25 -0
  177. package/dist/environments/dto.js +12 -0
  178. package/dist/environments/environments.controller.d.ts +33 -0
  179. package/dist/environments/environments.controller.js +110 -0
  180. package/dist/environments/environments.module.d.ts +8 -0
  181. package/dist/environments/environments.module.js +27 -0
  182. package/dist/environments/environments.service.d.ts +153 -0
  183. package/dist/environments/environments.service.js +541 -0
  184. package/dist/environments/legacy-cleanup.job.d.ts +34 -0
  185. package/dist/environments/legacy-cleanup.job.js +141 -0
  186. package/dist/errors.d.ts +85 -2
  187. package/dist/errors.js +85 -2
  188. package/dist/evals/reconstruct.d.ts +18 -9
  189. package/dist/evals/reconstruct.js +26 -7
  190. package/dist/evals/run-replay.d.ts +4 -2
  191. package/dist/evals/run-replay.js +20 -6
  192. package/dist/evals/runs.service.d.ts +2 -1
  193. package/dist/evals/runs.service.js +13 -12
  194. package/dist/evals/step-replay.d.ts +4 -6
  195. package/dist/evals/step-replay.js +4 -3
  196. package/dist/evals/trajectory.service.d.ts +8 -3
  197. package/dist/evals/trajectory.service.js +26 -14
  198. package/dist/evals/worker.d.ts +5 -5
  199. package/dist/evals/worker.js +9 -3
  200. package/dist/extensions/admin-ops.d.ts +36 -10
  201. package/dist/extensions/admin-ops.js +65 -42
  202. package/dist/extensions/admin-view.d.ts +37 -10
  203. package/dist/extensions/admin-view.js +103 -20
  204. package/dist/extensions/bootstrap.d.ts +17 -4
  205. package/dist/extensions/bootstrap.js +70 -9
  206. package/dist/extensions/cli.d.ts +12 -0
  207. package/dist/extensions/cli.js +11 -2
  208. package/dist/extensions/config-hash.d.ts +10 -0
  209. package/dist/extensions/config-hash.js +38 -0
  210. package/dist/extensions/deployment-config.d.ts +28 -5
  211. package/dist/extensions/deployment-config.js +48 -7
  212. package/dist/extensions/effective-config.d.ts +127 -0
  213. package/dist/extensions/effective-config.js +368 -0
  214. package/dist/extensions/extensions.module.js +11 -11
  215. package/dist/extensions/hooks.d.ts +37 -4
  216. package/dist/extensions/hooks.js +82 -16
  217. package/dist/extensions/host.d.ts +24 -10
  218. package/dist/extensions/host.js +49 -54
  219. package/dist/extensions/installs.d.ts +20 -8
  220. package/dist/extensions/installs.js +37 -15
  221. package/dist/extensions/org-config.d.ts +75 -6
  222. package/dist/extensions/org-config.js +184 -32
  223. package/dist/extensions/org-levels.d.ts +37 -0
  224. package/dist/extensions/org-levels.js +71 -0
  225. package/dist/extensions/org-overrides.d.ts +151 -0
  226. package/dist/extensions/org-overrides.js +524 -0
  227. package/dist/extensions/permission-view.d.ts +16 -4
  228. package/dist/extensions/permission-view.js +4 -4
  229. package/dist/extensions/plugin-items.d.ts +21 -0
  230. package/dist/extensions/plugin-items.js +42 -0
  231. package/dist/extensions/point-defaults.d.ts +12 -5
  232. package/dist/extensions/point-defaults.js +37 -9
  233. package/dist/extensions/resolve.d.ts +5 -1
  234. package/dist/extensions/resolve.js +15 -2
  235. package/dist/extensions/state.module.d.ts +9 -0
  236. package/dist/extensions/state.module.js +38 -0
  237. package/dist/files/previewers.d.ts +8 -1
  238. package/dist/files/previewers.js +35 -6
  239. package/dist/http/api.module.js +25 -3
  240. package/dist/http/app.d.ts +11 -2
  241. package/dist/http/app.js +31 -5
  242. package/dist/http/plugin-dispatch.d.ts +4 -1
  243. package/dist/http/plugin-dispatch.js +14 -2
  244. package/dist/identity/accounts.d.ts +29 -29
  245. package/dist/identity/accounts.js +47 -47
  246. package/dist/identity/audit.d.ts +2 -1
  247. package/dist/identity/auth.guard.d.ts +13 -5
  248. package/dist/identity/auth.guard.js +26 -9
  249. package/dist/identity/identity.module.d.ts +1 -1
  250. package/dist/identity/identity.module.js +4 -4
  251. package/dist/identity/me.controller.js +1 -1
  252. package/dist/identity/principal.d.ts +3 -3
  253. package/dist/identity/principal.js +3 -3
  254. package/dist/identity/settings.d.ts +22 -11
  255. package/dist/identity/settings.js +53 -18
  256. package/dist/identity/{enterprise-admin.d.ts → super-admin.d.ts} +5 -5
  257. package/dist/identity/{enterprise-admin.js → super-admin.js} +24 -24
  258. package/dist/inbox/inbox.module.d.ts +4 -1
  259. package/dist/inbox/inbox.module.js +7 -3
  260. package/dist/inbox/inbox.service.d.ts +62 -3
  261. package/dist/inbox/inbox.service.js +74 -4
  262. package/dist/inbox/org-notices.d.ts +63 -0
  263. package/dist/inbox/org-notices.js +91 -0
  264. package/dist/inbox/platform-inbox.controller.d.ts +23 -0
  265. package/dist/inbox/platform-inbox.controller.js +58 -0
  266. package/dist/inbox/platform-inbox.service.d.ts +151 -0
  267. package/dist/inbox/platform-inbox.service.js +263 -0
  268. package/dist/inbox/platform-notices.d.ts +19 -0
  269. package/dist/inbox/platform-notices.js +9 -0
  270. package/dist/index.d.ts +1 -1
  271. package/dist/index.js +1 -1
  272. package/dist/infra/cli/kernel-cli.module.js +9 -1
  273. package/dist/infra/config/kernel-config.service.js +24 -1
  274. package/dist/infra/database/xact-lock.d.ts +1 -1
  275. package/dist/infra/database/xact-lock.js +1 -1
  276. package/dist/infra/events/kernel-events.d.ts +19 -2
  277. package/dist/infra/queue/add-job-once.d.ts +14 -0
  278. package/dist/infra/queue/add-job-once.js +16 -0
  279. package/dist/kernel.module.js +6 -0
  280. package/dist/lifecycle/kernel-lifecycle.d.ts +1 -1
  281. package/dist/lifecycle/kernel-lifecycle.js +4 -4
  282. package/dist/models/embeddings.d.ts +82 -0
  283. package/dist/models/embeddings.js +326 -0
  284. package/dist/models/enablement.controller.d.ts +40 -0
  285. package/dist/models/enablement.controller.js +74 -0
  286. package/dist/models/enablement.d.ts +99 -0
  287. package/dist/models/enablement.js +263 -0
  288. package/dist/models/models.module.d.ts +5 -1
  289. package/dist/models/models.module.js +16 -4
  290. package/dist/models/prices.d.ts +5 -5
  291. package/dist/models/prices.js +4 -4
  292. package/dist/models/purposes.controller.d.ts +6 -4
  293. package/dist/models/purposes.controller.js +13 -7
  294. package/dist/models/purposes.d.ts +37 -12
  295. package/dist/models/purposes.js +63 -17
  296. package/dist/orgs/directory-sync.d.ts +14 -5
  297. package/dist/orgs/directory-sync.js +41 -17
  298. package/dist/orgs/offboarding.d.ts +9 -7
  299. package/dist/orgs/offboarding.js +28 -17
  300. package/dist/orgs/org-lock.d.ts +5 -0
  301. package/dist/orgs/org-lock.js +13 -0
  302. package/dist/orgs/org.guard.d.ts +10 -0
  303. package/dist/orgs/org.guard.js +43 -32
  304. package/dist/orgs/orgs.module.js +3 -0
  305. package/dist/orgs/orgs.service.d.ts +20 -7
  306. package/dist/orgs/orgs.service.js +32 -12
  307. package/dist/orgs/roles.d.ts +1 -1
  308. package/dist/orgs/roles.js +5 -1
  309. package/dist/orgs/settings.controller.d.ts +1 -1
  310. package/dist/orgs/settings.service.d.ts +15 -3
  311. package/dist/orgs/settings.service.js +6 -2
  312. package/dist/overrides.d.ts +3 -0
  313. package/dist/overrides.js +2 -0
  314. package/dist/platform/actor.d.ts +48 -0
  315. package/dist/platform/actor.js +100 -0
  316. package/dist/platform/agent-docs.d.ts +18 -0
  317. package/dist/platform/agent-docs.js +59 -0
  318. package/dist/platform/availability.d.ts +14 -0
  319. package/dist/platform/availability.js +43 -0
  320. package/dist/platform/errors.d.ts +11 -0
  321. package/dist/platform/errors.js +26 -0
  322. package/dist/platform/exclusions.d.ts +12 -0
  323. package/dist/platform/exclusions.js +1405 -0
  324. package/dist/platform/method.d.ts +6 -0
  325. package/dist/platform/method.js +15 -0
  326. package/dist/platform/operation.d.ts +92 -0
  327. package/dist/platform/operation.js +35 -0
  328. package/dist/platform/ops/agent-templates.ops.d.ts +14 -0
  329. package/dist/platform/ops/agent-templates.ops.js +92 -0
  330. package/dist/platform/ops/agents.ops.d.ts +19 -0
  331. package/dist/platform/ops/agents.ops.js +294 -0
  332. package/dist/platform/ops/connectors.ops.d.ts +15 -0
  333. package/dist/platform/ops/connectors.ops.js +126 -0
  334. package/dist/platform/ops/errors.d.ts +11 -0
  335. package/dist/platform/ops/errors.js +22 -0
  336. package/dist/platform/ops/extensions.ops.d.ts +19 -0
  337. package/dist/platform/ops/extensions.ops.js +116 -0
  338. package/dist/platform/ops/marketplaces.ops.d.ts +16 -0
  339. package/dist/platform/ops/marketplaces.ops.js +157 -0
  340. package/dist/platform/ops/paging.d.ts +14 -0
  341. package/dist/platform/ops/paging.js +20 -0
  342. package/dist/platform/ops/platform.ops.d.ts +23 -0
  343. package/dist/platform/ops/platform.ops.js +158 -0
  344. package/dist/platform/ops/plugins.ops.d.ts +33 -0
  345. package/dist/platform/ops/plugins.ops.js +377 -0
  346. package/dist/platform/ops/requests.ops.d.ts +14 -0
  347. package/dist/platform/ops/requests.ops.js +153 -0
  348. package/dist/platform/ops/role.d.ts +4 -0
  349. package/dist/platform/ops/role.js +10 -0
  350. package/dist/platform/ops/skills.ops.d.ts +13 -0
  351. package/dist/platform/ops/skills.ops.js +98 -0
  352. package/dist/platform/ops/summary.d.ts +10 -0
  353. package/dist/platform/ops/summary.js +18 -0
  354. package/dist/platform/platform-ops.module.d.ts +7 -0
  355. package/dist/platform/platform-ops.module.js +55 -0
  356. package/dist/platform/platform.module.d.ts +8 -0
  357. package/dist/platform/platform.module.js +25 -0
  358. package/dist/platform/redact-orgs.d.ts +7 -0
  359. package/dist/platform/redact-orgs.js +52 -0
  360. package/dist/platform/registry.d.ts +30 -0
  361. package/dist/platform/registry.js +111 -0
  362. package/dist/roles/worker-role.d.ts +6 -4
  363. package/dist/roles/worker-role.js +14 -7
  364. package/dist/roles/worker.module.d.ts +1 -1
  365. package/dist/roles/worker.module.js +9 -1
  366. package/dist/runtime/context/build.d.ts +6 -4
  367. package/dist/runtime/context/build.js +26 -7
  368. package/dist/runtime/context/claude-tools.d.ts +2 -1
  369. package/dist/runtime/context/claude-tools.js +5 -4
  370. package/dist/runtime/context/compaction.js +9 -0
  371. package/dist/runtime/context/reminders.d.ts +2 -0
  372. package/dist/runtime/context/reminders.js +2 -0
  373. package/dist/runtime/context/skills.js +9 -2
  374. package/dist/runtime/context/tool-changes.d.ts +27 -0
  375. package/dist/runtime/context/tool-changes.js +60 -0
  376. package/dist/runtime/hook-calls.d.ts +8 -1
  377. package/dist/runtime/hook-calls.js +40 -7
  378. package/dist/runtime/langgraph-loop.d.ts +3 -1
  379. package/dist/runtime/langgraph-loop.js +35 -17
  380. package/dist/runtime/loop.d.ts +32 -4
  381. package/dist/runtime/maintenance.d.ts +7 -4
  382. package/dist/runtime/maintenance.js +23 -8
  383. package/dist/runtime/model-call.d.ts +38 -11
  384. package/dist/runtime/model-call.js +97 -24
  385. package/dist/runtime/providers.d.ts +146 -32
  386. package/dist/runtime/providers.js +321 -67
  387. package/dist/runtime/run-control.d.ts +11 -1
  388. package/dist/runtime/run-control.js +12 -0
  389. package/dist/runtime/run-drafts.d.ts +85 -0
  390. package/dist/runtime/run-drafts.js +230 -0
  391. package/dist/runtime/run-jobs.d.ts +3 -5
  392. package/dist/runtime/run-jobs.js +3 -7
  393. package/dist/runtime/run-queue.d.ts +37 -3
  394. package/dist/runtime/run-queue.js +188 -11
  395. package/dist/runtime/run-worker.d.ts +12 -6
  396. package/dist/runtime/run-worker.js +58 -35
  397. package/dist/runtime/runtime.module.js +3 -0
  398. package/dist/runtime/step-log.d.ts +9 -4
  399. package/dist/runtime/step-log.js +8 -5
  400. package/dist/runtime/stream.controller.d.ts +23 -1
  401. package/dist/runtime/stream.controller.js +60 -3
  402. package/dist/runtime/stream.d.ts +4 -1
  403. package/dist/runtime/stream.js +27 -3
  404. package/dist/runtime/subagents/child.d.ts +55 -7
  405. package/dist/runtime/subagents/child.js +105 -7
  406. package/dist/runtime/subagents/definition.d.ts +12 -3
  407. package/dist/runtime/subagents/definition.js +46 -32
  408. package/dist/runtime/subagents/deliveries.d.ts +71 -0
  409. package/dist/runtime/subagents/deliveries.js +228 -0
  410. package/dist/runtime/subagents/dispatch.d.ts +115 -26
  411. package/dist/runtime/subagents/dispatch.js +212 -141
  412. package/dist/runtime/subagents/limits.d.ts +24 -5
  413. package/dist/runtime/subagents/limits.js +40 -6
  414. package/dist/runtime/subagents/messages.d.ts +95 -0
  415. package/dist/runtime/subagents/messages.js +328 -0
  416. package/dist/runtime/subagents/preamble.d.ts +4 -4
  417. package/dist/runtime/subagents/preamble.js +9 -7
  418. package/dist/runtime/subagents/progress.d.ts +8 -6
  419. package/dist/runtime/subagents/progress.js +11 -6
  420. package/dist/runtime/subagents/render.d.ts +30 -0
  421. package/dist/runtime/subagents/render.js +53 -0
  422. package/dist/runtime/subagents/roster.d.ts +24 -7
  423. package/dist/runtime/subagents/roster.js +47 -11
  424. package/dist/runtime/subagents/skill-fork.d.ts +3 -2
  425. package/dist/runtime/subagents/skill-fork.js +8 -4
  426. package/dist/runtime/subagents/status.d.ts +14 -0
  427. package/dist/runtime/subagents/status.js +23 -0
  428. package/dist/runtime/subagents/subagents.service.d.ts +7 -4
  429. package/dist/runtime/subagents/subagents.service.js +11 -6
  430. package/dist/runtime/usage-report-jobs.d.ts +88 -0
  431. package/dist/runtime/usage-report-jobs.js +158 -0
  432. package/dist/runtime/usage-report.d.ts +33 -38
  433. package/dist/runtime/usage-report.js +169 -96
  434. package/dist/runtime/waits.d.ts +140 -37
  435. package/dist/runtime/waits.js +394 -106
  436. package/dist/sandbox/jobs.d.ts +40 -13
  437. package/dist/sandbox/jobs.js +57 -20
  438. package/dist/sandbox/leases.d.ts +37 -54
  439. package/dist/sandbox/leases.js +71 -115
  440. package/dist/sandbox/providers.d.ts +2 -2
  441. package/dist/sandbox/providers.js +1 -1
  442. package/dist/sandbox/sandbox.module.d.ts +3 -2
  443. package/dist/sandbox/sandbox.module.js +4 -3
  444. package/dist/sandbox/sandbox.service.d.ts +229 -134
  445. package/dist/sandbox/sandbox.service.js +630 -409
  446. package/dist/skills/catalog.d.ts +3 -2
  447. package/dist/skills/catalog.js +21 -43
  448. package/dist/skills/changes.controller.d.ts +7 -0
  449. package/dist/skills/changes.controller.js +19 -1
  450. package/dist/skills/invoke.js +8 -3
  451. package/dist/skills/package.d.ts +20 -1
  452. package/dist/skills/package.js +28 -1
  453. package/dist/skills/skills.controller.d.ts +39 -4
  454. package/dist/skills/skills.controller.js +88 -10
  455. package/dist/skills/skills.module.js +10 -1
  456. package/dist/skills/skills.service.d.ts +106 -26
  457. package/dist/skills/skills.service.js +421 -75
  458. package/dist/skills/usable.d.ts +81 -0
  459. package/dist/skills/usable.js +379 -0
  460. package/dist/tools/approvals.service.d.ts +20 -2
  461. package/dist/tools/approvals.service.js +23 -4
  462. package/dist/tools/builtin-names.d.ts +21 -5
  463. package/dist/tools/builtin-names.js +30 -5
  464. package/dist/tools/builtins/agent.d.ts +23 -21
  465. package/dist/tools/builtins/agent.js +62 -55
  466. package/dist/tools/builtins/builtin-tools.d.ts +6 -2
  467. package/dist/tools/builtins/builtin-tools.js +37 -12
  468. package/dist/tools/builtins/handback.d.ts +28 -0
  469. package/dist/tools/builtins/handback.js +53 -0
  470. package/dist/tools/builtins/platform.d.ts +34 -0
  471. package/dist/tools/builtins/platform.js +362 -0
  472. package/dist/tools/builtins/sandbox/bash.js +13 -3
  473. package/dist/tools/builtins/sandbox/common.d.ts +43 -24
  474. package/dist/tools/builtins/sandbox/common.js +80 -45
  475. package/dist/tools/builtins/sandbox/edit.js +2 -2
  476. package/dist/tools/builtins/sandbox/glob.js +2 -2
  477. package/dist/tools/builtins/sandbox/grep.js +2 -4
  478. package/dist/tools/builtins/sandbox/index.d.ts +1 -1
  479. package/dist/tools/builtins/sandbox/index.js +1 -1
  480. package/dist/tools/builtins/sandbox/read.js +1 -1
  481. package/dist/tools/builtins/sandbox/task-output.d.ts +14 -3
  482. package/dist/tools/builtins/sandbox/task-output.js +30 -5
  483. package/dist/tools/builtins/sandbox/task-stop.js +2 -1
  484. package/dist/tools/builtins/sandbox/write.js +2 -2
  485. package/dist/tools/builtins/send-message.d.ts +56 -0
  486. package/dist/tools/builtins/send-message.js +100 -0
  487. package/dist/tools/builtins/skill-load.d.ts +22 -14
  488. package/dist/tools/builtins/skill-load.js +86 -57
  489. package/dist/tools/builtins/skill-write.js +1 -1
  490. package/dist/tools/builtins/web/extract.js +5 -1
  491. package/dist/tools/builtins/web/fetch.js +1 -0
  492. package/dist/tools/builtins/web/search.js +1 -0
  493. package/dist/tools/connectors.controller.d.ts +10 -0
  494. package/dist/tools/connectors.controller.js +12 -0
  495. package/dist/tools/connectors.service.d.ts +46 -5
  496. package/dist/tools/connectors.service.js +94 -15
  497. package/dist/tools/extension-tools.controller.d.ts +14 -0
  498. package/dist/tools/extension-tools.controller.js +37 -0
  499. package/dist/tools/info.d.ts +42 -1
  500. package/dist/tools/info.js +64 -1
  501. package/dist/tools/org-tool-switches.d.ts +74 -0
  502. package/dist/tools/org-tool-switches.js +184 -0
  503. package/dist/tools/pipeline.d.ts +46 -40
  504. package/dist/tools/pipeline.js +193 -364
  505. package/dist/tools/policy.d.ts +1 -1
  506. package/dist/tools/policy.js +36 -16
  507. package/dist/tools/registry.d.ts +98 -5
  508. package/dist/tools/registry.js +87 -9
  509. package/dist/tools/tools.module.js +12 -2
  510. package/dist/ui/views.d.ts +2 -1
  511. package/dist/ui/views.js +17 -3
  512. package/package.json +3 -3
  513. package/src/migrations/0074_subagent_tree.sql +50 -0
  514. package/src/migrations/0075_plugin_scope.sql +61 -0
  515. package/src/migrations/0076_skills_created_by_nullable.sql +6 -0
  516. package/src/migrations/0077_scope_requests.sql +52 -0
  517. package/src/migrations/0078_scope_grant_switches.sql +18 -0
  518. package/src/migrations/0079_scope_live_install_switches.sql +19 -0
  519. package/src/migrations/0080_rename_enterprise_admin.sql +18 -0
  520. package/src/migrations/0081_platform_components.sql +129 -0
  521. package/src/migrations/0082_platform_migration.sql +33 -0
  522. package/src/migrations/0083_plugin_scope_sync_failures.sql +15 -0
  523. package/src/migrations/0084_org_owned_items.sql +85 -0
  524. package/src/migrations/0085_agent_templates_phase4.sql +45 -0
  525. package/src/migrations/0086_org_layering.sql +30 -0
  526. package/src/migrations/0087_approval_summary.sql +6 -0
  527. package/src/migrations/0088_environments.sql +80 -0
  528. package/src/migrations/0089_model_kinds_usage.sql +38 -0
  529. package/dist/catalog/upgrade-targets.d.ts +0 -56
  530. package/dist/catalog/upgrade-targets.js +0 -90
  531. package/dist/conversations/sandbox-status.d.ts +0 -24
  532. package/dist/conversations/sandbox-status.js +0 -52
  533. package/dist/extensions/org-config.controller.d.ts +0 -32
  534. package/dist/extensions/org-config.controller.js +0 -70
@@ -1,5 +1,6 @@
1
1
  import { type AgentTemplate, type ConnectorTemplateFile, type ConnectorTemplateSpec, type PluginManifest } from "@capybara-hq/plugin-sdk";
2
2
  import type { KernelSchemaDb, SourceFormat } from "../db/kernel-schema.js";
3
+ import { ApiError } from "../errors.js";
3
4
  import { OrgExtensionConfigs, type OrgExtensionInput, type OrgExtensionPutOptions } from "../extensions/org-config.js";
4
5
  import { ExtensionRegistry } from "../extensions/registry.js";
5
6
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
@@ -10,10 +11,10 @@ import { OrgLock } from "../orgs/org-lock.js";
10
11
  import type { OrgAction } from "../orgs/roles.js";
11
12
  import { type SkillConflict, SkillsService } from "../skills/skills.service.js";
12
13
  import { StorageService } from "../storage/storage.service.js";
13
- import type { CreateConnectorInput } from "../tools/connectors.service.js";
14
+ import type { ConnectorDetail, CreateConnectorInput, ToolIssue } from "../tools/connectors.service.js";
14
15
  import { ConnectorsService } from "../tools/connectors.service.js";
15
16
  import { type CatalogVersionFiles, type TemplateDeps } from "./catalog-content.js";
16
- import { CatalogRequestsService } from "./requests.service.js";
17
+ import { type DefinitionRefs } from "./component-state.js";
17
18
  /** What an org fills in for one connector template at install (C30). */
18
19
  export interface ConnectorInstallInput {
19
20
  name?: string;
@@ -50,9 +51,49 @@ export interface UninstallReport {
50
51
  kept: {
51
52
  kind: ComponentKind;
52
53
  ref: string;
53
- reason: "pre_existing" | "used_by_agents" | "used_by_other_install" | "used_by_connectors" | "used_by_plugins";
54
+ reason: "pre_existing" | "used_by_agents" | "used_by_other_install" | "used_by_connectors" | "used_by_plugins"
55
+ /** A dependency install still wanted on in the org by its own scope: it stays, standalone. */
56
+ | "wanted_by_scope"
57
+ /**
58
+ * A connector the install created, kept by a scope sync uninstall (the plugin disabled or its
59
+ * scope narrowed, spec §5 rule 8): it stays as the org's own, with its credentials.
60
+ */
61
+ | "org_owned";
54
62
  }[];
55
63
  }
64
+ /**
65
+ * What switching a plugin off would do, read without changing anything: its components, the ones the
66
+ * uninstall rules would keep for a reason visible beforehand (a component that pre-existed, or one an
67
+ * agent uses), and the agents that use the plugin's skills, connectors or agent templates.
68
+ */
69
+ export interface UninstallPreview {
70
+ installId: string;
71
+ name: string;
72
+ version: string;
73
+ components: {
74
+ kind: ComponentKind;
75
+ ref: string;
76
+ created: boolean;
77
+ }[];
78
+ kept: UninstallReport["kept"];
79
+ agents: {
80
+ id: string;
81
+ name: string;
82
+ uses: {
83
+ kind: ComponentKind;
84
+ ref: string;
85
+ }[];
86
+ }[];
87
+ }
88
+ /** The confirm hash of an uninstall preview: sha256 over its sorted JSON (the scheme of `diffHash`). */
89
+ export declare function uninstallPreviewHash(p: UninstallPreview): string;
90
+ /** Upserts the org's switch row of an item in the caller's transaction (the org lock is held). */
91
+ export declare function upsertOrgSwitch(db: KernelSchemaDb, orgId: string, itemId: string, enabled: boolean, actor: string | null): Promise<void>;
92
+ /** The kernel (actor null, the scope sync) never installs what needs the org's input. */
93
+ export declare class NeedsOrgInput extends ApiError {
94
+ readonly plugin: string;
95
+ constructor(plugin: string);
96
+ }
56
97
  /** A plugin install in an org (`GET /orgs/:orgId/plugin-installs`). */
57
98
  export interface PluginInstallView {
58
99
  id: string;
@@ -78,13 +119,13 @@ export interface PluginInstallView {
78
119
  skillVersion: number | null;
79
120
  dropped: boolean;
80
121
  }[];
81
- /** The highest version this install can be upgraded to now, null when none (spec §10). */
82
- upgradeAvailable: string | null;
83
122
  /**
84
- * The plugin's extension on the deployment is not the one of this install's version: the org
85
- * should upgrade to the deployment's version ("upgrade pending", Decision 10).
123
+ * Always null / false since plugin scope phase 2: a platform plugin has one version for the
124
+ * deployment and the platform update moves every org install (ruling F2); kept for the web until
125
+ * its upgrade dialog goes.
86
126
  */
87
- deploymentPending: boolean;
127
+ upgradeAvailable: null;
128
+ deploymentPending: false;
88
129
  }
89
130
  /** A dependency resolved against the catalog. */
90
131
  export interface ResolvedDependency {
@@ -149,6 +190,8 @@ export declare class InstallFailure extends Error {
149
190
  dependency: string[], rolledBack: boolean);
150
191
  get code(): string;
151
192
  }
193
+ /** Merged into an install's or uninstall's audit detail (a write made through the Platform tool). */
194
+ type AuditDetail = Record<string, unknown>;
152
195
  export interface UninstallCtx {
153
196
  report: UninstallReport;
154
197
  /** The installs this uninstall is removing (none of them counts as still using a component). */
@@ -160,12 +203,15 @@ export interface UninstallCtx {
160
203
  reason?: string;
161
204
  opts: {
162
205
  actorTokenId?: string;
206
+ auditDetail?: AuditDetail;
163
207
  };
208
+ /** Uninstalled by the plugin scope sync: the connectors it created stay as the org's own. */
209
+ via?: "scope";
164
210
  }
165
211
  /**
166
- * Resolves a plugin's dependencies against the catalog: for each one the highest imported version
167
- * of the live item with that name satisfying its range. The whole dependency tree is checked: a
168
- * dependency nothing satisfies -> `catalog.dependency_unresolved`; a disabled one ->
212
+ * Resolves a plugin's dependencies against the catalog: for each one the platform version of the
213
+ * live item with that name, which must satisfy its range (see `resolveOne`). The whole dependency
214
+ * tree is checked: a dependency nothing satisfies -> `catalog.dependency_unresolved`; a disabled one ->
169
215
  * `catalog.dependency_disabled`; a cycle (`a` -> `b` -> `a`, by name) or nesting deeper than
170
216
  * {@link DEPENDENCY_DEPTH_LIMIT} -> `catalog.dependency_cycle`. Returns the direct dependencies.
171
217
  */
@@ -194,9 +240,11 @@ export declare function under(e: unknown, at: string): unknown;
194
240
  * not run it; already enabled is recorded created=false);
195
241
  * 3. connectors from the templates (credentials / clients go to secrets, default policies are
196
242
  * recorded `policy_source 'template'`);
197
- * 4. the skills (an org skill of the same name from the same catalog item gets a new version,
198
- * recorded created=false with skill_version; one of other provenance, the org's own or another
199
- * item's, refuses the install while planning with `plugin.skill_conflict`, spec §9.2).
243
+ * The plugin's skills and agent templates are platform components (plugin scope phase 2): stored
244
+ * once for the deployment and on in the org while the plugin is, so an install writes no org rows
245
+ * for them; a skill name the org already uses (its own skill, another plugin's) refuses the install
246
+ * while planning with `plugin.skill_conflict` (spec §9.2, rule 10). Uninstall leaves the org copies
247
+ * earlier installs wrote (linked to the platform components by the migration).
200
248
  * Approval follows the installed plugin's policy only (spec §10): dependency components are
201
249
  * re-checked against the root item's policy and their own item's disabled state. Each component is
202
250
  * recorded in `plugin_install_components` as soon as it exists; if any step fails, the components
@@ -204,9 +252,10 @@ export declare function under(e: unknown, at: string): unknown;
204
252
  * install is marked failed (error holds only the step and the error code) and 502
205
253
  * `plugin.install_failed` is thrown. Uninstall removes only components with created=true that
206
254
  * nothing else uses, and reports what it kept and why. No in-process state; the org row lock
207
- * serializes writes within one org. In-place upgrades are run by `PluginUpgrader`
208
- * (plugin-upgrade.ts), which reuses the planning, install and ledger methods here (the ones without
209
- * `private` are internal to the catalog, not an API).
255
+ * serializes writes within one org. There is no per-org upgrade: a platform plugin is updated
256
+ * once for the deployment (`PlatformPluginUpdater`, plugin-upgrade.ts, ruling F2); an install left
257
+ * `upgrading` by an earlier per-org upgrade is undone from its journal by the next uninstall. The
258
+ * methods without `private` are internal to the catalog, not an API.
210
259
  */
211
260
  export declare class PluginInstaller {
212
261
  private readonly kdb;
@@ -217,7 +266,6 @@ export declare class PluginInstaller {
217
266
  private readonly registry;
218
267
  private readonly skills;
219
268
  private readonly orgConfigs;
220
- private readonly requests;
221
269
  private readonly config;
222
270
  /** Org connectors: installs create, upgrade and remove them. */
223
271
  private readonly connectors;
@@ -227,7 +275,7 @@ export declare class PluginInstaller {
227
275
  /** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
228
276
  orgLock: OrgLock, storage: StorageService,
229
277
  /** The loaded extensions and connectors of this replica (the extension registry). */
230
- registry: ExtensionRegistry, skills: SkillsService, orgConfigs: OrgExtensionConfigs, requests: CatalogRequestsService, config: KernelConfigService,
278
+ registry: ExtensionRegistry, skills: SkillsService, orgConfigs: OrgExtensionConfigs, config: KernelConfigService,
231
279
  /** Org connectors: installs create, upgrade and remove them. */
232
280
  connectors: ConnectorsService, log: KernelLogger, txHost: TransactionHost);
233
281
  /** The kernel-schema handle of the current context (the transaction, else the pool). */
@@ -242,8 +290,11 @@ export declare class PluginInstaller {
242
290
  preflight(orgId: string, actor: string, itemId: string, version: string): Promise<{
243
291
  actions: OrgAction[];
244
292
  }>;
245
- install(orgId: string, actor: string, itemId: string, version: string, input: PluginInstallInput, opts?: {
293
+ install(orgId: string, actor: string | null, itemId: string, version: string, input: PluginInstallInput, opts?: {
246
294
  actorTokenId?: string;
295
+ auditDetail?: AuditDetail;
296
+ switchOn?: boolean;
297
+ via?: "scope";
247
298
  }): Promise<PluginInstallView>;
248
299
  /**
249
300
  * Refuses a plan whose skills would overwrite a skill of other provenance (spec §9.2, Decision
@@ -260,7 +311,20 @@ export declare class PluginInstaller {
260
311
  * an empty input. `at` prefixes validation paths (`dependencies.<name>.` for a dependency);
261
312
  * `approvedBy` is the root item for a dependency.
262
313
  */
263
- plan(orgId: string, actor: string, itemId: string, version: string, input: PluginInstallInput | null, at: string, approvedBy: string | undefined): Promise<InstallPlan>;
314
+ plan(orgId: string, actor: string | null, itemId: string, version: string, input: PluginInstallInput | null, at: string, approvedBy: string | undefined): Promise<InstallPlan>;
315
+ /**
316
+ * The providers of the templates' connector kinds as implied dependencies: a template whose
317
+ * `plugin` is neither this plugin, a declared dependency nor already enabled in the org makes that
318
+ * plugin a dependency (installed first, recorded like a declared one, so an uninstall hands it
319
+ * back). No such plugin offered by the catalog -> `connector.kind_unavailable` naming it, before
320
+ * anything is written.
321
+ */
322
+ impliedProviders(orgId: string, manifest: PluginManifest, templates: {
323
+ id: string;
324
+ file: ConnectorTemplateFile;
325
+ }[], declared: {
326
+ name: string;
327
+ }[]): Promise<ResolvedDependency[]>;
264
328
  /**
265
329
  * The connector input of one template from the org's input (C30), checked without a connection:
266
330
  * the template's connector extension deployed, the input valid, the credential / OAuth client it
@@ -300,12 +364,16 @@ export declare class PluginInstaller {
300
364
  * {@link InstallFailure} once the row exists (after rolling back); errors before it propagate
301
365
  * as they are. Returns the install id.
302
366
  */
303
- execute(orgId: string, actor: string, plan: InstallPlan, opts: {
367
+ execute(orgId: string, actor: string | null, plan: InstallPlan, opts: {
304
368
  actorTokenId?: string;
369
+ auditDetail?: AuditDetail;
305
370
  }, ctx: {
306
371
  actions: OrgAction[];
307
372
  approvedBy?: string;
308
373
  parent?: string;
374
+ switchOn?: boolean;
375
+ /** Installed by the plugin scope sync (recorded in the audits). */
376
+ via?: "scope";
309
377
  }): Promise<string>;
310
378
  /**
311
379
  * The install row (role and item policy re-checked under the lock; one live install per org and
@@ -318,13 +386,8 @@ export declare class PluginInstaller {
318
386
  * created), and the ledger row is written before the COMMIT, so no concurrent uninstall fits
319
387
  * between enabling and recording. Used by the install and the upgrade.
320
388
  */
321
- enableExtension(orgId: string, name: string, input: OrgExtensionInput, actor: string, actorTokenId: string | undefined, opts: Pick<OrgExtensionPutOptions, "viaItem" | "approvedBy">, record: (c: Component) => Promise<void>): Promise<void>;
389
+ enableExtension(orgId: string, name: string, input: OrgExtensionInput, actor: string | null, actorTokenId: string | undefined, opts: Pick<OrgExtensionPutOptions, "viaItem" | "approvedBy">, record: (c: Component) => Promise<void>): Promise<void>;
322
390
  private createInstallRow;
323
- /**
324
- * An agent template step: created (or a new version of the org's live template of this plugin and
325
- * name) and recorded in one transaction of its own, under the org row lock.
326
- */
327
- private installAgentTemplate;
328
391
  /** The install `installed` and its `plugin.org_installed` audit, under the org row lock (its own transaction). */
329
392
  private markInstalled;
330
393
  /** The install `failed` with `{ step, code }` and its `plugin.org_install_failed` audit (its own transaction). */
@@ -353,7 +416,7 @@ export declare class PluginInstaller {
353
416
  */
354
417
  private rollbackOne;
355
418
  /** Removes one component (one already gone is no error); returns whether anything changed. */
356
- removeComponent(orgId: string, actor: string, c: Component, reason: string): Promise<boolean>;
419
+ removeComponent(orgId: string, actor: string | null, c: Component, reason: string): Promise<boolean>;
357
420
  /**
358
421
  * Uninstall (the plugin's component actions, see `requiredActions`, re-checked under the org row
359
422
  * lock, one transaction). Removes only components with created=true:
@@ -376,10 +439,19 @@ export declare class PluginInstaller {
376
439
  * (a replica crashed midway) - the last two are cleaned up as a rollback (versions added to
377
440
  * existing skills are reverted too). Still installing -> `plugin.install_in_progress`.
378
441
  */
379
- uninstall(orgId: string, actor: string, installId: string, opts?: {
442
+ uninstall(orgId: string, actor: string | null, installId: string, opts?: {
380
443
  actorTokenId?: string;
444
+ auditDetail?: AuditDetail;
445
+ via?: "scope";
446
+ }, sw?: {
447
+ expectHash?: string;
381
448
  }): Promise<UninstallReport>;
382
- /** The uninstall's one transaction; the extensions it disabled are notified once it commits. */
449
+ /**
450
+ * The uninstall's one transaction; the extensions it disabled are notified once it commits. A
451
+ * scope sync uninstall (`via: "scope"`) re-checks under the org row lock that the item is still
452
+ * not wanted in the org and that no other live install depends on it ({@link ScopeStillWanted},
453
+ * nothing written), and keeps the connectors it created as the org's own (`org_owned`).
454
+ */
383
455
  private writeUninstall;
384
456
  /**
385
457
  * The oldest other live install (not in `removing`) that has component `kind` / `ref`, or
@@ -394,7 +466,7 @@ export declare class PluginInstaller {
394
466
  * outcome of the install itself is returned for the caller to report: `missing`, `kept` (another
395
467
  * install outside this uninstall depends on it) or `removed`.
396
468
  */
397
- uninstallIn(orgId: string, actor: string, installId: string, ctx: UninstallCtx): Promise<"missing" | "kept" | "removed">;
469
+ uninstallIn(orgId: string, actor: string | null, installId: string, ctx: UninstallCtx): Promise<"missing" | "kept" | "removed" | "wanted_by_scope">;
398
470
  /**
399
471
  * The uninstall rules for one component an install created (a skill, connector or extension;
400
472
  * dependency installs recurse through {@link uninstallIn}), in the caller's transaction: kept
@@ -405,7 +477,7 @@ export declare class PluginInstaller {
405
477
  * (`used_by_plugins`); otherwise removed (`removed`, or `gone` when it no longer existed). Used
406
478
  * by uninstall and by an upgrade's removals.
407
479
  */
408
- decideRemovalIn(orgId: string, actor: string, c: Component, removing: Set<string>, agentRefs: {
480
+ decideRemovalIn(orgId: string, actor: string | null, c: Component, removing: Set<string>, agentRefs: {
409
481
  connectors: Set<string>;
410
482
  skills: Set<string>;
411
483
  templates: Set<string>;
@@ -423,21 +495,92 @@ export declare class PluginInstaller {
423
495
  * extension among them needs `afterDisable` once committed). Used when an upgrade fails and when
424
496
  * an interrupted one is cleaned up.
425
497
  */
426
- undoUpgradeIn(orgId: string, actor: string, installId: string, steps: readonly UpgradeStep[], reason: string): Promise<{
498
+ undoUpgradeIn(orgId: string, actor: string | null, installId: string, steps: readonly UpgradeStep[], reason: string): Promise<{
427
499
  kind: ComponentKind;
428
500
  ref: string;
429
501
  }[]>;
502
+ /**
503
+ * Installs the dependencies an installed plugin's version declares and the org lacks (rule 9),
504
+ * as the kernel (actor null): a platform update can add one. Each is recorded on the install
505
+ * as a `plugin` component (created when this installed it, so an uninstall takes it along). One
506
+ * that needs the org's input (connector templates) is left out and its name returned. A
507
+ * dependency already installed in the org is recorded as it is (created false).
508
+ */
509
+ addMissingDependencies(orgId: string, installId: string): Promise<string[]>;
510
+ /**
511
+ * The connector templates of an installed plugin that are on in the org (ruling P2-6) and have
512
+ * no live connector there: made from the platform template (`platform_template_id`) or recorded
513
+ * on the install (`template_id`). The org's plugin is `needs_config` while any is missing (ruling
514
+ * P2-10). Empty for a plugin not installed.
515
+ */
516
+ missingConnectors(orgId: string, itemId: string): Promise<{
517
+ installId: string;
518
+ version: string;
519
+ templates: {
520
+ id: string;
521
+ file: ConnectorTemplateFile;
522
+ }[];
523
+ } | undefined>;
524
+ /**
525
+ * Creates the connectors an installed plugin is missing (ruling P2-10, `POST …/catalog/:itemId/
526
+ * connectors`): `input.connectors` names some of {@link missingConnectors}' templates with the
527
+ * same input as an install (endpoint, credential or OAuth client); each is created as at install
528
+ * and recorded on the install. Returns the created connectors by template.
529
+ */
530
+ configureConnectors(orgId: string, actor: string, itemId: string, input: PluginInstallInput, opts?: {
531
+ actorTokenId?: string;
532
+ }): Promise<{
533
+ templateId: string;
534
+ connectorId: string;
535
+ }[]>;
536
+ /** A configured connector's ledger row (its own transaction). */
537
+ private recordConnector;
538
+ /**
539
+ * One more connector from a platform connector template on in the org (rulings P4-7, P4-T6-8;
540
+ * `POST …/connector-templates/:templateId/connectors`): `templateId` is the platform connector
541
+ * template's id; `config` is an install's connector input (endpoint, credential or OAuth client,
542
+ * slug) and `name` its name. Without a slug the name and slug default to the first free ones,
543
+ * chosen by the create under the org lock after its outbound calls
544
+ * (`CreateConnectorInput.slugDefault`); only a given slug answers 409 `connector.slug_taken`. Created as at install ({@link planConnector}, then
545
+ * `ConnectorsService.create`, which checks the slug before any outbound call and re-checks it,
546
+ * `connectors.manage`, the item and the template being on under the org lock), linked to the
547
+ * template, and recorded on the plugin's live install in the org when there is one. A template
548
+ * that is missing, deleted or not offered to the org -> 404 `component.not_found`; offered but
549
+ * off there (its plugin not installed, or switched off) -> 409 `component.off`; input errors ->
550
+ * 400 `validation_failed` at `config.<field>`.
551
+ */
552
+ addTemplateConnector(orgId: string, actor: string, templateId: string, input: {
553
+ name?: string | undefined;
554
+ config: Omit<ConnectorInstallInput, "name">;
555
+ }, opts?: {
556
+ actorTokenId?: string;
557
+ }): Promise<{
558
+ connector: ConnectorDetail;
559
+ issues: ToolIssue[];
560
+ }>;
561
+ /**
562
+ * Records a connector made from a plugin's template on the org's live install of that plugin,
563
+ * when there is one, under the org lock (so an uninstall in between is seen).
564
+ */
565
+ private recordOnLiveInstall;
430
566
  /** The connector kinds an extension provides (the `connector@1` implementations loaded on this replica). */
431
567
  connectorKindsOf(plugin: string): string[];
432
568
  /**
433
- * The connectors, org skills and agent templates (`subagents.templates`) referenced by the
434
- * current definitions of the org's live agents.
569
+ * The uninstall preview of an install (see {@link UninstallPreview}); the real uninstall may keep
570
+ * more (another install using a component, a connector still using an extension). The plugin's
571
+ * skills and agent templates are platform components (phase 2): the ones on in the org through
572
+ * the plugin (`follow`) go off with it, so the agents using them (by the platform id or an
573
+ * unpinned org copy linked to it) are listed, also for the dependency installs it created that
574
+ * go with it; ledger rows of earlier installs' org copies are not removed and not listed (an
575
+ * uninstall keeps legacy copies, like the platform update keeps copies of removed components).
435
576
  */
436
- agentRefs(orgId: string): Promise<{
437
- connectors: Set<string>;
438
- skills: Set<string>;
439
- templates: Set<string>;
440
- }>;
577
+ previewUninstall(orgId: string, installId: string): Promise<UninstallPreview>;
578
+ /**
579
+ * The connectors, skills (selected, pinned, or in an inline sub-agent template) and agent
580
+ * templates (`subagents.templates`) referenced by the current definitions of the org's live
581
+ * agents.
582
+ */
583
+ agentRefs(orgId: string): Promise<DefinitionRefs>;
441
584
  }
442
585
  /**
443
586
  * The skill names of a catalog version, read from each skill's SKILL.md in storage (the names are
@@ -487,3 +630,4 @@ export type UpgradeStep = {
487
630
  export declare function journalEntries(upgrade: unknown): UpgradeStep[];
488
631
  /** The org actions a plan needs: the union over the plugins it installs (spec §10). */
489
632
  export declare function planActions(plan: InstallPlan): OrgAction[];
633
+ export {};