@capybara-hq/kernel 0.0.0-stage → 0.1.0-rc.1

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 (637) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +2 -0
  3. package/README.md +20 -2
  4. package/bootstrap.json +26 -0
  5. package/dist/admin/admin.controller.d.ts +139 -0
  6. package/dist/admin/admin.controller.js +238 -0
  7. package/dist/admin/extensions.controller.d.ts +100 -0
  8. package/dist/admin/extensions.controller.js +226 -0
  9. package/dist/admin/setup.controller.d.ts +36 -0
  10. package/dist/admin/setup.controller.js +106 -0
  11. package/dist/admin/setup.service.d.ts +47 -0
  12. package/dist/admin/setup.service.js +90 -0
  13. package/dist/agents/agents.controller.d.ts +205 -0
  14. package/dist/agents/agents.controller.js +144 -0
  15. package/dist/agents/agents.service.d.ts +177 -0
  16. package/dist/agents/agents.service.js +677 -0
  17. package/dist/agents/definition.d.ts +198 -0
  18. package/dist/agents/definition.js +152 -0
  19. package/dist/agents/models.controller.d.ts +13 -0
  20. package/dist/agents/models.controller.js +31 -0
  21. package/dist/agents/templates.controller.d.ts +15 -0
  22. package/dist/agents/templates.controller.js +37 -0
  23. package/dist/agents/templates.d.ts +83 -0
  24. package/dist/agents/templates.js +173 -0
  25. package/dist/catalog/admin-catalog.controller.d.ts +143 -0
  26. package/dist/catalog/admin-catalog.controller.js +245 -0
  27. package/dist/catalog/catalog.service.d.ts +430 -0
  28. package/dist/catalog/catalog.service.js +882 -0
  29. package/dist/catalog/claude/agents.d.ts +27 -0
  30. package/dist/catalog/claude/agents.js +270 -0
  31. package/dist/catalog/claude/commands.d.ts +50 -0
  32. package/dist/catalog/claude/commands.js +179 -0
  33. package/dist/catalog/claude/manifest.d.ts +69 -0
  34. package/dist/catalog/claude/manifest.js +134 -0
  35. package/dist/catalog/claude/marketplace.d.ts +35 -0
  36. package/dist/catalog/claude/marketplace.js +194 -0
  37. package/dist/catalog/claude/mcp.d.ts +33 -0
  38. package/dist/catalog/claude/mcp.js +226 -0
  39. package/dist/catalog/claude/report.d.ts +86 -0
  40. package/dist/catalog/claude/report.js +121 -0
  41. package/dist/catalog/claude/translate.d.ts +56 -0
  42. package/dist/catalog/claude/translate.js +857 -0
  43. package/dist/catalog/cli.d.ts +46 -0
  44. package/dist/catalog/cli.js +211 -0
  45. package/dist/catalog/git-source.d.ts +127 -0
  46. package/dist/catalog/git-source.js +520 -0
  47. package/dist/catalog/marketplace-fetch.d.ts +99 -0
  48. package/dist/catalog/marketplace-fetch.js +203 -0
  49. package/dist/catalog/marketplaces.controller.d.ts +97 -0
  50. package/dist/catalog/marketplaces.controller.js +197 -0
  51. package/dist/catalog/marketplaces.service.d.ts +340 -0
  52. package/dist/catalog/marketplaces.service.js +1217 -0
  53. package/dist/catalog/org-catalog.controller.d.ts +128 -0
  54. package/dist/catalog/org-catalog.controller.js +277 -0
  55. package/dist/catalog/org-catalog.service.d.ts +246 -0
  56. package/dist/catalog/org-catalog.service.js +625 -0
  57. package/dist/catalog/plugin-import.d.ts +436 -0
  58. package/dist/catalog/plugin-import.js +1069 -0
  59. package/dist/catalog/plugin-install.d.ts +447 -0
  60. package/dist/catalog/plugin-install.js +1333 -0
  61. package/dist/catalog/plugin-package.d.ts +143 -0
  62. package/dist/catalog/plugin-package.js +382 -0
  63. package/dist/catalog/plugin-upgrade.d.ts +222 -0
  64. package/dist/catalog/plugin-upgrade.js +1219 -0
  65. package/dist/catalog/requests.service.d.ts +162 -0
  66. package/dist/catalog/requests.service.js +504 -0
  67. package/dist/catalog/schema-path.d.ts +7 -0
  68. package/dist/catalog/schema-path.js +63 -0
  69. package/dist/catalog/upgrade-targets.d.ts +59 -0
  70. package/dist/catalog/upgrade-targets.js +90 -0
  71. package/dist/catalog/versions.d.ts +31 -0
  72. package/dist/catalog/versions.js +44 -0
  73. package/dist/channels/actions.d.ts +37 -0
  74. package/dist/channels/actions.js +121 -0
  75. package/dist/channels/cards.d.ts +44 -0
  76. package/dist/channels/cards.js +156 -0
  77. package/dist/channels/connections.controller.d.ts +59 -0
  78. package/dist/channels/connections.controller.js +115 -0
  79. package/dist/channels/connections.service.d.ts +187 -0
  80. package/dist/channels/connections.service.js +534 -0
  81. package/dist/channels/features.d.ts +12 -0
  82. package/dist/channels/features.js +22 -0
  83. package/dist/channels/inbound.d.ts +120 -0
  84. package/dist/channels/inbound.js +332 -0
  85. package/dist/channels/outbound.d.ts +140 -0
  86. package/dist/channels/outbound.js +1126 -0
  87. package/dist/channels/phrases.d.ts +100 -0
  88. package/dist/channels/phrases.js +81 -0
  89. package/dist/channels/supervisor.d.ts +182 -0
  90. package/dist/channels/supervisor.js +625 -0
  91. package/dist/channels/threads.d.ts +29 -0
  92. package/dist/channels/threads.js +104 -0
  93. package/dist/channels/webhook-url.d.ts +16 -0
  94. package/dist/channels/webhook-url.js +34 -0
  95. package/dist/channels/webhook.controller.d.ts +19 -0
  96. package/dist/channels/webhook.controller.js +72 -0
  97. package/dist/channels/webhook.d.ts +73 -0
  98. package/dist/channels/webhook.js +274 -0
  99. package/dist/config/docs.d.ts +9 -0
  100. package/dist/config/docs.js +85 -0
  101. package/dist/config/env.d.ts +6 -0
  102. package/dist/config/env.js +73 -0
  103. package/dist/config/fields.d.ts +42 -0
  104. package/dist/config/fields.js +214 -0
  105. package/dist/config/file-source.d.ts +3 -0
  106. package/dist/config/file-source.js +31 -0
  107. package/dist/config/load.d.ts +20 -0
  108. package/dist/config/load.js +98 -0
  109. package/dist/config/nacos-source.d.ts +31 -0
  110. package/dist/config/nacos-source.js +229 -0
  111. package/dist/config/schema.d.ts +237 -0
  112. package/dist/config/schema.js +1192 -0
  113. package/dist/config/sources.d.ts +18 -0
  114. package/dist/config/sources.js +59 -0
  115. package/dist/config/types.d.ts +9 -0
  116. package/dist/config/types.js +7 -0
  117. package/dist/conversations/artifacts.d.ts +52 -0
  118. package/dist/conversations/artifacts.js +137 -0
  119. package/dist/conversations/attachments.controller.d.ts +28 -0
  120. package/dist/conversations/attachments.controller.js +96 -0
  121. package/dist/conversations/attachments.service.d.ts +180 -0
  122. package/dist/conversations/attachments.service.js +578 -0
  123. package/dist/conversations/conversations.controller.d.ts +288 -0
  124. package/dist/conversations/conversations.controller.js +607 -0
  125. package/dist/conversations/conversations.service.d.ts +321 -0
  126. package/dist/conversations/conversations.service.js +754 -0
  127. package/dist/conversations/event-log.d.ts +122 -0
  128. package/dist/conversations/event-log.js +259 -0
  129. package/dist/conversations/events.d.ts +856 -0
  130. package/dist/conversations/events.js +639 -0
  131. package/dist/conversations/files.d.ts +92 -0
  132. package/dist/conversations/files.js +213 -0
  133. package/dist/conversations/outputs-read.d.ts +34 -0
  134. package/dist/conversations/outputs-read.js +37 -0
  135. package/dist/conversations/queue.d.ts +169 -0
  136. package/dist/conversations/queue.js +527 -0
  137. package/dist/conversations/sandbox-status.d.ts +21 -0
  138. package/dist/conversations/sandbox-status.js +24 -0
  139. package/dist/conversations/selection.d.ts +46 -0
  140. package/dist/conversations/selection.js +75 -0
  141. package/dist/conversations/titles.d.ts +93 -0
  142. package/dist/conversations/titles.js +423 -0
  143. package/dist/ctx/bus.d.ts +16 -0
  144. package/dist/ctx/bus.js +101 -0
  145. package/dist/ctx/create-ctx.d.ts +109 -0
  146. package/dist/ctx/create-ctx.js +592 -0
  147. package/dist/ctx/kv.d.ts +4 -0
  148. package/dist/ctx/kv.js +31 -0
  149. package/dist/ctx/lock.d.ts +4 -0
  150. package/dist/ctx/lock.js +39 -0
  151. package/dist/ctx/namespace.d.ts +6 -0
  152. package/dist/ctx/namespace.js +12 -0
  153. package/dist/ctx/queue.d.ts +25 -0
  154. package/dist/ctx/queue.js +151 -0
  155. package/dist/ctx/secrets.d.ts +45 -0
  156. package/dist/ctx/secrets.js +175 -0
  157. package/dist/db/kernel-schema.d.ts +1122 -0
  158. package/dist/db/kernel-schema.js +5 -0
  159. package/dist/db/migrator.d.ts +28 -0
  160. package/dist/db/migrator.js +140 -0
  161. package/dist/db/pool.d.ts +21 -0
  162. package/dist/db/pool.js +28 -0
  163. package/dist/db/sql-statements.d.ts +34 -0
  164. package/dist/db/sql-statements.js +168 -0
  165. package/dist/errors.d.ts +211 -0
  166. package/dist/errors.js +213 -0
  167. package/dist/evals/budget.d.ts +61 -0
  168. package/dist/evals/budget.js +181 -0
  169. package/dist/evals/diff.d.ts +55 -0
  170. package/dist/evals/diff.js +133 -0
  171. package/dist/evals/judge.d.ts +53 -0
  172. package/dist/evals/judge.js +149 -0
  173. package/dist/evals/plan.d.ts +47 -0
  174. package/dist/evals/plan.js +77 -0
  175. package/dist/evals/reconstruct.d.ts +137 -0
  176. package/dist/evals/reconstruct.js +322 -0
  177. package/dist/evals/recorded-tools.d.ts +54 -0
  178. package/dist/evals/recorded-tools.js +167 -0
  179. package/dist/evals/run-replay.d.ts +86 -0
  180. package/dist/evals/run-replay.js +502 -0
  181. package/dist/evals/runs.controller.d.ts +100 -0
  182. package/dist/evals/runs.controller.js +199 -0
  183. package/dist/evals/runs.service.d.ts +275 -0
  184. package/dist/evals/runs.service.js +836 -0
  185. package/dist/evals/sets.controller.d.ts +61 -0
  186. package/dist/evals/sets.controller.js +183 -0
  187. package/dist/evals/sets.service.d.ts +128 -0
  188. package/dist/evals/sets.service.js +558 -0
  189. package/dist/evals/snapshot.d.ts +76 -0
  190. package/dist/evals/snapshot.js +207 -0
  191. package/dist/evals/step-replay.d.ts +113 -0
  192. package/dist/evals/step-replay.js +181 -0
  193. package/dist/evals/trajectory.controller.d.ts +41 -0
  194. package/dist/evals/trajectory.controller.js +88 -0
  195. package/dist/evals/trajectory.d.ts +144 -0
  196. package/dist/evals/trajectory.js +338 -0
  197. package/dist/evals/trajectory.service.d.ts +108 -0
  198. package/dist/evals/trajectory.service.js +323 -0
  199. package/dist/evals/worker.d.ts +101 -0
  200. package/dist/evals/worker.js +790 -0
  201. package/dist/extensions/admin-ops.d.ts +105 -0
  202. package/dist/extensions/admin-ops.js +353 -0
  203. package/dist/extensions/admin-view.d.ts +79 -0
  204. package/dist/extensions/admin-view.js +327 -0
  205. package/dist/extensions/approvals.d.ts +119 -0
  206. package/dist/extensions/approvals.js +205 -0
  207. package/dist/extensions/blobs.d.ts +45 -0
  208. package/dist/extensions/blobs.js +160 -0
  209. package/dist/extensions/bootstrap.d.ts +176 -0
  210. package/dist/extensions/bootstrap.js +535 -0
  211. package/dist/extensions/cli.d.ts +61 -0
  212. package/dist/extensions/cli.js +165 -0
  213. package/dist/extensions/config-json-schema.d.ts +9 -0
  214. package/dist/extensions/config-json-schema.js +73 -0
  215. package/dist/extensions/deployment-config.d.ts +138 -0
  216. package/dist/extensions/deployment-config.js +394 -0
  217. package/dist/extensions/enabled.d.ts +31 -0
  218. package/dist/extensions/enabled.js +55 -0
  219. package/dist/extensions/hooks.d.ts +161 -0
  220. package/dist/extensions/hooks.js +425 -0
  221. package/dist/extensions/host.d.ts +577 -0
  222. package/dist/extensions/host.js +2071 -0
  223. package/dist/extensions/inflight.d.ts +69 -0
  224. package/dist/extensions/inflight.js +277 -0
  225. package/dist/extensions/installs.d.ts +166 -0
  226. package/dist/extensions/installs.js +253 -0
  227. package/dist/extensions/instance.d.ts +167 -0
  228. package/dist/extensions/instance.js +329 -0
  229. package/dist/extensions/ledger.d.ts +30 -0
  230. package/dist/extensions/ledger.js +50 -0
  231. package/dist/extensions/lifecycle.d.ts +80 -0
  232. package/dist/extensions/lifecycle.js +152 -0
  233. package/dist/extensions/migrate-lock.d.ts +51 -0
  234. package/dist/extensions/migrate-lock.js +100 -0
  235. package/dist/extensions/org-config.controller.d.ts +24 -0
  236. package/dist/extensions/org-config.controller.js +59 -0
  237. package/dist/extensions/org-config.d.ts +169 -0
  238. package/dist/extensions/org-config.js +520 -0
  239. package/dist/extensions/package.d.ts +115 -0
  240. package/dist/extensions/package.js +246 -0
  241. package/dist/extensions/permission-set.d.ts +117 -0
  242. package/dist/extensions/permission-set.js +184 -0
  243. package/dist/extensions/permission-view.d.ts +194 -0
  244. package/dist/extensions/permission-view.js +284 -0
  245. package/dist/extensions/registry.d.ts +24 -0
  246. package/dist/extensions/registry.js +56 -0
  247. package/dist/extensions/resolve.d.ts +12 -0
  248. package/dist/extensions/resolve.js +71 -0
  249. package/dist/extensions/sources.d.ts +69 -0
  250. package/dist/extensions/sources.js +120 -0
  251. package/dist/extensions/sync.d.ts +40 -0
  252. package/dist/extensions/sync.js +242 -0
  253. package/dist/files/previewers.controller.d.ts +46 -0
  254. package/dist/files/previewers.controller.js +105 -0
  255. package/dist/files/previewers.d.ts +100 -0
  256. package/dist/files/previewers.js +250 -0
  257. package/dist/http/api.module.d.ts +114 -0
  258. package/dist/http/api.module.js +448 -0
  259. package/dist/http/app.d.ts +77 -0
  260. package/dist/http/app.js +220 -0
  261. package/dist/http/error.filter.d.ts +21 -0
  262. package/dist/http/error.filter.js +85 -0
  263. package/dist/http/gateway.module.d.ts +15 -0
  264. package/dist/http/gateway.module.js +13 -0
  265. package/dist/http/health.controller.d.ts +26 -0
  266. package/dist/http/health.controller.js +79 -0
  267. package/dist/http/nest-logger.d.ts +20 -0
  268. package/dist/http/nest-logger.js +28 -0
  269. package/dist/http/plugin-dispatch.d.ts +68 -0
  270. package/dist/http/plugin-dispatch.js +200 -0
  271. package/dist/http/tokens.d.ts +131 -0
  272. package/dist/http/tokens.js +131 -0
  273. package/dist/http/zod.pipe.d.ts +8 -0
  274. package/dist/http/zod.pipe.js +14 -0
  275. package/dist/identity/accounts.d.ts +93 -0
  276. package/dist/identity/accounts.js +367 -0
  277. package/dist/identity/api-tokens.d.ts +73 -0
  278. package/dist/identity/api-tokens.js +197 -0
  279. package/dist/identity/audit.d.ts +23 -0
  280. package/dist/identity/audit.js +41 -0
  281. package/dist/identity/auth.controller.d.ts +40 -0
  282. package/dist/identity/auth.controller.js +130 -0
  283. package/dist/identity/auth.guard.d.ts +41 -0
  284. package/dist/identity/auth.guard.js +162 -0
  285. package/dist/identity/binding.d.ts +47 -0
  286. package/dist/identity/binding.js +84 -0
  287. package/dist/identity/cookies.d.ts +16 -0
  288. package/dist/identity/cookies.js +32 -0
  289. package/dist/identity/credential-check.d.ts +17 -0
  290. package/dist/identity/credential-check.js +24 -0
  291. package/dist/identity/enterprise-admin.d.ts +14 -0
  292. package/dist/identity/enterprise-admin.js +27 -0
  293. package/dist/identity/external.d.ts +106 -0
  294. package/dist/identity/external.js +337 -0
  295. package/dist/identity/hash.d.ts +2 -0
  296. package/dist/identity/hash.js +3 -0
  297. package/dist/identity/login.d.ts +6 -0
  298. package/dist/identity/login.js +20 -0
  299. package/dist/identity/me.controller.d.ts +61 -0
  300. package/dist/identity/me.controller.js +159 -0
  301. package/dist/identity/passwords.d.ts +6 -0
  302. package/dist/identity/passwords.js +37 -0
  303. package/dist/identity/principal.d.ts +56 -0
  304. package/dist/identity/principal.js +38 -0
  305. package/dist/identity/rate-limit.d.ts +55 -0
  306. package/dist/identity/rate-limit.js +121 -0
  307. package/dist/identity/sessions.d.ts +84 -0
  308. package/dist/identity/sessions.js +306 -0
  309. package/dist/identity/settings.d.ts +121 -0
  310. package/dist/identity/settings.js +248 -0
  311. package/dist/identity/sso.controller.d.ts +59 -0
  312. package/dist/identity/sso.controller.js +192 -0
  313. package/dist/identity/sso.d.ts +83 -0
  314. package/dist/identity/sso.js +202 -0
  315. package/dist/inbox/inbox.service.d.ts +43 -0
  316. package/dist/inbox/inbox.service.js +57 -0
  317. package/dist/index.d.ts +69 -0
  318. package/dist/index.js +67 -0
  319. package/dist/kernel.d.ts +259 -0
  320. package/dist/kernel.js +1326 -0
  321. package/dist/log-config.d.ts +9 -0
  322. package/dist/log-config.js +27 -0
  323. package/dist/log-context.d.ts +32 -0
  324. package/dist/log-context.js +40 -0
  325. package/dist/log-loki.d.ts +34 -0
  326. package/dist/log-loki.js +145 -0
  327. package/dist/log.d.ts +79 -0
  328. package/dist/log.js +303 -0
  329. package/dist/models/prices.d.ts +53 -0
  330. package/dist/models/prices.js +121 -0
  331. package/dist/models/purposes.controller.d.ts +19 -0
  332. package/dist/models/purposes.controller.js +56 -0
  333. package/dist/models/purposes.d.ts +140 -0
  334. package/dist/models/purposes.js +267 -0
  335. package/dist/net/proxy.d.ts +44 -0
  336. package/dist/net/proxy.js +162 -0
  337. package/dist/net/public-address.d.ts +60 -0
  338. package/dist/net/public-address.js +272 -0
  339. package/dist/net/safe-fetch.d.ts +38 -0
  340. package/dist/net/safe-fetch.js +140 -0
  341. package/dist/orgs/directory-sync.controller.d.ts +14 -0
  342. package/dist/orgs/directory-sync.controller.js +40 -0
  343. package/dist/orgs/directory-sync.d.ts +166 -0
  344. package/dist/orgs/directory-sync.js +558 -0
  345. package/dist/orgs/invitations.controller.d.ts +58 -0
  346. package/dist/orgs/invitations.controller.js +137 -0
  347. package/dist/orgs/invitations.service.d.ts +80 -0
  348. package/dist/orgs/invitations.service.js +217 -0
  349. package/dist/orgs/members.service.d.ts +63 -0
  350. package/dist/orgs/members.service.js +234 -0
  351. package/dist/orgs/offboarding.d.ts +141 -0
  352. package/dist/orgs/offboarding.js +398 -0
  353. package/dist/orgs/org-lock.d.ts +32 -0
  354. package/dist/orgs/org-lock.js +46 -0
  355. package/dist/orgs/org.guard.d.ts +35 -0
  356. package/dist/orgs/org.guard.js +95 -0
  357. package/dist/orgs/orgs.controller.d.ts +78 -0
  358. package/dist/orgs/orgs.controller.js +192 -0
  359. package/dist/orgs/orgs.service.d.ts +61 -0
  360. package/dist/orgs/orgs.service.js +209 -0
  361. package/dist/orgs/roles.d.ts +13 -0
  362. package/dist/orgs/roles.js +58 -0
  363. package/dist/orgs/settings.controller.d.ts +20 -0
  364. package/dist/orgs/settings.controller.js +53 -0
  365. package/dist/orgs/settings.service.d.ts +120 -0
  366. package/dist/orgs/settings.service.js +178 -0
  367. package/dist/packages/npm.d.ts +50 -0
  368. package/dist/packages/npm.js +218 -0
  369. package/dist/packages/provenance.d.ts +47 -0
  370. package/dist/packages/provenance.js +147 -0
  371. package/dist/packages/tgz.d.ts +76 -0
  372. package/dist/packages/tgz.js +225 -0
  373. package/dist/runtime/abort.d.ts +32 -0
  374. package/dist/runtime/abort.js +71 -0
  375. package/dist/runtime/checkpointer.d.ts +32 -0
  376. package/dist/runtime/checkpointer.js +243 -0
  377. package/dist/runtime/context/build.d.ts +254 -0
  378. package/dist/runtime/context/build.js +693 -0
  379. package/dist/runtime/context/claude-tools.d.ts +11 -0
  380. package/dist/runtime/context/claude-tools.js +24 -0
  381. package/dist/runtime/context/compaction.d.ts +26 -0
  382. package/dist/runtime/context/compaction.js +195 -0
  383. package/dist/runtime/context/pairing.d.ts +11 -0
  384. package/dist/runtime/context/pairing.js +82 -0
  385. package/dist/runtime/context/reminders.d.ts +5 -0
  386. package/dist/runtime/context/reminders.js +11 -0
  387. package/dist/runtime/context/skills.d.ts +105 -0
  388. package/dist/runtime/context/skills.js +283 -0
  389. package/dist/runtime/context/tokens.d.ts +19 -0
  390. package/dist/runtime/context/tokens.js +104 -0
  391. package/dist/runtime/conversation-lock.d.ts +40 -0
  392. package/dist/runtime/conversation-lock.js +97 -0
  393. package/dist/runtime/hook-calls.d.ts +84 -0
  394. package/dist/runtime/hook-calls.js +136 -0
  395. package/dist/runtime/langgraph-loop.d.ts +52 -0
  396. package/dist/runtime/langgraph-loop.js +247 -0
  397. package/dist/runtime/loop.d.ts +93 -0
  398. package/dist/runtime/loop.js +7 -0
  399. package/dist/runtime/maintenance.d.ts +80 -0
  400. package/dist/runtime/maintenance.js +148 -0
  401. package/dist/runtime/media-cache.d.ts +21 -0
  402. package/dist/runtime/media-cache.js +51 -0
  403. package/dist/runtime/model-call.d.ts +176 -0
  404. package/dist/runtime/model-call.js +1049 -0
  405. package/dist/runtime/providers.d.ts +86 -0
  406. package/dist/runtime/providers.js +224 -0
  407. package/dist/runtime/quota.d.ts +29 -0
  408. package/dist/runtime/quota.js +70 -0
  409. package/dist/runtime/run-finish.d.ts +45 -0
  410. package/dist/runtime/run-finish.js +69 -0
  411. package/dist/runtime/run-queue.d.ts +121 -0
  412. package/dist/runtime/run-queue.js +493 -0
  413. package/dist/runtime/run-worker.d.ts +138 -0
  414. package/dist/runtime/run-worker.js +806 -0
  415. package/dist/runtime/stream.controller.d.ts +34 -0
  416. package/dist/runtime/stream.controller.js +122 -0
  417. package/dist/runtime/stream.d.ts +63 -0
  418. package/dist/runtime/stream.js +262 -0
  419. package/dist/runtime/subagents/child.d.ts +80 -0
  420. package/dist/runtime/subagents/child.js +225 -0
  421. package/dist/runtime/subagents/definition.d.ts +103 -0
  422. package/dist/runtime/subagents/definition.js +392 -0
  423. package/dist/runtime/subagents/dispatch.d.ts +69 -0
  424. package/dist/runtime/subagents/dispatch.js +502 -0
  425. package/dist/runtime/subagents/limits.d.ts +23 -0
  426. package/dist/runtime/subagents/limits.js +34 -0
  427. package/dist/runtime/subagents/org-agents.d.ts +50 -0
  428. package/dist/runtime/subagents/org-agents.js +70 -0
  429. package/dist/runtime/subagents/preamble.d.ts +7 -0
  430. package/dist/runtime/subagents/preamble.js +11 -0
  431. package/dist/runtime/subagents/progress.d.ts +26 -0
  432. package/dist/runtime/subagents/progress.js +36 -0
  433. package/dist/runtime/subagents/roster.d.ts +55 -0
  434. package/dist/runtime/subagents/roster.js +111 -0
  435. package/dist/runtime/subagents/skill-fork.d.ts +123 -0
  436. package/dist/runtime/subagents/skill-fork.js +259 -0
  437. package/dist/runtime/usage-report.d.ts +163 -0
  438. package/dist/runtime/usage-report.js +551 -0
  439. package/dist/runtime/waits.d.ts +233 -0
  440. package/dist/runtime/waits.js +883 -0
  441. package/dist/sandbox/leases.d.ts +169 -0
  442. package/dist/sandbox/leases.js +515 -0
  443. package/dist/sandbox/lifecycle.d.ts +21 -0
  444. package/dist/sandbox/lifecycle.js +68 -0
  445. package/dist/sandbox/sandbox.service.d.ts +249 -0
  446. package/dist/sandbox/sandbox.service.js +908 -0
  447. package/dist/skills/catalog.d.ts +149 -0
  448. package/dist/skills/catalog.js +405 -0
  449. package/dist/skills/changes.controller.d.ts +56 -0
  450. package/dist/skills/changes.controller.js +136 -0
  451. package/dist/skills/changes.service.d.ts +175 -0
  452. package/dist/skills/changes.service.js +805 -0
  453. package/dist/skills/invocable.controller.d.ts +23 -0
  454. package/dist/skills/invocable.controller.js +50 -0
  455. package/dist/skills/invocation-keys.d.ts +23 -0
  456. package/dist/skills/invocation-keys.js +44 -0
  457. package/dist/skills/invoke.d.ts +135 -0
  458. package/dist/skills/invoke.js +286 -0
  459. package/dist/skills/package.d.ts +87 -0
  460. package/dist/skills/package.js +227 -0
  461. package/dist/skills/skills.controller.d.ts +40 -0
  462. package/dist/skills/skills.controller.js +110 -0
  463. package/dist/skills/skills.service.d.ts +192 -0
  464. package/dist/skills/skills.service.js +567 -0
  465. package/dist/storage/prefix.d.ts +36 -0
  466. package/dist/storage/prefix.js +104 -0
  467. package/dist/storage/purge.d.ts +27 -0
  468. package/dist/storage/purge.js +75 -0
  469. package/dist/storage/storage.service.d.ts +44 -0
  470. package/dist/storage/storage.service.js +145 -0
  471. package/dist/text.d.ts +13 -0
  472. package/dist/text.js +13 -0
  473. package/dist/tools/approvals.controller.d.ts +53 -0
  474. package/dist/tools/approvals.controller.js +128 -0
  475. package/dist/tools/approvals.service.d.ts +172 -0
  476. package/dist/tools/approvals.service.js +568 -0
  477. package/dist/tools/breaker.d.ts +28 -0
  478. package/dist/tools/breaker.js +72 -0
  479. package/dist/tools/builtins/agent.d.ts +81 -0
  480. package/dist/tools/builtins/agent.js +223 -0
  481. package/dist/tools/builtins/ask-user.d.ts +28 -0
  482. package/dist/tools/builtins/ask-user.js +139 -0
  483. package/dist/tools/builtins/read-tool-output.d.ts +18 -0
  484. package/dist/tools/builtins/read-tool-output.js +108 -0
  485. package/dist/tools/builtins/sandbox/bash.d.ts +16 -0
  486. package/dist/tools/builtins/sandbox/bash.js +137 -0
  487. package/dist/tools/builtins/sandbox/common.d.ts +116 -0
  488. package/dist/tools/builtins/sandbox/common.js +306 -0
  489. package/dist/tools/builtins/sandbox/deliver.d.ts +5 -0
  490. package/dist/tools/builtins/sandbox/deliver.js +180 -0
  491. package/dist/tools/builtins/sandbox/edit.d.ts +4 -0
  492. package/dist/tools/builtins/sandbox/edit.js +98 -0
  493. package/dist/tools/builtins/sandbox/glob-match.d.ts +25 -0
  494. package/dist/tools/builtins/sandbox/glob-match.js +240 -0
  495. package/dist/tools/builtins/sandbox/glob.d.ts +4 -0
  496. package/dist/tools/builtins/sandbox/glob.js +104 -0
  497. package/dist/tools/builtins/sandbox/grep.d.ts +9 -0
  498. package/dist/tools/builtins/sandbox/grep.js +133 -0
  499. package/dist/tools/builtins/sandbox/index.d.ts +12 -0
  500. package/dist/tools/builtins/sandbox/index.js +27 -0
  501. package/dist/tools/builtins/sandbox/names.d.ts +7 -0
  502. package/dist/tools/builtins/sandbox/names.js +20 -0
  503. package/dist/tools/builtins/sandbox/read.d.ts +8 -0
  504. package/dist/tools/builtins/sandbox/read.js +121 -0
  505. package/dist/tools/builtins/sandbox/write.d.ts +4 -0
  506. package/dist/tools/builtins/sandbox/write.js +88 -0
  507. package/dist/tools/builtins/skill-load.d.ts +53 -0
  508. package/dist/tools/builtins/skill-load.js +446 -0
  509. package/dist/tools/builtins/skill-write.d.ts +59 -0
  510. package/dist/tools/builtins/skill-write.js +244 -0
  511. package/dist/tools/builtins/tool-search.d.ts +31 -0
  512. package/dist/tools/builtins/tool-search.js +171 -0
  513. package/dist/tools/connector-content.controller.d.ts +34 -0
  514. package/dist/tools/connector-content.controller.js +78 -0
  515. package/dist/tools/connector-content.d.ts +104 -0
  516. package/dist/tools/connector-content.js +267 -0
  517. package/dist/tools/connectors.controller.d.ts +210 -0
  518. package/dist/tools/connectors.controller.js +234 -0
  519. package/dist/tools/connectors.service.d.ts +303 -0
  520. package/dist/tools/connectors.service.js +1102 -0
  521. package/dist/tools/credentials.d.ts +139 -0
  522. package/dist/tools/credentials.js +351 -0
  523. package/dist/tools/drift.d.ts +141 -0
  524. package/dist/tools/drift.js +539 -0
  525. package/dist/tools/elicitation.d.ts +81 -0
  526. package/dist/tools/elicitation.js +266 -0
  527. package/dist/tools/endpoint.d.ts +18 -0
  528. package/dist/tools/endpoint.js +115 -0
  529. package/dist/tools/info.d.ts +67 -0
  530. package/dist/tools/info.js +113 -0
  531. package/dist/tools/naming.d.ts +27 -0
  532. package/dist/tools/naming.js +47 -0
  533. package/dist/tools/oauth/discovery.d.ts +65 -0
  534. package/dist/tools/oauth/discovery.js +307 -0
  535. package/dist/tools/oauth/flow.d.ts +63 -0
  536. package/dist/tools/oauth/flow.js +237 -0
  537. package/dist/tools/oauth/oauth.controller.d.ts +31 -0
  538. package/dist/tools/oauth/oauth.controller.js +95 -0
  539. package/dist/tools/oauth/tokens.d.ts +111 -0
  540. package/dist/tools/oauth/tokens.js +258 -0
  541. package/dist/tools/outputs.d.ts +61 -0
  542. package/dist/tools/outputs.js +156 -0
  543. package/dist/tools/pipeline.d.ts +322 -0
  544. package/dist/tools/pipeline.js +1236 -0
  545. package/dist/tools/policy.d.ts +60 -0
  546. package/dist/tools/policy.js +236 -0
  547. package/dist/tools/questions.controller.d.ts +24 -0
  548. package/dist/tools/questions.controller.js +58 -0
  549. package/dist/tools/questions.service.d.ts +103 -0
  550. package/dist/tools/questions.service.js +295 -0
  551. package/dist/tools/redact.d.ts +20 -0
  552. package/dist/tools/redact.js +60 -0
  553. package/dist/tools/registry.d.ts +246 -0
  554. package/dist/tools/registry.js +481 -0
  555. package/dist/tools/resources.d.ts +16 -0
  556. package/dist/tools/resources.js +76 -0
  557. package/dist/tools/specs.d.ts +14 -0
  558. package/dist/tools/specs.js +31 -0
  559. package/dist/tools/validate.d.ts +20 -0
  560. package/dist/tools/validate.js +183 -0
  561. package/dist/tools/view.d.ts +43 -0
  562. package/dist/tools/view.js +225 -0
  563. package/dist/ui/embed-token.d.ts +31 -0
  564. package/dist/ui/embed-token.js +132 -0
  565. package/dist/ui/registry.d.ts +58 -0
  566. package/dist/ui/registry.js +90 -0
  567. package/dist/ui/ui-stream.d.ts +37 -0
  568. package/dist/ui/ui-stream.js +162 -0
  569. package/dist/ui/views.controller.d.ts +81 -0
  570. package/dist/ui/views.controller.js +261 -0
  571. package/dist/ui/views.d.ts +155 -0
  572. package/dist/ui/views.js +306 -0
  573. package/dist/version.d.ts +5 -0
  574. package/dist/version.js +6 -0
  575. package/package.json +69 -3
  576. package/src/migrations/0001_init.sql +8 -0
  577. package/src/migrations/0002_secrets.sql +8 -0
  578. package/src/migrations/0003_identity.sql +117 -0
  579. package/src/migrations/0004_plugin_org_config_nullable.sql +3 -0
  580. package/src/migrations/0005_agents.sql +27 -0
  581. package/src/migrations/0006_conversations.sql +37 -0
  582. package/src/migrations/0007_checkpoints.sql +26 -0
  583. package/src/migrations/0008_runs_trigger_seq.sql +3 -0
  584. package/src/migrations/0009_runs_active_unique.sql +4 -0
  585. package/src/migrations/0010_tools.sql +125 -0
  586. package/src/migrations/0011_approvals_spec.sql +10 -0
  587. package/src/migrations/0012_run_waits.sql +24 -0
  588. package/src/migrations/0013_app_tools_source.sql +4 -0
  589. package/src/migrations/0014_tool_specs.sql +8 -0
  590. package/src/migrations/0015_tool_drift.sql +20 -0
  591. package/src/migrations/0016_plugin_permissions.sql +11 -0
  592. package/src/migrations/0017_identity_sources.sql +6 -0
  593. package/src/migrations/0018_channels.sql +74 -0
  594. package/src/migrations/0019_identity_trust.sql +17 -0
  595. package/src/migrations/0020_channel_card_lookup.sql +10 -0
  596. package/src/migrations/0021_org_storage_purge.sql +9 -0
  597. package/src/migrations/0022_attachments.sql +29 -0
  598. package/src/migrations/0023_sandboxes.sql +37 -0
  599. package/src/migrations/0024_skills.sql +46 -0
  600. package/src/migrations/0025_skills_catalog_idx.sql +6 -0
  601. package/src/migrations/0026_skill_changes.sql +34 -0
  602. package/src/migrations/0027_model_prices.sql +18 -0
  603. package/src/migrations/0028_evals.sql +105 -0
  604. package/src/migrations/0029_model_purposes.sql +18 -0
  605. package/src/migrations/0030_plugin_installs.sql +73 -0
  606. package/src/migrations/0031_plugin_snapshot_source.sql +6 -0
  607. package/src/migrations/0032_plugin_deployment_configs.sql +10 -0
  608. package/src/migrations/0033_rename_apps_to_connectors.sql +25 -0
  609. package/src/migrations/0034_directory.sql +49 -0
  610. package/src/migrations/0035_catalogs.sql +40 -0
  611. package/src/migrations/0036_app_import_staging.sql +17 -0
  612. package/src/migrations/0037_directory_installs.sql +92 -0
  613. package/src/migrations/0038_channel_inbound_mode.sql +6 -0
  614. package/src/migrations/0039_channel_card_pending.sql +8 -0
  615. package/src/migrations/0040_usage_report_sweep.sql +10 -0
  616. package/src/migrations/0041_rename_plugins_to_extensions.sql +38 -0
  617. package/src/migrations/0042_rename_directory_to_catalog.sql +80 -0
  618. package/src/migrations/0043_rename_app_installs_to_plugin_installs.sql +20 -0
  619. package/src/migrations/0044_catalog_one_kind.sql +90 -0
  620. package/src/migrations/0045_plugin_dependencies.sql +9 -0
  621. package/src/migrations/0046_git_sources.sql +25 -0
  622. package/src/migrations/0047_marketplace_entry_heads.sql +7 -0
  623. package/src/migrations/0048_marketplace_entry_trees.sql +8 -0
  624. package/src/migrations/0049_plugin_upgrades.sql +37 -0
  625. package/src/migrations/0050_bootstrap.sql +53 -0
  626. package/src/migrations/0051_claude_compat.sql +26 -0
  627. package/src/migrations/0052_conversations_account_agent_idx.sql +5 -0
  628. package/src/migrations/0053_subagents.sql +73 -0
  629. package/src/migrations/0054_subagent_wait_expiry.sql +7 -0
  630. package/src/migrations/0055_subagent_parent_indexes.sql +10 -0
  631. package/src/migrations/0056_approval_reason.sql +3 -0
  632. package/src/migrations/0057_conversation_titles.sql +11 -0
  633. package/src/migrations/0058_conversation_selection.sql +4 -0
  634. package/src/migrations/0059_conversation_queue.sql +22 -0
  635. package/src/migrations/0060_file_previewers.sql +10 -0
  636. package/src/migrations/0061_queue_selection.sql +5 -0
  637. package/src/migrations/0062_queued_skill.sql +8 -0
@@ -0,0 +1,1122 @@
1
+ import type { SkillInvocation } from "@capybara-hq/plugin-sdk";
2
+ import type { ColumnType, Generated, Kysely } from "kysely";
3
+ /** 带默认值的时间戳列:插入可省略,读出为 Date。 */
4
+ type Ts = ColumnType<Date, Date | string | undefined, Date | string>;
5
+ type TsNullable = ColumnType<Date | null, Date | string | null | undefined, Date | string | null>;
6
+ /** jsonb 列:写入时传 JSON 字符串,读出为已解析对象。 */
7
+ type Json<T = Record<string, unknown>> = ColumnType<T, string | undefined, string>;
8
+ export interface AccountsTable {
9
+ id: string;
10
+ display_name: string;
11
+ email: string | null;
12
+ email_verified: Generated<boolean>;
13
+ status: Generated<"active" | "disabled">;
14
+ is_enterprise_admin: Generated<boolean>;
15
+ created_at: Ts;
16
+ updated_at: Ts;
17
+ }
18
+ export interface IdentitiesTable {
19
+ source: string;
20
+ external_id: string;
21
+ account_id: string;
22
+ email: string | null;
23
+ email_verified: Generated<boolean>;
24
+ profile: Json;
25
+ created_at: Ts;
26
+ /** 0019:身份行如何建立(Ruling A18);null 为旧行,按 `sso` 处理。 */
27
+ linked_via: ColumnType<LinkedVia | null, LinkedVia | null | undefined, LinkedVia | null>;
28
+ }
29
+ /** 身份行的建立方式:IM 绑定链接、第三方登录、通讯录同步、本地登录名。 */
30
+ export type LinkedVia = "bind" | "sso" | "directory" | "local";
31
+ export interface LocalPasswordsTable {
32
+ account_id: string;
33
+ password_hash: string;
34
+ updated_at: Ts;
35
+ }
36
+ export interface OrgsTable {
37
+ id: string;
38
+ slug: string;
39
+ name: string;
40
+ created_by: string | null;
41
+ /** 0010:组织级设置(插入可省略,用列默认值 `{}`;写入传 JSON 字符串)。 */
42
+ settings: Json;
43
+ created_at: Ts;
44
+ deleted_at: TsNullable;
45
+ /** 0021:已删除组织的对象存储清理完成时间(storage/purge.ts);插入可省略。 */
46
+ storage_purged_at: TsNullable;
47
+ /** 0021:清理任务的认领时间(认领超时后可重新认领);插入可省略。 */
48
+ storage_purge_claimed_at: TsNullable;
49
+ }
50
+ export interface MembershipsTable {
51
+ org_id: string;
52
+ account_id: string;
53
+ role: "owner" | "admin" | "member" | "guest";
54
+ created_at: Ts;
55
+ updated_at: Ts;
56
+ /** 0017:成员关系来源;null = 手动 / 邀请,`"directory:<插件名>"` = 通讯录同步加入。 */
57
+ source: ColumnType<string | null, string | null | undefined, string | null>;
58
+ }
59
+ export interface InvitationsTable {
60
+ id: string;
61
+ org_id: string;
62
+ role: "admin" | "member" | "guest";
63
+ token_hash: string;
64
+ created_by: string;
65
+ created_at: Ts;
66
+ expires_at: ColumnType<Date, Date | string, Date | string>;
67
+ accepted_at: TsNullable;
68
+ accepted_by: string | null;
69
+ revoked_at: TsNullable;
70
+ }
71
+ export interface SessionsTable {
72
+ id: string;
73
+ account_id: string;
74
+ current_org_id: string | null;
75
+ refresh_hash: string;
76
+ prev_refresh_hash: string | null;
77
+ rotated_at: TsNullable;
78
+ user_agent: string | null;
79
+ ip: string | null;
80
+ created_at: Ts;
81
+ last_used_at: Ts;
82
+ expires_at: ColumnType<Date, Date | string, Date | string>;
83
+ revoked_at: TsNullable;
84
+ }
85
+ export interface ApiTokensTable {
86
+ id: string;
87
+ kind: "personal" | "service";
88
+ account_id: string | null;
89
+ org_id: string | null;
90
+ role: "admin" | "member" | "guest" | null;
91
+ name: string;
92
+ token_hash: string;
93
+ created_by: string;
94
+ created_at: Ts;
95
+ last_used_at: TsNullable;
96
+ expires_at: TsNullable;
97
+ revoked_at: TsNullable;
98
+ }
99
+ export interface DeploymentSettingsTable {
100
+ key: string;
101
+ value: ColumnType<unknown, string, string>;
102
+ updated_by: string | null;
103
+ updated_at: Ts;
104
+ }
105
+ export interface ExtensionOrgConfigsTable {
106
+ plugin: string;
107
+ org_id: string;
108
+ enabled: Generated<boolean>;
109
+ /** null when there is no config. */
110
+ config: ColumnType<Record<string, unknown> | null, string | null | undefined, string | null>;
111
+ updated_by: string | null;
112
+ updated_at: Ts;
113
+ }
114
+ export interface AuditEventsTable {
115
+ id: Generated<string>;
116
+ at: Ts;
117
+ actor_account_id: string | null;
118
+ actor_token_id: string | null;
119
+ org_id: string | null;
120
+ action: string;
121
+ target: string | null;
122
+ detail: Json;
123
+ }
124
+ /** 0016, renamed in 0041: the approved permission snapshot of an extension. */
125
+ export interface ExtensionPermissionSnapshotsTable {
126
+ plugin: string;
127
+ version: string;
128
+ /** The normalized permission set (see extensions/permission-set.ts). */
129
+ permissions: Json<unknown>;
130
+ approved_by: string | null;
131
+ approved_at: Ts;
132
+ /** `bootstrap` (0050): approved by the bootstrap step (core's release vouched for it). */
133
+ source: "cli" | "auto" | "web" | "bootstrap";
134
+ }
135
+ /** 0002_secrets.sql:加密值(读写走 `createSecrets`,这里只供按键查询是否存在)。 */
136
+ export interface SecretsTable {
137
+ namespace: string;
138
+ org_id: string;
139
+ key: string;
140
+ ciphertext: Buffer;
141
+ updated_at: Ts;
142
+ }
143
+ /** 0005_agents.sql:agent 当前元数据(定义在 agent_versions)。 */
144
+ export interface AgentsTable {
145
+ id: string;
146
+ org_id: string;
147
+ owner_account_id: string;
148
+ visibility: "private" | "org" | "members";
149
+ org_role: Generated<"admin" | "member" | "guest">;
150
+ current_version: number;
151
+ needs_reassignment: Generated<boolean>;
152
+ created_at: Ts;
153
+ updated_at: Ts;
154
+ deleted_at: TsNullable;
155
+ }
156
+ /** 0005_agents.sql:agent 定义的版本,只追加。 */
157
+ export interface AgentVersionsTable {
158
+ agent_id: string;
159
+ version: number;
160
+ definition: Json;
161
+ created_by: string;
162
+ created_at: Ts;
163
+ }
164
+ /** 0005_agents.sql:visibility='members' 的 agent 名单。 */
165
+ export interface AgentMembersTable {
166
+ agent_id: string;
167
+ account_id: string;
168
+ }
169
+ /** PG bigint:pg 驱动读出为字符串,读取方自行 `Number()`。 */
170
+ type Int8 = ColumnType<string, number | string | undefined, number | string>;
171
+ /** 0006_conversations.sql:会话;`last_seq` 为已分配的最大事件序号。 */
172
+ export interface ConversationsTable {
173
+ id: string;
174
+ org_id: string;
175
+ agent_id: string;
176
+ account_id: string;
177
+ title: string | null;
178
+ last_seq: Int8;
179
+ consumed_seq: Int8;
180
+ created_at: Ts;
181
+ updated_at: Ts;
182
+ /** 0028:chat(普通对话)/ eval(整轮回放的隐藏对话)。 */
183
+ kind: ColumnType<ConversationKind, ConversationKind | undefined, ConversationKind>;
184
+ /** 0028:eval 对话所属的评测运行。 */
185
+ eval_run_id: ColumnType<string | null, string | null | undefined, string | null>;
186
+ /** 0053: a sub-agent's parent conversation (kind 'subagent' only). */
187
+ parent_conversation_id: ColumnType<string | null, string | null | undefined, string | null>;
188
+ /** 0053: the sub-agent type as resolved at the first dispatch (kind 'subagent' only). */
189
+ subagent_type: ColumnType<string | null, string | null | undefined, string | null>;
190
+ /** 0057: who wrote `title` (null = nobody yet). */
191
+ title_source: ColumnType<TitleSource | null, TitleSource | null | undefined, TitleSource | null>;
192
+ /** 0057: title-generation attempts made. */
193
+ title_attempts: ColumnType<number, number | undefined, number>;
194
+ /** 0057: the first message's clientMessageId (idempotent create on first send). */
195
+ create_request_id: ColumnType<string | null, string | null | undefined, string | null>;
196
+ /** 0058: the switched model / effort (`Selection`); null = never switched. */
197
+ selection: ColumnType<unknown | null, string | null | undefined, string | null>;
198
+ /** 0059: a run failed or was stopped with messages queued; the queue waits for resume. */
199
+ queue_paused: ColumnType<boolean, boolean | undefined, boolean>;
200
+ /** 0062: why the queue paused (`QueuePauseReason`); null when not paused or not recorded. */
201
+ queue_pause_reason: ColumnType<string | null, string | null | undefined, string | null>;
202
+ }
203
+ /** 0060: an org's order of file-preview@1 previewers (UI refresh B Task 11). */
204
+ export interface FilePreviewersTable {
205
+ org_id: string;
206
+ plugin: string;
207
+ previewer_id: string;
208
+ position: number;
209
+ disabled: ColumnType<boolean, boolean | undefined, boolean>;
210
+ }
211
+ /** 0059: a queued message (not in the event log until sent). */
212
+ export interface ConversationQueueTable {
213
+ id: string;
214
+ conversation_id: string;
215
+ account_id: string;
216
+ position: Int8;
217
+ text: string;
218
+ /** The content blocks after the text (`@` resources, uploaded file refs). */
219
+ content: Json<unknown>;
220
+ /** `@` resource metadata for `user_message.payload.attachments`. */
221
+ attachments: ColumnType<unknown, string | undefined, string>;
222
+ /** Uploaded files' display metadata `{ attachmentId, name, mediaType }[]`. */
223
+ files: ColumnType<unknown, string | undefined, string>;
224
+ client_message_id: string;
225
+ /** The model the message picks (`{ provider, model }`), or null (0061). */
226
+ model: ColumnType<unknown, string | null | undefined, string | null>;
227
+ /** The effort the message picks, or null (0061). */
228
+ effort: ColumnType<string | null, string | null | undefined, string | null>;
229
+ /** 0062: the `user_message.skill` record of a queued skill invocation, or null. */
230
+ skill: ColumnType<unknown, string | null | undefined, string | null>;
231
+ created_at: Ts;
232
+ updated_at: Ts;
233
+ }
234
+ export type TitleSource = "generated" | "manual";
235
+ /** chat; eval (a hidden full-run replay conversation); subagent (0053: a sub-agent's conversation). */
236
+ export type ConversationKind = "chat" | "eval" | "subagent";
237
+ /** 0006_conversations.sql:会话事件日志,只追加。 */
238
+ export interface ConversationEventsTable {
239
+ conversation_id: string;
240
+ seq: Int8;
241
+ type: string;
242
+ run_id: string | null;
243
+ idem_key: string | null;
244
+ payload: Json<unknown>;
245
+ created_at: Ts;
246
+ }
247
+ /** 0006_conversations.sql:一次 agent 运行。 */
248
+ export interface RunsTable {
249
+ id: string;
250
+ conversation_id: string;
251
+ status: "queued" | "running" | "waiting" | "completed" | "failed" | "aborted";
252
+ agent_version: number;
253
+ trigger_account_id: string;
254
+ /** 0008:创建运行时最新 user_message 的 seq(终态时 consumed_seq 至少推进到它)。 */
255
+ trigger_seq: Int8;
256
+ created_at: Ts;
257
+ started_at: TsNullable;
258
+ finished_at: TsNullable;
259
+ /** 0012:进入 waiting 的时刻(续跑时清空)。 */
260
+ waiting_since: TsNullable;
261
+ /** 0012:累计等待时长(毫秒),不计入运行时长。 */
262
+ waited_ms: Int8;
263
+ /** 0012:续跑任务的 jobId;为空表示按触发消息生成的 jobId。 */
264
+ job_id: string | null;
265
+ /** 0012:最近一次(续跑)回到 queued 的时刻。 */
266
+ queued_at: TsNullable;
267
+ /** 0053: tokens used by this run's sub-agents (the parent run's budget counter). */
268
+ subagent_tokens_used: Int8;
269
+ /** 0054: when this run's `subagents` wait expires (set while it waits on sub-agents). */
270
+ wait_expires_at: TsNullable;
271
+ }
272
+ /** 0053: one row per sub-agent dispatch (an `agent` call of a parent run). */
273
+ export interface SubagentDispatchesTable {
274
+ parent_run_id: string;
275
+ parent_call_id: string;
276
+ parent_conversation_id: string;
277
+ step: number;
278
+ child_conversation_id: string;
279
+ child_run_id: string;
280
+ /** A follow-up to an existing sub-agent, not a new one. */
281
+ resumed: ColumnType<boolean, boolean | undefined, boolean>;
282
+ created_at: Ts;
283
+ }
284
+ /** 0053: an agent template installed in an org from a plugin. */
285
+ export interface AgentTemplatesTable {
286
+ id: string;
287
+ org_id: string;
288
+ name: string;
289
+ catalog_item_id: ColumnType<string | null, string | null | undefined, string | null>;
290
+ /** The plugin that installed it (`NOT NULL`, 0053): the roster type is `<plugin>:<name>`. */
291
+ plugin_name: string;
292
+ current_version: number;
293
+ deleted_at: TsNullable;
294
+ created_at: Ts;
295
+ updated_at: Ts;
296
+ }
297
+ /** 0053: one version of an agent template; `definition` is the parsed frontmatter and body. */
298
+ export interface AgentTemplateVersionsTable {
299
+ template_id: string;
300
+ version: number;
301
+ definition: Json<unknown>;
302
+ source_format: ColumnType<SourceFormat, SourceFormat | undefined, SourceFormat>;
303
+ catalog_version: ColumnType<string | null, string | null | undefined, string | null>;
304
+ created_at: Ts;
305
+ }
306
+ /**
307
+ * 0010_tools.sql(0033 由 `apps` 改名):已安装的连接器(远端服务实例)。列 `connector` 是连接器插件的 kind,
308
+ * 改名后叫 `connectors.connector` 有点别扭,但为避免多一次 RENAME 保持原名。
309
+ */
310
+ export interface ConnectorsTable {
311
+ id: string;
312
+ org_id: string;
313
+ slug: string;
314
+ name: string;
315
+ /** 连接器 kind(`Connector.kind`,如 `mcp`),由 `ToolRegistry.connector(kind)` 查找实现。 */
316
+ connector: string;
317
+ /** jsonb 带默认值:Json 的插入类型本身已可省略,不再包 Generated(嵌套会让插入类型失配)。 */
318
+ endpoint: Json<unknown>;
319
+ /** `{type, ownership: "org" | "personal", ...非密钥字段}`;凭据在 secrets。 */
320
+ auth: Json<unknown>;
321
+ status: Generated<"active" | "disabled">;
322
+ created_by: string;
323
+ created_at: Ts;
324
+ updated_at: Ts;
325
+ deleted_at: TsNullable;
326
+ /** 0015:最近一次成功拿到工具清单的时间;为空 = 从未拍过快照(首个快照按安装处理)。 */
327
+ tools_synced_at: TsNullable;
328
+ /**
329
+ * 0037, renamed in 0042: the source item (an app's template records the app item) and version
330
+ * when installed from a catalog template.
331
+ */
332
+ catalog_item_id: ColumnType<string | null, string | null | undefined, string | null>;
333
+ catalog_version: ColumnType<string | null, string | null | undefined, string | null>;
334
+ /** 0037:模板的 defaultToolPolicies(授权码连接器在首个快照时应用)。 */
335
+ template_tool_policies: ColumnType<Record<string, "allow" | "ask" | "deny"> | null, string | null | undefined, string | null>;
336
+ }
337
+ /** 0010_tools.sql(0033 由 `app_tools` 改名):连接器暴露的工具。 */
338
+ export interface ConnectorToolsTable {
339
+ connector_id: string;
340
+ name: string;
341
+ spec: Json<unknown>;
342
+ spec_hash: string;
343
+ status: "enabled" | "disabled" | "pending_review";
344
+ default_policy: "allow" | "ask" | "deny";
345
+ reviewed_at: TsNullable;
346
+ /** 0013:工具来源(`resources` = 内核为支持 resources 的连接器补上的两个工具)。 */
347
+ source: Generated<"connector" | "resources">;
348
+ /** 0015:变化后待复核的新定义(复核前 spec / spec_hash / source 仍是旧的)。 */
349
+ pending_spec: ColumnType<unknown, string | null | undefined, string | null>;
350
+ pending_spec_hash: string | null;
351
+ pending_source: "connector" | "resources" | null;
352
+ /** 0015:默认策略的来历(admin = 管理员设定,复核通过后保留;derived = 按注解重新推导)。 */
353
+ policy_source: Generated<"derived" | "admin" | "template">;
354
+ /** 0015:远端不再提供该工具的时间(工具停用,行保留)。 */
355
+ missing_since: TsNullable;
356
+ }
357
+ /** 0010_tools.sql:「以后都允许」。 */
358
+ export interface ToolGrantsTable {
359
+ org_id: string;
360
+ account_id: string;
361
+ agent_id: string;
362
+ tool_key: string;
363
+ spec_hash: string;
364
+ /** 连接器工具的来源连接器(插件 / 内置工具为 null;0033 由 `app_id` 改名);授权只对同一个连接器有效。 */
365
+ connector_id: string | null;
366
+ created_at: Ts;
367
+ }
368
+ /** 0010_tools.sql:「本会话都允许」。 */
369
+ export interface ConversationToolGrantsTable {
370
+ conversation_id: string;
371
+ tool_key: string;
372
+ spec_hash: string;
373
+ /** 同 `ToolGrantsTable.connector_id`。 */
374
+ connector_id: string | null;
375
+ }
376
+ /** 0010_tools.sql:工具调用审批;requested_for 与 approver_role 至少一个非空。 */
377
+ export interface ApprovalsTable {
378
+ id: string;
379
+ org_id: string;
380
+ conversation_id: string;
381
+ run_id: string;
382
+ call_id: string;
383
+ tool_key: string;
384
+ /** jsonb 带默认值:Json 的插入类型本身已可省略。 */
385
+ input: Json<unknown>;
386
+ requested_for: string | null;
387
+ approver_role: string | null;
388
+ status: Generated<"pending" | "approved" | "denied" | "expired" | "cancelled">;
389
+ scope: "once" | "session" | "always" | null;
390
+ decided_by: string | null;
391
+ decided_at: TsNullable;
392
+ expires_at: Date | string;
393
+ created_at: Ts;
394
+ /** 0011:所批准的工具定义指纹(写授权用)。 */
395
+ spec_hash: string;
396
+ /** 0011:连接器工具的来源连接器(0033 由 `app_id` 改名)。 */
397
+ connector_id: string | null;
398
+ /** 0012:同一调用的第几次审批(从 1 起;工具定义变化后重新审批时递增)。 */
399
+ attempt: Generated<number>;
400
+ /** 0056: the reason given with a denial (null without one). */
401
+ deny_reason: Generated<string | null>;
402
+ }
403
+ /** 0010_tools.sql:ask_user 提问。 */
404
+ export interface QuestionsTable {
405
+ id: string;
406
+ org_id: string;
407
+ conversation_id: string;
408
+ run_id: string;
409
+ call_id: string;
410
+ spec: Json<unknown>;
411
+ status: Generated<"pending" | "answered" | "expired" | "cancelled">;
412
+ answer: ColumnType<unknown, string | null | undefined, string | null>;
413
+ answered_by: string | null;
414
+ answered_at: TsNullable;
415
+ expires_at: Date | string;
416
+ created_at: Ts;
417
+ /** 0012:同一调用的第几轮输入请求(从 1 起)。 */
418
+ attempt: Generated<number>;
419
+ }
420
+ /** 0010_tools.sql:超大工具输出的存档。 */
421
+ export interface ToolOutputsTable {
422
+ id: string;
423
+ org_id: string;
424
+ conversation_id: string;
425
+ call_id: string;
426
+ size_chars: number;
427
+ line_count: number;
428
+ content: string;
429
+ created_at: Ts;
430
+ expires_at: Date | string;
431
+ }
432
+ /** 0014_tool_specs.sql:工具定义快照(内容寻址,只增不改)。 */
433
+ export interface ToolSpecsTable {
434
+ spec_hash: string;
435
+ spec: Json<unknown>;
436
+ created_at: Ts;
437
+ }
438
+ /** bytea 列:读出为 Buffer,写入可传 Buffer / Uint8Array。 */
439
+ type Bytea = ColumnType<Buffer, Buffer | Uint8Array, Buffer | Uint8Array>;
440
+ /** 0007_checkpoints.sql:LangGraph checkpoint(KyselyCheckpointSaver)。 */
441
+ export interface LgCheckpointsTable {
442
+ thread_id: string;
443
+ checkpoint_ns: Generated<string>;
444
+ checkpoint_id: string;
445
+ parent_checkpoint_id: string | null;
446
+ checkpoint_type: string;
447
+ checkpoint: Bytea;
448
+ metadata_type: string;
449
+ metadata: Bytea;
450
+ created_at: Ts;
451
+ }
452
+ /** 0007_checkpoints.sql:checkpoint 的 pending writes。 */
453
+ export interface LgCheckpointWritesTable {
454
+ thread_id: string;
455
+ checkpoint_ns: Generated<string>;
456
+ checkpoint_id: string;
457
+ task_id: string;
458
+ idx: number;
459
+ channel: string;
460
+ value_type: string;
461
+ value: Bytea;
462
+ task_path: Generated<string>;
463
+ }
464
+ /** 0018_channels.sql:组织的渠道连接(非密钥配置;密钥在 secrets `channels:<id>:config`)。 */
465
+ export interface ChannelConnectionsTable {
466
+ id: string;
467
+ org_id: string;
468
+ plugin: string;
469
+ name: string;
470
+ agent_id: string;
471
+ config: Json;
472
+ unbound_policy: Generated<"bind" | "anonymous">;
473
+ status: Generated<"active" | "disabled" | "error">;
474
+ /** 0038_channel_inbound_mode.sql: how inbound events arrive (long connection by default). */
475
+ inbound_mode: Generated<"long_connection" | "webhook">;
476
+ last_error: string | null;
477
+ bot_user_id: string | null;
478
+ tenant_id: string | null;
479
+ created_by: string;
480
+ created_at: Ts;
481
+ updated_at: Ts;
482
+ deleted_at: TsNullable;
483
+ }
484
+ /** 0018_channels.sql:IM 话题 ↔ 会话(未归档的行在 (连接, chat, thread_key, 账号) 上唯一)。 */
485
+ export interface ChannelThreadsTable {
486
+ id: string;
487
+ connection_id: string;
488
+ chat_id: string;
489
+ thread_key: string;
490
+ account_id: string | null;
491
+ conversation_id: string;
492
+ created_at: Ts;
493
+ archived_at: TsNullable;
494
+ }
495
+ /** 0018_channels.sql:会话的 IM 投递目标与已投递到的事件序号(Task 11)。 */
496
+ export interface ChannelDeliveriesTable {
497
+ conversation_id: string;
498
+ connection_id: string;
499
+ target: Json<unknown>;
500
+ last_seq: Int8;
501
+ draft_message_id: string | null;
502
+ fail_seq: ColumnType<string | null, number | string | null | undefined, number | string | null>;
503
+ fail_count: Generated<number>;
504
+ updated_at: Ts;
505
+ }
506
+ /** 0018_channels.sql:出站投递发出的审批 / 提问卡片对应的 IM 消息(Task 11,用于更新卡片状态)。 */
507
+ export interface ChannelCardMessagesTable {
508
+ conversation_id: string;
509
+ connection_id: string;
510
+ card_kind: "approval" | "question";
511
+ card_id: string;
512
+ /** 0039: null while the row is `pending` (recorded before the send returned). */
513
+ message_id: string | null;
514
+ /** 0039: `pending` = recorded before sending; `sent` = message_id is known. */
515
+ status: Generated<"pending" | "sent">;
516
+ target: Json<unknown>;
517
+ created_at: Ts;
518
+ }
519
+ /** 0018_channels.sql:每个组织一个的匿名访客账号。 */
520
+ export interface OrgAnonymousAccountsTable {
521
+ org_id: string;
522
+ account_id: string;
523
+ created_at: Ts;
524
+ }
525
+ /** 0019:通讯录排除(Ruling A20)——手动移出 / 离开的通讯录成员,同步不再加回。 */
526
+ export interface DirectoryExclusionsTable {
527
+ org_id: string;
528
+ account_id: string;
529
+ plugin: string;
530
+ created_at: Ts;
531
+ created_by: string | null;
532
+ }
533
+ /** 0022_attachments.sql:对话附件(字节在对象存储,见 conversations/attachments.service.ts)。 */
534
+ export interface AttachmentsTable {
535
+ id: string;
536
+ org_id: string;
537
+ conversation_id: string | null;
538
+ account_id: string;
539
+ name: string;
540
+ content_type: string;
541
+ size: Int8;
542
+ object_key: string;
543
+ status: "pending" | "ready" | "deleting";
544
+ etag: string | null;
545
+ pages: number | null;
546
+ created_at: Ts;
547
+ expires_at: TsNullable;
548
+ /** 0024:上传用途(技能包不能绑定到消息)。 */
549
+ purpose: ColumnType<AttachmentPurpose, AttachmentPurpose | undefined, AttachmentPurpose>;
550
+ }
551
+ /** 预签名上传的用途:对话附件 / 技能包 zip。 */
552
+ export type AttachmentPurpose = "chat" | "skill-package";
553
+ /** 技能版本的清单(`skill_versions.manifest`)。 */
554
+ export interface SkillManifest {
555
+ name: string;
556
+ description: string;
557
+ files: {
558
+ path: string;
559
+ size: number;
560
+ sha256: string;
561
+ }[];
562
+ /**
563
+ * Phase D: how the version can be invoked, read from its SKILL.md when it was written. Absent
564
+ * means `{ model: true, user: true }` (every version written before phase D, and ordinary skills,
565
+ * whose manifest is unchanged). No backfill (decided 2026-10-27).
566
+ */
567
+ invocation?: SkillInvocation;
568
+ }
569
+ /** 0024_skills.sql:技能(组织技能库 / agent 自己的技能)。 */
570
+ export interface SkillsTable {
571
+ id: string;
572
+ org_id: string;
573
+ scope: "org" | "agent";
574
+ agent_id: string | null;
575
+ name: string;
576
+ description: string;
577
+ current_version: number;
578
+ created_by: string;
579
+ created_at: Ts;
580
+ updated_at: Ts;
581
+ deleted_at: TsNullable;
582
+ /**
583
+ * 0037, renamed in 0042: the source item (an app's skill records the app item) and version when
584
+ * installed from the catalog.
585
+ */
586
+ catalog_item_id: ColumnType<string | null, string | null | undefined, string | null>;
587
+ catalog_version: ColumnType<string | null, string | null | undefined, string | null>;
588
+ }
589
+ /** 0024_skills.sql:技能的版本。 */
590
+ export interface SkillVersionsTable {
591
+ skill_id: string;
592
+ version: number;
593
+ manifest: Json<SkillManifest>;
594
+ object_prefix: string;
595
+ created_by: string;
596
+ created_at: Ts;
597
+ /**
598
+ * 0037, renamed in 0042: this version's enterprise catalog source (NULL for custom uploads /
599
+ * agent skills).
600
+ */
601
+ catalog_item_id: ColumnType<string | null, string | null | undefined, string | null>;
602
+ catalog_version: ColumnType<string | null, string | null | undefined, string | null>;
603
+ /** 0051: the format of the plugin this version came from. */
604
+ source_format: ColumnType<SourceFormat, SourceFormat | undefined, SourceFormat>;
605
+ /** 0051: the plugin suggests pinning this skill (spec §9.1). */
606
+ suggest_pinned: ColumnType<boolean, boolean | undefined, boolean>;
607
+ }
608
+ /** 0051: the format a plugin version was read from. */
609
+ export type SourceFormat = "capybara" | "claude-code";
610
+ /** 0026_skill_changes.sql:技能变更申请里提议的版本。 */
611
+ export interface ProposedSkillVersion {
612
+ /** 已有技能的 id,或新技能预先分配的 id。 */
613
+ skillId: string;
614
+ /** 批准后预期的版本号(试用时目录里用它)。 */
615
+ version: number;
616
+ manifest: SkillManifest;
617
+ }
618
+ /** 0026_skill_changes.sql:共享 agent 的技能变更申请(R4)。 */
619
+ export interface SkillChangeRequestsTable {
620
+ id: string;
621
+ org_id: string;
622
+ agent_id: string;
623
+ skill_id: string | null;
624
+ proposed_version: Json<ProposedSkillVersion>;
625
+ object_prefix: string;
626
+ requested_by_account: string;
627
+ requested_in_conversation: string;
628
+ status: Generated<"pending" | "approved" | "rejected" | "cancelled">;
629
+ decided_by: string | null;
630
+ decided_at: TsNullable;
631
+ created_at: Ts;
632
+ }
633
+ /** 0023_sandboxes.sql:按对话的沙箱(见 sandbox/sandbox.service.ts)。 */
634
+ export interface SandboxesTable {
635
+ conversation_id: string;
636
+ org_id: string;
637
+ provider: string;
638
+ /** 提供方的 `SandboxHandle`;creating 时为 NULL。 */
639
+ handle: ColumnType<{
640
+ id: string;
641
+ [k: string]: unknown;
642
+ } | null, string | null | undefined, string | null>;
643
+ status: "creating" | "running" | "suspended" | "destroyed";
644
+ last_used_at: Ts;
645
+ running_since: TsNullable;
646
+ created_at: Ts;
647
+ suspended_at: TsNullable;
648
+ destroyed_at: TsNullable;
649
+ /** 防护号:锁内的每次 status / handle 写入都按它比较并加一。 */
650
+ generation: ColumnType<number, number | undefined, number>;
651
+ /** 曾经成功创建过实例(只会置 true)。 */
652
+ had_instance: ColumnType<boolean, boolean | undefined, boolean>;
653
+ /** 换提供方时留下的旧实例。 */
654
+ prev_provider: string | null;
655
+ prev_handle: ColumnType<{
656
+ id: string;
657
+ [k: string]: unknown;
658
+ } | null, string | null | undefined, string | null>;
659
+ sweep_failed_at: TsNullable;
660
+ }
661
+ /** pg numeric:驱动读出为字符串(精确小数),读取方自行 `Number()`。 */
662
+ type Numeric = ColumnType<string, number | string, number | string>;
663
+ type NumericNullable = ColumnType<string | null, number | string | null, number | string | null>;
664
+ /** 0027_model_prices.sql:模型价格(每百万 token,币种为部署设置 priceCurrency)。 */
665
+ export interface ModelPricesTable {
666
+ provider: string;
667
+ model: string;
668
+ input_per_mtok: Numeric;
669
+ output_per_mtok: Numeric;
670
+ cache_read_per_mtok: NumericNullable;
671
+ cache_write_per_mtok: NumericNullable;
672
+ updated_by: string | null;
673
+ updated_at: Ts;
674
+ }
675
+ /** 0029_model_purposes.sql:模型用途映射(org_id 为 null = 部署默认;组织可覆盖)。 */
676
+ export interface ModelPurposeMappingsTable {
677
+ org_id: string | null;
678
+ purpose: string;
679
+ provider: string;
680
+ model: string;
681
+ params: Json;
682
+ updated_by: string | null;
683
+ updated_at: Ts;
684
+ }
685
+ /** 0028_evals.sql:评测集(一个集合对应一个 agent;软删除)。 */
686
+ export interface EvalSetsTable {
687
+ id: Generated<string>;
688
+ org_id: string;
689
+ agent_id: string;
690
+ name: string;
691
+ description: ColumnType<string, string | undefined, string>;
692
+ rubric: string | null;
693
+ created_by: string;
694
+ created_at: Ts;
695
+ updated_at: Ts;
696
+ deleted_at: TsNullable;
697
+ }
698
+ /** 0028_evals.sql:评测用例(某次运行的日志快照,不引用原对话)。 */
699
+ export interface EvalCasesTable {
700
+ id: Generated<string>;
701
+ set_id: string;
702
+ org_id: string;
703
+ source_conversation_id: string;
704
+ source_run_id: string;
705
+ agent_version: number;
706
+ title: string;
707
+ snapshot: Json<unknown>;
708
+ snapshot_bytes: number;
709
+ replayable_steps: ColumnType<number, number | undefined, number>;
710
+ /** 两种回放模式的计划(`StoredCasePlan`),写入时算好。 */
711
+ plan_step: Json<unknown>;
712
+ plan_run: Json<unknown>;
713
+ /** 用例原版本的模型(`ModelRef`);没有定义时为 null。 */
714
+ base_model: ColumnType<unknown | null, string | null | undefined, string | null>;
715
+ added_by: string;
716
+ created_at: Ts;
717
+ }
718
+ export type EvalRunStatus = "queued" | "running" | "completed" | "cancelled" | "capped" | "failed";
719
+ /** 0028_evals.sql:评测运行(T4 起写入)。 */
720
+ export interface EvalRunsTable {
721
+ id: Generated<string>;
722
+ org_id: string;
723
+ set_id: string;
724
+ mode: "step" | "run";
725
+ candidate: Json<unknown>;
726
+ judge: ColumnType<boolean, boolean | undefined, boolean>;
727
+ token_cap: Int8;
728
+ tokens_used: Int8;
729
+ status: ColumnType<EvalRunStatus, EvalRunStatus | undefined, EvalRunStatus>;
730
+ cases_total: number;
731
+ cases_done: ColumnType<number, number | undefined, number>;
732
+ consecutive_errors: ColumnType<number, number | undefined, number>;
733
+ error: ColumnType<unknown | null, string | null | undefined, string | null>;
734
+ estimate: Json<unknown>;
735
+ created_by: string;
736
+ created_at: Ts;
737
+ started_at: TsNullable;
738
+ finished_at: TsNullable;
739
+ }
740
+ export type EvalResultStatus = "pending" | "running" | "done" | "error" | "skipped";
741
+ /** 0029:评委状态(pending = 结果已 done、评委还没做)。 */
742
+ export type JudgeStatus = "none" | "pending" | "done" | "error" | "skipped";
743
+ /** 0028_evals.sql:评测结果(每用例一行或每步一行,T4 起写入)。 */
744
+ export interface EvalResultsTable {
745
+ id: Generated<string>;
746
+ run_id: string;
747
+ case_id: string;
748
+ org_id: string;
749
+ step: number | null;
750
+ model_call_seq: ColumnType<string | null, number | string | null | undefined, number | string | null>;
751
+ status: ColumnType<EvalResultStatus, EvalResultStatus | undefined, EvalResultStatus>;
752
+ baseline: ColumnType<unknown | null, string | null | undefined, string | null>;
753
+ candidate: ColumnType<unknown | null, string | null | undefined, string | null>;
754
+ diff: ColumnType<unknown | null, string | null | undefined, string | null>;
755
+ judge: ColumnType<unknown | null, string | null | undefined, string | null>;
756
+ drift: ColumnType<string[], string[] | undefined, string[]>;
757
+ error: ColumnType<unknown | null, string | null | undefined, string | null>;
758
+ eval_conversation_id: string | null;
759
+ claimed_by: ColumnType<string | null, string | null | undefined, string | null>;
760
+ judge_status: ColumnType<JudgeStatus, JudgeStatus | undefined, JudgeStatus>;
761
+ label: "pass" | "fail" | null;
762
+ label_note: string | null;
763
+ labeled_by: string | null;
764
+ labeled_at: TsNullable;
765
+ created_at: Ts;
766
+ updated_at: Ts;
767
+ }
768
+ /**
769
+ * 内核 schema(capybara)的表结构,逐列对应 0002_secrets.sql(secrets)、0003_identity.sql、
770
+ * 0005_agents.sql、0006_conversations.sql、0007_checkpoints.sql、0010_tools.sql、0011_approvals_spec.sql、0016_plugin_permissions.sql、0018_channels.sql 与 0019_identity_trust.sql。
771
+ */
772
+ /** 0030, renamed in 0041: content-addressed extension packages (sha256 = the whole tgz). */
773
+ export interface ExtensionPackagesTable {
774
+ sha256: string;
775
+ /** The extension manifest name. */
776
+ name: string;
777
+ /** The npm package name from package.json. */
778
+ package_name: string;
779
+ version: string;
780
+ size: Int8;
781
+ /**
782
+ * The plugin's reviewed extension section (`PluginExtensionSection` from plugin.json); rows stored
783
+ * before 0.1.0 hold the old `capybara` section of package.json (both carry the static manifest).
784
+ */
785
+ section: Json<unknown>;
786
+ blob_store: "object" | "pg";
787
+ source: "npm" | "file" | "catalog" | "bootstrap";
788
+ source_ref: string;
789
+ uploaded_by: string | null;
790
+ created_at: Ts;
791
+ }
792
+ /** 0030, renamed in 0041: package bytes when there is no object storage. */
793
+ export interface ExtensionBlobsTable {
794
+ sha256: string;
795
+ bytes: Buffer;
796
+ }
797
+ /** 0030, renamed in 0041: one install record (desired state) per extension. */
798
+ export interface ExtensionInstallsTable {
799
+ name: string;
800
+ sha256: string;
801
+ version: string;
802
+ source: "npm" | "file" | "catalog" | "bootstrap";
803
+ desired_state: ColumnType<"enabled" | "disabled", "enabled" | "disabled" | undefined>;
804
+ migrated_sha: string | null;
805
+ installed_by: string | null;
806
+ installed_at: Ts;
807
+ updated_by: string | null;
808
+ updated_at: Ts;
809
+ /** 0034 (F-AA): the source item when installed through the enterprise catalog. */
810
+ catalog_item_id: ColumnType<string | null, string | null | undefined, string | null>;
811
+ /**
812
+ * 0050: a required bootstrap plugin (enabled in every org without an org config row; cannot be
813
+ * disabled or uninstalled). Written only by the bootstrap step.
814
+ */
815
+ required: ColumnType<boolean, boolean | undefined, boolean>;
816
+ }
817
+ /** Which npm package owns an extension name (Ruling P3): written on first install, kept on uninstall. */
818
+ export interface ExtensionNameOwnersTable {
819
+ name: string;
820
+ package_name: string;
821
+ created_at: Generated<Date>;
822
+ }
823
+ /** 0032, renamed in 0041: non-secret fields of the deployment-level extension config (secrets in `secrets`, org_id `_deployment`). */
824
+ export interface ExtensionDeploymentConfigsTable {
825
+ plugin: string;
826
+ config: ColumnType<Record<string, unknown>, string | undefined, string>;
827
+ updated_by: string | null;
828
+ updated_at: Ts;
829
+ }
830
+ export interface ExtensionReplicaStatusTable {
831
+ replica_id: string;
832
+ plugin: string;
833
+ version: string;
834
+ sha256: string | null;
835
+ source: "config" | "install";
836
+ state: "loaded" | "failed" | "unloaded" | "pending";
837
+ reason: string | null;
838
+ detail: string | null;
839
+ /** The old version this replica still serves when this row's version did not load (see migration 0030). */
840
+ serving_version: Generated<string | null>;
841
+ http_replica_id: string | null;
842
+ heartbeat_at: Ts;
843
+ }
844
+ /** 0040: the usage.report sweeper's watermark (a single row, id = 1). */
845
+ export interface UsageReportSweepTable {
846
+ id: ColumnType<number, number | undefined, never>;
847
+ watermark: Ts;
848
+ updated_at: ColumnType<Date, Date | string | undefined, Date | string>;
849
+ }
850
+ export interface KernelDatabase {
851
+ accounts: AccountsTable;
852
+ identities: IdentitiesTable;
853
+ local_passwords: LocalPasswordsTable;
854
+ orgs: OrgsTable;
855
+ memberships: MembershipsTable;
856
+ invitations: InvitationsTable;
857
+ sessions: SessionsTable;
858
+ api_tokens: ApiTokensTable;
859
+ deployment_settings: DeploymentSettingsTable;
860
+ extension_org_configs: ExtensionOrgConfigsTable;
861
+ audit_events: AuditEventsTable;
862
+ secrets: SecretsTable;
863
+ agents: AgentsTable;
864
+ agent_versions: AgentVersionsTable;
865
+ agent_members: AgentMembersTable;
866
+ conversations: ConversationsTable;
867
+ conversation_events: ConversationEventsTable;
868
+ conversation_queue: ConversationQueueTable;
869
+ file_previewers: FilePreviewersTable;
870
+ runs: RunsTable;
871
+ subagent_dispatches: SubagentDispatchesTable;
872
+ agent_templates: AgentTemplatesTable;
873
+ agent_template_versions: AgentTemplateVersionsTable;
874
+ lg_checkpoints: LgCheckpointsTable;
875
+ lg_checkpoint_writes: LgCheckpointWritesTable;
876
+ connectors: ConnectorsTable;
877
+ connector_tools: ConnectorToolsTable;
878
+ tool_grants: ToolGrantsTable;
879
+ conversation_tool_grants: ConversationToolGrantsTable;
880
+ approvals: ApprovalsTable;
881
+ questions: QuestionsTable;
882
+ tool_outputs: ToolOutputsTable;
883
+ tool_specs: ToolSpecsTable;
884
+ extension_permission_snapshots: ExtensionPermissionSnapshotsTable;
885
+ channel_connections: ChannelConnectionsTable;
886
+ channel_threads: ChannelThreadsTable;
887
+ channel_deliveries: ChannelDeliveriesTable;
888
+ channel_card_messages: ChannelCardMessagesTable;
889
+ org_anonymous_accounts: OrgAnonymousAccountsTable;
890
+ directory_exclusions: DirectoryExclusionsTable;
891
+ attachments: AttachmentsTable;
892
+ sandboxes: SandboxesTable;
893
+ skills: SkillsTable;
894
+ skill_versions: SkillVersionsTable;
895
+ skill_change_requests: SkillChangeRequestsTable;
896
+ model_prices: ModelPricesTable;
897
+ eval_sets: EvalSetsTable;
898
+ eval_cases: EvalCasesTable;
899
+ eval_runs: EvalRunsTable;
900
+ eval_results: EvalResultsTable;
901
+ model_purpose_mappings: ModelPurposeMappingsTable;
902
+ extension_packages: ExtensionPackagesTable;
903
+ extension_blobs: ExtensionBlobsTable;
904
+ extension_installs: ExtensionInstallsTable;
905
+ extension_replica_status: ExtensionReplicaStatusTable;
906
+ usage_report_sweep: UsageReportSweepTable;
907
+ extension_name_owners: ExtensionNameOwnersTable;
908
+ extension_deployment_configs: ExtensionDeploymentConfigsTable;
909
+ catalog_items: CatalogItemsTable;
910
+ catalog_item_versions: CatalogItemVersionsTable;
911
+ marketplaces: MarketplacesTable;
912
+ marketplace_entries: MarketplaceEntriesTable;
913
+ plugin_import_staging: PluginImportStagingTable;
914
+ catalog_requests: CatalogRequestsTable;
915
+ catalog_org_grants: CatalogOrgGrantsTable;
916
+ plugin_installs: PluginInstallsTable;
917
+ plugin_install_components: PluginInstallComponentsTable;
918
+ extension_catalog_sources: ExtensionCatalogSourcesTable;
919
+ bootstrap_runs: BootstrapRunsTable;
920
+ }
921
+ /** 0050: one row per bootstrap manifest the bootstrap step completed. */
922
+ export interface BootstrapRunsTable {
923
+ /** sha256 (hex) of the bootstrap manifest. */
924
+ manifest_sha256: string;
925
+ completed_at: Ts;
926
+ results: ColumnType<unknown, string, string>;
927
+ }
928
+ /** 0034_directory.sql, renamed in 0042, one kind (plugin) since 0044: enterprise catalog items. */
929
+ export interface CatalogItemsTable {
930
+ id: string;
931
+ /** The plugin name (one live item per name). */
932
+ name: string;
933
+ /** 0046: null for a git plugin without package.json. */
934
+ package_name: string | null;
935
+ publisher: string;
936
+ display_name: ColumnType<{
937
+ zh: string;
938
+ en: string;
939
+ } | null, string | null | undefined, string | null>;
940
+ description: string;
941
+ policy: ColumnType<"allow" | "needs_approval" | "disabled", "allow" | "needs_approval" | "disabled" | undefined, "allow" | "needs_approval" | "disabled">;
942
+ latest_version: string;
943
+ created_by: string | null;
944
+ created_at: Generated<Date>;
945
+ updated_at: Ts;
946
+ deleted_at: ColumnType<Date | null, Date | string | null | undefined, Date | string | null>;
947
+ /** 0035, renamed in 0042: the marketplace it was imported from (null once that is deleted). */
948
+ marketplace_id: ColumnType<string | null, string | null | undefined, string | null>;
949
+ }
950
+ /**
951
+ * 0034, renamed in 0042, reshaped in 0044: the versions of an enterprise catalog item. `manifest` is
952
+ * the normalized plugin.json (skills and connector templates listed explicitly); `extension_sha256`
953
+ * the plugin's extension package in `extension_packages` (null without an extension); `files` the
954
+ * files stored under `object_prefix` (skills, connector templates, icons).
955
+ */
956
+ export interface CatalogItemVersionsTable {
957
+ item_id: string;
958
+ version: string;
959
+ manifest: Json<unknown>;
960
+ source: "file" | "npm" | "marketplace" | "git" | "bootstrap";
961
+ source_ref: string;
962
+ integrity: string | null;
963
+ /** 0046: where the plugin came from (git location, archive URL or npm registry). */
964
+ source_detail: ColumnType<Record<string, unknown> | null, string | null | undefined, string | null>;
965
+ /** 0046: the content digest of the imported files (null before phase A1). */
966
+ content_digest: ColumnType<string | null, string | null | undefined, string | null>;
967
+ object_prefix: string | null;
968
+ extension_sha256: string | null;
969
+ files: Json<{
970
+ path: string;
971
+ size: number;
972
+ sha256: string;
973
+ }[]>;
974
+ size: Int8;
975
+ imported_by: string | null;
976
+ imported_at: Generated<Date>;
977
+ /** 0051: the format the version was read from. */
978
+ source_format: ColumnType<SourceFormat, SourceFormat | undefined, SourceFormat>;
979
+ /** 0051: the translation report of a Claude Code plugin (null for a native plugin). */
980
+ translation: ColumnType<unknown | null, string | null | undefined, string | null>;
981
+ /** 0051: the root LICENSE text (at most 64 KiB). */
982
+ license_text: ColumnType<string | null, string | null | undefined, string | null>;
983
+ /** 0051: the root LICENSE was too long (or not UTF-8) to store. */
984
+ license_truncated: ColumnType<boolean, boolean | undefined, boolean>;
985
+ }
986
+ /** 0035_catalogs.sql, renamed in 0042: marketplaces (official / enterprise). */
987
+ export interface MarketplacesTable {
988
+ id: string;
989
+ name: string;
990
+ url: string;
991
+ mirrors: Json<string[]>;
992
+ builtin: ColumnType<boolean, boolean | undefined, boolean>;
993
+ enabled: ColumnType<boolean, boolean | undefined, boolean>;
994
+ etag: ColumnType<string | null, string | null | undefined, string | null>;
995
+ last_refreshed_at: ColumnType<Date | null, Date | string | null | undefined, Date | string | null>;
996
+ last_status: ColumnType<"ok" | "error" | "never", "ok" | "error" | "never" | undefined, "ok" | "error" | "never">;
997
+ last_error: ColumnType<string | null, string | null | undefined, string | null>;
998
+ created_by: ColumnType<string | null, string | null | undefined, string | null>;
999
+ created_at: Generated<Date>;
1000
+ /** 0046: http (a marketplace.json URL) or git (a repository). */
1001
+ form: ColumnType<"http" | "git", "http" | "git" | undefined, "http" | "git">;
1002
+ /** 0046: the git ref a git marketplace follows (null = the remote HEAD). */
1003
+ ref: ColumnType<string | null, string | null | undefined, string | null>;
1004
+ /** 0046: the commit of a git marketplace's last successful refresh. */
1005
+ last_commit: ColumnType<string | null, string | null | undefined, string | null>;
1006
+ /** 0046: the manifest's `owner.name` at the last successful refresh. */
1007
+ owner_name: ColumnType<string | null, string | null | undefined, string | null>;
1008
+ /** 0051: entries the last successful refresh could not store (`{ name, reason }[]`). */
1009
+ skipped: ColumnType<{
1010
+ name: string;
1011
+ reason: string;
1012
+ }[], string | undefined, string>;
1013
+ }
1014
+ /**
1015
+ * 0035, renamed in 0042, reshaped in 0044: cached marketplace entries (replaced as a whole on each
1016
+ * successful refresh). One row per `marketplace.json` entry, keyed `(source_id, name, version)`;
1017
+ * `version` is `''` for an entry without one; `npm` is the npm package of an npm source (else null).
1018
+ */
1019
+ export interface MarketplaceEntriesTable {
1020
+ source_id: string;
1021
+ name: string;
1022
+ version: ColumnType<string, string | undefined, string>;
1023
+ npm: ColumnType<string | null, string | null | undefined, string | null>;
1024
+ entry: Json<unknown>;
1025
+ /** 0047: the branch head of a branch-following git entry already imported (null: unknown). */
1026
+ head_commit: ColumnType<string | null, string | null | undefined, string | null>;
1027
+ /** 0048: the git tree oid of the entry's plugin directory (path entries; git entries with a path). */
1028
+ tree_oid: ColumnType<string | null, string | null | undefined, string | null>;
1029
+ /** 0051: the Claude marketplace entry's overlay (`ClaudeEntryOverlay`; null for a Capybara entry). */
1030
+ claude: ColumnType<unknown | null, string | null | undefined, string | null>;
1031
+ updated_at: Ts;
1032
+ }
1033
+ /**
1034
+ * 0036_app_import_staging.sql, renamed in 0043, reshaped in 0044: a staged plugin import (written by
1035
+ * prepare, deleted by confirm, expires after 24 hours). `manifest` holds what confirm writes.
1036
+ */
1037
+ export interface PluginImportStagingTable {
1038
+ id: string;
1039
+ review: Json<unknown>;
1040
+ manifest: Json<unknown>;
1041
+ object_prefix: string | null;
1042
+ source: Json<unknown>;
1043
+ created_by: string | null;
1044
+ created_at: Generated<Date>;
1045
+ expires_at: ColumnType<Date, Date | string, Date | string>;
1046
+ }
1047
+ type NullableCol<T> = ColumnType<T | null, T | null | undefined, T | null>;
1048
+ /**
1049
+ * 0037, renamed in 0042: an org's catalog requests (stage org = a member request; deployment =
1050
+ * waiting for enterprise admin approval).
1051
+ */
1052
+ export interface CatalogRequestsTable {
1053
+ id: string;
1054
+ org_id: string;
1055
+ item_id: string;
1056
+ version: NullableCol<string>;
1057
+ stage: "org" | "deployment";
1058
+ requested_by: string | null;
1059
+ note: ColumnType<string, string | undefined, string>;
1060
+ status: ColumnType<"pending" | "approved" | "rejected" | "cancelled", "pending" | "approved" | "rejected" | "cancelled" | undefined, "pending" | "approved" | "rejected" | "cancelled">;
1061
+ decided_by: NullableCol<string>;
1062
+ decided_at: NullableCol<Date>;
1063
+ org_decided_by: NullableCol<string>;
1064
+ org_decided_at: NullableCol<Date>;
1065
+ created_at: Generated<Date>;
1066
+ }
1067
+ /**
1068
+ * 0037, renamed in 0041: the catalog items that brought an extension into the deployment (plugin
1069
+ * and app items).
1070
+ */
1071
+ export interface ExtensionCatalogSourcesTable {
1072
+ plugin: string;
1073
+ item_id: string;
1074
+ created_at: Generated<Date>;
1075
+ }
1076
+ /** 0037, renamed in 0042: an enterprise admin's approval for an org to install a needs_approval item. */
1077
+ export interface CatalogOrgGrantsTable {
1078
+ item_id: string;
1079
+ org_id: string;
1080
+ granted_by: string | null;
1081
+ granted_at: Generated<Date>;
1082
+ }
1083
+ /** 0037:应用在组织里的安装。 */
1084
+ export interface PluginInstallsTable {
1085
+ id: string;
1086
+ org_id: string;
1087
+ item_id: string;
1088
+ version: string;
1089
+ /** 0049: `upgrading` while an in-place upgrade runs. */
1090
+ status: "installing" | "installed" | "failed" | "uninstalling" | "upgrading";
1091
+ installed_by: string | null;
1092
+ installed_at: Generated<Date>;
1093
+ error: ColumnType<unknown, string | null | undefined, string | null>;
1094
+ /**
1095
+ * 0049: the journal of the running upgrade, `{ id, from, to, startedAt, done }` with `done` the
1096
+ * `UpgradeStep`s of catalog/plugin-install.ts (read by `journalEntries`); null otherwise.
1097
+ */
1098
+ upgrade: ColumnType<unknown, string | null | undefined, string | null>;
1099
+ }
1100
+ /**
1101
+ * 0037: the components of a plugin install (created = this install created it); kind 'plugin'
1102
+ * (0045) is a dependency install, ref = its plugin_installs id.
1103
+ */
1104
+ export interface PluginInstallComponentsTable {
1105
+ install_id: string;
1106
+ /** 0053: 'agent_template', ref = the agent_templates id. */
1107
+ kind: "extension" | "connector" | "skill" | "plugin" | "agent_template";
1108
+ ref: string;
1109
+ created: boolean;
1110
+ skill_version: NullableCol<number>;
1111
+ /** 0049: the connector template a connector component was created from (null otherwise). */
1112
+ template_id: NullableCol<string>;
1113
+ /**
1114
+ * 0049: an upgrade removed the component from the plugin but kept it (an agent still uses it):
1115
+ * "no longer in the plugin"; still this install's for uninstall.
1116
+ */
1117
+ dropped: ColumnType<boolean, boolean | undefined, boolean>;
1118
+ }
1119
+ export type KernelDb = Kysely<KernelDatabase>;
1120
+ /** 把无类型的 Kysely 实例收窄成内核 schema 视图(`capybara`)。 */
1121
+ export declare function kernelDb(db: Kysely<any>): KernelDb;
1122
+ export {};